Beispiel #1
0
 /**
  * Get menu items from the platform.
  *
  * @param array $params
  * @return array    List of routes to the pages.
  */
 protected function getItemsFromPlatform($params)
 {
     $attributes = ['menutype'];
     $values = [$params['menu']];
     // Items are already filtered by access and language, in admin we need to work around that.
     if (\JFactory::getApplication()->isAdmin()) {
         $attributes[] = 'access';
         $values[] = null;
         $attributes[] = 'language';
         $values[] = null;
     }
     return $this->menu->getItems($attributes, $values);
 }
Beispiel #2
0
 /**
  * Fills the lookup variable.
  *
  * @return null
  */
 private function makeLookup()
 {
     $this->lookup = array();
     $component = JComponentHelper::getComponent('com_monitor');
     $attributes = array('component_id');
     $values = array($component->id);
     $items = $this->menu->getItems($attributes, $values);
     foreach ($items as $item) {
         if (isset($item->query)) {
             switch ($item->query['view']) {
                 case 'projects':
                     $this->addLookup((int) $item->id, 'projects');
                     break;
                 case 'comments':
                     $this->addLookup((int) $item->id, 'comments');
                     break;
                 case 'project':
                     if (isset($item->query['id'])) {
                         $this->addLookup((int) $item->id, 'project', $item->query['id']);
                     }
                     break;
                 case 'issues':
                     $id = isset($item->query['project_id']) ? $item->query['project_id'] : '_';
                     $this->addLookup((int) $item->id, 'issues', $id);
                     break;
                 case 'issue':
                     $layout = isset($item->query['layout']) ? $item->query['layout'] : 'default';
                     if (isset($item->query['id'])) {
                         $this->addLookup((int) $item->id, 'issue', $item->query['id'], $layout);
                     } elseif ($layout === 'edit' && isset($item->query['project_id'])) {
                         $this->addLookup((int) $item->id, 'issue', $item->query['project_id'], 'new');
                     }
                     break;
                 case 'comment':
                     if (isset($item->query['id'])) {
                         $this->addLookup((int) $item->id, 'comment', $item->query['id'], 'edit');
                     } elseif (isset($item->query['issue_id'])) {
                         $this->addLookup((int) $item->id, 'comment', $item->query['id'], 'new');
                     }
                     break;
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Gets menu items by attribute
  *
  * @param	string	$attributes	The field name
  * @param	string	$values		The value of the field
  * @param	boolean	$firstonly	If true, only returns the first item found
  *
  * @return	array
  */
 public function getItems($attributes, $values, $firstonly = false)
 {
     $attributes = (array) $attributes;
     $values = (array) $values;
     $app = JApplication::getInstance('site');
     if ($app->isSite()) {
         // Filter by language if not set
         if (($key = array_search('language', $attributes)) === false) {
             if ($app->getLanguageFilter()) {
                 $attributes[] = 'language';
                 $values[] = array(JFactory::getLanguage()->getTag(), '*');
             }
         } elseif ($values[$key] === null) {
             unset($attributes[$key]);
             unset($values[$key]);
         }
         // Filter by access level if not set
         if (($key = array_search('access', $attributes)) === false) {
             $attributes[] = 'access';
             $values[] = JFactory::getUser()->getAuthorisedViewLevels();
         } elseif ($values[$key] === null) {
             unset($attributes[$key]);
             unset($values[$key]);
         }
     }
     return parent::getItems($attributes, $values, $firstonly);
 }
Beispiel #4
0
	/**
	 * Gets menu items by attribute
	 *
	 * @param	string	$attributes	The field name
	 * @param	string	$values		The value of the field
	 * @param	boolean	$firstonly	If true, only returns the first item found
	 *
	 * @return	array
	 */
	public function getItems($attributes, $values, $firstonly = false)
	{
		$attributes = (array) $attributes;
		$values = (array) $values;
		$app	= JFactory::getApplication();
		// Filter by language if not set
		if ($app->isSite() && $app->getLanguageFilter() && !array_key_exists('language',$attributes)) {
			$attributes[]='language';
			$values[]=array(JFactory::getLanguage()->getTag(), '*');
		}
		return parent::getItems($attributes, $values, $firstonly);
	}
 /**
  * buildFromViewAndId
  *
  * @param string  $component
  * @param string  $view
  * @param array   $queries
  * @param boolean $replace
  * @param \JMenu  $menu
  */
 public static function buildFromViewAndId($component, $view, &$queries, &$replace, \JMenu $menu)
 {
     // Get all com_flower menus
     $menuItems = $menu->getItems('component', $component);
     // Find matched menu item.
     foreach ($menuItems as $menuItem) {
         if (isset($menuItem->query['view']) && $menuItem->query['view'] == $view && isset($menuItem->query['id']) && $menuItem->query['id'] == $queries['id']) {
             // Replace core route rule.
             $replace = true;
             // Only return menu Itemid then Joomla will convert to menu alias
             $queries = array('Itemid' => $menuItem->id);
         }
     }
     // No menu matched, follows default rule.
 }
Beispiel #6
0
 /**
  * Get menu items from the platform.
  *
  * @param array $params
  * @return array    List of routes to the pages.
  */
 protected function getItemsFromPlatform($params)
 {
     // Items are already filtered by ViewLevels and user language.
     return $this->menu->getItems('menutype', $params['menu'] ?: $this->default->menutype);
 }
Beispiel #7
0
 /**
  * Gets menu items by attribute
  *
  * @param   string   $attributes  The field name
  * @param   string   $values      The value of the field
  * @param   boolean  $firstonly   If true, only returns the first item found
  *
  * @return  array
  *
  * @since   1.6
  */
 public function getItems($attributes, $values, $firstonly = false)
 {
     $attributes = (array) $attributes;
     $values = (array) $values;
     if ($this->app->isSite()) {
         // Filter by language if not set
         if (($key = array_search('language', $attributes)) === false) {
             if (JLanguageMultilang::isEnabled()) {
                 $attributes[] = 'language';
                 $values[] = array(JFactory::getLanguage()->getTag(), '*');
             }
         } elseif ($values[$key] === null) {
             unset($attributes[$key]);
             unset($values[$key]);
         }
         // Filter by access level if not set
         if (($key = array_search('access', $attributes)) === false) {
             $attributes[] = 'access';
             $values[] = $this->user->getAuthorisedViewLevels();
         } elseif ($values[$key] === null) {
             unset($attributes[$key]);
             unset($values[$key]);
         }
     }
     // Reset arrays or we get a notice if some values were unset
     $attributes = array_values($attributes);
     $values = array_values($values);
     return parent::getItems($attributes, $values, $firstonly);
 }