summaryrefslogtreecommitdiff
path: root/core/helpers/graphics.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-05-26 05:28:59 +0000
committerBharat Mediratta <bharat@menalto.com>2009-05-26 05:28:59 +0000
commit7aed9239088b582a065da3fb63796ff66cd357c8 (patch)
tree8be9bc4faec21b20cbcc060ad5e9ca128465d09e /core/helpers/graphics.php
parent2966289b147ceae2fed79b9534840607bf38e0d8 (diff)
Restructure the module lifecycle.
Install: <module>_installer::install() is called, any necessary tables are created. Activate: <module>_installer::activate() is called. Module controllers are routable, helpers are accessible, etc. The module is in use. Deactivate: <module>_installer::deactivate() is called. Module code is not accessible or routable. Module is *not* in use, but its tables are still around. Uninstall: <module>_installer::uninstall() is called. Module is completely removed from the database. Admin > Modules will install and activate modules, but will only deactivate (will NOT uninstall modules).
Diffstat (limited to 'core/helpers/graphics.php')
-rw-r--r--core/helpers/graphics.php32
1 files changed, 30 insertions, 2 deletions
diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php
index b82b6ba8..6d51e60d 100644
--- a/core/helpers/graphics.php
+++ b/core/helpers/graphics.php
@@ -46,6 +46,7 @@ class graphics_Core {
$rule->operation = $operation;
$rule->priority = $priority;
$rule->args = serialize($args);
+ $rule->active = true;
$rule->save();
self::mark_dirty($target == "thumb", $target == "resize");
@@ -72,14 +73,33 @@ class graphics_Core {
* @param string $module_name
*/
static function remove_rules($module_name) {
- $db = Database::instance();
- $status = $db->delete("graphics_rules", array("module_name" => $module_name));
+ $status = Database::instance()->delete("graphics_rules", array("module_name" => $module_name));
if (count($status)) {
self::mark_dirty(true, true);
}
}
/**
+ * Activate the rules for this module, typically done when the module itself is deactivated.
+ * Note that this does not mark images as dirty so that if you deactivate and reactivate a
+ * module it won't cause all of your images to suddenly require a rebuild.
+ */
+ static function activate_rules($module_name) {
+ Database::instance()
+ ->update("graphics_rules",array("active" => true), array("module_name" => $module_name));
+ }
+
+ /**
+ * Deactivate the rules for this module, typically done when the module itself is deactivated.
+ * Note that this does not mark images as dirty so that if you deactivate and reactivate a
+ * module it won't cause all of your images to suddenly require a rebuild.
+ */
+ static function deactivate_rules($module_name) {
+ Database::instance()
+ ->update("graphics_rules",array("active" => false), array("module_name" => $module_name));
+ }
+
+ /**
* Rebuild the thumb and resize for the given item.
* @param Item_Model $item
*/
@@ -106,6 +126,7 @@ class graphics_Core {
return;
}
+ try {
foreach ($ops as $target => $output_file) {
if ($input_item->is_movie()) {
// Convert the movie to a JPG first
@@ -118,6 +139,7 @@ class graphics_Core {
foreach (ORM::factory("graphics_rule")
->where("target", $target)
+ ->where("active", true)
->orderby("priority", "asc")
->find_all() as $rule) {
$args = array($working_file, $output_file, unserialize($rule->args));
@@ -140,6 +162,12 @@ class graphics_Core {
$item->resize_dirty = 0;
}
$item->save();
+ } catch (Kohana_Exception $e) {
+ // 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->getTraceAsString());
+ }
}
/**