Merge pull request #516 from MrPetovan/task/3878-move-include-bbcode-to-src
authorMichael Vogel <icarus@dabo.de>
Wed, 7 Feb 2018 14:03:29 +0000 (15:03 +0100)
committerGitHub <noreply@github.com>
Wed, 7 Feb 2018 14:03:29 +0000 (15:03 +0100)
Move include/bbcode to src/ part 1 : Everything but bbcode()

dwpost/dwpost.php
ljpost/ljpost.php
membersince/membersince.php
pumpio/pumpio.php
statusnet/statusnet.php
twitter/twitter.php

index fe4a53ef8d044108397a2b8da2d2e1b71aeeccd1..6a9cfe522b69c82909043b7e493d269d76a7ea8c 100644 (file)
@@ -180,7 +180,6 @@ function dwpost_send(&$a,&$b) {
        if($dw_username && $dw_password && $dw_blog) {
 
                require_once('include/bbcode.php');
-               require_once('include/datetime.php');
 
                $title = $b['title'];
                $post = bbcode($b['body']);
index 2a14172f1cedbbec88279ccb79e40990d88dce1e..de62c9761894469f1396ea433a21c919f6df77fa 100644 (file)
@@ -180,7 +180,6 @@ function ljpost_send(&$a,&$b) {
        if($lj_username && $lj_password && $lj_blog) {
 
                require_once('include/bbcode.php');
-               require_once('include/datetime.php');
 
                $title = xmlify($b['title']);
                $post = bbcode($b['body']);
index c1d38b83f762a4cdb3aa64f0bbf0d4bdda85a4ad..8c42c1359b1e036c70c0a740f41b8706c51854a9 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Name: MemberSince
  * Description: Display membership date in profile
- * Version: 1.0
+ * Version: 1.1
  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
  *
  */
@@ -11,8 +11,6 @@ use Friendica\Core\Addon;
 use Friendica\Core\L10n;
 use Friendica\Util\DateTimeFormat;
 
-require_once 'include/datetime.php';
-
 function membersince_install()
 {
        Addon::registerHook('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display');
@@ -25,9 +23,37 @@ function membersince_uninstall()
 
 function membersince_display(&$a, &$b)
 {
-       // Works in Vier
-       $b = preg_replace('/<\/dl>/', "</dl>\n\n\n<dl id=\"aprofile-membersince\" class=\"aprofile\">\n<dt>" . L10n::t('Member since:') . "</dt>\n<dd>" . DateTimeFormat::local($a->profile['register_date']) . "</dd>\n</dl>", $b, 1);
+       if (current_theme() == 'frio') {
+               // Works in Frio.
+               $doc = new DOMDocument();
+               $doc->loadHTML($b);
+
+               $elm = $doc->getElementById('aprofile-fullname');
+
+               $div = $doc->createElement('div');
+               $div->setAttribute('id','aprofile-membersince');
+               $div->setAttribute('class','col-lg-12 col-md-12 col-sm-12 col-xs-12 aprofile');
+
+               // The seperator line.
+               $hr = $doc->createElement('hr','');
+               $hr->setAttribute('class','profile-separator');
+
+               // The label div.
+               $label = $doc->createElement('div', L10n::t('Member since:'));
+               $label->setAttribute('class', 'col-lg-4 col-md-4 col-sm-4 col-xs-12 profile-label-name text-muted');
+
+               // The div for the register date of the profile owner.
+               $entry = $doc->createElement('div', DateTimeFormat::local($a->profile['register_date']));
+               $entry->setAttribute('class', 'col-lg-8 col-md-8 col-sm-8 col-xs-12 profile-entry');
+
+               $div->appendChild($hr);
+               $div->appendChild($label);
+               $div->appendChild($entry);
+               $elm->parentNode->insertBefore($div, $elm->nextSibling);
 
-       // Trying for Frio
-       //$b = preg_replace('/<\/div>/', "<div id=\"aprofile-membersince\" class=\"aprofile\"><hr class=\"profile-separator\"><div class=\"profile-label-name\">" . L10n::t('Member since:') . "</div><div class=\"profile-entry\">" . DateTimeFormat::local($a->profile['register_date']) . "</div></div>", $b, 1);
+               $b = $doc->saveHTML();
+       } else {
+               // Works in Vier.
+               $b = preg_replace('/<\/dl>/', "</dl>\n\n\n<dl id=\"aprofile-membersince\" class=\"aprofile\">\n<dt>" . L10n::t('Member since:') . "</dt>\n<dd>" . DateTimeFormat::local($a->profile['register_date']) . "</dd>\n</dl>", $b, 1);
+       }
 }
index 1e416f47ea549837f49da1956442ee7b650c009e..8e194f85a0406ec61931a2e2fa1f22b542bbbe54 100644 (file)
@@ -543,10 +543,7 @@ function pumpio_send(&$a,&$b) {
                        logger('pumpio_send '.$username.': success '.$post_id);
                        if($post_id && $iscomment) {
                                logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$b['id']);
-                               q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
-                                       dbesc($post_id),
-                                       intval($b['id'])
-                               );
+                               Item::update(['extid' => $post_id], ['id' => $b['id']]);
                        }
                } else {
                        logger('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user,true));
@@ -870,13 +867,7 @@ function pumpio_dounlike(&$a, $uid, $self, $post, $own_id) {
                        $contactid = $orig_post['contact-id'];
        }
 
-       $r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `verb` = '%s' AND `uid` = %d AND `contact-id` = %d AND `thr-parent` = '%s'",
-               dbesc(DateTimeFormat::utcNow()),
-               dbesc(ACTIVITY_LIKE),
-               intval($uid),
-               intval($contactid),
-               dbesc($orig_post['uri'])
-       );
+       Item::delete(['verb' => ACTIVITY_LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]);
 
        if(count($r))
                logger("pumpio_dounlike: unliked existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
@@ -1060,7 +1051,7 @@ function pumpio_dodelete(&$a, $uid, $self, $post, $own_id) {
                );
 
        if (count($r))
-               return Item::delete($r[0]["id"]);
+               return Item::deleteById($r[0]["id"]);
 
        $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
                                dbesc($post->object->id),
@@ -1068,7 +1059,7 @@ function pumpio_dodelete(&$a, $uid, $self, $post, $own_id) {
                );
 
        if (count($r))
-               return Item::delete($r[0]["id"]);
+               return Item::deleteById($r[0]["id"]);
 }
 
 function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcompletion = true) {
@@ -1256,13 +1247,9 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
        $postarray["id"] = $top_item;
 
        if (($top_item == 0) && ($post->verb == "update")) {
-               $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s' , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
-                       dbesc($postarray["title"]),
-                       dbesc($postarray["body"]),
-                       dbesc($postarray["edited"]),
-                       dbesc($postarray["uri"]),
-                       intval($uid)
-                       );
+               $fields = ['title' => $postarray["title"], 'body' => $postarray["body"], 'changed' => $postarray["edited"]];
+               $condition = ['uri' => $postarray["uri"], 'uid' => $uid];
+               Item::update($fields, $condition);
        }
 
        if ($post->object->objectType == "comment") {
@@ -1491,10 +1478,7 @@ function pumpio_queue_hook(&$a,&$b) {
                                logger('pumpio_queue: send '.$username.': success '.$post_id);
                                if($post_id && $iscomment) {
                                        logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$z['item']);
-                                       q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
-                                               dbesc($post_id),
-                                               intval($z['item'])
-                                       );
+                                       Item::update(['extid' => $post_id], ['id' => $z['item']]);
                                }
                                Queue::removeItem($x['id']);
                        } else
index 22e8f5f9c28256032b5283fc464010951b85623b..f1c080f495c53aa6838148c37d20c0d3af743979 100644 (file)
@@ -600,11 +600,7 @@ function statusnet_post_hook(App $a, &$b)
                                logger('Send to GNU Social failed: "' . $result->error . '"');
                        } elseif ($iscomment) {
                                logger('statusnet_post: Update extid ' . $result->id . " for post id " . $b['id']);
-                               q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d",
-                                       dbesc($hostname . "::" . $result->id),
-                                       dbesc($result->text),
-                                       intval($b['id'])
-                               );
+                               Item::update(['extid' => $hostname . "::" . $result->id, 'body' => $result->text], ['id' => $b['id']]);
                        }
                }
                if ($tempfile != "") {
index bf85f081702aa35fd98580cdfd1fcc10596742f5..47b4fa0751064123690570b4419ee6945df68811 100644 (file)
@@ -571,11 +571,7 @@ function twitter_post_hook(App $a, &$b)
                                $image = "";
                        } elseif ($iscomment) {
                                logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
-                               q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d",
-                                       dbesc("twitter::" . $result->id_str),
-                                       dbesc($result->text),
-                                       intval($b['id'])
-                               );
+                               Item::update(['extid' => "twitter::" . $result->id_str, 'body' => $result->text], ['id' => $b['id']]);
                        }
                }
 
@@ -621,10 +617,7 @@ function twitter_post_hook(App $a, &$b)
                                notice(L10n::t('Twitter post failed. Queued for retry.') . EOL);
                        } elseif ($iscomment) {
                                logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
-                               q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
-                                       dbesc("twitter::" . $result->id_str),
-                                       intval($b['id'])
-                               );
+                               Item::update(['extid' => "twitter::" . $result->id_str], ['id' => $b['id']]);
                        }
                }
        }