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


PHP JRouter::build方法代码示例

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


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

示例1: build

 /**
  * Function to convert an internal URI to a route
  *
  * @param   string  $url  The internal URL
  *
  * @return  string  The absolute search engine friendly URL
  *
  * @since   1.5
  */
 public function build($url)
 {
     $uri = parent::build($url);
     // Get the path data
     $route = $uri->getPath();
     // Add the suffix to the uri
     if ($this->_mode == JROUTER_MODE_SEF && $route) {
         $app = JApplication::getInstance('site');
         if ($app->getCfg('sef_suffix') && !(substr($route, -9) == 'index.php' || substr($route, -1) == '/')) {
             if ($format = $uri->getVar('format', 'html')) {
                 $route .= '.' . $format;
                 $uri->delVar('format');
             }
         }
         if ($app->getCfg('sef_rewrite')) {
             // Transform the route
             if ($route == 'index.php') {
                 $route = '';
             } else {
                 $route = str_replace('index.php/', '', $route);
             }
         }
     }
     // Add basepath to the uri
     $uri->setPath(JUri::base(true) . '/' . $route);
     return $uri;
 }
开发者ID:ryanshowers,项目名称:joomla-cms,代码行数:36,代码来源:site.php

示例2: _

 /**
  * Translates an internal Joomla URL to a humanly readible URL.
  *
  * @param   string   $url    Absolute or Relative URI to Joomla resource.
  * @param   boolean  $xhtml  Replace & by & for XML compilance.
  * @param   integer  $ssl    Secure state for the resolved URI.
  *                             1: Make URI secure using global secure site URI.
  *                             0: Leave URI in the same secure state as it was passed to the function.
  *                            -1: Make URI unsecure using the global unsecure site URI.
  *
  * @return  The translated humanly readible URL.
  *
  * @since   11.1
  */
 public static function _($url, $xhtml = true, $ssl = null)
 {
     if (!self::$_router) {
         // Get the router.
         self::$_router = JFactory::getApplication()->getRouter();
         // Make sure that we have our router
         if (!self::$_router) {
             return null;
         }
     }
     if (strpos($url, '&') !== 0 && strpos($url, 'index.php') !== 0) {
         return $url;
     }
     // Build route.
     $uri = self::$_router->build($url);
     $url = $uri->toString(array('path', 'query', 'fragment'));
     // Replace spaces.
     $url = preg_replace('/\\s/u', '%20', $url);
     /*
      * Get the secure/unsecure URLs.
      *
      * If the first 5 characters of the BASE are 'https', then we are on an ssl connection over
      * https and need to set our secure URL to the current request URL, if not, and the scheme is
      * 'http', then we need to do a quick string manipulation to switch schemes.
      */
     if ((int) $ssl) {
         $uri = JURI::getInstance();
         // Get additional parts.
         static $prefix;
         if (!$prefix) {
             $prefix = $uri->toString(array('host', 'port'));
         }
         // Determine which scheme we want.
         $scheme = (int) $ssl === 1 ? 'https' : 'http';
         // Make sure our URL path begins with a slash.
         if (!preg_match('#^/#', $url)) {
             $url = '/' . $url;
         }
         // Build the URL.
         $url = $scheme . '://' . $prefix . $url;
     }
     if ($xhtml) {
         $url = htmlspecialchars($url);
     }
     return $url;
 }
开发者ID:interfaceslivres,项目名称:ccmd-ufpb,代码行数:60,代码来源:route.php

示例3: _

 /**
  * Translates an internal Joomla URL to a humanly readable URL.
  *
  * @param   string   $url    Absolute or Relative URI to Joomla resource.
  * @param   boolean  $xhtml  Replace & by & for XML compliance.
  * @param   integer  $ssl    Secure state for the resolved URI.
  *                             0: (default) No change, use the protocol currently used in the request
  *                             1: Make URI secure using global secure site URI.
  *                             2: Make URI unsecure using the global unsecure site URI.
  *
  * @return string The translated humanly readable URL.
  *
  * @since   11.1
  */
 public static function _($url, $xhtml = true, $ssl = null)
 {
     if (!self::$_router) {
         // Get the router.
         $app = JFactory::getApplication();
         self::$_router = $app::getRouter();
         // Make sure that we have our router
         if (!self::$_router) {
             return null;
         }
     }
     if (!is_array($url) && strpos($url, '&') !== 0 && strpos($url, 'index.php') !== 0) {
         return $url;
     }
     // Build route.
     $uri = self::$_router->build($url);
     $scheme = array('path', 'query', 'fragment');
     /*
      * Get the secure/unsecure URLs.
      *
      * If the first 5 characters of the BASE are 'https', then we are on an ssl connection over
      * https and need to set our secure URL to the current request URL, if not, and the scheme is
      * 'http', then we need to do a quick string manipulation to switch schemes.
      */
     if ((int) $ssl || $uri->isSsl()) {
         static $host_port;
         if (!is_array($host_port)) {
             $uri2 = JUri::getInstance();
             $host_port = array($uri2->getHost(), $uri2->getPort());
         }
         // Determine which scheme we want.
         $uri->setScheme((int) $ssl === 1 || $uri->isSsl() ? 'https' : 'http');
         $uri->setHost($host_port[0]);
         $uri->setPort($host_port[1]);
         $scheme = array_merge($scheme, array('host', 'port', 'scheme'));
     }
     $url = $uri->toString($scheme);
     // Replace spaces.
     $url = preg_replace('/\\s/u', '%20', $url);
     if ($xhtml) {
         $url = htmlspecialchars($url);
     }
     return $url;
 }
