Esempio n. 1
0
 protected function getTags()
 {
     $aTags = $this->Question['a_tags'];
     if (empty($aTags) || empty($aTags[0])) {
         return '';
     }
     $res = '';
     $cur = $this->Registry->Mongo->QUESTION_TAGS->find(array('tag' => array('$in' => $aTags), 'i_count' => array('$gt' => 0)));
     $count = $cur->count();
     d('count: ' . $count);
     if ($cur && $count > 0) {
         d('found ' . $count . ' tags in QUESTION_TAGS collection');
         $res = \tplLinktag::loop($cur);
     }
     d('$res: ' . $res);
     return $res;
 }
Esempio n. 2
0
 /**
  * Generated html string
  * of links to recent tags fom QA module
  *
  */
 public function qrecent()
 {
     d('cp');
     $limit = $this->Registry->Ini->MAX_RECENT_TAGS;
     $cur = $this->Registry->Mongo->QUESTION_TAGS->find(array('i_count' => array('$gt' => 0)), array('tag', 'i_count'))->sort(array('i_ts' => -1))->limit($limit);
     d('got ' . $cur->count(true) . ' tag results');
     $html = \tplLinktag::loop($cur);
     d('html recent tags: ' . $html);
     $this->aTags = array('tags');
     return '<div class="tags-list">' . $html . '</div>';
 }
Esempio n. 3
0
 /**
  * Creates html for the recent tags block
  * but user's followed tags will always be
  * on top
  *
  *
  * @param array $aUserTags array of tags user follows
  *
  * @return string html with parsed tags links
  */
 protected function getSortedRecentTags(array $aUserTags, $type = 'recent')
 {
     $limit = 30;
     if ('unanswered' === $type) {
         $cur = $this->Registry->Mongo->UNANSWERED_TAGS->find(array(), array('tag', 'i_count'))->sort(array('i_ts' => -1))->limit($limit);
     } else {
         $cur = $this->Registry->Mongo->QUESTION_TAGS->find(array('i_count' => array('$gt' => 0)), array('tag', 'i_count'))->sort(array('i_ts' => -1))->limit($limit);
     }
     d('got ' . $cur->count(true) . ' tag results');
     $aTags = iterator_to_array($cur);
     d('aTags: ' . print_r($aTags, 1));
     /**
     * $aTags now looks like array of
     * elements like this one:
     * [4d84c3693630000000003820] => Array
     (
     [_id] => MongoId Object
     (
     [$id] => 4d84c3693630000000003820
     )
     
     [i_count] => 1
     [tag] => pop
     )
     */
     if (!empty($aTags)) {
         usort($aTags, function ($a, $b) use($aUserTags) {
             return in_array($a['tag'], $aUserTags) ? -1 : 1;
         });
     }
     d('$aTags now: ' . print_r($aTags, 1));
     $html = 'unanswered' === $type ? \tplUnanstags::loop($aTags) : \tplLinktag::loop($aTags);
     d('html recent tags: ' . $html);
     return '<div class="tags-list">' . $html . '</div>';
 }