vendor: Upgrade Zend to version 1.12.15

refs #10044
This commit is contained in:
Eric Lippmann 2015-09-01 22:53:57 +02:00
parent 4adaf5a2d0
commit 935691233b
1531 changed files with 73757 additions and 20557 deletions

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -48,7 +48,7 @@
/**
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Acl

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -38,7 +38,7 @@
/**
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Acl_Assert_Interface

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -28,7 +28,7 @@
/**
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Acl_Exception extends Zend_Exception

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -28,7 +28,7 @@
/**
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Acl_Resource implements Zend_Acl_Resource_Interface

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -23,7 +23,7 @@
/**
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Acl_Resource_Interface

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -28,7 +28,7 @@
/**
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Acl_Role implements Zend_Acl_Role_Interface

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -23,7 +23,7 @@
/**
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Acl_Role_Interface

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -28,7 +28,7 @@
/**
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Acl_Role_Registry

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -28,7 +28,7 @@
/**
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Acl_Role_Registry_Exception extends Zend_Acl_Exception

View File

@ -1,131 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** @see Zend_Amf_Auth_Abstract */
/** @see Zend_Acl */
/** @see Zend_Auth_Result */
/** @see Zend_Xml_Security */
/**
* This class implements authentication against XML file with roles for Flex Builder.
*
* @package Zend_Amf
* @subpackage Adobe
* @copyright Copyright (c) 2005-2014 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 = Zend_Xml_Security::scanFile($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
*/
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);
}
}

View File

@ -1,103 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* This class implements authentication against XML file with roles for Flex Builder.
*
* @package Zend_Amf
* @subpackage Adobe
* @copyright Copyright (c) 2005-2014 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();
}
}

View File

@ -1,314 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** @see Zend_Amf_Parse_TypeLoader */
/** @see Zend_Reflection_Class */
/** @see Zend_Server_Reflection */
/**
* This class implements a service for generating AMF service descriptions as XML.
*
* @package Zend_Amf
* @subpackage Adobe
* @copyright Copyright (c) 2005-2014 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)) {
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);
if($param->isDefaultValueAvailable()) {
$arg->setAttribute('defaultvalue', $param->getDefaultValue());
}
$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';
}
// Arrays
if ('array' == $typename) {
return 'Unknown[]';
}
if (in_array($typename, array('int', 'integer', 'bool', 'boolean', 'float', 'string', 'object', 'Unknown', 'stdClass'))) {
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';
}
}

View File

@ -1,87 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* The following constants are used throughout serialization and
* deserialization to detect the AMF marker and encoding types.
*
* @package Zend_Amf
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
final class Zend_Amf_Constants
{
const AMF0_NUMBER = 0x00;
const AMF0_BOOLEAN = 0x01;
const AMF0_STRING = 0x02;
const AMF0_OBJECT = 0x03;
const AMF0_MOVIECLIP = 0x04;
const AMF0_NULL = 0x05;
const AMF0_UNDEFINED = 0x06;
const AMF0_REFERENCE = 0x07;
const AMF0_MIXEDARRAY = 0x08;
const AMF0_OBJECTTERM = 0x09;
const AMF0_ARRAY = 0x0a;
const AMF0_DATE = 0x0b;
const AMF0_LONGSTRING = 0x0c;
const AMF0_UNSUPPORTED = 0x0e;
const AMF0_XML = 0x0f;
const AMF0_TYPEDOBJECT = 0x10;
const AMF0_AMF3 = 0x11;
const AMF0_OBJECT_ENCODING = 0x00;
const AMF3_UNDEFINED = 0x00;
const AMF3_NULL = 0x01;
const AMF3_BOOLEAN_FALSE = 0x02;
const AMF3_BOOLEAN_TRUE = 0x03;
const AMF3_INTEGER = 0x04;
const AMF3_NUMBER = 0x05;
const AMF3_STRING = 0x06;
const AMF3_XML = 0x07;
const AMF3_DATE = 0x08;
const AMF3_ARRAY = 0x09;
const AMF3_OBJECT = 0x0A;
const AMF3_XMLSTRING = 0x0B;
const AMF3_BYTEARRAY = 0x0C;
const AMF3_OBJECT_ENCODING = 0x03;
// Object encodings for AMF3 object types
const ET_PROPLIST = 0x00;
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
* per AMF Specification
*/
const UNKNOWN_CONTENT_LENGTH = -1;
const URL_APPEND_HEADER = 'AppendToGatewayUrl';
const RESULT_METHOD = '/onResult';
const STATUS_METHOD = '/onStatus';
const CREDENTIALS_HEADER = 'Credentials';
const PERSISTENT_HEADER = 'RequestPersistentHeader';
const DESCRIBE_HEADER = 'DescribeService';
const GUEST_ROLE = 'anonymous';
}

View File

@ -1,301 +0,0 @@
<?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_Amf0
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** Zend_Amf_Constants */
/** Zend_Xml_Security */
/** @see Zend_Amf_Parse_Deserializer */
/**
* Read an AMF0 input stream and convert it into PHP data types
*
* @todo Implement Typed Object Class Mapping
* @todo Class could be implemented as Factory Class with each data type it's own class
* @package Zend_Amf
* @subpackage Parse_Amf0
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Parse_Amf0_Deserializer extends Zend_Amf_Parse_Deserializer
{
/**
* An array of objects used for recursively deserializing an object.
* @var array
*/
protected $_reference = array();
/**
* If AMF3 serialization occurs, update to AMF0 0x03
*
* @var int
*/
protected $_objectEncoding = Zend_Amf_Constants::AMF0_OBJECT_ENCODING;
/**
* Read AMF markers and dispatch for deserialization
*
* Checks for AMF marker types and calls the appropriate methods
* for deserializing those marker types. Markers are the data type of
* the following value.
*
* @param integer $typeMarker
* @return mixed whatever the data type is of the marker in php
* @throws Zend_Amf_Exception for invalid type
*/
public function readTypeMarker($typeMarker = null)
{
if ($typeMarker === null) {
$typeMarker = $this->_stream->readByte();
}
switch($typeMarker) {
// number
case Zend_Amf_Constants::AMF0_NUMBER:
return $this->_stream->readDouble();
// boolean
case Zend_Amf_Constants::AMF0_BOOLEAN:
return (boolean) $this->_stream->readByte();
// string
case Zend_Amf_Constants::AMF0_STRING:
return $this->_stream->readUTF();
// object
case Zend_Amf_Constants::AMF0_OBJECT:
return $this->readObject();
// null
case Zend_Amf_Constants::AMF0_NULL:
return null;
// undefined
case Zend_Amf_Constants::AMF0_UNDEFINED:
return null;
// Circular references are returned here
case Zend_Amf_Constants::AMF0_REFERENCE:
return $this->readReference();
// mixed array with numeric and string keys
case Zend_Amf_Constants::AMF0_MIXEDARRAY:
return $this->readMixedArray();
// array
case Zend_Amf_Constants::AMF0_ARRAY:
return $this->readArray();
// date
case Zend_Amf_Constants::AMF0_DATE:
return $this->readDate();
// longString strlen(string) > 2^16
case Zend_Amf_Constants::AMF0_LONGSTRING:
return $this->_stream->readLongUTF();
//internal AS object, not supported
case Zend_Amf_Constants::AMF0_UNSUPPORTED:
return null;
// XML
case Zend_Amf_Constants::AMF0_XML:
return $this->readXmlString();
// typed object ie Custom Class
case Zend_Amf_Constants::AMF0_TYPEDOBJECT:
return $this->readTypedObject();
//AMF3-specific
case Zend_Amf_Constants::AMF0_AMF3:
return $this->readAmf3TypeMarker();
default:
throw new Zend_Amf_Exception('Unsupported marker type: ' . $typeMarker);
}
}
/**
* Read AMF objects and convert to PHP objects
*
* Read the name value pair objects form the php message and convert them to
* a php object class.
*
* Called when the marker type is 3.
*
* @param array|null $object
* @return object
*/
public function readObject($object = null)
{
if ($object === null) {
$object = array();
}
while (true) {
$key = $this->_stream->readUTF();
$typeMarker = $this->_stream->readByte();
if ($typeMarker != Zend_Amf_Constants::AMF0_OBJECTTERM ){
//Recursivly call readTypeMarker to get the types of properties in the object
$object[$key] = $this->readTypeMarker($typeMarker);
} else {
//encountered AMF object terminator
break;
}
}
$this->_reference[] = $object;
return (object) $object;
}
/**
* Read reference objects
*
* Used to gain access to the private array of reference objects.
* Called when marker type is 7.
*
* @return object
* @throws Zend_Amf_Exception for invalid reference keys
*/
public function readReference()
{
$key = $this->_stream->readInt();
if (!array_key_exists($key, $this->_reference)) {
throw new Zend_Amf_Exception('Invalid reference key: '. $key);
}
return $this->_reference[$key];
}
/**
* Reads an array with numeric and string indexes.
*
* Called when marker type is 8
*
* @todo As of Flash Player 9 there is not support for mixed typed arrays
* so we handle this as an object. With the introduction of vectors
* in Flash Player 10 this may need to be reconsidered.
* @return array
*/
public function readMixedArray()
{
$length = $this->_stream->readLong();
return $this->readObject();
}
/**
* Converts numerically indexed actiosncript arrays into php arrays.
*
* Called when marker type is 10
*
* @return array
*/
public function readArray()
{
$length = $this->_stream->readLong();
$array = array();
while ($length--) {
$array[] = $this->readTypeMarker();
}
return $array;
}
/**
* Convert AS Date to Zend_Date
*
* @return Zend_Date
*/
public function readDate()
{
// get the unix time stamp. Not sure why ActionScript does not use
// milliseconds
$timestamp = floor($this->_stream->readDouble() / 1000);
// The timezone offset is never returned to the server; it is always 0,
// so read and ignore.
$offset = $this->_stream->readInt();
$date = new Zend_Date($timestamp);
return $date;
}
/**
* Convert XML to SimpleXml
* If user wants DomDocument they can use dom_import_simplexml
*
* @return SimpleXml Object
*/
public function readXmlString()
{
$string = $this->_stream->readLongUTF();
return Zend_Xml_Security::scan($string); //simplexml_load_string($string);
}
/**
* Read Class that is to be mapped to a server class.
*
* Commonly used for Value Objects on the server
*
* @todo implement Typed Class mapping
* @return object|array
* @throws Zend_Amf_Exception if unable to load type
*/
public function readTypedObject()
{
// get the remote class name
$className = $this->_stream->readUTF();
$loader = Zend_Amf_Parse_TypeLoader::loadType($className);
$returnObject = new $loader();
$properties = get_object_vars($this->readObject());
foreach($properties as $key=>$value) {
if($key) {
$returnObject->$key = $value;
}
}
if($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
$returnObject = get_object_vars($returnObject);
}
return $returnObject;
}
/**
* AMF3 data type encountered load AMF3 Deserializer to handle
* type markers.
*
* @return string
*/
public function readAmf3TypeMarker()
{
$deserializer = new Zend_Amf_Parse_Amf3_Deserializer($this->_stream);
$this->_objectEncoding = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
return $deserializer->readTypeMarker();
}
/**
* Return the object encoding to check if an AMF3 object
* is going to be return.
*
* @return int
*/
public function getObjectEncoding()
{
return $this->_objectEncoding;
}
}

View File

