コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 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()));
 }
コード例 #4
0
 public function getViewAccount(array $params)
 {
     $this->cmsController->abortIfUserHasNotRights('MOD_USERS_EDIT_USER');
     $userID = $params[0];
     if (($rightGroupID = $this->cmsController->getHttpRequest()->getVar('remove_right_group')) !== null) {
         try {
             $this->loginModel->removeRightgroupFromLogin($rightGroupID, $userID);
             $this->setMessageForNextPage(new CmsBackendMessage($this->translator->_d('backend', 'The right group has been removed'), CmsBackendMessage::MSG_TYPE_SUCCESS));
         } catch (\Exception $e) {
             $this->setMessageForNextPage(new CmsBackendMessage($this->translator->_d('backend', 'Could not remove right group') . ': ' . $e->getMessage(), CmsBackendMessage::MSG_TYPE_ERROR));
         }
     }
     $rightGroupsAddArr = array(0 => '- ' . $this->translator->_d('backend', 'please choose') . ' -');
     foreach ($this->rightGroupModel->getRightGroups() as $rg) {
         if ($this->loginModel->hasLoginRightGroup($userID, $rg->getID()) || $rg->getID() == 0) {
             continue;
         }
         $rightGroupsAddArr[$rg->getID()] = $rg->getGroupName();
     }
     $userData = $this->loginModel->getLoginByID($userID);
     $lastLogin = $userData->getLastLogin();
     $confirmed = $userData->getConfirmed();
     $stmntUserRights = "\n\t\t\tSELECT rg.ID, rg.groupname, rg.groupkey, rg.root, lhr.datefrom, lhr.dateto\n\t\t\tFROM login_has_rightgroup lhr\n\t\t\tLEFT JOIN rightgroup rg ON rg.ID = lhr.rightgroupIDFK\n\t\t\tWHERE lhr.loginIDFK = ?\n\t\t";
     $tableRendererTranslator = $this->cmsController->getTranslator($this->cmsController->getCore()->getSiteRoot() . 'locale' . DIRECTORY_SEPARATOR);
     $trRights = new TableRenderer('user-rights-' . $userID, $this->cmsController->getDB(), $stmntUserRights);
     $trRights->setTranslator($tableRendererTranslator);
     $trRights->setColumns(array(new Column('groupname', $this->translator->_d('backend', 'Right group'), array(), true), new Column('datefrom', $this->translator->_d('backend', 'From'), array(new DateColumnDecorator($this->cmsController->getLocaleHandler()->getDateTimeFormat())), true), new Column('dateto', $this->translator->_d('backend', 'To'), array(new DateColumnDecorator($this->cmsController->getLocaleHandler()->getDateTimeFormat()), new EmptyValueColumnDecorator('<em>' . $this->translator->_d('backend', 'indeterminate') . '</em>')), true)));
     $trRights->setOptions(array('delete' => '?remove_right_group={ID}'));
     return $this->renderModuleContent('mod-users/account-view', array('siteTitle' => $userID == $this->cmsController->getAuth()->getUserID() ? $this->translator->_d('backend', 'My account overview') : $this->translator->_d('backend', 'Account') . ' ' . $userData->getEmail(), 'user_id' => $userData->getID(), 'user_username' => $userData->getUsername(), 'user_email' => $userData->getEmail(), 'last_login' => $lastLogin instanceof \DateTime ? $lastLogin->format($this->cmsController->getLocaleHandler()->getDateTimeFormat()) : $this->translator->_d('backend', 'never'), 'confirmed' => $confirmed instanceof \DateTime ? $confirmed->format($this->cmsController->getLocaleHandler()->getDateTimeFormat()) : $this->translator->_d('backend', 'not yet'), 'registered' => $userData->getRegistered()->format($this->cmsController->getLocaleHandler()->getDateTimeFormat()), 'active' => $this->translator->_d('backend', $userData->getActive() == 1 ? 'yes' : 'no'), 'wrong_logins' => $userData->getWrongLogins(), 'right_groups' => $trRights->display(array($userID)), 'rightgroupsAdd' => $rightGroupsAddArr, 'rightgroupsAddSelected' => array(0), 'status_message' => $this->renderPendingMessage(), 'translator' => $this->translator));
 }
