JHTML::_('behavior.mootools');
$doc =& JFactory::getDocument();
$doc->addScript(JURI::Root(true) . "/modules/mod_rokmicronews/tmpl/rokmicronews.js");
// Cache this basd on access level
$conf =& JFactory::getConfig();
if ($conf->getValue('config.caching') && $params->get("module_cache", 0)) {
    $user =& JFactory::getUser();
    $aid = (int) $user->get('aid', 0);
    switch ($aid) {
        case 0:
            $level = "public";
            break;
        case 1:
            $level = "registered";
            break;
        case 2:
            $level = "special";
            break;
    }
    // Cache this based on access level
    $cache =& JFactory::getCache('mod_rokmicronews-' . $level);
    $list = $cache->call(array('modRokMicroNewsHelper', 'getList'), $params);
} else {
    $list = modRokMicroNewsHelper::getList($params);
}
$num_lead = 1;
// this is now configured via js
if (sizeof($list) < $num_lead) {
    $num_lead = sizeof($list);
}
require JModuleHelper::getLayoutPath('mod_rokmicronews');
Esempio n. 2
0
 function getList(&$params)
 {
     global $mainframe;
     $cparams =& $mainframe->getParams('com_content');
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $userId = (int) $user->get('id');
     $count = $params->get('article_count', 3);
     $catid = trim($params->get('catid'));
     $secid = trim($params->get('secid'));
     $show_front = $params->get('show_front', 1);
     $aid = $user->get('aid', 0);
     $text_length = intval($params->get('preview_count', 200));
     $contentConfig =& JComponentHelper::getParams('com_content');
     $access = !$contentConfig->get('shownoauth');
     $nullDate = $db->getNullDate();
     $date =& JFactory::getDate();
     $now = $date->toMySQL();
     $where = 'a.state = 1' . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )';
     // User Filter
     switch ($params->get('user_id')) {
         case 'by_me':
             $where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')';
             break;
         case 'not_me':
             $where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')';
             break;
     }
     // Ordering
     switch ($params->get('ordering')) {
         case 'o_dsc':
             $ordering = 'a.ordering ASC';
             break;
         case 'm_dsc':
             $ordering = 'a.modified DESC, a.created DESC';
             break;
         case 'c_dsc':
         default:
             $ordering = 'a.created DESC';
             break;
     }
     if ($catid) {
         $ids = explode(',', $catid);
         JArrayHelper::toInteger($ids);
         $catCondition = ' AND (cc.id=' . implode(' OR cc.id=', $ids) . ')';
     }
     if ($secid) {
         $ids = explode(',', $secid);
         JArrayHelper::toInteger($ids);
         $secCondition = ' AND (s.id=' . implode(' OR s.id=', $ids) . ')';
     }
     // Content Items only
     $query = 'SELECT a.*, ' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug' . ' FROM #__content AS a' . ($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') . ' INNER JOIN #__categories AS cc ON cc.id = a.catid' . ' INNER JOIN #__sections AS s ON s.id = a.sectionid' . ' WHERE ' . $where . ' AND s.id > 0' . ($access ? ' AND a.access <= ' . (int) $aid . ' AND cc.access <= ' . (int) $aid . ' AND s.access <= ' . (int) $aid : '') . ($catid ? $catCondition : '') . ($secid ? $secCondition : '') . ($show_front == '0' ? ' AND f.content_id IS NULL ' : '') . ' AND s.published = 1' . ' AND cc.published = 1' . ' ORDER BY ' . $ordering;
     $db->setQuery($query, 0, $count);
     $rows = $db->loadObjectList();
     $i = 0;
     $lists = array();
     foreach ($rows as $row) {
         //process content plugins
         $text = JHTML::_('content.prepare', $row->introtext, $cparams);
         $lists[$i]->id = $row->id;
         $lists[$i]->thumb = modRokMicroNewsHelper::getThumb($row->introtext, $params->get('thumb_width', 160));
         $lists[$i]->created = $row->created;
         $lists[$i]->modified = $row->modified;
         $lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
         $lists[$i]->title = htmlspecialchars($row->title);
         $lists[$i]->introtext = modRokMicroNewsHelper::prepareContent($text, $text_length);
         $i++;
     }
     return $lists;
 }