aboutsummaryrefslogtreecommitdiff
path: root/mod/pages
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-08-13 12:27:12 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-08-13 12:27:12 +0000
commit55724ff6f6818f2c1b16d4bacd912ae2eb745fdb (patch)
tree5365657ba47de2e891d84965a6ba2bb98d4783d8 /mod/pages
parenta6e012278e2a33721e91ae36a7fda65804785440 (diff)
downloadelgg-55724ff6f6818f2c1b16d4bacd912ae2eb745fdb.tar.gz
elgg-55724ff6f6818f2c1b16d4bacd912ae2eb745fdb.tar.bz2
Added a new latest activity title to the front page
git-svn-id: https://code.elgg.org/elgg/trunk@1895 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/pages')
-rw-r--r--mod/pages/actions/pages/delete.php35
-rw-r--r--mod/pages/actions/pages/edit.php114
-rw-r--r--mod/pages/actions/pages/editwelcome.php77
-rw-r--r--mod/pages/edit.php42
-rw-r--r--mod/pages/history.php50
-rw-r--r--mod/pages/images/application.pngbin0 -> 464 bytes
-rw-r--r--mod/pages/images/code.pngbin0 -> 603 bytes
-rw-r--r--mod/pages/images/css.pngbin0 -> 618 bytes
-rw-r--r--mod/pages/images/db.pngbin0 -> 579 bytes
-rw-r--r--mod/pages/images/directory.pngbin0 -> 537 bytes
-rw-r--r--mod/pages/images/doc.pngbin0 -> 651 bytes
-rw-r--r--mod/pages/images/file.gifbin0 -> 110 bytes
-rw-r--r--mod/pages/images/file.pngbin0 -> 294 bytes
-rw-r--r--mod/pages/images/film.pngbin0 -> 653 bytes
-rw-r--r--mod/pages/images/flash.pngbin0 -> 582 bytes
-rw-r--r--mod/pages/images/folder-closed.gifbin0 -> 105 bytes
-rw-r--r--mod/pages/images/folder.gifbin0 -> 106 bytes
-rw-r--r--mod/pages/images/folder_open.pngbin0 -> 583 bytes
-rw-r--r--mod/pages/images/html.pngbin0 -> 734 bytes
-rw-r--r--mod/pages/images/java.pngbin0 -> 633 bytes
-rw-r--r--mod/pages/images/linux.pngbin0 -> 668 bytes
-rw-r--r--mod/pages/images/minus.gifbin0 -> 837 bytes
-rw-r--r--mod/pages/images/music.pngbin0 -> 385 bytes
-rw-r--r--mod/pages/images/pdf.pngbin0 -> 591 bytes
-rw-r--r--mod/pages/images/php.pngbin0 -> 538 bytes
-rw-r--r--mod/pages/images/picture.pngbin0 -> 606 bytes
-rw-r--r--mod/pages/images/plus.gifbin0 -> 841 bytes
-rw-r--r--mod/pages/images/ppt.pngbin0 -> 588 bytes
-rw-r--r--mod/pages/images/psd.pngbin0 -> 856 bytes
-rw-r--r--mod/pages/images/ruby.pngbin0 -> 626 bytes
-rw-r--r--mod/pages/images/script.pngbin0 -> 859 bytes
-rw-r--r--mod/pages/images/spinner.gifbin0 -> 2530 bytes
-rw-r--r--mod/pages/images/treeview-black-line.gifbin0 -> 1877 bytes
-rw-r--r--mod/pages/images/treeview-black.gifbin0 -> 1216 bytes
-rw-r--r--mod/pages/images/treeview-default-line.gifbin0 -> 1993 bytes
-rw-r--r--mod/pages/images/treeview-default.gifbin0 -> 1222 bytes
-rw-r--r--mod/pages/images/treeview-famfamfam-line.gifbin0 -> 807 bytes
-rw-r--r--mod/pages/images/treeview-famfamfam.gifbin0 -> 1280 bytes
-rw-r--r--mod/pages/images/treeview-gray-line.gifbin0 -> 1877 bytes
-rw-r--r--mod/pages/images/treeview-gray.gifbin0 -> 1230 bytes
-rw-r--r--mod/pages/images/treeview-red-line.gifbin0 -> 1877 bytes
-rw-r--r--mod/pages/images/treeview-red.gifbin0 -> 1230 bytes
-rw-r--r--mod/pages/images/txt.pngbin0 -> 342 bytes
-rw-r--r--mod/pages/images/xls.pngbin0 -> 663 bytes
-rw-r--r--mod/pages/images/zip.pngbin0 -> 386 bytes
-rw-r--r--mod/pages/index.php55
-rw-r--r--mod/pages/javascript/jquery.treeview.async.js72
-rw-r--r--mod/pages/javascript/jquery.treeview.js251
-rw-r--r--mod/pages/languages/en.php89
-rw-r--r--mod/pages/manifest.xml9
-rw-r--r--mod/pages/new.php44
-rw-r--r--mod/pages/pagesTree.php56
-rw-r--r--mod/pages/start.php291
-rw-r--r--mod/pages/view.php57
-rw-r--r--mod/pages/views/default/annotation/icon.php32
-rw-r--r--mod/pages/views/default/annotation/page.php40
-rw-r--r--mod/pages/views/default/forms/pages/edit.php66
-rw-r--r--mod/pages/views/default/forms/pages/editwelcome.php57
-rw-r--r--mod/pages/views/default/object/page.php21
-rw-r--r--mod/pages/views/default/object/page_top.php21
-rw-r--r--mod/pages/views/default/pages/breadcrumbs.php28
-rw-r--r--mod/pages/views/default/pages/css.php108
-rw-r--r--mod/pages/views/default/pages/groupprofile_pages.php9
-rw-r--r--mod/pages/views/default/pages/menu.php14
-rw-r--r--mod/pages/views/default/pages/metatags.php22
-rw-r--r--mod/pages/views/default/pages/pagegallery.php37
-rw-r--r--mod/pages/views/default/pages/pagelisting.php38
-rw-r--r--mod/pages/views/default/pages/pageprofile.php66
-rw-r--r--mod/pages/views/default/pages/sidebar/sidebarthis.php82
-rw-r--r--mod/pages/views/default/pages/sidebar/starter.php21
-rw-r--r--mod/pages/views/default/pages/sidebar/tree.php8
-rw-r--r--mod/pages/views/default/pages/sidebar/wrapper.php7
-rw-r--r--mod/pages/views/default/pages/welcome.php29
-rw-r--r--mod/pages/welcome.php34
-rw-r--r--mod/pages/world.php51
75 files changed, 2033 insertions, 0 deletions
diff --git a/mod/pages/actions/pages/delete.php b/mod/pages/actions/pages/delete.php
new file mode 100644
index 000000000..6533ed520
--- /dev/null
+++ b/mod/pages/actions/pages/delete.php
@@ -0,0 +1,35 @@
+<?php
+
+ $page = get_input('page');
+
+ if ($page = get_entity($page)) {
+
+ if ($page->canEdit()) {
+
+ // Bring all child elements forward
+ $parent = $page->parent_guid;
+ if ($children = get_entities_from_metadata('parent_guid',$page->getGUID())) {
+ foreach($children as $child) {
+ $child->parent_guid = $parent;
+ }
+ }
+ if ($page->delete()) {
+ system_message(elgg_echo('pages:delete:success'));
+ if ($parent) {
+ if ($parent = get_entity($parent)) {
+ forward($parent->getURL());
+ exit;
+ }
+ }
+ forward('pg/pages/owned/' . $_SESSION['user']->username);
+ exit;
+ }
+
+ }
+
+ }
+
+ register_error(elgg_echo('pages:delete:failure'));
+ forward($_SERVER['HTTP_REFERER']);
+
+?> \ No newline at end of file
diff --git a/mod/pages/actions/pages/edit.php b/mod/pages/actions/pages/edit.php
new file mode 100644
index 000000000..a34971173
--- /dev/null
+++ b/mod/pages/actions/pages/edit.php
@@ -0,0 +1,114 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ // Load configuration
+ global $CONFIG;
+
+ gatekeeper();
+ set_context('pages');
+
+ // Get group fields
+ $input = array();
+ foreach($CONFIG->pages as $shortname => $valuetype) {
+ $input[$shortname] = get_input($shortname);
+ if ($valuetype == 'tags')
+ $input[$shortname] = string_to_tag_array($input[$shortname]);
+ }
+
+ // Get parent
+ $parent_guid = (int)get_input('parent_guid', 0);
+
+ // New or old?
+ $page = NULL;
+ $pages_guid = (int)get_input('pages_guid');
+ if ($pages_guid)
+ {
+ $page = get_entity($pages_guid);
+ if (!$page->canEdit())
+ $page = NULL; // if we can't edit it, go no further.
+ }
+ else
+ {
+ $page = new ElggObject();
+ if (!$parent_guid)
+ $page->subtype = 'page_top';
+ else
+ $page->subtype = 'page';
+
+ // New instance, so set container_guid
+ $container_guid = get_input('container_guid', $_SESSION['user']->getGUID());
+ $page->container_guid = $container_guid;
+ }
+
+ // Have we got it? Can we edit it?
+ if ($page instanceof ElggObject)
+ {
+ // Yes we have, and yes we can.
+
+ // Save fields - note we always save latest description as both description and annotation
+ if (sizeof($input) > 0)
+ {
+ foreach($input as $shortname => $value) {
+ if ((!$pages_guid) || (($pages_guid) && ($shortname != 'title')))
+ $page->$shortname = $value;
+ }
+ }
+
+
+ // Validate create
+ if (!$page->title)
+ {
+ register_error(elgg_echo("pages:notitle"));
+
+ forward($_SERVER['HTTP_REFERER']);
+ exit;
+ }
+
+ // Access ids
+ $page->access_id = (int)get_input('access_id', 0);
+
+ // Write access id
+ $page->write_access_id = (int)get_input('write_access_id', 0);
+
+ // Set parent
+ $page->parent_guid = $parent_guid;
+
+ // Ensure ultimate owner
+ $page->owner_guid = ($page->owner_guid ? $page->owner_guid : $_SESSION['user']->guid);
+
+ // finally save
+ if ($page->save())
+ {
+
+ // Now save description as an annotation
+ $page->annotate('page', $page->description, $page->access_id);
+
+
+ system_message(elgg_echo("pages:saved"));
+
+ // Forward to the user's profile
+ forward($page->getUrl());
+ exit;
+ }
+ else
+ register_error(elgg_echo('pages:notsaved'));
+
+ }
+ else
+ {
+ register_error(elgg_echo("pages:noaccess"));
+ }
+
+
+ // Forward to the user's profile
+ forward($page->getUrl());
+ exit;
+?>
diff --git a/mod/pages/actions/pages/editwelcome.php b/mod/pages/actions/pages/editwelcome.php
new file mode 100644
index 000000000..edf0d89f3
--- /dev/null
+++ b/mod/pages/actions/pages/editwelcome.php
@@ -0,0 +1,77 @@
+<?php
+ /**
+ * Elgg Pages Edit welcome message
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ // Load configuration
+ global $CONFIG;
+
+ gatekeeper();
+
+ // Get group fields
+ $message = get_input("pages_welcome");
+ $owner_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 ($owner_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->owner_guid = $owner_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"));
+
+ }
+
+ }//end of first if statement
+
+ // Forward to the main blog page
+ forward("pg/pages/owned/" . get_user($owner_guid)->username);
+ exit;
+
+?> \ No newline at end of file
diff --git a/mod/pages/edit.php b/mod/pages/edit.php
new file mode 100644
index 000000000..c9d12b207
--- /dev/null
+++ b/mod/pages/edit.php
@@ -0,0 +1,42 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+ gatekeeper();
+
+ $page_guid = get_input('page_guid');
+ $pages = get_entity($page_guid);
+
+ // Get the current page's owner
+ if ($container = $pages->container_guid) {
+ set_page_owner($container);
+ }
+ $page_owner = page_owner_entity();
+ if ($page_owner === false || is_null($page_owner)) {
+ $page_owner = $_SESSION['user'];
+ set_page_owner($page_owner->getGUID());
+ }
+
+ $title = elgg_echo("pages:edit");
+ $body = elgg_view_title($title);
+
+ if (($pages) && ($pages->canEdit()))
+ {
+ $body .= elgg_view("forms/pages/edit", array('entity' => $pages));
+
+ } else {
+ $body .= elgg_echo("pages:noaccess");
+ }
+
+ $body = elgg_view_layout('two_column_left_sidebar', '', $body);
+
+ page_draw($title, $body);
+?> \ No newline at end of file
diff --git a/mod/pages/history.php b/mod/pages/history.php
new file mode 100644
index 000000000..135ffe3d2
--- /dev/null
+++ b/mod/pages/history.php
@@ -0,0 +1,50 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+ gatekeeper();
+
+ $page_guid = get_input('page_guid');
+
+ $pages = get_entity($page_guid);
+ if ($pages->container_guid) {
+ set_page_owner($pages->container_guid);
+ } else {
+ set_page_owner($pages->owner_guid);
+ }
+
+ $limit = (int)get_input('limit', 20);
+ $offset = (int)get_input('offset');
+
+ $page_guid = get_input('page_guid');
+ $pages = get_entity($page_guid);
+
+ add_submenu_item(sprintf(elgg_echo("pages:user"), page_owner_entity()->name), $CONFIG->url . "pg/pages/owned/" . page_owner_entity()->username);
+
+ $title = $pages->title . ": " . elgg_echo("pages:history");
+ $area2 = elgg_view_title($title);
+
+ $context = get_context();
+
+ set_context('search');
+
+ $area2 .= list_annotations($page_guid, 'page', $limit, false);
+
+ set_context($context);
+
+
+ pages_set_navigation_parent($pages);
+ $area3 = elgg_view('pages/sidebar/tree');
+
+ $body = elgg_view_layout('two_column_left_sidebar', '', $area2, $area3);
+
+ page_draw($title, $body);
+?> \ No newline at end of file
diff --git a/mod/pages/images/application.png b/mod/pages/images/application.png
new file mode 100644
index 000000000..1dee9e366
--- /dev/null
+++ b/mod/pages/images/application.png
Binary files differ
diff --git a/mod/pages/images/code.png b/mod/pages/images/code.png
new file mode 100644
index 000000000..0c76bd129
--- /dev/null
+++ b/mod/pages/images/code.png
Binary files differ
diff --git a/mod/pages/images/css.png b/mod/pages/images/css.png
new file mode 100644
index 000000000..f907e44b3
--- /dev/null
+++ b/mod/pages/images/css.png
Binary files differ
diff --git a/mod/pages/images/db.png b/mod/pages/images/db.png
new file mode 100644
index 000000000..bddba1f98
--- /dev/null
+++ b/mod/pages/images/db.png
Binary files differ
diff --git a/mod/pages/images/directory.png b/mod/pages/images/directory.png
new file mode 100644
index 000000000..784e8fa48
--- /dev/null
+++ b/mod/pages/images/directory.png
Binary files differ
diff --git a/mod/pages/images/doc.png b/mod/pages/images/doc.png
new file mode 100644
index 000000000..ae8ecbf47
--- /dev/null
+++ b/mod/pages/images/doc.png
Binary files differ
diff --git a/mod/pages/images/file.gif b/mod/pages/images/file.gif
new file mode 100644
index 000000000..7e6216798
--- /dev/null
+++ b/mod/pages/images/file.gif
Binary files differ
diff --git a/mod/pages/images/file.png b/mod/pages/images/file.png
new file mode 100644
index 000000000..8b8b1ca00
--- /dev/null
+++ b/mod/pages/images/file.png
Binary files differ
diff --git a/mod/pages/images/film.png b/mod/pages/images/film.png
new file mode 100644
index 000000000..b0ce7bb19
--- /dev/null
+++ b/mod/pages/images/film.png
Binary files differ
diff --git a/mod/pages/images/flash.png b/mod/pages/images/flash.png
new file mode 100644
index 000000000..5769120b1
--- /dev/null
+++ b/mod/pages/images/flash.png
Binary files differ
diff --git a/mod/pages/images/folder-closed.gif b/mod/pages/images/folder-closed.gif
new file mode 100644
index 000000000..541107888
--- /dev/null
+++ b/mod/pages/images/folder-closed.gif
Binary files differ
diff --git a/mod/pages/images/folder.gif b/mod/pages/images/folder.gif
new file mode 100644
index 000000000..2b31631ca
--- /dev/null
+++ b/mod/pages/images/folder.gif
Binary files differ
diff --git a/mod/pages/images/folder_open.png b/mod/pages/images/folder_open.png
new file mode 100644
index 000000000..4e3548352
--- /dev/null
+++ b/mod/pages/images/folder_open.png
Binary files differ
diff --git a/mod/pages/images/html.png b/mod/pages/images/html.png
new file mode 100644
index 000000000..6ed2490ed
--- /dev/null
+++ b/mod/pages/images/html.png
Binary files differ
diff --git a/mod/pages/images/java.png b/mod/pages/images/java.png
new file mode 100644
index 000000000..b7bfcd15f
--- /dev/null
+++ b/mod/pages/images/java.png
Binary files differ
diff --git a/mod/pages/images/linux.png b/mod/pages/images/linux.png
new file mode 100644
index 000000000..52699bfee
--- /dev/null
+++ b/mod/pages/images/linux.png
Binary files differ
diff --git a/mod/pages/images/minus.gif b/mod/pages/images/minus.gif
new file mode 100644
index 000000000..47fb7b767
--- /dev/null
+++ b/mod/pages/images/minus.gif
Binary files differ
diff --git a/mod/pages/images/music.png b/mod/pages/images/music.png
new file mode 100644
index 000000000..a8b3ede3d
--- /dev/null
+++ b/mod/pages/images/music.png
Binary files differ
diff --git a/mod/pages/images/pdf.png b/mod/pages/images/pdf.png
new file mode 100644
index 000000000..8f8095e46
--- /dev/null
+++ b/mod/pages/images/pdf.png
Binary files differ
diff --git a/mod/pages/images/php.png b/mod/pages/images/php.png
new file mode 100644
index 000000000..7868a2594
--- /dev/null
+++ b/mod/pages/images/php.png
Binary files differ
diff --git a/mod/pages/images/picture.png b/mod/pages/images/picture.png
new file mode 100644
index 000000000..4a158fef7
--- /dev/null
+++ b/mod/pages/images/picture.png
Binary files differ
diff --git a/mod/pages/images/plus.gif b/mod/pages/images/plus.gif
new file mode 100644
index 000000000..690662162
--- /dev/null
+++ b/mod/pages/images/plus.gif
Binary files differ
diff --git a/mod/pages/images/ppt.png b/mod/pages/images/ppt.png
new file mode 100644
index 000000000..c4eff0387
--- /dev/null
+++ b/mod/pages/images/ppt.png
Binary files differ
diff --git a/mod/pages/images/psd.png b/mod/pages/images/psd.png
new file mode 100644
index 000000000..73c5b3f24
--- /dev/null
+++ b/mod/pages/images/psd.png
Binary files differ
diff --git a/mod/pages/images/ruby.png b/mod/pages/images/ruby.png
new file mode 100644
index 000000000..f59b7c436
--- /dev/null
+++ b/mod/pages/images/ruby.png
Binary files differ
diff --git a/mod/pages/images/script.png b/mod/pages/images/script.png
new file mode 100644
index 000000000..63fe6ceff
--- /dev/null
+++ b/mod/pages/images/script.png
Binary files differ
diff --git a/mod/pages/images/spinner.gif b/mod/pages/images/spinner.gif
new file mode 100644
index 000000000..85b99d46b
--- /dev/null
+++ b/mod/pages/images/spinner.gif
Binary files differ
diff --git a/mod/pages/images/treeview-black-line.gif b/mod/pages/images/treeview-black-line.gif
new file mode 100644
index 000000000..e5496877a
--- /dev/null
+++ b/mod/pages/images/treeview-black-line.gif
Binary files differ
diff --git a/mod/pages/images/treeview-black.gif b/mod/pages/images/treeview-black.gif
new file mode 100644
index 000000000..d549b9fc5
--- /dev/null
+++ b/mod/pages/images/treeview-black.gif
Binary files differ
diff --git a/mod/pages/images/treeview-default-line.gif b/mod/pages/images/treeview-default-line.gif
new file mode 100644
index 000000000..37114d306
--- /dev/null
+++ b/mod/pages/images/treeview-default-line.gif
Binary files differ
diff --git a/mod/pages/images/treeview-default.gif b/mod/pages/images/treeview-default.gif
new file mode 100644
index 000000000..a12ac52ff
--- /dev/null
+++ b/mod/pages/images/treeview-default.gif
Binary files differ
diff --git a/mod/pages/images/treeview-famfamfam-line.gif b/mod/pages/images/treeview-famfamfam-line.gif
new file mode 100644
index 000000000..6e289cecc
--- /dev/null
+++ b/mod/pages/images/treeview-famfamfam-line.gif
Binary files differ
diff --git a/mod/pages/images/treeview-famfamfam.gif b/mod/pages/images/treeview-famfamfam.gif
new file mode 100644
index 000000000..0cb178e89
--- /dev/null
+++ b/mod/pages/images/treeview-famfamfam.gif
Binary files differ
diff --git a/mod/pages/images/treeview-gray-line.gif b/mod/pages/images/treeview-gray-line.gif
new file mode 100644
index 000000000..37600447d
--- /dev/null
+++ b/mod/pages/images/treeview-gray-line.gif
Binary files differ
diff --git a/mod/pages/images/treeview-gray.gif b/mod/pages/images/treeview-gray.gif
new file mode 100644
index 000000000..cfb8a2f09
--- /dev/null
+++ b/mod/pages/images/treeview-gray.gif
Binary files differ
diff --git a/mod/pages/images/treeview-red-line.gif b/mod/pages/images/treeview-red-line.gif
new file mode 100644
index 000000000..df9e749a8
--- /dev/null
+++ b/mod/pages/images/treeview-red-line.gif
Binary files differ
diff --git a/mod/pages/images/treeview-red.gif b/mod/pages/images/treeview-red.gif
new file mode 100644
index 000000000..3bbb3a157
--- /dev/null
+++ b/mod/pages/images/treeview-red.gif
Binary files differ
diff --git a/mod/pages/images/txt.png b/mod/pages/images/txt.png
new file mode 100644
index 000000000..813f712f7
--- /dev/null
+++ b/mod/pages/images/txt.png
Binary files differ
diff --git a/mod/pages/images/xls.png b/mod/pages/images/xls.png
new file mode 100644
index 000000000..b977d7e52
--- /dev/null
+++ b/mod/pages/images/xls.png
Binary files differ
diff --git a/mod/pages/images/zip.png b/mod/pages/images/zip.png
new file mode 100644
index 000000000..fd4bbccdf
--- /dev/null
+++ b/mod/pages/images/zip.png
Binary files differ
diff --git a/mod/pages/index.php b/mod/pages/index.php
new file mode 100644
index 000000000..ea0b8c3f6
--- /dev/null
+++ b/mod/pages/index.php
@@ -0,0 +1,55 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ global $CONFIG;
+
+ // Add menus
+ $owner = page_owner_entity();
+ add_submenu_item(sprintf(elgg_echo("pages:user"), page_owner_entity()->name), $CONFIG->url . "pg/pages/owned/" . page_owner_entity()->username);
+ add_submenu_item(elgg_echo('pages:all'),$CONFIG->wwwroot."mod/pages/world.php");
+ if (($owner) && ($owner->canWriteToContainer($_SESSION['user']))){
+ add_submenu_item(elgg_echo('pages:new'), $CONFIG->url . "pg/pages/new/?container_guid=" . page_owner());
+ add_submenu_item(elgg_echo('pages:welcome'), $CONFIG->url . "pg/pages/welcome/");
+ }
+
+
+ $limit = get_input("limit", 10);
+ $offset = get_input("offset", 0);
+
+ if($owner instanceof ElggGroup){
+ $title = sprintf(elgg_echo("pages:group"),$owner->name);
+ }else{
+ $title = sprintf(elgg_echo("pages:user"),$owner->name);
+ }
+
+
+ // Get objects
+ $context = get_context();
+
+ set_context('search');
+
+ $objects = list_entities("object", "page_top", page_owner(), $limit, false);
+
+ set_context($context);
+
+ //get the owners latest welcome message
+ $welcome_message = get_entities("object", "pages_welcome", $owner->guid, '', 1);
+
+ $body = elgg_view_title($title);
+ $body .= elgg_view("pages/welcome", array('entity' => $welcome_message));
+ $body .= $objects;
+ $body = elgg_view_layout('two_column_left_sidebar', '', $body);
+
+ // Finally draw the page
+ page_draw($title, $body);
+?> \ No newline at end of file
diff --git a/mod/pages/javascript/jquery.treeview.async.js b/mod/pages/javascript/jquery.treeview.async.js
new file mode 100644
index 000000000..01059191f
--- /dev/null
+++ b/mod/pages/javascript/jquery.treeview.async.js
@@ -0,0 +1,72 @@
+/*
+ * Async Treeview 0.1 - Lazy-loading extension for Treeview
+ *
+ * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
+ *
+ * Copyright (c) 2007 Jörn Zaefferer
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * Revision: $Id$
+ *
+ */
+
+;(function($) {
+
+function load(settings, root, child, container) {
+ $.getJSON(settings.url, {root: root, currentpage: settings.currentpage}, function(response) {
+ function createNode(parent) {
+ var current = $("<li/>").attr("id", this.id || "").html("<span>" + this.text + "</span>").appendTo(parent);
+ if (this.classes) {
+ current.children("span").addClass(this.classes);
+ }
+ if (this.expanded) {
+ current.addClass("open");
+ }
+ if (this.hasChildren || this.children && this.children.length) {
+ var branch = $("<ul/>").appendTo(current);
+ if (this.hasChildren) {
+ current.addClass("hasChildren");
+ createNode.call({
+ text:"placeholder",
+ id:"placeholder",
+ children:[]
+ }, branch);
+ }
+ if (this.children && this.children.length) {
+ $.each(this.children, createNode, [branch])
+ }
+ }
+ }
+ $.each(response, createNode, [child]);
+ $(container).treeview({add: child}, root);
+ });
+}
+
+var proxied = $.fn.treeview;
+$.fn.treeview = function(settings, source) {
+ if (!settings.url) {
+ return proxied.apply(this, arguments);
+ }
+ var container = this;
+ load(settings, source, this, container);
+ var userToggle = settings.toggle;
+ return proxied.call(this, $.extend({}, settings, {
+ collapsed: true,
+ toggle: function() {
+ var $this = $(this);
+ if ($this.hasClass("hasChildren")) {
+ var childList = $this.removeClass("hasChildren").find("ul");
+ childList.empty();
+ load(settings, this.id, childList, container);
+ }
+ if (userToggle) {
+ userToggle.apply(this, arguments);
+ }
+ }
+ }));
+};
+
+})(jQuery); \ No newline at end of file
diff --git a/mod/pages/javascript/jquery.treeview.js b/mod/pages/javascript/jquery.treeview.js
new file mode 100644
index 000000000..bc5d9e46b
--- /dev/null
+++ b/mod/pages/javascript/jquery.treeview.js
@@ -0,0 +1,251 @@
+/*
+ * Treeview 1.4 - jQuery plugin to hide and show branches of a tree
+ *
+ * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
+ * http://docs.jquery.com/Plugins/Treeview
+ *
+ * Copyright (c) 2007 Jörn Zaefferer
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * Revision: $Id: jquery.treeview.js 4684 2008-02-07 19:08:06Z joern.zaefferer $
+ *
+ */
+
+;(function($) {
+
+ $.extend($.fn, {
+ swapClass: function(c1, c2) {
+ var c1Elements = this.filter('.' + c1);
+ this.filter('.' + c2).removeClass(c2).addClass(c1);
+ c1Elements.removeClass(c1).addClass(c2);
+ return this;
+ },
+ replaceClass: function(c1, c2) {
+ return this.filter('.' + c1).removeClass(c1).addClass(c2).end();
+ },
+ hoverClass: function(className) {
+ className = className || "hover";
+ return this.hover(function() {
+ $(this).addClass(className);
+ }, function() {
+ $(this).removeClass(className);
+ });
+ },
+ heightToggle: function(animated, callback) {
+ animated ?
+ this.animate({ height: "toggle" }, animated, callback) :
+ this.each(function(){
+ jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
+ if(callback)
+ callback.apply(this, arguments);
+ });
+ },
+ heightHide: function(animated, callback) {
+ if (animated) {
+ this.animate({ height: "hide" }, animated, callback);
+ } else {
+ this.hide();
+ if (callback)
+ this.each(callback);
+ }
+ },
+ prepareBranches: function(settings) {
+ if (!settings.prerendered) {
+ // mark last tree items
+ this.filter(":last-child:not(ul)").addClass(CLASSES.last);
+ // collapse whole tree, or only those marked as closed, anyway except those marked as open
+ this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide();
+ }
+ // return all items with sublists
+ return this.filter(":has(>ul)");
+ },
+ applyClasses: function(settings, toggler) {
+ this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event) {
+ toggler.apply($(this).next());
+ }).add( $("a", this) ).hoverClass();
+
+ if (!settings.prerendered) {
+ // handle closed ones first
+ this.filter(":has(>ul:hidden)")
+ .addClass(CLASSES.expandable)
+ .replaceClass(CLASSES.last, CLASSES.lastExpandable);
+
+ // handle open ones
+ this.not(":has(>ul:hidden)")
+ .addClass(CLASSES.collapsable)
+ .replaceClass(CLASSES.last, CLASSES.lastCollapsable);
+
+ // create hitarea
+ this.prepend("<div class=\"" + CLASSES.hitarea + "\"/>").find("div." + CLASSES.hitarea).each(function() {
+ var classes = "";
+ $.each($(this).parent().attr("class").split(" "), function() {
+ classes += this + "-hitarea ";
+ });
+ $(this).addClass( classes );
+ });
+ }
+
+ // apply event to hitarea
+ this.find("div." + CLASSES.hitarea).click( toggler );
+ },
+ treeview: function(settings) {
+
+ settings = $.extend({
+ cookieId: "treeview"
+ }, settings);
+
+ if (settings.add) {
+ return this.trigger("add", [settings.add]);
+ }
+
+ if ( settings.toggle ) {
+ var callback = settings.toggle;
+ settings.toggle = function() {
+ return callback.apply($(this).parent()[0], arguments);
+ };
+ }
+
+ // factory for treecontroller
+ function treeController(tree, control) {
+ // factory for click handlers
+ function handler(filter) {
+ return function() {
+ // reuse toggle event handler, applying the elements to toggle
+ // start searching for all hitareas
+ toggler.apply( $("div." + CLASSES.hitarea, tree).filter(function() {
+ // for plain toggle, no filter is provided, otherwise we need to check the parent element
+ return filter ? $(this).parent("." + filter).length : true;
+ }) );
+ return false;
+ };
+ }
+ // click on first element to collapse tree
+ $("a:eq(0)", control).click( handler(CLASSES.collapsable) );
+ // click on second to expand tree
+ $("a:eq(1)", control).click( handler(CLASSES.expandable) );
+ // click on third to toggle tree
+ $("a:eq(2)", control).click( handler() );
+ }
+
+ // handle toggle event
+ function toggler() {
+ $(this)
+ .parent()
+ // swap classes for hitarea
+ .find(">.hitarea")
+ .swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
+ .swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea )
+ .end()
+ // swap classes for parent li
+ .swapClass( CLASSES.collapsable, CLASSES.expandable )
+ .swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
+ // find child lists
+ .find( ">ul" )
+ // toggle them
+ .heightToggle( settings.animated, settings.toggle );
+ if ( settings.unique ) {
+ $(this).parent()
+ .siblings()
+ // swap classes for hitarea
+ .find(">.hitarea")
+ .replaceClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
+ .replaceClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea )
+ .end()
+ .replaceClass( CLASSES.collapsable, CLASSES.expandable )
+ .replaceClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
+ .find( ">ul" )
+ .heightHide( settings.animated, settings.toggle );
+ }
+ }
+
+ function serialize() {
+ function binary(arg) {
+ return arg ? 1 : 0;
+ }
+ var data = [];
+ branches.each(function(i, e) {
+ data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0;
+ });
+ $.cookie(settings.cookieId, data.join("") );
+ }
+
+ function deserialize() {
+ var stored = $.cookie(settings.cookieId);
+ if ( stored ) {
+ var data = stored.split("");
+ branches.each(function(i, e) {
+ $(e).find(">ul")[ parseInt(data[i]) ? "show" : "hide" ]();
+ });
+ }
+ }
+
+ // add treeview class to activate styles
+ this.addClass("treeview");
+
+ // prepare branches and find all tree items with child lists
+ var branches = this.find("li").prepareBranches(settings);
+
+ switch(settings.persist) {
+ case "cookie":
+ var toggleCallback = settings.toggle;
+ settings.toggle = function() {
+ serialize();
+ if (toggleCallback) {
+ toggleCallback.apply(this, arguments);
+ }
+ };
+ deserialize();
+ break;
+ case "location":
+ var current = this.find("a").filter(function() { return this.href.toLowerCase() == location.href.toLowerCase(); });
+ if ( current.length ) {
+ current.addClass("selected").parents("ul, li").add( current.next() ).show();
+ }
+ break;
+ }
+
+ branches.applyClasses(settings, toggler);
+
+ // if control option is set, create the treecontroller and show it
+ if ( settings.control ) {
+ treeController(this, settings.control);
+ $(settings.control).show();
+ }
+
+ return this.bind("add", function(event, branches) {
+ $(branches).prev()
+ .removeClass(CLASSES.last)
+ .removeClass(CLASSES.lastCollapsable)
+ .removeClass(CLASSES.lastExpandable)
+ .find(">.hitarea")
+ .removeClass(CLASSES.lastCollapsableHitarea)
+ .removeClass(CLASSES.lastExpandableHitarea);
+ $(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings, toggler);
+ });
+ }
+ });
+
+ // classes used by the plugin
+ // need to be styled via external stylesheet, see first example
+ var CLASSES = $.fn.treeview.classes = {
+ open: "open",
+ closed: "closed",
+ expandable: "expandable",
+ expandableHitarea: "expandable-hitarea",
+ lastExpandableHitarea: "lastExpandable-hitarea",
+ collapsable: "collapsable",
+ collapsableHitarea: "collapsable-hitarea",
+ lastCollapsableHitarea: "lastCollapsable-hitarea",
+ lastCollapsable: "lastCollapsable",
+ lastExpandable: "lastExpandable",
+ last: "last",
+ hitarea: "hitarea"
+ };
+
+ // provide backwards compability
+ $.fn.Treeview = $.fn.treeview;
+
+})(jQuery); \ No newline at end of file
diff --git a/mod/pages/languages/en.php b/mod/pages/languages/en.php
new file mode 100644
index 000000000..1040676a2
--- /dev/null
+++ b/mod/pages/languages/en.php
@@ -0,0 +1,89 @@
+<?php
+ /**
+ * Elgg pages plugin language pack
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $english = array(
+
+ /**
+ * Menu items and titles
+ */
+
+ 'pages' => "Pages",
+ 'pages:yours' => "Your pages",
+ 'pages:user' => "Pages home",
+ 'pages:group' => "%s's pages",
+ 'pages:all' => "All site pages",
+ 'pages:new' => "New page",
+ 'pages:groupprofile' => "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:welcomeerror' => "There was a problem saving your welcome message",
+ 'pages:welcomeposted' => "Your welcome message has been posted",
+ 'pages:navigation' => "Page navigation",
+
+ 'item:object:page_top' => 'Top-level pages',
+ 'item:object:page' => 'Pages',
+ 'item:object:pages_welcome' => 'Pages welcome blocks',
+
+
+ /**
+ * Form fields
+ */
+
+ 'pages:title' => 'Pages Title',
+ 'pages:description' => 'Your page entry',
+ 'pages:tags' => 'Tags',
+ 'pages:access_id' => 'Access',
+ 'pages:write_access_id' => 'Write access',
+
+ /**
+ * Status and error messages
+ */
+ 'pages:noaccess' => 'No access to page',
+ 'pages:cantedit' => 'You can not edit this page',
+ 'pages:saved' => 'Pages saved',
+ 'pages:notsaved' => 'Page could not be saved',
+ 'pages:notitle' => 'You must specify a title for your page.',
+ 'pages:delete:success' => 'Your page was successfully deleted.',
+ 'pages:delete:failure' => 'The page could not be deleted.',
+
+ /**
+ * Page
+ */
+ 'pages:strapline' => 'Last updated %s by %s',
+
+ /**
+ * History
+ */
+ 'pages:revision' => 'Revision created %s by %s',
+
+ /**
+ * Submenu items
+ */
+ 'pages:label:view' => "View page",
+ 'pages:label:edit' => "Edit page",
+ 'pages:label:history' => "Page history",
+
+ /**
+ * Sidebar items
+ */
+ 'pages:sidebar:this' => "This page",
+ 'pages:sidebar:children' => "Sub-pages",
+ 'pages:sidebar:parent' => "Parent",
+
+ 'pages:newchild' => "Create a sub-page",
+ 'pages:backtoparent' => "Back to '%s'",
+ );
+
+ add_translation("en",$english);
+?> \ No newline at end of file
diff --git a/mod/pages/manifest.xml b/mod/pages/manifest.xml
new file mode 100644
index 000000000..77da40918
--- /dev/null
+++ b/mod/pages/manifest.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest>
+ <field key="author" value="Marcus Povey" />
+ <field key="version" value="1.0" />
+ <field key="description" value="Elgg Pages" />
+ <field key="website" value="http://www.elgg.org" />
+ <field key="copyright" value="(C) Curverider 2008" />
+ <field key="licence" value="GNU Public License version 2" />
+</plugin_manifest> \ No newline at end of file
diff --git a/mod/pages/new.php b/mod/pages/new.php
new file mode 100644
index 000000000..8dea9add1
--- /dev/null
+++ b/mod/pages/new.php
@@ -0,0 +1,44 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ 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 = page_owner_entity();
+ if ($page_owner === false || is_null($page_owner)) {
+ $page_owner = $_SESSION['user'];
+ set_page_owner($page_owner->getGUID());
+ }
+
+ //if it is a sub page, provide a link back to parent
+ if(get_input('parent_guid')){
+ $parent = get_entity(get_input('parent_guid'));
+
+ // Breadcrumbs
+ $area2 .= elgg_view('pages/breadcrumbs', array('page_owner' => $page_owner, 'parent' => $parent, 'add' => true));
+ }
+
+ global $CONFIG;
+ add_submenu_item(sprintf(elgg_echo("pages:user"), page_owner_entity()->name), $CONFIG->url . "pg/pages/owned/" . page_owner_entity()->username);
+
+ $title = elgg_echo("pages:new");
+ $area2 .= elgg_view_title($title);
+ $area2 .= elgg_view("forms/pages/edit");
+
+ $body = elgg_view_layout('two_column_left_sidebar', $area1, $area2);
+
+ page_draw($title, $body);
+?> \ No newline at end of file
diff --git a/mod/pages/pagesTree.php b/mod/pages/pagesTree.php
new file mode 100644
index 000000000..167877e00
--- /dev/null
+++ b/mod/pages/pagesTree.php
@@ -0,0 +1,56 @@
+<?php
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ $page = (int) get_input('root',get_input('source'));
+
+ if (!$page = get_entity($page)) {
+ exit;
+ }
+
+ // View tree
+ echo pages_get_entity_sidebar($page, $fulltree);
+
+//
+// jQuery File Tree PHP Connector
+//
+// Version 1.01
+//
+// Cory S.N. LaViska
+// A Beautiful Site (http://abeautifulsite.net/)
+// 24 March 2008
+//
+// History:
+//
+// 1.01 - updated to work with foreign characters in directory/file names (12 April 2008)
+// 1.00 - released (24 March 2008)
+//
+// Output a list of files for jQuery File Tree
+//
+
+/*
+$_POST['dir'] = urldecode($_POST['dir']);
+
+if( file_exists($root . $_POST['dir']) ) {
+ $files = scandir($root . $_POST['dir']);
+ natcasesort($files);
+ if( count($files) > 2 ) {
+ echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
+ // All dirs
+ foreach( $files as $file ) {
+ if( file_exists($root . $_POST['dir'] . $file) && $file != '.' && $file != '..' && is_dir($root . $_POST['dir'] . $file) ) {
+ echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "/\">" . htmlentities($file) . "</a></li>";
+ }
+ }
+ // All files
+ foreach( $files as $file ) {
+ if( file_exists($root . $_POST['dir'] . $file) && $file != '.' && $file != '..' && !is_dir($root . $_POST['dir'] . $file) ) {
+ $ext = preg_replace('/^.*\./', '', $file);
+ echo "<li class=\"file ext_$ext\"><a href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "\">" . htmlentities($file) . "</a></li>";
+ }
+ }
+ echo "</ul>";
+ }
+}
+*/
+
+?> \ No newline at end of file
diff --git a/mod/pages/start.php b/mod/pages/start.php
new file mode 100644
index 000000000..5ba875ca0
--- /dev/null
+++ b/mod/pages/start.php
@@ -0,0 +1,291 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ /**
+ * Initialise the pages plugin.
+ *
+ */
+ function pages_init()
+ {
+ global $CONFIG;
+
+ // Set up the menu for logged in users
+ if (isloggedin())
+ {
+ add_menu(elgg_echo('pages'), $CONFIG->wwwroot . "pg/pages/owned/" . $_SESSION['user']->username,'pages');
+ }
+ else
+ {
+ add_menu(elgg_echo('pages'), $CONFIG->wwwroot . "mod/pages/world.php");
+ }
+
+ // Extend hover-over menu
+ extend_view('profile/menu/links','pages/menu');
+
+ // Register a page handler, so we can have nice URLs
+ 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 some actions
+ register_action("pages/edit",false, $CONFIG->pluginspath . "pages/actions/pages/edit.php");
+ register_action("pages/editwelcome",false, $CONFIG->pluginspath . "pages/actions/pages/editwelcome.php");
+ register_action("pages/delete",false, $CONFIG->pluginspath . "pages/actions/pages/delete.php");
+
+ // Extend some views
+ extend_view('css','pages/css');
+ extend_view('groups/menu/links', 'pages/menu'); // Add to groups context
+ 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');
+
+ // For now, we'll hard code the groups profile items as follows:
+ // TODO make this user configurable
+
+ // Language short codes must be of the form "pages:key"
+ // where key is the array key below
+ $CONFIG->pages = array(
+ 'title' => 'text',
+ 'description' => 'longtext',
+ 'tags' => 'tags',
+ 'access_id' => 'access',
+ 'write_access_id' => 'access',
+ );
+ }
+
+ function pages_url($entity) {
+
+ global $CONFIG;
+
+
+ return $CONFIG->url . "pg/pages/view/{$entity->guid}/";
+
+ }
+
+ /**
+ * Sets up submenus for the pages system. Triggered on pagesetup.
+ *
+ */
+ function pages_submenus() {
+
+ global $CONFIG;
+
+ $page_owner = page_owner_entity();
+
+ // Group submenu option
+ if ($page_owner instanceof ElggGroup && get_context() != "pages") {
+ add_submenu_item(sprintf(elgg_echo("pages:group"),$page_owner->name), $CONFIG->wwwroot . "pg/pages/owned/" . $page_owner->username);
+ }
+
+
+ }
+
+ /**
+ * 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" :
+ 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'), $CONFIG->url . "pg/pages/view/{$page[1]}");
+ add_submenu_item(elgg_echo('pages:user'), $CONFIG->wwwroot . "pg/pages/owned/" . $_SESSION['user']->username);
+ if (($entity) && ($entity->canEdit())) add_submenu_item(elgg_echo('pages:label:edit'), $CONFIG->url . "pg/pages/edit/{$page[1]}");
+ add_submenu_item(elgg_echo('pages:label:history'), $CONFIG->url . "pg/pages/history/{$page[1]}");
+
+ include($CONFIG->pluginspath . "pages/edit.php");
+ break;
+ case "view" :
+
+ if (isset($page[1]))
+ set_input('page_guid', $page[1]);
+
+ extend_view('metatags','pages/metatags');
+
+ $entity = get_entity($page[1]);
+ add_submenu_item(elgg_echo('pages:label:view'), $CONFIG->url . "pg/pages/view/{$page[1]}");
+ if (($entity) && ($entity->canEdit())) add_submenu_item(elgg_echo('pages:label:edit'), $CONFIG->url . "pg/pages/edit/{$page[1]}");
+ add_submenu_item(elgg_echo('pages:label:history'), $CONFIG->url . "pg/pages/history/{$page[1]}");
+
+ include($CONFIG->pluginspath . "pages/view.php");
+ break;
+ case "history" :
+ if (isset($page[1]))
+ set_input('page_guid', $page[1]);
+
+ extend_view('metatags','pages/metatags');
+
+ $entity = get_entity($page[1]);
+ add_submenu_item(elgg_echo('pages:label:view'), $CONFIG->url . "pg/pages/view/{$page[1]}");
+ if (($entity) && ($entity->canEdit())) add_submenu_item(elgg_echo('pages:label:edit'), $CONFIG->url . "pg/pages/edit/{$page[1]}");
+ add_submenu_item(elgg_echo('pages:label:history'), $CONFIG->url . "pg/pages/history/{$page[1]}");
+
+ include($CONFIG->pluginspath . "pages/history.php");
+ break;
+ default:
+ include($CONFIG->pluginspath . "pages/new.php");
+ break;
+ }
+ }
+
+ }
+
+ /**
+ * Sets the parent of the current page, for navigation purposes
+ *
+ * @param ElggObject $entity
+ */
+ function pages_set_navigation_parent(ElggObject $entity) {
+
+ $guid = $entity->getGUID();
+
+ while ($parent_guid = $entity->parent_guid) {
+ $entity = get_entity($parent_guid);
+ if ($entity) {
+ $guid = $entity->getGUID();
+ }
+ }
+
+ set_input('treeguid',$guid);
+ }
+
+ function pages_get_path($guid) {
+
+ if (!$entity = get_entity($guid)) return array();
+
+ $path = array($guid);
+
+ while ($parent_guid = $entity->parent_guid) {
+ $entity = get_entity($parent_guid);
+ if ($entity) {
+ $path[] = $entity->getGUID();
+ }
+ }
+
+ return $path;
+ }
+
+ /**
+ * Return the correct sidebar for a given entity
+ *
+ * @param ElggObject $entity
+ */
+ function pages_get_entity_sidebar(ElggObject $entity, $fulltree = 0)
+ {
+ $body = "";
+
+ $children = get_entities_from_metadata('parent_guid',$entity->guid);
+ $body .= elgg_view('pages/sidebar/sidebarthis', array('entity' => $entity,
+ 'children' => $children,
+ 'fulltree' => $fulltree));
+ //$body = elgg_view('pages/sidebar/wrapper', array('body' => $body));
+
+ return $body;
+ }
+
+ /**
+ * Extend permissions checking to extend can-edit for write users.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $returnvalue
+ * @param unknown_type $params
+ */
+ function pages_write_permission_check($hook, $entity_type, $returnvalue, $params)
+ {
+ if ($params['entity']->getSubtype() == 'page'
+ || $params['entity']->getSubtype() == 'page_top') {
+
+ $write_permission = $params['entity']->write_access_id;
+ $user = $params['user'];
+
+ if (($write_permission) && ($user))
+ {
+ // $list = get_write_access_array($user->guid);
+ $list = get_access_array($user->guid); // get_access_list($user->guid);
+
+ if (($write_permission!=0) && (in_array($write_permission,$list)))
+ return true;
+
+ }
+ }
+ }
+
+ /**
+ * Extend container permissions checking to extend can_write_to_container for write users.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $returnvalue
+ * @param unknown_type $params
+ */
+ function pages_container_permission_check($hook, $entity_type, $returnvalue, $params) {
+
+ if (get_context() == "pages") {
+ if (page_owner()) {
+ if (can_write_to_container($_SESSION['user']->guid, page_owner())) return true;
+ }
+ if ($page_guid = get_input('page_guid',0)) {
+ $entity = get_entity($page_guid);
+ } else if ($parent_guid = get_input('parent_guid',0)) {
+ $entity = get_entity($parent_guid);
+ }
+ if ($entity instanceof ElggObject) {
+ if (
+ can_write_to_container($_SESSION['user']->guid, $entity->container_guid)
+ || in_array($entity->write_access_id,get_access_list())
+ ) {
+ return true;
+ }
+ }
+ }
+
+ }
+
+ // write permission plugin hooks
+ register_plugin_hook('permissions_check', 'object', 'pages_write_permission_check');
+ register_plugin_hook('container_permissions_check', 'object', 'pages_container_permission_check');
+
+ // Make sure the pages initialisation function is called on initialisation
+ register_elgg_event_handler('init','system','pages_init');
+ register_elgg_event_handler('pagesetup','system','pages_submenus');
+?> \ No newline at end of file
diff --git a/mod/pages/view.php b/mod/pages/view.php
new file mode 100644
index 000000000..398368aab
--- /dev/null
+++ b/mod/pages/view.php
@@ -0,0 +1,57 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ $page_guid = get_input('page_guid');
+ set_context('pages');
+
+ $pages = get_entity($page_guid);
+ if (!$pages) forward();
+
+ $container = $pages->container_guid;
+
+ if ($container) {
+ set_page_owner($container);
+ } else {
+ set_page_owner($pages->owner_guid);
+ }
+
+ global $CONFIG;
+ add_submenu_item(sprintf(elgg_echo("pages:user"), page_owner_entity()->name), $CONFIG->url . "pg/pages/owned/" . page_owner_entity()->username);
+
+ if ($pages->canEdit()) {
+ add_submenu_item(elgg_echo('pages:newchild'),"{$CONFIG->wwwroot}pg/pages/new/?parent_guid={$pages->getGUID()}&container_guid=" . page_owner());
+ add_submenu_item(elgg_echo('pages:delete'),"{$CONFIG->wwwroot}action/pages/delete?page={$pages->getGUID()}");
+ }
+
+ //if the page has a parent, get it
+ if($parent_page = get_entity(get_input("page_guid")))
+ $parent = $parent_page;
+
+ // Breadcrumbs
+ $body = elgg_view('pages/breadcrumbs', array('page_owner' => page_owner_entity(), 'parent' => $parent));
+
+ $body .= elgg_view_title($pages->title);
+ $body .= elgg_view_entity($pages, true);
+
+ //add comments
+ $body .= elgg_view_comments($pages);
+
+ pages_set_navigation_parent($pages);
+ $sidebar = elgg_view('pages/sidebar/tree');
+
+ $body = elgg_view_layout('two_column_left_sidebar', '', $body, $sidebar);
+
+ // Finally draw the page
+ page_draw($title, $body);
+
+?> \ No newline at end of file
diff --git a/mod/pages/views/default/annotation/icon.php b/mod/pages/views/default/annotation/icon.php
new file mode 100644
index 000000000..cb2548cb2
--- /dev/null
+++ b/mod/pages/views/default/annotation/icon.php
@@ -0,0 +1,32 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+
+ $annotation = $vars['annotation'];
+ $entity = get_entity($annotation->entity_guid);
+
+ // Get size
+ if (!in_array($vars['size'],array('small','medium','large','tiny','master','topbar')))
+ $vars['size'] = "medium";
+
+ // Get any align and js
+ if (!empty($vars['align'])) {
+ $align = " align=\"{$vars['align']}\" ";
+ } else {
+ $align = "";
+ }
+
+
+?>
+
+<div class="groupicon">
+<a href="<?php echo $entity->getURL() . "?rev=" . $annotation->id; ?>"><img src="<?php echo $vars['url']; ?>mod/pages/graphics/default<?php echo $vars['size']; ?>.jpg" border="0" <?php echo $align; ?> <?php echo $vars['js']; ?> /></a>
+</div> \ No newline at end of file
diff --git a/mod/pages/views/default/annotation/page.php b/mod/pages/views/default/annotation/page.php
new file mode 100644
index 000000000..ff06178ec
--- /dev/null
+++ b/mod/pages/views/default/annotation/page.php
@@ -0,0 +1,40 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $annotation = $vars['annotation'];
+ $entity = get_entity($annotation->entity_guid);
+
+ $icon = elgg_view(
+ "annotation/icon", array(
+ 'annotation' => $vars['annotation'],
+ 'size' => 'small',
+ )
+ );
+
+ $owner_guid = $annotation->owner_guid;
+ $owner = get_entity($owner_guid);
+
+ $rev = sprintf(elgg_echo('pages:revision'),
+ friendly_time($annotation->time_created),
+
+ "<a href=\"" . $owner->getURL() . "\">" . $owner->name ."</a>"
+ );
+
+ $link = $entity->getURL() . "?rev=" . $annotation->id;
+
+ $info = <<< END
+
+<div><a href="$link">{$entity->title}</a></div>
+<div>$rev</div>
+END;
+
+ echo elgg_view_listing($icon, $info);
+?> \ No newline at end of file
diff --git a/mod/pages/views/default/forms/pages/edit.php b/mod/pages/views/default/forms/pages/edit.php
new file mode 100644
index 000000000..8c9e5ccfc
--- /dev/null
+++ b/mod/pages/views/default/forms/pages/edit.php
@@ -0,0 +1,66 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $parent_guid = get_input('parent_guid');
+ $container_guid = get_input('container_guid');
+ if (!$container_guid) $container_guid = page_owner();
+?>
+<form action="<?php echo $vars['url']; ?>action/pages/edit" method="post">
+
+<?php
+
+ //var_export($vars['profile']);
+ if (is_array($vars['config']->pages) && sizeof($vars['config']->pages) > 0)
+ foreach($vars['config']->pages as $shortname => $valtype) {
+
+ $disabled = "";
+
+ if (($vars['entity']) && ($shortname == 'title'))
+ {
+ $disabled = true;
+ }
+?>
+
+ <p>
+ <label>
+ <?php echo elgg_echo("pages:{$shortname}") ?><br />
+ <?php echo elgg_view("input/{$valtype}",array(
+ 'internalname' => $shortname,
+ 'value' => $vars['entity']->$shortname,
+ 'disabled' => $disabled
+ )); ?>
+ </label>
+ </p>
+
+<?php
+
+ }
+
+?>
+ <p>
+ <?php
+ if ($vars['entity'])
+ {
+ ?><input type="hidden" name="pages_guid" value="<?php echo $vars['entity']->getGUID(); ?>" /><?php
+ }
+ ?>
+ <?php
+ if ($container_guid)
+ {
+ ?><input type="hidden" name="container_guid" value="<?php echo $container_guid; ?>" /><?php
+ }
+ ?>
+ <input type="hidden" name="parent_guid" value="<?php if ($vars['entity']) echo $vars['entity']->parent_guid; else echo $parent_guid; ?>" />
+ <input type="hidden" name="owner_guid" value="<?php if ($vars['entity']) echo $vars['entity']->owner_guid; else echo page_owner(); ?>" />
+ <input type="submit" class="submit_button" value="<?php echo elgg_echo("save"); ?>" />
+ </p>
+
+</form> \ No newline at end of file
diff --git a/mod/pages/views/default/forms/pages/editwelcome.php b/mod/pages/views/default/forms/pages/editwelcome.php
new file mode 100644
index 000000000..d8960bf9c
--- /dev/null
+++ b/mod/pages/views/default/forms/pages/editwelcome.php
@@ -0,0 +1,57 @@
+<?php
+ /**
+ * Elgg Pages Edit welcome page
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ //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 = 0;
+ }
+
+ $page_owner = $vars['owner']->guid;
+
+?>
+<form action="<?php echo $vars['url']; ?>action/pages/editwelcome" method="post">
+
+ <p>
+ <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
+ //if it is editing, include the object guid
+ if($object_guid != ''){
+ ?>
+ <input type="hidden" name="object_guid" value="<?php echo $object_guid; ?>" />
+ <?php
+ }
+ ?>
+
+ <input type="submit" class="submit_button" value="<?php echo elgg_echo("save"); ?>" />
+</form>
diff --git a/mod/pages/views/default/object/page.php b/mod/pages/views/default/object/page.php
new file mode 100644
index 000000000..6a872f3ae
--- /dev/null
+++ b/mod/pages/views/default/object/page.php
@@ -0,0 +1,21 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ if ($vars['full']) {
+ echo elgg_view("pages/pageprofile",$vars);
+ } else {
+ if (get_input('search_viewtype') == "gallery") {
+ echo elgg_view('pages/pagegallery',$vars);
+ } else {
+ echo elgg_view("pages/pagelisting",$vars);
+ }
+ }
+?> \ No newline at end of file
diff --git a/mod/pages/views/default/object/page_top.php b/mod/pages/views/default/object/page_top.php
new file mode 100644
index 000000000..6a872f3ae
--- /dev/null
+++ b/mod/pages/views/default/object/page_top.php
@@ -0,0 +1,21 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ if ($vars['full']) {
+ echo elgg_view("pages/pageprofile",$vars);
+ } else {
+ if (get_input('search_viewtype') == "gallery") {
+ echo elgg_view('pages/pagegallery',$vars);
+ } else {
+ echo elgg_view("pages/pagelisting",$vars);
+ }
+ }
+?> \ No newline at end of file
diff --git a/mod/pages/views/default/pages/breadcrumbs.php b/mod/pages/views/default/pages/breadcrumbs.php
new file mode 100644
index 000000000..52662b5bd
--- /dev/null
+++ b/mod/pages/views/default/pages/breadcrumbs.php
@@ -0,0 +1,28 @@
+<?php
+
+ $page_owner = $vars['page_owner'];
+ $parent = $vars['parent'];
+
+ $breadcrumbs = '';
+
+ $owner_url = $CONFIG->wwwroot . "pg/pages/owned/" . get_entity($page_owner)->username;
+ echo "<div id=\"pages_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/css.php b/mod/pages/views/default/pages/css.php
new file mode 100644
index 000000000..1fc1e5abb
--- /dev/null
+++ b/mod/pages/views/default/pages/css.php
@@ -0,0 +1,108 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+?>
+
+.treeview, .treeview ul {
+ padding: 0;
+ margin: 0;
+ list-style: none;
+}
+
+.treeview ul {
+ background-color: white;
+ margin-top: 4px;
+}
+
+.treeview .hitarea {
+ background: url(<?php echo $vars['url']; ?>mod/pages/images/treeview-default.gif) -64px -25px no-repeat;
+ height: 16px;
+ width: 16px;
+ margin-left: -16px;
+ float: left;
+ cursor: pointer;
+}
+/* fix for IE6 */
+* html .hitarea {
+ display: inline;
+ float:none;
+}
+
+.treeview li {
+ margin: 0;
+ padding: 3px 0pt 3px 16px;
+}
+
+.treeview a.selected {
+ background-color: #eee;
+}
+
+#treecontrol { margin: 1em 0; display: none; }
+
+.treeview .hover { color: red; cursor: pointer; }
+
+.treeview li { background: url(<?php echo $vars['url']; ?>mod/pages/images/treeview-default-line.gif) 0 0 no-repeat; }
+.treeview li.collapsable, .treeview li.expandable { background-position: 0 -176px; }
+
+.treeview .expandable-hitarea { background-position: -80px -3px; }
+
+.treeview li.last { background-position: 0 -1766px }
+.treeview li.lastCollapsable, .treeview li.lastExpandable { background-image: url(<?php echo $vars['url']; ?>mod/pages/images/treeview-default.gif); }
+.treeview li.lastCollapsable { background-position: 0 -111px }
+.treeview li.lastExpandable { background-position: -32px -67px }
+
+.treeview div.lastCollapsable-hitarea, .treeview div.lastExpandable-hitarea { background-position: 0; }
+
+.treeview-red li { background-image: url(<?php echo $vars['url']; ?>mod/pages/images/treeview-red-line.gif); }
+.treeview-red .hitarea, .treeview-red li.lastCollapsable, .treeview-red li.lastExpandable { background-image: url(<?php echo $vars['url']; ?>mod/pages/images/treeview-red.gif); }
+
+.treeview-black li { background-image: url(<?php echo $vars['url']; ?>mod/pages/images/treeview-black-line.gif); }
+.treeview-black .hitarea, .treeview-black li.lastCollapsable, .treeview-black li.lastExpandable { background-image: url(<?php echo $vars['url']; ?>mod/pages/images/treeview-black.gif); }
+
+.treeview-gray li { background-image: url(<?php echo $vars['url']; ?>mod/pages/images/treeview-gray-line.gif); }
+.treeview-gray .hitarea, .treeview-gray li.lastCollapsable, .treeview-gray li.lastExpandable { background-image: url(<?php echo $vars['url']; ?>mod/pages/images/treeview-gray.gif); }
+
+.treeview-famfamfam li { background-image: url(<?php echo $vars['url']; ?>mod/pages/images/treeview-famfamfam-line.gif); }
+.treeview-famfamfam .hitarea, .treeview-famfamfam li.lastCollapsable, .treeview-famfamfam li.lastExpandable { background-image: url(<?php echo $vars['url']; ?>mod/pages/images/treeview-famfamfam.gif); }
+
+
+.filetree li { padding: 3px 0 2px 16px; }
+.filetree span.folder, .filetree span.file { padding: 1px 0 1px 16px; display: block; }
+.filetree span.folder { background: url(<?php echo $vars['url']; ?>mod/pages/images/folder.gif) 0 0 no-repeat; }
+.filetree li.expandable span.folder { background: url(<?php echo $vars['url']; ?>mod/pages/images/folder-closed.gif) 0 0 no-repeat; }
+.filetree span.file { background: url(<?php echo $vars['url']; ?>mod/pages/images/file.gif) 0 0 no-repeat; }
+
+.pagesTreeContainer {
+ margin:0;
+ min-height: 200px;
+ }
+
+/* delete, Dave's test addition */
+
+#pages_page .strapline {
+ text-align:right;
+ border-top:1px solid #efefef;
+ margin:10px 0 10px 0;
+}
+
+#pages_page .tags {
+ padding:0 0 0 16px;
+ margin:10px 0 4px 0;
+ background:transparent url(<?php echo $vars['url']; ?>_graphics/icon_tag.gif) no-repeat scroll left 2px;
+}
+
+#pages_page img[align="left"] {
+ margin: 10px 20px 10px 0;
+ float:left;
+}
+#pages_page img[align="right"] {
+ margin: 10px 0 10px 10px;
+ float:right;
+}
+
diff --git a/mod/pages/views/default/pages/groupprofile_pages.php b/mod/pages/views/default/pages/groupprofile_pages.php
new file mode 100644
index 000000000..b32ccf3b0
--- /dev/null
+++ b/mod/pages/views/default/pages/groupprofile_pages.php
@@ -0,0 +1,9 @@
+<div id="group_pages_widget">
+<h2><?php echo elgg_echo("pages:groupprofile"); ?></h2>
+<?php
+
+ $objects = list_entities("object", "page_top", page_owner(), 5, false);
+ echo $objects;
+
+?>
+</div> \ No newline at end of file
diff --git a/mod/pages/views/default/pages/menu.php b/mod/pages/views/default/pages/menu.php
new file mode 100644
index 000000000..ca8620f70
--- /dev/null
+++ b/mod/pages/views/default/pages/menu.php
@@ -0,0 +1,14 @@
+<?php
+ /**
+ * Elgg Pages: Add group menu
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+?>
+<p class="user_menu_pages">
+ <a href="<?php echo $vars['url']; ?>pg/pages/owned/<?php echo $vars['entity']->username; ?>"><?php echo elgg_echo("pages"); ?></a>
+ </p> \ No newline at end of file
diff --git a/mod/pages/views/default/pages/metatags.php b/mod/pages/views/default/pages/metatags.php
new file mode 100644
index 000000000..895df6657
--- /dev/null
+++ b/mod/pages/views/default/pages/metatags.php
@@ -0,0 +1,22 @@
+<?php
+
+ $treeguid = get_input('treeguid');
+ if (empty($treeguid)) {
+ $treeguid = get_input('page_guid');
+ }
+
+?>
+
+ <script type="text/javascript" src="<?php echo $vars['url']; ?>mod/pages/javascript/jquery.treeview.js" ></script>
+ <script type="text/javascript" src="<?php echo $vars['url']; ?>mod/pages/javascript/jquery.treeview.async.js" ></script>
+ <script type="text/javascript">
+
+ $(document).ready( function() {
+
+ $("#pagesTree").treeview({
+ url: "<?php echo $vars['url']; ?>mod/pages/pagesTree.php",
+ currentpage: "<?php echo get_input('page_guid'); ?>"
+ }, "<?php echo $treeguid; ?>")
+
+ });
+ </script>
diff --git a/mod/pages/views/default/pages/pagegallery.php b/mod/pages/views/default/pages/pagegallery.php
new file mode 100644
index 000000000..b49150927
--- /dev/null
+++ b/mod/pages/views/default/pages/pagegallery.php
@@ -0,0 +1,37 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $icon = elgg_view(
+ "graphics/icon", array(
+ 'entity' => $vars['entity'],
+ 'size' => 'medium',
+ )
+ );
+
+ $info = "<div><p><b><a href=\"" . $vars['entity']->getUrl() . "\">" . $vars['entity']->title . "</a></b></p></div>";
+
+
+ $latest = $vars['entity']->getAnnotations('page', 1, 0, 'desc');
+ if ($latest) {
+ $latest = $latest[0];
+
+ $time_updated = $latest->time_created;
+ $owner_guid = $latest->owner_guid;
+ $owner = get_entity($owner_guid);
+
+
+ $info .= "<br /><div>".
+ strip_tags(substr($latest->value, 0, 100))
+ . "</div>";
+ }
+
+ echo elgg_view_listing($icon, $info);
+?> \ No newline at end of file
diff --git a/mod/pages/views/default/pages/pagelisting.php b/mod/pages/views/default/pages/pagelisting.php
new file mode 100644
index 000000000..a04e53bd4
--- /dev/null
+++ b/mod/pages/views/default/pages/pagelisting.php
@@ -0,0 +1,38 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $icon = elgg_view(
+ "graphics/icon", array(
+ 'entity' => $vars['entity'],
+ 'size' => 'small',
+ )
+ );
+
+ $info .= "<p><b><a href=\"" . $vars['entity']->getUrl() . "\">" . $vars['entity']->title . "</a></b></p>";
+
+
+ $latest = $vars['entity']->getAnnotations('page', 1, 0, 'desc');
+ if ($latest) {
+ $latest = $latest[0];
+
+ $time_updated = $latest->time_created;
+ $owner_guid = $latest->owner_guid;
+ $owner = get_entity($owner_guid);
+
+
+ $info .= "<p class=\"owner_timestamp\">".sprintf(elgg_echo("pages:strapline"),
+ friendly_time($time_updated),
+ "<a href=\"" . $owner->getURL() . "\">" . $owner->name ."</a>"
+ ) . "</p>";
+ }
+
+ echo elgg_view_listing($icon, $info);
+?> \ No newline at end of file
diff --git a/mod/pages/views/default/pages/pageprofile.php b/mod/pages/views/default/pages/pageprofile.php
new file mode 100644
index 000000000..e82e91728
--- /dev/null
+++ b/mod/pages/views/default/pages/pageprofile.php
@@ -0,0 +1,66 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ // Output body
+ $entity = $vars['entity'];
+
+ $rev = (int)get_input('rev');
+
+ if ($rev)
+ {
+ $latest = get_annotation($rev);
+ }
+ else
+ {
+ $latest = $entity->getAnnotations('page', 1, 0, 'desc');
+ if ($latest) $latest = $latest[0];
+ }
+
+?>
+
+ <div id="pages_page">
+
+<?php
+ if ($entity)
+ {
+ echo elgg_view('output/longtext', array('value' => /*$entity->description*/ $latest->value));
+
+?>
+ <!-- display tags -->
+ <p class="tags">
+ <?php
+
+ echo elgg_view('output/tags', array('tags' => $vars['entity']->tags));
+
+ ?>
+ </p>
+
+<?php
+ }
+
+ // last edit & by whome
+?>
+
+ <p class="strapline">
+ <?php
+
+ $time_updated = $latest->time_created;
+ $owner_guid = $latest->owner_guid;
+ $owner = get_entity($owner_guid);
+
+ echo sprintf(elgg_echo("pages:strapline"),
+ friendly_time($time_updated),
+ "<a href=\"" . $owner->getURL() . "\">" . $owner->name ."</a>"
+ );
+
+ ?>
+ </p>
+</div> \ No newline at end of file
diff --git a/mod/pages/views/default/pages/sidebar/sidebarthis.php b/mod/pages/views/default/pages/sidebar/sidebarthis.php
new file mode 100644
index 000000000..ffdc6c802
--- /dev/null
+++ b/mod/pages/views/default/pages/sidebar/sidebarthis.php
@@ -0,0 +1,82 @@
+[<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ global $CONFIG;
+ $entity = $vars['entity'];
+ $parent = $vars['entity']->parent_guid;
+
+ $currentpage = (int) get_input('currentpage');
+ if ($currentpage) {
+
+ $path = pages_get_path($currentpage);
+ $pathstring = implode(',',$path);
+
+ } else {
+ $path = array();
+ }
+
+ function pages_draw_child($childentity, $path) {
+
+ $child = "\n\t\t{\n";
+ $child .= "\t\t\t\"text\": \"<a href=\\\"{$childentity->getURL()}\\\">{$childentity->title}</a>\",\n";
+
+ $haschild = get_entities_from_metadata('parent_guid',$childentity->guid,'','',0,9999);
+ if ($haschild) {
+ if (in_array($childentity->getGUID(),$path)) {
+ $child .= "\t\t\t\"expanded\": true,";
+ $child .= "\t\t\t\"children\": [\n";
+
+ $childstring = "";
+ foreach($haschild as $subchild) {
+ if (!empty($childstring)) $childstring .= ", ";
+ $childstring .= pages_draw_child($subchild,$path);
+ }
+
+ $child .= $childstring . "\n\t\t\t]\n";
+ } else {
+ $child .= "\t\t\t\"id\": \"{$childentity->getGUID()}\",\n\t\t\t\"hasChildren\": true\n";
+ }
+
+ }
+ $child .= "\t\t}";
+ return $child;
+ }
+
+ if (!$parent) {
+ echo "{\n";
+ echo "\t\"text\": \"<a href=\\\"{$vars['entity']->getURL()}\\\">{$vars['entity']->title}</a>\",\n";
+ }
+ $children = "";
+ if (isset($vars['children']) && is_array($vars['children']) && (!isset($vars['fulltree']) || $vars['fulltree'] == 0)) {
+ if (!$parent) echo "\t" . '"expanded": true,' . "\n";
+ if (!$parent) echo "\t" . '"children": [' . "\n";
+ foreach($vars['children'] as $child) {
+ if (!empty($children)) $children .= ", \n";
+ /*
+ $children .= "\n\t\t{\n";
+ $children .= "\t\t\t\"text\": \"<a href=\\\"{$child->getURL()}\\\">{$child->title}</a>\",\n";
+
+ $haschild = get_entities_from_metadata('parent_guid',$child->guid,'','',0,10,0,'',0,true);
+ if ($haschild) {
+ $children .= "\t\t\t\"id\": \"{$child->getGUID()}\",\n\t\t\t\"hasChildren\": true\n";
+ }
+ $children .= "\t\t}";
+ */
+ $children .= pages_draw_child($child,$path);
+ }
+ echo $children;
+ if (!$parent) echo "\t\t" . ']' . "\n";
+
+ }
+
+ if (!$parent) echo "}";
+
+?>] \ No newline at end of file
diff --git a/mod/pages/views/default/pages/sidebar/starter.php b/mod/pages/views/default/pages/sidebar/starter.php
new file mode 100644
index 000000000..234ec28e5
--- /dev/null
+++ b/mod/pages/views/default/pages/sidebar/starter.php
@@ -0,0 +1,21 @@
+<?php
+
+ if (isset($vars['entity']) && $vars['entity'] instanceof ElggEntity) {
+
+?>
+
+<script type="text/javascript">
+
+ $(document).ready( function() {
+
+ $("#pagetree<?php echo $vars['entity']->getGUID(); ?>").click();
+
+ });
+
+</script>
+
+<?php
+
+ }
+
+?> \ No newline at end of file
diff --git a/mod/pages/views/default/pages/sidebar/tree.php b/mod/pages/views/default/pages/sidebar/tree.php
new file mode 100644
index 000000000..1424eeebe
--- /dev/null
+++ b/mod/pages/views/default/pages/sidebar/tree.php
@@ -0,0 +1,8 @@
+<?php
+
+?>
+<div id="sidebar_page_tree">
+ <h3><?php echo elgg_echo("pages:navigation"); ?></h3>
+ <div id="pagesTree" class="pagesTreeContainer"></div>
+</div>
+<br class="clearfloat" /> \ No newline at end of file
diff --git a/mod/pages/views/default/pages/sidebar/wrapper.php b/mod/pages/views/default/pages/sidebar/wrapper.php
new file mode 100644
index 000000000..08e6a5b7d
--- /dev/null
+++ b/mod/pages/views/default/pages/sidebar/wrapper.php
@@ -0,0 +1,7 @@
+<?php
+
+ echo "[";
+ echo $vars['body'];
+ echo "]";
+
+?> \ No newline at end of file
diff --git a/mod/pages/views/default/pages/welcome.php b/mod/pages/views/default/pages/welcome.php
new file mode 100644
index 000000000..0974ba151
--- /dev/null
+++ b/mod/pages/views/default/pages/welcome.php
@@ -0,0 +1,29 @@
+<?php
+
+ /**
+ * Elgg Pages welcome message
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ if($vars['entity']){
+
+ foreach($vars['entity'] as $welcome){
+
+ echo $welcome->description;
+
+ }
+
+ } else {
+
+?>
+
+ <p>Welcome to this Elgg pages plugin. This feature allows you to create pages on any topic and select who can view them and edit them.</p>
+
+<?php
+ }
+?> \ No newline at end of file
diff --git a/mod/pages/welcome.php b/mod/pages/welcome.php
new file mode 100644
index 000000000..ecd27b313
--- /dev/null
+++ b/mod/pages/welcome.php
@@ -0,0 +1,34 @@
+<?php
+ /**
+ * Elgg Pages welcome intro
+ * The user or group owner can set an introduction to their wiki pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+ gatekeeper();
+ global $CONFIG;
+
+ // Get the current page's owner
+ $page_owner = page_owner_entity();
+ if ($page_owner === false || is_null($page_owner)) {
+ $page_owner = $_SESSION['user'];
+ set_page_owner($page_owner->getGUID());
+ }
+
+ //get the owners welcome message if it exists
+ $welcome_message = get_entities("object", "pages_welcome", $page_owner->getGUID(), '', 1);
+
+ $title = elgg_echo("pages:welcome");
+ $area2 .= elgg_view_title($title);
+ $area2 .= elgg_view("forms/pages/editwelcome", array('entity' => $welcome_message, 'owner' => $page_owner));
+
+ $body = elgg_view_layout('two_column_left_sidebar', $area1, $area2);
+
+ page_draw($title, $body);
+?> \ No newline at end of file
diff --git a/mod/pages/world.php b/mod/pages/world.php
new file mode 100644
index 000000000..04ecd4312
--- /dev/null
+++ b/mod/pages/world.php
@@ -0,0 +1,51 @@
+<?php
+ /**
+ * Elgg Pages
+ *
+ * @package ElggPages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ global $CONFIG;
+
+ // Get the current page's owner
+ $page_owner = page_owner_entity();
+ if ($page_owner === false || is_null($page_owner)) {
+ $page_owner = $_SESSION['user'];
+ set_page_owner($_SESSION['guid']);
+ }
+
+ add_submenu_item(elgg_echo('pages:all'),$CONFIG->wwwroot."mod/pages/world.php");
+ if (($page_owner) && ($page_owner->canWriteToContainer($_SESSION['user']))){
+ add_submenu_item(elgg_echo('pages:new'), $CONFIG->url . "pg/pages/new/");
+ add_submenu_item(elgg_echo('pages:welcome'), $CONFIG->url . "pg/pages/welcome/");
+ add_submenu_item(sprintf(elgg_echo("pages:user"), page_owner_entity()->name), $CONFIG->url . "pg/pages/owned/" . page_owner_entity()->username);
+ }
+
+ $limit = get_input("limit", 10);
+ $offset = get_input("offset", 0);
+
+ $title = sprintf(elgg_echo("pages:all"),page_owner_entity()->name);
+
+
+ // Get objects
+ $context = get_context();
+
+ set_context('search');
+
+ $objects = list_entities("object", "page_top", 0, $limit, false);
+
+ set_context($context);
+
+ $body = elgg_view_title($title);
+ $body .= $objects;
+ $body = elgg_view_layout('two_column_left_sidebar','',$body);
+
+ // Finally draw the page
+ page_draw($title, $body);
+?> \ No newline at end of file