From 450b57bc95f405aebb1dc110bafc1b5def5041f4 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 21 Mar 2009 15:57:48 +0000 Subject: code cleanup --- edit.php | 8 ++----- edit_multi.php | 8 ++----- friends.php | 8 ++----- index.php | 2 +- newalbum.php | 34 +++++++++++--------------- thumbnail.php | 60 ++++++++++++++++++++++------------------------ upload.php | 9 ++----- view.php | 76 +++++++++++++++++++++++++++------------------------------- world.php | 18 ++++++-------- 9 files changed, 93 insertions(+), 130 deletions(-) diff --git a/edit.php b/edit.php index 2c202e402..4e6d0d2ec 100644 --- a/edit.php +++ b/edit.php @@ -1,14 +1,10 @@ - * @copyright Curverider Ltd 2008 - * @link http://elgg.com/ */ // Load Elgg engine - require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); - gatekeeper(); - + require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + gatekeeper(); + // 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']); - } - - $area2 = elgg_view_title(elgg_echo('album:add')); - $area2 .= elgg_view("tidypics/forms/edit"); - + $page_owner = page_owner_entity(); + if ($page_owner === false || is_null($page_owner)) { + $page_owner = $_SESSION['user']; + set_page_owner($_SESSION['guid']); + } + + $area2 = elgg_view_title(elgg_echo('album:add')); + $area2 .= elgg_view("tidypics/forms/edit"); + // Display page - page_draw(elgg_echo('album:add'),elgg_view_layout("two_column_left_sidebar", $area1, $area2, $area3 )); + page_draw(elgg_echo('album:add'),elgg_view_layout("two_column_left_sidebar", $area1, $area2, $area3 )); - ?> \ No newline at end of file diff --git a/thumbnail.php b/thumbnail.php index 0e6142cbb..b4c745ae2 100644 --- a/thumbnail.php +++ b/thumbnail.php @@ -1,46 +1,42 @@ getSubtype() == "image") { - // Get file thumbnail - if ($size == "small") { - $thumbfile = $file->smallthumb; - } else { - $thumbfile = $file->largethumb; - } + if ($file = get_entity($file_guid)) { + if ($file->getSubtype() == "image") { + // Get file thumbnail + if ($size == "small") { + $thumbfile = $file->smallthumb; + } else { + $thumbfile = $file->largethumb; + } - // Grab the file - if ($thumbfile && !empty($thumbfile)) { - $readfile = new ElggFile(); - $readfile->owner_guid = $file->owner_guid; - $readfile->setFilename($thumbfile); - //$mime = $file->getMimeType(); - $contents = $readfile->grabFile(); - } - } //end subtype comparison - } //end get_entity + // Grab the file + if ($thumbfile && !empty($thumbfile)) { + $readfile = new ElggFile(); + $readfile->owner_guid = $file->owner_guid; + $readfile->setFilename($thumbfile); + //$mime = $file->getMimeType(); + $contents = $readfile->grabFile(); + } + } //end subtype comparison + } //end get_entity // Open error image if file was not found if (!isset($contents) || is_null($contents) || $file->getSubtype()!='image') { @@ -49,7 +45,7 @@ } //end of default error image // Return the thumbnail and exit - header("Content-type: image"); - echo $contents; - exit; + header("Content-type: image"); + echo $contents; + exit; ?> \ No newline at end of file diff --git a/upload.php b/upload.php index 4fcf27695..062fec325 100644 --- a/upload.php +++ b/upload.php @@ -1,15 +1,10 @@ container_guid)->container_guid; - - if ($top_container) { - set_page_owner($top_container); - } else { - set_page_owner($entity->owner_guid); - } + //set "real" container - image container is the album , group/user is the album container + $top_container = get_entity($entity->container_guid)->container_guid; + + if ($top_container) { + set_page_owner($top_container); + } else { + set_page_owner($entity->owner_guid); + } // Set the body to be the full view of the entity, and the title to be its title - $area2 = elgg_view_entity($entity,true); - if ($shell) { - $body = elgg_view_layout('two_column_left_sidebar', '', $area1 . $area2); - } else { - $body = $area2; - } - - } else { - $body = elgg_echo('notfound'); - } - - // Display the page + $area2 = elgg_view_entity($entity,true); if ($shell) { - page_draw("", $body); + $body = elgg_view_layout('two_column_left_sidebar', '', $area1 . $area2); } else { - header("Content-type: text/html; charset=UTF-8"); - echo $body; + $body = $area2; } + } else { + $body = elgg_echo('notfound'); + } + + // Display the page + if ($shell) { + page_draw("", $body); + } else { + header("Content-type: text/html; charset=UTF-8"); + echo $body; + } + ?> \ No newline at end of file diff --git a/world.php b/world.php index 2e80f5393..d5dbf1f2a 100644 --- a/world.php +++ b/world.php @@ -1,25 +1,21 @@