Dynamically add connections
This commit is contained in:
parent
84fcc1c8d2
commit
634a5b92a2
25
index.php
25
index.php
@ -122,6 +122,31 @@ if(function_exists('fbird_connect'))
|
||||
// ! Global Functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Convert an array to an object
|
||||
*
|
||||
* @param array $array
|
||||
* @return object
|
||||
*/
|
||||
function array_to_object($array)
|
||||
{
|
||||
if (is_object($array))
|
||||
{
|
||||
return $array;
|
||||
}
|
||||
|
||||
$obj = new StdClass();
|
||||
|
||||
foreach($array as $k => $v)
|
||||
{
|
||||
$obj->$k = $v;
|
||||
}
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create info dialog to retun an informational message
|
||||
*
|
||||
|
@ -96,6 +96,11 @@ class Connection_Sidebar extends GtkVBox {
|
||||
{
|
||||
foreach($db_conns as $name => $props)
|
||||
{
|
||||
if (is_array($props))
|
||||
{
|
||||
$props = array_to_object($props);
|
||||
}
|
||||
|
||||
$db = $props;
|
||||
$db->name = $name;
|
||||
|
||||
@ -247,6 +252,13 @@ class Connection_Sidebar extends GtkVBox {
|
||||
*/
|
||||
public function refresh()
|
||||
{
|
||||
$cols = $this->treeview->get_columns();
|
||||
|
||||
foreach($cols as $c)
|
||||
{
|
||||
$this->treeview->remove_column($c);
|
||||
}
|
||||
|
||||
$this->_render();
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ class DB_Info_Widget extends GtkTable {
|
||||
$db->port = '';
|
||||
$db->conn_db = '';
|
||||
$db->dbtype = '';
|
||||
$db->db_file = NULL;
|
||||
$db->file = NULL;
|
||||
}
|
||||
|
||||
// Set up the form elements, with default values
|
||||
@ -153,7 +153,7 @@ class DB_Info_Widget extends GtkTable {
|
||||
{
|
||||
$add_button->connect_simple("clicked", array($this, 'db_add'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Test connection button
|
||||
@ -279,7 +279,7 @@ class DB_Info_Widget extends GtkTable {
|
||||
|
||||
// Pass to connection sidebar to update
|
||||
Connection_Sidebar::get_instance()->refresh();
|
||||
|
||||
|
||||
// Let the user know the connection has been updated
|
||||
alert("Changes to database connection have been saved");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user