Browse Source

Move suppress_tags config to template

- Add new item.suppress_tags template variable
- Fix template formatting
pull/4682/head
Hypolite Petovan 2 years ago
parent
commit
daffc27061
12 changed files with 103 additions and 82 deletions
  1. +20
    -20
      include/text.php
  2. +2
    -0
      src/Object/Post.php
  3. +7
    -5
      view/templates/wall_thread.tpl
  4. +15
    -13
      view/theme/frio/templates/search_item.tpl
  5. +16
    -14
      view/theme/frio/templates/wall_thread.tpl
  6. +7
    -5
      view/theme/frost-mobile/templates/wall_thread.tpl
  7. +7
    -5
      view/theme/frost/templates/wall_thread.tpl
  8. +3
    -1
      view/theme/quattro/templates/search_item.tpl
  9. +10
    -8
      view/theme/quattro/templates/wall_thread.tpl
  10. +3
    -1
      view/theme/smoothly/templates/wall_thread.tpl
  11. +3
    -2
      view/theme/vier/templates/search_item.tpl
  12. +10
    -8
      view/theme/vier/templates/wall_thread.tpl

+ 20
- 20
include/text.php View File

@ -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[] = "#<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 = "@";
if ($tag["type"] == TERM_HASHTAG) {
if ($orig_tag != $tag["url"]) {
$item['body'] = str_replace($orig_tag, $tag["url"], $item['body']);
}
$tags[] = $prefix."<a href=\"".$tag["url"]."\" target=\"_blank\">".$tag["term"]."</a>";
$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 = "@";
}
dba::close($taglist);
$tags[] = $prefix . "<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
}
dba::close($taglist);
$item['tags'] = $tags;
$item['hashtags'] = $hashtags;


+ 2
- 0
src/Object/Post.php View File

@ -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'],


+ 7
- 5
view/templates/wall_thread.tpl View File

