Test Failed
Push — master ( 2c8b6d...9d1fea )
by Alxarafe
45:51
created
dolibarr/dev/tools/test/testtcpdf.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -64,11 +64,11 @@
 block discarded – undo
64 64
  - To convert pfx certificate to pem: openssl pkcs12 -in tcpdf.pfx -out tcpdf.crt -nodes
65 65
 
66 66
 */
67
-$permissions=array('copy');
68
-$user_pass='aaa';
69
-$owner_pass=null;
70
-$mode=0;
71
-$pubkeys=null;
67
+$permissions = array('copy');
68
+$user_pass = 'aaa';
69
+$owner_pass = null;
70
+$mode = 0;
71
+$pubkeys = null;
72 72
 $pdf->SetProtection($permissions, $user_pass, $owner_pass, $mode, $pubkeys);
73 73
 
74 74
 // Example with public-key
Please login to merge, or discard this patch.
dolibarr/dev/examples/code/create_invoice.php 3 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -83,19 +83,19 @@  discard block
 block discarded – undo
83 83
 $idobject=$obj->create($user);
84 84
 if ($idobject > 0)
85 85
 {
86
-	// Change status to validated
87
-	$result=$obj->validate($user);
88
-	if ($result > 0) print "OK Object created with id ".$idobject."\n";
89
-	else
90
-	{
91
-		$error++;
92
-		dol_print_error($db,$obj->error);
93
-	}
86
+    // Change status to validated
87
+    $result=$obj->validate($user);
88
+    if ($result > 0) print "OK Object created with id ".$idobject."\n";
89
+    else
90
+    {
91
+        $error++;
92
+        dol_print_error($db,$obj->error);
93
+    }
94 94
 }
95 95
 else
96 96
 {
97
-	$error++;
98
-	dol_print_error($db,$obj->error);
97
+    $error++;
98
+    dol_print_error($db,$obj->error);
99 99
 }
100 100
 
101 101
 
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 
104 104
 if (! $error)
105 105
 {
106
-	$db->commit();
107
-	print '--- end ok'."\n";
106
+    $db->commit();
107
+    print '--- end ok'."\n";
108 108
 }
109 109
 else
110 110
 {
111
-	print '--- end error code='.$error."\n";
112
-	$db->rollback();
111
+    print '--- end error code='.$error."\n";
112
+    $db->rollback();
113 113
 }
114 114
 
115 115
 $db->close();
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 $sapi_type = php_sapi_name();
27 27
 $script_file = basename(__FILE__);
28
-$path=dirname(__FILE__).'/';
28
+$path = dirname(__FILE__).'/';
29 29
 
30 30
 // Test if batch mode
31 31
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 }
35 35
 
36 36
 // Global variables
37
-$version='1.7';
38
-$error=0;
37
+$version = '1.7';
38
+$error = 0;
39 39
 
40 40
 
41 41
 // -------------------- START OF YOUR CODE HERE --------------------
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file.
45 45
 
46 46
 //$langs->setDefaultLang('en_US'); 	// To change default language of $langs
47
-$langs->load("main");				// To load language file for default language
47
+$langs->load("main"); // To load language file for default language
48 48
 @set_time_limit(0);
49 49
 
50 50
 // Load user and its permissions
51
-$result=$user->fetch('','admin');	// Load user for login 'admin'. Comment line to run as anonymous user.
52
-if (! $result > 0) { dol_print_error('',$user->error); exit; }
51
+$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
52
+if (!$result > 0) { dol_print_error('', $user->error); exit; }
53 53
 $user->getrights();
54 54
 
55 55
 
@@ -65,43 +65,43 @@  discard block
 block discarded – undo
65 65
 //$obj->initAsSpecimen();
66 66
 
67 67
 $obj->ref            = 'ABCDE';
68
-$obj->socid          = 4;	// Put id of third party (rowid in llx_societe table)
68
+$obj->socid          = 4; // Put id of third party (rowid in llx_societe table)
69 69
 $obj->date           = mktime();
70 70
 $obj->note           = 'A comment';
71 71
 $obj->cond_reglement_id = 1;
72 72
 
73
-$line1=new FactureLigne($db);
74
-$line1->tva_tx=10.0;
75
-$line1->remise_percent=0;
76
-$line1->qty=1;
77
-$line1->total_ht=100;
78
-$line1->total_tva=10;
79
-$line1->total_ttc=110;
80
-$obj->lines[]=$line1;
73
+$line1 = new FactureLigne($db);
74
+$line1->tva_tx = 10.0;
75
+$line1->remise_percent = 0;
76
+$line1->qty = 1;
77
+$line1->total_ht = 100;
78
+$line1->total_tva = 10;
79
+$line1->total_ttc = 110;
80
+$obj->lines[] = $line1;
81 81
 
82 82
 // Create invoice
83
-$idobject=$obj->create($user);
83
+$idobject = $obj->create($user);
84 84
 if ($idobject > 0)
85 85
 {
86 86
 	// Change status to validated
87
-	$result=$obj->validate($user);
87
+	$result = $obj->validate($user);
88 88
 	if ($result > 0) print "OK Object created with id ".$idobject."\n";
89 89
 	else
90 90
 	{
91 91
 		$error++;
92
-		dol_print_error($db,$obj->error);
92
+		dol_print_error($db, $obj->error);
93 93
 	}
94 94
 }
95 95
 else
96 96
 {
97 97
 	$error++;
98
-	dol_print_error($db,$obj->error);
98
+	dol_print_error($db, $obj->error);
99 99
 }
100 100
 
101 101
 
102 102
 // -------------------- END OF YOUR CODE --------------------
103 103
 
104
-if (! $error)
104
+if (!$error)
105 105
 {
106 106
 	$db->commit();
107 107
 	print '--- end ok'."\n";
Please login to merge, or discard this patch.
Braces   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 {
86 86
 	// Change status to validated
87 87
 	$result=$obj->validate($user);
88
-	if ($result > 0) print "OK Object created with id ".$idobject."\n";
89
-	else
88
+	if ($result > 0) {
89
+	    print "OK Object created with id ".$idobject."\n";
90
+	} else
90 91
 	{
91 92
 		$error++;
92 93
 		dol_print_error($db,$obj->error);
93 94
 	}
94
-}
95
-else
95
+} else
96 96
 {
97 97
 	$error++;
98 98
 	dol_print_error($db,$obj->error);
@@ -105,8 +105,7 @@  discard block
 block discarded – undo
105 105
 {
106 106
 	$db->commit();
107 107
 	print '--- end ok'."\n";
108
-}
109
-else
108
+} else
110 109
 {
111 110
 	print '--- end error code='.$error."\n";
112 111
 	$db->rollback();
Please login to merge, or discard this patch.
dolibarr/dev/examples/code/get_contracts.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 $sapi_type = php_sapi_name();
27 27
 $script_file = basename(__FILE__);
28
-$path=dirname(__FILE__).'/';
28
+$path = dirname(__FILE__).'/';
29 29
 
30 30
 // Test if batch mode
31 31
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 }
35 35
 
36 36
 // Global variables
37
-$version='1.7';
38
-$error=0;
37
+$version = '1.7';
38
+$error = 0;
39 39
 
40 40
 
41 41
 // -------------------- START OF YOUR CODE HERE --------------------
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file.
45 45
 
46 46
 //$langs->setDefaultLang('en_US'); 	// To change default language of $langs
47
-$langs->load("main");				// To load language file for default language
47
+$langs->load("main"); // To load language file for default language
48 48
 @set_time_limit(0);
49 49
 
50 50
 // Load user and its permissions
51
-$result=$user->fetch('','admin');	// Load user for login 'admin'. Comment line to run as anonymous user.
52
-if (! $result > 0) { dol_print_error('',$user->error); exit; }
51
+$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
52
+if (!$result > 0) { dol_print_error('', $user->error); exit; }
53 53
 $user->getrights();
54 54
 
55 55
 
56 56
 print "***** ".$script_file." (".$version.") *****\n";
57
-if (! isset($argv[1])) {	// Check parameters
57
+if (!isset($argv[1])) {	// Check parameters
58 58
     print "Usage: ".$script_file." id_thirdparty ...\n";
59 59
     exit;
60 60
 }
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 
70 70
 // Create contract object
71 71
 $obj = new Contrat($db);
72
-$obj->socid=$argv[1];
72
+$obj->socid = $argv[1];
73 73
 
74
-$listofcontractsforcompany=$obj->getListOfContracts('all');
74
+$listofcontractsforcompany = $obj->getListOfContracts('all');
75 75
 
76 76
 print $listofcontractsforcompany;
77 77
 
Please login to merge, or discard this patch.
dolibarr/dev/examples/code/create_user.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -71,23 +71,23 @@  discard block
 block discarded – undo
71 71
 $idobject=$obj->create($user);
72 72
 if ($idobject > 0)
73 73
 {
74
-	// Change status to validated
75
-	$result=$obj->setStatut(1);
76
-	if ($result > 0) print "OK Object created with id ".$idobject."\n";
77
-	else
78
-	{
79
-		$error++;
80
-		dol_print_error($db,$obj->error);
81
-	}
74
+    // Change status to validated
75
+    $result=$obj->setStatut(1);
76
+    if ($result > 0) print "OK Object created with id ".$idobject."\n";
77
+    else
78
+    {
79
+        $error++;
80
+        dol_print_error($db,$obj->error);
81
+    }
82 82
 }
83 83
 else if ($obj->error == 'ErrorLoginAlreadyExists')
84 84
 {
85
-     print "User with login ".$obj->login." already exists\n";
85
+        print "User with login ".$obj->login." already exists\n";
86 86
 }
87 87
 else
88 88
 {
89
-	$error++;
90
-	dol_print_error($db,$obj->error);
89
+    $error++;
90
+    dol_print_error($db,$obj->error);
91 91
 }
92 92
 
93 93
 
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 
96 96
 if (! $error)
97 97
 {
98
-	$db->commit();
99
-	print '--- end ok'."\n";
98
+    $db->commit();
99
+    print '--- end ok'."\n";
100 100
 }
101 101
 else
102 102
 {
103
-	print '--- end error code='.$error."\n";
104
-	$db->rollback();
103
+    print '--- end error code='.$error."\n";
104
+    $db->rollback();
105 105
 }
106 106
 
107 107
 $db->close();
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 $sapi_type = php_sapi_name();
27 27
 $script_file = basename(__FILE__);
28
-$path=dirname(__FILE__).'/';
28
+$path = dirname(__FILE__).'/';
29 29
 
30 30
 // Test if batch mode
31 31
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 }
35 35
 
36 36
 // Global variables
37
-$version='1.7';
38
-$error=0;
37
+$version = '1.7';
38
+$error = 0;
39 39
 
40 40
 
41 41
 // -------------------- START OF YOUR CODE HERE --------------------
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file.
45 45
 
46 46
 //$langs->setDefaultLang('en_US'); 	// To change default language of $langs
47
-$langs->load("main");				// To load language file for default language
47
+$langs->load("main"); // To load language file for default language
48 48
 @set_time_limit(0);
49 49
 
50 50
 // Load user and its permissions
51
-$result=$user->fetch('','admin');	// Load user for login 'admin'. Comment line to run as anonymous user.
52
-if (! $result > 0) { dol_print_error('',$user->error); exit; }
51
+$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
52
+if (!$result > 0) { dol_print_error('', $user->error); exit; }
53 53
 $user->getrights();
54 54
 
55 55
 
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
 $obj->nom   = 'ABCDEF';
69 69
 
70 70
 // Create user
71
-$idobject=$obj->create($user);
71
+$idobject = $obj->create($user);
72 72
 if ($idobject > 0)
73 73
 {
74 74
 	// Change status to validated
75
-	$result=$obj->setStatut(1);
75
+	$result = $obj->setStatut(1);
76 76
 	if ($result > 0) print "OK Object created with id ".$idobject."\n";
77 77
 	else
78 78
 	{
79 79
 		$error++;
80
-		dol_print_error($db,$obj->error);
80
+		dol_print_error($db, $obj->error);
81 81
 	}
82 82
 }
83 83
 else if ($obj->error == 'ErrorLoginAlreadyExists')
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
 else
88 88
 {
89 89
 	$error++;
90
-	dol_print_error($db,$obj->error);
90
+	dol_print_error($db, $obj->error);
91 91
 }
92 92
 
93 93
 
94 94
 // -------------------- END OF YOUR CODE --------------------
95 95
 
96
-if (! $error)
96
+if (!$error)
97 97
 {
98 98
 	$db->commit();
99 99
 	print '--- end ok'."\n";
Please login to merge, or discard this patch.
Braces   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -73,18 +73,17 @@  discard block
 block discarded – undo
73 73
 {
74 74
 	// Change status to validated
75 75
 	$result=$obj->setStatut(1);
76
-	if ($result > 0) print "OK Object created with id ".$idobject."\n";
77
-	else
76
+	if ($result > 0) {
77
+	    print "OK Object created with id ".$idobject."\n";
78
+	} else
78 79
 	{
79 80
 		$error++;
80 81
 		dol_print_error($db,$obj->error);
81 82
 	}
82
-}
83
-else if ($obj->error == 'ErrorLoginAlreadyExists')
83
+} else if ($obj->error == 'ErrorLoginAlreadyExists')
84 84
 {
85 85
      print "User with login ".$obj->login." already exists\n";
86
-}
87
-else
86
+} else
88 87
 {
89 88
 	$error++;
90 89
 	dol_print_error($db,$obj->error);
@@ -97,8 +96,7 @@  discard block
 block discarded – undo
97 96
 {
98 97
 	$db->commit();
99 98
 	print '--- end ok'."\n";
100
-}
101
-else
99
+} else
102 100
 {
103 101
 	print '--- end error code='.$error."\n";
104 102
 	$db->rollback();
Please login to merge, or discard this patch.
dolibarr/dev/examples/code/create_order.php 3 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -81,19 +81,19 @@  discard block
 block discarded – undo
81 81
 $idobject=$com->create($user);
82 82
 if ($idobject > 0)
83 83
 {
84
-	// Change status to validated
85
-	$result=$com->valid($user);
86
-	if ($result > 0) print "OK Object created with id ".$idobject."\n";
87
-	else
88
-	{
89
-		$error++;
90
-		dol_print_error($db,$com->error);
91
-	}
84
+    // Change status to validated
85
+    $result=$com->valid($user);
86
+    if ($result > 0) print "OK Object created with id ".$idobject."\n";
87
+    else
88
+    {
89
+        $error++;
90
+        dol_print_error($db,$com->error);
91
+    }
92 92
 }
93 93
 else
94 94
 {
95
-	$error++;
96
-	dol_print_error($db,$com->error);
95
+    $error++;
96
+    dol_print_error($db,$com->error);
97 97
 }
98 98
 
99 99
 
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
 
102 102
 if (! $error)
103 103
 {
104
-	$db->commit();
105
-	print '--- end ok'."\n";
104
+    $db->commit();
105
+    print '--- end ok'."\n";
106 106
 }
107 107
 else
108 108
 {
109
-	print '--- end error code='.$error."\n";
110
-	$db->rollback();
109
+    print '--- end error code='.$error."\n";
110
+    $db->rollback();
111 111
 }
112 112
 
113 113
 $db->close();
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 $sapi_type = php_sapi_name();
27 27
 $script_file = basename(__FILE__);
28
-$path=dirname(__FILE__).'/';
28
+$path = dirname(__FILE__).'/';
29 29
 
30 30
 // Test if batch mode
31 31
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 }
35 35
 
36 36
 // Global variables
37
-$version='1.11';
38
-$error=0;
37
+$version = '1.11';
38
+$error = 0;
39 39
 
40 40
 
41 41
 // -------------------- START OF YOUR CODE HERE --------------------
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file.
45 45
 
46 46
 //$langs->setDefaultLang('en_US'); 	// To change default language of $langs
47
-$langs->load("main");				// To load language file for default language
47
+$langs->load("main"); // To load language file for default language
48 48
 @set_time_limit(0);
49 49
 
50 50
 // Load user and its permissions
51
-$result=$user->fetch('','admin');	// Load user for login 'admin'. Comment line to run as anonymous user.
52
-if (! $result > 0) { dol_print_error('',$user->error); exit; }
51
+$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
52
+if (!$result > 0) { dol_print_error('', $user->error); exit; }
53 53
 $user->getrights();
54 54
 
55 55
 
@@ -65,41 +65,41 @@  discard block
 block discarded – undo
65 65
 $com = new Commande($db);
66 66
 
67 67
 $com->ref            = 'ABCDE';
68
-$com->socid          = 4;	// Put id of third party (rowid in llx_societe table)
68
+$com->socid          = 4; // Put id of third party (rowid in llx_societe table)
69 69
 $com->date_commande  = mktime();
70 70
 $com->note           = 'A comment';
71 71
 $com->source         = 1;
72 72
 $com->remise_percent = 0;
73 73
 
