import v1.0.0-RC4 | 2009-05-20

This commit is contained in:
2019-07-17 22:08:50 +02:00
commit b484e522e8
2459 changed files with 1038434 additions and 0 deletions

563
libs/Zend/Dojo/Data.php Normal file
View File

@ -0,0 +1,563 @@
<?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_Dojo
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Data.php 11282 2008-09-08 16:05:59Z matthew $
*/
/**
* dojo.data support for Zend Framework
*
* @uses ArrayAccess
* @uses Iterator
* @uses Countable
* @package Zend_Dojo
* @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_Dojo_Data implements ArrayAccess,Iterator,Countable
{
/**
* Identifier field of item
* @var string|int
*/
protected $_identifier;
/**
* Collected items
* @var array
*/
protected $_items = array();
/**
* Label field of item
* @var string
*/
protected $_label;
/**
* Data container metadata
* @var array
*/
protected $_metadata = array();
/**
* Constructor
*
* @param string|null $identifier
* @param array|Traversable|null $items
* @param string|null $label
* @return void
*/
public function __construct($identifier = null, $items = null, $label = null)
{
if (null !== $identifier) {
$this->setIdentifier($identifier);
}
if (null !== $items) {
$this->setItems($items);
}
if (null !== $label) {
$this->setLabel($label);
}
}
/**
* Set the items to collect
*
* @param array|Traversable $items
* @return Zend_Dojo_Data
*/
public function setItems($items)
{
$this->clearItems();
return $this->addItems($items);
}
/**
* Set an individual item, optionally by identifier (overwrites)
*
* @param array|object $item
* @param string|null $identifier
* @return Zend_Dojo_Data
*/
public function setItem($item, $id = null)
{
$item = $this->_normalizeItem($item, $id);
$this->_items[$item['id']] = $item['data'];
return $this;
}
/**
* Add an individual item, optionally by identifier
*
* @param array|object $item
* @param string|null $id
* @return Zend_Dojo_Data
*/
public function addItem($item, $id = null)
{
$item = $this->_normalizeItem($item, $id);
if ($this->hasItem($item['id'])) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('Overwriting items using addItem() is not allowed');
}
$this->_items[$item['id']] = $item['data'];
return $this;
}
/**
* Add multiple items at once
*
* @param array|Traversable $items
* @return Zend_Dojo_Data
*/
public function addItems($items)
{
if (!is_array($items) && (!is_object($items) || !($items instanceof Traversable))) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('Only arrays and Traversable objects may be added to ' . __CLASS__);
}
foreach ($items as $item) {
$this->addItem($item);
}
return $this;
}
/**
* Get all items as an array
*
* Serializes items to arrays.
*
* @return array
*/
public function getItems()
{
return $this->_items;
}
/**
* Does an item with the given identifier exist?
*
* @param string|int $id
* @return bool
*/
public function hasItem($id)
{
return array_key_exists($id, $this->_items);
}
/**
* Retrieve an item by identifier
*
* Item retrieved will be flattened to an array.
*
* @param string $id
* @return array
*/
public function getItem($id)
{
if (!$this->hasItem($id)) {
return null;
}
return $this->_items[$id];
}
/**
* Remove item by identifier
*
* @param string $id
* @return Zend_Dojo_Data
*/
public function removeItem($id)
{
if ($this->hasItem($id)) {
unset($this->_items[$id]);
}
return $this;
}
/**
* Remove all items at once
*
* @return Zend_Dojo_Data
*/
public function clearItems()
{
$this->_items = array();
return $this;
}
/**
* Set identifier for item lookups
*
* @param string|int|null $identifier
* @return Zend_Dojo_Data
*/
public function setIdentifier($identifier)
{
if (null === $identifier) {
$this->_identifier = null;
} elseif (is_string($identifier)) {
$this->_identifier = $identifier;
} elseif (is_numeric($identifier)) {
$this->_identifier = (int) $identifier;
} else {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('Invalid identifier; please use a string or integer');
}
return $this;
}
/**
* Retrieve current item identifier
*
* @return string|int|null
*/
public function getIdentifier()
{
return $this->_identifier;
}
/**
* Set label to use for displaying item associations
*
* @param string|null $label
* @return Zend_Dojo_Data
*/
public function setLabel($label)
{
if (null === $label) {
$this->_label = null;
} else {
$this->_label = (string) $label;
}
return $this;
}
/**
* Retrieve item association label
*
* @return string|null
*/
public function getLabel()
{
return $this->_label;
}
/**
* Set metadata by key or en masse
*
* @param string|array $spec
* @param mixed $value
* @return Zend_Dojo_Data
*/
public function setMetadata($spec, $value = null)
{
if (is_string($spec) && (null !== $value)) {
$this->_metadata[$spec] = $value;
} elseif (is_array($spec)) {
foreach ($spec as $key => $value) {
$this->setMetadata($key, $value);
}
}
return $this;
}
/**
* Get metadata item or all metadata
*
* @param null|string $key Metadata key when pulling single metadata item
* @return mixed
*/
public function getMetadata($key = null)
{
if (null === $key) {
return $this->_metadata;
}
if (array_key_exists($key, $this->_metadata)) {
return $this->_metadata[$key];
}
return null;
}
/**
* Clear individual or all metadata item(s)
*
* @param null|string $key
* @return Zend_Dojo_Data
*/
public function clearMetadata($key = null)
{
if (null === $key) {
$this->_metadata = array();
} elseif (array_key_exists($key, $this->_metadata)) {
unset($this->_metadata[$key]);
}
return $this;
}
/**
* Load object from array
*
* @param array $data
* @return Zend_Dojo_Data
*/
public function fromArray(array $data)
{
if (array_key_exists('identifier', $data)) {
$this->setIdentifier($data['identifier']);
}
if (array_key_exists('label', $data)) {
$this->setLabel($data['label']);
}
if (array_key_exists('items', $data) && is_array($data['items'])) {
$this->setItems($data['items']);
} else {
$this->clearItems();
}
return $this;
}
/**
* Load object from JSON
*
* @param string $json
* @return Zend_Dojo_Data
*/
public function fromJson($json)
{
if (!is_string($json)) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('fromJson() expects JSON input');
}
require_once 'Zend/Json.php';
$data = Zend_Json::decode($json);
return $this->fromArray($data);
}
/**
* Seralize entire data structure, including identifier and label, to array
*
* @return array
*/
public function toArray()
{
if (null === ($identifier = $this->getIdentifier())) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('Serialization requires that an identifier be present in the object; first call setIdentifier()');
}
$array = array(
'identifier' => $identifier,
'items' => array_values($this->getItems()),
);
$metadata = $this->getMetadata();
if (!empty($metadata)) {
foreach ($metadata as $key => $value) {
$array[$key] = $value;
}
}
if (null !== ($label = $this->getLabel())) {
$array['label'] = $label;
}
return $array;
}
/**
* Serialize to JSON (dojo.data format)
*
* @return string
*/
public function toJson()
{
require_once 'Zend/Json.php';
return Zend_Json::encode($this->toArray());
}
/**
* Serialize to string (proxy to {@link toJson()})
*
* @return string
*/
public function __toString()
{
return $this->toJson();
}
/**
* ArrayAccess: does offset exist?
*
* @param string|int $offset
* @return bool
*/
public function offsetExists($offset)
{
return (null !== $this->getItem($offset));
}
/**
* ArrayAccess: retrieve by offset
*
* @param string|int $offset
* @return array
*/
public function offsetGet($offset)
{
return $this->getItem($offset);
}
/**
* ArrayAccess: set value by offset
*
* @param string $offset
* @param array|object|null $value
* @return void
*/
public function offsetSet($offset, $value)
{
$this->setItem($value, $offset);
}
/**
* ArrayAccess: unset value by offset
*
* @param string $offset
* @return void
*/
public function offsetUnset($offset)
{
$this->removeItem($offset);
}
/**
* Iterator: get current value
*
* @return array
*/
public function current()
{
return current($this->_items);
}
/**
* Iterator: get current key
*
* @return string|int
*/
public function key()
{
return key($this->_items);
}
/**
* Iterator: get next item
*
* @return void
*/
public function next()
{
return next($this->_items);
}
/**
* Iterator: rewind to first value in collection
*
* @return void
*/
public function rewind()
{
return reset($this->_items);
}
/**
* Iterator: is item valid?
*
* @return bool
*/
public function valid()
{
return (bool) $this->current();
}
/**
* Countable: how many items are present
*
* @return int
*/
public function count()
{
return count($this->_items);
}
/**
* Normalize an item to attach to the collection
*
* @param array|object $item
* @param string|int|null $id
* @return array
*/
protected function _normalizeItem($item, $id)
{
if (null === ($identifier = $this->getIdentifier())) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('You must set an identifier prior to adding items');
}
if (!is_object($item) && !is_array($item)) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('Only arrays and objects may be attached');
}
if (is_object($item)) {
if (method_exists($item, 'toArray')) {
$item = $item->toArray();
} else {
$item = get_object_vars($item);
}
}
if ((null === $id) && !array_key_exists($identifier, $item)) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('Item must contain a column matching the currently set identifier');
} elseif (null === $id) {
$id = $item[$identifier];
} else {
$item[$identifier] = $id;
}
return array(
'id' => $id,
'data' => $item,
);
}
}

View File

@ -0,0 +1,35 @@
<?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_Dojo
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 9854 2008-07-01 15:22:29Z matthew $
*/
/** Zend_Exception */
require_once 'Zend/Exception.php';
/**
* Exception class for Zend_Dojo
*
* @uses Zend_Exception
* @package Zend_Dojo
* @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_Dojo_Exception extends Zend_Exception
{
}

89
libs/Zend/Dojo/Form.php Normal file
View File

@ -0,0 +1,89 @@
<?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_Dojo
* @subpackage Form
* @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_Form */
require_once 'Zend/Form.php';
/**
* Dijit-enabled Form
*
* @uses Zend_Form
* @package Zend_Dojo
* @subpackage Form
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Form.php 12373 2008-11-07 16:52:44Z matthew $
*/
class Zend_Dojo_Form extends Zend_Form
{
/**
* Constructor
*
* @param array|Zend_Config|null $options
* @return void
*/
public function __construct($options = null)
{
$this->addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
->addPrefixPath('Zend_Dojo_Form_Element', 'Zend/Dojo/Form/Element', 'element')
->addElementPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
->addDisplayGroupPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator')
->setDefaultDisplayGroupClass('Zend_Dojo_Form_DisplayGroup');
parent::__construct($options);
}
/**
* Load the default decorators
*
* @return void
*/
public function loadDefaultDecorators()
{
if ($this->loadDefaultDecoratorsIsDisabled()) {
return;
}
$decorators = $this->getDecorators();
if (empty($decorators)) {
$this->addDecorator('FormElements')
->addDecorator('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form_dojo'))
->addDecorator('DijitForm');
}
}
/**
* Set the view object
*
* Ensures that the view object has the dojo view helper path set.
*
* @param Zend_View_Interface $view
* @return Zend_Dojo_Form_Element_Dijit
*/
public function setView(Zend_View_Interface $view = null)
{
if (null !== $view) {
if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
$view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
}
}
return parent::setView($view);
}
}

View File

@ -0,0 +1,43 @@
<?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_Form
* @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_Dojo_Form_Decorator_DijitContainer */
require_once 'Zend/Dojo/Form/Decorator/DijitContainer.php';
/**
* AccordionContainer
*
* Render a dijit AccordionContainer
*
* @uses Zend_Dojo_Form_Decorator_DijitContainer
* @package Zend_Dojo
* @subpackage Form_Decorator
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: AccordionContainer.php 10009 2008-07-09 16:52:18Z matthew $
*/
class Zend_Dojo_Form_Decorator_AccordionContainer extends Zend_Dojo_Form_Decorator_DijitContainer
{
/**
* View helper
* @var string
*/
protected $_helper = 'AccordionContainer';
}

View File

@ -0,0 +1,43 @@
<?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_Form
* @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_Dojo_Form_Decorator_DijitContainer */
require_once 'Zend/Dojo/Form/Decorator/DijitContainer.php';
/**
* AccordionPane
*
* Render a dijit AccordionPane
*
* @uses Zend_Dojo_Form_Decorator_DijitContainer
* @package Zend_Dojo
* @subpackage Form_Decorator
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: AccordionPane.php 10009 2008-07-09 16:52:18Z matthew $
*/
class Zend_Dojo_Form_Decorator_AccordionPane extends Zend_Dojo_Form_Decorator_DijitContainer
{
/**
* View helper
* @var string
*/
protected $_helper = 'AccordionPane';
}

View File

@ -0,0 +1,43 @@
<?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_Form
* @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_Dojo_Form_Decorator_DijitContainer */
require_once 'Zend/Dojo/Form/Decorator/DijitContainer.php';
/**
* BorderContainer
*
* Render a dijit BorderContainer
*
* @uses Zend_Dojo_Form_Decorator_DijitContainer
* @package Zend_Dojo
* @subpackage Form_Decorator
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: BorderContainer.php 10009 2008-07-09 16:52:18Z matthew $
*/
class Zend_Dojo_Form_Decorator_BorderContainer extends Zend_Dojo_Form_Decorator_DijitContainer
{
/**
* View helper
* @var string
*/
protected $_helper = 'BorderContainer';
}

View File

@ -0,0 +1,43 @@
<?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_Form
* @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_Dojo_Form_Decorator_DijitContainer */
require_once 'Zend/Dojo/Form/Decorator/DijitContainer.php';
/**
* ContentPane
*
* Render a dijit ContentPane
*
* @uses Zend_Dojo_Form_Decorator_DijitContainer
* @package Zend_Dojo
* @subpackage Form_Decorator
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ContentPane.php 10009 2008-07-09 16:52:18Z matthew $
*/
class Zend_Dojo_Form_Decorator_ContentPane extends Zend_Dojo_Form_Decorator_DijitContainer
{
/**
* View helper
* @var string
*/
protected $_helper = 'ContentPane';
}

View File

@ -0,0 +1,200 @@
<?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_Form
* @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_Form_Decorator_Abstract */
require_once 'Zend/Form/Decorator/Abstract.php';
/**
* Zend_Dojo_Form_Decorator_DijitContainer
*
* Render a dojo dijit layout container via a view helper
*
* Accepts the following options:
* - helper: the name of the view helper to use
*
* Assumes the view helper accepts four parameters, the id, content, dijit
* parameters, and (X)HTML attributes; these will be provided by the element.
*
* @uses Zend_Form_Decorator_Abstract
* @package Zend_Dojo
* @subpackage Form_Decorator
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DijitContainer.php 10032 2008-07-10 16:47:19Z matthew $
*/
abstract class Zend_Dojo_Form_Decorator_DijitContainer extends Zend_Form_Decorator_Abstract
{
/**
* View helper
* @var string
*/
protected $_helper;
/**
* Element attributes
* @var array
*/
protected $_attribs;
/**
* Dijit option parameters
* @var array
*/
protected $_dijitParams;
/**
* Container title
* @var string
*/
protected $_title;
/**
* Get view helper for rendering container
*
* @return string
*/
public function getHelper()
{
if (null === $this->_helper) {
require_once 'Zend/Form/Decorator/Exception.php';
throw new Zend_Form_Decorator_Exception('No view helper specified fo DijitContainer decorator');
}
return $this->_helper;
}
/**
* Get element attributes
*
* @return array
*/
public function getAttribs()
{
if (null === $this->_attribs) {
$attribs = $this->getElement()->getAttribs();
if (array_key_exists('dijitParams', $attribs)) {
unset($attribs['dijitParams']);
}
$this->_attribs = $attribs;
}
return $this->_attribs;
}
/**
* Get dijit option parameters
*
* @return array
*/
public function getDijitParams()
{
if (null === $this->_dijitParams) {
$attribs = $this->getElement()->getAttribs();
if (array_key_exists('dijitParams', $attribs)) {
$this->_dijitParams = $attribs['dijitParams'];
} else {
$this->_dijitParams = array();
}
$options = $this->getOptions();
if (array_key_exists('dijitParams', $options)) {
$this->_dijitParams = array_merge($this->_dijitParams, $options['dijitParams']);
$this->removeOption('dijitParams');
}
}
// Ensure we have a title param
if (!array_key_exists('title', $this->_dijitParams)) {
$this->_dijitParams['title'] = $this->getTitle();
}
return $this->_dijitParams;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
if (null === $this->_title) {
$title = null;
if (null !== ($element = $this->getElement())) {
if (method_exists($element, 'getLegend')) {
$title = $element->getLegend();
}
}
if (empty($title) && (null !== ($title = $this->getOption('legend')))) {
$this->removeOption('legend');
}
if (empty($title) && (null !== ($title = $this->getOption('title')))) {
$this->removeOption('title');
}
if (!empty($title)) {
if (null !== ($translator = $element->getTranslator())) {
$title = $translator->translate($title);
}
$this->_title = $title;
}
}
return (empty($this->_title) ? '' : $this->_title);
}
/**
* Render a dijit layout container
*
* Replaces $content entirely from currently set element.
*
* @param string $content
* @return string
*/
public function render($content)
{
$element = $this->getElement();
$view = $element->getView();
if (null === $view) {
return $content;
}
$dijitParams = $this->getDijitParams();
$attribs = array_merge($this->getAttribs(), $this->getOptions());
if (array_key_exists('legend', $attribs)) {
if (!array_key_exists('title', $dijitParams) || empty($dijitParams['title'])) {
$dijitParams['title'] = $attribs['legend'];
}
unset($attribs['legend']);
}
$helper = $this->getHelper();
$id = $element->getId() . '-' . $helper;
if ($view->dojo()->hasDijit($id)) {
trigger_error(sprintf('Duplicate dijit ID detected for id "%s; temporarily generating uniqid"', $id), E_USER_WARNING);
$base = $id;
do {
$id = $base . '-' . uniqid();
} while ($view->dojo()->hasDijit($id));
}
return $view->$helper($id, $content, $dijitParams, $attribs);
}
}

