@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | * - Exclude param optioncss, token, sortfield, sortorder |
25 | 25 | */ |
26 | 26 | |
27 | -$crawledLinks=array(); |
|
28 | -const MAX_DEPTH=2; |
|
27 | +$crawledLinks = array(); |
|
28 | +const MAX_DEPTH = 2; |
|
29 | 29 | |
30 | 30 | |
31 | 31 | /** |
@@ -36,35 +36,35 @@ discard block |
||
36 | 36 | function followLink($url, $depth = 0) |
37 | 37 | { |
38 | 38 | global $crawledLinks; |
39 | - $crawling=array(); |
|
40 | - if ($depth>MAX_DEPTH) { |
|
39 | + $crawling = array(); |
|
40 | + if ($depth > MAX_DEPTH) { |
|
41 | 41 | echo "<div style='color:red;'>The Crawler is giving up!</div>"; |
42 | 42 | return; |
43 | 43 | } |
44 | - $options=array( |
|
44 | + $options = array( |
|
45 | 45 | 'http'=>array( |
46 | 46 | 'method'=>"GET", |
47 | 47 | 'user-agent'=>"gfgBot/0.1\n" |
48 | 48 | ) |
49 | 49 | ); |
50 | - $context=stream_context_create($options); |
|
51 | - $doc=new DomDocument(); |
|
50 | + $context = stream_context_create($options); |
|
51 | + $doc = new DomDocument(); |
|
52 | 52 | @$doc->loadHTML(file_get_contents($url, false, $context)); |
53 | - $links=$doc->getElementsByTagName('a'); |
|
54 | - $pageTitle=getDocTitle($doc, $url); |
|
55 | - $metaData=getDocMetaData($doc); |
|
53 | + $links = $doc->getElementsByTagName('a'); |
|
54 | + $pageTitle = getDocTitle($doc, $url); |
|
55 | + $metaData = getDocMetaData($doc); |
|
56 | 56 | foreach ($links as $i) { |
57 | - $link=$i->getAttribute('href'); |
|
57 | + $link = $i->getAttribute('href'); |
|
58 | 58 | if (ignoreLink($link)) continue; |
59 | - $link=convertLink($url, $link); |
|
59 | + $link = convertLink($url, $link); |
|
60 | 60 | if (!in_array($link, $crawledLinks)) { |
61 | - $crawledLinks[]=$link; |
|
62 | - $crawling[]=$link; |
|
61 | + $crawledLinks[] = $link; |
|
62 | + $crawling[] = $link; |
|
63 | 63 | insertIntoDatabase($link, $pageTitle, $metaData, $depth); |
64 | 64 | } |
65 | 65 | } |
66 | 66 | foreach ($crawling as $crawlURL) |
67 | - followLink($crawlURL, $depth+1); |
|
67 | + followLink($crawlURL, $depth + 1); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function convertLink($site, $path) |
76 | 76 | { |
77 | - if (substr_compare($path, "//", 0, 2)==0) |
|
77 | + if (substr_compare($path, "//", 0, 2) == 0) |
|
78 | 78 | return parse_url($site)['scheme'].$path; |
79 | - elseif (substr_compare($path, "http://", 0, 7)==0 |
|
80 | - or substr_compare($path, "https://", 0, 8)==0 |
|
81 | - or substr_compare($path, "www.", 0, 4)==0 |
|
79 | + elseif (substr_compare($path, "http://", 0, 7) == 0 |
|
80 | + or substr_compare($path, "https://", 0, 8) == 0 |
|
81 | + or substr_compare($path, "www.", 0, 4) == 0 |
|
82 | 82 | ) |
83 | 83 | return $path; |
84 | 84 | else return $site.'/'.$path; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | function ignoreLink($url) |
92 | 92 | { |
93 | - return $url[0]=="#" or substr($url, 0, 11) == "javascript:"; |
|
93 | + return $url[0] == "#" or substr($url, 0, 11) == "javascript:"; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | */ |
117 | 117 | function getDocTitle(&$doc, $url) |
118 | 118 | { |
119 | - $titleNodes=$doc->getElementsByTagName('title'); |
|
120 | - if (count($titleNodes)==0 or !isset($titleNodes[0]->nodeValue)) |
|
119 | + $titleNodes = $doc->getElementsByTagName('title'); |
|
120 | + if (count($titleNodes) == 0 or !isset($titleNodes[0]->nodeValue)) |
|
121 | 121 | return $url; |
122 | - $title=str_replace('', '\n', $titleNodes[0]->nodeValue); |
|
123 | - return (strlen($title)<1)?$url:$title; |
|
122 | + $title = str_replace('', '\n', $titleNodes[0]->nodeValue); |
|
123 | + return (strlen($title) < 1) ? $url : $title; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | */ |
130 | 130 | function getDocMetaData(&$doc) |
131 | 131 | { |
132 | - $metaData=array(); |
|
133 | - $metaNodes=$doc->getElementsByTagName('meta'); |
|
132 | + $metaData = array(); |
|
133 | + $metaNodes = $doc->getElementsByTagName('meta'); |
|
134 | 134 | foreach ($metaNodes as $node) |
135 | 135 | $metaData[$node->getAttribute("name")] = $node->getAttribute("content"); |
136 | 136 | if (!isset($metaData['description'])) |
137 | - $metaData['description']='No Description Available'; |
|
138 | - if (!isset($metaData['keywords'])) $metaData['keywords']=''; |
|
137 | + $metaData['description'] = 'No Description Available'; |
|
138 | + if (!isset($metaData['keywords'])) $metaData['keywords'] = ''; |
|
139 | 139 | return array( |
140 | 140 | 'keywords'=>str_replace('', '\n', $metaData['keywords']), |
141 | 141 | 'description'=>str_replace('', '\n', $metaData['description']) |
@@ -55,7 +55,9 @@ discard block |
||
55 | 55 | $metaData=getDocMetaData($doc); |
56 | 56 | foreach ($links as $i) { |
57 | 57 | $link=$i->getAttribute('href'); |
58 | - if (ignoreLink($link)) continue; |
|
58 | + if (ignoreLink($link)) { |
|
59 | + continue; |
|
60 | + } |
|
59 | 61 | $link=convertLink($url, $link); |
60 | 62 | if (!in_array($link, $crawledLinks)) { |
61 | 63 | $crawledLinks[]=$link; |
@@ -63,9 +65,10 @@ discard block |
||
63 | 65 | insertIntoDatabase($link, $pageTitle, $metaData, $depth); |
64 | 66 | } |
65 | 67 | } |
66 | - foreach ($crawling as $crawlURL) |
|
67 | - followLink($crawlURL, $depth+1); |
|
68 | -} |
|
68 | + foreach ($crawling as $crawlURL) { |
|
69 | + followLink($crawlURL, $depth+1); |
|
70 | + } |
|
71 | + } |
|
69 | 72 | |
70 | 73 | /** |
71 | 74 | * @param string $site Site |
@@ -74,15 +77,17 @@ discard block |
||
74 | 77 | */ |
75 | 78 | function convertLink($site, $path) |
76 | 79 | { |
77 | - if (substr_compare($path, "//", 0, 2)==0) |
|
78 | - return parse_url($site)['scheme'].$path; |
|
79 | - elseif (substr_compare($path, "http://", 0, 7)==0 |
|
80 | + if (substr_compare($path, "//", 0, 2)==0) { |
|
81 | + return parse_url($site)['scheme'].$path; |
|
82 | + } elseif (substr_compare($path, "http://", 0, 7)==0 |
|
80 | 83 | or substr_compare($path, "https://", 0, 8)==0 |
81 | 84 | or substr_compare($path, "www.", 0, 4)==0 |
82 | - ) |
|
83 | - return $path; |
|
84 | - else return $site.'/'.$path; |
|
85 | -} |
|
85 | + ) { |
|
86 | + return $path; |
|
87 | + } else { |
|
88 | + return $site.'/'.$path; |
|
89 | + } |
|
90 | + } |
|
86 | 91 | |
87 | 92 | /** |
88 | 93 | * @param string $url URL |
@@ -117,8 +122,9 @@ discard block |
||
117 | 122 | function getDocTitle(&$doc, $url) |
118 | 123 | { |
119 | 124 | $titleNodes=$doc->getElementsByTagName('title'); |
120 | - if (count($titleNodes)==0 or !isset($titleNodes[0]->nodeValue)) |
|
121 | - return $url; |
|
125 | + if (count($titleNodes)==0 or !isset($titleNodes[0]->nodeValue)) { |
|
126 | + return $url; |
|
127 | + } |
|
122 | 128 | $title=str_replace('', '\n', $titleNodes[0]->nodeValue); |
123 | 129 | return (strlen($title)<1)?$url:$title; |
124 | 130 | } |
@@ -131,11 +137,15 @@ discard block |
||
131 | 137 | { |
132 | 138 | $metaData=array(); |
133 | 139 | $metaNodes=$doc->getElementsByTagName('meta'); |
134 | - foreach ($metaNodes as $node) |
|
135 | - $metaData[$node->getAttribute("name")] = $node->getAttribute("content"); |
|
136 | - if (!isset($metaData['description'])) |
|
137 | - $metaData['description']='No Description Available'; |
|
138 | - if (!isset($metaData['keywords'])) $metaData['keywords']=''; |
|
140 | + foreach ($metaNodes as $node) { |
|
141 | + $metaData[$node->getAttribute("name")] = $node->getAttribute("content"); |
|
142 | + } |
|
143 | + if (!isset($metaData['description'])) { |
|
144 | + $metaData['description']='No Description Available'; |
|
145 | + } |
|
146 | + if (!isset($metaData['keywords'])) { |
|
147 | + $metaData['keywords']=''; |
|
148 | + } |
|
139 | 149 | return array( |
140 | 150 | 'keywords'=>str_replace('', '\n', $metaData['keywords']), |
141 | 151 | 'description'=>str_replace('', '\n', $metaData['description']) |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class Bbb |
20 | 20 | { |
21 | - const BBB='bbb'; |
|
21 | + const BBB = 'bbb'; |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * do |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | global $globalaaa, $globalbbb; |
31 | 31 | echo 'dobbb'."\n"; |
32 | - $globalaaa.='+bbb'; |
|
33 | - $globalbbb.='+bbb'; |
|
32 | + $globalaaa .= '+bbb'; |
|
33 | + $globalbbb .= '+bbb'; |
|
34 | 34 | } |
35 | 35 | } |
@@ -25,9 +25,11 @@ |
||
25 | 25 | * |
26 | 26 | * @return void |
27 | 27 | */ |
28 | - public function do() |
|
28 | + public function do { |
|
29 | + () |
|
29 | 30 | { |
30 | 31 | global $globalaaa, $globalbbb; |
32 | + } |
|
31 | 33 | echo 'dobbb'."\n"; |
32 | 34 | $globalaaa.='+bbb'; |
33 | 35 | $globalbbb.='+bbb'; |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | class Aaa |
22 | 22 | { |
23 | - const AAA='aaa'; |
|
23 | + const AAA = 'aaa'; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * do |
@@ -27,8 +27,10 @@ |
||
27 | 27 | * |
28 | 28 | * @return void |
29 | 29 | */ |
30 | - public function do() |
|
30 | + public function do { |
|
31 | + () |
|
31 | 32 | { |
32 | 33 | echo 'doaaa'."\n"; |
33 | 34 | } |
35 | + } |
|
34 | 36 | } |
@@ -65,11 +65,11 @@ |
||
65 | 65 | - To convert pfx certificate to pem: openssl pkcs12 -in tcpdf.pfx -out tcpdf.crt -nodes |
66 | 66 | |
67 | 67 | */ |
68 | -$permissions=array('copy'); |
|
69 | -$user_pass='aaa'; |
|
70 | -$owner_pass=null; |
|
71 | -$mode=0; |
|
72 | -$pubkeys=null; |
|
68 | +$permissions = array('copy'); |
|
69 | +$user_pass = 'aaa'; |
|
70 | +$owner_pass = null; |
|
71 | +$mode = 0; |
|
72 | +$pubkeys = null; |
|
73 | 73 | $pdf->SetProtection($permissions, $user_pass, $owner_pass, $mode, $pubkeys); |
74 | 74 | |
75 | 75 | // Example with public-key |
@@ -123,7 +123,7 @@ |
||
123 | 123 | Encryption Example |
124 | 124 | |
125 | 125 | Consult the source code documentation for the SetProtection() method. |
126 | -EOD; |
|
126 | +eod; |
|
127 | 127 | |
128 | 128 | // print a block of text using Write() |
129 | 129 | $pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | $sapi_type = php_sapi_name(); |
23 | 23 | $script_file = basename(__FILE__); |
24 | -$path=dirname(__FILE__).'/'; |
|
24 | +$path = dirname(__FILE__).'/'; |
|
25 | 25 | |
26 | 26 | // Test if batch mode |
27 | 27 | if (substr($sapi_type, 0, 3) == 'cgi') { |
@@ -30,39 +30,39 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | // Global variables |
33 | -$error=0; |
|
33 | +$error = 0; |
|
34 | 34 | |
35 | -$sourceserver=isset($argv[1])?$argv[1]:''; // user@server:/src/file |
|
36 | -$password=isset($argv[2])?$argv[2]:''; |
|
37 | -$dataserver=isset($argv[3])?$argv[3]:''; |
|
38 | -$database=isset($argv[4])?$argv[4]:''; |
|
39 | -$loginbase=isset($argv[5])?$argv[5]:''; |
|
40 | -$passwordbase=isset($argv[6])?$argv[6]:''; |
|
35 | +$sourceserver = isset($argv[1]) ? $argv[1] : ''; // user@server:/src/file |
|
36 | +$password = isset($argv[2]) ? $argv[2] : ''; |
|
37 | +$dataserver = isset($argv[3]) ? $argv[3] : ''; |
|
38 | +$database = isset($argv[4]) ? $argv[4] : ''; |
|
39 | +$loginbase = isset($argv[5]) ? $argv[5] : ''; |
|
40 | +$passwordbase = isset($argv[6]) ? $argv[6] : ''; |
|
41 | 41 | |
42 | 42 | // Include Dolibarr environment |
43 | -$res=0; |
|
44 | -if (! $res && file_exists($path."../../master.inc.php")) { |
|
45 | - $res=@include $path."../../master.inc.php"; |
|
43 | +$res = 0; |
|
44 | +if (!$res && file_exists($path."../../master.inc.php")) { |
|
45 | + $res = @include $path."../../master.inc.php"; |
|
46 | 46 | } |
47 | -if (! $res && file_exists($path."../../htdocs/master.inc.php")) { |
|
48 | - $res=@include $path."../../htdocs/master.inc.php"; |
|
47 | +if (!$res && file_exists($path."../../htdocs/master.inc.php")) { |
|
48 | + $res = @include $path."../../htdocs/master.inc.php"; |
|
49 | 49 | } |
50 | -if (! $res && file_exists("../master.inc.php")) { |
|
51 | - $res=@include "../master.inc.php"; |
|
50 | +if (!$res && file_exists("../master.inc.php")) { |
|
51 | + $res = @include "../master.inc.php"; |
|
52 | 52 | } |
53 | -if (! $res && file_exists("../../master.inc.php")) { |
|
54 | - $res=@include "../../master.inc.php"; |
|
53 | +if (!$res && file_exists("../../master.inc.php")) { |
|
54 | + $res = @include "../../master.inc.php"; |
|
55 | 55 | } |
56 | -if (! $res && file_exists("../../../master.inc.php")) { |
|
57 | - $res=@include "../../../master.inc.php"; |
|
56 | +if (!$res && file_exists("../../../master.inc.php")) { |
|
57 | + $res = @include "../../../master.inc.php"; |
|
58 | 58 | } |
59 | -if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) { |
|
60 | - $res=@include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only |
|
59 | +if (!$res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) { |
|
60 | + $res = @include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only |
|
61 | 61 | } |
62 | -if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) { |
|
63 | - $res=@include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only |
|
62 | +if (!$res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) { |
|
63 | + $res = @include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only |
|
64 | 64 | } |
65 | -if (! $res) { |
|
65 | +if (!$res) { |
|
66 | 66 | die("Failed to include master.inc.php file\n"); |
67 | 67 | } |
68 | 68 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | * Main |
73 | 73 | */ |
74 | 74 | |
75 | -$login=''; |
|
76 | -$server=''; |
|
75 | +$login = ''; |
|
76 | +$server = ''; |
|
77 | 77 | if (preg_match('/^(.*)@(.*):(.*)$/', $sourceserver, $reg)) { |
78 | - $login=$reg[1]; |
|
79 | - $server=$reg[2]; |
|
80 | - $sourcefile=$reg[3]; |
|
81 | - $targetfile=basename($sourcefile); |
|
78 | + $login = $reg[1]; |
|
79 | + $server = $reg[2]; |
|
80 | + $sourcefile = $reg[3]; |
|
81 | + $targetfile = basename($sourcefile); |
|
82 | 82 | } |
83 | 83 | if (empty($sourceserver) || empty($server) || empty($login) || empty($sourcefile) || empty($password) || empty($database) || empty($loginbase) || empty($passwordbase)) { |
84 | 84 | print "Usage: $script_file login@server:/src/file.(sql|gz|bz2) passssh databaseserver databasename loginbase passbase\n"; |
@@ -88,22 +88,22 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | -$targetdir='/tmp'; |
|
91 | +$targetdir = '/tmp'; |
|
92 | 92 | print "Get dump file from server ".$server.", path ".$sourcefile.", connect with login ".$login." loaded into localhost\n"; |
93 | 93 | |
94 | -$sftpconnectstring=$sourceserver; |
|
94 | +$sftpconnectstring = $sourceserver; |
|
95 | 95 | print 'SFTP connect string : '.$sftpconnectstring."\n"; |
96 | 96 | //print 'SFTP password '.$password."\n"; |
97 | 97 | |
98 | 98 | |
99 | 99 | // SFTP connect |
100 | -if (! function_exists("ssh2_connect")) { |
|
100 | +if (!function_exists("ssh2_connect")) { |
|
101 | 101 | dol_print_error('', 'ssh2_connect function does not exists'); exit(1); |
102 | 102 | } |
103 | 103 | |
104 | 104 | $connection = ssh2_connect($server, 22); |
105 | 105 | if ($connection) { |
106 | - if (! @ssh2_auth_password($connection, $login, $password)) { |
|
106 | + if (!@ssh2_auth_password($connection, $login, $password)) { |
|
107 | 107 | dol_syslog("Could not authenticate with username ".$login." . and password ".preg_replace('/./', '*', $password), LOG_ERR); |
108 | 108 | exit(-5); |
109 | 109 | } else { |
@@ -121,16 +121,16 @@ discard block |
||
121 | 121 | print 'Get file '.$sourcefile.' into '.$targetdir.$targetfile."\n"; |
122 | 122 | ssh2_scp_recv($connection, $sourcefile, $targetdir.$targetfile); |
123 | 123 | |
124 | - $fullcommand="cat ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database; |
|
124 | + $fullcommand = "cat ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database; |
|
125 | 125 | if (preg_match('/\.bz2$/', $targetfile)) { |
126 | - $fullcommand="bzip2 -c -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database; |
|
126 | + $fullcommand = "bzip2 -c -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database; |
|
127 | 127 | } |
128 | 128 | if (preg_match('/\.gz$/', $targetfile)) { |
129 | - $fullcommand="gzip -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database; |
|
129 | + $fullcommand = "gzip -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database; |
|
130 | 130 | } |
131 | 131 | print "Load dump with ".$fullcommand."\n"; |
132 | - $output=array(); |
|
133 | - $return_var=0; |
|
132 | + $output = array(); |
|
133 | + $return_var = 0; |
|
134 | 134 | print strftime("%Y%m%d-%H%M%S").' '.$fullcommand."\n"; |
135 | 135 | exec($fullcommand, $output, $return_var); |
136 | 136 | foreach ($output as $line) { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | $sapi_type = php_sapi_name(); |
48 | 48 | $script_file = basename(__FILE__); |
49 | -$path=dirname(__FILE__).'/'; |
|
49 | +$path = dirname(__FILE__).'/'; |
|
50 | 50 | |
51 | 51 | // Test if batch mode |
52 | 52 | if (substr($sapi_type, 0, 3) == 'cgi') { |
@@ -58,16 +58,16 @@ discard block |
||
58 | 58 | |
59 | 59 | // Get and check arguments |
60 | 60 | |
61 | -$lPrimary = isset($argv[1])?$argv[1]:''; |
|
62 | -$lSecondary = isset($argv[2])?$argv[2]:''; |
|
61 | +$lPrimary = isset($argv[1]) ? $argv[1] : ''; |
|
62 | +$lSecondary = isset($argv[2]) ? $argv[2] : ''; |
|
63 | 63 | $lEnglish = 'en_US'; |
64 | -$filesToProcess = isset($argv[3])?$argv[3]:''; |
|
64 | +$filesToProcess = isset($argv[3]) ? $argv[3] : ''; |
|
65 | 65 | |
66 | 66 | if (empty($lPrimary) || empty($lSecondary) || empty($filesToProcess)) { |
67 | 67 | $rc = 1; |
68 | 68 | $msg = '***** Script to clean language files *****'."\n"; |
69 | - $msg.= 'Usage: ./dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n"; |
|
70 | - print $msg . "(rc=$rc).\n"; |
|
69 | + $msg .= 'Usage: ./dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n"; |
|
70 | + print $msg."(rc=$rc).\n"; |
|
71 | 71 | exit($rc); |
72 | 72 | } |
73 | 73 | |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | if ($filesToProcess == 'all') { |
80 | 80 | $dir = new DirectoryIterator('htdocs/langs/'.$lPrimary); |
81 | 81 | while ($dir->valid()) { |
82 | - if (!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) { |
|
83 | - $files[] = $dir->getFilename(); |
|
82 | + if (!$dir->isDot() && $dir->isFile() && !preg_match('/^\./', $dir->getFilename())) { |
|
83 | + $files[] = $dir->getFilename(); |
|
84 | 84 | } |
85 | 85 | $dir->next(); |
86 | 86 | } |
87 | - $filesToProcess=$files; |
|
87 | + $filesToProcess = $files; |
|
88 | 88 | } else { |
89 | - $filesToProcess=explode(',', $filesToProcess); |
|
89 | + $filesToProcess = explode(',', $filesToProcess); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | // Arguments should be OK here. |
@@ -97,28 +97,28 @@ discard block |
||
97 | 97 | $lPrimaryFile = 'htdocs/langs/'.$lPrimary.'/'.$fileToProcess; |
98 | 98 | $lSecondaryFile = 'htdocs/langs/'.$lSecondary.'/'.$fileToProcess; |
99 | 99 | $lEnglishFile = 'htdocs/langs/'.$lEnglish.'/'.$fileToProcess; |
100 | - $output = $lSecondaryFile . '.delta'; |
|
100 | + $output = $lSecondaryFile.'.delta'; |
|
101 | 101 | |
102 | 102 | print "---- Process language file ".$lSecondaryFile."\n"; |
103 | 103 | |
104 | - if (! is_readable($lPrimaryFile)) { |
|
104 | + if (!is_readable($lPrimaryFile)) { |
|
105 | 105 | $rc = 2; |
106 | 106 | $msg = "Cannot read primary language file $lPrimaryFile."; |
107 | - print $msg . " (rc=$rc).\n"; |
|
107 | + print $msg." (rc=$rc).\n"; |
|
108 | 108 | exit($rc); |
109 | 109 | } |
110 | 110 | |
111 | - if (! is_readable($lSecondaryFile)) { |
|
111 | + if (!is_readable($lSecondaryFile)) { |
|
112 | 112 | $rc = 3; |
113 | 113 | $msg = "Cannot read secondary language file $lSecondaryFile. We discard this file."; |
114 | - print $msg . "\n"; |
|
114 | + print $msg."\n"; |
|
115 | 115 | continue; |
116 | 116 | } |
117 | 117 | |
118 | - if (! is_readable($lEnglishFile)) { |
|
118 | + if (!is_readable($lEnglishFile)) { |
|
119 | 119 | $rc = 3; |
120 | 120 | $msg = "Cannot read english language file $lEnglishFile. We discard this file."; |
121 | - print $msg . "\n"; |
|
121 | + print $msg."\n"; |
|
122 | 122 | continue; |
123 | 123 | } |
124 | 124 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | $a = mb_split('=', trim($line), 2); |
143 | 143 | if (count($a) != 2) { |
144 | - print "ERROR in file $lSecondaryFile, line $cnt: " . trim($line) . "\n"; |
|
144 | + print "ERROR in file $lSecondaryFile, line $cnt: ".trim($line)."\n"; |
|
145 | 145 | continue; |
146 | 146 | } |
147 | 147 | |
@@ -161,17 +161,17 @@ discard block |
||
161 | 161 | |
162 | 162 | $aSecondary[$key] = trim($value); |
163 | 163 | } |
164 | - if (! feof($handle)) { |
|
164 | + if (!feof($handle)) { |
|
165 | 165 | $rc = 5; |
166 | 166 | $msg = "Unexpected fgets() fail"; |
167 | - print $msg . " (rc=$rc).\n"; |
|
167 | + print $msg." (rc=$rc).\n"; |
|
168 | 168 | exit($rc); |
169 | 169 | } |
170 | 170 | fclose($handle); |
171 | 171 | } else { |
172 | 172 | $rc = 6; |
173 | 173 | $msg = "Cannot open file $lSecondaryFile"; |
174 | - print $msg . " (rc=$rc).\n"; |
|
174 | + print $msg." (rc=$rc).\n"; |
|
175 | 175 | exit($rc); |
176 | 176 | } |
177 | 177 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | |
196 | 196 | $a = mb_split('=', trim($line), 2); |
197 | 197 | if (count($a) != 2) { |
198 | - print "ERROR in file $lEnglishFile, line $cnt: " . trim($line) . "\n"; |
|
198 | + print "ERROR in file $lEnglishFile, line $cnt: ".trim($line)."\n"; |
|
199 | 199 | continue; |
200 | 200 | } |
201 | 201 | |
@@ -215,17 +215,17 @@ discard block |
||
215 | 215 | |
216 | 216 | $aEnglish[$key] = trim($value); |
217 | 217 | } |
218 | - if (! feof($handle)) { |
|
218 | + if (!feof($handle)) { |
|
219 | 219 | $rc = 5; |
220 | 220 | $msg = "Unexpected fgets() fail"; |
221 | - print $msg . " (rc=$rc).\n"; |
|
221 | + print $msg." (rc=$rc).\n"; |
|
222 | 222 | exit($rc); |
223 | 223 | } |
224 | 224 | fclose($handle); |
225 | 225 | } else { |
226 | 226 | $rc = 6; |
227 | 227 | $msg = "Cannot open file $lEnglishFile"; |
228 | - print $msg . " (rc=$rc).\n"; |
|
228 | + print $msg." (rc=$rc).\n"; |
|
229 | 229 | exit($rc); |
230 | 230 | } |
231 | 231 | |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | |
234 | 234 | // Start reading and parsing Primary. See rules in header! |
235 | 235 | |
236 | - $arrayofkeytoalwayskeep=array('DIRECTION','FONTFORPDF','FONTSIZEFORPDF','SeparatorDecimal','SeparatorThousand'); |
|
236 | + $arrayofkeytoalwayskeep = array('DIRECTION', 'FONTFORPDF', 'FONTSIZEFORPDF', 'SeparatorDecimal', 'SeparatorThousand'); |
|
237 | 237 | |
238 | 238 | |
239 | 239 | if ($handle = fopen($lPrimaryFile, 'r')) { |
240 | - if (! $oh = fopen($output, 'w')) { |
|
240 | + if (!$oh = fopen($output, 'w')) { |
|
241 | 241 | print "ERROR in writing to file ".$output."\n"; |
242 | 242 | exit; |
243 | 243 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | |
265 | 265 | $a = mb_split('=', trim($line), 2); |
266 | 266 | if (count($a) != 2) { |
267 | - print "ERROR in file $lPrimaryFile, line $cnt: " . trim($line) . "\n"; |
|
267 | + print "ERROR in file $lPrimaryFile, line $cnt: ".trim($line)."\n"; |
|
268 | 268 | continue; |
269 | 269 | } |
270 | 270 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | // Key not in other file |
297 | 297 | if (in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key)) { |
298 | 298 | //print "Key $key is a key we always want to see into secondary file (line: $cnt).\n"; |
299 | - } elseif (! array_key_exists($key, $aSecondary)) { |
|
299 | + } elseif (!array_key_exists($key, $aSecondary)) { |
|
300 | 300 | //print "Key $key does NOT exist in secondary language (line: $cnt).\n"; |
301 | 301 | continue; |
302 | 302 | } |
@@ -308,13 +308,13 @@ discard block |
||
308 | 308 | || in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key) |
309 | 309 | ) { |
310 | 310 | //print "Key $key differs (aSecondary=".$aSecondary[$key].", aPrimary=".$aPrimary[$key].", aEnglish=".$aEnglish[$key].") so we add it into new secondary language (line: $cnt).\n"; |
311 | - fwrite($oh, $key."=".(empty($aSecondary[$key])?$aPrimary[$key]:$aSecondary[$key])."\n"); |
|
311 | + fwrite($oh, $key."=".(empty($aSecondary[$key]) ? $aPrimary[$key] : $aSecondary[$key])."\n"); |
|
312 | 312 | } |
313 | 313 | } |
314 | - if (! feof($handle)) { |
|
314 | + if (!feof($handle)) { |
|
315 | 315 | $rc = 7; |
316 | 316 | $msg = "Unexpected fgets() fail"; |
317 | - print $msg . " (rc=$rc).\n"; |
|
317 | + print $msg." (rc=$rc).\n"; |
|
318 | 318 | exit($rc); |
319 | 319 | } |
320 | 320 | fclose($oh); |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | } else { |
323 | 323 | $rc = 8; |
324 | 324 | $msg = "Cannot open file $lPrimaryFile"; |
325 | - print $msg . " (rc=$rc).\n"; |
|
325 | + print $msg." (rc=$rc).\n"; |
|
326 | 326 | exit($rc); |
327 | 327 | } |
328 | 328 |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | |
150 | 150 | // key is redundant |
151 | 151 | if (array_key_exists($key, $aSecondary)) { |
152 | - print "Key $key is redundant in file $lSecondaryFile (line: $cnt).\n"; |
|
152 | + print "key $key is redundant in file $lSecondaryFile (line: $cnt).\n"; |
|
153 | 153 | continue; |
154 | 154 | } |
155 | 155 | |
156 | 156 | // String has no value |
157 | 157 | if ($value == '') { |
158 | - print "Key $key has no value in file $lSecondaryFile (line: $cnt).\n"; |
|
158 | + print "key $key has no value in file $lSecondaryFile (line: $cnt).\n"; |
|
159 | 159 | continue; |
160 | 160 | } |
161 | 161 | |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | |
204 | 204 | // key is redundant |
205 | 205 | if (array_key_exists($key, $aEnglish)) { |
206 | - print "Key $key is redundant in file $lEnglishFile (line: $cnt).\n"; |
|
206 | + print "key $key is redundant in file $lEnglishFile (line: $cnt).\n"; |
|
207 | 207 | continue; |
208 | 208 | } |
209 | 209 | |
210 | 210 | // String has no value |
211 | 211 | if ($value == '') { |
212 | - print "Key $key has no value in file $lEnglishFile (line: $cnt).\n"; |
|
212 | + print "key $key has no value in file $lEnglishFile (line: $cnt).\n"; |
|
213 | 213 | continue; |
214 | 214 | } |
215 | 215 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | |
273 | 273 | // key is redundant |
274 | 274 | if (array_key_exists($key, $aPrimary)) { |
275 | - print "Key $key is redundant in file $lPrimaryFile (line: $cnt) - Already found into ".$fileFirstFound[$key]." (line: ".$lineFirstFound[$key].").\n"; |
|
275 | + print "key $key is redundant in file $lPrimaryFile (line: $cnt) - Already found into ".$fileFirstFound[$key]." (line: ".$lineFirstFound[$key].").\n"; |
|
276 | 276 | continue; |
277 | 277 | } else { |
278 | 278 | $fileFirstFound[$key] = $fileToProcess; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | // String has no value |
283 | 283 | if ($value == '') { |
284 | - print "Key $key has no value in file $lPrimaryFile (line: $cnt).\n"; |
|
284 | + print "key $key has no value in file $lPrimaryFile (line: $cnt).\n"; |
|
285 | 285 | continue; |
286 | 286 | } |
287 | 287 |
@@ -84,46 +84,46 @@ discard block |
||
84 | 84 | $counter++; |
85 | 85 | $fileContent = null; |
86 | 86 | $refPath = $this->_langDir.$this->_refLang.self::DIR_SEPARATOR.$file; |
87 | - $fileContent = file($refPath, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); |
|
88 | - print "Processing file " . $file . ", with ".count($fileContent)." lines<br>\n"; |
|
87 | + $fileContent = file($refPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
88 | + print "Processing file ".$file.", with ".count($fileContent)." lines<br>\n"; |
|
89 | 89 | |
90 | 90 | // Define target dirs |
91 | - $targetlangs=array($this->_destlang); |
|
91 | + $targetlangs = array($this->_destlang); |
|
92 | 92 | if ($this->_destlang == 'all') { |
93 | - $targetlangs=array(); |
|
93 | + $targetlangs = array(); |
|
94 | 94 | |
95 | 95 | // If we must process all languages |
96 | - $arraytmp=dol_dir_list($this->_langDir, 'directories', 0); |
|
96 | + $arraytmp = dol_dir_list($this->_langDir, 'directories', 0); |
|
97 | 97 | foreach ($arraytmp as $dirtmp) { |
98 | 98 | if ($dirtmp['name'] === $this->_refLang) { |
99 | - continue; // We discard source language |
|
99 | + continue; // We discard source language |
|
100 | 100 | } |
101 | - $tmppart=explode('_', $dirtmp['name']); |
|
101 | + $tmppart = explode('_', $dirtmp['name']); |
|
102 | 102 | if (preg_match('/^en/i', $dirtmp['name'])) { |
103 | - continue; // We discard en_* languages |
|
103 | + continue; // We discard en_* languages |
|
104 | 104 | } |
105 | 105 | if (preg_match('/^fr/i', $dirtmp['name'])) { |
106 | - continue; // We discard fr_* languages |
|
106 | + continue; // We discard fr_* languages |
|
107 | 107 | } |
108 | 108 | if (preg_match('/^es/i', $dirtmp['name'])) { |
109 | - continue; // We discard es_* languages |
|
109 | + continue; // We discard es_* languages |
|
110 | 110 | } |
111 | 111 | if (preg_match('/ca_ES/i', $dirtmp['name'])) { |
112 | - continue; // We discard es_CA language |
|
112 | + continue; // We discard es_CA language |
|
113 | 113 | } |
114 | 114 | if (preg_match('/pt_BR/i', $dirtmp['name'])) { |
115 | - continue; // We discard pt_BR language |
|
115 | + continue; // We discard pt_BR language |
|
116 | 116 | } |
117 | 117 | if (preg_match('/nl_BE/i', $dirtmp['name'])) { |
118 | - continue; // We discard nl_BE language |
|
118 | + continue; // We discard nl_BE language |
|
119 | 119 | } |
120 | 120 | if (preg_match('/^\./i', $dirtmp['name'])) { |
121 | - continue; // We discard files .* |
|
121 | + continue; // We discard files .* |
|
122 | 122 | } |
123 | 123 | if (preg_match('/^CVS/i', $dirtmp['name'])) { |
124 | - continue; // We discard CVS |
|
124 | + continue; // We discard CVS |
|
125 | 125 | } |
126 | - $targetlangs[]=$dirtmp['name']; |
|
126 | + $targetlangs[] = $dirtmp['name']; |
|
127 | 127 | } |
128 | 128 | //var_dump($targetlangs); |
129 | 129 | } |
@@ -134,27 +134,27 @@ discard block |
||
134 | 134 | |
135 | 135 | $destPath = $this->_langDir.$my_destlang.self::DIR_SEPARATOR.$file; |
136 | 136 | // Check destination file presence |
137 | - if (! file_exists($destPath)) { |
|
137 | + if (!file_exists($destPath)) { |
|
138 | 138 | // No file present, we generate file |
139 | - echo "File not found: " . $destPath . ". We generate it.<br>\n"; |
|
139 | + echo "File not found: ".$destPath.". We generate it.<br>\n"; |
|
140 | 140 | $this->createTranslationFile($destPath, $my_destlang); |
141 | 141 | } else { |
142 | - echo "Updating file: " . $destPath . "<br>\n"; |
|
142 | + echo "Updating file: ".$destPath."<br>\n"; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // Translate lines |
146 | - $fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); |
|
147 | - $newlines=0; |
|
146 | + $fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
147 | + $newlines = 0; |
|
148 | 148 | foreach ($fileContent as $line) { |
149 | 149 | $key = $this->getLineKey($line); |
150 | 150 | $value = $this->getLineValue($line); |
151 | 151 | if ($key && $value) { |
152 | - $newlines+=$this->translateFileLine($fileContentDest, $file, $key, $value, $my_destlang); |
|
152 | + $newlines += $this->translateFileLine($fileContentDest, $file, $key, $value, $my_destlang); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | 156 | $this->updateTranslationFile($destPath, $file, $my_destlang); |
157 | - echo "New translated lines: " . $newlines . "<br>\n"; |
|
157 | + echo "New translated lines: ".$newlines."<br>\n"; |
|
158 | 158 | //if ($counter ==3) die('fim'); |
159 | 159 | } |
160 | 160 | } |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | { |
173 | 173 | $this->_time_end = date('Y-m-d H:i:s'); |
174 | 174 | |
175 | - if (isset($this->_translatedFiles[$file]) && count($this->_translatedFiles[$file])>0) { |
|
175 | + if (isset($this->_translatedFiles[$file]) && count($this->_translatedFiles[$file]) > 0) { |
|
176 | 176 | $fp = fopen($destPath, 'a'); |
177 | 177 | fwrite($fp, "\n"); |
178 | 178 | fwrite($fp, "\n"); |
179 | 179 | fwrite($fp, "// START - Lines generated via autotranslator.php tool (".$this->_time.").\n"); |
180 | 180 | fwrite($fp, "// Reference language: ".$this->_refLang." -> ".$my_destlang."\n"); |
181 | 181 | foreach ($this->_translatedFiles[$file] as $line) { |
182 | - fwrite($fp, $line . "\n"); |
|
182 | + fwrite($fp, $line."\n"); |
|
183 | 183 | } |
184 | 184 | fwrite($fp, "// STOP - Lines generated via autotranslator.php tool (".$this->_time_end.").\n"); |
185 | 185 | fclose($fp); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | fwrite($fp, "/*\n"); |
201 | 201 | fwrite($fp, " * Language code: {$my_destlang}\n"); |
202 | 202 | fwrite($fp, " * Automatic generated via autotranslator.php tool\n"); |
203 | - fwrite($fp, " * Generation date " . $this->_time. "\n"); |
|
203 | + fwrite($fp, " * Generation date ".$this->_time."\n"); |
|
204 | 204 | fwrite($fp, " */\n"); |
205 | 205 | fclose($fp); |
206 | 206 | return; |
@@ -231,27 +231,27 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | if ($key == 'CHARSET') { |
234 | - $val=$this->_outputpagecode; |
|
234 | + $val = $this->_outputpagecode; |
|
235 | 235 | } elseif (preg_match('/^Format/', $key)) { |
236 | - $val=$value; |
|
237 | - } elseif ($value=='-') { |
|
238 | - $val=$value; |
|
236 | + $val = $value; |
|
237 | + } elseif ($value == '-') { |
|
238 | + $val = $value; |
|
239 | 239 | } else { |
240 | 240 | // If not translated then translate |
241 | 241 | if ($this->_outputpagecode == 'UTF-8') { |
242 | - $val=$this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)); |
|
242 | + $val = $this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)); |
|
243 | 243 | } else { |
244 | - $val=utf8_decode($this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2))); |
|
244 | + $val = utf8_decode($this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2))); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | - $val=trim($val); |
|
248 | + $val = trim($val); |
|
249 | 249 | |
250 | 250 | if (empty($val)) { |
251 | 251 | return 0; |
252 | 252 | } |
253 | 253 | |
254 | - $this->_translatedFiles[$file][] = $key . '=' . $val ; |
|
254 | + $this->_translatedFiles[$file][] = $key.'='.$val; |
|
255 | 255 | return 1; |
256 | 256 | } |
257 | 257 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | private function getLineValue($line) |
277 | 277 | { |
278 | 278 | $arraykey = explode('=', $line, 2); |
279 | - return trim(isset($arraykey[1])?$arraykey[1]:''); |
|
279 | + return trim(isset($arraykey[1]) ? $arraykey[1] : ''); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | { |
290 | 290 | $dir = new DirectoryIterator($this->_langDir.$lang); |
291 | 291 | while ($dir->valid()) { |
292 | - if (!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) { |
|
293 | - $files[] = $dir->getFilename(); |
|
292 | + if (!$dir->isDot() && $dir->isFile() && !preg_match('/^\./', $dir->getFilename())) { |
|
293 | + $files[] = $dir->getFilename(); |
|
294 | 294 | } |
295 | 295 | $dir->next(); |
296 | 296 | } |
@@ -308,20 +308,20 @@ discard block |
||
308 | 308 | private function translateTexts($src_texts, $src_lang, $dest_lang) |
309 | 309 | { |
310 | 310 | // We want to be sure that src_lang and dest_lang are using 2 chars only |
311 | - $tmp=explode('_', $src_lang); |
|
311 | + $tmp = explode('_', $src_lang); |
|
312 | 312 | if (!empty($tmp[1]) && $tmp[0] == $tmp[1]) { |
313 | - $src_lang=$tmp[0]; |
|
313 | + $src_lang = $tmp[0]; |
|
314 | 314 | } |
315 | - $tmp=explode('_', $dest_lang); |
|
315 | + $tmp = explode('_', $dest_lang); |
|
316 | 316 | if (!empty($tmp[1]) && $tmp[0] == $tmp[1]) { |
317 | - $dest_lang=$tmp[0]; |
|
317 | + $dest_lang = $tmp[0]; |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | //setting language pair |
321 | 321 | $lang_pair = $src_lang.'|'.$dest_lang; |
322 | 322 | |
323 | - $src_text_to_translate=preg_replace('/%s/', 'SSSSS', implode('', $src_texts)); |
|
324 | - $src_text_to_translate=preg_replace('/'.preg_quote('\n\n').'/', ' NNNNN ', $src_text_to_translate); |
|
323 | + $src_text_to_translate = preg_replace('/%s/', 'SSSSS', implode('', $src_texts)); |
|
324 | + $src_text_to_translate = preg_replace('/'.preg_quote('\n\n').'/', ' NNNNN ', $src_text_to_translate); |
|
325 | 325 | |
326 | 326 | // Define GET URL v1 |
327 | 327 | //$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode($src_text_to_translate)."&langpair=".urlencode($lang_pair); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | // Send request |
334 | 334 | //print "Url to translate: ".$url."\n"; |
335 | 335 | |
336 | - if (! function_exists("curl_init")) { |
|
336 | + if (!function_exists("curl_init")) { |
|
337 | 337 | print "Error, your PHP does not support curl functions.\n"; |
338 | 338 | die(); |
339 | 339 | } |
@@ -355,10 +355,10 @@ discard block |
||
355 | 355 | return false; |
356 | 356 | } |
357 | 357 | |
358 | - $rep=$json['data']['translations'][0]['translatedText']; |
|
359 | - $rep=preg_replace('/SSSSS/i', '%s', $rep); |
|
360 | - $rep=preg_replace('/NNNNN/i', '\n\n', $rep); |
|
361 | - $rep=preg_replace('/'/i', '\'', $rep); |
|
358 | + $rep = $json['data']['translations'][0]['translatedText']; |
|
359 | + $rep = preg_replace('/SSSSS/i', '%s', $rep); |
|
360 | + $rep = preg_replace('/NNNNN/i', '\n\n', $rep); |
|
361 | + $rep = preg_replace('/'/i', '\'', $rep); |
|
362 | 362 | |
363 | 363 | //print "OK ".join('',$src_texts).' => '.$rep."\n"; |
364 | 364 |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | |
21 | 21 | $sapi_type = php_sapi_name(); |
22 | 22 | $script_file = basename(__FILE__); |
23 | -$path=dirname(__FILE__).'/'; |
|
23 | +$path = dirname(__FILE__).'/'; |
|
24 | 24 | |
25 | -$web=0; |
|
25 | +$web = 0; |
|
26 | 26 | |
27 | 27 | // Test if batch mode |
28 | 28 | if (substr($sapi_type, 0, 3) == 'cgi') { |
29 | - $web=1; |
|
29 | + $web = 1; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | exit; |
113 | 113 | } |
114 | 114 | |
115 | -$dups=array(); |
|
116 | -$exludefiles = array('.','..','README'); |
|
115 | +$dups = array(); |
|
116 | +$exludefiles = array('.', '..', 'README'); |
|
117 | 117 | $files = array_diff($files, $exludefiles); |
118 | 118 | // To force a file: $files=array('myfile.lang'); |
119 | 119 | if (isset($argv[2])) { |
@@ -124,18 +124,18 @@ discard block |
||
124 | 124 | foreach ($files as $file) { |
125 | 125 | $path_file = pathinfo($file); |
126 | 126 | // we're only interested in .lang files |
127 | - if ($path_file['extension']=='lang') { |
|
127 | + if ($path_file['extension'] == 'lang') { |
|
128 | 128 | $content = file($workdir.$file); |
129 | 129 | foreach ($content as $line => $row) { |
130 | 130 | // don't want comment lines |
131 | 131 | if (substr($row, 0, 1) !== '#') { |
132 | 132 | // don't want lines without the separator (why should those even be here, anyway...) |
133 | - if (strpos($row, '=')!==false) { |
|
134 | - $row_array = explode('=', $row); // $row_array[0] = key |
|
135 | - $langstrings_3d[$path_file['basename']][$line+1]=$row_array[0]; |
|
136 | - $langstrings_3dtrans[$path_file['basename']][$line+1]=$row_array[1]; |
|
137 | - $langstrings_full[]=$row_array[0]; |
|
138 | - $langstrings_dist[$row_array[0]]=$row; |
|
133 | + if (strpos($row, '=') !== false) { |
|
134 | + $row_array = explode('=', $row); // $row_array[0] = key |
|
135 | + $langstrings_3d[$path_file['basename']][$line + 1] = $row_array[0]; |
|
136 | + $langstrings_3dtrans[$path_file['basename']][$line + 1] = $row_array[1]; |
|
137 | + $langstrings_full[] = $row_array[0]; |
|
138 | + $langstrings_dist[$row_array[0]] = $row; |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | foreach ($langstrings_3d as $filename => $file) { |
146 | 146 | foreach ($file as $linenum => $value) { |
147 | 147 | $keys = array_keys($langstrings_full, $value); |
148 | - if (count($keys)>1) { |
|
148 | + if (count($keys) > 1) { |
|
149 | 149 | foreach ($keys as $key) { |
150 | 150 | $dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]); |
151 | 151 | } |
@@ -167,75 +167,75 @@ discard block |
||
167 | 167 | echo "<tbody>\n"; |
168 | 168 | } |
169 | 169 | |
170 | -$sduplicateinsamefile=''; |
|
171 | -$sinmainandother=''; |
|
172 | -$sininstallandadmin=''; |
|
173 | -$sother=''; |
|
170 | +$sduplicateinsamefile = ''; |
|
171 | +$sinmainandother = ''; |
|
172 | +$sininstallandadmin = ''; |
|
173 | +$sother = ''; |
|
174 | 174 | |
175 | 175 | $count = 0; |
176 | 176 | foreach ($dups as $string => $pages) { |
177 | 177 | $count++; |
178 | - $s=''; |
|
178 | + $s = ''; |
|
179 | 179 | |
180 | 180 | // Keyword $string |
181 | 181 | if ($web) { |
182 | - $s.="<tr>"; |
|
182 | + $s .= "<tr>"; |
|
183 | 183 | } |
184 | 184 | if ($web) { |
185 | - $s.="<td align=\"center\">"; |
|
185 | + $s .= "<td align=\"center\">"; |
|
186 | 186 | } |
187 | 187 | if ($web) { |
188 | - $s.=$count; |
|
188 | + $s .= $count; |
|
189 | 189 | } |
190 | 190 | if ($web) { |
191 | - $s.="</td>"; |
|
191 | + $s .= "</td>"; |
|
192 | 192 | } |
193 | 193 | if ($web) { |
194 | - $s.="<td>"; |
|
194 | + $s .= "<td>"; |
|
195 | 195 | } |
196 | - $s.=$string; |
|
196 | + $s .= $string; |
|
197 | 197 | if ($web) { |
198 | - $s.="</td>"; |
|
198 | + $s .= "</td>"; |
|
199 | 199 | } |
200 | 200 | if ($web) { |
201 | - $s.="<td>"; |
|
201 | + $s .= "<td>"; |
|
202 | 202 | } |
203 | - if (! $web) { |
|
204 | - $s.= ' : '; |
|
203 | + if (!$web) { |
|
204 | + $s .= ' : '; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | // Loop on each files keyword was found |
208 | - $duplicateinsamefile=0; |
|
209 | - $inmain=0; |
|
210 | - $inadmin=0; |
|
208 | + $duplicateinsamefile = 0; |
|
209 | + $inmain = 0; |
|
210 | + $inadmin = 0; |
|
211 | 211 | foreach ($pages as $file => $lines) { |
212 | 212 | if ($file == 'main.lang') { |
213 | - $inmain=1; $inadmin=0; |
|
213 | + $inmain = 1; $inadmin = 0; |
|
214 | 214 | } |
215 | - if ($file == 'admin.lang' && ! $inmain) { |
|
216 | - $inadmin=1; |
|
215 | + if ($file == 'admin.lang' && !$inmain) { |
|
216 | + $inadmin = 1; |
|
217 | 217 | } |
218 | 218 | |
219 | - $s.=$file." "; |
|
219 | + $s .= $file." "; |
|
220 | 220 | |
221 | 221 | // Loop on each line keword was found into file. |
222 | - $listoffilesforthisentry=array(); |
|
222 | + $listoffilesforthisentry = array(); |
|
223 | 223 | foreach ($lines as $line => $translatedvalue) { |
224 | 224 | if (!empty($listoffilesforthisentry[$file])) { |
225 | - $duplicateinsamefile=1; |
|
225 | + $duplicateinsamefile = 1; |
|
226 | 226 | } |
227 | - $listoffilesforthisentry[$file]=1; |
|
227 | + $listoffilesforthisentry[$file] = 1; |
|
228 | 228 | |
229 | - $s.= "(".$line." - ".htmlentities($translatedvalue).") "; |
|
229 | + $s .= "(".$line." - ".htmlentities($translatedvalue).") "; |
|
230 | 230 | } |
231 | 231 | if ($web) { |
232 | - $s.="<br>"; |
|
232 | + $s .= "<br>"; |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | if ($web) { |
236 | - $s.="</td></tr>"; |
|
236 | + $s .= "</td></tr>"; |
|
237 | 237 | } |
238 | - $s.="\n"; |
|
238 | + $s .= "\n"; |
|
239 | 239 | |
240 | 240 | if ($duplicateinsamefile) { |
241 | 241 | $sduplicateinsamefile .= $s; |
@@ -248,47 +248,47 @@ discard block |
||
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | -if (! $web) { |
|
251 | +if (!$web) { |
|
252 | 252 | print "\n***** Entries duplicated in same file\n"; |
253 | 253 | } |
254 | 254 | print $sduplicateinsamefile; |
255 | -if (! $web && empty($sduplicateinsamefile)) { |
|
255 | +if (!$web && empty($sduplicateinsamefile)) { |
|
256 | 256 | print "None\n"; |
257 | 257 | } |
258 | -if (! $web) { |
|
258 | +if (!$web) { |
|
259 | 259 | print "\n"; |
260 | 260 | } |
261 | 261 | |
262 | -if (! $web) { |
|
262 | +if (!$web) { |
|
263 | 263 | print "***** Entries in main and another (keep only entry in main)\n"; |
264 | 264 | } |
265 | 265 | print $sinmainandother; |
266 | -if (! $web && empty($sinmainandother)) { |
|
266 | +if (!$web && empty($sinmainandother)) { |
|
267 | 267 | print "None\n"; |
268 | 268 | } |
269 | -if (! $web) { |
|
269 | +if (!$web) { |
|
270 | 270 | print "\n"; |
271 | 271 | } |
272 | 272 | |
273 | -if (! $web) { |
|
273 | +if (!$web) { |
|
274 | 274 | print "***** Entries in admin and another\n"; |
275 | 275 | } |
276 | 276 | print $sininstallandadmin; |
277 | -if (! $web && empty($sininstallandadmin)) { |
|
277 | +if (!$web && empty($sininstallandadmin)) { |
|
278 | 278 | print "None\n"; |
279 | 279 | } |
280 | -if (! $web) { |
|
280 | +if (!$web) { |
|
281 | 281 | print "\n"; |
282 | 282 | } |
283 | 283 | |
284 | -if (! $web) { |
|
284 | +if (!$web) { |
|
285 | 285 | print "***** Other\n"; |
286 | 286 | } |
287 | 287 | print $sother; |
288 | -if (! $web && empty($sother)) { |
|
288 | +if (!$web && empty($sother)) { |
|
289 | 289 | print "None\n"; |
290 | 290 | } |
291 | -if (! $web) { |
|
291 | +if (!$web) { |
|
292 | 292 | print "\n"; |
293 | 293 | } |
294 | 294 | |
@@ -300,265 +300,265 @@ discard block |
||
300 | 300 | |
301 | 301 | // STEP 2 - Search key not used |
302 | 302 | |
303 | -if ((!empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1]=='unused=true')) { |
|
303 | +if ((!empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1] == 'unused=true')) { |
|
304 | 304 | print "***** Strings in en_US that are never used:\n"; |
305 | 305 | |
306 | - $unused=array(); |
|
306 | + $unused = array(); |
|
307 | 307 | foreach ($langstrings_dist as $value => $line) { |
308 | - $qualifiedforclean=1; |
|
308 | + $qualifiedforclean = 1; |
|
309 | 309 | // Check if we must keep this key to be into file for removal |
310 | 310 | if (preg_match('/^Module\d+/', $value)) { |
311 | - $qualifiedforclean=0; |
|
311 | + $qualifiedforclean = 0; |
|
312 | 312 | } |
313 | 313 | if (preg_match('/^Permission\d+/', $value)) { |
314 | - $qualifiedforclean=0; |
|
314 | + $qualifiedforclean = 0; |
|
315 | 315 | } |
316 | 316 | if (preg_match('/^PermissionAdvanced\d+/', $value)) { |
317 | - $qualifiedforclean=0; |
|
317 | + $qualifiedforclean = 0; |
|
318 | 318 | } |
319 | 319 | if (preg_match('/^ProfId\d+/', $value)) { |
320 | - $qualifiedforclean=0; |
|
320 | + $qualifiedforclean = 0; |
|
321 | 321 | } |
322 | 322 | if (preg_match('/^Delays_/', $value)) { |
323 | - $qualifiedforclean=0; |
|
323 | + $qualifiedforclean = 0; |
|
324 | 324 | } |
325 | 325 | if (preg_match('/^BarcodeDesc/', $value)) { |
326 | - $qualifiedforclean=0; |
|
326 | + $qualifiedforclean = 0; |
|
327 | 327 | } |
328 | 328 | if (preg_match('/^Extrafield/', $value)) { |
329 | - $qualifiedforclean=0; |
|
329 | + $qualifiedforclean = 0; |
|
330 | 330 | } |
331 | 331 | if (preg_match('/^LocalTax/', $value)) { |
332 | - $qualifiedforclean=0; |
|
332 | + $qualifiedforclean = 0; |
|
333 | 333 | } |
334 | 334 | if (preg_match('/^Country/', $value)) { |
335 | - $qualifiedforclean=0; |
|
335 | + $qualifiedforclean = 0; |
|
336 | 336 | } |
337 | 337 | if (preg_match('/^Civility/', $value)) { |
338 | - $qualifiedforclean=0; |
|
338 | + $qualifiedforclean = 0; |
|
339 | 339 | } |
340 | 340 | if (preg_match('/^Currency/', $value)) { |
341 | - $qualifiedforclean=0; |
|
341 | + $qualifiedforclean = 0; |
|
342 | 342 | } |
343 | 343 | if (preg_match('/^DemandReasonTypeSRC/', $value)) { |
344 | - $qualifiedforclean=0; |
|
344 | + $qualifiedforclean = 0; |
|
345 | 345 | } |
346 | 346 | if (preg_match('/^PaperFormat/', $value)) { |
347 | - $qualifiedforclean=0; |
|
347 | + $qualifiedforclean = 0; |
|
348 | 348 | } |
349 | 349 | if (preg_match('/^Duration/', $value)) { |
350 | - $qualifiedforclean=0; |
|
350 | + $qualifiedforclean = 0; |
|
351 | 351 | } |
352 | 352 | if (preg_match('/^AmountLT/', $value)) { |
353 | - $qualifiedforclean=0; |
|
353 | + $qualifiedforclean = 0; |
|
354 | 354 | } |
355 | 355 | if (preg_match('/^TotalLT/', $value)) { |
356 | - $qualifiedforclean=0; |
|
356 | + $qualifiedforclean = 0; |
|
357 | 357 | } |
358 | 358 | if (preg_match('/^Month/', $value)) { |
359 | - $qualifiedforclean=0; |
|
359 | + $qualifiedforclean = 0; |
|
360 | 360 | } |
361 | 361 | if (preg_match('/^MonthShort/', $value)) { |
362 | - $qualifiedforclean=0; |
|
362 | + $qualifiedforclean = 0; |
|
363 | 363 | } |
364 | 364 | if (preg_match('/^Day\d/', $value)) { |
365 | - $qualifiedforclean=0; |
|
365 | + $qualifiedforclean = 0; |
|
366 | 366 | } |
367 | 367 | if (preg_match('/^Short/', $value)) { |
368 | - $qualifiedforclean=0; |
|
368 | + $qualifiedforclean = 0; |
|
369 | 369 | } |
370 | 370 | if (preg_match('/^ExportDataset_/', $value)) { |
371 | - $qualifiedforclean=0; |
|
371 | + $qualifiedforclean = 0; |
|
372 | 372 | } |
373 | 373 | if (preg_match('/^ImportDataset_/', $value)) { |
374 | - $qualifiedforclean=0; |
|
374 | + $qualifiedforclean = 0; |
|
375 | 375 | } |
376 | 376 | if (preg_match('/^ActionAC_/', $value)) { |
377 | - $qualifiedforclean=0; |
|
377 | + $qualifiedforclean = 0; |
|
378 | 378 | } |
379 | 379 | if (preg_match('/^TypeLocaltax/', $value)) { |
380 | - $qualifiedforclean=0; |
|
380 | + $qualifiedforclean = 0; |
|
381 | 381 | } |
382 | 382 | if (preg_match('/^StatusProspect/', $value)) { |
383 | - $qualifiedforclean=0; |
|
383 | + $qualifiedforclean = 0; |
|
384 | 384 | } |
385 | 385 | if (preg_match('/^PL_/', $value)) { |
386 | - $qualifiedforclean=0; |
|
386 | + $qualifiedforclean = 0; |
|
387 | 387 | } |
388 | 388 | if (preg_match('/^TE_/', $value)) { |
389 | - $qualifiedforclean=0; |
|
389 | + $qualifiedforclean = 0; |
|
390 | 390 | } |
391 | 391 | if (preg_match('/^JuridicalStatus/', $value)) { |
392 | - $qualifiedforclean=0; |
|
392 | + $qualifiedforclean = 0; |
|
393 | 393 | } |
394 | 394 | if (preg_match('/^CalcMode/', $value)) { |
395 | - $qualifiedforclean=0; |
|
395 | + $qualifiedforclean = 0; |
|
396 | 396 | } |
397 | 397 | if (preg_match('/^newLT/', $value)) { |
398 | - $qualifiedforclean=0; |
|
398 | + $qualifiedforclean = 0; |
|
399 | 399 | } |
400 | 400 | if (preg_match('/^LT[0-9]/', $value)) { |
401 | - $qualifiedforclean=0; |
|
401 | + $qualifiedforclean = 0; |
|
402 | 402 | } |
403 | 403 | if (preg_match('/^TypeContact_contrat_/', $value)) { |
404 | - $qualifiedforclean=0; |
|
404 | + $qualifiedforclean = 0; |
|
405 | 405 | } |
406 | 406 | if (preg_match('/^ErrorPriceExpression/', $value)) { |
407 | - $qualifiedforclean=0; |
|
407 | + $qualifiedforclean = 0; |
|
408 | 408 | } |
409 | 409 | if (preg_match('/^Language_/', $value)) { |
410 | - $qualifiedforclean=0; |
|
410 | + $qualifiedforclean = 0; |
|
411 | 411 | } |
412 | 412 | if (preg_match('/^DescADHERENT_/', $value)) { |
413 | - $qualifiedforclean=0; |
|
413 | + $qualifiedforclean = 0; |
|
414 | 414 | } |
415 | 415 | if (preg_match('/^SubmitTranslation/', $value)) { |
416 | - $qualifiedforclean=0; |
|
416 | + $qualifiedforclean = 0; |
|
417 | 417 | } |
418 | 418 | if (preg_match('/^ModuleCompanyCode/', $value)) { |
419 | - $qualifiedforclean=0; |
|
419 | + $qualifiedforclean = 0; |
|
420 | 420 | } |
421 | 421 | if (preg_match('/InDolibarr$/', $value)) { |
422 | - $qualifiedforclean=0; |
|
422 | + $qualifiedforclean = 0; |
|
423 | 423 | } |
424 | 424 | // admin.lang |
425 | 425 | if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) { |
426 | - $qualifiedforclean=0; |
|
426 | + $qualifiedforclean = 0; |
|
427 | 427 | } |
428 | 428 | if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) { |
429 | - $qualifiedforclean=0; |
|
429 | + $qualifiedforclean = 0; |
|
430 | 430 | } |
431 | 431 | // boxes.lang |
432 | 432 | if (preg_match('/^BoxTitleLast/', $value)) { |
433 | - $qualifiedforclean=0; |
|
433 | + $qualifiedforclean = 0; |
|
434 | 434 | } |
435 | 435 | if (preg_match('/^BoxTitleLatest/', $value)) { |
436 | - $qualifiedforclean=0; |
|
436 | + $qualifiedforclean = 0; |
|
437 | 437 | } |
438 | 438 | // install.lang |
439 | 439 | if (preg_match('/^KeepDefaultValues/', $value)) { |
440 | - $qualifiedforclean=0; |
|
440 | + $qualifiedforclean = 0; |
|
441 | 441 | } |
442 | 442 | // mail.lang |
443 | 443 | if (preg_match('/MailingModuleDesc/i', $value)) { |
444 | - $qualifiedforclean=0; |
|
444 | + $qualifiedforclean = 0; |
|
445 | 445 | } |
446 | 446 | // main.lang |
447 | 447 | if (preg_match('/^Duration/', $value)) { |
448 | - $qualifiedforclean=0; |
|
448 | + $qualifiedforclean = 0; |
|
449 | 449 | } |
450 | 450 | if (preg_match('/^FormatDate/', $value)) { |
451 | - $qualifiedforclean=0; |
|
451 | + $qualifiedforclean = 0; |
|
452 | 452 | } |
453 | 453 | if (preg_match('/^DateFormat/', $value)) { |
454 | - $qualifiedforclean=0; |
|
454 | + $qualifiedforclean = 0; |
|
455 | 455 | } |
456 | 456 | if (preg_match('/^.b$/', $value)) { |
457 | - $qualifiedforclean=0; |
|
457 | + $qualifiedforclean = 0; |
|
458 | 458 | } |
459 | 459 | if (preg_match('/^.*Bytes$/', $value)) { |
460 | - $qualifiedforclean=0; |
|
460 | + $qualifiedforclean = 0; |
|
461 | 461 | } |
462 | 462 | if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) { |
463 | - $qualifiedforclean=0; |
|
463 | + $qualifiedforclean = 0; |
|
464 | 464 | } |
465 | 465 | if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) { |
466 | - $qualifiedforclean=0; |
|
466 | + $qualifiedforclean = 0; |
|
467 | 467 | } |
468 | 468 | // modulebuilder |
469 | 469 | if (preg_match('/^ModuleBuilderDesc/', $value)) { |
470 | - $qualifiedforclean=0; |
|
470 | + $qualifiedforclean = 0; |
|
471 | 471 | } |
472 | 472 | // orders |
473 | 473 | if (preg_match('/^OrderSource/', $value)) { |
474 | - $qualifiedforclean=0; |
|
474 | + $qualifiedforclean = 0; |
|
475 | 475 | } |
476 | 476 | if (preg_match('/^TypeContact_/', $value)) { |
477 | - $qualifiedforclean=0; |
|
477 | + $qualifiedforclean = 0; |
|
478 | 478 | } |
479 | 479 | // other.lang |
480 | 480 | if (preg_match('/^Notify_/', $value)) { |
481 | - $qualifiedforclean=0; |
|
481 | + $qualifiedforclean = 0; |
|
482 | 482 | } |
483 | 483 | if (preg_match('/^PredefinedMail/', $value)) { |
484 | - $qualifiedforclean=0; |
|
484 | + $qualifiedforclean = 0; |
|
485 | 485 | } |
486 | 486 | if (preg_match('/^DemoCompany/', $value)) { |
487 | - $qualifiedforclean=0; |
|
487 | + $qualifiedforclean = 0; |
|
488 | 488 | } |
489 | 489 | if (preg_match('/^WeightUnit/', $value)) { |
490 | - $qualifiedforclean=0; |
|
490 | + $qualifiedforclean = 0; |
|
491 | 491 | } |
492 | 492 | if (preg_match('/^LengthUnit/', $value)) { |
493 | - $qualifiedforclean=0; |
|
493 | + $qualifiedforclean = 0; |
|
494 | 494 | } |
495 | 495 | if (preg_match('/^SurfaceUnit/', $value)) { |
496 | - $qualifiedforclean=0; |
|
496 | + $qualifiedforclean = 0; |
|
497 | 497 | } |
498 | 498 | if (preg_match('/^VolumeUnit/', $value)) { |
499 | - $qualifiedforclean=0; |
|
499 | + $qualifiedforclean = 0; |
|
500 | 500 | } |
501 | 501 | if (preg_match('/^SizeUnit/', $value)) { |
502 | - $qualifiedforclean=0; |
|
502 | + $qualifiedforclean = 0; |
|
503 | 503 | } |
504 | 504 | if (preg_match('/^EMailText/', $value)) { |
505 | - $qualifiedforclean=0; |
|
505 | + $qualifiedforclean = 0; |
|
506 | 506 | } |
507 | 507 | if (preg_match('/ById$/', $value)) { |
508 | - $qualifiedforclean=0; |
|
508 | + $qualifiedforclean = 0; |
|
509 | 509 | } |
510 | 510 | if (preg_match('/ByLogin$/', $value)) { |
511 | - $qualifiedforclean=0; |
|
511 | + $qualifiedforclean = 0; |
|
512 | 512 | } |
513 | 513 | // printing |
514 | 514 | if (preg_match('/PrintingDriverDesc$/', $value)) { |
515 | - $qualifiedforclean=0; |
|
515 | + $qualifiedforclean = 0; |
|
516 | 516 | } |
517 | 517 | if (preg_match('/PrintTestDesc$/', $value)) { |
518 | - $qualifiedforclean=0; |
|
518 | + $qualifiedforclean = 0; |
|
519 | 519 | } |
520 | 520 | // products |
521 | 521 | if (preg_match('/GlobalVariableUpdaterType$/', $value)) { |
522 | - $qualifiedforclean=0; |
|
522 | + $qualifiedforclean = 0; |
|
523 | 523 | } |
524 | 524 | if (preg_match('/GlobalVariableUpdaterHelp$/', $value)) { |
525 | - $qualifiedforclean=0; |
|
525 | + $qualifiedforclean = 0; |
|
526 | 526 | } |
527 | 527 | if (preg_match('/OppStatus/', $value)) { |
528 | - $qualifiedforclean=0; |
|
528 | + $qualifiedforclean = 0; |
|
529 | 529 | } |
530 | 530 | if (preg_match('/AvailabilityType/', $value)) { |
531 | - $qualifiedforclean=0; |
|
531 | + $qualifiedforclean = 0; |
|
532 | 532 | } |
533 | 533 | if (preg_match('/CardProduct/', $value)) { |
534 | - $qualifiedforclean=0; |
|
534 | + $qualifiedforclean = 0; |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | if (preg_match('/sms/i', $value)) { |
538 | - $qualifiedforclean=0; |
|
538 | + $qualifiedforclean = 0; |
|
539 | 539 | } |
540 | 540 | if (preg_match('/TF_/i', $value)) { |
541 | - $qualifiedforclean=0; |
|
541 | + $qualifiedforclean = 0; |
|
542 | 542 | } |
543 | 543 | if (preg_match('/WithBankUsing/i', $value)) { |
544 | - $qualifiedforclean=0; |
|
544 | + $qualifiedforclean = 0; |
|
545 | 545 | } |
546 | 546 | if (preg_match('/descWORKFLOW_/i', $value)) { |
547 | - $qualifiedforclean=0; |
|
547 | + $qualifiedforclean = 0; |
|
548 | 548 | } |
549 | 549 | |
550 | - if (! $qualifiedforclean) { |
|
550 | + if (!$qualifiedforclean) { |
|
551 | 551 | continue; |
552 | 552 | } |
553 | 553 | |
554 | 554 | //$search = '\'trans("'.$value.'")\''; |
555 | 555 | $search = '-e "\''.$value.'\'" -e \'"'.$value.'"\' -e "('.$value.')" -e "('.$value.',"'; |
556 | - $string = 'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*'; |
|
556 | + $string = 'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*'; |
|
557 | 557 | //print $string."<br>\n"; |
558 | 558 | exec($string, $output); |
559 | 559 | if (empty($output)) { |
560 | 560 | $unused[$value] = $line; |
561 | - echo $line; // $trad contains the \n |
|
561 | + echo $line; // $trad contains the \n |
|
562 | 562 | } else { |
563 | 563 | unset($output); |
564 | 564 | //print 'X'.$output.'Y'; |
@@ -568,16 +568,16 @@ discard block |
||
568 | 568 | if (empty($unused)) { |
569 | 569 | print "No string not used found.\n"; |
570 | 570 | } else { |
571 | - $filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang'; |
|
571 | + $filetosave = '/tmp/'.($argv[2] ? $argv[2] : "").'notused.lang'; |
|
572 | 572 | print "Strings in en_US that are never used are saved into file ".$filetosave.":\n"; |
573 | 573 | file_put_contents($filetosave, implode("", $unused)); |
574 | 574 | print "To remove from original file, run command :\n"; |
575 | - if (($argv[2]?$argv[2]:"")) { |
|
576 | - print 'cd htdocs/langs/en_US; mv '.($argv[2]?$argv[2]:"")." ".($argv[2]?$argv[2]:"").".tmp; "; |
|
575 | + if (($argv[2] ? $argv[2] : "")) { |
|
576 | + print 'cd htdocs/langs/en_US; mv '.($argv[2] ? $argv[2] : "")." ".($argv[2] ? $argv[2] : "").".tmp; "; |
|
577 | 577 | } |
578 | - print "diff ".($argv[2]?$argv[2]:"").".tmp ".$filetosave." | grep \< | cut -b 3- > ".($argv[2]?$argv[2]:""); |
|
579 | - if (($argv[2]?$argv[2]:"")) { |
|
580 | - print "; rm ".($argv[2]?$argv[2]:"").".tmp;\n"; |
|
578 | + print "diff ".($argv[2] ? $argv[2] : "").".tmp ".$filetosave." | grep \< | cut -b 3- > ".($argv[2] ? $argv[2] : ""); |
|
579 | + if (($argv[2] ? $argv[2] : "")) { |
|
580 | + print "; rm ".($argv[2] ? $argv[2] : "").".tmp;\n"; |
|
581 | 581 | } |
582 | 582 | } |
583 | 583 | } |
@@ -28,7 +28,7 @@ discard block |
||
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 |
||
45 | 45 | $langs->load("main"); |
46 | 46 | |
47 | 47 | // Global variables |
48 | -$version='1.14'; |
|
49 | -$error=0; |
|
48 | +$version = '1.14'; |
|
49 | +$error = 0; |
|
50 | 50 | |
51 | 51 | |
52 | 52 | // -------------------- START OF YOUR CODE HERE -------------------- |
53 | 53 | @set_time_limit(0); |
54 | 54 | print "***** ".$script_file." (".$version.") *****\n"; |
55 | -$dir=DOL_DOCUMENT_ROOT."/langs"; |
|
55 | +$dir = DOL_DOCUMENT_ROOT."/langs"; |
|
56 | 56 | |
57 | 57 | // Check parameters |
58 | -if (! isset($argv[3])) { |
|
58 | +if (!isset($argv[3])) { |
|
59 | 59 | print "Usage: ".$script_file." lang_code_src lang_code_dest|all APIKEY [langfile.lang]\n"; |
60 | 60 | print "Example: ".$script_file." en_US pt_PT 123456\n"; |
61 | 61 | print "Rem: lang_code to use can be found on https://translate.google.com\n"; |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | print 'Argument 1='.$argv[1]."\n"; |
67 | 67 | print 'Argument 2='.$argv[2]."\n"; |
68 | 68 | print 'Argument 3='.$argv[3]."\n"; |
69 | -$file=''; |
|
69 | +$file = ''; |
|
70 | 70 | if (isset($argv[4])) { |
71 | - $file=$argv[4]; |
|
71 | + $file = $argv[4]; |
|
72 | 72 | print 'Argument 4='.$argv[4]."\n"; |
73 | 73 | } |
74 | 74 | print 'Files will be generated/updated in directory '.$dir."\n"; |
75 | 75 | |
76 | 76 | if ($argv[2] != 'all') { |
77 | - if (! is_dir($dir.'/'.$argv[2])) { |
|
77 | + if (!is_dir($dir.'/'.$argv[2])) { |
|
78 | 78 | print 'Create directory '.$dir.'/'.$argv[2]."\n"; |
79 | - $result=mkdir($dir.'/'.$argv[2]); |
|
80 | - if (! $result) { |
|
79 | + $result = mkdir($dir.'/'.$argv[2]); |
|
80 | + if (!$result) { |
|
81 | 81 | $db->close(); |
82 | 82 | return -1; |
83 | 83 | } |