$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.$a->get_baseurl().'/addon/showmore/showmore.css'.'" media="all"/>'."\r\n";
- $enable_checked = (intval(get_pconfig(local_user(),'showmore','disable')) ? '' : ' checked="checked"');
- $chars = get_pconfig(local_user(),'showmore','chars');
+ $enable_checked = (intval(PConfig::get(local_user(),'showmore','disable')) ? '' : ' checked="checked"');
+ $chars = PConfig::get(local_user(),'showmore','chars');
if(!$chars)
$chars = '1100';
return;
if($_POST['showmore-submit']) {
- set_pconfig(local_user(),'showmore','chars',trim($_POST['showmore-chars']));
+ PConfig::set(local_user(),'showmore','chars',trim($_POST['showmore-chars']));
$enable = ((x($_POST,'showmore-enable')) ? intval($_POST['showmore-enable']) : 0);
$disable = 1-$enable;
PConfig::set(local_user(),'showmore','disable', $disable);
return strlen($string);
}
-function showmore_prepare_body(&$a,&$b) {
+function showmore_prepare_body(\Friendica\App $a, &$hook_data)
+{
+ // No combination with content filters
+ if (!empty($hook_data['filter_reasons'])) {
+ return;
+ }
- $words = null;
- if(get_pconfig(local_user(),'showmore','disable'))
+ if (PConfig::get(local_user(), 'showmore', 'disable')) {
return;
+ }
- $chars = (int)get_pconfig(local_user(),'showmore','chars');
- if(!$chars)
+ $chars = (int) PConfig::get(local_user(), 'showmore', 'chars');
+ if (!$chars) {
$chars = 1100;
+ }
- if (get_body_length($b['html']) > $chars) {
+ if (get_body_length($hook_data['html']) > $chars) {
$found = true;
- $shortened = trim(showmore_cutitem($b['html'], $chars))."...";
+ $shortened = trim(showmore_cutitem($hook_data['html'], $chars)) . "...";
}
- if($found) {
+ 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>';
}
}
@$doc->loadHTML($doctype."<html><body>".$text."</body></html>");
$text = $doc->saveHTML();
- $text = str_replace(array("<html><body>", "</body></html>", $doctype), array("", "", ""), $text);
+ $text = str_replace(["<html><body>", "</body></html>", $doctype], ["", "", ""], $text);
return($text);
}