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


PHP JRouter类代码示例

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


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

示例1: DefaultViewEventCatRowNew

function DefaultViewEventCatRowNew($view, $row, $args = "")
{
    // I choost not to use $row->fgcolor()
    $fgcolor = "inherit";
    $router = JRouter::getInstance("site");
    $vars = $router->getVars();
    $vars["catids"] = $row->catid();
    if (array_key_exists("Itemid", $vars) && is_null($vars["Itemid"])) {
        $vars["Itemid"] = JRequest::getInt("Itemid", 0);
    }
    $eventlink = "index.php?";
    foreach ($vars as $key => $val) {
        $eventlink .= $key . "=" . $val . "&";
    }
    $eventlink = substr($eventlink, 0, strlen($eventlink) - 1);
    $eventlink = JRoute::_($eventlink);
    ?>
		<a class="ev_link_cat" href="<?php 
    echo $eventlink;
    ?>
"  style="color:<?php 
    echo $fgcolor;
    ?>
;" title="<?php 
    echo JEventsHTML::special($row->catname());
    ?>
"><?php 
    echo $row->catname();
    ?>
</a>
		<?php 
}
开发者ID:madcsaba,项目名称:li-de,代码行数:32,代码来源:defaultvieweventcatrownew.php

示例2: testCreateUriGeneratesUriFromUrlAndPreset

 /**
  * Tests createURI() method
  *
  * @param   array  $url      valid inputs to the createURI() method
  * @param   array  $preset   global Vars that should be merged into the URL
  * @param   string $expected expected URI string
  *
  * @dataProvider casesCreateUri
  * @testdox      createUri() generates URI combining URL and preset variables
  * @since        3.4
  */
 public function testCreateUriGeneratesUriFromUrlAndPreset($url, $preset, $expected)
 {
     $this->object->setVars($preset, false);
     $createUriMethod = new ReflectionMethod('JRouter', 'createUri');
     $createUriMethod->setAccessible(true);
     $this->assertEquals($expected, (string) $createUriMethod->invoke($this->object, $url));
 }
开发者ID:joomla-agency,项目名称:joomla-cms,代码行数:18,代码来源:JRouterTest.php

示例3: getUri

 /**
  * Get Uri
  *
  * @param   string  $url  URL
  *
  * @return  JUri
  */
 public function getUri($url = 'SERVER')
 {
     static $uriArray = array();
     if (!array_key_exists($url, $uriArray)) {
         // This will enable both SEF and non-SEF URI to be parsed properly
         $router = clone JRouter::getInstance('site');
         $uri = clone JUri::getInstance($url);
         $langCode = JLanguageHelper::detectLanguage();
         $lang = $uri->getVar('lang', $langCode);
         $uri->setVar('lang', $lang);
         $sefs = JLanguageHelper::getLanguages('lang_code');
         if (isset($sefs[$lang])) {
             $lang = $sefs[$lang]->sef;
             $uri->setVar('lang', $lang);
         }
         $router->setVars(array(), false);
         $query = $router->parse($uri);
         $query = array_merge($query, $uri->getQuery(true));
         $uri->setQuery($query);
         // We are removing format because of default value is csv if present and if not set
         // and we are never going to remember csv page in a browser history anyway
         $uri->delVar('format');
         $uriArray[$url] = $uri;
     }
     return $uriArray[$url];
 }
开发者ID:thangredweb,项目名称:redCORE,代码行数:33,代码来源:browser.php

示例4: browse

 /**
  * Browse the given uri.
  *
  * @param   string   $uri            The uri
  * @param   boolean  $duplicateLast  True to duplicate the last element if it's the same.
  *
  * @return  void
  */
 public function browse($uri = null, $duplicateLast = false)
 {
     // This will enable both SEF and non-SEF URI to be parsed properly
     $router = JRouter::getInstance('site');
     if (null === $uri) {
         $uri = Juri::getInstance();
     } else {
         $uri = Juri::getInstance($uri);
     }
     // We are removing format because of default value is csv if present and if not set
     // and we are never going to remember csv page in a browser history anyway
     $uri->delVar('format');
     $query = $router->parse($uri);
     $uri = 'index.php?' . Juri::getInstance()->buildQuery($query);
     $this->history->enqueue($uri, $duplicateLast);
 }
开发者ID:810,项目名称:redCORE,代码行数:24,代码来源:browser.php

