mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-10 18:38:49 +00:00
Merge pull request #566 from MrPetovan/task/add-content_filter-hook
Add content_filter hook
This commit is contained in:
commit
c4bd245a1a
10 changed files with 119 additions and 112 deletions
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2013-02-27 05:01-0500\n"
|
||||
"POT-Creation-Date: 2018-04-01 11:11-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -17,26 +17,26 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: showmore.php:38
|
||||
#: showmore.php:41 showmore.php:45
|
||||
msgid "\"Show more\" Settings"
|
||||
msgstr ""
|
||||
|
||||
#: showmore.php:41
|
||||
#: showmore.php:50
|
||||
msgid "Enable Show More"
|
||||
msgstr ""
|
||||
|
||||
#: showmore.php:44
|
||||
#: showmore.php:53
|
||||
msgid "Cutting posts after how much characters"
|
||||
msgstr ""
|
||||
|
||||
#: showmore.php:48
|
||||
msgid "Submit"
|
||||
#: showmore.php:57
|
||||
msgid "Save Settings"
|
||||
msgstr ""
|
||||
|
||||
#: showmore.php:65
|
||||
#: showmore.php:74
|
||||
msgid "Show More Settings saved."
|
||||
msgstr ""
|
||||
|
||||
#: showmore.php:119
|
||||
#: showmore.php:134
|
||||
msgid "show more"
|
||||
msgstr ""
|
||||
|
|
|
@ -107,26 +107,32 @@ function get_body_length($body) {
|
|||
return strlen($string);
|
||||
}
|
||||
|
||||
function showmore_prepare_body(&$a,&$b) {
|
||||
|
||||
$words = null;
|
||||
if(PConfig::get(local_user(),'showmore','disable'))
|
||||
function showmore_prepare_body(\Friendica\App $a, &$hook_data)
|
||||
{
|
||||
// No combination with content filters
|
||||
if (!empty($hook_data['filter_reasons'])) {
|
||||
return;
|
||||
|
||||
$chars = (int)PConfig::get(local_user(),'showmore','chars');
|
||||
if(!$chars)
|
||||
$chars = 1100;
|
||||
|
||||
if (get_body_length($b['html']) > $chars) {
|
||||
$found = true;
|
||||
$shortened = trim(showmore_cutitem($b['html'], $chars))."...";
|
||||
}
|
||||
|
||||
if($found) {
|
||||
if (PConfig::get(local_user(), 'showmore', 'disable')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$chars = (int) PConfig::get(local_user(), 'showmore', 'chars');
|
||||
if (!$chars) {
|
||||
$chars = 1100;
|
||||
}
|
||||
|
||||
if (get_body_length($hook_data['html']) > $chars) {
|
||||
$found = true;
|
||||
$shortened = trim(showmore_cutitem($hook_data['html'], $chars)) . "...";
|
||||
}
|
||||
|
||||
if ($found) {
|
||||
$rnd = random_string(8);
|
||||
$b['html'] = '<span id="showmore-teaser-'.$rnd.'" class="showmore-teaser" style="display: block;">'.$shortened." ".
|
||||
'<span id="showmore-wrap-'.$rnd.'" style="white-space:nowrap;" class="showmore-wrap fakelink" onclick="openClose(\'showmore-'.$rnd.'\'); openClose(\'showmore-teaser-'.$rnd.'\');" >'.L10n::t('show more').'</span></span>'.
|
||||
'<div id="showmore-'.$rnd.'" class="showmore-content" style="display: none;">'.$b['html'].'</div>';
|
||||
$hook_data['html'] = '<span id="showmore-teaser-' . $rnd . '" class="showmore-teaser" style="display: block;">' . $shortened . " " .
|
||||
'<span id="showmore-wrap-' . $rnd . '" style="white-space:nowrap;" class="showmore-wrap fakelink" onclick="openClose(\'showmore-' . $rnd . '\'); openClose(\'showmore-teaser-' . $rnd . '\');" >' . L10n::t('show more') . '</span></span>' .
|
||||
'<div id="showmore-' . $rnd . '" class="showmore-content" style="display: none;">' . $hook_data['html'] . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue