Completed
Branch develop (f5af02)
by
unknown
17:35
created
dev/tools/test/testtcpdf.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,11 +65,11 @@
 block discarded – undo
65 65
  - To convert pfx certificate to pem: openssl pkcs12 -in tcpdf.pfx -out tcpdf.crt -nodes
66 66
 
67 67
 */
68
-$permissions=array('copy');
69
-$user_pass='aaa';
70
-$owner_pass=null;
71
-$mode=0;
72
-$pubkeys=null;
68
+$permissions = array('copy');
69
+$user_pass = 'aaa';
70
+$owner_pass = null;
71
+$mode = 0;
72
+$pubkeys = null;
73 73
 $pdf->SetProtection($permissions, $user_pass, $owner_pass, $mode, $pubkeys);
74 74
 
75 75
 // Example with public-key
Please login to merge, or discard this patch.
dev/initdemo/sftpget_and_loaddump.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 $sapi_type = php_sapi_name();
23 23
 $script_file = basename(__FILE__);
24
-$path=dirname(__FILE__).'/';
24
+$path = dirname(__FILE__).'/';
25 25
 
26 26
 // Test if batch mode
27 27
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -30,39 +30,39 @@  discard block
 block discarded – undo
30 30
 }
31 31
 
32 32
 // Global variables
33
-$error=0;
33
+$error = 0;
34 34
 
35
-$sourceserver=isset($argv[1])?$argv[1]:'';		// user@server:/src/file
36
-$password=isset($argv[2])?$argv[2]:'';
37
-$dataserver=isset($argv[3])?$argv[3]:'';
38
-$database=isset($argv[4])?$argv[4]:'';
39
-$loginbase=isset($argv[5])?$argv[5]:'';
40
-$passwordbase=isset($argv[6])?$argv[6]:'';
35
+$sourceserver = isset($argv[1]) ? $argv[1] : ''; // user@server:/src/file
36
+$password = isset($argv[2]) ? $argv[2] : '';
37
+$dataserver = isset($argv[3]) ? $argv[3] : '';
38
+$database = isset($argv[4]) ? $argv[4] : '';
39
+$loginbase = isset($argv[5]) ? $argv[5] : '';
40
+$passwordbase = isset($argv[6]) ? $argv[6] : '';
41 41
 
42 42
 // Include Dolibarr environment
