Permalink
Browse files

Initial import of eZ components: Base and ConsoleTools.

  • Loading branch information...
sebastianbergmann committed Jun 30, 2006
1 parent 937b138 commit 5d53036714e0fd44e5ef5ec77e77eabcb1e21e7f
Showing with 6,970 additions and 0 deletions.
  1. +451 −0 Bundled/eZcomponents/Base/base.php
  2. +25 −0 Bundled/eZcomponents/Base/base_autoload.php
  3. +43 −0 Bundled/eZcomponents/Base/exceptions/exception.php
  4. +25 −0 Bundled/eZcomponents/Base/exceptions/file_exception.php
  5. +50 −0 Bundled/eZcomponents/Base/exceptions/file_io.php
  6. +43 −0 Bundled/eZcomponents/Base/exceptions/file_not_found.php
  7. +63 −0 Bundled/eZcomponents/Base/exceptions/file_permission.php
  8. +28 −0 Bundled/eZcomponents/Base/exceptions/property_not_found.php
  9. +42 −0 Bundled/eZcomponents/Base/exceptions/property_permission.php
  10. +28 −0 Bundled/eZcomponents/Base/exceptions/setting_not_found.php
  11. +41 −0 Bundled/eZcomponents/Base/exceptions/setting_value.php
  12. +42 −0 Bundled/eZcomponents/Base/exceptions/value.php
  13. +40 −0 Bundled/eZcomponents/Base/exceptions/whatever.php
  14. +142 −0 Bundled/eZcomponents/Base/options.php
  15. +51 −0 Bundled/eZcomponents/ConsoleTools/console_autoload.php
  16. +20 −0 Bundled/eZcomponents/ConsoleTools/exceptions/exception.php
  17. +26 −0 Bundled/eZcomponents/ConsoleTools/exceptions/invalid_option_name.php
  18. +25 −0 Bundled/eZcomponents/ConsoleTools/exceptions/no_position_stored.php
  19. +22 −0 Bundled/eZcomponents/ConsoleTools/exceptions/option.php
  20. +25 −0 Bundled/eZcomponents/ConsoleTools/exceptions/option_already_registered.php
  21. +26 −0 Bundled/eZcomponents/ConsoleTools/exceptions/option_arguments_violation.php
  22. +31 −0 Bundled/eZcomponents/ConsoleTools/exceptions/option_dependency_violation.php
  23. +31 −0 Bundled/eZcomponents/ConsoleTools/exceptions/option_exclusion_violation.php
  24. +26 −0 Bundled/eZcomponents/ConsoleTools/exceptions/option_mandatory_violation.php
  25. +26 −0 Bundled/eZcomponents/ConsoleTools/exceptions/option_missing_value.php
  26. +25 −0 Bundled/eZcomponents/ConsoleTools/exceptions/option_no_alias.php
  27. +25 −0 Bundled/eZcomponents/ConsoleTools/exceptions/option_not_exists.php
  28. +25 −0 Bundled/eZcomponents/ConsoleTools/exceptions/option_string_not_wellformed.php
  29. +26 −0 Bundled/eZcomponents/ConsoleTools/exceptions/option_too_many_values.php
  30. +38 −0 Bundled/eZcomponents/ConsoleTools/exceptions/option_type_violation.php
  31. +1,032 −0 Bundled/eZcomponents/ConsoleTools/input.php
  32. +602 −0 Bundled/eZcomponents/ConsoleTools/input/option.php
  33. +122 −0 Bundled/eZcomponents/ConsoleTools/options/output.php
  34. +139 −0 Bundled/eZcomponents/ConsoleTools/options/progressbar.php
  35. +58 −0 Bundled/eZcomponents/ConsoleTools/options/progressmonitor.php
  36. +66 −0 Bundled/eZcomponents/ConsoleTools/options/statusbar.php
  37. +247 −0 Bundled/eZcomponents/ConsoleTools/options/table.php
  38. +500 −0 Bundled/eZcomponents/ConsoleTools/output.php
  39. +443 −0 Bundled/eZcomponents/ConsoleTools/progressbar.php
  40. +208 −0 Bundled/eZcomponents/ConsoleTools/progressmonitor.php
  41. +247 −0 Bundled/eZcomponents/ConsoleTools/statusbar.php
  42. +144 −0 Bundled/eZcomponents/ConsoleTools/structs/option_rule.php
  43. +169 −0 Bundled/eZcomponents/ConsoleTools/structs/output_format.php
  44. +109 −0 Bundled/eZcomponents/ConsoleTools/structs/output_formats.php
  45. +784 −0 Bundled/eZcomponents/ConsoleTools/table.php
  46. +148 −0 Bundled/eZcomponents/ConsoleTools/table/cell.php
  47. +368 −0 Bundled/eZcomponents/ConsoleTools/table/row.php
  48. +73 −0 package.xml

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,25 @@
+<?php
+/**
+ * @package Base
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ * @version 1.1
+ * @filesource
+ */
+
+return array(
+ 'ezcBaseException' => 'Base/exceptions/exception.php',
+ 'ezcBaseFileException' => 'Base/exceptions/file_exception.php',
+
+ 'ezcBaseFileNotFoundException' => 'Base/exceptions/file_not_found.php',
+ 'ezcBaseFileIoException' => 'Base/exceptions/file_io.php',
+ 'ezcBaseFilePermissionException' => 'Base/exceptions/file_permission.php',
+ 'ezcBasePropertyPermissionException' => 'Base/exceptions/property_permission.php',
+ 'ezcBasePropertyNotFoundException' => 'Base/exceptions/property_not_found.php',
+ 'ezcBaseSettingNotFoundException' => 'Base/exceptions/setting_not_found.php',
+ 'ezcBaseSettingValueException' => 'Base/exceptions/setting_value.php',
+ 'ezcBaseValueException' => 'Base/exceptions/value.php',
+
+ 'ezcBaseOptions' => 'Base/options.php',
+);
+?>
@@ -0,0 +1,43 @@
+<?php
+/**
+ * File containing the ezcBaseException class.
+ *
+ * @package Base
+ * @version 1.1
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * ezcBaseException is a container from which all other exceptions in the
+ * components library descent.
+ *
+ * @package Base
+ * @version 1.1
+ */
+abstract class ezcBaseException extends Exception
+{
+ /**
+ * Original message, before escaping
+ */
+ public $originalMessage;
+
+ /**
+ * Constructs a new ezcBaseException with $message
+ *
+ * @param string $message
+ */
+ public function __construct( $message )
+ {
+ $this->originalMessage = $message;
+
+ if ( php_sapi_name() == 'cli' )
+ {
+ parent::__construct( $message );
+ }
+ else
+ {
+ parent::__construct( htmlspecialchars( $message ) );
+ }
+ }
+}
+?>
@@ -0,0 +1,25 @@
+<?php
+/**
+ * File containing the ezcBaseFileException class
+ *
+ * @package Base
+ * @version 1.1
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * ezcBaseFileException is the exception from which all file related exceptions
+ * inherit.
+ *
+ * @package Base
+ * @version 1.1
+ */
+abstract class ezcBaseFileException extends ezcBaseException
+{
+ const READ = 1;
+ const WRITE = 2;
+ const EXECUTE = 4;
+ const CHANGE = 8;
+ const REMOVE = 16;
+}
+?>
@@ -0,0 +1,50 @@
+<?php
+/**
+ * File containing the ezcBaseFileIoException class
+ *
+ * @package Base
+ * @version 1.1
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * ezcBaseFileIoException is thrown when a problem occurs while writing
+ * and reading to/from an open file.
+ *
+ * @package Base
+ * @version 1.1
+ */
+class ezcBaseFileIoException extends ezcBaseFileException
+{
+ /**
+ * Constructs a new ezcBaseFileIoException for the file $path.
+ *
+ * @param string $name The name of the file.
+ * @param int $mode The mode of the property that is allowed
+ * (ezcBaseFileException::READ, ezcBaseFileException::WRITE,
+ * ezcBaseFileException::EXECUTE or
+ * ezcBaseFileException::CHANGE).
+ * @param string $message A string with extra information.
+ */
+ function __construct( $path, $mode, $message = null )
+ {
+ switch ( $mode )
+ {
+ case ezcBaseFileException::READ:
+ $operation = "An error occurred while reading from <{$path}>";
+ break;
+ case ezcBaseFileException::WRITE:
+ $operation = "An error occurred while writing to <{$path}>";
+ break;
+ }
+
+ $messagePart = '';
+ if ( $message )
+ {
+ $messagePart = " ($message)";
+ }
+
+ parent::__construct( "$operation.$messagePart" );
+ }
+}
+?>
@@ -0,0 +1,43 @@
+<?php
+/**
+ * File containing the ezcBaseFileNotFoundException class
+ *
+ * @package Base
+ * @version 1.1
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * ezcBaseFileNotFoundException is thrown when a file or directory was tried to
+ * be opened, but did not exist.
+ *
+ * @package Base
+ * @version 1.1
+ */
+class ezcBaseFileNotFoundException extends ezcBaseFileException
+{
+ /**
+ * Constructs a new ezcBaseFileNotFoundException.
+ *
+ * @param string $name The name of the file.
+ * @param string $type The type of the file.
+ * @param string $message A string with extra information.
+ */
+ function __construct( $path, $type = null, $message = null )
+ {
+ $typePart = '';
+ if ( $type )
+ {
+ $typePart = "$type ";
+ }
+
+ $messagePart = '';
+ if ( $message )
+ {
+ $messagePart = " ($message)";
+ }
+
+ parent::__construct( "The {$typePart}file <{$path}> could not be found.$messagePart" );
+ }
+}
+?>
@@ -0,0 +1,63 @@
+<?php
+/**
+ * File containing the ezcBaseFilePermissionException class
+ *
+ * @package Base
+ * @version 1.1
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * ezcBaseFilePermissionException is thrown whenever a permission problem with
+ * a file, directory or stream occurred.
+ *
+ * @package Base
+ * @version 1.1
+ */
+class ezcBaseFilePermissionException extends ezcBaseFileException
+{
+ /**
+ * Constructs a new ezcPropertyPermissionException for the property $name.
+ *
+ * @param string $name The name of the file.
+ * @param int $mode The mode of the property that is allowed
+ * (ezcBaseFileException::READ, ezcBaseFileException::WRITE,
+ * ezcBaseFileException::EXECUTE,
+ * ezcBaseFileException::CHANGE or
+ * ezcBaseFileException::REMOVE).
+ * @param string $message A string with extra information.
+ */
+ function __construct( $path, $mode, $message = null )
+ {
+ switch ( $mode )
+ {
+ case ezcBaseFileException::READ:
+ $operation = "The file <{$path}> can not be opened for reading";
+ break;
+ case ezcBaseFileException::WRITE:
+ $operation = "The file <{$path}> can not be opened for writing";
+ break;
+ case ezcBaseFileException::EXECUTE:
+ $operation = "The file <{$path}> can not be executed";
+ break;
+ case ezcBaseFileException::CHANGE:
+ $operation = "The permissions for <{$path}> can not be changed";
+ break;
+ case ezcBaseFileException::REMOVE:
+ $operation = "The file <{$path}> can not be removed";
+ break;
+ case ( ezcBaseFileException::READ || ezcBaseFileException::WRITE ):
+ $operation = "The file <{$path}> can not be opened for reading and writing";
+ break;
+ }
+
+ $messagePart = '';
+ if ( $message )
+ {
+ $messagePart = " ($message)";
+ }
+
+ parent::__construct( "$operation.$messagePart" );
+ }
+}
+?>
@@ -0,0 +1,28 @@
+<?php
+/**
+ * File containing the ezcPropertyNotFoundException class
+ *
+ * @package Base
+ * @version 1.1
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * ezcBasePropertyNotFoundException is thrown whenever a non existent property
+ * is accessed in the Components library.
+ *
+ * @package Base
+ * @version 1.1
+ */
+class ezcBasePropertyNotFoundException extends ezcBaseException
+{
+ /**
+ * Constructs a new ezcPropertyNotFoundException for the property
+ * $name.
+ */
+ function __construct( $name )
+ {
+ parent::__construct( "No such property name <{$name}>." );
+ }
+}
+?>
@@ -0,0 +1,42 @@
+<?php
+/**
+ * File containing the ezcPropertyReadOnlyException class
+ *
+ * @package Base
+ * @version 1.1
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * ezcBasePropertyPermissionException is thrown whenever a read-only property
+ * is tried to be changed, or when a write-only property was accessed for reading.
+ *
+ * @package Base
+ * @version 1.1
+ */
+class ezcBasePropertyPermissionException extends ezcBaseException
+{
+ /**
+ * Used when the property is read-only.
+ */
+ const READ = 1;
+
+ /**
+ * Used when the property is write-only.
+ */
+ const WRITE = 2;
+
+ /**
+ * Constructs a new ezcPropertyPermissionException for the property $name.
+ *
+ * @param string $name The name of the property.
+ * @param int $mode The mode of the property that is allowed (::READ or ::WRITE).
+ */
+ function __construct( $name, $mode )
+ {
+ parent::__construct( "The property <{$name}> is " .
+ ( $mode == self::READ ? "read" : "write" ) .
+ "-only." );
+ }
+}
+?>
@@ -0,0 +1,28 @@
+<?php
+/**
+ * File containing the ezcBaseSettingNotFoundException class.
+ *
+ * @package Base
+ * @version 1.1
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * ezcBaseSettingNotFoundException is thrown whenever there is a name passed as
+ * part as the options array to setOptions() for an option that doesn't exist.
+ *
+ * @package Base
+ */
+class ezcBaseSettingNotFoundException extends ezcBaseException
+{
+ /**
+ * Constructs a new ezcBaseSettingNotFoundException for $settingName.
+ *
+ * @param string $settingName The name of the setting that does not exist.
+ */
+ function __construct( $settingName )
+ {
+ parent::__construct( "The setting <{$settingName}> is not a valid configuration setting." );
+ }
+}
+?>
@@ -0,0 +1,41 @@
+<?php
+/**
+ * File containing the ezcBaseSettingValueException class.
+ *
+ * @package Base
+ * @version 1.1
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * ezcBaseSettingValueExeception is thrown whenever a value to a class'
+ * configuration option is either of the wrong type, or has a wrong value.
+ *
+ * @package Base
+ */
+class ezcBaseSettingValueException extends ezcBaseException
+{
+ /**
+ * Constructs a new ezcBaseConfigException
+ *
+ * @param string $settingName The name of the setting where something was
+ * wrong with.
+ * @param mixed $value The value that the option was tried to be set too.
+ * @param string $expectedValue A string explaining the allowed type and value range.
+ */
+ function __construct( $settingName, $value, $expectedValue = null )
+ {
+ $type = gettype( $value );
+ if ( in_array( $type, array( 'array', 'object', 'resource' ) ) )
+ {
+ $value = serialize( $value );
+ }
+ $msg = "The value <{$value}> that you were trying to assign to setting <{$settingName}> is invalid.";
+ if ( $expectedValue )
+ {
+ $msg .= " Allowed values are: " . $expectedValue;
+ }
+ parent::__construct( $msg );
+ }
+}
+?>
Oops, something went wrong.

0 comments on commit 5d53036

Please sign in to comment.