JURI/base: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Returns the base URI for the request.
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>... |
m removing red link to edit, no existant pages |
||
| Line 3: | Line 3: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[< | <nowiki>[<! removed edit link to red link >]</nowiki> | ||
</span> | </span> | ||
<! removed transcluded page call, red link never existed > | |||
===Syntax=== | ===Syntax=== | ||
| Line 67: | Line 67: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[< | <nowiki>[<! removed edit link to red link >]</nowiki> | ||
</span> | </span> | ||
<! removed transcluded page call, red link never existed > | |||
===Examples=== | ===Examples=== | ||
| Line 82: | Line 82: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
[[Category:Archived pages API15]] | |||
Revision as of 18:55, 12 May 2013
Description
Returns the base URI for the request.
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
base($pathonly=false)
| Parameter Name | Default Value | Description |
|---|---|---|
| $pathonly | false | $pathonly If false, prepend the scheme, host and port information. Default is false. |
Returns
string The base URI string
Defined in
libraries/joomla/environment/uri.php
Importing
jimport( 'joomla.environment.uri' );
Source Body
function base($pathonly = false)
{
static $base;
// Get the base request path
if (!isset($base))
{
$config =& JFactory::getConfig();
$live_site = $config->getValue('config.live_site');
if(trim($live_site) != '') {
$uri =& JURI::getInstance($live_site);
$base['prefix'] = $uri->toString( array('scheme', 'host', 'port'));
$base['path'] = rtrim($uri->toString( array('path')), '/\\');
if(JPATH_BASE == JPATH_ADMINISTRATOR) {
$base['path'] .= '/administrator';
}
} else {
$uri =& JURI::getInstance();
$base['prefix'] = $uri->toString( array('scheme', 'host', 'port'));
if (strpos(php_sapi_name(), 'cgi') !== false && !empty($_SERVER['REQUEST_URI'])) {
//Apache CGI
$base['path'] = rtrim(dirname(str_replace(array('"', '<', '>', "'"), '', $_SERVER["PHP_SELF"])), '/\\');
} else {
//Others
$base['path'] = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
}
}
}
return $pathonly === false ? $base['prefix'].$base['path'].'/' : $base['path'];
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />