name = "[unbenannte Website]"; $this->buttonPublish = true; $this->editable = USER_ADMIN; $this->allowedChildObjects = array("menu", "indexpage"); } /** @see DBElement::canBeDeleted() */ //---------------------------------------------- function canBeDeleted(){ //---------------------------------------------- $this->addError("Die Website darf nicht gelöscht werden!"); return false; } /** @see CmsObject::doPublish() */ //---------------------------------------------- function doPublish(){ //---------------------------------------------- for($i = 0; $i < sizeof($this->childObjects); $i++){ $child = $this->childObjects[$i]; $load = !$child->isLoaded(); if($load){ $child->load(); } $child->publish(); if($load){ $child->unload(); } } } /** @see CmsObject::canBePublished() */ //--------------------------------------------- function canBePublished(){ //--------------------------------------------- $index = 0; $menu = 0; for($i = 0; $i < sizeof($this->childObjects); $i++){ $child = $this->childObjects[$i]; if(strtolower(get_class($child)) == "menu"){ $menu++; } else if(strtolower(get_class($child)) == "indexpage"){ $index++; } } if($index != 1){ logError(1, "No index page", __FILE__, __LINE__); $this->addError("Die Website muss eine Indexseite besitzen!"); return false; } /*if($menu != 6){ logError(1, "Wrong menu items count ($menu)", __FILE__, __LINE__); $this->addError("Die Website muss genau 6 Menüpunkte besitzen!"); 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 "itemWebsite"; } // === ADDITIONAL METHODS =========================================================== // /** prints the main menu * @param t template to print the menu in (variable "MENU") * @return template */ //------------------------------------------- function printMenu($t){ //------------------------------------------- $menu = ""; $count = 0; for($i = 0; $i < sizeof($this->childObjects); $i++){ $child = $this->childObjects[$i]; if(strtolower(get_class($child)) == "menu"){ $load = !$child->isLoaded(); if($load){ $child->load(); } if (!$child->isVisible()) { continue; } $menu .= sprintf( '', $count + 1, $child->getStartPage(), $child->toString() ); $count++; if($load){ $child->unload(); } } } $t->setVar("MENU", $menu); return $t; } }; ?>