本文整理汇总了PHP中JURI::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP JURI::getQuery方法的具体用法?PHP JURI::getQuery怎么用?PHP JURI::getQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JURI
的用法示例。
在下文中一共展示了JURI::getQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkLogin
function checkLogin()
{
global $mainframe;
DEFINE('GOTOSTARTPAGE_COOKIE', 'ap_gotostartpage');
DEFINE('LOGINPAGELOCATION_COOKIE', 'ap_loginpagelocation');
DEFINE('STARTPAGE_COOKIE', 'ap_startpage');
$gotostartpage = @$_COOKIE[GOTOSTARTPAGE_COOKIE];
if ($gotostartpage) {
setcookie(GOTOSTARTPAGE_COOKIE, 0);
$uri = JFactory::getURI();
$url = $uri->toString();
$loginpagelocation = @$_COOKIE[LOGINPAGELOCATION_COOKIE];
$loginpagelocationuri = new JURI($loginpagelocation);
$query = $loginpagelocationuri->getQuery();
if ($query && strpos($query, 'com_login') === FALSE) {
if ($loginpagelocation && $url != $loginpagelocation) {
$mainframe->redirect($loginpagelocation);
}
} else {
$startpage = @$_COOKIE[STARTPAGE_COOKIE];
if ($startpage && $url != $startpage) {
$mainframe->redirect($startpage);
}
}
}
}
示例2: getList
/**
* Function for getting the list of languages
*
* @return array Language list
*/
public static function getList()
{
$app = JFactory::getApplication();
$languages = JLanguageHelper::getLanguages();
$db = JFactory::getDbo();
$Itemid = $app->input->getInt('Itemid', 0);
$uri = new JURI(Juri::current());
$uri->delVar('lang');
$uri->delVar('Itemid');
$location = htmlspecialchars($uri->getQuery());
if (!empty($location)) {
$location .= '&';
}
if (!$Itemid) {
$active = $app->getMenu()->getActive();
if ($active) {
$Itemid = $active->id;
}
}
// For every language we load menu items language specific alias and params
foreach ($languages as $i => $language) {
$db->forceLanguageTranslation = $language->lang_code;
RMenu::resetJoomlaMenuItems();
$db->forceLanguageTranslation = false;
$languages[$i]->active = $language->lang_code == JFactory::getLanguage()->getTag();
$languages[$i]->link = RRoute::_('index.php?' . $location . 'lang=' . $language->sef . ($Itemid > 0 ? '&Itemid=' . $Itemid : ''));
}
// After we are done we reset it the way it was
RMenu::resetJoomlaMenuItems();
return $languages;
}
示例3: 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);
}
}
示例4: testGetQuery
public function testGetQuery() {
$this->object->parse('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment');
$this->assertThat(
$this->object->getQuery(),
$this->equalTo('var=value')
);
}
示例5: _
public static function _($uri = null, $xhtml = true, $ssl = 0)
{
jimport('joomla.environment.uri');
if (!$uri) {
$link = self::current(true);
$link->delVar('Itemid');
$link->delVar('defaultmenu');
$link->delVar('language');
} else {
if (is_numeric($uri)) {
$item = self::$menu[intval($uri)];
return JRoute::_($item->link . "&Itemid={$item->id}");
} else {
$link = new JURI((string) $uri);
}
}
$query = $link->getQuery(true);
$Itemid = self::_getItemID($query);
$link->setVar('Itemid', $Itemid);
return JRoute::_('index.php?' . $link->getQuery(), $xhtml, $ssl);
}
示例6: checkAclViolation
public function checkAclViolation($data)
{
$redirectUrl = XiptRoute::_($this->getRedirectUrl());
$redirectURI = new JURI($redirectUrl);
$redirectVar = $redirectURI->getQuery(true);
foreach ($redirectVar as $key => $value) {
if (array_key_exists($key, $data)) {
if ($value != $data[$key]) {
return true;
}
}
}
return false;
}
示例7: JURI
function _addItemId($url)
{
$Jurl = new JURI($url);
$query = $Jurl->getQuery(true);
//already itemid is there
if (isset($query['Itemid'])) {
return $url;
}
XiptBuildRoute($query);
// no menu there, so we can't add item id
if (!isset($query['Itemid'])) {
return $url;
}
//we have menu so add it's item id
return $url . "&Itemid=" . $query['Itemid'];
}
示例8: getRouterLink
/**
*
* Ajax sef URL
*/
public function getRouterLink()
{
error_reporting(0);
$config = JFactory::getConfig();
if ($config->get('sef') == 1) {
$url = base64_decode(JRequest::getVar('link', ''));
if ($url) {
$uri = new JURI($url);
$query = $uri->getQuery();
if ($query) {
$routeLink = JRoute::_('index.php?' . $query);
echo base64_encode($routeLink);
} else {
echo base64_encode(JURI::root());
}
}
} else {
echo 'error';
}
jexit();
}
示例9: _fetchStringForSigning
/**
* Method to get the OAuth message string for signing.
*
* Note: As of PHP 5.3 the $this->encode() function is RFC 3986 compliant therefore this requires PHP 5.3+
*
* @param string $requestUrl The message's request URL.
* @param string $requestMethod The message's request method.
*
* @return string The unsigned OAuth message string.
*
* @link http://www.faqs.org/rfcs/rfc3986
* @see $this->encode()
* @since 1.0
*/
public function _fetchStringForSigning($requestUrl, $requestMethod)
{
// Get a JURI instance for the request URL.
$uri = new JURI($requestUrl);
// Initialise base array.
$base = array();
// Get the found parameters.
$params = $this->getParameters();
// Add the variables from the URI query string.
foreach ($uri->getQuery(true) as $k => $v) {
if (strpos($k, 'oauth_') !== 0) {
$params[$k] = $v;
}
}
// Make sure that any found oauth_signature is not included.
unset($params['oauth_signature']);
// Ensure the parameters are in order by key.
ksort($params);
// Iterate over the keys to add properties to the base.
foreach ($params as $key => $value) {
// If we have multiples for the parameter let's loop over them.
if (is_array($value)) {
// Don't want to do this more than once in the inner loop.
$key = $this->encode($key);
// Sort the value array and add each one.
sort($value, SORT_STRING);
foreach ($value as $v) {
$base[] = $key . '=' . $this->encode($v);
}
} else {
$base[] = $this->encode($key) . '=' . $this->encode($value);
}
}
// Start off building the base string by adding the request method and URI.
$base = array($this->encode(strtoupper($requestMethod)), $this->encode(strtolower($uri->toString(array('scheme', 'user', 'pass', 'host', 'port'))) . $uri->getPath()), $this->encode(implode('&', $base)));
return implode('&', $base);
}
示例10: 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'));
}
示例11: __construct
public function __construct($title, $link = null, $class = null, $active = false, $target = null, $titleicon = null)
{
$this->title = $titleicon ? $title . $titleicon : $title;
$this->link = JFilterOutput::ampReplace($link);
$this->class = $class;
$this->active = $active;
$this->id = null;
if (!empty($link) && $link !== '#') {
$uri = new JURI($link);
$params = $uri->getQuery(true);
$parts = array();
foreach ($params as $name => $value) {
$parts[] = str_replace(array('.', '_'), '-', $value);
}
$this->id = implode('-', $parts);
}
$this->target = $target;
}
示例12: parse
function parse(&$uri)
{
$mainframe =& JFactory::getApplication();
// test for the backlink plugin to work correctly
if (JPluginHelper::isEnabled('system', 'backlink')) {
// && $uri->getQuery() ) { // commented out - causing problems
$joomlaRequest = urldecode($_SERVER['REQUEST_URI']);
$realRequest = $uri->toString(array('path', 'query'));
if ($realRequest != $joomlaRequest) {
$uri = new JURI($joomlaRequest);
}
}
// store the old URI before we change it in case we will need it
// for default Joomla SEF
$oldUri = new JURI($uri->toString());
if (!SEFTools::JoomFishInstalled()) {
$url_query = $uri->getQuery();
$host = explode(".", $uri->getHost());
$subdomain = array_shift($host);
$db = JFactory::getDBO();
// Subdomain titlepage
if ($uri->getPath() == '/' && empty($url_query) && empty($_POST)) {
$query = "SELECT Itemid_titlepage FROM #__sef_subdomains WHERE subdomain = " . $db->quote($subdomain) . " LIMIT 1";
$db->setQuery($query);
$Itemid = $db->loadResult();
if ($Itemid > 0) {
$uri->setVar('Itemid', $Itemid);
JoomSEF::set('real_domain', JFactory::getUri()->getHost());
JFactory::getUri()->setHost(implode(".", $host));
}
} else {
$query = "SELECT COUNT(*) FROM #__sef_subdomains WHERE subdomain = " . $db->quote($subdomain);
$db->setQuery($query);
$cnt = $db->loadResult();
if ($cnt) {
JoomSEF::set('real_domain', JFactory::getUri()->getHost());
JFactory::getUri()->setHost(implode(".", $host));
}
}
}
$sefConfig =& SEFConfig::getConfig();
// load patches
JPluginHelper::importPlugin('sefpatch');
// trigger onSefLoad patches
$mainframe->triggerEvent('onSefLoad');
// get path
$path = $uri->getPath();
// remove basepath
$path = substr_replace($path, '', 0, strlen(JURI::base(true)));
// remove slashes
$path = ltrim($path, '/');
// Redirect URL with / on the end to URL without / on the end
if ($sefConfig->redirectSlash) {
$request = $_SERVER["REQUEST_URI"];
$noBase = substr_replace($request, '', 0, strlen(JURI::base(true)));
if ($request != "/" && $noBase != "/" && substr($request, -1) == '/') {
$mainframe->redirect(rtrim($request, "/"), '', 'message');
JFactory::getApplication()->close();
}
}
// Redirect the index.php (need to check this before index.php removal)
if ($sefConfig->fixIndexPhp && $path == 'index.php' && count($_POST) == 0) {
$q = $uri->getQuery(true);
if (count($q) == 0) {
$newUrl = JURI::root();
if (substr($newUrl, -1) != '/') {
$newUrl .= '/';
}
$mainframe->redirect($newUrl, '', 'message', true);
exit;
}
}
// Try the 301 Alias redirect
if (count($_POST) == 0) {
JoomSEF::_parseAlias($path, $uri->getQuery(true));
}
// Disable non-SEF redirect for index2.php links
// EDIT: don't even parse index2.php links!
if (substr($path, 0, 10) == 'index2.php') {
//$sefConfig->nonSefRedirect = false;
return $uri->getQuery(true);
}
// Redirect old /index.php/ links if set to
if ($sefConfig->fixIndexPhp && substr($path, 0, 10) == 'index.php/' && count($_POST) == 0) {
$newUrl = JURI::root();
if (substr($newUrl, -1) != '/') {
$newUrl .= '/';
}
$newUrl .= substr($path, 10);
$mainframe->redirect($newUrl, '', 'message', true);
exit;
}
// remove prefix (both index.php and index2.php)
$path = preg_replace('/^index2?.php/i', '', $path);
// remove slashes again to be sure there aren't any left
$path = ltrim($path, '/');
// replace spaces with our replacement character
// (mainly for '+' handling, but may be useful in some other situations too)
$path = str_replace(' ', $sefConfig->replacement, $path);
// set the route
//.........这里部分代码省略.........
示例13: 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);
}
示例14: getSubDomain
function getSubDomain($Itemid, $uri, &$titlepage)
{
$sefConfig = SEFConfig::getConfig();
$titlepage = false;
$option = $uri->getVar('option');
$db = JFactory::getDBO();
$lang = '*';
if ($sefConfig->langEnable) {
$lang = $uri->getVar('lang', '*');
}
// Get subdomains
$subdomains = self::getAllSubdomains();
if (!array_key_exists($lang, $subdomains)) {
// No subdomain for given language
return null;
}
for ($i = 0; $i < count($subdomains[$lang]); $i++) {
$Itemids = explode(",", $subdomains[$lang][$i]->Itemid);
if ($Itemid == $subdomains[$lang][$i]->Itemid_titlepage) {
$link = new JURI(self::getMenuItemSubDomains($Itemid));
$uri_query = $uri->getQuery(true);
$titlepage = true;
foreach ($link->getQuery(true) as $opt => $val) {
if ($val != @$uri_query[$opt]) {
$titlepage = false;
}
}
return $subdomains[$lang][$i]->subdomain;
}
if ($option == $subdomains[$lang][$i]->option) {
return $subdomains[$lang][$i]->subdomain;
}
if (strlen($subdomains[$lang][$i]->Itemid) && in_array($Itemid, $Itemids)) {
return $subdomains[$lang][$i]->subdomain;
}
}
return null;
}
示例15: _lookupSef
/**
*
* Lookup a SEF url in the cache and database, searching
* for a non-sef associated url
* Returns a record holding query vars and a status code
* If no non-sef is found, incoming query vars are returned untouched
* If a non-sef is found, a query var array is built, merged with incoming vars
* and returned instead of the incoming one
*
* @param JURI object full request details
* @param array $vars key/value pairs of query vars, usually empty
* @param string $sefUrl the sef url to search for
*/
protected function _lookupSef($uri, $vars, $sefUrl)
{
// object to hold result
$result = new stdClass();
// identify Sh404sefClassBaseextplugin::TYPE_SIMPLE URLs, ie simple encoding, DB bypass
$isSimpleUrl = JString::substr($sefUrl, 0, 14) == 'component/com_';
if ($isSimpleUrl) {
// handle manual decoding
$vars = $this->_parseSimpleUrls($sefUrl);
$urlType = sh404SEF_URLTYPE_AUTO;
}
if (!$isSimpleUrl) {
// get a model and check if we've seen this request before
$nonSefUrl = '';
$urlType = JModel::getInstance('Sefurls', 'Sh404sefModel')->getNonSefUrlFromDatabase($sefUrl, $nonSefUrl);
switch ($urlType) {
// existing matching url
case sh404SEF_URLTYPE_AUTO:
case sh404SEF_URLTYPE_CUSTOM:
// our db lookup is case insensitive, which allows
// doing a 301 to the correct url case, avoiding duplicate content
$this->_checkRedirectToCorrectCase($uri, $sefUrl);
// collect the query vars, using a JURI instance
$newUri = new JURI($nonSefUrl);
$vars = array_merge($vars, $newUri->getQuery(true));
break;
// 404 or some kind or error
// 404 or some kind or error
default:
break;
}
}
// store result
$result->vars = $vars;
$result->urlType = $urlType;
return $result;
}