Exemplo n.º 1
0
 /**
  * Generates html block with question info.
  *
  * @todo also get count and N first
  * followers
  * Followers to be selected from USERS collection
  * using find() by a_f_q and using limit 5
  * and then link to 'show more' if i_flwrs in Question is > 5
  *
  *
  * @param Question $Question
  * @return string
  */
 public function getHtml(Question $Question)
 {
     $this->Question = $Question;
     $tagsBlock = \tplBoxrecent::parse(array('title' => '@@Question tags@@', 'id' => 'question_tags', $this->getTags()), false);
     $ret = \tplQuestionInfo::parse(array('tags' => $tagsBlock, 'asked' => TimeAgo::format(new \DateTime(str_replace(' AEST', ' UTC+10', $Question['hts']))) . ' ago', 'updated' => TimeAgo::format(new \DateTime(date('r', $Question['i_lm_ts']))) . ' ago', 'views' => $this->Question['i_views'], 'ans_count' => $this->Question->getAnswerCount(), 'asked_label' => '@@Asked@@', 'updated_label' => '@@Last updated@@', 'ans_count_label' => '@@Number of Answers@@', 'views_label' => '@@Number of Views@@'));
     return $ret;
 }
 /**
  * Generates html block with question info.
  *
  * @todo also get count and N first
  * followers
  * Followers to be selected from USERS collection
  * using find() by a_f_q and using limit 5
  * and then link to 'show more' if i_flwrs in Question is > 5
  *
  *
  * @param Question $Question
  */
 public function getHtml(Question $Question)
 {
     $this->Question = $Question;
     $Tr = $this->Registry->Tr;
     /**
      * @todo translate Title string
      */
     $tagsBlock = \tplBoxrecent::parse(array('title' => $Tr['Topic tags'], 'id' => 'question_tags', $this->getTags()), false);
     /**
      * @todo translate labels used
      * in tplQuestionsInfo template
      *
      */
     $ret = \tplQuestionInfo::parse(array('tags' => $tagsBlock, 'asked' => TimeAgo::format(new \DateTime($Question['hts'])) . ' ago', 'updated' => TimeAgo::format(new \DateTime(date('r', $Question['i_lm_ts']))) . ' ago', 'views' => $this->Question['i_views'], 'ans_count' => $this->Question->getAnswerCount(), 'asked_label' => $Tr['Posted'], 'updated_label' => $Tr['Last updated'], 'ans_count_label' => $Tr['Number of posts'], 'views_label' => $Tr['Number of Views']));
     d('$ret: ' . $ret);
     return $ret;
 }
 /**
  * Set similars:
  * similar questions block in
  * right column
  *
  * @return object $this
  */
 protected function setSimilar()
 {
     if (!empty($this->aQuestion['sim_q'])) {
         $sim = \tplBoxrecent::parse(array($this->_('Similar topics'), 'recent-tags', $this->aQuestion['sim_q']), false);
         $this->aPageVars['tags'] = $sim;
     }
     return $this;
 }
 /**
  * @todo translate word "Unanswered"
  *
  * @see wwwViewquestions::makeRecentTags()
  */
 protected function makeRecentTags()
 {
     /**
      * If user is logged in AND
      * has 'followed tags' then don't use
      * cache and instead do this:
      * get array of recent tags, sort in a way
      * than user's tags are on top and then render
      * This way user's tags will always be on top
      * at a cost of couple of milliseconds we get
      * a nice personalization that does increase
      * the click rate!
      * */
     $aUserTags = $this->Registry->Viewer['a_f_t'];
     if (!empty($aUserTags)) {
         $s = $this->getSortedRecentTags($aUserTags, 'unanswered');
     } else {
         $s = $this->Registry->Cache->qunanswered;
     }
     $tags = \tplBoxrecent::parse(array('tags' => $s, 'title' => $this->_('Unanswered tags')));
     $this->aPageVars['tags'] = $tags;
     return $this;
 }
Exemplo n.º 5
0
 /**
  * Generates html of the "recent tags"
  * block
  *
  * If user is logged in AND
  * has 'followed tags' then don't use
  * cache and instead do this:
  * get array of recent tags, sort in a way
  * than user's tags are on top and then render
  * This way user's tags will always be on top
  * at a cost of couple of milliseconds we get
  * a nice personalization that does increase
  * the click rate!
  *
  * @return object $this
  */
 protected function makeRecentTags()
 {
     $aUserTags = $this->Registry->Viewer['a_f_t'];
     if (!empty($aUserTags)) {
         $s = $this->getSortedRecentTags($aUserTags);
     } else {
         $s = $this->Registry->Cache->get('qrecent');
     }
     $tags = \tplBoxrecent::parse(array('tags' => $s, 'title' => $this->_('Recent Tags')));
     d('cp');
     $this->aPageVars['tags'] = $tags;
     return $this;
 }
Exemplo n.º 6
0
 protected function makeRecentTags()
 {
     /**
      * @todo
      * Currently we are finding related tags for just one tag
      * This is very fast because we store related tags pre-parsed
      * as html string. This works and looks good but...
      * If we really wanted this to work just like
      * on stackoverflow then we have to change it to this:
      * if there is only one tag passed in URL, then use this method
      * otherwise do this:
      * Use find() on RELATED_TAGS collection and pass $this->aTags
      * as $all condition. This will find all records in RELATED_TAGS
      * that have all these tags. Then we have result cursor from which
      * we are only interested in _id value which is the actual tag related
      * to all our tags.
      * We would then loop over cursor and pass
      * each array to tplRelatedlink, passing each _id
      * as value of 'tag' and prepend +tag to $this->rawTags as
      * value of 'link'
      *
      * This will be slower than just using pre-parsed related tags
      * but it will be exactly like on Stackoverflow
      *
      * For this to work we need to ensureIndex on 'tags' in RELATED_TAGS
      * collection!
      */
     $tag = end($this->aTags);
     d('tag: ' . $tag);
     $s = Relatedtags::factory($this->Registry)->getHtml($tag);
     if (!empty($s)) {
         $tags = \tplBoxrecent::parse(array('tags' => $s, 'title' => $this->_('Related Tags')));
         $this->aPageVars['tags'] = $tags;
     }
     $this->makeFollowTagButton();
     return $this;
 }