aboutsummaryrefslogtreecommitdiff
path: root/views/default/page/layouts/content/header.php
blob: c5f78bd06e49a4609e5dd30b4fb10090581b334a (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
45
46
47
48
49
50
51
<?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_extract('context', $vars, elgg_get_context());
if ($context) {
	$title = elgg_extract('title', $vars, '');
	if (!$title) {
		$title = elgg_echo($context);
	}

	if (isset($vars['buttons'])) {
		$buttons = $vars['buttons'];
	} else {
		if (elgg_is_logged_in() && $context) {
			$owner = elgg_get_page_owner_entity();
			if (elgg_instanceof($owner, 'group')) {
				$guid = $owner->getGUID();
			} else {
				$guid = elgg_get_logged_in_user_guid();
			}
			
			elgg_register_menu_item('title', array(
				'name' => 'add',
				'href' => elgg_extract('new_link', $vars, "pg/$context/add/$guid"),
				'text' => elgg_echo("$context:add"),
				'class' => 'elgg-button elgg-button-action',
			));
		}
		
		$buttons = elgg_view_menu('title', array('sort_by' => 'weight'));
	}
	echo <<<HTML
<div class="elgg-head clearfix">
	<h2 class="elgg-heading-main">$title</h2>$buttons
</div>
HTML;
}