summaryrefslogtreecommitdiff
path: root/core/helpers/graphics.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-28 23:48:15 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-28 23:48:15 +0000
commited8689f768f81d2c3ed8bee70c43d4f7c71c108e (patch)
tree35fccdad514cd834cc0b7cea86966604e617d3f0 /core/helpers/graphics.php
parent1d76689e4b3ea68cada5154d1c0e17b00dec6bd7 (diff)
Expand on the maintenance code to make it more robust and give the
admin more control. You can now track running tasks, resume stalled tasks, cancel running tasks, and remove finished tasks. Added graphics::compose() as a placeholder for future watermark operations. Added CSRF protection to maintenance urls.
Diffstat (limited to 'core/helpers/graphics.php')
-rw-r--r--core/helpers/graphics.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php
index 68aacaca..62bde88a 100644
--- a/core/helpers/graphics.php
+++ b/core/helpers/graphics.php
@@ -129,10 +129,17 @@ class graphics_Core {
}
/**
+ * Stub.
+ * @todo implement this
+ */
+ public static function compose($input_file, $output_file, $other_args) {
+ }
+
+ /**
* Return a query result that locates all items with dirty images.
* @return Database_Result Query result
*/
- private static function _find_dirty_images_query() {
+ public static function find_dirty_images_query() {
return Database::instance()->query(
"SELECT `id` FROM `items` " .
"WHERE (`thumb_dirty` = 1 AND (`type` <> 'album' OR `right` - `left` > 1))" .
@@ -147,12 +154,12 @@ class graphics_Core {
$db = Database::instance();
$db->query("UPDATE `items` SET `thumb_dirty` = 1, `resize_dirty` = 1");
- $count = self::_find_dirty_images_query()->count();
+ $count = self::find_dirty_images_query()->count();
if ($count) {
message::warning(
sprintf(_("%d of your photos are out of date. %sClick here to fix them%s"),
$count, "<a href=\"" .
- url::site("admin/maintenance/start/rebuild_images") .
+ url::site("admin/maintenance/start/rebuild_images?csrf=" . access::csrf_token()) .
"\" class=\"gDialogLink\">", "</a>"),
"graphics_dirty");
}
@@ -165,7 +172,7 @@ class graphics_Core {
public static function rebuild_dirty_images($task) {
$db = Database::instance();
- $result = self::_find_dirty_images_query();
+ $result = self::find_dirty_images_query();
$remaining = $result->count();
$completed = $task->get("completed", 0);
@@ -194,9 +201,9 @@ class graphics_Core {
}
$task->set("completed", $completed);
- $task->done = ($remaining == 0);
-
- if ($task->done) {
+ if ($remaining == 0) {
+ $task->done = true;
+ $task->state = "success";
message::clear_permanent("graphics_dirty");
}
}