Test Failed
Push — master ( 0ba343...0c40ee )
by Alxarafe
39:21
created
dolibarr/htdocs/core/lib/prelevement.lib.php 3 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -33,31 +33,31 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function prelevement_prepare_head(BonPrelevement $object)
35 35
 {
36
-	global $langs, $conf, $user;
37
-	$langs->load("withdrawals");
36
+    global $langs, $conf, $user;
37
+    $langs->load("withdrawals");
38 38
 
39
-	$h = 0;
40
-	$head = array();
39
+    $h = 0;
40
+    $head = array();
41 41
 
42
-	$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$object->id;
43
-	$head[$h][1] = $langs->trans("Card");
44
-	$head[$h][2] = 'prelevement';
45
-	$h++;
42
+    $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$object->id;
43
+    $head[$h][1] = $langs->trans("Card");
44
+    $head[$h][2] = 'prelevement';
45
+    $h++;
46 46
 
47
-	$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/factures.php?id='.$object->id;
48
-	$head[$h][1] = $langs->trans("Bills");
49
-	$head[$h][2] = 'invoices';
50
-	$h++;
47
+    $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/factures.php?id='.$object->id;
48
+    $head[$h][1] = $langs->trans("Bills");
49
+    $head[$h][2] = 'invoices';
50
+    $h++;
51 51
 
52
-	$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-rejet.php?id='.$object->id;
53
-	$head[$h][1] = $langs->trans("Rejects");
54
-	$head[$h][2] = 'rejects';
55
-	$h++;
52
+    $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-rejet.php?id='.$object->id;
53
+    $head[$h][1] = $langs->trans("Rejects");
54
+    $head[$h][2] = 'rejects';
55
+    $h++;
56 56
 
57
-	$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-stat.php?id='.$object->id;
58
-	$head[$h][1] = $langs->trans("Statistics");
59
-	$head[$h][2] = 'statistics';
60
-	$h++;
57
+    $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-stat.php?id='.$object->id;
58
+    $head[$h][1] = $langs->trans("Statistics");
59
+    $head[$h][2] = 'statistics';
60
+    $h++;
61 61
 
62 62
     // Show more tabs from modules
63 63
     // Entries must be declared in modules descriptor with line
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
  */
78 78
 function prelevement_check_config()
79 79
 {
80
-	global $conf;
81
-	if(empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
82
-	if(empty($conf->global->PRELEVEMENT_ICS)) return -1;
80
+    global $conf;
81
+    if(empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
82
+    if(empty($conf->global->PRELEVEMENT_ICS)) return -1;
83 83
     if(empty($conf->global->PRELEVEMENT_USER)) return -1;
84
-	return 0;
84
+    return 0;
85 85
 }
86 86
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
     // Entries must be declared in modules descriptor with line
64 64
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
65 65
     // $this->tabs = array('entity:-tabname);   												to remove a tab
66
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'prelevement');
66
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement');
67 67
 
68
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'prelevement','remove');
68
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement', 'remove');
69 69
 
70 70
     return $head;
71 71
 }
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 function prelevement_check_config()
79 79
 {
80 80
 	global $conf;
81
-	if(empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
82
-	if(empty($conf->global->PRELEVEMENT_ICS)) return -1;
83
-    if(empty($conf->global->PRELEVEMENT_USER)) return -1;
81
+	if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
82
+	if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
83
+    if (empty($conf->global->PRELEVEMENT_USER)) return -1;
84 84
 	return 0;
85 85
 }
86 86
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -78,9 +78,15 @@
 block discarded – undo
78 78
 function prelevement_check_config()
79 79
 {
80 80
 	global $conf;
81
-	if(empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
82
-	if(empty($conf->global->PRELEVEMENT_ICS)) return -1;
83
-    if(empty($conf->global->PRELEVEMENT_USER)) return -1;
81
+	if(empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) {
82
+	    return -1;
83
+	}
84
+	if(empty($conf->global->PRELEVEMENT_ICS)) {
85
+	    return -1;
86
+	}
87
+    if(empty($conf->global->PRELEVEMENT_USER)) {
88
+        return -1;
89
+    }
84 90
 	return 0;
85 91
 }
86 92
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/barcode.lib.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
     return array(
227 227
         "error" => '',
228 228
         "encoding" => $encoding,
229
-		"bars" => $line,
230
-		"text" => $text
229
+        "bars" => $line,
230
+        "text" => $text
231 231
     );
232 232
 }
233 233
 
@@ -271,16 +271,16 @@  discard block
 block discarded – undo
271 271
     }
272 272
     //var_dump($bars);
273 273
     $ret=array(
274
-		"bars" => trim($bars),
275
-		"text" => trim($text),
276
-		"encoding" => trim($encoding),
277
-    	"error" => ""
274
+        "bars" => trim($bars),
275
+        "text" => trim($text),
276
+        "encoding" => trim($encoding),
277
+        "error" => ""
278 278
     );
279 279
     //var_dump($ret);
280 280
     if (preg_match('/permission denied/i',$ret['bars']))
281 281
     {
282
-    	$ret['error']=$ret['bars']; $ret['bars']='';
283
-    	return $ret;
282
+        $ret['error']=$ret['bars']; $ret['bars']='';
283
+        return $ret;
284 284
     }
285 285
     if (!$ret['bars']) return false;
286 286
     if (!$ret['text']) return false;
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -27,18 +27,18 @@  discard block
 block discarded – undo
27 27
 /* ******************************************************************** */
28 28
 /*                          COLORS                                      */
29 29
 /* ******************************************************************** */
30
-$bar_color=array(0,0,0);
31
-$bg_color=array(255,255,255);
32
-$text_color=array(0,0,0);
30
+$bar_color = array(0, 0, 0);
31
+$bg_color = array(255, 255, 255);
32
+$text_color = array(0, 0, 0);
33 33
 
34 34
 
35 35
 /* ******************************************************************** */
36 36
 /*                          FONT FILE                                   */
37 37
 /* ******************************************************************** */
38
-if (defined('DOL_DEFAULT_TTF_BOLD')) $font_loc=constant('DOL_DEFAULT_TTF_BOLD');
38
+if (defined('DOL_DEFAULT_TTF_BOLD')) $font_loc = constant('DOL_DEFAULT_TTF_BOLD');
39 39
 // Automatic-Detection of Font if running Windows
40 40
 // @CHANGE LDR
41
-if (isset($_SERVER['WINDIR']) && @file_exists($_SERVER['WINDIR'])) $font_loc=$_SERVER['WINDIR'].'\Fonts\arialbd.ttf';
41
+if (isset($_SERVER['WINDIR']) && @file_exists($_SERVER['WINDIR'])) $font_loc = $_SERVER['WINDIR'].'\Fonts\arialbd.ttf';
42 42
 if (empty($font_loc)) die('DOL_DEFAULT_TTF_BOLD must de defined with full path to a TTF font.');
43 43
 
44 44
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 * genbarcode is needed to render encodings other than EAN-12/EAN-13/ISBN
51 51
 */
52 52
 
53
-if (defined('PHP-BARCODE_PATH_COMMAND')) $genbarcode_loc=constant('PHP-BARCODE_PATH_COMMAND');
53
+if (defined('PHP-BARCODE_PATH_COMMAND')) $genbarcode_loc = constant('PHP-BARCODE_PATH_COMMAND');
54 54
 else $genbarcode_loc = $conf->global->GENBARCODE_LOCATION;
55 55
 
56 56
 
@@ -65,20 +65,20 @@  discard block
 block discarded – undo
65 65
  * @param	string	       $mode		'png' or 'jpg' ...
66 66
  * @return	array|string   $bars		array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info) or string with error message
67 67
  */
