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 = '';
27 public function __construct(
28 $array = array(), $flags = 0, $iterator_class = "ArrayIterator"
30 parent
::__construct($array, $flags, $iterator_class);
34 * returns item only if there is only one in the list
38 public function getSingleItem()
40 if (count($this) === 1) {
44 return $this->getEmpty();
48 * defines what is an empty item (0, '', false or null)
50 * @return mixed an empty item
52 public function getEmpty()
54 return $this->item_empty
;
58 * checks if the given db names exists in the current list, if there is
59 * missing at least one item it returns false otherwise true
61 * @return boolean true if all items exists, otheriwse false
63 public function exists()
65 $this_elements = $this->getArrayCopy();
66 foreach (func_get_args() as $result) {
67 if (! in_array($result, $this_elements)) {
76 * returns HTML <option>-tags to be used inside <select></select>
78 * @param mixed $selected the selected db or true for
79 * selecting current db
80 * @param boolean $include_information_schema whether include information schema
82 * @return string HTML option tags
84 public function getHtmlOptions(
85 $selected = '', $include_information_schema = true
87 if (true === $selected) {
88 $selected = $this->getDefault();
92 foreach ($this as $each_item) {
93 if (false === $include_information_schema
94 && $GLOBALS['dbi']->isSystemSchema($each_item)
98 $options .= '<option value="' . htmlspecialchars($each_item) . '"';
99 if ($selected === $each_item) {
100 $options .= ' selected="selected"';
102 $options .= '>' . htmlspecialchars($each_item) . '</option>' . "\n";
109 * returns default item
111 * @return string default item
113 public function getDefault()
115 return $this->getEmpty();
123 abstract public function build();