Example #1
0
 /**
  * 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);
 }
Example #2
0
 public function begin()
 {
     $post_id = $this->getParams('post_id');
     if ($post_id) {
         $this->post = \Posts::retrieveById($post_id);
     }
 }
Example #3
0
 public function executeDetail()
 {
     if (!($post = \Posts::retrieveById($this->request()->get('id')))) {
         $this->raise404();
     }
     $post->setHits($post->getHits() + 1);
     $post->save(false);
     $term = \Terms::retrieveById($post->getTermId());
     if (($viewProp = $term->getProperty('post_view')) && $this->view()->checkViewFileExist($this->getTemplatePath() . '/Controller/Post/' . $this->_path . $viewProp->getPropertyValue())) {
         $this->setView('Post/' . $viewProp->getPropertyValue());
     } else {
         $this->setView('Post/default');
     }
     $this->view()->assign(array('post' => $post, 'term' => $term));
     return $this->renderComponent();
 }
Example #4
0
 public function executePin()
 {
     $this->validAjaxRequest();
     $res = new \AjaxResponse();
     if (!($post = \Posts::retrieveById($this->request()->get('id')))) {
         $res->type = \AjaxResponse::ERROR;
         $res->message = t('Post not found!');
         return $this->renderText($res->toString());
     }
     $post->setIsPin(true);
     $post->save(false);
     $res->type = \AjaxResponse::SUCCESS;
     $res->id = $post->getId();
     $res->post = $post->toArray();
     return $this->renderText($res->toString());
 }