68
-function barcode_print($code, $encoding="ANY", $scale = 2 ,$mode = "png")
68
+function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png")
69 69
 {
70 70
     dol_syslog("barcode.lib.php::barcode_print $code $encoding $scale $mode");
71 71
 
72
-    $bars=barcode_encode($code,$encoding);
73
-    if (! $bars || ! empty($bars['error']))
72
+    $bars = barcode_encode($code, $encoding);
73
+    if (!$bars || !empty($bars['error']))
74 74
     {
75 75
         // Return error message instead of array
76
-        if (empty($bars['error'])) $error='Bad Value '.$code.' for encoding '.$encoding;
77
-        else $error=$bars['error'];
76
+        if (empty($bars['error'])) $error = 'Bad Value '.$code.' for encoding '.$encoding;
77
+        else $error = $bars['error'];
78 78
         dol_syslog('barcode.lib.php::barcode_print '.$error, LOG_ERR);
79 79
         return $error;
80 80
     }
81
-    if (! $mode) $mode="png";
81
+    if (!$mode) $mode = "png";
82 82
     //if (preg_match("/^(text|txt|plain)$/i",$mode)) print barcode_outtext($bars['text'],$bars['bars']);
83 83
     //elseif (preg_match("/^(html|htm)$/i",$mode)) print barcode_outhtml($bars['text'],$bars['bars'], $scale,0, 0);
84 84
     //else
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
  * @param	string	$encoding	Encoding
109 109
  * @return	array				array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
110 110
  */
111
-function barcode_encode($code,$encoding)
111
+function barcode_encode($code, $encoding)
112 112
 {
113 113
     global $genbarcode_loc;
114 114
 
@@ -116,23 +116,23 @@  discard block
 block discarded – undo
116 116
     (preg_match("/^ean$/i", $encoding))
117 117
 
118 118
     || (($encoding) && (preg_match("/^isbn$/i", $encoding))
119
-    && (( strlen($code)==9 || strlen($code)==10) ||
120
-    (((preg_match("/^978/", $code) && strlen($code)==12) ||
121
-    (strlen($code)==13)))))
119
+    && ((strlen($code) == 9 || strlen($code) == 10) ||
120
+    (((preg_match("/^978/", $code) && strlen($code) == 12) ||
121
+    (strlen($code) == 13)))))
122 122
 
123
-    || (( !isset($encoding) || !$encoding || (preg_match("/^ANY$/i", $encoding) ))
123
+    || ((!isset($encoding) || !$encoding || (preg_match("/^ANY$/i", $encoding)))
124 124
     && (preg_match("/^[0-9]{12,13}$/", $code)))
125 125
     )
126 126
     {
127 127
         /* use built-in EAN-Encoder */
128 128
         dol_syslog("barcode.lib.php::barcode_encode Use barcode_encode_ean");
129
-        $bars=barcode_encode_ean($code, $encoding);
129
+        $bars = barcode_encode_ean($code, $encoding);
130 130
     }
131 131
     else if (file_exists($genbarcode_loc))	// For example C39
132 132
     {
133 133
         /* use genbarcode */
134 134
         dol_syslog("barcode.lib.php::barcode_encode Use genbarcode ".$genbarcode_loc." code=".$code." encoding=".$encoding);
135
-        $bars=barcode_encode_genbarcode($code, $encoding);
135
+        $bars = barcode_encode_genbarcode($code, $encoding);
136 136
     }
137 137
     else
138 138
     {
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
  */
161 161
 function barcode_gen_ean_sum($ean)
162 162
 {
163
-    $even=true; $esum=0; $osum=0;
164
-    $ln=strlen($ean)-1;
165
-    for ($i=$ln; $i>=0; $i--)
163
+    $even = true; $esum = 0; $osum = 0;
164
+    $ln = strlen($ean) - 1;
165
+    for ($i = $ln; $i >= 0; $i--)
166 166
     {
167
-        if ($even) $esum+=$ean[$i];	else $osum+=$ean[$i];
168
-        $even=!$even;
167
+        if ($even) $esum += $ean[$i]; else $osum += $ean[$i];
168
+        $even = !$even;
169 169
     }
170
-    return (10-((3*$esum+$osum)%10))%10;
170
+    return (10 - ((3 * $esum + $osum) % 10)) % 10;
171 171
 }
172 172
 
173 173
 /**
@@ -179,48 +179,48 @@  discard block
 block discarded – undo
179 179
  */
180 180
 function barcode_encode_ean($ean, $encoding = "EAN-13")
181 181
 {
182
-    $digits=array(3211,2221,2122,1411,1132,1231,1114,1312,1213,3112);
183
-    $mirror=array("000000","001011","001101","001110","010011","011001","011100","010101","010110","011010");
184
-    $guards=array("9a1a","1a1a1","a1a");
182
+    $digits = array(3211, 2221, 2122, 1411, 1132, 1231, 1114, 1312, 1213, 3112);
183
+    $mirror = array("000000", "001011", "001101", "001110", "010011", "011001", "011100", "010101", "010110", "011010");
184
+    $guards = array("9a1a", "1a1a1", "a1a");
185 185
 
186
-    $ean=trim($ean);
187
-    if (preg_match("/[^0-9]/i",$ean))
186
+    $ean = trim($ean);
187
+    if (preg_match("/[^0-9]/i", $ean))
188 188
     {
189 189
         return array("error"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (not a numeric)", "text"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (not a numeric)");
190 190
     }
191
-    $encoding=strtoupper($encoding);
192
-    if ($encoding=="ISBN")
191
+    $encoding = strtoupper($encoding);
192
+    if ($encoding == "ISBN")
193 193
     {
194
-        if (!preg_match("/^978/", $ean)) $ean="978".$ean;
194
+        if (!preg_match("/^978/", $ean)) $ean = "978".$ean;
195 195
     }
196
-    if (preg_match("/^978/", $ean)) $encoding="ISBN";
197
-    if (strlen($ean)<12 || strlen($ean)>13)
196
+    if (preg_match("/^978/", $ean)) $encoding = "ISBN";
197
+    if (strlen($ean) < 12 || strlen($ean) > 13)
198 198
     {
199 199
         return array("error"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (must have 12/13 numbers)", "text"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (must have 12/13 numbers)");
200 200
     }
201 201
 
202
-    $ean=substr($ean,0,12);
203
-    $eansum=barcode_gen_ean_sum($ean);
204
-    $ean.=$eansum;
205
-    $line=$guards[0];
206
-    for ($i=1;$i<13;$i++)
202
+    $ean = substr($ean, 0, 12);
203
+    $eansum = barcode_gen_ean_sum($ean);
204
+    $ean .= $eansum;
205
+    $line = $guards[0];
206
+    for ($i = 1; $i < 13; $i++)
207 207
     {
208
-        $str=$digits[$ean[$i]];
209
-        if ($i<7 && $mirror[$ean[0]][$i-1]==1) $line.=strrev($str); else $line.=$str;
210
-        if ($i==6) $line.=$guards[1];
208
+        $str = $digits[$ean[$i]];
209
+        if ($i < 7 && $mirror[$ean[0]][$i - 1] == 1) $line .= strrev($str); else $line .= $str;
210
+        if ($i == 6) $line .= $guards[1];
211 211
     }
212
-    $line.=$guards[2];
212
+    $line .= $guards[2];
213 213
 
214 214
     /* create text */
215
-    $pos=0;
216
-    $text="";
217
-    for ($a=0;$a<13;$a++)
215
+    $pos = 0;
216
+    $text = "";
217
+    for ($a = 0; $a < 13; $a++)
218 218
     {
219
-        if ($a>0) $text.=" ";
220
-        $text.="$pos:12:{$ean[$a]}";
221
-        if ($a==0) $pos+=12;
222
-        else if ($a==6) $pos+=12;
223
-        else $pos+=7;
219
+        if ($a > 0) $text .= " ";
220
+        $text .= "$pos:12:{$ean[$a]}";
221
+        if ($a == 0) $pos += 12;
222
+        else if ($a == 6) $pos += 12;
223
+        else $pos += 7;
224 224
     }
225 225
 
226 226
     return array(
@@ -238,30 +238,30 @@  discard block
 block discarded – undo
238 238
  * @param	string	$encoding	Encoding
239 239
  * @return	array				array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
240 240
  */
241
-function barcode_encode_genbarcode($code,$encoding)
241
+function barcode_encode_genbarcode($code, $encoding)
242 242
 {
243 243
     global $genbarcode_loc;
244 244
 
245 245
     // Clean parameters
246
-    if (preg_match("/^ean$/i", $encoding) && strlen($code)==13) $code=substr($code,0,12);
247
-    if (!$encoding) $encoding="ANY";
248
-    $encoding=preg_replace("/[\\\|]/", "_", $encoding);
249
-    $code=preg_replace("/[\\\|]/", "_", $code);
246
+    if (preg_match("/^ean$/i", $encoding) && strlen($code) == 13) $code = substr($code, 0, 12);
247
+    if (!$encoding) $encoding = "ANY";
248
+    $encoding = preg_replace("/[\\\|]/", "_", $encoding);
249
+    $code = preg_replace("/[\\\|]/", "_", $code);
250 250
 
251
-    $command=escapeshellarg($genbarcode_loc);
251
+    $command = escapeshellarg($genbarcode_loc);
252 252
     //$paramclear=" \"".str_replace("\"", "\\\"",$code)."\" \"".str_replace("\"", "\\\"",strtoupper($encoding))."\"";
253
-    $paramclear=" ".escapeshellarg($code)." ".escapeshellarg(strtoupper($encoding));
253
+    $paramclear = " ".escapeshellarg($code)." ".escapeshellarg(strtoupper($encoding));
254 254
 
255
-    $fullcommandclear=$command." ".$paramclear." 2>&1";
255
+    $fullcommandclear = $command." ".$paramclear." 2>&1";
256 256
     //print $fullcommandclear."<br>\n";exit;
257 257
 
258 258
     dol_syslog("Run command ".$fullcommandclear);
259
-    $fp=popen($fullcommandclear, "r");
259
+    $fp = popen($fullcommandclear, "r");
260 260
     if ($fp)
261 261
     {
262
-        $bars=fgets($fp, 1024);
263
-        $text=fgets($fp, 1024);
264
-        $encoding=fgets($fp, 1024);
262
+        $bars = fgets($fp, 1024);
263
+        $text = fgets($fp, 1024);
264
+        $encoding = fgets($fp, 1024);
265 265
         pclose($fp);
266 266
     }
267 267
     else
@@ -270,16 +270,16 @@  discard block
 block discarded – undo
270 270
         return false;
271 271
     }
272 272
     //var_dump($bars);
273
-    $ret=array(
273
+    $ret = array(
274 274
 		"bars" => trim($bars),
275 275
 		"text" => trim($text),
276 276
 		"encoding" => trim($encoding),
277 277
     	"error" => ""
278 278
     );
279 279
     //var_dump($ret);
280
-    if (preg_match('/permission denied/i',$ret['bars']))
280
+    if (preg_match('/permission denied/i', $ret['bars']))
281 281
     {
282
-    	$ret['error']=$ret['bars']; $ret['bars']='';
282
+    	$ret['error'] = $ret['bars']; $ret['bars'] = '';
283 283
     	return $ret;
284 284
     }
285 285
     if (!$ret['bars']) return false;
@@ -310,101 +310,101 @@  discard block
 block discarded – undo
310 310
     //var_dump($font_loc);
311 311
 
312 312
     /* set defaults */
313
-    if ($scale<1) $scale=2;
314
-    $total_y=(int) $total_y;
315
-    if ($total_y<1) $total_y=(int) $scale * 60;
313
+    if ($scale < 1) $scale = 2;
314
+    $total_y = (int) $total_y;
315
+    if ($total_y < 1) $total_y = (int) $scale * 60;
316 316
     if (!$space)
317
-    $space=array('top'=>2*$scale,'bottom'=>2*$scale,'left'=>2*$scale,'right'=>2*$scale);
317
+    $space = array('top'=>2 * $scale, 'bottom'=>2 * $scale, 'left'=>2 * $scale, 'right'=>2 * $scale);
318 318
 
319 319
     /* count total width */
320
-    $xpos=0;
321
-    $width=true;
322
-    $ln=strlen($bars);
323
-    for ($i=0; $i<$ln; $i++)
320
+    $xpos = 0;
321
+    $width = true;
322
+    $ln = strlen($bars);
323
+    for ($i = 0; $i < $ln; $i++)
324 324
     {
325
-        $val=strtolower($bars[$i]);
325
+        $val = strtolower($bars[$i]);
326 326
         if ($width)
327 327
         {
328
-            $xpos+=$val*$scale;
329
-            $width=false;
328
+            $xpos += $val * $scale;
329
+            $width = false;
330 330
             continue;
331 331
         }
332 332
         if (preg_match("/[a-z]/", $val))
333 333
         {
334 334
             /* tall bar */
335
-            $val=ord($val)-ord('a')+1;
335
+            $val = ord($val) - ord('a') + 1;
336 336
         }
337
-        $xpos+=$val*$scale;
338
-        $width=true;
337
+        $xpos += $val * $scale;
338
+        $width = true;
339 339
     }
340 340
 
341 341
     /* allocate the image */
342
-    $total_x=( $xpos )+$space['right']+$space['right'];
343
-    $xpos=$space['left'];
344
-    if (! function_exists("imagecreate"))
342
+    $total_x = ($xpos) + $space['right'] + $space['right'];
343
+    $xpos = $space['left'];
344
+    if (!function_exists("imagecreate"))
345 345
     {
346 346
         print "You don't have the gd2 extension enabled<br>\n";
347 347
         return "";
348 348
     }
349
-    $im=imagecreate($total_x, $total_y);
349
+    $im = imagecreate($total_x, $total_y);
350 350
     /* create two images */
351
-    $col_bg=ImageColorAllocate($im,$bg_color[0],$bg_color[1],$bg_color[2]);
352
-    $col_bar=ImageColorAllocate($im,$bar_color[0],$bar_color[1],$bar_color[2]);
353
-    $col_text=ImageColorAllocate($im,$text_color[0],$text_color[1],$text_color[2]);
354
-    $height=round($total_y-($scale*10));
355
-    $height2=round($total_y-$space['bottom']);
351
+    $col_bg = ImageColorAllocate($im, $bg_color[0], $bg_color[1], $bg_color[2]);
352
+    $col_bar = ImageColorAllocate($im, $bar_color[0], $bar_color[1], $bar_color[2]);
353
+    $col_text = ImageColorAllocate($im, $text_color[0], $text_color[1], $text_color[2]);
354
+    $height = round($total_y - ($scale * 10));
355
+    $height2 = round($total_y - $space['bottom']);
356 356
 
357 357
     /* paint the bars */
358
-    $width=true;
359
-    $ln=strlen($bars);
360
-    for ($i=0; $i<$ln; $i++)
358
+    $width = true;
359
+    $ln = strlen($bars);
360
+    for ($i = 0; $i < $ln; $i++)
361 361
     {
362
-        $val=strtolower($bars[$i]);
362
+        $val = strtolower($bars[$i]);
363 363
         if ($width)
364 364
         {
365
-            $xpos+=$val*$scale;
366
-            $width=false;
365
+            $xpos += $val * $scale;
366
+            $width = false;
367 367
             continue;
368 368
         }
369 369
         if (preg_match("/[a-z]/", $val))
370 370
         {
371 371
             /* tall bar */
372
-            $val=ord($val)-ord('a')+1;
373
-            $h=$height2;
374
-        } else $h=$height;
375
-        imagefilledrectangle($im, $xpos, $space['top'], $xpos+($val*$scale)-1, $h, $col_bar);
376
-        $xpos+=$val*$scale;
377
-        $width=true;
372
+            $val = ord($val) - ord('a') + 1;
373
+            $h = $height2;
374
+        } else $h = $height;
375
+        imagefilledrectangle($im, $xpos, $space['top'], $xpos + ($val * $scale) - 1, $h, $col_bar);
376
+        $xpos += $val * $scale;
377
+        $width = true;
378 378
     }
379 379
 
380
-    $chars=explode(" ", $text);
380
+    $chars = explode(" ", $text);
381 381
     reset($chars);
382
-    while (list($n, $v)=each($chars))
382
+    while (list($n, $v) = each($chars))
383 383
     {
384 384
         if (trim($v))
385 385
         {
386
-            $inf=explode(":", $v);
387
-            $fontsize=$scale*($inf[1]/1.8);
388
-            $fontheight=$total_y-($fontsize/2.7)+2;
389
-            imagettftext($im, $fontsize, 0, $space['left']+($scale*$inf[0])+2, $fontheight, $col_text, $font_loc, $inf[2]);
386
+            $inf = explode(":", $v);
387
+            $fontsize = $scale * ($inf[1] / 1.8);
388
+            $fontheight = $total_y - ($fontsize / 2.7) + 2;
389
+            imagettftext($im, $fontsize, 0, $space['left'] + ($scale * $inf[0]) + 2, $fontheight, $col_text, $font_loc, $inf[2]);
390 390
         }
391 391
     }
392 392
 
393 393
     /* output the image */
394
-    $mode=strtolower($mode);
395
-    if ($mode=='jpg' || $mode=='jpeg')
394
+    $mode = strtolower($mode);
395
+    if ($mode == 'jpg' || $mode == 'jpeg')
396 396
     {
397 397
         header("Content-Type: image/jpeg; name=\"barcode.jpg\"");
398 398
         imagejpeg($im);
399 399
     }
400
-    else if ($mode=='gif')
400
+    else if ($mode == 'gif')
401 401
     {
402 402
         header("Content-Type: image/gif; name=\"barcode.gif\"");
403 403
         imagegif($im);
404 404
     }
405
-    else if (! empty($filebarcode))    // To wxrite into  afile onto disk
405
+    else if (!empty($filebarcode))    // To wxrite into  afile onto disk
406 406
     {
407
-        imagepng($im,$filebarcode);
407
+        imagepng($im, $filebarcode);
408 408
     }
409 409
     else
410 410
     {
Please login to merge, or discard this patch.
Braces   +87 added lines, -38 removed lines patch added patch discarded remove patch
@@ -35,11 +35,17 @@  discard block
 block discarded – undo
35 35
 /* ******************************************************************** */
36 36
 /*                          FONT FILE                                   */
37 37
 /* ******************************************************************** */
38
-if (defined('DOL_DEFAULT_TTF_BOLD')) $font_loc=constant('DOL_DEFAULT_TTF_BOLD');
38
+if (defined('DOL_DEFAULT_TTF_BOLD')) {
39
+    $font_loc=constant('DOL_DEFAULT_TTF_BOLD');
40
+}
39 41
 // Automatic-Detection of Font if running Windows
40 42
 // @CHANGE LDR
41
-if (isset($_SERVER['WINDIR']) && @file_exists($_SERVER['WINDIR'])) $font_loc=$_SERVER['WINDIR'].'\Fonts\arialbd.ttf';
42
-if (empty($font_loc)) die('DOL_DEFAULT_TTF_BOLD must de defined with full path to a TTF font.');
43
+if (isset($_SERVER['WINDIR']) && @file_exists($_SERVER['WINDIR'])) {
44
+    $font_loc=$_SERVER['WINDIR'].'\Fonts\arialbd.ttf';
45
+}
46
+if (empty($font_loc)) {
47
+    die('DOL_DEFAULT_TTF_BOLD must de defined with full path to a TTF font.');
48
+}
43 49
 
44 50
 
45 51
 /* ******************************************************************** */
@@ -50,8 +56,11 @@  discard block
 block discarded – undo
50 56
 * genbarcode is needed to render encodings other than EAN-12/EAN-13/ISBN
51 57
 */
52 58
 
53
-if (defined('PHP-BARCODE_PATH_COMMAND')) $genbarcode_loc=constant('PHP-BARCODE_PATH_COMMAND');
54
-else $genbarcode_loc = $conf->global->GENBARCODE_LOCATION;
59
+if (defined('PHP-BARCODE_PATH_COMMAND')) {
60
+    $genbarcode_loc=constant('PHP-BARCODE_PATH_COMMAND');
61
+} else {
62
+    $genbarcode_loc = $conf->global->GENBARCODE_LOCATION;
63
+}
55 64
 
56 65
 
57 66
 
@@ -73,12 +82,17 @@  discard block
 block discarded – undo
73 82
     if (! $bars || ! empty($bars['error']))
74 83
     {
75 84
         // Return error message instead of array
76
-        if (empty($bars['error'])) $error='Bad Value '.$code.' for encoding '.$encoding;
77
-        else $error=$bars['error'];
85
+        if (empty($bars['error'])) {
86
+            $error='Bad Value '.$code.' for encoding '.$encoding;
87
+        } else {
88
+            $error=$bars['error'];
89
+        }
78 90
         dol_syslog('barcode.lib.php::barcode_print '.$error, LOG_ERR);
79 91
         return $error;
80 92
     }
81
-    if (! $mode) $mode="png";
93
+    if (! $mode) {
94
+        $mode="png";
95
+    }
82 96
     //if (preg_match("/^(text|txt|plain)$/i",$mode)) print barcode_outtext($bars['text'],$bars['bars']);
83 97
     //elseif (preg_match("/^(html|htm)$/i",$mode)) print barcode_outhtml($bars['text'],$bars['bars'], $scale,0, 0);
84 98
     //else
@@ -127,14 +141,14 @@  discard block
 block discarded – undo
127 141
         /* use built-in EAN-Encoder */
128 142
         dol_syslog("barcode.lib.php::barcode_encode Use barcode_encode_ean");
129 143
         $bars=barcode_encode_ean($code, $encoding);
130
-    }
131
-    else if (file_exists($genbarcode_loc))	// For example C39
144
+    } else if (file_exists($genbarcode_loc)) {
145
+        // For example C39
132 146
     {
133 147
         /* use genbarcode */
134 148
         dol_syslog("barcode.lib.php::barcode_encode Use genbarcode ".$genbarcode_loc." code=".$code." encoding=".$encoding);
135
-        $bars=barcode_encode_genbarcode($code, $encoding);
136 149
     }
137
-    else
150
+        $bars=barcode_encode_genbarcode($code, $encoding);
151
+    } else
138 152
     {
139 153
         print "barcode_encode needs an external programm for encodings other then EAN/ISBN (code=".$code.", encoding=".$encoding.")<BR>\n";
140 154
         print "<UL>\n";
@@ -164,7 +178,11 @@  discard block
 block discarded – undo
164 178
     $ln=strlen($ean)-1;
165 179
     for ($i=$ln; $i>=0; $i--)
166 180
     {
167
-        if ($even) $esum+=$ean[$i];	else $osum+=$ean[$i];
181
+        if ($even) {
182
+            $esum+=$ean[$i];
183
+        } else {
184
+            $osum+=$ean[$i];
185
+        }
168 186
         $even=!$even;
169 187
     }
170 188
     return (10-((3*$esum+$osum)%10))%10;
@@ -191,9 +209,13 @@  discard block
 block discarded – undo
191 209
     $encoding=strtoupper($encoding);
192 210
     if ($encoding=="ISBN")
193 211
     {
194
-        if (!preg_match("/^978/", $ean)) $ean="978".$ean;
212
+        if (!preg_match("/^978/", $ean)) {
213
+            $ean="978".$ean;
214
+        }
215
+    }
216
+    if (preg_match("/^978/", $ean)) {
217
+        $encoding="ISBN";
195 218
     }
196
-    if (preg_match("/^978/", $ean)) $encoding="ISBN";
197 219
     if (strlen($ean)<12 || strlen($ean)>13)
198 220
     {
199 221
         return array("error"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (must have 12/13 numbers)", "text"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (must have 12/13 numbers)");
@@ -206,8 +228,14 @@  discard block
 block discarded – undo
206 228
     for ($i=1;$i<13;$i++)
207 229
     {
208 230
         $str=$digits[$ean[$i]];
209
-        if ($i<7 && $mirror[$ean[0]][$i-1]==1) $line.=strrev($str); else $line.=$str;
210
-        if ($i==6) $line.=$guards[1];
231
+        if ($i<7 && $mirror[$ean[0]][$i-1]==1) {
232
+            $line.=strrev($str);
233
+        } else {
234
+            $line.=$str;
235
+        }
236
+        if ($i==6) {
237
+            $line.=$guards[1];
238
+        }
211 239
     }
212 240
     $line.=$guards[2];
213 241
 
@@ -216,11 +244,17 @@  discard block
 block discarded – undo
216 244
     $text="";
217 245
     for ($a=0;$a<13;$a++)
218 246
     {
219
-        if ($a>0) $text.=" ";
247
+        if ($a>0) {
248
+            $text.=" ";
249
+        }
220 250
         $text.="$pos:12:{$ean[$a]}";
221
-        if ($a==0) $pos+=12;
222
-        else if ($a==6) $pos+=12;
223
-        else $pos+=7;
251
+        if ($a==0) {
252
+            $pos+=12;
253
+        } else if ($a==6) {
254
+            $pos+=12;
255
+        } else {
256
+            $pos+=7;
257
+        }
224 258
     }
225 259
 
226 260
     return array(
@@ -243,8 +277,12 @@  discard block
 block discarded – undo
243 277
     global $genbarcode_loc;
244 278
 
245 279
     // Clean parameters
246
-    if (preg_match("/^ean$/i", $encoding) && strlen($code)==13) $code=substr($code,0,12);
247
-    if (!$encoding) $encoding="ANY";
280
+    if (preg_match("/^ean$/i", $encoding) && strlen($code)==13) {
281
+        $code=substr($code,0,12);
282
+    }
283
+    if (!$encoding) {
284
+        $encoding="ANY";
285
+    }
248 286
     $encoding=preg_replace("/[\\\|]/", "_", $encoding);
249 287
     $code=preg_replace("/[\\\|]/", "_", $code);
250 288
 
@@ -263,8 +301,7 @@  discard block
 block discarded – undo
263 301
         $text=fgets($fp, 1024);
264 302
         $encoding=fgets($fp, 1024);
265 303
         pclose($fp);
266
-    }
267
-    else
304
+    } else
268 305
     {
269 306
         dol_syslog("barcode.lib.php::barcode_encode_genbarcode failed to run popen ".$fullcommandclear, LOG_ERR);
270 307
         return false;
@@ -282,9 +319,15 @@  discard block
 block discarded – undo
282 319
     	$ret['error']=$ret['bars']; $ret['bars']='';
283 320
     	return $ret;
284 321
     }
285
-    if (!$ret['bars']) return false;
286
-    if (!$ret['text']) return false;
287
-    if (!$ret['encoding']) return false;
322
+    if (!$ret['bars']) {
323
+        return false;
324
+    }
325
+    if (!$ret['text']) {
326
+        return false;
327
+    }
328
+    if (!$ret['encoding']) {
329
+        return false;
330
+    }
288 331
     return $ret;
289 332
 }
290 333
 
@@ -310,11 +353,16 @@  discard block
 block discarded – undo
310 353
     //var_dump($font_loc);
311 354
 
312 355
     /* set defaults */
313
-    if ($scale<1) $scale=2;
356
+    if ($scale<1) {
357
+        $scale=2;
358
+    }
314 359
     $total_y=(int) $total_y;
315
-    if ($total_y<1) $total_y=(int) $scale * 60;
316
-    if (!$space)
317
-    $space=array('top'=>2*$scale,'bottom'=>2*$scale,'left'=>2*$scale,'right'=>2*$scale);
360
+    if ($total_y<1) {
361
+        $total_y=(int) $scale * 60;
362
+    }
363
+    if (!$space) {
364
+        $space=array('top'=>2*$scale,'bottom'=>2*$scale,'left'=>2*$scale,'right'=>2*$scale);
365
+    }
318 366
 
319 367
     /* count total width */
320 368
     $xpos=0;
@@ -371,7 +419,9 @@  discard block
 block discarded – undo
371 419
             /* tall bar */
372 420
             $val=ord($val)-ord('a')+1;
373 421
             $h=$height2;
374
-        } else $h=$height;
422
+        } else {
423
+            $h=$height;
424
+        }
375 425
         imagefilledrectangle($im, $xpos, $space['top'], $xpos+($val*$scale)-1, $h, $col_bar);
376 426
         $xpos+=$val*$scale;
377 427
         $width=true;
@@ -396,17 +446,16 @@  discard block
 block discarded – undo
396 446
     {
397 447
         header("Content-Type: image/jpeg; name=\"barcode.jpg\"");
398 448
         imagejpeg($im);
399
-    }
400
-    else if ($mode=='gif')
449
+    } else if ($mode=='gif')
401 450
     {
402 451
         header("Content-Type: image/gif; name=\"barcode.gif\"");
403 452
         imagegif($im);
404
-    }
405
-    else if (! empty($filebarcode))    // To wxrite into  afile onto disk
453
+    } else if (! empty($filebarcode)) {
454
+        // To wxrite into  afile onto disk
406 455
     {
407 456
         imagepng($im,$filebarcode);
408 457
     }
409
-    else
458
+    } else
410 459
     {
411 460
         header("Content-Type: image/png; name=\"barcode.png\"");
412 461
         imagepng($im);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/accounting.lib.php 3 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -31,25 +31,25 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function accounting_prepare_head(AccountingAccount $object)
33 33
 {
34
-	global $langs, $conf;
34
+    global $langs, $conf;
35 35
 
36
-	$h = 0;
37
-	$head = array ();
36
+    $h = 0;
37
+    $head = array ();
38 38
 
39
-	$head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/card.php?id=' . $object->id;
40
-	$head[$h][1] = $langs->trans("Card");
41
-	$head[$h][2] = 'card';
42
-	$h ++;
39
+    $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/card.php?id=' . $object->id;
40
+    $head[$h][1] = $langs->trans("Card");
41
+    $head[$h][2] = 'card';
42
+    $h ++;
43 43
 
44
-	// Show more tabs from modules
45
-	// Entries must be declared in modules descriptor with line
46
-	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
47
-	// $this->tabs = array('entity:-tabname); to remove a tab
48
-	complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_account');
44
+    // Show more tabs from modules
45
+    // Entries must be declared in modules descriptor with line
46
+    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
47
+    // $this->tabs = array('entity:-tabname); to remove a tab
48
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_account');
49 49
 
50
-	complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_account', 'remove');
50
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_account', 'remove');
51 51
 
52
-	return $head;
52
+    return $head;
53 53
 }
54 54
 
55 55
 /**
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
  */
61 61
 function clean_account($account)
62 62
 {
63
-	$account = rtrim($account,"0");
63
+    $account = rtrim($account,"0");
64 64
 
65
-	return $account;
65
+    return $account;
66 66
 }
67 67
 
68 68
 /**
@@ -73,31 +73,31 @@  discard block
 block discarded – undo
73 73
  */
74 74
 function length_accountg($account)
75 75
 {
76
-	global $conf;
76
+    global $conf;
77 77
 
78
-	if ($account < 0 || empty($account)) return '';
78
+    if ($account < 0 || empty($account)) return '';
79 79
 
80
-	if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
80
+    if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
81 81
 
82
-	$g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT;
83
-	if (! empty($g)) {
84
-		// Clean parameters
85
-		$i = strlen($account);
82
+    $g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT;
83
+    if (! empty($g)) {
84
+        // Clean parameters
85
+        $i = strlen($account);
86 86
 
87
-		if ($i >= 1) {
88
-			while ( $i < $g ) {
89
-				$account .= '0';
87
+        if ($i >= 1) {
88
+            while ( $i < $g ) {
89
+                $account .= '0';
90 90
 
91
-				$i ++;
92
-			}
91
+                $i ++;
92
+            }
93 93
 
94
-			return $account;
95
-		} else {
96
-			return $account;
97
-		}
98
-	} else {
99
-		return $account;
100
-	}
94
+            return $account;
95
+        } else {
96
+            return $account;
97
+        }
98
+    } else {
99
+        return $account;
100
+    }
101 101
 }
102 102
 
103 103
 /**
@@ -108,31 +108,31 @@  discard block
 block discarded – undo
108 108
  */
109 109
 function length_accounta($accounta)
110 110
 {
111
-	global $conf, $langs;
111
+    global $conf, $langs;
112 112
 
113
-	if ($accounta < 0 || empty($accounta)) return '';
113
+    if ($accounta < 0 || empty($accounta)) return '';
114 114
 
115
-	if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
115
+    if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
116 116
 
117
-	$a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
118
-	if (! empty($a)) {
119
-		// Clean parameters
120
-		$i = strlen($accounta);
117
+    $a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
118
+    if (! empty($a)) {
119
+        // Clean parameters
120
+        $i = strlen($accounta);
121 121
 
122
-		if ($i >= 1) {
123
-			while ( $i < $a ) {
124
-				$accounta .= '0';
122
+        if ($i >= 1) {
123
+            while ( $i < $a ) {
124
+                $accounta .= '0';
125 125
 
126
-				$i ++;
127
-			}
126
+                $i ++;
127
+            }
128 128
 
129
-			return $accounta;
130
-		} else {
131
-			return $accounta;
132
-		}
133
-	} else {
134
-		return $accounta;
135
-	}
129
+            return $accounta;
130
+        } else {
131
+            return $accounta;
132
+        }
133
+    } else {
134
+        return $accounta;
135
+    }
136 136
 }
137 137
 
138 138
 
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 	global $langs, $conf;
35 35
 
36 36
 	$h = 0;
37
-	$head = array ();
37
+	$head = array();
38 38
 
39
-	$head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/card.php?id=' . $object->id;
39
+	$head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.$object->id;
40 40
 	$head[$h][1] = $langs->trans("Card");
41 41
 	$head[$h][2] = 'card';
42
-	$h ++;
42
+	$h++;
43 43
 
44 44
 	// Show more tabs from modules
45 45
 	// Entries must be declared in modules descriptor with line
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  */
61 61
 function clean_account($account)
62 62
 {
63
-	$account = rtrim($account,"0");
63
+	$account = rtrim($account, "0");
64 64
 
65 65
 	return $account;
66 66
 }
@@ -77,18 +77,18 @@  discard block
 block discarded – undo
77 77
 
78 78
 	if ($account < 0 || empty($account)) return '';
79 79
 
80
-	if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
80
+	if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
81 81
 
82 82
 	$g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT;
83
-	if (! empty($g)) {
83
+	if (!empty($g)) {
84 84
 		// Clean parameters
85 85
 		$i = strlen($account);
86 86
 
87 87
 		if ($i >= 1) {
88
-			while ( $i < $g ) {
88
+			while ($i < $g) {
89 89
 				$account .= '0';
90 90
 
91
-				$i ++;
91
+				$i++;
92 92
 			}
93 93
 
94 94
 			return $account;
@@ -112,18 +112,18 @@  discard block
 block discarded – undo
112 112
 
113 113
 	if ($accounta < 0 || empty($accounta)) return '';
114 114
 
115
-	if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
115
+	if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
116 116
 
117 117
 	$a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
118
-	if (! empty($a)) {
118
+	if (!empty($a)) {
119 119
 		// Clean parameters
120 120
 		$i = strlen($accounta);
121 121
 
122 122
 		if ($i >= 1) {
123
-			while ( $i < $a ) {
123
+			while ($i < $a) {
124 124
 				$accounta .= '0';
125 125
 
126
-				$i ++;
126
+				$i++;
127 127
 			}
128 128
 
129 129
 			return $accounta;
@@ -152,17 +152,17 @@  discard block
 block discarded – undo
152 152
  *  @param  string              $varlink        Add a variable into the address of the page
153 153
  *	@return	void
154 154
  */
155
-function journalHead($nom,$variante,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='')
155
+function journalHead($nom, $variante, $period, $periodlink, $description, $builddate, $exportlink = '', $moreparam = array(), $calcmode = '', $varlink = '')
156 156
 {
157 157
     global $langs;
158 158
 
159
-    if (empty($hselected)) $hselected='report';
159
+    if (empty($hselected)) $hselected = 'report';
160 160
 
161 161
     print "\n\n<!-- debut cartouche journal -->\n";
162 162
 
163
-    if(! empty($varlink)) $varlink = '?'.$varlink;
163
+    if (!empty($varlink)) $varlink = '?'.$varlink;
164 164
 
165
-    $h=0;
165
+    $h = 0;
166 166
     $head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
167 167
     $head[$h][1] = $langs->trans("Journalization");
168 168
     $head[$h][2] = 'journal';
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
     dol_fiche_head($head, 'journal');
173 173
 
174
-    foreach($moreparam as $key => $value)
174
+    foreach ($moreparam as $key => $value)
175 175
     {
176 176
         print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
177 177
     }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     // Ligne de titre
181 181
     print '<tr>';
182 182
     print '<td width="110">'.$langs->trans("Name").'</td>';
183
-    if (! $variantexxx) print '<td colspan="3">';
183
+    if (!$variantexxx) print '<td colspan="3">';
184 184
     else print '<td>';
185 185
     print $nom;
186 186
     if ($variantexxx) print '</td><td colspan="2">'.$variantexxx;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     {
193 193
         print '<tr>';
194 194
         print '<td width="110">'.$langs->trans("CalculationMode").'</td>';
195
-        if (! $variante) print '<td colspan="3">';
195
+        if (!$variante) print '<td colspan="3">';
196 196
         else print '<td>';
197 197
         print $calcmode;
198 198
         if ($variante) print '</td><td colspan="2">'.$variante;
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     // Ligne de la periode d'analyse du rapport
204 204
     print '<tr>';
205 205
     print '<td>'.$langs->trans("ReportPeriod").'</td>';
206
-    if (! $periodlink) print '<td colspan="3">';
206
+    if (!$periodlink) print '<td colspan="3">';
207 207
     else print '<td>';
208 208
     if ($period) print $period;
209 209
     if ($periodlink) print '</td><td colspan="2">'.$periodlink;
Please login to merge, or discard this patch.
Braces   +45 added lines, -16 removed lines patch added patch discarded remove patch
@@ -75,9 +75,13 @@  discard block
 block discarded – undo
75 75
 {
76 76
 	global $conf;
77 77
 
78
-	if ($account < 0 || empty($account)) return '';
78
+	if ($account < 0 || empty($account)) {
79
+	    return '';
80
+	}
79 81
 
80
-	if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
82
+	if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
83
+	    return $account;
84
+	}
81 85
 
82 86
 	$g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT;
83 87
 	if (! empty($g)) {
@@ -110,9 +114,13 @@  discard block
 block discarded – undo
110 114
 {
111 115
 	global $conf, $langs;
112 116
 
113
-	if ($accounta < 0 || empty($accounta)) return '';
117
+	if ($accounta < 0 || empty($accounta)) {
118
+	    return '';
119
+	}
114 120
 
115
-	if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
121
+	if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
122
+	    return $accounta;
123
+	}
116 124
 
117 125
 	$a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
118 126
 	if (! empty($a)) {
@@ -156,11 +164,15 @@  discard block
 block discarded – undo
156 164
 {
157 165
     global $langs;
158 166
 
159
-    if (empty($hselected)) $hselected='report';
167
+    if (empty($hselected)) {
168
+        $hselected='report';
169
+    }
160 170
 
161 171
     print "\n\n<!-- debut cartouche journal -->\n";
162 172
 
163
-    if(! empty($varlink)) $varlink = '?'.$varlink;
173
+    if(! empty($varlink)) {
174
+        $varlink = '?'.$varlink;
175
+    }
164 176
 
165 177
     $h=0;
166 178
     $head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
@@ -180,10 +192,15 @@  discard block
 block discarded – undo
180 192
     // Ligne de titre
181 193
     print '<tr>';
182 194
     print '<td width="110">'.$langs->trans("Name").'</td>';
183
-    if (! $variantexxx) print '<td colspan="3">';
184
-    else print '<td>';
195
+    if (! $variantexxx) {
196
+        print '<td colspan="3">';
197
+    } else {
198
+        print '<td>';
199
+    }
185 200
     print $nom;
186
-    if ($variantexxx) print '</td><td colspan="2">'.$variantexxx;
201
+    if ($variantexxx) {
202
+        print '</td><td colspan="2">'.$variantexxx;
203
+    }
187 204
     print '</td>';
188 205
     print '</tr>';
189 206
 
@@ -192,10 +209,15 @@  discard block
 block discarded – undo
192 209
     {
193 210
         print '<tr>';
194 211
         print '<td width="110">'.$langs->trans("CalculationMode").'</td>';
195
-        if (! $variante) print '<td colspan="3">';
196
-        else print '<td>';
212
+        if (! $variante) {
213
+            print '<td colspan="3">';
214
+        } else {
215
+            print '<td>';
216
+        }
197 217
         print $calcmode;
198
-        if ($variante) print '</td><td colspan="2">'.$variante;
218
+        if ($variante) {
219
+            print '</td><td colspan="2">'.$variante;
220
+        }
199 221
         print '</td>';
200 222
         print '</tr>';
201 223
     }
@@ -203,10 +225,17 @@  discard block
 block discarded – undo
203 225
     // Ligne de la periode d'analyse du rapport
204 226
     print '<tr>';
205 227
     print '<td>'.$langs->trans("ReportPeriod").'</td>';
206
-    if (! $periodlink) print '<td colspan="3">';
207
-    else print '<td>';
208
-    if ($period) print $period;
209
-    if ($periodlink) print '</td><td colspan="2">'.$periodlink;
228
+    if (! $periodlink) {
229
+        print '<td colspan="3">';
230
+    } else {
231
+        print '<td>';
232
+    }
233
+    if ($period) {
234
+        print $period;
235
+    }
236
+    if ($periodlink) {
237
+        print '</td><td colspan="2">'.$periodlink;
238
+    }
210 239
     print '</td>';
211 240
     print '</tr>';
212 241
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/resource.lib.php 3 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -31,70 +31,70 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function resource_prepare_head($object)
33 33
 {
34
-	global $langs, $conf, $user;
35
-	$h = 0;
36
-	$head = array();
37
-
38
-	$head[$h][0] = dol_buildpath('/resource/card.php',1).'?id='.$object->id;
39
-	$head[$h][1] = $langs->trans("ResourceCard");
40
-    	$head[$h][2] = 'resource';
41
-	$h++;
42
-
43
-	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && (empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER) || empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY)))
44
-	{
45
-	    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
46
-	    $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
47
-		$head[$h][1] = $langs->trans('ContactsAddresses');
48
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
49
-		$head[$h][2] = 'contact';
50
-		$h++;
51
-	}
52
-
53
-	// Show more tabs from modules
54
-	// Entries must be declared in modules descriptor with line
55
-	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
56
-	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
57
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'resource');
58
-
59
-	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60
-	{
61
-		$nbNote = 0;
62
-		if(!empty($object->note_private)) $nbNote++;
63
-		if(!empty($object->note_public)) $nbNote++;
64
-		$head[$h][0] = DOL_URL_ROOT.'/resource/note.php?id='.$object->id;
65
-		$head[$h][1] = $langs->trans('Notes');
66
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
67
-		$head[$h][2] = 'note';
68
-		$h++;
69
-	}
70
-
71
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
72
-	$upload_dir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($object->ref);
73
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
74
-	$head[$h][0] = DOL_URL_ROOT.'/resource/document.php?id='.$object->id;
75
-	$head[$h][1] = $langs->trans("Documents");
76
-	if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
77
-	$head[$h][2] = 'documents';
78
-	$h++;
79
-
80
-	$head[$h][0] = DOL_URL_ROOT.'/resource/agenda.php?id='.$object->id;
81
-	$head[$h][1] = $langs->trans("Events");
82
-	if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
83
-	{
84
-		$head[$h][1].= '/';
85
-		$head[$h][1].= $langs->trans("Agenda");
86
-	}
87
-	$head[$h][2] = 'agenda';
88
-	$h++;
89
-
90
-	/*$head[$h][0] = DOL_URL_ROOT.'/resource/info.php?id='.$object->id;
34
+    global $langs, $conf, $user;
35
+    $h = 0;
36
+    $head = array();
37
+
38
+    $head[$h][0] = dol_buildpath('/resource/card.php',1).'?id='.$object->id;
39
+    $head[$h][1] = $langs->trans("ResourceCard");
40
+        $head[$h][2] = 'resource';
41
+    $h++;
42
+
43
+    if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && (empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER) || empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY)))
44
+    {
45
+        $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
46
+        $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
47
+        $head[$h][1] = $langs->trans('ContactsAddresses');
48
+        if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
49
+        $head[$h][2] = 'contact';
50
+        $h++;
51
+    }
52
+
53
+    // Show more tabs from modules
54
+    // Entries must be declared in modules descriptor with line
55
+    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
56
+    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
57
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'resource');
58
+
59
+    if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60
+    {
61
+        $nbNote = 0;
62
+        if(!empty($object->note_private)) $nbNote++;
63
+        if(!empty($object->note_public)) $nbNote++;
64
+        $head[$h][0] = DOL_URL_ROOT.'/resource/note.php?id='.$object->id;
65
+        $head[$h][1] = $langs->trans('Notes');
66
+        if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
67
+        $head[$h][2] = 'note';
68
+        $h++;
69
+    }
70
+
71
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
72
+    $upload_dir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($object->ref);
73
+    $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
74
+    $head[$h][0] = DOL_URL_ROOT.'/resource/document.php?id='.$object->id;
75
+    $head[$h][1] = $langs->trans("Documents");
76
+    if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
77
+    $head[$h][2] = 'documents';
78
+    $h++;
79
+
80
+    $head[$h][0] = DOL_URL_ROOT.'/resource/agenda.php?id='.$object->id;
81
+    $head[$h][1] = $langs->trans("Events");
82
+    if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
83
+    {
84
+        $head[$h][1].= '/';
85
+        $head[$h][1].= $langs->trans("Agenda");
86
+    }
87
+    $head[$h][2] = 'agenda';
88
+    $h++;
89
+
90
+    /*$head[$h][0] = DOL_URL_ROOT.'/resource/info.php?id='.$object->id;
91 91
 	$head[$h][1] = $langs->trans('Info');
92 92
 	$head[$h][2] = 'info';
93 93
 	$h++;*/
94 94
 
95
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'resource', 'remove');
95
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'resource', 'remove');
96 96
 
97
-	return $head;
97
+    return $head;
98 98
 }
99 99
 
100 100
 /**
@@ -105,28 +105,28 @@  discard block
 block discarded – undo
105 105
 function resource_admin_prepare_head()
106 106
 {
107 107
 
108
-	global $langs, $conf, $user;
108
+    global $langs, $conf, $user;
109 109
 
110
-	$h = 0;
111
-	$head = array();
110
+    $h = 0;
111
+    $head = array();
112 112
 
113
-	$head[$h][0] = DOL_URL_ROOT.'/admin/resource.php';
114
-	$head[$h][1] = $langs->trans("ResourceSetup");
115
-	$head[$h][2] = 'general';
116
-	$h++;
113
+    $head[$h][0] = DOL_URL_ROOT.'/admin/resource.php';
114
+    $head[$h][1] = $langs->trans("ResourceSetup");
115
+    $head[$h][2] = 'general';
116
+    $h++;
117 117
 
118
-	// Show more tabs from modules
119
-	// Entries must be declared in modules descriptor with line
120
-	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
121
-	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
122
-	complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin');
118
+    // Show more tabs from modules
119
+    // Entries must be declared in modules descriptor with line
120
+    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
121
+    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
122
+    complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin');
123 123
 
124
-	$head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php';
125
-	$head[$h][1] = $langs->trans("ExtraFields");
126
-	$head[$h][2] = 'attributes';
127
-	$h++;
124
+    $head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php';
125
+    $head[$h][1] = $langs->trans("ExtraFields");
126
+    $head[$h][2] = 'attributes';
127
+    $h++;
128 128
 
129
-	complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin','remove');
129
+    complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin','remove');
130 130
 
131
-	return $head;
131
+    return $head;
132 132
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 	$h = 0;
36 36
 	$head = array();
37 37
 
38
-	$head[$h][0] = dol_buildpath('/resource/card.php',1).'?id='.$object->id;
38
+	$head[$h][0] = dol_buildpath('/resource/card.php', 1).'?id='.$object->id;
39 39
 	$head[$h][1] = $langs->trans("ResourceCard");
40 40
     	$head[$h][2] = 'resource';
41 41
 	$h++;
42 42
 
43 43
 	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && (empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER) || empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY)))
44 44
 	{
45
-	    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
45
+	    $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
46 46
 	    $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
47 47
 		$head[$h][1] = $langs->trans('ContactsAddresses');
48
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
48
+		if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>';
49 49
 		$head[$h][2] = 'contact';
50 50
 		$h++;
51 51
 	}
@@ -54,35 +54,35 @@  discard block
 block discarded – undo
54 54
 	// Entries must be declared in modules descriptor with line
55 55
 	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
56 56
 	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
57
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'resource');
57
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'resource');
58 58
 
59 59
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60 60
 	{
61 61
 		$nbNote = 0;
62
-		if(!empty($object->note_private)) $nbNote++;
63
-		if(!empty($object->note_public)) $nbNote++;
62
+		if (!empty($object->note_private)) $nbNote++;
63
+		if (!empty($object->note_public)) $nbNote++;
64 64
 		$head[$h][0] = DOL_URL_ROOT.'/resource/note.php?id='.$object->id;
65 65
 		$head[$h][1] = $langs->trans('Notes');
66
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
66
+		if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>';
67 67
 		$head[$h][2] = 'note';
68 68
 		$h++;
69 69
 	}
70 70
 
71 71
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
72
-	$upload_dir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($object->ref);
73
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
72
+	$upload_dir = $conf->resource->dir_output."/".dol_sanitizeFileName($object->ref);
73
+	$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
74 74
 	$head[$h][0] = DOL_URL_ROOT.'/resource/document.php?id='.$object->id;
75 75
 	$head[$h][1] = $langs->trans("Documents");
76
-	if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
76
+	if ($nbFiles > 0) $head[$h][1] .= ' <span class="badge">'.$nbFiles.'</span>';
77 77
 	$head[$h][2] = 'documents';
78 78
 	$h++;
79 79
 
80 80
 	$head[$h][0] = DOL_URL_ROOT.'/resource/agenda.php?id='.$object->id;
81 81
 	$head[$h][1] = $langs->trans("Events");
82
-	if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
82
+	if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
83 83
 	{
84
-		$head[$h][1].= '/';
85
-		$head[$h][1].= $langs->trans("Agenda");
84
+		$head[$h][1] .= '/';
85
+		$head[$h][1] .= $langs->trans("Agenda");
86 86
 	}
87 87
 	$head[$h][2] = 'agenda';
88 88
 	$h++;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	$head[$h][2] = 'info';
93 93
 	$h++;*/
94 94
 
95
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'resource', 'remove');
95
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'resource', 'remove');
96 96
 
97 97
 	return $head;
98 98
 }
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 	// Entries must be declared in modules descriptor with line
120 120
 	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
121 121
 	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
122
-	complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin');
122
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'resource_admin');
123 123
 
124 124
 	$head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php';
125 125
 	$head[$h][1] = $langs->trans("ExtraFields");
126 126
 	$head[$h][2] = 'attributes';
127 127
 	$h++;
128 128
 
129
-	complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin','remove');
129
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'resource_admin', 'remove');
130 130
 
131 131
 	return $head;
132 132
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 	    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
46 46
 	    $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
47 47
 		$head[$h][1] = $langs->trans('ContactsAddresses');
48
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
48
+		if ($nbContact > 0) {
49
+		    $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
50
+		}
49 51
 		$head[$h][2] = 'contact';
50 52
 		$h++;
51 53
 	}
@@ -59,11 +61,17 @@  discard block
 block discarded – undo
59 61
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60 62
 	{
61 63
 		$nbNote = 0;
62
-		if(!empty($object->note_private)) $nbNote++;
63
-		if(!empty($object->note_public)) $nbNote++;
64
+		if(!empty($object->note_private)) {
65
+		    $nbNote++;
66
+		}
67
+		if(!empty($object->note_public)) {
68
+		    $nbNote++;
69
+		}
64 70
 		$head[$h][0] = DOL_URL_ROOT.'/resource/note.php?id='.$object->id;
65 71
 		$head[$h][1] = $langs->trans('Notes');
66
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
72
+		if ($nbNote > 0) {
73
+		    $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
74
+		}
67 75
 		$head[$h][2] = 'note';
68 76
 		$h++;
69 77
 	}
@@ -73,7 +81,9 @@  discard block
 block discarded – undo
73 81
 	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
74 82
 	$head[$h][0] = DOL_URL_ROOT.'/resource/document.php?id='.$object->id;
75 83
 	$head[$h][1] = $langs->trans("Documents");
76
-	if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
84
+	if($nbFiles > 0) {
85
+	    $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
86
+	}
77 87
 	$head[$h][2] = 'documents';
78 88
 	$h++;
79 89
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/ws.lib.php 3 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -65,32 +65,32 @@
 block discarded – undo
65 65
             $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password';
66 66
         }
67 67
 
68
-		if (! $error && $fuser->statut == 0)
69
-		{
70
-			$error++;
71
-			$errorcode='ERROR_USER_DISABLED'; $errorlabel='This user has been locked or disabled';
72
-		}
68
+        if (! $error && $fuser->statut == 0)
69
+        {
70
+            $error++;
71
+            $errorcode='ERROR_USER_DISABLED'; $errorlabel='This user has been locked or disabled';
72
+        }
73 73
 
74
-    	// Validation of login
75
-		if (! $error)
76
-		{
77
-			$fuser->getrights();	// Load permission of user
74
+        // Validation of login
75
+        if (! $error)
76
+        {
77
+            $fuser->getrights();	// Load permission of user
78 78
 
79
-        	// Authentication mode
80
-        	if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr';
81
-        	// Authentication mode: forceuser
82
-        	if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
83
-        	// Set authmode
84
-        	$authmode=explode(',',$dolibarr_main_authentication);
79
+            // Authentication mode
80
+            if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr';
81
+            // Authentication mode: forceuser
82
+            if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
83
+            // Set authmode
84
+            $authmode=explode(',',$dolibarr_main_authentication);
85 85
 
86 86
             include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
87
-        	$login = checkLoginPassEntity($authentication['login'],$authentication['password'],$authentication['entity'],$authmode);
88
-			if (empty($login))
89
-			{
90
-			    $error++;
87
+            $login = checkLoginPassEntity($authentication['login'],$authentication['password'],$authentication['entity'],$authmode);
88
+            if (empty($login))
89
+            {
90
+                $error++;
91 91
                 $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password';
92
-			}
93
-		}
92
+            }
93
+        }
94 94
     }
