]> git.mxchange.org Git - friendica.git/commitdiff
Move content filter HTML in a template
authorHypolite Petovan <mrpetovan@gmail.com>
Sun, 22 Apr 2018 22:02:00 +0000 (18:02 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Sun, 22 Apr 2018 22:02:00 +0000 (18:02 -0400)
include/text.php
view/templates/wall/content_filter.tpl [new file with mode: 0644]

index 6c09167494231dd20635681ef307ef6bb55c822c..5e189d58f14857f480d4b291e8d513a16dacc0b3 100644 (file)
@@ -1411,27 +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);
-
-               if (count($reasons) > 1) {
-                       $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><button type="button" id="content-filter-wrap-' . $rnd . '" class="btn btn-default btn-small content-filter-button" onclick="openClose(\'content-filter-' . $rnd . '\');"><i class="glyphicon glyphicon-eye-open"></i> ' .
-                               L10n::t('Click to open/close') .
-                               '</button></p>';
-               } elseif (count($reasons) == 1) {
-                       $reason = array_pop($reasons);
-                       $content_filter_html .= '<p>' . htmlspecialchars($reason) . ' <button type="button" id="content-filter-wrap-' . $rnd . '" class="btn btn-default btn-xs content-filter-button" onclick="openClose(\'content-filter-' . $rnd . '\');"><i class="glyphicon glyphicon-eye-open"></i> ' .
-                               L10n::t('Click to open/close') .
-                               '</button></p>';
-               }
-
-               $content_filter_html .= '<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;
diff --git a/view/templates/wall/content_filter.tpl b/view/templates/wall/content_filter.tpl
new file mode 100644 (file)
index 0000000..2dafdca
--- /dev/null
@@ -0,0 +1,22 @@
+{{if count($reasons) > 1}}
+<ul class="content-filter-reasons">
+       {{foreach $reasons as $reason}}
+       <li>{{$reason|escape:html}}</li>
+       {{/foreach}}
+</ul>
+<p>
+       <button type="button" id="content-filter-wrap-{{$rnd}}" class="btn btn-default btn-small content-filter-button" onclick="openClose('content-filter-{{$rnd}}');">
+               <i class="glyphicon glyphicon-eye-open"></i> {{$openclose}}
+       </button>
+</p>
+{{else}}
+<p>
+       {{$reasons.0|escape:html}}
+       <button type="button" id="content-filter-wrap-{{$rnd}}" class="btn btn-default btn-xs content-filter-button" onclick="openClose('content-filter-{{$rnd}}');">
+               <i class="glyphicon glyphicon-eye-open"></i> {{$openclose}}
+       </button>
+</p>
+{{/if}}
+<div id="content-filter-{{$rnd}}" class="content-filter-content" style="display: none;">
+       {{$html}}
+</div>
\ No newline at end of file