diff options
Diffstat (limited to 'mod/file/search.php')
-rw-r--r-- | mod/file/search.php | 124 |
1 files changed, 61 insertions, 63 deletions
diff --git a/mod/file/search.php b/mod/file/search.php index 0e541c276..157b5b8b8 100644 --- a/mod/file/search.php +++ b/mod/file/search.php @@ -8,93 +8,91 @@ // 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); -$friends = (int) get_input('friends_guid', 0); -if ($friends) { - if ($owner_guid = get_user_friends($user_guid, "", 999999, 0)) { - foreach ($owner_guid as $key => $friend) - $owner_guid[$key] = (int) $friend->getGUID(); + +// 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 { - $owner_guid = array(); - } -} else { - $owner_guid = get_input('owner_guid', 0); - if (substr_count($owner_guid, ',')) { - $owner_guid = explode(",", $owner_guid); + elgg_push_breadcrumb($owner->name, "pg/file/group/$owner->guid/owner"); } } -$page_owner = get_input('page_owner', 0); -if ($page_owner) { - set_page_owner($page_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 { - if ($friends) { - set_page_owner($friends); - } else { - if ($owner_guid > 0 && !is_array($owner_guid)) - set_page_owner($owner_guid); - } + elgg_push_breadcrumb(elgg_echo('all')); } -if (is_callable('group_gatekeeper')) - group_gatekeeper(); - -if (empty($tag)) { - $title = elgg_echo('file:type:all'); - $area2 = elgg_view_title(elgg_echo('file:type:all')); - $area2 = elgg_view('page/elements/content_header', array('context' => "everyone", 'type' => 'file')); +// title +if (!$owner) { + // world files + $title = elgg_echo('all') . ' ' . elgg_echo("file:type:$tag"); } else { - $title = elgg_echo('searchtitle', array($tag)); - if (is_array($owner_guid)) { - //$area2 = elgg_view_title(elgg_echo("file:friends:type:" . $tag)); - $area2 = elgg_view('page/elements/content_header', array('context' => "friends", 'type' => 'file')); - } else if (elgg_get_page_owner_guid() && elgg_get_page_owner_guid() != get_loggedin_userid()) { - //$area2 = elgg_view_title(elgg_echo("file:user:type:" . $tag,array(elgg_get_page_owner()->name))); - $area2 = elgg_view('page/elements/content_header', array('context' => "mine", 'type' => 'file')); - } else { - //$area2 = elgg_view_title(elgg_echo("file:type:" . $tag)); - $area2 = elgg_view('page/elements/content_header', array('context' => "everyone", 'type' => 'file')); - } + $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) { - $area1 = get_filetype_cloud($friends, true); -} else if ($owner_guid) { - $area1 = get_filetype_cloud($owner_guid); -} else { - $area1 = get_filetype_cloud(); + // 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; } -elgg_push_context('search'); - -$offset = (int) get_input('offset', 0); $limit = 10; - if ($listtype == "gallery") { $limit = 12; } -if (!empty($tag)) { - $params = array( - 'metadata_name' => $md_type, - 'metadata_value' => $tag, - 'types' => 'object', - 'subtypes' => 'file', - 'owner_guid' => $owner_guid, - 'limit' => $limit, - ); - $area2 .= elgg_list_entities_from_metadata($params); +$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 { - $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'owner_guid' => $owner_guid, 'limit' => $limit, 'offset' => $offset)); + $content = elgg_list_entities($params); } -elgg_pop_context(); - -$content = "<div class='files'>" . $area1 . $area2 . "</div>"; - -$body = elgg_view_layout('one_column_with_sidebar', array('content' => $content)); +$body = elgg_view_layout('content', array( + 'filter' => '', + 'buttons' => '', + 'content' => $content, + 'title' => $title, + 'sidebar' => $sidebar, +)); echo elgg_view_page($title, $body);
\ No newline at end of file |