finish off like/dislike localisation except for zrl/magic_link
This commit is contained in:
parent
9050faa487
commit
55df0452b6
@ -88,41 +88,46 @@ function localize_item(&$item){
|
|||||||
if($extracted['images'])
|
if($extracted['images'])
|
||||||
$item['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $item['contact-id']);
|
$item['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $item['contact-id']);
|
||||||
|
|
||||||
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
logger('localize');
|
||||||
/*
|
|
||||||
if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){
|
if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){
|
||||||
|
|
||||||
// FIXME we shouldn't have a DB lookup on every item
|
$obj= json_decode($item['object']);
|
||||||
$r = q("SELECT * from `item`,`contact` WHERE
|
|
||||||
`item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
|
|
||||||
dbesc($item['parent_uri']));
|
|
||||||
if(count($r)==0) return;
|
|
||||||
$obj=$r[0];
|
|
||||||
|
|
||||||
$author = '[url=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/url]';
|
// logger('object: ' . print_r($obj,true));
|
||||||
$objauthor = '[url=' . $obj['author-link'] . ']' . $obj['author-name'] . '[/url]';
|
|
||||||
|
|
||||||
switch($obj['verb']){
|
if($obj->author && $obj->author->link)
|
||||||
case ACTIVITY_POST:
|
$author_link = get_json_rel_link($obj->author->link,'alternate');
|
||||||
switch ($obj['obj_type']){
|
else
|
||||||
|
$author_link = '';
|
||||||
|
|
||||||
|
$author_name = (($obj->author && $obj->author->name) ? $obj->author->name : '');
|
||||||
|
|
||||||
|
$item_url = get_json_rel_link($obj->link,'alternate');
|
||||||
|
|
||||||
|
|
||||||
|
// If we couldn't parse something useful, don't bother translating.
|
||||||
|
// We need something better than zrl here, probably magic_link(), but it needs writing
|
||||||
|
|
||||||
|
if($author_link && $author_name && $item_url) {
|
||||||
|
|
||||||
|
$author = '[url=' . zrl($item['author']['xchan_url']) . ']' . $item['author']['xchan_name'] . '[/url]';
|
||||||
|
$objauthor = '[url=' . zrl($author_link) . ']' . $author_name . '[/url]';
|
||||||
|
|
||||||
|
switch($obj->type) {
|
||||||
|
case ACTIVITY_OBJ_PHOTO:
|
||||||
|
$post_type = t('photo');
|
||||||
|
break;
|
||||||
case ACTIVITY_OBJ_EVENT:
|
case ACTIVITY_OBJ_EVENT:
|
||||||
$post_type = t('event');
|
$post_type = t('event');
|
||||||
break;
|
break;
|
||||||
|
case ACTIVITY_OBJ_NOTE:
|
||||||
default:
|
default:
|
||||||
$post_type = t('status');
|
$post_type = t('status');
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
if($obj['resource_id']){
|
|
||||||
$post_type = t('photo');
|
|
||||||
$m=array(); preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
|
|
||||||
$rr['plink'] = $m[1];
|
|
||||||
} else {
|
|
||||||
$post_type = t('status');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
|
$plink = '[url=' . zrl($item_url) . ']' . $post_type . '[/url]';
|
||||||
|
|
||||||
if(activity_match($item['verb'],ACTIVITY_LIKE)) {
|
if(activity_match($item['verb'],ACTIVITY_LIKE)) {
|
||||||
$bodyverb = t('%1$s likes %2$s\'s %3$s');
|
$bodyverb = t('%1$s likes %2$s\'s %3$s');
|
||||||
@ -133,7 +138,9 @@ function localize_item(&$item){
|
|||||||
$item['body'] = sprintf($bodyverb, $author, $objauthor, $plink);
|
$item['body'] = sprintf($bodyverb, $author, $objauthor, $plink);
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
}
|
||||||
|
|
||||||
if (activity_match($item['verb'],ACTIVITY_FRIEND)) {
|
if (activity_match($item['verb'],ACTIVITY_FRIEND)) {
|
||||||
|
|
||||||
if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return;
|
if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return;
|
||||||
|
@ -1721,3 +1721,19 @@ function find_xchan_in_array($xchan,$arr) {
|
|||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_json_rel_link($j,$rel) {
|
||||||
|
if(count($j))
|
||||||
|
foreach($j as $l)
|
||||||
|
if($l->rel === $rel)
|
||||||
|
return $l->href;
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Lots of code to write here
|
||||||
|
|
||||||
|
function magic_link($s) {
|
||||||
|
return $s;
|
||||||
|
}
|
||||||
|
|
@ -69,7 +69,7 @@ function like_content(&$a) {
|
|||||||
dbesc($item['author_xchan'])
|
dbesc($item['author_xchan'])
|
||||||
);
|
);
|
||||||
if($r)
|
if($r)
|
||||||
$item_owner = $r[0];
|
$item_author = $r[0];
|
||||||
else
|
else
|
||||||
killme();
|
killme();
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
2012-11-05.129
|
2012-11-06.130
|
||||||
|
Reference in New Issue
Block a user