@ -1,355 +0,0 @@
<?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_Amf0
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** Zend_Amf_Constants */
/** @see Zend_Amf_Parse_Serializer */
/**
* Serializer PHP misc types back to there corresponding AMF0 Type Marker.
*
* @uses Zend_Amf_Parse_Serializer
* @package Zend_Amf
* @subpackage Parse_Amf0
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
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
*/
protected $_referenceObjects = array();
/**
* Determine type and serialize accordingly
*
* Checks to see if the type was declared and then either
* auto negotiates the type or relies on the user defined markerType to
* serialize the data into amf
*
* @param mixed $data
* @param mixed $markerType
* @param mixed $dataByVal
* @return Zend_Amf_Parse_Amf0_Serializer
* @throws Zend_Amf_Exception for unrecognized types or data
*/
public function writeTypeMarker(&$data, $markerType = null, $dataByVal = false)
{
// Workaround for PHP5 with E_STRICT enabled complaining about "Only
// variables should be passed by reference"
if ((null === $data) && ($dataByVal !== false)) {
$data = &$dataByVal;
}
if (null !== $markerType) {
//try to reference 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) {
case Zend_Amf_Constants::AMF0_NUMBER:
$this->_stream->writeDouble($data);
break;
case Zend_Amf_Constants::AMF0_BOOLEAN:
$this->_stream->writeByte($data);
break;
case Zend_Amf_Constants::AMF0_STRING:
$this->_stream->writeUTF($data);
break;
case Zend_Amf_Constants::AMF0_OBJECT:
$this->writeObject($data);
break;
case Zend_Amf_Constants::AMF0_NULL:
break;
case Zend_Amf_Constants::AMF0_REFERENCE:
$this->_stream->writeInt($data);
break;
case Zend_Amf_Constants::AMF0_MIXEDARRAY:
// Write length of numeric keys as zero.
$this->_stream->writeLong(0);
$this->writeObject($data);
break;
case Zend_Amf_Constants::AMF0_ARRAY:
$this->writeArray($data);
break;
case Zend_Amf_Constants::AMF0_DATE:
$this->writeDate($data);
break;
case Zend_Amf_Constants::AMF0_LONGSTRING:
$this->_stream->writeLongUTF($data);
break;
case Zend_Amf_Constants::AMF0_TYPEDOBJECT:
$this->writeTypedObject($data);
break;
case Zend_Amf_Constants::AMF0_AMF3:
$this->writeAmf3TypeMarker($data);
break;
default:
throw new Zend_Amf_Exception("Unknown Type Marker: " . $markerType);
}
}
} else {
if (is_resource($data)) {
$data = Zend_Amf_Parse_TypeLoader::handleResource($data);
}
switch (true) {
case (is_int($data) || is_float($data)):
$markerType = Zend_Amf_Constants::AMF0_NUMBER;
break;
case (is_bool($data)):
$markerType = Zend_Amf_Constants::AMF0_BOOLEAN;
break;
case (is_string($data) && (($this->_mbStringFunctionsOverloaded ? mb_strlen($data, '8bit') : strlen($data)) > 65536)):
$markerType = Zend_Amf_Constants::AMF0_LONGSTRING;
break;
case (is_string($data)):
$markerType = Zend_Amf_Constants::AMF0_STRING;
break;
case (is_object($data)):
if (($data instanceof DateTime) || ($data instanceof Zend_Date)) {
$markerType = Zend_Amf_Constants::AMF0_DATE;
} else {
if($className = $this->getClassName($data)){
//Object is a Typed object set classname
$markerType = Zend_Amf_Constants::AMF0_TYPEDOBJECT;
$this->_className = $className;
} else {
// Object is a generic classname
$markerType = Zend_Amf_Constants::AMF0_OBJECT;
}
break;
}
break;
case (null === $data):
$markerType = Zend_Amf_Constants::AMF0_NULL;
break;
case (is_array($data)):
// check if it is an associative array
$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;
// check if it is a sparse indexed array
} else if ($key != $i) {
$markerType = Zend_Amf_Constants::AMF0_MIXEDARRAY;
break;
}
$i++;
}
// Dealing with a standard numeric array
if(!$markerType){
$markerType = Zend_Amf_Constants::AMF0_ARRAY;
break;
}
break;
default:
throw new Zend_Amf_Exception('Unsupported data type: ' . gettype($data));
}
$this->writeTypeMarker($data, $markerType);
}
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 reference to check for reference
* @param string $markerType AMF type of the object to write
* @param mixed $objectByVal object to check for reference
* @return Boolean true, if the reference was written, false otherwise
*/
protected function writeObjectReference(&$object, $markerType, $objectByVal = false)
{
// Workaround for PHP5 with E_STRICT enabled complaining about "Only
// variables should be passed by reference"
if ((null === $object) && ($objectByVal !== false)) {
$object = &$objectByVal;
}
if ($markerType == Zend_Amf_Constants::AMF0_OBJECT
|| $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){
$this->writeTypeMarker($ref,Zend_Amf_Constants::AMF0_REFERENCE);
return true;
}
$this->_referenceObjects[] = $object;
}
return false;
}
/**
* Write a PHP array with string or mixed keys.
*
* @param object $data
* @return Zend_Amf_Parse_Amf0_Serializer
*/
public function writeObject($object)
{
// Loop each element and write the name of the property.
foreach ($object as $key => &$value) {
// skip variables starting with an _ private transient
if( $key[0] == "_") continue;
$this->_stream->writeUTF($key);
$this->writeTypeMarker($value);
}
// Write the end object flag
$this->_stream->writeInt(0);
$this->_stream->writeByte(Zend_Amf_Constants::AMF0_OBJECTTERM);
return $this;
}
/**
* Write a standard numeric array to the output stream. If a mixed array
* is encountered call writeTypeMarker with mixed array.
*
* @param array $array
* @return Zend_Amf_Parse_Amf0_Serializer
*/
public function writeArray(&$array)
{
$length = count($array);
if (!$length < 0) {
// write the length of the array
$this->_stream->writeLong(0);
} else {
// Write the length of the numeric array
$this->_stream->writeLong($length);
for ($i=0; $i<$length; $i++) {
$value = isset($array[$i]) ? $array[$i] : null;
$this->writeTypeMarker($value);
}
}
return $this;
}
/**
* Convert the DateTime into an AMF Date
*
* @param DateTime|Zend_Date $data
* @return Zend_Amf_Parse_Amf0_Serializer
*/
public function writeDate($data)
{
if ($data instanceof DateTime) {
$dateString = $data->format('U');
} elseif ($data instanceof Zend_Date) {
$dateString = $data->toString('U');
} else {
throw new Zend_Amf_Exception('Invalid date specified; must be a DateTime or Zend_Date object');
}
$dateString *= 1000;
// Make the conversion and remove milliseconds.
$this->_stream->writeDouble($dateString);
// Flash does not respect timezone but requires it.
$this->_stream->writeInt(0);
return $this;
}
/**
* Write a class mapped object to the output stream.
*
* @param object $data
* @return Zend_Amf_Parse_Amf0_Serializer
*/
public function writeTypedObject($data)
{
$this->_stream->writeUTF($this->_className);
$this->writeObject($data);
return $this;
}
/**
* Encountered and AMF3 Type Marker use AMF3 serializer. Once AMF3 is
* encountered it will not return to AMf0.
*
* @param string $data
* @return Zend_Amf_Parse_Amf0_Serializer
*/
public function writeAmf3TypeMarker(&$data)
{
$serializer = new Zend_Amf_Parse_Amf3_Serializer($this->_stream);
$serializer->writeTypeMarker($data);
return $this;
}
/**
* Find if the class name is a class mapped name and return the
* respective classname if it is.
*
* @param object $object
* @return false|string $className
*/
protected function getClassName($object)
{
//Check to see if the object is a typed object and we need to change
$className = '';
switch (true) {
// the return class mapped name back to actionscript class name.
case Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object)):
$className = Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object));
break;
// Check to see if the user has defined an explicit Action Script type.
case isset($object->_explicitType):
$className = $object->_explicitType;
break;
// Check if user has defined a method for accessing the Action Script type
case method_exists($object, 'getASClassName'):
$className = $object->getASClassName();
break;
// No return class name is set make it a generic object
case ($object instanceof stdClass):
$className = '';
break;
// By default, use object's class name
default:
$className = get_class($object);
break;
}
if(!$className == '') {
return $className;
} else {
return false;
}
}
}

View File

@ -1,414 +0,0 @@
<?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_Amf3
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** Zend_Amf_Parse_Deserializer */
/** Zend_Xml_Security */
/** Zend_Amf_Parse_TypeLoader */
/**
* Read an AMF3 input stream and convert it into PHP data types.
*
* @todo readObject to handle Typed Objects
* @todo readXMLStrimg to be implemented.
* @todo Class could be implemented as Factory Class with each data type it's own class.
* @package Zend_Amf
* @subpackage Parse_Amf3
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Parse_Amf3_Deserializer extends Zend_Amf_Parse_Deserializer
{
/**
* Total number of objects in the referenceObject array
* @var int
*/
protected $_objectCount;
/**
* An array of reference objects per amf body
* @var array
*/
protected $_referenceObjects = array();
/**
* An array of reference strings per amf body
* @var array
*/
protected $_referenceStrings = array();
/**
* An array of reference class definitions per body
* @var array
*/
protected $_referenceDefinitions = array();
/**
* Read AMF markers and dispatch for deserialization
*
* Checks for AMF marker types and calls the appropriate methods
* for deserializing those marker types. markers are the data type of
* the following value.
*
* @param integer $typeMarker
* @return mixed Whatever the corresponding PHP data type is
* @throws Zend_Amf_Exception for unidentified marker type
*/
public function readTypeMarker($typeMarker = null)
{
if(null === $typeMarker) {
$typeMarker = $this->_stream->readByte();
}
switch($typeMarker) {
case Zend_Amf_Constants::AMF3_UNDEFINED:
return null;
case Zend_Amf_Constants::AMF3_NULL:
return null;
case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE:
return false;
case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE:
return true;
case Zend_Amf_Constants::AMF3_INTEGER:
return $this->readInteger();
case Zend_Amf_Constants::AMF3_NUMBER:
return $this->_stream->readDouble();
case Zend_Amf_Constants::AMF3_STRING:
return $this->readString();
case Zend_Amf_Constants::AMF3_DATE:
return $this->readDate();
case Zend_Amf_Constants::AMF3_ARRAY:
return $this->readArray();
case Zend_Amf_Constants::AMF3_OBJECT:
return $this->readObject();
case Zend_Amf_Constants::AMF3_XML:
case Zend_Amf_Constants::AMF3_XMLSTRING:
return $this->readXmlString();
case Zend_Amf_Constants::AMF3_BYTEARRAY:
return $this->readString();
default:
throw new Zend_Amf_Exception('Unsupported type marker: ' . $typeMarker);
}
}
/**
* Read and deserialize an integer
*
* AMF 3 represents smaller integers with fewer bytes using the most
* significant bit of each byte. The worst case uses 32-bits
* to represent a 29-bit number, which is what we would have
* done with no compression.
* - 0x00000000 - 0x0000007F : 0xxxxxxx
* - 0x00000080 - 0x00003FFF : 1xxxxxxx 0xxxxxxx
* - 0x00004000 - 0x001FFFFF : 1xxxxxxx 1xxxxxxx 0xxxxxxx
* - 0x00200000 - 0x3FFFFFFF : 1xxxxxxx 1xxxxxxx 1xxxxxxx xxxxxxxx
* - 0x40000000 - 0xFFFFFFFF : throw range exception
*
* 0x04 -> integer type code, followed by up to 4 bytes of data.
*
* Parsing integers on OSFlash for the AMF3 integer data format:
* @link http://osflash.org/amf3/parsing_integers
* @return int|float
*/
public function readInteger()
{
$count = 1;
$intReference = $this->_stream->readByte();
$result = 0;
while ((($intReference & 0x80) != 0) && $count < 4) {
$result <<= 7;
$result |= ($intReference & 0x7f);
$intReference = $this->_stream->readByte();
$count++;
}
if ($count < 4) {
$result <<= 7;
$result |= $intReference;
} else {
// Use all 8 bits from the 4th byte
$result <<= 8;
$result |= $intReference;
// Check if the integer should be negative
if (($result & 0x10000000) != 0) {
//and extend the sign bit
$result |= ~0xFFFFFFF;
}
}
return $result;
}
/**
* Read and deserialize a string
*
* Strings can be sent as a reference to a previously
* occurring String by using an index to the implicit string reference table.
* Strings are encoding using UTF-8 - however the header may either
* describe a string literal or a string reference.
*
* - string = 0x06 string-data
* - string-data = integer-data [ modified-utf-8 ]
* - modified-utf-8 = *OCTET
*
* @return String
*/
public function readString()
{
$stringReference = $this->readInteger();
//Check if this is a reference string
if (($stringReference & 0x01) == 0) {
// reference string
$stringReference = $stringReference >> 1;
if ($stringReference >= count($this->_referenceStrings)) {
throw new Zend_Amf_Exception('Undefined string reference: ' . $stringReference);
}
// reference string found
return $this->_referenceStrings[$stringReference];
}
$length = $stringReference >> 1;
if ($length) {
$string = $this->_stream->readBytes($length);
$this->_referenceStrings[] = $string;
} else {
$string = "";
}
return $string;
}
/**
* Read and deserialize a date
*
* Data is the number of milliseconds elapsed since the epoch
* of midnight, 1st Jan 1970 in the UTC time zone.
* Local time zone information is not sent to flash.
*
* - date = 0x08 integer-data [ number-data ]
*
* @return Zend_Date
*/
public function readDate()
{
$dateReference = $this->readInteger();
if (($dateReference & 0x01) == 0) {
$dateReference = $dateReference >> 1;
if ($dateReference>=count($this->_referenceObjects)) {
throw new Zend_Amf_Exception('Undefined date reference: ' . $dateReference);
}
return $this->_referenceObjects[$dateReference];
}
$timestamp = floor($this->_stream->readDouble() / 1000);
$dateTime = new Zend_Date($timestamp);
$this->_referenceObjects[] = $dateTime;
return $dateTime;
}
/**
* Read amf array to PHP array
*
* - array = 0x09 integer-data ( [ 1OCTET *amf3-data ] | [OCTET *amf3-data 1] | [ OCTET *amf-data ] )
*
* @return array
*/
public function readArray()
{
$arrayReference = $this->readInteger();
if (($arrayReference & 0x01)==0){
$arrayReference = $arrayReference >> 1;
if ($arrayReference>=count($this->_referenceObjects)) {
throw new Zend_Amf_Exception('Unknow array reference: ' . $arrayReference);
}
return $this->_referenceObjects[$arrayReference];
}
// Create a holder for the array in the reference list
$data = array();
$this->_referenceObjects[] =& $data;
$key = $this->readString();
// Iterating for string based keys.
while ($key != '') {
$data[$key] = $this->readTypeMarker();
$key = $this->readString();
}
$arrayReference = $arrayReference >>1;
//We have a dense array
for ($i=0; $i < $arrayReference; $i++) {
$data[] = $this->readTypeMarker();
}
return $data;
}
/**
* Read an object from the AMF stream and convert it into a PHP object
*
* @todo Rather than using an array of traitsInfo create Zend_Amf_Value_TraitsInfo
* @return object|array
*/
public function readObject()
{
$traitsInfo = $this->readInteger();
$storedObject = ($traitsInfo & 0x01)==0;
$traitsInfo = $traitsInfo >> 1;
// Check if the Object is in the stored Objects reference table
if ($storedObject) {
$ref = $traitsInfo;
if (!isset($this->_referenceObjects[$ref])) {
throw new Zend_Amf_Exception('Unknown Object reference: ' . $ref);
}
$returnObject = $this->_referenceObjects[$ref];
} else {
// Check if the Object is in the stored Definitions reference table
$storedClass = ($traitsInfo & 0x01) == 0;
$traitsInfo = $traitsInfo >> 1;
if ($storedClass) {
$ref = $traitsInfo;
if (!isset($this->_referenceDefinitions[$ref])) {
throw new Zend_Amf_Exception('Unknows Definition reference: '. $ref);
}
// Populate the reference attributes
$className = $this->_referenceDefinitions[$ref]['className'];
$encoding = $this->_referenceDefinitions[$ref]['encoding'];
$propertyNames = $this->_referenceDefinitions[$ref]['propertyNames'];
} else {
// The class was not in the reference tables. Start reading rawdata to build traits.
// Create a traits table. Zend_Amf_Value_TraitsInfo would be ideal
$className = $this->readString();
$encoding = $traitsInfo & 0x03;
$propertyNames = array();
$traitsInfo = $traitsInfo >> 2;
}
// We now have the object traits defined in variables. Time to go to work:
if (!$className) {
// No class name generic object
$returnObject = new stdClass();
} else {
// Defined object
// Typed object lookup against registered classname maps
if ($loader = Zend_Amf_Parse_TypeLoader::loadType($className)) {
$returnObject = new $loader();
} else {
//user defined typed object
throw new Zend_Amf_Exception('Typed object not found: '. $className . ' ');
}
}
// Add the Object to the reference table
$this->_referenceObjects[] = $returnObject;
$properties = array(); // clear value
// Check encoding types for additional processing.
switch ($encoding) {
case (Zend_Amf_Constants::ET_EXTERNAL):
// Externalizable object such as {ArrayCollection} and {ObjectProxy}
if (!$storedClass) {
$this->_referenceDefinitions[] = array(
'className' => $className,
'encoding' => $encoding,
'propertyNames' => $propertyNames,
);
}
$returnObject->externalizedData = $this->readTypeMarker();
break;
case (Zend_Amf_Constants::ET_DYNAMIC):
// used for Name-value encoding
if (!$storedClass) {
$this->_referenceDefinitions[] = array(
'className' => $className,
'encoding' => $encoding,
'propertyNames' => $propertyNames,
);
}
// not a reference object read name value properties from byte stream
do {
$property = $this->readString();
if ($property != "") {
$propertyNames[] = $property;
$properties[$property] = $this->readTypeMarker();
}
} while ($property !="");
break;
default:
// basic property list object.
if (!$storedClass) {
$count = $traitsInfo; // Number of properties in the list
for($i=0; $i< $count; $i++) {
$propertyNames[] = $this->readString();
}
// Add a reference to the class.
$this->_referenceDefinitions[] = array(
'className' => $className,
'encoding' => $encoding,
'propertyNames' => $propertyNames,
);
}
foreach ($propertyNames as $property) {
$properties[$property] = $this->readTypeMarker();
}
break;
}
// Add properties back to the return object.
if (!is_array($properties)) $properties = array();
foreach($properties as $key=>$value) {
if($key) {
$returnObject->$key = $value;
}
}
}
if ($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
if (isset($returnObject->externalizedData)) {
$returnObject = $returnObject->externalizedData;
} else {
$returnObject = get_object_vars($returnObject);
}
}
return $returnObject;
}
/**
* Convert XML to SimpleXml
* If user wants DomDocument they can use dom_import_simplexml
*
* @return SimpleXml Object
*/
public function readXmlString()
{
$xmlReference = $this->readInteger();
$length = $xmlReference >> 1;
$string = $this->_stream->readBytes($length);
return Zend_Xml_Security::scan($string);
}
}

View File

@ -1,523 +0,0 @@
<?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_Amf3
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** Zend_Amf_Constants */
/** Zend_Amf_Parse_Serializer */
/** Zend_Amf_Parse_TypeLoader */
/**
* Detect PHP object type and convert it to a corresponding AMF3 object type
*
* @package Zend_Amf
* @subpackage Parse_Amf3
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
{
/**
* A constant empty string
* @var string
*/
protected $_strEmpty = '';
/**
* An array of reference objects per amf body
* @var array
*/
protected $_referenceObjects = array();
/**
* An array of reference strings per amf body
* @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
*
* Checks to see if the type was declared and then either
* auto negotiates the type or use the user defined markerType to
* serialize the data from php back to AMF3
*
* @param mixed $data
* @param int $markerType
* @param mixed $dataByVal
* @return void
*/
public function writeTypeMarker(&$data, $markerType = null, $dataByVal = false)
{
// Workaround for PHP5 with E_STRICT enabled complaining about "Only
// variables should be passed by reference"
if ((null === $data) && ($dataByVal !== false)) {
$data = &$dataByVal;
}
if (null !== $markerType) {
// Write the Type Marker to denote the following action script data type
$this->_stream->writeByte($markerType);
switch ($markerType) {
case Zend_Amf_Constants::AMF3_NULL:
break;
case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE:
break;
case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE:
break;
case Zend_Amf_Constants::AMF3_INTEGER:
$this->writeInteger($data);
break;
case Zend_Amf_Constants::AMF3_NUMBER:
$this->_stream->writeDouble($data);
break;
case Zend_Amf_Constants::AMF3_STRING:
$this->writeString($data);
break;
case Zend_Amf_Constants::AMF3_DATE:
$this->writeDate($data);
break;
case Zend_Amf_Constants::AMF3_ARRAY:
$this->writeArray($data);
break;
case Zend_Amf_Constants::AMF3_OBJECT:
$this->writeObject($data);
break;
case Zend_Amf_Constants::AMF3_BYTEARRAY:
$this->writeByteArray($data);
break;
case Zend_Amf_Constants::AMF3_XMLSTRING;
$this->writeXml($data);
break;
default:
throw new Zend_Amf_Exception('Unknown Type Marker: ' . $markerType);
}
} else {
// Detect Type Marker
if (is_resource($data)) {
$data = Zend_Amf_Parse_TypeLoader::handleResource($data);
}
switch (true) {
case (null === $data):
$markerType = Zend_Amf_Constants::AMF3_NULL;
break;
case (is_bool($data)):
if ($data){
$markerType = Zend_Amf_Constants::AMF3_BOOLEAN_TRUE;
} else {
$markerType = Zend_Amf_Constants::AMF3_BOOLEAN_FALSE;
}
break;
case (is_int($data)):
if (($data > 0xFFFFFFF) || ($data < -268435456)) {
$markerType = Zend_Amf_Constants::AMF3_NUMBER;
} else {
$markerType = Zend_Amf_Constants::AMF3_INTEGER;
}
break;
case (is_float($data)):
$markerType = Zend_Amf_Constants::AMF3_NUMBER;
break;
case (is_string($data)):
$markerType = Zend_Amf_Constants::AMF3_STRING;
break;
case (is_array($data)):
$markerType = Zend_Amf_Constants::AMF3_ARRAY;
break;
case (is_object($data)):
// Handle object types.
if (($data instanceof DateTime) || ($data instanceof Zend_Date)) {
$markerType = Zend_Amf_Constants::AMF3_DATE;
} else if ($data instanceof Zend_Amf_Value_ByteArray) {
$markerType = Zend_Amf_Constants::AMF3_BYTEARRAY;
} else if (($data instanceof DOMDocument) || ($data instanceof SimpleXMLElement)) {
$markerType = Zend_Amf_Constants::AMF3_XMLSTRING;
} else {
$markerType = Zend_Amf_Constants::AMF3_OBJECT;
}
break;
default:
throw new Zend_Amf_Exception('Unsupported data type: ' . gettype($data));
}
$this->writeTypeMarker($data, $markerType);
}
}
/**
* Write an AMF3 integer
*
* @param int|float $data
* @return Zend_Amf_Parse_Amf3_Serializer
*/
public function writeInteger($int)
{
if (($int & 0xffffff80) == 0) {
$this->_stream->writeByte($int & 0x7f);
return $this;
}
if (($int & 0xffffc000) == 0 ) {
$this->_stream->writeByte(($int >> 7 ) | 0x80);
$this->_stream->writeByte($int & 0x7f);
return $this;
}
if (($int & 0xffe00000) == 0) {
$this->_stream->writeByte(($int >> 14 ) | 0x80);
$this->_stream->writeByte(($int >> 7 ) | 0x80);
$this->_stream->writeByte($int & 0x7f);
return $this;
}
$this->_stream->writeByte(($int >> 22 ) | 0x80);
$this->_stream->writeByte(($int >> 15 ) | 0x80);
$this->_stream->writeByte(($int >> 8 ) | 0x80);
$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
*
* @param string $string
* @return Zend_Amf_Parse_Amf3_Serializer
*/
protected function writeBinaryString(&$string){
$ref = ($this->_mbStringFunctionsOverloaded ? mb_strlen($string, '8bit') : strlen($string)) << 1 | 0x01;
$this->writeInteger($ref);
$this->_stream->writeBytes($string);
return $this;
}
/**
* Send string to output stream
*
* @param string $string
* @return Zend_Amf_Parse_Amf3_Serializer
*/
public function writeString(&$string)
{
$len = $this->_mbStringFunctionsOverloaded ? mb_strlen($string, '8bit') : strlen($string);
if(!$len){
$this->writeInteger(0x01);
return $this;
}
$ref = array_key_exists($string, $this->_referenceStrings)
? $this->_referenceStrings[$string]
: false;
if ($ref === false){
$this->_referenceStrings[$string] = count($this->_referenceStrings);
$this->writeBinaryString($string);
} else {
$ref <<= 1;
$this->writeInteger($ref);
}
return $this;
}
/**
* Send ByteArray to output stream
*
* @param string|Zend_Amf_Value_ByteArray $data
* @return Zend_Amf_Parse_Amf3_Serializer
*/
public function writeByteArray(&$data)
{
if ($this->writeObjectReference($data)) {
return $this;
}
if (is_string($data)) {
//nothing to do
} else if ($data instanceof Zend_Amf_Value_ByteArray) {
$data = $data->getData();
} else {
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
* @return Zend_Amf_Parse_Amf3_Serializer
*/
public function writeXml($xml)
{
if ($this->writeObjectReference($xml)) {
return $this;
}
if(is_string($xml)) {
//nothing to do
} else if ($xml instanceof DOMDocument) {
$xml = $xml->saveXml();
} else if ($xml instanceof SimpleXMLElement) {
$xml = $xml->asXML();
} else {
throw new Zend_Amf_Exception('Invalid xml specified; must be a DOMDocument or SimpleXMLElement');
}
$this->writeBinaryString($xml);
return $this;
}
/**
* Convert DateTime/Zend_Date to AMF date
*
* @param DateTime|Zend_Date $date
* @return Zend_Amf_Parse_Amf3_Serializer
*/
public function writeDate($date)
{
if ($this->writeObjectReference($date)) {
return $this;
}
if ($date instanceof DateTime) {
$dateString = $date->format('U') * 1000;
} elseif ($date instanceof Zend_Date) {
$dateString = $date->toString('U') * 1000;
} else {
throw new Zend_Amf_Exception('Invalid date specified; must be a string DateTime or Zend_Date object');
}
$this->writeInteger(0x01);
// write time to stream minus milliseconds
$this->_stream->writeDouble($dateString);
return $this;
}
/**
* Write a PHP array back to the amf output stream
*
* @param array $array
* @return Zend_Amf_Parse_Amf3_Serializer
*/
public function writeArray(&$array)
{
// arrays aren't reference here but still counted
$this->_referenceObjects[] = $array;
// have to seperate mixed from numberic keys.
$numeric = array();
$string = array();
foreach ($array as $key => &$value) {
if (is_int($key)) {
$numeric[] = $value;
} else {
$string[$key] = $value;
}
}
// write the preamble id of the array
$length = count($numeric);
$id = ($length << 1) | 0x01;
$this->writeInteger($id);
//Write the mixed type array to the output stream
foreach($string as $key => &$value) {
$this->writeString($key)
->writeTypeMarker($value);
}
$this->writeString($this->_strEmpty);
// Write the numeric array to ouput stream
foreach($numeric as &$value) {
$this->writeTypeMarker($value);
}
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 reference to check for reference
* @param mixed $objectByVal object to check for reference
* @return Boolean true, if the reference was written, false otherwise
*/
protected function writeObjectReference(&$object, $objectByVal = false)
{
// Workaround for PHP5 with E_STRICT enabled complaining about "Only
// variables should be passed by reference"
if ((null === $object) && ($objectByVal !== false)) {
$object = &$objectByVal;
}
$hash = spl_object_hash($object);
$ref = array_key_exists($hash, $this->_referenceObjects)
? $this->_referenceObjects[$hash]
: false;
// quickly handle object references
if ($ref !== false){
$ref <<= 1;
$this->writeInteger($ref);
return true;
}
$this->_referenceObjects[$hash] = count($this->_referenceObjects);
return false;
}
/**
* Write object to ouput stream
*
* @param mixed $data
* @return Zend_Amf_Parse_Amf3_Serializer
*/
public function writeObject($object)
{
if($this->writeObjectReference($object)){
return $this;
}
$className = '';
//Check to see if the object is a typed object and we need to change
switch (true) {
// the return class mapped name back to actionscript class name.
case ($className = Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object))):
break;
// Check to see if the user has defined an explicit Action Script type.
case isset($object->_explicitType):
$className = $object->_explicitType;
break;
// Check if user has defined a method for accessing the Action Script type
case method_exists($object, 'getASClassName'):
$className = $object->getASClassName();
break;
// No return class name is set make it a generic object
case ($object instanceof stdClass):
$className = '';
break;
// By default, use object's class name
default:
$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:
//Write the sealed values to the output stream.
foreach ($propertyNames as $key) {
$this->writeTypeMarker($object->$key);
}
break;
case Zend_Amf_Constants::ET_DYNAMIC:
//Write the sealed values to the output stream.
foreach ($propertyNames as $key) {
$this->writeTypeMarker($object->$key);
}
//Write remaining properties
foreach($object as $key => $value){
if(!in_array($key,$propertyNames) && $key[0] != "_"){
$this->writeString($key);
$this->writeTypeMarker($value);
}
}
//Write an empty string to end the dynamic part
$this->writeString($this->_strEmpty);
break;
case Zend_Amf_Constants::ET_EXTERNAL:
throw new Zend_Amf_Exception('External Object Encoding not implemented');
break;
default:
throw new Zend_Amf_Exception('Unknown Object Encoding type: ' . $encoding);
}
} catch (Exception $e) {
throw new Zend_Amf_Exception('Unable to writeObject output: ' . $e->getMessage(), 0, $e);
}
return $this;
}
}

View File

@ -1,65 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* 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
* source tree.
*
* @see http://opensource.adobe.com/svn/opensource/blazeds/trunk/modules/core/src/java/flex/messaging/io/amf/
* @package Zend_Amf
* @subpackage Parse
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Amf_Parse_Deserializer
{
/**
* The raw string that represents the AMF request.
*
* @var Zend_Amf_Parse_InputStream
*/
protected $_stream;
/**
* Constructor
*
* @param Zend_Amf_Parse_InputStream $stream
* @return void
*/
public function __construct(Zend_Amf_Parse_InputStream $stream)
{
$this->_stream = $stream;
}
/**
* Checks for AMF marker types and calls the appropriate methods
* for deserializing those marker types. Markers are the data type of
* the following value.
*
* @param int $typeMarker
* @return mixed Whatever the data type is of the marker in php
*/
public abstract function readTypeMarker($markerType = null);
}

View File

@ -1,38 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** Zend_Amf_Util_BinaryStream */
/**
* InputStream is used to iterate at a binary level through the AMF request.
*
* 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
* @subpackage Parse
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Parse_InputStream extends Zend_Amf_Util_BinaryStream
{
}

View File

@ -1,70 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* 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-2014 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

@ -1,128 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* 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-2014 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
{
/**
* 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",
);
// 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',
);
/**
* 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]];
}
}
while($row = mysqli_fetch_assoc($resource)) {
foreach($fields_transform as $fieldname => $fieldtype) {
settype($row[$fieldname], $fieldtype);
}
$result[] = $row;
}
return $result;
}
}

View File

@ -1,68 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* Base abstract class for all AMF serializers.
*
* @package Zend_Amf
* @subpackage Parse
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Amf_Parse_Serializer
{
/**
* Reference to the current output stream being constructed
*
* @var string
*/
protected $_stream;
/**
* str* functions overloaded using mbstring.func_overload
*
* @var bool
*/
protected $mbStringFunctionsOverloaded;
/**
* Constructor
*
* @param Zend_Amf_Parse_OutputStream $stream
* @return void
*/
public function __construct(Zend_Amf_Parse_OutputStream $stream)
{
$this->_stream = $stream;
$this->_mbStringFunctionsOverloaded = function_exists('mb_strlen') && (ini_get('mbstring.func_overload') !== '') && ((int)ini_get('mbstring.func_overload') & 2);
}
/**
* Find the PHP object type and convert it into an AMF object type
*
* @param mixed $content
* @param int $markerType
* @param mixed $contentByVal
* @return void
*/
public abstract function writeTypeMarker(&$content, $markerType = null, $contentByVal = false);
}

View File

@ -1,222 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Amf_Value_Messaging_AcknowledgeMessage
*/
/**
* @see Zend_Amf_Value_Messaging_AsyncMessage
*/
/**
* @see Zend_Amf_Value_Messaging_CommandMessage
*/
/**
* @see Zend_Amf_Value_Messaging_ErrorMessage
*/
/**
* @see Zend_Amf_Value_Messaging_RemotingMessage
*/
/**
* Loads a local class and executes the instantiation of that class.
*
* @todo PHP 5.3 can drastically change this class w/ namespace and the new call_user_func w/ namespace
* @package Zend_Amf
* @subpackage Parse
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
final class Zend_Amf_Parse_TypeLoader
{
/**
* @var string callback class
*/
public static $callbackClass;
/**
* @var array AMF class map
*/
public static $classMap = array (
'flex.messaging.messages.AcknowledgeMessage' => 'Zend_Amf_Value_Messaging_AcknowledgeMessage',
'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_AsyncMessage',
'flex.messaging.messages.CommandMessage' => 'Zend_Amf_Value_Messaging_CommandMessage',
'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_ErrorMessage',
'flex.messaging.messages.RemotingMessage' => 'Zend_Amf_Value_Messaging_RemotingMessage',
'flex.messaging.io.ArrayCollection' => 'Zend_Amf_Value_Messaging_ArrayCollection',
);
/**
* @var array Default class map
*/
protected static $_defaultClassMap = array(
'flex.messaging.messages.AcknowledgeMessage' => 'Zend_Amf_Value_Messaging_AcknowledgeMessage',
'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_AsyncMessage',
'flex.messaging.messages.CommandMessage' => 'Zend_Amf_Value_Messaging_CommandMessage',
'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_ErrorMessage',
'flex.messaging.messages.RemotingMessage' => 'Zend_Amf_Value_Messaging_RemotingMessage',
'flex.messaging.io.ArrayCollection' => 'Zend_Amf_Value_Messaging_ArrayCollection',
);
/**
* @var Zend_Loader_PluginLoader_Interface
*/
protected static $_resourceLoader = null;
/**
* Load the mapped class type into a callback.
*
* @param string $className
* @return object|false
*/
public static function loadType($className)
{
$class = self::getMappedClassName($className);
if(!$class) {
$class = str_replace('.', '_', $className);
}
if (!class_exists($class)) {
return "stdClass";
}
return $class;
}
/**
* Looks up the supplied call name to its mapped class name
*
* @param string $className
* @return string
*/
public static function getMappedClassName($className)
{
$mappedName = array_search($className, self::$classMap);
if ($mappedName) {
return $mappedName;
}
$mappedName = array_search($className, array_flip(self::$classMap));
if ($mappedName) {
return $mappedName;
}
return false;
}
/**
* Map PHP class names to ActionScript class names
*
* Allows users to map the class names of there action script classes
* to the equivelent php class name. Used in deserialization to load a class
* and serialiation to set the class name of the returned object.
*
* @param string $asClassName
* @param string $phpClassName
* @return void
*/
public static function setMapping($asClassName, $phpClassName)
{
self::$classMap[$asClassName] = $phpClassName;
}
/**
* Reset type map
*
* @return void
*/
public static function resetMap()
{
self::$classMap = self::$_defaultClassMap;
}
/**
* Set loader for resource type handlers
*
* @param Zend_Loader_PluginLoader_Interface $loader
*/
public static function setResourceLoader(Zend_Loader_PluginLoader_Interface $loader)
{
self::$_resourceLoader = $loader;
}
/**
* 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);
}
}
/**
* 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;
}
/**
* Convert resource to a serializable object
*
* @param resource $resource
* @return mixed
*/
public static function handleResource($resource)
{
if(!self::$_resourceLoader) {
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) {
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 {
throw new Zend_Amf_Exception("Could not call parse() method on class $resclass");
}
}
return $resource;
} catch(Zend_Amf_Exception $e) {
throw new Zend_Amf_Exception($e->getMessage(), $e->getCode(), $e);
} catch(Exception $e) {
throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource), 0, $e);
}
}
}

View File

@ -1,243 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** @see Zend_Amf_Parse_InputStream */
/** @see Zend_Amf_Parse_Amf0_Deserializer */
/** @see Zend_Amf_Constants */
/** @see Zend_Amf_Value_MessageHeader */
/** @see Zend_Amf_Value_MessageBody */
/**
* Handle the incoming AMF request by deserializing the data to php object
* types and storing the data for Zend_Amf_Server to handle for processing.
*
* @todo Currently not checking if the object needs to be Type Mapped to a server object.
* @package Zend_Amf
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Request
{
/**
* @var int AMF client type (AMF0, AMF3)
*/
protected $_clientType = 0; // default AMF0
/**
* @var array Message bodies
*/
protected $_bodies = array();
/**
* @var array Message headers
*/
protected $_headers = array();
/**
* @var int Message encoding to use for objects in response
*/
protected $_objectEncoding = 0;
/**
* @var Zend_Amf_Parse_InputStream
*/
protected $_inputStream;
/**
* @var Zend_Amf_Parse_AMF0_Deserializer
*/
protected $_deserializer;
/**
* Time of the request
* @var mixed
*/
protected $_time;
/**
* Prepare the AMF InputStream for parsing.
*
* @param string $request
* @return Zend_Amf_Request
*/
public function initialize($request)
{
$this->_inputStream = new Zend_Amf_Parse_InputStream($request);
$this->_deserializer = new Zend_Amf_Parse_Amf0_Deserializer($this->_inputStream);
$this->readMessage($this->_inputStream);
return $this;
}
/**
* Takes the raw AMF input stream and converts it into valid PHP objects
*
* @param Zend_Amf_Parse_InputStream
* @return Zend_Amf_Request
*/
public function readMessage(Zend_Amf_Parse_InputStream $stream)
{
$clientVersion = $stream->readUnsignedShort();
if (($clientVersion != Zend_Amf_Constants::AMF0_OBJECT_ENCODING)
&& ($clientVersion != Zend_Amf_Constants::AMF3_OBJECT_ENCODING)
&& ($clientVersion != Zend_Amf_Constants::FMS_OBJECT_ENCODING)
) {
throw new Zend_Amf_Exception('Unknown Player Version ' . $clientVersion);
}
$this->_bodies = array();
$this->_headers = array();
$headerCount = $stream->readInt();
// Iterate through the AMF envelope header
while ($headerCount--) {
$this->_headers[] = $this->readHeader();
}
// Iterate through the AMF envelope body
$bodyCount = $stream->readInt();
while ($bodyCount--) {
$this->_bodies[] = $this->readBody();
}
return $this;
}
/**
* Deserialize a message header from the input stream.
*
* A message header is structured as:
* - NAME String
* - MUST UNDERSTAND Boolean
* - LENGTH Int
* - DATA Object
*
* @return Zend_Amf_Value_MessageHeader
*/
public function readHeader()
{
$name = $this->_inputStream->readUTF();
$mustRead = (bool)$this->_inputStream->readByte();
$length = $this->_inputStream->readLong();
try {
$data = $this->_deserializer->readTypeMarker();
} catch (Exception $e) {
throw new Zend_Amf_Exception('Unable to parse ' . $name . ' header data: ' . $e->getMessage() . ' '. $e->getLine(), 0, $e);
}
$header = new Zend_Amf_Value_MessageHeader($name, $mustRead, $data, $length);
return $header;
}
/**
* Deserialize a message body from the input stream
*
* @return Zend_Amf_Value_MessageBody
*/
public function readBody()
{
$targetURI = $this->_inputStream->readUTF();
$responseURI = $this->_inputStream->readUTF();
$length = $this->_inputStream->readLong();
try {
$data = $this->_deserializer->readTypeMarker();
} catch (Exception $e) {
throw new Zend_Amf_Exception('Unable to parse ' . $targetURI . ' body data ' . $e->getMessage(), 0, $e);
}
// Check for AMF3 objectEncoding
if ($this->_deserializer->getObjectEncoding() == Zend_Amf_Constants::AMF3_OBJECT_ENCODING) {
/*
* When and AMF3 message is sent to the server it is nested inside
* an AMF0 array called Content. The following code gets the object
* out of the content array and sets it as the message data.
*/
if(is_array($data) && $data[0] instanceof Zend_Amf_Value_Messaging_AbstractMessage){
$data = $data[0];
}
// set the encoding so we return our message in AMF3
$this->_objectEncoding = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
}
$body = new Zend_Amf_Value_MessageBody($targetURI, $responseURI, $data);
return $body;
}
/**
* Return an array of the body objects that were found in the amf request.
*
* @return array {target, response, length, content}
*/
public function getAmfBodies()
{
return $this->_bodies;
}
/**
* Accessor to private array of message bodies.
*
* @param Zend_Amf_Value_MessageBody $message
* @return Zend_Amf_Request
*/
public function addAmfBody(Zend_Amf_Value_MessageBody $message)
{
$this->_bodies[] = $message;
return $this;
}
/**
* Return an array of headers that were found in the amf request.
*
* @return array {operation, mustUnderstand, length, param}
*/
public function getAmfHeaders()
{
return $this->_headers;
}
/**
* Return the either 0 or 3 for respect AMF version
*
* @return int
*/
public function getObjectEncoding()
{
return $this->_objectEncoding;
}
/**
* Set the object response encoding
*
* @param mixed $int
* @return Zend_Amf_Request
*/
public function setObjectEncoding($int)
{
$this->_objectEncoding = $int;
return $this;
}
}

View File

@ -1,79 +0,0 @@
<?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 Request
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** @see Zend_Amf_Request */
/**
* AMF Request object -- Request via HTTP
*
* Extends {@link Zend_Amf_Request} to accept a request via HTTP. Request is
* built at construction time using a raw POST; if no data is available, the
* request is declared a fault.
*
* @package Zend_Amf
* @subpackage Request
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Request_Http extends Zend_Amf_Request
{
/**
* Raw AMF request
* @var string
*/
protected $_rawRequest;
/**
* Constructor
*
* Attempts to read from php://input to get raw POST request; if an error
* occurs in doing so, or if the AMF body is invalid, the request is declared a
* fault.
*
* @return void
*/
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
// special php.ini directives
$amfRequest = file_get_contents('php://input');
// Check to make sure that we have data on the input stream.
if ($amfRequest != '') {
$this->_rawRequest = $amfRequest;
$this->initialize($amfRequest);
} else {
echo '<p>Zend Amf Endpoint</p>' ;
}
}
/**
* Retrieve raw AMF Request
*
* @return string
*/
public function getRawRequest()
{
return $this->_rawRequest;
}
}

View File

@ -1,202 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** @see Zend_Amf_Constants */
/** @see Zend_Amf_Parse_OutputStream */
/** @see Zend_Amf_Parse_Amf0_Serializer */
/**
* Handles converting the PHP object ready for response back into AMF
*
* @package Zend_Amf
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Response
{
/**
* @var int Object encoding for response
*/
protected $_objectEncoding = 0;
/**
* Array of Zend_Amf_Value_MessageBody objects
* @var array
*/
protected $_bodies = array();
/**
* Array of Zend_Amf_Value_MessageHeader objects
* @var array
*/
protected $_headers = array();
/**
* @var Zend_Amf_Parse_OutputStream
*/
protected $_outputStream;
/**
* Instantiate new output stream and start serialization
*
* @return Zend_Amf_Response
*/
public function finalize()
{
$this->_outputStream = new Zend_Amf_Parse_OutputStream();
$this->writeMessage($this->_outputStream);
return $this;
}
/**
* Serialize the PHP data types back into Actionscript and
* create and AMF stream.
*
* @param Zend_Amf_Parse_OutputStream $stream
* @return Zend_Amf_Response
*/
public function writeMessage(Zend_Amf_Parse_OutputStream $stream)
{
$objectEncoding = $this->_objectEncoding;
//Write encoding to start of stream. Preamble byte is written of two byte Unsigned Short
$stream->writeByte(0x00);
$stream->writeByte($objectEncoding);
// Loop through the AMF Headers that need to be returned.
$headerCount = count($this->_headers);
$stream->writeInt($headerCount);
foreach ($this->getAmfHeaders() as $header) {
$serializer = new Zend_Amf_Parse_Amf0_Serializer($stream);
$stream->writeUTF($header->name);
$stream->writeByte($header->mustRead);
$stream->writeLong(Zend_Amf_Constants::UNKNOWN_CONTENT_LENGTH);
if (is_object($header->data)) {
// Workaround for PHP5 with E_STRICT enabled complaining about
// "Only variables should be passed by reference"
$placeholder = null;
$serializer->writeTypeMarker($placeholder, null, $header->data);
} else {
$serializer->writeTypeMarker($header->data);
}
}
// loop through the AMF bodies that need to be returned.
$bodyCount = count($this->_bodies);
$stream->writeInt($bodyCount);
foreach ($this->_bodies as $body) {
$serializer = new Zend_Amf_Parse_Amf0_Serializer($stream);
$stream->writeUTF($body->getTargetURI());
$stream->writeUTF($body->getResponseURI());
$stream->writeLong(Zend_Amf_Constants::UNKNOWN_CONTENT_LENGTH);
$bodyData = $body->getData();
$markerType = ($this->_objectEncoding == Zend_Amf_Constants::AMF0_OBJECT_ENCODING) ? null : Zend_Amf_Constants::AMF0_AMF3;
if (is_object($bodyData)) {
// Workaround for PHP5 with E_STRICT enabled complaining about
// "Only variables should be passed by reference"
$placeholder = null;
$serializer->writeTypeMarker($placeholder, $markerType, $bodyData);
} else {
$serializer->writeTypeMarker($bodyData, $markerType);
}
}
return $this;
}
/**
* Return the output stream content
*
* @return string The contents of the output stream
*/
public function getResponse()
{
return $this->_outputStream->getStream();
}
/**
* Return the output stream content
*
* @return string
*/
public function __toString()
{
return $this->getResponse();
}
/**
* Add an AMF body to be sent to the Flash Player
*
* @param Zend_Amf_Value_MessageBody $body
* @return Zend_Amf_Response
*/
public function addAmfBody(Zend_Amf_Value_MessageBody $body)
{
$this->_bodies[] = $body;
return $this;
}
/**
* Return an array of AMF bodies to be serialized
*
* @return array
*/
public function getAmfBodies()
{
return $this->_bodies;
}
/**
* Add an AMF Header to be sent back to the flash player
*
* @param Zend_Amf_Value_MessageHeader $header
* @return Zend_Amf_Response
*/
public function addAmfHeader(Zend_Amf_Value_MessageHeader $header)
{
$this->_headers[] = $header;
return $this;
}
/**
* Retrieve attached AMF message headers
*
* @return array Array of Zend_Amf_Value_MessageHeader objects
*/
public function getAmfHeaders()
{
return $this->_headers;
}
/**
* Set the AMF encoding that will be used for serialization
*
* @param int $encoding
* @return Zend_Amf_Response
*/
public function setObjectEncoding($encoding)
{
$this->_objectEncoding = $encoding;
return $this;
}
}

View File

@ -1,72 +0,0 @@
<?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 Response
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** Zend_Amf_Response */
/**
* Creates the proper http headers and send the serialized AMF stream to standard out.
*
* @package Zend_Amf
* @subpackage Response
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Response_Http extends Zend_Amf_Response
{
/**
* Create the application response header for AMF and sends the serialized AMF string
*
* @return string
*/
public function getResponse()
{
if (!headers_sent()) {
if ($this->isIeOverSsl()) {
header('Cache-Control: cache, must-revalidate');
header('Pragma: public');
} else {
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
}
header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
header('Content-Type: application/x-amf');
}
return parent::getResponse();
}
protected function isIeOverSsl()
{
$ssl = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : false;
if (!$ssl || ($ssl == 'off')) {
// IIS reports "off", whereas other browsers simply don't populate
return false;
}
$ua = $_SERVER['HTTP_USER_AGENT'];
if (!preg_match('/; MSIE \d+\.\d+;/', $ua)) {
// Not MicroSoft Internet Explorer
return false;
}
return true;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,294 +0,0 @@
<?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 Util
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* Utility class to walk through a data stream byte by byte with conventional names
*
* @package Zend_Amf
* @subpackage Util
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Util_BinaryStream
{
/**
* @var string Byte stream
*/
protected $_stream;
/**
* @var int Length of stream
*/
protected $_streamLength;
/**
* @var bool BigEndian encoding?
*/
protected $_bigEndian;
/**
* @var int Current position in stream
*/
protected $_needle;
/**
* @var bool str* functions overloaded using mbstring.func_overload?
*/
protected $_mbStringFunctionsOverloaded;
/**
* Constructor
*
* Create a reference 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.
* @return void
*/
public function __construct($stream)
{
if (!is_string($stream)) {
throw new Zend_Amf_Exception('Inputdata is not of type String');
}
$this->_stream = $stream;
$this->_needle = 0;
$this->_mbStringFunctionsOverloaded = function_exists('mb_strlen') && (ini_get('mbstring.func_overload') !== '') && ((int)ini_get('mbstring.func_overload') & 2);
$this->_streamLength = $this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream);
$this->_bigEndian = (pack('l', 1) === "\x00\x00\x00\x01");
}
/**
* Returns the current stream
*
* @return string
*/
public function getStream()
{
return $this->_stream;
}
/**
* Read the number of bytes in a row for the length supplied.
*
* @todo Should check that there are enough bytes left in the stream we are about to read.
* @param int $length
* @return string
* @throws Zend_Amf_Exception for buffer underrun
*/
public function readBytes($length)
{
if (($length + $this->_needle) > $this->_streamLength) {
throw new Zend_Amf_Exception('Buffer underrun at needle position: ' . $this->_needle . ' while requesting length: ' . $length);
}
$bytes = $this->_mbStringFunctionsOverloaded ? mb_substr($this->_stream, $this->_needle, $length, '8bit') : substr($this->_stream, $this->_needle, $length);
$this->_needle+= $length;
return $bytes;
}
/**
* Write any length of bytes to the stream
*
* Usually a string.
*
* @param string $bytes
* @return Zend_Amf_Util_BinaryStream
*/
public function writeBytes($bytes)
{
$this->_stream.= $bytes;
return $this;
}
/**
* Reads a signed byte
*
* @return int Value is in the range of -128 to 127.
* @throws Zend_Amf_Exception
*/
public function readByte()
{
if (($this->_needle + 1) > $this->_streamLength) {
throw new Zend_Amf_Exception(
'Buffer underrun at needle position: '
. $this->_needle
. ' while requesting length: '
. $this->_streamLength
);
}
return ord($this->_stream{$this->_needle++});
}
/**
* Writes the passed string into a signed byte on the stream.
*
* @param string $stream
* @return Zend_Amf_Util_BinaryStream
*/
public function writeByte($stream)
{
$this->_stream.= pack('c', $stream);
return $this;
}
/**
* Reads a signed 32-bit integer from the data stream.
*
* @return int Value is in the range of -2147483648 to 2147483647
*/
public function readInt()
{
return ($this->readByte() << 8) + $this->readByte();
}
/**
* Write an the integer to the output stream as a 32 bit signed integer
*
* @param int $stream
* @return Zend_Amf_Util_BinaryStream
*/
public function writeInt($stream)
{
$this->_stream.= pack('n', $stream);
return $this;
}
/**
* Reads a UTF-8 string from the data stream
*
* @return string A UTF-8 string produced by the byte representation of characters
*/
public function readUtf()
{
$length = $this->readInt();
return $this->readBytes($length);
}
/**
* Wite a UTF-8 string to the outputstream
*
* @param string $stream
* @return Zend_Amf_Util_BinaryStream
*/
public function writeUtf($stream)
{
$this->writeInt($this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream));
$this->_stream.= $stream;
return $this;
}
/**
* Read a long UTF string
*
* @return string
*/
public function readLongUtf()
{
$length = $this->readLong();
return $this->readBytes($length);
}
/**
* Write a long UTF string to the buffer
*
* @param string $stream
* @return Zend_Amf_Util_BinaryStream
*/
public function writeLongUtf($stream)
{
$this->writeLong($this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream));
$this->_stream.= $stream;
}
/**
* Read a long numeric value
*
* @return double
*/
public function readLong()
{
return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
}
/**
* Write long numeric value to output stream
*
* @param int|string $stream
* @return Zend_Amf_Util_BinaryStream
*/
public function writeLong($stream)
{
$this->_stream.= pack('N', $stream);
return $this;
}
/**
* Read a 16 bit unsigned short.
*
* @todo This could use the unpack() w/ S,n, or v
* @return double
*/
public function readUnsignedShort()
{
$byte1 = $this->readByte();
$byte2 = $this->readByte();
return (($byte1 << 8) | $byte2);
}
/**
* Reads an IEEE 754 double-precision floating point number from the data stream.
*
* @return double Floating point number
*/
public function readDouble()
{
$bytes = $this->_mbStringFunctionsOverloaded ? mb_substr($this->_stream, $this->_needle, 8, '8bit') : substr($this->_stream, $this->_needle, 8);
$this->_needle+= 8;
if (!$this->_bigEndian) {
$bytes = strrev($bytes);
}
$double = unpack('dflt', $bytes);
return $double['flt'];
}
/**
* Writes an IEEE 754 double-precision floating point number from the data stream.
*
* @param string|double $stream
* @return Zend_Amf_Util_BinaryStream
*/
public function writeDouble($stream)
{
$stream = pack('d', $stream);
if (!$this->_bigEndian) {
$stream = strrev($stream);
}
$this->_stream.= $stream;
return $this;
}
}

View File

@ -1,182 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* 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-2014 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

@ -1,81 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* 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
* @subpackage Value
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_MessageHeader
{
/**
* Name of the header
*
* @var string
*/
public $name;
/**
* Flag if the data has to be parsed on return
*
* @var boolean
*/
public $mustRead;
/**
* Length of the data field
*
* @var int
*/
public $length;
/**
* Data sent with the header name
*
* @var mixed
*/
public $data;
/**
* Used to create and store AMF Header data.
*
* @param String $name
* @param Boolean $mustRead
* @param misc $content
* @param integer $length
*/
public function __construct($name, $mustRead, $data, $length=null)
{
$this->name = $name;
$this->mustRead = (bool) $mustRead;
$this->data = $data;
if (null !== $length) {
$this->length = (int) $length;
}
}
}

View File

@ -1,92 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* This is the default Implementation of Message, which provides
* a convenient base for behavior and association of common endpoints
*
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_Messaging_AbstractMessage
{
/**
* @var string Client identifier
*/
public $clientId;
/**
* @var string Destination
*/
public $destination;
/**
* @var string Message identifier
*/
public $messageId;
/**
* @var int Message timestamp
*/
public $timestamp;
/**
* @var int Message TTL
*/
public $timeToLive;
/**
* @var object Message headers
*/
public $headers;
/**
* @var string Message body
*/
public $body;
/**
* generate a unique id
*
* Format is: ########-####-####-####-############
* Where # is an uppercase letter or number
* example: 6D9DC7EC-A273-83A9-ABE3-00005FD752D6
*
* @return string
*/
public function generateId()
{
return sprintf(
'%08X-%04X-%04X-%02X%02X-%012X',
mt_rand(),
mt_rand(0, 65535),
bindec(substr_replace(
sprintf('%016b', mt_rand(0, 65535)), '0100', 11, 4)
),
bindec(substr_replace(sprintf('%08b', mt_rand(0, 255)), '01', 5, 2)),
mt_rand(0, 255),
mt_rand()
);
}
}

View File

@ -1,59 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** Zend_Amf_Value_Messaging_AsyncMessage */
/**
* This is the type of message returned by the MessageBroker
* to endpoints after the broker has routed an endpoint's message
* to a service.
*
* flex.messaging.messages.AcknowledgeMessage
*
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_Messaging_AcknowledgeMessage extends Zend_Amf_Value_Messaging_AsyncMessage
{
/**
* Create a new Acknowledge Message
*
* @param unknown_type $message
*/
public function __construct($message)
{
$this->clientId = $this->generateId();
$this->destination = null;
$this->messageId = $this->generateId();
$this->timestamp = time().'00';
$this->timeToLive = 0;
$this->headers = new STDClass();
$this->body = null;
// correleate the two messages
if ($message && isset($message->messageId)) {
$this->correlationId = $message->messageId;
}
}
}

View File

@ -1,35 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* Type encapsulating Flex ArrayCollection
*
* Corresponds to flex.messaging.io.ArrayCollection
*
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_Messaging_ArrayCollection extends ArrayObject
{
}

View File

@ -1,118 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Amf_Value_Messaging_AsyncMessage
*/
/**
* 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-2014 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 SUBSCRIBE_OPERATION = 0;
/**
* This operation is used to unsubscribe from a remote destination.
*/
const UNSUSBSCRIBE_OPERATION = 1;
/**
* This operation is used to poll a remote destination for pending,
* undelivered messages.
*/
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 CLIENT_SYNC_OPERATION = 4;
/**
* This operation is used to test connectivity over the current channel to
* the remote endpoint.
*/
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 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 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 LOGOUT_OPERATION = 9;
/**
* This operation is used to indicate that the client's subscription to a
* remote destination has been invalidated.
*/
const SESSION_INVALIDATE_OPERATION = 10;
/**
* This operation is used by the MultiTopicConsumer to subscribe/unsubscribe
* from multiple subtopics/selectors in the same message.
*/
const MULTI_SUBSCRIBE_OPERATION = 11;
/**
* This operation is used to indicate that a channel has disconnected
*/
const DISCONNECT_OPERATION = 12;
/**
* This is the default operation for new CommandMessage instances.
*/
const UNKNOWN_OPERATION = 10000;
/**
* The operation to execute for messages of this type
* @var int
*/
public $operation = self::UNKNOWN_OPERATION;
}

View File

@ -1,66 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** @see Zend_Amf_Value_Messaging_AcknowledgeMessage */
/**
* 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-2014 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

@ -1,72 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/** Zend_Amf_Value_Messaging_AbstractMessage */
/**
* This type of message contains information needed to perform
* a Remoting invocation.
*
* Corresponds to flex.messaging.messages.RemotingMessage
*
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_Messaging_RemotingMessage extends Zend_Amf_Value_Messaging_AbstractMessage
{
/**
* The name of the service to be called including package name
* @var String
*/
public $source;
/**
* The name of the method to be called
* @var string
*/
public $operation;
/**
* The arguments to call the mathod with
* @var array
*/
public $parameters;
/**
* Create a new Remoting Message
*
* @return void
*/
public function __construct()
{
$this->clientId = $this->generateId();
$this->destination = null;
$this->messageId = $this->generateId();
$this->timestamp = time().'00';
$this->timeToLive = 0;
$this->headers = new stdClass();
$this->body = null;
}
}

View File