开发者ID:deenison,项目名称:joomla-cms,代码行数:58,代码来源:route.php

示例4: build

 /**
  * Function to convert an internal URI to a route
  *
  * @param   string  $url  The internal URL
  *
  * @return  string  The absolute search engine friendly URL
  *
  * @since   1.5
  */
 public function build($url)
 {
     // Create the URI object
     $uri = parent::build($url);
     // Get the path data
     $route = $uri->getPath();
     // Add basepath to the uri
     $uri->setPath(JUri::base(true) . '/' . $route);
     return $uri;
 }
开发者ID:01J,项目名称:skazkipronebo,代码行数:19,代码来源:administrator.php

示例5: testBuild

 /**
  * testBuild().
  *
  * @param   string   $url       The URL
  * @param   integer  $mode      JROUTER_MODE_RAW or JROUTER_MODE_SEF
  * @param   array    $vars      An associative array with global variables
  * @param   array    $map       Valuemap for JApplication::get() Mock
  * @param   array    $server    Values for $_SERVER
  * @param   array    $expected  Expected value
  *
  * @dataProvider casesBuild
  *
  * @return void
  *
  * @since  3.4
  */
 public function testBuild($url, $mode, $vars, $map, $server, $expected)
 {
     //Set $_SERVER variable
     $_SERVER = array_merge($_SERVER, $server);
     $this->object->setMode($mode);
     $app = $this->object->getApp();
     $app->expects($this->any())->method('get')->will($this->returnValueMap($map));
     $this->object->setApp($app);
     $uri = $this->object->build($url);
     // Check the expected values
     $this->assertEquals($expected, $uri->toString());
     // Check that caching works
     $juri = $this->object->build($url);
     $this->assertEquals($uri, $juri);
 }
开发者ID:nirpan,项目名称:joomla-cms,代码行数:31,代码来源:JRouterSiteTest.php

示例6:

 function &build($url)
 {
     $uri =& parent::build($url);
     // Get the path data
     $route = $uri->getPath();
     //Add the suffix to the uri
     if ($this->_mode == JROUTER_MODE_SEF && $route) {
         $app =& JFactory::getApplication();
         if ($app->getCfg('sef_rewrite')) {
             //Transform the route
             $route = str_replace('index.php/', '', $route);
         }
     }
     //Add basepath to the uri
     $uri->setPath($route);
     return $uri;
 }
开发者ID:skyview059,项目名称:e-learning-website,代码行数:17,代码来源:router.php

