]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
More code cleanup to pages.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 16 Jul 2010 15:25:25 +0000 (15:25 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 16 Jul 2010 15:25:25 +0000 (15:25 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@6730 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/pages/actions/pages/edit.php
mod/pages/history.php

index c4075a7bbc0b622b16731ffef76979c86b3976bc..004b81a25bf80c75a7d242ac9e3706079ae8f83f 100644 (file)
@@ -31,22 +31,22 @@ $parent_guid = (int)get_input('parent_guid', 0);
 // New or old?
 $page = NULL;
 $pages_guid = (int)get_input('pages_guid');
-if ($pages_guid)
-{
+
+if ($pages_guid) {
        $page = get_entity($pages_guid);
-       if (!$page->canEdit())
+       if (!$page->canEdit()) {
                $page = NULL; // if we can't edit it, go no further.
+       }
 
        //select river boolean to edit
        $which_river = 'edit';
-}
-else
-{
+} else {
        $page = new ElggObject();
-       if (!$parent_guid)
+       if (!$parent_guid) {
                $page->subtype = 'page_top';
-       else
+       } else {
                $page->subtype = 'page';
+       }
 
        // New instance, so set container_guid
        $container_guid = get_input('container_guid', $_SESSION['user']->getGUID());
@@ -60,44 +60,28 @@ else
 }
 
 // Have we got it? Can we edit it?
-if ($page instanceof ElggObject)
-{
-       // Yes we have, and yes we can.
-
+if ($page instanceof ElggObject) {
        // Save fields - note we always save latest description as both description and annotation
-       if (sizeof($input) > 0)
-       {
+       if (sizeof($input) > 0) {
                foreach($input as $shortname => $value) {
-                       if ((!$pages_guid) || (($pages_guid) && ($shortname != 'title')))
+                       if ((!$pages_guid) || (($pages_guid) && ($shortname != 'title'))) {
                                $page->$shortname = $value;
+                       }
                }
        }
 
-
-       // Validate create
-       if (!$page->title)
-       {
+       if (!$page->title) {
                register_error(elgg_echo("pages:notitle"));
 
                forward($_SERVER['HTTP_REFERER']);
-               exit;
        }
 
-       // Access ids
        $page->access_id = (int)get_input('access_id', ACCESS_PRIVATE);
-
-       // Write access id
        $page->write_access_id = (int)get_input('write_access_id', ACCESS_PRIVATE);
-
-       // Set parent
-       $page->parent_guid = $parent_guid;
-
-       // Ensure ultimate owner
+       $page->parent_guid = $parent_guid;\
        $page->owner_guid = ($page->owner_guid ? $page->owner_guid : $_SESSION['user']->guid);
 
-       // finally save
-       if ($page->save())
-       {
+       if ($page->save()) {
 
                // Now save description as an annotation
                $page->annotate('page', $page->description, $page->access_id);
@@ -108,30 +92,24 @@ if ($page instanceof ElggObject)
                unset($_SESSION['page_read_access']);
                unset($_SESSION['page_write_access']);
 
-
                system_message(elgg_echo("pages:saved"));
 
                //add to river
-               if($which_river == 'new')
+               if ($which_river == 'new') {
                        add_to_river('river/object/page/create','create',$_SESSION['user']->guid,$page->guid);
-               else
+               } else {
                        add_to_river('river/object/page/update','update',$_SESSION['user']->guid,$page->guid);
+               }
 
                // Forward to the user's profile
                forward($page->getUrl());
-               exit;
-       }
-       else
+       } else {
                register_error(elgg_echo('pages:notsaved'));
+       }
 
-}
-else
-{
+} else {
        register_error(elgg_echo("pages:noaccess"));
 }
 
-
 // Forward to the user's profile
-forward($page->getUrl());
-exit;
-?>
+forward($page->getUrl());
\ No newline at end of file
index c4e4c85fae2892b85b9507206c460974e2e2a8a9..d929a33c99b132589cc894ed952e5031ca257c3a 100644 (file)
@@ -29,19 +29,12 @@ $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, 'pageslinksgeneral');
 
 $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);
+$content = elgg_view_title($title);
+$content.= list_annotations($page_guid, 'page', $limit, false);
 
 pages_set_navigation_parent($pages);
-$area3 = elgg_view('pages/sidebar/tree');
+$sidebar = elgg_view('pages/sidebar/tree');
 
-$body = elgg_view_layout('one_column_with_sidebar', $area3, $area2);
+$body = elgg_view_layout('one_column_with_sidebar', $content, $sidebar);
 
 page_draw($title, $body);
\ No newline at end of file