import v2.0.0.0_RC3 | 2012-07-01

https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
2019-07-17 22:31:04 +02:00
parent 38c146901c
commit 2f397f01f7
2677 changed files with 296182 additions and 45159 deletions

View File

@ -16,7 +16,7 @@
* @package Zend_Acl
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Acl.php 17515 2009-08-10 13:48:44Z ralph $
* @version $Id: Acl.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -84,12 +84,12 @@ class Zend_Acl
* @var Zend_Acl_Role_Interface
*/
protected $_isAllowedRole = null;
/**
* @var Zend_Acl_Resource_Interface
*/
protected $_isAllowedResource = null;
/**
* ACL rules; whitelist (deny everything to all) by default
*
@ -133,13 +133,13 @@ class Zend_Acl
if (is_string($role)) {
$role = new Zend_Acl_Role($role);
}
if (!$role instanceof Zend_Acl_Role_Interface) {
require_once 'Zend/Acl/Exception.php';
throw new Zend_Acl_Exception('addRole() expects $role to be of type Zend_Acl_Role_Interface');
}
$this->_getRoleRegistry()->add($role, $parents);
return $this;
@ -218,9 +218,11 @@ class Zend_Acl
}
}
foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $visitor) {
foreach ($visitor['byRoleId'] as $roleIdCurrent => $rules) {
if ($roleId === $roleIdCurrent) {
unset($this->_rules['byResourceId'][$resourceIdCurrent]['byRoleId'][$roleIdCurrent]);
if (array_key_exists('byRoleId', $visitor)) {
foreach ($visitor['byRoleId'] as $roleIdCurrent => $rules) {
if ($roleId === $roleIdCurrent) {
unset($this->_rules['byResourceId'][$resourceIdCurrent]['byRoleId'][$roleIdCurrent]);
}
}
}
}
@ -263,15 +265,15 @@ class Zend_Acl
*/
public function addResource($resource, $parent = null)
{
if (is_string($resource)) {
$resource = new Zend_Acl_Resource($resource);
}
if (!$resource instanceof Zend_Acl_Resource_Interface) {
if (is_string($resource)) {
$resource = new Zend_Acl_Resource($resource);
}
if (!$resource instanceof Zend_Acl_Resource_Interface) {
require_once 'Zend/Acl/Exception.php';
throw new Zend_Acl_Exception('addResource() expects $resource to be of type Zend_Acl_Resource_Interface');
}
}
$resourceId = $resource->getResourceId();
if ($this->has($resourceId)) {
@ -303,7 +305,7 @@ class Zend_Acl
return $this;
}
/**
* Adds a Resource having an identifier unique to the ACL
*
@ -312,7 +314,7 @@ class Zend_Acl
*
* @deprecated in version 1.9.1 and will be available till 2.0. New code
* should use addResource() instead.
*
*
* @param Zend_Acl_Resource_Interface $resource
* @param Zend_Acl_Resource_Interface|string $parent
* @throws Zend_Acl_Exception
@ -731,24 +733,24 @@ class Zend_Acl
*/
public function isAllowed($role = null, $resource = null, $privilege = null)
{
// reset role & resource to null
$this->_isAllowedRole = $this->_isAllowedResource = null;
// reset role & resource to null
$this->_isAllowedRole = $this->_isAllowedResource = null;
if (null !== $role) {
// keep track of originally called role
$this->_isAllowedRole = $role;
// keep track of originally called role
$this->_isAllowedRole = $role;
$role = $this->_getRoleRegistry()->get($role);
if (!$this->_isAllowedRole instanceof Zend_Acl_Role_Interface) {
$this->_isAllowedRole = $role;
$this->_isAllowedRole = $role;
}
}
if (null !== $resource) {
// keep track of originally called resource
$this->_isAllowedResource = $resource;
// keep track of originally called resource
$this->_isAllowedResource = $resource;
$resource = $this->get($resource);
if (!$this->_isAllowedResource instanceof Zend_Acl_Resource_Interface) {
$this->_isAllowedResource = $resource;
$this->_isAllowedResource = $resource;
}
}
@ -1034,8 +1036,8 @@ class Zend_Acl
($this->_isAllowedResource instanceof Zend_Acl_Resource_Interface) ? $this->_isAllowedResource : $resource,
$privilege
);
}
}
if (null === $rule['assert'] || $assertionValue) {
return $rule['type'];
} else if (null !== $resource || null !== $role || null !== $privilege) {
@ -1104,4 +1106,14 @@ class Zend_Acl
return $visitor['byRoleId'][$roleId];
}
/**
* @return array of registered roles
*
*/
public function getRegisteredRoles()
{
return $this->_getRoleRegistry()->getRoles();
}
}

View File

@ -16,7 +16,7 @@
* @package Zend_Acl
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Registry.php 16199 2009-06-21 18:42:43Z thomas $
* @version $Id: Registry.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -263,4 +263,9 @@ class Zend_Acl_Role_Registry
return $this;
}
public function getRoles()
{
return $this->_roles;
}
}

266
libs/Zend/Amf/Adobe/Auth.php Executable file → Normal file
View File

@ -1,133 +1,133 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Auth.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/** Zend_Amf_Auth_Abstract */
require_once 'Zend/Amf/Auth/Abstract.php';
/** Zend_Acl */
require_once 'Zend/Acl.php';
/** Zend_Auth_Result */
require_once 'Zend/Auth/Result.php';
/**
* This class implements authentication against XML file with roles for Flex Builder.
*
* @package Zend_Amf
* @subpackage Adobe
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Adobe_Auth extends Zend_Amf_Auth_Abstract
{
/**
* ACL for authorization
*
* @var Zend_Acl
*/
protected $_acl;
/**
* Username/password array
*
* @var array
*/
protected $_users = array();
/**
* Create auth adapter
*
* @param string $rolefile File containing XML with users and roles
*/
public function __construct($rolefile)
{
$this->_acl = new Zend_Acl();
$xml = simplexml_load_file($rolefile);
/*
Roles file format:
<roles>
<role id=”admin”>
<user name=”user1” password=”pwd”/>
</role>
<role id=”hr”>
<user name=”user2” password=”pwd2”/>
</role>
</roles>
*/
foreach($xml->role as $role) {
$this->_acl->addRole(new Zend_Acl_Role((string)$role["id"]));
foreach($role->user as $user) {
$this->_users[(string)$user["name"]] = array("password" => (string)$user["password"],
"role" => (string)$role["id"]);
}
}
}
/**
* Get ACL with roles from XML file
*
* @return Zend_Acl
*/
public function getAcl()
{
return $this->_acl;
}
/**
* Perform authentication
*
* @throws Zend_Auth_Adapter_Exception
* @return Zend_Auth_Result
* @see Zend_Auth_Adapter_Interface#authenticate()
*/
public function authenticate()
{
if (empty($this->_username) ||
empty($this->_password)) {
/**
* @see Zend_Auth_Adapter_Exception
*/
require_once 'Zend/Auth/Adapter/Exception.php';
throw new Zend_Auth_Adapter_Exception('Username/password should be set');
}
if(!isset($this->_users[$this->_username])) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
null,
array('Username not found')
);
}
$user = $this->_users[$this->_username];
if($user["password"] != $this->_password) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
null,
array('Authentication failed')
);
}
$id = new stdClass();
$id->role = $user["role"];
$id->name = $this->_username;
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $id);
}
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Auth.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Amf_Auth_Abstract */
require_once 'Zend/Amf/Auth/Abstract.php';
/** Zend_Acl */
require_once 'Zend/Acl.php';
/** Zend_Auth_Result */
require_once 'Zend/Auth/Result.php';
/**
* This class implements authentication against XML file with roles for Flex Builder.
*
* @package Zend_Amf
* @subpackage Adobe
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Adobe_Auth extends Zend_Amf_Auth_Abstract
{
/**
* ACL for authorization
*
* @var Zend_Acl
*/
protected $_acl;
/**
* Username/password array
*
* @var array
*/
protected $_users = array();
/**
* Create auth adapter
*
* @param string $rolefile File containing XML with users and roles
*/
public function __construct($rolefile)
{
$this->_acl = new Zend_Acl();
$xml = simplexml_load_file($rolefile);
/*
Roles file format:
<roles>
<role id=”admin”>
<user name=”user1” password=”pwd”/>
</role>
<role id=”hr”>
<user name=”user2” password=”pwd2”/>
</role>
</roles>
*/
foreach($xml->role as $role) {
$this->_acl->addRole(new Zend_Acl_Role((string)$role["id"]));
foreach($role->user as $user) {
$this->_users[(string)$user["name"]] = array("password" => (string)$user["password"],
"role" => (string)$role["id"]);
}
}
}
/**
* Get ACL with roles from XML file
*
* @return Zend_Acl
*/
public function getAcl()
{
return $this->_acl;
}
/**
* Perform authentication
*
* @throws Zend_Auth_Adapter_Exception
* @return Zend_Auth_Result
* @see Zend_Auth_Adapter_Interface#authenticate()
*/
public function authenticate()
{
if (empty($this->_username) ||
empty($this->_password)) {
/**
* @see Zend_Auth_Adapter_Exception
*/
require_once 'Zend/Auth/Adapter/Exception.php';
throw new Zend_Auth_Adapter_Exception('Username/password should be set');
}
if(!isset($this->_users[$this->_username])) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
null,
array('Username not found')
);
}
$user = $this->_users[$this->_username];
if($user["password"] != $this->_password) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
null,
array('Authentication failed')
);
}
$id = new stdClass();
$id->role = $user["role"];
$id->name = $this->_username;
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $id);
}
}

206
libs/Zend/Amf/Adobe/DbInspector.php Executable file → Normal file
View File

@ -1,103 +1,103 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DbInspector.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
* This class implements authentication against XML file with roles for Flex Builder.
*
* @package Zend_Amf
* @subpackage Adobe
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Adobe_DbInspector
{
/**
* Connect to the database
*
* @param string $dbType Database adapter type for Zend_Db
* @param array|object $dbDescription Adapter-specific connection settings
* @return Zend_Db_Adapter_Abstract
* @see Zend_Db::factory()
*/
protected function _connect($dbType, $dbDescription)
{
if(is_object($dbDescription)) {
$dbDescription = get_object_vars($dbDescription);
}
return Zend_Db::factory($dbType, $dbDescription);
}
/**
* Describe database object.
*
* Usage example:
* $inspector->describeTable('Pdo_Mysql',
* array(
* 'host' => '127.0.0.1',
* 'username' => 'webuser',
* 'password' => 'xxxxxxxx',
* 'dbname' => 'test'
* ),
* 'mytable'
* );
*
* @param string $dbType Database adapter type for Zend_Db
* @param array|object $dbDescription Adapter-specific connection settings
* @param string $tableName Table name
* @return array Table description
* @see Zend_Db::describeTable()
* @see Zend_Db::factory()
*/
public function describeTable($dbType, $dbDescription, $tableName)
{
$db = $this->_connect($dbType, $dbDescription);
return $db->describeTable($tableName);
}
/**
* Test database connection
*
* @param string $dbType Database adapter type for Zend_Db
* @param array|object $dbDescription Adapter-specific connection settings
* @return bool
* @see Zend_Db::factory()
*/
public function connect($dbType, $dbDescription)
{
$db = $this->_connect($dbType, $dbDescription);
$db->listTables();
return true;
}
/**
* Get the list of database tables
*
* @param string $dbType Database adapter type for Zend_Db
* @param array|object $dbDescription Adapter-specific connection settings
* @return array List of the tables
*/
public function getTables($dbType, $dbDescription)
{
$db = $this->_connect($dbType, $dbDescription);
return $db->listTables();
}
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DbInspector.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
* This class implements authentication against XML file with roles for Flex Builder.
*
* @package Zend_Amf
* @subpackage Adobe
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Adobe_DbInspector
{
/**
* Connect to the database
*
* @param string $dbType Database adapter type for Zend_Db
* @param array|object $dbDescription Adapter-specific connection settings
* @return Zend_Db_Adapter_Abstract
* @see Zend_Db::factory()
*/
protected function _connect($dbType, $dbDescription)
{
if(is_object($dbDescription)) {
$dbDescription = get_object_vars($dbDescription);
}
return Zend_Db::factory($dbType, $dbDescription);
}
/**
* Describe database object.
*
* Usage example:
* $inspector->describeTable('Pdo_Mysql',
* array(
* 'host' => '127.0.0.1',
* 'username' => 'webuser',
* 'password' => 'xxxxxxxx',
* 'dbname' => 'test'
* ),
* 'mytable'
* );
*
* @param string $dbType Database adapter type for Zend_Db
* @param array|object $dbDescription Adapter-specific connection settings
* @param string $tableName Table name
* @return array Table description
* @see Zend_Db::describeTable()
* @see Zend_Db::factory()
*/
public function describeTable($dbType, $dbDescription, $tableName)
{
$db = $this->_connect($dbType, $dbDescription);
return $db->describeTable($tableName);
}
/**
* Test database connection
*
* @param string $dbType Database adapter type for Zend_Db
* @param array|object $dbDescription Adapter-specific connection settings
* @return bool
* @see Zend_Db::factory()
*/
public function connect($dbType, $dbDescription)
{
$db = $this->_connect($dbType, $dbDescription);
$db->listTables();
return true;
}
/**
* Get the list of database tables
*
* @param string $dbType Database adapter type for Zend_Db
* @param array|object $dbDescription Adapter-specific connection settings
* @return array List of the tables
*/
public function getTables($dbType, $dbDescription)
{
$db = $this->_connect($dbType, $dbDescription);
return $db->listTables();
}
}

618
libs/Zend/Amf/Adobe/Introspector.php Executable file → Normal file
View File

@ -1,309 +1,309 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Introspector.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/** Zend_Amf_Parse_TypeLoader */
require_once 'Zend/Amf/Parse/TypeLoader.php';
/** Zend_Reflection_Class */
require_once 'Zend/Reflection/Class.php';
/** Zend_Server_Reflection */
require_once 'Zend/Server/Reflection.php';
/**
* This class implements a service for generating AMF service descriptions as XML.
*
* @package Zend_Amf
* @subpackage Adobe
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Adobe_Introspector
{
/**
* Options used:
* - server: instance of Zend_Amf_Server to use
* - directories: directories where class files may be looked up
*
* @var array Introspector options
*/
protected $_options;
/**
* @var DOMElement DOM element to store types
*/
protected $_types;
/**
* @var array Map of the known types
*/
protected $_typesMap = array();
/**
* @var DOMDocument XML document to store data
*/
protected $_xml;
/**
* Constructor
*
* @return void
*/
public function __construct()
{
$this->_xml = new DOMDocument('1.0', 'utf-8');
}
/**
* Create XML definition on an AMF service class
*
* @param string $serviceClass Service class name
* @param array $options invocation options
* @return string XML with service class introspection
*/
public function introspect($serviceClass, $options = array())
{
$this->_options = $options;
if (strpbrk($serviceClass, '\\/<>')) {
return $this->_returnError('Invalid service name');
}
// Transform com.foo.Bar into com_foo_Bar
$serviceClass = str_replace('.' , '_', $serviceClass);
// Introspect!
if (!class_exists($serviceClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($serviceClass, $this->_getServicePath());
}
$serv = $this->_xml->createElement('service-description');
$serv->setAttribute('xmlns', 'http://ns.adobe.com/flex/service-description/2008');
$this->_types = $this->_xml->createElement('types');
$this->_ops = $this->_xml->createElement('operations');
$r = Zend_Server_Reflection::reflectClass($serviceClass);
$this->_addService($r, $this->_ops);
$serv->appendChild($this->_types);
$serv->appendChild($this->_ops);
$this->_xml->appendChild($serv);
return $this->_xml->saveXML();
}
/**
* Authentication handler
*
* @param Zend_Acl $acl
* @return unknown_type
*/
public function initAcl(Zend_Acl $acl)
{
return false; // we do not need auth for this class
}
/**
* Generate map of public class attributes
*
* @param string $typename type name
* @param DOMElement $typexml target XML element
* @return void
*/
protected function _addClassAttributes($typename, DOMElement $typexml)
{
// Do not try to autoload here because _phpTypeToAS should
// have already attempted to load this class
if (!class_exists($typename, false)) {
return;
}
$rc = new Zend_Reflection_Class($typename);
foreach ($rc->getProperties() as $prop) {
if (!$prop->isPublic()) {
continue;
}
$propxml = $this->_xml->createElement('property');
$propxml->setAttribute('name', $prop->getName());
$type = $this->_registerType($this->_getPropertyType($prop));
$propxml->setAttribute('type', $type);
$typexml->appendChild($propxml);
}
}
/**
* Build XML service description from reflection class
*
* @param Zend_Server_Reflection_Class $refclass
* @param DOMElement $target target XML element
* @return void
*/
protected function _addService(Zend_Server_Reflection_Class $refclass, DOMElement $target)
{
foreach ($refclass->getMethods() as $method) {
if (!$method->isPublic()
|| $method->isConstructor()
|| ('__' == substr($method->name, 0, 2))
) {
continue;
}
foreach ($method->getPrototypes() as $proto) {
$op = $this->_xml->createElement('operation');
$op->setAttribute('name', $method->getName());
$rettype = $this->_registerType($proto->getReturnType());
$op->setAttribute('returnType', $rettype);
foreach ($proto->getParameters() as $param) {
$arg = $this->_xml->createElement('argument');
$arg->setAttribute('name', $param->getName());
$type = $param->getType();
if ($type == 'mixed' && ($pclass = $param->getClass())) {
$type = $pclass->getName();
}
$ptype = $this->_registerType($type);
$arg->setAttribute('type', $ptype);
$op->appendChild($arg);
}
$target->appendChild($op);
}
}
}
/**
* Extract type of the property from DocBlock
*
* @param Zend_Reflection_Property $prop reflection property object
* @return string Property type
*/
protected function _getPropertyType(Zend_Reflection_Property $prop)
{
$docBlock = $prop->getDocComment();
if (!$docBlock) {
return 'Unknown';
}
if (!$docBlock->hasTag('var')) {
return 'Unknown';
}
$tag = $docBlock->getTag('var');
return trim($tag->getDescription());
}
/**
* Get the array of service directories
*
* @return array Service class directories
*/
protected function _getServicePath()
{
if (isset($this->_options['server'])) {
return $this->_options['server']->getDirectory();
}
if (isset($this->_options['directories'])) {
return $this->_options['directories'];
}
return array();
}
/**
* Map from PHP type name to AS type name
*
* @param string $typename PHP type name
* @return string AS type name
*/
protected function _phpTypeToAS($typename)
{
if (class_exists($typename)) {
$vars = get_class_vars($typename);
if (isset($vars['_explicitType'])) {
return $vars['_explicitType'];
}
}
if (false !== ($asname = Zend_Amf_Parse_TypeLoader::getMappedClassName($typename))) {
return $asname;
}
return $typename;
}
/**
* Register new type on the system
*
* @param string $typename type name
* @return string New type name
*/
protected function _registerType($typename)
{
// Known type - return its AS name
if (isset($this->_typesMap[$typename])) {
return $this->_typesMap[$typename];
}
// Standard types
if (in_array($typename, array('void', 'null', 'mixed', 'unknown_type'))) {
return 'Unknown';
}
if (in_array($typename, array('int', 'integer', 'bool', 'boolean', 'float', 'string', 'object', 'Unknown', 'stdClass', 'array'))) {
return $typename;
}
// Resolve and store AS name
$asTypeName = $this->_phpTypeToAS($typename);
$this->_typesMap[$typename] = $asTypeName;
// Create element for the name
$typeEl = $this->_xml->createElement('type');
$typeEl->setAttribute('name', $asTypeName);
$this->_addClassAttributes($typename, $typeEl);
$this->_types->appendChild($typeEl);
return $asTypeName;
}
/**
* Return error with error message
*
* @param string $msg Error message
* @return string
*/
protected function _returnError($msg)
{
return 'ERROR: $msg';
}
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Introspector.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Amf_Parse_TypeLoader */
require_once 'Zend/Amf/Parse/TypeLoader.php';
/** Zend_Reflection_Class */
require_once 'Zend/Reflection/Class.php';
/** Zend_Server_Reflection */
require_once 'Zend/Server/Reflection.php';
/**
* This class implements a service for generating AMF service descriptions as XML.
*
* @package Zend_Amf
* @subpackage Adobe
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Adobe_Introspector
{
/**
* Options used:
* - server: instance of Zend_Amf_Server to use
* - directories: directories where class files may be looked up
*
* @var array Introspector options
*/
protected $_options;
/**
* @var DOMElement DOM element to store types
*/
protected $_types;
/**
* @var array Map of the known types
*/
protected $_typesMap = array();
/**
* @var DOMDocument XML document to store data
*/
protected $_xml;
/**
* Constructor
*
* @return void
*/
public function __construct()
{
$this->_xml = new DOMDocument('1.0', 'utf-8');
}
/**
* Create XML definition on an AMF service class
*
* @param string $serviceClass Service class name
* @param array $options invocation options
* @return string XML with service class introspection
*/
public function introspect($serviceClass, $options = array())
{
$this->_options = $options;
if (strpbrk($serviceClass, '\\/<>')) {
return $this->_returnError('Invalid service name');
}
// Transform com.foo.Bar into com_foo_Bar
$serviceClass = str_replace('.' , '_', $serviceClass);
// Introspect!
if (!class_exists($serviceClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($serviceClass, $this->_getServicePath());
}
$serv = $this->_xml->createElement('service-description');
$serv->setAttribute('xmlns', 'http://ns.adobe.com/flex/service-description/2008');
$this->_types = $this->_xml->createElement('types');
$this->_ops = $this->_xml->createElement('operations');
$r = Zend_Server_Reflection::reflectClass($serviceClass);
$this->_addService($r, $this->_ops);
$serv->appendChild($this->_types);
$serv->appendChild($this->_ops);
$this->_xml->appendChild($serv);
return $this->_xml->saveXML();
}
/**
* Authentication handler
*
* @param Zend_Acl $acl
* @return unknown_type
*/
public function initAcl(Zend_Acl $acl)
{
return false; // we do not need auth for this class
}
/**
* Generate map of public class attributes
*
* @param string $typename type name
* @param DOMElement $typexml target XML element
* @return void
*/
protected function _addClassAttributes($typename, DOMElement $typexml)
{
// Do not try to autoload here because _phpTypeToAS should
// have already attempted to load this class
if (!class_exists($typename, false)) {
return;
}
$rc = new Zend_Reflection_Class($typename);
foreach ($rc->getProperties() as $prop) {
if (!$prop->isPublic()) {
continue;
}
$propxml = $this->_xml->createElement('property');
$propxml->setAttribute('name', $prop->getName());
$type = $this->_registerType($this->_getPropertyType($prop));
$propxml->setAttribute('type', $type);
$typexml->appendChild($propxml);
}
}
/**
* Build XML service description from reflection class
*
* @param Zend_Server_Reflection_Class $refclass
* @param DOMElement $target target XML element
* @return void
*/
protected function _addService(Zend_Server_Reflection_Class $refclass, DOMElement $target)
{
foreach ($refclass->getMethods() as $method) {
if (!$method->isPublic()
|| $method->isConstructor()
|| ('__' == substr($method->name, 0, 2))
) {
continue;
}
foreach ($method->getPrototypes() as $proto) {
$op = $this->_xml->createElement('operation');
$op->setAttribute('name', $method->getName());
$rettype = $this->_registerType($proto->getReturnType());
$op->setAttribute('returnType', $rettype);
foreach ($proto->getParameters() as $param) {
$arg = $this->_xml->createElement('argument');
$arg->setAttribute('name', $param->getName());
$type = $param->getType();
if ($type == 'mixed' && ($pclass = $param->getClass())) {
$type = $pclass->getName();
}
$ptype = $this->_registerType($type);
$arg->setAttribute('type', $ptype);
$op->appendChild($arg);
}
$target->appendChild($op);
}
}
}
/**
* Extract type of the property from DocBlock
*
* @param Zend_Reflection_Property $prop reflection property object
* @return string Property type
*/
protected function _getPropertyType(Zend_Reflection_Property $prop)
{
$docBlock = $prop->getDocComment();
if (!$docBlock) {
return 'Unknown';
}
if (!$docBlock->hasTag('var')) {
return 'Unknown';
}
$tag = $docBlock->getTag('var');
return trim($tag->getDescription());
}
/**
* Get the array of service directories
*
* @return array Service class directories
*/
protected function _getServicePath()
{
if (isset($this->_options['server'])) {
return $this->_options['server']->getDirectory();
}
if (isset($this->_options['directories'])) {
return $this->_options['directories'];
}
return array();
}
/**
* Map from PHP type name to AS type name
*
* @param string $typename PHP type name
* @return string AS type name
*/
protected function _phpTypeToAS($typename)
{
if (class_exists($typename)) {
$vars = get_class_vars($typename);
if (isset($vars['_explicitType'])) {
return $vars['_explicitType'];
}
}
if (false !== ($asname = Zend_Amf_Parse_TypeLoader::getMappedClassName($typename))) {
return $asname;
}
return $typename;
}
/**
* Register new type on the system
*
* @param string $typename type name
* @return string New type name
*/
protected function _registerType($typename)
{
// Known type - return its AS name
if (isset($this->_typesMap[$typename])) {
return $this->_typesMap[$typename];
}
// Standard types
if (in_array($typename, array('void', 'null', 'mixed', 'unknown_type'))) {
return 'Unknown';
}
if (in_array($typename, array('int', 'integer', 'bool', 'boolean', 'float', 'string', 'object', 'Unknown', 'stdClass', 'array'))) {
return $typename;
}
// Resolve and store AS name
$asTypeName = $this->_phpTypeToAS($typename);
$this->_typesMap[$typename] = $asTypeName;
// Create element for the name
$typeEl = $this->_xml->createElement('type');
$typeEl->setAttribute('name', $asTypeName);
$this->_addClassAttributes($typename, $typeEl);
$this->_types->appendChild($typeEl);
return $asTypeName;
}
/**
* Return error with error message
*
* @param string $msg Error message
* @return string
*/
protected function _returnError($msg)
{
return 'ERROR: $msg';
}
}

84
libs/Zend/Amf/Auth/Abstract.php Executable file → Normal file
View File

@ -1,42 +1,42 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/** Zend_Auth_Adapter_Interface */
require_once 'Zend/Auth/Adapter/Interface.php';
/**
* Base abstract class for AMF authentication implementation
*
* @package Zend_Amf
* @subpackage Auth
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Amf_Auth_Abstract implements Zend_Auth_Adapter_Interface
{
protected $_username;
protected $_password;
public function setCredentials($username, $password) {
$this->_username = $username;
$this->_password = $password;
}
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Auth_Adapter_Interface */
require_once 'Zend/Auth/Adapter/Interface.php';
/**
* Base abstract class for AMF authentication implementation
*
* @package Zend_Amf
* @subpackage Auth
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Amf_Auth_Abstract implements Zend_Auth_Adapter_Interface
{
protected $_username;
protected $_password;
public function setCredentials($username, $password) {
$this->_username = $username;
$this->_password = $password;
}
}

View File

@ -16,18 +16,18 @@
* @package Zend_Amf
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Constants.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Constants.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
* The following constants are used throughout serialization and
* The following constants are used throughout serialization and
* deserialization to detect the AMF marker and encoding types.
*
* @package Zend_Amf
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
final class Zend_Amf_Constants
final class Zend_Amf_Constants
{
const AMF0_NUMBER = 0x00;
const AMF0_BOOLEAN = 0x01;
@ -68,11 +68,11 @@ final class Zend_Amf_Constants
const ET_EXTERNAL = 0x01;
const ET_DYNAMIC = 0x02;
const ET_PROXY = 0x03;
const FMS_OBJECT_ENCODING = 0x01;
/**
* Special content length value that indicates "unknown" content length
* Special content length value that indicates "unknown" content length
* per AMF Specification
*/
const UNKNOWN_CONTENT_LENGTH = -1;
@ -82,6 +82,6 @@ final class Zend_Amf_Constants
const CREDENTIALS_HEADER = 'Credentials';
const PERSISTENT_HEADER = 'RequestPersistentHeader';
const DESCRIBE_HEADER = 'DescribeService';
const GUEST_ROLE = 'anonymous';
}

View File

@ -17,7 +17,7 @@
* @subpackage Parse_Amf0
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Deserializer.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Deserializer.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Amf_Parse_Deserializer */
@ -270,9 +270,9 @@ class Zend_Amf_Parse_Amf0_Deserializer extends Zend_Amf_Parse_Deserializer
$returnObject->$key = $value;
}
}
if($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
$returnObject = get_object_vars($returnObject);
}
if($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
$returnObject = get_object_vars($returnObject);
}
return $returnObject;
}
@ -284,7 +284,7 @@ class Zend_Amf_Parse_Amf0_Deserializer extends Zend_Amf_Parse_Deserializer
*/
public function readAmf3TypeMarker()
{
require_once 'Zend/Amf/Parse/Amf3/Deserializer.php';
require_once 'Zend/Amf/Parse/Amf3/Deserializer.php';
$deserializer = new Zend_Amf_Parse_Amf3_Deserializer($this->_stream);
$this->_objectEncoding = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
return $deserializer->readTypeMarker();

View File

@ -17,7 +17,7 @@
* @subpackage Parse_Amf0
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Serializer.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Serializer.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Amf_Parse_Serializer */
@ -38,7 +38,7 @@ class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
* @var string Name of the class to be returned
*/
protected $_className = '';
/**
* An array of reference objects
* @var array
@ -62,7 +62,7 @@ class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
if (null !== $markerType) {
//try to refrence the given object
if( !$this->writeObjectReference($data, $markerType) ) {
// Write the Type Marker to denote the following action script data type
$this->_stream->writeByte($markerType);
switch($markerType) {
@ -113,7 +113,7 @@ class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
$data = Zend_Amf_Parse_TypeLoader::handleResource($data);
}
switch (true) {
case (is_int($data) || is_float($data)):
case (is_int($data) || is_float($data)):
$markerType = Zend_Amf_Constants::AMF0_NUMBER;
break;
case (is_bool($data)):
@ -149,13 +149,13 @@ class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
$i = 0;
foreach (array_keys($data) as $key) {
// check if it contains non-integer keys
if (!is_numeric($key) || intval($key) != $key) {
$markerType = Zend_Amf_Constants::AMF0_OBJECT;
break;
if (!is_numeric($key) || intval($key) != $key) {
$markerType = Zend_Amf_Constants::AMF0_OBJECT;
break;
// check if it is a sparse indexed array
} else if ($key != $i) {
$markerType = Zend_Amf_Constants::AMF0_MIXEDARRAY;
break;
} else if ($key != $i) {
$markerType = Zend_Amf_Constants::AMF0_MIXEDARRAY;
break;
}
$i++;
}
@ -174,11 +174,11 @@ class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
}
return $this;
}
/**
/**
* Check if the given object is in the reference table, write the reference if it exists,
* otherwise add the object to the reference table
*
*
* @param mixed $object object to check for reference
* @param $markerType AMF type of the object to write
* @return Boolean true, if the reference was written, false otherwise
@ -188,7 +188,7 @@ class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
$markerType == Zend_Amf_Constants::AMF0_MIXEDARRAY ||
$markerType == Zend_Amf_Constants::AMF0_ARRAY ||
$markerType == Zend_Amf_Constants::AMF0_TYPEDOBJECT ) {
$ref = array_search($object, $this->_referenceObjects,true);
//handle object reference
if($ref !== false){
@ -198,7 +198,7 @@ class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
$this->_referenceObjects[] = $object;
}
return false;
}
@ -213,7 +213,7 @@ class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
// Loop each element and write the name of the property.
foreach ($object as $key => $value) {
// skip variables starting with an _ provate transient
if( $key[0] == "_") continue;
if( $key[0] == "_") continue;
$this->_stream->writeUTF($key);
$this->writeTypeMarker($value);
}
@ -332,9 +332,9 @@ class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
case ($object instanceof stdClass):
$className = '';
break;
// By default, use object's class name
// By default, use object's class name
default:
$className = get_class($object);
$className = get_class($object);
break;
}
if(!$className == '') {

View File

@ -17,7 +17,7 @@
* @subpackage Parse_Amf3
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Deserializer.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Deserializer.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Amf_Parse_Deserializer */
@ -390,18 +390,18 @@ class Zend_Amf_Parse_Amf3_Deserializer extends Zend_Amf_Parse_Deserializer
$returnObject->$key = $value;
}
}
}
if($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
if(isset($returnObject->externalizedData)) {
$returnObject = $returnObject->externalizedData;
} else {
$returnObject = get_object_vars($returnObject);
}
}
if($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
if(isset($returnObject->externalizedData)) {
$returnObject = $returnObject->externalizedData;
} else {
$returnObject = get_object_vars($returnObject);
}
}
return $returnObject;
}

