Author: Tobias Schlitt
Date: 2006-01-29 12:40:05 +0100 (Sun, 29 Jan 2006)
New Revision: 2080

Log:
- Update examples and synchronized with inline docs.

Modified:
   packages/Cache/trunk/docs/example_ezpublish.php
   packages/Cache/trunk/docs/example_general.php
   packages/Cache/trunk/src/manager.php
   packages/ConsoleTools/trunk/docs/example_input.php
   packages/ConsoleTools/trunk/docs/example_output.php
   packages/ConsoleTools/trunk/docs/example_progressbar.php
   packages/ConsoleTools/trunk/docs/example_table.php
   packages/ConsoleTools/trunk/docs/example_table_2.php
   packages/ConsoleTools/trunk/src/input.php
   packages/ConsoleTools/trunk/src/output.php
   packages/ConsoleTools/trunk/src/progressbar.php
   packages/ConsoleTools/trunk/src/statusbar.php
   packages/ConsoleTools/trunk/src/table.php

Modified: packages/Cache/trunk/docs/example_ezpublish.php
===================================================================
--- packages/Cache/trunk/docs/example_ezpublish.php     2006-01-29 11:24:50 UTC 
(rev 2079)
+++ packages/Cache/trunk/docs/example_ezpublish.php     2006-01-29 11:40:05 UTC 
(rev 2080)
@@ -39,6 +39,5 @@
     // ... and store it inside the cache
     $cache->store( $id, $attributes, $data );
 }
-
 // And that's all! : )
 ?>

Modified: packages/Cache/trunk/docs/example_general.php
===================================================================
--- packages/Cache/trunk/docs/example_general.php       2006-01-29 11:24:50 UTC 
(rev 2079)
+++ packages/Cache/trunk/docs/example_general.php       2006-01-29 11:40:05 UTC 
(rev 2080)
@@ -12,7 +12,6 @@
 
 // Some pre-work, needed by the example
 $basePath = dirname( __FILE__ ).'/cache';
-
 function getUniqueId()
 {
     return 'This is a unique ID';
@@ -25,15 +24,7 @@
  */
 function __autoload( $class_name )
 {
-    if ( ezcBase::autoload( $class_name ) )
-    {
-        return;
-    }
-    if ( strpos( $class_name, '_' ) !== false )
-    {
-        $file = str_replace( '_', '/', $class_name ) . '.php';
-        require_once( $file );
-    }
+    ezcBase::autoload( $class_name );
 }
 
 // Central creation and configuration of the caches
@@ -102,5 +93,4 @@
 // attributes. This will result in all cache items to be deleted, that
 // have this attribute assigned.
 $cache->delete( null, array( 'node' => 5 ) );
-
 ?>

Modified: packages/Cache/trunk/src/manager.php
===================================================================
--- packages/Cache/trunk/src/manager.php        2006-01-29 11:24:50 UTC (rev 
2079)
+++ packages/Cache/trunk/src/manager.php        2006-01-29 11:40:05 UTC (rev 
2080)
@@ -21,6 +21,13 @@
  * 
  * Usage example for ezcCacheManager:
  * <code>
+ * // Some pre-work, needed by the example
+ * $basePath = dirname( __FILE__ ).'/cache';
+ * function getUniqueId()
+ * {
+ *     return 'This is a unique ID';
+ * }
+ * 
  * // Central creation and configuration of the caches
  * // The ezcCacheManager just stores the configuration right now and 
  * // performs sanity checks. The [EMAIL PROTECTED] ezcCacheStorage} instances
@@ -44,8 +51,8 @@
  * 
  * // Somewhere in the application you can access the caches
  *  
- * // Retreive the cache we configured earlier and identified it as "content".
- * // Right now the instance of [EMAIL PROTECTED] ezcCacheStorageFileArray} is 
created and
+ * // Get the instance of the cache called "content"
+ * // Now the instance of [EMAIL PROTECTED] ezcCacheStorageFileArray is 
created and
  * // returned to be used. Next time you access this cache, the created
  * // instance will be reused.
  * $cache = ezcCacheManager::getCache( 'content' );

Modified: packages/ConsoleTools/trunk/docs/example_input.php
===================================================================
--- packages/ConsoleTools/trunk/docs/example_input.php  2006-01-29 11:24:50 UTC 
(rev 2079)
+++ packages/ConsoleTools/trunk/docs/example_input.php  2006-01-29 11:40:05 UTC 
(rev 2080)
@@ -8,6 +8,7 @@
  * @license http://ez.no/licenses/new_bsd New BSD License
  */
 
+require_once "Base/trunk/src/base.php";
 /**
  * Autoload ezc classes 
  * 
@@ -15,14 +16,13 @@
  */
 function __autoload( $class_name )
 {
-    require_once "Base/trunk/src/base.php";
     ezcBase::autoload( $class_name );
 }
 
-$paramHandler = new ezcConsoleInput();
+$optionHandler = new ezcConsoleInput();
 
 // Register simple parameter -h/--help
-$paramHandler->registerOption( new ezcConsoleOption( 'h', 'help' ) );
+$optionHandler->registerOption( new ezcConsoleOption( 'h', 'help' ) );
 
 // Register complex parameter -f/--file
 $file = new ezcConsoleOption(
@@ -34,7 +34,7 @@
  'Process a file.',
  'Processes a single file.'
 );
-$paramHandler->registerOption( $file );
+$optionHandler->registerOption( $file );
 
 // Manipulate parameter -f/--file after registration
 $file->multiple = true;
@@ -48,18 +48,18 @@
  true,
  'Process a directory.',
  'Processes a complete directory.',
- array( new ezcConsoleOptionRule( $paramHandler->getOption( 'f' ) ) ),
- array( new ezcConsoleOptionRule( $paramHandler->getOption( 'h' ) ) )
+ array( new ezcConsoleOptionRule( $optionHandler->getOption( 'f' ) ) ),
+ array( new ezcConsoleOptionRule( $optionHandler->getOption( 'h' ) ) )
 );
