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


PHP JURI::setQuery方法代码示例

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


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

示例1: buildRoute

 /**
  * Method to build the router
  *
  * @param   JRouter  $router  JRouter instance
  * @param   JURI     $uri     Current JURI instance
  *
  * @return null
  */
 public function buildRoute($router, $uri)
 {
     if ($uri->getVar('view') == 'article') {
         $query = $uri->getQuery();
         $query = preg_replace('/\\&id=([0-9]+):([a-z0-9\\-\\_]+)/', '&id=\\2', $query);
         $uri->setQuery($query);
     }
 }
开发者ID:pjasmits,项目名称:JoomlaPluginsBook,代码行数:16,代码来源:ch06test04.php

示例2: testSetQuery

	public function testSetQuery() {
		$this->object->setQuery('somevar=somevalue');

		$this->assertThat(
			$this->object->getQuery(),
			$this->equalTo('somevar=somevalue')
		);
	}
开发者ID:realityking,项目名称:JAJAX,代码行数:8,代码来源:JURITest.php

示例3: testSetQuery

 /**
  * Test the setQuery method.
  *
  * @return  void
  *
  * @since   11.1
  * @covers  JURI::setQuery
  */
 public function testSetQuery()
 {
     $this->object->setQuery('somevar=somevalue');
     $this->assertThat($this->object->getQuery(), $this->equalTo('somevar=somevalue'));
     $this->object->setQuery('somevar=somevalue&test=true');
     $this->assertThat($this->object->getQuery(), $this->equalTo('somevar=somevalue&test=true'));
     $this->object->setQuery(array('somevar' => 'somevalue', 'test' => 'true'));
     $this->assertThat($this->object->getQuery(), $this->equalTo('somevar=somevalue&test=true'));
 }
开发者ID:nprasath002,项目名称:joomla-platform,代码行数:17,代码来源:JURITest.php

示例4: testQuery

 /**
  * Returns the path generated by the Simple Custom Router when building the
  * given query.
  * The query should not contain the leading '?'; it must be just the query
  * itself.
  * 
  * @param string $query The query to build.
  * @return string The generated path, if any.
  */
 public function testQuery($query)
 {
     $simpleCustomRouter = new SimpleCustomRouter();
     $uri = new JURI();
     $uri->setPath('index.php');
     $uri->setQuery($query);
     $siteRouter = null;
     $simpleCustomRouter->build($siteRouter, $uri);
     if ($uri->getPath() == 'index.php') {
         return '';
     } else {
         if ($uri->getQuery() == '') {
             return $uri->getPath();
         } else {
             return $uri->getPath() . '?' . $uri->getQuery();
         }
     }
 }
开发者ID:A-Bush,项目名称:pprod,代码行数:27,代码来源:test.php

示例5: gTranslate

function gTranslate($text, $SourceLan, $ResultLan)
{
    $url = new JURI();
    // for APIv2
    $url->setHost('https://www.googleapis.com/');
    $url->setPath('language/translate/v2');
    $query['key'] = 'AIzaSyC04nF4KXjfR2VQ0jsFm5vEd9LbyiXqbKw';
    $query['q'] = urlencode($text);
    $query['source'] = $SourceLan;
    $query['target'] = $ResultLan;
    if (!$text) {
        return;
    }
    $url->setQuery($query);
    $url->toString();
    $response = AKHelper::_('curl.getPage', $url->toString());
    $json = new JRegistry($response);
    $r = $json->get('data.translations');
    return $r[0]->translatedText;
}
开发者ID:ForAEdesWeb,项目名称:AEW3,代码行数:20,代码来源:gTranslate.php

