PDF rausgenommen

This commit is contained in:
aschwarz
2023-01-23 11:03:31 +01:00
parent 82d562a322
commit a6523903eb
28078 changed files with 4247552 additions and 2 deletions

View File

@ -0,0 +1,161 @@
<?php
/**
* Class for <button> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: Button.php 300722 2010-06-24 10:15:52Z mansion $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for simple HTML_QuickForm2 elements
*/
// require_once 'HTML/QuickForm2/Element.php';
/**
* Class for <button> elements
*
* Note that this element was named 'xbutton' in previous version of QuickForm,
* the name 'button' being used for current 'inputbutton' element.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_Button extends HTML_QuickForm2_Element
{
/**
* Contains options and data used for the element creation
* - content: Content to be displayed between <button></button> tags
* @var array
*/
protected $data = array('content' => '');
/**
* Element's submit value
* @var string
*/
protected $submitValue = null;
public function getType()
{
return 'button';
}
/**
* Buttons can not be frozen
*
* @param bool Whether element should be frozen or editable. This
* parameter is ignored in case of buttons
* @return bool Always returns false
*/
public function toggleFrozen($freeze = null)
{
return false;
}
/**
* Sets the contents of the button element
*
* @param string Button content (HTML to add between <button></button> tags)
* @return HTML_QuickForm2_Element_Button
*/
function setContent($content)
{
$this->data['content'] = $content;
return $this;
}
/**
* Button's value cannot be set via this method
*
* @param mixed Element's value, this parameter is ignored
* @return HTML_QuickForm2_Element_Button
*/
public function setValue($value)
{
return $this;
}
/**
* Returns the element's value
*
* The value is only returned if the following is true
* - button has 'type' attribute set to 'submit' (or no 'type' attribute)
* - the form was submitted by clicking on this button
*
* This method returns the actual value submitted by the browser. Note that
* different browsers submit different values!
*
* @return string|null
*/
public function getValue()
{
if ((empty($this->attributes['type']) || 'submit' == $this->attributes['type']) &&
!$this->getAttribute('disabled'))
{
return $this->applyFilters($this->submitValue);
} else {
return null;
}
}
public function __toString()
{
return $this->getIndent() . '<button' . $this->getAttributes(true) .
'>' . $this->data['content'] . '</button>';
}
public function updateValue()
{
foreach ($this->getDataSources() as $ds) {
if ($ds instanceof HTML_QuickForm2_DataSource_Submit &&
null !== ($value = $ds->getValue($this->getName())))
{
$this->submitValue = $value;
return;
}
}
$this->submitValue = null;
}
}
?>

View File