74
-$orderline1=new OrderLine($db);
75
-$orderline1->tva_tx=10.0;
76
-$orderline1->remise_percent=0;
77
-$orderline1->qty=1;
78
-$com->lines[]=$orderline1;
74
+$orderline1 = new OrderLine($db);
75
+$orderline1->tva_tx = 10.0;
76
+$orderline1->remise_percent = 0;
77
+$orderline1->qty = 1;
78
+$com->lines[] = $orderline1;
79 79
 
80 80
 // Create order
81
-$idobject=$com->create($user);
81
+$idobject = $com->create($user);
82 82
 if ($idobject > 0)
83 83
 {
84 84
 	// Change status to validated
85
-	$result=$com->valid($user);
85
+	$result = $com->valid($user);
86 86
 	if ($result > 0) print "OK Object created with id ".$idobject."\n";
87 87
 	else
88 88
 	{
89 89
 		$error++;
90
-		dol_print_error($db,$com->error);
90
+		dol_print_error($db, $com->error);
91 91
 	}
92 92
 }
93 93
 else
94 94
 {
95 95
 	$error++;
96
-	dol_print_error($db,$com->error);
96
+	dol_print_error($db, $com->error);
97 97
 }
98 98
 
99 99
 
100 100
 // -------------------- END OF YOUR CODE --------------------
101 101
 
102
-if (! $error)
102
+if (!$error)
103 103
 {
104 104
 	$db->commit();
105 105
 	print '--- end ok'."\n";
Please login to merge, or discard this patch.
Braces   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
 {
84 84
 	// Change status to validated
85 85
 	$result=$com->valid($user);
86
-	if ($result > 0) print "OK Object created with id ".$idobject."\n";
87
-	else
86
+	if ($result > 0) {
87
+	    print "OK Object created with id ".$idobject."\n";
88
+	} else
88 89
 	{
89 90
 		$error++;
90 91
 		dol_print_error($db,$com->error);
91 92
 	}
92
-}
93
-else
93
+} else
94 94
 {
95 95
 	$error++;
96 96
 	dol_print_error($db,$com->error);
@@ -103,8 +103,7 @@  discard block
 block discarded – undo
103 103
 {
104 104
 	$db->commit();
105 105
 	print '--- end ok'."\n";
106
-}
107
-else
106
+} else
108 107
 {
109 108
 	print '--- end error code='.$error."\n";
110 109
 	$db->rollback();
Please login to merge, or discard this patch.
dolibarr/dev/examples/code/create_product.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -81,25 +81,25 @@
 block discarded – undo
81 81
 $idobject = $myproduct->create($user);
82 82
 if ($idobject > 0)
83 83
 {
84
-	print "OK Object created with id ".$idobject."\n";
84
+    print "OK Object created with id ".$idobject."\n";
85 85
 }
86 86
 else
87 87
 {
88
-	$error++;
89
-	dol_print_error($db,$myproduct->error);
88
+    $error++;
89
+    dol_print_error($db,$myproduct->error);
90 90
 }
91 91
 
92 92
 // -------------------- END OF YOUR CODE --------------------
93 93
 
94 94
 if (! $error)
95 95
 {
96
-	$db->commit();
97
-	print '--- end ok'."\n";
96
+    $db->commit();
97
+    print '--- end ok'."\n";
98 98
 }
99 99
 else
100 100
 {
101
-	print '--- end error code='.$error."\n";
102
-	$db->rollback();
101
+    print '--- end error code='.$error."\n";
102
+    $db->rollback();
103 103
 }
104 104
 
105 105
 $db->close();
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 $sapi_type = php_sapi_name();
27 27
 $script_file = basename(__FILE__);
28
-$path=dirname(__FILE__).'/';
28
+$path = dirname(__FILE__).'/';
29 29
 
30 30
 // Test if batch mode
31 31
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 }
35 35
 
36 36
 // Global variables
37
-$version='1.10';
38
-$error=0;
37
+$version = '1.10';
38
+$error = 0;
39 39
 
40 40
 
41 41
 // -------------------- START OF YOUR CODE HERE --------------------
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 // After this $db, $mysoc, $langs and $conf->entity are defined. Opened handler to database will be closed at end of file.
45 45
 
46 46
 //$langs->setDefaultLang('en_US'); 	// To change default language of $langs
47
-$langs->load("main");				// To load language file for default language
47
+$langs->load("main"); // To load language file for default language
48 48
 @set_time_limit(0);
49 49
 
50 50
 // Load user and its permissions
51
-$result=$user->fetch('','admin');	// Load user for login 'admin'. Comment line to run as anonymous user.
52
-if (! $result > 0) { dol_print_error('',$user->error); exit; }
51
+$result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
52
+if (!$result > 0) { dol_print_error('', $user->error); exit; }
53 53
 $user->getrights();
54 54
 
55 55
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
63 63
 
64 64
 // Create instance of object
65
-$myproduct=new Product($db);
65
+$myproduct = new Product($db);
66 66
 
67 67
 // Definition of product instance properties
68 68
 $myproduct->ref                = '1234';
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 else
87 87
 {
88 88
 	$error++;
89
-	dol_print_error($db,$myproduct->error);
89
+	dol_print_error($db, $myproduct->error);
90 90
 }
91 91
 
92 92
 // -------------------- END OF YOUR CODE --------------------
93 93
 
