summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorChad Kieffer <ckieffer@gmail.com>2009-06-06 00:35:39 -0600
committerChad Kieffer <ckieffer@gmail.com>2009-06-06 00:35:39 -0600
commit7cdcb5179f6d5414c9224fb65b7b36ab69ba52da (patch)
treeffc78236234505ca953870dc68ffb76fe0cae872 /modules
parentc5425f42a4a13f7f585ffe45c070a865cdef6077 (diff)
parent329bd8caa126040ba7abaf28e8f76e0b6739ceff (diff)
Merge branch 'master' of git@github.com:gallery/gallery3
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/controllers/photos.php30
-rw-r--r--modules/gallery/helpers/gallery_installer.php2
-rw-r--r--modules/gallery/helpers/gallery_menu.php2
-rw-r--r--modules/gallery/helpers/gallery_task.php13
-rw-r--r--modules/gallery/helpers/graphics.php12
-rw-r--r--modules/gallery/helpers/locale.php1
-rw-r--r--modules/gallery/models/item.php2
-rw-r--r--modules/gallery/tests/Xss_Security_Test.php32
-rw-r--r--modules/gallery/tests/xss_data.txt5
-rw-r--r--modules/image_block/views/image_block_block.html.php2
10 files changed, 39 insertions, 62 deletions
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"] = "&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;"; // Arabic
+ $l["be_BY"] = "&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1110;"; // Belarusian
$l["bg_BG"] = "&#x0411;&#x044a;&#x043b;&#x0433;&#x0430;&#x0440;&#x0441;&#x043a;&#x0438;"; // Bulgarian
$l["ca_ES"] = "Catalan"; // Catalan
$l["cs_CZ"] = "&#x010c;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>