<?php
Class ManageService extends Management {
private $service;
public function __construct(){
parent::__construct();
$this->service = new ServicesDef();
$servicemon = new ServiceMon();
$this->service->registerObserver($servicemon);
}
public function show(){
parent::show();
}
public function remove(){
parent::remove();
}
public function removeItem(){
$this->service->remove($_POST['id']);
}
public function populateShowContent(){
$array_column = array('Service Name','Port','Description');
$this->xml->addTable($this->service->select($this->offset,$this->pglimit),
$array_column,'Table Service Definition',$this->navigator->getAccess($this),$this->offset,'rightcontent',0);
}
public function populateAddForm(){
$this->xml->addTextField('Service Name',null,'name','text');
$this->xml->addTextField('Port',null,'port','text');
$this->xml->addTextField('Description',null,'description','text');
}
public function populateEditForm(){
$this->service->selectByID($_POST['id']);
$this->xml->addTextField('Service Name',$this->service->getName(),'name','text');
$this->xml->addTextField('Port',$this->service->getPort(),'port','text');
$this->xml->addTextField('Description',$this->service->getDescription(),'description','text');
}
//return string to set the title
public function getTitle(){
return SITENAME.' -service';
}
public function getFormPlace(){
return 'panel';
}
public function editItem(){
$array = array('name'=>$_POST['name'],'port'=>$_POST['port'],'description'=>$_POST['description']);
return $this->service->update($array,$_POST['id']);
}
public function getKeyVar(){
return 'name';
}
public function getTotal(){
return $this->service->getTotal();
}
public function addItem(){
$array = array('',$_POST['name'],$_POST['port'],$_POST['description']);
$this->service->add($array);
}
public function checkAdd(){
if($_POST['port']==''){
die('Port number should not be empty');
}
}
public function checkEdit(){
$this->checkAdd();
}
}
?>