94
-if (! $error)
94
+if (!$error)
95 95
 {
96 96
 	$db->commit();
97 97
 	print '--- end ok'."\n";
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@  discard block
 block discarded – undo
82 82
 if ($idobject > 0)
83 83
 {
84 84
 	print "OK Object created with id ".$idobject."\n";
85
-}
86
-else
85
+} else
87 86
 {
88 87
 	$error++;
89 88
 	dol_print_error($db,$myproduct->error);
@@ -95,8 +94,7 @@  discard block
 block discarded – undo
95 94
 {
96 95
 	$db->commit();
97 96
 	print '--- end ok'."\n";
98
-}
99
-else
97
+} else
100 98
 {
101 99
 	print '--- end error code='.$error."\n";
102 100
 	$db->rollback();
Please login to merge, or discard this patch.
dolibarr/dev/translation/autotranslator.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -69,23 +69,23 @@
 block discarded – undo
69 69
 $file='';
70 70
 if (isset($argv[4]))
71 71
 {
72
-	$file=$argv[4];
73
-	print 'Argument 4='.$argv[4]."\n";
72
+    $file=$argv[4];
73
+    print 'Argument 4='.$argv[4]."\n";
74 74
 }
75 75
 print 'Files will be generated/updated in directory '.$dir."\n";
76 76
 
77 77
 if ($argv[2] != 'all')
78 78
 {
79
-	if (! is_dir($dir.'/'.$argv[2]))
80
-	{
81
-		print 'Create directory '.$dir.'/'.$argv[2]."\n";
82
-		$result=mkdir($dir.'/'.$argv[2]);
83
-		if (! $result)
84
-		{
85
-			$db->close();
86
-			return -1;
87
-		}
88
-	}
79
+    if (! is_dir($dir.'/'.$argv[2]))
80
+    {
81
+        print 'Create directory '.$dir.'/'.$argv[2]."\n";
82
+        $result=mkdir($dir.'/'.$argv[2]);
83
+        if (! $result)
84
+        {
85
+            $db->close();
86
+            return -1;
87
+        }
88
+    }
89 89
 }
90 90
 
91 91
 require_once DOL_DOCUMENT_ROOT."/../dev/translation/autotranslator.class.php";
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 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 http://www.google.com/language_tools\n";
@@ -66,21 +66,21 @@  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 71
 {
72
-	$file=$argv[4];
72
+	$file = $argv[4];
73 73
 	print 'Argument 4='.$argv[4]."\n";
74 74
 }
75 75
 print 'Files will be generated/updated in directory '.$dir."\n";
76 76
 
77 77
 if ($argv[2] != 'all')
78 78
 {
79
-	if (! is_dir($dir.'/'.$argv[2]))
79
+	if (!is_dir($dir.'/'.$argv[2]))
80 80
 	{
81 81
 		print 'Create directory '.$dir.'/'.$argv[2]."\n";
82
-		$result=mkdir($dir.'/'.$argv[2]);
83
-		if (! $result)
82
+		$result = mkdir($dir.'/'.$argv[2]);
83
+		if (!$result)
84 84
 		{
85 85
 			$db->close();
86 86
 			return -1;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
 require_once DOL_DOCUMENT_ROOT."/../dev/translation/autotranslator.class.php";
92 92
 
93
-$langParser = new autoTranslator($argv[2],$argv[1],$dir,$file,$argv[3]);
93
+$langParser = new autoTranslator($argv[2], $argv[1], $dir, $file, $argv[3]);
94 94
 
95 95
 print "***** Finished *****\n";
96 96
 
Please login to merge, or discard this patch.
dolibarr/dev/translation/strip_language_file.php 3 patches
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 
51 51
 // Test if batch mode
52 52
 if (substr($sapi_type, 0, 3) == 'cgi') {
53
-	echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
54
-	exit;
53
+    echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
54
+    exit;
55 55
 }
56 56
 
57 57
 $rc = 0;
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 
66 66
 if (empty($lPrimary) || empty($lSecondary) || empty($filesToProcess))
67 67
 {
68
-	$rc = 1;
69
-	$msg = '***** Script to clean language files *****'."\n";
70
-	$msg.= 'Usage: ./dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n";
71
-	print $msg . "(rc=$rc).\n";
72
-	exit($rc);
68
+    $rc = 1;
69
+    $msg = '***** Script to clean language files *****'."\n";
70
+    $msg.= 'Usage: ./dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n";
71
+    print $msg . "(rc=$rc).\n";
72
+    exit($rc);
73 73
 }
74 74
 
75 75
 $aPrimary = array();
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 // Define array $filesToProcess
80 80
 if ($filesToProcess == 'all')
81 81
 {
82
-	$dir = new DirectoryIterator('htdocs/langs/'.$lPrimary);
83
-	while($dir->valid()) {
84
-		if(!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./',$dir->getFilename())) {
85
-			$files[] =  $dir->getFilename();
86
-		}
87
-		$dir->next();
88
-	}
89
-	$filesToProcess=$files;
82
+    $dir = new DirectoryIterator('htdocs/langs/'.$lPrimary);
83
+    while($dir->valid()) {
84
+        if(!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./',$dir->getFilename())) {
85
+            $files[] =  $dir->getFilename();
86
+        }
87
+        $dir->next();
88
+    }
89
+    $filesToProcess=$files;
90 90
 }
91 91
 else $filesToProcess=explode(',',$filesToProcess);
92 92
 
@@ -96,257 +96,257 @@  discard block
 block discarded – undo
96 96
 // Loop on each file
97 97
 foreach($filesToProcess as $fileToProcess)
98 98
 {
99
-	$lPrimaryFile = 'htdocs/langs/'.$lPrimary.'/'.$fileToProcess;
100
-	$lSecondaryFile = 'htdocs/langs/'.$lSecondary.'/'.$fileToProcess;
101
-	$lEnglishFile = 'htdocs/langs/'.$lEnglish.'/'.$fileToProcess;
102
-	$output = $lSecondaryFile . '.delta';
103
-
104
-	print "---- Process language file ".$lSecondaryFile."\n";
105
-
106
-	if ( ! is_readable($lPrimaryFile) ) {
107
-		$rc = 2;
108
-		$msg = "Cannot read primary language file $lPrimaryFile.";
109
-		print $msg . " (rc=$rc).\n";
110
-		exit($rc);
111
-	}
112
-
113
-	if ( ! is_readable($lSecondaryFile) ) {
114
-		$rc = 3;
115
-		$msg = "Cannot read secondary language file $lSecondaryFile. We discard this file.";
116
-		print $msg . "\n";
117
-		continue;
118
-	}
119
-
120
-	if ( ! is_readable($lEnglishFile) ) {
121
-		$rc = 3;
122
-		$msg = "Cannot read english language file $lEnglishFile. We discard this file.";
123
-		print $msg . "\n";
124
-		continue;
125
-	}
126
-
127
-	// Start reading and parsing Secondary
128
-
129
-	if ( $handle = fopen($lSecondaryFile, 'r') )
130
-	{
131
-		print "Read Secondary File $lSecondaryFile:\n";
132
-		$cnt = 0;
133
-		while (($line = fgets($handle)) !== false)
134
-		{
135
-			$cnt++;
136
-
137
-			// strip comments
138
-			if ( preg_match("/^\w*#/", $line) ) {
139
-				continue;
140
-			}
141
-			// strip empty lines
142
-			if ( preg_match("/^\w*$/", $line) ) {
143
-				continue;
144
-			}
145
-
146
-			$a = mb_split('=', trim($line), 2);
147
-			if ( count($a) != 2 ) {
148
-				print "ERROR in file $lSecondaryFile, line $cnt: " . trim($line) . "\n";
149
-				continue;
150
-			}
151
-
152
-			list($key, $value) = $a;
153
-
154
-			// key is redundant
155
-			if ( array_key_exists($key, $aSecondary) ) {
156
-				print "Key $key is redundant in file $lSecondaryFile (line: $cnt).\n";
157
-				continue;
158
-			}
159
-
160
-			// String has no value
161
-			if ( $value == '' ) {
162
-				print "Key $key has no value in file $lSecondaryFile (line: $cnt).\n";
163
-				continue;
164
-			}
165
-
166
-			$aSecondary[$key] = trim($value);
167
-		}
168
-		if ( ! feof($handle) )
169
-		{
170
-			$rc = 5;
171
-			$msg = "Unexpected fgets() fail";
172
-			print $msg . " (rc=$rc).\n";
173
-			exit($rc);
174
-		}
175
-		fclose($handle);
176
-	}
177
-	else {
178
-		$rc = 6;
179
-		$msg = "Cannot open file $lSecondaryFile";
180
-		print $msg . " (rc=$rc).\n";
181
-		exit($rc);
182
-	}
183
-
184
-
185
-	// Start reading and parsing English
186
-
187
-	if ( $handle = fopen($lEnglishFile, 'r') )
188
-	{
189
-		print "Read English File $lEnglishFile:\n";
190
-		$cnt = 0;
191
-		while (($line = fgets($handle)) !== false)
192
-		{
193
-			$cnt++;
194
-
195
-			// strip comments
196
-			if ( preg_match("/^\w*#/", $line) ) {
197
-				continue;
198
-			}
199
-			// strip empty lines
200
-			if ( preg_match("/^\w*$/", $line) ) {
201
-				continue;
202
-			}
203
-
204
-			$a = mb_split('=', trim($line), 2);
205
-			if ( count($a) != 2 ) {
206
-				print "ERROR in file $lEnglishFile, line $cnt: " . trim($line) . "\n";
207
-				continue;
208
-			}
209
-
210
-			list($key, $value) = $a;
211
-
212
-			// key is redundant
213
-			if ( array_key_exists($key, $aEnglish) ) {
214
-				print "Key $key is redundant in file $lEnglishFile (line: $cnt).\n";
215
-				continue;
216
-			}
217
-
218
-			// String has no value
219
-			if ( $value == '' ) {
220
-				print "Key $key has no value in file $lEnglishFile (line: $cnt).\n";
221
-				continue;
222
-			}
223
-
224
-			$aEnglish[$key] = trim($value);
225
-		}
226
-		if ( ! feof($handle) )
227
-		{
228
-			$rc = 5;
229
-			$msg = "Unexpected fgets() fail";
230
-			print $msg . " (rc=$rc).\n";
231
-			exit($rc);
232
-		}
233
-		fclose($handle);
234
-	}
235
-	else {
236
-		$rc = 6;
237
-		$msg = "Cannot open file $lEnglishFile";
238
-		print $msg . " (rc=$rc).\n";
239
-		exit($rc);
240
-	}
241
-
242
-
243
-
244
-	// Start reading and parsing Primary. See rules in header!
245
-
246
-	$arrayofkeytoalwayskeep=array('DIRECTION','FONTFORPDF','FONTSIZEFORPDF','SeparatorDecimal','SeparatorThousand');
247
-
248
-
249
-	if ( $handle = fopen($lPrimaryFile, 'r') )
250
-	{
251
-		if ( ! $oh = fopen($output, 'w') )
252
-		{
253
-			print "ERROR in writing to file $output\n";
254
-			exit;
255
-		}
256
-
257
-		print "Read Primary File $lPrimaryFile and write ".$output.":\n";
258
-
259
-		fwrite($oh, "# Dolibarr language file - Source file is en_US - ".(preg_replace('/\.lang$/','',$fileToProcess))."\n");
260
-
261
-		$cnt = 0;
262
-		while (($line = fgets($handle)) !== false)
263
-		{
264
-			$cnt++;
265
-
266
-			// strip comments
267
-			if ( preg_match("/^\w*#/", $line) ) {
268
-				continue;
269
-			}
270
-			// strip empty lines
271
-			if ( preg_match("/^\w*$/", $line) ) {
272
-				continue;
273
-			}
274
-
275
-			$a = mb_split('=', trim($line), 2);
276
-			if ( count($a) != 2 ) {
277
-				print "ERROR in file $lPrimaryFile, line $cnt: " . trim($line) . "\n";
278
-				continue;
279
-			}
280
-
281
-			list($key, $value) = $a;
282
-
283
-			// key is redundant
284
-			if ( array_key_exists($key, $aPrimary) ) {
285
-				print "Key $key is redundant in file $lPrimaryFile (line: $cnt) - Already found into ".$fileFirstFound[$key]." (line: ".$lineFirstFound[$key].").\n";
286
-				continue;
287
-			}
288
-			else
289
-			{
290
-				$fileFirstFound[$key] = $fileToProcess;
291
-				$lineFirstFound[$key] = $cnt;
292
-			}
293
-
294
-			// String has no value
295
-			if ( $value == '' ) {
296
-				print "Key $key has no value in file $lPrimaryFile (line: $cnt).\n";
297
-				continue;
298
-			}
299
-
300
-			$aPrimary[$key] = trim($value);
301
-			$fileFirstFound[$key] = $fileToProcess;
302
-			$lineFirstFound[$key] = $cnt;
303
-
304
-			// ----- Process output now -----
305
-
306
-			//print "Found primary key = ".$key."\n";
307
-
308
-			// Key not in other file
309
-			if (in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/',$key) || preg_match('/^FormatHour/',$key))
310
-			{
311
-				//print "Key $key is a key we always want to see into secondary file (line: $cnt).\n";
312
-			}
313
-			else if ( ! array_key_exists($key, $aSecondary))
314
-			{
315
-				//print "Key $key does NOT exist in secondary language (line: $cnt).\n";
316
-				continue;
317
-			}
318
-
319
-			// String exists in both files and value into alternative language differs from main language but also from english files
320
-			if (
321
-				(! empty($aSecondary[$key]) && $aSecondary[$key] != $aPrimary[$key]
322
-			    && ! empty($aEnglish[$key]) && $aSecondary[$key] != $aEnglish[$key])
323
-				|| in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/',$key) || preg_match('/^FormatHour/',$key)
324
-				)
325
-			{
326
-				//print "Key $key differs (aSecondary=".$aSecondary[$key].", aPrimary=".$aPrimary[$key].", aEnglish=".$aEnglish[$key].") so we add it into new secondary language (line: $cnt).\n";
327
-				fwrite($oh, $key."=".(empty($aSecondary[$key])?$aPrimary[$key]:$aSecondary[$key])."\n");
328
-			}
329
-		}
330
-		if ( ! feof($handle) ) {
331
-			$rc = 7;
332
-			$msg = "Unexpected fgets() fail";
333
-			print $msg . " (rc=$rc).\n";
334
-			exit($rc);
335
-		}
336
-		fclose($oh);
337
-		fclose($handle);
338
-	}
339
-	else {
340
-		$rc = 8;
341
-		$msg = "Cannot open file $lPrimaryFile";
342
-		print $msg . " (rc=$rc).\n";
343
-		exit($rc);
344
-	}
345
-
346
-	print "Output can be found at $output.\n";
347
-
348
-	print "To rename all .delta files, you can do:\n";
349
-	print '> for fic in `ls htdocs/langs/'.$lSecondary.'/*.delta`; do f=`echo $fic | sed -e \'s/\.delta//\'`; echo $f; mv $f.delta $f; done'."\n";
99
+    $lPrimaryFile = 'htdocs/langs/'.$lPrimary.'/'.$fileToProcess;
100
+    $lSecondaryFile = 'htdocs/langs/'.$lSecondary.'/'.$fileToProcess;
101
+    $lEnglishFile = 'htdocs/langs/'.$lEnglish.'/'.$fileToProcess;
102
+    $output = $lSecondaryFile . '.delta';
103
+
104
+    print "---- Process language file ".$lSecondaryFile."\n";
105
+
106
+    if ( ! is_readable($lPrimaryFile) ) {
107
+        $rc = 2;
108
+        $msg = "Cannot read primary language file $lPrimaryFile.";
109
+        print $msg . " (rc=$rc).\n";
110
+        exit($rc);
111
+    }
112
+
113
+    if ( ! is_readable($lSecondaryFile) ) {
114
+        $rc = 3;
115
+        $msg = "Cannot read secondary language file $lSecondaryFile. We discard this file.";
116
+        print $msg . "\n";
117
+        continue;
118
+    }
119
+
120
+    if ( ! is_readable($lEnglishFile) ) {
121
+        $rc = 3;
122
+        $msg = "Cannot read english language file $lEnglishFile. We discard this file.";
123
+        print $msg . "\n";
124
+        continue;
125
+    }
126
+
127
+    // Start reading and parsing Secondary
128
+
129
+    if ( $handle = fopen($lSecondaryFile, 'r') )
130
+    {
131
+        print "Read Secondary File $lSecondaryFile:\n";
132
+        $cnt = 0;
133
+        while (($line = fgets($handle)) !== false)
134
+        {
135
+            $cnt++;
136
+
137
+            // strip comments
138
+            if ( preg_match("/^\w*#/", $line) ) {
139
+                continue;
140
+            }
141
+            // strip empty lines
142
+            if ( preg_match("/^\w*$/", $line) ) {
143
+                continue;
144
+            }
145
+
146
+            $a = mb_split('=', trim($line), 2);
147
+            if ( count($a) != 2 ) {
148
+                print "ERROR in file $lSecondaryFile, line $cnt: " . trim($line) . "\n";
149
+                continue;
150
+            }
151
+
152
+            list($key, $value) = $a;
153
+
154
+            // key is redundant
155
+            if ( array_key_exists($key, $aSecondary) ) {
156
+                print "Key $key is redundant in file $lSecondaryFile (line: $cnt).\n";
157
+                continue;
158
+            }
159
+
160
+            // String has no value
161
+            if ( $value == '' ) {
162
+                print "Key $key has no value in file $lSecondaryFile (line: $cnt).\n";
163
+                continue;
164
+            }
165
+
166
+            $aSecondary[$key] = trim($value);
167
+        }
168
+        if ( ! feof($handle) )
169
+        {
170
+            $rc = 5;
171
+            $msg = "Unexpected fgets() fail";
172
+            print $msg . " (rc=$rc).\n";
173
+            exit($rc);
174
+        }
175
+        fclose($handle);
176
+    }
177
+    else {
178
+        $rc = 6;
179
+        $msg = "Cannot open file $lSecondaryFile";
180
+        print $msg . " (rc=$rc).\n";
181
+        exit($rc);
182
+    }
183
+
184
+
185
+    // Start reading and parsing English
186
+
187
+    if ( $handle = fopen($lEnglishFile, 'r') )
188
+    {
189
+        print "Read English File $lEnglishFile:\n";
190
+        $cnt = 0;
191
+        while (($line = fgets($handle)) !== false)
192
+        {
193
+            $cnt++;
194
+
195
+            // strip comments
196
+            if ( preg_match("/^\w*#/", $line) ) {
197
+                continue;
198
+            }
199
+            // strip empty lines
200
+            if ( preg_match("/^\w*$/", $line) ) {
201
+                continue;
202
+            }
203
+
204
+            $a = mb_split('=', trim($line), 2);
205
+            if ( count($a) != 2 ) {
206
+                print "ERROR in file $lEnglishFile, line $cnt: " . trim($line) . "\n";
207
+                continue;
208
+            }
209
+
210
+            list($key, $value) = $a;
211
+
212
+            // key is redundant
213
+            if ( array_key_exists($key, $aEnglish) ) {
214
+                print "Key $key is redundant in file $lEnglishFile (line: $cnt).\n";
215
+                continue;
216
+            }
217
+
218
+            // String has no value
219
+            if ( $value == '' ) {
220
+                print "Key $key has no value in file $lEnglishFile (line: $cnt).\n";
221
+                continue;
222
+            }
223
+
224
+            $aEnglish[$key] = trim($value);
225
+        }
226
+        if ( ! feof($handle) )
227
+        {
228
+            $rc = 5;
229
+            $msg = "Unexpected fgets() fail";
230
+            print $msg . " (rc=$rc).\n";
231
+            exit($rc);
232
+        }
233
+        fclose($handle);
234
+    }
235
+    else {
236
+        $rc = 6;
237
+        $msg = "Cannot open file $lEnglishFile";
238
+        print $msg . " (rc=$rc).\n";
239
+        exit($rc);
240
+    }
241
+
242
+
243
+
244
+    // Start reading and parsing Primary. See rules in header!
245
+
246
+    $arrayofkeytoalwayskeep=array('DIRECTION','FONTFORPDF','FONTSIZEFORPDF','SeparatorDecimal','SeparatorThousand');
247
+
248
+
249
+    if ( $handle = fopen($lPrimaryFile, 'r') )
250
+    {
251
+        if ( ! $oh = fopen($output, 'w') )
252
+        {
253
+            print "ERROR in writing to file $output\n";
254
+            exit;
255
+        }
256
+
257
+        print "Read Primary File $lPrimaryFile and write ".$output.":\n";
258
+
259
+        fwrite($oh, "# Dolibarr language file - Source file is en_US - ".(preg_replace('/\.lang$/','',$fileToProcess))."\n");
260
+
261
+        $cnt = 0;
262
+        while (($line = fgets($handle)) !== false)
263
+        {
264
+            $cnt++;
265
+
266
+            // strip comments
267
+            if ( preg_match("/^\w*#/", $line) ) {
268
+                continue;
269
+            }
270
+            // strip empty lines
271
+            if ( preg_match("/^\w*$/", $line) ) {
272
+                continue;
273
+            }
274
+
275
+            $a = mb_split('=', trim($line), 2);
276
+            if ( count($a) != 2 ) {
277
+                print "ERROR in file $lPrimaryFile, line $cnt: " . trim($line) . "\n";
278
+                continue;
279
+            }
280
+
281
+            list($key, $value) = $a;
282
+
283
+            // key is redundant
284
+            if ( array_key_exists($key, $aPrimary) ) {
285
+                print "Key $key is redundant in file $lPrimaryFile (line: $cnt) - Already found into ".$fileFirstFound[$key]." (line: ".$lineFirstFound[$key].").\n";
286
+                continue;
287
+            }
288
+            else
289
+            {
290
+                $fileFirstFound[$key] = $fileToProcess;
291
+                $lineFirstFound[$key] = $cnt;
292
+            }
293
+
294
+            // String has no value
295
+            if ( $value == '' ) {
296
+                print "Key $key has no value in file $lPrimaryFile (line: $cnt).\n";
297
+                continue;
298
+            }
299
+
300
+            $aPrimary[$key] = trim($value);
301
+            $fileFirstFound[$key] = $fileToProcess;
302
+            $lineFirstFound[$key] = $cnt;
303
+
304
+            // ----- Process output now -----
305
+
306
+            //print "Found primary key = ".$key."\n";
307
+
308
+            // Key not in other file
309
+            if (in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/',$key) || preg_match('/^FormatHour/',$key))
310
+            {
311
+                //print "Key $key is a key we always want to see into secondary file (line: $cnt).\n";
312
+            }
313
+            else if ( ! array_key_exists($key, $aSecondary))
314
+            {
315
+                //print "Key $key does NOT exist in secondary language (line: $cnt).\n";
316
+                continue;
317
+            }
318
+
319
+            // String exists in both files and value into alternative language differs from main language but also from english files
320
+            if (
321
+                (! empty($aSecondary[$key]) && $aSecondary[$key] != $aPrimary[$key]
322
+                && ! empty($aEnglish[$key]) && $aSecondary[$key] != $aEnglish[$key])
323
+                || in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/',$key) || preg_match('/^FormatHour/',$key)
324
+                )
325
+            {
326
+                //print "Key $key differs (aSecondary=".$aSecondary[$key].", aPrimary=".$aPrimary[$key].", aEnglish=".$aEnglish[$key].") so we add it into new secondary language (line: $cnt).\n";
327
+                fwrite($oh, $key."=".(empty($aSecondary[$key])?$aPrimary[$key]:$aSecondary[$key])."\n");
328
+            }
329
+        }
330
+        if ( ! feof($handle) ) {
331
+            $rc = 7;
332
+            $msg = "Unexpected fgets() fail";
333
+            print $msg . " (rc=$rc).\n";
334
+            exit($rc);
335
+        }
336
+        fclose($oh);
337
+        fclose($handle);
338
+    }
339
+    else {
340
+        $rc = 8;
341
+        $msg = "Cannot open file $lPrimaryFile";
342
+        print $msg . " (rc=$rc).\n";
343
+        exit($rc);
344
+    }
345
+
346
+    print "Output can be found at $output.\n";
347
+
348
+    print "To rename all .delta files, you can do:\n";
349
+    print '> for fic in `ls htdocs/langs/'.$lSecondary.'/*.delta`; do f=`echo $fic | sed -e \'s/\.delta//\'`; echo $f; mv $f.delta $f; done'."\n";
350 350
 }
351 351
 
352 352
 
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 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,17 +58,17 @@  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
 {
68 68
 	$rc = 1;
69 69
 	$msg = '***** Script to clean language files *****'."\n";
70
-	$msg.= 'Usage: ./dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n";
71
-	print $msg . "(rc=$rc).\n";
70
+	$msg .= 'Usage: ./dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n";
71
+	print $msg."(rc=$rc).\n";
72 72
 	exit($rc);
73 73
 }
74 74
 
@@ -80,53 +80,53 @@  discard block
 block discarded – undo
80 80
 if ($filesToProcess == 'all')
81 81
 {
82 82
 	$dir = new DirectoryIterator('htdocs/langs/'.$lPrimary);
83
-	while($dir->valid()) {
84
-		if(!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./',$dir->getFilename())) {
85
-			$files[] =  $dir->getFilename();
83
+	while ($dir->valid()) {
84
+		if (!$dir->isDot() && $dir->isFile() && !preg_match('/^\./', $dir->getFilename())) {
85
+			$files[] = $dir->getFilename();
86 86
 		}
87 87
 		$dir->next();
88 88
 	}
89
-	$filesToProcess=$files;
89
+	$filesToProcess = $files;
90 90
 }
91
-else $filesToProcess=explode(',',$filesToProcess);
91
+else $filesToProcess = explode(',', $filesToProcess);
92 92
 
93 93
 // Arguments should be OK here.
94 94
 
95 95
 
96 96
 // Loop on each file
97
-foreach($filesToProcess as $fileToProcess)
97
+foreach ($filesToProcess as $fileToProcess)
98 98
 {
99 99
 	$lPrimaryFile = 'htdocs/langs/'.$lPrimary.'/'.$fileToProcess;
100 100
 	$lSecondaryFile = 'htdocs/langs/'.$lSecondary.'/'.$fileToProcess;
101 101
 	$lEnglishFile = 'htdocs/langs/'.$lEnglish.'/'.$fileToProcess;
102
-	$output = $lSecondaryFile . '.delta';
102
+	$output = $lSecondaryFile.'.delta';
103 103
 
104 104
 	print "---- Process language file ".$lSecondaryFile."\n";
105 105
 
106
-	if ( ! is_readable($lPrimaryFile) ) {
106
+	if (!is_readable($lPrimaryFile)) {
107 107
 		$rc = 2;
108 108
 		$msg = "Cannot read primary language file $lPrimaryFile.";
109
-		print $msg . " (rc=$rc).\n";
109
+		print $msg." (rc=$rc).\n";
110 110
 		exit($rc);
111 111
 	}
112 112
 
113
-	if ( ! is_readable($lSecondaryFile) ) {
113
+	if (!is_readable($lSecondaryFile)) {
114 114
 		$rc = 3;
115 115
 		$msg = "Cannot read secondary language file $lSecondaryFile. We discard this file.";
116
-		print $msg . "\n";
116
+		print $msg."\n";
117 117
 		continue;
118 118
 	}
119 119
 
120
-	if ( ! is_readable($lEnglishFile) ) {
120
+	if (!is_readable($lEnglishFile)) {
121 121
 		$rc = 3;
122 122
 		$msg = "Cannot read english language file $lEnglishFile. We discard this file.";
123
-		print $msg . "\n";
123
+		print $msg."\n";
124 124
 		continue;
125 125
 	}
126 126
 
127 127
 	// Start reading and parsing Secondary
128 128
 
129
-	if ( $handle = fopen($lSecondaryFile, 'r') )
129
+	if ($handle = fopen($lSecondaryFile, 'r'))
130 130
 	{
131 131
 		print "Read Secondary File $lSecondaryFile:\n";
132 132
 		$cnt = 0;
@@ -135,41 +135,41 @@  discard block
 block discarded – undo
135 135
 			$cnt++;
136 136
 
137 137
 			// strip comments
138
-			if ( preg_match("/^\w*#/", $line) ) {
138
+			if (preg_match("/^\w*#/", $line)) {
139 139
 				continue;
140 140
 			}
141 141
 			// strip empty lines
142
-			if ( preg_match("/^\w*$/", $line) ) {
142
+			if (preg_match("/^\w*$/", $line)) {
143 143
 				continue;
144 144
 			}
145 145
 
146 146
 			$a = mb_split('=', trim($line), 2);
147
-			if ( count($a) != 2 ) {
148
-				print "ERROR in file $lSecondaryFile, line $cnt: " . trim($line) . "\n";
147
+			if (count($a) != 2) {
148
+				print "ERROR in file $lSecondaryFile, line $cnt: ".trim($line)."\n";
149 149
 				continue;
150 150
 			}
151 151
 
152 152
 			list($key, $value) = $a;
153 153
 
154 154
 			// key is redundant
155
-			if ( array_key_exists($key, $aSecondary) ) {
155
+			if (array_key_exists($key, $aSecondary)) {
156 156
 				print "Key $key is redundant in file $lSecondaryFile (line: $cnt).\n";
157 157
 				continue;
158 158
 			}
159 159
 
160 160
 			// String has no value
161
-			if ( $value == '' ) {
161
+			if ($value == '') {
162 162
 				print "Key $key has no value in file $lSecondaryFile (line: $cnt).\n";
163 163
 				continue;
164 164
 			}
165 165
 
166 166
 			$aSecondary[$key] = trim($value);
167 167
 		}
168
-		if ( ! feof($handle) )
168
+		if (!feof($handle))
169 169
 		{
170 170
 			$rc = 5;
171 171
 			$msg = "Unexpected fgets() fail";
172
-			print $msg . " (rc=$rc).\n";
172
+			print $msg." (rc=$rc).\n";
173 173
 			exit($rc);
174 174
 		}
175 175
 		fclose($handle);
@@ -177,14 +177,14 @@  discard block
 block discarded – undo
177 177
 	else {
178 178
 		$rc = 6;
179 179
 		$msg = "Cannot open file $lSecondaryFile";
180
-		print $msg . " (rc=$rc).\n";
180
+		print $msg." (rc=$rc).\n";
181 181
 		exit($rc);
182 182
 	}
183 183
 
184 184
 
185 185
 	// Start reading and parsing English
186 186
 
187
-	if ( $handle = fopen($lEnglishFile, 'r') )
187
+	if ($handle = fopen($lEnglishFile, 'r'))
188 188
 	{
189 189
 		print "Read English File $lEnglishFile:\n";
190 190
 		$cnt = 0;
@@ -193,41 +193,41 @@  discard block
 block discarded – undo
193 193
 			$cnt++;
194 194
 
195 195
 			// strip comments
196
-			if ( preg_match("/^\w*#/", $line) ) {
196
+			if (preg_match("/^\w*#/", $line)) {
197 197
 				continue;
198 198
 			}
199 199
 			// strip empty lines
200
-			if ( preg_match("/^\w*$/", $line) ) {
200
+			if (preg_match("/^\w*$/", $line)) {
201 201
 				continue;
202 202
 			}
203 203
 
204 204
 			$a = mb_split('=', trim($line), 2);
205
-			if ( count($a) != 2 ) {
206
-				print "ERROR in file $lEnglishFile, line $cnt: " . trim($line) . "\n";
205
+			if (count($a) != 2) {
206
+				print "ERROR in file $lEnglishFile, line $cnt: ".trim($line)."\n";
207 207
 				continue;
208 208
 			}
209 209
 
210 210
 			list($key, $value) = $a;
211 211
 
212 212
 			// key is redundant
213
-			if ( array_key_exists($key, $aEnglish) ) {
213
+			if (array_key_exists($key, $aEnglish)) {
214 214
 				print "Key $key is redundant in file $lEnglishFile (line: $cnt).\n";
215 215
 				continue;
216 216
 			}
217 217
 
218 218
 			// String has no value
219
-			if ( $value == '' ) {
219
+			if ($value == '') {
220 220
 				print "Key $key has no value in file $lEnglishFile (line: $cnt).\n";
221 221
 				continue;
222 222
 			}
223 223
 
224 224
 			$aEnglish[$key] = trim($value);
225 225
 		}
226
-		if ( ! feof($handle) )
226
+		if (!feof($handle))
227 227
 		{
228 228
 			$rc = 5;
229 229
 			$msg = "Unexpected fgets() fail";
230
-			print $msg . " (rc=$rc).\n";
230
+			print $msg." (rc=$rc).\n";
231 231
 			exit($rc);
232 232
 		}
233 233
 		fclose($handle);
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	else {
236 236
 		$rc = 6;
237 237
 		$msg = "Cannot open file $lEnglishFile";
238
-		print $msg . " (rc=$rc).\n";
238
+		print $msg." (rc=$rc).\n";
239 239
 		exit($rc);
240 240
 	}
241 241
 
@@ -243,12 +243,12 @@  discard block
 block discarded – undo
243 243
 
244 244
 	// Start reading and parsing Primary. See rules in header!
245 245
 
246
-	$arrayofkeytoalwayskeep=array('DIRECTION','FONTFORPDF','FONTSIZEFORPDF','SeparatorDecimal','SeparatorThousand');
246
+	$arrayofkeytoalwayskeep = array('DIRECTION', 'FONTFORPDF', 'FONTSIZEFORPDF', 'SeparatorDecimal', 'SeparatorThousand');
247 247
 
248 248
 
249
-	if ( $handle = fopen($lPrimaryFile, 'r') )
249
+	if ($handle = fopen($lPrimaryFile, 'r'))
250 250
 	{
251
-		if ( ! $oh = fopen($output, 'w') )
251
+		if (!$oh = fopen($output, 'w'))
252 252
 		{
253 253
 			print "ERROR in writing to file $output\n";
254 254
 			exit;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
 		print "Read Primary File $lPrimaryFile and write ".$output.":\n";
258 258
 
259
-		fwrite($oh, "# Dolibarr language file - Source file is en_US - ".(preg_replace('/\.lang$/','',$fileToProcess))."\n");
259
+		fwrite($oh, "# Dolibarr language file - Source file is en_US - ".(preg_replace('/\.lang$/', '', $fileToProcess))."\n");
260 260
 
261 261
 		$cnt = 0;
262 262
 		while (($line = fgets($handle)) !== false)
@@ -264,24 +264,24 @@  discard block
 block discarded – undo
264 264
 			$cnt++;
265 265
 
266 266
 			// strip comments
267
-			if ( preg_match("/^\w*#/", $line) ) {
267
+			if (preg_match("/^\w*#/", $line)) {
268 268
 				continue;
269 269
 			}
270 270
 			// strip empty lines
271
-			if ( preg_match("/^\w*$/", $line) ) {
271
+			if (preg_match("/^\w*$/", $line)) {
272 272
 				continue;
273 273
 			}
274 274
 
275 275
 			$a = mb_split('=', trim($line), 2);
276
-			if ( count($a) != 2 ) {
277
-				print "ERROR in file $lPrimaryFile, line $cnt: " . trim($line) . "\n";
276
+			if (count($a) != 2) {
277
+				print "ERROR in file $lPrimaryFile, line $cnt: ".trim($line)."\n";
278 278
 				continue;
279 279
 			}
280 280
 
281 281
 			list($key, $value) = $a;
282 282
 
283 283
 			// key is redundant
284
-			if ( array_key_exists($key, $aPrimary) ) {
284
+			if (array_key_exists($key, $aPrimary)) {
285 285
 				print "Key $key is redundant in file $lPrimaryFile (line: $cnt) - Already found into ".$fileFirstFound[$key]." (line: ".$lineFirstFound[$key].").\n";
286 286
 				continue;
287 287
 			}
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 			}
293 293
 
294 294
 			// String has no value
295
-			if ( $value == '' ) {
295
+			if ($value == '') {
296 296
 				print "Key $key has no value in file $lPrimaryFile (line: $cnt).\n";
297 297
 				continue;
298 298
 			}
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 			//print "Found primary key = ".$key."\n";
307 307
 
308 308
 			// Key not in other file
309
-			if (in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/',$key) || preg_match('/^FormatHour/',$key))
309
+			if (in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key))
310 310
 			{
311 311
 				//print "Key $key is a key we always want to see into secondary file (line: $cnt).\n";
312 312
 			}
313
-			else if ( ! array_key_exists($key, $aSecondary))
313
+			else if (!array_key_exists($key, $aSecondary))
314 314
 			{
315 315
 				//print "Key $key does NOT exist in secondary language (line: $cnt).\n";
316 316
 				continue;
@@ -318,19 +318,19 @@  discard block
 block discarded – undo
318 318
 
319 319
 			// String exists in both files and value into alternative language differs from main language but also from english files
320 320
 			if (
321
-				(! empty($aSecondary[$key]) && $aSecondary[$key] != $aPrimary[$key]
322
-			    && ! empty($aEnglish[$key]) && $aSecondary[$key] != $aEnglish[$key])
323
-				|| in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/',$key) || preg_match('/^FormatHour/',$key)
321
+				(!empty($aSecondary[$key]) && $aSecondary[$key] != $aPrimary[$key]
322
+			    && !empty($aEnglish[$key]) && $aSecondary[$key] != $aEnglish[$key])
323
+				|| in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key)
324 324
 				)
325 325
 			{
326 326
 				//print "Key $key differs (aSecondary=".$aSecondary[$key].", aPrimary=".$aPrimary[$key].", aEnglish=".$aEnglish[$key].") so we add it into new secondary language (line: $cnt).\n";
327
-				fwrite($oh, $key."=".(empty($aSecondary[$key])?$aPrimary[$key]:$aSecondary[$key])."\n");
327
+				fwrite($oh, $key."=".(empty($aSecondary[$key]) ? $aPrimary[$key] : $aSecondary[$key])."\n");
328 328
 			}
329 329
 		}
330
-		if ( ! feof($handle) ) {
330
+		if (!feof($handle)) {
331 331
 			$rc = 7;
332 332
 			$msg = "Unexpected fgets() fail";
333
-			print $msg . " (rc=$rc).\n";
333
+			print $msg." (rc=$rc).\n";
334 334
 			exit($rc);
335 335
 		}
336 336
 		fclose($oh);
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	else {
340 340
 		$rc = 8;
341 341
 		$msg = "Cannot open file $lPrimaryFile";
342
-		print $msg . " (rc=$rc).\n";
342
+		print $msg." (rc=$rc).\n";
343 343
 		exit($rc);
344 344
 	}
345 345
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -11 removed lines patch added patch discarded remove patch
@@ -87,8 +87,9 @@  discard block
 block discarded – undo
87 87
 		$dir->next();
88 88
 	}
89 89
 	$filesToProcess=$files;
90
+} else {
91
+    $filesToProcess=explode(',',$filesToProcess);
90 92
 }
91
-else $filesToProcess=explode(',',$filesToProcess);
92 93
 
93 94
 // Arguments should be OK here.
94 95
 
@@ -173,8 +174,7 @@  discard block
 block discarded – undo
173 174
 			exit($rc);
174 175
 		}
175 176
 		fclose($handle);
176
-	}
177
-	else {
177
+	} else {
178 178
 		$rc = 6;
179 179
 		$msg = "Cannot open file $lSecondaryFile";
180 180
 		print $msg . " (rc=$rc).\n";
@@ -231,8 +231,7 @@  discard block
 block discarded – undo
231 231
 			exit($rc);
232 232
 		}
233 233
 		fclose($handle);
234
-	}
235
-	else {
234
+	} else {
236 235
 		$rc = 6;
237 236
 		$msg = "Cannot open file $lEnglishFile";
238 237
 		print $msg . " (rc=$rc).\n";
@@ -284,8 +283,7 @@  discard block
 block discarded – undo
284 283
 			if ( array_key_exists($key, $aPrimary) ) {
285 284
 				print "Key $key is redundant in file $lPrimaryFile (line: $cnt) - Already found into ".$fileFirstFound[$key]." (line: ".$lineFirstFound[$key].").\n";
286 285
 				continue;
287
-			}
288
-			else
286
+			} else
289 287
 			{
290 288
 				$fileFirstFound[$key] = $fileToProcess;
291 289
 				$lineFirstFound[$key] = $cnt;
@@ -309,8 +307,7 @@  discard block
 block discarded – undo
309 307
 			if (in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/',$key) || preg_match('/^FormatHour/',$key))
310 308
 			{
311 309
 				//print "Key $key is a key we always want to see into secondary file (line: $cnt).\n";
312
-			}
313
-			else if ( ! array_key_exists($key, $aSecondary))
310
+			} else if ( ! array_key_exists($key, $aSecondary))
314 311
 			{
315 312
 				//print "Key $key does NOT exist in secondary language (line: $cnt).\n";
316 313
 				continue;
@@ -335,8 +332,7 @@  discard block
 block discarded – undo
335 332
 		}
336 333
 		fclose($oh);
337 334
 		fclose($handle);
338
-	}
339
-	else {
335
+	} else {
340 336
 		$rc = 8;
341 337
 		$msg = "Cannot open file $lPrimaryFile";
342 338
 		print $msg . " (rc=$rc).\n";
Please login to merge, or discard this patch.
dolibarr/dev/translation/sanity_check_en_langfiles.php 3 patches
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 $files = scandir($workdir);
108 108
 if (empty($files))
109 109
 {
110
-	echo "Can't scan workdir = ".$workdir;
111
-	exit;
110
+    echo "Can't scan workdir = ".$workdir;
111
+    exit;
112 112
 }
113 113
 
114 114
 $dups=array();
@@ -122,38 +122,38 @@  discard block
 block discarded – undo
122 122
 $langstrings_3d = array();
123 123
 $langstrings_full = array();
124 124
 foreach ($files AS $file) {
125
-	$path_file = pathinfo($file);
126
-	// we're only interested in .lang files
127
-	if ($path_file['extension']=='lang') {
128
-		$content = file($workdir.$file);
129
-		foreach ($content AS $line => $row) {
130
-			// don't want comment lines
131
-			if (substr($row,0,1) !== '#') {
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;
139
-				}
140
-			}
141
-		}
142
-	}
125
+    $path_file = pathinfo($file);
126
+    // we're only interested in .lang files
127
+    if ($path_file['extension']=='lang') {
128
+        $content = file($workdir.$file);
129
+        foreach ($content AS $line => $row) {
130
+            // don't want comment lines
131
+            if (substr($row,0,1) !== '#') {
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;
139
+                }
140
+            }
141
+        }
142
+    }
143 143
 }
144 144
 
145 145
 foreach ($langstrings_3d AS $filename => $file)
146 146
 {
147
-	foreach ($file AS $linenum => $value)
148
-	{
149
-		$keys = array_keys($langstrings_full, $value);
150
-		if (count($keys)>1)
151
-		{
152
-				foreach ($keys AS $key) {
153
-					$dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]);
154
-				}
155
-		}
156
-	}
147
+    foreach ($file AS $linenum => $value)
148
+    {
149
+        $keys = array_keys($langstrings_full, $value);
150
+        if (count($keys)>1)
151
+        {
152
+                foreach ($keys AS $key) {
153
+                    $dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]);
154
+                }
155
+        }
156
+    }
157 157
 }
158 158
 
159 159
 if ($web) print "<h2>";
@@ -175,49 +175,49 @@  discard block
 block discarded – undo
175 175
 $count = 0;
176 176
 foreach ($dups as $string => $pages)
177 177
 {
178
-	$count++;
179
-	$s='';
180
-
181
-	// Keyword $string
182
-	if ($web) $s.="<tr>";
183
-	if ($web) $s.="<td align=\"center\">";
184
-	if ($web) $s.=$count;
185
-	if ($web) $s.="</td>";
186
-	if ($web) $s.="<td>";
187
-	$s.=$string;
188
-	if ($web) $s.="</td>";
189
-	if ($web) $s.="<td>";
190
-	if (! $web) $s.= ' : ';
191
-
192
-	// Loop on each files keyword was found
178
+    $count++;
179
+    $s='';
180
+
181
+    // Keyword $string
182
+    if ($web) $s.="<tr>";
183
+    if ($web) $s.="<td align=\"center\">";
184
+    if ($web) $s.=$count;
185
+    if ($web) $s.="</td>";
186
+    if ($web) $s.="<td>";
187
+    $s.=$string;
188
+    if ($web) $s.="</td>";
189
+    if ($web) $s.="<td>";
190
+    if (! $web) $s.= ' : ';
191
+
192
+    // Loop on each files keyword was found
193 193
     $duplicateinsamefile=0;
194
-	$inmain=0;
194
+    $inmain=0;
195 195
     $inadmin=0;
196
-	foreach ($pages AS $file => $lines)
197
-	{
196
+    foreach ($pages AS $file => $lines)
197
+    {
198 198
         if ($file == 'main.lang') { $inmain=1; $inadmin=0; }
199 199
         if ($file == 'admin.lang' && ! $inmain) { $inadmin=1; }
200 200
 
201
-	    $s.=$file." ";
201
+        $s.=$file." ";
202 202
 
203
-	    // Loop on each line keword was found into file.
204
-	    $listoffilesforthisentry=array();
205
-	    foreach ($lines as $line => $translatedvalue)
206
-		{
203
+        // Loop on each line keword was found into file.
204
+        $listoffilesforthisentry=array();
205
+        foreach ($lines as $line => $translatedvalue)
206
+        {
207 207
             if (! empty($listoffilesforthisentry[$file])) $duplicateinsamefile=1;
208 208
             $listoffilesforthisentry[$file]=1;
209 209
 
210
-			$s.= "(".$line." - ".htmlentities($translatedvalue).") ";
211
-		}
212
-		if ($web) $s.="<br>";
213
-	}
214
-	if ($web) $s.="</td></tr>";
215
-	$s.="\n";
216
-
217
-	if ($duplicateinsamefile) $sduplicateinsamefile .= $s;
218
-	else if ($inmain) $sinmainandother .= $s;
219
-	else if ($inadmin) $sininstallandadmin .= $s;
220
-	else $sother .= $s;
210
+            $s.= "(".$line." - ".htmlentities($translatedvalue).") ";
211
+        }
212
+        if ($web) $s.="<br>";
213
+    }
214
+    if ($web) $s.="</td></tr>";
215
+    $s.="\n";
216
+
217
+    if ($duplicateinsamefile) $sduplicateinsamefile .= $s;
218
+    else if ($inmain) $sinmainandother .= $s;
219
+    else if ($inadmin) $sininstallandadmin .= $s;
220
+    else $sother .= $s;
221 221
 }
222 222
 
223 223
 if (! $web) print "\n***** Entries duplicated in same file\n";
@@ -254,122 +254,122 @@  discard block
 block discarded – undo
254 254
     print "***** Strings in en_US that are never used:\n";
255 255
 
256 256
     $unused=array();
257
-	foreach ($langstrings_dist AS $value => $line)
258
-	{
259
-    	$qualifiedforclean=1;
260
-	    // Check if we must keep this key to be into file for removal
261
-	    if (preg_match('/^Module\d+/', $value)) $qualifiedforclean=0;
262
-	    if (preg_match('/^Permission\d+/', $value)) $qualifiedforclean=0;
263
-	    if (preg_match('/^PermissionAdvanced\d+/', $value)) $qualifiedforclean=0;
264
-	    if (preg_match('/^ProfId\d+/', $value)) $qualifiedforclean=0;
265
-	    if (preg_match('/^Delays_/', $value)) $qualifiedforclean=0;
266
-	    if (preg_match('/^BarcodeDesc/', $value)) $qualifiedforclean=0;
267
-	    if (preg_match('/^Extrafield/', $value)) $qualifiedforclean=0;
268
-	    if (preg_match('/^LocalTax/', $value)) $qualifiedforclean=0;
269
-	    if (preg_match('/^Country/', $value)) $qualifiedforclean=0;
270
-	    if (preg_match('/^Civility/', $value)) $qualifiedforclean=0;
271
-	    if (preg_match('/^Currency/', $value)) $qualifiedforclean=0;
272
-	    if (preg_match('/^DemandReasonTypeSRC/', $value)) $qualifiedforclean=0;
273
-	    if (preg_match('/^PaperFormat/', $value)) $qualifiedforclean=0;
274
-	    if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
275
-	    if (preg_match('/^AmountLT/', $value)) $qualifiedforclean=0;
276
-	    if (preg_match('/^TotalLT/', $value)) $qualifiedforclean=0;
277
-	    if (preg_match('/^Month/', $value)) $qualifiedforclean=0;
278
-	    if (preg_match('/^MonthShort/', $value)) $qualifiedforclean=0;
279
-	    if (preg_match('/^Day\d/', $value)) $qualifiedforclean=0;
280
-	    if (preg_match('/^Short/', $value)) $qualifiedforclean=0;
281
-	    if (preg_match('/^ExportDataset_/', $value)) $qualifiedforclean=0;
282
-	    if (preg_match('/^ImportDataset_/', $value)) $qualifiedforclean=0;
283
-	    if (preg_match('/^ActionAC_/', $value)) $qualifiedforclean=0;
284
-	    if (preg_match('/^TypeLocaltax/', $value)) $qualifiedforclean=0;
285
-	    if (preg_match('/^StatusProspect/', $value)) $qualifiedforclean=0;
286
-	    if (preg_match('/^PL_/', $value)) $qualifiedforclean=0;
287
-	    if (preg_match('/^TE_/', $value)) $qualifiedforclean=0;
288
-	    if (preg_match('/^JuridicalStatus/', $value)) $qualifiedforclean=0;
289
-	    if (preg_match('/^CalcMode/', $value)) $qualifiedforclean=0;
290
-	    if (preg_match('/^newLT/', $value)) $qualifiedforclean=0;
291
-	    if (preg_match('/^LT[0-9]/', $value)) $qualifiedforclean=0;
292
-	    if (preg_match('/^TypeContact_contrat_/', $value)) $qualifiedforclean=0;
293
-	    if (preg_match('/^ErrorPriceExpression/', $value)) $qualifiedforclean=0;
294
-	    if (preg_match('/^Language_/', $value)) $qualifiedforclean=0;
295
-	    if (preg_match('/^DescADHERENT_/', $value)) $qualifiedforclean=0;
296
-	    if (preg_match('/^SubmitTranslation/', $value)) $qualifiedforclean=0;
297
-	    if (preg_match('/^ModuleCompanyCode/', $value)) $qualifiedforclean=0;
298
-	    if (preg_match('/InDolibarr$/', $value)) $qualifiedforclean=0;
299
-	    // admin.lang
300
-	    if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) $qualifiedforclean=0;
301
-	    if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) $qualifiedforclean=0;
302
-	    // boxes.lang
303
-	    if (preg_match('/^BoxTitleLast/', $value)) $qualifiedforclean=0;
304
-	    if (preg_match('/^BoxTitleLatest/', $value)) $qualifiedforclean=0;
305
-	    // install.lang
306
-	    if (preg_match('/^KeepDefaultValues/', $value)) $qualifiedforclean=0;
307
-		// mail.lang
308
-	    if (preg_match('/MailingModuleDesc/i', $value)) $qualifiedforclean=0;
309
-	    // main.lang
310
-	    if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
311
-	    if (preg_match('/^FormatDate/', $value)) $qualifiedforclean=0;
312
-	    if (preg_match('/^DateFormat/', $value)) $qualifiedforclean=0;
313
-	    if (preg_match('/^.b$/', $value)) $qualifiedforclean=0;
314
-	    if (preg_match('/^.*Bytes$/', $value)) $qualifiedforclean=0;
315
-	    if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) $qualifiedforclean=0;
316
-	    if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) $qualifiedforclean=0;
317
-		// modulebuilder
318
-		if (preg_match('/^ModuleBuilderDesc/', $value)) $qualifiedforclean=0;
319
-	    // orders
320
-	    if (preg_match('/^OrderSource/', $value)) $qualifiedforclean=0;
321
-	    if (preg_match('/^TypeContact_/', $value)) $qualifiedforclean=0;
257
+    foreach ($langstrings_dist AS $value => $line)
258
+    {
259
+        $qualifiedforclean=1;
260
+        // Check if we must keep this key to be into file for removal
261
+        if (preg_match('/^Module\d+/', $value)) $qualifiedforclean=0;
262
+        if (preg_match('/^Permission\d+/', $value)) $qualifiedforclean=0;
263
+        if (preg_match('/^PermissionAdvanced\d+/', $value)) $qualifiedforclean=0;
264
+        if (preg_match('/^ProfId\d+/', $value)) $qualifiedforclean=0;
265
+        if (preg_match('/^Delays_/', $value)) $qualifiedforclean=0;
266
+        if (preg_match('/^BarcodeDesc/', $value)) $qualifiedforclean=0;
267
+        if (preg_match('/^Extrafield/', $value)) $qualifiedforclean=0;
268
+        if (preg_match('/^LocalTax/', $value)) $qualifiedforclean=0;
269
+        if (preg_match('/^Country/', $value)) $qualifiedforclean=0;
270
+        if (preg_match('/^Civility/', $value)) $qualifiedforclean=0;
271
+        if (preg_match('/^Currency/', $value)) $qualifiedforclean=0;
272
+        if (preg_match('/^DemandReasonTypeSRC/', $value)) $qualifiedforclean=0;
273
+        if (preg_match('/^PaperFormat/', $value)) $qualifiedforclean=0;
274
+        if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
275
+        if (preg_match('/^AmountLT/', $value)) $qualifiedforclean=0;
276
+        if (preg_match('/^TotalLT/', $value)) $qualifiedforclean=0;
277
+        if (preg_match('/^Month/', $value)) $qualifiedforclean=0;
278
+        if (preg_match('/^MonthShort/', $value)) $qualifiedforclean=0;
279
+        if (preg_match('/^Day\d/', $value)) $qualifiedforclean=0;
280
+        if (preg_match('/^Short/', $value)) $qualifiedforclean=0;
281
+        if (preg_match('/^ExportDataset_/', $value)) $qualifiedforclean=0;
282
+        if (preg_match('/^ImportDataset_/', $value)) $qualifiedforclean=0;
283
+        if (preg_match('/^ActionAC_/', $value)) $qualifiedforclean=0;
284
+        if (preg_match('/^TypeLocaltax/', $value)) $qualifiedforclean=0;
285
+        if (preg_match('/^StatusProspect/', $value)) $qualifiedforclean=0;
286
+        if (preg_match('/^PL_/', $value)) $qualifiedforclean=0;
287
+        if (preg_match('/^TE_/', $value)) $qualifiedforclean=0;
288
+        if (preg_match('/^JuridicalStatus/', $value)) $qualifiedforclean=0;
289
+        if (preg_match('/^CalcMode/', $value)) $qualifiedforclean=0;
290
+        if (preg_match('/^newLT/', $value)) $qualifiedforclean=0;
291
+        if (preg_match('/^LT[0-9]/', $value)) $qualifiedforclean=0;
292
+        if (preg_match('/^TypeContact_contrat_/', $value)) $qualifiedforclean=0;
293
+        if (preg_match('/^ErrorPriceExpression/', $value)) $qualifiedforclean=0;
294
+        if (preg_match('/^Language_/', $value)) $qualifiedforclean=0;
295
+        if (preg_match('/^DescADHERENT_/', $value)) $qualifiedforclean=0;
296
+        if (preg_match('/^SubmitTranslation/', $value)) $qualifiedforclean=0;
297
+        if (preg_match('/^ModuleCompanyCode/', $value)) $qualifiedforclean=0;
298
+        if (preg_match('/InDolibarr$/', $value)) $qualifiedforclean=0;
299
+        // admin.lang
300
+        if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) $qualifiedforclean=0;
301
+        if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) $qualifiedforclean=0;
302
+        // boxes.lang
303
+        if (preg_match('/^BoxTitleLast/', $value)) $qualifiedforclean=0;
304
+        if (preg_match('/^BoxTitleLatest/', $value)) $qualifiedforclean=0;
305
+        // install.lang
306
+        if (preg_match('/^KeepDefaultValues/', $value)) $qualifiedforclean=0;
307
+        // mail.lang
308
+        if (preg_match('/MailingModuleDesc/i', $value)) $qualifiedforclean=0;
309
+        // main.lang
310
+        if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
311
+        if (preg_match('/^FormatDate/', $value)) $qualifiedforclean=0;
312
+        if (preg_match('/^DateFormat/', $value)) $qualifiedforclean=0;
313
+        if (preg_match('/^.b$/', $value)) $qualifiedforclean=0;
314
+        if (preg_match('/^.*Bytes$/', $value)) $qualifiedforclean=0;
315
+        if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) $qualifiedforclean=0;
316
+        if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) $qualifiedforclean=0;
317
+        // modulebuilder
318
+        if (preg_match('/^ModuleBuilderDesc/', $value)) $qualifiedforclean=0;
319
+        // orders
320
+        if (preg_match('/^OrderSource/', $value)) $qualifiedforclean=0;
321
+        if (preg_match('/^TypeContact_/', $value)) $qualifiedforclean=0;
322 322
         // other.lang
323
-	    if (preg_match('/^Notify_/', $value)) $qualifiedforclean=0;
324
-	    if (preg_match('/^PredefinedMail/', $value)) $qualifiedforclean=0;
325
-	    if (preg_match('/^DemoCompany/', $value)) $qualifiedforclean=0;
326
-	    if (preg_match('/^WeightUnit/', $value)) $qualifiedforclean=0;
327
-	    if (preg_match('/^LengthUnit/', $value)) $qualifiedforclean=0;
328
-	    if (preg_match('/^SurfaceUnit/', $value)) $qualifiedforclean=0;
329
-	    if (preg_match('/^VolumeUnit/', $value)) $qualifiedforclean=0;
330
-	    if (preg_match('/^SizeUnit/', $value)) $qualifiedforclean=0;
331
-	    if (preg_match('/^EMailText/', $value)) $qualifiedforclean=0;
332
-	    if (preg_match('/ById$/', $value)) $qualifiedforclean=0;
333
-	    if (preg_match('/ByLogin$/', $value)) $qualifiedforclean=0;
334
-	    // printing
335
-	    if (preg_match('/PrintingDriverDesc$/', $value)) $qualifiedforclean=0;
336
-	    if (preg_match('/PrintTestDesc$/', $value)) $qualifiedforclean=0;
337
-	    // products
338
-	    if (preg_match('/GlobalVariableUpdaterType$/', $value)) $qualifiedforclean=0;
339
-	    if (preg_match('/GlobalVariableUpdaterHelp$/', $value)) $qualifiedforclean=0;
340
-	    if (preg_match('/OppStatus/', $value)) $qualifiedforclean=0;
341
-	    if (preg_match('/AvailabilityType/', $value)) $qualifiedforclean=0;
342
-	    if (preg_match('/CardProduct/', $value)) $qualifiedforclean=0;
343
-
344
-	    if (preg_match('/sms/i', $value)) $qualifiedforclean=0;
345
-	    if (preg_match('/TF_/i', $value)) $qualifiedforclean=0;
346
-	    if (preg_match('/WithBankUsing/i', $value)) $qualifiedforclean=0;
347
-	    if (preg_match('/descWORKFLOW_/i', $value)) $qualifiedforclean=0;
348
-
349
-	    if (! $qualifiedforclean)
350
-	    {
323
+        if (preg_match('/^Notify_/', $value)) $qualifiedforclean=0;
324
+        if (preg_match('/^PredefinedMail/', $value)) $qualifiedforclean=0;
325
+        if (preg_match('/^DemoCompany/', $value)) $qualifiedforclean=0;
326
+        if (preg_match('/^WeightUnit/', $value)) $qualifiedforclean=0;
327
+        if (preg_match('/^LengthUnit/', $value)) $qualifiedforclean=0;
328
+        if (preg_match('/^SurfaceUnit/', $value)) $qualifiedforclean=0;
329
+        if (preg_match('/^VolumeUnit/', $value)) $qualifiedforclean=0;
330
+        if (preg_match('/^SizeUnit/', $value)) $qualifiedforclean=0;
331
+        if (preg_match('/^EMailText/', $value)) $qualifiedforclean=0;
332
+        if (preg_match('/ById$/', $value)) $qualifiedforclean=0;
333
+        if (preg_match('/ByLogin$/', $value)) $qualifiedforclean=0;
334
+        // printing
335
+        if (preg_match('/PrintingDriverDesc$/', $value)) $qualifiedforclean=0;
336
+        if (preg_match('/PrintTestDesc$/', $value)) $qualifiedforclean=0;
337
+        // products
338
+        if (preg_match('/GlobalVariableUpdaterType$/', $value)) $qualifiedforclean=0;
339
+        if (preg_match('/GlobalVariableUpdaterHelp$/', $value)) $qualifiedforclean=0;
340
+        if (preg_match('/OppStatus/', $value)) $qualifiedforclean=0;
341
+        if (preg_match('/AvailabilityType/', $value)) $qualifiedforclean=0;
342
+        if (preg_match('/CardProduct/', $value)) $qualifiedforclean=0;
343
+
344
+        if (preg_match('/sms/i', $value)) $qualifiedforclean=0;
345
+        if (preg_match('/TF_/i', $value)) $qualifiedforclean=0;
346
+        if (preg_match('/WithBankUsing/i', $value)) $qualifiedforclean=0;
347
+        if (preg_match('/descWORKFLOW_/i', $value)) $qualifiedforclean=0;
348
+
349
+        if (! $qualifiedforclean)
350
+        {
351 351
             continue;
352
-	    }
353
-
354
-	    //$search = '\'trans("'.$value.'")\'';
355
-	    $search = '-e "\''.$value.'\'" -e \'"'.$value.'"\' -e "('.$value.')" -e "('.$value.',"';
356
-		$string =  'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*';
357
-		//print $string."<br>\n";
358
-		exec($string,$output);
359
-		if (empty($output)) {
360
-   			$unused[$value] = $line;
361
-       		echo $line;        // $trad contains the \n
362
-		}
363
-		else
364
-		{
365
-		    unset($output);
366
-		    //print 'X'.$output.'Y';
367
-		}
368
-	}
369
-
370
-	if (empty($unused)) print "No string not used found.\n";
371
-	else
372
-	{
352
+        }
353
+
354
+        //$search = '\'trans("'.$value.'")\'';
355
+        $search = '-e "\''.$value.'\'" -e \'"'.$value.'"\' -e "('.$value.')" -e "('.$value.',"';
356
+        $string =  'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*';
357
+        //print $string."<br>\n";
358
+        exec($string,$output);
359
+        if (empty($output)) {
360
+                $unused[$value] = $line;
361
+                echo $line;        // $trad contains the \n
362
+        }
363
+        else
364
+        {
365
+            unset($output);
366
+            //print 'X'.$output.'Y';
367
+        }
368
+    }
369
+
370
+    if (empty($unused)) print "No string not used found.\n";
371
+    else
372
+    {
373 373
         $filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang';
374 374
         print "Strings in en_US that are never used are saved into file ".$filetosave.":\n";
375 375
         file_put_contents($filetosave, implode("",$unused));
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
         if (($argv[2]?$argv[2]:"")) print 'cd htdocs/langs/en_US; mv '.($argv[2]?$argv[2]:"")." ".($argv[2]?$argv[2]:"").".tmp; ";
378 378
         print "diff ".($argv[2]?$argv[2]:"").".tmp ".$filetosave." | grep \< | cut  -b 3- > ".($argv[2]?$argv[2]:"");
379 379
         if (($argv[2]?$argv[2]:"")) print "; rm ".($argv[2]?$argv[2]:"").".tmp;\n";
380
-	}
380
+    }
381 381
 }
382 382
 
383 383
 echo "\n";
Please login to merge, or discard this patch.
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@  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 29
 {
30
-    $web=1;
30
+    $web = 1;
31 31
 }
32 32
 
33 33
 
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 	exit;
112 112
 }
113 113
 
114
-$dups=array();
115
-$exludefiles = array('.','..','README');
116
-$files = array_diff($files,$exludefiles);
114
+$dups = array();
115
+$exludefiles = array('.', '..', 'README');
116
+$files = array_diff($files, $exludefiles);
117 117
 // To force a file: $files=array('myfile.lang');
118 118
 if (isset($argv[2]))
119 119
 {
@@ -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
-			if (substr($row,0,1) !== '#') {
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
 		}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	foreach ($file AS $linenum => $value)
148 148
 	{
149 149
 		$keys = array_keys($langstrings_full, $value);
150
-		if (count($keys)>1)
150
+		if (count($keys) > 1)
151 151
 		{
152 152
 				foreach ($keys AS $key) {
153 153
 					$dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]);
@@ -167,52 +167,52 @@  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
 {
178 178
 	$count++;
179
-	$s='';
179
+	$s = '';
180 180
 
181 181
 	// Keyword $string
182
-	if ($web) $s.="<tr>";
183
-	if ($web) $s.="<td align=\"center\">";
184
-	if ($web) $s.=$count;
185
-	if ($web) $s.="</td>";
186
-	if ($web) $s.="<td>";
187
-	$s.=$string;
188
-	if ($web) $s.="</td>";
189
-	if ($web) $s.="<td>";
190
-	if (! $web) $s.= ' : ';
182
+	if ($web) $s .= "<tr>";
183
+	if ($web) $s .= "<td align=\"center\">";
184
+	if ($web) $s .= $count;
185
+	if ($web) $s .= "</td>";
186
+	if ($web) $s .= "<td>";
187
+	$s .= $string;
188
+	if ($web) $s .= "</td>";
189
+	if ($web) $s .= "<td>";
190
+	if (!$web) $s .= ' : ';
191 191
 
192 192
 	// Loop on each files keyword was found
193
-    $duplicateinsamefile=0;
194
-	$inmain=0;
195
-    $inadmin=0;
193
+    $duplicateinsamefile = 0;
194
+	$inmain = 0;
195
+    $inadmin = 0;
196 196
 	foreach ($pages AS $file => $lines)
197 197
 	{
198
-        if ($file == 'main.lang') { $inmain=1; $inadmin=0; }
199
-        if ($file == 'admin.lang' && ! $inmain) { $inadmin=1; }
198
+        if ($file == 'main.lang') { $inmain = 1; $inadmin = 0; }
199
+        if ($file == 'admin.lang' && !$inmain) { $inadmin = 1; }
200 200
 
201
-	    $s.=$file." ";
201
+	    $s .= $file." ";
202 202
 
203 203
 	    // Loop on each line keword was found into file.
204
-	    $listoffilesforthisentry=array();
204
+	    $listoffilesforthisentry = array();
205 205
 	    foreach ($lines as $line => $translatedvalue)
206 206
 		{
207
-            if (! empty($listoffilesforthisentry[$file])) $duplicateinsamefile=1;
208
-            $listoffilesforthisentry[$file]=1;
207
+            if (!empty($listoffilesforthisentry[$file])) $duplicateinsamefile = 1;
208
+            $listoffilesforthisentry[$file] = 1;
209 209
 
210
-			$s.= "(".$line." - ".htmlentities($translatedvalue).") ";
210
+			$s .= "(".$line." - ".htmlentities($translatedvalue).") ";
211 211
 		}
212
-		if ($web) $s.="<br>";
212
+		if ($web) $s .= "<br>";
213 213
 	}
214
-	if ($web) $s.="</td></tr>";
215
-	$s.="\n";
214
+	if ($web) $s .= "</td></tr>";
215
+	$s .= "\n";
216 216
 
217 217
 	if ($duplicateinsamefile) $sduplicateinsamefile .= $s;
218 218
 	else if ($inmain) $sinmainandother .= $s;
@@ -220,25 +220,25 @@  discard block
 block discarded – undo
220 220
 	else $sother .= $s;
221 221
 }
222 222
 
223
-if (! $web) print "\n***** Entries duplicated in same file\n";
223
+if (!$web) print "\n***** Entries duplicated in same file\n";
224 224
 print $sduplicateinsamefile;
225
-if (! $web && empty($sduplicateinsamefile)) print "None\n";
226
-if (! $web) print "\n";
225
+if (!$web && empty($sduplicateinsamefile)) print "None\n";
226
+if (!$web) print "\n";
227 227
 
228
-if (! $web) print "***** Entries in main and another (keep only entry in main)\n";
228
+if (!$web) print "***** Entries in main and another (keep only entry in main)\n";
229 229
 print $sinmainandother;
230
-if (! $web && empty($sinmainandother)) print "None\n";
231
-if (! $web) print "\n";
230
+if (!$web && empty($sinmainandother)) print "None\n";
231
+if (!$web) print "\n";
232 232
 
233
-if (! $web) print "***** Entries in admin and another\n";
233
+if (!$web) print "***** Entries in admin and another\n";
234 234
 print $sininstallandadmin;
235
-if (! $web && empty($sininstallandadmin)) print "None\n";
236
-if (! $web) print "\n";
235
+if (!$web && empty($sininstallandadmin)) print "None\n";
236
+if (!$web) print "\n";
237 237
 
238
-if (! $web) print "***** Other\n";
238
+if (!$web) print "***** Other\n";
239 239
 print $sother;
240
-if (! $web && empty($sother)) print "None\n";
241
-if (! $web) print "\n";
240
+if (!$web && empty($sother)) print "None\n";
241
+if (!$web) print "\n";
242 242
 
243 243
 if ($web)
244 244
 {
@@ -249,116 +249,116 @@  discard block
 block discarded – undo
249 249
 
250 250
 // STEP 2 - Search key not used
251 251
 
252
-if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1]=='unused=true'))
252
+if ((!empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1] == 'unused=true'))
253 253
 {
254 254
     print "***** Strings in en_US that are never used:\n";
255 255
 
256
-    $unused=array();
256
+    $unused = array();
257 257
 	foreach ($langstrings_dist AS $value => $line)
258 258
 	{
259
-    	$qualifiedforclean=1;
259
+    	$qualifiedforclean = 1;
260 260
 	    // Check if we must keep this key to be into file for removal
261
-	    if (preg_match('/^Module\d+/', $value)) $qualifiedforclean=0;
262
-	    if (preg_match('/^Permission\d+/', $value)) $qualifiedforclean=0;
263
-	    if (preg_match('/^PermissionAdvanced\d+/', $value)) $qualifiedforclean=0;
264
-	    if (preg_match('/^ProfId\d+/', $value)) $qualifiedforclean=0;
265
-	    if (preg_match('/^Delays_/', $value)) $qualifiedforclean=0;
266
-	    if (preg_match('/^BarcodeDesc/', $value)) $qualifiedforclean=0;
267
-	    if (preg_match('/^Extrafield/', $value)) $qualifiedforclean=0;
268
-	    if (preg_match('/^LocalTax/', $value)) $qualifiedforclean=0;
269
-	    if (preg_match('/^Country/', $value)) $qualifiedforclean=0;
270
-	    if (preg_match('/^Civility/', $value)) $qualifiedforclean=0;
271
-	    if (preg_match('/^Currency/', $value)) $qualifiedforclean=0;
272
-	    if (preg_match('/^DemandReasonTypeSRC/', $value)) $qualifiedforclean=0;
273
-	    if (preg_match('/^PaperFormat/', $value)) $qualifiedforclean=0;
274
-	    if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
275
-	    if (preg_match('/^AmountLT/', $value)) $qualifiedforclean=0;
276
-	    if (preg_match('/^TotalLT/', $value)) $qualifiedforclean=0;
277
-	    if (preg_match('/^Month/', $value)) $qualifiedforclean=0;
278
-	    if (preg_match('/^MonthShort/', $value)) $qualifiedforclean=0;
279
-	    if (preg_match('/^Day\d/', $value)) $qualifiedforclean=0;
280
-	    if (preg_match('/^Short/', $value)) $qualifiedforclean=0;
281
-	    if (preg_match('/^ExportDataset_/', $value)) $qualifiedforclean=0;
282
-	    if (preg_match('/^ImportDataset_/', $value)) $qualifiedforclean=0;
283
-	    if (preg_match('/^ActionAC_/', $value)) $qualifiedforclean=0;
284
-	    if (preg_match('/^TypeLocaltax/', $value)) $qualifiedforclean=0;
285
-	    if (preg_match('/^StatusProspect/', $value)) $qualifiedforclean=0;
286
-	    if (preg_match('/^PL_/', $value)) $qualifiedforclean=0;
287
-	    if (preg_match('/^TE_/', $value)) $qualifiedforclean=0;
288
-	    if (preg_match('/^JuridicalStatus/', $value)) $qualifiedforclean=0;
289
-	    if (preg_match('/^CalcMode/', $value)) $qualifiedforclean=0;
290
-	    if (preg_match('/^newLT/', $value)) $qualifiedforclean=0;
291
-	    if (preg_match('/^LT[0-9]/', $value)) $qualifiedforclean=0;
292
-	    if (preg_match('/^TypeContact_contrat_/', $value)) $qualifiedforclean=0;
293
-	    if (preg_match('/^ErrorPriceExpression/', $value)) $qualifiedforclean=0;
294
-	    if (preg_match('/^Language_/', $value)) $qualifiedforclean=0;
295
-	    if (preg_match('/^DescADHERENT_/', $value)) $qualifiedforclean=0;
296
-	    if (preg_match('/^SubmitTranslation/', $value)) $qualifiedforclean=0;
297
-	    if (preg_match('/^ModuleCompanyCode/', $value)) $qualifiedforclean=0;
298
-	    if (preg_match('/InDolibarr$/', $value)) $qualifiedforclean=0;
261
+	    if (preg_match('/^Module\d+/', $value)) $qualifiedforclean = 0;
262
+	    if (preg_match('/^Permission\d+/', $value)) $qualifiedforclean = 0;
263
+	    if (preg_match('/^PermissionAdvanced\d+/', $value)) $qualifiedforclean = 0;
264
+	    if (preg_match('/^ProfId\d+/', $value)) $qualifiedforclean = 0;
265
+	    if (preg_match('/^Delays_/', $value)) $qualifiedforclean = 0;
266
+	    if (preg_match('/^BarcodeDesc/', $value)) $qualifiedforclean = 0;
267
+	    if (preg_match('/^Extrafield/', $value)) $qualifiedforclean = 0;
268
+	    if (preg_match('/^LocalTax/', $value)) $qualifiedforclean = 0;
269
+	    if (preg_match('/^Country/', $value)) $qualifiedforclean = 0;
270
+	    if (preg_match('/^Civility/', $value)) $qualifiedforclean = 0;
271
+	    if (preg_match('/^Currency/', $value)) $qualifiedforclean = 0;
272
+	    if (preg_match('/^DemandReasonTypeSRC/', $value)) $qualifiedforclean = 0;
273
+	    if (preg_match('/^PaperFormat/', $value)) $qualifiedforclean = 0;
274
+	    if (preg_match('/^Duration/', $value)) $qualifiedforclean = 0;
275
+	    if (preg_match('/^AmountLT/', $value)) $qualifiedforclean = 0;
276
+	    if (preg_match('/^TotalLT/', $value)) $qualifiedforclean = 0;
277
+	    if (preg_match('/^Month/', $value)) $qualifiedforclean = 0;
278
+	    if (preg_match('/^MonthShort/', $value)) $qualifiedforclean = 0;
279
+	    if (preg_match('/^Day\d/', $value)) $qualifiedforclean = 0;
280
+	    if (preg_match('/^Short/', $value)) $qualifiedforclean = 0;
281
+	    if (preg_match('/^ExportDataset_/', $value)) $qualifiedforclean = 0;
282
+	    if (preg_match('/^ImportDataset_/', $value)) $qualifiedforclean = 0;
283
+	    if (preg_match('/^ActionAC_/', $value)) $qualifiedforclean = 0;
284
+	    if (preg_match('/^TypeLocaltax/', $value)) $qualifiedforclean = 0;
285
+	    if (preg_match('/^StatusProspect/', $value)) $qualifiedforclean = 0;
286
+	    if (preg_match('/^PL_/', $value)) $qualifiedforclean = 0;
287
+	    if (preg_match('/^TE_/', $value)) $qualifiedforclean = 0;
288
+	    if (preg_match('/^JuridicalStatus/', $value)) $qualifiedforclean = 0;
289
+	    if (preg_match('/^CalcMode/', $value)) $qualifiedforclean = 0;
290
+	    if (preg_match('/^newLT/', $value)) $qualifiedforclean = 0;
291
+	    if (preg_match('/^LT[0-9]/', $value)) $qualifiedforclean = 0;
292
+	    if (preg_match('/^TypeContact_contrat_/', $value)) $qualifiedforclean = 0;
293
+	    if (preg_match('/^ErrorPriceExpression/', $value)) $qualifiedforclean = 0;
294
+	    if (preg_match('/^Language_/', $value)) $qualifiedforclean = 0;
295
+	    if (preg_match('/^DescADHERENT_/', $value)) $qualifiedforclean = 0;
296
+	    if (preg_match('/^SubmitTranslation/', $value)) $qualifiedforclean = 0;
297
+	    if (preg_match('/^ModuleCompanyCode/', $value)) $qualifiedforclean = 0;
298
+	    if (preg_match('/InDolibarr$/', $value)) $qualifiedforclean = 0;
299 299
 	    // admin.lang
300
-	    if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) $qualifiedforclean=0;
301
-	    if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) $qualifiedforclean=0;
300
+	    if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) $qualifiedforclean = 0;
301
+	    if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) $qualifiedforclean = 0;
302 302
 	    // boxes.lang
303
-	    if (preg_match('/^BoxTitleLast/', $value)) $qualifiedforclean=0;
304
-	    if (preg_match('/^BoxTitleLatest/', $value)) $qualifiedforclean=0;
303
+	    if (preg_match('/^BoxTitleLast/', $value)) $qualifiedforclean = 0;
304
+	    if (preg_match('/^BoxTitleLatest/', $value)) $qualifiedforclean = 0;
305 305
 	    // install.lang
306
-	    if (preg_match('/^KeepDefaultValues/', $value)) $qualifiedforclean=0;
306
+	    if (preg_match('/^KeepDefaultValues/', $value)) $qualifiedforclean = 0;
307 307
 		// mail.lang
308
-	    if (preg_match('/MailingModuleDesc/i', $value)) $qualifiedforclean=0;
308
+	    if (preg_match('/MailingModuleDesc/i', $value)) $qualifiedforclean = 0;
309 309
 	    // main.lang
310
-	    if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
311
-	    if (preg_match('/^FormatDate/', $value)) $qualifiedforclean=0;
312
-	    if (preg_match('/^DateFormat/', $value)) $qualifiedforclean=0;
313
-	    if (preg_match('/^.b$/', $value)) $qualifiedforclean=0;
314
-	    if (preg_match('/^.*Bytes$/', $value)) $qualifiedforclean=0;
315
-	    if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) $qualifiedforclean=0;
316
-	    if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) $qualifiedforclean=0;
310
+	    if (preg_match('/^Duration/', $value)) $qualifiedforclean = 0;
311
+	    if (preg_match('/^FormatDate/', $value)) $qualifiedforclean = 0;
312
+	    if (preg_match('/^DateFormat/', $value)) $qualifiedforclean = 0;
313
+	    if (preg_match('/^.b$/', $value)) $qualifiedforclean = 0;
314
+	    if (preg_match('/^.*Bytes$/', $value)) $qualifiedforclean = 0;
315
+	    if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) $qualifiedforclean = 0;
316
+	    if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) $qualifiedforclean = 0;
317 317
 		// modulebuilder
318
-		if (preg_match('/^ModuleBuilderDesc/', $value)) $qualifiedforclean=0;
318
+		if (preg_match('/^ModuleBuilderDesc/', $value)) $qualifiedforclean = 0;
319 319
 	    // orders
320
-	    if (preg_match('/^OrderSource/', $value)) $qualifiedforclean=0;
321
-	    if (preg_match('/^TypeContact_/', $value)) $qualifiedforclean=0;
320
+	    if (preg_match('/^OrderSource/', $value)) $qualifiedforclean = 0;
321
+	    if (preg_match('/^TypeContact_/', $value)) $qualifiedforclean = 0;
322 322
         // other.lang
323
-	    if (preg_match('/^Notify_/', $value)) $qualifiedforclean=0;
324
-	    if (preg_match('/^PredefinedMail/', $value)) $qualifiedforclean=0;
325
-	    if (preg_match('/^DemoCompany/', $value)) $qualifiedforclean=0;
326
-	    if (preg_match('/^WeightUnit/', $value)) $qualifiedforclean=0;
327
-	    if (preg_match('/^LengthUnit/', $value)) $qualifiedforclean=0;
328
-	    if (preg_match('/^SurfaceUnit/', $value)) $qualifiedforclean=0;
329
-	    if (preg_match('/^VolumeUnit/', $value)) $qualifiedforclean=0;
330
-	    if (preg_match('/^SizeUnit/', $value)) $qualifiedforclean=0;
331
-	    if (preg_match('/^EMailText/', $value)) $qualifiedforclean=0;
332
-	    if (preg_match('/ById$/', $value)) $qualifiedforclean=0;
333
-	    if (preg_match('/ByLogin$/', $value)) $qualifiedforclean=0;
323
+	    if (preg_match('/^Notify_/', $value)) $qualifiedforclean = 0;
324
+	    if (preg_match('/^PredefinedMail/', $value)) $qualifiedforclean = 0;
325
+	    if (preg_match('/^DemoCompany/', $value)) $qualifiedforclean = 0;
326
+	    if (preg_match('/^WeightUnit/', $value)) $qualifiedforclean = 0;
327
+	    if (preg_match('/^LengthUnit/', $value)) $qualifiedforclean = 0;
328
+	    if (preg_match('/^SurfaceUnit/', $value)) $qualifiedforclean = 0;
329
+	    if (preg_match('/^VolumeUnit/', $value)) $qualifiedforclean = 0;
330
+	    if (preg_match('/^SizeUnit/', $value)) $qualifiedforclean = 0;
331
+	    if (preg_match('/^EMailText/', $value)) $qualifiedforclean = 0;
332
+	    if (preg_match('/ById$/', $value)) $qualifiedforclean = 0;
333
+	    if (preg_match('/ByLogin$/', $value)) $qualifiedforclean = 0;
334 334
 	    // printing
335
-	    if (preg_match('/PrintingDriverDesc$/', $value)) $qualifiedforclean=0;
336
-	    if (preg_match('/PrintTestDesc$/', $value)) $qualifiedforclean=0;
335
+	    if (preg_match('/PrintingDriverDesc$/', $value)) $qualifiedforclean = 0;
336
+	    if (preg_match('/PrintTestDesc$/', $value)) $qualifiedforclean = 0;
337 337
 	    // products
338
-	    if (preg_match('/GlobalVariableUpdaterType$/', $value)) $qualifiedforclean=0;
339
-	    if (preg_match('/GlobalVariableUpdaterHelp$/', $value)) $qualifiedforclean=0;
340
-	    if (preg_match('/OppStatus/', $value)) $qualifiedforclean=0;
341
-	    if (preg_match('/AvailabilityType/', $value)) $qualifiedforclean=0;
342
-	    if (preg_match('/CardProduct/', $value)) $qualifiedforclean=0;
343
-
344
-	    if (preg_match('/sms/i', $value)) $qualifiedforclean=0;
345
-	    if (preg_match('/TF_/i', $value)) $qualifiedforclean=0;
346
-	    if (preg_match('/WithBankUsing/i', $value)) $qualifiedforclean=0;
347
-	    if (preg_match('/descWORKFLOW_/i', $value)) $qualifiedforclean=0;
348
-
349
-	    if (! $qualifiedforclean)
338
+	    if (preg_match('/GlobalVariableUpdaterType$/', $value)) $qualifiedforclean = 0;
339
+	    if (preg_match('/GlobalVariableUpdaterHelp$/', $value)) $qualifiedforclean = 0;
340
+	    if (preg_match('/OppStatus/', $value)) $qualifiedforclean = 0;
341
+	    if (preg_match('/AvailabilityType/', $value)) $qualifiedforclean = 0;
342
+	    if (preg_match('/CardProduct/', $value)) $qualifiedforclean = 0;
343
+
344
+	    if (preg_match('/sms/i', $value)) $qualifiedforclean = 0;
345
+	    if (preg_match('/TF_/i', $value)) $qualifiedforclean = 0;
346
+	    if (preg_match('/WithBankUsing/i', $value)) $qualifiedforclean = 0;
347
+	    if (preg_match('/descWORKFLOW_/i', $value)) $qualifiedforclean = 0;
348
+
349
+	    if (!$qualifiedforclean)
350 350
 	    {
351 351
             continue;
352 352
 	    }
353 353
 
354 354
 	    //$search = '\'trans("'.$value.'")\'';
355 355
 	    $search = '-e "\''.$value.'\'" -e \'"'.$value.'"\' -e "('.$value.')" -e "('.$value.',"';
356
-		$string =  'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*';
356
+		$string = 'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*';
357 357
 		//print $string."<br>\n";
358
-		exec($string,$output);
358
+		exec($string, $output);
359 359
 		if (empty($output)) {
360 360
    			$unused[$value] = $line;
361
-       		echo $line;        // $trad contains the \n
361
+       		echo $line; // $trad contains the \n
362 362
 		}
363 363
 		else
364 364
 		{
@@ -370,13 +370,13 @@  discard block
 block discarded – undo
370 370
 	if (empty($unused)) print "No string not used found.\n";
371 371
 	else
372 372
 	{
373
-        $filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang';
373
+        $filetosave = '/tmp/'.($argv[2] ? $argv[2] : "").'notused.lang';
374 374
         print "Strings in en_US that are never used are saved into file ".$filetosave.":\n";
375
-        file_put_contents($filetosave, implode("",$unused));
375
+        file_put_contents($filetosave, implode("", $unused));
376 376
         print "To remove from original file, run command :\n";
377
-        if (($argv[2]?$argv[2]:"")) print 'cd htdocs/langs/en_US; mv '.($argv[2]?$argv[2]:"")." ".($argv[2]?$argv[2]:"").".tmp; ";
378
-        print "diff ".($argv[2]?$argv[2]:"").".tmp ".$filetosave." | grep \< | cut  -b 3- > ".($argv[2]?$argv[2]:"");
379
-        if (($argv[2]?$argv[2]:"")) print "; rm ".($argv[2]?$argv[2]:"").".tmp;\n";
377
+        if (($argv[2] ? $argv[2] : "")) print 'cd htdocs/langs/en_US; mv '.($argv[2] ? $argv[2] : "")." ".($argv[2] ? $argv[2] : "").".tmp; ";
378
+        print "diff ".($argv[2] ? $argv[2] : "").".tmp ".$filetosave." | grep \< | cut  -b 3- > ".($argv[2] ? $argv[2] : "");
379
+        if (($argv[2] ? $argv[2] : "")) print "; rm ".($argv[2] ? $argv[2] : "").".tmp;\n";
380 380
 	}
381 381
 }
382 382
 
Please login to merge, or discard this patch.
Braces   +329 added lines, -114 removed lines patch added patch discarded remove patch
@@ -87,9 +87,13 @@  discard block
 block discarded – undo
87 87
 }