View File

@ -0,0 +1,195 @@
<?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_Form
* @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_Form_Decorator_ViewHelper */
require_once 'Zend/Form/Decorator/ViewHelper.php';
/**
* Zend_Dojo_Form_Decorator_DijitElement
*
* Render a dojo dijit element via a view helper
*
* Accepts the following options:
* - separator: string with which to separate passed in content and generated content
* - placement: whether to append or prepend the generated content to the passed in content
* - helper: the name of the view helper to use
*
* Assumes the view helper accepts three parameters, the name, value, and
* optional attributes; these will be provided by the element.
*
* @package Zend_Dojo
* @subpackage Form_Decorator
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DijitElement.php 12374 2008-11-07 17:49:43Z matthew $
*/
class Zend_Dojo_Form_Decorator_DijitElement extends Zend_Form_Decorator_ViewHelper
{
/**
* Element attributes
* @var array
*/
protected $_attribs;
/**
* Element types that represent buttons
* @var array
*/
protected $_buttonTypes = array(
'Zend_Dojo_Form_Element_Button',
'Zend_Form_Element_Button',
'Zend_Form_Element_Reset',
'Zend_Form_Element_Submit',
);
/**
* Dijit option parameters
* @var array
*/
protected $_dijitParams = array();
/**
* Get element attributes
*
* @return array
*/
public function getElementAttribs()
{
if (null === $this->_attribs) {
$this->_attribs = parent::getElementAttribs();
if (array_key_exists('dijitParams', $this->_attribs)) {
$this->setDijitParams($this->_attribs['dijitParams']);
unset($this->_attribs['dijitParams']);
}
}
return $this->_attribs;
}
/**
* Set a single dijit option parameter
*
* @param string $key
* @param mixed $value
* @return Zend_Dojo_Form_Decorator_DijitContainer
*/
public function setDijitParam($key, $value)
{
$this->_dijitParams[(string) $key] = $value;
return $this;
}
/**
* Set dijit option parameters
*
* @param array $params
* @return Zend_Dojo_Form_Decorator_DijitContainer
*/
public function setDijitParams(array $params)
{
$this->_dijitParams = array_merge($this->_dijitParams, $params);
return $this;
}
/**
* Retrieve a single dijit option parameter
*
* @param string $key
* @return mixed|null
*/
public function getDijitParam($key)
{
$this->getElementAttribs();
$key = (string) $key;
if (array_key_exists($key, $this->_dijitParams)) {
return $this->_dijitParams[$key];
}
return null;
}
/**
* Get dijit option parameters
*
* @return array
*/
public function getDijitParams()
{
$this->getElementAttribs();
return $this->_dijitParams;
}
/**
* Render an element using a view helper
*
* Determine view helper from 'helper' option, or, if none set, from
* the element type. Then call as
* helper($element->getName(), $element->getValue(), $element->getAttribs())
*
* @param string $content
* @return string
* @throws Zend_Form_Decorator_Exception if element or view are not registered
*/
public function render($content)
{
$element = $this->getElement();
$view = $element->getView();
if (null === $view) {
require_once 'Zend/Form/Decorator/Exception.php';
throw new Zend_Form_Decorator_Exception('DijitElement decorator cannot render without a registered view object');
}
$options = null;
if (method_exists($element, 'getMultiOptions')) {
$options = $element->getMultiOptions();
}
$helper = $this->getHelper();
$separator = $this->getSeparator();
$value = $this->getValue($element);
$attribs = $this->getElementAttribs();
$name = $element->getFullyQualifiedName();
$dijitParams = $this->getDijitParams();
if ($element->isRequired()) {
$dijitParams['required'] = true;
}
$id = $element->getId();
if ($view->dojo()->hasDijit($id)) {
trigger_error(sprintf('Duplicate dijit ID detected for id "%s; temporarily generating uniqid"', $id), E_USER_NOTICE);
$base = $id;
do {
$id = $base . '-' . uniqid();
} while ($view->dojo()->hasDijit($id));
}
$attribs['id'] = $id;
$elementContent = $view->$helper($name, $value, $dijitParams, $attribs, $options);
switch ($this->getPlacement()) {
case self::APPEND:
return $content . $separator . $elementContent;
case self::PREPEND:
return $elementContent . $separator . $content;
default:
return $elementContent;
}
}
}

View File

@ -0,0 +1,61 @@
<?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_Form
* @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_Dojo_Form_Decorator_DijitContainer */
require_once 'Zend/Dojo/Form/Decorator/DijitContainer.php';
/**
* Zend_Dojo_Form_Decorator_DijitForm
*
* Render a dojo form dijit via a view helper
*
* Accepts the following options:
* - helper: the name of the view helper to use
*
* @package Zend_Dojo
* @subpackage Form_Decorator
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DijitForm.php 10009 2008-07-09 16:52:18Z matthew $
*/
class Zend_Dojo_Form_Decorator_DijitForm extends Zend_Dojo_Form_Decorator_DijitContainer
{
/**
* Render a form
*
* Replaces $content entirely from currently set element.
*
* @param string $content
* @return string
*/
public function render($content)
{
$element = $this->getElement();
$view = $element->getView();
if (null === $view) {
return $content;
}
$dijitParams = $this->getDijitParams();
$attribs = array_merge($this->getAttribs(), $this->getOptions());
return $view->form($element->getName(), $attribs, $content);
}
}

View File

@ -0,0 +1,43 @@
<?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_Form
* @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_Dojo_Form_Decorator_DijitContainer */
require_once 'Zend/Dojo/Form/Decorator/DijitContainer.php';
/**
* SplitContainer
*
* Render a dijit SplitContainer
*
* @uses Zend_Dojo_Form_Decorator_DijitContainer
* @package Zend_Dojo
* @subpackage Form_Decorator
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SplitContainer.php 10009 2008-07-09 16:52:18Z matthew $
*/
class Zend_Dojo_Form_Decorator_SplitContainer extends Zend_Dojo_Form_Decorator_DijitContainer
{
/**
* View helper
* @var string
*/
protected $_helper = 'SplitContainer';
}

View File

@ -0,0 +1,44 @@
<?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_Form
* @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_Dojo_Form_Decorator_DijitContainer */
require_once 'Zend/Dojo/Form/Decorator/DijitContainer.php';
/**
* StackContainer
*
* Render a dijit StackContainer
*
* @uses Zend_Dojo_Form_Decorator_DijitContainer
* @package Zend_Dojo
* @subpackage Form_Decorator
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: StackContainer.php 10009 2008-07-09 16:52:18Z matthew $
*/
class Zend_Dojo_Form_Decorator_StackContainer extends Zend_Dojo_Form_Decorator_DijitContainer
{
/**
* View helper
* @var string
*/
protected $_helper = 'StackContainer';
}

View File

@ -0,0 +1,43 @@
<?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_Form
* @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_Dojo_Form_Decorator_DijitContainer */
require_once 'Zend/Dojo/Form/Decorator/DijitContainer.php';
/**
* TabContainer
*
* Render a dijit TabContainer
*
* @uses Zend_Dojo_Form_Decorator_DijitContainer
* @package Zend_Dojo
* @subpackage Form_Decorator
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: TabContainer.php 10009 2008-07-09 16:52:18Z matthew $
*/
class Zend_Dojo_Form_Decorator_TabContainer extends Zend_Dojo_Form_Decorator_DijitContainer
{
/**
* View helper
* @var string
*/
protected $_helper = 'TabContainer';
}

View File

@ -0,0 +1,68 @@
<?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_Dojo
* @subpackage Form
* @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_Form_DisplayGroup */
require_once 'Zend/Form/DisplayGroup.php';
/**
* Dijit-enabled DisplayGroup
*
* @uses Zend_Form_DisplayGroup
* @package Zend_Dojo
* @subpackage Form
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DisplayGroup.php 10076 2008-07-13 12:58:08Z matthew $
*/
class Zend_Dojo_Form_DisplayGroup extends Zend_Form_DisplayGroup
{
/**
* Constructor
*
* @param string $name
* @param Zend_Loader_PluginLoader $loader
* @param array|Zend_Config|null $options
* @return void
*/
public function __construct($name, Zend_Loader_PluginLoader $loader, $options = null)
{
parent::__construct($name, $loader, $options);
$this->addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator');
}
/**
* Set the view object
*
* Ensures that the view object has the dojo view helper path set.
*
* @param Zend_View_Interface $view
* @return Zend_Dojo_Form_Element_Dijit
*/
public function setView(Zend_View_Interface $view = null)
{
if (null !== $view) {
if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
$view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
}
}
return parent::setView($view);
}
}

View File

@ -0,0 +1,121 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_Dijit */
require_once 'Zend/Dojo/Form/Element/Dijit.php';
/**
* Button dijit
*
* @category Zend
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Button.php 10091 2008-07-15 03:46:37Z matthew $
*/
class Zend_Dojo_Form_Element_Button extends Zend_Dojo_Form_Element_Dijit
{
/**
* Use Button dijit view helper
* @var string
*/
public $helper = 'Button';
/**
* Constructor
*
* @param string|array|Zend_Config $spec Element name or configuration
* @param string|array|Zend_Config $options Element value or configuration
* @return void
*/
public function __construct($spec, $options = null)
{
if (is_string($spec) && ((null !== $options) && is_string($options))) {
$options = array('label' => $options);
}
parent::__construct($spec, $options);
}
/**
* Return label
*
* If no label is present, returns the currently set name.
*
* If a translator is present, returns the translated label.
*
* @return string
*/
public function getLabel()
{
$value = parent::getLabel();
if (null === $value) {
$value = $this->getName();
}
if (null !== ($translator = $this->getTranslator())) {
return $translator->translate($value);
}
return $value;
}
/**
* Has this submit button been selected?
*
* @return bool
*/
public function isChecked()
{
$value = $this->getValue();
if (empty($value)) {
return false;
}
if ($value != $this->getLabel()) {
return false;
}
return true;
}
/**
* Default decorators
*
* Uses only 'DijitElement' and 'DtDdWrapper' decorators by default.
*
* @return void
*/
public function loadDefaultDecorators()
{
if ($this->loadDefaultDecoratorsIsDisabled()) {
return;
}
$decorators = $this->getDecorators();
if (empty($decorators)) {
$this->addDecorator('DijitElement')
->addDecorator('DtDdWrapper');
}
}
}

View File

@ -0,0 +1,212 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_Dijit */
require_once 'Zend/Dojo/Form/Element/Dijit.php';
/**
* CheckBox dijit
*
* Note: this would be easier with mixins or traits...
*
* @uses Zend_Dojo_Form_Element_Dijit
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CheckBox.php 10001 2008-07-08 21:26:09Z matthew $
*/
class Zend_Dojo_Form_Element_CheckBox extends Zend_Dojo_Form_Element_Dijit
{
/**
* Is the checkbox checked?
* @var bool
*/
public $checked = false;
/**
* Use formCheckbox view helper by default
* @var string
*/
public $helper = 'CheckBox';
/**
* Value when checked
* @var string
*/
protected $_checkedValue = '1';
/**
* Value when not checked
* @var string
*/
protected $_uncheckedValue = '0';
/**
* Current value
* @var string 0 or 1
*/
protected $_value = '0';
/**
* Set options
*
* Intercept checked and unchecked values and set them early; test stored
* value against checked and unchecked values after configuration.
*
* @param array $options
* @return Zend_Form_Element_Checkbox
*/
public function setOptions(array $options)
{
if (array_key_exists('checkedValue', $options)) {
$this->setCheckedValue($options['checkedValue']);
unset($options['checkedValue']);
}
if (array_key_exists('uncheckedValue', $options)) {
$this->setUncheckedValue($options['uncheckedValue']);
unset($options['uncheckedValue']);
}
parent::setOptions($options);
$curValue = $this->getValue();
$test = array($this->getCheckedValue(), $this->getUncheckedValue());
if (!in_array($curValue, $test)) {
$this->setValue($curValue);
}
return $this;
}
/**
* Set value
*
* If value matches checked value, sets to that value, and sets the checked
* flag to true.
*
* Any other value causes the unchecked value to be set as the current
* value, and the checked flag to be set as false.
*
*
* @param mixed $value
* @return Zend_Form_Element_Checkbox
*/
public function setValue($value)
{
if ($value == $this->getCheckedValue()) {
parent::setValue($value);
$this->checked = true;
} else {
parent::setValue($this->getUncheckedValue());
$this->checked = false;
}
return $this;
}
/**
* Set checked value
*
* @param string $value
* @return Zend_Form_Element_Checkbox
*/
public function setCheckedValue($value)
{
$this->_checkedValue = (string) $value;
return $this;
}
/**
* Get value when checked
*
* @return string
*/
public function getCheckedValue()
{
return $this->_checkedValue;
}
/**
* Set unchecked value
*
* @param string $value
* @return Zend_Form_Element_Checkbox
*/
public function setUncheckedValue($value)
{
$this->_uncheckedValue = (string) $value;
return $this;
}
/**
* Get value when not checked
*
* @return string
*/
public function getUncheckedValue()
{
return $this->_uncheckedValue;
}
/**
* Set checked flag
*
* @param bool $flag
* @return Zend_Form_Element_Checkbox
*/
public function setChecked($flag)
{
$this->checked = (bool) $flag;
if ($this->checked) {
$this->setValue($this->getCheckedValue());
} else {
$this->setValue($this->getUncheckedValue());
}
return $this;
}
/**
* Get checked flag
*
* @return bool
*/
public function isChecked()
{
return $this->checked;
}
/**
* Render
*
* Ensure that options property is set when rendering.
*
* @param Zend_View_Interface $view
* @return string
*/
public function render(Zend_View_Interface $view = null)
{
$this->options = array(
'checked' => $this->getCheckedValue(),
'unChecked' => $this->getUncheckedValue(),
);
return parent::render($view);
}
}

View File

