aboutsummaryrefslogtreecommitdiff
path: root/mod/file/search.php
blob: 157b5b8b81eedfcdded6a3543b58af91676d97f8 (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
<?php
/**
 * List files by type
 *
 * @package ElggFile

 */
// Load Elgg engine
require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");

$page_owner_guid = get_input('page_owner', null);
if ($page_owner_guid) {
	elgg_set_page_owner_guid($page_owner_guid);
}
$owner = elgg_get_page_owner();

group_gatekeeper();

// Get input
$md_type = 'simpletype';
$tag = get_input('tag');
$listtype = get_input('listtype');
$friends = get_input('friends', false);


// breadcrumbs
elgg_push_breadcrumb(elgg_echo('file'), "pg/file/all/");
if ($owner) {
	if (elgg_instanceof($owner, 'user')) {
		elgg_push_breadcrumb($owner->name, "pg/file/owner/$owner->username");
	} else {
		elgg_push_breadcrumb($owner->name, "pg/file/group/$owner->guid/owner");
	}
}
if ($friends && $owner) {
	elgg_push_breadcrumb(elgg_echo('friends'), "pg/file/friends/$owner->username");
}
if ($tag) {
	elgg_push_breadcrumb(elgg_echo("file:type:$tag"));
} else {
	elgg_push_breadcrumb(elgg_echo('all'));
}

// title
if (!$owner) {
	// world files
	$title = elgg_echo('all') . ' ' . elgg_echo("file:type:$tag");
} else {
	$friend_string = $friends ? elgg_echo('file:title:friends') : '';
	$type_string = elgg_echo("file:type:$tag");
	$title = elgg_echo('file:list:title', array($owner->name, $friend_string, $type_string));
}


$sidebar = file_get_type_cloud($page_owner_guid, $friends);

if ($friends) {
	// elgg_does not support getting objects that belong to an entity's friends
	$friend_entities = get_user_friends($page_owner_guid, "", 999999, 0);
	if ($friend_entities) {
		$friend_guids = array();
		foreach ($friend_entities as $friend) {
			$friend_guids[] = $friend->getGUID();
		}
	}
	$page_owner_guid = $friend_guids;
}

$limit = 10;
if ($listtype == "gallery") {
	$limit = 12;
}

$params = array(
	'types' => 'object',
	'subtypes' => 'file',
	'container_guid' => $page_owner_guid,
	'limit' => $limit,
	'full_view' => false,
);

if ($tag) {
	$params['metadata_name'] = $md_type;
	$params['metadata_value'] = $tag;
	$content = elgg_list_entities_from_metadata($params);
} else {
	$content = elgg_list_entities($params);
}

$body = elgg_view_layout('content', array(
	'filter' => '',
	'buttons' => '',
	'content' => $content,
	'title' => $title,
	'sidebar' => $sidebar,
));

echo elgg_view_page($title, $body);