name = "[Veranstaltungsliste]"; $this->category = 0; $this->type = "current"; $this->houseId = 0; $this->dynamic = true; $this->buttonPreview = true; $this->buttonPublish = true; $this->template = ""; $this->editable = USER_ADMIN; } /** @see Page::install() */ //----------------------------------------------- function install(){ //----------------------------------------------- $query = sprintf("CREATE TABLE IF NOT EXISTS bruckm_eventlist ( id INT NOT NULL AUTO_INCREMENT, category INT UNSIGNED NOT NULL DEFAULT 0, type ENUM('current','archive','artist') NOT NULL DEFAULT 'current', template VARCHAR(100) NOT NULL DEFAULT '', houseId INT NOT NULL DEFAULT 0, PRIMARY KEY (id) )"); dbQuery($query); } /** @see CmsObject::load() */ //----------------------------------------------- function load($path=array()){ //----------------------------------------------- parent::load($path); if(!$this->classId){ return; } $query = sprintf("SELECT * FROM bruckm_eventlist WHERE id = %d", $this->classId); $result = dbQuery($query); $line = mysqli_fetch_array($result, MYSQLI_ASSOC); $this->category = $line['category']; $this->type = $line['type']; $this->template = $line['template']; $this->houseId = $line['houseId']; } /** @see Page::doSave() */ //---------------------------------------------- function doSave(){ //---------------------------------------------- $query = sprintf("UPDATE bruckm_eventlist SET category = %s, type = %s, template = %s, houseId = %d WHERE id = %d", sqlstring($this->category), sqlstring($this->type), sqlstring($this->template), sqlnum($this->houseId), sqlnum($this->classId)); dbQuery($query); parent::doSave(); } /** @see Page::doCreate() */ //---------------------------------------------- function doCreate(){ //---------------------------------------------- $query = sprintf("INSERT INTO bruckm_eventlist (category) VALUES (%s)", sqlstring($this->category)); dbQuery($query); $this->classId = mysql_insert_id(); parent::doCreate(); } /** @see Page::doDelete() */ //----------------------------------------------- function doDelete(){ //----------------------------------------------- parent::doDelete(); $query = sprintf("DELETE FROM bruckm_eventlist WHERE id = %d LIMIT 1", $this->classId); dbQuery($query); } /** @see CmsObject::update() */ //----------------------------------------------- function update(){ //----------------------------------------------- parent::update(); $this->category = $_POST['category']; $this->type = $_POST['type']; $this->houseId = $_POST['houseId']; if(isset($_POST['template'])){ $this->template = $_POST['template']; } } /** @see CmsObject::doPrintClassContent() */ //----------------------------------------------- function doPrintClassContent(){ //----------------------------------------------- $t = new Template(CMS_TEMPLATE_DIR."eventlist.html"); $options = ""; $query = sprintf("SELECT id,name FROM bruckm_index WHERE class = 'TicketCategory' ORDER BY name ASC"); $result = dbQuery($query); while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){ if($line['id'] == $this->category){ $options .= ""; } else{ $options .= ""; } } $t->setVar("CATEGORIES", $options); if($this->type == "current"){ $t->setVar("TYPE_CURRENT", "selected=\"selected\""); $t->setVar("TYPE_ARCHIVE", ""); $t->setVar("TYPE_ARTIST", ""); } else if($this->type == "artist"){ $t->setVar("TYPE_ARTIST", "selected=\"selected\""); $t->setVar("TYPE_ARCHIVE", ""); $t->setVar("TYPE_CURRENT", ""); } else{ $t->setVar("TYPE_ARCHIVE", "selected=\"selected\""); $t->setVar("TYPE_CURRENT", ""); $t->setVar("TYPE_ARTIST", ""); } $templates = ""; $dir = opendir(TEMPLATE_DIR); while($file = readdir($dir)){ if(is_file(TEMPLATE_DIR.$file)){ if($file == $this->template){ $templates .= ""; } else{ $templates .= "\n"; } } } $t->setVar("TEMPLATES", $templates); if($this->isEditable()){ $t->setVar("TEMPLATE_DISABLED", ""); } else{ $t->setVar("TEMPLATES_DISABLED", "disabled=\"disabled\""); } // houses $query = sprintf("SELECT * FROM bruckm_house ORDER BY position ASC"); $result = dbQuery($query); $houses = ""; while ($line = mysqli_fetch_array($result, MYSQLI_ASSOC)) { if ($line['id'] == $this->houseId) { $houses .= ''; } $t->setVar("HOUSES", $houses); 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; } return true; } /** @see CmsObject::publish() */ //--------------------------------------------- function doPublish(){ //--------------------------------------------- if(isset($_GET['event'])){ return $this->printEvent($_GET['event']); } $t = new Template(TEMPLATE_DIR.$this->template); $content = "

