make the database list more magic:
load/fetch only if really required use SPL ArrayObject to behave like an array
This commit is contained in:
@@ -53,7 +53,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
|
|||||||
|
|
||||||
// rebuild the database list because PMA_Table::moveCopy
|
// rebuild the database list because PMA_Table::moveCopy
|
||||||
// checks in this list if the target db exists
|
// checks in this list if the target db exists
|
||||||
$GLOBALS['PMA_List_Database']->build();
|
$GLOBALS['pma']->databases->build();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($GLOBALS['add_constraints'])) {
|
if (isset($GLOBALS['add_constraints'])) {
|
||||||
|
@@ -417,7 +417,7 @@ if ($export_type == 'server') {
|
|||||||
$tmp_select = '|' . $tmp_select . '|';
|
$tmp_select = '|' . $tmp_select . '|';
|
||||||
}
|
}
|
||||||
// Walk over databases
|
// Walk over databases
|
||||||
foreach ($GLOBALS['PMA_List_Database']->items as $current_db) {
|
foreach ($GLOBALS['pma']->databases as $current_db) {
|
||||||
if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))
|
if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))
|
||||||
|| !isset($tmp_select)) {
|
|| !isset($tmp_select)) {
|
||||||
if (!PMA_exportDBHeader($current_db)) {
|
if (!PMA_exportDBHeader($current_db)) {
|
||||||
|
@@ -11,86 +11,49 @@
|
|||||||
* @since phpMyAdmin 2.9.10
|
* @since phpMyAdmin 2.9.10
|
||||||
* @abstract
|
* @abstract
|
||||||
*/
|
*/
|
||||||
/* abstract public */ class PMA_List
|
abstract class PMA_List extends ArrayObject
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var array the list items
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
var $items = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array details for list items
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
var $details = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool whether we need to re-index the database list for consistency keys
|
|
||||||
* @access protected
|
|
||||||
*/
|
|
||||||
var $_need_to_reindex = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var mixed empty item
|
* @var mixed empty item
|
||||||
*/
|
*/
|
||||||
var $item_empty = '';
|
protected $item_empty = '';
|
||||||
|
|
||||||
/**
|
public function __construct($array = array(), $flags = 0, $iterator_class = "ArrayIterator")
|
||||||
* returns first item from list
|
|
||||||
*
|
|
||||||
* @uses PMA_List::$items to get first item
|
|
||||||
* @uses reset() to retrive first item from PMA_List::$items array
|
|
||||||
* @return string value of first item
|
|
||||||
*/
|
|
||||||
function getFirst()
|
|
||||||
{
|
{
|
||||||
return reset($this->items);
|
parent::__construct($array, $flags, $iterator_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns item only if there is only one in the list
|
* returns item only if there is only one in the list
|
||||||
*
|
*
|
||||||
* @uses PMA_List::count() to decide what to return
|
* @uses count()
|
||||||
* @uses PMA_List::getFirst() to return it
|
* @uses reset()
|
||||||
* @uses PMA_List::getEmpty() to return it
|
* @uses PMA_List::getEmpty() to return it
|
||||||
* @return single item
|
* @return single item
|
||||||
*/
|
*/
|
||||||
function getSingleItem()
|
public function getSingleItem()
|
||||||
{
|
{
|
||||||
if ($this->count() === 1) {
|
if (count($this) === 1) {
|
||||||
return $this->getFirst();
|
return reset($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getEmpty();
|
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)
|
* defines what is an empty item (0, '', false or null)
|
||||||
*
|
*
|
||||||
* @uses PMA_List::$item_empty as return value
|
* @uses PMA_List::$item_empty as return value
|
||||||
* @return mixed an empty item
|
* @return mixed an empty item
|
||||||
*/
|
*/
|
||||||
function getEmpty()
|
public function getEmpty()
|
||||||
{
|
{
|
||||||
return $this->item_empty;
|
return $this->item_empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if the given db names exists in the current list, if there is
|
* 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
|
* missing at least one item it returns false other wise true
|
||||||
*
|
*
|
||||||
* @uses PMA_List::$items to check for existence of specific item
|
* @uses PMA_List::$items to check for existence of specific item
|
||||||
* @uses func_get_args()
|
* @uses func_get_args()
|
||||||
@@ -98,10 +61,10 @@
|
|||||||
* @param string $db_name,.. one or more mysql result resources
|
* @param string $db_name,.. one or more mysql result resources
|
||||||
* @return boolean true if all items exists, otheriwse false
|
* @return boolean true if all items exists, otheriwse false
|
||||||
*/
|
*/
|
||||||
function exists()
|
public function exists()
|
||||||
{
|
{
|
||||||
foreach (func_get_args() as $result) {
|
foreach (func_get_args() as $result) {
|
||||||
if (! in_array($result, $this->items)) {
|
if (! in_array($result, $this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,22 +82,22 @@
|
|||||||
* @param boolean $include_information_schema
|
* @param boolean $include_information_schema
|
||||||
* @return string HTML option tags
|
* @return string HTML option tags
|
||||||
*/
|
*/
|
||||||
function getHtmlOptions($selected = '', $include_information_schema = true)
|
public function getHtmlOptions($selected = '', $include_information_schema = true)
|
||||||
{
|
{
|
||||||
if (true === $selected) {
|
if (true === $selected) {
|
||||||
$selected = $this->getDefault();
|
$selected = $this->getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = '';
|
$options = '';
|
||||||
foreach ($this->items as $each_db) {
|
foreach ($this as $each_item) {
|
||||||
if (false === $include_information_schema && 'information_schema' === $each_db) {
|
if (false === $include_information_schema && 'information_schema' === $each_item) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$options .= '<option value="' . htmlspecialchars($each_db) . '"';
|
$options .= '<option value="' . htmlspecialchars($each_item) . '"';
|
||||||
if ($selected === $each_db) {
|
if ($selected === $each_item) {
|
||||||
$options .= ' selected="selected"';
|
$options .= ' selected="selected"';
|
||||||
}
|
}
|
||||||
$options .= '>' . htmlspecialchars($each_db) . '</option>' . "\n";
|
$options .= '>' . htmlspecialchars($each_item) . '</option>' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $options;
|
return $options;
|
||||||
@@ -146,7 +109,7 @@
|
|||||||
* @uses PMA_List::getEmpty() as fallback
|
* @uses PMA_List::getEmpty() as fallback
|
||||||
* @return string default item
|
* @return string default item
|
||||||
*/
|
*/
|
||||||
function getDefault()
|
public function getDefault()
|
||||||
{
|
{
|
||||||
return $this->getEmpty();
|
return $this->getEmpty();
|
||||||
}
|
}
|
||||||
@@ -154,8 +117,7 @@
|
|||||||
/**
|
/**
|
||||||
* builds up the list
|
* builds up the list
|
||||||
*
|
*
|
||||||
* @abstract
|
|
||||||
*/
|
*/
|
||||||
/* abstract public */ function build() {}
|
abstract public function build();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@@ -28,33 +28,29 @@ require_once './libraries/List.class.php';
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var mixed database link resource|object to be used
|
* @var mixed database link resource|object to be used
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
var $_db_link = null;
|
protected $_db_link = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var mixed user database link resource|object
|
* @var mixed user database link resource|object
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
var $_db_link_user = null;
|
protected $_db_link_user = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var mixed controluser database link resource|object
|
* @var mixed controluser database link resource|object
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
var $_db_link_control = null;
|
protected $_db_link_control = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var boolean whether SHOW DATABASES is disabled or not
|
* @var boolean whether SHOW DATABASES is disabled or not
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
var $_show_databases_disabled = false;
|
protected $_show_databases_disabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string command to retrieve databases from server
|
* @var string command to retrieve databases from server
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
var $_command = null;
|
protected $_command = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -66,11 +62,13 @@ require_once './libraries/List.class.php';
|
|||||||
* @param mixed $db_link_user user database link resource|object
|
* @param mixed $db_link_user user database link resource|object
|
||||||
* @param mixed $db_link_control control database link resource|object
|
* @param mixed $db_link_control control database link resource|object
|
||||||
*/
|
*/
|
||||||
function __construct($db_link_user = null, $db_link_control = null) {
|
public function __construct($db_link_user = null, $db_link_control = null)
|
||||||
|
{
|
||||||
$this->_db_link = $db_link_user;
|
$this->_db_link = $db_link_user;
|
||||||
$this->_db_link_user = $db_link_user;
|
$this->_db_link_user = $db_link_user;
|
||||||
$this->_db_link_control = $db_link_control;
|
$this->_db_link_control = $db_link_control;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
$this->build();
|
$this->build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,32 +76,27 @@ require_once './libraries/List.class.php';
|
|||||||
* checks if the configuration wants to hide some databases
|
* checks if the configuration wants to hide some databases
|
||||||
*
|
*
|
||||||
* @todo temporaly use this docblock to test how to doc $GLOBALS
|
* @todo temporaly use this docblock to test how to doc $GLOBALS
|
||||||
* @access protected
|
|
||||||
* @uses PMA_List_Database::$items
|
* @uses PMA_List_Database::$items
|
||||||
* @uses PMA_List_Database::$_need_to_reindex to set it if reuqired
|
|
||||||
* @uses preg_match()
|
* @uses preg_match()
|
||||||
* @uses $cfg['Server']['hide_db']
|
* @uses $cfg['Server']['hide_db']
|
||||||
*/
|
*/
|
||||||
function _checkHideDatabase()
|
protected function _checkHideDatabase()
|
||||||
{
|
{
|
||||||
if (empty($GLOBALS['cfg']['Server']['hide_db'])) {
|
if (empty($GLOBALS['cfg']['Server']['hide_db'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->items as $key => $db) {
|
foreach ($this as $key => $db) {
|
||||||
if (preg_match('/' . $GLOBALS['cfg']['Server']['hide_db'] . '/', $db)) {
|
if (preg_match('/' . $GLOBALS['cfg']['Server']['hide_db'] . '/', $db)) {
|
||||||
unset($this->items[$key]);
|
$this->offsetUnset($key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// re-index values
|
|
||||||
$this->_need_to_reindex = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieves database list from server
|
* retrieves database list from server
|
||||||
*
|
*
|
||||||
* @todo we could also search mysql tables if all fail?
|
* @todo we could also search mysql tables if all fail?
|
||||||
* @access protected
|
|
||||||
* @uses PMA_List_Database::$_show_databases_disabled for not retrying if SHOW DATABASES is disabled
|
* @uses PMA_List_Database::$_show_databases_disabled for not retrying if SHOW DATABASES is disabled
|
||||||
* @uses PMA_List_Database::$_db_link
|
* @uses PMA_List_Database::$_db_link
|
||||||
* @uses PMA_List_Database::$_db_link_control in case of SHOW DATABASES is disabled for userlink
|
* @uses PMA_List_Database::$_db_link_control in case of SHOW DATABASES is disabled for userlink
|
||||||
@@ -113,7 +106,7 @@ require_once './libraries/List.class.php';
|
|||||||
* @uses $GLOBALS['errno']
|
* @uses $GLOBALS['errno']
|
||||||
* @param string $like_db_name usally a db_name containing wildcards
|
* @param string $like_db_name usally a db_name containing wildcards
|
||||||
*/
|
*/
|
||||||
function _retrieve($like_db_name = null)
|
protected function _retrieve($like_db_name = null)
|
||||||
{
|
{
|
||||||
if ($this->_show_databases_disabled) {
|
if ($this->_show_databases_disabled) {
|
||||||
return array();
|
return array();
|
||||||
@@ -156,7 +149,6 @@ require_once './libraries/List.class.php';
|
|||||||
* builds up the list
|
* builds up the list
|
||||||
*
|
*
|
||||||
* @uses PMA_List_Database::$items to initialize it
|
* @uses PMA_List_Database::$items to initialize it
|
||||||
* @uses PMA_List_Database::$_need_to_reindex
|
|
||||||
* @uses PMA_List_Database::_checkOnlyDatabase()
|
* @uses PMA_List_Database::_checkOnlyDatabase()
|
||||||
* @uses PMA_List_Database::_retrieve()
|
* @uses PMA_List_Database::_retrieve()
|
||||||
* @uses PMA_List_Database::_checkHideDatabase()
|
* @uses PMA_List_Database::_checkHideDatabase()
|
||||||
@@ -164,23 +156,17 @@ require_once './libraries/List.class.php';
|
|||||||
* @uses natsort()
|
* @uses natsort()
|
||||||
* @uses $cfg['NaturalOrder']
|
* @uses $cfg['NaturalOrder']
|
||||||
*/
|
*/
|
||||||
function build()
|
public function build()
|
||||||
{
|
{
|
||||||
$this->items = array();
|
|
||||||
|
|
||||||
if (! $this->_checkOnlyDatabase()) {
|
if (! $this->_checkOnlyDatabase()) {
|
||||||
$this->items = $this->_retrieve();
|
$items = $this->_retrieve();
|
||||||
if ($GLOBALS['cfg']['NaturalOrder']) {
|
if ($GLOBALS['cfg']['NaturalOrder']) {
|
||||||
natsort($this->items);
|
natsort($items);
|
||||||
$this->_need_to_reindex = true;
|
|
||||||
}
|
}
|
||||||
|
$this->exchangeArray($items);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_checkHideDatabase();
|
$this->_checkHideDatabase();
|
||||||
|
|
||||||
if ($this->_need_to_reindex) {
|
|
||||||
$this->items = array_values($this->items);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,7 +185,7 @@ require_once './libraries/List.class.php';
|
|||||||
* @uses $cfg['Server']['only_db']
|
* @uses $cfg['Server']['only_db']
|
||||||
* @return boolean false if there is no only_db, otherwise true
|
* @return boolean false if there is no only_db, otherwise true
|
||||||
*/
|
*/
|
||||||
function _checkOnlyDatabase()
|
protected function _checkOnlyDatabase()
|
||||||
{
|
{
|
||||||
if (is_string($GLOBALS['cfg']['Server']['only_db'])
|
if (is_string($GLOBALS['cfg']['Server']['only_db'])
|
||||||
&& strlen($GLOBALS['cfg']['Server']['only_db'])) {
|
&& strlen($GLOBALS['cfg']['Server']['only_db'])) {
|
||||||
@@ -212,11 +198,13 @@ require_once './libraries/List.class.php';
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$items = array();
|
||||||
|
|
||||||
foreach ($GLOBALS['cfg']['Server']['only_db'] as $each_only_db) {
|
foreach ($GLOBALS['cfg']['Server']['only_db'] as $each_only_db) {
|
||||||
if ($each_only_db === '*' && ! $this->_show_databases_disabled) {
|
if ($each_only_db === '*' && ! $this->_show_databases_disabled) {
|
||||||
// append all not already listed dbs to the list
|
// append all not already listed dbs to the list
|
||||||
$this->items = array_merge($this->items,
|
$items = array_merge($items,
|
||||||
array_diff($this->_retrieve(), $this->items));
|
array_diff($this->_retrieve(), $items));
|
||||||
// there can only be one '*', and this can only be last
|
// there can only be one '*', and this can only be last
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -225,18 +213,20 @@ require_once './libraries/List.class.php';
|
|||||||
// thus containing not escaped _ or %
|
// thus containing not escaped _ or %
|
||||||
if (! preg_match('/(^|[^\\\\])(_|%)/', $each_only_db)) {
|
if (! preg_match('/(^|[^\\\\])(_|%)/', $each_only_db)) {
|
||||||
// ... not contains wildcard
|
// ... not contains wildcard
|
||||||
$this->items[] = PMA_unescape_mysql_wildcards($each_only_db);
|
$items[] = PMA_unescape_mysql_wildcards($each_only_db);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->_show_databases_disabled) {
|
if (! $this->_show_databases_disabled) {
|
||||||
$this->items = array_merge($this->items, $this->_retrieve($each_only_db));
|
$items = array_merge($items, $this->_retrieve($each_only_db));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo induce error, about not using wildcards with SHOW DATABASE disabled?
|
// @todo induce error, about not using wildcards with SHOW DATABASE disabled?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->exchangeArray($items);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +238,7 @@ require_once './libraries/List.class.php';
|
|||||||
* @uses strlen()
|
* @uses strlen()
|
||||||
* @return string default item
|
* @return string default item
|
||||||
*/
|
*/
|
||||||
function getDefault()
|
public function getDefault()
|
||||||
{
|
{
|
||||||
if (strlen($GLOBALS['db'])) {
|
if (strlen($GLOBALS['db'])) {
|
||||||
return $GLOBALS['db'];
|
return $GLOBALS['db'];
|
||||||
@@ -276,7 +266,7 @@ require_once './libraries/List.class.php';
|
|||||||
* @param integer $count
|
* @param integer $count
|
||||||
* @return array db list
|
* @return array db list
|
||||||
*/
|
*/
|
||||||
function getGroupedDetails($offset, $count)
|
public function getGroupedDetails($offset, $count)
|
||||||
{
|
{
|
||||||
$dbgroups = array();
|
$dbgroups = array();
|
||||||
$parts = array();
|
$parts = array();
|
||||||
@@ -334,15 +324,14 @@ require_once './libraries/List.class.php';
|
|||||||
/**
|
/**
|
||||||
* returns a part of the items
|
* returns a part of the items
|
||||||
*
|
*
|
||||||
* @uses PMA_List_Database::$items
|
|
||||||
* @uses array_slice()
|
* @uses array_slice()
|
||||||
* @param integer $offset
|
* @param integer $offset
|
||||||
* @param integer $count
|
* @param integer $count
|
||||||
* @return array some items
|
* @return array some items
|
||||||
*/
|
*/
|
||||||
function getLimitedItems($offset, $count)
|
public function getLimitedItems($offset, $count)
|
||||||
{
|
{
|
||||||
return(array_slice($this->items, $offset, $count));
|
return array_slice($this->getArrayCopy(), $offset, $count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -350,7 +339,7 @@ require_once './libraries/List.class.php';
|
|||||||
*
|
*
|
||||||
* @return string html code list
|
* @return string html code list
|
||||||
*/
|
*/
|
||||||
function getHtmlListGrouped($selected = '', $offset, $count)
|
public function getHtmlListGrouped($selected = '', $offset, $count)
|
||||||
{
|
{
|
||||||
if (true === $selected) {
|
if (true === $selected) {
|
||||||
$selected = $this->getDefault();
|
$selected = $this->getDefault();
|
||||||
@@ -406,7 +395,7 @@ require_once './libraries/List.class.php';
|
|||||||
*
|
*
|
||||||
* @return string html code select
|
* @return string html code select
|
||||||
*/
|
*/
|
||||||
function getHtmlSelectGrouped($selected = '', $offset, $count)
|
public function getHtmlSelectGrouped($selected = '', $offset, $count)
|
||||||
{
|
{
|
||||||
if (true === $selected) {
|
if (true === $selected) {
|
||||||
$selected = $this->getDefault();
|
$selected = $this->getDefault();
|
||||||
@@ -451,9 +440,8 @@ require_once './libraries/List.class.php';
|
|||||||
* this is just a backup, if all is fine this can be deleted later
|
* this is just a backup, if all is fine this can be deleted later
|
||||||
*
|
*
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
function _checkAgainstPrivTables()
|
protected function _checkAgainstPrivTables()
|
||||||
{
|
{
|
||||||
// 1. get allowed dbs from the "mysql.db" table
|
// 1. get allowed dbs from the "mysql.db" table
|
||||||
// lem9: User can be blank (anonymous user)
|
// lem9: User can be blank (anonymous user)
|
||||||
|
94
libraries/PMA.php
Normal file
94
libraries/PMA.php
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Enter description here...
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
require_once './libraries/List_Database.class.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phpMyAdmin mian Controller
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class PMA
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Holds database list
|
||||||
|
*
|
||||||
|
* @var PMA_List_Datase
|
||||||
|
*/
|
||||||
|
protected $databases = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DBMS user link
|
||||||
|
*
|
||||||
|
* @var resource
|
||||||
|
*/
|
||||||
|
protected $userlink = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DBMS control link
|
||||||
|
*
|
||||||
|
* @var resource
|
||||||
|
*/
|
||||||
|
protected $controllink = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* magic access to protected/inaccessible members/properties
|
||||||
|
*
|
||||||
|
* @see http://php.net/language.oop5.overloading
|
||||||
|
*/
|
||||||
|
public function __get($param)
|
||||||
|
{
|
||||||
|
switch ($param) {
|
||||||
|
case 'databases' :
|
||||||
|
return $this->getDatabaseList();
|
||||||
|
break;
|
||||||
|
case 'userlink' :
|
||||||
|
return $this->userlink;
|
||||||
|
break;
|
||||||
|
case 'controllink' :
|
||||||
|
return $this->controllink;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* magic access to protected/inaccessible members/properties
|
||||||
|
*
|
||||||
|
* @see http://php.net/language.oop5.overloading
|
||||||
|
*/
|
||||||
|
public function __set($param, $value)
|
||||||
|
{
|
||||||
|
switch ($param) {
|
||||||
|
case 'userlink' :
|
||||||
|
$this->userlink = $value;
|
||||||
|
break;
|
||||||
|
case 'controllink' :
|
||||||
|
$this->controllink = $value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accessor to PMA::$databases
|
||||||
|
*
|
||||||
|
* @uses PMA::$databases
|
||||||
|
* @uses PMA::$userlink
|
||||||
|
* @uses PMA::$controllink
|
||||||
|
* @uses PMA_List_Database
|
||||||
|
* @return PMA_List_Databases
|
||||||
|
*/
|
||||||
|
public function getDatabaseList()
|
||||||
|
{
|
||||||
|
if (null === $this->databases) {
|
||||||
|
$this->databases = new PMA_List_Database($this->userlink, $this->controllink);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->databases;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@@ -559,12 +559,12 @@ class PMA_Table {
|
|||||||
$GLOBALS['asfile'] = 1;
|
$GLOBALS['asfile'] = 1;
|
||||||
|
|
||||||
// Ensure the target is valid
|
// Ensure the target is valid
|
||||||
if (! $GLOBALS['PMA_List_Database']->exists($source_db, $target_db)) {
|
if (! $GLOBALS['pma']->databases->exists($source_db, $target_db)) {
|
||||||
if (! $GLOBALS['PMA_List_Database']->exists($source_db)) {
|
if (! $GLOBALS['pma']->databases->exists($source_db)) {
|
||||||
$GLOBALS['message'] = PMA_Message::rawError('source database `'
|
$GLOBALS['message'] = PMA_Message::rawError('source database `'
|
||||||
. htmlspecialchars($source_db) . '` not found');
|
. htmlspecialchars($source_db) . '` not found');
|
||||||
}
|
}
|
||||||
if (! $GLOBALS['PMA_List_Database']->exists($target_db)) {
|
if (! $GLOBALS['pma']->databases->exists($target_db)) {
|
||||||
$GLOBALS['message'] = PMA_Message::rawError('target database `'
|
$GLOBALS['message'] = PMA_Message::rawError('target database `'
|
||||||
. htmlspecialchars($target_db) . '` not found');
|
. htmlspecialchars($target_db) . '` not found');
|
||||||
}
|
}
|
||||||
@@ -951,7 +951,7 @@ class PMA_Table {
|
|||||||
{
|
{
|
||||||
if (null !== $new_db && $new_db !== $this->getDbName()) {
|
if (null !== $new_db && $new_db !== $this->getDbName()) {
|
||||||
// Ensure the target is valid
|
// Ensure the target is valid
|
||||||
if (! $GLOBALS['PMA_List_Database']->exists($new_db)) {
|
if (! $GLOBALS['pma']->databases->exists($new_db)) {
|
||||||
$this->errors[] = $GLOBALS['strInvalidDatabase'] . ': ' . $new_db;
|
$this->errors[] = $GLOBALS['strInvalidDatabase'] . ': ' . $new_db;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -907,8 +907,10 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
|||||||
/**
|
/**
|
||||||
* the PMA_List_Database class
|
* the PMA_List_Database class
|
||||||
*/
|
*/
|
||||||
require_once './libraries/List_Database.class.php';
|
require_once './libraries/PMA.php';
|
||||||
$PMA_List_Database = new PMA_List_Database($userlink, $controllink);
|
$pma = new PMA;
|
||||||
|
$pma->userlink = $userlink;
|
||||||
|
$pma->controllink = $controllink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* some resetting has to be done when switching servers
|
* some resetting has to be done when switching servers
|
||||||
|
@@ -487,7 +487,7 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
|
|||||||
|
|
||||||
// display only databases also in official database list
|
// display only databases also in official database list
|
||||||
// f.e. to apply hide_db and only_db
|
// f.e. to apply hide_db and only_db
|
||||||
$drops = array_diff(array_keys($databases), $GLOBALS['PMA_List_Database']->items);
|
$drops = array_diff(array_keys($databases), $GLOBALS['pma']->databases);
|
||||||
if (count($drops)) {
|
if (count($drops)) {
|
||||||
foreach ($drops as $drop) {
|
foreach ($drops as $drop) {
|
||||||
unset($databases[$drop]);
|
unset($databases[$drop]);
|
||||||
@@ -496,7 +496,7 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
|
|||||||
}
|
}
|
||||||
unset($sql_where_schema, $sql, $drops);
|
unset($sql_where_schema, $sql, $drops);
|
||||||
} else {
|
} else {
|
||||||
foreach ($GLOBALS['PMA_List_Database']->items as $database_name) {
|
foreach ($GLOBALS['pma']->databases as $database_name) {
|
||||||
// MySQL forward compatibility
|
// MySQL forward compatibility
|
||||||
// so pma could use this array as if every server is of version >5.0
|
// so pma could use this array as if every server is of version >5.0
|
||||||
$databases[$database_name]['SCHEMA_NAME'] = $database_name;
|
$databases[$database_name]['SCHEMA_NAME'] = $database_name;
|
||||||
@@ -630,7 +630,7 @@ function PMA_DBI_get_columns_full($database = null, $table = null,
|
|||||||
unset($sql_wheres, $sql);
|
unset($sql_wheres, $sql);
|
||||||
} else {
|
} else {
|
||||||
if (null === $database) {
|
if (null === $database) {
|
||||||
foreach ($GLOBALS['PMA_List_Database']->items as $database) {
|
foreach ($GLOBALS['pma']->databases as $database) {
|
||||||
$columns[$database] = PMA_DBI_get_columns_full($database, null,
|
$columns[$database] = PMA_DBI_get_columns_full($database, null,
|
||||||
null, $link);
|
null, $link);
|
||||||
}
|
}
|
||||||
|
@@ -420,7 +420,7 @@ elseif ($mult_btn == $strYes) {
|
|||||||
if ($rebuild_database_list) {
|
if ($rebuild_database_list) {
|
||||||
// avoid a problem with the database list navigator
|
// avoid a problem with the database list navigator
|
||||||
// when dropping a db from server_databases
|
// when dropping a db from server_databases
|
||||||
$GLOBALS['PMA_List_Database']->build();
|
$GLOBALS['pma']->databases->build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* the navigation frame - displays server, db and table selection tree
|
* the navigation frame - displays server, db and table selection tree
|
||||||
*
|
*
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
* @uses $GLOBALS['PMA_List_Database']
|
* @uses $GLOBALS['pma']->databases
|
||||||
* @uses $GLOBALS['server']
|
* @uses $GLOBALS['server']
|
||||||
* @uses $GLOBALS['db']
|
* @uses $GLOBALS['db']
|
||||||
* @uses $GLOBALS['table']
|
* @uses $GLOBALS['table']
|
||||||
@@ -24,7 +24,6 @@
|
|||||||
* @uses $GLOBALS['cfg']['DefaultTabDatabase']
|
* @uses $GLOBALS['cfg']['DefaultTabDatabase']
|
||||||
* @uses $GLOBALS['cfgRelation']['commwork']) {
|
* @uses $GLOBALS['cfgRelation']['commwork']) {
|
||||||
* @uses PMA_List_Database::getSingleItem()
|
* @uses PMA_List_Database::getSingleItem()
|
||||||
* @uses PMA_List_Database::count()
|
|
||||||
* @uses PMA_List_Database::getHtmlSelectGrouped()
|
* @uses PMA_List_Database::getHtmlSelectGrouped()
|
||||||
* @uses PMA_List_Database::getGroupedDetails()
|
* @uses PMA_List_Database::getGroupedDetails()
|
||||||
* @uses PMA_generate_common_url()
|
* @uses PMA_generate_common_url()
|
||||||
@@ -86,7 +85,7 @@ PMA_outBufferPre();
|
|||||||
* selects the database if there is only one on current server
|
* selects the database if there is only one on current server
|
||||||
*/
|
*/
|
||||||
if ($GLOBALS['server'] && ! strlen($GLOBALS['db'])) {
|
if ($GLOBALS['server'] && ! strlen($GLOBALS['db'])) {
|
||||||
$GLOBALS['db'] = $GLOBALS['PMA_List_Database']->getSingleItem();
|
$GLOBALS['db'] = $GLOBALS['pma']->databases->getSingleItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
$db_start = $GLOBALS['db'];
|
$db_start = $GLOBALS['db'];
|
||||||
@@ -188,11 +187,11 @@ require './libraries/navigation_header.inc.php';
|
|||||||
if (! $GLOBALS['server']) {
|
if (! $GLOBALS['server']) {
|
||||||
// no server selected
|
// no server selected
|
||||||
PMA_exitNavigationFrame();
|
PMA_exitNavigationFrame();
|
||||||
} elseif (! $GLOBALS['PMA_List_Database']->count()) {
|
} elseif (! count($GLOBALS['pma']->databases)) {
|
||||||
// no database available, so we break here
|
// no database available, so we break here
|
||||||
echo '<p>' . $GLOBALS['strNoDatabases'] . '</p>';
|
echo '<p>' . $GLOBALS['strNoDatabases'] . '</p>';
|
||||||
PMA_exitNavigationFrame();
|
PMA_exitNavigationFrame();
|
||||||
} elseif ($GLOBALS['cfg']['LeftFrameLight'] && $GLOBALS['PMA_List_Database']->count() > 1) {
|
} elseif ($GLOBALS['cfg']['LeftFrameLight'] && count($GLOBALS['pma']->databases) > 1) {
|
||||||
$list = $cfg['DisplayDatabasesList'];
|
$list = $cfg['DisplayDatabasesList'];
|
||||||
if ($list === 'auto') {
|
if ($list === 'auto') {
|
||||||
if (empty($GLOBALS['db'])) {
|
if (empty($GLOBALS['db'])) {
|
||||||
@@ -216,7 +215,7 @@ if (! $GLOBALS['server']) {
|
|||||||
<label for="lightm_db"><?php echo $GLOBALS['strDatabase']; ?></label>
|
<label for="lightm_db"><?php echo $GLOBALS['strDatabase']; ?></label>
|
||||||
<?php
|
<?php
|
||||||
echo PMA_generate_common_hidden_inputs() . "\n";
|
echo PMA_generate_common_hidden_inputs() . "\n";
|
||||||
echo $GLOBALS['PMA_List_Database']->getHtmlSelectGrouped(true, $_SESSION['userconf']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
|
echo $GLOBALS['pma']->databases->getHtmlSelectGrouped(true, $_SESSION['userconf']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
|
||||||
echo '<noscript>' . "\n"
|
echo '<noscript>' . "\n"
|
||||||
.'<input type="submit" name="Go" value="' . $GLOBALS['strGo'] . '" />' . "\n"
|
.'<input type="submit" name="Go" value="' . $GLOBALS['strGo'] . '" />' . "\n"
|
||||||
.'</noscript>' . "\n"
|
.'</noscript>' . "\n"
|
||||||
@@ -225,10 +224,10 @@ if (! $GLOBALS['server']) {
|
|||||||
if (! empty($db)) {
|
if (! empty($db)) {
|
||||||
echo '<div id="databaseList">' . "\n";
|
echo '<div id="databaseList">' . "\n";
|
||||||
}
|
}
|
||||||
echo $GLOBALS['PMA_List_Database']->getHtmlListGrouped(true, $_SESSION['userconf']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
|
echo $GLOBALS['pma']->databases->getHtmlListGrouped(true, $_SESSION['userconf']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
|
||||||
}
|
}
|
||||||
$_url_params = array('pos' => $pos);
|
$_url_params = array('pos' => $pos);
|
||||||
PMA_listNavigator($GLOBALS['PMA_List_Database']->count(), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
|
PMA_listNavigator(count($GLOBALS['pma']->databases), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
|
||||||
if (! empty($db)) {
|
if (! empty($db)) {
|
||||||
echo '</div>' . "\n";
|
echo '</div>' . "\n";
|
||||||
}
|
}
|
||||||
@@ -321,11 +320,11 @@ if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
|
|||||||
} else {
|
} else {
|
||||||
echo '<div id="databaseList">' . "\n";
|
echo '<div id="databaseList">' . "\n";
|
||||||
$_url_params = array('pos' => $pos);
|
$_url_params = array('pos' => $pos);
|
||||||
PMA_listNavigator($GLOBALS['PMA_List_Database']->count(), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
|
PMA_listNavigator(count($GLOBALS['pma']->databases), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
|
||||||
echo '</div>' . "\n";
|
echo '</div>' . "\n";
|
||||||
|
|
||||||
$common_url_query = PMA_generate_common_url();
|
$common_url_query = PMA_generate_common_url();
|
||||||
PMA_displayDbList($GLOBALS['PMA_List_Database']->getGroupedDetails($_SESSION['userconf']['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']), $_SESSION['userconf']['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']);
|
PMA_displayDbList($GLOBALS['pma']->databases->getGroupedDetails($_SESSION['userconf']['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']), $_SESSION['userconf']['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -357,13 +356,13 @@ function PMA_displayDbList($ext_dblist, $offset, $count) {
|
|||||||
|
|
||||||
// get table list, for all databases
|
// get table list, for all databases
|
||||||
// doing this in one step takes advantage of a single query with information_schema!
|
// doing this in one step takes advantage of a single query with information_schema!
|
||||||
$tables_full = PMA_DBI_get_tables_full($GLOBALS['PMA_List_Database']->getLimitedItems($offset, $count));
|
$tables_full = PMA_DBI_get_tables_full($GLOBALS['pma']->databases->getLimitedItems($offset, $count));
|
||||||
|
|
||||||
$url_dbgroup = '';
|
$url_dbgroup = '';
|
||||||
echo '<ul id="leftdatabaselist">';
|
echo '<ul id="leftdatabaselist">';
|
||||||
$close_db_group = false;
|
$close_db_group = false;
|
||||||
foreach ($ext_dblist as $group => $db_group) {
|
foreach ($ext_dblist as $group => $db_group) {
|
||||||
if ($GLOBALS['PMA_List_Database']->count() > 1) {
|
if (count($GLOBALS['pma']->databases) > 1) {
|
||||||
if ($close_db_group) {
|
if ($close_db_group) {
|
||||||
$url_dbgroup = '';
|
$url_dbgroup = '';
|
||||||
echo '</ul>';
|
echo '</ul>';
|
||||||
@@ -402,7 +401,7 @@ function PMA_displayDbList($ext_dblist, $offset, $count) {
|
|||||||
// Displays the database name
|
// Displays the database name
|
||||||
echo '<li>' . "\n";
|
echo '<li>' . "\n";
|
||||||
|
|
||||||
if ($GLOBALS['PMA_List_Database']->count() > 1) {
|
if (count($GLOBALS['pma']->databases) > 1) {
|
||||||
// only with more than one db we need collapse ...
|
// only with more than one db we need collapse ...
|
||||||
if ($db_start != $db['name'] || $db['num_tables'] < 1) {
|
if ($db_start != $db['name'] || $db['num_tables'] < 1) {
|
||||||
// display + only if this db is not preselected
|
// display + only if this db is not preselected
|
||||||
@@ -475,7 +474,7 @@ function PMA_displayDbList($ext_dblist, $offset, $count) {
|
|||||||
$tables = PMA_getTableList($db['name']);
|
$tables = PMA_getTableList($db['name']);
|
||||||
}
|
}
|
||||||
$child_visible =
|
$child_visible =
|
||||||
(bool) ($GLOBALS['PMA_List_Database']->count() === 1 || $db_start == $db['name']);
|
(bool) (count($GLOBALS['pma']->databases) === 1 || $db_start == $db['name']);
|
||||||
PMA_displayTableList($tables, $child_visible, '', $db['name']);
|
PMA_displayTableList($tables, $child_visible, '', $db['name']);
|
||||||
} elseif ($GLOBALS['cfg']['LeftFrameLight']) {
|
} elseif ($GLOBALS['cfg']['LeftFrameLight']) {
|
||||||
// no tables and LeftFrameLight:
|
// no tables and LeftFrameLight:
|
||||||
|
@@ -92,7 +92,7 @@ echo '<h2>' . "\n"
|
|||||||
if ($server > 0) {
|
if ($server > 0) {
|
||||||
$databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
|
$databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
|
||||||
$sort_order, $pos, true);
|
$sort_order, $pos, true);
|
||||||
$databases_count = $PMA_List_Database->count();
|
$databases_count = count($GLOBALS['pma']->databases);
|
||||||
} else {
|
} else {
|
||||||
$databases_count = 0;
|
$databases_count = 0;
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ $multi_values .= '<a href="' . $checkall_url . '&selectall=1" onclick="setSe
|
|||||||
$multi_values .= '<select name="db_select[]" size="6" multiple="multiple">';
|
$multi_values .= '<select name="db_select[]" size="6" multiple="multiple">';
|
||||||
$multi_values .= "\n";
|
$multi_values .= "\n";
|
||||||
|
|
||||||
foreach ($GLOBALS['PMA_List_Database']->items as $current_db) {
|
foreach ($GLOBALS['pma']->databases as $current_db) {
|
||||||
if (!empty($selectall) || (isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))) {
|
if (!empty($selectall) || (isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))) {
|
||||||
$is_selected = ' selected="selected"';
|
$is_selected = ' selected="selected"';
|
||||||
} else {
|
} else {
|
||||||
|
@@ -258,14 +258,14 @@ unset($columns);
|
|||||||
<input type="hidden" name="what" value="data" />
|
<input type="hidden" name="what" value="data" />
|
||||||
<fieldset id="fieldset_table_rename">
|
<fieldset id="fieldset_table_rename">
|
||||||
<legend><?php echo $strMoveTable; ?></legend>
|
<legend><?php echo $strMoveTable; ?></legend>
|
||||||
<?php if ($GLOBALS['PMA_List_Database']->count() > $GLOBALS['cfg']['MaxDbList']) {
|
<?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
|
||||||
?>
|
?>
|
||||||
<input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
|
<input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
<select name="target_db">
|
<select name="target_db">
|
||||||
<?php echo $GLOBALS['PMA_List_Database']->getHtmlOptions(true, false); ?>
|
<?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
|
||||||
</select>
|
</select>
|
||||||
<?php
|
<?php
|
||||||
} // end if
|
} // end if
|
||||||
@@ -462,14 +462,14 @@ if (isset($possible_row_formats[$tbl_type])) {
|
|||||||
<input type="hidden" name="reload" value="1" />
|
<input type="hidden" name="reload" value="1" />
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><?php echo $strCopyTable; ?></legend>
|
<legend><?php echo $strCopyTable; ?></legend>
|
||||||
<?php if ($GLOBALS['PMA_List_Database']->count() > $GLOBALS['cfg']['MaxDbList']) {
|
<?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
|
||||||
?>
|
?>
|
||||||
<input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
|
<input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
<select name="target_db">
|
<select name="target_db">
|
||||||
<?php echo $GLOBALS['PMA_List_Database']->getHtmlOptions(true, false); ?>
|
<?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
|
||||||
</select>
|
</select>
|
||||||
<?php
|
<?php
|
||||||
} // end if
|
} // end if
|
||||||
|
Reference in New Issue
Block a user