95 95
 
96 96
     return $fuser;
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -32,63 +32,63 @@
 block discarded – undo
32 32
  *  @param  string	$errorlabel		Error string label
33 33
  *  @return User						Return user object identified by login/pass/entity into authentication array
34 34
  */
35
-function check_authentication($authentication,&$error,&$errorcode,&$errorlabel)
35
+function check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
36 36
 {
37
-    global $db,$conf,$langs;
38
-    global $dolibarr_main_authentication,$dolibarr_auto_user;
37
+    global $db, $conf, $langs;
38
+    global $dolibarr_main_authentication, $dolibarr_auto_user;
39 39
 
40
-    $fuser=new User($db);
40
+    $fuser = new User($db);
41 41
 
42
-    if (! $error && ($authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY))
42
+    if (!$error && ($authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY))
43 43
     {
44 44
         $error++;
45
-        $errorcode='BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel='Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup';
45
+        $errorcode = 'BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel = 'Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup';
46 46
     }
47 47
 
48
-    if (! $error && ! empty($authentication['entity']) && ! is_numeric($authentication['entity']))
48
+    if (!$error && !empty($authentication['entity']) && !is_numeric($authentication['entity']))
49 49
     {
50 50
         $error++;
51
-        $errorcode='BAD_PARAMETERS'; $errorlabel="The entity parameter must be empty (or filled with numeric id of instance if multicompany module is used).";
51
+        $errorcode = 'BAD_PARAMETERS'; $errorlabel = "The entity parameter must be empty (or filled with numeric id of instance if multicompany module is used).";
52 52
     }
53 53
 
54
-    if (! $error)
54
+    if (!$error)
55 55
     {
56
-        $result=$fuser->fetch('',$authentication['login'],'',0);
56
+        $result = $fuser->fetch('', $authentication['login'], '', 0);
57 57
         if ($result < 0)
58 58
         {
59 59
             $error++;
60
-            $errorcode='ERROR_FETCH_USER'; $errorlabel='A technical error occurred during fetch of user';
60
+            $errorcode = 'ERROR_FETCH_USER'; $errorlabel = 'A technical error occurred during fetch of user';
61 61
         }
62 62
         else if ($result == 0)
63 63
         {
64 64
             $error++;
65
-            $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password';
65
+            $errorcode = 'BAD_CREDENTIALS'; $errorlabel = 'Bad value for login or password';
66 66
         }
67 67
 
68
-		if (! $error && $fuser->statut == 0)
68
+		if (!$error && $fuser->statut == 0)
69 69
 		{
70 70
 			$error++;
71
-			$errorcode='ERROR_USER_DISABLED'; $errorlabel='This user has been locked or disabled';
71
+			$errorcode = 'ERROR_USER_DISABLED'; $errorlabel = 'This user has been locked or disabled';
72 72
 		}
73 73
 
74 74
     	// Validation of login
75
-		if (! $error)
75
+		if (!$error)
76 76
 		{
77
-			$fuser->getrights();	// Load permission of user
77
+			$fuser->getrights(); // Load permission of user
78 78
 
79 79
         	// Authentication mode
80
-        	if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr';
80
+        	if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr';
81 81
         	// Authentication mode: forceuser
82
-        	if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
82
+        	if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user = 'auto';
83 83
         	// Set authmode
84
-        	$authmode=explode(',',$dolibarr_main_authentication);
84
+        	$authmode = explode(',', $dolibarr_main_authentication);
85 85
 
86 86
             include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
87
-        	$login = checkLoginPassEntity($authentication['login'],$authentication['password'],$authentication['entity'],$authmode);
87
+        	$login = checkLoginPassEntity($authentication['login'], $authentication['password'], $authentication['entity'], $authmode);
88 88
 			if (empty($login))
89 89
 			{
90 90
 			    $error++;
91
-                $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password';
91
+                $errorcode = 'BAD_CREDENTIALS'; $errorlabel = 'Bad value for login or password';
92 92
 			}
93 93
 		}
94 94
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@  discard block
 block discarded – undo
58 58
         {
59 59
             $error++;
60 60
             $errorcode='ERROR_FETCH_USER'; $errorlabel='A technical error occurred during fetch of user';
61
-        }
62
-        else if ($result == 0)
61
+        } else if ($result == 0)
63 62
         {
64 63
             $error++;
65 64
             $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password';
@@ -77,9 +76,13 @@  discard block
 block discarded – undo
77 76
 			$fuser->getrights();	// Load permission of user
78 77
 
79 78
         	// Authentication mode
80
-        	if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr';
79
+        	if (empty($dolibarr_main_authentication)) {
80
+        	    $dolibarr_main_authentication='http,dolibarr';
81
+        	}
81 82
         	// Authentication mode: forceuser
82
-        	if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
83
+        	if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) {
84
+        	    $dolibarr_auto_user='auto';
85
+        	}
83 86
         	// Set authmode
84 87
         	$authmode=explode(',',$dolibarr_main_authentication);
85 88
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/fichinter.lib.php 3 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -35,26 +35,26 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function fichinter_prepare_head($object)
37 37
 {
38
-	global $db, $langs, $conf, $user;
39
-	$langs->load("fichinter");
40
-
41
-	$h = 0;
42
-	$head = array();
43
-
44
-	$head[$h][0] = DOL_URL_ROOT.'/fichinter/card.php?id='.$object->id;
45
-	$head[$h][1] = $langs->trans("Card");
46
-	$head[$h][2] = 'card';
47
-	$h++;
48
-
49
-	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
50
-	{
51
-	    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
52
-	    $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
53
-		$head[$h][1] = $langs->trans('InterventionContact');
54
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
55
-		$head[$h][2] = 'contact';
56
-		$h++;
57
-	}
38
+    global $db, $langs, $conf, $user;
39
+    $langs->load("fichinter");
40
+
41
+    $h = 0;
42
+    $head = array();
43
+
44
+    $head[$h][0] = DOL_URL_ROOT.'/fichinter/card.php?id='.$object->id;
45
+    $head[$h][1] = $langs->trans("Card");
46
+    $head[$h][2] = 'card';
47
+    $h++;
48
+
49
+    if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
50
+    {
51
+        $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
52
+        $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
53
+        $head[$h][1] = $langs->trans('InterventionContact');
54
+        if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
55
+        $head[$h][2] = 'contact';
56
+        $h++;
57
+    }
58 58
 
59 59
     // Show more tabs from modules
60 60
     // Entries must be declared in modules descriptor with line
@@ -62,58 +62,58 @@  discard block
 block discarded – undo
62 62
     // $this->tabs = array('entity:-tabname);   												to remove a tab
63 63
     complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention');
64 64
 
65
-	// Tab to link resources
66
-	if ($conf->resource->enabled)
67
-	{
68
-		require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
69
- 		$nbResource = 0;
70
-		$objectres=new Dolresource($db);
71
-		if (is_array($objectres->available_resources))
72
-		{
73
-	 		foreach ($objectres->available_resources as $modresources => $resources)
74
-			{
75
-				$resources=(array) $resources;  // To be sure $resources is an array
76
-				foreach($resources as $resource_obj)
77
-				{
78
-					$linked_resources = $object->getElementResources('fichinter',$object->id,$resource_obj);
79
-				}
80
-			}
81
-		}
82
-
83
-   		$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id;
84
-		$head[$h][1] = $langs->trans("Resources");
85
-		if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>';
86
-		$head[$h][2] = 'resource';
87
-		$h++;
88
-	}
65
+    // Tab to link resources
66
+    if ($conf->resource->enabled)
67
+    {
68
+        require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
69
+            $nbResource = 0;
70
+        $objectres=new Dolresource($db);
71
+        if (is_array($objectres->available_resources))
72
+        {
73
+                foreach ($objectres->available_resources as $modresources => $resources)
74
+            {
75
+                $resources=(array) $resources;  // To be sure $resources is an array
76
+                foreach($resources as $resource_obj)
77
+                {
78
+                    $linked_resources = $object->getElementResources('fichinter',$object->id,$resource_obj);
79
+                }
80
+            }
81
+        }
82
+
83
+            $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id;
84
+        $head[$h][1] = $langs->trans("Resources");
85
+        if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>';
86
+        $head[$h][2] = 'resource';
87
+        $h++;
88
+    }
89 89
 
90 90
     if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
91 91
     {
92
-    	$nbNote = 0;
92
+        $nbNote = 0;
93 93
         if(!empty($object->note_private)) $nbNote++;
94
-		if(!empty($object->note_public)) $nbNote++;
95
-    	$head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
96
-    	$head[$h][1] = $langs->trans('Notes');
97
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
98
-    	$head[$h][2] = 'note';
99
-    	$h++;
94
+        if(!empty($object->note_public)) $nbNote++;
95
+        $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
96
+        $head[$h][1] = $langs->trans('Notes');
97
+        if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
98
+        $head[$h][2] = 'note';
99
+        $h++;
100 100
     }
101 101
 
102
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
102
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
103 103
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
104
-	$upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref);
105
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
104
+    $upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref);
105
+    $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
106 106
     $nbLinks=Link::count($db, $object->element, $object->id);
107
-	$head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id;
108
-	$head[$h][1] = $langs->trans("Documents");
109
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
110
-	$head[$h][2] = 'documents';
111
-	$h++;
107
+    $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id;
108
+    $head[$h][1] = $langs->trans("Documents");
109
+    if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
110
+    $head[$h][2] = 'documents';
111
+    $h++;
112 112
 
113 113
     $head[$h][0] = DOL_URL_ROOT.'/fichinter/info.php?id='.$object->id;
114
-	$head[$h][1] = $langs->trans('Info');
115
-	$head[$h][2] = 'info';
116
-	$h++;
114
+    $head[$h][1] = $langs->trans('Info');
115
+    $head[$h][2] = 'info';
116
+    $h++;
117 117
 
118 118
     complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention','remove');
119 119
 
@@ -127,39 +127,39 @@  discard block
 block discarded – undo
127 127
  */
128 128
 function fichinter_admin_prepare_head()
129 129
 {
130
-	global $langs, $conf, $user;
130
+    global $langs, $conf, $user;
131 131
 
132
-	$h = 0;
133
-	$head = array();
132
+    $h = 0;
133
+    $head = array();
134 134
 
135
-	$h = 0;
135
+    $h = 0;
136 136
 
137
-	$head[$h][0] = DOL_URL_ROOT."/admin/fichinter.php";
138
-	$head[$h][1] = $langs->trans("Interventions");
139
-	$head[$h][2] = 'ficheinter';
140
-	$h++;
137
+    $head[$h][0] = DOL_URL_ROOT."/admin/fichinter.php";
138
+    $head[$h][1] = $langs->trans("Interventions");
139
+    $head[$h][2] = 'ficheinter';
140
+    $h++;
141 141
 
142
-	// Show more tabs from modules
143
-	// Entries must be declared in modules descriptor with line
144
-	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
145
-	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
146
-	complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin');
142
+    // Show more tabs from modules
143
+    // Entries must be declared in modules descriptor with line
144
+    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
145
+    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
146
+    complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin');
147 147
 
148
-	$head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinter_extrafields.php';
149
-	$head[$h][1] = $langs->trans("ExtraFields");
148
+    $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinter_extrafields.php';
149
+    $head[$h][1] = $langs->trans("ExtraFields");
150 150
     $head[$h][2] = 'attributes';
151 151
     $h++;
152 152
 
153
-	$head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
154
-	$head[$h][1] = $langs->trans("ExtraFieldsLines");
153
+    $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
154
+    $head[$h][1] = $langs->trans("ExtraFieldsLines");
155 155
     $head[$h][2] = 'attributesdet';
156 156
     $h++;
157 157
 
158 158
 
159 159
 
160
-	complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin','remove');
160
+    complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin','remove');
161 161
 
162
-		return $head;
162
+        return $head;
163 163
 }