View File

@ -17,7 +17,7 @@
* @subpackage Parse_Amf3
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Serializer.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Serializer.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Amf_Parse_Serializer */
@ -47,13 +47,13 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
* @var array
*/
protected $_referenceStrings = array();
/**
* An array of reference class definitions, indexed by classname
* @var array
*/
protected $_referenceDefinitions = array();
/**
* Serialize PHP types to AMF3 and write to stream
*
@ -112,7 +112,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
$data = Zend_Amf_Parse_TypeLoader::handleResource($data);
}
switch (true) {
case (null === $data):
case (null === $data):
$markerType = Zend_Amf_Constants::AMF3_NULL;
break;
case (is_bool($data)):
@ -150,7 +150,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
$markerType = Zend_Amf_Constants::AMF3_OBJECT;
}
break;
default:
default:
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Unsupported data type: ' . gettype($data));
}
@ -190,7 +190,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
$this->_stream->writeByte($int & 0xff);
return $this;
}
/**
* Send string to output stream, without trying to reference it.
* The string is prepended with strlen($string) << 1 | 0x01
@ -202,7 +202,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
$ref = strlen($string) << 1 | 0x01;
$this->writeInteger($ref);
$this->_stream->writeBytes($string);
return $this;
}
@ -219,7 +219,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
$this->writeInteger(0x01);
return $this;
}
$ref = array_search($string, $this->_referenceStrings, true);
if($ref === false){
$this->_referenceStrings[] = $string;
@ -228,10 +228,10 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
$ref <<= 1;
$this->writeInteger($ref);
}
return $this;
}
/**
* Send ByteArray to output stream
*
@ -242,7 +242,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
if($this->writeObjectReference($data)){
return $this;
}
if(is_string($data)) {
//nothing to do
} else if ($data instanceof Zend_Amf_Value_ByteArray) {
@ -251,13 +251,13 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Invalid ByteArray specified; must be a string or Zend_Amf_Value_ByteArray');
}
$this->writeBinaryString($data);
return $this;
}
/**
/**
* Send xml to output stream
*
* @param DOMDocument|SimpleXMLElement $xml
@ -267,7 +267,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
{
if($this->writeObjectReference($xml)){
return $this;
}
}
if(is_string($xml)) {
//nothing to do
@ -279,9 +279,9 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Invalid xml specified; must be a DOMDocument or SimpleXMLElement');
}
$this->writeBinaryString($xml);
return $this;
}
@ -296,7 +296,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
if($this->writeObjectReference($date)){
return $this;
}
if ($date instanceof DateTime) {
$dateString = $date->format('U') * 1000;
} elseif ($date instanceof Zend_Date) {
@ -323,7 +323,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
if($this->writeObjectReference($array)){
return $this;
}
// have to seperate mixed from numberic keys.
$numeric = array();
$string = array();
@ -353,11 +353,11 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
}
return $this;
}
/**
* Check if the given object is in the reference table, write the reference if it exists,
* otherwise add the object to the reference table
*
*
* @param mixed $object object to check for reference
* @return Boolean true, if the reference was written, false otherwise
*/
@ -384,7 +384,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
if($this->writeObjectReference($object)){
return $this;
}
$className = '';
//Check to see if the object is a typed object and we need to change
@ -408,59 +408,59 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
$className = '';
break;
// By default, use object's class name
// By default, use object's class name
default:
$className = get_class($object);
$className = get_class($object);
break;
}
$writeTraits = true;
//check to see, if we have a corresponding definition
if(array_key_exists($className, $this->_referenceDefinitions)){
$traitsInfo = $this->_referenceDefinitions[$className]['id'];
$encoding = $this->_referenceDefinitions[$className]['encoding'];
$propertyNames = $this->_referenceDefinitions[$className]['propertyNames'];
$traitsInfo = ($traitsInfo << 2) | 0x01;
$writeTraits = false;
} else {
$propertyNames = array();
if($className == ''){
//if there is no className, we interpret the class as dynamic without any sealed members
$encoding = Zend_Amf_Constants::ET_DYNAMIC;
} else {
$encoding = Zend_Amf_Constants::ET_PROPLIST;
foreach($object as $key => $value) {
if( $key[0] != "_") {
$propertyNames[] = $key;
}
}
}
$this->_referenceDefinitions[$className] = array(
'id' => count($this->_referenceDefinitions),
'encoding' => $encoding,
'propertyNames' => $propertyNames,
);
$traitsInfo = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
$traitsInfo |= $encoding << 2;
$traitsInfo |= (count($propertyNames) << 4);
}
$this->writeInteger($traitsInfo);
if($writeTraits){
$this->writeString($className);
foreach ($propertyNames as $value) {
$this->writeString($value);
}
}
try {
switch($encoding) {
case Zend_Amf_Constants::ET_PROPLIST:
@ -474,7 +474,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
foreach ($propertyNames as $key) {
$this->writeTypeMarker($object->$key);
}
//Write remaining properties
foreach($object as $key => $value){
if(!in_array($key,$propertyNames) && $key[0] != "_"){
@ -482,7 +482,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
$this->writeTypeMarker($value);
}
}
//Write an empty string to end the dynamic part
$this->writeString('');
break;
@ -490,7 +490,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('External Object Encoding not implemented');
break;
default:
default:
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Unknown Object Encoding type: ' . $encoding);
}

View File

@ -17,14 +17,14 @@
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Deserializer.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Deserializer.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
* Abstract cass that all deserializer must implement.
*
* Logic for deserialization of the AMF envelop is based on resources supplied
* by Adobe Blaze DS. For and example of deserialization please review the BlazeDS
* Logic for deserialization of the AMF envelop is based on resources supplied
* by Adobe Blaze DS. For and example of deserialization please review the BlazeDS
* source tree.
*
* @see http://opensource.adobe.com/svn/opensource/blazeds/trunk/modules/core/src/java/flex/messaging/io/amf/

View File

@ -17,7 +17,7 @@
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: InputStream.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: InputStream.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Amf_Util_BinaryStream */
@ -26,7 +26,7 @@ require_once 'Zend/Amf/Util/BinaryStream.php';
/**
* InputStream is used to iterate at a binary level through the AMF request.
*
* InputStream extends BinaryStream as eventually BinaryStream could be placed
* InputStream extends BinaryStream as eventually BinaryStream could be placed
* outside of Zend_Amf in order to allow other packages to use the class.
*
* @package Zend_Amf

View File

@ -17,7 +17,7 @@
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: OutputStream.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: OutputStream.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Amf_Util_BinaryStream */
@ -26,7 +26,7 @@ require_once 'Zend/Amf/Util/BinaryStream.php';
/**
* Iterate at a binary level through the AMF response
*
* OutputStream extends BinaryStream as eventually BinaryStream could be placed
* OutputStream extends BinaryStream as eventually BinaryStream could be placed
* outside of Zend_Amf in order to allow other packages to use the class.
*
* @uses Zend_Amf_Util_BinaryStream
@ -39,7 +39,7 @@ class Zend_Amf_Parse_OutputStream extends Zend_Amf_Util_BinaryStream
{
/**
* Constructor
*
*
* @return void
*/
public function __construct()

140
libs/Zend/Amf/Parse/Resource/MysqlResult.php Executable file → Normal file
View File

@ -1,70 +1,70 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: MysqlResult.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
* This class will convert mysql result resource to array suitable for passing
* to the external entities.
*
* @package Zend_Amf
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Parse_Resource_MysqlResult
{
/**
* @var array List of Mysql types with PHP counterparts
*
* Key => Value is Mysql type (exact string) => PHP type
*/
static public $fieldTypes = array(
"int" => "int",
"timestamp" => "int",
"year" => "int",
"real" => "float",
);
/**
* Parse resource into array
*
* @param resource $resource
* @return array
*/
public function parse($resource) {
$result = array();
$fieldcnt = mysql_num_fields($resource);
$fields_transform = array();
for($i=0;$i<$fieldcnt;$i++) {
$type = mysql_field_type($resource, $i);
if(isset(self::$fieldTypes[$type])) {
$fields_transform[mysql_field_name($resource, $i)] = self::$fieldTypes[$type];
}
}
while($row = mysql_fetch_object($resource)) {
foreach($fields_transform as $fieldname => $fieldtype) {
settype($row->$fieldname, $fieldtype);
}
$result[] = $row;
}
return $result;
}
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: MysqlResult.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
* This class will convert mysql result resource to array suitable for passing
* to the external entities.
*
* @package Zend_Amf
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Parse_Resource_MysqlResult
{
/**
* @var array List of Mysql types with PHP counterparts
*
* Key => Value is Mysql type (exact string) => PHP type
*/
static public $fieldTypes = array(
"int" => "int",
"timestamp" => "int",
"year" => "int",
"real" => "float",
);
/**
* Parse resource into array
*
* @param resource $resource
* @return array
*/
public function parse($resource) {
$result = array();
$fieldcnt = mysql_num_fields($resource);
$fields_transform = array();
for($i=0;$i<$fieldcnt;$i++) {
$type = mysql_field_type($resource, $i);
if(isset(self::$fieldTypes[$type])) {
$fields_transform[mysql_field_name($resource, $i)] = self::$fieldTypes[$type];
}
}
while($row = mysql_fetch_object($resource)) {
foreach($fields_transform as $fieldname => $fieldtype) {
settype($row->$fieldname, $fieldtype);
}
$result[] = $row;
}
return $result;
}
}

View File

@ -17,11 +17,11 @@
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: MysqliResult.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: MysqliResult.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
* This class will convert mysql result resource to array suitable for passing
* This class will convert mysql result resource to array suitable for passing
* to the external entities.
*
* @package Zend_Amf
@ -29,89 +29,89 @@
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Parse_Resource_MysqliResult
class Zend_Amf_Parse_Resource_MysqliResult
{
/**
* mapping taken from http://forums.mysql.com/read.php?52,255868,255895#msg-255895
*/
/**
* mapping taken from http://forums.mysql.com/read.php?52,255868,255895#msg-255895
*/
static public $mysqli_type = array(
0 => "MYSQLI_TYPE_DECIMAL",
1 => "MYSQLI_TYPE_TINYINT",
2 => "MYSQLI_TYPE_SMALLINT",
3 => "MYSQLI_TYPE_INTEGER",
4 => "MYSQLI_TYPE_FLOAT",
5 => "MYSQLI_TYPE_DOUBLE",
7 => "MYSQLI_TYPE_TIMESTAMP",
8 => "MYSQLI_TYPE_BIGINT",
9 => "MYSQLI_TYPE_MEDIUMINT",
10 => "MYSQLI_TYPE_DATE",
11 => "MYSQLI_TYPE_TIME",
12 => "MYSQLI_TYPE_DATETIME",
13 => "MYSQLI_TYPE_YEAR",
14 => "MYSQLI_TYPE_DATE",
16 => "MYSQLI_TYPE_BIT",
246 => "MYSQLI_TYPE_DECIMAL",
247 => "MYSQLI_TYPE_ENUM",
248 => "MYSQLI_TYPE_SET",
249 => "MYSQLI_TYPE_TINYBLOB",
250 => "MYSQLI_TYPE_MEDIUMBLOB",
251 => "MYSQLI_TYPE_LONGBLOB",
252 => "MYSQLI_TYPE_BLOB",
253 => "MYSQLI_TYPE_VARCHAR",
254 => "MYSQLI_TYPE_CHAR",
255 => "MYSQLI_TYPE_GEOMETRY",
0 => "MYSQLI_TYPE_DECIMAL",
1 => "MYSQLI_TYPE_TINYINT",
2 => "MYSQLI_TYPE_SMALLINT",
3 => "MYSQLI_TYPE_INTEGER",
4 => "MYSQLI_TYPE_FLOAT",
5 => "MYSQLI_TYPE_DOUBLE",
7 => "MYSQLI_TYPE_TIMESTAMP",
8 => "MYSQLI_TYPE_BIGINT",
9 => "MYSQLI_TYPE_MEDIUMINT",
10 => "MYSQLI_TYPE_DATE",
11 => "MYSQLI_TYPE_TIME",
12 => "MYSQLI_TYPE_DATETIME",
13 => "MYSQLI_TYPE_YEAR",
14 => "MYSQLI_TYPE_DATE",
16 => "MYSQLI_TYPE_BIT",
246 => "MYSQLI_TYPE_DECIMAL",
247 => "MYSQLI_TYPE_ENUM",
248 => "MYSQLI_TYPE_SET",
249 => "MYSQLI_TYPE_TINYBLOB",
250 => "MYSQLI_TYPE_MEDIUMBLOB",
251 => "MYSQLI_TYPE_LONGBLOB",
252 => "MYSQLI_TYPE_BLOB",
253 => "MYSQLI_TYPE_VARCHAR",
254 => "MYSQLI_TYPE_CHAR",
255 => "MYSQLI_TYPE_GEOMETRY",
);
// Build an associative array for a type look up
static $mysqli_to_php = array(
"MYSQLI_TYPE_DECIMAL" => 'float',
"MYSQLI_TYPE_NEWDECIMAL" => 'float',
"MYSQLI_TYPE_BIT" => 'integer',
"MYSQLI_TYPE_TINYINT" => 'integer',
"MYSQLI_TYPE_SMALLINT" => 'integer',
"MYSQLI_TYPE_MEDIUMINT" => 'integer',
"MYSQLI_TYPE_BIGINT" => 'integer',
"MYSQLI_TYPE_INTEGER" => 'integer',
"MYSQLI_TYPE_FLOAT" => 'float',
"MYSQLI_TYPE_DOUBLE" => 'float',
"MYSQLI_TYPE_NULL" => 'null',
"MYSQLI_TYPE_TIMESTAMP" => 'string',
"MYSQLI_TYPE_INT24" => 'integer',
"MYSQLI_TYPE_DATE" => 'string',
"MYSQLI_TYPE_TIME" => 'string',
"MYSQLI_TYPE_DATETIME" => 'string',
"MYSQLI_TYPE_YEAR" => 'string',
"MYSQLI_TYPE_NEWDATE" => 'string',
"MYSQLI_TYPE_ENUM" => 'string',
"MYSQLI_TYPE_SET" => 'string',
"MYSQLI_TYPE_TINYBLOB" => 'object',
"MYSQLI_TYPE_MEDIUMBLOB" => 'object',
"MYSQLI_TYPE_LONGBLOB" => 'object',
"MYSQLI_TYPE_BLOB" => 'object',
"MYSQLI_TYPE_CHAR" => 'string',
"MYSQLI_TYPE_VARCHAR" => 'string',
"MYSQLI_TYPE_GEOMETRY" => 'object',
"MYSQLI_TYPE_BIT" => 'integer',
);
"MYSQLI_TYPE_DECIMAL" => 'float',
"MYSQLI_TYPE_NEWDECIMAL" => 'float',
"MYSQLI_TYPE_BIT" => 'integer',
"MYSQLI_TYPE_TINYINT" => 'integer',
"MYSQLI_TYPE_SMALLINT" => 'integer',
"MYSQLI_TYPE_MEDIUMINT" => 'integer',
"MYSQLI_TYPE_BIGINT" => 'integer',
"MYSQLI_TYPE_INTEGER" => 'integer',
"MYSQLI_TYPE_FLOAT" => 'float',
"MYSQLI_TYPE_DOUBLE" => 'float',
"MYSQLI_TYPE_NULL" => 'null',
"MYSQLI_TYPE_TIMESTAMP" => 'string',
"MYSQLI_TYPE_INT24" => 'integer',
"MYSQLI_TYPE_DATE" => 'string',
"MYSQLI_TYPE_TIME" => 'string',
"MYSQLI_TYPE_DATETIME" => 'string',
"MYSQLI_TYPE_YEAR" => 'string',
"MYSQLI_TYPE_NEWDATE" => 'string',
"MYSQLI_TYPE_ENUM" => 'string',
"MYSQLI_TYPE_SET" => 'string',
"MYSQLI_TYPE_TINYBLOB" => 'object',
"MYSQLI_TYPE_MEDIUMBLOB" => 'object',
"MYSQLI_TYPE_LONGBLOB" => 'object',
"MYSQLI_TYPE_BLOB" => 'object',
"MYSQLI_TYPE_CHAR" => 'string',
"MYSQLI_TYPE_VARCHAR" => 'string',
"MYSQLI_TYPE_GEOMETRY" => 'object',
"MYSQLI_TYPE_BIT" => 'integer',
);
/**
* Parse resource into array
*
*
* @param resource $resource
* @return array
*/
public function parse($resource) {
$result = array();
$fieldcnt = mysqli_num_fields($resource);
$fields_transform = array();
for($i=0;$i<$fieldcnt;$i++) {
$finfo = mysqli_fetch_field_direct($resource, $i);
if(isset(self::$mysqli_type[$finfo->type])) {
$fields_transform[$finfo->name] = self::$mysqli_to_php[self::$mysqli_type[$finfo->type]];
}

84
libs/Zend/Amf/Parse/Resource/Stream.php Executable file → Normal file
View File

@ -1,42 +1,42 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Stream.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
* This class will convert stream resource to string by just reading it
*
* @package Zend_Amf
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Parse_Resource_Stream
{
/**
* Parse resource into string
*
* @param resource $resource Stream resource
* @return array
*/
public function parse($resource) {
return stream_get_contents($resource);
}
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Stream.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
* This class will convert stream resource to string by just reading it
*
* @package Zend_Amf
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Parse_Resource_Stream
{
/**
* Parse resource into string
*
* @param resource $resource Stream resource
* @return array
*/
public function parse($resource) {
return stream_get_contents($resource);
}
}

View File

@ -17,7 +17,7 @@
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Serializer.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Serializer.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -39,8 +39,8 @@ abstract class Zend_Amf_Parse_Serializer
/**
* Constructor
*
* @param Zend_Amf_Parse_OutputStream $stream
*
* @param Zend_Amf_Parse_OutputStream $stream
* @return void
*/
public function __construct(Zend_Amf_Parse_OutputStream $stream)

View File

@ -17,7 +17,7 @@
* @subpackage Parse
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: TypeLoader.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: TypeLoader.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -80,7 +80,7 @@ final class Zend_Amf_Parse_TypeLoader
'flex.messaging.messages.RemotingMessage' => 'Zend_Amf_Value_Messaging_RemotingMessage',
'flex.messaging.io.ArrayCollection' => 'Zend_Amf_Value_Messaging_ArrayCollection',
);
/**
* @var Zend_Loader_PluginLoader_Interface
*/
@ -153,79 +153,79 @@ final class Zend_Amf_Parse_TypeLoader
{
self::$classMap = self::$_defaultClassMap;
}
/**
* Set loader for resource type handlers
*
* @param Zend_Loader_PluginLoader_Interface $loader
*
* @param Zend_Loader_PluginLoader_Interface $loader
*/
public static function setResourceLoader(Zend_Loader_PluginLoader_Interface $loader)
{
self::$_resourceLoader = $loader;
self::$_resourceLoader = $loader;
}
/**
* Add directory to the list of places where to look for resource handlers
*
* Add directory to the list of places where to look for resource handlers
*
* @param string $prefix
* @param string $dir
*/
public static function addResourceDirectory($prefix, $dir)
{
if(self::$_resourceLoader) {
self::$_resourceLoader->addPrefixPath($prefix, $dir);
}
if(self::$_resourceLoader) {
self::$_resourceLoader->addPrefixPath($prefix, $dir);
}
}
/**
* Get plugin class that handles this resource
*
*
* @param resource $resource Resource type
* @return string Class name
*/
public static function getResourceParser($resource)
{
if(self::$_resourceLoader) {
$type = preg_replace("/[^A-Za-z0-9_]/", " ", get_resource_type($resource));
$type = str_replace(" ","", ucwords($type));
return self::$_resourceLoader->load($type);
}
return false;
if(self::$_resourceLoader) {
$type = preg_replace("/[^A-Za-z0-9_]/", " ", get_resource_type($resource));
$type = str_replace(" ","", ucwords($type));
return self::$_resourceLoader->load($type);
}
return false;
}
/**
* Convert resource to a serializable object
*
*
* @param resource $resource
* @return mixed
*/
public static function handleResource($resource)
{
if(!self::$_resourceLoader) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Unable to handle resources - resource plugin loader not set');
}
try {
while(is_resource($resource)) {
$resclass = self::getResourceParser($resource);
if(!$resclass) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource));
}
$parser = new $resclass();
if(is_callable(array($parser, 'parse'))) {
$resource = $parser->parse($resource);
} else {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception("Could not call parse() method on class $resclass");
}
}
return $resource;
} catch(Zend_Amf_Exception $e) {
throw $e;
} catch(Exception $e) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource));
}
if(!self::$_resourceLoader) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Unable to handle resources - resource plugin loader not set');
}
try {
while(is_resource($resource)) {
$resclass = self::getResourceParser($resource);
if(!$resclass) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource));
}
$parser = new $resclass();
if(is_callable(array($parser, 'parse'))) {
$resource = $parser->parse($resource);
} else {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception("Could not call parse() method on class $resclass");
}
}
return $resource;
} catch(Zend_Amf_Exception $e) {
throw $e;
} catch(Exception $e) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource));
}
}
}

View File

