From f0abc0fe15a54da468cf37e748041bba4f362e53 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 29 Oct 2009 13:18:51 +0100 Subject: Updated bookmarklet. Created its own action --- lib/router.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/router.php b/lib/router.php index dedf73c86..2fd255fe6 100644 --- a/lib/router.php +++ b/lib/router.php @@ -179,6 +179,8 @@ class Router array('action' => 'deletenotice'), array('notice' => '[0-9]+')); + $m->connect('bookmarklet/new', array('action' => 'bookmarklet')); + // conversation $m->connect('conversation/:id', -- cgit v1.2.3-54-g00ecf From a6ed4e5bf7e7c15bc649c91451bbe7b6aa1f0735 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 29 Oct 2009 14:49:00 -0400 Subject: a location method for getting an URL --- lib/location.php | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/location.php b/lib/location.php index 048554f0f..c9411b55d 100644 --- a/lib/location.php +++ b/lib/location.php @@ -47,10 +47,11 @@ 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; var $names = array(); @@ -157,4 +158,33 @@ class Location } } } + + /** + * Get an URL suitable for this location + * + * @return string URL for this location or NULL + */ + + function getURL() + { + if ($this->_url == false) { // cached failure + return null; + } else if (is_string($this->_url)) { // cached value + return $this->_url; + } + + $url = null; + + Event::handle('LocationUrl', array($this, &$url)); + + // Save it for later + + if (is_null($url)) { + $this->_url = false; + } else { + $this->_url = $url; + } + + return $this->_url; + } } -- cgit v1.2.3-54-g00ecf From 5b0809f4a3619e8123b486f7e910913dc4e10086 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 29 Oct 2009 16:15:49 -0400 Subject: fix caching in location.php --- lib/location.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/location.php b/lib/location.php index c9411b55d..bbfc15a36 100644 --- a/lib/location.php +++ b/lib/location.php @@ -91,6 +91,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 @@ -167,9 +171,9 @@ class Location function getURL() { - if ($this->_url == false) { // cached failure - return null; - } else if (is_string($this->_url)) { // cached value + // Keep one cached + + if (is_string($this->_url)) { return $this->_url; } @@ -177,14 +181,8 @@ class Location Event::handle('LocationUrl', array($this, &$url)); - // Save it for later - - if (is_null($url)) { - $this->_url = false; - } else { - $this->_url = $url; - } + $this->_url = $url; - return $this->_url; + return $url; } } -- cgit v1.2.3-54-g00ecf From 49dd54315ffd98b84e64d0377d4c26c07ec4084e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 29 Oct 2009 16:16:02 -0400 Subject: show notice location in notice list --- lib/noticelist.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'lib') diff --git a/lib/noticelist.php b/lib/noticelist.php index 6c296f82a..8b3015cc3 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -199,6 +199,7 @@ class NoticeListItem extends Widget { $this->out->elementStart('div', 'entry-content'); $this->showNoticeLink(); + $this->showNoticeLocation(); $this->showNoticeSource(); $this->showContext(); $this->out->elementEnd('div'); @@ -369,6 +370,44 @@ class NoticeListItem extends Widget $this->out->elementEnd('a'); } + /** + * show the notice location + * + * shows the notice location in the correct language. + * + * If an URL is available, makes a link. Otherwise, just a span. + * + * @return void + */ + + function showNoticeLocation() + { + $id = $this->notice->id; + + $location = $this->notice->getLocation(); + + if (empty($location)) { + return; + } + + $name = $location->getName(); + + if (empty($name)) { + // XXX: Could be a translation issue. Fall back to... something? + return; + } + + $url = $location->getUrl(); + + if (empty($url)) { + $this->out->element('span', array('class' => 'location'), $name); + } else { + $this->out->element('a', array('class' => 'location', + 'href' => $url), + $name); + } + } + /** * Show the source of the notice * -- cgit v1.2.3-54-g00ecf