@ -51,11 +51,13 @@
<div class="wall-item-title p-name" id="wall-item-title-{{$item.id}}">{{$item.title}}</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="body-tag">
{{foreach $item.tags as $tag}}
<span class='tag'>{{$tag}}</span>
{{/foreach}}
</div>
<div class="body-tag">
{{if !$item.suppress_tags}}
{{foreach $item.tags as $tag}}
<span class="tag">{{$tag}}</span>
{{/foreach}}
{{/if}}
</div>
{{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>


+ 15
- 13
view/theme/frio/templates/search_item.tpl View File

@ -141,23 +141,25 @@
<div class="wall-item-links">
</div>
<div class="wall-item-tags">
{{foreach $item.hashtags as $tag}}
<span class="tag label btn-info sm">{{$tag}} <i class="fa fa-bolt" aria-hidden="true"></i></span>
{{/foreach}}
{{if !$item.suppress_tags}}
{{foreach $item.hashtags as $tag}}
<span class="tag label btn-info sm">{{$tag}} <i class="fa fa-bolt" aria-hidden="true"></i></span>
{{/foreach}}
{{foreach $item.mentions as $tag}}
<span class="mention label btn-warning sm">{{$tag}} <i class="fa fa-user" aria-hidden="true"></i></span>
{{/foreach}}
{{foreach $item.mentions as $tag}}
<span class="mention label btn-warning sm">{{$tag}} <i class="fa fa-user" aria-hidden="true"></i></span>
{{/foreach}}
{{/if}}
{{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>
{{/foreach}}
{{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>
{{/foreach}}
{{foreach $item.categories as $cat}}
<span class="category label btn-success sm">{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span>
{{/foreach}}
{{foreach $item.categories as $cat}}
<span class="category label btn-success sm">{{$cat.name}}</a>{{if $cat.removeurl}} (<a href="{{$cat.removeurl}}" title="{{$remove}}">x</a>) {{/if}} </span>
{{/foreach}}
</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}}
</div>
<!-- ./TODO -->


+ 16
- 14
view/theme/frio/templates/wall_thread.tpl View File

@ -263,23 +263,25 @@ as the value of $top_child_total (this is done at the end of this file)
<div class="wall-item-links">
</div>
<div class="wall-item-tags">
{{foreach $item.hashtags as $tag}}
<span class='tag label btn-info sm'>{{$tag}} <i class="fa fa-bolt" aria-hidden="true"></i></span>
{{/foreach}}
{{foreach $item.mentions as $tag}}
<span class='mention label btn-warning sm'>{{$tag}} <i class="fa fa-user" aria-hidden="true"></i></span>
{{/foreach}}
{{if !$item.suppress_tags}}
{{foreach $item.hashtags as $tag}}
<span class="tag label btn-info sm">{{$tag}} <i class="fa fa-bolt" aria-hidden="true"></i></span>
{{/foreach}}
{{foreach $item.mentions as $tag}}
<span class="mention label btn-warning sm">{{$tag}} <i class="fa fa-user" aria-hidden="true"></i></span>
{{/foreach}}
{{/if}}
{{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>
{{/foreach}}
{{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>
{{/foreach}}
{{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>
{{/foreach}}
{{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>
{{/foreach}}
</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}}
</div>
<!-- ./TODO -->


+ 7
- 5
view/theme/frost-mobile/templates/wall_thread.tpl View File

@ -52,11 +52,13 @@
<div class="wall-item-title p-name" id="wall-item-title-{{$item.id}}">{{$item.title}}</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="body-tag">-->*}}
{{foreach $item.tags as $tag}}
<span class='body-tag tag'>{{$tag}}</span>
{{/foreach}}
{{*<!--</div>-->*}}
{{*<!--<div class="body-tag">-->*}}
{{if !$item.suppress_tags}}
{{foreach $item.tags as $tag}}
<span class="body-tag tag">{{$tag}}</span>
{{/foreach}}
{{/if}}
{{*<!--</div>-->*}}
{{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>


+ 7
- 5
view/theme/frost/templates/wall_thread.tpl View File

@ -47,11 +47,13 @@
<div class="wall-item-title p-name" id="wall-item-title-{{$item.id}}">{{$item.title}}</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="body-tag">-->*}}
{{foreach $item.tags as $tag}}
<span class='body-tag tag'>{{$tag}}</span>
{{/foreach}}
{{*<!--</div>-->*}}
{{*<!--<div class="body-tag">-->*}}
{{if !$item.suppress_tags}}
{{foreach $item.tags as $tag}}
<span class="body-tag tag">{{$tag}}</span>
{{/foreach}}
{{/if}}
{{*<!--</div>-->*}}
{{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>


+ 3
- 1
view/theme/quattro/templates/search_item.tpl View File

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


+ 10
- 8
view/theme/quattro/templates/wall_thread.tpl View File

@ -67,18 +67,20 @@
<div class="wall-item-links">
</div>
<div class="wall-item-tags">
{{if !$item.suppress_tags}}
{{foreach $item.hashtags as $tag}}
<span class='tag'>{{$tag}}</span>
<span class="tag">{{$tag}}</span>
{{/foreach}}
{{foreach $item.mentions as $tag}}
<span class='mention'>{{$tag}}</span>
<span class="mention">{{$tag}}</span>
{{/foreach}}
{{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>
{{/foreach}}
{{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>
{{/foreach}}
{{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>
{{/foreach}}
{{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>
{{/foreach}}
{{/if}}
</div>
</div>
<div class="wall-item-bottom">


+ 3
- 1
view/theme/smoothly/templates/wall_thread.tpl View File

@ -60,9 +60,11 @@
<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="body-tag">
{{if !$item.suppress_tags}}
{{foreach $item.tags as $tag}}
<span class='tag'>{{$tag}}</span>
<span class="tag">{{$tag}}</span>
{{/foreach}}
{{/if}}
</div>
{{if $item.has_cats}}


+ 3
- 2
view/theme/vier/templates/search_item.tpl View File

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


+ 10
- 8
view/theme/vier/templates/wall_thread.tpl View File

@ -74,18 +74,20 @@
<div class="wall-item-links">
</div>
<div class="wall-item-tags">
{{if !$item.suppress_tags}}
{{foreach $item.hashtags as $tag}}
<span class='tag'>{{$tag}}</span>
<span class="tag">{{$tag}}</span>
{{/foreach}}
{{foreach $item.mentions as $tag}}
<span class='mention'>{{$tag}}</span>
<span class="mention">{{$tag}}</span>
{{/foreach}}
{{/if}}
{{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>
{{/foreach}}
{{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>
{{/foreach}}
{{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>
{{/foreach}}
{{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>
{{/foreach}}
</div>
</div>
<div class="wall-item-bottom">


Loading…
Cancel
Save