aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-01-25 04:30:03 -0800
committerfriendica <info@friendica.com>2013-01-25 04:30:03 -0800
commit132a5f0f9691d154a048874342a6ad042be2a9e3 (patch)
treec8088e3d4b3cad759d1a144a7e1c2270dd48229c /include
parent50915c46927e761a46578f8edc1499dcce19e5fc (diff)
downloadvolse-hubzilla-132a5f0f9691d154a048874342a6ad042be2a9e3.tar.gz
volse-hubzilla-132a5f0f9691d154a048874342a6ad042be2a9e3.tar.bz2
volse-hubzilla-132a5f0f9691d154a048874342a6ad042be2a9e3.zip
add new magic links to activity translations
Diffstat (limited to 'include')
-rw-r--r--include/conversation.php46
-rw-r--r--include/text.php6
2 files changed, 32 insertions, 20 deletions
diff --git a/include/conversation.php b/include/conversation.php
index 29c5938b0..65110fc72 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -1,8 +1,11 @@
<?php
+require_once('include/items.php');
+
// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
// is identical to the code in mod/message.php for 'item_extract_images' and
// 'item_redir_and_replace_images'
+
if(! function_exists('item_extract_images')) {
function item_extract_images($body) {
@@ -51,10 +54,13 @@ function item_redir_and_replace_images($body, $images, $cid) {
$origbody = $body;
$newbody = '';
+ $observer = get_app()->get_observer();
+ $obhash = (($observer) ? $observer['xchan_hash'] : '');
+ $obaddr = (($observer) ? $observer['xchan_addr'] : '');
+
for($i = 0; $i < count($images); $i++) {
$search = '/\[url\=(.*?)\]\[!#saved_image' . $i . '#!\]\[\/url\]' . '/is';
- $replace = '[url=' . z_path() . '/redir/' . $cid
- . '?f=1&url=' . '$1' . '][!#saved_image' . $i . '#!][/url]' ;
+ $replace = '[url=' . magiclink_url($obhash,$obaddr,'$1') . '][!#saved_image' . $i . '#!][/url]' ;
$img_end = strpos($origbody, '[!#saved_image' . $i . '#!][/url]') + strlen('[!#saved_image' . $i . '#!][/url]');
$process_part = substr($origbody, 0, $img_end);
@@ -108,8 +114,8 @@ function localize_item(&$item){
if($author_link && $author_name && $item_url) {
- $author = '[url=' . zid($item['author']['xchan_url']) . ']' . $item['author']['xchan_name'] . '[/url]';
- $objauthor = '[url=' . zid($author_link) . ']' . $author_name . '[/url]';
+ $author = '[url=' . chanlink_url($item['author']['xchan_url']) . ']' . $item['author']['xchan_name'] . '[/url]';
+ $objauthor = '[url=' . chanlink_url($author_link) . ']' . $author_name . '[/url]';
switch($obj->type) {
case ACTIVITY_OBJ_PHOTO:
@@ -160,11 +166,11 @@ function localize_item(&$item){
$Bname = $obj['title'];
- $A = '[url=' . zid($Alink) . ']' . $Aname . '[/url]';
- $B = '[url=' . zid($Blink) . ']' . $Bname . '[/url]';
- if ($Bphoto!="") $Bphoto = '[url=' . zid($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
+ $A = '[url=' . chanlink_url($Alink) . ']' . $Aname . '[/url]';
+ $B = '[url=' . chanlink_url($Blink) . ']' . $Bname . '[/url]';
+ if ($Bphoto!="") $Bphoto = '[url=' . chanlink_url($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
- $item['body'] = $item['localize'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B);
+ $item['body'] = $item['localize'] = sprintf( t('%1$s is now connected with %2$s'), $A, $B);
$item['body'] .= "\n\n\n" . $Bphoto;
}
@@ -188,9 +194,9 @@ function localize_item(&$item){
}
$Bname = $obj['title'];
- $A = '[url=' . zid($Alink) . ']' . $Aname . '[/url]';
- $B = '[url=' . zid($Blink) . ']' . $Bname . '[/url]';
- if ($Bphoto!="") $Bphoto = '[url=' . zid($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
+ $A = '[url=' . chanlink_url($Alink) . ']' . $Aname . '[/url]';
+ $B = '[url=' . chanlink_url($Blink) . ']' . $Bname . '[/url]';
+ if ($Bphoto!="") $Bphoto = '[url=' . chanlink_url($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
// we can't have a translation string with three positions but no distinguishable text
// So here is the translate string.
@@ -215,7 +221,7 @@ function localize_item(&$item){
$Aname = $item['author']['xchan_name'];
$Alink = $item['author']['xchan_url'];
- $A = '[url=' . zid($Alink) . ']' . $Aname . '[/url]';
+ $A = '[url=' . chanlink_url($Alink) . ']' . $Aname . '[/url]';
$txt = t('%1$s is currently %2$s');
@@ -304,19 +310,19 @@ function localize_item(&$item){
// add zid's to public images
if(preg_match_all('/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
foreach($matches as $mtch) {
- $item['body'] = str_replace($mtch[0],'[url=' . zid($mtch[1] . '/photos/' . $mtch[2] . '/image/' . $mtch[3] ,true) . '][img' . $mtch[4] . ']h' . $mtch[5] . '[/img][/url]',$item['body']);
+ $item['body'] = str_replace($mtch[0],'[url=' . chanlink_url($mtch[1] . '/photos/' . $mtch[2] . '/image/' . $mtch[3] ,true) . '][img' . $mtch[4] . ']h' . $mtch[5] . '[/img][/url]',$item['body']);
}
}
// add sparkle links to appropriate permalinks
- $x = stristr($item['plink'],'/display/');
- if($x) {
- $sparkle = false;
- $y = best_link_url($item,$sparkle,true);
- if($sparkle)
- $item['plink'] = $y . '?f=&url=' . $item['plink'];
- }
+// $x = stristr($item['plink'],'/display/');
+// if($x) {
+// $sparkle = false;
+// $y = best_link_url($item,$sparkle,true);
+ // if($sparkle)
+// $item['plink'] = $y . '?f=&url=' . $item['plink'];
+// }
}
/**
diff --git a/include/text.php b/include/text.php
index 167fbb1df..90cd86a5f 100644
--- a/include/text.php
+++ b/include/text.php
@@ -620,6 +620,12 @@ function chanlink_cid($d) {
return z_root() . '/chanview?f=&cid=' . intval($d);
}
+function magiclink_url($observer,$myaddr,$url) {
+ return (($observer)
+ ? z_root() . '/magic?f=&dest=' . $url . '&addr=' . $myaddr
+ : $url
+ );
+}
if(! function_exists('micropro')) {