コード例 #5
0
 public function getPageDetails($params)
 {
     $pageID = (int) $params[0];
     $cmsPage = $this->pageModel->getPageByID($pageID);
     if ($cmsPage === null) {
         throw new HttpException('Could not find page', 404);
     }
     $moduleModel = new ElementModel($this->cmsController->getDB());
     $coreModel = new CoreModel($this->cmsController->getDB());
     //$modules = $moduleModel->getModulesByPage($pageData);
     $elements = $moduleModel->getElementTree($cmsPage);
     $rights = array();
     foreach ($cmsPage->getRights() as $r) {
         $rightEntry = new \stdClass();
         $rightEntry->ID = $r->ID;
         $rightEntry->group_name = $r->groupname;
         $rightEntry->rights = CmsUtils::getRightsAsString($r->rights);
         $rightEntry->inherited_page = $r->inherted_page == $pageID ? null : '<a href="/backend/page/' . $r->inherted_page . '">Page #' . $r->inherted_page . '</a>';
         $dtStart = new \DateTime($r->start_date);
         $dtFormat = $this->cmsController->getLocaleHandler()->getDateTimeFormat();
         $rightEntry->duration = $r->end_date === null ? 'since ' . $dtStart->format($dtFormat) : $dtStart->format($dtFormat) . ' - ' . $r->end_date;
         $rights[] = $rightEntry;
     }
     $sqlQueryStr = "SELECT r.ID, r.pattern, m.ID mod_ID, m.name mod_name, r.robots, r.ssl_forbidden, r.ssl_required\n\t\t\tFROM route r\n\t\t\tLEFT JOIN cms_mod_available m ON m.ID = r.mod_IDFK\n\t\t\tWHERE page_IDFK = ?\n\t\t";
     $trRoutes = new TableRenderer('route', $this->cmsController->getDB(), $sqlQueryStr);
     $trRoutes->setColumns(array(new Column('ID', 'ID'), new Column('pattern', 'Path', array(new LinkColumnDecorator())), new Column('mod_name', 'Module', array(new EmptyValueColumnDecorator('<em>none</em>'), new RewriteColumnDecorator('<a href="/backend/module/{mod_name}">{mod_name}</a>'))), new Column('robots', 'Robots', array(new EmptyValueColumnDecorator('<em>default</em>'))), new Column(null, 'SSL', array(new CallbackColumnDecorator(function ($value, $record, $selector, $tableRenderer) {
         $sslAttrs = array();
         if ($record->ssl_forbidden + $record->ssl_required == 0) {
             return 'user\'s choice';
         }
         if ($record->ssl_forbidden == 1) {
             $sslAttrs[] = 'forbidden';
         }
         if ($record->ssl_required == 1) {
             $sslAttrs[] = 'required';
         }
         return implode(' / ', $sslAttrs);
     })))));
     $trRoutes->setOptions(array('edit' => '/backend/route/{ID}/edit', 'delete' => '/backend/route/{ID}/delete'));
     $pageInfo = array();
     $pageInfo['ID'] = $pageID;
     $pageInfo['Title'] = $cmsPage->getTitle();
     if ($cmsPage->getDescription() !== null) {
         $pageInfo['Description'] = $cmsPage->getDescription();
     }
     if (($pagePathAsHtmlStr = $this->getPagePathAsHtmlStr($this->pageModel->getPagePath($pageID))) !== null) {
         $pageInfo['Page inheritance'] = $pagePathAsHtmlStr;
     }
     $roles = $this->getRoleOptions();
     $pageInfo['Role'] = isset($roles[$cmsPage->getRole()]) ? $roles[$cmsPage->getRole()] : $cmsPage->getRole();
     $languages = $coreModel->getLanguages();
     $pageInfo['Language'] = isset($languages[$cmsPage->getLanguage()]) ? $languages[$cmsPage->getLanguage()] : $cmsPage->getLanguage();
     $pageInfo['Inherit rights'] = $cmsPage->getInheritRights() == 1 ? 'yes' : 'no';
     $dtCreated = new \DateTime($cmsPage->getCreated());
     $pageInfo['Created'] = $dtCreated->format($this->cmsController->getLocaleHandler()->getDateTimeFormat()) . ' by <a href="/backend/account/' . $cmsPage->getCreatorID() . '">' . $cmsPage->getCreatorName() . '</a>';
     if ($cmsPage->getLastModified() !== null) {
         $dtLastModified = new \DateTime($cmsPage->getCreated());
         $pageInfo['Last modified'] = $dtLastModified->format($this->cmsController->getLocaleHandler()->getDateTimeFormat()) . ' by <a href="/backend/account/' . $cmsPage->getModifierID() . '">' . $cmsPage->getModifierName() . '</a>';
     }
     $tplVars = array('siteTitle' => 'Page "' . $cmsPage->getTitle() . '"', 'base_link' => $this->baseLink, 'page' => $cmsPage, 'page_info' => $pageInfo, 'rights' => $rights, 'elements_list' => $this->generateElementList($elements, $cmsPage->getID()), 'routes' => $trRoutes->display(array($pageID)));
     return $this->renderModuleContent('mod-pages-page-details', $tplVars);
 }
