4 * Description: Show link to a pledgie account for donating
6 * Author: tony baldwin <tony@free-haven.org>
7 * Hauke Altmann <https://snarl.de/profile/tugelblend>
10 use Friendica\Core\Addon;
11 use Friendica\Core\Config;
13 function pledgie_install() {
14 Addon::registerHook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active');
15 Addon::registerHook('addon_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings');
16 Addon::registerHook('addon_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post');
19 function pledgie_uninstall() {
20 Addon::unregisterHook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active');
21 Addon::unregisterHook('addon_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings');
22 Addon::unregisterHook('addon_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post');
25 function pledgie_addon_settings(&$a,&$s) {
30 /* Add our stylesheet to the page so we can make our settings look nice */
32 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/pledgie/pledgie.css' . '" media="all" />' . "\r\n";
34 $campaign = Config::get('pledgie-campaign','text');
35 $describe = Config::get('pledgie-describe','text');
43 $s .= '<div class="settings-block">';
44 $s .= '<h3>' . t('"pledgie" Settings') . '</h3>';
45 $s .= '<div id="pledgie-wrapper">';
46 $s .= '<label id="pledgie-label" for="pledgie-campaign">' . t('Pledgie campaign number to use for donations') . ' </label>';
47 $s .= '<input id="pledgie-campaign" type="text" name="pledgie-campaign" value="' . $campaign . '">';
48 $s .= '</div><div class="clear"></div>';
50 $s .= '<div id="pledgie-wrapper">';
51 $s .= '<label id="pledgie-label" for="pledgie-describe">' . t('Description of the Pledgie campaign') . ' </label>';
52 $s .= '<input id="pledgie-describe" type="text" name="pledgie-describe" value="' . $describe . '">';
53 $s .= '</div><div class="clear"></div>';
55 $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pledgie-submit" name="pledgie-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
60 function pledgie_addon_settings_post(&$a,&$b) {
65 if($_POST['pledgie-submit']) {
66 Config::set('pledgie-describe','text',trim(strip_tags($_POST['pledgie-describe'])));
67 Config::set('pledgie-campaign','text',trim(strip_tags($_POST['pledgie-campaign'])));
68 info( t('pledgie Settings saved.') . EOL);
72 function pledgie_active(&$a,&$b) {
73 $campaign = Config::get('pledgie-campaign','text');
74 $describe = Config::get('pledgie-describe','text');
75 $b .= '<div style="position: fixed; padding:5px; border-style:dotted; border-width:1px; background-color: white; line-height: 1; bottom: 5px; left: 20px; z-index: 1000; width: 150px; font-size: 12px;">';
76 $b .= $describe . '<br/><a href="https://pledgie.com/campaigns/';
78 $b .= '"><img alt="Click here to lend your support to: ' . $describe . '!" src="https://pledgie.com/campaigns/';
80 $b .= '.png?skin_name=chrome" border="0" target="_blank" /></a></div>';