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

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;
}
}