Merge pull request #261 from tugelbend/master

Page Header addon now allows complex page header messages / Pledgie plugin allows to choose campaign
This commit is contained in:
Tobias Diekershoff 2015-05-16 12:05:45 +02:00
commit 1489253a95
7 changed files with 117 additions and 14 deletions

BIN
pageheader.tgz Executable file → Normal file

Binary file not shown.

View file

@ -3,3 +3,6 @@ Page Header
For server admins only.
Displays a text message for system announcements'
The message is entered in the admin account at settings, Plugin settings.
If you want to use HTML in the pageheader, create a file called pageheader.html
in the document root of your friendica instance and add the html there.

View file

@ -7,6 +7,8 @@
#pageheader-words {
float: left;
margin-top: 10px;
width: 400px;
height: 150px;
}
#pageheader-submit {

View file

@ -4,8 +4,9 @@
/**
* Name: Page Header
* Description: Inserts a page header
* Version: 1.0
* Version: 1.1
* Author: Keith Fernie <http://friendika.me4.it/profile/keith>
* Hauke Altmann <https://snarl.de/profile/tugelblend>
*
*/
@ -49,7 +50,8 @@ function pageheader_addon_settings(&$a,&$s) {
$s .= '<div class="settings-block">';
$s .= '<h3>' . t('"pageheader" Settings') . '</h3>';
$s .= '<div id="pageheader-wrapper">';
$s .= '<input id="pageheader-words" type="text" size="80" name="pageheader-words" value="' . $words .'" />';
$s .= '<label id="pageheader-label" for="pageheader-words">' . t('Message to display on every page on this server') . ' </label>';
$s .= '<textarea id="pageheader-words" type="text" name="pageheader-words">' . $words . '</textarea>';
$s .= '</div><div class="clear"></div>';
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pageheader-submit" name="pageheader-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
@ -71,9 +73,15 @@ function pageheader_addon_settings_post(&$a,&$b) {
function pageheader_fetch($a,&$b) {
if(file_exists('pageheader.html')){
$s = file_get_contents('pageheader.html');
} else {
$s = get_config('pageheader', 'text');
}
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
. $a->get_baseurl() . '/addon/pageheader/pageheader.css' . '" media="all" />' . "\r\n";
$s = get_config('pageheader','text');
if(! $s)
$s = '';
if ($s != '')

Binary file not shown.

28
pledgie/pledgie.css Executable file
View file

@ -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;
}

View file

@ -1,17 +1,79 @@
<?php
/**
* * Name: Pledgie
* * Description: Show link to Friendica pledgie account for donating
* * Version: 1.0
* * Author: tony baldwin <tony@free-haven.org>
* Status: Unsupported
* */
* Name: Pledgie
* Description: Show link to Friendica pledgie account for donating
* Version: 1.1
* Author: tony baldwin <tony@free-haven.org>
* Hauke Altmann <https://snarl.de/profile/tugelblend>
*
*/
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_uninstall() { unregister_hook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active'); }
function pledgie_addon_settings(&$a,&$s) {
if(! is_site_admin())
return;
/* Add our stylesheet to the page so we can make our settings look nice */
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/pledgie/pledgie.css' . '" media="all" />' . "\r\n";
$campaign = get_config('pledgie-campaign','text');
$describe = get_config('pledgie-describe','text');
if(! $campaign)
$campaign = '';
if(! describe)
$describe = '';
$s .= '<div class="settings-block">';
$s .= '<h3>' . t('"pledgie" Settings') . '</h3>';
$s .= '<div id="pledgie-wrapper">';
$s .= '<label id="pledgie-label" for="pledgie-campaign">' . t('Pledgie campaign number to use for donations') . ' </label>';
$s .= '<input id="pledgie-campaign" type="text" name="pledgie-campaign" value="' . $campaign . '">';
$s .= '</div><div class="clear"></div>';
$s .= '<div id="pledgie-wrapper">';
$s .= '<label id="pledgie-label" for="pledgie-describe">' . t('Description of the Pledgie campaign') . ' </label>';
$s .= '<input id="pledgie-describe" type="text" name="pledgie-describe" value="' . $describe . '">';
$s .= '</div><div class="clear"></div>';
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pledgie-submit" name="pledgie-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
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) {
//$b .= '<div style="position: fixed; bottom: 5px; left: 60px;"><a href=\'http://www.pledgie.com/campaigns/18417\'><img alt=\'Click here to lend your support to: Beyond Social Networking and make a donation at www.pledgie.com !\' src=\'http://www.pledgie.com/campaigns/18417.png?skin_name=chrome\' border=\'0\' target=\'_blank\' /></a></div>';
$campaign = get_config('pledgie-campaign','text');
$describe = get_config('pledgie-describe','text');
$b .= '<div style="position: fixed; bottom: 5px; left: 60px;">';
$b .= $describe . '<br/><a href=\'http://www.pledgie.com/campaigns/';
$b .= $campaign;
$b .= '\'><img alt=\'Click here to lend your support to: ' . $describe . '!\' src=\'http://www.pledgie.com/campaigns/';
$b .= $campaign;
$b .= '.png?skin_name=chrome\' border=\'0\' target=\'_blank\' /></a></div>';
}