88 88
 
89 89
 echo "If you call this with argument \"unused=true\" it searches for the translation strings that exist in en_US but are never used.\n";
90
-if ($web) print "<br>";
90
+if ($web) {
91
+    print "<br>";
92
+}
91 93
 echo "IMPORTANT: that can take quite a lot of time (up to 10 minutes), you need to tune the max_execution_time on your php.ini accordingly.\n";
92
-if ($web) print "<br>";
94
+if ($web) {
95
+    print "<br>";
96
+}
93 97
 
94 98
 
95 99
 
@@ -156,9 +160,13 @@  discard block
 block discarded – undo
156 160
 	}
157 161
 }
158 162
 
159
-if ($web) print "<h2>";
163
+if ($web) {
164
+    print "<h2>";
165
+}
160 166
 print "Duplicate strings in lang files in $workdir - ".count($dups)." found\n";
161
-if ($web) print "</h2>";
167
+if ($web) {
168
+    print "</h2>";
169
+}
162 170
 
163 171
 if ($web)
164 172
 {
@@ -179,15 +187,31 @@  discard block
 block discarded – undo
179 187
 	$s='';
180 188
 
181 189
 	// Keyword $string
182
-	if ($web) $s.="<tr>";
183
-	if ($web) $s.="<td align=\"center\">";
184
-	if ($web) $s.=$count;
185
-	if ($web) $s.="</td>";
186
-	if ($web) $s.="<td>";
190
+	if ($web) {
191
+	    $s.="<tr>";
192
+	}
193
+	if ($web) {
194
+	    $s.="<td align=\"center\">";
195
+	}
196
+	if ($web) {
197
+	    $s.=$count;
198
+	}
199
+	if ($web) {
200
+	    $s.="</td>";
201
+	}
202
+	if ($web) {
203
+	    $s.="<td>";
204
+	}
187 205
 	$s.=$string;
188
-	if ($web) $s.="</td>";
189
-	if ($web) $s.="<td>";
190
-	if (! $web) $s.= ' : ';
206
+	if ($web) {
207
+	    $s.="</td>";
208
+	}
209
+	if ($web) {
210
+	    $s.="<td>";
211
+	}
212
+	if (! $web) {
213
+	    $s.= ' : ';
214
+	}
191 215
 
192 216
 	// Loop on each files keyword was found
193 217
     $duplicateinsamefile=0;
@@ -204,41 +228,76 @@  discard block
 block discarded – undo
204 228
 	    $listoffilesforthisentry=array();
205 229
 	    foreach ($lines as $line => $translatedvalue)
206 230
 		{
207
-            if (! empty($listoffilesforthisentry[$file])) $duplicateinsamefile=1;
231
+            if (! empty($listoffilesforthisentry[$file])) {
232
+                $duplicateinsamefile=1;
233
+            }
208 234
             $listoffilesforthisentry[$file]=1;
209 235
 
210 236
 			$s.= "(".$line." - ".htmlentities($translatedvalue).") ";
211 237
 		}
212
-		if ($web) $s.="<br>";
238
+		if ($web) {
239
+		    $s.="<br>";
240
+		}
241
+	}
242
+	if ($web) {
243
+	    $s.="</td></tr>";
213 244
 	}
