License updated to GPLv3

🧲 New features
Custom user role permissions
Employee edit form updated
Employee daily task list
Attendance and employee distribution charts on dashboard
Improvements to company structure and company assets module
Improved tables for displaying data in several modules
Faster data loading (specially for employee module)
Initials based profile pictures
Re-designed login page
Re-designed user profile page
Improvements to filtering
New REST endpoints for employee qualifications

🐛 Bug fixes
Fixed, issue with managers being able to create performance reviews for employees who are not their direct reports
Fixed, issues related to using full profile image instead of using smaller version of profile image
Changing third gender to other
Improvements and fixes for internal frontend data caching
This commit is contained in:
Thilina Pituwala
2020-10-31 19:02:37 +01:00
parent 86b8345505
commit b1df0037db
29343 changed files with 867614 additions and 2191082 deletions

View File

@@ -0,0 +1,3 @@
vendor
run-tests-tmp
extract

View File

@@ -0,0 +1,19 @@
language: php
php:
- 5.6
- 7.0
- 7.1
- 7.2
- nightly
matrix:
allow_failures:
- php: nightly
before_script:
- composer self-update
- composer update
script:
- vendor/bin/phpunit

View File

@@ -0,0 +1,16 @@
CREDITS
=======
eZ Components team
------------------
- Sergey Alexeev
- Sebastian Bergmann
- Jan Borsodi
- Raymond Bosman
- Frederik Holljen
- Kore Nordmann
- Derick Rethans
- Vadym Savchuk
- Tobias Schlitt
- Alexandru Stanoi

View File

@@ -0,0 +1,354 @@
1.9.1 - Tuesday 11 November 2017
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- PHP 7.2 support, which deprecates __autoload and "Object" is now a keyword.
1.9 - Friday 12 September 2014
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Adjusted source headers of Base to Apache license.
- Updated: Moving copyright information to NOTICE files.
- Use ezc_autoload() instead of __autoload(). (tests)
- Use assertInternalType() instead of assertType() where appropriate. (tests)
- Use assertInstanceOf() instead of assertType(). (tests)
- Fixed #ZETACOMP-39: ezcBaseOptions implements Iterator.
- Fixed #ZETACOMP-59: ezcBaseFileFindRecursiveTest::testRecursive1|2|4() now work.
- Fixed #ZETACOMP-33: Many dead links (404).
- Remove custom test runner.
- Fix ezcBaseTest.
- Added composer.json and test dependencies.
- Added Travis configuration.
1.8 - Monday 21 December 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #15896: Autoload not working for all lowercase class names.
1.7 - Monday 29 June 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- No changes
1.7rc1 - Monday 22 June 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed an issue with the PEAR reader as sometimes the returned structure is
different.
1.7beta1 - Monday 08 June 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Made sure that we (try) to load the PEAR Registry class so that PEAR doesn't
have to be in autoload.
1.7alpha1 - Tuesday 26 May 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added 'SunOS' to the list of Unices to make finding binaries work on Solaris
as well.
- Implemented issue #13718: Include metadata about installed components that
can be queried to figure out required PHP versions, dependencies and
component versions.
1.6.1 - Monday 09 February 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #14402: Auto detection of external programs (binaries) does not
throw warnings anymore.
1.6 - Monday 05 January 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added a workaround for a segfault in call_user_func() in PHP 5.2.x.
1.6rc1 - Monday 15 December 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Implemented issue #12542: Refactored the ezcBaseFile::findRecursive() method
into the ezcBase::walkRecursive() method so that you can setup your own
callbacks to "do things". The findRecursive() method is now implemented
through this.
- Fixed issue #14091: Incorrect documentation for
ezcBaseConfigurationInitializer.
1.6beta1 - Monday 01 December 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added the exception class ezcBaseFunctionalityNotSupportedException.
1.5.2 - Monday 06 October 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed an issue in ezcBaseFile::removeRecursive, where the parent directory
could not be written to. We now make sure nothing is deleted until we're sure
everything can be deleted.
1.5.1 - Monday 04 August 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #13370: Infinitive loop in ezcBaseFile::calculateRelativePath().
- Implemented issue #11865: Different development modes.
1.5 - Monday 16 June 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- No changes.
1.5rc1 - Tuesday 10 June 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- No changes
1.5beta1 - Tuesday 27 May 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added the ezcBasePersistable interface that can be used to ensure that the
object implementing this interface can be used with PersistentObject and
Search.
1.5alpha2 - Tuesday 13 May 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed a bug in ezcBaseFile::findRecursive that prevented you from passing an
empty array to collect statistics.
- Changed ezcBase::getInstallationPath() so that it always returns a trailing
directory separator.
1.5alpha1 - Monday 07 April 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Implemented issue #8529: Added a by-reference argument to
ezcBaseFile::findRecursive that returns statistsics (count and total size)
of all files that are returned by this function.
- Implemented issue #11506: Added the static method
ezcBase::getInstallationPath().
- Implemented issue #12694: replace reflection test for class type with spl
function.
1.4.1 - Monday 14 January 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #11448: ezc_bootsrap.php uses relative paths.
- Fixed issue #12316: Numbers in own component prefix not possible.
- Fixed issue #12329: ezcBaseFeatures::findExecutableInPath's return value
does not include the extension to the executable at the end on Windows.
- Added an optional argument to the ezcBaseValueException constructor to allow
the exception to be used for non-property/setting type violations as well.
1.4 - Monday 17 December 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- No changes.
1.4rc1 - Wednesday 05 December 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- No changes.
1.4beta1 - Wednesday 28 November 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- No changes.
1.4alpha2 - Monday 29 October 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added the ezcBaseFile::copyRecursive() method, to recursively copy files or
directories
- Fixed issue #11540: Problems with ezcFile::findRecursive and
ezcFile::calculateRelativePath on systems where DIRECTORY_SEPERATOR is not
//.
1.4alpha1 - Tuesday 18 September 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added the ezcBaseFile class, which was moved from the File component.
- Added the ezcBaseFile::isAbsolutePath() method, which returns whether a path
is absolute or relative.
1.3.1 - Monday 30 July 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #11057: The ezcBaseConfigurationInitializer inteface is not
enforced for callback classes.
1.3 - Monday 02 July 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Documentation fixes and updates.
1.3rc1 - Monday 25 June 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Documentation fixes and updates.
1.3beta2 - Thursday 31 May 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #10704: Autoload fails on class not found. The exception is now
off by default, but can be turned on through the "debug" property of the
ezcBaseAutoloadOptions class. This option class can be set with
ezcBase::setOptions().
1.3beta1 - Monday 07 May 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #8433: ezcBase::getRepositoryDirectories() problems.
- Fixed issue #10583: ezcBaseOptions misses __isset().
- Fixed issue #10666: ezc_bootstrap.php fails on Windows.
- Implemented issue #9569: Add "autoload.php" as 3rd fallback autoload file to
search for.
- Implemented issue #9988: Implement component preloading for better opcode
cache performance.
- Added exception class ezcBaseExtensionNotFoundException to be thrown when an
extension is required but is not found.
- Changed the ezcBaseInit::fetchConfig() method to return the value that was
returned from the callback function.
1.2 - Monday 18 December 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #9658: Checking if $_ENV['PATH'] is set before using it in
ezcBaseFeatures.
- Fixed issue #9780: ezcBaseFeatures throws notice about non-existing array
key "PATH".
- Fixed issue #9819: Let all components deal with the ezcBaseAutoloadException
properly.
- Fixed the exception name for 'ezcBaseDoubleClassRepositoryPrefix' - it was
missing "Exception".
- Implemented issue #9811: If a file for a class can not be found through
autoloading, we now throw the ezcBaseAutoloadException which makes debugging
easier.
- Added the static method ezcBaseFeatures::findExecutableInPath() that searches the
path for the given executable.
- Added the static method ezcBaseFeatures::os() that returns a sanitized
version of the current OS' name.
1.2beta2 - Monday 20 November 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #8507: Two autoload directories with the same basepath don't
work.
- Fixed issue #9390: Classes in external repositories that map to the same
autoload filename of an internal component were added to the external
autoload cache array as well.
1.2beta1 - Tuesday 24 October 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added the ezcBaseFeatures class to check whether the current PHP
installation and environment provides features that can be used in the
components.
- Added the ezcBaseInit class that assists you by setting up on-demand
configurations for objects (most notable useful for singleton classes).
- Implemented FR #8508: Display search paths for the autoload files in case of
a missing class.
- Implemented FR #8753: Added the 'Base/ezc_bootstrap.php' file which sets up
the autoload environment for you to facilitate an easier way of starting to
use the eZ components.
1.1.1 - Monday 28 August 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added the ezcBaseStruct class from which all structs in all components
should inherit from.
1.1 - Friday 09 June 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed bug #8434: ezcBase autoload system does not handle classes without a
prefix.
- Fixed bug #8435: ezcBase::addClassRepository assumes the ezc way of
structuring files. From now on the path specifying the autoload directory is
*not* relative to the repository directory anymore.
1.1rc1 - Monday 29 May 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed bug #8252: Autoloading for external repositories only works for the
first such class.
1.1beta2 - Tuesday 09 May 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added support for external class repositories. You can now add a class
repository to the autoload mechanism by using the addClassRepository()
method.
- Added a method to return all configured class repositories.
- Added the REMOVE constant to the ezcBaseFileException.
- Added the ezcBaseOptions class that serves as base class for all option
classes in the components.
1.1beta1 - Wednesday 19 April 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Changed the way how files are included when the SVN checkout of the eZ
components was used. This does not affect normal use of the components.
- Fixed class descriptions for the exceptions in the documentation.
1.0 - Monday 30 January 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added HTML escaping of exception messages so that they show up correctly in
a browser. The original message is stored in the originalMessage property
in the exception object.
1.0rc1 - Monday 16 January 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added the ezcBaseException that all exceptions in the components library
should descent from.
- Added generic File and IO exceptions that all other components can use
instead of having to reimplement them.
- Added ezcBase::checkDependency() method that allows components to specify
dependencies on either a PHP version or a PHP extension.
1.0beta2 - Wednesday 21 December 2005
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added the ezcBasePropertyException that can be used by components to signal
that an property was assigned a value which it does not allows.
1.0beta1 - Tuesday 22 November 2005
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Initial release of this package.

View File

@@ -0,0 +1,2 @@
The Base package provides the basic infrastructure that all packages rely on.
Therefore every component relies on this package.

View File

