aboutsummaryrefslogtreecommitdiff
path: root/start.php
blob: b74541490a4084bfdfbe095f18b159abcf5bf687 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php

elgg_register_event_handler('init', 'system', 'saravea_theme_init');

function saravea_theme_init() {
	elgg_unregister_menu_item('topbar','elgg_logo');
	$item =  new ElggMenuItem('site_logo', elgg_get_site_entity()->name, elgg_get_site_url());
	elgg_register_menu_item('topbar', $item);
	elgg_register_plugin_hook_handler('register', 'menu:topbar', 'saravea_theme_topbar_menu');
	
	elgg_register_simplecache_view('saravea_theme/landing');
	elgg_register_css('n1:landing_page', elgg_get_simplecache_url('css', 'saravea_theme/landing'));
	
	elgg_extend_view('css/elgg', 'saravea_theme/css');
	elgg_extend_view('js/elgg', 'saravea_theme/js');
	elgg_extend_view('page/elements/title', 'saravea_theme/header', 0);
	// custom index widgets
	foreach(array("custom_index", "edit_widgets", "index_2rbhh", "index_2rhhb", 
		      "index",  "index_2rbms", "index_2rmsb",
		      "index_1rsss", "index_2rbsm", "index_2rsmb") as $layout) {
		elgg_extend_view('page/layouts/'.$layout, 'saravea_theme/landing', 0);
	}
	
	if (elgg_is_active_plugin('pages')) {
		// pages icon url override
		elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'saravea_theme_pages_icon_url_override');
	}
}

function saravea_theme_topbar_menu($hook, $type, $returnvalue, $params){
	$user = elgg_get_logged_in_user_entity();

	if (elgg_is_active_plugin('groups')) {

		$ia = elgg_set_ignore_access(TRUE);
		$num_invitations = elgg_get_entities_from_relationship(array(
			'relationship' => 'invited',
			'relationship_guid' => $user->guid,
			'inverse_relationship' => TRUE,
			'limit' => 0,
			'count' => TRUE,
		));
		elgg_set_ignore_access($ia);

		if ($num_invitations) {
			$num_invitations = elgg_view('output/url', array(
				'text' => "<span class=\"messages-new\">$num_invitations</span>",
				'href' => "groups/invitations/$user->username",
			));
		}

		$returnvalue[] = ElggMenuItem::factory(array(
			'name' => 'groups',
			'href' => "groups/member/$user->username",
			'text' => elgg_view_icon('groups') . $num_invitations,
			'title' => elgg_echo('groups'),
			'priority' => 500,
		));
	}

	if (elgg_is_admin_logged_in()) {
		$returnvalue[] = ElggMenuItem::factory(array(
			'name' => 'administration',
			'href' => "admin",
			'text' => elgg_view_icon('settings'),
			'title' => elgg_echo('admin'),
			'priority' => 100,
			'section' => 'alt',
		));
	}
	
	if (elgg_is_active_plugin('dashboard')) {
		$returnvalue[] = ElggMenuItem::factory(array(
			'name' => 'dashboard',
			'href' => "dashboard",
			'text' => elgg_view_icon('home'),
			'title' => elgg_echo('dashboard'),
			'priority' => 200,
			'section' => 'alt',
		));
	}

	$returnvalue[] = ElggMenuItem::factory(array(
		'name' => 'usersettings',
		'href' => "settings/user/{$user->username}",
		'text' => elgg_view_icon('settings-alt'),
		'title' => elgg_echo('settings'),
		'priority' => 500,
		'section' => 'alt',
	));

	$returnvalue[] = ElggMenuItem::factory(array(
		'name' => 'logout',
		'href' => "action/logout",
		'text' => elgg_echo('logout'),
		'title' => elgg_echo('logout'),
		'is_action' => TRUE,
		'priority' => 1000,
		'section' => 'alt',
	));
	return $returnvalue;
}

/**
 * Override the default entity icon for pages and pads
 *
 * @return string Relative URL
 */
function saravea_theme_pages_icon_url_override($hook, $type, $returnvalue, $params) {
	$entity = $params['entity'];
	if (elgg_instanceof($entity, 'object', 'page_top') ||
		elgg_instanceof($entity, 'object', 'page')) {
		$icon = 'pages';
	} elseif (elgg_instanceof($entity, 'object', 'etherpad') ||
			  elgg_instanceof($entity, 'object', 'subpad')) {
		$icon = 'pad';
	} else {
		return $returnvalue;
	}
	switch ($params['size']) {
		case 'topbar':
		case 'tiny':
			return "mod/saravea_theme/_graphics/icons/{$icon}_tiny.gif";
			break;
		case 'small':
			return "mod/saravea_theme/_graphics/icons/{$icon}_small.gif";
			break;
		default:
			return "mod/saravea_theme/_graphics/icons/{$icon}_lrg.gif";
			break;
	}
}