From 9e8edd103d9803721045df0efb535d5e4bee9ae8 Mon Sep 17 00:00:00 2001 From: hauke Date: Wed, 13 May 2015 22:28:09 +0200 Subject: [PATCH] Pledgie addon allows to configure the Pledgie campaign to use --- pledgie/pledgie.css | 28 ++++++++++++++++ pledgie/pledgie.php | 82 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 100 insertions(+), 10 deletions(-) create mode 100755 pledgie/pledgie.css diff --git a/pledgie/pledgie.css b/pledgie/pledgie.css new file mode 100755 index 00000000..9cb9896d --- /dev/null +++ b/pledgie/pledgie.css @@ -0,0 +1,28 @@ +#pledgie-label { + float: left; + width: 300px; + margin-top: 10px; +} + +#pledgie-campaign { + float: left; + margin-top: 10px; + width: 100px; +} + +#pledgie-describe { + float: left; + margin-top: 10px; + width: 300px; +} + +#pledgie-submit { + margin-top: 15px; +} + +.pledgie { + text-align: center; + width 100%; + margin-top: 25px; + font-size: 20px; +} diff --git a/pledgie/pledgie.php b/pledgie/pledgie.php index c88dcbeb..af72a45f 100644 --- a/pledgie/pledgie.php +++ b/pledgie/pledgie.php @@ -1,17 +1,79 @@ - * Status: Unsupported - * */ + * Name: Pledgie + * Description: Show link to Friendica pledgie account for donating + * Version: 1.1 + * Author: tony baldwin + * Hauke Altmann + * + */ -function pledgie_install() { register_hook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active'); } +function pledgie_install() { + register_hook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active'); + register_hook('plugin_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings'); + register_hook('plugin_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post'); +} + +function pledgie_uninstall() { + unregister_hook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active'); + unregister_hook('plugin_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings'); + unregister_hook('plugin_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post'); +} +function pledgie_addon_settings(&$a,&$s) { -function pledgie_uninstall() { unregister_hook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active'); } + if(! is_site_admin()) + return; -function pledgie_active(&$a,&$b) { - //$b .= '
\'Click
'; + /* Add our stylesheet to the page so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + $campaign = get_config('pledgie-campaign','text'); + $describe = get_config('pledgie-describe','text'); + + if(! $campaign) + $campaign = ''; + + if(! describe) + $describe = ''; + + $s .= '
'; + $s .= '

' . t('"pledgie" Settings') . '

'; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + + return; } + +function pledgie_addon_settings_post(&$a,&$b) { + + if(! is_site_admin()) + return; + + if($_POST['pledgie-submit']) { + set_config('pledgie-describe','text',trim(strip_tags($_POST['pledgie-describe']))); + set_config('pledgie-campaign','text',trim(strip_tags($_POST['pledgie-campaign']))); + info( t('pledgie Settings saved.') . EOL); + } +} + +function pledgie_active(&$a,&$b) { + $campaign = get_config('pledgie-campaign','text'); + $describe = get_config('pledgie-describe','text'); + $b .= '
'; + $b .= $describe . '
\'Click
'; +} \ No newline at end of file -- 2.39.5