@ -0,0 +1,503 @@
<?php
/**
* Date element
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2009, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: Date.php 297453 2010-04-04 10:22:39Z mansion $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for HTML_QuickForm2 group of elements
*/
// require_once 'HTML/QuickForm2/Container/Group.php';
/**
* Base class for HTML_QuickForm2 select element
*/
// require_once 'HTML/QuickForm2/Element/Select.php';
/**
* Class for a group of elements used to input dates (and times).
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_Date extends HTML_QuickForm2_Container_Group
{
public function getType()
{
return 'date';
}
/**
* Various options to control the element's display.
* @var array
*/
protected $data = array(
'language' => 'en',
'format' => 'dMY',
'minYear' => 2001,
'maxYear' => 2010,
'addEmptyOption' => false,
'emptyOptionValue' => '',
'emptyOptionText' => '&nbsp;',
'optionIncrement' => array('i' => 1, 's' => 1)
);
/**
* Class constructor
*
* The following keys may appear in $data array:
* - 'language': date language
* - 'format': Format of the date, based on PHP's date() function.
* The following characters are currently recognised in format string:
* <pre>
* D => Short names of days
* l => Long names of days
* d => Day numbers
* M => Short names of months
* F => Long names of months
* m => Month numbers
* Y => Four digit year
* y => Two digit year
* h => 12 hour format
* H => 23 hour format
* i => Minutes
* s => Seconds
* a => am/pm
* A => AM/PM
* </pre>
* - 'minYear': Minimum year in year select
* - 'maxYear': Maximum year in year select
* - 'addEmptyOption': Should an empty option be added to the top of
* each select box?
* - 'emptyOptionValue': The value passed by the empty option.
* - 'emptyOptionText': The text displayed for the empty option.
* - 'optionIncrement': Step to increase the option values by (works for 'i' and 's')
*
* @param string Element name
* @param mixed Attributes (either a string or an array)
* @param array Element data (label, options and data used for element creation)
*/
public function __construct($name = null, $attributes = null, $data = null)
{
parent::__construct($name, $attributes, $data);
$locale =& $this->locale[$this->data['language']];
$backslash = false;
$separators = array();
$separator = '';
for ($i = 0, $length = strlen($this->data['format']); $i < $length; $i++) {
$sign = $this->data['format']{$i};
if ($backslash) {
$backslash = false;
$separator .= $sign;
} else {
$loadSelect = true;
switch ($sign) {
case 'D':
// Sunday is 0 like with 'w' in date()
$options = $locale['weekdays_short'];
break;
case 'l':
$options = $locale['weekdays_long'];
break;
case 'd':
$options = $this->createOptionList(1, 31);
break;
case 'M':
$options = $locale['months_short'];
array_unshift($options , '');
unset($options[0]);
break;
case 'm':
$options = $this->createOptionList(1, 12);
break;
case 'F':
$options = $locale['months_long'];
array_unshift($options , '');
unset($options[0]);
break;
case 'Y':
$options = $this->createOptionList(
$this->data['minYear'],
$this->data['maxYear'],
$this->data['minYear'] > $this->data['maxYear']? -1: 1
);
break;
case 'y':
$options = $this->createOptionList(
$this->data['minYear'],
$this->data['maxYear'],
$this->data['minYear'] > $this->data['maxYear']? -1: 1
);
array_walk($options, create_function('&$v,$k','$v = substr($v,-2);'));
break;
case 'h':
$options = $this->createOptionList(1, 12);
break;
case 'g':
$options = $this->createOptionList(1, 12);
array_walk($options, create_function('&$v,$k', '$v = intval($v);'));
break;
case 'H':
$options = $this->createOptionList(0, 23);
break;
case 'i':
$options = $this->createOptionList(0, 59, $this->data['optionIncrement']['i']);
break;
case 's':
$options = $this->createOptionList(0, 59, $this->data['optionIncrement']['s']);
break;
case 'a':
$options = array('am' => 'am', 'pm' => 'pm');
break;
case 'A':
$options = array('AM' => 'AM', 'PM' => 'PM');
break;
case 'W':
$options = $this->createOptionList(1, 53);
break;
case '\\':
$backslash = true;
$loadSelect = false;
break;
default:
$separator .= (' ' == $sign? '&nbsp;': $sign);
$loadSelect = false;
}
if ($loadSelect) {
if (0 < count($this)) {
$separators[] = $separator;
}
$separator = '';
// Should we add an empty option to the top of the select?
if (!is_array($this->data['addEmptyOption']) && $this->data['addEmptyOption'] ||
is_array($this->data['addEmptyOption']) && !empty($this->data['addEmptyOption'][$sign])) {
// Using '+' array operator to preserve the keys
if (is_array($this->data['emptyOptionText']) && !empty($this->data['emptyOptionText'][$sign])) {
$options = array($this->data['emptyOptionValue'] => $this->data['emptyOptionText'][$sign]) + $options;
} else {
$options = array($this->data['emptyOptionValue'] => $this->data['emptyOptionText']) + $options;
}
}
$this->addSelect($sign, $this->getAttributes())->loadOptions($options);
}
}
}
$separators[] = $separator . ($backslash? '\\': '');
$this->setSeparator($separators);
}
/**
* Creates an option list containing the numbers from the start number to the end, inclusive
*
* @param int The start number
* @param int The end number
* @param int Increment by this value
* @return array An array of numeric options.
*/
protected function createOptionList($start, $end, $step = 1)
{
for ($i = $start, $options = array(); $start > $end? $i >= $end: $i <= $end; $i += $step) {
$options[$i] = sprintf('%02d', $i);
}
return $options;
}
/**
* Trims leading zeros from the (numeric) string
*
* @param string A numeric string, possibly with leading zeros
* @return string String with leading zeros removed
*/
protected function trimLeadingZeros($str)
{
if (0 == strcmp($str, $this->data['emptyOptionValue'])) {
return $str;
}
$trimmed = ltrim($str, '0');
return strlen($trimmed)? $trimmed: '0';
}
/**
* Tries to convert the given value to a usable date before setting the
* element value
* @param int|string|array A timestamp, a string compatible with strtotime()
* or an array that fits the element names
*/
public function setValue($value)
{
if (empty($value)) {
$value = array();
} elseif (is_scalar($value)) {
if (!is_numeric($value)) {
$value = strtotime($value);
}
// might be a unix epoch, then we fill all possible values
$arr = explode('-', date('w-j-n-Y-g-G-i-s-a-A-W', (int)$value));
$value = array(
'D' => $arr[0],
'l' => $arr[0],
'd' => $arr[1],
'M' => $arr[2],
'm' => $arr[2],
'F' => $arr[2],
'Y' => $arr[3],
'y' => $arr[3],
'h' => $arr[4],
'g' => $arr[4],
'H' => $arr[5],
'i' => $this->trimLeadingZeros($arr[6]),
's' => $this->trimLeadingZeros($arr[7]),
'a' => $arr[8],
'A' => $arr[9],
'W' => $this->trimLeadingZeros($arr[10])
);
} else {
$value = array_map(array($this, 'trimLeadingZeros'), $value);
}
return parent::setValue($value);
}
/**
* Called when the element needs to update its value from form's data sources
*
* Since the date element also accepts a timestamp as value, the default
* group behavior is changed.
*/
public function updateValue()
{
$name = $this->getName();
foreach ($this->getDataSources() as $ds) {
if (null !== ($value = $ds->getValue($name))) {
$this->setValue($value);
return;
}
}
parent::updateValue();
}
/**
* Options in different languages
*
* Note to potential translators: to avoid encoding problems please send
* your translations with "weird" letters encoded as HTML Unicode entities
*
* @var array
*/
protected $locale = array(
'en' => array (
'weekdays_short'=> array ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'),
'weekdays_long' => array ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'),
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
'months_long' => array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
),
'de' => array (
'weekdays_short'=> array ('So', 'Mon', 'Di', 'Mi', 'Do', 'Fr', 'Sa'),
'weekdays_long' => array ('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'),
'months_short' => array ('Jan', 'Feb', 'M&#xe4;rz', 'April', 'Mai', 'Juni', 'Juli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dez'),
'months_long' => array ('Januar', 'Februar', 'M&#xe4;rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember')
),
'fr' => array (
'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'),
'weekdays_long' => array ('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'),
'months_short' => array ('Jan', 'F&#xe9;v', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Ao&#xfb;t', 'Sep', 'Oct', 'Nov', 'D&#xe9;c'),
'months_long' => array ('Janvier', 'F&#xe9;vrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Ao&#xfb;t', 'Septembre', 'Octobre', 'Novembre', 'D&#xe9;cembre')
),
'hu' => array (
'weekdays_short'=> array ('V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'),
'weekdays_long' => array ('vas&#xe1;rnap', 'h&#xe9;tf&#x151;', 'kedd', 'szerda', 'cs&#xfc;t&#xf6;rt&#xf6;k', 'p&#xe9;ntek', 'szombat'),
'months_short' => array ('jan', 'feb', 'm&#xe1;rc', '&#xe1;pr', 'm&#xe1;j', 'j&#xfa;n', 'j&#xfa;l', 'aug', 'szept', 'okt', 'nov', 'dec'),
'months_long' => array ('janu&#xe1;r', 'febru&#xe1;r', 'm&#xe1;rcius', '&#xe1;prilis', 'm&#xe1;jus', 'j&#xfa;nius', 'j&#xfa;lius', 'augusztus', 'szeptember', 'okt&#xf3;ber', 'november', 'december')
),
'pl' => array (
'weekdays_short'=> array ('Nie', 'Pn', 'Wt', '&#x15a;r', 'Czw', 'Pt', 'Sob'),
'weekdays_long' => array ('Niedziela', 'Poniedzia&#x142;ek', 'Wtorek', '&#x15a;roda', 'Czwartek', 'Pi&#x105;tek', 'Sobota'),
'months_short' => array ('Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Pa&#x17a;', 'Lis', 'Gru'),
'months_long' => array ('Stycze&#x144;', 'Luty', 'Marzec', 'Kwiecie&#x144;', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpie&#x144;', 'Wrzesie&#x144;', 'Pa&#x17a;dziernik', 'Listopad', 'Grudzie&#x144;')
),
'sl' => array (
'weekdays_short'=> array ('Ned', 'Pon', 'Tor', 'Sre', 'Cet', 'Pet', 'Sob'),
'weekdays_long' => array ('Nedelja', 'Ponedeljek', 'Torek', 'Sreda', 'Cetrtek', 'Petek', 'Sobota'),
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Avg', 'Sep', 'Okt', 'Nov', 'Dec'),
'months_long' => array ('Januar', 'Februar', 'Marec', 'April', 'Maj', 'Junij', 'Julij', 'Avgust', 'September', 'Oktober', 'November', 'December')
),
'ru' => array (
'weekdays_short'=> array ('&#x412;&#x441;', '&#x41f;&#x43d;', '&#x412;&#x442;', '&#x421;&#x440;', '&#x427;&#x442;', '&#x41f;&#x442;', '&#x421;&#x431;'),
'weekdays_long' => array ('&#x412;&#x43e;&#x441;&#x43a;&#x440;&#x435;&#x441;&#x435;&#x43d;&#x44c;&#x435;', '&#x41f;&#x43e;&#x43d;&#x435;&#x434;&#x435;&#x43b;&#x44c;&#x43d;&#x438;&#x43a;', '&#x412;&#x442;&#x43e;&#x440;&#x43d;&#x438;&#x43a;', '&#x421;&#x440;&#x435;&#x434;&#x430;', '&#x427;&#x435;&#x442;&#x432;&#x435;&#x440;&#x433;', '&#x41f;&#x44f;&#x442;&#x43d;&#x438;&#x446;&#x430;', '&#x421;&#x443;&#x431;&#x431;&#x43e;&#x442;&#x430;'),
'months_short' => array ('&#x42f;&#x43d;&#x432;', '&#x424;&#x435;&#x432;', '&#x41c;&#x430;&#x440;', '&#x410;&#x43f;&#x440;', '&#x41c;&#x430;&#x439;', '&#x418;&#x44e;&#x43d;', '&#x418;&#x44e;&#x43b;', '&#x410;&#x432;&#x433;', '&#x421;&#x435;&#x43d;', '&#x41e;&#x43a;&#x442;', '&#x41d;&#x43e;&#x44f;', '&#x414;&#x435;&#x43a;'),
'months_long' => array ('&#x42f;&#x43d;&#x432;&#x430;&#x440;&#x44c;', '&#x424;&#x435;&#x432;&#x440;&#x430;&#x43b;&#x44c;', '&#x41c;&#x430;&#x440;&#x442;', '&#x410;&#x43f;&#x440;&#x435;&#x43b;&#x44c;', '&#x41c;&#x430;&#x439;', '&#x418;&#x44e;&#x43d;&#x44c;', '&#x418;&#x44e;&#x43b;&#x44c;', '&#x410;&#x432;&#x433;&#x443;&#x441;&#x442;', '&#x421;&#x435;&#x43d;&#x442;&#x44f;&#x431;&#x440;&#x44c;', '&#x41e;&#x43a;&#x442;&#x44f;&#x431;&#x440;&#x44c;', '&#x41d;&#x43e;&#x44f;&#x431;&#x440;&#x44c;', '&#x414;&#x435;&#x43a;&#x430;&#x431;&#x440;&#x44c;')
),
'es' => array (
'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mi&#xe9;', 'Jue', 'Vie', 'S&#xe1;b'),
'weekdays_long' => array ('Domingo', 'Lunes', 'Martes', 'Mi&#xe9;rcoles', 'Jueves', 'Viernes', 'S&#xe1;bado'),
'months_short' => array ('Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'),
'months_long' => array ('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')
),
'da' => array (
'weekdays_short'=> array ('S&#xf8;n', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'L&#xf8;r'),
'weekdays_long' => array ('S&#xf8;ndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&#xf8;rdag'),
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
'months_long' => array ('Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December')
),
'is' => array (
'weekdays_short'=> array ('Sun', 'M&#xe1;n', '&#xde;ri', 'Mi&#xf0;', 'Fim', 'F&#xf6;s', 'Lau'),
'weekdays_long' => array ('Sunnudagur', 'M&#xe1;nudagur', '&#xde;ri&#xf0;judagur', 'Mi&#xf0;vikudagur', 'Fimmtudagur', 'F&#xf6;studagur', 'Laugardagur'),
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Ma&#xed;', 'J&#xfa;n', 'J&#xfa;l', '&#xc1;g&#xfa;', 'Sep', 'Okt', 'N&#xf3;v', 'Des'),
'months_long' => array ('Jan&#xfa;ar', 'Febr&#xfa;ar', 'Mars', 'Apr&#xed;l', 'Ma&#xed;', 'J&#xfa;n&#xed;', 'J&#xfa;l&#xed;', '&#xc1;g&#xfa;st', 'September', 'Okt&#xf3;ber', 'N&#xf3;vember', 'Desember')
),
'it' => array (
'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'),
'weekdays_long' => array ('Domenica', 'Luned&#xec;', 'Marted&#xec;', 'Mercoled&#xec;', 'Gioved&#xec;', 'Venerd&#xec;', 'Sabato'),
'months_short' => array ('Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'),
'months_long' => array ('Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre')
),
'sk' => array (
'weekdays_short'=> array ('Ned', 'Pon', 'Uto', 'Str', '&#x8a;tv', 'Pia', 'Sob'),
'weekdays_long' => array ('Nede&#x17e;a', 'Pondelok', 'Utorok', 'Streda', '&#x8a;tvrtok', 'Piatok', 'Sobota'),
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'M&#xe1;j', 'J&#xfa;n', 'J&#xfa;l', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
'months_long' => array ('Janu&#xe1;r', 'Febru&#xe1;r', 'Marec', 'Apr&#xed;l', 'M&#xe1;j', 'J&#xfa;n', 'J&#xfa;l', 'August', 'September', 'Okt&#xf3;ber', 'November', 'December')
),
'cs' => array (
'weekdays_short'=> array ('Ne', 'Po', '&#xda;t', 'St', '&#x10c;t', 'P&#xe1;', 'So'),
'weekdays_long' => array ('Ned&#x11b;le', 'Pond&#x11b;l&#xed;', '&#xda;ter&#xfd;', 'St&#x159;eda', '&#x10c;tvrtek', 'P&#xe1;tek', 'Sobota'),
'months_short' => array ('Led', '&#xda;no', 'B&#x159;e', 'Dub', 'Kv&#x11b;', '&#x10c;en', '&#x10c;ec', 'Srp', 'Z&#xe1;&#x159;', '&#x158;&#xed;j', 'Lis', 'Pro'),
'months_long' => array ('Leden', '&#xda;nor', 'B&#x159;ezen', 'Duben', 'Kv&#x11b;ten', '&#x10c;erven', '&#x10c;ervenec', 'Srpen', 'Z&#xe1;&#x159;&#xed;', '&#x158;&#xed;jen', 'Listopad', 'Prosinec')
),
'hy' => array (
'weekdays_short'=> array ('&#x53f;&#x580;&#x56f;', '&#x535;&#x580;&#x56f;', '&#x535;&#x580;&#x584;', '&#x549;&#x580;&#x584;', '&#x540;&#x576;&#x563;', '&#x548;&#x582;&#x580;', '&#x547;&#x562;&#x569;'),
'weekdays_long' => array ('&#x53f;&#x56b;&#x580;&#x561;&#x56f;&#x56b;', '&#x535;&#x580;&#x56f;&#x578;&#x582;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x535;&#x580;&#x565;&#x584;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x549;&#x578;&#x580;&#x565;&#x584;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x540;&#x56b;&#x576;&#x563;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x548;&#x582;&#x580;&#x562;&#x561;&#x569;', '&#x547;&#x561;&#x562;&#x561;&#x569;'),
'months_short' => array ('&#x540;&#x576;&#x57e;', '&#x553;&#x57f;&#x580;', '&#x544;&#x580;&#x57f;', '&#x531;&#x57a;&#x580;', '&#x544;&#x575;&#x57d;', '&#x540;&#x576;&#x57d;', '&#x540;&#x56c;&#x57d;', '&#x555;&#x563;&#x57d;', '&#x54d;&#x57a;&#x57f;', '&#x540;&#x56f;&#x57f;', '&#x546;&#x575;&#x574;', '&#x534;&#x56f;&#x57f;'),
'months_long' => array ('&#x540;&#x578;&#x582;&#x576;&#x57e;&#x561;&#x580;', '&#x553;&#x565;&#x57f;&#x580;&#x57e;&#x561;&#x580;', '&#x544;&#x561;&#x580;&#x57f;', '&#x531;&#x57a;&#x580;&#x56b;&#x56c;', '&#x544;&#x561;&#x575;&#x56b;&#x57d;', '&#x540;&#x578;&#x582;&#x576;&#x56b;&#x57d;', '&#x540;&#x578;&#x582;&#x56c;&#x56b;&#x57d;', '&#x555;&#x563;&#x578;&#x57d;&#x57f;&#x578;&#x57d;', '&#x54d;&#x565;&#x57a;&#x57f;&#x565;&#x574;&#x562;&#x565;&#x580;', '&#x540;&#x578;&#x56f;&#x57f;&#x565;&#x574;&#x562;&#x565;&#x580;', '&#x546;&#x578;&#x575;&#x565;&#x574;&#x562;&#x565;&#x580;', '&#x534;&#x565;&#x56f;&#x57f;&#x565;&#x574;&#x562;&#x565;&#x580;')
),
'nl' => array (
'weekdays_short'=> array ('Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'),
'weekdays_long' => array ('Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'),
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
'months_long' => array ('Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December')
),
'et' => array (
'weekdays_short'=> array ('P', 'E', 'T', 'K', 'N', 'R', 'L'),
'weekdays_long' => array ('P&#xfc;hap&#xe4;ev', 'Esmasp&#xe4;ev', 'Teisip&#xe4;ev', 'Kolmap&#xe4;ev', 'Neljap&#xe4;ev', 'Reede', 'Laup&#xe4;ev'),
'months_short' => array ('Jaan', 'Veebr', 'M&#xe4;rts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dets'),
'months_long' => array ('Jaanuar', 'Veebruar', 'M&#xe4;rts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'August', 'September', 'Oktoober', 'November', 'Detsember')
),
'tr' => array (
'weekdays_short'=> array ('Paz', 'Pzt', 'Sal', '&#xc7;ar', 'Per', 'Cum', 'Cts'),
'weekdays_long' => array ('Pazar', 'Pazartesi', 'Sal&#x131;', '&#xc7;ar&#x15f;amba', 'Per&#x15f;embe', 'Cuma', 'Cumartesi'),
'months_short' => array ('Ock', '&#x15e;bt', 'Mrt', 'Nsn', 'Mys', 'Hzrn', 'Tmmz', 'A&#x11f;st', 'Eyl', 'Ekm', 'Ksm', 'Arlk'),
'months_long' => array ('Ocak', '&#x15e;ubat', 'Mart', 'Nisan', 'May&#x131;s', 'Haziran', 'Temmuz', 'A&#x11f;ustos', 'Eyl&#xfc;l', 'Ekim', 'Kas&#x131;m', 'Aral&#x131;k')
),
'no' => array (
'weekdays_short'=> array ('S&#xf8;n', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'L&#xf8;r'),
'weekdays_long' => array ('S&#xf8;ndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&#xf8;rdag'),
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des'),
'months_long' => array ('Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember')
),
'eo' => array (
'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', '&#x134;a&#x16D;', 'Ven', 'Sab'),
'weekdays_long' => array ('Diman&#x109;o', 'Lundo', 'Mardo', 'Merkredo', '&#x134;a&#x16D;do', 'Vendredo', 'Sabato'),
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'A&#x16D;g', 'Sep', 'Okt', 'Nov', 'Dec'),
'months_long' => array ('Januaro', 'Februaro', 'Marto', 'Aprilo', 'Majo', 'Junio', 'Julio', 'A&#x16D;gusto', 'Septembro', 'Oktobro', 'Novembro', 'Decembro')
),
'ua' => array (
'weekdays_short'=> array ('&#x41d;&#x434;&#x43b;', '&#x41f;&#x43d;&#x434;', '&#x412;&#x442;&#x440;', '&#x421;&#x440;&#x434;', '&#x427;&#x442;&#x432;', '&#x41f;&#x442;&#x43d;', '&#x421;&#x431;&#x442;'),
'weekdays_long' => array ('&#x41d;&#x435;&#x434;&#x456;&#x43b;&#x44f;', '&#x41f;&#x43e;&#x43d;&#x435;&#x434;&#x456;&#x43b;&#x43e;&#x43a;', '&#x412;&#x456;&#x432;&#x442;&#x43e;&#x440;&#x43e;&#x43a;', '&#x421;&#x435;&#x440;&#x435;&#x434;&#x430;', '&#x427;&#x435;&#x442;&#x432;&#x435;&#x440;', '&#x41f;\'&#x44f;&#x442;&#x43d;&#x438;&#x446;&#x44f;', '&#x421;&#x443;&#x431;&#x43e;&#x442;&#x430;'),
'months_short' => array ('&#x421;&#x456;&#x447;', '&#x41b;&#x44e;&#x442;', '&#x411;&#x435;&#x440;', '&#x41a;&#x432;&#x456;', '&#x422;&#x440;&#x430;', '&#x427;&#x435;&#x440;', '&#x41b;&#x438;&#x43f;', '&#x421;&#x435;&#x440;', '&#x412;&#x435;&#x440;', '&#x416;&#x43e;&#x432;', '&#x41b;&#x438;&#x441;', '&#x413;&#x440;&#x443;'),
'months_long' => array ('&#x421;&#x456;&#x447;&#x435;&#x43d;&#x44c;', '&#x41b;&#x44e;&#x442;&#x438;&#x439;', '&#x411;&#x435;&#x440;&#x435;&#x437;&#x435;&#x43d;&#x44c;', '&#x41a;&#x432;&#x456;&#x442;&#x435;&#x43d;&#x44c;', '&#x422;&#x440;&#x430;&#x432;&#x435;&#x43d;&#x44c;', '&#x427;&#x435;&#x440;&#x432;&#x435;&#x43d;&#x44c;', '&#x41b;&#x438;&#x43f;&#x435;&#x43d;&#x44c;', '&#x421;&#x435;&#x440;&#x43f;&#x435;&#x43d;&#x44c;', '&#x412;&#x435;&#x440;&#x435;&#x441;&#x435;&#x43d;&#x44c;', '&#x416;&#x43e;&#x432;&#x442;&#x435;&#x43d;&#x44c;', '&#x41b;&#x438;&#x441;&#x442;&#x43e;&#x43f;&#x430;&#x434;', '&#x413;&#x440;&#x443;&#x434;&#x435;&#x43d;&#x44c;')
),
'ro' => array (
'weekdays_short'=> array ('Dum', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sam'),
'weekdays_long' => array ('Duminica', 'Luni', 'Marti', 'Miercuri', 'Joi', 'Vineri', 'Sambata'),
'months_short' => array ('Ian', 'Feb', 'Mar', 'Apr', 'Mai', 'Iun', 'Iul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
'months_long' => array ('Ianuarie', 'Februarie', 'Martie', 'Aprilie', 'Mai', 'Iunie', 'Iulie', 'August', 'Septembrie', 'Octombrie', 'Noiembrie', 'Decembrie')
),
'he' => array (
'weekdays_short'=> array ('&#1512;&#1488;&#1513;&#1493;&#1503;', '&#1513;&#1504;&#1497;', '&#1513;&#1500;&#1497;&#1513;&#1497;', '&#1512;&#1489;&#1497;&#1506;&#1497;', '&#1495;&#1502;&#1497;&#1513;&#1497;', '&#1513;&#1497;&#1513;&#1497;', '&#1513;&#1489;&#1514;'),
'weekdays_long' => array ('&#1497;&#1493;&#1501; &#1512;&#1488;&#1513;&#1493;&#1503;', '&#1497;&#1493;&#1501; &#1513;&#1504;&#1497;', '&#1497;&#1493;&#1501; &#1513;&#1500;&#1497;&#1513;&#1497;', '&#1497;&#1493;&#1501; &#1512;&#1489;&#1497;&#1506;&#1497;', '&#1497;&#1493;&#1501; &#1495;&#1502;&#1497;&#1513;&#1497;', '&#1497;&#1493;&#1501; &#1513;&#1497;&#1513;&#1497;', '&#1513;&#1489;&#1514;'),
'months_short' => array ('&#1497;&#1504;&#1493;&#1488;&#1512;', '&#1508;&#1489;&#1512;&#1493;&#1488;&#1512;', '&#1502;&#1512;&#1509;', '&#1488;&#1508;&#1512;&#1497;&#1500;', '&#1502;&#1488;&#1497;', '&#1497;&#1493;&#1504;&#1497;', '&#1497;&#1493;&#1500;&#1497;', '&#1488;&#1493;&#1490;&#1493;&#1505;&#1496;', '&#1505;&#1508;&#1496;&#1502;&#1489;&#1512;', '&#1488;&#1493;&#1511;&#1496;&#1493;&#1489;&#1512;', '&#1504;&#1493;&#1489;&#1502;&#1489;&#1512;', '&#1491;&#1510;&#1502;&#1489;&#1512;'),
'months_long' => array ('&#1497;&#1504;&#1493;&#1488;&#1512;', '&#1508;&#1489;&#1512;&#1493;&#1488;&#1512;', '&#1502;&#1512;&#1509;', '&#1488;&#1508;&#1512;&#1497;&#1500;', '&#1502;&#1488;&#1497;', '&#1497;&#1493;&#1504;&#1497;', '&#1497;&#1493;&#1500;&#1497;', '&#1488;&#1493;&#1490;&#1493;&#1505;&#1496;', '&#1505;&#1508;&#1496;&#1502;&#1489;&#1512;', '&#1488;&#1493;&#1511;&#1496;&#1493;&#1489;&#1512;', '&#1504;&#1493;&#1489;&#1502;&#1489;&#1512;', '&#1491;&#1510;&#1502;&#1489;&#1512;')
),
'sv' => array (
'weekdays_short'=> array ('S&#xf6;n', 'M&#xe5;n', 'Tis', 'Ons', 'Tor', 'Fre', 'L&#xf6;r'),
'weekdays_long' => array ('S&#xf6;ndag', 'M&#xe5;ndag', 'Tisdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&#xf6;rdag'),
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
'months_long' => array ('Januari', 'Februari', 'Mars', 'April', 'Maj', 'Juni', 'Juli', 'Augusti', 'September', 'Oktober', 'November', 'December')
),
'pt' => array (
'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'S&aacute;b'),
'weekdays_long' => array ('Domingo', 'Segunda-feira', 'Ter&ccedil;a-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'S&aacute;bado'),
'months_short' => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'),
'months_long' => array ('Janeiro', 'Fevereiro', 'Mar&ccedil;o', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro')
),
'tw' => array (
'weekdays_short'=> array ('&#36913;&#26085;','&#36913;&#19968;', '&#36913;&#20108;','&#36913;&#19977;', '&#36913;&#22235;','&#36913;&#20116;', '&#36913;&#20845;'),
'weekdays_long' => array ('&#26143;&#26399;&#26085;', '&#26143;&#26399;&#19968;', '&#26143;&#26399;&#20108;', '&#26143;&#26399;&#19977;', '&#26143;&#26399;&#22235;', '&#26143;&#26399;&#20116;', '&#26143;&#26399;&#20845;'),
'months_short' => array ('&#19968;&#26376;', '&#20108;&#26376;', '&#19977;&#26376;', '&#22235;&#26376;', '&#20116;&#26376;', '&#20845;&#26376;', '&#19971;&#26376;', '&#20843;&#26376;', '&#20061;&#26376;', '&#21313;&#26376;', '&#21313;&#19968;&#26376;', '&#21313;&#20108;&#26376;'),
'months_long' => array ('&#19968;&#26376;', '&#20108;&#26376;', '&#19977;&#26376;', '&#22235;&#26376;', '&#20116;&#26376;', '&#20845;&#26376;', '&#19971;&#26376;', '&#20843;&#26376;', '&#20061;&#26376;', '&#21313;&#26376;', '&#21313;&#19968;&#26376;', '&#21313;&#20108;&#26376;')
),
'pt-br' => array (
'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'S&aacute;b'),
'weekdays_long' => array ('Domingo', 'Segunda', 'Ter&ccedil;a', 'Quarta', 'Quinta', 'Sexta', 'S&aacute;bado'),
'months_short' => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'),
'months_long' => array ('Janeiro', 'Fevereiro', 'Mar&ccedil;o', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro')
),
'sr' => array (
'weekdays_short'=> array ('&#1053;&#1077;&#1076;', '&#1055;&#1086;&#1085;', '&#1059;&#1090;&#1086;', '&#1057;&#1088;&#1077;', '&#1063;&#1077;&#1090;', '&#1055;&#1077;&#1090;', '&#1057;&#1091;&#1073;'),
'weekdays_long' => array ('&#1053;&#1077;&#1076;&#1077;&#1113;&#1072;', '&#1055;&#1086;&#1085;&#1077;&#1076;&#1077;&#1113;&#1072;&#1082;', '&#1059;&#1090;&#1086;&#1088;&#1072;&#1082;', '&#1057;&#1088;&#1077;&#1076;&#1072;', '&#1063;&#1077;&#1090;&#1074;&#1088;&#1090;&#1072;&#1082;', '&#1055;&#1077;&#1090;&#1072;&#1082;', '&#1057;&#1091;&#1073;&#1086;&#1090;&#1072;'),
'months_short' => array ('&#1032;&#1072;&#1085;', '&#1060;&#1077;&#1073;', '&#1052;&#1072;&#1088;', '&#1040;&#1087;&#1088;', '&#1052;&#1072;&#1112;', '&#1032;&#1091;&#1085;', '&#1032;&#1091;&#1083;', '&#1040;&#1074;&#1075;', '&#1057;&#1077;&#1087;', '&#1054;&#1082;&#1090;', '&#1053;&#1086;&#1074;', '&#1044;&#1077;&#1094;'),
'months_long' => array ('&#1032;&#1072;&#1085;&#1091;&#1072;&#1088;', '&#1060;&#1077;&#1073;&#1088;&#1091;&#1072;&#1088;', '&#1052;&#1072;&#1088;&#1090;', '&#1040;&#1087;&#1088;&#1080;&#1083;', '&#1052;&#1072;&#1112;', '&#1032;&#1091;&#1085;', '&#1032;&#1091;&#1083;', '&#1040;&#1074;&#1075;&#1091;&#1089;&#1090;', '&#1057;&#1077;&#1087;&#1090;&#1077;&#1084;&#1073;&#1072;&#1088;', '&#1054;&#1082;&#1090;&#1086;&#1073;&#1072;&#1088;', '&#1053;&#1086;&#1074;&#1077;&#1084;&#1073;&#1072;&#1088;', '&#1044;&#1077;&#1094;&#1077;&#1084;&#1073;&#1072;&#1088;')
),
'el' => array (
'weekdays_short'=> array ('&#916;&#949;&#965;', '&#932;&#961;&#943;', '&#932;&#949;&#964;', '&#928;&#941;&#956;', '&#928;&#945;&#961;', '&#931;&#940;&#946;', '&#922;&#965;&#961;'),
'weekdays_long' => array ('&#916;&#949;&#965;&#964;&#941;&#961;&#945;', '&#932;&#961;&#943;&#964;&#951;', '&#932;&#949;&#964;&#940;&#961;&#964;&#951;', '&#928;&#941;&#956;&#960;&#964;&#951;', '&#928;&#945;&#961;&#945;&#963;&#954;&#949;&#965;&#942;', '&#931;&#940;&#946;&#946;&#945;&#964;&#959;', '&#922;&#965;&#961;&#953;&#945;&#954;&#942;'),
'months_short' => array ('&#921;&#945;&#957;', '&#934;&#949;&#946;', '&#924;&#940;&#961;', '&#913;&#960;&#961;', '&#924;&#940;&#970;', 'Io&#973;&#957;', '&#921;&#959;&#973;&#955;', '&#913;&#973;&#947;', '&#931;&#949;&#960;', '&#927;&#954;&#964;', '&#925;&#959;&#941;', '&#916;&#949;&#954;'),
'months_long' => array ('&#921;&#945;&#957;&#959;&#965;&#940;&#961;&#953;&#959;&#962;', '&#934;&#949;&#946;&#961;&#959;&#965;&#940;&#961;&#953;&#959;&#962;', '&#924;&#940;&#961;&#964;&#953;&#959;&#962;', '&#913;&#960;&#961;&#943;&#955;&#953;&#959;&#962;', '&#924;&#940;&#970;&#959;&#962;', '&#921;&#959;&#973;&#957;&#953;&#959;&#962;', 'Io&#973;&#955;&#953;&#959;&#962;', '&#913;&#973;&#947;&#959;&#965;&#963;&#964;&#959;&#962;', '&#931;&#949;&#960;&#964;&#941;&#956;&#946;&#961;&#953;&#959;&#962;', '&#927;&#954;&#964;&#974;&#946;&#961;&#953;&#959;&#962;', '&#925;&#959;&#941;&#956;&#946;&#961;&#953;&#959;&#962;', '&#916;&#949;&#954;&#941;&#956;&#946;&#961;&#953;&#959;&#962;')
)
);
}
?>

View File

@ -0,0 +1,114 @@
<?php
/**
* Base class for <input> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: Input.php 300722 2010-06-24 10:15:52Z mansion $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for simple HTML_QuickForm2 elements (not Containers)
*/
// require_once 'HTML/QuickForm2/Element.php';
/**
* Base class for <input> elements
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_Input extends HTML_QuickForm2_Element
{
/**
* 'type' attribute should not be changeable
* @var array
*/
protected $watchedAttributes = array('id', 'name', 'type');
protected function onAttributeChange($name, $value = null)
{
if ('type' == $name) {
throw new HTML_QuickForm2_InvalidArgumentException(
"Attribute 'type' is read-only"
);
}
parent::onAttributeChange($name, $value);
}
public function getType()
{
return $this->attributes['type'];
}
public function setValue($value)
{
$this->setAttribute('value', $value);
return $this;
}
public function getValue()
{
return $this->getAttribute('disabled')? null: $this->applyFilters($this->getAttribute('value'));
}
public function __toString()
{
if ($this->frozen) {
return $this->getFrozenHtml();
} else {
return '<input' . $this->getAttributes(true) . ' />';
}
}
/**
* Returns the field's value without HTML tags
* @return string
*/
protected function getFrozenHtml()
{
$value = $this->getAttribute('value');
return (('' != $value)? htmlspecialchars($value, ENT_QUOTES, self::getOption('charset')): '&nbsp;') .
$this->getPersistentContent();
}
}
?>

View File

@ -0,0 +1,99 @@
<?php
/**
* Class for <input type="button" /> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: InputButton.php 294057 2010-01-26 21:10:28Z avb $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for <input> elements
*/
// require_once 'HTML/QuickForm2/Element/Input.php';
/**
* Class for <input type="button" /> elements
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_InputButton extends HTML_QuickForm2_Element_Input
{
protected $attributes = array('type' => 'button');
/**
* Buttons can not be frozen
*
* @param bool Whether element should be frozen or editable. This
* parameter is ignored in case of buttons
* @return bool Always returns false
*/
public function toggleFrozen($freeze = null)
{
return false;
}
/**
* Button elements cannot have any submit values
*
* @param mixed Element's value, this parameter is ignored
* @return HTML_QuickForm2_Element_InputButton
*/
public function setValue($value)
{
return $this;
}
/**
* Button elements cannot have any submit values
*
* This method always returns null
*
* return string|null
*/
public function getValue()
{
return null;
}
}
?>

View File

@ -0,0 +1,172 @@
<?php
/**
* Base class for checkboxes and radios
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: InputCheckable.php 300722 2010-06-24 10:15:52Z mansion $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for <input> elements
*/
// require_once 'HTML/QuickForm2/Element/Input.php';
/**
* Base class for <input> elements having 'checked' attribute (checkboxes and radios)
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_InputCheckable extends HTML_QuickForm2_Element_Input
{
protected $persistent = true;
/**
* HTML to represent the element in "frozen" state
*
* Array index "checked" contains HTML for element's "checked" state,
* "unchecked" for not checked
* @var array
*/
protected $frozenHtml = array(
'checked' => 'On',
'unchecked' => 'Off'
);
/**
* Contains options and data used for the element creation
* - content: Label "glued" to a checkbox or radio
* @var array
*/
protected $data = array('content' => '');
public function __construct($name = null, $attributes = null, $data = null)
{
parent::__construct($name, $attributes, $data);
// "checked" attribute should be updated on changes to "value" attribute
// see bug #15708
$this->watchedAttributes[] = 'value';
}
protected function onAttributeChange($name, $value = null)
{
if ('value' != $name) {
return parent::onAttributeChange($name, $value);
}
if (null === $value) {
unset($this->attributes['value'], $this->attributes['checked']);
} else {
$this->attributes['value'] = $value;
$this->updateValue();
}
}
/**
* Sets the label to be rendered glued to the element
*
* This label is returned by {@link __toString()} method with the element's
* HTML. It is automatically wrapped into the <label> tag.
*
* @param string
* @return HTML_QuickForm2_Element_InputCheckable
*/
public function setContent($content)
{
$this->data['content'] = $content;
return $this;
}
/**
* Returns the label that will be "glued" to element's HTML
*
* @return string
*/
public function getContent()
{
return $this->data['content'];
}
public function setValue($value)
{
if ((string)$value == $this->getAttribute('value')) {
return $this->setAttribute('checked');
} else {
return $this->removeAttribute('checked');
}
}
public function getValue()
{
if (!empty($this->attributes['checked']) && empty($this->attributes['disabled'])) {
return $this->applyFilters($this->getAttribute('value'));
} else {
return null;
}
}
public function __toString()
{
if (0 == strlen($this->data['content'])) {
$label = '';
} elseif ($this->frozen) {
$label = $this->data['content'];
} else {
$label = '<label for="' . htmlspecialchars(
$this->getId(), ENT_QUOTES, self::getOption('charset')
) . '">' . $this->data['content'] . '</label>';
}
return parent::__toString() . $label;
}
public function getFrozenHtml()
{
if ($this->getAttribute('checked')) {
return $this->frozenHtml['checked'] . $this->getPersistentContent();
} else {
return $this->frozenHtml['unchecked'];
}
}
}
?>

View File

@ -0,0 +1,99 @@
<?php
/**
* Class for <input type="checkbox" /> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: InputCheckbox.php 294057 2010-01-26 21:10:28Z avb $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for checkboxes and radios
*/
// require_once 'HTML/QuickForm2/Element/InputCheckable.php';
/**
* Class for <input type="checkbox" /> elements
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_InputCheckbox extends HTML_QuickForm2_Element_InputCheckable
{
protected $attributes = array('type' => 'checkbox');
protected $frozenHtml = array(
'checked' => '<tt>[x]</tt>',
'unchecked' => '<tt>[&nbsp;]</tt>'
);
public function __construct($name = null, $attributes = null, array $data = array())
{
parent::__construct($name, $attributes, $data);
if (!$this->getAttribute('value')) {
$this->setAttribute('value', 1);
}
}
public function updateValue()
{
$name = $this->getName();
if ('[]' == substr($name, -2)) {
$name = substr($name, 0, -2);
}
foreach ($this->getDataSources() as $ds) {
if (null !== ($value = $ds->getValue($name))
|| $ds instanceof HTML_QuickForm2_DataSource_Submit
) {
if (!is_array($value)) {
$this->setValue($value);
} elseif (in_array($this->getAttribute('value'), array_map('strval', $value), true)) {
$this->setAttribute('checked');
} else {
$this->removeAttribute('checked');
}
return;
}
}
}
}
?>

View File

@ -0,0 +1,268 @@
<?php
/**
* Class for <input type="file" /> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: InputFile.php 300722 2010-06-24 10:15:52Z mansion $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for <input> elements
*/
// require_once 'HTML/QuickForm2/Element/Input.php';
/**
* Class for <input type="file" /> elements
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_InputFile extends HTML_QuickForm2_Element_Input
{
/**
* Default language for error messages
*/
const DEFAULT_LANGUAGE = 'en';
/**
* Localized error messages for PHP's file upload errors
* @var array
*/
protected $errorMessages = array(
'en' => array(
UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds size permitted by PHP configuration (%d bytes)',
UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive in HTML form (%d bytes)',
UPLOAD_ERR_PARTIAL => 'The file was only partially uploaded',
UPLOAD_ERR_NO_TMP_DIR => 'Server error: temporary directory is missing',
UPLOAD_ERR_CANT_WRITE => 'Server error: failed to write the file to disk',
UPLOAD_ERR_EXTENSION => 'File upload was stopped by extension'
),
'fr' => array(
UPLOAD_ERR_INI_SIZE => 'Le fichier envoy&eacute; exc&egrave;de la taille autoris&eacute;e par la configuration de PHP (%d octets)',
UPLOAD_ERR_FORM_SIZE => 'Le fichier envoy&eacute; exc&egrave;de la taille de MAX_FILE_SIZE sp&eacute;cifi&eacute;e dans le formulaire HTML (%d octets)',
UPLOAD_ERR_PARTIAL => 'Le fichier n\'a &eacute;t&eacute; que partiellement t&eacute;l&eacute;charg&eacute;',
UPLOAD_ERR_NO_TMP_DIR => 'Erreur serveur: le r&eacute;pertoire temporaire est manquant',
UPLOAD_ERR_CANT_WRITE => 'Erreur serveur: &eacute;chec de l\'&eacute;criture du fichier sur le disque',
UPLOAD_ERR_EXTENSION => 'L\'envoi de fichier est arr&ecirc;t&eacute; par l\'extension'
),
'ru' => array(
UPLOAD_ERR_INI_SIZE => '&#x420;&#x430;&#x437;&#x43c;&#x435;&#x440; &#x437;&#x430;&#x433;&#x440;&#x443;&#x436;&#x435;&#x43d;&#x43d;&#x43e;&#x433;&#x43e; &#x444;&#x430;&#x439;&#x43b;&#x430; &#x43f;&#x440;&#x435;&#x432;&#x43e;&#x441;&#x445;&#x43e;&#x434;&#x438;&#x442; &#x43c;&#x430;&#x43a;&#x441;&#x438;&#x43c;&#x430;&#x43b;&#x44c;&#x43d;&#x43e; &#x440;&#x430;&#x437;&#x440;&#x435;&#x448;&#x451;&#x43d;&#x43d;&#x44b;&#x439; &#x43d;&#x430;&#x441;&#x442;&#x440;&#x43e;&#x439;&#x43a;&#x430;&#x43c;&#x438; PHP (%d &#x431;&#x430;&#x439;&#x442;)',
UPLOAD_ERR_FORM_SIZE => '&#x420;&#x430;&#x437;&#x43c;&#x435;&#x440; &#x437;&#x430;&#x433;&#x440;&#x443;&#x436;&#x435;&#x43d;&#x43d;&#x43e;&#x433;&#x43e; &#x444;&#x430;&#x439;&#x43b;&#x430; &#x43f;&#x440;&#x435;&#x432;&#x43e;&#x441;&#x445;&#x43e;&#x434;&#x438;&#x442; &#x434;&#x438;&#x440;&#x435;&#x43a;&#x442;&#x438;&#x432;&#x443; MAX_FILE_SIZE, &#x443;&#x43a;&#x430;&#x437;&#x430;&#x43d;&#x43d;&#x443;&#x44e; &#x432; &#x444;&#x43e;&#x440;&#x43c;&#x435; (%d &#x431;&#x430;&#x439;&#x442;)',
UPLOAD_ERR_PARTIAL => '&#x424;&#x430;&#x439;&#x43b; &#x431;&#x44b;&#x43b; &#x437;&#x430;&#x433;&#x440;&#x443;&#x436;&#x435;&#x43d; &#x43d;&#x435; &#x43f;&#x43e;&#x43b;&#x43d;&#x43e;&#x441;&#x442;&#x44c;&#x44e;',
UPLOAD_ERR_NO_TMP_DIR => '&#x41e;&#x448;&#x438;&#x431;&#x43a;&#x430; &#x43d;&#x430; &#x441;&#x435;&#x440;&#x432;&#x435;&#x440;&#x435;: &#x43e;&#x442;&#x441;&#x443;&#x442;&#x441;&#x442;&#x432;&#x443;&#x435;&#x442; &#x43a;&#x430;&#x442;&#x430;&#x43b;&#x43e;&#x433; &#x434;&#x43b;&#x44f; &#x432;&#x440;&#x435;&#x43c;&#x435;&#x43d;&#x43d;&#x44b;&#x445; &#x444;&#x430;&#x439;&#x43b;&#x43e;&#x432;',
UPLOAD_ERR_CANT_WRITE => '&#x41e;&#x448;&#x438;&#x431;&#x43a;&#x430; &#x43d;&#x430; &#x441;&#x435;&#x440;&#x432;&#x435;&#x440;&#x435;: &#x43d;&#x435; &#x443;&#x434;&#x430;&#x43b;&#x43e;&#x441;&#x44c; &#x437;&#x430;&#x43f;&#x438;&#x441;&#x430;&#x442;&#x44c; &#x444;&#x430;&#x439;&#x43b; &#x43d;&#x430; &#x434;&#x438;&#x441;&#x43a;',
UPLOAD_ERR_EXTENSION => '&#x417;&#x430;&#x433;&#x440;&#x443;&#x437;&#x43a;&#x430; &#x444;&#x430;&#x439;&#x43b;&#x430; &#x431;&#x44b;&#x43b;&#x430; &#x43e;&#x441;&#x442;&#x430;&#x43d;&#x43e;&#x432;&#x43b;&#x435;&#x43d;&#x430; &#x440;&#x430;&#x441;&#x448;&#x438;&#x440;&#x435;&#x43d;&#x438;&#x435;&#x43c;'
)
);
/**
* Language to display error messages in
* @var string
*/
protected $language;
/**
* Information on uploaded file, from submit data source
* @var array
*/
protected $value = null;
protected $attributes = array('type' => 'file');
/**
* Class constructor
*
* Possible keys in $data array are:
* - 'language': language to display error messages in, it should either be
* already available in the class or provided in 'errorMessages'
* - 'errorMessages': an array of error messages with the following format
* <pre>
* 'language code 1' => array(
* UPLOAD_ERR_... => 'message',
* ...
* UPLOAD_ERR_... => 'message'
* ),
* ...
* 'language code N' => array(
* ...
* )
* </pre>
* Note that error messages for UPLOAD_ERR_INI_SIZE and UPLOAD_ERR_FORM_SIZE
* may contain '%d' placeholders that will be automatically replaced by the
* appropriate size limits. Note also that you don't need to provide messages
* for every possible error code in the arrays, you may e.g. override just
* one error message for a particular language.
*
* @param string Element name
* @param mixed Attributes (either a string or an array)
* @param array Data used to set up error messages for PHP's file
* upload errors.
*/
public function __construct($name = null, $attributes = null, array $data = array())
{
if (isset($data['errorMessages'])) {
// neither array_merge() nor array_merge_recursive will do
foreach ($data['errorMessages'] as $lang => $ary) {
foreach ($ary as $code => $message) {
$this->errorMessages[$lang][$code] = $message;
}
}
unset($data['errorMessages']);
}
if (!isset($data['language'])) {
$this->language = self::DEFAULT_LANGUAGE;
} else {
$this->language = isset($this->errorMessages[$data['language']])?
$data['language']: self::DEFAULT_LANGUAGE;
unset($data['language']);
}
parent::__construct($name, $attributes, $data);
}
/**
* File upload elements cannot be frozen
*
* To properly "freeze" a file upload element one has to store the uploaded
* file somewhere and store the file info in session. This is way outside
* the scope of this class.
*
* @param bool Whether element should be frozen or editable. This
* parameter is ignored in case of file uploads
* @return bool Always returns false
*/
public function toggleFrozen($freeze = null)
{
return false;
}
/**
* Returns the information on uploaded file
*
* @return array|null
*/
public function getValue()
{
return $this->value;
}
/**
* File upload's value cannot be set here
*
* @param mixed Value for file element, this parameter is ignored
* @return HTML_QuickForm2_Element_InputFile
*/
public function setValue($value)
{
return $this;
}
public function updateValue()
{
foreach ($this->getDataSources() as $ds) {
if ($ds instanceof HTML_QuickForm2_DataSource_Submit) {
$value = $ds->getUpload($this->getName());
if (null !== $value) {
$this->value = $value;
return;
}
}
}
$this->value = null;
}
/**
* Performs the server-side validation
*
* Before the Rules added to the element kick in, the element checks the
* error code added to the $_FILES array by PHP. If the code isn't
* UPLOAD_ERR_OK or UPLOAD_ERR_NO_FILE then a built-in error message will be
* displayed and no further validation will take place.
*
* @return boolean Whether the element is valid
*/
protected function validate()
{
if (strlen($this->error)) {
return false;
}
if (isset($this->value['error']) &&
!in_array($this->value['error'], array(UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE)))
{
if (isset($this->errorMessages[$this->language][$this->value['error']])) {
$errorMessage = $this->errorMessages[$this->language][$this->value['error']];
} else {
$errorMessage = $this->errorMessages[self::DEFAULT_LANGUAGE][$this->value['error']];
}
if (UPLOAD_ERR_INI_SIZE == $this->value['error']) {
$iniSize = ini_get('upload_max_filesize');
$size = intval($iniSize);
switch (strtoupper(substr($iniSize, -1))) {
case 'G': $size *= 1024;
case 'M': $size *= 1024;
case 'K': $size *= 1024;
}
} elseif (UPLOAD_ERR_FORM_SIZE == $this->value['error']) {
foreach ($this->getDataSources() as $ds) {
if ($ds instanceof HTML_QuickForm2_DataSource_Submit) {
$size = intval($ds->getValue('MAX_FILE_SIZE'));
break;
}
}
}
$this->error = isset($size)? sprintf($errorMessage, $size): $errorMessage;
return false;
}
return parent::validate();
}
public function addFilter($callback, array $options = null, $recursive = true)
{
throw new HTML_QuickForm2_Exception(
'InputFile elements do not support filters'
);
}
}
?>

