aboutsummaryrefslogtreecommitdiff
path: root/views/default/layout/shells/content/header.php
blob: 768f26337d3b0eb33cd7059f654d9ee33a40d35b (plain)
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
<?php
/**
 * Main content header
 *
 * This includes a title and a new content button by default
 *
 * @uses $vars['header_override'] HTML for overriding the default header (override)
 * @uses $vars['title']           Title text (override)
 * @uses $vars['context']         Page context (override)
 * @uses $vars['buttons']         Content header buttons (override)
 */

if (isset($vars['header_override'])) {
	echo $vars['header_override'];
	return true;
}

$context = elgg_get_array_value('context', $vars, elgg_get_context());
if ($context) {
	$title = elgg_get_array_value('title', $vars, '');
	if (!$title) {
		$title = elgg_echo($context);
	}

	if (isset($vars['buttons'])) {
		$buttons = $vars['buttons'];
	} else {
		if (isloggedin() && $context) {
			$username = get_loggedin_user()->username;
			$new_link = elgg_get_array_value('new_link', $vars, "pg/$context/new/$username/");
			$params = array(
				'href' => $new_link = elgg_normalize_url($new_link),
				'text' => elgg_echo("$context:new"),
				'class' => 'elgg-action-button',
			);
			$buttons = elgg_view('output/url', $params);
		}
	}
	echo <<<HTML
<div class="elgg-header clearfix">
	<h2>$title</h2>$buttons
</div>
HTML;
}