diff --git a/OpenSQLManager.php b/OpenSQLManager.php index af36635..80dff6b 100644 --- a/OpenSQLManager.php +++ b/OpenSQLManager.php @@ -31,11 +31,11 @@ date_default_timezone_set('GMT'); ini_set('memory_limit', -1); // Set the current directory as the base for included files -define('BASE_DIR', __DIR__.'/sys'); -define('RESOURCE_DIR', __DIR__.'/resources'); -define('SETTINGS_DIR', __DIR__); -define('PROGRAM_NAME', 'OpenSQLManager'); -define('VERSION', '0.2.0pre'); +define('OSM_BASE_DIR', __DIR__.'/sys'); +define('OSM_RESOURCE_DIR', __DIR__.'/resources'); +define('OSM_SETTINGS_DIR', __DIR__); +define('OSM_PROGRAM_NAME', 'OpenSQLManager'); +define('OSM_VERSION', '0.2.0pre'); // -------------------------------------------------------------------------- @@ -132,8 +132,8 @@ function osm_autoload($class) { $class_spaces = explode('\\', $class); $class = strtolower(end($class_spaces)); - $widget_path = BASE_DIR . "/widgets/{$class}.php"; - $window_path = BASE_DIR . "/windows/{$class}.php"; + $widget_path = OSM_BASE_DIR . "/widgets/{$class}.php"; + $window_path = OSM_BASE_DIR . "/windows/{$class}.php"; if (is_file($widget_path)) { @@ -148,13 +148,13 @@ function osm_autoload($class) // -------------------------------------------------------------------------- // Load all the common classes, and register the autoloader -array_map('OpenSQLManager\do_include', glob(BASE_DIR.'/common/*.php')); +array_map('OpenSQLManager\do_include', glob(OSM_BASE_DIR.'/common/*.php')); spl_autoload_register('OpenSQLManager\osm_autoload'); // -------------------------------------------------------------------------- // Auto-load db drivers -require_once(BASE_DIR . "/db/autoload.php"); +require_once(OSM_BASE_DIR . "/db/autoload.php"); // -------------------------------------------------------------------------- // ! App Bootstrap class diff --git a/README.md b/README.md index fdf6f9f..81f9202 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ I've put together this package from the latest wxPHP windows package. It's avail * php5-postgresql * php5-sqlite * php5-ssh2 + * Firebird support has to be manually compiled * Compile wxPHP extension * Run via terminal in the OpenSQLManager folder using `php OpenSQLManager.php` diff --git a/sys/common/settings.php b/sys/common/settings.php index e685943..2c4bdbb 100644 --- a/sys/common/settings.php +++ b/sys/common/settings.php @@ -57,13 +57,13 @@ class Settings { private function __construct() { // For testing and use outside of OpenSQLManager, - // define a different SETTINGS_DIR - if ( ! defined('SETTINGS_DIR')) + // define a different settings directory + if ( ! defined('OSM_SETTINGS_DIR')) { - define('SETTINGS_DIR', '.'); + define('OSM_SETTINGS_DIR', '.'); } - $path = SETTINGS_DIR.'/settings.json'; + $path = OSM_SETTINGS_DIR.'/settings.json'; if( ! is_file($path)) { @@ -102,7 +102,7 @@ class Settings { ? json_encode($this->current, JSON_PRETTY_PRINT) : json_encode($this->current); - file_put_contents(SETTINGS_DIR . '/settings.json', $file_string); + file_put_contents(OSM_SETTINGS_DIR . '/settings.json', $file_string); } // -------------------------------------------------------------------------- diff --git a/sys/widgets/data_grid.php b/sys/widgets/data_grid.php index fa38ad0..00c0faf 100644 --- a/sys/widgets/data_grid.php +++ b/sys/widgets/data_grid.php @@ -33,7 +33,7 @@ class Data_Grid extends \wxGrid { if ( ! is_null($parent)) { parent::__construct($parent, wxID_ANY); - $this->CreateGrid(0,0); + $this->CreateGrid(10,10); $this->HideColLabels(); $this->HideRowLabels(); } diff --git a/sys/widgets/db_tabs.php b/sys/widgets/db_tabs.php index b36e01c..03393cf 100644 --- a/sys/widgets/db_tabs.php +++ b/sys/widgets/db_tabs.php @@ -21,7 +21,7 @@ namespace OpenSQLManager; * @package OpenSQLManager * @subpackage Widgets */ -class DB_tabs extends \wxNotebook { +class DB_tabs extends \wxAUINotebook { /** * Current Tab Widget object @@ -36,17 +36,24 @@ class DB_tabs extends \wxNotebook { * @var array */ private $data; + + /** + * Reference to parent + * + * @var wxWindow + */ + private $parent; /** * Return the db tabs object if it exists, or create and return * * @return DB_tabs */ - public static function &get_instance() + public static function &get_instance($parent) { if (empty(self::$instance)) { - self::$instance = new DB_tabs(); + self::$instance = new DB_tabs($parent); } return self::$instance; @@ -57,10 +64,11 @@ class DB_tabs extends \wxNotebook { /** * Create the object */ - public function __construct() + public function __construct($parent) { - parent::__construct(); - $this->data = new StdClass(); + parent::__construct($parent); + $this->parent = $parent; + $this->data = new \StdClass(); } // -------------------------------------------------------------------------- @@ -76,10 +84,11 @@ class DB_tabs extends \wxNotebook { { if (is_null($widget)) { - $widget = new Data_Grid(); + $widget = new Data_Grid($this); + } - - //$this->append_page($widget, new GtkLabel($label)); + + $this->AddPage($widget, $label); } } // End of db_tabs.php \ No newline at end of file diff --git a/sys/windows/main.php b/sys/windows/main.php index 2058d61..23efa66 100644 --- a/sys/windows/main.php +++ b/sys/windows/main.php @@ -23,7 +23,10 @@ namespace OpenSQLManager; * @package OpenSQLManager * @subpackage Windows */ -class Main extends \wxFrame { +class Main extends \wxFrame { + + const MAC_EXIT_ITEM = 100; + const MAC_ABOUT_ITEM = 101; /** * Reference to settings instance @@ -51,7 +54,7 @@ class Main extends \wxFrame { */ public function __construct() { - parent::__construct(NULL, NULL, PROGRAM_NAME, \wxDefaultPosition,new \wxSize(800, 480)); + parent::__construct(NULL, NULL, OSM_PROGRAM_NAME, \wxDefaultPosition, new \wxSize(800, 480)); $this->_create_menu(); $sbar = $this->CreateStatusBar(2); @@ -99,14 +102,14 @@ class Main extends \wxFrame { { $dlg = new \wxAboutDialogInfo(); - $dlg->SetName(PROGRAM_NAME); - $dlg->SetVersion(VERSION); + $dlg->SetName(OSM_PROGRAM_NAME); + $dlg->SetVersion(OSM_VERSION); $dlg->SetCopyright("Copyright (c) ".date('Y')." Timothy J. Warren"); $dlg->SetWebSite('https://github.com/aviat4ion/OpenSQLManager','Fork on Github'); - $dlg->SetLicense(file_get_contents(RESOURCE_DIR . "/LICENSE")); + $dlg->SetLicense(file_get_contents(OSM_RESOURCE_DIR . "/LICENSE")); $dlg->SetDevelopers(array( 'Timothy J. Warren', @@ -118,13 +121,15 @@ class Main extends \wxFrame { // -------------------------------------------------------------------------- /** - * Layout tabs for databases, tables, &c; + * Loads data tabs for the selected database + * + * @param string $dbname */ - public function load_tabs() + public function load_tabs($dbname) { } - + // -------------------------------------------------------------------------- /** @@ -144,7 +149,8 @@ class Main extends \wxFrame { // Add the connection sidebar $this->connection_sidebar =& Connection_Sidebar::get_instance($win); - $win2 = new Data_Grid($win); + $win2 = new Db_tabs($win); + $win2->add_tab('Test'); // Add the widgets to the split window $win->SplitVertically($this->connection_sidebar, $win2); @@ -162,23 +168,32 @@ class Main extends \wxFrame { * @return void */ private function _create_menu() - { + { // Menu Bar $menu_bar = new \wxMenuBar(); // Menu Bar Top Items - $top_file_menu = new \wxMenu(); + $top_file_menu = new \wxMenu(); + $top_export_menu = new \wxMenu(); $top_help_menu = new \wxMenu(); // File Menu { // Set up the quit item $top_file_menu->Append(wxID_EXIT, "&Quit\tCtrl+Q", "Exit the program"); - $this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit")); + $this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit")); + + // Add the top level menu to the menubar $menu_bar->Append($top_file_menu, "&File"); - } + } + + // Export Menu + { + // Add the top level menu to the menubar + $menu_bar->Append($top_export_menu, "E&xport"); + } // Help Menu { @@ -189,6 +204,18 @@ class Main extends \wxFrame { // Add the top level menu to the menubar $menu_bar->Append($top_help_menu, "&Help"); + } + + // For OS X, duplicate the Quit and About menu items + if (PLATFORM == wxOS_MAC_OSX_DARWIN) + { + // Quit + $top_file_menu->Append(self::MAC_EXIT_ITEM, "&Quit\tCtrl+Q", "Exit the program"); + $this->Connect(self::MAC_EXIT_ITEM, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit")); + + // About + $top_help_menu->Append(self::MAC_ABOUT_ITEM, "&About", "About this program"); + $this->Connect(self::MAC_ABOUT_ITEM, wxEVT_COMMAND_MENU_SELECTED, array($this, "about")); } $this->SetMenuBar($menu_bar);