]> git.mxchange.org Git - friendica.git/commitdiff
New function for building the "share" header
authorMichael Vogel <icarus@dabo.de>
Sun, 5 Apr 2015 18:43:06 +0000 (20:43 +0200)
committerMichael Vogel <icarus@dabo.de>
Sun, 5 Apr 2015 18:43:06 +0000 (20:43 +0200)
include/api.php
include/diaspora.php
include/items.php
mod/share.php

index 600cc0c3d60d54dad8169652966106c0c86ae1ad..d2592afc676716cbf22f7efd3831f7781bde3e11 100644 (file)
@@ -7,6 +7,7 @@
        require_once("include/conversation.php");
        require_once("include/oauth.php");
        require_once("include/html2plain.php");
+       require_once("mod/share.php");
        /*
         * Twitter-Like API
         *
                                        $pos = strpos($r[0]['body'], "[share");
                                        $post = substr($r[0]['body'], $pos);
                                } else {
-                                       $post = "[share author='".str_replace("'", "&#039;", $r[0]['author-name']).
-                                                       "' profile='".$r[0]['author-link'].
-                                                       "' avatar='".$r[0]['author-avatar'].
-                                                       "' link='".$r[0]['plink']."']";
+                                       $post = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
+
                                        $post .= $r[0]['body'];
                                        $post .= "[/share]";
                                }
index dd877112ba906cc71a371deba3e023fcd1dd4eaf..2dfa67e108dedfababdacde6ce90d46d56d0af67 100755 (executable)
@@ -7,6 +7,7 @@ require_once('include/contact_selectors.php');
 require_once('include/queue_fn.php');
 require_once('include/lock.php');
 require_once('include/threads.php');
+require_once('mod/share.php');
 
 function diaspora_dispatch_public($msg) {
 
@@ -1165,12 +1166,8 @@ function diaspora_reshare($importer,$xml,$msg) {
        $datarray['owner-link'] = $contact['url'];
        $datarray['owner-avatar'] = ((x($contact,'thumb')) ? $contact['thumb'] : $contact['photo']);
        if (!intval(get_config('system','wall-to-wall_share'))) {
-               $prefix = "[share author='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$person['name']).
-                               "' profile='".$person['url'].
-                               "' avatar='".((x($person,'thumb')) ? $person['thumb'] : $person['photo']).
-                               "' guid='".$orig_guid.
-                               "' posted='".$orig_created.
-                               "' link='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$orig_url)."']";
+               $prefix = share_header($person['name'], $person['url'], ((x($person,'thumb')) ? $person['thumb'] : $person['photo']), $orig_guid, $orig_created, $orig_url);
+
                $datarray['author-name'] = $contact['name'];
                $datarray['author-link'] = $contact['url'];
                $datarray['author-avatar'] = $contact['thumb'];
@@ -1199,7 +1196,7 @@ function diaspora_reshare($importer,$xml,$msg) {
                $datarray2['contact-id'] = get_contact($person['url'], 0);
                $datarray2['guid'] = $orig_guid;
                $datarray2['uri'] = $datarray2['parent-uri'] = $orig_author.':'.$orig_guid;
-               $datarray2['changed'] = $datarray2['created'] = $datarray2['edited'] = datetime_convert('UTC','UTC',$orig_created);
+               $datarray2['changed'] = $datarray2['created'] = $datarray2['edited'] = $datarray2['commented'] = $datarray2['received'] = datetime_convert('UTC','UTC',$orig_created);
                $datarray2['plink'] = 'https://'.substr($orig_author,strpos($orig_author,'@')+1).'/posts/'.$orig_guid;
 
                $datarray2['author-name'] = $person['name'];
index 0b8bf8fea9de84067b7490326340f2267e57b22e..7e30bc2b70c660632acc5386110516739049191b 100644 (file)
@@ -12,6 +12,7 @@ require_once('include/email.php');
 require_once('include/ostatus_conversation.php');
 require_once('include/threads.php');
 require_once('include/socgraph.php');
+require_once('mod/share.php');
 
 function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
 
@@ -838,10 +839,8 @@ function get_atom_elements($feed, $item, $contact = array()) {
                        logger('get_atom_elements: fixing sender of repeated message.');
 
                        if (!intval(get_config('system','wall-to-wall_share'))) {
-                               $prefix = "[share author='".str_replace("'", "&#039;",$name).
-                                               "' profile='".$uri.
-                                               "' avatar='".$avatar.
-                                               "' link='".$orig_uri."']";
+                               logger("Repeated data: ".print_r($child["http://activitystrea.ms/spec/1.0/"]["object"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10], true), LOGGER_DEBUG);
+                               $prefix = share_header($name, $uri, $avatar, "", "", $orig_uri);
 
                                $res["body"] = $prefix.html2bbcode($message)."[/share]";
                        } else {
@@ -1183,9 +1182,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
        $arr['owner-avatar']  = ((x($arr,'owner-avatar'))  ? notags(trim($arr['owner-avatar']))  : '');
        $arr['created']       = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert());
        $arr['edited']        = ((x($arr,'edited')  !== false) ? datetime_convert('UTC','UTC',$arr['edited'])  : datetime_convert());
-       $arr['commented']     = datetime_convert();
-       $arr['received']      = datetime_convert();
-       $arr['changed']       = datetime_convert();
+       $arr['commented']     = ((x($arr,'commented')  !== false) ? datetime_convert('UTC','UTC',$arr['commented'])  : datetime_convert());
+       $arr['received']      = ((x($arr,'received')  !== false) ? datetime_convert('UTC','UTC',$arr['received'])  : datetime_convert());
+       $arr['changed']       = ((x($arr,'changed')  !== false) ? datetime_convert('UTC','UTC',$arr['changed'])  : datetime_convert());
        $arr['title']         = ((x($arr,'title'))         ? notags(trim($arr['title']))         : '');
        $arr['location']      = ((x($arr,'location'))      ? notags(trim($arr['location']))      : '');
        $arr['coord']         = ((x($arr,'coord'))         ? notags(trim($arr['coord']))         : '');
index e9127b647d4a9d321d3d2f3c2e019f37d33e5415..085da4e30d8a8b6f15e343a480d6743f733def15 100644 (file)
@@ -1,7 +1,4 @@
 <?php
-
-require_once('include/bbcode.php');
-
 function share_init(&$a) {
 
        $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
@@ -23,11 +20,8 @@ function share_init(&$a) {
                        $pos = strpos($r[0]['body'], "[share");
                        $o = substr($r[0]['body'], $pos);
                } else {
-                       $o = "[share author='".str_replace("'", "&#039;",$r[0]['author-name']).
-                               "' profile='".$r[0]['author-link'].
-                               "' avatar='".$r[0]['author-avatar'].
-                               "' link='".$r[0]['plink'].
-                               "' posted='".$r[0]['created']."']\n";
+                       $o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
+
                        if($r[0]['title'])
                                $o .= '[b]'.$r[0]['title'].'[/b]'."\n";
                        $o .= $r[0]['body'];
@@ -46,3 +40,19 @@ function share_init(&$a) {
        echo $o;
        killme();
 }
+
+function share_header($author, $profile, $avatar, $guid, $posted, $link) {
+       $header = "[share author='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$author).
+               "' profile='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$profile).
+               "' avatar='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$avatar);
+
+       if ($guid)
+               $header .= "' guid='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$guid);
+
+       if ($posted)
+               $header .= "' posted='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$posted);
+
+       $header .= "' link='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$link)."']";
+
+       return $header;
+}