[Phphtmllib-devel] phphtmllib/form/form_elements FEListBox.inc,1.14,1.15
Status: Beta
Brought to you by:
hemna
From: <cu...@us...> - 2004-03-12 14:54:43
|
Update of /cvsroot/phphtmllib/phphtmllib/form/form_elements In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28509/form/form_elements Modified Files: FEListBox.inc Log Message: Added set_element_order() and changed month generation to use the built in php setlocale() function. This is still not well tested. Index: FEListBox.inc =================================================================== RCS file: /cvsroot/phphtmllib/phphtmllib/form/form_elements/FEListBox.inc,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- FEListBox.inc 11 Mar 2004 06:01:14 -0000 1.14 +++ FEListBox.inc 12 Mar 2004 14:35:09 -0000 1.15 @@ -807,85 +807,21 @@ class FEMonths extends FEListBox { /** - * The months array divided up by language - * @var array - */ - var $_locale = array( - 'en' => array ( - 'short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), - 'long' => array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December') - ), - 'de' => array ( - 'short' => array ('Jan', 'Feb', 'März', 'April', 'Mai', 'Juni', 'Juli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dez'), - 'long' => array ('Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember') - ), - 'fr' => array ( - 'short' => array ('Jan', 'Fev', 'Mar', 'Avr', 'Mai', 'Jun', 'Jul', 'Aou', 'Sep', 'Oct', 'Nov', 'Dec'), - 'long' => array ('Janvier', 'Fevrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'Decembre') - ), - 'hu' => array ( - 'short' => array ('jan', 'feb', 'márc', 'ápr', 'máj', 'jún', 'júl', 'aug', 'szept', 'okt', 'nov', 'dec'), - 'long' => array ('január', 'február', 'március', 'április', 'május', 'június', 'július', 'augusztus', 'szeptember', 'október', 'november', 'december') - ), - 'pl' => array ( - 'short' => array ('Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Pa¼', 'Lis', 'Gru'), - 'long' => array ('Styczeñ', 'Luty', 'Marzec', 'Kwiecieñ', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpieñ', 'Wrzesieñ', 'Pa¼dziernik', 'Listopad', 'Grudzieñ') - ), - 'sl' => array ( - 'short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Avg', 'Sep', 'Okt', 'Nov', 'Dec'), - 'long' => array ('Januar', 'Februar', 'Marec', 'April', 'Maj', 'Junij', 'Julij', 'Avgust', 'September', 'Oktober', 'November', 'December') - ), - 'ru' => array ( - 'short' => array ('ßíâ', 'Ôåâ', 'Ìàð', 'Àïð', 'Ìàé', 'Èþí', 'Èþë', 'Àâã', 'Ñåí', 'Îêò', 'Íîÿ', 'Äåê'), - 'long' => array ('ßíâàðü', 'Ôåâðàëü', 'Ìàðò', 'Àïðåëü', 'Ìàé', 'Èþíü', 'Èþëü', 'Àâãóñò', 'Ñåíòÿáðü', 'Îêòÿáðü', 'Íîÿáðü', 'Äåêàáðü') - ), - 'es' => array ( - 'short' => array ('Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'), - 'long' => array ('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septimbre', 'Octubre', 'Noviembre', 'Diciembre') - ), - 'da' => array ( - 'short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'), - 'long' => array ('Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December') - ), - 'is' => array ( - 'short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maí', 'Jún', 'Júl', 'Ágú', 'Sep', 'Okt', 'Nóv', 'Des'), - 'long' => array ('Janúar', 'Febrúar', 'Mars', 'Apríl', 'Maí', 'Júní', 'Júlí', 'Ágúst', 'September', 'Október', 'Nóvember', 'Desember') - ), - 'it' => array ( - 'short' => array ('Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'), - 'long' => array ('Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre') - ), - 'sk' => array ( - 'short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Máj', 'Jún', 'Júl', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'), - 'long' => array ('Január', 'Február', 'Marec', 'Apríl', 'Máj', 'Jún', 'Júl', 'August', 'September', 'Október', 'November', 'December') - ), - 'cs' => array ( - 'short' => array ('Led', 'Úno', 'Bøe', 'Dub', 'Kvì', 'Èen', 'Èec', 'Srp', 'Záø', 'Øíj', 'Lis', 'Pro'), - 'long' => array ('Leden', 'Únor', 'Bøezen', 'Duben', 'Kvìten', 'Èerven', 'Èervenec', 'Srpen', 'Záøí', 'Øíjen', 'Listopad', 'Prosinec') - ), - 'hy' => array( - 'short' => array ('ÐÝí','öïñ','Øñï','²åñ','ØÛë','ÐÝë','ÐÉë','ú·ë','êåï','ÐÏï','ÜÛÙ','¸Ïï'), - 'long' => array ('ÐáõÝí³ñ','ö»ïñí³ñ','سñï','²åñÇÉ','سÛÇë','ÐáõÝÇë','ÐáõÉÇë','ú·áëïáë','ê»åï»Ùµ»ñ','ÐáÏï»Ùµ»ñ','ÜáÛ»Ùµ»ñ','¸»Ïï»Ùµ»ñ') - ), - 'nl' => array ( - 'short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'), - 'long' => array ('Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December') - ) - ); - - - /** * The constructor * * @param string text label for the element * @param boolean is this a required element? * @param int element width in characters, pixels (px), percentage (%) or elements (em) * @param int element height in px - * @param string locale one of: en, de, hu, pl, sl, ru, es, da, is, it, sk, cs, hy, nl * @param string format either long or short */ - function FEMonths($label, $required = TRUE, $width = NULL, $height = NULL, $locale = 'en', $format = 'long') { - $this->FEListBox($label, $required, $width, $height, array_flip($this->_locale[$locale][$format])); + function FEMonths($label, $required = TRUE, $width = NULL, $height = NULL, $format = 'long') { + + $format = (strcmp($format, 'long') == 0) ? '%B' : '%b'; + for ($i = 1; $i < 13; $i++) { + $months[] = strftime($format, strtotime("$i/12/2004")); + } + $this->FEListBox($label, $required, $width, $height, array_flip($months)); } } @@ -939,8 +875,8 @@ } /** - * This class builds a FEDataList that shows - * a select box listing the days of the month + * This class builds a FEDataList that shows a group of select boxes + * (FEYears, FEMonths, FEDays) representing a date. * * @author Culley Harrelson <cu...@fa...> * @@ -949,12 +885,6 @@ class FEDate extends FEBoxElement { /** - * The default locale for the month display - * @var string - */ - var $_locale = 'en'; - - /** * The month format. Default to the long format. * @var bool */ @@ -973,6 +903,14 @@ var $_max_year = 2010; /** + * The order in which to show the elements. This variable must be 3 + * characters long and contain only one m only one d and only one y. + * + * @var string + */ + var $_element_order = 'mdy'; + + /** * The constructor * * @param string text label for the element @@ -995,30 +933,32 @@ $month_format = ($this->_short_months) ? 'short' : 'long'; $container = new Container(); + $years = new FEYears($this->_element_name . '_years', false, null, null, $this->_min_year, $this->_max_year); - $months = new FEMonths($this->_element_name . '_months', false, null, null, $this->_locale, $month_format); + $months = new FEMonths($this->_element_name . '_months', false, null, null, $month_format); $days = new FEDays($this->_element_name . '_days'); - $container->add($months->get_element()); - $container->add($days->get_element()); - $container->add($years->get_element()); + // add the elements in the order specified. + $chars = preg_split('//', $this->_element_order, -1, PREG_SPLIT_NO_EMPTY); + foreach ($chars as $char) { + switch ($char) { + case 'y': + $container->add($years->get_element()); + break; + case 'm': + $container->add($months->get_element()); + break; + case 'd': + $container->add($days->get_element()); + break; + } + } return $container; } /** - * this method sets the locale for the Month display - * - * @param string locale - */ - function set_locale($locale = 'en') { - - $this->_locale = $locale; - - } - - /** * this method toggles the month display between short and long format * * @param bool @@ -1051,6 +991,32 @@ } + /** + * this method sets the display order for the elements in the widget + * + * @param string + * @return bool success or failure + */ + function set_element_order($element_order) { + + if (strlen($element_order) != 3) { + return false; + } + + // compare the characters sent with the characters needed. only set + // the property if one of each is present + $search_for = array ('y', 'm', 'd'); + $chars = preg_split('//', strtolower($element_order), -1, PREG_SPLIT_NO_EMPTY); + + if (count(array_diff($search_for, $chars)) > 0) { + return false; + } + + $this->_element_order = $element_order; + return true; + + } + } ?> |