import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -1,15 +1,20 @@
<?
class Monkeys_Form_Decorator_Composite extends Zend_Form_Decorator_Abstract
implements Zend_Form_Decorator_Marker_File_Interface // to avoid Zend_Form_Element_File to whine
{
public function buildLabel()
{
$element = $this->getElement();
$label = $element->getLabel();
if ($label == '') {
return false;
}
if ($translator = $element->getTranslator()) {
$label = $translator->translate($label);
}
if ($element->isRequired()) {
if ($element->isRequired() && !$this->getOption('dontMarkRequired')) {
$label .= '*';
}
@ -83,6 +88,7 @@ class Monkeys_Form_Decorator_Composite extends Zend_Form_Decorator_Abstract
return $content;
}
$separator = $this->getSeparator();
$placement = $this->getPlacement();
$label = $this->buildLabel();
$input = $this->buildInput($content);
@ -102,15 +108,30 @@ class Monkeys_Form_Decorator_Composite extends Zend_Form_Decorator_Abstract
}
if ($this->getOption('wideLabel')) {
$output = "<div class=\"yui-$yuiGridType\" style=\"padding-bottom:10px\">\n"
." <div class=\"formLabel\" style=\"padding-bottom:10px\">$label</div>\n"
." <div class=\"yui-u first\">&nbsp;</div>\n"
." <div class=\"yui-u\">\n"
." $input\n"
." $desc\n"
. ($errors? " <div>$errors</div>\n" : "")
." </div>\n"
."</div>\n";
if ($label !== false) {
$output = "<div class=\"yui-$yuiGridType\" style=\"padding-bottom:10px\">\n"
." <div class=\"formLabel\" style=\"padding-bottom:10px\">$label</div>\n"
." <div class=\"yui-u first\">&nbsp;</div>\n"
." <div class=\"yui-u\">\n"
." $input\n"
." $desc\n"
. ($errors? " <div>$errors</div>\n" : "")
." </div>\n"
."</div>\n";
} else {
$output = "<div style=\"padding-bottom:10px\">\n"
." $input\n"
." $desc\n"
. ($errors? " <div>$errors</div>\n" : "")
."</div>\n";
}
} else if ($this->getOption('separateLine')) {
$output = "<div class=\"yui-$yuiGridType\" style=\"font-weight:bold\">\n"
." $label\n"
."</div>\n"
."<div>$input</div>\n"
."<div>$desc</div>\n"
. ($errors? "<div>$errors</div>\n" : "");
} else if ($this->getOption('continuous')) {
$output = "<div style=\"padding-bottom:10px\">\n"
." <span class=\"formLabel\">$label</span> $input"
@ -131,6 +152,15 @@ class Monkeys_Form_Decorator_Composite extends Zend_Form_Decorator_Abstract
}
return $output;
// I believe we shouldn't use $placement (messes up the captcha, but I'm not sure about radios)
/*switch ($placement) {
case (self::PREPEND):
return $output . $separator . $content;
case (self::APPEND):
default:
return $content . $separator . $output;
}*/
}
}

View File

@ -0,0 +1,142 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD Licensese
* @author Keyboard Monkeys Ltd.
* @since CommunityID0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Monkeys_Form_Element_DateTime extends Zend_Form_Element_Xhtml
{
public $helper = 'formDateTimeSelects';
public $options = array();
protected $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
public function init()
{
$this->options['showEmpty'] = true;
$this->options['startYear'] = 1900;
$this->options['endYear'] = (int) date("Y");
$this->options['reverseYears'] = false;
}
public function setShowEmptyValues($value)
{
$this->options['showEmpty'] = (bool) $value;
return $this;
}
public function setStartEndYear($start = null, $end = null)
{
if ($start)
{
$this->options['startYear'] = (int) $start;
}
if ($end)
{
$this->options['endYear'] = (int) $end;
}
return $this;
}
public function setReverseYears($value)
{
$this->options['reverseYears'] = (bool) $value;
return $this;
}
public function isValid($value, $context = null)
{
$fieldName = $this->getName();
$auxiliaryFieldsNames = $this->getDayMonthYearTimeFieldNames($fieldName);
if (isset($context[$auxiliaryFieldsNames['day']]) && isset($context[$auxiliaryFieldsNames['month']])
&& isset($context[$auxiliaryFieldsNames['year']]) && isset($context[$auxiliaryFieldsNames['hour']])
&& isset($context[$auxiliaryFieldsNames['minutes']]) && isset($context[$auxiliaryFieldsNames['ampm']]))
{
if ($context[$auxiliaryFieldsNames['year']] == '-'
|| $context[$auxiliaryFieldsNames['month']] == '-'
|| $context[$auxiliaryFieldsNames['day']] == '-'
|| $context[$auxiliaryFieldsNames['hour']] == '-'
|| $context[$auxiliaryFieldsNames['minutes']] == '-'
|| $context[$auxiliaryFieldsNames['ampm']] == '-')
{
$value = null;
}
else
{
$hour = $context[$auxiliaryFieldsNames['hour']];
if ($context[$auxiliaryFieldsNames['ampm']] == 'pm') {
$hour += 12;
}
$value = str_pad($context[$auxiliaryFieldsNames['year']], 4, '0', STR_PAD_LEFT) . '-'
. str_pad($context[$auxiliaryFieldsNames['month']], 2, '0', STR_PAD_LEFT) . '-'
. str_pad($context[$auxiliaryFieldsNames['day']], 2, '0', STR_PAD_LEFT) . ' '
. str_pad($hour, 2, '0', STR_PAD_LEFT) . ':'
. str_pad($context[$auxiliaryFieldsNames['minutes']], 2, '0', STR_PAD_LEFT) . ':00';
}
$this->setValue($value);
}
return parent::isValid($value, $context);
}
protected function getDayMonthYearTimeFieldNames($value)
{
if (empty($value) || !is_string($value)) {
return $value;
}
$ret = array(
'day' => $value . '_day',
'month' => $value . '_month',
'year' => $value . '_year',
'hour' => $value . '_hour',
'minutes' => $value . '_minutes',
'ampm' => $value . '_ampm',
);
if (strstr($value, '['))
{
$endPos = strlen($value) - 1;
if (']' != $value[$endPos]) {
return $ret;
}
$start = strrpos($value, '[') + 1;
$name = substr($value, $start, $endPos - $start);
$arrayName = substr($value, 0, $start-1);
$ret = array(
'day' => $arrayName . '[' . $name . '_day' . ']',
'month' => $arrayName . '[' . $name . '_month' . ']',
'year' => $arrayName . '[' . $name . '_year' . ']',
'hour' => $arrayName . '[' . $name . '_hour' . ']',
'minutes' => $arrayName . '[' . $name . '_minutes' . ']',
'ampm' => $arrayName . '[' . $name . '_ampm' . ']',
);
}
return $ret;
}
}