@ -1,154 +0,0 @@
<?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-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* Zend_Amf_Value_TraitsInfo
*
* @package Zend_Amf
* @subpackage Value
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Amf_Value_TraitsInfo
{
/**
* @var string Class name
*/
protected $_className;
/**
* @var bool Whether or not this is a dynamic class
*/
protected $_dynamic;
/**
* @var bool Whether or not the class is externalizable
*/
protected $_externalizable;
/**
* @var array Class properties
*/
protected $_properties;
/**
* Used to keep track of all class traits of an AMF3 object
*
* @param string $className
* @param boolean $dynamic
* @param boolean $externalizable
* @param boolean $properties
* @return void
*/
public function __construct($className, $dynamic=false, $externalizable=false, $properties=null)
{
$this->_className = $className;
$this->_dynamic = $dynamic;
$this->_externalizable = $externalizable;
$this->_properties = $properties;
}
/**
* Test if the class is a dynamic class
*
* @return boolean
*/
public function isDynamic()
{
return $this->_dynamic;
}
/**
* Test if class is externalizable
*
* @return boolean
*/
public function isExternalizable()
{
return $this->_externalizable;
}
/**
* Return the number of properties in the class
*
* @return int
*/
public function length()
{
return count($this->_properties);
}
/**
* Return the class name
*
* @return string
*/
public function getClassName()
{
return $this->_className;
}
/**
* Add an additional property
*
* @param string $name
* @return Zend_Amf_Value_TraitsInfo
*/
public function addProperty($name)
{
$this->_properties[] = $name;
return $this;
}
/**
* Add all properties of the class.
*
* @param array $props
* @return Zend_Amf_Value_TraitsInfo
*/
public function addAllProperties(array $props)
{
$this->_properties = $props;
return $this;
}
/**
* Get the property at a given index
*
* @param int $index
* @return string
*/
public function getProperty($index)
{
return $this->_properties[(int) $index];
}
/**
* Return all properties of the class.
*
* @return array
*/
public function getAllProperties()
{
return $this->_properties;
}
}

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Application
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -22,7 +22,7 @@
/**
* @category Zend
* @package Zend_Application
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application
@ -70,14 +70,16 @@ class Zend_Application
*
* @param string $environment
* @param string|array|Zend_Config $options String path to configuration file, or array/Zend_Config of configuration options
* @param bool $suppressNotFoundWarnings Should warnings be suppressed when a file is not found during autoloading?
* @throws Zend_Application_Exception When invalid options are provided
* @return void
*/
public function __construct($environment, $options = null)
public function __construct($environment, $options = null, $suppressNotFoundWarnings = null)
{
$this->_environment = (string) $environment;
$this->_autoloader = Zend_Loader_Autoloader::getInstance();
$this->_autoloader->suppressNotFoundWarnings($suppressNotFoundWarnings);
if (null !== $options) {
if (is_string($options)) {
@ -85,7 +87,10 @@ class Zend_Application
} elseif ($options instanceof Zend_Config) {
$options = $options->toArray();
} elseif (!is_array($options)) {
throw new Zend_Application_Exception('Invalid options provided; must be location of config file, a config object, or an array');
throw new Zend_Application_Exception(
'Invalid options provided; must be location of config file,'
. ' a config object, or an array'
);
}
$this->setOptions($options);
@ -126,11 +131,15 @@ class Zend_Application
if (is_array($options['config'])) {
$_options = array();
foreach ($options['config'] as $tmp) {
$_options = $this->mergeOptions($_options, $this->_loadConfig($tmp));
$_options = $this->mergeOptions(
$_options, $this->_loadConfig($tmp)
);
}
$options = $this->mergeOptions($_options, $options);
} else {
$options = $this->mergeOptions($this->_loadConfig($options['config']), $options);
$options = $this->mergeOptions(
$this->_loadConfig($options['config']), $options
);
}
}
@ -170,7 +179,9 @@ class Zend_Application
$this->setBootstrap($bootstrap);
} elseif (is_array($bootstrap)) {
if (empty($bootstrap['path'])) {
throw new Zend_Application_Exception('No bootstrap path provided');
throw new Zend_Application_Exception(
'No bootstrap path provided'
);
}
$path = $bootstrap['path'];
@ -182,7 +193,9 @@ class Zend_Application
$this->setBootstrap($path, $class);
} else {
throw new Zend_Application_Exception('Invalid bootstrap information provided');
throw new Zend_Application_Exception(
'Invalid bootstrap information provided'
);
}
}
@ -317,13 +330,18 @@ class Zend_Application
if (!class_exists($class, false)) {
if (!class_exists($class, false)) {
throw new Zend_Application_Exception('Bootstrap class not found');
throw new Zend_Application_Exception(
'Bootstrap class not found'
);
}
}
$this->_bootstrap = new $class($this);
if (!$this->_bootstrap instanceof Zend_Application_Bootstrap_Bootstrapper) {
throw new Zend_Application_Exception('Bootstrap class does not implement Zend_Application_Bootstrap_Bootstrapper');
throw new Zend_Application_Exception(
'Bootstrap class does not implement'
. ' Zend_Application_Bootstrap_Bootstrapper'
);
}
return $this;
@ -401,13 +419,18 @@ class Zend_Application
case 'inc':
$config = include $file;
if (!is_array($config)) {
throw new Zend_Application_Exception('Invalid configuration file provided; PHP file does not return array value');
throw new Zend_Application_Exception(
'Invalid configuration file provided; PHP file does not'
. ' return array value'
);
}
return $config;
break;
default:
throw new Zend_Application_Exception('Invalid configuration file provided; unknown config type');
throw new Zend_Application_Exception(
'Invalid configuration file provided; unknown config type'
);
}
return $config->toArray();

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Bootstrap
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -33,7 +33,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Bootstrap
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Bootstrap_Bootstrap
@ -63,9 +63,13 @@ class Zend_Application_Bootstrap_Bootstrap
parent::__construct($application);
if ($application->hasOption('resourceloader')) {
$this->setOptions(array(
'resourceloader' => $application->getOption('resourceloader')
));
$this->setOptions(
array(
'resourceloader' => $application->getOption(
'resourceloader'
)
)
);
}
$this->getResourceLoader();
@ -127,10 +131,14 @@ class Zend_Application_Bootstrap_Bootstrap
) {
$r = new ReflectionClass($this);
$path = $r->getFileName();
$this->setResourceLoader(new Zend_Application_Module_Autoloader(array(
$this->setResourceLoader(
new Zend_Application_Module_Autoloader(
array(
'namespace' => $namespace,
'basePath' => dirname($path),
)));
)
)
);
}
return $this->_resourceLoader;
}

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Bootstrap
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -36,7 +36,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Bootstrap
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Application_Bootstrap_BootstrapAbstract

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Bootstrap
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -26,7 +26,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Bootstrap
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Application_Bootstrap_Bootstrapper

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Application
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -29,7 +29,7 @@
* @category Zend
* @package Zend_Application
* @uses Zend_Application_Exception
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Bootstrap_Exception extends Zend_Application_Exception

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Bootstrap
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -26,7 +26,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Bootstrap
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Application_Bootstrap_ResourceBootstrapper

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Application
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -29,7 +29,7 @@
* @uses Zend_Exception
* @category Zend
* @package Zend_Application
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Exception extends Zend_Exception

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Module
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id$
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@ -29,7 +29,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Module
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Module_Autoloader extends Zend_Loader_Autoloader_Resource
@ -53,7 +53,8 @@ class Zend_Application_Module_Autoloader extends Zend_Loader_Autoloader_Resource
public function initDefaultResourceTypes()
{
$basePath = $this->getBasePath();
$this->addResourceTypes(array(
$this->addResourceTypes(
array(
'dbtable' => array(
'namespace' => 'Model_DbTable',
'path' => 'models/DbTable',
@ -86,7 +87,8 @@ class Zend_Application_Module_Autoloader extends Zend_Loader_Autoloader_Resource
'namespace' => 'View_Filter',
'path' => 'views/filters',
),
));
)
);
$this->setDefaultResourceType('model');
}
}

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Module
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id$
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@ -32,7 +32,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Module
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 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

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -27,7 +27,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Cachemanager extends Zend_Application_Resource_ResourceAbstract

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -31,7 +31,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Db extends Zend_Application_Resource_ResourceAbstract

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -32,7 +32,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Dojo

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -31,7 +31,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Exception extends Zend_Application_Exception

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -31,7 +31,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Frontcontroller extends Zend_Application_Resource_ResourceAbstract
@ -71,7 +71,7 @@ class Zend_Application_Resource_Frontcontroller extends Zend_Application_Resourc
if (is_string($value)) {
$front->addModuleDirectory($value);
} elseif (is_array($value)) {
foreach($value as $moduleDir) {
foreach ($value as $moduleDir) {
$front->addModuleDirectory($moduleDir);
}
}
@ -102,11 +102,10 @@ class Zend_Application_Resource_Frontcontroller extends Zend_Application_Resourc
case 'plugins':
foreach ((array) $value as $pluginClass) {
$stackIndex = null;
if(is_array($pluginClass)) {
if (is_array($pluginClass)) {
$pluginClass = array_change_key_case($pluginClass, CASE_LOWER);
if(isset($pluginClass['class']))
{
if(isset($pluginClass['stackindex'])) {
if (isset($pluginClass['class'])) {
if (isset($pluginClass['stackindex'])) {
$stackIndex = $pluginClass['stackindex'];
}
@ -136,7 +135,7 @@ class Zend_Application_Resource_Frontcontroller extends Zend_Application_Resourc
break;
case 'dispatcher':
if(!isset($value['class'])) {
if (!isset($value['class'])) {
throw new Zend_Application_Exception('You must specify both ');
}
if (!isset($value['params'])) {
@ -144,7 +143,7 @@ class Zend_Application_Resource_Frontcontroller extends Zend_Application_Resourc
}
$dispatchClass = $value['class'];
if(!class_exists($dispatchClass)) {
if (!class_exists($dispatchClass)) {
throw new Zend_Application_Exception('Dispatcher class not found!');
}
$front->setDispatcher(new $dispatchClass((array)$value['params']));

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -32,7 +32,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Layout

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -32,7 +32,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Locale
@ -67,9 +67,9 @@ class Zend_Application_Resource_Locale
if (!isset($options['default'])) {
$this->_locale = new Zend_Locale();
} elseif(!isset($options['force']) ||
(bool) $options['force'] == false)
{
} elseif (!isset($options['force'])
|| (bool)$options['force'] == false
) {
// Don't force any locale, just go for auto detection
Zend_Locale::setDefault($options['default']);
$this->_locale = new Zend_Locale();

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -32,7 +32,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Log

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -31,7 +31,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceAbstract
@ -42,7 +42,8 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
*/
protected $_transport;
public function init() {
public function init()
{
return $this->getMail();
}
@ -54,21 +55,21 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
{
if (null === $this->_transport) {
$options = $this->getOptions();
foreach($options as $key => $option) {
foreach ($options as $key => $option) {
$options[strtolower($key)] = $option;
}
$this->setOptions($options);
if(isset($options['transport']) &&
!is_numeric($options['transport']))
{
if (isset($options['transport'])
&& !is_numeric($options['transport'])
) {
$this->_transport = $this->_setupTransport($options['transport']);
if(!isset($options['transport']['register']) ||
$options['transport']['register'] == '1' ||
(isset($options['transport']['register']) &&
!is_numeric($options['transport']['register']) &&
(bool) $options['transport']['register'] == true))
{
if (!isset($options['transport']['register'])
|| $options['transport']['register'] == '1'
|| (isset($options['transport']['register'])
&& !is_numeric($options['transport']['register'])
&& (bool)$options['transport']['register'] == true)
) {
Zend_Mail::setDefaultTransport($this->_transport);
}
}
@ -80,19 +81,23 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
return $this->_transport;
}
protected function _setDefaults($type) {
protected function _setDefaults($type)
{
$key = strtolower('default' . $type);
$options = $this->getOptions();
if(isset($options[$key]['email']) &&
!is_numeric($options[$key]['email']))
{
if (isset($options[$key]['email'])
&& !is_numeric($options[$key]['email'])
) {
$method = array('Zend_Mail', 'setDefault' . ucfirst($type));
if(isset($options[$key]['name']) &&
!is_numeric($options[$key]['name']))
{
call_user_func($method, $options[$key]['email'],
$options[$key]['name']);
if (isset($options[$key]['name'])
&& !is_numeric(
$options[$key]['name']
)
) {
call_user_func(
$method, $options[$key]['email'], $options[$key]['name']
);
} else {
call_user_func($method, $options[$key]['email']);
}
@ -101,19 +106,17 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
protected function _setupTransport($options)
{
if(!isset($options['type'])) {
if (!isset($options['type'])) {
$options['type'] = 'sendmail';
}
$transportName = $options['type'];
if(!Zend_Loader_Autoloader::autoload($transportName))
{
if (!Zend_Loader_Autoloader::autoload($transportName)) {
$transportName = ucfirst(strtolower($transportName));
if(!Zend_Loader_Autoloader::autoload($transportName))
{
if (!Zend_Loader_Autoloader::autoload($transportName)) {
$transportName = 'Zend_Mail_Transport_' . $transportName;
if(!Zend_Loader_Autoloader::autoload($transportName)) {
if (!Zend_Loader_Autoloader::autoload($transportName)) {
throw new Zend_Application_Resource_Exception(
"Specified Mail Transport '{$transportName}'"
. 'could not be found'
@ -127,10 +130,11 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
switch($transportName) {
case 'Zend_Mail_Transport_Smtp':
if(!isset($options['host'])) {
if (!isset($options['host'])) {
throw new Zend_Application_Resource_Exception(
'A host is necessary for smtp transport,'
.' but none was given');
. ' but none was given'
);
}
$transport = new $transportName($options['host'], $options);

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -31,7 +31,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Modules extends Zend_Application_Resource_ResourceAbstract
@ -78,16 +78,20 @@ class Zend_Application_Resource_Modules extends Zend_Application_Resource_Resour
if (($default != $module)
&& !class_exists($bootstrapClass, false)
) {
throw new Zend_Application_Resource_Exception(sprintf(
throw new Zend_Application_Resource_Exception(
sprintf(
$eMsgTpl, $module, $bootstrapClass
));
)
);
} elseif ($default == $module) {
if (!class_exists($bootstrapClass, false)) {
$bootstrapClass = 'Bootstrap';
if (!class_exists($bootstrapClass, false)) {
throw new Zend_Application_Resource_Exception(sprintf(
throw new Zend_Application_Resource_Exception(
sprintf(
$eMsgTpl, $module, $bootstrapClass
));
)
);
}
}
}
@ -117,7 +121,7 @@ class Zend_Application_Resource_Modules extends Zend_Application_Resource_Resour
$bootstrap = $this->getBootstrap();
$out = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
foreach($bootstraps as $module => $bootstrapClass) {
foreach ($bootstraps as $module => $bootstrapClass) {
$moduleBootstrap = new $bootstrapClass($bootstrap);
$moduleBootstrap->bootstrap();
$out[$module] = $moduleBootstrap;

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -49,7 +49,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Multidb extends Zend_Application_Resource_ResourceAbstract
@ -112,7 +112,7 @@ class Zend_Application_Resource_Multidb extends Zend_Application_Resource_Resour
*/
public function isDefault($db)
{
if(!$db instanceof Zend_Db_Adapter_Abstract) {
if (!$db instanceof Zend_Db_Adapter_Abstract) {
$db = $this->getDb($db);
}

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -32,7 +32,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @author Dolf Schimmel
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@ -56,8 +56,10 @@ class Zend_Application_Resource_Navigation
if (!$this->_container) {
$options = $this->getOptions();
if(isset($options['defaultPageType'])) {
Zend_Navigation_Page::setDefaultPageType($options['defaultPageType']);
if (isset($options['defaultPageType'])) {
Zend_Navigation_Page::setDefaultPageType(
$options['defaultPageType']
);
}
$pages = isset($options['pages']) ? $options['pages'] : array();
@ -92,15 +94,16 @@ class Zend_Application_Resource_Navigation
protected function _storeRegistry()
{
$options = $this->getOptions();
if(isset($options['storage']['registry']['key']) &&
!is_numeric($options['storage']['registry']['key'])) // see ZF-7461
{
// see ZF-7461
if (isset($options['storage']['registry']['key'])
&& !is_numeric($options['storage']['registry']['key'])
) {
$key = $options['storage']['registry']['key'];
} else {
$key = self::DEFAULT_REGISTRY_KEY;
}
Zend_Registry::set($key,$this->getContainer());
Zend_Registry::set($key, $this->getContainer());
}
/**

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -26,7 +26,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Application_Resource_Resource

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -31,7 +31,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Application_Resource_ResourceAbstract implements Zend_Application_Resource_Resource

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -32,7 +32,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Router

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -32,7 +32,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Session extends Zend_Application_Resource_ResourceAbstract

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -32,7 +32,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_Translate extends Zend_Application_Resource_ResourceAbstract
@ -90,7 +90,7 @@ class Zend_Application_Resource_Translate extends Zend_Application_Resource_Reso
}
if (isset($options['options'])) {
foreach($options['options'] as $key => $value) {
foreach ($options['options'] as $key => $value) {
$options[$key] = $value;
}
}
@ -115,12 +115,14 @@ class Zend_Application_Resource_Translate extends Zend_Application_Resource_Reso
: self::DEFAULT_REGISTRY_KEY;
unset($options['registry_key']);
if(Zend_Registry::isRegistered($key)) {
if (Zend_Registry::isRegistered($key)) {
$translate = Zend_Registry::get($key);
if(!$translate instanceof Zend_Translate) {
throw new Zend_Application_Resource_Exception($key
if (!$translate instanceof Zend_Translate) {
throw new Zend_Application_Resource_Exception(
$key
. ' already registered in registry but is '
. 'no instance of Zend_Translate');
. 'no instance of Zend_Translate'
);
}
$translate->addTranslation($options);

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@ -23,7 +23,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_UserAgent extends Zend_Application_Resource_ResourceAbstract

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -32,7 +32,7 @@
* @category Zend
* @package Zend_Application
* @subpackage Resource
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Application_Resource_View extends Zend_Application_Resource_ResourceAbstract

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Auth
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -23,7 +23,7 @@
/**
* @category Zend
* @package Zend_Auth
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Adapter
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -38,7 +38,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Adapter
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Adapter
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -30,7 +30,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Adapter
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth_Adapter_Digest implements Zend_Auth_Adapter_Interface

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Adapter
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -30,7 +30,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Adapter
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth_Adapter_Exception extends Zend_Auth_Exception

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter_Http
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -34,7 +34,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter_Http
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @todo Support auth-int
* @todo Track nonces, nonce-count, opaque for replay protection and stale support

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter_Http
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -32,7 +32,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter_Http
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth_Adapter_Http_Resolver_Exception extends Zend_Auth_Exception

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter_Http
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -32,7 +32,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter_Http
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth_Adapter_Http_Resolver_File implements Zend_Auth_Adapter_Http_Resolver_Interface

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter_Http
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -30,7 +30,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter_Http
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Auth_Adapter_Http_Resolver_Interface

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -30,7 +30,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Auth_Adapter_Interface

View File

@ -0,0 +1,526 @@
<?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_Auth
* @subpackage Zend_Auth_Adapter
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Auth_Adapter_Interface
*/
/**
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface
{
/**
* The Zend_Ldap context.
*
* @var Zend_Ldap
*/
protected $_ldap = null;
/**
* The array of arrays of Zend_Ldap options passed to the constructor.
*
* @var array
*/
protected $_options = null;
/**
* The username of the account being authenticated.
*
* @var string
*/
protected $_username = null;
/**
* The password of the account being authenticated.
*
* @var string
*/
protected $_password = null;
/**
* The DN of the authenticated account. Used to retrieve the account entry on request.
*
* @var string
*/
protected $_authenticatedDn = null;
/**
* Constructor
*
* @param array $options An array of arrays of Zend_Ldap options
* @param string $username The username of the account being authenticated
* @param string $password The password of the account being authenticated
*/
public function __construct(array $options = array(), $username = null, $password = null)
{
$this->setOptions($options);
if ($username !== null) {
$this->setUsername($username);
}
if ($password !== null) {
$this->setPassword($password);
}
}
/**
* Returns the array of arrays of Zend_Ldap options of this adapter.
*
* @return array|null
*/
public function getOptions()
{
return $this->_options;
}
/**
* Sets the array of arrays of Zend_Ldap options to be used by
* this adapter.
*
* @param array $options The array of arrays of Zend_Ldap options
* @return Zend_Auth_Adapter_Ldap Provides a fluent interface
*/
public function setOptions($options)
{
$this->_options = is_array($options) ? $options : array();
return $this;
}
/**
* Returns the username of the account being authenticated, or
* NULL if none is set.
*
* @return string|null
*/
public function getUsername()
{
return $this->_username;
}
/**
* Sets the username for binding
*
* @param string $username The username for binding
* @return Zend_Auth_Adapter_Ldap Provides a fluent interface
*/
public function setUsername($username)
{
$this->_username = (string) $username;
return $this;
}
/**
* Returns the password of the account being authenticated, or
* NULL if none is set.
*
* @return string|null
*/
public function getPassword()
{
return $this->_password;
}
/**
* Sets the passwort for the account
*
* @param string $password The password of the account being authenticated
* @return Zend_Auth_Adapter_Ldap Provides a fluent interface
*/
public function setPassword($password)
{
$this->_password = (string) $password;
return $this;
}
/**
* setIdentity() - set the identity (username) to be used
*
* Proxies to {@see setUsername()}
*
* Closes ZF-6813
*
* @param string $identity
* @return Zend_Auth_Adapter_Ldap Provides a fluent interface
*/
public function setIdentity($identity)
{
return $this->setUsername($identity);
}
/**
* setCredential() - set the credential (password) value to be used
*
* Proxies to {@see setPassword()}
*
* Closes ZF-6813
*
* @param string $credential
* @return Zend_Auth_Adapter_Ldap Provides a fluent interface
*/
public function setCredential($credential)
{
return $this->setPassword($credential);
}
/**
* Returns the LDAP Object
*
* @return Zend_Ldap The Zend_Ldap object used to authenticate the credentials
*/
public function getLdap()
{
if ($this->_ldap === null) {
/**
* @see Zend_Ldap
*/
$this->_ldap = new Zend_Ldap();
}
return $this->_ldap;
}
/**
* Set an Ldap connection
*
* @param Zend_Ldap $ldap An existing Ldap object
* @return Zend_Auth_Adapter_Ldap Provides a fluent interface
*/
public function setLdap(Zend_Ldap $ldap)
{
$this->_ldap = $ldap;
$this->setOptions(array($ldap->getOptions()));
return $this;
}
/**
* Returns a domain name for the current LDAP options. This is used
* for skipping redundant operations (e.g. authentications).
*
* @return string
*/
protected function _getAuthorityName()
{
$options = $this->getLdap()->getOptions();
$name = $options['accountDomainName'];
if (!$name)
$name = $options['accountDomainNameShort'];
return $name ? $name : '';
}
/**
* Authenticate the user
*
* @throws Zend_Auth_Adapter_Exception
* @return Zend_Auth_Result
*/
public function authenticate()
{
/**
* @see Zend_Ldap_Exception
*/
$messages = array();
$messages[0] = ''; // reserved
$messages[1] = ''; // reserved
$username = $this->_username;
$password = $this->_password;
if (!$username) {
$code = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
$messages[0] = 'A username is required';
return new Zend_Auth_Result($code, '', $messages);
}
if (!$password) {
/* A password is required because some servers will
* treat an empty password as an anonymous bind.
*/
$code = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
$messages[0] = 'A password is required';
return new Zend_Auth_Result($code, '', $messages);
}
$ldap = $this->getLdap();
$code = Zend_Auth_Result::FAILURE;
$messages[0] = "Authority not found: $username";
$failedAuthorities = array();
/* Iterate through each server and try to authenticate the supplied
* credentials against it.
*/
foreach ($this->_options as $name => $options) {
if (!is_array($options)) {
/**
* @see Zend_Auth_Adapter_Exception
*/
throw new Zend_Auth_Adapter_Exception('Adapter options array not an array');
}
$adapterOptions = $this->_prepareOptions($ldap, $options);
$dname = '';
try {
if ($messages[1])
$messages[] = $messages[1];
$messages[1] = '';
$messages[] = $this->_optionsToString($options);
$dname = $this->_getAuthorityName();
if (isset($failedAuthorities[$dname])) {
/* If multiple sets of server options for the same domain
* are supplied, we want to skip redundant authentications
* where the identity or credentials where found to be
* invalid with another server for the same domain. The
* $failedAuthorities array tracks this condition (and also
* serves to supply the original error message).
* This fixes issue ZF-4093.
*/
$messages[1] = $failedAuthorities[$dname];
$messages[] = "Skipping previously failed authority: $dname";
continue;
}
$canonicalName = $ldap->getCanonicalAccountName($username);
$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 optionally
* "password" in the Zend_Ldap options is able to retrieve the required
* information.
*/
$requireRebind = false;
if (isset($options['username'])) {
$ldap->bind();
$requireRebind = true;
}
$dn = $ldap->getCanonicalAccountName($canonicalName, Zend_Ldap::ACCTNAME_FORM_DN);
$groupResult = $this->_checkGroupMembership($ldap, $canonicalName, $dn, $adapterOptions);
if ($groupResult === true) {
$this->_authenticatedDn = $dn;
$messages[0] = '';
$messages[1] = '';
$messages[] = "$canonicalName authentication successful";
if ($requireRebind === true) {
// 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';
$messages[1] = $groupResult;
$failedAuthorities[$dname] = $groupResult;
}
} catch (Zend_Ldap_Exception $zle) {
/* LDAP based authentication is notoriously difficult to diagnose. Therefore
* we bend over backwards to capture and record every possible bit of
* information when something goes wrong.
*/
$err = $zle->getCode();
if ($err == Zend_Ldap_Exception::LDAP_X_DOMAIN_MISMATCH) {
/* This error indicates that the domain supplied in the
* username did not match the domains in the server options
* and therefore we should just skip to the next set of
* server options.
*/
continue;
} else if ($err == Zend_Ldap_Exception::LDAP_NO_SUCH_OBJECT) {
$code = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
$messages[0] = "Account not found: $username";
$failedAuthorities[$dname] = $zle->getMessage();
} else if ($err == Zend_Ldap_Exception::LDAP_INVALID_CREDENTIALS) {
$code = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
$messages[0] = 'Invalid credentials';
$failedAuthorities[$dname] = $zle->getMessage();
} else {
$line = $zle->getLine();
$messages[] = $zle->getFile() . "($line): " . $zle->getMessage();
$messages[] = preg_replace(
'/\b'.preg_quote(substr($password, 0, 15), '/').'\b/',
'*****',
$zle->getTraceAsString()
);
$messages[0] = 'An unexpected failure occurred';
}
$messages[1] = $zle->getMessage();
}
}
$msg = isset($messages[1]) ? $messages[1] : $messages[0];
$messages[] = "$username authentication failed: $msg";
return new Zend_Auth_Result($code, $username, $messages);
}
/**
* Sets the LDAP specific options on the Zend_Ldap instance
*
* @param Zend_Ldap $ldap
* @param array $options
* @return array of auth-adapter specific options
*/
protected function _prepareOptions(Zend_Ldap $ldap, array $options)
{
$adapterOptions = array(
'group' => null,
'groupDn' => $ldap->getBaseDn(),
'groupScope' => Zend_Ldap::SEARCH_SCOPE_SUB,
'groupAttr' => 'cn',
'groupFilter' => 'objectClass=groupOfUniqueNames',
'memberAttr' => 'uniqueMember',
'memberIsDn' => true
);
foreach ($adapterOptions as $key => $value) {
if (array_key_exists($key, $options)) {
$value = $options[$key];
unset($options[$key]);
switch ($key) {
case 'groupScope':
$value = (int)$value;
if (in_array($value, array(Zend_Ldap::SEARCH_SCOPE_BASE,
Zend_Ldap::SEARCH_SCOPE_ONE, Zend_Ldap::SEARCH_SCOPE_SUB), true)) {
$adapterOptions[$key] = $value;
}
break;
case 'memberIsDn':
$adapterOptions[$key] = ($value === true ||
$value === '1' || strcasecmp($value, 'true') == 0);
break;
default:
$adapterOptions[$key] = trim($value);
break;
}
}
}
$ldap->setOptions($options);
return $adapterOptions;
}
/**
* Checks the group membership of the bound user
*
* @param Zend_Ldap $ldap
* @param string $canonicalName
* @param string $dn
* @param array $adapterOptions
* @return string|true
*/
protected function _checkGroupMembership(Zend_Ldap $ldap, $canonicalName, $dn, array $adapterOptions)
{
if ($adapterOptions['group'] === null) {
return true;
}
if ($adapterOptions['memberIsDn'] === false) {
$user = $canonicalName;
} else {
$user = $dn;
}
/**
* @see Zend_Ldap_Filter
*/
$groupName = Zend_Ldap_Filter::equals($adapterOptions['groupAttr'], $adapterOptions['group']);
$membership = Zend_Ldap_Filter::equals($adapterOptions['memberAttr'], $user);
$group = Zend_Ldap_Filter::andFilter($groupName, $membership);
$groupFilter = $adapterOptions['groupFilter'];
if (!empty($groupFilter)) {
$group = $group->addAnd($groupFilter);
}
$result = $ldap->count($group, $adapterOptions['groupDn'], $adapterOptions['groupScope']);
if ($result === 1) {
return true;
} else {
return 'Failed to verify group membership with ' . $group->toString();
}
}
/**
* getAccountObject() - Returns the result entry as a stdClass object
*
* This resembles the feature {@see Zend_Auth_Adapter_DbTable::getResultRowObject()}.
* Closes ZF-6813
*
* @param array $returnAttribs
* @param array $omitAttribs
* @return stdClass|boolean
*/
public function getAccountObject(array $returnAttribs = array(), array $omitAttribs = array())
{
if (!$this->_authenticatedDn) {
return false;
}
$returnObject = new stdClass();
$returnAttribs = array_map('strtolower', $returnAttribs);
$omitAttribs = array_map('strtolower', $omitAttribs);
$returnAttribs = array_diff($returnAttribs, $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 {
$returnObject->$attr = $value;
}
}
return $returnObject;
}
/**
* Converts options to string
*
* @param array $options
* @return string
*/
private function _optionsToString(array $options)
{
$str = '';
foreach ($options as $key => $val) {
if ($key === 'password')
$val = '*****';
if ($str)
$str .= ',';
$str .= $key . '=' . $val;
}
return $str;
}
}

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -38,7 +38,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Zend_Auth_Adapter
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth_Adapter_OpenId implements Zend_Auth_Adapter_Interface

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Auth
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -28,7 +28,7 @@
/**
* @category Zend
* @package Zend_Auth
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth_Exception extends Zend_Exception

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Auth
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -23,7 +23,7 @@
/**
* @category Zend
* @package Zend_Auth
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth_Result

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Storage
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -30,7 +30,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Storage
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth_Storage_Exception extends Zend_Auth_Exception

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Storage
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -24,7 +24,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Storage
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Auth_Storage_Interface

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Storage
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -36,7 +36,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Storage
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth_Storage_NonPersistent implements Zend_Auth_Storage_Interface

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Storage
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -35,7 +35,7 @@
* @category Zend
* @package Zend_Auth
* @subpackage Storage
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Auth_Storage_Session implements Zend_Auth_Storage_Interface

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -24,7 +24,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -27,7 +27,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Exception extends Zend_Exception

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Code25.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
@ -33,7 +33,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Code128 extends Zend_Barcode_Object_ObjectAbstract

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -33,7 +33,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Code25 extends Zend_Barcode_Object_ObjectAbstract

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -29,7 +29,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Code25interleaved extends Zend_Barcode_Object_Code25

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -33,7 +33,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Code39 extends Zend_Barcode_Object_ObjectAbstract

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -33,7 +33,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Ean13 extends Zend_Barcode_Object_ObjectAbstract

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -33,7 +33,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Ean2 extends Zend_Barcode_Object_Ean5

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -33,7 +33,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Ean5 extends Zend_Barcode_Object_Ean13

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -33,7 +33,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Ean8 extends Zend_Barcode_Object_Ean13

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -27,7 +27,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Error extends Zend_Barcode_Object_ObjectAbstract

View File

@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -26,7 +26,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Exception extends Zend_Barcode_Exception

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -33,7 +33,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Identcode extends Zend_Barcode_Object_Code25interleaved

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -29,7 +29,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Itf14 extends Zend_Barcode_Object_Code25interleaved

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -33,7 +33,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Leitcode extends Zend_Barcode_Object_Identcode

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -25,55 +25,63 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Barcode_Object_ObjectAbstract
{
/**
* Namespace of the barcode for autoloading
*
* @var string
*/
protected $_barcodeNamespace = 'Zend_Barcode_Object';
/**
* Set of drawing instructions
*
* @var array
*/
protected $_instructions = array();
/**
* Barcode type
*
* @var string
*/
protected $_type = null;
/**
* Height of the object
*
* @var integer
*/
protected $_height = null;
/**
* Width of the object
*
* @var integer
*/
protected $_width = null;
/**
* Height of the bar
*
* @var integer
*/
protected $_barHeight = 50;
/**
* Width of a thin bar
*
* @var integer
*/
protected $_barThinWidth = 1;
/**
* Width of a thick bar
*
* @var integer
*/
protected $_barThickWidth = 3;
@ -81,42 +89,49 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Factor to multiply bar and font measure
* (barHeight, barThinWidth, barThickWidth & fontSize)
*
* @var integer
*/
protected $_factor = 1;
/**
* Font and bars color of the object
*
* @var integer
*/
protected $_foreColor = 0x000000;
/**
* Background color of the object
*
* @var integer
*/
protected $_backgroundColor = 0xFFFFFF;
/**
* Activate/deactivate border of the object
*
* @var boolean
*/
protected $_withBorder = false;
/**
* Activate/deactivate drawing of quiet zones
*
* @var boolean
*/
protected $_withQuietZones = true;
/**
* Force quiet zones even if
*
* @var boolean
*/
protected $_mandatoryQuietZones = false;
/**
* Orientation of the barcode in degrees
*
* @var float
*/
protected $_orientation = 0;
@ -124,6 +139,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Offset from the top the object
* (calculated from the orientation)
*
* @var integer
*/
protected $_offsetTop = null;
@ -131,24 +147,28 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Offset from the left the object
* (calculated from the orientation)
*
* @var integer
*/
protected $_offsetLeft = null;
/**
* Text to display
*
* @var string
*/
protected $_text = null;
/**
* Display (or not) human readable text
*
* @var boolean
*/
protected $_drawText = true;
/**
* Adjust (or not) position of human readable characters with barcode
*
* @var boolean
*/
protected $_stretchText = false;
@ -157,30 +177,35 @@ abstract class Zend_Barcode_Object_ObjectAbstract
* Font resource
* - integer (1 to 5): corresponds to GD included fonts
* - string: corresponds to path of a TTF font
*
* @var integer|string
*/
protected $_font = null;
/**
* Font size
*
* @var float
*/
protected $_fontSize = 10;
/**
* Drawing of checksum
*
* @var boolean
*/
protected $_withChecksum = false;
/**
* Drawing of checksum inside text
*
* @var boolean
*/
protected $_withChecksumInText = false;
/**
* Fix barcode length (numeric or string like 'even')
*
* @var $_barcodeLength integer | string
*/
protected $_barcodeLength = null;
@ -188,6 +213,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Activate automatic addition of leading zeros
* if barcode length is fixed
*
* @var $_addLeadingZeros boolean
*/
protected $_addLeadingZeros = true;
@ -195,18 +221,21 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Activation of mandatory checksum
* to deactivate unauthorized modification
*
* @var $_mandatoryChecksum boolean
*/
protected $_mandatoryChecksum = false;
/**
* Character used to substitute checksum character for validation
*
* @var $_substituteChecksumCharacter mixed
*/
protected $_substituteChecksumCharacter = 0;
/**
* TTF font name: can be set before instanciation of the object
*
* @var string
*/
protected static $_staticFont = null;
@ -228,7 +257,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
if (is_array($options)) {
$this->setOptions($options);
}
$this->_type = strtolower(substr(get_class($this), strlen($this->_barcodeNamespace) + 1));
$this->_type = strtolower(
substr(get_class($this), strlen($this->_barcodeNamespace) + 1)
);
if ($this->_mandatoryChecksum) {
$this->_withChecksum = true;
$this->_withChecksumInText = true;
@ -237,7 +268,6 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Set default options for particular object
* @return void
*/
protected function _getDefaultOptions()
{
@ -245,8 +275,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Set barcode state from options array
*
* @param array $options
* @return Zend_Barcode_Object
* @return $this
*/
public function setOptions($options)
{
@ -261,8 +292,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Set barcode state from config object
*
* @param Zend_Config $config
* @return Zend_Barcode_Object
* @return $this
*/
public function setConfig(Zend_Config $config)
{
@ -273,7 +305,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
* Set barcode namespace for autoloading
*
* @param string $namespace
* @return Zend_Barcode_Object
* @return $this
*/
public function setBarcodeNamespace($namespace)
{
@ -293,6 +325,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve type of barcode
*
* @return string
*/
public function getType()
@ -302,8 +335,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Set height of the barcode bar
*
* @param integer $value
* @return Zend_Barcode_Object
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
public function setBarHeight($value)
@ -319,6 +353,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Get height of the barcode bar
*
* @return integer
*/
public function getBarHeight()
@ -328,8 +363,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Set thickness of thin bar
*
* @param integer $value
* @return Zend_Barcode_Object
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
public function setBarThinWidth($value)
@ -345,6 +381,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Get thickness of thin bar
*
* @return integer
*/
public function getBarThinWidth()
@ -354,8 +391,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Set thickness of thick bar
*
* @param integer $value
* @return Zend_Barcode_Object
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
public function setBarThickWidth($value)
@ -371,6 +409,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Get thickness of thick bar
*
* @return integer
*/
public function getBarThickWidth()
@ -381,8 +420,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Set factor applying to
* thinBarWidth - thickBarWidth - barHeight - fontSize
* @param float $value
* @return Zend_Barcode_Object
*
* @param int|float|string|bool $value
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
public function setFactor($value)
@ -399,6 +439,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Get factor applying to
* thinBarWidth - thickBarWidth - barHeight - fontSize
*
* @return integer
*/
public function getFactor()
@ -408,8 +449,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Set color of the barcode and text
*
* @param string $value
* @return Zend_Barcode_Object
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
public function setForeColor($value)
@ -428,6 +470,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve color of the barcode and text
*
* @return unknown
*/
public function getForeColor()
@ -437,8 +480,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Set the color of the background
*
* @param integer $value
* @return Zend_Barcode_Object
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
public function setBackgroundColor($value)
@ -457,6 +501,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve background color of the image
*
* @return integer
*/
public function getBackgroundColor()
@ -466,8 +511,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Activate/deactivate drawing of the bar
*
* @param boolean $value
* @return Zend_Barcode_Object
* @return $this
*/
public function setWithBorder($value)
{
@ -477,6 +523,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve if border are draw or not
*
* @return boolean
*/
public function getWithBorder()
@ -486,8 +533,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Activate/deactivate drawing of the quiet zones
*
* @param boolean $value
* @return Zend_Barcode_Object
* @return $this
*/
public function setWithQuietZones($value)
{
@ -497,6 +545,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve if quiet zones are draw or not
*
* @return boolean
*/
public function getWithQuietZones()
@ -506,30 +555,35 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Allow fast inversion of font/bars color and background color
* @return Zend_Barcode_Object
*
* @return $this
*/
public function setReverseColor()
{
$tmp = $this->_foreColor;
$this->_foreColor = $this->_backgroundColor;
$this->_backgroundColor = $tmp;
return $this;
}
/**
* Set orientation of barcode and text
* @param float $value
* @return Zend_Barcode_Object
*
* @param int|float|string|bool $value
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
public function setOrientation($value)
{
$this->_orientation = floatval($value) - floor(floatval($value) / 360) * 360;
$value = floatval($value);
$this->_orientation = $value - floor($value / 360) * 360;
return $this;
}
/**
* Retrieve orientation of barcode and text
*
* @return float
*/
public function getOrientation()
@ -539,8 +593,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Set text to encode
*
* @param string $value
* @return Zend_Barcode_Object
* @return $this
*/
public function setText($value)
{
@ -550,6 +605,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve text to encode
*
* @return string
*/
public function getText()
@ -588,6 +644,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve text to encode
*
* @return string
*/
public function getRawText()
@ -597,6 +654,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve text to display
*
* @return string
*/
public function getTextToDisplay()
@ -610,8 +668,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Activate/deactivate drawing of text to encode
*
* @param boolean $value
* @return Zend_Barcode_Object
* @return $this
*/
public function setDrawText($value)
{
@ -621,6 +680,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve if drawing of text to encode is enabled
*
* @return boolean
*/
public function getDrawText()
@ -631,8 +691,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Activate/deactivate the adjustment of the position
* of the characters to the position of the bars
*
* @param boolean $value
* @return Zend_Barcode_Object
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
public function setStretchText($value)
@ -644,6 +705,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve if the adjustment of the position of the characters
* to the position of the bars is enabled
*
* @return boolean
*/
public function getStretchText()
@ -655,8 +717,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
* Activate/deactivate the automatic generation
* of the checksum character
* added to the barcode text
*
* @param boolean $value
* @return Zend_Barcode_Object
* @return $this
*/
public function setWithChecksum($value)
{
@ -669,6 +732,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve if the checksum character is automatically
* added to the barcode text
*
* @return boolean
*/
public function getWithChecksum()
@ -680,8 +744,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
* Activate/deactivate the automatic generation
* of the checksum character
* added to the barcode text
*
* @param boolean $value
* @return Zend_Barcode_Object
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
public function setWithChecksumInText($value)
@ -689,12 +754,14 @@ abstract class Zend_Barcode_Object_ObjectAbstract
if (!$this->_mandatoryChecksum) {
$this->_withChecksumInText = (bool) $value;
}
return $this;
}
/**
* Retrieve if the checksum character is automatically
* added to the barcode text
*
* @return boolean
*/
public function getWithChecksumInText()
@ -704,8 +771,8 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Set the font for all instances of barcode
*
* @param string $font
* @return void
*/
public static function setBarcodeFont($font)
{
@ -718,8 +785,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
* Set the font:
* - if integer between 1 and 5, use gd built-in fonts
* - if string, $value is assumed to be the path to a TTF font
*
* @param integer|string $value
* @return Zend_Barcode_Object
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
public function setFont($value)
@ -739,16 +807,19 @@ abstract class Zend_Barcode_Object_ObjectAbstract
} elseif (is_string($value)) {
$this->_font = $value;
} else {
throw new Zend_Barcode_Object_Exception(sprintf(
throw new Zend_Barcode_Object_Exception(
sprintf(
'Invalid font "%s" provided to setFont()',
$value
));
)
);
}
return $this;
}
/**
* Retrieve the font
*
* @return integer|string
*/
public function getFont()
@ -758,8 +829,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Set the size of the font in case of TTF
*
* @param float $value
* @return Zend_Barcode_Object
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
public function setFontSize($value)
@ -781,6 +853,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve the size of the font in case of TTF
*
* @return float
*/
public function getFontSize()
@ -791,6 +864,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Quiet zone before first bar
* and after the last bar
*
* @return integer
*/
public function getQuietZone()
@ -804,6 +878,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Add an instruction in the array of instructions
*
* @param array $instruction
*/
protected function _addInstruction(array $instruction)
@ -813,6 +888,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Retrieve the set of drawing instructions
*
* @return array
*/
public function getInstructions()
@ -822,6 +898,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Add a polygon drawing instruction in the set of instructions
*
* @param array $points
* @param integer $color
* @param boolean $filled
@ -831,12 +908,14 @@ abstract class Zend_Barcode_Object_ObjectAbstract
if ($color === null) {
$color = $this->_foreColor;
}
$this->_addInstruction(array(
$this->_addInstruction(
array(
'type' => 'polygon',
'points' => $points,
'color' => $color,
'filled' => $filled,
));
)
);
}
/**
@ -862,7 +941,8 @@ abstract class Zend_Barcode_Object_ObjectAbstract
if ($color === null) {
$color = $this->_foreColor;
}
$this->_addInstruction(array(
$this->_addInstruction(
array(
'type' => 'text',
'text' => $text,
'size' => $size,
@ -871,7 +951,8 @@ abstract class Zend_Barcode_Object_ObjectAbstract
'color' => $color,
'alignment' => $alignment,
'orientation' => $orientation,
));
)
);
}
/**
@ -891,7 +972,6 @@ abstract class Zend_Barcode_Object_ObjectAbstract
* Check if a text is really provided to barcode
*
* @param string|null $value
* @return void
* @throws Zend_Barcode_Object_Exception
*/
protected function _checkText($value = null)
@ -912,26 +992,26 @@ abstract class Zend_Barcode_Object_ObjectAbstract
*
* @param int $min
* @param int $max
* @return void
* @throws Zend_Barcode_Object_Exception
*/
protected function _checkRatio($min = 2, $max = 3)
{
$ratio = $this->_barThickWidth / $this->_barThinWidth;
if (!($ratio >= $min && $ratio <= $max)) {
throw new Zend_Barcode_Object_Exception(sprintf(
throw new Zend_Barcode_Object_Exception(
sprintf(
'Ratio thick/thin bar must be between %0.1f and %0.1f (actual %0.3f)',
$min,
$max,
$ratio
));
)
);
}
}
/**
* Drawing with an angle is just allow TTF font
*
* @return void
* @throws Zend_Barcode_Object_Exception
*/
protected function _checkFontAndOrientation()
@ -987,7 +1067,9 @@ abstract class Zend_Barcode_Object_ObjectAbstract
$textHeight += $this->_fontSize;
$extraHeight = 2;
}
return ($this->_barHeight + $textHeight) * $this->_factor + $extraHeight;
return ($this->_barHeight + $textHeight) * $this->_factor
+ $extraHeight;
}
/**
@ -1000,8 +1082,16 @@ abstract class Zend_Barcode_Object_ObjectAbstract
{
if ($this->_height === null || $recalculate) {
$this->_height =
abs($this->_calculateHeight() * cos($this->_orientation / 180 * pi()))
+ abs($this->_calculateWidth() * sin($this->_orientation / 180 * pi()));
abs(
$this->_calculateHeight() * cos(
$this->_orientation / 180 * pi()
)
)
+ abs(
$this->_calculateWidth() * sin(
$this->_orientation / 180 * pi()
)
);
}
return $this->_height;
}
@ -1016,8 +1106,16 @@ abstract class Zend_Barcode_Object_ObjectAbstract
{
if ($this->_width === null || $recalculate) {
$this->_width =
abs($this->_calculateWidth() * cos($this->_orientation / 180 * pi()))
+ abs($this->_calculateHeight() * sin($this->_orientation / 180 * pi()));
abs(
$this->_calculateWidth() * cos(
$this->_orientation / 180 * pi()
)
)
+ abs(
$this->_calculateHeight() * sin(
$this->_orientation / 180 * pi()
)
);
}
return $this->_width;
}
@ -1093,7 +1191,11 @@ abstract class Zend_Barcode_Object_ObjectAbstract
$y2 = $y1 * cos($this->_orientation / 180 * pi())
+ $x1 * sin($this->_orientation / 180 * pi())
+ $this->getOffsetTop();
return array(intval($x2) , intval($y2));
return array(
intval($x2),
intval($y2)
);
}
/**
@ -1112,8 +1214,6 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Draw the barcode
*
* @return void
*/
protected function _drawBarcode()
{
@ -1132,12 +1232,14 @@ abstract class Zend_Barcode_Object_ObjectAbstract
);
$point4 = $this->_rotate($this->_calculateWidth() - 1, 0);
$this->_addPolygon(array(
$this->_addPolygon(
array(
$point1,
$point2,
$point3,
$point4
), $this->_backgroundColor);
), $this->_backgroundColor
);
$xpos += $this->getQuietZone();
$barLength = $this->_barHeight * $this->_factor;
@ -1155,12 +1257,14 @@ abstract class Zend_Barcode_Object_ObjectAbstract
$xpos + $width - 1,
$ypos + $bar[2] * $barLength
);
$this->_addPolygon(array(
$this->_addPolygon(
array(
$point1,
$point2,
$point3,
$point4,
));
)
);
}
$xpos += $width;
}
@ -1170,8 +1274,6 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Partial function to draw border
*
* @return void
*/
protected function _drawBorder()
{
@ -1183,19 +1285,20 @@ abstract class Zend_Barcode_Object_ObjectAbstract
$this->_calculateHeight() - 1
);
$point4 = $this->_rotate(0, $this->_calculateHeight() - 1);
$this->_addPolygon(array(
$this->_addPolygon(
array(
$point1,
$point2,
$point3,
$point4,
$point1,
), $this->_foreColor, false);
), $this->_foreColor, false
);
}
}
/**
* Partial function to draw text
* @return void
*/
protected function _drawText()
{
@ -1240,8 +1343,8 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Check for invalid characters
*
* @param string $value Text to be ckecked
* @return void
*/
public function validateText($value)
{
@ -1259,10 +1362,12 @@ abstract class Zend_Barcode_Object_ObjectAbstract
{
$validatorName = (isset($options['validator'])) ? $options['validator'] : $this->getType();
$validator = new Zend_Validate_Barcode(array(
$validator = new Zend_Validate_Barcode(
array(
'adapter' => $validatorName,
'checksum' => false,
));
)
);
$checksumCharacter = '';
$withChecksum = false;
@ -1271,7 +1376,8 @@ abstract class Zend_Barcode_Object_ObjectAbstract
$withChecksum = true;
}
$value = $this->_addLeadingZeros($value, $withChecksum) . $checksumCharacter;
$value = $this->_addLeadingZeros($value, $withChecksum)
. $checksumCharacter;
if (!$validator->isValid($value)) {
$message = implode("\n", $validator->getMessages());
@ -1301,15 +1407,11 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Checking of parameters after all settings
*
* @return void
*/
abstract protected function _checkParams();
/**
* Allow each child to draw something else
*
* @return void
*/
protected function _preDrawBarcode()
{
@ -1318,8 +1420,6 @@ abstract class Zend_Barcode_Object_ObjectAbstract
/**
* Allow each child to draw something else
* (ex: bearer bars in interleaved 2 of 5 code)
*
* @return void
*/
protected function _postDrawBarcode()
{

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Barcode
* @subpackage Object
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -33,7 +33,7 @@
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Barcode_Object_Planet extends Zend_Barcode_Object_Postnet

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