164 164
 
165 165
 /**
@@ -170,20 +170,20 @@  discard block
 block discarded – undo
170 170
  */
171 171
 function fichinter_rec_prepare_head($object)
172 172
 {
173
-	global $langs, $conf; //, $user;
173
+    global $langs, $conf; //, $user;
174 174
 
175
-	$h = 0;
176
-	$head = array();
175
+    $h = 0;
176
+    $head = array();
177 177
 
178
-	$head[$h][0] = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id;
179
-	$head[$h][1] = $langs->trans("CardFichinter");
180
-	$head[$h][2] = 'card';
181
-	$h++;
178
+    $head[$h][0] = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id;
179
+    $head[$h][1] = $langs->trans("CardFichinter");
180
+    $head[$h][2] = 'card';
181
+    $h++;
182 182
 
183
-	complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec');
183
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec');
184 184
 
185
-	complete_head_from_modules($conf, $langs, $object, $head, $h,'intervention-rec','remove');
185
+    complete_head_from_modules($conf, $langs, $object, $head, $h,'intervention-rec','remove');
186 186
 
187 187
 
188
-	return $head;
188
+    return $head;
189 189
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
 
49 49
 	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
50 50
 	{
51
-	    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
51
+	    $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
52 52
 	    $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
53 53
 		$head[$h][1] = $langs->trans('InterventionContact');
54
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
54
+		if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>';
55 55
 		$head[$h][2] = 'contact';
56 56
 		$h++;
57 57
 	}
@@ -60,29 +60,29 @@  discard block
 block discarded – undo
60 60
     // Entries must be declared in modules descriptor with line
61 61
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
62 62
     // $this->tabs = array('entity:-tabname);   												to remove a tab
63
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention');
63
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention');
64 64
 
65 65
 	// Tab to link resources
66 66
 	if ($conf->resource->enabled)
67 67
 	{
68 68
 		require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
69 69
  		$nbResource = 0;
70
-		$objectres=new Dolresource($db);
70
+		$objectres = new Dolresource($db);
71 71
 		if (is_array($objectres->available_resources))
72 72
 		{
73 73
 	 		foreach ($objectres->available_resources as $modresources => $resources)
74 74
 			{
75
-				$resources=(array) $resources;  // To be sure $resources is an array
76
-				foreach($resources as $resource_obj)
75
+				$resources = (array) $resources; // To be sure $resources is an array
76
+				foreach ($resources as $resource_obj)
77 77
 				{
78
-					$linked_resources = $object->getElementResources('fichinter',$object->id,$resource_obj);
78
+					$linked_resources = $object->getElementResources('fichinter', $object->id, $resource_obj);
79 79
 				}
80 80
 			}
81 81
 		}
82 82
 
83 83
    		$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id;
84 84
 		$head[$h][1] = $langs->trans("Resources");
85
-		if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>';
85
+		if ($nbResource > 0) $head[$h][1] .= ' <span class="badge">'.$nbResource.'</span>';
86 86
 		$head[$h][2] = 'resource';
87 87
 		$h++;
88 88
 	}
@@ -90,23 +90,23 @@  discard block
 block discarded – undo
90 90
     if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
91 91
     {
92 92
     	$nbNote = 0;
93
-        if(!empty($object->note_private)) $nbNote++;
94
-		if(!empty($object->note_public)) $nbNote++;
93
+        if (!empty($object->note_private)) $nbNote++;
94
+		if (!empty($object->note_public)) $nbNote++;
95 95
     	$head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
96 96
     	$head[$h][1] = $langs->trans('Notes');
97
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
97
+		if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>';
98 98
     	$head[$h][2] = 'note';
99 99
     	$h++;
100 100
     }
101 101
 
102 102
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
103 103
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
104
-	$upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref);
105
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
106
-    $nbLinks=Link::count($db, $object->element, $object->id);
104
+	$upload_dir = $conf->ficheinter->dir_output."/".dol_sanitizeFileName($object->ref);
105
+	$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
106
+    $nbLinks = Link::count($db, $object->element, $object->id);
107 107
 	$head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id;
108 108
 	$head[$h][1] = $langs->trans("Documents");
109
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
109
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>';
110 110
 	$head[$h][2] = 'documents';
111 111
 	$h++;
112 112
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	$head[$h][2] = 'info';
116 116
 	$h++;
117 117
 
118
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention','remove');
118
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention', 'remove');
119 119
 
120 120
     return $head;
121 121
 }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	// Entries must be declared in modules descriptor with line
144 144
 	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
145 145
 	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
146
-	complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin');
146
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'fichinter_admin');
147 147
 
148 148
 	$head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinter_extrafields.php';
149 149
 	$head[$h][1] = $langs->trans("ExtraFields");
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
 
159 159
 
160
-	complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin','remove');
160
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'fichinter_admin', 'remove');
161 161
 
162 162
 		return $head;
163 163
 }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 	complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec');
184 184
 
185
-	complete_head_from_modules($conf, $langs, $object, $head, $h,'intervention-rec','remove');
185
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec', 'remove');
186 186
 
187 187
 
188 188
 	return $head;
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,7 +51,9 @@  discard block
 block discarded – undo
51 51
 	    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
52 52
 	    $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
53 53
 		$head[$h][1] = $langs->trans('InterventionContact');
54
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
54
+		if ($nbContact > 0) {
55
+		    $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
56
+		}
55 57
 		$head[$h][2] = 'contact';
56 58
 		$h++;
57 59
 	}
@@ -82,7 +84,9 @@  discard block
 block discarded – undo
82 84
 
83 85
    		$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id;
84 86
 		$head[$h][1] = $langs->trans("Resources");
85
-		if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>';
87
+		if ($nbResource > 0) {
88
+		    $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>';
89
+		}
86 90
 		$head[$h][2] = 'resource';
87 91
 		$h++;
88 92
 	}
@@ -90,11 +94,17 @@  discard block
 block discarded – undo
90 94
     if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
91 95
     {
92 96
     	$nbNote = 0;
93
-        if(!empty($object->note_private)) $nbNote++;
94
-		if(!empty($object->note_public)) $nbNote++;
97
+        if(!empty($object->note_private)) {
98
+            $nbNote++;
99
+        }
100
+		if(!empty($object->note_public)) {
101
+		    $nbNote++;
102
+		}
95 103
     	$head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
96 104
     	$head[$h][1] = $langs->trans('Notes');
97
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
105
+		if ($nbNote > 0) {
106
+		    $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
107
+		}
98 108
     	$head[$h][2] = 'note';
99 109
     	$h++;
100 110
     }
@@ -106,7 +116,9 @@  discard block
 block discarded – undo
106 116
     $nbLinks=Link::count($db, $object->element, $object->id);
107 117
 	$head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id;
108 118
 	$head[$h][1] = $langs->trans("Documents");
109
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
119
+	if (($nbFiles+$nbLinks) > 0) {
120
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
121
+	}
110 122
 	$head[$h][2] = 'documents';
111 123
 	$h++;
112 124
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/emailing.lib.php 3 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -29,42 +29,42 @@
 block discarded – undo
29 29
  */
30 30
 function emailing_prepare_head(Mailing $object)
31 31
 {
32
-	global $user, $langs, $conf;
32
+    global $user, $langs, $conf;
33 33
 
34
-	$h = 0;
35
-	$head = array();
34
+    $h = 0;
35
+    $head = array();
36 36
 
37
-	$head[$h][0] = DOL_URL_ROOT."/comm/mailing/card.php?id=".$object->id;
38
-	$head[$h][1] = $langs->trans("MailCard");
39
-	$head[$h][2] = 'card';
40
-	$h++;
37
+    $head[$h][0] = DOL_URL_ROOT."/comm/mailing/card.php?id=".$object->id;
38
+    $head[$h][1] = $langs->trans("MailCard");
39
+    $head[$h][2] = 'card';
40
+    $h++;
41 41
 
42
-	if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient))
43
-	{
44
-    	$head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id;
45
-    	$head[$h][1] = $langs->trans("MailRecipients");
46
-		if ($object->nbemail > 0) $head[$h][1].= ' <span class="badge">'.$object->nbemail.'</span>';
47
-    	$head[$h][2] = 'targets';
48
-    	$h++;
49
-	}
42
+    if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient))
43
+    {
44
+        $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id;
45
+        $head[$h][1] = $langs->trans("MailRecipients");
46
+        if ($object->nbemail > 0) $head[$h][1].= ' <span class="badge">'.$object->nbemail.'</span>';
47
+        $head[$h][2] = 'targets';
48
+        $h++;
49
+    }
50 50
 
51
-	if (! empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR))
52
-	{
53
-		$head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id;
54
-		$head[$h][1] = $langs->trans("MailAdvTargetRecipients");
55
-		$head[$h][2] = 'advtargets';
56
-		$h++;
57
-	}
51
+    if (! empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR))
52
+    {
53
+        $head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id;
54
+        $head[$h][1] = $langs->trans("MailAdvTargetRecipients");
55
+        $head[$h][2] = 'advtargets';
56
+        $h++;
57
+    }
58 58
 
59
-	$head[$h][0] = DOL_URL_ROOT."/comm/mailing/info.php?id=".$object->id;
60
-	$head[$h][1] = $langs->trans("Info");
61
-	$head[$h][2] = 'info';
62
-	$h++;
59
+    $head[$h][0] = DOL_URL_ROOT."/comm/mailing/info.php?id=".$object->id;
60
+    $head[$h][1] = $langs->trans("Info");
61
+    $head[$h][2] = 'info';
62
+    $h++;
63 63
 
64
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing');
64
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing');
65 65
 
66
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing','remove');
66
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing','remove');
67 67
 
68
-	return $head;
68
+    return $head;
69 69
 }
70 70
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,16 +39,16 @@  discard block
 block discarded – undo
39 39
 	$head[$h][2] = 'card';
40 40
 	$h++;
41 41
 
42
-	if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient))
42
+	if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient))
43 43
 	{
44 44
     	$head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id;
45 45
     	$head[$h][1] = $langs->trans("MailRecipients");
46
-		if ($object->nbemail > 0) $head[$h][1].= ' <span class="badge">'.$object->nbemail.'</span>';
46
+		if ($object->nbemail > 0) $head[$h][1] .= ' <span class="badge">'.$object->nbemail.'</span>';
47 47
     	$head[$h][2] = 'targets';
48 48
     	$h++;
49 49
 	}
50 50
 
51
-	if (! empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR))
51
+	if (!empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR))
52 52
 	{
53 53
 		$head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id;
54 54
 		$head[$h][1] = $langs->trans("MailAdvTargetRecipients");
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 	$head[$h][2] = 'info';
62 62
 	$h++;
63 63
 
64
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing');
64
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'emailing');
65 65
 
66
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing','remove');
66
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'emailing', 'remove');
67 67
 
68 68
 	return $head;
69 69
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@
 block discarded – undo
43 43
 	{
44 44
     	$head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id;
45 45
     	$head[$h][1] = $langs->trans("MailRecipients");
46
-		if ($object->nbemail > 0) $head[$h][1].= ' <span class="badge">'.$object->nbemail.'</span>';
46
+		if ($object->nbemail > 0) {
47
+		    $head[$h][1].= ' <span class="badge">'.$object->nbemail.'</span>';
48
+		}
47 49
     	$head[$h][2] = 'targets';
48 50
     	$h++;
49 51
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/order.lib.php 3 patches
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -33,48 +33,48 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function commande_prepare_head(Commande $object)
35 35
 {
36
-	global $db, $langs, $conf, $user;
37
-	if (! empty($conf->expedition->enabled)) $langs->load("sendings");
38
-	$langs->load("orders");
39
-
40
-	$h = 0;
41
-	$head = array();
42
-
43
-	if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
44
-	{
45
-		$head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id;
46
-		$head[$h][1] = $langs->trans("OrderCard");
47
-		$head[$h][2] = 'order';
48
-		$h++;
49
-	}
50
-
51
-	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
52
-	{
53
-	    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
54
-	    $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
55
-		$head[$h][1] = $langs->trans('ContactsAddresses');
56
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
57
-		$head[$h][2] = 'contact';
58
-		$h++;
59
-	}
60
-
61
-	if (($conf->expedition_bon->enabled && $user->rights->expedition->lire)
62
-	|| ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire))
63
-	{
64
-		$nbShipments=$object->getNbOfShipments(); $nbReceiption=0;
65
-		$head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id;
66
-		$text='';
67
-		if ($conf->expedition_bon->enabled) $text.=$langs->trans("Shipments");
68
-		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
69
-		if ($conf->livraison_bon->enabled)  $text.=$langs->trans("Receivings");
70
-		if ($nbShipments > 0 || $nbReceiption > 0) $text.= ' <span class="badge">'.($nbShipments?$nbShipments:0);
71
-		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
72
-		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.= ($nbReceiption?$nbReceiption:0);
73
-		if ($nbShipments > 0 || $nbReceiption > 0) $text.= '</span>';
74
-		$head[$h][1] = $text;
75
-		$head[$h][2] = 'shipping';
76
-		$h++;
77
-	}
36
+    global $db, $langs, $conf, $user;
37
+    if (! empty($conf->expedition->enabled)) $langs->load("sendings");
38
+    $langs->load("orders");
39
+
40
+    $h = 0;
41
+    $head = array();
42
+
43
+    if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
44
+    {
45
+        $head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id;
46
+        $head[$h][1] = $langs->trans("OrderCard");
47
+        $head[$h][2] = 'order';
48
+        $h++;
49
+    }
50
+
51
+    if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
52
+    {
53
+        $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
54
+        $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
55
+        $head[$h][1] = $langs->trans('ContactsAddresses');
56
+        if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
57
+        $head[$h][2] = 'contact';
58
+        $h++;
59
+    }
60
+
61
+    if (($conf->expedition_bon->enabled && $user->rights->expedition->lire)
62
+    || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire))
63
+    {
64
+        $nbShipments=$object->getNbOfShipments(); $nbReceiption=0;
65
+        $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id;
66
+        $text='';
67
+        if ($conf->expedition_bon->enabled) $text.=$langs->trans("Shipments");
68
+        if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
69
+        if ($conf->livraison_bon->enabled)  $text.=$langs->trans("Receivings");
70
+        if ($nbShipments > 0 || $nbReceiption > 0) $text.= ' <span class="badge">'.($nbShipments?$nbShipments:0);
71
+        if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
72
+        if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.= ($nbReceiption?$nbReceiption:0);
73
+        if ($nbShipments > 0 || $nbReceiption > 0) $text.= '</span>';
74
+        $head[$h][1] = $text;
75
+        $head[$h][2] = 'shipping';
76
+        $h++;
77
+    }
78 78
 
79 79
     // Show more tabs from modules
80 80
     // Entries must be declared in modules descriptor with line
@@ -82,33 +82,33 @@  discard block
 block discarded – undo
82 82
     // $this->tabs = array('entity:-tabname);   												to remove a tab
83 83
     complete_head_from_modules($conf,$langs,$object,$head,$h,'order');
84 84
 
85
-	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
86
-	{
87
-		$nbNote = 0;
85
+    if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
86
+    {
87
+        $nbNote = 0;
88 88
         if(!empty($object->note_private)) $nbNote++;
89
-		if(!empty($object->note_public)) $nbNote++;
90
-		$head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
91
-		$head[$h][1] = $langs->trans('Notes');
92
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
93
-		$head[$h][2] = 'note';
94
-		$h++;
95
-	}
96
-
97
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
89
+        if(!empty($object->note_public)) $nbNote++;
90
+        $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
91
+        $head[$h][1] = $langs->trans('Notes');
92
+        if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
93
+        $head[$h][2] = 'note';
94
+        $h++;
95
+    }
96
+
97
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
98 98
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
99
-	$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
100
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
99
+    $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
100
+    $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
101 101
     $nbLinks=Link::count($db, $object->element, $object->id);
102
-	$head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id;
103
-	$head[$h][1] = $langs->trans('Documents');
104
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
105
-	$head[$h][2] = 'documents';
106
-	$h++;
102
+    $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id;
103
+    $head[$h][1] = $langs->trans('Documents');
104
+    if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
105
+    $head[$h][2] = 'documents';
106
+    $h++;
107 107
 
108
-	$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$object->id;
109
-	$head[$h][1] = $langs->trans("Info");
110
-	$head[$h][2] = 'info';
111
-	$h++;
108
+    $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$object->id;
109
+    $head[$h][1] = $langs->trans("Info");
110
+    $head[$h][2] = 'info';
111
+    $h++;
112 112
 
113 113
     complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove');
114 114
 
@@ -122,31 +122,31 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function order_admin_prepare_head()
124 124
 {
125
-	global $langs, $conf, $user;
125
+    global $langs, $conf, $user;
126 126
 
127
-	$h = 0;
128
-	$head = array();
127
+    $h = 0;
128
+    $head = array();
129 129
 
130
-	$head[$h][0] = DOL_URL_ROOT.'/admin/commande.php';
131
-	$head[$h][1] = $langs->trans("Miscellaneous");
132
-	$head[$h][2] = 'general';
133
-	$h++;
130
+    $head[$h][0] = DOL_URL_ROOT.'/admin/commande.php';
131
+    $head[$h][1] = $langs->trans("Miscellaneous");
132
+    $head[$h][2] = 'general';
133
+    $h++;
134 134
 
135
-	complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin');
135
+    complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin');
136 136
 
137
-	$head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php';
138
-	$head[$h][1] = $langs->trans("ExtraFields");
139
-	$head[$h][2] = 'attributes';
140
-	$h++;
137
+    $head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php';
138
+    $head[$h][1] = $langs->trans("ExtraFields");
139
+    $head[$h][2] = 'attributes';
140
+    $h++;
141 141
 
142
-	$head[$h][0] = DOL_URL_ROOT.'/admin/orderdet_extrafields.php';
143
-	$head[$h][1] = $langs->trans("ExtraFieldsLines");
144
-	$head[$h][2] = 'attributeslines';
145
-	$h++;
142
+    $head[$h][0] = DOL_URL_ROOT.'/admin/orderdet_extrafields.php';
143
+    $head[$h][1] = $langs->trans("ExtraFieldsLines");
144
+    $head[$h][2] = 'attributeslines';
145
+    $h++;
146 146
 
147
-	complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin','remove');
147
+    complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin','remove');
148 148
 
149
-	return $head;
149
+    return $head;
150 150
 }
151 151
 
152 152
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
 function commande_prepare_head(Commande $object)
35 35
 {
36 36
 	global $db, $langs, $conf, $user;
37
-	if (! empty($conf->expedition->enabled)) $langs->load("sendings");
37
+	if (!empty($conf->expedition->enabled)) $langs->load("sendings");
38 38
 	$langs->load("orders");
39 39
 
40 40
 	$h = 0;
41 41
 	$head = array();
42 42
 
43
-	if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
43
+	if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
44 44
 	{
45 45
 		$head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id;
46 46
 		$head[$h][1] = $langs->trans("OrderCard");
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 
51 51
 	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
52 52
 	{
53
-	    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
53
+	    $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
54 54
 	    $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
55 55
 		$head[$h][1] = $langs->trans('ContactsAddresses');
56
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
56
+		if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>';
57 57
 		$head[$h][2] = 'contact';
58 58
 		$h++;
59 59
 	}
@@ -61,16 +61,16 @@  discard block
 block discarded – undo
61 61
 	if (($conf->expedition_bon->enabled && $user->rights->expedition->lire)
62 62
 	|| ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire))
63 63
 	{
64
-		$nbShipments=$object->getNbOfShipments(); $nbReceiption=0;
64
+		$nbShipments = $object->getNbOfShipments(); $nbReceiption = 0;
65 65
 		$head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id;
66
-		$text='';
67
-		if ($conf->expedition_bon->enabled) $text.=$langs->trans("Shipments");
68
-		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
69
-		if ($conf->livraison_bon->enabled)  $text.=$langs->trans("Receivings");
70
-		if ($nbShipments > 0 || $nbReceiption > 0) $text.= ' <span class="badge">'.($nbShipments?$nbShipments:0);
71
-		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
72
-		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.= ($nbReceiption?$nbReceiption:0);
73
-		if ($nbShipments > 0 || $nbReceiption > 0) $text.= '</span>';
66
+		$text = '';
67
+		if ($conf->expedition_bon->enabled) $text .= $langs->trans("Shipments");
68
+		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text .= '/';
69
+		if ($conf->livraison_bon->enabled)  $text .= $langs->trans("Receivings");
70
+		if ($nbShipments > 0 || $nbReceiption > 0) $text .= ' <span class="badge">'.($nbShipments ? $nbShipments : 0);
71
+		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text .= '/';
72
+		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text .= ($nbReceiption ? $nbReceiption : 0);
73
+		if ($nbShipments > 0 || $nbReceiption > 0) $text .= '</span>';
74 74
 		$head[$h][1] = $text;
75 75
 		$head[$h][2] = 'shipping';
76 76
 		$h++;
@@ -80,28 +80,28 @@  discard block
 block discarded – undo
80 80
     // Entries must be declared in modules descriptor with line
81 81
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
82 82
     // $this->tabs = array('entity:-tabname);   												to remove a tab
83
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'order');
83
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'order');
84 84
 
85 85
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
86 86
 	{
87 87
 		$nbNote = 0;
88
-        if(!empty($object->note_private)) $nbNote++;
89
-		if(!empty($object->note_public)) $nbNote++;
88
+        if (!empty($object->note_private)) $nbNote++;
89
+		if (!empty($object->note_public)) $nbNote++;
90 90
 		$head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
91 91
 		$head[$h][1] = $langs->trans('Notes');
92
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
92
+		if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>';
93 93
 		$head[$h][2] = 'note';
94 94
 		$h++;
95 95
 	}
96 96
 
97 97
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
98 98
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
99
-	$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
100
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
101
-    $nbLinks=Link::count($db, $object->element, $object->id);
99
+	$upload_dir = $conf->commande->dir_output."/".dol_sanitizeFileName($object->ref);
100
+	$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
101
+    $nbLinks = Link::count($db, $object->element, $object->id);
102 102
 	$head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id;
103 103
 	$head[$h][1] = $langs->trans('Documents');
104
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
104
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>';
105 105
 	$head[$h][2] = 'documents';
106 106
 	$h++;
107 107
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	$head[$h][2] = 'info';
111 111
 	$h++;
112 112
 
113
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove');
113
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove');
114 114
 
115 115
     return $head;
116 116
 }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	$head[$h][2] = 'general';
133 133
 	$h++;
134 134
 
135
-	complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin');
135
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'order_admin');
136 136
 
137 137
 	$head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php';
138 138
 	$head[$h][1] = $langs->trans("ExtraFields");
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	$head[$h][2] = 'attributeslines';
145 145
 	$h++;
146 146
 
147
-	complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin','remove');
147
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'order_admin', 'remove');
148 148
 
149 149
 	return $head;
150 150
 }
Please login to merge, or discard this patch.
Braces   +39 added lines, -13 removed lines patch added patch discarded remove patch
@@ -34,7 +34,9 @@  discard block
 block discarded – undo
34 34
 function commande_prepare_head(Commande $object)
35 35
 {
36 36
 	global $db, $langs, $conf, $user;
37
-	if (! empty($conf->expedition->enabled)) $langs->load("sendings");
37
+	if (! empty($conf->expedition->enabled)) {
38
+	    $langs->load("sendings");
39
+	}
38 40
 	$langs->load("orders");
39 41
 
40 42
 	$h = 0;
@@ -53,7 +55,9 @@  discard block
 block discarded – undo
53 55
 	    $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
54 56
 	    $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
55 57
 		$head[$h][1] = $langs->trans('ContactsAddresses');
56
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
58
+		if ($nbContact > 0) {
59
+		    $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
60
+		}
57 61
 		$head[$h][2] = 'contact';
58 62
 		$h++;
59 63
 	}
@@ -64,13 +68,27 @@  discard block
 block discarded – undo
64 68
 		$nbShipments=$object->getNbOfShipments(); $nbReceiption=0;
65 69
 		$head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id;
66 70
 		$text='';
