allow non-linkable locations, self-linked locations and get rid of google default location link

This commit is contained in:
friendica 2013-02-02 16:34:00 -08:00
parent 09ece497f7
commit b41106f2fb
2 changed files with 22 additions and 17 deletions

View File

@ -135,16 +135,8 @@ class Item extends BaseObject {
$profile_link = chanlink_url($item['author']['xchan_url']); $profile_link = chanlink_url($item['author']['xchan_url']);
$profile_name = $item['author']['xchan_name']; $profile_name = $item['author']['xchan_name'];
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); $location = format_location($item);
call_hooks('render_location',$locate);
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate));
// are we still using $item['tag']? Need to check...
$tags = array();
foreach(explode(',',$item['tag']) as $tag){
$tag = trim($tag);
if ($tag!="") $tags[] = bbcode($tag);
}
$showlike = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : ''); $showlike = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : '');
$showdislike = ((x($dlike,$item['uri']) && feature_enabled($conv->get_profile_owner(),'dislike')) $showdislike = ((x($dlike,$item['uri']) && feature_enabled($conv->get_profile_owner(),'dislike'))
@ -200,7 +192,7 @@ class Item extends BaseObject {
'template' => $this->get_template(), 'template' => $this->get_template(),
'type' => implode("",array_slice(explode("/",$item['verb']),-1)), 'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
'tags' => $tags, 'tags' => array(),
'body' => $body, 'body' => $body,
'text' => strip_tags($body), 'text' => strip_tags($body),
'id' => $this->get_id(), 'id' => $this->get_id(),

View File

@ -548,10 +548,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
$profile_avatar = $item['author']['xchan_photo_m']; $profile_avatar = $item['author']['xchan_photo_m'];
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); $location = format_location($item);
call_hooks('render_location',$locate);
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate));
localize_item($item); localize_item($item);
if($mode === 'network-new') if($mode === 'network-new')
@ -1085,9 +1082,25 @@ function find_thread_parent_index($arr,$x) {
return false; return false;
} }
function render_location_google($item) { function format_location($item) {
$location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
$coord = (($item['coord']) ? '<a target="map" title="' . $item['coord'] . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : ''); if(strpos($item['location'],'#') === 0) {
$location = substr($item['location'],1);
$location = ((strpos($location,'[') !== false) ? bbcode($location) : $location);
}
else {
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
call_hooks('render_location',$locate);
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_default($locate));
}
return $location;
}
function render_location_default($item) {
$location = $item['location'];
$coord = $item['coord'];
if($coord) { if($coord) {
if($location) if($location)
$location .= '<br /><span class="smalltext">(' . $coord . ')</span>'; $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';