".$this->toString()."

"; $content .= $this->printCustomerInfo(); $content .= $this->printCategories(); if($this->type == "current"){ $content .= $this->printCurrentEvents(); } else if($this->type == "artist"){ $content .= $this->printArtistEvents(); } else { $content .= $this->printPastEvents(); } $t->setVar("CONTENT", $content); 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::show() */ //------------------------------------------------ function show(){ //------------------------------------------------ if($this->canBePublished()){ return $this->doPublish(); } } /** @see CmsObject::getCssClass() */ //------------------------------------------------ function getCssClass(){ //------------------------------------------------ return "itemTicketEvent"; } // === ADDITIONAL METHODS ============================================== // /** prints a category selector * @return string */ //------------------------------------------------ function printCategories(){ //------------------------------------------------ if(isset($_GET['category'])){ $category = $_GET['category']; } else{ $category = $this->category; } ### BEGIN HACK: exclude events, tanz, seminar, kino ### $query = sprintf("SELECT id,name FROM bruckm_index WHERE class = 'TicketCategory' AND id NOT IN (201, 203, 1993, 2041) ORDER BY name ASC"); ### END HACK ### $result = dbQuery($query); $out = "
"; if($category == 0){ $out .= "alle"; } else{ $out .= "id."&category=0\" target=\"_self\" class=\"sans\">alle"; } while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){ $out .= " | "; if($category == $line['id']){ $out .= "".htmlspecialchars($line['name']).""; } else{ $out .= "id."&category=$line[id]\" target=\"_self\" class=\"sans\">".htmlspecialchars($line['name']).""; } } ### BEGIN HACK: add 'events' to the end of the list ### $out .= " | "; if($category == 203){ $out .= "Event"; } else{ $out .= "id."&category=203\" target=\"_self\" class=\"sans\">Event"; } ### END HACK ### $out .= "

"; return $out; } /** prints a section with additional infos for customers * @return string */ //------------------------------------------------ function printCustomerInfo(){ //------------------------------------------------ $t = new Template(TEMPLATE_DIR."subparts/events-info.html"); return $t->toString(); } /** prints current events for the selected category * @return string */ //---------------------------------------------- function printCurrentEvents(){ //---------------------------------------------- global $IGNORED_EVENTS; // see include/events.inc.php if(isset($_GET['category'])){ $category = $_GET['category']; } else{ $category = $this->category; } $query = sprintf("SELECT flexiconId FROM bruckm_ticketevent WHERE endDate >= '%s' ", date("Y-m-d")); if ($this->houseId != 0) { $query .= sprintf("AND (houseId = %d OR houseId = 0) ", $this->houseId); } if ($category != 0) { $query .= sprintf("AND (category1 = %d OR category2 = %d OR category3 = %d) ", sqlnum($category), sqlnum($category), sqlnum($category)); } $query .= "ORDER BY startDate ASC, endDate DESC"; $result = dbQuery($query); $out = ""; $i = 1; $navi = "
"; $years = array(); $currYear = date ("Y"); while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){ $event = FlexiconFactory::instanceById($line['flexiconId'], $this); $event->load(); if($event->isVisible() && !in_array($line['flexiconId'], $IGNORED_EVENTS)){ $y = $event->getYear(true); if ($y < $currYear) $y = $currYear; if(!in_array($y, $years)){ $years[] = $y; $out .= "

