X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=startpage%2Fstartpage.php;h=1e5edeea750de439cfa3b3fe36fd30028321eff2;hb=a2760cb1d1ca3d05337ba3e39fab45b772c474eb;hp=82ae1eb04db6f7dd0ea1722b415d82b9dc5c4157;hpb=36120615dd049c94b9db7858aae77d8ec9d28e84;p=friendica-addons.git diff --git a/startpage/startpage.php b/startpage/startpage.php index 82ae1eb0..1e5edeea 100644 --- a/startpage/startpage.php +++ b/startpage/startpage.php @@ -6,9 +6,11 @@ * Author: Mike Macgirvin * */ + +use Friendica\App; use Friendica\Core\Hook; -use Friendica\Core\L10n; -use Friendica\Core\PConfig; +use Friendica\Core\Renderer; +use Friendica\DI; function startpage_install() { Hook::register('home_init', 'addon/startpage/startpage.php', 'startpage_home_init'); @@ -16,22 +18,15 @@ function startpage_install() { Hook::register('addon_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post'); } -function startpage_uninstall() -{ - Hook::unregister('home_init', 'addon/startpage/startpage.php', 'startpage_home_init'); - Hook::unregister('addon_settings', 'addon/startpage/startpage.php', 'startpage_settings'); - Hook::unregister('addon_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post'); -} - -function startpage_home_init($a, $b) +function startpage_home_init(App $a, $b) { if (!local_user()) { return; } - $page = PConfig::get(local_user(), 'startpage', 'startpage'); + $page = DI::pConfig()->get(local_user(), 'startpage', 'startpage'); if (strlen($page)) { - $a->internalRedirect($page); + DI::baseUrl()->redirect($page); } return; } @@ -45,14 +40,14 @@ function startpage_home_init($a, $b) * */ -function startpage_settings_post($a, $post) +function startpage_settings_post(App $a, $post) { if (!local_user()) { return; } if (!empty($_POST['startpage-submit'])) { - PConfig::set(local_user(), 'startpage', 'startpage', strip_tags(trim($_POST['startpage']))); + DI::pConfig()->set(local_user(), 'startpage', 'startpage', strip_tags(trim($_POST['startpage']))); } } @@ -62,36 +57,22 @@ function startpage_settings_post($a, $post) * Add our own settings info to the page. * */ -function startpage_settings(&$a, &$s) +function startpage_settings(App &$a, array &$data) { if (!local_user()) { return; } - /* Add our stylesheet to the page so we can make our settings look nice */ - - $a->page['htmlhead'] .= '' . "\r\n"; - - /* Get the current state of our config variable */ - - $page = PConfig::get(local_user(), 'startpage', 'startpage'); - - /* Add some HTML to the existing form */ - - $s .= ''; - $s .= '

' . L10n::t('Startpage') . '

'; - $s .= '
'; - $s .= ''; + $data = [ + 'addon' => 'startpage', + 'title' => DI::l10n()->t('Startpage'), + 'html' => $html, + ]; }