43
-$res=0;
44
-if (! $res && file_exists($path."../../master.inc.php")) {
45
-	$res=@include $path."../../master.inc.php";
43
+$res = 0;
44
+if (!$res && file_exists($path."../../master.inc.php")) {
45
+	$res = @include $path."../../master.inc.php";
46 46
 }
47
-if (! $res && file_exists($path."../../htdocs/master.inc.php")) {
48
-	$res=@include $path."../../htdocs/master.inc.php";
47
+if (!$res && file_exists($path."../../htdocs/master.inc.php")) {
48
+	$res = @include $path."../../htdocs/master.inc.php";
49 49
 }
50
-if (! $res && file_exists("../master.inc.php")) {
51
-	$res=@include "../master.inc.php";
50
+if (!$res && file_exists("../master.inc.php")) {
51
+	$res = @include "../master.inc.php";
52 52
 }
53
-if (! $res && file_exists("../../master.inc.php")) {
54
-	$res=@include "../../master.inc.php";
53
+if (!$res && file_exists("../../master.inc.php")) {
54
+	$res = @include "../../master.inc.php";
55 55
 }
56
-if (! $res && file_exists("../../../master.inc.php")) {
57
-	$res=@include "../../../master.inc.php";
56
+if (!$res && file_exists("../../../master.inc.php")) {
57
+	$res = @include "../../../master.inc.php";
58 58
 }
59
-if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
60
-	$res=@include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
59
+if (!$res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
60
+	$res = @include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
61 61
 }
62
-if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
63
-	$res=@include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
62
+if (!$res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
63
+	$res = @include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
64 64
 }
65
-if (! $res) {
65
+if (!$res) {
66 66
 	die("Failed to include master.inc.php file\n");
67 67
 }
68 68
 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
  *	Main
73 73
  */
74 74
 
75
-$login='';
76
-$server='';
75
+$login = '';
76
+$server = '';
77 77
 if (preg_match('/^(.*)@(.*):(.*)$/', $sourceserver, $reg)) {
78
-	$login=$reg[1];
79
-	$server=$reg[2];
80
-	$sourcefile=$reg[3];
81
-	$targetfile=basename($sourcefile);
78
+	$login = $reg[1];
79
+	$server = $reg[2];
80
+	$sourcefile = $reg[3];
81
+	$targetfile = basename($sourcefile);
82 82
 }
83 83
 if (empty($sourceserver) || empty($server) || empty($login) || empty($sourcefile) || empty($password) || empty($database) || empty($loginbase) || empty($passwordbase)) {
84 84
 	print "Usage: $script_file login@server:/src/file.(sql|gz|bz2) passssh databaseserver databasename loginbase passbase\n";
@@ -88,22 +88,22 @@  discard block
 block discarded – undo
88 88
 }
89 89
 
90 90
 
91
-$targetdir='/tmp';
91
+$targetdir = '/tmp';
92 92
 print "Get dump file from server ".$server.", path ".$sourcefile.", connect with login ".$login." loaded into localhost\n";
93 93
 
94
-$sftpconnectstring=$sourceserver;
94
+$sftpconnectstring = $sourceserver;
95 95
 print 'SFTP connect string : '.$sftpconnectstring."\n";
96 96
 //print 'SFTP password '.$password."\n";
97 97
 
98 98
 
99 99
 // SFTP connect
100
-if (! function_exists("ssh2_connect")) {
100
+if (!function_exists("ssh2_connect")) {
101 101
 	dol_print_error('', 'ssh2_connect function does not exists'); exit(1);
102 102
 }
103 103
 
104 104
 $connection = ssh2_connect($server, 22);
105 105
 if ($connection) {
106
-	if (! @ssh2_auth_password($connection, $login, $password)) {
106
+	if (!@ssh2_auth_password($connection, $login, $password)) {
107 107
 		dol_syslog("Could not authenticate with username ".$login." . and password ".preg_replace('/./', '*', $password), LOG_ERR);
108 108
 		exit(-5);
109 109
 	} else {
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
 		print 'Get file '.$sourcefile.' into '.$targetdir.$targetfile."\n";
122 122
 		ssh2_scp_recv($connection, $sourcefile, $targetdir.$targetfile);
123 123
 
124
-		$fullcommand="cat ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
124
+		$fullcommand = "cat ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
125 125
 		if (preg_match('/\.bz2$/', $targetfile)) {
126
-			$fullcommand="bzip2 -c -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
126
+			$fullcommand = "bzip2 -c -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
127 127
 		}
128 128
 		if (preg_match('/\.gz$/', $targetfile)) {
129
-			$fullcommand="gzip -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
129
+			$fullcommand = "gzip -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
130 130
 		}
131 131
 		print "Load dump with ".$fullcommand."\n";
132
-		$output=array();
133
-		$return_var=0;
132
+		$output = array();
133
+		$return_var = 0;
134 134
 		print strftime("%Y%m%d-%H%M%S").' '.$fullcommand."\n";
135 135
 		exec($fullcommand, $output, $return_var);
136 136
 		foreach ($output as $line) {
Please login to merge, or discard this patch.
dev/initdemo/updatedemo.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 $sapi_type = php_sapi_name();
23 23
 $script_file = basename(__FILE__);
24
-$path=dirname(__FILE__).'/';
24
+$path = dirname(__FILE__).'/';
25 25
 
26 26
 // Test if batch mode
27 27
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -30,34 +30,34 @@  discard block
 block discarded – undo
30 30
 }
31 31
 
32 32
 // Global variables
33
-$error=0;
33
+$error = 0;
34 34
 
35
-$confirm=isset($argv[1])?$argv[1]:'';
35
+$confirm = isset($argv[1]) ? $argv[1] : '';
36 36
 
37 37
 // Include Dolibarr environment
38
-$res=0;
39
-if (! $res && file_exists($path."../../master.inc.php")) {
40
-	$res=@include $path."../../master.inc.php";
38
+$res = 0;
39
+if (!$res && file_exists($path."../../master.inc.php")) {
40
+	$res = @include $path."../../master.inc.php";
41 41
 }
42
-if (! $res && file_exists($path."../../htdocs/master.inc.php")) {
43
-	$res=@include $path."../../htdocs/master.inc.php";
42
+if (!$res && file_exists($path."../../htdocs/master.inc.php")) {
43
+	$res = @include $path."../../htdocs/master.inc.php";
44 44
 }
45
-if (! $res && file_exists("../master.inc.php")) {
46
-	$res=@include "../master.inc.php";
45
+if (!$res && file_exists("../master.inc.php")) {
46
+	$res = @include "../master.inc.php";
47 47
 }
48
-if (! $res && file_exists("../../master.inc.php")) {
49
-	$res=@include "../../master.inc.php";
48
+if (!$res && file_exists("../../master.inc.php")) {
49
+	$res = @include "../../master.inc.php";
50 50
 }
51
-if (! $res && file_exists("../../../master.inc.php")) {
52
-	$res=@include "../../../master.inc.php";
51
+if (!$res && file_exists("../../../master.inc.php")) {
52
+	$res = @include "../../../master.inc.php";
53 53
 }
54
-if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
55
-	$res=@include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
54
+if (!$res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
55
+	$res = @include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
56 56
 }
57
-if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
58
-	$res=@include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
57
+if (!$res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
58
+	$res = @include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
59 59
 }
60
-if (! $res) {
60
+if (!$res) {
61 61
 	die("Failed to include master.inc.php file\n");
62 62
 }
63 63
 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 }
77 77
 
78 78
 
79
-$tmp=dol_getdate(dol_now());
79
+$tmp = dol_getdate(dol_now());
80 80
 
81 81
 
82
-$tables=array(
82
+$tables = array(
83 83
 	'propal'=>array(0=>'datep', 1=>'fin_validite', 2=>'date_valid', 3=>'date_cloture'),
84 84
 	'commande'=>array(0=>'date_commande', 1=>'date_valid', 2=>'date_cloture'),
85 85
 	'facture'=>array(0=>'datec', 0=>'datef', 1=>'date_valid', 2=>'date_lim_reglement'),
@@ -92,40 +92,40 @@  discard block
 block discarded – undo
92 92
 	'ticket'=>array(0=>'datec', 1=>'date_read', 2=>'date_close')
93 93
 );
94 94
 
95
-$year=2010;
96
-$currentyear=$tmp['year'];
95
+$year = 2010;
96
+$currentyear = $tmp['year'];
97 97
 while ($year <= $currentyear) {
98 98
 	//$year=2021;
99
-	$delta1=($currentyear - $year);
100
-	$delta2=($currentyear - $year - 1);
99
+	$delta1 = ($currentyear - $year);
100
+	$delta2 = ($currentyear - $year - 1);
101 101
 	//$delta=-1;
102 102
 
103 103
 	if ($delta1) {
104 104
 		foreach ($tables as $tablekey => $tableval) {
105 105
 			print "Correct ".$tablekey." for year ".$year." and move them to current year ".$currentyear." ";
106
-			$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." < DATE_ADD(NOW(), INTERVAL -1 YEAR)";
106
+			$sql = "select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." < DATE_ADD(NOW(), INTERVAL -1 YEAR)";
107 107
 			//$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." > NOW()";
108 108
 			$resql = $db->query($sql);
109 109
 			if ($resql) {
110 110
 				$num = $db->num_rows($resql);
111
-				$i=0;
111
+				$i = 0;
112 112
 				while ($i < $num) {
113
-					$obj=$db->fetch_object($resql);
113
+					$obj = $db->fetch_object($resql);
114 114
 					if ($obj) {
115 115
 						print ".";
116
-						$sql2="UPDATE ".MAIN_DB_PREFIX.$tablekey." set ";
117
-						$j=0;
116
+						$sql2 = "UPDATE ".MAIN_DB_PREFIX.$tablekey." set ";
117
+						$j = 0;
118 118
 						foreach ($tableval as $field) {
119 119
 							if ($j) {
120
-								$sql2.=", ";
120
+								$sql2 .= ", ";
121 121
 							}
122
-							$sql2.= $field." = ".$db->ifsql("DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR) > NOW()", "DATE_ADD(".$field.", INTERVAL ".$delta2." YEAR)", "DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR)");
122
+							$sql2 .= $field." = ".$db->ifsql("DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR) > NOW()", "DATE_ADD(".$field.", INTERVAL ".$delta2." YEAR)", "DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR)");
123 123
 							$j++;
124 124
 						}
125
-						$sql2.=" WHERE rowid = ".$obj->rowid;
125
+						$sql2 .= " WHERE rowid = ".$obj->rowid;
126 126
 						//print $sql2."\n";
127 127
 						$resql2 = $db->query($sql2);
128
-						if (! $resql2) {
128
+						if (!$resql2) {
129 129
 							dol_print_error($db);
130 130
 						}
131 131
 					}
Please login to merge, or discard this patch.
dev/translation/strip_language_file.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
 $sapi_type = php_sapi_name();
48 48
 $script_file = basename(__FILE__);
49
-$path=dirname(__FILE__).'/';
49
+$path = dirname(__FILE__).'/';
50 50
 
51 51
 // Test if batch mode
52 52
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
 
59 59
 // Get and check arguments
60 60
 
61
-$lPrimary = isset($argv[1])?$argv[1]:'';
62
-$lSecondary = isset($argv[2])?$argv[2]:'';
61
+$lPrimary = isset($argv[1]) ? $argv[1] : '';
62
+$lSecondary = isset($argv[2]) ? $argv[2] : '';
63 63
 $lEnglish = 'en_US';
64
-$filesToProcess = isset($argv[3])?$argv[3]:'';
64
+$filesToProcess = isset($argv[3]) ? $argv[3] : '';
65 65
 
66 66
 if (empty($lPrimary) || empty($lSecondary) || empty($filesToProcess)) {
67 67
 	$rc = 1;
68 68
 	$msg = '***** Script to clean language files *****'."\n";
69
-	$msg.= 'Usage: ./dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n";
70
-	print $msg . "(rc=$rc).\n";
69
+	$msg .= 'Usage: ./dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n";
70
+	print $msg."(rc=$rc).\n";
71 71
 	exit($rc);
72 72
 }
73 73
 
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 if ($filesToProcess == 'all') {
80 80
 	$dir = new DirectoryIterator('htdocs/langs/'.$lPrimary);
81 81
 	while ($dir->valid()) {
82
-		if (!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) {
83
-			$files[] =  $dir->getFilename();
82
+		if (!$dir->isDot() && $dir->isFile() && !preg_match('/^\./', $dir->getFilename())) {
83
+			$files[] = $dir->getFilename();
84 84
 		}
85 85
 		$dir->next();
86 86
 	}
87
-	$filesToProcess=$files;
87
+	$filesToProcess = $files;
88 88
 } else {
89
-	$filesToProcess=explode(',', $filesToProcess);
89
+	$filesToProcess = explode(',', $filesToProcess);
90 90
 }
91 91
 
92 92
 // Arguments should be OK here.
@@ -97,28 +97,28 @@  discard block
 block discarded – undo
97 97
 	$lPrimaryFile = 'htdocs/langs/'.$lPrimary.'/'.$fileToProcess;
98 98
 	$lSecondaryFile = 'htdocs/langs/'.$lSecondary.'/'.$fileToProcess;
99 99
 	$lEnglishFile = 'htdocs/langs/'.$lEnglish.'/'.$fileToProcess;
100
-	$output = $lSecondaryFile . '.delta';
100
+	$output = $lSecondaryFile.'.delta';
101 101
 
102 102
 	print "---- Process language file ".$lSecondaryFile."\n";
103 103
 
104
-	if (! is_readable($lPrimaryFile)) {
104
+	if (!is_readable($lPrimaryFile)) {
105 105
 		$rc = 2;
106 106
 		$msg = "Cannot read primary language file $lPrimaryFile.";
107
-		print $msg . " (rc=$rc).\n";
107
+		print $msg." (rc=$rc).\n";
108 108
 		exit($rc);
109 109
 	}
110 110
 
111
-	if (! is_readable($lSecondaryFile)) {
111
+	if (!is_readable($lSecondaryFile)) {
112 112
 		$rc = 3;
113 113
 		$msg = "Cannot read secondary language file $lSecondaryFile. We discard this file.";
114
-		print $msg . "\n";
114
+		print $msg."\n";
115 115
 		continue;
116 116
 	}
117 117
 
118
-	if (! is_readable($lEnglishFile)) {
118
+	if (!is_readable($lEnglishFile)) {
119 119
 		$rc = 3;
120 120
 		$msg = "Cannot read english language file $lEnglishFile. We discard this file.";
121
-		print $msg . "\n";
121
+		print $msg."\n";
122 122
 		continue;
123 123
 	}
124 124
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
 			$a = mb_split('=', trim($line), 2);
143 143
 			if (count($a) != 2) {
144
-				print "ERROR in file $lSecondaryFile, line $cnt: " . trim($line) . "\n";
144
+				print "ERROR in file $lSecondaryFile, line $cnt: ".trim($line)."\n";
145 145
 				continue;
146 146
 			}
147 147
 
@@ -161,17 +161,17 @@  discard block
 block discarded – undo
161 161
 
162 162
 			$aSecondary[$key] = trim($value);
163 163
 		}
164
-		if (! feof($handle)) {
164
+		if (!feof($handle)) {
165 165
 			$rc = 5;
166 166
 			$msg = "Unexpected fgets() fail";
167
-			print $msg . " (rc=$rc).\n";
167
+			print $msg." (rc=$rc).\n";
168 168
 			exit($rc);
169 169
 		}
170 170
 		fclose($handle);
171 171
 	} else {
172 172
 		$rc = 6;
173 173
 		$msg = "Cannot open file $lSecondaryFile";
174
-		print $msg . " (rc=$rc).\n";
174
+		print $msg." (rc=$rc).\n";
175 175
 		exit($rc);
176 176
 	}
177 177
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
 			$a = mb_split('=', trim($line), 2);
197 197
 			if (count($a) != 2) {
198
-				print "ERROR in file $lEnglishFile, line $cnt: " . trim($line) . "\n";
198
+				print "ERROR in file $lEnglishFile, line $cnt: ".trim($line)."\n";
199 199
 				continue;
200 200
 			}
201 201
 
@@ -215,17 +215,17 @@  discard block
 block discarded – undo
215 215
 
216 216
 			$aEnglish[$key] = trim($value);
217 217
 		}
218
-		if (! feof($handle)) {
218
+		if (!feof($handle)) {
219 219
 			$rc = 5;
220 220
 			$msg = "Unexpected fgets() fail";
221
-			print $msg . " (rc=$rc).\n";
221
+			print $msg." (rc=$rc).\n";
222 222
 			exit($rc);
223 223
 		}
224 224
 		fclose($handle);
225 225
 	} else {
226 226
 		$rc = 6;
227 227
 		$msg = "Cannot open file $lEnglishFile";
228
-		print $msg . " (rc=$rc).\n";
228
+		print $msg." (rc=$rc).\n";
229 229
 		exit($rc);
230 230
 	}
231 231
 
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
 
234 234
 	// Start reading and parsing Primary. See rules in header!
235 235
 
236
-	$arrayofkeytoalwayskeep=array('DIRECTION','FONTFORPDF','FONTSIZEFORPDF','SeparatorDecimal','SeparatorThousand');
236
+	$arrayofkeytoalwayskeep = array('DIRECTION', 'FONTFORPDF', 'FONTSIZEFORPDF', 'SeparatorDecimal', 'SeparatorThousand');
237 237
 
238 238
 
239 239
 	if ($handle = fopen($lPrimaryFile, 'r')) {
240
-		if (! $oh = fopen($output, 'w')) {
240
+		if (!$oh = fopen($output, 'w')) {
241 241
 			print "ERROR in writing to file ".$output."\n";
242 242
 			exit;
243 243
 		}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
 			$a = mb_split('=', trim($line), 2);
266 266
 			if (count($a) != 2) {
267
-				print "ERROR in file $lPrimaryFile, line $cnt: " . trim($line) . "\n";
267
+				print "ERROR in file $lPrimaryFile, line $cnt: ".trim($line)."\n";
268 268
 				continue;
269 269
 			}
270 270
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 			// Key not in other file
297 297
 			if (in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key)) {
298 298
 				//print "Key $key is a key we always want to see into secondary file (line: $cnt).\n";
299
-			} elseif (! array_key_exists($key, $aSecondary)) {
299
+			} elseif (!array_key_exists($key, $aSecondary)) {
300 300
 				//print "Key $key does NOT exist in secondary language (line: $cnt).\n";
301 301
 				continue;
302 302
 			}
@@ -308,13 +308,13 @@  discard block
 block discarded – undo
308 308
 				|| in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key)
309 309
 				) {
310 310
 				//print "Key $key differs (aSecondary=".$aSecondary[$key].", aPrimary=".$aPrimary[$key].", aEnglish=".$aEnglish[$key].") so we add it into new secondary language (line: $cnt).\n";
311
-				fwrite($oh, $key."=".(empty($aSecondary[$key])?$aPrimary[$key]:$aSecondary[$key])."\n");
311
+				fwrite($oh, $key."=".(empty($aSecondary[$key]) ? $aPrimary[$key] : $aSecondary[$key])."\n");
312 312
 			}
313 313
 		}
314
-		if (! feof($handle)) {
314
+		if (!feof($handle)) {
315 315
 			$rc = 7;
316 316
 			$msg = "Unexpected fgets() fail";
317
-			print $msg . " (rc=$rc).\n";
317
+			print $msg." (rc=$rc).\n";
318 318
 			exit($rc);
319 319
 		}
320 320
 		fclose($oh);
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	} else {
323 323
 		$rc = 8;
324 324
 		$msg = "Cannot open file $lPrimaryFile";
325
-		print $msg . " (rc=$rc).\n";
325
+		print $msg." (rc=$rc).\n";
326 326
 		exit($rc);
327 327
 	}
328 328
 
Please login to merge, or discard this patch.
dev/translation/autotranslator.class.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -84,46 +84,46 @@  discard block
 block discarded – undo
84 84
 			$counter++;
85 85
 			$fileContent = null;
86 86
 			$refPath = $this->_langDir.$this->_refLang.self::DIR_SEPARATOR.$file;
87
-			$fileContent = file($refPath, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
88
-			print "Processing file " . $file . ", with ".count($fileContent)." lines<br>\n";
87
+			$fileContent = file($refPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
88
+			print "Processing file ".$file.", with ".count($fileContent)." lines<br>\n";
89 89
 
90 90
 			// Define target dirs
91
-			$targetlangs=array($this->_destlang);
91
+			$targetlangs = array($this->_destlang);
92 92
 			if ($this->_destlang == 'all') {
93
-				$targetlangs=array();
93
+				$targetlangs = array();
94 94
 
95 95
 				// If we must process all languages
96
-				$arraytmp=dol_dir_list($this->_langDir, 'directories', 0);
96
+				$arraytmp = dol_dir_list($this->_langDir, 'directories', 0);
97 97
 				foreach ($arraytmp as $dirtmp) {
98 98
 					if ($dirtmp['name'] === $this->_refLang) {
99
-						continue;	// We discard source language
99
+						continue; // We discard source language
100 100
 					}
101
-					$tmppart=explode('_', $dirtmp['name']);
101
+					$tmppart = explode('_', $dirtmp['name']);
102 102
 					if (preg_match('/^en/i', $dirtmp['name'])) {
103
-						continue;	// We discard en_* languages
103
+						continue; // We discard en_* languages
104 104
 					}
105 105
 					if (preg_match('/^fr/i', $dirtmp['name'])) {
106
-						continue;	// We discard fr_* languages
106
+						continue; // We discard fr_* languages
107 107
 					}
108 108
 					if (preg_match('/^es/i', $dirtmp['name'])) {
109
-						continue;	// We discard es_* languages
109
+						continue; // We discard es_* languages
110 110
 					}
111 111
 					if (preg_match('/ca_ES/i', $dirtmp['name'])) {
112
-						continue;	// We discard es_CA language
112
+						continue; // We discard es_CA language
113 113
 					}
114 114
 					if (preg_match('/pt_BR/i', $dirtmp['name'])) {
115
-						continue;	// We discard pt_BR language
115
+						continue; // We discard pt_BR language
116 116
 					}
117 117
 					if (preg_match('/nl_BE/i', $dirtmp['name'])) {
118
-						continue;  // We discard nl_BE language
118
+						continue; // We discard nl_BE language
119 119
 					}
120 120
 					if (preg_match('/^\./i', $dirtmp['name'])) {
121
-						continue;	// We discard files .*
121
+						continue; // We discard files .*
122 122
 					}
123 123
 					if (preg_match('/^CVS/i', $dirtmp['name'])) {
124
-						continue;	// We discard CVS
124
+						continue; // We discard CVS
125 125
 					}
126
-					$targetlangs[]=$dirtmp['name'];
126
+					$targetlangs[] = $dirtmp['name'];
127 127
 				}
128 128
 				//var_dump($targetlangs);
129 129
 			}
@@ -134,27 +134,27 @@  discard block
 block discarded – undo
134 134
 
135 135
 				$destPath = $this->_langDir.$my_destlang.self::DIR_SEPARATOR.$file;
136 136
 				// Check destination file presence
137
-				if (! file_exists($destPath)) {
137
+				if (!file_exists($destPath)) {
138 138
 					// No file present, we generate file
139
-					echo "File not found: " . $destPath . ". We generate it.<br>\n";
139
+					echo "File not found: ".$destPath.". We generate it.<br>\n";
140 140
 					$this->createTranslationFile($destPath, $my_destlang);
141 141
 				} else {
142
-					echo "Updating file: " . $destPath . "<br>\n";
142
+					echo "Updating file: ".$destPath."<br>\n";
143 143
 				}
144 144
 
145 145
 				// Translate lines
146
-				$fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
147
-				$newlines=0;
146
+				$fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
147
+				$newlines = 0;
148 148
 				foreach ($fileContent as $line) {
149 149
 					$key = $this->getLineKey($line);
150 150
 					$value = $this->getLineValue($line);
151 151
 					if ($key && $value) {
152
-						$newlines+=$this->translateFileLine($fileContentDest, $file, $key, $value, $my_destlang);
152
+						$newlines += $this->translateFileLine($fileContentDest, $file, $key, $value, $my_destlang);
153 153
 					}
154 154
 				}
155 155
 
156 156
 				$this->updateTranslationFile($destPath, $file, $my_destlang);
157
-				echo "New translated lines: " . $newlines . "<br>\n";
157
+				echo "New translated lines: ".$newlines."<br>\n";
158 158
 				//if ($counter ==3) die('fim');
159 159
 			}
160 160
 		}
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 	{
173 173
 		$this->_time_end = date('Y-m-d H:i:s');
174 174
 
175
-		if (isset($this->_translatedFiles[$file]) && count($this->_translatedFiles[$file])>0) {
175
+		if (isset($this->_translatedFiles[$file]) && count($this->_translatedFiles[$file]) > 0) {
176 176
 			$fp = fopen($destPath, 'a');
177 177
 			fwrite($fp, "\n");
178 178
 			fwrite($fp, "\n");
179 179
 			fwrite($fp, "// START - Lines generated via autotranslator.php tool (".$this->_time.").\n");
180 180
 			fwrite($fp, "// Reference language: ".$this->_refLang." -> ".$my_destlang."\n");
181 181
 			foreach ($this->_translatedFiles[$file] as $line) {
182
-				fwrite($fp, $line . "\n");
182
+				fwrite($fp, $line."\n");
183 183
 			}
184 184
 			fwrite($fp, "// STOP - Lines generated via autotranslator.php tool (".$this->_time_end.").\n");
185 185
 			fclose($fp);
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		fwrite($fp, "/*\n");
201 201
 		fwrite($fp, " * Language code: {$my_destlang}\n");
202 202
 		fwrite($fp, " * Automatic generated via autotranslator.php tool\n");
203
-		fwrite($fp, " * Generation date " . $this->_time. "\n");
203
+		fwrite($fp, " * Generation date ".$this->_time."\n");
204 204
 		fwrite($fp, " */\n");
205 205
 		fclose($fp);
206 206
 		return;
@@ -231,27 +231,27 @@  discard block
 block discarded – undo
231 231
 		}
232 232
 
233 233
 		if ($key == 'CHARSET') {
234
-			$val=$this->_outputpagecode;
234
+			$val = $this->_outputpagecode;
235 235
 		} elseif (preg_match('/^Format/', $key)) {
236
-			$val=$value;
237
-		} elseif ($value=='-') {
238
-			$val=$value;
236
+			$val = $value;
237
+		} elseif ($value == '-') {
238
+			$val = $value;
239 239
 		} else {
240 240
 			// If not translated then translate
241 241
 			if ($this->_outputpagecode == 'UTF-8') {
242
-				$val=$this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2));
242
+				$val = $this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2));
243 243
 			} else {
244
-				$val=utf8_decode($this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)));
244
+				$val = utf8_decode($this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)));
245 245
 			}
246 246
 		}
247 247
 
248
-		$val=trim($val);
248
+		$val = trim($val);
249 249
 
250 250
 		if (empty($val)) {
251 251
 			return 0;
252 252
 		}
253 253
 
254
-		$this->_translatedFiles[$file][] = $key . '=' . $val ;
254
+		$this->_translatedFiles[$file][] = $key.'='.$val;
255 255
 		return 1;
256 256
 	}
257 257
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	private function getLineValue($line)
277 277
 	{
278 278
 		$arraykey = explode('=', $line, 2);
279
-		return trim(isset($arraykey[1])?$arraykey[1]:'');
279
+		return trim(isset($arraykey[1]) ? $arraykey[1] : '');
280 280
 	}
281 281
 
282 282
 	/**
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	{
290 290
 		$dir = new DirectoryIterator($this->_langDir.$lang);
291 291
 		while ($dir->valid()) {
292
-			if (!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) {
293
-				$files[] =  $dir->getFilename();
292
+			if (!$dir->isDot() && $dir->isFile() && !preg_match('/^\./', $dir->getFilename())) {
293
+				$files[] = $dir->getFilename();
294 294
 			}
295 295
 			$dir->next();
296 296
 		}
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 	private function translateTexts($src_texts, $src_lang, $dest_lang)
309 309
 	{
310 310
 		// We want to be sure that src_lang and dest_lang are using 2 chars only
311
-		$tmp=explode('_', $src_lang);
311
+		$tmp = explode('_', $src_lang);
312 312
 		if (!empty($tmp[1]) && $tmp[0] == $tmp[1]) {
313
-			$src_lang=$tmp[0];
313
+			$src_lang = $tmp[0];
314 314
 		}
315
-		$tmp=explode('_', $dest_lang);
315
+		$tmp = explode('_', $dest_lang);
316 316
 		if (!empty($tmp[1]) && $tmp[0] == $tmp[1]) {
317
-			$dest_lang=$tmp[0];
317
+			$dest_lang = $tmp[0];
318 318
 		}
319 319
 
320 320
 		//setting language pair
321 321
 		$lang_pair = $src_lang.'|'.$dest_lang;
322 322
 
323
-		$src_text_to_translate=preg_replace('/%s/', 'SSSSS', implode('', $src_texts));
324
-		$src_text_to_translate=preg_replace('/'.preg_quote('\n\n').'/', ' NNNNN ', $src_text_to_translate);
323
+		$src_text_to_translate = preg_replace('/%s/', 'SSSSS', implode('', $src_texts));
324
+		$src_text_to_translate = preg_replace('/'.preg_quote('\n\n').'/', ' NNNNN ', $src_text_to_translate);
325 325
 
326 326
 		// Define GET URL v1
327 327
 		//$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode($src_text_to_translate)."&langpair=".urlencode($lang_pair);
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		// Send request
334 334
 		//print "Url to translate: ".$url."\n";
335 335
 
336
-		if (! function_exists("curl_init")) {
336
+		if (!function_exists("curl_init")) {
337 337
 			  print "Error, your PHP does not support curl functions.\n";
338 338
 			  die();
339 339
 		}
@@ -355,10 +355,10 @@  discard block
 block discarded – undo
355 355
 			return false;
356 356
 		}
357 357
 
358
-		$rep=$json['data']['translations'][0]['translatedText'];
359
-		$rep=preg_replace('/SSSSS/i', '%s', $rep);
360
-		$rep=preg_replace('/NNNNN/i', '\n\n', $rep);
361
-		$rep=preg_replace('/&#39;/i', '\'', $rep);
358
+		$rep = $json['data']['translations'][0]['translatedText'];
359
+		$rep = preg_replace('/SSSSS/i', '%s', $rep);
360
+		$rep = preg_replace('/NNNNN/i', '\n\n', $rep);
361
+		$rep = preg_replace('/&#39;/i', '\'', $rep);
362 362
 
363 363
 		//print "OK ".join('',$src_texts).' => '.$rep."\n";
364 364
 
Please login to merge, or discard this patch.
dev/translation/sanity_check_en_langfiles.php 1 patch
Spacing   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 
21 21
 $sapi_type = php_sapi_name();
22 22
 $script_file = basename(__FILE__);
23
-$path=dirname(__FILE__).'/';
23
+$path = dirname(__FILE__).'/';
24 24
 
25
-$web=0;
25
+$web = 0;
26 26
 
27 27
 // Test if batch mode
28 28
 if (substr($sapi_type, 0, 3) == 'cgi') {
29
-	$web=1;
29
+	$web = 1;
30 30
 }
31 31
 
32 32
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	exit;
113 113
 }
114 114
 
115
-$dups=array();
116
-$exludefiles = array('.','..','README');
115
+$dups = array();
116
+$exludefiles = array('.', '..', 'README');
117 117
 $files = array_diff($files, $exludefiles);
118 118
 // To force a file: $files=array('myfile.lang');
119 119
 if (isset($argv[2])) {
@@ -124,18 +124,18 @@  discard block
 block discarded – undo
124 124
 foreach ($files as $file) {
125 125
 	$path_file = pathinfo($file);
126 126
 	// we're only interested in .lang files
127
-	if ($path_file['extension']=='lang') {
127
+	if ($path_file['extension'] == 'lang') {
128 128
 		$content = file($workdir.$file);
129 129
 		foreach ($content as $line => $row) {
130 130
 			// don't want comment lines
131 131
 			if (substr($row, 0, 1) !== '#') {
132 132
 				// don't want lines without the separator (why should those even be here, anyway...)
133
-				if (strpos($row, '=')!==false) {
134
-					$row_array = explode('=', $row);		// $row_array[0] = key
135
-					$langstrings_3d[$path_file['basename']][$line+1]=$row_array[0];
136
-					$langstrings_3dtrans[$path_file['basename']][$line+1]=$row_array[1];
137
-					$langstrings_full[]=$row_array[0];
138
-					$langstrings_dist[$row_array[0]]=$row;
133
+				if (strpos($row, '=') !== false) {
134
+					$row_array = explode('=', $row); // $row_array[0] = key
135
+					$langstrings_3d[$path_file['basename']][$line + 1] = $row_array[0];
136
+					$langstrings_3dtrans[$path_file['basename']][$line + 1] = $row_array[1];
137
+					$langstrings_full[] = $row_array[0];
138
+					$langstrings_dist[$row_array[0]] = $row;
139 139
 				}
140 140
 			}
141 141
 		}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 foreach ($langstrings_3d as $filename => $file) {
146 146
 	foreach ($file as $linenum => $value) {
147 147
 		$keys = array_keys($langstrings_full, $value);
148
-		if (count($keys)>1) {
148
+		if (count($keys) > 1) {
149 149
 			foreach ($keys as $key) {
150 150
 				$dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]);
151 151
 			}
@@ -167,75 +167,75 @@  discard block
 block discarded – undo
167 167
 	echo "<tbody>\n";
168 168
 }
169 169
 
170
-$sduplicateinsamefile='';
171
-$sinmainandother='';
172
-$sininstallandadmin='';
173
-$sother='';
170
+$sduplicateinsamefile = '';
171
+$sinmainandother = '';
172
+$sininstallandadmin = '';
173
+$sother = '';
174 174
 
175 175
 $count = 0;
176 176
 foreach ($dups as $string => $pages) {
177 177
 	$count++;
178
-	$s='';
178
+	$s = '';
179 179
 
180 180
 	// Keyword $string
181 181
 	if ($web) {
182
-		$s.="<tr>";
182
+		$s .= "<tr>";
183 183
 	}
184 184
 	if ($web) {
185
-		$s.="<td align=\"center\">";
185
+		$s .= "<td align=\"center\">";
186 186
 	}
187 187
 	if ($web) {
188
-		$s.=$count;
188
+		$s .= $count;
189 189
 	}
190 190
 	if ($web) {
191
-		$s.="</td>";
191
+		$s .= "</td>";
192 192
 	}
193 193
 	if ($web) {
194
-		$s.="<td>";
194
+		$s .= "<td>";
195 195
 	}
196
-	$s.=$string;
196
+	$s .= $string;
197 197
 	if ($web) {
198
-		$s.="</td>";
198
+		$s .= "</td>";
199 199
 	}
200 200
 	if ($web) {
201
-		$s.="<td>";
201
+		$s .= "<td>";
202 202
 	}
203
-	if (! $web) {
204
-		$s.= ' : ';
203
+	if (!$web) {
204
+		$s .= ' : ';
205 205
 	}
206 206
 
207 207
 	// Loop on each files keyword was found
208
-	$duplicateinsamefile=0;
209
-	$inmain=0;
210
-	$inadmin=0;
208
+	$duplicateinsamefile = 0;
209
+	$inmain = 0;
210
+	$inadmin = 0;
211 211
 	foreach ($pages as $file => $lines) {
212 212
 		if ($file == 'main.lang') {
213
-			$inmain=1; $inadmin=0;
213
+			$inmain = 1; $inadmin = 0;
214 214
 		}
215
-		if ($file == 'admin.lang' && ! $inmain) {
216
-			$inadmin=1;
215
+		if ($file == 'admin.lang' && !$inmain) {
216
+			$inadmin = 1;
217 217
 		}
218 218
 
219
-		$s.=$file." ";
219
+		$s .= $file." ";
220 220
 
221 221
 		// Loop on each line keword was found into file.
222
-		$listoffilesforthisentry=array();
222
+		$listoffilesforthisentry = array();
223 223
 		foreach ($lines as $line => $translatedvalue) {
224 224
 			if (!empty($listoffilesforthisentry[$file])) {
225
-				$duplicateinsamefile=1;
225
+				$duplicateinsamefile = 1;
226 226
 			}
227
-			$listoffilesforthisentry[$file]=1;
227
+			$listoffilesforthisentry[$file] = 1;
228 228
 
229
-			$s.= "(".$line." - ".htmlentities($translatedvalue).") ";
229
+			$s .= "(".$line." - ".htmlentities($translatedvalue).") ";
230 230
 		}
231 231
 		if ($web) {
232
-			$s.="<br>";
232
+			$s .= "<br>";
233 233
 		}
234 234
 	}
235 235
 	if ($web) {
236
-		$s.="</td></tr>";
236
+		$s .= "</td></tr>";
237 237
 	}
238
-	$s.="\n";
238
+	$s .= "\n";
239 239
 
240 240
 	if ($duplicateinsamefile) {
241 241
 		$sduplicateinsamefile .= $s;
@@ -248,47 +248,47 @@  discard block
 block discarded – undo
248 248
 	}
249 249
 }
250 250
 
251
-if (! $web) {
251
+if (!$web) {
252 252
 	print "\n***** Entries duplicated in same file\n";
253 253
 }
254 254
 print $sduplicateinsamefile;
255
-if (! $web && empty($sduplicateinsamefile)) {
255
+if (!$web && empty($sduplicateinsamefile)) {
256 256
 	print "None\n";
257 257
 }
258
-if (! $web) {
258
+if (!$web) {
259 259
 	print "\n";
260 260
 }
261 261
 
262
-if (! $web) {
262
+if (!$web) {
263 263
 	print "***** Entries in main and another (keep only entry in main)\n";
264 264
 }
265 265
 print $sinmainandother;
266
-if (! $web && empty($sinmainandother)) {
266
+if (!$web && empty($sinmainandother)) {
267 267
 	print "None\n";
268 268
 }
269
-if (! $web) {
269
+if (!$web) {
270 270
 	print "\n";
271 271
 }
272 272
 
273
-if (! $web) {
273
+if (!$web) {
274 274
 	print "***** Entries in admin and another\n";
275 275
 }
276 276
 print $sininstallandadmin;
277
-if (! $web && empty($sininstallandadmin)) {
277
+if (!$web && empty($sininstallandadmin)) {
278 278
 	print "None\n";
279 279
 }
280
-if (! $web) {
280
+if (!$web) {
281 281
 	print "\n";
282 282
 }
283 283
 
284
-if (! $web) {
284
+if (!$web) {
285 285
 	print "***** Other\n";
286 286
 }
287 287
 print $sother;
288
-if (! $web && empty($sother)) {
288
+if (!$web && empty($sother)) {
289 289
 	print "None\n";
290 290
 }
291
-if (! $web) {
291
+if (!$web) {
292 292
 	print "\n";
293 293
 }
294 294
 
@@ -300,265 +300,265 @@  discard block
 block discarded – undo
300 300
 
301 301
 // STEP 2 - Search key not used
302 302
 
303
-if ((!empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1]=='unused=true')) {
303
+if ((!empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1] == 'unused=true')) {
304 304
 	print "***** Strings in en_US that are never used:\n";
305 305
 
306
-	$unused=array();
306
+	$unused = array();
307 307
 	foreach ($langstrings_dist as $value => $line) {
308
-		$qualifiedforclean=1;
308
+		$qualifiedforclean = 1;
309 309
 		// Check if we must keep this key to be into file for removal
310 310
 		if (preg_match('/^Module\d+/', $value)) {
311
-			$qualifiedforclean=0;
311
+			$qualifiedforclean = 0;
312 312
 		}
313 313
 		if (preg_match('/^Permission\d+/', $value)) {
314
-			$qualifiedforclean=0;
314
+			$qualifiedforclean = 0;
315 315
 		}
316 316
 		if (preg_match('/^PermissionAdvanced\d+/', $value)) {
317
-			$qualifiedforclean=0;
317
+			$qualifiedforclean = 0;
318 318
 		}
319 319
 		if (preg_match('/^ProfId\d+/', $value)) {
320
-			$qualifiedforclean=0;
320
+			$qualifiedforclean = 0;
321 321
 		}
322 322
 		if (preg_match('/^Delays_/', $value)) {
323
-			$qualifiedforclean=0;
323
+			$qualifiedforclean = 0;
324 324
 		}
325 325
 		if (preg_match('/^BarcodeDesc/', $value)) {
326
-			$qualifiedforclean=0;
326
+			$qualifiedforclean = 0;
327 327
 		}
328 328
 		if (preg_match('/^Extrafield/', $value)) {
329
-			$qualifiedforclean=0;
329
+			$qualifiedforclean = 0;
330 330
 		}
331 331
 		if (preg_match('/^LocalTax/', $value)) {
332
-			$qualifiedforclean=0;
332
+			$qualifiedforclean = 0;
333 333
 		}
334 334
 		if (preg_match('/^Country/', $value)) {
335
-			$qualifiedforclean=0;
335
+			$qualifiedforclean = 0;
336 336
 		}
337 337
 		if (preg_match('/^Civility/', $value)) {
338
-			$qualifiedforclean=0;
338
+			$qualifiedforclean = 0;
339 339
 		}
340 340
 		if (preg_match('/^Currency/', $value)) {
341
-			$qualifiedforclean=0;
341
+			$qualifiedforclean = 0;
342 342
 		}
343 343
 		if (preg_match('/^DemandReasonTypeSRC/', $value)) {
344
-			$qualifiedforclean=0;
344
+			$qualifiedforclean = 0;
345 345
 		}
346 346
 		if (preg_match('/^PaperFormat/', $value)) {
347
-			$qualifiedforclean=0;
347
+			$qualifiedforclean = 0;
348 348
 		}
349 349
 		if (preg_match('/^Duration/', $value)) {
350
-			$qualifiedforclean=0;
350
+			$qualifiedforclean = 0;
351 351
 		}
352 352
 		if (preg_match('/^AmountLT/', $value)) {
353
-			$qualifiedforclean=0;
353
+			$qualifiedforclean = 0;
354 354
 		}
355 355
 		if (preg_match('/^TotalLT/', $value)) {
356
-			$qualifiedforclean=0;
356
+			$qualifiedforclean = 0;
357 357
 		}
358 358
 		if (preg_match('/^Month/', $value)) {
359
-			$qualifiedforclean=0;
359
+			$qualifiedforclean = 0;
360 360
 		}
361 361
 		if (preg_match('/^MonthShort/', $value)) {
362
-			$qualifiedforclean=0;
362
+			$qualifiedforclean = 0;
363 363
 		}
364 364
 		if (preg_match('/^Day\d/', $value)) {
365
-			$qualifiedforclean=0;
365
+			$qualifiedforclean = 0;
366 366
 		}
367 367
 		if (preg_match('/^Short/', $value)) {
368
-			$qualifiedforclean=0;
368
+			$qualifiedforclean = 0;
369 369
 		}
370 370
 		if (preg_match('/^ExportDataset_/', $value)) {
371
-			$qualifiedforclean=0;
371
+			$qualifiedforclean = 0;
372 372
 		}
373 373
 		if (preg_match('/^ImportDataset_/', $value)) {
374
-			$qualifiedforclean=0;
374
+			$qualifiedforclean = 0;
375 375
 		}
376 376
 		if (preg_match('/^ActionAC_/', $value)) {
377
-			$qualifiedforclean=0;
377
+			$qualifiedforclean = 0;
378 378
 		}
379 379
 		if (preg_match('/^TypeLocaltax/', $value)) {
380
-			$qualifiedforclean=0;
380
+			$qualifiedforclean = 0;
381 381
 		}
382 382
 		if (preg_match('/^StatusProspect/', $value)) {
383
-			$qualifiedforclean=0;
383
+			$qualifiedforclean = 0;
384 384
 		}
385 385
 		if (preg_match('/^PL_/', $value)) {
386
-			$qualifiedforclean=0;
386
+			$qualifiedforclean = 0;
387 387
 		}
388 388
 		if (preg_match('/^TE_/', $value)) {
389
-			$qualifiedforclean=0;
389
+			$qualifiedforclean = 0;
390 390
 		}
391 391
 		if (preg_match('/^JuridicalStatus/', $value)) {
392
-			$qualifiedforclean=0;
392
+			$qualifiedforclean = 0;
393 393
 		}
394 394
 		if (preg_match('/^CalcMode/', $value)) {
395
-			$qualifiedforclean=0;
395
+			$qualifiedforclean = 0;
396 396
 		}
397 397
 		if (preg_match('/^newLT/', $value)) {
398
-			$qualifiedforclean=0;
398
+			$qualifiedforclean = 0;
399 399
 		}
400 400
 		if (preg_match('/^LT[0-9]/', $value)) {
401
-			$qualifiedforclean=0;
401
+			$qualifiedforclean = 0;
402 402
 		}
403 403
 		if (preg_match('/^TypeContact_contrat_/', $value)) {
404
-			$qualifiedforclean=0;
404
+			$qualifiedforclean = 0;
405 405
 		}
406 406
 		if (preg_match('/^ErrorPriceExpression/', $value)) {
407
-			$qualifiedforclean=0;
407
+			$qualifiedforclean = 0;
408 408
 		}
409 409
 		if (preg_match('/^Language_/', $value)) {
410
-			$qualifiedforclean=0;
410
+			$qualifiedforclean = 0;
411 411
 		}
412 412
 		if (preg_match('/^DescADHERENT_/', $value)) {
413
-			$qualifiedforclean=0;
413
+			$qualifiedforclean = 0;
414 414
 		}
415 415
 		if (preg_match('/^SubmitTranslation/', $value)) {
416
-			$qualifiedforclean=0;
416
+			$qualifiedforclean = 0;
417 417
 		}
418 418
 		if (preg_match('/^ModuleCompanyCode/', $value)) {
419
-			$qualifiedforclean=0;
419
+			$qualifiedforclean = 0;
420 420
 		}
421 421
 		if (preg_match('/InDolibarr$/', $value)) {
422
-			$qualifiedforclean=0;
422
+			$qualifiedforclean = 0;
423 423
 		}
424 424
 		// admin.lang
425 425
 		if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) {
426
-			$qualifiedforclean=0;
426
+			$qualifiedforclean = 0;
427 427
 		}
428 428
 		if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) {
429
-			$qualifiedforclean=0;
429
+			$qualifiedforclean = 0;
430 430
 		}
431 431
 		// boxes.lang
432 432
 		if (preg_match('/^BoxTitleLast/', $value)) {
433
-			$qualifiedforclean=0;
433
+			$qualifiedforclean = 0;
434 434
 		}
435 435
 		if (preg_match('/^BoxTitleLatest/', $value)) {
436
-			$qualifiedforclean=0;
436
+			$qualifiedforclean = 0;
437 437
 		}
438 438
 		// install.lang
439 439
 		if (preg_match('/^KeepDefaultValues/', $value)) {
440
-			$qualifiedforclean=0;
440
+			$qualifiedforclean = 0;
441 441
 		}
442 442
 		// mail.lang
443 443
 		if (preg_match('/MailingModuleDesc/i', $value)) {
444
-			$qualifiedforclean=0;
444
+			$qualifiedforclean = 0;
445 445
 		}
446 446
 		// main.lang
447 447
 		if (preg_match('/^Duration/', $value)) {
448
-			$qualifiedforclean=0;
448
+			$qualifiedforclean = 0;
449 449
 		}
450 450
 		if (preg_match('/^FormatDate/', $value)) {
451
-			$qualifiedforclean=0;
451
+			$qualifiedforclean = 0;
452 452
 		}
453 453
 		if (preg_match('/^DateFormat/', $value)) {
454
-			$qualifiedforclean=0;
454
+			$qualifiedforclean = 0;
455 455
 		}
456 456
 		if (preg_match('/^.b$/', $value)) {
457
-			$qualifiedforclean=0;
457
+			$qualifiedforclean = 0;
458 458
 		}
459 459
 		if (preg_match('/^.*Bytes$/', $value)) {
460
-			$qualifiedforclean=0;
460
+			$qualifiedforclean = 0;
461 461
 		}
462 462
 		if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) {
463
-			$qualifiedforclean=0;
463
+			$qualifiedforclean = 0;
464 464
 		}
465 465
 		if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) {
466
-			$qualifiedforclean=0;
466
+			$qualifiedforclean = 0;
467 467
 		}
468 468
 		// modulebuilder
469 469
 		if (preg_match('/^ModuleBuilderDesc/', $value)) {
470
-			$qualifiedforclean=0;
470
+			$qualifiedforclean = 0;
471 471
 		}
472 472
 		// orders
473 473
 		if (preg_match('/^OrderSource/', $value)) {
474
-			$qualifiedforclean=0;
474
+			$qualifiedforclean = 0;
475 475
 		}
476 476
 		if (preg_match('/^TypeContact_/', $value)) {
477
-			$qualifiedforclean=0;
477
+			$qualifiedforclean = 0;
478 478
 		}
479 479
 		// other.lang
480 480
 		if (preg_match('/^Notify_/', $value)) {
481
-			$qualifiedforclean=0;
481
+			$qualifiedforclean = 0;
482 482
 		}
483 483
 		if (preg_match('/^PredefinedMail/', $value)) {
484
-			$qualifiedforclean=0;
484
+			$qualifiedforclean = 0;
485 485
 		}
486 486
 		if (preg_match('/^DemoCompany/', $value)) {
487
-			$qualifiedforclean=0;
487
+			$qualifiedforclean = 0;
488 488
 		}
489 489
 		if (preg_match('/^WeightUnit/', $value)) {
490
-			$qualifiedforclean=0;
490
+			$qualifiedforclean = 0;
491 491
 		}
492 492
 		if (preg_match('/^LengthUnit/', $value)) {
493
-			$qualifiedforclean=0;
493
+			$qualifiedforclean = 0;
494 494
 		}
495 495
 		if (preg_match('/^SurfaceUnit/', $value)) {
496
-			$qualifiedforclean=0;
496
+			$qualifiedforclean = 0;
497 497
 		}
498 498
 		if (preg_match('/^VolumeUnit/', $value)) {
499
-			$qualifiedforclean=0;
499
+			$qualifiedforclean = 0;
500 500
 		}
501 501
 		if (preg_match('/^SizeUnit/', $value)) {
502
-			$qualifiedforclean=0;
502
+			$qualifiedforclean = 0;
503 503
 		}
504 504
 		if (preg_match('/^EMailText/', $value)) {
505
-			$qualifiedforclean=0;
505
+			$qualifiedforclean = 0;
506 506
 		}
507 507
 		if (preg_match('/ById$/', $value)) {
508
-			$qualifiedforclean=0;
508
+			$qualifiedforclean = 0;
509 509
 		}
510 510
 		if (preg_match('/ByLogin$/', $value)) {
511
-			$qualifiedforclean=0;
511
+			$qualifiedforclean = 0;
512 512
 		}
513 513
 		// printing
514 514
 		if (preg_match('/PrintingDriverDesc$/', $value)) {
515
-			$qualifiedforclean=0;
515
+			$qualifiedforclean = 0;
516 516
 		}
517 517
 		if (preg_match('/PrintTestDesc$/', $value)) {
518
-			$qualifiedforclean=0;
518
+			$qualifiedforclean = 0;
519 519
 		}
520 520
 		// products
521 521
 		if (preg_match('/GlobalVariableUpdaterType$/', $value)) {
522
-			$qualifiedforclean=0;
522
+			$qualifiedforclean = 0;
523 523
 		}
524 524
 		if (preg_match('/GlobalVariableUpdaterHelp$/', $value)) {
525
-			$qualifiedforclean=0;
525
+			$qualifiedforclean = 0;
526 526
 		}
527 527
 		if (preg_match('/OppStatus/', $value)) {
528
-			$qualifiedforclean=0;
528
+			$qualifiedforclean = 0;
529 529
 		}
530 530
 		if (preg_match('/AvailabilityType/', $value)) {
531
-			$qualifiedforclean=0;
531
+			$qualifiedforclean = 0;
532 532
 		}
533 533
 		if (preg_match('/CardProduct/', $value)) {
534
-			$qualifiedforclean=0;
534
+			$qualifiedforclean = 0;
535 535
 		}
536 536
 
537 537
 		if (preg_match('/sms/i', $value)) {
538
-			$qualifiedforclean=0;
538
+			$qualifiedforclean = 0;
539 539
 		}
540 540
 		if (preg_match('/TF_/i', $value)) {
541
-			$qualifiedforclean=0;
541
+			$qualifiedforclean = 0;
542 542
 		}
543 543
 		if (preg_match('/WithBankUsing/i', $value)) {
544
-			$qualifiedforclean=0;
544
+			$qualifiedforclean = 0;
545 545
 		}
546 546
 		if (preg_match('/descWORKFLOW_/i', $value)) {
547
-			$qualifiedforclean=0;
547
+			$qualifiedforclean = 0;
548 548
 		}
549 549
 
550
-		if (! $qualifiedforclean) {
550
+		if (!$qualifiedforclean) {
551 551
 			continue;
552 552
 		}
553 553
 
554 554
 		//$search = '\'trans("'.$value.'")\'';
555 555
 		$search = '-e "\''.$value.'\'" -e \'"'.$value.'"\' -e "('.$value.')" -e "('.$value.',"';
556
-		$string =  'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*';
556
+		$string = 'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*';
557 557
 		//print $string."<br>\n";
558 558
 		exec($string, $output);
559 559
 		if (empty($output)) {
560 560
 			$unused[$value] = $line;
561
-			echo $line;        // $trad contains the \n
561
+			echo $line; // $trad contains the \n
562 562
 		} else {
563 563
 			unset($output);
564 564
 			//print 'X'.$output.'Y';
@@ -568,16 +568,16 @@  discard block
 block discarded – undo
568 568
 	if (empty($unused)) {
569 569
 		print "No string not used found.\n";
570 570
 	} else {
571
-		$filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang';
571
+		$filetosave = '/tmp/'.($argv[2] ? $argv[2] : "").'notused.lang';
572 572
 		print "Strings in en_US that are never used are saved into file ".$filetosave.":\n";
573 573
 		file_put_contents($filetosave, implode("", $unused));
574 574
 		print "To remove from original file, run command :\n";
575
-		if (($argv[2]?$argv[2]:"")) {
576
-			print 'cd htdocs/langs/en_US; mv '.($argv[2]?$argv[2]:"")." ".($argv[2]?$argv[2]:"").".tmp; ";
575
+		if (($argv[2] ? $argv[2] : "")) {
576
+			print 'cd htdocs/langs/en_US; mv '.($argv[2] ? $argv[2] : "")." ".($argv[2] ? $argv[2] : "").".tmp; ";
577 577
 		}
578
-		print "diff ".($argv[2]?$argv[2]:"").".tmp ".$filetosave." | grep \< | cut  -b 3- > ".($argv[2]?$argv[2]:"");
579
-		if (($argv[2]?$argv[2]:"")) {
580
-			print "; rm ".($argv[2]?$argv[2]:"").".tmp;\n";
578
+		print "diff ".($argv[2] ? $argv[2] : "").".tmp ".$filetosave." | grep \< | cut  -b 3- > ".($argv[2] ? $argv[2] : "");
579
+		if (($argv[2] ? $argv[2] : "")) {
580
+			print "; rm ".($argv[2] ? $argv[2] : "").".tmp;\n";
581 581
 		}
582 582
 	}
583 583
 }
Please login to merge, or discard this patch.
dev/translation/autotranslator.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 $sapi_type = php_sapi_name();
30 30
 $script_file = basename(__FILE__);
31
-$path=dirname(__FILE__).'/';
31
+$path = dirname(__FILE__).'/';
32 32
 
33 33
 // Test if batch mode
34 34
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
 $langs->load("main");
46 46
 
47 47
 // Global variables
48
-$version='1.14';
49
-$error=0;
48
+$version = '1.14';
49
+$error = 0;
50 50
 
51 51
 
52 52
 // -------------------- START OF YOUR CODE HERE --------------------
53 53
 @set_time_limit(0);
54 54
 print "***** ".$script_file." (".$version.") *****\n";
55
-$dir=DOL_DOCUMENT_ROOT."/langs";
55
+$dir = DOL_DOCUMENT_ROOT."/langs";
56 56
 
57 57
 // Check parameters
58
-if (! isset($argv[3])) {
58
+if (!isset($argv[3])) {
59 59
 	print "Usage:   ".$script_file."  lang_code_src lang_code_dest|all APIKEY [langfile.lang]\n";
60 60
 	print "Example: ".$script_file."  en_US         pt_PT              123456\n";
61 61
 	print "Rem:     lang_code to use can be found on https://translate.google.com\n";
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
 print 'Argument 1='.$argv[1]."\n";
67 67
 print 'Argument 2='.$argv[2]."\n";
68 68
 print 'Argument 3='.$argv[3]."\n";
69
-$file='';
69
+$file = '';
70 70
 if (isset($argv[4])) {
71
-	$file=$argv[4];
71
+	$file = $argv[4];
72 72
 	print 'Argument 4='.$argv[4]."\n";
73 73
 }
74 74
 print 'Files will be generated/updated in directory '.$dir."\n";
75 75
 
76 76
 if ($argv[2] != 'all') {
77
-	if (! is_dir($dir.'/'.$argv[2])) {
77
+	if (!is_dir($dir.'/'.$argv[2])) {
78 78
 		print 'Create directory '.$dir.'/'.$argv[2]."\n";
79
-		$result=mkdir($dir.'/'.$argv[2]);
80
-		if (! $result) {
79
+		$result = mkdir($dir.'/'.$argv[2]);
80
+		if (!$result) {
81 81
 			$db->close();
82 82
 			return -1;
83 83
 		}
Please login to merge, or discard this patch.
dev/initdata/import-thirdparties.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -28,27 +28,27 @@  discard block
 block discarded – undo
28 28
 // Test si mode batch
29 29
 $sapi_type = php_sapi_name();
30 30
 $script_file = basename(__FILE__);
31
-$path=dirname(__FILE__).'/';
31
+$path = dirname(__FILE__).'/';
32 32
 if (substr($sapi_type, 0, 3) == 'cgi') {
33 33
 	echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
34 34
 	exit;
35 35
 }
36 36
 
37 37
 // Recupere root dolibarr
38
-$path=preg_replace('/import-thirdparties.php/i', '', $_SERVER["PHP_SELF"]);
38
+$path = preg_replace('/import-thirdparties.php/i', '', $_SERVER["PHP_SELF"]);
39 39
 require $path."../../htdocs/master.inc.php";
40 40
 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
41 41
 include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
42 42
 
43
-$delimiter=',';
44
-$enclosure='"';
45
-$linelength=10000;
46
-$escape='/';
43
+$delimiter = ',';
44
+$enclosure = '"';
45
+$linelength = 10000;
46
+$escape = '/';
47 47
 
48 48
 // Global variables
49
-$version=DOL_VERSION;
50
-$confirmed=1;
51
-$error=0;
49
+$version = DOL_VERSION;
50
+$confirmed = 1;
51
+$error = 0;
52 52
 
53 53
 
54 54
 /*
@@ -63,42 +63,42 @@  discard block
 block discarded – undo
63 63
 $filepath = $argv[2];
64 64
 $filepatherr = $filepath.'.err';
65 65
 //$defaultlang = empty($argv[3])?'en_US':$argv[3];
66
-$startlinenb = empty($argv[3])?1:$argv[3];
67
-$endlinenb = empty($argv[4])?0:$argv[4];
66
+$startlinenb = empty($argv[3]) ? 1 : $argv[3];
67
+$endlinenb = empty($argv[4]) ? 0 : $argv[4];
68 68
 
69
-if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
69
+if (empty($mode) || !in_array($mode, array('test', 'confirm', 'confirmforced')) || empty($filepath)) {
70 70
 	print "Usage:  $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
71 71
 	print "Usage:  $script_file test myfilepath.csv 2 1002\n";
72 72
 	print "\n";
73 73
 	exit(-1);
74 74
 }
75
-if (! file_exists($filepath)) {
75
+if (!file_exists($filepath)) {
76 76
 	print "Error: File ".$filepath." not found.\n";
77 77
 	print "\n";
78 78
 	exit(-1);
79 79
 }
80 80
 
81
-$ret=$user->fetch('', 'admin');
82
-if (! $ret > 0) {
81
+$ret = $user->fetch('', 'admin');
82
+if (!$ret > 0) {
83 83
 	print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
84 84
 	exit;
85 85
 }
86 86
 $user->getrights();
87 87
 
88 88
 // Ask confirmation
89
-if (! $confirmed) {
89
+if (!$confirmed) {
90 90
 	print "Hit Enter to continue or CTRL+C to stop...\n";
91 91
 	$input = trim(fgets(STDIN));
92 92
 }
93 93
 
94 94
 // Open input and output files
95 95
 $fhandle = fopen($filepath, 'r');
96
-if (! $fhandle) {
96
+if (!$fhandle) {
97 97
 	print 'Error: Failed to open file '.$filepath."\n";
98 98
 	exit(1);
99 99
 }
100 100
 $fhandleerr = fopen($filepatherr, 'w');
101
-if (! $fhandleerr) {
101
+if (!$fhandleerr) {
102 102
 	print 'Error: Failed to open file '.$filepatherr."\n";
103 103
 	exit(1);
104 104
 }
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 
109 109
 $db->begin();
110 110
 
111
-$i=0;
112
-$nboflines=0;
113
-while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) {
111
+$i = 0;
112
+$nboflines = 0;
113
+while ($fields = fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) {
114 114
 	$i++;
115
-	$errorrecord=0;
115
+	$errorrecord = 0;
116 116
 
117 117
 	if ($startlinenb && $i < $startlinenb) {
118 118
 		continue;
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	$object->client = $fields[7];
129 129
 	$object->fournisseur = $fields[8];
130 130
 
131
-	$object->name = $fields[13]?trim($fields[13]):$fields[0];
132
-	$object->name_alias = $fields[0]!=$fields[13]?trim($fields[0]):'';
131
+	$object->name = $fields[13] ?trim($fields[13]) : $fields[0];
132
+	$object->name_alias = $fields[0] != $fields[13] ?trim($fields[0]) : '';
133 133
 
134 134
 	$object->address = trim($fields[14]);
135 135
 	$object->zip = trim($fields[15]);
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 
175 175
 
176 176
 	// Extrafields
177
-	$object->array_options['options_anastate']=price2num($fields[20]);
178
-	$object->array_options['options_anaregion']=price2num($fields[17]);
177
+	$object->array_options['options_anastate'] = price2num($fields[20]);
178
+	$object->array_options['options_anaregion'] = price2num($fields[17]);
179 179
 
180
-	if (! $errorrecord) {
181
-		$ret=$object->create($user);
180
+	if (!$errorrecord) {
181
+		$ret = $object->create($user);
182 182
 		if ($ret < 0) {
183 183
 			print " - Error in create result code = ".$ret." - ".$object->errorsToString();
184 184
 			$errorrecord++;
@@ -187,24 +187,24 @@  discard block
 block discarded – undo
187 187
 		}
188 188
 	}
189 189
 
190
-	if (! $errorrecord) {
190
+	if (!$errorrecord) {
191 191
 		dol_syslog("Set price level");
192 192
 		$object->set_price_level($object->price_level, $user);
193 193
 	}
194 194
 
195 195
 	// Assign sales representative
196
-	if (! $errorrecord && $fields[3]) {
197
-		$salesrep=new User($db);
196
+	if (!$errorrecord && $fields[3]) {
197
+		$salesrep = new User($db);
198 198
 
199
-		$tmp=explode(' ', $fields[3], 2);
199
+		$tmp = explode(' ', $fields[3], 2);
200 200
 		$salesrep->firstname = trim($tmp[0]);
201 201
 		$salesrep->lastname = trim($tmp[1]);
202 202
 		if ($salesrep->lastname) {
203
-			$salesrep->login = strtolower(substr($salesrep->firstname, 0, 1)) . strtolower(substr($salesrep->lastname, 0));
203
+			$salesrep->login = strtolower(substr($salesrep->firstname, 0, 1)).strtolower(substr($salesrep->lastname, 0));
204 204
 		} else {
205
-			$salesrep->login=strtolower($salesrep->firstname);
205
+			$salesrep->login = strtolower($salesrep->firstname);
206 206
 		}
207
-		$salesrep->login=preg_replace('/ /', '', $salesrep->login);
207
+		$salesrep->login = preg_replace('/ /', '', $salesrep->login);
208 208
 		$salesrep->fetch(0, $salesrep->login);
209 209
 
210 210
 		$result = $object->add_commercial($user, $salesrep->id);
@@ -218,19 +218,19 @@  discard block
 block discarded – undo
218 218
 
219 219
 	dol_syslog("Add invoice contacts");
220 220
 	// Insert an invoice contact if there is an invoice email != standard email
221
-	if (! $errorrecord && $fields[27] && $fields[26] != $fields[27]) {
222
-		$ret1=$ret2=0;
221
+	if (!$errorrecord && $fields[27] && $fields[26] != $fields[27]) {
222
+		$ret1 = $ret2 = 0;
223 223
 
224 224
 		$contact = new Contact($db);
225 225
 		$contact->lastname = $object->name;
226
-		$contact->address=$object->address;
227
-		$contact->zip=$object->zip;
228
-		$contact->town=$object->town;
229
-		$contact->country_id=$object->country_id;
230
-		$contact->email=$fields[27];
231
-		$contact->socid=$object->id;
232
-
233
-		$ret1=$contact->create($user);
226
+		$contact->address = $object->address;
227
+		$contact->zip = $object->zip;
228
+		$contact->town = $object->town;
229
+		$contact->country_id = $object->country_id;
230
+		$contact->email = $fields[27];
231
+		$contact->socid = $object->id;
232
+
233
+		$ret1 = $contact->create($user);
234 234
 		if ($ret1 > 0) {
235 235
 			//$ret2=$contact->add_contact($object->id, 'BILLING');
236 236
 		}
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
 
245 245
 	dol_syslog("Add delivery contacts");
246 246
 	// Insert a delivery contact
247
-	if (! $errorrecord && $fields[47]) {
248
-		$ret1=$ret2=0;
247
+	if (!$errorrecord && $fields[47]) {
248
+		$ret1 = $ret2 = 0;
249 249
 
250 250
 		$contact2 = new Contact($db);
251 251
 		$contact2->lastname = 'Service livraison - '.$fields[47];
252 252
 		$contact2->address = $fields[48];
253 253
 		$contact2->zip = $fields[50];
254 254
 		$contact2->town = $fields[51];
255
-		$contact2->country_id=dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid');
256
-		$contact2->note_public=$fields[54];
257
-		$contact2->socid=$object->id;
255
+		$contact2->country_id = dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid');
256
+		$contact2->note_public = $fields[54];
257
+		$contact2->socid = $object->id;
258 258
 
259 259
 		// Extrafields
260
-		$contact2->array_options['options_anazoneliv']=price2num($fields[53]);
260
+		$contact2->array_options['options_anazoneliv'] = price2num($fields[53]);
261 261
 
262
-		$ret1=$contact2->create($user);
262
+		$ret1 = $contact2->create($user);
263 263
 		if ($ret1 > 0) {
264 264
 			//$ret2=$contact2->add_contact($object->id, 'SHIPPING');
265 265
 		}
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
 	if ($errorrecord) {
278 278
 		fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
279
-		$error++;    // $errorrecord will be reset
279
+		$error++; // $errorrecord will be reset
280 280
 	}
281 281
 }
282 282
 
Please login to merge, or discard this patch.
dev/initdata/purge-data.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 $sapi_type = php_sapi_name();
28 28
 $script_file = basename(__FILE__);
29
-$path=__DIR__.'/';
29
+$path = __DIR__.'/';
30 30
 
31 31
 // Test si mode batch
32 32
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 }
36 36
 
37 37
 // Recupere root dolibarr
38
-$path=preg_replace('/purge-data.php/i', '', $_SERVER["PHP_SELF"]);
38
+$path = preg_replace('/purge-data.php/i', '', $_SERVER["PHP_SELF"]);
39 39
 require $path."../../htdocs/master.inc.php";
40 40
 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
41 41
 include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 $langs->loadLangs(array("main", "errors"));
48 48
 
49 49
 // Global variables
50
-$version=DOL_VERSION;
51
-$error=0;
50
+$version = DOL_VERSION;
51
+$error = 0;
52 52
 
53 53
 // List of sql to execute
54
-$sqls=array(
54
+$sqls = array(
55 55
 	'user'=>array(
56 56
 		"DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user IN (SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 0 and login != 'admin') AND fk_user IN (select rowid FROM ".MAIN_DB_PREFIX."user where datec < '__DATE__')",
57 57
 		"DELETE FROM ".MAIN_DB_PREFIX."user WHERE admin = 0 and login != 'admin' AND datec < '__DATE__'",
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 $option = $argv[2];
183 183
 $date = $argv[3];
184 184
 
185
-if (empty($mode) || ! in_array($mode, array('test','confirm'))) {
185
+if (empty($mode) || !in_array($mode, array('test', 'confirm'))) {
186 186
 	print "Usage:  $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
187 187
 	print "\n";
188 188
 	print "option can be ".implode(',', array_keys($sqls))."\n";
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 	exit(-1);
196 196
 }
197 197
 if ($option != 'all') {
198
-	$listofoptions=explode(',', $option);
198
+	$listofoptions = explode(',', $option);
199 199
 	foreach ($listofoptions as $cursoroption) {
200
-		if (! in_array($cursoroption, array_keys($sqls))) {
200
+		if (!in_array($cursoroption, array_keys($sqls))) {
201 201
 			print "Usage:  $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
202 202
 			print "\n";
203 203
 			print "option '".$cursoroption."' must be in list ".implode(',', array_keys($sqls))."\n";
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	}
207 207
 }
208 208
 
209
-if (empty($date) || (! preg_match('/\d\d\d\d\-\d\d\-\d\d$/', $date) && $date != 'all')) {
209
+if (empty($date) || (!preg_match('/\d\d\d\d\-\d\d\-\d\d$/', $date) && $date != 'all')) {
210 210
 	print "Usage:  $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
211 211
 	print "\n";
212 212
 	print "date can be 'all' or 'YYYY-MM-DD' to delete record before YYYY-MM-DD\n";
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 if (!empty($argv[4])) {
222 222
 	$db->close();
223 223
 	unset($db);
224
-	$db=getDoliDBInstance($argv[4], $argv[5], $argv[6], $argv[7], $argv[8], $argv[9]);
225
-	$user=new User($db);
224
+	$db = getDoliDBInstance($argv[4], $argv[5], $argv[6], $argv[7], $argv[8], $argv[9]);
225
+	$user = new User($db);
226 226
 }
227 227
 
228 228
 //var_dump($user->db->database_name);
229
-$ret=$user->fetch('', 'admin');
230
-if (! $ret > 0) {
229
+$ret = $user->fetch('', 'admin');
230
+if (!$ret > 0) {
231 231
 	print 'An admin user with login "admin" must exists to use this script.'."\n";
232 232
 	exit;
233 233
 }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 print "User = ".$db->database_user."\n";
243 243
 print "\n";
244 244
 
245
-if (! $confirmed) {
245
+if (!$confirmed) {
246 246
 	print "Hit Enter to continue or CTRL+C to stop...\n";
247 247
 	$input = trim(fgets(STDIN));
248 248
 }
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 {
260 260
 	global $db, $sqls;
261 261
 
262
-	$error=0;
262
+	$error = 0;
263 263
 	foreach ($sqls[$family] as $sql) {
264 264
 		if (preg_match('/^@/', $sql)) {
265
-			$newfamily=preg_replace('/@/', '', $sql);
265
+			$newfamily = preg_replace('/@/', '', $sql);
266 266
 			processfamily($newfamily, $date);
267 267
 			continue;
268 268
 		}
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 
272 272
 		print "Run sql: ".$sql."\n";
273 273
 
274
-		$resql=$db->query($sql);
275
-		if (! $resql) {
274
+		$resql = $db->query($sql);
275
+		if (!$resql) {
276 276
 			if ($db->errno() != 'DB_ERROR_NOSUCHTABLE') {
277 277
 				$error++;
278 278
 			}
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 
296 296
 $db->begin();
297 297
 
298
-$listofoptions=explode(',', $option);
298
+$listofoptions = explode(',', $option);
299 299
 foreach ($listofoptions as $cursoroption) {
300
-	$oldfamily='';
300
+	$oldfamily = '';
301 301
 	foreach ($sqls as $family => $familysql) {
302 302
 		if ($cursoroption && $cursoroption != 'all' && $cursoroption != $family) {
303 303
 			continue;
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 		}
309 309
 		$oldfamily = $family;
310 310
 
311
-		$result=processfamily($family, $date);
311
+		$result = processfamily($family, $date);
312 312
 		if ($result < 0) {
313 313
 			$error++;
314 314
 			break;
Please login to merge, or discard this patch.