00001 <?php
00024 require_once 'Zend/View/Helper/Placeholder/Registry.php';
00025
00027 require_once 'Zend/View/Helper/Abstract.php';
00028
00037 abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_View_Helper_Abstract implements IteratorAggregate, Countable, ArrayAccess
00038 {
00042 protected $_container;
00043
00047 protected $_registry;
00048
00053 protected $_regKey;
00054
00060 protected $_autoEscape = true;
00061
00067 public function __construct()
00068 {
00069 $this->setRegistry(Zend_View_Helper_Placeholder_Registry::getRegistry());
00070 $this->setContainer($this->getRegistry()->getContainer($this->_regKey));
00071 }
00072
00078 public function getRegistry()
00079 {
00080 return $this->_registry;
00081 }
00082
00089 public function setRegistry(Zend_View_Helper_Placeholder_Registry $registry)
00090 {
00091 $this->_registry = $registry;
00092 return $this;
00093 }
00094
00101 public function setAutoEscape($autoEscape = true)
00102 {
00103 $this->_autoEscape = ($autoEscape) ? true : false;
00104 return $this;
00105 }
00106
00112 public function getAutoEscape()
00113 {
00114 return $this->_autoEscape;
00115 }
00116
00123 protected function _escape($string)
00124 {
00125 $enc = 'UTF-8';
00126 if ($this->view instanceof Zend_View_Interface
00127 && method_exists($this->view, 'getEncoding')
00128 ) {
00129 $enc = $this->view->getEncoding();
00130 }
00131
00132 return htmlspecialchars((string) $string, ENT_COMPAT, $enc);
00133 }
00134
00141 public function setContainer(Zend_View_Helper_Placeholder_Container_Abstract $container)
00142 {
00143 $this->_container = $container;
00144 return $this;
00145 }
00146
00152 public function getContainer()
00153 {
00154 return $this->_container;
00155 }
00156
00164 public function __set($key, $value)
00165 {
00166 $container = $this->getContainer();
00167 $container[$key] = $value;
00168 }
00169
00176 public function __get($key)
00177 {
00178 $container = $this->getContainer();
00179 if (isset($container[$key])) {
00180 return $container[$key];
00181 }
00182
00183 return null;
00184 }
00185
00192 public function __isset($key)
00193 {
00194 $container = $this->getContainer();
00195 return isset($container[$key]);
00196 }
00197
00204 public function __unset($key)
00205 {
00206 $container = $this->getContainer();
00207 if (isset($container[$key])) {
00208 unset($container[$key]);
00209 }
00210 }
00211
00221 public function __call($method, $args)
00222 {
00223 $container = $this->getContainer();
00224 if (method_exists($container, $method)) {
00225 $return = call_user_func_array(array($container, $method), $args);
00226 if ($return === $container) {
00227
00228 return $this;
00229 }
00230 return $return;
00231 }
00232
00233 require_once 'Zend/View/Exception.php';
00234 throw new Zend_View_Exception('Method "' . $method . '" does not exist');
00235 }
00236
00242 public function toString()
00243 {
00244 return $this->getContainer()->toString();
00245 }
00246
00252 public function __toString()
00253 {
00254 return $this->toString();
00255 }
00256
00262 public function count()
00263 {
00264 $container = $this->getContainer();
00265 return count($container);
00266 }
00267
00274 public function offsetExists($offset)
00275 {
00276 return $this->getContainer()->offsetExists($offset);
00277 }
00278
00285 public function offsetGet($offset)
00286 {
00287 return $this->getContainer()->offsetGet($offset);
00288 }
00289
00297 public function offsetSet($offset, $value)
00298 {
00299 return $this->getContainer()->offsetSet($offset, $value);
00300 }
00301
00308 public function offsetUnset($offset)
00309 {
00310 return $this->getContainer()->offsetUnset($offset);
00311 }
00312
00318 public function getIterator()
00319 {
00320 return $this->getContainer()->getIterator();
00321 }
00322 }