X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Flocation.php;h=191550d6d6ca53e213f4a13f3b6b8bd2fc763a65;hb=69ac99ff949ab0118ff25a62471980ad0ec7a52b;hp=5b7f47102f412e420d5c7c654f92589ebffb6c3b;hpb=9c983c383029c9aaa7d0cf04a5fc9973d514dff7;p=quix0rs-gnu-social.git diff --git a/lib/location.php b/lib/location.php index 5b7f47102f..191550d6d6 100644 --- a/lib/location.php +++ b/lib/location.php @@ -47,10 +47,12 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { class Location { - public $lat; - public $lon; - public $location_id; - public $location_ns; + public $lat; + public $lon; + public $location_id; + public $location_ns; + private $_url; + private $_rdfurl; var $names = array(); @@ -90,6 +92,10 @@ class Location static function fromId($id, $ns, $language=null) { + if (is_null($language)) { + $language = common_language(); + } + $location = null; // Let a third-party handle it @@ -146,7 +152,7 @@ class Location $language = common_language(); } - if (array_key_exists($this->names, $language)) { + if (array_key_exists($language, $this->names)) { return $this->names[$language]; } else { $name = null; @@ -157,4 +163,50 @@ class Location } } } + + /** + * Get an URL suitable for this location + * + * @return string URL for this location or NULL + */ + + function getURL() + { + // Keep one cached + + if (is_string($this->_url)) { + return $this->_url; + } + + $url = null; + + Event::handle('LocationUrl', array($this, &$url)); + + $this->_url = $url; + + return $url; + } + + /** + * Get an URL for this location, suitable for embedding in RDF + * + * @return string URL for this location or NULL + */ + + function getRdfURL() + { + // Keep one cached + + if (is_string($this->_rdfurl)) { + return $this->_rdfurl; + } + + $url = null; + + Event::handle('LocationRdfUrl', array($this, &$url)); + + $this->_rdfurl = $url; + + return $url; + } }