From fce53afce4a14b55e1e5396de1e94afd2f496374 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Dec 2011 19:34:16 +0100 Subject: [PATCH] Work on POO optimize --- htdocs/admin/tools/dolibarr_export.php | 21 ++++++++++----------- htdocs/admin/tools/dolibarr_import.php | 10 +++++----- htdocs/admin/tools/export.php | 4 ++-- htdocs/core/db/mssql.class.php | 2 +- htdocs/core/db/mysql.class.php | 2 +- htdocs/core/db/mysqli.class.php | 2 +- htdocs/core/db/pgsql.class.php | 7 +++++-- htdocs/core/db/sqlite.class.php | 2 +- 8 files changed, 26 insertions(+), 24 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index a481969c7a4..1742fd1ff64 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -83,7 +83,6 @@ if ($_GET["msg"]) print "\n"; } - ?> @@ -100,7 +99,7 @@ if ($_GET["msg"])
trans("ExportMethod"); ?> label == 'MySQL') + if ($db::$label == 'MySQL') { ?>
@@ -113,7 +112,7 @@ if ($_GET["msg"]) label == 'PostgreSQL') + else if ($db::$label == 'PostgreSQL') { ?>
@@ -123,7 +122,7 @@ if ($_GET["msg"]) } else { - print 'No method available with database '.$db->label; + print 'No method available with database '.$db::$label; } ?>
@@ -135,7 +134,7 @@ if ($_GET["msg"])
label == 'MySQL') + if ($db::$label == 'MySQL') { ?>
trans("MySqlExportParameters"); ?> @@ -218,7 +217,7 @@ if ($_GET["msg"]) label == 'PostgreSQL') + if ($db::$label == 'PostgreSQL') { ?>
trans("PostgreSqlExportParameters"); ?> @@ -282,8 +281,8 @@ if ($_GET["msg"]) id="filename_template" value="label == 'MySQL') $prefix='mysqldump'; -if ($db->label == 'PostgreSQL') $prefix='pg_dump'; +if ($db::$label == 'MySQL') $prefix='mysqldump'; +if ($db::$label == 'PostgreSQL') $prefix='pg_dump'; $file=$prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.sql'; echo $file; ?>" />
@@ -297,7 +296,7 @@ $compression=array( // 'zip' => array('function' => 'zip_open', 'id' => 'radio_compression_zip', 'label' => $langs->trans("Zip")), Not open source 'gz' => array('function' => 'gzopen', 'id' => 'radio_compression_gzip', 'label' => $langs->trans("Gzip")), ); -if ($db->label == 'MySQL') +if ($db::$label == 'MySQL') { $compression['bz']=array('function' => 'bzopen', 'id' => 'radio_compression_bzip', 'label' => $langs->trans("Bzip2")); } @@ -331,10 +330,10 @@ print "\n"; ?>
-
" id="buttonGo" />

-
+
diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index c2478149af7..28c39d2c8b2 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -69,7 +69,7 @@ print $langs->trans("RestoreDesc3",DOL_DATA_ROOT).'

';
trans("ImportMethod"); ?> label == 'MySQL') + if ($db::$label == 'MySQL') { ?>
@@ -78,7 +78,7 @@ print $langs->trans("RestoreDesc3",DOL_DATA_ROOT).'

';
label == 'PostgreSQL') + else if ($db::$label == 'PostgreSQL') { ?>
@@ -89,7 +89,7 @@ print $langs->trans("RestoreDesc3",DOL_DATA_ROOT).'

'; } else { - print 'No method available with database '.$db->label; + print 'No method available with database '.$db::$label; } ?>
@@ -101,7 +101,7 @@ print $langs->trans("RestoreDesc3",DOL_DATA_ROOT).'

';
label == 'MySQL') +if ($db::$label == 'MySQL') { ?>
@@ -135,7 +135,7 @@ if ($db->label == 'MySQL')
label == 'PostgreSQL') +else if ($db::$label == 'PostgreSQL') { ?>
diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index be59a528f29..d32bae6ed53 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -208,7 +208,7 @@ if ($what == 'mysql') @dol_delete_file($outputerror,1); @rename($outputfile,$outputerror); // Si safe_mode on et command hors du parametre exec, on a un fichier out vide donc errormsg vide - if (! $errormsg) + if (! $errormsg) { $langs->load("errors"); $errormsg=$langs->trans("ErrorFailedToRunExternalCommand"); @@ -395,7 +395,7 @@ function backup_tables($outputfile, $tables='*') // Print headers and global mysql config vars $sqlhead = ''; - $sqlhead .= "-- ".$db->label." dump via php + $sqlhead .= "-- ".$db::$label." dump via php -- -- Host: ".$db->db->host_info." Database: ".$db->database_name." -- ------------------------------------------------------ diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 9232a94442d..7287bd62944 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -34,7 +34,7 @@ class DoliDBMssql //! Database handler var $db; //! Database type - static $type='mssql'; + public $type='mssql'; //! Database label static $label='MSSQL'; //! Charset used to force charset when creating database diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index ed4bb3d9e06..696440147c5 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -34,7 +34,7 @@ class DoliDBMysql //! Database handler var $db; //! Database type - static $type='mysql'; + public $type='mysql'; //! Database label static $label='MySQL'; //! Charset used to force charset when creating database diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 8ffeebf73ac..e6b324e8739 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -34,7 +34,7 @@ class DoliDBMysqli //! Database handler var $db; //! Database type - static $type='mysqli'; + public $type='mysqli'; //! Database label static $label='MySQL'; //! Charset used to force charset when creating database diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index ba1cb4c36d0..aefe7720d08 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -32,8 +32,11 @@ */ class DoliDBPgsql { - var $db; // Database handler - static $type='pgsql'; // Name of manager + //! Database handler + var $db; + //! Database type + public $type='pgsql'; // Name of manager + //! Database label static $label='PostgreSQL'; // Label of manager //! Charset static $forcecharset='latin1'; diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index 49191d3d708..fa71cb2874d 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -34,7 +34,7 @@ class DoliDBSqlite //! Database handler var $db; //! Database type - static $type='sqlite'; + public $type='sqlite'; //! Database label static $label='Sqlite'; //! Charset used to force charset when creating database