Passed
Push — master ( 37a2f2...290aa0 )
by Michael
02:35
created

FormSelectCountry::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 4
nop 5
dl 0
loc 12
rs 9.9666
c 0
b 0
f 0
1
<?php namespace XoopsModules\Xfguestbook\Form;
2
3
//
4
//  ------------------------------------------------------------------------ //
5
//             XF Guestbook                                                  //
6
// ------------------------------------------------------------------------- //
7
//  This program is free software; you can redistribute it and/or modify     //
8
//  it under the terms of the GNU General Public License as published by     //
9
//  the Free Software Foundation; either version 2 of the License, or        //
10
//  (at your option) any later version.                                      //
11
//                                                                           //
12
//  You may not change or alter any portion of this comment or credits       //
13
//  of supporting developers from this source code or any supporting         //
14
//  source code which is considered copyrighted (c) material of the          //
15
//  original comment or credit authors.                                      //
16
//                                                                           //
17
//  This program is distributed in the hope that it will be useful,          //
18
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
19
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
20
//  GNU General Public License for more details.                             //
21
//                                                                           //
22
//  You should have received a copy of the GNU General Public License        //
23
//  along with this program; if not, write to the Free Software              //
24
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
25
//  ------------------------------------------------------------------------ //
26
27
require_once dirname(dirname(dirname(dirname(__DIR__)))) . '/class/xoopsform/formselect.php';
28
29
/**
30
 * Class FormSelectCountry
31
 */
32
class FormSelectCountry extends \XoopsFormSelect
33
{
34
    /**
35
     * FormSelectCountry constructor.
36
     * @param      $caption
37
     * @param      $name
38
     * @param null $value
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $value is correct as it would always require null to be passed?
Loading history...
39
     * @param int  $size
40
     * @param bool $nullopt
41
     */
42
    public function __construct($caption, $name, $value = null, $size = 1, $nullopt = false)
43
    {
44
        $db = \XoopsDatabaseFactory::getDatabaseConnection();
45
        parent::__construct($caption, $name, $value, $size);
46
        $sql    = 'SELECT country_code, country_name FROM ' . $db->prefix('xfguestbook_country') . ' ORDER BY country_name';
47
        $result = $db->query($sql);
48
        if ($nullopt) {
49
            $this->addOption('', '-');
50
        }
51
        $this->addOption('other', MI_XFGUESTBOOK_OTHER);
52
        while (false !== ($myrow = $db->fetchArray($result))) {
53
            $this->addOption($myrow['country_code'], $myrow['country_name']);
54
        }
55
    }
56
}
57