/components/com_contact/helpers/route.php
PHP | 78 lines | 46 code | 13 blank | 19 comment | 7 complexity | 7a5b645c0e9a6842df7e502239a7877d MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
- <?php
- /**
- * @version $Id$
- * @package Joomla
- * @subpackage com_content
- * @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');
- /**
- * Contact Component Route Helper
- *
- * @static
- * @package Joomla
- * @subpackage com_contact
- * @since 1.6
- */
- class ContactHelperRoute
- {
- function getContactRoute($id, $catid) {
- $needles = array(
- 'category' => (int) $catid,
- 'categories' => null
- );
- //Find the itemid
- $itemid = ContactHelperRoute::_findItem($needles);
- $itemid = $itemid ? '&Itemid='.$itemid : '';
- //Create the link
- $link = 'index.php?option=com_contact&view=contact&id='. $id . '&catid='.$catid . $itemid;
- return $link;
- }
- function _findItem($needles)
- {
- static $items;
- if (!$items)
- {
- $component = &JComponentHelper::getComponent('com_contact');
- $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;
- }
- }
- ?>