From 852b78f79fd59c68ebfb7997dc4d918539777731 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Aug 2014 00:53:29 +0200 Subject: [PATCH] Removed 2 other call to getStaticMember (pb with php 5.5).Fix PHPCS for constants into database driver classes. --- htdocs/admin/boxes.php | 3 ++- htdocs/admin/system/database.php | 2 +- htdocs/admin/system/index.php | 2 +- htdocs/admin/tools/dolibarr_export.php | 2 +- htdocs/admin/tools/dolibarr_import.php | 2 +- htdocs/admin/tools/export.php | 8 +++---- htdocs/core/class/infobox.class.php | 21 ++++++++++++------- htdocs/core/db/mssql.class.php | 4 ++-- htdocs/core/db/mysql.class.php | 4 ++-- htdocs/core/db/mysqli.class.php | 4 ++-- htdocs/core/db/pgsql.class.php | 4 ++-- htdocs/core/db/sqlite.class.php | 4 ++-- htdocs/core/modules/DolibarrModules.class.php | 7 ++++--- htdocs/install/fileconf.php | 6 +++--- htdocs/install/upgrade.php | 2 +- 15 files changed, 42 insertions(+), 33 deletions(-) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 0a23b26f36c69..c88d771708487 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -35,8 +35,9 @@ $rowid = GETPOST('rowid','int'); $action = GETPOST('action','alpha'); + // Define possible position of boxes -$pos_name = getStaticMember('InfoBox','listOfPages'); +$pos_name = InfoBox::getListOfPagesForBoxes(); $boxes = array(); diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index d7f39530502dd..1cacc75797166 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -44,7 +44,7 @@ // Database print ''; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index 71ce99d55250f..30bd3f80d4a50 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -86,7 +86,7 @@ // Database print '
'.$langs->trans("Database").'
'.$langs->trans("Version").''.$db::label.' '.$db->getVersion().'
'.$langs->trans("Version").''.$db::LABEL.' '.$db->getVersion().'
'.$langs->trans("DatabaseServer").''.$conf->db->host.'
'.$langs->trans("DatabasePort").''.(empty($conf->db->port)?$langs->trans("Default"):$conf->db->port).'
'.$langs->trans("DatabaseName").''.$conf->db->name.'
'; print "\n"; -$dblabel=$db::label; +$dblabel=$db::LABEL; $dbversion=$db->getVersion(); print "\n"; print '
".$langs->trans("Database")."
".$langs->trans("Version")."" .$dblabel." ".$dbversion."
'; diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 9f4e62155c25b..74037147760ce 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -65,7 +65,7 @@ $form=new Form($db); $formfile = new FormFile($db); -$label=$db::label; +$label=$db::LABEL; $help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad'; llxHeader('','',$help_url); diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index b18aefc75a544..d66df365afa50 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -38,7 +38,7 @@ * View */ -$label=$db::label; +$label=$db::LABEL; $help_url='EN:Restores|FR:Restaurations|ES:Restauraciones'; llxHeader('','',$help_url); diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index ca12f3fbc380d..57fbb045a02cd 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -416,7 +416,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." -- ------------------------------------------------------ @@ -464,11 +464,11 @@ function backup_tables($outputfile, $tables='*') fwrite($handle, "\n--\n-- Dumping data for table `".$table."`\n--\n"); if (!GETPOST("nobin_nolocks")) fwrite($handle, "LOCK TABLES `".$table."` WRITE;\n"); // Lock the table before inserting data (when the data will be imported back) if (GETPOST("nobin_disable_fk")) fwrite($handle, "ALTER TABLE `".$table."` DISABLE KEYS;\n"); - + $sql='SELECT * FROM '.$table; $result = $db->query($sql); $num_fields = $db->num_rows($result); - while($row = $db->fetch_row($result)) + while($row = $db->fetch_row($result)) { // For each row of data we print a line of INSERT fwrite($handle,'INSERT '.$delayed.$ignore.'INTO `'.$table.'` VALUES ('); @@ -497,7 +497,7 @@ function backup_tables($outputfile, $tables='*') fwrite($handle,"\n\n\n"); } } - + /* Backup Procedure structure*/ /* $result = $db->query('SHOW PROCEDURE STATUS'); diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 4138059337508..fdc2d6fbe4f45 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -23,12 +23,19 @@ */ /** - * Class to manage boxes on pages + * Class to manage boxes on pages. This is an utility class (all is static) */ class InfoBox { - static $listOfPages = array(0=>'Home'); // Nom des positions 0=Home, 1=... - + /** + * Name of positions 0=Home, 1=... + * + * @return array Array with list of zones + */ + static function getListOfPagesForBoxes() + { + return array(0=>'Home'); + } /** * Return array of boxes qualified for area and user @@ -137,12 +144,12 @@ static function listBoxes($db, $mode, $zone, $user, $excludelist=array()) $arrayelem=explode('|',$moduleelem); $tmpenabled=0; // $tmpenabled is used for the '|' test (OR) foreach($arrayelem as $module) - { + { $tmpmodule=preg_replace('/@[^@]+/','',$module); - if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1; + if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1; //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'
'; } - if (empty($tmpenabled)) // We found at least one module required that disabled + if (empty($tmpenabled)) // We found at least one module required that disabled { $enabled=0; break; @@ -150,7 +157,7 @@ static function listBoxes($db, $mode, $zone, $user, $excludelist=array()) } } //print '=>'.$boxname.'-enabled='.$enabled.'
'; - + //print 'xx module='.$module.' enabled='.$enabled; if ($enabled) $boxes[]=$box; else unset($box); diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 820706cd6f1fd..e3ba9ef6a0e26 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -33,13 +33,13 @@ class DoliDBMssql extends DoliDB //! Database type public $type='mssql'; //! Database label - const label='MSSQL'; + const LABEL='MSSQL'; //! Charset used to force charset when creating database var $forcecharset='latin1'; // Can't be static as it may be forced with a dynamic value //! Collate used to force collate when creating database var $forcecollate='latin1_swedish_ci'; // Can't be static as it may be forced with a dynamic value //! Version min database - const versionmin='2000'; + const VERSIONMIN='2000'; //! Resultset of last query private $_results; diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index ac1a6d0e2f62e..7f51091c442ca 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -34,9 +34,9 @@ class DoliDBMysql extends DoliDB //! Database type public $type='mysql'; //! Database label - const label='MySQL'; + const LABEL='MySQL'; //! Version min database - const versionmin='4.1.0'; + const VERSIONMIN='4.1.0'; //! Resultset of last query private $_results; diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index e86490ac88c57..a88a88f369bac 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -34,9 +34,9 @@ class DoliDBMysqli extends DoliDB //! Database type public $type='mysqli'; //! Database label - const label='MySQL'; + const LABEL='MySQL'; //! Version min database - const versionmin='4.1.0'; + const VERSIONMIN='4.1.0'; //! Resultset of last query private $_results; diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 9110d7cea06dd..396e780f2b65b 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -37,13 +37,13 @@ class DoliDBPgsql extends DoliDB //! Database type public $type='pgsql'; // Name of manager //! Database label - const label='PostgreSQL'; // Label of manager + const LABEL='PostgreSQL'; // Label of manager //! Charset var $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value //! Collate used to force collate when creating database var $forcecollate=''; // Can't be static as it may be forced with a dynamic value //! Version min database - const versionmin='8.4.0'; // Version min database + const VERSIONMIN='8.4.0'; // Version min database //! Resultset of last query private $_results; diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index fbae9300dddcc..dd040a9b19944 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -34,9 +34,9 @@ class DoliDBSqlite extends DoliDB //! Database type public $type='sqlite'; //! Database label - const label='PDO Sqlite'; + const LABEL='PDO Sqlite'; //! Version min database - const versionmin='3.0.0'; + const VERSIONMIN='3.0.0'; //! Resultset of last query private $_results; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 1657efa6e462d..1215f8e85e28a 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -523,8 +523,10 @@ function insert_boxes($option='') if (is_array($this->boxes)) { - foreach ($this->boxes as $key => $value) - { + $pos_name = InfoBox::getListOfPagesForBoxes(); + + foreach ($this->boxes as $key => $value) + { $file = isset($this->boxes[$key]['file'])?$this->boxes[$key]['file']:''; $note = isset($this->boxes[$key]['note'])?$this->boxes[$key]['note']:''; $enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton'])?$this->boxes[$key]['enabledbydefaulton']:'Home'; @@ -564,7 +566,6 @@ function insert_boxes($option='') { $lastid=$this->db->last_insert_id(MAIN_DB_PREFIX."boxes_def","rowid"); - $pos_name = getStaticMember('InfoBox','listOfPages'); foreach ($pos_name as $key2 => $val2) { //print 'key2='.$key2.'-val2='.$val2."
\n"; diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 7e681e1b21b66..2c6a5730100f7 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -307,10 +307,10 @@ include_once $dir."/".$file; if ($type == 'sqlite') continue; // We hide sqlite because support can't be complete unti sqlit does not manage foreign key creation after table creation - + // Version min of database - $versionbasemin=explode('.',$class::versionmin); - $note='('.$class::label.' >= '.$class::versionmin.')'; + $versionbasemin=explode('.',$class::VERSIONMIN); + $note='('.$class::LABEL.' >= '.$class::VERSIONMIN.')'; // Switch to mysql if mysqli is not present if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql'; diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index f88047e50176d..d89596e25e613 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -168,7 +168,7 @@ dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerVersion")." : $version"); // Test database version - $versionmindb=$db::versionmin; + $versionmindb=$db::VERSIONMIN; //print join('.',$versionarray).' - '.join('.',$versionmindb); if (count($versionmindb) && count($versionarray) && versioncompare($versionarray,$versionmindb) < 0)