X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=group_text%2Fgroup_text.php;h=cb2c5eee4c6de034beffcac256977e659f2e3744;hb=886c56e4b7a96c7d88c58d1bec1da36abc987b89;hp=3e636091fe6fdcbac5b4a35c236c9d58499d3e15;hpb=8504f2e9997e83c19d76a01a4fdbafd480b0926d;p=friendica-addons.git diff --git a/group_text/group_text.php b/group_text/group_text.php index 3e636091..cb2c5eee 100644 --- a/group_text/group_text.php +++ b/group_text/group_text.php @@ -5,10 +5,11 @@ * Version: 1.0 * Author: Thomas Willingham */ + +use Friendica\App; use Friendica\Core\Hook; -use Friendica\Core\L10n; use Friendica\Core\Logger; -use Friendica\Core\PConfig; +use Friendica\Core\Renderer; use Friendica\DI; function group_text_install() { @@ -16,21 +17,9 @@ function group_text_install() { Hook::register('addon_settings', 'addon/group_text/group_text.php', 'group_text_settings'); Hook::register('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post'); - Logger::log("installed group_text"); + Logger::notice("installed group_text"); } - -function group_text_uninstall() { - - Hook::unregister('addon_settings', 'addon/group_text/group_text.php', 'group_text_settings'); - Hook::unregister('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post'); - - - Logger::log("removed group_text"); -} - - - /** * * Callback from the settings post function. @@ -43,9 +32,7 @@ function group_text_uninstall() { function group_text_settings_post($a,$post) { if(! local_user() || empty($_POST['group_text-submit'])) return; - PConfig::set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text'])); - - info(L10n::t('Group Text settings updated.') . EOL); + DI::pConfig()->set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text'])); } @@ -58,31 +45,22 @@ function group_text_settings_post($a,$post) { -function group_text_settings(&$a,&$s) { - - if(! local_user()) +function group_text_settings(App &$a, array &$data) +{ + if (!local_user()) { return; + } - /* Add our stylesheet to the page so we can make our settings look nice */ - - DI::page()['htmlhead'] .= '' . "\r\n"; - - /* Get the current state of our config variable */ - - $enabled = PConfig::get(local_user(),'system','groupedit_image_limit'); - $checked = (($enabled) ? ' checked="checked" ' : ''); - - /* Add some HTML to the existing form */ - - $s .= '
'; - $s .= '

' . L10n::t('Group Text') . '

'; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - /* provide a submit button */ + $enabled = DI::pConfig()->get(local_user(),'system','groupedit_image_limit'); - $s .= '
'; + $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/group_text/'); + $html = Renderer::replaceMacros($t, [ + '$enabled' => ['group_text', DI::l10n()->t('Use a text only (non-image) group selector in the "group edit" menu'), $enabled], + ]); + $data = [ + 'addon' => 'group_text', + 'title' => DI::l10n()->t('Group Text'), + 'html' => $html, + ]; }