Exemplo n.º 1
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>';
 }
Exemplo n.º 2
0
 /**
  * Generated html string
  * of links to unanswered tags fom QA module
  *
  */
 public function qunanswered()
 {
     $limit = $this->Registry->Ini->MAX_RECENT_TAGS;
     $cur = $this->Registry->Mongo->UNANSWERED_TAGS->find(array(), array('tag', 'i_count'))->sort(array('i_ts' => -1))->limit($limit);
     $count = $cur->count(true);
     d('got ' . $count . ' tag results');
     $html = \tplUnanstags::loop($cur);
     d('html recent tags: ' . $html);
     $ret = '<div class="tags-list">' . $html . '</div>';
     /* if ($count > $limit) {
            $ret .= '<div class="moretags"><a href="{_WEB_ROOT_}/{_viewqtags_}/{_unanswered_}/"><span rel="in">@@All unanswered tags@@</span></a>';
        }*/
     $this->aTags = array('tags');
     return $ret;
 }
Exemplo n.º 3
0
 /**
  * Generated html string
  * of links to unanswered tags fom QA module
  *
  * @todo the limit will be in SETTINGS
  */
 public function qunanswered()
 {
     $limit = 30;
     $cur = $this->Registry->Mongo->UNANSWERED_TAGS->find(array(), array('tag', 'i_count'))->sort(array('i_ts' => -1))->limit($limit);
     $count = $cur->count(true);
     d('got ' . $count . ' tag results');
     $html = \tplUnanstags::loop($cur);
     d('html recent tags: ' . $html);
     $ret = '<div class="tags-list">' . $html . '</div>';
     if ($count > $limit) {
         $ret .= '<div class="moretags"><a href="/tags/unanswered/"><span rel="in">All unanswered tags</span></a>';
     }
     $this->aTags = array('tags');
     return $ret;
 }