aboutsummaryrefslogtreecommitdiff
path: root/views/default/page_elements/owner_block.php
blob: 649591058dd743cb00b9651cbd78fc3893b3d43d (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
<?php
/**
 * Elgg owner block
 * Displays page ownership information
 *
 * @package Elgg
 * @subpackage Core
 *
 */

$contents = "";

// Are there feeds to display?
global $autofeed;
if (isset($autofeed) && $autofeed == true) {
	$url = full_url();
	if (substr_count($url,'?')) {
		$url .= "&view=rss";
	} else {
		$url .= "?view=rss";
	}
	$url = elgg_format_url($url);
	$label = elgg_echo('feed:rss');
	$contents .= <<<END
	<div class="rss_link clearfloat"><a href="{$url}" rel="nofollow" title="{$label}">{$label}</a></div>
END;
}

if(is_plugin_enabled('profile')) {
	// Is there a page owner?
	$owner = page_owner_entity();
	if ($owner instanceof ElggGroup ||
		($owner instanceof ElggUser && $owner->getGUID() != get_loggedin_userid())
	) {
		$icon = elgg_view('profile/icon', array('entity' => $owner, 'size' => 'tiny'));
		$owner_url = $owner->getURL();
		$display = "<div class='owner_block_icon'>$icon</div>";
		$display .= '<div class="owner_block_contents clearfloat">';
		$display .= "<h3><a href=\"$owner_url\">{$owner->name}</a></h3>";

		if ($owner->briefdescription) {
			$display .= "<p class=\"profile_info briefdescription\">{$owner->briefdescription}</p>";
		}
		
		$location = elgg_view('output/tags', array('value' => $owner->location));
		$display .= "<p class=\"profile_info location\">$location</p>";
		
		$display .= '</div>';
		
		// Trigger owner block menu
		$params = array('owner' => $owner);
		$links = trigger_plugin_hook('profile_menu', 'profile', $params, array());
		if (is_array($links) && !empty($links)) {
			// sort the links by name
			usort($links, create_function(
				'$a, $b',
				'return strnatcasecmp($a[\'text\'], $b[\'text\']);'
			));
			
			$display .= '<div class="owners_content_links"><ul>';
			foreach ($links as $link) {
				$display .= "<li><a href=\"{$link['href']}\">{$link['text']}</a></li>";
			}
			$display .= '</ul></div>';
		}
		
		// Allow plugins to extend the owner block contents
		$display .= elgg_view('owner_block/profile_extend');

		$contents .= "<div id='owner_block' class='clearfloat'>$display</div>";
	}
}

$contents .= elgg_view('owner_block/extend');


echo $contents;