@ -17,7 +17,7 @@
* @subpackage Request
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Http.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Http.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Amf_Request */
@ -54,8 +54,8 @@ class Zend_Amf_Request_Http extends Zend_Amf_Request
*/
public function __construct()
{
// php://input allows you to read raw POST data. It is a less memory
// intensive alternative to $HTTP_RAW_POST_DATA and does not need any
// php://input allows you to read raw POST data. It is a less memory
// intensive alternative to $HTTP_RAW_POST_DATA and does not need any
// special php.ini directives
$amfRequest = file_get_contents('php://input');
@ -70,7 +70,7 @@ class Zend_Amf_Request_Http extends Zend_Amf_Request
/**
* Retrieve raw AMF Request
*
*
* @return string
*/
public function getRawRequest()

View File

@ -16,7 +16,7 @@
* @package Zend_Amf
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Response.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Response.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Amf_Constants */
@ -172,7 +172,7 @@ class Zend_Amf_Response
/**
* Retrieve attached AMF message headers
*
*
* @return array Array of Zend_Amf_Value_MessageHeader objects
*/
public function getAmfHeaders()

View File

@ -16,7 +16,7 @@
* @package Zend_Amf
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Server.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Server.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Server_Interface */
@ -62,10 +62,10 @@ class Zend_Amf_Server implements Zend_Server_Interface
* @var array
*/
protected $_methods = array();
/**
* Array of classes that can be called without being explicitly loaded
*
*
* Keys are class names.
*
* @var array
@ -121,13 +121,13 @@ class Zend_Amf_Server implements Zend_Server_Interface
/**
* Authentication handler object
*
*
* @var Zend_Amf_Auth_Abstract
*/
protected $_auth;
/**
* ACL handler object
*
*
* @var Zend_Acl
*/
protected $_acl;
@ -136,9 +136,9 @@ class Zend_Amf_Server implements Zend_Server_Interface
*/
public function __construct()
{
Zend_Amf_Parse_TypeLoader::setResourceLoader(new Zend_Loader_PluginLoader(array("Zend_Amf_Parse_Resource" => "Zend/Amf/Parse/Resource")));
Zend_Amf_Parse_TypeLoader::setResourceLoader(new Zend_Loader_PluginLoader(array("Zend_Amf_Parse_Resource" => "Zend/Amf/Parse/Resource")));
}
/**
* Set authentication adapter
*
@ -159,7 +159,7 @@ class Zend_Amf_Server implements Zend_Server_Interface
{
return $this->_auth;
}
/**
* Set ACL adapter
*
@ -180,7 +180,7 @@ class Zend_Amf_Server implements Zend_Server_Interface
{
return $this->_acl;
}
/**
* Set production flag
*
@ -225,8 +225,8 @@ class Zend_Amf_Server implements Zend_Server_Interface
}
/**
* Check if the ACL allows accessing the function or method
*
* Check if the ACL allows accessing the function or method
*
* @param string|object $object Object or class being accessed
* @param string $function Function or method being acessed
* @return unknown_type
@ -239,7 +239,7 @@ class Zend_Amf_Server implements Zend_Server_Interface
if($object) {
$class = is_object($object)?get_class($object):$object;
if(!$this->_acl->has($class)) {
require_once 'Zend/Acl/Resource.php';
require_once 'Zend/Acl/Resource.php';
$this->_acl->add(new Zend_Acl_Resource($class));
}
$call = array($object, "initAcl");
@ -250,15 +250,15 @@ class Zend_Amf_Server implements Zend_Server_Interface
} else {
$class = null;
}
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity()) {
$role = $auth->getIdentity()->role;
} else {
if($this->_acl->hasRole(Zend_Amf_Constants::GUEST_ROLE)) {
if($this->_acl->hasRole(Zend_Amf_Constants::GUEST_ROLE)) {
$role = Zend_Amf_Constants::GUEST_ROLE;
} else {
require_once 'Zend/Amf/Server/Exception.php';
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception("Unauthenticated access not allowed");
}
}
@ -269,7 +269,7 @@ class Zend_Amf_Server implements Zend_Server_Interface
throw new Zend_Amf_Server_Exception("Access not allowed");
}
}
/**
* Get PluginLoader for the Server
*
@ -277,13 +277,13 @@ class Zend_Amf_Server implements Zend_Server_Interface
*/
protected function getLoader()
{
if(empty($this->_loader)) {
require_once 'Zend/Loader/PluginLoader.php';
$this->_loader = new Zend_Loader_PluginLoader();
}
return $this->_loader;
if(empty($this->_loader)) {
require_once 'Zend/Loader/PluginLoader.php';
$this->_loader = new Zend_Loader_PluginLoader();
}
return $this->_loader;
}
/**
* Loads a remote class or method and executes the function and returns
* the result
@ -295,23 +295,23 @@ class Zend_Amf_Server implements Zend_Server_Interface
*/
protected function _dispatch($method, $params = null, $source = null)
{
if($source) {
if(($mapped = Zend_Amf_Parse_TypeLoader::getMappedClassName($source)) !== false) {
$source = $mapped;
}
}
if($source) {
if(($mapped = Zend_Amf_Parse_TypeLoader::getMappedClassName($source)) !== false) {
$source = $mapped;
}
}
$qualifiedName = empty($source) ? $method : $source.".".$method;
if (!isset($this->_table[$qualifiedName])) {
// if source is null a method that was not defined was called.
if ($source) {
$className = str_replace(".", "_", $source);
if(class_exists($className, false) && !isset($this->_classAllowed[$className])) {
require_once 'Zend/Amf/Server/Exception.php';
$className = str_replace(".", "_", $source);
if(class_exists($className, false) && !isset($this->_classAllowed[$className])) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Can not call "' . $className . '" - use setClass()');
}
}
try {
$this->getLoader()->load($className);
$this->getLoader()->load($className);
} catch (Exception $e) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Class "' . $className . '" does not exist: '.$e->getMessage());
@ -326,7 +326,7 @@ class Zend_Amf_Server implements Zend_Server_Interface
$info = $this->_table[$qualifiedName];
$argv = $info->getInvokeArguments();
if (0 < count($argv)) {
$params = array_merge($params, $argv);
}
@ -377,13 +377,13 @@ class Zend_Amf_Server implements Zend_Server_Interface
require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
switch($message->operation) {
case Zend_Amf_Value_Messaging_CommandMessage::DISCONNECT_OPERATION :
case Zend_Amf_Value_Messaging_CommandMessage::CLIENT_PING_OPERATION :
case Zend_Amf_Value_Messaging_CommandMessage::CLIENT_PING_OPERATION :
$return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
break;
case Zend_Amf_Value_Messaging_CommandMessage::LOGIN_OPERATION :
$data = explode(':', base64_decode($message->body));
$userid = $data[0];
$password = isset($data[1])?$data[1]:"";
$userid = $data[0];
$password = isset($data[1])?$data[1]:"";
if(empty($userid)) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Login failed: username not supplied');
@ -410,7 +410,7 @@ class Zend_Amf_Server implements Zend_Server_Interface
/**
* Create appropriate error message
*
*
* @param int $objectEncoding Current AMF encoding
* @param string $message Message that was being processed when error happened
* @param string $description Error description
@ -422,55 +422,55 @@ class Zend_Amf_Server implements Zend_Server_Interface
protected function _errorMessage($objectEncoding, $message, $description, $detail, $code, $line)
{
$return = null;
switch ($objectEncoding) {
case Zend_Amf_Constants::AMF0_OBJECT_ENCODING :
return array (
'description' => ($this->isProduction ()) ? '' : $description,
'detail' => ($this->isProduction ()) ? '' : $detail,
'line' => ($this->isProduction ()) ? 0 : $line,
'code' => $code
);
case Zend_Amf_Constants::AMF3_OBJECT_ENCODING :
require_once 'Zend/Amf/Value/Messaging/ErrorMessage.php';
$return = new Zend_Amf_Value_Messaging_ErrorMessage ( $message );
$return->faultString = $this->isProduction () ? '' : $description;
$return->faultCode = $code;
$return->faultDetail = $this->isProduction () ? '' : $detail;
break;
}
switch ($objectEncoding) {
case Zend_Amf_Constants::AMF0_OBJECT_ENCODING :
return array (
'description' => ($this->isProduction ()) ? '' : $description,
'detail' => ($this->isProduction ()) ? '' : $detail,
'line' => ($this->isProduction ()) ? 0 : $line,
'code' => $code
);
case Zend_Amf_Constants::AMF3_OBJECT_ENCODING :
require_once 'Zend/Amf/Value/Messaging/ErrorMessage.php';
$return = new Zend_Amf_Value_Messaging_ErrorMessage ( $message );
$return->faultString = $this->isProduction () ? '' : $description;
$return->faultCode = $code;
$return->faultDetail = $this->isProduction () ? '' : $detail;
break;
}
return $return;
}
/**
* Handle AMF authenticaton
*
* @param string $userid
* @param string $password
* @return boolean
*/
protected function _handleAuth( $userid, $password)
{
if (!$this->_auth) {
return true;
}
$this->_auth->setCredentials($userid, $password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($this->_auth);
if ($result->isValid()) {
if (!$this->isSession()) {
$this->setSession();
}
return true;
} else {
// authentication failed, good bye
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception(
"Authentication failed: " . join("\n",
$result->getMessages()), $result->getCode());
}
/**
* Handle AMF authenticaton
*
* @param string $userid
* @param string $password
* @return boolean
*/
protected function _handleAuth( $userid, $password)
{
if (!$this->_auth) {
return true;
}
$this->_auth->setCredentials($userid, $password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($this->_auth);
if ($result->isValid()) {
if (!$this->isSession()) {
$this->setSession();
}
return true;
} else {
// authentication failed, good bye
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception(
"Authentication failed: " . join("\n",
$result->getMessages()), $result->getCode());
}
}
/**
* Takes the deserialized AMF request and performs any operations.
*
@ -490,38 +490,38 @@ class Zend_Amf_Server implements Zend_Server_Interface
// set reponse encoding
$response->setObjectEncoding($objectEncoding);
$responseBody = $request->getAmfBodies();
$handleAuth = false;
if ($this->_auth) {
$headers = $request->getAmfHeaders();
if (isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER]) &&
isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->userid)) {
$handleAuth = true;
}
}
if ($this->_auth) {
$headers = $request->getAmfHeaders();
if (isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER]) &&
isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->userid)) {
$handleAuth = true;
}
}
// Iterate through each of the service calls in the AMF request
foreach($responseBody as $body)
{
try {
if ($handleAuth) {
if ($this->_handleAuth(
$headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->userid,
$headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->password)) {
// use RequestPersistentHeader to clear credentials
$response->addAmfHeader(
new Zend_Amf_Value_MessageHeader(
Zend_Amf_Constants::PERSISTENT_HEADER,
false,
new Zend_Amf_Value_MessageHeader(
Zend_Amf_Constants::CREDENTIALS_HEADER,
false, null)));
$handleAuth = false;
}
}
if ($handleAuth) {
if ($this->_handleAuth(
$headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->userid,
$headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->password)) {
// use RequestPersistentHeader to clear credentials
$response->addAmfHeader(
new Zend_Amf_Value_MessageHeader(
Zend_Amf_Constants::PERSISTENT_HEADER,
false,
new Zend_Amf_Value_MessageHeader(
Zend_Amf_Constants::CREDENTIALS_HEADER,
false, null)));
$handleAuth = false;
}
}
if ($objectEncoding == Zend_Amf_Constants::AMF0_OBJECT_ENCODING) {
// AMF0 Object Encoding
$targetURI = $body->getTargetURI();
@ -567,7 +567,7 @@ class Zend_Amf_Server implements Zend_Server_Interface
}
$responseType = Zend_AMF_Constants::RESULT_METHOD;
} catch (Exception $e) {
$return = $this->_errorMessage($objectEncoding, $message,
$return = $this->_errorMessage($objectEncoding, $message,
$e->getMessage(), $e->getTraceAsString(),$e->getCode(), $e->getLine());
$responseType = Zend_AMF_Constants::STATUS_METHOD;
}
@ -584,10 +584,10 @@ class Zend_Amf_Server implements Zend_Server_Interface
if(!strpos($_SERVER['QUERY_STRING'], $currentID) !== FALSE) {
if(strrpos($_SERVER['QUERY_STRING'], "?") !== FALSE) {
$joint = "&";
}
}
}
}
}
// create a new AMF message header with the session id as a variable.
$sessionValue = $joint . $this->_sessionName . "=" . $currentID;
$sessionHeader = new Zend_Amf_Value_MessageHeader(Zend_Amf_Constants::URL_APPEND_HEADER, false, $sessionValue);
@ -739,11 +739,11 @@ class Zend_Amf_Server implements Zend_Server_Interface
}
// Use the class name as the name space by default.
if ($namespace == '') {
$namespace = is_object($class) ? get_class($class) : $class;
}
$this->_classAllowed[is_object($class) ? get_class($class) : $class] = true;
$this->_methods[] = Zend_Server_Reflection::reflectClass($class, $argv, $namespace);
@ -793,12 +793,12 @@ class Zend_Amf_Server implements Zend_Server_Interface
/**
* Creates an array of directories in which services can reside.
* TODO: add support for prefixes?
*
*
* @param string $dir
*/
public function addDirectory($dir)
{
$this->getLoader()->addPrefixPath("", $dir);
$this->getLoader()->addPrefixPath("", $dir);
}
/**

View File

@ -17,7 +17,7 @@
* @subpackage Util
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: BinaryStream.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: BinaryStream.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -53,8 +53,8 @@ class Zend_Amf_Util_BinaryStream
/**
* Constructor
*
* Create a refrence to a byte stream that is going to be parsed or created
* by the methods in the class. Detect if the class should use big or
* Create a refrence to a byte stream that is going to be parsed or created
* by the methods in the class. Detect if the class should use big or
* little Endian encoding.
*
* @param string $stream use '' if creating a new stream or pass a string if reading.

View File

@ -17,7 +17,7 @@
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ByteArray.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: ByteArray.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -28,7 +28,7 @@
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_ByteArray
class Zend_Amf_Value_ByteArray
{
/**
* @var string ByteString Data

View File

@ -1,182 +1,182 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: MessageBody.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
* An AMF Message contains information about the actual individual
* transaction that is to be performed. It specifies the remote
* operation that is to be performed; a local (client) operation
* to be invoked upon success; and, the data to be used in the
* operation.
* <p/>
* This Message structure defines how a local client would
* invoke a method/operation on a remote server. Additionally,
* the response from the Server is structured identically.
*
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_MessageBody
{
/**
* A string describing which operation, function, or method
* is to be remotley invoked.
* @var string
*/
protected $_targetUri = "";
/**
* Universal Resource Identifier that uniquely targets the originator's
* Object that should receive the server's response. The server will
* use this path specification to target the "OnResult()" or "onStatus()"
* handlers within the client. For Flash, it specifies an ActionScript
* Object path only. The NetResponse object pointed to by the Response Uri
* contains the connection state information. Passing/specifying this
* provides a convenient mechanism for the client/server to share access
* to an object that is managing the state of the shared connection.
*
* Since the server will use this field in the event of an error,
* this field is required even if a successful server request would
* not be expected to return a value to the client.
*
* @var string
*/
protected $_responseUri = "";
/**
* Contains the actual data associated with the operation. It contains
* the client's parameter data that is passed to the server's operation/method.
* When serializing a root level data type or a parameter list array, no
* name field is included. That is, the data is anonomously represented
* as "Type Marker"/"Value" pairs. When serializing member data, the data is
* represented as a series of "Name"/"Type"/"Value" combinations.
*
* For server generated responses, it may contain any ActionScript
* data/objects that the server was expected to provide.
*
* @var string
*/
protected $_data;
/**
* Constructor
*
* @param string $targetUri
* @param string $responseUri
* @param string $data
* @return void
*/
public function __construct($targetUri, $responseUri, $data)
{
$this->setTargetUri($targetUri);
$this->setResponseUri($responseUri);
$this->setData($data);
}
/**
* Retrieve target Uri
*
* @return string
*/
public function getTargetUri()
{
return $this->_targetUri;
}
/**
* Set target Uri
*
* @param string $targetUri
* @return Zend_Amf_Value_MessageBody
*/
public function setTargetUri($targetUri)
{
if (null === $targetUri) {
$targetUri = '';
}
$this->_targetUri = (string) $targetUri;
return $this;
}
/**
* Get target Uri
*
* @return string
*/
public function getResponseUri()
{
return $this->_responseUri;
}
/**
* Set response Uri
*
* @param string $responseUri
* @return Zend_Amf_Value_MessageBody
*/
public function setResponseUri($responseUri)
{
if (null === $responseUri) {
$responseUri = '';
}
$this->_responseUri = $responseUri;
return $this;
}
/**
* Retrieve response data
*
* @return string
*/
public function getData()
{
return $this->_data;
}
/**
* Set response data
*
* @param mixed $data
* @return Zend_Amf_Value_MessageBody
*/
public function setData($data)
{
$this->_data = $data;
return $this;
}
/**
* Set reply method
*
* @param string $methodName
* @return Zend_Amf_Value_MessageBody
*/
public function setReplyMethod($methodName)
{
if (!preg_match('#^[/?]#', $methodName)) {
$this->_targetUri = rtrim($this->_targetUri, '/') . '/';
}
$this->_targetUri = $this->_targetUri . $methodName;
return $this;
}
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: MessageBody.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
* An AMF Message contains information about the actual individual
* transaction that is to be performed. It specifies the remote
* operation that is to be performed; a local (client) operation
* to be invoked upon success; and, the data to be used in the
* operation.
* <p/>
* This Message structure defines how a local client would
* invoke a method/operation on a remote server. Additionally,
* the response from the Server is structured identically.
*
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_MessageBody
{
/**
* A string describing which operation, function, or method
* is to be remotley invoked.
* @var string
*/
protected $_targetUri = "";
/**
* Universal Resource Identifier that uniquely targets the originator's
* Object that should receive the server's response. The server will
* use this path specification to target the "OnResult()" or "onStatus()"
* handlers within the client. For Flash, it specifies an ActionScript
* Object path only. The NetResponse object pointed to by the Response Uri
* contains the connection state information. Passing/specifying this
* provides a convenient mechanism for the client/server to share access
* to an object that is managing the state of the shared connection.
*
* Since the server will use this field in the event of an error,
* this field is required even if a successful server request would
* not be expected to return a value to the client.
*
* @var string
*/
protected $_responseUri = "";
/**
* Contains the actual data associated with the operation. It contains
* the client's parameter data that is passed to the server's operation/method.
* When serializing a root level data type or a parameter list array, no
* name field is included. That is, the data is anonomously represented
* as "Type Marker"/"Value" pairs. When serializing member data, the data is
* represented as a series of "Name"/"Type"/"Value" combinations.
*
* For server generated responses, it may contain any ActionScript
* data/objects that the server was expected to provide.
*
* @var string
*/
protected $_data;
/**
* Constructor
*
* @param string $targetUri
* @param string $responseUri
* @param string $data
* @return void
*/
public function __construct($targetUri, $responseUri, $data)
{
$this->setTargetUri($targetUri);
$this->setResponseUri($responseUri);
$this->setData($data);
}
/**
* Retrieve target Uri
*
* @return string
*/
public function getTargetUri()
{
return $this->_targetUri;
}
/**
* Set target Uri
*
* @param string $targetUri
* @return Zend_Amf_Value_MessageBody
*/
public function setTargetUri($targetUri)
{
if (null === $targetUri) {
$targetUri = '';
}
$this->_targetUri = (string) $targetUri;
return $this;
}
/**
* Get target Uri
*
* @return string
*/
public function getResponseUri()
{
return $this->_responseUri;
}
/**
* Set response Uri
*
* @param string $responseUri
* @return Zend_Amf_Value_MessageBody
*/
public function setResponseUri($responseUri)
{
if (null === $responseUri) {
$responseUri = '';
}
$this->_responseUri = $responseUri;
return $this;
}
/**
* Retrieve response data
*
* @return string
*/
public function getData()
{
return $this->_data;
}
/**
* Set response data
*
* @param mixed $data
* @return Zend_Amf_Value_MessageBody
*/
public function setData($data)
{
$this->_data = $data;
return $this;
}
/**
* Set reply method
*
* @param string $methodName
* @return Zend_Amf_Value_MessageBody
*/
public function setReplyMethod($methodName)
{
if (!preg_match('#^[/?]#', $methodName)) {
$this->_targetUri = rtrim($this->_targetUri, '/') . '/';
}
$this->_targetUri = $this->_targetUri . $methodName;
return $this;
}
}

View File

@ -17,13 +17,13 @@
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: MessageHeader.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: MessageHeader.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
* Message Headers provide context for the processing of the
* the AMF Packet and all subsequent Messages.
*
*
* Multiple Message Headers may be included within an AMF Packet.
*
* @package Zend_Amf
@ -31,7 +31,7 @@
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_MessageHeader
class Zend_Amf_Value_MessageHeader
{
/**
* Name of the header

0
libs/Zend/Amf/Value/Messaging/ArrayCollection.php Executable file → Normal file
View File

View File

@ -1,131 +1,131 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CommandMessage.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CommandMessage.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
* @see Zend_Amf_Value_Messaging_AsyncMessage
*/
require_once 'Zend/Amf/Value/Messaging/AsyncMessage.php';
/**
* A message that represents an infrastructure command passed between
* client and server. Subscribe/unsubscribe operations result in
* CommandMessage transmissions, as do polling operations.
*
* Corresponds to flex.messaging.messages.CommandMessage
*
* Note: THESE VALUES MUST BE THE SAME ON CLIENT AND SERVER
*
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_Messaging_CommandMessage extends Zend_Amf_Value_Messaging_AsyncMessage
{
/**
* This operation is used to subscribe to a remote destination.
* @const int
*/
const SUBSCRIBE_OPERATION = 0;
/**
* This operation is used to unsubscribe from a remote destination.
* @const int
*/
const UNSUSBSCRIBE_OPERATION = 1;
/**
* This operation is used to poll a remote destination for pending,
* undelivered messages.
* @const int
*/
const POLL_OPERATION = 2;
/**
* This operation is used by a remote destination to sync missed or cached messages
* back to a client as a result of a client issued poll command.
* @const int
*/
const CLIENT_SYNC_OPERATION = 4;
/**
* This operation is used to test connectivity over the current channel to
* the remote endpoint.
* @const int
*/
const CLIENT_PING_OPERATION = 5;
/**
* This operation is used to request a list of failover endpoint URIs
* for the remote destination based on cluster membership.
* @const int
*/
const CLUSTER_REQUEST_OPERATION = 7;
/**
* This operation is used to send credentials to the endpoint so that
* the user can be logged in over the current channel.
* The credentials need to be Base64 encoded and stored in the <code>body</code>
* of the message.
* @const int
*/
const LOGIN_OPERATION = 8;
/**
* This operation is used to log the user out of the current channel, and
* will invalidate the server session if the channel is HTTP based.
* @const int
*/
const LOGOUT_OPERATION = 9;
/**
* This operation is used to indicate that the client's subscription to a
* remote destination has been invalidated.
* @const int
*/
const SESSION_INVALIDATE_OPERATION = 10;
/**
* This operation is used by the MultiTopicConsumer to subscribe/unsubscribe
* from multiple subtopics/selectors in the same message.
* @const int
*/
const MULTI_SUBSCRIBE_OPERATION = 11;
/**
* This operation is used to indicate that a channel has disconnected
* @const int
*/
const DISCONNECT_OPERATION = 12;
/**
* This is the default operation for new CommandMessage instances.
* @const int
*/
const UNKNOWN_OPERATION = 10000;
/**
* The operation to execute for messages of this type
* @var int
*/
public $operation = self::UNKNOWN_OPERATION;
}
*/
require_once 'Zend/Amf/Value/Messaging/AsyncMessage.php';
/**
* A message that represents an infrastructure command passed between
* client and server. Subscribe/unsubscribe operations result in
* CommandMessage transmissions, as do polling operations.
*
* Corresponds to flex.messaging.messages.CommandMessage
*
* Note: THESE VALUES MUST BE THE SAME ON CLIENT AND SERVER
*
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_Messaging_CommandMessage extends Zend_Amf_Value_Messaging_AsyncMessage
{
/**
* This operation is used to subscribe to a remote destination.
* @const int
*/
const SUBSCRIBE_OPERATION = 0;
/**
* This operation is used to unsubscribe from a remote destination.
* @const int
*/
const UNSUSBSCRIBE_OPERATION = 1;
/**
* This operation is used to poll a remote destination for pending,
* undelivered messages.
* @const int
*/
const POLL_OPERATION = 2;
/**
* This operation is used by a remote destination to sync missed or cached messages
* back to a client as a result of a client issued poll command.
* @const int
*/
const CLIENT_SYNC_OPERATION = 4;
/**
* This operation is used to test connectivity over the current channel to
* the remote endpoint.
* @const int
*/
const CLIENT_PING_OPERATION = 5;
/**
* This operation is used to request a list of failover endpoint URIs
* for the remote destination based on cluster membership.
* @const int
*/
const CLUSTER_REQUEST_OPERATION = 7;
/**
* This operation is used to send credentials to the endpoint so that
* the user can be logged in over the current channel.
* The credentials need to be Base64 encoded and stored in the <code>body</code>
* of the message.
* @const int
*/
const LOGIN_OPERATION = 8;
/**
* This operation is used to log the user out of the current channel, and
* will invalidate the server session if the channel is HTTP based.
* @const int
*/
const LOGOUT_OPERATION = 9;
/**
* This operation is used to indicate that the client's subscription to a
* remote destination has been invalidated.
* @const int
*/
const SESSION_INVALIDATE_OPERATION = 10;
/**
* This operation is used by the MultiTopicConsumer to subscribe/unsubscribe
* from multiple subtopics/selectors in the same message.
* @const int
*/
const MULTI_SUBSCRIBE_OPERATION = 11;
/**
* This operation is used to indicate that a channel has disconnected
* @const int
*/
const DISCONNECT_OPERATION = 12;
/**
* This is the default operation for new CommandMessage instances.
* @const int
*/
const UNKNOWN_OPERATION = 10000;
/**
* The operation to execute for messages of this type
* @var int
*/
public $operation = self::UNKNOWN_OPERATION;
}

View File

@ -1,67 +1,67 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ErrorMessage.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/** Zend_Amf_Value_Messaging_AcknowledgeMessage */
require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
/**
* Creates the error message to report to flex the issue with the call
*
* Corresponds to flex.messaging.messages.ErrorMessage
*
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_Messaging_ErrorMessage extends Zend_Amf_Value_Messaging_AcknowledgeMessage
{
/**
* Additional data with error
* @var object
*/
public $extendedData = null;
/**
* Error code number
* @var string
*/
public $faultCode;
/**
* Description as to the cause of the error
* @var string
*/
public $faultDetail;
/**
* Short description of error
* @var string
*/
public $faultString = '';
/**
* root cause of error
* @var object
*/
public $rootCause = null;
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ErrorMessage.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Amf_Value_Messaging_AcknowledgeMessage */
require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
/**
* Creates the error message to report to flex the issue with the call
*
* Corresponds to flex.messaging.messages.ErrorMessage
*
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_Messaging_ErrorMessage extends Zend_Amf_Value_Messaging_AcknowledgeMessage
{
/**
* Additional data with error
* @var object
*/
public $extendedData = null;
/**
* Error code number
* @var string
*/
public $faultCode;
/**
* Description as to the cause of the error
* @var string
*/
public $faultDetail;
/**
* Short description of error
* @var string
*/
public $faultString = '';
/**
* root cause of error
* @var object
*/
public $rootCause = null;
}

View File

@ -17,12 +17,12 @@
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: TraitsInfo.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: TraitsInfo.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
* Zend_Amf_Value_TraitsInfo
*
* Zend_Amf_Value_TraitsInfo
*
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)

View File

@ -16,7 +16,7 @@
* @package Zend_Application
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Application.php 17802 2009-08-24 21:15:12Z matthew $
* @version $Id: Application.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -29,35 +29,35 @@ class Zend_Application
{
/**
* Autoloader to use
*
*
* @var Zend_Loader_Autoloader
*/
protected $_autoloader;
/**
* Bootstrap
*
*
* @var Zend_Application_Bootstrap_BootstrapAbstract
*/
protected $_bootstrap;
/**
* Application environment
*
*
* @var string
*/
protected $_environment;
/**
* Flattened (lowercase) option keys
*
*
* @var array
*/
protected $_optionKeys = array();
/**
* Options for Zend_Application
*
*
* @var array
*/
protected $_options = array();
@ -65,10 +65,10 @@ class Zend_Application
/**
* Constructor
*
* Initialize application. Potentially initializes include_paths, PHP
* Initialize application. Potentially initializes include_paths, PHP
* settings, and bootstrap class.
*
* @param string $environment
*
* @param string $environment
* @param string|array|Zend_Config $options String path to configuration file, or array/Zend_Config of configuration options
* @throws Zend_Application_Exception When invalid options are provided
* @return void
@ -95,7 +95,7 @@ class Zend_Application
/**
* Retrieve current environment
*
*
* @return string
*/
public function getEnvironment()
@ -105,7 +105,7 @@ class Zend_Application
/**
* Retrieve autoloader instance
*
*
* @return Zend_Loader_Autoloader
*/
public function getAutoloader()
@ -115,8 +115,8 @@ class Zend_Application
/**
* Set application options
*
* @param array $options
*
* @param array $options
* @throws Zend_Application_Exception When no bootstrap path is provided
* @throws Zend_Application_Exception When invalid bootstrap information are provided
* @return Zend_Application
@ -126,7 +126,7 @@ class Zend_Application
if (!empty($options['config'])) {
$options = $this->mergeOptions($options, $this->_loadConfig($options['config']));
}
$this->_options = $options;
$options = array_change_key_case($options, CASE_LOWER);
@ -136,32 +136,43 @@ class Zend_Application
if (!empty($options['phpsettings'])) {
$this->setPhpSettings($options['phpsettings']);
}
if (!empty($options['includepaths'])) {
$this->setIncludePaths($options['includepaths']);
}
if (!empty($options['autoloadernamespaces'])) {
$this->setAutoloaderNamespaces($options['autoloadernamespaces']);
}
if (!empty($options['autoloaderzfpath'])) {
$autoloader = $this->getAutoloader();
if (method_exists($autoloader, 'setZfPath')) {
$zfPath = $options['autoloaderzfpath'];
$zfVersion = !empty($options['autoloaderzfversion'])
? $options['autoloaderzfversion']
: 'latest';
$autoloader->setZfPath($zfPath, $zfVersion);
}
}
if (!empty($options['bootstrap'])) {
$bootstrap = $options['bootstrap'];
if (is_string($bootstrap)) {
$this->setBootstrap($bootstrap);
} elseif (is_array($bootstrap)) {
if (empty($bootstrap['path'])) {
throw new Zend_Application_Exception('No bootstrap path provided');
}
$path = $bootstrap['path'];
$class = null;
if (!empty($bootstrap['class'])) {
$class = $bootstrap['class'];
}
$this->setBootstrap($path, $class);
} else {
throw new Zend_Application_Exception('Invalid bootstrap information provided');
@ -173,7 +184,7 @@ class Zend_Application
/**
* Retrieve application options (for caching)
*
*
* @return array
*/
public function getOptions()
@ -183,19 +194,19 @@ class Zend_Application
/**
* Is an option present?
*
* @param string $key
*
* @param string $key
* @return bool
*/
public function hasOption($key)
{
return in_array($key, $this->_optionKeys);
return in_array(strtolower($key), $this->_optionKeys);
}
/**
* Retrieve a single option
*
* @param string $key
*
* @param string $key
* @return mixed
*/
public function getOption($key)
@ -210,9 +221,9 @@ class Zend_Application
/**
* Merge options recursively
*
* @param array $array1
* @param mixed $array2
*
* @param array $array1
* @param mixed $array2
* @return array
*/
public function mergeOptions(array $array1, $array2 = null)
@ -221,7 +232,7 @@ class Zend_Application
foreach ($array2 as $key => $val) {
if (is_array($array2[$key])) {
$array1[$key] = (array_key_exists($key, $array1) && is_array($array1[$key]))
? $this->mergeOptions($array1[$key], $array2[$key])
? $this->mergeOptions($array1[$key], $array2[$key])
: $array2[$key];
} else {
$array1[$key] = $val;
@ -233,8 +244,8 @@ class Zend_Application
/**
* Set PHP configuration settings
*
* @param array $settings
*
* @param array $settings
* @param string $prefix Key prefix to prepend to array values (used to map . separated INI values)
* @return Zend_Application
*/
@ -248,14 +259,14 @@ class Zend_Application
$this->setPhpSettings($value, $key . '.');
}
}
return $this;
}
/**
* Set include path
*
* @param array $paths
*
* @param array $paths
* @return Zend_Application
*/
public function setIncludePaths(array $paths)
@ -267,31 +278,31 @@ class Zend_Application
/**
* Set autoloader namespaces
*
* @param array $namespaces
*
* @param array $namespaces
* @return Zend_Application
*/
public function setAutoloaderNamespaces(array $namespaces)
{
$autoloader = $this->getAutoloader();
foreach ($namespaces as $namespace) {
$autoloader->registerNamespace($namespace);
}
return $this;
}
/**
* Set bootstrap path/class
*
* @param string $path
* @param string $class
*
* @param string $path
* @param string $class
* @return Zend_Application
*/
public function setBootstrap($path, $class = null)
{
// setOptions() can potentially send a null value; specify default
// setOptions() can potentially send a null value; specify default
// here
if (null === $class) {
$class = 'Bootstrap';
@ -308,13 +319,13 @@ class Zend_Application
if (!$this->_bootstrap instanceof Zend_Application_Bootstrap_Bootstrapper) {
throw new Zend_Application_Exception('Bootstrap class does not implement Zend_Application_Bootstrap_Bootstrapper');
}
return $this;
}
/**
* Get bootstrap object
*
*
* @return Zend_Application_Bootstrap_BootstrapAbstract
*/
public function getBootstrap()
@ -327,18 +338,19 @@ class Zend_Application
/**
* Bootstrap application
*
*
* @param null|string|array $resource
* @return Zend_Application
*/
public function bootstrap()
public function bootstrap($resource = null)
{
$this->getBootstrap()->bootstrap();
$this->getBootstrap()->bootstrap($resource);
return $this;
}
/**
* Run the application
*
*
* @return void
*/
public function run()
@ -348,25 +360,25 @@ class Zend_Application
/**
* Load configuration file of options
*
*
* @param string $file
* @throws Zend_Application_Exception When invalid configuration file is provided
* @throws Zend_Application_Exception When invalid configuration file is provided
* @return array
*/
protected function _loadConfig($file)
{
$environment = $this->getEnvironment();
$suffix = strtolower(pathinfo($file, PATHINFO_EXTENSION));
switch ($suffix) {
case 'ini':
$config = new Zend_Config_Ini($file, $environment);
break;
case 'xml':
$config = new Zend_Config_Xml($file, $environment);
break;
case 'php':
case 'inc':
$config = include $file;
@ -375,11 +387,11 @@ class Zend_Application
}
return $config;
break;
default:
throw new Zend_Application_Exception('Invalid configuration file provided; unknown config type');
}
return $config->toArray();
}
}

View File

@ -17,7 +17,7 @@
* @subpackage Bootstrap
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Bootstrap.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Bootstrap.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -32,15 +32,15 @@
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Bootstrap_Bootstrap
class Zend_Application_Bootstrap_Bootstrap
extends Zend_Application_Bootstrap_BootstrapAbstract
{
/**
* Constructor
*
* Ensure FrontController resource is registered
*
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
*
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
* @return void
*/
public function __construct($application)
@ -54,12 +54,12 @@ class Zend_Application_Bootstrap_Bootstrap
/**
* Run the application
*
* Checks to see that we have a default controller directory. If not, an
* Checks to see that we have a default controller directory. If not, an
* exception is thrown.
*
* If so, it registers the bootstrap with the 'bootstrap' parameter of
* If so, it registers the bootstrap with the 'bootstrap' parameter of
* the front controller, and dispatches the front controller.
*
*
* @return void
* @throws Zend_Application_Bootstrap_Exception
*/

View File

@ -17,7 +17,7 @@
* @subpackage Bootstrap
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: BootstrapAbstract.php 17802 2009-08-24 21:15:12Z matthew $
* @version $Id: BootstrapAbstract.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -32,7 +32,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Application_Bootstrap_BootstrapAbstract
implements Zend_Application_Bootstrap_Bootstrapper,
implements Zend_Application_Bootstrap_Bootstrapper,
Zend_Application_Bootstrap_ResourceBootstrapper
{
/**
@ -57,7 +57,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Flattened (lowercase) option keys used for lookups
*
*
* @var array
*/
protected $_optionKeys = array();
@ -90,12 +90,12 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Constructor
*
* Sets application object, initializes options, and prepares list of
* Sets application object, initializes options, and prepares list of
* initializer methods.
*
*
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
* @return void
* @throws Zend_Application_Bootstrap_Exception When invalid applicaiton is provided
* @throws Zend_Application_Bootstrap_Exception When invalid applicaiton is provided
*/
public function __construct($application)
{
@ -106,8 +106,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Set class state
*
* @param array $options
*
* @param array $options
* @return Zend_Application_Bootstrap_BootstrapAbstract
*/
public function setOptions(array $options)
@ -115,7 +115,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
$this->_options = $this->mergeOptions($this->_options, $options);
$options = array_change_key_case($options, CASE_LOWER);
$this->_optionKeys = array_keys($options);
$this->_optionKeys = array_merge($this->_optionKeys, array_keys($options));
$methods = get_class_methods($this);
foreach ($methods as $key => $method) {
@ -124,7 +124,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
if (array_key_exists('pluginpaths', $options)) {
$pluginLoader = $this->getPluginLoader();
foreach ($options['pluginpaths'] as $prefix => $path) {
$pluginLoader->addPrefixPath($prefix, $path);
}
@ -147,7 +147,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Get current options from bootstrap
*
*
* @return array
*/
public function getOptions()
@ -157,8 +157,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Is an option present?
*
* @param string $key
*
* @param string $key
* @return bool
*/
public function hasOption($key)
@ -168,8 +168,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Retrieve a single option
*
* @param string $key
*
* @param string $key
* @return mixed
*/
public function getOption($key)
@ -184,9 +184,9 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Merge options recursively
*
* @param array $array1
* @param mixed $array2
*
* @param array $array1
* @param mixed $array2
* @return array
*/
public function mergeOptions(array $array1, $array2 = null)
@ -195,7 +195,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
foreach ($array2 as $key => $val) {
if (is_array($array2[$key])) {
$array1[$key] = (array_key_exists($key, $array1) && is_array($array1[$key]))
? $this->mergeOptions($array1[$key], $array2[$key])
? $this->mergeOptions($array1[$key], $array2[$key])
: $array2[$key];
} else {
$array1[$key] = $val;
@ -207,10 +207,10 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Get class resources (as resource/method pairs)
*
*
* Uses get_class_methods() by default, reflection on prior to 5.2.6,
* as a bug prevents the usage of get_class_methods() there.
*
* as a bug prevents the usage of get_class_methods() there.
*
* @return array
*/
public function getClassResources()
@ -220,14 +220,14 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
$class = new ReflectionObject($this);
$classMethods = $class->getMethods();
$methodNames = array();
foreach ($classMethods as $method) {
$methodNames[] = $method->getName();
}
} else {
$methodNames = get_class_methods($this);
}
$this->_classResources = array();
foreach ($methodNames as $method) {
if (5 < strlen($method) && '_init' === substr($method, 0, 5)) {
@ -235,13 +235,13 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
}
}
}
return $this->_classResources;
}
/**
* Get class resource names
*
*
* @return array
*/
public function getClassResourceNames()
@ -252,7 +252,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Register a new resource plugin
*
*
* @param string|Zend_Application_Resource_Resource $resource
* @param mixed $options
* @return Zend_Application_Bootstrap_BootstrapAbstract
@ -277,8 +277,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Unregister a resource from the bootstrap
*
* @param string|Zend_Application_Resource_Resource $resource
*
* @param string|Zend_Application_Resource_Resource $resource
* @return Zend_Application_Bootstrap_BootstrapAbstract
* @throws Zend_Application_Bootstrap_Exception When unknown resource type is provided
*/
@ -304,16 +304,16 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
}
/**
* Is the requested plugin resource registered?
*
* @param string $resource
* Is the requested plugin resource registered?
*
* @param string $resource
* @return bool
*/
public function hasPluginResource($resource)
{
return (null !== $this->getPluginResource($resource));
}
/**
* Get a registered plugin resource
*
@ -365,12 +365,12 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
}
}
return null;
return null;
}
/**
* Retrieve all plugin resources
*
*
* @return array
*/
public function getPluginResources()
@ -383,7 +383,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Retrieve plugin resource names
*
*
* @return array
*/
public function getPluginResourceNames()
@ -394,8 +394,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Set plugin loader for loading resources
*
* @param Zend_Loader_PluginLoader_Interface $loader
*
* @param Zend_Loader_PluginLoader_Interface $loader
* @return Zend_Application_Bootstrap_BootstrapAbstract
*/
public function setPluginLoader(Zend_Loader_PluginLoader_Interface $loader)
@ -403,7 +403,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
$this->_pluginLoader = $loader;
return $this;
}
/**
* Get the plugin loader for resources
*
@ -424,13 +424,13 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Set application/parent bootstrap
*
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
*
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
* @return Zend_Application_Bootstrap_BootstrapAbstract
*/
public function setApplication($application)
{
if (($application instanceof Zend_Application)
if (($application instanceof Zend_Application)
|| ($application instanceof Zend_Application_Bootstrap_Bootstrapper)
) {
$this->_application = $application;
@ -439,10 +439,10 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
}
return $this;
}
/**
* Retrieve parent application instance
*
*
* @return Zend_Application|Zend_Application_Bootstrap_Bootstrapper
*/
public function getApplication()
@ -452,7 +452,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Retrieve application environment
*
*
* @return string
*/
public function getEnvironment()
@ -466,13 +466,13 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Set resource container
*
* By default, if a resource callback has a non-null return value, this
* value will be stored in a container using the resource name as the
* By default, if a resource callback has a non-null return value, this
* value will be stored in a container using the resource name as the
* key.
*
* Containers must be objects, and must allow setting public properties.
*
* @param object $container
*
* @param object $container
* @return Zend_Application_Bootstrap_BootstrapAbstract
*/
public function setContainer($container)
@ -486,7 +486,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Retrieve resource container
*
*
* @return object
*/
public function getContainer()
@ -500,11 +500,11 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Determine if a resource has been stored in the container
*
* During bootstrap resource initialization, you may return a value. If
* During bootstrap resource initialization, you may return a value. If
* you do, it will be stored in the {@link setContainer() container}.
* You can use this method to determine if a value was stored.
*
* @param string $name
*
* @param string $name
* @return bool
*/
public function hasResource($name)
@ -517,13 +517,13 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Retrieve a resource from the container
*
* During bootstrap resource initialization, you may return a value. If
* During bootstrap resource initialization, you may return a value. If
* you do, it will be stored in the {@link setContainer() container}.
* You can use this method to retrieve that value.
*
* If no value was returned, this will return a null value.
*
* @param string $name
*
* @param string $name
* @return null|mixed
*/
public function getResource($name)
@ -551,7 +551,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Implement PHP's magic to ask for the
* existence of a ressource in the bootstrap
*
*
* @param string $prop
* @return bool
*/
@ -567,12 +567,12 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
* child class 'Bootstrap' (in which case, overriding this method
* would result in it being treated as a constructor).
*
* If you need to override this functionality, override the
* If you need to override this functionality, override the
* {@link _bootstrap()} method.
*
*
* @param null|string|array $resource
* @return Zend_Application_Bootstrap_BootstrapAbstract
* @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
* @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
*/
final public function bootstrap($resource = null)
{
@ -582,11 +582,11 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Overloading: intercept calls to bootstrap<resourcename>() methods
*
* @param string $method
*
* @param string $method
* @param array $args
* @return void
* @throws Zend_Application_Bootstrap_Exception On invalid method name
* @throws Zend_Application_Bootstrap_Exception On invalid method name
*/
public function __call($method, $args)
{
@ -601,12 +601,12 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Bootstrap implementation
*
* This method may be overridden to provide custom bootstrapping logic.
* This method may be overridden to provide custom bootstrapping logic.
* It is the sole method called by {@link bootstrap()}.
*
* @param null|string|array $resource
*
* @param null|string|array $resource
* @return void
* @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
* @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
*/
protected function _bootstrap($resource = null)
{
@ -614,7 +614,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
foreach ($this->getClassResourceNames() as $resource) {
$this->_executeResource($resource);
}
foreach ($this->getPluginResourceNames() as $resource) {
$this->_executeResource($resource);
}
@ -632,14 +632,14 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Execute a resource
*
* Checks to see if the resource has already been run. If not, it searches
* first to see if a local method matches the resource, and executes that.
* If not, it checks to see if a plugin resource matches, and executes that
* Checks to see if the resource has already been run. If not, it searches
* first to see if a local method matches the resource, and executes that.
* If not, it checks to see if a plugin resource matches, and executes that
* if found.
*
* Finally, if not found, it throws an exception.
*
* @param string $resource
* @param string $resource
* @return void
* @throws Zend_Application_Bootstrap_Exception When resource not found
*/
@ -661,7 +661,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
$method = $classResources[$resourceName];
$return = $this->$method();
unset($this->_started[$resourceName]);
$this->_markRun($resource);
$this->_markRun($resourceName);
if (null !== $return) {
$this->getContainer()->{$resourceName} = $return;
@ -689,9 +689,9 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Load a plugin resource
*
* @param string $resource
* @param array|object|null $options
*
* @param string $resource
* @param array|object|null $options
* @return string|false
*/
protected function _loadPluginResource($resource, $options)
@ -719,8 +719,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
/**
* Mark a resource as having run
*
* @param string $resource
*
* @param string $resource
* @return void
*/
protected function _markRun($resource)
@ -739,8 +739,8 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
* - class name (if none of the above are true)
*
* The name is then cast to lowercase.
*
* @param Zend_Application_Resource_Resource $resource
*
* @param Zend_Application_Resource_Resource $resource
* @return string
*/
protected function _resolvePluginResourceName($resource)

View File

@ -17,7 +17,7 @@
* @subpackage Bootstrap
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Bootstrapper.php 16200 2009-06-21 18:50:06Z thomas $
* @version $Id: Bootstrapper.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -33,61 +33,61 @@ interface Zend_Application_Bootstrap_Bootstrapper
{
/**
* Constructor
*
* @param Zend_Application $application
*
* @param Zend_Application $application
* @return void
*/
public function __construct($application);
/**
* Set bootstrap options
*
* @param array $options
*
* @param array $options
* @return Zend_Application_Bootstrap_Bootstrapper
*/
public function setOptions(array $options);
/**
* Retrieve application object
*
*
* @return Zend_Application|Zend_Application_Bootstrap_Bootstrapper
*/
public function getApplication();
/**
* Retrieve application environment
*
*
* @return string
*/
public function getEnvironment();
/**
* Retrieve list of class resource initializers (_init* methods). Returns
* Retrieve list of class resource initializers (_init* methods). Returns
* as resource/method pairs.
*
*
* @return array
*/
public function getClassResources();
/**
* Retrieve list of class resource initializer names (resource names only,
* Retrieve list of class resource initializer names (resource names only,
* no method names)
*
*
* @return array
*/
public function getClassResourceNames();
/**
* Bootstrap application or individual resource
*
* @param null|string $resource
*
* @param null|string $resource
* @return mixed
*/
public function bootstrap($resource = null);
/**
* Run the application
*
*
* @return void
*/
public function run();

View File

@ -17,7 +17,7 @@
* @subpackage Bootstrap
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ResourceBootstrapper.php 16200 2009-06-21 18:50:06Z thomas $
* @version $Id: ResourceBootstrapper.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -33,62 +33,62 @@ interface Zend_Application_Bootstrap_ResourceBootstrapper
{
/**
* Register a resource with the bootstrap
*
* @param string|Zend_Application_Resource_Resource $resource
* @param null|array|Zend_Config $options
*
* @param string|Zend_Application_Resource_Resource $resource
* @param null|array|Zend_Config $options
* @return Zend_Application_Bootstrap_ResourceBootstrapper
*/
public function registerPluginResource($resource, $options = null);
/**
* Unregister a resource from the bootstrap
*
* @param string|Zend_Application_Resource_Resource $resource
*
* @param string|Zend_Application_Resource_Resource $resource
* @return Zend_Application_Bootstrap_ResourceBootstrapper
*/
public function unregisterPluginResource($resource);
/**
* Is the requested resource registered?
*
* @param string $resource
*
* @param string $resource
* @return bool
*/
public function hasPluginResource($resource);
/**
* Retrieve resource
*
* @param string $resource
*
* @param string $resource
* @return Zend_Application_Resource_Resource
*/
public function getPluginResource($resource);
/**
* Get all resources
*
*
* @return array
*/
public function getPluginResources();
/**
* Get just resource names
*
*
* @return array
*/
public function getPluginResourceNames();
/**
* Set plugin loader to use to fetch resources
*
* @param Zend_Loader_PluginLoader_Interface Zend_Loader_PluginLoader
*
* @param Zend_Loader_PluginLoader_Interface Zend_Loader_PluginLoader
* @return Zend_Application_Bootstrap_ResourceBootstrapper
*/
public function setPluginLoader(Zend_Loader_PluginLoader_Interface $loader);
/**
* Retrieve plugin loader for resources
*
*
* @return Zend_Loader_PluginLoader
*/
public function getPluginLoader();

View File

@ -16,7 +16,7 @@
* @package Zend_Application
* @subpackage Module
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Autoloader.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Autoloader.php 18951 2009-11-12 16:26:19Z alexander $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@ -25,7 +25,7 @@ require_once 'Zend/Loader/Autoloader/Resource.php';
/**
* Resource loader for application module classes
*
*
* @uses Zend_Loader_Autoloader_Resource
* @package Zend_Application
* @subpackage Module
@ -36,8 +36,8 @@ class Zend_Application_Module_Autoloader extends Zend_Loader_Autoloader_Resource
{
/**
* Constructor
*
* @param array|Zend_Config $options
*
* @param array|Zend_Config $options
* @return void
*/
public function __construct($options)
@ -48,7 +48,7 @@ class Zend_Application_Module_Autoloader extends Zend_Loader_Autoloader_Resource
/**
* Initialize default resource types for module resource classes
*
*
* @return void
*/
public function initDefaultResourceTypes()

View File

@ -16,7 +16,7 @@
* @package Zend_Application
* @subpackage Module
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Bootstrap.php 17802 2009-08-24 21:15:12Z matthew $
* @version $Id: Bootstrap.php 18951 2009-11-12 16:26:19Z alexander $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@ -27,7 +27,7 @@ require_once 'Zend/Application/Bootstrap/Bootstrap.php';
/**
* Base bootstrap class for modules
*
*
* @uses Zend_Loader_Autoloader_Resource
* @uses Zend_Application_Bootstrap_Bootstrap
* @package Zend_Application
@ -35,7 +35,7 @@ require_once 'Zend/Application/Bootstrap/Bootstrap.php';
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Application_Module_Bootstrap
abstract class Zend_Application_Module_Bootstrap
extends Zend_Application_Bootstrap_Bootstrap
{
/**
@ -45,8 +45,8 @@ abstract class Zend_Application_Module_Bootstrap
/**
* Constructor
*
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
*
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
* @return void
*/
public function __construct($application)
@ -84,8 +84,8 @@ abstract class Zend_Application_Module_Bootstrap
/**
* Set module resource loader
*
* @param Zend_Loader_Autoloader_Resource $loader
*
* @param Zend_Loader_Autoloader_Resource $loader
* @return Zend_Application_Module_Bootstrap
*/
public function setResourceLoader(Zend_Loader_Autoloader_Resource $loader)
@ -96,7 +96,7 @@ abstract class Zend_Application_Module_Bootstrap
/**
* Retrieve module resource loader
*
*
* @return Zend_Loader_Autoloader_Resource
*/
public function getResourceLoader()
@ -114,7 +114,7 @@ abstract class Zend_Application_Module_Bootstrap
/**
* Ensure resource loader is loaded
*
*
* @return void
*/
public function initResourceLoader()
@ -124,7 +124,7 @@ abstract class Zend_Application_Module_Bootstrap
/**
* Retrieve module name
*
*
* @return string
*/
public function getModuleName()

View File

@ -17,7 +17,7 @@
* @subpackage Resource
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Db.php 16200 2009-06-21 18:50:06Z thomas $
* @version $Id: Db.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -43,24 +43,24 @@ class Zend_Application_Resource_Db extends Zend_Application_Resource_ResourceAbs
* @var Zend_Db_Adapter_Interface
*/
protected $_db;
/**
* Parameters to use
*
* @var array
*/
protected $_params = array();
/**
* Wether to register the created adapter as default table adapter
*
* @var boolean
*/
protected $_isDefaultTableAdapter = true;
protected $_isDefaultTableAdapter = true;
/**
* Set the adapter
*
*
* @param $adapter string
* @return Zend_Application_Resource_Db
*/
@ -72,7 +72,7 @@ class Zend_Application_Resource_Db extends Zend_Application_Resource_ResourceAbs
/**
* Adapter type to use
*
*
* @return string
*/
public function getAdapter()
@ -82,7 +82,7 @@ class Zend_Application_Resource_Db extends Zend_Application_Resource_ResourceAbs
/**
* Set the adapter params
*
*
* @param $adapter string
* @return Zend_Application_Resource_Db
*/
@ -94,14 +94,14 @@ class Zend_Application_Resource_Db extends Zend_Application_Resource_ResourceAbs
/**
* Adapter parameters
*
*
* @return array
*/
public function getParams()
{
return $this->_params;
}
/**
* Set whether to use this as default table adapter
*
@ -116,7 +116,7 @@ class Zend_Application_Resource_Db extends Zend_Application_Resource_ResourceAbs
/**
* Is this adapter the default table adapter?
*
*
* @return void
*/
public function isDefaultTableAdapter()
@ -126,19 +126,19 @@ class Zend_Application_Resource_Db extends Zend_Application_Resource_ResourceAbs
/**
* Retrieve initialized DB connection
*
*
* @return null|Zend_Db_Adapter_Interface
*/
public function getDbAdapter()
{
if ((null === $this->_db)
if ((null === $this->_db)
&& (null !== ($adapter = $this->getAdapter()))
) {
$this->_db = Zend_Db::factory($adapter, $this->getParams());
}
return $this->_db;
}
/**
* Defined by Zend_Application_Resource_Resource
*

View File

@ -17,7 +17,7 @@
* @subpackage Resource
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Frontcontroller.php 17737 2009-08-21 20:57:50Z matthew $
* @version $Id: Frontcontroller.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -38,13 +38,13 @@ class Zend_Application_Resource_Frontcontroller extends Zend_Application_Resourc
/**
* Initialize Front Controller
*
*
* @return Zend_Controller_Front
*/
public function init()
{
$front = $this->getFrontController();
foreach ($this->getOptions() as $key => $value) {
switch (strtolower($key)) {
case 'controllerdirectory':
@ -56,37 +56,37 @@ class Zend_Application_Resource_Frontcontroller extends Zend_Application_Resourc
}
}
break;
case 'modulecontrollerdirectoryname':
$front->setModuleControllerDirectoryName($value);
break;
case 'moduledirectory':
$front->addModuleDirectory($value);
break;
case 'defaultcontrollername':
$front->setDefaultControllerName($value);
break;
case 'defaultaction':
$front->setDefaultAction($value);
break;
case 'defaultmodule':
$front->setDefaultModule($value);
break;
case 'baseurl':
if (!empty($value)) {
$front->setBaseUrl($value);
}
break;
case 'params':
$front->setParams($value);
break;
case 'plugins':
foreach ((array) $value as $pluginClass) {
$plugin = new $pluginClass();
@ -121,7 +121,7 @@ class Zend_Application_Resource_Frontcontroller extends Zend_Application_Resourc
/**
* Retrieve front controller instance
*
*
* @return Zend_Controller_Front
*/
public function getFrontController()

View File

@ -17,7 +17,7 @@
* @subpackage Resource
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Layout.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Layout.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -30,7 +30,7 @@
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Layout
class Zend_Application_Resource_Layout
extends Zend_Application_Resource_ResourceAbstract
{
/**

View File

@ -17,7 +17,7 @@
* @subpackage Resource
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Locale.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Locale.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -30,7 +30,7 @@
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Locale
class Zend_Application_Resource_Locale
extends Zend_Application_Resource_ResourceAbstract
{
const DEFAULT_REGISTRY_KEY = 'Zend_Locale';
@ -62,7 +62,7 @@ class Zend_Application_Resource_Locale
$options = $this->getOptions();
if (!isset($options['default'])) {
$this->_locale = new Zend_Locale();
} else {
} else {
Zend_Locale::setDefault($options['default']);
$this->_locale = new Zend_Locale($options['default']);
}

View File

@ -17,7 +17,7 @@
* @subpackage Resource
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Modules.php 17730 2009-08-21 19:50:07Z matthew $
* @version $Id: Modules.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -92,7 +92,7 @@ class Zend_Application_Resource_Modules extends Zend_Application_Resource_Resour
}
if ($bootstrapClass == $curBootstrapClass) {
// If the found bootstrap class matches the one calling this
// If the found bootstrap class matches the one calling this
// resource, don't re-execute.
continue;
}

View File

@ -17,7 +17,7 @@
* @subpackage Resource
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Navigation.php 17017 2009-07-24 02:45:52Z freak $
* @version $Id: Navigation.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -31,7 +31,7 @@
* @author Dolf Schimmel
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Navigation
class Zend_Application_Resource_Navigation
extends Zend_Application_Resource_ResourceAbstract
{
const DEFAULT_REGISTRY_KEY = 'Zend_Navigation';
@ -88,10 +88,10 @@ class Zend_Application_Resource_Navigation
{
$key = $options['storage']['registry']['key'];
} else {
$key = self::DEFAULT_REGISTRY_KEY;
$key = self::DEFAULT_REGISTRY_KEY;
}
Zend_Registry::set($key,$this->getContainer());
Zend_Registry::set($key,$this->getContainer());
}
/**

View File

@ -17,7 +17,7 @@
* @subpackage Resource
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Resource.php 16200 2009-06-21 18:50:06Z thomas $
* @version $Id: Resource.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -35,38 +35,38 @@ interface Zend_Application_Resource_Resource
* Constructor
*
* Must take an optional single argument, $options.
*
* @param mixed $options
*
* @param mixed $options
* @return void
*/
public function __construct($options = null);
/**
* Set the bootstrap to which the resource is attached
*
* @param Zend_Application_Bootstrap_Bootstrapper $bootstrap
*
* @param Zend_Application_Bootstrap_Bootstrapper $bootstrap
* @return Zend_Application_Resource_Resource
*/
public function setBootstrap(Zend_Application_Bootstrap_Bootstrapper $bootstrap);
/**
* Retrieve the bootstrap to which the resource is attached
*
*
* @return Zend_Application_Bootstrap_Bootstrapper
*/
public function getBootstrap();
/**
* Set resource options
*
* @param array $options
*
* @param array $options
* @return Zend_Application_Resource_Resource
*/
public function setOptions(array $options);
/**
* Retrieve resource options
*
*
* @return array
*/
public function getOptions();

View File

@ -17,7 +17,7 @@
* @subpackage Resource
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ResourceAbstract.php 16200 2009-06-21 18:50:06Z thomas $
* @version $Id: ResourceAbstract.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -39,14 +39,14 @@ abstract class Zend_Application_Resource_ResourceAbstract implements Zend_Applic
{
/**
* Parent bootstrap
*
*
* @var Zend_Application_Bootstrap_Bootstrapper
*/
protected $_bootstrap;
/**
* Options for the resource
*
*
* @var array
*/
protected $_options = array();
@ -96,7 +96,7 @@ abstract class Zend_Application_Resource_ResourceAbstract implements Zend_Applic
unset($options[$key]);
}
}
$this->_options = $this->mergeOptions($this->_options, $options);
return $this;
@ -104,7 +104,7 @@ abstract class Zend_Application_Resource_ResourceAbstract implements Zend_Applic
/**
* Retrieve resource options
*
*
* @return array
*/
public function getOptions()
@ -114,9 +114,9 @@ abstract class Zend_Application_Resource_ResourceAbstract implements Zend_Applic
/**
* Merge options recursively
*
* @param array $array1
* @param mixed $array2
*
* @param array $array1
* @param mixed $array2
* @return array
*/
public function mergeOptions(array $array1, $array2 = null)
@ -125,7 +125,7 @@ abstract class Zend_Application_Resource_ResourceAbstract implements Zend_Applic
foreach ($array2 as $key => $val) {
if (is_array($array2[$key])) {
$array1[$key] = (array_key_exists($key, $array1) && is_array($array1[$key]))
? $this->mergeOptions($array1[$key], $array2[$key])
? $this->mergeOptions($array1[$key], $array2[$key])
: $array2[$key];
} else {
$array1[$key] = $val;
@ -137,8 +137,8 @@ abstract class Zend_Application_Resource_ResourceAbstract implements Zend_Applic
/**
* Set the bootstrap to which the resource is attached
*
* @param Zend_Application_Bootstrap_Bootstrapper $bootstrap
*
* @param Zend_Application_Bootstrap_Bootstrapper $bootstrap
* @return Zend_Application_Resource_Resource
*/
public function setBootstrap(Zend_Application_Bootstrap_Bootstrapper $bootstrap)
@ -149,7 +149,7 @@ abstract class Zend_Application_Resource_ResourceAbstract implements Zend_Applic
/**
* Retrieve the bootstrap to which the resource is attached
*
*
* @return null|Zend_Application_Bootstrap_Bootstrapper
*/
public function getBootstrap()

View File

@ -17,7 +17,7 @@
* @subpackage Resource
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Router.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Router.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -30,7 +30,7 @@
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Router
class Zend_Application_Resource_Router
extends Zend_Application_Resource_ResourceAbstract
{
/**
@ -64,12 +64,12 @@ class Zend_Application_Resource_Router
if (!isset($options['routes'])) {
$options['routes'] = array();
}
if (isset($options['chainNameSeparator'])) {
$this->_router->setChainNameSeparator($options['chainNameSeparator']);
}
$this->_router->addConfig(new Zend_Config($options['routes']));
}

View File

@ -17,7 +17,7 @@
* @subpackage Resource
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Session.php 16200 2009-06-21 18:50:06Z thomas $
* @version $Id: Session.php 18204 2009-09-17 22:13:16Z beberlei $
*/
/**
@ -48,28 +48,47 @@ class Zend_Application_Resource_Session extends Zend_Application_Resource_Resour
*/
public function setSaveHandler($saveHandler)
{
if (is_array($saveHandler)) {
if (!array_key_exists('class', $saveHandler)) {
throw new Zend_Application_Resource_Exception('Session save handler class not provided in options');
}
if (array_key_exists('options', $saveHandler)) {
$options = $saveHandler['options'];
}
$saveHandler = $saveHandler['class'];
$saveHandler = new $saveHandler($options);
} elseif (is_string($saveHandler)) {
$saveHandler = new $saveHandler();
}
if (!$saveHandler instanceof Zend_Session_SaveHandler_Interface) {
throw new Zend_Application_Resource_Exception('Invalid session save handler');
}
$this->_saveHandler = $saveHandler;
return $this;
}
/**
* Get session save handler
*
* @return Zend_Session_SaveHandler_Interface
*/
public function getSaveHandler()
{
if (!$this->_saveHandler instanceof Zend_Session_SaveHandler_Interface) {
if (is_array($this->_saveHandler)) {
if (!array_key_exists('class', $this->_saveHandler)) {
throw new Zend_Application_Resource_Exception('Session save handler class not provided in options');
}
$options = array();
if (array_key_exists('options', $this->_saveHandler)) {
$options = $this->_saveHandler['options'];
}
$this->_saveHandler = $this->_saveHandler['class'];
$this->_saveHandler = new $this->_saveHandler($options);
} elseif (is_string($this->_saveHandler)) {
$this->_saveHandler = new $this->_saveHandler();
}
if (!$this->_saveHandler instanceof Zend_Session_SaveHandler_Interface) {
throw new Zend_Application_Resource_Exception('Invalid session save handler');
}
}
return $this->_saveHandler;
}
/**
* @return bool
*/
protected function _hasSaveHandler()
{
return ($this->_saveHandler !== null);
}
/**
* Defined by Zend_Application_Resource_Resource
*
@ -86,8 +105,8 @@ class Zend_Application_Resource_Session extends Zend_Application_Resource_Resour
Zend_Session::setOptions($options);
}
if ($this->_saveHandler !== null) {
Zend_Session::setSaveHandler($this->_saveHandler);
if ($this->_hasSaveHandler()) {
Zend_Session::setSaveHandler($this->getSaveHandler());
}
}
}

View File

@ -17,7 +17,7 @@
* @subpackage Resource
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: View.php 16200 2009-06-21 18:50:06Z thomas $
* @version $Id: View.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -54,7 +54,7 @@ class Zend_Application_Resource_View extends Zend_Application_Resource_ResourceA
/**
* Retrieve view object
*
*
* @return Zend_View
*/
public function getView()

View File

@ -16,7 +16,7 @@
* @package Zend_Auth
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Auth.php 16200 2009-06-21 18:50:06Z thomas $
* @version $Id: Auth.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -116,6 +116,14 @@ class Zend_Auth
{
$result = $adapter->authenticate();
/**
* ZF-7546 - prevent multiple succesive calls from storing inconsistent results
* Ensure storage has clean state
*/
if ($this->hasIdentity()) {
$this->clearIdentity();
}
if ($result->isValid()) {
$this->getStorage()->write($result->getIdentity());
}

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Auth_Adapter
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DbTable.php 16200 2009-06-21 18:50:06Z thomas $
* @version $Id: DbTable.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -58,7 +58,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
* @var Zend_Db_Select
*/
protected $_dbSelect = null;
/**
* $_tableName - the table name to check
*
@ -241,10 +241,10 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
if ($this->_dbSelect == null) {
$this->_dbSelect = $this->_zendDb->select();
}
return $this->_dbSelect;
}
/**
* getResultRowObject() - Returns the result row as a stdClass object
*
@ -373,7 +373,9 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
. ' = ' . $this->_credentialTreatment, $this->_credential
)
. ' THEN 1 ELSE 0 END) AS '
. $this->_zendDb->quoteIdentifier('zend_auth_credential_match')
. $this->_zendDb->quoteIdentifier(
$this->_zendDb->foldCase('zend_auth_credential_match')
)
);
// get select
@ -426,7 +428,6 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
protected function _authenticateValidateResultSet(array $resultIdentities)
{
if (count($resultIdentities) < 1) {
$this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
$this->_authenticateResultInfo['messages'][] = 'A record with the supplied identity could not be found.';
@ -449,13 +450,15 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
*/
protected function _authenticateValidateResult($resultIdentity)
{
if ($resultIdentity['zend_auth_credential_match'] != '1') {
$zendAuthCredentialMatchColumn = $this->_zendDb->foldCase('zend_auth_credential_match');
if ($resultIdentity[$zendAuthCredentialMatchColumn] != '1') {
$this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
$this->_authenticateResultInfo['messages'][] = 'Supplied credential is invalid.';
return $this->_authenticateCreateAuthResult();
}
unset($resultIdentity['zend_auth_credential_match']);
unset($resultIdentity[$zendAuthCredentialMatchColumn]);
$this->_resultRow = $resultIdentity;
$this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS;

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Auth_Adapter_Http
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Http.php 16200 2009-06-21 18:50:06Z thomas $
* @version $Id: Http.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -403,7 +403,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface
// challenge again the client
return $this->_challengeClient();
}
switch ($clientScheme) {
case 'basic':
$result = $this->_basicAuth($authHeader);

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Auth_Adapter
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Ldap.php 17788 2009-08-24 14:43:23Z sgehrig $
* @version $Id: Ldap.php 18882 2009-11-06 10:57:58Z sgehrig $
*/
/**
@ -161,7 +161,7 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface
/**
* setIdentity() - set the identity (username) to be used
*
* Proxies to {@see setPassword()}
* Proxies to {@see setUsername()}
*
* Closes ZF-6813
*
@ -312,10 +312,16 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface
continue;
}
$ldap->bind($username, $password);
$canonicalName = $ldap->getCanonicalAccountName($username);
$dn = $ldap->getCanonicalAccountName($username, Zend_Ldap::ACCTNAME_FORM_DN);
$ldap->bind($canonicalName, $password);
/*
* Fixes problem when authenticated user is not allowed to retrieve
* group-membership information or own account.
* This requires that the user specified with "username" and "password"
* in the Zend_Ldap options is able to retrieve the required information.
*/
$ldap->bind();
$dn = $ldap->getCanonicalAccountName($canonicalName, Zend_Ldap::ACCTNAME_FORM_DN);
$groupResult = $this->_checkGroupMembership($ldap, $canonicalName, $dn, $adapterOptions);
if ($groupResult === true) {
@ -323,6 +329,8 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface
$messages[0] = '';
$messages[1] = '';
$messages[] = "$canonicalName authentication successful";
// rebinding with authenticated user
$ldap->bind($dn, $password);
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $canonicalName, $messages);
} else {
$messages[0] = 'Account is not a member of the specified group';
@ -409,7 +417,6 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface
}
}
}
$ldap->setOptions($options);
return $adapterOptions;
}
@ -463,9 +470,10 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface
* Closes ZF-6813
*
* @param array $returnAttribs
* @param array $omitAttribs
* @return stdClass|boolean
*/
public function getAccountObject(array $returnAttribs = array())
public function getAccountObject(array $returnAttribs = array(), array $omitAttribs = array())
{
if (!$this->_authenticatedDn) {
return false;
@ -473,8 +481,14 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface
$returnObject = new stdClass();
$omitAttribs = array_map('strtolower', $omitAttribs);
$entry = $this->getLdap()->getEntry($this->_authenticatedDn, $returnAttribs, true);
foreach ($entry as $attr => $value) {
if (in_array($attr, $omitAttribs)) {
// skip attributes marked to be omitted
continue;
}
if (is_array($value)) {
$returnObject->$attr = (count($value) > 1) ? $value : $value[0];
} else {

View File

@ -16,7 +16,7 @@
* @package Zend_Cache
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Cache.php 16200 2009-06-21 18:50:06Z thomas $
* @version $Id: Cache.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -44,11 +44,11 @@ abstract class Zend_Cache
/**
* Standard backends which implement the ExtendedInterface
*
*
* @var array
*/
public static $standardExtendedBackends = array('File', 'Apc', 'TwoLevels', 'Memcached', 'Sqlite');
/**
* Only for backward compatibily (may be removed in next major release)
*
@ -73,7 +73,7 @@ abstract class Zend_Cache
const CLEANING_MODE_MATCHING_TAG = 'matchingTag';
const CLEANING_MODE_NOT_MATCHING_TAG = 'notMatchingTag';
const CLEANING_MODE_MATCHING_ANY_TAG = 'matchingAnyTag';
/**
* Factory
*
@ -110,7 +110,7 @@ abstract class Zend_Cache
$frontendObject->setBackend($backendObject);
return $frontendObject;
}
/**
* Frontend Constructor
*
@ -151,7 +151,7 @@ abstract class Zend_Cache
}
return new $backendClass($backendOptions);
}
/**
* Backend Constructor
*

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Backend.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Backend.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -140,77 +140,77 @@ class Zend_Cache_Backend
{
return true;
}
/**
* Determine system TMP directory and detect if we have read access
*
* inspired from Zend_File_Transfer_Adapter_Abstract
* inspired from Zend_File_Transfer_Adapter_Abstract
*
* @return string
* @throws Zend_Cache_Exception if unable to determine directory
*/
public function getTmpDir()
{
$tmpdir = array();
$tmpdir = array();
foreach (array($_ENV, $_SERVER) as $tab) {
foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
if (isset($tab[$key])) {
if (($key == 'windir') or ($key == 'SystemRoot')) {
foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
if (isset($tab[$key])) {
if (($key == 'windir') or ($key == 'SystemRoot')) {
$dir = realpath($tab[$key] . '\\temp');
} else {
$dir = realpath($tab[$key]);
$dir = realpath($tab[$key]);
}
if ($this->_isGoodTmpDir($dir)) {
return $dir;
}
}
}
if ($this->_isGoodTmpDir($dir)) {
return $dir;
}
}
}
}
$upload = ini_get('upload_tmp_dir');
if ($upload) {
$dir = realpath($upload);
if ($this->_isGoodTmpDir($dir)) {
return $dir;
}
if ($this->_isGoodTmpDir($dir)) {
return $dir;
}
}
if (function_exists('sys_get_temp_dir')) {
$dir = sys_get_temp_dir();
if ($this->_isGoodTmpDir($dir)) {
return $dir;
}
if ($this->_isGoodTmpDir($dir)) {
return $dir;
}
}
// Attemp to detect by creating a temporary file
$tempFile = tempnam(md5(uniqid(rand(), TRUE)), '');
if ($tempFile) {
$dir = realpath(dirname($tempFile));
$dir = realpath(dirname($tempFile));
unlink($tempFile);
if ($this->_isGoodTmpDir($dir)) {
return $dir;
}
}
if ($this->_isGoodTmpDir('/tmp')) {
return '/tmp';
return '/tmp';
}
if ($this->_isGoodTmpDir('\\temp')) {
return '\\temp';
return '\\temp';
}
Zend_Cache::throwException('Could not determine temp directory, please specify a cache_dir manually');
}
/**
* Verify if the given temporary directory is readable and writable
*
*
* @param $dir temporary directory
* @return boolean true if the directory is ok
*/
protected function _isGoodTmpDir($dir)
{
if (is_readable($dir)) {
if (is_writable($dir)) {
return true;
}
}
return false;
if (is_readable($dir)) {
if (is_writable($dir)) {
return true;
}
}
return false;
}
/**
@ -261,7 +261,7 @@ class Zend_Cache_Backend
}
if (!isset($this->_directives['logger'])) {
Zend_Cache::throwException('Logging is enabled but logger is not set.');
Zend_Cache::throwException('Logging is enabled but logger is not set.');
}
$logger = $this->_directives['logger'];
if (!$logger instanceof Zend_Log) {

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Apc.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Apc.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -166,18 +166,18 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba
* Return true if the automatic cleaning is available for the backend
*
* DEPRECATED : use getCapabilities() instead
*
* @deprecated
*
* @deprecated
* @return boolean
*/
public function isAutomaticCleaningAvailable()
{
return false;
}
/**
* Return the filling percentage of the backend storage
*
*
* @throws Zend_Cache_Exception
* @return int integer between 0 and 100
*/
@ -195,21 +195,21 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba
}
return ((int) (100. * ($memUsed / $memSize)));
}
/**
* Return an array of stored tags
*
* @return array array of stored tags (string)
*/
public function getTags()
{
{
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
return array();
}
/**
* Return an array of stored cache ids which match given tags
*
*
* In case of multiple tags, a logical AND is made between tags
*
* @param array $tags array of tags
@ -218,26 +218,26 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba
public function getIdsMatchingTags($tags = array())
{
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
return array();
return array();
}
/**
* Return an array of stored cache ids which don't match given tags
*
*
* In case of multiple tags, a logical OR is made between tags
*
* @param array $tags array of tags
* @return array array of not matching cache ids (string)
*/
*/
public function getIdsNotMatchingTags($tags = array())
{
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
return array();
return array();
}
/**
* Return an array of stored cache ids which match any given tags
*
*
* In case of multiple tags, a logical AND is made between tags
*
* @param array $tags array of tags
@ -246,12 +246,12 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba
public function getIdsMatchingAnyTags($tags = array())
{
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
return array();
return array();
}
/**
* Return an array of stored cache ids
*
*
* @return array array of stored cache ids (string)
*/
public function getIds()
@ -264,7 +264,7 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba
}
return $res;
}
/**
* Return an array of metadatas for the given cache id
*
@ -272,7 +272,7 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba
* - expire : the expire timestamp
* - tags : a string array of tags
* - mtime : timestamp of last modification time
*
*
* @param string $id cache id
* @return array array of metadatas (false if the cache id is not found)
*/
@ -294,9 +294,9 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba
'mtime' => $mtime
);
}
return false;
return false;
}
/**
* Give (if possible) an extra lifetime to the given cache id
*
@ -318,17 +318,17 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba
$lifetime = $tmp[2];
$newLifetime = $lifetime - (time() - $mtime) + $extraLifetime;
if ($newLifetime <=0) {
return false;
return false;
}
apc_store($id, array($data, time(), $newLifetime), $newLifetime);
return true;
}
return false;
}
/**
* Return an associative array of capabilities (booleans) of the backend
*
*
* The array must include these keys :
* - automatic_cleaning (is automating cleaning necessary)
* - tags (are tags supported)
@ -337,7 +337,7 @@ class Zend_Cache_Backend_Apc extends Zend_Cache_Backend implements Zend_Cache_Ba
* - priority does the backend deal with priority when saving
* - infinite_lifetime (is infinite lifetime can work with this backend)
* - get_list (is it possible to get the list of cache ids and the complete list of tags)
*
*
* @return array associative of with capabilities
*/
public function getCapabilities()

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ExtendedInterface.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: ExtendedInterface.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -36,21 +36,21 @@ interface Zend_Cache_Backend_ExtendedInterface extends Zend_Cache_Backend_Interf
/**
* Return an array of stored cache ids
*
*
* @return array array of stored cache ids (string)
*/
public function getIds();
/**
* Return an array of stored tags
*
* @return array array of stored tags (string)
*/
public function getTags();
/**
* Return an array of stored cache ids which match given tags
*
*
* In case of multiple tags, a logical AND is made between tags
*
* @param array $tags array of tags
@ -60,24 +60,24 @@ interface Zend_Cache_Backend_ExtendedInterface extends Zend_Cache_Backend_Interf
/**
* Return an array of stored cache ids which don't match given tags
*
*
* In case of multiple tags, a logical OR is made between tags
*
* @param array $tags array of tags
* @return array array of not matching cache ids (string)
*/
*/
public function getIdsNotMatchingTags($tags = array());
/**
* Return an array of stored cache ids which match any given tags
*
*
* In case of multiple tags, a logical AND is made between tags
*
* @param array $tags array of tags
* @return array array of any matching cache ids (string)
*/
public function getIdsMatchingAnyTags($tags = array());
/**
* Return the filling percentage of the backend storage
*
@ -92,12 +92,12 @@ interface Zend_Cache_Backend_ExtendedInterface extends Zend_Cache_Backend_Interf
* - expire : the expire timestamp
* - tags : a string array of tags
* - mtime : timestamp of last modification time
*
*
* @param string $id cache id
* @return array array of metadatas (false if the cache id is not found)
*/
public function getMetadatas($id);
/**
* Give (if possible) an extra lifetime to the given cache id
*
@ -106,10 +106,10 @@ interface Zend_Cache_Backend_ExtendedInterface extends Zend_Cache_Backend_Interf
* @return boolean true if ok
*/
public function touch($id, $extraLifetime);
/**
* Return an associative array of capabilities (booleans) of the backend
*
*
* The array must include these keys :
* - automatic_cleaning (is automating cleaning necessary)
* - tags (are tags supported)
@ -118,9 +118,9 @@ interface Zend_Cache_Backend_ExtendedInterface extends Zend_Cache_Backend_Interf
* - priority does the backend deal with priority when saving
* - infinite_lifetime (is infinite lifetime can work with this backend)
* - get_list (is it possible to get the list of cache ids and the complete list of tags)
*
*
* @return array associative of with capabilities
*/
public function getCapabilities();
}

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: File.php 17029 2009-07-24 11:57:49Z matthew $
* @version $Id: File.php 17868 2009-08-28 09:46:30Z yoshida@zend.co.jp $
*/
/**
@ -259,7 +259,9 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
public function remove($id)
{
$file = $this->_file($id);
return ($this->_delMetadatas($id) && $this->_remove($file));
$boolRemove = $this->_remove($file);
$boolMetadata = $this->_delMetadatas($id);
return $boolMetadata && $boolRemove;
}
/**
@ -672,7 +674,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
break;
case Zend_Cache::CLEANING_MODE_OLD:
if (time() > $metadatas['expire']) {
$result = ($result) && ($this->remove($id));
$result = $this->remove($id) && $result;
}
break;
case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
@ -684,7 +686,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
}
}
if ($matching) {
$result = ($result) && ($this->remove($id));
$result = $this->remove($id) && $result;
}
break;
case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
@ -696,7 +698,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
}
}
if (!$matching) {
$result = ($result) && $this->remove($id);
$result = $this->remove($id) && $result;
}
break;
case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
@ -708,7 +710,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
}
}
if ($matching) {
$result = ($result) && ($this->remove($id));
$result = $this->remove($id) && $result;
}
break;
default:
@ -718,7 +720,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
}
if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) {
// Recursive call
$result = ($result) && ($this->_clean($file . DIRECTORY_SEPARATOR, $mode, $tags));
$result = $this->_clean($file . DIRECTORY_SEPARATOR, $mode, $tags) && $result;
if ($mode=='all') {
// if mode=='all', we try to drop the structure too
@rmdir($file);

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Memcached.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Memcached.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -155,16 +155,16 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca
$server['failure_callback'] = self::DEFAULT_FAILURE_CALLBACK;
}
if ($this->_options['compatibility']) {
// No status for compatibility mode (#ZF-5887)
$this->_memcache->addServer($server['host'], $server['port'], $server['persistent'],
// No status for compatibility mode (#ZF-5887)
$this->_memcache->addServer($server['host'], $server['port'], $server['persistent'],
$server['weight'], $server['timeout'],
$server['retry_interval']);
} else {
$this->_memcache->addServer($server['host'], $server['port'], $server['persistent'],
} else {
$this->_memcache->addServer($server['host'], $server['port'], $server['persistent'],
$server['weight'], $server['timeout'],
$server['retry_interval'],
$server['status'], $server['failure_callback']);
}
}
}
}
@ -383,22 +383,22 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca
$memSize = 0;
$memUsed = 0;
foreach ($mems as $key => $mem) {
if ($mem === false) {
if ($mem === false) {
Zend_Cache::throwException('can\'t get stat from ' . $key);
} else {
$eachSize = $mem['limit_maxbytes'];
if ($eachSize == 0) {
} else {
$eachSize = $mem['limit_maxbytes'];
if ($eachSize == 0) {
Zend_Cache::throwException('can\'t get memory size from ' . $key);
}
}
$eachUsed = $mem['bytes'];
if ($eachUsed > $eachSize) {
$eachUsed = $eachSize;
}
$eachUsed = $mem['bytes'];
if ($eachUsed > $eachSize) {
$eachUsed = $eachSize;
}
$memSize += $eachSize;
$memUsed += $eachUsed;
}
$memSize += $eachSize;
$memUsed += $eachUsed;
}
}
return ((int) (100. * ($memUsed / $memSize)));
@ -466,7 +466,7 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca
}
// #ZF-5702 : we try replace() first becase set() seems to be slower
if (!($result = $this->_memcache->replace($id, array($data, time(), $newLifetime), $flag, $newLifetime))) {
$result = $this->_memcache->set($id, array($data, time(), $newLifetime), $flag, $newLifetime);
$result = $this->_memcache->set($id, array($data, time(), $newLifetime), $flag, $newLifetime);
}
return $result;
}

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Sqlite.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Sqlite.php 17868 2009-08-28 09:46:30Z yoshida@zend.co.jp $
*/
@ -176,7 +176,7 @@ class Zend_Cache_Backend_Sqlite extends Zend_Cache_Backend implements Zend_Cache
}
$res = true;
foreach ($tags as $tag) {
$res = $res && $this->_registerTag($id, $tag);
$res = $this->_registerTag($id, $tag) && $res;
}
return $res;
}
@ -630,7 +630,7 @@ class Zend_Cache_Backend_Sqlite extends Zend_Cache_Backend implements Zend_Cache
$ids = $this->getIdsMatchingTags($tags);
$result = true;
foreach ($ids as $id) {
$result = $result && ($this->remove($id));
$result = $this->remove($id) && $result;
}
return $result;
break;
@ -638,7 +638,7 @@ class Zend_Cache_Backend_Sqlite extends Zend_Cache_Backend implements Zend_Cache
$ids = $this->getIdsNotMatchingTags($tags);
$result = true;
foreach ($ids as $id) {
$result = $result && ($this->remove($id));
$result = $this->remove($id) && $result;
}
return $result;
break;
@ -646,7 +646,7 @@ class Zend_Cache_Backend_Sqlite extends Zend_Cache_Backend implements Zend_Cache
$ids = $this->getIdsMatchingAnyTags($tags);
$result = true;
foreach ($ids as $id) {
$result = $result && ($this->remove($id));
$result = $this->remove($id) && $result;
}
return $result;
break;

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Xcache.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Xcache.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -46,7 +46,7 @@ class Zend_Cache_Backend_Xcache extends Zend_Cache_Backend implements Zend_Cache
*/
const TAGS_UNSUPPORTED_BY_CLEAN_OF_XCACHE_BACKEND = 'Zend_Cache_Backend_Xcache::clean() : tags are unsupported by the Xcache backend';
const TAGS_UNSUPPORTED_BY_SAVE_OF_XCACHE_BACKEND = 'Zend_Cache_Backend_Xcache::save() : tags are unsupported by the Xcache backend';
/**
* Available options
*

0
libs/Zend/Cache/Backend/ZendServer.php Executable file → Normal file
View File

200
libs/Zend/Cache/Backend/ZendServer/Disk.php Executable file → Normal file
View File

@ -1,100 +1,100 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Disk.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/** @see Zend_Cache_Backend_Interface */
require_once 'Zend/Cache/Backend/Interface.php';
/** @see Zend_Cache_Backend_ZendServer */
require_once 'Zend/Cache/Backend/ZendServer.php';
/**
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Cache_Backend_ZendServer_Disk extends Zend_Cache_Backend_ZendServer implements Zend_Cache_Backend_Interface
{
/**
* Constructor
*
* @param array $options associative array of options
* @throws Zend_Cache_Exception
*/
public function __construct(array $options = array())
{
if (!function_exists('zend_disk_cache_store')) {
Zend_Cache::throwException('Zend_Cache_ZendServer_Disk backend has to be used within Zend Server environment.');
}
parent::__construct($options);
}
/**
* Store data
*
* @param mixed $data Object to store
* @param string $id Cache id
* @param int $timeToLive Time to live in seconds
* @return boolean true if no problem
*/
protected function _store($data, $id, $timeToLive)
{
if (zend_disk_cache_store($this->_options['namespace'] . '::' . $id,
$data,
$timeToLive) === false) {
$this->_log('Store operation failed.');
return false;
}
return true;
}
/**
* Fetch data
*
* @param string $id Cache id
*/
protected function _fetch($id)
{
return zend_disk_cache_fetch($this->_options['namespace'] . '::' . $id);
}
/**
* Unset data
*
* @param string $id Cache id
* @return boolean true if no problem
*/
protected function _unset($id)
{
return zend_disk_cache_delete($this->_options['namespace'] . '::' . $id);
}
/**
* Clear cache
*/
protected function _clear()
{
zend_disk_cache_clear($this->_options['namespace']);
}
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Disk.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** @see Zend_Cache_Backend_Interface */
require_once 'Zend/Cache/Backend/Interface.php';
/** @see Zend_Cache_Backend_ZendServer */
require_once 'Zend/Cache/Backend/ZendServer.php';
/**
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Cache_Backend_ZendServer_Disk extends Zend_Cache_Backend_ZendServer implements Zend_Cache_Backend_Interface
{
/**
* Constructor
*
* @param array $options associative array of options
* @throws Zend_Cache_Exception
*/
public function __construct(array $options = array())
{
if (!function_exists('zend_disk_cache_store')) {
Zend_Cache::throwException('Zend_Cache_ZendServer_Disk backend has to be used within Zend Server environment.');
}
parent::__construct($options);
}
/**
* Store data
*
* @param mixed $data Object to store
* @param string $id Cache id
* @param int $timeToLive Time to live in seconds
* @return boolean true if no problem
*/
protected function _store($data, $id, $timeToLive)
{
if (zend_disk_cache_store($this->_options['namespace'] . '::' . $id,
$data,
$timeToLive) === false) {
$this->_log('Store operation failed.');
return false;
}
return true;
}
/**
* Fetch data
*
* @param string $id Cache id
*/
protected function _fetch($id)
{
return zend_disk_cache_fetch($this->_options['namespace'] . '::' . $id);
}
/**
* Unset data
*
* @param string $id Cache id
* @return boolean true if no problem
*/
protected function _unset($id)
{
return zend_disk_cache_delete($this->_options['namespace'] . '::' . $id);
}
/**
* Clear cache
*/
protected function _clear()
{
zend_disk_cache_clear($this->_options['namespace']);
}
}

200
libs/Zend/Cache/Backend/ZendServer/ShMem.php Executable file → Normal file
View File

@ -1,100 +1,100 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ShMem.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/** @see Zend_Cache_Backend_Interface */
require_once 'Zend/Cache/Backend/Interface.php';
/** @see Zend_Cache_Backend_ZendServer */
require_once 'Zend/Cache/Backend/ZendServer.php';
/**
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Cache_Backend_ZendServer_ShMem extends Zend_Cache_Backend_ZendServer implements Zend_Cache_Backend_Interface
{
/**
* Constructor
*
* @param array $options associative array of options
* @throws Zend_Cache_Exception
*/
public function __construct(array $options = array())
{
if (!function_exists('zend_shm_cache_store')) {
Zend_Cache::throwException('Zend_Cache_ZendServer_ShMem backend has to be used within Zend Server environment.');
}
parent::__construct($options);
}
/**
* Store data
*
* @param mixed $data Object to store
* @param string $id Cache id
* @param int $timeToLive Time to live in seconds
*
*/
protected function _store($data, $id, $timeToLive)
{
if (zend_shm_cache_store($this->_options['namespace'] . '::' . $id,
$data,
$timeToLive) === false) {
$this->_log('Store operation failed.');
return false;
}
return true;
}
/**
* Fetch data
*
* @param string $id Cache id
*/
protected function _fetch($id)
{
return zend_shm_cache_fetch($this->_options['namespace'] . '::' . $id);
}
/**
* Unset data
*
* @param string $id Cache id
* @return boolean true if no problem
*/
protected function _unset($id)
{
return zend_shm_cache_delete($this->_options['namespace'] . '::' . $id);
}
/**
* Clear cache
*/
protected function _clear()
{
zend_shm_cache_clear($this->_options['namespace']);
}
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ShMem.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** @see Zend_Cache_Backend_Interface */
require_once 'Zend/Cache/Backend/Interface.php';
/** @see Zend_Cache_Backend_ZendServer */
require_once 'Zend/Cache/Backend/ZendServer.php';
/**
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Cache_Backend_ZendServer_ShMem extends Zend_Cache_Backend_ZendServer implements Zend_Cache_Backend_Interface
{
/**
* Constructor
*
* @param array $options associative array of options
* @throws Zend_Cache_Exception
*/
public function __construct(array $options = array())
{
if (!function_exists('zend_shm_cache_store')) {
Zend_Cache::throwException('Zend_Cache_ZendServer_ShMem backend has to be used within Zend Server environment.');
}
parent::__construct($options);
}
/**
* Store data
*
* @param mixed $data Object to store
* @param string $id Cache id
* @param int $timeToLive Time to live in seconds
*
*/
protected function _store($data, $id, $timeToLive)
{
if (zend_shm_cache_store($this->_options['namespace'] . '::' . $id,
$data,
$timeToLive) === false) {
$this->_log('Store operation failed.');
return false;
}
return true;
}
/**
* Fetch data
*
* @param string $id Cache id
*/
protected function _fetch($id)
{
return zend_shm_cache_fetch($this->_options['namespace'] . '::' . $id);
}
/**
* Unset data
*
* @param string $id Cache id
* @return boolean true if no problem
*/
protected function _unset($id)
{
return zend_shm_cache_delete($this->_options['namespace'] . '::' . $id);
}
/**
* Clear cache
*/
protected function _clear()
{
zend_shm_cache_clear($this->_options['namespace']);
}
}

View File

@ -16,7 +16,7 @@
* @package Zend_Cache
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Core.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Core.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -124,18 +124,40 @@ class Zend_Cache_Core
/**
* Constructor
*
* @param array $options Associative array of options
* @param array|Zend_Config $options Associative array of options or Zend_Config instance
* @throws Zend_Cache_Exception
* @return void
*/
public function __construct(array $options = array())
public function __construct($options = array())
{
if ($options instanceof Zend_Config) {
$options = $options->toArray();
}
if (!is_array($options)) {
Zend_Cache::throwException("Options passed were not an array"
. " or Zend_Config instance.");
}
while (list($name, $value) = each($options)) {
$this->setOption($name, $value);
}
$this->_loggerSanity();
}
/**
* Set options using an instance of type Zend_Config
*
* @param Zend_Config $config
* @return Zend_Cache_Core
*/
public function setConfig(Zend_Config $config)
{
$options = $config->toArray();
while (list($name, $value) = each($options)) {
$this->setOption($name, $value);
}
return $this;
}
/**
* Set the backend
*
@ -483,11 +505,11 @@ class Zend_Cache_Core
// we need to remove cache_id_prefix from ids (see #ZF-6178)
$res = array();
while (list(,$id) = each($array)) {
if (strpos($id, $this->_options['cache_id_prefix']) === 0) {
$res[] = preg_replace("~^{$this->_options['cache_id_prefix']}~", '', $id);
} else {
$res[] = $id;
}
if (strpos($id, $this->_options['cache_id_prefix']) === 0) {
$res[] = preg_replace("~^{$this->_options['cache_id_prefix']}~", '', $id);
} else {
$res[] = $id;
}
}
return $res;
}
@ -520,7 +542,7 @@ class Zend_Cache_Core
}
return $this->_backend->getFillingPercentage();
}
/**
* Return an array of metadatas for the given cache id
*
@ -534,7 +556,7 @@ class Zend_Cache_Core
*/
public function getMetadatas($id)
{
if (!$this->_extendedBackend) {
if (!$this->_extendedBackend) {
Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available');
}
$id = $this->_id($id); // cache id may need prefix

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Cache_Frontend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: File.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: File.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -35,46 +35,46 @@ require_once 'Zend/Cache/Core.php';
*/
class Zend_Cache_Frontend_File extends Zend_Cache_Core
{
/**
* Consts for master_files_mode
*/
const MODE_AND = 'AND';
const MODE_OR = 'OR';
/**
* Consts for master_files_mode
*/
const MODE_AND = 'AND';
const MODE_OR = 'OR';
/**
* Available options
*
* ====> (string) master_file :
* - a complete path of the master file
* - deprecated (see master_files)
*
*
* ====> (array) master_files :
* - an array of complete path of master files
* - this option has to be set !
*
*
* ====> (string) master_files_mode :
* - Zend_Cache_Frontend_File::MODE_AND or Zend_Cache_Frontend_File::MODE_OR
* - if MODE_AND, then all master files have to be touched to get a cache invalidation
* - if MODE_OR (default), then a single touched master file is enough to get a cache invalidation
*
* ====> (boolean) ignore_missing_master_files
* - if set to true, missing master files are ignored silently
* - if set to true, missing master files are ignored silently
* - if set to false (default), an exception is thrown if there is a missing master file
* @var array available options
*/
protected $_specificOptions = array(
'master_file' => null,
'master_file' => null,
'master_files' => null,
'master_files_mode' => 'OR',
'ignore_missing_master_files' => false
'master_files_mode' => 'OR',
'ignore_missing_master_files' => false
);
/**
* Master file mtimes
*
* Array of int
*
*
* @var array
*/
private $_masterFile_mtimes = null;
@ -95,10 +95,10 @@ class Zend_Cache_Frontend_File extends Zend_Cache_Core
Zend_Cache::throwException('master_files option must be set');
}
}
/**
* Change the master_file option
*
*
* @param string $masterFile the complete path and name of the master file
*/
public function setMasterFiles($masterFiles)
@ -109,27 +109,27 @@ class Zend_Cache_Frontend_File extends Zend_Cache_Core
$this->_masterFile_mtimes = array();
$i = 0;
foreach ($masterFiles as $masterFile) {
$this->_masterFile_mtimes[$i] = @filemtime($masterFile);
if ((!($this->_specificOptions['ignore_missing_master_files'])) && (!($this->_masterFile_mtimes[$i]))) {
Zend_Cache::throwException('Unable to read master_file : '.$masterFile);
}
$i++;
$this->_masterFile_mtimes[$i] = @filemtime($masterFile);
if ((!($this->_specificOptions['ignore_missing_master_files'])) && (!($this->_masterFile_mtimes[$i]))) {
Zend_Cache::throwException('Unable to read master_file : '.$masterFile);
}
$i++;
}
}
/**
* Change the master_file option
*
* To keep the compatibility
*
*
* To keep the compatibility
*
* @deprecated
* @param string $masterFile the complete path and name of the master file
*/
*/
public function setMasterFile($masterFile)
{
$this->setMasterFiles(array(0 => $masterFile));
$this->setMasterFiles(array(0 => $masterFile));
}
/**
* Public frontend to set an option
*
@ -145,7 +145,7 @@ class Zend_Cache_Frontend_File extends Zend_Cache_Core
if ($name == 'master_file') {
$this->setMasterFile($value);
} else if ($name == 'master_files') {
$this->setMasterFiles($value);
$this->setMasterFiles($value);
} else {
parent::setOption($name, $value);
}
@ -180,27 +180,27 @@ class Zend_Cache_Frontend_File extends Zend_Cache_Core
{
$lastModified = parent::test($id);
if ($lastModified) {
if ($this->_specificOptions['master_files_mode'] == self::MODE_AND) {
// MODE_AND
foreach($this->_masterFile_mtimes as $masterFileMTime) {
if ($masterFileMTime) {
if ($lastModified > $masterFileMTime) {
return $lastModified;
}
}
}
} else {
// MODE_OR
$res = true;
foreach($this->_masterFile_mtimes as $masterFileMTime) {
if ($masterFileMTime) {
if ($lastModified <= $masterFileMTime) {
return false;
}
}
}
return $lastModified;
}
if ($this->_specificOptions['master_files_mode'] == self::MODE_AND) {
// MODE_AND
foreach($this->_masterFile_mtimes as $masterFileMTime) {
if ($masterFileMTime) {
if ($lastModified > $masterFileMTime) {
return $lastModified;
}
}
}
} else {
// MODE_OR
$res = true;
foreach($this->_masterFile_mtimes as $masterFileMTime) {
if ($masterFileMTime) {
if ($lastModified <= $masterFileMTime) {
return false;
}
}
}
return $lastModified;
}
}
return false;
}

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Cache_Frontend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Function.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Function.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -76,7 +76,7 @@ class Zend_Cache_Frontend_Function extends Zend_Cache_Core
* @param array $parameters Function parameters
* @param array $tags Cache tags
* @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
* @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
* @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
* @return mixed Result
*/
public function call($name, $parameters = array(), $tags = array(), $specificLifetime = false, $priority = 8)

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Cache_Frontend
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Page.php 16974 2009-07-22 19:23:08Z matthew $
* @version $Id: Page.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -275,7 +275,7 @@ class Zend_Cache_Frontend_Page extends Zend_Cache_Core
header("$name: $value");
}
}
if ($this->_specificOptions['debug_header']) {
if ($this->_specificOptions['debug_header']) {
echo 'DEBUG HEADER : This is a cached page !';
}
echo $data;
@ -339,9 +339,9 @@ class Zend_Cache_Frontend_Page extends Zend_Cache_Core
{
$tmp = $_SERVER['REQUEST_URI'];
$array = explode('?', $tmp, 2);
$tmp = $array[0];
$tmp = $array[0];
foreach (array('Get', 'Post', 'Session', 'Files', 'Cookie') as $arrayName) {
$tmp2 = $this->_makePartialId($arrayName, $this->_activeOptions['cache_with_' . strtolower($arrayName) . '_variables'], $this->_activeOptions['make_id_with_' . strtolower($arrayName) . '_variables']);
$tmp2 = $this->_makePartialId($arrayName, $this->_activeOptions['cache_with_' . strtolower($arrayName) . '_variables'], $this->_activeOptions['make_id_with_' . strtolower($arrayName) . '_variables']);
if ($tmp2===false) {
return false;
}
@ -360,7 +360,7 @@ class Zend_Cache_Frontend_Page extends Zend_Cache_Core
*/
protected function _makePartialId($arrayName, $bool1, $bool2)
{
switch ($arrayName) {
switch ($arrayName) {
case 'Get':
$var = $_GET;
break;

View File

@ -24,7 +24,7 @@ require_once 'Zend/Validate/Interface.php';
/**
* Generic Captcha adapter interface
*
*
* Each specific captcha implementation should implement this interface
*
* @category Zend
@ -32,9 +32,9 @@ require_once 'Zend/Validate/Interface.php';
* @subpackage Adapter
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Adapter.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Adapter.php 18951 2009-11-12 16:26:19Z alexander $
*/
interface Zend_Captcha_Adapter extends Zend_Validate_Interface
interface Zend_Captcha_Adapter extends Zend_Validate_Interface
{
/**
* Generate a new captcha
@ -62,7 +62,7 @@ interface Zend_Captcha_Adapter extends Zend_Validate_Interface
/**
* Get captcha name
*
*
* @return string
*/
public function getName();

View File

@ -27,7 +27,7 @@ require_once 'Zend/Validate/Abstract.php';
/**
* Base class for Captcha adapters
*
*
* Provides some utility functionality to build on
*
* @category Zend
@ -35,13 +35,13 @@ require_once 'Zend/Validate/Abstract.php';
* @subpackage Adapter
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Base.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Base.php 18951 2009-11-12 16:26:19Z alexander $
*/
abstract class Zend_Captcha_Base extends Zend_Validate_Abstract implements Zend_Captcha_Adapter
abstract class Zend_Captcha_Base extends Zend_Validate_Abstract implements Zend_Captcha_Adapter
{
/**
* Element name
*
*
* Useful to generate/check form fields
*
* @var string
@ -49,8 +49,8 @@ abstract class Zend_Captcha_Base extends Zend_Validate_Abstract implements Zend_
protected $_name;
/**
* Captcha options
*
* Captcha options
*
* @var array
*/
protected $_options = array();
@ -63,23 +63,23 @@ abstract class Zend_Captcha_Base extends Zend_Validate_Abstract implements Zend_
'options',
'config',
);
/**
* Get name
*
*
* @return string
*/
public function getName()
public function getName()
{
return $this->_name;
}
/**
* Set name
*
* Set name
*
* @param string $name
*/
public function setName($name)
public function setName($name)
{
$this->_name = $name;
return $this;
@ -88,7 +88,7 @@ abstract class Zend_Captcha_Base extends Zend_Validate_Abstract implements Zend_
/**
* Constructor
*
* @param array|Zend_Config $options
* @param array|Zend_Config $options
* @return void
*/
public function __construct($options = null)
@ -98,9 +98,9 @@ abstract class Zend_Captcha_Base extends Zend_Validate_Abstract implements Zend_
$this->setOptions($options);
} else if ($options instanceof Zend_Config) {
$this->setConfig($options);
}
}
}
}
/**
* Set single option for the object
*
@ -126,11 +126,11 @@ abstract class Zend_Captcha_Base extends Zend_Validate_Abstract implements Zend_
}
return $this;
}
/**
* Set object state from options array
*
* @param array $options
*
* @param array $options
* @return Zend_Form_Element
*/
public function setOptions($options = null)
@ -140,10 +140,10 @@ abstract class Zend_Captcha_Base extends Zend_Validate_Abstract implements Zend_
}
return $this;
}
/**
* Retrieve options representing object state
*
*
* @return array
*/
public function getOptions()
@ -153,8 +153,8 @@ abstract class Zend_Captcha_Base extends Zend_Validate_Abstract implements Zend_
/**
* Set object state from config object
*
* @param Zend_Config $config
*
* @param Zend_Config $config
* @return Zend_Captcha_Base
*/
public function setConfig(Zend_Config $config)
@ -164,12 +164,12 @@ abstract class Zend_Captcha_Base extends Zend_Validate_Abstract implements Zend_
/**
* Get optional decorator
*
*
* By default, return null, indicating no extra decorator needed.
*
* @return null
*/
public function getDecorator()
public function getDecorator()
{
return null;
}

View File

@ -24,15 +24,15 @@ require_once 'Zend/Captcha/Word.php';
/**
* Example dumb word-based captcha
*
*
* Note that only rendering is necessary for word-based captcha
*
*
* @category Zend
* @package Zend_Captcha
* @subpackage Adapter
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Dumb.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Dumb.php 18951 2009-11-12 16:26:19Z alexander $
*/
class Zend_Captcha_Dumb extends Zend_Captcha_Word
{

0
libs/Zend/Captcha/Exception.php Executable file → Normal file
View File

View File

@ -27,7 +27,7 @@ require_once 'Zend/Text/Figlet.php';
/**
* Captcha based on figlet text rendering service
*
*
* Note that this engine seems not to like numbers
*
* @category Zend
@ -35,7 +35,7 @@ require_once 'Zend/Text/Figlet.php';
* @subpackage Adapter
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Figlet.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Figlet.php 18951 2009-11-12 16:26:19Z alexander $
*/
class Zend_Captcha_Figlet extends Zend_Captcha_Word
{
@ -45,11 +45,11 @@ class Zend_Captcha_Figlet extends Zend_Captcha_Word
* @var Zend_Text_Figlet
*/
protected $_figlet;
/**
* Constructor
*
* @param null|string|array|Zend_Config $options
*
* @param null|string|array|Zend_Config $options
* @return void
*/
public function __construct($options = null)
@ -57,7 +57,7 @@ class Zend_Captcha_Figlet extends Zend_Captcha_Word
parent::__construct($options);
$this->_figlet = new Zend_Text_Figlet($options);
}
/**
* Generate new captcha
*
@ -66,7 +66,7 @@ class Zend_Captcha_Figlet extends Zend_Captcha_Word
public function generate()
{
$this->_useNumbers = false;
return parent::generate();
return parent::generate();
}
/**

View File

@ -17,7 +17,7 @@
* @subpackage Adapter
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Image.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Image.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Captcha_Word */
@ -423,8 +423,8 @@ class Zend_Captcha_Image extends Zend_Captcha_Word
$tries = 5;
// If there's already such file, try creating a new ID
while($tries-- && file_exists($this->getImgDir() . $id . $this->getSuffix())) {
$id = $this->_generateRandomId();
$this->_setId($id);
$id = $this->_generateRandomId();
$this->_setId($id);
}
$this->_generateImage($id, $this->getWord());

View File

@ -37,7 +37,7 @@ require_once 'Zend/Service/ReCaptcha.php';
* @subpackage Adapter
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ReCaptcha.php 16201 2009-06-21 18:51:15Z thomas $
* @version $Id: ReCaptcha.php 18166 2009-09-17 13:28:35Z padraic $
*/
class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base
{
@ -63,6 +63,13 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base
*/
protected $_serviceParams = array();
/**
* Options defined by the service
*
* @var array
*/
protected $_serviceOptions = array();
/**#@+
* Error codes
* @const string
@ -136,6 +143,7 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base
{
$this->setService(new Zend_Service_ReCaptcha());
$this->_serviceParams = $this->getService()->getParams();
$this->_serviceOptions = $this->getService()->getOptions();
parent::__construct($options);
@ -172,7 +180,8 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base
/**
* Set option
*
* If option is a service parameter, proxies to the service.
* If option is a service parameter, proxies to the service. The same
* goes for any service options (distinct from service params)
*
* @param string $key
* @param mixed $value
@ -185,6 +194,10 @@ class Zend_Captcha_ReCaptcha extends Zend_Captcha_Base
$service->setParam($key, $value);
return $this;
}
if (isset($this->_serviceOptions[$key])) {
$service->setOption($key, $value);
return $this;
}
return parent::setOption($key, $value);
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Abstract.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -33,12 +33,12 @@ abstract class Zend_CodeGenerator_Abstract
* @var string
*/
protected $_sourceContent = null;
/**
* @var bool
*/
protected $_isSourceDirty = true;
/**
* __construct()
*
@ -59,7 +59,7 @@ abstract class Zend_CodeGenerator_Abstract
}
$this->_prepare();
}
/**
* setConfig()
*
@ -71,7 +71,7 @@ abstract class Zend_CodeGenerator_Abstract
$this->setOptions($config->toArray());
return $this;
}
/**
* setOptions()
*
@ -88,7 +88,7 @@ abstract class Zend_CodeGenerator_Abstract
}
return $this;
}
/**
* setSourceContent()
*
@ -99,7 +99,7 @@ abstract class Zend_CodeGenerator_Abstract
$this->_sourceContent = $sourceContent;
return;
}
/**
* getSourceContent()
*
@ -109,31 +109,31 @@ abstract class Zend_CodeGenerator_Abstract
{
return $this->_sourceContent;
}
/**
* _init() - this is called before the constuctor
*
*/
protected function _init()
{
}
/**
* _prepare() - this is called at construction completion
*
*/
protected function _prepare()
{
}
/**
* generate() - must be implemented by the child
*
*/
abstract public function generate();
/**
* __toString() - casting to a string will in turn call generate()
*

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Abstract.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -39,17 +39,17 @@ abstract class Zend_CodeGenerator_Php_Abstract extends Zend_CodeGenerator_Abstra
*
*/
const LINE_FEED = "\n";
/**
* @var bool
*/
protected $_isSourceDirty = true;
/**
* @var int|string
*/
protected $_indentation = ' ';
/**
* setSourceDirty()
*
@ -61,7 +61,7 @@ abstract class Zend_CodeGenerator_Php_Abstract extends Zend_CodeGenerator_Abstra
$this->_isSourceDirty = ($isSourceDirty) ? true : false;
return $this;
}
/**
* isSourceDirty()
*
@ -71,7 +71,7 @@ abstract class Zend_CodeGenerator_Php_Abstract extends Zend_CodeGenerator_Abstra
{
return $this->_isSourceDirty;
}
/**
* setIndentation()
*
@ -83,7 +83,7 @@ abstract class Zend_CodeGenerator_Php_Abstract extends Zend_CodeGenerator_Abstra
$this->_indentation = $indentation;
return $this;
}
/**
* getIndentation()
*
@ -93,5 +93,5 @@ abstract class Zend_CodeGenerator_Php_Abstract extends Zend_CodeGenerator_Abstra
{
return $this->_indentation;
}
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Body.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Body.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -33,12 +33,12 @@ require_once 'Zend/CodeGenerator/Abstract.php';
*/
class Zend_CodeGenerator_Php_Body extends Zend_CodeGenerator_Abstract
{
/**
* @var string
*/
protected $_content = null;
/**
* setContent()
*
@ -50,7 +50,7 @@ class Zend_CodeGenerator_Php_Body extends Zend_CodeGenerator_Abstract
$this->_content = $content;
return $this;
}
/**
* getContent()
*
@ -60,7 +60,7 @@ class Zend_CodeGenerator_Php_Body extends Zend_CodeGenerator_Abstract
{
return (string) $this->_content;
}
/**
* generate()
*

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Class.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Class.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -53,37 +53,37 @@ require_once 'Zend/CodeGenerator/Php/Docblock.php';
*/
class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
/**
* @var Zend_CodeGenerator_Php_Docblock
*/
protected $_docblock = null;
/**
* @var string
*/
protected $_name = null;
/**
* @var bool
*/
protected $_isAbstract = false;
/**
* @var string
*/
protected $_extendedClass = null;
/**
* @var array Array of string names
*/
protected $_implementedInterfaces = array();
/**
* @var array Array of properties
*/
protected $_properties = null;
/**
* @var array Array of methods
*/
@ -98,26 +98,31 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
public static function fromReflection(Zend_Reflection_Class $reflectionClass)
{
$class = new self();
$class->setSourceContent($class->getSourceContent());
$class->setSourceDirty(false);
if ($reflectionClass->getDocComment() != '') {
$class->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionClass->getDocblock()));
}
$class->setAbstract($reflectionClass->isAbstract());
$class->setName($reflectionClass->getName());
if ($parentClass = $reflectionClass->getParentClass()) {
$class->setExtendedClass($parentClass->getName());
$interfaces = array_diff($parentClass->getInterfaces(), $reflectionClass->getInterfaces());
$interfaces = array_diff($reflectionClass->getInterfaces(), $parentClass->getInterfaces());
} else {
$interfaces = $reflectionClass->getInterfaces();
}
$class->setImplementedInterfaces($interfaces);
$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()) {
@ -125,7 +130,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
}
}
$class->setProperties($properties);
$methods = array();
foreach ($reflectionClass->getMethods() as $reflectionMethod) {
if ($reflectionMethod->getDeclaringClass()->getName() == $class->getName()) {
@ -133,33 +138,33 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
}
}
$class->setMethods($methods);
return $class;
}
/**
* setDocblock() Set the docblock
*
* @param Zend_CodeGenerator_Php_Docblock|array|string $docblock
* @return Zend_CodeGenerator_Php_File
*/
public function setDocblock($docblock)
public function setDocblock($docblock)
{
if (is_string($docblock)) {
$docblock = array('shortDescription' => $docblock);
}
if (is_array($docblock)) {
$docblock = new Zend_CodeGenerator_Php_Docblock($docblock);
} elseif (!$docblock instanceof Zend_CodeGenerator_Php_Docblock) {
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('setDocblock() is expecting either a string, array or an instance of Zend_CodeGenerator_Php_Docblock');
}
$this->_docblock = $docblock;
return $this;
}
/**
* getDocblock()
*
@ -169,7 +174,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return $this->_docblock;
}
/**
* setName()
*
@ -181,7 +186,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
$this->_name = $name;
return $this;
}
/**
* getName()
*
@ -203,7 +208,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
$this->_isAbstract = ($isAbstract) ? true : false;
return $this;
}
/**
* isAbstract()
*
@ -213,7 +218,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return $this->_isAbstract;
}
/**
* setExtendedClass()
*
@ -225,7 +230,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
$this->_extendedClass = $extendedClass;
return $this;
}
/**
* getExtendedClass()
*
@ -235,7 +240,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return $this->_extendedClass;
}
/**
* setImplementedInterfaces()
*
@ -247,7 +252,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
$this->_implementedInterfaces = $implementedInterfaces;
return $this;
}
/**
* getImplementedInterfaces
*
@ -257,7 +262,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return $this->_implementedInterfaces;
}
/**
* setProperties()
*
@ -269,10 +274,10 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
foreach ($properties as $property) {
$this->setProperty($property);
}
return $this;
}
/**
* setProperty()
*
@ -290,16 +295,16 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('setProperty() expects either an array of property options or an instance of Zend_CodeGenerator_Php_Property');
}
if (isset($this->_properties[$propertyName])) {
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('A property by name ' . $propertyName . ' already exists in this class.');
}
$this->_properties->append($property);
$this->_properties[$propertyName] = $property;
return $this;
}
/**
* getProperties()
*
@ -309,7 +314,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return $this->_properties;
}
/**
* getProperty()
*
@ -325,7 +330,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
}
return false;
}
/**
* hasProperty()
*
@ -336,7 +341,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return isset($this->_properties[$propertyName]);
}
/**
* setMethods()
*
@ -350,7 +355,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
}
return $this;
}
/**
* setMethod()
*
@ -368,16 +373,16 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('setMethod() expects either an array of method options or an instance of Zend_CodeGenerator_Php_Method');
}
if (isset($this->_methods[$methodName])) {
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('A method by name ' . $methodName . ' already exists in this class.');
}
$this->_methods->append($method);
$this->_methods[$methodName] = $method;
return $this;
}
/**
* getMethods()
*
@ -387,7 +392,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return $this->_methods;
}
/**
* getMethod()
*
@ -403,7 +408,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
}
return false;
}
/**
* hasMethod()
*
@ -414,7 +419,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return isset($this->_methods[$methodName]);
}
/**
* isSourceDirty()
*
@ -425,22 +430,22 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
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()
*
@ -451,50 +456,50 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
if (!$this->isSourceDirty()) {
return $this->getSourceContent();
}
$output = '';
$output = '';
if (null !== ($docblock = $this->getDocblock())) {
$docblock->setIndentation('');
$output .= $docblock->generate();
}
if ($this->isAbstract()) {
$output .= 'abstract ';
}
$output .= 'class ' . $this->getName();
if (null !== ($ec = $this->_extendedClass)) {
$output .= ' extends ' . $ec;
}
$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
*

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Docblock.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Docblock.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -42,12 +42,12 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
* @var string
*/
protected $_shortDescription = null;
/**
* @var string
*/
protected $_longDescription = null;
/**
* @var array
*/
@ -57,7 +57,7 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
* @var string
*/
protected $_indentation = '';
/**
* fromReflection() - Build a docblock generator object from a reflection object
*
@ -67,20 +67,20 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
public static function fromReflection(Zend_Reflection_Docblock $reflectionDocblock)
{
$docblock = new self();
$docblock->setSourceContent($reflectionDocblock->getContents());
$docblock->setSourceDirty(false);
$docblock->setShortDescription($reflectionDocblock->getShortDescription());
$docblock->setLongDescription($reflectionDocblock->getLongDescription());
foreach ($reflectionDocblock->getTags() as $tag) {
$docblock->setTag(Zend_CodeGenerator_Php_Docblock_Tag::fromReflection($tag));
}
return $docblock;
}
/**
* setShortDescription()
*
@ -92,7 +92,7 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
$this->_shortDescription = $shortDescription;
return $this;
}
/**
* getShortDescription()
*
@ -102,7 +102,7 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
{
return $this->_shortDescription;
}
/**
* setLongDescription()
*
@ -114,7 +114,7 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
$this->_longDescription = $longDescription;
return $this;
}
/**
* getLongDescription()
*
@ -124,7 +124,7 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
{
return $this->_longDescription;
}
/**
* setTags()
*
@ -136,10 +136,10 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
foreach ($tags as $tag) {
$this->setTag($tag);
}
return $this;
}
/**
* setTag()
*
@ -157,11 +157,11 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
. 'instance of Zend_CodeGenerator_Php_Docblock_Tag'
);
}
$this->_tags[] = $tag;
return $this;
}
/**
* getTags
*
@ -171,7 +171,7 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
{
return $this->_tags;
}
/**
* generate()
*
@ -182,7 +182,7 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
if (!$this->isSourceDirty()) {
return $this->_docCommentize($this->getSourceContent());
}
$output = '';
if (null !== ($sd = $this->getShortDescription())) {
$output .= $sd . self::LINE_FEED . self::LINE_FEED;
@ -194,10 +194,10 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
foreach ($this->getTags() as $tag) {
$output .= $tag->generate() . self::LINE_FEED;
}
return $this->_docCommentize(trim($output));
}
/**
* _docCommentize()
*
@ -216,5 +216,5 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
$output .= $indent . ' */' . self::LINE_FEED;
return $output;
}
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Tag.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Tag.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -53,7 +53,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag extends Zend_CodeGenerator_Php_Abstrac
* @var string
*/
protected $_name = null;
/**
* @var string
*/
@ -68,9 +68,9 @@ class Zend_CodeGenerator_Php_Docblock_Tag extends Zend_CodeGenerator_Php_Abstrac
public static function fromReflection(Zend_Reflection_Docblock_Tag $reflectionTag)
{
$tagName = $reflectionTag->getName();
$codeGenDocblockTag = self::factory($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) {
@ -81,10 +81,10 @@ class Zend_CodeGenerator_Php_Docblock_Tag extends Zend_CodeGenerator_Php_Abstrac
}
}
}
return $codeGenDocblockTag;
}
/**
* setPluginLoader()
*
@ -95,7 +95,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag extends Zend_CodeGenerator_Php_Abstrac
self::$_pluginLoader = $pluginLoader;
return;
}
/**
* getPluginLoader()
*
@ -109,24 +109,24 @@ class Zend_CodeGenerator_Php_Docblock_Tag extends Zend_CodeGenerator_Php_Abstrac
'Zend_CodeGenerator_Php_Docblock_Tag' => dirname(__FILE__) . '/Tag/'))
);
}
return self::$_pluginLoader;
}
public static function factory($tagName)
{
$pluginLoader = self::getPluginLoader();
try {
$tagClass = $pluginLoader->load($tagName);
} catch (Zend_Loader_Exception $exception) {
$tagClass = 'Zend_CodeGenerator_Php_Docblock_Tag';
}
$tag = new $tagClass(array('name' => $tagName));
return $tag;
}
/**
* setName()
*
@ -138,7 +138,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag extends Zend_CodeGenerator_Php_Abstrac
$this->_name = ltrim($name, '@');
return $this;
}
/**
* getName()
*
@ -148,7 +148,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag extends Zend_CodeGenerator_Php_Abstrac
{
return $this->_name;
}
/**
* setDescription()
*
@ -160,7 +160,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag extends Zend_CodeGenerator_Php_Abstrac
$this->_description = $description;
return $this;
}
/**
* getDescription()
*
@ -180,5 +180,5 @@ class Zend_CodeGenerator_Php_Docblock_Tag extends Zend_CodeGenerator_Php_Abstrac
{
return '@' . $this->_name . ' ' . $this->_description;
}
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: License.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: License.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -31,19 +31,19 @@ require_once 'Zend/CodeGenerator/Php/Docblock/Tag.php';
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_CodeGenerator_Php_Docblock_Tag_License extends Zend_CodeGenerator_Php_Docblock_Tag
class Zend_CodeGenerator_Php_Docblock_Tag_License extends Zend_CodeGenerator_Php_Docblock_Tag
{
/**
* @var string
*/
protected $_url = null;
/**
* @var string
*/
protected $_description = null;
/**
* fromReflection()
*
@ -53,14 +53,14 @@ class Zend_CodeGenerator_Php_Docblock_Tag_License extends Zend_CodeGenerator_Php
public static function fromReflection(Zend_Reflection_Docblock_Tag $reflectionTagLicense)
{
$returnTag = new self();
$returnTag->setName('license');
$returnTag->setUrl($reflectionTagLicense->getUrl());
$returnTag->setDescription($reflectionTagLicense->getDescription());
return $returnTag;
}
/**
* setUrl()
*
@ -72,7 +72,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag_License extends Zend_CodeGenerator_Php
$this->_url = $url;
return $this;
}
/**
* getUrl()
*
@ -94,5 +94,5 @@ class Zend_CodeGenerator_Php_Docblock_Tag_License extends Zend_CodeGenerator_Php
$output = '@license ' . $this->_url . ' ' . $this->_description . self::LINE_FEED;
return $output;
}
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Param.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Param.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -33,22 +33,22 @@ require_once 'Zend/CodeGenerator/Php/Docblock/Tag.php';
*/
class Zend_CodeGenerator_Php_Docblock_Tag_Param extends Zend_CodeGenerator_Php_Docblock_Tag
{
/**
* @var string
*/
protected $_datatype = null;
/**
* @var string
*/
protected $_paramName = null;
/**
* @var string
*/
protected $_description = null;
/**
* fromReflection()
*
@ -63,7 +63,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag_Param extends Zend_CodeGenerator_Php_D
$paramTag->setDatatype($reflectionTagParam->getType()); // @todo rename
$paramTag->setParamName($reflectionTagParam->getVariableName());
$paramTag->setDescription($reflectionTagParam->getDescription());
return $paramTag;
}
@ -78,7 +78,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag_Param extends Zend_CodeGenerator_Php_D
$this->_datatype = $datatype;
return $this;
}
/**
* getDatatype
*
@ -88,7 +88,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag_Param extends Zend_CodeGenerator_Php_D
{
return $this->_datatype;
}
/**
* setParamName()
*
@ -100,7 +100,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag_Param extends Zend_CodeGenerator_Php_D
$this->_paramName = $paramName;
return $this;
}
/**
* getParamName()
*
@ -110,7 +110,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag_Param extends Zend_CodeGenerator_Php_D
{
return $this->_paramName;
}
/**
* generate()
*
@ -118,11 +118,11 @@ class Zend_CodeGenerator_Php_Docblock_Tag_Param extends Zend_CodeGenerator_Php_D
*/
public function generate()
{
$output = '@param '
$output = '@param '
. (($this->_datatype != null) ? $this->_datatype : 'unknown')
. (($this->_paramName != null) ? ' $' . $this->_paramName : '')
. (($this->_paramName != null) ? ' $' . $this->_paramName : '')
. (($this->_description != null) ? ' ' . $this->_description : '');
return $output;
}
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Return.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Return.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -31,19 +31,19 @@ require_once 'Zend/CodeGenerator/Php/Docblock/Tag.php';
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_CodeGenerator_Php_Docblock_Tag_Return extends Zend_CodeGenerator_Php_Docblock_Tag
class Zend_CodeGenerator_Php_Docblock_Tag_Return extends Zend_CodeGenerator_Php_Docblock_Tag
{
/**
* @var string
*/
protected $_datatype = null;
/**
* @var string
*/
protected $_description = null;
/**
* fromReflection()
*
@ -53,14 +53,14 @@ class Zend_CodeGenerator_Php_Docblock_Tag_Return extends Zend_CodeGenerator_Php_
public static function fromReflection(Zend_Reflection_Docblock_Tag $reflectionTagReturn)
{
$returnTag = new self();
$returnTag->setName('return');
$returnTag->setDatatype($reflectionTagReturn->getType()); // @todo rename
$returnTag->setDescription($reflectionTagReturn->getDescription());
return $returnTag;
}
/**
* setDatatype()
*
@ -72,7 +72,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag_Return extends Zend_CodeGenerator_Php_
$this->_datatype = $datatype;
return $this;
}
/**
* getDatatype()
*
@ -94,5 +94,5 @@ class Zend_CodeGenerator_Php_Docblock_Tag_Return extends Zend_CodeGenerator_Php_
$output = '@return ' . $this->_datatype . ' ' . $this->_description;
return $output;
}
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Exception.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -33,5 +33,5 @@ require_once 'Zend/CodeGenerator/Exception.php';
*/
class Zend_CodeGenerator_Php_Exception extends Zend_CodeGenerator_Exception
{
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: File.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: File.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -38,12 +38,12 @@ require_once 'Zend/CodeGenerator/Php/Class.php';
*/
class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
{
/**
* @var array Array of Zend_CodeGenerator_Php_File
*/
protected static $_fileCodeGenerators = array();
/**#@+
* @var string
*/
@ -51,27 +51,27 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
protected static $_markerRequire = '/* Zend_CodeGenerator_Php_File-RequireMarker: {?} */';
protected static $_markerClass = '/* Zend_CodeGenerator_Php_File-ClassMarker: {?} */';
/**#@-*/
/**
* @var string
*/
protected $_filename = null;
/**
* @var Zend_CodeGenerator_Php_Docblock
*/
protected $_docblock = null;
/**
* @var array
*/
protected $_requiredFiles = array();
/**
* @var array
*/
protected $_classes = array();
/**
* @var string
*/
@ -82,20 +82,20 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
if ($fileName == null) {
$fileName = $fileCodeGenerator->getFilename();
}
if ($fileName == '') {
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_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
@ -108,31 +108,31 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
public static function fromReflectedFileName($filePath, $usePreviousCodeGeneratorIfItExists = true, $includeIfNotAlreadyIncluded = true)
{
$realpath = realpath($filePath);
if ($realpath === false) {
if ( ($realpath = Zend_Reflection_file::findRealpathInIncludePath($filePath)) === false) {
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_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 Zend_Reflection_File($realpath)));
if (!isset(self::$_fileCodeGenerators[$fileReflector->getFileName()])) {
self::$_fileCodeGenerators[$fileReflector->getFileName()] = $codeGenerator;
}
return $codeGenerator;
}
/**
* fromReflection()
*
@ -142,22 +142,22 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
public static function fromReflection(Zend_Reflection_File $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) {
$file->setClass(Zend_CodeGenerator_Php_Class::fromReflection($class));
$classStartLine = $class->getStartLine(true);
$classEndLine = $class->getEndLine();
$bodyLines = explode("\n", $body);
$bodyReturn = array();
for ($lineNum = 1; $lineNum <= count($bodyLines); $lineNum++) {
if ($lineNum == $classStartLine) {
if ($lineNum == $classStartLine) {
$bodyReturn[] = str_replace('?', $class->getName(), self::$_markerClass); //'/* Zend_CodeGenerator_Php_File-ClassMarker: {' . $class->getName() . '} */';
$lineNum = $classEndLine;
} else {
@ -167,15 +167,15 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
$body = implode("\n", $bodyReturn);
unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine);
}
if (($reflectionFile->getDocComment() != '')) {
$docblock = $reflectionFile->getDocblock();
$file->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($docblock));
$bodyLines = explode("\n", $body);
$bodyReturn = array();
for ($lineNum = 1; $lineNum <= count($bodyLines); $lineNum++) {
if ($lineNum == $docblock->getStartLine()) {
if ($lineNum == $docblock->getStartLine()) {
$bodyReturn[] = str_replace('?', $class->getName(), self::$_markerDocblock); //'/* Zend_CodeGenerator_Php_File-ClassMarker: {' . $class->getName() . '} */';
$lineNum = $docblock->getEndLine();
} else {
@ -185,41 +185,41 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
$body = implode("\n", $bodyReturn);
unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine);
}
$file->setBody($body);
return $file;
}
/**
* setDocblock() Set the docblock
*
* @param Zend_CodeGenerator_Php_Docblock|array|string $docblock
* @return Zend_CodeGenerator_Php_File
*/
public function setDocblock($docblock)
public function setDocblock($docblock)
{
if (is_string($docblock)) {
$docblock = array('shortDescription' => $docblock);
}
if (is_array($docblock)) {
$docblock = new Zend_CodeGenerator_Php_Docblock($docblock);
} elseif (!$docblock instanceof Zend_CodeGenerator_Php_Docblock) {
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_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_Php_Docblock
*/
public function getDocblock()
public function getDocblock()
{
return $this->_docblock;
}
@ -235,13 +235,13 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
$this->_requiredFiles = $requiredFiles;
return $this;
}
/**
* getRequiredFiles()
*
* @return array
*/
public function getRequiredFiles()
public function getRequiredFiles()
{
return $this->_requiredFiles;
}
@ -252,14 +252,14 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
* @param array $classes
* @return Zend_CodeGenerator_Php_File
*/
public function setClasses(Array $classes)
public function setClasses(Array $classes)
{
foreach ($classes as $class) {
$this->setClass($class);
}
return $this;
}
/**
* getClass()
*
@ -272,10 +272,10 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
reset($this->_classes);
return current($this->_classes);
}
return $this->_classes[$name];
}
/**
* setClass()
*
@ -293,13 +293,13 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('Expecting either an array or an instance of Zend_CodeGenerator_Php_Class');
}
// @todo check for dup here
// @todo check for dup here
$this->_classes[$className] = $class;
return $this;
}
/**
* setFilename()
*
@ -311,7 +311,7 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
$this->_filename = $filename;
return $this;
}
/**
* getFilename()
*
@ -321,13 +321,13 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
{
return $this->_filename;
}
/**
* getClasses()
*
* @return array Array of Zend_CodeGenerator_Php_Class
*/
public function getClasses()
public function getClasses()
{
return $this->_classes;
}
@ -343,7 +343,7 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
$this->_body = $body;
return $this;
}
/**
* getBody()
*
@ -353,7 +353,7 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
{
return $this->_body;
}
/**
* isSourceDirty()
*
@ -364,16 +364,16 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
if (($docblock = $this->getDocblock()) && $docblock->isSourceDirty()) {
return true;
}
foreach ($this->_classes as $class) {
if ($class->isSourceDirty()) {
return true;
}
}
return parent::isSourceDirty();
}
/**
* generate()
*
@ -384,21 +384,21 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
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 = '<?php' . self::LINE_FEED;
}
// 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('');
@ -409,10 +409,10 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
$output .= $docblock->generate() . self::LINE_FEED;
}
}
// newline
$output .= self::LINE_FEED;
// process required files
// @todo marker replacement for required files
$requiredFiles = $this->getRequiredFiles();
@ -420,10 +420,10 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
foreach ($requiredFiles as $requiredFile) {
$output .= 'require_once \'' . $requiredFile . '\';' . self::LINE_FEED;
}
$output .= self::LINE_FEED;
}
// process classes
$classes = $this->getClasses();
if (!empty($classes)) {
@ -436,22 +436,22 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
$output .= $class->generate() . self::LINE_FEED;
}
}
}
if (!empty($body)) {
// add an extra space betwee clsses and
// 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))) {
@ -461,5 +461,5 @@ class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
file_put_contents($this->_filename, $this->generate());
return $this;
}
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Abstract.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -38,7 +38,7 @@ require_once 'Zend/CodeGenerator/Php/Docblock.php';
*/
abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator_Php_Abstract
{
/**#@+
* @param const string
*/
@ -46,32 +46,32 @@ abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator
const VISIBILITY_PROTECTED = 'protected';
const VISIBILITY_PRIVATE = 'private';
/**#@-*/
/**
* @var Zend_CodeGenerator_Php_Docblock
*/
protected $_docblock = null;
/**
* @var bool
*/
protected $_isAbstract = false;
/**
* @var bool
*/
protected $_isFinal = false;
/**
* @var bool
*/
protected $_isStatic = false;
/**
* @var const
*/
protected $_visibility = self::VISIBILITY_PUBLIC;
/**
* @var string
*/
@ -83,23 +83,23 @@ abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator
* @param Zend_CodeGenerator_Php_Docblock|array|string $docblock
* @return Zend_CodeGenerator_Php_File
*/
public function setDocblock($docblock)
public function setDocblock($docblock)
{
if (is_string($docblock)) {
$docblock = array('shortDescription' => $docblock);
}
if (is_array($docblock)) {
$docblock = new Zend_CodeGenerator_Php_Docblock($docblock);
} elseif (!$docblock instanceof Zend_CodeGenerator_Php_Docblock) {
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('setDocblock() is expecting either a string, array or an instance of Zend_CodeGenerator_Php_Docblock');
}
$this->_docblock = $docblock;
return $this;
}
/**
* getDocblock()
*
@ -109,7 +109,7 @@ abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator
{
return $this->_docblock;
}
/**
* setAbstract()
*
@ -121,7 +121,7 @@ abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator
$this->_isAbstract = ($isAbstract) ? true : false;
return $this;
}
/**
* isAbstract()
*
@ -131,7 +131,7 @@ abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator
{
return $this->_isAbstract;
}
/**
* setFinal()
*
@ -143,7 +143,7 @@ abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator
$this->_isFinal = ($isFinal) ? true : false;
return $this;
}
/**
* isFinal()
*
@ -153,7 +153,7 @@ abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator
{
return $this->_isFinal;
}
/**
* setStatic()
*
@ -165,7 +165,7 @@ abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator
$this->_isStatic = ($isStatic) ? true : false;
return $this;
}
/**
* isStatic()
*
@ -175,7 +175,7 @@ abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator
{
return $this->_isStatic;
}
/**
* setVisitibility()
*
@ -187,7 +187,7 @@ abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator
$this->_visibility = $visibility;
return $this;
}
/**
* getVisibility()
*
@ -197,7 +197,7 @@ abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator
{
return $this->_visibility;
}
/**
* setName()
*
@ -209,7 +209,7 @@ abstract class Zend_CodeGenerator_Php_Member_Abstract extends Zend_CodeGenerator
$this->_name = $name;
return $this;
}
/**
* getName()
*

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Container.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Container.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -28,19 +28,19 @@
*/
class Zend_CodeGenerator_Php_Member_Container extends ArrayObject
{
/**#@+
* @param const string
*/
const TYPE_PROPERTY = 'property';
const TYPE_METHOD = 'method';
/**#@-*/
/**
* @var const|string
*/
protected $_type = self::TYPE_PROPERTY;
/**
* __construct()
*
@ -51,5 +51,5 @@ class Zend_CodeGenerator_Php_Member_Container extends ArrayObject
$this->_type = $type;
parent::__construct(array(), self::ARRAY_AS_PROPS);
}
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Method.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Method.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -41,28 +41,28 @@ require_once 'Zend/CodeGenerator/Php/Parameter.php';
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_CodeGenerator_Php_Method extends Zend_CodeGenerator_Php_Member_Abstract
class Zend_CodeGenerator_Php_Method extends Zend_CodeGenerator_Php_Member_Abstract
{
/**
* @var Zend_CodeGenerator_Php_Docblock
*/
protected $_docblock = null;
/**
* @var bool
*/
protected $_isFinal = false;
/**
* @var array
*/
protected $_parameters = array();
/**
* @var string
*/
protected $_body = null;
/**
* fromReflection()
*
@ -72,16 +72,16 @@ class Zend_CodeGenerator_Php_Method extends Zend_CodeGenerator_Php_Member_Abstra
public static function fromReflection(Zend_Reflection_Method $reflectionMethod)
{
$method = new self();
$method->setSourceContent($reflectionMethod->getContents(false));
$method->setSourceDirty(false);
if ($reflectionMethod->getDocComment() != '') {
$method->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionMethod->getDocblock()));
}
$method->setFinal($reflectionMethod->isFinal());
if ($reflectionMethod->isPrivate()) {
$method->setVisibility(self::VISIBILITY_PRIVATE);
} elseif ($reflectionMethod->isProtected()) {
@ -89,20 +89,20 @@ class Zend_CodeGenerator_Php_Method extends Zend_CodeGenerator_Php_Member_Abstra
} else {
$method->setVisibility(self::VISIBILITY_PUBLIC);
}
$method->setStatic($reflectionMethod->isStatic());
$method->setName($reflectionMethod->getName());
foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
$method->setParameter(Zend_CodeGenerator_Php_Parameter::fromReflection($reflectionParameter));
}
$method->setBody($reflectionMethod->getBody());
return $method;
}
/**
* setFinal()
*
@ -112,7 +112,7 @@ class Zend_CodeGenerator_Php_Method extends Zend_CodeGenerator_Php_Member_Abstra
{
$this->_isFinal = ($isFinal) ? true : false;
}
/**
* setParameters()
*
@ -126,7 +126,7 @@ class Zend_CodeGenerator_Php_Method extends Zend_CodeGenerator_Php_Member_Abstra
}
return $this;
}
/**
* setParameter()
*
@ -144,11 +144,11 @@ class Zend_CodeGenerator_Php_Method extends Zend_CodeGenerator_Php_Member_Abstra
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('setParameter() expects either an array of method options or an instance of Zend_CodeGenerator_Php_Parameter');
}
$this->_parameters[$parameterName] = $parameter;
return $this;
}
/**
* getParameters()
*
@ -170,7 +170,7 @@ class Zend_CodeGenerator_Php_Method extends Zend_CodeGenerator_Php_Member_Abstra
$this->_body = $body;
return $this;
}
/**
* getBody()
*
@ -180,7 +180,7 @@ class Zend_CodeGenerator_Php_Method extends Zend_CodeGenerator_Php_Member_Abstra
{
return $this->_body;
}
/**
* generate()
*
@ -189,22 +189,22 @@ class Zend_CodeGenerator_Php_Method extends Zend_CodeGenerator_Php_Member_Abstra
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() . '(';
@ -214,21 +214,21 @@ class Zend_CodeGenerator_Php_Method extends Zend_CodeGenerator_Php_Member_Abstra
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))
$output .= ' '
. str_replace(self::LINE_FEED, self::LINE_FEED . $indent . $indent, trim($this->_body))
. self::LINE_FEED;
}
$output .= $indent . '}' . self::LINE_FEED;
return $output;
}
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Parameter.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Parameter.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -25,6 +25,11 @@
*/
require_once 'Zend/CodeGenerator/Php/Abstract.php';
/**
* @see Zend_CodeGenerator_Php_ParameterDefaultValue
*/
require_once 'Zend/CodeGenerator/Php/Parameter/DefaultValue.php';
/**
* @category Zend
* @package Zend_CodeGenerator
@ -37,22 +42,27 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
* @var string
*/
protected $_type = null;
/**
* @var string
*/
protected $_name = null;
/**
* @var string
*/
protected $_defaultValue = null;
/**
* @var int
*/
protected $_position = null;
/**
* @var bool
*/
protected $_passedByReference = false;
/**
* fromReflection()
*
@ -61,10 +71,28 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
*/
public static function fromReflection(Zend_Reflection_Parameter $reflectionParameter)
{
// @todo Research this
return new self();
$param = new Zend_CodeGenerator_Php_Parameter();
$param->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()
*
@ -76,7 +104,7 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
$this->_type = $type;
return $this;
}
/**
* getType()
*
@ -86,7 +114,7 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
{
return $this->_type;
}
/**
* setName()
*
@ -98,7 +126,7 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
$this->_name = $name;
return $this;
}
/**
* getName()
*
@ -108,19 +136,34 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
{
return $this->_name;
}
/**
* setDefaultValue()
* Set the default value of the parameter.
*
* @param string $defaultValue
* Certain variables are difficult to expres
*
* @param null|bool|string|int|float|Zend_CodeGenerator_Php_Parameter_DefaultValue $defaultValue
* @return Zend_CodeGenerator_Php_Parameter
*/
public function setDefaultValue($defaultValue)
{
$this->_defaultValue = $defaultValue;
if($defaultValue === null) {
$this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue("null");
} else if(is_array($defaultValue)) {
$defaultValue = str_replace(array("\r", "\n"), "", var_export($defaultValue, true));
$this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue($defaultValue);
} else if(is_bool($defaultValue)) {
if($defaultValue == true) {
$this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue("true");
} else {
$this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue("false");
}
} else {
$this->_defaultValue = $defaultValue;
}
return $this;
}
/**
* getDefaultValue()
*
@ -130,7 +173,7 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
{
return $this->_defaultValue;
}
/**
* setPosition()
*
@ -142,7 +185,7 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
$this->_position = $position;
return $this;
}
/**
* getPosition()
*
@ -152,7 +195,25 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
{
return $this->_position;
}
/**
* @return bool
*/
public function getPassedByReference()
{
return $this->_passedByReference;
}
/**
* @param bool $passedByReference
* @return Zend_CodeGenerator_Php_Parameter
*/
public function setPassedByReference($passedByReference)
{
$this->_passedByReference = $passedByReference;
return $this;
}
/**
* generate()
*
@ -161,17 +222,23 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
public function generate()
{
$output = '';
if ($this->_type) {
$output .= $this->_type . ' ';
$output .= $this->_type . ' ';
}
if($this->_passedByReference === true) {
$output .= '&';
}
$output .= '$' . $this->_name;
if ($this->_defaultValue) {
if ($this->_defaultValue !== null) {
$output .= ' = ';
if (is_string($this->_defaultValue)) {
$output .= '\'' . $this->_defaultValue . '\'';
} else if($this->_defaultValue instanceof Zend_CodeGenerator_Php_ParameterDefaultValue) {
$output .= (string)$this->_defaultValue;
} else {
$output .= $this->_defaultValue;
}
@ -179,5 +246,5 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
return $output;
}
}

View File

@ -0,0 +1,60 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_CodeGenerator
* @subpackage Php
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DefaultValue.php 18010 2009-09-07 21:58:40Z beberlei $
*/
/**
* A value-holder object for non-expressable parameter default values, such as null, booleans and empty array()
*
* @category Zend
* @package Zend_CodeGenerator
* @subpackage Php
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_CodeGenerator_Php_Parameter_DefaultValue
{
/**
* @var string
*/
protected $_defaultValue = null;
/**
*
* @param string $defaultValue
* @throws Zend_CodeGenerator_Php_Exception
*/
public function __construct($defaultValue)
{
if(!is_string($defaultValue)) {
require_once "Zend/CodeGenerator/Php/Exception.php";
throw new Zend_CodeGenerator_Php_Exception(
"Can only set a string as default value representation, ".
"but ".gettype($defaultValue)." was given."
);
}
$this->_defaultValue = $defaultValue;
}
public function __toString()
{
return $this->_defaultValue;
}
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Property.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Property.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -36,14 +36,14 @@ require_once 'Zend/CodeGenerator/Php/Property/DefaultValue.php';
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_CodeGenerator_Php_Property extends Zend_CodeGenerator_Php_Member_Abstract
class Zend_CodeGenerator_Php_Property extends Zend_CodeGenerator_Php_Member_Abstract
{
/**
* @var bool
*/
protected $_isConst = null;
/**
* @var string
*/
@ -58,21 +58,21 @@ class Zend_CodeGenerator_Php_Property extends Zend_CodeGenerator_Php_Member_Abst
public static function fromReflection(Zend_Reflection_Property $reflectionProperty)
{
$property = new self();
$property->setName($reflectionProperty->getName());
$allDefaultProperties = $reflectionProperty->getDeclaringClass()->getDefaultProperties();
$property->setDefaultValue($allDefaultProperties[$reflectionProperty->getName()]);
if ($reflectionProperty->getDocComment() != '') {
$property->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionProperty->getDocComment()));
}
if ($reflectionProperty->isStatic()) {
$property->setStatic(true);
}
if ($reflectionProperty->isPrivate()) {
$property->setVisibility(self::VISIBILITY_PRIVATE);
} elseif ($reflectionProperty->isProtected()) {
@ -80,12 +80,12 @@ class Zend_CodeGenerator_Php_Property extends Zend_CodeGenerator_Php_Member_Abst
} else {
$property->setVisibility(self::VISIBILITY_PUBLIC);
}
$property->setSourceDirty(false);
return $property;
}
/**
* setConst()
*
@ -97,7 +97,7 @@ class Zend_CodeGenerator_Php_Property extends Zend_CodeGenerator_Php_Member_Abst
$this->_isConst = $const;
return $this;
}
/**
* isConst()
*
@ -117,16 +117,16 @@ class Zend_CodeGenerator_Php_Property extends Zend_CodeGenerator_Php_Member_Abst
public function setDefaultValue($defaultValue)
{
// if it looks like
if (is_array($defaultValue)
if (is_array($defaultValue)
&& array_key_exists('value', $defaultValue)
&& array_key_exists('type', $defaultValue)) {
$defaultValue = new Zend_CodeGenerator_Php_Property_DefaultValue($defaultValue);
}
if (!($defaultValue instanceof Zend_CodeGenerator_Php_Property_DefaultValue)) {
$defaultValue = new Zend_CodeGenerator_Php_Property_DefaultValue(array('value' => $defaultValue));
}
$this->_defaultValue = $defaultValue;
return $this;
}
@ -140,7 +140,7 @@ class Zend_CodeGenerator_Php_Property extends Zend_CodeGenerator_Php_Member_Abst
{
return $this->_defaultValue;
}
/**
* generate()
*
@ -150,30 +150,30 @@ class Zend_CodeGenerator_Php_Property extends Zend_CodeGenerator_Php_Member_Abst
{
$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()) {
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('The property ' . $this->_name . ' is said to be '
. 'constant but does not have a valid constant value.');
}
$output .= $this->_indentation . 'const ' . $name . ' = '
$output .= $this->_indentation . 'const ' . $name . ' = '
. (($defaultValue !== null) ? $defaultValue->generate() : 'null;');
} else {
$output .= $this->_indentation
. $this->getVisibility()
. (($this->isStatic()) ? ' static' : '')
. $this->getVisibility()
. (($this->isStatic()) ? ' static' : '')
. ' $' . $name . ' = '
. (($defaultValue !== null) ? $defaultValue->generate() : 'null;');
}
return $output;
return $output;
}
}

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DefaultValue.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: DefaultValue.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -50,22 +50,22 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
const TYPE_NULL = 'null';
const TYPE_OTHER = 'other';
/**#@-*/
/**
* @var array of reflected constants
*/
protected static $_constants = array();
/**
* @var mixed
*/
protected $_value = null;
/**
* @var string
*/
protected $_type = self::TYPE_AUTO;
/**
* @var int
*/
@ -78,11 +78,13 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
*/
protected function _init()
{
$reflect = new ReflectionClass(get_class($this));
self::$_constants = $reflect->getConstants();
unset($reflect);
if(count(self::$_constants) == 0) {
$reflect = new ReflectionClass(get_class($this));
self::$_constants = $reflect->getConstants();
unset($reflect);
}
}
/**
* isValidConstantType()
*
@ -93,7 +95,7 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
if ($this->_type == self::TYPE_AUTO) {
$type = $this->_getAutoDeterminedType($this->_value);
}
// valid types for constants
$scalarTypes = array(
self::TYPE_BOOLEAN,
@ -107,10 +109,10 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
self::TYPE_CONSTANT,
self::TYPE_NULL
);
return in_array($type, $scalarTypes);
}
/**
* setValue()
*
@ -122,7 +124,7 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
$this->_value = $value;
return $this;
}
/**
* getValue()
*
@ -132,7 +134,7 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
{
return $this->_value;
}
/**
* setType()
*
@ -144,7 +146,7 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
$this->_type = $type;
return $this;
}
/**
* getType()
*
@ -154,7 +156,7 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
{
return $this->_type;
}
/**
* setArrayDepth()
*
@ -166,7 +168,7 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
$this->_arrayDepth = $arrayDepth;
return $this;
}
/**
* getArrayDepth()
*
@ -176,7 +178,7 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
{
return $this->_arrayDepth;
}
/**
* _getValidatedType()
*
@ -188,10 +190,10 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
if (($constName = array_search($type, self::$_constants)) !== false) {
return $type;
}
return self::TYPE_AUTO;
}
/**
* _getAutoDeterminedType()
*
@ -221,10 +223,8 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
default:
return self::TYPE_OTHER;
}
return self::TYPE_OTHER;
}
/**
* generate()
*
@ -233,16 +233,16 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
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),
@ -257,21 +257,27 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
}
$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 .= "'" . $value . "'";
$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_NULL:
case self::TYPE_CONSTANT:
$output .= $value;
break;
@ -292,9 +298,9 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
$outputParts[] = $partV;
$noKeyIndex++;
} else {
$outputParts[] = (is_int($n) ? $n : "'" . $n . "'") . ' => ' . $partV;
$outputParts[] = (is_int($n) ? $n : "'" . addcslashes($n, "'") . "'") . ' => ' . $partV;
}
}
$output .= implode(',' . PHP_EOL . str_repeat($this->_indentation, $this->_arrayDepth+1), $outputParts);
if ($curArrayMultiblock == true) {
@ -304,11 +310,14 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
break;
case self::TYPE_OTHER:
default:
throw new Exception('I dont know this type');
require_once "Zend/CodeGenerator/Php/Exception.php";
throw new Zend_CodeGenerator_Php_Exception(
"Type '".get_class($value)."' is unknown or cannot be used as property default value."
);
}
$output .= ';';
return $output;
}
}

View File

@ -16,7 +16,7 @@
* @package Zend_Config
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Config.php 16201 2009-06-21 18:51:15Z thomas $
* @version $Id: Config.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -83,7 +83,7 @@ class Zend_Config implements Countable, Iterator
/**
* Load file error string.
*
*
* Is null if there was no error while file loading
*
* @var string
@ -169,11 +169,11 @@ class Zend_Config implements Countable, Iterator
throw new Zend_Config_Exception('Zend_Config is read only');
}
}
/**
* Deep clone of this instance to ensure that nested Zend_Configs
* are also cloned.
*
*
* @return void
*/
public function __clone()
@ -374,7 +374,7 @@ class Zend_Config implements Countable, Iterator
}
}
}
/**
* Returns if this Zend_Config object is read only or not.
*
@ -384,7 +384,7 @@ class Zend_Config implements Countable, Iterator
{
return !$this->_allowModifications;
}
/**
* Get the current extends
*
@ -394,7 +394,7 @@ class Zend_Config implements Countable, Iterator
{
return $this->_extends;
}
/**
* Set an extend for Zend_Config_Writer
*
@ -410,7 +410,7 @@ class Zend_Config implements Countable, Iterator
$this->_extends[$extendingSection] = $extendedSection;
}
}
/**
* Throws an exception if $extendingSection may not extend $extendedSection,
* and tracks the section extension if it is valid.
@ -445,7 +445,7 @@ class Zend_Config implements Countable, Iterator
* @param integer $errline
*/
protected function _loadFileErrorHandler($errno, $errstr, $errfile, $errline)
{
{
if ($this->_loadFileErrorStr === null) {
$this->_loadFileErrorStr = $errstr;
} else {

View File

@ -16,7 +16,7 @@
* @package Zend_Config
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Ini.php 16201 2009-06-21 18:51:15Z thomas $
* @version $Id: Ini.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -54,7 +54,7 @@ class Zend_Config_Ini extends Zend_Config
* @var boolean
*/
protected $_skipExtends = false;
/**
* Loads the section $section from the config file $filename for
* access facilitated by nested object properties.
@ -153,7 +153,7 @@ class Zend_Config_Ini extends Zend_Config
}
parent::__construct($dataArray, $allowModifications);
}
}
$this->_loadedSection = $section;
}
@ -210,7 +210,7 @@ class Zend_Config_Ini extends Zend_Config
return $iniArray;
}
/**
* Process each element in the section and handle the ";extends" inheritance
* key. Passes control to _processKey() to handle the nest separator
@ -230,7 +230,7 @@ class Zend_Config_Ini extends Zend_Config
if (strtolower($key) == ';extends') {
if (isset($iniArray[$value])) {
$this->_assertValidExtend($section, $value);
if (!$this->_skipExtends) {
$config = $this->_processSection($iniArray, $value, $config);
}

View File

@ -16,7 +16,7 @@
* @package Zend_Config
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Writer.php 16201 2009-06-21 18:51:15Z thomas $
* @version $Id: Writer.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -29,13 +29,13 @@ abstract class Zend_Config_Writer
{
/**
* Option keys to skip when calling setOptions()
*
*
* @var array
*/
protected $_skipOptions = array(
'options'
);
/**
* Config object to write
*
@ -45,8 +45,8 @@ abstract class Zend_Config_Writer
/**
* Create a new adapter
*
* $options can only be passed as array or be omitted
*
* $options can only be passed as array or be omitted
*
* @param null|array $options
*/
@ -56,7 +56,7 @@ abstract class Zend_Config_Writer
$this->setOptions($options);
}
}
/**
* Set options via a Zend_Config instance
*
@ -66,10 +66,10 @@ abstract class Zend_Config_Writer
public function setConfig(Zend_Config $config)
{
$this->_config = $config;
return $this;
}
/**
* Set options via an array
*
@ -88,10 +88,10 @@ abstract class Zend_Config_Writer
$this->$method($value);
}
}
return $this;
}
/**
* Write a Zend_Config object to it's target
*

View File

@ -16,7 +16,7 @@
* @package Zend_Config
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Array.php 16201 2009-06-21 18:51:15Z thomas $
* @version $Id: Array.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -38,14 +38,14 @@ class Zend_Config_Writer_Array extends Zend_Config_Writer
* @var string
*/
protected $_filename = null;
/**
* Wether to exclusively lock the file or not
*
* @var boolean
*/
protected $_exclusiveLock = false;
/**
* Set the target filename
*
@ -55,10 +55,10 @@ class Zend_Config_Writer_Array extends Zend_Config_Writer
public function setFilename($filename)
{
$this->_filename = $filename;
return $this;
}
/**
* Set wether to exclusively lock the file or not
*
@ -68,10 +68,10 @@ class Zend_Config_Writer_Array extends Zend_Config_Writer
public function setExclusiveLock($exclusiveLock)
{
$this->_exclusiveLock = $exclusiveLock;
return $this;
}
/**
* Defined by Zend_Config_Writer
*
@ -87,43 +87,43 @@ class Zend_Config_Writer_Array extends Zend_Config_Writer
if ($filename !== null) {
$this->setFilename($filename);
}
if ($config !== null) {
$this->setConfig($config);
}
if ($exclusiveLock !== null) {
$this->setExclusiveLock($exclusiveLock);
}
if ($this->_filename === null) {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('No filename was set');
}
if ($this->_config === null) {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('No config was set');
}
$data = $this->_config->toArray();
$sectionName = $this->_config->getSectionName();
if (is_string($sectionName)) {
$data = array($sectionName => $data);
}
$arrayString = "<?php\n"
. "return " . var_export($data, true) . ";\n";
$flags = 0;
if ($this->_exclusiveLock) {
$flags |= LOCK_EX;
}
$result = @file_put_contents($this->_filename, $arrayString, $flags);
if ($result === false) {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"');

View File

@ -16,7 +16,7 @@
* @package Zend_Config
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Ini.php 16201 2009-06-21 18:51:15Z thomas $
* @version $Id: Ini.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -38,21 +38,21 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
* @var string
*/
protected $_filename = null;
/**
* Wether to exclusively lock the file or not
*
* @var boolean
*/
protected $_exclusiveLock = false;
/**
* String that separates nesting levels of configuration data identifiers
*
* @var string
*/
protected $_nestSeparator = '.';
/**
* Set the target filename
*
@ -62,10 +62,10 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
public function setFilename($filename)
{
$this->_filename = $filename;
return $this;
}
/**
* Set wether to exclusively lock the file or not
*
@ -75,10 +75,10 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
public function setExclusiveLock($exclusiveLock)
{
$this->_exclusiveLock = $exclusiveLock;
return $this;
}
/**
* Set the nest separator
*
@ -88,10 +88,10 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
public function setNestSeparator($separator)
{
$this->_nestSeparator = $separator;
return $this;
}
/**
* Defined by Zend_Config_Writer
*
@ -107,29 +107,29 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
if ($filename !== null) {
$this->setFilename($filename);
}
if ($config !== null) {
$this->setConfig($config);
}
if ($exclusiveLock !== null) {
$this->setExclusiveLock($exclusiveLock);
}
if ($this->_filename === null) {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('No filename was set');
}
if ($this->_config === null) {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('No config was set');
}
$iniString = '';
$extends = $this->_config->getExtends();
$sectionName = $this->_config->getSectionName();
if (is_string($sectionName)) {
$iniString .= '[' . $sectionName . ']' . "\n"
. $this->_addBranch($this->_config)
@ -145,20 +145,20 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
if (isset($extends[$sectionName])) {
$sectionName .= ' : ' . $extends[$sectionName];
}
$iniString .= '[' . $sectionName . ']' . "\n"
. $this->_addBranch($data)
. "\n";
}
}
}
$flags = 0;
if ($this->_exclusiveLock) {
$flags |= LOCK_EX;
}
$result = @file_put_contents($this->_filename, $iniString, $flags);
if ($result === false) {
@ -166,7 +166,7 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"');
}
}
/**
* Add a branch to an INI string recursively
*
@ -179,7 +179,7 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
foreach ($config as $key => $value) {
$group = array_merge($parents, array($key));
if ($value instanceof Zend_Config) {
$iniString .= $this->_addBranch($value, $group);
} else {
@ -189,10 +189,10 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer
. "\n";
}
}
return $iniString;
}
/**
* Prepare a value for INI
*

View File

@ -16,7 +16,7 @@
* @package Zend_Config
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Xml.php 16924 2009-07-21 16:34:04Z dasprid $
* @version $Id: Xml.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -43,14 +43,14 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
* @var string
*/
protected $_filename = null;
/**
* Wether to exclusively lock the file or not
*
* @var boolean
*/
protected $_exclusiveLock = false;
/**
* Set the target filename
*
@ -60,10 +60,10 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
public function setFilename($filename)
{
$this->_filename = $filename;
return $this;
}
/**
* Set wether to exclusively lock the file or not
*
@ -73,10 +73,10 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
public function setExclusiveLock($exclusiveLock)
{
$this->_exclusiveLock = $exclusiveLock;
return $this;
}
/**
* Defined by Zend_Config_Writer
*
@ -92,29 +92,29 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
if ($filename !== null) {
$this->setFilename($filename);
}
if ($config !== null) {
$this->setConfig($config);
}
if ($exclusiveLock !== null) {
$this->setExclusiveLock($exclusiveLock);
}
if ($this->_filename === null) {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('No filename was set');
}
if ($this->_config === null) {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('No config was set');
}
$xml = new SimpleXMLElement('<zend-config xmlns:zf="' . Zend_Config_Xml::XML_NAMESPACE . '"/>');
$extends = $this->_config->getExtends();
$sectionName = $this->_config->getSectionName();
if (is_string($sectionName)) {
$child = $xml->addChild($sectionName);
@ -125,35 +125,35 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
$xml->addChild($sectionName, (string) $data);
} else {
$child = $xml->addChild($sectionName);
if (isset($extends[$sectionName])) {
$child->addAttribute('zf:extends', $extends[$sectionName], Zend_Config_Xml::XML_NAMESPACE);
}
$this->_addBranch($data, $child, $xml);
}
}
}
$dom = dom_import_simplexml($xml)->ownerDocument;
$dom->formatOutput = true;
$xmlString = $dom->saveXML();
$flags = 0;
if ($this->_exclusiveLock) {
$flags |= LOCK_EX;
}
$result = @file_put_contents($this->_filename, $xmlString, $flags);
if ($result === false) {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"');
}
}
/**
* Add a branch to an XML object recursively
*
@ -165,35 +165,35 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, SimpleXMLElement $parent)
{
$branchType = null;
foreach ($config as $key => $value) {
if ($branchType === null) {
if (is_numeric($key)) {
$branchType = 'numeric';
$branchName = $xml->getName();
$xml = $parent;
unset($parent->{$branchName});
} else {
$branchType = 'string';
}
} else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
}
if ($branchType === 'numeric') {
if ($value instanceof Zend_Config) {
$child = $parent->addChild($branchName, (string) $value);
$this->_addBranch($value, $child, $parent);
} else {
$parent->addChild($branchName, (string) $value);
}
} else {
} else {
if ($value instanceof Zend_Config) {
$child = $xml->addChild($key);
$this->_addBranch($value, $child, $xml);
} else {
$xml->addChild($key, (string) $value);

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Controller_Action_Helper
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ActionStack.php 16202 2009-06-21 18:53:49Z thomas $
* @version $Id: ActionStack.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -46,7 +46,7 @@ class Zend_Controller_Action_Helper_ActionStack extends Zend_Controller_Action_H
* Constructor
*
* Register action stack plugin
*
*
* @return void
*/
public function __construct()
@ -65,9 +65,9 @@ class Zend_Controller_Action_Helper_ActionStack extends Zend_Controller_Action_H
}
/**
* Push onto the stack
*
* @param Zend_Controller_Request_Abstract $next
* Push onto the stack
*
* @param Zend_Controller_Request_Abstract $next
* @return Zend_Controller_Action_Helper_ActionStack Provides a fluent interface
*/
public function pushStack(Zend_Controller_Request_Abstract $next)
@ -78,12 +78,12 @@ class Zend_Controller_Action_Helper_ActionStack extends Zend_Controller_Action_H
/**
* Push a new action onto the stack
*
* @param string $action
* @param string $controller
* @param string $module
*
* @param string $action
* @param string $controller
* @param string $module
* @param array $params
* @throws Zend_Controller_Action_Exception
* @throws Zend_Controller_Action_Exception
* @return Zend_Controller_Action_Helper_ActionStack
*/
public function actionToStack($action, $controller = null, $module = null, array $params = array())
@ -107,7 +107,7 @@ class Zend_Controller_Action_Helper_ActionStack extends Zend_Controller_Action_H
require_once 'Zend/Controller/Action/Exception.php';
throw new Zend_Controller_Action_Exception('Request object not set yet');
}
$controller = (null === $controller) ? $request->getControllerName() : $controller;
$module = (null === $module) ? $request->getModuleName() : $module;

View File

@ -17,7 +17,7 @@
* @subpackage Zend_Controller_Action_Helper
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: AjaxContext.php 16202 2009-06-21 18:53:49Z thomas $
* @version $Id: AjaxContext.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -47,7 +47,7 @@ class Zend_Controller_Action_Helper_AjaxContext extends Zend_Controller_Action_H
* Constructor
*
* Add HTML context
*
*
* @return void
*/
public function __construct()
@ -60,8 +60,8 @@ class Zend_Controller_Action_Helper_AjaxContext extends Zend_Controller_Action_H
* Initialize AJAX context switching
*
* Checks for XHR requests; if detected, attempts to perform context switch.
*
* @param string $format
*
* @param string $format
* @return void
*/
public function initContext($format = null)

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