getEventCount($body); if( $eventCount > MAX_LIST ) { $pageCount = floor($eventCount / MAX_LIST) + 1; $this->echoln("

"); for( $p = 0; $p < $pageCount; $p++ ) { if( $pageCount < 20 || ($p == 0 || $p == $pageCount - 1) || abs($start / MAX_LIST - $p) <= 8 ) { $this->echoln("" . ($p + 1) . ""); }elseif( $pageCount >= 20 && abs($start / MAX_LIST - $p) == 9 ) { $this->echoln("..."); } } $this->echoln("

"); } $result = $this->getEvents($start, $body); if( $result->numRows() >= 1 ) { $this->echoln(""); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $r = 0; while( $row = $result->fetchAssoc() ) { $eventSelected = isset($selevent) && $selevent == strtolower($row['eventcode']); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); $this->echoln(" "); } $this->echoln("
StartEndTitleLocationBooksPhotos
" . substr($this->formatDate($row['datestart']), 0, 5) . "" . $this->formatDate($row['dateend']) . "" . $row['title'] . "" . $row['location'] . "" . $row['bookcount'] . "" . $row['photocount'] . "
"); if( $eventSelected ) { $this->echoln(EventHelper::getEventDetail($this->getDbMySQL(), $selevent)); } $this->echoln("
"); }else { $this->echoln("

No events found

"); } } private function getEvents($start, $body) { $queryBuilder = $this->createEventQuery($body); $queryBuilder->addField("event.eventcode", "eventcode"); $queryBuilder->addField("event.datestart", "datestart"); $queryBuilder->addField("event.dateend", "dateend"); $queryBuilder->addField("event.title", "title"); $queryBuilder->addField("event.location", "location"); $queryBuilder->addField(new DBMethodCount("book.id"), "bookcount"); $queryBuilder->addField(new DBMethodMin("book.id"), "book_id"); $queryBuilder->addField(new DBMethodSum("book.photocount"), "photocount"); if( $_SESSION['event_sort'] == "title" ) { $queryBuilder->addOrderAsc("title"); $queryBuilder->addOrderAsc("datestart"); $queryBuilder->addOrderAsc("dateend"); }else { $queryBuilder->addOrderDesc("datestart"); $queryBuilder->addOrderDesc("dateend"); $queryBuilder->addOrderAsc("title"); } $queryBuilder->setLimit(MAX_LIST); if( $start ) { $queryBuilder->setOffset($start); } $result = $this->getDbMySQL()->select($queryBuilder->toQuery()); return $result; } private function getEventCount($body) { $queryBuilder = $this->createEventQuery($body); $queryBuilder->addField("event.eventcode"); $result = $this->getDbMySQL()->select($queryBuilder->toQuery()); return $result->numRows(); } private function createEventQuery($body) { $queryBuilder = new QueryBuilder($this->getDbMySQL(), "event"); $queryBuilder->addLeftJoin("book", "eventcode", "event.eventcode"); if( isset($_GET['event']) ) { $queryBuilder->addWhereEquals("event.eventcode", $_GET['event']); }else { $queryBuilder->addHavingGreater(new DBMethodSum("book.photocount"), 0); if( isset($body) ) { $queryBuilder->addWhere(new DBWhereOr(new DBWhereEquals("event.bodycode", $body), new DBWhereEquals("event.bodycode2", $body))); } } $queryBuilder->addGroup("event.eventcode"); $queryBuilder->addGroup("event.datestart"); $queryBuilder->addGroup("event.dateend"); $queryBuilder->addGroup("event.title"); $queryBuilder->addGroup("event.location"); return $queryBuilder; } } ?>