diff --git a/.gitignore b/.gitignore index 699037286f2..9ad2d9f890f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ nbproject -demos/Zend/Service/LiveDocx/DemoConfiguration.php diff --git a/INSTALL.txt b/INSTALL.txt index 5f6eecde660..5600ad610f6 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -1,68 +1,72 @@ INSTALLATION ------------ -Zend Framework requires no special installation steps. Simply download the framework, -extract it to the folder you would like to keep it in, and add the library directory -to your PHP include_path. To use components in the extras library, add the extras/library -directory to your PHP include_path, as well. -If you would like to use Zend_Tool, simply add bin/zf.bat (for Windows) or -bin/zf.sh (for anything else) to your system executable path. +Zend Framework requires no special installation steps. Simply download +the framework, extract it to the folder you would like to keep it in, +and add the library directory to your PHP include_path. To use +components in the extras library, add the extras/library directory to +your PHP include_path as well. + +If you would like to use Zend_Tool, simply add "bin/zf.bat" (for Windows) +or "bin/zf.sh" (for anything else) to your system executable path. SYSTEM REQUIREMENTS ------------------- -Zend Framework requires PHP 5.2.4 or later. Please see the system requirements -appendix for more detailed information: +Zend Framework 2 requires PHP 5.3.1 or later. -http://framework.zend.com/manual/en/requirements.html DEVELOPMENT VERSIONS -------------------- -If you would like to preview enhancements or bug fixes that have not yet been -released, you can obtain the current development version of Zend Framework using one -of the following methods: +If you would like to preview enhancements or bug fixes that have not yet +been released, you can obtain the current development version of Zend +Framework using one of the following methods: -* Using a Git client. Zend Framework is open source software, and the Git - repository used for its development is publicly available. Consider using Git - to get Zend Framework if you already use Git for your application development, - want to contribute back to the framework, or need to upgrade your framework - version very often. +* Using a Git client. Zend Framework is open source software, and the + Git repository used for its development is publicly available. + Consider using Git to get Zend Framework if you already use Git for + your application development, want to contribute back to the + framework, or need to upgrade your framework version very often. - Checking out a working copy is necessary if you would like to directly contribute - to Zend Framework; a working copy can be updated any time using git pull. + Checking out a working copy is necessary if you would like to directly + contribute to Zend Framework; a working copy can be updated any time + using git pull. To clone the git repository, use the following URL: - git://git.zendframework.com/zf.git + git://git.zendframework.com/zf.git For more information about Git, please see the official website: - http://www.git-scm.org + http://www.git-scm.org CONFIGURING THE INCLUDE PATH ---------------------------- -Once you have a copy of Zend Framework available, your application will need to -access the framework classes. Though there are several ways to achieve this, your -PHP include_path needs to contain the path to the Zend Framework classes under the -/library directory in this distribution. You can find out more about the PHP -include_path configuration directive here: +Once you have a copy of Zend Framework available, your application will +need to access the framework classes. Though there are several ways to +achieve this, your PHP include_path needs to contain the path to the +Zend Framework classes under the /library directory in this +distribution. You can find out more about the PHP include_path +configuration directive here: -http://www.php.net/manual/en/ini.core.php#ini.include-path + http://www.php.net/manual/en/ini.core.php#ini.include-path -Instructions on how to change PHP configuration directives can be found here: +Instructions on how to change PHP configuration directives can be found +here: -http://www.php.net/manual/en/configuration.changes.php + http://www.php.net/manual/en/configuration.changes.php GETTING STARTED --------------- -A great place to get up-to-speed quickly is the Zend Framework QuickStart: +A great place to get up-to-speed quickly is the Zend Framework +QuickStart: -http://framework.zend.com/manual/en/learning.quickstart.html + http://framework.zend.com/manual/en/learning.quickstart.html -The QuickStart covers some of the most commonly used components of ZF. Since -Zend Framework is designed with a use-at-will architecture and components are -loosely coupled, you can select and use only those components that are needed for -your project. +The QuickStart covers some of the most commonly used components of ZF. +Since Zend Framework is designed with a use-at-will architecture and +components are loosely coupled, you can select and use only those +components that are needed for your project. diff --git a/README-DEV.txt b/README-DEV.txt index c632346d03e..0734bf0b18f 100644 --- a/README-DEV.txt +++ b/README-DEV.txt @@ -55,6 +55,11 @@ To run tests: % phpunit --group Zend_Application + This will likely lead to errors, so it's usually best to specify a + specific component in which to run test: + + % phpunit --group ZF-XYZ Zend/Application + You can turn on conditional tests with the TestConfiguration.php file. To do so: diff --git a/README.txt b/README.txt index 9252dedb2a7..b311aaa01be 100644 --- a/README.txt +++ b/README.txt @@ -30,6 +30,13 @@ INSTALLATION Please see INSTALL.txt. +CONTRIBUTING +------------ + +If you wish to contribute to Zend Framework 2.0, please make sure you have +signed a CLA (http://framework.zend.com/cla), and please read both the +README-DEV.txt and README-GIT.txt file. + QUESTIONS AND FEEDBACK ---------------------- diff --git a/demos/Zend/Service/LiveDocx/MailMerge/conference-pass/dailemaitre.jpg b/demos/Zend/Service/LiveDocx/MailMerge/conference-pass/dailemaitre.jpg deleted file mode 100755 index 987b79b2047..00000000000 Binary files a/demos/Zend/Service/LiveDocx/MailMerge/conference-pass/dailemaitre.jpg and /dev/null differ diff --git a/demos/Zend/Service/LiveDocx/MailMerge/conference-pass/generate-document.php b/demos/Zend/Service/LiveDocx/MailMerge/conference-pass/generate-document.php deleted file mode 100755 index 73450d44833..00000000000 --- a/demos/Zend/Service/LiveDocx/MailMerge/conference-pass/generate-document.php +++ /dev/null @@ -1,39 +0,0 @@ -setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME) - ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD); - -/** - * Image Source: - * iStock_000003413016Medium_business-man-with-hands-up.jpg - */ -$photoFilename = 'dailemaitre.jpg'; - -if (!$mailMerge->imageExists($photoFilename)) { - $mailMerge->uploadImage($photoFilename); -} - -$mailMerge->setLocalTemplate('template.docx'); - -$mailMerge->assign('name', 'Daï Lemaitre') - ->assign('company', 'Megasoft Co-operation') - ->assign('date', Date::now()->toString(Date::DATE_LONG)) - ->assign('image:photo', $photoFilename); - -$mailMerge->createDocument(); - -$document = $mailMerge->retrieveDocument('pdf'); - -file_put_contents('document.pdf', $document); - -$mailMerge->deleteImage($photoFilename); - -unset($mailMerge); \ No newline at end of file diff --git a/demos/Zend/Service/LiveDocx/MailMerge/conference-pass/template.docx b/demos/Zend/Service/LiveDocx/MailMerge/conference-pass/template.docx deleted file mode 100755 index 4c2bc00cb10..00000000000 Binary files a/demos/Zend/Service/LiveDocx/MailMerge/conference-pass/template.docx and /dev/null differ diff --git a/demos/Zend/Service/LiveDocx/MailMerge/images/delete-all.php b/demos/Zend/Service/LiveDocx/MailMerge/images/delete-all.php deleted file mode 100755 index 1fe40e21d1a..00000000000 --- a/demos/Zend/Service/LiveDocx/MailMerge/images/delete-all.php +++ /dev/null @@ -1,30 +0,0 @@ -setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME) - ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD); - -$counter = 1; -foreach ($mailMerge->listImages() as $result) { - printf('%d) %s', $counter, $result['filename']); - $mailMerge->deleteImage($result['filename']); - print(' - DELETED.' . PHP_EOL); - $counter++; -} - -print(PHP_EOL); - -unset($mailMerge); diff --git a/demos/Zend/Service/LiveDocx/MailMerge/images/download.php b/demos/Zend/Service/LiveDocx/MailMerge/images/download.php deleted file mode 100755 index ef6d7b38c4f..00000000000 --- a/demos/Zend/Service/LiveDocx/MailMerge/images/download.php +++ /dev/null @@ -1,31 +0,0 @@ -setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME) - ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD); - -$counter = 1; -foreach ($mailMerge->listImages() as $result) { - printf('%d) %s', $counter, $result['filename']); - $image = $mailMerge->downloadImage($result['filename']); - file_put_contents('downloaded-' . $result['filename'], $image); - print(' - DOWNLOADED.' . PHP_EOL); - $counter++; -} - -print(PHP_EOL); - -unset($mailMerge); diff --git a/demos/Zend/Service/LiveDocx/MailMerge/images/image-01.png b/demos/Zend/Service/LiveDocx/MailMerge/images/image-01.png deleted file mode 100755 index 50f44d2dbd0..00000000000 Binary files a/demos/Zend/Service/LiveDocx/MailMerge/images/image-01.png and /dev/null differ diff --git a/demos/Zend/Service/LiveDocx/MailMerge/images/image-02.png b/demos/Zend/Service/LiveDocx/MailMerge/images/image-02.png deleted file mode 100755 index 51df1173d8d..00000000000 Binary files a/demos/Zend/Service/LiveDocx/MailMerge/images/image-02.png and /dev/null differ diff --git a/demos/Zend/Service/LiveDocx/MailMerge/images/image-exists.php b/demos/Zend/Service/LiveDocx/MailMerge/images/image-exists.php deleted file mode 100755 index 41cbdd3e6c7..00000000000 --- a/demos/Zend/Service/LiveDocx/MailMerge/images/image-exists.php +++ /dev/null @@ -1,30 +0,0 @@ -setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME) - ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD); - -print('Checking whether an image is available... '); -if (true === $mailMerge->imageExists('image-01.png')) { - print('EXISTS. '); -} else { - print('DOES NOT EXIST. '); -} -print('DONE' . PHP_EOL); - -print(PHP_EOL); - -unset($mailMerge); \ No newline at end of file diff --git a/demos/Zend/Service/LiveDocx/MailMerge/images/list.php b/demos/Zend/Service/LiveDocx/MailMerge/images/list.php deleted file mode 100755 index 9a45af86e77..00000000000 --- a/demos/Zend/Service/LiveDocx/MailMerge/images/list.php +++ /dev/null @@ -1,24 +0,0 @@ -setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME) - ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD); - -print(Helper::listDecorator($mailMerge->listImages())); - -unset($mailMerge); diff --git a/demos/Zend/Service/LiveDocx/MailMerge/images/upload.php b/demos/Zend/Service/LiveDocx/MailMerge/images/upload.php deleted file mode 100755 index 362cdc4e317..00000000000 --- a/demos/Zend/Service/LiveDocx/MailMerge/images/upload.php +++ /dev/null @@ -1,30 +0,0 @@ -setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME) - ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD); - -print('Uploading image... '); -$mailMerge->uploadImage('image-01.png'); -print('DONE.' . PHP_EOL); - -print('Uploading image... '); -$mailMerge->uploadImage('image-02.png'); -print('DONE.' . PHP_EOL); - -print(PHP_EOL); - -unset($mailMerge); \ No newline at end of file diff --git a/demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats-cached.php b/demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats-cached.php index 95bfaa713b7..186dd9360ab 100755 --- a/demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats-cached.php +++ b/demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats-cached.php @@ -47,7 +47,7 @@ $formats->template = $mailMerge->getTemplateFormats(); $formats->document = $mailMerge->getDocumentFormats(); - $formats->image = $mailMerge->getImageExportFormats(); + $formats->image = $mailMerge->getImageFormats(); $cache->save($formats, $cacheId); diff --git a/demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats.php b/demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats.php index 459f5639652..3b82dc95727 100755 --- a/demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats.php +++ b/demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats.php @@ -26,7 +26,7 @@ Helper::arrayDecorator($mailMerge->getDocumentFormats()), PHP_EOL); printf("Supported IMAGE file formats (output) : %s%s", - Helper::arrayDecorator($mailMerge->getImageExportFormats()), PHP_EOL); + Helper::arrayDecorator($mailMerge->getImageFormats()), PHP_EOL); print PHP_EOL; diff --git a/demos/Zend/Service/LiveDocx/check-environment.php b/demos/Zend/Service/LiveDocx/check-environment.php index 751621711d5..8beb7653aa1 100755 --- a/demos/Zend/Service/LiveDocx/check-environment.php +++ b/demos/Zend/Service/LiveDocx/check-environment.php @@ -227,7 +227,7 @@ try { $microtime = microtime(true); - $mailMerge = new MailMerge( + $mailMerge = new Zend_Service_LiveDocx_MailMerge( array ( 'username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME, 'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD diff --git a/library/Zend/CodeGenerator/PHP/Exception.php b/demos/Zend/Service/LiveDocx/configuration.php.dist similarity index 50% rename from library/Zend/CodeGenerator/PHP/Exception.php rename to demos/Zend/Service/LiveDocx/configuration.php.dist index e5af532a24b..0fef9c463ae 100644 --- a/library/Zend/CodeGenerator/PHP/Exception.php +++ b/demos/Zend/Service/LiveDocx/configuration.php.dist @@ -1,4 +1,5 @@ _acl->hasResource($class)) { $this->_acl->addResource(new \Zend\Acl\Resource\GenericResource($class)); } - $call = array($object, "initAcl"); - if(is_callable($call) && !call_user_func($call, $this->_acl)) { + if (method_exists($object, 'initAcl')) { // if initAcl returns false, no ACL check - return true; + if ($isObject && $object->initAcl($this->_acl)) { + return true; + } elseif ($class::initAcl($this->_acl)) { + return true; + } } } else { $class = null; diff --git a/library/Zend/Application/Module/Bootstrap.php b/library/Zend/Application/Module/Bootstrap.php index 944e4f062be..faf32606b54 100644 --- a/library/Zend/Application/Module/Bootstrap.php +++ b/library/Zend/Application/Module/Bootstrap.php @@ -117,7 +117,7 @@ public function getModuleName() { if (empty($this->_moduleName)) { $class = get_class($this); - if (preg_match('/^([a-z][a-z0-9]*)_/i', $class, $matches)) { + if (preg_match('/^([a-z][a-z0-9]*)\\\\/i', $class, $matches)) { $prefix = $matches[1]; } else { $prefix = $class; diff --git a/library/Zend/Application/Resource/Mail.php b/library/Zend/Application/Resource/Mail.php index e00bd513ddf..a81778bac83 100644 --- a/library/Zend/Application/Resource/Mail.php +++ b/library/Zend/Application/Resource/Mail.php @@ -107,14 +107,13 @@ protected function _setDefaults($type) if(isset($options[$key]['email']) && !is_numeric($options[$key]['email'])) { - $method = array('Zend\\Mail\\Mail', 'setDefault' . ucfirst($type)); + $method = 'setDefault' . ucfirst($type); if(isset($options[$key]['name']) && !is_numeric($options[$key]['name'])) { - call_user_func($method, $options[$key]['email'], - $options[$key]['name']); + \Zend\Mail\Mail::$method($options[$key]['email'], $options[$key]['name']); } else { - call_user_func($method, $options[$key]['email']); + \Zend\Mail\Mail::$method($options[$key]['email']); } } } diff --git a/library/Zend/Application/Resource/Modules.php b/library/Zend/Application/Resource/Modules.php index eb0ed93b46e..399c3a94bfd 100644 --- a/library/Zend/Application/Resource/Modules.php +++ b/library/Zend/Application/Resource/Modules.php @@ -71,7 +71,7 @@ public function init() $default = $front->getDefaultModule(); $curBootstrapClass = get_class($bootstrap); foreach ($modules as $module => $moduleDirectory) { - $bootstrapClass = $this->_formatModuleName($module) . '_Bootstrap'; + $bootstrapClass = $this->_formatModuleName($module) . '\Bootstrap'; if (!class_exists($bootstrapClass, false)) { $bootstrapPath = dirname($moduleDirectory) . '/Bootstrap.php'; if (file_exists($bootstrapPath)) { diff --git a/library/Zend/Barcode/Renderer/Image.php b/library/Zend/Barcode/Renderer/Image.php index 3a1be000183..e57502afd42 100644 --- a/library/Zend/Barcode/Renderer/Image.php +++ b/library/Zend/Barcode/Renderer/Image.php @@ -333,7 +333,7 @@ public function render() $this->draw(); header("Content-Type: image/" . $this->_imageType); $functionName = 'image' . $this->_imageType; - call_user_func($functionName, $this->_resource); + $functionName($this->_resource); @imagedestroy($this->_resource); } diff --git a/library/Zend/Cache/Backend/StaticBackend.php b/library/Zend/Cache/Backend/StaticBackend.php index e125e6ffc9a..915eab62666 100644 --- a/library/Zend/Cache/Backend/StaticBackend.php +++ b/library/Zend/Cache/Backend/StaticBackend.php @@ -558,6 +558,6 @@ protected function _octdec($val) */ protected function _decodeId($id) { - return pack('H*', $id);; + return pack('H*', $id); } } diff --git a/library/Zend/CodeGenerator/PHP/AbstractPHP.php b/library/Zend/CodeGenerator/PHP/AbstractPHP.php deleted file mode 100644 index 67cb9489f96..00000000000 --- a/library/Zend/CodeGenerator/PHP/AbstractPHP.php +++ /dev/null @@ -1,98 +0,0 @@ -_isSourceDirty = ($isSourceDirty) ? true : false; - return $this; - } - - /** - * isSourceDirty() - * - * @return bool - */ - public function isSourceDirty() - { - return $this->_isSourceDirty; - } - - /** - * setIndentation() - * - * @param string|int $indentation - * @return \Zend\CodeGenerator\PHP\AbstractPHP - */ - public function setIndentation($indentation) - { - $this->_indentation = $indentation; - return $this; - } - - /** - * getIndentation() - * - * @return string|int - */ - public function getIndentation() - { - return $this->_indentation; - } - -} diff --git a/library/Zend/CodeGenerator/PHP/Docblock/Tag/License.php b/library/Zend/CodeGenerator/PHP/Docblock/Tag/License.php deleted file mode 100644 index e7816480a1a..00000000000 --- a/library/Zend/CodeGenerator/PHP/Docblock/Tag/License.php +++ /dev/null @@ -1,99 +0,0 @@ -setName('license'); - $returnTag->setUrl($reflectionTagLicense->getUrl()); - $returnTag->setDescription($reflectionTagLicense->getDescription()); - - return $returnTag; - } - - /** - * setUrl() - * - * @param string $url - * @return \Zend\CodeGenerator\PHP\Docblock\Tag\License - */ - public function setUrl($url) - { - $this->_url = $url; - return $this; - } - - /** - * getUrl() - * - * @return string - */ - public function getUrl() - { - return $this->_url; - } - - - /** - * generate() - * - * @return string - */ - public function generate() - { - $output = '@license ' . $this->_url . ' ' . $this->_description . self::LINE_FEED; - return $output; - } - -} diff --git a/library/Zend/CodeGenerator/PHP/Docblock/Tag/Param.php b/library/Zend/CodeGenerator/PHP/Docblock/Tag/Param.php deleted file mode 100644 index cf5a54a753f..00000000000 --- a/library/Zend/CodeGenerator/PHP/Docblock/Tag/Param.php +++ /dev/null @@ -1,129 +0,0 @@ -setName('param'); - $paramTag->setDatatype($reflectionTagParam->getType()); // @todo rename - $paramTag->setParamName($reflectionTagParam->getVariableName()); - $paramTag->setDescription($reflectionTagParam->getDescription()); - - return $paramTag; - } - - /** - * setDatatype() - * - * @param string $datatype - * @return \Zend\CodeGenerator\PHP\Docblock\Tag\Param - */ - public function setDatatype($datatype) - { - $this->_datatype = $datatype; - return $this; - } - - /** - * getDatatype - * - * @return string - */ - public function getDatatype() - { - return $this->_datatype; - } - - /** - * setParamName() - * - * @param string $paramName - * @return \Zend\CodeGenerator\PHP\Docblock\Tag\Param - */ - public function setParamName($paramName) - { - $this->_paramName = $paramName; - return $this; - } - - /** - * getParamName() - * - * @return string - */ - public function getParamName() - { - return $this->_paramName; - } - - /** - * generate() - * - * @return string - */ - public function generate() - { - $output = '@param ' - . (($this->_datatype != null) ? $this->_datatype : 'unknown') - . (($this->_paramName != null) ? ' $' . $this->_paramName : '') - . (($this->_description != null) ? ' ' . $this->_description : ''); - return $output; - } - -} diff --git a/library/Zend/CodeGenerator/PHP/Docblock/Tag/Return.php b/library/Zend/CodeGenerator/PHP/Docblock/Tag/Return.php deleted file mode 100644 index 110d04a3927..00000000000 --- a/library/Zend/CodeGenerator/PHP/Docblock/Tag/Return.php +++ /dev/null @@ -1,99 +0,0 @@ -setName('return'); - $returnTag->setDatatype($reflectionTagReturn->getType()); // @todo rename - $returnTag->setDescription($reflectionTagReturn->getDescription()); - - return $returnTag; - } - - /** - * setDatatype() - * - * @param string $datatype - * @return \Zend\CodeGenerator\PHP\Docblock\Tag\Return - */ - public function setDatatype($datatype) - { - $this->_datatype = $datatype; - return $this; - } - - /** - * getDatatype() - * - * @return string - */ - public function getDatatype() - { - return $this->_datatype; - } - - - /** - * generate() - * - * @return string - */ - public function generate() - { - $output = '@return ' . $this->_datatype . ' ' . $this->_description; - return $output; - } - -} diff --git a/library/Zend/CodeGenerator/PHP/PHPBody.php b/library/Zend/CodeGenerator/PHP/PHPBody.php deleted file mode 100644 index 282849442c4..00000000000 --- a/library/Zend/CodeGenerator/PHP/PHPBody.php +++ /dev/null @@ -1,74 +0,0 @@ -_content = $content; - return $this; - } - - /** - * getContent() - * - * @return string - */ - public function getContent() - { - return (string) $this->_content; - } - - /** - * generate() - * - * @return string - */ - public function generate() - { - return $this->getContent(); - } -} diff --git a/library/Zend/CodeGenerator/PHP/PHPClass.php b/library/Zend/CodeGenerator/PHP/PHPClass.php deleted file mode 100644 index ac0b066ba33..00000000000 --- a/library/Zend/CodeGenerator/PHP/PHPClass.php +++ /dev/null @@ -1,553 +0,0 @@ -setSourceContent($class->getSourceContent()); - $class->setSourceDirty(false); - - if ($reflectionClass->getDocComment() != '') { - $class->setDocblock(PHPDocblock::fromReflection($reflectionClass->getDocblock())); - } - - $class->setAbstract($reflectionClass->isAbstract()); - - // set the namespace - if ($reflectionClass->inNamespace()) { - $class->setNamespaceName($reflectionClass->getNamespaceName()); - } - - $class->setName($reflectionClass->getName()); - - if ($parentClass = $reflectionClass->getParentClass()) { - $class->setExtendedClass($parentClass->getName()); - $interfaces = array_diff($reflectionClass->getInterfaces(), $parentClass->getInterfaces()); - } else { - $interfaces = $reflectionClass->getInterfaces(); - } - - $interfaceNames = array(); - foreach($interfaces AS $interface) { - $interfaceNames[] = $interface->getName(); - } - - $class->setImplementedInterfaces($interfaceNames); - - $properties = array(); - foreach ($reflectionClass->getProperties() as $reflectionProperty) { - if ($reflectionProperty->getDeclaringClass()->getName() == $class->getName()) { - $properties[] = PHPProperty::fromReflection($reflectionProperty); - } - } - $class->setProperties($properties); - - $methods = array(); - foreach ($reflectionClass->getMethods() as $reflectionMethod) { - if ($reflectionMethod->getDeclaringClass()->getName() == $class->getName()) { - $methods[] = PHPMethod::fromReflection($reflectionMethod); - } - } - $class->setMethods($methods); - - return $class; - } - - /** - * setPHPFile() - * - * @param Zend\CodeGenerator\PHP\PHPFile $phpFile - */ - public function setPHPFile(PHPFile $phpFile) - { - $this->_phpFile = $phpFile; - return $this; - } - - /** - * getPHPFile() - * - * @return Zend\CodeGenerator\PHP\PHPFile - */ - public function getPHPFile() - { - return $this->_phpFile; - } - - /** - * setDocblock() Set the docblock - * - * @param \Zend\CodeGenerator\PHPDocblock|array|string $docblock - * @return \Zend\CodeGenerator\PHP\PHPFile - */ - public function setDocblock($docblock) - { - if (is_string($docblock)) { - $docblock = array('shortDescription' => $docblock); - } - - if (is_array($docblock)) { - $docblock = new PHPDocblock($docblock); - } elseif (!$docblock instanceof PHPDocblock) { - throw new Exception('setDocblock() is expecting either a string, array or an instance of Zend_CodeGenerator_Php_Docblock'); - } - - $this->_docblock = $docblock; - return $this; - } - - /** - * getNamespaceName() - * - * @return string - */ - public function getNamespaceName() - { - return $this->_namespaceName; - } - - /** - * setNamespaceName() - * - * @param $namespaceName - * @return Zend\CodeGenerator\PHP\PHPClass - */ - public function setNamespaceName($namespaceName) - { - $this->_namespaceName = $namespaceName; - return $this; - } - - /** - * getDocblock() - * - * @return \Zend\CodeGenerator\PHPDocblock - */ - public function getDocblock() - { - return $this->_docblock; - } - - /** - * setName() - * - * @param string $name - * @return \Zend\CodeGenerator\PHP\PHPClass - */ - public function setName($name) - { - $this->_name = $name; - return $this; - } - - /** - * getName() - * - * @return string - */ - public function getName() - { - return $this->_name; - } - - /** - * setAbstract() - * - * @param bool $isAbstract - * @return \Zend\CodeGenerator\PHP\PHPClass - */ - public function setAbstract($isAbstract) - { - $this->_isAbstract = ($isAbstract) ? true : false; - return $this; - } - - /** - * isAbstract() - * - * @return bool - */ - public function isAbstract() - { - return $this->_isAbstract; - } - - /** - * setExtendedClass() - * - * @param string $extendedClass - * @return \Zend\CodeGenerator\PHP\PHPClass - */ - public function setExtendedClass($extendedClass) - { - $this->_extendedClass = $extendedClass; - return $this; - } - - /** - * getExtendedClass() - * - * @return string - */ - public function getExtendedClass() - { - return $this->_extendedClass; - } - - /** - * setImplementedInterfaces() - * - * @param array $implementedInterfaces - * @return \Zend\CodeGenerator\PHP\PHPClass - */ - public function setImplementedInterfaces(Array $implementedInterfaces) - { - $this->_implementedInterfaces = $implementedInterfaces; - return $this; - } - - /** - * getImplementedInterfaces - * - * @return array - */ - public function getImplementedInterfaces() - { - return $this->_implementedInterfaces; - } - - /** - * setProperties() - * - * @param array $properties - * @return \Zend\CodeGenerator\PHP\PHPClass - */ - public function setProperties(Array $properties) - { - foreach ($properties as $property) { - $this->setProperty($property); - } - - return $this; - } - - /** - * setProperty() - * - * @param array|\Zend\CodeGenerator\PHP\PHPProperty $property - * @return \Zend\CodeGenerator\PHP\PHPClass - */ - public function setProperty($property) - { - if (is_array($property)) { - $property = new PHPProperty($property); - $propertyName = $property->getName(); - } elseif ($property instanceof PHPProperty) { - $propertyName = $property->getName(); - } else { - throw new Exception('setProperty() expects either an array of property options or an instance of Zend_CodeGenerator_Php_Property'); - } - - if (isset($this->_properties[$propertyName])) { - throw new Exception('A property by name ' . $propertyName . ' already exists in this class.'); - } - - $this->_properties[$propertyName] = $property; - return $this; - } - - /** - * getProperties() - * - * @return array - */ - public function getProperties() - { - return $this->_properties; - } - - /** - * getProperty() - * - * @param string $propertyName - * @return \Zend\CodeGenerator\PHP\PHPProperty - */ - public function getProperty($propertyName) - { - foreach ($this->_properties as $property) { - if ($property->getName() == $propertyName) { - return $property; - } - } - return false; - } - - /** - * hasProperty() - * - * @param string $propertyName - * @return bool - */ - public function hasProperty($propertyName) - { - return isset($this->_properties[$propertyName]); - } - - /** - * setMethods() - * - * @param array $methods - * @return \Zend\CodeGenerator\PHP\PHPClass - */ - public function setMethods(Array $methods) - { - foreach ($methods as $method) { - $this->setMethod($method); - } - return $this; - } - - /** - * setMethod() - * - * @param array|\Zend\CodeGenerator\PHP\PHPMethod $method - * @return \Zend\CodeGenerator\PHP\PHPClass - */ - public function setMethod($method) - { - if (is_array($method)) { - $method = new PHPMethod($method); - $methodName = $method->getName(); - } elseif ($method instanceof PHPMethod) { - $methodName = $method->getName(); - } else { - throw new Exception('setMethod() expects either an array of method options or an instance of Zend\CodeGenerator\PHP\Method'); - } - - if (isset($this->_methods[$methodName])) { - throw new Exception('A method by name ' . $methodName . ' already exists in this class.'); - } - - $this->_methods[$methodName] = $method; - return $this; - } - - /** - * getMethods() - * - * @return array - */ - public function getMethods() - { - return $this->_methods; - } - - /** - * getMethod() - * - * @param string $methodName - * @return \Zend\CodeGenerator\PHP\PHPMethod - */ - public function getMethod($methodName) - { - foreach ($this->_methods as $method) { - if ($method->getName() == $methodName) { - return $method; - } - } - return false; - } - - /** - * hasMethod() - * - * @param string $methodName - * @return bool - */ - public function hasMethod($methodName) - { - return isset($this->_methods[$methodName]); - } - - /** - * isSourceDirty() - * - * @return bool - */ - public function isSourceDirty() - { - if (($docblock = $this->getDocblock()) && $docblock->isSourceDirty()) { - return true; - } - - foreach ($this->_properties as $property) { - if ($property->isSourceDirty()) { - return true; - } - } - - foreach ($this->_methods as $method) { - if ($method->isSourceDirty()) { - return true; - } - } - - return parent::isSourceDirty(); - } - - /** - * generate() - * - * @return string - */ - public function generate() - { - if (!$this->isSourceDirty()) { - return $this->getSourceContent(); - } - - $output = ''; - - if (null !== ($docblock = $this->getDocblock())) { - $docblock->setIndentation(''); - $output .= $docblock->generate(); - } - - if ($this->isAbstract()) { - $output .= 'abstract '; - } - - $output .= 'class ' . $this->getName(); - - if ( !empty( $this->_extendedClass) ) { - $output .= ' extends ' . $this->_extendedClass; - } - - $implemented = $this->getImplementedInterfaces(); - if (!empty($implemented)) { - $output .= ' implements ' . implode(', ', $implemented); - } - - $output .= self::LINE_FEED . '{' . self::LINE_FEED . self::LINE_FEED; - - $properties = $this->getProperties(); - if (!empty($properties)) { - foreach ($properties as $property) { - $output .= $property->generate() . self::LINE_FEED . self::LINE_FEED; - } - } - - $methods = $this->getMethods(); - if (!empty($methods)) { - foreach ($methods as $method) { - $output .= $method->generate() . self::LINE_FEED; - } - } - - $output .= self::LINE_FEED . '}' . self::LINE_FEED; - - return $output; - } - - /** - * _init() - is called at construction time - * - */ - protected function _init() - { - $this->_properties = new PHPMember\MemberContainer(PHPMember\MemberContainer::TYPE_PROPERTY); - $this->_methods = new PHPMember\MemberContainer(PHPMember\MemberContainer::TYPE_METHOD); - } - -} diff --git a/library/Zend/CodeGenerator/PHP/PHPDocblock.php b/library/Zend/CodeGenerator/PHP/PHPDocblock.php deleted file mode 100644 index 8a1da76d051..00000000000 --- a/library/Zend/CodeGenerator/PHP/PHPDocblock.php +++ /dev/null @@ -1,217 +0,0 @@ -setSourceContent($reflectionDocblock->getContents()); - $docblock->setSourceDirty(false); - - $docblock->setShortDescription($reflectionDocblock->getShortDescription()); - $docblock->setLongDescription($reflectionDocblock->getLongDescription()); - - foreach ($reflectionDocblock->getTags() as $tag) { - $docblock->setTag(PHPDocblockTag::fromReflection($tag)); - } - - return $docblock; - } - - /** - * setShortDescription() - * - * @param string $shortDescription - * @return \Zend\CodeGenerator\PHPDocblock - */ - public function setShortDescription($shortDescription) - { - $this->_shortDescription = $shortDescription; - return $this; - } - - /** - * getShortDescription() - * - * @return string - */ - public function getShortDescription() - { - return $this->_shortDescription; - } - - /** - * setLongDescription() - * - * @param string $longDescription - * @return \Zend\CodeGenerator\PHPDocblock - */ - public function setLongDescription($longDescription) - { - $this->_longDescription = $longDescription; - return $this; - } - - /** - * getLongDescription() - * - * @return string - */ - public function getLongDescription() - { - return $this->_longDescription; - } - - /** - * setTags() - * - * @param array $tags - * @return \Zend\CodeGenerator\PHPDocblock - */ - public function setTags(Array $tags) - { - foreach ($tags as $tag) { - $this->setTag($tag); - } - - return $this; - } - - /** - * setTag() - * - * @param array|\Zend\CodeGenerator\PHP\PHPDocblockTag $tag - * @return \Zend\CodeGenerator\PHPDocblock - */ - public function setTag($tag) - { - if (is_array($tag)) { - $tag = new PHPDocblockTag($tag); - } elseif (!$tag instanceof PHPDocblockTag) { - throw new Exception( - 'setTag() expects either an array of method options or an ' - . 'instance of Zend_CodeGenerator_Php_Docblock_Tag' - ); - } - - $this->_tags[] = $tag; - return $this; - } - - /** - * getTags - * - * @return array Array of \Zend\CodeGenerator\PHP\PHPDocblockTag - */ - public function getTags() - { - return $this->_tags; - } - - /** - * generate() - * - * @return string - */ - public function generate() - { - if (!$this->isSourceDirty()) { - return $this->_docCommentize($this->getSourceContent()); - } - - $output = ''; - if (null !== ($sd = $this->getShortDescription())) { - $output .= $sd . self::LINE_FEED . self::LINE_FEED; - } - if (null !== ($ld = $this->getLongDescription())) { - $output .= $ld . self::LINE_FEED . self::LINE_FEED; - } - - foreach ($this->getTags() as $tag) { - $output .= $tag->generate() . self::LINE_FEED; - } - - return $this->_docCommentize(trim($output)); - } - - /** - * _docCommentize() - * - * @param string $content - * @return string - */ - protected function _docCommentize($content) - { - $indent = $this->getIndentation(); - $output = $indent . '/**' . self::LINE_FEED; - $content = wordwrap($content, 80, self::LINE_FEED); - $lines = explode(self::LINE_FEED, $content); - foreach ($lines as $line) { - $output .= $indent . ' * ' . $line . self::LINE_FEED; - } - $output .= $indent . ' */' . self::LINE_FEED; - return $output; - } - -} diff --git a/library/Zend/CodeGenerator/PHP/PHPDocblockTag.php b/library/Zend/CodeGenerator/PHP/PHPDocblockTag.php deleted file mode 100644 index 5eb887aaa9e..00000000000 --- a/library/Zend/CodeGenerator/PHP/PHPDocblockTag.php +++ /dev/null @@ -1,142 +0,0 @@ - ' - ), - array( - 'return', - '@return ' - ), - array( - 'tag', - '@ ' - ) - ); - - /** - * @var string - */ - protected $_name = null; - - /** - * fromReflection() - * - * @param \Zend\Reflection\ReflectionDocblockTag $reflectionTag - * @return \Zend\CodeGenerator\PHP\PHPDocblockTag - */ - public static function fromReflection(\Zend\Reflection\ReflectionDocblockTag $reflectionTag) - { - $tagName = $reflectionTag->getName(); - - $codeGenDocblockTag = new self(); - $codeGenDocblockTag->setName($tagName); - - // transport any properties via accessors and mutators from reflection to codegen object - $reflectionClass = new \ReflectionClass($reflectionTag); - foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { - if (substr($method->getName(), 0, 3) == 'get') { - $propertyName = substr($method->getName(), 3); - if (method_exists($codeGenDocblockTag, 'set' . $propertyName)) { - $codeGenDocblockTag->{'set' . $propertyName}($reflectionTag->{'get' . $propertyName}()); - } - } - } - - return $codeGenDocblockTag; - } - - /** - * setName() - * - * @param string $name - * @return \Zend\CodeGenerator\PHP\PHPDocblockTag - */ - public function setName($name) - { - $this->_name = ltrim($name, '@'); - return $this; - } - - /** - * getName() - * - * @return string - */ - public function getName() - { - return $this->_name; - } - - /** - * setDescription() - * - * @param string $description - * @return \Zend\CodeGenerator\PHP\PHPDocblockTag - */ - public function setDescription($description) - { - $this->_description = $description; - return $this; - } - - /** - * getDescription() - * - * @return string - */ - public function getDescription() - { - return $this->_description; - } - - /** - * generate() - * - * @return string - */ - public function generate() - { - return '@' . $this->_name . ' ' . $this->_description; - } - -} diff --git a/library/Zend/CodeGenerator/PHP/PHPFile.php b/library/Zend/CodeGenerator/PHP/PHPFile.php deleted file mode 100644 index af86b8e4b67..00000000000 --- a/library/Zend/CodeGenerator/PHP/PHPFile.php +++ /dev/null @@ -1,573 +0,0 @@ -getFilename(); - } - - if ($fileName == '') { - throw new Exception('FileName does not exist.'); - } - - // cannot use realpath since the file might not exist, but we do need to have the index - // in the same DIRECTORY_SEPARATOR that realpath would use: - $fileName = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $fileName); - - self::$_fileCodeGenerators[$fileName] = $fileCodeGenerator; - - } - - /** - * fromReflectedFilePath() - use this if you intend on generating code generation objects based on the same file. - * This will keep previous changes to the file in tact during the same PHP process - * - * @param string $filePath - * @param bool $usePreviousCodeGeneratorIfItExists - * @param bool $includeIfNotAlreadyIncluded - * @return \Zend\CodeGenerator\PHP\PHPFile - */ - public static function fromReflectedFileName($filePath, $usePreviousCodeGeneratorIfItExists = true, $includeIfNotAlreadyIncluded = true) - { - $realpath = realpath($filePath); - - if ($realpath === false) { - if ( ($realpath = Reflection\file::findRealpathInIncludePath($filePath)) === false) { - throw new Exception('No file for ' . $realpath . ' was found.'); - } - } - - if ($usePreviousCodeGeneratorIfItExists && isset(self::$_fileCodeGenerators[$realpath])) { - return self::$_fileCodeGenerators[$realpath]; - } - - if ($includeIfNotAlreadyIncluded && !in_array($realpath, get_included_files())) { - include $realpath; - } - - $codeGenerator = self::fromReflection(($fileReflector = new Reflection\ReflectionFile($realpath))); - - if (!isset(self::$_fileCodeGenerators[$fileReflector->getFileName()])) { - self::$_fileCodeGenerators[$fileReflector->getFileName()] = $codeGenerator; - } - - return $codeGenerator; - } - - /** - * fromReflection() - * - * @param \Zend\Reflection\ReflectionFile $reflectionFile - * @return \Zend\CodeGenerator\PHP\PHPFile - */ - public static function fromReflection(Reflection\ReflectionFile $reflectionFile) - { - $file = new self(); - - $file->setSourceContent($reflectionFile->getContents()); - $file->setSourceDirty(false); - - $body = $reflectionFile->getContents(); - - // @todo this whole area needs to be reworked with respect to how body lines are processed - foreach ($reflectionFile->getClasses() as $class) { - $phpClass = PHPClass::fromReflection($class); - $phpClass->setPHPFile($file); - $file->setClass($phpClass); - $classStartLine = $class->getStartLine(true); - $classEndLine = $class->getEndLine(); - - $bodyLines = explode("\n", $body); - $bodyReturn = array(); - for ($lineNum = 1; $lineNum <= count($bodyLines); $lineNum++) { - if ($lineNum == $classStartLine) { - $bodyReturn[] = str_replace('?', $class->getName(), self::$_markerClass); //'/* Zend_CodeGenerator_Php_File-ClassMarker: {' . $class->getName() . '} */'; - $lineNum = $classEndLine; - } else { - $bodyReturn[] = $bodyLines[$lineNum - 1]; // adjust for index -> line conversion - } - } - $body = implode("\n", $bodyReturn); - unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine); - } - - $namespace = $reflectionFile->getNamespace(); - if ($namespace != '') { - $file->setNamespace($reflectionFile->getNamespace()); - } - - $uses = $reflectionFile->getUses(); - if ($uses) { - $file->setUses($uses); - } - - - if (($reflectionFile->getDocComment() != '')) { - $docblock = $reflectionFile->getDocblock(); - $file->setDocblock(PHPDocblock::fromReflection($docblock)); - - $bodyLines = explode("\n", $body); - $bodyReturn = array(); - for ($lineNum = 1; $lineNum <= count($bodyLines); $lineNum++) { - if ($lineNum == $docblock->getStartLine()) { - $bodyReturn[] = str_replace('?', $class->getName(), self::$_markerDocblock); //'/* Zend_CodeGenerator_Php_File-ClassMarker: {' . $class->getName() . '} */'; - $lineNum = $docblock->getEndLine(); - } else { - $bodyReturn[] = $bodyLines[$lineNum - 1]; // adjust for index -> line conversion - } - } - $body = implode("\n", $bodyReturn); - unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine); - } - - $file->setBody($body); - - return $file; - } - - /** - * setDocblock() Set the docblock - * - * @param \Zend\CodeGenerator\PHPDocblock|array|string $docblock - * @return \Zend\CodeGenerator\PHP\PHPFile - */ - public function setDocblock($docblock) - { - if (is_string($docblock)) { - $docblock = array('shortDescription' => $docblock); - } - - if (is_array($docblock)) { - $docblock = new PHPDocblock($docblock); - } elseif (!$docblock instanceof PHPDocblock) { - throw new Exception('setDocblock() is expecting either a string, array or an instance of Zend_CodeGenerator_Php_Docblock'); - } - - $this->_docblock = $docblock; - return $this; - } - - /** - * Get docblock - * - * @return \Zend\CodeGenerator\PHPDocblock - */ - public function getDocblock() - { - return $this->_docblock; - } - - /** - * setRequiredFiles - * - * @param array $requiredFiles - * @return \Zend\CodeGenerator\PHP\PHPFile - */ - public function setRequiredFiles($requiredFiles) - { - $this->_requiredFiles = $requiredFiles; - return $this; - } - - /** - * getRequiredFiles() - * - * @return array - */ - public function getRequiredFiles() - { - return $this->_requiredFiles; - } - - /** - * setClasses() - * - * @param array $classes - * @return \Zend\CodeGenerator\PHP\PHPFile - */ - public function setClasses(Array $classes) - { - foreach ($classes as $class) { - $this->setClass($class); - } - return $this; - } - - /** - * getNamespace() - * - * @return string - */ - public function getNamespace() - { - return $this->_namespace; - } - - /** - * setNamespace() - * - * @param $namespace - * @return Zend\CodeGenerator\PHP\PHPFile - */ - public function setNamespace($namespace) - { - $this->_namespace = $namespace; - return $this; - } - - /** - * getUses() - * - * Returns an array with the first element the use statement, second is the as part. - * If $withResolvedAs is set to true, there will be a third element that is the - * "resolved" as statement, as the second part is not required in use statements - * - * @param $withResolvedAs - * @return array - */ - public function getUses($withResolvedAs = false) - { - $uses = $this->_uses; - if ($withResolvedAs) { - for ($useIndex = 0; $useIndex < count($uses); $useIndex++) { - if ($uses[$useIndex][1] == '') { - if (($lastSeparator = strrpos($uses[$useIndex][0], '\\')) !== false) { - $uses[$useIndex][2] = substr($uses[$useIndex][0], $lastSeparator+1); - } else { - $uses[$useIndex][2] = $uses[$useIndex][0]; - } - } else { - $uses[$useIndex][2] = $uses[$useIndex][1]; - } - } - } - return $uses; - } - - /** - * setUses() - * - * @param $uses - * @return Zend\CodeGenerator\PHP\PHPFile - */ - public function setUses(Array $uses) - { - foreach ($uses as $use) { - $this->setUse($use[0], $use[1]); - } - return $this; - } - - /** - * setUse() - * - * @param $use - * @param $as - * @return Zend\CodeGenerator\PHP\PHPFile - */ - public function setUse($use, $as = null) - { - $this->_uses[] = array($use, $as); - return $this; - } - - /** - * getClass() - * - * @param string $name - * @return \Zend\CodeGenerator\PHP\PHPClass - */ - public function getClass($name = null) - { - if ($name == null) { - reset($this->_classes); - return current($this->_classes); - } - - return $this->_classes[$name]; - } - - /** - * setClass() - * - * @param \Zend\CodeGenerator\PHP\PHPClass|array $class - * @return \Zend\CodeGenerator\PHP\PHPFile - */ - public function setClass($class) - { - if (is_array($class)) { - $class = new PHPClass($class); - $className = $class->getName(); - } elseif ($class instanceof PHPClass) { - $className = $class->getName(); - } else { - throw new Exception('Expecting either an array or an instance of Zend_CodeGenerator_Php_Class'); - } - - // @todo check for dup here - - $this->_classes[$className] = $class; - return $this; - } - - /** - * setFilename() - * - * @param string $filename - * @return \Zend\CodeGenerator\PHP\PHPFile - */ - public function setFilename($filename) - { - $this->_filename = $filename; - return $this; - } - - /** - * getFilename() - * - * @return string - */ - public function getFilename() - { - return $this->_filename; - } - - /** - * getClasses() - * - * @return array Array of \Zend\CodeGenerator\PHP\PHPClass - */ - public function getClasses() - { - return $this->_classes; - } - - /** - * setBody() - * - * @param string $body - * @return \Zend\CodeGenerator\PHP\PHPFile - */ - public function setBody($body) - { - $this->_body = $body; - return $this; - } - - /** - * getBody() - * - * @return string - */ - public function getBody() - { - return $this->_body; - } - - /** - * isSourceDirty() - * - * @return bool - */ - public function isSourceDirty() - { - if (($docblock = $this->getDocblock()) && $docblock->isSourceDirty()) { - return true; - } - - foreach ($this->_classes as $class) { - if ($class->isSourceDirty()) { - return true; - } - } - - return parent::isSourceDirty(); - } - - /** - * generate() - * - * @return string - */ - public function generate() - { - if ($this->isSourceDirty() === false) { - return $this->_sourceContent; - } - - $output = ''; - - // start with the body (if there), or open tag - if (preg_match('#(?:\s*)<\?php#', $this->getBody()) == false) { - $output = 'getNamespace()) { - // @todo - } - - // if there are markers, put the body into the output - $body = $this->getBody(); - if (preg_match('#/\* Zend_CodeGenerator_Php_File-(.*?)Marker:#', $body)) { - $output .= $body; - $body = ''; - } - - // Add file docblock, if any - if (null !== ($docblock = $this->getDocblock())) { - $docblock->setIndentation(''); - $regex = preg_quote(self::$_markerDocblock, '#'); - if (preg_match('#'.$regex.'#', $output)) { - $output = preg_replace('#'.$regex.'#', $docblock->generate(), $output, 1); - } else { - $output .= $docblock->generate() . self::LINE_FEED; - } - } - - // newline - $output .= self::LINE_FEED; - - // process required files - // @todo marker replacement for required files - $requiredFiles = $this->getRequiredFiles(); - if (!empty($requiredFiles)) { - foreach ($requiredFiles as $requiredFile) { - $output .= 'require_once \'' . $requiredFile . '\';' . self::LINE_FEED; - } - - $output .= self::LINE_FEED; - } - - // process classes - $classes = $this->getClasses(); - if (!empty($classes)) { - foreach ($classes as $class) { - $regex = str_replace('?', $class->getName(), self::$_markerClass); - $regex = preg_quote($regex, '#'); - if (preg_match('#'.$regex.'#', $output)) { - $output = preg_replace('#'.$regex.'#', $class->generate(), $output, 1); - } else { - $output .= $class->generate() . self::LINE_FEED; - } - } - - } - - if (!empty($body)) { - - // add an extra space betwee clsses and - if (!empty($classes)) { - $output .= self::LINE_FEED; - } - - $output .= $body; - } - - return $output; - } - - public function write() - { - if ($this->_filename == '' || !is_writable(dirname($this->_filename))) { - throw new Exception('This code generator object is not writable.'); - } - file_put_contents($this->_filename, $this->generate()); - return $this; - } - -} diff --git a/library/Zend/CodeGenerator/PHP/PHPMember/AbstractMember.php b/library/Zend/CodeGenerator/PHP/PHPMember/AbstractMember.php deleted file mode 100644 index 5c2faf39876..00000000000 --- a/library/Zend/CodeGenerator/PHP/PHPMember/AbstractMember.php +++ /dev/null @@ -1,220 +0,0 @@ - $docblock); - } - - if (is_array($docblock)) { - $docblock = new PHP\PHPDocblock($docblock); - } elseif (!$docblock instanceof PHP\PHPDocblock) { - throw new PHP\Exception('setDocblock() is expecting either a string, array or an instance of Zend_CodeGenerator_Php_Docblock'); - } - - $this->_docblock = $docblock; - return $this; - } - - /** - * getDocblock() - * - * @return \Zend\CodeGenerator\PHPDocblock - */ - public function getDocblock() - { - return $this->_docblock; - } - - /** - * setAbstract() - * - * @param bool $isAbstract - * @return \Zend\CodeGenerator\PHP\PHPMember\AbstractMember - */ - public function setAbstract($isAbstract) - { - $this->_isAbstract = ($isAbstract) ? true : false; - return $this; - } - - /** - * isAbstract() - * - * @return bool - */ - public function isAbstract() - { - return $this->_isAbstract; - } - - /** - * setFinal() - * - * @param bool $isFinal - * @return \Zend\CodeGenerator\PHP\PHPMember\AbstractMember - */ - public function setFinal($isFinal) - { - $this->_isFinal = ($isFinal) ? true : false; - return $this; - } - - /** - * isFinal() - * - * @return bool - */ - public function isFinal() - { - return $this->_isFinal; - } - - /** - * setStatic() - * - * @param bool $isStatic - * @return \Zend\CodeGenerator\PHP\PHPMember\AbstractMember - */ - public function setStatic($isStatic) - { - $this->_isStatic = ($isStatic) ? true : false; - return $this; - } - - /** - * isStatic() - * - * @return bool - */ - public function isStatic() - { - return $this->_isStatic; - } - - /** - * setVisitibility() - * - * @param const $visibility - * @return \Zend\CodeGenerator\PHP\PHPMember\AbstractMember - */ - public function setVisibility($visibility) - { - $this->_visibility = $visibility; - return $this; - } - - /** - * getVisibility() - * - * @return const - */ - public function getVisibility() - { - return $this->_visibility; - } - - /** - * setName() - * - * @param string $name - * @return \Zend\CodeGenerator\PHP\PHPMember\AbstractMember - */ - public function setName($name) - { - $this->_name = $name; - return $this; - } - - /** - * getName() - * - * @return string - */ - public function getName() - { - return $this->_name; - } -} diff --git a/library/Zend/CodeGenerator/PHP/PHPMember/MemberContainer.php b/library/Zend/CodeGenerator/PHP/PHPMember/MemberContainer.php deleted file mode 100644 index c3419fa405f..00000000000 --- a/library/Zend/CodeGenerator/PHP/PHPMember/MemberContainer.php +++ /dev/null @@ -1,60 +0,0 @@ -_type = $type; - parent::__construct(array(), self::ARRAY_AS_PROPS); - } - -} \ No newline at end of file diff --git a/library/Zend/CodeGenerator/PHP/PHPMethod.php b/library/Zend/CodeGenerator/PHP/PHPMethod.php deleted file mode 100644 index 1098525525c..00000000000 --- a/library/Zend/CodeGenerator/PHP/PHPMethod.php +++ /dev/null @@ -1,227 +0,0 @@ -setSourceContent($reflectionMethod->getContents(false)); - $method->setSourceDirty(false); - - if ($reflectionMethod->getDocComment() != '') { - $method->setDocblock(PHPDocblock::fromReflection($reflectionMethod->getDocblock())); - } - - $method->setFinal($reflectionMethod->isFinal()); - - if ($reflectionMethod->isPrivate()) { - $method->setVisibility(self::VISIBILITY_PRIVATE); - } elseif ($reflectionMethod->isProtected()) { - $method->setVisibility(self::VISIBILITY_PROTECTED); - } else { - $method->setVisibility(self::VISIBILITY_PUBLIC); - } - - $method->setStatic($reflectionMethod->isStatic()); - - $method->setName($reflectionMethod->getName()); - - foreach ($reflectionMethod->getParameters() as $reflectionParameter) { - $method->setParameter(PHPParameter::fromReflection($reflectionParameter)); - } - - $method->setBody($reflectionMethod->getBody()); - - return $method; - } - - /** - * setFinal() - * - * @param bool $isFinal - */ - public function setFinal($isFinal) - { - $this->_isFinal = ($isFinal) ? true : false; - } - - /** - * setParameters() - * - * @param array $parameters - * @return \Zend\CodeGenerator\PHP\PHPMethod - */ - public function setParameters(Array $parameters) - { - foreach ($parameters as $parameter) { - $this->setParameter($parameter); - } - return $this; - } - - /** - * setParameter() - * - * @param \Zend\CodeGenerator\PHP\Parameter\Parameter|array $parameter - * @return \Zend\CodeGenerator\PHP\PHPMethod - */ - public function setParameter($parameter) - { - if (is_array($parameter)) { - $parameter = new PHPParameter($parameter); - $parameterName = $parameter->getName(); - } elseif ($parameter instanceof PHPParameter) { - $parameterName = $parameter->getName(); - } else { - throw new Exception('setParameter() expects either an array of method options or an instance of Zend_CodeGenerator_Php_Parameter'); - } - - $this->_parameters[$parameterName] = $parameter; - return $this; - } - - /** - * getParameters() - * - * @return array Array of \Zend\CodeGenerator\PHP\Parameter\Parameter - */ - public function getParameters() - { - return $this->_parameters; - } - - /** - * setBody() - * - * @param string $body - * @return \Zend\CodeGenerator\PHP\PHPMethod - */ - public function setBody($body) - { - $this->_body = $body; - return $this; - } - - /** - * getBody() - * - * @return string - */ - public function getBody() - { - return $this->_body; - } - - /** - * generate() - * - * @return string - */ - public function generate() - { - $output = ''; - - $indent = $this->getIndentation(); - - if (($docblock = $this->getDocblock()) !== null) { - $docblock->setIndentation($indent); - $output .= $docblock->generate(); - } - - $output .= $indent; - - if ($this->isAbstract()) { - $output .= 'abstract '; - } else { - $output .= (($this->isFinal()) ? 'final ' : ''); - } - - $output .= $this->getVisibility() - . (($this->isStatic()) ? ' static' : '') - . ' function ' . $this->getName() . '('; - - $parameters = $this->getParameters(); - if (!empty($parameters)) { - foreach ($parameters as $parameter) { - $parameterOuput[] = $parameter->generate(); - } - - $output .= implode(', ', $parameterOuput); - } - - $output .= ')' . self::LINE_FEED . $indent . '{' . self::LINE_FEED; - - if ($this->_body) { - $output .= ' ' - . str_replace(self::LINE_FEED, self::LINE_FEED . $indent . $indent, trim($this->_body)) - . self::LINE_FEED; - } - - $output .= $indent . '}' . self::LINE_FEED; - - return $output; - } - -} diff --git a/library/Zend/CodeGenerator/PHP/PHPParameter.php b/library/Zend/CodeGenerator/PHP/PHPParameter.php deleted file mode 100644 index e7a849dc991..00000000000 --- a/library/Zend/CodeGenerator/PHP/PHPParameter.php +++ /dev/null @@ -1,247 +0,0 @@ -setName($reflectionParameter->getName()); - - if($reflectionParameter->isArray()) { - $param->setType('array'); - } else { - $typeClass = $reflectionParameter->getClass(); - if($typeClass !== null) { - $param->setType($typeClass->getName()); - } - } - - $param->setPosition($reflectionParameter->getPosition()); - - if($reflectionParameter->isOptional()) { - $param->setDefaultValue($reflectionParameter->getDefaultValue()); - } - $param->setPassedByReference($reflectionParameter->isPassedByReference()); - - return $param; - } - - /** - * setType() - * - * @param string $type - * @return \Zend\CodeGenerator\PHP\PHPParameter\Parameter - */ - public function setType($type) - { - $this->_type = $type; - return $this; - } - - /** - * getType() - * - * @return string - */ - public function getType() - { - return $this->_type; - } - - /** - * setName() - * - * @param string $name - * @return \Zend\CodeGenerator\PHP\PHPParameter\Parameter - */ - public function setName($name) - { - $this->_name = $name; - return $this; - } - - /** - * getName() - * - * @return string - */ - public function getName() - { - return $this->_name; - } - - /** - * Set the default value of the parameter. - * - * Certain variables are difficult to expres - * - * @param null|bool|string|int|float|\Zend\CodeGenerator\PHP\PHPParameter\DefaultValue $defaultValue - * @return \Zend\CodeGenerator\PHP\PHPParameter\Parameter - */ - public function setDefaultValue($defaultValue) - { - if ($defaultValue === null) { - $this->_defaultValue = new PHPParameterDefaultValue(array('value' => null)); - } else if(is_array($defaultValue)) { - $defaultValue = str_replace(array("\r", "\n"), "", var_export($defaultValue, true)); - $this->_defaultValue = new PHPParameterDefaultValue(array('value' => $defaultValue)); - } else if(is_bool($defaultValue)) { - if($defaultValue == true) { - $this->_defaultValue = new PHPParameterDefaultValue(array('value' => "true")); - } else { - $this->_defaultValue = new PHPParameterDefaultValue(array('value' => "false")); - } - } else { - $this->_defaultValue = $defaultValue; - } - return $this; - } - - /** - * getDefaultValue() - * - * @return string - */ - public function getDefaultValue() - { - return $this->_defaultValue; - } - - /** - * setPosition() - * - * @param int $position - * @return \Zend\CodeGenerator\PHP\PHPParameter\Parameter - */ - public function setPosition($position) - { - $this->_position = $position; - return $this; - } - - /** - * getPosition() - * - * @return int - */ - public function getPosition() - { - return $this->_position; - } - - /** - * @return bool - */ - public function getPassedByReference() - { - return $this->_passedByReference; - } - - /** - * @param bool $passedByReference - * @return \Zend\CodeGenerator\PHP\PHPParameter\Parameter - */ - public function setPassedByReference($passedByReference) - { - $this->_passedByReference = $passedByReference; - return $this; - } - - /** - * generate() - * - * @return string - */ - public function generate() - { - $output = ''; - - if ($this->_type) { - $output .= $this->_type . ' '; - } - - if($this->_passedByReference === true) { - $output .= '&'; - } - - $output .= '$' . $this->_name; - - if ($this->_defaultValue !== null) { - $output .= ' = '; - if (is_string($this->_defaultValue)) { - $output .= '\'' . $this->_defaultValue . '\''; - } else if($this->_defaultValue instanceof \Zend\CodeGenerator\PHP\PHPParameterDefaultValue) { - $output .= (string)$this->_defaultValue; - } else { - $output .= $this->_defaultValue; - } - } - - return $output; - } - -} diff --git a/library/Zend/CodeGenerator/PHP/PHPParameterDefaultValue.php b/library/Zend/CodeGenerator/PHP/PHPParameterDefaultValue.php deleted file mode 100644 index 2fce6fb28ba..00000000000 --- a/library/Zend/CodeGenerator/PHP/PHPParameterDefaultValue.php +++ /dev/null @@ -1,52 +0,0 @@ -_indentation; -// $this->_indentation = ''; -// $output = parent::generate(); -// $output = str_replace(self::LINE_FEED, '', $output); -// $this->_indentation = $indent; -// return $output; -// } -} diff --git a/library/Zend/CodeGenerator/PHP/PHPProperty.php b/library/Zend/CodeGenerator/PHP/PHPProperty.php deleted file mode 100644 index 2dded9575da..00000000000 --- a/library/Zend/CodeGenerator/PHP/PHPProperty.php +++ /dev/null @@ -1,176 +0,0 @@ -setName($reflectionProperty->getName()); - - $allDefaultProperties = $reflectionProperty->getDeclaringClass()->getDefaultProperties(); - - $property->setDefaultValue($allDefaultProperties[$reflectionProperty->getName()]); - - if ($reflectionProperty->getDocComment() != '') { - $property->setDocblock(PHP\PHPDocblock::fromReflection($reflectionProperty->getDocComment())); - } - - if ($reflectionProperty->isStatic()) { - $property->setStatic(true); - } - - if ($reflectionProperty->isPrivate()) { - $property->setVisibility(self::VISIBILITY_PRIVATE); - } elseif ($reflectionProperty->isProtected()) { - $property->setVisibility(self::VISIBILITY_PROTECTED); - } else { - $property->setVisibility(self::VISIBILITY_PUBLIC); - } - - $property->setSourceDirty(false); - - return $property; - } - - /** - * setConst() - * - * @param bool $const - * @return \Zend\CodeGenerator\PHP\PHPProperty - */ - public function setConst($const) - { - $this->_isConst = $const; - return $this; - } - - /** - * isConst() - * - * @return bool - */ - public function isConst() - { - return ($this->_isConst) ? true : false; - } - - /** - * setDefaultValue() - * - * @param \Zend\CodeGenerator\PHP\PHPPropertyValue|string|array $defaultValue - * @return \Zend\CodeGenerator\PHP\PHPProperty - */ - public function setDefaultValue($defaultValue) - { - // if it looks like - if (is_array($defaultValue) - && array_key_exists('value', $defaultValue) - && array_key_exists('type', $defaultValue)) { - $defaultValue = new PHPPropertyValue($defaultValue); - } - - if (!($defaultValue instanceof PHPPropertyValue)) { - $defaultValue = new PHPPropertyValue(array('value' => $defaultValue)); - } - - $this->_defaultValue = $defaultValue; - return $this; - } - - /** - * getDefaultValue() - * - * @return \Zend\CodeGenerator\PHP\PHPPropertyValue - */ - public function getDefaultValue() - { - return $this->_defaultValue; - } - - /** - * generate() - * - * @return string - */ - public function generate() - { - $name = $this->getName(); - $defaultValue = $this->getDefaultValue(); - - $output = ''; - - if (($docblock = $this->getDocblock()) !== null) { - $docblock->setIndentation(' '); - $output .= $docblock->generate(); - } - - if ($this->isConst()) { - if ($defaultValue != null && !$defaultValue->isValidConstantType()) { - throw new Exception('The property ' . $this->_name . ' is said to be ' - . 'constant but does not have a valid constant value.'); - } - $output .= $this->_indentation . 'const ' . $name . ' = ' - . (($defaultValue !== null) ? $defaultValue->generate() : 'null;'); - } else { - $output .= $this->_indentation - . $this->getVisibility() - . (($this->isStatic()) ? ' static' : '') - . ' $' . $name . ' = ' - . (($defaultValue !== null) ? $defaultValue->generate() : 'null;'); - } - return $output; - } - -} diff --git a/library/Zend/CodeGenerator/PHP/PHPPropertyValue.php b/library/Zend/CodeGenerator/PHP/PHPPropertyValue.php deleted file mode 100644 index de2bc20e617..00000000000 --- a/library/Zend/CodeGenerator/PHP/PHPPropertyValue.php +++ /dev/null @@ -1,39 +0,0 @@ -getConstants() as $name => $value) { - if (substr($name, 0, 4) == 'TYPE') { - self::$_constants[$name] = $value; - } - } - unset($reflect); - } - } - - /** - * isValidConstantType() - * - * @return bool - */ - public function isValidConstantType() - { - if ($this->_type == self::TYPE_AUTO) { - $type = $this->_getAutoDeterminedType($this->_value); - } else { - $type = $this->_type; - } - - // valid types for constants - $scalarTypes = array( - self::TYPE_BOOLEAN, - self::TYPE_BOOL, - self::TYPE_NUMBER, - self::TYPE_INTEGER, - self::TYPE_INT, - self::TYPE_FLOAT, - self::TYPE_DOUBLE, - self::TYPE_STRING, - self::TYPE_CONSTANT, - self::TYPE_NULL - ); - - return in_array($type, $scalarTypes); - } - - /** - * setValue() - * - * @param mixed $value - * @return \Zend\CodeGenerator\PHP\PHPPropertyValue - */ - public function setValue($value) - { - $this->_value = $value; - return $this; - } - - /** - * getValue() - * - * @return mixed - */ - public function getValue() - { - return $this->_value; - } - - /** - * setType() - * - * @param string $type - * @return \Zend\CodeGenerator\PHP\PHPPropertyValue - */ - public function setType($type) - { - $this->_type = $type; - return $this; - } - - /** - * getType() - * - * @return string - */ - public function getType() - { - return $this->_type; - } - - /** - * setArrayDepth() - * - * @param int $arrayDepth - * @return \Zend\CodeGenerator\PHP\PHPPropertyValue - */ - public function setArrayDepth($arrayDepth) - { - $this->_arrayDepth = $arrayDepth; - return $this; - } - - /** - * getArrayDepth() - * - * @return int - */ - public function getArrayDepth() - { - return $this->_arrayDepth; - } - - /** - * _getValidatedType() - * - * @param string $type - * @return string - */ - protected function _getValidatedType($type) - { - if (($constName = array_search($type, self::$_constants)) !== false) { - return $type; - } - - return self::TYPE_AUTO; - } - - /** - * _getAutoDeterminedType() - * - * @param mixed $value - * @return string - */ - public function _getAutoDeterminedType($value) - { - switch (gettype($value)) { - case 'boolean': - return self::TYPE_BOOLEAN; - case 'integer': - return self::TYPE_INT; - case 'string': - return self::TYPE_STRING; - case 'double': - case 'float': - case 'integer': - return self::TYPE_NUMBER; - case 'array': - return self::TYPE_ARRAY; - case 'NULL': - return self::TYPE_NULL; - case 'object': - case 'resource': - case 'unknown type': - default: - return self::TYPE_OTHER; - } - } - - /** - * generate() - * - * @return string - */ - public function generate() - { - $type = $this->_type; - - if ($type != self::TYPE_AUTO) { - $type = $this->_getValidatedType($type); - } - - $value = $this->_value; - - if ($type == self::TYPE_AUTO) { - $type = $this->_getAutoDeterminedType($value); - - if ($type == self::TYPE_ARRAY) { - $rii = new \RecursiveIteratorIterator( - $it = new \RecursiveArrayIterator($value), - \RecursiveIteratorIterator::SELF_FIRST - ); - foreach ($rii as $curKey => $curValue) { - if (!$curValue instanceof self) { - $curValue = new self(array('value' => $curValue)); - $rii->getSubIterator()->offsetSet($curKey, $curValue); - } - $curValue->setArrayDepth($rii->getDepth()); - } - $value = $rii->getSubIterator()->getArrayCopy(); - } - - } - - $output = ''; - - switch ($type) { - case self::TYPE_BOOLEAN: - case self::TYPE_BOOL: - $output .= ( $value ? 'true' : 'false' ); - break; - case self::TYPE_STRING: - $output .= "'" . addcslashes($value, "'") . "'"; - break; - case self::TYPE_NULL: - $output .= 'null'; - break; - case self::TYPE_NUMBER: - case self::TYPE_INTEGER: - case self::TYPE_INT: - case self::TYPE_FLOAT: - case self::TYPE_DOUBLE: - case self::TYPE_CONSTANT: - $output .= $value; - break; - case self::TYPE_ARRAY: - $output .= 'array('; - $curArrayMultiblock = false; - if (count($value) > 1) { - $curArrayMultiblock = true; - if ($this->_outputMode == self::OUTPUT_MULTIPLE_LINE) { - $output .= self::LINE_FEED . str_repeat($this->_indentation, $this->_arrayDepth+1); - } - } - $outputParts = array(); - $noKeyIndex = 0; - foreach ($value as $n => $v) { - $v->setArrayDepth($this->_arrayDepth + 1); - $partV = $v->generate(); - $partV = substr($partV, 0, strlen($partV)-1); - if ($n === $noKeyIndex) { - $outputParts[] = $partV; - $noKeyIndex++; - } else { - $outputParts[] = (is_int($n) ? $n : "'" . addcslashes($n, "'") . "'") . ' => ' . $partV; - } - } - $padding = ($this->_outputMode == self::OUTPUT_MULTIPLE_LINE) - ? self::LINE_FEED . str_repeat($this->_indentation, $this->_arrayDepth+1) - : ' '; - $output .= implode(',' . $padding, $outputParts); - if ($curArrayMultiblock == true && $this->_outputMode == self::OUTPUT_MULTIPLE_LINE) { - $output .= self::LINE_FEED . str_repeat($this->_indentation, $this->_arrayDepth+1); - } - $output .= ')'; - break; - case self::TYPE_OTHER: - default: - throw new Exception( - "Type '".get_class($value)."' is unknown or cannot be used as property default value." - ); - } - - $output .= ';'; - - return $output; - } -} diff --git a/library/Zend/Controller/Action.php b/library/Zend/Controller/Action.php index 8fdd3a73a63..a47a9297b91 100644 --- a/library/Zend/Controller/Action.php +++ b/library/Zend/Controller/Action.php @@ -296,6 +296,7 @@ public function getViewScript($action = null, $noController = null) $dispatcher = Front::getInstance()->getDispatcher(); $wordDelimiters = $dispatcher->getWordDelimiter(); $pathDelimiters = $dispatcher->getPathDelimiter(); + $pathDelimiters = array($pathDelimiters, '_'); $this->_delimiters = array_unique(array_merge($wordDelimiters, (array) $pathDelimiters)); } diff --git a/library/Zend/Controller/Action/Helper/FlashMessenger.php b/library/Zend/Controller/Action/Helper/FlashMessenger.php index 4f0302b5884..123bfabe748 100644 --- a/library/Zend/Controller/Action/Helper/FlashMessenger.php +++ b/library/Zend/Controller/Action/Helper/FlashMessenger.php @@ -23,7 +23,8 @@ * @namespace */ namespace Zend\Controller\Action\Helper; -use Zend\Session; +use Zend\Session, + Zend\Stdlib\SplQueue; /** * Flash Messenger - implement session-based messages @@ -76,8 +77,15 @@ public function __construct() { if (!self::$_session instanceof Session\Container) { self::$_session = new Session\Container($this->getName()); + + // Should not modify the iterator while iterating; aggregate + // namespaces so they may be deleted after retrieving messages. + $namespaces = array(); foreach (self::$_session as $namespace => $messages) { self::$_messages[$namespace] = $messages; + $namespaces[] = $namespace; + } + foreach ($namespaces as $namespace) { unset(self::$_session->{$namespace}); } } @@ -132,11 +140,13 @@ public function addMessage($message) self::$_session->setExpirationHops(1, null, true); } - if (!is_array(self::$_session->{$this->_namespace})) { - self::$_session->{$this->_namespace} = array(); + if (!isset(self::$_session->{$this->_namespace}) + || !(self::$_session->{$this->_namespace} instanceof SplQueue) + ) { + self::$_session->{$this->_namespace} = new SplQueue(); } - self::$_session->{$this->_namespace}[] = $message; + self::$_session->{$this->_namespace}->push($message); return $this; } @@ -159,7 +169,7 @@ public function hasMessages() public function getMessages() { if ($this->hasMessages()) { - return self::$_messages[$this->_namespace]; + return self::$_messages[$this->_namespace]->toArray(); } return array(); @@ -200,7 +210,7 @@ public function hasCurrentMessages() public function getCurrentMessages() { if ($this->hasCurrentMessages()) { - return self::$_session->{$this->_namespace}; + return self::$_session->{$this->_namespace}->toArray(); } return array(); diff --git a/library/Zend/Controller/Action/Helper/Redirector.php b/library/Zend/Controller/Action/Helper/Redirector.php index e2b51918e26..8d2d0e01780 100644 --- a/library/Zend/Controller/Action/Helper/Redirector.php +++ b/library/Zend/Controller/Action/Helper/Redirector.php @@ -298,7 +298,7 @@ public function setGotoSimple($action, $controller = null, $module = null, array $params['action'] = $action; $router = $this->getFrontController()->getRouter(); - $url = $router->assemble($params, 'default', true); + $url = $router->assemble($params, 'application', true); $this->_redirect($url); } @@ -476,13 +476,6 @@ public function gotoUrlAndExit($url, array $options = array()) */ public function redirectAndExit() { - if ($this->getCloseSessionOnExit()) { - // Close session, if started - if (isset($_SESSION) && !empty($_SESSION)) { - session_write_close(); - } - } - $this->getResponse()->sendHeaders(); exit(); } diff --git a/library/Zend/Controller/Action/Helper/ViewRenderer.php b/library/Zend/Controller/Action/Helper/ViewRenderer.php index 443e9e2f4d2..123ee18e376 100644 --- a/library/Zend/Controller/Action/Helper/ViewRenderer.php +++ b/library/Zend/Controller/Action/Helper/ViewRenderer.php @@ -322,7 +322,7 @@ protected function _generateDefaultPrefix() } $module = $this->getModule(); - if ('default' == $module) { + if ('application' == $module) { return $default; } diff --git a/library/Zend/Controller/Dispatcher/AbstractDispatcher.php b/library/Zend/Controller/Dispatcher/AbstractDispatcher.php index e44de7a9fe4..65798972bd5 100644 --- a/library/Zend/Controller/Dispatcher/AbstractDispatcher.php +++ b/library/Zend/Controller/Dispatcher/AbstractDispatcher.php @@ -63,7 +63,7 @@ abstract class AbstractDispatcher implements Dispatcher * Default module * @var string */ - protected $_defaultModule = 'default'; + protected $_defaultModule = 'application'; /** * Front Controller instance @@ -82,7 +82,7 @@ abstract class AbstractDispatcher implements Dispatcher * Path delimiter character * @var string */ - protected $_pathDelimiter = '_'; + protected $_pathDelimiter = '\\'; /** * Response object to pass to action controllers, if any @@ -254,7 +254,7 @@ protected function _formatName($unformatted, $isAction = false) $segments[$key] = str_replace(' ', '', ucwords($segment)); } - return implode('_', $segments); + return implode('\\', $segments); } /** diff --git a/library/Zend/Controller/Dispatcher/Standard.php b/library/Zend/Controller/Dispatcher/Standard.php index fe4aa8a6658..92904673fe1 100644 --- a/library/Zend/Controller/Dispatcher/Standard.php +++ b/library/Zend/Controller/Dispatcher/Standard.php @@ -176,7 +176,7 @@ public function formatModuleName($unformatted) */ public function formatClassName($moduleName, $className) { - return $this->formatModuleName($moduleName) . '_' . $className; + return $this->formatModuleName($moduleName) . '\\' . $className; } /** diff --git a/library/Zend/Controller/Router/Rewrite.php b/library/Zend/Controller/Router/Rewrite.php index 3f086a6245c..94696d2919c 100644 --- a/library/Zend/Controller/Router/Rewrite.php +++ b/library/Zend/Controller/Router/Rewrite.php @@ -90,14 +90,14 @@ class Rewrite extends AbstractRouter */ public function addDefaultRoutes() { - if (!$this->hasRoute('default')) { + if (!$this->hasRoute('application')) { $dispatcher = $this->getFrontController()->getDispatcher(); $request = $this->getFrontController()->getRequest(); require_once 'Zend/Controller/Router/Route/Module.php'; $compat = new Route\Module(array(), $dispatcher, $request); - $this->_routes = array_merge(array('default' => $compat), $this->_routes); + $this->_routes = array_merge(array('application' => $compat), $this->_routes); } return $this; @@ -216,7 +216,7 @@ protected function _getRouteFromConfig(Config\Config $info) throw new \InvalidArgumentException('Class name ' . $class . ' does not exist.'); } - $route = call_user_func(array($class, 'getInstance'), $info); + $route = $class::getInstance($info); if (isset($info->abstract) && $info->abstract && method_exists($route, 'isAbstract')) { $route->isAbstract(true); @@ -455,7 +455,7 @@ public function assemble($userParams, $name = null, $reset = false, $encode = tr try { $name = $this->getCurrentRouteName(); } catch (Exception $e) { - $name = 'default'; + $name = 'application'; } } diff --git a/library/Zend/Db/Table/AbstractRow.php b/library/Zend/Db/Table/AbstractRow.php index 53920ec3108..3b9146d13ac 100644 --- a/library/Zend/Db/Table/AbstractRow.php +++ b/library/Zend/Db/Table/AbstractRow.php @@ -833,7 +833,7 @@ protected function _postDelete() */ protected function _prepareReference(AbstractTable $dependentTable, AbstractTable $parentTable, $ruleKey) { - $parentTableName = (get_class($parentTable) === 'Zend_Db_Table') ? $parentTable->getDefinitionConfigName() : get_class($parentTable); + $parentTableName = (get_class($parentTable) === 'Zend\Db\Table') ? $parentTable->getDefinitionConfigName() : get_class($parentTable); $map = $dependentTable->getReference($parentTableName, $ruleKey); if (!isset($map[AbstractTable::REF_COLUMNS])) { diff --git a/library/Zend/Feed/Reader/Entry/RSS.php b/library/Zend/Feed/Reader/Entry/RSS.php deleted file mode 100644 index 16c4baebcc5..00000000000 --- a/library/Zend/Feed/Reader/Entry/RSS.php +++ /dev/null @@ -1,632 +0,0 @@ -_xpathQueryRss = '//item[' . ($this->_entryKey+1) . ']'; - $this->_xpathQueryRdf = '//rss:item[' . ($this->_entryKey+1) . ']'; - - $pluginLoader = Reader\Reader::getPluginLoader(); - - $dublinCoreClass = $pluginLoader->getClassName('DublinCore\Entry'); - $this->_extensions['DublinCore\Entry'] = new $dublinCoreClass($entry, $entryKey, $type); - - $contentClass = $pluginLoader->getClassName('Content\Entry'); - $this->_extensions['Content\Entry'] = new $contentClass($entry, $entryKey, $type); - - $atomClass = $pluginLoader->getClassName('Atom\Entry'); - $this->_extensions['Atom\Entry'] = new $atomClass($entry, $entryKey, $type); - - $wfwClass = $pluginLoader->getClassName('WellFormedWeb\Entry'); - $this->_extensions['WellFormedWeb\Entry'] = new $wfwClass($entry, $entryKey, $type); - - $slashClass = $pluginLoader->getClassName('Slash\Entry'); - $this->_extensions['Slash\Entry'] = new $slashClass($entry, $entryKey, $type); - - $threadClass = $pluginLoader->getClassName('Thread\Entry'); - $this->_extensions['Thread\Entry'] = new $threadClass($entry, $entryKey, $type); - } - - /** - * Get an author entry - * - * @param DOMElement $element - * @return string - */ - public function getAuthor($index = 0) - { - $authors = $this->getAuthors(); - - if (isset($authors[$index])) { - return $authors[$index]; - } - - return null; - } - - /** - * Get an array with feed authors - * - * @return array - */ - public function getAuthors() - { - if (array_key_exists('authors', $this->_data)) { - return $this->_data['authors']; - } - - $authors = array(); - $authors_dc = $this->getExtension('DublinCore')->getAuthors(); - if (!empty($authors_dc)) { - foreach ($authors_dc as $author) { - $authors[] = array( - 'name' => $author['name'] - ); - } - } - - if ($this->getType() !== Reader\Reader::TYPE_RSS_10 - && $this->getType() !== Reader\Reader::TYPE_RSS_090) { - $list = $this->_xpath->query($this->_xpathQueryRss . '//author'); - } else { - $list = $this->_xpath->query($this->_xpathQueryRdf . '//rss:author'); - } - if ($list->length) { - foreach ($list as $author) { - $string = trim($author->nodeValue); - $email = null; - $name = null; - $data = array(); - // Pretty rough parsing - but it's a catchall - if (preg_match("/^.*@[^ ]*/", $string, $matches)) { - $data['email'] = trim($matches[0]); - if (preg_match("/\((.*)\)$/", $string, $matches)) { - $data['name'] = $matches[1]; - } - $authors[] = $data; - } - } - } - - if (count($authors) == 0) { - $authors = $this->getExtension('Atom')->getAuthors(); - } else { - $authors = new Reader\Collection\Author( - Reader\Reader::arrayUnique($authors) - ); - } - - if (count($authors) == 0) { - $authors = null; - } - - $this->_data['authors'] = $authors; - - return $this->_data['authors']; - } - - /** - * Get the entry content - * - * @return string - */ - public function getContent() - { - if (array_key_exists('content', $this->_data)) { - return $this->_data['content']; - } - - $content = $this->getExtension('Content')->getContent(); - - if (!$content) { - $content = $this->getDescription(); - } - - if (empty($content)) { - $content = $this->getExtension('Atom')->getContent(); - } - - $this->_data['content'] = $content; - - return $this->_data['content']; - } - - /** - * Get the entry's date of creation - * - * @return string - */ - public function getDateCreated() - { - return $this->getDateModified(); - } - - /** - * Get the entry's date of modification - * - * @return string - */ - public function getDateModified() - { - if (array_key_exists('datemodified', $this->_data)) { - return $this->_data['datemodified']; - } - - $dateModified = null; - $date = null; - - if ($this->getType() !== Reader\Reader::TYPE_RSS_10 - && $this->getType() !== Reader\Reader::TYPE_RSS_090 - ) { - $dateModified = $this->_xpath->evaluate('string('.$this->_xpathQueryRss.'/pubDate)'); - if ($dateModified) { - $dateModifiedParsed = strtotime($dateModified); - if ($dateModifiedParsed) { - $date = new Date\Date($dateModifiedParsed); - } else { - $dateStandards = array( - Date\Date::RSS, Date\Date::RFC_822, - Date\Date::RFC_2822, Date\Date::DATES, - ); - $date = new Date\Date; - foreach ($dateStandards as $standard) { - try { - $date->set($dateModified, $standard); - break; - } catch (Date\Exception $e) { - if ($standard == Date\Date::DATES) { - throw new \Zend\Feed\Exception( - 'Could not load date due to unrecognised' - .' format (should follow RFC 822 or 2822):' - . $e->getMessage(), - 0, $e - ); - } - } - } - } - } - } - - if (!$date) { - $date = $this->getExtension('DublinCore')->getDate(); - } - - if (!$date) { - $date = $this->getExtension('Atom')->getDateModified(); - } - - if (!$date) { - $date = null; - } - - $this->_data['datemodified'] = $date; - - return $this->_data['datemodified']; - } - - /** - * Get the entry description - * - * @return string - */ - public function getDescription() - { - if (array_key_exists('description', $this->_data)) { - return $this->_data['description']; - } - - $description = null; - - if ($this->getType() !== Reader\Reader::TYPE_RSS_10 - && $this->getType() !== Reader\Reader::TYPE_RSS_090 - ) { - $description = $this->_xpath->evaluate('string('.$this->_xpathQueryRss.'/description)'); - } else { - $description = $this->_xpath->evaluate('string('.$this->_xpathQueryRdf.'/rss:description)'); - } - - if (!$description) { - $description = $this->getExtension('DublinCore')->getDescription(); - } - - if (empty($description)) { - $description = $this->getExtension('Atom')->getDescription(); - } - - if (!$description) { - $description = null; - } - - $this->_data['description'] = $description; - - return $this->_data['description']; - } - - /** - * Get the entry enclosure - * @return string - */ - public function getEnclosure() - { - if (array_key_exists('enclosure', $this->_data)) { - return $this->_data['enclosure']; - } - - $enclosure = null; - - if ($this->getType() == Reader\Reader::TYPE_RSS_20) { - $nodeList = $this->_xpath->query($this->_xpathQueryRss . '/enclosure'); - - if ($nodeList->length > 0) { - $enclosure = new \stdClass(); - $enclosure->url = $nodeList->item(0)->getAttribute('url'); - $enclosure->length = $nodeList->item(0)->getAttribute('length'); - $enclosure->type = $nodeList->item(0)->getAttribute('type'); - } - } - - if (!$enclosure) { - $enclosure = $this->getExtension('Atom')->getEnclosure(); - } - - $this->_data['enclosure'] = $enclosure; - - return $this->_data['enclosure']; - } - - /** - * Get the entry ID - * - * @return string - */ - public function getId() - { - if (array_key_exists('id', $this->_data)) { - return $this->_data['id']; - } - - $id = null; - - if ($this->getType() !== Reader\Reader::TYPE_RSS_10 - && $this->getType() !== Reader\Reader::TYPE_RSS_090 - ) { - $id = $this->_xpath->evaluate('string('.$this->_xpathQueryRss.'/guid)'); - } - - if (!$id) { - $id = $this->getExtension('DublinCore')->getId(); - } - - if (empty($id)) { - $id = $this->getExtension('Atom')->getId(); - } - - if (!$id) { - if ($this->getPermalink()) { - $id = $this->getPermalink(); - } elseif ($this->getTitle()) { - $id = $this->getTitle(); - } else { - $id = null; - } - } - - $this->_data['id'] = $id; - - return $this->_data['id']; - } - - /** - * Get a specific link - * - * @param int $index - * @return string - */ - public function getLink($index = 0) - { - if (!array_key_exists('links', $this->_data)) { - $this->getLinks(); - } - - if (isset($this->_data['links'][$index])) { - return $this->_data['links'][$index]; - } - - return null; - } - - /** - * Get all links - * - * @return array - */ - public function getLinks() - { - if (array_key_exists('links', $this->_data)) { - return $this->_data['links']; - } - - $links = array(); - - if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && - $this->getType() !== Reader\Reader::TYPE_RSS_090) { - $list = $this->_xpath->query($this->_xpathQueryRss.'//link'); - } else { - $list = $this->_xpath->query($this->_xpathQueryRdf.'//rss:link'); - } - - if (!$list->length) { - $links = $this->getExtension('Atom')->getLinks(); - } else { - foreach ($list as $link) { - $links[] = $link->nodeValue; - } - } - - $this->_data['links'] = $links; - - return $this->_data['links']; - } - - /** - * Get all categories - * - * @return \Zend\Feed\Reader\Collection\Category - */ - public function getCategories() - { - if (array_key_exists('categories', $this->_data)) { - return $this->_data['categories']; - } - - if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && - $this->getType() !== Reader\Reader::TYPE_RSS_090) { - $list = $this->_xpath->query($this->_xpathQueryRss.'//category'); - } else { - $list = $this->_xpath->query($this->_xpathQueryRdf.'//rss:category'); - } - - if ($list->length) { - $categoryCollection = new Reader\Collection\Category; - foreach ($list as $category) { - $categoryCollection[] = array( - 'term' => $category->nodeValue, - 'scheme' => $category->getAttribute('domain'), - 'label' => $category->nodeValue, - ); - } - } else { - $categoryCollection = $this->getExtension('DublinCore')->getCategories(); - } - - if (count($categoryCollection) == 0) { - $categoryCollection = $this->getExtension('Atom')->getCategories(); - } - - $this->_data['categories'] = $categoryCollection; - - return $this->_data['categories']; - } - - /** - * Get a permalink to the entry - * - * @return string - */ - public function getPermalink() - { - return $this->getLink(0); - } - - /** - * Get the entry title - * - * @return string - */ - public function getTitle() - { - if (array_key_exists('title', $this->_data)) { - return $this->_data['title']; - } - - $title = null; - - if ($this->getType() !== Reader\Reader::TYPE_RSS_10 - && $this->getType() !== Reader\Reader::TYPE_RSS_090 - ) { - $title = $this->_xpath->evaluate('string('.$this->_xpathQueryRss.'/title)'); - } else { - $title = $this->_xpath->evaluate('string('.$this->_xpathQueryRdf.'/rss:title)'); - } - - if (!$title) { - $title = $this->getExtension('DublinCore')->getTitle(); - } - - if (!$title) { - $title = $this->getExtension('Atom')->getTitle(); - } - - if (!$title) { - $title = null; - } - - $this->_data['title'] = $title; - - return $this->_data['title']; - } - - /** - * Get the number of comments/replies for current entry - * - * @return string|null - */ - public function getCommentCount() - { - if (array_key_exists('commentcount', $this->_data)) { - return $this->_data['commentcount']; - } - - $commentcount = $this->getExtension('Slash')->getCommentCount(); - - if (!$commentcount) { - $commentcount = $this->getExtension('Thread')->getCommentCount(); - } - - if (!$commentcount) { - $commentcount = $this->getExtension('Atom')->getCommentCount(); - } - - if (!$commentcount) { - $commentcount = null; - } - - $this->_data['commentcount'] = $commentcount; - - return $this->_data['commentcount']; - } - - /** - * Returns a URI pointing to the HTML page where comments can be made on this entry - * - * @return string - */ - public function getCommentLink() - { - if (array_key_exists('commentlink', $this->_data)) { - return $this->_data['commentlink']; - } - - $commentlink = null; - - if ($this->getType() !== Reader\Reader::TYPE_RSS_10 - && $this->getType() !== Reader\Reader::TYPE_RSS_090 - ) { - $commentlink = $this->_xpath->evaluate('string('.$this->_xpathQueryRss.'/comments)'); - } - - if (!$commentlink) { - $commentlink = $this->getExtension('Atom')->getCommentLink(); - } - - if (!$commentlink) { - $commentlink = null; - } - - $this->_data['commentlink'] = $commentlink; - - return $this->_data['commentlink']; - } - - /** - * Returns a URI pointing to a feed of all comments for this entry - * - * @return string - */ - public function getCommentFeedLink() - { - if (array_key_exists('commentfeedlink', $this->_data)) { - return $this->_data['commentfeedlink']; - } - - $commentfeedlink = $this->getExtension('WellFormedWeb')->getCommentFeedLink(); - - if (!$commentfeedlink) { - $commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink('rss'); - } - - if (!$commentfeedlink) { - $commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink('rdf'); - } - - if (!$commentfeedlink) { - $commentfeedlink = null; - } - - $this->_data['commentfeedlink'] = $commentfeedlink; - - return $this->_data['commentfeedlink']; - } - - /** - * Set the XPath query (incl. on all Extensions) - * - * @param DOMXPath $xpath - */ - public function setXpath(\DOMXPath $xpath) - { - parent::setXpath($xpath); - foreach ($this->_extensions as $extension) { - $extension->setXpath($this->_xpath); - } - } -} diff --git a/library/Zend/Feed/Writer/AbstractFeed.php b/library/Zend/Feed/Writer/AbstractFeed.php index ae4ee743408..c6bbabefa72 100644 --- a/library/Zend/Feed/Writer/AbstractFeed.php +++ b/library/Zend/Feed/Writer/AbstractFeed.php @@ -24,6 +24,7 @@ namespace Zend\Feed\Writer; use Zend\Uri; use Zend\Date; +use Zend\Validator; /** * @uses \Zend\Date\Date @@ -31,8 +32,9 @@ * @uses \Zend\Feed\Writer\Writer * @uses \Zend\Feed\Writer\Entry * @uses \Zend\Feed\Writer\Renderer\Feed\Atom\Atom -* @uses \Zend\Feed\Writer\Renderer\Feed\RSS -* @uses \Zend\Uri\Uri +* @uses \Zend\Feed\Writer\Renderer\Feed\Rss +* @uses \Zend\Uri\Url +* @uses \Zend\Validator\EmailAddress * @category Zend * @package Zend_Feed_Writer * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) @@ -266,11 +268,44 @@ public function setGenerator($name, $version = null, $uri = null) public function setId($id) { if ((empty($id) || !is_string($id) || !Uri\Url::validate($id)) && - !preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", $id)) { + !preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", $id) + && !$this->_validateTagUri($id)) { throw new Exception('Invalid parameter: parameter must be a non-empty string and valid URI/IRI'); } $this->_data['id'] = $id; } + + /** + * Validate a URI using the tag scheme (RFC 4151) + * + * @param string $id + * @return bool + */ + protected function _validateTagUri($id) + { + if (preg_match('/^tag:(?.*),(?\d{4}-?\d{0,2}-?\d{0,2}):(?.*)(.*:)*$/', $id, $matches)) { + $dvalid = false; + $nvalid = false; + $date = $matches['date']; + $d6 = strtotime($date); + if ((strlen($date) == 4) && $date <= date('Y')) { + $dvalid = true; + } elseif ((strlen($date) == 7) && ($d6 < strtotime("now"))) { + $dvalid = true; + } elseif ((strlen($date) == 10) && ($d6 < strtotime("now"))) { + $dvalid = true; + } + $validator = new Validator\EmailAddress; + if ($validator->isValid($matches['name'])) { + $nvalid = true; + } else { + $nvalid = $validator->isValid('info@' . $matches['name']); + } + return $dvalid && $nvalid; + + } + return false; + } /** * Set a feed image (URI at minimum). Parameter is a single array with the diff --git a/library/Zend/Feed/Writer/Feed.php b/library/Zend/Feed/Writer/Feed.php index b6203fc90cd..675a6023510 100644 --- a/library/Zend/Feed/Writer/Feed.php +++ b/library/Zend/Feed/Writer/Feed.php @@ -36,7 +36,7 @@ * @uses \Zend\Feed\Writer\Feed\FeedAbstract * @uses \Zend\Feed\Writer\Renderer\Feed\Atom\Atom * @uses \Zend\Feed\Writer\Renderer\Feed\RSS -* @uses \Zend\Uri\Uri +* @uses \Zend\Uri\Url * @category Zend * @package Zend_Feed_Writer * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) diff --git a/library/Zend/Feed/Writer/Renderer/Entry/Atom.php b/library/Zend/Feed/Writer/Renderer/Entry/Atom.php index 12ed5cb8ab5..16ceea43d0c 100644 --- a/library/Zend/Feed/Writer/Renderer/Entry/Atom.php +++ b/library/Zend/Feed/Writer/Renderer/Entry/Atom.php @@ -26,6 +26,7 @@ use Zend\Feed\Writer; use Zend\Date; use Zend\URI; +use Zend\Validator; /** * @uses DOMDocument @@ -35,7 +36,8 @@ * @uses \Zend\Feed\Writer\Renderer\Feed\Atom\Source * @uses \Zend\Feed\Writer\Renderer\RendererAbstract * @uses \Zend\Feed\Writer\Renderer\RendererInterface -* @uses \Zend\Uri\Uri +* @uses \Zend\Uri\Url +* @uses \Zend\Validator * @uses tidy * @category Zend * @package Zend_Feed_Writer @@ -291,7 +293,9 @@ protected function _setId(\DOMDocument $dom, \DOMElement $root) $this->getDataContainer()->getLink()); } if (!URI\URL::validate($this->getDataContainer()->getId()) && - !preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", $this->getDataContainer()->getId())) { + !preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", + $this->getDataContainer()->getId() + ) && !$this->_validateTagUri($this->getDataContainer()->getId())) { throw new Exception('Atom 1.0 IDs must be a valid URI/IRI'); } $id = $dom->createElement('id'); @@ -300,6 +304,38 @@ protected function _setId(\DOMDocument $dom, \DOMElement $root) $id->appendChild($text); } + /** + * Validate a URI using the tag scheme (RFC 4151) + * + * @param string $id + * @return bool + */ + protected function _validateTagUri($id) + { + if (preg_match('/^tag:(?.*),(?\d{4}-?\d{0,2}-?\d{0,2}):(?.*)(.*:)*$/', $id, $matches)) { + $dvalid = false; + $nvalid = false; + $date = $matches['date']; + $d6 = strtotime($date); + if ((strlen($date) == 4) && $date <= date('Y')) { + $dvalid = true; + } elseif ((strlen($date) == 7) && ($d6 < strtotime("now"))) { + $dvalid = true; + } elseif ((strlen($date) == 10) && ($d6 < strtotime("now"))) { + $dvalid = true; + } + $validator = new Validator\EmailAddress; + if ($validator->isValid($matches['name'])) { + $nvalid = true; + } else { + $nvalid = $validator->isValid('info@' . $matches['name']); + } + return $dvalid && $nvalid; + + } + return false; + } + /** * Set entry content * diff --git a/library/Zend/Feed/Writer/Renderer/Entry/RSS.php b/library/Zend/Feed/Writer/Renderer/Entry/RSS.php deleted file mode 100644 index 127821f38ce..00000000000 --- a/library/Zend/Feed/Writer/Renderer/Entry/RSS.php +++ /dev/null @@ -1,347 +0,0 @@ -_dom = new \DOMDocument('1.0', $this->_container->getEncoding()); - $this->_dom->formatOutput = true; - $this->_dom->substituteEntities = false; - $entry = $this->_dom->createElement('item'); - $this->_dom->appendChild($entry); - - $this->_setTitle($this->_dom, $entry); - $this->_setDescription($this->_dom, $entry); - $this->_setDateCreated($this->_dom, $entry); - $this->_setDateModified($this->_dom, $entry); - $this->_setLink($this->_dom, $entry); - $this->_setId($this->_dom, $entry); - $this->_setAuthors($this->_dom, $entry); - $this->_setEnclosure($this->_dom, $entry); - $this->_setCommentLink($this->_dom, $entry); - $this->_setCategories($this->_dom, $entry); - foreach ($this->_extensions as $ext) { - $ext->setType($this->getType()); - $ext->setRootElement($this->getRootElement()); - $ext->setDomDocument($this->getDomDocument(), $entry); - $ext->render(); - } - - return $this; - } - - /** - * Set entry title - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setTitle(\DOMDocument $dom, \DOMElement $root) - { - if(!$this->getDataContainer()->getDescription() - && !$this->getDataContainer()->getTitle()) { - $message = 'RSS 2.0 entry elements SHOULD contain exactly one' - . ' title element but a title has not been set. In addition, there' - . ' is no description as required in the absence of a title.'; - $exception = new Feed\Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $title = $dom->createElement('title'); - $root->appendChild($title); - $text = $dom->createTextNode($this->getDataContainer()->getTitle()); - $title->appendChild($text); - } - - /** - * Set entry description - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDescription(\DOMDocument $dom, \DOMElement $root) - { - if(!$this->getDataContainer()->getDescription() - && !$this->getDataContainer()->getTitle()) { - $message = 'RSS 2.0 entry elements SHOULD contain exactly one' - . ' description element but a description has not been set. In' - . ' addition, there is no title element as required in the absence' - . ' of a description.'; - $exception = new Feed\Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - if (!$this->getDataContainer()->getDescription()) { - return; - } - $subtitle = $dom->createElement('description'); - $root->appendChild($subtitle); - $text = $dom->createCDATASection($this->getDataContainer()->getDescription()); - $subtitle->appendChild($text); - } - - /** - * Set date entry was last modified - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDateModified(\DOMDocument $dom, \DOMElement $root) - { - if(!$this->getDataContainer()->getDateModified()) { - return; - } - - $updated = $dom->createElement('pubDate'); - $root->appendChild($updated); - $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->get(\Zend\Date\Date::RSS) - ); - $updated->appendChild($text); - } - - /** - * Set date entry was created - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDateCreated(\DOMDocument $dom, \DOMElement $root) - { - if (!$this->getDataContainer()->getDateCreated()) { - return; - } - if (!$this->getDataContainer()->getDateModified()) { - $this->getDataContainer()->setDateModified( - $this->getDataContainer()->getDateCreated() - ); - } - } - - /** - * Set entry authors - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setAuthors(\DOMDocument $dom, \DOMElement $root) - { - $authors = $this->_container->getAuthors(); - if ((!$authors || empty($authors))) { - return; - } - foreach ($authors as $data) { - $author = $this->_dom->createElement('author'); - $name = $data['name']; - if (array_key_exists('email', $data)) { - $name = $data['email'] . ' (' . $data['name'] . ')'; - } - $text = $dom->createTextNode($name); - $author->appendChild($text); - $root->appendChild($author); - } - } - - /** - * Set entry enclosure - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setEnclosure(\DOMDocument $dom, \DOMElement $root) - { - $data = $this->_container->getEnclosure(); - if ((!$data || empty($data))) { - return; - } - if (!isset($data['type'])) { - $exception = new \Zend\Feed\Exception('Enclosure "type" is not set'); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - if (!isset($data['length'])) { - $exception = new \Zend\Feed\Exception('Enclosure "length" is not set'); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - if (isset($data['length']) && (int) $data['length'] <= 0) { - $exception = new \Zend\Feed\Exception('Enclosure "length" must be an integer' - . ' indicating the content\'s length in bytes'); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $enclosure = $this->_dom->createElement('enclosure'); - $enclosure->setAttribute('type', $data['type']); - $enclosure->setAttribute('length', $data['length']); - $enclosure->setAttribute('url', $data['uri']); - $root->appendChild($enclosure); - } - - /** - * Set link to entry - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setLink(\DOMDocument $dom, \DOMElement $root) - { - if(!$this->getDataContainer()->getLink()) { - return; - } - $link = $dom->createElement('link'); - $root->appendChild($link); - $text = $dom->createTextNode($this->getDataContainer()->getLink()); - $link->appendChild($text); - } - - /** - * Set entry identifier - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setId(\DOMDocument $dom, \DOMElement $root) - { - if(!$this->getDataContainer()->getId() - && !$this->getDataContainer()->getLink()) { - return; - } - - $id = $dom->createElement('guid'); - $root->appendChild($id); - if (!$this->getDataContainer()->getId()) { - $this->getDataContainer()->setId( - $this->getDataContainer()->getLink()); - } - $text = $dom->createTextNode($this->getDataContainer()->getId()); - $id->appendChild($text); - if (!\Zend\Uri\Url::validate($this->getDataContainer()->getId())) { - $id->setAttribute('isPermaLink', 'false'); - } - } - - /** - * Set link to entry comments - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCommentLink(\DOMDocument $dom, \DOMElement $root) - { - $link = $this->getDataContainer()->getCommentLink(); - if (!$link) { - return; - } - $clink = $this->_dom->createElement('comments'); - $text = $dom->createTextNode($link); - $clink->appendChild($text); - $root->appendChild($clink); - } - - /** - * Set entry categories - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCategories(\DOMDocument $dom, \DOMElement $root) - { - $categories = $this->getDataContainer()->getCategories(); - if (!$categories) { - return; - } - foreach ($categories as $cat) { - $category = $dom->createElement('category'); - if (isset($cat['scheme'])) { - $category->setAttribute('domain', $cat['scheme']); - } - $text = $dom->createCDATASection($cat['term']); - $category->appendChild($text); - $root->appendChild($category); - } - } -} diff --git a/library/Zend/Feed/Writer/Renderer/Feed/RSS.php b/library/Zend/Feed/Writer/Renderer/Feed/RSS.php deleted file mode 100644 index b97aec4a629..00000000000 --- a/library/Zend/Feed/Writer/Renderer/Feed/RSS.php +++ /dev/null @@ -1,498 +0,0 @@ -_container->getEncoding()) { - $this->_container->setEncoding('UTF-8'); - } - $this->_dom = new \DOMDocument('1.0', $this->_container->getEncoding()); - $this->_dom->formatOutput = true; - $this->_dom->substituteEntities = false; - $rss = $this->_dom->createElement('rss'); - $this->setRootElement($rss); - $rss->setAttribute('version', '2.0'); - - $channel = $this->_dom->createElement('channel'); - $rss->appendChild($channel); - $this->_dom->appendChild($rss); - $this->_setLanguage($this->_dom, $channel); - $this->_setBaseUrl($this->_dom, $channel); - $this->_setTitle($this->_dom, $channel); - $this->_setDescription($this->_dom, $channel); - $this->_setImage($this->_dom, $channel); - $this->_setDateCreated($this->_dom, $channel); - $this->_setDateModified($this->_dom, $channel); - $this->_setLastBuildDate($this->_dom, $channel); - $this->_setGenerator($this->_dom, $channel); - $this->_setLink($this->_dom, $channel); - $this->_setAuthors($this->_dom, $channel); - $this->_setCopyright($this->_dom, $channel); - $this->_setCategories($this->_dom, $channel); - - foreach ($this->_extensions as $ext) { - $ext->setType($this->getType()); - $ext->setRootElement($this->getRootElement()); - $ext->setDomDocument($this->getDomDocument(), $channel); - $ext->render(); - } - - foreach ($this->_container as $entry) { - if ($this->getDataContainer()->getEncoding()) { - $entry->setEncoding($this->getDataContainer()->getEncoding()); - } - if ($entry instanceof Feed\Writer\Entry) { - $renderer = new Feed\Writer\Renderer\Entry\RSS($entry); - } else { - continue; - } - if ($this->_ignoreExceptions === true) { - $renderer->ignoreExceptions(); - } - $renderer->setType($this->getType()); - $renderer->setRootElement($this->_dom->documentElement); - $renderer->render(); - $element = $renderer->getElement(); - $imported = $this->_dom->importNode($element, true); - $channel->appendChild($imported); - } - return $this; - } - - /** - * Set feed language - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setLanguage(\DOMDocument $dom, \DOMElement $root) - { - $lang = $this->getDataContainer()->getLanguage(); - if (!$lang) { - return; - } - $language = $dom->createElement('language'); - $root->appendChild($language); - $language->nodeValue = $lang; - } - - /** - * Set feed title - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setTitle(\DOMDocument $dom, \DOMElement $root) - { - if(!$this->getDataContainer()->getTitle()) { - $message = 'RSS 2.0 feed elements MUST contain exactly one' - . ' title element but a title has not been set'; - $exception = new Feed\Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - - $title = $dom->createElement('title'); - $root->appendChild($title); - $text = $dom->createTextNode($this->getDataContainer()->getTitle()); - $title->appendChild($text); - } - - /** - * Set feed description - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDescription(\DOMDocument $dom, \DOMElement $root) - { - if(!$this->getDataContainer()->getDescription()) { - $message = 'RSS 2.0 feed elements MUST contain exactly one' - . ' description element but one has not been set'; - $exception = new Feed\Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $subtitle = $dom->createElement('description'); - $root->appendChild($subtitle); - $text = $dom->createTextNode($this->getDataContainer()->getDescription()); - $subtitle->appendChild($text); - } - - /** - * Set date feed was last modified - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDateModified(\DOMDocument $dom, \DOMElement $root) - { - if(!$this->getDataContainer()->getDateModified()) { - return; - } - - $updated = $dom->createElement('pubDate'); - $root->appendChild($updated); - $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->get(\Zend\Date\Date::RSS) - ); - $updated->appendChild($text); - } - - /** - * Set feed generator string - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setGenerator(\DOMDocument $dom, \DOMElement $root) - { - if(!$this->getDataContainer()->getGenerator()) { - $this->getDataContainer()->setGenerator('Zend_Feed_Writer', - \Zend\Version::VERSION, 'http://framework.zend.com'); - } - - $gdata = $this->getDataContainer()->getGenerator(); - $generator = $dom->createElement('generator'); - $root->appendChild($generator); - $name = $gdata['name']; - if (array_key_exists('version', $gdata)) { - $name .= ' ' . $gdata['version']; - } - if (array_key_exists('uri', $gdata)) { - $name .= ' (' . $gdata['uri'] . ')'; - } - $text = $dom->createTextNode($name); - $generator->appendChild($text); - } - - /** - * Set link to feed - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setLink(\DOMDocument $dom, \DOMElement $root) - { - $value = $this->getDataContainer()->getLink(); - if(!$value) { - $message = 'RSS 2.0 feed elements MUST contain exactly one' - . ' link element but one has not been set'; - $exception = new Feed\Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $link = $dom->createElement('link'); - $root->appendChild($link); - $text = $dom->createTextNode($value); - $link->appendChild($text); - if (!\Zend\Uri\Url::validate($value)) { - $link->setAttribute('isPermaLink', 'false'); - } - } - - /** - * Set feed authors - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setAuthors(\DOMDocument $dom, \DOMElement $root) - { - $authors = $this->getDataContainer()->getAuthors(); - if (!$authors || empty($authors)) { - return; - } - foreach ($authors as $data) { - $author = $this->_dom->createElement('author'); - $name = $data['name']; - if (array_key_exists('email', $data)) { - $name = $data['email'] . ' (' . $data['name'] . ')'; - } - $text = $dom->createTextNode($name); - $author->appendChild($text); - $root->appendChild($author); - } - } - - /** - * Set feed copyright - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCopyright(\DOMDocument $dom, \DOMElement $root) - { - $copyright = $this->getDataContainer()->getCopyright(); - if (!$copyright) { - return; - } - $copy = $dom->createElement('copyright'); - $root->appendChild($copy); - $text = $dom->createTextNode($copyright); - $copy->appendChild($text); - } - - /** - * Set feed channel image - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setImage(\DOMDocument $dom, \DOMElement $root) - { - $image = $this->getDataContainer()->getImage(); - if (!$image) { - return; - } - if (!isset($image['title']) || empty($image['title']) - || !is_string($image['title'])) { - $message = 'RSS 2.0 feed images must include a title'; - $exception = new \Zend\Feed\Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - if (empty($image['link']) || !is_string($image['link']) - || !\Zend\Uri\Url::validate($image['link'])) { - $message = 'Invalid parameter: parameter \'link\'' - . ' must be a non-empty string and valid URI/IRI'; - $exception = new \Zend\Feed\Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $img = $dom->createElement('image'); - $root->appendChild($img); - $url = $dom->createElement('url'); - $text = $dom->createTextNode($image['uri']); - $url->appendChild($text); - $title = $dom->createElement('title'); - $text = $dom->createTextNode($image['title']); - $title->appendChild($text); - $link = $dom->createElement('link'); - $text = $dom->createTextNode($image['link']); - $link->appendChild($text); - $img->appendChild($url); - $img->appendChild($title); - $img->appendChild($link); - if (isset($image['height'])) { - if (!ctype_digit((string) $image['height']) || $image['height'] > 400) { - $message = 'Invalid parameter: parameter \'height\'' - . ' must be an integer not exceeding 400'; - $exception = new \Zend\Feed\Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $height = $dom->createElement('height'); - $text = $dom->createTextNode($image['height']); - $height->appendChild($text); - $img->appendChild($height); - } - if (isset($image['width'])) { - if (!ctype_digit((string) $image['width']) || $image['width'] > 144) { - $message = 'Invalid parameter: parameter \'width\'' - . ' must be an integer not exceeding 144'; - $exception = new \Zend\Feed\Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $width = $dom->createElement('width'); - $text = $dom->createTextNode($image['width']); - $width->appendChild($text); - $img->appendChild($width); - } - if (isset($image['description'])) { - if (empty($image['description']) || !is_string($image['description'])) { - $message = 'Invalid parameter: parameter \'description\'' - . ' must be a non-empty string'; - $exception = new \Zend\Feed\Exception($message); - if (!$this->_ignoreExceptions) { - throw $exception; - } else { - $this->_exceptions[] = $exception; - return; - } - } - $desc = $dom->createElement('description'); - $text = $dom->createTextNode($image['description']); - $desc->appendChild($text); - $img->appendChild($desc); - } - } - - - /** - * Set date feed was created - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setDateCreated(\DOMDocument $dom, \DOMElement $root) - { - if(!$this->getDataContainer()->getDateCreated()) { - return; - } - if(!$this->getDataContainer()->getDateModified()) { - $this->getDataContainer()->setDateModified( - $this->getDataContainer()->getDateCreated() - ); - } - } - - /** - * Set date feed last build date - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setLastBuildDate(\DOMDocument $dom, \DOMElement $root) - { - if(!$this->getDataContainer()->getLastBuildDate()) { - return; - } - - $lastBuildDate = $dom->createElement('lastBuildDate'); - $root->appendChild($lastBuildDate); - $text = $dom->createTextNode( - $this->getDataContainer()->getLastBuildDate()->get(\Zend\Date\Date::RSS) - ); - $lastBuildDate->appendChild($text); - } - - /** - * Set base URL to feed links - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setBaseUrl(\DOMDocument $dom, \DOMElement $root) - { - $baseUrl = $this->getDataContainer()->getBaseUrl(); - if (!$baseUrl) { - return; - } - $root->setAttribute('xml:base', $baseUrl); - } - - /** - * Set feed categories - * - * @param DOMDocument $dom - * @param DOMElement $root - * @return void - */ - protected function _setCategories(\DOMDocument $dom, \DOMElement $root) - { - $categories = $this->getDataContainer()->getCategories(); - if (!$categories) { - return; - } - foreach ($categories as $cat) { - $category = $dom->createElement('category'); - if (isset($cat['scheme'])) { - $category->setAttribute('domain', $cat['scheme']); - } - $text = $dom->createTextNode($cat['term']); - $category->appendChild($text); - $root->appendChild($category); - } - } -} diff --git a/library/Zend/Form/Element/Hash.php b/library/Zend/Form/Element/Hash.php index 2cf9252358e..5c7a2cf017a 100644 --- a/library/Zend/Form/Element/Hash.php +++ b/library/Zend/Form/Element/Hash.php @@ -183,7 +183,7 @@ public function getHash() */ public function getSessionName() { - return __CLASS__ . '_' . $this->getSalt() . '_' . $this->getName(); + return str_replace('\\', '_', __CLASS__) . '_' . $this->getSalt() . '_' . $this->getName(); } /** diff --git a/library/Zend/GData/App/Base.php b/library/Zend/GData/App/Base.php index d763d7c28e1..690afe4e969 100644 --- a/library/Zend/GData/App/Base.php +++ b/library/Zend/GData/App/Base.php @@ -475,7 +475,7 @@ public function __get($name) { $method = 'get'.ucfirst($name); if (method_exists($this, $method)) { - return call_user_func(array(&$this, $method)); + return $this->$method(); } else if (property_exists($this, "_${name}")) { return $this->{'_' . $name}; } else { @@ -495,12 +495,13 @@ public function __get($name) * * @param string $name * @param string $value + * @return void */ public function __set($name, $val) { $method = 'set'.ucfirst($name); if (method_exists($this, $method)) { - return call_user_func(array(&$this, $method), $val); + $this->$method($val); } else if (isset($this->{'_' . $name}) || ($this->{'_' . $name} === null)) { $this->{'_' . $name} = $val; } else { diff --git a/library/Zend/GData/App/BaseMediaSource.php b/library/Zend/GData/App/BaseMediaSource.php index a7660bc131b..86732367afc 100644 --- a/library/Zend/GData/App/BaseMediaSource.php +++ b/library/Zend/GData/App/BaseMediaSource.php @@ -113,7 +113,7 @@ public function __get($name) { $method = 'get'.ucfirst($name); if (method_exists($this, $method)) { - return call_user_func(array(&$this, $method)); + return $this->$method(); } else if (property_exists($this, "_${name}")) { return $this->{'_' . $name}; } else { @@ -131,12 +131,13 @@ public function __get($name) * * @param string $name * @param string $value + * @return void */ public function __set($name, $val) { $method = 'set'.ucfirst($name); if (method_exists($this, $method)) { - return call_user_func(array(&$this, $method), $val); + $this->$method($val); } else if (isset($this->{'_' . $name}) || ($this->{'_' . $name} === null)) { $this->{'_' . $name} = $val; } else { diff --git a/library/Zend/GData/Query.php b/library/Zend/GData/Query.php index 1e93b82750e..488fbd3044d 100644 --- a/library/Zend/GData/Query.php +++ b/library/Zend/GData/Query.php @@ -392,12 +392,11 @@ public function getCategory() return $this->_category; } - public function __get($name) { $method = 'get'.ucfirst($name); if (method_exists($this, $method)) { - return call_user_func(array(&$this, $method)); + return $this->$method(); } else { throw new App\Exception('Property ' . $name . ' does not exist'); } @@ -407,7 +406,7 @@ public function __set($name, $val) { $method = 'set'.ucfirst($name); if (method_exists($this, $method)) { - return call_user_func(array(&$this, $method), $val); + $this->$method($val); } else { throw new App\Exception('Property ' . $name . ' does not exist'); } diff --git a/library/Zend/Locale/Format.php b/library/Zend/Locale/Format.php index d6c342c25a5..8778a93eaea 100644 --- a/library/Zend/Locale/Format.php +++ b/library/Zend/Locale/Format.php @@ -806,13 +806,16 @@ private static function _parseDate($date, $options) if ($day !== false) { $parse[$day] = 'd'; if (!empty($options['locale']) && ($options['locale'] !== 'root') && - (!is_object($options['locale']) || ((string) $options['locale'] !== 'root'))) { + (!is_object($options['locale']) || ((string) $options['locale'] !== 'root')) + ) { // erase day string - $daylist = Data::getList($options['locale'], 'day'); - foreach($daylist as $key => $name) { - if (iconv_strpos($number, $name) !== false) { - $number = str_replace($name, "EEEE", $number); - break; + $daylist = Data::getList($options['locale'], 'day'); + if (is_scalar($number)) { + foreach($daylist as $key => $name) { + if (iconv_strpos($number, $name) !== false) { + $number = str_replace($name, "EEEE", $number); + break; + } } } } @@ -1061,7 +1064,7 @@ protected static function _replaceMonth(&$number, $monthlist) // If no $locale was given, or $locale was invalid, do not use this identity mapping to normalize. // Otherwise, translate locale aware month names in $number to their numeric equivalents. $position = false; - if ($monthlist && $monthlist[1] != 1) { + if ($monthlist && $monthlist[1] != 1 && is_scalar($number)) { foreach($monthlist as $key => $name) { if (($position = iconv_strpos($number, $name, 0, 'UTF-8')) !== false) { $number = str_ireplace($name, $key, $number); diff --git a/library/Zend/Locale/PhpMath.php b/library/Zend/Locale/PhpMath.php index 06e346c5a89..ad2b2f3b40b 100644 --- a/library/Zend/Locale/PhpMath.php +++ b/library/Zend/Locale/PhpMath.php @@ -40,15 +40,15 @@ class PhpMath extends Math public static function disable() { self::$_bcmathDisabled = true; - self::$add = 'Zend\\Locale\\PhpMath::Add'; - self::$sub = 'Zend\\Locale\\PhpMath::Sub'; - self::$pow = 'Zend\\Locale\\PhpMath::Pow'; - self::$mul = 'Zend\\Locale\\PhpMath::Mul'; - self::$div = 'Zend\\Locale\\PhpMath::Div'; - self::$comp = 'Zend\\Locale\\PhpMath::Comp'; - self::$sqrt = 'Zend\\Locale\\PhpMath::Sqrt'; - self::$mod = 'Zend\\Locale\\PhpMath::Mod'; - self::$scale = 'Zend\\Locale\\PhpMath::Scale'; + self::$add = 'Zend\Locale\PhpMath::Add'; + self::$sub = 'Zend\Locale\PhpMath::Sub'; + self::$pow = 'Zend\Locale\PhpMath::Pow'; + self::$mul = 'Zend\Locale\PhpMath::Mul'; + self::$div = 'Zend\Locale\PhpMath::Div'; + self::$comp = 'Zend\Locale\PhpMath::Comp'; + self::$sqrt = 'Zend\Locale\PhpMath::Sqrt'; + self::$mod = 'Zend\Locale\PhpMath::Mod'; + self::$scale = 'Zend\Locale\PhpMath::Scale'; self::$defaultScale = 0; self::$defaultPrecision = 1; diff --git a/library/Zend/Log/Filter/Priority.php b/library/Zend/Log/Filter/Priority.php index 5e7fe69d7f5..bec685fbf35 100644 --- a/library/Zend/Log/Filter/Priority.php +++ b/library/Zend/Log/Filter/Priority.php @@ -53,7 +53,7 @@ class Priority extends AbstractFilter * @param string $operator Comparison operator * @throws \Zend\Log\Exception\InvalidArgumentException */ - public function __construct($priority, $operator = \NULL) + public function __construct($priority, $operator = null) { if (! is_integer($priority)) { throw new \Zend\Log\Exception\InvalidArgumentException('Priority must be an integer'); @@ -88,7 +88,7 @@ static public function factory($config = array()) } return new self( - $config['priority'], + (int) $config['priority'], $config['operator'] ); } diff --git a/library/Zend/Log/Logger.php b/library/Zend/Log/Logger.php index 2c468449ab4..5b6dd918078 100644 --- a/library/Zend/Log/Logger.php +++ b/library/Zend/Log/Logger.php @@ -230,7 +230,7 @@ protected function _constructFromConfig($type, $config, $namespace) ); } - return call_user_func(array($className, 'factory'), $params); + return $className::factory($params); } /** diff --git a/library/Zend/Log/Writer/Db.php b/library/Zend/Log/Writer/Db.php index f0c185f1b6a..ae2d443a7bc 100644 --- a/library/Zend/Log/Writer/Db.php +++ b/library/Zend/Log/Writer/Db.php @@ -101,7 +101,7 @@ static public function factory($config = array()) * * @throws \Zend\Log\Exception\InvalidArgumentException */ - public function setFormatter(Zend_Log_Formatter_Interface $formatter) + public function setFormatter(\Zend\Log\Formatter $formatter) { throw new Log\Exception\InvalidArgumentException(get_class() . ' does not support formatting'); } diff --git a/library/Zend/Log/Writer/Firebug.php b/library/Zend/Log/Writer/Firebug.php index b597bc6ae35..3555d014cab 100644 --- a/library/Zend/Log/Writer/Firebug.php +++ b/library/Zend/Log/Writer/Firebug.php @@ -32,7 +32,7 @@ * @uses \Zend\Log\Logger * @uses \Zend\Log\Formatter\Firebug * @uses \Zend\Log\Writer\AbstractWriter - * @uses \Zend\Wildfire\Plugin\FirePhp\FirePhp + * @uses \Zend\Wildfire\Plugin\FirePhp * @category Zend * @package Zend_Log * @subpackage Writer @@ -46,20 +46,20 @@ class Firebug extends AbstractWriter * Maps logging priorities to logging display styles * @var array */ - protected $_priorityStyles = array(Log\Logger::EMERG => FirePhp\FirePhp::ERROR, - Log\Logger::ALERT => FirePhp\FirePhp::ERROR, - Log\Logger::CRIT => FirePhp\FirePhp::ERROR, - Log\Logger::ERR => FirePhp\FirePhp::ERROR, - Log\Logger::WARN => FirePhp\FirePhp::WARN, - Log\Logger::NOTICE => FirePhp\FirePhp::INFO, - Log\Logger::INFO => FirePhp\FirePhp::INFO, - Log\Logger::DEBUG => FirePhp\FirePhp::LOG); + protected $_priorityStyles = array(Log\Logger::EMERG => FirePhp::ERROR, + Log\Logger::ALERT => FirePhp::ERROR, + Log\Logger::CRIT => FirePhp::ERROR, + Log\Logger::ERR => FirePhp::ERROR, + Log\Logger::WARN => FirePhp::WARN, + Log\Logger::NOTICE => FirePhp::INFO, + Log\Logger::INFO => FirePhp::INFO, + Log\Logger::DEBUG => FirePhp::LOG); /** * The default logging style for un-mapped priorities * @var string */ - protected $_defaultPriorityStyle = FirePhp\FirePhp::LOG; + protected $_defaultPriorityStyle = FirePhp::LOG; /** * Flag indicating whether the log writer is enabled @@ -189,9 +189,9 @@ protected function _write($event) $label = isset($event['firebugLabel'])?$event['firebugLabel']:null; - FirePhp\FirePhp::getInstance()->send($message, - $label, - $type, - array('traceOffset'=>6)); + FirePhp::getInstance()->send($message, + $label, + $type, + array('traceOffset'=>6)); } } diff --git a/library/Zend/Markup/Markup.php b/library/Zend/Markup/Markup.php index 105a4e89a6f..2acd713e3fc 100644 --- a/library/Zend/Markup/Markup.php +++ b/library/Zend/Markup/Markup.php @@ -93,7 +93,7 @@ public static function getRendererBroker() * @param array $options * @return \Zend\Markup\Renderer\AbstractRenderer */ - public static function factory($parser, $renderer = 'HTML', array $options = array()) + public static function factory($parser, $renderer = 'Html', array $options = array()) { $parser = self::getParserBroker()->load($parser); $rendererBroker = self::getRendererBroker(); diff --git a/library/Zend/Markup/Parser/BBCode.php b/library/Zend/Markup/Parser/BBCode.php deleted file mode 100644 index 56df7ae193c..00000000000 --- a/library/Zend/Markup/Parser/BBCode.php +++ /dev/null @@ -1,476 +0,0 @@ - array( - 'type' => self::TYPE_DEFAULT, - 'stoppers' => array(), - ), - '*' => array( - 'type' => self::TYPE_DEFAULT, - 'stoppers' => array(self::NEWLINE, '[/*]', '[/]'), - ), - 'hr' => array( - 'type' => self::TYPE_SINGLE, - 'stoppers' => array(), - ), - 'code' => array( - 'type' => self::TYPE_DEFAULT, - 'stoppers' => array('[/code]', '[/]'), - 'parse_inside' => false - ) - ); - - /** - * Token array - * - * @var array - */ - protected $_tokens = array(); - - - /** - * Prepare the parsing of a bbcode string, the real parsing is done in {@link _parse()} - * - * @param string $value - * @return \Zend\Markup\TokenList - */ - public function parse($value) - { - if (!is_string($value)) { - throw new Exception('Value to parse should be a string.'); - } - - if (empty($value)) { - throw new Exception('Value to parse cannot be left empty.'); - } - - $tokens = $this->tokenize($value); - - return $this->buildTree($tokens); - } - - /** - * Tokenize - * - * @param string $value - * - * @return array - */ - public function tokenize($value) - { - $value = str_replace(array("\r\n", "\r", "\n"), self::NEWLINE, $value); - - $attribute = ''; - - $valueLen = strlen($value); - $pointer = 0; - $buffer = ''; - $temp = array(); - $tokens = array(); - - scan: { - if ($valueLen <= $pointer) { - goto end; - } - - $matches = array(); - $regex = '#\G(?[^\[]*)(?\[(?[' . self::NAME_CHARSET . ']+)?)?#'; - if (!preg_match($regex, $value, $matches, null, $pointer)) { - goto end; - } - - $pointer += strlen($matches[0]); - - if (!empty($matches['text'])) { - $buffer .= $matches['text']; - } - - if (!isset($matches['open'])) { - // great, no tag, we are ending the string - goto scan; - } - if (!isset($matches['name'])) { - $buffer .= $matches['open']; - goto scan; - } - - $temp = array( - 'tag' => '[' . $matches['name'], - 'name' => $matches['name'], - 'attributes' => array() - ); - - if ($pointer >= $valueLen) { - // damn, no tag - $buffer .= $temp['tag']; - goto end; - } - - if ($value[$pointer] == '=') { - $pointer++; - - $temp['tag'] .= '='; - $attribute = $temp['name']; - - goto parsevalue; - } - goto scanattrs; - } - - scanattrs: { - $matches = array(); - $regex = '#\G((?\s*\])|\s+(?[' . self::NAME_CHARSET . ']+)(?=?))#'; - if (!preg_match($regex, $value, $matches, null, $pointer)) { - goto end; - } - - $pointer += strlen($matches[0]); - - if (!empty($matches['end'])) { - if (!empty($buffer)) { - $tokens[] = array( - 'tag' => $buffer, - 'type' => Markup\Token::TYPE_NONE - ); - $buffer = ''; - } - $temp['tag'] .= $matches['end']; - $temp['type'] = Markup\Token::TYPE_TAG; - - $tokens[] = $temp; - $temp = array(); - - goto scan; - } else { - // attribute name - $attribute = $matches['attribute']; - - $temp['tag'] .= $matches[0]; - - $temp['attributes'][$attribute] = ''; - - if (empty($matches['eq'])) { - goto scanattrs; - } - goto parsevalue; - } - } - - parsevalue: { - $matches = array(); - $regex = '#\G((?"|\')(?.*?)\\2|(?[^\]\s]+))#'; - if (!preg_match($regex, $value, $matches, null, $pointer)) { - goto scanattrs; - } - - $pointer += strlen($matches[0]); - - if (!empty($matches['quote'])) { - $temp['attributes'][$attribute] = $matches['valuequote']; - } else { - $temp['attributes'][$attribute] = $matches['value']; - } - $temp['tag'] .= $matches[0]; - - goto scanattrs; - } - - end: - - if (!empty($buffer)) { - $tokens[] = array( - 'tag' => $buffer, - 'type' => Markup\Token::TYPE_NONE - ); - } - - return $tokens; - } - - /** - * Build a tree with a certain strategy - * - * @param array $tokens - * @param string $strategy - * - * @return \Zend\Markup\TokenList/ - */ - public function buildTree(array $tokens, $strategy = 'default') - { - switch ($strategy) { - case 'default': - return $this->_createTree($tokens); - break; - default: - // TODO: throw exception for this case - break; - } - } - - /** - * Parse the token array into a tree - * - * @param array $tokens - * - * @return \Zend\Markup\TokenList - */ - protected function _createTree($tokens) - { - // variable initialization for treebuilder - $this->_searchedStoppers = array(); - $this->_tree = new Markup\TokenList(); - $this->_current = new Markup\Token( - '', - Markup\Token::TYPE_NONE, - 'Zend_Markup_Root' - ); - - $this->_tree->addChild($this->_current); - - foreach ($tokens as $token) { - // first we want to know if this tag is a stopper, or at least a searched one - if ($this->_isStopper($token['tag'])) { - // find the stopper - $oldItems = array(); - - while (!in_array($token['tag'], $this->_tags[$this->_current->getName()]['stoppers'])) { - $oldItems[] = clone $this->_current; - $this->_current = $this->_current->getParent(); - } - - // we found the stopper, so stop the tag - $this->_current->setStopper($token['tag']); - $this->_removeFromSearchedStoppers($this->_current); - $this->_current = $this->_current->getParent(); - - // add the old items again if there are any - if (!empty($oldItems)) { - foreach (array_reverse($oldItems) as $item) { - /* @var $token \Zend\Markup\Token */ - $this->_current->addChild($item); - $item->setParent($this->_current); - $this->_current = $item; - } - } - } else { - if ($token['type'] == Markup\Token::TYPE_TAG) { - if ($token['tag'] == self::NEWLINE) { - // this is a newline tag, add it as a token - $this->_current->addChild(new Markup\Token( - "\n", - Markup\Token::TYPE_NONE, - '', - array(), - $this->_current - )); - } elseif (isset($token['name']) && ($token['name'][0] == '/')) { - // this is a stopper, add it as a empty token - $this->_current->addChild(new Markup\Token( - $token['tag'], - Markup\Token::TYPE_NONE, - '', - array(), - $this->_current - )); - } elseif (isset($this->_tags[$this->_current->getName()]['parse_inside']) - && !$this->_tags[$this->_current->getName()]['parse_inside'] - ) { - $this->_current->addChild(new Markup\Token( - $token['tag'], - Markup\Token::TYPE_NONE, - '', - array(), - $this->_current - )); - } else { - // add the tag - $child = new Markup\Token( - $token['tag'], - $token['type'], - $token['name'], - $token['attributes'], - $this->_current - ); - $this->_current->addChild($child); - - // add stoppers for this tag, if its has stoppers - if ($this->_getType($token['name']) == self::TYPE_DEFAULT) { - $this->_current = $child; - - $this->_addToSearchedStoppers($this->_current); - } - } - } else { - // no tag, just add it as a simple token - $this->_current->addChild(new Markup\Token( - $token['tag'], - Markup\Token::TYPE_NONE, - '', - array(), - $this->_current - )); - } - } - } - - return $this->_tree; - } - - /** - * Check if there is a tag declaration, and if it isnt there, add it - * - * @param string $name - * - * @return void - */ - protected function _checkTagDeclaration($name) - { - if (!isset($this->_tags[$name])) { - $this->_tags[$name] = array( - 'type' => self::TYPE_DEFAULT, - 'stoppers' => array( - '[/' . $name . ']', - '[/]' - ) - ); - } - } - /** - * Check the tag's type - * - * @param string $name - * @return string - */ - protected function _getType($name) - { - $this->_checkTagDeclaration($name); - - return $this->_tags[$name]['type']; - } - - /** - * Check if the tag is a stopper - * - * @param string $tag - * @return bool - */ - protected function _isStopper($tag) - { - $this->_checkTagDeclaration($this->_current->getName()); - - if (!empty($this->_searchedStoppers[$tag])) { - return true; - } - - return false; - } - - /** - * Add to searched stoppers - * - * @param \Zend\Markup\Token $token - * @return void - */ - protected function _addToSearchedStoppers(Markup\Token $token) - { - $this->_checkTagDeclaration($token->getName()); - - foreach ($this->_tags[$token->getName()]['stoppers'] as $stopper) { - if (!isset($this->_searchedStoppers[$stopper])) { - $this->_searchedStoppers[$stopper] = 0; - } - ++$this->_searchedStoppers[$stopper]; - } - } - - /** - * Remove from searched stoppers - * - * @param \Zend\Markup\Token $token - * @return void - */ - protected function _removeFromSearchedStoppers(Markup\Token $token) - { - $this->_checkTagDeclaration($token->getName()); - - foreach ($this->_tags[$token->getName()]['stoppers'] as $stopper) { - --$this->_searchedStoppers[$stopper]; - } - } - -} diff --git a/library/Zend/Markup/Parser/Textile.php b/library/Zend/Markup/Parser/Textile.php index cfad45cb2ab..a09da62889f 100644 --- a/library/Zend/Markup/Parser/Textile.php +++ b/library/Zend/Markup/Parser/Textile.php @@ -560,4 +560,28 @@ protected function _extractAttributes(array $matches) return $attributes; } + /** + * Build a tree with a certain strategy + * + * @todo IMPLEMENT + * @param array $tokens + * @param string $strategy + * + * @return \Zend\Markup\TokenList + */ + public function buildTree(array $tokens, $strategy = 'default') + { + } + + /** + * Tokenize a string + * + * @param string $value + * + * @todo IMPLEMENT + * @return array + */ + public function tokenize($value) + { + } } diff --git a/library/Zend/Markup/Renderer/HTML.php b/library/Zend/Markup/Renderer/HTML.php deleted file mode 100644 index cce363103b2..00000000000 --- a/library/Zend/Markup/Renderer/HTML.php +++ /dev/null @@ -1,533 +0,0 @@ - array('block', 'inline', 'block-empty', 'inline-empty', 'list'), - 'inline' => array('inline', 'inline-empty'), - 'list' => array('list-item'), - 'list-item' => array('inline', 'inline-empty', 'list'), - 'block-empty' => array(), - 'inline-empty' => array(), - ); - - /** - * The current group - * - * @var string - */ - protected $_group = 'block'; - - /** - * Default attributes - * - * @var array - */ - protected static $_defaultAttributes = array( - 'id' => '', - 'class' => '', - 'style' => '', - 'lang' => '', - 'title' => '' - ); - - - /** - * Constructor - * - * @param array|\Zend\Config\Config $options - * - * @return void - */ - public function __construct($options = array()) - { - if ($options instanceof \Zend\Config\Config) { - $options = $options->toArray(); - } - - $this->_pluginLoader = new PluginLoader(array( - 'Zend\Markup\Renderer\Markup\HTML' => 'Zend/Markup/Renderer/Markup/HTML/' - )); - - if (!isset($options['useDefaultMarkups']) && isset($options['useDefaultTags'])) { - $options['useDefaultMarkups'] = $options['useDefaultTags']; - } - if (isset($options['useDefaultMarkups']) && ($options['useDefaultMarkups'] !== false)) { - $this->_defineDefaultMarkups(); - } elseif (!isset($options['useDefaultMarkups'])) { - $this->_defineDefaultMarkups(); - } - - parent::__construct($options); - } - - /** - * Define the default markups - * - * @return void - */ - protected function _defineDefaultMarkups() - { - $this->_markups = array( - 'b' => array( - 'type' => 10, // self::TYPE_REPLACE | self::TAG_NORMAL - 'tag' => 'strong', - 'group' => 'inline', - 'filter' => true, - ), - 'u' => array( - 'type' => 10, - 'tag' => 'span', - 'attributes' => array( - 'style' => 'text-decoration: underline;', - ), - 'group' => 'inline', - 'filter' => true, - ), - 'i' => array( - 'type' => 10, - 'tag' => 'em', - 'group' => 'inline', - 'filter' => true, - ), - 'cite' => array( - 'type' => 10, - 'tag' => 'cite', - 'group' => 'inline', - 'filter' => true, - ), - 'del' => array( - 'type' => 10, - 'tag' => 'del', - 'group' => 'inline', - 'filter' => true, - ), - 'ins' => array( - 'type' => 10, - 'tag' => 'ins', - 'group' => 'inline', - 'filter' => true, - ), - 'sub' => array( - 'type' => 10, - 'tag' => 'sub', - 'group' => 'inline', - 'filter' => true, - ), - 'sup' => array( - 'type' => 10, - 'tag' => 'sup', - 'group' => 'inline', - 'filter' => true, - ), - 'span' => array( - 'type' => 10, - 'tag' => 'span', - 'group' => 'inline', - 'filter' => true, - ), - 'acronym' => array( - 'type' => 10, - 'tag' => 'acronym', - 'group' => 'inline', - 'filter' => true, - ), - // headings - 'h1' => array( - 'type' => 10, - 'tag' => 'h1', - 'group' => 'inline', - 'filter' => true, - ), - 'h2' => array( - 'type' => 10, - 'tag' => 'h2', - 'group' => 'inline', - 'filter' => true, - ), - 'h3' => array( - 'type' => 10, - 'tag' => 'h3', - 'group' => 'inline', - 'filter' => true, - ), - 'h4' => array( - 'type' => 10, - 'tag' => 'h4', - 'group' => 'inline', - 'filter' => true, - ), - 'h5' => array( - 'type' => 10, - 'tag' => 'h5', - 'group' => 'inline', - 'filter' => true, - ), - 'h6' => array( - 'type' => 10, - 'tag' => 'h6', - 'group' => 'inline', - 'filter' => true, - ), - // callback tags - 'url' => array( - 'type' => 16, // self::TYPE_ALIAS - 'name' => 'URL', - ), - 'URL' => array( - 'type' => 6, // self::TYPE_CALLBACK | self::TAG_NORMAL - 'callback' => null, - 'group' => 'inline', - 'filter' => true, - ), - 'img' => array( - 'type' => 6, - 'callback' => null, - 'group' => 'inline-empty', - 'filter' => true, - ), - 'code' => array( - 'type' => 6, - 'callback' => null, - 'group' => 'block-empty', - 'filter' => false, - ), - 'p' => array( - 'type' => 10, - 'tag' => 'p', - 'group' => 'block', - 'filter' => true, - ), - 'ignore' => array( - 'type' => 10, - 'start' => '', - 'end' => '', - 'group' => 'block-empty', - 'filter' => true, - ), - 'quote' => array( - 'type' => 10, - 'tag' => 'blockquote', - 'group' => 'block', - 'filter' => true, - ), - 'list' => array( - 'type' => 16, - 'name' => 'ListItem', - ), - 'ListItem' => array( - 'type' => 6, - 'callback' => null, - 'group' => 'list', - 'filter' => new PregReplaceFilter('/.*/is', ''), - ), - '*' => array( - 'type' => 10, - 'tag' => 'li', - 'group' => 'list-item', - 'filter' => true, - ), - 'hr' => array( - 'type' => 9, // self::TYPE_REPLACE | self::TAG_SINGLE - 'tag' => 'hr', - 'group' => 'block', - 'empty' => true, - ), - // aliases - 'bold' => array( - 'type' => 16, - 'name' => 'b', - ), - 'strong' => array( - 'type' => 16, - 'name' => 'b', - ), - 'italic' => array( - 'type' => 16, - 'name' => 'i', - ), - 'em' => array( - 'type' => 16, - 'name' => 'i', - ), - 'emphasized' => array( - 'type' => 16, - 'name' => 'i', - ), - 'underline' => array( - 'type' => 16, - 'name' => 'u', - ), - 'citation' => array( - 'type' => 16, - 'name' => 'cite', - ), - 'deleted' => array( - 'type' => 16, - 'name' => 'del', - ), - 'insert' => array( - 'type' => 16, - 'name' => 'ins', - ), - 'strike' => array( - 'type' => 16, - 'name' => 's', - ), - 's' => array( - 'type' => 16, - 'name' => 'del', - ), - 'subscript' => array( - 'type' => 16, - 'name' => 'sub', - ), - 'superscript' => array( - 'type' => 16, - 'name' => 'sup', - ), - 'a' => array( - 'type' => 16, - 'name' => 'url', - ), - 'image' => array( - 'type' => 16, - 'name' => 'img', - ), - 'li' => array( - 'type' => 16, - 'name' => '*', - ), - 'color' => array( - 'type' => 16, - 'name' => 'span', - ), - ); - } - - /** - * Add the default filters - * - * @return void - */ - public function addDefaultFilters() - { - $this->_defaultFilter = new \Zend\Filter\FilterChain(); - - $this->_defaultFilter->addFilter(new \Zend\Filter\HtmlEntities(array('encoding' => self::getEncoding()))); - $this->_defaultFilter->addFilter(new \Zend\Filter\Callback('nl2br')); - } - - /** - * Execute a replace token - * - * @param \Zend\Markup\Token $token - * @param array $markup - * @return string - */ - protected function _executeReplace(Token $token, $markup) - { - if (isset($markup['tag'])) { - if (!isset($markup['attributes'])) { - $markup['attributes'] = array(); - } - $attrs = self::renderAttributes($token, $markup['attributes']); - return "<{$markup['tag']}{$attrs}>{$this->_render($token)}"; - } - - return parent::_executeReplace($token, $markup); - } - - /** - * Execute a single replace token - * - * @param \Zend\Markup\Token $token - * @param array $markup - * @return string - */ - protected function _executeSingleReplace(Token $token, $markup) - { - if (isset($markup['tag'])) { - if (!isset($markup['attributes'])) { - $markup['attributes'] = array(); - } - $attrs = self::renderAttributes($token, $markup['attributes']); - return "<{$markup['tag']}{$attrs} />"; - } - return parent::_executeSingleReplace($token, $markup); - } - - /** - * Render some attributes - * - * @param \Zend\Markup\Token $token - * @param array $attributes - * @return string - */ - public static function renderAttributes(Token $token, array $attributes = array()) - { - $attributes = array_merge(self::$_defaultAttributes, $attributes); - - $return = ''; - - $tokenAttributes = $token->getAttributes(); - - // correct style attribute - if (isset($tokenAttributes['style'])) { - $tokenAttributes['style'] = trim($tokenAttributes['style']); - - if ($tokenAttributes['style'][strlen($tokenAttributes['style']) - 1] != ';') { - $tokenAttributes['style'] .= ';'; - } - } else { - $tokenAttributes['style'] = ''; - } - - // special treathment for 'align' and 'color' attribute - if (isset($tokenAttributes['align'])) { - $tokenAttributes['style'] .= 'text-align: ' . $tokenAttributes['align'] . ';'; - unset($tokenAttributes['align']); - } - if (isset($tokenAttributes['color']) && self::checkColor($tokenAttributes['color'])) { - $tokenAttributes['style'] .= 'color: ' . $tokenAttributes['color'] . ';'; - unset($tokenAttributes['color']); - } - - /* - * loop through all the available attributes, and check if there is - * a value defined by the token - * if there is no value defined by the token, use the default value or - * don't set the attribute - */ - foreach ($attributes as $attribute => $value) { - if (isset($tokenAttributes[$attribute]) && !empty($tokenAttributes[$attribute])) { - $return .= ' ' . $attribute . '="' . htmlentities($tokenAttributes[$attribute], - ENT_QUOTES, - self::getEncoding()) . '"'; - } elseif (!empty($value)) { - $return .= ' ' . $attribute . '="' . htmlentities($value, ENT_QUOTES, self::getEncoding()) . '"'; - } - } - - return $return; - } - - /** - * Check if a color is a valid HTML color - * - * @param string $color - * - * @return bool - */ - public static function checkColor($color) - { - /* - * aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, - * purple, red, silver, teal, white, and yellow. - */ - $colors = array( - 'aqua', 'black', 'blue', 'fuchsia', 'gray', 'green', 'lime', - 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', - 'white', 'yellow' - ); - - if (in_array($color, $colors)) { - return true; - } - - if (preg_match('/\#[0-9a-f]{6}/i', $color)) { - return true; - } - - return false; - } - - /** - * Check if the URI is valid - * - * @param string $uri - * - * @return bool - */ - public static function isValidUri($uri) - { - if (!preg_match('/^([a-z][a-z+\-.]*):/i', $uri, $matches)) { - return false; - } - - $scheme = strtolower($matches[1]); - - switch ($scheme) { - case 'javascript': - // JavaScript scheme is not allowed for security reason - return false; - - case 'http': - case 'https': - case 'ftp': - $components = @parse_url($uri); - - if ($components === false) { - return false; - } - - if (!isset($components['host'])) { - return false; - } - - return true; - - default: - return true; - } - } -} diff --git a/library/Zend/Markup/Renderer/Markup/HTML/AbstractHTML.php b/library/Zend/Markup/Renderer/Markup/HTML/AbstractHTML.php deleted file mode 100644 index 79033d55320..00000000000 --- a/library/Zend/Markup/Renderer/Markup/HTML/AbstractHTML.php +++ /dev/null @@ -1,126 +0,0 @@ -_attributes = $attributes; - - return $this; - } - - /** - * Add an attribute for this markup - * - * @param string $name - * @param string $value - * - * @return \Zend\Markup\Renderer\Markup\HTML\AbstractHTML - */ - public function addAttribute($name, $value) - { - $this->_attributes[$name] = $value; - - return $this; - } - - /** - * Remove an attribute from this markup - * - * @param string $name - * - * @return \Zend\Markup\Renderer\Markup\HTML\AbstractHTML - */ - public function removeAttribute($name) - { - unset($this->_attributes[$name]); - - return $this; - } - - /** - * Render some attributes - * - * @param \Zend\Markup\Token $token - * @param array $attributes - * @return string - */ - public function renderAttributes(Markup\Token $token) - { - $return = ''; - - $tokenAttributes = $token->getAttributes(); - - /* - * loop through all the available attributes, and check if there is - * a value defined by the token - * if there is no value defined by the token, use the default value or - * don't set the attribute - */ - foreach ($this->_attributes as $attribute => $value) { - if (isset($tokenAttributes[$attribute]) && !empty($tokenAttributes[$attribute])) { - $return .= ' ' . $attribute . '="' . htmlentities($tokenAttributes[$attribute], - ENT_QUOTES, - $this->getEncoding()) . '"'; - } elseif (!empty($value)) { - $return .= ' ' . $attribute . '="' . htmlentities($value, ENT_QUOTES, $this->getEncoding()) . '"'; - } - } - - return $return; - } -} diff --git a/library/Zend/Markup/Renderer/Markup/HTML/Code.php b/library/Zend/Markup/Renderer/Markup/HTML/Code.php deleted file mode 100644 index e7472fb1e5a..00000000000 --- a/library/Zend/Markup/Renderer/Markup/HTML/Code.php +++ /dev/null @@ -1,55 +0,0 @@ -hasAttribute('alt')) { - $alt = $token->getAttribute('alt'); - } else { - // try to get the alternative from the URL - $alt = rtrim($text, '/'); - $alt = strrchr($alt, '/'); - if (false !== strpos($alt, '.')) { - $alt = substr($alt, 1, strpos($alt, '.') - 1); - } - } - - // run the URI and alt through htmlentities - $uri = htmlentities($uri, ENT_QUOTES, $this->getEncoding()); - $alt = htmlentities($alt, ENT_QUOTES, $this->getEncoding()); - - return "\"{$alt}\""renderAttributes($token) . " />"; - } -} diff --git a/library/Zend/Markup/Renderer/Markup/HTML/ListItem.php b/library/Zend/Markup/Renderer/Markup/HTML/ListItem.php deleted file mode 100644 index dd1e32161e2..00000000000 --- a/library/Zend/Markup/Renderer/Markup/HTML/ListItem.php +++ /dev/null @@ -1,106 +0,0 @@ -hasAttribute('list')) { - // because '01' == '1' - if ($token->getAttribute('list') === '01') { - $type = 'decimal-leading-zero'; - } else { - switch ($token->getAttribute('list')) { - case '1': - $type = 'decimal'; - break; - case 'i': - $type = 'lower-roman'; - break; - case 'I': - $type = 'upper-roman'; - break; - case 'a': - $type = 'lower-alpha'; - break; - case 'A': - $type = 'upper-alpha'; - break; - - // the following type is unsupported by IE (including IE8) - case 'alpha': - $type = 'lower-greek'; - break; - - // the CSS names itself - case 'armenian': // unsupported by IE (including IE8) - case 'decimal': - case 'decimal-leading-zero': // unsupported by IE (including IE8) - case 'georgian': // unsupported by IE (including IE8) - case 'lower-alpha': - case 'lower-greek': // unsupported by IE (including IE8) - case 'lower-latin': // unsupported by IE (including IE8) - case 'lower-roman': - case 'upper-alpha': - case 'upper-latin': // unsupported by IE (including IE8) - case 'upper-roman': - $type = $token->getAttribute('list'); - break; - } - } - } - - if (null !== $type) { - return "
    {$text}
