Skip to content

Commit

Permalink
Initial import of eZ components: Base and ConsoleTools.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jun 30, 2006
1 parent 937b138 commit 5d53036
Show file tree
Hide file tree
Showing 48 changed files with 6,970 additions and 0 deletions.
451 changes: 451 additions & 0 deletions Bundled/eZcomponents/Base/base.php

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions Bundled/eZcomponents/Base/base_autoload.php
Original file line number Diff line number Diff line change
@@ -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',
);
?>
43 changes: 43 additions & 0 deletions Bundled/eZcomponents/Base/exceptions/exception.php
Original file line number Diff line number Diff line change
@@ -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 ) );
}
}
}
?>
25 changes: 25 additions & 0 deletions Bundled/eZcomponents/Base/exceptions/file_exception.php
Original file line number Diff line number Diff line change
@@ -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;
}
?>
50 changes: 50 additions & 0 deletions Bundled/eZcomponents/Base/exceptions/file_io.php
Original file line number Diff line number Diff line change
@@ -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" );
}
}
?>
43 changes: 43 additions & 0 deletions Bundled/eZcomponents/Base/exceptions/file_not_found.php
Original file line number Diff line number Diff line change
@@ -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" );
}
}
?>
63 changes: 63 additions & 0 deletions Bundled/eZcomponents/Base/exceptions/file_permission.php
Original file line number Diff line number Diff line change
@@ -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" );
}
}
?>
28 changes: 28 additions & 0 deletions Bundled/eZcomponents/Base/exceptions/property_not_found.php
Original file line number Diff line number Diff line change
@@ -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}>." );
}
}
?>
42 changes: 42 additions & 0 deletions Bundled/eZcomponents/Base/exceptions/property_permission.php
Original file line number Diff line number Diff line change
@@ -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." );
}
}
?>
28 changes: 28 additions & 0 deletions Bundled/eZcomponents/Base/exceptions/setting_not_found.php
Original file line number Diff line number Diff line change
@@ -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." );
}
}
?>
41 changes: 41 additions & 0 deletions Bundled/eZcomponents/Base/exceptions/setting_value.php
Original file line number Diff line number Diff line change
@@ -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 );
}
}
?>
Loading

0 comments on commit 5d53036

Please sign in to comment.