214
-	if ($web) $s.="</td></tr>";
215 245
 	$s.="\n";
216 246
 
217
-	if ($duplicateinsamefile) $sduplicateinsamefile .= $s;
218
-	else if ($inmain) $sinmainandother .= $s;
219
-	else if ($inadmin) $sininstallandadmin .= $s;
220
-	else $sother .= $s;
221
-}
247
+	if ($duplicateinsamefile) {
248
+	    $sduplicateinsamefile .= $s;
249
+	} else if ($inmain) {
250
+	    $sinmainandother .= $s;
251
+	} else if ($inadmin) {
252
+	    $sininstallandadmin .= $s;
253
+	} else {
254
+	    $sother .= $s;
255
+	}
256
+	}
222 257
 
223
-if (! $web) print "\n***** Entries duplicated in same file\n";
258
+if (! $web) {
259
+    print "\n***** Entries duplicated in same file\n";
260
+}
224 261
 print $sduplicateinsamefile;
225
-if (! $web && empty($sduplicateinsamefile)) print "None\n";
226
-if (! $web) print "\n";
262
+if (! $web && empty($sduplicateinsamefile)) {
263
+    print "None\n";
264
+}
265
+if (! $web) {
266
+    print "\n";
267
+}
227 268
 
228
-if (! $web) print "***** Entries in main and another (keep only entry in main)\n";
269
+if (! $web) {
270
+    print "***** Entries in main and another (keep only entry in main)\n";
271
+}
229 272
 print $sinmainandother;
