SetInitialValues(); } function SetInitialValues() { $this->id = -1; $this->name = ''; $this->content = ''; $this->stylesheet = ''; $this->encoding = ''; $this->active = false; $this->default = false; $this->modified_date = 0; } function Id() { return $this->id; } function Name() { return $this->name; } function UsageCount() { $gCms = cmsms(); $templateops = $gCms->GetTemplateOperations(); if ($this->id > -1) return $templateops->UsageCount($this->id); else return 0; } function Save() { $result = false; $gCms = cmsms(); $templateops = $gCms->GetTemplateOperations(); if ($this->id > -1) { $result = $templateops->UpdateTemplate($this); $this->modified_date = time(); } else { $newid = $templateops->InsertTemplate($this); if ($newid > -1) { $this->id = $newid; $this->modified_date = time(); $result = true; } } return $result; } function Delete() { $result = false; if ($this->id > -1) { $gCms = cmsms(); $templateops = $gCms->GetTemplateOperations(); $result = $templateops->DeleteTemplateByID($this->id); if ($result) { $this->SetInitialValues(); } } return $result; } } # vim:ts=4 sw=4 noet ?>