@ -0,0 +1,186 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_DijitMulti */
require_once 'Zend/Dojo/Form/Element/DijitMulti.php';
/**
* ComboBox dijit
*
* @uses Zend_Dojo_Form_Element_DijitMulti
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ComboBox.php 10723 2008-08-06 15:30:18Z matthew $
*/
class Zend_Dojo_Form_Element_ComboBox extends Zend_Dojo_Form_Element_DijitMulti
{
/**
* Use ComboBox dijit view helper
* @var string
*/
public $helper = 'ComboBox';
/**
* Flag: autoregister inArray validator?
* @var bool
*/
protected $_registerInArrayValidator = false;
/**
* Get datastore information
*
* @return array
*/
public function getStoreInfo()
{
if (!$this->hasDijitParam('store')) {
$this->dijitParams['store'] = array();
}
return $this->dijitParams['store'];
}
/**
* Set datastore identifier
*
* @param string $identifier
* @return Zend_Dojo_Form_Element_ComboBox
*/
public function setStoreId($identifier)
{
$store = $this->getStoreInfo();
$store['store'] = (string) $identifier;
$this->setDijitParam('store', $store);
return $this;
}
/**
* Get datastore identifier
*
* @return string|null
*/
public function getStoreId()
{
$store = $this->getStoreInfo();
if (array_key_exists('store', $store)) {
return $store['store'];
}
return null;
}
/**
* Set datastore dijit type
*
* @param string $dojoType
* @return Zend_Dojo_Form_Element_ComboBox
*/
public function setStoreType($dojoType)
{
$store = $this->getStoreInfo();
$store['type'] = (string) $dojoType;
$this->setDijitParam('store', $store);
return $this;
}
/**
* Get datastore dijit type
*
* @return string|null
*/
public function getStoreType()
{
$store = $this->getStoreInfo();
if (array_key_exists('type', $store)) {
return $store['type'];
}
return null;
}
/**
* Set datastore parameters
*
* @param array $params
* @return Zend_Dojo_Form_Element_ComboBox
*/
public function setStoreParams(array $params)
{
$store = $this->getStoreInfo();
$store['params'] = $params;
$this->setDijitParam('store', $store);
return $this;
}
/**
* Get datastore params
*
* @return array
*/
public function getStoreParams()
{
$store = $this->getStoreInfo();
if (array_key_exists('params', $store)) {
return $store['params'];
}
return array();
}
/**
* Set autocomplete flag
*
* @param bool $flag
* @return Zend_Dojo_Form_Element_ComboBox
*/
public function setAutocomplete($flag)
{
$this->setDijitParam('autocomplete', (bool) $flag);
return $this;
}
/**
* Get autocomplete flag
*
* @return bool
*/
public function getAutocomplete()
{
if (!$this->hasDijitParam('autocomplete')) {
return false;
}
return $this->getDijitParam('autocomplete');
}
/**
* Is the value valid?
*
* @param string $value
* @param mixed $context
* @return bool
*/
public function isValid($value, $context = null)
{
$storeInfo = $this->getStoreInfo();
if (!empty($storeInfo)) {
$this->setRegisterInArrayValidator(false);
}
return parent::isValid($value, $context);
}
}

View File

@ -0,0 +1,120 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_NumberTextBox */
require_once 'Zend/Dojo/Form/Element/NumberTextBox.php';
/**
* CurrencyTextBox dijit
*
* @uses Zend_Dojo_Form_Element_NumberTextBox
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CurrencyTextBox.php 10079 2008-07-14 10:56:37Z matthew $
*/
class Zend_Dojo_Form_Element_CurrencyTextBox extends Zend_Dojo_Form_Element_NumberTextBox
{
/**
* Use CurrencyTextBox dijit view helper
* @var string
*/
public $helper = 'CurrencyTextBox';
/**
* Set currency
*
* @param string $currency
* @return Zend_Dojo_Form_Element_CurrencyTextBox
*/
public function setCurrency($currency)
{
$this->setDijitParam('currency', (string) $currency);
return $this;
}
/**
* Retrieve currency
*
* @return string|null
*/
public function getCurrency()
{
return $this->getDijitParam('currency');
}
/**
* Set currency symbol
*
* Casts to string, uppercases, and trims to three characters.
*
* @param string $symbol
* @return Zend_Dojo_Form_Element_CurrencyTextBox
*/
public function setSymbol($symbol)
{
$symbol = strtoupper((string) $symbol);
$length = strlen($symbol);
if (3 > $length) {
require_once 'Zend/Form/Element/Exception.php';
throw new Zend_Form_Element_Exception('Invalid symbol provided; please provide ISO 4217 alphabetic currency code');
}
if (3 < $length) {
$symbol = substr($symbol, 0, 3);
}
$this->setConstraint('symbol', $symbol);
return $this;
}
/**
* Retrieve symbol
*
* @return string|null
*/
public function getSymbol()
{
return $this->getConstraint('symbol');
}
/**
* Set whether currency is fractional
*
* @param bool $flag
* @return Zend_Dojo_Form_Element_CurrencyTextBox
*/
public function setFractional($flag)
{
$this->setConstraint('fractional', (bool) $flag);
return $this;
}
/**
* Get whether or not to present fractional values
*
* @return bool
*/
public function getFractional()
{
return ('true' == $this->getConstraint('fractional'));
}
}

View File

@ -0,0 +1,214 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_ValidationTextBox */
require_once 'Zend/Dojo/Form/Element/ValidationTextBox.php';
/**
* DateTextBox dijit
*
* @uses Zend_Dojo_Form_Element_ValidationTextBox
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DateTextBox.php 10079 2008-07-14 10:56:37Z matthew $
*/
class Zend_Dojo_Form_Element_DateTextBox extends Zend_Dojo_Form_Element_ValidationTextBox
{
/**
* Use DateTextBox dijit view helper
* @var string
*/
public $helper = 'DateTextBox';
/**
* Allowed formatLength types
* @var array
*/
protected $_allowedFormatTypes = array(
'long',
'short',
'medium',
'full',
);
/**
* Allowed selector types
* @var array
*/
protected $_allowedSelectorTypes = array(
'time',
'date',
);
/**
* Set am,pm flag
*
* @param bool $am,pm
* @return Zend_Dojo_Form_Element_DateTextBox
*/
public function setAmPm($flag)
{
$this->setConstraint('am,pm', (bool) $flag);
return $this;
}
/**
* Retrieve am,pm flag
*
* @return bool
*/
public function getAmPm()
{
if (!$this->hasConstraint('am,pm')) {
return false;
}
return ('true' ==$this->getConstraint('am,pm'));
}
/**
* Set strict flag
*
* @param bool $strict
* @return Zend_Dojo_Form_Element_DateTextBox
*/
public function setStrict($flag)
{
$this->setConstraint('strict', (bool) $flag);
return $this;
}
/**
* Retrieve strict flag
*
* @return bool
*/
public function getStrict()
{
if (!$this->hasConstraint('strict')) {
return false;
}
return ('true' == $this->getConstraint('strict'));
}
/**
* Set locale
*
* @param string $locale
* @return Zend_Dojo_Form_Element_DateTextBox
*/
public function setLocale($locale)
{
$this->setConstraint('locale', (string) $locale);
return $this;
}
/**
* Retrieve locale
*
* @return string|null
*/
public function getLocale()
{
return $this->getConstraint('locale');
}
/**
* Set date format pattern
*
* @param string $pattern
* @return Zend_Dojo_Form_Element_NumberTextBox
*/
public function setDatePattern($pattern)
{
$this->setConstraint('datePattern', (string) $pattern);
return $this;
}
/**
* Retrieve date format pattern
*
* @return string|null
*/
public function getDatePattern()
{
return $this->getConstraint('datePattern');
}
/**
* Set numeric format formatLength
*
* @see $_allowedFormatTypes
* @param string $formatLength
* @return Zend_Dojo_Form_Element_NumberTextBox
*/
public function setFormatLength($formatLength)
{
$formatLength = strtolower($formatLength);
if (!in_array($formatLength, $this->_allowedFormatTypes)) {
require_once 'Zend/Form/Element/Exception.php';
throw new Zend_Form_Element_Exception(sprintf('Invalid formatLength "%s" specified', $formatLength));
}
$this->setConstraint('formatLength', $formatLength);
return $this;
}
/**
* Retrieve formatLength
*
* @return string|null
*/
public function getFormatLength()
{
return $this->getConstraint('formatLength');
}
/**
* Set numeric format Selector
*
* @see $_allowedSelectorTypes
* @param string $selector
* @return Zend_Dojo_Form_Element_NumberTextBox
*/
public function setSelector($selector)
{
$selector = strtolower($selector);
if (!in_array($selector, $this->_allowedSelectorTypes)) {
require_once 'Zend/Form/Element/Exception.php';
throw new Zend_Form_Element_Exception(sprintf('Invalid Selector "%s" specified', $selector));
}
$this->setConstraint('selector', $selector);
return $this;
}
/**
* Retrieve selector
*
* @return string|null
*/
public function getSelector()
{
return $this->getConstraint('selector');
}
}

View File

@ -0,0 +1,188 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Form_Element */
require_once 'Zend/Form/Element.php';
/**
* Base element for dijit elements
*
* @category Zend
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Dijit.php 10076 2008-07-13 12:58:08Z matthew $
*/
abstract class Zend_Dojo_Form_Element_Dijit extends Zend_Form_Element
{
/**
* Dijit parameters
* @var array
*/
public $dijitParams = array();
/**
* View helper to use
* @var string
*/
public $helper;
/**
* Constructor
*
* @todo Should we set dojo view helper paths here?
* @param mixed $spec
* @param mixed $options
* @return void
*/
public function __construct($spec, $options = null)
{
$this->addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator');
parent::__construct($spec, $options);
}
/**
* Set a dijit parameter
*
* @param string $key
* @param mixed $value
* @return Zend_Dojo_Form_Element_Dijit
*/
public function setDijitParam($key, $value)
{
$key = (string) $key;
$this->dijitParams[$key] = $value;
return $this;
}
/**
* Set multiple dijit params at once
*
* @param array $params
* @return Zend_Dojo_Form_Element_Dijit
*/
public function setDijitParams(array $params)
{
$this->dijitParams = array_merge($this->dijitParams, $params);
return $this;
}
/**
* Does the given dijit parameter exist?
*
* @param string $key
* @return bool
*/
public function hasDijitParam($key)
{
return array_key_exists($key, $this->dijitParams);
}
/**
* Get a single dijit parameter
*
* @param string $key
* @return mixed
*/
public function getDijitParam($key)
{
$key = (string) $key;
if ($this->hasDijitParam($key)) {
return $this->dijitParams[$key];
}
return null;
}
/**
* Retrieve all dijit parameters
*
* @return array
*/
public function getDijitParams()
{
return $this->dijitParams;
}
/**
* Remove a single dijit parameter
*
* @param string $key
* @return Zend_Dojo_Form_Element_Dijit
*/
public function removeDijitParam($key)
{
$key = (string) $key;
if (array_key_exists($key, $this->dijitParams)) {
unset($this->dijitParams[$key]);
}
return $this;
}
/**
* Clear all dijit parameters
*
* @return Zend_Dojo_Form_Element_Dijit
*/
public function clearDijitParams()
{
$this->dijitParams = array();
return $this;
}
/**
* Load default decorators
*
* @return void
*/
public function loadDefaultDecorators()
{
if ($this->loadDefaultDecoratorsIsDisabled()) {
return;
}
$decorators = $this->getDecorators();
if (empty($decorators)) {
$this->addDecorator('DijitElement')
->addDecorator('Errors')
->addDecorator('HtmlTag', array('tag' => 'dd'))
->addDecorator('Label', array('tag' => 'dt'));
}
}
/**
* Set the view object
*
* Ensures that the view object has the dojo view helper path set.
*
* @param Zend_View_Interface $view
* @return Zend_Dojo_Form_Element_Dijit
*/
public function setView(Zend_View_Interface $view = null)
{
if (null !== $view) {
if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
$view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
}
}
return parent::setView($view);
}
}

View File

@ -0,0 +1,304 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_Dijit */
require_once 'Zend/Dojo/Form/Element/Dijit.php';
/**
* CheckBox dijit
*
* Note: this would be easier with mixins or traits...
*
* @uses Zend_Dojo_Form_Element_Dijit
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DijitMulti.php 10646 2008-08-04 20:24:37Z matthew $
*/
abstract class Zend_Dojo_Form_Element_DijitMulti extends Zend_Dojo_Form_Element_Dijit
{
/**
* Array of options for multi-item
* @var array
*/
public $options = array();
/**
* Flag: autoregister inArray validator?
* @var bool
*/
protected $_registerInArrayValidator = true;
/**
* Separator to use between options; defaults to '<br />'.
* @var string
*/
protected $_separator = '<br />';
/**
* Which values are translated already?
* @var array
*/
protected $_translated = array();
/**
* Retrieve separator
*
* @return mixed
*/
public function getSeparator()
{
return $this->_separator;
}
/**
* Set separator
*
* @param mixed $separator
* @return self
*/
public function setSeparator($separator)
{
$this->_separator = $separator;
return $this;
}
/**
* Retrieve options array
*
* @return array
*/
protected function _getMultiOptions()
{
if (null === $this->options || !is_array($this->options)) {
$this->options = array();
}
return $this->options;
}
/**
* Add an option
*
* @param string $option
* @param string $value
* @return Zend_Form_Element_Multi
*/
public function addMultiOption($option, $value = '')
{
$option = (string) $option;
$this->_getMultiOptions();
if (!$this->_translateOption($option, $value)) {
$this->options[$option] = $value;
}
return $this;
}
/**
* Add many options at once
*
* @param array $options
* @return Zend_Form_Element_Multi
*/
public function addMultiOptions(array $options)
{
foreach ($options as $option => $value) {
if (is_array($value)
&& array_key_exists('key', $value)
&& array_key_exists('value', $value)
) {
$this->addMultiOption($value['key'], $value['value']);
} else {
$this->addMultiOption($option, $value);
}
}
return $this;
}
/**
* Set all options at once (overwrites)
*
* @param array $options
* @return Zend_Form_Element_Multi
*/
public function setMultiOptions(array $options)
{
$this->clearMultiOptions();
return $this->addMultiOptions($options);
}
/**
* Retrieve single multi option
*
* @param string $option
* @return mixed
*/
public function getMultiOption($option)
{
$option = (string) $option;
$this->_getMultiOptions();
if (isset($this->options[$option])) {
$this->_translateOption($option, $this->options[$option]);
return $this->options[$option];
}
return null;
}
/**
* Retrieve options
*
* @return array
*/
public function getMultiOptions()
{
$this->_getMultiOptions();
foreach ($this->options as $option => $value) {
$this->_translateOption($option, $value);
}
return $this->options;
}
/**
* Remove a single multi option
*
* @param string $option
* @return bool
*/
public function removeMultiOption($option)
{
$option = (string) $option;
$this->_getMultiOptions();
if (isset($this->options[$option])) {
unset($this->options[$option]);
if (isset($this->_translated[$option])) {
unset($this->_translated[$option]);
}
return true;
}
return false;
}
/**
* Clear all options
*
* @return Zend_Form_Element_Multi
*/
public function clearMultiOptions()
{
$this->options = array();
$this->_translated = array();
return $this;
}
/**
* Set flag indicating whether or not to auto-register inArray validator
*
* @param bool $flag
* @return Zend_Form_Element_Multi
*/
public function setRegisterInArrayValidator($flag)
{
$this->_registerInArrayValidator = (bool) $flag;
return $this;
}
/**
* Get status of auto-register inArray validator flag
*
* @return bool
*/
public function registerInArrayValidator()
{
return $this->_registerInArrayValidator;
}
/**
* Is the value provided valid?
*
* Autoregisters InArray validator if necessary.
*
* @param string $value
* @param mixed $context
* @return bool
*/
public function isValid($value, $context = null)
{
if ($this->registerInArrayValidator()) {
if (!$this->getValidator('InArray')) {
$options = $this->getMultiOptions();
$this->addValidator(
'InArray',
true,
array(array_keys($options))
);
}
}
return parent::isValid($value, $context);
}
/**
* Translate an option
*
* @param string $option
* @param string $value
* @return bool
*/
protected function _translateOption($option, $value)
{
if (!isset($this->_translated[$option])) {
$this->options[$option] = $this->_translateValue($value);
if ($this->options[$option] === $value) {
return false;
}
$this->_translated[$option] = true;
return true;
}
return false;
}
/**
* Translate a value
*
* @param array|string $value
* @return array|string
*/
protected function _translateValue($value)
{
if (is_array($value)) {
foreach ($value as $key => $val) {
$value[$key] = $this->_translateValue($val);
}
return $value;
} else {
if (null !== ($translator = $this->getTranslator())) {
if ($translator->isTranslated($value)) {
return $translator->translate($value);
}
}
return $value;
}
}
}

View File

