name = "[unbenannte PHP-Seite]"; $this->phpfile = ""; $this->template = ""; $this->dynamic = true; $this->editable = USER_ADMIN; $this->buttonPublish = true; $this->buttonPreview = true; } /** @see CmsObject::load() */ //----------------------------------------------- function load($path=array()){ //----------------------------------------------- parent::load($path); if(!$this->classId){ return; } $query = sprintf("SELECT * FROM bruckm_phppage WHERE id = %d", $this->classId); $result = dbQuery($query); $line = mysqli_fetch_array($result, MYSQLI_ASSOC); $this->template = $line['template']; $this->phpfile = $line['phpfile']; } /** @see Page::doSave() */ //---------------------------------------------- function doSave(){ //---------------------------------------------- $query = sprintf("UPDATE bruckm_phppage SET template = %s, phpfile = %s WHERE id = %d", sqlstring($this->template), sqlstring($this->phpfile), sqlnum($this->classId)); dbQuery($query); parent::doSave(); } /** @see Page::doCreate() */ //---------------------------------------------- function doCreate(){ //---------------------------------------------- $query = sprintf("INSERT INTO bruckm_phppage (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_phppage WHERE id = %d LIMIT 1", $this->classId); dbQuery($query); } /** @see Page::install() */ //----------------------------------------------- function install(){ //----------------------------------------------- $query = sprintf("CREATE TABLE IF NOT EXISTS bruckm_phppage ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, template VARCHAR(100) NOT NULL DEFAULT '', phpfile VARCHAR(100) NULL DEFAULT '', PRIMARY KEY (id) )"); dbQuery($query); } /** @see CmsObject::update() */ //----------------------------------------------- function update(){ //----------------------------------------------- parent::update(); if(isset($_POST['template'])){ $this->template = $_POST['template']; } if(isset($_POST['phpfile'])){ $this->phpfile = $_POST['phpfile']; } } /** @see CmsObject::doPrintClassContent() */ //----------------------------------------------- function doPrintClassContent(){ //----------------------------------------------- $t = new Template(CMS_TEMPLATE_DIR."phppage.html"); //templates $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); //php scripts $phpfiles; $dir = opendir(PHP_SCRIPT_DIR); while($file = readdir($dir)){ if(is_file(PHP_SCRIPT_DIR.$file)){ if($file == $this->phpfile){ $phpfiles .= ""; } else{ $phpfiles .= "\n"; } } } $t->setVar("PHP_SCRIPTS", $phpfiles); if($this->isEditable()){ $t->setVar("TEMPLATE_DISABLED", ""); $t->setVar("PHP_SCRIPT_DISABLED", ""); } else{ $t->setVar("TEMPLATES_DISABLED", "disabled=\"disabled\""); $t->setVar("PHP_SCRIPT_DISABLED", "disabled=\"disabled\""); } return $t->toString(); } /** @see CmsObject::canBePublished() */ //---------------------------------------------- function canBePublished(){ //---------------------------------------------- if(empty($this->template)){ logError(3, "No template selected", __FILE__, __LINE__); $this->addError("Bitte wählen Sie ein Template aus!"); return false; } if(empty($this->phpfile)){ logError(3, "No PHP script selected", __FILE__, __LINE__); $this->addError("Bitte wählen Sie ein PHP-Script aus!"); return false; } return true; } /** @see CmsObject::doPublish() */ //---------------------------------------------- function doPublish(){ //---------------------------------------------- return ""; } /** @see CmsObject:show() */ //---------------------------------------------- function show(){ //---------------------------------------------- require_once(PHP_SCRIPT_DIR.$this->phpfile); $t = new Template(TEMPLATE_DIR.$this->template); $t->setVar("CONTENT", doPhpScript($this)); if(!$this->parentObj){ $this->parentObj = FlexiconFactory::instanceById($this->parentId); } $parent = clone($this->parentObj); $parent->load(); $t = $parent->printMenu($t); $t->setVar("TITLE", $this->toString()); return $t->toString(); } /** @see CmsObject::preview() */ //--------------------------------------------- function preview(){ //--------------------------------------------- return $this->show(); } /** @see CmsObject::getCssClass() */ //------------------------------------------------ function getCssClass(){ //------------------------------------------------ return "itemPhpPage"; } }; ?>