diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-01-16 04:35:35 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-01-16 04:35:35 +0000 |
commit | b2e37f20c73f7f29bafca9bcf95c1e59902a50ee (patch) | |
tree | 5024f6efd4e347bee625222247f6d25be7d288a0 | |
parent | 2352dd162aacb6222aff7523aef4169223fe37a0 (diff) |
Move graphics::rebuild_dirty_images to core_task::rebuild_dirty_images
-rw-r--r-- | core/helpers/core_task.php | 45 | ||||
-rw-r--r-- | core/helpers/graphics.php | 48 |
2 files changed, 46 insertions, 47 deletions
diff --git a/core/helpers/core_task.php b/core/helpers/core_task.php index 2f37557d..a56c432f 100644 --- a/core/helpers/core_task.php +++ b/core/helpers/core_task.php @@ -21,7 +21,7 @@ class core_task_Core { static function available() { $dirty_count = graphics::find_dirty_images_query()->count(); return array(Task::factory() - ->callback("graphics::rebuild_dirty_images") + ->callback("core_task::rebuild_dirty_images") ->name(t("Rebuild Images")) ->description($dirty_count ? t2("You have one image which is out of date", @@ -30,4 +30,47 @@ class core_task_Core { : t("All your images are up to date")) ->severity($dirty_count ? log::WARNING : log::SUCCESS)); } + + /** + * Task that rebuilds all dirty images. + * @param Task_Model the task + */ + static function rebuild_dirty_images($task) { + $result = graphics::find_dirty_images_query(); + $remaining = $result->count(); + $completed = $task->get("completed", 0); + + $i = 0; + foreach ($result as $row) { + $item = ORM::factory("item", $row->id); + if ($item->loaded) { + graphics::generate($item); + } + + $completed++; + $remaining--; + + if (++$i == 2) { + break; + } + } + + $task->status = t2("Updated: 1 image. Total: %total_count.", + "Updated: %count images. Total: %total_count.", + $completed, + array("total_count" => ($remaining + $completed))); + + if ($completed + $remaining > 0) { + $task->percent_complete = (int)(100 * $completed / ($completed + $remaining)); + } else { + $task->percent_complete = 100; + } + + $task->set("completed", $completed); + if ($remaining == 0) { + $task->done = true; + $task->state = "success"; + site_status::clear("graphics_dirty"); + } + } }
\ No newline at end of file diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php index 2edfb5f8..67756c4b 100644 --- a/core/helpers/graphics.php +++ b/core/helpers/graphics.php @@ -221,7 +221,8 @@ class graphics_Core { "%count of your photos are out of date. %link_startClick here to fix them%link_end", $count, array("link_start" => "<a href=\"" . - url::site("admin/maintenance/start/graphics::rebuild_dirty_images?csrf=__CSRF__") . + url::site( + "admin/maintenance/start/core_task::rebuild_dirty_images?csrf=__CSRF__") . "\" class=\"gDialogLink\">", "link_end" => "</a>")), "graphics_dirty"); @@ -229,51 +230,6 @@ class graphics_Core { } /** - * Task that rebuilds all dirty images. - * @param Task_Model the task - */ - static function rebuild_dirty_images($task) { - $db = Database::instance(); - - $result = self::find_dirty_images_query(); - $remaining = $result->count(); - $completed = $task->get("completed", 0); - - $i = 0; - foreach ($result as $row) { - $item = ORM::factory("item", $row->id); - if ($item->loaded) { - self::generate($item); - } - - $completed++; - $remaining--; - - if (++$i == 2) { - break; - } - } - - $task->status = t2("Updated: 1 image. Total: %total_count.", - "Updated: %count images. Total: %total_count.", - $completed, - array("total_count" => ($remaining + $completed))); - - if ($completed + $remaining > 0) { - $task->percent_complete = (int)(100 * $completed / ($completed + $remaining)); - } else { - $task->percent_complete = 100; - } - - $task->set("completed", $completed); - if ($remaining == 0) { - $task->done = true; - $task->state = "success"; - site_status::clear("graphics_dirty"); - } - } - - /** * Detect which graphics toolkits are available on this system. Return an array of key value * pairs where the key is one of gd, imagemagick, graphicsmagick and the value is information * about that toolkit. For GD we return the version string, and for ImageMagick and |