4 * Description: Inserts a page header
6 * Author: Keith Fernie <http://friendika.me4.it/profile/keith>
7 * Hauke Altmann <https://snarl.de/profile/tugelblend>
12 use Friendica\Core\Config;
13 use Friendica\Core\Hook;
14 use Friendica\Core\Renderer;
17 function pageheader_install() {
18 Hook::register('page_content_top', __FILE__, 'pageheader_fetch');
21 function pageheader_addon_admin(App &$a, &$s)
23 if(! is_site_admin()) {
27 /* Add our stylesheet to the page so we can make our settings look nice */
28 $stylesheetPath = __DIR__ . '/pageheader.css';
29 DI::page()->registerStylesheet($stylesheetPath);
31 $words = DI::config()->get('pageheader','text');
35 $t = Renderer::getMarkupTemplate('admin.tpl', __DIR__);
36 $s .= Renderer::replaceMacros($t, [
37 '$title' => DI::l10n()->t('"pageheader" Settings'),
38 '$phwords' => ['pageheader-words', DI::l10n()->t('Message'), $words, DI::l10n()->t('Message to display on every page on this server (or put a pageheader.html file in your docroot)')],
39 '$submit' => DI::l10n()->t('Save Settings')
45 function pageheader_addon_admin_post(App $a)
47 if(!is_site_admin()) {
51 if(!empty($_POST['pageheader-submit'])) {
52 if (isset($_POST['pageheader-words'])) {
53 DI::config()->set('pageheader', 'text', trim(strip_tags($_POST['pageheader-words'])));
55 info(DI::l10n()->t('pageheader Settings saved.'));
59 function pageheader_fetch(App $a, &$b)
61 if(file_exists('pageheader.html')){
62 $s = file_get_contents('pageheader.html');
64 $s = DI::config()->get('pageheader', 'text');
67 $stylesheetPath = __DIR__ .'/pageheader.css';
68 DI::page()->registerStylesheet($stylesheetPath);
71 $b .= '<div class="pageheader">' . $s . '</div>';