From 34a7e9d555dc2009ef3d317961baf120b0ef5ec9 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Thu, 21 Sep 2006 12:49:01 +0000 Subject: [PATCH] new PMA_List class --- ChangeLog | 3 + libraries/PMA_List.class.php | 154 +++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 libraries/PMA_List.class.php diff --git a/ChangeLog b/ChangeLog index 3d7d5e2fb..3f33ea5cd 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ phpMyAdmin - ChangeLog $Id$ $Source$ +2006-09-21 Sebastian Mendel + * libraries/PMA_List.class.php: new PMA_List class + 2006-09-20 Marc Delisle ### 2.9.0 released from QA_2_9 diff --git a/libraries/PMA_List.class.php b/libraries/PMA_List.class.php new file mode 100644 index 000000000..906218983 --- /dev/null +++ b/libraries/PMA_List.class.php @@ -0,0 +1,154 @@ +items); + } + + /** + * returns item only if there is only one in the list + * + * @uses PMA_List::count() to decide what to return + * @uses PMA_List::getFirst() to return it + * @uses PMA_List::getEmpty() to return it + * @return single item + */ + function getSingleItem() + { + if ($this->count() === 1) { + return $this->getFirst(); + } + + return $this->getEmpty(); + } + + /** + * returns list item count + * + * @uses PMA_List::$items to count it items + * @uses count() to count items in PMA_List::$items + * @return integer PMA_List::$items count + */ + function count() + { + return count($this->items); + } + + /** + * defines what is an empty item (0, '', false or null) + * + * @uses PMA_List::$item_empty as return value + * @return mixed an empty item + */ + function getEmpty() + { + return $this->item_empty; + } + + /** + * checks if the given db names exists in the current list, if there is + * missing at least one item it reutrns false other wise true + * + * @uses PMA_List::$items to check for existence of specific item + * @uses func_get_args() + * @uses in_array() to check if given arguments exists in PMA_List::$items + * @param string $db_name,.. one or more mysql result resources + * @return boolean true if all items exists, otheriwse false + */ + function exists() + { + foreach (func_get_args() as $result) { + if (! in_array($result, $this->items)) { + return false; + } + } + + return true; + } + + /** + * returns HTML