From a541f954cde5a9cc0a2c5fad0a01b6626ffccc0d Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Tue, 15 Feb 2011 13:29:54 -0700 Subject: [PATCH 01/16] Update bit.ly README. Added twitter README. --- 3.1/modules/bitly/README | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/3.1/modules/bitly/README b/3.1/modules/bitly/README index d89fe4fe..3c385366 100644 --- a/3.1/modules/bitly/README +++ b/3.1/modules/bitly/README @@ -1,12 +1,12 @@ ABOUT: Shorten Gallery's album and item links using bit.ly's URL shortening service. -INSTALLATION AND CONFIGURATION INSTRUCTIONS: +INSTALLATION AND CONFIGURATION: http://codex.gallery2.org/Gallery3:Modules:bitly -QUESTIONS, COMMENTS? -http://2tbsp.com/content/bitly-module-gallery-3 +SUPPORT/BUG REPORTS: +http://gallery.menalto.com/node/100816 ROADMAP: -- Provide multi-user support. -- Display shortened link statistics (clicks, etc.) +* Provide multi-user support. +* Display shortened link statistics (clicks, etc.) From 0bd89b69b6c3f8062b8408c35926691bee42f593 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Wed, 16 Feb 2011 22:29:43 -0700 Subject: [PATCH 02/16] Check to see if we have an item before adding Twitter site_menu item. --- 3.1/modules/twitter/helpers/twitter_event.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/3.1/modules/twitter/helpers/twitter_event.php b/3.1/modules/twitter/helpers/twitter_event.php index 5dc810d6..81b78c28 100644 --- a/3.1/modules/twitter/helpers/twitter_event.php +++ b/3.1/modules/twitter/helpers/twitter_event.php @@ -28,8 +28,8 @@ class twitter_event_Core { } static function site_menu($menu, $theme) { - if ((identity::active_user()->id > 1) && twitter::is_registered()) { - $item = $theme->item(); + $item = $theme->item(); + if ($item && twitter::is_registered() && (identity::active_user()->id > 1)) { $menu->get("options_menu") ->append(Menu::factory("dialog") ->id("twitter") From a7aea129fb8843b372c0cc7049e8dd4058724500 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Wed, 16 Feb 2011 23:22:01 -0700 Subject: [PATCH 03/16] Added README. --- 3.1/modules/twitter/README | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 3.1/modules/twitter/README diff --git a/3.1/modules/twitter/README b/3.1/modules/twitter/README new file mode 100644 index 00000000..e63d9ea1 --- /dev/null +++ b/3.1/modules/twitter/README @@ -0,0 +1,15 @@ +ABOUT: +Share photos, movies, and albums on Twitter, directly from Gallery. + +INSTALLATION AND CONFIGURATION: +http://codex.gallery2.org/Gallery3:Modules:twitter + +SUPPORT/BUG REPORTS: +http://gallery.menalto.com/node/100791 + +ROADMAP: +* Provide a reset access token button on the user's profile. +* Display Twitter profile/follow links on Gallery user profile pages. +* Provide "Share on Twitter" for anonymous users. +* Display item (re)tweets. +* Twitter identity provider (log into Gallery with Twitter) From 34923c773f8e306a4ca438b07cb6ad82b04a3c3e Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Wed, 16 Feb 2011 23:22:48 -0700 Subject: [PATCH 04/16] Truncate default tweet values longer than 140. --- 3.1/modules/twitter/helpers/twitter.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/3.1/modules/twitter/helpers/twitter.php b/3.1/modules/twitter/helpers/twitter.php index ceea12f5..506da5c4 100644 --- a/3.1/modules/twitter/helpers/twitter.php +++ b/3.1/modules/twitter/helpers/twitter.php @@ -60,6 +60,7 @@ class twitter_Core { * Get tweet form * @param object $item * @return Forge + * @todo Truncate the $tweet at 140 - strlen($url) */ static function get_tweet_form($item) { $long_url = url::abs_site($item->relative_url_cache); @@ -81,7 +82,16 @@ class twitter_Core { } else { $url = url::abs_site($item->relative_url_cache); } - $tweet = preg_replace("/%url/", $url, $tweet); + + // Truncate the default tweet if it's too long + $url_length = strlen($url) + 1; + $tweet_length = strlen($tweet); + + if (($tweet_length + $url_length) > self::$character_count) { + $trim_pos = 0 - (($tweet_length + $url_length) - 140); + $tweet = substr($tweet, 0, $trim_pos); + } + $tweet = $tweet . ' ' . $url; $form = new Forge("twitter/tweet/$item->id", "", "post", array("id" => "g-twitter-tweet-form")); $group = $form->group("twitter_message")->label(t("Compose Tweet")); @@ -134,7 +144,7 @@ class twitter_Core { } static function reset_default_tweet() { - return t("Check out this %type, '%title': %description %url"); + return t("Check out this %type, '%title': %description"); } } From 3d7ebaf747b5e78ca7372e322ad67ba718e82e6c Mon Sep 17 00:00:00 2001 From: colings Date: Mon, 21 Feb 2011 14:39:44 -0600 Subject: [PATCH 05/16] Updated embed_videos to insert its Javascript later in the page, so jQuery will be initialized. --- 3.0/modules/embed_videos/helpers/embed_videos_theme.php | 2 +- 3.1/modules/embed_videos/helpers/embed_videos_theme.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/3.0/modules/embed_videos/helpers/embed_videos_theme.php b/3.0/modules/embed_videos/helpers/embed_videos_theme.php index bf921b21..61b7000a 100644 --- a/3.0/modules/embed_videos/helpers/embed_videos_theme.php +++ b/3.0/modules/embed_videos/helpers/embed_videos_theme.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class embed_videos_theme_Core { - static function head($theme) { + static function page_top($theme) { $item = $theme->item(); if ($item && $item->is_photo()) { $embedded_video = ORM::factory("embedded_video") diff --git a/3.1/modules/embed_videos/helpers/embed_videos_theme.php b/3.1/modules/embed_videos/helpers/embed_videos_theme.php index bf921b21..61b7000a 100644 --- a/3.1/modules/embed_videos/helpers/embed_videos_theme.php +++ b/3.1/modules/embed_videos/helpers/embed_videos_theme.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class embed_videos_theme_Core { - static function head($theme) { + static function page_top($theme) { $item = $theme->item(); if ($item && $item->is_photo()) { $embedded_video = ORM::factory("embedded_video") From abef6b5dab244ed9296ec5c157190c7f23af1ca4 Mon Sep 17 00:00:00 2001 From: colings Date: Mon, 21 Feb 2011 15:42:48 -0600 Subject: [PATCH 06/16] Updated modules that use graphics rules, and updated a couple that called gallery_graphics::resize directly. --- 3.1/modules/ecard/controllers/ecard.php | 4 ++-- 3.1/modules/max_size/helpers/max_size_event.php | 3 ++- .../rectangle_thumbs/helpers/rectangle_thumbs_graphics.php | 2 +- 3.1/modules/square_thumbs/helpers/square_thumbs_graphics.php | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/3.1/modules/ecard/controllers/ecard.php b/3.1/modules/ecard/controllers/ecard.php index 82777443..21a87080 100644 --- a/3.1/modules/ecard/controllers/ecard.php +++ b/3.1/modules/ecard/controllers/ecard.php @@ -62,11 +62,11 @@ class Ecard_Controller extends Controller { $tmpfile = tempnam(TMPPATH, "clean"); if($form->send_ecard->send_thumbnail->checked == true) { $options = array("width" => module::get_var("gallery", "thumb_size"), "height" => module::get_var("gallery", "thumb_size"), "master" => Image::AUTO); - gallery_graphics::resize($item->file_path(), $tmpfile, $options); + gallery_graphics::resize($item->file_path(), $tmpfile, $options, $item); $mime->addHTMLImage($tmpfile,$item->mime_type,$item->name); } else { $options = array("width" => module::get_var("gallery", "resize_size"), "height" => module::get_var("gallery", "resize_size"), "master" => Image::AUTO); - gallery_graphics::resize($item->file_path(), $tmpfile, $options); + gallery_graphics::resize($item->file_path(), $tmpfile, $options, $item); $mime->addHTMLImage($tmpfile,$item->mime_type,$item->name); } } else { diff --git a/3.1/modules/max_size/helpers/max_size_event.php b/3.1/modules/max_size/helpers/max_size_event.php index 4e1a69ae..be879e56 100644 --- a/3.1/modules/max_size/helpers/max_size_event.php +++ b/3.1/modules/max_size/helpers/max_size_event.php @@ -28,7 +28,8 @@ class max_size_event_Core { $tmpfile = $tempnam . "." . pathinfo($item->data_file, PATHINFO_EXTENSION); gallery_graphics::resize( $item->data_file, $tmpfile, - array("width" => $max_size, "height" => $max_size, "master" => Image::AUTO)); + array("width" => $max_size, "height" => $max_size, "master" => Image::AUTO), + $item); rename($tmpfile, $item->data_file); unlink($tempnam); } diff --git a/3.1/modules/rectangle_thumbs/helpers/rectangle_thumbs_graphics.php b/3.1/modules/rectangle_thumbs/helpers/rectangle_thumbs_graphics.php index fc431b46..63fd066f 100644 --- a/3.1/modules/rectangle_thumbs/helpers/rectangle_thumbs_graphics.php +++ b/3.1/modules/rectangle_thumbs/helpers/rectangle_thumbs_graphics.php @@ -27,7 +27,7 @@ class rectangle_thumbs_graphics_Core { * @param string $output_file * @param array $options */ - static function crop_to_aspect_ratio($input_file, $output_file, $options) { + static function crop_to_aspect_ratio($input_file, $output_file, $options, $item) { graphics::init_toolkit(); if (@filesize($input_file) == 0) { diff --git a/3.1/modules/square_thumbs/helpers/square_thumbs_graphics.php b/3.1/modules/square_thumbs/helpers/square_thumbs_graphics.php index a8641039..32a0b28a 100644 --- a/3.1/modules/square_thumbs/helpers/square_thumbs_graphics.php +++ b/3.1/modules/square_thumbs/helpers/square_thumbs_graphics.php @@ -25,7 +25,7 @@ class square_thumbs_graphics_Core { * @param string $output_file * @param array $options */ - static function crop_to_square($input_file, $output_file, $options) { + static function crop_to_square($input_file, $output_file, $options, $item) { graphics::init_toolkit(); if (@filesize($input_file) == 0) { From e88d458c7484b015c5b40a98d76afb4b43c72444 Mon Sep 17 00:00:00 2001 From: colings Date: Wed, 23 Feb 2011 20:30:23 -0600 Subject: [PATCH 07/16] Added extra item arg for gallery_graphics changes --- 3.1/modules/autorotate/helpers/autorotate.php | 2 +- 3.1/modules/embed_videos/controllers/embedded_videos.php | 2 +- 3.1/modules/gwtorganise/controllers/json_album.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/3.1/modules/autorotate/helpers/autorotate.php b/3.1/modules/autorotate/helpers/autorotate.php index bf531d01..50cc1ab3 100644 --- a/3.1/modules/autorotate/helpers/autorotate.php +++ b/3.1/modules/autorotate/helpers/autorotate.php @@ -42,7 +42,7 @@ class autorotate { } if($degrees) { $tmpfile = tempnam(TMPPATH, "rotate"); - gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees)); + gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees), $item); // Update EXIF info $data = new PelDataWindow(file_get_contents($tmpfile)); if (PelJpeg::isValid($data)) { diff --git a/3.1/modules/embed_videos/controllers/embedded_videos.php b/3.1/modules/embed_videos/controllers/embedded_videos.php index fc7281f2..f49d4220 100644 --- a/3.1/modules/embed_videos/controllers/embedded_videos.php +++ b/3.1/modules/embed_videos/controllers/embedded_videos.php @@ -106,7 +106,7 @@ class Embedded_videos_Controller extends Controller { $file = fopen($temp_filename, "wb"); fwrite($file, $content); fclose($file); - gallery_graphics::composite($temp_filename, $temp_filename, array("file" => "modules/embed_videos/images/embed_video_icon.png", "position" => "center", "transparency" => 95)); + gallery_graphics::composite($temp_filename, $temp_filename, array("file" => "modules/embed_videos/images/embed_video_icon.png", "position" => "center", "transparency" => 95), $item); $item->set_data_file($temp_filename); $item->name = basename($itemname); $item->title = $title; diff --git a/3.1/modules/gwtorganise/controllers/json_album.php b/3.1/modules/gwtorganise/controllers/json_album.php index bb682fb7..542efb01 100644 --- a/3.1/modules/gwtorganise/controllers/json_album.php +++ b/3.1/modules/gwtorganise/controllers/json_album.php @@ -247,7 +247,7 @@ class Json_Album_Controller extends Controller { } if ($degrees) { - gallery_graphics::rotate($item->file_path(), $item->file_path(), array("degrees" => $degrees)); + gallery_graphics::rotate($item->file_path(), $item->file_path(), array("degrees" => $degrees), $item); list($item->width, $item->height) = getimagesize($item->file_path()); $item->resize_dirty= 1; From fadd3ff8b83673c3610d632aa71afb972a29858a Mon Sep 17 00:00:00 2001 From: rWatcher Date: Wed, 2 Mar 2011 15:58:19 -0500 Subject: [PATCH 08/16] When in hide only mode, auto log the user in to the album their viewing. --- .../controllers/albumpassword.php | 2 ++ 3.0/modules/albumpassword/helpers/MY_item.php | 22 ++++++++++++++++++- .../helpers/albumpassword_event.php | 10 ++++++++- .../controllers/albumpassword.php | 2 ++ 3.1/modules/albumpassword/helpers/MY_item.php | 22 ++++++++++++++++++- .../helpers/albumpassword_event.php | 10 ++++++++- 6 files changed, 64 insertions(+), 4 deletions(-) diff --git a/3.0/modules/albumpassword/controllers/albumpassword.php b/3.0/modules/albumpassword/controllers/albumpassword.php index dfedcd2c..83ff4f0e 100644 --- a/3.0/modules/albumpassword/controllers/albumpassword.php +++ b/3.0/modules/albumpassword/controllers/albumpassword.php @@ -115,6 +115,7 @@ class albumpassword_Controller extends Controller { public function logout() { // Delete a stored password cookie. cookie::delete("g3_albumpassword"); + cookie::delete("g3_albumpassword_id"); url::redirect(url::abs_site("albums/1")); } @@ -135,6 +136,7 @@ class albumpassword_Controller extends Controller { if (count($existing_password) > 0) { // If the password if valid, then store it, and display a success message. // If not, close the dialog and display a rejected message. + cookie::delete("g3_albumpassword_id"); cookie::set("g3_albumpassword", $album_password); message::success(t("Password Accepted.")); print "\n\n\n\n\n"; diff --git a/3.0/modules/albumpassword/helpers/MY_item.php b/3.0/modules/albumpassword/helpers/MY_item.php index e26b65c6..07f81906 100644 --- a/3.0/modules/albumpassword/helpers/MY_item.php +++ b/3.0/modules/albumpassword/helpers/MY_item.php @@ -34,11 +34,31 @@ class item extends item_Core { $model->and_open()->join("albumpassword_idcaches", "items.id", "albumpassword_idcaches.item_id", "LEFT OUTER") ->and_where("albumpassword_idcaches.item_id", "IS", NULL); + // If in hide only mode, check and see if the current item is protected. + // If it is, log the user in with the password to view it. + if (module::get_var("albumpassword", "hideonly") == true) { + $existing_cacheditem = ORM::factory("albumpassword_idcache")->where("item_id", "=", $model->id)->order_by("cache_id")->find_all(); + if (count($existing_cacheditem) > 0) { + $existing_cacheditem_password = ORM::factory("items_albumpassword")->where("id", "=", $existing_cacheditem[0]->password_id)->find_all(); + if (cookie::get("g3_albumpassword") != $existing_cacheditem_password[0]->password) { + cookie::set("g3_albumpassword", $existing_cacheditem_password[0]->password); + cookie::set("g3_albumpassword_id", $existing_cacheditem_password[0]->id); + $model->or_where("albumpassword_idcaches.password_id", "=", $existing_cacheditem_password[0]->id); + } + } + } + // ... Unless their password id corresponds with a valid password. $existing_password = ORM::factory("items_albumpassword")->where("password", "=", cookie::get("g3_albumpassword"))->find_all(); if (count($existing_password) > 0) { foreach ($existing_password as $one_password) { - $model->or_where("albumpassword_idcaches.password_id", "=", $one_password->id); + if (cookie::get("g3_albumpassword_id") != "") { + if (cookie::get("g3_albumpassword_id") == $one_password->id) { + $model->or_where("albumpassword_idcaches.password_id", "=", $one_password->id); + } + } else { + $model->or_where("albumpassword_idcaches.password_id", "=", $one_password->id); + } } } diff --git a/3.0/modules/albumpassword/helpers/albumpassword_event.php b/3.0/modules/albumpassword/helpers/albumpassword_event.php index 0c9210ea..1201400d 100644 --- a/3.0/modules/albumpassword/helpers/albumpassword_event.php +++ b/3.0/modules/albumpassword/helpers/albumpassword_event.php @@ -48,9 +48,17 @@ class albumpassword_event_Core { ->css_id("g-album-password-logout") ->url(url::site("albumpassword/logout")) ->label(t("Clear password"))); - $existing_password = ORM::factory("items_albumpassword") + $existing_password = ""; + if (cookie::get("g3_albumpassword_id") != "") { + $existing_password = ORM::factory("items_albumpassword") + ->where("password", "=", cookie::get("g3_albumpassword")) + ->where("id", "=", cookie::get("g3_albumpassword_id")) + ->find_all(); + } else { + $existing_password = ORM::factory("items_albumpassword") ->where("password", "=", cookie::get("g3_albumpassword")) ->find_all(); + } if (count($existing_password) > 0) { $counter = 0; while ($counter < count($existing_password)) { diff --git a/3.1/modules/albumpassword/controllers/albumpassword.php b/3.1/modules/albumpassword/controllers/albumpassword.php index dfedcd2c..83ff4f0e 100644 --- a/3.1/modules/albumpassword/controllers/albumpassword.php +++ b/3.1/modules/albumpassword/controllers/albumpassword.php @@ -115,6 +115,7 @@ class albumpassword_Controller extends Controller { public function logout() { // Delete a stored password cookie. cookie::delete("g3_albumpassword"); + cookie::delete("g3_albumpassword_id"); url::redirect(url::abs_site("albums/1")); } @@ -135,6 +136,7 @@ class albumpassword_Controller extends Controller { if (count($existing_password) > 0) { // If the password if valid, then store it, and display a success message. // If not, close the dialog and display a rejected message. + cookie::delete("g3_albumpassword_id"); cookie::set("g3_albumpassword", $album_password); message::success(t("Password Accepted.")); print "\n\n\n\n\n"; diff --git a/3.1/modules/albumpassword/helpers/MY_item.php b/3.1/modules/albumpassword/helpers/MY_item.php index e26b65c6..07f81906 100644 --- a/3.1/modules/albumpassword/helpers/MY_item.php +++ b/3.1/modules/albumpassword/helpers/MY_item.php @@ -34,11 +34,31 @@ class item extends item_Core { $model->and_open()->join("albumpassword_idcaches", "items.id", "albumpassword_idcaches.item_id", "LEFT OUTER") ->and_where("albumpassword_idcaches.item_id", "IS", NULL); + // If in hide only mode, check and see if the current item is protected. + // If it is, log the user in with the password to view it. + if (module::get_var("albumpassword", "hideonly") == true) { + $existing_cacheditem = ORM::factory("albumpassword_idcache")->where("item_id", "=", $model->id)->order_by("cache_id")->find_all(); + if (count($existing_cacheditem) > 0) { + $existing_cacheditem_password = ORM::factory("items_albumpassword")->where("id", "=", $existing_cacheditem[0]->password_id)->find_all(); + if (cookie::get("g3_albumpassword") != $existing_cacheditem_password[0]->password) { + cookie::set("g3_albumpassword", $existing_cacheditem_password[0]->password); + cookie::set("g3_albumpassword_id", $existing_cacheditem_password[0]->id); + $model->or_where("albumpassword_idcaches.password_id", "=", $existing_cacheditem_password[0]->id); + } + } + } + // ... Unless their password id corresponds with a valid password. $existing_password = ORM::factory("items_albumpassword")->where("password", "=", cookie::get("g3_albumpassword"))->find_all(); if (count($existing_password) > 0) { foreach ($existing_password as $one_password) { - $model->or_where("albumpassword_idcaches.password_id", "=", $one_password->id); + if (cookie::get("g3_albumpassword_id") != "") { + if (cookie::get("g3_albumpassword_id") == $one_password->id) { + $model->or_where("albumpassword_idcaches.password_id", "=", $one_password->id); + } + } else { + $model->or_where("albumpassword_idcaches.password_id", "=", $one_password->id); + } } } diff --git a/3.1/modules/albumpassword/helpers/albumpassword_event.php b/3.1/modules/albumpassword/helpers/albumpassword_event.php index 0c9210ea..1201400d 100644 --- a/3.1/modules/albumpassword/helpers/albumpassword_event.php +++ b/3.1/modules/albumpassword/helpers/albumpassword_event.php @@ -48,9 +48,17 @@ class albumpassword_event_Core { ->css_id("g-album-password-logout") ->url(url::site("albumpassword/logout")) ->label(t("Clear password"))); - $existing_password = ORM::factory("items_albumpassword") + $existing_password = ""; + if (cookie::get("g3_albumpassword_id") != "") { + $existing_password = ORM::factory("items_albumpassword") + ->where("password", "=", cookie::get("g3_albumpassword")) + ->where("id", "=", cookie::get("g3_albumpassword_id")) + ->find_all(); + } else { + $existing_password = ORM::factory("items_albumpassword") ->where("password", "=", cookie::get("g3_albumpassword")) ->find_all(); + } if (count($existing_password) > 0) { $counter = 0; while ($counter < count($existing_password)) { From b7d542f8ca76bad47e0c904882975d0b574a9766 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Wed, 2 Mar 2011 16:05:54 -0500 Subject: [PATCH 09/16] Changed the wording on the admin screen to explain the new hide only functionality. --- 3.0/modules/albumpassword/controllers/admin_albumpassword.php | 2 +- 3.0/modules/albumpassword/views/admin_albumpassword.html.php | 2 +- 3.1/modules/albumpassword/controllers/admin_albumpassword.php | 2 +- 3.1/modules/albumpassword/views/admin_albumpassword.html.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/3.0/modules/albumpassword/controllers/admin_albumpassword.php b/3.0/modules/albumpassword/controllers/admin_albumpassword.php index 035978c7..d146a194 100644 --- a/3.0/modules/albumpassword/controllers/admin_albumpassword.php +++ b/3.0/modules/albumpassword/controllers/admin_albumpassword.php @@ -40,7 +40,7 @@ class Admin_Albumpassword_Controller extends Admin_Controller { // Should protected items be hidden, or completely in-accessable? $albumpassword_group = $form->group("album_password_group"); $albumpassword_group->checkbox("hideonly") - ->label("Only hide protected albums?") + ->label(t("Do not require passwords")) ->checked(module::get_var("albumpassword", "hideonly")); // Add a save button to the form. diff --git a/3.0/modules/albumpassword/views/admin_albumpassword.html.php b/3.0/modules/albumpassword/views/admin_albumpassword.html.php index 05e46454..93544e63 100644 --- a/3.0/modules/albumpassword/views/admin_albumpassword.html.php +++ b/3.0/modules/albumpassword/views/admin_albumpassword.html.php @@ -4,6 +4,6 @@
-