View File

@ -0,0 +1,82 @@
<?php
/**
* Class for <input type="hidden" /> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: InputHidden.php 294057 2010-01-26 21:10:28Z avb $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for <input> elements
*/
// require_once 'HTML/QuickForm2/Element/Input.php';
/**
* Class for <input type="hidden" /> elements
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_InputHidden extends HTML_QuickForm2_Element_Input
{
protected $attributes = array('type' => 'hidden');
/**
* Hidden elements can not be frozen
*
* @param bool Whether element should be frozen or editable. This
* parameter is ignored in case of hidden elements
* @return bool Always returns false
*/
public function toggleFrozen($freeze = null)
{
return false;
}
public function render(HTML_QuickForm2_Renderer $renderer)
{
$renderer->renderHidden($this);
return $renderer;
}
}
?>

View File

@ -0,0 +1,162 @@
<?php
/**
* Class for <input type="image" /> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: InputImage.php 300722 2010-06-24 10:15:52Z mansion $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for <input> elements
*/
// require_once 'HTML/QuickForm2/Element/Input.php';
/**
* Class for <input type="image" /> elements
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_InputImage extends HTML_QuickForm2_Element_Input
{
protected $attributes = array('type' => 'image');
/**
* Coordinates of user click within the image, array contains keys 'x' and 'y'
* @var array
*/
protected $coordinates = null;
/**
* Image buttons can not be frozen
*
* @param bool Whether element should be frozen or editable. This
* parameter is ignored in case of image elements
* @return bool Always returns false
*/
public function toggleFrozen($freeze = null)
{
return false;
}
/**
* Image button's value cannot be set via this method
*
* @param mixed Element's value, this parameter is ignored
* @return HTML_QuickForm2_Element_InputImage
*/
public function setValue($value)
{
return $this;
}
/**
* Returns the element's value
*
* The value is only returned if the form was actually submitted and this
* image button was clicked. Returns null in all other cases.
*
* @return array|null An array with keys 'x' and 'y' containing the
* coordinates of user click if the image was clicked,
* null otherwise
*/
public function getValue()
{
return $this->getAttribute('disabled')? null: $this->applyFilters($this->coordinates);
}
/**
* Returns the HTML representation of the element
*
* The method changes the element's name to foo[bar][] if it was foo[bar]
* originally. If it is not done, then one of the click coordinates will be
* lost, see {@link http://bugs.php.net/bug.php?id=745}
*
* @return string
*/
public function __toString()
{
if (false === strpos($this->attributes['name'], '[') ||
'[]' == substr($this->attributes['name'], -2))
{
return parent::__toString();
} else {
$this->attributes['name'] .= '[]';
$html = parent::__toString();
$this->attributes['name'] = substr($this->attributes['name'], 0, -2);
return $html;
}
}
public function updateValue()
{
foreach ($this->getDataSources() as $ds) {
if ($ds instanceof HTML_QuickForm2_DataSource_Submit) {
$name = $this->getName();
if (false === strpos($name, '[') &&
null !== ($value = $ds->getValue($name . '_x')))
{
$this->coordinates = array(
'x' => $value,
'y' => $ds->getValue($name . '_y')
);
return;
} elseif (false !== strpos($name, '[')) {
if ('[]' == substr($name, -2)) {
$name = substr($name, 0, -2);
}
if (null !== ($value = $ds->getValue($name))) {
$this->coordinates = array(
'x' => $value[0],
'y' => $value[1]
);
return;
}
}
}
}
$this->coordinates = null;
}
}
?>

View File

@ -0,0 +1,71 @@
<?php
/**
* Class for <input type="password" /> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: InputPassword.php 294057 2010-01-26 21:10:28Z avb $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for <input> elements
*/
// require_once 'HTML/QuickForm2/Element/Input.php';
/**
* Class for <input type="password" /> elements
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_InputPassword extends HTML_QuickForm2_Element_Input
{
protected $attributes = array('type' => 'password');
protected function getFrozenHtml()
{
$value = $this->getValue();
return (('' != $value)? '********': '&nbsp;') .
$this->getPersistentContent();
}
}
?>

View File

@ -0,0 +1,69 @@
<?php
/**
* Class for <input type="radio" /> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: InputRadio.php 294057 2010-01-26 21:10:28Z avb $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for checkboxes and radios
*/
// require_once 'HTML/QuickForm2/Element/InputCheckable.php';
/**
* Class for <input type="radio" /> elements
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_InputRadio extends HTML_QuickForm2_Element_InputCheckable
{
protected $attributes = array('type' => 'radio');
protected $frozenHtml = array(
'checked' => '<tt>(x)</tt>',
'unchecked' => '<tt>(&nbsp;)</tt>'
);
}
?>

View File

@ -0,0 +1,99 @@
<?php
/**
* Class for <input type="reset" /> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: InputReset.php 294057 2010-01-26 21:10:28Z avb $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for <input> elements
*/
// require_once 'HTML/QuickForm2/Element/Input.php';
/**
* Class for <input type="reset" /> elements
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_InputReset extends HTML_QuickForm2_Element_Input
{
protected $attributes = array('type' => 'reset');
/**
* Reset buttons can not be frozen
*
* @param bool Whether element should be frozen or editable. This
* parameter is ignored in case of reset buttons
* @return bool Always returns false
*/
public function toggleFrozen($freeze = null)
{
return false;
}
/**
* Reset elements cannot have any submit values
*
* @param mixed Element's value, this parameter is ignored
* @return HTML_QuickForm2_Element_InputReset
*/
public function setValue($value)
{
return $this;
}
/**
* Reset elements cannot have any submit values
*
* This method always returns null
*
* @return string|null
*/
public function getValue()
{
return null;
}
}
?>