示例6: pathAddHost

 /**
  * Give a relative path, return path with host.
  *
  * @param   string $path A system path.
  *
  * @return  string  Path with host added.
  */
 public static function pathAddHost($path)
 {
     if (!$path) {
         return;
     }
     // build path
     $uri = new JURI($path);
     if ($uri->getHost()) {
         return $path;
     }
     $uri->parse(JURI::root());
     $root_path = $uri->getPath();
     if (strpos($path, $root_path) === 0) {
         $num = JString::strlen($root_path);
         $path = JString::substr($path, $num);
     }
     $uri->setPath($uri->getPath() . $path);
     $uri->setScheme('http');
     $uri->setQuery(null);
     return $uri->toString();
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:28,代码来源:uri.php

示例7: gTranslate

 /**
  * A method to do Google translate.
  * 
  * @param   string    $text        String to translate.
  * @param   string    $SourceLan   Translate from this language, eg: 'zh-tw'. Empty will auto detect.
  * @param   string    $ResultLan   Translate to this language, eg: 'en'. Empty will auto detect.
  *
  * @return  string    Translated text.  
  */
 public static function gTranslate($text, $SourceLan, $ResultLan)
 {
     $url = new JURI();
     // for APIv2
     $url->setHost('https://www.googleapis.com/');
     $url->setPath('language/translate/v2');
     $query['key'] = self::APT_KEY;
     $query['q'] = urlencode($text);
     $query['source'] = $SourceLan;
     $query['target'] = $ResultLan;
     if (!$text) {
         return;
     }
     $url->setQuery($query);
     $url->toString();
     $response = AKHelper::_('curl.getPage', $url->toString());
     $json = new JRegistry();
     $json->loadString($response);
     $r = $json->get('data.translations');
     return $r[0]->translatedText;
 }
开发者ID:ForAEdesWeb,项目名称:AEW3,代码行数:30,代码来源:lang.php

示例8: JURI

 function _uriToUrl($uri, $removeVariables = null)
 {
     // Create new JURI object
     $url = new JURI($uri->toString(array('path', 'query', 'fragment')));
     // Remove variables if needed
     if (!empty($removeVariables)) {
         if (is_array($removeVariables)) {
             foreach ($removeVariables as $var) {
                 $url->delVar($var);
             }
         } else {
             $url->delVar($removeVariables);
         }
     }
     // sort variables
     $vars = $url->getQuery(true);
     ksort($vars);
     // Move option to beginning
     if (isset($vars['option'])) {
         $opt = $vars['option'];
         unset($vars['option']);
         $vars = array_merge(array('option' => $opt), $vars);
     }
     // Set vars
     $url->setQuery($vars);
     // Create string for db
     return $url->toString(array('path', 'query'));
 }
开发者ID:01J,项目名称:bealtine,代码行数:28,代码来源:joomsef.php

示例9: urldecode

 function _parseSefUrl(&$uri, &$oldUri)
 {
     $mainframe =& JFactory::getApplication();
     $db =& JFactory::getDBO();
     $sefConfig =& SEFConfig::getConfig();
     $route = $uri->getPath();
     $oldRoute = $jSef = str_replace(' ', '+', urldecode($oldUri->getPath()));
     $oldRoute = ltrim($oldRoute, '/');
     //Get the variables from the uri
     $vars = $uri->getQuery(true);
     // Should we generate canonical link automatically?
     $generateCanonical = count($vars) > 0;
     // handle an empty URL (special case)
     if (empty($route)) {
         if (count($vars) > 0 || count($_POST) > 0) {
             $redir = false;
         } else {
             $redir = true;
         }
         JoomSEF::_determineLanguage(JRequest::getVar('lang'), $redir, $redir);
         $menu =& JSite::getMenu(true);
         // if route is empty AND option is set in the query, assume it's non-sef url, and parse apropriately
         if (isset($vars['option']) || isset($vars['Itemid'])) {
             return JoomSEF::_parseRawRoute($uri);
         }
         $item = $menu->getDefault();
         //Set the information in the request
         $vars = $item->query;
         //Get the itemid
         $vars['Itemid'] = $item->id;
         // Set the active menu item
         $menu->setActive($vars['Itemid']);
         // Create automatic canonical link if set to
         if ($generateCanonical) {
             $extAuto = 2;
             if (isset($vars['option'])) {
                 $params =& SEFTools::getExtParams($vars['option']);
                 $extAuto = $params->get('autoCanonical', 2);
             }
             $autoCanonical = $extAuto == 2 ? $sefConfig->autoCanonical : $extAuto;
             if ($extAuto) {
                 JoomSEF::set('sef.link.canonical', JURI::root());
             }
         }
         // MetaTags for frontpage
         $db->setQuery("SELECT `id` FROM `#__plugins` WHERE `element` = 'joomsef' AND `folder` = 'system' AND `published` = '1'");
         if ($db->loadResult()) {
             // ... and frontpage has meta tags
             // If JoomFish installed, get all the URLs for frontpage and try to find the correct language
             $lang = JRequest::getVar('lang');
             $query = "SELECT * FROM `#__sefurls` WHERE (`sefurl` = '' OR `sefurl` = 'index.php') AND `trashed` = '0'";
             if (SEFTools::JoomFishInstalled() && !is_null($lang)) {
                 $db->setQuery($query);
                 $sefRows = $db->loadObjectList();
                 if (is_array($sefRows) && count($sefRows) > 0) {
                     $noLang = null;
                     foreach ($sefRows as $row) {
                         if (preg_match('/[?&]lang=' . $lang . '($|&)/', $row->origurl) > 0) {
                             $sefRow = $row;
                             break;
                         }
                         // Save the first URL with no lang variable
                         if (is_null($noLang)) {
                             if (preg_match('/[?&]lang=[^&]*/', $row->origurl) == 0) {
                                 $noLang = $row;
                             }
                         }
                     }
                     // If not found, try to use the one without lang variable
                     if (empty($sefRow) && !is_null($noLang)) {
                         $sefRow = $noLang;
                     }
                 }
             } else {
                 // Try to find it the old way
                 $db->setQuery($query . ' LIMIT 1');
                 $sefRow = $db->loadObject();
             }
             if (!empty($sefRow)) {
                 $mainframe =& JFactory::getApplication();
                 if (!empty($sefRow->metatitle)) {
                     JoomSEF::set('sef.meta.title', $sefRow->metatitle);
                 }
                 if (!empty($sefRow->metadesc)) {
                     JoomSEF::set('sef.meta.desc', $sefRow->metadesc);
                 }
                 if (!empty($sefRow->metakey)) {
                     JoomSEF::set('sef.meta.key', $sefRow->metakey);
                 }
                 if (!empty($sefRow->metalang)) {
                     JoomSEF::set('sef.meta.lang', $sefRow->metalang);
                 }
                 if (!empty($sefRow->metarobots)) {
                     JoomSEF::set('sef.meta.robots', $sefRow->metarobots);
                 }
                 if (!empty($sefRow->metagoogle)) {
                     JoomSEF::set('sef.meta.google', $sefRow->metagoogle);
                 }
                 if (!empty($sefRow->canonicallink)) {
                     JoomSEF::set('sef.link.canonical', $sefRow->canonicallink);
//.........这里部分代码省略.........
开发者ID:andreassetiawanhartanto,项目名称:PDKKI,代码行数:101,代码来源:joomsef.php

示例10: shNormalizeNonSefUri

function shNormalizeNonSefUri(&$uri, $menu = null, $removeSlugs = true)
{
    // put back a J!1.5 non-sef url to J! 1.0.x format
    // Get the route
    $route = $uri->getPath();
    //Get the query vars
    $vars = $uri->getQuery(true);
    // fix some problems in incoming URLs
    if (!empty($vars['Itemid'])) {
        // sometimes we get doubles : ?Itemid=xx?Itemid=xx
        $vars['Itemid'] = intval($vars['Itemid']);
        $uri->setQuery($vars);
    }
    // fix urls obtained through a single Itemid, in menus : url is option=com_xxx&Itemid=yy
    if (count($vars) == 2 && $uri->getVar('Itemid')) {
        if (empty($menu)) {
            $menu =& shRouter::shGetMenu();
        }
        $shItem = $menu->getItem($vars['Itemid']);
        if (!empty($shItem)) {
            // we found the menu item
            $url = $shItem->link . '&Itemid=' . $shItem->id;
            $uri = new JURI($url);
            // rebuild $uri based on this new url
            $uri->setPath($route);
            $vars = $uri->getQuery(true);
        }
    }
    if ($removeSlugs !== false) {
        $vars = shRemoveSlugs($vars, $removeSlugs);
    }
    $uri->setQuery($vars);
}
开发者ID:sangkasi,项目名称:joomla,代码行数:33,代码来源:sh404sef.class.php

示例11: setQuery

 /**
  * setQuery
  *
  * @param $queries
  *
  * @return void
  */
 public function setQuery($queries)
 {
     $this->uri->setQuery($queries);
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:11,代码来源:sdk.php

示例12: _processBuildRules

 /**
  * Process the build uri query data based on custom defined rules
  *
  * @param   JURI  $uri  The URI
  *
  * @return  void
  */
 protected function _processBuildRules($uri)
 {
     // Make sure any menu vars are used if no others are specified
     if ($this->_mode != JROUTER_MODE_SEF && $uri->getVar('Itemid') && count($uri->getQuery(true)) == 2) {
         $app = JApplication::getInstance('site');
         $menu = $app->getMenu();
         // Get the active menu item
         $itemid = $uri->getVar('Itemid');
         $item = $menu->getItem($itemid);
         if ($item) {
             $uri->setQuery($item->query);
         }
         $uri->setVar('Itemid', $itemid);
     }
     // Process the attached build rules
     parent::_processBuildRules($uri);
     // Get the path data
     $route = $uri->getPath();
     if ($this->_mode == JROUTER_MODE_SEF && $route) {
         $app = JApplication::getInstance('site');
         if ($limitstart = $uri->getVar('limitstart')) {
             $uri->setVar('start', (int) $limitstart);
             $uri->delVar('limitstart');
         }
     }
     $uri->setPath($route);
 }
开发者ID:RuDers,项目名称:JoomlaSQL,代码行数:34,代码来源:site.php

示例13: array

 static function append_sid($hook, $url, $params = false, $is_amp = true, $session_id = false)
 {
     global $_SID, $_EXTRA_URL;
     $arrParams = array();
     $arrExtra = array();
     $anchor = '';
     JForumHook::fixPage();
     $config =& JFactory::getConfig();
     if ($url == '.php') {
         $url = '/' . $config->getValue('config.phpbb_path') . '/index.php';
     }
     // Assign sid if session id is not specified
     if ($session_id === false) {
         $session_id = $_SID;
     }
     //Clean the url and the params first
     if ($is_amp) {
         $url = str_replace('&', '&', $url);
         if (!is_array($params)) {
             $params = str_replace('&', '&', $params);
         }
     }
     $amp_delim = $is_amp ? '&' : '&';
     $url_delim = strpos($url, '?') === false ? '?' : $amp_delim;
     // Process the parameters array
     if (is_array($params)) {
         foreach ($params as $key => $item) {
             if ($item === NULL) {
                 continue;
             }
             if ($key == '#') {
                 $anchor = '#' . $item;
                 continue;
             }
             $arrParams[$key] = $item;
         }
     } else {
         if (strpos($params, '#') !== false) {
             list($params, $anchor) = explode('#', $params, 2);
             $anchor = '#' . $anchor;
         }
         parse_str($params, $arrParams);
     }
     //Process the extra array
     if (!empty($_EXTRA_URL)) {
         $extra = implode('&', $_EXTRA_URL);
         parse_str($extra, $arrExtra);
     }
     //Create the URL
     $uri = new JURI($url);
     $query = $uri->getQuery(true);
     $query = $query + $arrParams + $arrExtra;
     $uri->setQuery($query);
     //Set session id variable
     if ($session_id) {
         $uri->setVar('sid', $session_id);
     }
     //Set fragment
     if ($anchor) {
         $uri->setFragment($anchor);
     }
     $view = basename($uri->getPath(), '.php');
     if (!$uri->getVar('rb_v') && $view != "style") {
         if (JRequest::getVar('rb_v') == 'adm') {
             if (strpos($url, $config->getValue('config.phpbb_path')) === false) {
                 $view = 'adm';
             }
         }
         if (stripos($url, $config->getValue('config.phpbb_path') . '/adm') !== false) {
             $view = 'adm';
         }
         if ($view != 'index') {
             $uri->setVar('rb_v', $view);
         }
     }
     if ($view != 'style') {
         $url = 'index.php' . $uri->toString(array('query', 'fragment'));
         // {} getting lost in encoding
         $url = str_replace(array('%7B', '%7D'), array('{', '}'), $url);
         return urldecode(JURI::base() . JRoute::_($url, $is_amp));
     } else {
         $url = 'style.php' . $uri->toString(array('query', 'fragment'));
         $url = str_replace(array('%7B', '%7D'), array('{', '}'), $url);
         return urldecode(JPATH_ROOT . '/' . $config->getValue('config.phpbb_path') . '/' . $url);
     }
 }
开发者ID:skyview059,项目名称:e-learning-website,代码行数:86,代码来源:hooks.php


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