summaryrefslogtreecommitdiff
path: root/core/controllers/scaffold.php
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-03-03 05:59:38 +0000
committerTim Almdal <tnalmdal@shaw.ca>2009-03-03 05:59:38 +0000
commit7cadb4b21b90864b4151481da9aba244d7083788 (patch)
treef8df3ce866f69a6bc11790d3b2cb4c18a4ba297b /core/controllers/scaffold.php
parent1d5cca34efcd25473f00ed5d6594ea15c569622f (diff)
Refactored the batch Api: 1) created a small batch helper class:
Starting a batch call batch::operation(name, item). In the case of adding photos name = add and item is the parent of the new items. When the operation is finished the batch::end_operation(name) is called. operation and end_operation events are called. Handlers (i.e. item_created) can call batch::in_progress(name) to determine if a batch is being processed.
Diffstat (limited to 'core/controllers/scaffold.php')
-rw-r--r--core/controllers/scaffold.php12
1 files changed, 6 insertions, 6 deletions
diff --git a/core/controllers/scaffold.php b/core/controllers/scaffold.php
index 45242b8c..c7f336df 100644
--- a/core/controllers/scaffold.php
+++ b/core/controllers/scaffold.php
@@ -218,8 +218,8 @@ class Scaffold_Controller extends Template_Controller {
throw new Exception("@todo BAD_ALBUM");
}
- $batch_id = mt_rand();
- module::event("start_batch");
+ batch::operation("add", $parent);
+
cookie::set("add_photos_path", $path);
$photo_count = 0;
foreach (glob("$path/*.[Jj][Pp][Gg]") as $file) {
@@ -227,7 +227,7 @@ class Scaffold_Controller extends Template_Controller {
photo::create($parent, $file, basename($file), basename($file));
$photo_count++;
}
- module::event("end_batch");
+ batch::end_operation("add");
if ($photo_count > 0) {
log::success("content", "(scaffold) Added $photo_count photos",
@@ -244,8 +244,8 @@ class Scaffold_Controller extends Template_Controller {
$test_images = glob(APPPATH . "tests/images/*.[Jj][Pp][Gg]");
- $batch_id = mt_rand();
- module::event("start_batch");
+ batch::operation("add", null);
+
$album_count = $photo_count = 0;
for ($i = 0; $i < $count; $i++) {
set_time_limit(30);
@@ -269,7 +269,7 @@ class Scaffold_Controller extends Template_Controller {
$photo_count++;
}
}
- module::event("end_batch");
+ batch::end_operation("add");
if ($photo_count > 0) {
log::success("content", "(scaffold) Added $photo_count photos");