230
-if (! $web && empty($sinmainandother)) print "None\n";
231
-if (! $web) print "\n";
273
+if (! $web && empty($sinmainandother)) {
274
+    print "None\n";
275
+}
276
+if (! $web) {
277
+    print "\n";
278
+}
232 279
 
233
-if (! $web) print "***** Entries in admin and another\n";
280
+if (! $web) {
281
+    print "***** Entries in admin and another\n";
282
+}
234 283
 print $sininstallandadmin;
235
-if (! $web && empty($sininstallandadmin)) print "None\n";
236
-if (! $web) print "\n";
284
+if (! $web && empty($sininstallandadmin)) {
285
+    print "None\n";
286
+}
287
+if (! $web) {
288
+    print "\n";
289
+}
237 290
 
238
-if (! $web) print "***** Other\n";
291
+if (! $web) {
292
+    print "***** Other\n";
293
+}
239 294
 print $sother;
240
-if (! $web && empty($sother)) print "None\n";
241
-if (! $web) print "\n";
295
+if (! $web && empty($sother)) {
296
+    print "None\n";
297
+}
298
+if (! $web) {
299
+    print "\n";
300
+}
242 301
 
243 302
 if ($web)
244 303
 {
@@ -258,93 +317,245 @@  discard block
 block discarded – undo
258 317
 	{
259 318
     	$qualifiedforclean=1;
260 319
 	    // Check if we must keep this key to be into file for removal
261
-	    if (preg_match('/^Module\d+/', $value)) $qualifiedforclean=0;
262
-	    if (preg_match('/^Permission\d+/', $value)) $qualifiedforclean=0;
263
-	    if (preg_match('/^PermissionAdvanced\d+/', $value)) $qualifiedforclean=0;
264
-	    if (preg_match('/^ProfId\d+/', $value)) $qualifiedforclean=0;
265
-	    if (preg_match('/^Delays_/', $value)) $qualifiedforclean=0;
266
-	    if (preg_match('/^BarcodeDesc/', $value)) $qualifiedforclean=0;
267
-	    if (preg_match('/^Extrafield/', $value)) $qualifiedforclean=0;
268
-	    if (preg_match('/^LocalTax/', $value)) $qualifiedforclean=0;
269
-	    if (preg_match('/^Country/', $value)) $qualifiedforclean=0;
270
-	    if (preg_match('/^Civility/', $value)) $qualifiedforclean=0;
271
-	    if (preg_match('/^Currency/', $value)) $qualifiedforclean=0;
272
-	    if (preg_match('/^DemandReasonTypeSRC/', $value)) $qualifiedforclean=0;
273
-	    if (preg_match('/^PaperFormat/', $value)) $qualifiedforclean=0;
274
-	    if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
275
-	    if (preg_match('/^AmountLT/', $value)) $qualifiedforclean=0;
276
-	    if (preg_match('/^TotalLT/', $value)) $qualifiedforclean=0;
277
-	    if (preg_match('/^Month/', $value)) $qualifiedforclean=0;
278
-	    if (preg_match('/^MonthShort/', $value)) $qualifiedforclean=0;
279
-	    if (preg_match('/^Day\d/', $value)) $qualifiedforclean=0;
280
-	    if (preg_match('/^Short/', $value)) $qualifiedforclean=0;
281
-	    if (preg_match('/^ExportDataset_/', $value)) $qualifiedforclean=0;
282
-	    if (preg_match('/^ImportDataset_/', $value)) $qualifiedforclean=0;
283
-	    if (preg_match('/^ActionAC_/', $value)) $qualifiedforclean=0;
284
-	    if (preg_match('/^TypeLocaltax/', $value)) $qualifiedforclean=0;
285
-	    if (preg_match('/^StatusProspect/', $value)) $qualifiedforclean=0;
286
-	    if (preg_match('/^PL_/', $value)) $qualifiedforclean=0;
287
-	    if (preg_match('/^TE_/', $value)) $qualifiedforclean=0;
288
-	    if (preg_match('/^JuridicalStatus/', $value)) $qualifiedforclean=0;
289
-	    if (preg_match('/^CalcMode/', $value)) $qualifiedforclean=0;
290
-	    if (preg_match('/^newLT/', $value)) $qualifiedforclean=0;
291
-	    if (preg_match('/^LT[0-9]/', $value)) $qualifiedforclean=0;
292
-	    if (preg_match('/^TypeContact_contrat_/', $value)) $qualifiedforclean=0;
293
-	    if (preg_match('/^ErrorPriceExpression/', $value)) $qualifiedforclean=0;
294
-	    if (preg_match('/^Language_/', $value)) $qualifiedforclean=0;
295
-	    if (preg_match('/^DescADHERENT_/', $value)) $qualifiedforclean=0;
296
-	    if (preg_match('/^SubmitTranslation/', $value)) $qualifiedforclean=0;
297
-	    if (preg_match('/^ModuleCompanyCode/', $value)) $qualifiedforclean=0;
298
-	    if (preg_match('/InDolibarr$/', $value)) $qualifiedforclean=0;
320
+	    if (preg_match('/^Module\d+/', $value)) {
321
+	        $qualifiedforclean=0;
322
+	    }
323
+	    if (preg_match('/^Permission\d+/', $value)) {
324
+	        $qualifiedforclean=0;
325
+	    }
326
+	    if (preg_match('/^PermissionAdvanced\d+/', $value)) {
327
+	        $qualifiedforclean=0;
328
+	    }
329
+	    if (preg_match('/^ProfId\d+/', $value)) {
330
+	        $qualifiedforclean=0;
331
+	    }
332
+	    if (preg_match('/^Delays_/', $value)) {
333
+	        $qualifiedforclean=0;
334
+	    }
335
+	    if (preg_match('/^BarcodeDesc/', $value)) {
336
+	        $qualifiedforclean=0;
337
+	    }
338
+	    if (preg_match('/^Extrafield/', $value)) {
339
+	        $qualifiedforclean=0;
340
+	    }
341
+	    if (preg_match('/^LocalTax/', $value)) {
342
+	        $qualifiedforclean=0;
343
+	    }
344
+	    if (preg_match('/^Country/', $value)) {
345
+	        $qualifiedforclean=0;
346
+	    }
347
+	    if (preg_match('/^Civility/', $value)) {
348
+	        $qualifiedforclean=0;
349
+	    }
350
+	    if (preg_match('/^Currency/', $value)) {
351
+	        $qualifiedforclean=0;
352
+	    }
353
+	    if (preg_match('/^DemandReasonTypeSRC/', $value)) {
354
+	        $qualifiedforclean=0;
355
+	    }
356
+	    if (preg_match('/^PaperFormat/', $value)) {
357
+	        $qualifiedforclean=0;
358
+	    }
359
+	    if (preg_match('/^Duration/', $value)) {
360
+	        $qualifiedforclean=0;
361
+	    }
362
+	    if (preg_match('/^AmountLT/', $value)) {
363
+	        $qualifiedforclean=0;
364
+	    }
365
+	    if (preg_match('/^TotalLT/', $value)) {
366
+	        $qualifiedforclean=0;
367
+	    }
368
+	    if (preg_match('/^Month/', $value)) {
369
+	        $qualifiedforclean=0;
370
+	    }
371
+	    if (preg_match('/^MonthShort/', $value)) {
372
+	        $qualifiedforclean=0;
373
+	    }
374
+	    if (preg_match('/^Day\d/', $value)) {
375
+	        $qualifiedforclean=0;
376
+	    }
377
+	    if (preg_match('/^Short/', $value)) {
378
+	        $qualifiedforclean=0;
379
+	    }
380
+	    if (preg_match('/^ExportDataset_/', $value)) {
381
+	        $qualifiedforclean=0;
382
+	    }
383
+	    if (preg_match('/^ImportDataset_/', $value)) {
384
+	        $qualifiedforclean=0;
385
+	    }
386
+	    if (preg_match('/^ActionAC_/', $value)) {
387
+	        $qualifiedforclean=0;
388
+	    }
389
+	    if (preg_match('/^TypeLocaltax/', $value)) {
390
+	        $qualifiedforclean=0;
391
+	    }
392
+	    if (preg_match('/^StatusProspect/', $value)) {
393
+	        $qualifiedforclean=0;
394
+	    }
395
+	    if (preg_match('/^PL_/', $value)) {
396
+	        $qualifiedforclean=0;
397
+	    }
398
+	    if (preg_match('/^TE_/', $value)) {
399
+	        $qualifiedforclean=0;
400
+	    }
401
+	    if (preg_match('/^JuridicalStatus/', $value)) {
402
+	        $qualifiedforclean=0;
403
+	    }
404
+	    if (preg_match('/^CalcMode/', $value)) {
405
+	        $qualifiedforclean=0;
406
+	    }
407
+	    if (preg_match('/^newLT/', $value)) {
408
+	        $qualifiedforclean=0;
409
+	    }
410
+	    if (preg_match('/^LT[0-9]/', $value)) {
411
+	        $qualifiedforclean=0;
412
+	    }
413
+	    if (preg_match('/^TypeContact_contrat_/', $value)) {
414
+	        $qualifiedforclean=0;
415
+	    }
416
+	    if (preg_match('/^ErrorPriceExpression/', $value)) {
417
+	        $qualifiedforclean=0;
418
+	    }
419
+	    if (preg_match('/^Language_/', $value)) {
420
+	        $qualifiedforclean=0;
421
+	    }
422
+	    if (preg_match('/^DescADHERENT_/', $value)) {
423
+	        $qualifiedforclean=0;
424
+	    }
425
+	    if (preg_match('/^SubmitTranslation/', $value)) {
426
+	        $qualifiedforclean=0;
427
+	    }
428
+	    if (preg_match('/^ModuleCompanyCode/', $value)) {
429
+	        $qualifiedforclean=0;
430
+	    }
431
+	    if (preg_match('/InDolibarr$/', $value)) {
432
+	        $qualifiedforclean=0;
433
+	    }
299 434
 	    // admin.lang
300
-	    if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) $qualifiedforclean=0;
301
-	    if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) $qualifiedforclean=0;
435
+	    if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) {
436
+	        $qualifiedforclean=0;
437
+	    }
438
+	    if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) {
439
+	        $qualifiedforclean=0;
440
+	    }
302 441
 	    // boxes.lang
