2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * hold the PMA_List base class
8 if (! defined('PHPMYADMIN')) {
18 * @since phpMyAdmin 2.9.10
20 abstract class PMA_List
extends ArrayObject
23 * @var mixed empty item
25 protected $item_empty = '';
28 * PMA_List constructor
30 * @param array $array The input parameter accepts an array or an
32 * @param int $flags Flags to control the behaviour of the
34 * @param string $iterator_class Specify the class that will be used for
35 * iteration of the ArrayObject object.
36 * ArrayIterator is the default class used.
38 public function __construct(
39 $array = array(), $flags = 0, $iterator_class = "ArrayIterator"
41 parent
::__construct($array, $flags, $iterator_class);
45 * defines what is an empty item (0, '', false or null)
47 * @return mixed an empty item
49 public function getEmpty()
51 return $this->item_empty
;
55 * checks if the given db names exists in the current list, if there is
56 * missing at least one item it returns false otherwise true
58 * @return boolean true if all items exists, otherwise false
60 public function exists()
62 $this_elements = $this->getArrayCopy();
63 foreach (func_get_args() as $result) {
64 if (! in_array($result, $this_elements)) {
73 * returns HTML <option>-tags to be used inside <select></select>
75 * @param mixed $selected the selected db or true for
76 * selecting current db
77 * @param boolean $include_information_schema whether include information schema
79 * @return string HTML option tags
81 public function getHtmlOptions(
82 $selected = '', $include_information_schema = true
84 if (true === $selected) {
85 $selected = $this->getDefault();
89 foreach ($this as $each_item) {
90 if (false === $include_information_schema
91 && $GLOBALS['dbi']->isSystemSchema($each_item)
95 $options .= '<option value="' . htmlspecialchars($each_item) . '"';
96 if ($selected === $each_item) {
97 $options .= ' selected="selected"';
99 $options .= '>' . htmlspecialchars($each_item) . '</option>' . "\n";
106 * returns default item
108 * @return string default item
110 public function getDefault()
112 return $this->getEmpty();
120 abstract public function build();