67
-		if ($conf->expedition_bon->enabled) $text.=$langs->trans("Shipments");
68
-		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
69
-		if ($conf->livraison_bon->enabled)  $text.=$langs->trans("Receivings");
70
-		if ($nbShipments > 0 || $nbReceiption > 0) $text.= ' <span class="badge">'.($nbShipments?$nbShipments:0);
71
-		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
72
-		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.= ($nbReceiption?$nbReceiption:0);
73
-		if ($nbShipments > 0 || $nbReceiption > 0) $text.= '</span>';
71
+		if ($conf->expedition_bon->enabled) {
72
+		    $text.=$langs->trans("Shipments");
73
+		}
74
+		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) {
75
+		    $text.='/';
76
+		}
77
+		if ($conf->livraison_bon->enabled) {
78
+		    $text.=$langs->trans("Receivings");
79
+		}
80
+		if ($nbShipments > 0 || $nbReceiption > 0) {
81
+		    $text.= ' <span class="badge">'.($nbShipments?$nbShipments:0);
82
+		}
83
+		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) {
84
+		    $text.='/';
85
+		}
86
+		if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) {
87
+		    $text.= ($nbReceiption?$nbReceiption:0);
88
+		}
89
+		if ($nbShipments > 0 || $nbReceiption > 0) {
90
+		    $text.= '</span>';
91
+		}
74 92
 		$head[$h][1] = $text;
75 93
 		$head[$h][2] = 'shipping';
76 94
 		$h++;
@@ -85,11 +103,17 @@  discard block
 block discarded – undo
85 103
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
86 104
 	{
87 105
 		$nbNote = 0;
88
-        if(!empty($object->note_private)) $nbNote++;
89
-		if(!empty($object->note_public)) $nbNote++;
106
+        if(!empty($object->note_private)) {
107
+            $nbNote++;
108
+        }
109
+		if(!empty($object->note_public)) {
110
+		    $nbNote++;
111
+		}
90 112
 		$head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
91 113
 		$head[$h][1] = $langs->trans('Notes');
92
-		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
114
+		if ($nbNote > 0) {
115
+		    $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
116
+		}
93 117
 		$head[$h][2] = 'note';
94 118
 		$h++;
95 119
 	}
@@ -101,7 +125,9 @@  discard block
 block discarded – undo
101 125
     $nbLinks=Link::count($db, $object->element, $object->id);
102 126
 	$head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id;
103 127
 	$head[$h][1] = $langs->trans('Documents');
104
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
128
+	if (($nbFiles+$nbLinks) > 0) {
129
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
130
+	}
105 131
 	$head[$h][2] = 'documents';
106 132
 	$h++;
107 133
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/website.lib.php 3 patches
Indentation   +601 added lines, -601 removed lines patch added patch discarded remove patch
@@ -35,63 +35,63 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0)
37 37
 {
38
-	$nbrep = 0;
39
-
40
-	// Replace php code. Note $content may come from database and does not contains body tags.
41
-	$replacewith='...php...';
42
-	if ($removephppart) $replacewith='';
43
-	$content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content);
44
-
45
-	$replacewith='"callto=#';
46
-	if ($removephppart) $replacewith='';
47
-	$content = preg_replace('/"callto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
48
-
49
-	$replacewith='"mailto=#';
50
-	if ($removephppart) $replacewith='';
51
-	$content = preg_replace('/"mailto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
52
-
53
-	$replacewith='src="php';
54
-	if ($removephppart) $replacewith='';
55
-	$content = preg_replace('/src="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
56
-
57
-	$replacewith='href="php';
58
-	if ($removephppart) $replacewith='';
59
-	$content = preg_replace('/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
60
-
61
-	//$replacewith='<span class="phptag">...php...</span>';
62
-	$replacewith='<span class="phptag">...php...</span>';
63
-	if ($removephppart) $replacewith='';
64
-	//$content = preg_replace('/<\?php((?!\?toremove>).)*\?toremove>\n*/ims', $replacewith, $content);
65
-	/*if ($content === null) {
38
+    $nbrep = 0;
39
+
40
+    // Replace php code. Note $content may come from database and does not contains body tags.
41
+    $replacewith='...php...';
42
+    if ($removephppart) $replacewith='';
43
+    $content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content);
44
+
45
+    $replacewith='"callto=#';
46
+    if ($removephppart) $replacewith='';
47
+    $content = preg_replace('/"callto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
48
+
49
+    $replacewith='"mailto=#';
50
+    if ($removephppart) $replacewith='';
51
+    $content = preg_replace('/"mailto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
52
+
53
+    $replacewith='src="php';
54
+    if ($removephppart) $replacewith='';
55
+    $content = preg_replace('/src="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
56
+
57
+    $replacewith='href="php';
58
+    if ($removephppart) $replacewith='';
59
+    $content = preg_replace('/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
60
+
61
+    //$replacewith='<span class="phptag">...php...</span>';
62
+    $replacewith='<span class="phptag">...php...</span>';
63
+    if ($removephppart) $replacewith='';
64
+    //$content = preg_replace('/<\?php((?!\?toremove>).)*\?toremove>\n*/ims', $replacewith, $content);
65
+    /*if ($content === null) {
66 66
 		if (preg_last_error() == PREG_JIT_STACKLIMIT_ERROR) $content = 'preg_replace error (when removing php tags) PREG_JIT_STACKLIMIT_ERROR';
67 67
 	}*/
68
-	$content = dolStripPhpCode($content, $replacewith);
69
-	//var_dump($content);
68
+    $content = dolStripPhpCode($content, $replacewith);
69
+    //var_dump($content);
70 70
 
71
-	// Replace relative link / with dolibarr URL
72
-	$content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
73
-	// Replace relative link /xxx.php with dolibarr URL
74
-	$content = preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
71
+    // Replace relative link / with dolibarr URL
72
+    $content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
73
+    // Replace relative link /xxx.php with dolibarr URL
74
+    $content = preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
75 75
 
76
-	// Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
77
-	$content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
78
-	$content = preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
76
+    // Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
77
+    $content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
78
+    $content = preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
79 79
 
80
-	// <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
81
-	$content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
82
-	// <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
83
-	$content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
84
-	// <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png"
85
-	$content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep);
80
+    // <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
81
+    $content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
82
+    // <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
83
+    $content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
84
+    // <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png"
85
+    $content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep);
86 86
 
87
-	// action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage
88
-	$content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
87
+    // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage
88
+    $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
89 89
 
90
-	// Fix relative link /document.php with correct URL after the DOL_URL_ROOT:  ...href="/document.php?modulepart="
91
-	$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
92
-	$content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
90
+    // Fix relative link /document.php with correct URL after the DOL_URL_ROOT:  ...href="/document.php?modulepart="
91
+    $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
92
+    $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
93 93
 
94
-	return $content;
94
+    return $content;
95 95
 }
96 96
 
97 97
 
@@ -104,33 +104,33 @@  discard block
 block discarded – undo
104 104
  */
105 105
 function dolStripPhpCode($str, $replacewith='')
106 106
 {
107
-	$newstr = '';
108
-
109
-	//split on each opening tag
110
-	$parts = explode('<?php',$str);
111
-	if (!empty($parts))
112
-	{
113
-		$i=0;
114
-		foreach($parts as $part)
115
-		{
116
-			if ($i == 0) 	// The first part is never php code
117
-			{
118
-				$i++;
119
-				$newstr .= $part;
120
-				continue;
121
-			}
122
-			//split on closing tag
123
-			$partlings = explode('?>', $part);
124
-			if (!empty($partlings))
125
-			{
126
-				//remove content before closing tag
127
-				if (count($partlings) > 1) $partlings[0] = '';
128
-				//append to out string
129
-				$newstr .= $replacewith.implode('',$partlings);
130
-			}
131
-		}
132
-	}
133
-	return $newstr;
107
+    $newstr = '';
108
+
109
+    //split on each opening tag
110
+    $parts = explode('<?php',$str);
111
+    if (!empty($parts))
112
+    {
113
+        $i=0;
114
+        foreach($parts as $part)
115
+        {
116
+            if ($i == 0) 	// The first part is never php code
117
+            {
118
+                $i++;
119
+                $newstr .= $part;
120
+                continue;
121
+            }
122
+            //split on closing tag
123
+            $partlings = explode('?>', $part);
124
+            if (!empty($partlings))
125
+            {
126
+                //remove content before closing tag
127
+                if (count($partlings) > 1) $partlings[0] = '';
128
+                //append to out string
129
+                $newstr .= $replacewith.implode('',$partlings);
130
+            }
131
+        }
132
+    }
133
+    return $newstr;
134 134
 }
135 135
 
136 136
 
@@ -144,101 +144,101 @@  discard block
 block discarded – undo
144 144
  */
145 145
 function dolWebsiteOutput($content)
146 146
 {
147
-	global $db, $langs, $conf, $user;
148
-	global $dolibarr_main_url_root, $dolibarr_main_data_root;
147
+    global $db, $langs, $conf, $user;
148
+    global $dolibarr_main_url_root, $dolibarr_main_data_root;
149
+
150
+    dol_syslog("dolWebsiteOutput start (USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." (USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')');
151
+
152
+    // Define $urlwithroot
153
+    $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
154
+    $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
155
+    //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
156
+
157
+    if (defined('USEDOLIBARREDITOR'))		// REPLACEMENT OF LINKS When page called from Dolibarr editor
158
+    {
159
+        // We remove the <head> part of content
160
+        $content = preg_replace('/<head>.*<\/head>/ims', '', $content);
161
+        $content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $content);
162
+        $content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $content);
163
+    }
164
+    elseif (defined('USEDOLIBARRSERVER'))	// REPLACEMENT OF LINKS When page called from Dolibarr server
165
+    {
166
+        global $website;
167
+
168
+        // Replace relative link / with dolibarr URL:  ...href="/"...
169
+        $content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'"', $content, -1, $nbrep);
170
+        // Replace relative link /xxx.php with dolibarr URL:  ...href="....php"
171
+        $content=preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
172
+        // Replace relative link /xxx with dolibarr URL:  ...href="....php"
173
+        $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep);
174
+        $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\?)/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep);
175
+
176
+        // Fix relative link /document.php with correct URL after the DOL_URL_ROOT:  href="/document.php?modulepart=" => href="/dolibarr/document.php?modulepart="
177
+        $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
178
+        $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
179
+
180
+        // Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: href="/viewimage.php?modulepart=" => href="/dolibarr/viewimage.php?modulepart="
181
+        $content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
182
+        $content=preg_replace('/(src=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
183
+
184
+        // Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
185
+        $content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
186
+        $content=preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
187
+
188
+        // <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
189
+        $content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
190
+        // <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
191
+        $content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
192
+        // <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png"
193
+        $content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep);
194
+
195
+        // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage
196
+        $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
197
+    }
198
+    else									// REPLACEMENT OF LINKS When page called from virtual host
199
+    {
200
+        $symlinktomediaexists=1;
201
+
202
+        // Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server
203
+        // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
204
+        // become
205
+        // <img alt="" src="'.$urlwithroot.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
206
+        $nbrep=0;
207
+        if (! $symlinktomediaexists)
208
+        {
209
+            $content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
210
+
211
+            $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
212
+            $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
213
+            $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',  '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
214
+
215
+            $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
216
+            $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
217
+            $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/',  '\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep);
218
+
219
+            $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
220
+        }
221
+        else
222
+        {
223
+            $content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
224
+
225
+            $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
226
+            $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
227
+            $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
228
+
229
+            $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
230
+            $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
231
+            $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
232
+
233
+            $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
234
+        }
235
+    }
149 236
 
150
-	dol_syslog("dolWebsiteOutput start (USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." (USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')');
237
+    $content=preg_replace('/ contenteditable="true"/', ' contenteditable="false"', $content, -1, $nbrep);
151 238
 
152
-	// Define $urlwithroot
153
-	$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
154
-	$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
155
-	//$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
239
+    dol_syslog("dolWebsiteOutput end");
156 240
 
157
-	if (defined('USEDOLIBARREDITOR'))		// REPLACEMENT OF LINKS When page called from Dolibarr editor
158
-	{
159
-		// We remove the <head> part of content
160
-		$content = preg_replace('/<head>.*<\/head>/ims', '', $content);
161
-		$content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $content);
162
-		$content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $content);
163
-	}
164
-	elseif (defined('USEDOLIBARRSERVER'))	// REPLACEMENT OF LINKS When page called from Dolibarr server
165
-	{
166
-		global $website;
167
-
168
-		// Replace relative link / with dolibarr URL:  ...href="/"...
169
-		$content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'"', $content, -1, $nbrep);
170
-		// Replace relative link /xxx.php with dolibarr URL:  ...href="....php"
171
-		$content=preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
172
-		// Replace relative link /xxx with dolibarr URL:  ...href="....php"
173
-		$content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep);
174
-		$content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\?)/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep);
175
-
176
-		// Fix relative link /document.php with correct URL after the DOL_URL_ROOT:  href="/document.php?modulepart=" => href="/dolibarr/document.php?modulepart="
177
-		$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
178
-		$content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
179
-
180
-		// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: href="/viewimage.php?modulepart=" => href="/dolibarr/viewimage.php?modulepart="
181
-		$content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
182
-		$content=preg_replace('/(src=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
183
-
184
-		// Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
185
-		$content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
186
-		$content=preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
187
-
188
-		// <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
189
-		$content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
190
-		// <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
191
-		$content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
192
-		// <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png"
193
-		$content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep);
194
-
195
-		// action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage
196
-		$content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
197
-	}
198
-	else									// REPLACEMENT OF LINKS When page called from virtual host
199
-	{
200
-		$symlinktomediaexists=1;
201
-
202
-		// Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server
203
-		// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
204
-		// become
205
-		// <img alt="" src="'.$urlwithroot.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
206
-		$nbrep=0;
207
-		if (! $symlinktomediaexists)
208
-		{
209
-			$content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
210
-
211
-			$content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
212
-			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
213
-			$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',  '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
214
-
215
-			$content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
216
-			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
217
-			$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/',  '\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep);
218
-
219
-			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
220
-		}
221
-		else
222
-		{
223
-			$content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
224
-
225
-			$content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
226
-			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
227
-			$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
228
-
229
-			$content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
230
-			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
231
-			$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
232
-
233
-			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
234
-		}
235
-	}
236
-
237
-	$content=preg_replace('/ contenteditable="true"/', ' contenteditable="false"', $content, -1, $nbrep);
238
-
239
-	dol_syslog("dolWebsiteOutput end");
240
-
241
-	print $content;
241
+    print $content;
242 242
 }
243 243
 
244 244
 
@@ -279,74 +279,74 @@  discard block
 block discarded – undo
279 279
  */
280 280
 function redirectToContainer($containerref, $containeraliasalt='',$containerid=0)
281 281
 {
282
-	global $db, $website;
283
-
284
-	$newurl = '';
285
-	$result=0;
286
-
287
-	// We make redirect using the alternative alias, we must find the real $containerref
288
-	if ($containeraliasalt)
289
-	{
290
-		include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
291
-		$tmpwebsitepage=new WebsitePage($db);
292
-		$result = $tmpwebsitepage->fetch(0, $website->id, '', $containeraliasalt);
293
-		if ($result > 0)
294
-		{
295
-			$containerref = $tmpwebsitepage->pageurl;
296
-		}
297
-		else
298
-		{
299
-			print "Error, page contains a redirect to the alternative alias '".$containeraliasalt."' that does not exists in web site (".$website->id." / ".$website->ref.")";
300
-			exit;
301
-		}
302
-	}
303
-
304
-	if (defined('USEDOLIBARRSERVER'))	// When page called from Dolibarr server
305
-	{
306
-		// Check new container exists
307
-		if (! $containeraliasalt)	// If containeraliasalt set, we already did the test
308
-		{
309
-			include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
310
-			$tmpwebsitepage=new WebsitePage($db);
311
-			$result = $tmpwebsitepage->fetch(0, $website->id, $containerref);
312
-			unset($tmpwebsitepage);
313
-		}
314
-		if ($result > 0)
315
-		{
316
-			$currenturi = $_SERVER["REQUEST_URI"];
317
-			if (preg_match('/&pageref=([^&]+)/', $currenturi, $regtmp))
318
-			{
319
-				if ($regtmp[0] == $containerref)
320
-				{
321
-					print "Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containerref."' in web site '".$website->ref."'";
322
-					exit;
323
-				}
324
-				else
325
-				{
326
-					$newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containerref, $currenturi);
327
-				}
328
-			}
329
-			else
330
-			{
331
-				$newurl = $currenturi.'&pageref='.urlencode($containerref);
332
-			}
333
-		}
334
-	}
335
-	else								// When page called from virtual host server
336
-	{
337
-		$newurl = '/'.$containerref.'.php';
338
-	}
339
-
340
-	if ($newurl)
341
-	{
342
-		header("Location: ".$newurl);
343
-		exit;
344
-	}
345
-	else
346
-	{
347
-		print "Error, page contains a redirect to the alias page '".$containerref."' that does not exists in web site (".$website->id." / ".$website->ref.")";
348
-		exit;
349
-	}
282
+    global $db, $website;
283
+
284
+    $newurl = '';
285
+    $result=0;
286
+
287
+    // We make redirect using the alternative alias, we must find the real $containerref
288
+    if ($containeraliasalt)
289
+    {
290
+        include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
291
+        $tmpwebsitepage=new WebsitePage($db);
292
+        $result = $tmpwebsitepage->fetch(0, $website->id, '', $containeraliasalt);
293
+        if ($result > 0)
294
+        {
295
+            $containerref = $tmpwebsitepage->pageurl;
296
+        }
297
+        else
298
+        {
299
+            print "Error, page contains a redirect to the alternative alias '".$containeraliasalt."' that does not exists in web site (".$website->id." / ".$website->ref.")";
300
+            exit;
301
+        }
302
+    }
303
+
304
+    if (defined('USEDOLIBARRSERVER'))	// When page called from Dolibarr server
305
+    {
306
+        // Check new container exists
307
+        if (! $containeraliasalt)	// If containeraliasalt set, we already did the test
308
+        {
309
+            include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
310
+            $tmpwebsitepage=new WebsitePage($db);
311
+            $result = $tmpwebsitepage->fetch(0, $website->id, $containerref);
312
+            unset($tmpwebsitepage);
313
+        }
314
+        if ($result > 0)
315
+        {
316
+            $currenturi = $_SERVER["REQUEST_URI"];
317
+            if (preg_match('/&pageref=([^&]+)/', $currenturi, $regtmp))
318
+            {
319
+                if ($regtmp[0] == $containerref)
320
+                {
321
+                    print "Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containerref."' in web site '".$website->ref."'";
322
+                    exit;
323
+                }
324
+                else
325
+                {
326
+                    $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containerref, $currenturi);
327
+                }
328
+            }
329
+            else
330
+            {
331
+                $newurl = $currenturi.'&pageref='.urlencode($containerref);
332
+            }
333
+        }
334
+    }
335
+    else								// When page called from virtual host server
336
+    {
337
+        $newurl = '/'.$containerref.'.php';
338
+    }
339
+
340
+    if ($newurl)
341
+    {
342
+        header("Location: ".$newurl);
343
+        exit;
344
+    }
345
+    else
346
+    {
347
+        print "Error, page contains a redirect to the alias page '".$containerref."' that does not exists in web site (".$website->id." / ".$website->ref.")";
348
+        exit;
349
+    }
350 350
 }
351 351
 
352 352
 
@@ -359,41 +359,41 @@  discard block
 block discarded – undo
359 359
  */
360 360
 function includeContainer($containerref)
361 361
 {
362
-	global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;	// Very important. Required to have var available when running inluded containers.
363
-	global $includehtmlcontentopened;
364
-	global $websitekey, $websitepagefile;
362
+    global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;	// Very important. Required to have var available when running inluded containers.
363
+    global $includehtmlcontentopened;
364
+    global $websitekey, $websitepagefile;
365 365
 
366
-	$MAXLEVEL=20;
366
+    $MAXLEVEL=20;
367 367
 
368
-	if (! preg_match('/\.php$/i', $containerref)) $containerref.='.php';
368
+    if (! preg_match('/\.php$/i', $containerref)) $containerref.='.php';
369 369
 
370
-	$fullpathfile=DOL_DATA_ROOT.'/website/'.$websitekey.'/'.$containerref;
370
+    $fullpathfile=DOL_DATA_ROOT.'/website/'.$websitekey.'/'.$containerref;
371 371
 
372
-	if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0;
373
-	$includehtmlcontentopened++;
374
-	if ($includehtmlcontentopened > $MAXLEVEL)
375
-	{
376
-		print 'ERROR: RECURSIVE CONTENT LEVEL. Depth of recursive call is more than the limit of '.$MAXLEVEL.".\n";
377
-		return;
378
-	}
379
-	// file_get_contents is not possible. We must execute code with include
380
-	//$content = file_get_contents($fullpathfile);
381
-	//print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/
372
+    if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0;
373
+    $includehtmlcontentopened++;
374
+    if ($includehtmlcontentopened > $MAXLEVEL)
375
+    {
376
+        print 'ERROR: RECURSIVE CONTENT LEVEL. Depth of recursive call is more than the limit of '.$MAXLEVEL.".\n";
377
+        return;
378
+    }
379
+    // file_get_contents is not possible. We must execute code with include
380
+    //$content = file_get_contents($fullpathfile);
381
+    //print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/
382 382
 
383
-	ob_start();
384
-	$res = include $fullpathfile;		// Include because we want to execute code content
385
-	$tmpoutput = ob_get_contents();
386
-	ob_end_clean();
383
+    ob_start();
384
+    $res = include $fullpathfile;		// Include because we want to execute code content
385
+    $tmpoutput = ob_get_contents();
386
+    ob_end_clean();
387 387
 
388
-	print "\n".'<!-- include '.$fullpathfile.' level = '.$includehtmlcontentopened.' -->'."\n";
389
-	print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $tmpoutput);
388
+    print "\n".'<!-- include '.$fullpathfile.' level = '.$includehtmlcontentopened.' -->'."\n";
389
+    print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $tmpoutput);
390 390
 
391
-	if (! $res)
392
-	{
393
-		print 'ERROR: FAILED TO INCLUDE PAGE '.$containerref.".\n";
394
-	}
391
+    if (! $res)
392
+    {
393
+        print 'ERROR: FAILED TO INCLUDE PAGE '.$containerref.".\n";
394
+    }
395 395
 
396
-	$includehtmlcontentopened--;
396
+    $includehtmlcontentopened--;
397 397
 }
398 398
 
399 399
 
@@ -414,172 +414,172 @@  discard block
 block discarded – undo
414 414
  */
415 415
 function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto='subpage')
