当前位置: 首页>>代码示例>>PHP>>正文


PHP JMenu::getItem方法代码示例

本文整理汇总了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;
 }
开发者ID:educakanchay,项目名称:educared,代码行数:38,代码来源:site.php

示例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, '/'));
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:47,代码来源:site.php

示例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') {
//.........这里部分代码省略.........
开发者ID:Harmageddon,项目名称:com_monitor,代码行数:101,代码来源:router.php


注:本文中的JMenu::getItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。