Render a database select in existing Node engine

Signed-off-by: Atul Pratap Singh <atulpratapsingh05@gmail.com>
This commit is contained in:
Atul Pratap Singh 2015-01-18 01:59:27 +05:30
parent 12f584f1f7
commit b295b6442c
3 changed files with 78 additions and 10 deletions

View File

@ -33,8 +33,6 @@ class PMA_Navigation
if (! PMA_Response::getInstance()->isAjax()) {
$header = new PMA_NavigationHeader();
$retval = $header->getDisplay();
}
if ($GLOBALS['cfg']['ShowNavigationAsTree']) {
$class = ' class="list_container';
if ($GLOBALS['cfg']['NavigationLinkWithMainPanel']) {
$class .= ' synced';
@ -44,7 +42,10 @@ class PMA_Navigation
}
$class .= '"';
$retval .= '<div id="pma_navigation_tree"' . $class . '>';
}
$tree = new PMA_NavigationTree();
if ($GLOBALS['cfg']['ShowNavigationAsTree']) {
if (! PMA_Response::getInstance()->isAjax()
|| ! empty($_REQUEST['full'])
|| ! empty($_REQUEST['reload'])
@ -62,14 +63,15 @@ class PMA_Navigation
} else {
$retval .= $treeRender;
}
$retval .= '</div>'; // pma_navigation_tree
} else {
// provide legacy pre-4.0 navigation
$retval .= $this->_quickWarp();
$retval .= $this->_quickWarp();
$retval .= $tree->renderDbSelect();
}
if (! PMA_Response::getInstance()->isAjax()) {
// closes the tags that were opened by the navigation header
$retval .= '</div>'; // pma_navigation_tree
$retval .= '</div>'; // pma_navigation_content
$retval .= $this->_getDropHandler();
$retval .= '</div>'; // pma_navigation

View File

@ -145,7 +145,9 @@ class PMA_NavigationTree
// Initialise the tree by creating a root node
$node = PMA_NodeFactory::getInstance('Node_Database_Container', 'root');
$this->_tree = $node;
if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']) {
if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']
&& $GLOBALS['cfg']['ShowNavigationAsTree']
) {
$this->_tree->separator = $GLOBALS['cfg']['NavigationTreeDbSeparator'];
$this->_tree->separator_depth = 10000;
}
@ -628,6 +630,7 @@ class PMA_NavigationTree
{
if ($node->type != Node::CONTAINER
|| $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']
|| ! $GLOBALS['cfg']['ShowNavigationAsTree']
) {
return;
}
@ -771,7 +774,9 @@ class PMA_NavigationTree
$retval = '<div class="clearfloat"></div>';
$retval .= '<ul>';
$retval .= $this->_fastFilterHtml($this->_tree);
if (! $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) {
if (! $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']
|| ! $GLOBALS['cfg']['ShowNavigationAsTree']
) {
$retval .= $this->_controls();
}
$retval .= '</ul>';
@ -1133,6 +1138,59 @@ class PMA_NavigationTree
}
return $retval;
}
/**
* Renders a database select box like the pre-4.0 navigation panel
*
* @return string HTML code
*/
public function renderDbSelect()
{
$this->_buildPath();
$this->_tree->is_group = false;
$retval = '<div id="pma_navigation_select_database">';
// Provide for pagination in database select
$retval .= PMA_Util::getListNavigator(
$this->_tree->getPresence('databases', ''),
$this->_pos,
array('server' => $GLOBALS['server']),
'navigation.php',
'frame_navigation',
$GLOBALS['cfg']['FirstLevelNavigationItems'],
'pos',
array('dbselector')
);
$children = $this->_tree->children;
$node = $children[0];
$retval .= '<form method="post" action="index.php" target="_parent" id="left">';
$retval .= '<select name="db" id="navi_db_select">'
. '<option value="" dir="' . $GLOBALS['text_dir'] . '">'
. '(' . __('Databases') . ') ...</option>' . "\n";
$selected = $GLOBALS['db'];
foreach ($children as $node) {
if (isset($node->links['text'])) {
$args = array();
foreach ($node->parents(true) as $parent) {
$args[] = urlencode($parent->real_name);
}
$link = vsprintf($node->links['text'], $args);
$title = empty($node->links['title']) ? '' : $node->links['title'];
$retval .= '<option value="' . htmlspecialchars($node->real_name) . '"'
.' title="' . htmlspecialchars($title) . '"';
if ($node->real_name == $selected || (PMA_DRIZZLE && strtolower($node->real_name) == strtolower($selected))) {
$retval .= ' selected="selected"';
}
$retval .= '>' . htmlspecialchars($node->real_name);
//if (! empty($db['num_tables'])) {
// $return .= ' (' . $db['num_tables'] . ')';
//}
$retval .= '</option>';
}
}
$retval .= '</select></form></div>';
return $retval;
}
/**
* Makes some nodes visible based on the which node is active

View File

@ -366,7 +366,9 @@ class Node
public function getData($type, $pos, $searchClause = '')
{
$maxItems = $GLOBALS['cfg']['FirstLevelNavigationItems'];
if (!$GLOBALS['cfg']['NavigationTreeEnableGrouping']) {
if (!$GLOBALS['cfg']['NavigationTreeEnableGrouping']
|| !$GLOBALS['cfg']['ShowNavigationAsTree']
) {
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$query = "SELECT `SCHEMA_NAME` ";
$query .= "FROM `INFORMATION_SCHEMA`.`SCHEMATA` ";
@ -544,7 +546,9 @@ class Node
*/
public function getPresence($type = '', $searchClause = '')
{
if (!$GLOBALS['cfg']['NavigationTreeEnableGrouping']) {
if (!$GLOBALS['cfg']['NavigationTreeEnableGrouping']
|| !$GLOBALS['cfg']['ShowNavigationAsTree']
) {
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$query = "SELECT COUNT(*) ";
$query .= "FROM INFORMATION_SCHEMA.SCHEMATA ";
@ -711,7 +715,9 @@ class Node
*/
public function getCssClasses($match)
{
if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) {
if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']
|| ! $GLOBALS['cfg']['ShowNavigationAsTree']
) {
return '';
}
@ -736,7 +742,9 @@ class Node
*/
public function getIcon($match)
{
if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) {
if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']
|| ! $GLOBALS['cfg']['ShowNavigationAsTree']
) {
return '';
} elseif ($match && ! $this->is_group) {
$this->visible = true;