joomla /components/com_newsfeeds/helpers/route.php

Language PHP Lines 78
MD5 Hash c70edcc9ae91b318afc39a8490cd7556
Repository https://github.com/joebushi/joomla.git View Raw File View Project SPDX
 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
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
 * @version		$Id: route.php 13088 2009-10-07 13:10:56Z mcsmom $
 * @package		Joomla
 * @subpackage	com_newsfeeds
 * @copyright	Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;

// Component Helper
jimport('joomla.application.component.helper');
jimport('joomla.application.categorytree');

/**
 * Newsfeed Component Route Helper
 *
 * @static
 * @package		Joomla
 * @subpackage	com_newsfeeds
 * @since 1.6
 */

class NewsfeedsHelperRoute
{
	function getNewsfeedsRoute($id, $catid) {
		$needles = array(
			'category' => (int) $catid,
			'categories' => null
		);

		//Find the itemid
		$itemid = NewsfeedsHelperRoute::_findItem($needles);
		$itemid = $itemid ? '&Itemid='.$itemid : '';

		//Create the link
		$link = 'index.php?option=com_newsfeeds&view=newsfeed&id='. $id . '&catid='.$catid . $itemid;

		return $link;
	}

	function _findItem($needles)
	{
		static $items;

		if (!$items)
		{
			$component = &JComponentHelper::getComponent('com_newsfeeds');
			$menu = &JSite::getMenu();
			$items = $menu->getItems('component_id', $component->id);
		}

		if (!is_array($items)) {
			return null;
		}

		$match = null;
		foreach($needles as $needle => $id)
		{
			foreach($items as $item)
			{
				if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id)) {
					$match = $item->id;
					break;
				}
			}

			if (isset($match)) {
				break;
			}
		}

		return $match;
	}
}
?>
Back to Top