API16

JURI/base

< API16:JURI

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description

Returns the base URI for the request.



Syntax

static 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

public static 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($_SERVER['PHP_SELF']), '/\\');
                        }
                        else
                        {
                                //Others
                                $base['path'] =  rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
                        }
                }
        }

        return $pathonly === false ? $base['prefix'].$base['path'].'/' : $base['path'];
}



Examples

Code Examples


Advertisement