View File

@ -2,12 +2,22 @@
class Monkeys_Form_Element_Password extends Zend_Form_Element_Password
{
private $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->addDecorator(new Monkeys_Form_Decorator_Composite());
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
}

View File

@ -0,0 +1,24 @@
<?php
class Monkeys_Form_Element_Richtextarea extends Zend_Form_Element_Xhtml
{
public $helper = 'formRichtextarea';
private $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
}

View File

@ -0,0 +1,23 @@
<?php
class Monkeys_Form_Element_Select extends Zend_Form_Element_Select
{
private $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
}

View File

@ -0,0 +1,246 @@
AFGHANISTAN;AF
ÅLAND ISLANDS;AX
ALBANIA;AL
ALGERIA;DZ
AMERICAN SAMOA;AS
ANDORRA;AD
ANGOLA;AO
ANGUILLA;AI
ANTARCTICA;AQ
ANTIGUA AND BARBUDA;AG
ARGENTINA;AR
ARMENIA;AM
ARUBA;AW
AUSTRALIA;AU
AUSTRIA;AT
AZERBAIJAN;AZ
BAHAMAS;BS
BAHRAIN;BH
BANGLADESH;BD
BARBADOS;BB
BELARUS;BY
BELGIUM;BE
BELIZE;BZ
BENIN;BJ
BERMUDA;BM
BHUTAN;BT
BOLIVIA;BO
BOSNIA AND HERZEGOVINA;BA
BOTSWANA;BW
BOUVET ISLAND;BV
BRAZIL;BR
BRITISH INDIAN OCEAN TERRITORY;IO
BRUNEI DARUSSALAM;BN
BULGARIA;BG
BURKINA FASO;BF
BURUNDI;BI
CAMBODIA;KH
CAMEROON;CM
CANADA;CA
CAPE VERDE;CV
CAYMAN ISLANDS;KY
CENTRAL AFRICAN REPUBLIC;CF
CHAD;TD
CHILE;CL
CHINA;CN
CHRISTMAS ISLAND;CX
COCOS (KEELING) ISLANDS;CC
COLOMBIA;CO
COMOROS;KM
CONGO;CG
CONGO, THE DEMOCRATIC REPUBLIC OF THE;CD
COOK ISLANDS;CK
COSTA RICA;CR
CÔTE D'IVOIRE;CI
CROATIA;HR
CUBA;CU
CYPRUS;CY
CZECH REPUBLIC;CZ
DENMARK;DK
DJIBOUTI;DJ
DOMINICA;DM
DOMINICAN REPUBLIC;DO
ECUADOR;EC
EGYPT;EG
EL SALVADOR;SV
EQUATORIAL GUINEA;GQ
ERITREA;ER
ESTONIA;EE
ETHIOPIA;ET
FALKLAND ISLANDS (MALVINAS);FK
FAROE ISLANDS;FO
FIJI;FJ
FINLAND;FI
FRANCE;FR
FRENCH GUIANA;GF
FRENCH POLYNESIA;PF
FRENCH SOUTHERN TERRITORIES;TF
GABON;GA
GAMBIA;GM
GEORGIA;GE
GERMANY;DE
GHANA;GH
GIBRALTAR;GI
GREECE;GR
GREENLAND;GL
GRENADA;GD
GUADELOUPE;GP
GUAM;GU
GUATEMALA;GT
GUERNSEY;GG
GUINEA;GN
GUINEA-BISSAU;GW
GUYANA;GY
HAITI;HT
HEARD ISLAND AND MCDONALD ISLANDS;HM
HOLY SEE (VATICAN CITY STATE);VA
HONDURAS;HN
HONG KONG;HK
HUNGARY;HU
ICELAND;IS
INDIA;IN
INDONESIA;ID
IRAN, ISLAMIC REPUBLIC OF;IR
IRAQ;IQ
IRELAND;IE
ISLE OF MAN;IM
ISRAEL;IL
ITALY;IT
JAMAICA;JM
JAPAN;JP
JERSEY;JE
JORDAN;JO
KAZAKHSTAN;KZ
KENYA;KE
KIRIBATI;KI
KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF;KP
KOREA, REPUBLIC OF;KR
KUWAIT;KW
KYRGYZSTAN;KG
LAO PEOPLE'S DEMOCRATIC REPUBLIC;LA
LATVIA;LV
LEBANON;LB
LESOTHO;LS
LIBERIA;LR
LIBYAN ARAB JAMAHIRIYA;LY
LIECHTENSTEIN;LI
LITHUANIA;LT
LUXEMBOURG;LU
MACAO;MO
MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF;MK
MADAGASCAR;MG
MALAWI;MW
MALAYSIA;MY
MALDIVES;MV
MALI;ML
MALTA;MT
MARSHALL ISLANDS;MH
MARTINIQUE;MQ
MAURITANIA;MR
MAURITIUS;MU
MAYOTTE;YT
MEXICO;MX
MICRONESIA, FEDERATED STATES OF;FM
MOLDOVA, REPUBLIC OF;MD
MONACO;MC
MONGOLIA;MN
MONTENEGRO;ME
MONTSERRAT;MS
MOROCCO;MA
MOZAMBIQUE;MZ
MYANMAR;MM
NAMIBIA;NA
NAURU;NR
NEPAL;NP
NETHERLANDS;NL
NETHERLANDS ANTILLES;AN
NEW CALEDONIA;NC
NEW ZEALAND;NZ
NICARAGUA;NI
NIGER;NE
NIGERIA;NG
NIUE;NU
NORFOLK ISLAND;NF
NORTHERN MARIANA ISLANDS;MP
NORWAY;NO
OMAN;OM
PAKISTAN;PK
PALAU;PW
PALESTINIAN TERRITORY, OCCUPIED;PS
PANAMA;PA
PAPUA NEW GUINEA;PG
PARAGUAY;PY
PERU;PE
PHILIPPINES;PH
PITCAIRN;PN
POLAND;PL
PORTUGAL;PT
PUERTO RICO;PR
QATAR;QA
REUNION;RE
ROMANIA;RO
RUSSIAN FEDERATION;RU
RWANDA;RW
SAINT BARTHÉLEMY;BL
SAINT HELENA;SH
SAINT KITTS AND NEVIS;KN
SAINT LUCIA;LC
SAINT MARTIN;MF
SAINT PIERRE AND MIQUELON;PM
SAINT VINCENT AND THE GRENADINES;VC
SAMOA;WS
SAN MARINO;SM
SAO TOME AND PRINCIPE;ST
SAUDI ARABIA;SA
SENEGAL;SN
SERBIA;RS
SEYCHELLES;SC
SIERRA LEONE;SL
SINGAPORE;SG
SLOVAKIA;SK
SLOVENIA;SI
SOLOMON ISLANDS;SB
SOMALIA;SO
SOUTH AFRICA;ZA
SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS;GS
SPAIN;ES
SRI LANKA;LK
SUDAN;SD
SURINAME;SR
SVALBARD AND JAN MAYEN;SJ
SWAZILAND;SZ
SWEDEN;SE
SWITZERLAND;CH
SYRIAN ARAB REPUBLIC;SY
TAIWAN, PROVINCE OF CHINA;TW
TAJIKISTAN;TJ
TANZANIA, UNITED REPUBLIC OF;TZ
THAILAND;TH
TIMOR-LESTE;TL
TOGO;TG
TOKELAU;TK
TONGA;TO
TRINIDAD AND TOBAGO;TT
TUNISIA;TN
TURKEY;TR
TURKMENISTAN;TM
TURKS AND CAICOS ISLANDS;TC
TUVALU;TV
UGANDA;UG
UKRAINE;UA
UNITED ARAB EMIRATES;AE
UNITED KINGDOM;GB
UNITED STATES;US
UNITED STATES MINOR OUTLYING ISLANDS;UM
URUGUAY;UY
UZBEKISTAN;UZ
VANUATU;VU
VENEZUELA;VE
VIET NAM;VN
VIRGIN ISLANDS, BRITISH;VG
VIRGIN ISLANDS, U.S.;VI
WALLIS AND FUTUNA;WF
WESTERN SAHARA;EH
YEMEN;YE
ZAMBIA;ZM
ZIMBABWE;ZW