示例5: getContentRoute

 function getContentRoute($url)
 {
     static $router;
     // Only get the router once.
     if (!is_object($router)) {
         // Import dependencies.
         jimport('joomla.application.router');
         require_once JPATH_SITE . DS . 'includes' . DS . 'application.php';
         // Get the site router.
         $config =& JFactory::getConfig();
         $router = JRouter::getInstance('site');
         $router->setMode($config->getValue('sef', 1));
     }
     // Build the route.
     $uri =& $router->build($url);
     $route = $uri->toString(array('path', 'query', 'fragment'));
     // Strip out the base portion of the route.
     $route = str_replace('administrator/', '', $route);
     return $route;
 }
开发者ID:joebushi,项目名称:joomla,代码行数:20,代码来源:view.html.php

示例6: render

    /**
     *
     * JT3 Framework render
     */
    public function render()
    {
        $replace = array();
        $matches = array();
        parent::loadLayout();
        $data = $this->_html;
        if (preg_match_all('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data, $matches)) {
            $cache_exclude = parent::getParam('cache_exclude');
            $cache_exclude = new JRegistry($cache_exclude);
            $nc_com = explode(',', $cache_exclude->get('component'));
            $nc_pos = explode(',', $cache_exclude->get('position'));
            $replace = array();
            $matches[0] = array_reverse($matches[0]);
            $matches[1] = array_reverse($matches[1]);
            $matches[2] = array_reverse($matches[2]);
            $count = count($matches[1]);
            $option = JRequest::getCmd('option');
            $headindex = -1;
            //for none cache items
            $nonecachesearch = array();
            $nonecachereplace = array();
            //search for item load in template (css, images, js)
            $regex = '/(href|src)=("|\')([^"\']*\\/templates\\/' . T3_ACTIVE_TEMPLATE . '\\/([^"\']*))\\2/';
            for ($i = 0; $i < $count; $i++) {
                $attribs = JUtility::parseAttributes($matches[2][$i]);
                $type = $matches[1][$i];
                $name = isset($attribs['name']) ? $attribs['name'] : null;
                //no cache => no cache for all jdoc include except head
                //cache: exclude modules positions & components listed in cache exclude param
                //check if head
                if ($type == 'head') {
                    $headindex = $i;
                } else {
                    $content = parent::getBuffer($type, $name, $attribs);
                    $renderer = $this->loadRenderer('module');
                    $poweradmin = JRequest::getCmd('poweradmin', 0);
                    $vsm_changeposition = JRequest::getCmd('vsm_changeposition', 0);
                    //Add a div wrapper for showing block information
                    if ($poweradmin == 1) {
                        //If the page requested to render position only
                        if ($vsm_changeposition == 1) {
                            if ($type == 'modules') {
                                $content = '<div class="jsn-element-container_inner">' . '<div class="jsn-poweradmin-position clearafter" id="' . $name . '-jsnposition">
												<p>' . $name . '</p>
											</div>
											</div>
										    ';
                            } else {
                                if ($type == 'module') {
                                    $key = "mod.{$name}";
                                } else {
                                    if ($type == 'component') {
                                        $content = '<div class="jsn-component-container" id="jsnrender-component"><div class="jsn-show-component-container"><p>' . parent::getTitle() . '</p></div></div>';
                                    } else {
                                        $key = "{$type}.{$name}";
                                    }
                                }
                            }
                        } else {
                            if ($type == 'modules') {
                                $buffer = '';
                                foreach (JModuleHelper::getModules($name) as $mod) {
                                    $buffer .= '<div class="poweradmin-module-item" id="' . $mod->id . '-jsnposition" ><div id="moduleid-' . $mod->id . '-content">' . $renderer->render($mod, $attribs) . '</div></div>';
                                }
                                $content = '<div class="jsn-element-container_inner">' . '<div class="jsn-poweradmin-position clearafter" id="' . $name . '-jsnposition">
											' . $buffer . '
											</div>
											</div>
										    ';
                            } else {
                                if ($type == 'module') {
                                    $key = "mod.{$name}";
                                } else {
                                    if ($type == 'component') {
                                        $app = JFactory::getApplication();
                                        $itemid = JRequest::getVar('itemid', '');
                                        $menu = $app->getMenu();
                                        if ($itemid) {
                                            $menuItem = $menu->getItem($itemid);
                                        } else {
                                            $menuItem = $menu->getActive();
                                        }
                                        $uri = JURI::getInstance();
                                        $route = JRouter::getInstance('site');
                                        $params = $route->parse($uri);
                                        if (empty($params['id']) && !empty($menuItem->id)) {
                                            $uri->parse($menuItem->link);
                                            $params = $route->parse($uri);
                                        }
                                        if (!empty($params['option'])) {
                                            $key = array_search($params['option'], array('', 'com_content', 'com_categories', 'com_banner', 'com_weblinks', 'com_contact', 'com_newsfeeds', 'com_search', 'com_redirect'));
                                            if ($key) {
                                                if (!empty($params['id'])) {
                                                    if ($params['view'] == 'category') {
                                                        $editLink = 'option=com_categories&task=category.edit&id=' . $params['id'] . '&extension=' . $params['option'] . '&tmpl=component';
                                                        $task = 'category.apply';
//.........这里部分代码省略.........
开发者ID:kleinhelmi,项目名称:tus03_j3_2015_01,代码行数:101,代码来源:jsnjoomlart.php

示例7: getRouter

 public static function getRouter($name = null, array $options = array())
 {
     $name = 'administrator';
     try {
         $router = \JRouter::getInstance($name, $options);
     } catch (\Exception $e) {
         return null;
     }
     return $router;
 }
开发者ID:mvanduijker,项目名称:joomla-cli,代码行数:10,代码来源:Application.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: getRouter

 /**
  * getRouter
  *
  * @return  \JRouterSite
  */
 protected static function getRouter()
 {
     return \JRouter::getInstance('site', ['mode' => JROUTER_MODE_SEF]);
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:9,代码来源:SiteRoute.php

示例10: getUrlVars

 public function getUrlVars($url)
 {
     $router = JRouter::getInstance('site');
     $origVars = $router->getVars();
     $router->setVars(array(), false);
     // DO NOT use JURI::getInstance! Re-routing on the same instance causes big issues
     $juri = new JURI($url);
     // Odd hack to prevent the parsing of the URL to redirect to the https version in certain circumstances
     $jConfig = JFactory::getConfig();
     $forceSSL = $jConfig->get('force_ssl');
     $jConfig->set('force_ssl', 0);
     $queryVars = $router->parse($juri);
     $jConfig->set('force_ssl', $forceSSL);
     // Reset the router back to it's original state
     $router->setVars($origVars);
     return $queryVars;
 }
开发者ID:q0821,项目名称:esportshop,代码行数:17,代码来源:opengraphaction.php

示例11: getContentPath

 /**
  * Method to get the path (SEF route) for a content item.
  *
  * @param   string  $url  The non-SEF route to the content item.
  *
  * @return  string  The path for the content item.
  *
  * @since   2.5
  */
 public static function getContentPath($url)
 {
     static $router;
     // Only get the router once.
     if (!$router instanceof JRouter) {
         jimport('joomla.application.router');
         include_once JPATH_SITE . '/includes/application.php';
         // Get and configure the site router.
         $config = JFactory::getConfig();
         $router = JRouter::getInstance('site');
         $router->setMode($config->get('sef', 1));
     }
     // Build the relative route.
     $uri = $router->build($url);
     $route = $uri->toString(array('path', 'query', 'fragment'));
     $route = str_replace(JURI::base(true) . '/', '', $route);
     return $route;
 }
开发者ID:christianesperar,项目名称:joomla-example,代码行数:27,代码来源:helper.php

示例12: _

 /**
  * 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 &amp; 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

示例13: testSetComponentRouter

 /**
  * Tests the setComponentRouter() method
  *
  * @return  void
  *
  * @since   3.4
  */
 public function testSetComponentRouter()
 {
     // Check if a router that implements JComponentRouterInterface gets accepted
     $router = new TestRouter();
     $this->assertEquals($this->object->setComponentRouter('com_test', $router), true);
     $this->assertSame($this->object->getComponentRouter('com_test'), $router);
     // Check if a false router is correctly rejected
     $this->assertFalse($this->object->setComponentRouter('com_test3', new stdClass()));
 }
开发者ID:nirpan,项目名称:joomla-cms,代码行数:16,代码来源:JRouterSiteTest.php

示例14: _

 /**
  * 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 &amp; 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

示例15: 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


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