303
-	    if (preg_match('/^BoxTitleLast/', $value)) $qualifiedforclean=0;
304
-	    if (preg_match('/^BoxTitleLatest/', $value)) $qualifiedforclean=0;
442
+	    if (preg_match('/^BoxTitleLast/', $value)) {
443
+	        $qualifiedforclean=0;
444
+	    }
445
+	    if (preg_match('/^BoxTitleLatest/', $value)) {
446
+	        $qualifiedforclean=0;
447
+	    }
305 448
 	    // install.lang
306
-	    if (preg_match('/^KeepDefaultValues/', $value)) $qualifiedforclean=0;
449
+	    if (preg_match('/^KeepDefaultValues/', $value)) {
450
+	        $qualifiedforclean=0;
451
+	    }
307 452
 		// mail.lang
308
-	    if (preg_match('/MailingModuleDesc/i', $value)) $qualifiedforclean=0;
453
+	    if (preg_match('/MailingModuleDesc/i', $value)) {
454
+	        $qualifiedforclean=0;
455
+	    }
309 456
 	    // main.lang
310
-	    if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
311
-	    if (preg_match('/^FormatDate/', $value)) $qualifiedforclean=0;
312
-	    if (preg_match('/^DateFormat/', $value)) $qualifiedforclean=0;
313
-	    if (preg_match('/^.b$/', $value)) $qualifiedforclean=0;
314
-	    if (preg_match('/^.*Bytes$/', $value)) $qualifiedforclean=0;
315
-	    if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) $qualifiedforclean=0;
316
-	    if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) $qualifiedforclean=0;
457
+	    if (preg_match('/^Duration/', $value)) {
458
+	        $qualifiedforclean=0;
459
+	    }
460
+	    if (preg_match('/^FormatDate/', $value)) {
461
+	        $qualifiedforclean=0;
462
+	    }
463
+	    if (preg_match('/^DateFormat/', $value)) {
464
+	        $qualifiedforclean=0;
465
+	    }
466
+	    if (preg_match('/^.b$/', $value)) {
467
+	        $qualifiedforclean=0;
468
+	    }
469
+	    if (preg_match('/^.*Bytes$/', $value)) {
470
+	        $qualifiedforclean=0;
471
+	    }
472
+	    if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) {
473
+	        $qualifiedforclean=0;
474
+	    }
475
+	    if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) {
476
+	        $qualifiedforclean=0;
477
+	    }
317 478
 		// modulebuilder
