]> git.mxchange.org Git - friendica.git/blobdiff - include/text.php
Frio: admin/users template
[friendica.git] / include / text.php
index 7807dc08b490440908b799761b6bae36fb2a2ccd..ee8a213ff659bfa3aa238e740ac51138346d25b3 100644 (file)
@@ -1184,6 +1184,7 @@ function put_item_in_cache(&$item, $update = false)
        $body = $item["body"];
 
        $rendered_hash = defaults($item, 'rendered-hash', '');
+       $rendered_html = defaults($item, 'rendered-html', '');
 
        if ($rendered_hash == ''
                || $item["rendered-html"] == ""
@@ -1196,6 +1197,16 @@ function put_item_in_cache(&$item, $update = false)
                $item["rendered-html"] = prepare_text($item["body"]);
                $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"]) {
+                       $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;
+               }
+
                if ($update && ($item["id"] > 0)) {
                        dba::update('item', ['rendered-html' => $item["rendered-html"], 'rendered-hash' => $item["rendered-hash"]],
                                        ['id' => $item["id"]], false);
@@ -1214,7 +1225,7 @@ function put_item_in_cache(&$item, $update = false)
  * @param boolean $is_preview
  * @return string item body html
  * @hook prepare_body_init item array before any work
- * @hook content_filter ('item'=>item array, 'filter_reasons'=>string array) before first bbcode to html
+ * @hook prepare_body_content_filter ('item'=>item array, 'filter_reasons'=>string array) before first bbcode to html
  * @hook prepare_body ('item'=>item array, 'html'=>body string, 'is_preview'=>boolean, 'filter_reasons'=>string array) after first bbcode to html
  * @hook prepare_body_final ('item'=>item array, 'html'=>body string) after attach icons and blockquote special case handling (spoiler, author)
  */
@@ -1270,17 +1281,19 @@ function prepare_body(array &$item, $attach = false, $is_preview = false)
 
        // Compile eventual content filter reasons
        $filter_reasons = [];
-       if (!empty($item['content-warning']) && !PConfig::get(local_user(), 'social', 'disable_cw')) {
-               $filter_reasons[] = L10n::t('Content warning: %s', $item['content-warning']);
-       }
+       if (!$is_preview && !($item['self'] && local_user() == $item['uid'])) {
+               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']);
+               }
 
-       $hook_data = [
-               'item' => $item,
-               'filter_reasons' => $filter_reasons
-       ];
-       Addon::callHooks('content_filter', $hook_data);
-       $filter_reasons = $hook_data['filter_reasons'];
-       unset($hook_data);
+               $hook_data = [
+                       'item' => $item,
+                       'filter_reasons' => $filter_reasons
+               ];
+               Addon::callHooks('prepare_body_content_filter', $hook_data);
+               $filter_reasons = $hook_data['filter_reasons'];
+               unset($hook_data);
+       }
 
        // Update the cached values if there is no "zrl=..." on the links.
        $update = (!local_user() && !remote_user() && ($item["uid"] == 0));
@@ -1431,15 +1444,15 @@ function apply_content_filter($html, array $reasons)
 {
        if (count($reasons)) {
                $rnd = random_string(8);
-               $content_filter_html = '<ul>';
+               $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>
-                       <div id="content-filter-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'content-filter-' . $rnd . '\'); >' .
+                       <p><span id="content-filter-wrap-' . $rnd . '" class="fakelink content-filter-button" onclick=openClose(\'content-filter-' . $rnd . '\'); >' .
                        L10n::t('Click to open/close') .
-                       '</div>
-                       <div id="content-filter-' . $rnd . '" style="display: none;">';
+                       '</span></p>
+                       <div id="content-filter-' . $rnd . '" class="content-filter-content" style="display: none;">';
 
                $html = $content_filter_html . $html . '</div>';
        }