示例7: testStagesAreProcessedInCorrectOrder

 /**
  * @param   string $url      The URL
  * @param   string $expected Expected return value
  *
  * @dataProvider casesProcessBuildRulesOrder
  *
  * @since        4.0
  */
 public function testStagesAreProcessedInCorrectOrder($url, $expected)
 {
     $this->object->attachBuildRule(function (JRouter $router, JUri $uri) {
         $uri->setVar('var1', 'before');
         $uri->setVar('var3', 'before');
         $uri->setVar('var4', 'before');
     }, JRouter::PROCESS_BEFORE);
     $this->object->attachBuildRule(function (JRouter $router, JUri $uri) {
         $uri->setVar('var1', 'during');
         $uri->setVar('var4', 'during');
         $uri->setVar('var5', 'during');
     }, JRouter::PROCESS_DURING);
     $this->object->attachBuildRule(function (JRouter $router, JUri $uri) {
         $uri->setVar('var1', 'after');
         $uri->setVar('var5', 'after');
     }, JRouter::PROCESS_AFTER);
     $this->assertEquals($expected, (string) $this->object->build($url));
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:26,代码来源:JRouterTest.php

示例8: siteRoute

 /**
  * Route URI to front-end.
  *
  * @param object  $item
  * @param string  $website
  * @param JRouter $routerSite
  *
  * @return string
  */
 public static function siteRoute($item, $website, $routerSite)
 {
     $routedUri = $routerSite->build(CrowdfundingHelperRoute::getDetailsRoute($item->slug, $item->catslug));
     if ($routedUri instanceof JUri) {
         $routedUri = $routedUri->toString();
     }
     if (false !== strpos($routedUri, "/administrator")) {
         $routedUri = str_replace("/administrator", "", $routedUri);
     }
     return $website . $routedUri;
 }
开发者ID:bellodox,项目名称:CrowdFunding,代码行数:20,代码来源:crowdfundingbackend.php

示例9: build

 public function build($url)
 {
     $uri = parent::build($url);
     // Get the path data
     $route = $uri->getPath();
     //Add the suffix to the uri
     if ($this->_mode == JROUTER_MODE_SEF && $route) {
         $app = JApplication::getInstance('site');
         if ($app->getCfg('sef_suffix') && !(substr($route, -9) == 'index.php' || substr($route, -1) == '/')) {
             if ($format = $uri->getVar('format', 'html')) {
                 $route .= '.' . $format;
                 $uri->delVar('format');
             }
         }
         if ($app->getCfg('sef_rewrite')) {
             //Transform the route
             if ($route == 'index.php') {
                 $route = '';
             } else {
                 $route = str_replace('index.php/', '', $route);
             }
         }
     }
     //Add basepath to the uri
     $uri->setPath(JURI::base(true) . '/' . $route);
     /* START: HUBzero Extension for SEF Groups */
     if (!empty($_SERVER['REWROTE_FROM'])) {
         if (stripos($uri->toString(), $_SERVER['REWROTE_TO']->getPath()) !== false) {
             $uri->setPath(str_replace($_SERVER['REWROTE_TO']->getPath(), '', $uri->getPath()));
             $uri->setHost($_SERVER['REWROTE_FROM']->getHost());
             $uri->setScheme($_SERVER['REWROTE_FROM']->getScheme());
         }
     }
     /* END: HUBzero Extension for SEF Groups */
     return $uri;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:36,代码来源:router.php

示例10:

 function &build($url)
 {
     $uri =& parent::build($url);
     return $uri;
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:5,代码来源:shsef.php

示例11:

 /**
  * Short description for 'build'
  *
  * Long description (if any) ...
  *
  * @param      unknown $url Parameter description (if any) ...
  * @return     object Return description (if any) ...
  */
 function &build($url)
 {
     $uri = parent::build($url);
     // Get the path data
     $route = $uri->getPath();
     //Add the suffix to the uri
     if ($this->_mode == JROUTER_MODE_SEF && $route) {
         $app = JFactory::getApplication();
         if ($app->getCfg('sef_suffix') && !(substr($route, -9) == 'index.php' || substr($route, -1) == '/')) {
             if ($format = $uri->getVar('format', 'html')) {
                 $route .= '.' . $format;
                 $uri->delVar('format');
             }
         }
         if ($app->getCfg('sef_rewrite')) {
             //Transform the route
             $route = str_replace('index.php/', '', $route);
         }
     }
     //Add basepath to the uri
     //$uri->setPath(JURI::base(true).'/'.$route);
     $uri->setPath('/' . $route);
     if (!empty($_SERVER['REWROTE_FROM'])) {
         if (stripos($uri->toString(), $_SERVER['REWROTE_TO']->getPath()) !== false) {
             $uri->setPath(str_replace($_SERVER['REWROTE_TO']->getPath(), '', $uri->getPath()));
             $uri->setHost($_SERVER['REWROTE_FROM']->getHost());
             $uri->setScheme($_SERVER['REWROTE_FROM']->getScheme());
         }
     }
     return $uri;
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:39,代码来源:router.php

示例12: testBuild

 /**
  * Tests the build() method
  *
  * @return  void
  *
  * @since   3.4
  */
 public function testBuild()
 {
     $uri = new JUri('index.php?var1=value1');
     $result = $this->object->build('index.php?var1=value1');
     $this->assertEquals($uri, $result);
     $this->assertEquals($uri, $this->object->build('index.php?var1=value1'));
     $object = new JRouter();
     $object->setMode(JROUTER_MODE_SEF);
     $result = $object->build('index.php?var1=value1');
     $this->assertEquals($uri, $result);
 }
开发者ID:nirpan,项目名称:joomla-cms,代码行数:18,代码来源:JRouterTest.php

示例13:

 function &build($url)
 {
     $uri =& JRouter::build($url);
     // Get the path data
     $route = $uri->getPath();
     //Add the suffix to the uri
     if ($this->_mode == JROUTER_MODE_SEF && $route) {
         $app =& JFactory::getApplication();
         if ($app->getCfg('sef_suffix') && !(substr($route, -9) == 'index.php' || substr($route, -1) == '/')) {
             if ($format = $uri->getVar('format', 'html')) {
                 $route .= '.' . $format;
                 $uri->delVar('format');
             }
         }
         if ($app->getCfg('sef_rewrite')) {
             //Transform the route
             $route = str_replace('index.php/', '', $route);
         }
     }
     // 以下即是JRouterSite的build函数的修改点,仅仅不需要增加baseurl
     //Add basepath to the uri
     //$uri->setPath(JURI::base(true).'/'.$route);
     $uri->setPath($route);
     return $uri;
 }
开发者ID:apachesep,项目名称:joomla-weibo,代码行数:25,代码来源:weibo.php


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