2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * hold the PMA_List base class
11 * @since phpMyAdmin 2.9.10
15 abstract class PMA_List
extends ArrayObject
18 * @var mixed empty item
20 protected $item_empty = '';
22 public function __construct($array = array(), $flags = 0, $iterator_class = "ArrayIterator")
24 parent
::__construct($array, $flags, $iterator_class);
28 * returns item only if there is only one in the list
32 public function getSingleItem()
34 if (count($this) === 1) {
38 return $this->getEmpty();
42 * defines what is an empty item (0, '', false or null)
44 * @return mixed an empty item
46 public function getEmpty()
48 return $this->item_empty
;
52 * checks if the given db names exists in the current list, if there is
53 * missing at least one item it returns false otherwise true
55 * @param string $db_name,.. one or more mysql result resources
56 * @return boolean true if all items exists, otheriwse false
58 public function exists()
60 $this_elements = $this->getArrayCopy();
61 foreach (func_get_args() as $result) {
62 if (! in_array($result, $this_elements)) {
71 * returns HTML <option>-tags to be used inside <select></select>
73 * @param mixed $selected the selected db or true for selecting current db
74 * @param boolean $include_information_schema
75 * @return string HTML option tags
77 public function getHtmlOptions($selected = '', $include_information_schema = true)
79 if (true === $selected) {
80 $selected = $this->getDefault();
84 foreach ($this as $each_item) {
85 if (false === $include_information_schema
86 && PMA_is_system_schema($each_item)) {
89 $options .= '<option value="' . htmlspecialchars($each_item) . '"';
90 if ($selected === $each_item) {
91 $options .= ' selected="selected"';
93 $options .= '>' . htmlspecialchars($each_item) . '</option>' . "\n";
100 * returns default item
102 * @return string default item
104 public function getDefault()
106 return $this->getEmpty();
113 abstract public function build();