aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/pages/actions/pages/editwelcome.php55
-rw-r--r--mod/pages/edit.php39
-rw-r--r--mod/pages/friends.php34
-rw-r--r--mod/pages/history.php42
-rw-r--r--mod/pages/index.php51
-rw-r--r--mod/pages/languages/en.php19
-rw-r--r--mod/pages/lib/pages.php41
-rw-r--r--mod/pages/new.php49
-rw-r--r--mod/pages/start.php231
-rw-r--r--mod/pages/view.php73
-rw-r--r--mod/pages/views/default/forms/pages/editwelcome.php56
-rw-r--r--mod/pages/views/default/object/page_top.php83
-rw-r--r--mod/pages/views/default/pages/breadcrumbs.php30
-rw-r--r--mod/pages/views/default/pages/welcome.php16
-rw-r--r--mod/pages/welcome.php39
-rw-r--r--mod/pages/world.php52
16 files changed, 394 insertions, 516 deletions
diff --git a/mod/pages/actions/pages/editwelcome.php b/mod/pages/actions/pages/editwelcome.php
deleted file mode 100644
index a13ae4c35..000000000
--- a/mod/pages/actions/pages/editwelcome.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/**
- * Elgg Pages Edit welcome message
- *
- * @package ElggPages
- */
-
-global $CONFIG;
-
-// Get group fields
-$message = get_input("pages_welcome");
-$container_guid = get_input("owner_guid");
-$object_guid = get_input("object_guid");
-$access_id = (int) get_input("access_id");
-
-//check to see if this is an edit or new welcome message
-if($object_guid){
-
- //it is an edit so grab the object
- $welcome = get_entity($object_guid);
- if ($welcome->getSubtype() == "pages_welcome" && $welcome->canEdit()) {
-
- $welcome->description = $message;
- $welcome->access_id = $access_id;
- $welcome->save();
- system_message(elgg_echo("pages:welcomeposted"));
-
- } else {
- register_error(elgg_echo("pages:welcomeerror"));
- }
-} else {
- //it is a new welcome object
- if ($container_guid) {
- $welcome = new ElggObject();
- // Tell the system it's a pages welcome message
- $welcome->subtype = "pages_welcome";
- $welcome->title = "Welcome";
- $welcome->description = $message;
- $welcome->access_id = $access_id;
-
- // Set the owner
- $welcome->container_guid = $container_guid;
-
- // save
- if (!$welcome->save()){
- register_error(elgg_echo("pages:welcomeerror"));
- } else {
- system_message(elgg_echo("pages:welcomeposted"));
- }
- } else {
- register_error(elgg_echo("pages:welcomeerror"));
- }
-}
-
-forward("pg/pages/owned/" . get_entity($container_guid)->username); \ No newline at end of file
diff --git a/mod/pages/edit.php b/mod/pages/edit.php
index dc290ea7d..23b6cc168 100644
--- a/mod/pages/edit.php
+++ b/mod/pages/edit.php
@@ -1,36 +1,41 @@
<?php
/**
- * Edit a page form
+ * Edit a page
*
* @package ElggPages
*/
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
gatekeeper();
-$page_guid = get_input('page_guid');
-$pages = get_entity($page_guid);
+$page_guid = get_input('guid');
+$page = get_entity($page_guid);
+if (!$page) {
-// Get the current page's owner
-if ($container = $pages->container_guid) {
- set_page_owner($container);
}
-$page_owner = elgg_get_page_owner();
+$container = $page->getContainerEntity();
+if (!$container) {
-if ($page_owner === false || is_null($page_owner)) {
- $page_owner = get_loggedin_user();
- set_page_owner($page_owner->getGUID());
}
+elgg_set_page_owner_guid($container->getGUID());
+
+elgg_push_breadcrumb($page->title, $page->getURL());
+elgg_push_breadcrumb(elgg_echo('edit'));
+
$title = elgg_echo("pages:edit");
-$body = elgg_view_title($title);
-if ($pages && ($pages->canEdit())) {
- $body .= elgg_view("forms/pages/edit", array('entity' => $pages));
+if ($page->canEdit()) {
+ $content = elgg_view("forms/pages/edit", array('entity' => $page));
} else {
- $body .= elgg_echo("pages:noaccess");
+ $content = elgg_echo("pages:noaccess");
}
-$body = elgg_view_layout('one_column_with_sidebar', array('content' => $body));
+$body = elgg_view_layout('content', array(
+ 'filter' => '',
+ 'buttons' => '',
+ 'content' => $content,
+ 'title' => $title,
+));
-echo elgg_view_page($title, $body); \ No newline at end of file
+echo elgg_view_page($title, $body);
diff --git a/mod/pages/friends.php b/mod/pages/friends.php
new file mode 100644
index 000000000..fd2e01833
--- /dev/null
+++ b/mod/pages/friends.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Elgg Pages list
+ *
+ * @package ElggPages
+ */
+
+$guid = get_input('guid');
+
+elgg_set_page_owner_guid($guid);
+$owner = elgg_get_page_owner();
+if (!$owner) {
+
+}
+
+elgg_push_breadcrumb($owner->name, "pg/pages/owner/$owner->username");
+elgg_push_breadcrumb(elgg_echo('friends'));
+
+$title = elgg_echo('pages:friends');
+
+$content = list_user_friends_objects($owner->guid, 'page_top', 10, false);
+if (!$content) {
+ $content = elgg_echo('pages:none');
+}
+
+$params = array(
+ 'filter_context' => 'friends',
+ 'content' => $content,
+ 'title' => $title,
+);
+
+$body = elgg_view_layout('content', $params);
+
+echo elgg_view_page($title, $body);
diff --git a/mod/pages/history.php b/mod/pages/history.php
index d40dfaeb8..7a13ae484 100644
--- a/mod/pages/history.php
+++ b/mod/pages/history.php
@@ -5,40 +5,36 @@
* @package ElggPages
*/
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-gatekeeper();
+$page_guid = get_input('guid');
-$page_guid = get_input('page_guid');
+$page = get_entity($page_guid);
+if (!$page) {
-$pages = get_entity($page_guid);
-if ($pages->container_guid) {
- set_page_owner($pages->container_guid);
-} else {
- set_page_owner($pages->owner_guid);
}
-if (is_callable('group_gatekeeper')) group_gatekeeper();
+$container = $page->getContainerEntity();
+if (!$container) {
-$limit = (int)get_input('limit', 20);
-$offset = (int)get_input('offset');
+}
+
+elgg_set_page_owner_guid($container->getGUID());
-$page_guid = get_input('page_guid');
-$pages = get_entity($page_guid);
+elgg_push_breadcrumb($page->title, $page->getURL());
+elgg_push_breadcrumb(elgg_echo('pages:history'));
-add_submenu_item(elgg_echo("pages:user", array(elgg_get_page_owner()->name)),
- "pg/pages/owned/" . elgg_get_page_owner()->username, 'pageslinksgeneral');
+$title = $page->title . ": " . elgg_echo('pages:history');
-$title = $pages->title . ": " . elgg_echo("pages:history");
-$content = elgg_view_title($title);
-$content.= list_annotations($page_guid, 'page', $limit, false);
+$content = list_annotations($page_guid, 'page', 20, false);
-pages_set_navigation_parent($pages);
+pages_set_navigation_parent($page);
$sidebar = elgg_view('pages/sidebar/tree');
-$params = array(
+$body = elgg_view_layout('content', array(
+ 'filter' => '',
+ 'buttons' => '',
'content' => $content,
- 'sidebar' => $sidebar
-);
-$body = elgg_view_layout('one_column_with_sidebar', $params);
+ 'title' => $title,
+ 'sidebar' => $sidebar,
+));
echo elgg_view_page($title, $body);
diff --git a/mod/pages/index.php b/mod/pages/index.php
index 1d84587d5..2da53ed7b 100644
--- a/mod/pages/index.php
+++ b/mod/pages/index.php
@@ -5,46 +5,39 @@
* @package ElggPages
*/
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+$guid = get_input('guid');
-global $CONFIG;
-
-// Add menus
+elgg_set_page_owner_guid($guid);
$owner = elgg_get_page_owner();
-if (!($owner instanceof ElggGroup)) {
- add_submenu_item(elgg_echo("pages:user", array(elgg_get_page_owner()->name)), "pg/pages/owned/" . elgg_get_page_owner()->username, 'pageslinksgeneral');
- add_submenu_item(elgg_echo('pages:all'), "mod/pages/world.php", 'pageslinksgeneral');
+if (!$owner) {
+
}
- if (($owner instanceof ElggEntity) && (can_write_to_container(0,$owner->guid))){
- add_submenu_item(elgg_echo('pages:new'), "pg/pages/new/?container_guid=" . elgg_get_page_owner_guid(), 'pagesactions');
- add_submenu_item(elgg_echo('pages:welcome'), "pg/pages/welcome/" . $owner->username, 'pagesactions');
- }
// access check for closed groups
group_gatekeeper();
-$limit = get_input("limit", 10);
-$offset = get_input("offset", 0);
+$title = elgg_echo('pages:owner', array($owner->name));
-if($owner instanceof ElggGroup){
- $title = elgg_echo("pages:group",array($owner->name));
-}else{
- $title = elgg_echo("pages:user",array($owner->name));
-}
+elgg_push_breadcrumb($title);
+$content = elgg_list_entities(array(
+ 'types' => 'object',
+ 'subtypes' => 'page_top',
+ 'container_guid' => elgg_get_page_owner_guid(),
+ 'limit' => $limit,
+ 'full_view' => false,
+));
-// Get objects
-elgg_push_context('search');
-$objects = elgg_list_entities(array('types' => 'object', 'subtypes' => 'page_top', 'container_guid' => elgg_get_page_owner_guid(), 'limit' => $limit, 'offset' => $offset, 'full_view' => FALSE));
-elgg_pop_context();
+$params = array(
+ 'filter_context' => 'mine',
+ 'content' => $content,
+ 'title' => $title,
+);
-//get the owners latest welcome message
-$welcome_message = elgg_get_entities(array('types' => 'object', 'subtypes' => 'pages_welcome', 'container_guid' => $owner->guid, 'limit' => 1));
+if (elgg_instanceof($owner, 'group')) {
+ $params['filter'] = '';
+}
-$body = elgg_view_title($title);
-$body .= elgg_view("pages/welcome", array('entity' => $welcome_message));
-$body .= $objects;
-$body = elgg_view_layout('one_column_with_sidebar', array('content' => $body));
+$body = elgg_view_layout('content', $params);
-// Finally draw the page
echo elgg_view_page($title, $body);
diff --git a/mod/pages/languages/en.php b/mod/pages/languages/en.php
index 478f8e5c3..eab972343 100644
--- a/mod/pages/languages/en.php
+++ b/mod/pages/languages/en.php
@@ -12,27 +12,26 @@ $english = array(
*/
'pages' => "Pages",
- 'pages:yours' => "Your pages",
- 'pages:user' => "Pages home",
- 'pages:group' => "Group pages",
+ 'pages:owner' => "%s's pages",
+ 'pages:friends' => "Friends' pages",
'pages:all' => "All site pages",
- 'pages:new' => "New page",
- 'pages:groupprofile' => "Group pages",
+ 'pages:add' => "New page",
+
+ 'pages:group' => "Group pages",
+ 'groups:enablepages' => 'Enable group pages',
+
'pages:edit' => "Edit this page",
'pages:delete' => "Delete this page",
'pages:history' => "Page history",
'pages:view' => "View page",
- 'pages:welcome' => "Edit welcome message",
- 'pages:welcomemessage' => "Welcome to the pages tool of %s. This tool allows you to create pages on any topic and select who can view them and edit them.",
- 'pages:welcomeerror' => "There was a problem saving your welcome message",
- 'pages:welcomeposted' => "Your welcome message has been posted",
+
'pages:navigation' => "Page navigation",
'pages:via' => "via pages",
'item:object:page_top' => 'Top-level pages',
'item:object:page' => 'Pages',
- 'item:object:pages_welcome' => 'Pages welcome blocks',
'pages:nogroup' => 'This group does not have any pages yet',
'pages:more' => 'More pages',
+ 'pages:none' => 'No pages created yet',
/**
* River
diff --git a/mod/pages/lib/pages.php b/mod/pages/lib/pages.php
new file mode 100644
index 000000000..943383fd7
--- /dev/null
+++ b/mod/pages/lib/pages.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Pages function library
+ */
+
+/**
+ * Prepare the add/edit form variables
+ *
+ * @param ElggOobject $page
+ * @return array
+ */
+function pages_prepare_form_vars($page = null) {
+
+ // input names => defaults
+ $values = array(
+ 'title' => '',
+ 'description' => '',
+ 'access_id' => ACCESS_DEFAULT,
+ 'write_access_id' => ACCESS_DEFAULT,
+ 'tags' => '',
+ 'container_guid' => elgg_get_page_owner_guid(),
+ 'guid' => null,
+ 'entity' => $page,
+ );
+
+ if ($page) {
+ foreach (array_keys($values) as $field) {
+ $values[$field] = $file->$field;
+ }
+ }
+
+ if (elgg_is_sticky_form('page')) {
+ foreach (array_keys($values) as $field) {
+ $values[$field] = elgg_get_sticky_value('page', $field);
+ }
+ }
+
+ elgg_clear_sticky_form('page');
+
+ return $values;
+}
diff --git a/mod/pages/new.php b/mod/pages/new.php
index 2175572b2..8a51d9f03 100644
--- a/mod/pages/new.php
+++ b/mod/pages/new.php
@@ -1,43 +1,36 @@
<?php
/**
- * Create a new Page
+ * Create a new page
*
* @package ElggPages
*/
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
gatekeeper();
-global $CONFIG;
-// Get the current page's owner
-if ($container = (int) get_input('container_guid')) {
- set_page_owner($container);
-}
-$page_owner = elgg_get_page_owner();
-if ($page_owner === false || is_null($page_owner)) {
- $page_owner = get_loggedin_user();
- set_page_owner($page_owner->getGUID());
+$container_guid = get_input('guid');
+
+$container = get_entity($container_guid);
+if (!$container) {
+
}
-//if it is a sub page, provide a link back to parent
-if(get_input('parent_guid')){
- $parent = get_entity(get_input('parent_guid'));
+$page_owner = $container;
+if (elgg_instanceof($container, 'object')) {
+ $page_owner = $container->getContainerEntity();
+}
- // Breadcrumbs
- $area2 .= elgg_view('pages/breadcrumbs', array('page_owner' => $page_owner, 'parent' => $parent, 'add' => true));
- }
+elgg_set_page_owner_guid($page_owner->getGUID);
- global $CONFIG;
-add_submenu_item(elgg_echo("pages:user", array(elgg_get_page_owner()->name)), "pg/pages/owned/" . elgg_get_page_owner()->username, 'pageslinksgeneral');
+$title = elgg_echo('pages:add');
+elgg_push_breadcrumb($title);
-$title = elgg_echo("pages:new");
-$area2 .= elgg_view_title($title);
-$area2 .= elgg_view("forms/pages/edit");
+$content = elgg_view("forms/pages/edit");
-$params = array(
- 'content' => $area2,
- 'sidebar' => $area1
-);
-$body = elgg_view_layout('one_column_with_sidebar', $params);
+$body = elgg_view_layout('content', array(
+ 'filter' => '',
+ 'buttons' => '',
+ 'content' => $content,
+ 'title' => $title,
+));
-echo elgg_view_page($title, $body); \ No newline at end of file
+echo elgg_view_page($title, $body);
diff --git a/mod/pages/start.php b/mod/pages/start.php
index 1c8290327..16b73cce6 100644
--- a/mod/pages/start.php
+++ b/mod/pages/start.php
@@ -5,54 +5,53 @@
* @package ElggPages
*/
+elgg_register_event_handler('init', 'system', 'pages_init');
+
/**
- * Initialise the pages plugin.
+ * Initialize the pages plugin.
*
*/
function pages_init() {
global $CONFIG;
- $item = new ElggMenuItem('pages', elgg_echo('pages'), 'mod/pages/world.php');
+ // register a library of helper functions
+ elgg_register_library('elgg:pages', elgg_get_plugin_path() . 'pages/lib/pages.php');
+
+ $item = new ElggMenuItem('pages', elgg_echo('pages'), 'pg/pages/all');
elgg_register_menu_item('site', $item);
// Register a page handler, so we can have nice URLs
- register_page_handler('pages','pages_page_handler');
+ register_page_handler('pages', 'pages_page_handler');
// Register a url handler
- register_entity_url_handler('pages_url','object', 'page_top');
- register_entity_url_handler('pages_url','object', 'page');
+ register_entity_url_handler('pages_url', 'object', 'page_top');
+ register_entity_url_handler('pages_url', 'object', 'page');
// Register some actions
- elgg_register_action("pages/edit", $CONFIG->pluginspath . "pages/actions/pages/edit.php");
- elgg_register_action("pages/editwelcome", $CONFIG->pluginspath . "pages/actions/pages/editwelcome.php");
- elgg_register_action("pages/delete", $CONFIG->pluginspath . "pages/actions/pages/delete.php");
+ $action_base = elgg_get_plugin_path() . 'pages/actions/pages';
+ elgg_register_action("pages/edit", "$action_base/edit.php");
+ elgg_register_action("pages/editwelcome", "$action_base/editwelcome.php");
+ elgg_register_action("pages/delete", "$action_base/delete.php");
// Extend some views
- elgg_extend_view('css/screen','pages/css');
- elgg_extend_view('groups/menu/links', 'pages/menu'); // Add to groups context
+ elgg_extend_view('css/screen', 'pages/css');
elgg_extend_view('groups/right_column', 'pages/groupprofile_pages'); // Add to groups context
- // Register entity type
- register_entity_type('object','page');
- register_entity_type('object','page_top');
+ // Register entity type for search
+ register_entity_type('object', 'page');
+ register_entity_type('object', 'page_top');
// Register granular notification for this type
- if (is_callable('register_notification_object')) {
- register_notification_object('object', 'page', elgg_echo('pages:new'));
- register_notification_object('object', 'page_top', elgg_echo('pages:new'));
- }
-
- // Listen to notification events and supply a more useful message
+ register_notification_object('object', 'page', elgg_echo('pages:new'));
+ register_notification_object('object', 'page_top', elgg_echo('pages:new'));
elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'page_notify_message');
- // add the group pages tool option
- add_group_tool_option('pages',elgg_echo('groups:enablepages'),true);
+ // add to groups
+ add_group_tool_option('pages', elgg_echo('groups:enablepages'), true);
+ elgg_extend_view('groups/tool_latest', 'pages/group_module');
//add a widget
- elgg_register_widget_type('pages',elgg_echo('pages'),elgg_echo('pages:widget:description'));
-
- // For now, we'll hard code the groups profile items as follows:
- // TODO make this user configurable
+ elgg_register_widget_type('pages', elgg_echo('pages'), elgg_echo('pages:widget:description'));
// Language short codes must be of the form "pages:key"
// where key is the array key below
@@ -66,14 +65,91 @@ function pages_init() {
elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'pages_owner_block_menu');
+ // write permission plugin hooks
+ elgg_register_plugin_hook_handler('permissions_check', 'object', 'pages_write_permission_check');
+ elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'pages_container_permission_check');
+
// register ecml views to parse
elgg_register_plugin_hook_handler('get_views', 'ecml', 'pages_ecml_views_hook');
}
-function pages_url($entity) {
+/**
+ * Dispatcher for pages.
+ * URLs take the form of
+ * All pages: pg/pages/all
+ * User's pages: pg/pages/owner/<username>
+ * Friends' pages: pg/pages/friends/<username>
+ * View page: pg/pages/view/<guid>/<title>
+ * New page: pg/pages/add/<guid> (container: user, group, parent)
+ * Edit page: pg/pages/edit/<guid>
+ * History of page: pg/pages/history/<guid>
+ * Group pages: pg/pages/group/<guid>/owner
+ *
+ * Title is ignored
+ *
+ * @param array $page
+ */
+function pages_page_handler($page) {
+
+ elgg_load_library('elgg:pages');
+
+ if (!isset($page[0])) {
+ $page[0] = 'all';
+ }
+
+ elgg_push_breadcrumb(elgg_echo('pages'), 'pg/pages/all');
+
+ $base_dir = elgg_get_plugin_path() . 'pages';
+
+ $page_type = $page[0];
+ switch ($page_type) {
+ case 'owner':
+ $owner = get_user_by_username($page[1]);
+ set_input('guid', $owner->guid);
+ include "$base_dir/index.php";
+ break;
+ case 'friends':
+ set_input('username', $page[1]);
+ include "$base_dir/friends.php";
+ break;
+ case 'view':
+ set_input('guid', $page[1]);
+ include "$base_dir/view.php";
+ break;
+ case 'add':
+ set_input('guid', $page[1]);
+ include "$base_dir/new.php";
+ break;
+ case 'edit':
+ set_input('guid', $page[1]);
+ include "$base_dir/edit.php";
+ break;
+ case 'group':
+ set_input('guid', $page[1]);
+ include "$base_dir/index.php";
+ break;
+ case 'history':
+ set_input('guid', $page[1]);
+ include "$base_dir/history.php";
+ break;
+ case 'all':
+ default:
+ include "$base_dir/world.php";
+ break;
+ }
+ return;
+}
+
+/**
+ * Override the page url
+ *
+ * @param ElggObject $entity Page object
+ * @return string
+ */
+function pages_url($entity) {
$title = elgg_get_friendly_title($entity->title);
- return "pg/pages/view/{$entity->guid}/$title";
+ return "pg/pages/view/$entity->guid/$title";
}
/**
@@ -86,7 +162,7 @@ function pages_owner_block_menu($hook, $type, $return, $params) {
$return[] = $item;
} else {
if ($params['entity']->pages_enable != "no") {
- $url = "pg/pages/owned/group:{$vars['entity']->guid}";
+ $url = "pg/pages/group/{$params['entity']->guid}/owner";
$item = new ElggMenuItem('pages', elgg_echo('pages:group'), $url);
$return[] = $item;
}
@@ -96,98 +172,6 @@ function pages_owner_block_menu($hook, $type, $return, $params) {
}
/**
- * Pages page handler.
- *
- * @param array $page
- */
-function pages_page_handler($page) {
- global $CONFIG;
-
- if (isset($page[0])) {
- // See what context we're using
- switch($page[0]) {
- case "new" :
- include($CONFIG->pluginspath . "pages/new.php");
- break;
-
- case "welcome" :
- if (isset($page[1])) {
- set_input('username', $page[1]);
- }
- include($CONFIG->pluginspath . "pages/welcome.php");
- break;
-
- case "world":
- include($CONFIG->pluginspath . "pages/world.php");
- break;
- case "owned" :
- // Owned by a user
- if (isset($page[1])) {
- set_input('username',$page[1]);
- }
-
- include($CONFIG->pluginspath . "pages/index.php");
- break;
-
- case "edit" :
- if (isset($page[1])) {
- set_input('page_guid', $page[1]);
- }
-
- $entity = get_entity($page[1]);
- add_submenu_item(elgg_echo('pages:label:view'), "pg/pages/view/{$page[1]}", 'pageslinks');
- // add_submenu_item(elgg_echo('pages:user'), elgg_get_site_url() . "pg/pages/owned/" . get_loggedin_user()->username, 'pageslinksgeneral');
- if (($entity) && ($entity->canEdit())) {
- add_submenu_item(elgg_echo('pages:label:edit'), "pg/pages/edit/{$page[1]}", 'pagesactions');
- }
- add_submenu_item(elgg_echo('pages:label:history'), "pg/pages/history/{$page[1]}", 'pageslinks');
-
- include($CONFIG->pluginspath . "pages/edit.php");
- break;
-
- case "view" :
- if (isset($page[1])) {
- set_input('page_guid', $page[1]);
- }
-
- elgg_extend_view('html_head/extend','pages/metatags');
-
- $entity = get_entity($page[1]);
- //add_submenu_item(elgg_echo('pages:label:view'), "pg/pages/view/{$page[1]}", 'pageslinks');
- if (($entity) && ($entity->canEdit())) {
- add_submenu_item(elgg_echo('pages:label:edit'), "pg/pages/edit/{$page[1]}", 'pagesactions');
- }
-
- add_submenu_item(elgg_echo('pages:label:history'), "pg/pages/history/{$page[1]}", 'pageslinks');
-
- include($CONFIG->pluginspath . "pages/view.php");
- break;
-
- case "history" :
- if (isset($page[1])) {
- set_input('page_guid', $page[1]);
- }
-
- elgg_extend_view('html_head/extend','pages/metatags');
-
- $entity = get_entity($page[1]);
- add_submenu_item(elgg_echo('pages:label:view'), "pg/pages/view/{$page[1]}", 'pageslinks');
- if (($entity) && ($entity->canEdit())) {
- add_submenu_item(elgg_echo('pages:label:edit'), "pg/pages/edit/{$page[1]}", 'pagesactions');
- }
- add_submenu_item(elgg_echo('pages:label:history'), "pg/pages/history/{$page[1]}", 'pageslinks');
-
- include($CONFIG->pluginspath . "pages/history.php");
- break;
-
- default:
- include($CONFIG->pluginspath . "pages/new.php");
- break;
- }
- }
-}
-
-/**
* Returns a more meaningful message
*
* @param unknown_type $hook
@@ -347,10 +331,3 @@ function pages_ecml_views_hook($hook, $entity_type, $return_value, $params) {
return $return_value;
}
-
-// write permission plugin hooks
-elgg_register_plugin_hook_handler('permissions_check', 'object', 'pages_write_permission_check');
-elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'pages_container_permission_check');
-
-// Make sure the pages initialisation function is called on initialisation
-elgg_register_event_handler('init','system','pages_init');
diff --git a/mod/pages/view.php b/mod/pages/view.php
index 6996c44e0..19f7c8227 100644
--- a/mod/pages/view.php
+++ b/mod/pages/view.php
@@ -5,59 +5,46 @@
* @package ElggPages
*/
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-$page_guid = get_input('page_guid');
-elgg_set_context('pages');
-
-if (is_callable('group_gatekeeper')) {
- group_gatekeeper();
-}
-
-$pages = get_entity($page_guid);
-if (!$pages) {
+$page_guid = get_input('guid');
+$page = get_entity($page_guid);
+if (!$page) {
forward();
}
-$container = $pages->container_guid;
+elgg_set_page_owner_guid($page->getContainerGUID());
-if ($container) {
- set_page_owner($container);
-} else {
- set_page_owner($pages->owner_guid);
-}
+group_gatekeeper();
-global $CONFIG;
-
-if ($pages->canEdit()) {
- add_submenu_item(elgg_echo('pages:newchild'), "pg/pages/new/?parent_guid={$pages->getGUID()}&container_guid=" . elgg_get_page_owner_guid(), 'pagesactions');
- $delete_url = elgg_add_action_tokens_to_url("action/pages/delete?page={$pages->getGUID()}");
- add_submenu_item(elgg_echo('pages:delete'), $delete_url, 'pagesactions', true);
-}
-
-//if the page has a parent, get it
-if ($parent_page = get_entity(get_input("page_guid"))) {
- $parent = $parent_page;
+$container = elgg_get_page_owner();
+if (!$container) {
}
-$title = $pages->title;
+$title = $page->title;
-// Breadcrumbs
-$body = elgg_view('pages/breadcrumbs', array('page_owner' => elgg_get_page_owner(), 'parent' => $parent));
+elgg_push_breadcrumb($container->name, $container->getURL());
+elgg_push_breadcrumb($title);
-$body .= elgg_view_title($pages->title);
-$body .= elgg_view_entity($pages, true);
+$content = elgg_view_entity($page, true);
+$content .= elgg_view_comments($page);
-//add comments
-$body .= elgg_view_comments($pages);
+$sidebar = elgg_view('pages/sidebar/tree', array('page' => $page));
-pages_set_navigation_parent($pages);
-$sidebar = elgg_view('pages/sidebar/tree');
+$buttons = '';
+if ($page->canEdit()) {
+ $url = "pg/pages/add/$page->guid";
+ $buttons = elgg_view('output/url', array(
+ 'text' => elgg_echo('pages:newchild'),
+ 'href' => $url,
+ 'class' => 'elgg-action-button',
+ ));
+}
-$params = array(
- 'content' => $body,
- 'sidebar' => $sidebar
-);
-$body = elgg_view_layout('one_column_with_sidebar', $params);
+$body = elgg_view_layout('content', array(
+ 'filter' => '',
+ 'buttons' => $buttons,
+ 'content' => $content,
+ 'title' => $title,
+ 'sidebar' => $sidebar,
+));
-echo elgg_view_page($title, $body); \ No newline at end of file
+echo elgg_view_page($title, $body);
diff --git a/mod/pages/views/default/forms/pages/editwelcome.php b/mod/pages/views/default/forms/pages/editwelcome.php
deleted file mode 100644
index a0ad3131b..000000000
--- a/mod/pages/views/default/forms/pages/editwelcome.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
- * Welcome page edit form
- *
- * @package ElggPages
- */
-
-//set some variables
-if($vars['entity']) {
- foreach($vars['entity'] as $welcome) {
- $current_message = $welcome->description;
- $object_guid = $welcome->guid;
- $access_id = $welcome->access_id;
- }
-} else {
- $current_message = '';
- $object_guid = '';
- $access_id = ACCESS_PUBLIC;
-}
-
-$page_owner = $vars['owner']->guid;
-
-?>
-<form action="<?php echo elgg_get_site_url(); ?>action/pages/editwelcome" method="post">
-
- <p class="longtext_inputarea">
- <label>
- <?php echo elgg_view("input/longtext",array(
- 'internalname' => "pages_welcome",
- 'value' => $current_message,
- 'disabled' => $disabled
- )); ?>
- </label>
-</p>
-<p>
- <label>
- <?php echo elgg_echo('access'); ?><br />
- <?php echo elgg_view('input/access', array('internalname' => 'access_id','value' => $access_id)); ?>
- </label>
-</p>
-<input type="hidden" name="owner_guid" value="<?php echo $page_owner; ?>" />
-
-<?php
- echo elgg_view('input/securitytoken');
-
- //if it is editing, include the object guid
- if ($object_guid != ''){
- ?>
- <input type="hidden" name="object_guid" value="<?php echo $object_guid; ?>" />
-<?php
- }
-
- echo elgg_view('input/submit', array('value' => elgg_echo('save')));
-?>
-
-</form>
diff --git a/mod/pages/views/default/object/page_top.php b/mod/pages/views/default/object/page_top.php
index 0a1cfdf83..d1a9ef7e8 100644
--- a/mod/pages/views/default/object/page_top.php
+++ b/mod/pages/views/default/object/page_top.php
@@ -5,12 +5,79 @@
* @package ElggPages
*/
-if ($vars['full']) {
- echo elgg_view("pages/pageprofile", $vars);
+
+$full = elgg_get_array_value('full', $vars, FALSE);
+$page = elgg_get_array_value('entity', $vars, FALSE);
+
+if (!$page) {
+ return TRUE;
+}
+
+$owner = $page->getOwnerEntity();
+$owner_icon = elgg_view('profile/icon', array('entity' => $owner, 'size' => 'tiny'));
+$owner_link = elgg_view('output/url', array(
+ 'href' => "pg/pages/owner/$owner->username",
+ 'text' => $owner->name,
+));
+$author_text = elgg_echo('blog:author_by_line', array($owner_link));
+$tags = elgg_view('output/tags', array('tags' => $page->tags));
+$date = elgg_view_friendly_time($page->time_created);
+$excerpt = elgg_get_excerpt($page->description);
+
+$comments_count = elgg_count_comments($page);
+//only display if there are commments
+if ($comments_count != 0) {
+ $text = elgg_echo("comments") . " ($comments_count)";
+ $comments_link = elgg_view('output/url', array(
+ 'href' => $page->getURL() . '#page-comments',
+ 'text' => $text,
+ ));
} else {
- if (get_input('listtype') == "gallery") {
- echo elgg_view('pages/pagegallery', $vars);
- } else {
- echo elgg_view("pages/pagelisting", $vars);
- }
-} \ No newline at end of file
+ $comments_link = '';
+}
+
+$metadata = elgg_view('layout/objects/list/metadata', array(
+ 'entity' => $page,
+ 'handler' => 'pages',
+));
+
+$subtitle = "$author_text $date $categories $comments_link";
+
+// do not show the metadata and controls in widget view
+if (elgg_in_context('widgets')) {
+ $metadata = '';
+}
+
+if ($full) {
+ $body = elgg_view('output/longtext', array('value' => $page->description));
+
+ $params = array(
+ 'entity' => $page,
+ 'title' => false,
+ 'metadata' => $metadata,
+ 'subtitle' => $subtitle,
+ 'tags' => $tags,
+ );
+ $list_body = elgg_view('layout/objects/list/body', $params);
+
+ $info = elgg_view_image_block($owner_icon, $list_body);
+
+ echo <<<HTML
+$info
+$body
+HTML;
+
+} else {
+ // brief view
+
+ $params = array(
+ 'entity' => $page,
+ 'metadata' => $metadata,
+ 'subtitle' => $subtitle,
+ 'tags' => $tags,
+ 'content' => $excerpt,
+ );
+ $list_body = elgg_view('layout/objects/list/body', $params);
+
+ echo elgg_view_image_block($owner_icon, $list_body);
+}
diff --git a/mod/pages/views/default/pages/breadcrumbs.php b/mod/pages/views/default/pages/breadcrumbs.php
deleted file mode 100644
index 9c95c64c2..000000000
--- a/mod/pages/views/default/pages/breadcrumbs.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/**
- * Breadcrumbs for pages.
- *
- * @package ElggPages
- */
-
-$page_owner = elgg_get_page_owner_guid();
-$parent = $vars['parent'];
-
-$breadcrumbs = '';
-
-$owner_url = elgg_get_site_url() . "pg/pages/owned/" . get_entity($page_owner)->username;
-echo "<div id='breadcrumbs'><b><a href=\"{$owner_url}\">" . elgg_echo('pages:user') . "</a></b>";
-
-//see if the new page's parent has a parent
-$getparent = get_entity($parent->parent_guid);
-while ($getparent instanceof ElggObject){
- $breadcrumbs = " &gt; <a href=\"{$getparent->getURL()}\">$getparent->title</a>" . $breadcrumbs;
- $getparent = get_entity($getparent->parent_guid);
-}
-
-echo $breadcrumbs;
-
-//if it is adding a page, make the last page a link, otherwise, don't
-if ($vars['add']){
- echo " &gt; <a href=\"{$parent->getURL()}\">$parent->title</a></div>";
-} else {
- echo " &gt; $parent->title</div>";
-} \ No newline at end of file
diff --git a/mod/pages/views/default/pages/welcome.php b/mod/pages/views/default/pages/welcome.php
deleted file mode 100644
index 7dbc6109a..000000000
--- a/mod/pages/views/default/pages/welcome.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-/**
- * Elgg Pages welcome message
- *
- * @package ElggPages
- */
-
-if($vars['entity']) {
- foreach($vars['entity'] as $welcome){
- echo "<div class=\"contentWrapper pageswelcome\">" . $welcome->description . "</div>";
- }
-} else {
-?>
-<div class="contentWrapper pageswelcome"><p><?php echo elgg_echo('pages:welcomemessage', array($vars['config']->sitename)); ?></p></div>
-<?php
-}
diff --git a/mod/pages/welcome.php b/mod/pages/welcome.php
deleted file mode 100644
index 7db649253..000000000
--- a/mod/pages/welcome.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
- * Elgg Pages welcome intro
- * The user or group owner can set an introduction to their wiki pages
- *
- * @package ElggPages
- */
-
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-gatekeeper();
-global $CONFIG;
-
-// Get the current page's owner
-if ($container = (int) get_input('container_guid')) {
- set_page_owner($container);
-}
-
-$page_owner = elgg_get_page_owner();
-if ($page_owner === false || is_null($page_owner)) {
- $page_owner = get_loggedin_user();
- set_page_owner($page_owner->getGUID());
-}
-
-//get the owners welcome message if it exists
-$welcome_message = elgg_get_entities(array('types' => 'object', 'subtypes' => 'pages_welcome', 'container_guid' => $page_owner->getGUID(), 'limit' => 1));
-global $CONFIG;
-add_submenu_item(elgg_echo("pages:user", array(elgg_get_page_owner()->name)), "pg/pages/owned/" . elgg_get_page_owner()->username, 'pageslinksgeneral');
-
-$title = elgg_echo("pages:welcome");
-$area2 .= elgg_view_title($title);
-$area2 .= elgg_view("forms/pages/editwelcome", array('entity' => $welcome_message, 'owner' => $page_owner));
-
-$params = array(
- 'content' => $area2,
- 'sidebar' => $area1
-);
-$body = elgg_view_layout('one_column_with_sidebar', $params);
-
-echo elgg_view_page($title, $body); \ No newline at end of file
diff --git a/mod/pages/world.php b/mod/pages/world.php
index d258ba157..e3b158c1e 100644
--- a/mod/pages/world.php
+++ b/mod/pages/world.php
@@ -1,44 +1,26 @@
<?php
/**
- * Elgg Pages
+ * All pages
*
* @package ElggPages
*/
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+$title = elgg_echo('pages:all');
-global $CONFIG;
-
-// Get the current page's owner
-$page_owner = elgg_get_page_owner();
-if ($page_owner === false || is_null($page_owner)) {
- $page_owner = get_loggedin_user();
- set_page_owner(get_loggedin_userid());
-}
-
-if (($page_owner instanceof ElggEntity) && ($page_owner->canWriteToContainer())){
- add_submenu_item(elgg_echo('pages:new'), "pg/pages/new/", 'pagesactions');
-}
-
-if(isloggedin()) {
- add_submenu_item(elgg_echo("pages:user", array(elgg_get_page_owner()->name)), "pg/pages/owned/" . elgg_get_page_owner()->username, 'pageslinksgeneral');
-}
-
-add_submenu_item(elgg_echo('pages:all'), "mod/pages/world.php", 'pageslinksgeneral');
-
-$limit = get_input("limit", 10);
-$offset = get_input("offset", 0);
-
-$title = elgg_echo("pages:all",array(elgg_get_page_owner()->name));
+elgg_pop_breadcrumb();
+elgg_push_breadcrumb(elgg_echo('pages'));
// Get objects
-elgg_push_context('search');
-$objects = elgg_list_entities(array('types' => 'object', 'subtypes' => 'page_top', 'limit' => $limit, 'offset' => $offset, 'full_view' => FALSE));
-elgg_pop_context();
-
-$body = elgg_view_title($title);
-$body .= $objects;
-$body = elgg_view_layout('one_column_with_sidebar', array('content' => $body));
-
-// Finally draw the page
-echo elgg_view_page($title, $body); \ No newline at end of file
+$content = elgg_list_entities(array(
+ 'types' => 'object',
+ 'subtypes' => 'page_top',
+ 'full_view' => false,
+));
+
+$body = elgg_view_layout('content', array(
+ 'filter_context' => 'all',
+ 'content' => $content,
+ 'title' => $title,
+));
+
+echo elgg_view_page($title, $body);