diff options
32 files changed, 361 insertions, 230 deletions
diff --git a/installer/installer.php b/installer/installer.php index 1a36ddb5..9ba88bea 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -17,7 +17,35 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + +// We know that we have either mysql or mysqli. By default we use mysql functions, so if they're +// not defined then do the simplest thing which will work: remap them to their mysqli +// counterparts. +if (!function_exists("mysql_query")) { + function mysql_connect($host, $user, $pass) { + installer::$mysqli = new mysqli($host, $user, $pass); + // http://php.net/manual/en/mysqli.connect.php says to use mysqli_connect_error() instead of + // $mysqli->connect_error because of bugs before PHP 5.2.9 + $error = mysqli_connect_error(); + return empty($error); + } + function mysql_query($query) { + return installer::$mysqli->query($query); + } + function mysql_num_rows($result) { + return $result->num_rows; + } + function mysql_error() { + return installer::$mysqli->error; + } + function mysql_select_db($db) { + return installer::$mysqli->select_db($db); + } +} + class installer { + static $mysqli; + static function already_installed() { return file_exists(VARPATH . "database.php"); } diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php new file mode 100644 index 00000000..b191c326 --- /dev/null +++ b/modules/comment/helpers/comment_rss.php @@ -0,0 +1,65 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +class comment_rss_Core { + static function available_feeds($item) { + return array(array("description" => t("All new comments"), + "sidebar" => true, + "uri" => "comments"), + array("description" => sprintf(t("Comments on %s"), $item->title), + "sidebar" => true, + "uri" => "comments/{$item->id}")); + } + + static function comments($offset, $limit, $id) { + $feed = new stdClass(); + $orm = ORM::factory("comment") + ->where("state", "published") + ->orderby("created", "DESC"); + if (!empty($id)) { + $orm->where("item_id", $id); + } + + $feed->view = "comment.mrss"; + $comments = $orm->find_all($limit, $offset); + $feed->data["children"] = array(); + foreach ($comments as $comment) { + $item = $comment->item(); + $feed->data["children"][] = array( + "pub_date" => date("D, d M Y H:i:s T", $comment->created), + "text" => htmlspecialchars($comment->text), + "thumb_url" => $item->thumb_url(), + "thumb_height" => $item->thumb_height, + "thumb_width" => $item->thumb_width, + "item_link" => htmlspecialchars(url::abs_site("{$item->type}s/$item->id")), + "title" =>htmlspecialchars($item->title), + "author" => + empty($comment->guest_name) ? $comment->author()->full_name : $comment->guest_name + ); + } + + $feed->max_pages = ceil($comments->count() / $limit); + $feed->data["title"] = htmlspecialchars(t("Recent Comments")); + $feed->data["link"] = url::abs_site("albums/" . (empty($id) ? "1" : $id)); + $feed->data["description"] = t("Recent Comments"); + + return $feed; + } +}
\ No newline at end of file diff --git a/modules/comment/views/admin_block_recent_comments.html.php b/modules/comment/views/admin_block_recent_comments.html.php index d5aab84c..8b9634c5 100644 --- a/modules/comment/views/admin_block_recent_comments.html.php +++ b/modules/comment/views/admin_block_recent_comments.html.php @@ -7,7 +7,7 @@ alt="<?= p::clean($comment->author_name()) ?>" width="32" height="32" /> - <?= date("Y-M-d H:i:s", $comment->created) ?> + <?= gallery::date_time($comment->created) ?> <?= t("<a href=#>%author_name</a> said <em>%comment_text</em>", array("author_name" => p::clean($comment->author_name()), "comment_text" => text::limit_words(p::clean($comment->text), 50))); ?> diff --git a/modules/comment/views/admin_comments.html.php b/modules/comment/views/admin_comments.html.php index 79bdb1f3..e749fde0 100644 --- a/modules/comment/views/admin_comments.html.php +++ b/modules/comment/views/admin_comments.html.php @@ -117,7 +117,7 @@ </td> <td> <div class="right"> - <? $item = $comment->item(); ?> + <? $item = $comment->item() ?> <div class="gItem gPhoto"> <a href="<?= $item->url() ?>"> <? if ($item->has_thumb()): ?> @@ -131,7 +131,7 @@ </a> </div> </div> - <p><?= date("Y-M-d", $comment->created); ?></p> + <p><?= gallery::date($comment->created) ?></p> <?= p::clean($comment->text) ?> </td> <td> diff --git a/modules/comment/views/comment.html.php b/modules/comment/views/comment.html.php index 0337173b..ce52951b 100644 --- a/modules/comment/views/comment.html.php +++ b/modules/comment/views/comment.html.php @@ -8,8 +8,9 @@ width="40" height="40" /> </a> - <?= t("on ") . date("Y-M-d H:i:s", $comment->created) ?> - <a href="#"><?= p::clean($comment->author_name()) ?></a> <?= t("said") ?> + <?= t("on %date_time, %author_name said", + array("date_time" => gallery::date_time($comment->created), + "author_name" => p::clean($comment->author_name()))) ?> </p> <div> <?= p::clean($comment->text) ?> diff --git a/modules/rss/views/comment.mrss.php b/modules/comment/views/comment.mrss.php index d2177026..d2177026 100644 --- a/modules/rss/views/comment.mrss.php +++ b/modules/comment/views/comment.mrss.php diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index 968d97cd..f2969f49 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -44,20 +44,13 @@ class Admin_g2_import_Controller extends Admin_Controller { $form = $this->_get_import_form(); if ($form->validate()) { $embed_path = $form->configure_g2_import->embed_path->value; - $multi_path = $form->configure_g2_import->multi_path->value; - if (!is_file($embed_path) && file_exists("$embed_path/embed.php")) { $embed_path = "$embed_path/embed.php"; } - - if (!empty($multi_path) && !is_file($multi_path) && file_exists("$multi_path/config.php")) { - $multi_path = "$multi_path/embed.php"; - } - if (g2_import::is_valid_embed_path($embed_path, $multi_path)) { + if (g2_import::is_valid_embed_path($embed_path)) { message::success("Gallery 2 path saved."); module::set_var("g2_import", "embed_path", $embed_path); - module::set_var("g2_import", "multi_path", $multi_path); url::redirect("admin/g2_import"); } else { $form->configure_g2_import->embed_path->add_error("invalid", 1); @@ -74,16 +67,11 @@ class Admin_g2_import_Controller extends Admin_Controller { $form = new Forge( "admin/g2_import/save", "", "post", array("id" => "gAdminConfigureG2ImportForm")); $group = $form->group("configure_g2_import")->label(t("Configure Gallery 2 Import")); - $group->input("embed_path")->label(t("Filesystem path to your Gallery 2 embed.php file (in case of multisite config, use the path to the 'master')")) + $group->input("embed_path")->label(t("Filesystem path to your Gallery 2 embed.php file")) ->value(module::get_var("g2_import", "embed_path", "")); - - $group->input("multi_path")->label(t("Filesystem path to your Gallery 2 multisite instance config (leave empty if not applicable)")) - ->value(module::get_var("g2_import", "multi_path", "")); - $group->embed_path->error_messages( "invalid", t("The path you entered is not a Gallery 2 installation.")); - $group->submit("")->value(t("Save")); return $form; } -} +}
\ No newline at end of file diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 33cfc158..19d02f25 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -37,24 +37,22 @@ class g2_import_Core { } $embed_path = module::get_var("g2_import", "embed_path"); - $multi_path = module::get_var("g2_import", "multi_path"); - if (empty($embed_path)) { throw new Exception("@todo G2_IMPORT_NOT_CONFIGURED"); } - g2_import::$init = g2_import::init_embed($embed_path, $multi_path); + g2_import::$init = g2_import::init_embed($embed_path); } - static function is_valid_embed_path($embed_path, $multi_path) { - return file_exists($embed_path) && (empty($multi_path) || file_exists($multi_path)) && g2_import::init_embed($embed_path, $multi_path); + static function is_valid_embed_path($embed_path) { + return file_exists($embed_path) && g2_import::init_embed($embed_path); } /** * Initialize the embedded Gallery2 instance. Call this before any other Gallery2 calls. */ - static function init_embed($embed_path, $multi_path) { - if (!is_file($embed_path) && (empty($multi_path) || is_dir($multi_path))) { + static function init_embed($embed_path) { + if (!is_file($embed_path)) { return false; } @@ -71,11 +69,17 @@ class g2_import_Core { @dir::unlink($mod_path); mkdir($mod_path); - $base_dir = dirname($embed_path); - if (!empty($multi_path)) - $config_dir = dirname($multi_path); - else - $config_dir = $base_dir; + $config_dir = dirname($embed_path); + if (filesize($embed_path) > 200) { + // Regular install + $base_dir = $config_dir; + } else { + // Multisite install. Line 2 of embed.php will be something like: + // require('/usr/home/bharat/public_html/gallery2/embed.php'); + $lines = file($embed_path); + preg_match("#require\('(.*)/embed.php'\);#", $lines[2], $matches); + $base_dir = $matches[1]; + } file_put_contents( "$mod_path/embed.php", @@ -107,11 +111,13 @@ class g2_import_Core { array("require_once(dirname(__FILE__) . '/modules/core/classes/Gallery.class');", "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', dirname(__FILE__));", - "\$gallery =& new Gallery();"), + "\$gallery =& new Gallery();", + "\$gallery = new Gallery();"), array("require_once(dirname(__FILE__) . '/Gallery.class');", "require_once('$base_dir/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', '$config_dir');", - "\$gallery =& new G2_Gallery();"), + "\$gallery =& new G2_Gallery();", + "\$gallery = new G2_Gallery();"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("$base_dir/bootstrap.inc")))); diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php index c0ee2b17..d5e29e12 100644 --- a/modules/g2_import/views/admin_g2_import.html.php +++ b/modules/g2_import/views/admin_g2_import.html.php @@ -3,7 +3,10 @@ <h1> <?= t("Gallery 2 Import") ?> </h1> <p> <?= t("Import your Gallery 2 users, photos, movies, comments and tags into your new Gallery 3 installation.") ?> - <?= t("<b>Note: The importer is a work in progress and does not currently support permissions, and movie formats other than Flash video and MP4</b>") ?> + <br/> + <?= t("<b>Note</b>: The importer is a work in progress and does not currently support permissions, and movie formats other than Flash video and MP4") ?> + <br/> + <?= t("<b>Note</b>: The importer has <i>known issues</i> with the eAccelerator PHP accelerator. If you're using eAccelerator, please disable it. One way to do that is to put <code>php_value eaccelerator.enable 0</code> in gallery3/.htaccess") ?> </p> <?= $form ?> </div> diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index d6f5213f..cff6686b 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -95,6 +95,23 @@ class Quick_Controller extends Controller { print json_encode(array("result" => "success", "reload" => 1)); } + public function form_delete($id) { + $item = model_cache::get("item", $id); + access::required("view", $item); + access::required("edit", $item); + + if ($item->is_album()) { + print t( + "Delete the album <b>%title</b>? All photos and movies in the album will also be deleted.", + array("title" => $item->title)); + } else { + print t("Are you sure you want to delete <b>%title</b>?", array("title" => $item->title)); + } + + $form = item::get_delete_form($item); + print $form; + } + public function delete($id) { access::verify_csrf(); $item = model_cache::get("item", $id); diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 1686571c..e22cc17f 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -49,4 +49,31 @@ class gallery_Core { static function shutdown() { module::event("gallery_shutdown"); } + + /** + * Return a unix timestamp in a user specified format including date and time. + * @param $timestamp unix timestamp + * @return string + */ + static function date_time($timestamp) { + return date(module::get_var("gallery", "date_time_format", "Y-M-d H:i:s"), $timestamp); + } + + /** + * Return a unix timestamp in a user specified format that's just the date. + * @param $timestamp unix timestamp + * @return string + */ + static function date($timestamp) { + return date(module::get_var("gallery", "date_format", "Y-M-d"), $timestamp); + } + + /** + * Return a unix timestamp in a user specified format that's just the time. + * @param $timestamp unix timestamp + * @return string + */ + static function time($timestamp) { + return date(module::get_var("gallery", "time_format", "H:i:s"), $timestamp); + } }
\ No newline at end of file diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index abc8a195..c3837f54 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -56,7 +56,8 @@ class gallery_block_Core { $block->css_id = "gStats"; $block->title = t("Gallery Stats"); $block->content = new View("admin_block_stats.html"); - $block->content->album_count = ORM::factory("item")->where("type", "album")->count_all(); + $block->content->album_count = + ORM::factory("item")->where("type", "album")->where("id <>", 1)->count_all(); $block->content->photo_count = ORM::factory("item")->where("type", "photo")->count_all(); break; @@ -92,7 +93,7 @@ class gallery_block_Core { $form = new Forge("admin/dashboard/add_block", "", "post", array("id" => "gAddDashboardBlockForm")); $group = $form->group("add_block")->label(t("Add Block")); - $group->dropdown("id")->label("Available Blocks")->options(block_manager::get_available()); + $group->dropdown("id")->label(t("Available Blocks"))->options(block_manager::get_available()); $group->submit("center")->value(t("Add to center")); $group->submit("sidebar")->value(t("Add to sidebar")); return $form; diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 242bb486..b2be63be 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -254,6 +254,12 @@ class gallery_installer { // @todo this string needs to be picked up by l10n_scanner module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>"); + } else if ($version == 1) { + module::set_var("gallery", "date_format", "Y-M-d"); + module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); + module::set_var("gallery", "time_format", "H:i:s"); + module::set_var("gallery", "version", "3.0 pre beta 2 (git)"); + module::set_version("gallery", 2); } } diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php new file mode 100644 index 00000000..6e722ff6 --- /dev/null +++ b/modules/gallery/helpers/gallery_rss.php @@ -0,0 +1,61 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +class gallery_rss_Core { + static function available_feeds($item) { + return array(array("description" => t("New photos or movies"), + "sidebar" => true, + "uri" => "updates"), + array("description" => t("Album feed"), + "sidebar" => false, + "uri" => "albums")); + } + + static function updates($offset, $limit) { + $feed = new stdClass(); + $feed->data["children"] = ORM::factory("item") + ->viewable() + ->where("type !=", "album") + ->orderby("created", "DESC") + ->find_all($limit, $offset); + $feed->max_pages = ceil($feed->data["children"]->count() / $limit); + $feed->data["title"] = t("Recent Updates"); + $feed->data["link"] = url::abs_site("albums/1"); + $feed->data["description"] = t("Recent Updates"); + + return $feed; + } + + static function albums($offset, $limit, $id) { + $item = ORM::factory("item", $id); + access::required("view", $item); + + $feed = new stdClass(); + $feed->data["children"] = $item + ->viewable() + ->descendants($limit, $offset, "photo"); + $feed->max_pages = ceil($item->viewable()->descendants_count("photo") / $limit); + $feed->data["title"] = $item->title; + $feed->data["link"] = url::abs_site("albums/{$item->id}"); + $feed->data["description"] = $item->description; + + return $feed; + } +} diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 25eb0891..feebfb34 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -326,6 +326,7 @@ class graphics_Core { if (!isset($gd["GD Version"])) { $gd["GD Version"] = false; } + putenv("PATH=" . getenv("PATH") . ":/usr/local/bin"); return array("gd" => $gd, "imagemagick" => $exec ? dirname(exec("which convert")) : false, "graphicsmagick" => $exec ? dirname(exec("which gm")) : false); diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 09870b45..f40b5c97 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -119,4 +119,22 @@ class item_Core { $title = preg_replace("/ +/", " ", $title); return $title; } + + /** + * Display delete confirmation message and form + * @param object $item + * @return string form + */ + static function get_delete_form($item) { + if (Input::instance()->get("page_type") == "album") { + $page_type = "album"; + } else { + $page_type = "item"; + } + $form = new Forge("quick/delete/$item->id?page_type=$page_type", "", "post", array("id" => "gConfirmDelete")); + $form->hidden("_method")->value("put"); + $group = $form->group("confirm_delete")->label(t("Confirm Deletion")); + $group->submit("")->value(t("Delete")); + return $form; + } }
\ No newline at end of file diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 986d5f62..1d1d29d1 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -140,13 +140,11 @@ class movie_Core { static function find_ffmpeg() { if (!$ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) { + putenv("PATH=" . getenv("PATH") . ":/usr/local/bin"); if (function_exists("exec")) { $ffmpeg_path = exec("which ffmpeg"); } - if (empty($ffmpeg) && @file_exists("/usr/local/bin/ffmpeg")) { - $ffmpeg_path = "/usr/local/bin/ffmpeg"; - } module::set_var("gallery", "ffmpeg_path", $ffmpeg_path); } return $ffmpeg_path; diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index 8a87ed07..4ebdac47 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -39,10 +39,6 @@ var show_quick = function() { ); $("#gQuickPane a:not(.options)").click(function(e) { e.preventDefault(); - if ($(this).attr("id") == "gQuickDelete" && - !confirm($(this).attr("ref"))) { - return; - } quick_do(cont, $(this), img); }); $("#gQuickPane a.options").click(function(e) { diff --git a/modules/gallery/module.info b/modules/gallery/module.info index ff7da82d..3a5dd593 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = Gallery 3 description = Gallery core application -version = 1 +version = 2 diff --git a/modules/gallery/views/admin_advanced_settings.html.php b/modules/gallery/views/admin_advanced_settings.html.php index b4dedaef..b37c1c73 100644 --- a/modules/gallery/views/admin_advanced_settings.html.php +++ b/modules/gallery/views/admin_advanced_settings.html.php @@ -6,7 +6,7 @@ </p> <ul id="gMessage"> <li class="gWarning"> - <b><?= t("Change these values at your own risk!") ?> + <b><?= t("Change these values at your own risk!") ?></b> </li> </ul> diff --git a/modules/gallery/views/admin_block_log_entries.html.php b/modules/gallery/views/admin_block_log_entries.html.php index 38070fe1..44c1657f 100644 --- a/modules/gallery/views/admin_block_log_entries.html.php +++ b/modules/gallery/views/admin_block_log_entries.html.php @@ -3,7 +3,7 @@ <? foreach ($entries as $entry): ?> <li class="<?= log::severity_class($entry->severity) ?>" style="direction: ltr"> <a href="<?= url::site("user/$entry->user_id") ?>"><?= p::clean($entry->user->name) ?></a> - <?= date("Y-M-d H:i:s", $entry->timestamp) ?> + <?= gallery::date_time($entry->timestamp) ?> <?= $entry->message ?> <?= $entry->html ?> </li> diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index 66c4eea0..c47f77f8 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -69,7 +69,7 @@ <? foreach ($running_tasks as $task): ?> <tr class="<?= $task->state == "stalled" ? "gWarning" : "" ?>"> <td> - <?= date("M j, Y H:i:s", $task->updated) ?> + <?= gallery::date_time($task->updated) ?> </td> <td> <?= $task->name ?> @@ -139,7 +139,7 @@ <? foreach ($finished_tasks as $task): ?> <tr class="<?= $task->state == "success" ? "gSuccess" : "gError" ?>"> <td> - <?= date("M j, Y H:i:s", $task->updated) ?> + <?= gallery::date_time($task->updated) ?> </td> <td> <?= $task->name ?> diff --git a/modules/gallery/views/permissions_form.html.php b/modules/gallery/views/permissions_form.html.php index adf2bd94..0f60070a 100644 --- a/modules/gallery/views/permissions_form.html.php +++ b/modules/gallery/views/permissions_form.html.php @@ -69,7 +69,7 @@ <? elseif ($intent === access::ALLOW): ?> <td class="gAllowed"> <? if ($item->id == 1): ?> - <img src="<?= url::file('themes/default/images/ico-success.png') ?>" title="allowed" alt="<?= t('allowed icon') ?>" /> + <img src="<?= url::file('themes/default/images/ico-success.png') ?>" title="<?= t("allowed") ?>" alt="<?= t('allowed icon') ?>" /> <? else: ?> <a href="javascript:set('reset',<?= $group->id ?>,<?= $permission->id ?>,<?= $item->id ?>)" title="<?= t('allowed, click to reset') ?>"> diff --git a/modules/gallery/views/quick_pane.html.php b/modules/gallery/views/quick_pane.html.php index 95de972b..f50e1abe 100644 --- a/modules/gallery/views/quick_pane.html.php +++ b/modules/gallery/views/quick_pane.html.php @@ -67,15 +67,12 @@ <? if ($item->type == "photo"): ?> <? $title = t("Delete this photo") ?> -<? $message = t("Do you really want to delete this photo") ?> <? elseif ($item->type == "movie"): ?> <? $title = t("Delete this movie") ?> -<? $message = t("Do you really want to delete this movie") ?> <? elseif ($item->type == "album"): ?> <? $title = t("Delete this album") ?> -<? $message = t("Do you really want to delete this album") ?> <? endif ?> -<a class="gButtonLink ui-corner-all ui-state-default" href="<?= url::site("quick/delete/$item->id?csrf=$csrf&page_type=$page_type") ?>" ref="<?= $message ?>" id="gQuickDelete" title="<?= $title ?>"> +<a class="gDialogLink gButtonLink ui-corner-all ui-state-default" href="<?= url::site("quick/form_delete/$item->id?page_type=$page_type") ?>" id="gQuickDelete" title="<?= $title ?>"> <span class="ui-icon ui-icon-trash"> <?= $title ?> </span> diff --git a/modules/info/views/info_block.html.php b/modules/info/views/info_block.html.php index f8e5f35e..9f9ec5df 100644 --- a/modules/info/views/info_block.html.php +++ b/modules/info/views/info_block.html.php @@ -31,7 +31,7 @@ <? if ($item->captured): ?> <tr> <th><?= t("Captured:") ?></th> - <td><?= date("M j, Y H:i:s", $item->captured)?></td> + <td><?= gallery::date_time($item->captured) ?></td> </tr> <? endif ?> <? if ($item->owner): ?> diff --git a/modules/rss/controllers/rss.php b/modules/rss/controllers/rss.php index 1f8b8a4e..164803cb 100644 --- a/modules/rss/controllers/rss.php +++ b/modules/rss/controllers/rss.php @@ -20,185 +20,38 @@ class Rss_Controller extends Controller { public static $page_size = 30; - public function albums($id) { - $item = ORM::factory("item", $id); - access::required("view", $item); - + public function __call($method, $arguments) { + $id = empty($arguments) ? null : $arguments[0]; $page = $this->input->get("page", 1); + $feed_uri = "rss/$method" . (empty($id) ? "" : "/$id"); if ($page < 1) { - url::redirect("rss/albums/{$item->id}"); - } - - $children = $item - ->viewable() - ->descendants(self::$page_size, ($page - 1) * self::$page_size, "photo"); - $max_pages = ceil($item->viewable()->descendants_count("photo") / self::$page_size); - - if ($max_pages && $page > $max_pages) { - url::redirect("rss/albums/{$item->id}?page=$max_pages"); - } - - $view = new View("feed.mrss"); - $view->title = $item->title; - $view->link = url::abs_site("albums/{$item->id}"); - $view->description = $item->description; - $view->feed_link = url::abs_site("rss/albums/{$item->id}"); - $view->children = $children; - - if ($page > 1) { - $previous_page = $page - 1; - $view->previous_page_link = url::site("rss/albums/{$item->id}?page={$previous_page}"); + url::redirect($feed_uri); } - if ($page < $max_pages) { - $next_page = $page + 1; - $view->next_page_link = url::site("rss/albums/{$item->id}?page={$next_page}"); + $feed = rss::process_feed($method, ($page - 1) * self::$page_size, self::$page_size, $id); + if ($feed->max_pages && $page > $feed->max_pages) { + url::redirect("$feed_uri?page={$feed->max_pages}"); } - // @todo do we want to add an upload date to the items table? - $view->pub_date = date("D, d M Y H:i:s T"); - - rest::http_content_type(rest::RSS); - print $view; - } - - public function updates() { - $page = $this->input->get("page", 1); - if ($page < 1) { - url::redirect("rss/updates"); + $view = new View(empty($feed->view) ? "feed.mrss" : $feed->view); + foreach ($feed->data as $field => $value) { + $view->$field = $value; } - - $items = ORM::factory("item") - ->viewable() - ->where("type !=", "album") - ->orderby("created", "DESC") - ->find_all(self::$page_size, ($page - 1) * self::$page_size); - $max_pages = ceil($items->count() / self::$page_size); - - if ($max_pages && $page > $max_pages) { - url::redirect("rss/updates?page=$max_pages"); - } - - $view = new View("feed.mrss"); - $view->title = t("Recent Updates"); - $view->link = url::abs_site("albums/1"); - $view->description = t("Recent Updates"); - $view->feed_link = url::abs_site("rss/updates"); - $view->children = $items; + $view->feed_link = url::abs_site($feed_uri); if ($page > 1) { $previous_page = $page - 1; - $view->previous_page_link = url::site("rss/updates?page={$previous_page}"); + $view->previous_page_link = url::site("$feed_uri?page={$previous_page}"); } - if ($page < $max_pages) { + if ($page < $feed->max_pages) { $next_page = $page + 1; - $view->next_page_link = url::site("rss/updates?page={$next_page}"); + $view->next_page_link = url::site("$feed_uri?page={$next_page}"); } - // @todo do we want to add an upload date to the items table? $view->pub_date = date("D, d M Y H:i:s T"); rest::http_content_type(rest::RSS); print $view; } - - public function tags($id) { - $tag = ORM::factory("tag", $id); - if (!$tag->loaded) { - return Kohana::show_404(); - } - - $page = $this->input->get("page", 1); - if ($page < 1) { - url::redirect("rss/tags/{$tag->id}"); - } - - $children = $tag->items(self::$page_size, ($page - 1) * self::$page_size, "photo"); - $max_pages = ceil($tag->count / self::$page_size); - - if ($max_pages && $page > $max_pages) { - url::redirect("rss/tags/{$tag->id}?page=$max_pages"); - } - - $view = new View("feed.mrss"); - $view->title = $tag->name; - $view->link = url::abs_site("tags/{$tag->id}"); - $view->description = t("Photos related to %tag_name", array("tag_name" => $tag->name)); - $view->feed_link = url::abs_site("rss/tags/{$tag->id}"); - $view->children = $children; - - if ($page > 1) { - $previous_page = $page - 1; - $view->previous_page_link = url::site("rss/tags/{$tag->id}?page={$previous_page}"); - } - - if ($page < $max_pages) { - $next_page = $page + 1; - $view->next_page_link = url::site("rss/tags/{$tag->id}?page={$next_page}"); - } - - // @todo do we want to add an upload date to the items table? - $view->pub_date = date("D, d M Y H:i:s T"); - - rest::http_content_type(rest::RSS); - print $view; - } - - public function comments($id=null) { - $page = $this->input->get("page", 1); - if ($page < 1) { - url::redirect("rss/comments/$id"); - } - - $orm = ORM::factory("comment") - ->where("state", "published") - ->orderby("created", "DESC"); - if (!empty($id)) { - $orm->where("item_id", $id); - } - - $comments = $orm->find_all(self::$page_size, ($page - 1) * self::$page_size); - $max_pages = ceil($orm->count_last_query() / self::$page_size); - - if ($max_pages && $page > $max_pages) { - url::redirect("rss/comments/{$item->id}?page=$max_pages"); - } - - $view = new View("comment.mrss"); - $view->title = htmlspecialchars(t("Recent Comments")); - $view->link = url::abs_site("albums/1"); - $view->description = t("Recent Comments"); - $view->feed_link = url::abs_site("rss/comments"); - $view->pub_date = date("D, d M Y H:i:s T"); - - $view->children = array(); - foreach ($comments as $comment) { - $item = $comment->item(); - $view->children[] = array( - "pub_date" => date("D, d M Y H:i:s T", $comment->created), - "text" => htmlspecialchars($comment->text), - "thumb_url" => $item->thumb_url(), - "thumb_height" => $item->thumb_height, - "thumb_width" => $item->thumb_width, - "item_link" => htmlspecialchars(url::abs_site("{$item->type}s/$item->id")), - "title" =>htmlspecialchars($item->title), - "author" => - empty($comment->guest_name) ? $comment->author()->full_name : $comment->guest_name - ); - } - - if ($page > 1) { - $previous_page = $page - 1; - $view->previous_page_link = url::site("rss/comments/{$item->id}?page={$previous_page}"); - } - - if ($page < $max_pages) { - $next_page = $page + 1; - $view->next_page_link = url::site("rss/comments/{$item->id}?page={$next_page}"); - } - - rest::http_content_type(rest::RSS); - print $view; - } }
\ No newline at end of file diff --git a/modules/rss/helpers/rss.php b/modules/rss/helpers/rss.php index b320aeae..1d30425f 100644 --- a/modules/rss/helpers/rss.php +++ b/modules/rss/helpers/rss.php @@ -27,4 +27,33 @@ class rss_Core { static function tag_feed($tag) { return url::site("rss/tags/$tag->id}"); } + + /** + * Get all available rss feeds + */ + static function get_feeds($item, $sidebar_only=true) { + $feeds = array(); + foreach (module::active() as $module) { + $class_name = "{$module->name}_rss"; + if (method_exists($class_name, "available_feeds")) { + foreach (call_user_func(array($class_name, "available_feeds"), $item) as $feed) { + if ($sidebar_only && !$feed["sidebar"]) { + continue; + } + $feeds[$feed["description"]] = url::site("rss/{$feed['uri']}"); + } + } + } + + return $feeds; + } + + static function process_feed($feed, $offset, $limit, $id) { + foreach (module::active() as $module) { + $class_name = "{$module->name}_rss"; + if (method_exists($class_name, $feed)) { + return call_user_func(array($class_name, $feed), $offset, $limit, $id); + } + } + } }
\ No newline at end of file diff --git a/modules/rss/helpers/rss_theme.php b/modules/rss/helpers/rss_theme.php index 54bba210..b82133bd 100644 --- a/modules/rss/helpers/rss_theme.php +++ b/modules/rss/helpers/rss_theme.php @@ -40,16 +40,8 @@ class rss_theme_Core { $block->css_id = "gRss"; $block->title = t("Available RSS Feeds"); $block->content = new View("rss_block.html"); - // @todo consider pushing the code for the feeds back to the associated modules - // and create an event 'generate_rss_feeds' that modules can respond to create - // the list of feeds. - $feeds = array(t("New photos or movies") => url::site("rss/updates")); - if (module::is_active("comment")) { - $feeds[t("All new comments")] = url::site("rss/comments"); - $feeds[sprintf(t("Comments on %s"), $theme->item()->title)] = - url::site("rss/comments/{$theme->item()->id}"); - } - $block->content->feeds = $feeds; + $block->content->feeds = rss::get_feeds($theme->item()); + return $block; } } diff --git a/modules/server_add/helpers/server_add_task.php b/modules/server_add/helpers/server_add_task.php index 98575915..0482b47c 100644 --- a/modules/server_add/helpers/server_add_task.php +++ b/modules/server_add/helpers/server_add_task.php @@ -56,11 +56,12 @@ class server_add_task_Core { } else { $extension = strtolower(substr(strrchr($name, '.'), 1)); $source_path = "$path{$file['path']}/$name"; + $title = item::convert_filename_to_title($name); if (in_array($extension, array("flv", "mp4"))) { - $movie = movie::create($parent, $source_path, $name, $name, + $movie = movie::create($parent, $source_path, $name, $title, null, user::active()->id); } else { - $photo = photo::create($parent, $source_path, $name, $name, + $photo = photo::create($parent, $source_path, $name, $title, null, user::active()->id); } } diff --git a/modules/tag/helpers/tag_rss.php b/modules/tag/helpers/tag_rss.php new file mode 100644 index 00000000..ace7fd6a --- /dev/null +++ b/modules/tag/helpers/tag_rss.php @@ -0,0 +1,43 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +class tag_rss_Core { + static function available_feeds($item) { + return array(array("description" => t("Tag Album feed"), + "sidebar" => false, + "uri" => "tags")); + } + + static function tags($offset, $limit, $id) { + $tag = ORM::factory("tag", $id); + if (!$tag->loaded) { + return Kohana::show_404(); + } + + $feed = new stdClass(); + $feed->data["children"] = $tag->items($limit, $offset, "photo"); + $feed->max_pages = ceil($tag->count / $limit); + $feed->data["title"] = $tag->name; + $feed->data["link"] = url::abs_site("tags/{$tag->id}"); + $feed->data["description"] = t("Photos related to %tag_name", array("tag_name" => $tag->name)); + + return $feed; + } +} diff --git a/modules/tag/views/admin_tags.html.php b/modules/tag/views/admin_tags.html.php index 62e3a2a1..21661c48 100644 --- a/modules/tag/views/admin_tags.html.php +++ b/modules/tag/views/admin_tags.html.php @@ -30,7 +30,7 @@ <tr> <td> <? foreach ($tags as $i => $tag): ?> - <? $current_letter = strtoupper(substr($tag->name, 0, 1)) ?> + <? $current_letter = strtoupper(mb_substr($tag->name, 0, 1)) ?> <? if ($i == 0): /* first letter */ ?> <strong><?= $current_letter ?></strong> diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index a99c9506..68486e6d 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -80,7 +80,7 @@ <?= p::clean($user->email) ?> </td> <td> - <?= ($user->last_login == 0) ? "" : date("j-M-y", $user->last_login) ?> + <?= ($user->last_login == 0) ? "" : gallery::date($user->last_login) ?> </td> <td class="gActions"> <a href="<?= url::site("admin/users/edit_user_form/$user->id") ?>" |