@ -0,0 +1,598 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_Dijit */
require_once 'Zend/Dojo/Form/Element/Dijit.php';
/**
* Editor dijit
*
* @uses Zend_Dojo_Form_Element_Dijit
* @category Zend
* @package Zend_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_Editor extends Zend_Dojo_Form_Element_Dijit
{
/**
* @var string View helper
*/
public $helper = 'Editor';
/**
* Add a single event to connect to the editing area
*
* @param string $event
* @return Zend_Dojo_Form_Element_Editor
*/
public function addCaptureEvent($event)
{
$event = (string) $event;
$captureEvents = $this->getCaptureEvents();
if (in_array($event, $captureEvents)) {
return $this;
}
$captureEvents[] = (string) $event;
$this->setDijitParam('captureEvents', $captureEvents);
return $this;
}
/**
* Add multiple capture events
*
* @param array $events
* @return Zend_Dojo_Form_Element_Editor
*/
public function addCaptureEvents(array $events)
{
foreach ($events as $event) {
$this->addCaptureEvent($event);
}
return $this;
}
/**
* Overwrite many capture events at once
*
* @param array $events
* @return Zend_Dojo_Form_Element_Editor
*/
public function setCaptureEvents(array $events)
{
$this->clearCaptureEvents();
$this->addCaptureEvents($events);
return $this;
}
/**
* Get all capture events
*
* @return array
*/
public function getCaptureEvents()
{
if (!$this->hasDijitParam('captureEvents')) {
return array();
}
return $this->getDijitParam('captureEvents');
}
/**
* Is a given capture event registered?
*
* @param string $event
* @return bool
*/
public function hasCaptureEvent($event)
{
$captureEvents = $this->getCaptureEvents();
return in_array((string) $event, $captureEvents);
}
/**
* Remove a given capture event
*
* @param string $event
* @return Zend_Dojo_Form_Element_Editor
*/
public function removeCaptureEvent($event)
{
$event = (string) $event;
$captureEvents = $this->getCaptureEvents();
if (false === ($index = array_search($event, $captureEvents))) {
return $this;
}
unset($captureEvents[$index]);
$this->setDijitParam('captureEvents', $captureEvents);
return $this;
}
/**
* Clear all capture events
*
* @return Zend_Dojo_Form_Element_Editor
*/
public function clearCaptureEvents()
{
return $this->removeDijitParam('captureEvents');
}
/**
* Add a single event to the dijit
*
* @param string $event
* @return Zend_Dojo_Form_Element_Editor
*/
public function addEvent($event)
{
$event = (string) $event;
$events = $this->getEvents();
if (in_array($event, $events)) {
return $this;
}
$events[] = (string) $event;
$this->setDijitParam('events', $events);
return $this;
}
/**
* Add multiple events
*
* @param array $events
* @return Zend_Dojo_Form_Element_Editor
*/
public function addEvents(array $events)
{
foreach ($events as $event) {
$this->addEvent($event);
}
return $this;
}
/**
* Overwrite many events at once
*
* @param array $events
* @return Zend_Dojo_Form_Element_Editor
*/
public function setEvents(array $events)
{
$this->clearEvents();
$this->addEvents($events);
return $this;
}
/**
* Get all events
*
* @return array
*/
public function getEvents()
{
if (!$this->hasDijitParam('events')) {
return array();
}
return $this->getDijitParam('events');
}
/**
* Is a given event registered?
*
* @param string $event
* @return bool
*/
public function hasEvent($event)
{
$events = $this->getEvents();
return in_array((string) $event, $events);
}
/**
* Remove a given event
*
* @param string $event
* @return Zend_Dojo_Form_Element_Editor
*/
public function removeEvent($event)
{
$events = $this->getEvents();
if (false === ($index = array_search($event, $events))) {
return $this;
}
unset($events[$index]);
$this->setDijitParam('events', $events);
return $this;
}
/**
* Clear all events
*
* @return Zend_Dojo_Form_Element_Editor
*/
public function clearEvents()
{
return $this->removeDijitParam('events');
}
/**
* Add a single editor plugin
*
* @param string $plugin
* @return Zend_Dojo_Form_Element_Editor
*/
public function addPlugin($plugin)
{
$plugin = (string) $plugin;
$plugins = $this->getPlugins();
if (in_array($plugin, $plugins)) {
return $this;
}
$plugins[] = (string) $plugin;
$this->setDijitParam('plugins', $plugins);
return $this;
}
/**
* Add multiple plugins
*
* @param array $plugins
* @return Zend_Dojo_Form_Element_Editor
*/
public function addPlugins(array $plugins)
{
foreach ($plugins as $plugin) {
$this->addPlugin($plugin);
}
return $this;
}
/**
* Overwrite many plugins at once
*
* @param array $plugins
* @return Zend_Dojo_Form_Element_Editor
*/
public function setPlugins(array $plugins)
{
$this->clearPlugins();
$this->addPlugins($plugins);
return $this;
}
/**
* Get all plugins
*
* @return array
*/
public function getPlugins()
{
if (!$this->hasDijitParam('plugins')) {
return array();
}
return $this->getDijitParam('plugins');
}
/**
* Is a given plugin registered?
*
* @param string $plugin
* @return bool
*/
public function hasPlugin($plugin)
{
$plugins = $this->getPlugins();
return in_array((string) $plugin, $plugins);
}
/**
* Remove a given plugin
*
* @param string $plugin
* @return Zend_Dojo_Form_Element_Editor
*/
public function removePlugin($plugin)
{
$plugins = $this->getPlugins();
if (false === ($index = array_search($plugin, $plugins))) {
return $this;
}
unset($plugins[$index]);
$this->setDijitParam('plugins', $plugins);
return $this;
}
/**
* Clear all plugins
*
* @return Zend_Dojo_Form_Element_Editor
*/
public function clearPlugins()
{
return $this->removeDijitParam('plugins');
}
/**
* Set edit action interval
*
* @param int $interval
* @return Zend_Dojo_Form_Element_Editor
*/
public function setEditActionInterval($interval)
{
return $this->setDijitParam('editActionInterval', (int) $interval);
}
/**
* Get edit action interval; defaults to 3
*
* @return int
*/
public function getEditActionInterval()
{
if (!$this->hasDijitParam('editActionInterval')) {
$this->setEditActionInterval(3);
}
return $this->getDijitParam('editActionInterval');
}
/**
* Set focus on load flag
*
* @param bool $flag
* @return Zend_Dojo_Form_Element_Editor
*/
public function setFocusOnLoad($flag)
{
return $this->setDijitParam('focusOnLoad', (bool) $flag);
}
/**
* Retrieve focus on load flag
*
* @return bool
*/
public function getFocusOnLoad()
{
if (!$this->hasDijitParam('focusOnLoad')) {
return false;
}
return $this->getDijitParam('focusOnLoad');
}
/**
* Set editor height
*
* @param string|int $height
* @return Zend_Dojo_Form_Element_Editor
*/
public function setHeight($height)
{
if (!preg_match('/^\d+(em|px|%)?$/i', $height)) {
require_once 'Zend/Form/Element/Exception.php';
throw new Zend_Form_Element_Exception('Invalid height provided; must be integer or CSS measurement');
}
if (!preg_match('/(em|px|%)$/', $height)) {
$height .= 'px';
}
return $this->setDijitParam('height', $height);
}
/**
* Retrieve height
*
* @return string
*/
public function getHeight()
{
if (!$this->hasDijitParam('height')) {
return '300px';
}
return $this->getDijitParam('height');
}
/**
* Set whether or not to inherit parent's width
*
* @param bool $flag
* @return Zend_Dojo_Form_Element_Editor
*/
public function setInheritWidth($flag)
{
return $this->setDijitParam('inheritWidth', (bool) $flag);
}
/**
* Whether or not to inherit the parent's width
*
* @return bool
*/
public function getInheritWidth()
{
if (!$this->hasDijitParam('inheritWidth')) {
return false;
}
return $this->getDijitParam('inheritWidth');
}
/**
* Set minimum height of editor
*
* @param string|int $minHeight
* @return Zend_Dojo_Form_Element_Editor
*/
public function setMinHeight($minHeight)
{
if (!preg_match('/^\d+(em)?$/i', $minHeight)) {
require_once 'Zend/Form/Element/Exception.php';
throw new Zend_Form_Element_Exception('Invalid minHeight provided; must be integer or CSS measurement');
}
if ('em' != substr($minHeight, -2)) {
$minHeight .= 'em';
}
return $this->setDijitParam('minHeight', $minHeight);
}
/**
* Get minimum height of editor
*
* @return string
*/
public function getMinHeight()
{
if (!$this->hasDijitParam('minHeight')) {
return '1em';
}
return $this->getDijitParam('minHeight');
}
/**
* Add a custom stylesheet
*
* @param string $styleSheet
* @return Zend_Dojo_Form_Element_Editor
*/
public function addStyleSheet($styleSheet)
{
$stylesheets = $this->getStyleSheets();
if (strstr($stylesheets, ';')) {
$stylesheets = explode(';', $stylesheets);
} elseif (!empty($stylesheets)) {
$stylesheets = (array) $stylesheets;
} else {
$stylesheets = array();
}
if (!in_array($styleSheet, $stylesheets)) {
$stylesheets[] = (string) $styleSheet;
}
return $this->setDijitParam('styleSheets', implode(';', $stylesheets));
}
/**
* Add multiple custom stylesheets
*
* @param array $styleSheets
* @return Zend_Dojo_Form_Element_Editor
*/
public function addStyleSheets(array $styleSheets)
{
foreach ($styleSheets as $styleSheet) {
$this->addStyleSheet($styleSheet);
}
return $this;
}
/**
* Overwrite all stylesheets
*
* @param array $styleSheets
* @return Zend_Dojo_Form_Element_Editor
*/
public function setStyleSheets(array $styleSheets)
{
$this->clearStyleSheets();
return $this->addStyleSheets($styleSheets);
}
/**
* Get all stylesheets
*
* @return string
*/
public function getStyleSheets()
{
if (!$this->hasDijitParam('styleSheets')) {
return '';
}
return $this->getDijitParam('styleSheets');
}
/**
* Is a given stylesheet registered?
*
* @param string $styleSheet
* @return bool
*/
public function hasStyleSheet($styleSheet)
{
$styleSheets = $this->getStyleSheets();
$styleSheets = explode(';', $styleSheets);
return in_array($styleSheet, $styleSheets);
}
/**
* Remove a single stylesheet
*
* @param string $styleSheet
* @return Zend_Dojo_Form_Element_Editor
*/
public function removeStyleSheet($styleSheet)
{
$styleSheets = $this->getStyleSheets();
$styleSheets = explode(';', $styleSheets);
if (false !== ($index = array_search($styleSheet, $styleSheets))) {
unset($styleSheets[$index]);
$this->setDijitParam('styleSheets', implode(';', $styleSheets));
}
return $this;
}
/**
* Clear all stylesheets
*
* @return Zend_Dojo_Form_Element_Editor
*/
public function clearStyleSheets()
{
if ($this->hasDijitParam('styleSheets')) {
$this->removeDijitParam('styleSheets');
}
return $this;
}
/**
* Set update interval
*
* @param int $interval
* @return Zend_Dojo_Form_Element_Editor
*/
public function setUpdateInterval($interval)
{
return $this->setDijitParam('updateInterval', (int) $interval);
}
/**
* Get update interval
*
* @return int
*/
public function getUpdateInterval()
{
if (!$this->hasDijitParam('updateInterval')) {
return 200;
}
return $this->getDijitParam('updateInterval');
}
}

View File

@ -0,0 +1,48 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_ComboBox */
require_once 'Zend/Dojo/Form/Element/ComboBox.php';
/**
* FilteringSelect dijit
*
* @uses Zend_Dojo_Form_Element_ComboBox
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: FilteringSelect.php 10723 2008-08-06 15:30:18Z matthew $
*/
class Zend_Dojo_Form_Element_FilteringSelect extends Zend_Dojo_Form_Element_ComboBox
{
/**
* Use FilteringSelect dijit view helper
* @var string
*/
public $helper = 'FilteringSelect';
/**
* Flag: autoregister inArray validator?
* @var bool
*/
protected $_registerInArrayValidator = true;
}

View File

@ -0,0 +1,208 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_Slider */
require_once 'Zend/Dojo/Form/Element/Slider.php';
/**
* HorizontalSlider dijit
*
* @uses Zend_Dojo_Form_Element_Slider
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: HorizontalSlider.php 10012 2008-07-09 20:47:48Z matthew $
*/
class Zend_Dojo_Form_Element_HorizontalSlider extends Zend_Dojo_Form_Element_Slider
{
/**
* Use HorizontalSlider dijit view helper
* @var string
*/
public $helper = 'HorizontalSlider';
/**
* Get top decoration data
*
* @return array
*/
public function getTopDecoration()
{
if ($this->hasDijitParam('topDecoration')) {
return $this->getDijitParam('topDecoration');
}
return array();
}
/**
* Set dijit to use with top decoration
*
* @param mixed $dijit
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setTopDecorationDijit($dijit)
{
$decoration = $this->getTopDecoration();
$decoration['dijit'] = (string) $dijit;
$this->setDijitParam('topDecoration', $decoration);
return $this;
}
/**
* Set container to use with top decoration
*
* @param mixed $container
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setTopDecorationContainer($container)
{
$decoration = $this->getTopDecoration();
$decoration['container'] = (string) $container;
$this->setDijitParam('topDecoration', $decoration);
return $this;
}
/**
* Set labels to use with top decoration
*
* @param array $labels
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setTopDecorationLabels(array $labels)
{
$decoration = $this->getTopDecoration();
$decoration['labels'] = array_values($labels);
$this->setDijitParam('topDecoration', $decoration);
return $this;
}
/**
* Set params to use with top decoration
*
* @param array $params
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setTopDecorationParams(array $params)
{
$decoration = $this->getTopDecoration();
$decoration['params'] = $params;
$this->setDijitParam('topDecoration', $decoration);
return $this;
}
/**
* Set attribs to use with top decoration
*
* @param array $attribs
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setTopDecorationAttribs(array $attribs)
{
$decoration = $this->getTopDecoration();
$decoration['attribs'] = $attribs;
$this->setDijitParam('topDecoration', $decoration);
return $this;
}
/**
* Get bottom decoration data
*
* @return array
*/
public function getBottomDecoration()
{
if ($this->hasDijitParam('bottomDecoration')) {
return $this->getDijitParam('bottomDecoration');
}
return array();
}
/**
* Set dijit to use with bottom decoration
*
* @param mixed $dijit
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setBottomDecorationDijit($dijit)
{
$decoration = $this->getBottomDecoration();
$decoration['dijit'] = (string) $dijit;
$this->setDijitParam('bottomDecoration', $decoration);
return $this;
}
/**
* Set container to use with bottom decoration
*
* @param mixed $container
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setBottomDecorationContainer($container)
{
$decoration = $this->getBottomDecoration();
$decoration['container'] = (string) $container;
$this->setDijitParam('bottomDecoration', $decoration);
return $this;
}
/**
* Set labels to use with bottom decoration
*
* @param array $labels
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setBottomDecorationLabels(array $labels)
{
$decoration = $this->getBottomDecoration();
$decoration['labels'] = array_values($labels);
$this->setDijitParam('bottomDecoration', $decoration);
return $this;
}
/**
* Set params to use with bottom decoration
*
* @param array $params
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setBottomDecorationParams(array $params)
{
$decoration = $this->getBottomDecoration();
$decoration['params'] = $params;
$this->setDijitParam('bottomDecoration', $decoration);
return $this;
}
/**
* Set attribs to use with bottom decoration
*
* @param array $attribs
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setBottomDecorationAttribs(array $attribs)
{
$decoration = $this->getBottomDecoration();
$decoration['attribs'] = $attribs;
$this->setDijitParam('bottomDecoration', $decoration);
return $this;
}
}

View File

@ -0,0 +1,245 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_ValidationTextBox */
require_once 'Zend/Dojo/Form/Element/ValidationTextBox.php';
/**
* NumberSpinner dijit
*
* @uses Zend_Dojo_Form_Element_ValidationTextBox
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: NumberSpinner.php 10069 2008-07-12 23:48:03Z matthew $
*/
class Zend_Dojo_Form_Element_NumberSpinner extends Zend_Dojo_Form_Element_ValidationTextBox
{
/**
* Use NumberSpinner dijit view helper
* @var string
*/
public $helper = 'NumberSpinner';
/**
* Set defaultTimeout
*
* @param int $timeout
* @return Zend_Dojo_Form_Element_NumberSpinner
*/
public function setDefaultTimeout($timeout)
{
$this->setDijitParam('defaultTimeout', (int) $timeout);
return $this;
}
/**
* Retrieve defaultTimeout
*
* @return int|null
*/
public function getDefaultTimeout()
{
return $this->getDijitParam('defaultTimeout');
}
/**
* Set timeoutChangeRate
*
* @param int $rate
* @return Zend_Dojo_Form_Element_NumberSpinner
*/
public function setTimeoutChangeRate($rate)
{
$this->setDijitParam('timeoutChangeRate', (int) $rate);
return $this;
}
/**
* Retrieve timeoutChangeRate
*
* @return int|null
*/
public function getTimeoutChangeRate()
{
return $this->getDijitParam('timeoutChangeRate');
}
/**
* Set largeDelta
*
* @param int $delta
* @return Zend_Dojo_Form_Element_NumberSpinner
*/
public function setLargeDelta($delta)
{
$this->setDijitParam('largeDelta', (int) $delta);
return $this;
}
/**
* Retrieve largeDelta
*
* @return int|null
*/
public function getLargeDelta()
{
return $this->getDijitParam('largeDelta');
}
/**
* Set smallDelta
*
* @param int $delta
* @return Zend_Dojo_Form_Element_NumberSpinner
*/
public function setSmallDelta($delta)
{
$this->setDijitParam('smallDelta', (int) $delta);
return $this;
}
/**
* Retrieve smallDelta
*
* @return int|null
*/
public function getSmallDelta()
{
return $this->getDijitParam('smallDelta');
}
/**
* Set intermediateChanges flag
*
* @param bool $flag
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setIntermediateChanges($flag)
{
$this->setDijitParam('intermediateChanges', (bool) $flag);
return $this;
}
/**
* Retrieve intermediateChanges flag
*
* @return bool
*/
public function getIntermediateChanges()
{
if (!$this->hasDijitParam('intermediateChanges')) {
return false;
}
return $this->getDijitParam('intermediateChanges');
}
/**
* Set rangeMessage
*
* @param string $message
* @return Zend_Dojo_Form_Element_NumberSpinner
*/
public function setRangeMessage($message)
{
$this->setDijitParam('rangeMessage', (string) $message);
return $this;
}
/**
* Retrieve rangeMessage
*
* @return string|null
*/
public function getRangeMessage()
{
return $this->getDijitParam('rangeMessage');
}
/**
* Set minimum value
*
* @param int $value
* @return Zend_Dojo_Form_Element_NumberSpinner
*/
public function setMin($value)
{
$constraints = array();
if ($this->hasDijitParam('constraints')) {
$constraints = $this->getDijitParam('constraints');
}
$constraints['min'] = (int) $value;
$this->setDijitParam('constraints', $constraints);
return $this;
}
/**
* Get minimum value
*
* @return null|int
*/
public function getMin()
{
if (!$this->hasDijitParam('constraints')) {
return null;
}
$constraints = $this->getDijitParam('constraints');
if (!array_key_exists('min', $constraints)) {
return null;
}
return $constraints['min'];
}
/**
* Set maximum value
*
* @param int $value
* @return Zend_Dojo_Form_Element_NumberSpinner
*/
public function setMax($value)
{
$constraints = array();
if ($this->hasDijitParam('constraints')) {
$constraints = $this->getDijitParam('constraints');
}
$constraints['max'] = (int) $value;
$this->setDijitParam('constraints', $constraints);
return $this;
}
/**
* Get maximum value
*
* @return null|int
*/
public function getMax()
{
if (!$this->hasDijitParam('constraints')) {
return null;
}
$constraints = $this->getDijitParam('constraints');
if (!array_key_exists('max', $constraints)) {
return null;
}
return $constraints['max'];
}
}

View File

@ -0,0 +1,173 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_ValidationTextBox */
require_once 'Zend/Dojo/Form/Element/ValidationTextBox.php';
/**
* NumberTextBox dijit
*
* @uses Zend_Dojo_Form_Element_ValidationTextBox
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: NumberTextBox.php 10079 2008-07-14 10:56:37Z matthew $
*/
class Zend_Dojo_Form_Element_NumberTextBox extends Zend_Dojo_Form_Element_ValidationTextBox
{
/**
* Use NumberTextBox dijit view helper
* @var string
*/
public $helper = 'NumberTextBox';
/**
* Allowed numeric type formats
* @var array
*/
protected $_allowedTypes = array(
'decimal',
'scientific',
'percent',
'currency',
);
/**
* Set locale
*
* @param string $locale
* @return Zend_Dojo_Form_Element_NumberTextBox
*/
public function setLocale($locale)
{
$this->setConstraint('locale', (string) $locale);
return $this;
}
/**
* Retrieve locale
*
* @return string|null
*/
public function getLocale()
{
return $this->getConstraint('locale');
}
/**
* Set numeric format pattern
*
* @param string $pattern
* @return Zend_Dojo_Form_Element_NumberTextBox
*/
public function setPattern($pattern)
{
$this->setConstraint('pattern', (string) $pattern);
return $this;
}
/**
* Retrieve numeric format pattern
*
* @return string|null
*/
public function getPattern()
{
return $this->getConstraint('pattern');
}
/**
* Set numeric format type
*
* @see $_allowedTypes
* @param string $type
* @return Zend_Dojo_Form_Element_NumberTextBox
*/
public function setType($type)
{
$type = strtolower($type);
if (!in_array($type, $this->_allowedTypes)) {
require_once 'Zend/Form/Element/Exception.php';
throw new Zend_Form_Element_Exception(sprintf('Invalid numeric type "%s" specified', $type));
}
$this->setConstraint('type', $type);
return $this;
}
/**
* Retrieve type
*
* @return string|null
*/
public function getType()
{
return $this->getConstraint('type');
}
/**
* Set decimal places
*
* @param int $places
* @return Zend_Dojo_Form_Element_NumberTextBox
*/
public function setPlaces($places)
{
$this->setConstraint('places', (int) $places);
return $this;
}
/**
* Retrieve decimal places
*
* @return int|null
*/
public function getPlaces()
{
return $this->getConstraint('places');
}
/**
* Set strict flag
*
* @param bool $strict
* @return Zend_Dojo_Form_Element_NumberTextBox
*/
public function setStrict($flag)
{
$this->setConstraint('strict', (bool) $flag);
return $this;
}
/**
* Retrieve strict flag
*
* @return bool
*/
public function getStrict()
{
if (!$this->hasConstraint('strict')) {
return false;
}
return ('true' == $this->getConstraint('strict'));
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_ValidationTextBox */
require_once 'Zend/Dojo/Form/Element/ValidationTextBox.php';
/**
* ValidationTextBox dijit tied to password input
*
* @uses Zend_Dojo_Form_Element_ValidationTextBox
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: PasswordTextBox.php 10667 2008-08-05 13:00:56Z matthew $
*/
class Zend_Dojo_Form_Element_PasswordTextBox extends Zend_Dojo_Form_Element_ValidationTextBox
{
/**
* Use PasswordTextBox dijit view helper
* @var string
*/
public $helper = 'PasswordTextBox';
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_DijitMulti */
require_once 'Zend/Dojo/Form/Element/DijitMulti.php';
/**
* RadioButton dijit
*
* @uses Zend_Dojo_Form_Element_DijitMulti
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: RadioButton.php 10003 2008-07-09 02:40:49Z matthew $
*/
class Zend_Dojo_Form_Element_RadioButton extends Zend_Dojo_Form_Element_DijitMulti
{
/**
* Use RadioButton dijit view helper
* @var string
*/
public $helper = 'RadioButton';
}

View File

@ -0,0 +1,199 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_Dijit */
require_once 'Zend/Dojo/Form/Element/Dijit.php';
/**
* Abstract Slider dijit
*
* @uses Zend_Dojo_Form_Element_Dijit
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Slider.php 10003 2008-07-09 02:40:49Z matthew $
*/
abstract class Zend_Dojo_Form_Element_Slider extends Zend_Dojo_Form_Element_Dijit
{
/**
* Set clickSelect flag
*
* @param bool $clickSelect
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setClickSelect($flag)
{
$this->setDijitParam('clickSelect', (bool) $flag);
return $this;
}
/**
* Retrieve clickSelect flag
*
* @return bool
*/
public function getClickSelect()
{
if (!$this->hasDijitParam('clickSelect')) {
return false;
}
return $this->getDijitParam('clickSelect');
}
/**
* Set intermediateChanges flag
*
* @param bool $intermediateChanges
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setIntermediateChanges($flag)
{
$this->setDijitParam('intermediateChanges', (bool) $flag);
return $this;
}
/**
* Retrieve intermediateChanges flag
*
* @return bool
*/
public function getIntermediateChanges()
{
if (!$this->hasDijitParam('intermediateChanges')) {
return false;
}
return $this->getDijitParam('intermediateChanges');
}
/**
* Set showButtons flag
*
* @param bool $showButtons
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setShowButtons($flag)
{
$this->setDijitParam('showButtons', (bool) $flag);
return $this;
}
/**
* Retrieve showButtons flag
*
* @return bool
*/
public function getShowButtons()
{
if (!$this->hasDijitParam('showButtons')) {
return false;
}
return $this->getDijitParam('showButtons');
}
/**
* Set discreteValues
*
* @param int $value
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setDiscreteValues($value)
{
$this->setDijitParam('discreteValues', (int) $value);
return $this;
}
/**
* Retrieve discreteValues
*
* @return int|null
*/
public function getDiscreteValues()
{
return $this->getDijitParam('discreteValues');
}
/**
* Set maximum
*
* @param int $value
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setMaximum($value)
{
$this->setDijitParam('maximum', (int) $value);
return $this;
}
/**
* Retrieve maximum
*
* @return int|null
*/
public function getMaximum()
{
return $this->getDijitParam('maximum');
}
/**
* Set minimum
*
* @param int $value
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setMinimum($value)
{
$this->setDijitParam('minimum', (int) $value);
return $this;
}
/**
* Retrieve minimum
*
* @return int|null
*/
public function getMinimum()
{
return $this->getDijitParam('minimum');
}
/**
* Set pageIncrement
*
* @param int $value
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setPageIncrement($value)
{
$this->setDijitParam('pageIncrement', (int) $value);
return $this;
}
/**
* Retrieve pageIncrement
*
* @return int|null
*/
public function getPageIncrement()
{
return $this->getDijitParam('pageIncrement');
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_Button */
require_once 'Zend/Dojo/Form/Element/Button.php';
/**
* Submit button dijit
*
* @category Zend
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SubmitButton.php 10621 2008-08-04 00:05:33Z matthew $
*/
class Zend_Dojo_Form_Element_SubmitButton extends Zend_Dojo_Form_Element_Button
{
/**
* Use SubmitButton dijit view helper
* @var string
*/
public $helper = 'SubmitButton';
}

View File

@ -0,0 +1,164 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_Dijit */
require_once 'Zend/Dojo/Form/Element/Dijit.php';
/**
* TextBox dijit
*
* @category Zend
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: TextBox.php 10003 2008-07-09 02:40:49Z matthew $
*/
class Zend_Dojo_Form_Element_TextBox extends Zend_Dojo_Form_Element_Dijit
{
/**
* Use TextBox dijit view helper
* @var string
*/
public $helper = 'TextBox';
/**
* Set lowercase flag
*
* @param bool $lowercase
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setLowercase($flag)
{
$this->setDijitParam('lowercase', (bool) $flag);
return $this;
}
/**
* Retrieve lowercase flag
*
* @return bool
*/
public function getLowercase()
{
if (!$this->hasDijitParam('lowercase')) {
return false;
}
return $this->getDijitParam('lowercase');
}
/**
* Set propercase flag
*
* @param bool $propercase
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setPropercase($flag)
{
$this->setDijitParam('propercase', (bool) $flag);
return $this;
}
/**
* Retrieve propercase flag
*
* @return bool
*/
public function getPropercase()
{
if (!$this->hasDijitParam('propercase')) {
return false;
}
return $this->getDijitParam('propercase');
}
/**
* Set uppercase flag
*
* @param bool $uppercase
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setUppercase($flag)
{
$this->setDijitParam('uppercase', (bool) $flag);
return $this;
}
/**
* Retrieve uppercase flag
*
* @return bool
*/
public function getUppercase()
{
if (!$this->hasDijitParam('uppercase')) {
return false;
}
return $this->getDijitParam('uppercase');
}
/**
* Set trim flag
*
* @param bool $trim
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setTrim($flag)
{
$this->setDijitParam('trim', (bool) $flag);
return $this;
}
/**
* Retrieve trim flag
*
* @return bool
*/
public function getTrim()
{
if (!$this->hasDijitParam('trim')) {
return false;
}
return $this->getDijitParam('trim');
}
/**
* Set maxLength
*
* @param int $length
* @return Zend_Dojo_Form_Element_TextBox
*/
public function setMaxLength($length)
{
$this->setDijitParam('maxLength', (int) $length);
return $this;
}
/**
* Retrieve maxLength
*
* @return int|null
*/
public function getMaxLength()
{
return $this->getDijitParam('maxLength');
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_Dijit */
require_once 'Zend/Dojo/Form/Element/Dijit.php';
/**
* Textarea dijit
*
* @category Zend
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Textarea.php 10001 2008-07-08 21:26:09Z matthew $
*/
class Zend_Dojo_Form_Element_Textarea extends Zend_Dojo_Form_Element_Dijit
{
/**
* Use Textarea dijit view helper
* @var string
*/
public $helper = 'Textarea';
}

View File

@ -0,0 +1,152 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_DateTextBox */
require_once 'Zend/Dojo/Form/Element/DateTextBox.php';
/**
* TimeTextBox dijit
*
* @uses Zend_Dojo_Form_Element_DateTextBox
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: TimeTextBox.php 10079 2008-07-14 10:56:37Z matthew $
*/
class Zend_Dojo_Form_Element_TimeTextBox extends Zend_Dojo_Form_Element_DateTextBox
{
/**
* Use TimeTextBox dijit view helper
* @var string
*/
public $helper = 'TimeTextBox';
/**
* Validate ISO 8601 time format
*
* @param string $format
* @return true
* @throws Zend_Form_Element_Exception
*/
protected function _validateIso8601($format)
{
if (!preg_match('/^T\d{2}:\d{2}:\d{2}$/', $format)) {
require_once 'Zend/Form/Element/Exception.php';
throw new Zend_Form_Element_Exception(sprintf('Invalid format "%s" provided; must match T:00:00:00 format', $format));
}
return true;
}
/**
* Set time format pattern
*
* @param string $pattern
* @return Zend_Dojo_Form_Element_NumberTextBox
*/
public function setTimePattern($pattern)
{
$this->setConstraint('timePattern', (string) $pattern);
return $this;
}
/**
* Retrieve time format pattern
*
* @return string|null
*/
public function getTimePattern()
{
return $this->getConstraint('timePattern');
}
/**
* Set clickableIncrement
*
* @param string $format
* @return Zend_Dojo_Form_Element_NumberTextBox
*/
public function setClickableIncrement($format)
{
$format = (string) $format;
$this->_validateIso8601($format);
$this->setConstraint('clickableIncrement', $format);
return $this;
}
/**
* Retrieve clickableIncrement
*
* @return string|null
*/
public function getClickableIncrement()
{
return $this->getConstraint('clickableIncrement');
}
/**
* Set visibleIncrement
*
* @param string $format
* @return Zend_Dojo_Form_Element_NumberTextBox
*/
public function setVisibleIncrement($format)
{
$format = (string) $format;
$this->_validateIso8601($format);
$this->setConstraint('visibleIncrement', $format);
return $this;
}
/**
* Retrieve visibleIncrement
*
* @return string|null
*/
public function getVisibleIncrement()
{
return $this->getConstraint('visibleIncrement');
}
/**
* Set visibleRange
*
* @param string $format
* @return Zend_Dojo_Form_Element_NumberTextBox
*/
public function setVisibleRange($format)
{
$format = (string) $format;
$this->_validateIso8601($format);
$this->setConstraint('visibleRange', $format);
return $this;
}
/**
* Retrieve visibleRange
*
* @return string|null
*/
public function getVisibleRange()
{
return $this->getConstraint('visibleRange');
}
}

View File

@ -0,0 +1,218 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_TextBox */
require_once 'Zend/Dojo/Form/Element/TextBox.php';
/**
* ValidationTextBox dijit
*
* @uses Zend_Dojo_Form_Element_TextBox
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ValidationTextBox.php 10079 2008-07-14 10:56:37Z matthew $
*/
class Zend_Dojo_Form_Element_ValidationTextBox extends Zend_Dojo_Form_Element_TextBox
{
/**
* Use ValidationTextBox dijit view helper
* @var string
*/
public $helper = 'ValidationTextBox';
/**
* Set invalidMessage
*
* @param string $message
* @return Zend_Dojo_Form_Element_ValidationTextBox
*/
public function setInvalidMessage($message)
{
$this->setDijitParam('invalidMessage', (string) $message);
return $this;
}
/**
* Retrieve invalidMessage
*
* @return string|null
*/
public function getInvalidMessage()
{
return $this->getDijitParam('invalidMessage');
}
/**
* Set promptMessage
*
* @param string $message
* @return Zend_Dojo_Form_Element_ValidationTextBox
*/
public function setPromptMessage($message)
{
$this->setDijitParam('promptMessage', (string) $message);
return $this;
}
/**
* Retrieve promptMessage
*
* @return string|null
*/
public function getPromptMessage()
{
return $this->getDijitParam('promptMessage');
}
/**
* Set regExp
*
* @param string $regexp
* @return Zend_Dojo_Form_Element_ValidationTextBox
*/
public function setRegExp($regexp)
{
$this->setDijitParam('regExp', (string) $regexp);
return $this;
}
/**
* Retrieve regExp
*
* @return string|null
*/
public function getRegExp()
{
return $this->getDijitParam('regExp');
}
/**
* Set an individual constraint
*
* @param string $key
* @param mixed $value
* @return Zend_Dojo_Form_Element_ValidationTextBox
*/
public function setConstraint($key, $value)
{
$constraints = $this->getConstraints();
$constraints[(string) $key] = $value;
$this->setConstraints($constraints);
return $this;
}
/**
* Set validation constraints
*
* Refer to Dojo dijit.form.ValidationTextBox documentation for valid
* structure.
*
* @param array $constraints
* @return Zend_Dojo_Form_Element_ValidationTextBox
*/
public function setConstraints(array $constraints)
{
array_walk_recursive($constraints, array($this, '_castBoolToString'));
$this->setDijitParam('constraints', $constraints);
return $this;
}
/**
* Is the given constraint set?
*
* @param string $key
* @return bool
*/
public function hasConstraint($key)
{
$constraints = $this->getConstraints();
return array_key_exists((string)$key, $constraints);
}
/**
* Get an individual constraint
*
* @param string $key
* @return mixed
*/
public function getConstraint($key)
{
$key = (string) $key;
if (!$this->hasConstraint($key)) {
return null;
}
return $this->dijitParams['constraints'][$key];
}
/**
* Get constraints
*
* @return array
*/
public function getConstraints()
{
if ($this->hasDijitParam('constraints')) {
return $this->getDijitParam('constraints');
}
return array();
}
/**
* Remove a single constraint
*
* @param string $key
* @return Zend_Dojo_Form_Element_ValidationTextBox
*/
public function removeConstraint($key)
{
$key = (string) $key;
if ($this->hasConstraint($key)) {
unset($this->dijitParams['constraints'][$key]);
}
return $this;
}
/**
* Clear all constraints
*
* @return Zend_Dojo_Form_Element_ValidationTextBox
*/
public function clearConstraints()
{
return $this->removeDijitParam('constraints');
}
/**
* Cast a boolean value to a string
*
* @param mixed $item
* @param string $key
* @return void
*/
protected function _castBoolToString(&$item, $key)
{
if (is_bool($item)) {
$item = ($item) ? 'true' : 'false';
}
}
}

View File

@ -0,0 +1,208 @@
<?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_Dojo
* @subpackage Form_Element
* @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_Dojo_Form_Element_Slider */
require_once 'Zend/Dojo/Form/Element/Slider.php';
/**
* VerticalSlider dijit
*
* @uses Zend_Dojo_Form_Element_Slider
* @package Zend_Dojo
* @subpackage Form_Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: VerticalSlider.php 10012 2008-07-09 20:47:48Z matthew $
*/
class Zend_Dojo_Form_Element_VerticalSlider extends Zend_Dojo_Form_Element_Slider
{
/**
* Use VerticalSlider dijit view helper
* @var string
*/
public $helper = 'VerticalSlider';
/**
* Get left decoration data
*
* @return array
*/
public function getLeftDecoration()
{
if ($this->hasDijitParam('leftDecoration')) {
return $this->getDijitParam('leftDecoration');
}
return array();
}
/**
* Set dijit to use with left decoration
*
* @param mixed $dijit
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setLeftDecorationDijit($dijit)
{
$decoration = $this->getLeftDecoration();
$decoration['dijit'] = (string) $dijit;
$this->setDijitParam('leftDecoration', $decoration);
return $this;
}
/**
* Set container to use with left decoration
*
* @param mixed $container
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setLeftDecorationContainer($container)
{
$decoration = $this->getLeftDecoration();
$decoration['container'] = (string) $container;
$this->setDijitParam('leftDecoration', $decoration);
return $this;
}
/**
* Set labels to use with left decoration
*
* @param array $labels
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setLeftDecorationLabels(array $labels)
{
$decoration = $this->getLeftDecoration();
$decoration['labels'] = array_values($labels);
$this->setDijitParam('leftDecoration', $decoration);
return $this;
}
/**
* Set params to use with left decoration
*
* @param array $params
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setLeftDecorationParams(array $params)
{
$decoration = $this->getLeftDecoration();
$decoration['params'] = $params;
$this->setDijitParam('leftDecoration', $decoration);
return $this;
}
/**
* Set attribs to use with left decoration
*
* @param array $attribs
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setLeftDecorationAttribs(array $attribs)
{
$decoration = $this->getLeftDecoration();
$decoration['attribs'] = $attribs;
$this->setDijitParam('leftDecoration', $decoration);
return $this;
}
/**
* Get right decoration data
*
* @return array
*/
public function getRightDecoration()
{
if ($this->hasDijitParam('rightDecoration')) {
return $this->getDijitParam('rightDecoration');
}
return array();
}
/**
* Set dijit to use with right decoration
*
* @param mixed $dijit
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setRightDecorationDijit($dijit)
{
$decoration = $this->getRightDecoration();
$decoration['dijit'] = (string) $dijit;
$this->setDijitParam('rightDecoration', $decoration);
return $this;
}
/**
* Set container to use with right decoration
*
* @param mixed $container
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setRightDecorationContainer($container)
{
$decoration = $this->getRightDecoration();
$decoration['container'] = (string) $container;
$this->setDijitParam('rightDecoration', $decoration);
return $this;
}
/**
* Set labels to use with right decoration
*
* @param array $labels
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setRightDecorationLabels(array $labels)
{
$decoration = $this->getRightDecoration();
$decoration['labels'] = array_values($labels);
$this->setDijitParam('rightDecoration', $decoration);
return $this;
}
/**
* Set params to use with right decoration
*
* @param array $params
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setRightDecorationParams(array $params)
{
$decoration = $this->getRightDecoration();
$decoration['params'] = $params;
$this->setDijitParam('rightDecoration', $decoration);
return $this;
}
/**
* Set attribs to use with right decoration
*
* @param array $attribs
* @return Zend_Dojo_Form_Element_HorizontalSlider
*/
public function setRightDecorationAttribs(array $attribs)
{
$decoration = $this->getRightDecoration();
$decoration['attribs'] = $attribs;
$this->setDijitParam('rightDecoration', $decoration);
return $this;
}
}

View File

@ -0,0 +1,94 @@
<?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_Dojo
* @subpackage Form
* @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_Form_SubForm */
require_once 'Zend/Form/SubForm.php';
/**
* Dijit-enabled SubForm
*
* @uses Zend_Form_SubForm
* @package Zend_Dojo
* @subpackage Form
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SubForm.php 10038 2008-07-10 21:45:16Z matthew $
*/
class Zend_Dojo_Form_SubForm extends Zend_Form_SubForm
{
/**
* Has the dojo view helper path been registered?
* @var bool
*/
protected $_dojoViewPathRegistered = false;
/**
* Constructor
*
* @param array|Zend_Config|null $options
* @return void
*/
public function __construct($options = null)
{
$this->addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
->addPrefixPath('Zend_Dojo_Form_Element', 'Zend/Dojo/Form/Element', 'element')
->addElementPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
->addDisplayGroupPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator')
->setDefaultDisplayGroupClass('Zend_Dojo_Form_DisplayGroup');
parent::__construct($options);
}
/**
* Load the default decorators
*
* @return void
*/
public function loadDefaultDecorators()
{
if ($this->loadDefaultDecoratorsIsDisabled()) {
return;
}
$decorators = $this->getDecorators();
if (empty($decorators)) {
$this->addDecorator('FormElements')
->addDecorator('HtmlTag', array('tag' => 'dl'))
->addDecorator('ContentPane');
}
}
/**
* Get view
*
* @return Zend_View_Interface
*/
public function getView()
{
$view = parent::getView();
if (!$this->_dojoViewPathRegistered) {
if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
$view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
}
$this->_dojoViewPathRegistered = true;
}
return $view;
}
}

View File

@ -0,0 +1,6 @@
<?php
require_once 'Zend/Dojo/Exception.php';
class Zend_Dojo_View_Exception extends Zend_Dojo_Exception
{
}

View File

@ -0,0 +1,66 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: AccordionContainer.php 10067 2008-07-12 21:05:32Z matthew $
*/
/** Zend_Dojo_View_Helper_DijitContainer */
require_once 'Zend/Dojo/View/Helper/DijitContainer.php';
/**
* Dojo AccordionContainer dijit
*
* @uses Zend_Dojo_View_Helper_DijitContainer
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_AccordionContainer extends Zend_Dojo_View_Helper_DijitContainer
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.layout.AccordionContainer';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.layout.AccordionContainer';
/**
* dijit.layout.AccordionContainer
*
* @param string $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function accordionContainer($id = null, $content = '', array $params = array(), array $attribs = array())
{
if (0 === func_num_args()) {
return $this;
}
return $this->_createLayoutContainer($id, $content, $params, $attribs);
}
}

View File

@ -0,0 +1,66 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: AccordionPane.php 10067 2008-07-12 21:05:32Z matthew $
*/
/** Zend_Dojo_View_Helper_DijitContainer */
require_once 'Zend/Dojo/View/Helper/DijitContainer.php';
/**
* Dojo AccordionPane dijit
*
* @uses Zend_Dojo_View_Helper_DijitContainer
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_AccordionPane extends Zend_Dojo_View_Helper_DijitContainer
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.layout.AccordionPane';
/**
* Module being used
* @var string
*/
protected $_module = 'dijit.layout.AccordionContainer';
/**
* dijit.layout.AccordionPane
*
* @param int $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function accordionPane($id = null, $content = '', array $params = array(), array $attribs = array())
{
if (0 === func_num_args()) {
return $this;
}
return $this->_createLayoutContainer($id, $content, $params, $attribs);
}
}

View File

@ -0,0 +1,79 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: BorderContainer.php 12378 2008-11-07 18:39:20Z matthew $
*/
/** Zend_Dojo_View_Helper_DijitContainer */
require_once 'Zend/Dojo/View/Helper/DijitContainer.php';
/**
* Dojo BorderContainer dijit
*
* @uses Zend_Dojo_View_Helper_DijitContainer
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_BorderContainer extends Zend_Dojo_View_Helper_DijitContainer
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.layout.BorderContainer';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.layout.BorderContainer';
/**
* Ensure style is only registered once
* @var bool
*/
protected $_styleIsRegistered = false;
/**
* dijit.layout.BorderContainer
*
* @param string $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function borderContainer($id = null, $content = '', array $params = array(), array $attribs = array())
{
if (0 === func_num_args()) {
return $this;
}
// this will ensure that the border container is viewable:
if (!$this->_styleIsRegistered) {
$this->view->headStyle()->appendStyle('html, body { height: 100%; width: 100%; margin: 0; padding: 0; }');
$this->_styleIsRegistered = true;
}
// and now we create it:
return $this->_createLayoutContainer($id, $content, $params, $attribs);
}
}

View File

@ -0,0 +1,68 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Button.php 10091 2008-07-15 03:46:37Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo Button dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_Button extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.Button';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.Button';
/**
* dijit.form.Button
*
* @param string $id
* @param string $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function button($id, $value = null, array $params = array(), array $attribs = array())
{
$attribs['name'] = $id;
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
$attribs = $this->_prepareDijit($attribs, $params, 'element');
return $this->view->formButton($id, $value, $attribs);
}
}

View File

@ -0,0 +1,100 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CheckBox.php 11292 2008-09-08 18:51:39Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo CheckBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_CheckBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.CheckBox';
/**
* Element type
* @var string
*/
protected $_elementType = 'checkbox';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.CheckBox';
/**
* dijit.form.CheckBox
*
* @param int $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @param array $checkedOptions Should contain either two items, or the keys checkedValue and unCheckedValue
* @return string
*/
public function checkBox($id, $value = null, array $params = array(), array $attribs = array(), array $checkedOptions = null)
{
// Prepare the checkbox options
require_once 'Zend/View/Helper/FormCheckbox.php';
$checked = false;
if (isset($attribs['checked']) && $attribs['checked']) {
$checked = true;
} elseif (isset($attribs['checked'])) {
$checked = false;
}
$checkboxInfo = Zend_View_Helper_FormCheckbox::determineCheckboxInfo($value, $checked, $checkedOptions);
$attribs['checked'] = $checkboxInfo['checked'];
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
$attribs = $this->_prepareDijit($attribs, $params, 'element');
// strip options so they don't show up in markup
if (array_key_exists('options', $attribs)) {
unset($attribs['options']);
}
// and now we create it:
$html = '';
if (!strstr($id, '[]')) {
// hidden element for unchecked value
$html .= $this->_renderHiddenElement($id, $checkboxInfo['unCheckedValue']);
}
// and final element
$html .= $this->_createFormElement($id, $checkboxInfo['checkedValue'], $params, $attribs);
return $html;
}
}

View File

@ -0,0 +1,151 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ComboBox.php 11014 2008-08-24 21:15:31Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo ComboBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_ComboBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.ComboBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.ComboBox';
/**
* dijit.form.ComboBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @param array|null $options Select options
* @return string
*/
public function comboBox($id, $value = null, array $params = array(), array $attribs = array(), array $options = null)
{
$html = '';
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
if (array_key_exists('store', $params) && is_array($params['store'])) {
// using dojo.data datastore
if (false !== ($store = $this->_renderStore($params['store']))) {
$params['store'] = $params['store']['store'];
if (is_string($store)) {
$html .= $store;
}
$html .= $this->_createFormElement($id, $value, $params, $attribs);
return $html;
}
unset($params['store']);
} elseif (array_key_exists('store', $params)) {
if (array_key_exists('storeType', $params)) {
$storeParams = array(
'store' => $params['store'],
'type' => $params['storeType'],
);
unset($params['storeType']);
if (array_key_exists('storeParams', $params)) {
$storeParams['params'] = $params['storeParams'];
unset($params['storeParams']);
}
if (false !== ($store = $this->_renderStore($storeParams))) {
if (is_string($store)) {
$html .= $store;
}
}
}
$html .= $this->_createFormElement($id, $value, $params, $attribs);
return $html;
}
// do as normal select
$attribs = $this->_prepareDijit($attribs, $params, 'element');
return $this->view->formSelect($id, $value, $attribs, $options);
}
/**
* Render data store element
*
* Renders to dojo view helper
*
* @param array $params
* @return string|false
*/
protected function _renderStore(array $params)
{
if (!array_key_exists('store', $params) || !array_key_exists('type', $params)) {
return false;
}
$this->dojo->requireModule($params['type']);
$extraParams = array();
$storeParams = array(
'dojoType' => $params['type'],
'jsId' => $params['store'],
);
if (array_key_exists('params', $params)) {
$storeParams = array_merge($storeParams, $params['params']);
$extraParams = $params['params'];
}
if ($this->_useProgrammatic()) {
if (!$this->_useProgrammaticNoScript()) {
$this->dojo->addJavascript('var ' . $storeParams['jsId'] . ';');
require_once 'Zend/Json.php';
$js = "function() {\n"
. ' ' . $storeParams['jsId'] . ' = '
. 'new ' . $storeParams['dojoType'] . '('
. Zend_Json::encode($extraParams)
. ");\n}";
$this->dojo->addOnLoad($js);
}
return true;
}
return '<div' . $this->_htmlAttribs($storeParams) . '></div>';
}
}

View File

@ -0,0 +1,66 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ContentPane.php 10067 2008-07-12 21:05:32Z matthew $
*/
/** Zend_Dojo_View_Helper_DijitContainer */
require_once 'Zend/Dojo/View/Helper/DijitContainer.php';
/**
* Dojo ContentPane dijit
*
* @uses Zend_Dojo_View_Helper_DijitContainer
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_ContentPane extends Zend_Dojo_View_Helper_DijitContainer
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.layout.ContentPane';
/**
* Module being used
* @var string
*/
protected $_module = 'dijit.layout.ContentPane';
/**
* dijit.layout.ContentPane
*
* @param string $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function contentPane($id = null, $content = '', array $params = array(), array $attribs = array())
{
if (0 === func_num_args()) {
return $this;
}
return $this->_createLayoutContainer($id, $content, $params, $attribs);
}
}

View File

@ -0,0 +1,68 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CurrencyTextBox.php 9998 2008-07-08 19:54:41Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo CurrencyTextBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_CurrencyTextBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.CurrencyTextBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.CurrencyTextBox';
/**
* dijit.form.CurrencyTextBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function currencyTextBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}

View File

@ -0,0 +1,68 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DateTextBox.php 9998 2008-07-08 19:54:41Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo DateTextBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_DateTextBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.DateTextBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.DateTextBox';
/**
* dijit.form.DateTextBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function dateTextBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}

View File

@ -0,0 +1,311 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Dijit.php 12281 2008-11-04 14:40:05Z matthew $
*/
/** Zend_View_Helper_HtmlElement */
require_once 'Zend/View/Helper/HtmlElement.php';
/**
* Dojo dijit base class
*
* @uses Zend_View_Helper_Abstract
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_Dijit extends Zend_View_Helper_HtmlElement
{
/**
* @var Zend_Dojo_View_Helper_Dojo_Container
*/
public $dojo;
/**
* Dijit being used
* @var string
*/
protected $_dijit;
/**
* Element type
* @var string
*/
protected $_elementType;
/**
* Parameters that should be JSON encoded
* @var array
*/
protected $_jsonParams = array('constraints');
/**
* Dojo module to use
* @var string
*/
protected $_module;
/**
* Set view
*
* Set view and enable dojo
*
* @param Zend_View_Interface $view
* @return Zend_Dojo_View_Helper_Dijit
*/
public function setView(Zend_View_Interface $view)
{
parent::setView($view);
$this->dojo = $this->view->dojo();
$this->dojo->enable();
return $this;
}
/**
* Whether or not to use declarative dijit creation
*
* @return bool
*/
protected function _useDeclarative()
{
return Zend_Dojo_View_Helper_Dojo::useDeclarative();
}
/**
* Whether or not to use programmatic dijit creation
*
* @return bool
*/
protected function _useProgrammatic()
{
return Zend_Dojo_View_Helper_Dojo::useProgrammatic();
}
/**
* Whether or not to use programmatic dijit creation w/o script creation
*
* @return bool
*/
protected function _useProgrammaticNoScript()
{
return Zend_Dojo_View_Helper_Dojo::useProgrammaticNoScript();
}
/**
* Create a layout container
*
* @param int $id
* @param string $content
* @param array $params
* @param array $attribs
* @param string|null $dijit
* @return string
*/
protected function _createLayoutContainer($id, $content, array $params, array $attribs, $dijit = null)
{
$attribs['id'] = $id;
$attribs = $this->_prepareDijit($attribs, $params, 'layout', $dijit);
$html = '<div' . $this->_htmlAttribs($attribs) . '>'
. $content
. "</div>\n";
return $html;
}
/**
* Create HTML representation of a dijit form element
*
* @param string $id
* @param string $value
* @param array $params
* @param array $attribs
* @param string|null $dijit
* @return string
*/
public function _createFormElement($id, $value, array $params, array $attribs, $dijit = null)
{
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
$attribs['name'] = $id;
$attribs['value'] = (string) $value;
$attribs['type'] = $this->_elementType;
$attribs = $this->_prepareDijit($attribs, $params, 'element', $dijit);
$html = '<input'
. $this->_htmlAttribs($attribs)
. $this->getClosingBracket();
return $html;
}
/**
* Merge attributes and parameters
*
* Also sets up requires
*
* @param array $attribs
* @param array $params
* @param string $type
* @param string $dijit Dijit type to use (otherwise, pull from $_dijit)
* @return array
*/
protected function _prepareDijit(array $attribs, array $params, $type, $dijit = null)
{
$this->dojo->requireModule($this->_module);
switch ($type) {
case 'layout':
$stripParams = array('id');
break;
case 'element':
$stripParams = array('id', 'name', 'value', 'type');
foreach (array('checked', 'disabled', 'readonly') as $attrib) {
if (array_key_exists($attrib, $attribs)) {
if ($attribs[$attrib]) {
$attribs[$attrib] = $attrib;
} else {
unset($attribs[$attrib]);
}
}
}
break;
case 'textarea':
$stripParams = array('id', 'name', 'type');
break;
default:
}
foreach ($stripParams as $param) {
if (array_key_exists($param, $params)) {
unset($params[$param]);
}
}
// Normalize constraints, if present
foreach ($this->_jsonParams as $param) {
if (array_key_exists($param, $params)) {
require_once 'Zend/Json.php';
if (is_array($params[$param])) {
$values = array();
foreach ($params[$param] as $key => $value) {
if (!is_scalar($value)) {
continue;
}
$values[$key] = $value;
}
} elseif (is_string($params[$param])) {
$values = (array) $params[$param];
} else {
$values = array();
}
$values = Zend_Json::encode($values);
if ($this->_useDeclarative()) {
$values = str_replace('"', "'", $values);
}
$params[$param] = $values;
}
}
$dijit = (null === $dijit) ? $this->_dijit : $dijit;
if ($this->_useDeclarative()) {
$attribs = array_merge($attribs, $params);
$attribs['dojoType'] = $dijit;
} elseif (!$this->_useProgrammaticNoScript()) {
$this->_createDijit($dijit, $attribs['id'], $params);
}
return $attribs;
}
/**
* Create a dijit programmatically
*
* @param string $dijit
* @param string $id
* @param array $params
* @return void
*/
protected function _createDijit($dijit, $id, array $params)
{
$params['dojoType'] = $dijit;
array_walk_recursive($params, array($this, '_castBoolToString'));
$this->dojo->setDijit($id, $params);
}
/**
* Cast a boolean to a string value
*
* @param mixed $item
* @param string $key
* @return void
*/
protected function _castBoolToString(&$item, $key)
{
if (!is_bool($item)) {
return;
}
$item = ($item) ? "true" : "false";
}
/**
* Render a hidden element to hold a value
*
* @param string $id
* @param string|int|float $value
* @return string
*/
protected function _renderHiddenElement($id, $value)
{
$hiddenAttribs = array(
'name' => $id,
'value' => (string) $value,
'type' => 'hidden',
);
return '<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket();
}
/**
* Create JS function for retrieving parent form
*
* @return void
*/
protected function _createGetParentFormFunction()
{
$function =<<<EOJ
if (zend == undefined) {
var zend = {};
}
zend.findParentForm = function(elementNode) {
while (elementNode.nodeName.toLowerCase() != 'form') {
elementNode = elementNode.parentNode;
}
return elementNode;
};
EOJ;
$this->dojo->addJavascript($function);
}
}

View File

@ -0,0 +1,92 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DijitContainer.php 11744 2008-10-08 18:06:15Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dijit layout container base class
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_DijitContainer extends Zend_Dojo_View_Helper_Dijit
{
/**
* Capture locks
* @var array
*/
protected $_captureLock = array();
/**
* Metadata information to use with captured content
* @var array
*/
protected $_captureInfo = array();
/**
* Begin capturing content for layout container
*
* @param string $id
* @param array $params
* @param array $attribs
* @return void
*/
public function captureStart($id, array $params = array(), array $attribs = array())
{
if (array_key_exists($id, $this->_captureLock)) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception(sprintf('Lock already exists for id "%s"', $id));
}
$this->_captureLock[$id] = true;
$this->_captureInfo[$id] = array(
'params' => $params,
'attribs' => $attribs,
);
ob_start();
return;
}
/**
* Finish capturing content for layout container
*
* @param string $id
* @return string
*/
public function captureEnd($id)
{
if (!array_key_exists($id, $this->_captureLock)) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception(sprintf('No capture lock exists for id "%s"; nothing to capture', $id));
}
$content = ob_get_clean();
extract($this->_captureInfo[$id]);
unset($this->_captureLock[$id], $this->_captureInfo[$id]);
return $this->_createLayoutContainer($id, $content, $params, $attribs);
}
}

View File

@ -0,0 +1,176 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: Dojo.php 10024 2008-07-10 14:04:33Z matthew $
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Registry */
require_once 'Zend/Registry.php';
/**
* Zend_Dojo_View_Helper_Dojo: Dojo View Helper
*
* Allows specifying stylesheets, path to dojo, module paths, and onLoad
* events.
*
* @package Zend_Dojo
* @subpackage View
* @copyright Copyright (C) 2008 - Present, Zend Technologies, Inc.
* @license New BSD {@link http://framework.zend.com/license/new-bsd}
*/
class Zend_Dojo_View_Helper_Dojo
{
/**#@+
* @const Programmatic dijit creation style constants
*/
const PROGRAMMATIC_SCRIPT = 1;
const PROGRAMMATIC_NOSCRIPT = -1;
/**#@-*/
/**
* @var Zend_View_Interface
*/
public $view;
/**
* @var Zend_Dojo_View_Helper_Dojo_Container
*/
protected $_container;
/**
* @var bool Whether or not dijits should be declared programmatically
*/
protected static $_useProgrammatic = true;
/**
* Initialize helper
*
* Retrieve container from registry or create new container and store in
* registry.
*
* @return void
*/
public function __construct()
{
$registry = Zend_Registry::getInstance();
if (!isset($registry[__CLASS__])) {
require_once 'Zend/Dojo/View/Helper/Dojo/Container.php';
$container = new Zend_Dojo_View_Helper_Dojo_Container();
$registry[__CLASS__] = $container;
}
$this->_container = $registry[__CLASS__];
}
/**
* Set view object
*
* @param Zend_Dojo_View_Interface $view
* @return void
*/
public function setView(Zend_View_Interface $view)
{
$this->view = $view;
$this->_container->setView($view);
}
/**
* Return dojo container
*
* @return Zend_Dojo_View_Helper_Dojo_Container
*/
public function dojo()
{
return $this->_container;
}
/**
* Proxy to container methods
*
* @param string $method
* @param array $args
* @return mixed
* @throws Zend_Dojo_View_Exception For invalid method calls
*/
public function __call($method, $args)
{
if (!method_exists($this->_container, $method)) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception(sprintf('Invalid method "%s" called on dojo view helper', $method));
}
return call_user_func_array(array($this->_container, $method), $args);
}
/**
* Set whether or not dijits should be created declaratively
*
* @return void
*/
public static function setUseDeclarative()
{
self::$_useProgrammatic = false;
}
/**
* Set whether or not dijits should be created programmatically
*
* Optionally, specifiy whether or not dijit helpers should generate the
* programmatic dojo.
*
* @param int $style
* @return void
*/
public static function setUseProgrammatic($style = self::PROGRAMMATIC_SCRIPT)
{
if (!in_array($style, array(self::PROGRAMMATIC_SCRIPT, self::PROGRAMMATIC_NOSCRIPT))) {
$style = self::PROGRAMMATIC_SCRIPT;
}
self::$_useProgrammatic = $style;
}
/**
* Should dijits be created declaratively?
*
* @return bool
*/
public static function useDeclarative()
{
return (false === self::$_useProgrammatic);
}
/**
* Should dijits be created programmatically?
*
* @return bool
*/
public static function useProgrammatic()
{
return (false !== self::$_useProgrammatic);
}
/**
* Should dijits be created programmatically but without scripts?
*
* @return bool
*/
public static function useProgrammaticNoScript()
{
return (self::PROGRAMMATIC_NOSCRIPT === self::$_useProgrammatic);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,132 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
*/
/** Zend_Dojo_View_Helper_Textarea */
require_once 'Zend/Dojo/View/Helper/Textarea.php';
/** Zend_Json */
require_once 'Zend/Json.php';
/**
* Dojo Editor dijit
*
* @uses Zend_Dojo_View_Helper_Textarea
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_Editor extends Zend_Dojo_View_Helper_Textarea
{
/**
* @param string Dijit type
*/
protected $_dijit = 'dijit.Editor';
/**
* @var string Dijit module to load
*/
protected $_module = 'dijit.Editor';
/**
* JSON-encoded parameters
* @var array
*/
protected $_jsonParams = array('captureEvents', 'events', 'plugins');
/**
* dijit.Editor
*
* @param string $id
* @param string $value
* @param array $params
* @param array $attribs
* @return string
*/
public function editor($id, $value = null, $params = array(), $attribs = array())
{
$hiddenName = $id;
if (array_key_exists('id', $attribs)) {
$hiddenId = $attribs['id'];
} else {
$hiddenId = $hiddenName;
}
$hiddenId = $this->_normalizeId($hiddenId);
$textareaName = $this->_normalizeEditorName($hiddenName);
$textareaId = $hiddenId . '-Editor';
$hiddenAttribs = array(
'id' => $hiddenId,
'name' => $hiddenName,
'value' => $value,
'type' => 'hidden',
);
$attribs['id'] = $textareaId;
$this->_createGetParentFormFunction();
$this->_createEditorOnSubmit($hiddenId, $textareaId);
$html = '<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket()
. $this->textarea($textareaName, $value, $params, $attribs);
return $html;
}
/**
* Normalize editor element name
*
* @param string $name
* @return string
*/
protected function _normalizeEditorName($name)
{
if ('[]' == substr($name, -2)) {
$name = substr($name, 0, strlen($name) - 2);
$name .= '[Editor][]';
} else {
$name .= '[Editor]';
}
return $name;
}
/**
* Create onSubmit binding for element
*
* @param string $hiddenId
* @param string $editorId
* @return void
*/
protected function _createEditorOnSubmit($hiddenId, $editorId)
{
$this->dojo->onLoadCaptureStart();
echo <<<EOJ
function() {
var form = zend.findParentForm(dojo.byId('$hiddenId'));
dojo.connect(form, 'onsubmit', function () {
dojo.byId('$hiddenId').value = dijit.byId('$editorId').getValue(false);
});
}
EOJ;
$this->dojo->onLoadCaptureEnd();
}
}

View File

@ -0,0 +1,63 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: FilteringSelect.php 9978 2008-07-07 12:39:39Z matthew $
*/
/** Zend_Dojo_View_Helper_ComboBox */
require_once 'Zend/Dojo/View/Helper/ComboBox.php';
/**
* Dojo FilteringSelect dijit
*
* @uses Zend_Dojo_View_Helper_ComboBox
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_FilteringSelect extends Zend_Dojo_View_Helper_ComboBox
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.FilteringSelect';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.FilteringSelect';
/**
* dijit.form.FilteringSelect
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @param array|null $options Select options
* @return string
*/
public function filteringSelect($id, $value = null, array $params = array(), array $attribs = array(), array $options = null)
{
return $this->comboBox($id, $value, $params, $attribs, $options);
}
}

View File

@ -0,0 +1,96 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Form.php 10196 2008-07-18 22:01:18Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo Form dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_Form extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.Form';
/**
* Module being used
* @var string
*/
protected $_module = 'dijit.form.Form';
/**
* @var Zend_View_Helper_Form
*/
protected $_helper;
/**
* dijit.form.Form
*
* @param string $id
* @param null|array $attribs HTML attributes
* @param false|string $content
* @return string
*/
public function form($id, $attribs = null, $content = false)
{
if (!is_array($attribs)) {
$attribs = (array) $attribs;
}
if (array_key_exists('id', $attribs)) {
$attribs['name'] = $id;
} else {
$attribs['id'] = $id;
}
if (false === $content) {
$content = '';
}
$attribs = $this->_prepareDijit($attribs, array(), 'layout');
return $this->getFormHelper()->form($id, $attribs, $content);
}
/**
* Get standard form helper
*
* @return Zend_View_Helper_Form
*/
public function getFormHelper()
{
if (null === $this->_helper) {
require_once 'Zend/View/Helper/Form.php';
$this->_helper = new Zend_View_Helper_Form;
$this->_helper->setView($this->view);
}
return $this->_helper;
}
}

View File

@ -0,0 +1,62 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: HorizontalSlider.php 9965 2008-07-06 14:46:20Z matthew $
*/
/** Zend_Dojo_View_Helper_Slider */
require_once 'Zend/Dojo/View/Helper/Slider.php';
/**
* Dojo HorizontalSlider dijit
*
* @uses Zend_Dojo_View_Helper_Slider
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_HorizontalSlider extends Zend_Dojo_View_Helper_Slider
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.HorizontalSlider';
/**
* Slider type
* @var string
*/
protected $_sliderType = 'Horizontal';
/**
* dijit.form.HorizontalSlider
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function horizontalSlider($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->prepareSlider($id, $value, $params, $attribs);
}
}

View File

@ -0,0 +1,90 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: NumberSpinner.php 10043 2008-07-11 15:41:54Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo NumberSpinner dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_NumberSpinner extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.NumberSpinner';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.NumberSpinner';
/**
* dijit.form.NumberSpinner
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function numberSpinner($id, $value = null, array $params = array(), array $attribs = array())
{
// Get constraints and serialize to JSON if necessary
if (array_key_exists('constraints', $params)) {
if (!is_array($params['constraints'])) {
unset($params['constraints']);
}
} else {
$constraints = array();
if (array_key_exists('min', $params)) {
$constraints['min'] = $params['min'];
unset($params['min']);
}
if (array_key_exists('max', $params)) {
$constraints['max'] = $params['max'];
unset($params['max']);
}
if (array_key_exists('places', $params)) {
$constraints['places'] = $params['places'];
unset($params['places']);
}
$params['constraints'] = $constraints;
}
return $this->_createFormElement($id, $value, $params, $attribs);
}
}

View File

@ -0,0 +1,68 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: NumberTextBox.php 9998 2008-07-08 19:54:41Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo NumberTextBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_NumberTextBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.NumberTextBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.NumberTextBox';
/**
* dijit.form.NumberTextBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function numberTextBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}

View File

@ -0,0 +1,56 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: PasswordTextBox.php 10667 2008-08-05 13:00:56Z matthew $
*/
/** Zend_Dojo_View_Helper_ValidationTextBox */
require_once 'Zend/Dojo/View/Helper/ValidationTextBox.php';
/**
* Dojo ValidationTextBox dijit tied to password input
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_PasswordTextBox extends Zend_Dojo_View_Helper_ValidationTextBox
{
/**
* HTML element type
* @var string
*/
protected $_elementType = 'password';
/**
* dijit.form.ValidationTextBox tied to password input
*
* @param string $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function passwordTextBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}

View File

@ -0,0 +1,89 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: RadioButton.php 10091 2008-07-15 03:46:37Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo RadioButton dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_RadioButton extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.RadioButton';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.CheckBox';
/**
* dijit.form.RadioButton
*
* @param string $id
* @param string $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @param array $options Array of radio options
* @param string $listsep String with which to separate options
* @return string
*/
public function radioButton(
$id,
$value = null,
array $params = array(),
array $attribs = array(),
array $options = null,
$listsep = "<br />\n"
) {
$attribs['name'] = $id;
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
$attribs = $this->_prepareDijit($attribs, $params, 'element');
if (is_array($options) && $this->_useProgrammatic() && !$this->_useProgrammaticNoScript()) {
$baseId = $id;
if (array_key_exists('id', $attribs)) {
$baseId = $attribs['id'];
}
require_once 'Zend/Filter/Alnum.php';
$filter = new Zend_Filter_Alnum();
foreach (array_keys($options) as $key) {
$optId = $baseId . '-' . $filter->filter($key);
$this->_createDijit($this->_dijit, $optId, array());
}
}
return $this->view->formRadio($id, $value, $attribs, $options, $listsep);
}
}