View File

@ -0,0 +1,120 @@
<?php
/**
* Class for <input type="submit" /> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: InputSubmit.php 300722 2010-06-24 10:15:52Z mansion $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for <input> elements
*/
// require_once 'HTML/QuickForm2/Element/Input.php';
/**
* Class for <input type="submit" /> elements
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_InputSubmit extends HTML_QuickForm2_Element_Input
{
protected $attributes = array('type' => 'submit');
/**
* Element's submit value
* @var string
*/
protected $submitValue = null;
/**
* Submit buttons can not be frozen
*
* @param bool Whether element should be frozen or editable. This
* parameter is ignored in case of submit elements
* @return bool Always returns false
*/
public function toggleFrozen($freeze = null)
{
return false;
}
/**
* Submit's value cannot be set via this method
*
* @param mixed Element's value, this parameter is ignored
* @return HTML_QuickForm2_Element_InputSubmit
*/
public function setValue($value)
{
return $this;
}
/**
* Returns the element's value
*
* The value is only returned if the form was actually submitted and this
* submit button was clicked. Returns null in all other cases
*
* @return string|null
*/
public function getValue()
{
return $this->getAttribute('disabled')? null: $this->applyFilters($this->submitValue);
}
public function updateValue()
{
foreach ($this->getDataSources() as $ds) {
if ($ds instanceof HTML_QuickForm2_DataSource_Submit &&
null !== ($value = $ds->getValue($this->getName())))
{
$this->submitValue = $value;
return;
}
}
$this->submitValue = null;
}
}
?>