416 416
 {
417
-	global $conf;
418
-
419
-	$error=0;
420
-
421
-	dol_syslog("Call getAllImages with grabimagesinto=".$grabimagesinto);
422
-
423
-	$alreadygrabbed=array();
424
-
425
-	if (preg_match('/\/$/', $urltograb)) $urltograb.='.';
426
-	$urltograb = dirname($urltograb);							// So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1
427
-
428
-	// Search X in "img...src=X"
429
-	preg_match_all('/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs);
430
-
431
-	foreach ($regs[0] as $key => $val)
432
-	{
433
-		if (preg_match('/^data:image/i', $regs[2][$key])) continue;		// We do nothing for such images
434
-
435
-		if (preg_match('/^\//', $regs[2][$key]))
436
-		{
437
-			$urltograbdirrootwithoutslash = getRootURLFromURL($urltograb);
438
-			$urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];	// We use dirroot
439
-		}
440
-		else
441
-		{
442
-			$urltograbbis = $urltograb.'/'.$regs[2][$key];	// We use dir of grabbed file
443
-		}
444
-
445
-		$linkwithoutdomain = $regs[2][$key];
446
-		$dirforimages = '/'.$objectpage->pageurl;
447
-		if ($grabimagesinto == 'root') $dirforimages='';
448
-
449
-		// Define $filetosave and $filename
450
-		$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
451
-		if (preg_match('/^http/', $regs[2][$key]))
452
-		{
453
-			$urltograbbis = $regs[2][$key];
454
-			$linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
455
-			$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
456
-		}
457
-		$filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
458
-
459
-		// Clean the aa/bb/../cc into aa/cc
460
-		$filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave);
461
-		$filename = preg_replace('/\/[^\/]+\/\.\./', '', $filename);
462
-
463
-		//var_dump($filetosave);
464
-		//var_dump($filename);
465
-		//exit;
466
-
467
-		if (empty($alreadygrabbed[$urltograbbis]))
468
-		{
469
-			if ($grabimages)
470
-			{
471
-				$tmpgeturl = getURLContent($urltograbbis);
472
-				if ($tmpgeturl['curl_error_no'])
473
-				{
474
-					$error++;
475
-					setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
476
-					$action='create';
477
-				}
478
-				elseif ($tmpgeturl['http_code'] != '200')
479
-				{
480
-					$error++;
481
-					setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
482
-					$action='create';
483
-				}
484
-				else
485
-				{
486
-					$alreadygrabbed[$urltograbbis]=1;	// Track that file was alreay grabbed.
487
-
488
-					dol_mkdir(dirname($filetosave));
489
-
490
-					$fp = fopen($filetosave, "w");
491
-					fputs($fp, $tmpgeturl['content']);
492
-					fclose($fp);
493
-					if (! empty($conf->global->MAIN_UMASK))
494
-						@chmod($filetosave, octdec($conf->global->MAIN_UMASK));
495
-				}
496
-			}
497
-		}
498
-
499
-		if ($modifylinks)
500
-		{
501
-			$tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '<img'.$regs[1][$key].'src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'"'.$regs[3][$key].'>', $tmp);
502
-		}
503
-	}
504
-
505
-	// Search X in "background...url(X)"
506
-	preg_match_all('/background([^\.\/\(;]+)url\([\"\']?([^\)\"\']*)[\"\']?\)/i', $tmp, $regs);
507
-
508
-	foreach ($regs[0] as $key => $val)
509
-	{
510
-		if (preg_match('/^data:image/i', $regs[2][$key])) continue;		// We do nothing for such images
511
-
512
-		if (preg_match('/^\//', $regs[2][$key]))
513
-		{
514
-			$urltograbdirrootwithoutslash = getRootURLFromURL($urltograb);
515
-			$urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];	// We use dirroot
516
-		}
517
-		else
518
-		{
519
-			$urltograbbis = $urltograb.'/'.$regs[2][$key];	// We use dir of grabbed file
520
-		}
521
-
522
-		$linkwithoutdomain = $regs[2][$key];
523
-
524
-		$dirforimages = '/'.$objectpage->pageurl;
525
-		if ($grabimagesinto == 'root') $dirforimages='';
526
-
527
-		$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
528
-
529
-		if (preg_match('/^http/', $regs[2][$key]))
530
-		{
531
-			$urltograbbis = $regs[2][$key];
532
-			$linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
533
-			$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
534
-		}
535
-
536
-		$filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
537
-
538
-		// Clean the aa/bb/../cc into aa/cc
539
-		$filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave);
540
-		$filename = preg_replace('/\/[^\/]+\/\.\./', '', $filename);
541
-
542
-		//var_dump($filetosave);
543
-		//var_dump($filename);
544
-		//exit;
545
-
546
-		if (empty($alreadygrabbed[$urltograbbis]))
547
-		{
548
-			if ($grabimages)
549
-			{
550
-				$tmpgeturl = getURLContent($urltograbbis);
551
-				if ($tmpgeturl['curl_error_no'])
552
-				{
553
-					$error++;
554
-					setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
555
-					$action='create';
556
-				}
557
-				elseif ($tmpgeturl['http_code'] != '200')
558
-				{
559
-					$error++;
560
-					setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
561
-					$action='create';
562
-				}
563
-				else
564
-				{
565
-					$alreadygrabbed[$urltograbbis]=1;	// Track that file was alreay grabbed.
566
-
567
-					dol_mkdir(dirname($filetosave));
568
-
569
-					$fp = fopen($filetosave, "w");
570
-					fputs($fp, $tmpgeturl['content']);
571
-					fclose($fp);
572
-					if (! empty($conf->global->MAIN_UMASK))
573
-						@chmod($filetosave, octdec($conf->global->MAIN_UMASK));
574
-				}
575
-			}
576
-		}
577
-
578
-		if ($modifylinks)
579
-		{
580
-			$tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', 'background'.$regs[1][$key].'url("'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'")', $tmp);
581
-		}
582
-	}
417
+    global $conf;
418
+
419
+    $error=0;
420
+
421
+    dol_syslog("Call getAllImages with grabimagesinto=".$grabimagesinto);
422
+
423
+    $alreadygrabbed=array();
424
+
425
+    if (preg_match('/\/$/', $urltograb)) $urltograb.='.';
426
+    $urltograb = dirname($urltograb);							// So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1
427
+
428
+    // Search X in "img...src=X"
429
+    preg_match_all('/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs);
430
+
431
+    foreach ($regs[0] as $key => $val)
432
+    {
433
+        if (preg_match('/^data:image/i', $regs[2][$key])) continue;		// We do nothing for such images
434
+
435
+        if (preg_match('/^\//', $regs[2][$key]))
436
+        {
437
+            $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb);
438
+            $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];	// We use dirroot
439
+        }
440
+        else
441
+        {
442
+            $urltograbbis = $urltograb.'/'.$regs[2][$key];	// We use dir of grabbed file
443
+        }
444
+
445
+        $linkwithoutdomain = $regs[2][$key];
446
+        $dirforimages = '/'.$objectpage->pageurl;
447
+        if ($grabimagesinto == 'root') $dirforimages='';
448
+
449
+        // Define $filetosave and $filename
450
+        $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
451
+        if (preg_match('/^http/', $regs[2][$key]))
452
+        {
453
+            $urltograbbis = $regs[2][$key];
454
+            $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
455
+            $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
456
+        }
457
+        $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
458
+
459
+        // Clean the aa/bb/../cc into aa/cc
460
+        $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave);
461
+        $filename = preg_replace('/\/[^\/]+\/\.\./', '', $filename);
462
+
463
+        //var_dump($filetosave);
464
+        //var_dump($filename);
465
+        //exit;
466
+
467
+        if (empty($alreadygrabbed[$urltograbbis]))
468
+        {
469
+            if ($grabimages)
470
+            {
471
+                $tmpgeturl = getURLContent($urltograbbis);
472
+                if ($tmpgeturl['curl_error_no'])
473
+                {
474
+                    $error++;
475
+                    setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
476
+                    $action='create';
477
+                }
478
+                elseif ($tmpgeturl['http_code'] != '200')
479
+                {
480
+                    $error++;
481
+                    setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
482
+                    $action='create';
483
+                }
484
+                else
485
+                {
486
+                    $alreadygrabbed[$urltograbbis]=1;	// Track that file was alreay grabbed.
487
+
488
+                    dol_mkdir(dirname($filetosave));
489
+
490
+                    $fp = fopen($filetosave, "w");
491
+                    fputs($fp, $tmpgeturl['content']);
492
+                    fclose($fp);
493
+                    if (! empty($conf->global->MAIN_UMASK))
494
+                        @chmod($filetosave, octdec($conf->global->MAIN_UMASK));
495
+                }
496
+            }
497
+        }
498
+
499
+        if ($modifylinks)
500
+        {
501
+            $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '<img'.$regs[1][$key].'src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'"'.$regs[3][$key].'>', $tmp);
502
+        }
503
+    }
504
+
505
+    // Search X in "background...url(X)"
506
+    preg_match_all('/background([^\.\/\(;]+)url\([\"\']?([^\)\"\']*)[\"\']?\)/i', $tmp, $regs);
507
+
508
+    foreach ($regs[0] as $key => $val)
509
+    {
510
+        if (preg_match('/^data:image/i', $regs[2][$key])) continue;		// We do nothing for such images
511
+
512
+        if (preg_match('/^\//', $regs[2][$key]))
513
+        {
514
+            $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb);
515
+            $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];	// We use dirroot
516
+        }
517
+        else
518
+        {
519
+            $urltograbbis = $urltograb.'/'.$regs[2][$key];	// We use dir of grabbed file
520
+        }
521
+
522
+        $linkwithoutdomain = $regs[2][$key];
523
+
524
+        $dirforimages = '/'.$objectpage->pageurl;
525
+        if ($grabimagesinto == 'root') $dirforimages='';
526
+
527
+        $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
528
+
529
+        if (preg_match('/^http/', $regs[2][$key]))
530
+        {
531
+            $urltograbbis = $regs[2][$key];
532
+            $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
533
+            $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
534
+        }
535
+
536
+        $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
537
+
538
+        // Clean the aa/bb/../cc into aa/cc
539
+        $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave);
540
+        $filename = preg_replace('/\/[^\/]+\/\.\./', '', $filename);
541
+
542
+        //var_dump($filetosave);
543
+        //var_dump($filename);
544
+        //exit;
545
+
546
+        if (empty($alreadygrabbed[$urltograbbis]))
547
+        {
548
+            if ($grabimages)
549
+            {
550
+                $tmpgeturl = getURLContent($urltograbbis);
551
+                if ($tmpgeturl['curl_error_no'])
552
+                {
553
+                    $error++;
554
+                    setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
555
+                    $action='create';
556
+                }
557
+                elseif ($tmpgeturl['http_code'] != '200')
558
+                {
559
+                    $error++;
560
+                    setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
561
+                    $action='create';
562
+                }
563
+                else
564
+                {
565
+                    $alreadygrabbed[$urltograbbis]=1;	// Track that file was alreay grabbed.
566
+
567
+                    dol_mkdir(dirname($filetosave));
568
+
569
+                    $fp = fopen($filetosave, "w");
570
+                    fputs($fp, $tmpgeturl['content']);
571
+                    fclose($fp);
572
+                    if (! empty($conf->global->MAIN_UMASK))
573
+                        @chmod($filetosave, octdec($conf->global->MAIN_UMASK));
574
+                }
575
+            }
576
+        }
577
+
578
+        if ($modifylinks)
579
+        {
580
+            $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', 'background'.$regs[1][$key].'url("'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'")', $tmp);
581
+        }
582
+    }
583 583
 }
584 584
 
585 585
 
@@ -592,21 +592,21 @@  discard block
 block discarded – undo
592 592
  */
593 593
 function dolSaveMasterFile($filemaster)
594 594
 {
595
-	global $conf;
595
+    global $conf;
596 596
 
597
-	// Now generate the master.inc.php page
598
-	dol_syslog("We regenerate the master file");
599
-	dol_delete_file($filemaster);
597
+    // Now generate the master.inc.php page
598
+    dol_syslog("We regenerate the master file");
599
+    dol_delete_file($filemaster);
600 600
 
601
-	$mastercontent = '<?php'."\n";
602
-	$mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
603
-	$mastercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
604
-	$mastercontent.= '?>'."\n";
605
-	$result = file_put_contents($filemaster, $mastercontent);
606
-	if (! empty($conf->global->MAIN_UMASK))
607
-		@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
601
+    $mastercontent = '<?php'."\n";
602
+    $mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
603
+    $mastercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
604
+    $mastercontent.= '?>'."\n";
605
+    $result = file_put_contents($filemaster, $mastercontent);
606
+    if (! empty($conf->global->MAIN_UMASK))
607
+        @chmod($filemaster, octdec($conf->global->MAIN_UMASK));
608 608
 
609
-	return $result;
609
+    return $result;
610 610
 }
611 611
 
612 612
 /**
@@ -619,23 +619,23 @@  discard block
 block discarded – undo
619 619
  */
620 620
 function dolSavePageAlias($filealias, $object, $objectpage)
621 621
 {
622
-	global $conf;
623
-
624
-	// Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
625
-	dol_syslog("We regenerate the alias page filealias=".$filealias);
626
-
627
-	$aliascontent = '<?php'."\n";
628
-	$aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
629
-	$aliascontent.= 'global $dolibarr_main_data_root;'."\n";
630
-	$aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
631
-	$aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
632
-	$aliascontent.= '?>'."\n";
633
-	$result = file_put_contents($filealias, $aliascontent);
634
-	if (! empty($conf->global->MAIN_UMASK)) {
622
+    global $conf;
623
+
624
+    // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
625
+    dol_syslog("We regenerate the alias page filealias=".$filealias);
626
+
627
+    $aliascontent = '<?php'."\n";
628
+    $aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
629
+    $aliascontent.= 'global $dolibarr_main_data_root;'."\n";
630
+    $aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
631
+    $aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
632
+    $aliascontent.= '?>'."\n";
633
+    $result = file_put_contents($filealias, $aliascontent);
634
+    if (! empty($conf->global->MAIN_UMASK)) {
635 635
         @chmod($filealias, octdec($conf->global->MAIN_UMASK));
636 636
     }
637 637
 
638
-	return ($result?true:false);
638
+    return ($result?true:false);
639 639
 }
640 640
 
641 641
 
@@ -649,60 +649,60 @@  discard block
 block discarded – undo
649 649
  */
650 650
 function dolSavePageContent($filetpl, $object, $objectpage)
651 651
 {
652
-	global $conf;
653
-
654
-	// Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
655
-	dol_syslog("We regenerate the tpl page filetpl=".$filetpl);
656
-
657
-	dol_delete_file($filetpl);
658
-
659
-	$shortlangcode = '';
660
-	if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang);		// en_US or en-US -> en
661
-
662
-	$tplcontent ='';
663
-	$tplcontent.= "<?php // BEGIN PHP\n";
664
-	$tplcontent.= '$websitekey=basename(dirname(__FILE__)); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
665
-	$tplcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n";
666
-	$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
667
-	$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
668
-	$tplcontent.= "ob_start();\n";
669
-	$tplcontent.= "// END PHP ?>\n";
670
-	$tplcontent.= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"':'').'>'."\n";
671
-	$tplcontent.= '<head>'."\n";
672
-	$tplcontent.= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n";
673
-	$tplcontent.= '<meta charset="UTF-8">'."\n";
674
-	$tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
675
-	$tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
676
-	$tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
677
-	$tplcontent.= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n";
678
-	$tplcontent.= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n";
679
-	$tplcontent.= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
680
-	$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
681
-	$tplcontent.= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n";
682
-	$tplcontent.= '<!-- Include link to CSS file -->'."\n";
683
-	$tplcontent.= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'."\n";
684
-	$tplcontent.= '<!-- Include HTML header from common file -->'."\n";
685
-	$tplcontent.= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
686
-	$tplcontent.= '<!-- Include HTML header from page header block -->'."\n";
687
-	$tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
688
-	$tplcontent.= '</head>'."\n";
689
-
690
-	$tplcontent.= '<!-- File generated by Dolibarr website module editor -->'."\n";
691
-	$tplcontent.= '<body id="bodywebsite" class="bodywebsite">'."\n";
692
-	$tplcontent.= $objectpage->content."\n";
693
-	$tplcontent.= '</body>'."\n";
694
-	$tplcontent.= '</html>'."\n";
695
-
696
-	$tplcontent.= '<?php // BEGIN PHP'."\n";
697
-	$tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
698
-	$tplcontent.= "// END PHP ?>"."\n";
699
-
700
-	//var_dump($filetpl);exit;
701
-	$result = file_put_contents($filetpl, $tplcontent);
702
-	if (! empty($conf->global->MAIN_UMASK))
703
-		@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
704
-
705
-		return $result;
652
+    global $conf;
653
+
654
+    // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
655
+    dol_syslog("We regenerate the tpl page filetpl=".$filetpl);
656
+
657
+    dol_delete_file($filetpl);
658
+
659
+    $shortlangcode = '';
660
+    if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang);		// en_US or en-US -> en
661
+
662
+    $tplcontent ='';
663
+    $tplcontent.= "<?php // BEGIN PHP\n";
664
+    $tplcontent.= '$websitekey=basename(dirname(__FILE__)); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
665
+    $tplcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n";
666
+    $tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
667
+    $tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
668
+    $tplcontent.= "ob_start();\n";
669
+    $tplcontent.= "// END PHP ?>\n";
670
+    $tplcontent.= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"':'').'>'."\n";
671
+    $tplcontent.= '<head>'."\n";
672
+    $tplcontent.= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n";
673
+    $tplcontent.= '<meta charset="UTF-8">'."\n";
674
+    $tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
675
+    $tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
676
+    $tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
677
+    $tplcontent.= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n";
678
+    $tplcontent.= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n";
679
+    $tplcontent.= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
680
+    $tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
681
+    $tplcontent.= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n";
682
+    $tplcontent.= '<!-- Include link to CSS file -->'."\n";
683
+    $tplcontent.= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'."\n";
684
+    $tplcontent.= '<!-- Include HTML header from common file -->'."\n";
685
+    $tplcontent.= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
686
+    $tplcontent.= '<!-- Include HTML header from page header block -->'."\n";
687
+    $tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
688
+    $tplcontent.= '</head>'."\n";
689
+
690
+    $tplcontent.= '<!-- File generated by Dolibarr website module editor -->'."\n";
691
+    $tplcontent.= '<body id="bodywebsite" class="bodywebsite">'."\n";
692
+    $tplcontent.= $objectpage->content."\n";
693
+    $tplcontent.= '</body>'."\n";
694
+    $tplcontent.= '</html>'."\n";
695
+
696
+    $tplcontent.= '<?php // BEGIN PHP'."\n";
697
+    $tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
698
+    $tplcontent.= "// END PHP ?>"."\n";
699
+
700
+    //var_dump($filetpl);exit;
701
+    $result = file_put_contents($filetpl, $tplcontent);
702
+    if (! empty($conf->global->MAIN_UMASK))
703
+        @chmod($filetpl, octdec($conf->global->MAIN_UMASK));
704
+
705
+        return $result;
706 706
 }
707 707
 
708 708
 
@@ -717,38 +717,38 @@  discard block
 block discarded – undo
717 717
  */
718 718
 function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
719 719
 {
720
-	global $conf;
721
-
722
-	$result1=false;
723
-	$result2=false;
724
-
725
-	dol_mkdir($pathofwebsite);
726
-
727
-	dol_delete_file($fileindex);
728
-	$indexcontent = '<?php'."\n";
729
-	$indexcontent.= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
730
-	$indexcontent.= '$websitekey=basename(dirname(__FILE__)); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
731
-	$indexcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
732
-	$indexcontent.= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
733
-	$indexcontent.= "	require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
734
-	$indexcontent.= "	require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
735
-	$indexcontent.= '	redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
736
-	$indexcontent.= "}\n";
737
-	$indexcontent.= "include_once './".basename($filetpl)."'\n";
738
-	$indexcontent.= '// END PHP ?>'."\n";
739
-	$result1 = file_put_contents($fileindex, $indexcontent);
740
-	if (! empty($conf->global->MAIN_UMASK))
741
-		@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
742
-
743
-	dol_delete_file($filewrapper);
744
-
745
-	$wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
746
-
747
-	$result2 = file_put_contents($filewrapper, $wrappercontent);
748
-	if (! empty($conf->global->MAIN_UMASK))
749
-		@chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
750
-
751
-	return ($result1 && $result2);
720
+    global $conf;
721
+
722
+    $result1=false;
723
+    $result2=false;
724
+
725
+    dol_mkdir($pathofwebsite);
726
+
727
+    dol_delete_file($fileindex);
728
+    $indexcontent = '<?php'."\n";
729
+    $indexcontent.= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
730
+    $indexcontent.= '$websitekey=basename(dirname(__FILE__)); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
731
+    $indexcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
732
+    $indexcontent.= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
733
+    $indexcontent.= "	require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
734
+    $indexcontent.= "	require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
735
+    $indexcontent.= '	redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
736
+    $indexcontent.= "}\n";
737
+    $indexcontent.= "include_once './".basename($filetpl)."'\n";
738
+    $indexcontent.= '// END PHP ?>'."\n";
739
+    $result1 = file_put_contents($fileindex, $indexcontent);
740
+    if (! empty($conf->global->MAIN_UMASK))
741
+        @chmod($fileindex, octdec($conf->global->MAIN_UMASK));
742
+
743
+    dol_delete_file($filewrapper);
744
+
745
+    $wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
746
+
747
+    $result2 = file_put_contents($filewrapper, $wrappercontent);
748
+    if (! empty($conf->global->MAIN_UMASK))
749
+        @chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
750
+
751
+    return ($result1 && $result2);
752 752
 }
753 753
 
754 754
 
@@ -761,22 +761,22 @@  discard block
 block discarded – undo
761 761
  */
762 762
 function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
763 763
 {
764
-	global $conf, $pathofwebsite;
764
+    global $conf, $pathofwebsite;
765 765
 
766
-	dol_syslog("Save html header into ".$filehtmlheader);
766
+    dol_syslog("Save html header into ".$filehtmlheader);
767 767
 
768
-	dol_mkdir($pathofwebsite);
769
-	$result = file_put_contents($filehtmlheader, $htmlheadercontent);
770
-	if (! empty($conf->global->MAIN_UMASK))
771
-		@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
768
+    dol_mkdir($pathofwebsite);
769
+    $result = file_put_contents($filehtmlheader, $htmlheadercontent);
770
+    if (! empty($conf->global->MAIN_UMASK))
771
+        @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
772 772
 
773
-		if (! $result)
774
-		{
775
-			setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
776
-			return false;
777
-		}
773
+        if (! $result)
774
+        {
775
+            setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
776
+            return false;
777
+        }
778 778
 
779
-		return true;
779
+        return true;
780 780
 }
781 781
 
782 782
 /**
@@ -788,22 +788,22 @@  discard block
 block discarded – undo
788 788
  */
789 789
 function dolSaveCssFile($filecss, $csscontent)
790 790
 {
791
-	global $conf, $pathofwebsite;
791
+    global $conf, $pathofwebsite;
792 792
 
793
-	dol_syslog("Save css file into ".$filecss);
793
+    dol_syslog("Save css file into ".$filecss);
794 794
 
795
-	dol_mkdir($pathofwebsite);
796
-	$result = file_put_contents($filecss, $csscontent);
797
-	if (! empty($conf->global->MAIN_UMASK))
798
-		@chmod($filecss, octdec($conf->global->MAIN_UMASK));
795
+    dol_mkdir($pathofwebsite);
796
+    $result = file_put_contents($filecss, $csscontent);
797
+    if (! empty($conf->global->MAIN_UMASK))
798
+        @chmod($filecss, octdec($conf->global->MAIN_UMASK));
799 799
 
800
-		if (! $result)
801
-		{
802
-			setEventMessages('Failed to write file '.$filecss, null, 'errors');
803
-			return false;
804
-		}
800
+        if (! $result)
801
+        {
802
+            setEventMessages('Failed to write file '.$filecss, null, 'errors');
803
+            return false;
804
+        }
805 805
 
806
-		return true;
806
+        return true;
807 807
 }
808 808
 
809 809
 /**
@@ -815,22 +815,22 @@  discard block
 block discarded – undo
815 815
  */
816 816
 function dolSaveJsFile($filejs, $jscontent)
817 817
 {
818
-	global $conf, $pathofwebsite;
818
+    global $conf, $pathofwebsite;
819 819
 
820
-	dol_syslog("Save js file into ".$filejs);
820
+    dol_syslog("Save js file into ".$filejs);
821 821
 
822
-	dol_mkdir($pathofwebsite);
823
-	$result = file_put_contents($filejs, $jscontent);
824
-	if (! empty($conf->global->MAIN_UMASK))
825
-		@chmod($filejs, octdec($conf->global->MAIN_UMASK));
822
+    dol_mkdir($pathofwebsite);
823
+    $result = file_put_contents($filejs, $jscontent);
824
+    if (! empty($conf->global->MAIN_UMASK))
825
+        @chmod($filejs, octdec($conf->global->MAIN_UMASK));
826 826
 
827
-		if (! $result)
828
-		{
829
-			setEventMessages('Failed to write file '.$filejs, null, 'errors');
830
-			return false;
831
-		}
827
+        if (! $result)
828
+        {
829
+            setEventMessages('Failed to write file '.$filejs, null, 'errors');
830
+            return false;
831
+        }
832 832
 
833
-		return true;
833
+        return true;
834 834
 }
835 835
 
836 836
 /**
@@ -842,22 +842,22 @@  discard block
 block discarded – undo
842 842
  */
843 843
 function dolSaveRobotFile($filerobot, $robotcontent)
844 844
 {
845
-	global $conf, $pathofwebsite;
845
+    global $conf, $pathofwebsite;
846 846
 
847
-	dol_syslog("Save robot file into ".$filerobot);
847
+    dol_syslog("Save robot file into ".$filerobot);
848 848
 
849
-	dol_mkdir($pathofwebsite);
850
-	$result = file_put_contents($filerobot, $robotcontent);
851
-	if (! empty($conf->global->MAIN_UMASK))
852
-		@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
849
+    dol_mkdir($pathofwebsite);
850
+    $result = file_put_contents($filerobot, $robotcontent);
851
+    if (! empty($conf->global->MAIN_UMASK))
852
+        @chmod($filerobot, octdec($conf->global->MAIN_UMASK));
853 853
 
854
-		if (! $result)
855
-		{
856
-			setEventMessages('Failed to write file '.$filerobot, null, 'errors');
857
-			return false;
858
-		}
854
+        if (! $result)
855
+        {
856
+            setEventMessages('Failed to write file '.$filerobot, null, 'errors');
857
+            return false;
858
+        }
859 859
 
860
-		return true;
860
+        return true;
861 861
 }