View File

@ -0,0 +1,77 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* dijit.form.SimpleTextarea view helper
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_SimpleTextarea extends Zend_Dojo_View_Helper_Dijit
{
/**
* @var string Dijit type
*/
protected $_dijit = 'dijit.form.SimpleTextarea';
/**
* @var string HTML element type
*/
protected $_elementType = 'textarea';
/**
* @var string Dojo module
*/
protected $_module = 'dijit.form.SimpleTextarea';
/**
* dijit.form.SimpleTextarea
*
* @param string $id
* @param string $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function simpleTextarea($id, $value = null, array $params = array(), array $attribs = array())
{
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
$attribs['name'] = $id;
$attribs['type'] = $this->_elementType;
$attribs = $this->_prepareDijit($attribs, $params, 'textarea');
$html = '<textarea' . $this->_htmlAttribs($attribs) . '>'
. $this->view->escape($value)
. "</textarea>\n";
return $html;
}
}

View File

@ -0,0 +1,239 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Slider.php 12387 2008-11-07 21:03:34Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Abstract class for Dojo Slider dijits
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_Slider extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.Slider';
/**
* Required slider parameters
* @var array
*/
protected $_requiredParams = array('minimum', 'maximum', 'discreteValues');
/**
* Slider type -- vertical or horizontal
* @var string
*/
protected $_sliderType;
/**
* dijit.form.Slider
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function prepareSlider($id, $value = null, array $params = array(), array $attribs = array())
{
$this->_sliderType = strtolower($this->_sliderType);
// Prepare two items: a hidden element to store the value, and the slider
$hidden = $this->_renderHiddenElement($id, $value);
$hidden = preg_replace('/(name=")([^"]*)"/', 'id="$2" $1$2"', $hidden);
foreach ($this->_requiredParams as $param) {
if (!array_key_exists($param, $params)) {
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception('prepareSlider() requires minimally the "minimum", "maximum", and "discreteValues" parameters');
}
}
$content = '';
$params['value'] = $value;
if (!array_key_exists('onChange', $attribs)) {
$attribs['onChange'] = "dojo.byId('" . $id . "').value = arguments[0];";
}
$id = str_replace('][', '-', $id);
$id = str_replace(array('[', ']'), '-', $id);
$id = rtrim($id, '-');
$id .= '-slider';
switch ($this->_sliderType) {
case 'horizontal':
if (array_key_exists('topDecoration', $params)) {
$content .= $this->_prepareDecoration('topDecoration', $id, $params['topDecoration']);
unset($params['topDecoration']);
}
if (array_key_exists('bottomDecoration', $params)) {
$content .= $this->_prepareDecoration('bottomDecoration', $id, $params['bottomDecoration']);
unset($params['bottomDecoration']);
}
if (array_key_exists('leftDecoration', $params)) {
unset($params['leftDecoration']);
}
if (array_key_exists('rightDecoration', $params)) {
unset($params['rightDecoration']);
}
break;
case 'vertical':
if (array_key_exists('leftDecoration', $params)) {
$content .= $this->_prepareDecoration('leftDecoration', $id, $params['leftDecoration']);
unset($params['leftDecoration']);
}
if (array_key_exists('rightDecoration', $params)) {
$content .= $this->_prepareDecoration('rightDecoration', $id, $params['rightDecoration']);
unset($params['rightDecoration']);
}
if (array_key_exists('topDecoration', $params)) {
unset($params['topDecoration']);
}
if (array_key_exists('bottomDecoration', $params)) {
unset($params['bottomDecoration']);
}
break;
default:
require_once 'Zend/Dojo/View/Exception.php';
throw new Zend_Dojo_View_Exception('Invalid slider type; slider must be horizontal or vertical');
}
return $hidden . $this->_createLayoutContainer($id, $content, $params, $attribs);
}
/**
* Prepare slider decoration
*
* @param string $position
* @param string $id
* @param array $decInfo
* @return string
*/
protected function _prepareDecoration($position, $id, $decInfo)
{
if (!in_array($position, array('topDecoration', 'bottomDecoration', 'leftDecoration', 'rightDecoration'))) {
return '';
}
if (!is_array($decInfo)
|| !array_key_exists('labels', $decInfo)
|| !is_array($decInfo['labels'])
) {
return '';
}
$id .= '-' . $position;
if (!array_key_exists('dijit', $decInfo)) {
$dijit = 'dijit.form.' . ucfirst($this->_sliderType) . 'Rule';
} else {
$dijit = $decInfo['dijit'];
if ('dijit.form.' != substr($dijit, 0, 10)) {
$dijit = 'dijit.form.' . $dijit;
}
}
$params = array();
$attribs = array();
$labels = $decInfo['labels'];
if (array_key_exists('params', $decInfo)) {
$params = $decInfo['params'];
}
if (array_key_exists('attribs', $decInfo)) {
$attribs = $decInfo['attribs'];
}
$containerParams = null;
if (array_key_exists('container', $params)) {
$containerParams = $params['container'];
unset($params['container']);
}
if (array_key_exists('labels', $params)) {
$labelsParams = $params['labels'];
unset($params['labels']);
} else {
$labelsParams = $params;
}
if (null === $containerParams) {
$containerParams = $params;
}
$containerAttribs = null;
if (array_key_exists('container', $attribs)) {
$containerAttribs = $attribs['container'];
unset($attribs['container']);
}
if (array_key_exists('labels', $attribs)) {
$labelsAttribs = $attribs['labels'];
unset($attribs['labels']);
} else {
$labelsAttribs = $attribs;
}
if (null === $containerAttribs) {
$containerAttribs = $attribs;
}
$containerParams['container'] = $position;
$labelsParams['container'] = $position;
$labelList = $this->_prepareLabelsList($id, $labelsParams, $labelsAttribs, $labels);
return $this->_createLayoutContainer($id, $labelList, $containerParams, $containerAttribs, $dijit);
}
/**
* Prepare slider label list
*
* @param string $id
* @param array $params
* @param array $attribs
* @param array $labels
* @return string
*/
protected function _prepareLabelsList($id, array $params, array $attribs, array $labels)
{
$attribs['id'] = $id . '-labels';
$dijit = 'dijit.form.' . ucfirst($this->_sliderType) . 'RuleLabels';
$attribs = $this->_prepareDijit($attribs, $params, 'layout', $dijit);
return $this->view->htmlList($labels, true, $attribs);
}
}

