diff options
author | Chad Kieffer <ckieffer@gmail.com> | 2009-06-06 00:35:39 -0600 |
---|---|---|
committer | Chad Kieffer <ckieffer@gmail.com> | 2009-06-06 00:35:39 -0600 |
commit | 7cdcb5179f6d5414c9224fb65b7b36ab69ba52da (patch) | |
tree | ffc78236234505ca953870dc68ffb76fe0cae872 | |
parent | c5425f42a4a13f7f585ffe45c070a865cdef6077 (diff) | |
parent | 329bd8caa126040ba7abaf28e8f76e0b6739ceff (diff) |
Merge branch 'master' of git@github.com:gallery/gallery3
-rw-r--r-- | application/config/config.php | 3 | ||||
-rwxr-xr-x | installer/install.sql | 2 | ||||
-rw-r--r-- | modules/gallery/controllers/photos.php | 30 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_menu.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_task.php | 13 | ||||
-rw-r--r-- | modules/gallery/helpers/graphics.php | 12 | ||||
-rw-r--r-- | modules/gallery/helpers/locale.php | 1 | ||||
-rw-r--r-- | modules/gallery/models/item.php | 2 | ||||
-rw-r--r-- | modules/gallery/tests/Xss_Security_Test.php | 32 | ||||
-rw-r--r-- | modules/gallery/tests/xss_data.txt | 5 | ||||
-rw-r--r-- | modules/image_block/views/image_block_block.html.php | 2 | ||||
-rw-r--r-- | themes/default/js/ui.init.js | 4 | ||||
-rw-r--r-- | themes/default/views/photo.html.php | 3 |
14 files changed, 47 insertions, 66 deletions
diff --git a/application/config/config.php b/application/config/config.php index 6a30d91c..d274a31b 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -23,7 +23,8 @@ * then a full URL will be used, eg: http://localhost/kohana/. If it only includes * the path, and a site_protocol is specified, the domain will be auto-detected. */ -$config["site_domain"] = dirname($_SERVER["SCRIPT_NAME"]); +$config["site_domain"] = dirname( + empty($_SERVER["ORIG_SCRIPT_NAME"]) ? $_SERVER["SCRIPT_NAME"] : $_SERVER["ORIG_SCRIPT_NAME"]); /** * Force a default protocol to be used by the site. If no site_protocol is diff --git a/installer/install.sql b/installer/install.sql index 0aaf8e79..a06ef4e7 100755 --- a/installer/install.sql +++ b/installer/install.sql @@ -335,4 +335,4 @@ CREATE TABLE {vars} ( UNIQUE KEY `module_name` (`module_name`,`name`) ) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'),(2,'gallery','active_admin_theme','admin_default'),(3,'gallery','page_size','9'),(4,'gallery','thumb_size','200'),(5,'gallery','resize_size','640'),(6,'gallery','default_locale','en_US'),(7,'gallery','image_quality','75'),(9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'),(14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(17,'gallery','version','3.0 pre-beta git'),(18,'gallery','choose_default_tookit','1'),(19,'gallery','credits','Powered by <a href=\"%url\">Gallery %version</a>'),(21,'comment','spam_caught','0'); +INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'),(2,'gallery','active_admin_theme','admin_default'),(3,'gallery','page_size','9'),(4,'gallery','thumb_size','200'),(5,'gallery','resize_size','640'),(6,'gallery','default_locale','en_US'),(7,'gallery','image_quality','75'),(9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'),(14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(17,'gallery','version','3.0 beta 1'),(18,'gallery','choose_default_tookit','1'),(19,'gallery','credits','Powered by <a href=\"%url\">Gallery %version</a>'),(21,'comment','spam_caught','0'); diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 2de51bc7..f5be5d59 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -25,32 +25,22 @@ class Photos_Controller extends Items_Controller { public function _show($photo) { access::required("view", $photo); - // We sort by id ascending so for now, find sibling info by doing id based queries. - $next_item = ORM::factory("item") - ->viewable() - ->where("parent_id", $photo->parent_id) - ->where("id >", $photo->id) - ->orderby("id", "ASC") - ->find(); - $previous_item = ORM::factory("item") - ->viewable() - ->where("parent_id", $photo->parent_id) - ->where("id <", $photo->id) - ->orderby("id", "DESC") - ->find(); - $position = ORM::factory("item") - ->viewable() - ->where("parent_id", $photo->parent_id) - ->where("id <=", $photo->id) - ->count_all(); + $position = $photo->parent()->get_position($photo->id); + if ($position > 1) { + list ($previous_item, $ignore, $next_item) = + $photo->parent()->children(3, $position - 2); + } else { + $previous_item = null; + list ($next_item) = $photo->parent()->children(1, $position); + } $template = new Theme_View("page.html", "photo"); $template->set_global("item", $photo); $template->set_global("children", array()); $template->set_global("children_count", $photo->children_count()); $template->set_global("parents", $photo->parents()); - $template->set_global("next_item", $next_item->loaded ? $next_item : null); - $template->set_global("previous_item", $previous_item->loaded ? $previous_item : null); + $template->set_global("next_item", $next_item); + $template->set_global("previous_item", $previous_item); $template->set_global("sibling_count", $photo->parent()->children_count()); $template->set_global("position", $position); diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index b97adcd0..242bb486 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -249,7 +249,7 @@ class gallery_installer { block_manager::add("dashboard_center", "gallery", "log_entries"); module::set_version("gallery", 1); - module::set_var("gallery", "version", "3.0 pre-beta git"); + module::set_var("gallery", "version", "3.0 beta 1"); module::set_var("gallery", "choose_default_tookit", 1); // @todo this string needs to be picked up by l10n_scanner diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php index 97f0fd81..9729a868 100644 --- a/modules/gallery/helpers/gallery_menu.php +++ b/modules/gallery/helpers/gallery_menu.php @@ -127,7 +127,7 @@ class gallery_menu_Core { access::csrf_token()))) ->append(Menu::factory("link") ->id("advanced") - ->label("Advanced") + ->label(t("Advanced")) ->url(url::site("admin/advanced_settings")))) ->append(Menu::factory("link") ->id("modules") diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 6046bfc4..2493c49e 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -46,14 +46,22 @@ class gallery_task_Core { */ static function rebuild_dirty_images($task) { $result = graphics::find_dirty_images_query(); - $remaining = $result->count(); $completed = $task->get("completed", 0); + $ignored = $task->get("ignored", array()); + $remaining = $result->count() - count($ignored); $i = 0; foreach ($result as $row) { + if (array_key_exists($row->id, $ignored)) { + continue; + } + $item = ORM::factory("item", $row->id); if ($item->loaded) { - graphics::generate($item); + $success = graphics::generate($item); + if (!$success) { + $ignored[$item->id] = 1; + } } $completed++; @@ -76,6 +84,7 @@ class gallery_task_Core { } $task->set("completed", $completed); + $task->set("ignored", $ignored); if ($remaining == 0) { $task->done = true; $task->state = "success"; diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 605b9ff8..4846fa8a 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -102,11 +102,12 @@ class graphics_Core { /** * Rebuild the thumb and resize for the given item. * @param Item_Model $item + * @return true on successful generation */ static function generate($item) { if ($item->is_album()) { if (!$cover = $item->album_cover()) { - return; + return false; } $input_file = $cover->file_path(); $input_item = $cover; @@ -123,7 +124,10 @@ class graphics_Core { } if (empty($ops)) { - return; + $item->thumb_dirty = 0; + $item->resize_dirty = 0; + $item->save(); + return true; } try { @@ -166,8 +170,12 @@ class graphics_Core { // Something went wrong rebuilding the image. Leave it dirty and move on. // @todo we should handle this better. Kohana::log("error", "Caught exception rebuilding image: {$item->title}\n" . + $e->getMessage() . "\n" . $e->getTraceAsString()); + return false; } + + return true; } /** diff --git a/modules/gallery/helpers/locale.php b/modules/gallery/helpers/locale.php index 2ba0f255..c176dcc6 100644 --- a/modules/gallery/helpers/locale.php +++ b/modules/gallery/helpers/locale.php @@ -59,6 +59,7 @@ class locale_Core { private static function _init_language_data() { $l["af_ZA"] = "Afrikaans"; // Afrikaans $l["ar_SA"] = "العربية"; // Arabic + $l["be_BY"] = "Беларускі"; // Belarusian $l["bg_BG"] = "Български"; // Bulgarian $l["ca_ES"] = "Catalan"; // Catalan $l["cs_CZ"] = "Česky"; // Czech diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 10bad0b2..7dce9e51 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -380,7 +380,7 @@ class Item_Model extends ORM_MPTT { public function get_position($child_id) { $result = Database::instance()->query(" SELECT COUNT(*) AS position FROM {items} - WHERE parent_id = {$this->parent_id} + WHERE parent_id = {$this->id} AND {$this->sort_column} <= (SELECT {$this->sort_column} FROM {items} WHERE id = $child_id) ORDER BY {$this->sort_column} {$this->sort_order}"); diff --git a/modules/gallery/tests/Xss_Security_Test.php b/modules/gallery/tests/Xss_Security_Test.php index 03151c8c..e179482c 100644 --- a/modules/gallery/tests/Xss_Security_Test.php +++ b/modules/gallery/tests/Xss_Security_Test.php @@ -18,41 +18,9 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Xss_Security_Test extends Unit_Test_Case { - - static function scan_php_file($file, &$cache) { - $code = file_get_contents($file); - $raw_tokens = token_get_all($code); - unset($code); - - $tokens = array(); - $func_token_list = array("t" => array(), "t2" => array()); - $token_number = 0; - // Filter out HTML / whitespace, and build a lookup for global function calls. - foreach ($raw_tokens as $token) { - if ((!is_array($token)) || (($token[0] != T_WHITESPACE) && ($token[0] != T_INLINE_HTML))) { - if (is_array($token)) { - if ($token[0] == T_STRING && in_array($token[1], array("t", "t2"))) { - $func_token_list[$token[1]][] = $token_number; - } - } - $tokens[] = $token; - $token_number++; - } - } - unset($raw_tokens); - - if (!empty($func_token_list["t"])) { - l10n_scanner::_parse_t_calls($tokens, $func_token_list["t"], $cache); - } - if (!empty($func_token_list["t2"])) { - l10n_scanner::_parse_plural_calls($tokens, $func_token_list["t2"], $cache); - } - } - public function find_unescaped_variables_in_views_test() { foreach (glob("*/*/views/*.php") as $view) { $expr = null; - $line = null; $level = 0; $php = 0; $str = null; diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 04dbd23b..e3dbb188 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -279,7 +279,7 @@ modules/gallery/views/simple_uploader.html.php 30 $item->ti modules/gallery/views/simple_uploader.html.php 77 DIRTY $item->id modules/gallery/views/simple_uploader.html.php 81 DIRTY $csrf modules/image_block/views/image_block_block.html.php 3 DIRTY $item->url() -modules/image_block/views/image_block_block.html.php 4 DIRTY $item->thumb_image(array("class" => "gThumbnail")) +modules/image_block/views/image_block_block.html.php 4 DIRTY $item->thumb_img(array("class" => "gThumbnail")) modules/info/views/info_block.html.php 6 $item->title modules/info/views/info_block.html.php 11 $item->description modules/info/views/info_block.html.php 17 $item->name @@ -492,6 +492,7 @@ themes/admin_default/views/admin.html.php 31 DIRTY $theme->a themes/admin_default/views/admin.html.php 35 DIRTY $theme->admin_page_top() themes/admin_default/views/admin.html.php 41 DIRTY $theme->site_status() themes/admin_default/views/admin.html.php 43 DIRTY $theme->admin_header_top() +themes/admin_default/views/admin.html.php 46 DIRTY $csrf themes/admin_default/views/admin.html.php 50 DIRTY $theme->admin_menu() themes/admin_default/views/admin.html.php 52 DIRTY $theme->admin_header_bottom() themes/admin_default/views/admin.html.php 58 DIRTY $theme->messages() @@ -612,7 +613,7 @@ themes/default/views/photo.html.php 32 DIRTY $item->re themes/default/views/photo.html.php 36 DIRTY $theme->resize_bottom($item) themes/default/views/photo.html.php 40 $item->title themes/default/views/photo.html.php 41 $item->description -themes/default/views/photo.html.php 44 DIRTY $theme->photo_bottom() +themes/default/views/photo.html.php 47 DIRTY $theme->photo_bottom() themes/default/views/sidebar.html.php 2 DIRTY $theme->sidebar_top() themes/default/views/sidebar.html.php 6 DIRTY $theme->album_menu() themes/default/views/sidebar.html.php 8 DIRTY $theme->photo_menu() diff --git a/modules/image_block/views/image_block_block.html.php b/modules/image_block/views/image_block_block.html.php index 48a3c912..c51c1b4a 100644 --- a/modules/image_block/views/image_block_block.html.php +++ b/modules/image_block/views/image_block_block.html.php @@ -1,6 +1,6 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <div class="gImageBlock"> <a href="<?= $item->url() ?>"> - <?= $item->thumb_image(array("class" => "gThumbnail")) ?> + <?= $item->thumb_img(array("class" => "gThumbnail")) ?> </a> </div> diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js index ae6f1966..9d9d3079 100644 --- a/themes/default/js/ui.init.js +++ b/themes/default/js/ui.init.js @@ -12,7 +12,7 @@ var shortForms = new Array( ); $(document).ready(function() { - + // Initialize Superfish menus $("ul.gMenu").addClass("sf-menu"); $('ul.sf-menu').superfish({ @@ -64,7 +64,7 @@ $(document).ready(function() { // Collapse comments form, insert button to expand if ($("#gAddCommentForm").length) { - var showCommentForm = '<a href="#add_comment_form" class="showCommentForm gButtonLink ui-corner-all ui-icon-left ui-state-default right"><span class="ui-icon ui-icon-comment"></span>Add a comment</a>'; + var showCommentForm = '<a href="#add_comment_form" class="showCommentForm gButtonLink ui-corner-all ui-icon-left ui-state-default right"><span class="ui-icon ui-icon-comment"></span>' + ADD_A_COMMENT + '</a>'; $("#gAddCommentForm").hide(); $("#gComments").prepend(showCommentForm); $(".showCommentForm").click(function(){ diff --git a/themes/default/views/photo.html.php b/themes/default/views/photo.html.php index 85143da8..cc4cc750 100644 --- a/themes/default/views/photo.html.php +++ b/themes/default/views/photo.html.php @@ -41,5 +41,8 @@ <div><?= p::clean($item->description) ?></div> </div> + <script type="text/javascript"> + var ADD_A_COMMENT = "<?= t("Add a comment") ?>"; + </script> <?= $theme->photo_bottom() ?> </div> |