aboutsummaryrefslogtreecommitdiff
path: root/mod/pages/lib/pages.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-01-22 16:36:30 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-01-22 16:36:30 +0000
commitaf5b59b518123a15a7182ebfe2487a9e10f67ee8 (patch)
tree4fcb24176b2b445acee48869aa816813f03352b6 /mod/pages/lib/pages.php
parent186f5474e37f9ebde09b9afe2c82fa711402b421 (diff)
downloadelgg-af5b59b518123a15a7182ebfe2487a9e10f67ee8.tar.gz
elgg-af5b59b518123a15a7182ebfe2487a9e10f67ee8.tar.bz2
more clean up of the pages plugin to use new HTML/CSS
git-svn-id: http://code.elgg.org/elgg/trunk@7898 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/pages/lib/pages.php')
-rw-r--r--mod/pages/lib/pages.php71
1 files changed, 68 insertions, 3 deletions
diff --git a/mod/pages/lib/pages.php b/mod/pages/lib/pages.php
index 943383fd7..e3ed3c822 100644
--- a/mod/pages/lib/pages.php
+++ b/mod/pages/lib/pages.php
@@ -6,10 +6,10 @@
/**
* Prepare the add/edit form variables
*
- * @param ElggOobject $page
+ * @param ElggObject $page
* @return array
*/
-function pages_prepare_form_vars($page = null) {
+function pages_prepare_form_vars($page = null, $parent_guid = 0) {
// input names => defaults
$values = array(
@@ -21,11 +21,12 @@ function pages_prepare_form_vars($page = null) {
'container_guid' => elgg_get_page_owner_guid(),
'guid' => null,
'entity' => $page,
+ 'parent_guid' => $parent_guid,
);
if ($page) {
foreach (array_keys($values) as $field) {
- $values[$field] = $file->$field;
+ $values[$field] = $page->$field;
}
}
@@ -39,3 +40,67 @@ function pages_prepare_form_vars($page = null) {
return $values;
}
+
+/**
+ * Register the navigation menu
+ *
+ * @param ElggEntity $container Container entity for the pages
+ */
+function pages_register_navigation_tree($container) {
+ if (!$container) {
+ return;
+ }
+
+ $top_pages = elgg_get_entities(array(
+ 'type' => 'object',
+ 'subtype' => 'page_top',
+ 'container_guid' => $container->getGUID,
+ ));
+
+ foreach ($top_pages as $page) {
+ elgg_register_menu_item('pages_nav', array(
+ 'name' => $page->getGUID(),
+ 'title' => $page->title,
+ 'url' => $page->getURL(),
+ ));
+
+ $stack = array();
+ array_push($stack, $page);
+ while (count($stack) > 0) {
+ $parent = array_pop($stack);
+ $children = elgg_get_entities_from_metadata(array(
+ 'type' => 'object',
+ 'subtype' => 'page',
+ 'metadata_name' => 'parent_guid',
+ 'metadata_value' => $parent->getGUID(),
+ ));
+
+ foreach ($children as $child) {
+ elgg_register_menu_item('pages_nav', array(
+ 'name' => $child->getGUID(),
+ 'title' => $child->title,
+ 'url' => $child->getURL(),
+ 'parent_name' => $parent->getGUID(),
+ ));
+ array_push($stack, $child);
+ }
+ }
+ }
+}
+
+/**
+ * Return the correct sidebar for a given entity
+ *
+ * @param ElggObject $entity
+ */
+function pages_get_entity_sidebar(ElggObject $entity, $fulltree = 0) {
+ $body = "";
+
+ $children = elgg_get_entities_from_metadata(array('metadata_names' => 'parent_guid', 'metadata_values' => $entity->guid, 'limit' => 9999));
+ $body .= elgg_view('pages/sidebar/sidebarthis', array('entity' => $entity,
+ 'children' => $children,
+ 'fulltree' => $fulltree));
+ //$body = elgg_view('pages/sidebar/wrapper', array('body' => $body));
+
+ return $body;
+}