cvs: pear /HTML_Select_Common/Select/Common Country.php FRDepartements.php UKCounty.php USState.php

From: Date: Sat, 18 Jan 2003 13:37:58 +0000
Subject: cvs: pear /HTML_Select_Common/Select/Common Country.php FRDepartements.php UKCounty.php USState.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8363@lists.php.net to get a copy of this message
richard Sat Jan 18 08:37:58 2003 EDT Added files: /pear/HTML_Select_Common/Select/Common Country.php FRDepartements.php UKCounty.php USState.php Log: Added for new structure

Index: pear/HTML_Select_Common/Select/Common/Country.php +++ pear/HTML_Select_Common/Select/Common/Country.php <?php // +-----------------------------------------------------------------------+ // | Copyright (c) 2002 Richard Heyes | // | All rights reserved. | // | | // | Redistribution and use in source and binary forms, with or without | // | modification, are permitted provided that the following conditions | // | are met: | // | | // | o Redistributions of source code must retain the above copyright | // | notice, this list of conditions and the following disclaimer. | // | o 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.| // | o 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. | // | | // +-----------------------------------------------------------------------+ // | Author: Richard Heyes <richard@php.net> | // +-----------------------------------------------------------------------+ // // $Id: Country.php,v 1.1 2003/01/18 13:37:58 richard Exp $ /** * Class to produce a HTML Select dropdown of countries * * @author Richard Heyes <richard@php.net> * @access public * @version 1.0 * @package HTML_Select */ require_once('I18N/Country.php'); class HTML_Select_Common_Country extends I18N_Country { /** * Produces the HTML for the dropdown. * * @param string $name The name="" attribute * @param string $selectedOption The option to be selected by default. * Must match the country code. * @param string $promoText The text to appear as the first option * @param string $extraAttributes Any extra attributes for the <select> tag * @return string The HTML for the <select> * @access public */ function toHTML($name, $selectedOption = null, $promoText = 'Select a country...', $extraAttributes = '') { $options[] = sprintf('<option value="">%s</option>', $promoText); $selectedOption = strtolower($selectedOption); foreach ($this->_codes as $code => $country) { $code = strtolower($code); $selected = $selectedOption == $code ? ' selected="selected"' : ''; $options[] = '<option value="' . $code . '"' . $selected . '>' . ucfirst(strtolower($country)) . '</option>'; } return sprintf('<select name="%s" %s>%s</select>', $name, $extraAttributes, implode("\r\n", $options)); } } ?> Index: pear/HTML_Select_Common/Select/Common/FRDepartements.php +++ pear/HTML_Select_Common/Select/Common/FRDepartements.php <?php // +-----------------------------------------------------------------------+ // | Copyright (c) 2002 Richard Heyes | // | All rights reserved. | // | | // | Redistribution and use in source and binary forms, with or without | // | modification, are permitted provided that the following conditions | // | are met: | // | | // | o Redistributions of source code must retain the above copyright | // | notice, this list of conditions and the following disclaimer. | // | o 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.| // | o 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. | // | | // +-----------------------------------------------------------------------+ // | Author: Richard Heyes <richard@php.net> | // | Eric De Sousa <esc.z@wanadoo.fr> | // +-----------------------------------------------------------------------+ // // $Id: FRDepartements.php,v 1.1 2003/01/18 13:37:58 richard Exp $ /** * Class to produce a HTML Select dropdown of FR Departements * * @author Richard Heyes <richard@php.net> * @author Eric De Sousa <esc.z@wanadoo.fr> * @access public * @version 1.0 * @package HTML_Select */ class HTML_Select_Common_FRDepartements { /** * Constructor * * @access public */ function HTML_Select_Common_FRDepartements() { $this->_departements['01'] = 'Ain'; $this->_departements['02'] = 'Aisne'; $this->_departements['03'] = 'Allier'; $this->_departements['04'] = 'Alpes de-Htes Provence'; $this->_departements['05'] = 'Hautes-Alpes'; $this->_departements['06'] = 'Alpes-Maritimes'; $this->_departements['07'] = 'Ardèche'; $this->_departements['08'] = 'Ardennes'; $this->_departements['09'] = 'Ariège'; $this->_departements['10'] = 'Aube'; $this->_departements['11'] = 'Aude'; $this->_departements['12'] = 'Aveyron'; $this->_departements['13'] = 'Bouches-du-Rhône'; $this->_departements['14'] = 'Calvados'; $this->_departements['15'] = 'Cantal'; $this->_departements['16'] = 'Charente'; $this->_departements['17'] = 'Charente-Maritime'; $this->_departements['18'] = 'Cher'; $this->_departements['19'] = 'Corrèze'; $this->_departements['21'] = 'Côte d\'Or'; $this->_departements['22'] = 'Côtes d\'Armor'; $this->_departements['23'] = 'Creuse'; $this->_departements['24'] = 'Dordogne'; $this->_departements['25'] = 'Doubs'; $this->_departements['26'] = 'Drôme'; $this->_departements['27'] = 'Eure'; $this->_departements['28'] = 'Eure-et-Loir'; $this->_departements['29'] = 'Finistère'; $this->_departements['2A'] = 'Corse du Sud'; $this->_departements['2B'] = 'Hautes-Corse'; $this->_departements['30'] = 'Gard'; $this->_departements['31'] = 'Hautes-Garonne'; $this->_departements['32'] = 'Gers'; $this->_departements['33'] = 'Gironde'; $this->_departements['34'] = 'Hérault'; $this->_departements['35'] = 'Ille-et-Vilaine'; $this->_departements['36'] = 'Indre'; $this->_departements['37'] = 'Indre-et-Loire'; $this->_departements['38'] = 'Isère'; $this->_departements['39'] = 'Jura'; $this->_departements['40'] = 'Landes'; $this->_departements['41'] = 'Loir-et-Cher'; $this->_departements['42'] = 'Loire'; $this->_departements['43'] = 'Hautes-Loire'; $this->_departements['44'] = 'Loire-Atlantique'; $this->_departements['45'] = 'Loiret'; $this->_departements['46'] = 'Lot'; $this->_departements['47'] = 'Lot-et-Garonne'; $this->_departements['48'] = 'Lozère'; $this->_departements['49'] = 'Maine-et-Loire'; $this->_departements['50'] = 'Manche'; $this->_departements['51'] = 'Marne'; $this->_departements['52'] = 'Haute-Marne'; $this->_departements['53'] = 'Mayenne'; $this->_departements['54'] = 'Meurthe-et-Moselle'; $this->_departements['55'] = 'Meuse'; $this->_departements['56'] = 'Morbihan'; $this->_departements['57'] = 'Moselle'; $this->_departements['58'] = 'Nièvre'; $this->_departements['59'] = 'Nord'; $this->_departements['60'] = 'Oise'; $this->_departements['61'] = 'Orne'; $this->_departements['62'] = 'Pas-de-Calais'; $this->_departements['63'] = 'Puy-de-Dôme'; $this->_departements['64'] = 'Pyrénées-Atlantiques'; $this->_departements['65'] = 'Hautes-Pyrénées'; $this->_departements['66'] = 'Pyrénées'; $this->_departements['67'] = 'Bas-Rhin'; $this->_departements['68'] = 'Haut-Rhin'; $this->_departements['69'] = 'Rhône'; $this->_departements['70'] = 'Hautes-Saône'; $this->_departements['71'] = 'Saône-et-Loire'; $this->_departements['72'] = 'Sarthe'; $this->_departements['73'] = 'Savoie'; $this->_departements['74'] = 'Hautes-Savoie'; $this->_departements['75'] = 'Paris'; $this->_departements['76'] = 'Seine-Maritime'; $this->_departements['77'] = 'Sein-et-Marne'; $this->_departements['78'] = 'Yvelines'; $this->_departements['79'] = 'Deux-Sèvres'; $this->_departements['80'] = 'Somme'; $this->_departements['81'] = 'Tarn'; $this->_departements['82'] = 'Tarn-et-Garonne'; $this->_departements['83'] = 'Var'; $this->_departements['84'] = 'Vaucluse'; $this->_departements['85'] = 'Vendée'; $this->_departements['86'] = 'Vienne'; $this->_departements['87'] = 'Hautes-Vienne'; $this->_departements['88'] = 'Vosges'; $this->_departements['89'] = 'Yonne'; $this->_departements['90'] = 'Territoire de Belfort'; $this->_departements['91'] = 'Essonne'; $this->_departements['92'] = 'Hauts-de-Seine'; $this->_departements['93'] = 'Seine-St-Denis'; $this->_departements['94'] = 'Val de Marne'; $this->_departements['95'] = 'Val d\'Oise'; $this->_departements['971'] = 'Guadeloupe'; $this->_departements['972'] = 'Martinique'; $this->_departements['973'] = 'Guyane'; $this->_departements['974'] = 'Réunion'; } /** * Produces the HTML for the dropdown * * @param string $name The name="" attribute * @param string $selectedOption The option to be selected by default. * Must match the departement name exactly, * OR departement code * (though it can be a different case). * @param string $promoText The text to appear as the first option * @param string $extraAttributes Any extra attributes for the <select> tag * @return string The HTML for the <select> * @access public */ function toHTML($name, $selectedOption = null, $promoText = 'Selectionnez un departement...', $extraAttributes = '') { $options[] = sprintf('<option value="">%s</option>', $promoText); $selectedOption = strtolower($selectedOption); foreach ($this->_departements as $code => $departement) { $code = strtolower($code); //$departements_lc = explode(' - ',$departements_ld); $selected = ( $selectedOption == $code || $selectedOption == strtolower($departement) ) ? ' selected="selected" ' : ''; $options[] = '<option value="' . $code . '"' . $selected . '>' . $code . ' - ' . $departement . '</option>'; } return sprintf('<select name="%s" %s>%s</select>', $name, $extraAttributes, implode("\r\n", $options)); } } ?> Index: pear/HTML_Select_Common/Select/Common/UKCounty.php +++ pear/HTML_Select_Common/Select/Common/UKCounty.php <?php // +-----------------------------------------------------------------------+ // | Copyright (c) 2002 Richard Heyes | // | All rights reserved. | // | | // | Redistribution and use in source and binary forms, with or without | // | modification, are permitted provided that the following conditions | // | are met: | // | | // | o Redistributions of source code must retain the above copyright | // | notice, this list of conditions and the following disclaimer. | // | o 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.| // | o 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. | // | | // +-----------------------------------------------------------------------+ // | Author: Richard Heyes <richard@php.net> | // +-----------------------------------------------------------------------+ // // $Id: UKCounty.php,v 1.1 2003/01/18 13:37:58 richard Exp $ /** * Class to produce a HTML Select dropdown of UK Counties * Probably not an entirely accurate list and no doubt contains * some fluff. However it did come from Post Office data. * * @author Richard Heyes <richard@php.net> * @access public * @version 1.0 * @package HTML_Select */ class HTML_Select_Common_UKCounty { /** * Constructor * * @access public */ function HTML_Select_Common_UKCounty() { $this->_counties[] = 'Aberdeenshire'; $this->_counties[] = 'Angus'; $this->_counties[] = 'Argyll'; $this->_counties[] = 'Avon'; $this->_counties[] = 'Ayrshire'; $this->_counties[] = 'Banffshire'; $this->_counties[] = 'Bedfordshire'; $this->_counties[] = 'Berkshire'; $this->_counties[] = 'Berwickshire'; $this->_counties[] = 'Buckinghamshire'; $this->_counties[] = 'Caithness'; $this->_counties[] = 'Cambridgeshire'; $this->_counties[] = 'Cheshire'; $this->_counties[] = 'Clackmannanshire'; $this->_counties[] = 'Cleveland'; $this->_counties[] = 'Clwyd'; $this->_counties[] = 'Cornwall'; $this->_counties[] = 'county'; $this->_counties[] = 'County Antrim'; $this->_counties[] = 'County Armagh'; $this->_counties[] = 'County Down'; $this->_counties[] = 'County Durham'; $this->_counties[] = 'County Fermanagh'; $this->_counties[] = 'County Londonderry'; $this->_counties[] = 'County Tyrone'; $this->_counties[] = 'Cumbria'; $this->_counties[] = 'Derbyshire'; $this->_counties[] = 'Devon'; $this->_counties[] = 'Dorset'; $this->_counties[] = 'Dumfriesshire'; $this->_counties[] = 'Dunbartonshire'; $this->_counties[] = 'Dyfed'; $this->_counties[] = 'East Lothian'; $this->_counties[] = 'East Sussex'; $this->_counties[] = 'Essex'; $this->_counties[] = 'Fife'; $this->_counties[] = 'Gloucestershire'; $this->_counties[] = 'Gwent'; $this->_counties[] = 'Gwynedd'; $this->_counties[] = 'Hampshire'; $this->_counties[] = 'Herefordshire'; $this->_counties[] = 'Hertfordshire'; $this->_counties[] = 'Inverness-shire'; $this->_counties[] = 'Isle of Arran'; $this->_counties[] = 'Isle of Barra'; $this->_counties[] = 'Isle of Bute'; $this->_counties[] = 'Isle of Canna'; $this->_counties[] = 'Isle of Coll'; $this->_counties[] = 'Isle of Colonsay'; $this->_counties[] = 'Isle of Cumbrae'; $this->_counties[] = 'Isle of Eigg'; $this->_counties[] = 'Isle of Gigha'; $this->_counties[] = 'Isle of Harris'; $this->_counties[] = 'Isle of Iona'; $this->_counties[] = 'Isle of Islay'; $this->_counties[] = 'Isle of Jura'; $this->_counties[] = 'Isle of Lewis'; $this->_counties[] = 'Isle of Mull'; $this->_counties[] = 'Isle of North Uist'; $this->_counties[] = 'Isle of Orkney'; $this->_counties[] = 'Isle of Rhum'; $this->_counties[] = 'Isle of Skye'; $this->_counties[] = 'Isle of South Uist'; $this->_counties[] = 'Isle of Tiree'; $this->_counties[] = 'Isle of Wight'; $this->_counties[] = 'Isles of Scilly'; $this->_counties[] = 'Kent'; $this->_counties[] = 'Kincardineshire'; $this->_counties[] = 'Kirkcudbrightshire'; $this->_counties[] = 'Lanarkshire'; $this->_counties[] = 'Lancashire'; $this->_counties[] = 'Leicestershire'; $this->_counties[] = 'Lincolnshire'; $this->_counties[] = 'Merseyside'; $this->_counties[] = 'Middlesex'; $this->_counties[] = 'Mid Glamorgan'; $this->_counties[] = 'Midlothian'; $this->_counties[] = 'Morayshire'; $this->_counties[] = 'Norfolk'; $this->_counties[] = 'Northamptonshire'; $this->_counties[] = 'North Humberside'; $this->_counties[] = 'Northumberland'; $this->_counties[] = 'North Yorkshire'; $this->_counties[] = 'Nottinghamshire'; $this->_counties[] = 'Orkney'; $this->_counties[] = 'Oxfordshire'; $this->_counties[] = 'Peeblesshire'; $this->_counties[] = 'Perthshire'; $this->_counties[] = 'Powys'; $this->_counties[] = 'Renfrewshire'; $this->_counties[] = 'Ross-shire'; $this->_counties[] = 'Roxburghshire'; $this->_counties[] = 'Selkirkshire'; $this->_counties[] = 'Shetland Islands'; $this->_counties[] = 'Shropshire'; $this->_counties[] = 'Somerset'; $this->_counties[] = 'South Glamorgan'; $this->_counties[] = 'South Humberside'; $this->_counties[] = 'South Yorkshire'; $this->_counties[] = 'Staffordshire'; $this->_counties[] = 'Stirlingshire'; $this->_counties[] = 'Suffolk'; $this->_counties[] = 'Surrey'; $this->_counties[] = 'Sutherland'; $this->_counties[] = 'Tyne and Wear'; $this->_counties[] = 'Warwickshire'; $this->_counties[] = 'West Glamorgan'; $this->_counties[] = 'West Lothian'; $this->_counties[] = 'West Midlands'; $this->_counties[] = 'West Sussex'; $this->_counties[] = 'West Yorkshire'; $this->_counties[] = 'Wigtownshire'; $this->_counties[] = 'Wilts'; $this->_counties[] = 'Wiltshire'; $this->_counties[] = 'Worcestershire'; } /** * Produces the HTML for the dropdown * * @param string $name The name="" attribute * @param string $selectedOption The option to be selected by default. * Must match the county name exactly, * (though it can be a different case). * @param string $promoText The text to appear as the first option * @param string $extraAttributes Any extra attributes for the <select> tag * @return string The HTML for the <select> * @access public */ function toHTML($name, $selectedOption = null, $promoText = 'Select a county...', $extraAttributes = '') { $options[] = sprintf('<option value="">%s</option>', $promoText); $selectedOption = strtolower($selectedOption); foreach ($this->_counties as $county) { $county_lc = strtolower($county); $selected = $selectedOption == $county_lc ? ' selected="selected"' : ''; $options[] = '<option value="' . $county_lc . '"' . $selected . '>' . ucfirst($county) . '</option>'; } return sprintf('<select name="%s" %s>%s</select>', $name, $extraAttributes, implode("\r\n", $options)); } } ?> Index: pear/HTML_Select_Common/Select/Common/USState.php +++ pear/HTML_Select_Common/Select/Common/USState.php <?php // +-----------------------------------------------------------------------+ // | Copyright (c) 2002 Richard Heyes | // | All rights reserved. | // | | // | Redistribution and use in source and binary forms, with or without | // | modification, are permitted provided that the following conditions | // | are met: | // | | // | o Redistributions of source code must retain the above copyright | // | notice, this list of conditions and the following disclaimer. | // | o 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.| // | o 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. | // | | // +-----------------------------------------------------------------------+ // | Author: Richard Heyes <richard@php.net> | // +-----------------------------------------------------------------------+ // // $Id: USState.php,v 1.1 2003/01/18 13:37:58 richard Exp $ /** * Class to produce a HTML Select dropdown of US States * * @author Richard Heyes <richard@php.net> * @access public * @version 1.0 * @package HTML_Select */ class HTML_Select_Common_USState { /** * Constructor * * @access public */ function HTML_Select_Common_USState() { $this->_states['ak'] = 'Alabama'; $this->_states['al'] = 'Alaska'; $this->_states['ar'] = 'Arizona'; $this->_states['az'] = 'Arkansas'; $this->_states['ca'] = 'California'; $this->_states['co'] = 'Colorado'; $this->_states['ct'] = 'Connecticut'; $this->_states['de'] = 'Delaware'; $this->_states['dc'] = 'District of Columbia'; $this->_states['fl'] = 'Florida'; $this->_states['ga'] = 'Georgia'; $this->_states['hi'] = 'Hawaii'; $this->_states['id'] = 'Idaho'; $this->_states['il'] = 'Illinois'; $this->_states['in'] = 'Indiana'; $this->_states['ia'] = 'Iowa'; $this->_states['ks'] = 'Kansas'; $this->_states['ky'] = 'Kentucky'; $this->_states['la'] = 'Louisiana'; $this->_states['ma'] = 'Maine'; $this->_states['md'] = 'Maryland'; $this->_states['ma'] = 'Massachusetts'; $this->_states['mi'] = 'Michigan'; $this->_states['mn'] = 'Minnesota'; $this->_states['ms'] = 'Mississippi'; $this->_states['mo'] = 'Missouri'; $this->_states['mt'] = 'Montana'; $this->_states['ne'] = 'Nebraska'; $this->_states['nv'] = 'Nevada'; $this->_states['ne'] = 'New England'; $this->_states['nh'] = 'New Hampshire'; $this->_states['nj'] = 'New Jersey'; $this->_states['nm'] = 'New Mexico'; $this->_states['ny'] = 'New York'; $this->_states['nc'] = 'North Carolina'; $this->_states['nd'] = 'North Dakota'; $this->_states['oh'] = 'Ohio'; $this->_states['ok'] = 'Oklahoma'; $this->_states['or'] = 'Oregon'; $this->_states['pa'] = 'Pennsylvania'; $this->_states['ri'] = 'Rhode Island'; $this->_states['sc'] = 'South Carolina'; $this->_states['sd'] = 'South Dakota'; $this->_states['tn'] = 'Tennessee'; $this->_states['tx'] = 'Texas'; $this->_states['ut'] = 'Utah'; $this->_states['vt'] = 'Vermont'; $this->_states['va'] = 'Virginia'; $this->_states['wa'] = 'Washington'; $this->_states['wv'] = 'West Virginia'; $this->_states['wi'] = 'Wisconsin'; $this->_states['wy'] = 'Wyoming'; } /** * Produces the HTML for the dropdown * * @param string $name The name="" attribute * @param string $selectedOption The option to be selected by default. * Must match the state name exactly, * (though it can be a different case). * @param string $promoText The text to appear as the first option * @param string $extraAttributes Any extra attributes for the <select> tag * @return string The HTML for the <select> * @access public */ function toHTML($name, $selectedOption = null, $promoText = 'Select a state...', $extraAttributes = '') { $options[] = sprintf('<option value="">%s</option>', $promoText); $selectedOption = strtolower($selectedOption); foreach ($this->_states as $state) { $state_lc = strtolower($state); $selected = $selectedOption == $state_lc ? ' selected="selected"' : ''; $options[] = '<option value="' . $state_lc . '"' . $selected . '>' . ucfirst($state) . '</option>'; } return sprintf('<select name="%s" %s>%s</select>', $name, $extraAttributes, implode("\r\n", $options)); } /** * Returns an array with all states, indexed by shortcut * * @return array The array containing all state data * @access public */ function getList() { return $this->_states; } } ?>
« previous php.pear.cvs (#8363) next »