2013-02-18 23:14:26 -05:00
|
|
|
<?php
|
|
|
|
/**
|
2015-05-13 16:28:09 -04:00
|
|
|
* Name: Pledgie
|
2015-05-18 15:51:34 -04:00
|
|
|
* Description: Show link to a pledgie account for donating
|
2015-05-13 16:28:09 -04:00
|
|
|
* Version: 1.1
|
|
|
|
* Author: tony baldwin <tony@free-haven.org>
|
|
|
|
* Hauke Altmann <https://snarl.de/profile/tugelblend>
|
2018-01-22 14:03:11 -05:00
|
|
|
*
|
2015-05-13 16:28:09 -04:00
|
|
|
*/
|
2018-01-16 19:51:12 -05:00
|
|
|
use Friendica\Core\Addon;
|
2017-11-06 18:55:24 -05:00
|
|
|
use Friendica\Core\Config;
|
2018-01-22 14:03:11 -05:00
|
|
|
use Friendica\Core\L10n;
|
2017-11-06 18:55:24 -05:00
|
|
|
|
2015-05-13 16:28:09 -04:00
|
|
|
function pledgie_install() {
|
2018-01-16 19:51:12 -05:00
|
|
|
Addon::registerHook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active');
|
2018-01-20 08:57:41 -05:00
|
|
|
Addon::registerHook('addon_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings');
|
|
|
|
Addon::registerHook('addon_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post');
|
2015-05-13 16:28:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function pledgie_uninstall() {
|
2018-01-16 19:51:12 -05:00
|
|
|
Addon::unregisterHook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active');
|
2018-01-20 08:57:41 -05:00
|
|
|
Addon::unregisterHook('addon_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings');
|
|
|
|
Addon::unregisterHook('addon_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post');
|
2015-05-13 16:28:09 -04:00
|
|
|
}
|
2013-02-18 23:14:26 -05:00
|
|
|
|
2015-05-13 16:28:09 -04:00
|
|
|
function pledgie_addon_settings(&$a,&$s) {
|
2013-02-18 23:14:26 -05:00
|
|
|
|
2015-05-13 16:28:09 -04:00
|
|
|
if(! is_site_admin())
|
|
|
|
return;
|
2013-02-18 23:14:26 -05:00
|
|
|
|
2015-05-13 16:28:09 -04:00
|
|
|
/* Add our stylesheet to the page so we can make our settings look nice */
|
|
|
|
|
2018-10-09 14:13:22 -04:00
|
|
|
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->getBaseURL() . '/addon/pledgie/pledgie.css' . '" media="all" />' . "\r\n";
|
2015-05-13 16:28:09 -04:00
|
|
|
|
2017-11-06 18:55:24 -05:00
|
|
|
$campaign = Config::get('pledgie-campaign','text');
|
|
|
|
$describe = Config::get('pledgie-describe','text');
|
2015-05-13 16:28:09 -04:00
|
|
|
|
|
|
|
if(! $campaign)
|
|
|
|
$campaign = '';
|
|
|
|
|
|
|
|
if(! describe)
|
|
|
|
$describe = '';
|
|
|
|
|
|
|
|
$s .= '<div class="settings-block">';
|
2018-01-22 14:03:11 -05:00
|
|
|
$s .= '<h3>' . L10n::t('"pledgie" Settings') . '</h3>';
|
2015-05-13 16:28:09 -04:00
|
|
|
$s .= '<div id="pledgie-wrapper">';
|
2018-01-22 14:03:11 -05:00
|
|
|
$s .= '<label id="pledgie-label" for="pledgie-campaign">' . L10n::t('Pledgie campaign number to use for donations') . ' </label>';
|
2015-05-13 16:28:09 -04:00
|
|
|
$s .= '<input id="pledgie-campaign" type="text" name="pledgie-campaign" value="' . $campaign . '">';
|
|
|
|
$s .= '</div><div class="clear"></div>';
|
|
|
|
|
|
|
|
$s .= '<div id="pledgie-wrapper">';
|
2018-01-22 14:03:11 -05:00
|
|
|
$s .= '<label id="pledgie-label" for="pledgie-describe">' . L10n::t('Description of the Pledgie campaign') . ' </label>';
|
2015-05-13 16:28:09 -04:00
|
|
|
$s .= '<input id="pledgie-describe" type="text" name="pledgie-describe" value="' . $describe . '">';
|
|
|
|
$s .= '</div><div class="clear"></div>';
|
|
|
|
|
2018-01-22 14:03:11 -05:00
|
|
|
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pledgie-submit" name="pledgie-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
|
2015-05-13 16:28:09 -04:00
|
|
|
|
|
|
|
return;
|
2015-02-12 11:29:43 -05:00
|
|
|
}
|
2015-05-13 16:28:09 -04:00
|
|
|
|
|
|
|
function pledgie_addon_settings_post(&$a,&$b) {
|
|
|
|
|
|
|
|
if(! is_site_admin())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if($_POST['pledgie-submit']) {
|
2017-11-06 18:55:24 -05:00
|
|
|
Config::set('pledgie-describe','text',trim(strip_tags($_POST['pledgie-describe'])));
|
|
|
|
Config::set('pledgie-campaign','text',trim(strip_tags($_POST['pledgie-campaign'])));
|
2018-01-22 14:03:11 -05:00
|
|
|
info(L10n::t('pledgie Settings saved.') . EOL);
|
2015-05-13 16:28:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function pledgie_active(&$a,&$b) {
|
2017-11-06 18:55:24 -05:00
|
|
|
$campaign = Config::get('pledgie-campaign','text');
|
|
|
|
$describe = Config::get('pledgie-describe','text');
|
2015-05-18 16:21:38 -04:00
|
|
|
$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;">';
|
2017-03-20 03:38:50 -04:00
|
|
|
$b .= $describe . '<br/><a href="https://pledgie.com/campaigns/';
|
2015-05-13 16:28:09 -04:00
|
|
|
$b .= $campaign;
|
2017-03-20 03:38:50 -04:00
|
|
|
$b .= '"><img alt="Click here to lend your support to: ' . $describe . '!" src="https://pledgie.com/campaigns/';
|
2015-05-13 16:28:09 -04:00
|
|
|
$b .= $campaign;
|
2017-02-09 13:07:00 -05:00
|
|
|
$b .= '.png?skin_name=chrome" border="0" target="_blank" /></a></div>';
|
2017-02-09 09:52:50 -05:00
|
|
|
}
|