name = "[Personenliste]"; $this->allowedChildObjects = array("person", "separator"); $this->buttonPublish = true; $this->buttonPreview = true; $this->editable = USER_GROUP; } /** @see CmsObject::load() */ //----------------------------------------------- function load($path=array()){ //----------------------------------------------- parent::load($path); if(!$this->classId){ return; } $query = sprintf("SELECT * FROM bruckm_personlist WHERE id = %d", $this->classId); $result = dbQuery($query); $line = mysqli_fetch_array($result, MYSQLI_ASSOC); $this->template = $line['template']; } /** @see Page::doSave() */ //---------------------------------------------- function doSave(){ //---------------------------------------------- $query = sprintf("UPDATE bruckm_personlist SET template = %s WHERE id = %d", sqlstring($this->template), sqlnum($this->classId)); dbQuery($query); parent::doSave(); } /** @see Page::doCreate() */ //---------------------------------------------- function doCreate(){ //---------------------------------------------- $query = sprintf("INSERT INTO bruckm_personlist (template) VALUES (%s)", sqlstring($this->template)); dbQuery($query); $this->classId = mysql_insert_id(); parent::doCreate(); } /** @see Page::doDelete() */ //----------------------------------------------- function doDelete(){ //----------------------------------------------- parent::doDelete(); $query = sprintf("DELETE FROM bruckm_personlist WHERE id = %d LIMIT 1", $this->classId); dbQuery($query); } /** @see Page::install() */ //----------------------------------------------- function install(){ //----------------------------------------------- $query = sprintf("CREATE TABLE IF NOT EXISTS bruckm_personlist ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, template VARCHAR(100) NOT NULL, PRIMARY KEY (id) )"); dbQuery($query); } /** @see CmsObject::update() */ //----------------------------------------------- function update(){ //----------------------------------------------- parent::update(); if(isset($_POST['template'])){ $this->template = $_POST['template']; } } /** @see CmsObject::doPrintClassContent() */ //----------------------------------------------- function doPrintClassContent(){ //----------------------------------------------- $t = new Template(CMS_TEMPLATE_DIR."stdpage.html"); $templates = ""; $templateFiles = array(); $dir = opendir(TEMPLATE_DIR); while($file = readdir($dir)){ if(is_file(TEMPLATE_DIR.$file)){ $templateFiles[] = $file; } } sort($templateFiles); foreach($templateFiles as $file){ if($file == $this->template){ $templates .= ""; } else{ $templates .= "\n"; } } $t->setVar("TEMPLATES", $templates); if($_SESSION['userlevel'] == USER_ADMIN){ $t->setVar("TEMPLATE_DISABLED", ""); } else{ $t->setVar("TEMPLATE_DISABLED", "disabled=\"disabled\""); } return $t->toString(); } /** @see CmsObject::publish() */ //--------------------------------------------- function doPublish(){ //--------------------------------------------- $t = new Template(TEMPLATE_DIR.$this->template); $content = "

".$this->toString()."

"; $j = 0; for($i = 0; $i < sizeof($this->childObjects); $i++) { $child = $this->childObjects[$i]; $load = !$child->isLoaded(); if($load){ $child->load(); } if($child->isVisible()){ $child->publish(); $content .= $child->publishForPersonList($j%2); if(strtolower(get_class($child)) == "person"){ $j++; } } if($load){ $child->unload(); } } $t->setVar("CONTENT", $content); if(!$this->parentObj){ $this->parentObj = FlexiconFactory::instanceById($this->parentId); } if(!$this->parentObj->isLoaded()){ $this->parentObj->load(); } $t = $this->parentObj->printMenu($t); $t->setVar("TITLE", $this->toString()); return $t->toString(); } /** @see CmsObject::canBePublished() */ //---------------------------------------------- function canBePublished(){ //---------------------------------------------- /*if(sizeof($this->childObjects) == 0 && $this->visible){ $this->addError("Die Personenliste ist leer!"); return false; }*/ $ok = true; for($i = 0; $i < sizeof($this->childObjects); $i++) { $child = $this->childObjects[$i]; $load = !$child->isLoaded(); if($load){ $child->load(); } if(!$child->canBePublished()){ if($ok){ $ok = false; $this->addError("Ein oder mehere Seiten können nicht veröffentlicht werden!"); } $this->addError($child->getErrors()); } if($load){ $child->unload(); } } return $ok; } /** @see Element::getCssClass() */ //------------------------------------------------ function getCssClass(){ //------------------------------------------------ return "itemPersonPage"; } // === ADDITIONAL METHODS ============================================================== // /** returns the name of the template file * @return template */ //----------------------------------------------- function getTemplate(){ //----------------------------------------------- return $this->template; } /** returns the Menu object * @return Menu */ //----------------------------------------------- function getMenu(){ //----------------------------------------------- if(!$this->parentObj){ $this->parentObj = FlexiconFactory::instanceById($this->parentId); } if(!$this->parentObj->isLoaded()){ $this->parentObj->load(); } return $this->parentObj; } }; ?>