File: hook_htmlinject.php

package info (click to toggle)
simplesamlphp 1.19.7-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 42,920 kB
  • sloc: php: 202,044; javascript: 14,867; xml: 2,700; sh: 225; perl: 82; makefile: 70; python: 5
file content (48 lines) | stat: -rw-r--r-- 1,432 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

/**
 * Hook to inject HTML content into all pages...
 *
 * @param array &$hookinfo  hookinfo
 * @return void
 */
function portal_hook_htmlinject(&$hookinfo)
{
    assert(is_array($hookinfo));
    assert(array_key_exists('pre', $hookinfo));
    assert(array_key_exists('post', $hookinfo));
    assert(array_key_exists('page', $hookinfo));

    $links = ['links' => []];
    \SimpleSAML\Module::callHooks('frontpage', $links);

    assert(is_array($links));

    $portalConfig = \SimpleSAML\Configuration::getOptionalConfig('module_portal.php');

    $allLinks = [];
    foreach ($links as $ls) {
        $allLinks = array_merge($allLinks, $ls);
    }

    $pagesets = $portalConfig->getValue('pagesets', [
        ['frontpage_welcome', 'frontpage_config', 'frontpage_auth', 'frontpage_federation'],
    ]);
    \SimpleSAML\Module::callHooks('portalextras', $pagesets);
    $portal = new \SimpleSAML\Module\portal\Portal($allLinks, $pagesets);

    if (!$portal->isPortalized($hookinfo['page'])) {
        return;
    }

    // Include jquery UI CSS files in header
    $hookinfo['jquery']['css'] = true;

    // Header
    $hookinfo['pre'][] = '<div id="portalmenu" class="ui-tabs ui-widget ui-widget-content ui-corner-all">' .
        $portal->getMenu($hookinfo['page']) .
        '<div id="portalcontent" class="ui-tabs-panel ui-widget-content ui-corner-bottom">';

    // Footer
    $hookinfo['post'][] = '</div></div>';
}