Merge commit 'mainline/0.9.x' into 0.9.x

This commit is contained in:
Brenda Wallace
2009-10-30 09:41:04 +13:00
17 changed files with 241 additions and 17 deletions

View File

@@ -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();
@@ -90,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
@@ -157,4 +162,27 @@ 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;
}
}

View File

@@ -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
*

View File

@@ -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',