本文整理汇总了PHP中JMenu::getItem方法的典型用法代码示例。如果您正苦于以下问题:PHP JMenu::getItem方法的具体用法?PHP JMenu::getItem怎么用?PHP JMenu::getItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMenu
的用法示例。
在下文中一共展示了JMenu::getItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createURI
/**
* Create a uri based on a full or partial url string
*
* @param string $url The URI
*
* @return JUri
*
* @since 3.2
*/
protected function createURI($url)
{
// Create the URI
$uri = parent::createURI($url);
// Get the itemid form the URI
$itemid = $uri->getVar('Itemid');
if (is_null($itemid)) {
if ($option = $uri->getVar('option')) {
$item = $this->menu->getItem($this->getVar('Itemid'));
if (isset($item) && $item->component == $option) {
$uri->setVar('Itemid', $item->id);
}
} else {
if ($option = $this->getVar('option')) {
$uri->setVar('option', $option);
}
if ($itemid = $this->getVar('Itemid')) {
$uri->setVar('Itemid', $itemid);
}
}
} else {
if (!$uri->getVar('option')) {
if ($item = $this->menu->getItem($itemid)) {
$uri->setVar('option', $item->component);
}
}
}
return $uri;
}
示例2: buildSefRoute
/**
* Build the SEF route
*
* @param JRouterSite &$router Router object
* @param JUri &$uri URI object to process
*
* @return void
*
* @since 4.0
*/
public function buildSefRoute(&$router, &$uri)
{
// Get the route
$route = $uri->getPath();
// Get the query data
$query = $uri->getQuery(true);
if (!isset($query['option'])) {
return;
}
// Build the component route
$component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $query['option']);
$tmp = '';
$Itemid = isset($query['Itemid']) ? $query['Itemid'] : null;
$crouter = $this->getComponentRouter($component);
$parts = $crouter->build($query);
$tmp = trim(implode('/', $parts));
if (empty($query['Itemid']) && !empty($Itemid)) {
$query['Itemid'] = $Itemid;
}
// Build the application route
if (isset($query['Itemid']) && ($item = $this->menu->getItem($query['Itemid']))) {
if (is_object($item) && $query['option'] == $item->component) {
if (!$item->home) {
$tmp = !empty($tmp) ? $item->route . '/' . $tmp : $item->route;
}
unset($query['Itemid']);
}
} else {
$tmp = 'component/' . substr($query['option'], 4) . '/' . $tmp;
}
$route .= '/' . $tmp;
// Unset unneeded query information
unset($query['option']);
// Set query again in the URI
$uri->setQuery($query);
$uri->setPath(trim($route, '/'));
}
示例3: parse
/**
* Parse method for URLs
* This method is meant to transform the human readable URL back into
* query parameters. It is only executed when SEF mode is switched on.
*
* @param array &$segments The segments of the URL to parse.
*
* @return array The URL attributes to be used by the application.
*
* @since 3.3
*/
public function parse(&$segments)
{
/*
* Available urls:
*
* projects
* {project}
* {project}/issues
* {project}/{issue}
* {project}/{issue}/edit
* comment/edit/{comment}
* comments
*/
$query = array('option' => 'com_monitor');
if (empty($query['Itemid'])) {
$menuItem = $this->menu->getActive();
} else {
$menuItem = $this->menu->getItem($query['Itemid']);
}
if (empty(array_filter($segments))) {
return $menuItem->query;
}
$menuQuery = $menuItem !== null && $menuItem->query['option'] === self::COMPONENT ? $menuItem->query : null;
self::convertTaskToView($menuQuery);
$menuView = isset($menuQuery['view']) ? $menuQuery['view'] : null;
if ($segments[0] == 'projects') {
$query['view'] = 'projects';
} elseif ($segments[0] == 'issues') {
$query['view'] = 'issues';
if ($menuView == 'project' && isset($menuQuery['id'])) {
$query['project_id'] = $menuQuery['id'];
}
} elseif ($segments[0] == 'comment') {
$query['view'] = 'comment';
$query['layout'] = $segments[1] === 'delete' ? 'delete' : 'edit';
if (isset($segments[1]) && $segments[1] == 'new' && is_numeric($segments[2])) {
$query['issue_id'] = $segments[2];
} elseif (is_numeric($segments[2])) {
$query['id'] = $segments[2];
}
} elseif ($segments[0] == 'comments') {
$query['view'] = 'comments';
} elseif (is_numeric($segments[0])) {
$query['view'] = 'issue';
$query['id'] = $segments[0];
if (isset($segments[1]) && $segments[1] === 'edit') {
$query['layout'] = 'edit';
}
} elseif ($segments[0] === 'edit' || $segments[0] === 'new') {
$query['layout'] = 'edit';
if ($menuView === 'comment') {
$query['view'] = 'comment';
if (is_numeric($segments[1])) {
if ($segments[0] === 'new') {
$query['issue_id'] = $segments[1];
} else {
$query['id'] = $segments[1];
}
}
} else {
$query['view'] = 'issue';
if ($segments[0] === 'new') {
if (isset($menuQuery['id'])) {
$query['project_id'] = $menuQuery['id'];
} elseif (isset($menuQuery['project_id'])) {
$query['project_id'] = $menuQuery['project_id'];
}
} else {
if (isset($menuQuery['id'])) {
$query['id'] = $menuQuery['id'];
}
}
}
} else {
// {project}
if (!isset($segments[1])) {
$id = $this->modelProject->resolveAlias($segments[0]);
$query['view'] = 'project';
$query['id'] = $id;
} else {
// {project}/issues
if ($segments[1] === 'issues') {
$id = $this->modelProject->resolveAlias($segments[0]);
$query['view'] = 'issues';
$query['project_id'] = $id;
} else {
$query['view'] = 'issue';
// {project}/new
if ($segments[1] === 'new') {
//.........这里部分代码省略.........