]> git.mxchange.org Git - friendica.git/blobdiff - include/text.php
Merge pull request #5258 from Quix0r/rewrites/curly-braces-is-result-usage-002-split1
[friendica.git] / include / text.php
index 53eae1ff33924f7118df4c5f8beb3714743628c0..f1bc5123269be18a4bfc628f368fda19975e893b 100644 (file)
@@ -462,33 +462,6 @@ function perms2str($p) {
        return $ret;
 }
 
-
-/**
- * generate a guaranteed unique (for this domain) item ID for ATOM
- * safe from birthday paradox
- *
- * @param string $hostname
- * @param int $uid
- * @return string
- */
-function item_new_uri($hostname, $uid, $guid = "") {
-
-       do {
-               if ($guid == "") {
-                       $hash = get_guid(32);
-               } else {
-                       $hash = $guid;
-                       $guid = "";
-               }
-
-               $uri = "urn:X-dfrn:" . $hostname . ':' . $uid . ':' . $hash;
-
-               $dups = dba::exists('item', ['uri' => $uri]);
-       } while ($dups == true);
-
-       return $uri;
-}
-
 /**
  * @deprecated
  * wrapper to load a view template, checking for alternate
@@ -961,13 +934,9 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
        $redir = false;
 
        if ($redirect) {
-               $redirect_url = 'redir/' . $contact['id'];
-               if (local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === NETWORK_DFRN)) {
-                       $redir = true;
-                       $url = $redirect_url;
+               $url = Contact::magicLink($contact['url']);
+               if (strpos($url, 'redir/') === 0) {
                        $sparkle = ' sparkle';
-               } else {
-                       $url = Profile::zrl($url);
                }
        }
 
@@ -1015,7 +984,7 @@ function search($s, $id = 'search-box', $url = 'search', $save = false, $aside =
                        '$action_url' => $url,
                        '$search_label' => L10n::t('Search'),
                        '$save_label' => $save_label,
-                       '$savedsearch' => Feature::isEnabled(local_user(),'savedsearch'),
+                       '$savedsearch' => local_user() && Feature::isEnabled(local_user(),'savedsearch'),
                        '$search_hint' => L10n::t('@name, !forum, #tags, content'),
                        '$mode' => $mode
                ];
@@ -1208,8 +1177,8 @@ function put_item_in_cache(&$item, $update = false)
                }
 
                if ($update && ($item["id"] > 0)) {
-                       dba::update('item', ['rendered-html' => $item["rendered-html"], 'rendered-hash' => $item["rendered-hash"]],
-                                       ['id' => $item["id"]], false);
+                       Item::update(['rendered-html' => $item["rendered-html"], 'rendered-hash' => $item["rendered-hash"]],
+                                       ['id' => $item["id"]]);
                }
        }
 
@@ -1284,8 +1253,6 @@ function prepare_body(array &$item, $attach = false, $is_preview = false)
        $s = $hook_data['html'];
        unset($hook_data);
 
-       $s = apply_content_filter($s, $filter_reasons);
-
        if (! $attach) {
                // Replace the blockquotes with quotes that are used in mails.
                $mailquote = '<blockquote type="cite" class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">';
@@ -1300,11 +1267,7 @@ function prepare_body(array &$item, $attach = false, $is_preview = false)
        foreach ($matches as $mtch) {
                $mime = $mtch[3];
 
-               if ((local_user() == $item['uid']) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN)) {
-                       $the_url = 'redir/' . $item['contact-id'] . '?f=1&url=' . $mtch[1];
-               } else {
-                       $the_url = $mtch[1];
-               }
+               $the_url = Contact::magicLinkById($item['author-id'], $mtch[1]);
 
                if (strpos($mime, 'video') !== false) {
                        if (!$vhead) {
@@ -1393,6 +1356,8 @@ function prepare_body(array &$item, $attach = false, $is_preview = false)
                $s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s);
        }
 
+       $s = apply_content_filter($s, $filter_reasons);
+
        $hook_data = ['item' => $item, 'html' => $s];
        Addon::callHooks('prepare_body_final', $hook_data);
 
@@ -2005,6 +1970,7 @@ function is_a_date_arg($s) {
  */
 function deindent($text, $chr = "[\t ]", $count = NULL) {
        $lines = explode("\n", $text);
+
        if (is_null($count)) {
                $m = [];
                $k = 0;