* */ use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; function startpage_install() { Addon::registerHook('home_init', 'addon/startpage/startpage.php', 'startpage_home_init'); Addon::registerHook('addon_settings', 'addon/startpage/startpage.php', 'startpage_settings'); Addon::registerHook('addon_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post'); } function startpage_uninstall() { Addon::unregisterHook('home_init', 'addon/startpage/startpage.php', 'startpage_home_init'); Addon::unregisterHook('addon_settings', 'addon/startpage/startpage.php', 'startpage_settings'); Addon::unregisterHook('addon_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post'); } function startpage_home_init($a, $b) { if(! local_user()) return; $page = get_pconfig(local_user(),'startpage','startpage'); if(strlen($page)) { $slash = ((strpos($page,'/') === 0) ? true : false); if(stristr($page,'://')) goaway($page); goaway($a->get_baseurl() . (($slash) ? '' : '/') . $page); } return; } /** * * Callback from the settings post function. * $post contains the $_POST array. * We will make sure we've got a valid user account * and if so set our configuration setting for this person. * */ function startpage_settings_post($a,$post) { if(! local_user()) return; if($_POST['startpage-submit']) set_pconfig(local_user(),'startpage','startpage',strip_tags(trim($_POST['startpage']))); } /** * * Called from the Addon Setting form. * Add our own settings info to the page. * */ function startpage_settings(&$a,&$s) { 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 = get_pconfig(local_user(),'startpage','startpage'); /* Add some HTML to the existing form */ $s .= ''; $s .= '

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

'; $s .= '
'; $s .= ''; }