adding zend project folders into old campcaster.
This commit is contained in:
parent
56abfaf28e
commit
7ef0c18b26
4045 changed files with 1054952 additions and 0 deletions
378
library/Zend/View/Helper/Placeholder/Container/Abstract.php
Normal file
378
library/Zend/View/Helper/Placeholder/Container/Abstract.php
Normal file
|
@ -0,0 +1,378 @@
|
|||
<?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-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstract class representing container for placeholder values
|
||||
*
|
||||
* @package Zend_View
|
||||
* @subpackage Helper
|
||||
* @copyright Copyright (c) 2005-2010 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';
|
||||
$e = new Zend_View_Helper_Placeholder_Container_Exception('Cannot nest placeholder captures for the same placeholder');
|
||||
$e->setView($this->view);
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$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();
|
||||
}
|
||||
}
|
39
library/Zend/View/Helper/Placeholder/Container/Exception.php
Normal file
39
library/Zend/View/Helper/Placeholder/Container/Exception.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?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-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
* @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-2010 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
|
||||
{
|
||||
}
|
324
library/Zend/View/Helper/Placeholder/Container/Standalone.php
Normal file
324
library/Zend/View/Helper/Placeholder/Container/Standalone.php
Normal file
|
@ -0,0 +1,324 @@
|
|||
<?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-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @version $Id: Standalone.php 20143 2010-01-08 15:17:11Z 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-2010 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)
|
||||
{
|
||||
$enc = 'UTF-8';
|
||||
if ($this->view instanceof Zend_View_Interface
|
||||
&& method_exists($this->view, 'getEncoding')
|
||||
) {
|
||||
$enc = $this->view->getEncoding();
|
||||
}
|
||||
|
||||
return htmlspecialchars((string) $string, ENT_COMPAT, $enc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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';
|
||||
$e = new Zend_View_Exception('Method "' . $method . '" does not exist');
|
||||
$e->setView($this->view);
|
||||
throw $e;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue