251 lines
6.1 KiB
PHP
251 lines
6.1 KiB
PHP
<?php
|
|
|
|
/** Press List
|
|
*
|
|
* @version 1.0.0
|
|
* @since 2009-03-19
|
|
* @author Martin Lenzelbauer
|
|
*/
|
|
class PressList extends Page{
|
|
|
|
var $template;
|
|
|
|
|
|
/** C'tor
|
|
*/
|
|
//------------------------------------------------
|
|
function PressList($id, $parent){
|
|
//------------------------------------------------
|
|
parent::Page($id, $parent);
|
|
$this->name = "[Presseinformationen]";
|
|
$this->allowedChildObjects = array("pressinfo", "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_presslist 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_presslist 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_presslist (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_presslist WHERE id = %d LIMIT 1", $this->classId);
|
|
dbQuery($query);
|
|
}
|
|
|
|
|
|
/** @see Page::install()
|
|
*/
|
|
//-----------------------------------------------
|
|
function install(){
|
|
//-----------------------------------------------
|
|
$query = sprintf("CREATE TABLE IF NOT EXISTS bruckm_presslist (
|
|
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 .= "<option value=\"$file\" selected=\"selected\">$file</option>";
|
|
}
|
|
else{
|
|
$templates .= "<option value=\"$file\">$file</option>\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 = "<h1>".$this->toString()."</h1>";
|
|
$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->publishForPressList($j%2);
|
|
if(strtolower(get_class($child)) == "pressinfo"){
|
|
$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 Presseliste 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 "itemPressList";
|
|
}
|
|
|
|
|
|
// === 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;
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
?>
|