]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
basic pages for viewing all/mine/friends and viewing an album
authorcash <cash.costello@gmail.com>
Sat, 19 Nov 2011 17:10:46 +0000 (12:10 -0500)
committercash <cash.costello@gmail.com>
Sat, 19 Nov 2011 17:10:46 +0000 (12:10 -0500)
19 files changed:
classes/TidypicsAlbum.php
classes/TidypicsImage.php
languages/en.php
pages/friends.php [deleted file]
pages/ownedalbums.php [deleted file]
pages/photos/album/view.php [new file with mode: 0644]
pages/photos/all.php [new file with mode: 0644]
pages/photos/friends.php [new file with mode: 0644]
pages/photos/owner.php [new file with mode: 0644]
pages/viewalbum.php [deleted file]
pages/world.php [deleted file]
start.php
views/default/object/album.php
views/default/object/album/full.php [new file with mode: 0644]
views/default/object/album/summary.php [new file with mode: 0644]
views/default/object/image.php
views/default/object/image/full.php [new file with mode: 0644]
views/default/object/image/summary.php [new file with mode: 0644]
views/default/tidypics/css.php

index e178acd5df51f175fbe6c40d45a7ffd34bfac7e3..1fbdb8ad8170085824aba9837fe96b6db44a2ab8 100644 (file)
@@ -17,6 +17,15 @@ class TidypicsAlbum extends ElggObject {
                parent::__construct($guid);
        }
 
+       /**
+        * Get the title of the photo album
+        * 
+        * @return string
+        */
+       public function getTitle() {
+               return $this->title;
+       }
+
        /**
         * Delete album
         *
@@ -70,6 +79,15 @@ class TidypicsAlbum extends ElggObject {
                return elgg_view_entity_list($images, $count, $offset, $limit, false, false, true);
        }
 
+       public function getCoverImageURL($size = 'small') {
+               if ($this->cover) {
+                       $url = "pg/photos/thumbnail/$this->cover/$size/";
+               } else {
+                       $url = "mod/tidypics/graphics/empty_album.png";
+               }
+               return elgg_normalize_url($url);
+       }
+
        /**
         * Get the GUID of the album cover
         * 
index 531d549120a11197e35b51a432d0f2f42b21b416..652cc9e9bdf1ccaf80f67dfa2b4ad230f471f2f8 100644 (file)
@@ -17,6 +17,19 @@ class TidypicsImage extends ElggFile {
                parent::__construct($guid);
        }
 
+       /**
+        * Get the title of the image
+        *
+        * @return string
+        */
+       public function getTitle() {
+               return $this->title;
+       }
+
+       public function getSrcUrl() {
+               return "pg/photos/thumbnail/$this->guid/small/";
+       }
+
        /**
         * delete image
         *
index 8bc66a5f62be1eff788997b1712b2031e88548c7..d6d934c20da5f7c8146ecdbbf8c47e03c88493bc 100644 (file)
@@ -11,11 +11,15 @@ $english = array(
                        'photos' => "Photos",
                        'album' => "Photo Album",
                        'albums' => "Photo Albums",
+
+                       'photos:add' => "Create album",
+                       'images:upload' => "Upload photos",
+
                        'album:slideshow' => "View slideshow",
                        'album:yours' => "Your photo albums",
                        'album:yours:friends' => "Your friends' photo albums",
                        'album:user' => "%s's photo albums",
-                       'album:friends' => "%s's friends' photo albums",
+                       'album:friends' => "Friends' photo albums",
                        'album:all' => "All site photo albums",
                        'album:group' => "Group albums",
                        'item:object:image' => "Photos",
@@ -104,6 +108,9 @@ $english = array(
                        'tidypics:uploader:basic' => 'You can upload up to 10 photos at a time (%s MB maximum per photo)',
                        'tidypics:sort:instruct' => 'Sort the album photos by dragging and dropping the images. Then click the save button.',
 
+               // albums
+                       'album:num' => '%s photos',
+
                //views
                        'image:total' => "Images in album:",
                        'image:by' => "Image added by",
diff --git a/pages/friends.php b/pages/friends.php
deleted file mode 100644 (file)
index d5dfdba..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-/**
- * Tidypics Friends Albums Listing
- *
- * List all the albums of someone's friends
- */
-
-include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
-
-$username = get_input('username');
-
-// if no username, redirect to world photo albums
-if (!$username) {
-       forward('pg/photos/world');
-}
-
-// setup title
-$user = get_user_by_username($username);
-if (!$user) {
-       forward('pg/photos/world');
-}
-if ($user->guid == get_loggedin_userid()) {
-       $title = elgg_echo('album:yours:friends');
-} else {
-       $title = sprintf(elgg_echo('album:friends'), $user->name);
-}
-
-$area2 = elgg_view_title($title);
-
-$albums = get_user_friends_objects($user->guid, 'album', 12);
-
-// get html for viewing list of photo albums
-set_context('search');
-set_input('search_viewtype', 'gallery'); // need to force gallery view
-$content = tp_view_entity_list($albums, count($albums), 0, 12, false, false, true);
-
-$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,));
-
-$body = elgg_view_layout('two_column_left_sidebar', '', $area2);
-
-page_draw($title, $body);
diff --git a/pages/ownedalbums.php b/pages/ownedalbums.php
deleted file mode 100644 (file)
index 9483512..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/**
- * tidypics photo gallery album listing page for a person/group
- *
- * Shows all the albums that belong to that person or group
- */
-
-include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
-
-// if this page belongs to a closed group, prevent anyone outside group from seeing
-if (is_callable('group_gatekeeper')) {
-       group_gatekeeper();
-}
-
-//get the owner of the current page
-$owner = page_owner_entity();
-
-
-//if page owner cannot be found, forward to world album list
-if (is_null($owner->username) || empty($owner->username)) {
-       forward('pg/photos/world');
-}
-
-
-// setup group menu for album index
-if ($owner instanceof ElggGroup) {
-       add_submenu_item(       sprintf(elgg_echo('album:group'),$owner->name),
-                       $CONFIG->wwwroot . "pg/photos/owned/" . $owner->username);
-       if (can_write_to_container(0, $owner->guid)) {
-               add_submenu_item(       elgg_echo('album:create'),
-                               $CONFIG->wwwroot . 'pg/photos/new/' . $owner->username,
-                               'tidypics');
-       }
-}
-
-//set the title
-$title = sprintf(elgg_echo('album:user'), $owner->name);
-$area2 = elgg_view_title($title);
-
-// Get objects
-set_context('search');
-set_input('search_viewtype', 'gallery');
-if ($owner instanceof ElggGroup) {
-       $content .= elgg_list_entities(array(
-               "type" => "object",
-               "subtype" => "album",
-               "container_guid" => $owner->guid,
-               "limit" => 12,
-               "full_view" => false,
-));
-} else {
-       $content .= elgg_list_entities(array(
-               "type" => "object",
-               "subtype" => "album",
-               "container_guid" => $owner->guid,
-               "limit" => 12,
-               "full_view" => false,
-));
-}
-
-$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,));
-
-set_context('photos');
-$body = elgg_view_layout('two_column_left_sidebar', '', $area2);
-
-// Finally draw the page
-page_draw($title, $body);
\ No newline at end of file
diff --git a/pages/photos/album/view.php b/pages/photos/album/view.php
new file mode 100644 (file)
index 0000000..adb5a1b
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * This displays the photos that belong to an album
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+group_gatekeeper();
+
+// get the album entity
+$album_guid = (int) get_input('guid');
+$album = get_entity($album_guid);
+if (!$album) {
+       
+}
+
+elgg_set_page_owner_guid($album->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo($album->getTitle());
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
+elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+elgg_push_breadcrumb($album->getTitle());
+
+$content = elgg_view_entity($album, array('full_view' => true));
+
+if ($album->canWriteToContainer()) {
+       elgg_register_menu_item('title', array(
+                       'name' => 'upload',
+                       'href' => 'photos/upload/' . $album->getGUID(),
+                       'text' => elgg_echo('images:upload'),
+                       'link_class' => 'elgg-button elgg-button-action',
+       ));
+}
+
+$body = elgg_view_layout('content', array(
+       'filter' => false,
+       'content' => $content,
+       'title' => $album->getTitle(),
+       'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'album')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/pages/photos/all.php b/pages/photos/all.php
new file mode 100644 (file)
index 0000000..edda65c
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+/**
+ * View all albums on the site
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+elgg_push_breadcrumb(elgg_echo('photos'));
+
+$num_albums = 16;
+
+elgg_push_context('tidypics:main');
+$offset = (int)get_input('offset', 0);
+$content = elgg_list_entities(array(
+       'type' => 'object',
+       'subtype' => 'album',
+       'limit' => $num_albums,
+       'full_view' => false,
+       'list_type' => 'gallery',
+       'list_type_toggle' => false,
+       'gallery_class' => 'tidypics-gallery',
+));
+elgg_pop_context();
+
+$title = elgg_echo('album:all');
+
+elgg_register_title_button('photos');
+
+$body = elgg_view_layout('content', array(
+       'filter_context' => 'all',
+       'content' => $content,
+       'title' => $title,
+       'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'all')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/pages/photos/friends.php b/pages/photos/friends.php
new file mode 100644 (file)
index 0000000..b7b6178
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+/**
+ * List all the albums of someone's friends
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$owner = elgg_get_page_owner_entity();
+
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+elgg_push_breadcrumb($owner->name, "photos/friends/$owner->username");
+elgg_push_breadcrumb(elgg_echo('friends'));
+
+$title = elgg_echo('album:friends');
+
+
+$num_albums = 16;
+
+elgg_push_context('tidypics:main');
+set_input('list_type', 'gallery');
+$content = list_user_friends_objects($owner->guid, 'album', $num_albums, false);
+elgg_pop_context();
+
+elgg_register_title_button();
+
+$body = elgg_view_layout('content', array(
+       'filter_context' => 'friends',
+       'content' => $content,
+       'title' => $title,
+));
+
+echo elgg_view_page($title, $body);
diff --git a/pages/photos/owner.php b/pages/photos/owner.php
new file mode 100644 (file)
index 0000000..f6582e3
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Show all the albums that belong to a user or group
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+group_gatekeeper();
+
+$owner = elgg_get_page_owner_entity();
+
+//set the title
+$title = elgg_echo('album:user', array($owner->name));
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), 'photos/all');
+elgg_push_breadcrumb($owner->name);
+
+
+$num_albums = 16;
+
+elgg_push_context('tidypics:main');
+$content = elgg_list_entities(array(
+       'type' => 'object',
+       'subtype' => 'album',
+       'container_guid' => $owner->getGUID(),
+       'limit' => $num_albums,
+       'full_view' => false,
+       'list_type' => 'gallery',
+       'list_type_toggle' => false,
+       'gallery_class' => 'tidypics-gallery',
+));
+elgg_pop_context();
+
+elgg_register_title_button();
+
+$body = elgg_view_layout('content', array(
+       'filter_context' => 'mine',
+       'content' => $content,
+       'title' => $title,
+       'sidebar' => elgg_view('tidypics/sidebar', array('page' => 'owner')),
+));
+
+echo elgg_view_page($title, $body);
diff --git a/pages/viewalbum.php b/pages/viewalbum.php
deleted file mode 100644 (file)
index 8705967..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-
-/**
- * Tidypics Album View Page
- *
- * This displays a listing of all the photos that belong to an album
- */
-
-include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
-
-// if this page belongs to a closed group, prevent anyone outside group from seeing
-if (is_callable('group_gatekeeper')) {
-       group_gatekeeper();
-}
-
-// get the album entity
-$album_guid = (int) get_input('guid');
-$album = get_entity($album_guid);
-
-// panic if we can't get it
-if (!$album) {
-       forward();
-}
-
-// container should always be set, but just in case
-if ($album->container_guid) {
-       set_page_owner($album->container_guid);
-} else {
-       set_page_owner($album->owner_guid);
-}
-
-$owner = page_owner_entity();
-
-// setup group menu
-if ($owner instanceof ElggGroup) {
-       add_submenu_item(       sprintf(elgg_echo('album:group'),$owner->name),
-                       $CONFIG->wwwroot . "pg/photos/owned/" . $owner->username);
-}
-
-// allow other plugins to override the slideshow
-$slideshow_link = trigger_plugin_hook('tp_slideshow', 'album', array('album' => $album), null);
-if ($slideshow_link) {
-       add_submenu_item(elgg_echo('album:slideshow'),
-                       $slideshow_link,
-                       'photos' );
-}
-
-if (can_write_to_container(0, $album->container_guid)) {
-       if ($owner instanceof ElggGroup) {
-               add_submenu_item(       elgg_echo('album:create'),
-                               $CONFIG->wwwroot . 'pg/photos/new/' . $owner->username,
-                               'photos');
-       }
-       add_submenu_item(       elgg_echo('album:addpix'),
-                       $CONFIG->wwwroot . 'pg/photos/upload/' . $album_guid,
-                       'photos');
-       add_submenu_item(       elgg_echo('album:sort'),
-                       $CONFIG->wwwroot . 'pg/photos/sort/' . $album_guid,
-                       'photos');
-       add_submenu_item(       elgg_echo('album:edit'),
-                       $CONFIG->wwwroot . 'pg/photos/edit/' . $album_guid,
-                       'photos');
-       $ts = time();
-       $token = generate_action_token($ts);
-       add_submenu_item(       elgg_echo('album:delete'),
-                       $CONFIG->wwwroot . 'action/tidypics/delete?guid=' . $album_guid . '&amp;__elgg_token=' . $token . '&amp;__elgg_ts=' . $ts,
-                       'photos',
-                       true);
-}
-
-// create body
-$area2 = elgg_view_entity($album, true);
-$body = elgg_view_layout('two_column_left_sidebar', '', $area2);
-
-page_draw($album->title, $body);
diff --git a/pages/world.php b/pages/world.php
deleted file mode 100644 (file)
index 4599f82..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-/**
- * Tidypics View All Albums on Site
- *
- */
-
-include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
-
-// set page owner to logged in user
-if (isloggedin()) {
-       set_page_owner(get_loggedin_userid());
-}
-
-$num_albums = 16;
-
-$title = elgg_echo('album:all');
-$area2 = elgg_view_title($title);
-
-set_context('search');
-set_input('search_viewtype', 'gallery');
-$content .= elgg_list_entities(array(
-       'type' => 'object',
-       'subtype' => 'album',
-       'limit' => $num_albums,
-));
-set_context('photos');
-
-$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,));
-
-$body = elgg_view_layout('two_column_left_sidebar', '', $area2);
-
-page_draw($title, $body);
index 167db651e4b0b48e70233517ca84f1b9b9be7304..ae52e7098d6c84d40d8d6b0c54f0893e7d24f005 100644 (file)
--- a/start.php
+++ b/start.php
@@ -1,8 +1,9 @@
 <?php
 /**
- * Elgg tidypics
+ * Photo Gallery plugin
  *
- * @license GPL2
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
  */
 
 // set some simple defines
@@ -11,8 +12,6 @@ define('TP_NEW_ALBUM', 1);
 
 // include core libraries
 require dirname(__FILE__) . "/lib/tidypics.php";
-require dirname(__FILE__) . "/classes/TidypicsImage.php";
-require dirname(__FILE__) . "/classes/TidypicsAlbum.php";
 
 
 // Make sure tidypics_init is called on initialization
@@ -24,13 +23,15 @@ register_elgg_event_handler('init', 'system', 'tidypics_init');
 function tidypics_init() {
        global $CONFIG;
 
-       // Set up menu for logged in users
-       if (isloggedin()) {
-               add_menu(elgg_echo('photos'), $CONFIG->wwwroot . "pg/photos/owned/" . $_SESSION['user']->username);
-       }
+       // Set up site menu
+       elgg_register_menu_item('site', array(
+               'name' => 'photos',
+               'href' => 'photos/all',
+               'text' => elgg_echo('photos'),
+       ));
 
        // Extend CSS
-       elgg_extend_view('css', 'tidypics/css');
+       elgg_extend_view('css/elgg', 'tidypics/css');
 
        // Extend hover-over and profile menu
        elgg_extend_view('profile/menu/links','tidypics/hover_menu');
@@ -42,11 +43,11 @@ function tidypics_init() {
        elgg_extend_view('extensions/xmlns', 'extensions/tidypics/xmlns');
        elgg_extend_view('extensions/channel', 'extensions/tidypics/channel');
 
-       // Register a page handler, so we can have nice URLs
-       register_page_handler('photos','tidypics_page_handler');
+       // Register a page handler so we can have nice URLs
+       elgg_register_page_handler('photos', 'tidypics_page_handler');
 
        // register for menus
-       register_elgg_event_handler('pagesetup', 'system', 'tidypics_submenus');
+       //register_elgg_event_handler('pagesetup', 'system', 'tidypics_submenus');
        register_elgg_event_handler('pagesetup', 'system', 'tidypics_adminmenu');
 
        // Add a new tidypics widget
@@ -248,145 +249,149 @@ function tidypics_mostviewed_submenus() {
 /**
  * tidypics page handler
  *
- * @param array $page Array of page elements, forwarded by the page handling mechanism
+ * @param array $page Array of url segments
  */
 function tidypics_page_handler($page) {
 
        global $CONFIG;
 
-       if (isset($page[0])) {
-               switch($page[0]) {
-                       case "owned":  //view list of albums owned by container
-                               if (isset($page[1])) {
-                                       set_input('username', $page[1]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/ownedalbums.php");
-                               break;
+       if (!isset($page[0])) {
+               return false;
+       }
 
-                       case "view": //view an image individually
-                               if (isset($page[1])) {
-                                       set_input('guid', $page[1]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/viewimage.php");
-                               break;
+       switch($page[0]) {
+               case "all": // all site albums
+               case "world":
+                       include($CONFIG->pluginspath . "tidypics/pages/photos/all.php");
+                       break;
 
-                       case "album": //view an album individually
-                               if (isset($page[1])) {
-                                       set_input('guid', $page[1]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/viewalbum.php");
-                               break;
+               case "owned":  // albums owned by container entity
+               case "owner":
+                       if (isset($page[1])) {
+                               set_input('username', $page[1]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/photos/owner.php");
+                       break;
 
-                       case "sort": //sort a photo album
-                               if (isset($page[1])) {
-                                       set_input('guid', $page[1]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/sortalbum.php");
-                               break;
+               case "friends": // albums of friends
+                       if (isset($page[1])) {
+                               set_input('username', $page[1]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/photos/friends.php");
+                       break;
 
-                       case "new":  //create new album
-                               if (isset($page[1])) {
-                                       set_input('username', $page[1]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/newalbum.php");
-                               break;
+               case "view": //view an image individually
+                       if (isset($page[1])) {
+                               set_input('guid', $page[1]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/viewimage.php");
+                       break;
 
-                       case "upload": //upload images to album
-                               if (isset($page[1])) {
-                                       set_input('album_guid', $page[1]);
-                               }
-                               if (isset($page[2])) {
-                                       set_input('uploader', 'basic');
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/upload.php");
-                               break;
+               case "album": //view an album individually
+                       if (isset($page[1])) {
+                               set_input('guid', $page[1]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/photos/album/view.php");
+                       break;
 
-                       case "edit": //edit image or album
-                               if (isset($page[1])) {
-                                       set_input('guid', $page[1]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/edit.php");
-                               break;
+               case "sort": //sort a photo album
+                       if (isset($page[1])) {
+                               set_input('guid', $page[1]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/sortalbum.php");
+                       break;
 
-                       case "batch": //update titles and descriptions
-                               if (isset($page[1])) {
-                                       set_input('batch', $page[1]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/edit_multiple.php");
-                               break;
+               case "new":  //create new album
+               case "add":
+                       if (isset($page[1])) {
+                               set_input('username', $page[1]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/newalbum.php");
+                       break;
 
-                       case "friends": // albums of friends
-                               if (isset($page[1])) {
-                                       set_input('username', $page[1]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/friends.php");
-                               break;
+               case "upload": //upload images to album
+                       if (isset($page[1])) {
+                               set_input('album_guid', $page[1]);
+                       }
+                       if (isset($page[2])) {
+                               set_input('uploader', 'basic');
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/upload.php");
+                       break;
 
-                       case "world": // all site albums
-                               include($CONFIG->pluginspath . "tidypics/pages/world.php");
-                               break;
+               case "edit": //edit image or album
+                       if (isset($page[1])) {
+                               set_input('guid', $page[1]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/edit.php");
+                       break;
 
-                       case "download": // download an image
-                               if (isset($page[1])) {
-                                       set_input('file_guid', $page[1]);
-                               }
-                               if (isset($page[2])) {
-                                       set_input('type', $page[2]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/download.php");
-                               break;
+               case "batch": //update titles and descriptions
+                       if (isset($page[1])) {
+                               set_input('batch', $page[1]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/edit_multiple.php");
+                       break;
 
-                       case "thumbnail": // tidypics thumbnail
-                               if (isset($page[1])) {
-                                       set_input('file_guid', $page[1]);
-                               }
-                               if (isset($page[2])) {
-                                       set_input('size', $page[2]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/thumbnail.php");
-                               break;
+               case "download": // download an image
+                       if (isset($page[1])) {
+                               set_input('file_guid', $page[1]);
+                       }
+                       if (isset($page[2])) {
+                               set_input('type', $page[2]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/download.php");
+                       break;
 
-                       case "tagged": // all photos tagged with user
-                               if (isset($page[1])) {
-                                       set_input('guid', $page[1]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/tagged.php");
-                               break;
+               case "thumbnail": // tidypics thumbnail
+                       if (isset($page[1])) {
+                               set_input('file_guid', $page[1]);
+                       }
+                       if (isset($page[2])) {
+                               set_input('size', $page[2]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/thumbnail.php");
+                       break;
 
-                       case "mostviewed": // images with the most views
-                               if (isset($page[1])) {
-                                       set_input('username', $page[1]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/lists/mostviewedimages.php");
-                               break;
+               case "tagged": // all photos tagged with user
+                       if (isset($page[1])) {
+                               set_input('guid', $page[1]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/tagged.php");
+                       break;
 
-                       case "mostrecent": // images uploaded most recently
-                               if (isset($page[1])) {
-                                       set_input('username', $page[1]);
-                               }
-                               include($CONFIG->pluginspath . "tidypics/pages/lists/mostrecentimages.php");
-                               break;
+               case "mostviewed": // images with the most views
+                       if (isset($page[1])) {
+                               set_input('username', $page[1]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/lists/mostviewedimages.php");
+                       break;
+
+               case "mostrecent": // images uploaded most recently
+                       if (isset($page[1])) {
+                               set_input('username', $page[1]);
+                       }
+                       include($CONFIG->pluginspath . "tidypics/pages/lists/mostrecentimages.php");
+                       break;
 
-                       case "recentlyviewed": // images most recently viewed
-                               include($CONFIG->pluginspath . "tidypics/pages/lists/recentlyviewed.php");
-                               break;
+               case "recentlyviewed": // images most recently viewed
+                       include($CONFIG->pluginspath . "tidypics/pages/lists/recentlyviewed.php");
+                       break;
 
-                       case "recentlycommented": // images with the most recent comments
-                               include($CONFIG->pluginspath . "tidypics/pages/lists/recentlycommented.php");
-                               break;
+               case "recentlycommented": // images with the most recent comments
+                       include($CONFIG->pluginspath . "tidypics/pages/lists/recentlycommented.php");
+                       break;
 
-                       case "highestrated": // images with the highest average rating
-                               include($CONFIG->pluginspath . "tidypics/pages/lists/highestrated.php");
-                               break;
+               case "highestrated": // images with the highest average rating
+                       include($CONFIG->pluginspath . "tidypics/pages/lists/highestrated.php");
+                       break;
 
-                       case "admin":
-                               include ($CONFIG->pluginspath . "tidypics/pages/admin.php");
-                               break;
-               }
-       }
-       else {
-               // going to all site albums if something goes wrong with the page handler
-               include($CONFIG->pluginspath . "tidypics/pages/world.php");
+               case "admin":
+                       include ($CONFIG->pluginspath . "tidypics/pages/admin.php");
+                       break;
+
+               default:
+                       return false;
        }
        
        return true;
index 13b94aed508499772f068c3b194988a2a74ceb3b..51b25b7da92937992aa6f07124ece0a80dc5c9d5 100644 (file)
 <?php
 /**
- * Tidypics Album Gallery View
- */
-
-global $CONFIG;
-
-$album = $vars['entity'];
-$album_guid = $album->getGUID();
-$owner = $album->getOwnerEntity();
-$tags = $album->tags;
-$title = $album->title;
-$desc = $album->description;
-$friendlytime = friendly_time($album->time_created);
-$mime = $album->mimetype;
-
-if (get_context() == "search") {
-
-       if (get_input('search_viewtype') == "gallery") {
-
-/******************************************************************************
- *
- *  Gallery view of an album object
+ * Album view
  * 
- *  This is called when looking at page of albums
- *
- *
- *****************************************************************************/
-
-               $album_cover_guid = $album->getCoverImageGuid();
-               if ($album_cover_guid) {
-                       $album_cover = '<img src="' . $vars['url'] . 'pg/photos/thumbnail/' . $album_cover_guid . '/small/" class="tidypics_album_cover" alt="' . $title . '"/>';
-               } else {
-                       $album_cover = '<img src="' . $vars['url'] . 'mod/tidypics/graphics/empty_album.png" class="tidypics_album_cover" alt="new album">';
-               }
-?>
-<div class="tidypics_album_gallery_item">
-       <div class="tidypics_gallery_title">
-               <a href="<?php echo $album->getURL();?>"><?php echo $title;?></a>
-       </div>
-       <a href="<?php echo $album->getURL();?>"><?php echo $album_cover;?></a><br>
-       <small><a href="<?php echo $vars['url'];?>pg/profile/<?php echo $owner->username;?>"><?php echo $owner->name;?></a>
-               <br /><?php echo $friendlytime;?><br />
-                               <?php
-                               //get the number of comments
-                               $numcomments = elgg_count_comments($album);
-                               if ($numcomments) {
-                                       echo "<a href=\"{$album->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a>";
-                               }
-?>
-       </small>
-</div>
-<?php
-       } else {
-/******************************************************************************
- *
- *  List view of an album object
+ * @uses $vars['entity'] TidypicsAlbum
  * 
- *  This is called when an album object is returned in a search.
- *
- *
- *****************************************************************************/
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
 
-               $info = '<p><a href="' . $album->getURL() . '">' . $title . '</a></p>';
-               $info .= "<p class=\"owner_timestamp\"><a href=\"{$vars['url']}pg/profile/{$owner->username}\">{$owner->name}</a> {$friendlytime}";
-               $numcomments = elgg_count_comments($album);
-               if ($numcomments) {
-                       $info .= ", <a href=\"{$album->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a>";
-               }
-               $info .= "</p>";
+$album = elgg_extract('entity', $vars);
+$full_view = elgg_extract('full_view', $vars, false);
 
-               $album_cover_guid = $album->getCoverImageGuid();
-               if ($album_cover_guid) {
-                       $icon = "<a href=\"{$album->getURL()}\">" . '<img src="' . $vars['url'] . 'mod/tidypics/thumbnail.php?file_guid=' . $album_cover_guid . '&size=thumb" alt="thumbnail" /></a>';
-               } else {
-                       $icon = "<a href=\"{$album->getURL()}\">" . '<img src="' . $vars['url'] . 'mod/tidypics/graphics/image_error_thumb.png" alt="new album"></a>';
-               }
-               echo elgg_view_listing($icon, $info);
-       }
+if ($full_view) {
+       echo elgg_view('object/album/full', $vars);
 } else {
-
-/******************************************************************************
- *
- *  Individual view of an album object
- * 
- *  This is called when getting a listing of the photos in an album
- *
- *
- *****************************************************************************/
-
-       $page = get_input("page");
-       list($album_placeholder, $album_id, $album_title) = split("/", $page);
-
-       $photo_ratings = get_plugin_setting('photo_ratings', 'tidypics');
-       if ($photo_ratings == "enabled") {
-               add_submenu_item(       elgg_echo("tidypics:highestrated"),
-                               $CONFIG->wwwroot . "pg/photos/highestrated/group:" . $album_id,
-                               'photos');
-       }
-       echo elgg_view_title($title);
-?>
-<div class="contentWrapper">
-       <div id="tidypics_breadcrumbs">
-                       <?php echo elgg_view('tidypics/breadcrumbs', array() ); ?>
-       </div>
-<?php
-       echo '<div id="tidypics_desc">' . autop($desc) . '</div>';
-
-       $offset = (int)get_input('offset', 0);
-       echo $album->viewImages(16, $offset);
-       //      echo '<div class="tidypics_info">' . elgg_echo('image:none') . '</div>';
-       //      $num_images = 0;
-       //}
-
-?>
-       <div class="clearfloat"></div>
-       <div class="tidypics_info">
-<?php
-
-       if (!is_null($tags)) {
-?>
-               <div class="object_tag_string"><?php echo elgg_view('output/tags',array('value' => $tags));?></div>
-<?php
-       }
-?>
-       <?php echo elgg_echo('album:by');?> <b><a href="<?php echo $vars['url'] ;?>pg/profile/<?php echo $owner->username; ?>"><?php echo $owner->name; ?></a></b>  <?php echo $friendlytime; ?><br>
-       <?php echo elgg_echo('image:total');?> <b><?php echo $album->getSize(); ?></b><br>
-<?php
-       $categories = elgg_view('categories/view',$vars);
-       if (!empty($categories)) {
-?>
-               <br />
-               <b><?php echo elgg_echo('categories'); ?>:</b>
-<?php
-
-       echo $categories;
-
-       }
-?>
-       </div>
-
-<?php
-
-       if ($vars['full']) {
-               echo elgg_view_comments($album);
-       }
-
-       echo '</div>';
-} // end of individual album view
-
+       echo elgg_view('object/album/summary', $vars);
+}
diff --git a/views/default/object/album/full.php b/views/default/object/album/full.php
new file mode 100644 (file)
index 0000000..7484a48
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * Full view of an album
+ *
+ * @uses $vars['entity'] TidypicsAlbum
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$album = elgg_extract('entity', $vars);
+$owner = $album->getOwnerEntity();
+
+$owner_icon = elgg_view_entity_icon($owner, 'tiny');
+
+$metadata = elgg_view_menu('entity', array(
+       'entity' => $album,
+       'handler' => 'photos',
+       'sort_by' => 'priority',
+       'class' => 'elgg-menu-hz',
+));
+
+$owner_link = elgg_view('output/url', array(
+       'href' => "photos/owner/$owner->username",
+       'text' => $owner->name,
+       'is_trusted' => true,
+));
+$author_text = elgg_echo('byline', array($owner_link));
+$date = elgg_view_friendly_time($album->time_created);
+$categories = elgg_view('output/categories', $vars);
+
+$subtitle = "$author_text $date $categories";
+
+$params = array(
+       'entity' => $album,
+       'title' => false,
+       'metadata' => $metadata,
+       'subtitle' => $subtitle,
+       'tags' => elgg_view('output/tags', array('tags' => $album->tags)),
+);
+$params = $params + $vars;
+$summary = elgg_view('object/elements/summary', $params);
+
+$body = elgg_list_entities(array(
+       'type' => 'object',
+       'subtype' => 'image',
+       'container_guid' => $album->getGUID(),
+       'limit' => 16,
+       'full_view' => false,
+       'list_type' => 'gallery',
+       'list_type_toggle' => false,
+       'gallery_class' => 'tidypics-gallery',
+));
+
+echo elgg_view('object/elements/full', array(
+       'entity' => $album,
+       'icon' => $owner_icon,
+       'summary' => $summary,
+       'body' => $body,
+));
diff --git a/views/default/object/album/summary.php b/views/default/object/album/summary.php
new file mode 100644 (file)
index 0000000..78eec35
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Summary of an album for lists/galleries
+ *
+ * @uses $vars['entity'] TidypicsAlbum
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$album = elgg_extract('entity', $vars);
+
+$album_cover = elgg_view('output/img', array(
+       'src' => $album->getCoverImageURL(),
+       'alt' => $album->getTitle(),
+       'class' => 'elgg-photo',
+));
+
+$header = elgg_view('output/url', array(
+       'text' => $album->getTitle(),
+       'href' => $album->getURL(),
+));
+
+$body = elgg_view('output/url', array(
+       'text' => $album_cover,
+       'href' => $album->getURL(),
+       'encode_text' => false,
+       'is_trusted' => true,
+));
+
+$footer = elgg_view('output/url', array(
+       'text' => $album->getContainerEntity()->name,
+       'href' => $album->getContainerEntity()->getURL(),
+       'is_trusted' => true,
+));
+$footer .= '<div class="elgg-subtext">' . elgg_echo('album:num', array($album->getSize())) . '</div>';
+
+$params = array(
+       'footer' => $footer,
+);
+echo elgg_view_module('tidypics-album', $header, $body, $params);
index 8c1f23ec279997dcda561f5f8fc014f759ea6108..12d58440d13c5fc00b1b373683c6d3a518d074a1 100644 (file)
@@ -1,9 +1,24 @@
 <?php
 /**
+ * Image view
  *
- * Tidypics image object views
+ * @uses $vars['entity'] TidypicsImage
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
  */
 
+
+$full_view = elgg_extract('full_view', $vars, false);
+
+if ($full_view) {
+       echo elgg_view('object/image/full', $vars);
+} else {
+       echo elgg_view('object/image/summary', $vars);
+}
+
+return true;
+
 global $CONFIG;
 include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/lib/exif.php";
 
diff --git a/views/default/object/image/full.php b/views/default/object/image/full.php
new file mode 100644 (file)
index 0000000..a4abe2d
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+
diff --git a/views/default/object/image/summary.php b/views/default/object/image/summary.php
new file mode 100644 (file)
index 0000000..71c1be6
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Summary of an image for lists/galleries
+ *
+ * @uses $vars['entity'] TidypicsImage
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$image = elgg_extract('entity', $vars);
+
+$img = elgg_view('output/img', array(
+       'src' => $image->getSrcURL(),
+       'alt' => $image->getTitle(),
+       'class' => 'elgg-photo',
+));
+
+$header = elgg_view('output/url', array(
+       'text' => $image->getTitle(),
+       'href' => $image->getURL(),
+));
+
+$body = elgg_view('output/url', array(
+       'text' => $img,
+       'href' => $image->getURL(),
+       'encode_text' => false,
+       'is_trusted' => true,
+));
+
+/*
+$footer = elgg_view('output/url', array(
+       'text' => $image->getContainerEntity()->name,
+       'href' => $image->getContainerEntity()->getURL(),
+       'is_trusted' => true,
+));
+$footer .= '<div class="elgg-subtext">' . elgg_echo('album:num', array($album->getSize())) . '</div>';
+*/
+
+$params = array(
+       'footer' => $footer,
+);
+echo elgg_view_module('tidypics-image', $header, $body, $params);
index 25a29fdc333de532e2baf892dc75f202d9c5450c..bf47d42b722eaae694d4ebc2a066deb2f6c9f081 100644 (file)
@@ -3,6 +3,18 @@
         * tidypics CSS extender
         */
 ?>
+
+.elgg-module-tidypics-album,
+.elgg-module-tidypics-image {
+       width: 161px;
+       text-align: center;
+       margin: 5px 10px;
+}
+
+<?php
+return true;
+?>
+
 /* ---- tidypics object views ---- */
 
 .tidypics_wrapper > table.entity_gallery {