Exemple #1
0
 public function executeShow(sfWebRequest $request)
 {
     sfApplicationConfiguration::getActive()->loadHelpers(array('I18N', 'Parse'));
     $this->post = Doctrine::getTable('Post')->find(array($request->getParameter('id')));
     if ($request->getParameter('noajax')) {
         $this->showAddComment = 1;
     }
     $this->forward404Unless($this->post);
     $this->partnerId = $request->getParameter('partnerId');
     if ($this->partnerId) {
         setcookie('partnerId', $this->partnerId, time() + 60 * 60 * 2, "/");
     }
     $this->seoTitle = $this->post->getSeoTitle();
     $this->title = $this->seoTitle ? $this->seoTitle . " / " : "";
     $this->description = $this->post->getSeoDescription();
     $this->text = trimword(strip_tags($this->post->getText()), sfConfig::get('app_post_description_length'));
     if ($this->text) {
         $this->title .= $this->text . " / ";
     }
     $this->tagnames = $this->post->getTagNames();
     if ($this->tagnames) {
         $this->title .= $this->tagnames . " / ";
     }
     $this->getResponse()->setTitle($this->title . __("JoyReactor – твое хорошее настроние. Смешные картинки, приколы, видео, лучшие демотиваторы со смыслом и по-русски, много комиксов."));
     $this->getResponse()->addMeta('description', $this->description);
     $this->getResponse()->addMeta('keywords', wordlist($this->description));
     $attr = $this->post->Attributes;
     if ($this->title) {
         try {
             $options = array('host' => '192.168.10.4', 'limit' => sfConfig::get('app_sphinx_results_per_page'), 'offset' => 0, 'mode' => sfSphinxClient::SPH_MATCH_ANY, 'weights' => array('tags' => 3, 'comment' => 1));
             $this->sphinx = new sfSphinxClient($options);
             $res = $this->sphinx->Query($this->title, sfConfig::get('app_sphinx_index'));
             $this->pager = new sfSphinxPager('Post', $options['limit'], $this->sphinx);
             $this->pager->setPage(1);
             $this->pager->init();
             $this->simPosts = $this->pager->getResults();
         } catch (Exception $e) {
         }
     }
 }
Exemple #2
0
 public function getSeoDescription()
 {
     if ($this->getHeader()) {
         return $this->getHeader();
     }
     $attr = $this->getAttributes();
     if (count($attr) && $attr[0]->getComment()) {
         return trimword($attr[0]->getComment(), sfConfig::get('app_post_description_length'));
     } else {
         return '';
     }
 }