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', 4); $catid = trim($params->get('catid')); $secid = trim($params->get('secid')); $show_front = $params->get('show_front', 1); $aid = $user->get('aid', 0); $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 ($show_front != 2) { 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' : '') . ($show_front == '2' ? ' INNER 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 && $show_front != 2 ? $catCondition : '') . ($secid && $show_front != 2 ? $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) { $images = modRokStoriesHelper::getImages($row->introtext, $params->get('thumb_width', 90)); //process content plugins $text = JHTML::_('content.prepare', $row->introtext, $cparams); $lists[$i]->id = $row->id; $lists[$i]->image = $images->image; $lists[$i]->thumb = $images->thumb; $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 = modRokStoriesHelper::prepareContent($text); $i++; } return $lists; }
// 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_rokstories-' . $level); $list = $cache->call(array('modRokStoriesHelper', 'getList'), $params); } else { $list = modRokStoriesHelper::getList($params); } if ($params->get('layout_type') == 'layout3') require(JModuleHelper::getLayoutPath('mod_rokstories', 'layout3')); else if ($params->get('layout_type') == 'layout4') require(JModuleHelper::getLayoutPath('mod_rokstories', 'layout4')); else if ($params->get('layout_type') == 'layout5') require(JModuleHelper::getLayoutPath('mod_rokstories', 'layout5')); else if ($params->get('layout_type') == 'layout6') require(JModuleHelper::getLayoutPath('mod_rokstories', 'layout6')); else require(JModuleHelper::getLayoutPath('mod_rokstories')); }
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',4); $catid = trim( $params->get('catid') ); $secid = trim( $params->get('secid') ); $show_front = $params->get('show_front', 1); $aid = $user->get('aid', 0); $content_type = $params->get('content_type','joomla'); $ordering = $params->get('itemsOrdering'); $cid = $params->get('category_id', NULL); $user_id = $params->get('user_id'); $image_size = $params->get('itemImgSize','M'); $thumb_size = $params->get('thumb_width',90); $contentConfig = &JComponentHelper::getParams( 'com_content' ); $access = !$contentConfig->get('shownoauth'); $nullDate = $db->getNullDate(); $date =& JFactory::getDate(); $now = $date->toMySQL(); $where = ''; // User Filter switch ($user_id) { case 'by_me': $where .= ' AND (a.created_by = ' . (int) $userId . ' OR a.modified_by = ' . (int) $userId . ')'; break; case 'not_me': $where .= ' AND (a.created_by <> ' . (int) $userId . ' AND a.modified_by <> ' . (int) $userId . ')'; break; } // ensure should be published $where .= " AND ( a.publish_up = ".$db->Quote($nullDate)." OR a.publish_up <= ".$db->Quote($now)." )"; $where .= " AND ( a.publish_down = ".$db->Quote($nullDate)." OR a.publish_down >= ".$db->Quote($now)." )"; // ordering switch ($ordering) { case 'date' : $orderby = 'a.created ASC'; break; case 'rdate' : $orderby = 'a.created DESC'; break; case 'alpha' : $orderby = 'a.title'; break; case 'ralpha' : $orderby = 'a.title DESC'; break; case 'order' : $orderby = 'a.ordering'; break; default : $orderby = 'a.id DESC'; break; } // content specific stuff if ($content_type=='joomla') { // start Joomla specific $catCondition = ''; $secCondition = ''; if ($show_front != 2) { 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' : '') . ($show_front == '2' ? ' INNER 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 a.state = 1'. $where .' AND s.id > 0' . ($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : ''). ($catid && $show_front != 2 ? $catCondition : ''). ($secid && $show_front != 2 ? $secCondition : ''). ($show_front == '0' ? ' AND f.content_id IS NULL ' : ''). ' AND s.published = 1' . ' AND cc.published = 1' . ' ORDER BY '. $orderby; // end Joomla specific } else { // start K2 specific require_once (JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'route.php'); $query = "SELECT a.*, c.name as categoryname,c.id as categoryid, c.alias as categoryalias, c.params as categoryparams". " FROM #__k2_items as a". " LEFT JOIN #__k2_categories c ON c.id = a.catid"; $query .= " WHERE a.published = 1" ." AND a.access <= {$aid}" ." AND a.trash = 0" ." AND c.published = 1" ." AND c.access <= {$aid}" ." AND c.trash = 0" ; if ($params->get('catfilter')){ if (!is_null($cid)) { if (is_array($cid)) { $query .= " AND a.catid IN(".implode(',', $cid).")"; } else { $query .= " AND a.catid={$cid}"; } } } if ($params->get('FeaturedItems')=='0') $query.= " AND a.featured != 1"; if ($params->get('FeaturedItems')=='2') $query.= " AND a.featured = 1"; $query .= $where . ' ORDER BY ' . $orderby; // end K2 specific } $db->setQuery($query, 0, $count); $rows = $db->loadObjectList(); $i=0; $lists = array(); if (is_array($rows) && count($rows)>0) { foreach ( $rows as $row ) { //process content plugins $text = JHTML::_('content.prepare',$row->introtext,$cparams); $lists[$i]->id = $row->id; $lists[$i]->created = $row->created; $lists[$i]->modified = $row->modified; $lists[$i]->title = htmlspecialchars( $row->title ); $lists[$i]->introtext = modRokStoriesHelper::prepareContent($text, $params); if ($content_type=='joomla') { $lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid)); $images = modRokStoriesHelper::getImages($row->introtext,$thumb_size); } else { $lists[$i]->link = JRoute::_(K2HelperRoute::getItemRoute($row->id.':'.$row->alias, $row->catid.':'.$row->categoryalias)); $images = modRokStoriesHelper::getK2Images($row->id,$image_size,$thumb_size); } $lists[$i]->image = $images->image; $lists[$i]->thumb = $images->thumb; $lists[$i]->thumbSizes = $images->thumbSizes; $i++; } } return $lists; }