Joomla! Programmierung/Framework/JURI/parse

Aus Joomla! Dokumentation
Wechseln zu: Navigation, Suche

JURI/parse parst die übergebene URI in die internen Objekteigenschaften. Gibt false bei einem Parserfehler zurück.

Inhaltsverzeichnis

[Bearbeiten] Syntax

parse( $uri )
  • @return boolean True bei Erfolg
  • @since Joomla 1.5
Parameter Datentyp Beschreibung Standardwert
$uri string Die URI welche vom JURI Objekt dargestellt werden soll.

[Bearbeiten] Beispiel

In diesem Beispiel wird ein neues URI Objekt erstellt und für eine neue URI wiederverwendet.

$uri = 'http://fredbloggs:itsasecret@www.example.com:8080/path/to/Joomla/index.php?task=view&id=32#anchorthis';
$u =& JURI::getInstance( $uri );
echo 'Die URI ist: '.$u->toString();
 
$u->parse( 'https://www.example.com/joomla/index.php' );
echo 'URI ist: '.$u->toString();

Ausgabe

Die URI ist: http://fredbloggs:itsasecret@www.example.com:8080/path/to/Joomla/index.php?task=view&id=32#anchorthis
Die URI ist: https://www.example.com/joomla/index.php?task=view&id=32

Beachten Sie, dass der query Teil nicht gelöscht wird.

[Bearbeiten] Siehe auch

[Bearbeiten] Quellcode

JURI->parse in Joomla! 2.5.4

Folder blue.png libraries

  • Folder red.png joomla
    • Folder green.png environment
      • File php.png uri.php
  1. public function parse($uri)
  2. {
  3. // Initialise variables
  4. $retval = false;
  5.  
  6. // Set the original URI to fall back on
  7. $this->_uri = $uri;
  8.  
  9. // Parse the URI and populate the object fields. If URI is parsed properly,
  10. // set method return value to true.
  11.  
  12. if ($_parts = JString::parse_url($uri))
  13. {
  14. $retval = true;
  15. }
  16.  
  17. // We need to replace & with & for parse_str to work right...
  18. if (isset($_parts['query']) && strpos($_parts['query'], '&'))
  19. {
  20. $_parts['query'] = str_replace('&', '&', $_parts['query']);
  21. }
  22.  
  23. $this->_scheme = isset($_parts['scheme']) ? $_parts['scheme'] : null;
  24. $this->_user = isset($_parts['user']) ? $_parts['user'] : null;
  25. $this->_pass = isset($_parts['pass']) ? $_parts['pass'] : null;
  26. $this->_host = isset($_parts['host']) ? $_parts['host'] : null;
  27. $this->_port = isset($_parts['port']) ? $_parts['port'] : null;
  28. $this->_path = isset($_parts['path']) ? $_parts['path'] : null;
  29. $this->_query = isset($_parts['query']) ? $_parts['query'] : null;
  30. $this->_fragment = isset($_parts['fragment']) ? $_parts['fragment'] : null;
  31.  
  32. // Parse the query
  33.  
  34. if (isset($_parts['query']))
  35. {
  36. parse_str($_parts['query'], $this->_vars);
  37. }
  38. return $retval;
  39. }
Meine Werkzeuge
Namensräume
Varianten
Aktionen
Navigation
Sonstiges
Team Navigation
Werkzeuge