forked from lasinducharith/joomla-tags-selected
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.php
65 lines (57 loc) · 1.85 KB
/
helper.php
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
61
62
63
64
65
<?php
/**
* @package Joomla.Site
* @subpackage mod_tags_popular
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Helper for mod_tags_popular
*
* @package Joomla.Site
* @subpackage mod_tags_popular
* @since 3.1
*/
abstract class ModTagsselectedHelper
{
public static function getContentList($params)
{
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
//$matchtype = $params->get('matchtype', 'all');
$maximum = $params->get('maximum', 5);
$tagsHelper = new JHelperTags;
$option = $app->input->get('option');
$view = $app->input->get('view');
$prefix = $option . '.' . $view;
$id = (array) $app->input->getObject('id');
$selectedTag = $params->get('selected_tag');
// Strip off any slug data.
foreach ($id as $id)
{
if (substr_count($id, ':') > 0)
{
$idexplode = explode(':', $id);
$id = $idexplode[0];
}
}
$tagsToMatch = $selectedTag;
if (!$tagsToMatch || is_null($tagsToMatch))
{
return $results = false;
}
$query=$tagsHelper->getTagItemsQuery($tagsToMatch, $typesr = null, $includeChildren = false, $orderByOption = 'c.core_title', $orderDir = 'ASC',$anyOrAll = true, $languageFilter = 'all', $stateFilter = '0,1');
$db->setQuery($query, 0, $maximum);
$results = $db->loadObjectList();
foreach ($results as $result)
{
$explodedAlias = explode('.', $result->type_alias);
$result->link = 'index.php?option=' . $explodedAlias[0] . '&view=' . $explodedAlias[1] . '&id=' . $result->content_item_id . '-' . $result->core_alias;
}
return $results;
}
}