本文整理汇总了PHP中JMenu::getItems方法的典型用法代码示例。如果您正苦于以下问题:PHP JMenu::getItems方法的具体用法?PHP JMenu::getItems怎么用?PHP JMenu::getItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMenu
的用法示例。
在下文中一共展示了JMenu::getItems方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getItemsFromPlatform
/**
* 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);
}
示例2: makeLookup
/**
* 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;
}
}
}
}
示例3: getItems
/**
* 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);
}
示例4: getItems
/**
* 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);
}
示例5: buildFromViewAndId
/**
* 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.
}
示例6: getItemsFromPlatform
/**
* 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);
}
示例7: getItems
/**
* 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);
}