X-Git-Url: https://git.mxchange.org/?p=friendica-addons.git;a=blobdiff_plain;f=showmore%2Fshowmore.php;h=8f0e6693c89c87cf647061a3ec21cd2da4a8df68;hp=9a136c7f23eb319c183cbfd1c869493444896912;hb=0afd633346b517894ff8e92c705bd5d052dd06a2;hpb=0b459e83794fff75fc9cbd980738147e367becf4 diff --git a/showmore/showmore.php b/showmore/showmore.php old mode 100755 new mode 100644 index 9a136c7f..8f0e6693 --- a/showmore/showmore.php +++ b/showmore/showmore.php @@ -7,17 +7,19 @@ * based upon NSFW from Mike Macgirvin * */ +use Friendica\Core\Addon; +use Friendica\Core\PConfig; function showmore_install() { - register_hook('prepare_body', 'addon/showmore/showmore.php', 'showmore_prepare_body'); - register_hook('plugin_settings', 'addon/showmore/showmore.php', 'showmore_addon_settings'); - register_hook('plugin_settings_post', 'addon/showmore/showmore.php', 'showmore_addon_settings_post'); + Addon::registerHook('prepare_body', 'addon/showmore/showmore.php', 'showmore_prepare_body'); + Addon::registerHook('plugin_settings', 'addon/showmore/showmore.php', 'showmore_addon_settings'); + Addon::registerHook('plugin_settings_post', 'addon/showmore/showmore.php', 'showmore_addon_settings_post'); } function showmore_uninstall() { - unregister_hook('prepare_body', 'addon/showmore/showmore.php', 'showmore_prepare_body'); - unregister_hook('plugin_settings', 'addon/showmore/showmore.php', 'showmore_addon_settings'); - unregister_hook('plugin_settings_post', 'addon/showmore/showmore.php', 'showmore_addon_settings_post'); + Addon::unregisterHook('prepare_body', 'addon/showmore/showmore.php', 'showmore_prepare_body'); + Addon::unregisterHook('plugin_settings', 'addon/showmore/showmore.php', 'showmore_addon_settings'); + Addon::unregisterHook('plugin_settings_post', 'addon/showmore/showmore.php', 'showmore_addon_settings_post'); } function showmore_addon_settings(&$a,&$s) { @@ -29,8 +31,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'; @@ -64,10 +66,10 @@ 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; - set_pconfig(local_user(),'showmore','disable', $disable); + PConfig::set(local_user(),'showmore','disable', $disable); info( t('Show More Settings saved.') . EOL); } } @@ -107,10 +109,10 @@ function get_body_length($body) { function showmore_prepare_body(&$a,&$b) { $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'); + $chars = (int)PConfig::get(local_user(),'showmore','chars'); if(!$chars) $chars = 1100; @@ -121,9 +123,9 @@ function showmore_prepare_body(&$a,&$b) { if($found) { $rnd = random_string(8); - $b['html'] = ''.$shortened." ". - ''.sprintf(t('show more')).''. - ''; + $b['html'] = ''.$shortened." ". + ''.sprintf(t('show more')).''. + ''; } } @@ -154,7 +156,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); }