Current File : /home/k/a/r/karenpetzb/www/items/category/Container.tar |
Interface.php 0000604 00000003111 15071303630 0007143 0 ustar 00 <?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.
*
* @package Zend_Memory
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Memory value container interface
*
* @category Zend
* @package Zend_Memory
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Memory_Container_Interface
{
/**
* Get string value reference
*
* _Must_ be used for value access before PHP v 5.2
* or _may_ be used for performance considerations
*
* @return &string
*/
public function &getRef();
/**
* Signal, that value is updated by external code.
*
* Should be used together with getRef()
*/
public function touch();
/**
* Lock object in memory.
*/
public function lock();
/**
* Unlock object
*/
public function unlock();
/**
* Return true if object is locked
*
* @return boolean
*/
public function isLocked();
}
Locked.php 0000604 00000004634 15071303630 0006457 0 ustar 00 <?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.
*
* @package Zend_Memory
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Memory_Exception */
require_once 'Zend/Memory/Exception.php';
/** Zend_Memory_Container */
require_once 'Zend/Memory/Container.php';
/**
* Memory value container
*
* Locked (always stored in memory).
*
* @category Zend
* @package Zend_Memory
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Memory_Container_Locked extends Zend_Memory_Container
{
/**
* Value object
*
* @var string
*/
public $value;
/**
* Object constructor
*
* @param Zend_Memory_Manager $memoryManager
* @param integer $id
* @param string $value
*/
public function __construct($value)
{
$this->value = $value;
}
/**
* Lock object in memory.
*/
public function lock()
{
/* Do nothing */
}
/**
* Unlock object
*/
public function unlock()
{
/* Do nothing */
}
/**
* Return true if object is locked
*
* @return boolean
*/
public function isLocked()
{
return true;
}
/**
* Get string value reference
*
* _Must_ be used for value access before PHP v 5.2
* or _may_ be used for performance considerations
*
* @return &string
*/
public function &getRef()
{
return $this->value;
}
/**
* Signal, that value is updated by external code.
*
* Should be used together with getRef()
*/
public function touch()
{
/* Do nothing */
}
/**
* Destroy memory container and remove it from memory manager list
*/
public function destroy()
{
/* Do nothing */
}
}
Movable.php 0000604 00000015307 15071303630 0006642 0 ustar 00 <?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.
*
* @package Zend_Memory
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Memory_Exception */
require_once 'Zend/Memory/Exception.php';
/** Zend_Memory_Container */
require_once 'Zend/Memory/Container.php';
/** Zend_Memory_Value */
require_once 'Zend/Memory/Value.php';
/**
* Memory value container
*
* Movable (may be swapped with specified backend and unloaded).
*
* @category Zend
* @package Zend_Memory
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Memory_Container_Movable extends Zend_Memory_Container {
/**
* Internal object Id
*
* @var integer
*/
protected $_id;
/**
* Memory manager reference
*
* @var Zend_Memory_Manager
*/
private $_memManager;
/**
* Value object
*
* @var Zend_Memory_Value
*/
private $_value;
/** Value states */
const LOADED = 1;
const SWAPPED = 2;
const LOCKED = 4;
/**
* Value state (LOADED/SWAPPED/LOCKED)
*
* @var integer
*/
private $_state;
/**
* Object constructor
*
* @param Zend_Memory_Manager $memoryManager
* @param integer $id
* @param string $value
*/
public function __construct(Zend_Memory_Manager $memoryManager, $id, $value)
{
$this->_memManager = $memoryManager;
$this->_id = $id;
$this->_state = self::LOADED;
$this->_value = new Zend_Memory_Value($value, $this);
}
/**
* Lock object in memory.
*/
public function lock()
{
if ( !($this->_state & self::LOADED) ) {
$this->_memManager->load($this, $this->_id);
$this->_state |= self::LOADED;
}
$this->_state |= self::LOCKED;
/**
* @todo
* It's possible to set "value" container attribute to avoid modification tracing, while it's locked
* Check, if it's more effective
*/
}
/**
* Unlock object
*/
public function unlock()
{
// Clear LOCKED state bit
$this->_state &= ~self::LOCKED;
}
/**
* Return true if object is locked
*
* @return boolean
*/
public function isLocked()
{
return $this->_state & self::LOCKED;
}
/**
* Get handler
*
* Loads object if necessary and moves it to the top of loaded objects list.
* Swaps objects from the bottom of loaded objects list, if necessary.
*
* @param string $property
* @return string
* @throws Zend_Memory_Exception
*/
public function __get($property)
{
if ($property != 'value') {
throw new Zend_Memory_Exception('Unknown property: Zend_Memory_container::$' . $property);
}
if ( !($this->_state & self::LOADED) ) {
$this->_memManager->load($this, $this->_id);
$this->_state |= self::LOADED;
}
return $this->_value;
}
/**
* Set handler
*
* @param string $property
* @param string $value
* @throws Zend_Exception
*/
public function __set($property, $value)
{
if ($property != 'value') {
throw new Zend_Memory_Exception('Unknown property: Zend_Memory_container::$' . $property);
}
$this->_state = self::LOADED;
$this->_value = new Zend_Memory_Value($value, $this);
$this->_memManager->processUpdate($this, $this->_id);
}
/**
* Get string value reference
*
* _Must_ be used for value access before PHP v 5.2
* or _may_ be used for performance considerations
*
* @return &string
*/
public function &getRef()
{
if ( !($this->_state & self::LOADED) ) {
$this->_memManager->load($this, $this->_id);
$this->_state |= self::LOADED;
}
return $this->_value->getRef();
}
/**
* Signal, that value is updated by external code.
*
* Should be used together with getRef()
*/
public function touch()
{
$this->_memManager->processUpdate($this, $this->_id);
}
/**
* Process container value update.
* Must be called only by value object
*
* @internal
*/
public function processUpdate()
{
// Clear SWAPPED state bit
$this->_state &= ~self::SWAPPED;
$this->_memManager->processUpdate($this, $this->_id);
}
/**
* Start modifications trace
*
* @internal
*/
public function startTrace()
{
if ( !($this->_state & self::LOADED) ) {
$this->_memManager->load($this, $this->_id);
$this->_state |= self::LOADED;
}
$this->_value->startTrace();
}
/**
* Set value (used by memory manager when value is loaded)
*
* @internal
*/
public function setValue($value)
{
$this->_value = new Zend_Memory_Value($value, $this);
}
/**
* Clear value (used by memory manager when value is swapped)
*
* @internal
*/
public function unloadValue()
{
// Clear LOADED state bit
$this->_state &= ~self::LOADED;
$this->_value = null;
}
/**
* Mark, that object is swapped
*
* @internal
*/
public function markAsSwapped()
{
// Clear LOADED state bit
$this->_state |= self::LOADED;
}
/**
* Check if object is marked as swapped
*
* @internal
* @return boolean
*/
public function isSwapped()
{
return $this->_state & self::SWAPPED;
}
/**
* Get object id
*
* @internal
* @return integer
*/
public function getId()
{
return $this->_id;
}
/**
* Destroy memory container and remove it from memory manager list
*
* @internal
*/
public function destroy()
{
/**
* We don't clean up swap because of performance considerations
* Cleaning is performed by Memory Manager destructor
*/
$this->_memManager->unlink($this, $this->_id);
}
}
Standalone.php 0000604 00000016700 15071557471 0007361 0 ustar 00 <?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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Standalone.php 13198 2008-12-13 13:51:40Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Helper_Placeholder_Registry */
require_once 'Zend/View/Helper/Placeholder/Registry.php';
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
* Base class for targetted placeholder helpers
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_View_Helper_Abstract implements IteratorAggregate, Countable, ArrayAccess
{
/**
* @var Zend_View_Helper_Placeholder_Container_Abstract
*/
protected $_container;
/**
* @var Zend_View_Helper_Placeholder_Registry
*/
protected $_registry;
/**
* Registry key under which container registers itself
* @var string
*/
protected $_regKey;
/**
* Flag wheter to automatically escape output, must also be
* enforced in the child class if __toString/toString is overriden
* @var book
*/
protected $_autoEscape = true;
/**
* Constructor
*
* @return void
*/
public function __construct()
{
$this->setRegistry(Zend_View_Helper_Placeholder_Registry::getRegistry());
$this->setContainer($this->getRegistry()->getContainer($this->_regKey));
}
/**
* Retrieve registry
*
* @return Zend_View_Helper_Placeholder_Registry
*/
public function getRegistry()
{
return $this->_registry;
}
/**
* Set registry object
*
* @param Zend_View_Helper_Placeholder_Registry $registry
* @return Zend_View_Helper_Placeholder_Container_Standalone
*/
public function setRegistry(Zend_View_Helper_Placeholder_Registry $registry)
{
$this->_registry = $registry;
return $this;
}
/**
* Set whether or not auto escaping should be used
*
* @param bool $autoEscape whether or not to auto escape output
* @return Zend_View_Helper_Placeholder_Container_Standalone
*/
public function setAutoEscape($autoEscape = true)
{
$this->_autoEscape = ($autoEscape) ? true : false;
return $this;
}
/**
* Return whether autoEscaping is enabled or disabled
*
* return bool
*/
public function getAutoEscape()
{
return $this->_autoEscape;
}
/**
* Escape a string
*
* @param string $string
* @return string
*/
protected function _escape($string)
{
if ($this->view instanceof Zend_View_Interface) {
return $this->view->escape($string);
}
return htmlentities((string) $string, null, 'UTF-8');
}
/**
* Set container on which to operate
*
* @param Zend_View_Helper_Placeholder_Container_Abstract $container
* @return Zend_View_Helper_Placeholder_Container_Standalone
*/
public function setContainer(Zend_View_Helper_Placeholder_Container_Abstract $container)
{
$this->_container = $container;
return $this;
}
/**
* Retrieve placeholder container
*
* @return Zend_View_Helper_Placeholder_Container_Abstract
*/
public function getContainer()
{
return $this->_container;
}
/**
* Overloading: set property value
*
* @param string $key
* @param mixed $value
* @return void
*/
public function __set($key, $value)
{
$container = $this->getContainer();
$container[$key] = $value;
}
/**
* Overloading: retrieve property
*
* @param string $key
* @return mixed
*/
public function __get($key)
{
$container = $this->getContainer();
if (isset($container[$key])) {
return $container[$key];
}
return null;
}
/**
* Overloading: check if property is set
*
* @param string $key
* @return bool
*/
public function __isset($key)
{
$container = $this->getContainer();
return isset($container[$key]);
}
/**
* Overloading: unset property
*
* @param string $key
* @return void
*/
public function __unset($key)
{
$container = $this->getContainer();
if (isset($container[$key])) {
unset($container[$key]);
}
}
/**
* Overload
*
* Proxy to container methods
*
* @param string $method
* @param array $args
* @return mixed
*/
public function __call($method, $args)
{
$container = $this->getContainer();
if (method_exists($container, $method)) {
$return = call_user_func_array(array($container, $method), $args);
if ($return === $container) {
// If the container is returned, we really want the current object
return $this;
}
return $return;
}
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Method "' . $method . '" does not exist');
}
/**
* String representation
*
* @return string
*/
public function toString()
{
return $this->getContainer()->toString();
}
/**
* Cast to string representation
*
* @return string
*/
public function __toString()
{
return $this->toString();
}
/**
* Countable
*
* @return int
*/
public function count()
{
$container = $this->getContainer();
return count($container);
}
/**
* ArrayAccess: offsetExists
*
* @param string|int $offset
* @return bool
*/
public function offsetExists($offset)
{
return $this->getContainer()->offsetExists($offset);
}
/**
* ArrayAccess: offsetGet
*
* @param string|int $offset
* @return mixed
*/
public function offsetGet($offset)
{
return $this->getContainer()->offsetGet($offset);
}
/**
* ArrayAccess: offsetSet
*
* @param string|int $offset
* @param mixed $value
* @return void
*/
public function offsetSet($offset, $value)
{
return $this->getContainer()->offsetSet($offset, $value);
}
/**
* ArrayAccess: offsetUnset
*
* @param string|int $offset
* @return void
*/
public function offsetUnset($offset)
{
return $this->getContainer()->offsetUnset($offset);
}
/**
* IteratorAggregate: get Iterator
*
* @return Iterator
*/
public function getIterator()
{
return $this->getContainer()->getIterator();
}
}
Abstract.php 0000604 00000022406 15071557471 0007034 0 ustar 00 <?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.
*
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Abstract.php 9099 2008-03-30 19:35:47Z thomas $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Abstract class representing container for placeholder values
*
* @package Zend_View
* @subpackage Helpers
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_View_Helper_Placeholder_Container_Abstract extends ArrayObject
{
/**
* Whether or not to override all contents of placeholder
* @const string
*/
const SET = 'SET';
/**
* Whether or not to append contents to placeholder
* @const string
*/
const APPEND = 'APPEND';
/**
* Whether or not to prepend contents to placeholder
* @const string
*/
const PREPEND = 'PREPEND';
/**
* What text to prefix the placeholder with when rendering
* @var string
*/
protected $_prefix = '';
/**
* What text to append the placeholder with when rendering
* @var string
*/
protected $_postfix = '';
/**
* What string to use between individual items in the placeholder when rendering
* @var string
*/
protected $_separator = '';
/**
* What string to use as the indentation of output, this will typically be spaces. Eg: ' '
* @var string
*/
protected $_indent = '';
/**
* Whether or not we're already capturing for this given container
* @var bool
*/
protected $_captureLock = false;
/**
* What type of capture (overwrite (set), append, prepend) to use
* @var string
*/
protected $_captureType;
/**
* Key to which to capture content
* @var string
*/
protected $_captureKey;
/**
* Constructor - This is needed so that we can attach a class member as the ArrayObject container
*
* @return void
*/
public function __construct()
{
parent::__construct(array(), parent::ARRAY_AS_PROPS);
}
/**
* Set a single value
*
* @param mixed $value
* @return void
*/
public function set($value)
{
$this->exchangeArray(array($value));
}
/**
* Prepend a value to the top of the container
*
* @param mixed $value
* @return void
*/
public function prepend($value)
{
$values = $this->getArrayCopy();
array_unshift($values, $value);
$this->exchangeArray($values);
}
/**
* Retrieve container value
*
* If single element registered, returns that element; otherwise,
* serializes to array.
*
* @return mixed
*/
public function getValue()
{
if (1 == count($this)) {
$keys = $this->getKeys();
$key = array_shift($keys);
return $this[$key];
}
return $this->getArrayCopy();
}
/**
* Set prefix for __toString() serialization
*
* @param string $prefix
* @return Zend_View_Helper_Placeholder_Container
*/
public function setPrefix($prefix)
{
$this->_prefix = (string) $prefix;
return $this;
}
/**
* Retrieve prefix
*
* @return string
*/
public function getPrefix()
{
return $this->_prefix;
}
/**
* Set postfix for __toString() serialization
*
* @param string $postfix
* @return Zend_View_Helper_Placeholder_Container
*/
public function setPostfix($postfix)
{
$this->_postfix = (string) $postfix;
return $this;
}
/**
* Retrieve postfix
*
* @return string
*/
public function getPostfix()
{
return $this->_postfix;
}
/**
* Set separator for __toString() serialization
*
* Used to implode elements in container
*
* @param string $separator
* @return Zend_View_Helper_Placeholder_Container
*/
public function setSeparator($separator)
{
$this->_separator = (string) $separator;
return $this;
}
/**
* Retrieve separator
*
* @return string
*/
public function getSeparator()
{
return $this->_separator;
}
/**
* Set the indentation string for __toString() serialization,
* optionally, if a number is passed, it will be the number of spaces
*
* @param string|int $indent
* @return Zend_View_Helper_Placeholder_Container_Abstract
*/
public function setIndent($indent)
{
$this->_indent = $this->getWhitespace($indent);
return $this;
}
/**
* Retrieve indentation
*
* @return string
*/
public function getIndent()
{
return $this->_indent;
}
/**
* Retrieve whitespace representation of $indent
*
* @param int|string $indent
* @return string
*/
public function getWhitespace($indent)
{
if (is_int($indent)) {
$indent = str_repeat(' ', $indent);
}
return (string) $indent;
}
/**
* Start capturing content to push into placeholder
*
* @param int $type How to capture content into placeholder; append, prepend, or set
* @return void
* @throws Zend_View_Helper_Placeholder_Exception if nested captures detected
*/
public function captureStart($type = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $key = null)
{
if ($this->_captureLock) {
require_once 'Zend/View/Helper/Placeholder/Container/Exception.php';
throw new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest placeholder captures for the same placeholder');
}
$this->_captureLock = true;
$this->_captureType = $type;
if ((null !== $key) && is_scalar($key)) {
$this->_captureKey = (string) $key;
}
ob_start();
}
/**
* End content capture
*
* @return void
*/
public function captureEnd()
{
$data = ob_get_clean();
$key = null;
$this->_captureLock = false;
if (null !== $this->_captureKey) {
$key = $this->_captureKey;
}
switch ($this->_captureType) {
case self::SET:
if (null !== $key) {
$this[$key] = $data;
} else {
$this->exchangeArray(array($data));
}
break;
case self::PREPEND:
if (null !== $key) {
$array = array($key => $data);
$values = $this->getArrayCopy();
$final = $array + $values;
$this->exchangeArray($final);
} else {
$this->prepend($data);
}
break;
case self::APPEND:
default:
if (null !== $key) {
if (empty($this[$key])) {
$this[$key] = $data;
} else {
$this[$key] .= $data;
}
} else {
$this[$this->nextIndex()] = $data;
}
break;
}
}
/**
* Get keys
*
* @return array
*/
public function getKeys()
{
$array = $this->getArrayCopy();
return array_keys($array);
}
/**
* Next Index
*
* as defined by the PHP manual
* @return int
*/
public function nextIndex()
{
$keys = $this->getKeys();
if (0 == count($keys)) {
return 0;
}
return $nextIndex = max($keys) + 1;
}
/**
* Render the placeholder
*
* @return string
*/
public function toString($indent = null)
{
$indent = ($indent !== null)
? $this->getWhitespace($indent)
: $this->getIndent();
$items = $this->getArrayCopy();
$return = $indent
. $this->getPrefix()
. implode($this->getSeparator(), $items)
. $this->getPostfix();
$return = preg_replace("/(\r\n?|\n)/", '$1' . $indent, $return);
return $return;
}
/**
* Serialize object to string
*
* @return string
*/
public function __toString()
{
return $this->toString();
}
}
Exception.php 0000604 00000002320 15071557471 0007220 0 ustar 00 <?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_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Exception.php 8064 2008-02-16 10:58:39Z thomas $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_View_Exception */
require_once 'Zend/View/Exception.php';
/**
* Exception for Zend_View_Helper_Placeholder_Container class.
*
* @category Zend
* @package Zend_View
* @subpackage Helper
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_View_Helper_Placeholder_Container_Exception extends Zend_View_Exception
{
}