Actions

API15

JURI/base

From Joomla! Documentation

< API15:JURI
Revision as of 17:20, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Returns the base URI for the request.

[Edit Descripton]

Description:JURI/base

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'];
}

[Edit See Also] SeeAlso:JURI/base

Examples

<CodeExamplesForm />