Merge pull request #4682 from MrPetovan/task/4681-nsfw-add-hashtag-only-hiding

Move suppress_tags config usage to template
This commit is contained in:
Michael Vogel 2018-03-25 22:26:17 +02:00 committed by GitHub
commit bfc2bda9b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 106 additions and 85 deletions

View file

@ -1239,13 +1239,12 @@ function prepare_body(&$item, $attach = false, $preview = false) {
return $ev; 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`", $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)); intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
while ($tag = dba::fetch($taglist)) { while ($tag = dba::fetch($taglist)) {
if ($tag["url"] == "") { if ($tag["url"] == "") {
$tag["url"] = $searchpath.strtolower($tag["term"]); $tag["url"] = $searchpath . strtolower($tag["term"]);
} }
$orig_tag = $tag["url"]; $orig_tag = $tag["url"];
@ -1256,16 +1255,17 @@ function prepare_body(&$item, $attach = false, $preview = false) {
if ($orig_tag != $tag["url"]) { if ($orig_tag != $tag["url"]) {
$item['body'] = str_replace($orig_tag, $tag["url"], $item['body']); $item['body'] = str_replace($orig_tag, $tag["url"], $item['body']);
} }
$hashtags[] = "#<a href=\"".$tag["url"]."\" target=\"_blank\">".$tag["term"]."</a>";
$hashtags[] = "#<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
$prefix = "#"; $prefix = "#";
} elseif ($tag["type"] == TERM_MENTION) { } elseif ($tag["type"] == TERM_MENTION) {
$mentions[] = "@<a href=\"".$tag["url"]."\" target=\"_blank\">".$tag["term"]."</a>"; $mentions[] = "@<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
$prefix = "@"; $prefix = "@";
} }
$tags[] = $prefix."<a href=\"".$tag["url"]."\" target=\"_blank\">".$tag["term"]."</a>";
$tags[] = $prefix . "<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
} }
dba::close($taglist); dba::close($taglist);
}
$item['tags'] = $tags; $item['tags'] = $tags;
$item['hashtags'] = $hashtags; $item['hashtags'] = $hashtags;

View file

@ -8,6 +8,7 @@ use Friendica\BaseObject;
use Friendica\Content\ContactSelector; use Friendica\Content\ContactSelector;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Database\DBM; use Friendica\Database\DBM;
@ -337,6 +338,7 @@ class Post extends BaseObject
$tmp_item = [ $tmp_item = [
'template' => $this->getTemplate(), 'template' => $this->getTemplate(),
'type' => implode("", array_slice(explode("/", $item['verb']), -1)), 'type' => implode("", array_slice(explode("/", $item['verb']), -1)),
'suppress_tags' => Config::get('system', 'suppress_tags'),
'tags' => $item['tags'], 'tags' => $item['tags'],
'hashtags' => $item['hashtags'], 'hashtags' => $item['hashtags'],
'mentions' => $item['mentions'], 'mentions' => $item['mentions'],

View file

@ -52,9 +52,11 @@
<div class="wall-item-title-end"></div> <div class="wall-item-title-end"></div>
<div class="wall-item-body" id="wall-item-body-{{$item.id}}" ><span class="e-content">{{$item.body}}<span> <div class="wall-item-body" id="wall-item-body-{{$item.id}}" ><span class="e-content">{{$item.body}}<span>
<div class="body-tag"> <div class="body-tag">
{{if !$item.suppress_tags}}
{{foreach $item.tags as $tag}} {{foreach $item.tags as $tag}}
<span class='tag'>{{$tag}}</span> <span class="tag">{{$tag}}</span>
{{/foreach}} {{/foreach}}
{{/if}}
</div> </div>
{{if $item.has_cats}} {{if $item.has_cats}}
<div class="categorytags"><span>{{$item.txt_cats}} {{foreach $item.categories as $cat}}<span class="p-category">{{$cat.name}}</span>{{if $cat.removeurl}} <a href="{{$cat.removeurl}}" title="{{$remove|escape:'html'}}">[{{$remove}}]</a>{{/if}} {{if $cat.last}}{{else}}, {{/if}}{{/foreach}} <div class="categorytags"><span>{{$item.txt_cats}} {{foreach $item.categories as $cat}}<span class="p-category">{{$cat.name}}</span>{{if $cat.removeurl}} <a href="{{$cat.removeurl}}" title="{{$remove|escape:'html'}}">[{{$remove}}]</a>{{/if}} {{if $cat.last}}{{else}}, {{/if}}{{/foreach}}

View file

@ -141,6 +141,7 @@
<div class="wall-item-links"> <div class="wall-item-links">
</div> </div>
<div class="wall-item-tags"> <div class="wall-item-tags">
{{if !$item.suppress_tags}}
{{foreach $item.hashtags as $tag}} {{foreach $item.hashtags as $tag}}
<span class="tag label btn-info sm">{{$tag}} <i class="fa fa-bolt" aria-hidden="true"></i></span> <span class="tag label btn-info sm">{{$tag}} <i class="fa fa-bolt" aria-hidden="true"></i></span>
{{/foreach}} {{/foreach}}
@ -148,6 +149,7 @@
{{foreach $item.mentions as $tag}} {{foreach $item.mentions as $tag}}
<span class="mention label btn-warning sm">{{$tag}} <i class="fa fa-user" aria-hidden="true"></i></span> <span class="mention label btn-warning sm">{{$tag}} <i class="fa fa-user" aria-hidden="true"></i></span>
{{/foreach}} {{/foreach}}
{{/if}}
{{foreach $item.folders as $cat}} {{foreach $item.folders as $cat}}
<span class="folder label btn-danger sm">{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span> <span class="folder label btn-danger sm">{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span>

View file

@ -263,20 +263,22 @@ as the value of $top_child_total (this is done at the end of this file)
<div class="wall-item-links"> <div class="wall-item-links">
</div> </div>
<div class="wall-item-tags"> <div class="wall-item-tags">
{{if !$item.suppress_tags}}
{{foreach $item.hashtags as $tag}} {{foreach $item.hashtags as $tag}}
<span class='tag label btn-info sm'>{{$tag}} <i class="fa fa-bolt" aria-hidden="true"></i></span> <span class="tag label btn-info sm">{{$tag}} <i class="fa fa-bolt" aria-hidden="true"></i></span>
{{/foreach}} {{/foreach}}
{{foreach $item.mentions as $tag}} {{foreach $item.mentions as $tag}}
<span class='mention label btn-warning sm'>{{$tag}} <i class="fa fa-user" aria-hidden="true"></i></span> <span class="mention label btn-warning sm">{{$tag}} <i class="fa fa-user" aria-hidden="true"></i></span>
{{/foreach}} {{/foreach}}
{{/if}}
{{foreach $item.folders as $cat}} {{foreach $item.folders as $cat}}
<span class='folder label btn-danger sm'><span class="p-category">{{$cat.name}}</span></a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span> <span class="folder label btn-danger sm"><span class="p-category">{{$cat.name}}</span></a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span>
{{/foreach}} {{/foreach}}
{{foreach $item.categories as $cat}} {{foreach $item.categories as $cat}}
<span class='category label btn-success sm'><span class="p-category">{{$cat.name}}</span></a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span> <span class="category label btn-success sm"><span class="p-category">{{$cat.name}}</span></a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span>
{{/foreach}} {{/foreach}}
</div> </div>
{{if $item.edited}}<div class="itemedited text-muted">{{$item.edited['label']}} (<span title="{{$item.edited['date']}}">{{$item.edited['relative']}}</span>)</div>{{/if}} {{if $item.edited}}<div class="itemedited text-muted">{{$item.edited['label']}} (<span title="{{$item.edited['date']}}">{{$item.edited['relative']}}</span>)</div>{{/if}}

View file

@ -53,9 +53,11 @@
{{*<!--<div class="wall-item-title-end"></div>-->*}} {{*<!--<div class="wall-item-title-end"></div>-->*}}
<div class="wall-item-body" id="wall-item-body-{{$item.id}}" ><span class="e-content">{{$item.body}}</span> <div class="wall-item-body" id="wall-item-body-{{$item.id}}" ><span class="e-content">{{$item.body}}</span>
{{*<!--<div class="body-tag">-->*}} {{*<!--<div class="body-tag">-->*}}
{{if !$item.suppress_tags}}
{{foreach $item.tags as $tag}} {{foreach $item.tags as $tag}}
<span class='body-tag tag'>{{$tag}}</span> <span class="body-tag tag">{{$tag}}</span>
{{/foreach}} {{/foreach}}
{{/if}}
{{*<!--</div>-->*}} {{*<!--</div>-->*}}
{{if $item.has_cats}} {{if $item.has_cats}}
<div class="categorytags">{{$item.txt_cats}} {{foreach $item.categories as $cat}}<span class="p-category">{{$cat.name}}</span> <a href="{{$cat.removeurl}}" title="{{$remove}}">[{{$remove}}]</a> {{if $cat.last}}{{else}}, {{/if}}{{/foreach}} <div class="categorytags">{{$item.txt_cats}} {{foreach $item.categories as $cat}}<span class="p-category">{{$cat.name}}</span> <a href="{{$cat.removeurl}}" title="{{$remove}}">[{{$remove}}]</a> {{if $cat.last}}{{else}}, {{/if}}{{/foreach}}

View file

@ -48,9 +48,11 @@
{{*<!--<div class="wall-item-title-end"></div>-->*}} {{*<!--<div class="wall-item-title-end"></div>-->*}}
<div class="wall-item-body" id="wall-item-body-{{$item.id}}" ><span class="e-content">{{$item.body}}</span> <div class="wall-item-body" id="wall-item-body-{{$item.id}}" ><span class="e-content">{{$item.body}}</span>
{{*<!--<div class="body-tag">-->*}} {{*<!--<div class="body-tag">-->*}}
{{if !$item.suppress_tags}}
{{foreach $item.tags as $tag}} {{foreach $item.tags as $tag}}
<span class='body-tag tag'>{{$tag}}</span> <span class="body-tag tag">{{$tag}}</span>
{{/foreach}} {{/foreach}}
{{/if}}
{{*<!--</div>-->*}} {{*<!--</div>-->*}}
{{if $item.has_cats}} {{if $item.has_cats}}
<div class="categorytags">{{$item.txt_cats}} {{foreach $item.categories as $cat}}<span class="p-category">{{$cat.name}}</span> <a href="{{$cat.removeurl}}" title="{{$remove}}">[{{$remove}}]</a> {{if $cat.last}}{{else}}, {{/if}}{{/foreach}} <div class="categorytags">{{$item.txt_cats}} {{foreach $item.categories as $cat}}<span class="p-category">{{$cat.name}}</span> <a href="{{$cat.removeurl}}" title="{{$remove}}">[{{$remove}}]</a> {{if $cat.last}}{{else}}, {{/if}}{{/foreach}}

View file

@ -30,9 +30,11 @@
<div class="wall-item-links"> <div class="wall-item-links">
</div> </div>
<div class="wall-item-tags"> <div class="wall-item-tags">
{{if !$item.suppress_tags}}
{{foreach $item.tags as $tag}} {{foreach $item.tags as $tag}}
<span class='tag'>{{$tag}}</span> <span class="tag">{{$tag}}</span>
{{/foreach}} {{/foreach}}
{{/if}}
</div> </div>
</div> </div>
<div class="wall-item-bottom"> <div class="wall-item-bottom">

View file

@ -67,18 +67,20 @@
<div class="wall-item-links"> <div class="wall-item-links">
</div> </div>
<div class="wall-item-tags"> <div class="wall-item-tags">
{{if !$item.suppress_tags}}
{{foreach $item.hashtags as $tag}} {{foreach $item.hashtags as $tag}}
<span class='tag'>{{$tag}}</span> <span class="tag">{{$tag}}</span>
{{/foreach}} {{/foreach}}
{{foreach $item.mentions as $tag}} {{foreach $item.mentions as $tag}}
<span class='mention'>{{$tag}}</span> <span class="mention">{{$tag}}</span>
{{/foreach}} {{/foreach}}
{{foreach $item.folders as $cat}} {{foreach $item.folders as $cat}}
<span class='folder p-category'>{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span> <span class="folder p-category">{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span>
{{/foreach}} {{/foreach}}
{{foreach $item.categories as $cat}} {{foreach $item.categories as $cat}}
<span class='category p-category'>{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span> <span class="category p-category">{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span>
{{/foreach}} {{/foreach}}
{{/if}}
</div> </div>
</div> </div>
<div class="wall-item-bottom"> <div class="wall-item-bottom">

View file

@ -60,9 +60,11 @@
<div class="wall-item-title-end"></div> <div class="wall-item-title-end"></div>
<div class="wall-item-body" id="wall-item-body-{{$item.id}}" ><span class="e-content">{{$item.body}}</span> <div class="wall-item-body" id="wall-item-body-{{$item.id}}" ><span class="e-content">{{$item.body}}</span>
<div class="body-tag"> <div class="body-tag">
{{if !$item.suppress_tags}}
{{foreach $item.tags as $tag}} {{foreach $item.tags as $tag}}
<span class='tag'>{{$tag}}</span> <span class="tag">{{$tag}}</span>
{{/foreach}} {{/foreach}}
{{/if}}
</div> </div>
{{if $item.has_cats}} {{if $item.has_cats}}

View file

@ -37,10 +37,11 @@
<div class="wall-item-links"> <div class="wall-item-links">
</div> </div>
<div class="wall-item-tags"> <div class="wall-item-tags">
{{if !$item.suppress_tags}}
{{foreach $item.tags as $tag}} {{foreach $item.tags as $tag}}
<span class='tag'>{{$tag}}</span> <span class="tag">{{$tag}}</span>
{{/foreach}} {{/foreach}}
{{/if}}
</div> </div>
</div> </div>
<div class="wall-item-bottom"> <div class="wall-item-bottom">

View file

@ -74,17 +74,19 @@
<div class="wall-item-links"> <div class="wall-item-links">
</div> </div>
<div class="wall-item-tags"> <div class="wall-item-tags">
{{if !$item.suppress_tags}}
{{foreach $item.hashtags as $tag}} {{foreach $item.hashtags as $tag}}
<span class='tag'>{{$tag}}</span> <span class="tag">{{$tag}}</span>
{{/foreach}} {{/foreach}}
{{foreach $item.mentions as $tag}} {{foreach $item.mentions as $tag}}
<span class='mention'>{{$tag}}</span> <span class="mention">{{$tag}}</span>
{{/foreach}} {{/foreach}}
{{/if}}
{{foreach $item.folders as $cat}} {{foreach $item.folders as $cat}}
<span class='folder p-category'>{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span> <span class="folder p-category">{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span>
{{/foreach}} {{/foreach}}
{{foreach $item.categories as $cat}} {{foreach $item.categories as $cat}}
<span class='category p-category'>{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span> <span class="category p-category">{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span>
{{/foreach}} {{/foreach}}
</div> </div>
</div> </div>