1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xoops\Form;
13:
14: /**
15: * SelectCountry - a select field with countries
16: *
17: * @category Xoops\Form\SelectCountry
18: * @package Xoops\Form
19: * @author Kazumi Ono <onokazu@xoops.org>
20: * @copyright 2001-2015 XOOPS Project (http://xoops.org)
21: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
22: * @link http://xoops.org
23: */
24: class SelectCountry extends Select
25: {
26: /**
27: * Constructor
28: *
29: * @param string|array $caption Caption or array of all attributes
30: * @param string $name "name" attribute
31: * @param mixed $value Pre-selected value (or array of them).
32: * Legal are all 2-letter country codes (in capitals).
33: * @param int $size Number or rows. "1" makes a drop-down-list
34: */
35: public function __construct($caption, $name = null, $value = null, $size = 1)
36: {
37: if (is_array($caption)) {
38: parent::__construct($caption);
39: $this->setIfNotSet('size', 1);
40: } else {
41: parent::__construct($caption, $name, $value, $size);
42: $this->setWithDefaults('caption', $caption, '');
43: $this->setWithDefaults('name', $name, 'name_error');
44: $this->set('value', $value);
45: $this->setWithDefaults('size', $size, 1);
46: }
47: \Xoops\Core\Lists\Country::setOptionsArray($this);
48: }
49: }
50: