diff options
author | friendica <info@friendica.com> | 2012-11-13 19:32:59 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-11-13 19:32:59 -0800 |
commit | aa88165383b14c35114549334567f362e9c83e54 (patch) | |
tree | 4f5eae97b6c1df5eab3a0b6ff198c539981839c0 /include | |
parent | 4af6d77de3e282002682c28b2709b217b4ae9306 (diff) | |
download | volse-hubzilla-aa88165383b14c35114549334567f362e9c83e54.tar.gz volse-hubzilla-aa88165383b14c35114549334567f362e9c83e54.tar.bz2 volse-hubzilla-aa88165383b14c35114549334567f362e9c83e54.zip |
mood mostly working
Diffstat (limited to 'include')
-rw-r--r-- | include/conversation.php | 88 | ||||
-rw-r--r-- | include/notify.php | 6 | ||||
-rw-r--r-- | include/text.php | 10 |
3 files changed, 51 insertions, 53 deletions
diff --git a/include/conversation.php b/include/conversation.php index 74160c309..1d068f424 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -83,7 +83,7 @@ function item_redir_and_replace_images($body, $images, $cid) { * Render actions localized */ -function localize_item(&$item,$brief = false){ +function localize_item(&$item){ $extracted = item_extract_images($item['body']); if($extracted['images']) @@ -93,18 +93,16 @@ function localize_item(&$item,$brief = false){ if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){ - $obj= json_decode($item['object']); + $obj= json_decode($item['object'],true); -// logger('object: ' . print_r($obj,true)); - - if($obj->author && $obj->author->link) - $author_link = get_json_rel_link($obj->author->link,'alternate'); + if($obj['author'] && $obj['author']['link']) + $author_link = get_rel_link($obj['author']['link'],'alternate'); else $author_link = ''; - $author_name = (($obj->author && $obj->author->name) ? $obj->author->name : ''); + $author_name = (($obj['author'] && $obj['author']['name']) ? $obj['author']['name'] : ''); - $item_url = get_json_rel_link($obj->link,'alternate'); + $item_url = get_rel_link($obj['link'],'alternate'); // If we couldn't parse something useful, don't bother translating. @@ -139,7 +137,7 @@ function localize_item(&$item,$brief = false){ elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) { $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s'); } - $item['body'] = sprintf($bodyverb, $author, $objauthor, $plink); + $item['body'] = $item['localize'] = sprintf($bodyverb, $author, $objauthor, $plink); } @@ -149,56 +147,48 @@ function localize_item(&$item,$brief = false){ if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return; - $Aname = $item['author-name']; - $Alink = $item['author-link']; + $Aname = $item['author']['xchan_name']; + $Alink = $item['author']['xchan_url']; - $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; - $obj = parse_xml_string($xmlhead.$item['object']); - $links = parse_xml_string($xmlhead."<links>".unxmlify($obj->link)."</links>"); - - $Bname = $obj->title; - $Blink = ""; $Bphoto = ""; - foreach ($links->link as $l){ - $atts = $l->attributes(); - switch($atts['rel']){ - case "alternate": $Blink = $atts['href']; - case "photo": $Bphoto = $atts['href']; - } + $obj= json_decode($item['object'],true); + + $Blink = $Bphoto = ''; + if($obj['link']) { + $Blink = get_rel_link($obj['link'],'alternate'); + $Bphoto = get_rel_link($obj['link'],'photo'); } + $Bname = $obj['title']; + $A = '[url=' . zid($Alink) . ']' . $Aname . '[/url]'; $B = '[url=' . zid($Blink) . ']' . $Bname . '[/url]'; - if ($Bphoto!="") $Bphoto = '[url=' . zid($Blink) . '][img]' . $Bphoto . '[/img][/url]'; - - $item['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto; + if ($Bphoto!="") $Bphoto = '[url=' . zid($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]'; + $item['body'] = $item['localize'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B); + $item['body'] .= "\n\n\n" . $Bphoto; } + if (stristr($item['verb'],ACTIVITY_POKE)) { $verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1)); if(! $verb) return; if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return; - $Aname = $item['author-name']; - $Alink = $item['author-link']; + $Aname = $item['author']['xchan_name']; + $Alink = $item['author']['xchan_url']; - $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; - $obj = parse_xml_string($xmlhead.$item['object']); - $links = parse_xml_string($xmlhead."<links>".unxmlify($obj->link)."</links>"); - - $Bname = $obj->title; - $Blink = ""; $Bphoto = ""; - foreach ($links->link as $l){ - $atts = $l->attributes(); - switch($atts['rel']){ - case "alternate": $Blink = $atts['href']; - case "photo": $Bphoto = $atts['href']; - } + $obj= json_decode($item['object'],true); + + $Blink = $Bphoto = ''; + if($obj['link']) { + $Blink = get_rel_link($obj['link'],'alternate'); + $Bphoto = get_rel_link($obj['link'],'photo'); } + $Bname = $obj['title']; $A = '[url=' . zid($Alink) . ']' . $Aname . '[/url]'; $B = '[url=' . zid($Blink) . ']' . $Bname . '[/url]'; @@ -215,7 +205,8 @@ function localize_item(&$item,$brief = false){ // then do the sprintf on the translation string - $item['body'] = sprintf($txt, $A, $B). "\n\n\n" . $Bphoto; + $item['body'] = $item['localize'] = sprintf($txt, $A, $B); + $item['body'] .= "\n\n\n" . $Bphoto; } if (stristr($item['verb'],ACTIVITY_MOOD)) { @@ -223,14 +214,18 @@ function localize_item(&$item,$brief = false){ if(! $verb) return; - $Aname = $item['author-name']; - $Alink = $item['author-link']; + $Aname = $item['author']['xchan_name']; + $Alink = $item['author']['xchan_url']; + $A = '[url=' . zid($Alink) . ']' . $Aname . '[/url]'; $txt = t('%1$s is currently %2$s'); $item['body'] = sprintf($txt, $A, t($verb)); } +/* +// FIXME store parent item as object or target +// (and update to json storage) if (activity_match($item['verb'],ACTIVITY_TAG)) { $r = q("SELECT * from `item`,`contact` WHERE @@ -269,13 +264,14 @@ function localize_item(&$item,$brief = false){ $item['body'] = sprintf( t('%1$s tagged %2$s\'s %3$s with %4$s'), $author, $objauthor, $plink, $tag ); } + if (activity_match($item['verb'],ACTIVITY_FAVORITE)){ if ($item['obj_type']== "") return; - $Aname = $item['author-name']; - $Alink = $item['author-link']; + $Aname = $item['author']['xchan_name']; + $Alink = $item['author']['xchan_url']; $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; @@ -297,6 +293,8 @@ function localize_item(&$item,$brief = false){ } } } +*/ + $matches = null; if(preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) { foreach($matches as $mtch) { diff --git a/include/notify.php b/include/notify.php index 468c31558..a551444ee 100644 --- a/include/notify.php +++ b/include/notify.php @@ -13,17 +13,17 @@ return array(); // Call localize_item with the "brief" flag to get a one line status for activities. // This should set $item['localized'] to indicate we have a brief summary. - localize_item($item,true); + localize_item($item); // FIXME - we may need the parent - if(! $item['localized']) { + if(! $item['localize']) { $itemem_text = (($item['item_flags'] & ITEM_THREAD_TOP) ? sprintf( t("%s created a new post"), $item['author']['xchan_name']) : sprintf( t("%s commented on %s's post"), $item['author']['xchan_name'], $item['pname'])); } else - $itemem_text = $item['body']; + $itemem_text = $item['localize']; // convert this logic into a json array just like the system notifications diff --git a/include/text.php b/include/text.php index ee7595c01..4458cdaa4 100644 --- a/include/text.php +++ b/include/text.php @@ -364,7 +364,7 @@ function item_message_id() { $dups = false; $hash = random_string(); - $uri = $hash . '@' . $hostname; + $uri = $hash . '@' . get_app()->get_hostname(); $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($uri)); @@ -527,8 +527,8 @@ function contact_block() { $o = ''; $a = get_app(); -logger('contact block'); $shown = get_pconfig($a->profile['uid'],'system','display_friend_count'); + if($shown === false) $shown = 24; if($shown == 0) @@ -1730,11 +1730,11 @@ function find_xchan_in_array($xchan,$arr) { return array(); } -function get_json_rel_link($j,$rel) { +function get_rel_link($j,$rel) { if(count($j)) foreach($j as $l) - if($l->rel === $rel) - return $l->href; + if($l['rel'] === $rel) + return $l['href']; return ''; } |