$y

"; $navi .= "$y | "; } $out .= $event->publishForEventList($this->id, $i%2); $i++; } } if (sizeof($years) > 1) { $out = substr($navi, 0, strlen($navi)-2) . "
" . $out; } return $out; } /** prints past events for the selected category * @return string */ //---------------------------------------------- function printPastEvents(){ //---------------------------------------------- if(isset($_GET['category'])){ $category = $_GET['category']; } else{ $category = $this->category; } $query = "SELECT flexiconId FROM bruckm_ticketevent WHERE endDate < NOW() "; if ($this->houseId != 0) { $query .= sprintf("AND (houseId = %d OR houseId = 0) ", $this->houseId); } if ($category != 0) { $query .= sprintf("AND (category1 = %d OR category2 = %d OR category3 = %d) ", sqlnum($category), sqlnum($category), sqlnum($category)); } $query .= "ORDER BY endDate DESC"; $result = dbQuery($query); $out = ""; $navi = "
"; $i = 1; $years = array(); while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){ $event = FlexiconFactory::instanceById($line['flexiconId'], $this); $event->load(); if($event->isVisible()){ $y = $event->getYear(); if(!in_array($y, $years)){ $years[] = $y; $out .= "

$y

"; $navi .= "$y | "; } $out .= $event->publishForEventList($this->id, $i%2); $i++; } } $navi = substr($navi, 0, strlen($navi)-2) . "
"; $out = $navi . $out; return $out; } /** prints past events for the selected category * @return string */ //---------------------------------------------- function printArtistEvents(){ //---------------------------------------------- $excludeIds = array( 281, 339, 375, 379, 411, 423, 431, 437, 449, 459, 465, 471, 483, 489, 503, 507, 521, 557, 561, 655, 750, 807, 869, 899, 906, 987, 991, 1083, 1093, 1095, 1137, 1308, 1310, 1425, 1448, 1595, 1598, 1643, 1671, 1723, 1751, 1756, 1770, 1805, 1817, 1892, 1926, 1941, 1956, 2156, 2173, 2178, 2193, 2205, 2214, 2236 ); if(isset($_GET['category'])){ $category = $_GET['category']; } else{ $category = $this->category; } $query = "SELECT flexiconId FROM bruckm_ticketevent WHERE endDate < NOW() "; if ($this->houseId != 0) { $query .= sprintf("AND (houseId = %d OR houseId = 0) ", $this->houseId); } if ($category != 0) { $query .= sprintf("AND (category1 = %d OR category2 = %d OR category3 = %d) ", sqlnum($category), sqlnum($category), sqlnum($category)); } $query .= "ORDER BY endDate DESC"; $result = dbQuery($query); $out = ""; $navi = "
"; $i = 1; $years = array(); while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){ if (!in_array($line['flexiconId'], $excludeIds)) { $event = FlexiconFactory::instanceById($line['flexiconId'], $this); $event->load(); if($event->isVisible()){ $y = $event->getYear(); if(!in_array($y, $years)){ $years[] = $y; $out .= "

$y

"; $navi .= "$y | "; } $out .= $event->publishForEventList($this->id, $i%2); $i++; } } } $navi = substr($navi, 0, strlen($navi)-2) . "
"; $out = $navi . $out; return $out; } /** prints single view of an event * @param id event id * @return string */ //------------------------------------------------- function printEvent($id){ //------------------------------------------------- $event = FlexiconFactory::instanceById($id, $this); if (!$event) { header('Location: http://www.bruckmuehle.at'); exit; } $event->load(); return $event->show(); } /** 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); } $parent = clone($this->parentObj); $parent->load(); return $parent; } }; ?>