View File

@ -0,0 +1,64 @@
<?php
/**
* Class for <input type="text" /> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: InputText.php 294057 2010-01-26 21:10:28Z avb $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for <input> elements
*/
// require_once 'HTML/QuickForm2/Element/Input.php';
/**
* Class for <input type="text" /> elements
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_InputText extends HTML_QuickForm2_Element_Input
{
protected $attributes = array('type' => 'text');
}
?>

View File

@ -0,0 +1,575 @@
<?php
/**
* Classes for <select> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: Select.php 300722 2010-06-24 10:15:52Z mansion $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for simple HTML_QuickForm2 elements
*/
// require_once 'HTML/QuickForm2/Element.php';
/**
* Collection of <option>s and <optgroup>s
*
* This class handles the output of <option> tags. The class is not intended to
* be used directly.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_Select_OptionContainer extends HTML_Common2
implements IteratorAggregate, Countable
{
/**
* List of options and optgroups in this container
*
* Options are stored as arrays (for performance reasons), optgroups as
* instances of Optgroup class.
*
* @var array
*/
protected $options = array();
/**
* Reference to parent <select>'s values
* @var array
*/
protected $values;
/**
* Reference to parent <select>'s possible values
* @var array
*/
protected $possibleValues;
/**
* Class constructor
*
* @param array Reference to values of parent <select> element
* @param array Reference to possible values of parent <select> element
*/
public function __construct(&$values, &$possibleValues)
{
$this->values =& $values;
$this->possibleValues =& $possibleValues;
}
/**
* Adds a new option
*
* Please note that if you pass 'selected' attribute in the $attributes
* parameter then this option's value will be added to <select>'s values.
*
* @param string Option text
* @param string 'value' attribute for <option> tag
* @param mixed Additional attributes for <option> tag (either as a
* string or as an associative array)
*/
public function addOption($text, $value, $attributes = null)
{
if (null === $attributes) {
$attributes = array('value' => (string)$value);
} else {
$attributes = self::prepareAttributes($attributes);
if (isset($attributes['selected'])) {
// the 'selected' attribute will be set in __toString()
unset($attributes['selected']);
if (!in_array($value, $this->values)) {
$this->values[] = $value;
}
}
$attributes['value'] = (string)$value;
}
if (!isset($attributes['disabled'])) {
$this->possibleValues[(string)$value] = true;
}
$this->options[] = array('text' => $text, 'attr' => $attributes);
}
/**
* Adds a new optgroup
*
* @param string 'label' attribute for optgroup tag
* @param mixed Additional attributes for <optgroup> tag (either as a
* string or as an associative array)
* @return HTML_QuickForm2_Element_Select_Optgroup
*/
public function addOptgroup($label, $attributes = null)
{
$optgroup = new HTML_QuickForm2_Element_Select_Optgroup(
$this->values, $this->possibleValues,
$label, $attributes
);
$this->options[] = $optgroup;
return $optgroup;
}
/**
* Returns an array of contained options
*
* @return array
*/
public function getOptions()
{
return $this->options;
}
public function __toString()
{
$indentLvl = $this->getIndentLevel();
$indent = $this->getIndent() . self::getOption('indent');
$linebreak = self::getOption('linebreak');
$html = '';
$strValues = array_map('strval', $this->values);
foreach ($this->options as $option) {
if (is_array($option)) {
if (in_array($option['attr']['value'], $strValues, true)) {
$option['attr']['selected'] = 'selected';
}
$html .= $indent . '<option' .
self::getAttributesString($option['attr']) .
'>' . $option['text'] . '</option>' . $linebreak;
} elseif ($option instanceof HTML_QuickForm2_Element_Select_OptionContainer) {
$option->setIndentLevel($indentLvl + 1);
$html .= $option->__toString();
}
}
return $html;
}
/**
* Returns an iterator over contained elements
*
* @return HTML_QuickForm2_Element_Select_OptionIterator
*/
public function getIterator()
{
return new HTML_QuickForm2_Element_Select_OptionIterator($this->options);
}
/**
* Returns a recursive iterator over contained elements
*
* @return RecursiveIteratorIterator
*/
public function getRecursiveIterator()
{
return new RecursiveIteratorIterator(
new HTML_QuickForm2_Element_Select_OptionIterator($this->options),
RecursiveIteratorIterator::SELF_FIRST
);
}
/**
* Returns the number of options in the container
*
* @return int
*/
public function count()
{
return count($this->options);
}
}
/**
* Class representing an <optgroup> tag
*
* Do not instantiate this class yourself, use
* {@link HTML_QuickForm2_Element_Select::addOptgroup()} method
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_Select_Optgroup
extends HTML_QuickForm2_Element_Select_OptionContainer
{
/**
* Class constructor
*
* @param array Reference to values of parent <select> element
* @param array Reference to possible values of parent <select> element
* @param string 'label' attribute for optgroup tag
* @param mixed Additional attributes for <optgroup> tag (either as a
* string or as an associative array)
*/
public function __construct(&$values, &$possibleValues, $label, $attributes = null)
{
parent::__construct($values, $possibleValues);
$this->setAttributes($attributes);
$this->attributes['label'] = (string)$label;
}
public function __toString()
{
$indent = $this->getIndent();
$linebreak = self::getOption('linebreak');
return $indent . '<optgroup' . $this->getAttributes(true) . '>' .
$linebreak . parent::__toString() . $indent . '</optgroup>' . $linebreak;
}
}
/**
* Implements a recursive iterator for options arrays
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_Select_OptionIterator extends RecursiveArrayIterator
implements RecursiveIterator
{
public function hasChildren()
{
return $this->current() instanceof HTML_QuickForm2_Element_Select_OptionContainer;
}
public function getChildren()
{
return new HTML_QuickForm2_Element_Select_OptionIterator(
$this->current()->getOptions()
);
}
}
/**
* Class representing a <select> element
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_Select extends HTML_QuickForm2_Element
{
protected $persistent = true;
/**
* Values for the select element (i.e. values of the selected options)
* @var array
*/
protected $values = array();
/**
* Possible values for select elements
*
* A value is considered possible if it is present as a value attribute of
* some option and that option is not disabled.
* @var array
*/
protected $possibleValues = array();
/**
* Object containing options for the <select> element
* @var HTML_QuickForm2_Element_Select_OptionContainer
*/
protected $optionContainer;
/**
* Enable intrinsic validation by default
* @var array
*/
protected $data = array('intrinsic_validation' => true);
/**
* Class constructor
*
* Select element can understand the following keys in $data parameter:
* - 'options': data to populate element's options with. Passed to
* {@link loadOptions()} method.
* - 'intrinsic_validation': setting this to false will disable
* that validation, {@link getValue()} will then return all submit
* values, not just those corresponding to options present in the
* element. May be useful in AJAX scenarios.
*
* @param string Element name
* @param mixed Attributes (either a string or an array)
* @param array Additional element data
* @throws HTML_QuickForm2_InvalidArgumentException if junk is given in $options
*/
public function __construct($name = null, $attributes = null, array $data = array())
{
$options = isset($data['options'])? $data['options']: array();
unset($data['options']);
parent::__construct($name, $attributes, $data);
$this->loadOptions($options);
}
public function getType()
{
return 'select';
}
public function __toString()
{
if ($this->frozen) {
return $this->getFrozenHtml();
} else {
if (empty($this->attributes['multiple'])) {
$attrString = $this->getAttributes(true);
} else {
$this->attributes['name'] .= '[]';
$attrString = $this->getAttributes(true);
$this->attributes['name'] = substr($this->attributes['name'], 0, -2);
}
$indent = $this->getIndent();
return $indent . '<select' . $attrString . '>' .
self::getOption('linebreak') .
$this->optionContainer->__toString() .
$indent . '</select>';
}
}
protected function getFrozenHtml()
{
if (null === ($value = $this->getValue())) {
return '&nbsp;';
}
$valueHash = is_array($value)? array_flip($value): array($value => true);
$options = array();
foreach ($this->optionContainer->getRecursiveIterator() as $child) {
if (is_array($child) && isset($valueHash[$child['attr']['value']]) &&
empty($child['attr']['disabled']))
{
$options[] = $child['text'];
}
}
$html = implode('<br />', $options);
if ($this->persistent) {
$name = $this->attributes['name'] .
(empty($this->attributes['multiple'])? '': '[]');
// Only use id attribute if doing single hidden input
$idAttr = (1 == count($valueHash))? array('id' => $this->getId()): array();
foreach ($valueHash as $key => $item) {
$html .= '<input type="hidden"' . self::getAttributesString(array(
'name' => $name,
'value' => $key
) + $idAttr) . ' />';
}
}
return $html;
}
/**
* Returns the value of the <select> element
*
* Please note that the returned value may not necessarily be equal to that
* passed to {@link setValue()}. It passes "intrinsic validation" confirming
* that such value could possibly be submitted by this <select> element.
* Specifically, this method will return null if the elements "disabled"
* attribute is set, it will not return values if there are no options having
* such a "value" attribute or if such options' "disabled" attribute is set.
* It will also only return a scalar value for single selects, mimicking
* the common browsers' behaviour.
*
* @return mixed "value" attribute of selected option in case of single
* select, array of selected options' "value" attributes in
* case of multiple selects, null if no options selected
*/
public function getValue()
{
if (!empty($this->attributes['disabled']) || 0 == count($this->values)
|| ($this->data['intrinsic_validation']
&& (0 == count($this->optionContainer) || 0 == count($this->possibleValues)))
) {
return null;
}
$values = array();
foreach ($this->values as $value) {
if (!$this->data['intrinsic_validation'] || !empty($this->possibleValues[$value])) {
$values[] = $value;
}
}
if (0 == count($values)) {
return null;
} elseif (!empty($this->attributes['multiple'])) {
return $this->applyFilters($values);
} elseif (1 == count($values)) {
return $this->applyFilters($values[0]);
} else {
// The <select> is not multiple, but several options are to be
// selected. At least IE and Mozilla select the last selected
// option in this case, we should do the same
foreach ($this->optionContainer->getRecursiveIterator() as $child) {
if (is_array($child) && in_array($child['attr']['value'], $values)) {
$lastValue = $child['attr']['value'];
}
}
return $this->applyFilters($lastValue);
}
}
public function setValue($value)
{
if (is_array($value)) {
$this->values = array_values($value);
} else {
$this->values = array($value);
}
return $this;
}
/**
* Loads <option>s (and <optgroup>s) for select element
*
* The method expects a array of options and optgroups:
* <pre>
* array(
* 'option value 1' => 'option text 1',
* ...
* 'option value N' => 'option text N',
* 'optgroup label 1' => array(
* 'option value' => 'option text',
* ...
* ),
* ...
* )
* </pre>
* If value is a scalar, then array key is treated as "value" attribute of
* <option> and value as this <option>'s text. If value is an array, then
* key is treated as a "label" attribute of <optgroup> and value as an
* array of <option>s for this <optgroup>.
*
* If you need to specify additional attributes for <option> and <optgroup>
* tags, then you need to use {@link addOption()} and {@link addOptgroup()}
* methods instead of this one.
*
* @param array
* @throws HTML_QuickForm2_InvalidArgumentException if junk is given in $options
* @return HTML_QuickForm2_Element_Select
*/
public function loadOptions(array $options)
{
$this->possibleValues = array();
$this->optionContainer = new HTML_QuickForm2_Element_Select_OptionContainer(
$this->values, $this->possibleValues
);
$this->loadOptionsFromArray($this->optionContainer, $options);
return $this;
}
/**
* Adds options from given array into given container
*
* @param HTML_QuickForm2_Element_Select_OptionContainer options will be
* added to this container
* @param array options array
*/
protected function loadOptionsFromArray(
HTML_QuickForm2_Element_Select_OptionContainer $container, $options
)
{
foreach ($options as $key => $value) {
if (is_array($value)) {
$optgroup = $container->addOptgroup($key);
$this->loadOptionsFromArray($optgroup, $value);
} else {
$container->addOption($value, $key);
}
}
}
/**
* Adds a new option
*
* Please note that if you pass 'selected' attribute in the $attributes
* parameter then this option's value will be added to <select>'s values.
*
* @param string Option text
* @param string 'value' attribute for <option> tag
* @param mixed Additional attributes for <option> tag (either as a
* string or as an associative array)
*/
public function addOption($text, $value, $attributes = null)
{
return $this->optionContainer->addOption($text, $value, $attributes);
}
/**
* Adds a new optgroup
*
* @param string 'label' attribute for optgroup tag
* @param mixed Additional attributes for <optgroup> tag (either as a
* string or as an associative array)
* @return HTML_QuickForm2_Element_Select_Optgroup
*/
public function addOptgroup($label, $attributes = null)
{
return $this->optionContainer->addOptgroup($label, $attributes);
}
public function updateValue()
{
if (!$this->getAttribute('multiple')) {
parent::updateValue();
} else {
$name = $this->getName();
foreach ($this->getDataSources() as $ds) {
if (null !== ($value = $ds->getValue($name)) ||
$ds instanceof HTML_QuickForm2_DataSource_Submit)
{
$this->setValue(null === $value? array(): $value);
return;
}
}
}
}
}
?>