View File

@ -0,0 +1,66 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SplitContainer.php 10067 2008-07-12 21:05:32Z matthew $
*/
/** Zend_Dojo_View_Helper_DijitContainer */
require_once 'Zend/Dojo/View/Helper/DijitContainer.php';
/**
* Dojo SplitContainer dijit
*
* @uses Zend_Dojo_View_Helper_DijitContainer
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_SplitContainer extends Zend_Dojo_View_Helper_DijitContainer
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.layout.SplitContainer';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.layout.SplitContainer';
/**
* dijit.layout.SplitContainer
*
* @param string $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function splitContainer($id = null, $content = '', array $params = array(), array $attribs = array())
{
if (0 === func_num_args()) {
return $this;
}
return $this->_createLayoutContainer($id, $content, $params, $attribs);
}
}

View File

@ -0,0 +1,66 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: StackContainer.php 10067 2008-07-12 21:05:32Z matthew $
*/
/** Zend_Dojo_View_Helper_DijitContainer */
require_once 'Zend/Dojo/View/Helper/DijitContainer.php';
/**
* Dojo StackContainer dijit
*
* @uses Zend_Dojo_View_Helper_DijitContainer
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_StackContainer extends Zend_Dojo_View_Helper_DijitContainer
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.layout.StackContainer';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.layout.StackContainer';
/**
* dijit.layout.StackContainer
*
* @param string $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function stackContainer($id = null, $content = '', array $params = array(), array $attribs = array())
{
if (0 === func_num_args()) {
return $this;
}
return $this->_createLayoutContainer($id, $content, $params, $attribs);
}
}

View File

@ -0,0 +1,58 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SubmitButton.php 10621 2008-08-04 00:05:33Z matthew $
*/
/** Zend_Dojo_View_Helper_Button */
require_once 'Zend/Dojo/View/Helper/Button.php';
/**
* Dojo Button dijit tied to submit input
*
* @uses Zend_Dojo_View_Helper_Button
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_SubmitButton extends Zend_Dojo_View_Helper_Button
{
/**
* @var string Submit input
*/
protected $_elementType = 'submit';
/**
* dijit.form.Button tied to submit input
*
* @param string $id
* @param string $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function submitButton($id, $value = null, array $params = array(), array $attribs = array())
{
if (!array_key_exists('label', $params)) {
$params['label'] = $value;
}
return $this->_createFormElement($id, $value, $params, $attribs);
}
}

View File

@ -0,0 +1,66 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: TabContainer.php 10067 2008-07-12 21:05:32Z matthew $
*/
/** Zend_Dojo_View_Helper_DijitContainer */
require_once 'Zend/Dojo/View/Helper/DijitContainer.php';
/**
* Dojo TabContainer dijit
*
* @uses Zend_Dojo_View_Helper_DijitContainer
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_TabContainer extends Zend_Dojo_View_Helper_DijitContainer
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.layout.TabContainer';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.layout.TabContainer';
/**
* dijit.layout.TabContainer
*
* @param string $id
* @param string $content
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function tabContainer($id = null, $content = '', array $params = array(), array $attribs = array())
{
if (0 === func_num_args()) {
return $this;
}
return $this->_createLayoutContainer($id, $content, $params, $attribs);
}
}

View File

@ -0,0 +1,68 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: TextBox.php 9998 2008-07-08 19:54:41Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo TextBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_TextBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.TextBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.TextBox';
/**
* dijit.form.TextBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function textBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}

View File

@ -0,0 +1,80 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Textarea.php 10256 2008-07-21 14:09:27Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo Textarea dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_Textarea extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.Textarea';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.Textarea';
/**
* dijit.form.Textarea
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function textarea($id, $value = null, array $params = array(), array $attribs = array())
{
if (!array_key_exists('id', $attribs)) {
$attribs['id'] = $id;
}
$attribs['name'] = $id;
$attribs['type'] = $this->_elementType;
$attribs = $this->_prepareDijit($attribs, $params, 'textarea');
$html = '<textarea' . $this->_htmlAttribs($attribs) . '>'
. $value
. "</textarea>\n";
return $html;
}
}

View File

@ -0,0 +1,68 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: TimeTextBox.php 9998 2008-07-08 19:54:41Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo TimeTextBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_TimeTextBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.TimeTextBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.TimeTextBox';
/**
* dijit.form.TimeTextBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function timeTextBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}

View File

@ -0,0 +1,68 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ValidationTextBox.php 9998 2008-07-08 19:54:41Z matthew $
*/
/** Zend_Dojo_View_Helper_Dijit */
require_once 'Zend/Dojo/View/Helper/Dijit.php';
/**
* Dojo ValidationTextBox dijit
*
* @uses Zend_Dojo_View_Helper_Dijit
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_ValidationTextBox extends Zend_Dojo_View_Helper_Dijit
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.ValidationTextBox';
/**
* HTML element type
* @var string
*/
protected $_elementType = 'text';
/**
* Dojo module to use
* @var string
*/
protected $_module = 'dijit.form.ValidationTextBox';
/**
* dijit.form.ValidationTextBox
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function validationTextBox($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->_createFormElement($id, $value, $params, $attribs);
}
}

View File

@ -0,0 +1,62 @@
<?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_Dojo
* @subpackage View
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: VerticalSlider.php 9965 2008-07-06 14:46:20Z matthew $
*/
/** Zend_Dojo_View_Helper_Slider */
require_once 'Zend/Dojo/View/Helper/Slider.php';
/**
* Dojo VerticalSlider dijit
*
* @uses Zend_Dojo_View_Helper_Slider
* @package Zend_Dojo
* @subpackage View
* @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_Dojo_View_Helper_VerticalSlider extends Zend_Dojo_View_Helper_Slider
{
/**
* Dijit being used
* @var string
*/
protected $_dijit = 'dijit.form.VerticalSlider';
/**
* Slider type
* @var string
*/
protected $_sliderType = 'Vertical';
/**
* dijit.form.VerticalSlider
*
* @param int $id
* @param mixed $value
* @param array $params Parameters to use for dijit creation
* @param array $attribs HTML attributes
* @return string
*/
public function verticalSlider($id, $value = null, array $params = array(), array $attribs = array())
{
return $this->prepareSlider($id, $value, $params, $attribs);
}
}