From a965e8a7bb94d8ac870fd6b773a3aa7949db960a Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Fri, 13 Apr 2012 16:35:22 -0700 Subject: Using the original file name for photo title if none is specified. --- pages/photos/album/sort.php | 2 +- pages/photos/batch/edit.php | 2 +- pages/photos/image/view.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'pages') diff --git a/pages/photos/album/sort.php b/pages/photos/album/sort.php index a1d890be1..8b6d1bfc7 100644 --- a/pages/photos/album/sort.php +++ b/pages/photos/album/sort.php @@ -30,7 +30,7 @@ if (elgg_instanceof($owner, 'group')) { } else { elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username"); } -elgg_push_breadcrumb($album->title, $album->getURL()); +elgg_push_breadcrumb($album->getTitle(), $album->getURL()); elgg_push_breadcrumb(elgg_echo('album:sort')); diff --git a/pages/photos/batch/edit.php b/pages/photos/batch/edit.php index b96ddf408..ca9a55b18 100644 --- a/pages/photos/batch/edit.php +++ b/pages/photos/batch/edit.php @@ -29,7 +29,7 @@ $title = elgg_echo('tidypics:editprops'); elgg_push_breadcrumb(elgg_echo('photos'), "photos/all"); elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username"); -elgg_push_breadcrumb($album->title, $album->getURL()); +elgg_push_breadcrumb($album->getTitle(), $album->getURL()); elgg_push_breadcrumb($title); $content = elgg_view_form('photos/batch/edit', array(), array('batch' => $batch)); diff --git a/pages/photos/image/view.php b/pages/photos/image/view.php index 6db9ff529..6bd0257e0 100644 --- a/pages/photos/image/view.php +++ b/pages/photos/image/view.php @@ -36,8 +36,8 @@ if (elgg_instanceof($owner, 'group')) { } else { elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username"); } -elgg_push_breadcrumb($album->title, $album->getURL()); -elgg_push_breadcrumb($photo->title); +elgg_push_breadcrumb($album->getTitle(), $album->getURL()); +elgg_push_breadcrumb($photo->getTitle()); if (elgg_get_plugin_setting('download_link', 'tidypics')) { // add download button to title menu @@ -54,11 +54,11 @@ $content = elgg_view_entity($photo, array('full_view' => true)); $body = elgg_view_layout('content', array( 'filter' => false, 'content' => $content, - 'title' => $photo->title, + 'title' => $photo->getTitle(), 'sidebar' => elgg_view('tidypics/sidebar', array( 'page' => 'view', 'image' => $photo, )), )); -echo elgg_view_page($photo->title, $body); +echo elgg_view_page($photo->getTitle(), $body); -- cgit v1.2.3 From c1da32e6a7e2f4a15a3b2d69cd38a1c0c164a99d Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Fri, 8 Jun 2012 15:23:47 -0700 Subject: Fixed invalid SQL caused by sorting an empty album. Also hiding slideshow and sort links for albums with no images. --- actions/photos/album/sort.php | 7 +++++-- classes/TidypicsAlbum.php | 11 +++++++++-- languages/en.php | 2 ++ pages/photos/album/sort.php | 12 +++++++++++- start.php | 3 ++- views/default/photos/group_module.php | 2 +- 6 files changed, 30 insertions(+), 7 deletions(-) (limited to 'pages') diff --git a/actions/photos/album/sort.php b/actions/photos/album/sort.php index 453f51ac5..fd62a7ba7 100644 --- a/actions/photos/album/sort.php +++ b/actions/photos/album/sort.php @@ -12,7 +12,10 @@ if (!$album) { $guids = get_input('guids'); $guids = explode(',', $guids); -$album->setImageList($guids); +if ($album->setImageList($guids)) { + system_message(elgg_echo('tidypics:album:sorted', array($album->getTitle()))); +} else { + register_error(elgg_echo('tidypics:album:could_not_sort', array($album->getTitle()))); +} -system_message(elgg_echo('tidypics:album:sorted', array($album->getTitle()))); forward($album->getURL()); \ No newline at end of file diff --git a/classes/TidypicsAlbum.php b/classes/TidypicsAlbum.php index 1fd98c76b..57bdcf707 100644 --- a/classes/TidypicsAlbum.php +++ b/classes/TidypicsAlbum.php @@ -207,7 +207,7 @@ class TidypicsAlbum extends ElggObject { $list = unserialize($listString); // if empty don't need to check the permissions. - if (!$list) { + if (!$list || $list[0] == '') { return array(); } @@ -231,8 +231,15 @@ class TidypicsAlbum extends ElggObject { * @param array $list An indexed array of image guids */ public function setImageList($list) { + // validate data + foreach ($list as $guid) { + if (!filter_var($guid, FILTER_VALIDATE_INT)) { + return false; + } + } + $listString = serialize($list); - $this->orderedImages = $listString; + return $this->orderedImages = $listString; } /** diff --git a/languages/en.php b/languages/en.php index 0f7aa8d69..624b5234c 100644 --- a/languages/en.php +++ b/languages/en.php @@ -172,6 +172,7 @@ $english = array( 'tidypics:uploader:instructs' => 'There are three easy steps for adding photos to your album using this uploader: choosing, uploading, and describing them. If you do not have Flash, there is also a basic uploader available.', '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.', + 'tidypics:sort:no_images' => 'No images found to sort. Upload images using the link above.', // albums 'album:num' => '%s photos', @@ -256,6 +257,7 @@ The photo can be viewed here: %s", 'album:save_cover_image' => 'Cover image saved.', 'tidypics:settings:save:ok' => 'Successfully saved the Tidypics plugin settings', 'tidypics:album:sorted' => 'The album %s is sorted', + 'tidypics:album:could_not_sort' => 'Could not sort the album %s. Make sure there are images in the album and try again.', 'tidypics:upgrade:success' => 'Upgrade of Tidypics a success', //Error messages diff --git a/pages/photos/album/sort.php b/pages/photos/album/sort.php index 8b6d1bfc7..005205dd5 100644 --- a/pages/photos/album/sort.php +++ b/pages/photos/album/sort.php @@ -33,8 +33,18 @@ if (elgg_instanceof($owner, 'group')) { elgg_push_breadcrumb($album->getTitle(), $album->getURL()); elgg_push_breadcrumb(elgg_echo('album:sort')); +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', +)); -$content = elgg_view_form('photos/album/sort', array(), array('album' => $album)); +if ($album->getSize()) { + $content = elgg_view_form('photos/album/sort', array(), array('album' => $album)); +} else { + $content = elgg_echo('tidypics:sort:no_images'); +} $body = elgg_view_layout('content', array( 'filter' => false, diff --git a/start.php b/start.php index c56382655..13a9e2d85 100644 --- a/start.php +++ b/start.php @@ -347,7 +347,8 @@ function tidypics_entity_menu_setup($hook, $type, $return, $params) { } } - if (elgg_instanceof($entity, 'object', 'album')) { + // only show these options if there are images + if (elgg_instanceof($entity, 'object', 'album') && $entity->getSize() > 0) { $url = $entity->getURL() . '?limit=50&view=rss'; $url = elgg_format_url($url); $slideshow_link = "javascript:PicLensLite.start({maxScale:0, feedUrl:'$url'})"; diff --git a/views/default/photos/group_module.php b/views/default/photos/group_module.php index aa0e7b3ff..de7a451c4 100644 --- a/views/default/photos/group_module.php +++ b/views/default/photos/group_module.php @@ -3,7 +3,7 @@ * Group blog module */ -$group = elgg_get_page_owner_entity(); +$group = $vars['entity']; if ($group->photos_enable == "no") { return true; -- cgit v1.2.3