View File

@ -0,0 +1,153 @@
<?php
/**
* Class for static elements that only contain text or markup
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: Static.php 299206 2010-05-10 10:21:10Z mansion $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for simple HTML_QuickForm2 elements (not Containers)
*/
// require_once 'HTML/QuickForm2/Element.php';
/**
* Class for static elements that only contain text or markup
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_Static extends HTML_QuickForm2_Element
{
/**
* Contains options and data used for the element creation
* - content: Content of the static element
* @var array
*/
protected $data = array('content' => '');
public function getType()
{
return 'static';
}
/**
* Static element can not be frozen
*
* @param bool Whether element should be frozen or editable. This
* parameter is ignored in case of static elements
* @return bool Always returns false
*/
public function toggleFrozen($freeze = null)
{
return false;
}
/**
* Sets the contents of the static element
*
* @param string Static content
* @return HTML_QuickForm2_Element_Static
*/
function setContent($content)
{
$this->data['content'] = $content;
return $this;
}
/**
* Returns the contents of the static element
*
* @return string
*/
function getContent()
{
return $this->data['content'];
}
/**
* Static element's content can also be set via this method
*
* @param mixed Element's value, this parameter is ignored
* @return HTML_QuickForm2_Element_Static
*/
public function setValue($value)
{
$this->setContent($value);
return $this;
}
/**
* Static elements have no value
*
* @return null
*/
public function getValue()
{
return null;
}
public function __toString()
{
return $this->getIndent() . $this->data['content'];
}
/**
* Called when the element needs to update its value from form's data sources
*
* Static elements content can be updated with default form values.
*/
public function updateValue()
{
foreach ($this->getDataSources() as $ds) {
if (!$ds instanceof HTML_QuickForm2_DataSource_Submit &&
null !== ($value = $ds->getValue($this->getName())))
{
$this->setContent($value);
return;
}
}
}
}
?>

View File

@ -0,0 +1,110 @@
<?php
/**
* Class for <textarea> elements
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2006-2010, Alexey Borzov <avb@php.net>,
* Bertrand Mansion <golgote@mamasam.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version SVN: $Id: Textarea.php 300722 2010-06-24 10:15:52Z mansion $
* @link http://pear.php.net/package/HTML_QuickForm2
*/
/**
* Base class for simple HTML_QuickForm2 elements
*/
// require_once 'HTML/QuickForm2/Element.php';
/**
* Class for <textarea> elements
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @version Release: @package_version@
*/
class HTML_QuickForm2_Element_Textarea extends HTML_QuickForm2_Element
{
protected $persistent = true;
/**
* Value for textarea field
* @var string
*/
protected $value = null;
public function getType()
{
return 'textarea';
}
public function setValue($value)
{
$this->value = $value;
return $this;
}
public function getValue()
{
return empty($this->attributes['disabled'])? $this->applyFilters($this->value): null;
}
public function __toString()
{
if ($this->frozen) {
return $this->getFrozenHtml();
} else {
return $this->getIndent() . '<textarea' . $this->getAttributes(true) .
'>' . preg_replace("/(\r\n|\n|\r)/", '&#010;', htmlspecialchars(
$this->value, ENT_QUOTES, self::getOption('charset')
)) . '</textarea>';
}
}
public function getFrozenHtml()
{
$value = htmlspecialchars($this->value, ENT_QUOTES, self::getOption('charset'));
if ('off' == $this->getAttribute('wrap')) {
$html = $this->getIndent() . '<pre>' . $value .
'</pre>' . self::getOption('linebreak');
} else {
$html = nl2br($value) . self::getOption('linbebreak');
}
return $html . $this->getPersistentContent();
}
}
?>