From: friendica Date: Wed, 23 May 2012 01:05:39 +0000 (-0700) Subject: startpage addon X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3926f5582d6d1f704201a858ca09c969d4f110a7;p=friendica-addons.git startpage addon --- diff --git a/startpage.tgz b/startpage.tgz new file mode 100644 index 00000000..67a4ebd0 Binary files /dev/null and b/startpage.tgz differ diff --git a/startpage/startpage.css b/startpage/startpage.css new file mode 100644 index 00000000..e78be7ec --- /dev/null +++ b/startpage/startpage.css @@ -0,0 +1,16 @@ + + + +#startpage-page-label { + float: left; + width: 200px; + margin-bottom: 25px; +} + +#startpage-page { + float: left; +} + +#startpage-desc { + margin-bottom: 10px; +} diff --git a/startpage/startpage.php b/startpage/startpage.php new file mode 100644 index 00000000..85988298 --- /dev/null +++ b/startpage/startpage.php @@ -0,0 +1,94 @@ + + * + */ + + +function startpage_install() { + register_hook('home_init', 'addon/startpage/startpage.php', 'startpage_home_init'); + register_hook('plugin_settings', 'addon/startpage/startpage.php', 'startpage_settings'); + register_hook('plugin_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post'); +} + + +function startpage_uninstall() { + unregister_hook('home_init', 'addon/startpage/startpage.php', 'startpage_home_init'); + unregister_hook('plugin_settings', 'addon/startpage/startpage.php', 'startpage_settings'); + unregister_hook('plugin_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 Plugin 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 .= '

' . t('Startpage Settings') . '

'; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + $s .= '
' . t('Examples: "network" or "notifications/system"') . '
'; + + /* provide a submit button */ + + $s .= '
'; + +}