Exemplo n.º 1
0
 protected function setup()
 {
     $pageTypeRepository = new PageTypeRepository(TRUE);
     $pageType = $pageTypeRepository->getOneByAlias(Utils::get('action'));
     $pageRepository = new PageRepository(TRUE);
     $page = $pageRepository->getOneByPageType($pageType['id']);
     MySmarty::assign('page', $page);
 }
Exemplo n.º 2
0
 public function getPageTypeObject()
 {
     if ($this->pageType === NULL) {
         $pageTypeRepository = new PageTypeRepository(TRUE);
         $this->pageType = $pageTypeRepository->getOneById($this['page_type']);
     }
     return $this->pageType;
 }
Exemplo n.º 3
0
 public static function getPageByTypeAndLanguage($type, $lang = NULL)
 {
     $language = Utils::getLanguage($lang);
     if ($language) {
         $pageTypeRepository = new PageTypeRepository(TRUE);
         $pageType = $pageTypeRepository->getOneByAlias($type);
         $pageRepository = new PageRepository(TRUE);
         $page = $pageRepository->getOneByLanguageAndPageType($language['id'], $pageType['id']);
         if ($page) {
             return $page;
         } else {
             throw new Exception('Page with type ' . $pageType['title'] . ' and language ' . $language['title'] . ' doesn\'t exist', 1326403622);
         }
     } else {
         throw new Exception('Language ' . $lang . ' not found', 1326403989);
     }
 }
Exemplo n.º 4
0
 protected function setup()
 {
     $pages = array();
     $pageTypeRepository = new PageTypeRepository(TRUE);
     $hasSelected = FALSE;
     foreach ($this->pageTypes as $pageTypeAlias) {
         $page = PageActionMap::getPageByTypeAndLanguage($pageTypeAlias);
         if ($page) {
             if ($hasSelected === FALSE) {
                 $pageType = $pageTypeRepository->getOneByAlias($pageTypeAlias);
                 if ($pageType['action'] == $this->actualAction) {
                     $page['sel'] = TRUE;
                     $hasSelected = TRUE;
                 }
             }
             $pages[] = $page;
         }
     }
     MySmarty::assign('pages', $pages);
 }
Exemplo n.º 5
0
 public function getCorrespondingUrl()
 {
     $action = Utils::get('action');
     if ($action) {
         $pageRepository = new PageRepository(TRUE);
         $actualPage = $pageRepository->getOneByAlias($action);
         $aliases = array();
         if ($actualPage) {
             $pageTypeRepository = new PageTypeRepository(TRUE);
             $pageType = $pageTypeRepository->getOneById($actualPage['page_type']);
             $page = PageActionMap::getPageByTypeAndLanguage($pageType['alias'], $this['shortcut']);
             $aliases[] = $page['alias'];
         } else {
             $aliases[] = $action;
         }
         if (Utils::get('identifier')) {
             $aliases[] = Utils::get('identifier');
         }
         return PageActionMap::createUrl($aliases, $this['shortcut']);
     } else {
         return $this->getUrl();
     }
 }
Exemplo n.º 6
0
require_once 'config.php';
require_once 'auto.php';
require_once 'init.php';
try {
    BangSeo::addTitlePart('Bang!');
    $language = Utils::get('language');
    if (!$language) {
        // TODO check user and country, then default en
        $url = PageActionMap::createUrl(array(), 'sk');
        Utils::redirect($url);
    }
    $actionAlias = Utils::get('action');
    $pageRepository = new PageRepository(TRUE);
    $page = $pageRepository->getOneByAlias($actionAlias);
    $pageTypeRepository = new PageTypeRepository(TRUE);
    $pageType = $pageTypeRepository->getOneById($page['page_type']);
    $action = PageActionMap::getActionByPageAndLanguage(Utils::get('action'));
    $actionClassName = ucfirst($action) . 'Action';
    // TODO caching
    if (LoggedUser::whoIsLogged() === NULL && $pageType['needs_login'] == 1) {
        if ($pageType['action'] != 'logout') {
            setcookie('ref_url', Utils::getActualUrl(), NULL, '/');
        }
        $page = PageActionMap::getPageByTypeAndLanguage('login', $language);
        $url = PageActionMap::createUrl($page['alias']);
        Utils::redirect($url);
    }
    $actionClass = new $actionClassName();
    MySmarty::assign('content', $actionClass->getContent());
} catch (Exception $e) {