elxisUri

από Elxis Team

URL handler and management class

The elxisUri class parses and analyzes the requested URI string. It actually validates and splits the URL into URI segments. The query string (if any) is stored separately.

Most important public methods

detectSSL

Returns true if the page was requested using an SSL/TLS connection or false.

public function detectSSL()

getElxisUri

Returns the Elxis formatted version of the requested URL. You can set if you wish to include also in the returned string the language indentifier and the query string (if any). If, for example, the current URL is: http://www.example.com/documentor/utilities/ then getElxisUri will return: documentor:utilities/

public function getElxisUri($with_lang=false, $with_query_string=false)

getUriString

Returns the whole URI string.

public function getUriString()

getUriLang

Returns the current language indentifier in URL. Empty for the site's default language.

public function getUriLang()

getQueryString

Returns the current query string (if any).

public function getQueryString()

getRoute

Returns the URI's first segment (can be empty, file, or directory). Note that it might be different from the current component if a custom route has been set.

public function getRoute()

getComponent

Returns the requested component.

public function getComponent()

getSegments

Returns an array of parsed URI segments (without the query string and the language indentifier).

public function getSegments()

secureURL

Returns the SSL version of a URL only if the $force parameter is true or the current page has been requested via SSL/TLS.

public function secureURL($url='', $force=false)
alias on elxisFramework class: eFactory::getElxis()->secureURL($url, $force);

makeURL

Generates a URL from an Elxis formatted URI string.

public function makeURL($elxis_uri='', $file='', $forcessl=false, $xhtml=true, $isadmin=false)
  • $file can be index.php, inner.php, empty (defaults to index.php) or other (very special cases).
  • $forcessl can be true or false.
  • $xhtml If true, Elxis will convert ampersands (&) to &
  • $isadmin True for admin URLs (see shorthad method makeAURL)
alias on elxisFramework eFactory::getElxis()->makeURL($elxis_uri, $file, $forcessl, $xhtml);

Example 1

makeURL('fr:documentor:test/', '', true)

The above will generate:

https://www.example.com/fr/documentor/test/ if SSL is enabled
or 
http://www.example.com/fr/documentor/test/ if SSL is not enabled

Example 2

makeURL('documentor:test/')

The above will generate:

http://www.example.com/documentor/test/ if the site's default language is currently active
or 
http://www.example.com/el/documentor/test/ if the user has switched language to Greek
or 
http://www.example.com/it/documentor/test/ if the user has switched language to Italian
etc...

Note that if the documentor components has been mapped to an other SEO base name the mapped name will return instead of the string documentor.

Example 3: Component documentor is mapped to help.

makeURL('documentor:test/')

result:

http://www.example.com/help/test/

Example 4: inner.php or non-SEF

If $file is different than index.php, or SEF is disabled in Elxis configuration, the returned URL will also containg the $file value.

makeURL('documentor:test/', 'inner.php')

result:

http://www.example.com/inner.php/help/test/

makeAURL

A shortcut of makeURL with $isadmin true by default.

public function makeAURL($elxis_uri='', $file='', $var=false, $xhtml=true)

makeSecureURL

A shortcut of makeURL with $forcessl true by default.

public function makeSecureURL($elxis_uri='', $file='', $xhtml=true, $isadmin=false)

makeSecureAURL

A shortcut of makeURL with $forcessl true AND $isadmin true by default.

public function makeSecureAURL($elxis_uri='', $file='', $xhtml=true)



 

Έχει διαβαστεί 4731 φορές
Ετικέτες: elxisuri url makeurl secureurl
elxisDocument
Προηγούμενο άρθρο
elxisDocument
elxisPlugin
Επόμενο άρθρο
elxisPlugin

Μπορείτε να αντιγράψετε, διανείμετε και παρουσιάσετε τα άρθρα αυτού του ιστότοπου για μη εμπορικούς σκοπούς.
Creative Commons 3.0