ez projects / batchtool / forum / general / [patch] using ez components...
You need to be logged in to post messages in the forums. New users may register here.
Member since: Posts: 6 |
Monday 26 July 2010 4:34:22 pm The following patch (created using git and git-svn) will render a progress bar instead of printing successfully modified nodes. Errors will still be printed.
From 2d99c7b7804a801ec35f7372ef54eb1c12cc8f0a Mon Sep 17 00:00:00 2001 From: Leif Arne Storset <lstorset@opera.com> Date: Mon, 26 Jul 2010 16:20:52 +0200 Subject: [PATCH] Using eZ Components' ProgressBar --- cronjobs/batchtool.php | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diff --git a/cronjobs/batchtool.php b/cronjobs/batchtool.php index 47c01e5..bda9bf7 100644 --- a/cronjobs/batchtool.php +++ b/cronjobs/batchtool.php @@ -6,6 +6,15 @@ include_once( 'lib/ezutils/classes/ezfunctionhandler.php' ); include_once( 'kernel/classes/ezcontentobjecttreenodeoperations.php' ); include_once( 'kernel/classes/ezcontentobjectoperations.php' ); include_once( 'extension/batchtool/classes/lib.php' ); +include_once( 'extension/batchtool/classes/lib.php' ); + +// eZ Components +$useBundledComponents = defined( 'EZP_USE_BUNDLED_COMPONENTS' ) ? EZP_USE_BUNDLED_COMPONENTS === true : file_exists( 'lib/ezc' ); +if ( $useBundledComponents ) +{ + set_include_path( './lib/ezc' . PATH_SEPARATOR . get_include_path() ); +} +include 'ConsoleTools/src/progressbar.php'; $standard_options = "[h|help][q|quiet][d;*|debug;*][c|colors][no-colors][logfiles][no-logfiles][s:|siteaccess:][l:|login:][p:|password:][v*|verbose*]"; $script_options = "[f:|filter:*][o:|operation:*][and][or]"; @@ -207,6 +216,11 @@ echo "Running operations on $total_count objects.\n"; $changed_count = 0; $duplicate_count = 0; $object_id_array = array(); + +// Set up progress bar +$output = new ezcConsoleOutput(); +$bar = new ezcConsoleProgressbar( $output, count($object_list) ); + foreach( $object_list as $object ) { $object_id = $object->attribute( $idFieldName ); @@ -228,8 +242,12 @@ foreach( $object_list as $object ) if ( $result ) $changed_count++; - echo ( $result ) ? "Done operations on node $object_id\n" : "Operations failed on node $object_id\n"; + + $bar->advance(); + if ( !$result ) + echo "\nOperations failed on node $object_id\n"; } +$bar->finish(); echo "$total_count nodes processed, $changed_count nodes successfull, $duplicate_count duplicates.\n"; -- 1.7.0.4 Leif Arne Storset |
|
|
Member since: Posts: 6 |
Wednesday 28 July 2010 10:12:34 pm Thanks for this, very nice solution.
Only problem I see with bringing in eZ Components is that it won't work on older eZ Publish versions. But there maybe is no need to support pre-4 versions now anyway. I'll have to think about this, but I'd like to include the patch. |
You need to be logged in to post messages in the forums. New users may register here.