Exemplo n.º 1
0
if ($links_block) {
    if ($links_animation != "disabled") {
        $c_links_count = $links_count * $links_slide_count;
    } else {
        $c_links_count = $links_count;
    }
} else {
    $c_links_count = 0;
}
$c_count = $c_article_count + $c_links_count;
if (!class_exists("modTzContentSliderCommonHelper")) {
    require_once 'common.php';
}
if ($content_source == "joomla") {
    require_once dirname(__FILE__) . DS . 'helper.php';
    $list = modTzContentSliderJHelper::getList($params, $c_count);
} elseif ($content_source == "vm") {
    if (!class_exists('VmModel')) {
        require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'vmmodel.php';
    }
    require_once dirname(__FILE__) . DS . 'vmhelper.php';
    $list = modTzContentSliderVMHelper::getList($params, $c_count);
} else {
    require_once dirname(__FILE__) . DS . 'k2helper.php';
    $list = modTzContentSliderK2Helper::getList($params, $c_count);
}
$a_count = count($list);
//actual count
if ($c_count > $a_count) {
    $c_count = $a_count;
    if ($c_article_count >= $c_count) {
Exemplo n.º 2
0
 static function getList($params, $count)
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     // Get an instance of the generic articles model
     $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
     // Set application parameters in model
     $appParams = JFactory::getApplication()->getParams();
     $model->setState('params', $appParams);
     // Set the filters based on the module params
     $model->setState('list.start', 0);
     $catids = $params->get('catids', array());
     $ordering = $params->get('ordering', 'a.ordering');
     $ordering_direction = $params->get('ordering_direction', 'ASC');
     $user_id = $params->get('user_id');
     $show_featured = $params->get('show_featured');
     //sp comments
     $plgParams = "";
     if (JPluginHelper::isEnabled('content', 'spcomments')) {
         $plgname = JPluginHelper::getPlugin('content', 'spcomments');
         $plgParams = new JParameter($plgname->params);
     }
     //sp comments
     $model->setState('list.limit', (int) $count);
     $model->setState('filter.published', 1);
     // User filter
     $userId = JFactory::getUser()->get('id');
     switch ($user_id) {
         case 'by_me':
             $model->setState('filter.author_id', (int) $userId);
             break;
         case 'not_me':
             $model->setState('filter.author_id', $userId);
             $model->setState('filter.author_id.include', false);
             break;
         case '0':
             break;
         default:
             $model->setState('filter.author_id', (int) $user_id);
             break;
     }
     //  Featured switch
     switch ($show_featured) {
         case '1':
             $model->setState('filter.featured', 'only');
             break;
         case '0':
             $model->setState('filter.featured', 'hide');
             break;
         default:
             $model->setState('filter.featured', 'show');
             break;
     }
     /*
     $model->setState('list.select', 'a.fulltext, a.id, a.title, a.alias, a.title_alias, a.introtext, a.state, a.catid, a.created, a.created_by, a.created_by_alias,a.images,' .
     	' a.modified, a.modified_by,a.publish_up, a.publish_down, a.attribs, a.metadata, a.metakey, a.metadesc, a.access,' .
     	' a.hits, a.featured,' .		
     	' LENGTH(a.fulltext) AS readmore');
     */
     // Access filter
     $access = !JComponentHelper::getParams('com_content')->get('show_noauth');
     $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
     $model->setState('filter.access', $access);
     // Category filter
     $model->setState('filter.category_id', $catids);
     // Filter by language
     $model->setState('filter.language', $app->getLanguageFilter());
     // Set ordering
     $model->setState('list.ordering', $ordering);
     $model->setState('list.direction', $ordering_direction);
     //	Retrieve Content
     $items = $model->getItems();
     foreach ($items as &$item) {
         $item->slug = $item->id . ':' . $item->alias;
         $item->catslug = $item->catid . ':' . $item->category_alias;
         $author =& JFactory::getUser($item->created_by);
         $item->author = $item->created_by_alias ? $item->created_by_alias : $author->name;
         $item->created = $item->created;
         $item->hits = $item->hits;
         $item->category = $item->category_title;
         $item->cat_link = JRoute::_(ContentHelperRoute::getCategoryRoute($item->catid));
         $item->image = modTzContentSliderJHelper::getImage($item->introtext, $item->images);
         $item->title = htmlspecialchars($item->title);
         $item->introtext = JHtml::_('content.prepare', $item->introtext);
         $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
         $item->comment = modTzContentSliderJHelper::getComment($item->link, $item->catid, $plgParams);
         $item->rating = $item->rating ? number_format(intval($item->rating) / intval($item->rating_count), 2) * 20 : 0;
     }
     return $items;
 }