862 862
 
863 863
 /**
@@ -869,20 +869,20 @@  discard block
 block discarded – undo
869 869
  */
870 870
 function dolSaveHtaccessFile($filehtaccess, $htaccess)
871 871
 {
872
-	global $conf, $pathofwebsite;
872
+    global $conf, $pathofwebsite;
873 873
 
874
-	dol_syslog("Save htaccess file into ".$filehtaccess);
874
+    dol_syslog("Save htaccess file into ".$filehtaccess);
875 875
 
876
-	dol_mkdir($pathofwebsite);
877
-	$result = file_put_contents($filehtaccess, $htaccess);
878
-	if (! empty($conf->global->MAIN_UMASK))
879
-		@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
876
+    dol_mkdir($pathofwebsite);
877
+    $result = file_put_contents($filehtaccess, $htaccess);
878
+    if (! empty($conf->global->MAIN_UMASK))
879
+        @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
880 880
 
881
-		if (! $result)
882
-		{
883
-			setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
884
-			return false;
885
-		}
881
+        if (! $result)
882
+        {
883
+            setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
884
+            return false;
885
+        }
886 886
 
887
-		return true;
887
+        return true;
888 888
 }
Please login to merge, or discard this patch.
Spacing   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -33,34 +33,34 @@  discard block
 block discarded – undo
33 33
  * @return	boolean							True if OK
34 34
  * @see dolWebsiteOutput for function used to replace content in a web server context
35 35
  */
36
-function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0)
36
+function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0)
37 37
 {
38 38
 	$nbrep = 0;
39 39
 
40 40
 	// Replace php code. Note $content may come from database and does not contains body tags.
41
-	$replacewith='...php...';
42
-	if ($removephppart) $replacewith='';
41
+	$replacewith = '...php...';
42
+	if ($removephppart) $replacewith = '';
43 43
 	$content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content);
44 44
 
45
-	$replacewith='"callto=#';
46
-	if ($removephppart) $replacewith='';
45
+	$replacewith = '"callto=#';
46
+	if ($removephppart) $replacewith = '';
47 47
 	$content = preg_replace('/"callto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
48 48
 
49
-	$replacewith='"mailto=#';
50
-	if ($removephppart) $replacewith='';
49
+	$replacewith = '"mailto=#';
50
+	if ($removephppart) $replacewith = '';
51 51
 	$content = preg_replace('/"mailto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
52 52
 
53
-	$replacewith='src="php';
54
-	if ($removephppart) $replacewith='';
53
+	$replacewith = 'src="php';
54
+	if ($removephppart) $replacewith = '';
55 55
 	$content = preg_replace('/src="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
56 56
 
57
-	$replacewith='href="php';
58
-	if ($removephppart) $replacewith='';
57
+	$replacewith = 'href="php';
58
+	if ($removephppart) $replacewith = '';
59 59
 	$content = preg_replace('/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
60 60
 
61 61
 	//$replacewith='<span class="phptag">...php...</span>';
62
-	$replacewith='<span class="phptag">...php...</span>';
63
-	if ($removephppart) $replacewith='';
62
+	$replacewith = '<span class="phptag">...php...</span>';
63
+	if ($removephppart) $replacewith = '';
64 64
 	//$content = preg_replace('/<\?php((?!\?toremove>).)*\?toremove>\n*/ims', $replacewith, $content);
65 65
 	/*if ($content === null) {
66 66
 		if (preg_last_error() == PREG_JIT_STACKLIMIT_ERROR) $content = 'preg_replace error (when removing php tags) PREG_JIT_STACKLIMIT_ERROR';
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	// <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
81 81
 	$content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
82 82
 	// <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
83
-	$content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
83
+	$content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT, '/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
84 84
 	// <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png"
85 85
 	$content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep);
86 86
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	$content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
89 89
 
90 90
 	// Fix relative link /document.php with correct URL after the DOL_URL_ROOT:  ...href="/document.php?modulepart="
91
-	$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
92
-	$content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
91
+	$content = preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
92
+	$content = preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
93 93
 
94 94
 	return $content;
95 95
 }
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
  * @param	string	$replacewith	String to use as replacement
103 103
  * @return 	string					Result string without php code
104 104
  */
105
-function dolStripPhpCode($str, $replacewith='')
105
+function dolStripPhpCode($str, $replacewith = '')
106 106
 {
107 107
 	$newstr = '';
108 108
 
109 109
 	//split on each opening tag
110
-	$parts = explode('<?php',$str);
110
+	$parts = explode('<?php', $str);
111 111
 	if (!empty($parts))
112 112
 	{
113
-		$i=0;
114
-		foreach($parts as $part)
113
+		$i = 0;
114
+		foreach ($parts as $part)
115 115
 		{
116 116
 			if ($i == 0) 	// The first part is never php code
117 117
 			{
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 				//remove content before closing tag
127 127
 				if (count($partlings) > 1) $partlings[0] = '';
128 128
 				//append to out string
129
-				$newstr .= $replacewith.implode('',$partlings);
129
+				$newstr .= $replacewith.implode('', $partlings);
130 130
 			}
131 131
 		}
132 132
 	}
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 	global $db, $langs, $conf, $user;
148 148
 	global $dolibarr_main_url_root, $dolibarr_main_data_root;
149 149
 
150
-	dol_syslog("dolWebsiteOutput start (USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." (USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')');
150
+	dol_syslog("dolWebsiteOutput start (USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER') ? '1' : '')." (USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR') ? '1' : '').')');
151 151
 
152 152
 	// Define $urlwithroot
153
-	$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
154
-	$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
153
+	$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
154
+	$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
155 155
 	//$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
156 156
 
157 157
 	if (defined('USEDOLIBARREDITOR'))		// REPLACEMENT OF LINKS When page called from Dolibarr editor
@@ -166,29 +166,29 @@  discard block
 block discarded – undo
166 166
 		global $website;
167 167
 
168 168
 		// Replace relative link / with dolibarr URL:  ...href="/"...
169
-		$content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'"', $content, -1, $nbrep);
169
+		$content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'"', $content, -1, $nbrep);
170 170
 		// Replace relative link /xxx.php with dolibarr URL:  ...href="....php"
171
-		$content=preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
171
+		$content = preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
172 172
 		// Replace relative link /xxx with dolibarr URL:  ...href="....php"
173
-		$content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep);
174
-		$content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\?)/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep);
173
+		$content = preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep);
174
+		$content = preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\?)/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep);
175 175
 
176 176
 		// Fix relative link /document.php with correct URL after the DOL_URL_ROOT:  href="/document.php?modulepart=" => href="/dolibarr/document.php?modulepart="
177
-		$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
178
-		$content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
177
+		$content = preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
178
+		$content = preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
179 179
 
180 180
 		// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: href="/viewimage.php?modulepart=" => href="/dolibarr/viewimage.php?modulepart="
181
-		$content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
182
-		$content=preg_replace('/(src=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
181
+		$content = preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
182
+		$content = preg_replace('/(src=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
183 183
 
184 184
 		// Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
185
-		$content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
186
-		$content=preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
185
+		$content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
186
+		$content = preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
187 187
 
188 188
 		// <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
189 189
 		$content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
190 190
 		// <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
191
-		$content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
191
+		$content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT, '/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
192 192
 		// <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png"
193 193
 		$content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep);
194 194
 
@@ -197,44 +197,44 @@  discard block
 block discarded – undo
197 197
 	}
198 198
 	else									// REPLACEMENT OF LINKS When page called from virtual host
199 199
 	{
200
-		$symlinktomediaexists=1;
200
+		$symlinktomediaexists = 1;
201 201
 
202 202
 		// Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server
203 203
 		// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
204 204
 		// become
205 205
 		// <img alt="" src="'.$urlwithroot.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
206
-		$nbrep=0;
207
-		if (! $symlinktomediaexists)
206
+		$nbrep = 0;
207
+		if (!$symlinktomediaexists)
208 208
 		{
209
-			$content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
209
+			$content = preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
210 210
 
211
-			$content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
212
-			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
213
-			$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',  '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
211
+			$content = preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
212
+			$content = preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
213
+			$content = preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
214 214
 
215
-			$content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
216
-			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
217
-			$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/',  '\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep);
215
+			$content = preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
216
+			$content = preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
217
+			$content = preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep);
218 218
 
219
-			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
219
+			$content = preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
220 220
 		}
221 221
 		else
222 222
 		{
223
-			$content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
223
+			$content = preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
224 224
 
225
-			$content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
226
-			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
227
-			$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
225
+			$content = preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
226
+			$content = preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
227
+			$content = preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
228 228
 
229
-			$content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
230
-			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
231
-			$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
229
+			$content = preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
230
+			$content = preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
231
+			$content = preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
232 232
 
233
-			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
233
+			$content = preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
234 234
 		}
235 235
 	}
236 236
 
237
-	$content=preg_replace('/ contenteditable="true"/', ' contenteditable="false"', $content, -1, $nbrep);
237
+	$content = preg_replace('/ contenteditable="true"/', ' contenteditable="false"', $content, -1, $nbrep);
238 238
 
239 239
 	dol_syslog("dolWebsiteOutput end");
240 240
 
@@ -277,18 +277,18 @@  discard block
 block discarded – undo
277 277
  * @param 	int		$containerid		Id of container.
278 278
  * @return  void
279 279
  */
280
-function redirectToContainer($containerref, $containeraliasalt='',$containerid=0)
280
+function redirectToContainer($containerref, $containeraliasalt = '', $containerid = 0)
281 281
 {
282 282
 	global $db, $website;
283 283
 
284 284
 	$newurl = '';
285
-	$result=0;
285
+	$result = 0;
286 286
 
287 287
 	// We make redirect using the alternative alias, we must find the real $containerref
288 288
 	if ($containeraliasalt)
289 289
 	{
290 290
 		include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
291
-		$tmpwebsitepage=new WebsitePage($db);
291
+		$tmpwebsitepage = new WebsitePage($db);
292 292
 		$result = $tmpwebsitepage->fetch(0, $website->id, '', $containeraliasalt);
293 293
 		if ($result > 0)
294 294
 		{
@@ -304,10 +304,10 @@  discard block
 block discarded – undo
304 304
 	if (defined('USEDOLIBARRSERVER'))	// When page called from Dolibarr server
305 305
 	{
306 306
 		// Check new container exists
307
-		if (! $containeraliasalt)	// If containeraliasalt set, we already did the test
307
+		if (!$containeraliasalt)	// If containeraliasalt set, we already did the test
308 308
 		{
309 309
 			include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
310
-			$tmpwebsitepage=new WebsitePage($db);
310
+			$tmpwebsitepage = new WebsitePage($db);
311 311
 			$result = $tmpwebsitepage->fetch(0, $website->id, $containerref);
312 312
 			unset($tmpwebsitepage);
313 313
 		}
@@ -359,17 +359,17 @@  discard block
 block discarded – undo
359 359
  */
360 360
 function includeContainer($containerref)
361 361
 {
362
-	global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;	// Very important. Required to have var available when running inluded containers.
362
+	global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers.
363 363
 	global $includehtmlcontentopened;
364 364
 	global $websitekey, $websitepagefile;
365 365
 
366
-	$MAXLEVEL=20;
366
+	$MAXLEVEL = 20;
367 367
 
368
-	if (! preg_match('/\.php$/i', $containerref)) $containerref.='.php';
368
+	if (!preg_match('/\.php$/i', $containerref)) $containerref .= '.php';
369 369
 
370
-	$fullpathfile=DOL_DATA_ROOT.'/website/'.$websitekey.'/'.$containerref;
370
+	$fullpathfile = DOL_DATA_ROOT.'/website/'.$websitekey.'/'.$containerref;
371 371
 
372
-	if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0;
372
+	if (empty($includehtmlcontentopened)) $includehtmlcontentopened = 0;
373 373
 	$includehtmlcontentopened++;
374 374
 	if ($includehtmlcontentopened > $MAXLEVEL)
375 375
 	{
@@ -381,14 +381,14 @@  discard block
 block discarded – undo
381 381
 	//print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/
382 382
 
383 383
 	ob_start();
384
-	$res = include $fullpathfile;		// Include because we want to execute code content
384
+	$res = include $fullpathfile; // Include because we want to execute code content
385 385
 	$tmpoutput = ob_get_contents();
386 386
 	ob_end_clean();
387 387
 
388 388
 	print "\n".'<!-- include '.$fullpathfile.' level = '.$includehtmlcontentopened.' -->'."\n";
389
-	print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $tmpoutput);
389
+	print preg_replace(array('/^.*<body[^>]*>/ims', '/<\/body>.*$/ims'), array('', ''), $tmpoutput);
390 390
 
391
-	if (! $res)
391
+	if (!$res)
392 392
 	{
393 393
 		print 'ERROR: FAILED TO INCLUDE PAGE '.$containerref.".\n";
394 394
 	}
@@ -412,49 +412,49 @@  discard block
 block discarded – undo
412 412
  * @param	string		$grabimagesinto	'root' or 'subpage'
413 413
  * @return	void
414 414
  */
415
-function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto='subpage')
415
+function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks = 0, $grabimages = 1, $grabimagesinto = 'subpage')
416 416
 {
417 417
 	global $conf;
418 418
 
419
-	$error=0;
419
+	$error = 0;
420 420
 
421 421
 	dol_syslog("Call getAllImages with grabimagesinto=".$grabimagesinto);
422 422
 
423
-	$alreadygrabbed=array();
423
+	$alreadygrabbed = array();
424 424
 
425
-	if (preg_match('/\/$/', $urltograb)) $urltograb.='.';
426
-	$urltograb = dirname($urltograb);							// So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1
425
+	if (preg_match('/\/$/', $urltograb)) $urltograb .= '.';
426
+	$urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1
427 427
 
428 428
 	// Search X in "img...src=X"
429 429
 	preg_match_all('/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs);
430 430
 
431 431
 	foreach ($regs[0] as $key => $val)
432 432
 	{
433
-		if (preg_match('/^data:image/i', $regs[2][$key])) continue;		// We do nothing for such images
433
+		if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images
434 434
 
435 435
 		if (preg_match('/^\//', $regs[2][$key]))
436 436
 		{
437 437
 			$urltograbdirrootwithoutslash = getRootURLFromURL($urltograb);
438
-			$urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];	// We use dirroot
438
+			$urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot
439 439
 		}
440 440
 		else
441 441
 		{
442
-			$urltograbbis = $urltograb.'/'.$regs[2][$key];	// We use dir of grabbed file
442
+			$urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file
443 443
 		}
444 444
 
445 445
 		$linkwithoutdomain = $regs[2][$key];
446 446
 		$dirforimages = '/'.$objectpage->pageurl;
447
-		if ($grabimagesinto == 'root') $dirforimages='';
447
+		if ($grabimagesinto == 'root') $dirforimages = '';
448 448
 
449 449
 		// Define $filetosave and $filename
450
-		$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
450
+		$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key]) ? '' : '/').$regs[2][$key];
451 451
 		if (preg_match('/^http/', $regs[2][$key]))
452 452
 		{
453 453
 			$urltograbbis = $regs[2][$key];
454 454
 			$linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
455
-			$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
455
+			$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain;
456 456
 		}
457
-		$filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
457
+		$filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain;
458 458
 
459 459
 		// Clean the aa/bb/../cc into aa/cc
460 460
 		$filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave);
@@ -473,24 +473,24 @@  discard block
 block discarded – undo
473 473
 				{
474 474
 					$error++;
475 475
 					setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
476
-					$action='create';
476
+					$action = 'create';
477 477
 				}
478 478
 				elseif ($tmpgeturl['http_code'] != '200')
479 479
 				{
480 480
 					$error++;
481 481
 					setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
482
-					$action='create';
482
+					$action = 'create';
483 483
 				}
484 484
 				else
485 485
 				{
486
-					$alreadygrabbed[$urltograbbis]=1;	// Track that file was alreay grabbed.
486
+					$alreadygrabbed[$urltograbbis] = 1; // Track that file was alreay grabbed.
487 487
 
488 488
 					dol_mkdir(dirname($filetosave));
489 489
 
490 490
 					$fp = fopen($filetosave, "w");
491 491
 					fputs($fp, $tmpgeturl['content']);
492 492
 					fclose($fp);
493
-					if (! empty($conf->global->MAIN_UMASK))
493
+					if (!empty($conf->global->MAIN_UMASK))
494 494
 						@chmod($filetosave, octdec($conf->global->MAIN_UMASK));
495 495
 				}
496 496
 			}
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 
499 499
 		if ($modifylinks)
500 500
 		{
501
-			$tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '<img'.$regs[1][$key].'src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'"'.$regs[3][$key].'>', $tmp);
501
+			$tmp = preg_replace('/'.preg_quote($regs[0][$key], '/').'/i', '<img'.$regs[1][$key].'src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'"'.$regs[3][$key].'>', $tmp);
502 502
 		}
503 503
 	}
504 504
 
@@ -507,33 +507,33 @@  discard block
 block discarded – undo
507 507
 
508 508
 	foreach ($regs[0] as $key => $val)
509 509
 	{
510
-		if (preg_match('/^data:image/i', $regs[2][$key])) continue;		// We do nothing for such images
510
+		if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images
511 511
 
512 512
 		if (preg_match('/^\//', $regs[2][$key]))
513 513
 		{
514 514
 			$urltograbdirrootwithoutslash = getRootURLFromURL($urltograb);
515
-			$urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];	// We use dirroot
515
+			$urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot
516 516
 		}
517 517
 		else
518 518
 		{
519
-			$urltograbbis = $urltograb.'/'.$regs[2][$key];	// We use dir of grabbed file
519
+			$urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file
520 520
 		}
521 521
 
522 522
 		$linkwithoutdomain = $regs[2][$key];
523 523
 
524 524
 		$dirforimages = '/'.$objectpage->pageurl;
525
-		if ($grabimagesinto == 'root') $dirforimages='';
525
+		if ($grabimagesinto == 'root') $dirforimages = '';
526 526
 
527
-		$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
527
+		$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key]) ? '' : '/').$regs[2][$key];
528 528
 
529 529
 		if (preg_match('/^http/', $regs[2][$key]))
530 530
 		{
531 531
 			$urltograbbis = $regs[2][$key];
532 532
 			$linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
533
-			$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
533
+			$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain;
534 534
 		}
535 535
 
536
-		$filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
536
+		$filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain;
537 537
 
538 538
 		// Clean the aa/bb/../cc into aa/cc
539 539
 		$filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave);
@@ -552,24 +552,24 @@  discard block
 block discarded – undo
552 552
 				{
553 553
 					$error++;
554 554
 					setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
555
-					$action='create';
555
+					$action = 'create';
556 556
 				}
557 557
 				elseif ($tmpgeturl['http_code'] != '200')
558 558
 				{
559 559
 					$error++;
560 560
 					setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
561
-					$action='create';
561
+					$action = 'create';
562 562
 				}
563 563
 				else
564 564
 				{
565
-					$alreadygrabbed[$urltograbbis]=1;	// Track that file was alreay grabbed.
565
+					$alreadygrabbed[$urltograbbis] = 1; // Track that file was alreay grabbed.
566 566
 
567 567
 					dol_mkdir(dirname($filetosave));
568 568
 
569 569
 					$fp = fopen($filetosave, "w");
570 570
 					fputs($fp, $tmpgeturl['content']);
571 571
 					fclose($fp);
572
-					if (! empty($conf->global->MAIN_UMASK))
572
+					if (!empty($conf->global->MAIN_UMASK))
573 573
 						@chmod($filetosave, octdec($conf->global->MAIN_UMASK));
574 574
 				}
575 575
 			}
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 
578 578
 		if ($modifylinks)
579 579
 		{
580
-			$tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', 'background'.$regs[1][$key].'url("'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'")', $tmp);
580
+			$tmp = preg_replace('/'.preg_quote($regs[0][$key], '/').'/i', 'background'.$regs[1][$key].'url("'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'")', $tmp);
581 581
 		}
582 582
 	}
583 583
 }
@@ -599,11 +599,11 @@  discard block
 block discarded – undo
599 599
 	dol_delete_file($filemaster);
600 600
 
601 601
 	$mastercontent = '<?php'."\n";
602
-	$mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
603
-	$mastercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
604
-	$mastercontent.= '?>'."\n";
602
+	$mastercontent .= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
603
+	$mastercontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
604
+	$mastercontent .= '?>'."\n";
605 605
 	$result = file_put_contents($filemaster, $mastercontent);
606
-	if (! empty($conf->global->MAIN_UMASK))
606
+	if (!empty($conf->global->MAIN_UMASK))
607 607
 		@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
608 608
 
609 609
 	return $result;
@@ -625,17 +625,17 @@  discard block
 block discarded – undo
625 625
 	dol_syslog("We regenerate the alias page filealias=".$filealias);
626 626
 
627 627
 	$aliascontent = '<?php'."\n";
628
-	$aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
629
-	$aliascontent.= 'global $dolibarr_main_data_root;'."\n";
630
-	$aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
631
-	$aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
632
-	$aliascontent.= '?>'."\n";
628
+	$aliascontent .= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
629
+	$aliascontent .= 'global $dolibarr_main_data_root;'."\n";
630
+	$aliascontent .= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
631
+	$aliascontent .= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
632
+	$aliascontent .= '?>'."\n";
633 633
 	$result = file_put_contents($filealias, $aliascontent);
634
-	if (! empty($conf->global->MAIN_UMASK)) {
634
+	if (!empty($conf->global->MAIN_UMASK)) {
635 635
         @chmod($filealias, octdec($conf->global->MAIN_UMASK));
636 636
     }
637 637
 
638
-	return ($result?true:false);
638
+	return ($result ?true:false);
639 639
 }
640 640
 
641 641
 
@@ -657,49 +657,49 @@  discard block
 block discarded – undo
657 657
 	dol_delete_file($filetpl);
658 658
 
659 659
 	$shortlangcode = '';
660
-	if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang);		// en_US or en-US -> en
661
-
662
-	$tplcontent ='';
663
-	$tplcontent.= "<?php // BEGIN PHP\n";
664
-	$tplcontent.= '$websitekey=basename(dirname(__FILE__)); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
665
-	$tplcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n";
666
-	$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
667
-	$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
668
-	$tplcontent.= "ob_start();\n";
669
-	$tplcontent.= "// END PHP ?>\n";
670
-	$tplcontent.= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"':'').'>'."\n";
671
-	$tplcontent.= '<head>'."\n";
672
-	$tplcontent.= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n";
673
-	$tplcontent.= '<meta charset="UTF-8">'."\n";
674
-	$tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
675
-	$tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
676
-	$tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
677
-	$tplcontent.= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n";
678
-	$tplcontent.= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n";
679
-	$tplcontent.= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
680
-	$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
681
-	$tplcontent.= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n";
682
-	$tplcontent.= '<!-- Include link to CSS file -->'."\n";
683
-	$tplcontent.= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'."\n";
684
-	$tplcontent.= '<!-- Include HTML header from common file -->'."\n";
685
-	$tplcontent.= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
686
-	$tplcontent.= '<!-- Include HTML header from page header block -->'."\n";
687
-	$tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
688
-	$tplcontent.= '</head>'."\n";
689
-
690
-	$tplcontent.= '<!-- File generated by Dolibarr website module editor -->'."\n";
691
-	$tplcontent.= '<body id="bodywebsite" class="bodywebsite">'."\n";
692
-	$tplcontent.= $objectpage->content."\n";
693
-	$tplcontent.= '</body>'."\n";
694
-	$tplcontent.= '</html>'."\n";
695
-
696
-	$tplcontent.= '<?php // BEGIN PHP'."\n";
697
-	$tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
698
-	$tplcontent.= "// END PHP ?>"."\n";
660
+	if ($objectpage->lang) $shortlangcode = preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en
661
+
662
+	$tplcontent = '';
663
+	$tplcontent .= "<?php // BEGIN PHP\n";
664
+	$tplcontent .= '$websitekey=basename(dirname(__FILE__)); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
665
+	$tplcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n";
666
+	$tplcontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
667
+	$tplcontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
668
+	$tplcontent .= "ob_start();\n";
669
+	$tplcontent .= "// END PHP ?>\n";
670
+	$tplcontent .= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"' : '').'>'."\n";
671
+	$tplcontent .= '<head>'."\n";
672
+	$tplcontent .= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n";
673
+	$tplcontent .= '<meta charset="UTF-8">'."\n";
674
+	$tplcontent .= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
675
+	$tplcontent .= '<meta name="robots" content="index, follow" />'."\n";
676
+	$tplcontent .= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
677
+	$tplcontent .= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n";
678
+	$tplcontent .= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n";
679
+	$tplcontent .= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
680
+	$tplcontent .= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
681
+	$tplcontent .= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n";
682
+	$tplcontent .= '<!-- Include link to CSS file -->'."\n";
683
+	$tplcontent .= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'."\n";
684
+	$tplcontent .= '<!-- Include HTML header from common file -->'."\n";
685
+	$tplcontent .= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
686
+	$tplcontent .= '<!-- Include HTML header from page header block -->'."\n";
687
+	$tplcontent .= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
688
+	$tplcontent .= '</head>'."\n";
689
+
690
+	$tplcontent .= '<!-- File generated by Dolibarr website module editor -->'."\n";
691
+	$tplcontent .= '<body id="bodywebsite" class="bodywebsite">'."\n";
692
+	$tplcontent .= $objectpage->content."\n";
693
+	$tplcontent .= '</body>'."\n";
694
+	$tplcontent .= '</html>'."\n";
695
+
696
+	$tplcontent .= '<?php // BEGIN PHP'."\n";
697
+	$tplcontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
698
+	$tplcontent .= "// END PHP ?>"."\n";
699 699
 
