4 * Description: Inserts a page header
6 * Author: Keith Fernie <http://friendika.me4.it/profile/keith>
7 * Hauke Altmann <https://snarl.de/profile/tugelblend>
10 use Friendica\Core\Addon;
11 use Friendica\Core\Config;
12 use Friendica\Core\L10n;
14 function pageheader_install() {
15 Addon::registerHook('page_content_top', 'addon/pageheader/pageheader.php', 'pageheader_fetch');
16 Addon::registerHook('addon_settings', 'addon/pageheader/pageheader.php', 'pageheader_addon_settings');
17 Addon::registerHook('addon_settings_post', 'addon/pageheader/pageheader.php', 'pageheader_addon_settings_post');
22 function pageheader_uninstall() {
23 Addon::unregisterHook('page_content_top', 'addon/pageheader/pageheader.php', 'pageheader_fetch');
24 Addon::unregisterHook('addon_settings', 'addon/pageheader/pageheader.php', 'pageheader_addon_settings');
25 Addon::unregisterHook('addon_settings_post', 'addon/pageheader/pageheader.php', 'pageheader_addon_settings_post');
27 // hook moved, uninstall the old one if still there.
28 Addon::unregisterHook('page_header', 'addon/pageheader/pageheader.php', 'pageheader_fetch');
36 function pageheader_addon_settings(&$a,&$s) {
42 /* Add our stylesheet to the page so we can make our settings look nice */
44 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/pageheader/pageheader.css' . '" media="all" />' . "\r\n";
47 $words = Config::get('pageheader','text');
51 $s .= '<div class="settings-block">';
52 $s .= '<h3>' . L10n::t('"pageheader" Settings') . '</h3>';
53 $s .= '<div id="pageheader-wrapper">';
54 $s .= '<label id="pageheader-label" for="pageheader-words">' . L10n::t('Message to display on every page on this server (or put a pageheader.html file in your docroot)') . ' </label>';
55 $s .= '<textarea id="pageheader-words" type="text" name="pageheader-words">' . $words . '</textarea>';
56 $s .= '</div><div class="clear"></div>';
58 $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pageheader-submit" name="pageheader-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
64 function pageheader_addon_settings_post(&$a,&$b) {
69 if($_POST['pageheader-submit']) {
70 Config::set('pageheader','text',trim(strip_tags($_POST['pageheader-words'])));
71 info(L10n::t('pageheader Settings saved.') . EOL);
75 function pageheader_fetch($a,&$b) {
77 if(file_exists('pageheader.html')){
78 $s = file_get_contents('pageheader.html');
80 $s = Config::get('pageheader', 'text');
83 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
84 . $a->get_baseurl() . '/addon/pageheader/pageheader.css' . '" media="all" />' . "\r\n";
89 $b .= '<div class="pageheader">' . $s . '</div>';