/**
  * Shows all the pages and their dependencies
  * @return HttpResponse
  */
 public function getRoutesOverview()
 {
     $lang = $this->getLocaleHandler()->getLanguage();
     $sqlRoutes = "\n\t\t\tSELECT\n\t\t\t\tr.ID, r.regex, r.pattern, r.robots, r.external_source, r.page_IDFK, r.redirect_route_IDFK,\n\t\t\t\trr.ID rrID, rr.pattern rr_pattern,\n\t\t\t\tr.mod_IDFK, m.ID mod_ID, m.manifest_content, m.name mod_name,\n\t\t\t\tp.ID page_ID, p.language_codeFK page_lang, p.title page_title\n\t\t\tFROM route r\n\t\t\tLEFT JOIN route rr ON rr.ID = r.redirect_route_IDFK\n\t\t\tLEFT JOIN page p ON p.ID = r.page_IDFK\n\t\t\tLEFT JOIN cms_mod_available m ON m.ID = r.mod_IDFK\n\t\t\tORDER BY pattern\n\t\t";
     $stmntRoutes = $this->db->prepare($sqlRoutes);
     $trRoutes = new TableRenderer('routes', $this->db, $sqlRoutes);
     $trRoutes->setOptions(array('edit' => '/backend/route/{ID}/edit', 'delete' => '/backend/route/{ID}/delete'));
     $columnPattern = new Column('r.pattern', 'Pattern', array(new LinkColumnDecorator()), true);
     $columnPattern->setFilter();
     $columnDestination = new Column(null, 'Destination', array(new CallbackColumnDecorator(array($this, 'renderDestinationColumn'))));
     $trRoutes->setColumns(array(new Column('ID', 'ID', array(), true, 'r.ID'), $columnPattern, new Column('r.regex', 'Regex active', array(new BooleanColumnDecorator()), true), $columnDestination, new Column('r.robots', 'Robots', array(), true)));
     $resRoutes = $this->db->select($stmntRoutes);
     $pageModel = new PageModel($this->db);
     /*foreach($resRoutes as $r) {
     			if($r->external_source !== null) {
     				$r->destination = 'External: <a href="' . $r->external_source . '">' . $r->external_source . '</a>';
     			} elseif($r->redirect_route_IDFK !== null) {
     				$r->destination = 'Route redirect: <a href="#">' . $r->rr_pattern . ' (#' . $r->rrID . ')</a>';
     			} elseif($r->page_ID !== null) {
     				$pagePath = $pageModel->getPagePath($r->page_ID);
     
     				$r->destination = 'Page: ' . ((count($pagePath) > 0)?implode(' > ', $pagePath):null). '<a href="#">' . $r->page_title . ' (#' . $r->page_ID . ', ' . $r->page_lang . ')</a>';
     			} else {
     				$r->destination = null;
     			}
     
     			if($r->mod_IDFK !== null) {
     				$jsonMod = JsonUtils::decode($r->manifest_content);
     				$r->destination .= ', Module: <a href="/backend/module/' . $r->mod_name . '">' . (isset($jsonMod->name->{$lang})?$jsonMod->name->{$lang}:$r->mod_name) . '</a>';
     			}
     		}*/
     $tplVars = array('routes' => $resRoutes, 'routes_table' => $trRoutes->display(), 'siteTitle' => 'Routes');
     return $this->generatePageFromTemplate('backend-routes-overview', $tplVars);
 }
 public function getModuleOverview()
 {
     if ($this->cmsController->getHttpRequest()->getVar('delete') !== null) {
         $this->deletePage();
     }
     $pageQueryStr = "\n\t\t\tSELECT\n\t\t\t\tp.ID, p.title, p.description, bp.ID base_page_ID, bp.title base_page_title, l.name lang_name, lc.ID creator_ID, lc.username creator_name, p.created,\n\t\t\t\tlm.ID last_modifier_ID, lm.username last_modifier, p.last_modified, p.uniqid,p.inhert_rights, r.pattern\n\t\t\tFROM page p\n\t\t\tLEFT JOIN login lc ON lc.ID = p.creator_IDFK\n\t\t\tLEFT JOIN login lm ON lm.ID = p.modifier_IDFK\n\t\t\tLEFT JOIN page bp ON bp.ID = p.base_page_IDFK\n\t\t\tLEFT JOIN route r ON r.page_IDFK = p.ID\n\t\t\tLEFT JOIN language l ON l.code = p.language_codeFK\n\t\t\tORDER BY p.title\n\t\t";
     $columnTitle = new Column('p.title', 'Title', array(new RewriteColumnDecorator('<a href="' . $this->baseLink . '/page/{ID}">{title}</a>')), true);
     $columnTitle->setFilter();
     $columnRoute = new Column('pattern', 'Route', array(), true, 'r.pattern');
     $columnRoute->setHidden(true);
     $columnRoute->setFilter();
     $tableRenderer = new TableRenderer('pages', $this->cmsController->getDB(), $pageQueryStr);
     $tableRenderer->setColumns(array(new Column('ID', '#', array(), true, 'p.ID'), $columnTitle, new Column('lang_name', 'Language', array(), true, 'l.name'), $columnRoute, new Column(null, 'Page inheritance', array(new CallbackColumnDecorator(array($this, 'getPagePathTableRenderer')))), new Column('inhert_rights', 'Inherit rights', array(new BooleanColumnDecorator()), true, 'p.inhert_rights'), new Column('created', 'Created', array(new DateColumnDecorator($this->cmsController->getLocaleHandler()->getDateTimeFormat())), true, 'p.created'), new Column('creator_name', 'Creator', array(new RewriteColumnDecorator('<a href="/backend/account/{creator_ID}">{creator_name}</a>')), true, 'lc.username'), new Column('last_modified', 'Last modified', array(new EmptyValueColumnDecorator('<span class="no-value">never</span>'), new DateColumnDecorator($this->cmsController->getLocaleHandler()->getDateTimeFormat())), true, 'p.last_modified'), new Column('last_modifier', 'Last modifier', array(new EmptyValueColumnDecorator('<span class="no-value">no one</span>'), new RewriteColumnDecorator('<a href="/backend/account/{last_modifier_ID}">{last_modifier}</a>')), true, 'lm.username')));
     $tableRenderer->setOptions(array('preview' => '/preview/page/{uniqid}', 'delete' => '?delete={ID}'));
     return $this->renderModuleContent('mod-pages-overview', array('siteTitle' => 'Pages', 'base_link' => $this->baseLink, 'pages' => $tableRenderer->display(), 'pages_tree' => $this->getPagesHierarchically()));
 }
 public function getModuleOverview()
 {
     $sqlNavigations = "\n\t\t\tSELECT ID, name, (SELECT COUNT(*) FROM navigation_has_entry WHERE navigation_IDFK = n.ID) entries\n\t\t\tFROM navigation n\n\t\t\tORDER BY name\n\t\t";
     $sqlNewsEntriesParams = array();
     $tableNavigations = new TableRenderer('navs', $this->cmsController->getDB(), $sqlNavigations);
     $tableNavigations->setOptions(array(TableRenderer::OPT_EDIT => $this->baseLink . '/nav/{ID}/edit', TableRenderer::OPT_DELETE => $this->baseLink . '/nav/{ID}/delete'));
     $tableNavigations->setColumns(array(new Column('ID', '#'), new Column('name', 'Name'), new Column('entries', 'Entries')));
     $sqlNavigationEntries = "\n\t\t\tSELECT ne.ID, ne.language_codeFK, ne.title, ne.route_IDFK, r.pattern route, ne.external_link, (SELECT COUNT(*) FROM navigation_has_entry WHERE navigation_entry_IDFK = ne.ID) occurrences\n\t\t\tFROM navigation_entry ne\n\t\t\tLEFT JOIN route r ON r.ID = ne.route_IDFK\n\t\t\tORDER BY ne.title\n\t\t";
     $sqlParams = array($this->cmsController->getCore()->getLocaleHandler()->getLanguage());
     $columnTitle = new Column('ne.title', 'Title');
     $columnTitle->setFilter();
     $tableNavigationEntries = new TableRenderer('naventries', $this->cmsController->getDB(), $sqlNavigationEntries);
     $tableNavigationEntries->setOptions(array(TableRenderer::OPT_EDIT => $this->baseLink . '/entry/{ID}/edit', TableRenderer::OPT_DELETE => $this->baseLink . '/entry/{ID}/delete'));
     $tableNavigationEntries->setColumns(array(new Column('ID', '#'), $columnTitle, new Column('ne.language_codeFK', 'Language'), new Column('route', 'Route', array(new RewriteColumnDecorator('<a href="{route}">{route}</a>'))), new Column('external_link', 'External source'), new Column('occurrences', 'Occurrences')));
     $tplVars = array('siteTitle' => 'Module: Navigation', 'news_entries_table' => $tableNavigations->display($sqlNewsEntriesParams), 'news_cats_table' => $tableNavigationEntries->display());
     return $this->renderModuleContent('mod-navigation-overview', $tplVars);
 }
 public function viewHttpErrors()
 {
     if (($deleteRouteId = $this->cmsController->getHttpRequest()->getVar('delete')) !== null) {
         try {
             $stmntRemove = $this->cmsController->getDB()->prepare("DELETE FROM mod_maintenance_page_not_found WHERE ID = ?");
             $this->cmsController->getDB()->delete($stmntRemove, array($deleteRouteId));
             $this->setMessageForNextPage(new CmsBackendMessage('Path removed successfully', CmsBackendMessage::MSG_TYPE_SUCCESS));
             RequestHandler::redirect($this->getBaseURI() . '/http-errors');
         } catch (\Exception $e) {
             $this->setMessageForNextPage(new CmsBackendMessage('Could not remove path', CmsBackendMessage::MSG_TYPE_ERROR));
         }
     }
     $sqlString = "\n\t\t\tSELECT *\n\t\t\tFROM mod_maintenance_page_not_found pnf\n\t\t\tLEFT JOIN (\n\t\t\t\tSELECT page_not_found_IDFK,\n\t\t\t\tCOUNT(*) error_count,\n\t\t\t\tCOUNT(DISTINCT ip_address) ip_address_count,\n\t\t\t\tMAX(request_date) most_recent_error_date\n\t\t\t\tFROM mod_maintenance_page_not_found_request\n\t\t\t\tGROUP BY page_not_found_IDFK\n\t\t\t) AS entry ON entry.page_not_found_IDFK = pnf.ID\n\t\t";
     $trPaths = new TableRenderer('mod-maintenance-http-errors-paths', $this->cmsController->getDB(), $sqlString);
     $trPaths->setOptions(array('delete' => '?delete={ID}'));
     $columnMostRecentErrorDate = new Column('most_recent_error_date', 'Newest error', array(new DateColumnDecorator($this->cmsController->getLocaleHandler()->getDateTimeFormat())), true, null, TableRenderer::SORT_DESC);
     $columnPath = new Column('path', 'Path', array(new RewriteColumnDecorator('<a href="' . $this->getBaseURI() . '/http-errors/view/{ID}">{path}</a>')), true);
     $columnPath->setFilter();
     $trPaths->setColumns(array($columnPath, $columnMostRecentErrorDate, new Column('error_count', 'Errors', array(), true), new Column('ip_address_count', 'IP addresses', array(), true)));
     $trPaths->setDefaultOrder($columnMostRecentErrorDate);
     return $this->renderModuleContent('mod-maintenance/http-errors-overview', array('siteTitle' => 'HTTP errors', 'table_paths' => $trPaths->display()));
 }
 public function setDefaultOrder(Column $column)
 {
     if (isset($_SESSION['table'][$this->tableName]['sort']) === true) {
         return;
     }
     $this->orderBy = array('column' => $column->getSQLColumn(), 'sort' => $column->getSort());
     $_SESSION['table'][$this->tableName]['sort'] = $this->orderBy['column'] . '-' . $this->orderBy['sort'];
 }