コード例 #1
0
ファイル: Controller.php プロジェクト: hosivan90/toxotes
 /**
  * shortcut call \Flywheel\Router\WebRouter::createUrl() method
  * @see \Flywheel\Router\WebRouter::createUrl()
  * @param $route
  * @param array $params
  * @param bool $absolute
  * @param string $ampersand
  * @return mixed
  */
 public function createUrl($route, $params = array(), $ampersand = '&', $absolute = false)
 {
     $route = trim($route, '/');
     if ('post/detail' == $route) {
         if (isset($params['id']) && ($post = \Posts::retrieveById($params['id']))) {
             $params['slug'] = $post->getSlug();
         }
     } else {
         if ('category/default' == $route) {
             if (isset($params['id']) && ($term = \Terms::retrieveById($params['id']))) {
                 $params['slug'] = $term->getSlug();
             }
         } else {
             if ('events/default' == $route) {
                 if (isset($params['id']) && ($term = \Terms::retrieveById($params['id']))) {
                     $params['slug'] = $term->getSlug();
                 }
             } else {
                 if ('events/detail' == $route) {
                     if (isset($params['id']) && ($post = \Posts::retrieveById($params['id']))) {
                         $params['slug'] = $post->getSlug();
                     }
                 }
             }
         }
     }
     $params = Plugin::applyFilters('custom_router_param', $route, $params);
     if ($this->currentLang && sizeof($this->languages) > 1) {
         $params['lang'] = $this->currentLang->getLangCode();
     }
     return parent::createUrl($route, $params, $ampersand, $absolute);
 }
コード例 #2
0
ファイル: CMSBackendBase.php プロジェクト: hosivan90/toxotes
 public function beforeExecute()
 {
     parent::beforeExecute();
     // TODO: Change the autogenerated stub
     $this->_registerDefaultTaxonomies();
     $this->loadPlugin();
     if ($this->_need_login) {
         /** @var CMSBackendAuth $auth */
         $auth = CMSBackendAuth::getInstance();
         if (!$auth->isCMSBackendAuthenticated()) {
             if ($this->request()->isXmlHttpRequest()) {
                 Base::end(json_encode(array('error' => 'AUTHENTICATE FAIL', 'error_code' => 'E0001', 'message' => t('This session was expired, plz login and comeback!'))));
             } else {
                 //redirect
                 $this->redirect($this->createUrl('login', array('r' => urlencode($this->request()->getUri()))));
             }
         }
     }
     $this->document()->addJsVar('login_url', $this->createUrl('login'));
     $this->document()->addJsVar('media_upload_url', $this->createUrl('media/upload'));
     $this->_initTemplate();
     $this->_loadLanguage();
 }