$eventDAO = EventDAO::getInstance(); $page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1; $platform_id = isset($_GET["platform"]) && is_numeric($_GET["platform"]) ? intval($_GET["platform"]) : 0; if ($page < 1) { $page = 1; } $count = $paginator = $paginator_page = $queryVars = $current_platform = null; if ($platform_id <= 0) { $count = $eventDAO->countStatus(Event::APPROVED_STATUS); $paginator = new Paginator($count, $PAGINATION_LIMIT); $paginator_page = $paginator->getPage($page); $event_array = $eventDAO->allByStatus(Event::APPROVED_STATUS, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true, "limit" => $paginator_page)); } else { $count = $eventDAO->countPlatformStatus($platform_id, Event::APPROVED_STATUS); $paginator = new Paginator($count, $PAGINATION_LIMIT); $paginator_page = $paginator->getPage($page); $event_array = $eventDAO->allByPlatformStatus($platform_id, Event::APPROVED_STATUS, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true, "limit" => $paginator_page)); $queryVars = array("platform" => $platform_id); } $platformDAO = PlatformDAO::getInstance(); $platform_array = $platformDAO->all(); //print_r ($event_array); if ($platform_id > 0) { $current_platform = $platformDAO->load($platform_id); } $this->template->render(array("title" => "Event List", "main_page" => "event_list_tpl.php", "event_array" => $event_array, "session" => $session, "paginator_page" => $paginator_page, "sidebar_extra" => joinPath("fragments", "event_sidebar_tpl.php"), "platform_array" => $platform_array, "queryVars" => $queryVars, "current_platform" => $current_platform)); } } $controller = new EventListController(); $controller->run();