2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * hold the PMA_List base class
8 if (! defined('PHPMYADMIN')) {
16 * @since phpMyAdmin 2.9.10
18 abstract class PMA_List
extends ArrayObject
21 * @var mixed empty item
23 protected $item_empty = '';
25 public function __construct($array = array(), $flags = 0, $iterator_class = "ArrayIterator")
27 parent
::__construct($array, $flags, $iterator_class);
31 * returns item only if there is only one in the list
35 public function getSingleItem()
37 if (count($this) === 1) {
41 return $this->getEmpty();
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, otheriwse 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($selected = '', $include_information_schema = true)
83 if (true === $selected) {
84 $selected = $this->getDefault();
88 foreach ($this as $each_item) {
89 if (false === $include_information_schema
90 && PMA_is_system_schema($each_item)
94 $options .= '<option value="' . htmlspecialchars($each_item) . '"';
95 if ($selected === $each_item) {
96 $options .= ' selected="selected"';
98 $options .= '>' . htmlspecialchars($each_item) . '</option>' . "\n";
105 * returns default item
107 * @return string default item
109 public function getDefault()
111 return $this->getEmpty();
119 abstract public function build();