Current Path :
/
home
/
develito
/
public_html
/
components
/
com_raforms
/
helpers
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/develito/public_html/components/com_raforms/helpers/route.php
<?php /* ------------------------------------------------------------------------ # com_raforms - rootArea Forms # ------------------------------------------------------------------------ # author Markus Döhla # copyright Copyright (C) 2012 rootarea.de. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # @license - Please read policy about plugins development in administrator/components/com_raforms/license-plugins.txt carefully # @license - Additional EULA on www.rootarea.de DOES NOT apply to ANY lite packages # Websites: http://www.rootarea.de # Technical Support: Forum - http://www.rootarea.de/en/forum ------------------------------------------------------------------------- */ // no direct access defined('_JEXEC') or die; // Component Helper jimport('joomla.application.component.helper'); jimport('joomla.application.categories'); abstract class RAformsHelperRoute { protected static $lookup; public static function getRAformRoute($id, $catid, $formView = 'fform') { $needles = array( 'raforms' => array((int) $id) ); //Create the link $link = 'index.php?option=com_raforms&view=' . $formView . '&task=' . $formView . '.display&formid='. $id; if ($catid > 1) { $categories = JCategories::getInstance('RAforms'); $category = $categories->get($catid); if ($category) { $needles['category'] = array_reverse($category->getPath()); $needles['categories'] = $needles['category']; $link .= '&catid='.$catid; } } if ($item = self::_findItem($needles)) { $link .= '&Itemid='.$item; } elseif ($item = self::_findItem()) { $link .= '&Itemid='.$item; } return $link; } public static function getCategoryRoute($catid, $formView = 'fform') { if ($catid instanceof JCategoryNode) { $id = $catid->id; $category = $catid; } else { $id = (int) $catid; $category = JCategories::getInstance('RAforms')->get($id); } if($id < 1) { $link = ''; } else { $needles = array( 'category' => array($id) ); if ($item = self::_findItem($needles)) { $link = 'index.php?Itemid='.$item; } else { //Create the link $link = 'index.php?option=com_raforms&form-view=' . $formView . '&view=category&id=' . $id; if($category) { $catids = array_reverse($category->getPath()); $needles = array( 'category' => $catids, 'categories' => $catids ); if ($item = self::_findItem($needles)) { $link .= '&Itemid='.$item; } elseif ($item = self::_findItem()) { $link .= '&Itemid='.$item; } } } } return $link; } protected static function _findItem($needles = null) { $app = JFactory::getApplication(); $menus = $app->getMenu('site'); // Prepare the reverse lookup array. if (self::$lookup === null) { self::$lookup = array(); $component = JComponentHelper::getComponent('com_raforms'); $items = $menus->getItems('component_id', $component->id); foreach ($items as $item) { if (isset($item->query) && isset($item->query['view'])) { $view = $item->query['view']; if (!isset(self::$lookup[$view])) { self::$lookup[$view] = array(); } if (isset($item->query['id'])) { self::$lookup[$view][$item->query['id']] = $item->id; } } } } if ($needles) { foreach ($needles as $view => $ids) { if (isset(self::$lookup[$view])) { foreach($ids as $id) { if (isset(self::$lookup[$view][(int)$id])) { return self::$lookup[$view][(int)$id]; } } } } } else { $active = $menus->getActive(); if ($active) { return $active->id; } } return null; } }