From ee47fbf70fc7f67efde6926237e13fc20a664a72 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 19 Mar 2011 14:58:46 +0000 Subject: Refs #3158 namespace file plugin's page scripts git-svn-id: http://code.elgg.org/elgg/trunk@8766 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/file/pages/file/edit.php | 41 ++++++++++++++++++ mod/file/pages/file/friends.php | 32 ++++++++++++++ mod/file/pages/file/index.php | 69 ++++++++++++++++++++++++++++++ mod/file/pages/file/search.php | 95 +++++++++++++++++++++++++++++++++++++++++ mod/file/pages/file/upload.php | 38 +++++++++++++++++ mod/file/pages/file/view.php | 35 +++++++++++++++ mod/file/pages/file/world.php | 32 ++++++++++++++ 7 files changed, 342 insertions(+) create mode 100644 mod/file/pages/file/edit.php create mode 100644 mod/file/pages/file/friends.php create mode 100644 mod/file/pages/file/index.php create mode 100644 mod/file/pages/file/search.php create mode 100644 mod/file/pages/file/upload.php create mode 100644 mod/file/pages/file/view.php create mode 100644 mod/file/pages/file/world.php (limited to 'mod/file/pages') diff --git a/mod/file/pages/file/edit.php b/mod/file/pages/file/edit.php new file mode 100644 index 000000000..66529af0b --- /dev/null +++ b/mod/file/pages/file/edit.php @@ -0,0 +1,41 @@ +canEdit()) { + forward(); +} + +$title = elgg_echo('file:edit'); + +elgg_push_breadcrumb(elgg_echo('file'), "file/all"); +elgg_push_breadcrumb($file->title, $file->getURL()); +elgg_push_breadcrumb($title); + +elgg_set_page_owner_guid($file->getContainerGUID()); + +$form_vars = array('enctype' => 'multipart/form-data'); +$body_vars = file_prepare_form_vars($file); + +$content = elgg_view_form('file/upload', $form_vars, $body_vars); + +$body = elgg_view_layout('content', array( + 'content' => $content, + 'title' => $title, + 'filter' => '', + 'buttons' => '', +)); + +echo elgg_view_page($title, $body); diff --git a/mod/file/pages/file/friends.php b/mod/file/pages/file/friends.php new file mode 100644 index 000000000..65fc66f62 --- /dev/null +++ b/mod/file/pages/file/friends.php @@ -0,0 +1,32 @@ +name, "file/owner/$owner->username"); +elgg_push_breadcrumb(elgg_echo('friends')); + + +$title = elgg_echo("file:friends", array($owner->name)); + +// offset is grabbed in list_user_friends_objects +$content = list_user_friends_objects($owner->guid, 'file', 10, false); +if (!$content) { + $content = elgg_echo("file:none"); +} + +$sidebar = file_get_type_cloud($owner->guid, true); + +$body = elgg_view_layout('content', array( + 'filter_context' => 'friends', + 'content' => $content, + 'title' => $title, + 'sidebar' => $sidebar, +)); + +echo elgg_view_page($title, $body); diff --git a/mod/file/pages/file/index.php b/mod/file/pages/file/index.php new file mode 100644 index 000000000..617e4c7f4 --- /dev/null +++ b/mod/file/pages/file/index.php @@ -0,0 +1,69 @@ +name); + +$params = array(); + +if ($owner->guid == elgg_get_logged_in_user_guid()) { + // user looking at own files + $title = elgg_echo('file:yours'); + $params['filter_context'] = 'mine'; +} else if (elgg_instanceof($owner, 'user')) { + // someone else's files + $title = elgg_echo("file:user", array($owner->name)); + // do not show button or select a tab when viewing someone else's posts + $params['filter_context'] = 'none'; + $params['buttons'] = ''; +} else { + // group files + $title = elgg_echo("file:user", array($owner->name)); + $params['filter'] = ''; + if ($owner->isMember(elgg_get_logged_in_user_entity())) { + $url = "file/add/$owner->guid"; + $vars = array( + 'href' => $url, + 'text' => elgg_echo("file:add"), + 'class' => 'elgg-button elgg-button-action', + ); + $button = elgg_view('output/url', $vars); + $params['buttons'] = $button; + } else { + $params['buttons'] = ''; + } +} + +// List files +$content = elgg_list_entities(array( + 'types' => 'object', + 'subtypes' => 'file', + 'container_guid' => $owner->guid, + 'limit' => 10, + 'full_view' => FALSE, +)); +if (!$content) { + $content = elgg_echo("file:none"); +} + +$sidebar = file_get_type_cloud(elgg_get_page_owner_guid()); +if (elgg_instanceof($owner, 'user')) { + $sidebar .= elgg_view_latest_comments(elgg_get_page_owner_guid(), 'object', 'file'); +} + +$params['content'] = $content; +$params['title'] = $title; +$params['sidebar'] = $sidebar; + +$body = elgg_view_layout('content', $params); + +echo elgg_view_page($title, $body); diff --git a/mod/file/pages/file/search.php b/mod/file/pages/file/search.php new file mode 100644 index 000000000..2fa1ea60f --- /dev/null +++ b/mod/file/pages/file/search.php @@ -0,0 +1,95 @@ +name, "file/owner/$owner->username"); + } else { + elgg_push_breadcrumb($owner->name, "file/group/$owner->guid/owner"); + } +} +if ($friends && $owner) { + elgg_push_breadcrumb(elgg_echo('friends'), "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); \ No newline at end of file diff --git a/mod/file/pages/file/upload.php b/mod/file/pages/file/upload.php new file mode 100644 index 000000000..c19522530 --- /dev/null +++ b/mod/file/pages/file/upload.php @@ -0,0 +1,38 @@ +name, "file/owner/$owner->username"); +} else { + elgg_push_breadcrumb($owner->name, "file/group/$owner->guid/owner"); +} +elgg_push_breadcrumb($title); + +// create form +$form_vars = array('enctype' => 'multipart/form-data'); +$body_vars = file_prepare_form_vars(); +$content = elgg_view_form('file/upload', $form_vars, $body_vars); + +$body = elgg_view_layout('content', array( + 'content' => $content, + 'title' => $title, + 'filter' => '', + 'buttons' => '', +)); + +echo elgg_view_page($title, $body); diff --git a/mod/file/pages/file/view.php b/mod/file/pages/file/view.php new file mode 100644 index 000000000..1d7c27337 --- /dev/null +++ b/mod/file/pages/file/view.php @@ -0,0 +1,35 @@ +name; +if (elgg_instanceof($owner, 'group')) { + elgg_push_breadcrumb($crumbs_title, "file/group/$owner->guid/owner"); +} else { + elgg_push_breadcrumb($crumbs_title, "file/owner/$owner->username"); +} + +$title = $file->title; + +elgg_push_breadcrumb($title); + +$content = elgg_view_entity($file, true); +$content .= elgg_view_comments($file); + +$body = elgg_view_layout('content', array( + 'content' => $content, + 'title' => $title, + 'filter' => '', + 'header' => '', +)); + +echo elgg_view_page($title, $body); diff --git a/mod/file/pages/file/world.php b/mod/file/pages/file/world.php new file mode 100644 index 000000000..a55dcb452 --- /dev/null +++ b/mod/file/pages/file/world.php @@ -0,0 +1,32 @@ + 'object', + 'subtypes' => 'file', + 'limit' => $limit, + 'full_view' => FALSE +)); +elgg_pop_context(); + +$sidebar = file_get_type_cloud(); + +$body = elgg_view_layout('content', array( + 'filter_context' => 'all', + 'content' => $content, + 'title' => $title, + 'sidebar' => $sidebar, +)); + +echo elgg_view_page($title, $body); -- cgit v1.2.3