+

diff --git a/3.1/modules/albumpassword/controllers/admin_albumpassword.php b/3.1/modules/albumpassword/controllers/admin_albumpassword.php index 035978c7..d146a194 100644 --- a/3.1/modules/albumpassword/controllers/admin_albumpassword.php +++ b/3.1/modules/albumpassword/controllers/admin_albumpassword.php @@ -40,7 +40,7 @@ class Admin_Albumpassword_Controller extends Admin_Controller { // Should protected items be hidden, or completely in-accessable? $albumpassword_group = $form->group("album_password_group"); $albumpassword_group->checkbox("hideonly") - ->label("Only hide protected albums?") + ->label(t("Do not require passwords")) ->checked(module::get_var("albumpassword", "hideonly")); // Add a save button to the form. diff --git a/3.1/modules/albumpassword/views/admin_albumpassword.html.php b/3.1/modules/albumpassword/views/admin_albumpassword.html.php index 05e46454..93544e63 100644 --- a/3.1/modules/albumpassword/views/admin_albumpassword.html.php +++ b/3.1/modules/albumpassword/views/admin_albumpassword.html.php @@ -4,6 +4,6 @@
-

+

From 4cfaa3dd4e954199cf89e3ca81e15e1b919392c8 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Wed, 2 Mar 2011 16:17:01 -0500 Subject: [PATCH 10/16] Updated "Tags module required" alerts and implimented the tags modules auto-complete function. --- .../batchtag/helpers/batchtag_event.php | 6 ++ .../batchtag/helpers/batchtag_installer.php | 9 +- .../batchtag/views/batchtag_block.html.php | 15 +++- 3.1/modules/batchtag/controllers/batchtag.php | 85 +++++++++++++++---- .../batchtag/helpers/batchtag_event.php | 6 ++ .../batchtag/helpers/batchtag_installer.php | 9 +- .../batchtag/views/batchtag_block.html.php | 15 +++- 7 files changed, 124 insertions(+), 21 deletions(-) diff --git a/3.0/modules/batchtag/helpers/batchtag_event.php b/3.0/modules/batchtag/helpers/batchtag_event.php index c0e61d3f..aedceacd 100644 --- a/3.0/modules/batchtag/helpers/batchtag_event.php +++ b/3.0/modules/batchtag/helpers/batchtag_event.php @@ -18,6 +18,12 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class batchtag_event_Core { + static function pre_deactivate($data) { + if ($data->module == "tag") { + $data->messages["warn"][] = t("The BatchTag module requires the Tags module."); + } + } + static function module_change($changes) { // See if the Tags module is installed, // tell the user to install it if it isn't. diff --git a/3.0/modules/batchtag/helpers/batchtag_installer.php b/3.0/modules/batchtag/helpers/batchtag_installer.php index 56096fb8..d0c03163 100644 --- a/3.0/modules/batchtag/helpers/batchtag_installer.php +++ b/3.0/modules/batchtag/helpers/batchtag_installer.php @@ -24,10 +24,17 @@ class batchtag_installer { } static function deactivate() { - // Clear the require tags message when metadescription is deactivated. site_status::clear("batchtag_needs_tag"); } + static function can_activate() { + $messages = array(); + if (!module::is_active("tag")) { + $messages["warn"][] = t("The BatchTag module requires the Tags module."); + } + return $messages; + } + static function uninstall() { module::delete("batchtag"); } diff --git a/3.0/modules/batchtag/views/batchtag_block.html.php b/3.0/modules/batchtag/views/batchtag_block.html.php index 9f820b35..c46603ca 100644 --- a/3.0/modules/batchtag/views/batchtag_block.html.php +++ b/3.0/modules/batchtag/views/batchtag_block.html.php @@ -1,2 +1,15 @@ - \ No newline at end of file + + diff --git a/3.1/modules/batchtag/controllers/batchtag.php b/3.1/modules/batchtag/controllers/batchtag.php index 023cff34..01f2e7ff 100644 --- a/3.1/modules/batchtag/controllers/batchtag.php +++ b/3.1/modules/batchtag/controllers/batchtag.php @@ -25,42 +25,93 @@ class BatchTag_Controller extends Controller { access::verify_csrf(); $input = Input::instance(); + url::redirect(url::abs_site("batchtag/tagitems2?name={$input->post('name')}&item_id={$input->post('item_id')}&tag_subitems={$input->post('tag_subitems')}&csrf={$input->post('csrf')}")); + } + + public function tagitems2() { + // Tag all non-album items in the current album with the specified tags. + + // Prevent Cross Site Request Forgery + access::verify_csrf(); + + $input = Input::instance(); + + // Variables + if (($input->get("batchtag_max") == false) || ($input->get("batchtag_max") == "0")) { + $batchtag_max = "50"; + } else { + $batchtag_max = $input->get("batchtag_max"); + } + if ($input->get("batchtag_items_processed") == false) { + $batchtag_items_processed = "0"; + } else { + $batchtag_items_processed = $input->get("batchtag_items_processed"); + } + // Figure out if the contents of sub-albums should also be tagged - $str_tag_subitems = $input->post("tag_subitems"); + $str_tag_subitems = $input->get("tag_subitems"); $children = ""; if ($str_tag_subitems == false) { // Generate an array of all non-album items in the current album. $children = ORM::factory("item") - ->where("parent_id", "=", $input->post("item_id")) + ->where("parent_id", "=", $input->get("item_id")) ->where("type", "!=", "album") ->find_all(); } else { // Generate an array of all non-album items in the current album // and any sub albums. - $item = ORM::factory("item", $input->post("item_id")); + $item = ORM::factory("item", $input->get("item_id")); $children = $item->descendants(); } + // Loop through each item in the album and make sure the user has // access to view and edit it. - foreach ($children as $child) { - if (access::can("view", $child) && access::can("edit", $child) && !$child->is_album()) { + $children_count = "0"; + $tag_count = "0"; - // Assuming the user can view/edit the current item, loop - // through each tag that was submitted and apply it to - // the current item. - foreach (explode(",", $input->post("name")) as $tag_name) { - $tag_name = trim($tag_name); - if ($tag_name) { - tag::add($child, $tag_name); + //echo Kohana::debug($children); + + echo ''; + + foreach ($children as $child) { + + if ($tag_count < $batchtag_max) { + + if ($children_count >= $batchtag_items_processed) { + if (access::can("view", $child) && access::can("edit", $child) && !$child->is_album()) { + + // Assuming the user can view/edit the current item, loop + // through each tag that was submitted and apply it to + // the current item. + foreach (explode(",", $input->get("name")) as $tag_name) { + $tag_name = trim($tag_name); + if ($tag_name) { + tag::add($child, $tag_name); + } + // $tag_count should be inside the foreach loop as it is depending on the number of time tag:add is run + $tag_count++; + } } - } - } + echo '' . "\n"; + $children_count++; + $batchtag_max_new = $tag_count; + echo ''; + } else { $children_count++; } + + } else { break; } + } - // Redirect back to the album. - $item = ORM::factory("item", $input->post("item_id")); - url::redirect(url::abs_site("{$item->type}s/{$item->id}")); + if ($tag_count < $batchtag_max) { + // Redirect back to the album. + $item = ORM::factory("item", $input->get("item_id")); + url::redirect(url::abs_site("{$item->type}s/{$item->id}")); + //echo url::abs_site("{$item->type}s/{$item->id}"); + } else { + url::redirect(url::abs_site("batchtag/tagitems2?name={$input->get('name')}&item_id={$input->get('item_id')}&tag_subitems={$input->get('tag_subitems')}&batchtag_items_processed=$children_count&batchtag_max=$batchtag_max&csrf={$input->get('csrf')}")); + //echo url::abs_site("batchtag/tagitems2?name={$input->get('name')}&item_id={$input->get('item_id')}&tag_subitems={$input->get('tag_subitems')}&batchtag_items_processed=$children_count&batchtag_max=$batchtag_max&csrf={$input->get('csrf')}"); + } } } diff --git a/3.1/modules/batchtag/helpers/batchtag_event.php b/3.1/modules/batchtag/helpers/batchtag_event.php index c0e61d3f..aedceacd 100644 --- a/3.1/modules/batchtag/helpers/batchtag_event.php +++ b/3.1/modules/batchtag/helpers/batchtag_event.php @@ -18,6 +18,12 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class batchtag_event_Core { + static function pre_deactivate($data) { + if ($data->module == "tag") { + $data->messages["warn"][] = t("The BatchTag module requires the Tags module."); + } + } + static function module_change($changes) { // See if the Tags module is installed, // tell the user to install it if it isn't. diff --git a/3.1/modules/batchtag/helpers/batchtag_installer.php b/3.1/modules/batchtag/helpers/batchtag_installer.php index 56096fb8..d0c03163 100644 --- a/3.1/modules/batchtag/helpers/batchtag_installer.php +++ b/3.1/modules/batchtag/helpers/batchtag_installer.php @@ -24,10 +24,17 @@ class batchtag_installer { } static function deactivate() { - // Clear the require tags message when metadescription is deactivated. site_status::clear("batchtag_needs_tag"); } + static function can_activate() { + $messages = array(); + if (!module::is_active("tag")) { + $messages["warn"][] = t("The BatchTag module requires the Tags module."); + } + return $messages; + } + static function uninstall() { module::delete("batchtag"); } diff --git a/3.1/modules/batchtag/views/batchtag_block.html.php b/3.1/modules/batchtag/views/batchtag_block.html.php index 9f820b35..c46603ca 100644 --- a/3.1/modules/batchtag/views/batchtag_block.html.php +++ b/3.1/modules/batchtag/views/batchtag_block.html.php @@ -1,2 +1,15 @@ - \ No newline at end of file + + From 753cc5809de50d1ae8cddcb2bfff4ebbd699f724 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Thu, 3 Mar 2011 16:30:25 -0500 Subject: [PATCH 11/16] Only run 1 db query instead of 367 queries. --- .../views/calendarview_year.html.php | 208 ++++++------------ .../views/calendarview_year.html.php | 208 ++++++------------ 2 files changed, 124 insertions(+), 292 deletions(-) diff --git a/3.0/modules/calendarview/views/calendarview_year.html.php b/3.0/modules/calendarview/views/calendarview_year.html.php index be739c79..1b47dbcf 100644 --- a/3.0/modules/calendarview/views/calendarview_year.html.php +++ b/3.0/modules/calendarview/views/calendarview_year.html.php @@ -9,170 +9,86 @@


"; - - // Figure out if any photos were taken for the current month. - if ($calendar_user == "-1") { - $month_count = ORM::factory("item") - ->viewable() - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, $counter_months+1, 1, $calendar_year)) - ->find_all() - ->count(); - } else { - $month_count = ORM::factory("item") - ->viewable() - ->where("owner_id", "=", $calendar_user) - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, $counter_months+1, 1, $calendar_year)) - ->find_all() - ->count(); - } - if ($month_count > 0) { - $month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/"); - } else { - $month_url = ""; - } - $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url); - - // If there are photos, loop through each day in the month and display links on the correct dates. - if ($month_count > 0) { - $curr_day = 1; - $MAX_DAYS = date('t', mktime(00, 00, 00, $counter_months, 1, $calendar_year)); - while ($curr_day < $MAX_DAYS) { - if ($calendar_user == "-1") { - $day_count = ORM::factory("item") - ->viewable() - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year)) - ->find_all() - ->count(); - } else { - $day_count = ORM::factory("item") - ->viewable() - ->where("owner_id", "=", $calendar_user) - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year)) - ->find_all() - ->count(); - } - if ($day_count > 0) { - $calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day)); - } - $curr_day++; - } - - // Do the last day of the month seperately, because the mktime code is different. - if ($calendar_user == "-1") { - $day_count = ORM::factory("item") - ->viewable() - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year)) - ->where("captured", "<",mktime(0, 0, 0, ($counter_months + 1), 1, $calendar_year)) - ->find_all() - ->count(); - } else { - $day_count = ORM::factory("item") - ->viewable() - ->where("owner_id", "=", $calendar_user) - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, ($counter_months + 1), 1, $calendar_year)) - ->find_all() - ->count(); - } - if ($day_count > 0) { - $calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS)); - } - } - echo $calendar->render(); - print ""; - $counter_months++; - } - - // Do December seperately, because the mktime code is different. - print "
"; + // Search the db for all photos that were taken during the selected year. if ($calendar_user == "-1") { - $month_count = ORM::factory("item") + $items_for_year = ORM::factory("item") ->viewable() ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year)) + ->where("captured", ">=", mktime(0, 0, 0, 1, 1, $calendar_year)) ->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1))) - ->find_all() - ->count(); + ->order_by("captured") + ->find_all(); } else { - $month_count = ORM::factory("item") + $items_for_year = ORM::factory("item") ->viewable() ->where("owner_id", "=", $calendar_user) ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year)) + ->where("captured", ">=", mktime(0, 0, 0, 1, 1, $calendar_year)) ->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1))) - ->find_all() - ->count(); + ->order_by("captured") + ->find_all(); } - if ($month_count > 0) { + + // Set up some initial variables. + $counter_months = 1; + $counter_days = 0; + $counter = 0; + + // Set up the January Calendar. + // Check and see if any photos were taken in January, + // If so, make the month title into a clickable link. + print "
"; + if (date("n", $items_for_year[$counter]->captured) == 1) { $month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/"); } else { $month_url = ""; } $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url); - if ($month_count > 0) { - $curr_day = 1; - $MAX_DAYS = date('t', mktime(00, 00, 00, $counter_months, 1, $calendar_year)); - while ($curr_day < $MAX_DAYS) { - if ($calendar_user == "-1") { - $day_count = ORM::factory("item") - ->viewable() - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year)) - ->find_all() - ->count(); + + // Loop through each photo taken during this year, and see what month and day they were taken on. + // Make the corresponding dates on the calendars into clickable links. + while ($counter < (count($items_for_year))) { + + // Check and see if we've switched to a new month. + // If so, render the current calendar and set up a new one. + while (date("n", $items_for_year[$counter]->captured) > $counter_months) { + echo $calendar->render(); + print "
"; + $counter_months++; + $counter_days = 0; + print "
"; + if (date("n", $items_for_year[$counter]->captured) == $counter_months) { + $month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/"); } else { - $day_count = ORM::factory("item") - ->viewable() - ->where("owner_id", "=", $calendar_user) - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year)) - ->find_all() - ->count(); + $month_url = ""; } - if ($day_count > 0) { - $calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day)); - } - $curr_day++; - } - if ($calendar_user == "-1") { - $day_count = ORM::factory("item") - ->viewable() - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, 1, 1, $calendar_year+1)) - ->find_all() - ->count(); - } else { - $day_count = ORM::factory("item") - ->viewable() - ->where("owner_id", "=", $calendar_user) - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, 1, 1, $calendar_year+1)) - ->find_all() - ->count(); - } - if ($day_count > 0) { - $calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS)); + $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url); } + + // If the day of the current photo is different then the day of the previous photo, + // then add a link to the calendar for this date and set the current day to this day. + if (date("j", $items_for_year[$counter]->captured) > $counter_days) { + $counter_days = date("j", $items_for_year[$counter]->captured); + $calendar->event($counter_days, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $counter_days)); + } + + // Move onto the next photo. + $counter++; } - $counter_months++; + + // Print out the last calendar to be generated. echo $calendar->render(); print "
"; -?> \ No newline at end of file + $counter_months++; + + // If the calendar that was previously rendered was not December, + // then print out a few empty months for the rest of the year. + while ($counter_months < 13) { + print "
"; + $month_url = ""; + $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url); + echo $calendar->render(); + print "
"; + $counter_months++; + } +?> diff --git a/3.1/modules/calendarview/views/calendarview_year.html.php b/3.1/modules/calendarview/views/calendarview_year.html.php index be739c79..1b47dbcf 100644 --- a/3.1/modules/calendarview/views/calendarview_year.html.php +++ b/3.1/modules/calendarview/views/calendarview_year.html.php @@ -9,170 +9,86 @@