-$paramHandler->registerOption( $dir );
+$optionHandler->registerOption( $dir );
 
 // Register an alias for this parameter
-$paramHandler->registerAlias( 'e', 'extended-dir', $dir );
+$optionHandler->registerAlias( 'e', 'extended-dir', $dir );
 
 // Process registered parameters and handle errors
 try
 {
-     $paramHandler->process( array( 'example_input.php', '-h' ) );
+     $optionHandler->process( array( 'example_input.php', '-h' ) );
 }
 catch ( ezcConsoleInputException $e )
 {
@@ -73,7 +73,7 @@
 }
 
 // Process a single parameter
-$file = $paramHandler->getOption( 'f' );
+$file = $optionHandler->getOption( 'f' );
 if ( $file->value === false )
 {
      echo "Parameter -{$file->short}/--{$file->long} was not submitted.\n";
@@ -88,7 +88,7 @@
 }
 
 // Process all parameters at once:
-foreach ( $paramHandler->getOptionValues() as $paramShort => $val )
+foreach ( $optionHandler->getOptionValues() as $paramShort => $val )
 {
      switch ( true )
      {

Modified: packages/ConsoleTools/trunk/docs/example_output.php
===================================================================
--- packages/ConsoleTools/trunk/docs/example_output.php 2006-01-29 11:24:50 UTC 
(rev 2079)
+++ packages/ConsoleTools/trunk/docs/example_output.php 2006-01-29 11:40:05 UTC 
(rev 2080)
@@ -8,6 +8,8 @@
  * @license http://ez.no/licenses/new_bsd New BSD License
  */
 
+require_once "Base/trunk/src/base.php";
+
 /**
  * Autoload ezc classes 
  * 
@@ -15,7 +17,6 @@
  */
 function __autoload( $class_name )
 {
-    require_once "Base/trunk/src/base.php";
     ezcBase::autoload( $class_name );
 }
 
@@ -23,7 +24,7 @@
 $out = new ezcConsoleOutput();
 
 // Set the verbosity to level 10
-$out->options->verboseLevel = 10;
+$out->options->verbosityLevel = 10;
 // Enable auto wrapping of lines after 40 characters
 $out->options->autobreak    = 40;
 
@@ -55,6 +56,8 @@
 
 // This is visible, since we set verboseLevel to 10, and printed in default 
format (now blue)
 $out->outputText( "Some verbose output.\n", null, 10 );
+// This is not visible, since we set verboseLevel to 10
+$out->outputText( "Some more verbose output.\n", null, 20 );
 // This is visible, since we set verboseLevel to 10, and printed in format 
'failure'
 $out->outputText( "And some not so verbose, failure output.\n", 'failure', 5 );
 ?>

Modified: packages/ConsoleTools/trunk/docs/example_progressbar.php
===================================================================
--- packages/ConsoleTools/trunk/docs/example_progressbar.php    2006-01-29 
11:24:50 UTC (rev 2079)
+++ packages/ConsoleTools/trunk/docs/example_progressbar.php    2006-01-29 
11:40:05 UTC (rev 2080)
@@ -8,6 +8,8 @@
  * @license http://ez.no/licenses/new_bsd New BSD License
  */
 
+require_once "Base/trunk/src/base.php";
+
 /**
  * Autoload ezc classes 
  * 
@@ -15,14 +17,13 @@
  */
 function __autoload( $class_name )
 {
-    require_once "Base/trunk/src/base.php";
     ezcBase::autoload( $class_name );
 }
 
 $out = new ezcConsoleOutput();
 
 // Create progress bar itself
-$progress = new ezcConsoleProgressbar( $out, 100, 5 );
+$progress = new ezcConsoleProgressbar( $out, 100, array( 'step' => 5 ) );
 
 $progress->options->emptyChar = '-';
 $progress->options->progressChar = '#';

Modified: packages/ConsoleTools/trunk/docs/example_table.php
===================================================================
--- packages/ConsoleTools/trunk/docs/example_table.php  2006-01-29 11:24:50 UTC 
(rev 2079)
+++ packages/ConsoleTools/trunk/docs/example_table.php  2006-01-29 11:40:05 UTC 
(rev 2080)
@@ -8,6 +8,7 @@
  * @license http://ez.no/licenses/new_bsd New BSD License
  */
 
+require_once "Base/trunk/src/base.php";
 /**
  * Autoload ezc classes 
  * 
@@ -15,7 +16,6 @@
  */
 function __autoload( $class_name )
 {
-    require_once "Base/trunk/src/base.php";
     ezcBase::autoload( $class_name );
 }
 

Modified: packages/ConsoleTools/trunk/docs/example_table_2.php
===================================================================
--- packages/ConsoleTools/trunk/docs/example_table_2.php        2006-01-29 
11:24:50 UTC (rev 2079)
+++ packages/ConsoleTools/trunk/docs/example_table_2.php        2006-01-29 
11:40:05 UTC (rev 2080)
@@ -8,6 +8,7 @@
  * @license http://ez.no/licenses/new_bsd New BSD License
  */
 
+require_once "Base/trunk/src/base.php";
 /**
  * Autoload ezc classes 
  * 
@@ -15,7 +16,6 @@
  */
 function __autoload( $class_name )
 {
-    require_once "Base/trunk/src/base.php";
     ezcBase::autoload( $class_name );
 }
 

Modified: packages/ConsoleTools/trunk/src/input.php
===================================================================
--- packages/ConsoleTools/trunk/src/input.php   2006-01-29 11:24:50 UTC (rev 
2079)
+++ packages/ConsoleTools/trunk/src/input.php   2006-01-29 11:40:05 UTC (rev 
2080)
@@ -15,10 +15,10 @@
  * to a console based application.
  *
  * <code>
- * $paramHandler = new ezcConsoleInput();
+ * $optionHandler = new ezcConsoleInput();
  * 
  * // Register simple parameter -h/--help
- * $paramHandler->registerOption( new ezcConsoleOption( 'h', 'help' ) );
+ * $optionHandler->registerOption( new ezcConsoleOption( 'h', 'help' ) );
  * 
  * // Register complex parameter -f/--file
  * $file = new ezcConsoleOption(
@@ -30,7 +30,7 @@
  *  'Process a file.',
  *  'Processes a single file.'
  * );
- * $paramHandler->registerOption( $file );
+ * $optionHandler->registerOption( $file );
  * 
  * // Manipulate parameter -f/--file after registration
  * $file->multiple = true;
@@ -44,27 +44,32 @@
  *  true,
  *  'Process a directory.',
  *  'Processes a complete directory.',
- *  array( new ezcConsoleOptionRule( $paramHandler->getOption( 'f' ) ) ),
- *  array( new ezcConsoleOptionRule( $paramHandler->getOption( 'h' ) ) )
+ *  array( new ezcConsoleOptionRule( $optionHandler->getOption( 'f' ) ) ),
+ *  array( new ezcConsoleOptionRule( $optionHandler->getOption( 'h' ) ) )
  * );
- * $paramHandler->registerOption( $dir );
+ * $optionHandler->registerOption( $dir );
  * 
  * // Register an alias for this parameter
- * $paramHandler->registerAlias( 'e', 'extended-dir', $dir );
+ * $optionHandler->registerAlias( 'e', 'extended-dir', $dir );
  * 
  * // Process registered parameters and handle errors
  * try
  * {
- *      $paramHandler->process( array( 'example_input.php', '-h' ) );
+ *      $optionHandler->process( array( 'example_input.php', '-h' ) );
  * }
- * catch ( ezcConsoleOptionDependencyViolationException $e )
+ * catch ( ezcConsoleInputException $e )
  * {
- *      $consoleOut->outputText( $e->getMessage() );
+ *      if ( $e->getCode() === 
ezcConsoleInputException::PARAMETER_DEPENDENCY_RULE_NOT_MET )
+ *      {
+ *          $consoleOut->outputText(
+ *              'Parameter ' . isset( $e->param ) ? $e->param->name : 
'unknown' . " may not occur here.\n", 'error'
+ *          );
+ *      }
  *      exit( 1 );
  * }
  * 
  * // Process a single parameter
- * $file = $paramHandler->getOption( 'f' );
+ * $file = $optionHandler->getOption( 'f' );
  * if ( $file->value === false )
  * {
  *      echo "Parameter -{$file->short}/--{$file->long} was not submitted.\n";
@@ -79,9 +84,9 @@
  * }
  * 
  * // Process all parameters at once:
- * foreach ( $paramHandler->getOptionValues() as $paramShort => $val )
+ * foreach ( $optionHandler->getOptionValues() as $paramShort => $val )
  * {
- *      switch (true)
+ *      switch ( true )
  *      {
  *          case $val === false:
  *              echo "Parameter $paramShort was not submitted.\n";
@@ -89,7 +94,7 @@
  *          case $val === true:
  *              echo "Parameter $paramShort was submitted without a value.\n";
  *              break;
- *          case is_array($val):
+ *          case is_array( $val ):
  *              echo "Parameter $paramShort was submitted multiple times with 
value: <".implode(', ', $val).">.\n";
  *              break;
  *          default:

Modified: packages/ConsoleTools/trunk/src/output.php
===================================================================
--- packages/ConsoleTools/trunk/src/output.php  2006-01-29 11:24:50 UTC (rev 
2079)
+++ packages/ConsoleTools/trunk/src/output.php  2006-01-29 11:40:05 UTC (rev 
2080)
@@ -27,35 +27,35 @@
  * 
  * // Set the color of the default output format to green
  * $out->formats->default->color   = 'green';
- *
+ * 
  * // Set the color of the output format named 'success' to white
  * $out->formats->success->color   = 'white';
  * // Set the style of the output format named 'success' to bold
  * $out->formats->success->style   = array( 'bold' );
- *
+ * 
  * // Set the color of the output format named 'failure' to red
  * $out->formats->failure->color   = 'red';
  * // Set the style of the output format named 'failure' to bold
  * $out->formats->failure->style   = array( 'bold' );
  * // Set the background color of the output format named 'failure' to blue
  * $out->formats->failure->bgcolor = 'blue';
- *
+ * 
  * // Output text with default format
  * $out->outputText( 'This is default text ' );
  * // Output text with format 'success'
  * $out->outputText( 'including success message', 'success' );
  * // Some more output with default output.
  * $out->outputText( "and a manual linebreak.\n" );
- *
+ * 
  * // Manipulate the later output
  * $out->formats->success->color = 'green';
  * $out->formats->default->color = 'blue';
- *
- * // This is visible, since we set verbosityLevel to 10, and printed in
- * // default format (now blue)
+ * 
+ * // This is visible, since we set verboseLevel to 10, and printed in default 
format (now blue)
  * $out->outputText( "Some verbose output.\n", null, 10 );
- * // This is visible, since we set verbosityLevel to 10, and printed in format
- * // 'failure'
+ * // This is not visible, since we set verboseLevel to 10
+ * $out->outputText( "Some more verbose output.\n", null, 20 );
+ * // This is visible, since we set verboseLevel to 10, and printed in format 
'failure'
  * $out->outputText( "And some not so verbose, failure output.\n", 'failure', 
5 );
  * </code>
  *

Modified: packages/ConsoleTools/trunk/src/progressbar.php
===================================================================
--- packages/ConsoleTools/trunk/src/progressbar.php     2006-01-29 11:24:50 UTC 
(rev 2079)
+++ packages/ConsoleTools/trunk/src/progressbar.php     2006-01-29 11:40:05 UTC 
(rev 2080)
@@ -13,11 +13,10 @@
  * Creating and maintaining progressbars to be printed to the console. 
  *
  * <code>
- *
  * $out = new ezcConsoleOutput();
  * 
  * // Create progress bar itself
- * $progress = new ezcConsoleProgressbar( $out, 100, 5 );
+ * $progress = new ezcConsoleProgressbar( $out, 100, array( 'step' => 5 ) );
  * 
  * $progress->options->emptyChar = '-';
  * $progress->options->progressChar = '#';
@@ -25,7 +24,7 @@
  * 
  * // Perform actions
  * $i = 0;
- * while ( $i++ < 20 ) 
+ * while( $i++ < 20 ) 
  * {
  *     // Do whatever you want to indicate progress for
  *     usleep( mt_rand( 20000, 2000000 ) );
@@ -37,7 +36,6 @@
  * $progress->finish();
  * 
  * $out->outputText( "Successfully uploaded </tmp/foobar.tar.bz2>.\n", 
'success' );
- *
  * </code>
  *  
  * 

Modified: packages/ConsoleTools/trunk/src/statusbar.php
===================================================================
--- packages/ConsoleTools/trunk/src/statusbar.php       2006-01-29 11:24:50 UTC 
(rev 2079)
+++ packages/ConsoleTools/trunk/src/statusbar.php       2006-01-29 11:40:05 UTC 
(rev 2080)
@@ -13,7 +13,6 @@
  * Creating  and maintaining statusbars to be printed to the console. 
  *
  * <code>
- *
  * // Construction
  * $status = new ezcConsoleStatusbar( new ezcConsoleOutput() );
  *
@@ -31,7 +30,6 @@
  * // Retreive and display final statusbar results
  * $msg = $status->getSuccess() . ' succeeded, ' . $status->getFailure() . ' 
failed.';
  * $out->outputText( "Finished uploading files: $msg\n" );
- *
  * </code>
  *  
  * 

Modified: packages/ConsoleTools/trunk/src/table.php
===================================================================
--- packages/ConsoleTools/trunk/src/table.php   2006-01-29 11:24:50 UTC (rev 
2079)
+++ packages/ConsoleTools/trunk/src/table.php   2006-01-29 11:40:05 UTC (rev 
2080)
@@ -13,7 +13,6 @@
  * Creating tables to be printed to the console. 
  *
  * <code>
- * 
  * // Initialize the console output handler
  * $out = new ezcConsoleOutput();
  * // Define a new format "headline"
@@ -51,7 +50,6 @@
  * $table[2]->format = 'sum';
  * 
  * $table->outputTable();
- *
  * </code>
  * 
  *

-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to