コード例 #6
0
 public function getAccountsOverview()
 {
     $status = null;
     if ($this->httpRequest->getVar('rgdelete') !== null) {
         $this->deleteRightgroup($this->httpRequest->getVar('rgdelete'));
     }
     if ($this->httpRequest->getVar('accdelete') !== null) {
         try {
             $this->deleteAccount($this->httpRequest->getVar('accdelete'));
         } catch (\Exception $e) {
             $status = 'Could not delete account: ' . $e->getMessage();
         }
     }
     $loginModel = new LoginModel($this->db);
     $rightgroupModel = new RightGroupModel($this->db);
     $users = $loginModel->getAllLogins();
     foreach ($users as $u) {
         $rgs = $rightgroupModel->getRightGroupByUser($u->ID);
         $rgArr = array();
         foreach ($rgs as $r) {
             $rgArr[] = '<a href="/backend/users/rightgroup/' . $r->ID . '/edit">' . $r->groupname;
         }
         $u->confirmed = $u->confirmed !== null ? $u->confirmed : 'not yet';
         $u->lastlogin = $u->lastlogin !== null ? $u->lastlogin : '******';
         $u->rightgroups = implode(', ', $rgArr);
     }
     $stmntRightGroups = "\n\t\t\tSELECT ID, groupkey, groupname, root\n\t\t\tFROM rightgroup\n\t\t\tWHERE ID != 0\n\t\t\tORDER BY groupname\n\t\t";
     $tableRendererRightgroups = new TableRenderer('rightgroups', $this->db, $stmntRightGroups);
     $tableRendererRightgroups->setColumns(array(new Column('ID', '#', array(), true), new Column('groupname', 'Name', array(), true), new Column('root', 'Root access', array(new BooleanColumnDecorator()), true)));
     $tableRendererRightgroups->setOptions(array('edit' => '/backend/users/rightgroup/{ID}/edit', 'delete' => '/backend/users?rgdelete={ID}'));
     $tplVars = array('siteTitle' => 'Accounts', 'logins' => $users, 'right_groups' => $tableRendererRightgroups->display(), 'status' => $status);
     return $this->generatePageFromTemplate('backend-accounts', $tplVars);
 }