"; - - // Figure out if any photos were taken for the current month. - if ($calendar_user == "-1") { - $month_count = ORM::factory("item") - ->viewable() - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, $counter_months+1, 1, $calendar_year)) - ->find_all() - ->count(); - } else { - $month_count = ORM::factory("item") - ->viewable() - ->where("owner_id", "=", $calendar_user) - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, $counter_months+1, 1, $calendar_year)) - ->find_all() - ->count(); - } - if ($month_count > 0) { - $month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/"); - } else { - $month_url = ""; - } - $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url); - - // If there are photos, loop through each day in the month and display links on the correct dates. - if ($month_count > 0) { - $curr_day = 1; - $MAX_DAYS = date('t', mktime(00, 00, 00, $counter_months, 1, $calendar_year)); - while ($curr_day < $MAX_DAYS) { - if ($calendar_user == "-1") { - $day_count = ORM::factory("item") - ->viewable() - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year)) - ->find_all() - ->count(); - } else { - $day_count = ORM::factory("item") - ->viewable() - ->where("owner_id", "=", $calendar_user) - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year)) - ->find_all() - ->count(); - } - if ($day_count > 0) { - $calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day)); - } - $curr_day++; - } - - // Do the last day of the month seperately, because the mktime code is different. - if ($calendar_user == "-1") { - $day_count = ORM::factory("item") - ->viewable() - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year)) - ->where("captured", "<",mktime(0, 0, 0, ($counter_months + 1), 1, $calendar_year)) - ->find_all() - ->count(); - } else { - $day_count = ORM::factory("item") - ->viewable() - ->where("owner_id", "=", $calendar_user) - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, ($counter_months + 1), 1, $calendar_year)) - ->find_all() - ->count(); - } - if ($day_count > 0) { - $calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS)); - } - } - echo $calendar->render(); - print "
"; - $counter_months++; - } - - // Do December seperately, because the mktime code is different. - print "
"; + // Search the db for all photos that were taken during the selected year. if ($calendar_user == "-1") { - $month_count = ORM::factory("item") + $items_for_year = ORM::factory("item") ->viewable() ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year)) + ->where("captured", ">=", mktime(0, 0, 0, 1, 1, $calendar_year)) ->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1))) - ->find_all() - ->count(); + ->order_by("captured") + ->find_all(); } else { - $month_count = ORM::factory("item") + $items_for_year = ORM::factory("item") ->viewable() ->where("owner_id", "=", $calendar_user) ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year)) + ->where("captured", ">=", mktime(0, 0, 0, 1, 1, $calendar_year)) ->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1))) - ->find_all() - ->count(); + ->order_by("captured") + ->find_all(); } - if ($month_count > 0) { + + // Set up some initial variables. + $counter_months = 1; + $counter_days = 0; + $counter = 0; + + // Set up the January Calendar. + // Check and see if any photos were taken in January, + // If so, make the month title into a clickable link. + print "
"; + if (date("n", $items_for_year[$counter]->captured) == 1) { $month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/"); } else { $month_url = ""; } $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url); - if ($month_count > 0) { - $curr_day = 1; - $MAX_DAYS = date('t', mktime(00, 00, 00, $counter_months, 1, $calendar_year)); - while ($curr_day < $MAX_DAYS) { - if ($calendar_user == "-1") { - $day_count = ORM::factory("item") - ->viewable() - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year)) - ->find_all() - ->count(); + + // Loop through each photo taken during this year, and see what month and day they were taken on. + // Make the corresponding dates on the calendars into clickable links. + while ($counter < (count($items_for_year))) { + + // Check and see if we've switched to a new month. + // If so, render the current calendar and set up a new one. + while (date("n", $items_for_year[$counter]->captured) > $counter_months) { + echo $calendar->render(); + print "
"; + $counter_months++; + $counter_days = 0; + print "
"; + if (date("n", $items_for_year[$counter]->captured) == $counter_months) { + $month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/"); } else { - $day_count = ORM::factory("item") - ->viewable() - ->where("owner_id", "=", $calendar_user) - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year)) - ->find_all() - ->count(); + $month_url = ""; } - if ($day_count > 0) { - $calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day)); - } - $curr_day++; - } - if ($calendar_user == "-1") { - $day_count = ORM::factory("item") - ->viewable() - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, 1, 1, $calendar_year+1)) - ->find_all() - ->count(); - } else { - $day_count = ORM::factory("item") - ->viewable() - ->where("owner_id", "=", $calendar_user) - ->where("type", "!=", "album") - ->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year)) - ->where("captured", "<", mktime(0, 0, 0, 1, 1, $calendar_year+1)) - ->find_all() - ->count(); - } - if ($day_count > 0) { - $calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS)); + $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url); } + + // If the day of the current photo is different then the day of the previous photo, + // then add a link to the calendar for this date and set the current day to this day. + if (date("j", $items_for_year[$counter]->captured) > $counter_days) { + $counter_days = date("j", $items_for_year[$counter]->captured); + $calendar->event($counter_days, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $counter_days)); + } + + // Move onto the next photo. + $counter++; } - $counter_months++; + + // Print out the last calendar to be generated. echo $calendar->render(); print "
"; -?> \ No newline at end of file + $counter_months++; + + // If the calendar that was previously rendered was not December, + // then print out a few empty months for the rest of the year. + while ($counter_months < 13) { + print "
"; + $month_url = ""; + $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url); + echo $calendar->render(); + print "
"; + $counter_months++; + } +?> From f6d2780f6c83088ef929e063fcefaa7eb3214714 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Thu, 3 Mar 2011 16:36:34 -0500 Subject: [PATCH 12/16] Added can_activate to warn that EXIF is required. --- .../calendarview/helpers/calendarview_installer.php | 8 ++++++++ .../calendarview/helpers/calendarview_installer.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/3.0/modules/calendarview/helpers/calendarview_installer.php b/3.0/modules/calendarview/helpers/calendarview_installer.php index 11ab23bb..b7d5828d 100644 --- a/3.0/modules/calendarview/helpers/calendarview_installer.php +++ b/3.0/modules/calendarview/helpers/calendarview_installer.php @@ -26,6 +26,14 @@ class calendarview_installer { site_status::clear("calendarview_needs_exif"); } + static function can_activate() { + $messages = array(); + if (!module::is_active("exif")) { + $messages["warn"][] = t("The CalendarView module requires the EXIF module."); + } + return $messages; + } + static function uninstall() { module::delete("calendarview"); } diff --git a/3.1/modules/calendarview/helpers/calendarview_installer.php b/3.1/modules/calendarview/helpers/calendarview_installer.php index 11ab23bb..b7d5828d 100644 --- a/3.1/modules/calendarview/helpers/calendarview_installer.php +++ b/3.1/modules/calendarview/helpers/calendarview_installer.php @@ -26,6 +26,14 @@ class calendarview_installer { site_status::clear("calendarview_needs_exif"); } + static function can_activate() { + $messages = array(); + if (!module::is_active("exif")) { + $messages["warn"][] = t("The CalendarView module requires the EXIF module."); + } + return $messages; + } + static function uninstall() { module::delete("calendarview"); } From b9eaf5690e25e7ccc51b9e3d1724905da12e82b6 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Thu, 3 Mar 2011 16:45:03 -0500 Subject: [PATCH 13/16] Sync calpage.html.php up with current page.html.php --- .../calendarview/views/calpage.html.php | 78 +++++++++++-------- .../calendarview/views/calpage.html.php | 78 +++++++++++-------- 2 files changed, 88 insertions(+), 68 deletions(-) diff --git a/3.0/modules/calendarview/views/calpage.html.php b/3.0/modules/calendarview/views/calpage.html.php index f98352b9..3dab5fc0 100644 --- a/3.0/modules/calendarview/views/calpage.html.php +++ b/3.0/modules/calendarview/views/calpage.html.php @@ -1,51 +1,42 @@ - +html_attributes() ?> xml:lang="en" lang="en"> + start_combining("script,css") ?> <? if ($page_title): ?> <?= $page_title ?> <? else: ?> <? if ($theme->item()): ?> - <? if ($theme->item()->is_album()): ?> - <?= t("Browse Album :: %album_title", array("album_title" => $theme->item()->title)) ?> - <? elseif ($theme->item()->is_photo()): ?> - <?= t("Photo :: %photo_title", array("photo_title" => $theme->item()->title)) ?> - <? else: ?> - <?= t("Movie :: %movie_title", array("movie_title" => $theme->item()->title)) ?> - <? endif ?> + <?= $theme->item()->title ?> <? elseif ($theme->tag()): ?> - <?= t("Browse Tag :: %tag_title", array("tag_title" => $theme->tag()->name)) ?> + <?= t("Photos tagged with %tag_title", array("tag_title" => $theme->tag()->name)) ?> <? else: /* Not an item, not a tag, no page_title specified. Help! */ ?> - <?= t("Gallery") ?> + <?= item::root()->title ?> <? endif ?> <? endif ?> - " type="image/x-icon" /> - css("yui/reset-fonts-grids.css") ?> - css("superfish/css/superfish.css") ?> - css("themeroller/ui.base.css") ?> - css("gallery.common.css") ?> - css("screen.css") ?> - + " + type="image/x-icon" /> + page_type == "collection"): ?> - - - + + + + + script("json2-min.js") ?> script("jquery.js") ?> script("jquery.form.js") ?> script("jquery-ui.js") ?> @@ -58,9 +49,8 @@ script("gallery.dialog.js") ?> script("superfish/js/superfish.js") ?> script("jquery.localscroll.js") ?> - script("ui.init.js") ?> - head() they get combined */ ?> + page_subtype == "photo"): ?> script("jquery.scrollTo.js") ?> script("gallery.show_full_size.js") ?> @@ -69,6 +59,23 @@ head() ?> + + + script("ui.init.js") ?> + css("yui/reset-fonts-grids.css") ?> + css("superfish/css/superfish.css") ?> + css("themeroller/ui.base.css") ?> + css("screen.css") ?> + + + + get_combined("script") ?> + + + get_combined("css") ?> body_attributes() ?>> @@ -87,15 +94,16 @@ user_menu() ?> header_top() ?> - + header_bottom() ?>
+ @@ -120,6 +128,8 @@ + +
@@ -151,4 +161,4 @@
page_bottom() ?> - + \ No newline at end of file diff --git a/3.1/modules/calendarview/views/calpage.html.php b/3.1/modules/calendarview/views/calpage.html.php index f98352b9..3dab5fc0 100644 --- a/3.1/modules/calendarview/views/calpage.html.php +++ b/3.1/modules/calendarview/views/calpage.html.php @@ -1,51 +1,42 @@ - +html_attributes() ?> xml:lang="en" lang="en"> + start_combining("script,css") ?> <? if ($page_title): ?> <?= $page_title ?> <? else: ?> <? if ($theme->item()): ?> - <? if ($theme->item()->is_album()): ?> - <?= t("Browse Album :: %album_title", array("album_title" => $theme->item()->title)) ?> - <? elseif ($theme->item()->is_photo()): ?> - <?= t("Photo :: %photo_title", array("photo_title" => $theme->item()->title)) ?> - <? else: ?> - <?= t("Movie :: %movie_title", array("movie_title" => $theme->item()->title)) ?> - <? endif ?> + <?= $theme->item()->title ?> <? elseif ($theme->tag()): ?> - <?= t("Browse Tag :: %tag_title", array("tag_title" => $theme->tag()->name)) ?> + <?= t("Photos tagged with %tag_title", array("tag_title" => $theme->tag()->name)) ?> <? else: /* Not an item, not a tag, no page_title specified. Help! */ ?> - <?= t("Gallery") ?> + <?= item::root()->title ?> <? endif ?> <? endif ?> - " type="image/x-icon" /> - css("yui/reset-fonts-grids.css") ?> - css("superfish/css/superfish.css") ?> - css("themeroller/ui.base.css") ?> - css("gallery.common.css") ?> - css("screen.css") ?> - + " + type="image/x-icon" /> + page_type == "collection"): ?> - - - + + + + + script("json2-min.js") ?> script("jquery.js") ?> script("jquery.form.js") ?> script("jquery-ui.js") ?> @@ -58,9 +49,8 @@ script("gallery.dialog.js") ?> script("superfish/js/superfish.js") ?> script("jquery.localscroll.js") ?> - script("ui.init.js") ?> - head() they get combined */ ?> + page_subtype == "photo"): ?> script("jquery.scrollTo.js") ?> script("gallery.show_full_size.js") ?> @@ -69,6 +59,23 @@ head() ?> + + + script("ui.init.js") ?> + css("yui/reset-fonts-grids.css") ?> + css("superfish/css/superfish.css") ?> + css("themeroller/ui.base.css") ?> + css("screen.css") ?> + + + + get_combined("script") ?> + + + get_combined("css") ?> body_attributes() ?>> @@ -87,15 +94,16 @@ user_menu() ?> header_top() ?> - + header_bottom() ?>
+ @@ -120,6 +128,8 @@ + +
@@ -151,4 +161,4 @@
page_bottom() ?> - + \ No newline at end of file From 8b1c15eea55ff1c8eb90603f85b774667e9afd7b Mon Sep 17 00:00:00 2001 From: rWatcher Date: Thu, 3 Mar 2011 19:40:23 -0500 Subject: [PATCH 14/16] That might do something important. --- 3.0/modules/calendarview/views/calendarview_year.html.php | 1 + 3.1/modules/calendarview/views/calendarview_year.html.php | 1 + 2 files changed, 2 insertions(+) diff --git a/3.0/modules/calendarview/views/calendarview_year.html.php b/3.0/modules/calendarview/views/calendarview_year.html.php index 1b47dbcf..880e0267 100644 --- a/3.0/modules/calendarview/views/calendarview_year.html.php +++ b/3.0/modules/calendarview/views/calendarview_year.html.php @@ -92,3 +92,4 @@ $counter_months++; } ?> +dynamic_bottom() ?> diff --git a/3.1/modules/calendarview/views/calendarview_year.html.php b/3.1/modules/calendarview/views/calendarview_year.html.php index 1b47dbcf..880e0267 100644 --- a/3.1/modules/calendarview/views/calendarview_year.html.php +++ b/3.1/modules/calendarview/views/calendarview_year.html.php @@ -92,3 +92,4 @@ $counter_months++; } ?> +dynamic_bottom() ?> From cf1ca042923642d8eb1374c8159b60ba73b35e68 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Thu, 3 Mar 2011 19:50:02 -0500 Subject: [PATCH 15/16] Gallery 3.0.1 Bugfix -- Make sure both CSS files are loaded. --- 3.0/modules/calendarview/controllers/calendarview.php | 1 - 3.0/modules/calendarview/helpers/calendarview_theme.php | 3 ++- 3.1/modules/calendarview/controllers/calendarview.php | 1 - 3.1/modules/calendarview/helpers/calendarview_theme.php | 3 ++- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/3.0/modules/calendarview/controllers/calendarview.php b/3.0/modules/calendarview/controllers/calendarview.php index 101ff688..c1302ba5 100644 --- a/3.0/modules/calendarview/controllers/calendarview.php +++ b/3.0/modules/calendarview/controllers/calendarview.php @@ -32,7 +32,6 @@ class CalendarView_Controller extends Controller { // Draw the page. $template = new Theme_View("calpage.html", "other", "CalendarView"); - $template->css("calendarview_calendar.css"); $template->set_global("calendar_user", $display_user); $template->page_title = t("Gallery :: Calendar"); $template->content = new View("calendarview_year.html"); diff --git a/3.0/modules/calendarview/helpers/calendarview_theme.php b/3.0/modules/calendarview/helpers/calendarview_theme.php index a1037f74..fa8002ea 100644 --- a/3.0/modules/calendarview/helpers/calendarview_theme.php +++ b/3.0/modules/calendarview/helpers/calendarview_theme.php @@ -20,6 +20,7 @@ class calendarview_theme_Core { static function head($theme) { - return $theme->css("calendarview_menu.css"); + $theme->css("calendarview_menu.css"); + return $theme->css("calendarview_calendar.css"); } } diff --git a/3.1/modules/calendarview/controllers/calendarview.php b/3.1/modules/calendarview/controllers/calendarview.php index 101ff688..c1302ba5 100644 --- a/3.1/modules/calendarview/controllers/calendarview.php +++ b/3.1/modules/calendarview/controllers/calendarview.php @@ -32,7 +32,6 @@ class CalendarView_Controller extends Controller { // Draw the page. $template = new Theme_View("calpage.html", "other", "CalendarView"); - $template->css("calendarview_calendar.css"); $template->set_global("calendar_user", $display_user); $template->page_title = t("Gallery :: Calendar"); $template->content = new View("calendarview_year.html"); diff --git a/3.1/modules/calendarview/helpers/calendarview_theme.php b/3.1/modules/calendarview/helpers/calendarview_theme.php index a1037f74..fa8002ea 100644 --- a/3.1/modules/calendarview/helpers/calendarview_theme.php +++ b/3.1/modules/calendarview/helpers/calendarview_theme.php @@ -20,6 +20,7 @@ class calendarview_theme_Core { static function head($theme) { - return $theme->css("calendarview_menu.css"); + $theme->css("calendarview_menu.css"); + return $theme->css("calendarview_calendar.css"); } } From d5ac05713fd76c6f18eb4a13f6bbbf407b3aadc1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 7 Mar 2011 08:38:34 -0800 Subject: [PATCH 16/16] Edit Captured module, by rWatcher and xmod ref: http://codex.gallery2.org/Gallery3:Modules:editcaptured --- 3.0/modules/editcaptured/css/editcaptured.css | 9 + .../helpers/editcaptured_event.php | 154 ++++++++++++++++++ .../helpers/editcaptured_theme.php | 31 ++++ 3.0/modules/editcaptured/module.info | 3 + 4 files changed, 197 insertions(+) create mode 100644 3.0/modules/editcaptured/css/editcaptured.css create mode 100644 3.0/modules/editcaptured/helpers/editcaptured_event.php create mode 100644 3.0/modules/editcaptured/helpers/editcaptured_theme.php create mode 100644 3.0/modules/editcaptured/module.info diff --git a/3.0/modules/editcaptured/css/editcaptured.css b/3.0/modules/editcaptured/css/editcaptured.css new file mode 100644 index 00000000..84e8853c --- /dev/null +++ b/3.0/modules/editcaptured/css/editcaptured.css @@ -0,0 +1,9 @@ +#g-dialog select { + display: inline; +} +.g-editcaptured-usedate { + display: inline; +} +.g-editcaptured-setsubitems { + display: inline; +} diff --git a/3.0/modules/editcaptured/helpers/editcaptured_event.php b/3.0/modules/editcaptured/helpers/editcaptured_event.php new file mode 100644 index 00000000..00b5735b --- /dev/null +++ b/3.0/modules/editcaptured/helpers/editcaptured_event.php @@ -0,0 +1,154 @@ +id == 1) + return; + + // Search if there are at least some child items containing a captured date + $model = ORM::factory("item") + ->where("parent_id", "=", $item->id) + ->where("captured", "IS NOT", null) + ->order_by("captured", "ASC"); + $first_child = $model->find(); + if (!$first_child->id) $first_child = null; + + // Chose preselected option, depending on wheather item already has captured date or not + if ($item->captured) { + $dateoptions_preselect = "selected"; + } else { + $dateoptions_preselect = "remove"; + } + + // Depending on wheather there are child items or not, we generate the dropdown options + if ($first_child) { + $dateoptions = array("selected" => t("Selected Date"), + "oldest" => t("Date of oldest Child"), + "youngest" => t("Date of youngest Child"), + "now" => t("Current Date"), + "remove" => t("Remove Date")); + + // If there are child items with captured date, we preset the date field with the oldest item + if (!$item->captured && $first_child) { + $item->captured = $first_child->captured; + $dateoptions_preselect = "oldest"; + } + } else { + $dateoptions = array("selected" => t("Selected Date"), + "now" => t("Current Date"), + "remove" => t("Remove Date")); + } + + // Add captured date field to the form + $form->edit_item->dateselect("capturedate") + ->label(t("Captured")) + ->minutes(1) + ->years(1970, date('Y')+1) + ->value($item->captured); + + // Add dropdown menu for options to the form + $form->edit_item->dropdown("capturedate_usedate") + ->options($dateoptions) + ->id("g-editcaptured-usedate") + ->selected($dateoptions_preselect); + + // Add checkbox for users who want to change the captured date of subitems, too + if ($item->is_album()) { + $form->edit_item->checkbox("capturedate_setsubitems") + ->label(t("Set also subitems's date")) + ->id("g-editcaptured-setsubitems"); + } + } + + static function item_edit_form_completed($item, $form) { + // Change the item's captured field to the specified value. + + // We don't want to change the root element, so check for that + if ($item->id == 1) { + return; + } + + // Depending on the dropdown option, we set the date + switch ($form->edit_item->capturedate_usedate->value) { + + // Just use the date selected in the form + case "selected": + $item->captured = $form->edit_item->capturedate->value; + break; + + // Use the date of the oldest child (we check again if there is such a child) + case "oldest": + $model = ORM::factory("item") + ->where("parent_id", "=", $item->id) + ->where("captured", "IS NOT", null) + ->order_by("captured", "ASC"); + $first_child = $model->find(); + if ($first_child->id) { + $item->captured = $first_child->captured; + } else { + $item->captured = null; + } + break; + + // Use the date of the youngest child (we check again if there is such a child) + case "youngest": + $model = ORM::factory("item") + ->where("parent_id", "=", $item->id) + ->where("captured", "IS NOT", null) + ->order_by("captured", "DESC"); + $first_child = $model->find(); + if ($first_child->id) { + $item->captured = $first_child->captured; + } else { + $item->captured = null; + } + break; + + // Use the current date + case "now": + $item->captured = time(); + break; + + // Remove the date + case "remove": + $item->captured = null; + } + + $item->save(); + + // Set the date also for all subitems (at the moment only direct subitems are supported + if ($item->is_album() && $form->edit_item->capturedate_setsubitems->checked) { + foreach (ORM::factory("item")->where("parent_id", "=", $item->id)->find_all() as $subitem) { + if ($subitem->loaded() && access::can("edit", $subitem)) { + $subitem->captured = $item->captured; + $subitem->save(); + } + } + //message::success(t("Changed captured date of subitems")); + } + + } + +} + diff --git a/3.0/modules/editcaptured/helpers/editcaptured_theme.php b/3.0/modules/editcaptured/helpers/editcaptured_theme.php new file mode 100644 index 00000000..7458860c --- /dev/null +++ b/3.0/modules/editcaptured/helpers/editcaptured_theme.php @@ -0,0 +1,31 @@ +item()) { + return; + } + $item = $theme->item(); + if ( $item && access::can("edit", $item) ) { + $theme->css("editcaptured.css"); + } + } +} diff --git a/3.0/modules/editcaptured/module.info b/3.0/modules/editcaptured/module.info new file mode 100644 index 00000000..9a76e495 --- /dev/null +++ b/3.0/modules/editcaptured/module.info @@ -0,0 +1,3 @@ +name = "Edit Captured Date" +description = "Edit the capture date of an element manually or semiautomatically based on date of subitems." +version = 2