From: Hypolite Petovan Date: Sun, 25 Mar 2018 04:38:23 +0000 (-0400) Subject: Move suppress_tags config to template X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=daffc27061e04bfa8b3de0197fbee4727c6998cc;p=friendica.git Move suppress_tags config to template - Add new item.suppress_tags template variable - Fix template formatting --- diff --git a/include/text.php b/include/text.php index 4efa308911..67ce7e65e8 100644 --- a/include/text.php +++ b/include/text.php @@ -1239,33 +1239,33 @@ function prepare_body(&$item, $attach = false, $preview = false) { return $ev; } - if (!Config::get('system','suppress_tags')) { - $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)); + $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"]); - } + while ($tag = dba::fetch($taglist)) { + if ($tag["url"] == "") { + $tag["url"] = $searchpath . strtolower($tag["term"]); + } - $orig_tag = $tag["url"]; + $orig_tag = $tag["url"]; - $tag["url"] = best_link_url($item, $sp, $tag["url"]); + $tag["url"] = best_link_url($item, $sp, $tag["url"]); - if ($tag["type"] == TERM_HASHTAG) { - if ($orig_tag != $tag["url"]) { - $item['body'] = str_replace($orig_tag, $tag["url"], $item['body']); - } - $hashtags[] = "#".$tag["term"].""; - $prefix = "#"; - } elseif ($tag["type"] == TERM_MENTION) { - $mentions[] = "@".$tag["term"].""; - $prefix = "@"; + if ($tag["type"] == TERM_HASHTAG) { + if ($orig_tag != $tag["url"]) { + $item['body'] = str_replace($orig_tag, $tag["url"], $item['body']); } - $tags[] = $prefix."".$tag["term"].""; + + $hashtags[] = "#" . $tag["term"] . ""; + $prefix = "#"; + } elseif ($tag["type"] == TERM_MENTION) { + $mentions[] = "@" . $tag["term"] . ""; + $prefix = "@"; } - dba::close($taglist); + + $tags[] = $prefix . "" . $tag["term"] . ""; } + dba::close($taglist); $item['tags'] = $tags; $item['hashtags'] = $hashtags; diff --git a/src/Object/Post.php b/src/Object/Post.php index 16dabbb71e..ecc6956be7 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -8,6 +8,7 @@ use Friendica\BaseObject; use Friendica\Content\ContactSelector; use Friendica\Content\Feature; use Friendica\Core\Addon; +use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Database\DBM; @@ -337,6 +338,7 @@ class Post extends BaseObject $tmp_item = [ 'template' => $this->getTemplate(), 'type' => implode("", array_slice(explode("/", $item['verb']), -1)), + 'suppress_tags' => Config::get('system', 'suppress_tags'), 'tags' => $item['tags'], 'hashtags' => $item['hashtags'], 'mentions' => $item['mentions'], diff --git a/view/templates/wall_thread.tpl b/view/templates/wall_thread.tpl index 37f034586a..a82efa7d1c 100644 --- a/view/templates/wall_thread.tpl +++ b/view/templates/wall_thread.tpl @@ -51,11 +51,13 @@
{{$item.title}}
{{$item.body}} -
- {{foreach $item.tags as $tag}} - {{$tag}} - {{/foreach}} -
+
+ {{if !$item.suppress_tags}} + {{foreach $item.tags as $tag}} + {{$tag}} + {{/foreach}} + {{/if}} +
{{if $item.has_cats}}
{{$item.txt_cats}} {{foreach $item.categories as $cat}}{{$cat.name}}{{if $cat.removeurl}} [{{$remove}}]{{/if}} {{if $cat.last}}{{else}}, {{/if}}{{/foreach}}
diff --git a/view/theme/frio/templates/search_item.tpl b/view/theme/frio/templates/search_item.tpl index c8c702b6a8..3ae36c7822 100644 --- a/view/theme/frio/templates/search_item.tpl +++ b/view/theme/frio/templates/search_item.tpl @@ -141,23 +141,25 @@
- {{foreach $item.hashtags as $tag}} - {{$tag}} - {{/foreach}} + {{if !$item.suppress_tags}} + {{foreach $item.hashtags as $tag}} + {{$tag}} + {{/foreach}} - {{foreach $item.mentions as $tag}} - {{$tag}} - {{/foreach}} + {{foreach $item.mentions as $tag}} + {{$tag}} + {{/foreach}} + {{/if}} - {{foreach $item.folders as $cat}} - {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} - {{/foreach}} + {{foreach $item.folders as $cat}} + {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} + {{/foreach}} - {{foreach $item.categories as $cat}} - {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} - {{/foreach}} + {{foreach $item.categories as $cat}} + {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} + {{/foreach}}
- {{if $item.edited}}
{{$item.edited['label']}} ({{$item.edited['relative']}})
{{/if}} + {{if $item.edited}}
{{$item.edited['label']}} ({{$item.edited['relative']}})
{{/if}}
diff --git a/view/theme/frio/templates/wall_thread.tpl b/view/theme/frio/templates/wall_thread.tpl index 94ff531294..927dc9bfaa 100644 --- a/view/theme/frio/templates/wall_thread.tpl +++ b/view/theme/frio/templates/wall_thread.tpl @@ -263,23 +263,25 @@ as the value of $top_child_total (this is done at the end of this file)
- {{foreach $item.hashtags as $tag}} - {{$tag}} - {{/foreach}} - - {{foreach $item.mentions as $tag}} - {{$tag}} - {{/foreach}} + {{if !$item.suppress_tags}} + {{foreach $item.hashtags as $tag}} + {{$tag}} + {{/foreach}} + + {{foreach $item.mentions as $tag}} + {{$tag}} + {{/foreach}} + {{/if}} - {{foreach $item.folders as $cat}} - {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} - {{/foreach}} + {{foreach $item.folders as $cat}} + {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} + {{/foreach}} - {{foreach $item.categories as $cat}} - {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} - {{/foreach}} + {{foreach $item.categories as $cat}} + {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} + {{/foreach}}
- {{if $item.edited}}
{{$item.edited['label']}} ({{$item.edited['relative']}})
{{/if}} + {{if $item.edited}}
{{$item.edited['label']}} ({{$item.edited['relative']}})
{{/if}} diff --git a/view/theme/frost-mobile/templates/wall_thread.tpl b/view/theme/frost-mobile/templates/wall_thread.tpl index 3a68b2739f..be8d00d850 100644 --- a/view/theme/frost-mobile/templates/wall_thread.tpl +++ b/view/theme/frost-mobile/templates/wall_thread.tpl @@ -52,11 +52,13 @@
{{$item.title}}
{{**}}
{{$item.body}} - {{**}} - {{foreach $item.tags as $tag}} - {{$tag}} - {{/foreach}} - {{**}} + {{**}} + {{if !$item.suppress_tags}} + {{foreach $item.tags as $tag}} + {{$tag}} + {{/foreach}} + {{/if}} + {{**}} {{if $item.has_cats}}
{{$item.txt_cats}} {{foreach $item.categories as $cat}}{{$cat.name}} [{{$remove}}] {{if $cat.last}}{{else}}, {{/if}}{{/foreach}}
diff --git a/view/theme/frost/templates/wall_thread.tpl b/view/theme/frost/templates/wall_thread.tpl index 498bab323f..c88e8008f0 100644 --- a/view/theme/frost/templates/wall_thread.tpl +++ b/view/theme/frost/templates/wall_thread.tpl @@ -47,11 +47,13 @@
{{$item.title}}
{{**}}
{{$item.body}} - {{**}} - {{foreach $item.tags as $tag}} - {{$tag}} - {{/foreach}} - {{**}} + {{**}} + {{if !$item.suppress_tags}} + {{foreach $item.tags as $tag}} + {{$tag}} + {{/foreach}} + {{/if}} + {{**}} {{if $item.has_cats}}
{{$item.txt_cats}} {{foreach $item.categories as $cat}}{{$cat.name}} [{{$remove}}] {{if $cat.last}}{{else}}, {{/if}}{{/foreach}}
diff --git a/view/theme/quattro/templates/search_item.tpl b/view/theme/quattro/templates/search_item.tpl index 512df75ef9..649ad341f6 100644 --- a/view/theme/quattro/templates/search_item.tpl +++ b/view/theme/quattro/templates/search_item.tpl @@ -30,9 +30,11 @@
+ {{if !$item.suppress_tags}} {{foreach $item.tags as $tag}} - {{$tag}} + {{$tag}} {{/foreach}} + {{/if}}
diff --git a/view/theme/quattro/templates/wall_thread.tpl b/view/theme/quattro/templates/wall_thread.tpl index c6085e9b16..89832403fc 100644 --- a/view/theme/quattro/templates/wall_thread.tpl +++ b/view/theme/quattro/templates/wall_thread.tpl @@ -67,18 +67,20 @@
+ {{if !$item.suppress_tags}} {{foreach $item.hashtags as $tag}} - {{$tag}} + {{$tag}} {{/foreach}} {{foreach $item.mentions as $tag}} - {{$tag}} + {{$tag}} {{/foreach}} - {{foreach $item.folders as $cat}} - {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} - {{/foreach}} - {{foreach $item.categories as $cat}} - {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} - {{/foreach}} + {{foreach $item.folders as $cat}} + {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} + {{/foreach}} + {{foreach $item.categories as $cat}} + {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} + {{/foreach}} + {{/if}}
diff --git a/view/theme/smoothly/templates/wall_thread.tpl b/view/theme/smoothly/templates/wall_thread.tpl index 134052b9f5..5aaa9c4eb1 100644 --- a/view/theme/smoothly/templates/wall_thread.tpl +++ b/view/theme/smoothly/templates/wall_thread.tpl @@ -60,9 +60,11 @@
{{$item.body}}
+ {{if !$item.suppress_tags}} {{foreach $item.tags as $tag}} - {{$tag}} + {{$tag}} {{/foreach}} + {{/if}}
{{if $item.has_cats}} diff --git a/view/theme/vier/templates/search_item.tpl b/view/theme/vier/templates/search_item.tpl index 27ab78af23..f056b0f7a9 100644 --- a/view/theme/vier/templates/search_item.tpl +++ b/view/theme/vier/templates/search_item.tpl @@ -37,10 +37,11 @@
+ {{if !$item.suppress_tags}} {{foreach $item.tags as $tag}} - {{$tag}} + {{$tag}} {{/foreach}} - + {{/if}}
diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl index c46c83ef5b..d1588bde30 100644 --- a/view/theme/vier/templates/wall_thread.tpl +++ b/view/theme/vier/templates/wall_thread.tpl @@ -74,18 +74,20 @@
+ {{if !$item.suppress_tags}} {{foreach $item.hashtags as $tag}} - {{$tag}} + {{$tag}} {{/foreach}} {{foreach $item.mentions as $tag}} - {{$tag}} + {{$tag}} + {{/foreach}} + {{/if}} + {{foreach $item.folders as $cat}} + {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} + {{/foreach}} + {{foreach $item.categories as $cat}} + {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} {{/foreach}} - {{foreach $item.folders as $cat}} - {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} - {{/foreach}} - {{foreach $item.categories as $cat}} - {{$cat.name}}{{if $cat.removeurl}} (x) {{/if}} - {{/foreach}}