700 700
 	//var_dump($filetpl);exit;
701 701
 	$result = file_put_contents($filetpl, $tplcontent);
702
-	if (! empty($conf->global->MAIN_UMASK))
702
+	if (!empty($conf->global->MAIN_UMASK))
703 703
 		@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
704 704
 
705 705
 		return $result;
@@ -719,33 +719,33 @@  discard block
 block discarded – undo
719 719
 {
720 720
 	global $conf;
721 721
 
722
-	$result1=false;
723
-	$result2=false;
722
+	$result1 = false;
723
+	$result2 = false;
724 724
 
725 725
 	dol_mkdir($pathofwebsite);
726 726
 
727 727
 	dol_delete_file($fileindex);
728 728
 	$indexcontent = '<?php'."\n";
729
-	$indexcontent.= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
730
-	$indexcontent.= '$websitekey=basename(dirname(__FILE__)); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
731
-	$indexcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
732
-	$indexcontent.= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
733
-	$indexcontent.= "	require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
734
-	$indexcontent.= "	require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
735
-	$indexcontent.= '	redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
736
-	$indexcontent.= "}\n";
737
-	$indexcontent.= "include_once './".basename($filetpl)."'\n";
738
-	$indexcontent.= '// END PHP ?>'."\n";
729
+	$indexcontent .= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
730
+	$indexcontent .= '$websitekey=basename(dirname(__FILE__)); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
731
+	$indexcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
732
+	$indexcontent .= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
733
+	$indexcontent .= "	require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
734
+	$indexcontent .= "	require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
735
+	$indexcontent .= '	redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
736
+	$indexcontent .= "}\n";
737
+	$indexcontent .= "include_once './".basename($filetpl)."'\n";
738
+	$indexcontent .= '// END PHP ?>'."\n";
739 739
 	$result1 = file_put_contents($fileindex, $indexcontent);
740
-	if (! empty($conf->global->MAIN_UMASK))
740
+	if (!empty($conf->global->MAIN_UMASK))
741 741
 		@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
742 742
 
743 743
 	dol_delete_file($filewrapper);
744 744
 
745
-	$wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
745
+	$wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
746 746
 
747 747
 	$result2 = file_put_contents($filewrapper, $wrappercontent);
748
-	if (! empty($conf->global->MAIN_UMASK))
748
+	if (!empty($conf->global->MAIN_UMASK))
749 749
 		@chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
750 750
 
751 751
 	return ($result1 && $result2);
@@ -767,10 +767,10 @@  discard block
 block discarded – undo
767 767
 
768 768
 	dol_mkdir($pathofwebsite);
769 769
 	$result = file_put_contents($filehtmlheader, $htmlheadercontent);
770
-	if (! empty($conf->global->MAIN_UMASK))
770
+	if (!empty($conf->global->MAIN_UMASK))
771 771
 		@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
772 772
 
773
-		if (! $result)
773
+		if (!$result)
774 774
 		{
775 775
 			setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
776 776
 			return false;
@@ -794,10 +794,10 @@  discard block
 block discarded – undo
794 794
 
795 795
 	dol_mkdir($pathofwebsite);
796 796
 	$result = file_put_contents($filecss, $csscontent);
797
-	if (! empty($conf->global->MAIN_UMASK))
797
+	if (!empty($conf->global->MAIN_UMASK))
798 798
 		@chmod($filecss, octdec($conf->global->MAIN_UMASK));
799 799
 
800
-		if (! $result)
800
+		if (!$result)
801 801
 		{
802 802
 			setEventMessages('Failed to write file '.$filecss, null, 'errors');
803 803
 			return false;
@@ -821,10 +821,10 @@  discard block
 block discarded – undo
821 821
 
822 822
 	dol_mkdir($pathofwebsite);
823 823
 	$result = file_put_contents($filejs, $jscontent);
824
-	if (! empty($conf->global->MAIN_UMASK))
824
+	if (!empty($conf->global->MAIN_UMASK))
825 825
 		@chmod($filejs, octdec($conf->global->MAIN_UMASK));
826 826
 
827
-		if (! $result)
827
+		if (!$result)
828 828
 		{
829 829
 			setEventMessages('Failed to write file '.$filejs, null, 'errors');
830 830
 			return false;
@@ -848,10 +848,10 @@  discard block
 block discarded – undo
848 848
 
849 849
 	dol_mkdir($pathofwebsite);
850 850
 	$result = file_put_contents($filerobot, $robotcontent);
851
-	if (! empty($conf->global->MAIN_UMASK))
851
+	if (!empty($conf->global->MAIN_UMASK))
852 852
 		@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
853 853
 
854
-		if (! $result)
854
+		if (!$result)
855 855
 		{
856 856
 			setEventMessages('Failed to write file '.$filerobot, null, 'errors');
857 857
 			return false;
@@ -875,10 +875,10 @@  discard block
 block discarded – undo
875 875
 
876 876
 	dol_mkdir($pathofwebsite);
877 877
 	$result = file_put_contents($filehtaccess, $htaccess);
878
-	if (! empty($conf->global->MAIN_UMASK))
878
+	if (!empty($conf->global->MAIN_UMASK))
879 879
 		@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
880 880
 
881
-		if (! $result)
881
+		if (!$result)
882 882
 		{
883 883
 			setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
884 884
 			return false;
Please login to merge, or discard this patch.
Braces   +106 added lines, -68 removed lines patch added patch discarded remove patch
@@ -39,28 +39,40 @@  discard block
 block discarded – undo
39 39
 
40 40
 	// Replace php code. Note $content may come from database and does not contains body tags.
41 41
 	$replacewith='...php...';
42
-	if ($removephppart) $replacewith='';
42
+	if ($removephppart) {
43
+	    $replacewith='';
44
+	}
43 45
 	$content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content);
44 46
 
45 47
 	$replacewith='"callto=#';
46
-	if ($removephppart) $replacewith='';
48
+	if ($removephppart) {
49
+	    $replacewith='';
50
+	}
47 51
 	$content = preg_replace('/"callto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
48 52
 
49 53
 	$replacewith='"mailto=#';
50
-	if ($removephppart) $replacewith='';
54
+	if ($removephppart) {
55
+	    $replacewith='';
56
+	}
51 57
 	$content = preg_replace('/"mailto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
52 58
 
53 59
 	$replacewith='src="php';
54
-	if ($removephppart) $replacewith='';
60
+	if ($removephppart) {
61
+	    $replacewith='';
62
+	}
55 63
 	$content = preg_replace('/src="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
56 64
 
57 65
 	$replacewith='href="php';
58
-	if ($removephppart) $replacewith='';
66
+	if ($removephppart) {
67
+	    $replacewith='';
68
+	}
59 69
 	$content = preg_replace('/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
60 70
 
61 71
 	//$replacewith='<span class="phptag">...php...</span>';
62 72
 	$replacewith='<span class="phptag">...php...</span>';
63
-	if ($removephppart) $replacewith='';
73
+	if ($removephppart) {
74
+	    $replacewith='';
75
+	}
64 76
 	//$content = preg_replace('/<\?php((?!\?toremove>).)*\?toremove>\n*/ims', $replacewith, $content);
65 77
 	/*if ($content === null) {
66 78
 		if (preg_last_error() == PREG_JIT_STACKLIMIT_ERROR) $content = 'preg_replace error (when removing php tags) PREG_JIT_STACKLIMIT_ERROR';
@@ -113,9 +125,11 @@  discard block
 block discarded – undo
113 125
 		$i=0;
114 126
 		foreach($parts as $part)
115 127
 		{
116
-			if ($i == 0) 	// The first part is never php code
128
+			if ($i == 0) {
129
+			    // The first part is never php code
117 130
 			{
118 131
 				$i++;
132
+			}
119 133
 				$newstr .= $part;
120 134
 				continue;
121 135
 			}
@@ -124,7 +138,9 @@  discard block
 block discarded – undo
124 138
 			if (!empty($partlings))
125 139
 			{
126 140
 				//remove content before closing tag
127
-				if (count($partlings) > 1) $partlings[0] = '';
141
+				if (count($partlings) > 1) {
142
+				    $partlings[0] = '';
143
+				}
128 144
 				//append to out string
129 145
 				$newstr .= $replacewith.implode('',$partlings);
130 146
 			}
@@ -154,16 +170,19 @@  discard block
 block discarded – undo
154 170
 	$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
155 171
 	//$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
156 172
 
157
-	if (defined('USEDOLIBARREDITOR'))		// REPLACEMENT OF LINKS When page called from Dolibarr editor
173
+	if (defined('USEDOLIBARREDITOR')) {
174
+	    // REPLACEMENT OF LINKS When page called from Dolibarr editor
158 175
 	{
159 176
 		// We remove the <head> part of content
160 177
 		$content = preg_replace('/<head>.*<\/head>/ims', '', $content);
178
+	}
161 179
 		$content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $content);
162 180
 		$content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $content);
163
-	}
164
-	elseif (defined('USEDOLIBARRSERVER'))	// REPLACEMENT OF LINKS When page called from Dolibarr server
181
+	} elseif (defined('USEDOLIBARRSERVER')) {
182
+	    // REPLACEMENT OF LINKS When page called from Dolibarr server
165 183
 	{
166 184
 		global $website;
185
+	}
167 186
 
168 187
 		// Replace relative link / with dolibarr URL:  ...href="/"...
169 188
 		$content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'"', $content, -1, $nbrep);
@@ -194,8 +213,7 @@  discard block
 block discarded – undo
194 213
 
195 214
 		// action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage
196 215
 		$content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
197
-	}
198
-	else									// REPLACEMENT OF LINKS When page called from virtual host
216
+	} else									// REPLACEMENT OF LINKS When page called from virtual host
199 217
 	{
200 218
 		$symlinktomediaexists=1;
201 219
 
@@ -217,8 +235,7 @@  discard block
 block discarded – undo
217 235
 			$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/',  '\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep);
218 236
 
219 237
 			$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
220
-		}
221
-		else
238
+		} else
222 239
 		{
223 240
 			$content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
224 241
 
@@ -293,20 +310,21 @@  discard block
 block discarded – undo
293 310
 		if ($result > 0)
294 311
 		{
295 312
 			$containerref = $tmpwebsitepage->pageurl;
296
-		}
297
-		else
313
+		} else
298 314
 		{
299 315
 			print "Error, page contains a redirect to the alternative alias '".$containeraliasalt."' that does not exists in web site (".$website->id." / ".$website->ref.")";
300 316
 			exit;
301 317
 		}
302 318
 	}
303 319
 
304
-	if (defined('USEDOLIBARRSERVER'))	// When page called from Dolibarr server
320
+	if (defined('USEDOLIBARRSERVER')) {
321
+	    // When page called from Dolibarr server
305 322
 	{
306 323
 		// Check new container exists
307 324
 		if (! $containeraliasalt)	// If containeraliasalt set, we already did the test
308 325
 		{
309 326
 			include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
327
+	}
310 328
 			$tmpwebsitepage=new WebsitePage($db);
311 329
 			$result = $tmpwebsitepage->fetch(0, $website->id, $containerref);
312 330
 			unset($tmpwebsitepage);
@@ -320,19 +338,16 @@  discard block
 block discarded – undo
320 338
 				{
321 339
 					print "Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containerref."' in web site '".$website->ref."'";
322 340
 					exit;
323
-				}
324
-				else
341
+				} else
325 342
 				{
326 343
 					$newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containerref, $currenturi);
327 344
 				}
328
-			}
329
-			else
345
+			} else
330 346
 			{
331 347
 				$newurl = $currenturi.'&pageref='.urlencode($containerref);
332 348
 			}
333 349
 		}
334
-	}
335
-	else								// When page called from virtual host server
350
+	} else								// When page called from virtual host server
336 351
 	{
337 352
 		$newurl = '/'.$containerref.'.php';
338 353
 	}
@@ -341,8 +356,7 @@  discard block
 block discarded – undo
341 356
 	{
342 357
 		header("Location: ".$newurl);
343 358
 		exit;
344
-	}
345
-	else
359
+	} else
346 360
 	{
347 361
 		print "Error, page contains a redirect to the alias page '".$containerref."' that does not exists in web site (".$website->id." / ".$website->ref.")";
348 362
 		exit;
@@ -365,11 +379,15 @@  discard block
 block discarded – undo
365 379
 
366 380
 	$MAXLEVEL=20;
367 381
 
368
-	if (! preg_match('/\.php$/i', $containerref)) $containerref.='.php';
382
+	if (! preg_match('/\.php$/i', $containerref)) {
383
+	    $containerref.='.php';
384
+	}
369 385
 
370 386
 	$fullpathfile=DOL_DATA_ROOT.'/website/'.$websitekey.'/'.$containerref;
371 387
 
372
-	if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0;
388
+	if (empty($includehtmlcontentopened)) {
389
+	    $includehtmlcontentopened=0;
390
+	}
373 391
 	$includehtmlcontentopened++;
374 392
 	if ($includehtmlcontentopened > $MAXLEVEL)
375 393
 	{
@@ -422,7 +440,9 @@  discard block
 block discarded – undo
422 440
 
423 441
 	$alreadygrabbed=array();
424 442
 
425
-	if (preg_match('/\/$/', $urltograb)) $urltograb.='.';
443
+	if (preg_match('/\/$/', $urltograb)) {
444
+	    $urltograb.='.';
445
+	}
426 446
 	$urltograb = dirname($urltograb);							// So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1
427 447
 
428 448
 	// Search X in "img...src=X"
@@ -430,21 +450,25 @@  discard block
 block discarded – undo
430 450
 
431 451
 	foreach ($regs[0] as $key => $val)
432 452
 	{
433
-		if (preg_match('/^data:image/i', $regs[2][$key])) continue;		// We do nothing for such images
453
+		if (preg_match('/^data:image/i', $regs[2][$key])) {
454
+		    continue;
455
+		}
456
+		// We do nothing for such images
434 457
 
435 458
 		if (preg_match('/^\//', $regs[2][$key]))
436 459
 		{
437 460
 			$urltograbdirrootwithoutslash = getRootURLFromURL($urltograb);
438 461
 			$urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];	// We use dirroot
439
-		}
440
-		else
462
+		} else
441 463
 		{
442 464
 			$urltograbbis = $urltograb.'/'.$regs[2][$key];	// We use dir of grabbed file
443 465
 		}
444 466
 
445 467
 		$linkwithoutdomain = $regs[2][$key];
446 468
 		$dirforimages = '/'.$objectpage->pageurl;
447
-		if ($grabimagesinto == 'root') $dirforimages='';
469
+		if ($grabimagesinto == 'root') {
470
+		    $dirforimages='';
471
+		}
448 472
 
449 473
 		// Define $filetosave and $filename
450 474
 		$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
@@ -474,14 +498,12 @@  discard block
 block discarded – undo
474 498
 					$error++;
475 499
 					setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
476 500
 					$action='create';
477
-				}
478
-				elseif ($tmpgeturl['http_code'] != '200')
501
+				} elseif ($tmpgeturl['http_code'] != '200')
479 502
 				{
480 503
 					$error++;
481 504
 					setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
482 505
 					$action='create';
483
-				}
484
-				else
506
+				} else
485 507
 				{
486 508
 					$alreadygrabbed[$urltograbbis]=1;	// Track that file was alreay grabbed.
487 509
 
@@ -490,8 +512,9 @@  discard block
 block discarded – undo
490 512
 					$fp = fopen($filetosave, "w");
491 513
 					fputs($fp, $tmpgeturl['content']);
492 514
 					fclose($fp);
493
-					if (! empty($conf->global->MAIN_UMASK))
494
-						@chmod($filetosave, octdec($conf->global->MAIN_UMASK));
515
+					if (! empty($conf->global->MAIN_UMASK)) {
516
+											@chmod($filetosave, octdec($conf->global->MAIN_UMASK));
517
+					}
495 518
 				}
496 519
 			}
497 520
 		}
@@ -507,14 +530,16 @@  discard block
 block discarded – undo
507 530
 
508 531
 	foreach ($regs[0] as $key => $val)
509 532
 	{
510
-		if (preg_match('/^data:image/i', $regs[2][$key])) continue;		// We do nothing for such images
533
+		if (preg_match('/^data:image/i', $regs[2][$key])) {
534
+		    continue;
535
+		}
536
+		// We do nothing for such images
511 537
 
512 538
 		if (preg_match('/^\//', $regs[2][$key]))
513 539
 		{
514 540
 			$urltograbdirrootwithoutslash = getRootURLFromURL($urltograb);
515 541
 			$urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];	// We use dirroot
516
-		}
517
-		else
542
+		} else
518 543
 		{
519 544
 			$urltograbbis = $urltograb.'/'.$regs[2][$key];	// We use dir of grabbed file
520 545
 		}
@@ -522,7 +547,9 @@  discard block
 block discarded – undo
522 547
 		$linkwithoutdomain = $regs[2][$key];
523 548
 
524 549
 		$dirforimages = '/'.$objectpage->pageurl;
525
-		if ($grabimagesinto == 'root') $dirforimages='';
550
+		if ($grabimagesinto == 'root') {
551
+		    $dirforimages='';
552
+		}
526 553
 
527 554
 		$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
528 555
 
@@ -553,14 +580,12 @@  discard block
 block discarded – undo
553 580
 					$error++;
554 581
 					setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
555 582
 					$action='create';
556
-				}
557
-				elseif ($tmpgeturl['http_code'] != '200')
583
+				} elseif ($tmpgeturl['http_code'] != '200')
558 584
 				{
559 585
 					$error++;
560 586
 					setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
561 587
 					$action='create';
562
-				}
563
-				else
588
+				} else
564 589
 				{
565 590
 					$alreadygrabbed[$urltograbbis]=1;	// Track that file was alreay grabbed.
566 591
 
@@ -569,8 +594,9 @@  discard block
 block discarded – undo
569 594
 					$fp = fopen($filetosave, "w");
570 595
 					fputs($fp, $tmpgeturl['content']);
571 596
 					fclose($fp);
572
-					if (! empty($conf->global->MAIN_UMASK))
573
-						@chmod($filetosave, octdec($conf->global->MAIN_UMASK));
597
+					if (! empty($conf->global->MAIN_UMASK)) {
598
+											@chmod($filetosave, octdec($conf->global->MAIN_UMASK));
599
+					}
574 600
 				}
575 601
 			}
576 602
 		}
@@ -603,8 +629,9 @@  discard block
 block discarded – undo
603 629
 	$mastercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
604 630
 	$mastercontent.= '?>'."\n";
605 631
 	$result = file_put_contents($filemaster, $mastercontent);
606
-	if (! empty($conf->global->MAIN_UMASK))
607
-		@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
632
+	if (! empty($conf->global->MAIN_UMASK)) {
633
+			@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
634
+	}
608 635
 
609 636
 	return $result;
610 637
 }
@@ -657,7 +684,10 @@  discard block
 block discarded – undo
657 684
 	dol_delete_file($filetpl);
658 685
 
659 686
 	$shortlangcode = '';
660
-	if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang);		// en_US or en-US -> en
687
+	if ($objectpage->lang) {
688
+	    $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang);
689
+	}
690
+	// en_US or en-US -> en
661 691
 
662 692
 	$tplcontent ='';
663 693
 	$tplcontent.= "<?php // BEGIN PHP\n";
@@ -699,8 +729,9 @@  discard block
 block discarded – undo
699 729
 
700 730
 	//var_dump($filetpl);exit;
701 731
 	$result = file_put_contents($filetpl, $tplcontent);
702
-	if (! empty($conf->global->MAIN_UMASK))
703
-		@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
732
+	if (! empty($conf->global->MAIN_UMASK)) {
733
+			@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
734
+	}
704 735
 
705 736
 		return $result;
706 737
 }
@@ -737,16 +768,18 @@  discard block
 block discarded – undo
737 768
 	$indexcontent.= "include_once './".basename($filetpl)."'\n";
738 769
 	$indexcontent.= '// END PHP ?>'."\n";
739 770
 	$result1 = file_put_contents($fileindex, $indexcontent);
740
-	if (! empty($conf->global->MAIN_UMASK))
741
-		@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
771
+	if (! empty($conf->global->MAIN_UMASK)) {
772
+			@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
773
+	}
742 774
 
743 775
 	dol_delete_file($filewrapper);
744 776
 
745 777
 	$wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
746 778
 
747 779
 	$result2 = file_put_contents($filewrapper, $wrappercontent);
748
-	if (! empty($conf->global->MAIN_UMASK))
749
-		@chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
780
+	if (! empty($conf->global->MAIN_UMASK)) {
781
+			@chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
782
+	}
750 783
 
751 784
 	return ($result1 && $result2);
752 785
 }
@@ -767,8 +800,9 @@  discard block
 block discarded – undo
767 800
 
768 801
 	dol_mkdir($pathofwebsite);
769 802
 	$result = file_put_contents($filehtmlheader, $htmlheadercontent);
770
-	if (! empty($conf->global->MAIN_UMASK))
771
-		@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
803
+	if (! empty($conf->global->MAIN_UMASK)) {
804
+			@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
805
+	}
772 806
 
773 807
 		if (! $result)
774 808
 		{
@@ -794,8 +828,9 @@  discard block
 block discarded – undo
794 828
 
795 829
 	dol_mkdir($pathofwebsite);
796 830
 	$result = file_put_contents($filecss, $csscontent);
797
-	if (! empty($conf->global->MAIN_UMASK))
798
-		@chmod($filecss, octdec($conf->global->MAIN_UMASK));
831
+	if (! empty($conf->global->MAIN_UMASK)) {
832
+			@chmod($filecss, octdec($conf->global->MAIN_UMASK));
833
+	}
799 834
 
800 835
 		if (! $result)
801 836
 		{
@@ -821,8 +856,9 @@  discard block
 block discarded – undo
821 856
 
822 857
 	dol_mkdir($pathofwebsite);
823 858
 	$result = file_put_contents($filejs, $jscontent);
824
-	if (! empty($conf->global->MAIN_UMASK))
825
-		@chmod($filejs, octdec($conf->global->MAIN_UMASK));
859
+	if (! empty($conf->global->MAIN_UMASK)) {
860
+			@chmod($filejs, octdec($conf->global->MAIN_UMASK));
861
+	}
826 862
 
827 863
 		if (! $result)
828 864
 		{
@@ -848,8 +884,9 @@  discard block
 block discarded – undo
848 884
 
849 885
 	dol_mkdir($pathofwebsite);
850 886
 	$result = file_put_contents($filerobot, $robotcontent);
851
-	if (! empty($conf->global->MAIN_UMASK))
852
-		@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
887
+	if (! empty($conf->global->MAIN_UMASK)) {
888
+			@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
889
+	}
853 890
 
854 891
 		if (! $result)
855 892
 		{
@@ -875,8 +912,9 @@  discard block
 block discarded – undo
875 912
 
876 913
 	dol_mkdir($pathofwebsite);
877 914
 	$result = file_put_contents($filehtaccess, $htaccess);
878
-	if (! empty($conf->global->MAIN_UMASK))
879
-		@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
915
+	if (! empty($conf->global->MAIN_UMASK)) {
916
+			@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
917
+	}
880 918
 
881 919
 		if (! $result)
882 920
 		{
Please login to merge, or discard this patch.