6 * Description: Inserts a page header
8 * Author: Keith Fernie <http://friendika.me4.it/profile/keith>
9 * Hauke Altmann <https://snarl.de/profile/tugelblend>
13 use Friendica\Core\Config;
15 function pageheader_install() {
16 register_hook('page_content_top', 'addon/pageheader/pageheader.php', 'pageheader_fetch');
17 register_hook('plugin_settings', 'addon/pageheader/pageheader.php', 'pageheader_addon_settings');
18 register_hook('plugin_settings_post', 'addon/pageheader/pageheader.php', 'pageheader_addon_settings_post');
23 function pageheader_uninstall() {
24 unregister_hook('page_content_top', 'addon/pageheader/pageheader.php', 'pageheader_fetch');
25 unregister_hook('plugin_settings', 'addon/pageheader/pageheader.php', 'pageheader_addon_settings');
26 unregister_hook('plugin_settings_post', 'addon/pageheader/pageheader.php', 'pageheader_addon_settings_post');
28 // hook moved, uninstall the old one if still there.
29 unregister_hook('page_header', 'addon/pageheader/pageheader.php', 'pageheader_fetch');
37 function pageheader_addon_settings(&$a,&$s) {
43 /* Add our stylesheet to the page so we can make our settings look nice */
45 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/pageheader/pageheader.css' . '" media="all" />' . "\r\n";
48 $words = Config::get('pageheader','text');
52 $s .= '<div class="settings-block">';
53 $s .= '<h3>' . t('"pageheader" Settings') . '</h3>';
54 $s .= '<div id="pageheader-wrapper">';
55 $s .= '<label id="pageheader-label" for="pageheader-words">' . t('Message to display on every page on this server (or put a pageheader.html file in your docroot)') . ' </label>';
56 $s .= '<textarea id="pageheader-words" type="text" name="pageheader-words">' . $words . '</textarea>';
57 $s .= '</div><div class="clear"></div>';
59 $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pageheader-submit" name="pageheader-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
65 function pageheader_addon_settings_post(&$a,&$b) {
70 if($_POST['pageheader-submit']) {
71 Config::set('pageheader','text',trim(strip_tags($_POST['pageheader-words'])));
72 info( t('pageheader Settings saved.') . EOL);
76 function pageheader_fetch($a,&$b) {
78 if(file_exists('pageheader.html')){
79 $s = file_get_contents('pageheader.html');
81 $s = Config::get('pageheader', 'text');
84 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
85 . $a->get_baseurl() . '/addon/pageheader/pageheader.css' . '" media="all" />' . "\r\n";
90 $b .= '<div class="pageheader">' . $s . '</div>';