@@ -0,0 +1,215 @@
Zeta Components
Copyright 2011-2015 The Zeta Components development group
Apache Zeta Components
Copyright 2010-2011 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Originally developed by eZ Systems as eZ Components
Copyright 2005-2010 eZ Systems AS (http://ez.no)
-----
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,48 @@
{
"authors": [
{
"name": "Sergey Alexeev"
},
{
"name": "Sebastian Bergmann"
},
{
"name": "Jan Borsodi"
},
{
"name": "Raymond Bosman"
},
{
"name": "Frederik Holljen"
},
{
"name": "Kore Nordmann"
},
{
"name": "Derick Rethans"
},
{
"name": "Vadym Savchuk"
},
{
"name": "Tobias Schlitt"
},
{
"name": "Alexandru Stanoi"
}
],
"autoload": {
"classmap": [
"src"
]
},
"description": "The Base package provides the basic infrastructure that all packages rely on. Therefore every component relies on this package.",
"homepage": "https://github.com/zetacomponents",
"license": "Apache-2.0",
"name": "zetacomponents/base",
"type": "library",
"require-dev": {
"phpunit/phpunit": "~5.7",
"zetacomponents/unit-test": "*"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

View File

@@ -0,0 +1,9 @@
Base
====
Purpose
-------
This is the base package of the eZ publish components, offering the basic
support that all Components need. In the first version this will be the
autoload support.

View File

@@ -0,0 +1,9 @@
<?php
class erMyClass1
{
function toString()
{
echo "Class 'erMyClass1'\n";
}
}
?>

View File

@@ -0,0 +1,9 @@
<?php
class erMyClass2
{
function toString()
{
echo "Class 'erMyClass2'\n";
}
}
?>

View File

@@ -0,0 +1,9 @@
<?php
class erYourClass1
{
function toString()
{
echo "Class 'erYourClass1'\n";
}
}
?>

View File

@@ -0,0 +1,9 @@
<?php
class erYourClass2
{
function toString()
{
echo "Class 'erYourClass2'\n";
}
}
?>

View File

@@ -0,0 +1,6 @@
<?php
return array (
'erMyClass1' => 'Me/myclass1.php',
'erMyClass2' => 'Me/myclass2.php',
);
?>

View File

@@ -0,0 +1,6 @@
<?php
return array (
'erYourClass1' => 'You/yourclass1.php',
'erYourClass2' => 'You/yourclass2.php',
);
?>

View File

@@ -0,0 +1,240 @@
eZ Components - Base
~~~~~~~~~~~~~~~~~~~~
.. contents:: Table of Contents
Introduction
============
The Base component provides the basic functionality, such as autoloading, that
all eZ Components need to function properly. The Base component needs to be
loaded specifically. Base can also autoload external class repositories from
outside the eZ Components.
Aside from the autoload functionality, the Base component also contains a number of
generic Exception classes that all inherit from the ezcBaseException class.
Installation
============
The installation and configuration of the eZ Components environment is
described in a separate article. Please refer to the `Components Introduction`_
for instructions on installation and configuration of the eZ Components library
and the Base component.
.. _Components Introduction: ../../../../zetacomponents/documentation/install.html
Usage
=====
Debugging
---------
By default the ezcBase component's autoload mechanism will not throw an
exception when an autoload class can not be found. In some cases (during
development) it is useful to have an exception with detailed information
about which autoload files were searched for, and in which directories.
ezcBase supports an option that enables this behavior::
<?php
$options = new ezcBaseAutoloadOptions;
$options->debug = true;
ezcBase::setOptions( $options );
?>
**Warning**: Exceptions are ignored when they are thrown from an autoload()
handler in PHP. In order to see the exception message that is thrown when a
class can not be found, you need to catch the exception *in* the autoload()
handler. Your autoload() function could then look like::
function __autoload( $className )
{
try
{
ezcBase::autoload( $className );
}
catch ( Exception $e )
{
echo $e->getMessage();
}
}
Preloading
----------
The default autoload policy of the eZ Components is to load every class
file on demand only. It is also possible to load all classes of one
component at the same time, when one of the component's classes is
requested for the first time. You can change this behavior with the
"preload" option that is available through the ezcBaseAutoloadOptions option
class. You can turn preloading on with::
<?php
$options = new ezcBaseAutoloadOptions;
$options->preload = true;
ezcBase::setOptions( $options );
?>
Please note that preloading will *not* be done for Exception classes.
Adding class repositories located outside eZ Components to autoload system
--------------------------------------------------------------------------
It can be useful to add repositories of user-defined classes to the eZ
Components autoload system. The ezcBase::addClassRepository() method can be
used to perform this task. You need to arrange the desired external classes
in a class repository. That is, make sure that classes and corresponding
\*_autoload.php files are named and placed according to the explanations below.
After they are in the proper structure, you can call addClassRepository() with
the proper parameters before you use the external classes.
External classes will then be loaded by autoload system.
ezcBase::addClassRepository() takes two arguments:
- $basePath is the base path for the whole class repository.
- $autoloadDirPath is the path where autoload files for this repository are found.
The paths in the autoload files are *not* relative to the package directory
as specified by the $basePath argument. In other words, class definition files will
only be searched for in the location $autoloadDirPath.
Consider the following example:
- There is a class repository stored in the directory "./repos".
- Autoload files for this repository are stored in "./repos/autoloads".
- There are two components in this repository: "Me" and "You".
- The "Me" component has the classes "erMyClass1" and "erMyClass2".
- The "You" component has the classes "erYourClass1" and "erYourClass2".
In this case, you need to create the following files in "./repos/autoloads".
Note that the prefix to _autoload.php ("my" and "your") in the filename is the
first part of the classname (excluding the lowercase classname prefix - "er").
Content of my_autoload.php:
.. include:: repos/autoloads/my_autoload.php
:literal:
Content of your_autoload.php:
.. include:: repos/autoloads/your_autoload.php
:literal:
The directory structure for the external repository is then: ::
./repos/autoloads/my_autoload.php
./repos/autoloads/your_autoload.php
./repos/Me/myclass1.php
./repos/Me/myclass2.php
./repos/You/yourclass1.php
./repos/You/yourclass2.php
To use this repository with the autoload mechanism, use the
following code:
.. include:: tutorial_example_01.php
:literal:
The above code will output: ::
Class 'erMyClass2'
Class 'erYourClass1'
Lazy initialization
-------------------
Lazy initialization is a mechanism to load and configure a component, only
when it is really used in your application. This mechanism saves time for
parsing the classes and configuration, when the component is not used at all
during one request. The implementation in ezcBaseInit may be reused by other
applications and components, like the following example will show.
.. include:: tutorial_lazy_initialization.php
:literal:
The example shows a random class implementing the singleton pattern, which may
be some database connection handler, or anything similar in your case. The
getInstance() method shows a typical PHP 5 implementation except the
additional line 14, which checks, if a configuration callback was provided
earlier and configures the newly created instance. If no configuration
callback was provided, nothing will happen. The customKey is used to receive
the right callback from ezcBaseInit and needs to be known by the user, who
wants to define a configuration callback for your class.
In line 32 the class used to configure your instance on creation is defined.
The first parameter is the key used earlier in the getInstance method, to
reference the right class, and the second parameter is the name of your
configuration class.
The configuration class beginning in line 22 just needs to implement the
ezcBaseConfigurationInitializer interface, which defines one
method: configureObject(). This method will be called with the object to
configure as a single parameter. In the example, a new public property on the
customSingleton instance is created, which will be echo'd later to show the
success of the configuration.
The configuration itself will not happen before the actual instance is created
in line 35 performing the static call on customSingleton::getInstance(). The
var_dump() in the following line shows, that the property value is set and
contains the earlier set value (int) 42.
File Operations
---------------
Finding files recursively
`````````````````````````
This example shows how to use the ezcBaseFile::findRecursive() method:
.. include:: tutorial_example_02.php
:literal:
The code in this example searches for files in the ``/dat/dev/ezcomponents``
directory. It will only include files that match *all* patterns in the
$includeFilters array (the second parameter). Files that match *any* of the
patterns in the $excludeFilters array (the third parameter) will not be returned.
In other words, the code above searches for files in the ``dat/dev/ezcomponents``
directory, which are in the ``src/`` directory and end with ``_autoload.php``,
except for files that are in the ``/autoload/`` directory.
Removing directories recursively
````````````````````````````````
This example shows how to use the ezcBaseFile::removeRecursive() method:
.. include:: tutorial_example_03.php
:literal:
This code simply removes the directory ``/dat/dev/ezcomponents/trash`` and all
of its files and sub-directories.
**Warning: Use this function with care, as it has the potential to erase
everything that the current user has access to.**
Overloading the callback
````````````````````````
The ezcBaseFile::findRecursive() method internally uses the
ezcBaseFile::walkRecursive() method to do the actual recursing. The callback
method ezcBaseFile::findRecursiveCallback() is then responsible for collecting
the data. In case you want to do additional things, such as printing progress,
you can either call walkRecursive() yourself with a callback function of your
choice, or overload the ezcBaseFile class and provide a new
findRecursiveCallback() method. The code below uses
ezcBaseFile::walkRecursive() directly in order to display dots for when ever it
finds a new directory:
.. include:: tutorial_example_04.php
:literal:
..
Local Variables:
mode: rst
fill-column: 79
End:
vim: et syn=rst tw=79

View File

@@ -0,0 +1,20 @@
<?php
$dir = dirname( __FILE__ );
$dirParts = explode( DIRECTORY_SEPARATOR, $dir );
switch ( $dirParts[count( $dirParts ) - 3] )
{
case 'doc': require_once 'ezc/Base/base.php'; break; // pear
case 'trunk': require_once "$dir/../../Base/src/base.php"; break; // svn
default: require_once "$dir/../../Base/src/base.php"; break; // bundle
}
/**
* Autoload ezc classes
*
* @param string $className
*/
function __autoload( $className )
{
ezcBase::autoload( $className );
}
?>

View File

@@ -0,0 +1,9 @@
<?php
require_once 'tutorial_autoload.php';
ezcBase::addClassRepository( './repos', './repos/autoloads' );
$myVar1 = new erMyClass2();
$myVar1->toString();
$yourVar1 = new erYourClass1();
$yourVar1->toString();
?>

View File

@@ -0,0 +1,11 @@
<?php
require 'tutorial_autoload.php';
$data = ezcBaseFile::findRecursive(
"/dat/dev/ezcomponents",
array( '@src/.*_autoload.php$@' ),
array( '@/autoload/@' )
);
var_dump( $data );
?>

View File

@@ -0,0 +1,6 @@
<?php
require 'tutorial_autoload.php';
ezcBaseFile::removeRecursive( '/dat/dev/ezcomponents/trash' );
?>

View File

@@ -0,0 +1,42 @@
<?php
require 'tutorial_autoload.php';
class myProgressFinder
{
static public function findRecursiveCallback( ezcBaseFileFindContext $context, $sourceDir, $fileName, $fileInfo )
{
// ignore if we have a directory, but do print a "." and sleep for
// extra demo time
if ( $fileInfo['mode'] & 0x4000 )
{
echo ".";
usleep( 100000 );
return;
}
// update the statistics
$context->elements[] = $sourceDir . DIRECTORY_SEPARATOR . $fileName;
$context->count++;
$context->size += $fileInfo['size'];
}
static public function findRecursive( $sourceDir, array $includeFilters = array(), array $excludeFilters = array() )
{
// create the context, and then start walking over the array
$context = new ezcBaseFileFindContext;
ezcBaseFile::walkRecursive( $sourceDir, $includeFilters, $excludeFilters,
array( 'myProgressFinder', 'findRecursiveCallback' ), $context );
// collect the statistics (which we don't do anything with in this example)
$statistics['size'] = $context->size;
$statistics['count'] = $context->count;
// return the found and pattern-matched files
sort( $context->elements );
return $context->elements;
}
}
$files = myProgressFinder::findRecursive( dirname( __FILE__ ) );
var_dump( $files );
?>

View File

@@ -0,0 +1,38 @@
<?php
require_once 'tutorial_autoload.php';
// Create a custom class implementing the singleton pattern
class customSingleton
{
protected static $instance;
public static function getInstance()
{
if ( self::$instance === null )
{
self::$instance = new customSingleton();
ezcBaseInit::fetchConfig( 'customKey', self::$instance );
}
return self::$instance;
}
}
// Implement your configuration class
class customSingletonConfiguration implements ezcBaseConfigurationInitializer
{
public static function configureObject( $object )
{
echo "Configure customSingleton.\n";
$object->value = 42;
}
}
// Register for lazy initilization
ezcBaseInit::setCallback( 'customKey', 'customSingletonConfiguration' );
// Configure on first initilization
$object = customSingleton::getInstance();
var_dump( $object->value );
?>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="Zeta Components Base">
<directory suffix="_test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>

View File

@@ -0,0 +1,23 @@
Review Alexandru 2008-05-08
===========================
[X] Regarding feature request #8529 (a du -s implementation). The documentation
for ezcBaseFile::findRecursive() says that you can supply an empty array
as the 4th argument to get the statistics.
If I pass for example $stats which I initialized with array() before, then
I get notices: "Undefined index: count in /home/as/dev/ezcomponents/trunk/Base/src/file.php
on line 139", and the same notice for index "size".
Also the documentation does not mention that you need to pass a variable and not
a value - if I pass array() as the 4th argument I get the error "Cannot pass
parameter 4 by reference"
If I pass $stats which I initialize with null, false or empty string before,
then the function works.
Also all the file recursive tests fail on Windows (slash issues mostly).
[X] Regarding feature request #11506 (method ezcBase::getInstallationPath()). On
Linux it returns the path without any slash at the end, but on Windows (Vista)
it adds a Windows slash at the end.

View File

@@ -0,0 +1,675 @@
<?php
/**
* File containing the ezcBase class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Base class implements the methods needed to use the eZ components.
*
* @package Base
* @version //autogentag//
* @mainclass
*/
class ezcBase
{
/**
* Used for dependency checking, to check for a PHP extension.
*/
const DEP_PHP_EXTENSION = "extension";
/**
* Used for dependency checking, to check for a PHP version.
*/
const DEP_PHP_VERSION = "version";
/**
* Denotes the production mode
*/
const MODE_PRODUCTION = 0;
/**
* Denotes the development mode
*/
const MODE_DEVELOPMENT = 1;
/**
* Indirectly it determines the path where the autoloads are stored.
*
* @var string
*/
private static $libraryMode = "devel";
/**
* Contains the current working directory, which is used when the
* $libraryMode is set to "custom".
*
* @var string
*/
private static $currentWorkingDirectory = null;
/**
* The full path to the autoload directory.
*
* @var string
*/
protected static $packageDir = null;
/**
* Contains which development mode is used. It's "development" by default,
* because of backwards compatibility reasons.
*/
private static $runMode = self::MODE_DEVELOPMENT;
/**
* Stores info with additional paths where autoload files and classes for
* autoloading could be found. Each item of $repositoryDirs looks like
* array( autoloadFileDir, baseDir ). The array key is the prefix belonging
* to classes within that repository - if provided when calling
* addClassRepository(), or an autoincrement integer otherwise.
*
* @var array(string=>array)
*/
protected static $repositoryDirs = array();
/**
* This variable stores all the elements from the autoload arrays. When a
* new autoload file is loaded, their files are added to this array.
*
* @var array(string=>string)
*/
protected static $autoloadArray = array();
/**
* This variable stores all the elements from the autoload arrays for
* external repositories. When a new autoload file is loaded, their files
* are added to this array.
*
* @var array(string=>string)
*/
protected static $externalAutoloadArray = array();
/**
* Options for the ezcBase class.
*
* @var ezcBaseOptions
*/
static private $options;
/**
* Associates an option object with this static class.
*
* @param ezcBaseAutoloadOptions $options
*/
static public function setOptions( ezcBaseAutoloadOptions $options )
{
self::$options = $options;
}
/**
* Tries to autoload the given className. If the className could be found
* this method returns true, otherwise false.
*
* This class caches the requested class names (including the ones who
* failed to load).
*
* @param string $className The name of the class that should be loaded.
*
* @return bool
*/
public static function autoload( $className )
{
ezcBase::setPackageDir();
// Check whether the classname is already in the cached autoloadArray.
if ( array_key_exists( $className, ezcBase::$autoloadArray ) )
{
// Is it registered as 'unloadable'?
if ( ezcBase::$autoloadArray[$className] == false )
{
return false;
}
ezcBase::loadFile( ezcBase::$autoloadArray[$className] );
return true;
}
// Check whether the classname is already in the cached autoloadArray
// for external repositories.
if ( array_key_exists( $className, ezcBase::$externalAutoloadArray ) )
{
// Is it registered as 'unloadable'?
if ( ezcBase::$externalAutoloadArray[$className] == false )
{
return false;
}
ezcBase::loadExternalFile( ezcBase::$externalAutoloadArray[$className] );
return true;
}
// Not cached, so load the autoload from the package.
// Matches the first and optionally the second 'word' from the classname.
$fileNames = array();
if ( preg_match( "/^([a-z0-9]*)([A-Z][a-z0-9]*)?([A-Z][a-z0-9]*)?/", $className, $matches ) !== false )
{
$autoloadFile = "";
// Try to match with both names, if available.
switch ( sizeof( $matches ) )
{
case 4:
// check for x_y_autoload.php
$autoloadFile = strtolower( "{$matches[2]}_{$matches[3]}_autoload.php" );
$fileNames[] = $autoloadFile;
if ( ezcBase::requireFile( $autoloadFile, $className, $matches[1] ) )
{
return true;
}
// break intentionally missing.
case 3:
// check for x_autoload.php
$autoloadFile = strtolower( "{$matches[2]}_autoload.php" );
$fileNames[] = $autoloadFile;
if ( ezcBase::requireFile( $autoloadFile, $className, $matches[1] ) )
{
return true;
}
// break intentionally missing.
case 2:
// check for autoload.php
$autoloadFile = 'autoload.php';
$fileNames[] = $autoloadFile;
if ( ezcBase::requireFile( $autoloadFile, $className, $matches[1] ) )
{
return true;
}
break;
}
// Maybe there is another autoload available.
// Register this classname as false.
ezcBase::$autoloadArray[$className] = false;
}
$path = ezcBase::$packageDir . 'autoload/';
$realPath = realpath( $path );
if ( $realPath == '' )
{
// Can not be tested, because if this happens, then the autoload
// environment has not been set-up correctly.
trigger_error( "Couldn't find autoload directory '$path'", E_USER_ERROR );
}
$dirs = self::getRepositoryDirectories();
if ( ezcBase::$options && ezcBase::$options->debug )
{
throw new ezcBaseAutoloadException( $className, $fileNames, $dirs );
}
return false;
}
/**
* Sets the current working directory to $directory.
*
* @param string $directory
*/
public static function setWorkingDirectory( $directory )
{
self::$libraryMode = 'custom';
self::$currentWorkingDirectory = $directory;
}
/**
* Figures out the base path of the Zeta Components installation.
*
* It stores the path that it finds in a static member variable. The path
* depends on the installation method of the Zeta Components. The SVN version
* has a different path than the PEAR installed version.
*/
protected static function setPackageDir()
{
if ( ezcBase::$packageDir !== null )
{
return;
}
// Get the path to the components.
$baseDir = dirname( __FILE__ );
switch ( ezcBase::$libraryMode )
{
case "custom":
ezcBase::$packageDir = self::$currentWorkingDirectory . '/';
break;
case "devel":
case "tarball":
ezcBase::$packageDir = $baseDir. "/../../";
break;
case "pear";
ezcBase::$packageDir = $baseDir. "/../";
break;
}
}
/**
* Tries to load the autoload array and, if loaded correctly, includes the class.
*
* @param string $fileName Name of the autoload file.
* @param string $className Name of the class that should be autoloaded.
* @param string $prefix The prefix of the class repository.
*
* @return bool True is returned when the file is correctly loaded.
* Otherwise false is returned.
*/
protected static function requireFile( $fileName, $className, $prefix )
{
$autoloadDir = ezcBase::$packageDir . "autoload/";
// We need the full path to the fileName. The method file_exists() doesn't
// automatically check the (php.ini) library paths. Therefore:
// file_exists( "ezc/autoload/$fileName" ) doesn't work.
if ( $prefix === 'ezc' && file_exists( "$autoloadDir$fileName" ) )
{
$array = require( "$autoloadDir$fileName" );
if ( is_array( $array) && array_key_exists( $className, $array ) )
{
// Add the array to the cache, and include the requested file.
ezcBase::$autoloadArray = array_merge( ezcBase::$autoloadArray, $array );
if ( ezcBase::$options !== null && ezcBase::$options->preload && !preg_match( '/Exception$/', $className ) )
{
foreach ( $array as $loadClassName => $file )
{
if ( $loadClassName !== 'ezcBase' && !class_exists( $loadClassName, false ) && !interface_exists( $loadClassName, false ) && !preg_match( '/Exception$/', $loadClassName ) /*&& !class_exists( $loadClassName, false ) && !interface_exists( $loadClassName, false )*/ )
{
ezcBase::loadFile( ezcBase::$autoloadArray[$loadClassName] );
}
}
}
else
{
ezcBase::loadFile( ezcBase::$autoloadArray[$className] );
}
return true;
}
}
// It is not in components autoload/ dir.
// try to search in additional dirs.
foreach ( ezcBase::$repositoryDirs as $repositoryPrefix => $extraDir )
{
if ( gettype( $repositoryPrefix ) === 'string' && $repositoryPrefix !== $prefix )
{
continue;
}
if ( file_exists( $extraDir['autoloadDirPath'] . '/' . $fileName ) )
{
$array = array();
$originalArray = require( $extraDir['autoloadDirPath'] . '/' . $fileName );
// Building paths.
// Resulting path to class definition file consists of:
// path to extra directory with autoload file +
// basePath provided for current extra directory +
// path to class definition file stored in autoload file.
foreach ( $originalArray as $class => $classPath )
{
$array[$class] = $extraDir['basePath'] . '/' . $classPath;
}
if ( is_array( $array ) && array_key_exists( $className, $array ) )
{
// Add the array to the cache, and include the requested file.
ezcBase::$externalAutoloadArray = array_merge( ezcBase::$externalAutoloadArray, $array );
ezcBase::loadExternalFile( ezcBase::$externalAutoloadArray[$className] );
return true;
}
}
}
// Nothing found :-(.
return false;
}
/**
* Loads, require(), the given file name. If we are in development mode,
* "/src/" is inserted into the path.
*
* @param string $file The name of the file that should be loaded.
*/
protected static function loadFile( $file )
{
switch ( ezcBase::$libraryMode )
{
case "devel":
case "tarball":
list( $first, $second ) = explode( '/', $file, 2 );
$file = $first . "/src/" . $second;
break;
case "custom":
list( $first, $second ) = explode( '/', $file, 2 );
// Add the "src/" after the package name.
if ( $first == 'Base' || $first == 'UnitTest' )
{
list( $first, $second ) = explode( '/', $file, 2 );
$file = $first . "/src/" . $second;
}
else
{
list( $first, $second, $third ) = explode( '/', $file, 3 );
$file = $first . '/' . $second . "/src/" . $third;
}
break;
case "pear":
/* do nothing, it's already correct */
break;
}
if ( file_exists( ezcBase::$packageDir . $file ) )
{
require( ezcBase::$packageDir . $file );
}
else
{
// Can not be tested, because if this happens, then one of the
// components has a broken autoload file.
throw new ezcBaseFileNotFoundException( ezcBase::$packageDir.$file );
}
}
/**
* Loads, require(), the given file name from an external package.
*
* @param string $file The name of the file that should be loaded.
*/
protected static function loadExternalFile( $file )
{
if ( file_exists( $file ) )
{
require( $file );
}
else
{
throw new ezcBaseFileNotFoundException( $file );
}
}
/**
* Checks for dependencies on PHP versions or extensions
*
* The function as called by the $component component checks for the $type
* dependency. The dependency $type is compared against the $value. The
* function aborts the script if the dependency is not matched.
*
* @param string $component
* @param int $type
* @param mixed $value
*/
public static function checkDependency( $component, $type, $value )
{
switch ( $type )
{
case self::DEP_PHP_EXTENSION:
if ( extension_loaded( $value ) )
{
return;
}
else
{
// Can not be tested as it would abort the PHP script.
die( "\nThe {$component} component depends on the default PHP extension '{$value}', which is not loaded.\n" );
}
break;
case self::DEP_PHP_VERSION:
$phpVersion = phpversion();
if ( version_compare( $phpVersion, $value, '>=' ) )
{
return;
}
else
{
// Can not be tested as it would abort the PHP script.
die( "\nThe {$component} component depends on the PHP version '{$value}', but the current version is '{$phpVersion}'.\n" );
}
break;
}
}
/**
* Return the list of directories that contain class repositories.
*
* The path to the eZ components directory is always included in the result
* array. Each element in the returned array has the format of:
* packageDirectory => ezcBaseRepositoryDirectory
*
* @return array(string=>ezcBaseRepositoryDirectory)
*/
public static function getRepositoryDirectories()
{
$autoloadDirs = array();
ezcBase::setPackageDir();
$repositoryDir = self::$currentWorkingDirectory ? self::$currentWorkingDirectory : ( realpath( dirname( __FILE__ ) . '/../../' ) );
$autoloadDirs['ezc'] = new ezcBaseRepositoryDirectory( ezcBaseRepositoryDirectory::TYPE_INTERNAL, $repositoryDir, $repositoryDir . "/autoload" );
foreach ( ezcBase::$repositoryDirs as $extraDirKey => $extraDirArray )
{
$repositoryDirectory = new ezcBaseRepositoryDirectory( ezcBaseRepositoryDirectory::TYPE_EXTERNAL, realpath( $extraDirArray['basePath'] ), realpath( $extraDirArray['autoloadDirPath'] ) );
$autoloadDirs[$extraDirKey] = $repositoryDirectory;
}
return $autoloadDirs;
}
/**
* Adds an additional class repository.
*
* Used for adding class repositoryies outside the eZ components to be
* loaded by the autoload system.
*
* This function takes two arguments: $basePath is the base path for the
* whole class repository and $autoloadDirPath the path where autoload
* files for this repository are found. The paths in the autoload files are
* relative to the package directory as specified by the $basePath
* argument. I.e. class definition file will be searched at location
* $basePath + path to the class definition file as stored in the autoload
* file.
*
* addClassRepository() should be called somewhere in code before external classes
* are used.
*
* Example:
* Take the following facts:
* <ul>
* <li>there is a class repository stored in the directory "./repos"</li>
* <li>autoload files for that repository are stored in "./repos/autoloads"</li>
* <li>there are two components in this repository: "Me" and "You"</li>
* <li>the "Me" component has the classes "erMyClass1" and "erMyClass2"</li>
* <li>the "You" component has the classes "erYourClass1" and "erYourClass2"</li>
* </ul>
*
* In this case you would need to create the following files in
* "./repos/autoloads". Please note that the part before _autoload.php in
* the filename is the first part of the <b>classname</b>, not considering
* the all lower-case letter prefix.
*
* "my_autoload.php":
* <code>
* <?php
* return array (
* 'erMyClass1' => 'Me/myclass1.php',
* 'erMyClass2' => 'Me/myclass2.php',
* );
* ?>
* </code>
*
* "your_autoload.php":
* <code>
* <?php
* return array (
* 'erYourClass1' => 'You/yourclass1.php',
* 'erYourClass2' => 'You/yourclass2.php',
* );
* ?>
* </code>
*
* The directory structure for the external repository is then:
* <code>
* ./repos/autoloads/my_autoload.php
* ./repos/autoloads/you_autoload.php
* ./repos/Me/myclass1.php
* ./repos/Me/myclass2.php
* ./repos/You/yourclass1.php
* ./repos/You/yourclass2.php
* </code>
*
* To use this repository with the autoload mechanism you have to use the
* following code:
* <code>
* <?php
* ezcBase::addClassRepository( './repos', './repos/autoloads' );
* $myVar = new erMyClass2();
* ?>
* </code>
*
* @throws ezcBaseFileNotFoundException if $autoloadDirPath or $basePath do not exist.
* @param string $basePath
* @param string $autoloadDirPath
* @param string $prefix
*/
public static function addClassRepository( $basePath, $autoloadDirPath = null, $prefix = null )
{
// check if base path exists
if ( !is_dir( $basePath ) )
{
throw new ezcBaseFileNotFoundException( $basePath, 'base directory' );
}
// calculate autoload path if it wasn't given
if ( is_null( $autoloadDirPath ) )
{
$autoloadDirPath = $basePath . '/autoload';
}
// check if autoload dir exists
if ( !is_dir( $autoloadDirPath ) )
{
throw new ezcBaseFileNotFoundException( $autoloadDirPath, 'autoload directory' );
}
// add info to $repositoryDirs
if ( $prefix === null )
{
$array = array( 'basePath' => $basePath, 'autoloadDirPath' => $autoloadDirPath );
// add info to the list of extra dirs
ezcBase::$repositoryDirs[] = $array;
}
else
{
if ( array_key_exists( $prefix, ezcBase::$repositoryDirs ) )
{
throw new ezcBaseDoubleClassRepositoryPrefixException( $prefix, $basePath, $autoloadDirPath );
}
// add info to the list of extra dirs, and use the prefix to identify the new repository.
ezcBase::$repositoryDirs[$prefix] = array( 'basePath' => $basePath, 'autoloadDirPath' => $autoloadDirPath );
}
}
/**
* Returns the base path of the Zeta Components installation
*
* This method returns the base path, including a trailing directory
* separator.
*
* @return string
*/
public static function getInstallationPath()
{
self::setPackageDir();
$path = realpath( self::$packageDir );
if ( substr( $path, -1 ) !== DIRECTORY_SEPARATOR )
{
$path .= DIRECTORY_SEPARATOR;
}
return $path;
}
/**
* Sets the development mode to the one specified.
*
* @param int $runMode
*/
public static function setRunMode( $runMode )
{
if ( !in_array( $runMode, array( ezcBase::MODE_PRODUCTION, ezcBase::MODE_DEVELOPMENT ) ) )
{
throw new ezcBaseValueException( 'runMode', $runMode, 'ezcBase::MODE_PRODUCTION or ezcBase::MODE_DEVELOPMENT' );
}
self::$runMode = $runMode;
}
/**
* Returns the current development mode.
*
* @return int
*/
public static function getRunMode()
{
return self::$runMode;
}
/**
* Returns true when we are in development mode.
*
* @return bool
*/
public static function inDevMode()
{
return self::$runMode == ezcBase::MODE_DEVELOPMENT;
}
/**
* Returns the installation method
*
* Possible return values are 'custom', 'devel', 'tarball' and 'pear'. Only
* 'tarball' and 'pear' are returned for user-installed versions.
*
* @return string
*/
public static function getInstallMethod()
{
return self::$libraryMode;
}
}
?>

View File

@@ -0,0 +1,63 @@
<?php
/**
* Autoloader definition for the Base component.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @version //autogentag//
* @filesource
* @package Base
*/
return array(
'ezcBaseException' => 'Base/exceptions/exception.php',
'ezcBaseFileException' => 'Base/exceptions/file_exception.php',
'ezcBaseAutoloadException' => 'Base/exceptions/autoload.php',
'ezcBaseDoubleClassRepositoryPrefixException' => 'Base/exceptions/double_class_repository_prefix.php',
'ezcBaseExtensionNotFoundException' => 'Base/exceptions/extension_not_found.php',
'ezcBaseFileIoException' => 'Base/exceptions/file_io.php',
'ezcBaseFileNotFoundException' => 'Base/exceptions/file_not_found.php',
'ezcBaseFilePermissionException' => 'Base/exceptions/file_permission.php',
'ezcBaseFunctionalityNotSupportedException' => 'Base/exceptions/functionality_not_supported.php',
'ezcBaseInitCallbackConfiguredException' => 'Base/exceptions/init_callback_configured.php',
'ezcBaseInitInvalidCallbackClassException' => 'Base/exceptions/invalid_callback_class.php',
'ezcBaseInvalidParentClassException' => 'Base/exceptions/invalid_parent_class.php',
'ezcBasePropertyNotFoundException' => 'Base/exceptions/property_not_found.php',
'ezcBasePropertyPermissionException' => 'Base/exceptions/property_permission.php',
'ezcBaseSettingNotFoundException' => 'Base/exceptions/setting_not_found.php',
'ezcBaseSettingValueException' => 'Base/exceptions/setting_value.php',
'ezcBaseValueException' => 'Base/exceptions/value.php',
'ezcBaseWhateverException' => 'Base/exceptions/whatever.php',
'ezcBaseOptions' => 'Base/options.php',
'ezcBaseStruct' => 'Base/struct.php',
'ezcBase' => 'Base/base.php',
'ezcBaseAutoloadOptions' => 'Base/options/autoload.php',
'ezcBaseConfigurationInitializer' => 'Base/interfaces/configuration_initializer.php',
'ezcBaseExportable' => 'Base/interfaces/exportable.php',
'ezcBaseFeatures' => 'Base/features.php',
'ezcBaseFile' => 'Base/file.php',
'ezcBaseFileFindContext' => 'Base/structs/file_find_context.php',
'ezcBaseInit' => 'Base/init.php',
'ezcBaseMetaData' => 'Base/metadata.php',
'ezcBaseMetaDataPearReader' => 'Base/metadata/pear.php',
'ezcBaseMetaDataTarballReader' => 'Base/metadata/tarball.php',
'ezcBasePersistable' => 'Base/interfaces/persistable.php',
'ezcBaseRepositoryDirectory' => 'Base/structs/repository_directory.php',
);
?>

View File

@@ -0,0 +1,54 @@
<?php
/**
* File containing the ezcBaseAutoloadException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBaseAutoloadException is thrown whenever a class can not be found with
* the autoload mechanism.
*
* @package Base
* @version //autogen//
*/
class ezcBaseAutoloadException extends ezcBaseException
{
/**
* Constructs a new ezcBaseAutoloadException for the $className that was
* searched for in the autoload files $fileNames from the directories
* specified in $dirs.
*
* @param string $className
* @param array(string) $files
* @param array(ezcBaseRepositoryDirectory) $dirs
*/
function __construct( $className, $files, $dirs )
{
$paths = array();
foreach ( $dirs as $dir )
{
$paths[] = realpath( $dir->autoloadPath );
}
parent::__construct( "Could not find a class to file mapping for '{$className}'. Searched for ". implode( ', ', $files ) . " in: " . implode( ', ', $paths ) );
}
}
?>

View File

@@ -0,0 +1,50 @@
<?php
/**
* File containing the ezcBaseDoubleClassRepositoryPrefixException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBaseDoubleClassRepositoryPrefixException is thrown whenever you try to
* register a class repository with a prefix that has already been added
* before.
*
* @package Base
* @version //autogen//
*/
class ezcBaseDoubleClassRepositoryPrefixException extends ezcBaseException
{
/**
* Constructs a new ezcBaseDoubleClassRepositoryPrefixException for the
* $prefix that points to $basePath with autoload directory
* $autoloadDirPath.
*
* @param string $prefix
* @param string $basePath
* @param string $autoloadDirPath
*/
function __construct( $prefix, $basePath, $autoloadDirPath )
{
parent::__construct( "The class repository in '{$basePath}' (with autoload dir '{$autoloadDirPath}') can not be added because another class repository already uses the prefix '{$prefix}'." );
}
}
?>

View File

@@ -0,0 +1,59 @@
<?php
/**
* File containing the ezcBaseException class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBaseException is a container from which all other exceptions in the
* components library descent.
*
* @package Base
* @version //autogen//
*/
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 ) );
}
}
}
?>

View File

@@ -0,0 +1,54 @@
<?php
/**
* File containing the ezcBaseExtensionNotFoundException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBaseExtensionNotFoundException is thrown when a requested PHP extension was not found.
*
* @package Base
* @version //autogen//
*/
class ezcBaseExtensionNotFoundException extends ezcBaseException
{
/**
* Constructs a new ezcBaseExtensionNotFoundException.
*
* @param string $name The name of the extension
* @param string $version The version of the extension
* @param string $message Additional text
*/
function __construct( $name, $version = null, $message = null )
{
if ( $version === null )
{
parent::__construct( "The extension '{$name}' could not be found. {$message}" );
}
else
{
parent::__construct( "The extension '{$name}' with version '{$version}' could not be found. {$message}" );
}
}
}
?>

View File

@@ -0,0 +1,41 @@
<?php
/**
* File containing the ezcBaseFileException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBaseFileException is the exception from which all file related exceptions
* inherit.
*
* @package Base
* @version //autogen//
*/
abstract class ezcBaseFileException extends ezcBaseException
{
const READ = 1;
const WRITE = 2;
const EXECUTE = 4;
const CHANGE = 8;
const REMOVE = 16;
}
?>

View File

@@ -0,0 +1,66 @@
<?php
/**
* File containing the ezcBaseFileIoException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBaseFileIoException is thrown when a problem occurs while writing
* and reading to/from an open file.
*
* @package Base
* @version //autogen//
*/
class ezcBaseFileIoException extends ezcBaseFileException
{
/**
* Constructs a new ezcBaseFileIoException for the file $path.
*
* @param string $path 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" );
}
}
?>

View File

@@ -0,0 +1,59 @@
<?php
/**
* File containing the ezcBaseFileNotFoundException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBaseFileNotFoundException is thrown when a file or directory was tried to
* be opened, but did not exist.
*
* @package Base
* @version //autogen//
*/
class ezcBaseFileNotFoundException extends ezcBaseFileException
{
/**
* Constructs a new ezcBaseFileNotFoundException.
*
* @param string $path 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" );
}
}
?>

View File

@@ -0,0 +1,79 @@
<?php
/**
* File containing the ezcBaseFilePermissionException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBaseFilePermissionException is thrown whenever a permission problem with
* a file, directory or stream occurred.
*
* @package Base
* @version //autogen//
*/
class ezcBaseFilePermissionException extends ezcBaseFileException
{
/**
* Constructs a new ezcPropertyPermissionException for the property $name.
*
* @param string $path 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" );
}
}
?>

View File

@@ -0,0 +1,47 @@
<?php
/**
* File containing the ezcBaseFunctionalityNotSupportedException class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* The ezcBaseFunctionalityNotSupportedException is thrown when a requested
* PHP function was not found.
*
* @package Base
* @version //autogen//
*/
class ezcBaseFunctionalityNotSupportedException extends ezcBaseException
{
/**
* Constructs a new ezcBaseFunctionalityNotSupportedException.
*
* @param string $message The message to throw
* @param string $reason The reason for the exception
*/
function __construct( $message, $reason )
{
parent::__construct( "{$message} is not supported. Reason: {$reason}." );
}
}
?>

View File

@@ -0,0 +1,47 @@
<?php
/**
* File containing the ezcBaseInitCallbackConfiguredException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBaseInitCallbackConfiguredException is thrown when you try to assign a
* callback clasname to an identifier, while there is already a callback class
* configured for this identifier.
*
* @package Base
* @version //autogen//
*/
class ezcBaseInitCallbackConfiguredException extends ezcBaseException
{
/**
* Constructs a new ezcBaseInitCallbackConfiguredException.
*
* @param string $identifier
* @param string $originalCallbackClassName
*/
function __construct( $identifier, $originalCallbackClassName )
{
parent::__construct( "The '{$identifier}' is already configured with callback class '{$originalCallbackClassName}'." );
}
}
?>

View File

@@ -0,0 +1,47 @@
<?php
/**
* File containing the ezcBaseInitInvalidCallbackClassException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Exception that is thrown if an invalid class is passed as callback class for
* delayed object configuration.
*
* @package Base
* @version //autogen//
*/
class ezcBaseInitInvalidCallbackClassException extends ezcBaseException
{
/**
* Constructs a new ezcBaseInitInvalidCallbackClassException for the $callbackClass.
*
* @param string $callbackClass
* @return void
*/
function __construct( $callbackClass )
{
parent::__construct( "Class '{$callbackClass}' does not exist, or does not implement the 'ezcBaseConfigurationInitializer' interface." );
}
}
?>

View File

@@ -0,0 +1,45 @@
<?php
/**
* File containing the ezcBaseInvalidParentClassException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Exception that is thrown if an invalid class is passed as custom class.
*
* @package Base
* @version //autogen//
*/
class ezcBaseInvalidParentClassException extends ezcBaseException
{
/**
* Constructs an ezcBaseInvalidParentClassException for custom class $customClass
*
* @param string $expectedParentClass
* @param string $customClass
*/
function __construct( $expectedParentClass, $customClass )
{
parent::__construct( "Class '{$customClass}' does not exist, or does not inherit from the '{$expectedParentClass}' class." );
}
}
?>

View File

@@ -0,0 +1,46 @@
<?php
/**
* File containing the ezcBasePropertyNotFoundException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBasePropertyNotFoundException is thrown whenever a non existent property
* is accessed in the Components library.
*
* @package Base
* @version //autogen//
*/
class ezcBasePropertyNotFoundException extends ezcBaseException
{
/**
* Constructs a new ezcBasePropertyNotFoundException for the property
* $name.
*
* @param string $name The name of the property
*/
function __construct( $name )
{
parent::__construct( "No such property name '{$name}'." );
}
}
?>

View File

@@ -0,0 +1,58 @@
<?php
/**
* File containing the ezcPropertyReadOnlyException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* 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 //autogen//
*/
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." );
}
}
?>

View File

@@ -0,0 +1,45 @@
<?php
/**
* File containing the ezcBaseSettingNotFoundException class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* 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
* @version //autogen//
*/
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." );
}
}
?>

View File

@@ -0,0 +1,58 @@
<?php
/**
* File containing the ezcBaseSettingValueException class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBaseSettingValueExeception is thrown whenever a value to a class'
* configuration option is either of the wrong type, or has a wrong value.
*
* @package Base
* @version //autogen//
*/
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 );
}
}
?>

View File

@@ -0,0 +1,59 @@
<?php
/**
* File containing the ezcBaseValueException class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBaseValueException is thrown whenever the type or value of the given
* variable is not as expected.
*
* @package Base
* @version //autogen//
*/
class ezcBaseValueException extends ezcBaseException
{
/**
* Constructs a new ezcBaseValueException on the $name variable.
*
* @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.
* @param string $variableType What type of variable was tried to be set (setting, argument).
*/
function __construct( $settingName, $value, $expectedValue = null, $variableType = 'setting' )
{
$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 $variableType '{$settingName}' is invalid.";
if ( $expectedValue )
{
$msg .= " Allowed values are: " . $expectedValue . '.';
}
parent::__construct( $msg );
}
}
?>

View File

@@ -0,0 +1,56 @@
<?php
/**
* File containing the ezcBaseWhateverException class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* ezcBaseWhateverException is thrown whenever something is so seriously wrong.
*
* If this happens it is not possible to repair anything gracefully. An
* example for this could be, that your eZ components installation has thrown
* far to many exceptions. Whenever you receive an ezcBaseWhateverException, do
* not even try to catch it, but forget your project completely and immediately
* stop coding! ;)
*
* @access private
* @package Base
* @version //autogen//
*/
class ezcBaseWhateverException extends ezcBaseException
{
/**
* Constructs a new ezcBaseWhateverException.
*
* @param string $what What happened?
* @param string $where Where did it happen?
* @param string $who Who is responsible?
* @param string $why Why did is happen?
* @access protected
* @return void
*/
function __construct( $what, $where, $who, $why )
{
parent::__construct( "Thanks for using eZ components. Hope you like it! Greetings from Amos, Derick, El Frederico, Ray and Toby." );
}
}
?>

View File

@@ -0,0 +1,47 @@
<?php
/**
* Include file that can be used for a quick setup of the eZ Components.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @version //autogentag//
* @filesource
* @package Base
* @access private
*/
$dir = dirname( __FILE__ );
$dirParts = explode( DIRECTORY_SEPARATOR, $dir );
if ( $dirParts[count( $dirParts ) - 1] === 'src' )
{
$baseDir = join( DIRECTORY_SEPARATOR, array_slice( $dirParts, 0, -2 ) );
require $baseDir . '/Base/src/base.php'; // svn, bundle
}
else if ( $dirParts[count( $dirParts ) - 2] === 'ezc' )
{
$baseDir = join( DIRECTORY_SEPARATOR, array_slice( $dirParts, 0, -2 ) );
require $baseDir . '/ezc/Base/base.php'; // pear
}
else
{
die( "Your environment isn't properly set-up. Please refer to the eZ components documentation at http://components.ez.no/doc ." );
}
spl_autoload_register( [ 'ezcBase', 'autoload' ] );
?>

View File

@@ -0,0 +1,381 @@
<?php
/**
* File containing the ezcBaseFeatures class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Provides methods needed to check for features.
*
* Example:
* <code>
* <?php
* echo "supports uid: " . ezcBaseFeatures::supportsUserId() . "\n";
* echo "supports symlink: " . ezcBaseFeatures::supportsSymLink() . "\n";
* echo "supports hardlink: " . ezcBaseFeatures::supportsLink() . "\n";
* echo "has imagemagick identify: " . ezcBaseFeatures::hasImageIdentify() . "\n";
* echo " identify path: " . ezcBaseFeatures::getImageIdentifyExecutable() . "\n";
* echo "has imagemagick convert: " . ezcBaseFeatures::hasImageConvert() . "\n";
* echo " convert path: " . ezcBaseFeatures::getImageConvertExecutable() . "\n";
* echo "has gzip extension: " . ezcBaseFeatures::hasExtensionSupport( 'zlib' ) . "\n";
* echo "has pdo_mysql 1.0.2: " . ezcBaseFeatures::hasExtensionSupport( 'pdo_mysql', '1.0.2' ) . "\n"
* ?>
* </code>
*
* @package Base
* @version //autogentag//
*/
class ezcBaseFeatures
{
/**
* Used to store the path of the ImageMagick convert utility.
*
* It is initialized in the {@link getImageConvertExecutable()} function.
*
* @var string
*/
private static $imageConvert = null;
/**
* Used to store the path of the ImageMagick identify utility.
*
* It is initialized in the {@link getImageIdentifyExecutable()} function.
*
* @var string
*/
private static $imageIdentify = null;
/**
* Used to store the operating system.
*
* It is initialized in the {@link os()} function.
*
* @var string
*/
private static $os = null;
/**
* Determines if hardlinks are supported.
*
* @return bool
*/
public static function supportsLink()
{
return function_exists( 'link' );
}
/**
* Determines if symlinks are supported.
*
* @return bool
*/
public static function supportsSymLink()
{
return function_exists( 'symlink' );
}
/**
* Determines if posix uids are supported.
*
* @return bool
*/
public static function supportsUserId()
{
return function_exists( 'posix_getpwuid' );
}
/**
* Determines if the ImageMagick convert utility is installed.
*
* @return bool
*/
public static function hasImageConvert()
{
return !is_null( self::getImageConvertExecutable() );
}
/**
* Returns the path to the ImageMagick convert utility.
*
* On Linux, Unix,... it will return something like: /usr/bin/convert
* On Windows it will return something like: C:\Windows\System32\convert.exe
*
* @return string
*/
public static function getImageConvertExecutable()
{
if ( !is_null( self::$imageConvert ) )
{
return self::$imageConvert;
}
return ( self::$imageConvert = self::findExecutableInPath( 'convert' ) );
}
/**
* Determines if the ImageMagick identify utility is installed.
*
* @return bool
*/
public static function hasImageIdentify()
{
return !is_null( self::getImageIdentifyExecutable() );
}
/**
* Returns the path to the ImageMagick identify utility.
*
* On Linux, Unix,... it will return something like: /usr/bin/identify
* On Windows it will return something like: C:\Windows\System32\identify.exe
*
* @return string
*/
public static function getImageIdentifyExecutable()
{
if ( !is_null( self::$imageIdentify ) )
{
return self::$imageIdentify;
}
return ( self::$imageIdentify = self::findExecutableInPath( 'identify' ) );
}
/**
* Determines if the specified extension is loaded.
*
* If $version is specified, the specified extension will be tested also
* against the version of the loaded extension.
*
* Examples:
* <code>
* hasExtensionSupport( 'gzip' );
* </code>
* will return true if gzip extension is loaded.
*
* <code>
* hasExtensionSupport( 'pdo_mysql', '1.0.2' );
* </code>
* will return true if pdo_mysql extension is loaded and its version is at least 1.0.2.
*
* @param string $extension
* @param string $version
* @return bool
*/
public static function hasExtensionSupport( $extension, $version = null )
{
if ( is_null( $version ) )
{
return extension_loaded( $extension );
}
return extension_loaded( $extension ) && version_compare( phpversion( $extension ), $version, ">=" ) ;
}
/**
* Determines if the specified function is available.
*
* Examples:
* <code>
* ezcBaseFeatures::hasFunction( 'imagepstext' );
* </code>
* will return true if support for Type 1 fonts is available with your GD
* extension.
*
* @param string $functionName
* @return bool
*/
public static function hasFunction( $functionName )
{
return function_exists( $functionName );
}
/**
* Returns if a given class exists.
* Checks for a given class name and returns if this class exists or not.
* Catches the ezcBaseAutoloadException and returns false, if it was thrown.
*
* @param string $className The class to check for.
* @param bool $autoload True to use __autoload(), otherwise false.
* @return bool True if the class exists. Otherwise false.
*/
public static function classExists( $className, $autoload = true )
{
try
{
if ( class_exists( $className, $autoload ) )
{
return true;
}
return false;
}
catch ( ezcBaseAutoloadException $e )
{
return false;
}
}
/**
* Returns the operating system on which PHP is running.
*
* This method returns a sanitized form of the OS name, example
* return values are "Windows", "Mac", "Linux" and "FreeBSD". In
* all other cases it returns the value of the internal PHP constant
* PHP_OS.
*
* @return string
*/
public static function os()
{
if ( is_null( self::$os ) )
{
$uname = php_uname( 's' );
if ( substr( $uname, 0, 7 ) == 'Windows' )
{
self::$os = 'Windows';
}
elseif ( substr( $uname, 0, 3 ) == 'Mac' )
{
self::$os = 'Mac';
}
elseif ( strtolower( $uname ) == 'linux' )
{
self::$os = 'Linux';
}
elseif ( strtolower( substr( $uname, 0, 7 ) ) == 'freebsd' )
{
self::$os = 'FreeBSD';
}
else
{
self::$os = PHP_OS;
}
}
return self::$os;
}
/**
* Returns the path of the specified executable, if it can be found in the system's path.
*
* It scans the PATH enviroment variable based on the OS to find the
* $fileName. For Windows, the path is with \, not /. If $fileName is not
* found, it returns null.
*
* @todo consider using getenv( 'PATH' ) instead of $_ENV['PATH']
* (but that won't work under IIS)
*
* @param string $fileName
* @return string
*/
public static function findExecutableInPath( $fileName )
{
if ( array_key_exists( 'PATH', $_ENV ) )
{
$envPath = trim( $_ENV['PATH'] );
}
else if ( ( $envPath = getenv( 'PATH' ) ) !== false )
{
$envPath = trim( $envPath );
}
if ( is_string( $envPath ) && strlen( trim( $envPath ) ) == 0 )
{
$envPath = false;
}
switch ( self::os() )
{
case 'Unix':
case 'FreeBSD':
case 'Mac':
case 'MacOS':
case 'Darwin':
case 'Linux':
case 'SunOS':
if ( $envPath )
{
$dirs = explode( ':', $envPath );
foreach ( $dirs as $dir )
{
// The @-operator is used here mainly to avoid
// open_basedir warnings. If open_basedir (or any other
// circumstance) prevents the desired file from being
// accessed, it is fine for file_exists() to return
// false, since it is useless for use then, anyway.
if ( file_exists( "{$dir}/{$fileName}" ) )
{
return "{$dir}/{$fileName}";
}
}
}
// The @-operator is used here mainly to avoid open_basedir
// warnings. If open_basedir (or any other circumstance)
// prevents the desired file from being accessed, it is fine
// for file_exists() to return false, since it is useless for
// use then, anyway.
elseif ( @file_exists( "./{$fileName}" ) )
{
return $fileName;
}
break;
case 'Windows':
if ( $envPath )
{
$dirs = explode( ';', $envPath );
foreach ( $dirs as $dir )
{
// The @-operator is used here mainly to avoid
// open_basedir warnings. If open_basedir (or any other
// circumstance) prevents the desired file from being
// accessed, it is fine for file_exists() to return
// false, since it is useless for use then, anyway.
if ( @file_exists( "{$dir}\\{$fileName}.exe" ) )
{
return "{$dir}\\{$fileName}.exe";
}
}
}
// The @-operator is used here mainly to avoid open_basedir
// warnings. If open_basedir (or any other circumstance)
// prevents the desired file from being accessed, it is fine
// for file_exists() to return false, since it is useless for
// use then, anyway.
elseif ( @file_exists( "{$fileName}.exe" ) )
{
return "{$fileName}.exe";
}
break;
}
return null;
}
/**
* Reset the cached information.
*
* @return void
* @access private
* @ignore
*/
public static function reset()
{
self::$imageIdentify = null;
self::$imageConvert = null;
self::$os = null;
}
}
?>

View File

@@ -0,0 +1,512 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @version //autogentag//
* @filesource
* @package Base
*/
/**
* Provides a selection of static independent methods to provide functionality
* for file and file system handling.
*
* This example shows how to use the findRecursive method:
* <code>
* <?php
* // lists all the files under /etc (including subdirectories) that end in
* // .conf
* $confFiles = ezcBaseFile::findRecursive( "/etc", array( '@\.conf$@' ) );
*
* // lists all autoload files in the components source tree and excludes the
* // ones in the autoload subdirectory. Statistics are returned in the $stats
* // variable which is passed by reference.
* $files = ezcBaseFile::findRecursive(
* "/dat/dev/ezcomponents",
* array( '@src/.*_autoload.php$@' ),
* array( '@/autoload/@' ),
* $stats
* );
*
* // lists all binaries in /bin except the ones starting with a "g"
* $data = ezcBaseFile::findRecursive( "/bin", array(), array( '@^/bin/g@' ) );
* ?>
* </code>
*
* @package Base
* @version //autogentag//
* @mainclass
*/
class ezcBaseFile
{
/**
* This is the callback used by findRecursive to collect data.
*
* This callback method works together with walkRecursive() and is called
* for every file/and or directory. The $context is a callback specific
* container in which data can be stored and shared between the different
* calls to the callback function. The walkRecursive() function also passes
* in the full absolute directory in $sourceDir, the filename in $fileName
* and file information (such as size, modes, types) as an array as
* returned by PHP's stat() in the $fileInfo parameter.
*
* @param ezcBaseFileFindContext $context
* @param string $sourceDir
* @param string $fileName
* @param array(stat) $fileInfo
*/
static protected function findRecursiveCallback( ezcBaseFileFindContext $context, $sourceDir, $fileName, $fileInfo )
{
// ignore if we have a directory
if ( $fileInfo['mode'] & 0x4000 )
{
return;
}
// update the statistics
$context->elements[] = $sourceDir . DIRECTORY_SEPARATOR . $fileName;
$context->count++;
$context->size += $fileInfo['size'];
}
/**
* Walks files and directories recursively on a file system
*
* This method walks over a directory and calls a callback from every file
* and directory it finds. You can use $includeFilters to include only
* specific files, and $excludeFilters to exclude certain files from being
* returned. The function will always go into subdirectories even if the
* entry would not have passed the filters.
*
* The callback is passed in the $callback parameter, and the
* $callbackContext will be send to the callback function/method as
* parameter so that you can store data in there that persists with all the
* calls and recursive calls to this method. It's up to the callback method
* to do something useful with this. The callback function's parameters are
* in order:
*
* <ul>
* <li>ezcBaseFileFindContext $context</li>
* <li>string $sourceDir</li>
* <li>string $fileName</li>
* <li>array(stat) $fileInfo</li>
* </ul>
*
* See {@see findRecursiveCallback()} for an example of a callback function.
*
* Filters are regular expressions and are therefore required to have
* starting and ending delimiters. The Perl Compatible syntax is used as
* regular expression language.
*
* @param string $sourceDir
* @param array(string) $includeFilters
* @param array(string) $excludeFilters
* @param callback $callback
* @param mixed $callbackContext
*
* @throws ezcBaseFileNotFoundException if the $sourceDir directory is not
* a directory or does not exist.
* @throws ezcBaseFilePermissionException if the $sourceDir directory could
* not be opened for reading.
* @return array
*/
static public function walkRecursive( $sourceDir, array $includeFilters = array(), array $excludeFilters = array(), $callback, &$callbackContext )
{
if ( !is_dir( $sourceDir ) )
{
throw new ezcBaseFileNotFoundException( $sourceDir, 'directory' );
}
$elements = array();
$d = @dir( $sourceDir );
if ( !$d )
{
throw new ezcBaseFilePermissionException( $sourceDir, ezcBaseFileException::READ );
}
while ( ( $entry = $d->read() ) !== false )
{
if ( $entry == '.' || $entry == '..' )
{
continue;
}
$fileInfo = @stat( $sourceDir . DIRECTORY_SEPARATOR . $entry );
if ( !$fileInfo )
{
$fileInfo = array( 'size' => 0, 'mode' => 0 );
}
if ( $fileInfo['mode'] & 0x4000 )
{
// We need to ignore the Permission exceptions here as it can
// be normal that a directory can not be accessed. We only need
// the exception if the top directory could not be read.
try
{
call_user_func_array( $callback, array( $callbackContext, $sourceDir, $entry, $fileInfo ) );
$subList = self::walkRecursive( $sourceDir . DIRECTORY_SEPARATOR . $entry, $includeFilters, $excludeFilters, $callback, $callbackContext );
$elements = array_merge( $elements, $subList );
}
catch ( ezcBaseFilePermissionException $e )
{
}
}
else
{
// By default a file is included in the return list
$ok = true;
// Iterate over the $includeFilters and prohibit the file from
// being returned when atleast one of them does not match
foreach ( $includeFilters as $filter )
{
if ( !preg_match( $filter, $sourceDir . DIRECTORY_SEPARATOR . $entry ) )
{
$ok = false;
break;
}
}
// Iterate over the $excludeFilters and prohibit the file from
// being returns when atleast one of them matches
foreach ( $excludeFilters as $filter )
{
if ( preg_match( $filter, $sourceDir . DIRECTORY_SEPARATOR . $entry ) )
{
$ok = false;
break;
}
}
// If everything's allright, call the callback and add the
// entry to the elements array
if ( $ok )
{
call_user_func( $callback, $callbackContext, $sourceDir, $entry, $fileInfo );
$elements[] = $sourceDir . DIRECTORY_SEPARATOR . $entry;
}
}
}
sort( $elements );
return $elements;
}
/**
* Finds files recursively on a file system
*
* With this method you can scan the file system for files. You can use
* $includeFilters to include only specific files, and $excludeFilters to
* exclude certain files from being returned. The function will always go
* into subdirectories even if the entry would not have passed the filters.
* It uses the {@see walkRecursive()} method to do the actually recursion.
*
* Filters are regular expressions and are therefore required to have
* starting and ending delimiters. The Perl Compatible syntax is used as
* regular expression language.
*
* If you pass an empty array to the $statistics argument, the function
* will in details about the number of files found into the 'count' array
* element, and the total filesize in the 'size' array element. Because this
* argument is passed by reference, you *have* to pass a variable and you
* can not pass a constant value such as "array()".
*
* @param string $sourceDir
* @param array(string) $includeFilters
* @param array(string) $excludeFilters
* @param array() $statistics
*
* @throws ezcBaseFileNotFoundException if the $sourceDir directory is not
* a directory or does not exist.
* @throws ezcBaseFilePermissionException if the $sourceDir directory could
* not be opened for reading.
* @return array
*/
static public function findRecursive( $sourceDir, array $includeFilters = array(), array $excludeFilters = array(), &$statistics = null )
{
// init statistics array
if ( !is_array( $statistics ) || !array_key_exists( 'size', $statistics ) || !array_key_exists( 'count', $statistics ) )
{
$statistics['size'] = 0;
$statistics['count'] = 0;
}
// create the context, and then start walking over the array
$context = new ezcBaseFileFindContext;
self::walkRecursive( $sourceDir, $includeFilters, $excludeFilters, array( 'ezcBaseFile', 'findRecursiveCallback' ), $context );
// collect the statistics
$statistics['size'] = $context->size;
$statistics['count'] = $context->count;
// return the found and pattern-matched files
sort( $context->elements );
return $context->elements;
}
/**
* Removes files and directories recursively from a file system
*
* This method recursively removes the $directory and all its contents.
* You should be <b>extremely</b> careful with this method as it has the
* potential to erase everything that the current user has access to.
*
* @param string $directory
*/
static public function removeRecursive( $directory )
{
$sourceDir = realpath( $directory );
if ( !$sourceDir )
{
throw new ezcBaseFileNotFoundException( $directory, 'directory' );
}
$d = @dir( $sourceDir );
if ( !$d )
{
throw new ezcBaseFilePermissionException( $directory, ezcBaseFileException::READ );
}
// check if we can remove the dir
$parentDir = realpath( $directory . DIRECTORY_SEPARATOR . '..' );
if ( !is_writable( $parentDir ) )
{
throw new ezcBaseFilePermissionException( $parentDir, ezcBaseFileException::WRITE );
}
// loop over contents
while ( ( $entry = $d->read() ) !== false )
{
if ( $entry == '.' || $entry == '..' )
{
continue;
}
if ( is_dir( $sourceDir . DIRECTORY_SEPARATOR . $entry ) )
{
self::removeRecursive( $sourceDir . DIRECTORY_SEPARATOR . $entry );
}
else
{
if ( @unlink( $sourceDir . DIRECTORY_SEPARATOR . $entry ) === false )
{
throw new ezcBaseFilePermissionException( $directory . DIRECTORY_SEPARATOR . $entry, ezcBaseFileException::REMOVE );
}
}
}
$d->close();
rmdir( $sourceDir );
}
/**
* Recursively copy a file or directory.
*
* Recursively copy a file or directory in $source to the given
* destination. If a depth is given, the operation will stop, if the given
* recursion depth is reached. A depth of -1 means no limit, while a depth
* of 0 means, that only the current file or directory will be copied,
* without any recursion.
*
* You may optionally define modes used to create files and directories.
*
* @throws ezcBaseFileNotFoundException
* If the $sourceDir directory is not a directory or does not exist.
* @throws ezcBaseFilePermissionException
* If the $sourceDir directory could not be opened for reading, or the
* destination is not writeable.
*
* @param string $source
* @param string $destination
* @param int $depth
* @param int $dirMode
* @param int $fileMode
* @return void
*/
static public function copyRecursive( $source, $destination, $depth = -1, $dirMode = 0775, $fileMode = 0664 )
{
// Check if source file exists at all.
if ( !is_file( $source ) && !is_dir( $source ) )
{
throw new ezcBaseFileNotFoundException( $source );
}
// Destination file should NOT exist
if ( is_file( $destination ) || is_dir( $destination ) )
{
throw new ezcBaseFilePermissionException( $destination, ezcBaseFileException::WRITE );
}
// Skip non readable files in source directory
if ( !is_readable( $source ) )
{
return;
}
// Copy
if ( is_dir( $source ) )
{
mkdir( $destination );
// To ignore umask, umask() should not be changed with
// multithreaded servers...
chmod( $destination, $dirMode );
}
elseif ( is_file( $source ) )
{
copy( $source, $destination );
chmod( $destination, $fileMode );
}
if ( ( $depth === 0 ) ||
( !is_dir( $source ) ) )
{
// Do not recurse (any more)
return;
}
// Recurse
$dh = opendir( $source );
while ( ( $file = readdir( $dh ) ) !== false )
{
if ( ( $file === '.' ) ||
( $file === '..' ) )
{
continue;
}
self::copyRecursive(
$source . '/' . $file,
$destination . '/' . $file,
$depth - 1, $dirMode, $fileMode
);
}
}
/**
* Calculates the relative path of the file/directory '$path' to a given
* $base path.
*
* $path and $base should be fully absolute paths. This function returns the
* answer of "How do I go from $base to $path". If the $path and $base are
* the same path, the function returns '.'. This method does not touch the
* filesystem.
*
* @param string $path
* @param string $base
* @return string
*/
static public function calculateRelativePath( $path, $base )
{
// Sanitize the paths to use the correct directory separator for the platform
$path = strtr( $path, '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR );
$base = strtr( $base, '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR );
$base = explode( DIRECTORY_SEPARATOR, $base );
$path = explode( DIRECTORY_SEPARATOR, $path );
// If the paths are the same we return
if ( $base === $path )
{
return '.';
}
$result = '';
$pathPart = array_shift( $path );
$basePart = array_shift( $base );
while ( $pathPart == $basePart )
{
$pathPart = array_shift( $path );
$basePart = array_shift( $base );
}
if ( $pathPart != null )
{
array_unshift( $path, $pathPart );
}
if ( $basePart != null )
{
array_unshift( $base, $basePart );
}
$result = str_repeat( '..' . DIRECTORY_SEPARATOR, count( $base ) );
// prevent a trailing DIRECTORY_SEPARATOR in case there is only a ..
if ( count( $path ) == 0 )
{
$result = substr( $result, 0, -strlen( DIRECTORY_SEPARATOR ) );
}
$result .= join( DIRECTORY_SEPARATOR, $path );
return $result;
}
/**
* Returns whether the passed $path is an absolute path, giving the current $os.
*
* With the $os parameter you can tell this function to use the semantics
* for a different operating system to determine whether a path is
* absolute. The $os argument defaults to the OS that the script is running
* on.
*
* @param string $path
* @param string $os
* @return bool
*/
public static function isAbsolutePath( $path, $os = null )
{
if ( $os === null )
{
$os = ezcBaseFeatures::os();
}
// Stream wrapper like phar can also be considered absolute paths
if ( preg_match( '(^[a-z]{3,}://)S', $path ) )
{
return true;
}
switch ( $os )
{
case 'Windows':
// Sanitize the paths to use the correct directory separator for the platform
$path = strtr( $path, '\\/', '\\\\' );
// Absolute paths with drive letter: X:\
if ( preg_match( '@^[A-Z]:\\\\@i', $path ) )
{
return true;
}
// Absolute paths with network paths: \\server\share\
if ( preg_match( '@^\\\\\\\\[A-Z]+\\\\[^\\\\]@i', $path ) )
{
return true;
}
break;
case 'Mac':
case 'Linux':
case 'FreeBSD':
default:
// Sanitize the paths to use the correct directory separator for the platform
$path = strtr( $path, '\\/', '//' );
if ( $path[0] == '/' )
{
return true;
}
}
return false;
}
}
?>

View File

@@ -0,0 +1,141 @@
<?php
/**
* File containing the ezcBaseInit class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Provides a method to implement delayed initialization of objects.
*
* With the methods in this class you can implement callbacks to configure
* singleton classes. In order to do so you will have to change the
* getInstance() method of your singleton class to include a call to
* ezcBaseInit::fetchConfig() as in the following example:
*
* <code>
* <?php
* public static function getInstance()
* {
* if ( is_null( self::$instance ) )
* {
* self::$instance = new ezcConfigurationmanager();
* ezcBaseInit::fetchConfig( 'ezcInitConfigurationManager', self::$instance );
* }
* return self::$instance;
* }
* ?>
* </code>
*
* You will also need to configure which callback class to call. This you do
* with the ezcBaseInit::setCallback() method. The following examples sets the
* callback classname for the configuration identifier
* 'ezcInitConfigurationManager' to 'cfgConfigurationManager':
*
* <code>
* <?php
* ezcBaseInit::setCallback( 'ezcInitConfigurationManager', 'cfgConfigurationManager' );
* ?>
* </code>
*
* The class 'cfgConfigurationManager' is required to implement the
* ezcBaseConfigurationInitializer interface, which defines only one method:
* configureObject(). An example on how to implement such a class could be:
*
* <code>
* <?php
* class cfgConfigurationManager implements ezcBaseConfigurationInitializer
* {
* static public function configureObject( ezcConfigurationManager $cfgManagerObject )
* {
* $cfgManagerObject->init( 'ezcConfigurationIniReader', 'settings', array( 'useComments' => true ) );
* }
* }
* ?>
* </code>
*
* Of course the implementation of this callback class is up to the application
* developer that uses the component (in this example the Configuration
* component's class ezcConfigurationManager).
*
* @package Base
* @version //autogentag//
*/
class ezcBaseInit
{
/**
* Contains the callback where the identifier is the key of the array, and the classname to callback to the value.
*
* @var array(string=>string)
*/
static private $callbackMap = array();
/**
* Adds the classname $callbackClassname as callback for the identifier $identifier.
*
* @param string $identifier
* @param string $callbackClassname
*/
public static function setCallback( $identifier, $callbackClassname )
{
if ( array_key_exists( $identifier, self::$callbackMap ) )
{
throw new ezcBaseInitCallbackConfiguredException( $identifier, self::$callbackMap[$identifier] );
}
else
{
// Check if the passed classname actually exists
if ( !ezcBaseFeatures::classExists( $callbackClassname, true ) )
{
throw new ezcBaseInitInvalidCallbackClassException( $callbackClassname );
}
// Check if the passed classname actually implements the interface.
if ( !in_array( 'ezcBaseConfigurationInitializer', class_implements( $callbackClassname ) ) )
{
throw new ezcBaseInitInvalidCallbackClassException( $callbackClassname );
}
self::$callbackMap[$identifier] = $callbackClassname;
}
}
/**
* Uses the configured callback belonging to $identifier to configure the $object.
*
* The method will return the return value of the callback method, or null
* in case there was no callback set for the specified $identifier.
*
* @param string $identifier
* @param object $object
* @return mixed
*/
public static function fetchConfig( $identifier, $object )
{
if ( isset( self::$callbackMap[$identifier] ) )
{
$callbackClassname = self::$callbackMap[$identifier];
return call_user_func( array( $callbackClassname, 'configureObject' ), $object );
}
return null;
}
}
?>

View File

@@ -0,0 +1,48 @@
<?php
/**
* File containing the ezcBaseConfigurationInitializer class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* This class provides the interface that classes need to implement to act as
* an callback initializer class to work with the delayed initialization
* mechanism.
*
* @package Base
* @version //autogen//
*/
interface ezcBaseConfigurationInitializer
{
/**
* Configures the given object, or returns the proper object depending on
* the given identifier.
*
* In case a string identifier was given, it should return the associated
* object, in case an object was given the method should return null.
*
* @param string|object $object
* @return mixed
*/
static public function configureObject( $object );
}
?>

View File

@@ -0,0 +1,49 @@
<?php
/**
* File containing the ezcBaseExportable interface.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Interface for class of which instances can be exported using var_export().
*
* In some components, objects can be stored (e.g. to disc) using the var_export()
* function. To ensure that an object supports proper importing again, this
* interface should be implemented.
*
* @see var_export()
*/
interface ezcBaseExportable
{
/**
* Returns an instance of the desired object, initialized from $state.
*
* This method must return a new instance of the class it is implemented
* in, which has its properties set from the given $state array.
*
* @param array $state
* @return object
*/
public static function __set_state( array $state );
}
?>

View File

@@ -0,0 +1,56 @@
<?php
/**
* File containing the ezcBasePersistable interface
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* This class provides the interface that classes need to implement to be able
* to be used by the PersistentObject and Search components.
*
* @package Base
* @version //autogen//
*/
interface ezcBasePersistable
{
/**
* The constructor for the object needs to be able to accept no arguments.
*
* The data is later set through the setState() method.
*/
public function __construct();
/**
* Returns all the object's properties so that they can be stored or indexed.
*
* @return array(string=>mixed)
*/
public function getState();
/**
* Accepts an array containing data for one or more of the class' properties.
*
* @param array $properties
*/
public function setState( array $properties );
}
?>

View File

@@ -0,0 +1,136 @@
<?php
/**
* File containing the ezcBaseMetaData class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Base class implements ways of fetching information about the installed
* eZ Components. It knows whether to use the PEAR registry or the bundled XML
* file, depending on how eZ Components is installed.
*
* @package Base
* @version //autogentag//
* @mainclass
*/
class ezcBaseMetaData
{
/**
* Creates a ezcBaseMetaData object
*
* The sole parameter $installMethod should only be used if you are really
* sure that you need to use it. It is mostly there to make testing at
* least slightly possible. Again, do not set it unless instructed.
*
* @param string $installMethod
*/
public function __construct( $installMethod = NULL )
{
$installMethod = $installMethod !== NULL ? $installMethod : ezcBase::getInstallMethod();
// figure out which reader to use
switch ( $installMethod )
{
case 'tarball':
$this->reader = new ezcBaseMetaDataTarballReader;
break;
case 'pear':
$this->reader = new ezcBaseMetaDataPearReader;
break;
default:
throw new ezcBaseMetaDataReaderException( "Unknown install method '$installMethod'." );
break;
}
}
/**
* Returns the version string for the installed eZ Components bundle.
*
* A version string such as "2008.2.2" is returned.
*
* @return string
*/
public function getBundleVersion()
{
return $this->reader->getBundleVersion();
}
/**
* Returns a PHP version string that describes the required PHP version for
* this installed eZ Components bundle.
*
* @return string
*/
public function getRequiredPhpVersion()
{
return $this->reader->getRequiredPhpVersion();
}
/**
* Returns whether $componentName is installed
*
* If installed with PEAR, it checks the PEAR registry whether the
* component is there. In case the tarball installation method is used, it
* will return true for every component that exists (because all of them
* are then available).
*
* @return bool
*/
public function isComponentInstalled( $componentName )
{
return $this->reader->isComponentInstalled( $componentName );
}
/**
* Returns the version string of the available $componentName or false when
* the component is not installed.
*
* @return string
*/
public function getComponentVersion( $componentName )
{
return $this->reader->getComponentVersion( $componentName );
}
/**
* Returns a list of components that $componentName depends on.
*
* If $componentName is left empty, all installed components are returned.
*
* The returned array has as keys the component names, and as values the
* version of the components.
*
* @return array(string=>string).
*/
public function getComponentDependencies( $componentName = null )
{
if ( $componentName === null )
{
return $this->reader->getComponentDependencies();
}
else
{
return $this->reader->getComponentDependencies( $componentName );
}
}
}
?>

View File

@@ -0,0 +1,145 @@
<?php
/**
* File containing the ezcBaseMetaDataPearReader class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
@require 'PEAR/Registry.php';
/**
* Base class implements ways of fetching information about the installed
* eZ Components when installed as tarball.
*
* Note: there are lots of @ used here, because PEAR still lives in the stone
* age with their PHP 3 code and general liberal use of throwing warnings and
* notices.
*
* @package Base
* @version //autogentag//
* @mainclass
*/
class ezcBaseMetaDataPearReader
{
/**
* Stores the PEAR_Registry to query for information
*
* @var PEAR_Registry
*/
private $registry;
/**
* Creates the reader object and initialized the registry for querying
*/
public function __construct()
{
@$this->registry = new PEAR_Registry;
}
/**
* Returns the version string for the installed eZ Components bundle.
*
* A version string such as "2008.2.2" is returned.
*
* @return string
*/
public function getBundleVersion()
{
@$packageInfo = $this->registry->packageInfo( 'ezcomponents', null, 'components.ez.no' );
return $packageInfo['version']['release'];
}
/**
* Returns a PHP version string that describes the required PHP version for
* this installed eZ Components bundle.
*
* @return string
*/
public function getRequiredPhpVersion()
{
@$packageInfo = $this->registry->packageInfo( 'ezcomponents', null, 'components.ez.no' );
if ( array_key_exists( 'required', $packageInfo['dependencies'] ) )
{
return $packageInfo['dependencies']['required']['php']['min'];
}
return $packageInfo['dependencies']['php']['min'];
}
/**
* Returns whether $componentName is installed
*
* Checks the PEAR registry whether the component is there.
*
* @return bool
*/
public function isComponentInstalled( $componentName )
{
@$packageInfo = $this->registry->packageInfo( $componentName, null, 'components.ez.no' );
return is_array( $packageInfo );
}
/**
* Returns the version string of the available $componentName or false when
* the component is not installed.
*
* @return string
*/
public function getComponentVersion( $componentName )
{
@$packageInfo = $this->registry->packageInfo( $componentName, null, 'components.ez.no' );
$release = $packageInfo['version']['release'];
return $release === null ? false : $release;
}
/**
* Returns a list of components that $componentName depends on.
*
* If $componentName is left empty, all installed components are returned.
*
* The returned array has as keys the component names, and as values the
* version of the components.
*
* @return array(string=>string).
*/
public function getComponentDependencies( $componentName = 'ezcomponents' )
{
@$packageInfo = $this->registry->packageInfo( $componentName, 'dependencies', 'components.ez.no' );
if ( isset( $packageInfo['required']['package'] ) )
{
$deps = array();
if ( isset( $packageInfo['required']['package']['name'] ) )
{
$deps[$packageInfo['required']['package']['name']] = $packageInfo['required']['package']['min'];
}
else
{
foreach ( $packageInfo['required']['package'] as $package )
{
$deps[$package['name']] = $package['min'];
}
}
return $deps;
}
return array();
}
}
?>

View File

@@ -0,0 +1,169 @@
<?php
/**
* File containing the ezcBaseMetaDataTarballReader class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Base class implements ways of fetching information about the installed
* eZ Components when installed as tarball.
*
* @package Base
* @version //autogentag//
* @mainclass
*/
class ezcBaseMetaDataTarballReader
{
/**
* Contains the handler to the XML file containing the release information.
* @var SimpleXmlElement
*/
private $xml;
/**
* Creates the reader object and opens the release-info file.
*/
public function __construct()
{
$filename = dirname( __FILE__ ) . '/../../../release-info.xml';
$this->xml = simplexml_load_file( $filename );
}
/**
* Returns the version string for the installed eZ Components bundle.
*
* A version string such as "2008.2.2" is returned.
*
* @return string
*/
public function getBundleVersion()
{
return (string) $this->xml->version;
}
/**
* Returns a PHP version string that describes the required PHP version for
* this installed eZ Components bundle.
*
* @return string
*/
public function getRequiredPhpVersion()
{
return (string) $this->xml->deps->php;
}
/**
* Returns whether $componentName is installed
*
* Returns true for every component that exists (because all of them are
* then available).
*
* @return bool
*/
public function isComponentInstalled( $componentName )
{
$root = $this->xml->deps->packages->package;
foreach ( $root as $package )
{
if ( (string) $package['name'] == $componentName )
{
return true;
}
}
return false;
}
/**
* Returns the version string of the available $componentName or false when
* the component is not installed.
*
* @return string
*/
public function getComponentVersion( $componentName )
{
$root = $this->xml->deps->packages->package;
foreach ( $root as $package )
{
if ( (string) $package['name'] == $componentName )
{
return (string) $package['version'];
}
}
return false;
}
/**
* Returns a list of components that $componentName depends on.
*
* If $componentName is left empty, all installed components are returned.
*
* The returned array has as keys the component names, and as values the
* version of the components. It returns null of the $componentName
* is not found.
*
* @return array(string=>string).
*/
public function getComponentDependencies( $componentName = null )
{
$baseVersion = false;
$root = $this->xml->deps->packages;
$found = $componentName === null ? true : false;
// in case $componentName != null, we loop through all the components
// in the file, and figure out the new root that we can list dependency
// packages from.
foreach ( $root->package as $package )
{
if ( (string) $package['name'] == 'Base' )
{
$baseVersion = $package['version'];
}
if ( !$found && (string) $package['name'] == $componentName )
{
$root = $package->deps;
$found = true;
}
}
if ( !$found )
{
return null;
}
// We always add the Base dependency even though it's not in the dependency file.
$deps = array();
$deps['Base'] = (string) $baseVersion;
if ( !isset( $root->package ) )
{
return $deps;
}
foreach ( $root->package as $package )
{
$deps[(string) $package['name']] = (string) $package['version'];
}
return $deps;
}
}
?>

View File

@@ -0,0 +1,248 @@
<?php
/**
* File containing the ezcBaseOptions class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Base options class for all eZ components.
*
* @package Base
* @version //autogentag//
*/
abstract class ezcBaseOptions implements ArrayAccess, Iterator
{
/**
* Container to hold the properties
*
* @var array(string=>mixed)
*/
protected $properties;
/**
* Construct a new options object.
* Options are constructed from an option array by default. The constructor
* automatically passes the given options to the __set() method to set them
* in the class.
*
* @throws ezcBasePropertyNotFoundException
* If trying to access a non existent property.
* @throws ezcBaseValueException
* If the value for a property is out of range.
* @param array(string=>mixed) $options The initial options to set.
*/
public function __construct( array $options = array() )
{
foreach ( $options as $option => $value )
{
$this->__set( $option, $value );
}
}
/**
* Merge an array into the actual options object.
* This method merges an array of new options into the actual options object.
*
* @throws ezcBasePropertyNotFoundException
* If trying to access a non existent property.
* @throws ezcBaseValueException
* If the value for a property is out of range.
* @param array(string=>mixed) $newOptions The new options.
*/
public function merge( array $newOptions )
{
foreach ( $newOptions as $key => $value )
{
$this->__set( $key, $value );
}
}
/**
* Property get access.
* Simply returns a given option.
*
* @throws ezcBasePropertyNotFoundException
* If a the value for the property options is not an instance of
* @param string $propertyName The name of the option to get.
* @return mixed The option value.
* @ignore
*
* @throws ezcBasePropertyNotFoundException
* if the given property does not exist.
* @throws ezcBasePropertyPermissionException
* if the property to be set is a write-only property.
*/
public function __get( $propertyName )
{
if ( $this->__isset( $propertyName ) === true )
{
return $this->properties[$propertyName];
}
throw new ezcBasePropertyNotFoundException( $propertyName );
}
/**
* Sets an option.
* This method is called when an option is set.
*
* @param string $propertyName The name of the option to set.
* @param mixed $propertyValue The option value.
* @ignore
*
* @throws ezcBasePropertyNotFoundException
* if the given property does not exist.
* @throws ezcBaseValueException
* if the value to be assigned to a property is invalid.
* @throws ezcBasePropertyPermissionException
* if the property to be set is a read-only property.
*/
abstract public function __set( $propertyName, $propertyValue );
/**
* Returns if a option exists.
*
* @param string $propertyName Option name to check for.
* @return bool Whether the option exists.
* @ignore
*/
public function __isset( $propertyName )
{
return array_key_exists( $propertyName, $this->properties );
}
/**
* Returns if an option exists.
* Allows isset() using ArrayAccess.
*
* @param string $propertyName The name of the option to get.
* @return bool Whether the option exists.
*/
public function offsetExists( $propertyName )
{
return $this->__isset( $propertyName );
}
/**
* Returns an option value.
* Get an option value by ArrayAccess.
*
* @throws ezcBasePropertyNotFoundException
* If $propertyName is not a key in the $properties array.
* @param string $propertyName The name of the option to get.
* @return mixed The option value.
*/
public function offsetGet( $propertyName )
{
return $this->__get( $propertyName );
}
/**
* Set an option.
* Sets an option using ArrayAccess.
*
* @throws ezcBasePropertyNotFoundException
* If $propertyName is not a key in the $properties array.
* @throws ezcBaseValueException
* If the value for a property is out of range.
* @param string $propertyName The name of the option to set.
* @param mixed $propertyValue The value for the option.
*/
public function offsetSet( $propertyName, $propertyValue )
{
$this->__set( $propertyName, $propertyValue );
}
/**
* Unset an option.
* Unsets an option using ArrayAccess.
*
* @throws ezcBasePropertyNotFoundException
* If $propertyName is not a key in the $properties array.
* @throws ezcBaseValueException
* If a the value for a property is out of range.
* @param string $propertyName The name of the option to unset.
*/
public function offsetUnset( $propertyName )
{
$this->__set( $propertyName, null );
}
/**
* Return the current element.
*
* @return void
*/
public function current()
{
return current( $this->properties );
}
/**
* Return the key of the current element.
*
* @return void
*/
public function key()
{
return key( $this->properties );
}
/**
* Move forward to next element.
*
* @return void
*/
public function next()
{
return next( $this->properties );
}
/**
* Rewind the Iterator to the first element.
*
* @return void
*/
public function rewind()
{
reset( $this->properties );
}
/**
* Check if there is a current element after calls to {@link rewind()} or
* {@link next()}.
*
* @return void
*/
public function valid()
{
$key = key( $this->properties );
if( $key !== null && $key !== false)
{
return true;
}
return false;
}
}
?>

View File

@@ -0,0 +1,91 @@
<?php
/**
* File containing the ezcBaseAutoloadOptions class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogen//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Class containing the basic options for ezcBase' autoload.
*
* @property bool $preload
* If component preloading is enabled then as soon as one of the
* classes of a component is request, all other classes in the
* component are loaded as well (except for Exception classes).
* @property bool $debug
* If debug is enabled then the autoload method will show exceptions
* when a class can not be found. Because exceptions are ignored by
* PHP in the autoload handler, you have to catch them in autoload()
* yourself and do something with the exception message.
*
* @package Base
* @version //autogen//
*/
class ezcBaseAutoloadOptions extends ezcBaseOptions
{
/**
* Constructs an object with the specified values.
*
* @throws ezcBasePropertyNotFoundException
* if $options contains a property not defined
* @throws ezcBaseValueException
* if $options contains a property with a value not allowed
* @param array(string=>mixed) $options
*/
public function __construct( array $options = array() )
{
$this->preload = false;
$this->debug = false;
parent::__construct( $options );
}
/**
* Sets the option $name to $value.
*
* @throws ezcBasePropertyNotFoundException
* if the property $name is not defined
* @throws ezcBaseValueException
* if $value is not correct for the property $name
* @param string $name
* @param mixed $value
* @ignore
*/
public function __set( $name, $value )
{
switch ( $name )
{
case 'debug':
case 'preload':
if ( !is_bool( $value ) )
{
throw new ezcBaseValueException( $name, $value, 'bool' );
}
$this->properties[$name] = $value;
break;
default:
throw new ezcBasePropertyNotFoundException( $name );
}
}
}
?>

View File

@@ -0,0 +1,58 @@
<?php
/**
* File containing the ezcBaseStruct.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Base class for all struct classes.
*
* @package Base
* @version //autogentag//
*/
class ezcBaseStruct
{
/**
* Throws a BasePropertyNotFound exception.
*
* @param string $name
* @param mixed $value
* @ignore
*/
final public function __set( $name, $value )
{
throw new ezcBasePropertyNotFoundException( $name );
}
/**
* Throws a BasePropertyNotFound exception.
*
* @param string $name
* @ignore
*/
final public function __get( $name )
{
throw new ezcBasePropertyNotFoundException( $name );
}
}
?>

View File

@@ -0,0 +1,88 @@
<?php
/**
* File containing the ezcBaseFileFindContext class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Struct which defines the information collected by the file walker for locating files.
*
* @package Base
* @version //autogentag//
*/
class ezcBaseFileFindContext extends ezcBaseStruct
{
/**
* The list of files
*
* @var array(string)
*/
public $elements;
/**
* The number of files
*
* @var int
*/
public $count;
/**
* The total file size of all files found
*
* @var int
*/
public $size;
/**
* Constructs a new ezcBaseFileFindContext with initial values.
*
* @param array(string) $elements
* @param int $count
* @param int $size
*/
public function __construct( $elements = array(), $count = 0, $size = 0 )
{
$this->elements = $elements;
$this->count = $count;
$this->size = $size;
}
/**
* Returns a new instance of this class with the data specified by $array.
*
* $array contains all the data members of this class in the form:
* array('member_name'=>value).
*
* __set_state makes this class exportable with var_export.
* var_export() generates code, that calls this method when it
* is parsed with PHP.
*
* @param array(string=>mixed) $array
* @return ezcBaseFileFindContext
*/
static public function __set_state( array $array )
{
return new ezcBaseFileFindContext( $array['elements'], $array['count'], $array['size'] );
}
}
?>

View File

@@ -0,0 +1,99 @@
<?php
/**
* File containing the ezcBaseRepositoryDirectory.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Struct which defines a repository directory.
*
* @package Base
* @version //autogentag//
*/
class ezcBaseRepositoryDirectory extends ezcBaseStruct
{
/**
* Specifies that the entry is for the eZ Components repository.
*/
const TYPE_INTERNAL = 0;
/**
* Specifies that the entry is for an external (user defined) repository.
*/
const TYPE_EXTERNAL = 1;
/**
* The $type is one of the two TYPE_* constants defined in this class.
*
* @var string
*/
public $type;
/**
* The path to the configured repository.
*
* @var string
*/
public $basePath;
/**
* The path to the autoload files.
*
* @var string
*/
public $autoloadPath;
/**
* Constructs a new ezcBaseRepositoryDirectory of type $type with base path
* $basePath and autoload path $autoloadPath.
*
* @param string $type
* @param string $basePath
* @param string $autoloadPath
*/
public function __construct( $type, $basePath, $autoloadPath )
{
$this->type = $type;
$this->basePath = $basePath;
$this->autoloadPath = $autoloadPath;
}
/**
* Returns a new instance of this class with the data specified by $array.
*
* $array contains all the data members of this class in the form:
* array('member_name'=>value).
*
* __set_state makes this class exportable with var_export.
* var_export() generates code, that calls this method when it
* is parsed with PHP.
*
* @param array(string=>mixed) $array
* @return ezcBaseRepositoryDirectory
*/
static public function __set_state( array $array )
{
return new ezcBaseRepositoryDirectory( $array['type'], $array['basePath'], $array['autoloadPath'] );
}
}
?>

View File

@@ -0,0 +1,2 @@
<?php
return array();

View File

@@ -0,0 +1,98 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @subpackage Tests
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
require_once 'init/base_init_callback.php';
require_once 'init/base_init_class.php';
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseInitTest extends ezcTestCase
{
public function setUp()
{
testBaseInitClass::$instance = null;
}
public function testCallbackWithClassThatDoesNotExists()
{
try
{
ezcBaseInit::setCallback( 'testBaseInit', 'classDoesNotExist' );
$this->fail( "Expected exception not thrown." );
}
catch ( ezcBaseInitInvalidCallbackClassException $e )
{
$this->assertEquals( "Class 'classDoesNotExist' does not exist, or does not implement the 'ezcBaseConfigurationInitializer' interface.", $e->getMessage() );
}
}
public function testCallbackWithClassThatDoesNotImplementTheInterface()
{
try
{
ezcBaseInit::setCallback( 'testBaseInit', 'ezcBaseFeatures' );
$this->fail( "Expected exception not thrown." );
}
catch ( ezcBaseInitInvalidCallbackClassException $e )
{
$this->assertEquals( "Class 'ezcBaseFeatures' does not exist, or does not implement the 'ezcBaseConfigurationInitializer' interface.", $e->getMessage() );
}
}
public function testCallback1()
{
$obj = testBaseInitClass::getInstance();
$this->assertEquals( false, $obj->configured );
}
public function testCallback2()
{
ezcBaseInit::setCallback( 'testBaseInit', 'testBaseInitCallback' );
$obj = testBaseInitClass::getInstance();
$this->assertEquals( true, $obj->configured );
}
public function testCallback3()
{
try
{
ezcBaseInit::setCallback( 'testBaseInit', 'testBaseInitCallback' );
$this->fail( "Expected exception not thrown." );
}
catch ( ezcBaseInitCallbackConfiguredException $e )
{
$this->assertEquals( "The 'testBaseInit' is already configured with callback class 'testBaseInitCallback'.", $e->getMessage() );
}
}
public static function suite()
{
return new PHPUnit_Framework_TestSuite("ezcBaseInitTest");
}
}
?>

View File

@@ -0,0 +1,162 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @subpackage Tests
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
require_once dirname( __FILE__ ) . '/test_options.php';
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseOptionsTest extends ezcTestCase
{
public static function suite()
{
return new PHPUnit_Framework_TestSuite("ezcBaseOptionsTest");
}
public function testGetAccessFailure()
{
$opt = new ezcBaseTestOptions();
try
{
echo $opt->properties;
}
catch ( ezcBasePropertyNotFoundException $e )
{
return;
}
$this->fail( "ezcBasePropertyNotFoundException not thrown on access to forbidden property \$properties" );
}
public function testGetOffsetAccessFailure()
{
$opt = new ezcBaseTestOptions();
try
{
echo $opt["properties"];
}
catch ( ezcBasePropertyNotFoundException $e )
{
return;
}
$this->fail( "ezcBasePropertyNotFoundException not thrown on access to forbidden property \$properties" );
}
public function testSetOffsetAccessFailure()
{
$opt = new ezcBaseTestOptions();
try
{
$opt["properties"] = "foo";
}
catch ( ezcBasePropertyNotFoundException $e )
{
return;
}
$this->fail( "ezcBasePropertyNotFoundException not thrown on access to forbidden property \$properties" );
}
public function testConstructorWithParameters()
{
$options = new ezcBaseTestOptions( array( 'foo' => 'xxx' ) );
$this->assertEquals( 'xxx', $options->foo );
}
public function testMerge()
{
$options = new ezcBaseTestOptions();
$this->assertEquals( 'bar', $options->foo );
$options->merge( array( 'foo' => 'xxx' ) );
$this->assertEquals( 'xxx', $options->foo );
}
public function testOffsetExists()
{
$options = new ezcBaseTestOptions();
$this->assertEquals( true, $options->offsetExists( 'foo' ) );
$this->assertEquals( false, $options->offsetExists( 'bar' ) );
}
public function testOffsetSet()
{
$options = new ezcBaseTestOptions();
$this->assertEquals( 'bar', $options->foo );
$options->offsetSet( 'foo', 'xxx' );
$this->assertEquals( 'xxx', $options->foo );
}
public function testOffsetUnset()
{
$options = new ezcBaseTestOptions();
$this->assertEquals( 'bar', $options->foo );
$options->offsetUnset( 'foo' );
$this->assertEquals( null, $options->foo );
$this->assertEquals( true, $options->offsetExists( 'foo' ) );
}
public function testAutoloadOptions()
{
$options = new ezcBaseAutoloadOptions();
try
{
$options->no_such_property = 'value';
$this->fail( 'Expected exception was not thrown.' );
}
catch ( ezcBasePropertyNotFoundException $e )
{
$this->assertEquals( "No such property name 'no_such_property'.", $e->getMessage() );
}
try
{
$options->preload = 'wrong value';
$this->fail( 'Expected exception was not thrown.' );
}
catch ( ezcBaseValueException $e )
{
$this->assertEquals( "The value 'wrong value' that you were trying to assign to setting 'preload' is invalid. Allowed values are: bool.", $e->getMessage() );
}
}
public function testIterator()
{
$options = new ezcBaseTestOptions();
$expectedArray = array( "foo" => "bar", "baz" => "blah" );
$resultArray = array();
foreach( $options as $key => $option )
{
$resultArray[$key] = $option;
}
$this->assertEquals( $expectedArray, $resultArray );
}
}
?>

View File

@@ -0,0 +1,545 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @subpackage Tests
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseTest extends ezcTestCase
{
/*
* For use with the method testInvalidClass().
*/
private $errorMessage = null;
public function testConfigExceptionUnknownSetting()
{
try
{
throw new ezcBaseSettingNotFoundException( 'broken' );
}
catch ( ezcBaseSettingNotFoundException $e )
{
$this->assertEquals( "The setting 'broken' is not a valid configuration setting.", $e->getMessage() );
}
}
public function testConfigExceptionOutOfRange1()
{
try
{
throw new ezcBaseSettingValueException( 'broken', 42 );
}
catch ( ezcBaseSettingValueException $e )
{
$this->assertEquals( "The value '42' that you were trying to assign to setting 'broken' is invalid.", $e->getMessage() );
}
}
public function testConfigExceptionOutOfRange2()
{
try
{
throw new ezcBaseSettingValueException( 'broken', 42, "int, 40 - 48" );
}
catch ( ezcBaseSettingValueException $e )
{
$this->assertEquals( "The value '42' that you were trying to assign to setting 'broken' is invalid. Allowed values are: int, 40 - 48", $e->getMessage() );
}
}
public function testConfigExceptionOutOfRange3()
{
try
{
throw new ezcBaseSettingValueException( 'broken', array(1, 1, 3, 4, 5), 'int' );
}
catch ( ezcBaseSettingValueException $e )
{
$this->assertEquals( "The value 'a:5:{i:0;i:1;i:1;i:1;i:2;i:3;i:3;i:4;i:4;i:5;}' that you were trying to assign to setting 'broken' is invalid. Allowed values are: int", $e->getMessage() );
}
}
public function testFileIoException1()
{
try
{
throw new ezcBaseFileIoException( 'testfile.php', ezcBaseFileException::READ );
}
catch ( ezcBaseFileIoException $e )
{
$this->assertEquals( "An error occurred while reading from 'testfile.php'.", $e->getMessage() );
}
}
public function testFileIoException2()
{
try
{
throw new ezcBaseFileIoException( 'testfile.php', ezcBaseFileException::WRITE );
}
catch ( ezcBaseFileIoException $e )
{
$this->assertEquals( "An error occurred while writing to 'testfile.php'.", $e->getMessage() );
}
}
public function testFileIoException3()
{
try
{
throw new ezcBaseFileIoException( 'testfile.php', ezcBaseFileException::WRITE, "Extra extra" );
}
catch ( ezcBaseFileIoException $e )
{
$this->assertEquals( "An error occurred while writing to 'testfile.php'. (Extra extra)", $e->getMessage() );
}
}
public function testFileNotFoundException1()
{
try
{
throw new ezcBaseFileNotFoundException( 'testfile.php' );
}
catch ( ezcBaseFileNotFoundException $e )
{
$this->assertEquals( "The file 'testfile.php' could not be found.", $e->getMessage() );
}
}
public function testFileNotFoundException2()
{
try
{
throw new ezcBaseFileNotFoundException( 'testfile.php', 'INI' );
}
catch ( ezcBaseFileNotFoundException $e )
{
$this->assertEquals( "The INI file 'testfile.php' could not be found.", $e->getMessage() );
}
}
public function testFileNotFoundException3()
{
try
{
throw new ezcBaseFileNotFoundException( 'testfile.php', 'INI', "Extra extra" );
}
catch ( ezcBaseFileNotFoundException $e )
{
$this->assertEquals( "The INI file 'testfile.php' could not be found. (Extra extra)", $e->getMessage() );
}
}
public function testFilePermissionException1()
{
try
{
throw new ezcBaseFilePermissionException( 'testfile.php', ezcBaseFileException::READ );
}
catch ( ezcBaseFilePermissionException $e )
{
$this->assertEquals( "The file 'testfile.php' can not be opened for reading.", $e->getMessage() );
}
}
public function testFilePermissionException2()
{
try
{
throw new ezcBaseFilePermissionException( 'testfile.php', ezcBaseFileException::WRITE );
}
catch ( ezcBaseFileException $e )
{
$this->assertEquals( "The file 'testfile.php' can not be opened for writing.", $e->getMessage() );
}
}
public function testFilePermissionException3()
{
try
{
throw new ezcBaseFilePermissionException( 'testfile.php', ezcBaseFileException::EXECUTE );
}
catch ( ezcBaseException $e )
{
$this->assertEquals( "The file 'testfile.php' can not be executed.", $e->getMessage() );
}
}
public function testFilePermissionException4()
{
try
{
throw new ezcBaseFilePermissionException( 'testfile.php', ezcBaseFilePermissionException::CHANGE, "Extra extra" );
}
catch ( ezcBaseException $e )
{
$this->assertEquals( "The permissions for 'testfile.php' can not be changed. (Extra extra)", $e->getMessage() );
}
}
public function testFilePermissionException5()
{
try
{
throw new ezcBaseFilePermissionException( 'testfile.php', ezcBaseFilePermissionException::READ | ezcBaseFilePermissionException::WRITE, "Extra extra" );
}
catch ( ezcBaseException $e )
{
$this->assertEquals( "The file 'testfile.php' can not be opened for reading and writing. (Extra extra)", $e->getMessage() );
}
}
public function testFilePermissionException6()
{
try
{
throw new ezcBaseFilePermissionException( 'testfile.php', ezcBaseFilePermissionException::REMOVE, "Extra extra" );
}
catch ( ezcBaseException $e )
{
$this->assertEquals( "The file 'testfile.php' can not be removed. (Extra extra)", $e->getMessage() );
}
}
public function testPropertyNotFoundException()
{
try
{
throw new ezcBasePropertyNotFoundException( 'broken' );
}
catch ( ezcBasePropertyNotFoundException $e )
{
$this->assertEquals( "No such property name 'broken'.", $e->getMessage() );
}
}
public function testPropertyPermissionException1()
{
try
{
throw new ezcBasePropertyPermissionException( 'broken', ezcBasePropertyPermissionException::READ );
}
catch ( ezcBaseException $e )
{
$this->assertEquals( "The property 'broken' is read-only.", $e->getMessage() );
}
}
public function testPropertyPermissionException2()
{
try
{
throw new ezcBasePropertyPermissionException( 'broken', ezcBasePropertyPermissionException::WRITE );
}
catch ( ezcBaseException $e )
{
$this->assertEquals( "The property 'broken' is write-only.", $e->getMessage() );
}
}
public function testBaseValue1()
{
try
{
throw new ezcBaseValueException( 'broken', array( 42 ) );
}
catch ( ezcBaseValueException $e )
{
$this->assertEquals( "The value 'a:1:{i:0;i:42;}' that you were trying to assign to setting 'broken' is invalid.", $e->getMessage() );
}
}
public function testBaseValue2()
{
try
{
throw new ezcBaseValueException( 'broken', "string", "strings" );
}
catch ( ezcBaseValueException $e )
{
$this->assertEquals( "The value 'string' that you were trying to assign to setting 'broken' is invalid. Allowed values are: strings.", $e->getMessage() );
$this->assertEquals( "The value 'string' that you were trying to assign to setting 'broken' is invalid. Allowed values are: strings.", $e->originalMessage );
}
}
public function testExtraDirNotFoundException()
{
try
{
ezcBase::addClassRepository( 'wrongDir' );
}
catch ( ezcBaseFileNotFoundException $e )
{
$this->assertEquals( "The base directory file 'wrongDir' could not be found.", $e->getMessage() );
}
}
public function testExtraDirBaseNotFoundException()
{
try
{
ezcBase::addClassRepository( '.', './wrongAutoloadDir' );
}
catch ( ezcBaseFileNotFoundException $e )
{
$this->assertEquals( "The autoload directory file './wrongAutoloadDir' could not be found.", $e->getMessage() );
}
}
public function testBaseAddAndGetAutoloadDirs1()
{
ezcBase::addClassRepository( __DIR__ );
$resultArray = ezcBase::getRepositoryDirectories();
if ( count( $resultArray ) != 2 )
{
$this->fail( "Duplicating or missing extra autoload dirs while adding." );
}
if ( !isset( $resultArray['ezc'] ) )
{
$this->fail( "No packageDir found in result of getRepositoryDirectories()" );
}
if ( !isset( $resultArray[0] ) || $resultArray[0]->basePath != __DIR__ )
{
$this->fail( "Extra base dir '{$resultArray[0]->basePath}' is added incorrectly" );
}
if ( !isset( $resultArray[0] ) || $resultArray[0]->autoloadPath != __DIR__ . '/autoload' )
{
$this->fail( "Extra autoload dir '{$resultArray[0]->autoloadPath}' is added incorrectly" );
}
}
// this test is sorta obsolete, but we keep it around for good measure
public function testBaseAddAndGetAutoloadDirs2()
{
ezcBase::addClassRepository( __DIR__, __DIR__ . '/autoload' );
ezcBase::addClassRepository( __DIR__ . '/test_repository', __DIR__ . '/test_repository/autoload_files' );
ezcBase::addClassRepository( __DIR__ . '/test_repository', __DIR__ . '/test_repository/autoload_files' );
$resultArray = ezcBase::getRepositoryDirectories();
if ( count( $resultArray ) != 5 )
{
$this->fail( "Duplicating or missing extra autoload dirs while adding." );
}
if ( !isset( $resultArray['ezc'] ) )
{
$this->fail( "No packageDir found in result of getRepositoryDirectories()" );
}
if ( !isset( $resultArray[2] ) || $resultArray[2]->autoloadPath != __DIR__ . '/test_repository/autoload_files' )
{
$this->fail( "Extra autoload dir '{$resultArray[2]->autoloadPath}' is added incorrectly" );
}
self::assertEquals( true, class_exists( 'trBasetestClass', true ) );
self::assertEquals( true, class_exists( 'trBasetestClass2', true ) );
try
{
self::assertEquals( false, class_exists( 'trBasetestClass3', true ) );
self::fail( 'The expected exception was not thrown.' );
}
catch ( ezcBaseAutoloadException $e )
{
self::assertStringStartsWith( "Could not find a class to file mapping for 'trBasetestClass3'. Searched for basetest_class3_autoload.php, basetest_autoload.php, autoload.php in:", $e->getMessage());
}
self::assertEquals( true, class_exists( 'trBasetestLongClass', true ) );
try
{
class_exists( 'trBasetestClass4', true );
self::fail( 'The expected exception was not thrown.' );
}
catch ( ezcBaseFileNotFoundException $e )
{
self::assertEquals( "The file '" . __DIR__ . "/test_repository/TestClasses/base_test_class_number_four.php' could not be found.", $e->getMessage() );
}
}
public function testBaseAddAndGetAutoloadDirs3()
{
ezcBase::addClassRepository( __DIR__ . '/extra_repository', null, 'ext' );
$resultArray = ezcBase::getRepositoryDirectories();
self::assertEquals( true, array_key_exists( 'ezc', $resultArray ) );
self::assertEquals( true, array_key_exists( 'ext', $resultArray ) );
//self::assertEquals( true, class_exists( 'extTranslationTest', true ) );
//self::assertEquals( true, class_exists( 'ezcTranslationTsBackend', true ) );
}
public function testBaseAddAndGetAutoloadDirs4()
{
ezcBase::addClassRepository( __DIR__ . '/test_repository', __DIR__ . '/test_repository/autoload_files', 'tr' );
try
{
ezcBase::addClassRepository( __DIR__ . '/test_repository', __DIR__ . '/test_repository/autoload_files', 'tr' );
}
catch ( ezcBaseDoubleClassRepositoryPrefixException $e )
{
self::assertEquals( "The class repository in '" . __DIR__ . "/test_repository' (with autoload dir '" . __DIR__ . "/test_repository/autoload_files') can not be added because another class repository already uses the prefix 'tr'.", $e->getMessage() );
}
$resultArray = ezcBase::getRepositoryDirectories();
self::assertEquals( 7, count( $resultArray ) );
self::assertEquals( true, array_key_exists( 'ezc', $resultArray ) );
self::assertEquals( true, array_key_exists( 'tr', $resultArray ) );
self::assertEquals( __DIR__ . '/test_repository', $resultArray['tr']->basePath );
self::assertEquals( __DIR__ . '/test_repository/autoload_files', $resultArray['tr']->autoloadPath );
}
public function testNoPrefixAutoload()
{
ezcBase::addClassRepository( __DIR__ . '/test_repository', __DIR__ . '/test_repository/autoload_files' );
ezc_autoload( 'Objet' );
if ( !class_exists( 'Objet' ) )
{
$this->fail( "Autoload does not handle classes with no prefix" );
}
}
public function testNoPrefixAutoload2()
{
ezcBase::addClassRepository( __DIR__ . '/issue15896' );
ezc_autoload( 'ab' );
}
public function testCheckDependencyExtension()
{
ezcBase::checkDependency( 'Tester', ezcBase::DEP_PHP_EXTENSION, 'standard' );
}
public function testCheckDependencyVersion()
{
ezcBase::checkDependency( 'Tester', ezcBase::DEP_PHP_VERSION, '5.1.1' );
}
public function testInvalidClass()
{
$this->setExpectedException( 'ezcBaseAutoloadException', "Could not find a class to file mapping for 'ezcNoSuchClass'. Searched for no_such_autoload.php, no_autoload.php, autoload.php in:" );
self::assertEquals( false, class_exists( 'ezcNoSuchClass', true ) );
}
public function testDebug()
{
try
{
class_exists( 'ezcTestingOne' );
self::fail( "There should have been an exception" );
}
catch ( ezcBaseAutoloadException $e )
{
}
}
public function testNoDebug()
{
try
{
$options = new ezcBaseAutoloadOptions;
$options->debug = false;
ezcBase::setOptions( $options );
class_exists( 'ezcTestingOne' );
}
catch ( Exception $e )
{
self::fail( "There should not have been an exception. Found one: " . $e->getMessage() );
}
}
public function testGetInstallationPath()
{
$this->markTestSkipped( 'What should behavior be in a composer installed environment?' );
$path = ezcBase::getInstallationPath();
$pathParts = explode( DIRECTORY_SEPARATOR, $path );
self::assertEquals( array( 'trunk', '' ), array_splice( $pathParts, -2 ) );
self::assertEquals( DIRECTORY_SEPARATOR, substr( $path, -1 ) );
}
public function testSetInvalidRunMode()
{
try
{
ezcBase::setRunMode( -3 );
self::fail( "Expected exception not thrown." );
}
catch ( ezcBaseValueException $e )
{
self::assertEquals( "The value '-3' that you were trying to assign to setting 'runMode' is invalid. Allowed values are: ezcBase::MODE_PRODUCTION or ezcBase::MODE_DEVELOPMENT.", $e->getMessage() );
}
}
public function testSetGetRunMode()
{
self::assertEquals( ezcBase::MODE_DEVELOPMENT, ezcBase::getRunMode() );
self::assertEquals( true, ezcBase::inDevMode() );
ezcBase::setRunMode( ezcBase::MODE_PRODUCTION );
self::assertEquals( ezcBase::MODE_PRODUCTION, ezcBase::getRunMode() );
self::assertEquals( false, ezcBase::inDevMode() );
ezcBase::setRunMode( ezcBase::MODE_DEVELOPMENT );
self::assertEquals( ezcBase::MODE_DEVELOPMENT, ezcBase::getRunMode() );
self::assertEquals( true, ezcBase::inDevMode() );
}
public function testGetInstallMethod()
{
self::assertEquals( 'custom', ezcBase::getInstallMethod() );
}
public function setup()
{
$options = new ezcBaseAutoloadOptions;
$options->debug = true;
ezcBase::setOptions( $options );
}
public function teardown()
{
$options = new ezcBaseAutoloadOptions;
$options->debug = true;
ezcBase::setOptions( $options );
}
public static function suite()
{
return new PHPUnit_Framework_TestSuite("ezcBaseTest");
}
}
?>

View File

@@ -0,0 +1,26 @@
<?php
if ( ! @include __DIR__ . '/../vendor/autoload.php' )
{
die(<<<'EOT'
You must set up the project dependencies, run the following commands:
wget http://getcomposer.org/composer.phar
php composer.phar install --dev
You can then run tests by calling:
phpunit
EOT
);
}
function ezc_autoload( $className )
{
if ( strpos( $className, '_' ) === false )
{
ezcBase::autoload( $className );
}
}
spl_autoload_register( 'ezc_autoload' );
ezcBase::setWorkingDirectory(__DIR__);

View File

@@ -0,0 +1,14 @@
<?php
// modify when needed
require '/tmp/ezcomponents-2009.1alpha1/Base/src/ezc_bootstrap.php';
$md = new ezcBaseMetaData();
echo $md->getComponentVersion( 'Base' ), "\n";
echo $md->getComponentVersion( 'Archive' ), "\n";
echo $md->getComponentVersion( 'Blah' ), "\n";
echo $md->getComponentVersion( 'Configuration' ), "\n";
echo $md->isComponentInstalled( 'Base' ) ? "true" : "false", "\n";
echo $md->isComponentInstalled( 'Archive' ) ? "true" : "false", "\n";
echo $md->isComponentInstalled( 'Blah' ) ? "true" : "false", "\n";
echo $md->isComponentInstalled( 'Configuration' ) ? "true" : "false", "\n";
?>

View File

@@ -0,0 +1,5 @@
<?php
class extTranslationTest
{
}
?>

View File

@@ -0,0 +1,5 @@
<?php
return array(
'extTranslationTest' => 'Translation/test.php',
);
?>

View File

@@ -0,0 +1,162 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @subpackage Tests
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseFeaturesUnixTest extends ezcTestCase
{
protected function setUp()
{
$uname = php_uname( 's' );
if ( substr( $uname, 0, 7 ) == 'Windows' )
{
$this->markTestSkipped( 'Unix tests' );
}
}
public function testSupportsLink()
{
$this->assertEquals( true, ezcBaseFeatures::supportsLink() );
}
public function testSupportsSymLink()
{
$this->assertEquals( true, ezcBaseFeatures::supportsSymLink() );
}
public function testSupportsUserId()
{
$this->assertEquals( true, ezcBaseFeatures::supportsUserId() );
}
/* // Need to find a way to make this test work, as setting global enviroment variables
// is not working (putenv( "PATH=" ) doesn't unset $_ENV["PATH"])
// One solution would be to use in the ezcBaseFeatures::getPath():
// getenv( 'PATH' ) instead of $_ENV['PATH'] (but that won't work under IIS).
public function testHasImageIdentifyNoPath()
{
$envPath = getenv( 'PATH' );
putenv( "PATH=" );
$this->assertEquals( false, ezcBaseFeatures::hasImageIdentify() );
putenv( "PATH={$envPath}" );
}
*/
public function testHasImageConvert()
{
$this->assertEquals( true, ezcBaseFeatures::hasImageConvert() );
}
public function testGetImageConvertExecutable()
{
$this->assertEquals( '/usr/bin/convert', ezcBaseFeatures::getImageConvertExecutable() );
}
public function testGetImageIdentifyExecutable()
{
$this->assertEquals( '/usr/bin/identify', ezcBaseFeatures::getImageIdentifyExecutable() );
}
public function testHasImageIdentify()
{
$this->assertEquals( true, ezcBaseFeatures::hasImageIdentify() );
}
public function testHasExtensionSupport1()
{
$this->assertEquals( true, ezcBaseFeatures::hasExtensionSupport( 'standard' ) );
}
public function testHasExtensionSupportNotFound1()
{
$this->assertEquals( false, ezcBaseFeatures::hasExtensionSupport( 'non_existent_extension' ) );
try
{
throw new ezcBaseExtensionNotFoundException( 'non_existent_extension', null, 'This is just a test.' );
}
catch ( ezcBaseExtensionNotFoundException $e )
{
$this->assertEquals( "The extension 'non_existent_extension' could not be found. This is just a test.",
$e->getMessage() );
}
}
public function testHasExtensionSupportNotFound2()
{
$this->assertEquals( false, ezcBaseFeatures::hasExtensionSupport( 'non_existent_extension' ) );
try
{
throw new ezcBaseExtensionNotFoundException( 'non_existent_extension', '1.2', 'This is just a test.' );
}
catch ( ezcBaseExtensionNotFoundException $e )
{
$this->assertEquals( "The extension 'non_existent_extension' with version '1.2' could not be found. This is just a test.",
$e->getMessage() );
}
}
public function testHasFunction1()
{
$this->assertEquals( true, ezcBaseFeatures::hasFunction( 'function_exists' ) );
}
public function testHasFunction2()
{
$this->assertEquals( false, ezcBaseFeatures::hasFunction( 'non_existent_function_in_php' ) );
}
public function testHasExtensionSupport2()
{
$this->assertEquals( true, ezcBaseFeatures::hasExtensionSupport( 'date', '5.1.0' ) );
}
public function testClassExists()
{
$this->assertEquals( true, ezcBaseFeatures::classExists( 'Exception', false ) );
}
public function testClassExistsAutoload()
{
$this->assertEquals( true, ezcBaseFeatures::classExists( 'ezcBaseFeatures' ) );
}
public function testClassExistsNotFound()
{
$this->assertEquals( false, ezcBaseFeatures::classExists( 'ezcBaseNonExistingClass', false ) );
}
public function testClassExistsNotFoundAutoload()
{
$this->assertEquals( false, ezcBaseFeatures::classExists( 'ezcBaseNonExistingClass' ) );
}
public static function suite()
{
return new PHPUnit_Framework_TestSuite(__CLASS__);
}
}
?>

View File

@@ -0,0 +1,162 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @subpackage Tests
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseFeaturesWindowsTest extends ezcTestCase
{
protected function setUp()
{
$uname = php_uname( 's' );
if ( substr( $uname, 0, 7 ) != 'Windows' )
{
$this->markTestSkipped( 'Windows tests' );
}
}
public function testSupportsLink()
{
$this->assertFalse( ezcBaseFeatures::supportsLink() );
}
public function testSupportsSymLink()
{
$this->assertFalse( ezcBaseFeatures::supportsSymLink() );
}
public function testSupportsUserId()
{
$this->assertFalse( ezcBaseFeatures::supportsUserId() );
}
/* // Need to find a way to make this test work, as setting global enviroment variables
// is not working (putenv( "PATH=" ) doesn't unset $_ENV["PATH"])
// One solution would be to use in the ezcBaseFeatures::getPath():
// getenv( 'PATH' ) instead of $_ENV['PATH'] (but that won't work under IIS).
public function testHasImageIdentifyNoPath()
{
$envPath = getenv( 'PATH' );
putenv( "PATH=" );
$this->assertEquals( false, ezcBaseFeatures::hasImageIdentify() );
putenv( "PATH={$envPath}" );
}
*/
public function testHasImageConvert()
{
$this->assertTrue( ezcBaseFeatures::hasImageConvert() );
}
public function testGetImageConvertExecutable()
{
$this->assertNotNull( ezcBaseFeatures::getImageConvertExecutable() );
}
public function testGetImageIdentifyExecutable()
{
$this->assertNotNull( ezcBaseFeatures::getImageIdentifyExecutable() );
}
public function testHasImageIdentify()
{
$this->assertTrue( ezcBaseFeatures::hasImageIdentify() );
}
public function testHasExtensionSupport1()
{
$this->assertTrue( ezcBaseFeatures::hasExtensionSupport( 'standard' ) );
}
public function testHasExtensionSupportNotFound1()
{
$this->assertEquals( false, ezcBaseFeatures::hasExtensionSupport( 'non_existent_extension' ) );
try
{
throw new ezcBaseExtensionNotFoundException( 'non_existent_extension', null, 'This is just a test.' );
}
catch ( ezcBaseExtensionNotFoundException $e )
{
$this->assertEquals( "The extension 'non_existent_extension' could not be found. This is just a test.",
$e->getMessage() );
}
}
public function testHasExtensionSupportNotFound2()
{
$this->assertEquals( false, ezcBaseFeatures::hasExtensionSupport( 'non_existent_extension' ) );
try
{
throw new ezcBaseExtensionNotFoundException( 'non_existent_extension', '1.2', 'This is just a test.' );
}
catch ( ezcBaseExtensionNotFoundException $e )
{
$this->assertEquals( "The extension 'non_existent_extension' with version '1.2' could not be found. This is just a test.",
$e->getMessage() );
}
}
public function testHasFunction1()
{
$this->assertEquals( true, ezcBaseFeatures::hasFunction( 'function_exists' ) );
}
public function testHasFunction2()
{
$this->assertEquals( false, ezcBaseFeatures::hasFunction( 'non_existent_function_in_php' ) );
}
public function testHasExtensionSupport2()
{
$this->assertEquals( true, ezcBaseFeatures::hasExtensionSupport( 'date', '5.1.0' ) );
}
public function testClassExists()
{
$this->assertEquals( true, ezcBaseFeatures::classExists( 'Exception', false ) );
}
public function testClassExistsAutoload()
{
$this->assertEquals( true, ezcBaseFeatures::classExists( 'ezcBaseFeatures' ) );
}
public function testClassExistsNotFound()
{
$this->assertEquals( false, ezcBaseFeatures::classExists( 'ezcBaseNonExistingClass', false ) );
}
public function testClassExistsNotFoundAutoload()
{
$this->assertEquals( false, ezcBaseFeatures::classExists( 'ezcBaseNonExistingClass' ) );
}
public static function suite()
{
return new PHPUnit_Framework_TestSuite( __CLASS__ );
}
}
?>

View File

@@ -0,0 +1,109 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @version //autogentag//
* @filesource
* @package Base
* @subpackage Tests
*/
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseFileCalculateRelativePathTest extends ezcTestCase
{
public function testRelative1()
{
$result = ezcBaseFile::calculateRelativePath( 'C:/foo/1/2/php.php', 'C:/foo/bar' );
self::assertEquals( '..' . DIRECTORY_SEPARATOR . '1' . DIRECTORY_SEPARATOR . '2' . DIRECTORY_SEPARATOR . 'php.php', $result );
$result = ezcBaseFile::calculateRelativePath( 'C:/foo/bar/php.php', 'C:/foo/bar' );
self::assertEquals( 'php.php', $result );
$result = ezcBaseFile::calculateRelativePath( 'C:/php.php', 'C:/foo/bar/1/2');
self::assertEquals( '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'php.php', $result );
$result = ezcBaseFile::calculateRelativePath( 'C:/bar/php.php', 'C:/foo/bar/1/2');
self::assertEquals('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR . 'php.php', $result);
}
public function testRelative2()
{
$result = ezcBaseFile::calculateRelativePath( 'C:\\foo\\1\\2\\php.php', 'C:\\foo\\bar' );
self::assertEquals( '..' . DIRECTORY_SEPARATOR . '1' . DIRECTORY_SEPARATOR . '2' . DIRECTORY_SEPARATOR . 'php.php', $result );
$result = ezcBaseFile::calculateRelativePath( 'C:\\foo\\bar\\php.php', 'C:\\foo\\bar' );
self::assertEquals( 'php.php', $result );
$result = ezcBaseFile::calculateRelativePath( 'C:\\foo\\bar', 'C:\\foo\\bar\\php.php' );
self::assertEquals( '..', $result );
$result = ezcBaseFile::calculateRelativePath( 'C:\\php.php', 'C:\\foo\\bar\\1\\2');
self::assertEquals( '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'php.php', $result );
$result = ezcBaseFile::calculateRelativePath( 'C:\\bar\\php.php', 'C:\\foo\\bar\\1\\2');
self::assertEquals('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR . 'php.php', $result);
$result = ezcBaseFile::calculateRelativePath( 'C:\\bar\\php.php', 'D:\\foo\\bar\\1\\2');
self::assertEquals('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'C:' . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR . 'php.php', $result);
}
public function testRelative3()
{
$result = ezcBaseFile::calculateRelativePath( '/foo/1/2/php.php', '/foo/bar' );
self::assertEquals( '..' . DIRECTORY_SEPARATOR . '1' . DIRECTORY_SEPARATOR . '2' . DIRECTORY_SEPARATOR . 'php.php', $result );
$result = ezcBaseFile::calculateRelativePath( '/foo/bar/php.php', '/foo/bar' );
self::assertEquals( 'php.php', $result );
$result = ezcBaseFile::calculateRelativePath( '/foo/bar', '/foo/bar/php.php' );
self::assertEquals( '..', $result );
$result = ezcBaseFile::calculateRelativePath( '/foo/', '/foo/bar/php.php' );
self::assertEquals( '../..', $result );
$result = ezcBaseFile::calculateRelativePath( '/foo', '/foo/bar/php.php' );
self::assertEquals( '../..', $result );
$result = ezcBaseFile::calculateRelativePath( '/', '/foo/bar/php.php' );
self::assertEquals( '../../..', $result );
$result = ezcBaseFile::calculateRelativePath( '/php.php', '/foo/bar/1/2');
self::assertEquals( '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'php.php', $result );
$result = ezcBaseFile::calculateRelativePath( '/bar/php.php', '/foo/bar/1/2');
self::assertEquals('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR . 'php.php', $result);
}
// test for issue #13370
public function testEqual()
{
self::assertEquals( '.', ezcBaseFile::calculateRelativePath( '/bar/php.php', '/bar/php.php' ) );
self::assertEquals( '.', ezcBaseFile::calculateRelativePath( 'C:\workspace\xxx_upgrade', 'C:\workspace\xxx_upgrade' ) );
}
public static function suite()
{
return new PHPUnit_Framework_TestSuite( "ezcBaseFileCalculateRelativePathTest" );
}
}
?>

View File

@@ -0,0 +1,268 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @version //autogentag//
* @filesource
* @package Base
* @subpackage Tests
*/
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseFileCopyRecursiveTest extends ezcTestCase
{
protected function setUp()
{
$this->tempDir = $this->createTempDir( __CLASS__ );
mkdir( $this->tempDir . '/dir1' );
mkdir( $this->tempDir . '/dir2' );
mkdir( $this->tempDir . '/dir2/dir1' );
mkdir( $this->tempDir . '/dir2/dir1/dir1' );
mkdir( $this->tempDir . '/dir2/dir2' );
mkdir( $this->tempDir . '/dir4' );
mkdir( $this->tempDir . '/dir5' );
mkdir( $this->tempDir . '/dir6' );
mkdir( $this->tempDir . '/dir7' );
mkdir( $this->tempDir . '/dir7/0' );
file_put_contents( $this->tempDir . '/dir1/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir1/file2.txt', 'test' );
file_put_contents( $this->tempDir . '/dir1/.file3.txt', 'test' );
file_put_contents( $this->tempDir . '/dir2/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir2/dir1/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir2/dir1/dir1/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir2/dir1/dir1/file2.txt', 'test' );
file_put_contents( $this->tempDir . '/dir2/dir2/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir4/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir4/file2.txt', 'test' );
file_put_contents( $this->tempDir . '/dir5/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir5/file2.txt', 'test' );
file_put_contents( $this->tempDir . '/dir6/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir6/file2.txt', 'test' );
chmod( $this->tempDir . '/dir4/file1.txt', 0 );
chmod( $this->tempDir . '/dir5', 0 );
chmod( $this->tempDir . '/dir6', 0400 );
}
protected function tearDown()
{
chmod( $this->tempDir . '/dir5', 0700 );
chmod( $this->tempDir . '/dir6', 0700 );
$this->removeTempDir();
}
public function testRecursiveCopyEmptyDir()
{
ezcBaseFile::copyRecursive(
$this->tempDir . '/dir1',
$this->tempDir . '/dest'
);
$this->assertEquals(
count( ezcBaseFile::findRecursive( $this->tempDir . '/dir1' ) ),
count( ezcBaseFile::findRecursive( $this->tempDir . '/dest' ) )
);
$this->assertSame(
0775,
fileperms( $this->tempDir . '/dest' ) & 0777,
'Directory mode should equal 0775.'
);
}
public function testRecursiveCopyFile()
{
ezcBaseFile::copyRecursive(
$this->tempDir . '/dir1/file1.txt',
$this->tempDir . '/dest'
);
$this->assertTrue(
is_file( $this->tempDir . '/dest' )
);
$this->assertSame(
0664,
fileperms( $this->tempDir . '/dest' ) & 0777,
'File mode should equal 0664.'
);
}
public function testRecursiveCopyEmptyDirMode()
{
ezcBaseFile::copyRecursive(
$this->tempDir . '/dir1',
$this->tempDir . '/dest',
-1,
0777,
0777
);
$this->assertEquals(
count( ezcBaseFile::findRecursive( $this->tempDir . '/dir1' ) ),
count( ezcBaseFile::findRecursive( $this->tempDir . '/dest' ) )
);
$this->assertSame(
0777,
fileperms( $this->tempDir . '/dest' ) & 0777,
'Directory mode should equal 0777.'
);
}
public function testRecursiveCopyFileMode()
{
ezcBaseFile::copyRecursive(
$this->tempDir . '/dir1/file1.txt',
$this->tempDir . '/dest',
-1,
0777,
0777
);
$this->assertTrue(
is_file( $this->tempDir . '/dest' )
);
$this->assertSame(
0777,
fileperms( $this->tempDir . '/dest' ) & 0777,
'File mode should equal 0777.'
);
}
public function testRecursiveCopyFullDir()
{
ezcBaseFile::copyRecursive(
$this->tempDir . '/dir2',
$this->tempDir . '/dest'
);
$this->assertEquals(
count( ezcBaseFile::findRecursive( $this->tempDir . '/dir2' ) ),
count( ezcBaseFile::findRecursive( $this->tempDir . '/dest' ) )
);
}
public function testRecursiveCopyFullDirDepthZero()
{
ezcBaseFile::copyRecursive(
$this->tempDir . '/dir2',
$this->tempDir . '/dest',
0
);
$this->assertEquals(
0,
count( ezcBaseFile::findRecursive( $this->tempDir . '/dest' ) )
);
$this->assertTrue(
is_dir( $this->tempDir . '/dest' )
);
}
public function testRecursiveCopyFullDirLimitedDepth()
{
ezcBaseFile::copyRecursive(
$this->tempDir . '/dir2',
$this->tempDir . '/dest',
2
);
$this->assertEquals(
3,
count( ezcBaseFile::findRecursive( $this->tempDir . '/dest' ) )
);
}
public function testRecursiveCopyFailureNotExisting()
{
try
{
ezcBaseFile::copyRecursive(
$this->tempDir . '/not_existing',
$this->tempDir . '/dest'
);
}
catch ( ezcBaseFileNotFoundException $e )
{
return;
}
$this->fail( 'Expected ezcBaseFileNotFoundException.' );
}
public function testRecursiveCopyFailureNotReadable()
{
ezcBaseFile::copyRecursive(
$this->tempDir . '/dir5',
$this->tempDir . '/dest'
);
$this->assertFalse(
is_dir( $this->tempDir . '/dest' )
);
$this->assertFalse(
is_file( $this->tempDir . '/dest' )
);
}
public function testRecursiveCopyFailureNotWriteable()
{
try
{
ezcBaseFile::copyRecursive(
$this->tempDir . '/dir2',
$this->tempDir . '/dir4'
);
}
catch ( ezcBaseFilePermissionException $e )
{
return;
}
$this->fail( 'Expected ezcBaseFilePermissionException.' );
}
public static function suite()
{
return new PHPUnit_Framework_TestSuite( __CLASS__ );
}
public function testRecursiveCopyDirCalled0()
{
ezcBaseFile::copyRecursive(
$this->tempDir . '/dir7',
$this->tempDir . '/dest'
);
$this->assertEquals(
count( ezcBaseFile::findRecursive( $this->tempDir . '/dir7' ) ),
count( ezcBaseFile::findRecursive( $this->tempDir . '/dest' ) )
);
$this->assertTrue( is_dir( $this->tempDir . '/dest/0' ) );
}
}
?>

View File

@@ -0,0 +1,166 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @version //autogentag//
* @filesource
* @package Base
* @subpackage Tests
*/
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseFileFindRecursiveTest extends ezcTestCase
{
public function testRecursive1()
{
$expected = array(
0 => 'src/base.php',
1 => 'src/base_autoload.php',
2 => 'src/exceptions/autoload.php',
3 => 'src/exceptions/double_class_repository_prefix.php',
4 => 'src/exceptions/exception.php',
5 => 'src/exceptions/extension_not_found.php',
6 => 'src/exceptions/file_exception.php',
7 => 'src/exceptions/file_io.php',
8 => 'src/exceptions/file_not_found.php',
9 => 'src/exceptions/file_permission.php',
10 => 'src/exceptions/functionality_not_supported.php',
11 => 'src/exceptions/init_callback_configured.php',
12 => 'src/exceptions/invalid_callback_class.php',
13 => 'src/exceptions/invalid_parent_class.php',
14 => 'src/exceptions/property_not_found.php',
15 => 'src/exceptions/property_permission.php',
16 => 'src/exceptions/setting_not_found.php',
17 => 'src/exceptions/setting_value.php',
18 => 'src/exceptions/value.php',
19 => 'src/exceptions/whatever.php',
20 => 'src/ezc_bootstrap.php',
21 => 'src/features.php',
22 => 'src/file.php',
23 => 'src/init.php',
24 => 'src/interfaces/configuration_initializer.php',
25 => 'src/interfaces/exportable.php',
26 => 'src/interfaces/persistable.php',
27 => 'src/metadata.php',
28 => 'src/metadata/pear.php',
29 => 'src/metadata/tarball.php',
30 => 'src/options.php',
31 => 'src/options/autoload.php',
32 => 'src/struct.php',
33 => 'src/structs/file_find_context.php',
34 => 'src/structs/repository_directory.php',
);
$files = ezcBaseFile::findRecursive( "src", array(), array( '@/docs/@', '@svn@', '@\.swp$@', '@git@' ), $stats );
self::assertEquals( $expected, $files );
self::assertEquals( array( 'size' => 133978, 'count' => 35 ), $stats );
}
public function testRecursive2()
{
$expected = array(
0 => 'vendor/zetacomponents/unit-test/CREDITS',
1 => 'vendor/zetacomponents/unit-test/ChangeLog',
2 => 'vendor/zetacomponents/unit-test/NOTICE',
3 => 'vendor/zetacomponents/unit-test/composer.json',
4 => 'vendor/zetacomponents/unit-test/design/class_diagram.png',
5 => 'vendor/zetacomponents/unit-test/src/constraint/image.php',
6 => 'vendor/zetacomponents/unit-test/src/regression_suite.php',
7 => 'vendor/zetacomponents/unit-test/src/regression_test.php',
8 => 'vendor/zetacomponents/unit-test/src/test/case.php',
9 => 'vendor/zetacomponents/unit-test/src/test/image_case.php',
10 => 'vendor/zetacomponents/unit-test/src/test_autoload.php',
);
self::assertEquals( $expected, ezcBaseFile::findRecursive( "vendor/zetacomponents/unit-test", array( '@^vendor/zetacomponents/unit-test/@' ), array( '@/docs/@', '@\.git@', '@\.swp$@' ), $stats ) );
self::assertEquals( array( 'size' => 191012, 'count' => 11 ), $stats );
}
public function testRecursive3()
{
$expected = array (
0 => 'vendor/zetacomponents/unit-test/design/class_diagram.png',
);
self::assertEquals( $expected, ezcBaseFile::findRecursive( "vendor/zetacomponents/unit-test", array( '@\.png$@' ), array( '@\.svn@' ), $stats ) );
self::assertEquals( array( 'size' => 166066, 'count' => 1 ), $stats );
}
public function testRecursive4()
{
$expected = array (
0 => 'vendor/zetacomponents/unit-test/design/class_diagram.png',
);
self::assertEquals( $expected, ezcBaseFile::findRecursive( "vendor/zetacomponents/unit-test", array( '@/design/@' ), array( '@\.svn@' ), $stats ) );
self::assertEquals( array( 'size' => 166066, 'count' => 1 ), $stats );
}
public function testRecursive5()
{
$expected = array (
0 => 'vendor/zetacomponents/unit-test/design/class_diagram.png',
1 => 'vendor/zetacomponents/unit-test/src/constraint/image.php',
2 => 'vendor/zetacomponents/unit-test/src/regression_suite.php',
3 => 'vendor/zetacomponents/unit-test/src/regression_test.php',
4 => 'vendor/zetacomponents/unit-test/src/test/case.php',
5 => 'vendor/zetacomponents/unit-test/src/test/image_case.php',
6 => 'vendor/zetacomponents/unit-test/src/test_autoload.php',
);
self::assertEquals( $expected, ezcBaseFile::findRecursive( "vendor/zetacomponents/unit-test", array( '@\.(php|png)$@' ), array( '@/docs/@', '@\.svn@' ) ) );
}
public function testRecursive6()
{
$expected = array();
self::assertEquals( $expected, ezcBaseFile::findRecursive( "vendor/zetacomponents/unit-test", array( '@xxx@' ) ) );
}
public function testNonExistingDirectory()
{
$expected = array();
try
{
ezcBaseFile::findRecursive( "NotHere", array( '@xxx@' ) );
}
catch ( ezcBaseFileNotFoundException $e )
{
self::assertEquals( "The directory file 'NotHere' could not be found.", $e->getMessage() );
}
}
public function testStatsEmptyArray()
{
$expected = array (
0 => 'vendor/zetacomponents/unit-test/design/class_diagram.png',
);
$stats = array();
self::assertEquals( $expected, ezcBaseFile::findRecursive( "vendor/zetacomponents/unit-test", array( '@/design/@' ), array( '@\.svn@' ), $stats ) );
self::assertEquals( array( 'size' => 166066, 'count' => 1 ), $stats );
}
public static function suite()
{
return new PHPUnit_Framework_TestSuite( "ezcBaseFileFindRecursiveTest" );
}
}
?>

View File

@@ -0,0 +1,247 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @version //autogentag//
* @filesource
* @package Base
* @subpackage Tests
*/
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseFileIsAbsoluteTest extends ezcTestCase
{
public static function testAbsoluteWindows1()
{
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:\\winnt\\winnt.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:\winnt\winnt.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:\\winnt', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:\\winnt.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:\winnt.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:\\winnt.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:\table.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:winnt', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c\\winnt.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '\\winnt.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '\winnt.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'winnt.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '\\server\share\foo.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\\\server\share\foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '\\tequila\share\foo.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\\\tequila\share\foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '\\tequila\thare\foo.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\\\tequila\thare\foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '\\server\\share\foo.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\\\server\\share\foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '\\tequila\\share\foo.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\\\tequila\\share\foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '\etc\init.d\apache', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '\\etc\\init.d\\apache', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'etc\init.d\apache', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'etc\\init.d\\apache', 'Windows' ) );
}
public static function testAbsoluteWindows2()
{
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c://winnt//winnt.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:/winnt/winnt.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c://winnt', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c://winnt.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:/winnt.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c://winnt.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:/table.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:winnt', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c//winnt.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '//winnt.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '/winnt.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'winnt.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//server/share/foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '////server/share/foo.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//tequila/share/foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '////tequila/share/foo.sys', 'Windows' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//tequila/thare/foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '////tequila/thare/foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '//server//share/foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '////server//share/foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '//tequila//share/foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '////tequila//share/foo.sys', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '/etc/init.d/apache', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '//etc//init.d//apache', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'etc/init.d/apache', 'Windows' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'etc//init.d//apache', 'Windows' ) );
}
public static function testAbsoluteWindows3()
{
if ( ezcBaseFeatures::os() !== 'Windows' )
{
self::markTestSkipped( 'Test is for Windows only' );
}
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c://winnt//winnt.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:/winnt/winnt.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c://winnt' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c://winnt.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:/winnt.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c://winnt.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'c:/table.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:winnt' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c//winnt.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '//winnt.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '/winnt.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'winnt.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//server/share/foo.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '////server/share/foo.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//tequila/share/foo.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '////tequila/share/foo.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//tequila/thare/foo.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '////tequila/thare/foo.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '//server//share/foo.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '////server//share/foo.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '//tequila//share/foo.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '////tequila//share/foo.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '/etc/init.d/apache' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( '//etc//init.d//apache' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'etc/init.d/apache' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'etc//init.d//apache' ) );
}
public static function testAbsoluteLinux1()
{
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:\\winnt\\winnt.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:\winnt\winnt.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:\\winnt', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:\\winnt.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:\winnt.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:\\winnt.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:\table.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:winnt', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c\\winnt.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\winnt.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\winnt.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'winnt.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\server\share\foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\\\server\share\foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\tequila\share\foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\\\tequila\share\foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\tequila\thare\foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\\\tequila\thare\foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\server\\share\foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\\\server\\share\foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\tequila\\share\foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\\\tequila\\share\foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\etc\init.d\apache', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '\\etc\\init.d\\apache', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'etc\init.d\apache', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'etc\\init.d\\apache', 'Linux' ) );
}
public static function testAbsoluteLinux2()
{
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c://winnt//winnt.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:/winnt/winnt.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c://winnt', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c://winnt.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:/winnt.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c://winnt.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:/table.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:winnt', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c//winnt.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//winnt.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '/winnt.sys', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'winnt.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//server/share/foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '////server/share/foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//tequila/share/foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '////tequila/share/foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//tequila/thare/foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '////tequila/thare/foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//server//share/foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '////server//share/foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//tequila//share/foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '////tequila//share/foo.sys', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '/etc/init.d/apache', 'Linux' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//etc//init.d//apache', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'etc/init.d/apache', 'Linux' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'etc//init.d//apache', 'Linux' ) );
}
public static function testAbsoluteLinux3()
{
if ( ezcBaseFeatures::os() === 'Windows' )
{
self::markTestSkipped( 'Test is for unix-like systems only' );
}
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c://winnt//winnt.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:/winnt/winnt.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c://winnt' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c://winnt.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:/winnt.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c://winnt.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:/table.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c:winnt' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'c//winnt.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//winnt.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '/winnt.sys' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'winnt.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//server/share/foo.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '////server/share/foo.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//tequila/share/foo.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '////tequila/share/foo.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//tequila/thare/foo.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '////tequila/thare/foo.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//server//share/foo.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '////server//share/foo.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//tequila//share/foo.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '////tequila//share/foo.sys' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '/etc/init.d/apache' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( '//etc//init.d//apache' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'etc/init.d/apache' ) );
self::assertEquals( false, ezcBaseFile::isAbsolutePath( 'etc//init.d//apache' ) );
}
public static function testAbsoluteStreamWrapper()
{
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'phar://test.phar/foo' ) );
self::assertEquals( true, ezcBaseFile::isAbsolutePath( 'http://example.com/file' ) );
}
public static function suite()
{
return new PHPUnit_Framework_TestSuite( "ezcBaseFileIsAbsoluteTest" );
}
}
?>

View File

@@ -0,0 +1,174 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @version //autogentag//
* @filesource
* @package Base
* @subpackage Tests
*/
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseFileRemoveRecursiveTest extends ezcTestCase
{
protected function setUp()
{
$this->tempDir = $this->createTempDir( 'ezcBaseFileRemoveFileRecursiveTest' );
mkdir( $this->tempDir . '/dir1' );
mkdir( $this->tempDir . '/dir2' );
mkdir( $this->tempDir . '/dir2/dir1' );
mkdir( $this->tempDir . '/dir2/dir1/dir1' );
mkdir( $this->tempDir . '/dir2/dir2' );
mkdir( $this->tempDir . '/dir4' );
mkdir( $this->tempDir . '/dir5' );
mkdir( $this->tempDir . '/dir6' );
mkdir( $this->tempDir . '/dir7' );
mkdir( $this->tempDir . '/dir7/dir1' );
mkdir( $this->tempDir . '/dir8' );
mkdir( $this->tempDir . '/dir8/dir1' );
mkdir( $this->tempDir . '/dir8/dir1/dir1' );
file_put_contents( $this->tempDir . '/dir1/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir1/file2.txt', 'test' );
file_put_contents( $this->tempDir . '/dir1/.file3.txt', 'test' );
file_put_contents( $this->tempDir . '/dir2/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir2/dir1/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir2/dir1/dir1/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir2/dir1/dir1/file2.txt', 'test' );
file_put_contents( $this->tempDir . '/dir2/dir2/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir4/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir4/file2.txt', 'test' );
file_put_contents( $this->tempDir . '/dir5/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir5/file2.txt', 'test' );
file_put_contents( $this->tempDir . '/dir6/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir6/file2.txt', 'test' );
file_put_contents( $this->tempDir . '/dir7/dir1/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir8/dir1/file1.txt', 'test' );
file_put_contents( $this->tempDir . '/dir8/dir1/dir1/file1.txt', 'test' );
chmod( $this->tempDir . '/dir4/file1.txt', 0 );
chmod( $this->tempDir . '/dir5', 0 );
chmod( $this->tempDir . '/dir6', 0400 );
chmod( $this->tempDir . '/dir7', 0500 );
chmod( $this->tempDir . '/dir8/dir1', 0500 );
}
protected function tearDown()
{
chmod( $this->tempDir . '/dir5', 0700 );
chmod( $this->tempDir . '/dir6', 0700 );
chmod( $this->tempDir . '/dir7', 0700 );
chmod( $this->tempDir . '/dir8/dir1', 0700 );
$this->removeTempDir();
}
public function testRecursive1()
{
self::assertEquals( 15, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
ezcBaseFile::removeRecursive( $this->tempDir . '/dir1' );
self::assertEquals( 12, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
ezcBaseFile::removeRecursive( $this->tempDir . '/dir2' );
self::assertEquals( 7, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
}
public function testRecursive2()
{
self::assertEquals( 15, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
try
{
ezcBaseFile::removeRecursive( $this->tempDir . '/dir3' );
}
catch ( ezcBaseFileNotFoundException $e )
{
self::assertEquals( "The directory file '{$this->tempDir}/dir3' could not be found.", $e->getMessage() );
}
self::assertEquals( 15, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
}
public function testRecursive3()
{
self::assertEquals( 15, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
try
{
ezcBaseFile::removeRecursive( $this->tempDir . '/dir4' );
}
catch ( ezcBaseFilePermissionException $e )
{
self::assertEquals( "The file '{$this->tempDir}/dir5' can not be opened for reading.", $e->getMessage() );
}
self::assertEquals( 13, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
}
public function testRecursive4()
{
self::assertEquals( 15, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
try
{
ezcBaseFile::removeRecursive( $this->tempDir . '/dir5' );
}
catch ( ezcBaseFilePermissionException $e )
{
self::assertEquals( "The file '{$this->tempDir}/dir5' can not be opened for reading.", $e->getMessage() );
}
self::assertEquals( 15, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
}
public function testRecursive5()
{
self::assertEquals( 15, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
try
{
ezcBaseFile::removeRecursive( $this->tempDir . '/dir6' );
}
catch ( ezcBaseFilePermissionException $e )
{
// Make no asumption on which file is tried to be removed first
self::assertEquals(
1,
preg_match(
"(The file '{$this->tempDir}/dir6/file[12].txt' can not be removed.)",
$e->getMessage()
)
);
}
self::assertEquals( 15, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
}
public function testRecursiveNotWritableParent()
{
self::assertEquals( 15, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
try
{
ezcBaseFile::removeRecursive( $this->tempDir . '/dir7/dir1' );
}
catch ( ezcBaseFilePermissionException $e )
{
self::assertEquals( "The file '{$this->tempDir}/dir7' can not be opened for writing.", $e->getMessage() );
}
self::assertEquals( 15, count( ezcBaseFile::findRecursive( $this->tempDir ) ) );
}
public static function suite()
{
return new PHPUnit_Framework_TestSuite( "ezcBaseFileRemoveRecursiveTest" );
}
}
?>

View File

@@ -0,0 +1,40 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @subpackage Tests
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Test class for ezcBaseInitTest.
*
* @package Base
* @subpackage Tests
*/
class testBaseInitCallback implements ezcBaseConfigurationInitializer
{
static public function configureObject( $objectToConfigure )
{
$objectToConfigure->configured = true;
}
}
?>

View File

@@ -0,0 +1,48 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @subpackage Tests
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Test class for ezcBaseInitTest.
*
* @package Base
* @subpackage Tests
*/
class testBaseInitClass
{
public $configured = false;
public static $instance;
public static function getInstance()
{
if ( is_null( self::$instance ) )
{
self::$instance = new testBaseInitClass();
ezcBaseInit::fetchConfig( 'testBaseInit', self::$instance );
}
return self::$instance;
}
}
?>

View File

@@ -0,0 +1,7 @@
<?php
class ab
{
}
?>

View File

@@ -0,0 +1,7 @@
<?php
return array(
'ab' => 'ab.php'
);
?>

View File

@@ -0,0 +1,98 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @subpackage Tests
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseMetaDataPearTest extends ezcTestCase
{
public function setUp()
{
$this->markTestSkipped('Only work when Zeta Components is installed as pear package.');
}
public static function testConstruct()
{
$r = new ezcBaseMetaData( 'pear' );
self::assertInstanceOf( 'ezcBaseMetaData', $r );
self::assertInstanceOf( 'ezcBaseMetaDataPearReader', self::readAttribute( $r, 'reader' ) );
}
public static function testGetBundleVersion()
{
$r = new ezcBaseMetaData( 'pear' );
$release = $r->getBundleVersion();
self::assertInternalType( 'string', $release );
self::assertRegexp( '@[0-9]{4}\.[0-9](\.[0-9])?@', $release );
}
public static function testIsComponentInstalled()
{
$r = new ezcBaseMetaData( 'pear' );
self::assertTrue( $r->isComponentInstalled( 'Base' ) );
self::assertFalse( $r->isComponentInstalled( 'DefinitelyNot' ) );
}
public static function testGetComponentVersion()
{
$r = new ezcBaseMetaData( 'pear' );
$release = $r->getComponentVersion( 'Base' );
self::assertInternalType( 'string', $release );
self::assertRegexp( '@[0-9]\.[0-9](\.[0-9])?@', $release );
self::assertFalse( $r->getComponentVersion( 'DefinitelyNot' ) );
}
public static function testGetComponentDependencies1()
{
$r = new ezcBaseMetaData( 'pear' );
$deps = array_keys( $r->getComponentDependencies() );
self::assertContains( 'Base', $deps );
self::assertContains( 'Cache', $deps );
self::assertContains( 'Webdav', $deps );
self::assertNotContains( 'Random', $deps );
}
public static function testGetComponentDependencies2()
{
$r = new ezcBaseMetaData( 'pear' );
self::assertSame( array(), $r->getComponentDependencies( 'Base' ) );
self::assertSame( array( 'Base' ), array_keys( $r->getComponentDependencies( 'Template' ) ) );
}
public static function testGetComponentDependencies3()
{
$r = new ezcBaseMetaData( 'pear' );
self::assertContains( 'Base', array_keys( $r->getComponentDependencies( 'TemplateTranslationTiein' ) ) );
self::assertContains( 'Template', array_keys( $r->getComponentDependencies( 'TemplateTranslationTiein' ) ) );
self::assertContains( 'Translation', array_keys( $r->getComponentDependencies( 'TemplateTranslationTiein' ) ) );
}
public static function suite()
{
return new PHPUnit_Framework_TestSuite( 'ezcBaseMetaDataPearTest' );
}
}
?>

View File

@@ -0,0 +1,70 @@
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @subpackage Tests
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseStructTest extends ezcTestCase
{
public function testBaseStructGetSet()
{
$struct = new ezcBaseStruct();
try
{
$struct->no_such_property = 'value';
$this->fail( 'Expected exception was not thrown.' );
}
catch ( ezcBasePropertyNotFoundException $e )
{
$this->assertEquals( "No such property name 'no_such_property'.", $e->getMessage() );
}
try
{
$value = $struct->no_such_property;
$this->fail( 'Expected exception was not thrown.' );
}
catch ( ezcBasePropertyNotFoundException $e )
{
$this->assertEquals( "No such property name 'no_such_property'.", $e->getMessage() );
}
}
public function testBaseRepositoryDirectorySetState()
{
$dir = ezcBaseRepositoryDirectory::__set_state( array( 'type' => ezcBaseRepositoryDirectory::TYPE_EXTERNAL, 'basePath' => '/tmp', 'autoloadPath' => '/tmp/autoload' ) );
$this->assertEquals( ezcBaseRepositoryDirectory::TYPE_EXTERNAL, $dir->type );
$this->assertEquals( '/tmp', $dir->basePath );
$this->assertEquals( '/tmp/autoload', $dir->autoloadPath );
}
public static function suite()
{
return new PHPUnit_Framework_TestSuite( "ezcBaseStructTest" );
}
}
?>

View File

@@ -0,0 +1,18 @@
<?php
class ezcBaseTestOptions extends ezcBaseOptions
{
protected $properties = array( "foo" => "bar", "baz" => "blah" );
public function __set( $propertyName, $propertyValue )
{
if ( $this->__isset( $propertyName ) )
{
$this->properties[$propertyName] = $propertyValue;
}
else
{
throw new ezcBasePropertyNotFoundException( $propertyName );
}
}
}
?>

View File

@@ -0,0 +1,4 @@
<?php
class trBasetestClass {
}
?>

View File

@@ -0,0 +1,4 @@
<?php
class trBasetestClass2 {
}
?>

View File

@@ -0,0 +1,4 @@
<?php
class trBasetestLongClass {
}
?>

View File

@@ -0,0 +1,7 @@
<?php
return array(
'trBasetestClass' => 'TestClasses/base_test_class.php',
'trBasetestClass2' => 'TestClasses/base_test_class_number_two.php',
'trBasetestClass4' => 'TestClasses/base_test_class_number_four.php',
);
?>

View File

@@ -0,0 +1,5 @@
<?php
return array(
'trBasetestLongClass' => 'TestClasses/base_test_long_class.php',
);
?>

View File

@@ -0,0 +1,5 @@
<?php
return array(
'Objet' => 'object/object.php',
);
?>

View File

@@ -0,0 +1,5 @@
<?php
class Objet{
// Objet is not a typo, Object is a reserved keywork in 7.2+
}
?>

View File

@@ -0,0 +1,5 @@
vendor
run-tests-tmp
extract
composer.lock
composer.phar

View File

@@ -0,0 +1,21 @@
language: php
php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- nightly
matrix:
allow_failures:
- php: nightly
before_script:
- composer self-update
- composer update
script:
- vendor/bin/phpunit

View File

@@ -0,0 +1,16 @@
CREDITS
=======
eZ Components team
------------------
- Sergey Alexeev
- Sebastian Bergmann
- Jan Borsodi
- Raymond Bosman
- Frederik Holljen
- Kore Nordmann
- Derick Rethans
- Vadym Savchuk
- Tobias Schlitt
- Alexandru Stanoi

View File

@@ -0,0 +1,465 @@
1.7.1 - Friday 13 March 2020
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixes #11: Compatibility with PHP 7.4
- Enable Travis.
1.7 - Saturday 27 September 2014
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed: Adjusted source headers of Execution to Apache license.
- Updated: Moving copyright information to NOTICE files.
- Fixed: Updated copyright dates in NOTICE files.
- Remove custom test runner.
- Fix autoloading with composer
- Fixed issue #16055: Corrected regression in error message for option
dependencies.
1.6 - Monday 21 December 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- No changes.
1.6rc1 - Monday 07 December 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- No changes.
1.6beta1 - Monday 23 November 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- No changes.
1.6alpha1 - Tuesday 01 September 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Implemented enhancement #14804: ezcConsoleOptionRule now has a property
"ifSet". This one defaults to true, meaning that the rule is validated if
the option it is attached to was submitted. If set to false, the rule is
validated if the option was not submitted.
- Implemented enhansement #14916: Extracted help generation and input
validation from ezcConsoleInput. The interfaces still need validation and are
not public for now.
- Implemented enhancement #15010: The table does not use output formats
anymore, if "useFormats" is set to false in the ezcConsoleOutput instance
used.
1.5.2 - Monday 22 June 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #15009: Empty tables are now rendered correctly.
- Fixed issue #14073: ConsoleTools is not binary safe, presuming UTF-8 input.
Note that the component now depends on ext/iconv which is bundled with PHP
and active by default.
1.5.1 - Monday 11 May 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #14803: Exclusions and dependencies between options now also work
if no short name is provided for the options.
1.5 - Monday 05 January 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- No changes.
1.5rc1 - Monday 15 December 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #14078: ezcConsoleDialog implementations now throw an
ezcConsoleDialogAbortException, if the user closes STDIN (<CTRL>-D).
1.5beta1 - Monday 01 December 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Implemented feature #12567: All help generation methods now support grouping
of options.
- Implemented feature #13240: ezcConsoleProgressbar now allows to specify
$minVerbosity and $maxVerbosity options.
1.4 - Monday 16 June 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- No changes.
1.4rc1 - Tuesday 10 June 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #13118: Class::method() replaced by Class->method() for object
method calls and attribute accesses where appropriate.
1.4beta1 - Tuesday 27 May 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- No changes.
1.4alpha1 - Monday 05 May 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Implemented issue #10765: ezcConsoleQuestionDialog::YesNoQuestion does not
accept "Yes" or "yes" / "no", "No" as valid answer. A new validator
(ezcConsoleQuestionMappingValidator) was introduced for this, which extends
ezcConsoleQuestionCollectionValidator and is now used for the yes-no-question.
- Implemented issue #10791: ezcConsoleTable should implement __toString.
- Implemented issue #10838: ezcConsoleOutputFormats should implement Iterator
and Countable.
- Fixed issue #12561: getSynopsis() bugs when at least 2 options don't have
short-names.
- Fixed issue #12623: console menu dialog handles unexisting options wrong.
- Fixed issue #12624: Wrong text in documentation of eZConsoleDialogViewer.
- Fixed issue #12625: console tools lacks documentation on targets.
- Fixed issue #12626: Type "ta" in ezconsoleoutput documentation.
- Fixed issue #12628: Missing space in ezcConsoleInput::getHelp API doc.
- Fixed issue #12629: Method name not replaced with link in
ezcConsoleMenuDialog::display() API doc.
- Fixed issue #12630: Add link to ezcDialogNoValidResultException in
ezcConsoleDialog::getResult() API doc.
- Fxied issue #12636: ezcConsoleOutput->outputLine() prints EOL always to
STDOUT instead of the defined target.
1.3.2 - Monday 14 January 2008
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #11435: ConsoleInput does not reset $option->value;. The newly
added reset() method can in addtion be used to manually reset all option and
argument values.
- Fixed issue #12364: /ezc/trunk/ConsoleTools/docs/example_table.php base
value exception.
1.3.1 - Wednesday 28 November 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #11378: Example code throws Exception.
1.3 - Monday 02 July 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Documentation updates.
1.3beta2 - Thursday 31 May 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #10766: ezcConsoleQuestionDialogTypeValidator with TYPE_FLOAT
does not accept numbers like 4E3.
- Fixed issue #10767: Class ezcConsoleQuestionDialogRegexValidator described
in the design document is missing.
- Fixed issue #10782: ConsoleTools: Argument mandatoryness applies always. If
help option is set, arguments are not checked anymore and old argument
checking is used, if arguments are disallowed (to assure this is checked
correctly).
- Fixed issue #10864: ezcConsoleTable calculates wrong column length for
content including line breaks.
- Fixed issue #10873: ezcConsoleArgument default value not working.
- Fixed issue #10874: ezcConsoleArgument default value not contained in
generated help text.
1.3beta1 - Monday 07 May 2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #9857: Multi-option and default value. Arrays are now allowed in
default value, if multiple-option is set to true.
- Fixed issue #9902: Problems on Windows.
- Fixed issue #10594: ezcConsole*Options throw incorrect exceptions.
- Fixed issue #10595: ezcConsole*Options perform improper string checks.
- Fixed issue #10596: ezcConsoleTable* classes do not perform proper property
checks.
- Fixed issue #10604: ezcConsoleInput exception not thrown on invalid option
string.
- Fixed issue #10608: ezcConsoleInput->registerAlias( ) does not work.
- Fixed issue #10617: ezcConsoleInput->process() bails out incorrectly on
option exclusion.
- Fixed issue #10619: ezcConsoleOutput __set() broken.
- Fixed issue #10620: ezcConsoleProgressMonitor->__set() issues warning.
- Fixed issue #10624: ezcConsoleStatusbar set access to property $options
broken.
- Fixed issue #10625: ezcConsoleStatusbar isset access to property $options
broken.
- Fixed issue #10626: ezcConsoleStatusbar does not trigger warning on invalid
status.
- Fixed issue #10710: ezcConsoleTable reports fatal error on example
$table[][0]->content = "foo".
- Implemented issue #8461: Argument help text. A completely new argument
handling was invented.
- Implemented issue #8471: Disable borders for ezcConsoleTable. Borders can be
disabled by setting the line and corner properties to null.
- Implemented issue #9216: ezcConsoleInput::getOptionValues I want long names.
ezcConsoleInput->getOptionsValues() can now be configured to index the
returning array with option long names.
1.2 - Monday 18 December 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #9493: Convert < and > in exception messages to ' and ' for
Cache, ConsoleTools, ImageAnalysis, ImageConversion, PersistentObject,
PersistentObjectDatabaseSchemaTiein.
1.2beta2 - Monday 20 November 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed issue #8466: Properties are not documented in ezcConsoleTable,
ezcConsoleStatusbar, etc.
- Fixed issue #9241: Progressbar does not work correctly on Mac OS X.
1.2beta1 - Tuesday 24 October 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added the 'target' property to the ezcConsoleOutputFormat struct. This
allows you to print to a different output target (e.g. stderr).
1.1.3 - Monday 09 October 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed bug #9046: An argument should not be treated as an invalid option
value for an option that doesn't take any value.
- Fixed bug #9052: An exception was thrown because of an invalid property in
ezcConsoleOption.
1.1.2 - Monday 28 August 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed bug #8738: Unexpected behaviour with options->colPadding.
- Fixed bug #8478: ezcConsoleOutput format (foreground) color 'black' not
available. (The fore-/background colors black and gray are now the same and
available for fore- and background).
- PHP 5.2 compatibility.
1.1.1 - Monday 07 August 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed bug #8525: ConsoleInput::getHelpTable() exits with a fatal error.
- Fixed bug #8645: Default values not set correctly in ezcConsoleInput.
1.1 - Monday 12 June 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed bug #8460: ConsoleOption is a class and should have properties instead
of public variables.
- Fixed bug #8472: Update documentation for ezcConsoleTableOptions.
1.1rc1 - Monday 29 May 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Implemented feature request #7792: Possibility to omit the short options.
- Refactored to use the new ezcBaseOptions class.
1.1beta2 - Tuesday 09 May 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed bug #8173: ezcConsoleInput::getHelpText() does return empty synopsis.
1.1beta1 - Wednesday 19 April 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added getHelpTable() and getHelpText() methods to ezcConsoleInput for more
convenient help output generation.
- Added ezcConsoleOption::$isHelpOption flag to indicate, that an option is to
request help. If this flag is set and the option is submitted by the user,
rule checking (dependencies/exclusions/madatoryness) is disabled.
- Added ezcConsoleInput::helpOptionSet() method which returns if an option
that was defined to be a help option was submitted.
- Added the class ezcConsoleProgressMonitor that is capable of printing status
information and percentage progress to the console.
1.0.1 - Monday 06 March 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed unreported bug: ezcConsoleOutput::toPos() has a typo in a parameter.
- Fixed unreported bug: ezcConsoleOption::__construct() still threw old
exception style. Now throws correct ezcConsoleInvalidOptionNameException on
an invalid option name.
- Fixed bug #7897: Access to 'step' property does not work through overloading
in ezcConsoleProgressbar.
- Fixed bug #7923: ezcConsoleInput::getSynopsis() does not work when
supplying parameters to show.
ezcConsoleProgressbar
---------------------
- Added support for a non-integer maximum.
- Added an optional parameter to the advance() method that advances the
progress bar with a different step size than 1.
- Added formatting options for %max% and %act%.
1.0 - Monday 30 January 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed unreported bug: ezcConsoleTableOptions struct caried deprecated
options and missed 2 in its constructor.
- Fixed unreported bug: Option values not properly checked for ezcConsoleTable,
ezcConsoleOutput.
- Fixed unreported bug: ezcConsoleProgressbarOptions disallowed option
read access.
- Fixed unreported bug: ezcConsoleTable "colWrap" option not recognized
correctly.
- Fixed unreported bug: ezcConsoleTable "defaultFormat" and
"defaultBorderFormat" not recognized.
- Fixed notice in ezcConsoleOptionExclusionViolationException.
1.0rc1 - Monday 16 January 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added redrawFrequency option to ezcConsoleProgressbar to allow less redraws
than advance() is called. This allows the progress measuring of huge numbers
without redrawing the bar each time advance() is called.
- Added setOptions() method to ezcConsoleOutput, ezcConsoleTable,
ezcConsoleProgressbar and ezcConsoleStatusbar.
- Changed exception behavior. All errors will now throw a different exception
class.
- Changed default progressbar size to 78 characters (standard console width).
- Changed submission of options to ezcConsoleOutput, ezcConsoleTable,
ezcConsoleProgressbar and ezcConsoleStatusbar to be an array.
- Changed value "step" to be an option in ezcConsoleProgressbar with default
value = 1 (was a setting before).
- Changed "successChar" and "failureChar" to be options in
ezcConsoleStatusbar (were properties before).
- Changed getSuccesses() to getSuccessCount() and getFailures() to
getFailureCount() in ezcConsoleStatusbar.
- Fixed unreported bug regarding rounding problems when calculating different
measures.
1.0beta2 - Friday 23 December 2005
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added convenience method ezcConsoleOutput::outputLine().
This one adds a line break after outputting the desired text and works also
without any text to print a blank line (similar to Pascals writeln()).
- Added option filter parameter to ezcConsoleParameter::getHelp().
This allows you to filter which parameters the information will return
information about.
- Added a new class ezcConsoleOption.
This represents a single option. Before this was named parameter and an array was
used to structure option properties.
Therefore changed / removed the following methods in ezcConsoleParameter
(now ezcConsoleInput):
* getParamDef() -> Deprecated & removed, since getOption() now returns the
complete option object, including settings and value.
* getDefaults() -> Deprecated & removed, since getOption() now returns the
complete option object including the default.
- Added new setting "mandatory" to ezcConsoleOption.
This indicates that an option should always have submitted. Normally all
options are optional.
- Added method getSynopsis().
This generates a synopsis string for the program autonmatically.
- Added cell, row and table based format and alignment settings to
ezcConsoleTable. This allows you to let rows and cells inherit their format
and alignment settings. Rows inherit the format, align and (new)
borderFormat value that were set globally, but only if they have no explicit
value set. Cells inherit their row's format and alignment settings if they
are not explicitly set.
- Added <borderFormat> property to rows.
This allows a more flexible way to specify the format that a border of a row
should have, instead of just saying: "this is a headline row".
- Added new alignment constant ALIGN_DEFAULT to ezcConsoleTable.
This is the default alignment used in ezcConsoleTable objects (cell, row) to
indicate, that the alignment setting should be inherited from the parent.
- Refactored the whole package to fit into the unified layout and provide a
much more convenient API.
- Renamed the class ezcConsoleParameter to ezcConsoleInput.
Reflects it's purpose much better and avoids conflicts with the acronym
"option", which is now used in ezcConsoleOption.
Renamed the cooperating types and methods:
* ezcConsoleParameter::registerParam() to ezcConsoleInput::registerOption().
* ezcConsoleParameter::unregisterParam()
to ezcConsoleInput::unregisterOption().
* ezcConsoleParameter::getParam() to ezcConsoleInput::getOption().
* ezcConsoleParameter::getParams() to ezcConsoleInput::getOptions().
- Changed to the use of structs instead of complex array structures:
* ezcConsoleOptionRule (replaces old handling of dependencies and exclusions
between options - former parameters).
* ezcConsoleOutputFormat (to define format options).
* ezcConsoleOutputOptions (stores the options for ezcConsoleOutput).
* ezcConsoleProgressbarOptions (stores the options for
ezcConsoleProgressbar).
* ezcConsoleTableOptions (stores the options for ezcConsoleTable).
- Changed to the use of "extended structs" where it made sense to avoid
complex arrays:
* ezcConsoleOutputFormats (iteration and on-the-fly creation of format
definitions in ezcConsoleOutput through
$out->formats->{formatname}->{formatoption} = ...;)
- Changed handling of parameter names in ezcConsoleInput.
Short and long parameters are now also handled without their prefixes ("-"
for short names and "--" for long names) everywhere.
- Changed to use overloading property access - __get(),__set(),__isset().
To unify access to object properties and in different other places, which
are explicitly mentioned above (see e.g. ezcConsoleTable) where possible.
- Changed handling of default values for ezcConsoleOption.
Default values are now set if the parameter is not submitted at all. If an
option that expects a value is submitted without, this results in an
exception.
- Changed "colAlign" option to "defaultAlign".
- Changed handling of table structure to classes ezcConsoleTableRow and
ezcConsoleTableCell. These allow a convenient way to create and customize
console based tables:
* $table[0][]; // creates a new cell
* $table[2][]->format = 'important'; // creates a new cell and set's it's
format to 'important',
* $table[2]->align = ezcConsoleTable::ALIGN_CENTER; // sets the default
align
- Removed $cols setting from ezcConsoleTable.
The table now knows on its own how many columns it has, when it is
rendered.
- Renamed ezcConsoleParameter to ezcConsoleInput.
- Renamed methods (consistency):
* ezcConsoleOutput::styleText() to ezcConsoleOutput::formatText().
* ezcConsoleInput::fromString() to ezcConsoleInput::registerOptionString().
* ezcConsoleInput::getValues() to ezcConsoleInput::getOptionsValues().
- Fixed bug with argument handling and non-value parameters in
ezcConsoleInput. It was not possible to sumit the name of a parameter as an
argument after the argument seperator "-- ".
- Fixed bug with submitting multiple parameters of the same name without
value.
1.0beta1 - Friday 25 November 2005
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Initial release of this package.

View File

@@ -0,0 +1,3 @@
A set of classes to do different actions with the console, also called shell.
It can render a progress bar, tables and a status bar and contains a class for
parsing command line options.

View File

@@ -0,0 +1,215 @@
Zeta Components
Copyright 2011-2015 The Zeta Components development group
Apache Zeta Components
Copyright 2010-2011 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Originally developed by eZ Systems as eZ Components
Copyright 2005-2010 eZ Systems AS (http://ez.no)
-----
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,2 @@
- Fix issue with Gnome terminal not recognizing position restore sequence.
- Add generation of help tables.

View File

@@ -0,0 +1,56 @@
{
"authors": [
{
"name": "Sergey Alexeev"
},
{
"name": "Sebastian Bergmann"
},
{
"name": "Jan Borsodi"
},
{
"name": "Raymond Bosman"
},
{
"name": "Frederik Holljen"
},
{
"name": "Kore Nordmann"
},
{
"name": "Derick Rethans"
},
{
"name": "Vadym Savchuk"
},
{
"name": "Tobias Schlitt"
},
{
"name": "Alexandru Stanoi"
}
],
"autoload": {
"classmap": [
"src"
]
},
"autoload-dev": {
"classmap": [
"tests"
]
},
"description": "A set of classes to do different actions with the console (also called shell). It can render a progress bar, tables and a status bar and contains a class for parsing command line options.",
"homepage": "https://github.com/zetacomponents",
"license": "Apache-2.0",
"name": "zetacomponents/console-tools",
"type": "library",
"require": {
"zetacomponents/base": "~1.8"
},
"require-dev": {
"phpunit/phpunit": "~5.7",
"zetacomponents/unit-test": "*"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Some files were not shown because too many files have changed in this diff Show More