Completed
Push — master ( e944e6...657e09 )
by
unknown
19:32 queued 19s
created
includes/librairies/HTML2PDF/_class/parsingCss.class.php 4 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,6 +30,7 @@  discard block
 block discarded – undo
30 30
      * Constructor
31 31
      *
32 32
      * @param  &HTML2PDF_myPdf reference to the PDF $object
33
+     * @param HTML2PDF_myPdf $pdf
33 34
      * @access public
34 35
      */
35 36
     public function __construct(&$pdf)
@@ -75,6 +76,7 @@  discard block
 block discarded – undo
75 76
     * define the Default Font to use, if the font does not exist, or if no font asked
76 77
     *
77 78
     * @param  string  default font-family. If null : Arial for no font asked, and error fot ont does not exist
79
+    * @param string $default
78 80
     * @return string  old default font-family
79 81
     * @access public
80 82
     */
@@ -473,6 +475,7 @@  discard block
 block discarded – undo
473 475
      * @access public
474 476
      * @param  string   tag name
475 477
      * @param  array    styles
478
+     * @param string $tagName
476 479
      */
477 480
     public function getSvgStyle($tagName, &$param)
478 481
     {
@@ -1661,7 +1664,7 @@  discard block
 block discarded – undo
1661 1664
      * read a css content
1662 1665
      *
1663 1666
      * @access protected
1664
-     * @param  &string $code
1667
+     * @param  string $code
1665 1668
      */
1666 1669
     protected function _analyseStyle(&$code)
1667 1670
     {
@@ -1725,6 +1728,7 @@  discard block
 block discarded – undo
1725 1728
      *
1726 1729
      * @access public
1727 1730
      * @param  string   &$html
1731
+     * @param string $html
1728 1732
      */
1729 1733
     public function readStyle(&$html)
1730 1734
     {
Please login to merge, or discard this patch.
Indentation   +1797 added lines, -1797 removed lines patch added patch discarded remove patch
@@ -11,1802 +11,1802 @@
 block discarded – undo
11 11
 
12 12
 class HTML2PDF_parsingCss
13 13
 {
14
-    /**
15
-     * reference to the pdf object
16
-     * @var TCPDF
17
-     */
18
-    protected $_pdf         = null;
19
-
20
-    protected $_htmlColor   = array(); // list of the HTML colors
21
-    protected $_onlyLeft    = false;   // flag if we are in a sub html => only "text-align:left" is used
22
-    protected $_defaultFont = null;    // default font to use if the asked font does not exist
23
-
24
-    public    $value        = array(); // current values
25
-    public    $css          = array(); // css values
26
-    public    $cssKeys      = array(); // css key, for the execution order
27
-    public    $table        = array(); // level history
28
-
29
-    /**
30
-     * Constructor
31
-     *
32
-     * @param  &HTML2PDF_myPdf reference to the PDF $object
33
-     * @access public
34
-     */
35
-    public function __construct(&$pdf)
36
-    {
37
-        $this->_init();
38
-        $this->setPdfParent($pdf);
39
-    }
40
-
41
-    /**
42
-     * Set the HTML2PDF parent object
43
-     *
44
-     * @param  &HTML2PDF reference to the HTML2PDF parent $object
45
-     * @access public
46
-     */
47
-    public function setPdfParent(&$pdf)
48
-    {
49
-        $this->_pdf = &$pdf;
50
-    }
51
-
52
-    /**
53
-     * Inform that we want only "test-align:left" because we are in a sub HTML
54
-     *
55
-     * @access public
56
-     */
57
-    public function setOnlyLeft()
58
-    {
59
-        $this->value['text-align'] = 'left';
60
-        $this->_onlyLeft = true;
61
-    }
62
-
63
-    /**
64
-     * Get the vales of the parent, if exist
65
-     *
66
-     * @return array CSS values
67
-     * @access public
68
-     */
69
-    public function getOldValues()
70
-    {
71
-        return isset($this->table[count($this->table)-1]) ? $this->table[count($this->table)-1] : $this->value;
72
-    }
73
-
74
-    /**
75
-    * define the Default Font to use, if the font does not exist, or if no font asked
76
-    *
77
-    * @param  string  default font-family. If null : Arial for no font asked, and error fot ont does not exist
78
-    * @return string  old default font-family
79
-    * @access public
80
-    */
81
-    public function setDefaultFont($default = null)
82
-    {
83
-        $old = $this->_defaultFont;
84
-        $this->_defaultFont = $default;
85
-        if ($default) $this->value['font-family'] = $default;
86
-        return $old;
87
-    }
88
-
89
-     /**
90
-     * Init the object
91
-     *
92
-     * @access protected
93
-     */
94
-    protected function _init()
95
-    {
96
-        // get the Web Colors from TCPDF
97
-        require(K_PATH_MAIN.'htmlcolors.php');
98
-        $this->_htmlColor = $webcolor;
99
-
100
-        // init the Style
101
-        $this->table = array();
102
-        $this->value = array();
103
-        $this->initStyle();
104
-
105
-        // Init the styles without legacy
106
-        $this->resetStyle();
107
-    }
108
-
109
-    /**
110
-     * Init the CSS Style
111
-     *
112
-     * @access public
113
-     */
114
-    public function initStyle()
115
-    {
116
-        $this->value['id_tag']       = 'body';        // tag name
117
-        $this->value['id_name']          = null;         // tag - attribute name
118
-        $this->value['id_id']            = null;         // tag - attribute id
119
-        $this->value['id_class']         = null;         // tag - attribute class
120
-        $this->value['id_lst']           = array('*');   // tag - list of legacy
121
-        $this->value['mini-size']        = 1.;           // specific size report for sup, sub
122
-        $this->value['mini-decal']       = 0;            // specific position report for sup, sub
123
-        $this->value['font-family']      = 'Arial';
124
-        $this->value['font-bold']        = false;
125
-        $this->value['font-italic']      = false;
126
-        $this->value['font-underline']   = false;
127
-        $this->value['font-overline']    = false;
128
-        $this->value['font-linethrough'] = false;
129
-        $this->value['text-transform']   = 'none';
130
-        $this->value['font-size']        = $this->convertToMM('10pt');
131
-        $this->value['text-indent']      = 0;
132
-        $this->value['text-align']       = 'left';
133
-        $this->value['vertical-align']   = 'middle';
134
-        $this->value['line-height']      = 'normal';
135
-
136
-        $this->value['position']         = null;
137
-        $this->value['x']                = null;
138
-        $this->value['y']                = null;
139
-        $this->value['width']            = 0;
140
-        $this->value['height']           = 0;
141
-        $this->value['top']              = null;
142
-        $this->value['right']            = null;
143
-        $this->value['bottom']           = null;
144
-        $this->value['left']             = null;
145
-        $this->value['float']            = null;
146
-        $this->value['display']          = null;
147
-        $this->value['rotate']           = null;
148
-        $this->value['overflow']         = 'visible';
149
-
150
-        $this->value['color']            = array(0, 0, 0);
151
-        $this->value['background']       = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null);
152
-        $this->value['border']           = array();
153
-        $this->value['padding']          = array();
154
-        $this->value['margin']           = array();
155
-        $this->value['margin-auto']      = false;
156
-
157
-        $this->value['list-style-type']  = '';
158
-        $this->value['list-style-image'] = '';
159
-
160
-        $this->value['xc'] = null;
161
-        $this->value['yc'] = null;
162
-    }
163
-
164
-    /**
165
-     * Init the CSS Style without legacy
166
-     *
167
-     * @param  string  tag name
168
-     * @access public
169
-     */
170
-    public function resetStyle($tagName = '')
171
-    {
172
-        // prepare somme values
173
-        $border = $this->readBorder('solid 1px #000000');
174
-        $units = array(
175
-            '1px' => $this->convertToMM('1px'),
176
-            '5px' => $this->convertToMM('5px'),
177
-        );
178
-
179
-
180
-        // prepare the Collapse attribute
181
-        $collapse = isset($this->value['border']['collapse']) ? $this->value['border']['collapse'] : false;
182
-        if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) $collapse = false;
183
-
184
-        // set the global css values
185
-        $this->value['position']   = null;
186
-        $this->value['x']          = null;
187
-        $this->value['y']          = null;
188
-        $this->value['width']      = 0;
189
-        $this->value['height']     = 0;
190
-        $this->value['top']        = null;
191
-        $this->value['right']      = null;
192
-        $this->value['bottom']     = null;
193
-        $this->value['left']       = null;
194
-        $this->value['float']      = null;
195
-        $this->value['display']    = null;
196
-        $this->value['rotate']     = null;
197
-        $this->value['overflow']   = 'visible';
198
-        $this->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null);
199
-        $this->value['border']     = array(
200
-            't' => $this->readBorder('none'),
201
-            'r' => $this->readBorder('none'),
202
-            'b' => $this->readBorder('none'),
203
-            'l' => $this->readBorder('none'),
204
-            'radius' => array(
205
-                'tl' => array(0, 0),
206
-                'tr' => array(0, 0),
207
-                'br' => array(0, 0),
208
-                'bl' => array(0, 0)
209
-            ),
210
-            'collapse' => $collapse,
211
-        );
212
-
213
-        // specific values for some tags
214
-        if (!in_array($tagName, array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) {
215
-            $this->value['margin'] = array('t'=>0,'r'=>0,'b'=>0,'l'=>0);
216
-        }
217
-
218
-        if (in_array($tagName, array('input', 'select', 'textarea'))) {
219
-            $this->value['border']['t'] = null;
220
-            $this->value['border']['r'] = null;
221
-            $this->value['border']['b'] = null;
222
-            $this->value['border']['l'] = null;
223
-        }
224
-
225
-        if ($tagName=='p') {
226
-            $this->value['margin']['t'] = null;
227
-            $this->value['margin']['b'] = null;
228
-        }
229
-        if ($tagName=='blockquote') {
230
-            $this->value['margin']['t'] = 3;
231
-            $this->value['margin']['r'] = 3;
232
-            $this->value['margin']['b'] = 3;
233
-            $this->value['margin']['l'] = 6;
234
-        }
235
-        $this->value['margin-auto'] = false;
236
-
237
-        if (in_array($tagName, array('blockquote', 'div', 'fieldset'))) {
238
-            $this->value['vertical-align'] = 'top';
239
-        }
240
-
241
-        if (in_array($tagName, array('fieldset', 'legend'))) {
242
-            $this->value['border'] = array(
243
-                't' => $border,
244
-                'r' => $border,
245
-                'b' => $border,
246
-                'l' => $border,
247
-                'radius' => array(
248
-                    'tl' => array($units['5px'], $units['5px']),
249
-                    'tr' => array($units['5px'], $units['5px']),
250
-                    'br' => array($units['5px'], $units['5px']),
251
-                    'bl' => array($units['5px'], $units['5px'])
252
-                ),
253
-                'collapse' => false,
254
-            );
255
-        }
256
-
257
-        if (in_array($tagName, array('ul', 'li'))) {
258
-            $this->value['list-style-type']  = '';
259
-            $this->value['list-style-image'] = '';
260
-        }
261
-
262
-        if (!in_array($tagName, array('tr', 'td'))) {
263
-            $this->value['padding'] = array(
264
-                't' => 0,
265
-                'r' => 0,
266
-                'b' => 0,
267
-                'l' => 0
268
-            );
269
-        } else {
270
-            $this->value['padding'] = array(
271
-                't' => $units['1px'],
272
-                'r' => $units['1px'],
273
-                'b' => $units['1px'],
274
-                'l' => $units['1px']
275
-            );
276
-        }
277
-
278
-        if ($tagName=='hr') {
279
-            $this->value['border'] = array(
280
-                't' => $border,
281
-                'r' => $border,
282
-                'b' => $border,
283
-                'l' => $border,
284
-                'radius' => array(
285
-                    'tl' => array(0, 0),
286
-                    'tr' => array(0, 0),
287
-                    'br' => array(0, 0),
288
-                    'bl' => array(0, 0)
289
-                ),
290
-                'collapse' => false,
291
-            );
292
-            $this->convertBackground('#FFFFFF', $this->value['background']);
293
-        }
294
-
295
-        $this->value['xc'] = null;
296
-        $this->value['yc'] = null;
297
-    }
298
-
299
-    /**
300
-     * Init the PDF Font
301
-     *
302
-     * @access public
303
-     */
304
-    public function fontSet()
305
-    {
306
-        $family = strtolower($this->value['font-family']);
307
-
308
-        $b = ($this->value['font-bold']        ? 'B' : '');
309
-        $i = ($this->value['font-italic']      ? 'I' : '');
310
-        $u = ($this->value['font-underline']   ? 'U' : '');
311
-        $d = ($this->value['font-linethrough'] ? 'D' : '');
312
-        $o = ($this->value['font-overline']    ? 'O' : '');
313
-
314
-        // font style
315
-        $style = $b.$i;
316
-
317
-        if ($this->_defaultFont) {
318
-            if($family=='arial')
319
-                $family='helvetica';
320
-            elseif($family=='symbol' || $family=='zapfdingbats')
321
-                $style='';
322
-
323
-            $fontkey = $family.$style;
324
-            if (!$this->_pdf->isLoadedFont($fontkey))
325
-                $family = $this->_defaultFont;
326
-        }
327
-
328
-        if($family=='arial')
329
-            $family='helvetica';
330
-        elseif($family=='symbol' || $family=='zapfdingbats')
331
-            $style='';
332
-
333
-        // complete style
334
-        $style.= $u.$d.$o;
335
-
336
-        // size : mm => pt
337
-        $size = $this->value['font-size'];
338
-        $size = 72 * $size / 25.4;
339
-
340
-        // apply the font
341
-        $this->_pdf->SetFont($family, $style, $this->value['mini-size']*$size);
342
-        $this->_pdf->setTextColorArray($this->value['color']);
343
-        if ($this->value['background']['color'])
344
-            $this->_pdf->setFillColorArray($this->value['background']['color']);
345
-        else
346
-            $this->_pdf->setFillColor(255);
347
-    }
348
-
349
-     /**
350
-     * add a level in the CSS history
351
-     *
352
-     * @access public
353
-     */
354
-    public function save()
355
-    {
356
-        array_push($this->table, $this->value);
357
-    }
358
-
359
-     /**
360
-     * remove a level in the CSS history
361
-     *
362
-     * @access public
363
-     */
364
-    public function load()
365
-    {
366
-        if (count($this->table)) {
367
-            $this->value = array_pop($this->table);
368
-        }
369
-    }
370
-
371
-     /**
372
-     * restore the Y positiony (used after a span)
373
-     *
374
-     * @access public
375
-     */
376
-    public function restorePosition()
377
-    {
378
-        if ($this->value['y']==$this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false);
379
-    }
380
-
381
-     /**
382
-     * set the New position for the current Tag
383
-     *
384
-     * @access public
385
-     */
386
-    public function setPosition()
387
-    {
388
-        // get the current position
389
-        $currentX = $this->_pdf->getX();
390
-        $currentY = $this->_pdf->getY();
391
-
392
-        // save it
393
-        $this->value['xc'] = $currentX;
394
-        $this->value['yc'] = $currentY;
395
-
396
-        if ($this->value['position']=='relative' || $this->value['position']=='absolute') {
397
-            if ($this->value['right']!==null) {
398
-                $x = $this->getLastWidth(true) - $this->value['right'] - $this->value['width'];
399
-                if ($this->value['margin']['r']) $x-= $this->value['margin']['r'];
400
-            } else {
401
-                $x = $this->value['left'];
402
-                if ($this->value['margin']['l']) $x+= $this->value['margin']['l'];
403
-            }
404
-
405
-            if ($this->value['bottom']!==null) {
406
-                $y = $this->getLastHeight(true) - $this->value['bottom'] - $this->value['height'];
407
-                if ($this->value['margin']['b']) $y-= $this->value['margin']['b'];
408
-            } else {
409
-                $y = $this->value['top'];
410
-                if ($this->value['margin']['t']) $y+= $this->value['margin']['t'];
411
-            }
412
-
413
-            if ($this->value['position']=='relative') {
414
-                $this->value['x'] = $currentX + $x;
415
-                $this->value['y'] = $currentY + $y;
416
-            } else {
417
-                $this->value['x'] = $this->_getLastAbsoluteX()+$x;
418
-                $this->value['y'] = $this->_getLastAbsoluteY()+$y;
419
-            }
420
-        } else {
421
-            $this->value['x'] = $currentX;
422
-            $this->value['y'] = $currentY;
423
-            if ($this->value['margin']['l']) $this->value['x']+= $this->value['margin']['l'];
424
-            if ($this->value['margin']['t']) $this->value['y']+= $this->value['margin']['t'];
425
-        }
426
-
427
-        // save the new position
428
-        $this->_pdf->setXY($this->value['x'], $this->value['y']);
429
-    }
430
-
431
-     /**
432
-     * Analise the CSS style to convert it into Form style
433
-     *
434
-     * @access public
435
-     * @param  array    styles
436
-     */
437
-    public function getFormStyle()
438
-    {
439
-        $prop = array();
440
-
441
-        $prop['alignment'] = $this->value['text-align'];
442
-
443
-        if (isset($this->value['background']['color']) && is_array($this->value['background']['color'])) {
444
-            $prop['fillColor'] = $this->value['background']['color'];
445
-        }
446
-
447
-        if (isset($this->value['border']['t']['color'])) {
448
-            $prop['strokeColor'] = $this->value['border']['t']['color'];
449
-        }
450
-
451
-        if (isset($this->value['border']['t']['width'])) {
452
-            $prop['lineWidth'] = $this->value['border']['t']['width'];
453
-        }
454
-
455
-        if (isset($this->value['border']['t']['type'])) {
456
-            $prop['borderStyle'] = $this->value['border']['t']['type'];
457
-        }
458
-
459
-        if (!empty($this->value['color'])) {
460
-            $prop['textColor'] = $this->value['color'];
461
-        }
462
-
463
-        if (!empty($this->value['font-size'])) {
464
-            $prop['textSize'] = $this->value['font-size'];
465
-        }
466
-
467
-        return $prop;
468
-    }
469
-
470
-     /**
471
-     * Analise the CSS style to convert it into SVG style
472
-     *
473
-     * @access public
474
-     * @param  string   tag name
475
-     * @param  array    styles
476
-     */
477
-    public function getSvgStyle($tagName, &$param)
478
-    {
479
-        // prepare
480
-        $tagName = strtolower($tagName);
481
-        $id   = isset($param['id'])   ? strtolower(trim($param['id']))   : null; if (!$id)   $id   = null;
482
-        $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null;
483
-
484
-        // read the class attribute
485
-        $class = array();
486
-        $tmp = isset($param['class']) ? strtolower(trim($param['class'])) : '';
487
-        $tmp = explode(' ', $tmp);
488
-        foreach ($tmp as $k => $v) {
489
-            $v = trim($v);
490
-            if ($v) $class[] = $v;
491
-        }
492
-
493
-        // identify the tag, and the direct styles
494
-        $this->value['id_tag'] = $tagName;
495
-        $this->value['id_name']   = $name;
496
-        $this->value['id_id']     = $id;
497
-        $this->value['id_class']  = $class;
498
-        $this->value['id_lst']    = array();
499
-        $this->value['id_lst'][] = '*';
500
-        $this->value['id_lst'][] = $tagName;
501
-        if (!isset($this->value['svg'])) {
502
-            $this->value['svg'] = array(
503
-                'stroke'         => null,
504
-                'stroke-width'   => $this->convertToMM('1pt'),
505
-                'fill'           => null,
506
-                'fill-opacity'   => null,
507
-            );
508
-        }
509
-
510
-        if (count($class)) {
511
-            foreach ($class as $v) {
512
-                $this->value['id_lst'][] = '*.'.$v;
513
-                $this->value['id_lst'][] = '.'.$v;
514
-                $this->value['id_lst'][] = $tagName.'.'.$v;
515
-            }
516
-        }
517
-        if ($id) {
518
-            $this->value['id_lst'][] = '*#'.$id;
519
-            $this->value['id_lst'][] = '#'.$id;
520
-            $this->value['id_lst'][] = $tagName.'#'.$id;
521
-        }
522
-
523
-        // CSS style
524
-        $styles = $this->_getFromCSS();
525
-
526
-        // adding the style from the tag
527
-        $styles = array_merge($styles, $param['style']);
528
-
529
-        if (isset($styles['stroke']))        $this->value['svg']['stroke']       = $this->convertToColor($styles['stroke'], $res);
530
-        if (isset($styles['stroke-width']))  $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']);
531
-        if (isset($styles['fill']))          $this->value['svg']['fill']         = $this->convertToColor($styles['fill'], $res);
532
-        if (isset($styles['fill-opacity']))  $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity'];
533
-
534
-        return $this->value['svg'];
535
-    }
536
-
537
-    /**
538
-     * analyse the css properties from the HTML parsing
539
-     *
540
-     * @access public
541
-     * @param  string  $tagName
542
-     * @param  array   $param
543
-     * @param  array   $legacy
544
-     */
545
-    public function analyse($tagName, &$param, $legacy = null)
546
-    {
547
-        // prepare the informations
548
-        $tagName = strtolower($tagName);
549
-        $id   = isset($param['id'])   ? strtolower(trim($param['id']))    : null; if (!$id)   $id   = null;
550
-        $name = isset($param['name']) ? strtolower(trim($param['name']))  : null; if (!$name) $name = null;
551
-
552
-        // get the class names to use
553
-        $class = array();
554
-        $tmp = isset($param['class']) ? strtolower(trim($param['class'])) : '';
555
-        $tmp = explode(' ', $tmp);
556
-        foreach ($tmp as $k => $v) {
557
-            $v = trim($v);
558
-            if ($v) $class[] = $v;
559
-        }
560
-
561
-        // prepare the values, and the list of css tags to identify
562
-        $this->value['id_tag']   = $tagName;
563
-        $this->value['id_name']  = $name;
564
-        $this->value['id_id']    = $id;
565
-        $this->value['id_class'] = $class;
566
-        $this->value['id_lst']   = array();
567
-        $this->value['id_lst'][] = '*';
568
-        $this->value['id_lst'][] = $tagName;
569
-        if (count($class)) {
570
-            foreach ($class as $v) {
571
-                $this->value['id_lst'][] = '*.'.$v;
572
-                $this->value['id_lst'][] = '.'.$v;
573
-                $this->value['id_lst'][] = $tagName.'.'.$v;
574
-            }
575
-        }
576
-        if ($id) {
577
-            $this->value['id_lst'][] = '*#'.$id;
578
-            $this->value['id_lst'][] = '#'.$id;
579
-            $this->value['id_lst'][] = $tagName.'#'.$id;
580
-        }
581
-
582
-        // get the css styles from class
583
-        $styles = $this->_getFromCSS();
584
-
585
-        // merge with the css styles from tag
586
-        $styles = array_merge($styles, $param['style']);
587
-        if (isset($param['allwidth']) && !isset($styles['width'])) $styles['width'] = '100%';
588
-
589
-        // reset some styles, depending on the tag name
590
-        $this->resetStyle($tagName);
591
-
592
-        // add the legacy values
593
-        if ($legacy) {
594
-            foreach ($legacy as $legacyName => $legacyValue) {
595
-                if (is_array($legacyValue)) {
596
-                    foreach($legacyValue as $legacy2Name => $legacy2Value)
597
-                        $this->value[$legacyName][$legacy2Name] = $legacy2Value;
598
-                } else {
599
-                    $this->value[$legacyName] = $legacyValue;
600
-                }
601
-            }
602
-        }
603
-
604
-        // some flags
605
-        $correctWidth = false;
606
-        $noWidth = true;
607
-
608
-        // read all the css styles
609
-        foreach ($styles as $nom => $val) {
610
-            switch($nom)
611
-            {
612
-                case 'font-family':
613
-                    $val = explode(',', $val);
614
-                    $val = trim($val[0]);
615
-                    if ($val) $this->value['font-family'] = $val;
616
-                    break;
617
-
618
-                case 'font-weight':
619
-                    $this->value['font-bold'] = ($val=='bold');
620
-                    break;
621
-
622
-                case 'font-style':
623
-                    $this->value['font-italic'] = ($val=='italic');
624
-                    break;
625
-
626
-                case 'text-decoration':
627
-                    $val = explode(' ', $val);
628
-                    $this->value['font-underline']   = (in_array('underline', $val));
629
-                    $this->value['font-overline']    = (in_array('overline', $val));
630
-                    $this->value['font-linethrough'] = (in_array('line-through', $val));
631
-                    break;
632
-
633
-                case 'text-indent':
634
-                    $this->value['text-indent'] = $this->convertToMM($val);
635
-                    break;
636
-
637
-                case 'text-transform':
638
-                    if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none';
639
-                    $this->value['text-transform']  = $val;
640
-                    break;
641
-
642
-                case 'font-size':
643
-                    $val = $this->convertToMM($val, $this->value['font-size']);
644
-                    if ($val) $this->value['font-size'] = $val;
645
-                    break;
646
-
647
-                case 'color':
648
-                    $res = null;
649
-                    $this->value['color'] = $this->convertToColor($val, $res);
650
-                    if ($tagName=='hr') {
651
-                        $this->value['border']['l']['color'] = $this->value['color'];
652
-                        $this->value['border']['t']['color'] = $this->value['color'];
653
-                        $this->value['border']['r']['color'] = $this->value['color'];
654
-                        $this->value['border']['b']['color'] = $this->value['color'];
655
-                    }
656
-                    break;
657
-
658
-                case 'text-align':
659
-                    $val = strtolower($val);
660
-                    if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) $val = 'left';
661
-                    $this->value['text-align'] = $val;
662
-                    break;
663
-
664
-                case 'vertical-align':
665
-                    $this->value['vertical-align'] = $val;
666
-                    break;
667
-
668
-                case 'width':
669
-                    $this->value['width'] = $this->convertToMM($val, $this->getLastWidth());
670
-                    if ($this->value['width'] && substr($val, -1)=='%') $correctWidth=true;
671
-                    $noWidth = false;
672
-                    break;
673
-
674
-                case 'height':
675
-                    $this->value['height'] = $this->convertToMM($val, $this->getLastHeight());
676
-                    break;
677
-
678
-                case 'line-height':
679
-                    if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val*100).'%';
680
-                    $this->value['line-height'] = $val;
681
-                    break;
682
-
683
-                case 'rotate':
684
-                    if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null;
685
-                    if ($val<0) $val+= 360;
686
-                    $this->value['rotate'] = $val;
687
-                    break;
688
-
689
-                case 'overflow':
690
-                    if (!in_array($val, array('visible', 'hidden'))) $val = 'visible';
691
-                    $this->value['overflow'] = $val;
692
-                    break;
693
-
694
-                case 'padding':
695
-                    $val = explode(' ', $val);
696
-                    foreach ($val as $k => $v) {
697
-                        $v = trim($v);
698
-                        if ($v!='') {
699
-                            $val[$k] = $v;
700
-                        } else {
701
-                            unset($val[$k]);
702
-                        }
703
-                    }
704
-                    $val = array_values($val);
705
-                    $this->_duplicateBorder($val);
706
-                    $this->value['padding']['t'] = $this->convertToMM($val[0], 0);
707
-                    $this->value['padding']['r'] = $this->convertToMM($val[1], 0);
708
-                    $this->value['padding']['b'] = $this->convertToMM($val[2], 0);
709
-                    $this->value['padding']['l'] = $this->convertToMM($val[3], 0);
710
-                    break;
711
-
712
-                case 'padding-top':
713
-                    $this->value['padding']['t'] = $this->convertToMM($val, 0);
714
-                    break;
715
-
716
-                case 'padding-right':
717
-                    $this->value['padding']['r'] = $this->convertToMM($val, 0);
718
-                    break;
719
-
720
-                case 'padding-bottom':
721
-                    $this->value['padding']['b'] = $this->convertToMM($val, 0);
722
-                    break;
723
-
724
-                case 'padding-left':
725
-                    $this->value['padding']['l'] = $this->convertToMM($val, 0);
726
-                    break;
727
-
728
-                case 'margin':
729
-                    if ($val=='auto') {
730
-                        $this->value['margin-auto'] = true;
731
-                        break;
732
-                    }
733
-                    $val = explode(' ', $val);
734
-                    foreach ($val as $k => $v) {
735
-                        $v = trim($v);
736
-                        if ($v!='') {
737
-                            $val[$k] = $v;
738
-                        } else {
739
-                            unset($val[$k]);
740
-                        }
741
-                    }
742
-                    $val = array_values($val);
743
-                    $this->_duplicateBorder($val);
744
-                    $this->value['margin']['t'] = $this->convertToMM($val[0], 0);
745
-                    $this->value['margin']['r'] = $this->convertToMM($val[1], 0);
746
-                    $this->value['margin']['b'] = $this->convertToMM($val[2], 0);
747
-                    $this->value['margin']['l'] = $this->convertToMM($val[3], 0);
748
-                    break;
749
-
750
-                case 'margin-top':
751
-                    $this->value['margin']['t'] = $this->convertToMM($val, 0);
752
-                    break;
753
-
754
-                case 'margin-right':
755
-                    $this->value['margin']['r'] = $this->convertToMM($val, 0);
756
-                    break;
757
-
758
-                case 'margin-bottom':
759
-                    $this->value['margin']['b'] = $this->convertToMM($val, 0);
760
-                    break;
761
-
762
-                case 'margin-left':
763
-                    $this->value['margin']['l'] = $this->convertToMM($val, 0);
764
-                    break;
765
-
766
-                case 'border':
767
-                    $val = $this->readBorder($val);
768
-                    $this->value['border']['t'] = $val;
769
-                    $this->value['border']['r'] = $val;
770
-                    $this->value['border']['b'] = $val;
771
-                    $this->value['border']['l'] = $val;
772
-                    break;
773
-
774
-                case 'border-style':
775
-                    $val = explode(' ', $val);
776
-                    foreach ($val as $valK => $valV) {
777
-                        if (!in_array($valV, array('solid', 'dotted', 'dashed'))) {
778
-                            $val[$valK] = null;
779
-                        }
780
-                    }
781
-                    $this->_duplicateBorder($val);
782
-                    if ($val[0]) $this->value['border']['t']['type'] = $val[0];
783
-                    if ($val[1]) $this->value['border']['r']['type'] = $val[1];
784
-                    if ($val[2]) $this->value['border']['b']['type'] = $val[2];
785
-                    if ($val[3]) $this->value['border']['l']['type'] = $val[3];
786
-                    break;
787
-
788
-                case 'border-top-style':
789
-                    if (in_array($val, array('solid', 'dotted', 'dashed'))) {
790
-                        $this->value['border']['t']['type'] = $val;
791
-                    }
792
-                    break;
793
-
794
-                case 'border-right-style':
795
-                    if (in_array($val, array('solid', 'dotted', 'dashed'))) {
796
-                        $this->value['border']['r']['type'] = $val;
797
-                    }
798
-                    break;
799
-
800
-                case 'border-bottom-style':
801
-                    if (in_array($val, array('solid', 'dotted', 'dashed'))) {
802
-                        $this->value['border']['b']['type'] = $val;
803
-                    }
804
-                    break;
805
-
806
-                case 'border-left-style':
807
-                    if (in_array($val, array('solid', 'dotted', 'dashed')))
808
-                        $this->value['border']['l']['type'] = $val;
809
-                    break;
810
-
811
-                case 'border-color':
812
-                    $res = false;
813
-                    $val = preg_replace('/,[\s]+/', ',', $val);
814
-                    $val = explode(' ', $val);
815
-                    foreach ($val as $valK => $valV) {
816
-                            $val[$valK] = $this->convertToColor($valV, $res);
817
-                            if (!$res) {
818
-                                $val[$valK] = null;
819
-                            }
820
-                    }
821
-                    $this->_duplicateBorder($val);
822
-                    if (is_array($val[0])) $this->value['border']['t']['color'] = $val[0];
823
-                    if (is_array($val[1])) $this->value['border']['r']['color'] = $val[1];
824
-                    if (is_array($val[2])) $this->value['border']['b']['color'] = $val[2];
825
-                    if (is_array($val[3])) $this->value['border']['l']['color'] = $val[3];
826
-
827
-                    break;
828
-
829
-                case 'border-top-color':
830
-                    $res = false;
831
-                    $val = $this->convertToColor($val, $res);
832
-                    if ($res) $this->value['border']['t']['color'] = $val;
833
-                    break;
834
-
835
-                case 'border-right-color':
836
-                    $res = false;
837
-                    $val = $this->convertToColor($val, $res);
838
-                    if ($res) $this->value['border']['r']['color'] = $val;
839
-                    break;
840
-
841
-                case 'border-bottom-color':
842
-                    $res = false;
843
-                    $val = $this->convertToColor($val, $res);
844
-                    if ($res) $this->value['border']['b']['color'] = $val;
845
-                    break;
846
-
847
-                case 'border-left-color':
848
-                    $res = false;
849
-                    $val = $this->convertToColor($val, $res);
850
-                    if ($res) $this->value['border']['l']['color'] = $val;
851
-                    break;
852
-
853
-                case 'border-width':
854
-                    $val = explode(' ', $val);
855
-                    foreach ($val as $valK => $valV) {
856
-                            $val[$valK] = $this->convertToMM($valV, 0);
857
-                    }
858
-                    $this->_duplicateBorder($val);
859
-                    if ($val[0]) $this->value['border']['t']['width'] = $val[0];
860
-                    if ($val[1]) $this->value['border']['r']['width'] = $val[1];
861
-                    if ($val[2]) $this->value['border']['b']['width'] = $val[2];
862
-                    if ($val[3]) $this->value['border']['l']['width'] = $val[3];
863
-                    break;
864
-
865
-                case 'border-top-width':
866
-                    $val = $this->convertToMM($val, 0);
867
-                    if ($val) $this->value['border']['t']['width'] = $val;
868
-                    break;
869
-
870
-                case 'border-right-width':
871
-                    $val = $this->convertToMM($val, 0);
872
-                    if ($val) $this->value['border']['r']['width'] = $val;
873
-                    break;
874
-
875
-                case 'border-bottom-width':
876
-                    $val = $this->convertToMM($val, 0);
877
-                    if ($val) $this->value['border']['b']['width'] = $val;
878
-                    break;
879
-
880
-                case 'border-left-width':
881
-                    $val = $this->convertToMM($val, 0);
882
-                    if ($val) $this->value['border']['l']['width'] = $val;
883
-                    break;
884
-
885
-                case 'border-collapse':
886
-                    if ($tagName=='table') $this->value['border']['collapse'] = ($val=='collapse');
887
-                    break;
888
-
889
-                case 'border-radius':
890
-                    $val = explode('/', $val);
891
-                    if (count($val)>2) {
892
-                        break;
893
-                    }
894
-                    $valH = $this->convertToRadius(trim($val[0]));
895
-                    if (count($valH)<1 || count($valH)>4) {
896
-                        break;
897
-                    }
898
-                    if (!isset($valH[1])) $valH[1] = $valH[0];
899
-                    if (!isset($valH[2])) $valH = array($valH[0], $valH[0], $valH[1], $valH[1]);
900
-                    if (!isset($valH[3])) $valH[3] = $valH[1];
901
-                    if (isset($val[1])) {
902
-                        $valV = $this->convertToRadius(trim($val[1]));
903
-                        if (count($valV)<1 || count($valV)>4) {
904
-                            break;
905
-                        }
906
-                        if (!isset($valV[1])) $valV[1] = $valV[0];
907
-                        if (!isset($valV[2])) $valV = array($valV[0], $valV[0], $valV[1], $valV[1]);
908
-                        if (!isset($valV[3])) $valV[3] = $valV[1];
909
-                    } else {
910
-                        $valV = $valH;
911
-                    }
912
-                    $this->value['border']['radius'] = array(
913
-                                'tl' => array($valH[0], $valV[0]),
914
-                                'tr' => array($valH[1], $valV[1]),
915
-                                'br' => array($valH[2], $valV[2]),
916
-                                'bl' => array($valH[3], $valV[3])
917
-                            );
918
-                    break;
919
-
920
-                case 'border-top-left-radius':
921
-                    $val = $this->convertToRadius($val);
922
-                    if (count($val)<1 || count($val)>2) {
923
-                        break;
924
-                    }
925
-                    $this->value['border']['radius']['tl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
926
-                    break;
927
-
928
-                case 'border-top-right-radius':
929
-                    $val = $this->convertToRadius($val);
930
-                    if (count($val)<1 || count($val)>2) {
931
-                        break;
932
-                    }
933
-                    $this->value['border']['radius']['tr'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
934
-                    break;
935
-
936
-                case 'border-bottom-right-radius':
937
-                    $val = $this->convertToRadius($val);
938
-                    if (count($val)<1 || count($val)>2) {
939
-                        break;
940
-                    }
941
-                    $this->value['border']['radius']['br'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
942
-                    break;
943
-
944
-                case 'border-bottom-left-radius':
945
-                    $val = $this->convertToRadius($val);
946
-                    if (count($val)<1 || count($val)>2) {
947
-                        break;
948
-                    }
949
-                    $this->value['border']['radius']['bl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
950
-                    break;
951
-
952
-                case 'border-top':
953
-                    $this->value['border']['t'] = $this->readBorder($val);
954
-                    break;
955
-
956
-                case 'border-right':
957
-                    $this->value['border']['r'] = $this->readBorder($val);
958
-                    break;
959
-
960
-                case 'border-bottom':
961
-                    $this->value['border']['b'] = $this->readBorder($val);
962
-                    break;
963
-
964
-                case 'border-left':
965
-                    $this->value['border']['l'] = $this->readBorder($val);
966
-                    break;
967
-
968
-                case 'background-color':
969
-                    $this->value['background']['color'] = $this->convertBackgroundColor($val);
970
-                    break;
971
-
972
-                case 'background-image':
973
-                    $this->value['background']['image'] = $this->convertBackgroundImage($val);
974
-                    break;
975
-
976
-                case 'background-position':
977
-                    $res = null;
978
-                    $this->value['background']['position'] = $this->convertBackgroundPosition($val, $res);
979
-                    break;
980
-
981
-                case 'background-repeat':
982
-                    $this->value['background']['repeat'] = $this->convertBackgroundRepeat($val);
983
-                    break;
984
-
985
-                case 'background':
986
-                    $this->convertBackground($val, $this->value['background']);
987
-                    break;
988
-
989
-                case 'position':
990
-                    if ($val=='absolute')       $this->value['position'] = 'absolute';
991
-                    else if ($val=='relative')  $this->value['position'] = 'relative';
992
-                    else                        $this->value['position'] = null;
993
-                    break;
994
-
995
-                case 'float':
996
-                    if ($val=='left')           $this->value['float'] = 'left';
997
-                    else if ($val=='right')     $this->value['float'] = 'right';
998
-                    else                        $this->value['float'] = null;
999
-                    break;
1000
-
1001
-                case 'display':
1002
-                    if ($val=='inline')         $this->value['display'] = 'inline';
1003
-                    else if ($val=='block')     $this->value['display'] = 'block';
1004
-                    else if ($val=='none')      $this->value['display'] = 'none';
1005
-                    else                        $this->value['display'] = null;
1006
-                    break;
1007
-
1008
-                case 'top':
1009
-                case 'bottom':
1010
-                case 'left':
1011
-                case 'right':
1012
-                    $this->value[$nom] = $val;
1013
-                    break;
1014
-
1015
-                case 'list-style':
1016
-                case 'list-style-type':
1017
-                case 'list-style-image':
1018
-                    if ($nom=='list-style') $nom = 'list-style-type';
1019
-                    $this->value[$nom] = $val;
1020
-                    break;
1021
-
1022
-                default:
1023
-                    break;
1024
-            }
1025
-        }
1026
-
1027
-        $return = true;
1028
-
1029
-        // only for P tag
1030
-        if ($this->value['margin']['t']===null) $this->value['margin']['t'] = $this->value['font-size'];
1031
-        if ($this->value['margin']['b']===null) $this->value['margin']['b'] = $this->value['font-size'];
1032
-
1033
-        // force the text align to left, if asked by html2pdf
1034
-        if ($this->_onlyLeft) $this->value['text-align'] = 'left';
1035
-
1036
-        // correction on the width (quick box)
1037
-        if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position']!='absolute') {
1038
-            $this->value['width'] = $this->getLastWidth();
1039
-            $this->value['width']-= $this->value['margin']['l'] + $this->value['margin']['r'];
1040
-        } else {
1041
-            if ($correctWidth) {
1042
-                if (!in_array($tagName, array('table', 'div', 'blockquote', 'fieldset', 'hr'))) {
1043
-                    $this->value['width']-= $this->value['padding']['l'] + $this->value['padding']['r'];
1044
-                    $this->value['width']-= $this->value['border']['l']['width'] + $this->value['border']['r']['width'];
1045
-                }
1046
-                if (in_array($tagName, array('th', 'td'))) {
1047
-                    $this->value['width']-= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
1048
-                    $return = false;
1049
-                }
1050
-                if ($this->value['width']<0) $this->value['width']=0;
1051
-            } else {
1052
-                if ($this->value['width']) {
1053
-                    if ($this->value['border']['l']['width']) $this->value['width'] += $this->value['border']['l']['width'];
1054
-                    if ($this->value['border']['r']['width']) $this->value['width'] += $this->value['border']['r']['width'];
1055
-                    if ($this->value['padding']['l'])         $this->value['width'] += $this->value['padding']['l'];
1056
-                    if ($this->value['padding']['r'])         $this->value['width'] += $this->value['padding']['r'];
1057
-                }
1058
-            }
1059
-        }
1060
-        if ($this->value['height']) {
1061
-            if ($this->value['border']['b']['width']) $this->value['height'] += $this->value['border']['b']['width'];
1062
-            if ($this->value['border']['t']['width']) $this->value['height'] += $this->value['border']['t']['width'];
1063
-            if ($this->value['padding']['b'])         $this->value['height'] += $this->value['padding']['b'];
1064
-            if ($this->value['padding']['t'])         $this->value['height'] += $this->value['padding']['t'];
1065
-        }
1066
-
1067
-        if ($this->value['top']!=null)      $this->value['top']     = $this->convertToMM($this->value['top'], $this->getLastHeight(true));
1068
-        if ($this->value['bottom']!=null)   $this->value['bottom']  = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true));
1069
-        if ($this->value['left']!=null)     $this->value['left']    = $this->convertToMM($this->value['left'], $this->getLastWidth(true));
1070
-        if ($this->value['right']!=null)    $this->value['right']   = $this->convertToMM($this->value['right'], $this->getLastWidth(true));
1071
-
1072
-        if ($this->value['top'] && $this->value['bottom'] && $this->value['height'])    $this->value['bottom']  = null;
1073
-        if ($this->value['left'] && $this->value['right'] && $this->value['width'])     $this->value['right']   = null;
1074
-
1075
-        return $return;
1076
-    }
1077
-
1078
-     /**
1079
-     * get the height of the current line
1080
-     *
1081
-     * @access public
1082
-     * @return float $height in mm
1083
-     */
1084
-    public function getLineHeight()
1085
-    {
1086
-        $val = $this->value['line-height'];
1087
-        if ($val=='normal') $val = '108%';
1088
-        return $this->convertToMM($val, $this->value['font-size']);
1089
-    }
1090
-
1091
-     /**
1092
-     * get the width of the parent
1093
-     *
1094
-     * @access public
1095
-     * @param  boolean $mode true => adding padding and border
1096
-     * @return float $width in mm
1097
-     */
1098
-    public function getLastWidth($mode = false)
1099
-    {
1100
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1101
-            if ($this->table[$k]['width']) {
1102
-                $w = $this->table[$k]['width'];
1103
-                if ($mode) {
1104
-                    $w+= $this->table[$k]['border']['l']['width'] + $this->table[$k]['padding']['l'] + 0.02;
1105
-                    $w+= $this->table[$k]['border']['r']['width'] + $this->table[$k]['padding']['r'] + 0.02;
1106
-                }
1107
-                return $w;
1108
-            }
1109
-        }
1110
-        return $this->_pdf->getW() - $this->_pdf->getlMargin() - $this->_pdf->getrMargin();
1111
-    }
1112
-
1113
-     /**
1114
-     * get the height of the parent
1115
-     *
1116
-     * @access public
1117
-     * @param  boolean $mode true => adding padding and border
1118
-     * @return float $height in mm
1119
-     */
1120
-    public function getLastHeight($mode = false)
1121
-    {
1122
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1123
-            if ($this->table[$k]['height']) {
1124
-                $h = $this->table[$k]['height'];
1125
-                if ($mode) {
1126
-                    $h+= $this->table[$k]['border']['t']['width'] + $this->table[$k]['padding']['t'] + 0.02;
1127
-                    $h+= $this->table[$k]['border']['b']['width'] + $this->table[$k]['padding']['b'] + 0.02;
1128
-                }
1129
-                return $h;
1130
-            }
1131
-        }
1132
-        return $this->_pdf->getH() - $this->_pdf->gettMargin() - $this->_pdf->getbMargin();
1133
-    }
1134
-
1135
-    /**
1136
-     * get the value of the float property
1137
-     *
1138
-     * @access public
1139
-     * @return $float left/right
1140
-     */
1141
-    public function getFloat()
1142
-    {
1143
-        if ($this->value['float']=='left')    return 'left';
1144
-        if ($this->value['float']=='right')   return 'right';
1145
-        return null;
1146
-    }
1147
-
1148
-    /**
1149
-     * get the last value for a specific key
1150
-     *
1151
-     * @access public
1152
-     * @param  string $key
1153
-     * @return mixed
1154
-     */
1155
-    public function getLastValue($key)
1156
-    {
1157
-        $nb = count($this->table);
1158
-        if ($nb>0) {
1159
-            return $this->table[$nb-1][$key];
1160
-        } else {
1161
-            return null;
1162
-        }
1163
-    }
1164
-
1165
-    /**
1166
-     * get the last absolute X
1167
-     *
1168
-     * @access protected
1169
-     * @return float $x
1170
-     */
1171
-    protected function _getLastAbsoluteX()
1172
-    {
1173
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1174
-            if ($this->table[$k]['x'] && $this->table[$k]['position']) return $this->table[$k]['x'];
1175
-        }
1176
-        return $this->_pdf->getlMargin();
1177
-    }
1178
-
1179
-    /**
1180
-     * get the last absolute Y
1181
-     *
1182
-     * @access protected
1183
-     * @return float $y
1184
-     */
1185
-    protected function _getLastAbsoluteY()
1186
-    {
1187
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1188
-            if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y'];
1189
-        }
1190
-        return $this->_pdf->gettMargin();
1191
-    }
1192
-
1193
-    /**
1194
-     * get the CSS properties of the current tag
1195
-     *
1196
-     * @access protected
1197
-     * @return array $styles
1198
-     */
1199
-    protected function _getFromCSS()
1200
-    {
1201
-        // styles to apply
1202
-        $styles = array();
1203
-
1204
-        // list of the selectors to get in the CSS files
1205
-        $getit  = array();
1206
-
1207
-        // get the list of the selectors of each tags
1208
-        $lst = array();
1209
-        $lst[] = $this->value['id_lst'];
1210
-        for ($i=count($this->table)-1; $i>=0; $i--) {
1211
-            $lst[] = $this->table[$i]['id_lst'];
1212
-        }
1213
-
1214
-        // foreach selectors in the CSS files, verify if it match with the list of selectors
1215
-        foreach ($this->cssKeys as $key => $num) {
1216
-            if ($this->_getReccursiveStyle($key, $lst)) {
1217
-                $getit[$key] = $num;
1218
-            }
1219
-        }
1220
-
1221
-        // if we have selectors
1222
-        if (count($getit)) {
1223
-            // get them, but in the definition order, because of priority
1224
-            asort($getit);
1225
-            foreach ($getit as $key => $val) $styles = array_merge($styles, $this->css[$key]);
1226
-        }
1227
-
1228
-        return $styles;
1229
-    }
1230
-
1231
-    /**
1232
-     * identify if the selector $key match with the list of tag selectors
1233
-     *
1234
-     * @access protected
1235
-     * @param  string   $key CSS selector to analyse
1236
-     * @param  array    $lst list of the selectors of each tags
1237
-     * @param  string   $next next step of parsing the selector
1238
-     * @return boolean
1239
-     */
1240
-    protected function _getReccursiveStyle($key, $lst, $next = null)
1241
-    {
1242
-        // if next step
1243
-        if ($next!==null) {
1244
-            // we remove this step
1245
-            if ($next) $key = trim(substr($key, 0, -strlen($next)));
1246
-            array_shift($lst);
1247
-
1248
-            // if no more step to identify => return false
1249
-            if (!count($lst)) {
1250
-                return false;
1251
-            }
1252
-        }
1253
-
1254
-        // for each selector of the current step
1255
-        foreach ($lst[0] as $name) {
1256
-            // if selector = key => ok
1257
-            if ($key==$name) {
1258
-                return true;
1259
-            }
1260
-
1261
-            // if the end of the key = the selector and the next step is ok => ok
1262
-            if (substr($key, -strlen(' '.$name))==' '.$name && $this->_getReccursiveStyle($key, $lst, $name)) {
1263
-                return true;
1264
-            }
1265
-        }
1266
-
1267
-        // if we are not in the first step, we analyse the sub steps (the pareng tag of the current tag)
1268
-        if ($next!==null && $this->_getReccursiveStyle($key, $lst, '')) {
1269
-            return true;
1270
-        }
1271
-
1272
-        // no corresponding found
1273
-        return false;
1274
-    }
1275
-
1276
-    /**
1277
-     * Analyse a border
1278
-     *
1279
-     * @access  public
1280
-     * @param   string $css css border properties
1281
-     * @return  array  border properties
1282
-     */
1283
-    public function readBorder($css)
1284
-    {
1285
-        // border none
1286
-        $none = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0));
1287
-
1288
-        // default value
1289
-        $type  = 'solid';
1290
-        $width = $this->convertToMM('1pt');
1291
-        $color = array(0, 0, 0);
1292
-
1293
-        // clean up the values
1294
-        $css = explode(' ', $css);
1295
-        foreach ($css as $k => $v) {
1296
-            $v = trim($v);
1297
-            if ($v) $css[$k] = $v;
1298
-            else    unset($css[$k]);
1299
-        }
1300
-        $css = array_values($css);
1301
-
1302
-        // read the values
1303
-        $res = null;
1304
-        foreach ($css as $value) {
1305
-
1306
-            // if no border => return none
1307
-            if ($value=='none' || $value=='hidden') {
1308
-                return $none;
1309
-            }
1310
-
1311
-            // try to convert the value as a distance
1312
-            $tmp = $this->convertToMM($value);
1313
-
1314
-            // if the convert is ok => it is a width
1315
-            if ($tmp!==null) {
1316
-                $width = $tmp;
1317
-            // else, it could be the type
1318
-            } else if (in_array($value, array('solid', 'dotted', 'dashed', 'double'))) {
1319
-                $type = $value;
1320
-            // else, it could be the color
1321
-            } else {
1322
-                $tmp = $this->convertToColor($value, $res);
1323
-                if ($res) $color = $tmp;
1324
-            }
1325
-        }
1326
-
1327
-        // if no witdh => return none
1328
-        if (!$width) return $none;
1329
-
1330
-        // return the border properties
1331
-        return array('type' => $type, 'width' => $width, 'color' => $color);
1332
-    }
1333
-
1334
-    /**
1335
-     * duplicate the borders if needed
1336
-     *
1337
-     * @access protected
1338
-     * @param  &array $val
1339
-     */
1340
-    protected function _duplicateBorder(&$val)
1341
-    {
1342
-        // 1 value => L => RTB
1343
-        if (count($val)==1) {
1344
-            $val[1] = $val[0];
1345
-            $val[2] = $val[0];
1346
-            $val[3] = $val[0];
1347
-        // 2 values => L => R & T => B
1348
-        } else if (count($val)==2) {
1349
-            $val[2] = $val[0];
1350
-            $val[3] = $val[1];
1351
-        // 3 values => T => B
1352
-        } else if (count($val)==3) {
1353
-            $val[3] = $val[1];
1354
-        }
1355
-    }
1356
-
1357
-    /**
1358
-     * Analyse a background
1359
-     *
1360
-     * @access public
1361
-     * @param  string $css css background properties
1362
-     * @param  &array $value parsed values (by reference, because, ther is a legacy of the parent CSS properties)
1363
-     */
1364
-    public function convertBackground($css, &$value)
1365
-    {
1366
-        // is there a image ?
1367
-        $text = '/url\(([^)]*)\)/isU';
1368
-        if (preg_match($text, $css, $match)) {
1369
-            // get the image
1370
-            $value['image'] = $this->convertBackgroundImage($match[0]);
1371
-
1372
-            // remove if from the css properties
1373
-            $css = preg_replace($text, '', $css);
1374
-            $css = preg_replace('/[\s]+/', ' ', $css);
1375
-        }
1376
-
1377
-        // protect some spaces
1378
-        $css = preg_replace('/,[\s]+/', ',', $css);
1379
-
1380
-        // explode the values
1381
-        $css = explode(' ', $css);
1382
-
1383
-        // background position to parse
1384
-        $pos = '';
1385
-
1386
-        // foreach value
1387
-        foreach ($css as $val) {
1388
-            // try to parse the value as a color
1389
-            $ok = false;
1390
-            $color = $this->convertToColor($val, $ok);
1391
-
1392
-            // if ok => it is a color
1393
-            if ($ok) {
1394
-                $value['color'] = $color;
1395
-            // else if transparent => no coloàr
1396
-            } else if ($val=='transparent') {
1397
-                $value['color'] = null;
1398
-            // else
1399
-            } else {
1400
-                // try to parse the value as a repeat
1401
-                $repeat = $this->convertBackgroundRepeat($val);
1402
-
1403
-                // if ok => it is repeat
1404
-                if ($repeat) {
1405
-                    $value['repeat'] = $repeat;
1406
-                // else => it could only be a position
1407
-                } else {
1408
-                    $pos.= ($pos ? ' ' : '').$val;
1409
-                }
1410
-            }
1411
-        }
1412
-
1413
-        // if we have a position to parse
1414
-        if ($pos) {
1415
-            // try to read it
1416
-            $pos = $this->convertBackgroundPosition($pos, $ok);
1417
-            if ($ok) $value['position'] = $pos;
1418
-        }
1419
-    }
1420
-
1421
-    /**
1422
-     * parse a background color
1423
-     *
1424
-     * @access public
1425
-     * @param  string $css
1426
-     * @return string $value
1427
-     */
1428
-    public function convertBackgroundColor($css)
1429
-    {
1430
-        $res = null;
1431
-        if ($css=='transparent') return null;
1432
-        else                     return $this->convertToColor($css, $res);
1433
-    }
1434
-
1435
-    /**
1436
-     * parse a background image
1437
-     *
1438
-     * @access public
1439
-     * @param  string $css
1440
-     * @return string $value
1441
-     */
1442
-    public function convertBackgroundImage($css)
1443
-    {
1444
-        if ($css=='none')
1445
-            return null;
1446
-        else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match))
1447
-            return $match[1];
1448
-        else
1449
-            return null;
1450
-    }
1451
-
1452
-    /**
1453
-     * parse a background position
1454
-     *
1455
-     * @access public
1456
-     * @param  string $css
1457
-     * @param  &boolean $res flag if conver is ok or not
1458
-     * @return array ($x, $y)
1459
-     */
1460
-    public function convertBackgroundPosition($css, &$res)
1461
-    {
1462
-        // init the res
1463
-        $res = false;
1464
-
1465
-        // explode the value
1466
-        $css = explode(' ', $css);
1467
-
1468
-        // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2
1469
-        if (count($css)<2) {
1470
-            if (!$css[0]) return null;
1471
-            $css[1] = 'center';
1472
-        }
1473
-        if (count($css)>2) return null;
1474
-
1475
-        // prepare the values
1476
-        $x = 0;
1477
-        $y = 0;
1478
-        $res = true;
1479
-
1480
-        // convert the first value
1481
-        if ($css[0]=='left')        $x = '0%';
1482
-        else if ($css[0]=='center') $x = '50%';
1483
-        else if ($css[0]=='right')  $x = '100%';
1484
-        else if ($css[0]=='top')    $y = '0%';
1485
-        else if ($css[0]=='bottom') $y = '100%';
1486
-        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0];
1487
-        else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]);
1488
-        else $res = false;
1489
-
1490
-        // convert the second value
1491
-        if ($css[1]=='left')        $x = '0%';
1492
-        else if ($css[1]=='right')  $x = '100%';
1493
-        else if ($css[1]=='top')    $y = '0%';
1494
-        else if ($css[1]=='center') $y = '50%';
1495
-        else if ($css[1]=='bottom') $y = '100%';
1496
-        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1];
1497
-        else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]);
1498
-        else $res = false;
1499
-
1500
-        // return the values
1501
-        return array($x, $y);
1502
-    }
1503
-
1504
-    /**
1505
-     * parse a background repeat
1506
-     *
1507
-     * @access public
1508
-     * @param  string $css
1509
-     * @return string $value
1510
-     */
1511
-    public function convertBackgroundRepeat($css)
1512
-    {
1513
-        switch($css)
1514
-        {
1515
-            case 'repeat':
1516
-                return array(true, true);
1517
-            case 'repeat-x':
1518
-                return array(true, false);
1519
-            case 'repeat-y':
1520
-                return array(false, true);
1521
-            case 'no-repeat':
1522
-                return array(false, false);
1523
-        }
1524
-        return null;
1525
-    }
1526
-
1527
-     /**
1528
-     * convert a distance to mm
1529
-     *
1530
-     * @access public
1531
-     * @param  string $css distance to convert
1532
-     * @param  float  $old parent distance
1533
-     * @return float  $value
1534
-     */
1535
-    public function convertToMM($css, $old=0.)
1536
-    {
1537
-        $css = trim($css);
1538
-        if (preg_match('/^[0-9\.\-]+$/isU', $css))        $css.= 'px';
1539
-        if (preg_match('/^[0-9\.\-]+px$/isU', $css))      $css = 25.4/96. * str_replace('px', '', $css);
1540
-        else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css);
1541
-        else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css);
1542
-        else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css);
1543
-        else if (preg_match('/^[0-9\.\-]+%$/isU', $css))  $css = 1.*$old*str_replace('%', '', $css)/100.;
1544
-        else                                              $css = null;
1545
-
1546
-        return $css;
1547
-    }
1548
-
1549
-    /**
1550
-     * convert a css radius
1551
-     *
1552
-     * @access public
1553
-     * @param  string $css
1554
-     * @return float  $value
1555
-     */
1556
-    public function convertToRadius($css)
1557
-    {
1558
-        // explode the value
1559
-        $css = explode(' ', $css);
1560
-
1561
-        foreach ($css as $k => $v) {
1562
-            $v = trim($v);
1563
-            if ($v) {
1564
-                $v = $this->convertToMM($v, 0);
1565
-                if ($v!==null) {
1566
-                    $css[$k] = $v;
1567
-                } else {
1568
-                    unset($css[$k]);
1569
-                }
1570
-            } else {
1571
-                unset($css[$k]);
1572
-            }
1573
-        }
1574
-
1575
-        return array_values($css);
1576
-    }
1577
-
1578
-    /**
1579
-     * convert a css color
1580
-     *
1581
-     * @access public
1582
-     * @param  string $css
1583
-     * @param  &boolean $res
1584
-     * @return array (r,g, b)
1585
-     */
1586
-    public function convertToColor($css, &$res)
1587
-    {
1588
-        // prepare the value
1589
-        $css = trim($css);
1590
-        $res = true;
1591
-
1592
-        // if transparent => return null
1593
-        if (strtolower($css)=='transparent') return array(null, null, null);
1594
-
1595
-        // HTML color
1596
-        if (isset($this->_htmlColor[strtolower($css)])) {
1597
-            $css = $this->_htmlColor[strtolower($css)];
1598
-            $r = floatVal(hexdec(substr($css, 0, 2)));
1599
-            $v = floatVal(hexdec(substr($css, 2, 2)));
1600
-            $b = floatVal(hexdec(substr($css, 4, 2)));
1601
-            return array($r, $v, $b);
1602
-        }
1603
-
1604
-        // like #FFFFFF
1605
-        if (preg_match('/^#[0-9A-Fa-f]{6}$/isU', $css)) {
1606
-            $r = floatVal(hexdec(substr($css, 1, 2)));
1607
-            $v = floatVal(hexdec(substr($css, 3, 2)));
1608
-            $b = floatVal(hexdec(substr($css, 5, 2)));
1609
-            return array($r, $v, $b);
1610
-        }
1611
-
1612
-        // like #FFF
1613
-        if (preg_match('/^#[0-9A-F]{3}$/isU', $css)) {
1614
-            $r = floatVal(hexdec(substr($css, 1, 1).substr($css, 1, 1)));
1615
-            $v = floatVal(hexdec(substr($css, 2, 1).substr($css, 2, 1)));
1616
-            $b = floatVal(hexdec(substr($css, 3, 1).substr($css, 3, 1)));
1617
-            return array($r, $v, $b);
1618
-        }
1619
-
1620
-        // like rgb(100, 100, 100)
1621
-        if (preg_match('/rgb\([\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*\)/isU', $css, $match)) {
1622
-            $r = $this->_convertSubColor($match[1]);
1623
-            $v = $this->_convertSubColor($match[2]);
1624
-            $b = $this->_convertSubColor($match[3]);
1625
-            return array($r*255., $v*255., $b*255.);
1626
-        }
1627
-
1628
-        // like cmyk(100, 100, 100, 100)
1629
-        if (preg_match('/cmyk\([\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*\)/isU', $css, $match)) {
1630
-            $c = $this->_convertSubColor($match[1]);
1631
-            $m = $this->_convertSubColor($match[2]);
1632
-            $y = $this->_convertSubColor($match[3]);
1633
-            $k = $this->_convertSubColor($match[4]);
1634
-            return array($c*100., $m*100., $y*100., $k*100.);
1635
-        }
1636
-
1637
-        $res = false;
1638
-        return array(0., 0., 0.);
1639
-    }
1640
-
1641
-    /**
1642
-     * color value to convert
1643
-     *
1644
-     * @access protected
1645
-     * @param  string $c
1646
-     * @return float $c 0.->1.
1647
-     */
1648
-    protected function _convertSubColor($c)
1649
-    {
1650
-        if (substr($c, -1)=='%') {
1651
-            $c = floatVal(substr($c, 0, -1))/100.;
1652
-        } else {
1653
-            $c = floatVal($c);
1654
-            if ($c>1) $c = $c/255.;
1655
-        }
1656
-
1657
-        return $c;
1658
-    }
1659
-
1660
-    /**
1661
-     * read a css content
1662
-     *
1663
-     * @access protected
1664
-     * @param  &string $code
1665
-     */
1666
-    protected function _analyseStyle(&$code)
1667
-    {
1668
-        // clean the spaces
1669
-        $code = preg_replace('/[\s]+/', ' ', $code);
1670
-
1671
-        // remove the comments
1672
-        $code = preg_replace('/\/\*.*?\*\//s', '', $code);
1673
-
1674
-        // split each CSS code "selector { value }"
1675
-        preg_match_all('/([^{}]+){([^}]*)}/isU', $code, $match);
1676
-
1677
-        // for each CSS code
1678
-        for ($k=0; $k<count($match[0]); $k++) {
1679
-
1680
-            // selectors
1681
-            $names = strtolower(trim($match[1][$k]));
1682
-
1683
-            // css style
1684
-            $styles = trim($match[2][$k]);
1685
-
1686
-            // explode each value
1687
-            $styles = explode(';', $styles);
1688
-
1689
-            // parse each value
1690
-            $css = array();
1691
-            foreach ($styles as $style) {
1692
-                $tmp = explode(':', $style);
1693
-                if (count($tmp)>1) {
1694
-                    $cod = $tmp[0]; unset($tmp[0]); $tmp = implode(':', $tmp);
1695
-                    $css[trim(strtolower($cod))] = trim($tmp);
1696
-                }
1697
-            }
1698
-
1699
-            // explode the names
1700
-            $names = explode(',', $names);
1701
-
1702
-            // save the values for each names
1703
-            foreach ($names as $name) {
1704
-                // clean the name
1705
-                $name = trim($name);
1706
-
1707
-                // if a selector with somethink lige :hover => continue
1708
-                if (strpos($name, ':')!==false) continue;
1709
-
1710
-                // save the value
1711
-                if (!isset($this->css[$name]))
1712
-                    $this->css[$name] = $css;
1713
-                else
1714
-                    $this->css[$name] = array_merge($this->css[$name], $css);
1715
-
1716
-            }
1717
-        }
1718
-
1719
-        // get he list of the keys
1720
-        $this->cssKeys = array_flip(array_keys($this->css));
1721
-    }
1722
-
1723
-    /**
1724
-     * Extract the css files from a html code
1725
-     *
1726
-     * @access public
1727
-     * @param  string   &$html
1728
-     */
1729
-    public function readStyle(&$html)
1730
-    {
1731
-        // the CSS content
1732
-        $style = ' ';
1733
-
1734
-        // extract the link tags, and remove them in the html code
1735
-        preg_match_all('/<link([^>]*)>/isU', $html, $match);
1736
-        $html = preg_replace('/<link[^>]*>/isU', '', $html);
1737
-        $html = preg_replace('/<\/link[^>]*>/isU', '', $html);
1738
-
1739
-        // analyse each link tag
1740
-        foreach ($match[1] as $code) {
1741
-            $tmp = array();
1742
-
1743
-            // read the attributes name=value
1744
-            $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
1745
-            preg_match_all('/'.$prop.'/is', $code, $match);
1746
-            for ($k=0; $k<count($match[0]); $k++) {
1747
-                $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1748
-            }
1749
-
1750
-            // read the attributes name="value"
1751
-            $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
1752
-            preg_match_all('/'.$prop.'/is', $code, $match);
1753
-            for ($k=0; $k<count($match[0]); $k++) {
1754
-                $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1755
-            }
1756
-
1757
-            // read the attributes name='value'
1758
-            $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
1759
-            preg_match_all('/'.$prop.'/is', $code, $match);
1760
-            for ($k=0; $k<count($match[0]); $k++) {
1761
-                $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1762
-            }
1763
-
1764
-            // if type text/css => we keep it
1765
-            if (isset($tmp['type']) && strtolower($tmp['type'])=='text/css' && isset($tmp['href'])) {
1766
-
1767
-                // get the href
1768
-                $url = $tmp['href'];
1769
-
1770
-                // get the content of the css file
1771
-                $content = @file_get_contents($url);
1772
-
1773
-                // if "http://" in the url
1774
-                if (strpos($url, 'http://')!==false) {
1775
-
1776
-                    // get the domain "http://xxx/"
1777
-                    $url = str_replace('http://', '', $url);
1778
-                    $url = explode('/', $url);
1779
-                    $urlMain = 'http://'.$url[0].'/';
1780
-
1781
-                    // get the absolute url of the path
1782
-                    $urlSelf = $url; unset($urlSelf[count($urlSelf)-1]); $urlSelf = 'http://'.implode('/', $urlSelf).'/';
1783
-
1784
-                    // adapt the url in the css content
1785
-                    $content = preg_replace('/url\(([^\\\\][^)]*)\)/isU', 'url('.$urlSelf.'$1)', $content);
1786
-                    $content = preg_replace('/url\((\\\\[^)]*)\)/isU', 'url('.$urlMain.'$1)', $content);
1787
-                } else {
14
+	/**
15
+	 * reference to the pdf object
16
+	 * @var TCPDF
17
+	 */
18
+	protected $_pdf         = null;
19
+
20
+	protected $_htmlColor   = array(); // list of the HTML colors
21
+	protected $_onlyLeft    = false;   // flag if we are in a sub html => only "text-align:left" is used
22
+	protected $_defaultFont = null;    // default font to use if the asked font does not exist
23
+
24
+	public    $value        = array(); // current values
25
+	public    $css          = array(); // css values
26
+	public    $cssKeys      = array(); // css key, for the execution order
27
+	public    $table        = array(); // level history
28
+
29
+	/**
30
+	 * Constructor
31
+	 *
32
+	 * @param  &HTML2PDF_myPdf reference to the PDF $object
33
+	 * @access public
34
+	 */
35
+	public function __construct(&$pdf)
36
+	{
37
+		$this->_init();
38
+		$this->setPdfParent($pdf);
39
+	}
40
+
41
+	/**
42
+	 * Set the HTML2PDF parent object
43
+	 *
44
+	 * @param  &HTML2PDF reference to the HTML2PDF parent $object
45
+	 * @access public
46
+	 */
47
+	public function setPdfParent(&$pdf)
48
+	{
49
+		$this->_pdf = &$pdf;
50
+	}
51
+
52
+	/**
53
+	 * Inform that we want only "test-align:left" because we are in a sub HTML
54
+	 *
55
+	 * @access public
56
+	 */
57
+	public function setOnlyLeft()
58
+	{
59
+		$this->value['text-align'] = 'left';
60
+		$this->_onlyLeft = true;
61
+	}
62
+
63
+	/**
64
+	 * Get the vales of the parent, if exist
65
+	 *
66
+	 * @return array CSS values
67
+	 * @access public
68
+	 */
69
+	public function getOldValues()
70
+	{
71
+		return isset($this->table[count($this->table)-1]) ? $this->table[count($this->table)-1] : $this->value;
72
+	}
73
+
74
+	/**
75
+	 * define the Default Font to use, if the font does not exist, or if no font asked
76
+	 *
77
+	 * @param  string  default font-family. If null : Arial for no font asked, and error fot ont does not exist
78
+	 * @return string  old default font-family
79
+	 * @access public
80
+	 */
81
+	public function setDefaultFont($default = null)
82
+	{
83
+		$old = $this->_defaultFont;
84
+		$this->_defaultFont = $default;
85
+		if ($default) $this->value['font-family'] = $default;
86
+		return $old;
87
+	}
88
+
89
+	 /**
90
+	  * Init the object
91
+	  *
92
+	  * @access protected
93
+	  */
94
+	protected function _init()
95
+	{
96
+		// get the Web Colors from TCPDF
97
+		require(K_PATH_MAIN.'htmlcolors.php');
98
+		$this->_htmlColor = $webcolor;
99
+
100
+		// init the Style
101
+		$this->table = array();
102
+		$this->value = array();
103
+		$this->initStyle();
104
+
105
+		// Init the styles without legacy
106
+		$this->resetStyle();
107
+	}
108
+
109
+	/**
110
+	 * Init the CSS Style
111
+	 *
112
+	 * @access public
113
+	 */
114
+	public function initStyle()
115
+	{
116
+		$this->value['id_tag']       = 'body';        // tag name
117
+		$this->value['id_name']          = null;         // tag - attribute name
118
+		$this->value['id_id']            = null;         // tag - attribute id
119
+		$this->value['id_class']         = null;         // tag - attribute class
120
+		$this->value['id_lst']           = array('*');   // tag - list of legacy
121
+		$this->value['mini-size']        = 1.;           // specific size report for sup, sub
122
+		$this->value['mini-decal']       = 0;            // specific position report for sup, sub
123
+		$this->value['font-family']      = 'Arial';
124
+		$this->value['font-bold']        = false;
125
+		$this->value['font-italic']      = false;
126
+		$this->value['font-underline']   = false;
127
+		$this->value['font-overline']    = false;
128
+		$this->value['font-linethrough'] = false;
129
+		$this->value['text-transform']   = 'none';
130
+		$this->value['font-size']        = $this->convertToMM('10pt');
131
+		$this->value['text-indent']      = 0;
132
+		$this->value['text-align']       = 'left';
133
+		$this->value['vertical-align']   = 'middle';
134
+		$this->value['line-height']      = 'normal';
135
+
136
+		$this->value['position']         = null;
137
+		$this->value['x']                = null;
138
+		$this->value['y']                = null;
139
+		$this->value['width']            = 0;
140
+		$this->value['height']           = 0;
141
+		$this->value['top']              = null;
142
+		$this->value['right']            = null;
143
+		$this->value['bottom']           = null;
144
+		$this->value['left']             = null;
145
+		$this->value['float']            = null;
146
+		$this->value['display']          = null;
147
+		$this->value['rotate']           = null;
148
+		$this->value['overflow']         = 'visible';
149
+
150
+		$this->value['color']            = array(0, 0, 0);
151
+		$this->value['background']       = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null);
152
+		$this->value['border']           = array();
153
+		$this->value['padding']          = array();
154
+		$this->value['margin']           = array();
155
+		$this->value['margin-auto']      = false;
156
+
157
+		$this->value['list-style-type']  = '';
158
+		$this->value['list-style-image'] = '';
159
+
160
+		$this->value['xc'] = null;
161
+		$this->value['yc'] = null;
162
+	}
163
+
164
+	/**
165
+	 * Init the CSS Style without legacy
166
+	 *
167
+	 * @param  string  tag name
168
+	 * @access public
169
+	 */
170
+	public function resetStyle($tagName = '')
171
+	{
172
+		// prepare somme values
173
+		$border = $this->readBorder('solid 1px #000000');
174
+		$units = array(
175
+			'1px' => $this->convertToMM('1px'),
176
+			'5px' => $this->convertToMM('5px'),
177
+		);
178
+
179
+
180
+		// prepare the Collapse attribute
181
+		$collapse = isset($this->value['border']['collapse']) ? $this->value['border']['collapse'] : false;
182
+		if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) $collapse = false;
183
+
184
+		// set the global css values
185
+		$this->value['position']   = null;
186
+		$this->value['x']          = null;
187
+		$this->value['y']          = null;
188
+		$this->value['width']      = 0;
189
+		$this->value['height']     = 0;
190
+		$this->value['top']        = null;
191
+		$this->value['right']      = null;
192
+		$this->value['bottom']     = null;
193
+		$this->value['left']       = null;
194
+		$this->value['float']      = null;
195
+		$this->value['display']    = null;
196
+		$this->value['rotate']     = null;
197
+		$this->value['overflow']   = 'visible';
198
+		$this->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null);
199
+		$this->value['border']     = array(
200
+			't' => $this->readBorder('none'),
201
+			'r' => $this->readBorder('none'),
202
+			'b' => $this->readBorder('none'),
203
+			'l' => $this->readBorder('none'),
204
+			'radius' => array(
205
+				'tl' => array(0, 0),
206
+				'tr' => array(0, 0),
207
+				'br' => array(0, 0),
208
+				'bl' => array(0, 0)
209
+			),
210
+			'collapse' => $collapse,
211
+		);
212
+
213
+		// specific values for some tags
214
+		if (!in_array($tagName, array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) {
215
+			$this->value['margin'] = array('t'=>0,'r'=>0,'b'=>0,'l'=>0);
216
+		}
217
+
218
+		if (in_array($tagName, array('input', 'select', 'textarea'))) {
219
+			$this->value['border']['t'] = null;
220
+			$this->value['border']['r'] = null;
221
+			$this->value['border']['b'] = null;
222
+			$this->value['border']['l'] = null;
223
+		}
224
+
225
+		if ($tagName=='p') {
226
+			$this->value['margin']['t'] = null;
227
+			$this->value['margin']['b'] = null;
228
+		}
229
+		if ($tagName=='blockquote') {
230
+			$this->value['margin']['t'] = 3;
231
+			$this->value['margin']['r'] = 3;
232
+			$this->value['margin']['b'] = 3;
233
+			$this->value['margin']['l'] = 6;
234
+		}
235
+		$this->value['margin-auto'] = false;
236
+
237
+		if (in_array($tagName, array('blockquote', 'div', 'fieldset'))) {
238
+			$this->value['vertical-align'] = 'top';
239
+		}
240
+
241
+		if (in_array($tagName, array('fieldset', 'legend'))) {
242
+			$this->value['border'] = array(
243
+				't' => $border,
244
+				'r' => $border,
245
+				'b' => $border,
246
+				'l' => $border,
247
+				'radius' => array(
248
+					'tl' => array($units['5px'], $units['5px']),
249
+					'tr' => array($units['5px'], $units['5px']),
250
+					'br' => array($units['5px'], $units['5px']),
251
+					'bl' => array($units['5px'], $units['5px'])
252
+				),
253
+				'collapse' => false,
254
+			);
255
+		}
256
+
257
+		if (in_array($tagName, array('ul', 'li'))) {
258
+			$this->value['list-style-type']  = '';
259
+			$this->value['list-style-image'] = '';
260
+		}
261
+
262
+		if (!in_array($tagName, array('tr', 'td'))) {
263
+			$this->value['padding'] = array(
264
+				't' => 0,
265
+				'r' => 0,
266
+				'b' => 0,
267
+				'l' => 0
268
+			);
269
+		} else {
270
+			$this->value['padding'] = array(
271
+				't' => $units['1px'],
272
+				'r' => $units['1px'],
273
+				'b' => $units['1px'],
274
+				'l' => $units['1px']
275
+			);
276
+		}
277
+
278
+		if ($tagName=='hr') {
279
+			$this->value['border'] = array(
280
+				't' => $border,
281
+				'r' => $border,
282
+				'b' => $border,
283
+				'l' => $border,
284
+				'radius' => array(
285
+					'tl' => array(0, 0),
286
+					'tr' => array(0, 0),
287
+					'br' => array(0, 0),
288
+					'bl' => array(0, 0)
289
+				),
290
+				'collapse' => false,
291
+			);
292
+			$this->convertBackground('#FFFFFF', $this->value['background']);
293
+		}
294
+
295
+		$this->value['xc'] = null;
296
+		$this->value['yc'] = null;
297
+	}
298
+
299
+	/**
300
+	 * Init the PDF Font
301
+	 *
302
+	 * @access public
303
+	 */
304
+	public function fontSet()
305
+	{
306
+		$family = strtolower($this->value['font-family']);
307
+
308
+		$b = ($this->value['font-bold']        ? 'B' : '');
309
+		$i = ($this->value['font-italic']      ? 'I' : '');
310
+		$u = ($this->value['font-underline']   ? 'U' : '');
311
+		$d = ($this->value['font-linethrough'] ? 'D' : '');
312
+		$o = ($this->value['font-overline']    ? 'O' : '');
313
+
314
+		// font style
315
+		$style = $b.$i;
316
+
317
+		if ($this->_defaultFont) {
318
+			if($family=='arial')
319
+				$family='helvetica';
320
+			elseif($family=='symbol' || $family=='zapfdingbats')
321
+				$style='';
322
+
323
+			$fontkey = $family.$style;
324
+			if (!$this->_pdf->isLoadedFont($fontkey))
325
+				$family = $this->_defaultFont;
326
+		}
327
+
328
+		if($family=='arial')
329
+			$family='helvetica';
330
+		elseif($family=='symbol' || $family=='zapfdingbats')
331
+			$style='';
332
+
333
+		// complete style
334
+		$style.= $u.$d.$o;
335
+
336
+		// size : mm => pt
337
+		$size = $this->value['font-size'];
338
+		$size = 72 * $size / 25.4;
339
+
340
+		// apply the font
341
+		$this->_pdf->SetFont($family, $style, $this->value['mini-size']*$size);
342
+		$this->_pdf->setTextColorArray($this->value['color']);
343
+		if ($this->value['background']['color'])
344
+			$this->_pdf->setFillColorArray($this->value['background']['color']);
345
+		else
346
+			$this->_pdf->setFillColor(255);
347
+	}
348
+
349
+	 /**
350
+	  * add a level in the CSS history
351
+	  *
352
+	  * @access public
353
+	  */
354
+	public function save()
355
+	{
356
+		array_push($this->table, $this->value);
357
+	}
358
+
359
+	 /**
360
+	  * remove a level in the CSS history
361
+	  *
362
+	  * @access public
363
+	  */
364
+	public function load()
365
+	{
366
+		if (count($this->table)) {
367
+			$this->value = array_pop($this->table);
368
+		}
369
+	}
370
+
371
+	 /**
372
+	  * restore the Y positiony (used after a span)
373
+	  *
374
+	  * @access public
375
+	  */
376
+	public function restorePosition()
377
+	{
378
+		if ($this->value['y']==$this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false);
379
+	}
380
+
381
+	 /**
382
+	  * set the New position for the current Tag
383
+	  *
384
+	  * @access public
385
+	  */
386
+	public function setPosition()
387
+	{
388
+		// get the current position
389
+		$currentX = $this->_pdf->getX();
390
+		$currentY = $this->_pdf->getY();
391
+
392
+		// save it
393
+		$this->value['xc'] = $currentX;
394
+		$this->value['yc'] = $currentY;
395
+
396
+		if ($this->value['position']=='relative' || $this->value['position']=='absolute') {
397
+			if ($this->value['right']!==null) {
398
+				$x = $this->getLastWidth(true) - $this->value['right'] - $this->value['width'];
399
+				if ($this->value['margin']['r']) $x-= $this->value['margin']['r'];
400
+			} else {
401
+				$x = $this->value['left'];
402
+				if ($this->value['margin']['l']) $x+= $this->value['margin']['l'];
403
+			}
404
+
405
+			if ($this->value['bottom']!==null) {
406
+				$y = $this->getLastHeight(true) - $this->value['bottom'] - $this->value['height'];
407
+				if ($this->value['margin']['b']) $y-= $this->value['margin']['b'];
408
+			} else {
409
+				$y = $this->value['top'];
410
+				if ($this->value['margin']['t']) $y+= $this->value['margin']['t'];
411
+			}
412
+
413
+			if ($this->value['position']=='relative') {
414
+				$this->value['x'] = $currentX + $x;
415
+				$this->value['y'] = $currentY + $y;
416
+			} else {
417
+				$this->value['x'] = $this->_getLastAbsoluteX()+$x;
418
+				$this->value['y'] = $this->_getLastAbsoluteY()+$y;
419
+			}
420
+		} else {
421
+			$this->value['x'] = $currentX;
422
+			$this->value['y'] = $currentY;
423
+			if ($this->value['margin']['l']) $this->value['x']+= $this->value['margin']['l'];
424
+			if ($this->value['margin']['t']) $this->value['y']+= $this->value['margin']['t'];
425
+		}
426
+
427
+		// save the new position
428
+		$this->_pdf->setXY($this->value['x'], $this->value['y']);
429
+	}
430
+
431
+	 /**
432
+	  * Analise the CSS style to convert it into Form style
433
+	  *
434
+	  * @access public
435
+	  * @param  array    styles
436
+	  */
437
+	public function getFormStyle()
438
+	{
439
+		$prop = array();
440
+
441
+		$prop['alignment'] = $this->value['text-align'];
442
+
443
+		if (isset($this->value['background']['color']) && is_array($this->value['background']['color'])) {
444
+			$prop['fillColor'] = $this->value['background']['color'];
445
+		}
446
+
447
+		if (isset($this->value['border']['t']['color'])) {
448
+			$prop['strokeColor'] = $this->value['border']['t']['color'];
449
+		}
450
+
451
+		if (isset($this->value['border']['t']['width'])) {
452
+			$prop['lineWidth'] = $this->value['border']['t']['width'];
453
+		}
454
+
455
+		if (isset($this->value['border']['t']['type'])) {
456
+			$prop['borderStyle'] = $this->value['border']['t']['type'];
457
+		}
458
+
459
+		if (!empty($this->value['color'])) {
460
+			$prop['textColor'] = $this->value['color'];
461
+		}
462
+
463
+		if (!empty($this->value['font-size'])) {
464
+			$prop['textSize'] = $this->value['font-size'];
465
+		}
466
+
467
+		return $prop;
468
+	}
469
+
470
+	 /**
471
+	  * Analise the CSS style to convert it into SVG style
472
+	  *
473
+	  * @access public
474
+	  * @param  string   tag name
475
+	  * @param  array    styles
476
+	  */
477
+	public function getSvgStyle($tagName, &$param)
478
+	{
479
+		// prepare
480
+		$tagName = strtolower($tagName);
481
+		$id   = isset($param['id'])   ? strtolower(trim($param['id']))   : null; if (!$id)   $id   = null;
482
+		$name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null;
483
+
484
+		// read the class attribute
485
+		$class = array();
486
+		$tmp = isset($param['class']) ? strtolower(trim($param['class'])) : '';
487
+		$tmp = explode(' ', $tmp);
488
+		foreach ($tmp as $k => $v) {
489
+			$v = trim($v);
490
+			if ($v) $class[] = $v;
491
+		}
492
+
493
+		// identify the tag, and the direct styles
494
+		$this->value['id_tag'] = $tagName;
495
+		$this->value['id_name']   = $name;
496
+		$this->value['id_id']     = $id;
497
+		$this->value['id_class']  = $class;
498
+		$this->value['id_lst']    = array();
499
+		$this->value['id_lst'][] = '*';
500
+		$this->value['id_lst'][] = $tagName;
501
+		if (!isset($this->value['svg'])) {
502
+			$this->value['svg'] = array(
503
+				'stroke'         => null,
504
+				'stroke-width'   => $this->convertToMM('1pt'),
505
+				'fill'           => null,
506
+				'fill-opacity'   => null,
507
+			);
508
+		}
509
+
510
+		if (count($class)) {
511
+			foreach ($class as $v) {
512
+				$this->value['id_lst'][] = '*.'.$v;
513
+				$this->value['id_lst'][] = '.'.$v;
514
+				$this->value['id_lst'][] = $tagName.'.'.$v;
515
+			}
516
+		}
517
+		if ($id) {
518
+			$this->value['id_lst'][] = '*#'.$id;
519
+			$this->value['id_lst'][] = '#'.$id;
520
+			$this->value['id_lst'][] = $tagName.'#'.$id;
521
+		}
522
+
523
+		// CSS style
524
+		$styles = $this->_getFromCSS();
525
+
526
+		// adding the style from the tag
527
+		$styles = array_merge($styles, $param['style']);
528
+
529
+		if (isset($styles['stroke']))        $this->value['svg']['stroke']       = $this->convertToColor($styles['stroke'], $res);
530
+		if (isset($styles['stroke-width']))  $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']);
531
+		if (isset($styles['fill']))          $this->value['svg']['fill']         = $this->convertToColor($styles['fill'], $res);
532
+		if (isset($styles['fill-opacity']))  $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity'];
533
+
534
+		return $this->value['svg'];
535
+	}
536
+
537
+	/**
538
+	 * analyse the css properties from the HTML parsing
539
+	 *
540
+	 * @access public
541
+	 * @param  string  $tagName
542
+	 * @param  array   $param
543
+	 * @param  array   $legacy
544
+	 */
545
+	public function analyse($tagName, &$param, $legacy = null)
546
+	{
547
+		// prepare the informations
548
+		$tagName = strtolower($tagName);
549
+		$id   = isset($param['id'])   ? strtolower(trim($param['id']))    : null; if (!$id)   $id   = null;
550
+		$name = isset($param['name']) ? strtolower(trim($param['name']))  : null; if (!$name) $name = null;
551
+
552
+		// get the class names to use
553
+		$class = array();
554
+		$tmp = isset($param['class']) ? strtolower(trim($param['class'])) : '';
555
+		$tmp = explode(' ', $tmp);
556
+		foreach ($tmp as $k => $v) {
557
+			$v = trim($v);
558
+			if ($v) $class[] = $v;
559
+		}
560
+
561
+		// prepare the values, and the list of css tags to identify
562
+		$this->value['id_tag']   = $tagName;
563
+		$this->value['id_name']  = $name;
564
+		$this->value['id_id']    = $id;
565
+		$this->value['id_class'] = $class;
566
+		$this->value['id_lst']   = array();
567
+		$this->value['id_lst'][] = '*';
568
+		$this->value['id_lst'][] = $tagName;
569
+		if (count($class)) {
570
+			foreach ($class as $v) {
571
+				$this->value['id_lst'][] = '*.'.$v;
572
+				$this->value['id_lst'][] = '.'.$v;
573
+				$this->value['id_lst'][] = $tagName.'.'.$v;
574
+			}
575
+		}
576
+		if ($id) {
577
+			$this->value['id_lst'][] = '*#'.$id;
578
+			$this->value['id_lst'][] = '#'.$id;
579
+			$this->value['id_lst'][] = $tagName.'#'.$id;
580
+		}
581
+
582
+		// get the css styles from class
583
+		$styles = $this->_getFromCSS();
584
+
585
+		// merge with the css styles from tag
586
+		$styles = array_merge($styles, $param['style']);
587
+		if (isset($param['allwidth']) && !isset($styles['width'])) $styles['width'] = '100%';
588
+
589
+		// reset some styles, depending on the tag name
590
+		$this->resetStyle($tagName);
591
+
592
+		// add the legacy values
593
+		if ($legacy) {
594
+			foreach ($legacy as $legacyName => $legacyValue) {
595
+				if (is_array($legacyValue)) {
596
+					foreach($legacyValue as $legacy2Name => $legacy2Value)
597
+						$this->value[$legacyName][$legacy2Name] = $legacy2Value;
598
+				} else {
599
+					$this->value[$legacyName] = $legacyValue;
600
+				}
601
+			}
602
+		}
603
+
604
+		// some flags
605
+		$correctWidth = false;
606
+		$noWidth = true;
607
+
608
+		// read all the css styles
609
+		foreach ($styles as $nom => $val) {
610
+			switch($nom)
611
+			{
612
+				case 'font-family':
613
+					$val = explode(',', $val);
614
+					$val = trim($val[0]);
615
+					if ($val) $this->value['font-family'] = $val;
616
+					break;
617
+
618
+				case 'font-weight':
619
+					$this->value['font-bold'] = ($val=='bold');
620
+					break;
621
+
622
+				case 'font-style':
623
+					$this->value['font-italic'] = ($val=='italic');
624
+					break;
625
+
626
+				case 'text-decoration':
627
+					$val = explode(' ', $val);
628
+					$this->value['font-underline']   = (in_array('underline', $val));
629
+					$this->value['font-overline']    = (in_array('overline', $val));
630
+					$this->value['font-linethrough'] = (in_array('line-through', $val));
631
+					break;
632
+
633
+				case 'text-indent':
634
+					$this->value['text-indent'] = $this->convertToMM($val);
635
+					break;
636
+
637
+				case 'text-transform':
638
+					if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none';
639
+					$this->value['text-transform']  = $val;
640
+					break;
641
+
642
+				case 'font-size':
643
+					$val = $this->convertToMM($val, $this->value['font-size']);
644
+					if ($val) $this->value['font-size'] = $val;
645
+					break;
646
+
647
+				case 'color':
648
+					$res = null;
649
+					$this->value['color'] = $this->convertToColor($val, $res);
650
+					if ($tagName=='hr') {
651
+						$this->value['border']['l']['color'] = $this->value['color'];
652
+						$this->value['border']['t']['color'] = $this->value['color'];
653
+						$this->value['border']['r']['color'] = $this->value['color'];
654
+						$this->value['border']['b']['color'] = $this->value['color'];
655
+					}
656
+					break;
657
+
658
+				case 'text-align':
659
+					$val = strtolower($val);
660
+					if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) $val = 'left';
661
+					$this->value['text-align'] = $val;
662
+					break;
663
+
664
+				case 'vertical-align':
665
+					$this->value['vertical-align'] = $val;
666
+					break;
667
+
668
+				case 'width':
669
+					$this->value['width'] = $this->convertToMM($val, $this->getLastWidth());
670
+					if ($this->value['width'] && substr($val, -1)=='%') $correctWidth=true;
671
+					$noWidth = false;
672
+					break;
673
+
674
+				case 'height':
675
+					$this->value['height'] = $this->convertToMM($val, $this->getLastHeight());
676
+					break;
677
+
678
+				case 'line-height':
679
+					if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val*100).'%';
680
+					$this->value['line-height'] = $val;
681
+					break;
682
+
683
+				case 'rotate':
684
+					if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null;
685
+					if ($val<0) $val+= 360;
686
+					$this->value['rotate'] = $val;
687
+					break;
688
+
689
+				case 'overflow':
690
+					if (!in_array($val, array('visible', 'hidden'))) $val = 'visible';
691
+					$this->value['overflow'] = $val;
692
+					break;
693
+
694
+				case 'padding':
695
+					$val = explode(' ', $val);
696
+					foreach ($val as $k => $v) {
697
+						$v = trim($v);
698
+						if ($v!='') {
699
+							$val[$k] = $v;
700
+						} else {
701
+							unset($val[$k]);
702
+						}
703
+					}
704
+					$val = array_values($val);
705
+					$this->_duplicateBorder($val);
706
+					$this->value['padding']['t'] = $this->convertToMM($val[0], 0);
707
+					$this->value['padding']['r'] = $this->convertToMM($val[1], 0);
708
+					$this->value['padding']['b'] = $this->convertToMM($val[2], 0);
709
+					$this->value['padding']['l'] = $this->convertToMM($val[3], 0);
710
+					break;
711
+
712
+				case 'padding-top':
713
+					$this->value['padding']['t'] = $this->convertToMM($val, 0);
714
+					break;
715
+
716
+				case 'padding-right':
717
+					$this->value['padding']['r'] = $this->convertToMM($val, 0);
718
+					break;
719
+
720
+				case 'padding-bottom':
721
+					$this->value['padding']['b'] = $this->convertToMM($val, 0);
722
+					break;
723
+
724
+				case 'padding-left':
725
+					$this->value['padding']['l'] = $this->convertToMM($val, 0);
726
+					break;
727
+
728
+				case 'margin':
729
+					if ($val=='auto') {
730
+						$this->value['margin-auto'] = true;
731
+						break;
732
+					}
733
+					$val = explode(' ', $val);
734
+					foreach ($val as $k => $v) {
735
+						$v = trim($v);
736
+						if ($v!='') {
737
+							$val[$k] = $v;
738
+						} else {
739
+							unset($val[$k]);
740
+						}
741
+					}
742
+					$val = array_values($val);
743
+					$this->_duplicateBorder($val);
744
+					$this->value['margin']['t'] = $this->convertToMM($val[0], 0);
745
+					$this->value['margin']['r'] = $this->convertToMM($val[1], 0);
746
+					$this->value['margin']['b'] = $this->convertToMM($val[2], 0);
747
+					$this->value['margin']['l'] = $this->convertToMM($val[3], 0);
748
+					break;
749
+
750
+				case 'margin-top':
751
+					$this->value['margin']['t'] = $this->convertToMM($val, 0);
752
+					break;
753
+
754
+				case 'margin-right':
755
+					$this->value['margin']['r'] = $this->convertToMM($val, 0);
756
+					break;
757
+
758
+				case 'margin-bottom':
759
+					$this->value['margin']['b'] = $this->convertToMM($val, 0);
760
+					break;
761
+
762
+				case 'margin-left':
763
+					$this->value['margin']['l'] = $this->convertToMM($val, 0);
764
+					break;
765
+
766
+				case 'border':
767
+					$val = $this->readBorder($val);
768
+					$this->value['border']['t'] = $val;
769
+					$this->value['border']['r'] = $val;
770
+					$this->value['border']['b'] = $val;
771
+					$this->value['border']['l'] = $val;
772
+					break;
773
+
774
+				case 'border-style':
775
+					$val = explode(' ', $val);
776
+					foreach ($val as $valK => $valV) {
777
+						if (!in_array($valV, array('solid', 'dotted', 'dashed'))) {
778
+							$val[$valK] = null;
779
+						}
780
+					}
781
+					$this->_duplicateBorder($val);
782
+					if ($val[0]) $this->value['border']['t']['type'] = $val[0];
783
+					if ($val[1]) $this->value['border']['r']['type'] = $val[1];
784
+					if ($val[2]) $this->value['border']['b']['type'] = $val[2];
785
+					if ($val[3]) $this->value['border']['l']['type'] = $val[3];
786
+					break;
787
+
788
+				case 'border-top-style':
789
+					if (in_array($val, array('solid', 'dotted', 'dashed'))) {
790
+						$this->value['border']['t']['type'] = $val;
791
+					}
792
+					break;
793
+
794
+				case 'border-right-style':
795
+					if (in_array($val, array('solid', 'dotted', 'dashed'))) {
796
+						$this->value['border']['r']['type'] = $val;
797
+					}
798
+					break;
799
+
800
+				case 'border-bottom-style':
801
+					if (in_array($val, array('solid', 'dotted', 'dashed'))) {
802
+						$this->value['border']['b']['type'] = $val;
803
+					}
804
+					break;
805
+
806
+				case 'border-left-style':
807
+					if (in_array($val, array('solid', 'dotted', 'dashed')))
808
+						$this->value['border']['l']['type'] = $val;
809
+					break;
810
+
811
+				case 'border-color':
812
+					$res = false;
813
+					$val = preg_replace('/,[\s]+/', ',', $val);
814
+					$val = explode(' ', $val);
815
+					foreach ($val as $valK => $valV) {
816
+							$val[$valK] = $this->convertToColor($valV, $res);
817
+							if (!$res) {
818
+								$val[$valK] = null;
819
+							}
820
+					}
821
+					$this->_duplicateBorder($val);
822
+					if (is_array($val[0])) $this->value['border']['t']['color'] = $val[0];
823
+					if (is_array($val[1])) $this->value['border']['r']['color'] = $val[1];
824
+					if (is_array($val[2])) $this->value['border']['b']['color'] = $val[2];
825
+					if (is_array($val[3])) $this->value['border']['l']['color'] = $val[3];
826
+
827
+					break;
828
+
829
+				case 'border-top-color':
830
+					$res = false;
831
+					$val = $this->convertToColor($val, $res);
832
+					if ($res) $this->value['border']['t']['color'] = $val;
833
+					break;
834
+
835
+				case 'border-right-color':
836
+					$res = false;
837
+					$val = $this->convertToColor($val, $res);
838
+					if ($res) $this->value['border']['r']['color'] = $val;
839
+					break;
840
+
841
+				case 'border-bottom-color':
842
+					$res = false;
843
+					$val = $this->convertToColor($val, $res);
844
+					if ($res) $this->value['border']['b']['color'] = $val;
845
+					break;
846
+
847
+				case 'border-left-color':
848
+					$res = false;
849
+					$val = $this->convertToColor($val, $res);
850
+					if ($res) $this->value['border']['l']['color'] = $val;
851
+					break;
852
+
853
+				case 'border-width':
854
+					$val = explode(' ', $val);
855
+					foreach ($val as $valK => $valV) {
856
+							$val[$valK] = $this->convertToMM($valV, 0);
857
+					}
858
+					$this->_duplicateBorder($val);
859
+					if ($val[0]) $this->value['border']['t']['width'] = $val[0];
860
+					if ($val[1]) $this->value['border']['r']['width'] = $val[1];
861
+					if ($val[2]) $this->value['border']['b']['width'] = $val[2];
862
+					if ($val[3]) $this->value['border']['l']['width'] = $val[3];
863
+					break;
864
+
865
+				case 'border-top-width':
866
+					$val = $this->convertToMM($val, 0);
867
+					if ($val) $this->value['border']['t']['width'] = $val;
868
+					break;
869
+
870
+				case 'border-right-width':
871
+					$val = $this->convertToMM($val, 0);
872
+					if ($val) $this->value['border']['r']['width'] = $val;
873
+					break;
874
+
875
+				case 'border-bottom-width':
876
+					$val = $this->convertToMM($val, 0);
877
+					if ($val) $this->value['border']['b']['width'] = $val;
878
+					break;
879
+
880
+				case 'border-left-width':
881
+					$val = $this->convertToMM($val, 0);
882
+					if ($val) $this->value['border']['l']['width'] = $val;
883
+					break;
884
+
885
+				case 'border-collapse':
886
+					if ($tagName=='table') $this->value['border']['collapse'] = ($val=='collapse');
887
+					break;
888
+
889
+				case 'border-radius':
890
+					$val = explode('/', $val);
891
+					if (count($val)>2) {
892
+						break;
893
+					}
894
+					$valH = $this->convertToRadius(trim($val[0]));
895
+					if (count($valH)<1 || count($valH)>4) {
896
+						break;
897
+					}
898
+					if (!isset($valH[1])) $valH[1] = $valH[0];
899
+					if (!isset($valH[2])) $valH = array($valH[0], $valH[0], $valH[1], $valH[1]);
900
+					if (!isset($valH[3])) $valH[3] = $valH[1];
901
+					if (isset($val[1])) {
902
+						$valV = $this->convertToRadius(trim($val[1]));
903
+						if (count($valV)<1 || count($valV)>4) {
904
+							break;
905
+						}
906
+						if (!isset($valV[1])) $valV[1] = $valV[0];
907
+						if (!isset($valV[2])) $valV = array($valV[0], $valV[0], $valV[1], $valV[1]);
908
+						if (!isset($valV[3])) $valV[3] = $valV[1];
909
+					} else {
910
+						$valV = $valH;
911
+					}
912
+					$this->value['border']['radius'] = array(
913
+								'tl' => array($valH[0], $valV[0]),
914
+								'tr' => array($valH[1], $valV[1]),
915
+								'br' => array($valH[2], $valV[2]),
916
+								'bl' => array($valH[3], $valV[3])
917
+							);
918
+					break;
919
+
920
+				case 'border-top-left-radius':
921
+					$val = $this->convertToRadius($val);
922
+					if (count($val)<1 || count($val)>2) {
923
+						break;
924
+					}
925
+					$this->value['border']['radius']['tl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
926
+					break;
927
+
928
+				case 'border-top-right-radius':
929
+					$val = $this->convertToRadius($val);
930
+					if (count($val)<1 || count($val)>2) {
931
+						break;
932
+					}
933
+					$this->value['border']['radius']['tr'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
934
+					break;
935
+
936
+				case 'border-bottom-right-radius':
937
+					$val = $this->convertToRadius($val);
938
+					if (count($val)<1 || count($val)>2) {
939
+						break;
940
+					}
941
+					$this->value['border']['radius']['br'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
942
+					break;
943
+
944
+				case 'border-bottom-left-radius':
945
+					$val = $this->convertToRadius($val);
946
+					if (count($val)<1 || count($val)>2) {
947
+						break;
948
+					}
949
+					$this->value['border']['radius']['bl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
950
+					break;
951
+
952
+				case 'border-top':
953
+					$this->value['border']['t'] = $this->readBorder($val);
954
+					break;
955
+
956
+				case 'border-right':
957
+					$this->value['border']['r'] = $this->readBorder($val);
958
+					break;
959
+
960
+				case 'border-bottom':
961
+					$this->value['border']['b'] = $this->readBorder($val);
962
+					break;
963
+
964
+				case 'border-left':
965
+					$this->value['border']['l'] = $this->readBorder($val);
966
+					break;
967
+
968
+				case 'background-color':
969
+					$this->value['background']['color'] = $this->convertBackgroundColor($val);
970
+					break;
971
+
972
+				case 'background-image':
973
+					$this->value['background']['image'] = $this->convertBackgroundImage($val);
974
+					break;
975
+
976
+				case 'background-position':
977
+					$res = null;
978
+					$this->value['background']['position'] = $this->convertBackgroundPosition($val, $res);
979
+					break;
980
+
981
+				case 'background-repeat':
982
+					$this->value['background']['repeat'] = $this->convertBackgroundRepeat($val);
983
+					break;
984
+
985
+				case 'background':
986
+					$this->convertBackground($val, $this->value['background']);
987
+					break;
988
+
989
+				case 'position':
990
+					if ($val=='absolute')       $this->value['position'] = 'absolute';
991
+					else if ($val=='relative')  $this->value['position'] = 'relative';
992
+					else                        $this->value['position'] = null;
993
+					break;
994
+
995
+				case 'float':
996
+					if ($val=='left')           $this->value['float'] = 'left';
997
+					else if ($val=='right')     $this->value['float'] = 'right';
998
+					else                        $this->value['float'] = null;
999
+					break;
1000
+
1001
+				case 'display':
1002
+					if ($val=='inline')         $this->value['display'] = 'inline';
1003
+					else if ($val=='block')     $this->value['display'] = 'block';
1004
+					else if ($val=='none')      $this->value['display'] = 'none';
1005
+					else                        $this->value['display'] = null;
1006
+					break;
1007
+
1008
+				case 'top':
1009
+				case 'bottom':
1010
+				case 'left':
1011
+				case 'right':
1012
+					$this->value[$nom] = $val;
1013
+					break;
1014
+
1015
+				case 'list-style':
1016
+				case 'list-style-type':
1017
+				case 'list-style-image':
1018
+					if ($nom=='list-style') $nom = 'list-style-type';
1019
+					$this->value[$nom] = $val;
1020
+					break;
1021
+
1022
+				default:
1023
+					break;
1024
+			}
1025
+		}
1026
+
1027
+		$return = true;
1028
+
1029
+		// only for P tag
1030
+		if ($this->value['margin']['t']===null) $this->value['margin']['t'] = $this->value['font-size'];
1031
+		if ($this->value['margin']['b']===null) $this->value['margin']['b'] = $this->value['font-size'];
1032
+
1033
+		// force the text align to left, if asked by html2pdf
1034
+		if ($this->_onlyLeft) $this->value['text-align'] = 'left';
1035
+
1036
+		// correction on the width (quick box)
1037
+		if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position']!='absolute') {
1038
+			$this->value['width'] = $this->getLastWidth();
1039
+			$this->value['width']-= $this->value['margin']['l'] + $this->value['margin']['r'];
1040
+		} else {
1041
+			if ($correctWidth) {
1042
+				if (!in_array($tagName, array('table', 'div', 'blockquote', 'fieldset', 'hr'))) {
1043
+					$this->value['width']-= $this->value['padding']['l'] + $this->value['padding']['r'];
1044
+					$this->value['width']-= $this->value['border']['l']['width'] + $this->value['border']['r']['width'];
1045
+				}
1046
+				if (in_array($tagName, array('th', 'td'))) {
1047
+					$this->value['width']-= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
1048
+					$return = false;
1049
+				}
1050
+				if ($this->value['width']<0) $this->value['width']=0;
1051
+			} else {
1052
+				if ($this->value['width']) {
1053
+					if ($this->value['border']['l']['width']) $this->value['width'] += $this->value['border']['l']['width'];
1054
+					if ($this->value['border']['r']['width']) $this->value['width'] += $this->value['border']['r']['width'];
1055
+					if ($this->value['padding']['l'])         $this->value['width'] += $this->value['padding']['l'];
1056
+					if ($this->value['padding']['r'])         $this->value['width'] += $this->value['padding']['r'];
1057
+				}
1058
+			}
1059
+		}
1060
+		if ($this->value['height']) {
1061
+			if ($this->value['border']['b']['width']) $this->value['height'] += $this->value['border']['b']['width'];
1062
+			if ($this->value['border']['t']['width']) $this->value['height'] += $this->value['border']['t']['width'];
1063
+			if ($this->value['padding']['b'])         $this->value['height'] += $this->value['padding']['b'];
1064
+			if ($this->value['padding']['t'])         $this->value['height'] += $this->value['padding']['t'];
1065
+		}
1066
+
1067
+		if ($this->value['top']!=null)      $this->value['top']     = $this->convertToMM($this->value['top'], $this->getLastHeight(true));
1068
+		if ($this->value['bottom']!=null)   $this->value['bottom']  = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true));
1069
+		if ($this->value['left']!=null)     $this->value['left']    = $this->convertToMM($this->value['left'], $this->getLastWidth(true));
1070
+		if ($this->value['right']!=null)    $this->value['right']   = $this->convertToMM($this->value['right'], $this->getLastWidth(true));
1071
+
1072
+		if ($this->value['top'] && $this->value['bottom'] && $this->value['height'])    $this->value['bottom']  = null;
1073
+		if ($this->value['left'] && $this->value['right'] && $this->value['width'])     $this->value['right']   = null;
1074
+
1075
+		return $return;
1076
+	}
1077
+
1078
+	 /**
1079
+	  * get the height of the current line
1080
+	  *
1081
+	  * @access public
1082
+	  * @return float $height in mm
1083
+	  */
1084
+	public function getLineHeight()
1085
+	{
1086
+		$val = $this->value['line-height'];
1087
+		if ($val=='normal') $val = '108%';
1088
+		return $this->convertToMM($val, $this->value['font-size']);
1089
+	}
1090
+
1091
+	 /**
1092
+	  * get the width of the parent
1093
+	  *
1094
+	  * @access public
1095
+	  * @param  boolean $mode true => adding padding and border
1096
+	  * @return float $width in mm
1097
+	  */
1098
+	public function getLastWidth($mode = false)
1099
+	{
1100
+		for ($k=count($this->table)-1; $k>=0; $k--) {
1101
+			if ($this->table[$k]['width']) {
1102
+				$w = $this->table[$k]['width'];
1103
+				if ($mode) {
1104
+					$w+= $this->table[$k]['border']['l']['width'] + $this->table[$k]['padding']['l'] + 0.02;
1105
+					$w+= $this->table[$k]['border']['r']['width'] + $this->table[$k]['padding']['r'] + 0.02;
1106
+				}
1107
+				return $w;
1108
+			}
1109
+		}
1110
+		return $this->_pdf->getW() - $this->_pdf->getlMargin() - $this->_pdf->getrMargin();
1111
+	}
1112
+
1113
+	 /**
1114
+	  * get the height of the parent
1115
+	  *
1116
+	  * @access public
1117
+	  * @param  boolean $mode true => adding padding and border
1118
+	  * @return float $height in mm
1119
+	  */
1120
+	public function getLastHeight($mode = false)
1121
+	{
1122
+		for ($k=count($this->table)-1; $k>=0; $k--) {
1123
+			if ($this->table[$k]['height']) {
1124
+				$h = $this->table[$k]['height'];
1125
+				if ($mode) {
1126
+					$h+= $this->table[$k]['border']['t']['width'] + $this->table[$k]['padding']['t'] + 0.02;
1127
+					$h+= $this->table[$k]['border']['b']['width'] + $this->table[$k]['padding']['b'] + 0.02;
1128
+				}
1129
+				return $h;
1130
+			}
1131
+		}
1132
+		return $this->_pdf->getH() - $this->_pdf->gettMargin() - $this->_pdf->getbMargin();
1133
+	}
1134
+
1135
+	/**
1136
+	 * get the value of the float property
1137
+	 *
1138
+	 * @access public
1139
+	 * @return $float left/right
1140
+	 */
1141
+	public function getFloat()
1142
+	{
1143
+		if ($this->value['float']=='left')    return 'left';
1144
+		if ($this->value['float']=='right')   return 'right';
1145
+		return null;
1146
+	}
1147
+
1148
+	/**
1149
+	 * get the last value for a specific key
1150
+	 *
1151
+	 * @access public
1152
+	 * @param  string $key
1153
+	 * @return mixed
1154
+	 */
1155
+	public function getLastValue($key)
1156
+	{
1157
+		$nb = count($this->table);
1158
+		if ($nb>0) {
1159
+			return $this->table[$nb-1][$key];
1160
+		} else {
1161
+			return null;
1162
+		}
1163
+	}
1164
+
1165
+	/**
1166
+	 * get the last absolute X
1167
+	 *
1168
+	 * @access protected
1169
+	 * @return float $x
1170
+	 */
1171
+	protected function _getLastAbsoluteX()
1172
+	{
1173
+		for ($k=count($this->table)-1; $k>=0; $k--) {
1174
+			if ($this->table[$k]['x'] && $this->table[$k]['position']) return $this->table[$k]['x'];
1175
+		}
1176
+		return $this->_pdf->getlMargin();
1177
+	}
1178
+
1179
+	/**
1180
+	 * get the last absolute Y
1181
+	 *
1182
+	 * @access protected
1183
+	 * @return float $y
1184
+	 */
1185
+	protected function _getLastAbsoluteY()
1186
+	{
1187
+		for ($k=count($this->table)-1; $k>=0; $k--) {
1188
+			if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y'];
1189
+		}
1190
+		return $this->_pdf->gettMargin();
1191
+	}
1192
+
1193
+	/**
1194
+	 * get the CSS properties of the current tag
1195
+	 *
1196
+	 * @access protected
1197
+	 * @return array $styles
1198
+	 */
1199
+	protected function _getFromCSS()
1200
+	{
1201
+		// styles to apply
1202
+		$styles = array();
1203
+
1204
+		// list of the selectors to get in the CSS files
1205
+		$getit  = array();
1206
+
1207
+		// get the list of the selectors of each tags
1208
+		$lst = array();
1209
+		$lst[] = $this->value['id_lst'];
1210
+		for ($i=count($this->table)-1; $i>=0; $i--) {
1211
+			$lst[] = $this->table[$i]['id_lst'];
1212
+		}
1213
+
1214
+		// foreach selectors in the CSS files, verify if it match with the list of selectors
1215
+		foreach ($this->cssKeys as $key => $num) {
1216
+			if ($this->_getReccursiveStyle($key, $lst)) {
1217
+				$getit[$key] = $num;
1218
+			}
1219
+		}
1220
+
1221
+		// if we have selectors
1222
+		if (count($getit)) {
1223
+			// get them, but in the definition order, because of priority
1224
+			asort($getit);
1225
+			foreach ($getit as $key => $val) $styles = array_merge($styles, $this->css[$key]);
1226
+		}
1227
+
1228
+		return $styles;
1229
+	}
1230
+
1231
+	/**
1232
+	 * identify if the selector $key match with the list of tag selectors
1233
+	 *
1234
+	 * @access protected
1235
+	 * @param  string   $key CSS selector to analyse
1236
+	 * @param  array    $lst list of the selectors of each tags
1237
+	 * @param  string   $next next step of parsing the selector
1238
+	 * @return boolean
1239
+	 */
1240
+	protected function _getReccursiveStyle($key, $lst, $next = null)
1241
+	{
1242
+		// if next step
1243
+		if ($next!==null) {
1244
+			// we remove this step
1245
+			if ($next) $key = trim(substr($key, 0, -strlen($next)));
1246
+			array_shift($lst);
1247
+
1248
+			// if no more step to identify => return false
1249
+			if (!count($lst)) {
1250
+				return false;
1251
+			}
1252
+		}
1253
+
1254
+		// for each selector of the current step
1255
+		foreach ($lst[0] as $name) {
1256
+			// if selector = key => ok
1257
+			if ($key==$name) {
1258
+				return true;
1259
+			}
1260
+
1261
+			// if the end of the key = the selector and the next step is ok => ok
1262
+			if (substr($key, -strlen(' '.$name))==' '.$name && $this->_getReccursiveStyle($key, $lst, $name)) {
1263
+				return true;
1264
+			}
1265
+		}
1266
+
1267
+		// if we are not in the first step, we analyse the sub steps (the pareng tag of the current tag)
1268
+		if ($next!==null && $this->_getReccursiveStyle($key, $lst, '')) {
1269
+			return true;
1270
+		}
1271
+
1272
+		// no corresponding found
1273
+		return false;
1274
+	}
1275
+
1276
+	/**
1277
+	 * Analyse a border
1278
+	 *
1279
+	 * @access  public
1280
+	 * @param   string $css css border properties
1281
+	 * @return  array  border properties
1282
+	 */
1283
+	public function readBorder($css)
1284
+	{
1285
+		// border none
1286
+		$none = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0));
1287
+
1288
+		// default value
1289
+		$type  = 'solid';
1290
+		$width = $this->convertToMM('1pt');
1291
+		$color = array(0, 0, 0);
1292
+
1293
+		// clean up the values
1294
+		$css = explode(' ', $css);
1295
+		foreach ($css as $k => $v) {
1296
+			$v = trim($v);
1297
+			if ($v) $css[$k] = $v;
1298
+			else    unset($css[$k]);
1299
+		}
1300
+		$css = array_values($css);
1301
+
1302
+		// read the values
1303
+		$res = null;
1304
+		foreach ($css as $value) {
1305
+
1306
+			// if no border => return none
1307
+			if ($value=='none' || $value=='hidden') {
1308
+				return $none;
1309
+			}
1310
+
1311
+			// try to convert the value as a distance
1312
+			$tmp = $this->convertToMM($value);
1313
+
1314
+			// if the convert is ok => it is a width
1315
+			if ($tmp!==null) {
1316
+				$width = $tmp;
1317
+			// else, it could be the type
1318
+			} else if (in_array($value, array('solid', 'dotted', 'dashed', 'double'))) {
1319
+				$type = $value;
1320
+			// else, it could be the color
1321
+			} else {
1322
+				$tmp = $this->convertToColor($value, $res);
1323
+				if ($res) $color = $tmp;
1324
+			}
1325
+		}
1326
+
1327
+		// if no witdh => return none
1328
+		if (!$width) return $none;
1329
+
1330
+		// return the border properties
1331
+		return array('type' => $type, 'width' => $width, 'color' => $color);
1332
+	}
1333
+
1334
+	/**
1335
+	 * duplicate the borders if needed
1336
+	 *
1337
+	 * @access protected
1338
+	 * @param  &array $val
1339
+	 */
1340
+	protected function _duplicateBorder(&$val)
1341
+	{
1342
+		// 1 value => L => RTB
1343
+		if (count($val)==1) {
1344
+			$val[1] = $val[0];
1345
+			$val[2] = $val[0];
1346
+			$val[3] = $val[0];
1347
+		// 2 values => L => R & T => B
1348
+		} else if (count($val)==2) {
1349
+			$val[2] = $val[0];
1350
+			$val[3] = $val[1];
1351
+		// 3 values => T => B
1352
+		} else if (count($val)==3) {
1353
+			$val[3] = $val[1];
1354
+		}
1355
+	}
1356
+
1357
+	/**
1358
+	 * Analyse a background
1359
+	 *
1360
+	 * @access public
1361
+	 * @param  string $css css background properties
1362
+	 * @param  &array $value parsed values (by reference, because, ther is a legacy of the parent CSS properties)
1363
+	 */
1364
+	public function convertBackground($css, &$value)
1365
+	{
1366
+		// is there a image ?
1367
+		$text = '/url\(([^)]*)\)/isU';
1368
+		if (preg_match($text, $css, $match)) {
1369
+			// get the image
1370
+			$value['image'] = $this->convertBackgroundImage($match[0]);
1371
+
1372
+			// remove if from the css properties
1373
+			$css = preg_replace($text, '', $css);
1374
+			$css = preg_replace('/[\s]+/', ' ', $css);
1375
+		}
1376
+
1377
+		// protect some spaces
1378
+		$css = preg_replace('/,[\s]+/', ',', $css);
1379
+
1380
+		// explode the values
1381
+		$css = explode(' ', $css);
1382
+
1383
+		// background position to parse
1384
+		$pos = '';
1385
+
1386
+		// foreach value
1387
+		foreach ($css as $val) {
1388
+			// try to parse the value as a color
1389
+			$ok = false;
1390
+			$color = $this->convertToColor($val, $ok);
1391
+
1392
+			// if ok => it is a color
1393
+			if ($ok) {
1394
+				$value['color'] = $color;
1395
+			// else if transparent => no coloàr
1396
+			} else if ($val=='transparent') {
1397
+				$value['color'] = null;
1398
+			// else
1399
+			} else {
1400
+				// try to parse the value as a repeat
1401
+				$repeat = $this->convertBackgroundRepeat($val);
1402
+
1403
+				// if ok => it is repeat
1404
+				if ($repeat) {
1405
+					$value['repeat'] = $repeat;
1406
+				// else => it could only be a position
1407
+				} else {
1408
+					$pos.= ($pos ? ' ' : '').$val;
1409
+				}
1410
+			}
1411
+		}
1412
+
1413
+		// if we have a position to parse
1414
+		if ($pos) {
1415
+			// try to read it
1416
+			$pos = $this->convertBackgroundPosition($pos, $ok);
1417
+			if ($ok) $value['position'] = $pos;
1418
+		}
1419
+	}
1420
+
1421
+	/**
1422
+	 * parse a background color
1423
+	 *
1424
+	 * @access public
1425
+	 * @param  string $css
1426
+	 * @return string $value
1427
+	 */
1428
+	public function convertBackgroundColor($css)
1429
+	{
1430
+		$res = null;
1431
+		if ($css=='transparent') return null;
1432
+		else                     return $this->convertToColor($css, $res);
1433
+	}
1434
+
1435
+	/**
1436
+	 * parse a background image
1437
+	 *
1438
+	 * @access public
1439
+	 * @param  string $css
1440
+	 * @return string $value
1441
+	 */
1442
+	public function convertBackgroundImage($css)
1443
+	{
1444
+		if ($css=='none')
1445
+			return null;
1446
+		else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match))
1447
+			return $match[1];
1448
+		else
1449
+			return null;
1450
+	}
1451
+
1452
+	/**
1453
+	 * parse a background position
1454
+	 *
1455
+	 * @access public
1456
+	 * @param  string $css
1457
+	 * @param  &boolean $res flag if conver is ok or not
1458
+	 * @return array ($x, $y)
1459
+	 */
1460
+	public function convertBackgroundPosition($css, &$res)
1461
+	{
1462
+		// init the res
1463
+		$res = false;
1464
+
1465
+		// explode the value
1466
+		$css = explode(' ', $css);
1467
+
1468
+		// we must have 2 values. if 0 or >2 : error. if 1 => put center for 2
1469
+		if (count($css)<2) {
1470
+			if (!$css[0]) return null;
1471
+			$css[1] = 'center';
1472
+		}
1473
+		if (count($css)>2) return null;
1474
+
1475
+		// prepare the values
1476
+		$x = 0;
1477
+		$y = 0;
1478
+		$res = true;
1479
+
1480
+		// convert the first value
1481
+		if ($css[0]=='left')        $x = '0%';
1482
+		else if ($css[0]=='center') $x = '50%';
1483
+		else if ($css[0]=='right')  $x = '100%';
1484
+		else if ($css[0]=='top')    $y = '0%';
1485
+		else if ($css[0]=='bottom') $y = '100%';
1486
+		else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0];
1487
+		else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]);
1488
+		else $res = false;
1489
+
1490
+		// convert the second value
1491
+		if ($css[1]=='left')        $x = '0%';
1492
+		else if ($css[1]=='right')  $x = '100%';
1493
+		else if ($css[1]=='top')    $y = '0%';
1494
+		else if ($css[1]=='center') $y = '50%';
1495
+		else if ($css[1]=='bottom') $y = '100%';
1496
+		else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1];
1497
+		else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]);
1498
+		else $res = false;
1499
+
1500
+		// return the values
1501
+		return array($x, $y);
1502
+	}
1503
+
1504
+	/**
1505
+	 * parse a background repeat
1506
+	 *
1507
+	 * @access public
1508
+	 * @param  string $css
1509
+	 * @return string $value
1510
+	 */
1511
+	public function convertBackgroundRepeat($css)
1512
+	{
1513
+		switch($css)
1514
+		{
1515
+			case 'repeat':
1516
+				return array(true, true);
1517
+			case 'repeat-x':
1518
+				return array(true, false);
1519
+			case 'repeat-y':
1520
+				return array(false, true);
1521
+			case 'no-repeat':
1522
+				return array(false, false);
1523
+		}
1524
+		return null;
1525
+	}
1526
+
1527
+	 /**
1528
+	  * convert a distance to mm
1529
+	  *
1530
+	  * @access public
1531
+	  * @param  string $css distance to convert
1532
+	  * @param  float  $old parent distance
1533
+	  * @return float  $value
1534
+	  */
1535
+	public function convertToMM($css, $old=0.)
1536
+	{
1537
+		$css = trim($css);
1538
+		if (preg_match('/^[0-9\.\-]+$/isU', $css))        $css.= 'px';
1539
+		if (preg_match('/^[0-9\.\-]+px$/isU', $css))      $css = 25.4/96. * str_replace('px', '', $css);
1540
+		else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css);
1541
+		else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css);
1542
+		else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css);
1543
+		else if (preg_match('/^[0-9\.\-]+%$/isU', $css))  $css = 1.*$old*str_replace('%', '', $css)/100.;
1544
+		else                                              $css = null;
1545
+
1546
+		return $css;
1547
+	}
1548
+
1549
+	/**
1550
+	 * convert a css radius
1551
+	 *
1552
+	 * @access public
1553
+	 * @param  string $css
1554
+	 * @return float  $value
1555
+	 */
1556
+	public function convertToRadius($css)
1557
+	{
1558
+		// explode the value
1559
+		$css = explode(' ', $css);
1560
+
1561
+		foreach ($css as $k => $v) {
1562
+			$v = trim($v);
1563
+			if ($v) {
1564
+				$v = $this->convertToMM($v, 0);
1565
+				if ($v!==null) {
1566
+					$css[$k] = $v;
1567
+				} else {
1568
+					unset($css[$k]);
1569
+				}
1570
+			} else {
1571
+				unset($css[$k]);
1572
+			}
1573
+		}
1574
+
1575
+		return array_values($css);
1576
+	}
1577
+
1578
+	/**
1579
+	 * convert a css color
1580
+	 *
1581
+	 * @access public
1582
+	 * @param  string $css
1583
+	 * @param  &boolean $res
1584
+	 * @return array (r,g, b)
1585
+	 */
1586
+	public function convertToColor($css, &$res)
1587
+	{
1588
+		// prepare the value
1589
+		$css = trim($css);
1590
+		$res = true;
1591
+
1592
+		// if transparent => return null
1593
+		if (strtolower($css)=='transparent') return array(null, null, null);
1594
+
1595
+		// HTML color
1596
+		if (isset($this->_htmlColor[strtolower($css)])) {
1597
+			$css = $this->_htmlColor[strtolower($css)];
1598
+			$r = floatVal(hexdec(substr($css, 0, 2)));
1599
+			$v = floatVal(hexdec(substr($css, 2, 2)));
1600
+			$b = floatVal(hexdec(substr($css, 4, 2)));
1601
+			return array($r, $v, $b);
1602
+		}
1603
+
1604
+		// like #FFFFFF
1605
+		if (preg_match('/^#[0-9A-Fa-f]{6}$/isU', $css)) {
1606
+			$r = floatVal(hexdec(substr($css, 1, 2)));
1607
+			$v = floatVal(hexdec(substr($css, 3, 2)));
1608
+			$b = floatVal(hexdec(substr($css, 5, 2)));
1609
+			return array($r, $v, $b);
1610
+		}
1611
+
1612
+		// like #FFF
1613
+		if (preg_match('/^#[0-9A-F]{3}$/isU', $css)) {
1614
+			$r = floatVal(hexdec(substr($css, 1, 1).substr($css, 1, 1)));
1615
+			$v = floatVal(hexdec(substr($css, 2, 1).substr($css, 2, 1)));
1616
+			$b = floatVal(hexdec(substr($css, 3, 1).substr($css, 3, 1)));
1617
+			return array($r, $v, $b);
1618
+		}
1619
+
1620
+		// like rgb(100, 100, 100)
1621
+		if (preg_match('/rgb\([\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*\)/isU', $css, $match)) {
1622
+			$r = $this->_convertSubColor($match[1]);
1623
+			$v = $this->_convertSubColor($match[2]);
1624
+			$b = $this->_convertSubColor($match[3]);
1625
+			return array($r*255., $v*255., $b*255.);
1626
+		}
1627
+
1628
+		// like cmyk(100, 100, 100, 100)
1629
+		if (preg_match('/cmyk\([\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*\)/isU', $css, $match)) {
1630
+			$c = $this->_convertSubColor($match[1]);
1631
+			$m = $this->_convertSubColor($match[2]);
1632
+			$y = $this->_convertSubColor($match[3]);
1633
+			$k = $this->_convertSubColor($match[4]);
1634
+			return array($c*100., $m*100., $y*100., $k*100.);
1635
+		}
1636
+
1637
+		$res = false;
1638
+		return array(0., 0., 0.);
1639
+	}
1640
+
1641
+	/**
1642
+	 * color value to convert
1643
+	 *
1644
+	 * @access protected
1645
+	 * @param  string $c
1646
+	 * @return float $c 0.->1.
1647
+	 */
1648
+	protected function _convertSubColor($c)
1649
+	{
1650
+		if (substr($c, -1)=='%') {
1651
+			$c = floatVal(substr($c, 0, -1))/100.;
1652
+		} else {
1653
+			$c = floatVal($c);
1654
+			if ($c>1) $c = $c/255.;
1655
+		}
1656
+
1657
+		return $c;
1658
+	}
1659
+
1660
+	/**
1661
+	 * read a css content
1662
+	 *
1663
+	 * @access protected
1664
+	 * @param  &string $code
1665
+	 */
1666
+	protected function _analyseStyle(&$code)
1667
+	{
1668
+		// clean the spaces
1669
+		$code = preg_replace('/[\s]+/', ' ', $code);
1670
+
1671
+		// remove the comments
1672
+		$code = preg_replace('/\/\*.*?\*\//s', '', $code);
1673
+
1674
+		// split each CSS code "selector { value }"
1675
+		preg_match_all('/([^{}]+){([^}]*)}/isU', $code, $match);
1676
+
1677
+		// for each CSS code
1678
+		for ($k=0; $k<count($match[0]); $k++) {
1679
+
1680
+			// selectors
1681
+			$names = strtolower(trim($match[1][$k]));
1682
+
1683
+			// css style
1684
+			$styles = trim($match[2][$k]);
1685
+
1686
+			// explode each value
1687
+			$styles = explode(';', $styles);
1688
+
1689
+			// parse each value
1690
+			$css = array();
1691
+			foreach ($styles as $style) {
1692
+				$tmp = explode(':', $style);
1693
+				if (count($tmp)>1) {
1694
+					$cod = $tmp[0]; unset($tmp[0]); $tmp = implode(':', $tmp);
1695
+					$css[trim(strtolower($cod))] = trim($tmp);
1696
+				}
1697
+			}
1698
+
1699
+			// explode the names
1700
+			$names = explode(',', $names);
1701
+
1702
+			// save the values for each names
1703
+			foreach ($names as $name) {
1704
+				// clean the name
1705
+				$name = trim($name);
1706
+
1707
+				// if a selector with somethink lige :hover => continue
1708
+				if (strpos($name, ':')!==false) continue;
1709
+
1710
+				// save the value
1711
+				if (!isset($this->css[$name]))
1712
+					$this->css[$name] = $css;
1713
+				else
1714
+					$this->css[$name] = array_merge($this->css[$name], $css);
1715
+
1716
+			}
1717
+		}
1718
+
1719
+		// get he list of the keys
1720
+		$this->cssKeys = array_flip(array_keys($this->css));
1721
+	}
1722
+
1723
+	/**
1724
+	 * Extract the css files from a html code
1725
+	 *
1726
+	 * @access public
1727
+	 * @param  string   &$html
1728
+	 */
1729
+	public function readStyle(&$html)
1730
+	{
1731
+		// the CSS content
1732
+		$style = ' ';
1733
+
1734
+		// extract the link tags, and remove them in the html code
1735
+		preg_match_all('/<link([^>]*)>/isU', $html, $match);
1736
+		$html = preg_replace('/<link[^>]*>/isU', '', $html);
1737
+		$html = preg_replace('/<\/link[^>]*>/isU', '', $html);
1738
+
1739
+		// analyse each link tag
1740
+		foreach ($match[1] as $code) {
1741
+			$tmp = array();
1742
+
1743
+			// read the attributes name=value
1744
+			$prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
1745
+			preg_match_all('/'.$prop.'/is', $code, $match);
1746
+			for ($k=0; $k<count($match[0]); $k++) {
1747
+				$tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1748
+			}
1749
+
1750
+			// read the attributes name="value"
1751
+			$prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
1752
+			preg_match_all('/'.$prop.'/is', $code, $match);
1753
+			for ($k=0; $k<count($match[0]); $k++) {
1754
+				$tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1755
+			}
1756
+
1757
+			// read the attributes name='value'
1758
+			$prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
1759
+			preg_match_all('/'.$prop.'/is', $code, $match);
1760
+			for ($k=0; $k<count($match[0]); $k++) {
1761
+				$tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1762
+			}
1763
+
1764
+			// if type text/css => we keep it
1765
+			if (isset($tmp['type']) && strtolower($tmp['type'])=='text/css' && isset($tmp['href'])) {
1766
+
1767
+				// get the href
1768
+				$url = $tmp['href'];
1769
+
1770
+				// get the content of the css file
1771
+				$content = @file_get_contents($url);
1772
+
1773
+				// if "http://" in the url
1774
+				if (strpos($url, 'http://')!==false) {
1775
+
1776
+					// get the domain "http://xxx/"
1777
+					$url = str_replace('http://', '', $url);
1778
+					$url = explode('/', $url);
1779
+					$urlMain = 'http://'.$url[0].'/';
1780
+
1781
+					// get the absolute url of the path
1782
+					$urlSelf = $url; unset($urlSelf[count($urlSelf)-1]); $urlSelf = 'http://'.implode('/', $urlSelf).'/';
1783
+
1784
+					// adapt the url in the css content
1785
+					$content = preg_replace('/url\(([^\\\\][^)]*)\)/isU', 'url('.$urlSelf.'$1)', $content);
1786
+					$content = preg_replace('/url\((\\\\[^)]*)\)/isU', 'url('.$urlMain.'$1)', $content);
1787
+				} else {
1788 1788
 // @TODO correction on url in absolute on a local css content
1789
-                    // $content = preg_replace('/url\(([^)]*)\)/isU', 'url('.dirname($url).'/$1)', $content);
1790
-                }
1791
-
1792
-                // add to the CSS content
1793
-                $style.= $content."\n";
1794
-            }
1795
-        }
1796
-
1797
-        // extract the style tags des tags style, and remove them in the html code
1798
-        preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match);
1799
-        $html = preg_replace('/<style[^>]*>(.*)<\/style[^>]*>/isU', '', $html);
1800
-
1801
-        // analyse each style tags
1802
-        foreach ($match[1] as $code) {
1803
-            // add to the CSS content
1804
-            $code = str_replace('<!--', '', $code);
1805
-            $code = str_replace('-->', '', $code);
1806
-            $style.= $code."\n";
1807
-        }
1808
-
1809
-        //analyse the css content
1810
-        $this->_analyseStyle($style);
1811
-    }
1789
+					// $content = preg_replace('/url\(([^)]*)\)/isU', 'url('.dirname($url).'/$1)', $content);
1790
+				}
1791
+
1792
+				// add to the CSS content
1793
+				$style.= $content."\n";
1794
+			}
1795
+		}
1796
+
1797
+		// extract the style tags des tags style, and remove them in the html code
1798
+		preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match);
1799
+		$html = preg_replace('/<style[^>]*>(.*)<\/style[^>]*>/isU', '', $html);
1800
+
1801
+		// analyse each style tags
1802
+		foreach ($match[1] as $code) {
1803
+			// add to the CSS content
1804
+			$code = str_replace('<!--', '', $code);
1805
+			$code = str_replace('-->', '', $code);
1806
+			$style.= $code."\n";
1807
+		}
1808
+
1809
+		//analyse the css content
1810
+		$this->_analyseStyle($style);
1811
+	}
1812 1812
 }
1813 1813
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * HTML2PDF Librairy - parsingCss class
4 4
  *
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
     protected $_pdf         = null;
19 19
 
20 20
     protected $_htmlColor   = array(); // list of the HTML colors
21
-    protected $_onlyLeft    = false;   // flag if we are in a sub html => only "text-align:left" is used
22
-    protected $_defaultFont = null;    // default font to use if the asked font does not exist
21
+    protected $_onlyLeft    = false; // flag if we are in a sub html => only "text-align:left" is used
22
+    protected $_defaultFont = null; // default font to use if the asked font does not exist
23 23
 
24 24
     public    $value        = array(); // current values
25 25
     public    $css          = array(); // css values
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function getOldValues()
70 70
     {
71
-        return isset($this->table[count($this->table)-1]) ? $this->table[count($this->table)-1] : $this->value;
71
+        return isset($this->table[count($this->table) - 1]) ? $this->table[count($this->table) - 1] : $this->value;
72 72
     }
73 73
 
74 74
     /**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     protected function _init()
95 95
     {
96 96
         // get the Web Colors from TCPDF
97
-        require(K_PATH_MAIN.'htmlcolors.php');
97
+        require(K_PATH_MAIN . 'htmlcolors.php');
98 98
         $this->_htmlColor = $webcolor;
99 99
 
100 100
         // init the Style
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function initStyle()
115 115
     {
116
-        $this->value['id_tag']       = 'body';        // tag name
117
-        $this->value['id_name']          = null;         // tag - attribute name
118
-        $this->value['id_id']            = null;         // tag - attribute id
119
-        $this->value['id_class']         = null;         // tag - attribute class
120
-        $this->value['id_lst']           = array('*');   // tag - list of legacy
121
-        $this->value['mini-size']        = 1.;           // specific size report for sup, sub
122
-        $this->value['mini-decal']       = 0;            // specific position report for sup, sub
116
+        $this->value['id_tag'] = 'body'; // tag name
117
+        $this->value['id_name']          = null; // tag - attribute name
118
+        $this->value['id_id']            = null; // tag - attribute id
119
+        $this->value['id_class']         = null; // tag - attribute class
120
+        $this->value['id_lst']           = array('*'); // tag - list of legacy
121
+        $this->value['mini-size']        = 1.; // specific size report for sup, sub
122
+        $this->value['mini-decal']       = 0; // specific position report for sup, sub
123 123
         $this->value['font-family']      = 'Arial';
124 124
         $this->value['font-bold']        = false;
125 125
         $this->value['font-italic']      = false;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
         // specific values for some tags
214 214
         if (!in_array($tagName, array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) {
215
-            $this->value['margin'] = array('t'=>0,'r'=>0,'b'=>0,'l'=>0);
215
+            $this->value['margin'] = array('t'=>0, 'r'=>0, 'b'=>0, 'l'=>0);
216 216
         }
217 217
 
218 218
         if (in_array($tagName, array('input', 'select', 'textarea'))) {
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
             $this->value['border']['l'] = null;
223 223
         }
224 224
 
225
-        if ($tagName=='p') {
225
+        if ($tagName == 'p') {
226 226
             $this->value['margin']['t'] = null;
227 227
             $this->value['margin']['b'] = null;
228 228
         }
229
-        if ($tagName=='blockquote') {
229
+        if ($tagName == 'blockquote') {
230 230
             $this->value['margin']['t'] = 3;
231 231
             $this->value['margin']['r'] = 3;
232 232
             $this->value['margin']['b'] = 3;
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
             );
276 276
         }
277 277
 
278
-        if ($tagName=='hr') {
278
+        if ($tagName == 'hr') {
279 279
             $this->value['border'] = array(
280 280
                 't' => $border,
281 281
                 'r' => $border,
@@ -305,40 +305,40 @@  discard block
 block discarded – undo
305 305
     {
306 306
         $family = strtolower($this->value['font-family']);
307 307
 
308
-        $b = ($this->value['font-bold']        ? 'B' : '');
309
-        $i = ($this->value['font-italic']      ? 'I' : '');
310
-        $u = ($this->value['font-underline']   ? 'U' : '');
308
+        $b = ($this->value['font-bold'] ? 'B' : '');
309
+        $i = ($this->value['font-italic'] ? 'I' : '');
310
+        $u = ($this->value['font-underline'] ? 'U' : '');
311 311
         $d = ($this->value['font-linethrough'] ? 'D' : '');
312
-        $o = ($this->value['font-overline']    ? 'O' : '');
312
+        $o = ($this->value['font-overline'] ? 'O' : '');
313 313
 
314 314
         // font style
315
-        $style = $b.$i;
315
+        $style = $b . $i;
316 316
 
317 317
         if ($this->_defaultFont) {
318
-            if($family=='arial')
319
-                $family='helvetica';
320
-            elseif($family=='symbol' || $family=='zapfdingbats')
321
-                $style='';
318
+            if ($family == 'arial')
319
+                $family = 'helvetica';
320
+            elseif ($family == 'symbol' || $family == 'zapfdingbats')
321
+                $style = '';
322 322
 
323
-            $fontkey = $family.$style;
323
+            $fontkey = $family . $style;
324 324
             if (!$this->_pdf->isLoadedFont($fontkey))
325 325
                 $family = $this->_defaultFont;
326 326
         }
327 327
 
328
-        if($family=='arial')
329
-            $family='helvetica';
330
-        elseif($family=='symbol' || $family=='zapfdingbats')
331
-            $style='';
328
+        if ($family == 'arial')
329
+            $family = 'helvetica';
330
+        elseif ($family == 'symbol' || $family == 'zapfdingbats')
331
+            $style = '';
332 332
 
333 333
         // complete style
334
-        $style.= $u.$d.$o;
334
+        $style .= $u . $d . $o;
335 335
 
336 336
         // size : mm => pt
337 337
         $size = $this->value['font-size'];
338 338
         $size = 72 * $size / 25.4;
339 339
 
340 340
         // apply the font
341
-        $this->_pdf->SetFont($family, $style, $this->value['mini-size']*$size);
341
+        $this->_pdf->SetFont($family, $style, $this->value['mini-size'] * $size);
342 342
         $this->_pdf->setTextColorArray($this->value['color']);
343 343
         if ($this->value['background']['color'])
344 344
             $this->_pdf->setFillColorArray($this->value['background']['color']);
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
      */
376 376
     public function restorePosition()
377 377
     {
378
-        if ($this->value['y']==$this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false);
378
+        if ($this->value['y'] == $this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false);
379 379
     }
380 380
 
381 381
      /**
@@ -393,35 +393,35 @@  discard block
 block discarded – undo
393 393
         $this->value['xc'] = $currentX;
394 394
         $this->value['yc'] = $currentY;
395 395
 
396
-        if ($this->value['position']=='relative' || $this->value['position']=='absolute') {
397
-            if ($this->value['right']!==null) {
396
+        if ($this->value['position'] == 'relative' || $this->value['position'] == 'absolute') {
397
+            if ($this->value['right'] !== null) {
398 398
                 $x = $this->getLastWidth(true) - $this->value['right'] - $this->value['width'];
399
-                if ($this->value['margin']['r']) $x-= $this->value['margin']['r'];
399
+                if ($this->value['margin']['r']) $x -= $this->value['margin']['r'];
400 400
             } else {
401 401
                 $x = $this->value['left'];
402
-                if ($this->value['margin']['l']) $x+= $this->value['margin']['l'];
402
+                if ($this->value['margin']['l']) $x += $this->value['margin']['l'];
403 403
             }
404 404
 
405
-            if ($this->value['bottom']!==null) {
405
+            if ($this->value['bottom'] !== null) {
406 406
                 $y = $this->getLastHeight(true) - $this->value['bottom'] - $this->value['height'];
407
-                if ($this->value['margin']['b']) $y-= $this->value['margin']['b'];
407
+                if ($this->value['margin']['b']) $y -= $this->value['margin']['b'];
408 408
             } else {
409 409
                 $y = $this->value['top'];
410
-                if ($this->value['margin']['t']) $y+= $this->value['margin']['t'];
410
+                if ($this->value['margin']['t']) $y += $this->value['margin']['t'];
411 411
             }
412 412
 
413
-            if ($this->value['position']=='relative') {
413
+            if ($this->value['position'] == 'relative') {
414 414
                 $this->value['x'] = $currentX + $x;
415 415
                 $this->value['y'] = $currentY + $y;
416 416
             } else {
417
-                $this->value['x'] = $this->_getLastAbsoluteX()+$x;
418
-                $this->value['y'] = $this->_getLastAbsoluteY()+$y;
417
+                $this->value['x'] = $this->_getLastAbsoluteX() + $x;
418
+                $this->value['y'] = $this->_getLastAbsoluteY() + $y;
419 419
             }
420 420
         } else {
421 421
             $this->value['x'] = $currentX;
422 422
             $this->value['y'] = $currentY;
423
-            if ($this->value['margin']['l']) $this->value['x']+= $this->value['margin']['l'];
424
-            if ($this->value['margin']['t']) $this->value['y']+= $this->value['margin']['t'];
423
+            if ($this->value['margin']['l']) $this->value['x'] += $this->value['margin']['l'];
424
+            if ($this->value['margin']['t']) $this->value['y'] += $this->value['margin']['t'];
425 425
         }
426 426
 
427 427
         // save the new position
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
     {
479 479
         // prepare
480 480
         $tagName = strtolower($tagName);
481
-        $id   = isset($param['id'])   ? strtolower(trim($param['id']))   : null; if (!$id)   $id   = null;
481
+        $id   = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id)   $id   = null;
482 482
         $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null;
483 483
 
484 484
         // read the class attribute
@@ -509,15 +509,15 @@  discard block
 block discarded – undo
509 509
 
510 510
         if (count($class)) {
511 511
             foreach ($class as $v) {
512
-                $this->value['id_lst'][] = '*.'.$v;
513
-                $this->value['id_lst'][] = '.'.$v;
514
-                $this->value['id_lst'][] = $tagName.'.'.$v;
512
+                $this->value['id_lst'][] = '*.' . $v;
513
+                $this->value['id_lst'][] = '.' . $v;
514
+                $this->value['id_lst'][] = $tagName . '.' . $v;
515 515
             }
516 516
         }
517 517
         if ($id) {
518
-            $this->value['id_lst'][] = '*#'.$id;
519
-            $this->value['id_lst'][] = '#'.$id;
520
-            $this->value['id_lst'][] = $tagName.'#'.$id;
518
+            $this->value['id_lst'][] = '*#' . $id;
519
+            $this->value['id_lst'][] = '#' . $id;
520
+            $this->value['id_lst'][] = $tagName . '#' . $id;
521 521
         }
522 522
 
523 523
         // CSS style
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
         if (isset($styles['stroke']))        $this->value['svg']['stroke']       = $this->convertToColor($styles['stroke'], $res);
530 530
         if (isset($styles['stroke-width']))  $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']);
531 531
         if (isset($styles['fill']))          $this->value['svg']['fill']         = $this->convertToColor($styles['fill'], $res);
532
-        if (isset($styles['fill-opacity']))  $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity'];
532
+        if (isset($styles['fill-opacity']))  $this->value['svg']['fill-opacity'] = 1. * $styles['fill-opacity'];
533 533
 
534 534
         return $this->value['svg'];
535 535
     }
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
     {
547 547
         // prepare the informations
548 548
         $tagName = strtolower($tagName);
549
-        $id   = isset($param['id'])   ? strtolower(trim($param['id']))    : null; if (!$id)   $id   = null;
550
-        $name = isset($param['name']) ? strtolower(trim($param['name']))  : null; if (!$name) $name = null;
549
+        $id   = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id)   $id   = null;
550
+        $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null;
551 551
 
552 552
         // get the class names to use
553 553
         $class = array();
@@ -568,15 +568,15 @@  discard block
 block discarded – undo
568 568
         $this->value['id_lst'][] = $tagName;
569 569
         if (count($class)) {
570 570
             foreach ($class as $v) {
571
-                $this->value['id_lst'][] = '*.'.$v;
572
-                $this->value['id_lst'][] = '.'.$v;
573
-                $this->value['id_lst'][] = $tagName.'.'.$v;
571
+                $this->value['id_lst'][] = '*.' . $v;
572
+                $this->value['id_lst'][] = '.' . $v;
573
+                $this->value['id_lst'][] = $tagName . '.' . $v;
574 574
             }
575 575
         }
576 576
         if ($id) {
577
-            $this->value['id_lst'][] = '*#'.$id;
578
-            $this->value['id_lst'][] = '#'.$id;
579
-            $this->value['id_lst'][] = $tagName.'#'.$id;
577
+            $this->value['id_lst'][] = '*#' . $id;
578
+            $this->value['id_lst'][] = '#' . $id;
579
+            $this->value['id_lst'][] = $tagName . '#' . $id;
580 580
         }
581 581
 
582 582
         // get the css styles from class
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
         if ($legacy) {
594 594
             foreach ($legacy as $legacyName => $legacyValue) {
595 595
                 if (is_array($legacyValue)) {
596
-                    foreach($legacyValue as $legacy2Name => $legacy2Value)
596
+                    foreach ($legacyValue as $legacy2Name => $legacy2Value)
597 597
                         $this->value[$legacyName][$legacy2Name] = $legacy2Value;
598 598
                 } else {
599 599
                     $this->value[$legacyName] = $legacyValue;
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 
608 608
         // read all the css styles
609 609
         foreach ($styles as $nom => $val) {
610
-            switch($nom)
610
+            switch ($nom)
611 611
             {
612 612
                 case 'font-family':
613 613
                     $val = explode(',', $val);
@@ -616,11 +616,11 @@  discard block
 block discarded – undo
616 616
                     break;
617 617
 
618 618
                 case 'font-weight':
619
-                    $this->value['font-bold'] = ($val=='bold');
619
+                    $this->value['font-bold'] = ($val == 'bold');
620 620
                     break;
621 621
 
622 622
                 case 'font-style':
623
-                    $this->value['font-italic'] = ($val=='italic');
623
+                    $this->value['font-italic'] = ($val == 'italic');
624 624
                     break;
625 625
 
626 626
                 case 'text-decoration':
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 
637 637
                 case 'text-transform':
638 638
                     if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none';
639
-                    $this->value['text-transform']  = $val;
639
+                    $this->value['text-transform'] = $val;
640 640
                     break;
641 641
 
642 642
                 case 'font-size':
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
                 case 'color':
648 648
                     $res = null;
649 649
                     $this->value['color'] = $this->convertToColor($val, $res);
650
-                    if ($tagName=='hr') {
650
+                    if ($tagName == 'hr') {
651 651
                         $this->value['border']['l']['color'] = $this->value['color'];
652 652
                         $this->value['border']['t']['color'] = $this->value['color'];
653 653
                         $this->value['border']['r']['color'] = $this->value['color'];
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 
668 668
                 case 'width':
669 669
                     $this->value['width'] = $this->convertToMM($val, $this->getLastWidth());
670
-                    if ($this->value['width'] && substr($val, -1)=='%') $correctWidth=true;
670
+                    if ($this->value['width'] && substr($val, -1) == '%') $correctWidth = true;
671 671
                     $noWidth = false;
672 672
                     break;
673 673
 
@@ -676,13 +676,13 @@  discard block
 block discarded – undo
676 676
                     break;
677 677
 
678 678
                 case 'line-height':
679
-                    if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val*100).'%';
679
+                    if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val * 100) . '%';
680 680
                     $this->value['line-height'] = $val;
681 681
                     break;
682 682
 
683 683
                 case 'rotate':
684 684
                     if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null;
685
-                    if ($val<0) $val+= 360;
685
+                    if ($val < 0) $val += 360;
686 686
                     $this->value['rotate'] = $val;
687 687
                     break;
688 688
 
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
                     $val = explode(' ', $val);
696 696
                     foreach ($val as $k => $v) {
697 697
                         $v = trim($v);
698
-                        if ($v!='') {
698
+                        if ($v != '') {
699 699
                             $val[$k] = $v;
700 700
                         } else {
701 701
                             unset($val[$k]);
@@ -726,14 +726,14 @@  discard block
 block discarded – undo
726 726
                     break;
727 727
 
728 728
                 case 'margin':
729
-                    if ($val=='auto') {
729
+                    if ($val == 'auto') {
730 730
                         $this->value['margin-auto'] = true;
731 731
                         break;
732 732
                     }
733 733
                     $val = explode(' ', $val);
734 734
                     foreach ($val as $k => $v) {
735 735
                         $v = trim($v);
736
-                        if ($v!='') {
736
+                        if ($v != '') {
737 737
                             $val[$k] = $v;
738 738
                         } else {
739 739
                             unset($val[$k]);
@@ -883,16 +883,16 @@  discard block
 block discarded – undo
883 883
                     break;
884 884
 
885 885
                 case 'border-collapse':
886
-                    if ($tagName=='table') $this->value['border']['collapse'] = ($val=='collapse');
886
+                    if ($tagName == 'table') $this->value['border']['collapse'] = ($val == 'collapse');
887 887
                     break;
888 888
 
889 889
                 case 'border-radius':
890 890
                     $val = explode('/', $val);
891
-                    if (count($val)>2) {
891
+                    if (count($val) > 2) {
892 892
                         break;
893 893
                     }
894 894
                     $valH = $this->convertToRadius(trim($val[0]));
895
-                    if (count($valH)<1 || count($valH)>4) {
895
+                    if (count($valH) < 1 || count($valH) > 4) {
896 896
                         break;
897 897
                     }
898 898
                     if (!isset($valH[1])) $valH[1] = $valH[0];
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
                     if (!isset($valH[3])) $valH[3] = $valH[1];
901 901
                     if (isset($val[1])) {
902 902
                         $valV = $this->convertToRadius(trim($val[1]));
903
-                        if (count($valV)<1 || count($valV)>4) {
903
+                        if (count($valV) < 1 || count($valV) > 4) {
904 904
                             break;
905 905
                         }
906 906
                         if (!isset($valV[1])) $valV[1] = $valV[0];
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 
920 920
                 case 'border-top-left-radius':
921 921
                     $val = $this->convertToRadius($val);
922
-                    if (count($val)<1 || count($val)>2) {
922
+                    if (count($val) < 1 || count($val) > 2) {
923 923
                         break;
924 924
                     }
925 925
                     $this->value['border']['radius']['tl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 
928 928
                 case 'border-top-right-radius':
929 929
                     $val = $this->convertToRadius($val);
930
-                    if (count($val)<1 || count($val)>2) {
930
+                    if (count($val) < 1 || count($val) > 2) {
931 931
                         break;
932 932
                     }
933 933
                     $this->value['border']['radius']['tr'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 
936 936
                 case 'border-bottom-right-radius':
937 937
                     $val = $this->convertToRadius($val);
938
-                    if (count($val)<1 || count($val)>2) {
938
+                    if (count($val) < 1 || count($val) > 2) {
939 939
                         break;
940 940
                     }
941 941
                     $this->value['border']['radius']['br'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 
944 944
                 case 'border-bottom-left-radius':
945 945
                     $val = $this->convertToRadius($val);
946
-                    if (count($val)<1 || count($val)>2) {
946
+                    if (count($val) < 1 || count($val) > 2) {
947 947
                         break;
948 948
                     }
949 949
                     $this->value['border']['radius']['bl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]);
@@ -987,21 +987,21 @@  discard block
 block discarded – undo
987 987
                     break;
988 988
 
989 989
                 case 'position':
990
-                    if ($val=='absolute')       $this->value['position'] = 'absolute';
991
-                    else if ($val=='relative')  $this->value['position'] = 'relative';
990
+                    if ($val == 'absolute')       $this->value['position'] = 'absolute';
991
+                    else if ($val == 'relative')  $this->value['position'] = 'relative';
992 992
                     else                        $this->value['position'] = null;
993 993
                     break;
994 994
 
995 995
                 case 'float':
996
-                    if ($val=='left')           $this->value['float'] = 'left';
997
-                    else if ($val=='right')     $this->value['float'] = 'right';
996
+                    if ($val == 'left')           $this->value['float'] = 'left';
997
+                    else if ($val == 'right')     $this->value['float'] = 'right';
998 998
                     else                        $this->value['float'] = null;
999 999
                     break;
1000 1000
 
1001 1001
                 case 'display':
1002
-                    if ($val=='inline')         $this->value['display'] = 'inline';
1003
-                    else if ($val=='block')     $this->value['display'] = 'block';
1004
-                    else if ($val=='none')      $this->value['display'] = 'none';
1002
+                    if ($val == 'inline')         $this->value['display'] = 'inline';
1003
+                    else if ($val == 'block')     $this->value['display'] = 'block';
1004
+                    else if ($val == 'none')      $this->value['display'] = 'none';
1005 1005
                     else                        $this->value['display'] = null;
1006 1006
                     break;
1007 1007
 
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
                 case 'list-style':
1016 1016
                 case 'list-style-type':
1017 1017
                 case 'list-style-image':
1018
-                    if ($nom=='list-style') $nom = 'list-style-type';
1018
+                    if ($nom == 'list-style') $nom = 'list-style-type';
1019 1019
                     $this->value[$nom] = $val;
1020 1020
                     break;
1021 1021
 
@@ -1027,27 +1027,27 @@  discard block
 block discarded – undo
1027 1027
         $return = true;
1028 1028
 
1029 1029
         // only for P tag
1030
-        if ($this->value['margin']['t']===null) $this->value['margin']['t'] = $this->value['font-size'];
1031
-        if ($this->value['margin']['b']===null) $this->value['margin']['b'] = $this->value['font-size'];
1030
+        if ($this->value['margin']['t'] === null) $this->value['margin']['t'] = $this->value['font-size'];
1031
+        if ($this->value['margin']['b'] === null) $this->value['margin']['b'] = $this->value['font-size'];
1032 1032
 
1033 1033
         // force the text align to left, if asked by html2pdf
1034 1034
         if ($this->_onlyLeft) $this->value['text-align'] = 'left';
1035 1035
 
1036 1036
         // correction on the width (quick box)
1037
-        if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position']!='absolute') {
1037
+        if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position'] != 'absolute') {
1038 1038
             $this->value['width'] = $this->getLastWidth();
1039
-            $this->value['width']-= $this->value['margin']['l'] + $this->value['margin']['r'];
1039
+            $this->value['width'] -= $this->value['margin']['l'] + $this->value['margin']['r'];
1040 1040
         } else {
1041 1041
             if ($correctWidth) {
1042 1042
                 if (!in_array($tagName, array('table', 'div', 'blockquote', 'fieldset', 'hr'))) {
1043
-                    $this->value['width']-= $this->value['padding']['l'] + $this->value['padding']['r'];
1044
-                    $this->value['width']-= $this->value['border']['l']['width'] + $this->value['border']['r']['width'];
1043
+                    $this->value['width'] -= $this->value['padding']['l'] + $this->value['padding']['r'];
1044
+                    $this->value['width'] -= $this->value['border']['l']['width'] + $this->value['border']['r']['width'];
1045 1045
                 }
1046 1046
                 if (in_array($tagName, array('th', 'td'))) {
1047
-                    $this->value['width']-= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
1047
+                    $this->value['width'] -= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
1048 1048
                     $return = false;
1049 1049
                 }
1050
-                if ($this->value['width']<0) $this->value['width']=0;
1050
+                if ($this->value['width'] < 0) $this->value['width'] = 0;
1051 1051
             } else {
1052 1052
                 if ($this->value['width']) {
1053 1053
                     if ($this->value['border']['l']['width']) $this->value['width'] += $this->value['border']['l']['width'];
@@ -1064,10 +1064,10 @@  discard block
 block discarded – undo
1064 1064
             if ($this->value['padding']['t'])         $this->value['height'] += $this->value['padding']['t'];
1065 1065
         }
1066 1066
 
1067
-        if ($this->value['top']!=null)      $this->value['top']     = $this->convertToMM($this->value['top'], $this->getLastHeight(true));
1068
-        if ($this->value['bottom']!=null)   $this->value['bottom']  = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true));
1069
-        if ($this->value['left']!=null)     $this->value['left']    = $this->convertToMM($this->value['left'], $this->getLastWidth(true));
1070
-        if ($this->value['right']!=null)    $this->value['right']   = $this->convertToMM($this->value['right'], $this->getLastWidth(true));
1067
+        if ($this->value['top'] != null)      $this->value['top']     = $this->convertToMM($this->value['top'], $this->getLastHeight(true));
1068
+        if ($this->value['bottom'] != null)   $this->value['bottom']  = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true));
1069
+        if ($this->value['left'] != null)     $this->value['left']    = $this->convertToMM($this->value['left'], $this->getLastWidth(true));
1070
+        if ($this->value['right'] != null)    $this->value['right']   = $this->convertToMM($this->value['right'], $this->getLastWidth(true));
1071 1071
 
1072 1072
         if ($this->value['top'] && $this->value['bottom'] && $this->value['height'])    $this->value['bottom']  = null;
1073 1073
         if ($this->value['left'] && $this->value['right'] && $this->value['width'])     $this->value['right']   = null;
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
     public function getLineHeight()
1085 1085
     {
1086 1086
         $val = $this->value['line-height'];
1087
-        if ($val=='normal') $val = '108%';
1087
+        if ($val == 'normal') $val = '108%';
1088 1088
         return $this->convertToMM($val, $this->value['font-size']);
1089 1089
     }
1090 1090
 
@@ -1097,12 +1097,12 @@  discard block
 block discarded – undo
1097 1097
      */
1098 1098
     public function getLastWidth($mode = false)
1099 1099
     {
1100
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1100
+        for ($k = count($this->table) - 1; $k >= 0; $k--) {
1101 1101
             if ($this->table[$k]['width']) {
1102 1102
                 $w = $this->table[$k]['width'];
1103 1103
                 if ($mode) {
1104
-                    $w+= $this->table[$k]['border']['l']['width'] + $this->table[$k]['padding']['l'] + 0.02;
1105
-                    $w+= $this->table[$k]['border']['r']['width'] + $this->table[$k]['padding']['r'] + 0.02;
1104
+                    $w += $this->table[$k]['border']['l']['width'] + $this->table[$k]['padding']['l'] + 0.02;
1105
+                    $w += $this->table[$k]['border']['r']['width'] + $this->table[$k]['padding']['r'] + 0.02;
1106 1106
                 }
1107 1107
                 return $w;
1108 1108
             }
@@ -1119,12 +1119,12 @@  discard block
 block discarded – undo
1119 1119
      */
1120 1120
     public function getLastHeight($mode = false)
1121 1121
     {
1122
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1122
+        for ($k = count($this->table) - 1; $k >= 0; $k--) {
1123 1123
             if ($this->table[$k]['height']) {
1124 1124
                 $h = $this->table[$k]['height'];
1125 1125
                 if ($mode) {
1126
-                    $h+= $this->table[$k]['border']['t']['width'] + $this->table[$k]['padding']['t'] + 0.02;
1127
-                    $h+= $this->table[$k]['border']['b']['width'] + $this->table[$k]['padding']['b'] + 0.02;
1126
+                    $h += $this->table[$k]['border']['t']['width'] + $this->table[$k]['padding']['t'] + 0.02;
1127
+                    $h += $this->table[$k]['border']['b']['width'] + $this->table[$k]['padding']['b'] + 0.02;
1128 1128
                 }
1129 1129
                 return $h;
1130 1130
             }
@@ -1140,8 +1140,8 @@  discard block
 block discarded – undo
1140 1140
      */
1141 1141
     public function getFloat()
1142 1142
     {
1143
-        if ($this->value['float']=='left')    return 'left';
1144
-        if ($this->value['float']=='right')   return 'right';
1143
+        if ($this->value['float'] == 'left')    return 'left';
1144
+        if ($this->value['float'] == 'right')   return 'right';
1145 1145
         return null;
1146 1146
     }
1147 1147
 
@@ -1155,8 +1155,8 @@  discard block
 block discarded – undo
1155 1155
     public function getLastValue($key)
1156 1156
     {
1157 1157
         $nb = count($this->table);
1158
-        if ($nb>0) {
1159
-            return $this->table[$nb-1][$key];
1158
+        if ($nb > 0) {
1159
+            return $this->table[$nb - 1][$key];
1160 1160
         } else {
1161 1161
             return null;
1162 1162
         }
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
      */
1171 1171
     protected function _getLastAbsoluteX()
1172 1172
     {
1173
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1173
+        for ($k = count($this->table) - 1; $k >= 0; $k--) {
1174 1174
             if ($this->table[$k]['x'] && $this->table[$k]['position']) return $this->table[$k]['x'];
1175 1175
         }
1176 1176
         return $this->_pdf->getlMargin();
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
      */
1185 1185
     protected function _getLastAbsoluteY()
1186 1186
     {
1187
-        for ($k=count($this->table)-1; $k>=0; $k--) {
1187
+        for ($k = count($this->table) - 1; $k >= 0; $k--) {
1188 1188
             if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y'];
1189 1189
         }
1190 1190
         return $this->_pdf->gettMargin();
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
         // get the list of the selectors of each tags
1208 1208
         $lst = array();
1209 1209
         $lst[] = $this->value['id_lst'];
1210
-        for ($i=count($this->table)-1; $i>=0; $i--) {
1210
+        for ($i = count($this->table) - 1; $i >= 0; $i--) {
1211 1211
             $lst[] = $this->table[$i]['id_lst'];
1212 1212
         }
1213 1213
 
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
     protected function _getReccursiveStyle($key, $lst, $next = null)
1241 1241
     {
1242 1242
         // if next step
1243
-        if ($next!==null) {
1243
+        if ($next !== null) {
1244 1244
             // we remove this step
1245 1245
             if ($next) $key = trim(substr($key, 0, -strlen($next)));
1246 1246
             array_shift($lst);
@@ -1254,18 +1254,18 @@  discard block
 block discarded – undo
1254 1254
         // for each selector of the current step
1255 1255
         foreach ($lst[0] as $name) {
1256 1256
             // if selector = key => ok
1257
-            if ($key==$name) {
1257
+            if ($key == $name) {
1258 1258
                 return true;
1259 1259
             }
1260 1260
 
1261 1261
             // if the end of the key = the selector and the next step is ok => ok
1262
-            if (substr($key, -strlen(' '.$name))==' '.$name && $this->_getReccursiveStyle($key, $lst, $name)) {
1262
+            if (substr($key, -strlen(' ' . $name)) == ' ' . $name && $this->_getReccursiveStyle($key, $lst, $name)) {
1263 1263
                 return true;
1264 1264
             }
1265 1265
         }
1266 1266
 
1267 1267
         // if we are not in the first step, we analyse the sub steps (the pareng tag of the current tag)
1268
-        if ($next!==null && $this->_getReccursiveStyle($key, $lst, '')) {
1268
+        if ($next !== null && $this->_getReccursiveStyle($key, $lst, '')) {
1269 1269
             return true;
1270 1270
         }
1271 1271
 
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
         foreach ($css as $value) {
1305 1305
 
1306 1306
             // if no border => return none
1307
-            if ($value=='none' || $value=='hidden') {
1307
+            if ($value == 'none' || $value == 'hidden') {
1308 1308
                 return $none;
1309 1309
             }
1310 1310
 
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
             $tmp = $this->convertToMM($value);
1313 1313
 
1314 1314
             // if the convert is ok => it is a width
1315
-            if ($tmp!==null) {
1315
+            if ($tmp !== null) {
1316 1316
                 $width = $tmp;
1317 1317
             // else, it could be the type
1318 1318
             } else if (in_array($value, array('solid', 'dotted', 'dashed', 'double'))) {
@@ -1340,16 +1340,16 @@  discard block
 block discarded – undo
1340 1340
     protected function _duplicateBorder(&$val)
1341 1341
     {
1342 1342
         // 1 value => L => RTB
1343
-        if (count($val)==1) {
1343
+        if (count($val) == 1) {
1344 1344
             $val[1] = $val[0];
1345 1345
             $val[2] = $val[0];
1346 1346
             $val[3] = $val[0];
1347 1347
         // 2 values => L => R & T => B
1348
-        } else if (count($val)==2) {
1348
+        } else if (count($val) == 2) {
1349 1349
             $val[2] = $val[0];
1350 1350
             $val[3] = $val[1];
1351 1351
         // 3 values => T => B
1352
-        } else if (count($val)==3) {
1352
+        } else if (count($val) == 3) {
1353 1353
             $val[3] = $val[1];
1354 1354
         }
1355 1355
     }
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
             if ($ok) {
1394 1394
                 $value['color'] = $color;
1395 1395
             // else if transparent => no coloàr
1396
-            } else if ($val=='transparent') {
1396
+            } else if ($val == 'transparent') {
1397 1397
                 $value['color'] = null;
1398 1398
             // else
1399 1399
             } else {
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
                     $value['repeat'] = $repeat;
1406 1406
                 // else => it could only be a position
1407 1407
                 } else {
1408
-                    $pos.= ($pos ? ' ' : '').$val;
1408
+                    $pos .= ($pos ? ' ' : '') . $val;
1409 1409
                 }
1410 1410
             }
1411 1411
         }
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
     public function convertBackgroundColor($css)
1429 1429
     {
1430 1430
         $res = null;
1431
-        if ($css=='transparent') return null;
1431
+        if ($css == 'transparent') return null;
1432 1432
         else                     return $this->convertToColor($css, $res);
1433 1433
     }
1434 1434
 
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
      */
1442 1442
     public function convertBackgroundImage($css)
1443 1443
     {
1444
-        if ($css=='none')
1444
+        if ($css == 'none')
1445 1445
             return null;
1446 1446
         else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match))
1447 1447
             return $match[1];
@@ -1466,11 +1466,11 @@  discard block
 block discarded – undo
1466 1466
         $css = explode(' ', $css);
1467 1467
 
1468 1468
         // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2
1469
-        if (count($css)<2) {
1469
+        if (count($css) < 2) {
1470 1470
             if (!$css[0]) return null;
1471 1471
             $css[1] = 'center';
1472 1472
         }
1473
-        if (count($css)>2) return null;
1473
+        if (count($css) > 2) return null;
1474 1474
 
1475 1475
         // prepare the values
1476 1476
         $x = 0;
@@ -1478,21 +1478,21 @@  discard block
 block discarded – undo
1478 1478
         $res = true;
1479 1479
 
1480 1480
         // convert the first value
1481
-        if ($css[0]=='left')        $x = '0%';
1482
-        else if ($css[0]=='center') $x = '50%';
1483
-        else if ($css[0]=='right')  $x = '100%';
1484
-        else if ($css[0]=='top')    $y = '0%';
1485
-        else if ($css[0]=='bottom') $y = '100%';
1481
+        if ($css[0] == 'left')        $x = '0%';
1482
+        else if ($css[0] == 'center') $x = '50%';
1483
+        else if ($css[0] == 'right')  $x = '100%';
1484
+        else if ($css[0] == 'top')    $y = '0%';
1485
+        else if ($css[0] == 'bottom') $y = '100%';
1486 1486
         else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0];
1487 1487
         else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]);
1488 1488
         else $res = false;
1489 1489
 
1490 1490
         // convert the second value
1491
-        if ($css[1]=='left')        $x = '0%';
1492
-        else if ($css[1]=='right')  $x = '100%';
1493
-        else if ($css[1]=='top')    $y = '0%';
1494
-        else if ($css[1]=='center') $y = '50%';
1495
-        else if ($css[1]=='bottom') $y = '100%';
1491
+        if ($css[1] == 'left')        $x = '0%';
1492
+        else if ($css[1] == 'right')  $x = '100%';
1493
+        else if ($css[1] == 'top')    $y = '0%';
1494
+        else if ($css[1] == 'center') $y = '50%';
1495
+        else if ($css[1] == 'bottom') $y = '100%';
1496 1496
         else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1];
1497 1497
         else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]);
1498 1498
         else $res = false;
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
      */
1511 1511
     public function convertBackgroundRepeat($css)
1512 1512
     {
1513
-        switch($css)
1513
+        switch ($css)
1514 1514
         {
1515 1515
             case 'repeat':
1516 1516
                 return array(true, true);
@@ -1532,15 +1532,15 @@  discard block
 block discarded – undo
1532 1532
      * @param  float  $old parent distance
1533 1533
      * @return float  $value
1534 1534
      */
1535
-    public function convertToMM($css, $old=0.)
1535
+    public function convertToMM($css, $old = 0.)
1536 1536
     {
1537 1537
         $css = trim($css);
1538
-        if (preg_match('/^[0-9\.\-]+$/isU', $css))        $css.= 'px';
1539
-        if (preg_match('/^[0-9\.\-]+px$/isU', $css))      $css = 25.4/96. * str_replace('px', '', $css);
1540
-        else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css);
1538
+        if (preg_match('/^[0-9\.\-]+$/isU', $css))        $css .= 'px';
1539
+        if (preg_match('/^[0-9\.\-]+px$/isU', $css))      $css = 25.4 / 96. * str_replace('px', '', $css);
1540
+        else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4 / 72. * str_replace('pt', '', $css);
1541 1541
         else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css);
1542
-        else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css);
1543
-        else if (preg_match('/^[0-9\.\-]+%$/isU', $css))  $css = 1.*$old*str_replace('%', '', $css)/100.;
1542
+        else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1. * str_replace('mm', '', $css);
1543
+        else if (preg_match('/^[0-9\.\-]+%$/isU', $css))  $css = 1. * $old * str_replace('%', '', $css) / 100.;
1544 1544
         else                                              $css = null;
1545 1545
 
1546 1546
         return $css;
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
             $v = trim($v);
1563 1563
             if ($v) {
1564 1564
                 $v = $this->convertToMM($v, 0);
1565
-                if ($v!==null) {
1565
+                if ($v !== null) {
1566 1566
                     $css[$k] = $v;
1567 1567
                 } else {
1568 1568
                     unset($css[$k]);
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
         $res = true;
1591 1591
 
1592 1592
         // if transparent => return null
1593
-        if (strtolower($css)=='transparent') return array(null, null, null);
1593
+        if (strtolower($css) == 'transparent') return array(null, null, null);
1594 1594
 
1595 1595
         // HTML color
1596 1596
         if (isset($this->_htmlColor[strtolower($css)])) {
@@ -1611,9 +1611,9 @@  discard block
 block discarded – undo
1611 1611
 
1612 1612
         // like #FFF
1613 1613
         if (preg_match('/^#[0-9A-F]{3}$/isU', $css)) {
1614
-            $r = floatVal(hexdec(substr($css, 1, 1).substr($css, 1, 1)));
1615
-            $v = floatVal(hexdec(substr($css, 2, 1).substr($css, 2, 1)));
1616
-            $b = floatVal(hexdec(substr($css, 3, 1).substr($css, 3, 1)));
1614
+            $r = floatVal(hexdec(substr($css, 1, 1) . substr($css, 1, 1)));
1615
+            $v = floatVal(hexdec(substr($css, 2, 1) . substr($css, 2, 1)));
1616
+            $b = floatVal(hexdec(substr($css, 3, 1) . substr($css, 3, 1)));
1617 1617
             return array($r, $v, $b);
1618 1618
         }
1619 1619
 
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
             $r = $this->_convertSubColor($match[1]);
1623 1623
             $v = $this->_convertSubColor($match[2]);
1624 1624
             $b = $this->_convertSubColor($match[3]);
1625
-            return array($r*255., $v*255., $b*255.);
1625
+            return array($r * 255., $v * 255., $b * 255.);
1626 1626
         }
1627 1627
 
1628 1628
         // like cmyk(100, 100, 100, 100)
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
             $m = $this->_convertSubColor($match[2]);
1632 1632
             $y = $this->_convertSubColor($match[3]);
1633 1633
             $k = $this->_convertSubColor($match[4]);
1634
-            return array($c*100., $m*100., $y*100., $k*100.);
1634
+            return array($c * 100., $m * 100., $y * 100., $k * 100.);
1635 1635
         }
1636 1636
 
1637 1637
         $res = false;
@@ -1647,11 +1647,11 @@  discard block
 block discarded – undo
1647 1647
      */
1648 1648
     protected function _convertSubColor($c)
1649 1649
     {
1650
-        if (substr($c, -1)=='%') {
1651
-            $c = floatVal(substr($c, 0, -1))/100.;
1650
+        if (substr($c, -1) == '%') {
1651
+            $c = floatVal(substr($c, 0, -1)) / 100.;
1652 1652
         } else {
1653 1653
             $c = floatVal($c);
1654
-            if ($c>1) $c = $c/255.;
1654
+            if ($c > 1) $c = $c / 255.;
1655 1655
         }
1656 1656
 
1657 1657
         return $c;
@@ -1675,7 +1675,7 @@  discard block
 block discarded – undo
1675 1675
         preg_match_all('/([^{}]+){([^}]*)}/isU', $code, $match);
1676 1676
 
1677 1677
         // for each CSS code
1678
-        for ($k=0; $k<count($match[0]); $k++) {
1678
+        for ($k = 0; $k < count($match[0]); $k++) {
1679 1679
 
1680 1680
             // selectors
1681 1681
             $names = strtolower(trim($match[1][$k]));
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
             $css = array();
1691 1691
             foreach ($styles as $style) {
1692 1692
                 $tmp = explode(':', $style);
1693
-                if (count($tmp)>1) {
1693
+                if (count($tmp) > 1) {
1694 1694
                     $cod = $tmp[0]; unset($tmp[0]); $tmp = implode(':', $tmp);
1695 1695
                     $css[trim(strtolower($cod))] = trim($tmp);
1696 1696
                 }
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
                 $name = trim($name);
1706 1706
 
1707 1707
                 // if a selector with somethink lige :hover => continue
1708
-                if (strpos($name, ':')!==false) continue;
1708
+                if (strpos($name, ':') !== false) continue;
1709 1709
 
1710 1710
                 // save the value
1711 1711
                 if (!isset($this->css[$name]))
@@ -1742,27 +1742,27 @@  discard block
 block discarded – undo
1742 1742
 
1743 1743
             // read the attributes name=value
1744 1744
             $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
1745
-            preg_match_all('/'.$prop.'/is', $code, $match);
1746
-            for ($k=0; $k<count($match[0]); $k++) {
1745
+            preg_match_all('/' . $prop . '/is', $code, $match);
1746
+            for ($k = 0; $k < count($match[0]); $k++) {
1747 1747
                 $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1748 1748
             }
1749 1749
 
1750 1750
             // read the attributes name="value"
1751 1751
             $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
1752
-            preg_match_all('/'.$prop.'/is', $code, $match);
1753
-            for ($k=0; $k<count($match[0]); $k++) {
1752
+            preg_match_all('/' . $prop . '/is', $code, $match);
1753
+            for ($k = 0; $k < count($match[0]); $k++) {
1754 1754
                 $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1755 1755
             }
1756 1756
 
1757 1757
             // read the attributes name='value'
1758 1758
             $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
1759
-            preg_match_all('/'.$prop.'/is', $code, $match);
1760
-            for ($k=0; $k<count($match[0]); $k++) {
1759
+            preg_match_all('/' . $prop . '/is', $code, $match);
1760
+            for ($k = 0; $k < count($match[0]); $k++) {
1761 1761
                 $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
1762 1762
             }
1763 1763
 
1764 1764
             // if type text/css => we keep it
1765
-            if (isset($tmp['type']) && strtolower($tmp['type'])=='text/css' && isset($tmp['href'])) {
1765
+            if (isset($tmp['type']) && strtolower($tmp['type']) == 'text/css' && isset($tmp['href'])) {
1766 1766
 
1767 1767
                 // get the href
1768 1768
                 $url = $tmp['href'];
@@ -1771,26 +1771,26 @@  discard block
 block discarded – undo
1771 1771
                 $content = @file_get_contents($url);
1772 1772
 
1773 1773
                 // if "http://" in the url
1774
-                if (strpos($url, 'http://')!==false) {
1774
+                if (strpos($url, 'http://') !== false) {
1775 1775
 
1776 1776
                     // get the domain "http://xxx/"
1777 1777
                     $url = str_replace('http://', '', $url);
1778 1778
                     $url = explode('/', $url);
1779
-                    $urlMain = 'http://'.$url[0].'/';
1779
+                    $urlMain = 'http://' . $url[0] . '/';
1780 1780
 
1781 1781
                     // get the absolute url of the path
1782
-                    $urlSelf = $url; unset($urlSelf[count($urlSelf)-1]); $urlSelf = 'http://'.implode('/', $urlSelf).'/';
1782
+                    $urlSelf = $url; unset($urlSelf[count($urlSelf) - 1]); $urlSelf = 'http://' . implode('/', $urlSelf) . '/';
1783 1783
 
1784 1784
                     // adapt the url in the css content
1785
-                    $content = preg_replace('/url\(([^\\\\][^)]*)\)/isU', 'url('.$urlSelf.'$1)', $content);
1786
-                    $content = preg_replace('/url\((\\\\[^)]*)\)/isU', 'url('.$urlMain.'$1)', $content);
1785
+                    $content = preg_replace('/url\(([^\\\\][^)]*)\)/isU', 'url(' . $urlSelf . '$1)', $content);
1786
+                    $content = preg_replace('/url\((\\\\[^)]*)\)/isU', 'url(' . $urlMain . '$1)', $content);
1787 1787
                 } else {
1788 1788
 // @TODO correction on url in absolute on a local css content
1789 1789
                     // $content = preg_replace('/url\(([^)]*)\)/isU', 'url('.dirname($url).'/$1)', $content);
1790 1790
                 }
1791 1791
 
1792 1792
                 // add to the CSS content
1793
-                $style.= $content."\n";
1793
+                $style .= $content . "\n";
1794 1794
             }
1795 1795
         }
1796 1796
 
@@ -1803,7 +1803,7 @@  discard block
 block discarded – undo
1803 1803
             // add to the CSS content
1804 1804
             $code = str_replace('<!--', '', $code);
1805 1805
             $code = str_replace('-->', '', $code);
1806
-            $style.= $code."\n";
1806
+            $style .= $code . "\n";
1807 1807
         }
1808 1808
 
1809 1809
         //analyse the css content
Please login to merge, or discard this patch.
Braces   +392 added lines, -156 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * HTML2PDF Librairy - parsingCss class
4 6
  *
@@ -82,7 +84,9 @@  discard block
 block discarded – undo
82 84
     {
83 85
         $old = $this->_defaultFont;
84 86
         $this->_defaultFont = $default;
85
-        if ($default) $this->value['font-family'] = $default;
87
+        if ($default) {
88
+        	$this->value['font-family'] = $default;
89
+        }
86 90
         return $old;
87 91
     }
88 92
 
@@ -179,7 +183,9 @@  discard block
 block discarded – undo
179 183
 
180 184
         // prepare the Collapse attribute
181 185
         $collapse = isset($this->value['border']['collapse']) ? $this->value['border']['collapse'] : false;
182
-        if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) $collapse = false;
186
+        if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) {
187
+        	$collapse = false;
188
+        }
183 189
 
184 190
         // set the global css values
185 191
         $this->value['position']   = null;
@@ -315,20 +321,23 @@  discard block
 block discarded – undo
315 321
         $style = $b.$i;
316 322
 
317 323
         if ($this->_defaultFont) {
318
-            if($family=='arial')
319
-                $family='helvetica';
320
-            elseif($family=='symbol' || $family=='zapfdingbats')
321
-                $style='';
324
+            if($family=='arial') {
325
+                            $family='helvetica';
326
+            } elseif($family=='symbol' || $family=='zapfdingbats') {
327
+                            $style='';
328
+            }
322 329
 
323 330
             $fontkey = $family.$style;
324
-            if (!$this->_pdf->isLoadedFont($fontkey))
325
-                $family = $this->_defaultFont;
331
+            if (!$this->_pdf->isLoadedFont($fontkey)) {
332
+                            $family = $this->_defaultFont;
333
+            }
326 334
         }
327 335
 
328
-        if($family=='arial')
329
-            $family='helvetica';
330
-        elseif($family=='symbol' || $family=='zapfdingbats')
331
-            $style='';
336
+        if($family=='arial') {
337
+                    $family='helvetica';
338
+        } elseif($family=='symbol' || $family=='zapfdingbats') {
339
+                    $style='';
340
+        }
332 341
 
333 342
         // complete style
334 343
         $style.= $u.$d.$o;
@@ -340,10 +349,11 @@  discard block
 block discarded – undo
340 349
         // apply the font
341 350
         $this->_pdf->SetFont($family, $style, $this->value['mini-size']*$size);
342 351
         $this->_pdf->setTextColorArray($this->value['color']);
343
-        if ($this->value['background']['color'])
344
-            $this->_pdf->setFillColorArray($this->value['background']['color']);
345
-        else
346
-            $this->_pdf->setFillColor(255);
352
+        if ($this->value['background']['color']) {
353
+                    $this->_pdf->setFillColorArray($this->value['background']['color']);
354
+        } else {
355
+                    $this->_pdf->setFillColor(255);
356
+        }
347 357
     }
348 358
 
349 359
      /**
@@ -375,7 +385,9 @@  discard block
 block discarded – undo
375 385
      */
376 386
     public function restorePosition()
377 387
     {
378
-        if ($this->value['y']==$this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false);
388
+        if ($this->value['y']==$this->_pdf->getY()) {
389
+        	$this->_pdf->setY($this->value['yc'], false);
390
+        }
379 391
     }
380 392
 
381 393
      /**
@@ -396,18 +408,26 @@  discard block
 block discarded – undo
396 408
         if ($this->value['position']=='relative' || $this->value['position']=='absolute') {
397 409
             if ($this->value['right']!==null) {
398 410
                 $x = $this->getLastWidth(true) - $this->value['right'] - $this->value['width'];
399
-                if ($this->value['margin']['r']) $x-= $this->value['margin']['r'];
411
+                if ($this->value['margin']['r']) {
412
+                	$x-= $this->value['margin']['r'];
413
+                }
400 414
             } else {
401 415
                 $x = $this->value['left'];
402
-                if ($this->value['margin']['l']) $x+= $this->value['margin']['l'];
416
+                if ($this->value['margin']['l']) {
417
+                	$x+= $this->value['margin']['l'];
418
+                }
403 419
             }
404 420
 
405 421
             if ($this->value['bottom']!==null) {
406 422
                 $y = $this->getLastHeight(true) - $this->value['bottom'] - $this->value['height'];
407
-                if ($this->value['margin']['b']) $y-= $this->value['margin']['b'];
423
+                if ($this->value['margin']['b']) {
424
+                	$y-= $this->value['margin']['b'];
425
+                }
408 426
             } else {
409 427
                 $y = $this->value['top'];
410
-                if ($this->value['margin']['t']) $y+= $this->value['margin']['t'];
428
+                if ($this->value['margin']['t']) {
429
+                	$y+= $this->value['margin']['t'];
430
+                }
411 431
             }
412 432
 
413 433
             if ($this->value['position']=='relative') {
@@ -420,8 +440,12 @@  discard block
 block discarded – undo
420 440
         } else {
421 441
             $this->value['x'] = $currentX;
422 442
             $this->value['y'] = $currentY;
423
-            if ($this->value['margin']['l']) $this->value['x']+= $this->value['margin']['l'];
424
-            if ($this->value['margin']['t']) $this->value['y']+= $this->value['margin']['t'];
443
+            if ($this->value['margin']['l']) {
444
+            	$this->value['x']+= $this->value['margin']['l'];
445
+            }
446
+            if ($this->value['margin']['t']) {
447
+            	$this->value['y']+= $this->value['margin']['t'];
448
+            }
425 449
         }
426 450
 
427 451
         // save the new position
@@ -478,8 +502,12 @@  discard block
 block discarded – undo
478 502
     {
479 503
         // prepare
480 504
         $tagName = strtolower($tagName);
481
-        $id   = isset($param['id'])   ? strtolower(trim($param['id']))   : null; if (!$id)   $id   = null;
482
-        $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null;
505
+        $id   = isset($param['id'])   ? strtolower(trim($param['id']))   : null; if (!$id) {
506
+        	$id   = null;
507
+        }
508
+        $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) {
509
+        	$name = null;
510
+        }
483 511
 
484 512
         // read the class attribute
485 513
         $class = array();
@@ -487,7 +515,9 @@  discard block
 block discarded – undo
487 515
         $tmp = explode(' ', $tmp);
488 516
         foreach ($tmp as $k => $v) {
489 517
             $v = trim($v);
490
-            if ($v) $class[] = $v;
518
+            if ($v) {
519
+            	$class[] = $v;
520
+            }
491 521
         }
492 522
 
493 523
         // identify the tag, and the direct styles
@@ -526,10 +556,18 @@  discard block
 block discarded – undo
526 556
         // adding the style from the tag
527 557
         $styles = array_merge($styles, $param['style']);
528 558
 
529
-        if (isset($styles['stroke']))        $this->value['svg']['stroke']       = $this->convertToColor($styles['stroke'], $res);
530
-        if (isset($styles['stroke-width']))  $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']);
531
-        if (isset($styles['fill']))          $this->value['svg']['fill']         = $this->convertToColor($styles['fill'], $res);
532
-        if (isset($styles['fill-opacity']))  $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity'];
559
+        if (isset($styles['stroke'])) {
560
+        	$this->value['svg']['stroke']       = $this->convertToColor($styles['stroke'], $res);
561
+        }
562
+        if (isset($styles['stroke-width'])) {
563
+        	$this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']);
564
+        }
565
+        if (isset($styles['fill'])) {
566
+        	$this->value['svg']['fill']         = $this->convertToColor($styles['fill'], $res);
567
+        }
568
+        if (isset($styles['fill-opacity'])) {
569
+        	$this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity'];
570
+        }
533 571
 
534 572
         return $this->value['svg'];
535 573
     }
@@ -546,8 +584,12 @@  discard block
 block discarded – undo
546 584
     {
547 585
         // prepare the informations
548 586
         $tagName = strtolower($tagName);
549
-        $id   = isset($param['id'])   ? strtolower(trim($param['id']))    : null; if (!$id)   $id   = null;
550
-        $name = isset($param['name']) ? strtolower(trim($param['name']))  : null; if (!$name) $name = null;
587
+        $id   = isset($param['id'])   ? strtolower(trim($param['id']))    : null; if (!$id) {
588
+        	$id   = null;
589
+        }
590
+        $name = isset($param['name']) ? strtolower(trim($param['name']))  : null; if (!$name) {
591
+        	$name = null;
592
+        }
551 593
 
552 594
         // get the class names to use
553 595
         $class = array();
@@ -555,7 +597,9 @@  discard block
 block discarded – undo
555 597
         $tmp = explode(' ', $tmp);
556 598
         foreach ($tmp as $k => $v) {
557 599
             $v = trim($v);
558
-            if ($v) $class[] = $v;
600
+            if ($v) {
601
+            	$class[] = $v;
602
+            }
559 603
         }
560 604
 
561 605
         // prepare the values, and the list of css tags to identify
@@ -584,7 +628,9 @@  discard block
 block discarded – undo
584 628
 
585 629
         // merge with the css styles from tag
586 630
         $styles = array_merge($styles, $param['style']);
587
-        if (isset($param['allwidth']) && !isset($styles['width'])) $styles['width'] = '100%';
631
+        if (isset($param['allwidth']) && !isset($styles['width'])) {
632
+        	$styles['width'] = '100%';
633
+        }
588 634
 
589 635
         // reset some styles, depending on the tag name
590 636
         $this->resetStyle($tagName);
@@ -593,8 +639,9 @@  discard block
 block discarded – undo
593 639
         if ($legacy) {
594 640
             foreach ($legacy as $legacyName => $legacyValue) {
595 641
                 if (is_array($legacyValue)) {
596
-                    foreach($legacyValue as $legacy2Name => $legacy2Value)
597
-                        $this->value[$legacyName][$legacy2Name] = $legacy2Value;
642
+                    foreach($legacyValue as $legacy2Name => $legacy2Value) {
643
+                                            $this->value[$legacyName][$legacy2Name] = $legacy2Value;
644
+                    }
598 645
                 } else {
599 646
                     $this->value[$legacyName] = $legacyValue;
600 647
                 }
@@ -612,7 +659,9 @@  discard block
 block discarded – undo
612 659
                 case 'font-family':
613 660
                     $val = explode(',', $val);
614 661
                     $val = trim($val[0]);
615
-                    if ($val) $this->value['font-family'] = $val;
662
+                    if ($val) {
663
+                    	$this->value['font-family'] = $val;
664
+                    }
616 665
                     break;
617 666
 
618 667
                 case 'font-weight':
@@ -635,13 +684,17 @@  discard block
 block discarded – undo
635 684
                     break;
636 685
 
637 686
                 case 'text-transform':
638
-                    if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none';
687
+                    if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) {
688
+                    	$val = 'none';
689
+                    }
639 690
                     $this->value['text-transform']  = $val;
640 691
                     break;
641 692
 
642 693
                 case 'font-size':
643 694
                     $val = $this->convertToMM($val, $this->value['font-size']);
644
-                    if ($val) $this->value['font-size'] = $val;
695
+                    if ($val) {
696
+                    	$this->value['font-size'] = $val;
697
+                    }
645 698
                     break;
646 699
 
647 700
                 case 'color':
@@ -657,7 +710,9 @@  discard block
 block discarded – undo
657 710
 
658 711
                 case 'text-align':
659 712
                     $val = strtolower($val);
660
-                    if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) $val = 'left';
713
+                    if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) {
714
+                    	$val = 'left';
715
+                    }
661 716
                     $this->value['text-align'] = $val;
662 717
                     break;
663 718
 
@@ -667,7 +722,9 @@  discard block
 block discarded – undo
667 722
 
668 723
                 case 'width':
669 724
                     $this->value['width'] = $this->convertToMM($val, $this->getLastWidth());
670
-                    if ($this->value['width'] && substr($val, -1)=='%') $correctWidth=true;
725
+                    if ($this->value['width'] && substr($val, -1)=='%') {
726
+                    	$correctWidth=true;
727
+                    }
671 728
                     $noWidth = false;
672 729
                     break;
673 730
 
@@ -676,18 +733,26 @@  discard block
 block discarded – undo
676 733
                     break;
677 734
 
678 735
                 case 'line-height':
679
-                    if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val*100).'%';
736
+                    if (preg_match('/^[0-9\.]+$/isU', $val)) {
737
+                    	$val = floor($val*100).'%';
738
+                    }
680 739
                     $this->value['line-height'] = $val;
681 740
                     break;
682 741
 
683 742
                 case 'rotate':
684
-                    if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null;
685
-                    if ($val<0) $val+= 360;
743
+                    if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) {
744
+                    	$val = null;
745
+                    }
746
+                    if ($val<0) {
747
+                    	$val+= 360;
748
+                    }
686 749
                     $this->value['rotate'] = $val;
687 750
                     break;
688 751
 
689 752
                 case 'overflow':
690
-                    if (!in_array($val, array('visible', 'hidden'))) $val = 'visible';
753
+                    if (!in_array($val, array('visible', 'hidden'))) {
754
+                    	$val = 'visible';
755
+                    }
691 756
                     $this->value['overflow'] = $val;
692 757
                     break;
693 758
 
@@ -779,10 +844,18 @@  discard block
 block discarded – undo
779 844
                         }
780 845
                     }
781 846
                     $this->_duplicateBorder($val);
782
-                    if ($val[0]) $this->value['border']['t']['type'] = $val[0];
783
-                    if ($val[1]) $this->value['border']['r']['type'] = $val[1];
784
-                    if ($val[2]) $this->value['border']['b']['type'] = $val[2];
785
-                    if ($val[3]) $this->value['border']['l']['type'] = $val[3];
847
+                    if ($val[0]) {
848
+                    	$this->value['border']['t']['type'] = $val[0];
849
+                    }
850
+                    if ($val[1]) {
851
+                    	$this->value['border']['r']['type'] = $val[1];
852
+                    }
853
+                    if ($val[2]) {
854
+                    	$this->value['border']['b']['type'] = $val[2];
855
+                    }
856
+                    if ($val[3]) {
857
+                    	$this->value['border']['l']['type'] = $val[3];
858
+                    }
786 859
                     break;
787 860
 
788 861
                 case 'border-top-style':
@@ -804,8 +877,9 @@  discard block
 block discarded – undo
804 877
                     break;
805 878
 
806 879
                 case 'border-left-style':
807
-                    if (in_array($val, array('solid', 'dotted', 'dashed')))
808
-                        $this->value['border']['l']['type'] = $val;
880
+                    if (in_array($val, array('solid', 'dotted', 'dashed'))) {
881
+                                            $this->value['border']['l']['type'] = $val;
882
+                    }
809 883
                     break;
810 884
 
811 885
                 case 'border-color':
@@ -819,35 +893,51 @@  discard block
 block discarded – undo
819 893
                             }
820 894
                     }
821 895
                     $this->_duplicateBorder($val);
822
-                    if (is_array($val[0])) $this->value['border']['t']['color'] = $val[0];
823
-                    if (is_array($val[1])) $this->value['border']['r']['color'] = $val[1];
824
-                    if (is_array($val[2])) $this->value['border']['b']['color'] = $val[2];
825
-                    if (is_array($val[3])) $this->value['border']['l']['color'] = $val[3];
896
+                    if (is_array($val[0])) {
897
+                    	$this->value['border']['t']['color'] = $val[0];
898
+                    }
899
+                    if (is_array($val[1])) {
900
+                    	$this->value['border']['r']['color'] = $val[1];
901
+                    }
902
+                    if (is_array($val[2])) {
903
+                    	$this->value['border']['b']['color'] = $val[2];
904
+                    }
905
+                    if (is_array($val[3])) {
906
+                    	$this->value['border']['l']['color'] = $val[3];
907
+                    }
826 908
 
827 909
                     break;
828 910
 
829 911
                 case 'border-top-color':
830 912
                     $res = false;
831 913
                     $val = $this->convertToColor($val, $res);
832
-                    if ($res) $this->value['border']['t']['color'] = $val;
914
+                    if ($res) {
915
+                    	$this->value['border']['t']['color'] = $val;
916
+                    }
833 917
                     break;
834 918
 
835 919
                 case 'border-right-color':
836 920
                     $res = false;
837 921
                     $val = $this->convertToColor($val, $res);
838
-                    if ($res) $this->value['border']['r']['color'] = $val;
922
+                    if ($res) {
923
+                    	$this->value['border']['r']['color'] = $val;
924
+                    }
839 925
                     break;
840 926
 
841 927
                 case 'border-bottom-color':
842 928
                     $res = false;
843 929
                     $val = $this->convertToColor($val, $res);
844
-                    if ($res) $this->value['border']['b']['color'] = $val;
930
+                    if ($res) {
931
+                    	$this->value['border']['b']['color'] = $val;
932
+                    }
845 933
                     break;
846 934
 
847 935
                 case 'border-left-color':
848 936
                     $res = false;
849 937
                     $val = $this->convertToColor($val, $res);
850
-                    if ($res) $this->value['border']['l']['color'] = $val;
938
+                    if ($res) {
939
+                    	$this->value['border']['l']['color'] = $val;
940
+                    }
851 941
                     break;
852 942
 
853 943
                 case 'border-width':
@@ -856,34 +946,52 @@  discard block
 block discarded – undo
856 946
                             $val[$valK] = $this->convertToMM($valV, 0);
857 947
                     }
858 948
                     $this->_duplicateBorder($val);
859
-                    if ($val[0]) $this->value['border']['t']['width'] = $val[0];
860
-                    if ($val[1]) $this->value['border']['r']['width'] = $val[1];
861
-                    if ($val[2]) $this->value['border']['b']['width'] = $val[2];
862
-                    if ($val[3]) $this->value['border']['l']['width'] = $val[3];
949
+                    if ($val[0]) {
950
+                    	$this->value['border']['t']['width'] = $val[0];
951
+                    }
952
+                    if ($val[1]) {
953
+                    	$this->value['border']['r']['width'] = $val[1];
954
+                    }
955
+                    if ($val[2]) {
956
+                    	$this->value['border']['b']['width'] = $val[2];
957
+                    }
958
+                    if ($val[3]) {
959
+                    	$this->value['border']['l']['width'] = $val[3];
960
+                    }
863 961
                     break;
864 962
 
865 963
                 case 'border-top-width':
866 964
                     $val = $this->convertToMM($val, 0);
867
-                    if ($val) $this->value['border']['t']['width'] = $val;
965
+                    if ($val) {
966
+                    	$this->value['border']['t']['width'] = $val;
967
+                    }
868 968
                     break;
869 969
 
870 970
                 case 'border-right-width':
871 971
                     $val = $this->convertToMM($val, 0);
872
-                    if ($val) $this->value['border']['r']['width'] = $val;
972
+                    if ($val) {
973
+                    	$this->value['border']['r']['width'] = $val;
974
+                    }
873 975
                     break;
874 976
 
875 977
                 case 'border-bottom-width':
876 978
                     $val = $this->convertToMM($val, 0);
877
-                    if ($val) $this->value['border']['b']['width'] = $val;
979
+                    if ($val) {
980
+                    	$this->value['border']['b']['width'] = $val;
981
+                    }
878 982
                     break;
879 983
 
880 984
                 case 'border-left-width':
881 985
                     $val = $this->convertToMM($val, 0);
882
-                    if ($val) $this->value['border']['l']['width'] = $val;
986
+                    if ($val) {
987
+                    	$this->value['border']['l']['width'] = $val;
988
+                    }
883 989
                     break;
884 990
 
885 991
                 case 'border-collapse':
886
-                    if ($tagName=='table') $this->value['border']['collapse'] = ($val=='collapse');
992
+                    if ($tagName=='table') {
993
+                    	$this->value['border']['collapse'] = ($val=='collapse');
994
+                    }
887 995
                     break;
888 996
 
889 997
                 case 'border-radius':
@@ -895,17 +1003,29 @@  discard block
 block discarded – undo
895 1003
                     if (count($valH)<1 || count($valH)>4) {
896 1004
                         break;
897 1005
                     }
898
-                    if (!isset($valH[1])) $valH[1] = $valH[0];
899
-                    if (!isset($valH[2])) $valH = array($valH[0], $valH[0], $valH[1], $valH[1]);
900
-                    if (!isset($valH[3])) $valH[3] = $valH[1];
1006
+                    if (!isset($valH[1])) {
1007
+                    	$valH[1] = $valH[0];
1008
+                    }
1009
+                    if (!isset($valH[2])) {
1010
+                    	$valH = array($valH[0], $valH[0], $valH[1], $valH[1]);
1011
+                    }
1012
+                    if (!isset($valH[3])) {
1013
+                    	$valH[3] = $valH[1];
1014
+                    }
901 1015
                     if (isset($val[1])) {
902 1016
                         $valV = $this->convertToRadius(trim($val[1]));
903 1017
                         if (count($valV)<1 || count($valV)>4) {
904 1018
                             break;
905 1019
                         }
906
-                        if (!isset($valV[1])) $valV[1] = $valV[0];
907
-                        if (!isset($valV[2])) $valV = array($valV[0], $valV[0], $valV[1], $valV[1]);
908
-                        if (!isset($valV[3])) $valV[3] = $valV[1];
1020
+                        if (!isset($valV[1])) {
1021
+                        	$valV[1] = $valV[0];
1022
+                        }
1023
+                        if (!isset($valV[2])) {
1024
+                        	$valV = array($valV[0], $valV[0], $valV[1], $valV[1]);
1025
+                        }
1026
+                        if (!isset($valV[3])) {
1027
+                        	$valV[3] = $valV[1];
1028
+                        }
909 1029
                     } else {
910 1030
                         $valV = $valH;
911 1031
                     }
@@ -987,22 +1107,35 @@  discard block
 block discarded – undo
987 1107
                     break;
988 1108
 
989 1109
                 case 'position':
990
-                    if ($val=='absolute')       $this->value['position'] = 'absolute';
991
-                    else if ($val=='relative')  $this->value['position'] = 'relative';
992
-                    else                        $this->value['position'] = null;
1110
+                    if ($val=='absolute') {
1111
+                    	$this->value['position'] = 'absolute';
1112
+                    } else if ($val=='relative') {
1113
+                    	$this->value['position'] = 'relative';
1114
+                    } else {
1115
+                    	$this->value['position'] = null;
1116
+                    }
993 1117
                     break;
994 1118
 
995 1119
                 case 'float':
996
-                    if ($val=='left')           $this->value['float'] = 'left';
997
-                    else if ($val=='right')     $this->value['float'] = 'right';
998
-                    else                        $this->value['float'] = null;
1120
+                    if ($val=='left') {
1121
+                    	$this->value['float'] = 'left';
1122
+                    } else if ($val=='right') {
1123
+                    	$this->value['float'] = 'right';
1124
+                    } else {
1125
+                    	$this->value['float'] = null;
1126
+                    }
999 1127
                     break;
1000 1128
 
1001 1129
                 case 'display':
1002
-                    if ($val=='inline')         $this->value['display'] = 'inline';
1003
-                    else if ($val=='block')     $this->value['display'] = 'block';
1004
-                    else if ($val=='none')      $this->value['display'] = 'none';
1005
-                    else                        $this->value['display'] = null;
1130
+                    if ($val=='inline') {
1131
+                    	$this->value['display'] = 'inline';
1132
+                    } else if ($val=='block') {
1133
+                    	$this->value['display'] = 'block';
1134
+                    } else if ($val=='none') {
1135
+                    	$this->value['display'] = 'none';
1136
+                    } else {
1137
+                    	$this->value['display'] = null;
1138
+                    }
1006 1139
                     break;
1007 1140
 
1008 1141
                 case 'top':
@@ -1015,7 +1148,9 @@  discard block
 block discarded – undo
1015 1148
                 case 'list-style':
1016 1149
                 case 'list-style-type':
1017 1150
                 case 'list-style-image':
1018
-                    if ($nom=='list-style') $nom = 'list-style-type';
1151
+                    if ($nom=='list-style') {
1152
+                    	$nom = 'list-style-type';
1153
+                    }
1019 1154
                     $this->value[$nom] = $val;
1020 1155
                     break;
1021 1156
 
@@ -1027,11 +1162,17 @@  discard block
 block discarded – undo
1027 1162
         $return = true;
1028 1163
 
1029 1164
         // only for P tag
1030
-        if ($this->value['margin']['t']===null) $this->value['margin']['t'] = $this->value['font-size'];
1031
-        if ($this->value['margin']['b']===null) $this->value['margin']['b'] = $this->value['font-size'];
1165
+        if ($this->value['margin']['t']===null) {
1166
+        	$this->value['margin']['t'] = $this->value['font-size'];
1167
+        }
1168
+        if ($this->value['margin']['b']===null) {
1169
+        	$this->value['margin']['b'] = $this->value['font-size'];
1170
+        }
1032 1171
 
1033 1172
         // force the text align to left, if asked by html2pdf
1034
-        if ($this->_onlyLeft) $this->value['text-align'] = 'left';
1173
+        if ($this->_onlyLeft) {
1174
+        	$this->value['text-align'] = 'left';
1175
+        }
1035 1176
 
1036 1177
         // correction on the width (quick box)
1037 1178
         if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position']!='absolute') {
@@ -1047,30 +1188,60 @@  discard block
 block discarded – undo
1047 1188
                     $this->value['width']-= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
1048 1189
                     $return = false;
1049 1190
                 }
1050
-                if ($this->value['width']<0) $this->value['width']=0;
1191
+                if ($this->value['width']<0) {
1192
+                	$this->value['width']=0;
1193
+                }
1051 1194
             } else {
1052 1195
                 if ($this->value['width']) {
1053
-                    if ($this->value['border']['l']['width']) $this->value['width'] += $this->value['border']['l']['width'];
1054
-                    if ($this->value['border']['r']['width']) $this->value['width'] += $this->value['border']['r']['width'];
1055
-                    if ($this->value['padding']['l'])         $this->value['width'] += $this->value['padding']['l'];
1056
-                    if ($this->value['padding']['r'])         $this->value['width'] += $this->value['padding']['r'];
1196
+                    if ($this->value['border']['l']['width']) {
1197
+                    	$this->value['width'] += $this->value['border']['l']['width'];
1198
+                    }
1199
+                    if ($this->value['border']['r']['width']) {
1200
+                    	$this->value['width'] += $this->value['border']['r']['width'];
1201
+                    }
1202
+                    if ($this->value['padding']['l']) {
1203
+                    	$this->value['width'] += $this->value['padding']['l'];
1204
+                    }
1205
+                    if ($this->value['padding']['r']) {
1206
+                    	$this->value['width'] += $this->value['padding']['r'];
1207
+                    }
1057 1208
                 }
1058 1209
             }
1059 1210
         }
1060 1211
         if ($this->value['height']) {
1061
-            if ($this->value['border']['b']['width']) $this->value['height'] += $this->value['border']['b']['width'];
1062
-            if ($this->value['border']['t']['width']) $this->value['height'] += $this->value['border']['t']['width'];
1063
-            if ($this->value['padding']['b'])         $this->value['height'] += $this->value['padding']['b'];
1064
-            if ($this->value['padding']['t'])         $this->value['height'] += $this->value['padding']['t'];
1212
+            if ($this->value['border']['b']['width']) {
1213
+            	$this->value['height'] += $this->value['border']['b']['width'];
1214
+            }
1215
+            if ($this->value['border']['t']['width']) {
1216
+            	$this->value['height'] += $this->value['border']['t']['width'];
1217
+            }
1218
+            if ($this->value['padding']['b']) {
1219
+            	$this->value['height'] += $this->value['padding']['b'];
1220
+            }
1221
+            if ($this->value['padding']['t']) {
1222
+            	$this->value['height'] += $this->value['padding']['t'];
1223
+            }
1065 1224
         }
1066 1225
 
1067
-        if ($this->value['top']!=null)      $this->value['top']     = $this->convertToMM($this->value['top'], $this->getLastHeight(true));
1068
-        if ($this->value['bottom']!=null)   $this->value['bottom']  = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true));
1069
-        if ($this->value['left']!=null)     $this->value['left']    = $this->convertToMM($this->value['left'], $this->getLastWidth(true));
1070
-        if ($this->value['right']!=null)    $this->value['right']   = $this->convertToMM($this->value['right'], $this->getLastWidth(true));
1226
+        if ($this->value['top']!=null) {
1227
+        	$this->value['top']     = $this->convertToMM($this->value['top'], $this->getLastHeight(true));
1228
+        }
1229
+        if ($this->value['bottom']!=null) {
1230
+        	$this->value['bottom']  = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true));
1231
+        }
1232
+        if ($this->value['left']!=null) {
1233
+        	$this->value['left']    = $this->convertToMM($this->value['left'], $this->getLastWidth(true));
1234
+        }
1235
+        if ($this->value['right']!=null) {
1236
+        	$this->value['right']   = $this->convertToMM($this->value['right'], $this->getLastWidth(true));
1237
+        }
1071 1238
 
1072
-        if ($this->value['top'] && $this->value['bottom'] && $this->value['height'])    $this->value['bottom']  = null;
1073
-        if ($this->value['left'] && $this->value['right'] && $this->value['width'])     $this->value['right']   = null;
1239
+        if ($this->value['top'] && $this->value['bottom'] && $this->value['height']) {
1240
+        	$this->value['bottom']  = null;
1241
+        }
1242
+        if ($this->value['left'] && $this->value['right'] && $this->value['width']) {
1243
+        	$this->value['right']   = null;
1244
+        }
1074 1245
 
1075 1246
         return $return;
1076 1247
     }
@@ -1084,7 +1255,9 @@  discard block
 block discarded – undo
1084 1255
     public function getLineHeight()
1085 1256
     {
1086 1257
         $val = $this->value['line-height'];
1087
-        if ($val=='normal') $val = '108%';
1258
+        if ($val=='normal') {
1259
+        	$val = '108%';
1260
+        }
1088 1261
         return $this->convertToMM($val, $this->value['font-size']);
1089 1262
     }
1090 1263
 
@@ -1140,8 +1313,12 @@  discard block
 block discarded – undo
1140 1313
      */
1141 1314
     public function getFloat()
1142 1315
     {
1143
-        if ($this->value['float']=='left')    return 'left';
1144
-        if ($this->value['float']=='right')   return 'right';
1316
+        if ($this->value['float']=='left') {
1317
+        	return 'left';
1318
+        }
1319
+        if ($this->value['float']=='right') {
1320
+        	return 'right';
1321
+        }
1145 1322
         return null;
1146 1323
     }
1147 1324
 
@@ -1171,7 +1348,9 @@  discard block
 block discarded – undo
1171 1348
     protected function _getLastAbsoluteX()
1172 1349
     {
1173 1350
         for ($k=count($this->table)-1; $k>=0; $k--) {
1174
-            if ($this->table[$k]['x'] && $this->table[$k]['position']) return $this->table[$k]['x'];
1351
+            if ($this->table[$k]['x'] && $this->table[$k]['position']) {
1352
+            	return $this->table[$k]['x'];
1353
+            }
1175 1354
         }
1176 1355
         return $this->_pdf->getlMargin();
1177 1356
     }
@@ -1185,7 +1364,9 @@  discard block
 block discarded – undo
1185 1364
     protected function _getLastAbsoluteY()
1186 1365
     {
1187 1366
         for ($k=count($this->table)-1; $k>=0; $k--) {
1188
-            if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y'];
1367
+            if ($this->table[$k]['y'] && $this->table[$k]['position']) {
1368
+            	return $this->table[$k]['y'];
1369
+            }
1189 1370
         }
1190 1371
         return $this->_pdf->gettMargin();
1191 1372
     }
@@ -1222,7 +1403,9 @@  discard block
 block discarded – undo
1222 1403
         if (count($getit)) {
1223 1404
             // get them, but in the definition order, because of priority
1224 1405
             asort($getit);
1225
-            foreach ($getit as $key => $val) $styles = array_merge($styles, $this->css[$key]);
1406
+            foreach ($getit as $key => $val) {
1407
+            	$styles = array_merge($styles, $this->css[$key]);
1408
+            }
1226 1409
         }
1227 1410
 
1228 1411
         return $styles;
@@ -1242,7 +1425,9 @@  discard block
 block discarded – undo
1242 1425
         // if next step
1243 1426
         if ($next!==null) {
1244 1427
             // we remove this step
1245
-            if ($next) $key = trim(substr($key, 0, -strlen($next)));
1428
+            if ($next) {
1429
+            	$key = trim(substr($key, 0, -strlen($next)));
1430
+            }
1246 1431
             array_shift($lst);
1247 1432
 
1248 1433
             // if no more step to identify => return false
@@ -1294,8 +1479,11 @@  discard block
 block discarded – undo
1294 1479
         $css = explode(' ', $css);
1295 1480
         foreach ($css as $k => $v) {
1296 1481
             $v = trim($v);
1297
-            if ($v) $css[$k] = $v;
1298
-            else    unset($css[$k]);
1482
+            if ($v) {
1483
+            	$css[$k] = $v;
1484
+            } else {
1485
+            	unset($css[$k]);
1486
+            }
1299 1487
         }
1300 1488
         $css = array_values($css);
1301 1489
 
@@ -1320,12 +1508,16 @@  discard block
 block discarded – undo
1320 1508
             // else, it could be the color
1321 1509
             } else {
1322 1510
                 $tmp = $this->convertToColor($value, $res);
1323
-                if ($res) $color = $tmp;
1511
+                if ($res) {
1512
+                	$color = $tmp;
1513
+                }
1324 1514
             }
1325 1515
         }
1326 1516
 
1327 1517
         // if no witdh => return none
1328
-        if (!$width) return $none;
1518
+        if (!$width) {
1519
+        	return $none;
1520
+        }
1329 1521
 
1330 1522
         // return the border properties
1331 1523
         return array('type' => $type, 'width' => $width, 'color' => $color);
@@ -1414,7 +1606,9 @@  discard block
 block discarded – undo
1414 1606
         if ($pos) {
1415 1607
             // try to read it
1416 1608
             $pos = $this->convertBackgroundPosition($pos, $ok);
1417
-            if ($ok) $value['position'] = $pos;
1609
+            if ($ok) {
1610
+            	$value['position'] = $pos;
1611
+            }
1418 1612
         }
1419 1613
     }
1420 1614
 
@@ -1428,8 +1622,11 @@  discard block
 block discarded – undo
1428 1622
     public function convertBackgroundColor($css)
1429 1623
     {
1430 1624
         $res = null;
1431
-        if ($css=='transparent') return null;
1432
-        else                     return $this->convertToColor($css, $res);
1625
+        if ($css=='transparent') {
1626
+        	return null;
1627
+        } else {
1628
+        	return $this->convertToColor($css, $res);
1629
+        }
1433 1630
     }
1434 1631
 
1435 1632
     /**
@@ -1441,12 +1638,13 @@  discard block
 block discarded – undo
1441 1638
      */
1442 1639
     public function convertBackgroundImage($css)
1443 1640
     {
1444
-        if ($css=='none')
1445
-            return null;
1446
-        else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match))
1447
-            return $match[1];
1448
-        else
1449
-            return null;
1641
+        if ($css=='none') {
1642
+                    return null;
1643
+        } else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match)) {
1644
+                    return $match[1];
1645
+        } else {
1646
+                    return null;
1647
+        }
1450 1648
     }
1451 1649
 
1452 1650
     /**
@@ -1467,10 +1665,14 @@  discard block
 block discarded – undo
1467 1665
 
1468 1666
         // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2
1469 1667
         if (count($css)<2) {
1470
-            if (!$css[0]) return null;
1668
+            if (!$css[0]) {
1669
+            	return null;
1670
+            }
1471 1671
             $css[1] = 'center';
1472 1672
         }
1473
-        if (count($css)>2) return null;
1673
+        if (count($css)>2) {
1674
+        	return null;
1675
+        }
1474 1676
 
1475 1677
         // prepare the values
1476 1678
         $x = 0;
@@ -1478,24 +1680,42 @@  discard block
 block discarded – undo
1478 1680
         $res = true;
1479 1681
 
1480 1682
         // convert the first value
1481
-        if ($css[0]=='left')        $x = '0%';
1482
-        else if ($css[0]=='center') $x = '50%';
1483
-        else if ($css[0]=='right')  $x = '100%';
1484
-        else if ($css[0]=='top')    $y = '0%';
1485
-        else if ($css[0]=='bottom') $y = '100%';
1486
-        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0];
1487
-        else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]);
1488
-        else $res = false;
1683
+        if ($css[0]=='left') {
1684
+        	$x = '0%';
1685
+        } else if ($css[0]=='center') {
1686
+        	$x = '50%';
1687
+        } else if ($css[0]=='right') {
1688
+        	$x = '100%';
1689
+        } else if ($css[0]=='top') {
1690
+        	$y = '0%';
1691
+        } else if ($css[0]=='bottom') {
1692
+        	$y = '100%';
1693
+        } else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) {
1694
+        	$x = $css[0];
1695
+        } else if ($this->convertToMM($css[0])) {
1696
+        	$x = $this->convertToMM($css[0]);
1697
+        } else {
1698
+        	$res = false;
1699
+        }
1489 1700
 
1490 1701
         // convert the second value
1491
-        if ($css[1]=='left')        $x = '0%';
1492
-        else if ($css[1]=='right')  $x = '100%';
1493
-        else if ($css[1]=='top')    $y = '0%';
1494
-        else if ($css[1]=='center') $y = '50%';
1495
-        else if ($css[1]=='bottom') $y = '100%';
1496
-        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1];
1497
-        else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]);
1498
-        else $res = false;
1702
+        if ($css[1]=='left') {
1703
+        	$x = '0%';
1704
+        } else if ($css[1]=='right') {
1705
+        	$x = '100%';
1706
+        } else if ($css[1]=='top') {
1707
+        	$y = '0%';
1708
+        } else if ($css[1]=='center') {
1709
+        	$y = '50%';
1710
+        } else if ($css[1]=='bottom') {
1711
+        	$y = '100%';
1712
+        } else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) {
1713
+        	$y = $css[1];
1714
+        } else if ($this->convertToMM($css[1])) {
1715
+        	$y = $this->convertToMM($css[1]);
1716
+        } else {
1717
+        	$res = false;
1718
+        }
1499 1719
 
1500 1720
         // return the values
1501 1721
         return array($x, $y);
@@ -1535,13 +1755,22 @@  discard block
 block discarded – undo
1535 1755
     public function convertToMM($css, $old=0.)
1536 1756
     {
1537 1757
         $css = trim($css);
1538
-        if (preg_match('/^[0-9\.\-]+$/isU', $css))        $css.= 'px';
1539
-        if (preg_match('/^[0-9\.\-]+px$/isU', $css))      $css = 25.4/96. * str_replace('px', '', $css);
1540
-        else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css);
1541
-        else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css);
1542
-        else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css);
1543
-        else if (preg_match('/^[0-9\.\-]+%$/isU', $css))  $css = 1.*$old*str_replace('%', '', $css)/100.;
1544
-        else                                              $css = null;
1758
+        if (preg_match('/^[0-9\.\-]+$/isU', $css)) {
1759
+        	$css.= 'px';
1760
+        }
1761
+        if (preg_match('/^[0-9\.\-]+px$/isU', $css)) {
1762
+        	$css = 25.4/96. * str_replace('px', '', $css);
1763
+        } else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) {
1764
+        	$css = 25.4/72. * str_replace('pt', '', $css);
1765
+        } else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) {
1766
+        	$css = 25.4 * str_replace('in', '', $css);
1767
+        } else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) {
1768
+        	$css = 1.*str_replace('mm', '', $css);
1769
+        } else if (preg_match('/^[0-9\.\-]+%$/isU', $css)) {
1770
+        	$css = 1.*$old*str_replace('%', '', $css)/100.;
1771
+        } else {
1772
+        	$css = null;
1773
+        }
1545 1774
 
1546 1775
         return $css;
1547 1776
     }
@@ -1590,7 +1819,9 @@  discard block
 block discarded – undo
1590 1819
         $res = true;
1591 1820
 
1592 1821
         // if transparent => return null
1593
-        if (strtolower($css)=='transparent') return array(null, null, null);
1822
+        if (strtolower($css)=='transparent') {
1823
+        	return array(null, null, null);
1824
+        }
1594 1825
 
1595 1826
         // HTML color
1596 1827
         if (isset($this->_htmlColor[strtolower($css)])) {
@@ -1651,7 +1882,9 @@  discard block
 block discarded – undo
1651 1882
             $c = floatVal(substr($c, 0, -1))/100.;
1652 1883
         } else {
1653 1884
             $c = floatVal($c);
1654
-            if ($c>1) $c = $c/255.;
1885
+            if ($c>1) {
1886
+            	$c = $c/255.;
1887
+            }
1655 1888
         }
1656 1889
 
1657 1890
         return $c;
@@ -1705,13 +1938,16 @@  discard block
 block discarded – undo
1705 1938
                 $name = trim($name);
1706 1939
 
1707 1940
                 // if a selector with somethink lige :hover => continue
1708
-                if (strpos($name, ':')!==false) continue;
1941
+                if (strpos($name, ':')!==false) {
1942
+                	continue;
1943
+                }
1709 1944
 
1710 1945
                 // save the value
1711
-                if (!isset($this->css[$name]))
1712
-                    $this->css[$name] = $css;
1713
-                else
1714
-                    $this->css[$name] = array_merge($this->css[$name], $css);
1946
+                if (!isset($this->css[$name])) {
1947
+                                    $this->css[$name] = $css;
1948
+                } else {
1949
+                                    $this->css[$name] = array_merge($this->css[$name], $css);
1950
+                }
1715 1951
 
1716 1952
             }
1717 1953
         }
Please login to merge, or discard this patch.
includes/librairies/HTML2PDF/_class/parsingHtml.class.php 4 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -38,6 +38,7 @@  discard block
 block discarded – undo
38 38
      * change the encoding
39 39
      *
40 40
      * @param   string encoding
41
+     * @param string $encoding
41 42
      * @access  public
42 43
      */
43 44
     public function setEncoding($encoding)
@@ -439,6 +440,7 @@  discard block
 block discarded – undo
439 440
      * get a full level of HTML, between an opening and closing corresponding
440 441
      *
441 442
      * @param   integer key
443
+     * @param integer $k
442 444
      * @return  array   actions
443 445
      */
444 446
     public function getLevel($k)
Please login to merge, or discard this patch.
Indentation   +506 added lines, -506 removed lines patch added patch discarded remove patch
@@ -11,510 +11,510 @@
 block discarded – undo
11 11
 
12 12
 class HTML2PDF_parsingHtml
13 13
 {
14
-    protected    $_html     = '';        // HTML code to parse
15
-    protected    $_num      = 0;         // table number
16
-    protected    $_level    = 0;         // table level
17
-    protected    $_encoding = '';        // encoding
18
-    public       $code      = array();   // parsed HTML codfe
19
-
20
-    const HTML_TAB = '        ';
21
-
22
-    /**
23
-     * main constructor
24
-     *
25
-     * @param   string encoding
26
-     * @access  public
27
-     */
28
-    public function __construct($encoding = 'UTF-8')
29
-    {
30
-        $this->_num   = 0;
31
-        $this->_level = array($this->_num);
32
-        $this->_html  = '';
33
-        $this->code  = array();
34
-        $this->setEncoding($encoding);
35
-    }
36
-
37
-    /**
38
-     * change the encoding
39
-     *
40
-     * @param   string encoding
41
-     * @access  public
42
-     */
43
-    public function setEncoding($encoding)
44
-    {
45
-        $this->_encoding = $encoding;
46
-    }
47
-
48
-    /**
49
-     * Define the HTML code to parse
50
-     *
51
-     * @param   string HTML code
52
-     * @access  public
53
-     */
54
-    public function setHTML($html)
55
-    {
56
-        // remove the HTML in comment
57
-        $html = preg_replace('/<!--(.*)-->/isU', '', $html);
58
-
59
-        // save the HTML code
60
-        $this->_html = $html;
61
-    }
62
-
63
-    /**
64
-     * parse the HTML code
65
-     *
66
-     * @access public
67
-     */
68
-    public function parse()
69
-    {
70
-        $parents = array();
71
-
72
-        // flag : are we in a <pre> Tag ?
73
-        $tagPreIn = false;
74
-
75
-        // action to use for each line of the content of a <pre> Tag
76
-        $tagPreBr = array(
77
-                    'name' => 'br',
78
-                    'close' => false,
79
-                    'param' => array(
80
-                        'style' => array(),
81
-                        'num'    => 0
82
-                    )
83
-                );
84
-
85
-        // tag that can be not closed
86
-        $tagsNotClosed = array(
87
-            'br', 'hr', 'img', 'col',
88
-            'input', 'link', 'option',
89
-            'circle', 'ellipse', 'path', 'rect', 'line', 'polygon', 'polyline'
90
-        );
91
-
92
-        // search the HTML tags
93
-        $tmp = array();
94
-        $this->_searchCode($tmp);
95
-
96
-        // all the actions to do
97
-        $actions = array();
98
-
99
-        // foreach part of the HTML code
100
-        foreach ($tmp as $part) {
101
-            // if it is a tag code
102
-            if ($part[0]=='code') {
103
-                // analise the HTML code
104
-                $res = $this->_analiseCode($part[1]);
105
-
106
-                // if it is a real HTML tag
107
-                if ($res) {
108
-                    // save the current posistion in the HTML code
109
-                    $res['html_pos'] = $part[2];
110
-
111
-                    // if the tag must be closed
112
-                    if (!in_array($res['name'], $tagsNotClosed)) {
113
-                        // if it is a closure tag
114
-                        if ($res['close']) {
115
-                            // HTML validation
116
-                            if (count($parents)<1)
117
-                                throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos']));
118
-                            else if ($parents[count($parents)-1]!=$res['name'])
119
-                                throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos']));
120
-                            else
121
-                                unset($parents[count($parents)-1]);
122
-                        } else {
123
-                            // if it is a autoclosed tag
124
-                            if ($res['autoclose']) {
125
-                                // save the opened tag
126
-                                $actions[] = $res;
127
-
128
-                                // prepare the closed tag
129
-                                $res['params'] = array();
130
-                                $res['close'] = true;
131
-                            }
132
-                            // else :add a child for validation
133
-                            else
134
-                                $parents[count($parents)] = $res['name'];
135
-                        }
136
-
137
-                        // if it is a <pre> tag (or <code> tag) not auclosed => update the flag
138
-                        if (($res['name']=='pre' || $res['name']=='code') && !$res['autoclose']) {
139
-                            $tagPreIn = !$res['close'];
140
-                        }
141
-                    }
142
-
143
-                    // save the actions to convert
144
-                    $actions[] = $res;
145
-                } else { // else (it is not a real HTML tag => we transform it in Texte
146
-                    $part[0]='txt';
147
-                }
148
-            }
149
-            // if it is text
150
-            if ($part[0]=='txt') {
151
-                // if we are not in a <pre> tag
152
-                if (!$tagPreIn) {
153
-                    // save the action
154
-                    $actions[] = array(
155
-                        'name'    => 'write',
156
-                        'close'    => false,
157
-                        'param' => array('txt' => $this->_prepareTxt($part[1])),
158
-                    );
159
-                } else { // else (if we are in a <pre> tag)
160
-                    // prepare the text
161
-                    $part[1] = str_replace("\r", '', $part[1]);
162
-                    $part[1] = explode("\n", $part[1]);
163
-
164
-                    // foreach line of the text
165
-                    foreach ($part[1] as $k => $txt) {
166
-                        // transform the line
167
-                        $txt = str_replace("\t", self::HTML_TAB, $txt);
168
-                        $txt = str_replace(' ', '&nbsp;', $txt);
169
-
170
-                        // add a break line
171
-                        if ($k>0) $actions[] = $tagPreBr;
172
-
173
-                        // save the action
174
-                        $actions[] = array(
175
-                            'name'    => 'write',
176
-                            'close'    => false,
177
-                            'param' => array('txt' => $this->_prepareTxt($txt, false)),
178
-                        );
179
-                    }
180
-                }
181
-            }
182
-        }
183
-
184
-        // for each indentified action, we have to clean up the begin and the end of the texte
185
-        // based on tags that surround it
186
-
187
-        // list of the tags to clean
188
-        $tagsToClean = array(
189
-            'page', 'page_header', 'page_footer', 'form',
190
-            'table', 'thead', 'tfoot', 'tr', 'td', 'th', 'br',
191
-            'div', 'hr', 'p', 'ul', 'ol', 'li',
192
-            'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
193
-            'bookmark', 'fieldset', 'legend',
194
-            'draw', 'circle', 'ellipse', 'path', 'rect', 'line', 'g', 'polygon', 'polyline',
195
-            'option'
196
-        );
197
-
198
-        // foreach action
199
-        $nb = count($actions);
200
-        for ($k=0; $k<$nb; $k++) {
201
-            // if it is a Text
202
-            if ($actions[$k]['name']=='write') {
203
-                // if the tag before the text is a tag to clean => ltrim on the text
204
-                if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean))
205
-                    $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']);
206
-
207
-                // if the tag after the text is a tag to clean => rtrim on the text
208
-                if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean))
209
-                    $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']);
210
-
211
-                // if the text is empty => remove the action
212
-                if (!strlen($actions[$k]['param']['txt']))
213
-                    unset($actions[$k]);
214
-            }
215
-        }
216
-
217
-        // if we are not on the level 0 => HTML validator ERROR
218
-        if (count($parents)) throw new HTML2PDF_exception(5, $parents);
219
-
220
-        // save the actions to do
221
-        $this->code = array_values($actions);
222
-    }
223
-
224
-    /**
225
-     * prepare the text
226
-     *
227
-     * @param   string texte
228
-     * @param   boolean true => replace multiple space+\t+\r+\n by a single space
229
-     * @return  string texte
230
-     * @access  protected
231
-     */
232
-    protected function _prepareTxt($txt, $spaces = true)
233
-    {
234
-        if ($spaces) $txt = preg_replace('/\s+/is', ' ', $txt);
235
-        $txt = str_replace('&euro;', '€', $txt);
236
-        $txt = html_entity_decode($txt, ENT_QUOTES, $this->_encoding);
237
-        return $txt;
238
-    }
239
-
240
-    /**
241
-     * parse the HTML code
242
-     *
243
-     * @param    &array    array's result
244
-     * @return   null
245
-     */
246
-    protected function _searchCode(&$tmp)
247
-    {
248
-        // initialise the array
249
-        $tmp = array();
250
-
251
-        // regexp to separate the tags from the texts
252
-        $reg = '/(<[^>]+>)|([^<]+)+/isU';
253
-
254
-        // last match found
255
-        $str = '';
256
-        $offset = 0;
257
-
258
-        // As it finds a match
259
-        while (preg_match($reg, $this->_html, $parse, PREG_OFFSET_CAPTURE, $offset)) {
260
-            // if it is a tag
261
-            if ($parse[1][0]) {
262
-                // save the previous text if it exists
263
-                if ($str!=='')    $tmp[] = array('txt', $str);
264
-
265
-                // save the tag, with the offset
266
-                $tmp[] = array('code', trim($parse[1][0]), $offset);
267
-
268
-                // init the current text
269
-                $str = '';
270
-            } else { // else (if it is a text)
271
-                // add the new text to the current text
272
-                $str.= $parse[2][0];
273
-            }
274
-
275
-            // Update offset to the end of the match
276
-            $offset = $parse[0][1] + strlen($parse[0][0]);
277
-            unset($parse);
278
-        }
279
-        // if a text is present in the end, we save it
280
-        if ($str!='') $tmp[] = array('txt', $str);
281
-        unset($str);
282
-    }
283
-
284
-    /**
285
-     * analise a HTML tag
286
-     *
287
-     * @param   string   HTML code to analise
288
-     * @return  array    corresponding action
289
-     */
290
-    protected function _analiseCode($code)
291
-    {
292
-        // name of the tag, opening, closure, autoclosure
293
-        $tag = '<([\/]{0,1})([_a-z0-9]+)([\/>\s]+)';
294
-        if (!preg_match('/'.$tag.'/isU', $code, $match)) return null;
295
-        $close     = ($match[1]=='/' ? true : false);
296
-        $autoclose = preg_match('/\/>$/isU', $code);
297
-        $name      = strtolower($match[2]);
298
-
299
-        // required parameters (depends on the tag name)
300
-        $param    = array();
301
-        $param['style'] = '';
302
-        if ($name=='img') {
303
-            $param['alt'] = '';
304
-            $param['src'] = '';
305
-        }
306
-        if ($name=='a') {
307
-            $param['href'] = '';
308
-        }
309
-
310
-        // read the parameters : nom=valeur
311
-        $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
312
-        preg_match_all('/'.$prop.'/is', $code, $match);
313
-        for($k=0; $k<count($match[0]); $k++)
314
-            $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
315
-
316
-        // read the parameters : nom="valeur"
317
-        $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
318
-        preg_match_all('/'.$prop.'/is', $code, $match);
319
-        for($k=0; $k<count($match[0]); $k++)
320
-            $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
321
-
322
-        // read the parameters : nom='valeur'
323
-        $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
324
-        preg_match_all('/'.$prop.'/is', $code, $match);
325
-        for($k=0; $k<count($match[0]); $k++)
326
-            $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
327
-
328
-        // compliance of each parameter
329
-        $color  = "#000000";
330
-        $border = null;
331
-        foreach ($param as $key => $val) {
332
-            $key = strtolower($key);
333
-            switch($key)
334
-            {
335
-                case 'width':
336
-                    unset($param[$key]);
337
-                    $param['style'] .= 'width: '.$val.'px; ';
338
-                    break;
339
-
340
-                case 'align':
341
-                    if ($name==='img') {
342
-                        unset($param[$key]);
343
-                        $param['style'] .= 'float: '.$val.'; ';
344
-                    } elseif ($name!=='table') {
345
-                        unset($param[$key]);
346
-                        $param['style'] .= 'text-align: '.$val.'; ';
347
-                    }
348
-                    break;
349
-
350
-                case 'valign':
351
-                    unset($param[$key]);
352
-                    $param['style'] .= 'vertical-align: '.$val.'; ';
353
-                    break;
354
-
355
-                case 'height':
356
-                    unset($param[$key]);
357
-                    $param['style'] .= 'height: '.$val.'px; ';
358
-                    break;
359
-
360
-                case 'bgcolor':
361
-                    unset($param[$key]);
362
-                    $param['style'] .= 'background: '.$val.'; ';
363
-                    break;
364
-
365
-                case 'bordercolor':
366
-                    unset($param[$key]);
367
-                    $color = $val;
368
-                    break;
369
-
370
-                case 'border':
371
-                    unset($param[$key]);
372
-                    if (preg_match('/^[0-9]+$/isU', $val)) $val = $val.'px';
373
-                    $border = $val;
374
-                    break;
375
-
376
-                case 'cellpadding':
377
-                case 'cellspacing':
378
-                    if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val.'px';
379
-                    break;
380
-
381
-                case 'colspan':
382
-                case 'rowspan':
383
-                    $val = preg_replace('/[^0-9]/isU', '', $val);
384
-                    if (!$val) $val = 1;
385
-                    $param[$key] = $val;
386
-                    break;
387
-            }
388
-        }
389
-
390
-        // compliance of the border
391
-        if ($border!==null) {
392
-            if ($border)    $border = 'border: solid '.$border.' '.$color;
393
-            else            $border = 'border: none';
394
-
395
-            $param['style'] .= $border.'; ';
396
-            $param['border'] = $border;
397
-        }
398
-
399
-        // reading styles: decomposition and standardization
400
-        $styles = explode(';', $param['style']);
401
-        $param['style'] = array();
402
-        foreach ($styles as $style) {
403
-            $tmp = explode(':', $style);
404
-            if (count($tmp)>1) {
405
-                $cod = $tmp[0];
406
-                unset($tmp[0]);
407
-                $tmp = implode(':', $tmp);
408
-                $param['style'][trim(strtolower($cod))] = preg_replace('/[\s]+/isU', ' ', trim($tmp));
409
-            }
410
-        }
411
-
412
-        // determining the level of table opening, with an added level
413
-        if (in_array($name, array('ul', 'ol', 'table')) && !$close) {
414
-            $this->_num++;
415
-            $this->_level[count($this->_level)] = $this->_num;
416
-        }
417
-
418
-        // get the level of the table containing the element
419
-        if (!isset($param['num'])) {
420
-            $param['num'] = $this->_level[count($this->_level)-1];
421
-        }
422
-
423
-        // for closures table: remove a level
424
-        if (in_array($name, array('ul', 'ol', 'table')) && $close) {
425
-            unset($this->_level[count($this->_level)-1]);
426
-        }
427
-
428
-        // prepare the parameters
429
-        if (isset($param['value']))  $param['value']  = $this->_prepareTxt($param['value']);
430
-        if (isset($param['alt']))    $param['alt']    = $this->_prepareTxt($param['alt']);
431
-        if (isset($param['title']))  $param['title']  = $this->_prepareTxt($param['title']);
432
-        if (isset($param['class']))  $param['class']  = $this->_prepareTxt($param['class']);
433
-
434
-        // return the new action to do
435
-        return array('name' => $name, 'close' => $close ? 1 : 0, 'autoclose' => $autoclose, 'param' => $param);
436
-    }
437
-
438
-    /**
439
-     * get a full level of HTML, between an opening and closing corresponding
440
-     *
441
-     * @param   integer key
442
-     * @return  array   actions
443
-     */
444
-    public function getLevel($k)
445
-    {
446
-        // if the code does not exist => return empty
447
-        if (!isset($this->code[$k])) return array();
448
-
449
-        // the tag to detect
450
-        $detect = $this->code[$k]['name'];
451
-
452
-        // if it is a text => return
453
-        if ($detect=='write') {
454
-            return array($this->code[$k]);
455
-        }
456
-
457
-        //
458
-        $level = 0;      // depth level
459
-        $end = false;    // end of the search
460
-        $code = array(); // extract code
461
-
462
-        // while it's not ended
463
-        while (!$end) {
464
-            // current action
465
-            $row = $this->code[$k];
466
-
467
-            // if 'write' => we add the text
468
-            if ($row['name']=='write') {
469
-                $code[] = $row;
470
-            } else { // else, it is a html tag
471
-                $not = false; // flag for not taking into account the current tag
472
-
473
-                // if it is the searched tag
474
-                if ($row['name']==$detect) {
475
-                    // if we are just at the root level => dont take it
476
-                    if ($level==0) {
477
-                        $not = true;
478
-                    }
479
-
480
-                    // update the level
481
-                    $level+= ($row['close'] ? -1 : 1);
482
-
483
-                    // if we are now at the root level => it is the end, and dont take it
484
-                    if ($level==0) {
485
-                        $not = true;
486
-                        $end = true;
487
-                    }
488
-                }
489
-
490
-                // if we can takin into account the current tag => save it
491
-                if (!$not) {
492
-                    if (isset($row['style']['text-align'])) unset($row['style']['text-align']);
493
-                    $code[] = $row;
494
-                }
495
-            }
496
-
497
-            // it continues as long as there has code to analise
498
-            if (isset($this->code[$k+1]))
499
-                $k++;
500
-            else
501
-                $end = true;
502
-        }
503
-
504
-        // return the extract
505
-        return $code;
506
-    }
507
-
508
-    /**
509
-     * return a part of the HTML code, for error message
510
-     *
511
-     * @param   integer position
512
-     * @param   integer take before
513
-     * @param   integer take after
514
-     * @return  string  part of the html code
515
-     */
516
-    public function getHtmlErrorCode($pos, $before=30, $after=40)
517
-    {
518
-        return substr($this->_html, $pos-$before, $before+$after);
519
-    }
14
+	protected    $_html     = '';        // HTML code to parse
15
+	protected    $_num      = 0;         // table number
16
+	protected    $_level    = 0;         // table level
17
+	protected    $_encoding = '';        // encoding
18
+	public       $code      = array();   // parsed HTML codfe
19
+
20
+	const HTML_TAB = '        ';
21
+
22
+	/**
23
+	 * main constructor
24
+	 *
25
+	 * @param   string encoding
26
+	 * @access  public
27
+	 */
28
+	public function __construct($encoding = 'UTF-8')
29
+	{
30
+		$this->_num   = 0;
31
+		$this->_level = array($this->_num);
32
+		$this->_html  = '';
33
+		$this->code  = array();
34
+		$this->setEncoding($encoding);
35
+	}
36
+
37
+	/**
38
+	 * change the encoding
39
+	 *
40
+	 * @param   string encoding
41
+	 * @access  public
42
+	 */
43
+	public function setEncoding($encoding)
44
+	{
45
+		$this->_encoding = $encoding;
46
+	}
47
+
48
+	/**
49
+	 * Define the HTML code to parse
50
+	 *
51
+	 * @param   string HTML code
52
+	 * @access  public
53
+	 */
54
+	public function setHTML($html)
55
+	{
56
+		// remove the HTML in comment
57
+		$html = preg_replace('/<!--(.*)-->/isU', '', $html);
58
+
59
+		// save the HTML code
60
+		$this->_html = $html;
61
+	}
62
+
63
+	/**
64
+	 * parse the HTML code
65
+	 *
66
+	 * @access public
67
+	 */
68
+	public function parse()
69
+	{
70
+		$parents = array();
71
+
72
+		// flag : are we in a <pre> Tag ?
73
+		$tagPreIn = false;
74
+
75
+		// action to use for each line of the content of a <pre> Tag
76
+		$tagPreBr = array(
77
+					'name' => 'br',
78
+					'close' => false,
79
+					'param' => array(
80
+						'style' => array(),
81
+						'num'    => 0
82
+					)
83
+				);
84
+
85
+		// tag that can be not closed
86
+		$tagsNotClosed = array(
87
+			'br', 'hr', 'img', 'col',
88
+			'input', 'link', 'option',
89
+			'circle', 'ellipse', 'path', 'rect', 'line', 'polygon', 'polyline'
90
+		);
91
+
92
+		// search the HTML tags
93
+		$tmp = array();
94
+		$this->_searchCode($tmp);
95
+
96
+		// all the actions to do
97
+		$actions = array();
98
+
99
+		// foreach part of the HTML code
100
+		foreach ($tmp as $part) {
101
+			// if it is a tag code
102
+			if ($part[0]=='code') {
103
+				// analise the HTML code
104
+				$res = $this->_analiseCode($part[1]);
105
+
106
+				// if it is a real HTML tag
107
+				if ($res) {
108
+					// save the current posistion in the HTML code
109
+					$res['html_pos'] = $part[2];
110
+
111
+					// if the tag must be closed
112
+					if (!in_array($res['name'], $tagsNotClosed)) {
113
+						// if it is a closure tag
114
+						if ($res['close']) {
115
+							// HTML validation
116
+							if (count($parents)<1)
117
+								throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos']));
118
+							else if ($parents[count($parents)-1]!=$res['name'])
119
+								throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos']));
120
+							else
121
+								unset($parents[count($parents)-1]);
122
+						} else {
123
+							// if it is a autoclosed tag
124
+							if ($res['autoclose']) {
125
+								// save the opened tag
126
+								$actions[] = $res;
127
+
128
+								// prepare the closed tag
129
+								$res['params'] = array();
130
+								$res['close'] = true;
131
+							}
132
+							// else :add a child for validation
133
+							else
134
+								$parents[count($parents)] = $res['name'];
135
+						}
136
+
137
+						// if it is a <pre> tag (or <code> tag) not auclosed => update the flag
138
+						if (($res['name']=='pre' || $res['name']=='code') && !$res['autoclose']) {
139
+							$tagPreIn = !$res['close'];
140
+						}
141
+					}
142
+
143
+					// save the actions to convert
144
+					$actions[] = $res;
145
+				} else { // else (it is not a real HTML tag => we transform it in Texte
146
+					$part[0]='txt';
147
+				}
148
+			}
149
+			// if it is text
150
+			if ($part[0]=='txt') {
151
+				// if we are not in a <pre> tag
152
+				if (!$tagPreIn) {
153
+					// save the action
154
+					$actions[] = array(
155
+						'name'    => 'write',
156
+						'close'    => false,
157
+						'param' => array('txt' => $this->_prepareTxt($part[1])),
158
+					);
159
+				} else { // else (if we are in a <pre> tag)
160
+					// prepare the text
161
+					$part[1] = str_replace("\r", '', $part[1]);
162
+					$part[1] = explode("\n", $part[1]);
163
+
164
+					// foreach line of the text
165
+					foreach ($part[1] as $k => $txt) {
166
+						// transform the line
167
+						$txt = str_replace("\t", self::HTML_TAB, $txt);
168
+						$txt = str_replace(' ', '&nbsp;', $txt);
169
+
170
+						// add a break line
171
+						if ($k>0) $actions[] = $tagPreBr;
172
+
173
+						// save the action
174
+						$actions[] = array(
175
+							'name'    => 'write',
176
+							'close'    => false,
177
+							'param' => array('txt' => $this->_prepareTxt($txt, false)),
178
+						);
179
+					}
180
+				}
181
+			}
182
+		}
183
+
184
+		// for each indentified action, we have to clean up the begin and the end of the texte
185
+		// based on tags that surround it
186
+
187
+		// list of the tags to clean
188
+		$tagsToClean = array(
189
+			'page', 'page_header', 'page_footer', 'form',
190
+			'table', 'thead', 'tfoot', 'tr', 'td', 'th', 'br',
191
+			'div', 'hr', 'p', 'ul', 'ol', 'li',
192
+			'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
193
+			'bookmark', 'fieldset', 'legend',
194
+			'draw', 'circle', 'ellipse', 'path', 'rect', 'line', 'g', 'polygon', 'polyline',
195
+			'option'
196
+		);
197
+
198
+		// foreach action
199
+		$nb = count($actions);
200
+		for ($k=0; $k<$nb; $k++) {
201
+			// if it is a Text
202
+			if ($actions[$k]['name']=='write') {
203
+				// if the tag before the text is a tag to clean => ltrim on the text
204
+				if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean))
205
+					$actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']);
206
+
207
+				// if the tag after the text is a tag to clean => rtrim on the text
208
+				if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean))
209
+					$actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']);
210
+
211
+				// if the text is empty => remove the action
212
+				if (!strlen($actions[$k]['param']['txt']))
213
+					unset($actions[$k]);
214
+			}
215
+		}
216
+
217
+		// if we are not on the level 0 => HTML validator ERROR
218
+		if (count($parents)) throw new HTML2PDF_exception(5, $parents);
219
+
220
+		// save the actions to do
221
+		$this->code = array_values($actions);
222
+	}
223
+
224
+	/**
225
+	 * prepare the text
226
+	 *
227
+	 * @param   string texte
228
+	 * @param   boolean true => replace multiple space+\t+\r+\n by a single space
229
+	 * @return  string texte
230
+	 * @access  protected
231
+	 */
232
+	protected function _prepareTxt($txt, $spaces = true)
233
+	{
234
+		if ($spaces) $txt = preg_replace('/\s+/is', ' ', $txt);
235
+		$txt = str_replace('&euro;', '€', $txt);
236
+		$txt = html_entity_decode($txt, ENT_QUOTES, $this->_encoding);
237
+		return $txt;
238
+	}
239
+
240
+	/**
241
+	 * parse the HTML code
242
+	 *
243
+	 * @param    &array    array's result
244
+	 * @return   null
245
+	 */
246
+	protected function _searchCode(&$tmp)
247
+	{
248
+		// initialise the array
249
+		$tmp = array();
250
+
251
+		// regexp to separate the tags from the texts
252
+		$reg = '/(<[^>]+>)|([^<]+)+/isU';
253
+
254
+		// last match found
255
+		$str = '';
256
+		$offset = 0;
257
+
258
+		// As it finds a match
259
+		while (preg_match($reg, $this->_html, $parse, PREG_OFFSET_CAPTURE, $offset)) {
260
+			// if it is a tag
261
+			if ($parse[1][0]) {
262
+				// save the previous text if it exists
263
+				if ($str!=='')    $tmp[] = array('txt', $str);
264
+
265
+				// save the tag, with the offset
266
+				$tmp[] = array('code', trim($parse[1][0]), $offset);
267
+
268
+				// init the current text
269
+				$str = '';
270
+			} else { // else (if it is a text)
271
+				// add the new text to the current text
272
+				$str.= $parse[2][0];
273
+			}
274
+
275
+			// Update offset to the end of the match
276
+			$offset = $parse[0][1] + strlen($parse[0][0]);
277
+			unset($parse);
278
+		}
279
+		// if a text is present in the end, we save it
280
+		if ($str!='') $tmp[] = array('txt', $str);
281
+		unset($str);
282
+	}
283
+
284
+	/**
285
+	 * analise a HTML tag
286
+	 *
287
+	 * @param   string   HTML code to analise
288
+	 * @return  array    corresponding action
289
+	 */
290
+	protected function _analiseCode($code)
291
+	{
292
+		// name of the tag, opening, closure, autoclosure
293
+		$tag = '<([\/]{0,1})([_a-z0-9]+)([\/>\s]+)';
294
+		if (!preg_match('/'.$tag.'/isU', $code, $match)) return null;
295
+		$close     = ($match[1]=='/' ? true : false);
296
+		$autoclose = preg_match('/\/>$/isU', $code);
297
+		$name      = strtolower($match[2]);
298
+
299
+		// required parameters (depends on the tag name)
300
+		$param    = array();
301
+		$param['style'] = '';
302
+		if ($name=='img') {
303
+			$param['alt'] = '';
304
+			$param['src'] = '';
305
+		}
306
+		if ($name=='a') {
307
+			$param['href'] = '';
308
+		}
309
+
310
+		// read the parameters : nom=valeur
311
+		$prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
312
+		preg_match_all('/'.$prop.'/is', $code, $match);
313
+		for($k=0; $k<count($match[0]); $k++)
314
+			$param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
315
+
316
+		// read the parameters : nom="valeur"
317
+		$prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
318
+		preg_match_all('/'.$prop.'/is', $code, $match);
319
+		for($k=0; $k<count($match[0]); $k++)
320
+			$param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
321
+
322
+		// read the parameters : nom='valeur'
323
+		$prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
324
+		preg_match_all('/'.$prop.'/is', $code, $match);
325
+		for($k=0; $k<count($match[0]); $k++)
326
+			$param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
327
+
328
+		// compliance of each parameter
329
+		$color  = "#000000";
330
+		$border = null;
331
+		foreach ($param as $key => $val) {
332
+			$key = strtolower($key);
333
+			switch($key)
334
+			{
335
+				case 'width':
336
+					unset($param[$key]);
337
+					$param['style'] .= 'width: '.$val.'px; ';
338
+					break;
339
+
340
+				case 'align':
341
+					if ($name==='img') {
342
+						unset($param[$key]);
343
+						$param['style'] .= 'float: '.$val.'; ';
344
+					} elseif ($name!=='table') {
345
+						unset($param[$key]);
346
+						$param['style'] .= 'text-align: '.$val.'; ';
347
+					}
348
+					break;
349
+
350
+				case 'valign':
351
+					unset($param[$key]);
352
+					$param['style'] .= 'vertical-align: '.$val.'; ';
353
+					break;
354
+
355
+				case 'height':
356
+					unset($param[$key]);
357
+					$param['style'] .= 'height: '.$val.'px; ';
358
+					break;
359
+
360
+				case 'bgcolor':
361
+					unset($param[$key]);
362
+					$param['style'] .= 'background: '.$val.'; ';
363
+					break;
364
+
365
+				case 'bordercolor':
366
+					unset($param[$key]);
367
+					$color = $val;
368
+					break;
369
+
370
+				case 'border':
371
+					unset($param[$key]);
372
+					if (preg_match('/^[0-9]+$/isU', $val)) $val = $val.'px';
373
+					$border = $val;
374
+					break;
375
+
376
+				case 'cellpadding':
377
+				case 'cellspacing':
378
+					if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val.'px';
379
+					break;
380
+
381
+				case 'colspan':
382
+				case 'rowspan':
383
+					$val = preg_replace('/[^0-9]/isU', '', $val);
384
+					if (!$val) $val = 1;
385
+					$param[$key] = $val;
386
+					break;
387
+			}
388
+		}
389
+
390
+		// compliance of the border
391
+		if ($border!==null) {
392
+			if ($border)    $border = 'border: solid '.$border.' '.$color;
393
+			else            $border = 'border: none';
394
+
395
+			$param['style'] .= $border.'; ';
396
+			$param['border'] = $border;
397
+		}
398
+
399
+		// reading styles: decomposition and standardization
400
+		$styles = explode(';', $param['style']);
401
+		$param['style'] = array();
402
+		foreach ($styles as $style) {
403
+			$tmp = explode(':', $style);
404
+			if (count($tmp)>1) {
405
+				$cod = $tmp[0];
406
+				unset($tmp[0]);
407
+				$tmp = implode(':', $tmp);
408
+				$param['style'][trim(strtolower($cod))] = preg_replace('/[\s]+/isU', ' ', trim($tmp));
409
+			}
410
+		}
411
+
412
+		// determining the level of table opening, with an added level
413
+		if (in_array($name, array('ul', 'ol', 'table')) && !$close) {
414
+			$this->_num++;
415
+			$this->_level[count($this->_level)] = $this->_num;
416
+		}
417
+
418
+		// get the level of the table containing the element
419
+		if (!isset($param['num'])) {
420
+			$param['num'] = $this->_level[count($this->_level)-1];
421
+		}
422
+
423
+		// for closures table: remove a level
424
+		if (in_array($name, array('ul', 'ol', 'table')) && $close) {
425
+			unset($this->_level[count($this->_level)-1]);
426
+		}
427
+
428
+		// prepare the parameters
429
+		if (isset($param['value']))  $param['value']  = $this->_prepareTxt($param['value']);
430
+		if (isset($param['alt']))    $param['alt']    = $this->_prepareTxt($param['alt']);
431
+		if (isset($param['title']))  $param['title']  = $this->_prepareTxt($param['title']);
432
+		if (isset($param['class']))  $param['class']  = $this->_prepareTxt($param['class']);
433
+
434
+		// return the new action to do
435
+		return array('name' => $name, 'close' => $close ? 1 : 0, 'autoclose' => $autoclose, 'param' => $param);
436
+	}
437
+
438
+	/**
439
+	 * get a full level of HTML, between an opening and closing corresponding
440
+	 *
441
+	 * @param   integer key
442
+	 * @return  array   actions
443
+	 */
444
+	public function getLevel($k)
445
+	{
446
+		// if the code does not exist => return empty
447
+		if (!isset($this->code[$k])) return array();
448
+
449
+		// the tag to detect
450
+		$detect = $this->code[$k]['name'];
451
+
452
+		// if it is a text => return
453
+		if ($detect=='write') {
454
+			return array($this->code[$k]);
455
+		}
456
+
457
+		//
458
+		$level = 0;      // depth level
459
+		$end = false;    // end of the search
460
+		$code = array(); // extract code
461
+
462
+		// while it's not ended
463
+		while (!$end) {
464
+			// current action
465
+			$row = $this->code[$k];
466
+
467
+			// if 'write' => we add the text
468
+			if ($row['name']=='write') {
469
+				$code[] = $row;
470
+			} else { // else, it is a html tag
471
+				$not = false; // flag for not taking into account the current tag
472
+
473
+				// if it is the searched tag
474
+				if ($row['name']==$detect) {
475
+					// if we are just at the root level => dont take it
476
+					if ($level==0) {
477
+						$not = true;
478
+					}
479
+
480
+					// update the level
481
+					$level+= ($row['close'] ? -1 : 1);
482
+
483
+					// if we are now at the root level => it is the end, and dont take it
484
+					if ($level==0) {
485
+						$not = true;
486
+						$end = true;
487
+					}
488
+				}
489
+
490
+				// if we can takin into account the current tag => save it
491
+				if (!$not) {
492
+					if (isset($row['style']['text-align'])) unset($row['style']['text-align']);
493
+					$code[] = $row;
494
+				}
495
+			}
496
+
497
+			// it continues as long as there has code to analise
498
+			if (isset($this->code[$k+1]))
499
+				$k++;
500
+			else
501
+				$end = true;
502
+		}
503
+
504
+		// return the extract
505
+		return $code;
506
+	}
507
+
508
+	/**
509
+	 * return a part of the HTML code, for error message
510
+	 *
511
+	 * @param   integer position
512
+	 * @param   integer take before
513
+	 * @param   integer take after
514
+	 * @return  string  part of the html code
515
+	 */
516
+	public function getHtmlErrorCode($pos, $before=30, $after=40)
517
+	{
518
+		return substr($this->_html, $pos-$before, $before+$after);
519
+	}
520 520
 }
521 521
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * HTML2PDF Librairy - parsingHtml class
4 4
  *
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
 
12 12
 class HTML2PDF_parsingHtml
13 13
 {
14
-    protected    $_html     = '';        // HTML code to parse
15
-    protected    $_num      = 0;         // table number
16
-    protected    $_level    = 0;         // table level
17
-    protected    $_encoding = '';        // encoding
18
-    public       $code      = array();   // parsed HTML codfe
14
+    protected    $_html     = ''; // HTML code to parse
15
+    protected    $_num      = 0; // table number
16
+    protected    $_level    = 0; // table level
17
+    protected    $_encoding = ''; // encoding
18
+    public       $code      = array(); // parsed HTML codfe
19 19
 
20 20
     const HTML_TAB = '        ';
21 21
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         $this->_num   = 0;
31 31
         $this->_level = array($this->_num);
32 32
         $this->_html  = '';
33
-        $this->code  = array();
33
+        $this->code = array();
34 34
         $this->setEncoding($encoding);
35 35
     }
36 36
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         // foreach part of the HTML code
100 100
         foreach ($tmp as $part) {
101 101
             // if it is a tag code
102
-            if ($part[0]=='code') {
102
+            if ($part[0] == 'code') {
103 103
                 // analise the HTML code
104 104
                 $res = $this->_analiseCode($part[1]);
105 105
 
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
                         // if it is a closure tag
114 114
                         if ($res['close']) {
115 115
                             // HTML validation
116
-                            if (count($parents)<1)
116
+                            if (count($parents) < 1)
117 117
                                 throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos']));
118
-                            else if ($parents[count($parents)-1]!=$res['name'])
118
+                            else if ($parents[count($parents) - 1] != $res['name'])
119 119
                                 throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos']));
120 120
                             else
121
-                                unset($parents[count($parents)-1]);
121
+                                unset($parents[count($parents) - 1]);
122 122
                         } else {
123 123
                             // if it is a autoclosed tag
124 124
                             if ($res['autoclose']) {
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
                         }
136 136
 
137 137
                         // if it is a <pre> tag (or <code> tag) not auclosed => update the flag
138
-                        if (($res['name']=='pre' || $res['name']=='code') && !$res['autoclose']) {
138
+                        if (($res['name'] == 'pre' || $res['name'] == 'code') && !$res['autoclose']) {
139 139
                             $tagPreIn = !$res['close'];
140 140
                         }
141 141
                     }
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
                     // save the actions to convert
144 144
                     $actions[] = $res;
145 145
                 } else { // else (it is not a real HTML tag => we transform it in Texte
146
-                    $part[0]='txt';
146
+                    $part[0] = 'txt';
147 147
                 }
148 148
             }
149 149
             // if it is text
150
-            if ($part[0]=='txt') {
150
+            if ($part[0] == 'txt') {
151 151
                 // if we are not in a <pre> tag
152 152
                 if (!$tagPreIn) {
153 153
                     // save the action
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
                         $txt = str_replace(' ', '&nbsp;', $txt);
169 169
 
170 170
                         // add a break line
171
-                        if ($k>0) $actions[] = $tagPreBr;
171
+                        if ($k > 0) $actions[] = $tagPreBr;
172 172
 
173 173
                         // save the action
174 174
                         $actions[] = array(
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
 
198 198
         // foreach action
199 199
         $nb = count($actions);
200
-        for ($k=0; $k<$nb; $k++) {
200
+        for ($k = 0; $k < $nb; $k++) {
201 201
             // if it is a Text
202
-            if ($actions[$k]['name']=='write') {
202
+            if ($actions[$k]['name'] == 'write') {
203 203
                 // if the tag before the text is a tag to clean => ltrim on the text
204
-                if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean))
204
+                if ($k > 0 && in_array($actions[$k - 1]['name'], $tagsToClean))
205 205
                     $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']);
206 206
 
207 207
                 // if the tag after the text is a tag to clean => rtrim on the text
208
-                if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean))
208
+                if ($k < $nb - 1 && in_array($actions[$k + 1]['name'], $tagsToClean))
209 209
                     $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']);
210 210
 
211 211
                 // if the text is empty => remove the action
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             // if it is a tag
261 261
             if ($parse[1][0]) {
262 262
                 // save the previous text if it exists
263
-                if ($str!=='')    $tmp[] = array('txt', $str);
263
+                if ($str !== '')    $tmp[] = array('txt', $str);
264 264
 
265 265
                 // save the tag, with the offset
266 266
                 $tmp[] = array('code', trim($parse[1][0]), $offset);
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
                 $str = '';
270 270
             } else { // else (if it is a text)
271 271
                 // add the new text to the current text
272
-                $str.= $parse[2][0];
272
+                $str .= $parse[2][0];
273 273
             }
274 274
 
275 275
             // Update offset to the end of the match
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
             unset($parse);
278 278
         }
279 279
         // if a text is present in the end, we save it
280
-        if ($str!='') $tmp[] = array('txt', $str);
280
+        if ($str != '') $tmp[] = array('txt', $str);
281 281
         unset($str);
282 282
     }
283 283
 
@@ -291,38 +291,38 @@  discard block
 block discarded – undo
291 291
     {
292 292
         // name of the tag, opening, closure, autoclosure
293 293
         $tag = '<([\/]{0,1})([_a-z0-9]+)([\/>\s]+)';
294
-        if (!preg_match('/'.$tag.'/isU', $code, $match)) return null;
295
-        $close     = ($match[1]=='/' ? true : false);
294
+        if (!preg_match('/' . $tag . '/isU', $code, $match)) return null;
295
+        $close     = ($match[1] == '/' ? true : false);
296 296
         $autoclose = preg_match('/\/>$/isU', $code);
297 297
         $name      = strtolower($match[2]);
298 298
 
299 299
         // required parameters (depends on the tag name)
300
-        $param    = array();
300
+        $param = array();
301 301
         $param['style'] = '';
302
-        if ($name=='img') {
302
+        if ($name == 'img') {
303 303
             $param['alt'] = '';
304 304
             $param['src'] = '';
305 305
         }
306
-        if ($name=='a') {
306
+        if ($name == 'a') {
307 307
             $param['href'] = '';
308 308
         }
309 309
 
310 310
         // read the parameters : nom=valeur
311 311
         $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
312
-        preg_match_all('/'.$prop.'/is', $code, $match);
313
-        for($k=0; $k<count($match[0]); $k++)
312
+        preg_match_all('/' . $prop . '/is', $code, $match);
313
+        for ($k = 0; $k < count($match[0]); $k++)
314 314
             $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
315 315
 
316 316
         // read the parameters : nom="valeur"
317 317
         $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
318
-        preg_match_all('/'.$prop.'/is', $code, $match);
319
-        for($k=0; $k<count($match[0]); $k++)
318
+        preg_match_all('/' . $prop . '/is', $code, $match);
319
+        for ($k = 0; $k < count($match[0]); $k++)
320 320
             $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
321 321
 
322 322
         // read the parameters : nom='valeur'
323 323
         $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
324
-        preg_match_all('/'.$prop.'/is', $code, $match);
325
-        for($k=0; $k<count($match[0]); $k++)
324
+        preg_match_all('/' . $prop . '/is', $code, $match);
325
+        for ($k = 0; $k < count($match[0]); $k++)
326 326
             $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
327 327
 
328 328
         // compliance of each parameter
@@ -330,36 +330,36 @@  discard block
 block discarded – undo
330 330
         $border = null;
331 331
         foreach ($param as $key => $val) {
332 332
             $key = strtolower($key);
333
-            switch($key)
333
+            switch ($key)
334 334
             {
335 335
                 case 'width':
336 336
                     unset($param[$key]);
337
-                    $param['style'] .= 'width: '.$val.'px; ';
337
+                    $param['style'] .= 'width: ' . $val . 'px; ';
338 338
                     break;
339 339
 
340 340
                 case 'align':
341
-                    if ($name==='img') {
341
+                    if ($name === 'img') {
342 342
                         unset($param[$key]);
343
-                        $param['style'] .= 'float: '.$val.'; ';
344
-                    } elseif ($name!=='table') {
343
+                        $param['style'] .= 'float: ' . $val . '; ';
344
+                    } elseif ($name !== 'table') {
345 345
                         unset($param[$key]);
346
-                        $param['style'] .= 'text-align: '.$val.'; ';
346
+                        $param['style'] .= 'text-align: ' . $val . '; ';
347 347
                     }
348 348
                     break;
349 349
 
350 350
                 case 'valign':
351 351
                     unset($param[$key]);
352
-                    $param['style'] .= 'vertical-align: '.$val.'; ';
352
+                    $param['style'] .= 'vertical-align: ' . $val . '; ';
353 353
                     break;
354 354
 
355 355
                 case 'height':
356 356
                     unset($param[$key]);
357
-                    $param['style'] .= 'height: '.$val.'px; ';
357
+                    $param['style'] .= 'height: ' . $val . 'px; ';
358 358
                     break;
359 359
 
360 360
                 case 'bgcolor':
361 361
                     unset($param[$key]);
362
-                    $param['style'] .= 'background: '.$val.'; ';
362
+                    $param['style'] .= 'background: ' . $val . '; ';
363 363
                     break;
364 364
 
365 365
                 case 'bordercolor':
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
 
370 370
                 case 'border':
371 371
                     unset($param[$key]);
372
-                    if (preg_match('/^[0-9]+$/isU', $val)) $val = $val.'px';
372
+                    if (preg_match('/^[0-9]+$/isU', $val)) $val = $val . 'px';
373 373
                     $border = $val;
374 374
                     break;
375 375
 
376 376
                 case 'cellpadding':
377 377
                 case 'cellspacing':
378
-                    if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val.'px';
378
+                    if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val . 'px';
379 379
                     break;
380 380
 
381 381
                 case 'colspan':
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
         }
389 389
 
390 390
         // compliance of the border
391
-        if ($border!==null) {
392
-            if ($border)    $border = 'border: solid '.$border.' '.$color;
391
+        if ($border !== null) {
392
+            if ($border)    $border = 'border: solid ' . $border . ' ' . $color;
393 393
             else            $border = 'border: none';
394 394
 
395
-            $param['style'] .= $border.'; ';
395
+            $param['style'] .= $border . '; ';
396 396
             $param['border'] = $border;
397 397
         }
398 398
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         $param['style'] = array();
402 402
         foreach ($styles as $style) {
403 403
             $tmp = explode(':', $style);
404
-            if (count($tmp)>1) {
404
+            if (count($tmp) > 1) {
405 405
                 $cod = $tmp[0];
406 406
                 unset($tmp[0]);
407 407
                 $tmp = implode(':', $tmp);
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
 
418 418
         // get the level of the table containing the element
419 419
         if (!isset($param['num'])) {
420
-            $param['num'] = $this->_level[count($this->_level)-1];
420
+            $param['num'] = $this->_level[count($this->_level) - 1];
421 421
         }
422 422
 
423 423
         // for closures table: remove a level
424 424
         if (in_array($name, array('ul', 'ol', 'table')) && $close) {
425
-            unset($this->_level[count($this->_level)-1]);
425
+            unset($this->_level[count($this->_level) - 1]);
426 426
         }
427 427
 
428 428
         // prepare the parameters
@@ -450,13 +450,13 @@  discard block
 block discarded – undo
450 450
         $detect = $this->code[$k]['name'];
451 451
 
452 452
         // if it is a text => return
453
-        if ($detect=='write') {
453
+        if ($detect == 'write') {
454 454
             return array($this->code[$k]);
455 455
         }
456 456
 
457 457
         //
458
-        $level = 0;      // depth level
459
-        $end = false;    // end of the search
458
+        $level = 0; // depth level
459
+        $end = false; // end of the search
460 460
         $code = array(); // extract code
461 461
 
462 462
         // while it's not ended
@@ -465,23 +465,23 @@  discard block
 block discarded – undo
465 465
             $row = $this->code[$k];
466 466
 
467 467
             // if 'write' => we add the text
468
-            if ($row['name']=='write') {
468
+            if ($row['name'] == 'write') {
469 469
                 $code[] = $row;
470 470
             } else { // else, it is a html tag
471 471
                 $not = false; // flag for not taking into account the current tag
472 472
 
473 473
                 // if it is the searched tag
474
-                if ($row['name']==$detect) {
474
+                if ($row['name'] == $detect) {
475 475
                     // if we are just at the root level => dont take it
476
-                    if ($level==0) {
476
+                    if ($level == 0) {
477 477
                         $not = true;
478 478
                     }
479 479
 
480 480
                     // update the level
481
-                    $level+= ($row['close'] ? -1 : 1);
481
+                    $level += ($row['close'] ? -1 : 1);
482 482
 
483 483
                     // if we are now at the root level => it is the end, and dont take it
484
-                    if ($level==0) {
484
+                    if ($level == 0) {
485 485
                         $not = true;
486 486
                         $end = true;
487 487
                     }
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
             }
496 496
 
497 497
             // it continues as long as there has code to analise
498
-            if (isset($this->code[$k+1]))
498
+            if (isset($this->code[$k + 1]))
499 499
                 $k++;
500 500
             else
501 501
                 $end = true;
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
      * @param   integer take after
514 514
      * @return  string  part of the html code
515 515
      */
516
-    public function getHtmlErrorCode($pos, $before=30, $after=40)
516
+    public function getHtmlErrorCode($pos, $before = 30, $after = 40)
517 517
     {
518
-        return substr($this->_html, $pos-$before, $before+$after);
518
+        return substr($this->_html, $pos - $before, $before + $after);
519 519
     }
520 520
 }
521 521
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +86 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * HTML2PDF Librairy - parsingHtml class
4 6
  *
@@ -113,12 +115,13 @@  discard block
 block discarded – undo
113 115
                         // if it is a closure tag
114 116
                         if ($res['close']) {
115 117
                             // HTML validation
116
-                            if (count($parents)<1)
117
-                                throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos']));
118
-                            else if ($parents[count($parents)-1]!=$res['name'])
119
-                                throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos']));
120
-                            else
121
-                                unset($parents[count($parents)-1]);
118
+                            if (count($parents)<1) {
119
+                                                            throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos']));
120
+                            } else if ($parents[count($parents)-1]!=$res['name']) {
121
+                                                            throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos']));
122
+                            } else {
123
+                                                            unset($parents[count($parents)-1]);
124
+                            }
122 125
                         } else {
123 126
                             // if it is a autoclosed tag
124 127
                             if ($res['autoclose']) {
@@ -130,8 +133,9 @@  discard block
 block discarded – undo
130 133
                                 $res['close'] = true;
131 134
                             }
132 135
                             // else :add a child for validation
133
-                            else
134
-                                $parents[count($parents)] = $res['name'];
136
+                            else {
137
+                                                            $parents[count($parents)] = $res['name'];
138
+                            }
135 139
                         }
136 140
 
137 141
                         // if it is a <pre> tag (or <code> tag) not auclosed => update the flag
@@ -168,7 +172,9 @@  discard block
 block discarded – undo
168 172
                         $txt = str_replace(' ', '&nbsp;', $txt);
169 173
 
170 174
                         // add a break line
171
-                        if ($k>0) $actions[] = $tagPreBr;
175
+                        if ($k>0) {
176
+                        	$actions[] = $tagPreBr;
177
+                        }
172 178
 
173 179
                         // save the action
174 180
                         $actions[] = array(
@@ -201,21 +207,26 @@  discard block
 block discarded – undo
201 207
             // if it is a Text
202 208
             if ($actions[$k]['name']=='write') {
203 209
                 // if the tag before the text is a tag to clean => ltrim on the text
204
-                if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean))
205
-                    $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']);
210
+                if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean)) {
211
+                                    $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']);
212
+                }
206 213
 
207 214
                 // if the tag after the text is a tag to clean => rtrim on the text
208
-                if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean))
209
-                    $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']);
215
+                if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean)) {
216
+                                    $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']);
217
+                }
210 218
 
211 219
                 // if the text is empty => remove the action
212
-                if (!strlen($actions[$k]['param']['txt']))
213
-                    unset($actions[$k]);
220
+                if (!strlen($actions[$k]['param']['txt'])) {
221
+                                    unset($actions[$k]);
222
+                }
214 223
             }
215 224
         }
216 225
 
217 226
         // if we are not on the level 0 => HTML validator ERROR
218
-        if (count($parents)) throw new HTML2PDF_exception(5, $parents);
227
+        if (count($parents)) {
228
+        	throw new HTML2PDF_exception(5, $parents);
229
+        }
219 230
 
220 231
         // save the actions to do
221 232
         $this->code = array_values($actions);
@@ -231,7 +242,9 @@  discard block
 block discarded – undo
231 242
      */
232 243
     protected function _prepareTxt($txt, $spaces = true)
233 244
     {
234
-        if ($spaces) $txt = preg_replace('/\s+/is', ' ', $txt);
245
+        if ($spaces) {
246
+        	$txt = preg_replace('/\s+/is', ' ', $txt);
247
+        }
235 248
         $txt = str_replace('&euro;', '€', $txt);
236 249
         $txt = html_entity_decode($txt, ENT_QUOTES, $this->_encoding);
237 250
         return $txt;
@@ -260,7 +273,9 @@  discard block
 block discarded – undo
260 273
             // if it is a tag
261 274
             if ($parse[1][0]) {
262 275
                 // save the previous text if it exists
263
-                if ($str!=='')    $tmp[] = array('txt', $str);
276
+                if ($str!=='') {
277
+                	$tmp[] = array('txt', $str);
278
+                }
264 279
 
265 280
                 // save the tag, with the offset
266 281
                 $tmp[] = array('code', trim($parse[1][0]), $offset);
@@ -277,7 +292,9 @@  discard block
 block discarded – undo
277 292
             unset($parse);
278 293
         }
279 294
         // if a text is present in the end, we save it
280
-        if ($str!='') $tmp[] = array('txt', $str);
295
+        if ($str!='') {
296
+        	$tmp[] = array('txt', $str);
297
+        }
281 298
         unset($str);
282 299
     }
283 300
 
@@ -291,7 +308,9 @@  discard block
 block discarded – undo
291 308
     {
292 309
         // name of the tag, opening, closure, autoclosure
293 310
         $tag = '<([\/]{0,1})([_a-z0-9]+)([\/>\s]+)';
294
-        if (!preg_match('/'.$tag.'/isU', $code, $match)) return null;
311
+        if (!preg_match('/'.$tag.'/isU', $code, $match)) {
312
+        	return null;
313
+        }
295 314
         $close     = ($match[1]=='/' ? true : false);
296 315
         $autoclose = preg_match('/\/>$/isU', $code);
297 316
         $name      = strtolower($match[2]);
@@ -310,20 +329,23 @@  discard block
 block discarded – undo
310 329
         // read the parameters : nom=valeur
311 330
         $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)';
312 331
         preg_match_all('/'.$prop.'/is', $code, $match);
313
-        for($k=0; $k<count($match[0]); $k++)
314
-            $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
332
+        for($k=0; $k<count($match[0]); $k++) {
333
+                    $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
334
+        }
315 335
 
316 336
         // read the parameters : nom="valeur"
317 337
         $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]';
318 338
         preg_match_all('/'.$prop.'/is', $code, $match);
319
-        for($k=0; $k<count($match[0]); $k++)
320
-            $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
339
+        for($k=0; $k<count($match[0]); $k++) {
340
+                    $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
341
+        }
321 342
 
322 343
         // read the parameters : nom='valeur'
323 344
         $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']";
324 345
         preg_match_all('/'.$prop.'/is', $code, $match);
325
-        for($k=0; $k<count($match[0]); $k++)
326
-            $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
346
+        for($k=0; $k<count($match[0]); $k++) {
347
+                    $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
348
+        }
327 349
 
328 350
         // compliance of each parameter
329 351
         $color  = "#000000";
@@ -369,19 +391,25 @@  discard block
 block discarded – undo
369 391
 
370 392
                 case 'border':
371 393
                     unset($param[$key]);
372
-                    if (preg_match('/^[0-9]+$/isU', $val)) $val = $val.'px';
394
+                    if (preg_match('/^[0-9]+$/isU', $val)) {
395
+                    	$val = $val.'px';
396
+                    }
373 397
                     $border = $val;
374 398
                     break;
375 399
 
376 400
                 case 'cellpadding':
377 401
                 case 'cellspacing':
378
-                    if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val.'px';
402
+                    if (preg_match('/^([0-9]+)$/isU', $val)) {
403
+                    	$param[$key] = $val.'px';
404
+                    }
379 405
                     break;
380 406
 
381 407
                 case 'colspan':
382 408
                 case 'rowspan':
383 409
                     $val = preg_replace('/[^0-9]/isU', '', $val);
384
-                    if (!$val) $val = 1;
410
+                    if (!$val) {
411
+                    	$val = 1;
412
+                    }
385 413
                     $param[$key] = $val;
386 414
                     break;
387 415
             }
@@ -389,8 +417,11 @@  discard block
 block discarded – undo
389 417
 
390 418
         // compliance of the border
391 419
         if ($border!==null) {
392
-            if ($border)    $border = 'border: solid '.$border.' '.$color;
393
-            else            $border = 'border: none';
420
+            if ($border) {
421
+            	$border = 'border: solid '.$border.' '.$color;
422
+            } else {
423
+            	$border = 'border: none';
424
+            }
394 425
 
395 426
             $param['style'] .= $border.'; ';
396 427
             $param['border'] = $border;
@@ -426,10 +457,18 @@  discard block
 block discarded – undo
426 457
         }
427 458
 
428 459
         // prepare the parameters
429
-        if (isset($param['value']))  $param['value']  = $this->_prepareTxt($param['value']);
430
-        if (isset($param['alt']))    $param['alt']    = $this->_prepareTxt($param['alt']);
431
-        if (isset($param['title']))  $param['title']  = $this->_prepareTxt($param['title']);
432
-        if (isset($param['class']))  $param['class']  = $this->_prepareTxt($param['class']);
460
+        if (isset($param['value'])) {
461
+        	$param['value']  = $this->_prepareTxt($param['value']);
462
+        }
463
+        if (isset($param['alt'])) {
464
+        	$param['alt']    = $this->_prepareTxt($param['alt']);
465
+        }
466
+        if (isset($param['title'])) {
467
+        	$param['title']  = $this->_prepareTxt($param['title']);
468
+        }
469
+        if (isset($param['class'])) {
470
+        	$param['class']  = $this->_prepareTxt($param['class']);
471
+        }
433 472
 
434 473
         // return the new action to do
435 474
         return array('name' => $name, 'close' => $close ? 1 : 0, 'autoclose' => $autoclose, 'param' => $param);
@@ -444,7 +483,9 @@  discard block
 block discarded – undo
444 483
     public function getLevel($k)
445 484
     {
446 485
         // if the code does not exist => return empty
447
-        if (!isset($this->code[$k])) return array();
486
+        if (!isset($this->code[$k])) {
487
+        	return array();
488
+        }
448 489
 
449 490
         // the tag to detect
450 491
         $detect = $this->code[$k]['name'];
@@ -489,16 +530,19 @@  discard block
 block discarded – undo
489 530
 
490 531
                 // if we can takin into account the current tag => save it
491 532
                 if (!$not) {
492
-                    if (isset($row['style']['text-align'])) unset($row['style']['text-align']);
533
+                    if (isset($row['style']['text-align'])) {
534
+                    	unset($row['style']['text-align']);
535
+                    }
493 536
                     $code[] = $row;
494 537
                 }
495 538
             }
496 539
 
497 540
             // it continues as long as there has code to analise
498
-            if (isset($this->code[$k+1]))
499
-                $k++;
500
-            else
501
-                $end = true;
541
+            if (isset($this->code[$k+1])) {
542
+                            $k++;
543
+            } else {
544
+                            $end = true;
545
+            }
502 546
         }
503 547
 
504 548
         // return the extract
Please login to merge, or discard this patch.
includes/librairies/HTML2PDF/_tcpdf_5.0.002/barcodes.php 4 patches
Doc Comments   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	/**
326 326
 	 * Encode a string to be used for CODE 39 Extended mode.
327 327
 	 * @param string $code code to represent.
328
-	 * @return encoded string.
328
+	 * @return false|string string.
329 329
 	 * @access protected
330 330
 	 */
331 331
 	protected function encode_code39_ext($code) {
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	/**
377 377
 	 * Calculate CODE 39 checksum (modulo 43).
378 378
 	 * @param string $code code to represent.
379
-	 * @return char checksum.
379
+	 * @return string checksum.
380 380
 	 * @access protected
381 381
 	 */
382 382
 	protected function checksum_code39($code) {
@@ -399,7 +399,6 @@  discard block
 block discarded – undo
399 399
 	 * CODE 93 - USS-93
400 400
 	 * Compact code similar to Code 39
401 401
 	 * @param string $code code to represent.
402
-	 * @param boolean $checksum if true add a checksum to the code
403 402
 	 * @return array barcode representation.
404 403
 	 * @access protected
405 404
 	 */
@@ -988,7 +987,7 @@  discard block
 block discarded – undo
988 987
 	 * UPC-A: Universal product code seen on almost all retail products in the USA and Canada
989 988
 	 * UPC-E: Short version of UPC symbol
990 989
 	 * @param string $code code to represent.
991
-	 * @param string $len barcode type: 6 = UPC-E, 8 = EAN8, 13 = EAN13, 12 = UPC-A
990
+	 * @param integer $len barcode type: 6 = UPC-E, 8 = EAN8, 13 = EAN13, 12 = UPC-A
992 991
 	 * @return array barcode representation.
993 992
 	 * @access protected
994 993
 	 */
@@ -1181,7 +1180,7 @@  discard block
 block discarded – undo
1181 1180
 	 * 2-Digit Ext.: Used to indicate magazines and newspaper issue numbers
1182 1181
 	 * 5-Digit Ext.: Used to mark suggested retail price of books
1183 1182
 	 * @param string $code code to represent.
1184
-	 * @param string $len barcode type: 2 = 2-Digit, 5 = 5-Digit
1183
+	 * @param integer $len barcode type: 2 = 2-Digit, 5 = 5-Digit
1185 1184
 	 * @return array barcode representation.
1186 1185
 	 * @access protected
1187 1186
 	 */
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
  */
52 52
 
53 53
 	/**
54
-	* PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www.tcpdf.org).<br>
55
-	* @name TCPDFBarcode
56
-	* @package com.tecnick.tcpdf
57
-	* @version 1.0.008
58
-	* @author Nicola Asuni
59
-	* @link http://www.tcpdf.org
60
-	* @license http://www.gnu.org/copyleft/lesser.html LGPL
61
-	*/
54
+	 * PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www.tcpdf.org).<br>
55
+	 * @name TCPDFBarcode
56
+	 * @package com.tecnick.tcpdf
57
+	 * @version 1.0.008
58
+	 * @author Nicola Asuni
59
+	 * @link http://www.tcpdf.org
60
+	 * @license http://www.gnu.org/copyleft/lesser.html LGPL
61
+	 */
62 62
 class TCPDFBarcode {
63 63
 	
64 64
 	/**
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * <li>$arrcode['bcode'][$k]['h'] bar height in units.</li>
80 80
 	 * <li>$arrcode['bcode'][$k]['p'] bar top position (0 = top, 1 = middle)</li></ul>
81 81
 	 * @param string $code code to print
82
- 	 * @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
82
+	 * @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
83 83
 	 */
84 84
 	public function __construct($code, $type) {
85 85
 		$this->setBarcode($code, $type);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	
88 88
 	/** 
89 89
 	 * Return an array representations of barcode.
90
- 	 * @return array
90
+	 * @return array
91 91
 	 */
92 92
 	public function getBarcodeArray() {
93 93
 		return $this->barcode_array;
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	/** 
97 97
 	 * Set the barcode.
98 98
 	 * @param string $code code to print
99
- 	 * @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
100
- 	 * @return array
99
+	 * @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
100
+	 * @return array
101 101
 	 */
102 102
 	public function setBarcode($code, $type) {
103 103
 		switch (strtoupper($type)) {
Please login to merge, or discard this patch.
Spacing   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 //============================================================+
3 3
 // File name   : barcodes.php
4 4
 // Begin       : 2008-06-09
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 * @return array barcode representation.
235 235
 	 * @access protected
236 236
 	 */
237
-	protected function barcode_code39($code, $extended=false, $checksum=false) {
237
+	protected function barcode_code39($code, $extended = false, $checksum = false) {
238 238
 		$chr['0'] = '111221211';
239 239
 		$chr['1'] = '211211112';
240 240
 		$chr['2'] = '112211112';
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
 			$code .= $this->checksum_code39($code);
294 294
 		}
295 295
 		// add start and stop codes
296
-		$code = '*'.$code.'*';
296
+		$code = '*' . $code . '*';
297 297
 		
298 298
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
299 299
 		$k = 0;
300 300
 		$clen = strlen($code);
301 301
 		for ($i = 0; $i < $clen; ++$i) {
302 302
 			$char = $code{$i};
303
-			if(!isset($chr[$char])) {
303
+			if (!isset($chr[$char])) {
304 304
 				// invalid character
305 305
 				return false;
306 306
 			}
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 			chr(124) => '%Q', chr(125) => '%R', chr(126) => '%S', chr(127) => '%T');
365 365
 		$code_ext = '';
366 366
 		$clen = strlen($code);
367
-		for ($i = 0 ; $i < $clen; ++$i) {
367
+		for ($i = 0; $i < $clen; ++$i) {
368 368
 			if (ord($code{$i}) > 127) {
369 369
 				return false;
370 370
 			}
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 			'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%');
388 388
 		$sum = 0;
389 389
 		$clen = strlen($code);
390
-		for ($i = 0 ; $i < $clen; ++$i) {
390
+		for ($i = 0; $i < $clen; ++$i) {
391 391
 			$k = array_keys($chars, $code{$i});
392 392
 			$sum += $k[0];
393 393
 		}
@@ -454,41 +454,41 @@  discard block
 block discarded – undo
454 454
 		$chr['*'] = '111141';
455 455
 		$code = strtoupper($code);
456 456
 		$encode = array(
457
-			chr(0) => chr(131).'U', chr(1) => chr(128).'A', chr(2) => chr(128).'B', chr(3) => chr(128).'C',
458
-			chr(4) => chr(128).'D', chr(5) => chr(128).'E', chr(6) => chr(128).'F', chr(7) => chr(128).'G',
459
-			chr(8) => chr(128).'H', chr(9) => chr(128).'I', chr(10) => chr(128).'J', chr(11) => '£K',
460
-			chr(12) => chr(128).'L', chr(13) => chr(128).'M', chr(14) => chr(128).'N', chr(15) => chr(128).'O',
461
-			chr(16) => chr(128).'P', chr(17) => chr(128).'Q', chr(18) => chr(128).'R', chr(19) => chr(128).'S',
462
-			chr(20) => chr(128).'T', chr(21) => chr(128).'U', chr(22) => chr(128).'V', chr(23) => chr(128).'W',
463
-			chr(24) => chr(128).'X', chr(25) => chr(128).'Y', chr(26) => chr(128).'Z', chr(27) => chr(131).'A',
464
-			chr(28) => chr(131).'B', chr(29) => chr(131).'C', chr(30) => chr(131).'D', chr(31) => chr(131).'E',
465
-			chr(32) => ' ', chr(33) => chr(129).'A', chr(34) => chr(129).'B', chr(35) => chr(129).'C',
466
-			chr(36) => chr(129).'D', chr(37) => chr(129).'E', chr(38) => chr(129).'F', chr(39) => chr(129).'G',
467
-			chr(40) => chr(129).'H', chr(41) => chr(129).'I', chr(42) => chr(129).'J', chr(43) => chr(129).'K',
468
-			chr(44) => chr(129).'L', chr(45) => '-', chr(46) => '.', chr(47) => chr(129).'O',
457
+			chr(0) => chr(131) . 'U', chr(1) => chr(128) . 'A', chr(2) => chr(128) . 'B', chr(3) => chr(128) . 'C',
458
+			chr(4) => chr(128) . 'D', chr(5) => chr(128) . 'E', chr(6) => chr(128) . 'F', chr(7) => chr(128) . 'G',
459
+			chr(8) => chr(128) . 'H', chr(9) => chr(128) . 'I', chr(10) => chr(128) . 'J', chr(11) => '£K',
460
+			chr(12) => chr(128) . 'L', chr(13) => chr(128) . 'M', chr(14) => chr(128) . 'N', chr(15) => chr(128) . 'O',
461
+			chr(16) => chr(128) . 'P', chr(17) => chr(128) . 'Q', chr(18) => chr(128) . 'R', chr(19) => chr(128) . 'S',
462
+			chr(20) => chr(128) . 'T', chr(21) => chr(128) . 'U', chr(22) => chr(128) . 'V', chr(23) => chr(128) . 'W',
463
+			chr(24) => chr(128) . 'X', chr(25) => chr(128) . 'Y', chr(26) => chr(128) . 'Z', chr(27) => chr(131) . 'A',
464
+			chr(28) => chr(131) . 'B', chr(29) => chr(131) . 'C', chr(30) => chr(131) . 'D', chr(31) => chr(131) . 'E',
465
+			chr(32) => ' ', chr(33) => chr(129) . 'A', chr(34) => chr(129) . 'B', chr(35) => chr(129) . 'C',
466
+			chr(36) => chr(129) . 'D', chr(37) => chr(129) . 'E', chr(38) => chr(129) . 'F', chr(39) => chr(129) . 'G',
467
+			chr(40) => chr(129) . 'H', chr(41) => chr(129) . 'I', chr(42) => chr(129) . 'J', chr(43) => chr(129) . 'K',
468
+			chr(44) => chr(129) . 'L', chr(45) => '-', chr(46) => '.', chr(47) => chr(129) . 'O',
469 469
 			chr(48) => '0', chr(49) => '1', chr(50) => '2', chr(51) => '3',
470 470
 			chr(52) => '4', chr(53) => '5', chr(54) => '6', chr(55) => '7',
471
-			chr(56) => '8', chr(57) => '9', chr(58) => chr(129).'Z', chr(59) => chr(131).'F',
472
-			chr(60) => chr(131).'G', chr(61) => chr(131).'H', chr(62) => chr(131).'I', chr(63) => chr(131).'J',
473
-			chr(64) => chr(131).'V', chr(65) => 'A', chr(66) => 'B', chr(67) => 'C',
471
+			chr(56) => '8', chr(57) => '9', chr(58) => chr(129) . 'Z', chr(59) => chr(131) . 'F',
472
+			chr(60) => chr(131) . 'G', chr(61) => chr(131) . 'H', chr(62) => chr(131) . 'I', chr(63) => chr(131) . 'J',
473
+			chr(64) => chr(131) . 'V', chr(65) => 'A', chr(66) => 'B', chr(67) => 'C',
474 474
 			chr(68) => 'D', chr(69) => 'E', chr(70) => 'F', chr(71) => 'G',
475 475
 			chr(72) => 'H', chr(73) => 'I', chr(74) => 'J', chr(75) => 'K',
476 476
 			chr(76) => 'L', chr(77) => 'M', chr(78) => 'N', chr(79) => 'O',
477 477
 			chr(80) => 'P', chr(81) => 'Q', chr(82) => 'R', chr(83) => 'S',
478 478
 			chr(84) => 'T', chr(85) => 'U', chr(86) => 'V', chr(87) => 'W',
479
-			chr(88) => 'X', chr(89) => 'Y', chr(90) => 'Z', chr(91) => chr(131).'K',
480
-			chr(92) => chr(131).'L', chr(93) => chr(131).'M', chr(94) => chr(131).'N', chr(95) => chr(131).'O',
481
-			chr(96) => chr(131).'W', chr(97) => chr(130).'A', chr(98) => chr(130).'B', chr(99) => chr(130).'C',
482
-			chr(100) => chr(130).'D', chr(101) => chr(130).'E', chr(102) => chr(130).'F', chr(103) => chr(130).'G',
483
-			chr(104) => chr(130).'H', chr(105) => chr(130).'I', chr(106) => chr(130).'J', chr(107) => chr(130).'K',
484
-			chr(108) => chr(130).'L', chr(109) => chr(130).'M', chr(110) => chr(130).'N', chr(111) => chr(130).'O',
485
-			chr(112) => chr(130).'P', chr(113) => chr(130).'Q', chr(114) => chr(130).'R', chr(115) => chr(130).'S',
486
-			chr(116) => chr(130).'T', chr(117) => chr(130).'U', chr(118) => chr(130).'V', chr(119) => chr(130).'W',
487
-			chr(120) => chr(130).'X', chr(121) => chr(130).'Y', chr(122) => chr(130).'Z', chr(123) => chr(131).'P',
488
-			chr(124) => chr(131).'Q', chr(125) => chr(131).'R', chr(126) => chr(131).'S', chr(127) => chr(131).'T');
479
+			chr(88) => 'X', chr(89) => 'Y', chr(90) => 'Z', chr(91) => chr(131) . 'K',
480
+			chr(92) => chr(131) . 'L', chr(93) => chr(131) . 'M', chr(94) => chr(131) . 'N', chr(95) => chr(131) . 'O',
481
+			chr(96) => chr(131) . 'W', chr(97) => chr(130) . 'A', chr(98) => chr(130) . 'B', chr(99) => chr(130) . 'C',
482
+			chr(100) => chr(130) . 'D', chr(101) => chr(130) . 'E', chr(102) => chr(130) . 'F', chr(103) => chr(130) . 'G',
483
+			chr(104) => chr(130) . 'H', chr(105) => chr(130) . 'I', chr(106) => chr(130) . 'J', chr(107) => chr(130) . 'K',
484
+			chr(108) => chr(130) . 'L', chr(109) => chr(130) . 'M', chr(110) => chr(130) . 'N', chr(111) => chr(130) . 'O',
485
+			chr(112) => chr(130) . 'P', chr(113) => chr(130) . 'Q', chr(114) => chr(130) . 'R', chr(115) => chr(130) . 'S',
486
+			chr(116) => chr(130) . 'T', chr(117) => chr(130) . 'U', chr(118) => chr(130) . 'V', chr(119) => chr(130) . 'W',
487
+			chr(120) => chr(130) . 'X', chr(121) => chr(130) . 'Y', chr(122) => chr(130) . 'Z', chr(123) => chr(131) . 'P',
488
+			chr(124) => chr(131) . 'Q', chr(125) => chr(131) . 'R', chr(126) => chr(131) . 'S', chr(127) => chr(131) . 'T');
489 489
 		$code_ext = '';
490 490
 		$clen = strlen($code);
491
-		for ($i = 0 ; $i < $clen; ++$i) {
491
+		for ($i = 0; $i < $clen; ++$i) {
492 492
 			if (ord($code{$i}) > 127) {
493 493
 				return false;
494 494
 			}
@@ -497,13 +497,13 @@  discard block
 block discarded – undo
497 497
 		// checksum
498 498
 		$code .= $this->checksum_code93($code);
499 499
 		// add start and stop codes
500
-		$code = '*'.$code.'*';
500
+		$code = '*' . $code . '*';
501 501
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
502 502
 		$k = 0;
503 503
 		$clen = strlen($code);
504 504
 		for ($i = 0; $i < $clen; ++$i) {
505 505
 			$char = $code{$i};
506
-			if(!isset($chr[$char])) {
506
+			if (!isset($chr[$char])) {
507 507
 				// invalid character
508 508
 				return false;
509 509
 			}
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 			'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
539 539
 			'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%');
540 540
 		// translate special characters
541
-		$code = strtr($code, chr(128).chr(129).chr(130).chr(131), '$/+%');	
541
+		$code = strtr($code, chr(128) . chr(129) . chr(130) . chr(131), '$/+%');	
542 542
 		$len = strlen($code);
543 543
 		// calculate check digit C
544 544
 		$p = 1;
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 		}
568 568
 		$check %= 47;
569 569
 		$k = $chars[$check];
570
-		return $c.$k;
570
+		return $c . $k;
571 571
 	}
572 572
 	
573 573
 	/**
@@ -579,15 +579,15 @@  discard block
 block discarded – undo
579 579
 	protected function checksum_s25($code) {
580 580
 		$len = strlen($code);
581 581
 		$sum = 0;
582
-		for ($i = 0; $i < $len; $i+=2) {
582
+		for ($i = 0; $i < $len; $i += 2) {
583 583
 			$sum += $code{$i};
584 584
 		}
585 585
 		$sum *= 3;
586
-		for ($i = 1; $i < $len; $i+=2) {
586
+		for ($i = 1; $i < $len; $i += 2) {
587 587
 			$sum += ($code{$i});
588 588
 		}
589 589
 		$r = $sum % 10;
590
-		if($r > 0) {
590
+		if ($r > 0) {
591 591
 			$r = (10 - $r);
592 592
 		}
593 593
 		return $r;
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	 * @return array barcode representation.
603 603
 	 * @access protected
604 604
 	 */
605
-	protected function barcode_msi($code, $checksum=false) {
605
+	protected function barcode_msi($code, $checksum = false) {
606 606
 		$chr['0'] = '100100100100';
607 607
 		$chr['1'] = '100100100110';
608 608
 		$chr['2'] = '100100110100';
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 	 * @return array barcode representation.
662 662
 	 * @access protected
663 663
 	 */
664
-	protected function barcode_s25($code, $checksum=false) {
664
+	protected function barcode_s25($code, $checksum = false) {
665 665
 		$chr['0'] = '10101110111010';
666 666
 		$chr['1'] = '11101010101110';
667 667
 		$chr['2'] = '10111010101110';
@@ -676,9 +676,9 @@  discard block
 block discarded – undo
676 676
 			// add checksum
677 677
 			$code .= $this->checksum_s25($code);
678 678
 		}
679
-		if((strlen($code) % 2) != 0) {
679
+		if ((strlen($code) % 2) != 0) {
680 680
 			// add leading zero if code-length is odd
681
-			$code = '0'.$code;
681
+			$code = '0' . $code;
682 682
 		}
683 683
 		$seq = '11011010';
684 684
 		$clen = strlen($code);
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 		$k = 0;
709 709
 		for ($i = 0; $i < $len; ++$i) {
710 710
 			$w += 1;
711
-			if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq{$i} != $seq{($i+1)}))) {
711
+			if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq{$i} != $seq{($i + 1)}))) {
712 712
 				if ($seq{$i} == '1') {
713 713
 					$t = true; // bar
714 714
 				} else {
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	 * @return array barcode representation.
733 733
 	 * @access protected
734 734
 	 */
735
-	protected function barcode_i25($code, $checksum=false) {
735
+	protected function barcode_i25($code, $checksum = false) {
736 736
 		$chr['0'] = '11221';
737 737
 		$chr['1'] = '21112';
738 738
 		$chr['2'] = '12112';
@@ -749,27 +749,27 @@  discard block
 block discarded – undo
749 749
 			// add checksum
750 750
 			$code .= $this->checksum_s25($code);
751 751
 		}
752
-		if((strlen($code) % 2) != 0) {
752
+		if ((strlen($code) % 2) != 0) {
753 753
 			// add leading zero if code-length is odd
754
-			$code = '0'.$code;
754
+			$code = '0' . $code;
755 755
 		}
756 756
 		// add start and stop codes
757
-		$code = 'AA'.strtolower($code).'ZA';
757
+		$code = 'AA' . strtolower($code) . 'ZA';
758 758
 			
759 759
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
760 760
 		$k = 0;
761 761
 		$clen = strlen($code);
762 762
 		for ($i = 0; $i < $clen; $i = ($i + 2)) {
763 763
 			$char_bar = $code{$i};
764
-			$char_space = $code{$i+1};
765
-			if((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) {
764
+			$char_space = $code{$i + 1};
765
+			if ((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) {
766 766
 				// invalid character
767 767
 				return false;
768 768
 			}
769 769
 			// create a bar-space sequence
770 770
 			$seq = '';
771 771
 			$chrlen = strlen($chr[$char_bar]);
772
-			for ($s = 0; $s < $chrlen; $s++){
772
+			for ($s = 0; $s < $chrlen; $s++) {
773 773
 				$seq .= $chr[$char_bar]{$s} . $chr[$char_space]{$s};
774 774
 			}
775 775
 			$seqlen = strlen($seq);
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 	 * @return array barcode representation.
797 797
 	 * @access protected
798 798
 	 */
799
-	protected function barcode_c128($code, $type='B') {
799
+	protected function barcode_c128($code, $type = 'B') {
800 800
 		$chr = array(
801 801
 			'212222', /* 00 */
802 802
 			'222122', /* 01 */
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 			'200000'  /* END */
909 909
 		);
910 910
 		$keys = '';
911
-		switch(strtoupper($type)) {
911
+		switch (strtoupper($type)) {
912 912
 			case 'A': {
913 913
 				$startid = 103;
914 914
 				$keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_';
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 			}
920 920
 			case 'B': {
921 921
 				$startid = 104;
922
-				$keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'.chr(127);
922
+				$keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~' . chr(127);
923 923
 				break;
924 924
 			}
925 925
 			case 'C': {
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 				$new_code = '';
936 936
 				$hclen = (strlen($code) / 2);
937 937
 				for ($i = 0; $i < $hclen; ++$i) {
938
-					$new_code .= chr(intval($code{(2 * $i)}.$code{(2 * $i + 1)}));
938
+					$new_code .= chr(intval($code{(2 * $i)} . $code{(2 * $i + 1)}));
939 939
 				}
940 940
 				$code = $new_code;
941 941
 				break;
@@ -948,20 +948,20 @@  discard block
 block discarded – undo
948 948
 		$sum = $startid;
949 949
 		$clen = strlen($code);
950 950
 		for ($i = 0; $i < $clen; ++$i) {
951
-			$sum +=  (strpos($keys, $code{$i}) * ($i+1));
951
+			$sum += (strpos($keys, $code{$i}) * ($i + 1));
952 952
 		}
953 953
 		$check = ($sum % 103);
954 954
 		// add start, check and stop codes
955
-		$code = chr($startid).$code.chr($check).chr(106).chr(107);
955
+		$code = chr($startid) . $code . chr($check) . chr(106) . chr(107);
956 956
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
957 957
 		$k = 0;
958 958
 		$len = strlen($code);
959 959
 		for ($i = 0; $i < $len; ++$i) {
960 960
 			$ck = strpos($keys, $code{$i});
961
-			if (($i == 0) OR ($i > ($len-4))) {
961
+			if (($i == 0) OR ($i > ($len - 4))) {
962 962
 				$char_num = ord($code{$i});
963 963
 				$seq = $chr[$char_num];
964
-			} elseif(($ck >= 0) AND isset($chr[$ck])) {
964
+			} elseif (($ck >= 0) AND isset($chr[$ck])) {
965 965
 					$seq = $chr[$ck];
966 966
 			} else {
967 967
 				// invalid character
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 	 * @return array barcode representation.
993 993
 	 * @access protected
994 994
 	 */
995
-	protected function barcode_eanupc($code, $len=13) {
995
+	protected function barcode_eanupc($code, $len = 13) {
996 996
 		$upce = false;
997 997
 		if ($len == 6) {
998 998
 			$len = 12; // UPC-A
@@ -1004,21 +1004,21 @@  discard block
 block discarded – undo
1004 1004
 		$code_len = strlen($code);
1005 1005
 		// calculate check digit
1006 1006
 		$sum_a = 0;
1007
-		for ($i = 1; $i < $data_len; $i+=2) {
1007
+		for ($i = 1; $i < $data_len; $i += 2) {
1008 1008
 			$sum_a += $code{$i};
1009 1009
 		}
1010 1010
 		if ($len > 12) {
1011 1011
 			$sum_a *= 3;
1012 1012
 		}
1013 1013
 		$sum_b = 0;
1014
-		for ($i = 0; $i < $data_len; $i+=2) {
1014
+		for ($i = 0; $i < $data_len; $i += 2) {
1015 1015
 			$sum_b += ($code{$i});
1016 1016
 		}
1017 1017
 		if ($len < 13) {
1018 1018
 			$sum_b *= 3;
1019 1019
 		}
1020 1020
 		$r = ($sum_a + $sum_b) % 10;
1021
-		if($r > 0) {
1021
+		if ($r > 0) {
1022 1022
 			$r = (10 - $r);
1023 1023
 		}
1024 1024
 		if ($code_len == $data_len) {
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 		}
1031 1031
 		if ($len == 12) {
1032 1032
 			// UPC-A
1033
-			$code = '0'.$code;
1033
+			$code = '0' . $code;
1034 1034
 			++$len;
1035 1035
 		}
1036 1036
 		if ($upce) {
@@ -1038,20 +1038,20 @@  discard block
 block discarded – undo
1038 1038
 			$tmp = substr($code, 4, 3);
1039 1039
 			if (($tmp == '000') OR ($tmp == '100') OR ($tmp == '200')) {
1040 1040
 				// manufacturer code ends in 000, 100, or 200
1041
-				$upce_code = substr($code, 2, 2).substr($code, 9, 3).substr($code, 4, 1);
1041
+				$upce_code = substr($code, 2, 2) . substr($code, 9, 3) . substr($code, 4, 1);
1042 1042
 			} else {
1043 1043
 				$tmp = substr($code, 5, 2);
1044 1044
 				if ($tmp == '00') {
1045 1045
 					// manufacturer code ends in 00
1046
-					$upce_code = substr($code, 2, 3).substr($code, 10, 2).'3';
1046
+					$upce_code = substr($code, 2, 3) . substr($code, 10, 2) . '3';
1047 1047
 				} else {
1048 1048
 					$tmp = substr($code, 6, 1);
1049 1049
 					if ($tmp == '0') {
1050 1050
 						// manufacturer code ends in 0
1051
-						$upce_code = substr($code, 2, 4).substr($code, 11, 1).'4';
1051
+						$upce_code = substr($code, 2, 4) . substr($code, 11, 1) . '4';
1052 1052
 					} else {
1053 1053
 						// manufacturer code does not end in zero
1054
-						$upce_code = substr($code, 2, 5).substr($code, 11, 1);
1054
+						$upce_code = substr($code, 2, 5) . substr($code, 11, 1);
1055 1055
 					}
1056 1056
 				}
1057 1057
 			}
@@ -1093,41 +1093,41 @@  discard block
 block discarded – undo
1093 1093
 				'9'=>'1110100')
1094 1094
 		);
1095 1095
 		$parities = array(
1096
-			'0'=>array('A','A','A','A','A','A'),
1097
-			'1'=>array('A','A','B','A','B','B'),
1098
-			'2'=>array('A','A','B','B','A','B'),
1099
-			'3'=>array('A','A','B','B','B','A'),
1100
-			'4'=>array('A','B','A','A','B','B'),
1101
-			'5'=>array('A','B','B','A','A','B'),
1102
-			'6'=>array('A','B','B','B','A','A'),
1103
-			'7'=>array('A','B','A','B','A','B'),
1104
-			'8'=>array('A','B','A','B','B','A'),
1105
-			'9'=>array('A','B','B','A','B','A')
1096
+			'0'=>array('A', 'A', 'A', 'A', 'A', 'A'),
1097
+			'1'=>array('A', 'A', 'B', 'A', 'B', 'B'),
1098
+			'2'=>array('A', 'A', 'B', 'B', 'A', 'B'),
1099
+			'3'=>array('A', 'A', 'B', 'B', 'B', 'A'),
1100
+			'4'=>array('A', 'B', 'A', 'A', 'B', 'B'),
1101
+			'5'=>array('A', 'B', 'B', 'A', 'A', 'B'),
1102
+			'6'=>array('A', 'B', 'B', 'B', 'A', 'A'),
1103
+			'7'=>array('A', 'B', 'A', 'B', 'A', 'B'),
1104
+			'8'=>array('A', 'B', 'A', 'B', 'B', 'A'),
1105
+			'9'=>array('A', 'B', 'B', 'A', 'B', 'A')
1106 1106
 		);
1107 1107
 		$upce_parities = array();
1108 1108
 		$upce_parities[0] = array(
1109
-			'0'=>array('B','B','B','A','A','A'),
1110
-			'1'=>array('B','B','A','B','A','A'),
1111
-			'2'=>array('B','B','A','A','B','A'),
1112
-			'3'=>array('B','B','A','A','A','B'),
1113
-			'4'=>array('B','A','B','B','A','A'),
1114
-			'5'=>array('B','A','A','B','B','A'),
1115
-			'6'=>array('B','A','A','A','B','B'),
1116
-			'7'=>array('B','A','B','A','B','A'),
1117
-			'8'=>array('B','A','B','A','A','B'),
1118
-			'9'=>array('B','A','A','B','A','B')
1109
+			'0'=>array('B', 'B', 'B', 'A', 'A', 'A'),
1110
+			'1'=>array('B', 'B', 'A', 'B', 'A', 'A'),
1111
+			'2'=>array('B', 'B', 'A', 'A', 'B', 'A'),
1112
+			'3'=>array('B', 'B', 'A', 'A', 'A', 'B'),
1113
+			'4'=>array('B', 'A', 'B', 'B', 'A', 'A'),
1114
+			'5'=>array('B', 'A', 'A', 'B', 'B', 'A'),
1115
+			'6'=>array('B', 'A', 'A', 'A', 'B', 'B'),
1116
+			'7'=>array('B', 'A', 'B', 'A', 'B', 'A'),
1117
+			'8'=>array('B', 'A', 'B', 'A', 'A', 'B'),
1118
+			'9'=>array('B', 'A', 'A', 'B', 'A', 'B')
1119 1119
 		);
1120 1120
 		$upce_parities[1] = array(
1121
-			'0'=>array('A','A','A','B','B','B'),
1122
-			'1'=>array('A','A','B','A','B','B'),
1123
-			'2'=>array('A','A','B','B','A','B'),
1124
-			'3'=>array('A','A','B','B','B','A'),
1125
-			'4'=>array('A','B','A','A','B','B'),
1126
-			'5'=>array('A','B','B','A','A','B'),
1127
-			'6'=>array('A','B','B','B','A','A'),
1128
-			'7'=>array('A','B','A','B','A','B'),
1129
-			'8'=>array('A','B','A','B','B','A'),
1130
-			'9'=>array('A','B','B','A','B','A')
1121
+			'0'=>array('A', 'A', 'A', 'B', 'B', 'B'),
1122
+			'1'=>array('A', 'A', 'B', 'A', 'B', 'B'),
1123
+			'2'=>array('A', 'A', 'B', 'B', 'A', 'B'),
1124
+			'3'=>array('A', 'A', 'B', 'B', 'B', 'A'),
1125
+			'4'=>array('A', 'B', 'A', 'A', 'B', 'B'),
1126
+			'5'=>array('A', 'B', 'B', 'A', 'A', 'B'),
1127
+			'6'=>array('A', 'B', 'B', 'B', 'A', 'A'),
1128
+			'7'=>array('A', 'B', 'A', 'B', 'A', 'B'),
1129
+			'8'=>array('A', 'B', 'A', 'B', 'B', 'A'),
1130
+			'9'=>array('A', 'B', 'B', 'A', 'B', 'A')
1131 1131
 		);
1132 1132
 		$k = 0;
1133 1133
 		$seq = '101'; // left guard bar
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
 			} else {
1149 1149
 				$p = $parities[$code{0}];
1150 1150
 				for ($i = 1; $i < $half_len; ++$i) {
1151
-					$seq .= $codes[$p[$i-1]][$code{$i}];
1151
+					$seq .= $codes[$p[$i - 1]][$code{$i}];
1152 1152
 				}
1153 1153
 			}
1154 1154
 			$seq .= '01010'; // center guard bar
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
 		$w = 0;
1162 1162
 		for ($i = 0; $i < $clen; ++$i) {
1163 1163
 			$w += 1;
1164
-			if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq{$i} != $seq{($i+1)}))) {
1164
+			if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq{$i} != $seq{($i + 1)}))) {
1165 1165
 				if ($seq{$i} == '1') {
1166 1166
 					$t = true; // bar
1167 1167
 				} else {
@@ -1185,14 +1185,14 @@  discard block
 block discarded – undo
1185 1185
 	 * @return array barcode representation.
1186 1186
 	 * @access protected
1187 1187
 	 */
1188
-	protected function barcode_eanext($code, $len=5) {
1188
+	protected function barcode_eanext($code, $len = 5) {
1189 1189
 		//Padding
1190 1190
 		$code = str_pad($code, $len, '0', STR_PAD_LEFT);
1191 1191
 		// calculate check digit
1192 1192
 		if ($len == 2) {
1193 1193
 			$r = $code % 4;
1194 1194
 		} elseif ($len == 5) {
1195
-			$r = (3 * ($code{0} + $code{2} + $code{4})) + (9 * ($code{1} + $code{3}));
1195
+			$r = (3 * ($code{0} +$code{2} +$code{4})) + (9 * ($code{1} +$code{3}));
1196 1196
 			$r %= 10;
1197 1197
 		} else {
1198 1198
 			return false;
@@ -1224,22 +1224,22 @@  discard block
 block discarded – undo
1224 1224
 		);
1225 1225
 		$parities = array();
1226 1226
 		$parities[2] = array(
1227
-			'0'=>array('A','A'),
1228
-			'1'=>array('A','B'),
1229
-			'2'=>array('B','A'),
1230
-			'3'=>array('B','B')
1227
+			'0'=>array('A', 'A'),
1228
+			'1'=>array('A', 'B'),
1229
+			'2'=>array('B', 'A'),
1230
+			'3'=>array('B', 'B')
1231 1231
 		);
1232 1232
 		$parities[5] = array(
1233
-			'0'=>array('B','B','A','A','A'),
1234
-			'1'=>array('B','A','B','A','A'),
1235
-			'2'=>array('B','A','A','B','A'),
1236
-			'3'=>array('B','A','A','A','B'),
1237
-			'4'=>array('A','B','B','A','A'),
1238
-			'5'=>array('A','A','B','B','A'),
1239
-			'6'=>array('A','A','A','B','B'),
1240
-			'7'=>array('A','B','A','B','A'),
1241
-			'8'=>array('A','B','A','A','B'),
1242
-			'9'=>array('A','A','B','A','B')
1233
+			'0'=>array('B', 'B', 'A', 'A', 'A'),
1234
+			'1'=>array('B', 'A', 'B', 'A', 'A'),
1235
+			'2'=>array('B', 'A', 'A', 'B', 'A'),
1236
+			'3'=>array('B', 'A', 'A', 'A', 'B'),
1237
+			'4'=>array('A', 'B', 'B', 'A', 'A'),
1238
+			'5'=>array('A', 'A', 'B', 'B', 'A'),
1239
+			'6'=>array('A', 'A', 'A', 'B', 'B'),
1240
+			'7'=>array('A', 'B', 'A', 'B', 'A'),
1241
+			'8'=>array('A', 'B', 'A', 'A', 'B'),
1242
+			'9'=>array('A', 'A', 'B', 'A', 'B')
1243 1243
 		);	
1244 1244
 		$p = $parities[$len][$r];
1245 1245
 		$seq = '1011'; // left guard bar
@@ -1260,33 +1260,33 @@  discard block
 block discarded – undo
1260 1260
 	 * @return array barcode representation.
1261 1261
 	 * @access protected
1262 1262
 	 */
1263
-	protected function barcode_postnet($code, $planet=false) {
1263
+	protected function barcode_postnet($code, $planet = false) {
1264 1264
 		// bar lenght
1265 1265
 		if ($planet) {
1266 1266
 			$barlen = Array(
1267
-				0 => Array(1,1,2,2,2),
1268
-				1 => Array(2,2,2,1,1),
1269
-				2 => Array(2,2,1,2,1),
1270
-				3 => Array(2,2,1,1,2),
1271
-				4 => Array(2,1,2,2,1),
1272
-				5 => Array(2,1,2,1,2),
1273
-				6 => Array(2,1,1,2,2),
1274
-				7 => Array(1,2,2,2,1),
1275
-				8 => Array(1,2,2,1,2),
1276
-				9 => Array(1,2,1,2,2)
1267
+				0 => Array(1, 1, 2, 2, 2),
1268
+				1 => Array(2, 2, 2, 1, 1),
1269
+				2 => Array(2, 2, 1, 2, 1),
1270
+				3 => Array(2, 2, 1, 1, 2),
1271
+				4 => Array(2, 1, 2, 2, 1),
1272
+				5 => Array(2, 1, 2, 1, 2),
1273
+				6 => Array(2, 1, 1, 2, 2),
1274
+				7 => Array(1, 2, 2, 2, 1),
1275
+				8 => Array(1, 2, 2, 1, 2),
1276
+				9 => Array(1, 2, 1, 2, 2)
1277 1277
 			);
1278 1278
 		} else {
1279 1279
 			$barlen = Array(
1280
-				0 => Array(2,2,1,1,1),
1281
-				1 => Array(1,1,1,2,2),
1282
-				2 => Array(1,1,2,1,2),
1283
-				3 => Array(1,1,2,2,1),
1284
-				4 => Array(1,2,1,1,2),
1285
-				5 => Array(1,2,1,2,1),
1286
-				6 => Array(1,2,2,1,1),
1287
-				7 => Array(2,1,1,1,2),
1288
-				8 => Array(2,1,1,2,1),
1289
-				9 => Array(2,1,2,1,1)
1280
+				0 => Array(2, 2, 1, 1, 1),
1281
+				1 => Array(1, 1, 1, 2, 2),
1282
+				2 => Array(1, 1, 2, 1, 2),
1283
+				3 => Array(1, 1, 2, 2, 1),
1284
+				4 => Array(1, 2, 1, 1, 2),
1285
+				5 => Array(1, 2, 1, 2, 1),
1286
+				6 => Array(1, 2, 2, 1, 1),
1287
+				7 => Array(2, 1, 1, 1, 2),
1288
+				8 => Array(2, 1, 1, 2, 1),
1289
+				9 => Array(2, 1, 2, 1, 1)
1290 1290
 			);
1291 1291
 		}
1292 1292
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
@@ -1300,7 +1300,7 @@  discard block
 block discarded – undo
1300 1300
 			$sum += intval($code{$i});
1301 1301
 		}
1302 1302
 		$chkd = ($sum % 10);
1303
-		if($chkd > 0) {
1303
+		if ($chkd > 0) {
1304 1304
 			$chkd = (10 - $chkd);
1305 1305
 		}
1306 1306
 		$code .= $chkd;
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 	 * @return array barcode representation.
1334 1334
 	 * @access protected
1335 1335
 	 */
1336
-	protected function barcode_rms4cc($code, $kix=false) {
1336
+	protected function barcode_rms4cc($code, $kix = false) {
1337 1337
 		$notkix = !$kix;
1338 1338
 		// bar mode
1339 1339
 		// 1 = pos 1, length 2
@@ -1341,42 +1341,42 @@  discard block
 block discarded – undo
1341 1341
 		// 3 = pos 2, length 1
1342 1342
 		// 4 = pos 2, length 2
1343 1343
 		$barmode = array(
1344
-			'0' => array(3,3,2,2),
1345
-			'1' => array(3,4,1,2),
1346
-			'2' => array(3,4,2,1),
1347
-			'3' => array(4,3,1,2),
1348
-			'4' => array(4,3,2,1),
1349
-			'5' => array(4,4,1,1),
1350
-			'6' => array(3,1,4,2),
1351
-			'7' => array(3,2,3,2),
1352
-			'8' => array(3,2,4,1),
1353
-			'9' => array(4,1,3,2),
1354
-			'A' => array(4,1,4,1),
1355
-			'B' => array(4,2,3,1),
1356
-			'C' => array(3,1,2,4),
1357
-			'D' => array(3,2,1,4),
1358
-			'E' => array(3,2,2,3),
1359
-			'F' => array(4,1,1,4),
1360
-			'G' => array(4,1,2,3),
1361
-			'H' => array(4,2,1,3),
1362
-			'I' => array(1,3,4,2),
1363
-			'J' => array(1,4,3,2),
1364
-			'K' => array(1,4,4,1),
1365
-			'L' => array(2,3,3,2),
1366
-			'M' => array(2,3,4,1),
1367
-			'N' => array(2,4,3,1),
1368
-			'O' => array(1,3,2,4),
1369
-			'P' => array(1,4,1,4),
1370
-			'Q' => array(1,4,2,3),
1371
-			'R' => array(2,3,1,4),
1372
-			'S' => array(2,3,2,3),
1373
-			'T' => array(2,4,1,3),
1374
-			'U' => array(1,1,4,4),
1375
-			'V' => array(1,2,3,4),
1376
-			'W' => array(1,2,4,3),
1377
-			'X' => array(2,1,3,4),
1378
-			'Y' => array(2,1,4,3),
1379
-			'Z' => array(2,2,3,3)		
1344
+			'0' => array(3, 3, 2, 2),
1345
+			'1' => array(3, 4, 1, 2),
1346
+			'2' => array(3, 4, 2, 1),
1347
+			'3' => array(4, 3, 1, 2),
1348
+			'4' => array(4, 3, 2, 1),
1349
+			'5' => array(4, 4, 1, 1),
1350
+			'6' => array(3, 1, 4, 2),
1351
+			'7' => array(3, 2, 3, 2),
1352
+			'8' => array(3, 2, 4, 1),
1353
+			'9' => array(4, 1, 3, 2),
1354
+			'A' => array(4, 1, 4, 1),
1355
+			'B' => array(4, 2, 3, 1),
1356
+			'C' => array(3, 1, 2, 4),
1357
+			'D' => array(3, 2, 1, 4),
1358
+			'E' => array(3, 2, 2, 3),
1359
+			'F' => array(4, 1, 1, 4),
1360
+			'G' => array(4, 1, 2, 3),
1361
+			'H' => array(4, 2, 1, 3),
1362
+			'I' => array(1, 3, 4, 2),
1363
+			'J' => array(1, 4, 3, 2),
1364
+			'K' => array(1, 4, 4, 1),
1365
+			'L' => array(2, 3, 3, 2),
1366
+			'M' => array(2, 3, 4, 1),
1367
+			'N' => array(2, 4, 3, 1),
1368
+			'O' => array(1, 3, 2, 4),
1369
+			'P' => array(1, 4, 1, 4),
1370
+			'Q' => array(1, 4, 2, 3),
1371
+			'R' => array(2, 3, 1, 4),
1372
+			'S' => array(2, 3, 2, 3),
1373
+			'T' => array(2, 4, 1, 3),
1374
+			'U' => array(1, 1, 4, 4),
1375
+			'V' => array(1, 2, 3, 4),
1376
+			'W' => array(1, 2, 4, 3),
1377
+			'X' => array(2, 1, 3, 4),
1378
+			'Y' => array(2, 1, 4, 3),
1379
+			'Z' => array(2, 2, 3, 3)		
1380 1380
 		);
1381 1381
 		$code = strtoupper($code);
1382 1382
 		$len = strlen($code);
@@ -1384,42 +1384,42 @@  discard block
 block discarded – undo
1384 1384
 		if ($notkix) {
1385 1385
 			// table for checksum calculation (row,col)
1386 1386
 			$checktable = array(
1387
-				'0' => array(1,1),
1388
-				'1' => array(1,2),
1389
-				'2' => array(1,3),
1390
-				'3' => array(1,4),
1391
-				'4' => array(1,5),
1392
-				'5' => array(1,0),
1393
-				'6' => array(2,1),
1394
-				'7' => array(2,2),
1395
-				'8' => array(2,3),
1396
-				'9' => array(2,4),
1397
-				'A' => array(2,5),
1398
-				'B' => array(2,0),
1399
-				'C' => array(3,1),
1400
-				'D' => array(3,2),
1401
-				'E' => array(3,3),
1402
-				'F' => array(3,4),
1403
-				'G' => array(3,5),
1404
-				'H' => array(3,0),
1405
-				'I' => array(4,1),
1406
-				'J' => array(4,2),
1407
-				'K' => array(4,3),
1408
-				'L' => array(4,4),
1409
-				'M' => array(4,5),
1410
-				'N' => array(4,0),
1411
-				'O' => array(5,1),
1412
-				'P' => array(5,2),
1413
-				'Q' => array(5,3),
1414
-				'R' => array(5,4),
1415
-				'S' => array(5,5),
1416
-				'T' => array(5,0),
1417
-				'U' => array(0,1),
1418
-				'V' => array(0,2),
1419
-				'W' => array(0,3),
1420
-				'X' => array(0,4),
1421
-				'Y' => array(0,5),
1422
-				'Z' => array(0,0)
1387
+				'0' => array(1, 1),
1388
+				'1' => array(1, 2),
1389
+				'2' => array(1, 3),
1390
+				'3' => array(1, 4),
1391
+				'4' => array(1, 5),
1392
+				'5' => array(1, 0),
1393
+				'6' => array(2, 1),
1394
+				'7' => array(2, 2),
1395
+				'8' => array(2, 3),
1396
+				'9' => array(2, 4),
1397
+				'A' => array(2, 5),
1398
+				'B' => array(2, 0),
1399
+				'C' => array(3, 1),
1400
+				'D' => array(3, 2),
1401
+				'E' => array(3, 3),
1402
+				'F' => array(3, 4),
1403
+				'G' => array(3, 5),
1404
+				'H' => array(3, 0),
1405
+				'I' => array(4, 1),
1406
+				'J' => array(4, 2),
1407
+				'K' => array(4, 3),
1408
+				'L' => array(4, 4),
1409
+				'M' => array(4, 5),
1410
+				'N' => array(4, 0),
1411
+				'O' => array(5, 1),
1412
+				'P' => array(5, 2),
1413
+				'Q' => array(5, 3),
1414
+				'R' => array(5, 4),
1415
+				'S' => array(5, 5),
1416
+				'T' => array(5, 0),
1417
+				'U' => array(0, 1),
1418
+				'V' => array(0, 2),
1419
+				'W' => array(0, 3),
1420
+				'X' => array(0, 4),
1421
+				'Y' => array(0, 5),
1422
+				'Z' => array(0, 0)
1423 1423
 			);
1424 1424
 			$row = 0;
1425 1425
 			$col = 0;
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
 			}
1430 1430
 			$row %= 6;
1431 1431
 			$col %= 6;
1432
-			$chk = array_keys($checktable, array($row,$col));
1432
+			$chk = array_keys($checktable, array($row, $col));
1433 1433
 			$code .= $chk[0];
1434 1434
 			++$len;
1435 1435
 		}
@@ -1511,7 +1511,7 @@  discard block
 block discarded – undo
1511 1511
 		$k = 0;
1512 1512
 		$w = 0;
1513 1513
 		$seq = '';
1514
-		$code = 'A'.strtoupper($code).'A';
1514
+		$code = 'A' . strtoupper($code) . 'A';
1515 1515
 		$len = strlen($code);
1516 1516
 		for ($i = 0; $i < $len; ++$i) {
1517 1517
 			if (!isset($chr[$code{$i}])) {
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
 			$code .= $check;
1604 1604
 			++$len;
1605 1605
 		}
1606
-		$code = 'S'.$code.'S';
1606
+		$code = 'S' . $code . 'S';
1607 1607
 		$len += 3;
1608 1608
 		for ($i = 0; $i < $len; ++$i) {
1609 1609
 			if (!isset($chr[$code{$i}])) {
@@ -1679,7 +1679,7 @@  discard block
 block discarded – undo
1679 1679
 					break;
1680 1680
 				}
1681 1681
 			}
1682
-		} while($code != 0);
1682
+		} while ($code != 0);
1683 1683
 		$seq = strrev($seq);
1684 1684
 		$k = 0;
1685 1685
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
@@ -1722,10 +1722,10 @@  discard block
 block discarded – undo
1722 1722
 	 * @access protected
1723 1723
 	 */
1724 1724
 	protected function barcode_imb($code) {
1725
-		$asc_chr = array(4,0,2,6,3,5,1,9,8,7,1,2,0,6,4,8,2,9,5,3,0,1,3,7,4,6,8,9,2,0,5,1,9,4,3,8,6,7,1,2,4,3,9,5,7,8,3,0,2,1,4,0,9,1,7,0,2,4,6,3,7,1,9,5,8);
1726
-		$dsc_chr = array(7,1,9,5,8,0,2,4,6,3,5,8,9,7,3,0,6,1,7,4,6,8,9,2,5,1,7,5,4,3,8,7,6,0,2,5,4,9,3,0,1,6,8,2,0,4,5,9,6,7,5,2,6,3,8,5,1,9,8,7,4,0,2,6,3);
1727
-		$asc_pos = array(3,0,8,11,1,12,8,11,10,6,4,12,2,7,9,6,7,9,2,8,4,0,12,7,10,9,0,7,10,5,7,9,6,8,2,12,1,4,2,0,1,5,4,6,12,1,0,9,4,7,5,10,2,6,9,11,2,12,6,7,5,11,0,3,2);
1728
-		$dsc_pos = array(2,10,12,5,9,1,5,4,3,9,11,5,10,1,6,3,4,1,10,0,2,11,8,6,1,12,3,8,6,4,4,11,0,6,1,9,11,5,3,7,3,10,7,11,8,2,10,3,5,8,0,3,12,11,8,4,5,1,3,0,7,12,9,8,10);
1725
+		$asc_chr = array(4, 0, 2, 6, 3, 5, 1, 9, 8, 7, 1, 2, 0, 6, 4, 8, 2, 9, 5, 3, 0, 1, 3, 7, 4, 6, 8, 9, 2, 0, 5, 1, 9, 4, 3, 8, 6, 7, 1, 2, 4, 3, 9, 5, 7, 8, 3, 0, 2, 1, 4, 0, 9, 1, 7, 0, 2, 4, 6, 3, 7, 1, 9, 5, 8);
1726
+		$dsc_chr = array(7, 1, 9, 5, 8, 0, 2, 4, 6, 3, 5, 8, 9, 7, 3, 0, 6, 1, 7, 4, 6, 8, 9, 2, 5, 1, 7, 5, 4, 3, 8, 7, 6, 0, 2, 5, 4, 9, 3, 0, 1, 6, 8, 2, 0, 4, 5, 9, 6, 7, 5, 2, 6, 3, 8, 5, 1, 9, 8, 7, 4, 0, 2, 6, 3);
1727
+		$asc_pos = array(3, 0, 8, 11, 1, 12, 8, 11, 10, 6, 4, 12, 2, 7, 9, 6, 7, 9, 2, 8, 4, 0, 12, 7, 10, 9, 0, 7, 10, 5, 7, 9, 6, 8, 2, 12, 1, 4, 2, 0, 1, 5, 4, 6, 12, 1, 0, 9, 4, 7, 5, 10, 2, 6, 9, 11, 2, 12, 6, 7, 5, 11, 0, 3, 2);
1728
+		$dsc_pos = array(2, 10, 12, 5, 9, 1, 5, 4, 3, 9, 11, 5, 10, 1, 6, 3, 4, 1, 10, 0, 2, 11, 8, 6, 1, 12, 3, 8, 6, 4, 4, 11, 0, 6, 1, 9, 11, 5, 3, 7, 3, 10, 7, 11, 8, 2, 10, 3, 5, 8, 0, 3, 12, 11, 8, 4, 5, 1, 3, 0, 7, 12, 9, 8, 10);
1729 1729
 		$code_arr = explode('-', $code);
1730 1730
 		$tracking_number = $code_arr[0];
1731 1731
 		if (isset($code_arr[1])) {
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
 		$fcs = $this->imb_crc11fcs($binary_code_arr);
1774 1774
 		// exclude first 2 bits from first byte
1775 1775
 		$first_byte = sprintf('%2s', dechex((hexdec($binary_code_arr[0]) << 2) >> 2));
1776
-		$binary_code_102bit = $first_byte.substr($binary_code, 2);
1776
+		$binary_code_102bit = $first_byte . substr($binary_code, 2);
1777 1777
 		// convert binary data to codewords
1778 1778
 		$codewords = array();
1779 1779
 		$data = $this->hex_to_dec($binary_code_102bit);
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
 		// convert codewords to characters
1794 1794
 		$characters = array();
1795 1795
 		$bitmask = 512;
1796
-		foreach($codewords as $k => $val) {
1796
+		foreach ($codewords as $k => $val) {
1797 1797
 			if ($val <= 1286) {
1798 1798
 				$chrcode = $table5of13[$val];
1799 1799
 			} else {
@@ -1848,11 +1848,11 @@  discard block
 block discarded – undo
1848 1848
 	public function dec_to_hex($number) {
1849 1849
 		$i = 0;
1850 1850
 		$hex = array();
1851
-		if($number == 0) {
1851
+		if ($number == 0) {
1852 1852
 			return '00';
1853 1853
 		}
1854
-		while($number > 0) {
1855
-			if($number == 0) {
1854
+		while ($number > 0) {
1855
+			if ($number == 0) {
1856 1856
 				array_push($hex, '0');
1857 1857
 			} else {
1858 1858
 				array_push($hex, strtoupper(dechex(bcmod($number, '16'))));
@@ -1873,7 +1873,7 @@  discard block
 block discarded – undo
1873 1873
 		$dec = 0;
1874 1874
 		$bitval = 1;
1875 1875
 		$len = strlen($hex);
1876
-		for($pos = ($len - 1); $pos >= 0; --$pos) {
1876
+		for ($pos = ($len - 1); $pos >= 0; --$pos) {
1877 1877
 			$dec = bcadd($dec, bcmul(hexdec($hex{$pos}), $bitval));
1878 1878
 			$bitval = bcmul($bitval, 16);
1879 1879
 		}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 //============================================================+
3 5
 // File name   : barcodes.php
4 6
 // Begin       : 2008-06-09
Please login to merge, or discard this patch.
includes/librairies/HTML2PDF/_tcpdf_5.0.002/fonts/utils/makefont.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -234,6 +234,8 @@  discard block
 block discarded – undo
234 234
 
235 235
 /**
236 236
  * Read UFM file
237
+ * @param string $file
238
+ * @param string $cidtogidmap
237 239
  */
238 240
 function ReadUFM($file, &$cidtogidmap) {
239 241
 	//Prepare empty CIDToGIDMap
@@ -526,6 +528,10 @@  discard block
 block discarded – undo
526 528
 	return rtrim($s);
527 529
 }
528 530
 
531
+/**
532
+ * @param string $file
533
+ * @param string $s
534
+ */
529 535
 function SaveToFile($file, $s, $mode='t') {
530 536
 	$f = fopen($file, 'w'.$mode);
531 537
 	if(!$f) {
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 //============================================================+
3 3
 // File name   : makefont.php
4 4
 // Begin       : 2004-12-31
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
  * @param string $enc Name of the encoding table to use. Omit this parameter for TrueType Unicode, OpenType Unicode and symbolic fonts like Symbol or ZapfDingBats.
56 56
  * @param array $patch Optional modification of the encoding
57 57
  */
58
-function MakeFont($fontfile, $fmfile, $embedded=true, $enc='cp1252', $patch=array()) {
58
+function MakeFont($fontfile, $fmfile, $embedded = true, $enc = 'cp1252', $patch = array()) {
59 59
 	//Generate a font definition file
60 60
 	set_magic_quotes_runtime(0);
61 61
 	ini_set('auto_detect_line_endings', '1');
62 62
 	if (!file_exists($fontfile)) {
63
-		die('Error: file not found: '.$fontfile);
63
+		die('Error: file not found: ' . $fontfile);
64 64
 	}
65 65
 	if (!file_exists($fmfile)) {
66
-		die('Error: file not found: '.$fmfile);
66
+		die('Error: file not found: ' . $fmfile);
67 67
 	}
68 68
 	$cidtogidmap = '';
69 69
 	$map = array();
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		} elseif ($ffext == 'pfb') {
78 78
 			$type = 'Type1';
79 79
 		} else {
80
-			die('Error: unrecognized font file extension: '.$ffext);
80
+			die('Error: unrecognized font file extension: ' . $ffext);
81 81
 		}
82 82
 		if ($enc) {
83 83
 			$map = ReadMap($enc);
@@ -98,25 +98,25 @@  discard block
 block discarded – undo
98 98
 		if (($ffext == 'ttf') OR ($ffext == 'otf')) {
99 99
 			$type = 'TrueTypeUnicode';
100 100
 		} else {
101
-			die('Error: not a TrueType font: '.$ffext);
101
+			die('Error: not a TrueType font: ' . $ffext);
102 102
 		}
103 103
 		$fm = ReadUFM($fmfile, $cidtogidmap);
104 104
 		$dw = $fm['MissingWidth'];
105 105
 		$fd = MakeFontDescriptor($fm, false);
106 106
 	}
107 107
 	//Start generation
108
-	$s = '<?php'."\n";
109
-	$s .= '$type=\''.$type."';\n";
110
-	$s .= '$name=\''.$fm['FontName']."';\n";
111
-	$s .= '$desc='.$fd.";\n";
108
+	$s = '<?php' . "\n";
109
+	$s .= '$type=\'' . $type . "';\n";
110
+	$s .= '$name=\'' . $fm['FontName'] . "';\n";
111
+	$s .= '$desc=' . $fd . ";\n";
112 112
 	if (!isset($fm['UnderlinePosition'])) {
113 113
 		$fm['UnderlinePosition'] = -100;
114 114
 	}
115 115
 	if (!isset($fm['UnderlineThickness'])) {
116 116
 		$fm['UnderlineThickness'] = 50;
117 117
 	}
118
-	$s .= '$up='.$fm['UnderlinePosition'].";\n";
119
-	$s .= '$ut='.$fm['UnderlineThickness'].";\n";
118
+	$s .= '$up=' . $fm['UnderlinePosition'] . ";\n";
119
+	$s .= '$ut=' . $fm['UnderlineThickness'] . ";\n";
120 120
 	if ($dw <= 0) {
121 121
 		if (isset($fm['Widths'][32]) AND ($fm['Widths'][32] > 0)) {
122 122
 			// assign default space width
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
 			$dw = 600;
126 126
 		}
127 127
 	}
128
-	$s .= '$dw='.$dw.";\n";
128
+	$s .= '$dw=' . $dw . ";\n";
129 129
 	$w = MakeWidthArray($fm);
130
-	$s .= '$cw='.$w.";\n";
131
-	$s .= '$enc=\''.$enc."';\n";
132
-	$s .= '$diff=\''.$diff."';\n";
130
+	$s .= '$cw=' . $w . ";\n";
131
+	$s .= '$enc=\'' . $enc . "';\n";
132
+	$s .= '$diff=\'' . $diff . "';\n";
133 133
 	$basename = substr(basename($fmfile), 0, -4);
134 134
 	if ($embedded) {
135 135
 		//Embedded font
136 136
 		if (($type == 'TrueType') OR ($type == 'TrueTypeUnicode')) {
137 137
 			CheckTTF($fontfile);
138 138
 		}
139
-		$f = fopen($fontfile,'rb');
139
+		$f = fopen($fontfile, 'rb');
140 140
 		if (!$f) {
141
-			die('Error: Unable to open '.$fontfile);
141
+			die('Error: Unable to open ' . $fontfile);
142 142
 		}
143 143
 		$file = fread($f, filesize($fontfile));
144 144
 		fclose($f);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			$size1 = $pos + 6;
157 157
 			if ($header AND (ord($file{$size1}) == 128)) {
158 158
 				//Strip second binary header
159
-				$file = substr($file, 0, $size1).substr($file, $size1+6);
159
+				$file = substr($file, 0, $size1) . substr($file, $size1 + 6);
160 160
 			}
161 161
 			$pos = strpos($file, '00000000');
162 162
 			if (!$pos) {
@@ -167,41 +167,41 @@  discard block
 block discarded – undo
167 167
 		}
168 168
 		$basename = strtolower($basename);
169 169
 		if (function_exists('gzcompress')) {
170
-			$cmp = $basename.'.z';
170
+			$cmp = $basename . '.z';
171 171
 			SaveToFile($cmp, gzcompress($file, 9), 'b');
172
-			$s .= '$file=\''.$cmp."';\n";
173
-			print "Font file compressed (".$cmp.")\n";
172
+			$s .= '$file=\'' . $cmp . "';\n";
173
+			print "Font file compressed (" . $cmp . ")\n";
174 174
 			if (!empty($cidtogidmap)) {
175
-				$cmp = $basename.'.ctg.z';
175
+				$cmp = $basename . '.ctg.z';
176 176
 				SaveToFile($cmp, gzcompress($cidtogidmap, 9), 'b');
177
-				print "CIDToGIDMap created and compressed (".$cmp.")\n";
178
-				$s .= '$ctg=\''.$cmp."';\n";
177
+				print "CIDToGIDMap created and compressed (" . $cmp . ")\n";
178
+				$s .= '$ctg=\'' . $cmp . "';\n";
179 179
 			}
180 180
 		} else {
181
-			$s .= '$file=\''.basename($fontfile)."';\n";
181
+			$s .= '$file=\'' . basename($fontfile) . "';\n";
182 182
 			print "Notice: font file could not be compressed (zlib extension not available)\n";
183 183
 			if (!empty($cidtogidmap)) {
184
-				$cmp = $basename.'.ctg';
184
+				$cmp = $basename . '.ctg';
185 185
 				$f = fopen($cmp, 'wb');
186 186
 				fwrite($f, $cidtogidmap);
187 187
 				fclose($f);
188
-				print "CIDToGIDMap created (".$cmp.")\n";
189
-				$s .= '$ctg=\''.$cmp."';\n";
188
+				print "CIDToGIDMap created (" . $cmp . ")\n";
189
+				$s .= '$ctg=\'' . $cmp . "';\n";
190 190
 			}
191 191
 		}
192
-		if($type == 'Type1') {
193
-			$s .= '$size1='.$size1.";\n";
194
-			$s .= '$size2='.$size2.";\n";
192
+		if ($type == 'Type1') {
193
+			$s .= '$size1=' . $size1 . ";\n";
194
+			$s .= '$size2=' . $size2 . ";\n";
195 195
 		} else {
196
-			$s.='$originalsize='.filesize($fontfile).";\n";
196
+			$s .= '$originalsize=' . filesize($fontfile) . ";\n";
197 197
 		}
198 198
 	} else {
199 199
 		//Not embedded font
200
-		$s .= '$file='."'';\n";
200
+		$s .= '$file=' . "'';\n";
201 201
 	}
202 202
 	$s .= "?>";
203
-	SaveToFile($basename.'.php',$s);
204
-	print "Font definition file generated (".$basename.".php)\n";
203
+	SaveToFile($basename . '.php', $s);
204
+	print "Font definition file generated (" . $basename . ".php)\n";
205 205
 }
206 206
 
207 207
 /**
@@ -210,22 +210,22 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function ReadMap($enc) {
212 212
 	//Read a map file
213
-	$file = dirname(__FILE__).'/enc/'.strtolower($enc).'.map';
213
+	$file = dirname(__FILE__) . '/enc/' . strtolower($enc) . '.map';
214 214
 	$a = file($file);
215 215
 	if (empty($a)) {
216
-		die('Error: encoding not found: '.$enc);
216
+		die('Error: encoding not found: ' . $enc);
217 217
 	}
218 218
 	$cc2gn = array();
219 219
 	foreach ($a as $l) {
220 220
 		if ($l{0} == '!') {
221
-			$e = preg_split('/[ \\t]+/',rtrim($l));
222
-			$cc = hexdec(substr($e[0],1));
221
+			$e = preg_split('/[ \\t]+/', rtrim($l));
222
+			$cc = hexdec(substr($e[0], 1));
223 223
 			$gn = $e[2];
224 224
 			$cc2gn[$cc] = $gn;
225 225
 		}
226 226
 	}
227
-	for($i = 0; $i <= 255; $i++) {
228
-		if(!isset($cc2gn[$i])) {
227
+	for ($i = 0; $i <= 255; $i++) {
228
+		if (!isset($cc2gn[$i])) {
229 229
 			$cc2gn[$i] = '.notdef';
230 230
 		}
231 231
 	}
@@ -245,14 +245,14 @@  discard block
 block discarded – undo
245 245
 	}
246 246
 	$widths = array();
247 247
 	$fm = array();
248
-	foreach($a as $l) {
249
-		$e = explode(' ',chop($l));
250
-		if(count($e) < 2) {
248
+	foreach ($a as $l) {
249
+		$e = explode(' ', chop($l));
250
+		if (count($e) < 2) {
251 251
 			continue;
252 252
 		}
253 253
 		$code = $e[0];
254 254
 		$param = $e[1];
255
-		if($code == 'U') {
255
+		if ($code == 'U') {
256 256
 			// U 827 ; WX 0 ; N squaresubnosp ; G 675 ;
257 257
 			//Character metrics
258 258
 			$cc = (int)$e[1];
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 			$w = $e[4];
262 262
 			$glyph = $e[10];
263 263
 			$widths[$cc] = $w;
264
-			if($cc == ord('X')) {
264
+			if ($cc == ord('X')) {
265 265
 				$fm['CapXHeight'] = $e[13];
266 266
 			}
267 267
 			// Set GID
@@ -270,37 +270,37 @@  discard block
 block discarded – undo
270 270
 				$cidtogidmap{(($cc * 2) + 1)} = chr($glyph & 0xFF);
271 271
 			}
272 272
 		}
273
-		if((isset($gn) AND ($gn == '.notdef')) AND (!isset($fm['MissingWidth']))) {
273
+		if ((isset($gn) AND ($gn == '.notdef')) AND (!isset($fm['MissingWidth']))) {
274 274
 			$fm['MissingWidth'] = $w;
275 275
 		}
276
-		} elseif($code == 'FontName') {
276
+		} elseif ($code == 'FontName') {
277 277
 			$fm['FontName'] = $param;
278
-		} elseif($code == 'Weight') {
278
+		} elseif ($code == 'Weight') {
279 279
 			$fm['Weight'] = $param;
280
-		} elseif($code == 'ItalicAngle') {
280
+		} elseif ($code == 'ItalicAngle') {
281 281
 			$fm['ItalicAngle'] = (double)$param;
282
-		} elseif($code == 'Ascender') {
282
+		} elseif ($code == 'Ascender') {
283 283
 			$fm['Ascender'] = (int)$param;
284
-		} elseif($code == 'Descender') {
284
+		} elseif ($code == 'Descender') {
285 285
 			$fm['Descender'] = (int)$param;
286
-		} elseif($code == 'UnderlineThickness') {
286
+		} elseif ($code == 'UnderlineThickness') {
287 287
 			$fm['UnderlineThickness'] = (int)$param;
288
-		} elseif($code == 'UnderlinePosition') {
288
+		} elseif ($code == 'UnderlinePosition') {
289 289
 			$fm['UnderlinePosition'] = (int)$param;
290
-		} elseif($code == 'IsFixedPitch') {
290
+		} elseif ($code == 'IsFixedPitch') {
291 291
 			$fm['IsFixedPitch'] = ($param == 'true');
292
-		} elseif($code == 'FontBBox') {
292
+		} elseif ($code == 'FontBBox') {
293 293
 			$fm['FontBBox'] = array($e[1], $e[2], $e[3], $e[4]);
294
-		} elseif($code == 'CapHeight') {
294
+		} elseif ($code == 'CapHeight') {
295 295
 			$fm['CapHeight'] = (int)$param;
296
-		} elseif($code == 'StdVW') {
296
+		} elseif ($code == 'StdVW') {
297 297
 			$fm['StdVW'] = (int)$param;
298 298
 		}
299 299
 	}
300
-	if(!isset($fm['MissingWidth'])) {
300
+	if (!isset($fm['MissingWidth'])) {
301 301
 		$fm['MissingWidth'] = 600;
302 302
 	}
303
-	if(!isset($fm['FontName'])) {
303
+	if (!isset($fm['FontName'])) {
304 304
 		die('FontName not found');
305 305
 	}
306 306
 	$fm['Widths'] = $widths;
@@ -310,10 +310,10 @@  discard block
 block discarded – undo
310 310
 /**
311 311
  * Read AFM file
312 312
  */
313
-function ReadAFM($file,&$map) {
313
+function ReadAFM($file, &$map) {
314 314
 	//Read a font metric file
315 315
 	$a = file($file);
316
-	if(empty($a)) {
316
+	if (empty($a)) {
317 317
 		die('File not found');
318 318
 	}
319 319
 	$widths = array();
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		'combiningdotbelow'=>'dotbelowcomb',
354 354
 		'dongsign'=>'dong'
355 355
 		);
356
-	foreach($a as $l) {
356
+	foreach ($a as $l) {
357 357
 		$e = explode(' ', rtrim($l));
358 358
 		if (count($e) < 2) {
359 359
 			continue;
@@ -381,34 +381,34 @@  discard block
 block discarded – undo
381 381
 				$widths[$cc] = $w;
382 382
 			} else {
383 383
 				$widths[$gn] = $w;
384
-				if($gn == 'X') {
384
+				if ($gn == 'X') {
385 385
 					$fm['CapXHeight'] = $e[13];
386 386
 				}
387 387
 			}
388
-			if($gn == '.notdef') {
388
+			if ($gn == '.notdef') {
389 389
 				$fm['MissingWidth'] = $w;
390 390
 			}
391
-		} elseif($code == 'FontName') {
391
+		} elseif ($code == 'FontName') {
392 392
 			$fm['FontName'] = $param;
393
-		} elseif($code == 'Weight') {
393
+		} elseif ($code == 'Weight') {
394 394
 			$fm['Weight'] = $param;
395
-		} elseif($code == 'ItalicAngle') {
395
+		} elseif ($code == 'ItalicAngle') {
396 396
 			$fm['ItalicAngle'] = (double)$param;
397
-		} elseif($code == 'Ascender') {
397
+		} elseif ($code == 'Ascender') {
398 398
 			$fm['Ascender'] = (int)$param;
399
-		} elseif($code == 'Descender') {
399
+		} elseif ($code == 'Descender') {
400 400
 			$fm['Descender'] = (int)$param;
401
-		} elseif($code == 'UnderlineThickness') {
401
+		} elseif ($code == 'UnderlineThickness') {
402 402
 			$fm['UnderlineThickness'] = (int)$param;
403
-		} elseif($code == 'UnderlinePosition') {
403
+		} elseif ($code == 'UnderlinePosition') {
404 404
 			$fm['UnderlinePosition'] = (int)$param;
405
-		} elseif($code == 'IsFixedPitch') {
405
+		} elseif ($code == 'IsFixedPitch') {
406 406
 			$fm['IsFixedPitch'] = ($param == 'true');
407
-		} elseif($code == 'FontBBox') {
407
+		} elseif ($code == 'FontBBox') {
408 408
 			$fm['FontBBox'] = array($e[1], $e[2], $e[3], $e[4]);
409
-		} elseif($code == 'CapHeight') {
409
+		} elseif ($code == 'CapHeight') {
410 410
 			$fm['CapHeight'] = (int)$param;
411
-		} elseif($code == 'StdVW') {
411
+		} elseif ($code == 'StdVW') {
412 412
 			$fm['StdVW'] = (int)$param;
413 413
 		}
414 414
 	}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 		//Order widths according to map
426 426
 		for ($i = 0; $i <= 255; $i++) {
427 427
 			if (!isset($widths[$map[$i]])) {
428
-				print "Warning: character ".$map[$i]." is missing\n";
428
+				print "Warning: character " . $map[$i] . " is missing\n";
429 429
 				$widths[$i] = $widths['.notdef'];
430 430
 			} else {
431 431
 				$widths[$i] = $widths[$map[$i]];
@@ -436,13 +436,13 @@  discard block
 block discarded – undo
436 436
 	return $fm;
437 437
 }
438 438
 
439
-function MakeFontDescriptor($fm, $symbolic=false) {
439
+function MakeFontDescriptor($fm, $symbolic = false) {
440 440
 	//Ascent
441 441
 	$asc = (isset($fm['Ascender']) ? $fm['Ascender'] : 1000);
442
-	$fd = "array('Ascent'=>".$asc;
442
+	$fd = "array('Ascent'=>" . $asc;
443 443
 	//Descent
444 444
 	$desc = (isset($fm['Descender']) ? $fm['Descender'] : -200);
445
-	$fd .= ",'Descent'=>".$desc;
445
+	$fd .= ",'Descent'=>" . $desc;
446 446
 	//CapHeight
447 447
 	if (isset($fm['CapHeight'])) {
448 448
 		$ch = $fm['CapHeight'];
@@ -451,31 +451,31 @@  discard block
 block discarded – undo
451 451
 	} else {
452 452
 		$ch = $asc;
453 453
 	}
454
-	$fd .= ",'CapHeight'=>".$ch;
454
+	$fd .= ",'CapHeight'=>" . $ch;
455 455
 	//Flags
456 456
 	$flags = 0;
457 457
 	if (isset($fm['IsFixedPitch']) AND $fm['IsFixedPitch']) {
458
-		$flags += 1<<0;
458
+		$flags += 1 << 0;
459 459
 	}
460 460
 	if ($symbolic) {
461
-		$flags += 1<<2;
461
+		$flags += 1 << 2;
462 462
 	} else {
463
-		$flags += 1<<5;
463
+		$flags += 1 << 5;
464 464
 	}
465 465
 	if (isset($fm['ItalicAngle']) AND ($fm['ItalicAngle'] != 0)) {
466
-		$flags += 1<<6;
466
+		$flags += 1 << 6;
467 467
 	}
468
-	$fd .= ",'Flags'=>".$flags;
468
+	$fd .= ",'Flags'=>" . $flags;
469 469
 	//FontBBox
470 470
 	if (isset($fm['FontBBox'])) {
471 471
 		$fbb = $fm['FontBBox'];
472 472
 	} else {
473 473
 		$fbb = array(0, ($desc - 100), 1000, ($asc + 100));
474 474
 	}
475
-	$fd .= ",'FontBBox'=>'[".$fbb[0].' '.$fbb[1].' '.$fbb[2].' '.$fbb[3]."]'";
475
+	$fd .= ",'FontBBox'=>'[" . $fbb[0] . ' ' . $fbb[1] . ' ' . $fbb[2] . ' ' . $fbb[3] . "]'";
476 476
 	//ItalicAngle
477 477
 	$ia = (isset($fm['ItalicAngle']) ? $fm['ItalicAngle'] : 0);
478
-	$fd .= ",'ItalicAngle'=>".$ia;
478
+	$fd .= ",'ItalicAngle'=>" . $ia;
479 479
 	//StemV
480 480
 	if (isset($fm['StdVW'])) {
481 481
 		$stemv = $fm['StdVW'];
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
 	} else {
485 485
 		$stemv = 70;
486 486
 	}
487
-	$fd .= ",'StemV'=>".$stemv;
487
+	$fd .= ",'StemV'=>" . $stemv;
488 488
 	//MissingWidth
489
-	if(isset($fm['MissingWidth'])) {
490
-		$fd .= ",'MissingWidth'=>".$fm['MissingWidth'];
489
+	if (isset($fm['MissingWidth'])) {
490
+		$fd .= ",'MissingWidth'=>" . $fm['MissingWidth'];
491 491
 	}
492 492
 	$fd .= ')';
493 493
 	return $fd;
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 	$c = 0;
502 502
 	foreach ($cw as $i => $w) {
503 503
 		if (is_numeric($i)) {
504
-			$els[] = (((($c++)%10) == 0) ? "\n" : '').$i.'=>'.$w;
504
+			$els[] = (((($c++) % 10) == 0) ? "\n" : '') . $i . '=>' . $w;
505 505
 		}
506 506
 	}
507 507
 	$s .= implode(',', $els);
@@ -516,20 +516,20 @@  discard block
 block discarded – undo
516 516
 	$last = 0;
517 517
 	for ($i = 32; $i <= 255; $i++) {
518 518
 		if ($map[$i] != $ref[$i]) {
519
-			if ($i != $last+1) {
520
-				$s .= $i.' ';
519
+			if ($i != $last + 1) {
520
+				$s .= $i . ' ';
521 521
 			}
522 522
 			$last = $i;
523
-			$s .= '/'.$map[$i].' ';
523
+			$s .= '/' . $map[$i] . ' ';
524 524
 		}
525 525
 	}
526 526
 	return rtrim($s);
527 527
 }
528 528
 
529
-function SaveToFile($file, $s, $mode='t') {
530
-	$f = fopen($file, 'w'.$mode);
531
-	if(!$f) {
532
-		die('Can\'t write to file '.$file);
529
+function SaveToFile($file, $s, $mode = 't') {
530
+	$f = fopen($file, 'w' . $mode);
531
+	if (!$f) {
532
+		die('Can\'t write to file ' . $file);
533 533
 	}
534 534
 	fwrite($f, $s, strlen($s));
535 535
 	fclose($f);
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 	//Check if font license allows embedding
550 550
 	$f = fopen($file, 'rb');
551 551
 	if (!$f) {
552
-		die('Error: unable to open '.$file);
552
+		die('Error: unable to open ' . $file);
553 553
 	}
554 554
 	//Extract number of tables
555 555
 	fseek($f, 4, SEEK_CUR);
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 	$pp = ($fsType & 0x04) != 0;
579 579
 	$e = ($fsType & 0x08) != 0;
580 580
 	fclose($f);
581
-	if($rl AND (!$pp) AND (!$e)) {
581
+	if ($rl AND (!$pp) AND (!$e)) {
582 582
 		print "Warning: font license does not allow embedding\n";
583 583
 	}
584 584
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 //============================================================+
3 5
 // File name   : makefont.php
4 6
 // Begin       : 2004-12-31
Please login to merge, or discard this patch.
script/wp-emulator.script.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 
159 159
 	function trailingslashit( $string )
160 160
 	{
161
-	    return untrailingslashit( $string ) . '/';
161
+		return untrailingslashit( $string ) . '/';
162 162
 	}
163 163
 
164 164
 	function untrailingslashit( $string )
165 165
 	{
166
-	        return rtrim( $string, '/\\' );
166
+			return rtrim( $string, '/\\' );
167 167
 	}
168 168
 
169 169
 	function site_url()
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 		public $term_relationships = "term_relationship";
289 289
 		public $term_taxonomy = "term_taxonomy";
290 290
 
291
-    }
291
+	}
292 292
 
293 293
 	class WP_Widget
294 294
 	{
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	define('ABSPATH', dirname(dirname(dirname(dirname(dirname(__FILE__))))) . DIRECTORY_SEPARATOR);
3
-	define('WP_PLUGIN_DIR', dirname(dirname(dirname(__FILE__))) );
3
+	define('WP_PLUGIN_DIR', dirname(dirname(dirname(__FILE__))));
4 4
 	define('WP_LANG_DIR', 'FR');
5 5
 	define('WP_CONTENT_DIR', 'wp-content');
6 6
 
7
-	function __( $str )
7
+	function __($str)
8 8
 	{
9 9
 		$translate = "Result Testing text";
10 10
 		echo "[+] Requesting __ -> " . $str . PHP_EOL;
11 11
 		return $translate;
12 12
 	}
13 13
 
14
-	function add_action( $init, $object )
14
+	function add_action($init, $object)
15 15
 	{
16 16
 		$length = 0;
17 17
 		$hooked = "";
18 18
 		$oType = gettype($object);
19
-		if($oType == "object" || $oType == "array")
19
+		if ($oType == "object" || $oType == "array")
20 20
 		{
21 21
 			$hooked = "[";
22
-			foreach($object as $hook)
22
+			foreach ($object as $hook)
23 23
 			{
24 24
 				$length++;
25 25
 				$type = gettype($hook);
26 26
 
27
-				switch($type)
27
+				switch ($type)
28 28
 				{
29 29
 					case "integer":
30 30
 					case "boolean":
@@ -37,27 +37,27 @@  discard block
 block discarded – undo
37 37
 						break;
38 38
 				}
39 39
 			}
40
-			if($length > 0) $hooked = rtrim($hooked, ",");
40
+			if ($length > 0) $hooked = rtrim($hooked, ",");
41 41
 			$hooked .= "]";
42 42
 		}
43 43
 		else $hooked .= $object;
44 44
 		echo "[+] Adding action -> " . $init . " in " . $hooked . PHP_EOL;
45 45
 	}
46 46
 
47
-	function register_activation_hook( $file , $object )
47
+	function register_activation_hook($file, $object)
48 48
 	{
49 49
 		$length = 0;
50 50
 		$hooked = "";
51 51
 		$oType = gettype($object);
52
-		if($oType == "object" || $oType == "array")
52
+		if ($oType == "object" || $oType == "array")
53 53
 		{
54 54
 			$hooked = "[";
55
-			foreach($object as $hook)
55
+			foreach ($object as $hook)
56 56
 			{
57 57
 				$length++;
58 58
 				$type = gettype($hook);
59 59
 
60
-				switch($type)
60
+				switch ($type)
61 61
 				{
62 62
 					case "integer":
63 63
 					case "boolean":
@@ -70,27 +70,27 @@  discard block
 block discarded – undo
70 70
 						break;
71 71
 				}
72 72
 			}
73
-			if($length > 0) $hooked = rtrim($hooked, ",");
73
+			if ($length > 0) $hooked = rtrim($hooked, ",");
74 74
 			$hooked .= "]";
75 75
 		}
76 76
 		else $hooked .= $object;
77 77
 		echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL;
78 78
 	}
79 79
 
80
-	function register_deactivation_hook( $file , $object )
80
+	function register_deactivation_hook($file, $object)
81 81
 	{
82 82
 		$length = 0;
83 83
 		$hooked = "";
84 84
 		$oType = gettype($object);
85
-		if($oType == "object" || $oType == "array")
85
+		if ($oType == "object" || $oType == "array")
86 86
 		{
87 87
 			$hooked = "[";
88
-			foreach($object as $hook)
88
+			foreach ($object as $hook)
89 89
 			{
90 90
 				$length++;
91 91
 				$type = gettype($hook);
92 92
 
93
-				switch($type)
93
+				switch ($type)
94 94
 				{
95 95
 					case "integer":
96 96
 					case "boolean":
@@ -103,29 +103,29 @@  discard block
 block discarded – undo
103 103
 						break;
104 104
 				}
105 105
 			}
106
-			if($length > 0) $hooked = rtrim($hooked, ",");
106
+			if ($length > 0) $hooked = rtrim($hooked, ",");
107 107
 			$hooked .= "]";
108 108
 		}
109 109
 		else $hooked .= $object;
110 110
 		echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL;
111 111
 	}
112 112
 
113
-	function add_filter( $name, $fn, $nbr = "")
113
+	function add_filter($name, $fn, $nbr = "")
114 114
 	{
115 115
 		echo "[+] Adding filter -> " . $name . " X" . $nbr . PHP_EOL;
116 116
 	}
117 117
 
118
-	function add_shortcode( $name )
118
+	function add_shortcode($name)
119 119
 	{
120 120
 		echo "[+] Adding shortcode -> " . $name . PHP_EOL;
121 121
 	}
122 122
 
123
-	function add_option( $name, $conf)
123
+	function add_option($name, $conf)
124 124
 	{
125 125
 		echo "[+] Adding option -> " . $name . " conf:" . $conf . PHP_EOL;
126 126
 	}
127 127
 
128
-	function update_option( $name, $conf)
128
+	function update_option($name, $conf)
129 129
 	{
130 130
 		echo "[+] Updating option -> " . $name . " conf:" . $conf . PHP_EOL;
131 131
 	}
@@ -153,17 +153,17 @@  discard block
 block discarded – undo
153 153
 	function plugin_dir_path($path)
154 154
 	{
155 155
 		echo "[+] Plugin path -> " . $path . PHP_EOL;
156
-		return trailingslashit( dirname( $path ) );
156
+		return trailingslashit(dirname($path));
157 157
 	}
158 158
 
159
-	function trailingslashit( $string )
159
+	function trailingslashit($string)
160 160
 	{
161
-	    return untrailingslashit( $string ) . '/';
161
+	    return untrailingslashit($string) . '/';
162 162
 	}
163 163
 
164
-	function untrailingslashit( $string )
164
+	function untrailingslashit($string)
165 165
 	{
166
-	        return rtrim( $string, '/\\' );
166
+	        return rtrim($string, '/\\');
167 167
 	}
168 168
 
169 169
 	function site_url()
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 		return $dir;
216 216
 	}
217 217
 
218
-	function add_theme_support( $theme )
218
+	function add_theme_support($theme)
219 219
 	{
220 220
 		echo "[+] Adding theme support -> " . $theme . PHP_EOL;
221 221
 	}
222 222
 
223
-	function add_image_size( $image, $x, $y, $bool )
223
+	function add_image_size($image, $x, $y, $bool)
224 224
 	{
225 225
 		echo "[+] Adding image size -> " . $image . " x:" . $x . " y:" . $y . " bool:" . $bool . PHP_EOL;
226 226
 	}
@@ -232,24 +232,24 @@  discard block
 block discarded – undo
232 232
 		return $lang;
233 233
 	}
234 234
 
235
-	function load_plugin_textdomain( $name, $bool, $dir)
235
+	function load_plugin_textdomain($name, $bool, $dir)
236 236
 	{
237 237
 		echo "[+] Loading plugin textdomain -> " . $name . " bool:" . $bool . " dir:" . $dir . PHP_EOL;
238 238
 	}
239 239
 
240
-	function get_option( $name, $int = 0 )
240
+	function get_option($name, $int = 0)
241 241
 	{
242 242
 		echo "[+] Getting option -> " . $name . " int:" . $int . PHP_EOL;
243 243
 		return "";
244 244
 	}
245 245
 
246
-	function get_site_option( $name, $int = 0 )
246
+	function get_site_option($name, $int = 0)
247 247
 	{
248 248
 		echo "[+] Getting site option -> " . $name . " int:" . $int . PHP_EOL;
249 249
 		return "";
250 250
 	}
251 251
 
252
-	function current_time( $str )
252
+	function current_time($str)
253 253
 	{
254 254
 		$time = " 2005-08-05 10:41:13";
255 255
 		echo "[+] Requesting current_time -> " . $str . PHP_EOL;
@@ -258,17 +258,17 @@  discard block
 block discarded – undo
258 258
 
259 259
 	class WPDB
260 260
 	{
261
-		function prepare( $request = "" )
261
+		function prepare($request = "")
262 262
 		{
263 263
 			echo "[+] Preparing -> " . $request . PHP_EOL;
264 264
 		}
265 265
 
266
-		public static function get_var( $request = "" )
266
+		public static function get_var($request = "")
267 267
 		{
268 268
 			echo "[+] Requesting get var -> " . $request . PHP_EOL;
269 269
 		}
270 270
 
271
-		public static function get_charset_collate( $request = "" )
271
+		public static function get_charset_collate($request = "")
272 272
 		{
273 273
 			echo "[+] Requesting get charset collate -> " . $request . PHP_EOL;
274 274
 		}
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,10 +37,13 @@  discard block
 block discarded – undo
37 37
 						break;
38 38
 				}
39 39
 			}
40
-			if($length > 0) $hooked = rtrim($hooked, ",");
40
+			if($length > 0) {
41
+				$hooked = rtrim($hooked, ",");
42
+			}
41 43
 			$hooked .= "]";
44
+		} else {
45
+			$hooked .= $object;
42 46
 		}
43
-		else $hooked .= $object;
44 47
 		echo "[+] Adding action -> " . $init . " in " . $hooked . PHP_EOL;
45 48
 	}
46 49
 
@@ -70,10 +73,13 @@  discard block
 block discarded – undo
70 73
 						break;
71 74
 				}
72 75
 			}
73
-			if($length > 0) $hooked = rtrim($hooked, ",");
76
+			if($length > 0) {
77
+				$hooked = rtrim($hooked, ",");
78
+			}
74 79
 			$hooked .= "]";
80
+		} else {
81
+			$hooked .= $object;
75 82
 		}
76
-		else $hooked .= $object;
77 83
 		echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL;
78 84
 	}
79 85
 
@@ -103,10 +109,13 @@  discard block
 block discarded – undo
103 109
 						break;
104 110
 				}
105 111
 			}
106
-			if($length > 0) $hooked = rtrim($hooked, ",");
112
+			if($length > 0) {
113
+				$hooked = rtrim($hooked, ",");
114
+			}
107 115
 			$hooked .= "]";
116
+		} else {
117
+			$hooked .= $object;
108 118
 		}
109
-		else $hooked .= $object;
110 119
 		echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL;
111 120
 	}
112 121
 
Please login to merge, or discard this patch.
script/unit.script.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 $unitList = searchFiles('.' . DIRECTORY_SEPARATOR, END_TEST);
11 11
 
12 12
 // Loop on unitList
13
-foreach($unitList as $test)
13
+foreach ($unitList as $test)
14 14
 {
15 15
 	echo "[+] Testing -> " . $test . PHP_EOL;
16 16
 	include($test);
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	$ite = new RecursiveIteratorIterator($dir);
29 29
 	$files = new RegexIterator($ite, $pattern, RegexIterator::GET_MATCH);
30 30
 	$fileList = array();
31
-	foreach($files as $file)
31
+	foreach ($files as $file)
32 32
 	{
33 33
 		$fileList[] = $file[0];
34 34
 	}
Please login to merge, or discard this patch.
includes/librairies/eav/wp_list_custom_attributes.class.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		 * to keep hidden, and a list of columns that are sortable. Each of these
315 315
 		 * can be defined in another method (as we've done here) before being
316 316
 		 * used to build the value for our _column_headers property.
317
-		*/
317
+		 */
318 318
 		$columns = $this->get_columns();
319 319
 		$hidden = array();
320 320
 		$sortable = $this->get_sortable_columns();
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
 		 * headers. The $this->_column_headers property takes an array which contains
325 325
 		 * 3 other arrays. One for all columns, one for hidden columns, and one
326 326
 		 * for sortable columns.
327
-		*/
327
+		 */
328 328
 		$this->_column_headers = array($columns, $hidden, $sortable);
329 329
 
330 330
 		/**
331 331
 		 * Optional. You can handle your bulk actions however you see fit. In this
332 332
 		 * case, we'll handle them within our package just to keep things clean.
333
-		*/
333
+		 */
334 334
 		$this->process_bulk_action();
335 335
 
336 336
 		/**
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
 		 * our data. In a real-world implementation, you will probably want to
342 342
 		 * use sort and pagination data to build a custom query instead, as you'll
343 343
 		 * be able to use your precisely-queried data immediately.
344
-		*/
344
+		 */
345 345
 		$data = $this->datas;
346 346
 
347 347
 		/**
348 348
 		 * REQUIRED for pagination. Let's figure out what page the user is currently
349 349
 		 * looking at. We'll need this later, so you should always include it in
350 350
 		 * your own package classes.
351
-		*/
351
+		 */
352 352
 		$current_page = $this->get_pagenum();
353 353
 
354 354
 		/**
@@ -356,20 +356,20 @@  discard block
 block discarded – undo
356 356
 		 * In real-world use, this would be the total number of items in your database,
357 357
 		 * without filtering. We'll need this later, so you should always include it
358 358
 		 * in your own package classes.
359
-		*/
359
+		 */
360 360
 		$total_items = count($data);
361 361
 
362 362
 		/**
363 363
 		 * The WP_List_Table class does not handle pagination for us, so we need
364 364
 		 * to ensure that the data is trimmed to only the current page. We can use
365 365
 		 * array_slice() to
366
-		*/
366
+		 */
367 367
 		$data = array_slice($data,(($current_page-1)*$per_page),$per_page);
368 368
 
369 369
 		/**
370 370
 		 * REQUIRED. Now we can add our *sorted* data to the items property, where
371 371
 		 * it can be used by the rest of the class.
372
-		*/
372
+		 */
373 373
 		$this->items = $data;
374 374
 
375 375
 		/*	REQUIRED. We also have to register our pagination options & calculations.	*/
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 
@@ -12,38 +12,38 @@  discard block
 block discarded – undo
12 12
  * @package wpshop
13 13
  * @subpackage librairies
14 14
  */
15
-class wpshop_attributes_custom_List_table extends WP_List_Table{
15
+class wpshop_attributes_custom_List_table extends WP_List_Table {
16 16
 	var $datas;
17 17
 
18 18
 	/** ************************************************************************
19 19
 	 * REQUIRED. Set up a constructor that references the parent constructor. We
20 20
 	 * use the parent reference to set some default configs.
21 21
 	 ***************************************************************************/
22
-	function __construct(){
22
+	function __construct() {
23 23
 		global $status, $page;
24 24
 
25 25
 		//Set parent defaults
26
-		parent::__construct( array(
27
-			'singular'  => __('attribute\'s', 'wpshop'),    //singular name of the listed records
28
-			'plural'    => __('attributes\'', 'wpshop'),    //plural name of the listed records
26
+		parent::__construct(array(
27
+			'singular'  => __('attribute\'s', 'wpshop'), //singular name of the listed records
28
+			'plural'    => __('attributes\'', 'wpshop'), //plural name of the listed records
29 29
 			'ajax'     => true       //does this table support ajax?
30
-		) );
30
+		));
31 31
 	}
32 32
 
33 33
 	/*	Allows to set different listings for attributes	*/
34
-	function get_views(){
34
+	function get_views() {
35 35
 		$wpshop_attribute_links = array();
36 36
 
37 37
 		$active_nb = wpshop_attributes::getElement('', "'valid'");
38 38
 		$unactive_nb = wpshop_attributes::getElement('', "'moderated', 'notused'");
39 39
 		$deleted_nb = wpshop_attributes::getElement('', "'deleted'");
40 40
 
41
-		$attribute_status = !empty( $_REQUEST['attribute_status'] ) ? sanitize_text_field( $_REQUEST['attribute_status'] ) : '';
41
+		$attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field($_REQUEST['attribute_status']) : '';
42 42
 
43
-		$wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_valid'.(empty($attribute_status)?' current':'')] = '<a href="'.admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING).'" >'.__('Used attributes', 'wpshop').' ('.count($active_nb).')</a>';
44
-		$wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_moderated'.(!empty($attribute_status) && ($attribute_status=='unactive')?' current':'')] = '<a href="'.admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING.'&attribute_status=unactive').'" >'.__('Unactive attributes', 'wpshop').' ('.count($unactive_nb).')</a>';
45
-		$wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_deleted'.(!empty($attribute_status) && ($attribute_status=='deleted')?' current':'')] = '<a href="'.admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING.'&attribute_status=deleted').'" >'.__('Trashed attributes', 'wpshop').' ('.count($deleted_nb).')</a>';
46
-		$wpshop_attribute_links['unit_management_link'] = '<a href="#" id="wpshop_attribute_unit_manager_opener" data-nonce="' . wp_create_nonce( 'load_unit_interface' ) . '">'.__('Unit management', 'wpshop').'</a>';
43
+		$wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_valid' . (empty($attribute_status) ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING) . '" >' . __('Used attributes', 'wpshop') . ' (' . count($active_nb) . ')</a>';
44
+		$wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_moderated' . (!empty($attribute_status) && ($attribute_status == 'unactive') ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING . '&attribute_status=unactive') . '" >' . __('Unactive attributes', 'wpshop') . ' (' . count($unactive_nb) . ')</a>';
45
+		$wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_deleted' . (!empty($attribute_status) && ($attribute_status == 'deleted') ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING . '&attribute_status=deleted') . '" >' . __('Trashed attributes', 'wpshop') . ' (' . count($deleted_nb) . ')</a>';
46
+		$wpshop_attribute_links['unit_management_link'] = '<a href="#" id="wpshop_attribute_unit_manager_opener" data-nonce="' . wp_create_nonce('load_unit_interface') . '">' . __('Unit management', 'wpshop') . '</a>';
47 47
 		$wpshop_attribute_links['unit_management_dialog'] = '<div id="wpshop_attribute_unit_manager"title="' . __('Unit management', 'wpshop') . '" class="wpshopHide" ><div class="loading_picture_container" id="product_chooser_picture" ><img src="' . WPSHOP_LOADING_ICON . '" alt="loading..." /></div></div>';
48 48
 		return $wpshop_attribute_links;
49 49
 	}
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 	 * @see WP_List_Table::::single_row_columns()
62 62
 	 * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
63 63
 	 **************************************************************************/
64
-	function get_columns(){
64
+	function get_columns() {
65 65
 		$columns = array(
66
-			'cb'       	=> '',//'<input type="checkbox" />', //Render a checkbox instead of text
66
+			'cb'       	=> '', //'<input type="checkbox" />', //Render a checkbox instead of text
67 67
 			'id'       	=> __('Id.', 'wpshop'),
68 68
 			'name'    	=> __('Name', 'wpshop'),
69 69
 			'status'    => __('Status', 'wpshop'),
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 	 * @param array $column_name The name/slug of the column to be processed
95 95
 	 * @return string Text or HTML to be placed inside the column <td>
96 96
 	 **************************************************************************/
97
-	function column_default($item, $column_name){
98
-		switch($column_name){
97
+	function column_default($item, $column_name) {
98
+		switch ($column_name) {
99 99
 			default:
100
-				return print_r($item,true); //Show the whole array for troubleshooting purposes
100
+				return print_r($item, true); //Show the whole array for troubleshooting purposes
101 101
 		}
102 102
 	}
103 103
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param array $item A singular item (one full row's worth of data)
118 118
 	 * @return string Text to be placed inside the column <td> (movie title only)
119 119
 	 **************************************************************************/
120
-	function column_id($item){
120
+	function column_id($item) {
121 121
 		return $item['id'];
122 122
 	}
123 123
 	/** ************************************************************************
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * @param array $item A singular item (one full row's worth of data)
137 137
 	 * @return string Text to be placed inside the column <td> (movie title only)
138 138
 	 **************************************************************************/
139
-	function column_status($item){
139
+	function column_status($item) {
140 140
 		return __($item['status'], 'wpshop');
141 141
 	}
142 142
 	/** ************************************************************************
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @param array $item A singular item (one full row's worth of data)
156 156
 	 * @return string Text to be placed inside the column <td> (movie title only)
157 157
 	 **************************************************************************/
158
-	function column_code($item){
158
+	function column_code($item) {
159 159
 		return $item['code'];
160 160
 	}
161 161
 	/** ************************************************************************
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 * @param array $item A singular item (one full row's worth of data)
175 175
 	 * @return string Text to be placed inside the column <td> (movie title only)
176 176
 	 **************************************************************************/
177
-	function column_entity($item){
178
-		return __($item['entity'],'wpshop');
177
+	function column_entity($item) {
178
+		return __($item['entity'], 'wpshop');
179 179
 	}
180 180
 	/** ************************************************************************
181 181
 	 * Recommended. This is a custom column method and is responsible for what
@@ -193,28 +193,28 @@  discard block
 block discarded – undo
193 193
 	 * @param array $item A singular item (one full row's worth of data)
194 194
 	 * @return string Text to be placed inside the column <td> (movie title only)
195 195
 	 **************************************************************************/
196
-	function column_name($item){
196
+	function column_name($item) {
197 197
 		$attribute_undeletable = unserialize(WPSHOP_ATTRIBUTE_UNDELETABLE);
198 198
 
199
-		$link_format = admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s';
200
-		$default_action='edit';
201
-		$default_action_text=__('Edit', 'wpshop');
202
-		$attribute_status = !empty( $_REQUEST['attribute_status'] ) ? sanitize_text_field( $_REQUEST['attribute_status'] ) : '';
203
-		if(!empty($attribute_status) && ($attribute_status=='deleted')){
204
-			$default_action='activate';
205
-			$default_action_text=__('Restore', 'wpshop');
199
+		$link_format = admin_url('admin.php') . '?page=%2$s&amp;action=%3$s&amp;id=%4$s';
200
+		$default_action = 'edit';
201
+		$default_action_text = __('Edit', 'wpshop');
202
+		$attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field($_REQUEST['attribute_status']) : '';
203
+		if (!empty($attribute_status) && ($attribute_status == 'deleted')) {
204
+			$default_action = 'activate';
205
+			$default_action_text = __('Restore', 'wpshop');
206 206
 		}
207 207
 		//Build row actions
208 208
 		$actions = array(
209
-			'edit'     => sprintf('<a href="'.$link_format.'">'.$default_action_text.'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING,$default_action,$item['id'])
209
+			'edit'     => sprintf('<a href="' . $link_format . '">' . $default_action_text . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, $default_action, $item['id'])
210 210
 		);
211
-		if(empty($attribute_status) && (!in_array($item['code'], $attribute_undeletable))){
212
-			$actions['delete'] = sprintf('<a href="'.$link_format.'">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING,'delete',$item['id']);
211
+		if (empty($attribute_status) && (!in_array($item['code'], $attribute_undeletable))) {
212
+			$actions['delete'] = sprintf('<a href="' . $link_format . '">' . __('Delete', 'wpshop') . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, 'delete', $item['id']);
213 213
 		}
214 214
 
215 215
 		//Return the title contents
216 216
 		return sprintf('%1$s%2$s',
217
-			/*$1%s*/ sprintf('<a href="'.$link_format.'">'.__($item['name'], 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING,$default_action,$item['id']),
217
+			/*$1%s*/ sprintf('<a href="' . $link_format . '">' . __($item['name'], 'wpshop') . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, $default_action, $item['id']),
218 218
 			/*$3%s*/ $this->row_actions($actions)
219 219
 		);
220 220
 	}
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 	 * @param array $item A singular item (one full row's worth of data)
228 228
 	 * @return string Text to be placed inside the column <td> (movie title only)
229 229
 	 **************************************************************************/
230
-	function column_cb($item){
230
+	function column_cb($item) {
231 231
 		return '';
232 232
 		return sprintf(
233 233
 			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
234
-			/*$1%s*/ $this->_args['singular'],  //Let's simply repurpose the table's singular label ("movie")
234
+			/*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie")
235 235
 			/*$2%s*/ $item['id']             //The value of the checkbox should be the record's id
236 236
 		);
237 237
 	}
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	 **************************************************************************/
253 253
 	function get_sortable_columns() {
254 254
 		$sortable_columns = array(
255
-			'name'    => array('frontend_label',true),    //true means its already sorted
256
-			'status'  => array('status',true)
255
+			'name'    => array('frontend_label', true), //true means its already sorted
256
+			'status'  => array('status', true)
257 257
 		);
258 258
 		return $sortable_columns;
259 259
 	}
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 **************************************************************************/
289 289
 	function process_bulk_action() {
290 290
 		//Detect when a bulk action is being triggered...
291
-		if( 'delete'===$this->current_action() ) {
291
+		if ('delete' === $this->current_action()) {
292 292
 			wp_die('Items deleted (or they would be if we had items to delete)!');
293 293
 		}
294 294
 	}
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 **************************************************************************/
310 310
 	function prepare_items() {
311 311
 		/*	First, lets decide how many records per page to show	*/
312
-		$per_page = 10;//$this->get_items_per_page('attributes_per_page', 10);
312
+		$per_page = 10; //$this->get_items_per_page('attributes_per_page', 10);
313 313
 
314 314
 		/**
315 315
 		 * REQUIRED. Now we need to define our column headers. This includes a complete
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 		 * to ensure that the data is trimmed to only the current page. We can use
368 368
 		 * array_slice() to
369 369
 		*/
370
-		$data = array_slice($data,(($current_page-1)*$per_page),$per_page);
370
+		$data = array_slice($data, (($current_page - 1) * $per_page), $per_page);
371 371
 
372 372
 		/**
373 373
 		 * REQUIRED. Now we can add our *sorted* data to the items property, where
@@ -376,10 +376,10 @@  discard block
 block discarded – undo
376 376
 		$this->items = $data;
377 377
 
378 378
 		/*	REQUIRED. We also have to register our pagination options & calculations.	*/
379
-		$this->set_pagination_args( array(
380
-			'total_items' => $total_items,               		//WE have to calculate the total number of items
381
-			'per_page'    => $per_page,                 		//WE have to determine how many items to show on a page
382
-			'total_pages' => ceil($total_items/$per_page)   //WE have to calculate the total number of pages
383
-		) );
379
+		$this->set_pagination_args(array(
380
+			'total_items' => $total_items, //WE have to calculate the total number of items
381
+			'per_page'    => $per_page, //WE have to determine how many items to show on a page
382
+			'total_pages' => ceil($total_items / $per_page)   //WE have to calculate the total number of pages
383
+		));
384 384
 	}
385 385
 }
Please login to merge, or discard this patch.
includes/librairies/eav/wp_list_custom_attributes_set.class.php 3 patches
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 	var $datas;
17 17
 
18 18
 	/** ************************************************************************
19
-	* REQUIRED. Set up a constructor that references the parent constructor. We
20
-	* use the parent reference to set some default configs.
21
-	***************************************************************************/
19
+	 * REQUIRED. Set up a constructor that references the parent constructor. We
20
+	 * use the parent reference to set some default configs.
21
+	 ***************************************************************************/
22 22
 	function __construct(){
23 23
 		global $status, $page;
24 24
 
@@ -44,18 +44,18 @@  discard block
 block discarded – undo
44 44
 	}
45 45
 
46 46
 	/** ************************************************************************
47
-	* REQUIRED! This method dictates the table's columns and titles. This should
48
-	* return an array where the key is the column slug (and class) and the value
49
-	* is the column's title text. If you need a checkbox for bulk actions, refer
50
-	* to the $columns array below.
51
-	*
52
-	* The 'cb' column is treated differently than the rest. If including a checkbox
53
-	* column in your table you must create a column_cb() method. If you don't need
54
-	* bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
55
-	*
56
-	* @see WP_List_Table::::single_row_columns()
57
-	* @return array An associative array containing column information: 'slugs'=>'Visible Titles'
58
-	**************************************************************************/
47
+	 * REQUIRED! This method dictates the table's columns and titles. This should
48
+	 * return an array where the key is the column slug (and class) and the value
49
+	 * is the column's title text. If you need a checkbox for bulk actions, refer
50
+	 * to the $columns array below.
51
+	 *
52
+	 * The 'cb' column is treated differently than the rest. If including a checkbox
53
+	 * column in your table you must create a column_cb() method. If you don't need
54
+	 * bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
55
+	 *
56
+	 * @see WP_List_Table::::single_row_columns()
57
+	 * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
58
+	 **************************************************************************/
59 59
 	function get_columns(){
60 60
 		$columns = array(
61 61
 			'cb'       => '',//'<input type="checkbox" />', //Render a checkbox instead of text
@@ -69,26 +69,26 @@  discard block
 block discarded – undo
69 69
 	}
70 70
 
71 71
 	/** ************************************************************************
72
-	* Recommended. This method is called when the parent class can't find a method
73
-	* specifically build for a given column. Generally, it's recommended to include
74
-	* one method for each column you want to render, keeping your package class
75
-	* neat and organized. For example, if the class needs to process a column
76
-	* named 'title', it would first see if a method named $this->column_title()
77
-	* exists - if it does, that method will be used. If it doesn't, this one will
78
-	* be used. Generally, you should try to use custom column methods as much as
79
-	* possible.
80
-	*
81
-	* Since we have defined a column_title() method later on, this method doesn't
82
-	* need to concern itself with any column with a name of 'title'. Instead, it
83
-	* needs to handle everything else.
84
-	*
85
-	* For more detailed insight into how columns are handled, take a look at
86
-	* WP_List_Table::single_row_columns()
87
-	*
88
-	* @param array $item A singular item (one full row's worth of data)
89
-	* @param array $column_name The name/slug of the column to be processed
90
-	* @return string Text or HTML to be placed inside the column <td>
91
-	**************************************************************************/
72
+	 * Recommended. This method is called when the parent class can't find a method
73
+	 * specifically build for a given column. Generally, it's recommended to include
74
+	 * one method for each column you want to render, keeping your package class
75
+	 * neat and organized. For example, if the class needs to process a column
76
+	 * named 'title', it would first see if a method named $this->column_title()
77
+	 * exists - if it does, that method will be used. If it doesn't, this one will
78
+	 * be used. Generally, you should try to use custom column methods as much as
79
+	 * possible.
80
+	 *
81
+	 * Since we have defined a column_title() method later on, this method doesn't
82
+	 * need to concern itself with any column with a name of 'title'. Instead, it
83
+	 * needs to handle everything else.
84
+	 *
85
+	 * For more detailed insight into how columns are handled, take a look at
86
+	 * WP_List_Table::single_row_columns()
87
+	 *
88
+	 * @param array $item A singular item (one full row's worth of data)
89
+	 * @param array $column_name The name/slug of the column to be processed
90
+	 * @return string Text or HTML to be placed inside the column <td>
91
+	 **************************************************************************/
92 92
 	function column_default($item, $column_name){
93 93
 		switch($column_name){
94 94
 			default:
@@ -97,97 +97,97 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 
99 99
 	/** ************************************************************************
100
-	* Recommended. This is a custom column method and is responsible for what
101
-	* is rendered in any column with a name/slug of 'title'. Every time the class
102
-	* needs to render a column, it first looks for a method named
103
-	* column_{$column_title} - if it exists, that method is run. If it doesn't
104
-	* exist, column_default() is called instead.
105
-	*
106
-	* This example also illustrates how to implement rollover actions. Actions
107
-	* should be an associative array formatted as 'slug'=>'link html' - and you
108
-	* will need to generate the URLs yourself. You could even ensure the links
109
-	*
110
-	*
111
-	* @see WP_List_Table::::single_row_columns()
112
-	* @param array $item A singular item (one full row's worth of data)
113
-	* @return string Text to be placed inside the column <td> (movie title only)
114
-	**************************************************************************/
100
+	 * Recommended. This is a custom column method and is responsible for what
101
+	 * is rendered in any column with a name/slug of 'title'. Every time the class
102
+	 * needs to render a column, it first looks for a method named
103
+	 * column_{$column_title} - if it exists, that method is run. If it doesn't
104
+	 * exist, column_default() is called instead.
105
+	 *
106
+	 * This example also illustrates how to implement rollover actions. Actions
107
+	 * should be an associative array formatted as 'slug'=>'link html' - and you
108
+	 * will need to generate the URLs yourself. You could even ensure the links
109
+	 *
110
+	 *
111
+	 * @see WP_List_Table::::single_row_columns()
112
+	 * @param array $item A singular item (one full row's worth of data)
113
+	 * @return string Text to be placed inside the column <td> (movie title only)
114
+	 **************************************************************************/
115 115
 	function column_id($item){
116 116
 		return $item['id'];
117 117
 	}
118 118
 	/** ************************************************************************
119
-	* Recommended. This is a custom column method and is responsible for what
120
-	* is rendered in any column with a name/slug of 'title'. Every time the class
121
-	* needs to render a column, it first looks for a method named
122
-	* column_{$column_title} - if it exists, that method is run. If it doesn't
123
-	* exist, column_default() is called instead.
124
-	*
125
-	* This example also illustrates how to implement rollover actions. Actions
126
-	* should be an associative array formatted as 'slug'=>'link html' - and you
127
-	* will need to generate the URLs yourself. You could even ensure the links
128
-	*
129
-	*
130
-	* @see WP_List_Table::::single_row_columns()
131
-	* @param array $item A singular item (one full row's worth of data)
132
-	* @return string Text to be placed inside the column <td> (movie title only)
133
-	**************************************************************************/
119
+	 * Recommended. This is a custom column method and is responsible for what
120
+	 * is rendered in any column with a name/slug of 'title'. Every time the class
121
+	 * needs to render a column, it first looks for a method named
122
+	 * column_{$column_title} - if it exists, that method is run. If it doesn't
123
+	 * exist, column_default() is called instead.
124
+	 *
125
+	 * This example also illustrates how to implement rollover actions. Actions
126
+	 * should be an associative array formatted as 'slug'=>'link html' - and you
127
+	 * will need to generate the URLs yourself. You could even ensure the links
128
+	 *
129
+	 *
130
+	 * @see WP_List_Table::::single_row_columns()
131
+	 * @param array $item A singular item (one full row's worth of data)
132
+	 * @return string Text to be placed inside the column <td> (movie title only)
133
+	 **************************************************************************/
134 134
 	function column_status($item){
135 135
 		return __($item['status'], 'wpshop');
136 136
 	}
137 137
 	/** ************************************************************************
138
-	* Recommended. This is a custom column method and is responsible for what
139
-	* is rendered in any column with a name/slug of 'title'. Every time the class
140
-	* needs to render a column, it first looks for a method named
141
-	* column_{$column_title} - if it exists, that method is run. If it doesn't
142
-	* exist, column_default() is called instead.
143
-	*
144
-	* This example also illustrates how to implement rollover actions. Actions
145
-	* should be an associative array formatted as 'slug'=>'link html' - and you
146
-	* will need to generate the URLs yourself. You could even ensure the links
147
-	*
148
-	*
149
-	* @see WP_List_Table::::single_row_columns()
150
-	* @param array $item A singular item (one full row's worth of data)
151
-	* @return string Text to be placed inside the column <td> (movie title only)
152
-	**************************************************************************/
138
+	 * Recommended. This is a custom column method and is responsible for what
139
+	 * is rendered in any column with a name/slug of 'title'. Every time the class
140
+	 * needs to render a column, it first looks for a method named
141
+	 * column_{$column_title} - if it exists, that method is run. If it doesn't
142
+	 * exist, column_default() is called instead.
143
+	 *
144
+	 * This example also illustrates how to implement rollover actions. Actions
145
+	 * should be an associative array formatted as 'slug'=>'link html' - and you
146
+	 * will need to generate the URLs yourself. You could even ensure the links
147
+	 *
148
+	 *
149
+	 * @see WP_List_Table::::single_row_columns()
150
+	 * @param array $item A singular item (one full row's worth of data)
151
+	 * @return string Text to be placed inside the column <td> (movie title only)
152
+	 **************************************************************************/
153 153
 	function column_content($item){
154 154
 		return $item['content'];
155 155
 	}
156 156
 	/** ************************************************************************
157
-	* Recommended. This is a custom column method and is responsible for what
158
-	* is rendered in any column with a name/slug of 'title'. Every time the class
159
-	* needs to render a column, it first looks for a method named
160
-	* column_{$column_title} - if it exists, that method is run. If it doesn't
161
-	* exist, column_default() is called instead.
162
-	*
163
-	* This example also illustrates how to implement rollover actions. Actions
164
-	* should be an associative array formatted as 'slug'=>'link html' - and you
165
-	* will need to generate the URLs yourself. You could even ensure the links
166
-	*
167
-	*
168
-	* @see WP_List_Table::::single_row_columns()
169
-	* @param array $item A singular item (one full row's worth of data)
170
-	* @return string Text to be placed inside the column <td> (movie title only)
171
-	**************************************************************************/
157
+	 * Recommended. This is a custom column method and is responsible for what
158
+	 * is rendered in any column with a name/slug of 'title'. Every time the class
159
+	 * needs to render a column, it first looks for a method named
160
+	 * column_{$column_title} - if it exists, that method is run. If it doesn't
161
+	 * exist, column_default() is called instead.
162
+	 *
163
+	 * This example also illustrates how to implement rollover actions. Actions
164
+	 * should be an associative array formatted as 'slug'=>'link html' - and you
165
+	 * will need to generate the URLs yourself. You could even ensure the links
166
+	 *
167
+	 *
168
+	 * @see WP_List_Table::::single_row_columns()
169
+	 * @param array $item A singular item (one full row's worth of data)
170
+	 * @return string Text to be placed inside the column <td> (movie title only)
171
+	 **************************************************************************/
172 172
 	function column_entity($item){
173 173
 		return __($item['entity'],'wpshop');
174 174
 	}
175 175
 	/** ************************************************************************
176
-	* Recommended. This is a custom column method and is responsible for what
177
-	* is rendered in any column with a name/slug of 'title'. Every time the class
178
-	* needs to render a column, it first looks for a method named
179
-	* column_{$column_title} - if it exists, that method is run. If it doesn't
180
-	* exist, column_default() is called instead.
181
-	*
182
-	* This example also illustrates how to implement rollover actions. Actions
183
-	* should be an associative array formatted as 'slug'=>'link html' - and you
184
-	* will need to generate the URLs yourself. You could even ensure the links
185
-	*
186
-	*
187
-	* @see WP_List_Table::::single_row_columns()
188
-	* @param array $item A singular item (one full row's worth of data)
189
-	* @return string Text to be placed inside the column <td> (movie title only)
190
-	**************************************************************************/
176
+	 * Recommended. This is a custom column method and is responsible for what
177
+	 * is rendered in any column with a name/slug of 'title'. Every time the class
178
+	 * needs to render a column, it first looks for a method named
179
+	 * column_{$column_title} - if it exists, that method is run. If it doesn't
180
+	 * exist, column_default() is called instead.
181
+	 *
182
+	 * This example also illustrates how to implement rollover actions. Actions
183
+	 * should be an associative array formatted as 'slug'=>'link html' - and you
184
+	 * will need to generate the URLs yourself. You could even ensure the links
185
+	 *
186
+	 *
187
+	 * @see WP_List_Table::::single_row_columns()
188
+	 * @param array $item A singular item (one full row's worth of data)
189
+	 * @return string Text to be placed inside the column <td> (movie title only)
190
+	 **************************************************************************/
191 191
 	function column_name($item){
192 192
 		//Build row actions
193 193
 		$default_action='edit';
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 		);
209 209
 	}
210 210
 	/** ************************************************************************
211
-	* REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column
212
-	* is given special treatment when columns are processed. It ALWAYS needs to
213
-	* have it's own method.
214
-	*
215
-	* @see WP_List_Table::::single_row_columns()
216
-	* @param array $item A singular item (one full row's worth of data)
217
-	* @return string Text to be placed inside the column <td> (movie title only)
218
-	**************************************************************************/
211
+	 * REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column
212
+	 * is given special treatment when columns are processed. It ALWAYS needs to
213
+	 * have it's own method.
214
+	 *
215
+	 * @see WP_List_Table::::single_row_columns()
216
+	 * @param array $item A singular item (one full row's worth of data)
217
+	 * @return string Text to be placed inside the column <td> (movie title only)
218
+	 **************************************************************************/
219 219
 	function column_cb($item){
220 220
 		return '';
221 221
 		return sprintf(
@@ -226,19 +226,19 @@  discard block
 block discarded – undo
226 226
 	}
227 227
 
228 228
 	/** ************************************************************************
229
-	* Optional. If you want one or more columns to be sortable (ASC/DESC toggle),
230
-	* you will need to register it here. This should return an array where the
231
-	* key is the column that needs to be sortable, and the value is db column to
232
-	* sort by. Often, the key and value will be the same, but this is not always
233
-	* the case (as the value is a column name from the database, not the list table).
234
-	*
235
-	* This method merely defines which columns should be sortable and makes them
236
-	* clickable - it does not handle the actual sorting. You still need to detect
237
-	* the ORDERBY and ORDER querystring variables within prepare_items() and sort
238
-	* your data accordingly (usually by modifying your query).
239
-	*
240
-	* @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
241
-	**************************************************************************/
229
+	 * Optional. If you want one or more columns to be sortable (ASC/DESC toggle),
230
+	 * you will need to register it here. This should return an array where the
231
+	 * key is the column that needs to be sortable, and the value is db column to
232
+	 * sort by. Often, the key and value will be the same, but this is not always
233
+	 * the case (as the value is a column name from the database, not the list table).
234
+	 *
235
+	 * This method merely defines which columns should be sortable and makes them
236
+	 * clickable - it does not handle the actual sorting. You still need to detect
237
+	 * the ORDERBY and ORDER querystring variables within prepare_items() and sort
238
+	 * your data accordingly (usually by modifying your query).
239
+	 *
240
+	 * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
241
+	 **************************************************************************/
242 242
 	function get_sortable_columns() {
243 243
 		$sortable_columns = array(
244 244
 			//'name'    => array('name',true)    //true means its already sorted
@@ -247,19 +247,19 @@  discard block
 block discarded – undo
247 247
 	}
248 248
 
249 249
 	/** ************************************************************************
250
-	* Optional. If you need to include bulk actions in your list table, this is
251
-	* the place to define them. Bulk actions are an associative array in the format
252
-	* 'slug'=>'Visible Title'
253
-	*
254
-	* If this method returns an empty value, no bulk action will be rendered. If
255
-	* you specify any bulk actions, the bulk actions box will be rendered with
256
-	* the table automatically on display().
257
-	*
258
-	* Also note that list tables are not automatically wrapped in <form> elements,
259
-	* so you will need to create those manually in order for bulk actions to function.
260
-	*
261
-	* @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
262
-	**************************************************************************/
250
+	 * Optional. If you need to include bulk actions in your list table, this is
251
+	 * the place to define them. Bulk actions are an associative array in the format
252
+	 * 'slug'=>'Visible Title'
253
+	 *
254
+	 * If this method returns an empty value, no bulk action will be rendered. If
255
+	 * you specify any bulk actions, the bulk actions box will be rendered with
256
+	 * the table automatically on display().
257
+	 *
258
+	 * Also note that list tables are not automatically wrapped in <form> elements,
259
+	 * so you will need to create those manually in order for bulk actions to function.
260
+	 *
261
+	 * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
262
+	 **************************************************************************/
263 263
 	function get_bulk_actions() {
264 264
 		$actions = array(
265 265
 			// 'delete'    => __('Delete','wpshop')
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 	}
269 269
 
270 270
 	/** ************************************************************************
271
-	* Optional. You can handle your bulk actions anywhere or anyhow you prefer.
272
-	* For this example package, we will handle it in the class to keep things
273
-	* clean and organized.
274
-	*
275
-	* @see $this->prepare_items()
276
-	**************************************************************************/
271
+	 * Optional. You can handle your bulk actions anywhere or anyhow you prefer.
272
+	 * For this example package, we will handle it in the class to keep things
273
+	 * clean and organized.
274
+	 *
275
+	 * @see $this->prepare_items()
276
+	 **************************************************************************/
277 277
 	function process_bulk_action() {
278 278
 		//Detect when a bulk action is being triggered...
279 279
 		if( 'delete'===$this->current_action() ) {
@@ -282,90 +282,90 @@  discard block
 block discarded – undo
282 282
 	}
283 283
 
284 284
 	/** ************************************************************************
285
-	* REQUIRED! This is where you prepare your data for display. This method will
286
-	* usually be used to query the database, sort and filter the data, and generally
287
-	* get it ready to be displayed. At a minimum, we should set $this->items and
288
-	* $this->set_pagination_args(), although the following properties and methods
289
-	* are frequently interacted with here...
290
-	*
291
-	* @uses $this->_column_headers
292
-	* @uses $this->items
293
-	* @uses $this->get_columns()
294
-	* @uses $this->get_sortable_columns()
295
-	* @uses $this->get_pagenum()
296
-	* @uses $this->set_pagination_args()
297
-	**************************************************************************/
285
+	 * REQUIRED! This is where you prepare your data for display. This method will
286
+	 * usually be used to query the database, sort and filter the data, and generally
287
+	 * get it ready to be displayed. At a minimum, we should set $this->items and
288
+	 * $this->set_pagination_args(), although the following properties and methods
289
+	 * are frequently interacted with here...
290
+	 *
291
+	 * @uses $this->_column_headers
292
+	 * @uses $this->items
293
+	 * @uses $this->get_columns()
294
+	 * @uses $this->get_sortable_columns()
295
+	 * @uses $this->get_pagenum()
296
+	 * @uses $this->set_pagination_args()
297
+	 **************************************************************************/
298 298
 	function prepare_items() {
299 299
 		/*	First, lets decide how many records per page to show	*/
300 300
 		$per_page = 10;
301 301
 
302 302
 		/**
303
-		* REQUIRED. Now we need to define our column headers. This includes a complete
304
-		* array of columns to be displayed (slugs & titles), a list of columns
305
-		* to keep hidden, and a list of columns that are sortable. Each of these
306
-		* can be defined in another method (as we've done here) before being
307
-		* used to build the value for our _column_headers property.
308
-		*/
303
+		 * REQUIRED. Now we need to define our column headers. This includes a complete
304
+		 * array of columns to be displayed (slugs & titles), a list of columns
305
+		 * to keep hidden, and a list of columns that are sortable. Each of these
306
+		 * can be defined in another method (as we've done here) before being
307
+		 * used to build the value for our _column_headers property.
308
+		 */
309 309
 		$columns = $this->get_columns();
310 310
 		$hidden = array();
311 311
 		$sortable = $this->get_sortable_columns();
312 312
 
313 313
 		/**
314
-		* REQUIRED. Finally, we build an array to be used by the class for column
315
-		* headers. The $this->_column_headers property takes an array which contains
316
-		* 3 other arrays. One for all columns, one for hidden columns, and one
317
-		* for sortable columns.
318
-		*/
314
+		 * REQUIRED. Finally, we build an array to be used by the class for column
315
+		 * headers. The $this->_column_headers property takes an array which contains
316
+		 * 3 other arrays. One for all columns, one for hidden columns, and one
317
+		 * for sortable columns.
318
+		 */
319 319
 		$this->_column_headers = array($columns, $hidden, $sortable);
320 320
 
321 321
 		/**
322
-		* Optional. You can handle your bulk actions however you see fit. In this
323
-		* case, we'll handle them within our package just to keep things clean.
324
-		*/
322
+		 * Optional. You can handle your bulk actions however you see fit. In this
323
+		 * case, we'll handle them within our package just to keep things clean.
324
+		 */
325 325
 		$this->process_bulk_action();
326 326
 
327 327
 		/**
328
-		* Instead of querying a database, we're going to fetch the example data
329
-		* property we created for use in this plugin. This makes this example
330
-		* package slightly different than one you might build on your own. In
331
-		* this example, we'll be using array manipulation to sort and paginate
332
-		* our data. In a real-world implementation, you will probably want to
333
-		* use sort and pagination data to build a custom query instead, as you'll
334
-		* be able to use your precisely-queried data immediately.
335
-		*/
328
+		 * Instead of querying a database, we're going to fetch the example data
329
+		 * property we created for use in this plugin. This makes this example
330
+		 * package slightly different than one you might build on your own. In
331
+		 * this example, we'll be using array manipulation to sort and paginate
332
+		 * our data. In a real-world implementation, you will probably want to
333
+		 * use sort and pagination data to build a custom query instead, as you'll
334
+		 * be able to use your precisely-queried data immediately.
335
+		 */
336 336
 		$data = $this->datas;
337 337
 
338 338
 		/**
339
-		* REQUIRED for pagination. Let's figure out what page the user is currently
340
-		* looking at. We'll need this later, so you should always include it in
341
-		* your own package classes.
342
-		*/
339
+		 * REQUIRED for pagination. Let's figure out what page the user is currently
340
+		 * looking at. We'll need this later, so you should always include it in
341
+		 * your own package classes.
342
+		 */
343 343
 		$current_page = $this->get_pagenum();
344 344
 
345 345
 		/**
346
-		* REQUIRED for pagination. Let's check how many items are in our data array.
347
-		* In real-world use, this would be the total number of items in your database,
348
-		* without filtering. We'll need this later, so you should always include it
349
-		* in your own package classes.
350
-		*/
346
+		 * REQUIRED for pagination. Let's check how many items are in our data array.
347
+		 * In real-world use, this would be the total number of items in your database,
348
+		 * without filtering. We'll need this later, so you should always include it
349
+		 * in your own package classes.
350
+		 */
351 351
 		$total_items = count($data);
352 352
 
353 353
 		/**
354
-		* The WP_List_Table class does not handle pagination for us, so we need
355
-		* to ensure that the data is trimmed to only the current page. We can use
356
-		* array_slice() to
357
-		*/
354
+		 * The WP_List_Table class does not handle pagination for us, so we need
355
+		 * to ensure that the data is trimmed to only the current page. We can use
356
+		 * array_slice() to
357
+		 */
358 358
 		$data = array_slice($data,(($current_page-1)*$per_page),$per_page);
359 359
 
360 360
 		/**
361
-		* REQUIRED. Now we can add our *sorted* data to the items property, where
362
-		* it can be used by the rest of the class.
363
-		*/
361
+		 * REQUIRED. Now we can add our *sorted* data to the items property, where
362
+		 * it can be used by the rest of the class.
363
+		 */
364 364
 		$this->items = $data;
365 365
 
366 366
 		/**
367
-		* REQUIRED. We also have to register our pagination options & calculations.
368
-		*/
367
+		 * REQUIRED. We also have to register our pagination options & calculations.
368
+		 */
369 369
 		$this->set_pagination_args( array(
370 370
 			'total_items' => $total_items,               		//WE have to calculate the total number of items
371 371
 			'per_page'    => $per_page,                 		//WE have to determine how many items to show on a page
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 * @package wpshop
12 12
 * @subpackage librairies
13 13
 */
14
-class wpshop_attributes_set_custom_List_table extends WP_List_Table{
14
+class wpshop_attributes_set_custom_List_table extends WP_List_Table {
15 15
 
16 16
 	var $datas;
17 17
 
@@ -19,28 +19,28 @@  discard block
 block discarded – undo
19 19
 	* REQUIRED. Set up a constructor that references the parent constructor. We
20 20
 	* use the parent reference to set some default configs.
21 21
 	***************************************************************************/
22
-	function __construct(){
22
+	function __construct() {
23 23
 		global $status, $page;
24 24
 
25 25
 		//Set parent defaults
26
-		parent::__construct( array(
27
-			'singular'  => __('attribute\'s set', 'wpshop'),    //singular name of the listed records
28
-			'plural'    => __('attributes\' set', 'wpshop'),    //plural name of the listed records
26
+		parent::__construct(array(
27
+			'singular'  => __('attribute\'s set', 'wpshop'), //singular name of the listed records
28
+			'plural'    => __('attributes\' set', 'wpshop'), //plural name of the listed records
29 29
 			'ajax'     => true       //does this table support ajax?
30
-		) );
30
+		));
31 31
 	}
32 32
 
33 33
 	/*	Allows to set different listings for attributes	*/
34
-	function get_views(){
34
+	function get_views() {
35 35
 		$wpshop_attribute_links = array();
36 36
 
37 37
 		$active_nb = wpshop_attributes_set::getElement('', "'moderated','valid'");
38 38
 		$deleted_nb = wpshop_attributes_set::getElement('', "'deleted'");
39 39
 
40
-		$attribute_group_status = !empty( $_REQUEST['attribute_groups_status'] ) ? sanitize_text_field( $_REQUEST['attribute_groups_status'] ) : '';
40
+		$attribute_group_status = !empty($_REQUEST['attribute_groups_status']) ? sanitize_text_field($_REQUEST['attribute_groups_status']) : '';
41 41
 
42
-		$wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_valid'.(empty($attribute_group_status)?' current':'')] = '<a href="'.admin_url('admin.php?page='.wpshop_attributes_set::getEditionSlug()).'" >'.__('Attribute groups', 'wpshop').' ('.count($active_nb).')</a>';
43
-		$wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_deleted'.(!empty($attribute_group_status) && ($attribute_group_status=='deleted')?' current':'')] = '<a href="'.admin_url('admin.php?page='.wpshop_attributes_set::getEditionSlug().'&attribute_groups_status=deleted').'" >'.__('Trashed attribute groups', 'wpshop').' ('.count($deleted_nb).')</a>';
42
+		$wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_valid' . (empty($attribute_group_status) ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . wpshop_attributes_set::getEditionSlug()) . '" >' . __('Attribute groups', 'wpshop') . ' (' . count($active_nb) . ')</a>';
43
+		$wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_deleted' . (!empty($attribute_group_status) && ($attribute_group_status == 'deleted') ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . wpshop_attributes_set::getEditionSlug() . '&attribute_groups_status=deleted') . '" >' . __('Trashed attribute groups', 'wpshop') . ' (' . count($deleted_nb) . ')</a>';
44 44
 
45 45
 		return $wpshop_attribute_links;
46 46
 	}
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 	* @see WP_List_Table::::single_row_columns()
59 59
 	* @return array An associative array containing column information: 'slugs'=>'Visible Titles'
60 60
 	**************************************************************************/
61
-	function get_columns(){
61
+	function get_columns() {
62 62
 		$columns = array(
63
-			'cb'       => '',//'<input type="checkbox" />', //Render a checkbox instead of text
63
+			'cb'       => '', //'<input type="checkbox" />', //Render a checkbox instead of text
64 64
 			'id'       => 'Id.',
65 65
 			'name'    => 'Nom',
66 66
 			'status'    => 'Statut',
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 	* @param array $column_name The name/slug of the column to be processed
92 92
 	* @return string Text or HTML to be placed inside the column <td>
93 93
 	**************************************************************************/
94
-	function column_default($item, $column_name){
95
-		switch($column_name){
94
+	function column_default($item, $column_name) {
95
+		switch ($column_name) {
96 96
 			default:
97
-				return print_r($item,true); //Show the whole array for troubleshooting purposes
97
+				return print_r($item, true); //Show the whole array for troubleshooting purposes
98 98
 		}
99 99
 	}
100 100
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	* @param array $item A singular item (one full row's worth of data)
115 115
 	* @return string Text to be placed inside the column <td> (movie title only)
116 116
 	**************************************************************************/
117
-	function column_id($item){
117
+	function column_id($item) {
118 118
 		return $item['id'];
119 119
 	}
120 120
 	/** ************************************************************************
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	* @param array $item A singular item (one full row's worth of data)
134 134
 	* @return string Text to be placed inside the column <td> (movie title only)
135 135
 	**************************************************************************/
136
-	function column_status($item){
136
+	function column_status($item) {
137 137
 		return __($item['status'], 'wpshop');
138 138
 	}
139 139
 	/** ************************************************************************
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	* @param array $item A singular item (one full row's worth of data)
153 153
 	* @return string Text to be placed inside the column <td> (movie title only)
154 154
 	**************************************************************************/
155
-	function column_content($item){
155
+	function column_content($item) {
156 156
 		return $item['content'];
157 157
 	}
158 158
 	/** ************************************************************************
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	* @param array $item A singular item (one full row's worth of data)
172 172
 	* @return string Text to be placed inside the column <td> (movie title only)
173 173
 	**************************************************************************/
174
-	function column_entity($item){
175
-		return __($item['entity'],'wpshop');
174
+	function column_entity($item) {
175
+		return __($item['entity'], 'wpshop');
176 176
 	}
177 177
 	/** ************************************************************************
178 178
 	* Recommended. This is a custom column method and is responsible for what
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
 	* @param array $item A singular item (one full row's worth of data)
191 191
 	* @return string Text to be placed inside the column <td> (movie title only)
192 192
 	**************************************************************************/
193
-	function column_name($item){
193
+	function column_name($item) {
194 194
 		//Build row actions
195
-		$default_action='edit';
196
-		$default_action_text=__('Edit', 'wpshop');
197
-		$attribute_groups_status = !empty( $_REQUEST['attribute_groups_status'] ) ? sanitize_text_field( $_REQUEST['attribute_groups_status'] ) : '';
198
-		if( !empty( $attribute_groups_status ) && ( $attribute_groups_status=='deleted' ) ){
199
-			$default_action='activate';
200
-			$default_action_text=__('Restore', 'wpshop');
195
+		$default_action = 'edit';
196
+		$default_action_text = __('Edit', 'wpshop');
197
+		$attribute_groups_status = !empty($_REQUEST['attribute_groups_status']) ? sanitize_text_field($_REQUEST['attribute_groups_status']) : '';
198
+		if (!empty($attribute_groups_status) && ($attribute_groups_status == 'deleted')) {
199
+			$default_action = 'activate';
200
+			$default_action_text = __('Restore', 'wpshop');
201 201
 		}
202
-		$actions['edit']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s">'.$default_action_text.'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,$default_action,$item['id']);
202
+		$actions['edit'] = sprintf('<a href="' . admin_url('admin.php') . '?page=%2$s&amp;action=%3$s&amp;id=%4$s">' . $default_action_text . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING, $default_action, $item['id']);
203 203
 
204 204
 		if (empty($attribute_groups_status))
205
-			$actions['delete']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'delete',$item['id']);
205
+			$actions['delete'] = sprintf('<a href="' . admin_url('admin.php') . '?page=%2$s&amp;action=%3$s&amp;id=%4$s">' . __('Delete', 'wpshop') . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING, 'delete', $item['id']);
206 206
 
207 207
 		//Return the title contents
208 208
 		return sprintf('%1$s%2$s',
209
-			/*$1%s*/ sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s">'.__($item['name'], 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'edit',$item['id']),
209
+			/*$1%s*/ sprintf('<a href="' . admin_url('admin.php') . '?page=%2$s&amp;action=%3$s&amp;id=%4$s">' . __($item['name'], 'wpshop') . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING, 'edit', $item['id']),
210 210
 			/*$3%s*/ $this->row_actions($actions)
211 211
 		);
212 212
 	}
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
 	* @param array $item A singular item (one full row's worth of data)
220 220
 	* @return string Text to be placed inside the column <td> (movie title only)
221 221
 	**************************************************************************/
222
-	function column_cb($item){
222
+	function column_cb($item) {
223 223
 		return '';
224 224
 		return sprintf(
225 225
 			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
226
-			/*$1%s*/ $this->_args['singular'],  //Let's simply repurpose the table's singular label ("movie")
226
+			/*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie")
227 227
 			/*$2%s*/ $item['id']             //The value of the checkbox should be the record's id
228 228
 		);
229 229
 	}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	**************************************************************************/
280 280
 	function process_bulk_action() {
281 281
 		//Detect when a bulk action is being triggered...
282
-		if( 'delete'===$this->current_action() ) {
282
+		if ('delete' === $this->current_action()) {
283 283
 			wp_die('Items deleted (or they would be if we had items to delete)!');
284 284
 		}
285 285
 	}
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 		* to ensure that the data is trimmed to only the current page. We can use
359 359
 		* array_slice() to
360 360
 		*/
361
-		$data = array_slice($data,(($current_page-1)*$per_page),$per_page);
361
+		$data = array_slice($data, (($current_page - 1) * $per_page), $per_page);
362 362
 
363 363
 		/**
364 364
 		* REQUIRED. Now we can add our *sorted* data to the items property, where
@@ -369,11 +369,11 @@  discard block
 block discarded – undo
369 369
 		/**
370 370
 		* REQUIRED. We also have to register our pagination options & calculations.
371 371
 		*/
372
-		$this->set_pagination_args( array(
373
-			'total_items' => $total_items,               		//WE have to calculate the total number of items
374
-			'per_page'    => $per_page,                 		//WE have to determine how many items to show on a page
375
-			'total_pages' => ceil($total_items/$per_page)   //WE have to calculate the total number of pages
376
-		) );
372
+		$this->set_pagination_args(array(
373
+			'total_items' => $total_items, //WE have to calculate the total number of items
374
+			'per_page'    => $per_page, //WE have to determine how many items to show on a page
375
+			'total_pages' => ceil($total_items / $per_page)   //WE have to calculate the total number of pages
376
+		));
377 377
 	}
378 378
 
379 379
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -201,8 +203,9 @@  discard block
 block discarded – undo
201 203
 		}
202 204
 		$actions['edit']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s">'.$default_action_text.'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,$default_action,$item['id']);
203 205
 
204
-		if (empty($attribute_groups_status))
205
-			$actions['delete']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'delete',$item['id']);
206
+		if (empty($attribute_groups_status)) {
207
+					$actions['delete']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'delete',$item['id']);
208
+		}
206 209
 
207 210
 		//Return the title contents
208 211
 		return sprintf('%1$s%2$s',
Please login to merge, or discard this patch.
includes/librairies/eav/attributes.class.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1423,7 +1423,7 @@
 block discarded – undo
1423 1423
 	 *	@param string $attributeType The extension of the database table to get the attribute value in
1424 1424
 	 *	@param integer $attributeId The attribute identifier we want to get the value for
1425 1425
 	 *	@param integer $entityTypeId The entity type identifier we want to get the attribute value for (example: product = 1)
1426
-	 	*	@param integer $entityId The entity id we want the attribute value for
1426
+	 *	@param integer $entityId The entity id we want the attribute value for
1427 1427
 	 *
1428 1428
 	 *	@return object $attributeValue A wordpress database object containing the value of the attribute for the selected entity
1429 1429
 	 */
Please login to merge, or discard this patch.
Doc Comments   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,6 +46,7 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 *	Get the url listing slug of the current class
48 48
 	 *
49
+	 *	@param string $message
49 50
 	 *	@return string The table of the class
50 51
 	 */
51 52
 	function setMessage($message){
@@ -1244,7 +1245,7 @@  discard block
 block discarded – undo
1244 1245
 	 *
1245 1246
 	 *	@param integer $element_id optionnal The attribute identifier we want to get. If not specify the entire list will be returned
1246 1247
 	 *	@param string $element_status optionnal The status of element to get into database. Default is set to valid element
1247
-	 *	@param mixed $field_to_search optionnal The field we want to check the row identifier into. Default is to set id
1248
+	 *	@param string $field_to_search optionnal The field we want to check the row identifier into. Default is to set id
1248 1249
 	 *
1249 1250
 	 *	@return object $element_list A wordpress database object containing the attribute list
1250 1251
 	 */
@@ -1484,9 +1485,6 @@  discard block
 block discarded – undo
1484 1485
 	 *	Get the existing element list into database
1485 1486
 	 *
1486 1487
 	 *	@param integer $elementId optionnal The element identifier we want to get. If not specify the entire list will be returned
1487
-	 *	@param string $elementStatus optionnal The status of element to get into database. Default is set to valid element
1488
-	 *
1489
-	 *	@return object $elements A wordpress database object containing the element list
1490 1488
 	 */
1491 1489
 	public static function getElementWithAttributeAndValue($entityId, $elementId, $language, $keyForArray = '', $outputType = '') {
1492 1490
 		global $wpdb;
@@ -1625,7 +1623,7 @@  discard block
 block discarded – undo
1625 1623
 	/**
1626 1624
 	 * Traduit le shortcode et affiche la valeur d'un attribut donn�
1627 1625
 	 * @param array $atts : tableau de param�tre du shortcode
1628
-	 * @return mixed
1626
+	 * @return string|null
1629 1627
 	 **/
1630 1628
 	public static function wpshop_att_val_func($atts) {
1631 1629
 		global $wpdb;
@@ -1914,7 +1912,7 @@  discard block
 block discarded – undo
1914 1912
 
1915 1913
 	/**
1916 1914
 	 *
1917
-	 * @param array $attribute_list
1915
+	 * @param array $attribute_code
1918 1916
 	 * @param string $output_from
1919 1917
 	 * @return string The output for
1920 1918
 	 */
@@ -2455,6 +2453,12 @@  discard block
 block discarded – undo
2455 2453
 		return $affected_value;
2456 2454
 	}
2457 2455
 
2456
+	/**
2457
+	 * @param string $attr_code
2458
+	 * @param string $attr_option
2459
+	 *
2460
+	 * @return string
2461
+	 */
2458 2462
 	public static function get_attribute_option_output($item, $attr_code, $attr_option, $additionnal_params = '') {
2459 2463
 		switch($attr_code){
2460 2464
 			case 'is_downloadable_':
@@ -3187,7 +3191,6 @@  discard block
 block discarded – undo
3187 3191
 	 * Define the different field available for bulk edition for entities. Attributes to display are defined by checking box in attribute option
3188 3192
 	 *
3189 3193
 	 * @param string $column_name The column name for output type definition
3190
-	 * @param string $post_type The current
3191 3194
 	 *
3192 3195
 	 */
3193 3196
 	function quick_edit( $column_name, $entity ) {
@@ -3212,7 +3215,6 @@  discard block
 block discarded – undo
3212 3215
 	 * Define the different field available for bulk edition for entities. Attributes to display are defined by checking box in attribute option
3213 3216
 	 *
3214 3217
 	 * @param string $column_name The column name for output type definition
3215
-	 * @param string $post_type The current
3216 3218
 	 *
3217 3219
 	 */
3218 3220
 	public static function bulk_edit( $column_name, $entity ) {
Please login to merge, or discard this patch.
Braces   +156 added lines, -171 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -90,12 +92,12 @@  discard block
 block discarded – undo
90 92
 			if(($action == 'edit') || ($action == 'delete')){
91 93
 				$editedItem = self::getElement($objectInEdition);
92 94
 				$title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label));
95
+			} elseif($action == 'add') {
96
+							$title = __(self::pageAddingTitle, 'wpshop');
93 97
 			}
94
-			elseif($action == 'add')
95
-				$title = __(self::pageAddingTitle, 'wpshop');
98
+		} elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())) {
99
+					$title = __(self::pageAddingTitle, 'wpshop');
96 100
 		}
97
-		elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug()))
98
-			$title = __(self::pageAddingTitle, 'wpshop');
99 101
 
100 102
 		return $title;
101 103
 	}
@@ -126,14 +128,15 @@  discard block
 block discarded – undo
126 128
 		if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){
127 129
 			$editedElement = self::getElement($saveditem);
128 130
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>');
129
-		}
130
-		elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){
131
+		} elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){
131 132
 			$editedElement = self::getElement($saveditem, "'deleted'");
132 133
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>');
133 134
 		}
134 135
 
135 136
 		$attribute_parameter = !empty( $_REQUEST[self::getDbTable()] ) ? (array)$_REQUEST[self::getDbTable()] : array();
136
-		 if ( !empty($set_section) ) unset($attribute_parameter['set_section']);
137
+		 if ( !empty($set_section) ) {
138
+		 	unset($attribute_parameter['set_section']);
139
+		 }
137 140
 
138 141
 		$wpshop_attribute_combo_values_list_order_def = !empty($attribute_parameter['wpshop_attribute_combo_values_list_order_def']) ? $attribute_parameter['wpshop_attribute_combo_values_list_order_def'] : array();
139 142
 		// @TODO $_REQUEST
@@ -193,66 +196,82 @@  discard block
 block discarded – undo
193 196
 			switch ($attribute_parameter['frontend_input']) {
194 197
 				case 'short_text':
195 198
 						$attribute_parameter['frontend_input'] = 'text';
196
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
199
+						if ( empty($attribute_parameter['backend_input']) ) {
200
+							$attribute_parameter['backend_input'] = 'text';
201
+						}
197 202
 						$attribute_parameter['data_type'] = 'varchar';
198 203
 					break;
199 204
 				case 'date_field':
200 205
 						$attribute_parameter['frontend_input'] = 'text';
201
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
206
+						if ( empty($attribute_parameter['backend_input']) ) {
207
+							$attribute_parameter['backend_input'] = 'text';
208
+						}
202 209
 						$attribute_parameter['data_type'] = 'datetime';
203 210
 					break;
204 211
 				case 'float_field':
205 212
 						$attribute_parameter['frontend_input'] = 'text';
206
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
213
+						if ( empty($attribute_parameter['backend_input']) ) {
214
+							$attribute_parameter['backend_input'] = 'text';
215
+						}
207 216
 						$attribute_parameter['data_type'] = 'decimal';
208 217
 					break;
209 218
 				case 'hidden_field':
210 219
 						$attribute_parameter['frontend_input'] = 'hidden';
211
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
220
+						if ( empty($attribute_parameter['backend_input']) ) {
221
+							$attribute_parameter['backend_input'] = 'text';
222
+						}
212 223
 						$attribute_parameter['data_type'] = 'varchar';
213 224
 					break;
214 225
 				case 'pass_field':
215 226
 						$attribute_parameter['frontend_input'] = 'password';
216
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
227
+						if ( empty($attribute_parameter['backend_input']) ) {
228
+							$attribute_parameter['backend_input'] = 'text';
229
+						}
217 230
 						$attribute_parameter['data_type'] = 'varchar';
218 231
 					break;
219 232
 
220 233
 				case 'select':
221 234
 						$attribute_parameter['frontend_input'] = 'select';
222
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
223
-							$attribute_parameter['backend_input'] = 'multiple-select';
235
+						if ( empty($attribute_parameter['backend_input']) || empty($id) ) {
236
+													$attribute_parameter['backend_input'] = 'multiple-select';
237
+						}
224 238
 						$attribute_parameter['data_type'] = 'integer';
225 239
 					break;
226 240
 				case 'multiple-select':
227 241
 						$attribute_parameter['frontend_input'] = 'multiple-select';
228
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
229
-							$attribute_parameter['backend_input'] = 'multiple-select';
242
+						if ( empty($attribute_parameter['backend_input']) || empty($id) ) {
243
+													$attribute_parameter['backend_input'] = 'multiple-select';
244
+						}
230 245
 						$attribute_parameter['data_type'] = 'integer';
231 246
 					break;
232 247
 				case 'radio':
233 248
 						$attribute_parameter['frontend_input'] = 'radio';
234
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
235
-							$attribute_parameter['backend_input'] = 'multiple-select';
249
+						if ( empty($attribute_parameter['backend_input']) || empty($id) ) {
250
+													$attribute_parameter['backend_input'] = 'multiple-select';
251
+						}
236 252
 						$attribute_parameter['data_type'] = 'integer';
237 253
 					break;
238 254
 				case 'checkbox':
239 255
 						$attribute_parameter['frontend_input'] = 'checkbox';
240
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
241
-							$attribute_parameter['backend_input'] = 'multiple-select';
256
+						if ( empty($attribute_parameter['backend_input']) || empty($id) ) {
257
+													$attribute_parameter['backend_input'] = 'multiple-select';
258
+						}
242 259
 						$attribute_parameter['data_type'] = 'integer';
243 260
 					break;
244 261
 
245 262
 				case 'textarea':
246 263
 						$attribute_parameter['frontend_input'] = 'textarea';
247
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
248
-							$attribute_parameter['backend_input'] = 'textarea';
264
+						if ( empty($attribute_parameter['backend_input']) || empty($id) ) {
265
+													$attribute_parameter['backend_input'] = 'textarea';
266
+						}
249 267
 						$attribute_parameter['data_type'] = 'text';
250 268
 					break;
251 269
 			}
252
-		}
253
-		else {
270
+		} else {
254 271
 			$attribute_parameter['frontend_input'] = 'text';
255
-			if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
272
+			if ( empty($attribute_parameter['backend_input']) ) {
273
+				$attribute_parameter['backend_input'] = 'text';
274
+			}
256 275
 			$attribute_parameter['data_type'] = 'varchar';
257 276
 		}
258 277
 
@@ -287,22 +306,18 @@  discard block
 block discarded – undo
287 306
 					if(!in_array($attribute_code, $attribute_undeletable)){
288 307
 						if(current_user_can('wpshop_delete_attributes')){
289 308
 							$attribute_parameter['status'] = 'deleted';
290
-						}
291
-						else{
309
+						} else{
292 310
 							$actionResult = 'userNotAllowedForActionDelete';
293 311
 						}
294
-					}
295
-					else{
312
+					} else{
296 313
 						$actionResult = 'unDeletableAtribute';
297 314
 					}
298 315
 				}
299 316
 				$actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable());
300
-			}
301
-			else{
317
+			} else{
302 318
 				$actionResult = 'userNotAllowedForActionEdit';
303 319
 			}
304
-		}
305
-		elseif(($pageAction != '') && (($pageAction == 'delete'))){
320
+		} elseif(($pageAction != '') && (($pageAction == 'delete'))){
306 321
 			$attribute_code = '';
307 322
 			if (empty(	$attribute_parameter['code'])) {
308 323
 				$attribute = self::getElement($id, "'valid', 'moderated', 'notused', 'deleted'", 'id');
@@ -313,14 +328,13 @@  discard block
 block discarded – undo
313 328
 					$attribute_parameter['last_update_date'] = current_time('mysql', 0);
314 329
 					$attribute_parameter['status'] = 'deleted';
315 330
 					$actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable());
331
+				} else {
332
+									$actionResult = 'userNotAllowedForActionDelete';
316 333
 				}
317
-				else
318
-					$actionResult = 'userNotAllowedForActionDelete';
334
+			} else {
335
+							$actionResult = 'unDeletableAtribute';
319 336
 			}
320
-			else
321
-				$actionResult = 'unDeletableAtribute';
322
-		}
323
-		elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){
337
+		} elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){
324 338
 			if(current_user_can('wpshop_add_attributes')){
325 339
 				$attribute_parameter['creation_date'] = current_time('mysql', 0);
326 340
 				if(trim($attribute_parameter['code']) == ''){
@@ -333,8 +347,7 @@  discard block
 block discarded – undo
333 347
 				}
334 348
 				$actionResult = wpshop_database::save($attribute_parameter, self::getDbTable());
335 349
 				$id = $wpdb->insert_id;
336
-			}
337
-			else{
350
+			} else{
338 351
 				$actionResult = 'userNotAllowedForActionAdd';
339 352
 			}
340 353
 		}
@@ -345,11 +358,12 @@  discard block
 block discarded – undo
345 358
 		/****************************************************************************/
346 359
 		if($actionResult != ''){
347 360
 			$elementIdentifierForMessage = __('the attribute', 'wpshop');
348
-			if(!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>';
361
+			if(!empty($attribute_parameter['name'])) {
362
+				$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>';
363
+			}
349 364
 			if ($actionResult == 'error') {/*	CHANGE HERE FOR SPECIFIC CASE	*/
350 365
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage, ' -> ' . $wpdb->last_error);
351
-			}
352
-			else if (($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) {/*	CHANGE HERE FOR SPECIFIC CASE	*/
366
+			} else if (($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) {/*	CHANGE HERE FOR SPECIFIC CASE	*/
353 367
 				/*****************************************************************************************************************/
354 368
 				/*************************			CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT				****************************/
355 369
 				/*****************************************************************************************************************/
@@ -368,8 +382,7 @@  discard block
 block discarded – undo
368 382
 					if (empty($attribute_parameter['code'])) {
369 383
 						$attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id');
370 384
 						$attribute_code = $attribute->code;
371
-					}
372
-					else {
385
+					} else {
373 386
 						$attribute_code = $attribute_parameter['code'];
374 387
 					}
375 388
 					foreach ($optionsUpdate as $option_key => $option_label) {
@@ -460,8 +473,7 @@  discard block
 block discarded – undo
460 473
 						$choosen_set_section = explode('_', $set_section);
461 474
 						$set_id = $choosen_set_section[0];
462 475
 						$group_id = $choosen_set_section[1];
463
-					}
464
-					else{
476
+					} else{
465 477
 						$attribute_current_attribute_set = 0;
466 478
 						$query = $wpdb->prepare("
467 479
 								SELECT id
@@ -509,7 +521,9 @@  discard block
 block discarded – undo
509 521
 								$attribute_parameter['entity_id']
510 522
 						);
511 523
 						$wpshopAttributePosition = $wpdb->get_var($query);
512
-						if($wpshopAttributePosition == 0)$wpshopAttributePosition = 1;
524
+						if($wpshopAttributePosition == 0) {
525
+							$wpshopAttributePosition = 1;
526
+						}
513 527
 						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $attribute_parameter['entity_id'], 'attribute_set_id' => $set_id, 'attribute_group_id' => $group_id, 'attribute_id' => $id, 'position' => $wpshopAttributePosition));
514 528
 					}
515 529
 				}
@@ -530,15 +544,14 @@  discard block
 block discarded – undo
530 544
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id));
531 545
 				}
532 546
 				else */
533
-				if ( $pageAction == 'add' )
534
-					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id));
535
-				elseif ( $pageAction == 'delete' )
536
-					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id));
537
-			}
538
-			elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')){
547
+				if ( $pageAction == 'add' ) {
548
+									wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id));
549
+				} elseif ( $pageAction == 'delete' ) {
550
+									wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id));
551
+				}
552
+			} elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')){
539 553
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop');
540
-			}
541
-			elseif(($actionResult == 'unDeletableAtribute')){
554
+			} elseif(($actionResult == 'unDeletableAtribute')){
542 555
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('This attribute could not be deleted due to configuration', 'wpshop');
543 556
 			}
544 557
 
@@ -583,8 +596,7 @@  discard block
 block discarded – undo
583 596
 		if ( !empty($s) ) {
584 597
 			$query = $wpdb->prepare("SELECT * FROM " . self::dbTable . ' WHERE frontend_label LIKE "%%%1$s%%" OR frontend_label LIKE "%%%2$s%%" AND backend_label LIKE "%%%1$s%%" OR backend_label LIKE "%%%2$s%%" AND code LIKE "%%%1$s%%" OR code LIKE "%%%2$s%%"', $s, __($s, 'wpshop') );
585 598
 			$attr_set_list = $wpdb->get_results( $query );
586
-		}
587
-		else {
599
+		} else {
588 600
 			$attr_set_list = self::getElement( '', $status );
589 601
 		}
590 602
 		$i=0;
@@ -638,8 +650,9 @@  discard block
 block discarded – undo
638 650
 		global $attribute_displayed_field, $attribute_options_group;
639 651
 		$dbFieldList = wpshop_database::fields_to_input(self::getDbTable());
640 652
 		$editedItem = '';
641
-		if($itemToEdit != '')
642
-			$editedItem = self::getElement($itemToEdit);
653
+		if($itemToEdit != '') {
654
+					$editedItem = self::getElement($itemToEdit);
655
+		}
643 656
 
644 657
 		$the_form_content_hidden = $the_form_general_content = '';
645 658
 		$the_form_option_content_list = array();
@@ -652,10 +665,11 @@  discard block
 block discarded – undo
652 665
 				$pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : '';
653 666
 				$requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['label']]) ? sanitize_text_field($_REQUEST[self::currentPageCode][$input_def['label']]) : '';
654 667
 				$currentFieldValue = $input_def['value'];
655
-				if(is_object($editedItem))
656
-					$currentFieldValue = $editedItem->{$input_def['label']};
657
-				elseif(($pageAction != '') && ($requestFormValue != ''))
658
-					$currentFieldValue = $requestFormValue;
668
+				if(is_object($editedItem)) {
669
+									$currentFieldValue = $editedItem->{$input_def['label']};
670
+				} elseif(($pageAction != '') && ($requestFormValue != '')) {
671
+									$currentFieldValue = $requestFormValue;
672
+				}
659 673
 
660 674
 				if($input_def['label'] == 'status'){
661 675
 					if(in_array('notused', $input_def['possible_value'])){
@@ -727,9 +741,9 @@  discard block
 block discarded – undo
727 741
 				}
728 742
 
729 743
 				$input_def['value'] = $currentFieldValue;
730
-				if($input_def['label'] == 'code')
731
-					$input_def['type'] = 'hidden';
732
-				elseif($input_def['label'] == 'entity_id'){
744
+				if($input_def['label'] == 'code') {
745
+									$input_def['type'] = 'hidden';
746
+				} elseif($input_def['label'] == 'entity_id'){
733 747
 					$input_def['possible_value'] = wpshop_entities::get_entities_list();
734 748
 					$input_def['valueToPut'] = 'index';
735 749
 					$input_def['type'] = 'select';
@@ -741,21 +755,17 @@  discard block
 block discarded – undo
741 755
 						}
742 756
 						$i++;
743 757
 					}
744
-				}
745
-				elseif($input_def['label'] == '_unit_group_id'){
758
+				} elseif($input_def['label'] == '_unit_group_id'){
746 759
 					$input_def['possible_value'] = wpshop_attributes_unit::get_unit_group();
747 760
 					$input_def['type'] = 'select';
748
-				}
749
-				elseif($input_def['label'] == '_default_unit'){
761
+				} elseif($input_def['label'] == '_default_unit'){
750 762
 					$unit_group_list = wpshop_attributes_unit::get_unit_group();
751 763
 					$input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group(!empty($editedItem->_unit_group_id)?$editedItem->_unit_group_id:(!empty($unit_group_list)?$unit_group_list[0]->id:''));
752 764
 					$input_def['type'] = 'select';
753
-				}
754
-				elseif ($input_def['label'] == 'backend_input') {
765
+				} elseif ($input_def['label'] == 'backend_input') {
755 766
 					if ( !is_object($editedItem) ) {
756 767
 						$input_def['type'] = 'hidden';
757
-					}
758
-					else {
768
+					} else {
759 769
 						$new_possible_value = array();
760 770
 						switch ( $editedItem->data_type) {
761 771
 							case 'integer':
@@ -789,8 +799,7 @@  discard block
 block discarded – undo
789 799
 						}
790 800
 						$input_def['possible_value'] = $new_possible_value;
791 801
 					}
792
-				}
793
-				elseif ($input_def['label'] == 'frontend_input') {
802
+				} elseif ($input_def['label'] == 'frontend_input') {
794 803
 					$new_possible_value = array();
795 804
 
796 805
 					if ( is_object($editedItem) ) {
@@ -824,8 +833,7 @@  discard block
 block discarded – undo
824 833
 									$new_possible_value[__('Date field', 'wpshop')] = 'date_field';
825 834
 								break;
826 835
 						}
827
-					}
828
-					else {
836
+					} else {
829 837
 						$new_possible_value[__('Text field', 'wpshop')] = 'short_text';
830 838
 						$new_possible_value[__('Number field', 'wpshop')] = 'float_field';
831 839
 						$new_possible_value[__('Date field', 'wpshop')] = 'date_field';
@@ -917,8 +925,7 @@  discard block
 block discarded – undo
917 925
 								$the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
918 926
 							break;
919 927
 						}
920
-					}
921
-					else {
928
+					} else {
922 929
 						$input_def['type']='text';
923 930
 						$the_input = wpshop_form::check_input_type($input_def, self::getDbTable());
924 931
 					}
@@ -945,9 +952,9 @@  discard block
 block discarded – undo
945 952
 			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_def['name'].'" ><label for="'.$input_def_id.'" >' . __($input_def['label'], 'wpshop') . '</label></td>
946 953
 			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_def['name'].'" >' . $the_input . '</td>
947 954
 		</tr>';
948
-					if ( (substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize( WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS )) )
949
-						$the_form_option_content_list[$input_def['label']] = $input;
950
-					else {
955
+					if ( (substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize( WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS )) ) {
956
+											$the_form_option_content_list[$input_def['label']] = $input;
957
+					} else {
951 958
 						$the_form_general_content .= $input;
952 959
 						if ( ($input_def['label'] == 'frontend_input') && !is_object($editedItem) ) {
953 960
 
@@ -961,8 +968,7 @@  discard block
 block discarded – undo
961 968
 							$the_form_general_content .= $input;
962 969
 						}
963 970
 					}
964
-				}
965
-				else{
971
+				} else{
966 972
 					$the_form_content_hidden .= '
967 973
 				' . $the_input;
968 974
 				}
@@ -1247,17 +1253,18 @@  discard block
 block discarded – undo
1247 1253
 
1248 1254
 		 //$currentPageButton .= '<h2 class="cancelButton alignleft" ><a href="' . admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&amp;page=' . self::getListingSlug()) . '" class="button add-new-h2" >' . __('Back', 'wpshop') . '</a></h2>';
1249 1255
 
1250
-		if(($action == 'add') && (current_user_can('wpshop_add_attributes')))
1251
-			$currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />';
1252
-
1253
-		elseif(current_user_can('wpshop_edit_attributes'))
1254
-		$currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />';
1256
+		if(($action == 'add') && (current_user_can('wpshop_add_attributes'))) {
1257
+					$currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />';
1258
+		} elseif(current_user_can('wpshop_edit_attributes')) {
1259
+				$currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />';
1260
+		}
1255 1261
 
1256 1262
 		$attribute_undeletable = unserialize(WPSHOP_ATTRIBUTE_UNDELETABLE);
1257 1263
 		$attribute = self::getElement($element_id, "'valid', 'moderated', 'notused'", 'id');
1258 1264
 		$attribute_code = !empty($attribute->code)?$attribute->code:'';
1259
-		if(current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable))
1260
-			$currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
1265
+		if(current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable)) {
1266
+					$currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
1267
+		}
1261 1268
 
1262 1269
 		return $currentPageButton;
1263 1270
 	}
@@ -1302,8 +1309,7 @@  discard block
 block discarded – undo
1302 1309
 		/*	Get the query result regarding on the function parameters. If there must be only one result or a collection	*/
1303 1310
 		if(($element_id == '') || $list){
1304 1311
 			$element_list = $wpdb->get_results($query);
1305
-		}
1306
-		else{
1312
+		} else{
1307 1313
 			$element_list = $wpdb->get_row($query);
1308 1314
 		}
1309 1315
 
@@ -1397,8 +1403,7 @@  discard block
 block discarded – undo
1397 1403
 										foreach($attributeValue as $a){
1398 1404
 											$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $a)));
1399 1405
 										}
1400
-									}
1401
-									else{
1406
+									} else{
1402 1407
 										$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $attributeValue)));
1403 1408
 										wpeologs_ctr::log_datas_in_files( 'wpshop_attributes', array(
1404 1409
 											'object_id' 	=> $entityId,
@@ -1417,8 +1422,10 @@  discard block
 block discarded – undo
1417 1422
 										$value = self::get_attribute_type_select_option_info($attributeTypeDetails[$attribute_code], 'value');
1418 1423
 										if (strtolower($value) == 'yes') :
1419 1424
 											update_post_meta($entityId, 'attribute_option_'.$attribute_code, $attribute_option);
1420
-										else :
1425
+										else {
1426
+											:
1421 1427
 											delete_post_meta($entityId, 'attribute_option_'.$attribute_code);
1428
+										}
1422 1429
 										endif;
1423 1430
 									}
1424 1431
 								}
@@ -1478,8 +1485,7 @@  discard block
 block discarded – undo
1478 1485
 
1479 1486
 		if ( ( (count($attributeValue) <= 1 ) && !empty($attributeValue[0]) ) && ( empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select') )) {
1480 1487
 			$attributeValue = $attributeValue[0];
1481
-		}
1482
-		else{
1488
+		} else{
1483 1489
 			$entity_meta = get_post_meta($entityId, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true);
1484 1490
 			if ( !empty($entity_meta) ) {
1485 1491
 				$query = $wpdb->prepare("SELECT code FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE id = %d AND entity_id = %d ", $attributeId, $entityTypeId);
@@ -1545,12 +1551,10 @@  discard block
 block discarded – undo
1545 1551
 			if ( !empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value']) ) {
1546 1552
 				if (is_array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) {
1547 1553
 					$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'][] = $elementDefinition->$attributeValueField;
1548
-				}
1549
-				else {
1554
+				} else {
1550 1555
 					$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'],$elementDefinition->$attributeValueField);
1551 1556
 				}
1552
-			}
1553
-			else {
1557
+			} else {
1554 1558
 				$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = $elementDefinition->$attributeValueField;
1555 1559
 			}
1556 1560
 
@@ -1631,17 +1635,14 @@  discard block
 block discarded – undo
1631 1635
 			if ( ( is_array($attribute_custom_config) && in_array($attribute_or_set, array('attribute', 'attribute_set_section', 'product_action_button')) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes' )
1632 1636
 				 || empty($attribute_custom_config) ) {
1633 1637
 				$attribute_output = true;
1634
-			}
1635
-			else if ( empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no')) )  {
1638
+			} else if ( empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no')) )  {
1636 1639
 				$attribute_output = false;
1637 1640
 			}
1638
-		}
1639
-		elseif ( $attribute_main_config === 'no' ) {
1641
+		} elseif ( $attribute_main_config === 'no' ) {
1640 1642
 			$attribute_output = false;
1641 1643
 			if ( empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code]) ) {
1642 1644
 				$attribute_output = false;
1643
-			}
1644
-			else if ( !empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes') )  {
1645
+			} else if ( !empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes') )  {
1645 1646
 				$attribute_output = true;
1646 1647
 			}
1647 1648
 		}
@@ -1659,7 +1660,9 @@  discard block
 block discarded – undo
1659 1660
 		global $wp_query;
1660 1661
 
1661 1662
 		$attribute = self::getElement( $atts['attid'] );
1662
-		if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID;
1663
+		if(empty($atts['pid'])) {
1664
+			$atts['pid'] = $wp_query->posts[0]->ID;
1665
+		}
1663 1666
 		$attribute_main_config = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing;
1664 1667
 		$output_type = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? 'complete_sheet' : 'mini_output';
1665 1668
 		$product_attribute_custom_config = get_post_meta($atts['pid'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, true);
@@ -1678,13 +1681,11 @@  discard block
 block discarded – undo
1678 1681
 					}
1679 1682
 					$has_value = true;
1680 1683
 				}
1681
-			}
1682
-			else {
1684
+			} else {
1683 1685
 				$data = $wpdb->get_var($query);
1684 1686
 				if ( !empty($data) ) {
1685 1687
 					$has_value = true;
1686
-				}
1687
-				elseif( !empty($attribute->default_value) ) {
1688
+				} elseif( !empty($attribute->default_value) ) {
1688 1689
 					$has_value = true;
1689 1690
 					$data = $attribute->default_value;
1690 1691
 				}
@@ -1744,11 +1745,9 @@  discard block
 block discarded – undo
1744 1745
 
1745 1746
 		if ( !empty($attribute_value) && !is_object($attribute_value) ) {
1746 1747
 			$input_def['value'] = $attribute_value;
1747
-		}
1748
-		else if ( !empty($attribute_value->value) ) {
1748
+		} else if ( !empty($attribute_value->value) ) {
1749 1749
 			$input_def['value'] = stripslashes($attribute_value->value);
1750
-		}
1751
-		else if ( !empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft') ) {
1750
+		} else if ( !empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft') ) {
1752 1751
 			$input_def['value'] = '';
1753 1752
 		}
1754 1753
 
@@ -1758,8 +1757,7 @@  discard block
 block discarded – undo
1758 1757
 			$date_config = unserialize( $attribute->default_value );
1759 1758
 			if ((($date_config['default_value'] == '') || ($date_config['default_value'] == 'date_of_current_day')) && ($date_config['default_value'] == 'date_of_current_day')) {
1760 1759
 				$input_def['value'] = date('Y-m-d');
1761
-			}
1762
-			else {
1760
+			} else {
1763 1761
 				/**	Modification due to a message on eoxia forum: http://www.eoxia.com/forums/topic/bug-attribut-de-type-date-dans-fiche-produit-admin/	*/
1764 1762
 				$input_def['value'] = !empty($attribute_value->value) && is_string($attribute_value->value) ? str_replace( " 00:00:00", "", $attribute_value->value ) : ( !empty($attribute_value) && is_string($attribute_value) ? str_replace( " 00:00:00", "", $attribute_value ) : '' );
1765 1763
 			}
@@ -1864,8 +1862,7 @@  discard block
 block discarded – undo
1864 1862
 		if((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC) ){
1865 1863
 			$input_def['option'] .= ' readonly="readonly" ';
1866 1864
 			$input_more_class .= ' wpshop_prices_readonly';
1867
-		}
1868
-		elseif((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT) ){
1865
+		} elseif((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT) ){
1869 1866
 			$input_def['option'] .= ' readonly="readonly" ';
1870 1867
 			$input_more_class .= ' wpshop_prices_readonly';
1871 1868
 		}
@@ -1889,14 +1886,12 @@  discard block
 block discarded – undo
1889 1886
 		if ($attribute->is_requiring_unit == 'yes') {
1890 1887
 			if ( in_array($attribute->code, $wpshop_price_attributes) || ( WPSHOP_COST_OF_POSTAGE == $attribute->code) ) {
1891 1888
 				$input_def['options'] .= '&nbsp;<span class="attribute_currency" id="attribute_currency_' . $attribute->id . '" >' . wpshop_tools::wpshop_get_currency() . '</span>';
1892
-			}
1893
-			elseif ( in_array($attribute->code, $wpshop_weight_attributes) ) {
1889
+			} elseif ( in_array($attribute->code, $wpshop_weight_attributes) ) {
1894 1890
 				$weight_defaut_unity_option = get_option('wpshop_shop_default_weight_unity');
1895 1891
 				$query = $wpdb->prepare('SELECT name FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option);
1896 1892
 				$unity = $wpdb->get_var( $query );
1897 1893
 				$input_def['options'] .= '&nbsp;<span class="attribute_weight" id="attribute_weight_' . $attribute->id . '" >' . __($unity, 'wpshop') . '</span>';
1898
-			}
1899
-			else {
1894
+			} else {
1900 1895
 				unset($unit_input_def);
1901 1896
 				$unit_input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group($attribute->_unit_group_id);
1902 1897
 				$unit_input_def['type'] = 'select';
@@ -1907,8 +1902,7 @@  discard block
 block discarded – undo
1907 1902
 				if($unit_input_def['value'] == ''){
1908 1903
 					if ( $attribute->_default_unit > 0 ) {
1909 1904
 						$unit_input_def['value'] = $attribute->_default_unit;
1910
-					}
1911
-					else {
1905
+					} else {
1912 1906
 						$unit_input_def['value'] = wpshop_attributes_unit::get_default_unit_for_group($attribute->_unit_group_id);
1913 1907
 					}
1914 1908
 				}
@@ -1932,8 +1926,7 @@  discard block
 block discarded – undo
1932 1926
 			$input_def['label_pointer'] = '';
1933 1927
 			$input_def['option'] = substr( $input_def['option'], 0 , -2 ) . ' wpshop_attributes_is_user_defined_admin_field "';
1934 1928
 			$input_def['field_container_class'] .= 'wpshop_attributes_is_user_defined_admin_container';
1935
-		}
1936
-		else {
1929
+		} else {
1937 1930
 			$input_def['output'] = wpshop_form::check_input_type($input_def, $attributeInputDomain);
1938 1931
 		}
1939 1932
 		return $input_def;
@@ -2030,8 +2023,7 @@  discard block
 block discarded – undo
2030 2023
 					/**	Check the value type to check if empty or not	*/
2031 2024
 					if ( $attributeDefinition['data_type'] == 'int' ) {
2032 2025
 						$attributeDefinition['value'] = (int)$attributeDefinition['value'];
2033
-					}
2034
-					else if ( $attributeDefinition['data_type'] == 'decimal' ) {
2026
+					} else if ( $attributeDefinition['data_type'] == 'decimal' ) {
2035 2027
 						$attributeDefinition['value'] = (float)$attributeDefinition['value'];
2036 2028
 					}
2037 2029
 
@@ -2093,8 +2085,7 @@  discard block
 block discarded – undo
2093 2085
 						require(wpshop_display::get_template_file($tpl_way_to_take[1]));
2094 2086
 						$tab_list .= ob_get_contents();
2095 2087
 						ob_end_clean();
2096
-					}
2097
-					else {
2088
+					} else {
2098 2089
 						$tab_list .= wpshop_display::display_template_element($template_part, $tpl_component);
2099 2090
 					}
2100 2091
 					unset($tpl_component);
@@ -2113,8 +2104,7 @@  discard block
 block discarded – undo
2113 2104
 						require(wpshop_display::get_template_file($tpl_way_to_take[1]));
2114 2105
 						$content_list .= ob_get_contents();
2115 2106
 						ob_end_clean();
2116
-					}
2117
-					else {
2107
+					} else {
2118 2108
 						$content_list .= wpshop_display::display_template_element($template_part, $tpl_component);
2119 2109
 					}
2120 2110
 					unset($tpl_component);
@@ -2136,8 +2126,7 @@  discard block
 block discarded – undo
2136 2126
 					require(wpshop_display::get_template_file($tpl_way_to_take[1]));
2137 2127
 					$attributeContentOutput = ob_get_contents();
2138 2128
 					ob_end_clean();
2139
-				}
2140
-				else {
2129
+				} else {
2141 2130
 					$attributeContentOutput = wpshop_display::display_template_element($template_part, $tpl_component);
2142 2131
 				}
2143 2132
 				unset($tpl_component);
@@ -2189,8 +2178,9 @@  discard block
 block discarded – undo
2189 2178
 				foreach ($attributeDefinition['value'] as $v) {
2190 2179
 					$attribute_value .= ' / '.wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']);
2191 2180
 				}
2181
+			} else {
2182
+				$attribute_value = ' / '.wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']);
2192 2183
 			}
2193
-			else $attribute_value = ' / '.wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']);
2194 2184
 			$attribute_value = substr($attribute_value,3);
2195 2185
 		}
2196 2186
 
@@ -2272,8 +2262,7 @@  discard block
 block discarded – undo
2272 2262
 								wps_shortcodes_ctr::output_shortcode('attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])), $shortcode_code_def, 'wpshop_product_shortcode_display wpshop_product_attribute_shortcode_display wpshop_product_attribute_shortcode_display_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])).' wpshop_cls');
2273 2263
 								$shortcodes .= '<li class="wpshop_cls" >'.sprintf(__('Insertion code for the attribute %s for this product', 'wpshop'), '<span>'.__($attribute_output_def['field_definition']['label'], 'wpshop').'</span>').ob_get_contents().'</li>';
2274 2264
 								ob_end_clean();
2275
-							}
2276
-							else {
2265
+							} else {
2277 2266
 								if ( $attribute->code == 'product_attribute_set_id' ) {
2278 2267
 									$attribute_output_def['field_definition']['type'] = 'hidden';
2279 2268
 								}
@@ -2293,10 +2282,11 @@  discard block
 block discarded – undo
2293 2282
 					$attribute_group_display = sprintf(__('Insertion code for attribute group %s for this product', 'wpshop'), '<span>'.$productAttributeSetDetail['name'].'</span>').ob_get_contents().'<ul class="" >'.$shortcodes.'</ul>';
2294 2283
 					ob_end_clean();
2295 2284
 
2296
-					if( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box' )
2297
-						$currentTabContent .= '<div class="wpshop_cls" ><strong>'.__('Shortcodes','wpshop').'</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>';
2298
-					else
2299
-						$shortcodes_attr .= $attribute_group_display;
2285
+					if( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box' ) {
2286
+											$currentTabContent .= '<div class="wpshop_cls" ><strong>'.__('Shortcodes','wpshop').'</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>';
2287
+					} else {
2288
+											$shortcodes_attr .= $attribute_group_display;
2289
+					}
2300 2290
 
2301 2291
 					if ( $output_nb <= 0 ) {
2302 2292
 						$currentTabContent = __('Nothing avaiblable here. You can go in attribute management interface in order to add content here.', 'wpshop');
@@ -2311,8 +2301,7 @@  discard block
 block discarded – undo
2311 2301
 						$box['boxContent'][$productAttributeSetDetail['code']] = '
2312 2302
 			<div id="wpshop_' . $currentPageCode . '_' . wpshop_tools::slugify($productAttributeSetDetail['code'], array('noAccent')) . '_form" >' . $currentTabContent . '
2313 2303
 							</div><div class="wpshop_cls" ></div>';
2314
-					}
2315
-					else if ( $outputType == 'column' ) {
2304
+					} else if ( $outputType == 'column' ) {
2316 2305
 						$currentTabContent = str_replace('wpshop_form_input_element', 'wpshop_form_input_column', $currentTabContent);
2317 2306
 						$currentTabContent = str_replace('wpshop_form_label', 'wpshop_form_label_column', $currentTabContent);
2318 2307
 
@@ -2350,8 +2339,7 @@  discard block
 block discarded – undo
2350 2339
 							$box['box']['shortcode'] = __('Product Shortcodes', 'wpshop');
2351 2340
 							$box['boxContent']['shortcode'] = $shortcodes_attr;
2352 2341
 							$box['box']['shortcode_backend_display_type'] = WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE;
2353
-						}
2354
-						else{
2342
+						} else{
2355 2343
 							$box['columnTitle']['shortcode'] = __('Product Shortcodes', 'wpshop');
2356 2344
 							$box['columnContent']['shortcode'] = $shortcodes_attr;
2357 2345
 						}
@@ -2391,8 +2379,7 @@  discard block
 block discarded – undo
2391 2379
 //					$ouput['more_input'] .= '<input type="hidden" value="' . (WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT ? str_replace("\\", "", $option->value) : str_replace("\\", "", $option->label)) . '" name="wpshop_product_attribute_' . $attribute->code . '_value_' . $option->id . '" id="wpshop_product_attribute_' . $attribute->code . '_value_' . $option->id . '" />';
2392 2380
 // 				}
2393 2381
 			endforeach;
2394
-		}
2395
-		elseif ( $attribute->data_type_to_use == 'internal')  {
2382
+		} elseif ( $attribute->data_type_to_use == 'internal')  {
2396 2383
 			switch ($attribute_default_value) {
2397 2384
 				case 'users':
2398 2385
 					$users = get_users('orderby=nicename');
@@ -2421,9 +2408,11 @@  discard block
 block discarded – undo
2421 2408
 		/*	There is no value existing for this value	*/
2422 2409
 		if (empty($attribute_select_options_list)) :
2423 2410
 			$ouput['more_input'].=__('Nothing found for this field', 'wpshop');
2424
-		else:
2411
+		else {
2412
+			:
2425 2413
 			/*	Add a default value to the combobox list	*/
2426 2414
 			$default_value_is_serial = false;
2415
+		}
2427 2416
 			$attribute_list_first_element = $attribute->default_value;
2428 2417
 			if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) {
2429 2418
 				$default_value_is_serial = true;
@@ -2439,8 +2428,7 @@  discard block
 block discarded – undo
2439 2428
 		/*	Add a extra element to create a new element into list	*/
2440 2429
 		if ( is_admin()  && ( empty($provenance['from']) || ($provenance['from'] != 'frontend')) ) {
2441 2430
 			/**	$ouput['more_input'] .= '<img src="'.WPSHOP_MEDIAS_ICON_URL.'add.png" id="new_value_pict_' . $attribute->code . '" alt="'.__('Add a new value for this attribute', 'wpshop').'" title="'.__('Add a new value for this attribute', 'wpshop').'" class="wpshop_icons wpshop_icons_add_new_value_to_option_list wpshop_icons_add_new_value_to_option_list_'.$attribute->code.'" />';	*/
2442
-		}
2443
-		else if ( 'yes' == $attribute->is_used_in_quick_add_form ) {
2431
+		} else if ( 'yes' == $attribute->is_used_in_quick_add_form ) {
2444 2432
 			$tpl_component = array();
2445 2433
 			$tpl_component['NEW_ELEMENT_CREATION_FIELD'] = 'attribute[new_value_creation][' . $attribute->code . ']';
2446 2434
 			$ouput['more_input'] .= wpshop_display::display_template_element('quick_entity_specific_field_new_element', $tpl_component);
@@ -2462,8 +2450,7 @@  discard block
 block discarded – undo
2462 2450
 WHERE ATT.code = %s
2463 2451
 	AND ATT_SELECT_OPTIONS_VALUE.status = 'valid'
2464 2452
 GROUP BY ATT.id, chosen_val", $element_id, $attribute_code);
2465
-		}
2466
-		else {
2453
+		} else {
2467 2454
 			$query = $wpdb->prepare("
2468 2455
 SELECT P.ID AS chosen_val, P.post_title
2469 2456
 FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATT
@@ -2638,14 +2625,17 @@  discard block
 block discarded – undo
2638 2625
 		$attribute_final = array();
2639 2626
 		$entity_type = get_post_type($entityId);
2640 2627
 		$data = self::get_attribute_list_for_item( wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE);
2641
-		foreach($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type);
2628
+		foreach($data as $d) {
2629
+			$attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type);
2630
+		}
2642 2631
 
2643 2632
 		// Creation d'un array "propre" et valide pour la fonction self::saveAttributeForEntity
2644 2633
 		foreach ( $values as $key => $value ) {
2645 2634
 			if ( in_array( $key, array_keys( $attribute_available ) ) ) {
2646 2635
 				$attribute_final[$attribute_available[$key]['data_type']][$key] = $value;
2636
+			} else {
2637
+				$message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key)."\n";
2647 2638
 			}
2648
-			else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key)."\n";
2649 2639
 		}
2650 2640
 
2651 2641
 		// Pour les autres attributs non donné on leur affecte leur valeur par défaut
@@ -2715,8 +2705,7 @@  discard block
 block discarded – undo
2715 2705
 						/** Build template	*/
2716 2706
 						$info = wpshop_display::display_template_element($template_part, $tpl_component);
2717 2707
 						unset($tpl_component);
2718
-					}
2719
-					else {
2708
+					} else {
2720 2709
 						$info = $entity_infos->post_title;
2721 2710
 					}
2722 2711
 				}
@@ -2904,8 +2893,7 @@  discard block
 block discarded – undo
2904 2893
 
2905 2894
 		});
2906 2895
 	</script>';
2907
-			}
2908
-			elseif((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))){
2896
+			} elseif((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))){
2909 2897
 				$sub_output='';
2910 2898
 				$wp_types = unserialize(WPSHOP_INTERNAL_TYPES);
2911 2899
 				unset($input_def);$input_def=array();
@@ -3006,8 +2994,7 @@  discard block
 block discarded – undo
3006 2994
 									<option value="' . $value->value . '" >' . $value->label . '</option>';
3007 2995
 										}
3008 2996
 									}
3009
-								}
3010
-								else {
2997
+								} else {
3011 2998
 									foreach ($attribute_values as $attribute_value) {
3012 2999
 										if ( !empty($attribute_value->value) ) {
3013 3000
 											$attribute_possible_values .= '
@@ -3090,8 +3077,7 @@  discard block
 block discarded – undo
3090 3077
 					$final_list['unavailable'][$attribute->code]['label'] = $attribute->frontend_label;
3091 3078
 					$final_list['unavailable'][$attribute->code]['values'] = array();
3092 3079
 					$final_list['unavailable'][$attribute->code]['attribute_complete_def'] = $attribute;
3093
-				}
3094
-				else {
3080
+				} else {
3095 3081
 					$final_list['available'][$attribute->code]['label'] = $attribute->frontend_label;
3096 3082
 					$final_list['available'][$attribute->code]['values'] = $attribute_values_for_variations;
3097 3083
 					$final_list['available'][$attribute->code]['attribute_complete_def'] = $attribute;
@@ -3119,8 +3105,7 @@  discard block
 block discarded – undo
3119 3105
 						$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = '';
3120 3106
 						$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = '';
3121 3107
 						$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = '';
3122
-					}
3123
-					else {
3108
+					} else {
3124 3109
 						$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = ' class="wpshop_unavailable_label_variation_definition" ';
3125 3110
 						$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ' disabled="disabled"';
3126 3111
 						$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = '';
Please login to merge, or discard this patch.
Spacing   +548 added lines, -548 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @package wpshop
21 21
  * @subpackage librairies
22 22
  */
23
-class wpshop_attributes{
23
+class wpshop_attributes {
24 24
 	/*	Define the database table used in the current class	*/
25 25
 	const dbTable = WPSHOP_DBT_ATTRIBUTE;
26 26
 	/*	Define the url listing slug used in the current class	*/
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 *	@return string The table of the class
52 52
 	 */
53
-	function setMessage($message){
53
+	function setMessage($message) {
54 54
 		$this->pageMessage = $message;
55 55
 	}
56 56
 	/**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 *	@return string The table of the class
60 60
 	 */
61
-	function getListingSlug(){
61
+	function getListingSlug() {
62 62
 		return self::urlSlugListing;
63 63
 	}
64 64
 	/**
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 *	@return string The table of the class
68 68
 	 */
69
-	function getEditionSlug(){
69
+	function getEditionSlug() {
70 70
 		return self::urlSlugEdition;
71 71
 	}
72 72
 	/**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 *	@return string The table of the class
76 76
 	 */
77
-	public static function getDbTable(){
77
+	public static function getDbTable() {
78 78
 		return self::dbTable;
79 79
 	}
80 80
 	/**
@@ -82,21 +82,21 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 *	@return string $title The title of the page looking at the environnement
84 84
 	 */
85
-	function pageTitle(){
85
+	function pageTitle() {
86 86
 		$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
87 87
 		$objectInEdition = isset($_REQUEST['id']) ? sanitize_key($_REQUEST['id']) : '';
88
-		$page = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
88
+		$page = !empty($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
89 89
 
90
-		$title = __(self::pageTitle, 'wpshop' );
91
-		if($action != ''){
92
-			if(($action == 'edit') || ($action == 'delete')){
90
+		$title = __(self::pageTitle, 'wpshop');
91
+		if ($action != '') {
92
+			if (($action == 'edit') || ($action == 'delete')) {
93 93
 				$editedItem = self::getElement($objectInEdition);
94 94
 				$title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label));
95 95
 			}
96
-			elseif($action == 'add')
96
+			elseif ($action == 'add')
97 97
 				$title = __(self::pageAddingTitle, 'wpshop');
98 98
 		}
99
-		elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug()))
99
+		elseif ((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug()))
100 100
 			$title = __(self::pageAddingTitle, 'wpshop');
101 101
 
102 102
 		return $title;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 *	Define the different message and action after an action is send through the element interface
107 107
 	 */
108
-	function elementAction(){
108
+	function elementAction() {
109 109
 		global $wpdb, $initialEavData;
110 110
 
111 111
 		$pageMessage = $actionResult = '';
@@ -118,75 +118,75 @@  discard block
 block discarded – undo
118 118
 		$saveditem = isset($_REQUEST['saveditem']) ? sanitize_text_field($_REQUEST['saveditem']) : '';
119 119
 		$set_section = !empty($_REQUEST[self::getDbTable()]['set_section']) ? sanitize_text_field($_REQUEST[self::getDbTable()]['set_section']) : '';
120 120
 		//@TODO $_REQUEST
121
-		$id = !empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : null;
122
-		if(!empty($action) && ($action=='activate') ){
123
-			if( isset($id) ) {
121
+		$id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : null;
122
+		if (!empty($action) && ($action == 'activate')) {
123
+			if (isset($id)) {
124 124
 				$query = $wpdb->update(self::getDbTable(), array('status'=>'moderated'), array('id'=>$id));
125 125
 				wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id));
126 126
 			}
127 127
 		}
128
-		if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){
128
+		if (($action != '') && ($action == 'saveok') && ($saveditem > 0)) {
129 129
 			$editedElement = self::getElement($saveditem);
130 130
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>');
131 131
 		}
132
-		elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){
132
+		elseif (($action != '') && ($action == 'deleteok') && ($saveditem > 0)) {
133 133
 			$editedElement = self::getElement($saveditem, "'deleted'");
134 134
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>');
135 135
 		}
136 136
 
137
-		$attribute_parameter = !empty( $_REQUEST[self::getDbTable()] ) ? (array)$_REQUEST[self::getDbTable()] : array();
138
-		 if ( !empty($set_section) ) unset($attribute_parameter['set_section']);
137
+		$attribute_parameter = !empty($_REQUEST[self::getDbTable()]) ? (array)$_REQUEST[self::getDbTable()] : array();
138
+		 if (!empty($set_section)) unset($attribute_parameter['set_section']);
139 139
 
140 140
 		$wpshop_attribute_combo_values_list_order_def = !empty($attribute_parameter['wpshop_attribute_combo_values_list_order_def']) ? $attribute_parameter['wpshop_attribute_combo_values_list_order_def'] : array();
141 141
 		// @TODO $_REQUEST
142 142
 		// unset($_REQUEST[self::getDbTable()]['wpshop_attribute_combo_values_list_order_def']);
143 143
 
144
-		if(!isset($attribute_parameter['status'])){
144
+		if (!isset($attribute_parameter['status'])) {
145 145
 			$attribute_parameter['status'] = 'moderated';
146 146
 		}
147
-		if(!isset($attribute_parameter['is_historisable'])){
147
+		if (!isset($attribute_parameter['is_historisable'])) {
148 148
 			$attribute_parameter['is_historisable'] = 'no';
149 149
 		}
150
-		if(!isset($attribute_parameter['is_required'])){
150
+		if (!isset($attribute_parameter['is_required'])) {
151 151
 			$attribute_parameter['is_required'] = 'no';
152 152
 		}
153
-		if(!isset($attribute_parameter['is_used_in_admin_listing_column'])){
153
+		if (!isset($attribute_parameter['is_used_in_admin_listing_column'])) {
154 154
 			$attribute_parameter['is_used_in_admin_listing_column'] = 'no';
155 155
 		}
156
-		if(!isset($attribute_parameter['is_used_in_quick_add_form'])){
156
+		if (!isset($attribute_parameter['is_used_in_quick_add_form'])) {
157 157
 			$attribute_parameter['is_used_in_quick_add_form'] = 'no';
158 158
 		}
159
-		if(!isset($attribute_parameter['is_intrinsic'])){
159
+		if (!isset($attribute_parameter['is_intrinsic'])) {
160 160
 			$attribute_parameter['is_intrinsic'] = 'no';
161 161
 		}
162
-		if(!isset($attribute_parameter['is_requiring_unit'])){
162
+		if (!isset($attribute_parameter['is_requiring_unit'])) {
163 163
 			$attribute_parameter['is_requiring_unit'] = 'no';
164 164
 		}
165
-		if(!isset($attribute_parameter['is_visible_in_front'])){
165
+		if (!isset($attribute_parameter['is_visible_in_front'])) {
166 166
 			$attribute_parameter['is_visible_in_front'] = 'no';
167 167
 		}
168
-		if(!isset($attribute_parameter['is_visible_in_front_listing'])){
168
+		if (!isset($attribute_parameter['is_visible_in_front_listing'])) {
169 169
 			$attribute_parameter['is_visible_in_front_listing'] = 'no';
170 170
 		}
171
-		if(!isset($attribute_parameter['is_used_for_sort_by'])){
171
+		if (!isset($attribute_parameter['is_used_for_sort_by'])) {
172 172
 			$attribute_parameter['is_used_for_sort_by'] = 'no';
173 173
 		}
174
-		if(!isset($attribute_parameter['is_visible_in_advanced_search'])){
174
+		if (!isset($attribute_parameter['is_visible_in_advanced_search'])) {
175 175
 			$attribute_parameter['is_visible_in_advanced_search'] = 'no';
176 176
 		}
177
-		if(!isset($attribute_parameter['is_searchable'])){
177
+		if (!isset($attribute_parameter['is_searchable'])) {
178 178
 			$attribute_parameter['is_searchable'] = 'no';
179 179
 		}
180
-		if(!isset($attribute_parameter['is_used_for_variation'])){
180
+		if (!isset($attribute_parameter['is_used_for_variation'])) {
181 181
 			$attribute_parameter['is_used_for_variation'] = 'no';
182 182
 		}
183
-		if(!isset($attribute_parameter['is_used_in_variation'])){
183
+		if (!isset($attribute_parameter['is_used_in_variation'])) {
184 184
 			$attribute_parameter['is_used_in_variation'] = 'no';
185 185
 		}
186
-		if(!isset($attribute_parameter['is_user_defined'])){
186
+		if (!isset($attribute_parameter['is_user_defined'])) {
187 187
 			$attribute_parameter['is_user_defined'] = 'no';
188 188
 		}
189
-		if(!isset($attribute_parameter['_display_informations_about_value'])){
189
+		if (!isset($attribute_parameter['_display_informations_about_value'])) {
190 190
 			$attribute_parameter['_display_informations_about_value'] = 'no';
191 191
 		}
192 192
 
@@ -195,58 +195,58 @@  discard block
 block discarded – undo
195 195
 			switch ($attribute_parameter['frontend_input']) {
196 196
 				case 'short_text':
197 197
 						$attribute_parameter['frontend_input'] = 'text';
198
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
198
+						if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text';
199 199
 						$attribute_parameter['data_type'] = 'varchar';
200 200
 					break;
201 201
 				case 'date_field':
202 202
 						$attribute_parameter['frontend_input'] = 'text';
203
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
203
+						if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text';
204 204
 						$attribute_parameter['data_type'] = 'datetime';
205 205
 					break;
206 206
 				case 'float_field':
207 207
 						$attribute_parameter['frontend_input'] = 'text';
208
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
208
+						if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text';
209 209
 						$attribute_parameter['data_type'] = 'decimal';
210 210
 					break;
211 211
 				case 'hidden_field':
212 212
 						$attribute_parameter['frontend_input'] = 'hidden';
213
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
213
+						if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text';
214 214
 						$attribute_parameter['data_type'] = 'varchar';
215 215
 					break;
216 216
 				case 'pass_field':
217 217
 						$attribute_parameter['frontend_input'] = 'password';
218
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
218
+						if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text';
219 219
 						$attribute_parameter['data_type'] = 'varchar';
220 220
 					break;
221 221
 
222 222
 				case 'select':
223 223
 						$attribute_parameter['frontend_input'] = 'select';
224
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
224
+						if (empty($attribute_parameter['backend_input']) || empty($id))
225 225
 							$attribute_parameter['backend_input'] = 'multiple-select';
226 226
 						$attribute_parameter['data_type'] = 'integer';
227 227
 					break;
228 228
 				case 'multiple-select':
229 229
 						$attribute_parameter['frontend_input'] = 'multiple-select';
230
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
230
+						if (empty($attribute_parameter['backend_input']) || empty($id))
231 231
 							$attribute_parameter['backend_input'] = 'multiple-select';
232 232
 						$attribute_parameter['data_type'] = 'integer';
233 233
 					break;
234 234
 				case 'radio':
235 235
 						$attribute_parameter['frontend_input'] = 'radio';
236
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
236
+						if (empty($attribute_parameter['backend_input']) || empty($id))
237 237
 							$attribute_parameter['backend_input'] = 'multiple-select';
238 238
 						$attribute_parameter['data_type'] = 'integer';
239 239
 					break;
240 240
 				case 'checkbox':
241 241
 						$attribute_parameter['frontend_input'] = 'checkbox';
242
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
242
+						if (empty($attribute_parameter['backend_input']) || empty($id))
243 243
 							$attribute_parameter['backend_input'] = 'multiple-select';
244 244
 						$attribute_parameter['data_type'] = 'integer';
245 245
 					break;
246 246
 
247 247
 				case 'textarea':
248 248
 						$attribute_parameter['frontend_input'] = 'textarea';
249
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
249
+						if (empty($attribute_parameter['backend_input']) || empty($id))
250 250
 							$attribute_parameter['backend_input'] = 'textarea';
251 251
 						$attribute_parameter['data_type'] = 'text';
252 252
 					break;
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 		}
255 255
 		else {
256 256
 			$attribute_parameter['frontend_input'] = 'text';
257
-			if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
257
+			if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text';
258 258
 			$attribute_parameter['data_type'] = 'varchar';
259 259
 		}
260 260
 
@@ -263,55 +263,55 @@  discard block
 block discarded – undo
263 263
 			// $attribute_parameter['use_ajax_for_filling_field']='no';
264 264
 		// }
265 265
 		$attribute_parameter['use_ajax_for_filling_field'] = 'yes';
266
-		if( $attribute_parameter['backend_input'] == 'multiple-select' ) {
266
+		if ($attribute_parameter['backend_input'] == 'multiple-select') {
267 267
 			$attribute_parameter['is_used_for_variation'] = 'yes';
268 268
 		}
269 269
 
270 270
 		/*	Define the database operation type from action launched by the user	 */
271 271
 		$attribute_parameter['default_value'] = (!empty($attribute_parameter['default_value']) && is_array($attribute_parameter['default_value'])) ? serialize($attribute_parameter['default_value']) : (isset($attribute_parameter['default_value']) ? str_replace('"', "'", $attribute_parameter['default_value']) : '');
272
-		if ( $attribute_parameter['data_type'] == 'datetime' ) {
272
+		if ($attribute_parameter['data_type'] == 'datetime') {
273 273
 			$date_default_value_trasform_into_config = array('default_value' => $attribute_parameter['default_value'], 'field_options' => (!empty($_POST[self::getDbTable() . '_options']) ? sanitize_text_field($_POST[self::getDbTable() . '_options']) : null));
274
-			$attribute_parameter['default_value'] = serialize( $date_default_value_trasform_into_config );
274
+			$attribute_parameter['default_value'] = serialize($date_default_value_trasform_into_config);
275 275
 		}
276 276
 		/*****************************		GENERIC				**************************/
277 277
 		/*************************************************************************/
278
-		$pageAction = (!empty($attribute_parameter['frontend_label']) && isset($_REQUEST[self::getDbTable() . '_action'])) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action']=='delete')) ? sanitize_text_field($_GET['action']) : '');
278
+		$pageAction = (!empty($attribute_parameter['frontend_label']) && isset($_REQUEST[self::getDbTable() . '_action'])) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action'] == 'delete')) ? sanitize_text_field($_GET['action']) : '');
279 279
 		$id = isset($attribute_parameter['id']) ? sanitize_key($attribute_parameter['id']) : ((!empty($_GET['id'])) ? $_GET['id'] : '');
280
-		if(($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))){
281
-			if(current_user_can('wpshop_edit_attributes')){
280
+		if (($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))) {
281
+			if (current_user_can('wpshop_edit_attributes')) {
282 282
 				$attribute_parameter['last_update_date'] = date('Y-m-d H:i:s');
283
-				if($pageAction == 'delete'){
283
+				if ($pageAction == 'delete') {
284 284
 					$attribute_code = $attribute_parameter['code'];
285
-					if(!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')){
285
+					if (!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')) {
286 286
 						$attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id');
287 287
 						$attribute_code = $attribute->code;
288 288
 					}
289
-					if(!in_array($attribute_code, $attribute_undeletable)){
290
-						if(current_user_can('wpshop_delete_attributes')){
289
+					if (!in_array($attribute_code, $attribute_undeletable)) {
290
+						if (current_user_can('wpshop_delete_attributes')) {
291 291
 							$attribute_parameter['status'] = 'deleted';
292 292
 						}
293
-						else{
293
+						else {
294 294
 							$actionResult = 'userNotAllowedForActionDelete';
295 295
 						}
296 296
 					}
297
-					else{
297
+					else {
298 298
 						$actionResult = 'unDeletableAtribute';
299 299
 					}
300 300
 				}
301 301
 				$actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable());
302 302
 			}
303
-			else{
303
+			else {
304 304
 				$actionResult = 'userNotAllowedForActionEdit';
305 305
 			}
306 306
 		}
307
-		elseif(($pageAction != '') && (($pageAction == 'delete'))){
307
+		elseif (($pageAction != '') && (($pageAction == 'delete'))) {
308 308
 			$attribute_code = '';
309
-			if (empty(	$attribute_parameter['code'])) {
309
+			if (empty($attribute_parameter['code'])) {
310 310
 				$attribute = self::getElement($id, "'valid', 'moderated', 'notused', 'deleted'", 'id');
311 311
 				$attribute_code = $attribute->code;
312 312
 			}
313 313
 			if (!in_array($attribute_code, $attribute_undeletable)) {
314
-				if(current_user_can('wpshop_delete_attributes')){
314
+				if (current_user_can('wpshop_delete_attributes')) {
315 315
 					$attribute_parameter['last_update_date'] = current_time('mysql', 0);
316 316
 					$attribute_parameter['status'] = 'deleted';
317 317
 					$actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable());
@@ -322,21 +322,21 @@  discard block
 block discarded – undo
322 322
 			else
323 323
 				$actionResult = 'unDeletableAtribute';
324 324
 		}
325
-		elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){
326
-			if(current_user_can('wpshop_add_attributes')){
325
+		elseif (($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))) {
326
+			if (current_user_can('wpshop_add_attributes')) {
327 327
 				$attribute_parameter['creation_date'] = current_time('mysql', 0);
328
-				if(trim($attribute_parameter['code']) == ''){
328
+				if (trim($attribute_parameter['code']) == '') {
329 329
 					$attribute_parameter['code'] = $attribute_parameter['frontend_label'];
330 330
 				}
331 331
 				$attribute_parameter['code'] = wpshop_tools::slugify(str_replace("\'", "_", str_replace('\"', "_", $attribute_parameter['code'])), array('noAccent', 'noSpaces', 'lowerCase', 'noPunctuation'));
332 332
 				$code_exists = self::getElement($attribute_parameter['code'], "'valid', 'moderated', 'deleted'", 'code');
333
-				if((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)){
333
+				if ((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)) {
334 334
 					$attribute_parameter['code'] = $attribute_parameter['code'] . '_' . (count($code_exists) + rand());
335 335
 				}
336 336
 				$actionResult = wpshop_database::save($attribute_parameter, self::getDbTable());
337 337
 				$id = $wpdb->insert_id;
338 338
 			}
339
-			else{
339
+			else {
340 340
 				$actionResult = 'userNotAllowedForActionAdd';
341 341
 			}
342 342
 		}
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
 		/************		CHANGE THE FIELD NAME TO TAKE TO DISPLAY				*************/
346 346
 		/************		CHANGE ERROR MESSAGE FOR SPECIFIC CASE					*************/
347 347
 		/****************************************************************************/
348
-		if($actionResult != ''){
348
+		if ($actionResult != '') {
349 349
 			$elementIdentifierForMessage = __('the attribute', 'wpshop');
350
-			if(!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>';
350
+			if (!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>';
351 351
 			if ($actionResult == 'error') {/*	CHANGE HERE FOR SPECIFIC CASE	*/
352 352
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage, ' -> ' . $wpdb->last_error);
353 353
 			}
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
 				$done_options_value = array();
360 360
 				$default_value = $attribute_parameter['default_value'];
361 361
 				$i = 1;
362
-				$options = !empty($_REQUEST['options']) ? (array) $_REQUEST['options'] : array();
363
-				$optionsValue = !empty($_REQUEST['optionsValue']) ? (array) $_REQUEST['optionsValue'] : array();
364
-				$optionsUpdate = !empty($_REQUEST['optionsUpdate']) ? (array) $_REQUEST['optionsUpdate'] : array();
365
-				$optionsUpdateValue = !empty($_REQUEST['optionsUpdateValue']) ? (array) $_REQUEST['optionsUpdateValue'] : array();
366
-				if ( !empty($optionsUpdate) ) {
362
+				$options = !empty($_REQUEST['options']) ? (array)$_REQUEST['options'] : array();
363
+				$optionsValue = !empty($_REQUEST['optionsValue']) ? (array)$_REQUEST['optionsValue'] : array();
364
+				$optionsUpdate = !empty($_REQUEST['optionsUpdate']) ? (array)$_REQUEST['optionsUpdate'] : array();
365
+				$optionsUpdateValue = !empty($_REQUEST['optionsUpdateValue']) ? (array)$_REQUEST['optionsUpdateValue'] : array();
366
+				if (!empty($optionsUpdate)) {
367 367
 					/**
368 368
 					 *	Check if there is an attribute code into sended request or if we have to get the code from database (Bug fix)
369 369
 					 */
@@ -377,25 +377,25 @@  discard block
 block discarded – undo
377 377
 					foreach ($optionsUpdate as $option_key => $option_label) {
378 378
 						$option_value = !empty($optionsUpdateValue[$option_key]) ? str_replace(",", ".", $optionsUpdateValue[$option_key]) : '';
379 379
 
380
-						if ( empty($option_value) || !in_array($option_value, $done_options_value) ) {
380
+						if (empty($option_value) || !in_array($option_value, $done_options_value)) {
381 381
 							/*	Update an existing value only if the value does not exist into existing list	*/
382 382
 							$label = (($option_label != '') ? $option_label : str_replace(",", ".", $option_value));
383 383
 							$value = str_replace(",", ".", $option_value);
384
-							if( !WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT ) {
384
+							if (!WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT) {
385 385
 								$label = $option_label;
386
-								$value =  str_replace(",", ".", $label);
386
+								$value = str_replace(",", ".", $label);
387 387
 							}
388 388
 
389 389
 							$wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('last_update_date' => current_time('mysql', 0), 'position' => $i, 'label' => stripslashes($label), 'value' => stripslashes($value)), array('id' => $option_key));
390 390
 							$done_options_value[] = str_replace(",", ".", $option_value);
391 391
 
392 392
 							/*	Check if this value is used for price calculation and make update on the different product using this value	*/
393
-							if($attribute_code == WPSHOP_PRODUCT_PRICE_TAX){
393
+							if ($attribute_code == WPSHOP_PRODUCT_PRICE_TAX) {
394 394
 								$action = wpshop_prices::mass_update_prices();
395 395
 							}
396 396
 						}
397 397
 
398
-						if($default_value == $option_key) {
398
+						if ($default_value == $option_key) {
399 399
 							/*	Update an existing a only if the value does not exist into existing list	*/
400 400
 							$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('last_update_date' => current_time('mysql', 0), 'default_value' => $option_key), array('id' => $id));
401 401
 							$done_options_value[] = str_replace(",", ".", $option_value);
@@ -403,13 +403,13 @@  discard block
 block discarded – undo
403 403
 						$i++;
404 404
 					}
405 405
 				}
406
-				if ( !empty($options) ) {
407
-					foreach ( $options as $option_key => $option_label ) {
406
+				if (!empty($options)) {
407
+					foreach ($options as $option_key => $option_label) {
408 408
 						$option_value = !empty($optionsValue[$option_key]) ? str_replace(",", ".", $optionsValue[$option_key]) : sanitize_title($option_label);
409 409
 
410 410
 						/*	Check what value to use for the new values	*/
411 411
 						$label = (!empty($option_label) ? $option_label : str_replace(",", ".", $option_value));
412
-						if( !WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT && empty($option_value) ) {
412
+						if (!WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT && empty($option_value)) {
413 413
 							$label = $option_label;
414 414
 							$option_value = sanitize_title($label);
415 415
 						}
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 						// If the optionsUpdateValue is empty, set it a empty array to avoid error calling the in_array() function
418 418
 						// $_REQUEST['optionsUpdateValue'] = !empty($_REQUEST['optionsUpdateValue']) ? $_REQUEST['optionsUpdateValue'] : array();
419 419
 
420
-						if (!in_array($option_value, $done_options_value) && !in_array($option_value, $optionsUpdateValue) ) {
420
+						if (!in_array($option_value, $done_options_value) && !in_array($option_value, $optionsUpdateValue)) {
421 421
 
422 422
 							$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('creation_date' => current_time('mysql', 0), 'status' => 'valid', 'attribute_id' => $id, 'position' => $i, 'label' => stripslashes($label), 'value' => stripslashes($option_value)));
423 423
 							$done_options_value[] = str_replace(",", ".", $option_value);
@@ -435,19 +435,19 @@  discard block
 block discarded – undo
435 435
 				}
436 436
 
437 437
 				// If the is_used_for_sort_by is mark as yes, we have to get out some attributes and save it separately
438
-				if( (!empty($attribute_parameter['is_used_for_sort_by']) && ($attribute_parameter['is_used_for_sort_by'] == 'yes')) || (!empty($attribute_parameter['is_filterable']) && ($attribute_parameter['is_filterable'] == 'yes')) || (!empty($attribute_parameter['is_searchable']) && ($attribute_parameter['is_searchable'] == 'yes')) ){
438
+				if ((!empty($attribute_parameter['is_used_for_sort_by']) && ($attribute_parameter['is_used_for_sort_by'] == 'yes')) || (!empty($attribute_parameter['is_filterable']) && ($attribute_parameter['is_filterable'] == 'yes')) || (!empty($attribute_parameter['is_searchable']) && ($attribute_parameter['is_searchable'] == 'yes'))) {
439 439
 					$attribute_code = $attribute_parameter['code'];
440
-					if(!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')){
440
+					if (!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')) {
441 441
 						$attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id');
442 442
 						$attribute_code = $attribute->code;
443 443
 					}
444 444
 
445 445
 					$count_products = wp_count_posts(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
446
-					for( $i = 0; $i <= $count_products->publish; $i+= 20 ) {
447
-						$query = $wpdb->prepare( 'SELECT * FROM '. $wpdb->posts .' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT '.$i.', 20', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish' );
448
-						$products = $wpdb->get_results( $query );
449
-						if ( !empty($products) ) {
450
-							foreach( $products as $product ) {
446
+					for ($i = 0; $i <= $count_products->publish; $i += 20) {
447
+						$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT ' . $i . ', 20', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish');
448
+						$products = $wpdb->get_results($query);
449
+						if (!empty($products)) {
450
+							foreach ($products as $product) {
451 451
 								$query = $wpdb->prepare("SELECT value FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attribute_parameter['data_type'] . " WHERE attribute_id = %d AND entity_type_id = %d AND entity_id = %d AND value != '' ORDER BY creation_date_value DESC", $id, $attribute_parameter['entity_id'], $product->ID);
452 452
 								$value = $wpdb->get_var($query);
453 453
 								update_post_meta($product->ID, '_' . $attribute_code, $value);
@@ -457,13 +457,13 @@  discard block
 block discarded – undo
457 457
 					wp_reset_query();
458 458
 				}
459 459
 
460
-				if ( $pageAction != 'delete' ) {/*	Add the new attribute in the additionnal informations attribute group	*/
461
-					if ( !empty($set_section) ) {
460
+				if ($pageAction != 'delete') {/*	Add the new attribute in the additionnal informations attribute group	*/
461
+					if (!empty($set_section)) {
462 462
 						$choosen_set_section = explode('_', $set_section);
463 463
 						$set_id = $choosen_set_section[0];
464 464
 						$group_id = $choosen_set_section[1];
465 465
 					}
466
-					else{
466
+					else {
467 467
 						$attribute_current_attribute_set = 0;
468 468
 						$query = $wpdb->prepare("
469 469
 								SELECT id
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 									AND ATTRIBUTE_SET_DETAILS.entity_type_id = %d", $id, $attribute_parameter['entity_id']);
474 474
 						$attribute_current_attribute_set = $wpdb->get_results($query);
475 475
 
476
-						if ( empty($attribute_current_attribute_set) ) {
476
+						if (empty($attribute_current_attribute_set)) {
477 477
 							$query = $wpdb->prepare("
478 478
 								SELECT
479 479
 									(
@@ -494,12 +494,12 @@  discard block
 block discarded – undo
494 494
 							$wpshop_default_group = $wpdb->get_row($query);
495 495
 
496 496
 							$set_id = $wpshop_default_group->attribute_set_id;
497
-							$default_group_id = ( !empty( $wpshop_default_group->default_attribute_group_id) ) ? $wpshop_default_group->default_attribute_group_id : '';
497
+							$default_group_id = (!empty($wpshop_default_group->default_attribute_group_id)) ? $wpshop_default_group->default_attribute_group_id : '';
498 498
 							$group_id = !empty($default_group_id) ? $default_group_id : $wpshop_default_group->attribute_group_id;
499 499
 						}
500 500
 					}
501 501
 
502
-					if ( !empty($set_id) && !empty($group_id) ) {
502
+					if (!empty($set_id) && !empty($group_id)) {
503 503
 						$query = $wpdb->prepare(
504 504
 								"SELECT (MAX(position) + 1) AS position
505 505
 								FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . "
@@ -511,12 +511,12 @@  discard block
 block discarded – undo
511 511
 								$attribute_parameter['entity_id']
512 512
 						);
513 513
 						$wpshopAttributePosition = $wpdb->get_var($query);
514
-						if($wpshopAttributePosition == 0)$wpshopAttributePosition = 1;
514
+						if ($wpshopAttributePosition == 0)$wpshopAttributePosition = 1;
515 515
 						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $attribute_parameter['entity_id'], 'attribute_set_id' => $set_id, 'attribute_group_id' => $group_id, 'attribute_id' => $id, 'position' => $wpshopAttributePosition));
516 516
 					}
517 517
 				}
518 518
 
519
-				if ( !empty($wpshop_attribute_combo_values_list_order_def) ) {
519
+				if (!empty($wpshop_attribute_combo_values_list_order_def)) {
520 520
 					$post_order = explode(',', $wpshop_attribute_combo_values_list_order_def);
521 521
 					$position = 1;
522 522
 					foreach ($post_order as $post_id) {
@@ -532,19 +532,19 @@  discard block
 block discarded – undo
532 532
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id));
533 533
 				}
534 534
 				else */
535
-				if ( $pageAction == 'add' )
535
+				if ($pageAction == 'add')
536 536
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id));
537
-				elseif ( $pageAction == 'delete' )
537
+				elseif ($pageAction == 'delete')
538 538
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id));
539 539
 			}
540
-			elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')){
540
+			elseif (($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) {
541 541
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop');
542 542
 			}
543
-			elseif(($actionResult == 'unDeletableAtribute')){
543
+			elseif (($actionResult == 'unDeletableAtribute')) {
544 544
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('This attribute could not be deleted due to configuration', 'wpshop');
545 545
 			}
546 546
 
547
-			if(empty($attribute_parameter['frontend_label']) && ($pageAction!='delete')){
547
+			if (empty($attribute_parameter['frontend_label']) && ($pageAction != 'delete')) {
548 548
 				$pageMessage .= __('Please enter an label for the attribut', 'wpshop');
549 549
 			}
550 550
 		}
@@ -562,37 +562,37 @@  discard block
 block discarded – undo
562 562
 		//Create an instance of our package class...
563 563
 		$wpshop_list_table = new wpshop_attributes_custom_List_table();
564 564
 		//Fetch, prepare, sort, and filter our data...
565
-		$status="'valid'";
566
-		$attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field( $_REQUEST['attribute_status'] ) : null;
567
-		$s = !empty($_REQUEST['s']) ? sanitize_text_field( $_REQUEST['s'] ) : null;
565
+		$status = "'valid'";
566
+		$attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field($_REQUEST['attribute_status']) : null;
567
+		$s = !empty($_REQUEST['s']) ? sanitize_text_field($_REQUEST['s']) : null;
568 568
 		$order = !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : null;
569 569
 		$orderby = !empty($_REQUEST['orderby']) ? sanitize_text_field($_REQUEST['orderby']) : null;
570
-		if(!empty($attribute_status)){
571
-			switch($attribute_status){
570
+		if (!empty($attribute_status)) {
571
+			switch ($attribute_status) {
572 572
 				case 'unactive':
573
-					$status="'moderated', 'notused'";
574
-					if(empty($order_by) && empty($order)){
573
+					$status = "'moderated', 'notused'";
574
+					if (empty($order_by) && empty($order)) {
575 575
 						// @TODO : REQUEST
576 576
 						// $_REQUEST['orderby']='status';
577 577
 						// $_REQUEST['order']='asc';
578 578
 					}
579 579
 					break;
580 580
 				default:
581
-					$status="'".sanitize_text_field($_REQUEST['attribute_status'])."'";
581
+					$status = "'" . sanitize_text_field($_REQUEST['attribute_status']) . "'";
582 582
 					break;
583 583
 			}
584 584
 		}
585
-		if ( !empty($s) ) {
586
-			$query = $wpdb->prepare("SELECT * FROM " . self::dbTable . ' WHERE frontend_label LIKE "%%%1$s%%" OR frontend_label LIKE "%%%2$s%%" AND backend_label LIKE "%%%1$s%%" OR backend_label LIKE "%%%2$s%%" AND code LIKE "%%%1$s%%" OR code LIKE "%%%2$s%%"', $s, __($s, 'wpshop') );
587
-			$attr_set_list = $wpdb->get_results( $query );
585
+		if (!empty($s)) {
586
+			$query = $wpdb->prepare("SELECT * FROM " . self::dbTable . ' WHERE frontend_label LIKE "%%%1$s%%" OR frontend_label LIKE "%%%2$s%%" AND backend_label LIKE "%%%1$s%%" OR backend_label LIKE "%%%2$s%%" AND code LIKE "%%%1$s%%" OR code LIKE "%%%2$s%%"', $s, __($s, 'wpshop'));
587
+			$attr_set_list = $wpdb->get_results($query);
588 588
 		}
589 589
 		else {
590
-			$attr_set_list = self::getElement( '', $status );
590
+			$attr_set_list = self::getElement('', $status);
591 591
 		}
592
-		$i=0;
593
-		$attribute_set_list=array();
594
-		foreach($attr_set_list as $attr_set){
595
-			if(!empty($attr_set->id) && ($attr_set->code != 'product_attribute_set_id') ){
592
+		$i = 0;
593
+		$attribute_set_list = array();
594
+		foreach ($attr_set_list as $attr_set) {
595
+			if (!empty($attr_set->id) && ($attr_set->code != 'product_attribute_set_id')) {
596 596
 				$attribute_set_list[$i]['id'] = $attr_set->id;
597 597
 				$attribute_set_list[$i]['name'] = $attr_set->frontend_label;
598 598
 				$attribute_set_list[$i]['status'] = $attr_set->status;
@@ -640,31 +640,31 @@  discard block
 block discarded – undo
640 640
 		global $attribute_displayed_field, $attribute_options_group;
641 641
 		$dbFieldList = wpshop_database::fields_to_input(self::getDbTable());
642 642
 		$editedItem = '';
643
-		if($itemToEdit != '')
643
+		if ($itemToEdit != '')
644 644
 			$editedItem = self::getElement($itemToEdit);
645 645
 
646 646
 		$the_form_content_hidden = $the_form_general_content = '';
647 647
 		$the_form_option_content_list = array();
648
-		foreach($dbFieldList as $input_key => $input_def){
648
+		foreach ($dbFieldList as $input_key => $input_def) {
649 649
 
650
-			if(!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)){
650
+			if (!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)) {
651 651
 				$input_def['label'] = $input_def['name'];
652
-				$input_def_id=$input_def['id']='wpshop_' . self::currentPageCode . '_edition_table_field_id_'.$input_def['label'];
652
+				$input_def_id = $input_def['id'] = 'wpshop_' . self::currentPageCode . '_edition_table_field_id_' . $input_def['label'];
653 653
 
654 654
 				$pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : '';
655 655
 				$requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['label']]) ? sanitize_text_field($_REQUEST[self::currentPageCode][$input_def['label']]) : '';
656 656
 				$currentFieldValue = $input_def['value'];
657
-				if(is_object($editedItem))
657
+				if (is_object($editedItem))
658 658
 					$currentFieldValue = $editedItem->{$input_def['label']};
659
-				elseif(($pageAction != '') && ($requestFormValue != ''))
659
+				elseif (($pageAction != '') && ($requestFormValue != ''))
660 660
 					$currentFieldValue = $requestFormValue;
661 661
 
662
-				if($input_def['label'] == 'status'){
663
-					if(in_array('notused', $input_def['possible_value'])){
662
+				if ($input_def['label'] == 'status') {
663
+					if (in_array('notused', $input_def['possible_value'])) {
664 664
 						$key = array_keys($input_def['possible_value'], 'notused');
665 665
 						unset($input_def['possible_value'][$key[0]]);
666 666
 					}
667
-					if(in_array('dbl', $input_def['possible_value'])){
667
+					if (in_array('dbl', $input_def['possible_value'])) {
668 668
 						$key = array_keys($input_def['possible_value'], 'dbl');
669 669
 						unset($input_def['possible_value'][$key[0]]);
670 670
 					}
@@ -672,94 +672,94 @@  discard block
 block discarded – undo
672 672
 					$input_def['type'] = 'checkbox';
673 673
 					$input_def['label'] = __('Use this attribute', 'wpshop');
674 674
 					$input_def['possible_value'] = array('valid');
675
-					$input_def_id.='_valid';
676
-					$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using this attribute', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
675
+					$input_def_id .= '_valid';
676
+					$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
677 677
 				}
678 678
 
679
-				if ( (substr($input_def['label'], 0, 3) == 'is_') || ( $input_def['label'] == '_display_informations_about_value') ) {
679
+				if ((substr($input_def['label'], 0, 3) == 'is_') || ($input_def['label'] == '_display_informations_about_value')) {
680 680
 					$input_def['type'] = 'checkbox';
681 681
 					$input_def['possible_value'] = 'yes';
682 682
 				}
683
-				switch($input_def['label']){
683
+				switch ($input_def['label']) {
684 684
 					case 'is_requiring_unit':
685
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using unit with this attribute', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
685
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using unit with this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
686 686
 					break;
687 687
 					case 'is_visible_in_front':
688
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute in shop', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
688
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute in shop', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
689 689
 					break;
690 690
 					case 'is_visible_in_front_listing':
691
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute in product listing in shop', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
691
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute in product listing in shop', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
692 692
 					break;
693 693
 					case 'is_used_for_sort_by':
694
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute into sortbar', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
694
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute into sortbar', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
695 695
 					break;
696 696
 					case 'is_searchable':
697
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for including values of this attribute as search parameter', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
697
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for including values of this attribute as search parameter', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
698 698
 					break;
699 699
 					case 'is_visible_in_advanced_search':
700
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using in advanced search form', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
700
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using in advanced search form', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
701 701
 					break;
702 702
 					case 'frontend_css_class':
703
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Separate with a space each CSS Class', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
703
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
704 704
 					break;
705 705
 					case 'backend_css_class':
706
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Separate with a space each CSS Class', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
706
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
707 707
 					break;
708 708
 					case 'is_historisable':
709
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want to save the different value this attribute, each time it is modified', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
709
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to save the different value this attribute, each time it is modified', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
710 710
 					break;
711 711
 					case 'is_filterable':
712
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want to use this attribute in the filter search', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
712
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to use this attribute in the filter search', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
713 713
 					break;
714 714
 					case 'is_intrinsic':
715
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if this attribute is intrinsic for a product', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
715
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if this attribute is intrinsic for a product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
716 716
 					break;
717 717
 					case 'is_used_for_variation':
718
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if this attribute is used for variation. It means that the user would be able to choose a value in frontend', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
718
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if this attribute is used for variation. It means that the user would be able to choose a value in frontend', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
719 719
 					break;
720 720
 					case 'is_used_in_variation':
721
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want to use this attribute for variation definition', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
722
-						if ( !empty($editedItem) && ($editedItem->is_used_for_variation == 'yes') ) {
721
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to use this attribute for variation definition', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
722
+						if (!empty($editedItem) && ($editedItem->is_used_for_variation == 'yes')) {
723 723
 							$input_def['option'] = 'disabled="disabled"';
724 724
 						}
725 725
 					break;
726 726
 					case 'is_user_defined':
727
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want your customer to choose a value for this attribute into frontend product', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
727
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want your customer to choose a value for this attribute into frontend product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
728 728
 					break;
729 729
 				}
730 730
 
731 731
 				$input_def['value'] = $currentFieldValue;
732
-				if($input_def['label'] == 'code')
732
+				if ($input_def['label'] == 'code')
733 733
 					$input_def['type'] = 'hidden';
734
-				elseif($input_def['label'] == 'entity_id'){
734
+				elseif ($input_def['label'] == 'entity_id') {
735 735
 					$input_def['possible_value'] = wpshop_entities::get_entities_list();
736 736
 					$input_def['valueToPut'] = 'index';
737 737
 					$input_def['type'] = 'select';
738 738
 
739
-					$i=0;
740
-					foreach($input_def['possible_value'] as $entity_id => $entity_name) {
741
-						if($i <= 0){
739
+					$i = 0;
740
+					foreach ($input_def['possible_value'] as $entity_id => $entity_name) {
741
+						if ($i <= 0) {
742 742
 							$current_entity_id = $entity_id;
743 743
 						}
744 744
 						$i++;
745 745
 					}
746 746
 				}
747
-				elseif($input_def['label'] == '_unit_group_id'){
747
+				elseif ($input_def['label'] == '_unit_group_id') {
748 748
 					$input_def['possible_value'] = wpshop_attributes_unit::get_unit_group();
749 749
 					$input_def['type'] = 'select';
750 750
 				}
751
-				elseif($input_def['label'] == '_default_unit'){
751
+				elseif ($input_def['label'] == '_default_unit') {
752 752
 					$unit_group_list = wpshop_attributes_unit::get_unit_group();
753
-					$input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group(!empty($editedItem->_unit_group_id)?$editedItem->_unit_group_id:(!empty($unit_group_list)?$unit_group_list[0]->id:''));
753
+					$input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group(!empty($editedItem->_unit_group_id) ? $editedItem->_unit_group_id : (!empty($unit_group_list) ? $unit_group_list[0]->id : ''));
754 754
 					$input_def['type'] = 'select';
755 755
 				}
756 756
 				elseif ($input_def['label'] == 'backend_input') {
757
-					if ( !is_object($editedItem) ) {
757
+					if (!is_object($editedItem)) {
758 758
 						$input_def['type'] = 'hidden';
759 759
 					}
760 760
 					else {
761 761
 						$new_possible_value = array();
762
-						switch ( $editedItem->data_type) {
762
+						switch ($editedItem->data_type) {
763 763
 							case 'integer':
764 764
 								$new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox';
765 765
 								$new_possible_value[__('Radio button', 'wpshop')] = 'radio';
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 								$new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select';
768 768
 								break;
769 769
 							case 'varchar':
770
-								switch ( $input_def['value'] ) {
770
+								switch ($input_def['value']) {
771 771
 									case 'hidden':
772 772
 										$new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field';
773 773
 										break;
@@ -795,8 +795,8 @@  discard block
 block discarded – undo
795 795
 				elseif ($input_def['label'] == 'frontend_input') {
796 796
 					$new_possible_value = array();
797 797
 
798
-					if ( is_object($editedItem) ) {
799
-						switch ( $editedItem->data_type) {
798
+					if (is_object($editedItem)) {
799
+						switch ($editedItem->data_type) {
800 800
 							case 'integer':
801 801
 								$new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox';
802 802
 								$new_possible_value[__('Radio button', 'wpshop')] = 'radio';
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 								$new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select';
805 805
 								break;
806 806
 							case 'varchar':
807
-									switch ( $input_def['value'] ) {
807
+									switch ($input_def['value']) {
808 808
 										case 'hidden':
809 809
 											$new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field';
810 810
 										break;
@@ -842,10 +842,10 @@  discard block
 block discarded – undo
842 842
 
843 843
 					$input_def['possible_value'] = $new_possible_value;
844 844
 
845
-					if ( !empty($editedItem->frontend_input) ) {
846
-						switch ( $editedItem->frontend_input ) {
845
+					if (!empty($editedItem->frontend_input)) {
846
+						switch ($editedItem->frontend_input) {
847 847
 							case 'text':
848
-								switch ( $editedItem->data_type ) {
848
+								switch ($editedItem->data_type) {
849 849
 									case 'varchar':
850 850
 										$input_def['value'] = 'short_text';
851 851
 									break;
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 					}
871 871
 				}
872 872
 
873
-				if(is_object($editedItem) && (($input_def['label'] == 'code') || ($input_def['label'] == 'data_type') || ($input_def['label'] == 'entity_id'))){
873
+				if (is_object($editedItem) && (($input_def['label'] == 'code') || ($input_def['label'] == 'data_type') || ($input_def['label'] == 'entity_id'))) {
874 874
 					// $input_def['type'] = 'hidden';
875 875
 					$input_def['option'] = ' disabled="disabled" ';
876 876
 					$the_form_content_hidden .= '<input type="hidden" name="' . self::getDbTable() . '[' . $input_def['name'] . ']" value="' . $input_def['value'] . '" />';
@@ -881,16 +881,16 @@  discard block
 block discarded – undo
881 881
 				$input_def['value'] = str_replace("\\", "", $input_def['value']);
882 882
 
883 883
 				$the_input = wpshop_form::check_input_type($input_def, self::getDbTable());
884
-				if ( $input_def['label'] == 'default_value' ) {
885
-					if ( !empty($editedItem->frontend_input) ) {
886
-						switch ( $editedItem->frontend_input ) {
884
+				if ($input_def['label'] == 'default_value') {
885
+					if (!empty($editedItem->frontend_input)) {
886
+						switch ($editedItem->frontend_input) {
887 887
 							case 'text':
888 888
 								$input_def['type'] = 'text';
889
-								switch ( $editedItem->data_type ) {
889
+								switch ($editedItem->data_type) {
890 890
 									case 'datetime':
891
-										$the_input = wpshop_attributes::attribute_type_date_config( unserialize($input_def['value']) );
891
+										$the_input = wpshop_attributes::attribute_type_date_config(unserialize($input_def['value']));
892 892
 
893
-										$input_def['label'] = __('Date field configuration','wpshop');
893
+										$input_def['label'] = __('Date field configuration', 'wpshop');
894 894
 									break;
895 895
 									default:
896 896
 										$the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 							case 'multiple-select':
908 908
 							case 'radio':
909 909
 							case 'checkbox':
910
-								$input_def['label'] = __('Options list for attribute','wpshop') . '
910
+								$input_def['label'] = __('Options list for attribute', 'wpshop') . '
911 911
 <div class="alignright wpshop_change_select_data_type" >
912 912
 	+' . __('Change data type for this attribute', 'wpshop') . '
913 913
 </div>';
@@ -921,50 +921,50 @@  discard block
 block discarded – undo
921 921
 						}
922 922
 					}
923 923
 					else {
924
-						$input_def['type']='text';
924
+						$input_def['type'] = 'text';
925 925
 						$the_input = wpshop_form::check_input_type($input_def, self::getDbTable());
926 926
 					}
927 927
 				}
928
-				if( $input_def['label'] == '_unit_group_id') {
928
+				if ($input_def['label'] == '_unit_group_id') {
929 929
 					$the_input .= '<div id="wpshop_loader_input_group_unit"></div>';
930
-					$the_input .= '<a class="button-primary" href="#wpshop_unit_group_list" id="wpshop_attribute_group_unit_manager_opener" data-nonce="' . wp_create_nonce( 'load_unit_interface' ) . '">'.__('Manage group unit', 'wpshop').'</a>';
930
+					$the_input .= '<a class="button-primary" href="#wpshop_unit_group_list" id="wpshop_attribute_group_unit_manager_opener" data-nonce="' . wp_create_nonce('load_unit_interface') . '">' . __('Manage group unit', 'wpshop') . '</a>';
931 931
 				}
932 932
 
933
-				if( $input_def['label'] == '_default_unit') {
933
+				if ($input_def['label'] == '_default_unit') {
934 934
 					$the_input .= '<div id="wpshop_loader_input_unit"></div>';
935
-					$the_input .= '<a class="button-primary" href="#wpshop_unit_list" id="wpshop_attribute_unit_manager_opener" data-nonce="' . wp_create_nonce( 'load_unit_interface' ) . '">'.__('Manage units', 'wpshop').'</a>';
935
+					$the_input .= '<a class="button-primary" href="#wpshop_unit_list" id="wpshop_attribute_unit_manager_opener" data-nonce="' . wp_create_nonce('load_unit_interface') . '">' . __('Manage units', 'wpshop') . '</a>';
936 936
 					$the_input .= '<input type="hidden" name="input_wpshop_load_attribute_unit_list" id="input_wpshop_load_attribute_unit_list" value="' . wp_create_nonce("wpshop_load_attribute_unit_list") . '" />';
937 937
 					$the_input .= '<div id="wpshop_attribute_unit_manager" title="' . __('Unit management', 'wpshop') . '" class="wpshopHide" ><div class="loading_picture_container" id="product_chooser_picture" ><img src="' . WPSHOP_LOADING_ICON . '" alt="loading..." /></div></div>';
938 938
 				}
939 939
 
940 940
 
941
-				if($input_def['type'] != 'hidden'){
942
-					if ( ($input_def['label'] == 'entity_id') && is_object($editedItem) ) {
941
+				if ($input_def['type'] != 'hidden') {
942
+					if (($input_def['label'] == 'entity_id') && is_object($editedItem)) {
943 943
 						$the_input .= '<br/><span class="wpshop_duplicate_attribute" >' . __('Duplicate this attribute to . another entity', 'wpshop') . '</span>';
944 944
 					}
945 945
 					$input = '
946
-		<tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_'.$input_def['name'].'" >
947
-			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_def['name'].'" ><label for="'.$input_def_id.'" >' . __($input_def['label'], 'wpshop') . '</label></td>
948
-			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_def['name'].'" >' . $the_input . '</td>
946
+		<tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_' . $input_def['name'] . '" >
947
+			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_' . $input_def['name'] . '" ><label for="' . $input_def_id . '" >' . __($input_def['label'], 'wpshop') . '</label></td>
948
+			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_' . $input_def['name'] . '" >' . $the_input . '</td>
949 949
 		</tr>';
950
-					if ( (substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize( WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS )) )
950
+					if ((substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize(WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS)))
951 951
 						$the_form_option_content_list[$input_def['label']] = $input;
952 952
 					else {
953 953
 						$the_form_general_content .= $input;
954
-						if ( ($input_def['label'] == 'frontend_input') && !is_object($editedItem) ) {
954
+						if (($input_def['label'] == 'frontend_input') && !is_object($editedItem)) {
955 955
 
956
-							$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id,  self::getDbTable(), self::currentPageCode);
956
+							$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode);
957 957
 
958 958
 							$input = '
959 959
 		<tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_set_section" >
960
-			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_set_section" ><label for="'.self::currentPageCode.'_set_section" >' . __('Affect this new attribute to the set section', 'wpshop') . '</label></td>
960
+			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_set_section" ><label for="' . self::currentPageCode . '_set_section" >' . __('Affect this new attribute to the set section', 'wpshop') . '</label></td>
961 961
 			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_set_section" >' . $the_input . '</td>
962 962
 		</tr>';
963 963
 							$the_form_general_content .= $input;
964 964
 						}
965 965
 					}
966 966
 				}
967
-				else{
967
+				else {
968 968
 					$the_form_content_hidden .= '
969 969
 				' . $the_input;
970 970
 				}
@@ -980,17 +980,17 @@  discard block
 block discarded – undo
980 980
 		$section_content = $the_form_general_content;
981 981
 
982 982
 		ob_start();
983
-		include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php');
983
+		include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php');
984 984
 		$the_form_general_content = ob_get_contents();
985 985
 		ob_end_clean();
986 986
 
987 987
 		/** It is attribute TVA, add a button to calcilate price in mass **/
988
-		if ( !empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva' ) {
989
-			$the_form_general_content .= '<input type="button" data-nonce="' . wp_create_nonce( 'wps_update_products_prices' ) . '" id="wps_update_price_infos" value="' .__('Update all products price', 'wpshop').'" /> <img src="' .WPSHOP_LOADING_ICON. '" alt="" id="update_products_loader" /> <br/>';
990
-			$the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop' );
988
+		if (!empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva') {
989
+			$the_form_general_content .= '<input type="button" data-nonce="' . wp_create_nonce('wps_update_products_prices') . '" id="wps_update_price_infos" value="' . __('Update all products price', 'wpshop') . '" /> <img src="' . WPSHOP_LOADING_ICON . '" alt="" id="update_products_loader" /> <br/>';
990
+			$the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop');
991 991
 		}
992 992
 		if (!empty($the_form_option_content_list)) {
993
-			$the_form_option_content_section='';
993
+			$the_form_option_content_section = '';
994 994
 			foreach ($attribute_options_group as $group_name => $group_content) {
995 995
 				$section_content = '';
996 996
 				foreach ($group_content as $group_code) {
@@ -999,23 +999,23 @@  discard block
 block discarded – undo
999 999
 						unset($the_form_option_content_list[$group_code]);
1000 1000
 					}
1001 1001
 				}
1002
-				$section_legend = __($group_name,'wpshop');
1002
+				$section_legend = __($group_name, 'wpshop');
1003 1003
 				$section_page_code = self::currentPageCode;
1004 1004
 
1005 1005
 				ob_start();
1006
-				include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php');
1006
+				include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php');
1007 1007
 				$the_form_option_content_section .= ob_get_contents();
1008 1008
 				ob_end_clean();
1009 1009
 			}
1010 1010
 
1011 1011
 			/*	Check there are other attributes to display not in defined group	*/
1012 1012
 			if (!empty($the_form_option_content_list)) {
1013
-				$section_legend = __('General options','wpshop');
1013
+				$section_legend = __('General options', 'wpshop');
1014 1014
 				$section_content = implode('', $the_form_option_content_list);
1015 1015
 				$section_page_code = self::currentPageCode;
1016 1016
 
1017 1017
 				ob_start();
1018
-				include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php');
1018
+				include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php');
1019 1019
 				$the_form_option_content = ob_get_contents();
1020 1020
 				ob_end_clean();
1021 1021
 
@@ -1025,17 +1025,17 @@  discard block
 block discarded – undo
1025 1025
 		}
1026 1026
 
1027 1027
 		/*	Default content for the current page	*/
1028
-		$bloc_list[self::currentPageCode]['main_info']['title']=__('Main informations', 'wpshop');
1028
+		$bloc_list[self::currentPageCode]['main_info']['title'] = __('Main informations', 'wpshop');
1029 1029
 		$bloc_list[self::currentPageCode]['main_info']['content'] = $the_form_general_content;
1030 1030
 
1031
-		$bloc_list[self::currentPageCode]['options']['title']=__('Options', 'wpshop');
1032
-		$bloc_list[self::currentPageCode]['options']['content']=$the_form_option_content;
1031
+		$bloc_list[self::currentPageCode]['options']['title'] = __('Options', 'wpshop');
1032
+		$bloc_list[self::currentPageCode]['options']['content'] = $the_form_option_content;
1033 1033
 
1034
-		$action = !empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action' ] ) : '';
1034
+		$action = !empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
1035 1035
 		$the_form = '
1036 1036
 <form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="#" >
1037
-	' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (isset($action) && ($action != '') ? sanitize_text_field($action) : 'save') , 'hidden') . '
1038
-	' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no' , 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_EDITION_PAGE_LAYOUT) . '
1037
+	' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (isset($action) && ($action != '') ? sanitize_text_field($action) : 'save'), 'hidden') . '
1038
+	' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_EDITION_PAGE_LAYOUT) . '
1039 1039
 </form>
1040 1040
 <div title="' . __('Change data type for selected attribute', 'wpshop') . '" id="wpshop_dialog_change_select_data_type" ><div id="wpshop_dialog_change_select_data_type_container" ></div></div>';
1041 1041
 		$input_def['possible_value'] = wpshop_entities::get_entities_list();
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 		$the_form .= '
1054 1054
 <script type="text/javascript" >
1055 1055
 	wpshop(document).ready(function(){
1056
-		wpshopMainInterface("'.self::getDbTable().'", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '");
1056
+		wpshopMainInterface("'.self::getDbTable() . '", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '");
1057 1057
 
1058 1058
 		jQuery("#wpshop_dialog_duplicate_attribute").dialog({
1059 1059
 			autoOpen: false,
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 			dialogClass: "wpshop_uidialog_box",
1064 1064
 			resizable: false,
1065 1065
 			buttons:{
1066
-				"'.__('Duplicate', 'wpshop').'": function(){
1066
+				"'.__('Duplicate', 'wpshop') . '": function(){
1067 1067
 					var data = {
1068 1068
 						action: "wpshop_duplicate_attribute",
1069 1069
 						wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_duplicate_attribute") . '",
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 						}
1080 1080
 					}, "json");
1081 1081
 				},
1082
-				"'.__('Cancel', 'wpshop').'": function(){
1082
+				"'.__('Cancel', 'wpshop') . '": function(){
1083 1083
 					jQuery(this).dialog("close");
1084 1084
 					jQuery(".wpshop_duplicate_attribute_result").remove();
1085 1085
 				}
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 			dialogClass: "wpshop_uidialog_box",
1098 1098
 			resizable: false,
1099 1099
 			buttons:{
1100
-				"'.__('Change type', 'wpshop').'": function(){
1100
+				"'.__('Change type', 'wpshop') . '": function(){
1101 1101
 					var delete_entity = false;
1102 1102
 					if(jQuery("#delete_entity").is(":checked")){
1103 1103
 						var delete_entity = true;
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 						jQuery("#wpshop_dialog_change_select_data_type").dialog("close");
1121 1121
 					}, "json");
1122 1122
 				},
1123
-				"'.__('Cancel', 'wpshop').'": function(){
1123
+				"'.__('Cancel', 'wpshop') . '": function(){
1124 1124
 					jQuery(this).dialog("close");
1125 1125
 				}
1126 1126
 			}
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 			change_unit_list();
1161 1161
 		});';
1162 1162
 
1163
-		if ( !is_object($editedItem) )  {
1163
+		if (!is_object($editedItem)) {
1164 1164
 			$the_form .= '
1165 1165
 		jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").change(function(){
1166 1166
 			jQuery(".wpshop_attributes_edition_table_field_input_default_value").html(jQuery("#wpshopLoadingPicture").html());
@@ -1243,23 +1243,23 @@  discard block
 block discarded – undo
1243 1243
 	 *
1244 1244
 	 *	@return string $currentPageButton The html output code with the different button to add to the interface
1245 1245
 	 */
1246
-	function getPageFormButton($element_id = 0){
1246
+	function getPageFormButton($element_id = 0) {
1247 1247
 		$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add';
1248 1248
 		$currentPageButton = '';
1249 1249
 
1250 1250
 		 //$currentPageButton .= '<h2 class="cancelButton alignleft" ><a href="' . admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&amp;page=' . self::getListingSlug()) . '" class="button add-new-h2" >' . __('Back', 'wpshop') . '</a></h2>';
1251 1251
 
1252
-		if(($action == 'add') && (current_user_can('wpshop_add_attributes')))
1252
+		if (($action == 'add') && (current_user_can('wpshop_add_attributes')))
1253 1253
 			$currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />';
1254 1254
 
1255
-		elseif(current_user_can('wpshop_edit_attributes'))
1255
+		elseif (current_user_can('wpshop_edit_attributes'))
1256 1256
 		$currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />';
1257 1257
 
1258 1258
 		$attribute_undeletable = unserialize(WPSHOP_ATTRIBUTE_UNDELETABLE);
1259 1259
 		$attribute = self::getElement($element_id, "'valid', 'moderated', 'notused'", 'id');
1260
-		$attribute_code = !empty($attribute->code)?$attribute->code:'';
1261
-		if(current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable))
1262
-			$currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
1260
+		$attribute_code = !empty($attribute->code) ? $attribute->code : '';
1261
+		if (current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable))
1262
+			$currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_' . self::currentPageCode . '" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
1263 1263
 
1264 1264
 		return $currentPageButton;
1265 1265
 	}
@@ -1273,22 +1273,22 @@  discard block
 block discarded – undo
1273 1273
 	 *
1274 1274
 	 *	@return object $element_list A wordpress database object containing the attribute list
1275 1275
 	 */
1276
-	public static function getElement($element_id = '', $element_status = "'valid', 'moderated', 'notused'", $field_to_search = 'id', $list = false){
1276
+	public static function getElement($element_id = '', $element_status = "'valid', 'moderated', 'notused'", $field_to_search = 'id', $list = false) {
1277 1277
 
1278 1278
 		global $wpdb;
1279 1279
 		$element_list = array();
1280 1280
 		$moreQuery = "";
1281
-		$moreArgs = array( 1, );
1281
+		$moreArgs = array(1,);
1282 1282
 
1283
-		$orderby = !empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : '';
1284
-		$order = !empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : '';
1283
+		$orderby = !empty($_REQUEST['orderby']) ? sanitize_text_field($_REQUEST['orderby']) : '';
1284
+		$order = !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : '';
1285 1285
 
1286
-		if($element_id != ''){
1286
+		if ($element_id != '') {
1287 1287
 			$moreQuery .= "
1288 1288
 					AND CURRENT_ELEMENT." . $field_to_search . " = %s ";
1289 1289
 			$moreArgs[] = $element_id;
1290 1290
 		}
1291
-		if(!empty($orderby) && !empty($order)){
1291
+		if (!empty($orderby) && !empty($order)) {
1292 1292
 			$moreQuery .= "
1293 1293
 					ORDER BY " . $orderby . "  " . $order;
1294 1294
 		}
@@ -1297,15 +1297,15 @@  discard block
 block discarded – undo
1297 1297
 			"SELECT CURRENT_ELEMENT.*, ENTITIES.post_name as entity
1298 1298
 			FROM " . self::getDbTable() . " AS CURRENT_ELEMENT
1299 1299
 			INNER JOIN {$wpdb->posts} AS ENTITIES ON (ENTITIES.ID = CURRENT_ELEMENT.entity_id)
1300
-			WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status.") " . $moreQuery,
1300
+			WHERE %d AND CURRENT_ELEMENT.status IN (" . $element_status . ") " . $moreQuery,
1301 1301
 			$moreArgs
1302 1302
 		);
1303 1303
 
1304 1304
 		/*	Get the query result regarding on the function parameters. If there must be only one result or a collection	*/
1305
-		if(($element_id == '') || $list){
1305
+		if (($element_id == '') || $list) {
1306 1306
 			$element_list = $wpdb->get_results($query);
1307 1307
 		}
1308
-		else{
1308
+		else {
1309 1309
 			$element_list = $wpdb->get_row($query);
1310 1310
 		}
1311 1311
 
@@ -1327,43 +1327,43 @@  discard block
 block discarded – undo
1327 1327
 		$user_id = function_exists('is_user_logged_in') && is_user_logged_in() ? get_current_user_id() : '0';
1328 1328
 		$sent_attribute_list = array();
1329 1329
 
1330
-		if ( !empty($attributeToSet) ) {
1330
+		if (!empty($attributeToSet)) {
1331 1331
 			foreach ($attributeToSet as $attributeType => $attributeTypeDetails) {
1332 1332
 				/** Preparation des parametres permettant de supprimer les bonnes valeurs des attributs suivant la configuration de la boutique et de la methode de mise a jour */
1333 1333
 				$delete_current_attribute_values_params = array(
1334 1334
 					'entity_id' => $entityId,
1335 1335
 					'entity_type_id' => $entityTypeId
1336 1336
 				);
1337
-				if ( WPSHOP_ATTRIBUTE_VALUE_PER_USER ) {
1337
+				if (WPSHOP_ATTRIBUTE_VALUE_PER_USER) {
1338 1338
 					$delete_current_attribute_values_params['user_id'] = $user_id;
1339 1339
 				}
1340 1340
 
1341
-				if(!empty($attributeTypeDetails) && is_array($attributeTypeDetails)) {
1342
-					foreach($attributeTypeDetails as $attribute_code => $attributeValue) {
1341
+				if (!empty($attributeTypeDetails) && is_array($attributeTypeDetails)) {
1342
+					foreach ($attributeTypeDetails as $attribute_code => $attributeValue) {
1343 1343
 
1344
-						if ( $attributeType == 'decimal' ) {
1344
+						if ($attributeType == 'decimal') {
1345 1345
 							$attributeValue = str_replace(',', '.', $attributeValue);
1346 1346
 						}
1347
-						if ( ($attributeType == 'integer') && !is_array($attributeValue) ) {
1347
+						if (($attributeType == 'integer') && !is_array($attributeValue)) {
1348 1348
 							$attributeValue = (int)$attributeValue;
1349 1349
 						}
1350 1350
 						$more_query_params_values = array();
1351
-						if($attribute_code != 'unit') {
1351
+						if ($attribute_code != 'unit') {
1352 1352
 
1353 1353
 							$unit_id = 0;
1354
-							if(isset($attributeTypeDetails['unit'][$attribute_code])){
1354
+							if (isset($attributeTypeDetails['unit'][$attribute_code])) {
1355 1355
 								$unit_id = $attributeTypeDetails['unit'][$attribute_code];
1356 1356
 							}
1357 1357
 
1358 1358
 							$currentAttribute = self::getElement($attribute_code, "'valid'", 'code');
1359
-							if( !empty($currentAttribute) ){
1359
+							if (!empty($currentAttribute)) {
1360 1360
 								$sent_attribute_list[] = $currentAttribute->id;
1361 1361
 
1362 1362
 								/*	Enregistrement de la valeur actuelle de l'attribut dans la table d'historique si l'option historique est activee sur l'attribut courant	*/
1363
-								if (  $currentAttribute->is_historisable == 'yes') {
1363
+								if ($currentAttribute->is_historisable == 'yes') {
1364 1364
 									$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType . " WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d", $entityTypeId, $currentAttribute->id, $entityId);
1365 1365
 									$attribute_histo = $wpdb->get_results($query);
1366
-									if(!empty($attribute_histo)){
1366
+									if (!empty($attribute_histo)) {
1367 1367
 										$attribute_histo_content['status'] = 'valid';
1368 1368
 										$attribute_histo_content['creation_date'] = current_time('mysql', 0);
1369 1369
 										$attribute_histo_content['creation_date_value'] = $attribute_histo[0]->creation_date_value;
@@ -1381,8 +1381,8 @@  discard block
 block discarded – undo
1381 1381
 								}
1382 1382
 								$attributeValue = str_replace("\\", "", $attributeValue);
1383 1383
 
1384
-								if ( empty($from) || (!empty($attributeValue)) ) {
1385
-									$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($delete_current_attribute_values_params, array('attribute_id' => $currentAttribute->id)));
1384
+								if (empty($from) || (!empty($attributeValue))) {
1385
+									$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($delete_current_attribute_values_params, array('attribute_id' => $currentAttribute->id)));
1386 1386
 
1387 1387
 									/**	Insertion de la nouvelle valeur de l'attribut dans la base	*/
1388 1388
 									$query_params = array(
@@ -1396,32 +1396,32 @@  discard block
 block discarded – undo
1396 1396
 										'creation_date_value' => current_time('mysql', 0)
1397 1397
 									);
1398 1398
 									/**	Si l'attribut courant est contenu dans un tableau (exemple: select multiple) on lit tout le tableau et on enregistre chaque valeur separement	*/
1399
-									if(is_array($attributeValue)){
1400
-										foreach($attributeValue as $a){
1401
-											$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $a)));
1399
+									if (is_array($attributeValue)) {
1400
+										foreach ($attributeValue as $a) {
1401
+											$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($query_params, array('value' => $a)));
1402 1402
 										}
1403 1403
 									}
1404
-									else{
1405
-										$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $attributeValue)));
1406
-										wpeologs_ctr::log_datas_in_files( 'wpshop_attributes', array(
1404
+									else {
1405
+										$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($query_params, array('value' => $attributeValue)));
1406
+										wpeologs_ctr::log_datas_in_files('wpshop_attributes', array(
1407 1407
 											'object_id' 	=> $entityId,
1408
-											'message' 		=> __( 'Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue , 'wpshop' ) ), 0
1408
+											'message' 		=> __('Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue, 'wpshop') ), 0
1409 1409
 										);
1410 1410
 									}
1411 1411
 
1412 1412
 									/**	Dans le cas ou l'attribut courant est utilise dans l'interface permettant de trier les produits (option de l'attribut) on defini une meta specifique	*/
1413
-									if ( ( ($currentAttribute->is_used_for_sort_by == 'yes') || ($currentAttribute->is_searchable == 'yes'))  || ( $currentAttribute->is_filterable == 'yes') && !empty($attributeValue) ) :
1414
-										update_post_meta($entityId, '_'.$attribute_code, $attributeValue);
1413
+									if ((($currentAttribute->is_used_for_sort_by == 'yes') || ($currentAttribute->is_searchable == 'yes')) || ($currentAttribute->is_filterable == 'yes') && !empty($attributeValue)) :
1414
+										update_post_meta($entityId, '_' . $attribute_code, $attributeValue);
1415 1415
 									endif;
1416 1416
 
1417 1417
 									/**	Enregistrement de toutes les valeurs des attributs dans une meta du produit	*/
1418
-									$attribute_option = (!empty($_POST['attribute_option'][$attribute_code])) ? (array) $_POST['attribute_option'][$attribute_code] : null;
1418
+									$attribute_option = (!empty($_POST['attribute_option'][$attribute_code])) ? (array)$_POST['attribute_option'][$attribute_code] : null;
1419 1419
 									if (isset($attribute_option)) {
1420 1420
 										$value = self::get_attribute_type_select_option_info($attributeTypeDetails[$attribute_code], 'value');
1421 1421
 										if (strtolower($value) == 'yes') :
1422
-											update_post_meta($entityId, 'attribute_option_'.$attribute_code, $attribute_option);
1422
+											update_post_meta($entityId, 'attribute_option_' . $attribute_code, $attribute_option);
1423 1423
 										else :
1424
-											delete_post_meta($entityId, 'attribute_option_'.$attribute_code);
1424
+											delete_post_meta($entityId, 'attribute_option_' . $attribute_code);
1425 1425
 										endif;
1426 1426
 									}
1427 1427
 								}
@@ -1429,15 +1429,15 @@  discard block
 block discarded – undo
1429 1429
 						}
1430 1430
 					}
1431 1431
 
1432
-					if ( empty($from) ) {
1433
-						$query = $wpdb->prepare("SELECT value_id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType . " WHERE attribute_id NOT IN ('" . implode("', '", $sent_attribute_list) . "') AND entity_id = %d AND entity_type_id = %d", $entityId, $entityTypeId);
1432
+					if (empty($from)) {
1433
+						$query = $wpdb->prepare("SELECT value_id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType . " WHERE attribute_id NOT IN ('" . implode("', '", $sent_attribute_list) . "') AND entity_id = %d AND entity_type_id = %d", $entityId, $entityTypeId);
1434 1434
 						$attr_to_delete = $wpdb->get_results($query);
1435
-						if(!empty($attr_to_delete)){
1435
+						if (!empty($attr_to_delete)) {
1436 1436
 							foreach ($attr_to_delete as $value) {
1437
-								$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($delete_current_attribute_values_params, array('value_id' => $value->value_id)));
1438
-								wpeologs_ctr::log_datas_in_files( 'wpshop_attributes', array(
1437
+								$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($delete_current_attribute_values_params, array('value_id' => $value->value_id)));
1438
+								wpeologs_ctr::log_datas_in_files('wpshop_attributes', array(
1439 1439
 									'object_id' 	=> $entityId,
1440
-									'message' 		=> __( 'Remove the attribute : ' . $value->value_id, 'wpshop' ) ), 0
1440
+									'message' 		=> __('Remove the attribute : ' . $value->value_id, 'wpshop') ), 0
1441 1441
 								);
1442 1442
 							}
1443 1443
 						}
@@ -1463,7 +1463,7 @@  discard block
 block discarded – undo
1463 1463
 
1464 1464
 		$query_params = "";
1465 1465
 		$query_params_values = array($attributeId, $entityTypeId, $entityId);
1466
-		if(WPSHOP_ATTRIBUTE_VALUE_PER_USER && (isset($atribute_params['intrinsic']) && ($atribute_params['intrinsic'] != 'yes'))){
1466
+		if (WPSHOP_ATTRIBUTE_VALUE_PER_USER && (isset($atribute_params['intrinsic']) && ($atribute_params['intrinsic'] != 'yes'))) {
1467 1467
 			$query_params = "
1468 1468
 				AND ATTR_VAL.user_id = %d";
1469 1469
 			$query_params_values[] = get_current_user_id();
@@ -1479,20 +1479,20 @@  discard block
 block discarded – undo
1479 1479
 		);
1480 1480
 		$attributeValue = $wpdb->get_results($query);
1481 1481
 
1482
-		if ( ( (count($attributeValue) <= 1 ) && !empty($attributeValue[0]) ) && ( empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select') )) {
1482
+		if (((count($attributeValue) <= 1) && !empty($attributeValue[0])) && (empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select'))) {
1483 1483
 			$attributeValue = $attributeValue[0];
1484 1484
 		}
1485
-		else{
1485
+		else {
1486 1486
 			$entity_meta = get_post_meta($entityId, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true);
1487
-			if ( !empty($entity_meta) ) {
1487
+			if (!empty($entity_meta)) {
1488 1488
 				$query = $wpdb->prepare("SELECT code FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE id = %d AND entity_id = %d ", $attributeId, $entityTypeId);
1489 1489
 				$attribute_code = $wpdb->get_var($query);
1490 1490
 				$attributeValue = !empty($entity_meta[$attribute_code]) ? $entity_meta[$attribute_code] : null;
1491 1491
 			}
1492
-			if ( is_array($attributeValue) ) {
1492
+			if (is_array($attributeValue)) {
1493 1493
 				$tmp_array = array();
1494
-				if ( !empty($attributeValue) ) {
1495
-					foreach ( $attributeValue as $att ) {
1494
+				if (!empty($attributeValue)) {
1495
+					foreach ($attributeValue as $att) {
1496 1496
 						$obj = new stdClass();
1497 1497
 						$obj->value = $att;
1498 1498
 						$obj->unit_id = 0;
@@ -1523,9 +1523,9 @@  discard block
 block discarded – undo
1523 1523
 		$elements = array();
1524 1524
 		$elementsWithAttributeAndValues = self::get_attribute_list_for_item($entityId, $elementId, $language);
1525 1525
 
1526
-		foreach ( $elementsWithAttributeAndValues as $elementDefinition ) {
1526
+		foreach ($elementsWithAttributeAndValues as $elementDefinition) {
1527 1527
 			$arrayKey = $elementDefinition->attribute_id;
1528
-			if ( $keyForArray == 'code' ) {
1528
+			if ($keyForArray == 'code') {
1529 1529
 				$arrayKey = $elementDefinition->attribute_code;
1530 1530
 			}
1531 1531
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['code'] = $elementDefinition->attribute_set_section_code;
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['backend_table'] = $elementDefinition->backend_table;
1536 1536
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['backend_input'] = $elementDefinition->backend_input;
1537 1537
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_input'] = $elementDefinition->frontend_input;
1538
-			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_label'] = __( $elementDefinition->frontend_label, 'wpshop' );
1538
+			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_label'] = __($elementDefinition->frontend_label, 'wpshop');
1539 1539
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['attribute_code'] = $elementDefinition->attribute_code;
1540 1540
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['data_type_to_use'] = $elementDefinition->data_type_to_use;
1541 1541
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['is_visible_in_front'] = $elementDefinition->is_visible_in_front;
@@ -1545,29 +1545,29 @@  discard block
 block discarded – undo
1545 1545
 			$attributeValueField = 'attribute_value_' . $elementDefinition->data_type;
1546 1546
 
1547 1547
 			// Manage the value differently if it is an array or not
1548
-			if ( !empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value']) ) {
1548
+			if (!empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) {
1549 1549
 				if (is_array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) {
1550 1550
 					$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'][] = $elementDefinition->$attributeValueField;
1551 1551
 				}
1552 1552
 				else {
1553
-					$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'],$elementDefinition->$attributeValueField);
1553
+					$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'], $elementDefinition->$attributeValueField);
1554 1554
 				}
1555 1555
 			}
1556 1556
 			else {
1557 1557
 				$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = $elementDefinition->$attributeValueField;
1558 1558
 			}
1559 1559
 
1560
-			if ( $elementDefinition->backend_input == 'multiple-select' ) {
1560
+			if ($elementDefinition->backend_input == 'multiple-select') {
1561 1561
 				$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['select_value'] = self::get_attribute_type_select_option_info($attributeValueField, 'value');
1562 1562
 			}
1563 1563
 
1564 1564
 			$attributeUnitField = 'attribute_unit_' . $elementDefinition->data_type;
1565
-			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __( $elementDefinition->$attributeUnitField, 'wpshop' );
1566
-			if( !empty($elementDefinition->is_requiring_unit ) && ( $elementDefinition->is_requiring_unit == 'yes' ) && empty( $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] ) ) {
1565
+			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __($elementDefinition->$attributeUnitField, 'wpshop');
1566
+			if (!empty($elementDefinition->is_requiring_unit) && ($elementDefinition->is_requiring_unit == 'yes') && empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'])) {
1567 1567
 				$unit = '';
1568
-				$query = $wpdb->prepare( 'SELECT unit FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d AND status = %s', $elementDefinition->_default_unit, 'valid');
1569
-				$unit = $wpdb->get_var( $query );
1570
-				$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __( $unit, 'wpshop' );
1568
+				$query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d AND status = %s', $elementDefinition->_default_unit, 'valid');
1569
+				$unit = $wpdb->get_var($query);
1570
+				$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __($unit, 'wpshop');
1571 1571
 			}
1572 1572
 
1573 1573
 		}
@@ -1579,7 +1579,7 @@  discard block
 block discarded – undo
1579 1579
 		$elementsWithAttributeAndValues = array();
1580 1580
 		$moreQuery = "";
1581 1581
 
1582
-		$entity_type = empty($defined_entity_type) ? get_post_type( $elementId ) : $defined_entity_type;
1582
+		$entity_type = empty($defined_entity_type) ? get_post_type($elementId) : $defined_entity_type;
1583 1583
 
1584 1584
 		$query = $wpdb->prepare(
1585 1585
 				"SELECT POST_META.*,
@@ -1628,23 +1628,23 @@  discard block
 block discarded – undo
1628 1628
 	 *
1629 1629
 	 * @return boolean The result to know if the element has to be displayed on frontend
1630 1630
 	 */
1631
-	public static function check_attribute_display( $attribute_main_config, $attribute_custom_config, $attribute_or_set, $attribute_code, $output_type) {
1632
-		if ( $attribute_main_config === 'yes' ) {
1631
+	public static function check_attribute_display($attribute_main_config, $attribute_custom_config, $attribute_or_set, $attribute_code, $output_type) {
1632
+		if ($attribute_main_config === 'yes') {
1633 1633
 			$attribute_output = true;
1634
-			if ( ( is_array($attribute_custom_config) && in_array($attribute_or_set, array('attribute', 'attribute_set_section', 'product_action_button')) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes' )
1635
-				 || empty($attribute_custom_config) ) {
1634
+			if ((is_array($attribute_custom_config) && in_array($attribute_or_set, array('attribute', 'attribute_set_section', 'product_action_button')) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes')
1635
+				 || empty($attribute_custom_config)) {
1636 1636
 				$attribute_output = true;
1637 1637
 			}
1638
-			else if ( empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no')) )  {
1638
+			else if (empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no'))) {
1639 1639
 				$attribute_output = false;
1640 1640
 			}
1641 1641
 		}
1642
-		elseif ( $attribute_main_config === 'no' ) {
1642
+		elseif ($attribute_main_config === 'no') {
1643 1643
 			$attribute_output = false;
1644
-			if ( empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code]) ) {
1644
+			if (empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code])) {
1645 1645
 				$attribute_output = false;
1646 1646
 			}
1647
-			else if ( !empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes') )  {
1647
+			else if (!empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes')) {
1648 1648
 				$attribute_output = true;
1649 1649
 			}
1650 1650
 		}
@@ -1661,22 +1661,22 @@  discard block
 block discarded – undo
1661 1661
 		global $wpdb;
1662 1662
 		global $wp_query;
1663 1663
 
1664
-		$attribute = self::getElement( $atts['attid'] );
1665
-		if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID;
1666
-		$attribute_main_config = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing;
1667
-		$output_type = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? 'complete_sheet' : 'mini_output';
1664
+		$attribute = self::getElement($atts['attid']);
1665
+		if (empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID;
1666
+		$attribute_main_config = (empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet')) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing;
1667
+		$output_type = (empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet')) ? 'complete_sheet' : 'mini_output';
1668 1668
 		$product_attribute_custom_config = get_post_meta($atts['pid'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, true);
1669
-		$display_attribute_value = wpshop_attributes::check_attribute_display( $attribute_main_config, $product_attribute_custom_config, 'attribute', $attribute->code, $output_type);
1669
+		$display_attribute_value = wpshop_attributes::check_attribute_display($attribute_main_config, $product_attribute_custom_config, 'attribute', $attribute->code, $output_type);
1670 1670
 
1671
-		if ( !empty( $attribute->data_type ) ) {
1671
+		if (!empty($attribute->data_type)) {
1672 1672
 			$attributeDefinition['unit'] = '';
1673 1673
 
1674 1674
 			$has_value = false;
1675
-			$query = $wpdb->prepare("SELECT value FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attribute->data_type . " WHERE entity_id=%s AND attribute_id=%d", $atts['pid'], $atts['attid'] );
1676
-			if ( in_array($attribute->backend_input, array('multiple-select', 'checkbox')) ) {
1675
+			$query = $wpdb->prepare("SELECT value FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attribute->data_type . " WHERE entity_id=%s AND attribute_id=%d", $atts['pid'], $atts['attid']);
1676
+			if (in_array($attribute->backend_input, array('multiple-select', 'checkbox'))) {
1677 1677
 				$list_of_value = $wpdb->get_results($query);
1678
-				if ( !empty($list_of_value) ) {
1679
-					foreach ( $list_of_value as $value ) {
1678
+				if (!empty($list_of_value)) {
1679
+					foreach ($list_of_value as $value) {
1680 1680
 						$data[] = $value->value;
1681 1681
 					}
1682 1682
 					$has_value = true;
@@ -1684,10 +1684,10 @@  discard block
 block discarded – undo
1684 1684
 			}
1685 1685
 			else {
1686 1686
 				$data = $wpdb->get_var($query);
1687
-				if ( !empty($data) ) {
1687
+				if (!empty($data)) {
1688 1688
 					$has_value = true;
1689 1689
 				}
1690
-				elseif( !empty($attribute->default_value) ) {
1690
+				elseif (!empty($attribute->default_value)) {
1691 1691
 					$has_value = true;
1692 1692
 					$data = $attribute->default_value;
1693 1693
 				}
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
 			$attributeDefinition['is_requiring_unit'] = $attribute->is_requiring_unit;
1700 1700
 			$attributeDefinition['backend_input'] = $attribute->backend_input;
1701 1701
 			$attributeDefinition['data_type_to_use'] = $attribute->data_type_to_use;
1702
-			$attribute_display = wpshop_attributes::wps_attribute_values_display( $attributeDefinition );
1702
+			$attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition);
1703 1703
 			$attribute_value = $attribute_display[0];
1704 1704
 			$attributeDefinition['value'] = $attribute_display[1];
1705 1705
 			$attribute_unit_list = $attribute_display[2];
@@ -1719,13 +1719,13 @@  discard block
 block discarded – undo
1719 1719
 	 * @param array $specific_argument Optionnal The different parameters used for filter output
1720 1720
 	 * @return array The definition for the field used to display an attribute
1721 1721
 	 */
1722
-	public static function get_attribute_field_definition( $attribute, $attribute_value = '', $specific_argument = array() ) {
1722
+	public static function get_attribute_field_definition($attribute, $attribute_value = '', $specific_argument = array()) {
1723 1723
 		global $wpdb;
1724 1724
 		$wpshop_price_attributes = unserialize(WPSHOP_ATTRIBUTE_PRICES);
1725 1725
 		$wpshop_weight_attributes = unserialize(WPSHOP_ATTRIBUTE_WEIGHT);
1726 1726
 		$input_def = array();
1727 1727
 		$input_def['option'] = $input_def['field_container_class'] = '';
1728
-		$attributeInputDomain = (!empty($specific_argument['field_custom_name_prefix']) || (!empty($specific_argument['field_custom_name_prefix']) && ($specific_argument['field_custom_name_prefix'] == 'empty')) ) ? $specific_argument['field_custom_name_prefix'] : ((!empty($specific_argument['page_code']) ? $specific_argument['page_code'] . '_' : '' ) . 'attribute[' . $attribute->data_type . ']');
1728
+		$attributeInputDomain = (!empty($specific_argument['field_custom_name_prefix']) || (!empty($specific_argument['field_custom_name_prefix']) && ($specific_argument['field_custom_name_prefix'] == 'empty'))) ? $specific_argument['field_custom_name_prefix'] : ((!empty($specific_argument['page_code']) ? $specific_argument['page_code'] . '_' : '') . 'attribute[' . $attribute->data_type . ']');
1729 1729
 		$input_def['input_domain'] = $attributeInputDomain;
1730 1730
 		$input_def['id'] = (!empty($specific_argument) && !empty($specific_argument['field_id']) ? $specific_argument['field_id'] . '_' : '') . 'attribute_' . $attribute->id;
1731 1731
 		$input_def['intrinsec'] = $attribute->is_intrinsic;
@@ -1745,26 +1745,26 @@  discard block
 block discarded – undo
1745 1745
 		$input_def['frontend_type'] = $attribute->frontend_input;
1746 1746
 		$input_def['is_used_in_quick_add_form'] = $attribute->is_used_in_quick_add_form;
1747 1747
 
1748
-		if ( !empty($attribute_value) && !is_object($attribute_value) ) {
1748
+		if (!empty($attribute_value) && !is_object($attribute_value)) {
1749 1749
 			$input_def['value'] = $attribute_value;
1750 1750
 		}
1751
-		else if ( !empty($attribute_value->value) ) {
1751
+		else if (!empty($attribute_value->value)) {
1752 1752
 			$input_def['value'] = stripslashes($attribute_value->value);
1753 1753
 		}
1754
-		else if ( !empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft') ) {
1754
+		else if (!empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft')) {
1755 1755
 			$input_def['value'] = '';
1756 1756
 		}
1757 1757
 
1758 1758
 		$input_def['options'] = '';
1759 1759
 		$input_more_class = !empty($specific_argument['input_class']) ? $specific_argument['input_class'] : '';
1760 1760
 		if ($attribute->data_type == 'datetime') {
1761
-			$date_config = unserialize( $attribute->default_value );
1761
+			$date_config = unserialize($attribute->default_value);
1762 1762
 			if ((($date_config['default_value'] == '') || ($date_config['default_value'] == 'date_of_current_day')) && ($date_config['default_value'] == 'date_of_current_day')) {
1763 1763
 				$input_def['value'] = date('Y-m-d');
1764 1764
 			}
1765 1765
 			else {
1766 1766
 				/**	Modification due to a message on eoxia forum: http://www.eoxia.com/forums/topic/bug-attribut-de-type-date-dans-fiche-produit-admin/	*/
1767
-				$input_def['value'] = !empty($attribute_value->value) && is_string($attribute_value->value) ? str_replace( " 00:00:00", "", $attribute_value->value ) : ( !empty($attribute_value) && is_string($attribute_value) ? str_replace( " 00:00:00", "", $attribute_value ) : '' );
1767
+				$input_def['value'] = !empty($attribute_value->value) && is_string($attribute_value->value) ? str_replace(" 00:00:00", "", $attribute_value->value) : (!empty($attribute_value) && is_string($attribute_value) ? str_replace(" 00:00:00", "", $attribute_value) : '');
1768 1768
 			}
1769 1769
 			$input_more_class .= ' wpshop_input_datetime ';
1770 1770
 			$field_script = '<script type="text/javascript" >
@@ -1777,31 +1777,31 @@  discard block
 block discarded – undo
1777 1777
 		wpshop("#' . $input_def['id'] . '").datepicker("option", "navigationAsDateFormat", true);
1778 1778
 		wpshop("#' . $input_def['id'] . '").val("' . str_replace(" 00:00:00", "", $input_def['value']) . '");';
1779 1779
 
1780
-			if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']) ) {
1781
-				if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0]) ) {
1780
+			if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur'])) {
1781
+				if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0])) {
1782 1782
 					$field_script .= '
1783 1783
 		wpshop("#' . $input_def['id'] . '").datepicker("option", "minDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0] . '");';
1784 1784
 				}
1785
-				if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0]) ) {
1785
+				if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0])) {
1786 1786
 					$field_script .= '
1787 1787
 		wpshop("#' . $input_def['id'] . '").datepicker("option", "maxDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0] . '");';
1788 1788
 				}
1789 1789
 			}
1790 1790
 
1791 1791
 			$script_options = $script_options_params = array();
1792
-			if ( !empty($date_config['field_options']['attribute_type_date_options_day_to_show']) ) {
1792
+			if (!empty($date_config['field_options']['attribute_type_date_options_day_to_show'])) {
1793 1793
 				$day_to_show_list = '    ';
1794
-				foreach ( $date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show ) {
1794
+				foreach ($date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show) {
1795 1795
 					$day_to_show_list .= '(date.getDay() == ' . $day_to_show . ') || ';
1796 1796
 				}
1797 1797
 				$script_options[] = '( ' . substr($day_to_show_list, 0, -4) . ' )';
1798 1798
 			}
1799 1799
 
1800
-			if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0]) ) {
1801
-				if ( !empty($date_config['field_options']['attribute_type_date_options_available_date']) ) {
1800
+			if (!empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0])) {
1801
+				if (!empty($date_config['field_options']['attribute_type_date_options_available_date'])) {
1802 1802
 					$available_date = ' ';
1803
-					foreach ( $date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list ) {
1804
-						if ( !empty($avalaible_date_list) ) {
1803
+					foreach ($date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list) {
1804
+						if (!empty($avalaible_date_list)) {
1805 1805
 							$available_date .= '"' . $avalaible_date_list . '",';
1806 1806
 						}
1807 1807
 					}
@@ -1810,7 +1810,7 @@  discard block
 block discarded – undo
1810 1810
 				}
1811 1811
 			}
1812 1812
 
1813
-			if ( !empty( $script_options ) ) {
1813
+			if (!empty($script_options)) {
1814 1814
 				$field_script .= '
1815 1815
 		wpshop("#' . $input_def['id'] . '").datepicker("option", "beforeShowDay", function(date){
1816 1816
 			' . implode(' ', $script_options_params) . ';
@@ -1838,37 +1838,37 @@  discard block
 block discarded – undo
1838 1838
 </script>';
1839 1839
 			$input_def['options'] .= $field_script;
1840 1840
 		}
1841
-		if ( in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) {
1842
-			$input_more_class .= (!empty($specific_argument['no_chosen']) ? '' : ' chosen_select ' );
1841
+		if (in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) {
1842
+			$input_more_class .= (!empty($specific_argument['no_chosen']) ? '' : ' chosen_select ');
1843 1843
 			$input_def['type'] = ((!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend')) || (!is_admin() && empty($specific_argument['from'])) ? $attribute->frontend_input : $attribute->backend_input);
1844 1844
 			$input_def['valueToPut'] = 'index';
1845 1845
 
1846 1846
 			$select_display = self::get_select_output($attribute, $specific_argument);
1847
-			if ( empty( $input_def[ 'options_label' ] ) && !empty( $specific_argument ) && (!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend') ) ) {
1848
-				$input_def[ 'options_label' ][ 'original' ] = true;
1847
+			if (empty($input_def['options_label']) && !empty($specific_argument) && (!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend'))) {
1848
+				$input_def['options_label']['original'] = true;
1849 1849
 			}
1850 1850
 			$input_def['options'] .= $select_display['more_input'];
1851 1851
 			$input_def['possible_value'] = (!empty($select_display) && !empty($select_display['possible_value'])) ? $select_display['possible_value'] : '';
1852
-			if ( !is_admin() ) {
1852
+			if (!is_admin()) {
1853 1853
 				$input_def['options'] .= '<input type="hidden" value="' . str_replace("\\", "", $input_def['value']) . '" name="wpshop_product_attribute_' . $attribute->code . '_current_value" id="wpshop_product_attribute_' . $attribute->code . '_current_value" />';
1854 1854
 			}
1855
-			if ( in_array($attribute->backend_input, array('multiple-select', 'checkbox')) && is_admin() && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend')) ) {
1856
-				$input_def['options'] .= wpshop_display::display_template_element('select_list_multiple_bulk_action', array( 'CURRENT_ATTRIBUTE_ID' => $input_def['id'], 'CURRENT_ATTRIBUTE_CODE' => $attribute->code), array(), 'admin');
1855
+			if (in_array($attribute->backend_input, array('multiple-select', 'checkbox')) && is_admin() && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend'))) {
1856
+				$input_def['options'] .= wpshop_display::display_template_element('select_list_multiple_bulk_action', array('CURRENT_ATTRIBUTE_ID' => $input_def['id'], 'CURRENT_ATTRIBUTE_CODE' => $attribute->code), array(), 'admin');
1857 1857
 			}
1858 1858
 		}
1859 1859
 		$input_def['label_pointer'] = 'for="' . $input_def['id'] . '"';
1860
-		if(($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')){
1860
+		if (($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')) {
1861 1861
 			$input_def['label_pointer'] = '';
1862 1862
 		}
1863 1863
 
1864 1864
 		/*
1865 1865
 		 * Specifc treatment for price attributes
1866 1866
 		 */
1867
-		if((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC) ){
1867
+		if ((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC)) {
1868 1868
 			$input_def['option'] .= ' readonly="readonly" ';
1869 1869
 			$input_more_class .= ' wpshop_prices_readonly';
1870 1870
 		}
1871
-		elseif((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT) ){
1871
+		elseif ((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT)) {
1872 1872
 			$input_def['option'] .= ' readonly="readonly" ';
1873 1873
 			$input_more_class .= ' wpshop_prices_readonly';
1874 1874
 		}
@@ -1879,7 +1879,7 @@  discard block
 block discarded – undo
1879 1879
 
1880 1880
 		$input_def['label'] = str_replace("\\", "", $input_def['label']);
1881 1881
 // 		$input_def['value'] = str_replace("\\", "", $input_def['value']);
1882
-		$input_def['option'] .= ' class="wpshop_product_attribute_' . $attribute->code . $input_more_class . ' ' . (( is_admin() ) ? $attribute->backend_css_class : $attribute->frontend_css_class) . ( !empty($attribute->frontend_verification) ? ' wps_attr_verification_' . $attribute->frontend_verification : '' ) . '" ';
1882
+		$input_def['option'] .= ' class="wpshop_product_attribute_' . $attribute->code . $input_more_class . ' ' . ((is_admin()) ? $attribute->backend_css_class : $attribute->frontend_css_class) . (!empty($attribute->frontend_verification) ? ' wps_attr_verification_' . $attribute->frontend_verification : '') . '" ';
1883 1883
 		$input_def['title'] = !empty($attribute->frontend_help_message) ? ' title="' . $attribute->frontend_help_message . '" ' : '';
1884 1884
 
1885 1885
 		if (($attribute->is_intrinsic == 'yes') && ((!empty($input_def['value'])) || ($input_def['value'] > 0))) {
@@ -1890,13 +1890,13 @@  discard block
 block discarded – undo
1890 1890
 		 * Add the unit to the attribute if attribute configuration is set to yes
1891 1891
 		 */
1892 1892
 		if ($attribute->is_requiring_unit == 'yes') {
1893
-			if ( in_array($attribute->code, $wpshop_price_attributes) || ( WPSHOP_COST_OF_POSTAGE == $attribute->code) ) {
1893
+			if (in_array($attribute->code, $wpshop_price_attributes) || (WPSHOP_COST_OF_POSTAGE == $attribute->code)) {
1894 1894
 				$input_def['options'] .= '&nbsp;<span class="attribute_currency" id="attribute_currency_' . $attribute->id . '" >' . wpshop_tools::wpshop_get_currency() . '</span>';
1895 1895
 			}
1896
-			elseif ( in_array($attribute->code, $wpshop_weight_attributes) ) {
1896
+			elseif (in_array($attribute->code, $wpshop_weight_attributes)) {
1897 1897
 				$weight_defaut_unity_option = get_option('wpshop_shop_default_weight_unity');
1898
-				$query = $wpdb->prepare('SELECT name FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option);
1899
-				$unity = $wpdb->get_var( $query );
1898
+				$query = $wpdb->prepare('SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option);
1899
+				$unity = $wpdb->get_var($query);
1900 1900
 				$input_def['options'] .= '&nbsp;<span class="attribute_weight" id="attribute_weight_' . $attribute->id . '" >' . __($unity, 'wpshop') . '</span>';
1901 1901
 			}
1902 1902
 			else {
@@ -1904,11 +1904,11 @@  discard block
 block discarded – undo
1904 1904
 				$unit_input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group($attribute->_unit_group_id);
1905 1905
 				$unit_input_def['type'] = 'select';
1906 1906
 				$unit_input_def['option'] = ' class="wpshop_attribute_unit_input chosen_select" ';
1907
-				$unit_input_def['id'] = ( !empty($specific_argument['page_code']) ? $specific_argument['page_code'] : null ) . '_' . ( !empty($specific_argument['element_identifier']) ? $specific_argument['element_identifier'] : null ) . '_unit_attribute_' . $attribute->id;
1907
+				$unit_input_def['id'] = (!empty($specific_argument['page_code']) ? $specific_argument['page_code'] : null) . '_' . (!empty($specific_argument['element_identifier']) ? $specific_argument['element_identifier'] : null) . '_unit_attribute_' . $attribute->id;
1908 1908
 				$unit_input_def['name'] = $attribute->code;
1909 1909
 				$unit_input_def['value'] = (!empty($attribute_value->unit_id) ? $attribute_value->unit_id : '');
1910
-				if($unit_input_def['value'] == ''){
1911
-					if ( $attribute->_default_unit > 0 ) {
1910
+				if ($unit_input_def['value'] == '') {
1911
+					if ($attribute->_default_unit > 0) {
1912 1912
 						$unit_input_def['value'] = $attribute->_default_unit;
1913 1913
 					}
1914 1914
 					else {
@@ -1922,18 +1922,18 @@  discard block
 block discarded – undo
1922 1922
 		/*
1923 1923
 		 * Add indication on postage cost tax
1924 1924
 		 */
1925
-		if ( $attribute->code == WPSHOP_COST_OF_POSTAGE ) {
1925
+		if ($attribute->code == WPSHOP_COST_OF_POSTAGE) {
1926 1926
 			$input_def['options'] .= ' <span class="attribute_currency" >' . __('ATI', 'wpshop') . '</span>';
1927 1927
 		}
1928 1928
 
1929 1929
 		/*
1930 1930
 		 * Create the field output
1931 1931
 		 */
1932
-		if ( is_admin() && ($attribute->data_type == 'datetime') && ($attribute->is_user_defined == 'yes') && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend')) ) {
1933
-			$input_def['output'] = sprintf(__('You select this field to be defined by final customer into frontend part. To change this behaviour you have to change attribute option "%s"', 'wpshop'),__('is_user_defined', 'wpshop'));
1932
+		if (is_admin() && ($attribute->data_type == 'datetime') && ($attribute->is_user_defined == 'yes') && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend'))) {
1933
+			$input_def['output'] = sprintf(__('You select this field to be defined by final customer into frontend part. To change this behaviour you have to change attribute option "%s"', 'wpshop'), __('is_user_defined', 'wpshop'));
1934 1934
 			$input_def['options'] = '';
1935 1935
 			$input_def['label_pointer'] = '';
1936
-			$input_def['option'] = substr( $input_def['option'], 0 , -2 ) . ' wpshop_attributes_is_user_defined_admin_field "';
1936
+			$input_def['option'] = substr($input_def['option'], 0, -2) . ' wpshop_attributes_is_user_defined_admin_field "';
1937 1937
 			$input_def['field_container_class'] .= 'wpshop_attributes_is_user_defined_admin_container';
1938 1938
 		}
1939 1939
 		else {
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
 	 * @param string $output_from
1949 1949
 	 * @return string The output for
1950 1950
 	 */
1951
-	public static function display_attribute( $attribute_code, $output_from = 'admin', $output_specs = array() ) {
1951
+	public static function display_attribute($attribute_code, $output_from = 'admin', $output_specs = array()) {
1952 1952
 		$output = '';
1953 1953
 		/*	Get the page code	*/
1954 1954
 		$currentPageCode = !empty($output_specs['page_code']) ? $output_specs['page_code'] : '';
@@ -1959,17 +1959,17 @@  discard block
 block discarded – undo
1959 1959
 
1960 1960
 		/*	Get attribute input definition	*/
1961 1961
 		$current_value = (!empty($output_specs['current_value']) ? $output_specs['current_value'] : '');
1962
-		$input = wpshop_attributes::get_attribute_field_definition( $attribute_def, $current_value, array_merge($output_specs, array('input_class' => ' wpshop_attributes_display', 'from' => $output_from)) );
1962
+		$input = wpshop_attributes::get_attribute_field_definition($attribute_def, $current_value, array_merge($output_specs, array('input_class' => ' wpshop_attributes_display', 'from' => $output_from)));
1963 1963
 
1964 1964
 		/*	Create default output	*/
1965 1965
 		$input_to_display = $input['output'] . $input['options'];
1966 1966
 
1967 1967
 		/*	Check if current field is linked to an addon, and if the addon is activated	*/
1968 1968
 		$addons_list = unserialize(WPSHOP_ADDONS_LIST);
1969
-		foreach ( $addons_list as $addon_code => $addon_def ) {
1970
-			if ( in_array($attribute_code, $addon_def) ) {
1971
-				if ( constant($addon_code) === false ) {
1972
-					$input_to_display = '<a href="' . admin_url('options-general.php?page=wpshop_option#wpshop_addons_option') . '" >' . __("This addon isn't activated, click to activate",'wpshop') . '</a>';
1969
+		foreach ($addons_list as $addon_code => $addon_def) {
1970
+			if (in_array($attribute_code, $addon_def)) {
1971
+				if (constant($addon_code) === false) {
1972
+					$input_to_display = '<a href="' . admin_url('options-general.php?page=wpshop_option#wpshop_addons_option') . '" >' . __("This addon isn't activated, click to activate", 'wpshop') . '</a>';
1973 1973
 				}
1974 1974
 			}
1975 1975
 		}
@@ -1994,11 +1994,11 @@  discard block
 block discarded – undo
1994 1994
 		/*
1995 1995
 		 * Display attribute option if applicable
1996 1996
 		 */
1997
-		if ( $output_from == 'admin') {
1998
-			$attribute_option_display = $attribute_def->backend_input=='select' && (strtolower( __(self::get_attribute_type_select_option_info($input['value'], 'value'), 'wpshop') ) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide';
1997
+		if ($output_from == 'admin') {
1998
+			$attribute_option_display = $attribute_def->backend_input == 'select' && (strtolower(__(self::get_attribute_type_select_option_info($input['value'], 'value'), 'wpshop')) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide';
1999 1999
 
2000 2000
 			$output['field'] .= '
2001
-	<div class="attribute_option_'.$attribute_def->code.''.$attribute_option_display.'">'.self::get_attribute_option_fields($element_identifier, $attribute_def->code).'</div>';
2001
+	<div class="attribute_option_'.$attribute_def->code . '' . $attribute_option_display . '">' . self::get_attribute_option_fields($element_identifier, $attribute_def->code) . '</div>';
2002 2002
 		}
2003 2003
 
2004 2004
 		$output['field'] .= '</div>';
@@ -2016,36 +2016,36 @@  discard block
 block discarded – undo
2016 2016
 	 *
2017 2017
 	 * @return string The html code to output directly tabs
2018 2018
 	 */
2019
-	public static function attribute_of_entity_to_tab( $element_code, $element_id, $element_definition ) {
2019
+	public static function attribute_of_entity_to_tab($element_code, $element_id, $element_definition) {
2020 2020
 		$attributeContentOutput = '';
2021 2021
 
2022 2022
 		/**	Get the different attribute affected to the entity	*/
2023 2023
 		$element_atribute_list = wpshop_attributes::getElementWithAttributeAndValue($element_code, $element_id, WPSHOP_CURRENT_LOCALE, '', 'frontend');
2024 2024
 
2025 2025
 
2026
-		if ( is_array($element_atribute_list) && (count($element_atribute_list) > 0) ) {
2027
-			foreach ( $element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent ) {
2026
+		if (is_array($element_atribute_list) && (count($element_atribute_list) > 0)) {
2027
+			foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) {
2028 2028
 				$attributeToShowNumber = 0;
2029 2029
 				$attributeOutput = '';
2030 2030
 
2031
-				foreach ( $attributeSetContent['attributes'] as $attributeId => $attributeDefinition ) {
2031
+				foreach ($attributeSetContent['attributes'] as $attributeId => $attributeDefinition) {
2032 2032
 
2033 2033
 					/**	Check the value type to check if empty or not	*/
2034
-					if ( $attributeDefinition['data_type'] == 'int' ) {
2034
+					if ($attributeDefinition['data_type'] == 'int') {
2035 2035
 						$attributeDefinition['value'] = (int)$attributeDefinition['value'];
2036 2036
 					}
2037
-					else if ( $attributeDefinition['data_type'] == 'decimal' ) {
2037
+					else if ($attributeDefinition['data_type'] == 'decimal') {
2038 2038
 						$attributeDefinition['value'] = (float)$attributeDefinition['value'];
2039 2039
 					}
2040 2040
 
2041 2041
 					/** Check if the attribute is set to be displayed in frontend	*/
2042
-					$attribute_display_state = wpshop_attributes::check_attribute_display( $attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet');
2042
+					$attribute_display_state = wpshop_attributes::check_attribute_display($attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet');
2043 2043
 
2044 2044
 					/**	Output the field if the value is not null	*/
2045 2045
 
2046
-					if ( (is_array($attributeDefinition['value']) || ( !empty($attributeDefinition['value']) ) ) && $attribute_display_state) {
2046
+					if ((is_array($attributeDefinition['value']) || (!empty($attributeDefinition['value']))) && $attribute_display_state) {
2047 2047
 
2048
-						$attribute_display = wpshop_attributes::wps_attribute_values_display( $attributeDefinition );
2048
+						$attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition);
2049 2049
 						$attribute_value = $attribute_display[0];
2050 2050
 						$attributeDefinition['value'] = $attribute_display[1];
2051 2051
 						$attribute_unit_list = $attribute_display[2];
@@ -2056,8 +2056,8 @@  discard block
 block discarded – undo
2056 2056
 						$tpl_component['PDT_ENTITY_CODE'] = self::currentPageCode;
2057 2057
 						$tpl_component['ATTRIBUTE_CODE'] = $attributeDefinition['attribute_code'];
2058 2058
 						$tpl_component['ATTRIBUTE_LABEL'] = __($attributeDefinition['frontend_label'], 'wpshop');
2059
-						$tpl_component['ATTRIBUTE_VALUE'] = (  !is_array($attribute_value) ) ? stripslashes($attribute_value) : $attribute_value;
2060
-						$tpl_component['ATTRIBUTE_VALUE_UNIT'] =  $attribute_unit_list;
2059
+						$tpl_component['ATTRIBUTE_VALUE'] = (!is_array($attribute_value)) ? stripslashes($attribute_value) : $attribute_value;
2060
+						$tpl_component['ATTRIBUTE_VALUE_UNIT'] = $attribute_unit_list;
2061 2061
 
2062 2062
 						/** Build template	*/
2063 2063
 						$attributeOutput .= wpshop_display::display_template_element($template_part, $tpl_component);
@@ -2068,9 +2068,9 @@  discard block
 block discarded – undo
2068 2068
 				}
2069 2069
 
2070 2070
 				/** Check if the attribute set section is set to be displayed in frontend	*/
2071
-				$attribute_set_display_state = wpshop_attributes::check_attribute_display( $attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet');
2071
+				$attribute_set_display_state = wpshop_attributes::check_attribute_display($attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet');
2072 2072
 
2073
-				if ( !$attribute_set_display_state ) {
2073
+				if (!$attribute_set_display_state) {
2074 2074
 					$attributeToShowNumber = 0;
2075 2075
 					$attributeOutput = '';
2076 2076
 				}
@@ -2080,8 +2080,8 @@  discard block
 block discarded – undo
2080 2080
 
2081 2081
 			/** Gestion de l'affichage	*/
2082 2082
 			$tab_list = $content_list = '';
2083
-			foreach ( $element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent ) {
2084
-				if ( !empty($attributeSetContent['count']) > 0 ) {
2083
+			foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) {
2084
+				if (!empty($attributeSetContent['count']) > 0) {
2085 2085
 					/** Template parameters	*/
2086 2086
 					$template_part = 'product_attribute_tabs';
2087 2087
 					$tpl_component = array();
@@ -2090,7 +2090,7 @@  discard block
 block discarded – undo
2090 2090
 
2091 2091
 					/** Build template	*/
2092 2092
 					$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2093
-					if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2093
+					if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2094 2094
 						/*	Include the old way template part	*/
2095 2095
 						ob_start();
2096 2096
 						require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2110,7 +2110,7 @@  discard block
 block discarded – undo
2110 2110
 
2111 2111
 					/** Build template	*/
2112 2112
 					$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2113
-					if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2113
+					if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2114 2114
 						/*	Include the old way template part	*/
2115 2115
 						ob_start();
2116 2116
 						require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2124,16 +2124,16 @@  discard block
 block discarded – undo
2124 2124
 				}
2125 2125
 			}
2126 2126
 
2127
-			if ( $tab_list != '' ) {
2127
+			if ($tab_list != '') {
2128 2128
 				/** Template parameters	*/
2129 2129
 				$template_part = 'product_attribute_container';
2130 2130
 				$tpl_component = array();
2131
-				$tpl_component['PDT_TABS'] = apply_filters( 'wpshop_extra_tabs_menu_before', '' ).$tab_list.apply_filters( 'wpshop_extra_tabs_menu_after', '' );
2132
-				$tpl_component['PDT_TAB_DETAIL'] = apply_filters( 'wpshop_extra_tabs_content_before', '' ).$content_list.apply_filters( 'wpshop_extra_tabs_content_after', '' );
2131
+				$tpl_component['PDT_TABS'] = apply_filters('wpshop_extra_tabs_menu_before', '') . $tab_list . apply_filters('wpshop_extra_tabs_menu_after', '');
2132
+				$tpl_component['PDT_TAB_DETAIL'] = apply_filters('wpshop_extra_tabs_content_before', '') . $content_list . apply_filters('wpshop_extra_tabs_content_after', '');
2133 2133
 
2134 2134
 				/** Build template	*/
2135 2135
 				$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2136
-				if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2136
+				if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2137 2137
 					/*	Include the old way template part	*/
2138 2138
 					ob_start();
2139 2139
 					require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2156,9 +2156,9 @@  discard block
 block discarded – undo
2156 2156
 	 * @param unknown_type $attributeDefinition
2157 2157
 	 * @return multitype:Ambigous <unknown, string> Ambigous <string, string> Ambigous <>
2158 2158
 	 */
2159
-	public static function wps_attribute_values_display( $attributeDefinition ) {
2159
+	public static function wps_attribute_values_display($attributeDefinition) {
2160 2160
 		$attribute_unit_list = '';
2161
-		if ( !empty($attributeDefinition['unit']) ) {
2161
+		if (!empty($attributeDefinition['unit'])) {
2162 2162
 			/** Template parameters	*/
2163 2163
 			$template_part = 'product_attribute_unit';
2164 2164
 			$tpl_component = array();
@@ -2170,31 +2170,31 @@  discard block
 block discarded – undo
2170 2170
 		}
2171 2171
 
2172 2172
 		$attribute_value = $attributeDefinition['value'];
2173
-		if ( $attributeDefinition['data_type'] == 'decimal' ) {
2174
-			$attribute_value =(is_numeric($attribute_value) ) ? number_format($attribute_value, 2, ',', '') : $attribute_value;
2175
-			if ( in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) {
2176
-				if ( $attributeDefinition['is_requiring_unit'] == 'yes' ) {
2173
+		if ($attributeDefinition['data_type'] == 'decimal') {
2174
+			$attribute_value = (is_numeric($attribute_value)) ? number_format($attribute_value, 2, ',', '') : $attribute_value;
2175
+			if (in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES))) {
2176
+				if ($attributeDefinition['is_requiring_unit'] == 'yes') {
2177 2177
 					$attribute_unit_list = ' ' . wpshop_tools::wpshop_get_currency();
2178 2178
 				}
2179 2179
 				$attributeDefinition['value'] = wpshop_display::format_field_output('wpshop_product_price', $attributeDefinition['value']);
2180 2180
 			}
2181 2181
 		}
2182
-		if ( $attributeDefinition['data_type'] == 'datetime' ) {
2182
+		if ($attributeDefinition['data_type'] == 'datetime') {
2183 2183
 			$attribute_value = mysql2date('d/m/Y', $attributeDefinition['value'], true);
2184 2184
 		}
2185
-		if ( $attributeDefinition['backend_input'] == 'select' ) {
2185
+		if ($attributeDefinition['backend_input'] == 'select') {
2186 2186
 			$attribute_value = wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']);
2187 2187
 		}
2188 2188
 		/** Manage differently if its an array of values or not	*/
2189
-		if ( $attributeDefinition['backend_input'] == 'multiple-select') {
2189
+		if ($attributeDefinition['backend_input'] == 'multiple-select') {
2190 2190
 			$attribute_value = '';
2191
-			if ( is_array($attributeDefinition['value']) ) {
2191
+			if (is_array($attributeDefinition['value'])) {
2192 2192
 				foreach ($attributeDefinition['value'] as $v) {
2193
-					$attribute_value .= ' / '.wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']);
2193
+					$attribute_value .= ' / ' . wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']);
2194 2194
 				}
2195 2195
 			}
2196
-			else $attribute_value = ' / '.wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']);
2197
-			$attribute_value = substr($attribute_value,3);
2196
+			else $attribute_value = ' / ' . wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']);
2197
+			$attribute_value = substr($attribute_value, 3);
2198 2198
 		}
2199 2199
 
2200 2200
 		return array($attribute_value, $attributeDefinition['value'], $attribute_unit_list);
@@ -2204,13 +2204,13 @@  discard block
 block discarded – undo
2204 2204
 	 * Manage display for the output when user uses a shortcode for attributes display
2205 2205
 	 * @param array $shorcode_args The list of argument passed through the shortcode
2206 2206
 	 */
2207
-	function wpshop_attributes_shortcode( $shorcode_args ) {
2207
+	function wpshop_attributes_shortcode($shorcode_args) {
2208 2208
 		$output = '';
2209 2209
 		/*
2210 2210
 		 * Read the attribute list
2211 2211
 		*/
2212
-		foreach ( explode(', ', $shorcode_args['attributes']) as $attribute_code ) {
2213
-			$attribute_output_def = wpshop_attributes::display_attribute( $attribute_code, $shorcode_args['from'] );
2212
+		foreach (explode(', ', $shorcode_args['attributes']) as $attribute_code) {
2213
+			$attribute_output_def = wpshop_attributes::display_attribute($attribute_code, $shorcode_args['from']);
2214 2214
 			$output .= $attribute_output_def['field'];
2215 2215
 		}
2216 2216
 
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
 		$productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails($attributeSetId, "'valid','deleted'");
2233 2233
 		$attribute_specification = array('page_code' => $currentPageCode, 'element_identifier' => $itemToEdit, 'field_id' => $currentPageCode . '_' . $itemToEdit . '_');
2234 2234
 
2235
-		if ( count($productAttributeSetDetails) > 0 ) {
2235
+		if (count($productAttributeSetDetails) > 0) {
2236 2236
 			/*	Read the attribute list in order to output	*/
2237 2237
 			$shortcodes_attr = '';
2238 2238
 			$shortcodes_to_display = false;
@@ -2242,80 +2242,80 @@  discard block
 block discarded – undo
2242 2242
 
2243 2243
 				$shortcodes = $currentTabContent = '';
2244 2244
 				$output_nb = 0;
2245
-				if(count($productAttributeSetDetail['attribut']) >= 1){
2246
-					foreach($productAttributeSetDetail['attribut'] as $attribute){
2245
+				if (count($productAttributeSetDetail['attribut']) >= 1) {
2246
+					foreach ($productAttributeSetDetail['attribut'] as $attribute) {
2247 2247
 
2248
-						if ( !empty($attribute->id) ) {
2249
-							if ( $attribute->code == 'product_attribute_set_id' ) {
2248
+						if (!empty($attribute->id)) {
2249
+							if ($attribute->code == 'product_attribute_set_id') {
2250 2250
 								$attribute_set_id_is_present = true;
2251 2251
 							}
2252 2252
 
2253 2253
 							/** Generic part for attribute field output	*/
2254 2254
 							$value = wpshop_attributes::getAttributeValueForEntityInSet($attribute->data_type, $attribute->id, wpshop_entities::get_entity_identifier_from_code($currentPageCode), $itemToEdit, array('intrinsic' => $attribute->is_intrinsic, 'backend_input' => $attribute->backend_input));
2255
-							$product_meta = get_post_meta( $itemToEdit, '_wpshop_product_metadata', true);
2255
+							$product_meta = get_post_meta($itemToEdit, '_wpshop_product_metadata', true);
2256 2256
 
2257 2257
 							/**	Check if value is empty and get value in meta if not empty	*/
2258 2258
 							$value = (empty($value) && !empty($product_meta[$attribute->code])) ? $product_meta[$attribute->code] : (!empty($value) ? $value : null);
2259 2259
 
2260 2260
 							/*	Manage specific field as the attribute_set_id in product form	*/
2261
-							if ( $attribute->code == 'product_attribute_set_id' ) {
2261
+							if ($attribute->code == 'product_attribute_set_id') {
2262 2262
 
2263 2263
 								$value = empty($value) ? $attributeSetId : $value;
2264 2264
 							}
2265 2265
 							$attribute_specification['current_value'] = $value;
2266
-							$attribute_output_def = apply_filters( 'wpshop_attribute_output_def', wpshop_attributes::display_attribute( $attribute->code, 'admin', $attribute_specification), $itemToEdit );
2267
-							if ( ($attribute_output_def['field_definition']['type'] != 'hidden') && ($attribute->code != 'product_attribute_set_id') ) {
2266
+							$attribute_output_def = apply_filters('wpshop_attribute_output_def', wpshop_attributes::display_attribute($attribute->code, 'admin', $attribute_specification), $itemToEdit);
2267
+							if (($attribute_output_def['field_definition']['type'] != 'hidden') && ($attribute->code != 'product_attribute_set_id')) {
2268 2268
 								$currentTabContent .= $attribute_output_def['field'];
2269
-								$shortcode_code_def=array();
2270
-								$shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val';
2271
-								$shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type;
2272
-								$shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id;
2273
-								$shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit;
2269
+								$shortcode_code_def = array();
2270
+								$shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val';
2271
+								$shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type;
2272
+								$shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id;
2273
+								$shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit;
2274 2274
 								ob_start();
2275
-								wps_shortcodes_ctr::output_shortcode('attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])), $shortcode_code_def, 'wpshop_product_shortcode_display wpshop_product_attribute_shortcode_display wpshop_product_attribute_shortcode_display_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])).' wpshop_cls');
2276
-								$shortcodes .= '<li class="wpshop_cls" >'.sprintf(__('Insertion code for the attribute %s for this product', 'wpshop'), '<span>'.__($attribute_output_def['field_definition']['label'], 'wpshop').'</span>').ob_get_contents().'</li>';
2275
+								wps_shortcodes_ctr::output_shortcode('attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])), $shortcode_code_def, 'wpshop_product_shortcode_display wpshop_product_attribute_shortcode_display wpshop_product_attribute_shortcode_display_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])) . ' wpshop_cls');
2276
+								$shortcodes .= '<li class="wpshop_cls" >' . sprintf(__('Insertion code for the attribute %s for this product', 'wpshop'), '<span>' . __($attribute_output_def['field_definition']['label'], 'wpshop') . '</span>') . ob_get_contents() . '</li>';
2277 2277
 								ob_end_clean();
2278 2278
 							}
2279 2279
 							else {
2280
-								if ( $attribute->code == 'product_attribute_set_id' ) {
2280
+								if ($attribute->code == 'product_attribute_set_id') {
2281 2281
 									$attribute_output_def['field_definition']['type'] = 'hidden';
2282 2282
 								}
2283
-								$currentTabContent .=  wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']);
2283
+								$currentTabContent .= wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']);
2284 2284
 							}
2285 2285
 							$output_nb++;
2286 2286
 						}
2287 2287
 					}
2288 2288
 
2289
-					$currentTabContent = apply_filters( 'wps_entity_attribute_edition', $currentTabContent, $itemToEdit, $productAttributeSetDetail );
2289
+					$currentTabContent = apply_filters('wps_entity_attribute_edition', $currentTabContent, $itemToEdit, $productAttributeSetDetail);
2290 2290
 
2291 2291
 					$shortcode_code['attributes_set']['main_code'] = 'wpshop_att_group';
2292 2292
 					$shortcode_code['attributes_set']['attrs_exemple']['pid'] = $itemToEdit;
2293 2293
 					$shortcode_code['attributes_set']['attrs_exemple']['sid'] = $productAttributeSetDetail['id'];
2294 2294
 					ob_start();
2295
-					wps_shortcodes_ctr::output_shortcode('attributes_set', $shortcode_code, 'wpshop_product_shortcode_display wpshop_product_attribute_group_shortcode_display wpshop_product_attribute_group_shortcode_display_'.str_replace('-', '_', sanitize_title($productAttributeSetDetail['name'])).' cls');
2296
-					$attribute_group_display = sprintf(__('Insertion code for attribute group %s for this product', 'wpshop'), '<span>'.$productAttributeSetDetail['name'].'</span>').ob_get_contents().'<ul class="" >'.$shortcodes.'</ul>';
2295
+					wps_shortcodes_ctr::output_shortcode('attributes_set', $shortcode_code, 'wpshop_product_shortcode_display wpshop_product_attribute_group_shortcode_display wpshop_product_attribute_group_shortcode_display_' . str_replace('-', '_', sanitize_title($productAttributeSetDetail['name'])) . ' cls');
2296
+					$attribute_group_display = sprintf(__('Insertion code for attribute group %s for this product', 'wpshop'), '<span>' . $productAttributeSetDetail['name'] . '</span>') . ob_get_contents() . '<ul class="" >' . $shortcodes . '</ul>';
2297 2297
 					ob_end_clean();
2298 2298
 
2299
-					if( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box' )
2300
-						$currentTabContent .= '<div class="wpshop_cls" ><strong>'.__('Shortcodes','wpshop').'</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>';
2299
+					if (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box')
2300
+						$currentTabContent .= '<div class="wpshop_cls" ><strong>' . __('Shortcodes', 'wpshop') . '</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>';
2301 2301
 					else
2302 2302
 						$shortcodes_attr .= $attribute_group_display;
2303 2303
 
2304
-					if ( $output_nb <= 0 ) {
2304
+					if ($output_nb <= 0) {
2305 2305
 						$currentTabContent = __('Nothing avaiblable here. You can go in attribute management interface in order to add content here.', 'wpshop');
2306 2306
 					}
2307 2307
 				}
2308 2308
 
2309 2309
 				if ($output_nb > 0) {
2310 2310
 					$shortcodes_to_display = true;
2311
-					if ( $outputType == 'box' ) {
2311
+					if ($outputType == 'box') {
2312 2312
 						$box['box'][$productAttributeSetDetail['code']] = $productAttributeSetDetail['name'];
2313
-						$box['box'][$productAttributeSetDetail['code'].'_backend_display_type'] = $productAttributeSetDetail['backend_display_type'];
2313
+						$box['box'][$productAttributeSetDetail['code'] . '_backend_display_type'] = $productAttributeSetDetail['backend_display_type'];
2314 2314
 						$box['boxContent'][$productAttributeSetDetail['code']] = '
2315 2315
 			<div id="wpshop_' . $currentPageCode . '_' . wpshop_tools::slugify($productAttributeSetDetail['code'], array('noAccent')) . '_form" >' . $currentTabContent . '
2316 2316
 							</div><div class="wpshop_cls" ></div>';
2317 2317
 					}
2318
-					else if ( $outputType == 'column' ) {
2318
+					else if ($outputType == 'column') {
2319 2319
 						$currentTabContent = str_replace('wpshop_form_input_element', 'wpshop_form_input_column', $currentTabContent);
2320 2320
 						$currentTabContent = str_replace('wpshop_form_label', 'wpshop_form_label_column', $currentTabContent);
2321 2321
 
@@ -2325,11 +2325,11 @@  discard block
 block discarded – undo
2325 2325
 				}
2326 2326
 			}
2327 2327
 
2328
-			if( !$attribute_set_id_is_present ) {
2328
+			if (!$attribute_set_id_is_present) {
2329 2329
 				/*	Get attribute definition	*/
2330 2330
 				$attribute_def = wpshop_attributes::getElement('product_attribute_set_id', "'valid'", 'code');
2331 2331
 				/*	Get attribute input definition	*/
2332
-				$input = wpshop_attributes::get_attribute_field_definition( $attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin')) );
2332
+				$input = wpshop_attributes::get_attribute_field_definition($attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin')));
2333 2333
 				$input['type'] = 'hidden';
2334 2334
 
2335 2335
 				$box['boxMore'] = wpshop_form::check_input_type($input, $input['input_domain']);
@@ -2340,13 +2340,13 @@  discard block
 block discarded – undo
2340 2340
 			$dialog_identifier = 'wpshop_new_attribute_option_value_add';
2341 2341
 			$dialog_input_identifier = 'wpshop_new_attribute_option_value';
2342 2342
 			ob_start();
2343
-			include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php');
2343
+			include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php');
2344 2344
 			$box['boxMore'] .= ob_get_contents();
2345 2345
 			ob_end_clean();
2346 2346
 			$box['boxMore'] .= '<input type="hidden" name="wpshop_attribute_type_select_code" value="" id="wpshop_attribute_type_select_code" />';
2347 2347
 
2348
-			if ( $shortcodes_to_display ) {
2349
-				switch ( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE ) {
2348
+			if ($shortcodes_to_display) {
2349
+				switch (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE) {
2350 2350
 					case 'fixed-tab':
2351 2351
 					case 'movable-tab':
2352 2352
 						if ($outputType == 'box') {
@@ -2354,7 +2354,7 @@  discard block
 block discarded – undo
2354 2354
 							$box['boxContent']['shortcode'] = $shortcodes_attr;
2355 2355
 							$box['box']['shortcode_backend_display_type'] = WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE;
2356 2356
 						}
2357
-						else{
2357
+						else {
2358 2358
 							$box['columnTitle']['shortcode'] = __('Product Shortcodes', 'wpshop');
2359 2359
 							$box['columnContent']['shortcode'] = $shortcodes_attr;
2360 2360
 						}
@@ -2378,12 +2378,12 @@  discard block
 block discarded – undo
2378 2378
 		$ouput['more_input'] = '';
2379 2379
 
2380 2380
 		$attribute_default_value = $attribute->default_value;
2381
-		if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) {
2381
+		if (!empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized($attribute->default_value))) {
2382 2382
 			$tmp_default_value = unserialize($attribute->default_value);
2383 2383
 			$attribute_default_value = !empty($tmp_default_value["default_value"]) ? $tmp_default_value["default_value"] : null;
2384 2384
 		}
2385 2385
 
2386
-		if ( $attribute->data_type_to_use == 'custom') {
2386
+		if ($attribute->data_type_to_use == 'custom') {
2387 2387
 			$query = $wpdb->prepare("SELECT id, label, value, '' as name FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d AND status = 'valid' ORDER BY position", $attribute->id);
2388 2388
 			$attribute_select_options = $wpdb->get_results($query);
2389 2389
 
@@ -2395,11 +2395,11 @@  discard block
 block discarded – undo
2395 2395
 // 				}
2396 2396
 			endforeach;
2397 2397
 		}
2398
-		elseif ( $attribute->data_type_to_use == 'internal')  {
2398
+		elseif ($attribute->data_type_to_use == 'internal') {
2399 2399
 			switch ($attribute_default_value) {
2400 2400
 				case 'users':
2401 2401
 					$users = get_users('orderby=nicename');
2402
-					foreach($users as $user){
2402
+					foreach ($users as $user) {
2403 2403
 						$attribute_select_options_list[$user->ID] = $user->display_name;
2404 2404
 					}
2405 2405
 				break;
@@ -2408,11 +2408,11 @@  discard block
 block discarded – undo
2408 2408
 					$wpshop_attr_custom_post_query = new WP_Query(array(
2409 2409
 						'post_type' => $attribute_default_value,
2410 2410
 						'posts_per_page' => -1,
2411
-						'post_status' => array( 'publish', 'draft', 'future' ) ,
2411
+						'post_status' => array('publish', 'draft', 'future'),
2412 2412
 					));
2413 2413
 
2414
-					if($wpshop_attr_custom_post_query->have_posts()):
2415
-						foreach($wpshop_attr_custom_post_query->posts as $post){
2414
+					if ($wpshop_attr_custom_post_query->have_posts()):
2415
+						foreach ($wpshop_attr_custom_post_query->posts as $post) {
2416 2416
 							$attribute_select_options_list[$post->ID] = $post->post_title;
2417 2417
 						}
2418 2418
 					endif;
@@ -2423,27 +2423,27 @@  discard block
 block discarded – undo
2423 2423
 
2424 2424
 		/*	There is no value existing for this value	*/
2425 2425
 		if (empty($attribute_select_options_list)) :
2426
-			$ouput['more_input'].=__('Nothing found for this field', 'wpshop');
2426
+			$ouput['more_input'] .= __('Nothing found for this field', 'wpshop');
2427 2427
 		else:
2428 2428
 			/*	Add a default value to the combobox list	*/
2429 2429
 			$default_value_is_serial = false;
2430 2430
 			$attribute_list_first_element = $attribute->default_value;
2431
-			if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) {
2431
+			if (!empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized($attribute->default_value))) {
2432 2432
 				$default_value_is_serial = true;
2433 2433
 				$tmp_default_value = unserialize($attribute->default_value);
2434 2434
 				$attribute_list_first_element = $tmp_default_value["field_options"]["label_for_first_item"];
2435 2435
 			}
2436 2436
 			//if ( !in_array($attribute->frontend_input, array('radio', 'checkbox')) || ($attribute_list_first_element != 'none') ) $ouput['possible_value'][] = ($default_value_is_serial && !empty($attribute_list_first_element)) ? $attribute_list_first_element : __('Choose a value', 'wpshop');
2437
-			foreach ( $attribute_select_options_list as $option_key => $option_value ) {
2437
+			foreach ($attribute_select_options_list as $option_key => $option_value) {
2438 2438
 				$ouput['possible_value'][$option_key] = stripslashes($option_value);
2439 2439
 			}
2440 2440
 		endif;
2441 2441
 
2442 2442
 		/*	Add a extra element to create a new element into list	*/
2443
-		if ( is_admin()  && ( empty($provenance['from']) || ($provenance['from'] != 'frontend')) ) {
2443
+		if (is_admin() && (empty($provenance['from']) || ($provenance['from'] != 'frontend'))) {
2444 2444
 			/**	$ouput['more_input'] .= '<img src="'.WPSHOP_MEDIAS_ICON_URL.'add.png" id="new_value_pict_' . $attribute->code . '" alt="'.__('Add a new value for this attribute', 'wpshop').'" title="'.__('Add a new value for this attribute', 'wpshop').'" class="wpshop_icons wpshop_icons_add_new_value_to_option_list wpshop_icons_add_new_value_to_option_list_'.$attribute->code.'" />';	*/
2445 2445
 		}
2446
-		else if ( 'yes' == $attribute->is_used_in_quick_add_form ) {
2446
+		else if ('yes' == $attribute->is_used_in_quick_add_form) {
2447 2447
 			$tpl_component = array();
2448 2448
 			$tpl_component['NEW_ELEMENT_CREATION_FIELD'] = 'attribute[new_value_creation][' . $attribute->code . ']';
2449 2449
 			$ouput['more_input'] .= wpshop_display::display_template_element('quick_entity_specific_field_new_element', $tpl_component);
@@ -2452,11 +2452,11 @@  discard block
 block discarded – undo
2452 2452
 		return $ouput;
2453 2453
 	}
2454 2454
 
2455
-	public static function get_affected_value_for_list( $attribute_code, $element_id, $attribute_data_type ) {
2455
+	public static function get_affected_value_for_list($attribute_code, $element_id, $attribute_data_type) {
2456 2456
 		global $wpdb;
2457 2457
 		$affected_value = array();
2458 2458
 
2459
-		if ( $attribute_data_type == 'custom' ) {
2459
+		if ($attribute_data_type == 'custom') {
2460 2460
 			$query = $wpdb->prepare("
2461 2461
 SELECT ATT_SELECT_OPTIONS_VALUE.id AS chosen_val, ATT_SELECT_OPTIONS_VALUE.value
2462 2462
 FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATT
@@ -2478,20 +2478,20 @@  discard block
 block discarded – undo
2478 2478
 		}
2479 2479
 
2480 2480
 		$attribute_values_for_variations = $wpdb->get_results($query);
2481
-		foreach ( $attribute_values_for_variations as $attribute_def ) {
2482
-			$affected_value[] = (int) $attribute_def->chosen_val;
2481
+		foreach ($attribute_values_for_variations as $attribute_def) {
2482
+			$affected_value[] = (int)$attribute_def->chosen_val;
2483 2483
 		}
2484 2484
 
2485 2485
 		return $affected_value;
2486 2486
 	}
2487 2487
 
2488 2488
 	public static function get_attribute_option_output($item, $attr_code, $attr_option, $additionnal_params = '') {
2489
-		switch($attr_code){
2489
+		switch ($attr_code) {
2490 2490
 			case 'is_downloadable_':
2491
-				$option = get_post_meta($item['item_id'], 'attribute_option_'.$attr_code, true);
2492
-				switch($attr_option){
2491
+				$option = get_post_meta($item['item_id'], 'attribute_option_' . $attr_code, true);
2492
+				switch ($attr_option) {
2493 2493
 					case 'file_url':
2494
-						if(in_array($additionnal_params['order_status'], array('completed', 'shipped')) && (!empty($item['item_'.$attr_code]) && (strtolower(__($item['item_'.$attr_code], 'wpshop')) == __('yes','wpshop'))) ){
2494
+						if (in_array($additionnal_params['order_status'], array('completed', 'shipped')) && (!empty($item['item_' . $attr_code]) && (strtolower(__($item['item_' . $attr_code], 'wpshop')) == __('yes', 'wpshop')))) {
2495 2495
 							$file_url = isset($option[$attr_option]) ? $option[$attr_option] : false;
2496 2496
 							return $file_url;
2497 2497
 						}
@@ -2504,17 +2504,17 @@  discard block
 block discarded – undo
2504 2504
 
2505 2505
 	public static function get_attribute_option_fields($postid, $code) {
2506 2506
 
2507
-		switch($code){
2507
+		switch ($code) {
2508 2508
 			case 'is_downloadable_':
2509
-				$data = get_post_meta($postid, 'attribute_option_'.$code, true);
2510
-				$data['file_url'] = !empty($data['file_url'])?$data['file_url']:__('No file selected', 'wpshop');
2511
-				$fields =  wp_nonce_field( 'ajax_wpshop_show_downloadable_interface_in_admin'.$postid, '_show_downloadable_interface_in_admin_wpnonce', true, false );
2509
+				$data = get_post_meta($postid, 'attribute_option_' . $code, true);
2510
+				$data['file_url'] = !empty($data['file_url']) ? $data['file_url'] : __('No file selected', 'wpshop');
2511
+				$fields = wp_nonce_field('ajax_wpshop_show_downloadable_interface_in_admin' . $postid, '_show_downloadable_interface_in_admin_wpnonce', true, false);
2512 2512
 				$fields .= '<div class="wpshop_form_label alignleft">&nbsp;</div>
2513 2513
 						<div class="wpshop_form_input_element alignleft">
2514
-						<div class="send_downloadable_file_dialog wpshop_add_box" data-post="'.$postid.'" title="' .__('Send the downloadable file', 'wpshop'). '"></div>
2515
-						<a data-nonce="' . wp_create_nonce( "ajax_wpshop_fill_the_downloadable_dialog".$postid ) . '"  class="send_downlodable_file wps-bton-first-mini-rounded">' .__('Send a file', 'wpshop').'</a>
2516
-						<input type="hidden" class="product_identifer_field" value="' .( !empty($postid) ? esc_attr( $postid ) : '') . '" /><br/><u>'.__('File url','wpshop').' :</u>
2517
-						<div class="is_downloadable_statut_'.$postid.'"><a href="' .$data['file_url']. '" target="_blank" download>'.basename($data['file_url']).'</a></div>
2514
+						<div class="send_downloadable_file_dialog wpshop_add_box" data-post="'.$postid . '" title="' . __('Send the downloadable file', 'wpshop') . '"></div>
2515
+						<a data-nonce="' . wp_create_nonce("ajax_wpshop_fill_the_downloadable_dialog" . $postid) . '"  class="send_downlodable_file wps-bton-first-mini-rounded">' . __('Send a file', 'wpshop') . '</a>
2516
+						<input type="hidden" class="product_identifer_field" value="' .(!empty($postid) ? esc_attr($postid) : '') . '" /><br/><u>' . __('File url', 'wpshop') . ' :</u>
2517
+						<div class="is_downloadable_statut_'.$postid . '"><a href="' . $data['file_url'] . '" target="_blank" download>' . basename($data['file_url']) . '</a></div>
2518 2518
 						</div>';
2519 2519
 				return $fields;
2520 2520
 				break;
@@ -2539,8 +2539,8 @@  discard block
 block discarded – undo
2539 2539
 		$attribute_value_content = '';
2540 2540
 
2541 2541
 		$atributes = self::getElement($attribute_code, "'valid'", 'code');
2542
-		if ( !empty($atributes) ) {
2543
-			$attribute_value_content = self::getAttributeValueForEntityInSet($atributes->data_type, $atributes->id,  wpshop_entities::get_entity_identifier_from_code($entity_type), $entity_id);
2542
+		if (!empty($atributes)) {
2543
+			$attribute_value_content = self::getAttributeValueForEntityInSet($atributes->data_type, $atributes->id, wpshop_entities::get_entity_identifier_from_code($entity_type), $entity_id);
2544 2544
 		}
2545 2545
 
2546 2546
 		return $attribute_value_content;
@@ -2552,14 +2552,14 @@  discard block
 block discarded – undo
2552 2552
 	 * @param mixed $value
2553 2553
 	 * @return string The complete interface allowing to manage datetime attribute field
2554 2554
 	 */
2555
-	function attribute_type_date_config( $value ) {
2555
+	function attribute_type_date_config($value) {
2556 2556
 		$date_config_output = '';
2557 2557
 
2558 2558
 		$input_def['name'] = 'default_value';
2559 2559
 		$input_def['type'] = 'checkbox';
2560 2560
 		$input_def['possible_value'] = 'date_of_current_day';
2561 2561
 		$input_def['value'] = !empty($value['default_value']) ? $value['default_value'] : '';
2562
-		$input_def['options_label']['custom'] = ' ' . __('Use the date of the day as default value', 'wpshop') . ' <a href="#" title="'.__('Check this box for using date of the day as value when editing a product', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
2562
+		$input_def['options_label']['custom'] = ' ' . __('Use the date of the day as default value', 'wpshop') . ' <a href="#" title="' . __('Check this box for using date of the day as value when editing a product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
2563 2563
 		$date_config_output .= wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
2564 2564
 
2565 2565
 		$input_def = array();
@@ -2568,35 +2568,35 @@  discard block
 block discarded – undo
2568 2568
 		$input_def['type'] = 'checkbox';
2569 2569
 		$input_def['valueToPut'] = 'index';
2570 2570
 		$input_def['value'] = !empty($value['field_options']['attribute_type_date_options_day_to_show']) ? $value['field_options']['attribute_type_date_options_day_to_show'] : '';
2571
-		$input_def['possible_value'] = array('1' => ' ' . __('Monday', 'wpshop'), '2' => ' ' .__('Tuesday', 'wpshop'), '3' => ' ' .__('Wednesday', 'wpshop'), '4' => ' ' .__('Thursday', 'wpshop'), '5' => ' ' .__('Friday', 'wpshop'), '6' => ' ' .__('Saturday', 'wpshop'), '0' => ' ' .__('Sunday', 'wpshop'));
2571
+		$input_def['possible_value'] = array('1' => ' ' . __('Monday', 'wpshop'), '2' => ' ' . __('Tuesday', 'wpshop'), '3' => ' ' . __('Wednesday', 'wpshop'), '4' => ' ' . __('Thursday', 'wpshop'), '5' => ' ' . __('Friday', 'wpshop'), '6' => ' ' . __('Saturday', 'wpshop'), '0' => ' ' . __('Sunday', 'wpshop'));
2572 2572
 		$input_def['options_label']['original'] = true;
2573
-		$date_config_output .= '<div>' . __('Choose available days in date picker', 'wpshop') . '<a href="#" title="'.__('This option allows you to define the available day in final datepicker', 'wpshop').'" class="wpshop_infobulle_marker">?</a>' . '<br/>' . wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_day_to_show]') . '</div>';
2573
+		$date_config_output .= '<div>' . __('Choose available days in date picker', 'wpshop') . '<a href="#" title="' . __('This option allows you to define the available day in final datepicker', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>' . '<br/>' . wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_day_to_show]') . '</div>';
2574 2574
 
2575 2575
 		/**	Past and futur date restriction	*/
2576 2576
 		$input_def = array();
2577 2577
 		$input_def['name'] = '';
2578 2578
 		$input_def['type'] = 'text';
2579
-		$date_config_output .= '<div id="wpshop_avalaible_date_for_past_and_futur" >' . __('Calendar past and futur date available', 'wpshop') . '<a href="#" title="'.__('Define if the end user is allowed to choose past and/or futur date', 'wpshop').'" class="wpshop_infobulle_marker">?</a><br/>';
2579
+		$date_config_output .= '<div id="wpshop_avalaible_date_for_past_and_futur" >' . __('Calendar past and futur date available', 'wpshop') . '<a href="#" title="' . __('Define if the end user is allowed to choose past and/or futur date', 'wpshop') . '" class="wpshop_infobulle_marker">?</a><br/>';
2580 2580
 		$available_type_input_def = array();
2581 2581
 		$available_type_input_def['name'] = '';
2582 2582
 		$available_type_input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_past_futur_minimum';
2583 2583
 		$available_type_input_def['type'] = 'text';
2584 2584
 		$available_type_input_def['value'] = !empty($value['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0]) ? $value['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0] : '';
2585
-		$date_config_output .= __('Minimum date to show', 'wpshop') . '<a href="#" title="'.__('If you want the calendar to start today put only 0, if you want to show anterior date, put the number of Day or Month or Year (ex: -1D)', 'wpshop').'" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][minDate]') . '<br/>';
2585
+		$date_config_output .= __('Minimum date to show', 'wpshop') . '<a href="#" title="' . __('If you want the calendar to start today put only 0, if you want to show anterior date, put the number of Day or Month or Year (ex: -1D)', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][minDate]') . '<br/>';
2586 2586
 		$available_type_input_def = array();
2587 2587
 		$available_type_input_def['name'] = '';
2588 2588
 		$available_type_input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_past_futur_maximum';
2589 2589
 		$available_type_input_def['type'] = 'text';
2590 2590
 		$available_type_input_def['value'] = !empty($value['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0]) ? $value['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0] : '';
2591
-		$date_config_output .= __('Maximum date to show', 'wpshop') . '<a href="#" title="'.__('If you want the calendar to end today put only 0, if you want to show date in futur, put the number of Day or Month or Year (ex: +1M)', 'wpshop').'" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][maxDate]') . '<br/>';
2591
+		$date_config_output .= __('Maximum date to show', 'wpshop') . '<a href="#" title="' . __('If you want the calendar to end today put only 0, if you want to show date in futur, put the number of Day or Month or Year (ex: +1M)', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][maxDate]') . '<br/>';
2592 2592
 		$date_config_output .= '</div>';
2593 2593
 
2594 2594
 		$input_def = array();
2595 2595
 		$input_def['name'] = '';
2596 2596
 		$input_def['type'] = 'text';
2597 2597
 		$date_config_output .= '
2598
-<div id="wpshop_attribute_date_empy_field" class="wpshopHide" ><br/>' . wpshop_form::check_input_type(array_merge($input_def, array('value' => '', 'id' => 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_new_input')), WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') .'</div>
2599
-<div id="wpshop_avalaible_date_list_container" >' . __('Choose available date in date picker', 'wpshop') . '<a href="#" title="'.__('This option allows you to define the available date in final datepicker', 'wpshop').'" class="wpshop_infobulle_marker">?</a><br/>';
2598
+<div id="wpshop_attribute_date_empy_field" class="wpshopHide" ><br/>' . wpshop_form::check_input_type(array_merge($input_def, array('value' => '', 'id' => 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_new_input')), WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') . '</div>
2599
+<div id="wpshop_avalaible_date_list_container" >' . __('Choose available date in date picker', 'wpshop') . '<a href="#" title="' . __('This option allows you to define the available date in final datepicker', 'wpshop') . '" class="wpshop_infobulle_marker">?</a><br/>';
2600 2600
 
2601 2601
 		$available_type_input_def = array();
2602 2602
 		$available_type_input_def['name'] = '';
@@ -2609,9 +2609,9 @@  discard block
 block discarded – undo
2609 2609
 		$date_config_output .= wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_type]') . '<br/>';
2610 2610
 
2611 2611
 		$existing = 0;
2612
-		if ( !empty($value['field_options']['attribute_type_date_options_available_date']) ) {
2613
-			foreach ( $value['field_options']['attribute_type_date_options_available_date'] as $index => $value ) {
2614
-				if ( !empty($value) ) {
2612
+		if (!empty($value['field_options']['attribute_type_date_options_available_date'])) {
2613
+			foreach ($value['field_options']['attribute_type_date_options_available_date'] as $index => $value) {
2614
+				if (!empty($value)) {
2615 2615
 					$input_def['value'] = $value;
2616 2616
 					$input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_' . $index;
2617 2617
 					$date_config_output .= wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') . '<br/>';
@@ -2635,20 +2635,20 @@  discard block
 block discarded – undo
2635 2635
 	 * @param array $values Valeurs d'attributs
2636 2636
 	 * @return array
2637 2637
 	 */
2638
-	public static function setAttributesValuesForItem($entityId, $values=array(), $defaultValueForOthers=false, $from = 'webservice') {
2639
-		$message='';
2638
+	public static function setAttributesValuesForItem($entityId, $values = array(), $defaultValueForOthers = false, $from = 'webservice') {
2639
+		$message = '';
2640 2640
 		$attribute_available = array();
2641 2641
 		$attribute_final = array();
2642 2642
 		$entity_type = get_post_type($entityId);
2643
-		$data = self::get_attribute_list_for_item( wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE);
2644
-		foreach($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type);
2643
+		$data = self::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE);
2644
+		foreach ($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type);
2645 2645
 
2646 2646
 		// Creation d'un array "propre" et valide pour la fonction self::saveAttributeForEntity
2647
-		foreach ( $values as $key => $value ) {
2648
-			if ( in_array( $key, array_keys( $attribute_available ) ) ) {
2647
+		foreach ($values as $key => $value) {
2648
+			if (in_array($key, array_keys($attribute_available))) {
2649 2649
 				$attribute_final[$attribute_available[$key]['data_type']][$key] = $value;
2650 2650
 			}
2651
-			else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key)."\n";
2651
+			else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key) . "\n";
2652 2652
 		}
2653 2653
 
2654 2654
 		// Pour les autres attributs non donné on leur affecte leur valeur par défaut
@@ -2669,7 +2669,7 @@  discard block
 block discarded – undo
2669 2669
 			}
2670 2670
 		}
2671 2671
 
2672
-		switch ( $entity_type ) {
2672
+		switch ($entity_type) {
2673 2673
 			case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
2674 2674
 					$meta_key = WPSHOP_PRODUCT_ATTRIBUTE_META_KEY;
2675 2675
 				break;
@@ -2700,18 +2700,18 @@  discard block
 block discarded – undo
2700 2700
 	public static function get_attribute_type_select_option_info($option_id, $field = 'label', $attribute_data_type = 'custom', $only_value = false) {
2701 2701
 		global $wpdb;
2702 2702
 
2703
-		switch ( $attribute_data_type ) {
2703
+		switch ($attribute_data_type) {
2704 2704
 			case 'internal':
2705 2705
 				$entity_infos = get_post($option_id);
2706
-				if ( !empty($entity_infos) ) {
2707
-					if ( !$only_value ) {
2706
+				if (!empty($entity_infos)) {
2707
+					if (!$only_value) {
2708 2708
 						/** Template parameters */
2709 2709
 						$template_part = 'product_attribute_value_internal';
2710 2710
 						$tpl_component = array();
2711 2711
 						$tpl_component['ATTRIBUTE_VALUE_POST_LINK'] = get_permalink($option_id);
2712 2712
 						$tpl_component['ATTRIBUTE_VALUE_POST_TITLE'] = $entity_infos->post_title;
2713 2713
 
2714
-						foreach ( $entity_infos as $post_definition_key => $post_definition_value ) {
2714
+						foreach ($entity_infos as $post_definition_key => $post_definition_value) {
2715 2715
 							$tpl_component['ATTRIBUTE_VALUE_' . strtoupper($post_definition_key)] = $entity_infos->$post_definition_key;
2716 2716
 						}
2717 2717
 
@@ -2726,8 +2726,8 @@  discard block
 block discarded – undo
2726 2726
 				break;
2727 2727
 
2728 2728
 			default:
2729
-				if( ! array_key_exists( $option_id, self::$select_option_info_cache ) ) {
2730
-					$query = $wpdb->prepare("SELECT " . $field . " FROM ".WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS." WHERE id=%d LIMIT 1", $option_id);
2729
+				if (!array_key_exists($option_id, self::$select_option_info_cache)) {
2730
+					$query = $wpdb->prepare("SELECT " . $field . " FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE id=%d LIMIT 1", $option_id);
2731 2731
 					self::$select_option_info_cache[$option_id] = $wpdb->get_var($query);
2732 2732
 				}
2733 2733
 				$info = self::$select_option_info_cache[$option_id];
@@ -2767,39 +2767,39 @@  discard block
 block discarded – undo
2767 2767
 	 * @param string $data_type optionnal Le type de donnees choisi pour cet attribut (custom | internal)
2768 2768
 	 * @return string Le resultat sous forme de code html pour la liste des options
2769 2769
 	 */
2770
-	function get_select_options_list($attribute_id, $data_type='custom') {
2770
+	function get_select_options_list($attribute_id, $data_type = 'custom') {
2771 2771
 		global $wpdb;
2772 2772
 		$output = '';
2773 2773
 
2774 2774
 		$attribute_select_options = self::get_select_option_list_($attribute_id);
2775 2775
 
2776 2776
 		/*	Add possibily to choose datat type to use with list	*/
2777
-		if(empty($attribute_id) || (!empty($attribute_select_options) && empty($attribute_select_options[0]->data_type_to_use))){
2778
-			unset($input_def);$input_def=array();
2777
+		if (empty($attribute_id) || (!empty($attribute_select_options) && empty($attribute_select_options[0]->data_type_to_use))) {
2778
+			unset($input_def); $input_def = array();
2779 2779
 			$input_def['label'] = __('Type of data for list', 'wpshop');
2780 2780
 			$input_def['type'] = 'radio';
2781 2781
 			$input_def['name'] = 'data_type_to_use';
2782 2782
 			$input_def['valueToPut'] = 'index';
2783 2783
 			$input_def['possible_value'] = unserialize(WPSHOP_ATTR_SELECT_TYPE);
2784 2784
 			$input_def['option'] = 'class="wpshop_cls wpshop_attr_combo_data_type"';
2785
-			$input_def['value'] = $data_type.'_data';
2785
+			$input_def['value'] = $data_type . '_data';
2786 2786
 			$input_def['options_label']['original'] = true;
2787 2787
 			$output = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
2788 2788
 		}
2789 2789
 
2790
-		if(!empty($attribute_id) || !empty($data_type)){
2791
-			$defaut_value = ( !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->default_value) ) ? $attribute_select_options[0]->default_value : null;
2790
+		if (!empty($attribute_id) || !empty($data_type)) {
2791
+			$defaut_value = (!empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->default_value)) ? $attribute_select_options[0]->default_value : null;
2792 2792
 			$default_is_serial = false;
2793
-			if ( !empty($attribute_select_options[0]->default_value) && ($attribute_select_options[0]->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute_select_options[0]->default_value ) ) ) {
2793
+			if (!empty($attribute_select_options[0]->default_value) && ($attribute_select_options[0]->default_value == serialize(false) || wpshop_tools::is_serialized($attribute_select_options[0]->default_value))) {
2794 2794
 				$defaut_value = unserialize($attribute_select_options[0]->default_value);
2795 2795
 				$default_is_serial = true;
2796 2796
 			}
2797 2797
 			/**	Add a custom text first item of list	*/
2798
-			$output .= '<div class="wpshop_cls" ><label for="text_for_empty_value" >' . __('Text displayed when no value selected', 'wpshop') . '</label> <input type="text" name="' . WPSHOP_DBT_ATTRIBUTE . '[default_value][field_options][label_for_first_item]" value="' . (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["field_options"]["label_for_first_item"])) ? stripslashes( $defaut_value["field_options"]["label_for_first_item"] ) : __('Choose a value', 'wpshop')) . '" id="text_for_empty_value" /></div>';
2798
+			$output .= '<div class="wpshop_cls" ><label for="text_for_empty_value" >' . __('Text displayed when no value selected', 'wpshop') . '</label> <input type="text" name="' . WPSHOP_DBT_ATTRIBUTE . '[default_value][field_options][label_for_first_item]" value="' . (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["field_options"]["label_for_first_item"])) ? stripslashes($defaut_value["field_options"]["label_for_first_item"]) : __('Choose a value', 'wpshop')) . '" id="text_for_empty_value" /></div>';
2799 2799
 
2800
-			if((($data_type == 'custom') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'custom'))){
2800
+			if ((($data_type == 'custom') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'custom'))) {
2801 2801
 				$sub_output = '';
2802
-				if ( !empty($attribute_select_options) && !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->id) ) {
2802
+				if (!empty($attribute_select_options) && !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->id)) {
2803 2803
 					$sub_output .= '
2804 2804
 					<li class="wpshop_attribute_combo_options_container ui-state-disabled" >
2805 2805
 						<input type="radio" name="' . WPSHOP_DBT_ATTRIBUTE . '[default_value][default_value]" value="" id="default_value_empty" ' . (($default_is_serial && is_array($defaut_value) && empty($defaut_value["default_value"])) || empty($defaut_value) ? 'checked ' : '') . '/> <label for="default_value_empty">' . __('No default value', 'wpshop') . '</label>
@@ -2812,7 +2812,7 @@  discard block
 block discarded – undo
2812 2812
 						$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_VALUE'] = str_replace(".", ",", $options->value);
2813 2813
 						$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_STATE'] = (!empty($options->id) && (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["default_value"]) && ($defaut_value["default_value"] == $options->id))) ? ' checked="checked"' : '');
2814 2814
 						$tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] = '';
2815
-						if( current_user_can('wpshop_delete_attributes_select_values') && ($options->value_id >= 0) ):
2815
+						if (current_user_can('wpshop_delete_attributes_select_values') && ($options->value_id >= 0)):
2816 2816
 							$tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item_deletion', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_id), 'admin');
2817 2817
 						endif;
2818 2818
 						$sub_output .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_id), 'admin');
@@ -2820,13 +2820,13 @@  discard block
 block discarded – undo
2820 2820
 					}
2821 2821
 				}
2822 2822
 				$add_button = $add_dialog_box = $user_more_script = '';
2823
-				if( current_user_can('wpshop_add_attributes_select_values') ) {
2823
+				if (current_user_can('wpshop_add_attributes_select_values')) {
2824 2824
 
2825 2825
 					$dialog_title = __('New value for attribute', 'wpshop');
2826 2826
 					$dialog_identifier = 'wpshop_new_attribute_option_value_add';
2827 2827
 					$dialog_input_identifier = 'wpshop_new_attribute_option_value';
2828 2828
 					ob_start();
2829
-					include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php');
2829
+					include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php');
2830 2830
 					$add_dialog_box = ob_get_contents();
2831 2831
 					ob_end_clean();
2832 2832
 
@@ -2834,23 +2834,23 @@  discard block
 block discarded – undo
2834 2834
 					$add_button_parent_class = 'wpshop_attribute_option_value_add';
2835 2835
 					$add_button_name = 'wpshop_add_option_to_select';
2836 2836
 					ob_start();
2837
-					include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_with_dialog.tpl.php');
2837
+					include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_with_dialog.tpl.php');
2838 2838
 					$add_button = ob_get_contents();
2839 2839
 					ob_end_clean();
2840 2840
 
2841 2841
 					$user_more_script = '
2842
-			jQuery("#'.$dialog_identifier.'").dialog({
2842
+			jQuery("#'.$dialog_identifier . '").dialog({
2843 2843
 				modal: true,
2844 2844
 				dialogClass: "wpshop_uidialog_box",
2845 2845
 				autoOpen:false,
2846 2846
 				show: "blind",
2847 2847
 				resizable: false,
2848 2848
 				buttons:{
2849
-					"'.__('Add', 'wpshop').'": function(){
2849
+					"'.__('Add', 'wpshop') . '": function(){
2850 2850
 						var data = {
2851 2851
 							action: "new_option_for_select",
2852 2852
 							wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_new_option_for_attribute_creation") . '",
2853
-							attribute_new_label: jQuery("#'.$dialog_input_identifier.'").val(),
2853
+							attribute_new_label: jQuery("#'.$dialog_input_identifier . '").val(),
2854 2854
 							attribute_identifier: "' . $attribute_id . '"
2855 2855
 						};
2856 2856
 						jQuery.post(ajaxurl, data, function(response) {
@@ -2866,21 +2866,21 @@  discard block
 block discarded – undo
2866 2866
 
2867 2867
 						jQuery(this).children("img").show();
2868 2868
 					},
2869
-					"'.__('Cancel', 'wpshop').'": function(){
2869
+					"'.__('Cancel', 'wpshop') . '": function(){
2870 2870
 						jQuery(this).dialog("close");
2871 2871
 					}
2872 2872
 				},
2873 2873
 				close:function(){
2874
-					jQuery("#'.$dialog_input_identifier.'").val("");
2874
+					jQuery("#'.$dialog_input_identifier . '").val("");
2875 2875
 				}
2876 2876
 			});
2877
-			jQuery(".'.$add_button_parent_class.' input").click(function(){
2878
-				jQuery("#'.$dialog_identifier.'").dialog("open");
2877
+			jQuery(".'.$add_button_parent_class . ' input").click(function(){
2878
+				jQuery("#'.$dialog_identifier . '").dialog("open");
2879 2879
 			});';
2880 2880
 
2881 2881
 				}
2882 2882
 				$output .= $add_dialog_box . '
2883
-	<ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options)>5 ? $add_button : '').$sub_output.$add_button.'
2883
+	<ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options) > 5 ? $add_button : '') . $sub_output . $add_button . '
2884 2884
 	</ul>
2885 2885
 	<input type="hidden" value="' . wp_create_nonce("wpshop_new_option_for_attribute_deletion") . '" name="wpshop_new_option_for_attribute_deletion_nonce" id="wpshop_new_option_for_attribute_deletion_nonce" />
2886 2886
 	<script type="text/javascript" >
@@ -2896,7 +2896,7 @@  discard block
 block discarded – undo
2896 2896
 					var data = {
2897 2897
 						action: "attribute_output_type",
2898 2898
 						current_type: jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").val(),
2899
-						elementIdentifier: "'.$attribute_id.'",
2899
+						elementIdentifier: "'.$attribute_id . '",
2900 2900
 						data_type_to_use: jQuery(this).val(),
2901 2901
 						wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_output_type_selection") . '"
2902 2902
 					};
@@ -2911,10 +2911,10 @@  discard block
 block discarded – undo
2911 2911
 		});
2912 2912
 	</script>';
2913 2913
 			}
2914
-			elseif((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))){
2915
-				$sub_output='';
2914
+			elseif ((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))) {
2915
+				$sub_output = '';
2916 2916
 				$wp_types = unserialize(WPSHOP_INTERNAL_TYPES);
2917
-				unset($input_def);$input_def=array();
2917
+				unset($input_def); $input_def = array();
2918 2918
 				$input_def['label'] = __('Type of data for list', 'wpshop');
2919 2919
 				$input_def['type'] = 'select';
2920 2920
 				$input_def['name'] = 'default_value][default_value';
@@ -2923,20 +2923,20 @@  discard block
 block discarded – undo
2923 2923
 				$input_def['possible_value'] = $wp_types;
2924 2924
 				$input_def['value'] = (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["default_value"])) ? $defaut_value["default_value"] : (!empty($defaut_value) ? $defaut_value : null));
2925 2925
 				$combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
2926
-				$output .= '<div class="wpshop_cls">'.$combo_wp_type.'</div>';
2927
-				if ( !empty($attribute_id) ) {
2926
+				$output .= '<div class="wpshop_cls">' . $combo_wp_type . '</div>';
2927
+				if (!empty($attribute_id)) {
2928 2928
 					$option_list = '<div>' . __('You can reorder element for display them in the order you want into frontend part', 'wpshop') . '</div>';
2929
-					$options_for_current_attribute = query_posts( array('post_type' => $input_def['value'], 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC' ) );
2930
-					if ( !empty($options_for_current_attribute) ) {
2929
+					$options_for_current_attribute = query_posts(array('post_type' => $input_def['value'], 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC'));
2930
+					if (!empty($options_for_current_attribute)) {
2931 2931
 						$option_list .= '<ul class="wpshop_attribute_combo_values_list_container" >';
2932 2932
 						$current_order = ' ';
2933
-						foreach ( $options_for_current_attribute as $options_def ) {
2933
+						foreach ($options_for_current_attribute as $options_def) {
2934 2934
 							$current_order .= 'post_' . $options_def->ID . ',';
2935 2935
 							$option_list .= '<li id="post_' . $options_def->ID . '" class="wpshop_attribute_combo_values_list_item wpshop_attribute_combo_values_list_item_' . $options_def->ID . '" ><span class="wpshop_internal_value_for_option_list_identifier" >#' . $options_def->ID . '</span> ' . $options_def->post_title . '</li>';
2936 2936
 						}
2937 2937
 						$option_list .= '</ul><input type="hidden" value="' . substr($current_order, 0, -1) . '" name="' . WPSHOP_DBT_ATTRIBUTE . '[wpshop_attribute_combo_values_list_order_def]" id="wpshop_attribute_combo_values_list_order_def" />';
2938 2938
 					}
2939
-					$output .= '<div class="wpshop_cls">'.$option_list.'</div>';
2939
+					$output .= '<div class="wpshop_cls">' . $option_list . '</div>';
2940 2940
 				}
2941 2941
 			}
2942 2942
 		}
@@ -2964,8 +2964,8 @@  discard block
 block discarded – undo
2964 2964
 		$attribute_list_for_entity = self::getElement($entity_id, "'valid'", 'entity_id', true);
2965 2965
 
2966 2966
 		/*	Read the list	*/
2967
-		if ( !empty ($attribute_list_for_entity ) ) {
2968
-			foreach ( $attribute_list_for_entity as $attribute) {
2967
+		if (!empty ($attribute_list_for_entity)) {
2968
+			foreach ($attribute_list_for_entity as $attribute) {
2969 2969
 				switch ($list_for) {
2970 2970
 					case 'attribute_value':
2971 2971
 							$checkbox_state = ' ';
@@ -2974,8 +2974,8 @@  discard block
 block discarded – undo
2974 2974
 								<select id="wpshop_shortcode_element_attribute_value_product_list_' . $attribute->id . '" class="wpshop_shortcode_element_attribute_value_product_list" >';
2975 2975
 
2976 2976
 							global $post;
2977
-							$posts = get_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'numberposts' => -1) );
2978
-							foreach( $posts as $post ) :
2977
+							$posts = get_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'numberposts' => -1));
2978
+							foreach ($posts as $post) :
2979 2979
 								setup_postdata($post);
2980 2980
 								$attribute_possible_values .= '<option value="' . get_the_ID() . '" >' . get_the_ID() . ' - ' . get_the_title() . '</option>';
2981 2981
 							endforeach;
@@ -2991,23 +2991,23 @@  discard block
 block discarded – undo
2991 2991
 
2992 2992
 						$checkbox_state = 'disabled ';
2993 2993
 						$attribute_possible_values = '';
2994
-						if ( !empty($attribute_values) ) {
2994
+						if (!empty($attribute_values)) {
2995 2995
 							$checkbox_state = '';
2996 2996
 							$attribute_possible_values = '
2997 2997
 							<div class="wpshop_shortcode_element_product_listing_per_attribute_value wpshop_shortcode_element_prodcut_listing_per_attribute_value_' . $attribute->code . '_container" >
2998 2998
 								<select id="wpshop_attribute_value_for_shortcode_generation_' . $attribute->id . '" class="wpshop_shortcode_element_prodcut_listing_per_attribute_value hidden" >';
2999 2999
 
3000
-								if ( ($attribute->data_type == 'integer') && ( ($attribute->backend_input == 'select') || ($attribute->backend_input == 'multiple-select') ) ) {
3000
+								if (($attribute->data_type == 'integer') && (($attribute->backend_input == 'select') || ($attribute->backend_input == 'multiple-select'))) {
3001 3001
 									$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id=%d ORDER BY position", $attribute->id);
3002 3002
 									$possible_values = $wpdb->get_results($query);
3003 3003
 									$already_selected_values = array();
3004 3004
 									foreach ($attribute_values as $attribute_value) {
3005
-										if ( !empty($attribute_value->value) ) {
3005
+										if (!empty($attribute_value->value)) {
3006 3006
 											$already_selected_values[] = $attribute_value->value;
3007 3007
 										}
3008 3008
 									}
3009 3009
 									foreach ($possible_values as $value) {
3010
-										if ( in_array( $value->id, $already_selected_values ) ) {
3010
+										if (in_array($value->id, $already_selected_values)) {
3011 3011
 											$attribute_possible_values .= '
3012 3012
 									<option value="' . $value->value . '" >' . $value->label . '</option>';
3013 3013
 										}
@@ -3015,7 +3015,7 @@  discard block
 block discarded – undo
3015 3015
 								}
3016 3016
 								else {
3017 3017
 									foreach ($attribute_values as $attribute_value) {
3018
-										if ( !empty($attribute_value->value) ) {
3018
+										if (!empty($attribute_value->value)) {
3019 3019
 											$attribute_possible_values .= '
3020 3020
 									<option value="' . $attribute_value->value . '" >' . $attribute_value->value . '</option>';
3021 3021
 										}
@@ -3044,23 +3044,23 @@  discard block
 block discarded – undo
3044 3044
 	 *
3045 3045
 	 * @return object The attribute list as a wordpress database object
3046 3046
 	 */
3047
-	function get_attribute_list_in_same_set_section( $attribute_code ) {
3047
+	function get_attribute_list_in_same_set_section($attribute_code) {
3048 3048
 		global $wpdb;
3049 3049
 
3050 3050
 		$attribute_def = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
3051 3051
 
3052 3052
 		/** Get the entire list of attribute in price set section for display	*/
3053
-		$query = $wpdb->prepare( "SELECT entity_type_id, attribute_set_id, attribute_group_id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_id = %d AND status = 'valid'", $attribute_def->id);
3053
+		$query = $wpdb->prepare("SELECT entity_type_id, attribute_set_id, attribute_group_id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_id = %d AND status = 'valid'", $attribute_def->id);
3054 3054
 		$attribute_attribution_def = $wpdb->get_row($query);
3055 3055
 
3056
-		$query = $wpdb->prepare( "
3056
+		$query = $wpdb->prepare("
3057 3057
 							SELECT ATTR.code, is_visible_in_front_listing, is_visible_in_front
3058 3058
 							FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " AS SET_SECTION_DETAIL
3059 3059
 								INNER JOIN " . WPSHOP_DBT_ATTRIBUTE . " AS ATTR ON (ATTR.id = SET_SECTION_DETAIL.attribute_id)
3060 3060
 							WHERE entity_type_id = %d
3061 3061
 								AND attribute_set_id = %d
3062 3062
 								AND attribute_group_id = %d",
3063
-				$attribute_attribution_def->entity_type_id, $attribute_attribution_def->attribute_set_id, $attribute_attribution_def->attribute_group_id );
3063
+				$attribute_attribution_def->entity_type_id, $attribute_attribution_def->attribute_set_id, $attribute_attribution_def->attribute_group_id);
3064 3064
 		$atribute_list = $wpdb->get_results($query);
3065 3065
 
3066 3066
 		return $atribute_list;
@@ -3071,7 +3071,7 @@  discard block
 block discarded – undo
3071 3071
 	 * @param unknown_type $current_entity_id
3072 3072
 	 * @return Ambigous <multitype:, multitype:NULL >
3073 3073
 	 */
3074
-	public static function get_variation_available_attribute( $current_entity_id ) {
3074
+	public static function get_variation_available_attribute($current_entity_id) {
3075 3075
 		global $wpdb;
3076 3076
 		$final_list = array();
3077 3077
 
@@ -3079,7 +3079,7 @@  discard block
 block discarded – undo
3079 3079
 		$query = $wpdb->prepare(
3080 3080
 				"SELECT ATT.*, ENTITY_META.meta_value
3081 3081
 				FROM " . self::getDbTable() . " AS ATT
3082
-					INNER JOIN " . WPSHOP_DBT_ATTRIBUTE_DETAILS. " AS ATT_DETAILS ON ((ATT_DETAILS.attribute_id = ATT.id) AND (ATT_DETAILS.entity_type_id = %d) AND (ATT_DETAILS.status = 'valid'))
3082
+					INNER JOIN " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " AS ATT_DETAILS ON ((ATT_DETAILS.attribute_id = ATT.id) AND (ATT_DETAILS.entity_type_id = %d) AND (ATT_DETAILS.status = 'valid'))
3083 3083
 					INNER JOIN " . $wpdb->postmeta . " AS ENTITY_META ON ((ENTITY_META.meta_key = %s) AND (ENTITY_META.meta_value = ATT_DETAILS.attribute_set_id))
3084 3084
 				WHERE ATT.status IN ('valid')
3085 3085
 					AND ATT.is_used_for_variation = %s
@@ -3089,10 +3089,10 @@  discard block
 block discarded – undo
3089 3089
 		);
3090 3090
 		$attribute_list = $wpdb->get_results($query);
3091 3091
 		foreach ($attribute_list as $attribute) {
3092
-			if ( !in_array($attribute->code, unserialize(WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE)) && in_array($attribute->backend_input, array('select', 'multiple-select')) ) {
3093
-				$attribute_values_for_variations = wpshop_attributes::get_affected_value_for_list( $attribute->code, $current_entity_id, $attribute->data_type_to_use );
3092
+			if (!in_array($attribute->code, unserialize(WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE)) && in_array($attribute->backend_input, array('select', 'multiple-select'))) {
3093
+				$attribute_values_for_variations = wpshop_attributes::get_affected_value_for_list($attribute->code, $current_entity_id, $attribute->data_type_to_use);
3094 3094
 
3095
-				if ( empty($attribute_values_for_variations) ) {
3095
+				if (empty($attribute_values_for_variations)) {
3096 3096
 					$final_list['unavailable'][$attribute->code]['label'] = $attribute->frontend_label;
3097 3097
 					$final_list['unavailable'][$attribute->code]['values'] = array();
3098 3098
 					$final_list['unavailable'][$attribute->code]['attribute_complete_def'] = $attribute;
@@ -3112,16 +3112,16 @@  discard block
 block discarded – undo
3112 3112
 	 * @param integer $current_entity_id The current element edited
3113 3113
 	 * @return Ambigous <string, string, mixed>
3114 3114
 	 */
3115
-	public static function get_variation_available_attribute_display( $current_entity_id, $variation_type = 'multiple' ) {
3115
+	public static function get_variation_available_attribute_display($current_entity_id, $variation_type = 'multiple') {
3116 3116
 		$attribute_list = wpshop_attributes::get_variation_available_attribute($current_entity_id);
3117 3117
 
3118 3118
 		$attribute_defined_as_available_for_variation = '';
3119
-		if ( !empty($attribute_list) ) {
3119
+		if (!empty($attribute_list)) {
3120 3120
 			foreach ($attribute_list as $list_type => $attribute_list_by_type) {
3121 3121
 				$sub_attribute_list = '';
3122 3122
 				foreach ($attribute_list_by_type as $attribute_code => $attribute_def) {
3123 3123
 					$tpl_component = array();
3124
-					if ( $list_type == 'available' ) {
3124
+					if ($list_type == 'available') {
3125 3125
 						$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = '';
3126 3126
 						$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = '';
3127 3127
 						$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = '';
@@ -3135,13 +3135,13 @@  discard block
 block discarded – undo
3135 3135
 					$tpl_component['ADMIN_ATTRIBUTE_CODE_FOR_VARIATION'] = $attribute_code;
3136 3136
 					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_code;
3137 3137
 					$tpl_component['ADMIN_VARIATION_ATTRIBUTE_CONTAINER_CLASS'] = ' wpshop_attribute_for_variation_' . $attribute_code;
3138
-					$tpl_component['ADMIN_VARIATION_NEW_SINGLE_LABEL'] = __( $attribute_def['label'], 'wpshop' );
3138
+					$tpl_component['ADMIN_VARIATION_NEW_SINGLE_LABEL'] = __($attribute_def['label'], 'wpshop');
3139 3139
 					$tpl_component['ADMIN_VARIATION_NEW_SINGLE_INPUT'] = '';
3140
-					if ( $variation_type == 'single' ) {
3141
-						$attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute_def['attribute_complete_def'], $attribute_def['values'], array('from' => 'frontend', 'field_custom_name_prefix' => 'variation_attr', 'input_class' => ' variation_attribute_usable_input') );
3142
-						if ( !empty($attribute_output_def['possible_value']) ) {
3143
-							foreach( $attribute_output_def['possible_value'] as $value_id => $value ){
3144
-								if ( !in_array($value_id, $attribute_def['values']) ) {
3140
+					if ($variation_type == 'single') {
3141
+						$attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute_def['attribute_complete_def'], $attribute_def['values'], array('from' => 'frontend', 'field_custom_name_prefix' => 'variation_attr', 'input_class' => ' variation_attribute_usable_input'));
3142
+						if (!empty($attribute_output_def['possible_value'])) {
3143
+							foreach ($attribute_output_def['possible_value'] as $value_id => $value) {
3144
+								if (!in_array($value_id, $attribute_def['values'])) {
3145 3145
 									unset($attribute_output_def['possible_value'][$value_id]);
3146 3146
 								}
3147 3147
 							}
@@ -3156,7 +3156,7 @@  discard block
 block discarded – undo
3156 3156
 			}
3157 3157
 		}
3158 3158
 
3159
-		return array($attribute_defined_as_available_for_variation, ( (!empty($attribute_list['available']) ) ? $attribute_list['available'] : ''), ( ( !empty($attribute_list['unavailable']) ) ? $attribute_list['unavailable'] : ''));
3159
+		return array($attribute_defined_as_available_for_variation, ((!empty($attribute_list['available'])) ? $attribute_list['available'] : ''), ((!empty($attribute_list['unavailable'])) ? $attribute_list['unavailable'] : ''));
3160 3160
 	}
3161 3161
 
3162 3162
 	/**
@@ -3165,18 +3165,18 @@  discard block
 block discarded – undo
3165 3165
 	 * @param array $variations_attribute_parameters Allows to give some parameters for customize list
3166 3166
 	 * @return string The output for all specific attribute in each product with option
3167 3167
 	 */
3168
-	public static function get_variation_attribute( $variations_attribute_parameters ) {
3168
+	public static function get_variation_attribute($variations_attribute_parameters) {
3169 3169
 		$output = '';
3170 3170
 
3171 3171
 		$attribute_list = wpshop_attributes::getElement('yes', "'valid'", "is_used_in_variation", true);
3172
-		if ( !empty( $attribute_list ) ) {
3172
+		if (!empty($attribute_list)) {
3173 3173
 			$tpl_component = array();
3174 3174
 			$tpl_component['ADMIN_VARIATION_DETAIL'] = '';
3175 3175
 			$price_piloting_option = get_option('wpshop_shop_price_piloting');
3176
-			foreach ( $attribute_list as $attribute_def ) {
3176
+			foreach ($attribute_list as $attribute_def) {
3177 3177
 
3178 3178
 				$variations_attribute_parameters['field_custom_name_prefix'] = $variations_attribute_parameters['field_name'] . '[attribute][' . $attribute_def->data_type . ']';
3179
-				$attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute_def, (!empty($variations_attribute_parameters['variation_dif_values'][$attribute_def->code]) ? $variations_attribute_parameters['variation_dif_values'][$attribute_def->code] : ''), $variations_attribute_parameters );
3179
+				$attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute_def, (!empty($variations_attribute_parameters['variation_dif_values'][$attribute_def->code]) ? $variations_attribute_parameters['variation_dif_values'][$attribute_def->code] : ''), $variations_attribute_parameters);
3180 3180
 
3181 3181
 				$field_output = $attribute_output_def['output'];
3182 3182
 
@@ -3188,9 +3188,9 @@  discard block
 block discarded – undo
3188 3188
 				$sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_ID'] = $attribute_output_def['id'];
3189 3189
 				$sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_LABEL'] = $attribute_output_def['label'];
3190 3190
 				$sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] = $field_output;
3191
-				if( isset( $variations_attribute_parameters['post_id'] ) ) {
3192
-					$attribute_option_display = $attribute_def->backend_input=='select' && (strtolower( __(self::get_attribute_type_select_option_info($attribute_output_def['value'], 'value'), 'wpshop') ) == strtolower( __('yes', 'wpshop') )) ? '' : ' wpshopHide';
3193
-					$sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] .= '<div class="attribute_option_'.$attribute_def->code.''.$attribute_option_display.'">'.self::get_attribute_option_fields($variations_attribute_parameters['post_id'], $attribute_def->code).'</div>';
3191
+				if (isset($variations_attribute_parameters['post_id'])) {
3192
+					$attribute_option_display = $attribute_def->backend_input == 'select' && (strtolower(__(self::get_attribute_type_select_option_info($attribute_output_def['value'], 'value'), 'wpshop')) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide';
3193
+					$sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] .= '<div class="attribute_option_' . $attribute_def->code . '' . $attribute_option_display . '">' . self::get_attribute_option_fields($variations_attribute_parameters['post_id'], $attribute_def->code) . '</div>';
3194 3194
 				}
3195 3195
 				$tpl_component['ADMIN_VARIATION_DETAIL'] .= wpshop_display::display_template_element('wpshop_admin_variation_item_details_line', $sub_tpl_component, array(), 'admin');
3196 3196
 				unset($sub_tpl_component);
@@ -3201,7 +3201,7 @@  discard block
 block discarded – undo
3201 3201
 		return $output;
3202 3202
 	}
3203 3203
 
3204
-	public static function get_attribute_user_defined( $use_defined_parameters, $status = "'publish'" ) {
3204
+	public static function get_attribute_user_defined($use_defined_parameters, $status = "'publish'") {
3205 3205
 		global $wpdb;
3206 3206
 		$attribute_user_defined_list = array();
3207 3207
 
@@ -3228,12 +3228,12 @@  discard block
 block discarded – undo
3228 3228
 	 * @param string $post_type The current
3229 3229
 	 *
3230 3230
 	 */
3231
-	function quick_edit( $column_name, $entity ) {
3232
-		switch ( $entity ) {
3231
+	function quick_edit($column_name, $entity) {
3232
+		switch ($entity) {
3233 3233
 			case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
3234 3234
 				$attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code');
3235
-				if ( !empty($attribute_def) ) {
3236
-					$input_def = self::get_attribute_field_definition( $attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input') );
3235
+				if (!empty($attribute_def)) {
3236
+					$input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input'));
3237 3237
 					$input = wpshop_form::check_input_type($input_def, $input_def['input_domain']);
3238 3238
 ?>
3239 3239
 	<div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php echo $column_name; ?>_container">
@@ -3253,12 +3253,12 @@  discard block
 block discarded – undo
3253 3253
 	 * @param string $post_type The current
3254 3254
 	 *
3255 3255
 	 */
3256
-	public static function bulk_edit( $column_name, $entity ) {
3257
-		switch ( $entity ) {
3256
+	public static function bulk_edit($column_name, $entity) {
3257
+		switch ($entity) {
3258 3258
 			case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
3259 3259
 				$attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code');
3260
-				if ( !empty($attribute_def) ) {
3261
-					$input_def = self::get_attribute_field_definition( $attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input') );
3260
+				if (!empty($attribute_def)) {
3261
+					$input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input'));
3262 3262
 					$input = wpshop_form::check_input_type($input_def, $input_def['input_domain']);
3263 3263
 ?>
3264 3264
 	<div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php echo $column_name; ?>_container">
Please login to merge, or discard this patch.