]> git.mxchange.org Git - friendica.git/blobdiff - include/text.php
Merge pull request #5004 from annando/missing-posts
[friendica.git] / include / text.php
index 957145ca1847308a47dfdf877fb5d24958a24e24..4c9a8864d595d6dca9d10c9f221d5a9e4627542b 100644 (file)
@@ -513,7 +513,7 @@ function load_view_file($s) {
                return $content;
        }
 
-       $theme = current_theme();
+       $theme = $a->getCurrentTheme();
 
        if (file_exists("$d/theme/$theme/$b")) {
                $stamp1 = microtime(true);
@@ -637,7 +637,7 @@ function logger($msg, $level = 0) {
 
        // turn off logger in install mode
        if (
-               $a->module == 'install'
+               $a->mode == App::MODE_INSTALL
                || !dba::$connected
        ) {
                return;
@@ -709,7 +709,7 @@ function dlogger($msg, $level = 0) {
 
        // turn off logger in install mode
        if (
-               $a->module == 'install'
+               $a->mode == App::MODE_INSTALL
                || !dba::$connected
        ) {
                return;
@@ -1198,7 +1198,12 @@ function put_item_in_cache(&$item, $update = false)
                $item["rendered-hash"] = hash("md5", $item["body"]);
 
                // Force an update if the generated values differ from the existing ones
-               if (($rendered_hash != $item["rendered-hash"]) || ($rendered_html != $item["rendered-html"])) {
+               if ($rendered_hash != $item["rendered-hash"]) {
+                       $update = true;
+               }
+
+               // Only compare the HTML when we forcefully ignore the cache
+               if (Config::get("system", "ignore_cache") && ($rendered_html != $item["rendered-html"])) {
                        $update = true;
                }
 
@@ -1229,12 +1234,6 @@ function prepare_body(array &$item, $attach = false, $is_preview = false)
        $a = get_app();
        Addon::callHooks('prepare_body_init', $item);
 
-       $searchpath = System::baseUrl() . "/search?tag=";
-
-       $tags = [];
-       $hashtags = [];
-       $mentions = [];
-
        // In order to provide theme developers more possibilities, event items
        // are treated differently.
        if ($item['object-type'] === ACTIVITY_OBJ_EVENT && isset($item['event-id'])) {
@@ -1242,41 +1241,15 @@ function prepare_body(array &$item, $attach = false, $is_preview = false)
                return $ev;
        }
 
-       $taglist = dba::p("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = ? AND `oid` = ? AND `type` IN (?, ?) ORDER BY `tid`",
-                       intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
-
-       while ($tag = dba::fetch($taglist)) {
-               if ($tag["url"] == "") {
-                       $tag["url"] = $searchpath . strtolower($tag["term"]);
-               }
-
-               $orig_tag = $tag["url"];
-
-               $tag["url"] = best_link_url($item, $sp, $tag["url"]);
+       $tags = \Friendica\Model\Term::populateTagsFromItem($item);
 
-               if ($tag["type"] == TERM_HASHTAG) {
-                       if ($orig_tag != $tag["url"]) {
-                               $item['body'] = str_replace($orig_tag, $tag["url"], $item['body']);
-                       }
-
-                       $hashtags[] = "#<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
-                       $prefix = "#";
-               } elseif ($tag["type"] == TERM_MENTION) {
-                       $mentions[] = "@<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
-                       $prefix = "@";
-               }
-
-               $tags[] = $prefix . "<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
-       }
-       dba::close($taglist);
-
-       $item['tags'] = $tags;
-       $item['hashtags'] = $hashtags;
-       $item['mentions'] = $mentions;
+       $item['tags'] = $tags['tags'];
+       $item['hashtags'] = $tags['hashtags'];
+       $item['mentions'] = $tags['mentions'];
 
        // Compile eventual content filter reasons
        $filter_reasons = [];
-       if (!$is_preview && !($item['self'] && local_user() == $item['uid'])) {
+       if (!$is_preview && public_contact() != $item['author-id']) {
                if (!empty($item['content-warning']) && (!local_user() || !PConfig::get(local_user(), 'system', 'disable_cw', false))) {
                        $filter_reasons[] = L10n::t('Content warning: %s', $item['content-warning']);
                }
@@ -1438,18 +1411,13 @@ function prepare_body(array &$item, $attach = false, $is_preview = false)
 function apply_content_filter($html, array $reasons)
 {
        if (count($reasons)) {
-               $rnd = random_string(8);
-               $content_filter_html = '<ul class="content-filter-reasons">';
-               foreach ($reasons as $reason) {
-                       $content_filter_html .= '<li>' . htmlspecialchars($reason) . '</li>' . PHP_EOL;
-               }
-               $content_filter_html .= '</ul>
-                       <p><span id="content-filter-wrap-' . $rnd . '" class="fakelink content-filter-button" onclick=openClose(\'content-filter-' . $rnd . '\'); >' .
-                       L10n::t('Click to open/close') .
-                       '</span></p>
-                       <div id="content-filter-' . $rnd . '" class="content-filter-content" style="display: none;">';
-
-               $html = $content_filter_html . $html . '</div>';
+               $tpl = get_markup_template('wall/content_filter.tpl');
+               $html = replace_macros($tpl, [
+                       '$reasons'   => $reasons,
+                       '$rnd'       => random_string(8),
+                       '$openclose' => L10n::t('Click to open/close'),
+                       '$html'      => $html
+               ]);
        }
 
        return $html;