Welcome to mirror list, hosted at ThFree Co, Russian Federation.

XHtmlSelect.php « xhtml « src - github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 33da85ae1c7626601661ce97e990f5be014832c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php

/**
 * PHPPgAdmin v6.0.0-RC4
 */

namespace PHPPgAdmin\XHtml;

/**
 * Class to render select elements.
 */
class XHtmlSelect extends XHtmlElement
{
    public $_data;

    public function __construct($name, $multiple = false, $size = null)
    {
        parent::__construct();

        $this->set_attribute('name', $name);
        if ($multiple) {
            $this->set_attribute('multiple', 'multiple');
        }

        if ($size) {
            $this->set_attribute('size', $size);
        }
    }

    public function set_data(&$data, $delim = ',')
    {
        switch (gettype($data)) {
            case 'string':
                $this->_data = explode($delim, $data);

                break;
            case 'array':
                $this->_data = $data;

                break;
            default:
                break;
        }
    }

    public function fetch()
    {
        if (isset($this->_data) && $this->_data) {
            foreach ($this->_data as $value) {
                $this->add(new XHtmlOption($value));
            }
        }

        return parent::fetch();
    }
}