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


PHP JComponentHelper::getComponents方法代码示例

本文整理汇总了PHP中JComponentHelper::getComponents方法的典型用法代码示例。如果您正苦于以下问题:PHP JComponentHelper::getComponents方法的具体用法?PHP JComponentHelper::getComponents怎么用?PHP JComponentHelper::getComponents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JComponentHelper的用法示例。


在下文中一共展示了JComponentHelper::getComponents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

 /**
  * Function to convert a route to an internal URI
  *
  * @param   JUri  &$uri  The uri.
  *
  * @return  array
  *
  * @since   1.5
  */
 public function parse(&$uri)
 {
     $vars = array();
     if ($this->app->get('force_ssl') == 2 && strtolower($uri->getScheme()) != 'https') {
         // Forward to https
         $uri->setScheme('https');
         $this->app->redirect((string) $uri, 301);
     }
     // Get the path
     // Decode URL to convert percent-encoding to unicode so that strings match when routing.
     $path = urldecode($uri->getPath());
     // Remove the base URI path.
     $path = substr_replace($path, '', 0, strlen(JUri::base(true)));
     // Check to see if a request to a specific entry point has been made.
     if (preg_match("#.*?\\.php#u", $path, $matches)) {
         // Get the current entry point path relative to the site path.
         $scriptPath = realpath($_SERVER['SCRIPT_FILENAME'] ? $_SERVER['SCRIPT_FILENAME'] : str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']));
         $relativeScriptPath = str_replace('\\', '/', str_replace(JPATH_SITE, '', $scriptPath));
         // If a php file has been found in the request path, check to see if it is a valid file.
         // Also verify that it represents the same file from the server variable for entry script.
         if (file_exists(JPATH_SITE . $matches[0]) && $matches[0] == $relativeScriptPath) {
             // Remove the entry point segments from the request path for proper routing.
             $path = str_replace($matches[0], '', $path);
         }
     }
     // Identify format
     if ($this->_mode == JROUTER_MODE_SEF) {
         if ($this->app->get('sef_suffix') && !(substr($path, -9) == 'index.php' || substr($path, -1) == '/')) {
             if ($suffix = pathinfo($path, PATHINFO_EXTENSION)) {
                 $vars['format'] = $suffix;
             }
         }
     }
     // Set the route
     $uri->setPath(trim($path, '/'));
     // Set the parsepreprocess components methods
     $components = JComponentHelper::getComponents();
     foreach ($components as $component) {
         $componentRouter = $this->getComponentRouter($component->option);
         if (method_exists($componentRouter, 'parsepreprocess')) {
             $this->attachParseRule(array($componentRouter, 'parsepreprocess'), static::PROCESS_BEFORE);
         }
     }
     $vars += parent::parse($uri);
     return $vars;
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:55,代码来源:site.php

示例2: preloadComponents

 /**
  * Method to preload the JAccessRules objects for all components.
  *
  * Note: This will only get the base permissions for the component.
  * e.g. it will get 'com_content', but not 'com_content.article.1' or
  * any more specific asset type rules.
  *
  * @return   array Array of component names that were preloaded.
  *
  * @since    1.6
  */
 protected static function preloadComponents()
 {
     // Add root to asset names list.
     $components = array();
     // Add enabled components to asset names list.
     foreach (JComponentHelper::getComponents() as $component) {
         if ($component->enabled) {
             $components[] = $component->option;
         }
     }
     // Get the database connection object.
     $db = JFactory::getDbo();
     // Get the asset info for all assets in asset names list.
     $query = $db->getQuery(true)->select($db->qn(array('id', 'name', 'rules', 'parent_id')))->from($db->qn('#__assets'))->where($db->qn('name') . ' IN (' . implode(',', $db->quote($components)) . ', ' . $db->quote('root.1') . ')');
     // Get the Name Permission Map List
     $assets = $db->setQuery($query)->loadObjectList('name');
     // Add the root asset as parent of all components.
     $assetsTree = array();
     $rootName = 'root.1';
     foreach ($assets as $extensionName => $asset) {
         $assetsTree[$extensionName][] = $assets[$rootName];
         if ($extensionName !== $rootName) {
             $assetsTree[$extensionName][] = $assets[$extensionName];
         }
     }
     // Save the permissions for the components asset.
     foreach ($assetsTree as $extensionName => $assets) {
         if (!isset(self::$preloadedAssetTypes[$extensionName])) {
             self::$assetPermissionsById[$extensionName] = array();
             self::$assetPermissionsByName[$extensionName] = array();
             foreach ($assets as $asset) {
                 self::$assetPermissionsById[$extensionName][$asset->id] = $asset;
                 self::$assetPermissionsByName[$extensionName][$asset->name] = $asset;
             }
             self::$preloadedAssetTypes[$extensionName] = true;
         }
     }
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:49,代码来源:access.php


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