echoln("

Back to events

"); $eventInfo = $this->getEventInfo(isset($_GET['photo'])); $size = $this->getRequestSize(); $photo = $this->getRequestPhoto($eventInfo['photocount']); $start = $this->getRequestStart($eventInfo['photocount']); if( $photo == null && !isset($_GET['photo']) ) { $this->showEventInfo($eventInfo); } if( $size == "thumb" ) { $this->echoln("

All pictures on one page in big size.

"); } $buttons = $this->getButtons($eventInfo['photocount'], $size, $photo, $start); $this->echoln($buttons); $photoResult = $this->getPhotos($size, $photo, $start); $this->showPhotos($photoResult, $size); $this->echoln($buttons); } private function getRequestSize() { if( isset($_GET['size']) && in_array($_GET['size'], array("thumb", "normal", "big")) ) { return $_GET['size']; }else { return "thumb"; } } private function getRequestPhoto($photocount) { if( isset($_GET['photo']) && is_numeric($_GET['photo']) && $_GET['photo'] >= 1 && $_GET['photo'] <= $photocount ) { return $_GET['photo']; }else { return null; } } private function getRequestStart($photocount) { if( isset($_GET['start']) && is_numeric($_GET['start']) && $_GET['start'] >= 1 && $_GET['start'] <= $photocount ) { return $_GET['start']; }else { return 1; } } private function getEventInfo($minimal = false) { $queryBuilder = new QueryBuilder($this->getDbMySQL(), "book"); $queryBuilder->addField("book.photocount", "photocount"); if( !$minimal ) { $queryBuilder->addField("book.title", "title"); $queryBuilder->addField("book.comment", "comment"); $queryBuilder->addField("event.title", "eventtitle"); $queryBuilder->addField("event.topic", "eventtopic"); $queryBuilder->addField("event.projectname", "projectname"); $queryBuilder->addField("event.location", "location"); $queryBuilder->addField("event.datestart", "datestart"); $queryBuilder->addField("event.dateend", "dateend"); $queryBuilder->addField("event.eventtype", "eventtype"); $queryBuilder->addField("event.area", "eventarea"); $queryBuilder->addField("event.eventrating", "eventrating"); $queryBuilder->addField("event.eventcode", "eventcode"); $queryBuilder->addField("organiser1.bodyname", "organiser1"); $queryBuilder->addField("organiser2.bodyname", "organiser2"); $queryBuilder->addField("event.bodycode2", "bodycode2"); $queryBuilder->addField("user.name", "owner"); $queryBuilder->addField("userlocal.bodyname", "ownerlocal"); $queryBuilder->addInnerJoin("event", "eventcode", "book.eventcode"); $queryBuilder->addLeftJoin("ab_bodies", "bodycode", "event.bodycode", "organiser1"); $queryBuilder->addLeftJoin("ab_bodies", "bodycode", "event.bodycode2", "organiser2"); $queryBuilder->addInnerJoin("user", "uid", "book.uid"); $queryBuilder->addLeftJoin("ab_bodies", "bodycode", "user.bodycode", "userlocal"); } $queryBuilder->addWhereEquals("book.id", $_GET['book']); $result = $this->getDbMySQL()->select($queryBuilder->toQuery()); if( $result->numRows() == 1 ) { $event = $result->fetchAssoc(); if( $minimal || $event['organiser1'] == "" || $event['organiser1'] == "XXX" ) { $event['organiser2'] = null; } return $event; }else { return null; } } private function showEventInfo($eventInfo) { $this->echoln("
"); $this->echoln("
Event:" . $eventInfo['eventtitle'] . "
"); $this->echoln("
Date:" . $this->formatDate($eventInfo['datestart']) . " until " . $this->formatDate($eventInfo['dateend']) . "
"); $this->echoln("
Organised by:" . $eventInfo['organiser1'] . (!empty($eventInfo['organiser2']) ? " & " . $eventInfo['organiser2'] : "") . "
"); if( !empty($eventInfo['eventtopic']) ) { $this->echoln("
Topic:" . $eventInfo['eventtopic'] . "
"); } if( !empty($eventInfo['projectname']) ) { $this->echoln("
Part of project:" . $eventInfo['projectname'] . "
"); } if( !empty($eventInfo['location']) ) { $this->echoln("
Location:" . $eventInfo['location'] . "
"); } if( !empty($eventInfo['eventtype']) ) { $this->echoln("
Event type:" . $eventInfo['eventtype'] . "
"); } if( !empty($eventInfo['eventarea']) ) { $this->echoln("
Area:" . $eventInfo['eventarea'] . "
"); } if( !empty($eventInfo['eventrating']) ) { $this->echoln("
Rating:" . $eventInfo['eventrating'] . "
"); } $this->echoln("
"); $this->echoln("
Photos by:" . $eventInfo['owner'] . " (" . $eventInfo['ownerlocal'] . ")
"); $this->echoln("
"); $this->echoln("
Book:" . $eventInfo['title'] . "
"); if( !empty($eventInfo['comment']) ) { $this->echoln("
Comment:" . $eventInfo['comment'] . "
"); } $this->echoln("
"); } private function getButtons($photocount, $size, $photo, $start) { $buttons = "
"; if( $photo != null ) { /** One photo */ if( $photo > 1 ) { $buttons .= ""; $buttons .= "\"Previous\""; $buttons .= " "; } if( $photo < $photocount ) { $buttons .= ""; $buttons .= "\"Next\""; $buttons .= " "; } $buttons .= ""; $buttons .= "\"List\""; $buttons .= " "; }elseif( $photocount > MAX_PHOTO_PER_PAGE ) { /** List, more than one page */ if( $start > 1 ) { $buttons .= ""; $buttons .= "\"Previous\""; $buttons .= " "; } if( $start + MAX_PHOTO_PER_PAGE <= $photocount ) { $buttons .= ""; $buttons .= "\"Next\""; $buttons .= " "; } } $buttons .= "
"; return $buttons; } private function getPhotos($size, $photo, $start) { $queryBuilder = new QueryBuilder($this->getDbMySQL(), "photo"); $queryBuilder->addField("id"); $queryBuilder->addField("nr"); $queryBuilder->addField("height_" . $size, "height"); $queryBuilder->addField("width_" . $size, "width"); $queryBuilder->addField("comment"); $queryBuilder->addField("date_add"); $queryBuilder->addWhereEquals("book_id", $_GET['book']); if( $photo != null ) { $queryBuilder->addWhereEquals("nr", $photo); }else { $queryBuilder->addOrderAsc("nr"); $queryBuilder->setLimit(MAX_PHOTO_PER_PAGE); $queryBuilder->setOffset($start - 1); } return $this->getDbMySQL()->select($queryBuilder->toQuery()); } private function showPhotos(IResult $photoResult, $size) { if( $size == "thumb" ) { $this->echoln(""); $r = 1; $colWidth = floor(100 / MAX_PHOTO_THUMB_COLS); while( $row = $photoResult->fetchAssoc() ) { if( $r % MAX_PHOTO_THUMB_COLS == 1 ) { $this->echoln(""); } $this->echoln(""); if( $r % MAX_PHOTO_THUMB_COLS == 0 ) { $this->echoln(""); } $r++; } while( $r % MAX_PHOTO_THUMB_COLS != 1 ) { $this->echoln(""); if( $r % MAX_PHOTO_THUMB_COLS == 0 ) { $this->echoln(""); } $r++; } $this->echoln("
"); $title = $this->getPhotoTitle($row); $this->echoln(""); $this->echoln("\"""); $this->echoln(""); $this->echoln("
"); }else { while( $row = $photoResult->fetchAssoc() ) { $title = $this->getPhotoTitle($row); $this->echoln("
"); $this->echoln("\"""); $this->echoln("
" . $title); $this->echoln("
"); } } } private function getPhotoTitle($photo) { return $photo['comment'] == null ? $photo['nr'] : $photo['nr'] . ": " . $photo['comment']; } } ?>