예제 #1
0
 function getList(&$params)
 {
     $dbo = JFactory::getDBO();
     $query = $dbo->getQuery(true);
     $query->select('count(*) as frequency');
     $query->select('name as name');
     $query->select('t.hits as hits');
     $query->select('t.created as created');
     $query->from('#__cedtag_term_content as tc');
     $query->innerJoin('#__cedtag_term as t on t.id=tc.tid');
     $query->where("t.published='1'");
     $query->group('tid');
     $query->order('hits desc');
     $dbo->setQuery($query);
     $count = intval($params->get('count', 25));
     $dbo->setQuery($query, 0, $count);
     $rows = $dbo->loadObjectList();
     if (isset($rows) && !empty($rows)) {
         $CedTagsHelper = new CedTagsHelper();
         $rows = $CedTagsHelper->mappingFrequencyToSize($rows);
         $sorting = $params->get('sorting', 'hitsasort');
         usort($rows, array('CedTagsHelper', $sorting));
         $CedTagThemes = new CedTagThemes();
         $CedTagThemes->addCss();
         if (intval($params->get('reverse', 0))) {
             $rows = array_reverse($rows);
         }
     }
     return $rows;
 }
예제 #2
0
 public function getList(&$params)
 {
     $termIds = $params->get("tagIds");
     $idsArray = @explode(',', $termIds);
     if (empty($idsArray)) {
         return array();
     }
     $dbo = JFactory::getDBO();
     $query = $dbo->getQuery(true);
     $query->select('count(*) as frequency');
     $query->select('id as id');
     $query->select('name as name');
     $query->select('t.hits as hits');
     $query->select('t.created as created');
     $query->select('1 as sequence');
     $query->from('#__cedtag_term as t');
     $query->where("t.id in (" . @implode(',', $idsArray) . ")");
     $dbo->setQuery($query);
     $query = $query->dump();
     $rows = $dbo->loadObjectList();
     //if there is results
     if (isset($rows) && !empty($rows)) {
         $rowsMap = array();
         $total_tags = count($rows);
         foreach ($rows as $row) {
             $rowsMap[$row->id] = $row;
         }
         $sortedRows = array();
         for ($index = 0; $index < $total_tags; $index++) {
             $id = $idsArray[$index];
             $rowsMap[$id]->sequence = $total_tags - $index;
             $sortedRows[] = $rowsMap[$id];
         }
         $rows = array_reverse($sortedRows);
         unset($sortedRows);
         unset($rowsMap);
         $CedTagsHelper = new CedTagsHelper();
         $rows = $CedTagsHelper->mappingFrequencyToSize($rows);
         $sorting = $params->get('sorting', 'tag_latestasort');
         usort($rows, array('CedTagsHelper', $sorting));
         $CedTagThemes = new CedTagThemes();
         $CedTagThemes->addCss();
         if (intval($params->get('reverse', 0))) {
             $rows = array_reverse($rows);
         }
     }
     return $rows;
 }