2012-02-24 15:16:49 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* OpenSQLManager
|
|
|
|
*
|
|
|
|
* Free Database manager for Open Source Databases
|
|
|
|
*
|
2012-04-20 13:30:27 -04:00
|
|
|
* @package OpenSQLManager
|
2012-02-24 15:16:49 -05:00
|
|
|
* @author Timothy J. Warren
|
|
|
|
* @copyright Copyright (c) 2012
|
|
|
|
* @link https://github.com/aviat4ion/OpenSQLManager
|
2012-03-28 09:57:57 -04:00
|
|
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
2012-02-24 15:16:49 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-03-28 09:57:57 -04:00
|
|
|
/**
|
|
|
|
* Widget managing saved database connections
|
2012-04-20 13:30:27 -04:00
|
|
|
*
|
|
|
|
* @package OpenSQLManager
|
|
|
|
* @subpackage Widgets
|
2012-03-28 09:57:57 -04:00
|
|
|
*/
|
2012-02-24 15:16:49 -05:00
|
|
|
class Connection_Sidebar extends GtkVBox {
|
|
|
|
|
2012-04-19 12:29:47 -04:00
|
|
|
/**
|
|
|
|
* Reference to Settings instance
|
2012-04-19 21:55:44 -04:00
|
|
|
*
|
|
|
|
* @var Settings
|
2012-04-19 12:29:47 -04:00
|
|
|
*/
|
|
|
|
protected $settings;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reference to popup menu
|
2012-04-19 21:55:44 -04:00
|
|
|
*
|
|
|
|
* @var GtkMenu
|
2012-04-19 12:29:47 -04:00
|
|
|
*/
|
|
|
|
protected $menu;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Treeview for displaying connections
|
2012-04-19 21:55:44 -04:00
|
|
|
*
|
|
|
|
* @var GtkTreeView
|
2012-04-19 12:29:47 -04:00
|
|
|
*/
|
|
|
|
protected $treeview;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Singleton instance
|
2012-04-19 21:55:44 -04:00
|
|
|
*
|
|
|
|
* @var Connection_Sidebar
|
2012-04-19 12:29:47 -04:00
|
|
|
*/
|
2012-02-28 10:38:13 -05:00
|
|
|
private static $instance;
|
2012-04-19 12:29:47 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Name of current db connection
|
2012-04-19 21:55:44 -04:00
|
|
|
*
|
|
|
|
* @var string
|
2012-04-19 12:29:47 -04:00
|
|
|
*/
|
2012-04-10 15:42:12 -04:00
|
|
|
private $conn_name;
|
2012-02-24 17:53:16 -05:00
|
|
|
|
2012-03-26 12:55:52 -04:00
|
|
|
/**
|
|
|
|
* Return the current instance of the class
|
|
|
|
*
|
|
|
|
* @return Connection_Sidebar
|
|
|
|
*/
|
2012-02-28 10:38:13 -05:00
|
|
|
public static function &get_instance()
|
|
|
|
{
|
|
|
|
if( ! isset(self::$instance))
|
|
|
|
{
|
|
|
|
$name = __CLASS__;
|
|
|
|
self::$instance = new $name();
|
|
|
|
}
|
|
|
|
|
|
|
|
return self::$instance;
|
|
|
|
}
|
|
|
|
|
2012-03-26 12:55:52 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-02-28 10:38:13 -05:00
|
|
|
/**
|
|
|
|
* Constructor method
|
|
|
|
*/
|
2012-02-24 15:16:49 -05:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->settings =& Settings::get_instance();
|
|
|
|
|
|
|
|
$add_button = new GtkButton();
|
|
|
|
$add_button->set_label("New Connnection");
|
|
|
|
$add_button->set_image(GTKImage::new_from_stock(GTK::STOCK_ADD, Gtk::ICON_SIZE_SMALL_TOOLBAR));
|
|
|
|
|
|
|
|
$add_button->connect_simple('clicked', array($this, 'new_conn'));
|
|
|
|
|
|
|
|
// Treeview to show database connections
|
|
|
|
{
|
2012-02-28 10:38:13 -05:00
|
|
|
// Render the treeview
|
2012-03-28 09:57:57 -04:00
|
|
|
$this->_render();
|
2012-02-24 15:16:49 -05:00
|
|
|
|
2012-02-28 10:38:13 -05:00
|
|
|
// Set up context menu event
|
2012-03-27 09:37:04 -04:00
|
|
|
$this->treeview->connect('button-press-event', array($this, 'on_button'));
|
2012-02-27 12:14:49 -05:00
|
|
|
|
2012-02-28 10:38:13 -05:00
|
|
|
$selection = $this->treeview->get_selection();
|
2012-02-24 15:16:49 -05:00
|
|
|
$selection->set_mode(GTK::SELECTION_SINGLE);
|
|
|
|
}
|
2012-03-28 09:57:57 -04:00
|
|
|
|
2012-02-24 15:16:49 -05:00
|
|
|
|
2012-02-28 10:38:13 -05:00
|
|
|
$this->pack_start($this->treeview);
|
2012-02-24 15:16:49 -05:00
|
|
|
$this->pack_start($add_button, FALSE);
|
|
|
|
}
|
|
|
|
|
2012-03-26 12:55:52 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-02-28 10:38:13 -05:00
|
|
|
/**
|
|
|
|
* Renders the connection sidebar widget
|
2012-04-11 14:57:38 -04:00
|
|
|
*
|
|
|
|
* @return void
|
2012-02-28 10:38:13 -05:00
|
|
|
*/
|
|
|
|
protected function _render()
|
|
|
|
{
|
2012-03-29 19:57:10 -04:00
|
|
|
// Create the treeview
|
|
|
|
$this->treeview = (isset($this->treeview))
|
|
|
|
? $this->treeview
|
2012-04-12 11:32:15 -04:00
|
|
|
: new Data_Grid(new GTKTreeStore(Gobject::TYPE_PHP_VALUE));
|
2012-03-29 16:26:50 -04:00
|
|
|
|
|
|
|
$model = $this->treeview->get_model();
|
|
|
|
|
2012-02-28 10:38:13 -05:00
|
|
|
// Add the existing connections to the model
|
|
|
|
$db_conns = $this->settings->get_dbs();
|
|
|
|
if( ! empty($db_conns))
|
|
|
|
{
|
2012-05-14 13:25:32 -04:00
|
|
|
foreach($db_conns as $name => &$props)
|
2012-02-28 10:38:13 -05:00
|
|
|
{
|
2012-03-30 09:58:41 -04:00
|
|
|
if (is_array($props))
|
|
|
|
{
|
|
|
|
$props = array_to_object($props);
|
|
|
|
}
|
|
|
|
|
2012-02-28 10:38:13 -05:00
|
|
|
$db = $props;
|
|
|
|
$db->name = $name;
|
|
|
|
|
2012-03-29 16:26:50 -04:00
|
|
|
$iter = $model->append();
|
|
|
|
$model->set($iter, 0, $db);
|
2012-02-28 10:38:13 -05:00
|
|
|
}
|
|
|
|
}
|
2012-03-28 09:57:57 -04:00
|
|
|
|
2012-02-28 10:38:13 -05:00
|
|
|
// Icon column
|
|
|
|
$cell_renderer = new GtkCellRendererPixbuf();
|
2012-03-27 09:37:04 -04:00
|
|
|
$this->treeview->insert_column_with_data_func(0, 'Type', $cell_renderer, array($this, 'set_icon'));
|
2012-02-28 10:38:13 -05:00
|
|
|
|
|
|
|
// Label column
|
|
|
|
$cell_renderer = new GtkCellRendererText();
|
2012-04-02 16:56:55 -04:00
|
|
|
$this->treeview->insert_column_with_data_func(1, 'Name', $cell_renderer, array($this, 'set_label'));
|
2012-04-02 10:23:27 -04:00
|
|
|
|
|
|
|
// Status column
|
|
|
|
$cell_renderer = new GtkCellRendererPixbuf();
|
|
|
|
$this->treeview->insert_column_with_data_func(2, 'Status', $cell_renderer, array($this, 'set_status_icon'));
|
2012-04-10 15:42:12 -04:00
|
|
|
|
|
|
|
// Connect event to change database tabs
|
|
|
|
$this->treeview->connect('cursor-changed', array($this, 'switch_tab'));
|
2012-04-10 16:47:25 -04:00
|
|
|
|
|
|
|
// Connect event to connect on double-click
|
|
|
|
$this->treeview->connect('row-activated', array($this, 'db_connect'));
|
|
|
|
|
2012-02-28 10:38:13 -05:00
|
|
|
}
|
|
|
|
|
2012-02-24 15:16:49 -05:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the icon for the current db type
|
2012-03-28 09:57:57 -04:00
|
|
|
*
|
|
|
|
* @param GtkTreeView Column $col
|
2012-02-24 15:16:49 -05:00
|
|
|
* @param GtkCellRenderer $cell
|
2012-04-19 12:29:47 -04:00
|
|
|
* @param GtkTreeModel $model
|
2012-02-24 15:16:49 -05:00
|
|
|
* @param GtkTreeIter $iter
|
2012-04-11 14:57:38 -04:00
|
|
|
* @return void
|
2012-02-24 15:16:49 -05:00
|
|
|
*/
|
|
|
|
public function set_icon($col, $cell, $model, $iter)
|
|
|
|
{
|
|
|
|
$col->set_reorderable(TRUE);
|
2012-03-29 16:26:50 -04:00
|
|
|
$info = $model->get_value($iter, 0);
|
2012-02-24 15:16:49 -05:00
|
|
|
$db_type = strtolower($info->type);
|
|
|
|
$img_file = BASE_DIR."/images/{$db_type}-logo-32.png";
|
|
|
|
|
|
|
|
if(is_file($img_file))
|
|
|
|
{
|
|
|
|
$cell->set_property('pixbuf', GdkPixbuf::new_from_file($img_file));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Load an empty image if the db image doesn't exist
|
|
|
|
$img = new GtkImage();
|
|
|
|
$cell->set_property('pixbuf', $img->get_pixbuf());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the label of the current db connection
|
2012-03-28 09:57:57 -04:00
|
|
|
*
|
2012-02-24 15:16:49 -05:00
|
|
|
* @param GtkTreeViewColumn $col
|
|
|
|
* @param GtkCellRenderer $cell
|
2012-04-19 12:29:47 -04:00
|
|
|
* @param GtkTreeModel $model
|
2012-02-24 15:16:49 -05:00
|
|
|
* @param GtkTreeIter $iter
|
2012-04-11 14:57:38 -04:00
|
|
|
* @return void
|
2012-02-24 15:16:49 -05:00
|
|
|
*/
|
|
|
|
public function set_label($col, $cell, $model, $iter)
|
|
|
|
{
|
|
|
|
$col->set_reorderable(TRUE);
|
2012-03-29 16:26:50 -04:00
|
|
|
$info = $model->get_value($iter, 0);
|
2012-02-24 15:16:49 -05:00
|
|
|
$cell->set_property('text', $info->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-04-02 10:23:27 -04:00
|
|
|
/**
|
|
|
|
* Sets the status icon of the current db connection
|
|
|
|
*
|
|
|
|
* @param GtkTreeViewColumn $col
|
|
|
|
* @param GtkCellRenderer $cell
|
|
|
|
* @param GtkTreeModel $model
|
|
|
|
* @param GtkTreeIter $iter
|
2012-04-11 14:57:38 -04:00
|
|
|
* @return void
|
2012-04-02 10:23:27 -04:00
|
|
|
*/
|
|
|
|
public function set_status_icon($col, $cell, $model, $iter)
|
|
|
|
{
|
2012-04-02 10:52:46 -04:00
|
|
|
$col->set_reorderable(TRUE);
|
|
|
|
$info = $model->get_value($iter, 0);
|
|
|
|
|
|
|
|
$conns = DB_Reg::get_connections();
|
|
|
|
|
2012-04-02 16:56:55 -04:00
|
|
|
if(in_array($info->name, $conns))
|
2012-04-02 10:52:46 -04:00
|
|
|
{
|
2012-04-02 16:56:55 -04:00
|
|
|
$cell->set_property('stock-id', 'gtk-yes');
|
2012-04-02 10:52:46 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-02 16:56:55 -04:00
|
|
|
$cell->set_property('stock-id', 'gtk-no');
|
|
|
|
}
|
2012-04-02 10:23:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-02-24 15:16:49 -05:00
|
|
|
/**
|
|
|
|
* Returns window for creating a new database connection
|
2012-03-28 09:57:57 -04:00
|
|
|
*
|
2012-02-24 15:16:49 -05:00
|
|
|
* @return Add_DB object
|
|
|
|
*/
|
|
|
|
public function new_conn()
|
|
|
|
{
|
|
|
|
return new Add_DB();
|
|
|
|
}
|
|
|
|
|
2012-02-24 17:53:16 -05:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-02-27 12:14:49 -05:00
|
|
|
/**
|
|
|
|
* Event for mouse clicks on connection sidebar
|
2012-03-28 09:57:57 -04:00
|
|
|
*
|
2012-02-27 12:14:49 -05:00
|
|
|
* @param GtkTreeView $view
|
|
|
|
* @param $event
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function on_button($view, $event)
|
|
|
|
{
|
2012-03-01 16:46:26 -05:00
|
|
|
if ($event->button !== 3 || empty($view))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-27 12:14:49 -05:00
|
|
|
// Right click
|
2012-03-01 16:46:26 -05:00
|
|
|
if ($event->button == 3)
|
2012-02-27 12:14:49 -05:00
|
|
|
{
|
|
|
|
// get the row and column
|
2012-03-27 09:37:04 -04:00
|
|
|
$path_array = $view->get_path_at_pos($event->x, $event->y);
|
|
|
|
$col = $path_array[1];
|
2012-03-01 16:46:26 -05:00
|
|
|
|
|
|
|
// Don't try to get values for an item that doesn't exist. Instead, return,
|
|
|
|
// so that the program doesn't crash because someone thought it funny
|
|
|
|
// to click on the empty area of the treeview.
|
|
|
|
if(empty($col))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2012-02-27 12:14:49 -05:00
|
|
|
}
|
|
|
|
|
2012-04-02 08:43:27 -04:00
|
|
|
$this->menu = $this->conn_popup_menu($path_array);
|
2012-02-27 12:14:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
2012-02-28 10:38:13 -05:00
|
|
|
* Creates and displays a context menu for the selected connection
|
2012-03-28 09:57:57 -04:00
|
|
|
*
|
2012-03-30 13:09:38 -04:00
|
|
|
* @param array $all
|
2012-02-28 10:38:13 -05:00
|
|
|
* @return void
|
2012-02-27 12:14:49 -05:00
|
|
|
*/
|
2012-04-02 08:43:27 -04:00
|
|
|
public function conn_popup_menu($all)
|
2012-02-27 12:14:49 -05:00
|
|
|
{
|
|
|
|
$this->menu = new GtkMenu();
|
|
|
|
|
2012-04-02 16:56:55 -04:00
|
|
|
$data = $this->treeview->get(0);
|
|
|
|
$conns = DB_Reg::get_connections();
|
|
|
|
|
2012-04-10 10:47:37 -04:00
|
|
|
// Don't try to set up popup menu
|
|
|
|
// on ambiguous areas
|
|
|
|
if ( ! is_object($data))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-27 12:14:49 -05:00
|
|
|
// Set up menu items
|
2012-03-01 16:46:26 -05:00
|
|
|
{
|
2012-04-02 16:56:55 -04:00
|
|
|
// Show disconnect
|
|
|
|
if (in_array($data->name, $conns))
|
|
|
|
{
|
|
|
|
$connect = new GtkImageMenuItem('Disconnect');
|
|
|
|
$connect->set_image(GtkImage::new_from_stock(GTK::STOCK_DISCONNECT, GTK::ICON_SIZE_MENU));
|
|
|
|
$connect->connect_simple('activate', array($this, 'db_disconnect'));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$connect = new GtkImageMenuItem('Connect');
|
|
|
|
$connect->set_image(GtkImage::new_from_stock(GTK::STOCK_CONNECT, GTK::ICON_SIZE_MENU));
|
|
|
|
$connect->connect_simple('activate', array($this, 'db_connect'));
|
|
|
|
}
|
2012-04-02 09:47:13 -04:00
|
|
|
|
|
|
|
$this->menu->append($connect);
|
|
|
|
|
2012-03-28 11:52:38 -04:00
|
|
|
$edit = new GtkImageMenuItem('Edit Connection');
|
|
|
|
$edit->set_image(GtkImage::new_from_stock(GTK::STOCK_EDIT, GTK::ICON_SIZE_MENU));
|
|
|
|
$edit->connect_simple('activate', array($this, 'edit_connection'));
|
|
|
|
|
|
|
|
$this->menu->append($edit);
|
|
|
|
|
2012-03-01 16:46:26 -05:00
|
|
|
$remove = new GtkImageMenuItem('Delete Connection');
|
|
|
|
$remove->set_image(GtkImage::new_from_stock(GTK::STOCK_CANCEL, Gtk::ICON_SIZE_MENU));
|
2012-03-27 09:37:04 -04:00
|
|
|
$remove->connect_simple('activate', array($this, 'remove_connection'), $all);
|
2012-03-01 16:46:26 -05:00
|
|
|
|
|
|
|
$this->menu->append($remove);
|
|
|
|
}
|
2012-03-28 09:57:57 -04:00
|
|
|
|
2012-03-01 16:46:26 -05:00
|
|
|
// Popup the menu
|
2012-02-27 12:14:49 -05:00
|
|
|
$this->menu->show_all();
|
|
|
|
$this->menu->popup();
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-03-29 19:57:10 -04:00
|
|
|
/**
|
|
|
|
* Recreate sidebar widget to update connections
|
2012-04-11 14:57:38 -04:00
|
|
|
*
|
|
|
|
* @return void
|
2012-03-29 19:57:10 -04:00
|
|
|
*/
|
|
|
|
public function refresh()
|
|
|
|
{
|
2012-03-30 10:04:41 -04:00
|
|
|
$this->treeview->reset();
|
2012-03-29 19:57:10 -04:00
|
|
|
$this->_render();
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-03-27 15:47:56 -04:00
|
|
|
/**
|
|
|
|
* Update the connection information for an existing connection
|
2012-04-11 14:57:38 -04:00
|
|
|
*
|
|
|
|
* @return void
|
2012-03-27 15:47:56 -04:00
|
|
|
*/
|
|
|
|
public function edit_connection()
|
|
|
|
{
|
2012-03-30 14:48:50 -04:00
|
|
|
return new Edit_Db($this->treeview->get(0));
|
2012-03-27 15:47:56 -04:00
|
|
|
}
|
|
|
|
|
2012-03-28 09:57:57 -04:00
|
|
|
// --------------------------------------------------------------------------
|
2012-03-27 15:47:56 -04:00
|
|
|
|
2012-02-24 17:53:16 -05:00
|
|
|
/**
|
|
|
|
* Remove a connection from the connection manager
|
2012-03-28 09:57:57 -04:00
|
|
|
*
|
2012-02-28 10:38:13 -05:00
|
|
|
* @return void
|
2012-02-24 17:53:16 -05:00
|
|
|
*/
|
2012-03-30 13:09:38 -04:00
|
|
|
public function remove_connection()
|
2012-02-24 17:53:16 -05:00
|
|
|
{
|
2012-03-27 15:47:56 -04:00
|
|
|
if ( ! confirm("Are you sure you want to remove this database connection?"))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-30 13:09:38 -04:00
|
|
|
// Get the data from the model for the current selection
|
|
|
|
$data = $this->treeview->get(0);
|
|
|
|
|
|
|
|
// Remove the connection from the settings
|
|
|
|
$this->settings->remove_db($data->name);
|
|
|
|
|
|
|
|
// Refresh the sidebar
|
|
|
|
$this->refresh();
|
2012-02-24 17:53:16 -05:00
|
|
|
}
|
2012-04-02 09:47:13 -04:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create connection to a database
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function db_connect()
|
|
|
|
{
|
|
|
|
$data = $this->treeview->get(0);
|
|
|
|
|
|
|
|
// Make sure to catch connection exceptions
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$conn =& DB_Reg::get_db($data->name);
|
2012-04-10 15:42:12 -04:00
|
|
|
$this->conn_name = $data->name;
|
2012-04-02 09:47:13 -04:00
|
|
|
}
|
|
|
|
catch(PDOException $e)
|
|
|
|
{
|
|
|
|
error("Could not connect to database:\n". $e->getMessage());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-03 10:16:25 -04:00
|
|
|
DB_Tabs::get_db_tabs($conn);
|
2012-04-02 09:47:13 -04:00
|
|
|
}
|
2012-04-02 16:56:55 -04:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disconnect from a database
|
2012-04-11 14:57:38 -04:00
|
|
|
*
|
|
|
|
* @return void
|
2012-04-02 16:56:55 -04:00
|
|
|
*/
|
|
|
|
public function db_disconnect()
|
|
|
|
{
|
|
|
|
$data = $this->treeview->get(0);
|
|
|
|
|
|
|
|
DB_Reg::remove_db($data->name);
|
2012-04-11 14:57:38 -04:00
|
|
|
DB_Tabs::reset($data->name);
|
2012-04-02 16:56:55 -04:00
|
|
|
|
|
|
|
$this->refresh();
|
|
|
|
}
|
2012-04-10 15:42:12 -04:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Change tabs based on db connection selected
|
|
|
|
*
|
2012-04-19 12:29:47 -04:00
|
|
|
* @param GtkTreeView $view
|
2012-04-11 14:57:38 -04:00
|
|
|
* @return void
|
2012-04-10 15:42:12 -04:00
|
|
|
*/
|
|
|
|
public function switch_tab($view)
|
|
|
|
{
|
|
|
|
$data = $view->get(0);
|
|
|
|
$conns = DB_Reg::get_connections();
|
|
|
|
|
|
|
|
// Don't reset if you are over the same database
|
|
|
|
if ($data->name === $this->conn_name)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (in_array($data->name, $conns))
|
|
|
|
{
|
|
|
|
$this->db_connect();
|
|
|
|
}
|
|
|
|
}
|
2012-02-24 15:16:49 -05:00
|
|
|
}
|
2012-05-14 13:25:32 -04:00
|
|
|
// End of connection_sidebar.php
|