translate "like"/"dislike"/"friends with" messages at print time

This commit is contained in:
fabrixxm 2011-04-18 20:38:48 +02:00
parent 60fbe0b39b
commit 1d8bd89fec
1 changed files with 20 additions and 4 deletions

View File

@ -8,11 +8,17 @@ function localize_item(&$item){
if ($item['verb']=="http://activitystrea.ms/schema/1.0/like" ||
$item['verb']=="http://activitystrea.ms/schema/1.0/dislike"){
$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-link'] . ']' . $item['author-name'] . '[/url]';
#$objauthor = '[url=' . $obj['author-link'] . ']' . $obj['author-name'] . '[/url]';
#$objlink = preg_grep("|<link.*href=&quot;, $input)$item['object']
// $item['verb']=="http://activitystrea.ms/schema/1.0/like"
$objauthor = '[url=' . $obj['author-link'] . ']' . $obj['author-name'] . '[/url]';
$post_type = (($obj['resource-id']) ? t('photo') : t('status'));
$plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
switch($item['verb']){
case "http://activitystrea.ms/schema/1.0/like":
@ -22,10 +28,20 @@ function localize_item(&$item){
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
break;
}
$item['body'] = sprintf($bodyverb, $author, "tizio", "coso");
$item['body'] = sprintf($bodyverb, $author, $objauthor, $plink);
}
if ($item['verb']=='http://activitystrea.ms/schema/1.0/make-friend'){
$b = str_replace("[/url]","[/url]\n", $item['body']);
preg_match_all("|(\[url.*\[/url\])|", $b, $match);
$item['body'] = $match[0][0]." "
.t('is now friends with')
." ".$match[0][1]."\n\n\n"
.$match[0][2];
}
}