318
-		if (preg_match('/^ModuleBuilderDesc/', $value)) $qualifiedforclean=0;
479
+		if (preg_match('/^ModuleBuilderDesc/', $value)) {
480
+		    $qualifiedforclean=0;
481
+		}
319 482
 	    // orders
320
-	    if (preg_match('/^OrderSource/', $value)) $qualifiedforclean=0;
321
-	    if (preg_match('/^TypeContact_/', $value)) $qualifiedforclean=0;
483
+	    if (preg_match('/^OrderSource/', $value)) {
484
+	        $qualifiedforclean=0;
485
+	    }
486
+	    if (preg_match('/^TypeContact_/', $value)) {
487
+	        $qualifiedforclean=0;
488
+	    }
322 489
         // other.lang
323
-	    if (preg_match('/^Notify_/', $value)) $qualifiedforclean=0;
324
-	    if (preg_match('/^PredefinedMail/', $value)) $qualifiedforclean=0;
325
-	    if (preg_match('/^DemoCompany/', $value)) $qualifiedforclean=0;
326
-	    if (preg_match('/^WeightUnit/', $value)) $qualifiedforclean=0;
327
-	    if (preg_match('/^LengthUnit/', $value)) $qualifiedforclean=0;
328
-	    if (preg_match('/^SurfaceUnit/', $value)) $qualifiedforclean=0;
329
-	    if (preg_match('/^VolumeUnit/', $value)) $qualifiedforclean=0;
330
-	    if (preg_match('/^SizeUnit/', $value)) $qualifiedforclean=0;
331
-	    if (preg_match('/^EMailText/', $value)) $qualifiedforclean=0;
332
-	    if (preg_match('/ById$/', $value)) $qualifiedforclean=0;
333
-	    if (preg_match('/ByLogin$/', $value)) $qualifiedforclean=0;
490
+	    if (preg_match('/^Notify_/', $value)) {
491
+	        $qualifiedforclean=0;
492
+	    }
493
+	    if (preg_match('/^PredefinedMail/', $value)) {
494
+	        $qualifiedforclean=0;
495
+	    }
496
+	    if (preg_match('/^DemoCompany/', $value)) {
497
+	        $qualifiedforclean=0;
498
+	    }
499
+	    if (preg_match('/^WeightUnit/', $value)) {
500
+	        $qualifiedforclean=0;
501
+	    }
502
+	    if (preg_match('/^LengthUnit/', $value)) {
503
+	        $qualifiedforclean=0;
504
+	    }
505
+	    if (preg_match('/^SurfaceUnit/', $value)) {
506
+	        $qualifiedforclean=0;
507
+	    }
508
+	    if (preg_match('/^VolumeUnit/', $value)) {
509
+	        $qualifiedforclean=0;
510
+	    }
511
+	    if (preg_match('/^SizeUnit/', $value)) {
512
+	        $qualifiedforclean=0;
513
+	    }
514
+	    if (preg_match('/^EMailText/', $value)) {
515
+	        $qualifiedforclean=0;
516
+	    }
517
+	    if (preg_match('/ById$/', $value)) {
518
+	        $qualifiedforclean=0;
519
+	    }
520
+	    if (preg_match('/ByLogin$/', $value)) {
521
+	        $qualifiedforclean=0;
522
+	    }
334 523
 	    // printing
335
-	    if (preg_match('/PrintingDriverDesc$/', $value)) $qualifiedforclean=0;
336
-	    if (preg_match('/PrintTestDesc$/', $value)) $qualifiedforclean=0;
524
+	    if (preg_match('/PrintingDriverDesc$/', $value)) {
525
+	        $qualifiedforclean=0;
526
+	    }
527
+	    if (preg_match('/PrintTestDesc$/', $value)) {
528
+	        $qualifiedforclean=0;
529
+	    }
337 530
 	    // products
338
-	    if (preg_match('/GlobalVariableUpdaterType$/', $value)) $qualifiedforclean=0;
339
-	    if (preg_match('/GlobalVariableUpdaterHelp$/', $value)) $qualifiedforclean=0;
340
-	    if (preg_match('/OppStatus/', $value)) $qualifiedforclean=0;
341
-	    if (preg_match('/AvailabilityType/', $value)) $qualifiedforclean=0;
342
-	    if (preg_match('/CardProduct/', $value)) $qualifiedforclean=0;
531
+	    if (preg_match('/GlobalVariableUpdaterType$/', $value)) {
532
+	        $qualifiedforclean=0;
533
+	    }
534
+	    if (preg_match('/GlobalVariableUpdaterHelp$/', $value)) {
535
+	        $qualifiedforclean=0;
536
+	    }
537
+	    if (preg_match('/OppStatus/', $value)) {
538
+	        $qualifiedforclean=0;
539
+	    }
540
+	    if (preg_match('/AvailabilityType/', $value)) {
541
+	        $qualifiedforclean=0;
542
+	    }
543
+	    if (preg_match('/CardProduct/', $value)) {
544
+	        $qualifiedforclean=0;
545
+	    }
343 546
 
344
-	    if (preg_match('/sms/i', $value)) $qualifiedforclean=0;
345
-	    if (preg_match('/TF_/i', $value)) $qualifiedforclean=0;
346
-	    if (preg_match('/WithBankUsing/i', $value)) $qualifiedforclean=0;
347
-	    if (preg_match('/descWORKFLOW_/i', $value)) $qualifiedforclean=0;
547
+	    if (preg_match('/sms/i', $value)) {
548
+	        $qualifiedforclean=0;
549
+	    }
550
+	    if (preg_match('/TF_/i', $value)) {
551
+	        $qualifiedforclean=0;
552
+	    }
553
+	    if (preg_match('/WithBankUsing/i', $value)) {
554
+	        $qualifiedforclean=0;
555
+	    }
556
+	    if (preg_match('/descWORKFLOW_/i', $value)) {
557
+	        $qualifiedforclean=0;
558
+	    }
348 559
 
349 560
 	    if (! $qualifiedforclean)
350 561
 	    {
@@ -359,24 +570,28 @@  discard block
 block discarded – undo
359 570
 		if (empty($output)) {
360 571
    			$unused[$value] = $line;
361 572
        		echo $line;        // $trad contains the \n
362
-		}
363
-		else
573
+		} else
364 574
 		{
365 575
 		    unset($output);
366 576
 		    //print 'X'.$output.'Y';
367 577
 		}
368 578
 	}
369 579
 
370
-	if (empty($unused)) print "No string not used found.\n";
371
-	else
580
+	if (empty($unused)) {
581
+	    print "No string not used found.\n";
582
+	} else
372 583
 	{
373 584
         $filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang';
374 585
         print "Strings in en_US that are never used are saved into file ".$filetosave.":\n";
375 586
         file_put_contents($filetosave, implode("",$unused));
376 587
         print "To remove from original file, run command :\n";
377
-        if (($argv[2]?$argv[2]:"")) print 'cd htdocs/langs/en_US; mv '.($argv[2]?$argv[2]:"")." ".($argv[2]?$argv[2]:"").".tmp; ";
588
+        if (($argv[2]?$argv[2]:"")) {
589
+            print 'cd htdocs/langs/en_US; mv '.($argv[2]?$argv[2]:"")." ".($argv[2]?$argv[2]:"").".tmp; ";
590
+        }
378 591
         print "diff ".($argv[2]?$argv[2]:"").".tmp ".$filetosave." | grep \< | cut  -b 3- > ".($argv[2]?$argv[2]:"");
379
-        if (($argv[2]?$argv[2]:"")) print "; rm ".($argv[2]?$argv[2]:"").".tmp;\n";
592
+        if (($argv[2]?$argv[2]:"")) {
593
+            print "; rm ".($argv[2]?$argv[2]:"").".tmp;\n";
594
+        }
380 595
 	}
381 596
 }
382 597
 
Please login to merge, or discard this patch.