helper.php
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* @package Joomla.Site
* @subpackage mod_banners
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Environment\Browser;
/**
* Helper for mod_banners
*
* @since 1.5
*/
class ModBannersHelper
{
/**
* Retrieve list of banners
*
* @param \Joomla\Registry\Registry &$params module parameters
*
* @return mixed
*/
public static function &getList(&$params)
{
JModelLegacy::addIncludePath(JPATH_ROOT . '/components/com_banners/models', 'BannersModel');
$document = JFactory::getDocument();
$app = JFactory::getApplication();
$keywords = explode(',', $document->getMetaData('keywords'));
$config = ComponentHelper::getParams('com_banners');
$model = JModelLegacy::getInstance('Banners', 'BannersModel', array('ignore_request' => true));
$model->setState('filter.client_id', (int) $params->get('cid'));
$model->setState('filter.category_id', $params->get('catid', array()));
$model->setState('list.limit', (int) $params->get('count', 1));
$model->setState('list.start', 0);
$model->setState('filter.ordering', $params->get('ordering'));
$model->setState('filter.tag_search', $params->get('tag_search'));
$model->setState('filter.keywords', $keywords);
$model->setState('filter.language', $app->getLanguageFilter());
$banners = $model->getItems();
if ($banners)
{
if ($config->get('track_robots_impressions', 1) == 1 || !Browser::getInstance()->isRobot())
{
$model->impress();
}
}
return $banners;
}
}