"; - } else { - return "
    {$text}
"; - } - } - -} diff --git a/library/Zend/Markup/Renderer/Markup/HTML/Replace.php b/library/Zend/Markup/Renderer/Markup/HTML/Replace.php deleted file mode 100644 index ace0e89c8a9..00000000000 --- a/library/Zend/Markup/Renderer/Markup/HTML/Replace.php +++ /dev/null @@ -1,74 +0,0 @@ -_replace = $replace; - } - - /** - * Invoke the markup on the token - * - * @param \Zend\Markup\Token $token - * @param string $text - * - * @return string - */ - public function __invoke(Markup\Token $token, $text) - { - return "<{$this->_replace}>{$text}_replace}>"; - } -} diff --git a/library/Zend/Markup/Renderer/Markup/HTML/URL.php b/library/Zend/Markup/Renderer/Markup/HTML/URL.php deleted file mode 100644 index 18132e39b78..00000000000 --- a/library/Zend/Markup/Renderer/Markup/HTML/URL.php +++ /dev/null @@ -1,77 +0,0 @@ -hasAttribute('url')) { - $uri = $token->getAttribute('url'); - } else { - $uri = $text; - } - - if (!preg_match('/^([a-z][a-z+\-.]*):/i', $uri)) { - $uri = 'http://' . $uri; - } - - // check if the URL is valid - // TODO: use the new Zend\Uri for this - if (!\Zend\Markup\Renderer\HTML::isValidUri($uri)) { - return $text; - } - - $attributes = $this->renderAttributes($token); - - // run the URI through htmlentities - $uri = htmlentities($uri, ENT_QUOTES, $this->getEncoding()); - - return "{$text}"; - } -} diff --git a/library/Zend/OAuth/Config/StandardConfig.php b/library/Zend/OAuth/Config/StandardConfig.php index 4b08b819da5..11e74791213 100644 --- a/library/Zend/OAuth/Config/StandardConfig.php +++ b/library/Zend/OAuth/Config/StandardConfig.php @@ -293,7 +293,7 @@ public function setSignatureMethod($method) . $method . '. Supported are HMAC-SHA1, RSA-SHA1, PLAINTEXT and HMAC-SHA256'); } - $this->_signatureMethod = $method;; + $this->_signatureMethod = $method; return $this; } diff --git a/library/Zend/Reflection/ReflectionFile.php b/library/Zend/Reflection/ReflectionFile.php index 1fac5c65de1..7e4ff77a6a4 100644 --- a/library/Zend/Reflection/ReflectionFile.php +++ b/library/Zend/Reflection/ReflectionFile.php @@ -370,7 +370,7 @@ protected function _reflect() // Name of something case T_STRING: if ($functionTrapped) { - $this->_functions[] = ($this->_namespace) ? $this->_namespace . $value : $value;; + $this->_functions[] = ($this->_namespace) ? $this->_namespace . $value : $value; $functionTrapped = false; } elseif ($classTrapped) { $this->_classes[] = ($this->_namespace) ? $this->_namespace . $value : $value; diff --git a/library/Zend/Serializer/Serializer.php b/library/Zend/Serializer/Serializer.php index f8cde1ebbbf..31a06d05b98 100644 --- a/library/Zend/Serializer/Serializer.php +++ b/library/Zend/Serializer/Serializer.php @@ -45,7 +45,7 @@ class Serializer * * @var string|Zend\Serializer\Adapter */ - protected static $_defaultAdapter = 'PHPSerialize'; + protected static $_defaultAdapter = 'PhpSerialize'; /** * Create a serializer adapter instance. diff --git a/library/Zend/Service/Amazon/Amazon.php b/library/Zend/Service/Amazon/Amazon.php index 80c7ca5a1ab..c0adf55710a 100644 --- a/library/Zend/Service/Amazon/Amazon.php +++ b/library/Zend/Service/Amazon/Amazon.php @@ -229,7 +229,7 @@ protected function _prepareOptions($query, array $options, array $defaultOptions $options = array_merge($defaultOptions, $options); if($this->_secretKey !== null) { - $options['Timestamp'] = gmdate("Y-m-d\TH:i:s\Z");; + $options['Timestamp'] = gmdate("Y-m-d\TH:i:s\Z"); ksort($options); $options['Signature'] = self::computeSignature($this->_baseUri, $this->_secretKey, $options); } diff --git a/library/Zend/Service/LiveDocx/AbstractLiveDocx.php b/library/Zend/Service/LiveDocx/AbstractLiveDocx.php index 0817361dbe3..733d9abac44 100644 --- a/library/Zend/Service/LiveDocx/AbstractLiveDocx.php +++ b/library/Zend/Service/LiveDocx/AbstractLiveDocx.php @@ -23,12 +23,12 @@ * @namespace */ namespace Zend\Service\LiveDocx; - -use Zend\Soap\Client as SoapClient; +use Zend\Service\LiveDocx\Exception; +use Zend\Soap\Client\Client; /** * @uses Exception - * @uses Zend\Soap\Client + * @uses Zend\Soap\Client\Client * @category Zend * @package Zend_Service * @subpackage LiveDocx @@ -46,7 +46,7 @@ abstract class AbstractLiveDocx /** * SOAP client used to connect to LiveDocx service - * @var Zend\Soap\Client + * @var Zend\Soap\Client\Client * @since LiveDocx 1.0 */ protected $_soapClient; @@ -135,14 +135,14 @@ public function __destruct() */ protected function _initSoapClient($endpoint) { - $this->_soapClient = new SoapClient(); + $this->_soapClient = new Client(); $this->_soapClient->setWSDL($endpoint); } /** * Get SOAP client * - * @return Zend\Soap\Client + * @return Zend\Soap\Client\Client * @since LiveDocx 1.2 */ public function getSoapClient() @@ -153,7 +153,7 @@ public function getSoapClient() /** * Set SOAP client * - * @param Zend\Soap\Client $soapClient + * @param Zend\Soap\Client\Client $soapClient * @return Zend\Service\AbstractLiveDocx * @since LiveDocx 1.2 */ diff --git a/library/Zend/Service/LiveDocx/MailMerge.php b/library/Zend/Service/LiveDocx/MailMerge.php index 76beb6ff004..161a0b5a16b 100644 --- a/library/Zend/Service/LiveDocx/MailMerge.php +++ b/library/Zend/Service/LiveDocx/MailMerge.php @@ -43,7 +43,7 @@ class MailMerge extends AbstractLiveDocx * URI of LiveDocx.MailMerge WSDL * @since LiveDocx 1.0 */ - const WSDL = 'https://api.livedocx.com/2.0/mailmerge.asmx?WSDL'; + const WSDL = 'https://api.livedocx.com/1.2/mailmerge.asmx?WSDL'; /** * Field values @@ -366,7 +366,7 @@ public function setDocumentAccessPermissions($permissions, $password) /** * Merge assigned data with template to generate document * - * @throws Zend\Service\LiveDocx\Exception + * @throws Zend_Service_LiveDocx_Excpetion * @return void * @since LiveDocx 1.0 */ @@ -888,6 +888,27 @@ public function getDocumentFormats() return $ret; } + + /* + * Return supported image formats (lowercase) + * + * @return array + * @since LiveDocx 1.2 + */ + public function getImageFormats() + { + $this->logIn(); + + $ret = array(); + $result = $this->getSoapClient()->GetImageFormats(); + + if (isset($result->GetImageFormatsResult->string)) { + $ret = $result->GetImageFormatsResult->string; + $ret = array_map('strtolower', $ret); + } + + return $ret; + } /** * Return the names of all fonts that are installed on backend server @@ -927,180 +948,7 @@ public function getDocumentAccessOptions() } return $ret; - } - - /** - * Return supported image formats from which can be imported (lowercase) - * - * @return array - * @since LiveDocx 2.0 - */ - public function getImageImportFormats() - { - $this->logIn(); - - $ret = array(); - $result = $this->getSoapClient()->GetImageImportFormats(); - - if (isset($result->GetImageImportFormatsResult->string)) { - $ret = $result->GetImageImportFormatsResult->string; - $ret = array_map('strtolower', $ret); - } - - return $ret; - } - - /** - * Return supported image formats to which can be exported (lowercase) - * - * @return array - * @since LiveDocx 2.0 - */ - public function getImageExportFormats() - { - $this->logIn(); - - $ret = array(); - $result = $this->getSoapClient()->GetImageExportFormats(); - - if (isset($result->GetImageExportFormatsResult->string)) { - $ret = $result->GetImageExportFormatsResult->string; - $ret = array_map('strtolower', $ret); - } - - return $ret; - } - - /* - * Return supported image formats (lowercase) - * - * @return array - * @since LiveDocx 1.2 - * @deprecated since LiveDocx 2.0 - */ - public function getImageFormats() - { - $replacement = 'getImageExportFormats'; - - $errorMessage = sprintf( - "%s::%s is deprecated as of LiveDocx 2.0. " - . "It has been replaced by %s::%s() (drop in replacement)", - __CLASS__, __FUNCTION__, __CLASS__, $replacement); - - trigger_error($errorMessage, E_USER_NOTICE); - - return $this->$replacement(); - } - - /** - * Upload an image file to LiveDocx service - * - * @param string $filename - * @return void - * @throws Zend\Service\LiveDocx\Exception - * @since LiveDocx 2.0 - */ - public function uploadImage($filename) - { - if (!is_readable($filename)) { - throw new Exception( - 'Cannot read image file from disk.' - ); - } - - $this->logIn(); - - try { - $this->getSoapClient()->UploadImage(array( - 'image' => base64_encode(file_get_contents($filename)), - 'filename' => basename($filename), - )); - } catch (Exception $e) { - throw new Exception( - 'Cannot upload image' - ); - } - } - - /** - * Download an image file from LiveDocx service - * - * @param string $filename - * @return void - * @throws Zend\Service\LiveDocx\Exception - * @since LiveDocx 2.0 - */ - public function downloadImage($filename) - { - $this->logIn(); - - try { - $result = $this->getSoapClient()->DownloadImage(array( - 'filename' => basename($filename), - )); - } catch (Exception $e) { - throw new Exception( - 'Cannot download image' - ); - } - - return base64_decode($result->DownloadImageResult); - } - - /** - * List all images stored on LiveDocx service - * - * @return array - * @since LiveDocx 2.0 - */ - public function listImages() - { - $this->logIn(); - - $ret = array(); - $result = $this->getSoapClient()->ListImages(); - - if (isset($result->ListImagesResult)) { - $ret = $this->_backendListArrayToMultiAssocArray($result->ListImagesResult); - } - - return $ret; - } - - /** - * Delete an image file from LiveDocx service - * - * @param string $filename - * @return void - * @throws Zend\Service\LiveDocx\Exception - * @since LiveDocx 2.0 - */ - public function deleteImage($filename) - { - $this->logIn(); - - $this->getSoapClient()->DeleteImage(array( - 'filename' => basename($filename), - )); - } - - /** - * Check whether an image file is available on LiveDocx service - * - * @param string $filename - * @return boolean - * @since LiveDocx 2.0 - */ - public function imageExists($filename) - { - $this->logIn(); - - $result = $this->getSoapClient()->ImageExists(array( - 'filename' => basename($filename), - )); - - return (boolean) $result->ImageExistsResult; - } + } /** * Convert LiveDocx service return value from list methods to consistent PHP array @@ -1111,8 +959,9 @@ public function imageExists($filename) */ protected function _backendListArrayToMultiAssocArray($list) { - $ret = array(); + $this->logIn(); + $ret = array(); if (isset($list->ArrayOfString)) { foreach ($list->ArrayOfString as $a) { if (is_array($a)) { // 1 template only diff --git a/library/Zend/Session/Container.php b/library/Zend/Session/Container.php index 4c1e8bf652f..6ec97f63412 100644 --- a/library/Zend/Session/Container.php +++ b/library/Zend/Session/Container.php @@ -183,14 +183,18 @@ protected function _createContainer() * If not, it raises an exception; otherwise, it returns the Storage * object. * - * @return Storage + * @param bool $createContainer Whether or not to create the container for the namespace + * @return Storage|null Returns null only if $createContainer is false * @throws Exception */ - protected function _verifyNamespace() + protected function _verifyNamespace($createContainer = true) { $storage = $this->_getStorage(); $name = $this->getName(); if (!isset($storage[$name])) { + if (!$createContainer) { + return; + } $storage[$name] = $this->_createContainer(); } if (!is_array($storage[$name]) && !$storage[$name] instanceof ArrayObject) { @@ -204,16 +208,16 @@ protected function _verifyNamespace() * * Returns true if the key has expired, false otherwise. * - * @param string $key + * @param null|string $key * @return bool */ - protected function _expireKeys($key) + protected function _expireKeys($key = null) { $storage = $this->_verifyNamespace(); $name = $this->getName(); // Return early if key not found - if (!isset($storage[$name][$key])) { + if ((null !== $key) && !isset($storage[$name][$key])) { return true; } @@ -242,6 +246,8 @@ protected function _expireKeys($key) protected function _expireByExpiryTime(Storage $storage, $name, $key) { $metadata = $storage->getMetadata($name); + + // Global container expiry if (is_array($metadata) && isset($metadata['EXPIRE']) && ($_SERVER['REQUEST_TIME'] > $metadata['EXPIRE']) @@ -252,7 +258,9 @@ protected function _expireByExpiryTime(Storage $storage, $name, $key) return true; } - if (is_array($metadata) + // Expire individual key + if ((null !== $key) + && is_array($metadata) && isset($metadata['EXPIRE_KEYS']) && isset($metadata['EXPIRE_KEYS'][$key]) && ($_SERVER['REQUEST_TIME'] > $metadata['EXPIRE_KEYS'][$key]) @@ -263,6 +271,23 @@ protected function _expireByExpiryTime(Storage $storage, $name, $key) return true; } + // Find any keys that have expired + if ((null === $key) + && is_array($metadata) + && isset($metadata['EXPIRE_KEYS']) + ) { + foreach (array_keys($metadata['EXPIRE_KEYS']) as $key) { + if ($_SERVER['REQUEST_TIME'] > $metadata['EXPIRE_KEYS'][$key]) { + unset($metadata['EXPIRE_KEYS'][$key]); + if (isset($storage[$name][$key])) { + unset($storage[$name][$key]); + } + } + } + $storage->setMetadata($name, $metadata, true); + return true; + } + return false; } @@ -281,6 +306,8 @@ protected function _expireByHops(Storage $storage, $name, $key) { $ts = $storage->getRequestAccessTime(); $metadata = $storage->getMetadata($name); + + // Global container expiry if (is_array($metadata) && isset($metadata['EXPIRE_HOPS']) && ($ts > $metadata['EXPIRE_HOPS']['ts']) @@ -297,7 +324,9 @@ protected function _expireByHops(Storage $storage, $name, $key) return false; } - if (is_array($metadata) + // Single key expiry + if ((null !== $key) + && is_array($metadata) && isset($metadata['EXPIRE_HOPS_KEYS']) && isset($metadata['EXPIRE_HOPS_KEYS'][$key]) && ($ts > $metadata['EXPIRE_HOPS_KEYS'][$key]['ts']) @@ -314,6 +343,27 @@ protected function _expireByHops(Storage $storage, $name, $key) return false; } + // Find all expired keys + if ((null === $key) + && is_array($metadata) + && isset($metadata['EXPIRE_HOPS_KEYS']) + ) { + foreach (array_keys($metadata['EXPIRE_HOPS_KEYS']) as $key) { + if ($ts > $metadata['EXPIRE_HOPS_KEYS'][$key]['ts']) { + $metadata['EXPIRE_HOPS_KEYS'][$key]['hops']--; + if (-1 === $metadata['EXPIRE_HOPS_KEYS'][$key]['hops']) { + unset($metadata['EXPIRE_HOPS_KEYS'][$key]); + $storage->setMetadata($name, $metadata, true); + unset($storage[$name][$key]); + continue; + } + $metadata['EXPIRE_HOPS_KEYS'][$key]['ts'] = $ts; + } + } + $storage->setMetadata($name, $metadata, true); + return false; + } + return false; } @@ -340,7 +390,10 @@ public function offsetSet($key, $value) */ public function offsetExists($key) { - $storage = $this->_verifyNamespace(); + // If no container exists, we can't inspect it + if (null === ($storage = $this->_verifyNamespace(false))) { + return false; + } $name = $this->getName(); // Return early if the key isn't set @@ -384,6 +437,19 @@ public function offsetUnset($key) unset($storage[$name][$key]); } + /** + * Iterate over session container + * + * @return Iterator + */ + public function getIterator() + { + $this->_expireKeys(); + $storage = $this->_getStorage(); + $container = $storage[$this->getName()]; + return $container->getIterator(); + } + /** * Set expiration TTL * diff --git a/library/Zend/Session/SessionManager.php b/library/Zend/Session/SessionManager.php index d84c6c2ee8e..9827f4e4cfe 100644 --- a/library/Zend/Session/SessionManager.php +++ b/library/Zend/Session/SessionManager.php @@ -100,6 +100,16 @@ public function start() if (!$this->isValid()) { throw new Exception\RuntimeException('Session failed validation'); } + $storage = $this->getStorage(); + + // Since session is starting, we need to potentially repopulate our + // session storage + if ($storage instanceof Storage\SessionStorage + && $_SESSION !== $storage + ) { + $storage->fromArray($_SESSION); + $_SESSION = $storage; + } } /** diff --git a/library/Zend/SignalSlot/GlobalSignals.php b/library/Zend/SignalSlot/GlobalSignals.php index 17a89e85b18..dca14d7a0f7 100644 --- a/library/Zend/SignalSlot/GlobalSignals.php +++ b/library/Zend/SignalSlot/GlobalSignals.php @@ -98,7 +98,7 @@ public static function emitUntil($callback, $signal, $args = null) $signals = self::getInstance(); $args = func_get_args(); $args = array_slice($args, 2); - return call_user_func(array($signals, 'emitUntil'), $callback, $signal, $args); + return $signals->emitUntil($callback, $signal, $args); } /** diff --git a/library/Zend/Soap/Client.php b/library/Zend/Soap/Client.php index fe012dfedef..b42e7a5f2fe 100644 --- a/library/Zend/Soap/Client.php +++ b/library/Zend/Soap/Client.php @@ -962,11 +962,10 @@ public function getLastMethod() public function _doRequest(Client\Common $client, $request, $location, $action, $version, $one_way = null) { // Perform request as is - if ($one_way == null) { - return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version); - } else { - return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version, $one_way); + if ($one_way === null) { + return $client->__doRequest($request, $location, $action, $version); } + return $client->__doRequest($request, $location, $action, $version, $one_way); } /** diff --git a/library/Zend/Stdlib/SignalHandler.php b/library/Zend/Stdlib/SignalHandler.php index a5b1ea3054a..21151d96e3f 100644 --- a/library/Zend/Stdlib/SignalHandler.php +++ b/library/Zend/Stdlib/SignalHandler.php @@ -141,10 +141,11 @@ protected function _validateStringCallback($callback) throw new InvalidCallbackException('Provided callback is not a function or a class'); } - $object = new $callback(); - if (!is_callable($object)) { + // check __invoke before instantiating + if (!method_exists($callback, '__invoke')) { throw new InvalidCallbackException('Class provided as a callback does not implement __invoke'); } + $object = new $callback(); $this->_callback = $object; $this->_isValidCallback = true; diff --git a/library/Zend/Tag/Cloud/Decorator/HTMLCloud.php b/library/Zend/Tag/Cloud/Decorator/HTMLCloud.php deleted file mode 100644 index c2a4cef793a..00000000000 --- a/library/Zend/Tag/Cloud/Decorator/HTMLCloud.php +++ /dev/null @@ -1,156 +0,0 @@ - array('class' => 'Zend_Tag_Cloud') - ); - - /** - * Separator for the single tags - * - * @var string - */ - protected $_separator = ' '; - - /** - * Get encoding - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Set encoding - * - * @param string - * @return \Zend\Tag\Cloud\Decorator\HTMLCloud - */ - public function setEncoding($value) - { - $this->_encoding = (string) $value; - return $this; - } - - /** - * Set the HTML tags surrounding all tags - * - * @param array $htmlTags - * @return \Zend\Tag\Cloud\Decorator\HTMLCloud - */ - public function setHTMLTags(array $htmlTags) - { - $this->_htmlTags = $htmlTags; - return $this; - } - - /** - * Retrieve HTML tag map - * - * @return array - */ - public function getHTMLTags() - { - return $this->_htmlTags; - } - - /** - * Set the separator between the single tags - * - * @param string - * @return \Zend\Tag\Cloud\Decorator\HTMLCloud - */ - public function setSeparator($separator) - { - $this->_separator = $separator; - return $this; - } - - /** - * Get tag separator - * - * @return string - */ - public function getSeparator() - { - return $this->_separator; - } - - /** - * Defined by Zend_Tag_Cloud_Decorator_Cloud - * - * @param array $tags - * @return string - */ - public function render(array $tags) - { - $cloudHTML = implode($this->getSeparator(), $tags); - - $enc = $this->getEncoding(); - foreach ($this->getHTMLTags() as $key => $data) { - if (is_array($data)) { - $htmlTag = $key; - $attributes = ''; - - foreach ($data as $param => $value) { - $attributes .= ' ' . $param . '="' . htmlspecialchars($value, ENT_COMPAT, $enc) . '"'; - } - } else { - $htmlTag = $data; - $attributes = ''; - } - - $cloudHTML = sprintf('<%1$s%3$s>%2$s', $htmlTag, $cloudHTML, $attributes); - } - - return $cloudHTML; - } -} diff --git a/library/Zend/Tag/Cloud/Decorator/HTMLTag.php b/library/Zend/Tag/Cloud/Decorator/HTMLTag.php deleted file mode 100644 index c88d3ebdffc..00000000000 --- a/library/Zend/Tag/Cloud/Decorator/HTMLTag.php +++ /dev/null @@ -1,303 +0,0 @@ -_classList = $classList; - return $this; - } - - /** - * Get class list - * - * @return array - */ - public function getClassList() - { - return $this->_classList; - } - - /** - * Get encoding - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Set encoding - * - * @param string $value - * @return \Zend\Tag\Cloud\Decorator\HTMLTag - */ - public function setEncoding($value) - { - $this->_encoding = (string) $value; - return $this; - } - - /** - * Set the font size unit - * - * Possible values are: em, ex, px, in, cm, mm, pt, pc and % - * - * @param string $fontSizeUnit - * @throws \Zend\Tag\Cloud\Decorator\Exception When an invalid fontsize unit is specified - * @return \Zend\Tag\Cloud\Decorator\HTMLTag - */ - public function setFontSizeUnit($fontSizeUnit) - { - if (!in_array($fontSizeUnit, $this->_alloweFontSizeUnits)) { - throw new Exception('Invalid fontsize unit specified'); - } - - $this->_fontSizeUnit = (string) $fontSizeUnit; - $this->setClassList(null); - return $this; - } - - /** - * Retrieve font size unit - * - * @return string - */ - public function getFontSizeUnit() - { - return $this->_fontSizeUnit; - } - /** - * Set the HTML tags surrounding the element - * - * @param array $htmlTags - * @return \Zend\Tag\Cloud\Decorator\HTMLTag - */ - public function setHTMLTags(array $htmlTags) - { - $this->_htmlTags = $htmlTags; - return $this; - } - - /** - * Get HTML tags map - * - * @return array - */ - public function getHTMLTags() - { - return $this->_htmlTags; - } - - /** - * Set maximum font size - * - * @param integer $maxFontSize - * @throws \Zend\Tag\Cloud\Decorator\Exception When fontsize is not numeric - * @return \Zend\Tag\Cloud\Decorator\HTMLTag - */ - public function setMaxFontSize($maxFontSize) - { - if (!is_numeric($maxFontSize)) { - throw new Exception('Fontsize must be numeric'); - } - - $this->_maxFontSize = (int) $maxFontSize; - $this->setClassList(null); - return $this; - } - - /** - * Retrieve maximum font size - * - * @return int - */ - public function getMaxFontSize() - { - return $this->_maxFontSize; - } - - /** - * Set minimum font size - * - * @param int $minFontSize - * @throws \Zend\Tag\Cloud\Decorator\Exception When fontsize is not numeric - * @return \Zend\Tag\Cloud\Decorator\HTMLTag - */ - public function setMinFontSize($minFontSize) - { - if (!is_numeric($minFontSize)) { - throw new Exception('Fontsize must be numeric'); - } - - $this->_minFontSize = (int) $minFontSize; - $this->setClassList(null); - return $this; - } - - /** - * Retrieve minimum font size - * - * @return int - */ - public function getMinFontSize() - { - return $this->_minFontSize; - } - - /** - * Defined by Zend_Tag_Cloud_Decorator_Tag - * - * @param \Zend\Tag\ItemList $tags - * @return array - */ - public function render(\Zend\Tag\ItemList $tags) - { - if (null === ($weightValues = $this->getClassList())) { - $weightValues = range($this->getMinFontSize(), $this->getMaxFontSize()); - } - - $tags->spreadWeightValues($weightValues); - - $result = array(); - - $enc = $this->getEncoding(); - foreach ($tags as $tag) { - if (null === ($classList = $this->getClassList())) { - $attribute = sprintf('style="font-size: %d%s;"', $tag->getParam('weightValue'), $this->getFontSizeUnit()); - } else { - $attribute = sprintf('class="%s"', htmlspecialchars($tag->getParam('weightValue'), ENT_COMPAT, $enc)); - } - - $tagHTML = sprintf('%s', htmlSpecialChars($tag->getParam('url'), ENT_COMPAT, $enc), $attribute, $tag->getTitle()); - - foreach ($this->getHTMLTags() as $key => $data) { - if (is_array($data)) { - $htmlTag = $key; - $attributes = ''; - - foreach ($data as $param => $value) { - $attributes .= ' ' . $param . '="' . htmlspecialchars($value, ENT_COMPAT, $enc) . '"'; - } - } else { - $htmlTag = $data; - $attributes = ''; - } - - $tagHTML = sprintf('<%1$s%3$s>%2$s', $htmlTag, $tagHTML, $attributes); - } - - $result[] = $tagHTML; - } - - return $result; - } -} diff --git a/library/Zend/Tool/Project/Context/Content/Engine/CodeGenerator.php b/library/Zend/Tool/Project/Context/Content/Engine/CodeGenerator.php index 494d2bad89b..c5633cc0a77 100644 --- a/library/Zend/Tool/Project/Context/Content/Engine/CodeGenerator.php +++ b/library/Zend/Tool/Project/Context/Content/Engine/CodeGenerator.php @@ -31,7 +31,7 @@ * A profile is a hierarchical set of resources that keep track of * items within a specific project. * - * @uses \Zend\CodeGenerator\PHP\PHPFile + * @uses \Zend\CodeGenerator\Php\PhpFile * @uses \Zend\Tool\Project\Exception * @category Zend * @package Zend_Tool @@ -89,7 +89,7 @@ public function getContent(Context $context, $method, $parameters) if (method_exists($context, 'getCodeGenerator')) { $codeGenerator = $context->getCodeGenerator(); } else { - $codeGenerator = new \Zend\CodeGenerator\PHP\PHPFile(); + $codeGenerator = new \Zend\CodeGenerator\Php\PhpFile(); } $codeGenerator = include $streamUri; diff --git a/library/Zend/Tool/Project/Context/Filesystem/File.php b/library/Zend/Tool/Project/Context/Filesystem/File.php index 34efed929bd..141b6c51fa6 100644 --- a/library/Zend/Tool/Project/Context/Filesystem/File.php +++ b/library/Zend/Tool/Project/Context/Filesystem/File.php @@ -164,7 +164,7 @@ protected function _initFileOnlyContext() if ($this->_resource->hasAttribute('defaultContentCallback')) { $contentFunc = $this->_resource->getAttribute('defaultContentCallback'); if (is_callable($contentFunc)) { - $this->_content = call_user_func_array($contentFunc, array($this)); + $this->_content = call_user_func($contentFunc, $this); } } if ($this->_filesystemName == null) { diff --git a/library/Zend/Tool/Project/Context/Zf/AbstractClassFile.php b/library/Zend/Tool/Project/Context/Zf/AbstractClassFile.php index 15650ee8928..cca291e1208 100644 --- a/library/Zend/Tool/Project/Context/Zf/AbstractClassFile.php +++ b/library/Zend/Tool/Project/Context/Zf/AbstractClassFile.php @@ -68,13 +68,13 @@ public function getFullClassName($localClassName, $classContextName = null) $prefix = $containingResource->getAttribute('classNamePrefix'); $fullClassName = $prefix; } elseif ($containingResource->getName() == 'ModuleDirectory') { - $prefix = $containingResource->getAttribute('moduleName') . '_'; + $prefix = $containingResource->getAttribute('moduleName') . '\\'; $fullClassName = $prefix; } } if ($classContextName) { - $fullClassName .= rtrim($classContextName, '_') . '_'; + $fullClassName .= rtrim($classContextName, '\\') . '\\'; } $fullClassName .= $localClassName; diff --git a/library/Zend/Tool/Project/Context/Zf/ActionMethod.php b/library/Zend/Tool/Project/Context/Zf/ActionMethod.php index 66d81d3d523..f7442da21cd 100644 --- a/library/Zend/Tool/Project/Context/Zf/ActionMethod.php +++ b/library/Zend/Tool/Project/Context/Zf/ActionMethod.php @@ -23,7 +23,6 @@ * @namespace */ namespace Zend\Tool\Project\Context\Zf; - use Zend\Tool\Project\Context\Context, Zend\CodeGenerator\Php, Zend\Tool\Project\Context\Exception; @@ -34,7 +33,7 @@ * A profile is a hierarchical set of resources that keep track of * items within a specific project. * - * @uses \Zend\CodeGenerator\PHP\PHPFile + * @uses \Zend\CodeGenerator\Php\PhpFile * @uses \Zend\Reflection\ReflectionFile * @uses \Zend\Tool\Project\Context\Exception * @uses \Zend\Tool\Project\Context @@ -185,7 +184,7 @@ public static function createActionMethod($controllerPath, $actionName, $body = return false; } - $controllerCodeGenFile = PHP\PHPFile::fromReflectedFileName($controllerPath, true, true); + $controllerCodeGenFile = Php\PhpFile::fromReflectedFileName($controllerPath, true, true); $controllerCodeGenFile->getClass()->setMethod(array( 'name' => $actionName . 'Action', 'body' => $body @@ -208,7 +207,7 @@ public static function hasActionMethod($controllerPath, $actionName) return false; } - $controllerCodeGenFile = PHP\PHPFile::fromReflectedFileName($controllerPath, true, true); + $controllerCodeGenFile = Php\PhpFile::fromReflectedFileName($controllerPath, true, true); return $controllerCodeGenFile->getClass()->hasMethod($actionName . 'Action'); } diff --git a/library/Zend/Tool/Project/Context/Zf/ApplicationDirectory.php b/library/Zend/Tool/Project/Context/Zf/ApplicationDirectory.php index f4a8af8b94e..6df10bc0e3b 100644 --- a/library/Zend/Tool/Project/Context/Zf/ApplicationDirectory.php +++ b/library/Zend/Tool/Project/Context/Zf/ApplicationDirectory.php @@ -42,7 +42,7 @@ class ApplicationDirectory protected $_filesystemName = 'application'; - protected $_classNamePrefix = 'Application_'; + protected $_classNamePrefix = 'Application\\'; public function init() { diff --git a/library/Zend/Tool/Project/Context/Zf/BootstrapFile.php b/library/Zend/Tool/Project/Context/Zf/BootstrapFile.php index 480fa99f44a..3d33b25aea3 100644 --- a/library/Zend/Tool/Project/Context/Zf/BootstrapFile.php +++ b/library/Zend/Tool/Project/Context/Zf/BootstrapFile.php @@ -32,8 +32,8 @@ * items within a specific project. * * @uses \Zend\Application\Application - * @uses \Zend\CodeGenerator\PHP\PHPClass - * @uses \Zend\CodeGenerator\PHP\PHPFile + * @uses \Zend\CodeGenerator\Php\PhpClass + * @uses \Zend\CodeGenerator\Php\PhpFile * @uses \Zend\Tool\Project\Context\Filesystem\File * @uses \Zend\Tool\Project\Exception * @category Zend @@ -97,9 +97,9 @@ public function init() public function getContents() { - $codeGenFile = new \Zend\CodeGenerator\PHP\PHPFile(array( + $codeGenFile = new \Zend\CodeGenerator\Php\PhpFile(array( 'classes' => array( - new \Zend\CodeGenerator\PHP\PHPClass(array( + new \Zend\CodeGenerator\Php\PhpClass(array( 'name' => 'Bootstrap', 'extendedClass' => '\Zend\Application\Bootstrap', )), diff --git a/library/Zend/Tool/Project/Context/Zf/ControllerFile.php b/library/Zend/Tool/Project/Context/Zf/ControllerFile.php index 0fdba2a537b..a76f0d809c6 100644 --- a/library/Zend/Tool/Project/Context/Zf/ControllerFile.php +++ b/library/Zend/Tool/Project/Context/Zf/ControllerFile.php @@ -23,7 +23,7 @@ * @namespace */ namespace Zend\Tool\Project\Context\Zf; -use Zend\CodeGenerator\PHP; +use Zend\CodeGenerator\Php; /** * This class is the front most class for utilizing Zend_Tool_Project @@ -31,9 +31,9 @@ * A profile is a hierarchical set of resources that keep track of * items within a specific project. * - * @uses \Zend\CodeGenerator\PHP\PHPClass - * @uses \Zend\CodeGenerator\PHP\PHPFile - * @uses \Zend\CodeGenerator\PHP\PHPMethod + * @uses \Zend\CodeGenerator\Php\PhpClass + * @uses \Zend\CodeGenerator\Php\PhpFile + * @uses \Zend\CodeGenerator\Php\PhpMethod * @category Zend * @package Zend_Tool * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) @@ -108,17 +108,17 @@ public function getControllerName() */ public function getContents() { - $className = ($this->_moduleName) ? ucfirst($this->_moduleName) . '_' : ''; + $className = ($this->_moduleName) ? ucfirst($this->_moduleName) . '\\' : ''; $className .= ucfirst($this->_controllerName) . 'Controller'; - $codeGenFile = new PHP\PHPFile(array( + $codeGenFile = new Php\PhpFile(array( 'fileName' => $this->getPath(), 'classes' => array( - new PHP\PHPClass(array( + new Php\PhpClass(array( 'name' => $className, 'extendedClass' => '\Zend\Controller\Action', 'methods' => array( - new PHP\PHPMethod(array( + new Php\PhpMethod(array( 'name' => 'init', 'body' => '/* Initialize action controller here */', )) @@ -130,14 +130,14 @@ public function getContents() if ($className == 'ErrorController') { - $codeGenFile = new PHP\PHPFile(array( + $codeGenFile = new Php\PhpFile(array( 'fileName' => $this->getPath(), 'classes' => array( - new PHP\PHPClass(array( + new Php\PhpClass(array( 'name' => $className, 'extendedClass' => 'Zend\Controller\Action', 'methods' => array( - new PHP\PHPMethod(array( + new Php\PhpMethod(array( 'name' => 'errorAction', 'body' => <<<'EOS' $errors = $this->_getParam('error_handler'); @@ -171,7 +171,7 @@ public function getContents() $this->view->request = $errors->request; EOS )), - new PHP\PHPMethod(array( + new Php\PhpMethod(array( 'name' => 'getLog', 'body' => <<<'EOS' $bootstrap = $this->getInvokeArg('bootstrap'); @@ -190,7 +190,7 @@ public function getContents() } // store the generator into the registry so that the addAction command can use the same object later - PHP\PHPFile::registerFileCodeGenerator($codeGenFile); // REQUIRES filename to be set + Php\PhpFile::registerFileCodeGenerator($codeGenFile); // REQUIRES filename to be set return $codeGenFile->generate(); } @@ -209,11 +209,11 @@ public function addAction($actionName) /** * getCodeGenerator() * - * @return \Zend\CodeGenerator\PHP\PHPClass + * @return \Zend\CodeGenerator\Php\PhpClass */ public function getCodeGenerator() { - $codeGenFile = PHP\PHPFile::fromReflectedFileName($this->getPath()); + $codeGenFile = Php\PhpFile::fromReflectedFileName($this->getPath()); $codeGenFileClasses = $codeGenFile->getClasses(); $class = array_shift($codeGenFileClasses); return $class; diff --git a/library/Zend/Tool/Project/Context/Zf/DbTableFile.php b/library/Zend/Tool/Project/Context/Zf/DbTableFile.php index ce2158b9cb7..105133c57e5 100644 --- a/library/Zend/Tool/Project/Context/Zf/DbTableFile.php +++ b/library/Zend/Tool/Project/Context/Zf/DbTableFile.php @@ -23,7 +23,7 @@ * @namespace */ namespace Zend\Tool\Project\Context\Zf; -use Zend\CodeGenerator\PHP; +use Zend\CodeGenerator\Php; /** * This class is the front most class for utilizing Zend_Tool_Project @@ -31,9 +31,9 @@ * A profile is a hierarchical set of resources that keep track of * items within a specific project. * - * @uses \Zend\CodeGenerator\PHP\PHPClass - * @uses \Zend\CodeGenerator\PHP\PHPFile - * @uses \Zend\CodeGenerator\PHP\PHPProperty + * @uses \Zend\CodeGenerator\Php\PhpClass + * @uses \Zend\CodeGenerator\Php\PhpFile + * @uses \Zend\CodeGenerator\Php\PhpProperty * @uses \Zend\Tool\Project\Context\Zf\AbstractClassFile * @category Zend * @package Zend_Tool @@ -76,18 +76,18 @@ public function getPersistentAttributes() public function getContents() { - $className = $this->getFullClassName($this->_dbTableName, 'Model_DbTable'); + $className = $this->getFullClassName($this->_dbTableName, 'Model\DbTable'); - $codeGenFile = new PHP\PHPFile(array( + $codeGenFile = new Php\PhpFile(array( 'fileName' => $this->getPath(), 'classes' => array( - new PHP\PHPClass(array( + new Php\PhpClass(array( 'name' => $className, - 'extendedClass' => 'Zend_Db_Table_Abstract', + 'extendedClass' => '\Zend\Db\Table\AbstractTable', 'properties' => array( - new PHP\PHPProperty(array( + new Php\PhpProperty(array( 'name' => '_name', - 'visibility' => PHP\PHPProperty::VISIBILITY_PROTECTED, + 'visibility' => Php\PhpProperty::VISIBILITY_PROTECTED, 'defaultValue' => $this->_actualTableName )) ), diff --git a/library/Zend/Tool/Project/Context/Zf/FormFile.php b/library/Zend/Tool/Project/Context/Zf/FormFile.php index 27c1b021399..1df9b69edd7 100644 --- a/library/Zend/Tool/Project/Context/Zf/FormFile.php +++ b/library/Zend/Tool/Project/Context/Zf/FormFile.php @@ -30,9 +30,9 @@ * A profile is a hierarchical set of resources that keep track of * items within a specific project. * - * @uses \Zend\CodeGenerator\PHP\PHPClass - * @uses \Zend\CodeGenerator\PHP\PHPFile - * @uses \Zend\CodeGenerator\PHP\PHPMethod + * @uses \Zend\CodeGenerator\Php\PhpClass + * @uses \Zend\CodeGenerator\Php\PhpFile + * @uses \Zend\CodeGenerator\Php\PhpMethod * @uses \Zend\Tool\Project\Context\Zf\AbstractClassFile * @category Zend * @package Zend_Tool @@ -95,14 +95,14 @@ public function getContents() $className = $this->getFullClassName($this->_formName, 'Form'); - $codeGenFile = new \Zend\CodeGenerator\PHP\PHPFile(array( + $codeGenFile = new \Zend\CodeGenerator\Php\PhpFile(array( 'fileName' => $this->getPath(), 'classes' => array( - new \Zend\CodeGenerator\PHP\PHPClass(array( + new \Zend\CodeGenerator\Php\PhpClass(array( 'name' => $className, - 'extendedClass' => 'Zend_Form', + 'extendedClass' => '\Zend\Form\Form', 'methods' => array( - new \Zend\CodeGenerator\PHP\PHPMethod(array( + new \Zend\CodeGenerator\Php\PhpMethod(array( 'name' => 'init', 'body' => '/* Form Elements & Other Definitions Here ... */', )) diff --git a/library/Zend/Tool/Project/Context/Zf/ModelFile.php b/library/Zend/Tool/Project/Context/Zf/ModelFile.php index ae73dc12ca6..52e2e631dbd 100644 --- a/library/Zend/Tool/Project/Context/Zf/ModelFile.php +++ b/library/Zend/Tool/Project/Context/Zf/ModelFile.php @@ -30,8 +30,8 @@ * A profile is a hierarchical set of resources that keep track of * items within a specific project. * - * @uses \Zend\CodeGenerator\PHP\PHPClass - * @uses \Zend\CodeGenerator\PHP\PHPFile + * @uses \Zend\CodeGenerator\Php\PhpClass + * @uses \Zend\CodeGenerator\Php\PhpFile * @uses \Zend\Tool\Project\Context\Zf\AbstractClassFile * @category Zend * @package Zend_Tool @@ -94,10 +94,10 @@ public function getContents() $className = $this->getFullClassName($this->_modelName, 'Model'); - $codeGenFile = new \Zend\CodeGenerator\PHP\PHPFile(array( + $codeGenFile = new \Zend\CodeGenerator\Php\PhpFile(array( 'fileName' => $this->getPath(), 'classes' => array( - new \Zend\CodeGenerator\PHP\PHPClass(array( + new \Zend\CodeGenerator\Php\PhpClass(array( 'name' => $className, )) ) diff --git a/library/Zend/Tool/Project/Context/Zf/ProjectProviderFile.php b/library/Zend/Tool/Project/Context/Zf/ProjectProviderFile.php index 440c040d7d7..2d445a1acde 100644 --- a/library/Zend/Tool/Project/Context/Zf/ProjectProviderFile.php +++ b/library/Zend/Tool/Project/Context/Zf/ProjectProviderFile.php @@ -30,9 +30,9 @@ * A profile is a hierarchical set of resources that keep track of * items within a specific project. * - * @uses \Zend\CodeGenerator\PHP\PHPClass - * @uses \Zend\CodeGenerator\PHP\PHPFile - * @uses \Zend\CodeGenerator\PHP\PHPMethod + * @uses \Zend\CodeGenerator\Php\PhpClass + * @uses \Zend\CodeGenerator\Php\PhpFile + * @uses \Zend\CodeGenerator\Php\PhpMethod * @uses \Zend\Filter\Word\DashToCamelCase * @uses \Zend\Tool\Project\Context\Filesystem\File * @category Zend @@ -120,14 +120,14 @@ public function getContents() $className = $filter->filter($this->_projectProviderName) . 'Provider'; - $class = new \Zend\CodeGenerator\PHP\PHPClass(array( + $class = new \Zend\CodeGenerator\Php\PhpClass(array( 'name' => $className, - 'extendedClass' => 'Zend_Tool_Project_Provider_Abstract' + 'extendedClass' => '\Zend\Tool\Project\Provider\AbstractProvider' )); $methods = array(); foreach ($this->_actionNames as $actionName) { - $methods[] = new \Zend\CodeGenerator\PHP\PHPMethod(array( + $methods[] = new \Zend\CodeGenerator\Php\PhpMethod(array( 'name' => $actionName, 'body' => ' /** @todo Implementation */' )); @@ -137,11 +137,7 @@ public function getContents() $class->setMethods($methods); } - $codeGenFile = new \Zend\CodeGenerator\PHP\PHPFile(array( - 'requiredFiles' => array( - 'Zend/Tool/Project/Provider/Abstract.php', - 'Zend/Tool/Project/Provider/Exception.php' - ), + $codeGenFile = new \Zend\CodeGenerator\Php\PhpFile(array( 'classes' => array($class) )); diff --git a/library/Zend/Tool/Project/Context/Zf/PublicIndexFile.php b/library/Zend/Tool/Project/Context/Zf/PublicIndexFile.php index 2f1ab9d0c23..bc268f2a667 100644 --- a/library/Zend/Tool/Project/Context/Zf/PublicIndexFile.php +++ b/library/Zend/Tool/Project/Context/Zf/PublicIndexFile.php @@ -30,7 +30,7 @@ * A profile is a hierarchical set of resources that keep track of * items within a specific project. * - * @uses \Zend\CodeGenerator\PHP\PHPFile + * @uses \Zend\CodeGenerator\Php\PhpFile * @uses \Zend\Tool\Project\Context\Filesystem\File * @category Zend * @package Zend_Tool @@ -62,7 +62,7 @@ public function getName() */ public function getContents() { - $codeGenerator = new \Zend\CodeGenerator\PHP\PHPFile(array( + $codeGenerator = new \Zend\CodeGenerator\Php\PhpFile(array( 'body' => <<<'EOS' // Define path to application directory defined('APPLICATION_PATH') diff --git a/library/Zend/Tool/Project/Context/Zf/TestApplicationControllerFile.php b/library/Zend/Tool/Project/Context/Zf/TestApplicationControllerFile.php index a954404602e..66fc4aa5905 100644 --- a/library/Zend/Tool/Project/Context/Zf/TestApplicationControllerFile.php +++ b/library/Zend/Tool/Project/Context/Zf/TestApplicationControllerFile.php @@ -23,7 +23,7 @@ * @namespace */ namespace Zend\Tool\Project\Context\Zf; -use Zend\CodeGenerator\PHP; +use Zend\CodeGenerator\Php; /** * This class is the front most class for utilizing Zend_Tool_Project @@ -31,9 +31,9 @@ * A profile is a hierarchical set of resources that keep track of * items within a specific project. * - * @uses \Zend\CodeGenerator\PHP\PHPClass - * @uses \Zend\CodeGenerator\PHP\PHPFile - * @uses \Zend\CodeGenerator\PHP\PHPMethod + * @uses \Zend\CodeGenerator\Php\PhpClass + * @uses \Zend\CodeGenerator\Php\PhpFile + * @uses \Zend\CodeGenerator\Php\PhpMethod * @uses \Zend\Filter\Word\DashToCamelCase * @uses \Zend\Tool\Project\Context\Filesystem\File * @category Zend @@ -84,20 +84,20 @@ public function getContents() $className = $filter->filter($this->_forControllerName) . 'ControllerTest'; - $codeGenFile = new PHP\PHPFile(array( + $codeGenFile = new Php\PhpFile(array( 'requiredFiles' => array( 'PHPUnit/Framework/TestCase.php' ), 'classes' => array( - new PHP\PHPClass(array( + new Php\PhpClass(array( 'name' => $className, 'extendedClass' => 'PHPUnit_Framework_TestCase', 'methods' => array( - new PHP\PHPMethod(array( + new Php\PhpMethod(array( 'name' => 'setUp', 'body' => ' /* Setup Routine */' )), - new PHP\PHPMethod(array( + new Php\PhpMethod(array( 'name' => 'tearDown', 'body' => ' /* Tear Down Routine */' )) diff --git a/library/Zend/Tool/Project/Context/Zf/TestLibraryFile.php b/library/Zend/Tool/Project/Context/Zf/TestLibraryFile.php index da86148b844..d53af0a1e08 100644 --- a/library/Zend/Tool/Project/Context/Zf/TestLibraryFile.php +++ b/library/Zend/Tool/Project/Context/Zf/TestLibraryFile.php @@ -23,7 +23,7 @@ * @namespace */ namespace Zend\Tool\Project\Context\Zf; -use Zend\CodeGenerator\PHP; +use Zend\CodeGenerator\Php; /** * This class is the front most class for utilizing Zend_Tool_Project @@ -31,9 +31,9 @@ * A profile is a hierarchical set of resources that keep track of * items within a specific project. * - * @uses \Zend\CodeGenerator\PHP\PHPClass - * @uses \Zend\CodeGenerator\PHP\PHPFile - * @uses \Zend\CodeGenerator\PHP\PHPMethod + * @uses \Zend\CodeGenerator\Php\PhpClass + * @uses \Zend\CodeGenerator\Php\PhpFile + * @uses \Zend\CodeGenerator\Php\PhpMethod * @uses \Zend\Filter\Word\DashToCamelCase * @uses \Zend\Tool\Project\Context\Filesystem\File * @category Zend @@ -84,20 +84,20 @@ public function getContents() $className = $filter->filter($this->_forClassName) . 'Test'; - $codeGenFile = new PHP\PHPFile(array( + $codeGenFile = new Php\PhpFile(array( 'requiredFiles' => array( 'PHPUnit/Framework/TestCase.php' ), 'classes' => array( - new PHP\PHPClass(array( + new Php\PhpClass(array( 'name' => $className, 'extendedClass' => 'PHPUnit_Framework_TestCase', 'methods' => array( - new PHP\PHPMethod(array( + new Php\PhpMethod(array( 'name' => 'setUp', 'body' => ' /* Setup Routine */' )), - new PHP\PHPMethod(array( + new Php\PhpMethod(array( 'name' => 'tearDown', 'body' => ' /* Tear Down Routine */' )) diff --git a/library/Zend/Tool/Project/Profile/Iterator/ContextFilter.php b/library/Zend/Tool/Project/Profile/Iterator/ContextFilter.php index e7fdb226bdf..404df406662 100644 --- a/library/Zend/Tool/Project/Profile/Iterator/ContextFilter.php +++ b/library/Zend/Tool/Project/Profile/Iterator/ContextFilter.php @@ -182,13 +182,13 @@ public function accept() } foreach ($this->_acceptTypes as $acceptType) { - if ($currentItem->getContent() instanceof \$acceptType) { + if ($currentItem->getContent() instanceof $acceptType) { return true; } } foreach ($this->_denyTypes as $denyType) { - if ($currentItem->getContext() instanceof \$denyType) { + if ($currentItem->getContext() instanceof $denyType) { return false; } } diff --git a/library/Zend/Tool/Project/Profile/Resource/Container.php b/library/Zend/Tool/Project/Profile/Resource/Container.php index cd7901e78c6..a3dd4b4a0ea 100644 --- a/library/Zend/Tool/Project/Profile/Resource/Container.php +++ b/library/Zend/Tool/Project/Profile/Resource/Container.php @@ -184,7 +184,7 @@ public function createResource($context, Array $attributes = array()) throw new Exception\InvalidArgumentException('Context must be of type string or Zend_Tool_Project_Context_Interface.'); } - $newResource = new Resource($context); + $newResource = new Profile\Resource($context); if ($attributes) { $newResource->setAttributes($attributes); diff --git a/library/Zend/Tool/Project/Provider/Module.php b/library/Zend/Tool/Project/Provider/Module.php index a5983b1c47a..7fd5374e3b6 100644 --- a/library/Zend/Tool/Project/Provider/Module.php +++ b/library/Zend/Tool/Project/Provider/Module.php @@ -69,7 +69,7 @@ public static function createResources(\Zend\Tool\Project\Profile $profile, $mod $targetModuleResource, array( 'denyNames' => array('ModulesDirectory', 'ViewControllerScriptsDirectory'), - 'denyType' => 'Zend_Tool_Project_Context_Filesystem_File' + 'denyType' => 'Zend\Tool\Project\Context\Filesystem\File' ) ); @@ -80,6 +80,7 @@ public static function createResources(\Zend\Tool\Project\Profile $profile, $mod $currentDepth = 0; $parentResources = array(); $currentResource = $moduleDirectory; + $currentChildResource = null; // loop through the target module skeleton foreach ($targetIterator as $targetSubResource) { diff --git a/library/Zend/Tool/Project/Provider/Test.php b/library/Zend/Tool/Project/Provider/Test.php index 7944d565640..6ebabdb872d 100644 --- a/library/Zend/Tool/Project/Provider/Test.php +++ b/library/Zend/Tool/Project/Provider/Test.php @@ -23,7 +23,7 @@ * @namespace */ namespace Zend\Tool\Project\Provider; -use Zend\Tool\Project\Profile; +use Zend\Tool\Project\Profile as ProjectProfile; /** * @uses \Zend\Tool\Project\Provider\AbstractProvider @@ -44,7 +44,7 @@ class Test extends AbstractProvider * @param \Zend\Tool\Project\Profile $profile * @return bool */ - public static function isTestingEnabled(Profile $profile) + public static function isTestingEnabled(ProjectProfile $profile) { $profileSearchParams = array('testsDirectory'); $testsDirectory = $profile->search($profileSearchParams); @@ -61,7 +61,7 @@ public static function isTestingEnabled(Profile $profile) * @param string $moduleName * @return \Zend\Tool\Project\Profile\Resource */ - public static function createApplicationResource(Profile $profile, $controllerName, $actionName, $moduleName = null) + public static function createApplicationResource(ProjectProfile $profile, $controllerName, $actionName, $moduleName = null) { if (!is_string($controllerName)) { throw new Exception\RuntimeException('Zend_Tool_Project_Provider_View::createApplicationResource() expects \"controllerName\" is the name of a controller resource to create.'); @@ -98,7 +98,7 @@ public static function createApplicationResource(Profile $profile, $controllerNa * @param string $libraryClassName * @return \Zend\Tool\Project\Profile\Resource */ - public static function createLibraryResource(Profile $profile, $libraryClassName) + public static function createLibraryResource(ProjectProfile $profile, $libraryClassName) { $testLibraryDirectoryResource = $profile->search(array('TestsDirectory', 'TestLibraryDirectory')); diff --git a/library/Zend/Validator/Barcode/AbstractAdapter.php b/library/Zend/Validator/Barcode/AbstractAdapter.php index 37483c08955..cddd25eb29e 100644 --- a/library/Zend/Validator/Barcode/AbstractAdapter.php +++ b/library/Zend/Validator/Barcode/AbstractAdapter.php @@ -138,7 +138,7 @@ public function checksum($value) $checksum = $this->getChecksum(); if (!empty($checksum)) { if (method_exists($this, $checksum)) { - return call_user_func(array($this, $checksum), $value); + return $this->$checksum($value); } } diff --git a/library/Zend/Validator/Date.php b/library/Zend/Validator/Date.php index 9147ec49ddf..6323880d0c7 100644 --- a/library/Zend/Validator/Date.php +++ b/library/Zend/Validator/Date.php @@ -172,8 +172,9 @@ public function isValid($value) $this->_setValue($value); - if (($this->_format !== null) || ($this->_locale !== null) || is_array($value) || - $value instanceof Date\Date) { + if (($this->_format !== null) || ($this->_locale !== null) + || is_array($value) || $value instanceof Date\Date + ) { if (!ZendDate\Date::isDate($value, $this->_format, $this->_locale)) { if ($this->_checkFormat($value) === false) { $this->_error(self::FALSEFORMAT); diff --git a/library/Zend/XmlRpc/Server/Fault.php b/library/Zend/XmlRpc/Server/Fault.php index 83553e3d483..d02b9efd519 100644 --- a/library/Zend/XmlRpc/Server/Fault.php +++ b/library/Zend/XmlRpc/Server/Fault.php @@ -89,7 +89,7 @@ public function __construct(\Exception $e) // Notify exception observers, if present if (!empty(self::$_observers)) { foreach (array_keys(self::$_observers) as $observer) { - call_user_func(array($observer, 'observe'), $this); + $observer::observe($this); } } } diff --git a/tests/Zend/Service/LiveDocx/LiveDocxTest.php b/tests/Zend/Service/LiveDocx/LiveDocxTest.php index 94d3c9d06be..838ec915847 100644 --- a/tests/Zend/Service/LiveDocx/LiveDocxTest.php +++ b/tests/Zend/Service/LiveDocx/LiveDocxTest.php @@ -25,7 +25,7 @@ */ namespace ZendTest\Service; namespace Zend\Service\LiveDocx; - +use Zend\Validator; if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'Zend_Service_LiveDocx_LiveDocxTest::main'); @@ -116,7 +116,7 @@ public function testSetWSDLGetWSDLWithSoapClient() $mailMerge = new MailMerge(); - $soapClient = new \Zend\Soap\Client(); + $soapClient = new \Zend\Soap\Client\Client(); $soapClient->setWSDL($wsdl); $mailMerge->setSoapClient($soapClient); diff --git a/tests/Zend/Service/LiveDocx/MailMerge/image-01.png b/tests/Zend/Service/LiveDocx/MailMerge/image-01.png deleted file mode 100755 index 50f44d2dbd0..00000000000 Binary files a/tests/Zend/Service/LiveDocx/MailMerge/image-01.png and /dev/null differ diff --git a/tests/Zend/Service/LiveDocx/MailMerge/image-02.png b/tests/Zend/Service/LiveDocx/MailMerge/image-02.png deleted file mode 100755 index 51df1173d8d..00000000000 Binary files a/tests/Zend/Service/LiveDocx/MailMerge/image-02.png and /dev/null differ diff --git a/tests/Zend/Service/LiveDocx/MailMergeTest.php b/tests/Zend/Service/LiveDocx/MailMergeTest.php index ba84f752824..ed5c670107d 100644 --- a/tests/Zend/Service/LiveDocx/MailMergeTest.php +++ b/tests/Zend/Service/LiveDocx/MailMergeTest.php @@ -25,7 +25,7 @@ namespace ZendTest\Service; namespace Zend\Service\LiveDocx; -use Zend\Soap\Client as SoapClient; +use \Zend\Soap\Client\Client; if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'MailMergeTest::main'); @@ -47,9 +47,7 @@ class MailMergeTest extends \PHPUnit_Framework_TestCase { const TEST_TEMPLATE_1 = 'phpunit-template.docx'; const TEST_TEMPLATE_2 = 'phpunit-template-block-fields.doc'; - const TEST_IMAGE_1 = 'image-01.png'; - const TEST_IMAGE_2 = 'image-02.png'; - const ENDPOINT = 'https://api.livedocx.com/2.0/mailmerge.asmx?wsdl'; + const ENDPOINT = 'https://api.livedocx.com/1.2/mailmerge.asmx?wsdl'; public $path; public $mailMerge; @@ -107,7 +105,7 @@ public function testLoginUsernamePasswordSoapClient() $mailMerge = new MailMerge(); $mailMerge->setUsername(TESTS_ZEND_SERVICE_LIVEDOCX_USERNAME); $mailMerge->setPassword(TESTS_ZEND_SERVICE_LIVEDOCX_PASSWORD); - $mailMerge->setSoapClient(new SoapClient(self::ENDPOINT)); + $mailMerge->setSoapClient(new Client(self::ENDPOINT)); $this->assertTrue($mailMerge->logIn()); } @@ -130,7 +128,7 @@ public function testLoginUsernamePasswordSoapClientException() $mailMerge = new MailMerge(); $mailMerge->setUsername('phpunitInvalidUsername'); $mailMerge->setPassword('phpunitInvalidPassword'); - $mailMerge->setSoapClient(new SoapClient(self::ENDPOINT)); + $mailMerge->setSoapClient(new Client(self::ENDPOINT)); $mailMerge->logIn(); } @@ -151,7 +149,7 @@ public function testConstructorOptionsUsernamePasswordSoapClient() array ( 'username' => TESTS_ZEND_SERVICE_LIVEDOCX_USERNAME, 'password' => TESTS_ZEND_SERVICE_LIVEDOCX_PASSWORD, - 'soapClient' => new SoapClient(self::ENDPOINT) + 'soapClient' => new Client(self::ENDPOINT) ) ); $this->assertTrue($mailMerge->logIn()); @@ -266,8 +264,6 @@ public function testCreateDocument() public function testRetrieveDocument() { - $formats = array('doc', 'docx', 'html', 'pdf', 'rtf', 'txd', 'txt'); - $testValues = array( 'software' => 'phpunit', 'licensee' => 'phpunit', @@ -278,14 +274,26 @@ public function testRetrieveDocument() 'country' => 'phpunit' ); + // PDF and DOCs are always slightly different: + // - PDF because of the timestamp in meta data + // - DOC because of ??? + + $expectedResults = array( + 'docx' => 'f493879ffedf14d34dc231d785a9ce1e', + 'rtf' => 'c3def91a4be1ecc9890bc0b8eb6fe1a8', + 'txd' => '24beda9de96daf49bd8d950bc8be17b3', + 'txt' => '3dc103f033ef6efba770c8196059d96d', + 'html' => '1207b9fa9abe4d724fbc6ca47ecba959' + ); + // Remote Template $this->mailMerge->uploadTemplate($this->path . DIRECTORY_SEPARATOR . self::TEST_TEMPLATE_1); $this->mailMerge->setRemoteTemplate(self::TEST_TEMPLATE_1); $this->mailMerge->assign($testValues); $this->mailMerge->createDocument(); - foreach ($formats as $format) { + foreach($expectedResults as $format => $hash) { $document = $this->mailMerge->retrieveDocument($format); - $this->assertGreaterThan(2048, strlen($document)); + $this->assertEquals($hash, md5($document)); } $this->mailMerge->deleteTemplate(self::TEST_TEMPLATE_1); @@ -293,16 +301,14 @@ public function testRetrieveDocument() $this->mailMerge->setLocalTemplate($this->path . DIRECTORY_SEPARATOR . self::TEST_TEMPLATE_1); $this->mailMerge->assign($testValues); $this->mailMerge->createDocument(); - foreach ($formats as $format) { + foreach($expectedResults as $format => $hash) { $document = $this->mailMerge->retrieveDocument($format); - $this->assertGreaterThan(2048, strlen($document)); + $this->assertEquals($hash, md5($document)); } } public function testRetrieveDocumentAppended() { - $formats = array('doc', 'docx', 'html', 'pdf', 'rtf', 'txd', 'txt'); - $testValues = array( array( 'software' => 'phpunit - document 1', @@ -324,14 +330,25 @@ public function testRetrieveDocumentAppended() ), ); + // PDF and DOCs are always slightly different: + // - PDF because of the timestamp in meta data + // - DOC because of ??? + $expectedResults = array( + 'docx' => '7a363f75f357a7ed3e130f5a9afb0e46', + 'rtf' => '879d76efadcec3e37b1d9b643b356013', + 'txd' => '1545f20057bc0d9d911b7b41aa560622', + 'txt' => 'e997415fd0d5e766b2490fed9386da21', + 'html' => '3a2b1e078767853215010c2ca9204980' + ); + // Remote Template $this->mailMerge->uploadTemplate($this->path . DIRECTORY_SEPARATOR . self::TEST_TEMPLATE_1); $this->mailMerge->setRemoteTemplate(self::TEST_TEMPLATE_1); $this->mailMerge->assign($testValues); $this->mailMerge->createDocument(); - foreach ($formats as $format) { + foreach($expectedResults as $format => $hash) { $document = $this->mailMerge->retrieveDocument($format); - $this->assertGreaterThan(2048, strlen($document)); + $this->assertEquals($hash, md5($document)); } $this->mailMerge->deleteTemplate(self::TEST_TEMPLATE_1); @@ -339,9 +356,9 @@ public function testRetrieveDocumentAppended() $this->mailMerge->setLocalTemplate($this->path . DIRECTORY_SEPARATOR . self::TEST_TEMPLATE_1); $this->mailMerge->assign($testValues); $this->mailMerge->createDocument(); - foreach ($formats as $format) { + foreach($expectedResults as $format => $hash) { $document = $this->mailMerge->retrieveDocument($format); - $this->assertGreaterThan(2048, strlen($document)); + $this->assertEquals($hash, md5($document)); } } @@ -349,26 +366,20 @@ public function testRetrieveDocumentAppended() public function testGetTemplateFormats() { - $expectedResults = array('doc' , 'docx' , 'rtf' , 'txd'); + $expectedResults = array('doc', 'docx', 'rtf', 'txd'); $this->assertEquals($expectedResults, $this->mailMerge->getTemplateFormats()); } public function testGetDocumentFormats() { - $expectedResults = array('doc' , 'docx' , 'html' , 'pdf' , 'rtf' , 'txd' , 'txt'); + $expectedResults = array('doc', 'docx', 'html', 'pdf', 'rtf', 'txd', 'txt'); $this->assertEquals($expectedResults, $this->mailMerge->getDocumentFormats()); } - public function testGetImageImportFormats() + public function testGetImageFormats() { - $expectedResults = array('bmp' , 'gif' , 'jpg' , 'png' , 'tiff', 'wmf'); - $this->assertEquals($expectedResults, $this->mailMerge->getImageImportFormats()); - } - - public function testGetImageExportFormats() - { - $expectedResults = array('bmp' , 'gif' , 'jpg' , 'png' , 'tiff'); - $this->assertEquals($expectedResults, $this->mailMerge->getImageExportFormats()); + $expectedResults = array('bmp', 'gif', 'jpg', 'png', 'tiff'); + $this->assertEquals($expectedResults, $this->mailMerge->getImageFormats()); } // ------------------------------------------------------------------------- @@ -396,7 +407,7 @@ public function testGetBitmaps() $this->mailMerge->setLocalTemplate($this->path . DIRECTORY_SEPARATOR . self::TEST_TEMPLATE_1); $this->mailMerge->assign($testValues); $this->mailMerge->createDocument(); - foreach($this->mailMerge->getImageExportFormats() as $format) { + foreach($this->mailMerge->getImageFormats() as $format) { $bitmaps = $this->mailMerge->getBitmaps(1, 1, 20, $format); $this->assertEquals($expectedResults[$format], md5(serialize($bitmaps))); } @@ -425,7 +436,7 @@ public function testGetAllBitmaps() $this->mailMerge->setLocalTemplate($this->path . DIRECTORY_SEPARATOR . self::TEST_TEMPLATE_1); $this->mailMerge->assign($testValues); $this->mailMerge->createDocument(); - foreach($this->mailMerge->getImageExportFormats() as $format) { + foreach($this->mailMerge->getImageFormats() as $format) { $bitmaps = $this->mailMerge->getAllBitmaps(20, $format); $this->assertEquals($expectedResults[$format], md5(serialize($bitmaps))); } @@ -571,80 +582,6 @@ public function testTemplateExists() // ------------------------------------------------------------------------- - public function testUploadImage() - { - $this->mailMerge->deleteImage(self::TEST_IMAGE_2); - $this->assertNull($this->mailMerge->uploadImage($this->path . DIRECTORY_SEPARATOR . self::TEST_IMAGE_2)); - $this->mailMerge->deleteImage(self::TEST_IMAGE_2); - } - - public function testDownloadImage() - { - $expectedResults = 'f8b663e465acd570414395d5c33541ab'; - $this->mailMerge->uploadImage($this->path . DIRECTORY_SEPARATOR . self::TEST_IMAGE_2); - $image = $this->mailMerge->downloadImage(self::TEST_IMAGE_2); - $this->assertEquals($expectedResults, md5($image)); - } - - public function testDeleteImage() - { - $this->mailMerge->uploadImage($this->path . DIRECTORY_SEPARATOR . self::TEST_IMAGE_2); - $this->mailMerge->deleteImage(self::TEST_IMAGE_2); - $imageDeleted = true; - foreach($this->mailMerge->listImages() as $image) { - if($image['filename'] == self::TEST_IMAGE_2) { - $imageDeleted = false; - } - } - $this->assertTrue($imageDeleted); - } - - public function testListImages() - { - $this->mailMerge->uploadImage($this->path . DIRECTORY_SEPARATOR . self::TEST_IMAGE_1); - $this->mailMerge->uploadImage($this->path . DIRECTORY_SEPARATOR . self::TEST_IMAGE_2); - - // Where images uploaded and are being listed? - $testImage1Exists = false; - $testImage2Exists = false; - - $images = $this->mailMerge->listImages(); - foreach($images as $image) { - if(self::TEST_IMAGE_1 === $image['filename']) { - $testImage1Exists = true; - } elseif(self::TEST_IMAGE_2 === $image['filename']) { - $testImage2Exists = true; - } - } - $this->assertTrue($testImage1Exists && $testImage2Exists); - - // Is all info about images available? - $expectedResults = array('filename', 'fileSize', 'createTime', 'modifyTime'); - foreach($images as $image) { - $this->assertEquals($expectedResults, array_keys($image)); - } - - // Is all info about images correct? - foreach($images as $image) { - $this->assertTrue(strlen($image['filename']) > 0); - $this->assertTrue($image['fileSize'] > 1); - $this->assertTrue($image['createTime'] > mktime(0, 0, 0, 1, 1, 1980)); - $this->assertTrue($image['modifyTime'] > mktime(0, 0, 0, 1, 1, 1980)); - } - - $this->mailMerge->deleteImage(self::TEST_IMAGE_1); - $this->mailMerge->deleteImage(self::TEST_IMAGE_2); - } - - public function testImageExists() - { - $this->mailMerge->uploadImage($this->path . DIRECTORY_SEPARATOR . self::TEST_IMAGE_2); - $this->assertTrue($this->mailMerge->imageExists(self::TEST_IMAGE_2)); - $this->mailMerge->deleteImage(self::TEST_IMAGE_2); - } - - // ------------------------------------------------------------------------- - public function testAssocArrayToArrayOfArrayOfString() { $testValues = array(