X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=showmore%2Fshowmore.php;h=e39acdeea60cd2498bfd8baafe674f410663af44;hb=2f5abe4b04dc75e415957380dfbb0f6d754244cd;hp=d3753e6fdc1340b3d4c3f26974195d3e8b9a93b0;hpb=39dd3dffe07efd69fa1ac6d0bd243c7fc0e3a66f;p=friendica-addons.git diff --git a/showmore/showmore.php b/showmore/showmore.php index d3753e6f..e39acdee 100644 --- a/showmore/showmore.php +++ b/showmore/showmore.php @@ -32,8 +32,8 @@ function showmore_addon_settings(&$a,&$s) { $a->page['htmlhead'] .= ''."\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'; @@ -67,7 +67,7 @@ function showmore_addon_settings_post(&$a,&$b) { 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); @@ -107,26 +107,32 @@ function get_body_length($body) { 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'] = ''.$shortened." ". - ''.L10n::t('show more').''. - ''; + $hook_data['html'] = '' . $shortened . " " . + '' . L10n::t('show more') . '' . + ''; } } @@ -157,7 +163,7 @@ function showmore_cutitem($text, $limit) { @$doc->loadHTML($doctype."".$text.""); $text = $doc->saveHTML(); - $text = str_replace(array("", "", $doctype), array("", "", ""), $text); + $text = str_replace(["", "", $doctype], ["", "", ""], $text); return($text); }