Completed
Pull Request — master (#2)
by Jimmy
1003:35 queued 970:52
created
includes/librairies/HTML2PDF/html2pdf.class.php 4 patches
Doc Comments   +16 added lines, -19 removed lines patch added patch discarded remove patch
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
          *
118 118
          * @access public
119 119
          * @param  string   $orientation page orientation, same as TCPDF
120
-         * @param  mixed    $format      The format used for pages, same as TCPDF
120
+         * @param  string    $format      The format used for pages, same as TCPDF
121 121
          * @param  $tring   $langue      Langue : fr, en, it...
122 122
          * @param  boolean  $unicode     TRUE means that the input text is unicode (default = true)
123 123
          * @param  String   $encoding    charset encoding; default is UTF-8
124
-         * @param  array    $marges      Default marges (left, top, right, bottom)
124
+         * @param  integer[]    $marges      Default marges (left, top, right, bottom)
125 125
          * @return HTML2PDF $this
126 126
          */
127 127
         public function __construct($orientation = 'P', $format = 'A4', $langue='fr', $unicode=true, $encoding='UTF-8', $marges = array(5, 5, 5, 8))
@@ -282,7 +282,6 @@  discard block
 block discarded – undo
282 282
          * @access public
283 283
          * @param string $family Font family. The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font.
284 284
          * @param string $style Font style. Possible values are (case insensitive):<ul><li>empty string: regular (default)</li><li>B: bold</li><li>I: italic</li><li>BI or IB: bold italic</li></ul>
285
-         * @param string $fontfile The font definition file. By default, the name is built from the family and style, in lower case with no spaces.
286 285
          * @return HTML2PDF $this
287 286
          * @see TCPDF::addFont
288 287
          */
@@ -413,6 +412,7 @@  discard block
 block discarded – undo
413 412
          *
414 413
          * @access public
415 414
          * @param  string HTML of a real page
415
+         * @param string $html
416 416
          * @return string HTML adapted to HTML2PDF
417 417
          */
418 418
         public function getHtmlFromPage($html)
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
          * display the content in HTML moden for debug
475 475
          *
476 476
          * @access protected
477
-         * @param  string $contenu
477
+         * @param  string $content
478 478
          */
479 479
         protected function _vueHTML($content)
480 480
         {
@@ -1856,7 +1856,7 @@  discard block
 block discarded – undo
1856 1856
          * draw a curve (for border radius)
1857 1857
          *
1858 1858
          * @access protected
1859
-         * @param  array $pt
1859
+         * @param  double[] $pt
1860 1860
          * @param  array $color
1861 1861
          */
1862 1862
         protected function _drawCurve($pt, $color)
@@ -3237,7 +3237,7 @@  discard block
 block discarded – undo
3237 3237
          * this is not a real TAG, it is just to write texts
3238 3238
          *
3239 3239
          * @param  array $param
3240
-         * @return boolean
3240
+         * @return null|boolean
3241 3241
          */
3242 3242
         protected function _tag_open_WRITE($param)
3243 3243
         {
@@ -4201,7 +4201,6 @@  discard block
 block discarded – undo
4201 4201
          * mode : OPEN
4202 4202
          *
4203 4203
          * @param  array $param
4204
-         * @param  string $other
4205 4204
          * @return boolean
4206 4205
          */
4207 4206
         protected function _tag_open_CODE($param)
@@ -5079,7 +5078,7 @@  discard block
 block discarded – undo
5079 5078
          * mode : OPEN
5080 5079
          *
5081 5080
          * @param  array $param
5082
-         * @return boolean
5081
+         * @return boolean|null
5083 5082
          */
5084 5083
         protected function _tag_open_COL($param)
5085 5084
         {
@@ -5696,7 +5695,6 @@  discard block
 block discarded – undo
5696 5695
          * tag : SELECT
5697 5696
          * mode : CLOSE
5698 5697
          *
5699
-         * @param  array $param
5700 5698
          * @return boolean
5701 5699
          */
5702 5700
         protected function _tag_close_SELECT()
@@ -5800,7 +5798,6 @@  discard block
 block discarded – undo
5800 5798
          * tag : TEXTAREA
5801 5799
          * mode : CLOSE
5802 5800
          *
5803
-         * @param  array $param
5804 5801
          * @return boolean
5805 5802
          */
5806 5803
         protected function _tag_close_TEXTAREA()
@@ -6110,7 +6107,7 @@  discard block
 block discarded – undo
6110 6107
          * mode : OPEN
6111 6108
          *
6112 6109
          * @param  array $param
6113
-         * @return boolean
6110
+         * @return boolean|null
6114 6111
          */
6115 6112
         protected function _tag_open_LINE($param)
6116 6113
         {
@@ -6137,7 +6134,7 @@  discard block
 block discarded – undo
6137 6134
          * mode : OPEN
6138 6135
          *
6139 6136
          * @param  array $param
6140
-         * @return boolean
6137
+         * @return boolean|null
6141 6138
          */
6142 6139
         protected function _tag_open_RECT($param)
6143 6140
         {
@@ -6164,7 +6161,7 @@  discard block
 block discarded – undo
6164 6161
          * mode : OPEN
6165 6162
          *
6166 6163
          * @param  array $param
6167
-         * @return boolean
6164
+         * @return boolean|null
6168 6165
          */
6169 6166
         protected function _tag_open_CIRCLE($param)
6170 6167
         {
@@ -6189,7 +6186,7 @@  discard block
 block discarded – undo
6189 6186
          * mode : OPEN
6190 6187
          *
6191 6188
          * @param  array $param
6192
-         * @return boolean
6189
+         * @return boolean|null
6193 6190
          */
6194 6191
         protected function _tag_open_ELLIPSE($param)
6195 6192
         {
@@ -6216,7 +6213,7 @@  discard block
 block discarded – undo
6216 6213
          * mode : OPEN
6217 6214
          *
6218 6215
          * @param  array $param
6219
-         * @return boolean
6216
+         * @return boolean|null
6220 6217
          */
6221 6218
         protected function _tag_open_POLYLINE($param)
6222 6219
         {
@@ -6262,7 +6259,7 @@  discard block
 block discarded – undo
6262 6259
          * mode : OPEN
6263 6260
          *
6264 6261
          * @param  array $param
6265
-         * @return boolean
6262
+         * @return boolean|null
6266 6263
          */
6267 6264
         protected function _tag_open_POLYGON($param)
6268 6265
         {
@@ -6309,7 +6306,7 @@  discard block
 block discarded – undo
6309 6306
          * mode : OPEN
6310 6307
          *
6311 6308
          * @param  array $param
6312
-         * @return boolean
6309
+         * @return boolean|null
6313 6310
          */
6314 6311
         protected function _tag_open_PATH($param)
6315 6312
         {
@@ -6438,7 +6435,7 @@  discard block
 block discarded – undo
6438 6435
          * mode : OPEN
6439 6436
          *
6440 6437
          * @param  array $param
6441
-         * @return boolean
6438
+         * @return boolean|null
6442 6439
          */
6443 6440
         protected function _tag_open_G($param)
6444 6441
         {
@@ -6455,7 +6452,7 @@  discard block
 block discarded – undo
6455 6452
          * mode : CLOSE
6456 6453
          *
6457 6454
          * @param  array $param
6458
-         * @return boolean
6455
+         * @return boolean|null
6459 6456
          */
6460 6457
         protected function _tag_close_G($param)
6461 6458
         {
Please login to merge, or discard this patch.
Indentation   +6464 added lines, -6465 removed lines patch added patch discarded remove patch
@@ -11,485 +11,484 @@  discard block
 block discarded – undo
11 11
 
12 12
 if (!defined('__CLASS_HTML2PDF__')) {
13 13
 
14
-    define('__CLASS_HTML2PDF__', '4.03');
15
-    define('HTML2PDF_USED_TCPDF_VERSION', '5.0.002');
16
-
17
-    require_once(dirname(__FILE__).'/_class/exception.class.php');
18
-    require_once(dirname(__FILE__).'/_class/locale.class.php');
19
-    require_once(dirname(__FILE__).'/_class/myPdf.class.php');
20
-    require_once(dirname(__FILE__).'/_class/parsingHtml.class.php');
21
-    require_once(dirname(__FILE__).'/_class/parsingCss.class.php');
22
-
23
-    class HTML2PDF
24
-    {
25
-        /**
26
-         * HTML2PDF_myPdf object, extends from TCPDF
27
-         * @var HTML2PDF_myPdf
28
-         */
29
-        public $pdf = null;
30
-
31
-        /**
32
-         * CSS parsing
33
-         * @var HTML2PDF_parsingCss
34
-         */
35
-        public $parsingCss = null;
36
-
37
-        /**
38
-         * HTML parsing
39
-         * @var HTML2PDF_parsingHtml
40
-         */
41
-        public $parsingHtml = null;
42
-
43
-        protected $_langue           = 'fr';        // locale of the messages
44
-        protected $_orientation      = 'P';         // page orientation : Portrait ou Landscape
45
-        protected $_format           = 'A4';        // page format : A4, A3, ...
46
-        protected $_encoding         = '';          // charset encoding
47
-        protected $_unicode          = true;        // means that the input text is unicode (default = true)
48
-
49
-        protected $_testTdInOnepage  = true;        // test of TD that can not take more than one page
50
-        protected $_testIsImage      = true;        // test if the images exist or not
51
-        protected $_testIsDeprecated = false;       // test the deprecated functions
52
-
53
-        protected $_parsePos         = 0;           // position in the parsing
54
-        protected $_tempPos          = 0;           // temporary position for complex table
55
-        protected $_page             = 0;           // current page number
56
-
57
-        protected $_subHtml          = null;        // sub html
58
-        protected $_subPart          = false;       // sub HTML2PDF
59
-        protected $_subHEADER        = array();     // sub action to make the header
60
-        protected $_subFOOTER        = array();     // sub action to make the footer
61
-        protected $_subSTATES        = array();     // array to save some parameters
62
-
63
-        protected $_isSubPart        = false;       // flag : in a sub html2pdf
64
-        protected $_isInThead        = false;       // flag : in a thead
65
-        protected $_isInTfoot        = false;       // flag : in a tfoot
66
-        protected $_isInOverflow     = false;       // flag : in a overflow
67
-        protected $_isInFooter       = false;       // flag : in a footer
68
-        protected $_isInDraw         = null;        // flag : in a draw (svg)
69
-        protected $_isAfterFloat     = false;       // flag : is just after a float
70
-        protected $_isInForm         = false;       // flag : is in a float. false / action of the form
71
-        protected $_isInLink         = '';          // flag : is in a link. empty / href of the link
72
-        protected $_isInParagraph    = false;       // flag : is in a paragraph
73
-        protected $_isForOneLine     = false;       // flag : in a specific sub html2pdf to have the height of the next line
74
-
75
-        protected $_maxX             = 0;           // maximum X of the current zone
76
-        protected $_maxY             = 0;           // maximum Y of the current zone
77
-        protected $_maxE             = 0;           // number of elements in the current zone
78
-        protected $_maxH             = 0;           // maximum height of the line in the current zone
79
-        protected $_maxSave          = array();     // save the maximums of the current zone
80
-        protected $_currentH         = 0;           // height of the current line
81
-
82
-        protected $_defaultLeft      = 0;           // default marges of the page
83
-        protected $_defaultTop       = 0;
84
-        protected $_defaultRight     = 0;
85
-        protected $_defaultBottom    = 0;
86
-        protected $_defaultFont      = null;        // default font to use, is the asked font does not exist
87
-
88
-        protected $_margeLeft        = 0;           // current marges of the page
89
-        protected $_margeTop         = 0;
90
-        protected $_margeRight       = 0;
91
-        protected $_margeBottom      = 0;
92
-        protected $_marges           = array();     // save the different marges of the current page
93
-        protected $_pageMarges       = array();     // float marges of the current page
94
-        protected $_background       = array();     // background informations
95
-
96
-
97
-        protected $_firstPage        = true;        // flag : first page
98
-        protected $_defList          = array();     // table to save the stats of the tags UL and OL
99
-
100
-        protected $_lstAnchor        = array();     // list of the anchors
101
-        protected $_lstField         = array();     // list of the fields
102
-        protected $_lstSelect        = array();     // list of the options of the current select
103
-        protected $_previousCall     = null;        // last action called
104
-
105
-        protected $_debugActif       = false;       // flag : mode debug is active
106
-        protected $_debugOkUsage     = false;       // flag : the function memory_get_usage exist
107
-        protected $_debugOkPeak      = false;       // flag : the function memory_get_peak_usage exist
108
-        protected $_debugLevel       = 0;           // level in the debug
109
-        protected $_debugStartTime   = 0;           // debug start time
110
-        protected $_debugLastTime    = 0;           // debug stop time
111
-
112
-        static protected $_subobj    = null;        // object html2pdf prepared in order to accelerate the creation of sub html2pdf
113
-        static protected $_tables    = array();     // static table to prepare the nested html tables
114
-
115
-        /**
116
-         * class constructor
117
-         *
118
-         * @access public
119
-         * @param  string   $orientation page orientation, same as TCPDF
120
-         * @param  mixed    $format      The format used for pages, same as TCPDF
121
-         * @param  $tring   $langue      Langue : fr, en, it...
122
-         * @param  boolean  $unicode     TRUE means that the input text is unicode (default = true)
123
-         * @param  String   $encoding    charset encoding; default is UTF-8
124
-         * @param  array    $marges      Default marges (left, top, right, bottom)
125
-         * @return HTML2PDF $this
126
-         */
127
-        public function __construct($orientation = 'P', $format = 'A4', $langue='fr', $unicode=true, $encoding='UTF-8', $marges = array(5, 5, 5, 8))
128
-        {
129
-            // init the page number
130
-            $this->_page         = 0;
131
-            $this->_firstPage    = true;
132
-
133
-            // save the parameters
134
-            $this->_orientation  = $orientation;
135
-            $this->_format       = $format;
136
-            $this->_langue       = strtolower($langue);
137
-            $this->_unicode      = $unicode;
138
-            $this->_encoding     = $encoding;
139
-
140
-            // load the Local
141
-            HTML2PDF_locale::load($this->_langue);
142
-
143
-            // create the  HTML2PDF_myPdf object
144
-            $this->pdf = new HTML2PDF_myPdf($orientation, 'mm', $format, $unicode, $encoding);
145
-
146
-            // init the CSS parsing object
147
-            $this->parsingCss = new HTML2PDF_parsingCss($this->pdf);
148
-            $this->parsingCss->fontSet();
149
-            $this->_defList = array();
150
-
151
-            // init some tests
152
-            $this->setTestTdInOnePage(true);
153
-            $this->setTestIsImage(true);
154
-            $this->setTestIsDeprecated(true);
155
-
156
-            // init the default font
157
-            $this->setDefaultFont(null);
158
-
159
-            // init the HTML parsing object
160
-            $this->parsingHtml = new HTML2PDF_parsingHtml($this->_encoding);
161
-            $this->_subHtml = null;
162
-            $this->_subPart = false;
163
-
164
-            // init the marges of the page
165
-            if (!is_array($marges)) $marges = array($marges, $marges, $marges, $marges);
166
-            $this->_setDefaultMargins($marges[0], $marges[1], $marges[2], $marges[3]);
167
-            $this->_setMargins();
168
-            $this->_marges = array();
169
-
170
-            // init the form's fields
171
-            $this->_lstField = array();
172
-
173
-            return $this;
174
-        }
175
-
176
-        /**
177
-         * Destructor
178
-         *
179
-         * @access public
180
-         * @return null
181
-         */
182
-        public function __destruct()
183
-        {
184
-
185
-        }
186
-
187
-        /**
188
-         * Clone to create a sub HTML2PDF from HTML2PDF::$_subobj
189
-         *
190
-         * @access public
191
-         */
192
-        public function __clone()
193
-        {
194
-            $this->pdf = clone $this->pdf;
195
-            $this->parsingHtml = clone $this->parsingHtml;
196
-            $this->parsingCss = clone $this->parsingCss;
197
-            $this->parsingCss->setPdfParent($this->pdf);
198
-        }
199
-
200
-        /**
201
-         * set the debug mode to On
202
-         *
203
-         * @access public
204
-         * @return HTML2PDF $this
205
-         */
206
-        public function setModeDebug()
207
-        {
208
-            $time = microtime(true);
209
-
210
-            $this->_debugActif     = true;
211
-            $this->_debugOkUsage   = function_exists('memory_get_usage');
212
-            $this->_debugOkPeak    = function_exists('memory_get_peak_usage');
213
-            $this->_debugStartTime = $time;
214
-            $this->_debugLastTime  = $time;
215
-
216
-            $this->_DEBUG_stepline('step', 'time', 'delta', 'memory', 'peak');
217
-            $this->_DEBUG_add('Init debug');
218
-
219
-            return $this;
220
-        }
221
-
222
-        /**
223
-         * Set the test of TD thdat can not take more than one page
224
-         *
225
-         * @access public
226
-         * @param  boolean  $mode
227
-         * @return HTML2PDF $this
228
-         */
229
-        public function setTestTdInOnePage($mode = true)
230
-        {
231
-            $this->_testTdInOnepage = $mode ? true : false;
232
-
233
-            return $this;
234
-        }
235
-
236
-        /**
237
-         * Set the test if the images exist or not
238
-         *
239
-         * @access public
240
-         * @param  boolean  $mode
241
-         * @return HTML2PDF $this
242
-         */
243
-        public function setTestIsImage($mode = true)
244
-        {
245
-            $this->_testIsImage = $mode ? true : false;
246
-
247
-            return $this;
248
-        }
249
-
250
-        /**
251
-         * Set the test on deprecated functions
252
-         *
253
-         * @access public
254
-         * @param  boolean  $mode
255
-         * @return HTML2PDF $this
256
-         */
257
-        public function setTestIsDeprecated($mode = true)
258
-        {
259
-            $this->_testIsDeprecated = $mode ? true : false;
260
-
261
-            return $this;
262
-        }
263
-
264
-        /**
265
-         * Set the default font to use, if no font is specify, or if the asked font does not exist
266
-         *
267
-         * @access public
268
-         * @param  string   $default name of the default font to use. If null : Arial is no font is specify, and error if the asked font does not exist
269
-         * @return HTML2PDF $this
270
-         */
271
-        public function setDefaultFont($default = null)
272
-        {
273
-            $this->_defaultFont = $default;
274
-            $this->parsingCss->setDefaultFont($default);
275
-
276
-            return $this;
277
-        }
278
-
279
-        /**
280
-         * add a font, see TCPDF function addFont
281
-         *
282
-         * @access public
283
-         * @param string $family Font family. The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font.
284
-         * @param string $style Font style. Possible values are (case insensitive):<ul><li>empty string: regular (default)</li><li>B: bold</li><li>I: italic</li><li>BI or IB: bold italic</li></ul>
285
-         * @param string $fontfile The font definition file. By default, the name is built from the family and style, in lower case with no spaces.
286
-         * @return HTML2PDF $this
287
-         * @see TCPDF::addFont
288
-         */
289
-        public function addFont($family, $style='', $file='')
290
-        {
291
-            $this->pdf->AddFont($family, $style, $file);
292
-
293
-            return $this;
294
-        }
295
-
296
-        /**
297
-         * display a automatic index, from the bookmarks
298
-         *
299
-         * @access public
300
-         * @param  string  $titre         index title
301
-         * @param  int     $sizeTitle     font size of the index title, in mm
302
-         * @param  int     $sizeBookmark  font size of the index, in mm
303
-         * @param  boolean $bookmarkTitle add a bookmark for the index, at his beginning
304
-         * @param  boolean $displayPage   display the page numbers
305
-         * @param  int     $onPage        if null : at the end of the document on a new page, else on the $onPage page
306
-         * @param  string  $fontName      font name to use
307
-         * @return null
308
-         */
309
-        public function createIndex($titre = 'Index', $sizeTitle = 20, $sizeBookmark = 15, $bookmarkTitle = true, $displayPage = true, $onPage = null, $fontName = 'helvetica')
310
-        {
311
-            $oldPage = $this->_INDEX_NewPage($onPage);
312
-            $this->pdf->createIndex($this, $titre, $sizeTitle, $sizeBookmark, $bookmarkTitle, $displayPage, $onPage, $fontName);
313
-            if ($oldPage) $this->pdf->setPage($oldPage);
314
-        }
315
-
316
-        /**
317
-         * clean up the objects
318
-         *
319
-         * @access protected
320
-         */
321
-        protected function _cleanUp()
322
-        {
323
-            HTML2PDF::$_subobj = null;
324
-            HTML2PDF::$_tables = array();
325
-        }
326
-
327
-        /**
328
-         * Send the document to a given destination: string, local file or browser.
329
-         * Dest can be :
330
-         *  I : send the file inline to the browser (default). The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF.
331
-         *  D : send to the browser and force a file download with the name given by name.
332
-         *  F : save to a local server file with the name given by name.
333
-         *  S : return the document as a string. name is ignored.
334
-         *  FI: equivalent to F + I option
335
-         *  FD: equivalent to F + D option
336
-         *  true  => I
337
-         *  false => S
338
-         *
339
-         * @param  string $name The name of the file when saved.
340
-         * @param  string $dest Destination where to send the document.
341
-         * @return string content of the PDF, if $dest=S
342
-         * @see TCPDF::close
343
-         * @access public
344
-
345
-         */
346
-        public function Output($name = '', $dest = false)
347
-        {
348
-            // close the pdf and clean up
349
-            $this->_cleanUp();
350
-
351
-            // if on debug mode
352
-            if ($this->_debugActif) {
353
-                $this->_DEBUG_add('Before output');
354
-                $this->pdf->Close();
355
-                exit;
356
-            }
357
-
358
-            // complete parameters
359
-            if ($dest===false) $dest = 'I';
360
-            if ($dest===true)  $dest = 'S';
361
-            if ($dest==='')    $dest = 'I';
362
-            if ($name=='')     $name='document.pdf';
363
-
364
-            // clean up the destination
365
-            $dest = strtoupper($dest);
366
-            if (!in_array($dest, array('I', 'D', 'F', 'S', 'FI','FD'))) $dest = 'I';
367
-
368
-            // the name must be a PDF name
369
-            if (strtolower(substr($name, -4))!='.pdf') {
370
-                throw new HTML2PDF_exception(0, 'The output document name "'.$name.'" is not a PDF name');
371
-            }
372
-
373
-            // call the output of TCPDF
374
-            return $this->pdf->Output($name, $dest);
375
-        }
376
-
377
-        /**
378
-         * convert HTML to PDF
379
-         *
380
-         * @access public
381
-         * @param  string   $html
382
-         * @param  boolean  $debugVue  enable the HTML debug vue
383
-         * @return null
384
-         */
385
-        public function writeHTML($html, $debugVue = false)
386
-        {
387
-            // if it is a real html page, we have to convert it
388
-            if (preg_match('/<body/isU', $html))
389
-                $html = $this->getHtmlFromPage($html);
390
-
391
-            $html = str_replace('[[date_y]]', date('Y'), $html);
392
-            $html = str_replace('[[date_m]]', date('m'), $html);
393
-            $html = str_replace('[[date_d]]', date('d'), $html);
394
-
395
-            $html = str_replace('[[date_h]]', date('H'), $html);
396
-            $html = str_replace('[[date_i]]', date('i'), $html);
397
-            $html = str_replace('[[date_s]]', date('s'), $html);
398
-
399
-            // If we are in HTML debug vue : display the HTML
400
-            if ($debugVue) {
401
-                return $this->_vueHTML($html);
402
-            }
403
-
404
-            // convert HTMl to PDF
405
-            $this->parsingCss->readStyle($html);
406
-            $this->parsingHtml->setHTML($html);
407
-            $this->parsingHtml->parse();
408
-            $this->_makeHTMLcode();
409
-        }
410
-
411
-        /**
412
-         * convert the HTML of a real page, to a code adapted to HTML2PDF
413
-         *
414
-         * @access public
415
-         * @param  string HTML of a real page
416
-         * @return string HTML adapted to HTML2PDF
417
-         */
418
-        public function getHtmlFromPage($html)
419
-        {
420
-            $html = str_replace('<BODY', '<body', $html);
421
-            $html = str_replace('</BODY', '</body', $html);
422
-
423
-            // extract the content
424
-            $res = explode('<body', $html);
425
-            if (count($res)<2) return $html;
426
-            $content = '<page'.$res[1];
427
-            $content = explode('</body', $content);
428
-            $content = $content[0].'</page>';
429
-
430
-            // extract the link tags
431
-            preg_match_all('/<link([^>]*)>/isU', $html, $match);
432
-            foreach ($match[0] as $src)
433
-                $content = $src.'</link>'.$content;
434
-
435
-            // extract the css style tags
436
-            preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match);
437
-            foreach ($match[0] as $src)
438
-                $content = $src.$content;
439
-
440
-            return $content;
441
-        }
442
-
443
-        /**
444
-         * init a sub HTML2PDF. does not use it directly. Only the method createSubHTML must use it
445
-         *
446
-         * @access public
447
-         * @param  string  $format
448
-         * @param  string  $orientation
449
-         * @param  array   $marge
450
-         * @param  integer $page
451
-         * @param  array   $defLIST
452
-         * @param  integer $myLastPageGroup
453
-         * @param  integer $myLastPageGroupNb
454
-         */
455
-        public function initSubHtml($format, $orientation, $marge, $page, $defLIST, $myLastPageGroup, $myLastPageGroupNb)
456
-        {
457
-            $this->_isSubPart = true;
458
-
459
-            $this->parsingCss->setOnlyLeft();
460
-
461
-            $this->_setNewPage($format, $orientation, null, null, ($myLastPageGroup!==null));
462
-
463
-            $this->_saveMargin(0, 0, $marge);
464
-            $this->_defList = $defLIST;
465
-
466
-            $this->_page = $page;
467
-            $this->pdf->setMyLastPageGroup($myLastPageGroup);
468
-            $this->pdf->setMyLastPageGroupNb($myLastPageGroupNb);
469
-            $this->pdf->setXY(0, 0);
470
-            $this->parsingCss->fontSet();
471
-        }
472
-
473
-        /**
474
-         * display the content in HTML moden for debug
475
-         *
476
-         * @access protected
477
-         * @param  string $contenu
478
-         */
479
-        protected function _vueHTML($content)
480
-        {
481
-            $content = preg_replace('/<page_header([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue01').' : $1<hr><div$1>', $content);
482
-            $content = preg_replace('/<page_footer([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue02').' : $1<hr><div$1>', $content);
483
-            $content = preg_replace('/<page([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue03').' : $1<hr><div$1>', $content);
484
-            $content = preg_replace('/<\/page([^>]*)>/isU', '</div><hr>', $content);
485
-            $content = preg_replace('/<bookmark([^>]*)>/isU', '<hr>bookmark : $1<hr>', $content);
486
-            $content = preg_replace('/<\/bookmark([^>]*)>/isU', '', $content);
487
-            $content = preg_replace('/<barcode([^>]*)>/isU', '<hr>barcode : $1<hr>', $content);
488
-            $content = preg_replace('/<\/barcode([^>]*)>/isU', '', $content);
489
-            $content = preg_replace('/<qrcode([^>]*)>/isU', '<hr>qrcode : $1<hr>', $content);
490
-            $content = preg_replace('/<\/qrcode([^>]*)>/isU', '', $content);
491
-
492
-            echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
14
+	define('__CLASS_HTML2PDF__', '4.03');
15
+	define('HTML2PDF_USED_TCPDF_VERSION', '5.0.002');
16
+
17
+	require_once(dirname(__FILE__).'/_class/exception.class.php');
18
+	require_once(dirname(__FILE__).'/_class/locale.class.php');
19
+	require_once(dirname(__FILE__).'/_class/myPdf.class.php');
20
+	require_once(dirname(__FILE__).'/_class/parsingHtml.class.php');
21
+	require_once(dirname(__FILE__).'/_class/parsingCss.class.php');
22
+
23
+	class HTML2PDF
24
+	{
25
+		/**
26
+		 * HTML2PDF_myPdf object, extends from TCPDF
27
+		 * @var HTML2PDF_myPdf
28
+		 */
29
+		public $pdf = null;
30
+
31
+		/**
32
+		 * CSS parsing
33
+		 * @var HTML2PDF_parsingCss
34
+		 */
35
+		public $parsingCss = null;
36
+
37
+		/**
38
+		 * HTML parsing
39
+		 * @var HTML2PDF_parsingHtml
40
+		 */
41
+		public $parsingHtml = null;
42
+
43
+		protected $_langue           = 'fr';        // locale of the messages
44
+		protected $_orientation      = 'P';         // page orientation : Portrait ou Landscape
45
+		protected $_format           = 'A4';        // page format : A4, A3, ...
46
+		protected $_encoding         = '';          // charset encoding
47
+		protected $_unicode          = true;        // means that the input text is unicode (default = true)
48
+
49
+		protected $_testTdInOnepage  = true;        // test of TD that can not take more than one page
50
+		protected $_testIsImage      = true;        // test if the images exist or not
51
+		protected $_testIsDeprecated = false;       // test the deprecated functions
52
+
53
+		protected $_parsePos         = 0;           // position in the parsing
54
+		protected $_tempPos          = 0;           // temporary position for complex table
55
+		protected $_page             = 0;           // current page number
56
+
57
+		protected $_subHtml          = null;        // sub html
58
+		protected $_subPart          = false;       // sub HTML2PDF
59
+		protected $_subHEADER        = array();     // sub action to make the header
60
+		protected $_subFOOTER        = array();     // sub action to make the footer
61
+		protected $_subSTATES        = array();     // array to save some parameters
62
+
63
+		protected $_isSubPart        = false;       // flag : in a sub html2pdf
64
+		protected $_isInThead        = false;       // flag : in a thead
65
+		protected $_isInTfoot        = false;       // flag : in a tfoot
66
+		protected $_isInOverflow     = false;       // flag : in a overflow
67
+		protected $_isInFooter       = false;       // flag : in a footer
68
+		protected $_isInDraw         = null;        // flag : in a draw (svg)
69
+		protected $_isAfterFloat     = false;       // flag : is just after a float
70
+		protected $_isInForm         = false;       // flag : is in a float. false / action of the form
71
+		protected $_isInLink         = '';          // flag : is in a link. empty / href of the link
72
+		protected $_isInParagraph    = false;       // flag : is in a paragraph
73
+		protected $_isForOneLine     = false;       // flag : in a specific sub html2pdf to have the height of the next line
74
+
75
+		protected $_maxX             = 0;           // maximum X of the current zone
76
+		protected $_maxY             = 0;           // maximum Y of the current zone
77
+		protected $_maxE             = 0;           // number of elements in the current zone
78
+		protected $_maxH             = 0;           // maximum height of the line in the current zone
79
+		protected $_maxSave          = array();     // save the maximums of the current zone
80
+		protected $_currentH         = 0;           // height of the current line
81
+
82
+		protected $_defaultLeft      = 0;           // default marges of the page
83
+		protected $_defaultTop       = 0;
84
+		protected $_defaultRight     = 0;
85
+		protected $_defaultBottom    = 0;
86
+		protected $_defaultFont      = null;        // default font to use, is the asked font does not exist
87
+
88
+		protected $_margeLeft        = 0;           // current marges of the page
89
+		protected $_margeTop         = 0;
90
+		protected $_margeRight       = 0;
91
+		protected $_margeBottom      = 0;
92
+		protected $_marges           = array();     // save the different marges of the current page
93
+		protected $_pageMarges       = array();     // float marges of the current page
94
+		protected $_background       = array();     // background informations
95
+
96
+
97
+		protected $_firstPage        = true;        // flag : first page
98
+		protected $_defList          = array();     // table to save the stats of the tags UL and OL
99
+
100
+		protected $_lstAnchor        = array();     // list of the anchors
101
+		protected $_lstField         = array();     // list of the fields
102
+		protected $_lstSelect        = array();     // list of the options of the current select
103
+		protected $_previousCall     = null;        // last action called
104
+
105
+		protected $_debugActif       = false;       // flag : mode debug is active
106
+		protected $_debugOkUsage     = false;       // flag : the function memory_get_usage exist
107
+		protected $_debugOkPeak      = false;       // flag : the function memory_get_peak_usage exist
108
+		protected $_debugLevel       = 0;           // level in the debug
109
+		protected $_debugStartTime   = 0;           // debug start time
110
+		protected $_debugLastTime    = 0;           // debug stop time
111
+
112
+		static protected $_subobj    = null;        // object html2pdf prepared in order to accelerate the creation of sub html2pdf
113
+		static protected $_tables    = array();     // static table to prepare the nested html tables
114
+
115
+		/**
116
+		 * class constructor
117
+		 *
118
+		 * @access public
119
+		 * @param  string   $orientation page orientation, same as TCPDF
120
+		 * @param  mixed    $format      The format used for pages, same as TCPDF
121
+		 * @param  $tring   $langue      Langue : fr, en, it...
122
+		 * @param  boolean  $unicode     TRUE means that the input text is unicode (default = true)
123
+		 * @param  String   $encoding    charset encoding; default is UTF-8
124
+		 * @param  array    $marges      Default marges (left, top, right, bottom)
125
+		 * @return HTML2PDF $this
126
+		 */
127
+		public function __construct($orientation = 'P', $format = 'A4', $langue='fr', $unicode=true, $encoding='UTF-8', $marges = array(5, 5, 5, 8))
128
+		{
129
+			// init the page number
130
+			$this->_page         = 0;
131
+			$this->_firstPage    = true;
132
+
133
+			// save the parameters
134
+			$this->_orientation  = $orientation;
135
+			$this->_format       = $format;
136
+			$this->_langue       = strtolower($langue);
137
+			$this->_unicode      = $unicode;
138
+			$this->_encoding     = $encoding;
139
+
140
+			// load the Local
141
+			HTML2PDF_locale::load($this->_langue);
142
+
143
+			// create the  HTML2PDF_myPdf object
144
+			$this->pdf = new HTML2PDF_myPdf($orientation, 'mm', $format, $unicode, $encoding);
145
+
146
+			// init the CSS parsing object
147
+			$this->parsingCss = new HTML2PDF_parsingCss($this->pdf);
148
+			$this->parsingCss->fontSet();
149
+			$this->_defList = array();
150
+
151
+			// init some tests
152
+			$this->setTestTdInOnePage(true);
153
+			$this->setTestIsImage(true);
154
+			$this->setTestIsDeprecated(true);
155
+
156
+			// init the default font
157
+			$this->setDefaultFont(null);
158
+
159
+			// init the HTML parsing object
160
+			$this->parsingHtml = new HTML2PDF_parsingHtml($this->_encoding);
161
+			$this->_subHtml = null;
162
+			$this->_subPart = false;
163
+
164
+			// init the marges of the page
165
+			if (!is_array($marges)) $marges = array($marges, $marges, $marges, $marges);
166
+			$this->_setDefaultMargins($marges[0], $marges[1], $marges[2], $marges[3]);
167
+			$this->_setMargins();
168
+			$this->_marges = array();
169
+
170
+			// init the form's fields
171
+			$this->_lstField = array();
172
+
173
+			return $this;
174
+		}
175
+
176
+		/**
177
+		 * Destructor
178
+		 *
179
+		 * @access public
180
+		 * @return null
181
+		 */
182
+		public function __destruct()
183
+		{
184
+
185
+		}
186
+
187
+		/**
188
+		 * Clone to create a sub HTML2PDF from HTML2PDF::$_subobj
189
+		 *
190
+		 * @access public
191
+		 */
192
+		public function __clone()
193
+		{
194
+			$this->pdf = clone $this->pdf;
195
+			$this->parsingHtml = clone $this->parsingHtml;
196
+			$this->parsingCss = clone $this->parsingCss;
197
+			$this->parsingCss->setPdfParent($this->pdf);
198
+		}
199
+
200
+		/**
201
+		 * set the debug mode to On
202
+		 *
203
+		 * @access public
204
+		 * @return HTML2PDF $this
205
+		 */
206
+		public function setModeDebug()
207
+		{
208
+			$time = microtime(true);
209
+
210
+			$this->_debugActif     = true;
211
+			$this->_debugOkUsage   = function_exists('memory_get_usage');
212
+			$this->_debugOkPeak    = function_exists('memory_get_peak_usage');
213
+			$this->_debugStartTime = $time;
214
+			$this->_debugLastTime  = $time;
215
+
216
+			$this->_DEBUG_stepline('step', 'time', 'delta', 'memory', 'peak');
217
+			$this->_DEBUG_add('Init debug');
218
+
219
+			return $this;
220
+		}
221
+
222
+		/**
223
+		 * Set the test of TD thdat can not take more than one page
224
+		 *
225
+		 * @access public
226
+		 * @param  boolean  $mode
227
+		 * @return HTML2PDF $this
228
+		 */
229
+		public function setTestTdInOnePage($mode = true)
230
+		{
231
+			$this->_testTdInOnepage = $mode ? true : false;
232
+
233
+			return $this;
234
+		}
235
+
236
+		/**
237
+		 * Set the test if the images exist or not
238
+		 *
239
+		 * @access public
240
+		 * @param  boolean  $mode
241
+		 * @return HTML2PDF $this
242
+		 */
243
+		public function setTestIsImage($mode = true)
244
+		{
245
+			$this->_testIsImage = $mode ? true : false;
246
+
247
+			return $this;
248
+		}
249
+
250
+		/**
251
+		 * Set the test on deprecated functions
252
+		 *
253
+		 * @access public
254
+		 * @param  boolean  $mode
255
+		 * @return HTML2PDF $this
256
+		 */
257
+		public function setTestIsDeprecated($mode = true)
258
+		{
259
+			$this->_testIsDeprecated = $mode ? true : false;
260
+
261
+			return $this;
262
+		}
263
+
264
+		/**
265
+		 * Set the default font to use, if no font is specify, or if the asked font does not exist
266
+		 *
267
+		 * @access public
268
+		 * @param  string   $default name of the default font to use. If null : Arial is no font is specify, and error if the asked font does not exist
269
+		 * @return HTML2PDF $this
270
+		 */
271
+		public function setDefaultFont($default = null)
272
+		{
273
+			$this->_defaultFont = $default;
274
+			$this->parsingCss->setDefaultFont($default);
275
+
276
+			return $this;
277
+		}
278
+
279
+		/**
280
+		 * add a font, see TCPDF function addFont
281
+		 *
282
+		 * @access public
283
+		 * @param string $family Font family. The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font.
284
+		 * @param string $style Font style. Possible values are (case insensitive):<ul><li>empty string: regular (default)</li><li>B: bold</li><li>I: italic</li><li>BI or IB: bold italic</li></ul>
285
+		 * @param string $fontfile The font definition file. By default, the name is built from the family and style, in lower case with no spaces.
286
+		 * @return HTML2PDF $this
287
+		 * @see TCPDF::addFont
288
+		 */
289
+		public function addFont($family, $style='', $file='')
290
+		{
291
+			$this->pdf->AddFont($family, $style, $file);
292
+
293
+			return $this;
294
+		}
295
+
296
+		/**
297
+		 * display a automatic index, from the bookmarks
298
+		 *
299
+		 * @access public
300
+		 * @param  string  $titre         index title
301
+		 * @param  int     $sizeTitle     font size of the index title, in mm
302
+		 * @param  int     $sizeBookmark  font size of the index, in mm
303
+		 * @param  boolean $bookmarkTitle add a bookmark for the index, at his beginning
304
+		 * @param  boolean $displayPage   display the page numbers
305
+		 * @param  int     $onPage        if null : at the end of the document on a new page, else on the $onPage page
306
+		 * @param  string  $fontName      font name to use
307
+		 * @return null
308
+		 */
309
+		public function createIndex($titre = 'Index', $sizeTitle = 20, $sizeBookmark = 15, $bookmarkTitle = true, $displayPage = true, $onPage = null, $fontName = 'helvetica')
310
+		{
311
+			$oldPage = $this->_INDEX_NewPage($onPage);
312
+			$this->pdf->createIndex($this, $titre, $sizeTitle, $sizeBookmark, $bookmarkTitle, $displayPage, $onPage, $fontName);
313
+			if ($oldPage) $this->pdf->setPage($oldPage);
314
+		}
315
+
316
+		/**
317
+		 * clean up the objects
318
+		 *
319
+		 * @access protected
320
+		 */
321
+		protected function _cleanUp()
322
+		{
323
+			HTML2PDF::$_subobj = null;
324
+			HTML2PDF::$_tables = array();
325
+		}
326
+
327
+		/**
328
+		 * Send the document to a given destination: string, local file or browser.
329
+		 * Dest can be :
330
+		 *  I : send the file inline to the browser (default). The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF.
331
+		 *  D : send to the browser and force a file download with the name given by name.
332
+		 *  F : save to a local server file with the name given by name.
333
+		 *  S : return the document as a string. name is ignored.
334
+		 *  FI: equivalent to F + I option
335
+		 *  FD: equivalent to F + D option
336
+		 *  true  => I
337
+		 *  false => S
338
+		 *
339
+		 * @param  string $name The name of the file when saved.
340
+		 * @param  string $dest Destination where to send the document.
341
+		 * @return string content of the PDF, if $dest=S
342
+		 * @see TCPDF::close
343
+		 * @access public
344
+		 */
345
+		public function Output($name = '', $dest = false)
346
+		{
347
+			// close the pdf and clean up
348
+			$this->_cleanUp();
349
+
350
+			// if on debug mode
351
+			if ($this->_debugActif) {
352
+				$this->_DEBUG_add('Before output');
353
+				$this->pdf->Close();
354
+				exit;
355
+			}
356
+
357
+			// complete parameters
358
+			if ($dest===false) $dest = 'I';
359
+			if ($dest===true)  $dest = 'S';
360
+			if ($dest==='')    $dest = 'I';
361
+			if ($name=='')     $name='document.pdf';
362
+
363
+			// clean up the destination
364
+			$dest = strtoupper($dest);
365
+			if (!in_array($dest, array('I', 'D', 'F', 'S', 'FI','FD'))) $dest = 'I';
366
+
367
+			// the name must be a PDF name
368
+			if (strtolower(substr($name, -4))!='.pdf') {
369
+				throw new HTML2PDF_exception(0, 'The output document name "'.$name.'" is not a PDF name');
370
+			}
371
+
372
+			// call the output of TCPDF
373
+			return $this->pdf->Output($name, $dest);
374
+		}
375
+
376
+		/**
377
+		 * convert HTML to PDF
378
+		 *
379
+		 * @access public
380
+		 * @param  string   $html
381
+		 * @param  boolean  $debugVue  enable the HTML debug vue
382
+		 * @return null
383
+		 */
384
+		public function writeHTML($html, $debugVue = false)
385
+		{
386
+			// if it is a real html page, we have to convert it
387
+			if (preg_match('/<body/isU', $html))
388
+				$html = $this->getHtmlFromPage($html);
389
+
390
+			$html = str_replace('[[date_y]]', date('Y'), $html);
391
+			$html = str_replace('[[date_m]]', date('m'), $html);
392
+			$html = str_replace('[[date_d]]', date('d'), $html);
393
+
394
+			$html = str_replace('[[date_h]]', date('H'), $html);
395
+			$html = str_replace('[[date_i]]', date('i'), $html);
396
+			$html = str_replace('[[date_s]]', date('s'), $html);
397
+
398
+			// If we are in HTML debug vue : display the HTML
399
+			if ($debugVue) {
400
+				return $this->_vueHTML($html);
401
+			}
402
+
403
+			// convert HTMl to PDF
404
+			$this->parsingCss->readStyle($html);
405
+			$this->parsingHtml->setHTML($html);
406
+			$this->parsingHtml->parse();
407
+			$this->_makeHTMLcode();
408
+		}
409
+
410
+		/**
411
+		 * convert the HTML of a real page, to a code adapted to HTML2PDF
412
+		 *
413
+		 * @access public
414
+		 * @param  string HTML of a real page
415
+		 * @return string HTML adapted to HTML2PDF
416
+		 */
417
+		public function getHtmlFromPage($html)
418
+		{
419
+			$html = str_replace('<BODY', '<body', $html);
420
+			$html = str_replace('</BODY', '</body', $html);
421
+
422
+			// extract the content
423
+			$res = explode('<body', $html);
424
+			if (count($res)<2) return $html;
425
+			$content = '<page'.$res[1];
426
+			$content = explode('</body', $content);
427
+			$content = $content[0].'</page>';
428
+
429
+			// extract the link tags
430
+			preg_match_all('/<link([^>]*)>/isU', $html, $match);
431
+			foreach ($match[0] as $src)
432
+				$content = $src.'</link>'.$content;
433
+
434
+			// extract the css style tags
435
+			preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match);
436
+			foreach ($match[0] as $src)
437
+				$content = $src.$content;
438
+
439
+			return $content;
440
+		}
441
+
442
+		/**
443
+		 * init a sub HTML2PDF. does not use it directly. Only the method createSubHTML must use it
444
+		 *
445
+		 * @access public
446
+		 * @param  string  $format
447
+		 * @param  string  $orientation
448
+		 * @param  array   $marge
449
+		 * @param  integer $page
450
+		 * @param  array   $defLIST
451
+		 * @param  integer $myLastPageGroup
452
+		 * @param  integer $myLastPageGroupNb
453
+		 */
454
+		public function initSubHtml($format, $orientation, $marge, $page, $defLIST, $myLastPageGroup, $myLastPageGroupNb)
455
+		{
456
+			$this->_isSubPart = true;
457
+
458
+			$this->parsingCss->setOnlyLeft();
459
+
460
+			$this->_setNewPage($format, $orientation, null, null, ($myLastPageGroup!==null));
461
+
462
+			$this->_saveMargin(0, 0, $marge);
463
+			$this->_defList = $defLIST;
464
+
465
+			$this->_page = $page;
466
+			$this->pdf->setMyLastPageGroup($myLastPageGroup);
467
+			$this->pdf->setMyLastPageGroupNb($myLastPageGroupNb);
468
+			$this->pdf->setXY(0, 0);
469
+			$this->parsingCss->fontSet();
470
+		}
471
+
472
+		/**
473
+		 * display the content in HTML moden for debug
474
+		 *
475
+		 * @access protected
476
+		 * @param  string $contenu
477
+		 */
478
+		protected function _vueHTML($content)
479
+		{
480
+			$content = preg_replace('/<page_header([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue01').' : $1<hr><div$1>', $content);
481
+			$content = preg_replace('/<page_footer([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue02').' : $1<hr><div$1>', $content);
482
+			$content = preg_replace('/<page([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue03').' : $1<hr><div$1>', $content);
483
+			$content = preg_replace('/<\/page([^>]*)>/isU', '</div><hr>', $content);
484
+			$content = preg_replace('/<bookmark([^>]*)>/isU', '<hr>bookmark : $1<hr>', $content);
485
+			$content = preg_replace('/<\/bookmark([^>]*)>/isU', '', $content);
486
+			$content = preg_replace('/<barcode([^>]*)>/isU', '<hr>barcode : $1<hr>', $content);
487
+			$content = preg_replace('/<\/barcode([^>]*)>/isU', '', $content);
488
+			$content = preg_replace('/<qrcode([^>]*)>/isU', '<hr>qrcode : $1<hr>', $content);
489
+			$content = preg_replace('/<\/qrcode([^>]*)>/isU', '', $content);
490
+
491
+			echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
493 492
 <html>
494 493
     <head>
495 494
         <title>'.HTML2PDF_locale::get('vue04').' HTML</title>
@@ -499,5990 +498,5990 @@  discard block
 block discarded – undo
499 498
 '.$content.'
500 499
     </body>
501 500
 </html>';
502
-            exit;
503
-        }
504
-
505
-        /**
506
-         * set the default margins of the page
507
-         *
508
-         * @access protected
509
-         * @param  int $left   (mm, left margin)
510
-         * @param  int $top    (mm, top margin)
511
-         * @param  int $right  (mm, right margin, if null => left=right)
512
-         * @param  int $bottom (mm, bottom margin, if null => bottom=8mm)
513
-         */
514
-        protected function _setDefaultMargins($left, $top, $right = null, $bottom = null)
515
-        {
516
-            if ($right===null)  $right = $left;
517
-            if ($bottom===null) $bottom = 8;
518
-
519
-            $this->_defaultLeft   = $this->parsingCss->ConvertToMM($left.'mm');
520
-            $this->_defaultTop    = $this->parsingCss->ConvertToMM($top.'mm');
521
-            $this->_defaultRight  = $this->parsingCss->ConvertToMM($right.'mm');
522
-            $this->_defaultBottom = $this->parsingCss->ConvertToMM($bottom.'mm');
523
-        }
524
-
525
-        /**
526
-         * create a new page
527
-         *
528
-         * @access protected
529
-         * @param  mixed   $format
530
-         * @param  string  $orientation
531
-         * @param  array   $background background information
532
-         * @param  integer $curr real position in the html parseur (if break line in the write of a text)
533
-         * @param  boolean $resetPageNumber
534
-         */
535
-        protected function _setNewPage($format = null, $orientation = '', $background = null, $curr = null, $resetPageNumber=false)
536
-        {
537
-            $this->_firstPage = false;
538
-
539
-            $this->_format = $format ? $format : $this->_format;
540
-            $this->_orientation = $orientation ? $orientation : $this->_orientation;
541
-            $this->_background = $background!==null ? $background : $this->_background;
542
-            $this->_maxY = 0;
543
-            $this->_maxX = 0;
544
-            $this->_maxH = 0;
545
-            $this->_maxE = 0;
546
-
547
-            $this->pdf->SetMargins($this->_defaultLeft, $this->_defaultTop, $this->_defaultRight);
548
-
549
-            if ($resetPageNumber) {
550
-                $this->pdf->startPageGroup();
551
-            }
552
-
553
-            $this->pdf->AddPage($this->_orientation, $this->_format);
554
-
555
-            if ($resetPageNumber) {
556
-                $this->pdf->myStartPageGroup();
557
-            }
558
-
559
-            $this->_page++;
560
-
561
-            if (!$this->_subPart && !$this->_isSubPart) {
562
-                if (is_array($this->_background)) {
563
-                    if (isset($this->_background['color']) && $this->_background['color']) {
564
-                        $this->pdf->setFillColorArray($this->_background['color']);
565
-                        $this->pdf->Rect(0, 0, $this->pdf->getW(), $this->pdf->getH(), 'F');
566
-                    }
567
-
568
-                    if (isset($this->_background['img']) && $this->_background['img'])
569
-                        $this->pdf->Image($this->_background['img'], $this->_background['posX'], $this->_background['posY'], $this->_background['width']);
570
-                }
571
-
572
-                $this->_setPageHeader();
573
-                $this->_setPageFooter();
574
-            }
575
-
576
-            $this->_setMargins();
577
-            $this->pdf->setY($this->_margeTop);
578
-
579
-            $this->_setNewPositionForNewLine($curr);
580
-            $this->_maxH = 0;
581
-        }
582
-
583
-        /**
584
-         * set the real margin, using the default margins and the page margins
585
-         *
586
-         * @access protected
587
-         */
588
-        protected function _setMargins()
589
-        {
590
-            // prepare the margins
591
-            $this->_margeLeft   = $this->_defaultLeft   + (isset($this->_background['left'])   ? $this->_background['left']   : 0);
592
-            $this->_margeRight  = $this->_defaultRight  + (isset($this->_background['right'])  ? $this->_background['right']  : 0);
593
-            $this->_margeTop    = $this->_defaultTop    + (isset($this->_background['top'])    ? $this->_background['top']    : 0);
594
-            $this->_margeBottom = $this->_defaultBottom + (isset($this->_background['bottom']) ? $this->_background['bottom'] : 0);
595
-
596
-            // set the PDF margins
597
-            $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight);
598
-            $this->pdf->SetAutoPageBreak(false, $this->_margeBottom);
599
-
600
-            // set the float Margins
601
-            $this->_pageMarges = array();
602
-            if ($this->_isInParagraph!==false) {
603
-                $this->_pageMarges[floor($this->_margeTop*100)] = array($this->_isInParagraph[0], $this->pdf->getW()-$this->_isInParagraph[1]);
604
-            } else {
605
-                $this->_pageMarges[floor($this->_margeTop*100)] = array($this->_margeLeft, $this->pdf->getW()-$this->_margeRight);
606
-            }
607
-        }
608
-
609
-        /**
610
-         * add a debug step
611
-         *
612
-         * @access protected
613
-         * @param  string  $name step name
614
-         * @param  boolean $level (true=up, false=down, null=nothing to do)
615
-         * @return $this
616
-         */
617
-        protected function _DEBUG_add($name, $level=null)
618
-        {
619
-            // if true : UP
620
-            if ($level===true) $this->_debugLevel++;
621
-
622
-            $name   = str_repeat('  ', $this->_debugLevel). $name.($level===true ? ' Begin' : ($level===false ? ' End' : ''));
623
-            $time  = microtime(true);
624
-            $usage = ($this->_debugOkUsage ? memory_get_usage() : 0);
625
-            $peak  = ($this->_debugOkPeak ? memory_get_peak_usage() : 0);
626
-
627
-            $this->_DEBUG_stepline(
628
-                $name,
629
-                number_format(($time - $this->_debugStartTime)*1000, 1, '.', ' ').' ms',
630
-                number_format(($time - $this->_debugLastTime)*1000, 1, '.', ' ').' ms',
631
-                number_format($usage/1024, 1, '.', ' ').' Ko',
632
-                number_format($peak/1024, 1, '.', ' ').' Ko'
633
-            );
634
-
635
-            $this->_debugLastTime = $time;
636
-
637
-            // it false : DOWN
638
-            if ($level===false) $this->_debugLevel--;
639
-
640
-            return $this;
641
-        }
642
-
643
-        /**
644
-         * display a debug line
645
-         *
646
-         *
647
-         * @access protected
648
-         * @param  string $name
649
-         * @param  string $timeTotal
650
-         * @param  string $timeStep
651
-         * @param  string $memoryUsage
652
-         * @param  string $memoryPeak
653
-         */
654
-        protected function _DEBUG_stepline($name, $timeTotal, $timeStep, $memoryUsage, $memoryPeak)
655
-        {
656
-            $txt = str_pad($name, 30, ' ', STR_PAD_RIGHT).
657
-                    str_pad($timeTotal, 12, ' ', STR_PAD_LEFT).
658
-                    str_pad($timeStep, 12, ' ', STR_PAD_LEFT).
659
-                    str_pad($memoryUsage, 15, ' ', STR_PAD_LEFT).
660
-                    str_pad($memoryPeak, 15, ' ', STR_PAD_LEFT);
661
-
662
-            echo '<pre style="padding:0; margin:0">'.$txt.'</pre>';
663
-        }
664
-
665
-        /**
666
-         * get the Min and Max X, for Y (use the float margins)
667
-         *
668
-         * @access protected
669
-         * @param  float $y
670
-         * @return array(float, float)
671
-         */
672
-        protected function _getMargins($y)
673
-        {
674
-            $y = floor($y*100);
675
-            $x = array($this->pdf->getlMargin(), $this->pdf->getW()-$this->pdf->getrMargin());
676
-
677
-            foreach ($this->_pageMarges as $mY => $mX)
678
-                if ($mY<=$y) $x = $mX;
679
-
680
-            return $x;
681
-        }
682
-
683
-        /**
684
-         * Add margins, for a float
685
-         *
686
-         * @access protected
687
-         * @param  string $float (left / right)
688
-         * @param  float  $xLeft
689
-         * @param  float  $yTop
690
-         * @param  float  $xRight
691
-         * @param  float  $yBottom
692
-         */
693
-        protected function _addMargins($float, $xLeft, $yTop, $xRight, $yBottom)
694
-        {
695
-            // get the current float margins, for top and bottom
696
-            $oldTop    = $this->_getMargins($yTop);
697
-            $oldBottom = $this->_getMargins($yBottom);
698
-
699
-            // update the top float margin
700
-            if ($float=='left'  && $oldTop[0]<$xRight) $oldTop[0] = $xRight;
701
-            if ($float=='right' && $oldTop[1]>$xLeft)  $oldTop[1] = $xLeft;
702
-
703
-            $yTop = floor($yTop*100);
704
-            $yBottom = floor($yBottom*100);
705
-
706
-            // erase all the float margins that are smaller than the new one
707
-            foreach ($this->_pageMarges as $mY => $mX) {
708
-                if ($mY<$yTop) continue;
709
-                if ($mY>$yBottom) break;
710
-                if ($float=='left' && $this->_pageMarges[$mY][0]<$xRight)  unset($this->_pageMarges[$mY]);
711
-                if ($float=='right' && $this->_pageMarges[$mY][1]>$xLeft) unset($this->_pageMarges[$mY]);
712
-            }
713
-
714
-            // save the new Top and Bottom margins
715
-            $this->_pageMarges[$yTop] = $oldTop;
716
-            $this->_pageMarges[$yBottom] = $oldBottom;
717
-
718
-            // sort the margins
719
-            ksort($this->_pageMarges);
720
-
721
-            // we are just after float
722
-            $this->_isAfterFloat = true;
723
-        }
724
-
725
-        /**
726
-         * Save old margins (push), and set new ones
727
-         *
728
-         * @access protected
729
-         * @param  float  $ml left margin
730
-         * @param  float  $mt top margin
731
-         * @param  float  $mr right margin
732
-         */
733
-        protected function _saveMargin($ml, $mt, $mr)
734
-        {
735
-            // save old margins
736
-            $this->_marges[] = array('l' => $this->pdf->getlMargin(), 't' => $this->pdf->gettMargin(), 'r' => $this->pdf->getrMargin(), 'page' => $this->_pageMarges);
737
-
738
-            // set new ones
739
-            $this->pdf->SetMargins($ml, $mt, $mr);
740
-
741
-            // prepare for float margins
742
-            $this->_pageMarges = array();
743
-            $this->_pageMarges[floor($mt*100)] = array($ml, $this->pdf->getW()-$mr);
744
-        }
745
-
746
-        /**
747
-         * load the last saved margins (pop)
748
-         *
749
-         * @access protected
750
-         */
751
-        protected function _loadMargin()
752
-        {
753
-            $old = array_pop($this->_marges);
754
-            if ($old) {
755
-                $ml = $old['l'];
756
-                $mt = $old['t'];
757
-                $mr = $old['r'];
758
-                $mP = $old['page'];
759
-            } else {
760
-                $ml = $this->_margeLeft;
761
-                $mt = 0;
762
-                $mr = $this->_margeRight;
763
-                $mP = array($mt => array($ml, $this->pdf->getW()-$mr));
764
-            }
765
-
766
-            $this->pdf->SetMargins($ml, $mt, $mr);
767
-            $this->_pageMarges = $mP;
768
-        }
769
-
770
-        /**
771
-         * save the current maxs (push)
772
-         *
773
-         * @access protected
774
-         */
775
-        protected function _saveMax()
776
-        {
777
-            $this->_maxSave[] = array($this->_maxX, $this->_maxY, $this->_maxH, $this->_maxE);
778
-        }
779
-
780
-        /**
781
-         * load the last saved current maxs (pop)
782
-         *
783
-         * @access protected
784
-         */
785
-        protected function _loadMax()
786
-        {
787
-            $old = array_pop($this->_maxSave);
788
-
789
-            if ($old) {
790
-                $this->_maxX = $old[0];
791
-                $this->_maxY = $old[1];
792
-                $this->_maxH = $old[2];
793
-                $this->_maxE = $old[3];
794
-            } else {
795
-                $this->_maxX = 0;
796
-                $this->_maxY = 0;
797
-                $this->_maxH = 0;
798
-                $this->_maxE = 0;
799
-            }
800
-        }
801
-
802
-        /**
803
-         * draw the PDF header with the HTML in page_header
804
-         *
805
-         * @access protected
806
-         */
807
-        protected function _setPageHeader()
808
-        {
809
-            if (!count($this->_subHEADER)) return false;
810
-
811
-            $oldParsePos = $this->_parsePos;
812
-            $oldParseCode = $this->parsingHtml->code;
813
-
814
-            $this->_parsePos = 0;
815
-            $this->parsingHtml->code = $this->_subHEADER;
816
-            $this->_makeHTMLcode();
817
-
818
-            $this->_parsePos = $oldParsePos;
819
-            $this->parsingHtml->code = $oldParseCode;
820
-        }
821
-
822
-        /**
823
-         * draw the PDF footer with the HTML in page_footer
824
-         *
825
-         * @access protected
826
-         */
827
-        protected function _setPageFooter()
828
-        {
829
-            if (!count($this->_subFOOTER)) return false;
830
-
831
-            $oldParsePos = $this->_parsePos;
832
-            $oldParseCode = $this->parsingHtml->code;
833
-
834
-            $this->_parsePos = 0;
835
-            $this->parsingHtml->code = $this->_subFOOTER;
836
-            $this->_isInFooter = true;
837
-            $this->_makeHTMLcode();
838
-            $this->_isInFooter = false;
839
-
840
-            $this->_parsePos = $oldParsePos;
841
-            $this->parsingHtml->code = $oldParseCode;
842
-        }
843
-
844
-        /**
845
-         * new line, with a specific height
846
-         *
847
-         * @access protected
848
-         * @param float   $h
849
-         * @param integer $curr real current position in the text, if new line in the write of a text
850
-         */
851
-        protected function _setNewLine($h, $curr = null)
852
-        {
853
-            $this->pdf->Ln($h);
854
-            $this->_setNewPositionForNewLine($curr);
855
-        }
856
-
857
-        /**
858
-         * calculate the start position of the next line,  depending on the text-align
859
-         *
860
-         * @access protected
861
-         * @param  integer $curr real current position in the text, if new line in the write of a text
862
-         */
863
-        protected function _setNewPositionForNewLine($curr = null)
864
-        {
865
-            // get the margins for the current line
866
-            list($lx, $rx) = $this->_getMargins($this->pdf->getY());
867
-            $this->pdf->setX($lx);
868
-            $wMax = $rx-$lx;
869
-            $this->_currentH = 0;
870
-
871
-            // if subPart => return because align left
872
-            if ($this->_subPart || $this->_isSubPart || $this->_isForOneLine) {
873
-                $this->pdf->setWordSpacing(0);
874
-                return null;
875
-            }
876
-
877
-            // create the sub object
878
-            $sub = null;
879
-            $this->_createSubHTML($sub);
880
-            $sub->_saveMargin(0, 0, $sub->pdf->getW()-$wMax);
881
-            $sub->_isForOneLine = true;
882
-            $sub->_parsePos = $this->_parsePos;
883
-            $sub->parsingHtml->code = $this->parsingHtml->code;
884
-
885
-            // if $curr => adapt the current position of the parsing
886
-            if ($curr!==null && $sub->parsingHtml->code[$this->_parsePos]['name']=='write') {
887
-                $txt = $sub->parsingHtml->code[$this->_parsePos]['param']['txt'];
888
-                $txt = str_replace('[[page_cu]]', $sub->pdf->getMyNumPage($this->_page), $txt);
889
-                $sub->parsingHtml->code[$this->_parsePos]['param']['txt'] = substr($txt, $curr+1);
890
-            } else
891
-                $sub->_parsePos++;
892
-
893
-            // for each element of the parsing => load the action
894
-            $res = null;
895
-            for ($sub->_parsePos; $sub->_parsePos<count($sub->parsingHtml->code); $sub->_parsePos++) {
896
-                $action = $sub->parsingHtml->code[$sub->_parsePos];
897
-                $res = $sub->_executeAction($action);
898
-                if (!$res) break;
899
-            }
900
-
901
-            $w = $sub->_maxX; // max width
902
-            $h = $sub->_maxH; // max height
903
-            $e = ($res===null ? $sub->_maxE : 0); // maxnumber of elemets on the line
904
-
905
-            // destroy the sub HTML
906
-            $this->_destroySubHTML($sub);
907
-
908
-            // adapt the start of the line, depending on the text-align
909
-            if ($this->parsingCss->value['text-align']=='center')
910
-                $this->pdf->setX(($rx+$this->pdf->getX()-$w)*0.5-0.01);
911
-            else if ($this->parsingCss->value['text-align']=='right')
912
-                $this->pdf->setX($rx-$w-0.01);
913
-            else
914
-                $this->pdf->setX($lx);
915
-
916
-            // set the height of the line
917
-            $this->_currentH = $h;
918
-
919
-            // if justify => set the word spacing
920
-            if ($this->parsingCss->value['text-align']=='justify' && $e>1) {
921
-                $this->pdf->setWordSpacing(($wMax-$w)/($e-1));
922
-            } else {
923
-                $this->pdf->setWordSpacing(0);
924
-            }
925
-        }
926
-
927
-        /**
928
-         * prepare HTML2PDF::$_subobj (used for create the sub HTML2PDF objects
929
-         *
930
-         * @access protected
931
-         */
932
-        protected function _prepareSubObj()
933
-        {
934
-            $pdf = null;
935
-
936
-            // create the sub object
937
-            HTML2PDF::$_subobj = new HTML2PDF(
938
-                                        $this->_orientation,
939
-                                        $this->_format,
940
-                                        $this->_langue,
941
-                                        $this->_unicode,
942
-                                        $this->_encoding,
943
-                                        array($this->_defaultLeft,$this->_defaultTop,$this->_defaultRight,$this->_defaultBottom)
944
-                                    );
945
-
946
-            // init
947
-            HTML2PDF::$_subobj->setTestTdInOnePage($this->_testTdInOnepage);
948
-            HTML2PDF::$_subobj->setTestIsImage($this->_testIsImage);
949
-            HTML2PDF::$_subobj->setTestIsDeprecated($this->_testIsDeprecated);
950
-            HTML2PDF::$_subobj->setDefaultFont($this->_defaultFont);
951
-            HTML2PDF::$_subobj->parsingCss->css            = &$this->parsingCss->css;
952
-            HTML2PDF::$_subobj->parsingCss->cssKeys        = &$this->parsingCss->cssKeys;
953
-
954
-            // clone font from the original PDF
955
-            HTML2PDF::$_subobj->pdf->cloneFontFrom($this->pdf);
956
-
957
-            // remove the link to the parent
958
-            HTML2PDF::$_subobj->parsingCss->setPdfParent($pdf);
959
-        }
960
-
961
-        /**
962
-         * create a sub HTML2PDF, to calculate the multi-tables
963
-         *
964
-         * @access protected
965
-         * @param  &HTML2PDF $subHtml sub HTML2PDF to create
966
-         * @param  integer   $cellmargin if in a TD : cellmargin of this td
967
-         */
968
-        protected function _createSubHTML(&$subHtml, $cellmargin=0)
969
-        {
970
-            // prepare the subObject, if never prepare before
971
-            if (HTML2PDF::$_subobj===null) {
972
-                $this->_prepareSubObj();
973
-            }
974
-
975
-            // calculate the width to use
976
-            if ($this->parsingCss->value['width']) {
977
-                $marge = $cellmargin*2;
978
-                $marge+= $this->parsingCss->value['padding']['l'] + $this->parsingCss->value['padding']['r'];
979
-                $marge+= $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['border']['r']['width'];
980
-                $marge = $this->pdf->getW() - $this->parsingCss->value['width'] + $marge;
981
-            } else {
982
-                $marge = $this->_margeLeft+$this->_margeRight;
983
-            }
984
-
985
-            // BUGFIX : we have to call the method, because of a bug in php 5.1.6
986
-            HTML2PDF::$_subobj->pdf->getPage();
987
-
988
-            // clone the sub oject
989
-            $subHtml = clone HTML2PDF::$_subobj;
990
-            $subHtml->parsingCss->table = $this->parsingCss->table;
991
-            $subHtml->parsingCss->value = $this->parsingCss->value;
992
-            $subHtml->initSubHtml(
993
-                $this->_format,
994
-                $this->_orientation,
995
-                $marge,
996
-                $this->_page,
997
-                $this->_defList,
998
-                $this->pdf->getMyLastPageGroup(),
999
-                $this->pdf->getMyLastPageGroupNb()
1000
-            );
1001
-        }
1002
-
1003
-        /**
1004
-         * destroy a subHTML2PDF
1005
-         *
1006
-         * @access protected
1007
-         */
1008
-        protected function _destroySubHTML(&$subHtml)
1009
-        {
1010
-            unset($subHtml);
1011
-            $subHtml = null;
1012
-        }
1013
-
1014
-        /**
1015
-         * Convert a arabic number in roman number
1016
-         *
1017
-         * @access protected
1018
-         * @param  integer $nbArabic
1019
-         * @return string  $nbRoman
1020
-         */
1021
-        protected function _listeArab2Rom($nbArabic)
1022
-        {
1023
-            $nbBaseTen    = array('I','X','C','M');
1024
-            $nbBaseFive    = array('V','L','D');
1025
-            $nbRoman    = '';
1026
-
1027
-            if ($nbArabic<1)    return $nbArabic;
1028
-            if ($nbArabic>3999) return $nbArabic;
1029
-
1030
-            for ($i=3; $i>=0 ; $i--) {
1031
-                $chiffre=floor($nbArabic/pow(10, $i));
1032
-                if ($chiffre>=1) {
1033
-                    $nbArabic=$nbArabic-$chiffre*pow(10, $i);
1034
-                    if ($chiffre<=3) {
1035
-                        for ($j=$chiffre; $j>=1; $j--) {
1036
-                            $nbRoman=$nbRoman.$nbBaseTen[$i];
1037
-                        }
1038
-                    } else if ($chiffre==9) {
1039
-                        $nbRoman=$nbRoman.$nbBaseTen[$i].$nbBaseTen[$i+1];
1040
-                    } else if ($chiffre==4) {
1041
-                    $nbRoman=$nbRoman.$nbBaseTen[$i].$nbBaseFive[$i];
1042
-                    } else {
1043
-                        $nbRoman=$nbRoman.$nbBaseFive[$i];
1044
-                        for ($j=$chiffre-5; $j>=1; $j--) {
1045
-                            $nbRoman=$nbRoman.$nbBaseTen[$i];
1046
-                        }
1047
-                    }
1048
-                }
1049
-            }
1050
-            return $nbRoman;
1051
-        }
1052
-
1053
-        /**
1054
-         * add a LI to the current level
1055
-         *
1056
-         * @access protected
1057
-         */
1058
-        protected function _listeAddLi()
1059
-        {
1060
-            $this->_defList[count($this->_defList)-1]['nb']++;
1061
-        }
1062
-
1063
-        /**
1064
-         * get the width to use for the column of the list
1065
-         *
1066
-         * @access protected
1067
-         * @return string $width
1068
-         */
1069
-        protected function _listeGetWidth()
1070
-        {
1071
-            return '7mm';
1072
-        }
1073
-
1074
-        /**
1075
-         * get the padding to use for the column of the list
1076
-         *
1077
-         * @access protected
1078
-         * @return string $padding
1079
-         */
1080
-        protected function _listeGetPadding()
1081
-        {
1082
-            return '1mm';
1083
-        }
1084
-
1085
-        /**
1086
-         * get the information of the li on the current level
1087
-         *
1088
-         * @access protected
1089
-         * @return array(fontName, small size, string)
1090
-         */
1091
-        protected function _listeGetLi()
1092
-        {
1093
-            $im = $this->_defList[count($this->_defList)-1]['img'];
1094
-            $st = $this->_defList[count($this->_defList)-1]['style'];
1095
-            $nb = $this->_defList[count($this->_defList)-1]['nb'];
1096
-            $up = (substr($st, 0, 6)=='upper-');
1097
-
1098
-            if ($im) return array(false, false, $im);
1099
-
1100
-            switch($st)
1101
-            {
1102
-                case 'none':
1103
-                    return array('helvetica', true, ' ');
1104
-
1105
-                case 'upper-alpha':
1106
-                case 'lower-alpha':
1107
-                    $str = '';
1108
-                    while ($nb>26) {
1109
-                        $str = chr(96+$nb%26).$str;
1110
-                        $nb = floor($nb/26);
1111
-                    }
1112
-                    $str = chr(96+$nb).$str;
1113
-
1114
-                    return array('helvetica', false, ($up ? strtoupper($str) : $str).'.');
1115
-
1116
-                case 'upper-roman':
1117
-                case 'lower-roman':
1118
-                    $str = $this->_listeArab2Rom($nb);
1119
-
1120
-                    return array('helvetica', false, ($up ? strtoupper($str) : $str).'.');
1121
-
1122
-                case 'decimal':
1123
-                    return array('helvetica', false, $nb.'.');
1124
-
1125
-                case 'square':
1126
-                    return array('zapfdingbats', true, chr(110));
1127
-
1128
-                case 'circle':
1129
-                    return array('zapfdingbats', true, chr(109));
1130
-
1131
-                case 'disc':
1132
-                default:
1133
-                    return array('zapfdingbats', true, chr(108));
1134
-            }
1135
-        }
1136
-
1137
-        /**
1138
-         * add a level to the list
1139
-         *
1140
-         * @access protected
1141
-         * @param  string $type  : ul, ol
1142
-         * @param  string $style : lower-alpha, ...
1143
-         * @param  string $img
1144
-         */
1145
-        protected function _listeAddLevel($type = 'ul', $style = '', $img = null)
1146
-        {
1147
-            // get the url of the image, if we want to use a image
1148
-            if ($img) {
1149
-                if (preg_match('/^url\(([^)]+)\)$/isU', trim($img), $match)) {
1150
-                    $img = $match[1];
1151
-                } else {
1152
-                    $img = null;
1153
-                }
1154
-            } else {
1155
-                $img = null;
1156
-            }
1157
-
1158
-            // prepare the datas
1159
-            if (!in_array($type, array('ul', 'ol'))) $type = 'ul';
1160
-            if (!in_array($style, array('lower-alpha', 'upper-alpha', 'upper-roman', 'lower-roman', 'decimal', 'square', 'circle', 'disc', 'none'))) $style = '';
1161
-
1162
-            if (!$style) {
1163
-                if ($type=='ul')    $style = 'disc';
1164
-                else                $style = 'decimal';
1165
-            }
1166
-
1167
-            // add the new level
1168
-            $this->_defList[count($this->_defList)] = array('style' => $style, 'nb' => 0, 'img' => $img);
1169
-        }
1170
-
1171
-        /**
1172
-         * remove a level to the list
1173
-         *
1174
-         * @access protected
1175
-         */
1176
-        protected function _listeDelLevel()
1177
-        {
1178
-            if (count($this->_defList)) {
1179
-                unset($this->_defList[count($this->_defList)-1]);
1180
-                $this->_defList = array_values($this->_defList);
1181
-            }
1182
-        }
1183
-
1184
-        /**
1185
-         * execute the actions to convert the html
1186
-         *
1187
-         * @access protected
1188
-         */
1189
-        protected function _makeHTMLcode()
1190
-        {
1191
-            // foreach elements of the parsing
1192
-            for ($this->_parsePos=0; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) {
1193
-
1194
-                // get the action to do
1195
-                $action = $this->parsingHtml->code[$this->_parsePos];
1196
-
1197
-                // if it is a opening of table / ul / ol
1198
-                if (in_array($action['name'], array('table', 'ul', 'ol')) && !$action['close']) {
1199
-
1200
-                    //  we will work as a sub HTML to calculate the size of the element
1201
-                    $this->_subPart = true;
1202
-
1203
-                    // get the name of the opening tag
1204
-                    $tagOpen = $action['name'];
1205
-
1206
-                    // save the actual pos on the parsing
1207
-                    $this->_tempPos = $this->_parsePos;
1208
-
1209
-                    // foreach elements, while we are in the opened tag
1210
-                    while (isset($this->parsingHtml->code[$this->_tempPos]) && !($this->parsingHtml->code[$this->_tempPos]['name']==$tagOpen && $this->parsingHtml->code[$this->_tempPos]['close'])) {
1211
-                        // make the action
1212
-                        $this->_executeAction($this->parsingHtml->code[$this->_tempPos]);
1213
-                        $this->_tempPos++;
1214
-                    }
1215
-
1216
-                    // execute the closure of the tag
1217
-                    if (isset($this->parsingHtml->code[$this->_tempPos])) {
1218
-                        $this->_executeAction($this->parsingHtml->code[$this->_tempPos]);
1219
-                    }
1220
-
1221
-                    // end of the sub part
1222
-                    $this->_subPart = false;
1223
-                }
1224
-
1225
-                // execute the action
1226
-                $this->_executeAction($action);
1227
-            }
1228
-        }
1229
-
1230
-        /**
1231
-         * execute the action from the parsing
1232
-         *
1233
-         * @access protected
1234
-         * @param  array $action
1235
-         */
1236
-        protected function _executeAction($action)
1237
-        {
1238
-            // name of the action
1239
-            $fnc = ($action['close'] ? '_tag_close_' : '_tag_open_').strtoupper($action['name']);
1240
-
1241
-            // parameters of the action
1242
-            $param = $action['param'];
1243
-
1244
-            // if it the first action of the first page, and if it is not a open tag of PAGE => create the new page
1245
-            if ($fnc!='_tag_open_PAGE' && $this->_firstPage) {
1246
-                $this->_setNewPage();
1247
-            }
1248
-
1249
-            // the action must exist
1250
-            if (!is_callable(array(&$this, $fnc))) {
1251
-                throw new HTML2PDF_exception(1, strtoupper($action['name']), $this->parsingHtml->getHtmlErrorCode($action['html_pos']));
1252
-            }
1253
-
1254
-            // lauch the action
1255
-            $res = $this->{$fnc}($param);
1256
-
1257
-            // save the name of the action
1258
-            $this->_previousCall = $fnc;
1259
-
1260
-            // return the result
1261
-            return $res;
1262
-        }
1263
-
1264
-        /**
1265
-         * get the position of the element on the current line, depending on his height
1266
-         *
1267
-         * @access protected
1268
-         * @param  float $h
1269
-         * @return float
1270
-         */
1271
-        protected function _getElementY($h)
1272
-        {
1273
-            if ($this->_subPart || $this->_isSubPart || !$this->_currentH || $this->_currentH<$h)
1274
-                return 0;
1275
-
1276
-            return ($this->_currentH-$h)*0.8;
1277
-        }
1278
-
1279
-        /**
1280
-         * make a break line
1281
-         *
1282
-         * @access protected
1283
-         * @param  float $h current line height
1284
-         * @param  integer $curr real current position in the text, if new line in the write of a text
1285
-         */
1286
-        protected function _makeBreakLine($h, $curr = null)
1287
-        {
1288
-            if ($h) {
1289
-                if (($this->pdf->getY()+$h<$this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter)
1290
-                    $this->_setNewLine($h, $curr);
1291
-                else
1292
-                    $this->_setNewPage(null, '', null, $curr);
1293
-            } else {
1294
-                $this->_setNewPositionForNewLine($curr);
1295
-            }
1296
-
1297
-            $this->_maxH = 0;
1298
-            $this->_maxE = 0;
1299
-        }
1300
-
1301
-        /**
1302
-         * display a image
1303
-         *
1304
-         * @access protected
1305
-         * @param  string $src
1306
-         * @param  boolean $subLi if true=image of a list
1307
-         * @return boolean depending on "isForOneLine"
1308
-         */
1309
-        protected function _drawImage($src, $subLi=false)
1310
-        {
1311
-            // get the size of the image
1312
-            // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini
1313
-            $infos=@getimagesize($src);
1314
-
1315
-            // if the image does not exist, or can not be loaded
1316
-            if (count($infos)<2) {
1317
-                // if the test is activ => exception
1318
-                if ($this->_testIsImage) {
1319
-                    throw new HTML2PDF_exception(6, $src);
1320
-                }
1321
-
1322
-                // else, display a gray rectangle
1323
-                $src = null;
1324
-                $infos = array(16, 16);
1325
-            }
1326
-
1327
-            // convert the size of the image in the unit of the PDF
1328
-            $imageWidth = $infos[0]/$this->pdf->getK();
1329
-            $imageHeight = $infos[1]/$this->pdf->getK();
1330
-
1331
-            // calculate the size from the css style
1332
-            if ($this->parsingCss->value['width'] && $this->parsingCss->value['height']) {
1333
-                $w = $this->parsingCss->value['width'];
1334
-                $h = $this->parsingCss->value['height'];
1335
-            } else if ($this->parsingCss->value['width']) {
1336
-                $w = $this->parsingCss->value['width'];
1337
-                $h = $imageHeight*$w/$imageWidth;
1338
-            } else if ($this->parsingCss->value['height']) {
1339
-                $h = $this->parsingCss->value['height'];
1340
-                $w = $imageWidth*$h/$imageHeight;
1341
-            } else {
1342
-                // convert px to pt
1343
-                $w = 72./96.*$imageWidth;
1344
-                $h = 72./96.*$imageHeight;
1345
-            }
1346
-
1347
-            // are we in a float
1348
-            $float = $this->parsingCss->getFloat();
1349
-
1350
-            // if we are in a float, but if something else if on the line => Break Line
1351
-            if ($float && $this->_maxH) {
1352
-                // make the break line (false if we are in "_isForOneLine" mode)
1353
-                if (!$this->_tag_open_BR(array())) {
1354
-                    return false;
1355
-                }
1356
-            }
1357
-
1358
-            // position of the image
1359
-            $x = $this->pdf->getX();
1360
-            $y = $this->pdf->getY();
1361
-
1362
-            // if the image can not be put on the current line => new line
1363
-            if (!$float && ($x + $w>$this->pdf->getW() - $this->pdf->getrMargin()) && $this->_maxH) {
1364
-                if ($this->_isForOneLine) {
1365
-                    return false;
1366
-                }
1367
-
1368
-                // set the new line
1369
-                $hnl = max($this->_maxH, $this->parsingCss->getLineHeight());
1370
-                $this->_setNewLine($hnl);
1371
-
1372
-                // get the new position
1373
-                $x = $this->pdf->getX();
1374
-                $y = $this->pdf->getY();
1375
-            }
1376
-
1377
-            // if the image can not be put on the current page
1378
-            if (($y + $h>$this->pdf->getH() - $this->pdf->getbMargin()) && !$this->_isInOverflow) {
1379
-                // new page
1380
-                $this->_setNewPage();
1381
-
1382
-                // get the new position
1383
-                $x = $this->pdf->getX();
1384
-                $y = $this->pdf->getY();
1385
-            }
1386
-
1387
-            // correction for display the image of a list
1388
-            $hT = 0.80*$this->parsingCss->value['font-size'];
1389
-            if ($subLi && $h<$hT) {
1390
-                $y+=($hT-$h);
1391
-            }
1392
-
1393
-            // add the margin top
1394
-            $yc = $y-$this->parsingCss->value['margin']['t'];
1395
-
1396
-            // get the width and the position of the parent
1397
-            $old = $this->parsingCss->getOldValues();
1398
-            if ( $old['width']) {
1399
-                $parentWidth = $old['width'];
1400
-                $parentX = $x;
1401
-            } else {
1402
-                $parentWidth = $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
1403
-                $parentX = $this->pdf->getlMargin();
1404
-            }
1405
-
1406
-            // if we are in a gloat => adapt the parent position and width
1407
-            if ($float) {
1408
-                list($lx, $rx) = $this->_getMargins($yc);
1409
-                $parentX = $lx;
1410
-                $parentWidth = $rx-$lx;
1411
-            }
1412
-
1413
-            // calculate the position of the image, if align to the right
1414
-            if ($parentWidth>$w && $float!='left') {
1415
-                if ($float=='right' || $this->parsingCss->value['text-align']=='li_right')    $x = $parentX + $parentWidth - $w-$this->parsingCss->value['margin']['r']-$this->parsingCss->value['margin']['l'];
1416
-            }
1417
-
1418
-            // display the image
1419
-            if (!$this->_subPart && !$this->_isSubPart) {
1420
-                if ($src) {
1421
-                    $this->pdf->Image($src, $x, $y, $w, $h, '', $this->_isInLink);
1422
-                } else {
1423
-                    // rectangle if the image can not be loaded
1424
-                    $this->pdf->setFillColorArray(array(240, 220, 220));
1425
-                    $this->pdf->Rect($x, $y, $w, $h, 'F');
1426
-                }
1427
-            }
1428
-
1429
-            // apply the margins
1430
-            $x-= $this->parsingCss->value['margin']['l'];
1431
-            $y-= $this->parsingCss->value['margin']['t'];
1432
-            $w+= $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['margin']['r'];
1433
-            $h+= $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['margin']['b'];
1434
-
1435
-            if ($float=='left') {
1436
-                // save the current max
1437
-                $this->_maxX = max($this->_maxX, $x+$w);
1438
-                $this->_maxY = max($this->_maxY, $y+$h);
1439
-
1440
-                // add the image to the margins
1441
-                $this->_addMargins($float, $x, $y, $x+$w, $y+$h);
1442
-
1443
-                // get the new position
1444
-                list($lx, $rx) = $this->_getMargins($yc);
1445
-                $this->pdf->setXY($lx, $yc);
1446
-            } else if ($float=='right') {
1447
-                // save the current max. We don't save the X because it is not the real max of the line
1448
-                $this->_maxY = max($this->_maxY, $y+$h);
1449
-
1450
-                // add the image to the margins
1451
-                $this->_addMargins($float, $x, $y, $x+$w, $y+$h);
1452
-
1453
-                // get the new position
1454
-                list($lx, $rx) = $this->_getMargins($yc);
1455
-                $this->pdf->setXY($lx, $yc);
1456
-            } else {
1457
-                // set the new position at the end of the image
1458
-                $this->pdf->setX($x+$w);
1459
-
1460
-                // save the current max
1461
-                $this->_maxX = max($this->_maxX, $x+$w);
1462
-                $this->_maxY = max($this->_maxY, $y+$h);
1463
-                $this->_maxH = max($this->_maxH, $h);
1464
-            }
1465
-
1466
-            return true;
1467
-        }
1468
-
1469
-        /**
1470
-         * draw a rectangle
1471
-         *
1472
-         * @access protected
1473
-         * @param  float $x
1474
-         * @param  float $y
1475
-         * @param  float $w
1476
-         * @param  float $h
1477
-         * @param  array $border
1478
-         * @param  float $padding - internal marge of the rectanble => not used, but...
1479
-         * @param  float $margin  - external marge of the rectanble
1480
-         * @param  array $background
1481
-         * @return boolean
1482
-         */
1483
-        protected function _drawRectangle($x, $y, $w, $h, $border, $padding, $margin, $background)
1484
-        {
1485
-            // if we are in a subpart or if height is null => return false
1486
-            if ($this->_subPart || $this->_isSubPart || $h===null) return false;
1487
-
1488
-            // add the margin
1489
-            $x+= $margin;
1490
-            $y+= $margin;
1491
-            $w-= $margin*2;
1492
-            $h-= $margin*2;
1493
-
1494
-            // get the radius of the border
1495
-            $outTL = $border['radius']['tl'];
1496
-            $outTR = $border['radius']['tr'];
1497
-            $outBR = $border['radius']['br'];
1498
-            $outBL = $border['radius']['bl'];
1499
-
1500
-            // prepare the out radius
1501
-            $outTL = ($outTL[0] && $outTL[1]) ? $outTL : null;
1502
-            $outTR = ($outTR[0] && $outTR[1]) ? $outTR : null;
1503
-            $outBR = ($outBR[0] && $outBR[1]) ? $outBR : null;
1504
-            $outBL = ($outBL[0] && $outBL[1]) ? $outBL : null;
1505
-
1506
-            // prepare the in radius
1507
-            $inTL = $outTL;
1508
-            $inTR = $outTR;
1509
-            $inBR = $outBR;
1510
-            $inBL = $outBL;
1511
-
1512
-            if (is_array($inTL)) {
1513
-                $inTL[0]-= $border['l']['width'];
1514
-                $inTL[1]-= $border['t']['width'];
1515
-            }
1516
-            if (is_array($inTR)) {
1517
-                $inTR[0]-= $border['r']['width'];
1518
-                $inTR[1]-= $border['t']['width'];
1519
-            }
1520
-            if (is_array($inBR)) {
1521
-                $inBR[0]-= $border['r']['width'];
1522
-                $inBR[1]-= $border['b']['width'];
1523
-            }
1524
-            if (is_array($inBL)) {
1525
-                $inBL[0]-= $border['l']['width'];
1526
-                $inBL[1]-= $border['b']['width'];
1527
-            }
1528
-
1529
-            if ($inTL[0]<=0 || $inTL[1]<=0) $inTL = null;
1530
-            if ($inTR[0]<=0 || $inTR[1]<=0) $inTR = null;
1531
-            if ($inBR[0]<=0 || $inBR[1]<=0) $inBR = null;
1532
-            if ($inBL[0]<=0 || $inBL[1]<=0) $inBL = null;
1533
-
1534
-            // prepare the background color
1535
-            $pdfStyle = '';
1536
-            if ($background['color']) {
1537
-                $this->pdf->setFillColorArray($background['color']);
1538
-                $pdfStyle.= 'F';
1539
-            }
1540
-
1541
-            // if we have a background to fill => fill it with a path (because of the radius)
1542
-            if ($pdfStyle) {
1543
-                $this->pdf->clippingPathStart($x, $y, $w, $h, $outTL, $outTR, $outBL, $outBR);
1544
-                $this->pdf->Rect($x, $y, $w, $h, $pdfStyle);
1545
-                $this->pdf->clippingPathStop();
1546
-            }
1547
-
1548
-            // prepare the background image
1549
-            if ($background['image']) {
1550
-                $iName      = $background['image'];
1551
-                $iPosition  = $background['position']!==null ? $background['position'] : array(0, 0);
1552
-                $iRepeat    = $background['repeat']!==null   ? $background['repeat']   : array(true, true);
1553
-
1554
-                // size of the background without the borders
1555
-                $bX = $x;
1556
-                $bY = $y;
1557
-                $bW = $w;
1558
-                $bH = $h;
1559
-
1560
-                if ($border['b']['width']) {
1561
-                    $bH-= $border['b']['width'];
1562
-                }
1563
-                if ($border['l']['width']) {
1564
-                    $bW-= $border['l']['width'];
1565
-                    $bX+= $border['l']['width'];
1566
-                }
1567
-                if ($border['t']['width']) {
1568
-                    $bH-= $border['t']['width'];
1569
-                    $bY+= $border['t']['width'];
1570
-                }
1571
-                if ($border['r']['width']) {
1572
-                    $bW-= $border['r']['width'];
1573
-                }
1574
-
1575
-                // get the size of the image
1576
-                // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini
1577
-                $imageInfos=@getimagesize($iName);
1578
-
1579
-                // if the image can not be loaded
1580
-                if (count($imageInfos)<2) {
1581
-                    if ($this->_testIsImage) {
1582
-                        throw new HTML2PDF_exception(6, $iName);
1583
-                    }
1584
-                } else {
1585
-                    // convert the size of the image from pixel to the unit of the PDF
1586
-                    $imageWidth    = 72./96.*$imageInfos[0]/$this->pdf->getK();
1587
-                    $imageHeight    = 72./96.*$imageInfos[1]/$this->pdf->getK();
1588
-
1589
-                    // prepare the position of the backgroung
1590
-                    if ($iRepeat[0]) $iPosition[0] = $bX;
1591
-                    else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) $iPosition[0] = $bX + $match[1]*($bW-$imageWidth)/100;
1592
-                    else $iPosition[0] = $bX+$iPosition[0];
1593
-
1594
-                    if ($iRepeat[1]) $iPosition[1] = $bY;
1595
-                    else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) $iPosition[1] = $bY + $match[1]*($bH-$imageHeight)/100;
1596
-                    else $iPosition[1] = $bY+$iPosition[1];
1597
-
1598
-                    $imageXmin = $bX;
1599
-                    $imageXmax = $bX+$bW;
1600
-                    $imageYmin = $bY;
1601
-                    $imageYmax = $bY+$bH;
1602
-
1603
-                    if (!$iRepeat[0] && !$iRepeat[1]) {
1604
-                        $imageXmin =     $iPosition[0]; $imageXmax =     $iPosition[0]+$imageWidth;
1605
-                        $imageYmin =     $iPosition[1]; $imageYmax =     $iPosition[1]+$imageHeight;
1606
-                    } else if ($iRepeat[0] && !$iRepeat[1]) {
1607
-                        $imageYmin =     $iPosition[1]; $imageYmax =     $iPosition[1]+$imageHeight;
1608
-                    } else if (!$iRepeat[0] && $iRepeat[1]) {
1609
-                        $imageXmin =     $iPosition[0]; $imageXmax =     $iPosition[0]+$imageWidth;
1610
-                    }
1611
-
1612
-                    // build the path to display the image (because of radius)
1613
-                    $this->pdf->clippingPathStart($bX, $bY, $bW, $bH, $inTL, $inTR, $inBL, $inBR);
1614
-
1615
-                    // repeat the image
1616
-                    for ($iY=$imageYmin; $iY<$imageYmax; $iY+=$imageHeight) {
1617
-                        for ($iX=$imageXmin; $iX<$imageXmax; $iX+=$imageWidth) {
1618
-                            $cX = null;
1619
-                            $cY = null;
1620
-                            $cW = $imageWidth;
1621
-                            $cH = $imageHeight;
1622
-                            if ($imageYmax-$iY<$imageHeight) {
1623
-                                $cX = $iX;
1624
-                                $cY = $iY;
1625
-                                $cH = $imageYmax-$iY;
1626
-                            }
1627
-                            if ($imageXmax-$iX<$imageWidth) {
1628
-                                $cX = $iX;
1629
-                                $cY = $iY;
1630
-                                $cW = $imageXmax-$iX;
1631
-                            }
1632
-
1633
-                            $this->pdf->Image($iName, $iX, $iY, $imageWidth, $imageHeight, '', '');
1634
-                        }
1635
-                    }
1636
-
1637
-                    // end of the path
1638
-                    $this->pdf->clippingPathStop();
1639
-                }
1640
-            }
1641
-
1642
-            // adding some loose (0.01mm)
1643
-            $loose = 0.01;
1644
-            $x-= $loose;
1645
-            $y-= $loose;
1646
-            $w+= 2.*$loose;
1647
-            $h+= 2.*$loose;
1648
-            if ($border['l']['width']) $border['l']['width']+= 2.*$loose;
1649
-            if ($border['t']['width']) $border['t']['width']+= 2.*$loose;
1650
-            if ($border['r']['width']) $border['r']['width']+= 2.*$loose;
1651
-            if ($border['b']['width']) $border['b']['width']+= 2.*$loose;
1652
-
1653
-            // prepare the test on borders
1654
-            $testBl = ($border['l']['width'] && $border['l']['color'][0]!==null);
1655
-            $testBt = ($border['t']['width'] && $border['t']['color'][0]!==null);
1656
-            $testBr = ($border['r']['width'] && $border['r']['color'][0]!==null);
1657
-            $testBb = ($border['b']['width'] && $border['b']['color'][0]!==null);
1658
-
1659
-            // draw the radius bottom-left
1660
-            if (is_array($outBL) && ($testBb || $testBl)) {
1661
-                if ($inBL) {
1662
-                    $courbe = array();
1663
-                    $courbe[] = $x+$outBL[0];              $courbe[] = $y+$h;
1664
-                    $courbe[] = $x;                        $courbe[] = $y+$h-$outBL[1];
1665
-                    $courbe[] = $x+$outBL[0];              $courbe[] = $y+$h-$border['b']['width'];
1666
-                    $courbe[] = $x+$border['l']['width'];  $courbe[] = $y+$h-$outBL[1];
1667
-                    $courbe[] = $x+$outBL[0];              $courbe[] = $y+$h-$outBL[1];
1668
-                } else {
1669
-                    $courbe = array();
1670
-                    $courbe[] = $x+$outBL[0];              $courbe[] = $y+$h;
1671
-                    $courbe[] = $x;                        $courbe[] = $y+$h-$outBL[1];
1672
-                    $courbe[] = $x+$border['l']['width'];  $courbe[] = $y+$h-$border['b']['width'];
1673
-                    $courbe[] = $x+$outBL[0];              $courbe[] = $y+$h-$outBL[1];
1674
-                }
1675
-                $this->_drawCurve($courbe, $border['l']['color']);
1676
-            }
1677
-
1678
-            // draw the radius left-top
1679
-            if (is_array($outTL) && ($testBt || $testBl)) {
1680
-                if ($inTL) {
1681
-                    $courbe = array();
1682
-                    $courbe[] = $x;                        $courbe[] = $y+$outTL[1];
1683
-                    $courbe[] = $x+$outTL[0];              $courbe[] = $y;
1684
-                    $courbe[] = $x+$border['l']['width'];  $courbe[] = $y+$outTL[1];
1685
-                    $courbe[] = $x+$outTL[0];              $courbe[] = $y+$border['t']['width'];
1686
-                    $courbe[] = $x+$outTL[0];              $courbe[] = $y+$outTL[1];
1687
-                } else {
1688
-                    $courbe = array();
1689
-                    $courbe[] = $x;                        $courbe[] = $y+$outTL[1];
1690
-                    $courbe[] = $x+$outTL[0];              $courbe[] = $y;
1691
-                    $courbe[] = $x+$border['l']['width'];  $courbe[] = $y+$border['t']['width'];
1692
-                    $courbe[] = $x+$outTL[0];              $courbe[] = $y+$outTL[1];
1693
-                }
1694
-                $this->_drawCurve($courbe, $border['t']['color']);
1695
-            }
1696
-
1697
-            // draw the radius top-right
1698
-            if (is_array($outTR) && ($testBt || $testBr)) {
1699
-                if ($inTR) {
1700
-                    $courbe = array();
1701
-                    $courbe[] = $x+$w-$outTR[0];             $courbe[] = $y;
1702
-                    $courbe[] = $x+$w;                       $courbe[] = $y+$outTR[1];
1703
-                    $courbe[] = $x+$w-$outTR[0];             $courbe[] = $y+$border['t']['width'];
1704
-                    $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$outTR[1];
1705
-                    $courbe[] = $x+$w-$outTR[0];             $courbe[] = $y+$outTR[1];
1706
-                } else {
1707
-                    $courbe = array();
1708
-                    $courbe[] = $x+$w-$outTR[0];             $courbe[] = $y;
1709
-                    $courbe[] = $x+$w;                       $courbe[] = $y+$outTR[1];
1710
-                    $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$border['t']['width'];
1711
-                    $courbe[] = $x+$w-$outTR[0];             $courbe[] = $y+$outTR[1];
1712
-                }
1713
-                $this->_drawCurve($courbe, $border['r']['color']);
1714
-            }
1715
-
1716
-            // draw the radius right-bottom
1717
-            if (is_array($outBR) && ($testBb || $testBr)) {
1718
-                if ($inBR) {
1719
-                    $courbe = array();
1720
-                    $courbe[] = $x+$w;                       $courbe[] = $y+$h-$outBR[1];
1721
-                    $courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h;
1722
-                    $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$h-$outBR[1];
1723
-                    $courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h-$border['b']['width'];
1724
-                    $courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h-$outBR[1];
1725
-                } else {
1726
-                    $courbe = array();
1727
-                    $courbe[] = $x+$w;                       $courbe[] = $y+$h-$outBR[1];
1728
-                    $courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h;
1729
-                    $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$h-$border['b']['width'];
1730
-                    $courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h-$outBR[1];
1731
-                }
1732
-                $this->_drawCurve($courbe, $border['b']['color']);
1733
-            }
1734
-
1735
-            // draw the left border
1736
-            if ($testBl) {
1737
-                $pt = array();
1738
-                $pt[] = $x;                       $pt[] = $y+$h;
1739
-                $pt[] = $x;                       $pt[] = $y+$h-$border['b']['width'];
1740
-                $pt[] = $x;                       $pt[] = $y+$border['t']['width'];
1741
-                $pt[] = $x;                       $pt[] = $y;
1742
-                $pt[] = $x+$border['l']['width']; $pt[] = $y+$border['t']['width'];
1743
-                $pt[] = $x+$border['l']['width']; $pt[] = $y+$h-$border['b']['width'];
1744
-
1745
-                $bord = 3;
1746
-                if (is_array($outBL)) {
1747
-                    $bord-=1;
1748
-                    $pt[3] -= $outBL[1] - $border['b']['width'];
1749
-                    if ($inBL) $pt[11]-= $inBL[1];
1750
-                    unset($pt[0]);unset($pt[1]);
1751
-                }
1752
-                if (is_array($outTL)) {
1753
-                    $bord-=2;
1754
-                    $pt[5] += $outTL[1]-$border['t']['width'];
1755
-                    if ($inTL) $pt[9] += $inTL[1];
1756
-                    unset($pt[6]);unset($pt[7]);
1757
-                }
1758
-
1759
-                $pt = array_values($pt);
1760
-                $this->_drawLine($pt, $border['l']['color'], $border['l']['type'], $border['l']['width'], $bord);
1761
-            }
1762
-
1763
-            // draw the top border
1764
-            if ($testBt) {
1765
-                $pt = array();
1766
-                $pt[] = $x;                          $pt[] = $y;
1767
-                $pt[] = $x+$border['l']['width'];    $pt[] = $y;
1768
-                $pt[] = $x+$w-$border['r']['width']; $pt[] = $y;
1769
-                $pt[] = $x+$w;                       $pt[] = $y;
1770
-                $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$border['t']['width'];
1771
-                $pt[] = $x+$border['l']['width'];    $pt[] = $y+$border['t']['width'];
1772
-
1773
-                $bord = 3;
1774
-                if (is_array($outTL)) {
1775
-                    $bord-=1;
1776
-                    $pt[2] += $outTL[0] - $border['l']['width'];
1777
-                    if ($inTL) $pt[10]+= $inTL[0];
1778
-                    unset($pt[0]);unset($pt[1]);
1779
-                }
1780
-                if (is_array($outTR)) {
1781
-                    $bord-=2;
1782
-                    $pt[4] -= $outTR[0] - $border['r']['width'];
1783
-                    if ($inTR) $pt[8] -= $inTR[0];
1784
-                    unset($pt[6]);unset($pt[7]);
1785
-                }
1786
-
1787
-                $pt = array_values($pt);
1788
-                $this->_drawLine($pt, $border['t']['color'], $border['t']['type'], $border['t']['width'], $bord);
1789
-            }
1790
-
1791
-            // draw the right border
1792
-            if ($testBr) {
1793
-                $pt = array();
1794
-                $pt[] = $x+$w;                       $pt[] = $y;
1795
-                $pt[] = $x+$w;                       $pt[] = $y+$border['t']['width'];
1796
-                $pt[] = $x+$w;                       $pt[] = $y+$h-$border['b']['width'];
1797
-                $pt[] = $x+$w;                       $pt[] = $y+$h;
1798
-                $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h-$border['b']['width'];
1799
-                $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$border['t']['width'];
1800
-
1801
-                $bord = 3;
1802
-                if (is_array($outTR)) {
1803
-                    $bord-=1;
1804
-                    $pt[3] += $outTR[1] - $border['t']['width'];
1805
-                    if ($inTR) $pt[11]+= $inTR[1];
1806
-                    unset($pt[0]);unset($pt[1]);
1807
-                }
1808
-                if (is_array($outBR)) {
1809
-                    $bord-=2;
1810
-                    $pt[5] -= $outBR[1] - $border['b']['width'];
1811
-                    if ($inBR) $pt[9] -= $inBR[1];
1812
-                    unset($pt[6]);unset($pt[7]);
1813
-                }
1814
-
1815
-                $pt = array_values($pt);
1816
-                $this->_drawLine($pt, $border['r']['color'], $border['r']['type'], $border['r']['width'], $bord);
1817
-            }
1818
-
1819
-            // draw the bottom border
1820
-            if ($testBb) {
1821
-                $pt = array();
1822
-                $pt[] = $x+$w;                       $pt[] = $y+$h;
1823
-                $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h;
1824
-                $pt[] = $x+$border['l']['width'];    $pt[] = $y+$h;
1825
-                $pt[] = $x;                          $pt[] = $y+$h;
1826
-                $pt[] = $x+$border['l']['width'];    $pt[] = $y+$h-$border['b']['width'];
1827
-                $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h-$border['b']['width'];
1828
-
1829
-                $bord = 3;
1830
-                if (is_array($outBL)) {
1831
-                    $bord-=2;
1832
-                    $pt[4] += $outBL[0] - $border['l']['width'];
1833
-                    if ($inBL) $pt[8] += $inBL[0];
1834
-                    unset($pt[6]);unset($pt[7]);
1835
-                }
1836
-                if (is_array($outBR)) {
1837
-                    $bord-=1;
1838
-                    $pt[2] -= $outBR[0] - $border['r']['width'];
1839
-                    if ($inBR) $pt[10]-= $inBR[0];
1840
-                    unset($pt[0]);unset($pt[1]);
1841
-
1842
-                }
1843
-
1844
-                $pt = array_values($pt);
1845
-                $this->_drawLine($pt, $border['b']['color'], $border['b']['type'], $border['b']['width'], $bord);
1846
-            }
1847
-
1848
-            if ($background['color']) {
1849
-                $this->pdf->setFillColorArray($background['color']);
1850
-            }
1851
-
1852
-            return true;
1853
-        }
1854
-
1855
-        /**
1856
-         * draw a curve (for border radius)
1857
-         *
1858
-         * @access protected
1859
-         * @param  array $pt
1860
-         * @param  array $color
1861
-         */
1862
-        protected function _drawCurve($pt, $color)
1863
-        {
1864
-            $this->pdf->setFillColorArray($color);
1865
-
1866
-            if (count($pt)==10)
1867
-                $this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]);
1868
-            else
1869
-                $this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]);
1870
-        }
1871
-
1872
-        /**
1873
-         * draw a ligne with a specific type, and specific start and end for radius
1874
-         *
1875
-         * @access protected
1876
-         * @param  array   $pt
1877
-         * @param  float   $color
1878
-         * @param  string  $type (dashed, dotted, double, solid)
1879
-         * @param  float   $width
1880
-         * @param  integer $radius (binary from 0 to 3 with 1=>start with a radius, 2=>end with a radius)
1881
-         */
1882
-        protected function _drawLine($pt, $color, $type, $width, $radius=3)
1883
-        {
1884
-            // set the fill color
1885
-            $this->pdf->setFillColorArray($color);
1886
-
1887
-            // if dashed or dotted
1888
-            if ($type=='dashed' || $type=='dotted') {
1889
-
1890
-                // clean the end of the line, if radius
1891
-                if ($radius==1) {
1892
-                    $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
1893
-                    $this->pdf->Polygon($tmp, 'F');
1894
-
1895
-                    $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
1896
-                    $pt = $tmp;
1897
-                } else if ($radius==2) {
1898
-                    $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7];
1899
-                    $this->pdf->Polygon($tmp, 'F');
1900
-
1901
-                    $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
1902
-                    $pt = $tmp;
1903
-                } else if ($radius==3) {
1904
-                    $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[10]; $tmp[]=$pt[11];
1905
-                    $this->pdf->Polygon($tmp, 'F');
1906
-
1907
-                    $tmp = array(); $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
1908
-                    $this->pdf->Polygon($tmp, 'F');
1909
-
1910
-                    $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[8]; $tmp[]=$pt[9]; $tmp[]=$pt[10]; $tmp[]=$pt[11];
1911
-                    $pt = $tmp;
1912
-                }
1913
-
1914
-                // horisontal or vertical line
1915
-                if ($pt[2]==$pt[0]) {
1916
-                    $l = abs(($pt[3]-$pt[1])*0.5);
1917
-                    $px = 0;
1918
-                    $py = $width;
1919
-                    $x1 = $pt[0]; $y1 = ($pt[3]+$pt[1])*0.5;
1920
-                    $x2 = $pt[6]; $y2 = ($pt[7]+$pt[5])*0.5;
1921
-                } else {
1922
-                    $l = abs(($pt[2]-$pt[0])*0.5);
1923
-                    $px = $width;
1924
-                    $py = 0;
1925
-                    $x1 = ($pt[2]+$pt[0])*0.5; $y1 = $pt[1];
1926
-                    $x2 = ($pt[6]+$pt[4])*0.5; $y2 = $pt[7];
1927
-                }
1928
-
1929
-                // if dashed : 3x bigger than dotted
1930
-                if ($type=='dashed') {
1931
-                    $px = $px*3.;
1932
-                    $py = $py*3.;
1933
-                }
1934
-                $mode = ($l/($px+$py)<.5);
1935
-
1936
-                // display the dotted/dashed line
1937
-                for ($i=0; $l-($px+$py)*($i-0.5)>0; $i++) {
1938
-                    if (($i%2)==$mode) {
1939
-                        $j = $i-0.5;
1940
-                        $lx1 = $px*($j);   if ($lx1<-$l) $lx1 =-$l;
1941
-                        $ly1 = $py*($j);   if ($ly1<-$l) $ly1 =-$l;
1942
-                        $lx2 = $px*($j+1); if ($lx2>$l)  $lx2 = $l;
1943
-                        $ly2 = $py*($j+1); if ($ly2>$l)  $ly2 = $l;
1944
-
1945
-                        $tmp = array();
1946
-                        $tmp[] = $x1+$lx1; $tmp[] = $y1+$ly1;
1947
-                        $tmp[] = $x1+$lx2; $tmp[] = $y1+$ly2;
1948
-                        $tmp[] = $x2+$lx2; $tmp[] = $y2+$ly2;
1949
-                        $tmp[] = $x2+$lx1; $tmp[] = $y2+$ly1;
1950
-                        $this->pdf->Polygon($tmp, 'F');
1951
-
1952
-                        if ($j>0) {
1953
-                            $tmp = array();
1954
-                            $tmp[] = $x1-$lx1; $tmp[] = $y1-$ly1;
1955
-                            $tmp[] = $x1-$lx2; $tmp[] = $y1-$ly2;
1956
-                            $tmp[] = $x2-$lx2; $tmp[] = $y2-$ly2;
1957
-                            $tmp[] = $x2-$lx1; $tmp[] = $y2-$ly1;
1958
-                            $this->pdf->Polygon($tmp, 'F');
1959
-                        }
1960
-                    }
1961
-                }
1962
-            } else if ($type=='double') {
1963
-
1964
-                // if double, 2 lines : 0=>1/3 and 2/3=>1
1965
-                $pt1 = $pt;
1966
-                $pt2 = $pt;
1967
-
1968
-                if (count($pt)==12) {
1969
-                    // line 1
1970
-                    $pt1[0] = ($pt[0]-$pt[10])*0.33 + $pt[10];
1971
-                    $pt1[1] = ($pt[1]-$pt[11])*0.33 + $pt[11];
1972
-                    $pt1[2] = ($pt[2]-$pt[10])*0.33 + $pt[10];
1973
-                    $pt1[3] = ($pt[3]-$pt[11])*0.33 + $pt[11];
1974
-                    $pt1[4] = ($pt[4]-$pt[8])*0.33 + $pt[8];
1975
-                    $pt1[5] = ($pt[5]-$pt[9])*0.33 + $pt[9];
1976
-                    $pt1[6] = ($pt[6]-$pt[8])*0.33 + $pt[8];
1977
-                    $pt1[7] = ($pt[7]-$pt[9])*0.33 + $pt[9];
1978
-                    $pt2[10]= ($pt[10]-$pt[0])*0.33 + $pt[0];
1979
-                    $pt2[11]= ($pt[11]-$pt[1])*0.33 + $pt[1];
1980
-
1981
-                    // line 2
1982
-                    $pt2[2] = ($pt[2] -$pt[0])*0.33 + $pt[0];
1983
-                    $pt2[3] = ($pt[3] -$pt[1])*0.33 + $pt[1];
1984
-                    $pt2[4] = ($pt[4] -$pt[6])*0.33 + $pt[6];
1985
-                    $pt2[5] = ($pt[5] -$pt[7])*0.33 + $pt[7];
1986
-                    $pt2[8] = ($pt[8] -$pt[6])*0.33 + $pt[6];
1987
-                    $pt2[9] = ($pt[9] -$pt[7])*0.33 + $pt[7];
1988
-                } else {
1989
-                    // line 1
1990
-                    $pt1[0] = ($pt[0]-$pt[6])*0.33 + $pt[6];
1991
-                    $pt1[1] = ($pt[1]-$pt[7])*0.33 + $pt[7];
1992
-                    $pt1[2] = ($pt[2]-$pt[4])*0.33 + $pt[4];
1993
-                    $pt1[3] = ($pt[3]-$pt[5])*0.33 + $pt[5];
1994
-
1995
-                    // line 2
1996
-                    $pt2[6] = ($pt[6]-$pt[0])*0.33 + $pt[0];
1997
-                    $pt2[7] = ($pt[7]-$pt[1])*0.33 + $pt[1];
1998
-                    $pt2[4] = ($pt[4]-$pt[2])*0.33 + $pt[2];
1999
-                    $pt2[5] = ($pt[5]-$pt[3])*0.33 + $pt[3];
2000
-                }
2001
-                $this->pdf->Polygon($pt1, 'F');
2002
-                $this->pdf->Polygon($pt2, 'F');
2003
-            } else if ($type=='solid') {
2004
-                // solid line : draw directly the polygon
2005
-                $this->pdf->Polygon($pt, 'F');
2006
-            }
2007
-        }
2008
-
2009
-        /**
2010
-         * prepare a transform matrix, only for drawing a SVG graphic
2011
-         *
2012
-         * @access protected
2013
-         * @param  string $transform
2014
-         * @return array  $matrix
2015
-         */
2016
-        protected function _prepareTransform($transform)
2017
-        {
2018
-            // it can not be  empty
2019
-            if (!$transform) return null;
2020
-
2021
-            // sctions must be like scale(...)
2022
-            if (!preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) return null;
2023
-
2024
-            // prepare the list of the actions
2025
-            $actions = array();
2026
-
2027
-            // for actions
2028
-            for ($k=0; $k<count($match[0]); $k++) {
2029
-
2030
-                // get the name of the action
2031
-                $name = strtolower($match[1][$k]);
2032
-
2033
-                // get the parameters of the action
2034
-                $val = explode(',', trim($match[2][$k]));
2035
-                foreach ($val as $i => $j) {
2036
-                    $val[$i] = trim($j);
2037
-                }
2038
-
2039
-                // prepare the matrix, depending on the action
2040
-                switch($name)
2041
-                {
2042
-                    case 'scale':
2043
-                        if (!isset($val[0])) $val[0] = 1.;      else $val[0] = 1.*$val[0];
2044
-                        if (!isset($val[1])) $val[1] = $val[0]; else $val[1] = 1.*$val[1];
2045
-                        $actions[] = array($val[0],0,0,$val[1],0,0);
2046
-                        break;
2047
-
2048
-                    case 'translate':
2049
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']);
2050
-                        if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']);
2051
-                        $actions[] = array(1,0,0,1,$val[0],$val[1]);
2052
-                        break;
2053
-
2054
-                    case 'rotate':
2055
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.;
2056
-                        if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']);
2057
-                        if (!isset($val[2])) $val[2] = 0.; else $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']);
2058
-                        if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,-$val[1],-$val[2]);
2059
-                        $actions[] = array(cos($val[0]),sin($val[0]),-sin($val[0]),cos($val[0]),0,0);
2060
-                        if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,$val[1],$val[2]);
2061
-                        break;
2062
-
2063
-                    case 'skewx':
2064
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.;
2065
-                        $actions[] = array(1,0,tan($val[0]),1,0,0);
2066
-                        break;
2067
-
2068
-                    case 'skewy':
2069
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.;
2070
-                        $actions[] = array(1,tan($val[0]),0,1,0,0);
2071
-                        break;
2072
-                    case 'matrix':
2073
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*1.;
2074
-                        if (!isset($val[1])) $val[1] = 0.; else $val[1] = $val[1]*1.;
2075
-                        if (!isset($val[2])) $val[2] = 0.; else $val[2] = $val[2]*1.;
2076
-                        if (!isset($val[3])) $val[3] = 0.; else $val[3] = $val[3]*1.;
2077
-                        if (!isset($val[4])) $val[4] = 0.; else $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']);
2078
-                        if (!isset($val[5])) $val[5] = 0.; else $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']);
2079
-                        $actions[] =$val;
2080
-                        break;
2081
-                }
2082
-            }
2083
-
2084
-            // if ther is no actions => return
2085
-            if (!$actions) return null;
2086
-
2087
-            // get the first matrix
2088
-            $m = $actions[0]; unset($actions[0]);
2089
-
2090
-            // foreach matrix => multiply to the last matrix
2091
-            foreach ($actions as $n) {
2092
-                $m = array(
2093
-                    $m[0]*$n[0]+$m[2]*$n[1],
2094
-                    $m[1]*$n[0]+$m[3]*$n[1],
2095
-                    $m[0]*$n[2]+$m[2]*$n[3],
2096
-                    $m[1]*$n[2]+$m[3]*$n[3],
2097
-                    $m[0]*$n[4]+$m[2]*$n[5]+$m[4],
2098
-                    $m[1]*$n[4]+$m[3]*$n[5]+$m[5]
2099
-                );
2100
-            }
2101
-
2102
-            // return the matrix
2103
-            return $m;
2104
-        }
2105
-
2106
-        /**
2107
-         * @access protected
2108
-         * @param  &array $cases
2109
-         * @param  &array $corr
2110
-         */
2111
-        protected function _calculateTableCellSize(&$cases, &$corr)
2112
-        {
2113
-            if (!isset($corr[0])) return true;
2114
-
2115
-            // for each cell without colspan, we get the max width for each column
2116
-            $sw = array();
2117
-            for ($x=0; $x<count($corr[0]); $x++) {
2118
-                $m=0;
2119
-                for ($y=0; $y<count($corr); $y++) {
2120
-                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]==1) {
2121
-                        $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']);
2122
-                    }
2123
-                }
2124
-                $sw[$x] = $m;
2125
-            }
2126
-
2127
-            // for each cell with colspan, we adapt the width of each column
2128
-            for ($x=0; $x<count($corr[0]); $x++) {
2129
-                for ($y=0; $y<count($corr); $y++) {
2130
-                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]>1) {
2131
-
2132
-                        // sum the max width of each column in colspan
2133
-                        $s = 0; for ($i=0; $i<$corr[$y][$x][2]; $i++) $s+= $sw[$x+$i];
2134
-
2135
-                        // if the max width is < the width of the cell with colspan => we adapt the width of each max width
2136
-                        if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']) {
2137
-                            for ($i=0; $i<$corr[$y][$x][2]; $i++) {
2138
-                                $sw[$x+$i] = $sw[$x+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
2139
-                            }
2140
-                        }
2141
-                    }
2142
-                }
2143
-            }
2144
-
2145
-            // set the new width, for each cell
2146
-            for ($x=0; $x<count($corr[0]); $x++) {
2147
-                for ($y=0; $y<count($corr); $y++) {
2148
-                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) {
2149
-                        // without colspan
2150
-                        if ($corr[$y][$x][2]==1) {
2151
-                            $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $sw[$x];
2152
-                        // with colspan
2153
-                        } else {
2154
-                            $s = 0;
2155
-                            for ($i=0; $i<$corr[$y][$x][2]; $i++) {
2156
-                                $s+= $sw[$x+$i];
2157
-                            }
2158
-                            $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $s;
2159
-                        }
2160
-                    }
2161
-                }
2162
-            }
2163
-
2164
-            // for each cell without rowspan, we get the max height for each line
2165
-            $sh = array();
2166
-            for ($y=0; $y<count($corr); $y++) {
2167
-                $m=0;
2168
-                for ($x=0; $x<count($corr[0]); $x++) {
2169
-                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]==1) {
2170
-                        $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']);
2171
-                    }
2172
-                }
2173
-                $sh[$y] = $m;
2174
-            }
2175
-
2176
-            // for each cell with rowspan, we adapt the height of each line
2177
-            for ($y=0; $y<count($corr); $y++) {
2178
-                for ($x=0; $x<count($corr[0]); $x++) {
2179
-                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]>1) {
2180
-
2181
-                        // sum the max height of each line in rowspan
2182
-                        $s = 0; for ($i=0; $i<$corr[$y][$x][3]; $i++) $s+= $sh[$y+$i];
2183
-
2184
-                        // if the max height is < the height of the cell with rowspan => we adapt the height of each max height
2185
-                        if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']) {
2186
-                            for ($i=0; $i<$corr[$y][$x][3]; $i++) {
2187
-                                $sh[$y+$i] = $sh[$y+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'];
2188
-                            }
2189
-                        }
2190
-                    }
2191
-                }
2192
-            }
2193
-
2194
-            // set the new height, for each cell
2195
-            for ($y=0; $y<count($corr); $y++) {
2196
-                for ($x=0; $x<count($corr[0]); $x++) {
2197
-                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) {
2198
-                        // without rowspan
2199
-                        if ($corr[$y][$x][3]==1) {
2200
-                            $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $sh[$y];
2201
-                        // with rowspan
2202
-                        } else {
2203
-                            $s = 0;
2204
-                            for ($i=0; $i<$corr[$y][$x][3]; $i++) {
2205
-                                $s+= $sh[$y+$i];
2206
-                            }
2207
-                            $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $s;
2208
-
2209
-                            for ($j=1; $j<$corr[$y][$x][3]; $j++) {
2210
-                                $tx = $x+1;
2211
-                                $ty = $y+$j;
2212
-                                for (true; isset($corr[$ty][$tx]) && !is_array($corr[$ty][$tx]); $tx++);
2213
-                                if (isset($corr[$ty][$tx])) {
2214
-                                    $cases[$corr[$ty][$tx][1]][$corr[$ty][$tx][0]]['dw']+= $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
2215
-                                }
2216
-                            }
2217
-                        }
2218
-                    }
2219
-                }
2220
-            }
2221
-        }
2222
-
2223
-        /**
2224
-         * tag : PAGE
2225
-         * mode : OPEN
2226
-         *
2227
-         * @param  array $param
2228
-         * @return boolean
2229
-         */
2230
-        protected function _tag_open_PAGE($param)
2231
-        {
2232
-            if ($this->_isForOneLine) return false;
2233
-            if ($this->_debugActif) $this->_DEBUG_add('PAGE '.($this->_page+1), true);
2234
-
2235
-            $newPageSet= (!isset($param['pageset']) || $param['pageset']!='old');
2236
-
2237
-            $resetPageNumber = (isset($param['pagegroup']) && $param['pagegroup']=='new');
2238
-
2239
-            $this->_maxH = 0;
2240
-
2241
-            // if new page set asked
2242
-            if ($newPageSet) {
2243
-                $this->_subHEADER = array();
2244
-                $this->_subFOOTER = array();
2245
-
2246
-                // orientation
2247
-                $orientation = '';
2248
-                if (isset($param['orientation'])) {
2249
-                    $param['orientation'] = strtolower($param['orientation']);
2250
-                    if ($param['orientation']=='p')         $orientation = 'P';
2251
-                    if ($param['orientation']=='portrait')  $orientation = 'P';
2252
-
2253
-                    if ($param['orientation']=='l')         $orientation = 'L';
2254
-                    if ($param['orientation']=='paysage')   $orientation = 'L';
2255
-                    if ($param['orientation']=='landscape') $orientation = 'L';
2256
-                }
2257
-
2258
-                // format
2259
-                $format = null;
2260
-                if (isset($param['format'])) {
2261
-                    $format = strtolower($param['format']);
2262
-                    if (preg_match('/^([0-9]+)x([0-9]+)$/isU', $format, $match)) {
2263
-                        $format = array(intval($match[1]), intval($match[2]));
2264
-                    }
2265
-                }
2266
-
2267
-                // background
2268
-                $background = array();
2269
-                if (isset($param['backimg'])) {
2270
-                    $background['img']    = isset($param['backimg'])  ? $param['backimg']  : '';       // src of the image
2271
-                    $background['posX']   = isset($param['backimgx']) ? $param['backimgx'] : 'center'; // horizontale position of the image
2272
-                    $background['posY']   = isset($param['backimgy']) ? $param['backimgy'] : 'middle'; // vertical position of the image
2273
-                    $background['width']  = isset($param['backimgw']) ? $param['backimgw'] : '100%';   // width of the image (100% = page width)
2274
-
2275
-                    // convert the src of the image, if parameters
2276
-                    $background['img'] = str_replace('&amp;', '&', $background['img']);
2277
-
2278
-                    // convert the positions
2279
-                    if ($background['posX']=='left')    $background['posX'] = '0%';
2280
-                    if ($background['posX']=='center')  $background['posX'] = '50%';
2281
-                    if ($background['posX']=='right')   $background['posX'] = '100%';
2282
-                    if ($background['posY']=='top')     $background['posY'] = '0%';
2283
-                    if ($background['posY']=='middle')  $background['posY'] = '50%';
2284
-                    if ($background['posY']=='bottom')  $background['posY'] = '100%';
2285
-
2286
-                    if ($background['img']) {
2287
-                        // get the size of the image
2288
-                        // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini
2289
-                        $infos=@getimagesize($background['img']);
2290
-                        if (count($infos)>1) {
2291
-                            $imageWidth = $this->parsingCss->ConvertToMM($background['width'], $this->pdf->getW());
2292
-                            $imageHeight = $imageWidth*$infos[1]/$infos[0];
2293
-
2294
-                            $background['width'] = $imageWidth;
2295
-                            $background['posX']  = $this->parsingCss->ConvertToMM($background['posX'], $this->pdf->getW() - $imageWidth);
2296
-                            $background['posY']  = $this->parsingCss->ConvertToMM($background['posY'], $this->pdf->getH() - $imageHeight);
2297
-                        } else {
2298
-                            $background = array();
2299
-                        }
2300
-                    } else {
2301
-                        $background = array();
2302
-                    }
2303
-                }
2304
-
2305
-                // margins of the page
2306
-                $background['top']    = isset($param['backtop'])    ? $param['backtop']    : '0';
2307
-                $background['bottom'] = isset($param['backbottom']) ? $param['backbottom'] : '0';
2308
-                $background['left']   = isset($param['backleft'])   ? $param['backleft']   : '0';
2309
-                $background['right']  = isset($param['backright'])  ? $param['backright']  : '0';
2310
-
2311
-                // if no unit => mm
2312
-                if (preg_match('/^([0-9]*)$/isU', $background['top']))    $background['top']    .= 'mm';
2313
-                if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) $background['bottom'] .= 'mm';
2314
-                if (preg_match('/^([0-9]*)$/isU', $background['left']))   $background['left']   .= 'mm';
2315
-                if (preg_match('/^([0-9]*)$/isU', $background['right']))  $background['right']  .= 'mm';
2316
-
2317
-                // convert to mm
2318
-                $background['top']    = $this->parsingCss->ConvertToMM($background['top'], $this->pdf->getH());
2319
-                $background['bottom'] = $this->parsingCss->ConvertToMM($background['bottom'], $this->pdf->getH());
2320
-                $background['left']   = $this->parsingCss->ConvertToMM($background['left'], $this->pdf->getW());
2321
-                $background['right']  = $this->parsingCss->ConvertToMM($background['right'], $this->pdf->getW());
2322
-
2323
-                // get the background color
2324
-                $res = false;
2325
-                $background['color']    = isset($param['backcolor'])    ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null;
2326
-                if (!$res) $background['color'] = null;
2327
-
2328
-                $this->parsingCss->save();
2329
-                $this->parsingCss->analyse('PAGE', $param);
2330
-                $this->parsingCss->setPosition();
2331
-                $this->parsingCss->fontSet();
2332
-
2333
-                // new page
2334
-                $this->_setNewPage($format, $orientation, $background, null, $resetPageNumber);
2335
-
2336
-                // automatic footer
2337
-                if (isset($param['footer'])) {
2338
-                    $lst = explode(';', $param['footer']);
2339
-                    foreach ($lst as $key => $val) $lst[$key] = trim(strtolower($val));
2340
-                    $page    = in_array('page', $lst);
2341
-                    $date    = in_array('date', $lst);
2342
-                    $hour    = in_array('heure', $lst);
2343
-                    $form    = in_array('form', $lst);
2344
-                } else {
2345
-                    $page    = null;
2346
-                    $date    = null;
2347
-                    $hour    = null;
2348
-                    $form    = null;
2349
-                }
2350
-                $this->pdf->SetMyFooter($page, $date, $hour, $form);
2351
-            // else => we use the last page set used
2352
-            } else {
2353
-                $this->parsingCss->save();
2354
-                $this->parsingCss->analyse('PAGE', $param);
2355
-                $this->parsingCss->setPosition();
2356
-                $this->parsingCss->fontSet();
2357
-
2358
-                $this->_setNewPage(null, null, null, null, $resetPageNumber);
2359
-            }
2360
-
2361
-            return true;
2362
-        }
2363
-
2364
-        /**
2365
-         * tag : PAGE
2366
-         * mode : CLOSE
2367
-         *
2368
-         * @param  array $param
2369
-         * @return boolean
2370
-         */
2371
-        protected function _tag_close_PAGE($param)
2372
-        {
2373
-            if ($this->_isForOneLine) return false;
2374
-
2375
-            $this->_maxH = 0;
2376
-
2377
-            $this->parsingCss->load();
2378
-            $this->parsingCss->fontSet();
2379
-
2380
-            if ($this->_debugActif) $this->_DEBUG_add('PAGE '.$this->_page, false);
2381
-
2382
-            return true;
2383
-        }
2384
-
2385
-        /**
2386
-         * tag : PAGE_HEADER
2387
-         * mode : OPEN
2388
-         *
2389
-         * @param  array $param
2390
-         * @return boolean
2391
-         */
2392
-        protected function _tag_open_PAGE_HEADER($param)
2393
-        {
2394
-            if ($this->_isForOneLine) return false;
2395
-
2396
-            $this->_subHEADER = array();
2397
-            for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) {
2398
-                $action = $this->parsingHtml->code[$this->_parsePos];
2399
-                if ($action['name']=='page_header') $action['name']='page_header_sub';
2400
-                $this->_subHEADER[] = $action;
2401
-                if (strtolower($action['name'])=='page_header_sub' && $action['close']) break;
2402
-            }
2403
-
2404
-            $this->_setPageHeader();
2405
-
2406
-            return true;
2407
-        }
2408
-
2409
-        /**
2410
-         * tag : PAGE_FOOTER
2411
-         * mode : OPEN
2412
-         *
2413
-         * @param  array $param
2414
-         * @return boolean
2415
-         */
2416
-        protected function _tag_open_PAGE_FOOTER($param)
2417
-        {
2418
-            if ($this->_isForOneLine) return false;
2419
-
2420
-            $this->_subFOOTER = array();
2421
-            for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) {
2422
-                $action = $this->parsingHtml->code[$this->_parsePos];
2423
-                if ($action['name']=='page_footer') $action['name']='page_footer_sub';
2424
-                $this->_subFOOTER[] = $action;
2425
-                if (strtolower($action['name'])=='page_footer_sub' && $action['close']) break;
2426
-            }
2427
-
2428
-            $this->_setPageFooter();
2429
-
2430
-            return true;
2431
-        }
2432
-
2433
-        /**
2434
-         * It is not a real tag. Does not use it directly
2435
-         *
2436
-         * @param  array $param
2437
-         * @return boolean
2438
-         */
2439
-        protected function _tag_open_PAGE_HEADER_SUB($param)
2440
-        {
2441
-            if ($this->_isForOneLine) return false;
2442
-
2443
-            // save the current stat
2444
-            $this->_subSTATES = array();
2445
-            $this->_subSTATES['x']  = $this->pdf->getX();
2446
-            $this->_subSTATES['y']  = $this->pdf->getY();
2447
-            $this->_subSTATES['s']  = $this->parsingCss->value;
2448
-            $this->_subSTATES['t']  = $this->parsingCss->table;
2449
-            $this->_subSTATES['ml'] = $this->_margeLeft;
2450
-            $this->_subSTATES['mr'] = $this->_margeRight;
2451
-            $this->_subSTATES['mt'] = $this->_margeTop;
2452
-            $this->_subSTATES['mb'] = $this->_margeBottom;
2453
-            $this->_subSTATES['mp'] = $this->_pageMarges;
2454
-
2455
-            // new stat for the header
2456
-            $this->_pageMarges = array();
2457
-            $this->_margeLeft    = $this->_defaultLeft;
2458
-            $this->_margeRight   = $this->_defaultRight;
2459
-            $this->_margeTop     = $this->_defaultTop;
2460
-            $this->_margeBottom  = $this->_defaultBottom;
2461
-            $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight);
2462
-            $this->pdf->SetAutoPageBreak(false, $this->_margeBottom);
2463
-            $this->pdf->setXY($this->_defaultLeft, $this->_defaultTop);
2464
-
2465
-            $this->parsingCss->initStyle();
2466
-            $this->parsingCss->resetStyle();
2467
-            $this->parsingCss->value['width'] = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight;
2468
-            $this->parsingCss->table = array();
2469
-
2470
-            $this->parsingCss->save();
2471
-            $this->parsingCss->analyse('page_header_sub', $param);
2472
-            $this->parsingCss->setPosition();
2473
-            $this->parsingCss->fontSet();
2474
-            $this->_setNewPositionForNewLine();
2475
-            return true;
2476
-        }
2477
-
2478
-        /**
2479
-         * It is not a real tag. Does not use it directly
2480
-         *
2481
-         * @param  array $param
2482
-         * @return boolean
2483
-         */
2484
-        protected function _tag_close_PAGE_HEADER_SUB($param)
2485
-        {
2486
-            if ($this->_isForOneLine) return false;
2487
-
2488
-            $this->parsingCss->load();
2489
-
2490
-            // restore the stat
2491
-            $this->parsingCss->value = $this->_subSTATES['s'];
2492
-            $this->parsingCss->table = $this->_subSTATES['t'];
2493
-            $this->_pageMarges       = $this->_subSTATES['mp'];
2494
-            $this->_margeLeft        = $this->_subSTATES['ml'];
2495
-            $this->_margeRight       = $this->_subSTATES['mr'];
2496
-            $this->_margeTop         = $this->_subSTATES['mt'];
2497
-            $this->_margeBottom      = $this->_subSTATES['mb'];
2498
-            $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight);
2499
-            $this->pdf->setbMargin($this->_margeBottom);
2500
-            $this->pdf->SetAutoPageBreak(false, $this->_margeBottom);
2501
-            $this->pdf->setXY($this->_subSTATES['x'], $this->_subSTATES['y']);
2502
-
2503
-            $this->parsingCss->fontSet();
2504
-            $this->_maxH = 0;
2505
-
2506
-            return true;
2507
-        }
2508
-
2509
-        /**
2510
-         * It is not a real tag. Does not use it directly
2511
-         *
2512
-         * @param  array $param
2513
-         * @return boolean
2514
-         */
2515
-        protected function _tag_open_PAGE_FOOTER_SUB($param)
2516
-        {
2517
-            if ($this->_isForOneLine) return false;
2518
-
2519
-            // save the current stat
2520
-            $this->_subSTATES = array();
2521
-            $this->_subSTATES['x']    = $this->pdf->getX();
2522
-            $this->_subSTATES['y']    = $this->pdf->getY();
2523
-            $this->_subSTATES['s']    = $this->parsingCss->value;
2524
-            $this->_subSTATES['t']    = $this->parsingCss->table;
2525
-            $this->_subSTATES['ml']    = $this->_margeLeft;
2526
-            $this->_subSTATES['mr']    = $this->_margeRight;
2527
-            $this->_subSTATES['mt']    = $this->_margeTop;
2528
-            $this->_subSTATES['mb']    = $this->_margeBottom;
2529
-            $this->_subSTATES['mp']    = $this->_pageMarges;
2530
-
2531
-            // new stat for the footer
2532
-            $this->_pageMarges  = array();
2533
-            $this->_margeLeft   = $this->_defaultLeft;
2534
-            $this->_margeRight  = $this->_defaultRight;
2535
-            $this->_margeTop    = $this->_defaultTop;
2536
-            $this->_margeBottom = $this->_defaultBottom;
2537
-            $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight);
2538
-            $this->pdf->SetAutoPageBreak(false, $this->_margeBottom);
2539
-            $this->pdf->setXY($this->_defaultLeft, $this->_defaultTop);
2540
-
2541
-            $this->parsingCss->initStyle();
2542
-            $this->parsingCss->resetStyle();
2543
-            $this->parsingCss->value['width']    = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight;
2544
-            $this->parsingCss->table                = array();
2545
-
2546
-            // we create a sub HTML2PFDF, and we execute on it the content of the footer, to get the height of it
2547
-            $sub = null;
2548
-            $this->_createSubHTML($sub);
2549
-            $sub->parsingHtml->code = $this->parsingHtml->getLevel($this->_parsePos);
2550
-            $sub->_makeHTMLcode();
2551
-            $this->pdf->setY($this->pdf->getH() - $sub->_maxY - $this->_defaultBottom - 0.01);
2552
-            $this->_destroySubHTML($sub);
2553
-
2554
-            $this->parsingCss->save();
2555
-            $this->parsingCss->analyse('page_footer_sub', $param);
2556
-            $this->parsingCss->setPosition();
2557
-            $this->parsingCss->fontSet();
2558
-            $this->_setNewPositionForNewLine();
2559
-
2560
-            return true;
2561
-        }
2562
-
2563
-        /**
2564
-         * It is not a real tag. Does not use it directly
2565
-         *
2566
-         * @param  array $param
2567
-         * @return boolean
2568
-         */
2569
-        protected function _tag_close_PAGE_FOOTER_SUB($param)
2570
-        {
2571
-            if ($this->_isForOneLine) return false;
2572
-
2573
-            $this->parsingCss->load();
2574
-
2575
-            $this->parsingCss->value                = $this->_subSTATES['s'];
2576
-            $this->parsingCss->table                = $this->_subSTATES['t'];
2577
-            $this->_pageMarges                 = $this->_subSTATES['mp'];
2578
-            $this->_margeLeft                = $this->_subSTATES['ml'];
2579
-            $this->_margeRight                = $this->_subSTATES['mr'];
2580
-            $this->_margeTop                    = $this->_subSTATES['mt'];
2581
-            $this->_margeBottom                = $this->_subSTATES['mb'];
2582
-            $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight);
2583
-            $this->pdf->SetAutoPageBreak(false, $this->_margeBottom);
2584
-            $this->pdf->setXY($this->_subSTATES['x'], $this->_subSTATES['y']);
2585
-
2586
-            $this->parsingCss->fontSet();
2587
-            $this->_maxH = 0;
2588
-
2589
-            return true;
2590
-        }
2591
-
2592
-        /**
2593
-         * tag : NOBREAK
2594
-         * mode : OPEN
2595
-         *
2596
-         * @param  array $param
2597
-         * @return boolean
2598
-         */
2599
-        protected function _tag_open_NOBREAK($param)
2600
-        {
2601
-            if ($this->_isForOneLine) return false;
2602
-
2603
-            $this->_maxH = 0;
2604
-
2605
-            // create a sub HTML2PDF to execute the content of the tag, to get the dimensions
2606
-            $sub = null;
2607
-            $this->_createSubHTML($sub);
2608
-            $sub->parsingHtml->code = $this->parsingHtml->getLevel($this->_parsePos);
2609
-            $sub->_makeHTMLcode();
2610
-            $y = $this->pdf->getY();
2611
-
2612
-            // if the content does not fit on the page => new page
2613
-            if (
2614
-                $sub->_maxY < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin()) &&
2615
-                $y + $sub->_maxY>=($this->pdf->getH() - $this->pdf->getbMargin())
2616
-            ) {
2617
-                $this->_setNewPage();
2618
-            }
2619
-
2620
-            // destroy the sub HTML2PDF
2621
-            $this->_destroySubHTML($sub);
2622
-
2623
-            return true;
2624
-        }
2625
-
2626
-
2627
-        /**
2628
-         * tag : NOBREAK
2629
-         * mode : CLOSE
2630
-         *
2631
-         * @param  array $param
2632
-         * @return boolean
2633
-         */
2634
-        protected function _tag_close_NOBREAK($param)
2635
-        {
2636
-            if ($this->_isForOneLine) return false;
2637
-
2638
-            $this->_maxH = 0;
2639
-
2640
-            return true;
2641
-        }
2642
-
2643
-        /**
2644
-         * tag : DIV
2645
-         * mode : OPEN
2646
-         *
2647
-         * @param  array $param
2648
-         * @param  string $other name of tag that used the div tag
2649
-         * @return boolean
2650
-         */
2651
-        protected function _tag_open_DIV($param, $other = 'div')
2652
-        {
2653
-            if ($this->_isForOneLine) return false;
2654
-            if ($this->_debugActif) $this->_DEBUG_add(strtoupper($other), true);
2655
-
2656
-            $this->parsingCss->save();
2657
-            $this->parsingCss->analyse($other, $param);
2658
-            $this->parsingCss->fontSet();
2659
-
2660
-            // for fieldset and legend
2661
-            if (in_array($other, array('fieldset', 'legend'))) {
2662
-                if (isset($param['moveTop']))  $this->parsingCss->value['margin']['t']    += $param['moveTop'];
2663
-                if (isset($param['moveLeft'])) $this->parsingCss->value['margin']['l']    += $param['moveLeft'];
2664
-                if (isset($param['moveDown'])) $this->parsingCss->value['margin']['b']    += $param['moveDown'];
2665
-            }
2666
-
2667
-            $alignObject = null;
2668
-            if ($this->parsingCss->value['margin-auto']) $alignObject = 'center';
2669
-
2670
-            $marge = array();
2671
-            $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
2672
-            $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03;
2673
-            $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03;
2674
-            $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03;
2675
-
2676
-            // extract the content of the div
2677
-            $level = $this->parsingHtml->getLevel($this->_parsePos);
2678
-
2679
-            // create a sub HTML2PDF to get the dimensions of the content of the div
2680
-            $w = 0; $h = 0;
2681
-            if (count($level)) {
2682
-                $sub = null;
2683
-                $this->_createSubHTML($sub);
2684
-                $sub->parsingHtml->code = $level;
2685
-                $sub->_makeHTMLcode();
2686
-                $w = $sub->_maxX;
2687
-                $h = $sub->_maxY;
2688
-                $this->_destroySubHTML($sub);
2689
-            }
2690
-            $wReel = $w;
2691
-            $hReel = $h;
2692
-
2693
-            $w+= $marge['l']+$marge['r']+0.001;
2694
-            $h+= $marge['t']+$marge['b']+0.001;
2695
-
2696
-            if ($this->parsingCss->value['overflow']=='hidden') {
2697
-                $overW = max($w, $this->parsingCss->value['width']);
2698
-                $overH = max($h, $this->parsingCss->value['height']);
2699
-                $overflow = true;
2700
-                $this->parsingCss->value['old_maxX'] = $this->_maxX;
2701
-                $this->parsingCss->value['old_maxY'] = $this->_maxY;
2702
-                $this->parsingCss->value['old_maxH'] = $this->_maxH;
2703
-                $this->parsingCss->value['old_overflow'] = $this->_isInOverflow;
2704
-                $this->_isInOverflow = true;
2705
-            } else {
2706
-                $overW = null;
2707
-                $overH = null;
2708
-                $overflow = false;
2709
-                $this->parsingCss->value['width']    = max($w, $this->parsingCss->value['width']);
2710
-                $this->parsingCss->value['height']    = max($h, $this->parsingCss->value['height']);
2711
-            }
2712
-
2713
-            switch($this->parsingCss->value['rotate'])
2714
-            {
2715
-                case 90:
2716
-                    $tmp = $overH; $overH = $overW; $overW = $tmp;
2717
-                    $tmp = $hReel; $hReel = $wReel; $wReel = $tmp;
2718
-                    unset($tmp);
2719
-                    $w = $this->parsingCss->value['height'];
2720
-                    $h = $this->parsingCss->value['width'];
2721
-                    $tX =-$h;
2722
-                    $tY = 0;
2723
-                    break;
2724
-
2725
-                case 180:
2726
-                    $w = $this->parsingCss->value['width'];
2727
-                    $h = $this->parsingCss->value['height'];
2728
-                    $tX = -$w;
2729
-                    $tY = -$h;
2730
-                    break;
2731
-
2732
-                case 270:
2733
-                    $tmp = $overH; $overH = $overW; $overW = $tmp;
2734
-                    $tmp = $hReel; $hReel = $wReel; $wReel = $tmp;
2735
-                    unset($tmp);
2736
-                    $w = $this->parsingCss->value['height'];
2737
-                    $h = $this->parsingCss->value['width'];
2738
-                    $tX = 0;
2739
-                    $tY =-$w;
2740
-                    break;
2741
-
2742
-                default:
2743
-                    $w = $this->parsingCss->value['width'];
2744
-                    $h = $this->parsingCss->value['height'];
2745
-                    $tX = 0;
2746
-                    $tY = 0;
2747
-                    break;
2748
-            }
2749
-
2750
-            if (!$this->parsingCss->value['position']) {
2751
-                if (
2752
-                    $w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) &&
2753
-                    $this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin())
2754
-                    )
2755
-                    $this->_tag_open_BR(array());
2756
-
2757
-                if (
2758
-                        ($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) &&
2759
-                        ($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) &&
2760
-                        !$this->_isInOverflow
2761
-                    )
2762
-                    $this->_setNewPage();
2763
-
2764
-                $old = $this->parsingCss->getOldValues();
2765
-                $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
2766
-
2767
-                if ($parentWidth>$w) {
2768
-                    if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
2769
-                    else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
2770
-                }
2771
-
2772
-                $this->parsingCss->setPosition();
2773
-            } else {
2774
-                $old = $this->parsingCss->getOldValues();
2775
-                $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
2776
-
2777
-                if ($parentWidth>$w) {
2778
-                    if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
2779
-                    else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
2780
-                }
2781
-
2782
-                $this->parsingCss->setPosition();
2783
-                $this->_saveMax();
2784
-                $this->_maxX = 0;
2785
-                $this->_maxY = 0;
2786
-                $this->_maxH = 0;
2787
-                $this->_maxE = 0;
2788
-            }
2789
-
2790
-            if ($this->parsingCss->value['rotate']) {
2791
-                $this->pdf->startTransform();
2792
-                $this->pdf->setRotation($this->parsingCss->value['rotate']);
2793
-                $this->pdf->setTranslate($tX, $tY);
2794
-            }
2795
-
2796
-            $this->_drawRectangle(
2797
-                $this->parsingCss->value['x'],
2798
-                $this->parsingCss->value['y'],
2799
-                $this->parsingCss->value['width'],
2800
-                $this->parsingCss->value['height'],
2801
-                $this->parsingCss->value['border'],
2802
-                $this->parsingCss->value['padding'],
2803
-                0,
2804
-                $this->parsingCss->value['background']
2805
-            );
2806
-
2807
-            $marge = array();
2808
-            $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
2809
-            $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03;
2810
-            $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03;
2811
-            $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03;
2812
-
2813
-            $this->parsingCss->value['width'] -= $marge['l']+$marge['r'];
2814
-            $this->parsingCss->value['height']-= $marge['t']+$marge['b'];
2815
-
2816
-            $xCorr = 0;
2817
-            $yCorr = 0;
2818
-            if (!$this->_subPart && !$this->_isSubPart) {
2819
-                switch($this->parsingCss->value['text-align'])
2820
-                {
2821
-                    case 'right':
2822
-                        $xCorr = ($this->parsingCss->value['width']-$wReel);
2823
-                        break;
2824
-                    case 'center':
2825
-                        $xCorr = ($this->parsingCss->value['width']-$wReel)*0.5;
2826
-                        break;
2827
-                }
2828
-                if ($xCorr>0) $xCorr=0;
2829
-                switch($this->parsingCss->value['vertical-align'])
2830
-                {
2831
-                    case 'bottom':
2832
-                        $yCorr = ($this->parsingCss->value['height']-$hReel);
2833
-                        break;
2834
-                    case 'middle':
2835
-                        $yCorr = ($this->parsingCss->value['height']-$hReel)*0.5;
2836
-                        break;
2837
-                }
2838
-            }
2839
-
2840
-            if ($overflow) {
2841
-                $overW-= $marge['l']+$marge['r'];
2842
-                $overH-= $marge['t']+$marge['b'];
2843
-                $this->pdf->clippingPathStart(
2844
-                    $this->parsingCss->value['x']+$marge['l'],
2845
-                    $this->parsingCss->value['y']+$marge['t'],
2846
-                    $this->parsingCss->value['width'],
2847
-                    $this->parsingCss->value['height']
2848
-                );
2849
-
2850
-                $this->parsingCss->value['x']+= $xCorr;
2851
-
2852
-                // marges from the dimension of the content
2853
-                $mL = $this->parsingCss->value['x']+$marge['l'];
2854
-                $mR = $this->pdf->getW() - $mL - $overW;
2855
-            } else {
2856
-                // marges from the dimension of the div
2857
-                $mL = $this->parsingCss->value['x']+$marge['l'];
2858
-                $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width'];
2859
-            }
2860
-
2861
-            $x = $this->parsingCss->value['x']+$marge['l'];
2862
-            $y = $this->parsingCss->value['y']+$marge['t']+$yCorr;
2863
-            $this->_saveMargin($mL, 0, $mR);
2864
-            $this->pdf->setXY($x, $y);
2865
-
2866
-            $this->_setNewPositionForNewLine();
2867
-
2868
-            return true;
2869
-        }
2870
-
2871
-        /**
2872
-         * tag : BLOCKQUOTE
2873
-         * mode : OPEN
2874
-         *
2875
-         * @param  array $param
2876
-         * @return boolean
2877
-         */
2878
-        protected function _tag_open_BLOCKQUOTE($param)
2879
-        {
2880
-            return $this->_tag_open_DIV($param, 'blockquote');
2881
-        }
2882
-
2883
-        /**
2884
-         * tag : LEGEND
2885
-         * mode : OPEN
2886
-         *
2887
-         * @param  array $param
2888
-         * @return boolean
2889
-         */
2890
-        protected function _tag_open_LEGEND($param)
2891
-        {
2892
-            return $this->_tag_open_DIV($param, 'legend');
2893
-        }
2894
-
2895
-        /**
2896
-         * tag : FIELDSET
2897
-         * mode : OPEN
2898
-         *
2899
-         * @author Pavel Kochman
2900
-         * @param  array $param
2901
-         * @return boolean
2902
-         */
2903
-        protected function _tag_open_FIELDSET($param)
2904
-        {
2905
-
2906
-            $this->parsingCss->save();
2907
-            $this->parsingCss->analyse('fieldset', $param);
2908
-
2909
-            // get height of LEGEND element and make fieldset corrections
2910
-            for ($tempPos = $this->_parsePos + 1; $tempPos<count($this->parsingHtml->code); $tempPos++) {
2911
-                $action = $this->parsingHtml->code[$tempPos];
2912
-                if ($action['name'] == 'fieldset') break;
2913
-                if ($action['name'] == 'legend' && !$action['close']) {
2914
-                    $legendOpenPos = $tempPos;
2915
-
2916
-                    $sub = null;
2917
-                    $this->_createSubHTML($sub);
2918
-                    $sub->parsingHtml->code = $this->parsingHtml->getLevel($tempPos - 1);
2919
-
2920
-                    $res = null;
2921
-                    for ($sub->_parsePos = 0; $sub->_parsePos<count($sub->parsingHtml->code); $sub->_parsePos++) {
2922
-                        $action = $sub->parsingHtml->code[$sub->_parsePos];
2923
-                        $sub->_executeAction($action);
2924
-
2925
-                        if ($action['name'] == 'legend' && $action['close'])
2926
-                            break;
2927
-                    }
2928
-
2929
-                    $legendH = $sub->_maxY;
2930
-                    $this->_destroySubHTML($sub);
2931
-
2932
-                    $move = $this->parsingCss->value['padding']['t'] + $this->parsingCss->value['border']['t']['width'] + 0.03;
2933
-
2934
-                    $param['moveTop'] = $legendH / 2;
2935
-
2936
-                    $this->parsingHtml->code[$legendOpenPos]['param']['moveTop'] = - ($legendH / 2 + $move);
2937
-                    $this->parsingHtml->code[$legendOpenPos]['param']['moveLeft'] = 2 - $this->parsingCss->value['border']['l']['width'] - $this->parsingCss->value['padding']['l'];
2938
-                    $this->parsingHtml->code[$legendOpenPos]['param']['moveDown'] = $move;
2939
-                    break;
2940
-                }
2941
-            }
2942
-            $this->parsingCss->load();
2943
-
2944
-            return $this->_tag_open_DIV($param, 'fieldset');
2945
-        }
2946
-
2947
-        /**
2948
-         * tag : DIV
2949
-         * mode : CLOSE
2950
-         *
2951
-         * @param  array $param
2952
-         * @param  string $other name of tag that used the div tag
2953
-         * @return boolean
2954
-         */
2955
-        protected function _tag_close_DIV($param, $other='div')
2956
-        {
2957
-            if ($this->_isForOneLine) return false;
2958
-
2959
-            if ($this->parsingCss->value['overflow']=='hidden') {
2960
-                $this->_maxX = $this->parsingCss->value['old_maxX'];
2961
-                $this->_maxY = $this->parsingCss->value['old_maxY'];
2962
-                $this->_maxH = $this->parsingCss->value['old_maxH'];
2963
-                $this->_isInOverflow = $this->parsingCss->value['old_overflow'];
2964
-                $this->pdf->clippingPathStop();
2965
-            }
2966
-
2967
-            if ($this->parsingCss->value['rotate'])
2968
-                $this->pdf->stopTransform();
2969
-
2970
-            $marge = array();
2971
-            $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
2972
-            $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03;
2973
-            $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03;
2974
-            $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03;
2975
-
2976
-            $x = $this->parsingCss->value['x'];
2977
-            $y = $this->parsingCss->value['y'];
2978
-            $w = $this->parsingCss->value['width']+$marge['l']+$marge['r']+$this->parsingCss->value['margin']['r'];
2979
-            $h = $this->parsingCss->value['height']+$marge['t']+$marge['b']+$this->parsingCss->value['margin']['b'];
2980
-
2981
-            switch($this->parsingCss->value['rotate'])
2982
-            {
2983
-                case 90:
2984
-                    $t = $w; $w = $h; $h = $t;
2985
-                    break;
2986
-
2987
-                case 270:
2988
-                    $t = $w; $w = $h; $h = $t;
2989
-                    break;
2990
-
2991
-                default:
2992
-                    break;
2993
-            }
2994
-
2995
-
2996
-            if ($this->parsingCss->value['position']!='absolute') {
2997
-                $this->pdf->setXY($x+$w, $y);
2998
-
2999
-                $this->_maxX = max($this->_maxX, $x+$w);
3000
-                $this->_maxY = max($this->_maxY, $y+$h);
3001
-                $this->_maxH = max($this->_maxH, $h);
3002
-            } else {
3003
-                $this->pdf->setXY($this->parsingCss->value['xc'], $this->parsingCss->value['yc']);
3004
-
3005
-                $this->_loadMax();
3006
-            }
3007
-
3008
-            $block = ($this->parsingCss->value['display']!='inline' && $this->parsingCss->value['position']!='absolute');
3009
-
3010
-            $this->parsingCss->load();
3011
-            $this->parsingCss->fontSet();
3012
-            $this->_loadMargin();
3013
-
3014
-            if ($block) $this->_tag_open_BR(array());
3015
-            if ($this->_debugActif) $this->_DEBUG_add(strtoupper($other), false);
3016
-
3017
-            return true;
3018
-        }
3019
-
3020
-        /**
3021
-         * tag : BLOCKQUOTE
3022
-         * mode : CLOSE
3023
-         *
3024
-         * @param  array $param
3025
-         * @return boolean
3026
-         */
3027
-        protected function _tag_close_BLOCKQUOTE($param)
3028
-        {
3029
-            return $this->_tag_close_DIV($param, 'blockquote');
3030
-        }
3031
-
3032
-        /**
3033
-         * tag : FIELDSET
3034
-         * mode : CLOSE
3035
-         *
3036
-         * @param  array $param
3037
-         * @return boolean
3038
-         */
3039
-        protected function _tag_close_FIELDSET($param)
3040
-        {
3041
-            return $this->_tag_close_DIV($param, 'fieldset');
3042
-        }
3043
-
3044
-        /**
3045
-         * tag : LEGEND
3046
-         * mode : CLOSE
3047
-         *
3048
-         * @param  array $param
3049
-         * @return boolean
3050
-         */
3051
-        protected function _tag_close_LEGEND($param)
3052
-        {
3053
-            return $this->_tag_close_DIV($param, 'legend');
3054
-        }
3055
-
3056
-        /**
3057
-         * tag : BARCODE
3058
-         * mode : OPEN
3059
-         *
3060
-         * @param  array $param
3061
-         * @return boolean
3062
-         */
3063
-        protected function _tag_open_BARCODE($param)
3064
-        {
3065
-            // for  compatibility with old versions < 3.29
3066
-            $lstBarcode = array();
3067
-            $lstBarcode['UPC_A']  =    'UPCA';
3068
-            $lstBarcode['CODE39'] =    'C39';
3069
-
3070
-            if (!isset($param['type']))     $param['type'] = 'C39';
3071
-            if (!isset($param['value']))    $param['value']    = 0;
3072
-            if (!isset($param['label']))    $param['label']    = 'label';
3073
-            if (!isset($param['style']['color'])) $param['style']['color'] = '#000000';
3074
-
3075
-            if ($this->_testIsDeprecated && (isset($param['bar_h']) || isset($param['bar_w'])))
3076
-                throw new HTML2PDF_exception(9, array('BARCODE', 'bar_h, bar_w'));
3077
-
3078
-            $param['type'] = strtoupper($param['type']);
3079
-            if (isset($lstBarcode[$param['type']])) $param['type'] = $lstBarcode[$param['type']];
3080
-
3081
-            $this->parsingCss->save();
3082
-            $this->parsingCss->analyse('barcode', $param);
3083
-            $this->parsingCss->setPosition();
3084
-            $this->parsingCss->fontSet();
3085
-
3086
-            $x = $this->pdf->getX();
3087
-            $y = $this->pdf->getY();
3088
-            $w = $this->parsingCss->value['width'];    if (!$w) $w = $this->parsingCss->ConvertToMM('50mm');
3089
-            $h = $this->parsingCss->value['height'];    if (!$h) $h = $this->parsingCss->ConvertToMM('10mm');
3090
-            $txt = ($param['label']!=='none' ? $this->parsingCss->value['font-size'] : false);
3091
-            $c = $this->parsingCss->value['color'];
3092
-            $infos = $this->pdf->myBarcode($param['value'], $param['type'], $x, $y, $w, $h, $txt, $c);
3093
-
3094
-            $this->_maxX = max($this->_maxX, $x+$infos[0]);
3095
-            $this->_maxY = max($this->_maxY, $y+$infos[1]);
3096
-            $this->_maxH = max($this->_maxH, $infos[1]);
3097
-            $this->_maxE++;
3098
-
3099
-            $this->pdf->setXY($x+$infos[0], $y);
3100
-
3101
-            $this->parsingCss->load();
3102
-            $this->parsingCss->fontSet();
3103
-
3104
-            return true;
3105
-        }
3106
-
3107
-        /**
3108
-         * tag : BARCODE
3109
-         * mode : CLOSE
3110
-         *
3111
-         * @param  array $param
3112
-         * @return boolean
3113
-         */
3114
-        protected function _tag_close_BARCODE($param)
3115
-        {
3116
-            // there is nothing to do here
3117
-
3118
-            return true;
3119
-        }
3120
-
3121
-        /**
3122
-         * tag : QRCODE
3123
-         * mode : OPEN
3124
-         *
3125
-         * @param  array $param
3126
-         * @return boolean
3127
-         */
3128
-        protected function _tag_open_QRCODE($param)
3129
-        {
3130
-            if ($this->_testIsDeprecated && (isset($param['size']) || isset($param['noborder'])))
3131
-                throw new HTML2PDF_exception(9, array('QRCODE', 'size, noborder'));
3132
-
3133
-            if ($this->_debugActif) $this->_DEBUG_add('QRCODE');
3134
-
3135
-            if (!isset($param['value']))                     $param['value'] = '';
3136
-            if (!isset($param['ec']))                        $param['ec'] = 'H';
3137
-            if (!isset($param['style']['color']))            $param['style']['color'] = '#000000';
3138
-            if (!isset($param['style']['background-color'])) $param['style']['background-color'] = '#FFFFFF';
3139
-            if (isset($param['style']['border'])) {
3140
-                $borders = $param['style']['border']!='none';
3141
-                unset($param['style']['border']);
3142
-            } else {
3143
-                $borders = true;
3144
-            }
3145
-
3146
-            if ($param['value']==='') return true;
3147
-            if (!in_array($param['ec'], array('L', 'M', 'Q', 'H'))) $param['ec'] = 'H';
3148
-
3149
-            $this->parsingCss->save();
3150
-            $this->parsingCss->analyse('qrcode', $param);
3151
-            $this->parsingCss->setPosition();
3152
-            $this->parsingCss->fontSet();
3153
-
3154
-            $x = $this->pdf->getX();
3155
-            $y = $this->pdf->getY();
3156
-            $w = $this->parsingCss->value['width'];
3157
-            $h = $this->parsingCss->value['height'];
3158
-            $size = max($w, $h); if (!$size) $size = $this->parsingCss->ConvertToMM('50mm');
3159
-
3160
-            $style = array(
3161
-                    'fgcolor' => $this->parsingCss->value['color'],
3162
-                    'bgcolor' => $this->parsingCss->value['background']['color'],
3163
-                );
3164
-
3165
-            if ($borders) {
3166
-                $style['border'] = true;
3167
-                $style['padding'] = 'auto';
3168
-            } else {
3169
-                $style['border'] = false;
3170
-                $style['padding'] = 0;
3171
-            }
3172
-
3173
-            if (!$this->_subPart && !$this->_isSubPart) {
3174
-                $this->pdf->write2DBarcode($param['value'], 'QRCODE,'.$param['ec'], $x, $y, $size, $size, $style);
3175
-            }
3176
-
3177
-            $this->_maxX = max($this->_maxX, $x+$size);
3178
-            $this->_maxY = max($this->_maxY, $y+$size);
3179
-            $this->_maxH = max($this->_maxH, $size);
3180
-            $this->_maxE++;
3181
-
3182
-            $this->pdf->setX($x+$size);
3183
-
3184
-            $this->parsingCss->load();
3185
-            $this->parsingCss->fontSet();
3186
-
3187
-            return true;
3188
-        }
3189
-
3190
-        /**
3191
-         * tag : QRCODE
3192
-         * mode : CLOSE
3193
-         *
3194
-         * @param  array $param
3195
-         * @return boolean
3196
-         */
3197
-        protected function _tag_close_QRCODE($param)
3198
-        {
3199
-            // there is nothing to do here
3200
-
3201
-            return true;
3202
-        }
3203
-
3204
-        /**
3205
-         * tag : BOOKMARK
3206
-         * mode : OPEN
3207
-         *
3208
-         * @param  array $param
3209
-         * @return boolean
3210
-         */
3211
-        protected function _tag_open_BOOKMARK($param)
3212
-        {
3213
-            $titre = isset($param['title']) ? trim($param['title']) : '';
3214
-            $level = isset($param['level']) ? floor($param['level']) : 0;
3215
-
3216
-            if ($level<0) $level = 0;
3217
-            if ($titre) $this->pdf->Bookmark($titre, $level, -1);
3218
-
3219
-            return true;
3220
-        }
3221
-
3222
-        /**
3223
-         * tag : BOOKMARK
3224
-         * mode : CLOSE
3225
-         *
3226
-         * @param  array $param
3227
-         * @return boolean
3228
-         */
3229
-        protected function _tag_close_BOOKMARK($param)
3230
-        {
3231
-            // there is nothing to do here
3232
-
3233
-            return true;
3234
-        }
3235
-
3236
-        /**
3237
-         * this is not a real TAG, it is just to write texts
3238
-         *
3239
-         * @param  array $param
3240
-         * @return boolean
3241
-         */
3242
-        protected function _tag_open_WRITE($param)
3243
-        {
3244
-            $fill = ($this->parsingCss->value['background']['color']!==null && $this->parsingCss->value['background']['image']===null);
3245
-            if (in_array($this->parsingCss->value['id_tag'], array('fieldset', 'legend', 'div', 'table', 'tr', 'td', 'th'))) {
3246
-                $fill = false;
3247
-            }
3248
-
3249
-            // get the text to write
3250
-            $txt = $param['txt'];
3251
-
3252
-            if ($this->_isAfterFloat) {
3253
-                $txt = ltrim($txt);
3254
-                $this->_isAfterFloat = false;
3255
-            }
3256
-
3257
-            $txt = str_replace('[[page_nb]]', $this->pdf->getMyAliasNbPages(), $txt);
3258
-            $txt = str_replace('[[page_cu]]', $this->pdf->getMyNumPage($this->_page), $txt);
3259
-
3260
-            if ($this->parsingCss->value['text-transform']!='none') {
3261
-                if ($this->parsingCss->value['text-transform']=='capitalize')
3262
-                    $txt = ucwords($txt);
3263
-                else if ($this->parsingCss->value['text-transform']=='uppercase')
3264
-                    $txt = strtoupper($txt);
3265
-                else if ($this->parsingCss->value['text-transform']=='lowercase')
3266
-                    $txt = strtolower($txt);
3267
-            }
3268
-
3269
-            // size of the text
3270
-            $h  = 1.08*$this->parsingCss->value['font-size'];
3271
-            $dh = $h*$this->parsingCss->value['mini-decal'];
3272
-            $lh = $this->parsingCss->getLineHeight();
3273
-
3274
-            // identify the align
3275
-            $align = 'L';
3276
-            if ($this->parsingCss->value['text-align']=='li_right') {
3277
-                $w = $this->parsingCss->value['width'];
3278
-                $align = 'R';
3279
-            }
3280
-
3281
-            // calculate the width of each words, and of all the sentence
3282
-            $w = 0;
3283
-            $words = explode(' ', $txt);
3284
-            foreach ($words as $k => $word) {
3285
-                $words[$k] = array($word, $this->pdf->GetStringWidth($word));
3286
-                $w+= $words[$k][1];
3287
-            }
3288
-            $space = $this->pdf->GetStringWidth(' ');
3289
-            $w+= $space*(count($words)-1);
3290
-
3291
-            // position in the text
3292
-            $currPos = 0;
3293
-
3294
-            // the bigger width of the text, after automatic break line
3295
-            $maxX = 0;
3296
-
3297
-            // position of the text
3298
-            $x = $this->pdf->getX();
3299
-            $y = $this->pdf->getY();
3300
-            $dy = $this->_getElementY($lh);
3301
-
3302
-            // margins
3303
-            list($left, $right) = $this->_getMargins($y);
3304
-
3305
-            // number of lines after automatic break line
3306
-            $nb = 0;
3307
-
3308
-            // while we have words, and the text does not fit on the line => we cut the sentence
3309
-            while ($x+$w>$right && $x<$right+$space && count($words)) {
3310
-                // adding words 1 by 1 to fit on the line
3311
-                $i=0;
3312
-                $old = array('', 0);
3313
-                $str = $words[0];
3314
-                $add = false;
3315
-                while (($x+$str[1])<$right) {
3316
-                    $i++;
3317
-                    $add = true;
3318
-
3319
-                    array_shift($words);
3320
-                    $old = $str;
3321
-
3322
-                    if (!count($words)) break;
3323
-                    $str[0].= ' '.$words[0][0];
3324
-                    $str[1]+= $space+$words[0][1];
3325
-                }
3326
-                $str = $old;
3327
-
3328
-                // if  nothing fit on the line, and if the first word does not fit on the line => the word is too long, we put it
3329
-                if ($i==0 && (($left+$words[0][1])>=$right)) {
3330
-                    $str = $words[0];
3331
-                    array_shift($words);
3332
-                    $i++;
3333
-                    $add = true;
3334
-                }
3335
-                $currPos+= ($currPos ? 1 : 0)+strlen($str[0]);
3336
-
3337
-                // write the extract sentence that fit on the page
3338
-                $wc = ($align=='L' ? $str[1] : $this->parsingCss->value['width']);
3339
-                if ($right - $left<$wc) $wc = $right - $left;
3340
-
3341
-                if (strlen($str[0])) {
3342
-                    $this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy);
3343
-                    $this->pdf->Cell($wc, $h, $str[0], 0, 0, $align, $fill, $this->_isInLink);
3344
-                    $this->pdf->setXY($this->pdf->getX(), $y);
3345
-                }
3346
-                $this->_maxH = max($this->_maxH, $lh);
3347
-
3348
-                // max width
3349
-                $maxX = max($maxX, $this->pdf->getX());
3350
-
3351
-                // new position and new width for the "while"
3352
-                $w-= $str[1];
3353
-                $y = $this->pdf->getY();
3354
-                $x = $this->pdf->getX();
3355
-                $dy = $this->_getElementY($lh);
3356
-
3357
-                // if we have again words to write
3358
-                if (count($words)) {
3359
-                    // remove the space at the end
3360
-                    if ($add) $w-= $space;
3361
-
3362
-                    // if we don't add any word, and if the first word is empty => useless space to skip
3363
-                    if (!$add && $words[0][0]==='') {
3364
-                        array_shift($words);
3365
-                    }
3366
-
3367
-                    // if it is just to calculate for one line => adding the number of words
3368
-                    if ($this->_isForOneLine) {
3369
-                        $this->_maxE+= $i;
3370
-                        $this->_maxX = max($this->_maxX, $maxX);
3371
-                        return null;
3372
-                    }
3373
-
3374
-                    // automatic line break
3375
-                    $this->_tag_open_BR(array('style' => ''), $currPos);
3376
-
3377
-                    // new position
3378
-                    $y = $this->pdf->getY();
3379
-                    $x = $this->pdf->getX();
3380
-                    $dy = $this->_getElementY($lh);
3381
-
3382
-                    // if the next line does  not fit on the page => new page
3383
-                    if ($y + $h>=$this->pdf->getH() - $this->pdf->getbMargin()) {
3384
-                        if (!$this->_isInOverflow && !$this->_isInFooter) {
3385
-                            $this->_setNewPage(null, '', null, $currPos);
3386
-                            $y = $this->pdf->getY();
3387
-                            $x = $this->pdf->getX();
3388
-                            $dy = $this->_getElementY($lh);
3389
-                        }
3390
-                    }
3391
-
3392
-                    // if more than 10000 line => error
3393
-                    $nb++;
3394
-                    if ($nb>10000) {
3395
-                        $txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0];
3396
-                        throw new HTML2PDF_exception(2, array($txt, $right-$left, $w));
3397
-                    }
3398
-
3399
-                    // new margins for the new line
3400
-                    list($left, $right) = $this->_getMargins($y);
3401
-                }
3402
-            }
3403
-
3404
-            // if we have words after automatic cut, it is because they fit on the line => we write the text
3405
-            if (count($words)) {
3406
-                $txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0];
3407
-                $w+= $this->pdf->getWordSpacing()*(count($words));
3408
-                $this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy);
3409
-                $this->pdf->Cell(($align=='L' ? $w : $this->parsingCss->value['width']), $h, $txt, 0, 0, $align, $fill, $this->_isInLink);
3410
-                $this->pdf->setXY($this->pdf->getX(), $y);
3411
-                $this->_maxH = max($this->_maxH, $lh);
3412
-                $this->_maxE+= count($words);
3413
-            }
3414
-
3415
-            $maxX = max($maxX, $this->pdf->getX());
3416
-            $maxY = $this->pdf->getY()+$h;
3417
-
3418
-            $this->_maxX = max($this->_maxX, $maxX);
3419
-            $this->_maxY = max($this->_maxY, $maxY);
3420
-
3421
-            return true;
3422
-        }
3423
-
3424
-        /**
3425
-         * tag : BR
3426
-         * mode : OPEN
3427
-         *
3428
-         * @param  array   $param
3429
-         * @param  integer $curr real position in the html parseur (if break line in the write of a text)
3430
-         * @return boolean
3431
-         */
3432
-        protected function _tag_open_BR($param, $curr = null)
3433
-        {
3434
-            if ($this->_isForOneLine) return false;
3435
-
3436
-            $h = max($this->_maxH, $this->parsingCss->getLineHeight());
3437
-
3438
-            if ($this->_maxH==0) $this->_maxY = max($this->_maxY, $this->pdf->getY()+$h);
3439
-
3440
-            $this->_makeBreakLine($h, $curr);
3441
-
3442
-            $this->_maxH = 0;
3443
-            $this->_maxE = 0;
3444
-
3445
-            return true;
3446
-        }
3447
-
3448
-        /**
3449
-         * tag : HR
3450
-         * mode : OPEN
3451
-         *
3452
-         * @param  array $param
3453
-         * @return boolean
3454
-         */
3455
-        protected function _tag_open_HR($param)
3456
-        {
3457
-            if ($this->_isForOneLine) return false;
3458
-            $oldAlign = $this->parsingCss->value['text-align'];
3459
-            $this->parsingCss->value['text-align'] = 'left';
3460
-
3461
-            if ($this->_maxH) $this->_tag_open_BR($param);
3462
-
3463
-            $fontSize = $this->parsingCss->value['font-size'];
3464
-            $this->parsingCss->value['font-size']=$fontSize*0.5; $this->_tag_open_BR($param);
3465
-            $this->parsingCss->value['font-size']=0;
3466
-
3467
-            $param['style']['width'] = '100%';
3468
-
3469
-            $this->parsingCss->save();
3470
-            $this->parsingCss->value['height']=$this->parsingCss->ConvertToMM('1mm');
3471
-
3472
-            $this->parsingCss->analyse('hr', $param);
3473
-            $this->parsingCss->setPosition();
3474
-            $this->parsingCss->fontSet();
3475
-
3476
-            $h = $this->parsingCss->value['height'];
3477
-            if ($h)    $h-= $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width'];
3478
-            if ($h<=0) $h = $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width'];
3479
-
3480
-            $this->_drawRectangle($this->pdf->getX(), $this->pdf->getY(), $this->parsingCss->value['width'], $h, $this->parsingCss->value['border'], 0, 0, $this->parsingCss->value['background']);
3481
-            $this->_maxH = $h;
3482
-
3483
-            $this->parsingCss->load();
3484
-            $this->parsingCss->fontSet();
3485
-
3486
-            $this->_tag_open_BR($param);
3487
-
3488
-            $this->parsingCss->value['font-size']=$fontSize*0.5; $this->_tag_open_BR($param);
3489
-            $this->parsingCss->value['font-size']=$fontSize;
3490
-
3491
-            $this->parsingCss->value['text-align'] = $oldAlign;
3492
-            $this->_setNewPositionForNewLine();
3493
-
3494
-            return true;
3495
-        }
3496
-
3497
-        /**
3498
-         * tag : B
3499
-         * mode : OPEN
3500
-         *
3501
-         * @param  array $param
3502
-         * @param  string $other
3503
-         * @return boolean
3504
-         */
3505
-        protected function _tag_open_B($param, $other = 'b')
3506
-        {
3507
-            $this->parsingCss->save();
3508
-            $this->parsingCss->value['font-bold'] = true;
3509
-            $this->parsingCss->analyse($other, $param);
3510
-            $this->parsingCss->setPosition();
3511
-            $this->parsingCss->fontSet();
3512
-
3513
-            return true;
3514
-        }
3515
-
3516
-        /**
3517
-         * tag : STRONG
3518
-         * mode : OPEN
3519
-         *
3520
-         * @param  array $param
3521
-         * @return boolean
3522
-         */
3523
-        protected function _tag_open_STRONG($param)
3524
-        {
3525
-            return $this->_tag_open_B($param, 'strong');
3526
-        }
3527
-
3528
-        /**
3529
-         * tag : B
3530
-         * mode : CLOSE
3531
-         *
3532
-         * @param    array $param
3533
-         * @return boolean
3534
-         */
3535
-        protected function _tag_close_B($param)
3536
-        {
3537
-            $this->parsingCss->load();
3538
-            $this->parsingCss->fontSet();
3539
-
3540
-            return true;
3541
-        }
3542
-
3543
-        /**
3544
-         * tag : STRONG
3545
-         * mode : CLOSE
3546
-         *
3547
-         * @param  array $param
3548
-         * @return boolean
3549
-         */
3550
-        protected function _tag_close_STRONG($param)
3551
-        {
3552
-            return $this->_tag_close_B($param);
3553
-        }
3554
-
3555
-        /**
3556
-         * tag : I
3557
-         * mode : OPEN
3558
-         *
3559
-         * @param  array $param
3560
-         * @param  string $other
3561
-         * @return boolean
3562
-         */
3563
-        protected function _tag_open_I($param, $other = 'i')
3564
-        {
3565
-            $this->parsingCss->save();
3566
-            $this->parsingCss->value['font-italic'] = true;
3567
-            $this->parsingCss->analyse($other, $param);
3568
-            $this->parsingCss->setPosition();
3569
-            $this->parsingCss->fontSet();
3570
-
3571
-            return true;
3572
-        }
3573
-
3574
-        /**
3575
-         * tag : ADDRESS
3576
-         * mode : OPEN
3577
-         *
3578
-         * @param  array $param
3579
-         * @return boolean
3580
-         */
3581
-        protected function _tag_open_ADDRESS($param)
3582
-        {
3583
-            return $this->_tag_open_I($param, 'address');
3584
-        }
3585
-
3586
-        /**
3587
-         * tag : CITE
3588
-         * mode : OPEN
3589
-         *
3590
-         * @param  array $param
3591
-         * @return boolean
3592
-         */
3593
-        protected function _tag_open_CITE($param)
3594
-        {
3595
-            return $this->_tag_open_I($param, 'cite');
3596
-        }
3597
-
3598
-        /**
3599
-         * tag : EM
3600
-         * mode : OPEN
3601
-         *
3602
-         * @param  array $param
3603
-         * @return boolean
3604
-         */
3605
-        protected function _tag_open_EM($param)
3606
-        {
3607
-            return $this->_tag_open_I($param, 'em');
3608
-        }
3609
-
3610
-        /**
3611
-         * tag : SAMP
3612
-         * mode : OPEN
3613
-         *
3614
-         * @param  array $param
3615
-         * @return boolean
3616
-         */
3617
-        protected function _tag_open_SAMP($param)
3618
-        {
3619
-            return $this->_tag_open_I($param, 'samp');
3620
-        }
3621
-
3622
-        /**
3623
-         * tag : I
3624
-         * mode : CLOSE
3625
-         *
3626
-         * @param  array $param
3627
-         * @return boolean
3628
-         */
3629
-        protected function _tag_close_I($param)
3630
-        {
3631
-            $this->parsingCss->load();
3632
-            $this->parsingCss->fontSet();
3633
-
3634
-            return true;
3635
-        }
3636
-
3637
-        /**
3638
-         * tag : ADDRESS
3639
-         * mode : CLOSE
3640
-         *
3641
-         * @param  array $param
3642
-         * @return boolean
3643
-         */
3644
-        protected function _tag_close_ADDRESS($param)
3645
-        {
3646
-            return $this->_tag_close_I($param);
3647
-        }
3648
-
3649
-        /**
3650
-         * tag : CITE
3651
-         * mode : CLOSE
3652
-         *
3653
-         * @param  array $param
3654
-         * @return boolean
3655
-         */
3656
-        protected function _tag_close_CITE($param)
3657
-        {
3658
-            return $this->_tag_close_I($param);
3659
-        }
3660
-
3661
-        /**
3662
-         * tag : EM
3663
-         * mode : CLOSE
3664
-         *
3665
-         * @param  array $param
3666
-         * @return boolean
3667
-         */
3668
-        protected function _tag_close_EM($param)
3669
-        {
3670
-            return $this->_tag_close_I($param);
3671
-        }
3672
-
3673
-        /**
3674
-         * tag : SAMP
3675
-         * mode : CLOSE
3676
-         *
3677
-         * @param  array $param
3678
-         * @return boolean
3679
-         */
3680
-        protected function _tag_close_SAMP($param)
3681
-        {
3682
-            return $this->_tag_close_I($param);
3683
-        }
3684
-
3685
-        /**
3686
-         * tag : S
3687
-         * mode : OPEN
3688
-         *
3689
-         * @param  array $param
3690
-         * @param  string $other
3691
-         * @return boolean
3692
-         */
3693
-        protected function _tag_open_S($param, $other = 's')
3694
-        {
3695
-            $this->parsingCss->save();
3696
-            $this->parsingCss->value['font-linethrough'] = true;
3697
-            $this->parsingCss->analyse($other, $param);
3698
-            $this->parsingCss->setPosition();
3699
-            $this->parsingCss->fontSet();
3700
-
3701
-            return true;
3702
-        }
3703
-
3704
-        /**
3705
-         * tag : DEL
3706
-         * mode : OPEN
3707
-         *
3708
-         * @param  array $param
3709
-         * @return boolean
3710
-         */
3711
-        protected function _tag_open_DEL($param)
3712
-        {
3713
-            return $this->_tag_open_S($param, 'del');
3714
-        }
3715
-
3716
-        /**
3717
-         * tag : S
3718
-         * mode : CLOSE
3719
-         *
3720
-         * @param    array $param
3721
-         * @return boolean
3722
-         */
3723
-        protected function _tag_close_S($param)
3724
-        {
3725
-            $this->parsingCss->load();
3726
-            $this->parsingCss->fontSet();
3727
-
3728
-            return true;
3729
-        }
3730
-
3731
-        /**
3732
-         * tag : DEL
3733
-         * mode : CLOSE
3734
-         *
3735
-         * @param  array $param
3736
-         * @return boolean
3737
-         */
3738
-        protected function _tag_close_DEL($param)
3739
-        {
3740
-            return $this->_tag_close_S($param);
3741
-        }
3742
-
3743
-        /**
3744
-         * tag : U
3745
-         * mode : OPEN
3746
-         *
3747
-         * @param  array $param
3748
-         * @param  string $other
3749
-         * @return boolean
3750
-         */
3751
-        protected function _tag_open_U($param, $other='u')
3752
-        {
3753
-            $this->parsingCss->save();
3754
-            $this->parsingCss->value['font-underline'] = true;
3755
-            $this->parsingCss->analyse($other, $param);
3756
-            $this->parsingCss->setPosition();
3757
-            $this->parsingCss->fontSet();
3758
-
3759
-            return true;
3760
-        }
3761
-
3762
-        /**
3763
-         * tag : INS
3764
-         * mode : OPEN
3765
-         *
3766
-         * @param  array $param
3767
-         * @return boolean
3768
-         */
3769
-        protected function _tag_open_INS($param)
3770
-        {
3771
-            return $this->_tag_open_U($param, 'ins');
3772
-        }
3773
-
3774
-        /**
3775
-         * tag : U
3776
-         * mode : CLOSE
3777
-         *
3778
-         * @param    array $param
3779
-         * @return boolean
3780
-         */
3781
-        protected function _tag_close_U($param)
3782
-        {
3783
-            $this->parsingCss->load();
3784
-            $this->parsingCss->fontSet();
3785
-
3786
-            return true;
3787
-        }
3788
-
3789
-        /**
3790
-         * tag : INS
3791
-         * mode : CLOSE
3792
-         *
3793
-         * @param  array $param
3794
-         * @return boolean
3795
-         */
3796
-        protected function _tag_close_INS($param)
3797
-        {
3798
-            return $this->_tag_close_U($param);
3799
-        }
3800
-
3801
-        /**
3802
-         * tag : A
3803
-         * mode : OPEN
3804
-         *
3805
-         * @param  array $param
3806
-         * @return boolean
3807
-         */
3808
-        protected function _tag_open_A($param)
3809
-        {
3810
-            $this->_isInLink = str_replace('&amp;', '&', isset($param['href']) ? $param['href'] : '');
3811
-
3812
-            if (isset($param['name'])) {
3813
-                $name =     $param['name'];
3814
-                if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false);
3815
-
3816
-                if (!$this->_lstAnchor[$name][1]) {
3817
-                    $this->_lstAnchor[$name][1] = true;
3818
-                    $this->pdf->SetLink($this->_lstAnchor[$name][0], -1, -1);
3819
-                }
3820
-            }
3821
-
3822
-            if (preg_match('/^#([^#]+)$/isU', $this->_isInLink, $match)) {
3823
-                $name = $match[1];
3824
-                if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false);
3825
-
3826
-                $this->_isInLink = $this->_lstAnchor[$name][0];
3827
-            }
3828
-
3829
-            $this->parsingCss->save();
3830
-            $this->parsingCss->value['font-underline'] = true;
3831
-            $this->parsingCss->value['color'] = array(20, 20, 250);
3832
-            $this->parsingCss->analyse('a', $param);
3833
-            $this->parsingCss->setPosition();
3834
-            $this->parsingCss->fontSet();
3835
-
3836
-            return true;
3837
-        }
3838
-
3839
-        /**
3840
-         * tag : A
3841
-         * mode : CLOSE
3842
-         *
3843
-         * @param  array $param
3844
-         * @return boolean
3845
-         */
3846
-        protected function _tag_close_A($param)
3847
-        {
3848
-            $this->_isInLink    = '';
3849
-            $this->parsingCss->load();
3850
-            $this->parsingCss->fontSet();
3851
-
3852
-            return true;
3853
-        }
3854
-
3855
-        /**
3856
-         * tag : H1
3857
-         * mode : OPEN
3858
-         *
3859
-         * @param  array $param
3860
-         * @param  string $other
3861
-         * @return boolean
3862
-         */
3863
-        protected function _tag_open_H1($param, $other = 'h1')
3864
-        {
3865
-            if ($this->_isForOneLine) return false;
3866
-
3867
-            if ($this->_maxH) $this->_tag_open_BR(array());
3868
-            $this->parsingCss->save();
3869
-            $this->parsingCss->value['font-bold'] = true;
3870
-
3871
-            $size = array('h1' => '28px', 'h2' => '24px', 'h3' => '20px', 'h4' => '16px', 'h5' => '12px', 'h6' => '9px');
3872
-            $this->parsingCss->value['margin']['l'] = 0;
3873
-            $this->parsingCss->value['margin']['r'] = 0;
3874
-            $this->parsingCss->value['margin']['t'] = $this->parsingCss->ConvertToMM('16px');
3875
-            $this->parsingCss->value['margin']['b'] = $this->parsingCss->ConvertToMM('16px');
3876
-            $this->parsingCss->value['font-size'] = $this->parsingCss->ConvertToMM($size[$other]);
3877
-
3878
-            $this->parsingCss->analyse($other, $param);
3879
-            $this->parsingCss->setPosition();
3880
-            $this->parsingCss->fontSet();
3881
-            $this->_setNewPositionForNewLine();
3882
-
3883
-            return true;
3884
-        }
3885
-
3886
-        /**
3887
-         * tag : H2
3888
-         * mode : OPEN
3889
-         *
3890
-         * @param  array $param
3891
-         * @return boolean
3892
-         */
3893
-        protected function _tag_open_H2($param)
3894
-        {
3895
-            return $this->_tag_open_H1($param, 'h2');
3896
-        }
3897
-
3898
-        /**
3899
-         * tag : H3
3900
-         * mode : OPEN
3901
-         *
3902
-         * @param  array $param
3903
-         * @return boolean
3904
-         */
3905
-        protected function _tag_open_H3($param)
3906
-        {
3907
-            return $this->_tag_open_H1($param, 'h3');
3908
-        }
3909
-
3910
-        /**
3911
-         * tag : H4
3912
-         * mode : OPEN
3913
-         *
3914
-         * @param  array $param
3915
-         * @return boolean
3916
-         */
3917
-        protected function _tag_open_H4($param)
3918
-        {
3919
-            return $this->_tag_open_H1($param, 'h4');
3920
-        }
3921
-
3922
-        /**
3923
-         * tag : H5
3924
-         * mode : OPEN
3925
-         *
3926
-         * @param  array $param
3927
-         * @return boolean
3928
-         */
3929
-        protected function _tag_open_H5($param)
3930
-        {
3931
-            return $this->_tag_open_H1($param, 'h5');
3932
-        }
3933
-
3934
-        /**
3935
-         * tag : H6
3936
-         * mode : OPEN
3937
-         *
3938
-         * @param  array $param
3939
-         * @return boolean
3940
-         */
3941
-        protected function _tag_open_H6($param)
3942
-        {
3943
-            return $this->_tag_open_H1($param, 'h6');
3944
-        }
3945
-
3946
-        /**
3947
-         * tag : H1
3948
-         * mode : CLOSE
3949
-         *
3950
-         * @param  array $param
3951
-         * @return boolean
3952
-         */
3953
-        protected function _tag_close_H1($param)
3954
-        {
3955
-            if ($this->_isForOneLine) return false;
3956
-
3957
-            $this->_maxH+= $this->parsingCss->value['margin']['b'];
3958
-            $h = max($this->_maxH, $this->parsingCss->getLineHeight());
3959
-
3960
-            $this->parsingCss->load();
3961
-            $this->parsingCss->fontSet();
3962
-
3963
-            $this->_makeBreakLine($h);
3964
-            $this->_maxH = 0;
3965
-
3966
-            $this->_maxY = max($this->_maxY, $this->pdf->getY());
3967
-
3968
-            return true;
3969
-        }
3970
-
3971
-        /**
3972
-         * tag : H2
3973
-         * mode : CLOSE
3974
-         *
3975
-         * @param  array $param
3976
-         * @return boolean
3977
-         */
3978
-        protected function _tag_close_H2($param)
3979
-        {
3980
-            return $this->_tag_close_H1($param);
3981
-        }
3982
-
3983
-        /**
3984
-         * tag : H3
3985
-         * mode : CLOSE
3986
-         *
3987
-         * @param  array $param
3988
-         * @return boolean
3989
-         */
3990
-        protected function _tag_close_H3($param)
3991
-        {
3992
-            return $this->_tag_close_H1($param);
3993
-        }
3994
-
3995
-        /**
3996
-         * tag : H4
3997
-         * mode : CLOSE
3998
-         *
3999
-         * @param  array $param
4000
-         * @return boolean
4001
-         */
4002
-        protected function _tag_close_H4($param)
4003
-        {
4004
-            return $this->_tag_close_H1($param);
4005
-        }
4006
-
4007
-        /**
4008
-         * tag : H5
4009
-         * mode : CLOSE
4010
-         *
4011
-         * @param  array $param
4012
-         * @return boolean
4013
-         */
4014
-        protected function _tag_close_H5($param)
4015
-        {
4016
-            return $this->_tag_close_H1($param);
4017
-        }
4018
-
4019
-        /**
4020
-         * tag : H6
4021
-         * mode : CLOSE
4022
-         *
4023
-         * @param  array $param
4024
-         * @return boolean
4025
-         */
4026
-        protected function _tag_close_H6($param)
4027
-        {
4028
-            return $this->_tag_close_H1($param);
4029
-        }
4030
-
4031
-        /**
4032
-         * tag : SPAN
4033
-         * mode : OPEN
4034
-         *
4035
-         * @param  array $param
4036
-         * @param  string $other
4037
-         * @return boolean
4038
-         */
4039
-        protected function _tag_open_SPAN($param, $other = 'span')
4040
-        {
4041
-            $this->parsingCss->save();
4042
-            $this->parsingCss->analyse($other, $param);
4043
-            $this->parsingCss->setPosition();
4044
-            $this->parsingCss->fontSet();
4045
-
4046
-            return true;
4047
-        }
4048
-
4049
-        /**
4050
-         * tag : FONT
4051
-         * mode : OPEN
4052
-         *
4053
-         * @param  array $param
4054
-         * @return boolean
4055
-         */
4056
-        protected function _tag_open_FONT($param)
4057
-        {
4058
-            return $this->_tag_open_SPAN($param, 'font');
4059
-        }
4060
-
4061
-        /**
4062
-         * tag : LABEL
4063
-         * mode : OPEN
4064
-         *
4065
-         * @param  array $param
4066
-         * @return boolean
4067
-         */
4068
-        protected function _tag_open_LABEL($param)
4069
-        {
4070
-            return $this->_tag_open_SPAN($param, 'label');
4071
-        }
4072
-
4073
-        /**
4074
-         * tag : SPAN
4075
-         * mode : CLOSE
4076
-         *
4077
-         * @param  array $param
4078
-         * @return boolean
4079
-         */
4080
-        protected function _tag_close_SPAN($param)
4081
-        {
4082
-            $this->parsingCss->restorePosition();
4083
-            $this->parsingCss->load();
4084
-            $this->parsingCss->fontSet();
4085
-
4086
-            return true;
4087
-        }
4088
-
4089
-        /**
4090
-         * tag : FONT
4091
-         * mode : CLOSE
4092
-         *
4093
-         * @param  array $param
4094
-         * @return boolean
4095
-         */
4096
-        protected function _tag_close_FONT($param)
4097
-        {
4098
-            return $this->_tag_close_SPAN($param);
4099
-        }
4100
-
4101
-        /**
4102
-         * tag : LABEL
4103
-         * mode : CLOSE
4104
-         *
4105
-         * @param  array $param
4106
-         * @return boolean
4107
-         */
4108
-        protected function _tag_close_LABEL($param)
4109
-        {
4110
-            return $this->_tag_close_SPAN($param);
4111
-        }
4112
-
4113
-        /**
4114
-         * tag : P
4115
-         * mode : OPEN
4116
-         *
4117
-         * @param    array $param
4118
-         * @return boolean
4119
-         */
4120
-        protected function _tag_open_P($param)
4121
-        {
4122
-            if ($this->_isForOneLine) return false;
4123
-
4124
-            if (!in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) {
4125
-                if ($this->_maxH) $this->_tag_open_BR(array());
4126
-            }
4127
-
4128
-            $this->parsingCss->save();
4129
-            $this->parsingCss->analyse('p', $param);
4130
-            $this->parsingCss->setPosition();
4131
-            $this->parsingCss->fontSet();
4132
-
4133
-             // cancel the effects of the setPosition
4134
-            $this->pdf->setXY($this->pdf->getX()-$this->parsingCss->value['margin']['l'], $this->pdf->getY()-$this->parsingCss->value['margin']['t']);
4135
-
4136
-            list($mL, $mR) = $this->_getMargins($this->pdf->getY());
4137
-            $mR = $this->pdf->getW()-$mR;
4138
-            $mL+= $this->parsingCss->value['margin']['l']+$this->parsingCss->value['padding']['l'];
4139
-            $mR+= $this->parsingCss->value['margin']['r']+$this->parsingCss->value['padding']['r'];
4140
-            $this->_saveMargin($mL, 0, $mR);
4141
-
4142
-            if ($this->parsingCss->value['text-indent']>0) {
4143
-                $y = $this->pdf->getY()+$this->parsingCss->value['margin']['t']+$this->parsingCss->value['padding']['t'];
4144
-                $this->_pageMarges[floor($y*100)] = array($mL+$this->parsingCss->value['text-indent'], $this->pdf->getW()-$mR);
4145
-                $y+= $this->parsingCss->getLineHeight()*0.1;
4146
-                $this->_pageMarges[floor($y*100)] = array($mL, $this->pdf->getW()-$mR);
4147
-            }
4148
-            $this->_makeBreakLine($this->parsingCss->value['margin']['t']+$this->parsingCss->value['padding']['t']);
4149
-            $this->_isInParagraph = array($mL, $mR);
4150
-            return true;
4151
-        }
4152
-
4153
-        /**
4154
-         * tag : P
4155
-         * mode : CLOSE
4156
-         *
4157
-         * @param  array $param
4158
-         * @return boolean
4159
-         */
4160
-        protected function _tag_close_P($param)
4161
-        {
4162
-            if ($this->_isForOneLine) return false;
4163
-
4164
-            if ($this->_maxH) $this->_tag_open_BR(array());
4165
-            $this->_isInParagraph = false;
4166
-            $this->_loadMargin();
4167
-            $h = $this->parsingCss->value['margin']['b']+$this->parsingCss->value['padding']['b'];
4168
-
4169
-            $this->parsingCss->load();
4170
-            $this->parsingCss->fontSet();
4171
-            $this->_makeBreakLine($h);
4172
-
4173
-            return true;
4174
-        }
4175
-
4176
-        /**
4177
-         * tag : PRE
4178
-         * mode : OPEN
4179
-         *
4180
-         * @param  array $param
4181
-         * @param  string $other
4182
-         * @return boolean
4183
-         */
4184
-        protected function _tag_open_PRE($param, $other = 'pre')
4185
-        {
4186
-            if ($other=='pre' && $this->_maxH) $this->_tag_open_BR(array());
4187
-
4188
-            $this->parsingCss->save();
4189
-            $this->parsingCss->value['font-family'] = 'courier';
4190
-            $this->parsingCss->analyse($other, $param);
4191
-            $this->parsingCss->setPosition();
4192
-            $this->parsingCss->fontSet();
4193
-
4194
-            if ($other=='pre') return $this->_tag_open_DIV($param, $other);
4195
-
4196
-            return true;
4197
-        }
4198
-
4199
-        /**
4200
-         * tag : CODE
4201
-         * mode : OPEN
4202
-         *
4203
-         * @param  array $param
4204
-         * @param  string $other
4205
-         * @return boolean
4206
-         */
4207
-        protected function _tag_open_CODE($param)
4208
-        {
4209
-            return $this->_tag_open_PRE($param, 'code');
4210
-        }
4211
-
4212
-        /**
4213
-         * tag : PRE
4214
-         * mode : CLOSE
4215
-         *
4216
-         * @param  array $param
4217
-         * @param  string $other
4218
-         * @return boolean
4219
-         */
4220
-        protected function _tag_close_PRE($param, $other = 'pre')
4221
-        {
4222
-            if ($other=='pre') {
4223
-                if ($this->_isForOneLine) return false;
4224
-
4225
-                $this->_tag_close_DIV($param, $other);
4226
-                $this->_tag_open_BR(array());
4227
-            }
4228
-            $this->parsingCss->load();
4229
-            $this->parsingCss->fontSet();
4230
-
4231
-            return true;
4232
-        }
4233
-
4234
-        /**
4235
-         * tag : CODE
4236
-         * mode : CLOSE
4237
-         *
4238
-         * @param  array $param
4239
-         * @return boolean
4240
-         */
4241
-        protected function _tag_close_CODE($param)
4242
-        {
4243
-            return $this->_tag_close_PRE($param, 'code');
4244
-        }
4245
-
4246
-        /**
4247
-         * tag : BIG
4248
-         * mode : OPEN
4249
-         *
4250
-         * @param    array $param
4251
-         * @return boolean
4252
-         */
4253
-        protected function _tag_open_BIG($param)
4254
-        {
4255
-            $this->parsingCss->save();
4256
-            $this->parsingCss->value['mini-decal']-= $this->parsingCss->value['mini-size']*0.12;
4257
-            $this->parsingCss->value['mini-size'] *= 1.2;
4258
-            $this->parsingCss->analyse('big', $param);
4259
-            $this->parsingCss->setPosition();
4260
-            $this->parsingCss->fontSet();
4261
-            return true;
4262
-        }
4263
-
4264
-        /**
4265
-         * tag : BIG
4266
-         * mode : CLOSE
4267
-         *
4268
-         * @param    array $param
4269
-         * @return boolean
4270
-         */
4271
-        protected function _tag_close_BIG($param)
4272
-        {
4273
-            $this->parsingCss->load();
4274
-            $this->parsingCss->fontSet();
4275
-
4276
-            return true;
4277
-        }
4278
-
4279
-        /**
4280
-         * tag : SMALL
4281
-         * mode : OPEN
4282
-         *
4283
-         * @param    array $param
4284
-         * @return boolean
4285
-         */
4286
-        protected function _tag_open_SMALL($param)
4287
-        {
4288
-            $this->parsingCss->save();
4289
-            $this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.05;
4290
-            $this->parsingCss->value['mini-size'] *= 0.82;
4291
-            $this->parsingCss->analyse('small', $param);
4292
-            $this->parsingCss->setPosition();
4293
-            $this->parsingCss->fontSet();
4294
-            return true;
4295
-        }
4296
-
4297
-        /**
4298
-         * tag : SMALL
4299
-         * mode : CLOSE
4300
-         *
4301
-         * @param    array $param
4302
-         * @return boolean
4303
-         */
4304
-        protected function _tag_close_SMALL($param)
4305
-        {
4306
-            $this->parsingCss->load();
4307
-            $this->parsingCss->fontSet();
4308
-
4309
-            return true;
4310
-        }
4311
-
4312
-        /**
4313
-         * tag : SUP
4314
-         * mode : OPEN
4315
-         *
4316
-         * @param    array $param
4317
-         * @return boolean
4318
-         */
4319
-        protected function _tag_open_SUP($param)
4320
-        {
4321
-            $this->parsingCss->save();
4322
-            $this->parsingCss->value['mini-decal']-= $this->parsingCss->value['mini-size']*0.15;
4323
-            $this->parsingCss->value['mini-size'] *= 0.75;
4324
-            $this->parsingCss->analyse('sup', $param);
4325
-            $this->parsingCss->setPosition();
4326
-            $this->parsingCss->fontSet();
4327
-
4328
-            return true;
4329
-        }
4330
-
4331
-        /**
4332
-         * tag : SUP
4333
-         * mode : CLOSE
4334
-         *
4335
-         * @param    array $param
4336
-         * @return boolean
4337
-         */
4338
-        protected function _tag_close_SUP($param)
4339
-        {
4340
-            $this->parsingCss->load();
4341
-            $this->parsingCss->fontSet();
4342
-
4343
-            return true;
4344
-        }
4345
-
4346
-        /**
4347
-         * tag : SUB
4348
-         * mode : OPEN
4349
-         *
4350
-         * @param    array $param
4351
-         * @return boolean
4352
-         */
4353
-        protected function _tag_open_SUB($param)
4354
-        {
4355
-            $this->parsingCss->save();
4356
-            $this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.15;
4357
-            $this->parsingCss->value['mini-size'] *= 0.75;
4358
-            $this->parsingCss->analyse('sub', $param);
4359
-            $this->parsingCss->setPosition();
4360
-            $this->parsingCss->fontSet();
4361
-            return true;
4362
-        }
4363
-
4364
-        /**
4365
-         * tag : SUB
4366
-         * mode : CLOSE
4367
-         *
4368
-         * @param    array $param
4369
-         * @return boolean
4370
-         */
4371
-        protected function _tag_close_SUB($param)
4372
-        {
4373
-            $this->parsingCss->load();
4374
-            $this->parsingCss->fontSet();
4375
-
4376
-            return true;
4377
-        }
4378
-
4379
-        /**
4380
-         * tag : UL
4381
-         * mode : OPEN
4382
-         *
4383
-         * @param  array $param
4384
-         * @param  string $other
4385
-         * @return boolean
4386
-         */
4387
-        protected function _tag_open_UL($param, $other = 'ul')
4388
-        {
4389
-            if ($this->_isForOneLine) return false;
4390
-
4391
-            if (!in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) {
4392
-                if ($this->_maxH) $this->_tag_open_BR(array());
4393
-                if (!count($this->_defList)) $this->_tag_open_BR(array());
4394
-            }
4395
-
4396
-            if (!isset($param['style']['width'])) $param['allwidth'] = true;
4397
-            $param['cellspacing'] = 0;
4398
-
4399
-            // a list is like a table
4400
-            $this->_tag_open_TABLE($param, $other);
4401
-
4402
-            // add a level of list
4403
-            $this->_listeAddLevel($other, $this->parsingCss->value['list-style-type'], $this->parsingCss->value['list-style-image']);
4404
-
4405
-            return true;
4406
-        }
4407
-
4408
-        /**
4409
-         * tag : OL
4410
-         * mode : OPEN
4411
-         *
4412
-         * @param  array $param
4413
-         * @return boolean
4414
-         */
4415
-        protected function _tag_open_OL($param)
4416
-        {
4417
-            return $this->_tag_open_UL($param, 'ol');
4418
-        }
4419
-
4420
-        /**
4421
-         * tag : UL
4422
-         * mode : CLOSE
4423
-         *
4424
-         * @param  array $param
4425
-         * @return boolean
4426
-         */
4427
-        protected function _tag_close_UL($param)
4428
-        {
4429
-            if ($this->_isForOneLine) return false;
4430
-
4431
-            $this->_tag_close_TABLE($param);
4432
-
4433
-            $this->_listeDelLevel();
4434
-
4435
-            if (!$this->_subPart) {
4436
-                if (!count($this->_defList)) $this->_tag_open_BR(array());
4437
-            }
4438
-
4439
-            return true;
4440
-        }
4441
-
4442
-        /**
4443
-         * tag : OL
4444
-         * mode : CLOSE
4445
-         *
4446
-         * @param  array $param
4447
-         * @return boolean
4448
-         */
4449
-        protected function _tag_close_OL($param)
4450
-        {
4451
-            return $this->_tag_close_UL($param);
4452
-        }
4453
-
4454
-        /**
4455
-         * tag : LI
4456
-         * mode : OPEN
4457
-         *
4458
-         * @param  array $param
4459
-         * @return boolean
4460
-         */
4461
-        protected function _tag_open_LI($param)
4462
-        {
4463
-            if ($this->_isForOneLine) return false;
4464
-
4465
-            $this->_listeAddLi();
4466
-
4467
-            if (!isset($param['style']['width'])) $param['style']['width'] = '100%';
4468
-
4469
-            $paramPUCE = $param;
4470
-
4471
-            $inf = $this->_listeGetLi();
4472
-            if ($inf[0]) {
4473
-                $paramPUCE['style']['font-family']     = $inf[0];
4474
-                $paramPUCE['style']['text-align']      = 'li_right';
4475
-                $paramPUCE['style']['vertical-align']  = 'top';
4476
-                $paramPUCE['style']['width']           = $this->_listeGetWidth();
4477
-                $paramPUCE['style']['padding-right']   = $this->_listeGetPadding();
4478
-                $paramPUCE['txt'] = $inf[2];
4479
-            } else {
4480
-                $paramPUCE['style']['text-align']      = 'li_right';
4481
-                $paramPUCE['style']['vertical-align']  = 'top';
4482
-                $paramPUCE['style']['width']           = $this->_listeGetWidth();
4483
-                $paramPUCE['style']['padding-right']   = $this->_listeGetPadding();
4484
-                $paramPUCE['src'] = $inf[2];
4485
-                $paramPUCE['sub_li'] = true;
4486
-            }
4487
-
4488
-            $this->_tag_open_TR($param, 'li');
4489
-
4490
-            $this->parsingCss->save();
4491
-
4492
-            // if small LI
4493
-            if ($inf[1]) {
4494
-                $this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.045;
4495
-                $this->parsingCss->value['mini-size'] *= 0.75;
4496
-            }
4497
-
4498
-            // if we are in a sub html => prepare. Else : display
4499
-            if ($this->_subPart) {
4500
-                // TD for the puce
4501
-                $tmpPos = $this->_tempPos;
4502
-                $tmpLst1 = $this->parsingHtml->code[$tmpPos+1];
4503
-                $tmpLst2 = $this->parsingHtml->code[$tmpPos+2];
4504
-                $this->parsingHtml->code[$tmpPos+1] = array();
4505
-                $this->parsingHtml->code[$tmpPos+1]['name']    = (isset($paramPUCE['src'])) ? 'img' : 'write';
4506
-                $this->parsingHtml->code[$tmpPos+1]['param']    = $paramPUCE; unset($this->parsingHtml->code[$tmpPos+1]['param']['style']['width']);
4507
-                $this->parsingHtml->code[$tmpPos+1]['close']    = 0;
4508
-                $this->parsingHtml->code[$tmpPos+2] = array();
4509
-                $this->parsingHtml->code[$tmpPos+2]['name']    = 'li';
4510
-                $this->parsingHtml->code[$tmpPos+2]['param']    = $paramPUCE;
4511
-                $this->parsingHtml->code[$tmpPos+2]['close']    = 1;
4512
-                $this->_tag_open_TD($paramPUCE, 'li_sub');
4513
-                $this->_tag_close_TD($param);
4514
-                $this->_tempPos = $tmpPos;
4515
-                $this->parsingHtml->code[$tmpPos+1] = $tmpLst1;
4516
-                $this->parsingHtml->code[$tmpPos+2] = $tmpLst2;
4517
-            } else {
4518
-                // TD for the puce
4519
-                $this->_tag_open_TD($paramPUCE, 'li_sub');
4520
-                unset($paramPUCE['style']['width']);
4521
-                if (isset($paramPUCE['src']))    $this->_tag_open_IMG($paramPUCE);
4522
-                else                            $this->_tag_open_WRITE($paramPUCE);
4523
-                $this->_tag_close_TD($paramPUCE);
4524
-            }
4525
-            $this->parsingCss->load();
4526
-
4527
-
4528
-            // TD for the content
4529
-            $this->_tag_open_TD($param, 'li');
4530
-
4531
-            return true;
4532
-        }
4533
-
4534
-        /**
4535
-         * tag : LI
4536
-         * mode : CLOSE
4537
-         *
4538
-         * @param  array $param
4539
-         * @return boolean
4540
-         */
4541
-        protected function _tag_close_LI($param)
4542
-        {
4543
-            if ($this->_isForOneLine) return false;
4544
-
4545
-            $this->_tag_close_TD($param);
4546
-
4547
-            $this->_tag_close_TR($param);
4548
-
4549
-            return true;
4550
-        }
4551
-
4552
-        /**
4553
-         * tag : TBODY
4554
-         * mode : OPEN
4555
-         *
4556
-         * @param  array $param
4557
-         * @return boolean
4558
-         */
4559
-        protected function _tag_open_TBODY($param)
4560
-        {
4561
-            if ($this->_isForOneLine) return false;
4562
-
4563
-            $this->parsingCss->save();
4564
-            $this->parsingCss->analyse('tbody', $param);
4565
-            $this->parsingCss->setPosition();
4566
-            $this->parsingCss->fontSet();
4567
-
4568
-            return true;
4569
-        }
4570
-
4571
-        /**
4572
-         * tag : TBODY
4573
-         * mode : CLOSE
4574
-         *
4575
-         * @param  array $param
4576
-         * @return boolean
4577
-         */
4578
-        protected function _tag_close_TBODY($param)
4579
-        {
4580
-            if ($this->_isForOneLine) return false;
4581
-
4582
-            $this->parsingCss->load();
4583
-            $this->parsingCss->fontSet();
4584
-
4585
-            return true;
4586
-        }
4587
-
4588
-        /**
4589
-         * tag : THEAD
4590
-         * mode : OPEN
4591
-         *
4592
-         * @param  array $param
4593
-         * @return boolean
4594
-         */
4595
-        protected function _tag_open_THEAD($param)
4596
-        {
4597
-            if ($this->_isForOneLine) return false;
4598
-
4599
-            $this->parsingCss->save();
4600
-            $this->parsingCss->analyse('thead', $param);
4601
-            $this->parsingCss->setPosition();
4602
-            $this->parsingCss->fontSet();
4603
-
4604
-            // if we are in a sub part, save the number of the first TR in the thead
4605
-            if ($this->_subPart) {
4606
-                HTML2PDF::$_tables[$param['num']]['thead']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr'];
4607
-                HTML2PDF::$_tables[$param['num']]['thead']['code'] = array();
4608
-                for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) {
4609
-                    $action = $this->parsingHtml->code[$pos];
4610
-                    if (strtolower($action['name'])=='thead') $action['name'] = 'thead_sub';
4611
-                    HTML2PDF::$_tables[$param['num']]['thead']['code'][] = $action;
4612
-                    if (strtolower($action['name'])=='thead_sub' && $action['close']) break;
4613
-                }
4614
-            } else {
4615
-                $level = $this->parsingHtml->getLevel($this->_parsePos);
4616
-                $this->_parsePos+= count($level);
4617
-                HTML2PDF::$_tables[$param['num']]['tr_curr']+= count(HTML2PDF::$_tables[$param['num']]['thead']['tr']);
4618
-            }
4619
-
4620
-            return true;
4621
-        }
4622
-
4623
-        /**
4624
-         * tag : THEAD
4625
-         * mode : CLOSE
4626
-         *
4627
-         * @param  array $param
4628
-         * @return boolean
4629
-         */
4630
-        protected function _tag_close_THEAD($param)
4631
-        {
4632
-            if ($this->_isForOneLine) return false;
4633
-
4634
-            $this->parsingCss->load();
4635
-            $this->parsingCss->fontSet();
4636
-
4637
-            // if we are in a sub HTM, construct the list of the TR in the thead
4638
-            if ($this->_subPart) {
4639
-                $min = HTML2PDF::$_tables[$param['num']]['thead']['tr'][0];
4640
-                $max = HTML2PDF::$_tables[$param['num']]['tr_curr']-1;
4641
-                HTML2PDF::$_tables[$param['num']]['thead']['tr'] = range($min, $max);
4642
-            }
4643
-
4644
-            return true;
4645
-        }
4646
-
4647
-        /**
4648
-         * tag : TFOOT
4649
-         * mode : OPEN
4650
-         *
4651
-         * @param  array $param
4652
-         * @return boolean
4653
-         */
4654
-        protected function _tag_open_TFOOT($param)
4655
-        {
4656
-            if ($this->_isForOneLine) return false;
4657
-
4658
-            $this->parsingCss->save();
4659
-            $this->parsingCss->analyse('tfoot', $param);
4660
-            $this->parsingCss->setPosition();
4661
-            $this->parsingCss->fontSet();
4662
-
4663
-            // if we are in a sub part, save the number of the first TR in the tfoot
4664
-            if ($this->_subPart) {
4665
-                HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr'];
4666
-                HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array();
4667
-                for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) {
4668
-                    $action = $this->parsingHtml->code[$pos];
4669
-                    if (strtolower($action['name'])=='tfoot') $action['name'] = 'tfoot_sub';
4670
-                    HTML2PDF::$_tables[$param['num']]['tfoot']['code'][] = $action;
4671
-                    if (strtolower($action['name'])=='tfoot_sub' && $action['close']) break;
4672
-                }
4673
-            } else {
4674
-                $level = $this->parsingHtml->getLevel($this->_parsePos);
4675
-                $this->_parsePos+= count($level);
4676
-                HTML2PDF::$_tables[$param['num']]['tr_curr']+= count(HTML2PDF::$_tables[$param['num']]['tfoot']['tr']);
4677
-            }
4678
-
4679
-            return true;
4680
-        }
4681
-
4682
-        /**
4683
-         * tag : TFOOT
4684
-         * mode : CLOSE
4685
-         *
4686
-         * @param  array $param
4687
-         * @return boolean
4688
-         */
4689
-        protected function _tag_close_TFOOT($param)
4690
-        {
4691
-            if ($this->_isForOneLine) return false;
4692
-
4693
-            $this->parsingCss->load();
4694
-            $this->parsingCss->fontSet();
4695
-
4696
-            // if we are in a sub HTM, construct the list of the TR in the tfoot
4697
-            if ($this->_subPart) {
4698
-                $min = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0];
4699
-                $max = HTML2PDF::$_tables[$param['num']]['tr_curr']-1;
4700
-                HTML2PDF::$_tables[$param['num']]['tfoot']['tr'] = range($min, $max);
4701
-            }
4702
-
4703
-            return true;
4704
-        }
4705
-
4706
-        /**
4707
-         * It is not a real TAG, does not use it !
4708
-         *
4709
-         * @param  array $param
4710
-         * @return boolean
4711
-         */
4712
-        protected function _tag_open_THEAD_SUB($param)
4713
-        {
4714
-            if ($this->_isForOneLine) return false;
4715
-
4716
-            $this->parsingCss->save();
4717
-            $this->parsingCss->analyse('thead', $param);
4718
-            $this->parsingCss->setPosition();
4719
-            $this->parsingCss->fontSet();
4720
-
4721
-            return true;
4722
-        }
4723
-
4724
-        /**
4725
-         * It is not a real TAG, does not use it !
4726
-         *
4727
-         * @param  array $param
4728
-         * @return boolean
4729
-         */
4730
-        protected function _tag_close_THEAD_SUB($param)
4731
-        {
4732
-            if ($this->_isForOneLine) return false;
4733
-
4734
-            $this->parsingCss->load();
4735
-            $this->parsingCss->fontSet();
4736
-
4737
-            return true;
4738
-        }
4739
-
4740
-        /**
4741
-         * It is not a real TAG, does not use it !
4742
-         *
4743
-         * @param    array $param
4744
-         * @return boolean
4745
-         */
4746
-        protected function _tag_open_TFOOT_SUB($param)
4747
-        {
4748
-            if ($this->_isForOneLine) return false;
4749
-
4750
-            $this->parsingCss->save();
4751
-            $this->parsingCss->analyse('tfoot', $param);
4752
-            $this->parsingCss->setPosition();
4753
-            $this->parsingCss->fontSet();
4754
-
4755
-            return true;
4756
-        }
4757
-
4758
-        /**
4759
-         * It is not a real TAG, does not use it !
4760
-         *
4761
-         * @param  array $param
4762
-         * @return boolean
4763
-         */
4764
-        protected function _tag_close_TFOOT_SUB($param)
4765
-        {
4766
-            if ($this->_isForOneLine) return false;
4767
-
4768
-            $this->parsingCss->load();
4769
-            $this->parsingCss->fontSet();
4770
-
4771
-            return true;
4772
-        }
4773
-
4774
-        /**
4775
-         * tag : FORM
4776
-         * mode : OPEN
4777
-         *
4778
-         * @param  array $param
4779
-         * @return boolean
4780
-         */
4781
-        protected function _tag_open_FORM($param)
4782
-        {
4783
-            $this->parsingCss->save();
4784
-            $this->parsingCss->analyse('form', $param);
4785
-            $this->parsingCss->setPosition();
4786
-            $this->parsingCss->fontSet();
4787
-
4788
-            $this->pdf->setFormDefaultProp(
4789
-                array(
4790
-                    'lineWidth'=>1,
4791
-                    'borderStyle'=>'solid',
4792
-                    'fillColor'=>array(220, 220, 255),
4793
-                    'strokeColor'=>array(128, 128, 200)
4794
-                )
4795
-            );
4796
-
4797
-            $this->_isInForm = isset($param['action']) ? $param['action'] : '';
4798
-
4799
-            return true;
4800
-        }
4801
-
4802
-        /**
4803
-         * tag : FORM
4804
-         * mode : CLOSE
4805
-         *
4806
-         * @param  array $param
4807
-         * @return boolean
4808
-         */
4809
-        protected function _tag_close_FORM($param)
4810
-        {
4811
-            $this->_isInForm = false;
4812
-            $this->parsingCss->load();
4813
-            $this->parsingCss->fontSet();
4814
-
4815
-            return true;
4816
-        }
4817
-
4818
-        /**
4819
-         * tag : TABLE
4820
-         * mode : OPEN
4821
-         *
4822
-         * @param  array $param
4823
-         * @return boolean
4824
-         */
4825
-        protected function _tag_open_TABLE($param, $other = 'table')
4826
-        {
4827
-            if ($this->_maxH) {
4828
-                if ($this->_isForOneLine) return false;
4829
-                $this->_tag_open_BR(array());
4830
-            }
4831
-
4832
-            if ($this->_isForOneLine) {
4833
-                $this->_maxX = $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
4834
-                return false;
4835
-            }
4836
-
4837
-            $this->_maxH = 0;
4838
-
4839
-            $alignObject = isset($param['align']) ? strtolower($param['align']) : 'left';
4840
-            if (isset($param['align'])) unset($param['align']);
4841
-            if (!in_array($alignObject, array('left', 'center', 'right'))) $alignObject = 'left';
4842
-
4843
-            $this->parsingCss->save();
4844
-            $this->parsingCss->analyse($other, $param);
4845
-            $this->parsingCss->setPosition();
4846
-            $this->parsingCss->fontSet();
4847
-
4848
-            if ($this->parsingCss->value['margin-auto']) $alignObject = 'center';
4849
-
4850
-            // collapse table ?
4851
-            $collapse = false;
4852
-            if ($other=='table') {
4853
-                $collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false;
4854
-            }
4855
-
4856
-            // if collapse => no borders for the table, only for TD
4857
-            if ($collapse) {
4858
-                $param['style']['border'] = 'none';
4859
-                $param['cellspacing'] = 0;
4860
-                $none = $this->parsingCss->readBorder('none');
4861
-                $this->parsingCss->value['border']['t'] = $none;
4862
-                $this->parsingCss->value['border']['r'] = $none;
4863
-                $this->parsingCss->value['border']['b'] = $none;
4864
-                $this->parsingCss->value['border']['l'] = $none;
4865
-            }
4866
-
4867
-            // if we are in a SUB html => prepare the properties of the table
4868
-            if ($this->_subPart) {
4869
-                if ($this->_debugActif) $this->_DEBUG_add('Table n'.$param['num'], true);
4870
-                HTML2PDF::$_tables[$param['num']] = array();
4871
-                HTML2PDF::$_tables[$param['num']]['border']          = isset($param['border']) ? $this->parsingCss->readBorder($param['border']) : null;
4872
-                HTML2PDF::$_tables[$param['num']]['cellpadding']     = $this->parsingCss->ConvertToMM(isset($param['cellpadding']) ? $param['cellpadding'] : '1px');
4873
-                HTML2PDF::$_tables[$param['num']]['cellspacing']     = $this->parsingCss->ConvertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
4874
-                HTML2PDF::$_tables[$param['num']]['cases']           = array();          // properties of each TR/TD
4875
-                HTML2PDF::$_tables[$param['num']]['corr']            = array();          // link between TR/TD and colspan/rowspan
4876
-                HTML2PDF::$_tables[$param['num']]['corr_x']          = 0;                // position in 'cases'
4877
-                HTML2PDF::$_tables[$param['num']]['corr_y']          = 0;                // position in 'cases'
4878
-                HTML2PDF::$_tables[$param['num']]['td_curr']         = 0;                // current column
4879
-                HTML2PDF::$_tables[$param['num']]['tr_curr']         = 0;                // current row
4880
-                HTML2PDF::$_tables[$param['num']]['curr_x']          = $this->pdf->getX();
4881
-                HTML2PDF::$_tables[$param['num']]['curr_y']          = $this->pdf->getY();
4882
-                HTML2PDF::$_tables[$param['num']]['width']           = 0;                // global width
4883
-                HTML2PDF::$_tables[$param['num']]['height']          = 0;                // global height
4884
-                HTML2PDF::$_tables[$param['num']]['align']           = $alignObject;
4885
-                HTML2PDF::$_tables[$param['num']]['marge']           = array();
4886
-                HTML2PDF::$_tables[$param['num']]['marge']['t']      = $this->parsingCss->value['padding']['t']+$this->parsingCss->value['border']['t']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5;
4887
-                HTML2PDF::$_tables[$param['num']]['marge']['r']      = $this->parsingCss->value['padding']['r']+$this->parsingCss->value['border']['r']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5;
4888
-                HTML2PDF::$_tables[$param['num']]['marge']['b']      = $this->parsingCss->value['padding']['b']+$this->parsingCss->value['border']['b']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5;
4889
-                HTML2PDF::$_tables[$param['num']]['marge']['l']      = $this->parsingCss->value['padding']['l']+$this->parsingCss->value['border']['l']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5;
4890
-                HTML2PDF::$_tables[$param['num']]['page']            = 0;                // number of pages
4891
-                HTML2PDF::$_tables[$param['num']]['new_page']        = true;             // flag : new page for the current TR
4892
-                HTML2PDF::$_tables[$param['num']]['style_value']     = null;             // CSS style of the table
4893
-                HTML2PDF::$_tables[$param['num']]['thead']           = array();          // properties on the thead
4894
-                HTML2PDF::$_tables[$param['num']]['tfoot']           = array();          // properties on the tfoot
4895
-                HTML2PDF::$_tables[$param['num']]['thead']['tr']     = array();          // list of the TRs in the thead
4896
-                HTML2PDF::$_tables[$param['num']]['tfoot']['tr']     = array();          // list of the TRs in the tfoot
4897
-                HTML2PDF::$_tables[$param['num']]['thead']['height']    = 0;             // thead height
4898
-                HTML2PDF::$_tables[$param['num']]['tfoot']['height']    = 0;             // tfoot height
4899
-                HTML2PDF::$_tables[$param['num']]['thead']['code'] = array();            // HTML content of the thead
4900
-                HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array();            // HTML content of the tfoot
4901
-                HTML2PDF::$_tables[$param['num']]['cols']        = array();              // properties of the COLs
4902
-
4903
-                $this->_saveMargin($this->pdf->getlMargin(), $this->pdf->gettMargin(), $this->pdf->getrMargin());
4904
-
4905
-                $this->parsingCss->value['width']-= HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r'];
4906
-            } else {
4907
-                // we start from the first page and the first page of the table
4908
-                HTML2PDF::$_tables[$param['num']]['page'] = 0;
4909
-                HTML2PDF::$_tables[$param['num']]['td_curr']    = 0;
4910
-                HTML2PDF::$_tables[$param['num']]['tr_curr']    = 0;
4911
-                HTML2PDF::$_tables[$param['num']]['td_x']        = HTML2PDF::$_tables[$param['num']]['marge']['l']+HTML2PDF::$_tables[$param['num']]['curr_x'];
4912
-                HTML2PDF::$_tables[$param['num']]['td_y']        = HTML2PDF::$_tables[$param['num']]['marge']['t']+HTML2PDF::$_tables[$param['num']]['curr_y'];
4913
-
4914
-                // draw the borders/background of the first page/part of the table
4915
-                $this->_drawRectangle(
4916
-                    HTML2PDF::$_tables[$param['num']]['curr_x'],
4917
-                    HTML2PDF::$_tables[$param['num']]['curr_y'],
4918
-                    HTML2PDF::$_tables[$param['num']]['width'],
4919
-                    isset(HTML2PDF::$_tables[$param['num']]['height'][0]) ? HTML2PDF::$_tables[$param['num']]['height'][0] : null,
4920
-                    $this->parsingCss->value['border'],
4921
-                    $this->parsingCss->value['padding'],
4922
-                    0,
4923
-                    $this->parsingCss->value['background']
4924
-                );
4925
-
4926
-                HTML2PDF::$_tables[$param['num']]['style_value'] = $this->parsingCss->value;
4927
-            }
4928
-
4929
-            return true;
4930
-        }
4931
-
4932
-        /**
4933
-         * tag : TABLE
4934
-         * mode : CLOSE
4935
-         *
4936
-         * @param  array $param
4937
-         * @return boolean
4938
-         */
4939
-        protected function _tag_close_TABLE($param)
4940
-        {
4941
-            if ($this->_isForOneLine) return false;
4942
-
4943
-            $this->_maxH = 0;
4944
-
4945
-            // if we are in a sub HTML
4946
-            if ($this->_subPart) {
4947
-                // calculate the size of each case
4948
-                $this->_calculateTableCellSize(HTML2PDF::$_tables[$param['num']]['cases'], HTML2PDF::$_tables[$param['num']]['corr']);
4949
-
4950
-                // calculate the height of the thead and the tfoot
4951
-                $lst = array('thead', 'tfoot');
4952
-                foreach ($lst as $mode) {
4953
-                    HTML2PDF::$_tables[$param['num']][$mode]['height'] = 0;
4954
-                    foreach (HTML2PDF::$_tables[$param['num']][$mode]['tr'] as $tr) {
4955
-                        // hauteur de la ligne tr
4956
-                        $h = 0;
4957
-                        for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++)
4958
-                            if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan']==1)
4959
-                                $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['h']);
4960
-                        HTML2PDF::$_tables[$param['num']][$mode]['height']+= $h;
4961
-                    }
4962
-                }
4963
-
4964
-                // calculate the width of the table
4965
-                HTML2PDF::$_tables[$param['num']]['width'] = HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r'];
4966
-                if (isset(HTML2PDF::$_tables[$param['num']]['cases'][0])) {
4967
-                    foreach (HTML2PDF::$_tables[$param['num']]['cases'][0] as $case) {
4968
-                        HTML2PDF::$_tables[$param['num']]['width']+= $case['w'];
4969
-                    }
4970
-                }
4971
-
4972
-                // X position of the table
4973
-                $old = $this->parsingCss->getOldValues();
4974
-                $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
4975
-                $x = HTML2PDF::$_tables[$param['num']]['curr_x'];
4976
-                $w = HTML2PDF::$_tables[$param['num']]['width'];
4977
-                if ($parentWidth>$w) {
4978
-                    if (HTML2PDF::$_tables[$param['num']]['align']=='center')
4979
-                        $x = $x + ($parentWidth-$w)*0.5;
4980
-                    else if (HTML2PDF::$_tables[$param['num']]['align']=='right')
4981
-                        $x = $x + $parentWidth-$w;
4982
-
4983
-                    HTML2PDF::$_tables[$param['num']]['curr_x'] = $x;
4984
-                }
4985
-
4986
-                // calculate the height of the table
4987
-                HTML2PDF::$_tables[$param['num']]['height'] = array();
4988
-
4989
-                // minimum of the height because of margins, and of the thead and tfoot height
4990
-                $h0 = HTML2PDF::$_tables[$param['num']]['marge']['t'] + HTML2PDF::$_tables[$param['num']]['marge']['b'];
4991
-                $h0+= HTML2PDF::$_tables[$param['num']]['thead']['height'] + HTML2PDF::$_tables[$param['num']]['tfoot']['height'];
4992
-
4993
-                // max height of the page
4994
-                $max = $this->pdf->getH() - $this->pdf->getbMargin();
4995
-
4996
-                // current position on the page
4997
-                $y = HTML2PDF::$_tables[$param['num']]['curr_y'];
4998
-                $height = $h0;
4999
-
5000
-                // we get the height of each line
5001
-                for ($k=0; $k<count(HTML2PDF::$_tables[$param['num']]['cases']); $k++) {
5002
-
5003
-                    // if it is a TR of the thead or of the tfoot => skip
5004
-                    if (in_array($k, HTML2PDF::$_tables[$param['num']]['thead']['tr'])) continue;
5005
-                    if (in_array($k, HTML2PDF::$_tables[$param['num']]['tfoot']['tr'])) continue;
5006
-
5007
-                    // height of the line
5008
-                    $th = 0;
5009
-                    $h = 0;
5010
-                    for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$k]); $i++) {
5011
-                        $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']);
5012
-
5013
-                        if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan']==1)
5014
-                            $th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']);
5015
-                    }
5016
-
5017
-                    // if the row does not fit on the page => new page
5018
-                    if ($y+$h+$height>$max) {
5019
-                        if ($height==$h0) $height = null;
5020
-                        HTML2PDF::$_tables[$param['num']]['height'][] = $height;
5021
-                        $height = $h0;
5022
-                        $y = $this->_margeTop;
5023
-                    }
5024
-                    $height+= $th;
5025
-                }
5026
-
5027
-                // if ther is a height at the end, add it
5028
-                if ($height!=$h0 || $k==0) HTML2PDF::$_tables[$param['num']]['height'][] = $height;
5029
-            } else {
5030
-                // if we have tfoor, draw it
5031
-                if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) {
5032
-                    $tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr'];
5033
-                    $tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr'];
5034
-                    $oldParsePos = $this->_parsePos;
5035
-                    $oldParseCode = $this->parsingHtml->code;
5036
-
5037
-                    HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0];
5038
-                    HTML2PDF::$_tables[$param['num']]['td_curr'] = 0;
5039
-                    $this->_parsePos = 0;
5040
-                    $this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['tfoot']['code'];
5041
-                    $this->_isInTfoot = true;
5042
-                    $this->_makeHTMLcode();
5043
-                    $this->_isInTfoot = false;
5044
-
5045
-                    $this->_parsePos =     $oldParsePos;
5046
-                    $this->parsingHtml->code = $oldParseCode;
5047
-                    HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR;
5048
-                    HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD;
5049
-                }
5050
-
5051
-                // get the positions of the end of the table
5052
-                $x = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['width'];
5053
-                if (count(HTML2PDF::$_tables[$param['num']]['height'])>1)
5054
-                    $y = $this->_margeTop+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1];
5055
-                else if (count(HTML2PDF::$_tables[$param['num']]['height'])==1)
5056
-                    $y = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1];
5057
-                else
5058
-                    $y = HTML2PDF::$_tables[$param['num']]['curr_y'];
5059
-
5060
-                $this->_maxX = max($this->_maxX, $x);
5061
-                $this->_maxY = max($this->_maxY, $y);
5062
-
5063
-                $this->pdf->setXY($this->pdf->getlMargin(), $y);
5064
-
5065
-                $this->_loadMargin();
5066
-
5067
-                if ($this->_debugActif) $this->_DEBUG_add('Table '.$param['num'], false);
5068
-            }
5069
-
5070
-            $this->parsingCss->load();
5071
-            $this->parsingCss->fontSet();
5072
-
5073
-
5074
-            return true;
5075
-        }
5076
-
5077
-        /**
5078
-         * tag : COL
5079
-         * mode : OPEN
5080
-         *
5081
-         * @param  array $param
5082
-         * @return boolean
5083
-         */
5084
-        protected function _tag_open_COL($param)
5085
-        {
5086
-            $span = isset($param['span']) ? $param['span'] : 1;
5087
-            for ($k=0; $k<$span; $k++)
5088
-                HTML2PDF::$_tables[$param['num']]['cols'][] = $param;
5089
-        }
5090
-
5091
-        /**
5092
-         * tag : COL
5093
-         * mode : CLOSE
5094
-         *
5095
-         * @param  array $param
5096
-         * @return boolean
5097
-         */
5098
-        protected function _tag_close_COL($param)
5099
-        {
5100
-            // there is nothing to do here
5101
-
5102
-            return true;
5103
-        }
5104
-
5105
-        /**
5106
-         * tag : TR
5107
-         * mode : OPEN
5108
-         *
5109
-         * @param  array $param
5110
-         * @return boolean
5111
-         */
5112
-        protected function _tag_open_TR($param, $other = 'tr')
5113
-        {
5114
-            if ($this->_isForOneLine) return false;
5115
-
5116
-            $this->_maxH = 0;
5117
-
5118
-            $this->parsingCss->save();
5119
-            $this->parsingCss->analyse($other, $param);
5120
-            $this->parsingCss->setPosition();
5121
-            $this->parsingCss->fontSet();
5122
-
5123
-            // position in the table
5124
-            HTML2PDF::$_tables[$param['num']]['tr_curr']++;
5125
-            HTML2PDF::$_tables[$param['num']]['td_curr']= 0;
5126
-
5127
-            // if we are not in a sub html
5128
-            if (!$this->_subPart) {
5129
-
5130
-                // Y after the row
5131
-                $ty=null;
5132
-                for ($ii=0; $ii<count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1]); $ii++) {
5133
-                    $ty = max($ty, HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['h']);
5134
-                }
5135
-
5136
-                // height of the tfoot
5137
-                $hfoot = HTML2PDF::$_tables[$param['num']]['tfoot']['height'];
5138
-
5139
-                // if the line does not fit on the page => new page
5140
-                if (!$this->_isInTfoot && HTML2PDF::$_tables[$param['num']]['td_y'] + HTML2PDF::$_tables[$param['num']]['marge']['b'] + $ty +$hfoot> $this->pdf->getH() - $this->pdf->getbMargin()) {
5141
-
5142
-                    // fi ther is a tfoot => draw it
5143
-                    if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) {
5144
-                        $tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr'];
5145
-                        $tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr'];
5146
-                        $oldParsePos = $this->_parsePos;
5147
-                        $oldParseCode = $this->parsingHtml->code;
5148
-
5149
-                        HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0];
5150
-                        HTML2PDF::$_tables[$param['num']]['td_curr'] = 0;
5151
-                        $this->_parsePos = 0;
5152
-                        $this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['tfoot']['code'];
5153
-                        $this->_isInTfoot = true;
5154
-                        $this->_makeHTMLcode();
5155
-                        $this->_isInTfoot = false;
5156
-
5157
-                        $this->_parsePos =     $oldParsePos;
5158
-                        $this->parsingHtml->code = $oldParseCode;
5159
-                        HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR;
5160
-                        HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD;
5161
-                    }
5162
-
5163
-                    // new page
5164
-                    HTML2PDF::$_tables[$param['num']]['new_page'] = true;
5165
-                    $this->_setNewPage();
5166
-
5167
-                    // new position
5168
-                    HTML2PDF::$_tables[$param['num']]['page']++;
5169
-                    HTML2PDF::$_tables[$param['num']]['curr_y'] = $this->pdf->getY();
5170
-                    HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['marge']['t'];
5171
-
5172
-                    // if we have the height of the tbale on the page => draw borders and background
5173
-                    if (isset(HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']])) {
5174
-                        $old = $this->parsingCss->value;
5175
-                        $this->parsingCss->value = HTML2PDF::$_tables[$param['num']]['style_value'];
5176
-
5177
-                        $this->_drawRectangle(
5178
-                            HTML2PDF::$_tables[$param['num']]['curr_x'],
5179
-                            HTML2PDF::$_tables[$param['num']]['curr_y'],
5180
-                            HTML2PDF::$_tables[$param['num']]['width'],
5181
-                            HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']],
5182
-                            $this->parsingCss->value['border'],
5183
-                            $this->parsingCss->value['padding'],
5184
-                            HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5,
5185
-                            $this->parsingCss->value['background']
5186
-                        );
5187
-
5188
-                        $this->parsingCss->value = $old;
5189
-                    }
5190
-                }
5191
-
5192
-                // if we are in a new page, and if we have a thead => draw it
5193
-                if (HTML2PDF::$_tables[$param['num']]['new_page'] && count(HTML2PDF::$_tables[$param['num']]['thead']['code'])) {
5194
-                    HTML2PDF::$_tables[$param['num']]['new_page'] = false;
5195
-                    $tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr'];
5196
-                    $tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr'];
5197
-                    $oldParsePos = $this->_parsePos;
5198
-                    $oldParseCode = $this->parsingHtml->code;
5199
-
5200
-                    HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['thead']['tr'][0];
5201
-                    HTML2PDF::$_tables[$param['num']]['td_curr'] = 0;
5202
-                    $this->_parsePos = 0;
5203
-                    $this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['thead']['code'];
5204
-                    $this->_isInThead = true;
5205
-                    $this->_makeHTMLcode();
5206
-                    $this->_isInThead = false;
5207
-
5208
-                    $this->_parsePos =     $oldParsePos;
5209
-                    $this->parsingHtml->code = $oldParseCode;
5210
-                    HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR;
5211
-                    HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD;
5212
-                    HTML2PDF::$_tables[$param['num']]['new_page'] = true;
5213
-                }
5214
-            // else (in a sub HTML)
5215
-            } else {
5216
-                // prepare it
5217
-                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1] = array();
5218
-                if (!isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']]))
5219
-                    HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array();
5220
-
5221
-                HTML2PDF::$_tables[$param['num']]['corr_x']=0;
5222
-                while(isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']]))
5223
-                    HTML2PDF::$_tables[$param['num']]['corr_x']++;
5224
-            }
5225
-
5226
-            return true;
5227
-        }
5228
-
5229
-        /**
5230
-         * tag : TR
5231
-         * mode : CLOSE
5232
-         *
5233
-         * @param  array $param
5234
-         * @return boolean
5235
-         */
5236
-        protected function _tag_close_TR($param)
5237
-        {
5238
-            if ($this->_isForOneLine) return false;
5239
-
5240
-            $this->_maxH = 0;
5241
-
5242
-            $this->parsingCss->load();
5243
-            $this->parsingCss->fontSet();
5244
-
5245
-            // if we are not in a sub HTML
5246
-            if (!$this->_subPart) {
5247
-
5248
-                // Y of the current line
5249
-                $ty=null;
5250
-                for ($ii=0; $ii<count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1]); $ii++) {
5251
-                    if (HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['rowspan']==1) {
5252
-                        $ty = HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['h'];
5253
-                    }
5254
-                }
5255
-
5256
-                // new position
5257
-                HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['curr_x']+HTML2PDF::$_tables[$param['num']]['marge']['l'];
5258
-                HTML2PDF::$_tables[$param['num']]['td_y']+= $ty;
5259
-                HTML2PDF::$_tables[$param['num']]['new_page'] = false;
5260
-            } else {
5261
-                HTML2PDF::$_tables[$param['num']]['corr_y']++;
5262
-            }
5263
-
5264
-            return true;
5265
-        }
5266
-
5267
-        /**
5268
-         * tag : TD
5269
-         * mode : OPEN
5270
-         *
5271
-         * @param  array $param
5272
-         * @return boolean
5273
-         */
5274
-        protected function _tag_open_TD($param, $other = 'td')
5275
-        {
5276
-            if ($this->_isForOneLine) return false;
5277
-
5278
-            $this->_maxH = 0;
5279
-
5280
-            $param['cellpadding'] = HTML2PDF::$_tables[$param['num']]['cellpadding'].'mm';
5281
-            $param['cellspacing'] = HTML2PDF::$_tables[$param['num']]['cellspacing'].'mm';
5282
-
5283
-            // specific style for LI
5284
-            if ($other=='li') {
5285
-                $specialLi = true;
5286
-            } else {
5287
-                $specialLi = false;
5288
-                if ($other=='li_sub') {
5289
-                    $param['style']['border'] = 'none';
5290
-                    $param['style']['background-color']    = 'transparent';
5291
-                    $param['style']['background-image']    = 'none';
5292
-                    $param['style']['background-position'] = '';
5293
-                    $param['style']['background-repeat']   = '';
5294
-                    $other = 'li';
5295
-                }
5296
-            }
5297
-
5298
-            // get the properties of the TD
5299
-            $x = HTML2PDF::$_tables[$param['num']]['td_curr'];
5300
-            $y = HTML2PDF::$_tables[$param['num']]['tr_curr']-1;
5301
-            $colspan = isset($param['colspan']) ? $param['colspan'] : 1;
5302
-            $rowspan = isset($param['rowspan']) ? $param['rowspan'] : 1;
5303
-
5304
-            // flag for collapse table
5305
-            $collapse = false;
5306
-
5307
-            // specific traitment for TD and TH
5308
-            if (in_array($other, array('td', 'th'))) {
5309
-                // id of the column
5310
-                $numCol = isset(HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr']) ? HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr'] : HTML2PDF::$_tables[$param['num']]['corr_x'];
5311
-
5312
-                // we get the properties of the COL tag, if exist
5313
-                if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol])) {
5314
-
5315
-                    $colParam = HTML2PDF::$_tables[$param['num']]['cols'][$numCol];
5316
-
5317
-                    // for colspans => we get all the neede widths
5318
-                    $colParam['style']['width'] = array();
5319
-                    for ($k=0; $k<$colspan; $k++) {
5320
-                        if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol+$k]['style']['width'])) {
5321
-                            $colParam['style']['width'][] = HTML2PDF::$_tables[$param['num']]['cols'][$numCol+$k]['style']['width'];
5322
-                        }
5323
-                    }
5324
-
5325
-                    // calculate the total width of the column
5326
-                    $total = '';
5327
-                    $last = $this->parsingCss->getLastWidth();
5328
-                    if (count($colParam['style']['width'])) {
5329
-                        $total = $colParam['style']['width'][0]; unset($colParam['style']['width'][0]);
5330
-                        foreach ($colParam['style']['width'] as $width) {
5331
-                            if (substr($total, -1)=='%' && substr($width, -1)=='%')
5332
-                                $total = (str_replace('%', '', $total)+str_replace('%', '', $width)).'%';
5333
-                            else
5334
-                                $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm';
5335
-                        }
5336
-                    }
5337
-
5338
-                    // get the final width
5339
-                    if ($total) {
5340
-                        $colParam['style']['width'] = $total;
5341
-                    } else {
5342
-                        unset($colParam['style']['width']);
5343
-                    }
5344
-
5345
-
5346
-                    // merge the styles of the COL and the TD
5347
-                    $param['style'] = array_merge($colParam['style'], $param['style']);
5348
-
5349
-                    // merge the class of the COL and the TD
5350
-                    if (isset($colParam['class'])) {
5351
-                        $param['class'] = $colParam['class'].(isset($param['class']) ? ' '.$param['class'] : '');
5352
-                    }
5353
-                }
5354
-
5355
-                $collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false;
5356
-            }
5357
-
5358
-            $this->parsingCss->save();
5359
-
5360
-            // legacy for TD and TH
5361
-            $legacy = null;
5362
-            if (in_array($other, array('td', 'th'))) {
5363
-                $legacy = array();
5364
-
5365
-                $old = $this->parsingCss->getLastValue('background');
5366
-                if ($old && ($old['color'] || $old['image']))
5367
-                    $legacy['background'] = $old;
5368
-
5369
-                if (HTML2PDF::$_tables[$param['num']]['border']) {
5370
-                    $legacy['border'] = array();
5371
-                    $legacy['border']['l'] = HTML2PDF::$_tables[$param['num']]['border'];
5372
-                    $legacy['border']['t'] = HTML2PDF::$_tables[$param['num']]['border'];
5373
-                    $legacy['border']['r'] = HTML2PDF::$_tables[$param['num']]['border'];
5374
-                    $legacy['border']['b'] = HTML2PDF::$_tables[$param['num']]['border'];
5375
-                }
5376
-            }
5377
-            $return = $this->parsingCss->analyse($other, $param, $legacy);
5378
-
5379
-            if ($specialLi) {
5380
-                $this->parsingCss->value['width']-= $this->parsingCss->ConvertToMM($this->_listeGetWidth());
5381
-                $this->parsingCss->value['width']-= $this->parsingCss->ConvertToMM($this->_listeGetPadding());
5382
-            }
5383
-            $this->parsingCss->setPosition();
5384
-            $this->parsingCss->fontSet();
5385
-
5386
-            // if tale collapse => modify the borders
5387
-            if ($collapse) {
5388
-                if (!$this->_subPart) {
5389
-                    if (
5390
-                        (HTML2PDF::$_tables[$param['num']]['tr_curr']>1 && !HTML2PDF::$_tables[$param['num']]['new_page']) ||
5391
-                        (!$this->_isInThead && count(HTML2PDF::$_tables[$param['num']]['thead']['code']))
5392
-                    ) {
5393
-                        $this->parsingCss->value['border']['t'] = $this->parsingCss->readBorder('none');
5394
-                    }
5395
-                }
5396
-
5397
-                if (HTML2PDF::$_tables[$param['num']]['td_curr']>0) {
5398
-                    if (!$return) $this->parsingCss->value['width']+= $this->parsingCss->value['border']['l']['width'];
5399
-                    $this->parsingCss->value['border']['l'] = $this->parsingCss->readBorder('none');
5400
-                }
5401
-            }
5402
-
5403
-            // margins of the table
5404
-            $marge = array();
5405
-            $marge['t'] = $this->parsingCss->value['padding']['t']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['t']['width'];
5406
-            $marge['r'] = $this->parsingCss->value['padding']['r']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['r']['width'];
5407
-            $marge['b'] = $this->parsingCss->value['padding']['b']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['b']['width'];
5408
-            $marge['l'] = $this->parsingCss->value['padding']['l']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['l']['width'];
5409
-
5410
-            // if we are in a sub HTML
5411
-            if ($this->_subPart) {
5412
-                // new position in the table
5413
-                HTML2PDF::$_tables[$param['num']]['td_curr']++;
5414
-                HTML2PDF::$_tables[$param['num']]['cases'][$y][$x] = array();
5415
-                HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'] = 0;
5416
-                HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'] = 0;
5417
-                HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw'] = 0;
5418
-                HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['colspan'] = $colspan;
5419
-                HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['rowspan'] = $rowspan;
5420
-                HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr'] = HTML2PDF::$_tables[$param['num']]['corr_x'];
5421
-                HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Yr'] = HTML2PDF::$_tables[$param['num']]['corr_y'];
5422
-
5423
-                // prepare the mapping for rowspan and colspan
5424
-                for ($j=0; $j<$rowspan; $j++) {
5425
-                    for ($i=0; $i<$colspan; $i++) {
5426
-                        HTML2PDF::$_tables[$param['num']]['corr']
5427
-                            [HTML2PDF::$_tables[$param['num']]['corr_y']+$j]
5428
-                            [HTML2PDF::$_tables[$param['num']]['corr_x']+$i] = ($i+$j>0) ? '' : array($x,$y,$colspan,$rowspan);
5429
-                    }
5430
-                }
5431
-                HTML2PDF::$_tables[$param['num']]['corr_x']+= $colspan;
5432
-                while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) {
5433
-                    HTML2PDF::$_tables[$param['num']]['corr_x']++;
5434
-                }
5435
-
5436
-                // extract the content of the TD, and calculate his size
5437
-                $level = $this->parsingHtml->getLevel($this->_tempPos);
5438
-                $this->_createSubHTML($this->_subHtml);
5439
-                $this->_subHtml->parsingHtml->code = $level;
5440
-                $this->_subHtml->_makeHTMLcode();
5441
-                $this->_tempPos+= count($level);
5442
-            } else {
5443
-                // new position in the table
5444
-                HTML2PDF::$_tables[$param['num']]['td_curr']++;
5445
-                HTML2PDF::$_tables[$param['num']]['td_x']+= HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw'];
5446
-
5447
-                // borders and background of the TD
5448
-                $this->_drawRectangle(
5449
-                    HTML2PDF::$_tables[$param['num']]['td_x'],
5450
-                    HTML2PDF::$_tables[$param['num']]['td_y'],
5451
-                    HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'],
5452
-                    HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'],
5453
-                    $this->parsingCss->value['border'],
5454
-                    $this->parsingCss->value['padding'],
5455
-                    HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5,
5456
-                    $this->parsingCss->value['background']
5457
-                );
5458
-
5459
-                $this->parsingCss->value['width'] = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'] - $marge['l'] - $marge['r'];
5460
-
5461
-                // marges = size of the TD
5462
-                $mL = HTML2PDF::$_tables[$param['num']]['td_x']+$marge['l'];
5463
-                $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width'];
5464
-                $this->_saveMargin($mL, 0, $mR);
5465
-
5466
-                // position of the content, from vertical-align
5467
-                $hCorr = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'];
5468
-                $hReel = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['real_h'];
5469
-                switch($this->parsingCss->value['vertical-align'])
5470
-                {
5471
-                    case 'bottom':
5472
-                        $yCorr = $hCorr-$hReel;
5473
-                        break;
5474
-
5475
-                    case 'middle':
5476
-                        $yCorr = ($hCorr-$hReel)*0.5;
5477
-                        break;
5478
-
5479
-                    case 'top':
5480
-                    default:
5481
-                        $yCorr = 0;
5482
-                        break;
5483
-                }
5484
-
5485
-                //  position of the content
5486
-                $x = HTML2PDF::$_tables[$param['num']]['td_x']+$marge['l'];
5487
-                $y = HTML2PDF::$_tables[$param['num']]['td_y']+$marge['t']+$yCorr;
5488
-                $this->pdf->setXY($x, $y);
5489
-                $this->_setNewPositionForNewLine();
5490
-            }
5491
-
5492
-            return true;
5493
-        }
5494
-
5495
-        /**
5496
-         * tag : TD
5497
-         * mode : CLOSE
5498
-         *
5499
-         * @param    array $param
5500
-         * @return boolean
5501
-         */
5502
-        protected function _tag_close_TD($param)
5503
-        {
5504
-            if ($this->_isForOneLine) return false;
5505
-
5506
-            $this->_maxH = 0;
5507
-
5508
-            // get the margins
5509
-            $marge = array();
5510
-            $marge['t'] = $this->parsingCss->value['padding']['t']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['t']['width'];
5511
-            $marge['r'] = $this->parsingCss->value['padding']['r']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['r']['width'];
5512
-            $marge['b'] = $this->parsingCss->value['padding']['b']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['b']['width'];
5513
-            $marge['l'] = $this->parsingCss->value['padding']['l']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['l']['width'];
5514
-            $marge['t']+= 0.001;
5515
-            $marge['r']+= 0.001;
5516
-            $marge['b']+= 0.001;
5517
-            $marge['l']+= 0.001;
5518
-
5519
-            // if we are in a sub HTML
5520
-            if ($this->_subPart) {
5521
-
5522
-                // it msut take only one page
5523
-                if ($this->_testTdInOnepage && $this->_subHtml->pdf->getPage()>1) {
5524
-                    throw new HTML2PDF_exception(7);
5525
-                }
5526
-
5527
-                // size of the content of the TD
5528
-                $w0 = $this->_subHtml->_maxX + $marge['l'] + $marge['r'];
5529
-                $h0 = $this->_subHtml->_maxY + $marge['t'] + $marge['b'];
5530
-
5531
-                // size from the CSS style
5532
-                $w2 = $this->parsingCss->value['width'] + $marge['l'] + $marge['r'];
5533
-                $h2 = $this->parsingCss->value['height'] + $marge['t'] + $marge['b'];
5534
-
5535
-                // final size of the TD
5536
-                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['w'] = max(array($w0, $w2));
5537
-                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['h'] = max(array($h0, $h2));
5538
-
5539
-                // real position of the content
5540
-                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['real_w'] = $w0;
5541
-                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['real_h'] = $h0;
5542
-
5543
-                // destroy the sub HTML
5544
-                $this->_destroySubHTML($this->_subHtml);
5545
-            } else {
5546
-                $this->_loadMargin();
5547
-
5548
-                HTML2PDF::$_tables[$param['num']]['td_x']+= HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['w'];
5549
-            }
5550
-
5551
-            $this->parsingCss->load();
5552
-            $this->parsingCss->fontSet();
5553
-
5554
-            return true;
5555
-        }
5556
-
5557
-
5558
-        /**
5559
-         * tag : TH
5560
-         * mode : OPEN
5561
-         *
5562
-         * @param  array $param
5563
-         * @return boolean
5564
-         */
5565
-        protected function _tag_open_TH($param)
5566
-        {
5567
-            if ($this->_isForOneLine) return false;
5568
-
5569
-            $this->parsingCss->save();
5570
-            $this->parsingCss->value['font-bold'] = true;
5571
-
5572
-            $this->_tag_open_TD($param, 'th');
5573
-
5574
-            return true;
5575
-        }
5576
-
5577
-        /**
5578
-         * tag : TH
5579
-         * mode : CLOSE
5580
-         *
5581
-         * @param  array $param
5582
-         * @return boolean
5583
-         */
5584
-        protected function _tag_close_TH($param)
5585
-        {
5586
-            if ($this->_isForOneLine) return false;
5587
-
5588
-            $this->_tag_close_TD($param);
5589
-
5590
-            $this->parsingCss->load();
5591
-
5592
-            return true;
5593
-        }
5594
-
5595
-        /**
5596
-         * tag : IMG
5597
-         * mode : OPEN
5598
-         *
5599
-         * @param  array $param
5600
-         * @return boolean
5601
-         */
5602
-        protected function _tag_open_IMG($param)
5603
-        {
5604
-            $src    = str_replace('&amp;', '&', $param['src']);
5605
-
5606
-            $this->parsingCss->save();
5607
-            $this->parsingCss->value['width']    = 0;
5608
-            $this->parsingCss->value['height']    = 0;
5609
-            $this->parsingCss->value['border']    = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0));
5610
-            $this->parsingCss->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null);
5611
-            $this->parsingCss->analyse('img', $param);
5612
-            $this->parsingCss->setPosition();
5613
-            $this->parsingCss->fontSet();
5614
-
5615
-            $res = $this->_drawImage($src, isset($param['sub_li']));
5616
-            if (!$res) return $res;
5617
-
5618
-            $this->parsingCss->load();
5619
-            $this->parsingCss->fontSet();
5620
-            $this->_maxE++;
5621
-
5622
-            return true;
5623
-        }
5624
-
5625
-        /**
5626
-         * tag : SELECT
5627
-         * mode : OPEN
5628
-         *
5629
-         * @param  array $param
5630
-         * @return boolean
5631
-         */
5632
-        protected function _tag_open_SELECT($param)
5633
-        {
5634
-            if (!isset($param['name'])) {
5635
-                $param['name'] = 'champs_pdf_'.(count($this->_lstField)+1);
5636
-            }
5637
-
5638
-            $param['name'] = strtolower($param['name']);
5639
-
5640
-            if (isset($this->_lstField[$param['name']])) {
5641
-                $this->_lstField[$param['name']]++;
5642
-            } else {
5643
-                $this->_lstField[$param['name']] = 1;
5644
-            }
5645
-
5646
-            $this->parsingCss->save();
5647
-            $this->parsingCss->analyse('select', $param);
5648
-            $this->parsingCss->setPosition();
5649
-            $this->parsingCss->fontSet();
5650
-
5651
-            $this->_lstSelect = array();
5652
-            $this->_lstSelect['name']    = $param['name'];
5653
-            $this->_lstSelect['multi']    = isset($param['multiple']) ? true : false;
5654
-            $this->_lstSelect['size']    = isset($param['size']) ? $param['size'] : 1;
5655
-            $this->_lstSelect['options']    = array();
5656
-
5657
-            if ($this->_lstSelect['multi'] && $this->_lstSelect['size']<3) $this->_lstSelect['size'] = 3;
5658
-
5659
-            return true;
5660
-        }
5661
-
5662
-        /**
5663
-         * tag : OPTION
5664
-         * mode : OPEN
5665
-         *
5666
-         * @param    array $param
5667
-         * @return boolean
5668
-         */
5669
-        protected function _tag_open_OPTION($param)
5670
-        {
5671
-            // get the content of the option : it is the text of the option
5672
-            $level = $this->parsingHtml->getLevel($this->_parsePos);
5673
-            $this->_parsePos+= count($level);
5674
-            $value = isset($param['value']) ? $param['value'] : 'aut_tag_open_opt_'.(count($this->_lstSelect)+1);
5675
-
5676
-            $this->_lstSelect['options'][$value] = isset($level[0]['param']['txt']) ? $level[0]['param']['txt'] : '';
5677
-
5678
-            return true;
5679
-        }
5680
-
5681
-        /**
5682
-         * tag : OPTION
5683
-         * mode : CLOSE
5684
-         *
5685
-         * @param    array $param
5686
-         * @return boolean
5687
-         */
5688
-        protected function _tag_close_OPTION($param)
5689
-        {
5690
-            // nothing to do here
5691
-
5692
-            return true;
5693
-        }
5694
-
5695
-        /**
5696
-         * tag : SELECT
5697
-         * mode : CLOSE
5698
-         *
5699
-         * @param  array $param
5700
-         * @return boolean
5701
-         */
5702
-        protected function _tag_close_SELECT()
5703
-        {
5704
-            // position of the select
5705
-            $x = $this->pdf->getX();
5706
-            $y = $this->pdf->getY();
5707
-            $f = 1.08*$this->parsingCss->value['font-size'];
5708
-
5709
-            // width
5710
-            $w = $this->parsingCss->value['width']; if (!$w) $w = 50;
5711
-
5712
-            // height (automatic)
5713
-            $h = ($f*1.07*$this->_lstSelect['size'] + 1);
5714
-
5715
-            $prop = $this->parsingCss->getFormStyle();
5716
-
5717
-            // multy select
5718
-            if ($this->_lstSelect['multi']) {
5719
-                $prop['multipleSelection'] = 'true';
5720
-            }
5721
-
5722
-
5723
-            // single or multi select
5724
-            if ($this->_lstSelect['size']>1) {
5725
-                $this->pdf->ListBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop);
5726
-            } else {
5727
-                $this->pdf->ComboBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop);
5728
-            }
5729
-
5730
-            $this->_maxX = max($this->_maxX, $x+$w);
5731
-            $this->_maxY = max($this->_maxY, $y+$h);
5732
-            $this->_maxH = max($this->_maxH, $h);
5733
-            $this->_maxE++;
5734
-            $this->pdf->setX($x+$w);
5735
-
5736
-            $this->parsingCss->load();
5737
-            $this->parsingCss->fontSet();
5738
-
5739
-            $this->_lstSelect = array();
5740
-
5741
-            return true;
5742
-        }
5743
-
5744
-        /**
5745
-         * tag : TEXTAREA
5746
-         * mode : OPEN
5747
-         *
5748
-         * @param    array $param
5749
-         * @return boolean
5750
-         */
5751
-        protected function _tag_open_TEXTAREA($param)
5752
-        {
5753
-            if (!isset($param['name'])) {
5754
-                $param['name'] = 'champs_pdf_'.(count($this->_lstField)+1);
5755
-            }
5756
-
5757
-            $param['name'] = strtolower($param['name']);
5758
-
5759
-            if (isset($this->_lstField[$param['name']])) {
5760
-                $this->_lstField[$param['name']]++;
5761
-            } else {
5762
-                $this->_lstField[$param['name']] = 1;
5763
-            }
5764
-
5765
-            $this->parsingCss->save();
5766
-            $this->parsingCss->analyse('textarea', $param);
5767
-            $this->parsingCss->setPosition();
5768
-            $this->parsingCss->fontSet();
5769
-
5770
-            $x = $this->pdf->getX();
5771
-            $y = $this->pdf->getY();
5772
-            $fx = 0.65*$this->parsingCss->value['font-size'];
5773
-            $fy = 1.08*$this->parsingCss->value['font-size'];
5774
-
5775
-            // extract the content the textarea : value
5776
-            $level = $this->parsingHtml->getLevel($this->_parsePos);
5777
-            $this->_parsePos+= count($level);
5778
-
5779
-            // automatic size, from cols and rows properties
5780
-            $w = $fx*(isset($param['cols']) ? $param['cols'] : 22)+1;
5781
-            $h = $fy*1.07*(isset($param['rows']) ? $param['rows'] : 3)+3;
5782
-
5783
-            $prop = $this->parsingCss->getFormStyle();
5784
-
5785
-            $prop['multiline'] = true;
5786
-            $prop['value'] = isset($level[0]['param']['txt']) ? $level[0]['param']['txt'] : '';
5787
-
5788
-            $this->pdf->TextField($param['name'], $w, $h, $prop, array(), $x, $y);
5789
-
5790
-            $this->_maxX = max($this->_maxX, $x+$w);
5791
-            $this->_maxY = max($this->_maxY, $y+$h);
5792
-            $this->_maxH = max($this->_maxH, $h);
5793
-            $this->_maxE++;
5794
-            $this->pdf->setX($x+$w);
5795
-
5796
-            return true;
5797
-        }
5798
-
5799
-        /**
5800
-         * tag : TEXTAREA
5801
-         * mode : CLOSE
5802
-         *
5803
-         * @param  array $param
5804
-         * @return boolean
5805
-         */
5806
-        protected function _tag_close_TEXTAREA()
5807
-        {
5808
-            $this->parsingCss->load();
5809
-            $this->parsingCss->fontSet();
5810
-
5811
-            return true;
5812
-        }
5813
-
5814
-        /**
5815
-         * tag : INPUT
5816
-         * mode : OPEN
5817
-         *
5818
-         * @param  array $param
5819
-         * @return boolean
5820
-         */
5821
-        protected function _tag_open_INPUT($param)
5822
-        {
5823
-            if (!isset($param['name']))  $param['name']  = 'champs_pdf_'.(count($this->_lstField)+1);
5824
-            if (!isset($param['value'])) $param['value'] = '';
5825
-            if (!isset($param['type']))  $param['type']  = 'text';
5826
-
5827
-            $param['name'] = strtolower($param['name']);
5828
-            $param['type'] = strtolower($param['type']);
5829
-
5830
-            // the type must be valid
5831
-            if (!in_array($param['type'], array('text', 'checkbox', 'radio', 'hidden', 'submit', 'reset', 'button'))) {
5832
-                $param['type'] = 'text';
5833
-            }
5834
-
5835
-            if (isset($this->_lstField[$param['name']])) {
5836
-                $this->_lstField[$param['name']]++;
5837
-            } else {
5838
-                $this->_lstField[$param['name']] = 1;
5839
-            }
5840
-
5841
-            $this->parsingCss->save();
5842
-            $this->parsingCss->analyse('input', $param);
5843
-            $this->parsingCss->setPosition();
5844
-            $this->parsingCss->fontSet();
5845
-
5846
-            $name = $param['name'];
5847
-
5848
-            $x = $this->pdf->getX();
5849
-            $y = $this->pdf->getY();
5850
-            $f = 1.08*$this->parsingCss->value['font-size'];
5851
-
5852
-            $prop = $this->parsingCss->getFormStyle();
5853
-
5854
-            switch($param['type'])
5855
-            {
5856
-                case 'checkbox':
5857
-                    $w = 3;
5858
-                    $h = $w;
5859
-                    if ($h<$f) $y+= ($f-$h)*0.5;
5860
-                    $checked = (isset($param['checked']) && $param['checked']=='checked');
5861
-                    $this->pdf->CheckBox($name, $w, $checked, $prop, array(), ($param['value'] ? $param['value'] : 'Yes'), $x, $y);
5862
-                    break;
5863
-
5864
-                case 'radio':
5865
-                    $w = 3;
5866
-                    $h = $w;
5867
-                    if ($h<$f) $y+= ($f-$h)*0.5;
5868
-                    $checked = (isset($param['checked']) && $param['checked']=='checked');
5869
-                    $this->pdf->RadioButton($name, $w, $prop, array(), ($param['value'] ? $param['value'] : 'On'), $checked, $x, $y);
5870
-                    break;
5871
-
5872
-                case 'hidden':
5873
-                    $w = 0;
5874
-                    $h = 0;
5875
-                    $prop['value'] = $param['value'];
5876
-                    $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y);
5877
-                    break;
5878
-
5879
-                case 'text':
5880
-                    $w = $this->parsingCss->value['width']; if (!$w) $w = 40;
5881
-                    $h = $f*1.3;
5882
-                    $prop['value'] = $param['value'];
5883
-                    $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y);
5884
-                    break;
5885
-
5886
-                case 'submit':
5887
-                    $w = $this->parsingCss->value['width'];    if (!$w) $w = 40;
5888
-                    $h = $this->parsingCss->value['height'];    if (!$h) $h = $f*1.3;
5889
-                    $action = array('S'=>'SubmitForm', 'F'=>$this->_isInForm, 'Flags'=>array('ExportFormat'));
5890
-                    $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
5891
-                    break;
5892
-
5893
-                case 'reset':
5894
-                    $w = $this->parsingCss->value['width'];    if (!$w) $w = 40;
5895
-                    $h = $this->parsingCss->value['height'];    if (!$h) $h = $f*1.3;
5896
-                    $action = array('S'=>'ResetForm');
5897
-                    $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
5898
-                    break;
5899
-
5900
-                case 'button':
5901
-                    $w = $this->parsingCss->value['width'];    if (!$w) $w = 40;
5902
-                    $h = $this->parsingCss->value['height'];    if (!$h) $h = $f*1.3;
5903
-                    $action = isset($param['onclick']) ? $param['onclick'] : '';
5904
-                    $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
5905
-                    break;
5906
-
5907
-                default:
5908
-                    $w = 0;
5909
-                    $h = 0;
5910
-                    break;
5911
-            }
5912
-
5913
-            $this->_maxX = max($this->_maxX, $x+$w);
5914
-            $this->_maxY = max($this->_maxY, $y+$h);
5915
-            $this->_maxH = max($this->_maxH, $h);
5916
-            $this->_maxE++;
5917
-            $this->pdf->setX($x+$w);
5918
-
5919
-            $this->parsingCss->load();
5920
-            $this->parsingCss->fontSet();
5921
-
5922
-            return true;
5923
-        }
5924
-
5925
-        /**
5926
-         * tag : DRAW
5927
-         * mode : OPEN
5928
-         *
5929
-         * @param  array $param
5930
-         * @return boolean
5931
-         */
5932
-        protected function _tag_open_DRAW($param)
5933
-        {
5934
-            if ($this->_isForOneLine) return false;
5935
-            if ($this->_debugActif) $this->_DEBUG_add('DRAW', true);
5936
-
5937
-            $this->parsingCss->save();
5938
-            $this->parsingCss->analyse('draw', $param);
5939
-            $this->parsingCss->fontSet();
5940
-
5941
-            $alignObject = null;
5942
-            if ($this->parsingCss->value['margin-auto']) $alignObject = 'center';
5943
-
5944
-            $overW = $this->parsingCss->value['width'];
5945
-            $overH = $this->parsingCss->value['height'];
5946
-            $this->parsingCss->value['old_maxX'] = $this->_maxX;
5947
-            $this->parsingCss->value['old_maxY'] = $this->_maxY;
5948
-            $this->parsingCss->value['old_maxH'] = $this->_maxH;
5949
-
5950
-            $w = $this->parsingCss->value['width'];
5951
-            $h = $this->parsingCss->value['height'];
5952
-
5953
-            if (!$this->parsingCss->value['position']) {
5954
-                if (
5955
-                    $w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) &&
5956
-                    $this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin())
5957
-                    )
5958
-                    $this->_tag_open_BR(array());
5959
-
5960
-                if (
5961
-                        ($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) &&
5962
-                        ($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) &&
5963
-                        !$this->_isInOverflow
5964
-                    )
5965
-                    $this->_setNewPage();
5966
-
5967
-                $old = $this->parsingCss->getOldValues();
5968
-                $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
5969
-
5970
-                if ($parentWidth>$w) {
5971
-                    if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
5972
-                    else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
5973
-                }
5974
-
5975
-                $this->parsingCss->setPosition();
5976
-            } else {
5977
-                $old = $this->parsingCss->getOldValues();
5978
-                $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
5979
-
5980
-                if ($parentWidth>$w) {
5981
-                    if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
5982
-                    else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
5983
-                }
5984
-
5985
-                $this->parsingCss->setPosition();
5986
-                $this->_saveMax();
5987
-                $this->_maxX = 0;
5988
-                $this->_maxY = 0;
5989
-                $this->_maxH = 0;
5990
-                $this->_maxE = 0;
5991
-            }
5992
-
5993
-            $this->_drawRectangle(
5994
-                $this->parsingCss->value['x'],
5995
-                $this->parsingCss->value['y'],
5996
-                $this->parsingCss->value['width'],
5997
-                $this->parsingCss->value['height'],
5998
-                $this->parsingCss->value['border'],
5999
-                $this->parsingCss->value['padding'],
6000
-                0,
6001
-                $this->parsingCss->value['background']
6002
-            );
6003
-
6004
-            $marge = array();
6005
-            $marge['l'] = $this->parsingCss->value['border']['l']['width'];
6006
-            $marge['r'] = $this->parsingCss->value['border']['r']['width'];
6007
-            $marge['t'] = $this->parsingCss->value['border']['t']['width'];
6008
-            $marge['b'] = $this->parsingCss->value['border']['b']['width'];
6009
-
6010
-            $this->parsingCss->value['width'] -= $marge['l']+$marge['r'];
6011
-            $this->parsingCss->value['height']-= $marge['t']+$marge['b'];
6012
-
6013
-            $overW-= $marge['l']+$marge['r'];
6014
-            $overH-= $marge['t']+$marge['b'];
6015
-
6016
-            // clipping to draw only in the size opf the DRAW tag
6017
-            $this->pdf->clippingPathStart(
6018
-                $this->parsingCss->value['x']+$marge['l'],
6019
-                $this->parsingCss->value['y']+$marge['t'],
6020
-                $this->parsingCss->value['width'],
6021
-                $this->parsingCss->value['height']
6022
-            );
6023
-
6024
-            // left and right of the DRAW tag
6025
-            $mL = $this->parsingCss->value['x']+$marge['l'];
6026
-            $mR = $this->pdf->getW() - $mL - $overW;
6027
-
6028
-            // position of the DRAW tag
6029
-            $x = $this->parsingCss->value['x']+$marge['l'];
6030
-            $y = $this->parsingCss->value['y']+$marge['t'];
6031
-
6032
-            // prepare the drawing area
6033
-            $this->_saveMargin($mL, 0, $mR);
6034
-            $this->pdf->setXY($x, $y);
6035
-
6036
-            // we are in a draw tag
6037
-            $this->_isInDraw = array(
6038
-                'x' => $x,
6039
-                'y' => $y,
6040
-                'w' => $overW,
6041
-                'h' => $overH,
6042
-            );
6043
-
6044
-            // init the translate matrix : (0,0) => ($x, $y)
6045
-            $this->pdf->doTransform(array(1,0,0,1,$x,$y));
6046
-            $this->pdf->SetAlpha(1.);
6047
-            return true;
6048
-        }
6049
-
6050
-        /**
6051
-         * tag : DRAW
6052
-         * mode : CLOSE
6053
-         *
6054
-         * @param  array $param
6055
-         * @return boolean
6056
-         */
6057
-        protected function _tag_close_DRAW($param)
6058
-        {
6059
-            if ($this->_isForOneLine) return false;
6060
-
6061
-            $this->pdf->SetAlpha(1.);
6062
-            $this->pdf->undoTransform();
6063
-            $this->pdf->clippingPathStop();
6064
-
6065
-            $this->_maxX = $this->parsingCss->value['old_maxX'];
6066
-            $this->_maxY = $this->parsingCss->value['old_maxY'];
6067
-            $this->_maxH = $this->parsingCss->value['old_maxH'];
6068
-
6069
-            $marge = array();
6070
-            $marge['l'] = $this->parsingCss->value['border']['l']['width'];
6071
-            $marge['r'] = $this->parsingCss->value['border']['r']['width'];
6072
-            $marge['t'] = $this->parsingCss->value['border']['t']['width'];
6073
-            $marge['b'] = $this->parsingCss->value['border']['b']['width'];
6074
-
6075
-            $x = $this->parsingCss->value['x'];
6076
-            $y = $this->parsingCss->value['y'];
6077
-            $w = $this->parsingCss->value['width']+$marge['l']+$marge['r'];
6078
-            $h = $this->parsingCss->value['height']+$marge['t']+$marge['b'];
6079
-
6080
-            if ($this->parsingCss->value['position']!='absolute') {
6081
-                $this->pdf->setXY($x+$w, $y);
6082
-
6083
-                $this->_maxX = max($this->_maxX, $x+$w);
6084
-                $this->_maxY = max($this->_maxY, $y+$h);
6085
-                $this->_maxH = max($this->_maxH, $h);
6086
-                $this->_maxE++;
6087
-            } else {
6088
-                // position
6089
-                $this->pdf->setXY($this->parsingCss->value['xc'], $this->parsingCss->value['yc']);
6090
-
6091
-                $this->_loadMax();
6092
-            }
6093
-
6094
-            $block = ($this->parsingCss->value['display']!='inline' && $this->parsingCss->value['position']!='absolute');
6095
-
6096
-            $this->parsingCss->load();
6097
-            $this->parsingCss->fontSet();
6098
-            $this->_loadMargin();
6099
-
6100
-            if ($block) $this->_tag_open_BR(array());
6101
-            if ($this->_debugActif) $this->_DEBUG_add('DRAW', false);
6102
-
6103
-            $this->_isInDraw = null;
6104
-
6105
-            return true;
6106
-        }
6107
-
6108
-        /**
6109
-         * tag : LINE
6110
-         * mode : OPEN
6111
-         *
6112
-         * @param  array $param
6113
-         * @return boolean
6114
-         */
6115
-        protected function _tag_open_LINE($param)
6116
-        {
6117
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'LINE');
6118
-
6119
-            $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6120
-            $this->parsingCss->save();
6121
-            $styles = $this->parsingCss->getSvgStyle('path', $param);
6122
-            $styles['fill'] = null;
6123
-            $style = $this->pdf->svgSetStyle($styles);
6124
-
6125
-            $x1 = isset($param['x1']) ? $this->parsingCss->ConvertToMM($param['x1'], $this->_isInDraw['w']) : 0.;
6126
-            $y1 = isset($param['y1']) ? $this->parsingCss->ConvertToMM($param['y1'], $this->_isInDraw['h']) : 0.;
6127
-            $x2 = isset($param['x2']) ? $this->parsingCss->ConvertToMM($param['x2'], $this->_isInDraw['w']) : 0.;
6128
-            $y2 = isset($param['y2']) ? $this->parsingCss->ConvertToMM($param['y2'], $this->_isInDraw['h']) : 0.;
6129
-            $this->pdf->svgLine($x1, $y1, $x2, $y2);
6130
-
6131
-            $this->pdf->undoTransform();
6132
-            $this->parsingCss->load();
6133
-        }
6134
-
6135
-        /**
6136
-         * tag : RECT
6137
-         * mode : OPEN
6138
-         *
6139
-         * @param  array $param
6140
-         * @return boolean
6141
-         */
6142
-        protected function _tag_open_RECT($param)
6143
-        {
6144
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'RECT');
6145
-
6146
-            $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6147
-            $this->parsingCss->save();
6148
-            $styles = $this->parsingCss->getSvgStyle('path', $param);
6149
-            $style = $this->pdf->svgSetStyle($styles);
6150
-
6151
-            $x = isset($param['x']) ? $this->parsingCss->ConvertToMM($param['x'], $this->_isInDraw['w']) : 0.;
6152
-            $y = isset($param['y']) ? $this->parsingCss->ConvertToMM($param['y'], $this->_isInDraw['h']) : 0.;
6153
-            $w = isset($param['w']) ? $this->parsingCss->ConvertToMM($param['w'], $this->_isInDraw['w']) : 0.;
6154
-            $h = isset($param['h']) ? $this->parsingCss->ConvertToMM($param['h'], $this->_isInDraw['h']) : 0.;
6155
-
6156
-            $this->pdf->svgRect($x, $y, $w, $h, $style);
6157
-
6158
-            $this->pdf->undoTransform();
6159
-            $this->parsingCss->load();
6160
-        }
6161
-
6162
-        /**
6163
-         * tag : CIRCLE
6164
-         * mode : OPEN
6165
-         *
6166
-         * @param  array $param
6167
-         * @return boolean
6168
-         */
6169
-        protected function _tag_open_CIRCLE($param)
6170
-        {
6171
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'CIRCLE');
6172
-
6173
-            $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6174
-            $this->parsingCss->save();
6175
-            $styles = $this->parsingCss->getSvgStyle('path', $param);
6176
-            $style = $this->pdf->svgSetStyle($styles);
6177
-
6178
-            $cx = isset($param['cx']) ? $this->parsingCss->ConvertToMM($param['cx'], $this->_isInDraw['w']) : 0.;
6179
-            $cy = isset($param['cy']) ? $this->parsingCss->ConvertToMM($param['cy'], $this->_isInDraw['h']) : 0.;
6180
-            $r = isset($param['r']) ? $this->parsingCss->ConvertToMM($param['r'], $this->_isInDraw['w']) : 0.;
6181
-            $this->pdf->svgEllipse($cx, $cy, $r, $r, $style);
6182
-
6183
-            $this->pdf->undoTransform();
6184
-            $this->parsingCss->load();
6185
-        }
6186
-
6187
-        /**
6188
-         * tag : ELLIPSE
6189
-         * mode : OPEN
6190
-         *
6191
-         * @param  array $param
6192
-         * @return boolean
6193
-         */
6194
-        protected function _tag_open_ELLIPSE($param)
6195
-        {
6196
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'ELLIPSE');
6197
-
6198
-            $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6199
-            $this->parsingCss->save();
6200
-            $styles = $this->parsingCss->getSvgStyle('path', $param);
6201
-            $style = $this->pdf->svgSetStyle($styles);
6202
-
6203
-            $cx = isset($param['cx']) ? $this->parsingCss->ConvertToMM($param['cx'], $this->_isInDraw['w']) : 0.;
6204
-            $cy = isset($param['cy']) ? $this->parsingCss->ConvertToMM($param['cy'], $this->_isInDraw['h']) : 0.;
6205
-            $rx = isset($param['ry']) ? $this->parsingCss->ConvertToMM($param['rx'], $this->_isInDraw['w']) : 0.;
6206
-            $ry = isset($param['rx']) ? $this->parsingCss->ConvertToMM($param['ry'], $this->_isInDraw['h']) : 0.;
6207
-            $this->pdf->svgEllipse($cx, $cy, $rx, $ry, $style);
6208
-
6209
-            $this->pdf->undoTransform();
6210
-            $this->parsingCss->load();
6211
-        }
6212
-
6213
-
6214
-        /**
6215
-         * tag : POLYLINE
6216
-         * mode : OPEN
6217
-         *
6218
-         * @param  array $param
6219
-         * @return boolean
6220
-         */
6221
-        protected function _tag_open_POLYLINE($param)
6222
-        {
6223
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON');
6224
-
6225
-            $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6226
-            $this->parsingCss->save();
6227
-            $styles = $this->parsingCss->getSvgStyle('path', $param);
6228
-            $style = $this->pdf->svgSetStyle($styles);
6229
-
6230
-            $path = isset($param['points']) ? $param['points'] : null;
6231
-            if ($path) {
6232
-                $path = str_replace(',', ' ', $path);
6233
-                $path = preg_replace('/[\s]+/', ' ', trim($path));
6234
-
6235
-                // prepare the path
6236
-                $path = explode(' ', $path);
6237
-                foreach ($path as $k => $v) {
6238
-                    $path[$k] = trim($v);
6239
-                    if ($path[$k]==='') unset($path[$k]);
6240
-                }
6241
-                $path = array_values($path);
6242
-
6243
-                $actions = array();
6244
-                for ($k=0; $k<count($path); $k+=2) {
6245
-                    $actions[] = array(
6246
-                        ($k ? 'L' : 'M') ,
6247
-                        $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']),
6248
-                        $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h'])
6249
-                    );
6250
-                }
6251
-
6252
-                // drawing
6253
-                $this->pdf->svgPolygone($actions, $style);
6254
-            }
6255
-
6256
-            $this->pdf->undoTransform();
6257
-            $this->parsingCss->load();
6258
-        }
6259
-
6260
-        /**
6261
-         * tag : POLYGON
6262
-         * mode : OPEN
6263
-         *
6264
-         * @param  array $param
6265
-         * @return boolean
6266
-         */
6267
-        protected function _tag_open_POLYGON($param)
6268
-        {
6269
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON');
6270
-
6271
-            $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6272
-            $this->parsingCss->save();
6273
-            $styles = $this->parsingCss->getSvgStyle('path', $param);
6274
-            $style = $this->pdf->svgSetStyle($styles);
6275
-
6276
-            $path = (isset($param['points']) ? $param['points'] : null);
6277
-            if ($path) {
6278
-                $path = str_replace(',', ' ', $path);
6279
-                $path = preg_replace('/[\s]+/', ' ', trim($path));
6280
-
6281
-                // prepare the path
6282
-                $path = explode(' ', $path);
6283
-                foreach ($path as $k => $v) {
6284
-                    $path[$k] = trim($v);
6285
-                    if ($path[$k]==='') unset($path[$k]);
6286
-                }
6287
-                $path = array_values($path);
6288
-
6289
-                $actions = array();
6290
-                for ($k=0; $k<count($path); $k+=2) {
6291
-                    $actions[] = array(
6292
-                        ($k ? 'L' : 'M') ,
6293
-                        $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']),
6294
-                        $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h'])
6295
-                    );
6296
-                }
6297
-                $actions[] = array('z');
6298
-
6299
-                // drawing
6300
-                $this->pdf->svgPolygone($actions, $style);
6301
-            }
6302
-
6303
-            $this->pdf->undoTransform();
6304
-            $this->parsingCss->load();
6305
-        }
6306
-
6307
-        /**
6308
-         * tag : PATH
6309
-         * mode : OPEN
6310
-         *
6311
-         * @param  array $param
6312
-         * @return boolean
6313
-         */
6314
-        protected function _tag_open_PATH($param)
6315
-        {
6316
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'PATH');
6317
-
6318
-            $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6319
-            $this->parsingCss->save();
6320
-            $styles = $this->parsingCss->getSvgStyle('path', $param);
6321
-            $style = $this->pdf->svgSetStyle($styles);
6322
-
6323
-            $path = isset($param['d']) ? $param['d'] : null;
6324
-
6325
-            if ($path) {
6326
-                // prepare the path
6327
-                $path = str_replace(',', ' ', $path);
6328
-                $path = preg_replace('/([a-zA-Z])([0-9\.\-])/', '$1 $2', $path);
6329
-                $path = preg_replace('/([0-9\.])([a-zA-Z])/', '$1 $2', $path);
6330
-                $path = preg_replace('/[\s]+/', ' ', trim($path));
6331
-                $path = preg_replace('/ ([a-z]{2})/', '$1', $path);
6332
-
6333
-                $path = explode(' ', $path);
6334
-                foreach ($path as $k => $v) {
6335
-                    $path[$k] = trim($v);
6336
-                    if ($path[$k]==='') unset($path[$k]);
6337
-                }
6338
-                $path = array_values($path);
6339
-
6340
-                // read each actions in the path
6341
-                $actions = array();
6342
-                $action = array();
6343
-                $lastAction = null; // last action found
6344
-                for ($k=0; $k<count($path);true) {
6345
-
6346
-                    // for this actions, we can not have multi coordonate
6347
-                    if (in_array($lastAction, array('z', 'Z'))) {
6348
-                        $lastAction = null;
6349
-                    }
6350
-
6351
-                    // read the new action (forcing if no action before)
6352
-                    if (preg_match('/^[a-z]+$/i', $path[$k]) || $lastAction===null) {
6353
-                        $lastAction = $path[$k];
6354
-                        $k++;
6355
-                    }
6356
-
6357
-                    // current action
6358
-                    $action = array();
6359
-                    $action[] = $lastAction;
6360
-                    switch($lastAction)
6361
-                    {
6362
-                        case 'C':
6363
-                        case 'c':
6364
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // x1
6365
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']);    // y1
6366
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+2], $this->_isInDraw['w']);    // x2
6367
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+3], $this->_isInDraw['h']);    // y2
6368
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+4], $this->_isInDraw['w']);    // x
6369
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+5], $this->_isInDraw['h']);    // y
6370
-                            $k+= 6;
6371
-                            break;
6372
-
6373
-                        case 'Q':
6374
-                        case 'S':
6375
-                        case 'q':
6376
-                        case 's':
6377
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // x2
6378
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']);    // y2
6379
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+2], $this->_isInDraw['w']);    // x
6380
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+3], $this->_isInDraw['h']);    // y
6381
-                            $k+= 4;
6382
-                            break;
6383
-
6384
-                        case 'A':
6385
-                        case 'a':
6386
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // rx
6387
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']);    // ry
6388
-                            $action[] = 1.*$path[$k+2];                                                        // angle de deviation de l'axe X
6389
-                            $action[] = ($path[$k+3]=='1') ? 1 : 0;                                            // large-arc-flag
6390
-                            $action[] = ($path[$k+4]=='1') ? 1 : 0;                                            // sweep-flag
6391
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+5], $this->_isInDraw['w']);    // x
6392
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+6], $this->_isInDraw['h']);    // y
6393
-                            $k+= 7;
6394
-                            break;
6395
-
6396
-                        case 'M':
6397
-                        case 'L':
6398
-                        case 'T':
6399
-                        case 'm':
6400
-                        case 'l':
6401
-                        case 't':
6402
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // x
6403
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']);    // y
6404
-                            $k+= 2;
6405
-                            break;
6406
-
6407
-                        case 'H':
6408
-                        case 'h':
6409
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // x
6410
-                            $k+= 1;
6411
-                            break;
6412
-
6413
-                        case 'V':
6414
-                        case 'v':
6415
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['h']);    // y
6416
-                            $k+= 1;
6417
-                            break;
6418
-
6419
-                        case 'z':
6420
-                        case 'Z':
6421
-                        default:
6422
-                            break;
6423
-                    }
6424
-                    // add the action
6425
-                    $actions[] = $action;
6426
-                }
6427
-
6428
-                // drawing
6429
-                $this->pdf->svgPolygone($actions, $style);
6430
-            }
6431
-
6432
-            $this->pdf->undoTransform();
6433
-            $this->parsingCss->load();
6434
-        }
6435
-
6436
-        /**
6437
-         * tag : G
6438
-         * mode : OPEN
6439
-         *
6440
-         * @param  array $param
6441
-         * @return boolean
6442
-         */
6443
-        protected function _tag_open_G($param)
6444
-        {
6445
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'G');
6446
-
6447
-            $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6448
-            $this->parsingCss->save();
6449
-            $styles = $this->parsingCss->getSvgStyle('path', $param);
6450
-            $style = $this->pdf->svgSetStyle($styles);
6451
-        }
6452
-
6453
-        /**
6454
-         * tag : G
6455
-         * mode : CLOSE
6456
-         *
6457
-         * @param  array $param
6458
-         * @return boolean
6459
-         */
6460
-        protected function _tag_close_G($param)
6461
-        {
6462
-            $this->pdf->undoTransform();
6463
-            $this->parsingCss->load();
6464
-        }
6465
-
6466
-        /**
6467
-         * new page for the automatic Index, does not use thie method. Only HTML2PDF_myPdf could use it !!!!
6468
-         *
6469
-         * @param  &int $page
6470
-         * @return integer $oldPage
6471
-         */
6472
-        public function _INDEX_NewPage(&$page)
6473
-        {
6474
-            if ($page) {
6475
-                $oldPage = $this->pdf->getPage();
6476
-                $this->pdf->setPage($page);
6477
-                $this->pdf->setXY($this->_margeLeft, $this->_margeTop);
6478
-                $this->_maxH = 0;
6479
-                $page++;
6480
-                return $oldPage;
6481
-            } else {
6482
-                $this->_setNewPage();
6483
-                return null;
6484
-            }
6485
-        }
6486
-
6487
-    }
501
+			exit;
502
+		}
503
+
504
+		/**
505
+		 * set the default margins of the page
506
+		 *
507
+		 * @access protected
508
+		 * @param  int $left   (mm, left margin)
509
+		 * @param  int $top    (mm, top margin)
510
+		 * @param  int $right  (mm, right margin, if null => left=right)
511
+		 * @param  int $bottom (mm, bottom margin, if null => bottom=8mm)
512
+		 */
513
+		protected function _setDefaultMargins($left, $top, $right = null, $bottom = null)
514
+		{
515
+			if ($right===null)  $right = $left;
516
+			if ($bottom===null) $bottom = 8;
517
+
518
+			$this->_defaultLeft   = $this->parsingCss->ConvertToMM($left.'mm');
519
+			$this->_defaultTop    = $this->parsingCss->ConvertToMM($top.'mm');
520
+			$this->_defaultRight  = $this->parsingCss->ConvertToMM($right.'mm');
521
+			$this->_defaultBottom = $this->parsingCss->ConvertToMM($bottom.'mm');
522
+		}
523
+
524
+		/**
525
+		 * create a new page
526
+		 *
527
+		 * @access protected
528
+		 * @param  mixed   $format
529
+		 * @param  string  $orientation
530
+		 * @param  array   $background background information
531
+		 * @param  integer $curr real position in the html parseur (if break line in the write of a text)
532
+		 * @param  boolean $resetPageNumber
533
+		 */
534
+		protected function _setNewPage($format = null, $orientation = '', $background = null, $curr = null, $resetPageNumber=false)
535
+		{
536
+			$this->_firstPage = false;
537
+
538
+			$this->_format = $format ? $format : $this->_format;
539
+			$this->_orientation = $orientation ? $orientation : $this->_orientation;
540
+			$this->_background = $background!==null ? $background : $this->_background;
541
+			$this->_maxY = 0;
542
+			$this->_maxX = 0;
543
+			$this->_maxH = 0;
544
+			$this->_maxE = 0;
545
+
546
+			$this->pdf->SetMargins($this->_defaultLeft, $this->_defaultTop, $this->_defaultRight);
547
+
548
+			if ($resetPageNumber) {
549
+				$this->pdf->startPageGroup();
550
+			}
551
+
552
+			$this->pdf->AddPage($this->_orientation, $this->_format);
553
+
554
+			if ($resetPageNumber) {
555
+				$this->pdf->myStartPageGroup();
556
+			}
557
+
558
+			$this->_page++;
559
+
560
+			if (!$this->_subPart && !$this->_isSubPart) {
561
+				if (is_array($this->_background)) {
562
+					if (isset($this->_background['color']) && $this->_background['color']) {
563
+						$this->pdf->setFillColorArray($this->_background['color']);
564
+						$this->pdf->Rect(0, 0, $this->pdf->getW(), $this->pdf->getH(), 'F');
565
+					}
566
+
567
+					if (isset($this->_background['img']) && $this->_background['img'])
568
+						$this->pdf->Image($this->_background['img'], $this->_background['posX'], $this->_background['posY'], $this->_background['width']);
569
+				}
570
+
571
+				$this->_setPageHeader();
572
+				$this->_setPageFooter();
573
+			}
574
+
575
+			$this->_setMargins();
576
+			$this->pdf->setY($this->_margeTop);
577
+
578
+			$this->_setNewPositionForNewLine($curr);
579
+			$this->_maxH = 0;
580
+		}
581
+
582
+		/**
583
+		 * set the real margin, using the default margins and the page margins
584
+		 *
585
+		 * @access protected
586
+		 */
587
+		protected function _setMargins()
588
+		{
589
+			// prepare the margins
590
+			$this->_margeLeft   = $this->_defaultLeft   + (isset($this->_background['left'])   ? $this->_background['left']   : 0);
591
+			$this->_margeRight  = $this->_defaultRight  + (isset($this->_background['right'])  ? $this->_background['right']  : 0);
592
+			$this->_margeTop    = $this->_defaultTop    + (isset($this->_background['top'])    ? $this->_background['top']    : 0);
593
+			$this->_margeBottom = $this->_defaultBottom + (isset($this->_background['bottom']) ? $this->_background['bottom'] : 0);
594
+
595
+			// set the PDF margins
596
+			$this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight);
597
+			$this->pdf->SetAutoPageBreak(false, $this->_margeBottom);
598
+
599
+			// set the float Margins
600
+			$this->_pageMarges = array();
601
+			if ($this->_isInParagraph!==false) {
602
+				$this->_pageMarges[floor($this->_margeTop*100)] = array($this->_isInParagraph[0], $this->pdf->getW()-$this->_isInParagraph[1]);
603
+			} else {
604
+				$this->_pageMarges[floor($this->_margeTop*100)] = array($this->_margeLeft, $this->pdf->getW()-$this->_margeRight);
605
+			}
606
+		}
607
+
608
+		/**
609
+		 * add a debug step
610
+		 *
611
+		 * @access protected
612
+		 * @param  string  $name step name
613
+		 * @param  boolean $level (true=up, false=down, null=nothing to do)
614
+		 * @return $this
615
+		 */
616
+		protected function _DEBUG_add($name, $level=null)
617
+		{
618
+			// if true : UP
619
+			if ($level===true) $this->_debugLevel++;
620
+
621
+			$name   = str_repeat('  ', $this->_debugLevel). $name.($level===true ? ' Begin' : ($level===false ? ' End' : ''));
622
+			$time  = microtime(true);
623
+			$usage = ($this->_debugOkUsage ? memory_get_usage() : 0);
624
+			$peak  = ($this->_debugOkPeak ? memory_get_peak_usage() : 0);
625
+
626
+			$this->_DEBUG_stepline(
627
+				$name,
628
+				number_format(($time - $this->_debugStartTime)*1000, 1, '.', ' ').' ms',
629
+				number_format(($time - $this->_debugLastTime)*1000, 1, '.', ' ').' ms',
630
+				number_format($usage/1024, 1, '.', ' ').' Ko',
631
+				number_format($peak/1024, 1, '.', ' ').' Ko'
632
+			);
633
+
634
+			$this->_debugLastTime = $time;
635
+
636
+			// it false : DOWN
637
+			if ($level===false) $this->_debugLevel--;
638
+
639
+			return $this;
640
+		}
641
+
642
+		/**
643
+		 * display a debug line
644
+		 *
645
+		 *
646
+		 * @access protected
647
+		 * @param  string $name
648
+		 * @param  string $timeTotal
649
+		 * @param  string $timeStep
650
+		 * @param  string $memoryUsage
651
+		 * @param  string $memoryPeak
652
+		 */
653
+		protected function _DEBUG_stepline($name, $timeTotal, $timeStep, $memoryUsage, $memoryPeak)
654
+		{
655
+			$txt = str_pad($name, 30, ' ', STR_PAD_RIGHT).
656
+					str_pad($timeTotal, 12, ' ', STR_PAD_LEFT).
657
+					str_pad($timeStep, 12, ' ', STR_PAD_LEFT).
658
+					str_pad($memoryUsage, 15, ' ', STR_PAD_LEFT).
659
+					str_pad($memoryPeak, 15, ' ', STR_PAD_LEFT);
660
+
661
+			echo '<pre style="padding:0; margin:0">'.$txt.'</pre>';
662
+		}
663
+
664
+		/**
665
+		 * get the Min and Max X, for Y (use the float margins)
666
+		 *
667
+		 * @access protected
668
+		 * @param  float $y
669
+		 * @return array(float, float)
670
+		 */
671
+		protected function _getMargins($y)
672
+		{
673
+			$y = floor($y*100);
674
+			$x = array($this->pdf->getlMargin(), $this->pdf->getW()-$this->pdf->getrMargin());
675
+
676
+			foreach ($this->_pageMarges as $mY => $mX)
677
+				if ($mY<=$y) $x = $mX;
678
+
679
+			return $x;
680
+		}
681
+
682
+		/**
683
+		 * Add margins, for a float
684
+		 *
685
+		 * @access protected
686
+		 * @param  string $float (left / right)
687
+		 * @param  float  $xLeft
688
+		 * @param  float  $yTop
689
+		 * @param  float  $xRight
690
+		 * @param  float  $yBottom
691
+		 */
692
+		protected function _addMargins($float, $xLeft, $yTop, $xRight, $yBottom)
693
+		{
694
+			// get the current float margins, for top and bottom
695
+			$oldTop    = $this->_getMargins($yTop);
696
+			$oldBottom = $this->_getMargins($yBottom);
697
+
698
+			// update the top float margin
699
+			if ($float=='left'  && $oldTop[0]<$xRight) $oldTop[0] = $xRight;
700
+			if ($float=='right' && $oldTop[1]>$xLeft)  $oldTop[1] = $xLeft;
701
+
702
+			$yTop = floor($yTop*100);
703
+			$yBottom = floor($yBottom*100);
704
+
705
+			// erase all the float margins that are smaller than the new one
706
+			foreach ($this->_pageMarges as $mY => $mX) {
707
+				if ($mY<$yTop) continue;
708
+				if ($mY>$yBottom) break;
709
+				if ($float=='left' && $this->_pageMarges[$mY][0]<$xRight)  unset($this->_pageMarges[$mY]);
710
+				if ($float=='right' && $this->_pageMarges[$mY][1]>$xLeft) unset($this->_pageMarges[$mY]);
711
+			}
712
+
713
+			// save the new Top and Bottom margins
714
+			$this->_pageMarges[$yTop] = $oldTop;
715
+			$this->_pageMarges[$yBottom] = $oldBottom;
716
+
717
+			// sort the margins
718
+			ksort($this->_pageMarges);
719
+
720
+			// we are just after float
721
+			$this->_isAfterFloat = true;
722
+		}
723
+
724
+		/**
725
+		 * Save old margins (push), and set new ones
726
+		 *
727
+		 * @access protected
728
+		 * @param  float  $ml left margin
729
+		 * @param  float  $mt top margin
730
+		 * @param  float  $mr right margin
731
+		 */
732
+		protected function _saveMargin($ml, $mt, $mr)
733
+		{
734
+			// save old margins
735
+			$this->_marges[] = array('l' => $this->pdf->getlMargin(), 't' => $this->pdf->gettMargin(), 'r' => $this->pdf->getrMargin(), 'page' => $this->_pageMarges);
736
+
737
+			// set new ones
738
+			$this->pdf->SetMargins($ml, $mt, $mr);
739
+
740
+			// prepare for float margins
741
+			$this->_pageMarges = array();
742
+			$this->_pageMarges[floor($mt*100)] = array($ml, $this->pdf->getW()-$mr);
743
+		}
744
+
745
+		/**
746
+		 * load the last saved margins (pop)
747
+		 *
748
+		 * @access protected
749
+		 */
750
+		protected function _loadMargin()
751
+		{
752
+			$old = array_pop($this->_marges);
753
+			if ($old) {
754
+				$ml = $old['l'];
755
+				$mt = $old['t'];
756
+				$mr = $old['r'];
757
+				$mP = $old['page'];
758
+			} else {
759
+				$ml = $this->_margeLeft;
760
+				$mt = 0;
761
+				$mr = $this->_margeRight;
762
+				$mP = array($mt => array($ml, $this->pdf->getW()-$mr));
763
+			}
764
+
765
+			$this->pdf->SetMargins($ml, $mt, $mr);
766
+			$this->_pageMarges = $mP;
767
+		}
768
+
769
+		/**
770
+		 * save the current maxs (push)
771
+		 *
772
+		 * @access protected
773
+		 */
774
+		protected function _saveMax()
775
+		{
776
+			$this->_maxSave[] = array($this->_maxX, $this->_maxY, $this->_maxH, $this->_maxE);
777
+		}
778
+
779
+		/**
780
+		 * load the last saved current maxs (pop)
781
+		 *
782
+		 * @access protected
783
+		 */
784
+		protected function _loadMax()
785
+		{
786
+			$old = array_pop($this->_maxSave);
787
+
788
+			if ($old) {
789
+				$this->_maxX = $old[0];
790
+				$this->_maxY = $old[1];
791
+				$this->_maxH = $old[2];
792
+				$this->_maxE = $old[3];
793
+			} else {
794
+				$this->_maxX = 0;
795
+				$this->_maxY = 0;
796
+				$this->_maxH = 0;
797
+				$this->_maxE = 0;
798
+			}
799
+		}
800
+
801
+		/**
802
+		 * draw the PDF header with the HTML in page_header
803
+		 *
804
+		 * @access protected
805
+		 */
806
+		protected function _setPageHeader()
807
+		{
808
+			if (!count($this->_subHEADER)) return false;
809
+
810
+			$oldParsePos = $this->_parsePos;
811
+			$oldParseCode = $this->parsingHtml->code;
812
+
813
+			$this->_parsePos = 0;
814
+			$this->parsingHtml->code = $this->_subHEADER;
815
+			$this->_makeHTMLcode();
816
+
817
+			$this->_parsePos = $oldParsePos;
818
+			$this->parsingHtml->code = $oldParseCode;
819
+		}
820
+
821
+		/**
822
+		 * draw the PDF footer with the HTML in page_footer
823
+		 *
824
+		 * @access protected
825
+		 */
826
+		protected function _setPageFooter()
827
+		{
828
+			if (!count($this->_subFOOTER)) return false;
829
+
830
+			$oldParsePos = $this->_parsePos;
831
+			$oldParseCode = $this->parsingHtml->code;
832
+
833
+			$this->_parsePos = 0;
834
+			$this->parsingHtml->code = $this->_subFOOTER;
835
+			$this->_isInFooter = true;
836
+			$this->_makeHTMLcode();
837
+			$this->_isInFooter = false;
838
+
839
+			$this->_parsePos = $oldParsePos;
840
+			$this->parsingHtml->code = $oldParseCode;
841
+		}
842
+
843
+		/**
844
+		 * new line, with a specific height
845
+		 *
846
+		 * @access protected
847
+		 * @param float   $h
848
+		 * @param integer $curr real current position in the text, if new line in the write of a text
849
+		 */
850
+		protected function _setNewLine($h, $curr = null)
851
+		{
852
+			$this->pdf->Ln($h);
853
+			$this->_setNewPositionForNewLine($curr);
854
+		}
855
+
856
+		/**
857
+		 * calculate the start position of the next line,  depending on the text-align
858
+		 *
859
+		 * @access protected
860
+		 * @param  integer $curr real current position in the text, if new line in the write of a text
861
+		 */
862
+		protected function _setNewPositionForNewLine($curr = null)
863
+		{
864
+			// get the margins for the current line
865
+			list($lx, $rx) = $this->_getMargins($this->pdf->getY());
866
+			$this->pdf->setX($lx);
867
+			$wMax = $rx-$lx;
868
+			$this->_currentH = 0;
869
+
870
+			// if subPart => return because align left
871
+			if ($this->_subPart || $this->_isSubPart || $this->_isForOneLine) {
872
+				$this->pdf->setWordSpacing(0);
873
+				return null;
874
+			}
875
+
876
+			// create the sub object
877
+			$sub = null;
878
+			$this->_createSubHTML($sub);
879
+			$sub->_saveMargin(0, 0, $sub->pdf->getW()-$wMax);
880
+			$sub->_isForOneLine = true;
881
+			$sub->_parsePos = $this->_parsePos;
882
+			$sub->parsingHtml->code = $this->parsingHtml->code;
883
+
884
+			// if $curr => adapt the current position of the parsing
885
+			if ($curr!==null && $sub->parsingHtml->code[$this->_parsePos]['name']=='write') {
886
+				$txt = $sub->parsingHtml->code[$this->_parsePos]['param']['txt'];
887
+				$txt = str_replace('[[page_cu]]', $sub->pdf->getMyNumPage($this->_page), $txt);
888
+				$sub->parsingHtml->code[$this->_parsePos]['param']['txt'] = substr($txt, $curr+1);
889
+			} else
890
+				$sub->_parsePos++;
891
+
892
+			// for each element of the parsing => load the action
893
+			$res = null;
894
+			for ($sub->_parsePos; $sub->_parsePos<count($sub->parsingHtml->code); $sub->_parsePos++) {
895
+				$action = $sub->parsingHtml->code[$sub->_parsePos];
896
+				$res = $sub->_executeAction($action);
897
+				if (!$res) break;
898
+			}
899
+
900
+			$w = $sub->_maxX; // max width
901
+			$h = $sub->_maxH; // max height
902
+			$e = ($res===null ? $sub->_maxE : 0); // maxnumber of elemets on the line
903
+
904
+			// destroy the sub HTML
905
+			$this->_destroySubHTML($sub);
906
+
907
+			// adapt the start of the line, depending on the text-align
908
+			if ($this->parsingCss->value['text-align']=='center')
909
+				$this->pdf->setX(($rx+$this->pdf->getX()-$w)*0.5-0.01);
910
+			else if ($this->parsingCss->value['text-align']=='right')
911
+				$this->pdf->setX($rx-$w-0.01);
912
+			else
913
+				$this->pdf->setX($lx);
914
+
915
+			// set the height of the line
916
+			$this->_currentH = $h;
917
+
918
+			// if justify => set the word spacing
919
+			if ($this->parsingCss->value['text-align']=='justify' && $e>1) {
920
+				$this->pdf->setWordSpacing(($wMax-$w)/($e-1));
921
+			} else {
922
+				$this->pdf->setWordSpacing(0);
923
+			}
924
+		}
925
+
926
+		/**
927
+		 * prepare HTML2PDF::$_subobj (used for create the sub HTML2PDF objects
928
+		 *
929
+		 * @access protected
930
+		 */
931
+		protected function _prepareSubObj()
932
+		{
933
+			$pdf = null;
934
+
935
+			// create the sub object
936
+			HTML2PDF::$_subobj = new HTML2PDF(
937
+										$this->_orientation,
938
+										$this->_format,
939
+										$this->_langue,
940
+										$this->_unicode,
941
+										$this->_encoding,
942
+										array($this->_defaultLeft,$this->_defaultTop,$this->_defaultRight,$this->_defaultBottom)
943
+									);
944
+
945
+			// init
946
+			HTML2PDF::$_subobj->setTestTdInOnePage($this->_testTdInOnepage);
947
+			HTML2PDF::$_subobj->setTestIsImage($this->_testIsImage);
948
+			HTML2PDF::$_subobj->setTestIsDeprecated($this->_testIsDeprecated);
949
+			HTML2PDF::$_subobj->setDefaultFont($this->_defaultFont);
950
+			HTML2PDF::$_subobj->parsingCss->css            = &$this->parsingCss->css;
951
+			HTML2PDF::$_subobj->parsingCss->cssKeys        = &$this->parsingCss->cssKeys;
952
+
953
+			// clone font from the original PDF
954
+			HTML2PDF::$_subobj->pdf->cloneFontFrom($this->pdf);
955
+
956
+			// remove the link to the parent
957
+			HTML2PDF::$_subobj->parsingCss->setPdfParent($pdf);
958
+		}
959
+
960
+		/**
961
+		 * create a sub HTML2PDF, to calculate the multi-tables
962
+		 *
963
+		 * @access protected
964
+		 * @param  &HTML2PDF $subHtml sub HTML2PDF to create
965
+		 * @param  integer   $cellmargin if in a TD : cellmargin of this td
966
+		 */
967
+		protected function _createSubHTML(&$subHtml, $cellmargin=0)
968
+		{
969
+			// prepare the subObject, if never prepare before
970
+			if (HTML2PDF::$_subobj===null) {
971
+				$this->_prepareSubObj();
972
+			}
973
+
974
+			// calculate the width to use
975
+			if ($this->parsingCss->value['width']) {
976
+				$marge = $cellmargin*2;
977
+				$marge+= $this->parsingCss->value['padding']['l'] + $this->parsingCss->value['padding']['r'];
978
+				$marge+= $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['border']['r']['width'];
979
+				$marge = $this->pdf->getW() - $this->parsingCss->value['width'] + $marge;
980
+			} else {
981
+				$marge = $this->_margeLeft+$this->_margeRight;
982
+			}
983
+
984
+			// BUGFIX : we have to call the method, because of a bug in php 5.1.6
985
+			HTML2PDF::$_subobj->pdf->getPage();
986
+
987
+			// clone the sub oject
988
+			$subHtml = clone HTML2PDF::$_subobj;
989
+			$subHtml->parsingCss->table = $this->parsingCss->table;
990
+			$subHtml->parsingCss->value = $this->parsingCss->value;
991
+			$subHtml->initSubHtml(
992
+				$this->_format,
993
+				$this->_orientation,
994
+				$marge,
995
+				$this->_page,
996
+				$this->_defList,
997
+				$this->pdf->getMyLastPageGroup(),
998
+				$this->pdf->getMyLastPageGroupNb()
999
+			);
1000
+		}
1001
+
1002
+		/**
1003
+		 * destroy a subHTML2PDF
1004
+		 *
1005
+		 * @access protected
1006
+		 */
1007
+		protected function _destroySubHTML(&$subHtml)
1008
+		{
1009
+			unset($subHtml);
1010
+			$subHtml = null;
1011
+		}
1012
+
1013
+		/**
1014
+		 * Convert a arabic number in roman number
1015
+		 *
1016
+		 * @access protected
1017
+		 * @param  integer $nbArabic
1018
+		 * @return string  $nbRoman
1019
+		 */
1020
+		protected function _listeArab2Rom($nbArabic)
1021
+		{
1022
+			$nbBaseTen    = array('I','X','C','M');
1023
+			$nbBaseFive    = array('V','L','D');
1024
+			$nbRoman    = '';
1025
+
1026
+			if ($nbArabic<1)    return $nbArabic;
1027
+			if ($nbArabic>3999) return $nbArabic;
1028
+
1029
+			for ($i=3; $i>=0 ; $i--) {
1030
+				$chiffre=floor($nbArabic/pow(10, $i));
1031
+				if ($chiffre>=1) {
1032
+					$nbArabic=$nbArabic-$chiffre*pow(10, $i);
1033
+					if ($chiffre<=3) {
1034
+						for ($j=$chiffre; $j>=1; $j--) {
1035
+							$nbRoman=$nbRoman.$nbBaseTen[$i];
1036
+						}
1037
+					} else if ($chiffre==9) {
1038
+						$nbRoman=$nbRoman.$nbBaseTen[$i].$nbBaseTen[$i+1];
1039
+					} else if ($chiffre==4) {
1040
+					$nbRoman=$nbRoman.$nbBaseTen[$i].$nbBaseFive[$i];
1041
+					} else {
1042
+						$nbRoman=$nbRoman.$nbBaseFive[$i];
1043
+						for ($j=$chiffre-5; $j>=1; $j--) {
1044
+							$nbRoman=$nbRoman.$nbBaseTen[$i];
1045
+						}
1046
+					}
1047
+				}
1048
+			}
1049
+			return $nbRoman;
1050
+		}
1051
+
1052
+		/**
1053
+		 * add a LI to the current level
1054
+		 *
1055
+		 * @access protected
1056
+		 */
1057
+		protected function _listeAddLi()
1058
+		{
1059
+			$this->_defList[count($this->_defList)-1]['nb']++;
1060
+		}
1061
+
1062
+		/**
1063
+		 * get the width to use for the column of the list
1064
+		 *
1065
+		 * @access protected
1066
+		 * @return string $width
1067
+		 */
1068
+		protected function _listeGetWidth()
1069
+		{
1070
+			return '7mm';
1071
+		}
1072
+
1073
+		/**
1074
+		 * get the padding to use for the column of the list
1075
+		 *
1076
+		 * @access protected
1077
+		 * @return string $padding
1078
+		 */
1079
+		protected function _listeGetPadding()
1080
+		{
1081
+			return '1mm';
1082
+		}
1083
+
1084
+		/**
1085
+		 * get the information of the li on the current level
1086
+		 *
1087
+		 * @access protected
1088
+		 * @return array(fontName, small size, string)
1089
+		 */
1090
+		protected function _listeGetLi()
1091
+		{
1092
+			$im = $this->_defList[count($this->_defList)-1]['img'];
1093
+			$st = $this->_defList[count($this->_defList)-1]['style'];
1094
+			$nb = $this->_defList[count($this->_defList)-1]['nb'];
1095
+			$up = (substr($st, 0, 6)=='upper-');
1096
+
1097
+			if ($im) return array(false, false, $im);
1098
+
1099
+			switch($st)
1100
+			{
1101
+				case 'none':
1102
+					return array('helvetica', true, ' ');
1103
+
1104
+				case 'upper-alpha':
1105
+				case 'lower-alpha':
1106
+					$str = '';
1107
+					while ($nb>26) {
1108
+						$str = chr(96+$nb%26).$str;
1109
+						$nb = floor($nb/26);
1110
+					}
1111
+					$str = chr(96+$nb).$str;
1112
+
1113
+					return array('helvetica', false, ($up ? strtoupper($str) : $str).'.');
1114
+
1115
+				case 'upper-roman':
1116
+				case 'lower-roman':
1117
+					$str = $this->_listeArab2Rom($nb);
1118
+
1119
+					return array('helvetica', false, ($up ? strtoupper($str) : $str).'.');
1120
+
1121
+				case 'decimal':
1122
+					return array('helvetica', false, $nb.'.');
1123
+
1124
+				case 'square':
1125
+					return array('zapfdingbats', true, chr(110));
1126
+
1127
+				case 'circle':
1128
+					return array('zapfdingbats', true, chr(109));
1129
+
1130
+				case 'disc':
1131
+				default:
1132
+					return array('zapfdingbats', true, chr(108));
1133
+			}
1134
+		}
1135
+
1136
+		/**
1137
+		 * add a level to the list
1138
+		 *
1139
+		 * @access protected
1140
+		 * @param  string $type  : ul, ol
1141
+		 * @param  string $style : lower-alpha, ...
1142
+		 * @param  string $img
1143
+		 */
1144
+		protected function _listeAddLevel($type = 'ul', $style = '', $img = null)
1145
+		{
1146
+			// get the url of the image, if we want to use a image
1147
+			if ($img) {
1148
+				if (preg_match('/^url\(([^)]+)\)$/isU', trim($img), $match)) {
1149
+					$img = $match[1];
1150
+				} else {
1151
+					$img = null;
1152
+				}
1153
+			} else {
1154
+				$img = null;
1155
+			}
1156
+
1157
+			// prepare the datas
1158
+			if (!in_array($type, array('ul', 'ol'))) $type = 'ul';
1159
+			if (!in_array($style, array('lower-alpha', 'upper-alpha', 'upper-roman', 'lower-roman', 'decimal', 'square', 'circle', 'disc', 'none'))) $style = '';
1160
+
1161
+			if (!$style) {
1162
+				if ($type=='ul')    $style = 'disc';
1163
+				else                $style = 'decimal';
1164
+			}
1165
+
1166
+			// add the new level
1167
+			$this->_defList[count($this->_defList)] = array('style' => $style, 'nb' => 0, 'img' => $img);
1168
+		}
1169
+
1170
+		/**
1171
+		 * remove a level to the list
1172
+		 *
1173
+		 * @access protected
1174
+		 */
1175
+		protected function _listeDelLevel()
1176
+		{
1177
+			if (count($this->_defList)) {
1178
+				unset($this->_defList[count($this->_defList)-1]);
1179
+				$this->_defList = array_values($this->_defList);
1180
+			}
1181
+		}
1182
+
1183
+		/**
1184
+		 * execute the actions to convert the html
1185
+		 *
1186
+		 * @access protected
1187
+		 */
1188
+		protected function _makeHTMLcode()
1189
+		{
1190
+			// foreach elements of the parsing
1191
+			for ($this->_parsePos=0; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) {
1192
+
1193
+				// get the action to do
1194
+				$action = $this->parsingHtml->code[$this->_parsePos];
1195
+
1196
+				// if it is a opening of table / ul / ol
1197
+				if (in_array($action['name'], array('table', 'ul', 'ol')) && !$action['close']) {
1198
+
1199
+					//  we will work as a sub HTML to calculate the size of the element
1200
+					$this->_subPart = true;
1201
+
1202
+					// get the name of the opening tag
1203
+					$tagOpen = $action['name'];
1204
+
1205
+					// save the actual pos on the parsing
1206
+					$this->_tempPos = $this->_parsePos;
1207
+
1208
+					// foreach elements, while we are in the opened tag
1209
+					while (isset($this->parsingHtml->code[$this->_tempPos]) && !($this->parsingHtml->code[$this->_tempPos]['name']==$tagOpen && $this->parsingHtml->code[$this->_tempPos]['close'])) {
1210
+						// make the action
1211
+						$this->_executeAction($this->parsingHtml->code[$this->_tempPos]);
1212
+						$this->_tempPos++;
1213
+					}
1214
+
1215
+					// execute the closure of the tag
1216
+					if (isset($this->parsingHtml->code[$this->_tempPos])) {
1217
+						$this->_executeAction($this->parsingHtml->code[$this->_tempPos]);
1218
+					}
1219
+
1220
+					// end of the sub part
1221
+					$this->_subPart = false;
1222
+				}
1223
+
1224
+				// execute the action
1225
+				$this->_executeAction($action);
1226
+			}
1227
+		}
1228
+
1229
+		/**
1230
+		 * execute the action from the parsing
1231
+		 *
1232
+		 * @access protected
1233
+		 * @param  array $action
1234
+		 */
1235
+		protected function _executeAction($action)
1236
+		{
1237
+			// name of the action
1238
+			$fnc = ($action['close'] ? '_tag_close_' : '_tag_open_').strtoupper($action['name']);
1239
+
1240
+			// parameters of the action
1241
+			$param = $action['param'];
1242
+
1243
+			// if it the first action of the first page, and if it is not a open tag of PAGE => create the new page
1244
+			if ($fnc!='_tag_open_PAGE' && $this->_firstPage) {
1245
+				$this->_setNewPage();
1246
+			}
1247
+
1248
+			// the action must exist
1249
+			if (!is_callable(array(&$this, $fnc))) {
1250
+				throw new HTML2PDF_exception(1, strtoupper($action['name']), $this->parsingHtml->getHtmlErrorCode($action['html_pos']));
1251
+			}
1252
+
1253
+			// lauch the action
1254
+			$res = $this->{$fnc}($param);
1255
+
1256
+			// save the name of the action
1257
+			$this->_previousCall = $fnc;
1258
+
1259
+			// return the result
1260
+			return $res;
1261
+		}
1262
+
1263
+		/**
1264
+		 * get the position of the element on the current line, depending on his height
1265
+		 *
1266
+		 * @access protected
1267
+		 * @param  float $h
1268
+		 * @return float
1269
+		 */
1270
+		protected function _getElementY($h)
1271
+		{
1272
+			if ($this->_subPart || $this->_isSubPart || !$this->_currentH || $this->_currentH<$h)
1273
+				return 0;
1274
+
1275
+			return ($this->_currentH-$h)*0.8;
1276
+		}
1277
+
1278
+		/**
1279
+		 * make a break line
1280
+		 *
1281
+		 * @access protected
1282
+		 * @param  float $h current line height
1283
+		 * @param  integer $curr real current position in the text, if new line in the write of a text
1284
+		 */
1285
+		protected function _makeBreakLine($h, $curr = null)
1286
+		{
1287
+			if ($h) {
1288
+				if (($this->pdf->getY()+$h<$this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter)
1289
+					$this->_setNewLine($h, $curr);
1290
+				else
1291
+					$this->_setNewPage(null, '', null, $curr);
1292
+			} else {
1293
+				$this->_setNewPositionForNewLine($curr);
1294
+			}
1295
+
1296
+			$this->_maxH = 0;
1297
+			$this->_maxE = 0;
1298
+		}
1299
+
1300
+		/**
1301
+		 * display a image
1302
+		 *
1303
+		 * @access protected
1304
+		 * @param  string $src
1305
+		 * @param  boolean $subLi if true=image of a list
1306
+		 * @return boolean depending on "isForOneLine"
1307
+		 */
1308
+		protected function _drawImage($src, $subLi=false)
1309
+		{
1310
+			// get the size of the image
1311
+			// WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini
1312
+			$infos=@getimagesize($src);
1313
+
1314
+			// if the image does not exist, or can not be loaded
1315
+			if (count($infos)<2) {
1316
+				// if the test is activ => exception
1317
+				if ($this->_testIsImage) {
1318
+					throw new HTML2PDF_exception(6, $src);
1319
+				}
1320
+
1321
+				// else, display a gray rectangle
1322
+				$src = null;
1323
+				$infos = array(16, 16);
1324
+			}
1325
+
1326
+			// convert the size of the image in the unit of the PDF
1327
+			$imageWidth = $infos[0]/$this->pdf->getK();
1328
+			$imageHeight = $infos[1]/$this->pdf->getK();
1329
+
1330
+			// calculate the size from the css style
1331
+			if ($this->parsingCss->value['width'] && $this->parsingCss->value['height']) {
1332
+				$w = $this->parsingCss->value['width'];
1333
+				$h = $this->parsingCss->value['height'];
1334
+			} else if ($this->parsingCss->value['width']) {
1335
+				$w = $this->parsingCss->value['width'];
1336
+				$h = $imageHeight*$w/$imageWidth;
1337
+			} else if ($this->parsingCss->value['height']) {
1338
+				$h = $this->parsingCss->value['height'];
1339
+				$w = $imageWidth*$h/$imageHeight;
1340
+			} else {
1341
+				// convert px to pt
1342
+				$w = 72./96.*$imageWidth;
1343
+				$h = 72./96.*$imageHeight;
1344
+			}
1345
+
1346
+			// are we in a float
1347
+			$float = $this->parsingCss->getFloat();
1348
+
1349
+			// if we are in a float, but if something else if on the line => Break Line
1350
+			if ($float && $this->_maxH) {
1351
+				// make the break line (false if we are in "_isForOneLine" mode)
1352
+				if (!$this->_tag_open_BR(array())) {
1353
+					return false;
1354
+				}
1355
+			}
1356
+
1357
+			// position of the image
1358
+			$x = $this->pdf->getX();
1359
+			$y = $this->pdf->getY();
1360
+
1361
+			// if the image can not be put on the current line => new line
1362
+			if (!$float && ($x + $w>$this->pdf->getW() - $this->pdf->getrMargin()) && $this->_maxH) {
1363
+				if ($this->_isForOneLine) {
1364
+					return false;
1365
+				}
1366
+
1367
+				// set the new line
1368
+				$hnl = max($this->_maxH, $this->parsingCss->getLineHeight());
1369
+				$this->_setNewLine($hnl);
1370
+
1371
+				// get the new position
1372
+				$x = $this->pdf->getX();
1373
+				$y = $this->pdf->getY();
1374
+			}
1375
+
1376
+			// if the image can not be put on the current page
1377
+			if (($y + $h>$this->pdf->getH() - $this->pdf->getbMargin()) && !$this->_isInOverflow) {
1378
+				// new page
1379
+				$this->_setNewPage();
1380
+
1381
+				// get the new position
1382
+				$x = $this->pdf->getX();
1383
+				$y = $this->pdf->getY();
1384
+			}
1385
+
1386
+			// correction for display the image of a list
1387
+			$hT = 0.80*$this->parsingCss->value['font-size'];
1388
+			if ($subLi && $h<$hT) {
1389
+				$y+=($hT-$h);
1390
+			}
1391
+
1392
+			// add the margin top
1393
+			$yc = $y-$this->parsingCss->value['margin']['t'];
1394
+
1395
+			// get the width and the position of the parent
1396
+			$old = $this->parsingCss->getOldValues();
1397
+			if ( $old['width']) {
1398
+				$parentWidth = $old['width'];
1399
+				$parentX = $x;
1400
+			} else {
1401
+				$parentWidth = $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
1402
+				$parentX = $this->pdf->getlMargin();
1403
+			}
1404
+
1405
+			// if we are in a gloat => adapt the parent position and width
1406
+			if ($float) {
1407
+				list($lx, $rx) = $this->_getMargins($yc);
1408
+				$parentX = $lx;
1409
+				$parentWidth = $rx-$lx;
1410
+			}
1411
+
1412
+			// calculate the position of the image, if align to the right
1413
+			if ($parentWidth>$w && $float!='left') {
1414
+				if ($float=='right' || $this->parsingCss->value['text-align']=='li_right')    $x = $parentX + $parentWidth - $w-$this->parsingCss->value['margin']['r']-$this->parsingCss->value['margin']['l'];
1415
+			}
1416
+
1417
+			// display the image
1418
+			if (!$this->_subPart && !$this->_isSubPart) {
1419
+				if ($src) {
1420
+					$this->pdf->Image($src, $x, $y, $w, $h, '', $this->_isInLink);
1421
+				} else {
1422
+					// rectangle if the image can not be loaded
1423
+					$this->pdf->setFillColorArray(array(240, 220, 220));
1424
+					$this->pdf->Rect($x, $y, $w, $h, 'F');
1425
+				}
1426
+			}
1427
+
1428
+			// apply the margins
1429
+			$x-= $this->parsingCss->value['margin']['l'];
1430
+			$y-= $this->parsingCss->value['margin']['t'];
1431
+			$w+= $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['margin']['r'];
1432
+			$h+= $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['margin']['b'];
1433
+
1434
+			if ($float=='left') {
1435
+				// save the current max
1436
+				$this->_maxX = max($this->_maxX, $x+$w);
1437
+				$this->_maxY = max($this->_maxY, $y+$h);
1438
+
1439
+				// add the image to the margins
1440
+				$this->_addMargins($float, $x, $y, $x+$w, $y+$h);
1441
+
1442
+				// get the new position
1443
+				list($lx, $rx) = $this->_getMargins($yc);
1444
+				$this->pdf->setXY($lx, $yc);
1445
+			} else if ($float=='right') {
1446
+				// save the current max. We don't save the X because it is not the real max of the line
1447
+				$this->_maxY = max($this->_maxY, $y+$h);
1448
+
1449
+				// add the image to the margins
1450
+				$this->_addMargins($float, $x, $y, $x+$w, $y+$h);
1451
+
1452
+				// get the new position
1453
+				list($lx, $rx) = $this->_getMargins($yc);
1454
+				$this->pdf->setXY($lx, $yc);
1455
+			} else {
1456
+				// set the new position at the end of the image
1457
+				$this->pdf->setX($x+$w);
1458
+
1459
+				// save the current max
1460
+				$this->_maxX = max($this->_maxX, $x+$w);
1461
+				$this->_maxY = max($this->_maxY, $y+$h);
1462
+				$this->_maxH = max($this->_maxH, $h);
1463
+			}
1464
+
1465
+			return true;
1466
+		}
1467
+
1468
+		/**
1469
+		 * draw a rectangle
1470
+		 *
1471
+		 * @access protected
1472
+		 * @param  float $x
1473
+		 * @param  float $y
1474
+		 * @param  float $w
1475
+		 * @param  float $h
1476
+		 * @param  array $border
1477
+		 * @param  float $padding - internal marge of the rectanble => not used, but...
1478
+		 * @param  float $margin  - external marge of the rectanble
1479
+		 * @param  array $background
1480
+		 * @return boolean
1481
+		 */
1482
+		protected function _drawRectangle($x, $y, $w, $h, $border, $padding, $margin, $background)
1483
+		{
1484
+			// if we are in a subpart or if height is null => return false
1485
+			if ($this->_subPart || $this->_isSubPart || $h===null) return false;
1486
+
1487
+			// add the margin
1488
+			$x+= $margin;
1489
+			$y+= $margin;
1490
+			$w-= $margin*2;
1491
+			$h-= $margin*2;
1492
+
1493
+			// get the radius of the border
1494
+			$outTL = $border['radius']['tl'];
1495
+			$outTR = $border['radius']['tr'];
1496
+			$outBR = $border['radius']['br'];
1497
+			$outBL = $border['radius']['bl'];
1498
+
1499
+			// prepare the out radius
1500
+			$outTL = ($outTL[0] && $outTL[1]) ? $outTL : null;
1501
+			$outTR = ($outTR[0] && $outTR[1]) ? $outTR : null;
1502
+			$outBR = ($outBR[0] && $outBR[1]) ? $outBR : null;
1503
+			$outBL = ($outBL[0] && $outBL[1]) ? $outBL : null;
1504
+
1505
+			// prepare the in radius
1506
+			$inTL = $outTL;
1507
+			$inTR = $outTR;
1508
+			$inBR = $outBR;
1509
+			$inBL = $outBL;
1510
+
1511
+			if (is_array($inTL)) {
1512
+				$inTL[0]-= $border['l']['width'];
1513
+				$inTL[1]-= $border['t']['width'];
1514
+			}
1515
+			if (is_array($inTR)) {
1516
+				$inTR[0]-= $border['r']['width'];
1517
+				$inTR[1]-= $border['t']['width'];
1518
+			}
1519
+			if (is_array($inBR)) {
1520
+				$inBR[0]-= $border['r']['width'];
1521
+				$inBR[1]-= $border['b']['width'];
1522
+			}
1523
+			if (is_array($inBL)) {
1524
+				$inBL[0]-= $border['l']['width'];
1525
+				$inBL[1]-= $border['b']['width'];
1526
+			}
1527
+
1528
+			if ($inTL[0]<=0 || $inTL[1]<=0) $inTL = null;
1529
+			if ($inTR[0]<=0 || $inTR[1]<=0) $inTR = null;
1530
+			if ($inBR[0]<=0 || $inBR[1]<=0) $inBR = null;
1531
+			if ($inBL[0]<=0 || $inBL[1]<=0) $inBL = null;
1532
+
1533
+			// prepare the background color
1534
+			$pdfStyle = '';
1535
+			if ($background['color']) {
1536
+				$this->pdf->setFillColorArray($background['color']);
1537
+				$pdfStyle.= 'F';
1538
+			}
1539
+
1540
+			// if we have a background to fill => fill it with a path (because of the radius)
1541
+			if ($pdfStyle) {
1542
+				$this->pdf->clippingPathStart($x, $y, $w, $h, $outTL, $outTR, $outBL, $outBR);
1543
+				$this->pdf->Rect($x, $y, $w, $h, $pdfStyle);
1544
+				$this->pdf->clippingPathStop();
1545
+			}
1546
+
1547
+			// prepare the background image
1548
+			if ($background['image']) {
1549
+				$iName      = $background['image'];
1550
+				$iPosition  = $background['position']!==null ? $background['position'] : array(0, 0);
1551
+				$iRepeat    = $background['repeat']!==null   ? $background['repeat']   : array(true, true);
1552
+
1553
+				// size of the background without the borders
1554
+				$bX = $x;
1555
+				$bY = $y;
1556
+				$bW = $w;
1557
+				$bH = $h;
1558
+
1559
+				if ($border['b']['width']) {
1560
+					$bH-= $border['b']['width'];
1561
+				}
1562
+				if ($border['l']['width']) {
1563
+					$bW-= $border['l']['width'];
1564
+					$bX+= $border['l']['width'];
1565
+				}
1566
+				if ($border['t']['width']) {
1567
+					$bH-= $border['t']['width'];
1568
+					$bY+= $border['t']['width'];
1569
+				}
1570
+				if ($border['r']['width']) {
1571
+					$bW-= $border['r']['width'];
1572
+				}
1573
+
1574
+				// get the size of the image
1575
+				// WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini
1576
+				$imageInfos=@getimagesize($iName);
1577
+
1578
+				// if the image can not be loaded
1579
+				if (count($imageInfos)<2) {
1580
+					if ($this->_testIsImage) {
1581
+						throw new HTML2PDF_exception(6, $iName);
1582
+					}
1583
+				} else {
1584
+					// convert the size of the image from pixel to the unit of the PDF
1585
+					$imageWidth    = 72./96.*$imageInfos[0]/$this->pdf->getK();
1586
+					$imageHeight    = 72./96.*$imageInfos[1]/$this->pdf->getK();
1587
+
1588
+					// prepare the position of the backgroung
1589
+					if ($iRepeat[0]) $iPosition[0] = $bX;
1590
+					else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) $iPosition[0] = $bX + $match[1]*($bW-$imageWidth)/100;
1591
+					else $iPosition[0] = $bX+$iPosition[0];
1592
+
1593
+					if ($iRepeat[1]) $iPosition[1] = $bY;
1594
+					else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) $iPosition[1] = $bY + $match[1]*($bH-$imageHeight)/100;
1595
+					else $iPosition[1] = $bY+$iPosition[1];
1596
+
1597
+					$imageXmin = $bX;
1598
+					$imageXmax = $bX+$bW;
1599
+					$imageYmin = $bY;
1600
+					$imageYmax = $bY+$bH;
1601
+
1602
+					if (!$iRepeat[0] && !$iRepeat[1]) {
1603
+						$imageXmin =     $iPosition[0]; $imageXmax =     $iPosition[0]+$imageWidth;
1604
+						$imageYmin =     $iPosition[1]; $imageYmax =     $iPosition[1]+$imageHeight;
1605
+					} else if ($iRepeat[0] && !$iRepeat[1]) {
1606
+						$imageYmin =     $iPosition[1]; $imageYmax =     $iPosition[1]+$imageHeight;
1607
+					} else if (!$iRepeat[0] && $iRepeat[1]) {
1608
+						$imageXmin =     $iPosition[0]; $imageXmax =     $iPosition[0]+$imageWidth;
1609
+					}
1610
+
1611
+					// build the path to display the image (because of radius)
1612
+					$this->pdf->clippingPathStart($bX, $bY, $bW, $bH, $inTL, $inTR, $inBL, $inBR);
1613
+
1614
+					// repeat the image
1615
+					for ($iY=$imageYmin; $iY<$imageYmax; $iY+=$imageHeight) {
1616
+						for ($iX=$imageXmin; $iX<$imageXmax; $iX+=$imageWidth) {
1617
+							$cX = null;
1618
+							$cY = null;
1619
+							$cW = $imageWidth;
1620
+							$cH = $imageHeight;
1621
+							if ($imageYmax-$iY<$imageHeight) {
1622
+								$cX = $iX;
1623
+								$cY = $iY;
1624
+								$cH = $imageYmax-$iY;
1625
+							}
1626
+							if ($imageXmax-$iX<$imageWidth) {
1627
+								$cX = $iX;
1628
+								$cY = $iY;
1629
+								$cW = $imageXmax-$iX;
1630
+							}
1631
+
1632
+							$this->pdf->Image($iName, $iX, $iY, $imageWidth, $imageHeight, '', '');
1633
+						}
1634
+					}
1635
+
1636
+					// end of the path
1637
+					$this->pdf->clippingPathStop();
1638
+				}
1639
+			}
1640
+
1641
+			// adding some loose (0.01mm)
1642
+			$loose = 0.01;
1643
+			$x-= $loose;
1644
+			$y-= $loose;
1645
+			$w+= 2.*$loose;
1646
+			$h+= 2.*$loose;
1647
+			if ($border['l']['width']) $border['l']['width']+= 2.*$loose;
1648
+			if ($border['t']['width']) $border['t']['width']+= 2.*$loose;
1649
+			if ($border['r']['width']) $border['r']['width']+= 2.*$loose;
1650
+			if ($border['b']['width']) $border['b']['width']+= 2.*$loose;
1651
+
1652
+			// prepare the test on borders
1653
+			$testBl = ($border['l']['width'] && $border['l']['color'][0]!==null);
1654
+			$testBt = ($border['t']['width'] && $border['t']['color'][0]!==null);
1655
+			$testBr = ($border['r']['width'] && $border['r']['color'][0]!==null);
1656
+			$testBb = ($border['b']['width'] && $border['b']['color'][0]!==null);
1657
+
1658
+			// draw the radius bottom-left
1659
+			if (is_array($outBL) && ($testBb || $testBl)) {
1660
+				if ($inBL) {
1661
+					$courbe = array();
1662
+					$courbe[] = $x+$outBL[0];              $courbe[] = $y+$h;
1663
+					$courbe[] = $x;                        $courbe[] = $y+$h-$outBL[1];
1664
+					$courbe[] = $x+$outBL[0];              $courbe[] = $y+$h-$border['b']['width'];
1665
+					$courbe[] = $x+$border['l']['width'];  $courbe[] = $y+$h-$outBL[1];
1666
+					$courbe[] = $x+$outBL[0];              $courbe[] = $y+$h-$outBL[1];
1667
+				} else {
1668
+					$courbe = array();
1669
+					$courbe[] = $x+$outBL[0];              $courbe[] = $y+$h;
1670
+					$courbe[] = $x;                        $courbe[] = $y+$h-$outBL[1];
1671
+					$courbe[] = $x+$border['l']['width'];  $courbe[] = $y+$h-$border['b']['width'];
1672
+					$courbe[] = $x+$outBL[0];              $courbe[] = $y+$h-$outBL[1];
1673
+				}
1674
+				$this->_drawCurve($courbe, $border['l']['color']);
1675
+			}
1676
+
1677
+			// draw the radius left-top
1678
+			if (is_array($outTL) && ($testBt || $testBl)) {
1679
+				if ($inTL) {
1680
+					$courbe = array();
1681
+					$courbe[] = $x;                        $courbe[] = $y+$outTL[1];
1682
+					$courbe[] = $x+$outTL[0];              $courbe[] = $y;
1683
+					$courbe[] = $x+$border['l']['width'];  $courbe[] = $y+$outTL[1];
1684
+					$courbe[] = $x+$outTL[0];              $courbe[] = $y+$border['t']['width'];
1685
+					$courbe[] = $x+$outTL[0];              $courbe[] = $y+$outTL[1];
1686
+				} else {
1687
+					$courbe = array();
1688
+					$courbe[] = $x;                        $courbe[] = $y+$outTL[1];
1689
+					$courbe[] = $x+$outTL[0];              $courbe[] = $y;
1690
+					$courbe[] = $x+$border['l']['width'];  $courbe[] = $y+$border['t']['width'];
1691
+					$courbe[] = $x+$outTL[0];              $courbe[] = $y+$outTL[1];
1692
+				}
1693
+				$this->_drawCurve($courbe, $border['t']['color']);
1694
+			}
1695
+
1696
+			// draw the radius top-right
1697
+			if (is_array($outTR) && ($testBt || $testBr)) {
1698
+				if ($inTR) {
1699
+					$courbe = array();
1700
+					$courbe[] = $x+$w-$outTR[0];             $courbe[] = $y;
1701
+					$courbe[] = $x+$w;                       $courbe[] = $y+$outTR[1];
1702
+					$courbe[] = $x+$w-$outTR[0];             $courbe[] = $y+$border['t']['width'];
1703
+					$courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$outTR[1];
1704
+					$courbe[] = $x+$w-$outTR[0];             $courbe[] = $y+$outTR[1];
1705
+				} else {
1706
+					$courbe = array();
1707
+					$courbe[] = $x+$w-$outTR[0];             $courbe[] = $y;
1708
+					$courbe[] = $x+$w;                       $courbe[] = $y+$outTR[1];
1709
+					$courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$border['t']['width'];
1710
+					$courbe[] = $x+$w-$outTR[0];             $courbe[] = $y+$outTR[1];
1711
+				}
1712
+				$this->_drawCurve($courbe, $border['r']['color']);
1713
+			}
1714
+
1715
+			// draw the radius right-bottom
1716
+			if (is_array($outBR) && ($testBb || $testBr)) {
1717
+				if ($inBR) {
1718
+					$courbe = array();
1719
+					$courbe[] = $x+$w;                       $courbe[] = $y+$h-$outBR[1];
1720
+					$courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h;
1721
+					$courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$h-$outBR[1];
1722
+					$courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h-$border['b']['width'];
1723
+					$courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h-$outBR[1];
1724
+				} else {
1725
+					$courbe = array();
1726
+					$courbe[] = $x+$w;                       $courbe[] = $y+$h-$outBR[1];
1727
+					$courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h;
1728
+					$courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$h-$border['b']['width'];
1729
+					$courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h-$outBR[1];
1730
+				}
1731
+				$this->_drawCurve($courbe, $border['b']['color']);
1732
+			}
1733
+
1734
+			// draw the left border
1735
+			if ($testBl) {
1736
+				$pt = array();
1737
+				$pt[] = $x;                       $pt[] = $y+$h;
1738
+				$pt[] = $x;                       $pt[] = $y+$h-$border['b']['width'];
1739
+				$pt[] = $x;                       $pt[] = $y+$border['t']['width'];
1740
+				$pt[] = $x;                       $pt[] = $y;
1741
+				$pt[] = $x+$border['l']['width']; $pt[] = $y+$border['t']['width'];
1742
+				$pt[] = $x+$border['l']['width']; $pt[] = $y+$h-$border['b']['width'];
1743
+
1744
+				$bord = 3;
1745
+				if (is_array($outBL)) {
1746
+					$bord-=1;
1747
+					$pt[3] -= $outBL[1] - $border['b']['width'];
1748
+					if ($inBL) $pt[11]-= $inBL[1];
1749
+					unset($pt[0]);unset($pt[1]);
1750
+				}
1751
+				if (is_array($outTL)) {
1752
+					$bord-=2;
1753
+					$pt[5] += $outTL[1]-$border['t']['width'];
1754
+					if ($inTL) $pt[9] += $inTL[1];
1755
+					unset($pt[6]);unset($pt[7]);
1756
+				}
1757
+
1758
+				$pt = array_values($pt);
1759
+				$this->_drawLine($pt, $border['l']['color'], $border['l']['type'], $border['l']['width'], $bord);
1760
+			}
1761
+
1762
+			// draw the top border
1763
+			if ($testBt) {
1764
+				$pt = array();
1765
+				$pt[] = $x;                          $pt[] = $y;
1766
+				$pt[] = $x+$border['l']['width'];    $pt[] = $y;
1767
+				$pt[] = $x+$w-$border['r']['width']; $pt[] = $y;
1768
+				$pt[] = $x+$w;                       $pt[] = $y;
1769
+				$pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$border['t']['width'];
1770
+				$pt[] = $x+$border['l']['width'];    $pt[] = $y+$border['t']['width'];
1771
+
1772
+				$bord = 3;
1773
+				if (is_array($outTL)) {
1774
+					$bord-=1;
1775
+					$pt[2] += $outTL[0] - $border['l']['width'];
1776
+					if ($inTL) $pt[10]+= $inTL[0];
1777
+					unset($pt[0]);unset($pt[1]);
1778
+				}
1779
+				if (is_array($outTR)) {
1780
+					$bord-=2;
1781
+					$pt[4] -= $outTR[0] - $border['r']['width'];
1782
+					if ($inTR) $pt[8] -= $inTR[0];
1783
+					unset($pt[6]);unset($pt[7]);
1784
+				}
1785
+
1786
+				$pt = array_values($pt);
1787
+				$this->_drawLine($pt, $border['t']['color'], $border['t']['type'], $border['t']['width'], $bord);
1788
+			}
1789
+
1790
+			// draw the right border
1791
+			if ($testBr) {
1792
+				$pt = array();
1793
+				$pt[] = $x+$w;                       $pt[] = $y;
1794
+				$pt[] = $x+$w;                       $pt[] = $y+$border['t']['width'];
1795
+				$pt[] = $x+$w;                       $pt[] = $y+$h-$border['b']['width'];
1796
+				$pt[] = $x+$w;                       $pt[] = $y+$h;
1797
+				$pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h-$border['b']['width'];
1798
+				$pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$border['t']['width'];
1799
+
1800
+				$bord = 3;
1801
+				if (is_array($outTR)) {
1802
+					$bord-=1;
1803
+					$pt[3] += $outTR[1] - $border['t']['width'];
1804
+					if ($inTR) $pt[11]+= $inTR[1];
1805
+					unset($pt[0]);unset($pt[1]);
1806
+				}
1807
+				if (is_array($outBR)) {
1808
+					$bord-=2;
1809
+					$pt[5] -= $outBR[1] - $border['b']['width'];
1810
+					if ($inBR) $pt[9] -= $inBR[1];
1811
+					unset($pt[6]);unset($pt[7]);
1812
+				}
1813
+
1814
+				$pt = array_values($pt);
1815
+				$this->_drawLine($pt, $border['r']['color'], $border['r']['type'], $border['r']['width'], $bord);
1816
+			}
1817
+
1818
+			// draw the bottom border
1819
+			if ($testBb) {
1820
+				$pt = array();
1821
+				$pt[] = $x+$w;                       $pt[] = $y+$h;
1822
+				$pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h;
1823
+				$pt[] = $x+$border['l']['width'];    $pt[] = $y+$h;
1824
+				$pt[] = $x;                          $pt[] = $y+$h;
1825
+				$pt[] = $x+$border['l']['width'];    $pt[] = $y+$h-$border['b']['width'];
1826
+				$pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h-$border['b']['width'];
1827
+
1828
+				$bord = 3;
1829
+				if (is_array($outBL)) {
1830
+					$bord-=2;
1831
+					$pt[4] += $outBL[0] - $border['l']['width'];
1832
+					if ($inBL) $pt[8] += $inBL[0];
1833
+					unset($pt[6]);unset($pt[7]);
1834
+				}
1835
+				if (is_array($outBR)) {
1836
+					$bord-=1;
1837
+					$pt[2] -= $outBR[0] - $border['r']['width'];
1838
+					if ($inBR) $pt[10]-= $inBR[0];
1839
+					unset($pt[0]);unset($pt[1]);
1840
+
1841
+				}
1842
+
1843
+				$pt = array_values($pt);
1844
+				$this->_drawLine($pt, $border['b']['color'], $border['b']['type'], $border['b']['width'], $bord);
1845
+			}
1846
+
1847
+			if ($background['color']) {
1848
+				$this->pdf->setFillColorArray($background['color']);
1849
+			}
1850
+
1851
+			return true;
1852
+		}
1853
+
1854
+		/**
1855
+		 * draw a curve (for border radius)
1856
+		 *
1857
+		 * @access protected
1858
+		 * @param  array $pt
1859
+		 * @param  array $color
1860
+		 */
1861
+		protected function _drawCurve($pt, $color)
1862
+		{
1863
+			$this->pdf->setFillColorArray($color);
1864
+
1865
+			if (count($pt)==10)
1866
+				$this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]);
1867
+			else
1868
+				$this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]);
1869
+		}
1870
+
1871
+		/**
1872
+		 * draw a ligne with a specific type, and specific start and end for radius
1873
+		 *
1874
+		 * @access protected
1875
+		 * @param  array   $pt
1876
+		 * @param  float   $color
1877
+		 * @param  string  $type (dashed, dotted, double, solid)
1878
+		 * @param  float   $width
1879
+		 * @param  integer $radius (binary from 0 to 3 with 1=>start with a radius, 2=>end with a radius)
1880
+		 */
1881
+		protected function _drawLine($pt, $color, $type, $width, $radius=3)
1882
+		{
1883
+			// set the fill color
1884
+			$this->pdf->setFillColorArray($color);
1885
+
1886
+			// if dashed or dotted
1887
+			if ($type=='dashed' || $type=='dotted') {
1888
+
1889
+				// clean the end of the line, if radius
1890
+				if ($radius==1) {
1891
+					$tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
1892
+					$this->pdf->Polygon($tmp, 'F');
1893
+
1894
+					$tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
1895
+					$pt = $tmp;
1896
+				} else if ($radius==2) {
1897
+					$tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7];
1898
+					$this->pdf->Polygon($tmp, 'F');
1899
+
1900
+					$tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
1901
+					$pt = $tmp;
1902
+				} else if ($radius==3) {
1903
+					$tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[10]; $tmp[]=$pt[11];
1904
+					$this->pdf->Polygon($tmp, 'F');
1905
+
1906
+					$tmp = array(); $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
1907
+					$this->pdf->Polygon($tmp, 'F');
1908
+
1909
+					$tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[8]; $tmp[]=$pt[9]; $tmp[]=$pt[10]; $tmp[]=$pt[11];
1910
+					$pt = $tmp;
1911
+				}
1912
+
1913
+				// horisontal or vertical line
1914
+				if ($pt[2]==$pt[0]) {
1915
+					$l = abs(($pt[3]-$pt[1])*0.5);
1916
+					$px = 0;
1917
+					$py = $width;
1918
+					$x1 = $pt[0]; $y1 = ($pt[3]+$pt[1])*0.5;
1919
+					$x2 = $pt[6]; $y2 = ($pt[7]+$pt[5])*0.5;
1920
+				} else {
1921
+					$l = abs(($pt[2]-$pt[0])*0.5);
1922
+					$px = $width;
1923
+					$py = 0;
1924
+					$x1 = ($pt[2]+$pt[0])*0.5; $y1 = $pt[1];
1925
+					$x2 = ($pt[6]+$pt[4])*0.5; $y2 = $pt[7];
1926
+				}
1927
+
1928
+				// if dashed : 3x bigger than dotted
1929
+				if ($type=='dashed') {
1930
+					$px = $px*3.;
1931
+					$py = $py*3.;
1932
+				}
1933
+				$mode = ($l/($px+$py)<.5);
1934
+
1935
+				// display the dotted/dashed line
1936
+				for ($i=0; $l-($px+$py)*($i-0.5)>0; $i++) {
1937
+					if (($i%2)==$mode) {
1938
+						$j = $i-0.5;
1939
+						$lx1 = $px*($j);   if ($lx1<-$l) $lx1 =-$l;
1940
+						$ly1 = $py*($j);   if ($ly1<-$l) $ly1 =-$l;
1941
+						$lx2 = $px*($j+1); if ($lx2>$l)  $lx2 = $l;
1942
+						$ly2 = $py*($j+1); if ($ly2>$l)  $ly2 = $l;
1943
+
1944
+						$tmp = array();
1945
+						$tmp[] = $x1+$lx1; $tmp[] = $y1+$ly1;
1946
+						$tmp[] = $x1+$lx2; $tmp[] = $y1+$ly2;
1947
+						$tmp[] = $x2+$lx2; $tmp[] = $y2+$ly2;
1948
+						$tmp[] = $x2+$lx1; $tmp[] = $y2+$ly1;
1949
+						$this->pdf->Polygon($tmp, 'F');
1950
+
1951
+						if ($j>0) {
1952
+							$tmp = array();
1953
+							$tmp[] = $x1-$lx1; $tmp[] = $y1-$ly1;
1954
+							$tmp[] = $x1-$lx2; $tmp[] = $y1-$ly2;
1955
+							$tmp[] = $x2-$lx2; $tmp[] = $y2-$ly2;
1956
+							$tmp[] = $x2-$lx1; $tmp[] = $y2-$ly1;
1957
+							$this->pdf->Polygon($tmp, 'F');
1958
+						}
1959
+					}
1960
+				}
1961
+			} else if ($type=='double') {
1962
+
1963
+				// if double, 2 lines : 0=>1/3 and 2/3=>1
1964
+				$pt1 = $pt;
1965
+				$pt2 = $pt;
1966
+
1967
+				if (count($pt)==12) {
1968
+					// line 1
1969
+					$pt1[0] = ($pt[0]-$pt[10])*0.33 + $pt[10];
1970
+					$pt1[1] = ($pt[1]-$pt[11])*0.33 + $pt[11];
1971
+					$pt1[2] = ($pt[2]-$pt[10])*0.33 + $pt[10];
1972
+					$pt1[3] = ($pt[3]-$pt[11])*0.33 + $pt[11];
1973
+					$pt1[4] = ($pt[4]-$pt[8])*0.33 + $pt[8];
1974
+					$pt1[5] = ($pt[5]-$pt[9])*0.33 + $pt[9];
1975
+					$pt1[6] = ($pt[6]-$pt[8])*0.33 + $pt[8];
1976
+					$pt1[7] = ($pt[7]-$pt[9])*0.33 + $pt[9];
1977
+					$pt2[10]= ($pt[10]-$pt[0])*0.33 + $pt[0];
1978
+					$pt2[11]= ($pt[11]-$pt[1])*0.33 + $pt[1];
1979
+
1980
+					// line 2
1981
+					$pt2[2] = ($pt[2] -$pt[0])*0.33 + $pt[0];
1982
+					$pt2[3] = ($pt[3] -$pt[1])*0.33 + $pt[1];
1983
+					$pt2[4] = ($pt[4] -$pt[6])*0.33 + $pt[6];
1984
+					$pt2[5] = ($pt[5] -$pt[7])*0.33 + $pt[7];
1985
+					$pt2[8] = ($pt[8] -$pt[6])*0.33 + $pt[6];
1986
+					$pt2[9] = ($pt[9] -$pt[7])*0.33 + $pt[7];
1987
+				} else {
1988
+					// line 1
1989
+					$pt1[0] = ($pt[0]-$pt[6])*0.33 + $pt[6];
1990
+					$pt1[1] = ($pt[1]-$pt[7])*0.33 + $pt[7];
1991
+					$pt1[2] = ($pt[2]-$pt[4])*0.33 + $pt[4];
1992
+					$pt1[3] = ($pt[3]-$pt[5])*0.33 + $pt[5];
1993
+
1994
+					// line 2
1995
+					$pt2[6] = ($pt[6]-$pt[0])*0.33 + $pt[0];
1996
+					$pt2[7] = ($pt[7]-$pt[1])*0.33 + $pt[1];
1997
+					$pt2[4] = ($pt[4]-$pt[2])*0.33 + $pt[2];
1998
+					$pt2[5] = ($pt[5]-$pt[3])*0.33 + $pt[3];
1999
+				}
2000
+				$this->pdf->Polygon($pt1, 'F');
2001
+				$this->pdf->Polygon($pt2, 'F');
2002
+			} else if ($type=='solid') {
2003
+				// solid line : draw directly the polygon
2004
+				$this->pdf->Polygon($pt, 'F');
2005
+			}
2006
+		}
2007
+
2008
+		/**
2009
+		 * prepare a transform matrix, only for drawing a SVG graphic
2010
+		 *
2011
+		 * @access protected
2012
+		 * @param  string $transform
2013
+		 * @return array  $matrix
2014
+		 */
2015
+		protected function _prepareTransform($transform)
2016
+		{
2017
+			// it can not be  empty
2018
+			if (!$transform) return null;
2019
+
2020
+			// sctions must be like scale(...)
2021
+			if (!preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) return null;
2022
+
2023
+			// prepare the list of the actions
2024
+			$actions = array();
2025
+
2026
+			// for actions
2027
+			for ($k=0; $k<count($match[0]); $k++) {
2028
+
2029
+				// get the name of the action
2030
+				$name = strtolower($match[1][$k]);
2031
+
2032
+				// get the parameters of the action
2033
+				$val = explode(',', trim($match[2][$k]));
2034
+				foreach ($val as $i => $j) {
2035
+					$val[$i] = trim($j);
2036
+				}
2037
+
2038
+				// prepare the matrix, depending on the action
2039
+				switch($name)
2040
+				{
2041
+					case 'scale':
2042
+						if (!isset($val[0])) $val[0] = 1.;      else $val[0] = 1.*$val[0];
2043
+						if (!isset($val[1])) $val[1] = $val[0]; else $val[1] = 1.*$val[1];
2044
+						$actions[] = array($val[0],0,0,$val[1],0,0);
2045
+						break;
2046
+
2047
+					case 'translate':
2048
+						if (!isset($val[0])) $val[0] = 0.; else $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']);
2049
+						if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']);
2050
+						$actions[] = array(1,0,0,1,$val[0],$val[1]);
2051
+						break;
2052
+
2053
+					case 'rotate':
2054
+						if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.;
2055
+						if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']);
2056
+						if (!isset($val[2])) $val[2] = 0.; else $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']);
2057
+						if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,-$val[1],-$val[2]);
2058
+						$actions[] = array(cos($val[0]),sin($val[0]),-sin($val[0]),cos($val[0]),0,0);
2059
+						if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,$val[1],$val[2]);
2060
+						break;
2061
+
2062
+					case 'skewx':
2063
+						if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.;
2064
+						$actions[] = array(1,0,tan($val[0]),1,0,0);
2065
+						break;
2066
+
2067
+					case 'skewy':
2068
+						if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.;
2069
+						$actions[] = array(1,tan($val[0]),0,1,0,0);
2070
+						break;
2071
+					case 'matrix':
2072
+						if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*1.;
2073
+						if (!isset($val[1])) $val[1] = 0.; else $val[1] = $val[1]*1.;
2074
+						if (!isset($val[2])) $val[2] = 0.; else $val[2] = $val[2]*1.;
2075
+						if (!isset($val[3])) $val[3] = 0.; else $val[3] = $val[3]*1.;
2076
+						if (!isset($val[4])) $val[4] = 0.; else $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']);
2077
+						if (!isset($val[5])) $val[5] = 0.; else $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']);
2078
+						$actions[] =$val;
2079
+						break;
2080
+				}
2081
+			}
2082
+
2083
+			// if ther is no actions => return
2084
+			if (!$actions) return null;
2085
+
2086
+			// get the first matrix
2087
+			$m = $actions[0]; unset($actions[0]);
2088
+
2089
+			// foreach matrix => multiply to the last matrix
2090
+			foreach ($actions as $n) {
2091
+				$m = array(
2092
+					$m[0]*$n[0]+$m[2]*$n[1],
2093
+					$m[1]*$n[0]+$m[3]*$n[1],
2094
+					$m[0]*$n[2]+$m[2]*$n[3],
2095
+					$m[1]*$n[2]+$m[3]*$n[3],
2096
+					$m[0]*$n[4]+$m[2]*$n[5]+$m[4],
2097
+					$m[1]*$n[4]+$m[3]*$n[5]+$m[5]
2098
+				);
2099
+			}
2100
+
2101
+			// return the matrix
2102
+			return $m;
2103
+		}
2104
+
2105
+		/**
2106
+		 * @access protected
2107
+		 * @param  &array $cases
2108
+		 * @param  &array $corr
2109
+		 */
2110
+		protected function _calculateTableCellSize(&$cases, &$corr)
2111
+		{
2112
+			if (!isset($corr[0])) return true;
2113
+
2114
+			// for each cell without colspan, we get the max width for each column
2115
+			$sw = array();
2116
+			for ($x=0; $x<count($corr[0]); $x++) {
2117
+				$m=0;
2118
+				for ($y=0; $y<count($corr); $y++) {
2119
+					if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]==1) {
2120
+						$m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']);
2121
+					}
2122
+				}
2123
+				$sw[$x] = $m;
2124
+			}
2125
+
2126
+			// for each cell with colspan, we adapt the width of each column
2127
+			for ($x=0; $x<count($corr[0]); $x++) {
2128
+				for ($y=0; $y<count($corr); $y++) {
2129
+					if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]>1) {
2130
+
2131
+						// sum the max width of each column in colspan
2132
+						$s = 0; for ($i=0; $i<$corr[$y][$x][2]; $i++) $s+= $sw[$x+$i];
2133
+
2134
+						// if the max width is < the width of the cell with colspan => we adapt the width of each max width
2135
+						if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']) {
2136
+							for ($i=0; $i<$corr[$y][$x][2]; $i++) {
2137
+								$sw[$x+$i] = $sw[$x+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
2138
+							}
2139
+						}
2140
+					}
2141
+				}
2142
+			}
2143
+
2144
+			// set the new width, for each cell
2145
+			for ($x=0; $x<count($corr[0]); $x++) {
2146
+				for ($y=0; $y<count($corr); $y++) {
2147
+					if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) {
2148
+						// without colspan
2149
+						if ($corr[$y][$x][2]==1) {
2150
+							$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $sw[$x];
2151
+						// with colspan
2152
+						} else {
2153
+							$s = 0;
2154
+							for ($i=0; $i<$corr[$y][$x][2]; $i++) {
2155
+								$s+= $sw[$x+$i];
2156
+							}
2157
+							$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $s;
2158
+						}
2159
+					}
2160
+				}
2161
+			}
2162
+
2163
+			// for each cell without rowspan, we get the max height for each line
2164
+			$sh = array();
2165
+			for ($y=0; $y<count($corr); $y++) {
2166
+				$m=0;
2167
+				for ($x=0; $x<count($corr[0]); $x++) {
2168
+					if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]==1) {
2169
+						$m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']);
2170
+					}
2171
+				}
2172
+				$sh[$y] = $m;
2173
+			}
2174
+
2175
+			// for each cell with rowspan, we adapt the height of each line
2176
+			for ($y=0; $y<count($corr); $y++) {
2177
+				for ($x=0; $x<count($corr[0]); $x++) {
2178
+					if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]>1) {
2179
+
2180
+						// sum the max height of each line in rowspan
2181
+						$s = 0; for ($i=0; $i<$corr[$y][$x][3]; $i++) $s+= $sh[$y+$i];
2182
+
2183
+						// if the max height is < the height of the cell with rowspan => we adapt the height of each max height
2184
+						if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']) {
2185
+							for ($i=0; $i<$corr[$y][$x][3]; $i++) {
2186
+								$sh[$y+$i] = $sh[$y+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'];
2187
+							}
2188
+						}
2189
+					}
2190
+				}
2191
+			}
2192
+
2193
+			// set the new height, for each cell
2194
+			for ($y=0; $y<count($corr); $y++) {
2195
+				for ($x=0; $x<count($corr[0]); $x++) {
2196
+					if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) {
2197
+						// without rowspan
2198
+						if ($corr[$y][$x][3]==1) {
2199
+							$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $sh[$y];
2200
+						// with rowspan
2201
+						} else {
2202
+							$s = 0;
2203
+							for ($i=0; $i<$corr[$y][$x][3]; $i++) {
2204
+								$s+= $sh[$y+$i];
2205
+							}
2206
+							$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $s;
2207
+
2208
+							for ($j=1; $j<$corr[$y][$x][3]; $j++) {
2209
+								$tx = $x+1;
2210
+								$ty = $y+$j;
2211
+								for (true; isset($corr[$ty][$tx]) && !is_array($corr[$ty][$tx]); $tx++);
2212
+								if (isset($corr[$ty][$tx])) {
2213
+									$cases[$corr[$ty][$tx][1]][$corr[$ty][$tx][0]]['dw']+= $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
2214
+								}
2215
+							}
2216
+						}
2217
+					}
2218
+				}
2219
+			}
2220
+		}
2221
+
2222
+		/**
2223
+		 * tag : PAGE
2224
+		 * mode : OPEN
2225
+		 *
2226
+		 * @param  array $param
2227
+		 * @return boolean
2228
+		 */
2229
+		protected function _tag_open_PAGE($param)
2230
+		{
2231
+			if ($this->_isForOneLine) return false;
2232
+			if ($this->_debugActif) $this->_DEBUG_add('PAGE '.($this->_page+1), true);
2233
+
2234
+			$newPageSet= (!isset($param['pageset']) || $param['pageset']!='old');
2235
+
2236
+			$resetPageNumber = (isset($param['pagegroup']) && $param['pagegroup']=='new');
2237
+
2238
+			$this->_maxH = 0;
2239
+
2240
+			// if new page set asked
2241
+			if ($newPageSet) {
2242
+				$this->_subHEADER = array();
2243
+				$this->_subFOOTER = array();
2244
+
2245
+				// orientation
2246
+				$orientation = '';
2247
+				if (isset($param['orientation'])) {
2248
+					$param['orientation'] = strtolower($param['orientation']);
2249
+					if ($param['orientation']=='p')         $orientation = 'P';
2250
+					if ($param['orientation']=='portrait')  $orientation = 'P';
2251
+
2252
+					if ($param['orientation']=='l')         $orientation = 'L';
2253
+					if ($param['orientation']=='paysage')   $orientation = 'L';
2254
+					if ($param['orientation']=='landscape') $orientation = 'L';
2255
+				}
2256
+
2257
+				// format
2258
+				$format = null;
2259
+				if (isset($param['format'])) {
2260
+					$format = strtolower($param['format']);
2261
+					if (preg_match('/^([0-9]+)x([0-9]+)$/isU', $format, $match)) {
2262
+						$format = array(intval($match[1]), intval($match[2]));
2263
+					}
2264
+				}
2265
+
2266
+				// background
2267
+				$background = array();
2268
+				if (isset($param['backimg'])) {
2269
+					$background['img']    = isset($param['backimg'])  ? $param['backimg']  : '';       // src of the image
2270
+					$background['posX']   = isset($param['backimgx']) ? $param['backimgx'] : 'center'; // horizontale position of the image
2271
+					$background['posY']   = isset($param['backimgy']) ? $param['backimgy'] : 'middle'; // vertical position of the image
2272
+					$background['width']  = isset($param['backimgw']) ? $param['backimgw'] : '100%';   // width of the image (100% = page width)
2273
+
2274
+					// convert the src of the image, if parameters
2275
+					$background['img'] = str_replace('&amp;', '&', $background['img']);
2276
+
2277
+					// convert the positions
2278
+					if ($background['posX']=='left')    $background['posX'] = '0%';
2279
+					if ($background['posX']=='center')  $background['posX'] = '50%';
2280
+					if ($background['posX']=='right')   $background['posX'] = '100%';
2281
+					if ($background['posY']=='top')     $background['posY'] = '0%';
2282
+					if ($background['posY']=='middle')  $background['posY'] = '50%';
2283
+					if ($background['posY']=='bottom')  $background['posY'] = '100%';
2284
+
2285
+					if ($background['img']) {
2286
+						// get the size of the image
2287
+						// WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini
2288
+						$infos=@getimagesize($background['img']);
2289
+						if (count($infos)>1) {
2290
+							$imageWidth = $this->parsingCss->ConvertToMM($background['width'], $this->pdf->getW());
2291
+							$imageHeight = $imageWidth*$infos[1]/$infos[0];
2292
+
2293
+							$background['width'] = $imageWidth;
2294
+							$background['posX']  = $this->parsingCss->ConvertToMM($background['posX'], $this->pdf->getW() - $imageWidth);
2295
+							$background['posY']  = $this->parsingCss->ConvertToMM($background['posY'], $this->pdf->getH() - $imageHeight);
2296
+						} else {
2297
+							$background = array();
2298
+						}
2299
+					} else {
2300
+						$background = array();
2301
+					}
2302
+				}
2303
+
2304
+				// margins of the page
2305
+				$background['top']    = isset($param['backtop'])    ? $param['backtop']    : '0';
2306
+				$background['bottom'] = isset($param['backbottom']) ? $param['backbottom'] : '0';
2307
+				$background['left']   = isset($param['backleft'])   ? $param['backleft']   : '0';
2308
+				$background['right']  = isset($param['backright'])  ? $param['backright']  : '0';
2309
+
2310
+				// if no unit => mm
2311
+				if (preg_match('/^([0-9]*)$/isU', $background['top']))    $background['top']    .= 'mm';
2312
+				if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) $background['bottom'] .= 'mm';
2313
+				if (preg_match('/^([0-9]*)$/isU', $background['left']))   $background['left']   .= 'mm';
2314
+				if (preg_match('/^([0-9]*)$/isU', $background['right']))  $background['right']  .= 'mm';
2315
+
2316
+				// convert to mm
2317
+				$background['top']    = $this->parsingCss->ConvertToMM($background['top'], $this->pdf->getH());
2318
+				$background['bottom'] = $this->parsingCss->ConvertToMM($background['bottom'], $this->pdf->getH());
2319
+				$background['left']   = $this->parsingCss->ConvertToMM($background['left'], $this->pdf->getW());
2320
+				$background['right']  = $this->parsingCss->ConvertToMM($background['right'], $this->pdf->getW());
2321
+
2322
+				// get the background color
2323
+				$res = false;
2324
+				$background['color']    = isset($param['backcolor'])    ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null;
2325
+				if (!$res) $background['color'] = null;
2326
+
2327
+				$this->parsingCss->save();
2328
+				$this->parsingCss->analyse('PAGE', $param);
2329
+				$this->parsingCss->setPosition();
2330
+				$this->parsingCss->fontSet();
2331
+
2332
+				// new page
2333
+				$this->_setNewPage($format, $orientation, $background, null, $resetPageNumber);
2334
+
2335
+				// automatic footer
2336
+				if (isset($param['footer'])) {
2337
+					$lst = explode(';', $param['footer']);
2338
+					foreach ($lst as $key => $val) $lst[$key] = trim(strtolower($val));
2339
+					$page    = in_array('page', $lst);
2340
+					$date    = in_array('date', $lst);
2341
+					$hour    = in_array('heure', $lst);
2342
+					$form    = in_array('form', $lst);
2343
+				} else {
2344
+					$page    = null;
2345
+					$date    = null;
2346
+					$hour    = null;
2347
+					$form    = null;
2348
+				}
2349
+				$this->pdf->SetMyFooter($page, $date, $hour, $form);
2350
+			// else => we use the last page set used
2351
+			} else {
2352
+				$this->parsingCss->save();
2353
+				$this->parsingCss->analyse('PAGE', $param);
2354
+				$this->parsingCss->setPosition();
2355
+				$this->parsingCss->fontSet();
2356
+
2357
+				$this->_setNewPage(null, null, null, null, $resetPageNumber);
2358
+			}
2359
+
2360
+			return true;
2361
+		}
2362
+
2363
+		/**
2364
+		 * tag : PAGE
2365
+		 * mode : CLOSE
2366
+		 *
2367
+		 * @param  array $param
2368
+		 * @return boolean
2369
+		 */
2370
+		protected function _tag_close_PAGE($param)
2371
+		{
2372
+			if ($this->_isForOneLine) return false;
2373
+
2374
+			$this->_maxH = 0;
2375
+
2376
+			$this->parsingCss->load();
2377
+			$this->parsingCss->fontSet();
2378
+
2379
+			if ($this->_debugActif) $this->_DEBUG_add('PAGE '.$this->_page, false);
2380
+
2381
+			return true;
2382
+		}
2383
+
2384
+		/**
2385
+		 * tag : PAGE_HEADER
2386
+		 * mode : OPEN
2387
+		 *
2388
+		 * @param  array $param
2389
+		 * @return boolean
2390
+		 */
2391
+		protected function _tag_open_PAGE_HEADER($param)
2392
+		{
2393
+			if ($this->_isForOneLine) return false;
2394
+
2395
+			$this->_subHEADER = array();
2396
+			for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) {
2397
+				$action = $this->parsingHtml->code[$this->_parsePos];
2398
+				if ($action['name']=='page_header') $action['name']='page_header_sub';
2399
+				$this->_subHEADER[] = $action;
2400
+				if (strtolower($action['name'])=='page_header_sub' && $action['close']) break;
2401
+			}
2402
+
2403
+			$this->_setPageHeader();
2404
+
2405
+			return true;
2406
+		}
2407
+
2408
+		/**
2409
+		 * tag : PAGE_FOOTER
2410
+		 * mode : OPEN
2411
+		 *
2412
+		 * @param  array $param
2413
+		 * @return boolean
2414
+		 */
2415
+		protected function _tag_open_PAGE_FOOTER($param)
2416
+		{
2417
+			if ($this->_isForOneLine) return false;
2418
+
2419
+			$this->_subFOOTER = array();
2420
+			for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) {
2421
+				$action = $this->parsingHtml->code[$this->_parsePos];
2422
+				if ($action['name']=='page_footer') $action['name']='page_footer_sub';
2423
+				$this->_subFOOTER[] = $action;
2424
+				if (strtolower($action['name'])=='page_footer_sub' && $action['close']) break;
2425
+			}
2426
+
2427
+			$this->_setPageFooter();
2428
+
2429
+			return true;
2430
+		}
2431
+
2432
+		/**
2433
+		 * It is not a real tag. Does not use it directly
2434
+		 *
2435
+		 * @param  array $param
2436
+		 * @return boolean
2437
+		 */
2438
+		protected function _tag_open_PAGE_HEADER_SUB($param)
2439
+		{
2440
+			if ($this->_isForOneLine) return false;
2441
+
2442
+			// save the current stat
2443
+			$this->_subSTATES = array();
2444
+			$this->_subSTATES['x']  = $this->pdf->getX();
2445
+			$this->_subSTATES['y']  = $this->pdf->getY();
2446
+			$this->_subSTATES['s']  = $this->parsingCss->value;
2447
+			$this->_subSTATES['t']  = $this->parsingCss->table;
2448
+			$this->_subSTATES['ml'] = $this->_margeLeft;
2449
+			$this->_subSTATES['mr'] = $this->_margeRight;
2450
+			$this->_subSTATES['mt'] = $this->_margeTop;
2451
+			$this->_subSTATES['mb'] = $this->_margeBottom;
2452
+			$this->_subSTATES['mp'] = $this->_pageMarges;
2453
+
2454
+			// new stat for the header
2455
+			$this->_pageMarges = array();
2456
+			$this->_margeLeft    = $this->_defaultLeft;
2457
+			$this->_margeRight   = $this->_defaultRight;
2458
+			$this->_margeTop     = $this->_defaultTop;
2459
+			$this->_margeBottom  = $this->_defaultBottom;
2460
+			$this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight);
2461
+			$this->pdf->SetAutoPageBreak(false, $this->_margeBottom);
2462
+			$this->pdf->setXY($this->_defaultLeft, $this->_defaultTop);
2463
+
2464
+			$this->parsingCss->initStyle();
2465
+			$this->parsingCss->resetStyle();
2466
+			$this->parsingCss->value['width'] = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight;
2467
+			$this->parsingCss->table = array();
2468
+
2469
+			$this->parsingCss->save();
2470
+			$this->parsingCss->analyse('page_header_sub', $param);
2471
+			$this->parsingCss->setPosition();
2472
+			$this->parsingCss->fontSet();
2473
+			$this->_setNewPositionForNewLine();
2474
+			return true;
2475
+		}
2476
+
2477
+		/**
2478
+		 * It is not a real tag. Does not use it directly
2479
+		 *
2480
+		 * @param  array $param
2481
+		 * @return boolean
2482
+		 */
2483
+		protected function _tag_close_PAGE_HEADER_SUB($param)
2484
+		{
2485
+			if ($this->_isForOneLine) return false;
2486
+
2487
+			$this->parsingCss->load();
2488
+
2489
+			// restore the stat
2490
+			$this->parsingCss->value = $this->_subSTATES['s'];
2491
+			$this->parsingCss->table = $this->_subSTATES['t'];
2492
+			$this->_pageMarges       = $this->_subSTATES['mp'];
2493
+			$this->_margeLeft        = $this->_subSTATES['ml'];
2494
+			$this->_margeRight       = $this->_subSTATES['mr'];
2495
+			$this->_margeTop         = $this->_subSTATES['mt'];
2496
+			$this->_margeBottom      = $this->_subSTATES['mb'];
2497
+			$this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight);
2498
+			$this->pdf->setbMargin($this->_margeBottom);
2499
+			$this->pdf->SetAutoPageBreak(false, $this->_margeBottom);
2500
+			$this->pdf->setXY($this->_subSTATES['x'], $this->_subSTATES['y']);
2501
+
2502
+			$this->parsingCss->fontSet();
2503
+			$this->_maxH = 0;
2504
+
2505
+			return true;
2506
+		}
2507
+
2508
+		/**
2509
+		 * It is not a real tag. Does not use it directly
2510
+		 *
2511
+		 * @param  array $param
2512
+		 * @return boolean
2513
+		 */
2514
+		protected function _tag_open_PAGE_FOOTER_SUB($param)
2515
+		{
2516
+			if ($this->_isForOneLine) return false;
2517
+
2518
+			// save the current stat
2519
+			$this->_subSTATES = array();
2520
+			$this->_subSTATES['x']    = $this->pdf->getX();
2521
+			$this->_subSTATES['y']    = $this->pdf->getY();
2522
+			$this->_subSTATES['s']    = $this->parsingCss->value;
2523
+			$this->_subSTATES['t']    = $this->parsingCss->table;
2524
+			$this->_subSTATES['ml']    = $this->_margeLeft;
2525
+			$this->_subSTATES['mr']    = $this->_margeRight;
2526
+			$this->_subSTATES['mt']    = $this->_margeTop;
2527
+			$this->_subSTATES['mb']    = $this->_margeBottom;
2528
+			$this->_subSTATES['mp']    = $this->_pageMarges;
2529
+
2530
+			// new stat for the footer
2531
+			$this->_pageMarges  = array();
2532
+			$this->_margeLeft   = $this->_defaultLeft;
2533
+			$this->_margeRight  = $this->_defaultRight;
2534
+			$this->_margeTop    = $this->_defaultTop;
2535
+			$this->_margeBottom = $this->_defaultBottom;
2536
+			$this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight);
2537
+			$this->pdf->SetAutoPageBreak(false, $this->_margeBottom);
2538
+			$this->pdf->setXY($this->_defaultLeft, $this->_defaultTop);
2539
+
2540
+			$this->parsingCss->initStyle();
2541
+			$this->parsingCss->resetStyle();
2542
+			$this->parsingCss->value['width']    = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight;
2543
+			$this->parsingCss->table                = array();
2544
+
2545
+			// we create a sub HTML2PFDF, and we execute on it the content of the footer, to get the height of it
2546
+			$sub = null;
2547
+			$this->_createSubHTML($sub);
2548
+			$sub->parsingHtml->code = $this->parsingHtml->getLevel($this->_parsePos);
2549
+			$sub->_makeHTMLcode();
2550
+			$this->pdf->setY($this->pdf->getH() - $sub->_maxY - $this->_defaultBottom - 0.01);
2551
+			$this->_destroySubHTML($sub);
2552
+
2553
+			$this->parsingCss->save();
2554
+			$this->parsingCss->analyse('page_footer_sub', $param);
2555
+			$this->parsingCss->setPosition();
2556
+			$this->parsingCss->fontSet();
2557
+			$this->_setNewPositionForNewLine();
2558
+
2559
+			return true;
2560
+		}
2561
+
2562
+		/**
2563
+		 * It is not a real tag. Does not use it directly
2564
+		 *
2565
+		 * @param  array $param
2566
+		 * @return boolean
2567
+		 */
2568
+		protected function _tag_close_PAGE_FOOTER_SUB($param)
2569
+		{
2570
+			if ($this->_isForOneLine) return false;
2571
+
2572
+			$this->parsingCss->load();
2573
+
2574
+			$this->parsingCss->value                = $this->_subSTATES['s'];
2575
+			$this->parsingCss->table                = $this->_subSTATES['t'];
2576
+			$this->_pageMarges                 = $this->_subSTATES['mp'];
2577
+			$this->_margeLeft                = $this->_subSTATES['ml'];
2578
+			$this->_margeRight                = $this->_subSTATES['mr'];
2579
+			$this->_margeTop                    = $this->_subSTATES['mt'];
2580
+			$this->_margeBottom                = $this->_subSTATES['mb'];
2581
+			$this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight);
2582
+			$this->pdf->SetAutoPageBreak(false, $this->_margeBottom);
2583
+			$this->pdf->setXY($this->_subSTATES['x'], $this->_subSTATES['y']);
2584
+
2585
+			$this->parsingCss->fontSet();
2586
+			$this->_maxH = 0;
2587
+
2588
+			return true;
2589
+		}
2590
+
2591
+		/**
2592
+		 * tag : NOBREAK
2593
+		 * mode : OPEN
2594
+		 *
2595
+		 * @param  array $param
2596
+		 * @return boolean
2597
+		 */
2598
+		protected function _tag_open_NOBREAK($param)
2599
+		{
2600
+			if ($this->_isForOneLine) return false;
2601
+
2602
+			$this->_maxH = 0;
2603
+
2604
+			// create a sub HTML2PDF to execute the content of the tag, to get the dimensions
2605
+			$sub = null;
2606
+			$this->_createSubHTML($sub);
2607
+			$sub->parsingHtml->code = $this->parsingHtml->getLevel($this->_parsePos);
2608
+			$sub->_makeHTMLcode();
2609
+			$y = $this->pdf->getY();
2610
+
2611
+			// if the content does not fit on the page => new page
2612
+			if (
2613
+				$sub->_maxY < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin()) &&
2614
+				$y + $sub->_maxY>=($this->pdf->getH() - $this->pdf->getbMargin())
2615
+			) {
2616
+				$this->_setNewPage();
2617
+			}
2618
+
2619
+			// destroy the sub HTML2PDF
2620
+			$this->_destroySubHTML($sub);
2621
+
2622
+			return true;
2623
+		}
2624
+
2625
+
2626
+		/**
2627
+		 * tag : NOBREAK
2628
+		 * mode : CLOSE
2629
+		 *
2630
+		 * @param  array $param
2631
+		 * @return boolean
2632
+		 */
2633
+		protected function _tag_close_NOBREAK($param)
2634
+		{
2635
+			if ($this->_isForOneLine) return false;
2636
+
2637
+			$this->_maxH = 0;
2638
+
2639
+			return true;
2640
+		}
2641
+
2642
+		/**
2643
+		 * tag : DIV
2644
+		 * mode : OPEN
2645
+		 *
2646
+		 * @param  array $param
2647
+		 * @param  string $other name of tag that used the div tag
2648
+		 * @return boolean
2649
+		 */
2650
+		protected function _tag_open_DIV($param, $other = 'div')
2651
+		{
2652
+			if ($this->_isForOneLine) return false;
2653
+			if ($this->_debugActif) $this->_DEBUG_add(strtoupper($other), true);
2654
+
2655
+			$this->parsingCss->save();
2656
+			$this->parsingCss->analyse($other, $param);
2657
+			$this->parsingCss->fontSet();
2658
+
2659
+			// for fieldset and legend
2660
+			if (in_array($other, array('fieldset', 'legend'))) {
2661
+				if (isset($param['moveTop']))  $this->parsingCss->value['margin']['t']    += $param['moveTop'];
2662
+				if (isset($param['moveLeft'])) $this->parsingCss->value['margin']['l']    += $param['moveLeft'];
2663
+				if (isset($param['moveDown'])) $this->parsingCss->value['margin']['b']    += $param['moveDown'];
2664
+			}
2665
+
2666
+			$alignObject = null;
2667
+			if ($this->parsingCss->value['margin-auto']) $alignObject = 'center';
2668
+
2669
+			$marge = array();
2670
+			$marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
2671
+			$marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03;
2672
+			$marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03;
2673
+			$marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03;
2674
+
2675
+			// extract the content of the div
2676
+			$level = $this->parsingHtml->getLevel($this->_parsePos);
2677
+
2678
+			// create a sub HTML2PDF to get the dimensions of the content of the div
2679
+			$w = 0; $h = 0;
2680
+			if (count($level)) {
2681
+				$sub = null;
2682
+				$this->_createSubHTML($sub);
2683
+				$sub->parsingHtml->code = $level;
2684
+				$sub->_makeHTMLcode();
2685
+				$w = $sub->_maxX;
2686
+				$h = $sub->_maxY;
2687
+				$this->_destroySubHTML($sub);
2688
+			}
2689
+			$wReel = $w;
2690
+			$hReel = $h;
2691
+
2692
+			$w+= $marge['l']+$marge['r']+0.001;
2693
+			$h+= $marge['t']+$marge['b']+0.001;
2694
+
2695
+			if ($this->parsingCss->value['overflow']=='hidden') {
2696
+				$overW = max($w, $this->parsingCss->value['width']);
2697
+				$overH = max($h, $this->parsingCss->value['height']);
2698
+				$overflow = true;
2699
+				$this->parsingCss->value['old_maxX'] = $this->_maxX;
2700
+				$this->parsingCss->value['old_maxY'] = $this->_maxY;
2701
+				$this->parsingCss->value['old_maxH'] = $this->_maxH;
2702
+				$this->parsingCss->value['old_overflow'] = $this->_isInOverflow;
2703
+				$this->_isInOverflow = true;
2704
+			} else {
2705
+				$overW = null;
2706
+				$overH = null;
2707
+				$overflow = false;
2708
+				$this->parsingCss->value['width']    = max($w, $this->parsingCss->value['width']);
2709
+				$this->parsingCss->value['height']    = max($h, $this->parsingCss->value['height']);
2710
+			}
2711
+
2712
+			switch($this->parsingCss->value['rotate'])
2713
+			{
2714
+				case 90:
2715
+					$tmp = $overH; $overH = $overW; $overW = $tmp;
2716
+					$tmp = $hReel; $hReel = $wReel; $wReel = $tmp;
2717
+					unset($tmp);
2718
+					$w = $this->parsingCss->value['height'];
2719
+					$h = $this->parsingCss->value['width'];
2720
+					$tX =-$h;
2721
+					$tY = 0;
2722
+					break;
2723
+
2724
+				case 180:
2725
+					$w = $this->parsingCss->value['width'];
2726
+					$h = $this->parsingCss->value['height'];
2727
+					$tX = -$w;
2728
+					$tY = -$h;
2729
+					break;
2730
+
2731
+				case 270:
2732
+					$tmp = $overH; $overH = $overW; $overW = $tmp;
2733
+					$tmp = $hReel; $hReel = $wReel; $wReel = $tmp;
2734
+					unset($tmp);
2735
+					$w = $this->parsingCss->value['height'];
2736
+					$h = $this->parsingCss->value['width'];
2737
+					$tX = 0;
2738
+					$tY =-$w;
2739
+					break;
2740
+
2741
+				default:
2742
+					$w = $this->parsingCss->value['width'];
2743
+					$h = $this->parsingCss->value['height'];
2744
+					$tX = 0;
2745
+					$tY = 0;
2746
+					break;
2747
+			}
2748
+
2749
+			if (!$this->parsingCss->value['position']) {
2750
+				if (
2751
+					$w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) &&
2752
+					$this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin())
2753
+					)
2754
+					$this->_tag_open_BR(array());
2755
+
2756
+				if (
2757
+						($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) &&
2758
+						($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) &&
2759
+						!$this->_isInOverflow
2760
+					)
2761
+					$this->_setNewPage();
2762
+
2763
+				$old = $this->parsingCss->getOldValues();
2764
+				$parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
2765
+
2766
+				if ($parentWidth>$w) {
2767
+					if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
2768
+					else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
2769
+				}
2770
+
2771
+				$this->parsingCss->setPosition();
2772
+			} else {
2773
+				$old = $this->parsingCss->getOldValues();
2774
+				$parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
2775
+
2776
+				if ($parentWidth>$w) {
2777
+					if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
2778
+					else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
2779
+				}
2780
+
2781
+				$this->parsingCss->setPosition();
2782
+				$this->_saveMax();
2783
+				$this->_maxX = 0;
2784
+				$this->_maxY = 0;
2785
+				$this->_maxH = 0;
2786
+				$this->_maxE = 0;
2787
+			}
2788
+
2789
+			if ($this->parsingCss->value['rotate']) {
2790
+				$this->pdf->startTransform();
2791
+				$this->pdf->setRotation($this->parsingCss->value['rotate']);
2792
+				$this->pdf->setTranslate($tX, $tY);
2793
+			}
2794
+
2795
+			$this->_drawRectangle(
2796
+				$this->parsingCss->value['x'],
2797
+				$this->parsingCss->value['y'],
2798
+				$this->parsingCss->value['width'],
2799
+				$this->parsingCss->value['height'],
2800
+				$this->parsingCss->value['border'],
2801
+				$this->parsingCss->value['padding'],
2802
+				0,
2803
+				$this->parsingCss->value['background']
2804
+			);
2805
+
2806
+			$marge = array();
2807
+			$marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
2808
+			$marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03;
2809
+			$marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03;
2810
+			$marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03;
2811
+
2812
+			$this->parsingCss->value['width'] -= $marge['l']+$marge['r'];
2813
+			$this->parsingCss->value['height']-= $marge['t']+$marge['b'];
2814
+
2815
+			$xCorr = 0;
2816
+			$yCorr = 0;
2817
+			if (!$this->_subPart && !$this->_isSubPart) {
2818
+				switch($this->parsingCss->value['text-align'])
2819
+				{
2820
+					case 'right':
2821
+						$xCorr = ($this->parsingCss->value['width']-$wReel);
2822
+						break;
2823
+					case 'center':
2824
+						$xCorr = ($this->parsingCss->value['width']-$wReel)*0.5;
2825
+						break;
2826
+				}
2827
+				if ($xCorr>0) $xCorr=0;
2828
+				switch($this->parsingCss->value['vertical-align'])
2829
+				{
2830
+					case 'bottom':
2831
+						$yCorr = ($this->parsingCss->value['height']-$hReel);
2832
+						break;
2833
+					case 'middle':
2834
+						$yCorr = ($this->parsingCss->value['height']-$hReel)*0.5;
2835
+						break;
2836
+				}
2837
+			}
2838
+
2839
+			if ($overflow) {
2840
+				$overW-= $marge['l']+$marge['r'];
2841
+				$overH-= $marge['t']+$marge['b'];
2842
+				$this->pdf->clippingPathStart(
2843
+					$this->parsingCss->value['x']+$marge['l'],
2844
+					$this->parsingCss->value['y']+$marge['t'],
2845
+					$this->parsingCss->value['width'],
2846
+					$this->parsingCss->value['height']
2847
+				);
2848
+
2849
+				$this->parsingCss->value['x']+= $xCorr;
2850
+
2851
+				// marges from the dimension of the content
2852
+				$mL = $this->parsingCss->value['x']+$marge['l'];
2853
+				$mR = $this->pdf->getW() - $mL - $overW;
2854
+			} else {
2855
+				// marges from the dimension of the div
2856
+				$mL = $this->parsingCss->value['x']+$marge['l'];
2857
+				$mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width'];
2858
+			}
2859
+
2860
+			$x = $this->parsingCss->value['x']+$marge['l'];
2861
+			$y = $this->parsingCss->value['y']+$marge['t']+$yCorr;
2862
+			$this->_saveMargin($mL, 0, $mR);
2863
+			$this->pdf->setXY($x, $y);
2864
+
2865
+			$this->_setNewPositionForNewLine();
2866
+
2867
+			return true;
2868
+		}
2869
+
2870
+		/**
2871
+		 * tag : BLOCKQUOTE
2872
+		 * mode : OPEN
2873
+		 *
2874
+		 * @param  array $param
2875
+		 * @return boolean
2876
+		 */
2877
+		protected function _tag_open_BLOCKQUOTE($param)
2878
+		{
2879
+			return $this->_tag_open_DIV($param, 'blockquote');
2880
+		}
2881
+
2882
+		/**
2883
+		 * tag : LEGEND
2884
+		 * mode : OPEN
2885
+		 *
2886
+		 * @param  array $param
2887
+		 * @return boolean
2888
+		 */
2889
+		protected function _tag_open_LEGEND($param)
2890
+		{
2891
+			return $this->_tag_open_DIV($param, 'legend');
2892
+		}
2893
+
2894
+		/**
2895
+		 * tag : FIELDSET
2896
+		 * mode : OPEN
2897
+		 *
2898
+		 * @author Pavel Kochman
2899
+		 * @param  array $param
2900
+		 * @return boolean
2901
+		 */
2902
+		protected function _tag_open_FIELDSET($param)
2903
+		{
2904
+
2905
+			$this->parsingCss->save();
2906
+			$this->parsingCss->analyse('fieldset', $param);
2907
+
2908
+			// get height of LEGEND element and make fieldset corrections
2909
+			for ($tempPos = $this->_parsePos + 1; $tempPos<count($this->parsingHtml->code); $tempPos++) {
2910
+				$action = $this->parsingHtml->code[$tempPos];
2911
+				if ($action['name'] == 'fieldset') break;
2912
+				if ($action['name'] == 'legend' && !$action['close']) {
2913
+					$legendOpenPos = $tempPos;
2914
+
2915
+					$sub = null;
2916
+					$this->_createSubHTML($sub);
2917
+					$sub->parsingHtml->code = $this->parsingHtml->getLevel($tempPos - 1);
2918
+
2919
+					$res = null;
2920
+					for ($sub->_parsePos = 0; $sub->_parsePos<count($sub->parsingHtml->code); $sub->_parsePos++) {
2921
+						$action = $sub->parsingHtml->code[$sub->_parsePos];
2922
+						$sub->_executeAction($action);
2923
+
2924
+						if ($action['name'] == 'legend' && $action['close'])
2925
+							break;
2926
+					}
2927
+
2928
+					$legendH = $sub->_maxY;
2929
+					$this->_destroySubHTML($sub);
2930
+
2931
+					$move = $this->parsingCss->value['padding']['t'] + $this->parsingCss->value['border']['t']['width'] + 0.03;
2932
+
2933
+					$param['moveTop'] = $legendH / 2;
2934
+
2935
+					$this->parsingHtml->code[$legendOpenPos]['param']['moveTop'] = - ($legendH / 2 + $move);
2936
+					$this->parsingHtml->code[$legendOpenPos]['param']['moveLeft'] = 2 - $this->parsingCss->value['border']['l']['width'] - $this->parsingCss->value['padding']['l'];
2937
+					$this->parsingHtml->code[$legendOpenPos]['param']['moveDown'] = $move;
2938
+					break;
2939
+				}
2940
+			}
2941
+			$this->parsingCss->load();
2942
+
2943
+			return $this->_tag_open_DIV($param, 'fieldset');
2944
+		}
2945
+
2946
+		/**
2947
+		 * tag : DIV
2948
+		 * mode : CLOSE
2949
+		 *
2950
+		 * @param  array $param
2951
+		 * @param  string $other name of tag that used the div tag
2952
+		 * @return boolean
2953
+		 */
2954
+		protected function _tag_close_DIV($param, $other='div')
2955
+		{
2956
+			if ($this->_isForOneLine) return false;
2957
+
2958
+			if ($this->parsingCss->value['overflow']=='hidden') {
2959
+				$this->_maxX = $this->parsingCss->value['old_maxX'];
2960
+				$this->_maxY = $this->parsingCss->value['old_maxY'];
2961
+				$this->_maxH = $this->parsingCss->value['old_maxH'];
2962
+				$this->_isInOverflow = $this->parsingCss->value['old_overflow'];
2963
+				$this->pdf->clippingPathStop();
2964
+			}
2965
+
2966
+			if ($this->parsingCss->value['rotate'])
2967
+				$this->pdf->stopTransform();
2968
+
2969
+			$marge = array();
2970
+			$marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
2971
+			$marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03;
2972
+			$marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03;
2973
+			$marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03;
2974
+
2975
+			$x = $this->parsingCss->value['x'];
2976
+			$y = $this->parsingCss->value['y'];
2977
+			$w = $this->parsingCss->value['width']+$marge['l']+$marge['r']+$this->parsingCss->value['margin']['r'];
2978
+			$h = $this->parsingCss->value['height']+$marge['t']+$marge['b']+$this->parsingCss->value['margin']['b'];
2979
+
2980
+			switch($this->parsingCss->value['rotate'])
2981
+			{
2982
+				case 90:
2983
+					$t = $w; $w = $h; $h = $t;
2984
+					break;
2985
+
2986
+				case 270:
2987
+					$t = $w; $w = $h; $h = $t;
2988
+					break;
2989
+
2990
+				default:
2991
+					break;
2992
+			}
2993
+
2994
+
2995
+			if ($this->parsingCss->value['position']!='absolute') {
2996
+				$this->pdf->setXY($x+$w, $y);
2997
+
2998
+				$this->_maxX = max($this->_maxX, $x+$w);
2999
+				$this->_maxY = max($this->_maxY, $y+$h);
3000
+				$this->_maxH = max($this->_maxH, $h);
3001
+			} else {
3002
+				$this->pdf->setXY($this->parsingCss->value['xc'], $this->parsingCss->value['yc']);
3003
+
3004
+				$this->_loadMax();
3005
+			}
3006
+
3007
+			$block = ($this->parsingCss->value['display']!='inline' && $this->parsingCss->value['position']!='absolute');
3008
+
3009
+			$this->parsingCss->load();
3010
+			$this->parsingCss->fontSet();
3011
+			$this->_loadMargin();
3012
+
3013
+			if ($block) $this->_tag_open_BR(array());
3014
+			if ($this->_debugActif) $this->_DEBUG_add(strtoupper($other), false);
3015
+
3016
+			return true;
3017
+		}
3018
+
3019
+		/**
3020
+		 * tag : BLOCKQUOTE
3021
+		 * mode : CLOSE
3022
+		 *
3023
+		 * @param  array $param
3024
+		 * @return boolean
3025
+		 */
3026
+		protected function _tag_close_BLOCKQUOTE($param)
3027
+		{
3028
+			return $this->_tag_close_DIV($param, 'blockquote');
3029
+		}
3030
+
3031
+		/**
3032
+		 * tag : FIELDSET
3033
+		 * mode : CLOSE
3034
+		 *
3035
+		 * @param  array $param
3036
+		 * @return boolean
3037
+		 */
3038
+		protected function _tag_close_FIELDSET($param)
3039
+		{
3040
+			return $this->_tag_close_DIV($param, 'fieldset');
3041
+		}
3042
+
3043
+		/**
3044
+		 * tag : LEGEND
3045
+		 * mode : CLOSE
3046
+		 *
3047
+		 * @param  array $param
3048
+		 * @return boolean
3049
+		 */
3050
+		protected function _tag_close_LEGEND($param)
3051
+		{
3052
+			return $this->_tag_close_DIV($param, 'legend');
3053
+		}
3054
+
3055
+		/**
3056
+		 * tag : BARCODE
3057
+		 * mode : OPEN
3058
+		 *
3059
+		 * @param  array $param
3060
+		 * @return boolean
3061
+		 */
3062
+		protected function _tag_open_BARCODE($param)
3063
+		{
3064
+			// for  compatibility with old versions < 3.29
3065
+			$lstBarcode = array();
3066
+			$lstBarcode['UPC_A']  =    'UPCA';
3067
+			$lstBarcode['CODE39'] =    'C39';
3068
+
3069
+			if (!isset($param['type']))     $param['type'] = 'C39';
3070
+			if (!isset($param['value']))    $param['value']    = 0;
3071
+			if (!isset($param['label']))    $param['label']    = 'label';
3072
+			if (!isset($param['style']['color'])) $param['style']['color'] = '#000000';
3073
+
3074
+			if ($this->_testIsDeprecated && (isset($param['bar_h']) || isset($param['bar_w'])))
3075
+				throw new HTML2PDF_exception(9, array('BARCODE', 'bar_h, bar_w'));
3076
+
3077
+			$param['type'] = strtoupper($param['type']);
3078
+			if (isset($lstBarcode[$param['type']])) $param['type'] = $lstBarcode[$param['type']];
3079
+
3080
+			$this->parsingCss->save();
3081
+			$this->parsingCss->analyse('barcode', $param);
3082
+			$this->parsingCss->setPosition();
3083
+			$this->parsingCss->fontSet();
3084
+
3085
+			$x = $this->pdf->getX();
3086
+			$y = $this->pdf->getY();
3087
+			$w = $this->parsingCss->value['width'];    if (!$w) $w = $this->parsingCss->ConvertToMM('50mm');
3088
+			$h = $this->parsingCss->value['height'];    if (!$h) $h = $this->parsingCss->ConvertToMM('10mm');
3089
+			$txt = ($param['label']!=='none' ? $this->parsingCss->value['font-size'] : false);
3090
+			$c = $this->parsingCss->value['color'];
3091
+			$infos = $this->pdf->myBarcode($param['value'], $param['type'], $x, $y, $w, $h, $txt, $c);
3092
+
3093
+			$this->_maxX = max($this->_maxX, $x+$infos[0]);
3094
+			$this->_maxY = max($this->_maxY, $y+$infos[1]);
3095
+			$this->_maxH = max($this->_maxH, $infos[1]);
3096
+			$this->_maxE++;
3097
+
3098
+			$this->pdf->setXY($x+$infos[0], $y);
3099
+
3100
+			$this->parsingCss->load();
3101
+			$this->parsingCss->fontSet();
3102
+
3103
+			return true;
3104
+		}
3105
+
3106
+		/**
3107
+		 * tag : BARCODE
3108
+		 * mode : CLOSE
3109
+		 *
3110
+		 * @param  array $param
3111
+		 * @return boolean
3112
+		 */
3113
+		protected function _tag_close_BARCODE($param)
3114
+		{
3115
+			// there is nothing to do here
3116
+
3117
+			return true;
3118
+		}
3119
+
3120
+		/**
3121
+		 * tag : QRCODE
3122
+		 * mode : OPEN
3123
+		 *
3124
+		 * @param  array $param
3125
+		 * @return boolean
3126
+		 */
3127
+		protected function _tag_open_QRCODE($param)
3128
+		{
3129
+			if ($this->_testIsDeprecated && (isset($param['size']) || isset($param['noborder'])))
3130
+				throw new HTML2PDF_exception(9, array('QRCODE', 'size, noborder'));
3131
+
3132
+			if ($this->_debugActif) $this->_DEBUG_add('QRCODE');
3133
+
3134
+			if (!isset($param['value']))                     $param['value'] = '';
3135
+			if (!isset($param['ec']))                        $param['ec'] = 'H';
3136
+			if (!isset($param['style']['color']))            $param['style']['color'] = '#000000';
3137
+			if (!isset($param['style']['background-color'])) $param['style']['background-color'] = '#FFFFFF';
3138
+			if (isset($param['style']['border'])) {
3139
+				$borders = $param['style']['border']!='none';
3140
+				unset($param['style']['border']);
3141
+			} else {
3142
+				$borders = true;
3143
+			}
3144
+
3145
+			if ($param['value']==='') return true;
3146
+			if (!in_array($param['ec'], array('L', 'M', 'Q', 'H'))) $param['ec'] = 'H';
3147
+
3148
+			$this->parsingCss->save();
3149
+			$this->parsingCss->analyse('qrcode', $param);
3150
+			$this->parsingCss->setPosition();
3151
+			$this->parsingCss->fontSet();
3152
+
3153
+			$x = $this->pdf->getX();
3154
+			$y = $this->pdf->getY();
3155
+			$w = $this->parsingCss->value['width'];
3156
+			$h = $this->parsingCss->value['height'];
3157
+			$size = max($w, $h); if (!$size) $size = $this->parsingCss->ConvertToMM('50mm');
3158
+
3159
+			$style = array(
3160
+					'fgcolor' => $this->parsingCss->value['color'],
3161
+					'bgcolor' => $this->parsingCss->value['background']['color'],
3162
+				);
3163
+
3164
+			if ($borders) {
3165
+				$style['border'] = true;
3166
+				$style['padding'] = 'auto';
3167
+			} else {
3168
+				$style['border'] = false;
3169
+				$style['padding'] = 0;
3170
+			}
3171
+
3172
+			if (!$this->_subPart && !$this->_isSubPart) {
3173
+				$this->pdf->write2DBarcode($param['value'], 'QRCODE,'.$param['ec'], $x, $y, $size, $size, $style);
3174
+			}
3175
+
3176
+			$this->_maxX = max($this->_maxX, $x+$size);
3177
+			$this->_maxY = max($this->_maxY, $y+$size);
3178
+			$this->_maxH = max($this->_maxH, $size);
3179
+			$this->_maxE++;
3180
+
3181
+			$this->pdf->setX($x+$size);
3182
+
3183
+			$this->parsingCss->load();
3184
+			$this->parsingCss->fontSet();
3185
+
3186
+			return true;
3187
+		}
3188
+
3189
+		/**
3190
+		 * tag : QRCODE
3191
+		 * mode : CLOSE
3192
+		 *
3193
+		 * @param  array $param
3194
+		 * @return boolean
3195
+		 */
3196
+		protected function _tag_close_QRCODE($param)
3197
+		{
3198
+			// there is nothing to do here
3199
+
3200
+			return true;
3201
+		}
3202
+
3203
+		/**
3204
+		 * tag : BOOKMARK
3205
+		 * mode : OPEN
3206
+		 *
3207
+		 * @param  array $param
3208
+		 * @return boolean
3209
+		 */
3210
+		protected function _tag_open_BOOKMARK($param)
3211
+		{
3212
+			$titre = isset($param['title']) ? trim($param['title']) : '';
3213
+			$level = isset($param['level']) ? floor($param['level']) : 0;
3214
+
3215
+			if ($level<0) $level = 0;
3216
+			if ($titre) $this->pdf->Bookmark($titre, $level, -1);
3217
+
3218
+			return true;
3219
+		}
3220
+
3221
+		/**
3222
+		 * tag : BOOKMARK
3223
+		 * mode : CLOSE
3224
+		 *
3225
+		 * @param  array $param
3226
+		 * @return boolean
3227
+		 */
3228
+		protected function _tag_close_BOOKMARK($param)
3229
+		{
3230
+			// there is nothing to do here
3231
+
3232
+			return true;
3233
+		}
3234
+
3235
+		/**
3236
+		 * this is not a real TAG, it is just to write texts
3237
+		 *
3238
+		 * @param  array $param
3239
+		 * @return boolean
3240
+		 */
3241
+		protected function _tag_open_WRITE($param)
3242
+		{
3243
+			$fill = ($this->parsingCss->value['background']['color']!==null && $this->parsingCss->value['background']['image']===null);
3244
+			if (in_array($this->parsingCss->value['id_tag'], array('fieldset', 'legend', 'div', 'table', 'tr', 'td', 'th'))) {
3245
+				$fill = false;
3246
+			}
3247
+
3248
+			// get the text to write
3249
+			$txt = $param['txt'];
3250
+
3251
+			if ($this->_isAfterFloat) {
3252
+				$txt = ltrim($txt);
3253
+				$this->_isAfterFloat = false;
3254
+			}
3255
+
3256
+			$txt = str_replace('[[page_nb]]', $this->pdf->getMyAliasNbPages(), $txt);
3257
+			$txt = str_replace('[[page_cu]]', $this->pdf->getMyNumPage($this->_page), $txt);
3258
+
3259
+			if ($this->parsingCss->value['text-transform']!='none') {
3260
+				if ($this->parsingCss->value['text-transform']=='capitalize')
3261
+					$txt = ucwords($txt);
3262
+				else if ($this->parsingCss->value['text-transform']=='uppercase')
3263
+					$txt = strtoupper($txt);
3264
+				else if ($this->parsingCss->value['text-transform']=='lowercase')
3265
+					$txt = strtolower($txt);
3266
+			}
3267
+
3268
+			// size of the text
3269
+			$h  = 1.08*$this->parsingCss->value['font-size'];
3270
+			$dh = $h*$this->parsingCss->value['mini-decal'];
3271
+			$lh = $this->parsingCss->getLineHeight();
3272
+
3273
+			// identify the align
3274
+			$align = 'L';
3275
+			if ($this->parsingCss->value['text-align']=='li_right') {
3276
+				$w = $this->parsingCss->value['width'];
3277
+				$align = 'R';
3278
+			}
3279
+
3280
+			// calculate the width of each words, and of all the sentence
3281
+			$w = 0;
3282
+			$words = explode(' ', $txt);
3283
+			foreach ($words as $k => $word) {
3284
+				$words[$k] = array($word, $this->pdf->GetStringWidth($word));
3285
+				$w+= $words[$k][1];
3286
+			}
3287
+			$space = $this->pdf->GetStringWidth(' ');
3288
+			$w+= $space*(count($words)-1);
3289
+
3290
+			// position in the text
3291
+			$currPos = 0;
3292
+
3293
+			// the bigger width of the text, after automatic break line
3294
+			$maxX = 0;
3295
+
3296
+			// position of the text
3297
+			$x = $this->pdf->getX();
3298
+			$y = $this->pdf->getY();
3299
+			$dy = $this->_getElementY($lh);
3300
+
3301
+			// margins
3302
+			list($left, $right) = $this->_getMargins($y);
3303
+
3304
+			// number of lines after automatic break line
3305
+			$nb = 0;
3306
+
3307
+			// while we have words, and the text does not fit on the line => we cut the sentence
3308
+			while ($x+$w>$right && $x<$right+$space && count($words)) {
3309
+				// adding words 1 by 1 to fit on the line
3310
+				$i=0;
3311
+				$old = array('', 0);
3312
+				$str = $words[0];
3313
+				$add = false;
3314
+				while (($x+$str[1])<$right) {
3315
+					$i++;
3316
+					$add = true;
3317
+
3318
+					array_shift($words);
3319
+					$old = $str;
3320
+
3321
+					if (!count($words)) break;
3322
+					$str[0].= ' '.$words[0][0];
3323
+					$str[1]+= $space+$words[0][1];
3324
+				}
3325
+				$str = $old;
3326
+
3327
+				// if  nothing fit on the line, and if the first word does not fit on the line => the word is too long, we put it
3328
+				if ($i==0 && (($left+$words[0][1])>=$right)) {
3329
+					$str = $words[0];
3330
+					array_shift($words);
3331
+					$i++;
3332
+					$add = true;
3333
+				}
3334
+				$currPos+= ($currPos ? 1 : 0)+strlen($str[0]);
3335
+
3336
+				// write the extract sentence that fit on the page
3337
+				$wc = ($align=='L' ? $str[1] : $this->parsingCss->value['width']);
3338
+				if ($right - $left<$wc) $wc = $right - $left;
3339
+
3340
+				if (strlen($str[0])) {
3341
+					$this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy);
3342
+					$this->pdf->Cell($wc, $h, $str[0], 0, 0, $align, $fill, $this->_isInLink);
3343
+					$this->pdf->setXY($this->pdf->getX(), $y);
3344
+				}
3345
+				$this->_maxH = max($this->_maxH, $lh);
3346
+
3347
+				// max width
3348
+				$maxX = max($maxX, $this->pdf->getX());
3349
+
3350
+				// new position and new width for the "while"
3351
+				$w-= $str[1];
3352
+				$y = $this->pdf->getY();
3353
+				$x = $this->pdf->getX();
3354
+				$dy = $this->_getElementY($lh);
3355
+
3356
+				// if we have again words to write
3357
+				if (count($words)) {
3358
+					// remove the space at the end
3359
+					if ($add) $w-= $space;
3360
+
3361
+					// if we don't add any word, and if the first word is empty => useless space to skip
3362
+					if (!$add && $words[0][0]==='') {
3363
+						array_shift($words);
3364
+					}
3365
+
3366
+					// if it is just to calculate for one line => adding the number of words
3367
+					if ($this->_isForOneLine) {
3368
+						$this->_maxE+= $i;
3369
+						$this->_maxX = max($this->_maxX, $maxX);
3370
+						return null;
3371
+					}
3372
+
3373
+					// automatic line break
3374
+					$this->_tag_open_BR(array('style' => ''), $currPos);
3375
+
3376
+					// new position
3377
+					$y = $this->pdf->getY();
3378
+					$x = $this->pdf->getX();
3379
+					$dy = $this->_getElementY($lh);
3380
+
3381
+					// if the next line does  not fit on the page => new page
3382
+					if ($y + $h>=$this->pdf->getH() - $this->pdf->getbMargin()) {
3383
+						if (!$this->_isInOverflow && !$this->_isInFooter) {
3384
+							$this->_setNewPage(null, '', null, $currPos);
3385
+							$y = $this->pdf->getY();
3386
+							$x = $this->pdf->getX();
3387
+							$dy = $this->_getElementY($lh);
3388
+						}
3389
+					}
3390
+
3391
+					// if more than 10000 line => error
3392
+					$nb++;
3393
+					if ($nb>10000) {
3394
+						$txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0];
3395
+						throw new HTML2PDF_exception(2, array($txt, $right-$left, $w));
3396
+					}
3397
+
3398
+					// new margins for the new line
3399
+					list($left, $right) = $this->_getMargins($y);
3400
+				}
3401
+			}
3402
+
3403
+			// if we have words after automatic cut, it is because they fit on the line => we write the text
3404
+			if (count($words)) {
3405
+				$txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0];
3406
+				$w+= $this->pdf->getWordSpacing()*(count($words));
3407
+				$this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy);
3408
+				$this->pdf->Cell(($align=='L' ? $w : $this->parsingCss->value['width']), $h, $txt, 0, 0, $align, $fill, $this->_isInLink);
3409
+				$this->pdf->setXY($this->pdf->getX(), $y);
3410
+				$this->_maxH = max($this->_maxH, $lh);
3411
+				$this->_maxE+= count($words);
3412
+			}
3413
+
3414
+			$maxX = max($maxX, $this->pdf->getX());
3415
+			$maxY = $this->pdf->getY()+$h;
3416
+
3417
+			$this->_maxX = max($this->_maxX, $maxX);
3418
+			$this->_maxY = max($this->_maxY, $maxY);
3419
+
3420
+			return true;
3421
+		}
3422
+
3423
+		/**
3424
+		 * tag : BR
3425
+		 * mode : OPEN
3426
+		 *
3427
+		 * @param  array   $param
3428
+		 * @param  integer $curr real position in the html parseur (if break line in the write of a text)
3429
+		 * @return boolean
3430
+		 */
3431
+		protected function _tag_open_BR($param, $curr = null)
3432
+		{
3433
+			if ($this->_isForOneLine) return false;
3434
+
3435
+			$h = max($this->_maxH, $this->parsingCss->getLineHeight());
3436
+
3437
+			if ($this->_maxH==0) $this->_maxY = max($this->_maxY, $this->pdf->getY()+$h);
3438
+
3439
+			$this->_makeBreakLine($h, $curr);
3440
+
3441
+			$this->_maxH = 0;
3442
+			$this->_maxE = 0;
3443
+
3444
+			return true;
3445
+		}
3446
+
3447
+		/**
3448
+		 * tag : HR
3449
+		 * mode : OPEN
3450
+		 *
3451
+		 * @param  array $param
3452
+		 * @return boolean
3453
+		 */
3454
+		protected function _tag_open_HR($param)
3455
+		{
3456
+			if ($this->_isForOneLine) return false;
3457
+			$oldAlign = $this->parsingCss->value['text-align'];
3458
+			$this->parsingCss->value['text-align'] = 'left';
3459
+
3460
+			if ($this->_maxH) $this->_tag_open_BR($param);
3461
+
3462
+			$fontSize = $this->parsingCss->value['font-size'];
3463
+			$this->parsingCss->value['font-size']=$fontSize*0.5; $this->_tag_open_BR($param);
3464
+			$this->parsingCss->value['font-size']=0;
3465
+
3466
+			$param['style']['width'] = '100%';
3467
+
3468
+			$this->parsingCss->save();
3469
+			$this->parsingCss->value['height']=$this->parsingCss->ConvertToMM('1mm');
3470
+
3471
+			$this->parsingCss->analyse('hr', $param);
3472
+			$this->parsingCss->setPosition();
3473
+			$this->parsingCss->fontSet();
3474
+
3475
+			$h = $this->parsingCss->value['height'];
3476
+			if ($h)    $h-= $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width'];
3477
+			if ($h<=0) $h = $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width'];
3478
+
3479
+			$this->_drawRectangle($this->pdf->getX(), $this->pdf->getY(), $this->parsingCss->value['width'], $h, $this->parsingCss->value['border'], 0, 0, $this->parsingCss->value['background']);
3480
+			$this->_maxH = $h;
3481
+
3482
+			$this->parsingCss->load();
3483
+			$this->parsingCss->fontSet();
3484
+
3485
+			$this->_tag_open_BR($param);
3486
+
3487
+			$this->parsingCss->value['font-size']=$fontSize*0.5; $this->_tag_open_BR($param);
3488
+			$this->parsingCss->value['font-size']=$fontSize;
3489
+
3490
+			$this->parsingCss->value['text-align'] = $oldAlign;
3491
+			$this->_setNewPositionForNewLine();
3492
+
3493
+			return true;
3494
+		}
3495
+
3496
+		/**
3497
+		 * tag : B
3498
+		 * mode : OPEN
3499
+		 *
3500
+		 * @param  array $param
3501
+		 * @param  string $other
3502
+		 * @return boolean
3503
+		 */
3504
+		protected function _tag_open_B($param, $other = 'b')
3505
+		{
3506
+			$this->parsingCss->save();
3507
+			$this->parsingCss->value['font-bold'] = true;
3508
+			$this->parsingCss->analyse($other, $param);
3509
+			$this->parsingCss->setPosition();
3510
+			$this->parsingCss->fontSet();
3511
+
3512
+			return true;
3513
+		}
3514
+
3515
+		/**
3516
+		 * tag : STRONG
3517
+		 * mode : OPEN
3518
+		 *
3519
+		 * @param  array $param
3520
+		 * @return boolean
3521
+		 */
3522
+		protected function _tag_open_STRONG($param)
3523
+		{
3524
+			return $this->_tag_open_B($param, 'strong');
3525
+		}
3526
+
3527
+		/**
3528
+		 * tag : B
3529
+		 * mode : CLOSE
3530
+		 *
3531
+		 * @param    array $param
3532
+		 * @return boolean
3533
+		 */
3534
+		protected function _tag_close_B($param)
3535
+		{
3536
+			$this->parsingCss->load();
3537
+			$this->parsingCss->fontSet();
3538
+
3539
+			return true;
3540
+		}
3541
+
3542
+		/**
3543
+		 * tag : STRONG
3544
+		 * mode : CLOSE
3545
+		 *
3546
+		 * @param  array $param
3547
+		 * @return boolean
3548
+		 */
3549
+		protected function _tag_close_STRONG($param)
3550
+		{
3551
+			return $this->_tag_close_B($param);
3552
+		}
3553
+
3554
+		/**
3555
+		 * tag : I
3556
+		 * mode : OPEN
3557
+		 *
3558
+		 * @param  array $param
3559
+		 * @param  string $other
3560
+		 * @return boolean
3561
+		 */
3562
+		protected function _tag_open_I($param, $other = 'i')
3563
+		{
3564
+			$this->parsingCss->save();
3565
+			$this->parsingCss->value['font-italic'] = true;
3566
+			$this->parsingCss->analyse($other, $param);
3567
+			$this->parsingCss->setPosition();
3568
+			$this->parsingCss->fontSet();
3569
+
3570
+			return true;
3571
+		}
3572
+
3573
+		/**
3574
+		 * tag : ADDRESS
3575
+		 * mode : OPEN
3576
+		 *
3577
+		 * @param  array $param
3578
+		 * @return boolean
3579
+		 */
3580
+		protected function _tag_open_ADDRESS($param)
3581
+		{
3582
+			return $this->_tag_open_I($param, 'address');
3583
+		}
3584
+
3585
+		/**
3586
+		 * tag : CITE
3587
+		 * mode : OPEN
3588
+		 *
3589
+		 * @param  array $param
3590
+		 * @return boolean
3591
+		 */
3592
+		protected function _tag_open_CITE($param)
3593
+		{
3594
+			return $this->_tag_open_I($param, 'cite');
3595
+		}
3596
+
3597
+		/**
3598
+		 * tag : EM
3599
+		 * mode : OPEN
3600
+		 *
3601
+		 * @param  array $param
3602
+		 * @return boolean
3603
+		 */
3604
+		protected function _tag_open_EM($param)
3605
+		{
3606
+			return $this->_tag_open_I($param, 'em');
3607
+		}
3608
+
3609
+		/**
3610
+		 * tag : SAMP
3611
+		 * mode : OPEN
3612
+		 *
3613
+		 * @param  array $param
3614
+		 * @return boolean
3615
+		 */
3616
+		protected function _tag_open_SAMP($param)
3617
+		{
3618
+			return $this->_tag_open_I($param, 'samp');
3619
+		}
3620
+
3621
+		/**
3622
+		 * tag : I
3623
+		 * mode : CLOSE
3624
+		 *
3625
+		 * @param  array $param
3626
+		 * @return boolean
3627
+		 */
3628
+		protected function _tag_close_I($param)
3629
+		{
3630
+			$this->parsingCss->load();
3631
+			$this->parsingCss->fontSet();
3632
+
3633
+			return true;
3634
+		}
3635
+
3636
+		/**
3637
+		 * tag : ADDRESS
3638
+		 * mode : CLOSE
3639
+		 *
3640
+		 * @param  array $param
3641
+		 * @return boolean
3642
+		 */
3643
+		protected function _tag_close_ADDRESS($param)
3644
+		{
3645
+			return $this->_tag_close_I($param);
3646
+		}
3647
+
3648
+		/**
3649
+		 * tag : CITE
3650
+		 * mode : CLOSE
3651
+		 *
3652
+		 * @param  array $param
3653
+		 * @return boolean
3654
+		 */
3655
+		protected function _tag_close_CITE($param)
3656
+		{
3657
+			return $this->_tag_close_I($param);
3658
+		}
3659
+
3660
+		/**
3661
+		 * tag : EM
3662
+		 * mode : CLOSE
3663
+		 *
3664
+		 * @param  array $param
3665
+		 * @return boolean
3666
+		 */
3667
+		protected function _tag_close_EM($param)
3668
+		{
3669
+			return $this->_tag_close_I($param);
3670
+		}
3671
+
3672
+		/**
3673
+		 * tag : SAMP
3674
+		 * mode : CLOSE
3675
+		 *
3676
+		 * @param  array $param
3677
+		 * @return boolean
3678
+		 */
3679
+		protected function _tag_close_SAMP($param)
3680
+		{
3681
+			return $this->_tag_close_I($param);
3682
+		}
3683
+
3684
+		/**
3685
+		 * tag : S
3686
+		 * mode : OPEN
3687
+		 *
3688
+		 * @param  array $param
3689
+		 * @param  string $other
3690
+		 * @return boolean
3691
+		 */
3692
+		protected function _tag_open_S($param, $other = 's')
3693
+		{
3694
+			$this->parsingCss->save();
3695
+			$this->parsingCss->value['font-linethrough'] = true;
3696
+			$this->parsingCss->analyse($other, $param);
3697
+			$this->parsingCss->setPosition();
3698
+			$this->parsingCss->fontSet();
3699
+
3700
+			return true;
3701
+		}
3702
+
3703
+		/**
3704
+		 * tag : DEL
3705
+		 * mode : OPEN
3706
+		 *
3707
+		 * @param  array $param
3708
+		 * @return boolean
3709
+		 */
3710
+		protected function _tag_open_DEL($param)
3711
+		{
3712
+			return $this->_tag_open_S($param, 'del');
3713
+		}
3714
+
3715
+		/**
3716
+		 * tag : S
3717
+		 * mode : CLOSE
3718
+		 *
3719
+		 * @param    array $param
3720
+		 * @return boolean
3721
+		 */
3722
+		protected function _tag_close_S($param)
3723
+		{
3724
+			$this->parsingCss->load();
3725
+			$this->parsingCss->fontSet();
3726
+
3727
+			return true;
3728
+		}
3729
+
3730
+		/**
3731
+		 * tag : DEL
3732
+		 * mode : CLOSE
3733
+		 *
3734
+		 * @param  array $param
3735
+		 * @return boolean
3736
+		 */
3737
+		protected function _tag_close_DEL($param)
3738
+		{
3739
+			return $this->_tag_close_S($param);
3740
+		}
3741
+
3742
+		/**
3743
+		 * tag : U
3744
+		 * mode : OPEN
3745
+		 *
3746
+		 * @param  array $param
3747
+		 * @param  string $other
3748
+		 * @return boolean
3749
+		 */
3750
+		protected function _tag_open_U($param, $other='u')
3751
+		{
3752
+			$this->parsingCss->save();
3753
+			$this->parsingCss->value['font-underline'] = true;
3754
+			$this->parsingCss->analyse($other, $param);
3755
+			$this->parsingCss->setPosition();
3756
+			$this->parsingCss->fontSet();
3757
+
3758
+			return true;
3759
+		}
3760
+
3761
+		/**
3762
+		 * tag : INS
3763
+		 * mode : OPEN
3764
+		 *
3765
+		 * @param  array $param
3766
+		 * @return boolean
3767
+		 */
3768
+		protected function _tag_open_INS($param)
3769
+		{
3770
+			return $this->_tag_open_U($param, 'ins');
3771
+		}
3772
+
3773
+		/**
3774
+		 * tag : U
3775
+		 * mode : CLOSE
3776
+		 *
3777
+		 * @param    array $param
3778
+		 * @return boolean
3779
+		 */
3780
+		protected function _tag_close_U($param)
3781
+		{
3782
+			$this->parsingCss->load();
3783
+			$this->parsingCss->fontSet();
3784
+
3785
+			return true;
3786
+		}
3787
+
3788
+		/**
3789
+		 * tag : INS
3790
+		 * mode : CLOSE
3791
+		 *
3792
+		 * @param  array $param
3793
+		 * @return boolean
3794
+		 */
3795
+		protected function _tag_close_INS($param)
3796
+		{
3797
+			return $this->_tag_close_U($param);
3798
+		}
3799
+
3800
+		/**
3801
+		 * tag : A
3802
+		 * mode : OPEN
3803
+		 *
3804
+		 * @param  array $param
3805
+		 * @return boolean
3806
+		 */
3807
+		protected function _tag_open_A($param)
3808
+		{
3809
+			$this->_isInLink = str_replace('&amp;', '&', isset($param['href']) ? $param['href'] : '');
3810
+
3811
+			if (isset($param['name'])) {
3812
+				$name =     $param['name'];
3813
+				if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false);
3814
+
3815
+				if (!$this->_lstAnchor[$name][1]) {
3816
+					$this->_lstAnchor[$name][1] = true;
3817
+					$this->pdf->SetLink($this->_lstAnchor[$name][0], -1, -1);
3818
+				}
3819
+			}
3820
+
3821
+			if (preg_match('/^#([^#]+)$/isU', $this->_isInLink, $match)) {
3822
+				$name = $match[1];
3823
+				if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false);
3824
+
3825
+				$this->_isInLink = $this->_lstAnchor[$name][0];
3826
+			}
3827
+
3828
+			$this->parsingCss->save();
3829
+			$this->parsingCss->value['font-underline'] = true;
3830
+			$this->parsingCss->value['color'] = array(20, 20, 250);
3831
+			$this->parsingCss->analyse('a', $param);
3832
+			$this->parsingCss->setPosition();
3833
+			$this->parsingCss->fontSet();
3834
+
3835
+			return true;
3836
+		}
3837
+
3838
+		/**
3839
+		 * tag : A
3840
+		 * mode : CLOSE
3841
+		 *
3842
+		 * @param  array $param
3843
+		 * @return boolean
3844
+		 */
3845
+		protected function _tag_close_A($param)
3846
+		{
3847
+			$this->_isInLink    = '';
3848
+			$this->parsingCss->load();
3849
+			$this->parsingCss->fontSet();
3850
+
3851
+			return true;
3852
+		}
3853
+
3854
+		/**
3855
+		 * tag : H1
3856
+		 * mode : OPEN
3857
+		 *
3858
+		 * @param  array $param
3859
+		 * @param  string $other
3860
+		 * @return boolean
3861
+		 */
3862
+		protected function _tag_open_H1($param, $other = 'h1')
3863
+		{
3864
+			if ($this->_isForOneLine) return false;
3865
+
3866
+			if ($this->_maxH) $this->_tag_open_BR(array());
3867
+			$this->parsingCss->save();
3868
+			$this->parsingCss->value['font-bold'] = true;
3869
+
3870
+			$size = array('h1' => '28px', 'h2' => '24px', 'h3' => '20px', 'h4' => '16px', 'h5' => '12px', 'h6' => '9px');
3871
+			$this->parsingCss->value['margin']['l'] = 0;
3872
+			$this->parsingCss->value['margin']['r'] = 0;
3873
+			$this->parsingCss->value['margin']['t'] = $this->parsingCss->ConvertToMM('16px');
3874
+			$this->parsingCss->value['margin']['b'] = $this->parsingCss->ConvertToMM('16px');
3875
+			$this->parsingCss->value['font-size'] = $this->parsingCss->ConvertToMM($size[$other]);
3876
+
3877
+			$this->parsingCss->analyse($other, $param);
3878
+			$this->parsingCss->setPosition();
3879
+			$this->parsingCss->fontSet();
3880
+			$this->_setNewPositionForNewLine();
3881
+
3882
+			return true;
3883
+		}
3884
+
3885
+		/**
3886
+		 * tag : H2
3887
+		 * mode : OPEN
3888
+		 *
3889
+		 * @param  array $param
3890
+		 * @return boolean
3891
+		 */
3892
+		protected function _tag_open_H2($param)
3893
+		{
3894
+			return $this->_tag_open_H1($param, 'h2');
3895
+		}
3896
+
3897
+		/**
3898
+		 * tag : H3
3899
+		 * mode : OPEN
3900
+		 *
3901
+		 * @param  array $param
3902
+		 * @return boolean
3903
+		 */
3904
+		protected function _tag_open_H3($param)
3905
+		{
3906
+			return $this->_tag_open_H1($param, 'h3');
3907
+		}
3908
+
3909
+		/**
3910
+		 * tag : H4
3911
+		 * mode : OPEN
3912
+		 *
3913
+		 * @param  array $param
3914
+		 * @return boolean
3915
+		 */
3916
+		protected function _tag_open_H4($param)
3917
+		{
3918
+			return $this->_tag_open_H1($param, 'h4');
3919
+		}
3920
+
3921
+		/**
3922
+		 * tag : H5
3923
+		 * mode : OPEN
3924
+		 *
3925
+		 * @param  array $param
3926
+		 * @return boolean
3927
+		 */
3928
+		protected function _tag_open_H5($param)
3929
+		{
3930
+			return $this->_tag_open_H1($param, 'h5');
3931
+		}
3932
+
3933
+		/**
3934
+		 * tag : H6
3935
+		 * mode : OPEN
3936
+		 *
3937
+		 * @param  array $param
3938
+		 * @return boolean
3939
+		 */
3940
+		protected function _tag_open_H6($param)
3941
+		{
3942
+			return $this->_tag_open_H1($param, 'h6');
3943
+		}
3944
+
3945
+		/**
3946
+		 * tag : H1
3947
+		 * mode : CLOSE
3948
+		 *
3949
+		 * @param  array $param
3950
+		 * @return boolean
3951
+		 */
3952
+		protected function _tag_close_H1($param)
3953
+		{
3954
+			if ($this->_isForOneLine) return false;
3955
+
3956
+			$this->_maxH+= $this->parsingCss->value['margin']['b'];
3957
+			$h = max($this->_maxH, $this->parsingCss->getLineHeight());
3958
+
3959
+			$this->parsingCss->load();
3960
+			$this->parsingCss->fontSet();
3961
+
3962
+			$this->_makeBreakLine($h);
3963
+			$this->_maxH = 0;
3964
+
3965
+			$this->_maxY = max($this->_maxY, $this->pdf->getY());
3966
+
3967
+			return true;
3968
+		}
3969
+
3970
+		/**
3971
+		 * tag : H2
3972
+		 * mode : CLOSE
3973
+		 *
3974
+		 * @param  array $param
3975
+		 * @return boolean
3976
+		 */
3977
+		protected function _tag_close_H2($param)
3978
+		{
3979
+			return $this->_tag_close_H1($param);
3980
+		}
3981
+
3982
+		/**
3983
+		 * tag : H3
3984
+		 * mode : CLOSE
3985
+		 *
3986
+		 * @param  array $param
3987
+		 * @return boolean
3988
+		 */
3989
+		protected function _tag_close_H3($param)
3990
+		{
3991
+			return $this->_tag_close_H1($param);
3992
+		}
3993
+
3994
+		/**
3995
+		 * tag : H4
3996
+		 * mode : CLOSE
3997
+		 *
3998
+		 * @param  array $param
3999
+		 * @return boolean
4000
+		 */
4001
+		protected function _tag_close_H4($param)
4002
+		{
4003
+			return $this->_tag_close_H1($param);
4004
+		}
4005
+
4006
+		/**
4007
+		 * tag : H5
4008
+		 * mode : CLOSE
4009
+		 *
4010
+		 * @param  array $param
4011
+		 * @return boolean
4012
+		 */
4013
+		protected function _tag_close_H5($param)
4014
+		{
4015
+			return $this->_tag_close_H1($param);
4016
+		}
4017
+
4018
+		/**
4019
+		 * tag : H6
4020
+		 * mode : CLOSE
4021
+		 *
4022
+		 * @param  array $param
4023
+		 * @return boolean
4024
+		 */
4025
+		protected function _tag_close_H6($param)
4026
+		{
4027
+			return $this->_tag_close_H1($param);
4028
+		}
4029
+
4030
+		/**
4031
+		 * tag : SPAN
4032
+		 * mode : OPEN
4033
+		 *
4034
+		 * @param  array $param
4035
+		 * @param  string $other
4036
+		 * @return boolean
4037
+		 */
4038
+		protected function _tag_open_SPAN($param, $other = 'span')
4039
+		{
4040
+			$this->parsingCss->save();
4041
+			$this->parsingCss->analyse($other, $param);
4042
+			$this->parsingCss->setPosition();
4043
+			$this->parsingCss->fontSet();
4044
+
4045
+			return true;
4046
+		}
4047
+
4048
+		/**
4049
+		 * tag : FONT
4050
+		 * mode : OPEN
4051
+		 *
4052
+		 * @param  array $param
4053
+		 * @return boolean
4054
+		 */
4055
+		protected function _tag_open_FONT($param)
4056
+		{
4057
+			return $this->_tag_open_SPAN($param, 'font');
4058
+		}
4059
+
4060
+		/**
4061
+		 * tag : LABEL
4062
+		 * mode : OPEN
4063
+		 *
4064
+		 * @param  array $param
4065
+		 * @return boolean
4066
+		 */
4067
+		protected function _tag_open_LABEL($param)
4068
+		{
4069
+			return $this->_tag_open_SPAN($param, 'label');
4070
+		}
4071
+
4072
+		/**
4073
+		 * tag : SPAN
4074
+		 * mode : CLOSE
4075
+		 *
4076
+		 * @param  array $param
4077
+		 * @return boolean
4078
+		 */
4079
+		protected function _tag_close_SPAN($param)
4080
+		{
4081
+			$this->parsingCss->restorePosition();
4082
+			$this->parsingCss->load();
4083
+			$this->parsingCss->fontSet();
4084
+
4085
+			return true;
4086
+		}
4087
+
4088
+		/**
4089
+		 * tag : FONT
4090
+		 * mode : CLOSE
4091
+		 *
4092
+		 * @param  array $param
4093
+		 * @return boolean
4094
+		 */
4095
+		protected function _tag_close_FONT($param)
4096
+		{
4097
+			return $this->_tag_close_SPAN($param);
4098
+		}
4099
+
4100
+		/**
4101
+		 * tag : LABEL
4102
+		 * mode : CLOSE
4103
+		 *
4104
+		 * @param  array $param
4105
+		 * @return boolean
4106
+		 */
4107
+		protected function _tag_close_LABEL($param)
4108
+		{
4109
+			return $this->_tag_close_SPAN($param);
4110
+		}
4111
+
4112
+		/**
4113
+		 * tag : P
4114
+		 * mode : OPEN
4115
+		 *
4116
+		 * @param    array $param
4117
+		 * @return boolean
4118
+		 */
4119
+		protected function _tag_open_P($param)
4120
+		{
4121
+			if ($this->_isForOneLine) return false;
4122
+
4123
+			if (!in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) {
4124
+				if ($this->_maxH) $this->_tag_open_BR(array());
4125
+			}
4126
+
4127
+			$this->parsingCss->save();
4128
+			$this->parsingCss->analyse('p', $param);
4129
+			$this->parsingCss->setPosition();
4130
+			$this->parsingCss->fontSet();
4131
+
4132
+			 // cancel the effects of the setPosition
4133
+			$this->pdf->setXY($this->pdf->getX()-$this->parsingCss->value['margin']['l'], $this->pdf->getY()-$this->parsingCss->value['margin']['t']);
4134
+
4135
+			list($mL, $mR) = $this->_getMargins($this->pdf->getY());
4136
+			$mR = $this->pdf->getW()-$mR;
4137
+			$mL+= $this->parsingCss->value['margin']['l']+$this->parsingCss->value['padding']['l'];
4138
+			$mR+= $this->parsingCss->value['margin']['r']+$this->parsingCss->value['padding']['r'];
4139
+			$this->_saveMargin($mL, 0, $mR);
4140
+
4141
+			if ($this->parsingCss->value['text-indent']>0) {
4142
+				$y = $this->pdf->getY()+$this->parsingCss->value['margin']['t']+$this->parsingCss->value['padding']['t'];
4143
+				$this->_pageMarges[floor($y*100)] = array($mL+$this->parsingCss->value['text-indent'], $this->pdf->getW()-$mR);
4144
+				$y+= $this->parsingCss->getLineHeight()*0.1;
4145
+				$this->_pageMarges[floor($y*100)] = array($mL, $this->pdf->getW()-$mR);
4146
+			}
4147
+			$this->_makeBreakLine($this->parsingCss->value['margin']['t']+$this->parsingCss->value['padding']['t']);
4148
+			$this->_isInParagraph = array($mL, $mR);
4149
+			return true;
4150
+		}
4151
+
4152
+		/**
4153
+		 * tag : P
4154
+		 * mode : CLOSE
4155
+		 *
4156
+		 * @param  array $param
4157
+		 * @return boolean
4158
+		 */
4159
+		protected function _tag_close_P($param)
4160
+		{
4161
+			if ($this->_isForOneLine) return false;
4162
+
4163
+			if ($this->_maxH) $this->_tag_open_BR(array());
4164
+			$this->_isInParagraph = false;
4165
+			$this->_loadMargin();
4166
+			$h = $this->parsingCss->value['margin']['b']+$this->parsingCss->value['padding']['b'];
4167
+
4168
+			$this->parsingCss->load();
4169
+			$this->parsingCss->fontSet();
4170
+			$this->_makeBreakLine($h);
4171
+
4172
+			return true;
4173
+		}
4174
+
4175
+		/**
4176
+		 * tag : PRE
4177
+		 * mode : OPEN
4178
+		 *
4179
+		 * @param  array $param
4180
+		 * @param  string $other
4181
+		 * @return boolean
4182
+		 */
4183
+		protected function _tag_open_PRE($param, $other = 'pre')
4184
+		{
4185
+			if ($other=='pre' && $this->_maxH) $this->_tag_open_BR(array());
4186
+
4187
+			$this->parsingCss->save();
4188
+			$this->parsingCss->value['font-family'] = 'courier';
4189
+			$this->parsingCss->analyse($other, $param);
4190
+			$this->parsingCss->setPosition();
4191
+			$this->parsingCss->fontSet();
4192
+
4193
+			if ($other=='pre') return $this->_tag_open_DIV($param, $other);
4194
+
4195
+			return true;
4196
+		}
4197
+
4198
+		/**
4199
+		 * tag : CODE
4200
+		 * mode : OPEN
4201
+		 *
4202
+		 * @param  array $param
4203
+		 * @param  string $other
4204
+		 * @return boolean
4205
+		 */
4206
+		protected function _tag_open_CODE($param)
4207
+		{
4208
+			return $this->_tag_open_PRE($param, 'code');
4209
+		}
4210
+
4211
+		/**
4212
+		 * tag : PRE
4213
+		 * mode : CLOSE
4214
+		 *
4215
+		 * @param  array $param
4216
+		 * @param  string $other
4217
+		 * @return boolean
4218
+		 */
4219
+		protected function _tag_close_PRE($param, $other = 'pre')
4220
+		{
4221
+			if ($other=='pre') {
4222
+				if ($this->_isForOneLine) return false;
4223
+
4224
+				$this->_tag_close_DIV($param, $other);
4225
+				$this->_tag_open_BR(array());
4226
+			}
4227
+			$this->parsingCss->load();
4228
+			$this->parsingCss->fontSet();
4229
+
4230
+			return true;
4231
+		}
4232
+
4233
+		/**
4234
+		 * tag : CODE
4235
+		 * mode : CLOSE
4236
+		 *
4237
+		 * @param  array $param
4238
+		 * @return boolean
4239
+		 */
4240
+		protected function _tag_close_CODE($param)
4241
+		{
4242
+			return $this->_tag_close_PRE($param, 'code');
4243
+		}
4244
+
4245
+		/**
4246
+		 * tag : BIG
4247
+		 * mode : OPEN
4248
+		 *
4249
+		 * @param    array $param
4250
+		 * @return boolean
4251
+		 */
4252
+		protected function _tag_open_BIG($param)
4253
+		{
4254
+			$this->parsingCss->save();
4255
+			$this->parsingCss->value['mini-decal']-= $this->parsingCss->value['mini-size']*0.12;
4256
+			$this->parsingCss->value['mini-size'] *= 1.2;
4257
+			$this->parsingCss->analyse('big', $param);
4258
+			$this->parsingCss->setPosition();
4259
+			$this->parsingCss->fontSet();
4260
+			return true;
4261
+		}
4262
+
4263
+		/**
4264
+		 * tag : BIG
4265
+		 * mode : CLOSE
4266
+		 *
4267
+		 * @param    array $param
4268
+		 * @return boolean
4269
+		 */
4270
+		protected function _tag_close_BIG($param)
4271
+		{
4272
+			$this->parsingCss->load();
4273
+			$this->parsingCss->fontSet();
4274
+
4275
+			return true;
4276
+		}
4277
+
4278
+		/**
4279
+		 * tag : SMALL
4280
+		 * mode : OPEN
4281
+		 *
4282
+		 * @param    array $param
4283
+		 * @return boolean
4284
+		 */
4285
+		protected function _tag_open_SMALL($param)
4286
+		{
4287
+			$this->parsingCss->save();
4288
+			$this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.05;
4289
+			$this->parsingCss->value['mini-size'] *= 0.82;
4290
+			$this->parsingCss->analyse('small', $param);
4291
+			$this->parsingCss->setPosition();
4292
+			$this->parsingCss->fontSet();
4293
+			return true;
4294
+		}
4295
+
4296
+		/**
4297
+		 * tag : SMALL
4298
+		 * mode : CLOSE
4299
+		 *
4300
+		 * @param    array $param
4301
+		 * @return boolean
4302
+		 */
4303
+		protected function _tag_close_SMALL($param)
4304
+		{
4305
+			$this->parsingCss->load();
4306
+			$this->parsingCss->fontSet();
4307
+
4308
+			return true;
4309
+		}
4310
+
4311
+		/**
4312
+		 * tag : SUP
4313
+		 * mode : OPEN
4314
+		 *
4315
+		 * @param    array $param
4316
+		 * @return boolean
4317
+		 */
4318
+		protected function _tag_open_SUP($param)
4319
+		{
4320
+			$this->parsingCss->save();
4321
+			$this->parsingCss->value['mini-decal']-= $this->parsingCss->value['mini-size']*0.15;
4322
+			$this->parsingCss->value['mini-size'] *= 0.75;
4323
+			$this->parsingCss->analyse('sup', $param);
4324
+			$this->parsingCss->setPosition();
4325
+			$this->parsingCss->fontSet();
4326
+
4327
+			return true;
4328
+		}
4329
+
4330
+		/**
4331
+		 * tag : SUP
4332
+		 * mode : CLOSE
4333
+		 *
4334
+		 * @param    array $param
4335
+		 * @return boolean
4336
+		 */
4337
+		protected function _tag_close_SUP($param)
4338
+		{
4339
+			$this->parsingCss->load();
4340
+			$this->parsingCss->fontSet();
4341
+
4342
+			return true;
4343
+		}
4344
+
4345
+		/**
4346
+		 * tag : SUB
4347
+		 * mode : OPEN
4348
+		 *
4349
+		 * @param    array $param
4350
+		 * @return boolean
4351
+		 */
4352
+		protected function _tag_open_SUB($param)
4353
+		{
4354
+			$this->parsingCss->save();
4355
+			$this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.15;
4356
+			$this->parsingCss->value['mini-size'] *= 0.75;
4357
+			$this->parsingCss->analyse('sub', $param);
4358
+			$this->parsingCss->setPosition();
4359
+			$this->parsingCss->fontSet();
4360
+			return true;
4361
+		}
4362
+
4363
+		/**
4364
+		 * tag : SUB
4365
+		 * mode : CLOSE
4366
+		 *
4367
+		 * @param    array $param
4368
+		 * @return boolean
4369
+		 */
4370
+		protected function _tag_close_SUB($param)
4371
+		{
4372
+			$this->parsingCss->load();
4373
+			$this->parsingCss->fontSet();
4374
+
4375
+			return true;
4376
+		}
4377
+
4378
+		/**
4379
+		 * tag : UL
4380
+		 * mode : OPEN
4381
+		 *
4382
+		 * @param  array $param
4383
+		 * @param  string $other
4384
+		 * @return boolean
4385
+		 */
4386
+		protected function _tag_open_UL($param, $other = 'ul')
4387
+		{
4388
+			if ($this->_isForOneLine) return false;
4389
+
4390
+			if (!in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) {
4391
+				if ($this->_maxH) $this->_tag_open_BR(array());
4392
+				if (!count($this->_defList)) $this->_tag_open_BR(array());
4393
+			}
4394
+
4395
+			if (!isset($param['style']['width'])) $param['allwidth'] = true;
4396
+			$param['cellspacing'] = 0;
4397
+
4398
+			// a list is like a table
4399
+			$this->_tag_open_TABLE($param, $other);
4400
+
4401
+			// add a level of list
4402
+			$this->_listeAddLevel($other, $this->parsingCss->value['list-style-type'], $this->parsingCss->value['list-style-image']);
4403
+
4404
+			return true;
4405
+		}
4406
+
4407
+		/**
4408
+		 * tag : OL
4409
+		 * mode : OPEN
4410
+		 *
4411
+		 * @param  array $param
4412
+		 * @return boolean
4413
+		 */
4414
+		protected function _tag_open_OL($param)
4415
+		{
4416
+			return $this->_tag_open_UL($param, 'ol');
4417
+		}
4418
+
4419
+		/**
4420
+		 * tag : UL
4421
+		 * mode : CLOSE
4422
+		 *
4423
+		 * @param  array $param
4424
+		 * @return boolean
4425
+		 */
4426
+		protected function _tag_close_UL($param)
4427
+		{
4428
+			if ($this->_isForOneLine) return false;
4429
+
4430
+			$this->_tag_close_TABLE($param);
4431
+
4432
+			$this->_listeDelLevel();
4433
+
4434
+			if (!$this->_subPart) {
4435
+				if (!count($this->_defList)) $this->_tag_open_BR(array());
4436
+			}
4437
+
4438
+			return true;
4439
+		}
4440
+
4441
+		/**
4442
+		 * tag : OL
4443
+		 * mode : CLOSE
4444
+		 *
4445
+		 * @param  array $param
4446
+		 * @return boolean
4447
+		 */
4448
+		protected function _tag_close_OL($param)
4449
+		{
4450
+			return $this->_tag_close_UL($param);
4451
+		}
4452
+
4453
+		/**
4454
+		 * tag : LI
4455
+		 * mode : OPEN
4456
+		 *
4457
+		 * @param  array $param
4458
+		 * @return boolean
4459
+		 */
4460
+		protected function _tag_open_LI($param)
4461
+		{
4462
+			if ($this->_isForOneLine) return false;
4463
+
4464
+			$this->_listeAddLi();
4465
+
4466
+			if (!isset($param['style']['width'])) $param['style']['width'] = '100%';
4467
+
4468
+			$paramPUCE = $param;
4469
+
4470
+			$inf = $this->_listeGetLi();
4471
+			if ($inf[0]) {
4472
+				$paramPUCE['style']['font-family']     = $inf[0];
4473
+				$paramPUCE['style']['text-align']      = 'li_right';
4474
+				$paramPUCE['style']['vertical-align']  = 'top';
4475
+				$paramPUCE['style']['width']           = $this->_listeGetWidth();
4476
+				$paramPUCE['style']['padding-right']   = $this->_listeGetPadding();
4477
+				$paramPUCE['txt'] = $inf[2];
4478
+			} else {
4479
+				$paramPUCE['style']['text-align']      = 'li_right';
4480
+				$paramPUCE['style']['vertical-align']  = 'top';
4481
+				$paramPUCE['style']['width']           = $this->_listeGetWidth();
4482
+				$paramPUCE['style']['padding-right']   = $this->_listeGetPadding();
4483
+				$paramPUCE['src'] = $inf[2];
4484
+				$paramPUCE['sub_li'] = true;
4485
+			}
4486
+
4487
+			$this->_tag_open_TR($param, 'li');
4488
+
4489
+			$this->parsingCss->save();
4490
+
4491
+			// if small LI
4492
+			if ($inf[1]) {
4493
+				$this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.045;
4494
+				$this->parsingCss->value['mini-size'] *= 0.75;
4495
+			}
4496
+
4497
+			// if we are in a sub html => prepare. Else : display
4498
+			if ($this->_subPart) {
4499
+				// TD for the puce
4500
+				$tmpPos = $this->_tempPos;
4501
+				$tmpLst1 = $this->parsingHtml->code[$tmpPos+1];
4502
+				$tmpLst2 = $this->parsingHtml->code[$tmpPos+2];
4503
+				$this->parsingHtml->code[$tmpPos+1] = array();
4504
+				$this->parsingHtml->code[$tmpPos+1]['name']    = (isset($paramPUCE['src'])) ? 'img' : 'write';
4505
+				$this->parsingHtml->code[$tmpPos+1]['param']    = $paramPUCE; unset($this->parsingHtml->code[$tmpPos+1]['param']['style']['width']);
4506
+				$this->parsingHtml->code[$tmpPos+1]['close']    = 0;
4507
+				$this->parsingHtml->code[$tmpPos+2] = array();
4508
+				$this->parsingHtml->code[$tmpPos+2]['name']    = 'li';
4509
+				$this->parsingHtml->code[$tmpPos+2]['param']    = $paramPUCE;
4510
+				$this->parsingHtml->code[$tmpPos+2]['close']    = 1;
4511
+				$this->_tag_open_TD($paramPUCE, 'li_sub');
4512
+				$this->_tag_close_TD($param);
4513
+				$this->_tempPos = $tmpPos;
4514
+				$this->parsingHtml->code[$tmpPos+1] = $tmpLst1;
4515
+				$this->parsingHtml->code[$tmpPos+2] = $tmpLst2;
4516
+			} else {
4517
+				// TD for the puce
4518
+				$this->_tag_open_TD($paramPUCE, 'li_sub');
4519
+				unset($paramPUCE['style']['width']);
4520
+				if (isset($paramPUCE['src']))    $this->_tag_open_IMG($paramPUCE);
4521
+				else                            $this->_tag_open_WRITE($paramPUCE);
4522
+				$this->_tag_close_TD($paramPUCE);
4523
+			}
4524
+			$this->parsingCss->load();
4525
+
4526
+
4527
+			// TD for the content
4528
+			$this->_tag_open_TD($param, 'li');
4529
+
4530
+			return true;
4531
+		}
4532
+
4533
+		/**
4534
+		 * tag : LI
4535
+		 * mode : CLOSE
4536
+		 *
4537
+		 * @param  array $param
4538
+		 * @return boolean
4539
+		 */
4540
+		protected function _tag_close_LI($param)
4541
+		{
4542
+			if ($this->_isForOneLine) return false;
4543
+
4544
+			$this->_tag_close_TD($param);
4545
+
4546
+			$this->_tag_close_TR($param);
4547
+
4548
+			return true;
4549
+		}
4550
+
4551
+		/**
4552
+		 * tag : TBODY
4553
+		 * mode : OPEN
4554
+		 *
4555
+		 * @param  array $param
4556
+		 * @return boolean
4557
+		 */
4558
+		protected function _tag_open_TBODY($param)
4559
+		{
4560
+			if ($this->_isForOneLine) return false;
4561
+
4562
+			$this->parsingCss->save();
4563
+			$this->parsingCss->analyse('tbody', $param);
4564
+			$this->parsingCss->setPosition();
4565
+			$this->parsingCss->fontSet();
4566
+
4567
+			return true;
4568
+		}
4569
+
4570
+		/**
4571
+		 * tag : TBODY
4572
+		 * mode : CLOSE
4573
+		 *
4574
+		 * @param  array $param
4575
+		 * @return boolean
4576
+		 */
4577
+		protected function _tag_close_TBODY($param)
4578
+		{
4579
+			if ($this->_isForOneLine) return false;
4580
+
4581
+			$this->parsingCss->load();
4582
+			$this->parsingCss->fontSet();
4583
+
4584
+			return true;
4585
+		}
4586
+
4587
+		/**
4588
+		 * tag : THEAD
4589
+		 * mode : OPEN
4590
+		 *
4591
+		 * @param  array $param
4592
+		 * @return boolean
4593
+		 */
4594
+		protected function _tag_open_THEAD($param)
4595
+		{
4596
+			if ($this->_isForOneLine) return false;
4597
+
4598
+			$this->parsingCss->save();
4599
+			$this->parsingCss->analyse('thead', $param);
4600
+			$this->parsingCss->setPosition();
4601
+			$this->parsingCss->fontSet();
4602
+
4603
+			// if we are in a sub part, save the number of the first TR in the thead
4604
+			if ($this->_subPart) {
4605
+				HTML2PDF::$_tables[$param['num']]['thead']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr'];
4606
+				HTML2PDF::$_tables[$param['num']]['thead']['code'] = array();
4607
+				for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) {
4608
+					$action = $this->parsingHtml->code[$pos];
4609
+					if (strtolower($action['name'])=='thead') $action['name'] = 'thead_sub';
4610
+					HTML2PDF::$_tables[$param['num']]['thead']['code'][] = $action;
4611
+					if (strtolower($action['name'])=='thead_sub' && $action['close']) break;
4612
+				}
4613
+			} else {
4614
+				$level = $this->parsingHtml->getLevel($this->_parsePos);
4615
+				$this->_parsePos+= count($level);
4616
+				HTML2PDF::$_tables[$param['num']]['tr_curr']+= count(HTML2PDF::$_tables[$param['num']]['thead']['tr']);
4617
+			}
4618
+
4619
+			return true;
4620
+		}
4621
+
4622
+		/**
4623
+		 * tag : THEAD
4624
+		 * mode : CLOSE
4625
+		 *
4626
+		 * @param  array $param
4627
+		 * @return boolean
4628
+		 */
4629
+		protected function _tag_close_THEAD($param)
4630
+		{
4631
+			if ($this->_isForOneLine) return false;
4632
+
4633
+			$this->parsingCss->load();
4634
+			$this->parsingCss->fontSet();
4635
+
4636
+			// if we are in a sub HTM, construct the list of the TR in the thead
4637
+			if ($this->_subPart) {
4638
+				$min = HTML2PDF::$_tables[$param['num']]['thead']['tr'][0];
4639
+				$max = HTML2PDF::$_tables[$param['num']]['tr_curr']-1;
4640
+				HTML2PDF::$_tables[$param['num']]['thead']['tr'] = range($min, $max);
4641
+			}
4642
+
4643
+			return true;
4644
+		}
4645
+
4646
+		/**
4647
+		 * tag : TFOOT
4648
+		 * mode : OPEN
4649
+		 *
4650
+		 * @param  array $param
4651
+		 * @return boolean
4652
+		 */
4653
+		protected function _tag_open_TFOOT($param)
4654
+		{
4655
+			if ($this->_isForOneLine) return false;
4656
+
4657
+			$this->parsingCss->save();
4658
+			$this->parsingCss->analyse('tfoot', $param);
4659
+			$this->parsingCss->setPosition();
4660
+			$this->parsingCss->fontSet();
4661
+
4662
+			// if we are in a sub part, save the number of the first TR in the tfoot
4663
+			if ($this->_subPart) {
4664
+				HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr'];
4665
+				HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array();
4666
+				for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) {
4667
+					$action = $this->parsingHtml->code[$pos];
4668
+					if (strtolower($action['name'])=='tfoot') $action['name'] = 'tfoot_sub';
4669
+					HTML2PDF::$_tables[$param['num']]['tfoot']['code'][] = $action;
4670
+					if (strtolower($action['name'])=='tfoot_sub' && $action['close']) break;
4671
+				}
4672
+			} else {
4673
+				$level = $this->parsingHtml->getLevel($this->_parsePos);
4674
+				$this->_parsePos+= count($level);
4675
+				HTML2PDF::$_tables[$param['num']]['tr_curr']+= count(HTML2PDF::$_tables[$param['num']]['tfoot']['tr']);
4676
+			}
4677
+
4678
+			return true;
4679
+		}
4680
+
4681
+		/**
4682
+		 * tag : TFOOT
4683
+		 * mode : CLOSE
4684
+		 *
4685
+		 * @param  array $param
4686
+		 * @return boolean
4687
+		 */
4688
+		protected function _tag_close_TFOOT($param)
4689
+		{
4690
+			if ($this->_isForOneLine) return false;
4691
+
4692
+			$this->parsingCss->load();
4693
+			$this->parsingCss->fontSet();
4694
+
4695
+			// if we are in a sub HTM, construct the list of the TR in the tfoot
4696
+			if ($this->_subPart) {
4697
+				$min = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0];
4698
+				$max = HTML2PDF::$_tables[$param['num']]['tr_curr']-1;
4699
+				HTML2PDF::$_tables[$param['num']]['tfoot']['tr'] = range($min, $max);
4700
+			}
4701
+
4702
+			return true;
4703
+		}
4704
+
4705
+		/**
4706
+		 * It is not a real TAG, does not use it !
4707
+		 *
4708
+		 * @param  array $param
4709
+		 * @return boolean
4710
+		 */
4711
+		protected function _tag_open_THEAD_SUB($param)
4712
+		{
4713
+			if ($this->_isForOneLine) return false;
4714
+
4715
+			$this->parsingCss->save();
4716
+			$this->parsingCss->analyse('thead', $param);
4717
+			$this->parsingCss->setPosition();
4718
+			$this->parsingCss->fontSet();
4719
+
4720
+			return true;
4721
+		}
4722
+
4723
+		/**
4724
+		 * It is not a real TAG, does not use it !
4725
+		 *
4726
+		 * @param  array $param
4727
+		 * @return boolean
4728
+		 */
4729
+		protected function _tag_close_THEAD_SUB($param)
4730
+		{
4731
+			if ($this->_isForOneLine) return false;
4732
+
4733
+			$this->parsingCss->load();
4734
+			$this->parsingCss->fontSet();
4735
+
4736
+			return true;
4737
+		}
4738
+
4739
+		/**
4740
+		 * It is not a real TAG, does not use it !
4741
+		 *
4742
+		 * @param    array $param
4743
+		 * @return boolean
4744
+		 */
4745
+		protected function _tag_open_TFOOT_SUB($param)
4746
+		{
4747
+			if ($this->_isForOneLine) return false;
4748
+
4749
+			$this->parsingCss->save();
4750
+			$this->parsingCss->analyse('tfoot', $param);
4751
+			$this->parsingCss->setPosition();
4752
+			$this->parsingCss->fontSet();
4753
+
4754
+			return true;
4755
+		}
4756
+
4757
+		/**
4758
+		 * It is not a real TAG, does not use it !
4759
+		 *
4760
+		 * @param  array $param
4761
+		 * @return boolean
4762
+		 */
4763
+		protected function _tag_close_TFOOT_SUB($param)
4764
+		{
4765
+			if ($this->_isForOneLine) return false;
4766
+
4767
+			$this->parsingCss->load();
4768
+			$this->parsingCss->fontSet();
4769
+
4770
+			return true;
4771
+		}
4772
+
4773
+		/**
4774
+		 * tag : FORM
4775
+		 * mode : OPEN
4776
+		 *
4777
+		 * @param  array $param
4778
+		 * @return boolean
4779
+		 */
4780
+		protected function _tag_open_FORM($param)
4781
+		{
4782
+			$this->parsingCss->save();
4783
+			$this->parsingCss->analyse('form', $param);
4784
+			$this->parsingCss->setPosition();
4785
+			$this->parsingCss->fontSet();
4786
+
4787
+			$this->pdf->setFormDefaultProp(
4788
+				array(
4789
+					'lineWidth'=>1,
4790
+					'borderStyle'=>'solid',
4791
+					'fillColor'=>array(220, 220, 255),
4792
+					'strokeColor'=>array(128, 128, 200)
4793
+				)
4794
+			);
4795
+
4796
+			$this->_isInForm = isset($param['action']) ? $param['action'] : '';
4797
+
4798
+			return true;
4799
+		}
4800
+
4801
+		/**
4802
+		 * tag : FORM
4803
+		 * mode : CLOSE
4804
+		 *
4805
+		 * @param  array $param
4806
+		 * @return boolean
4807
+		 */
4808
+		protected function _tag_close_FORM($param)
4809
+		{
4810
+			$this->_isInForm = false;
4811
+			$this->parsingCss->load();
4812
+			$this->parsingCss->fontSet();
4813
+
4814
+			return true;
4815
+		}
4816
+
4817
+		/**
4818
+		 * tag : TABLE
4819
+		 * mode : OPEN
4820
+		 *
4821
+		 * @param  array $param
4822
+		 * @return boolean
4823
+		 */
4824
+		protected function _tag_open_TABLE($param, $other = 'table')
4825
+		{
4826
+			if ($this->_maxH) {
4827
+				if ($this->_isForOneLine) return false;
4828
+				$this->_tag_open_BR(array());
4829
+			}
4830
+
4831
+			if ($this->_isForOneLine) {
4832
+				$this->_maxX = $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
4833
+				return false;
4834
+			}
4835
+
4836
+			$this->_maxH = 0;
4837
+
4838
+			$alignObject = isset($param['align']) ? strtolower($param['align']) : 'left';
4839
+			if (isset($param['align'])) unset($param['align']);
4840
+			if (!in_array($alignObject, array('left', 'center', 'right'))) $alignObject = 'left';
4841
+
4842
+			$this->parsingCss->save();
4843
+			$this->parsingCss->analyse($other, $param);
4844
+			$this->parsingCss->setPosition();
4845
+			$this->parsingCss->fontSet();
4846
+
4847
+			if ($this->parsingCss->value['margin-auto']) $alignObject = 'center';
4848
+
4849
+			// collapse table ?
4850
+			$collapse = false;
4851
+			if ($other=='table') {
4852
+				$collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false;
4853
+			}
4854
+
4855
+			// if collapse => no borders for the table, only for TD
4856
+			if ($collapse) {
4857
+				$param['style']['border'] = 'none';
4858
+				$param['cellspacing'] = 0;
4859
+				$none = $this->parsingCss->readBorder('none');
4860
+				$this->parsingCss->value['border']['t'] = $none;
4861
+				$this->parsingCss->value['border']['r'] = $none;
4862
+				$this->parsingCss->value['border']['b'] = $none;
4863
+				$this->parsingCss->value['border']['l'] = $none;
4864
+			}
4865
+
4866
+			// if we are in a SUB html => prepare the properties of the table
4867
+			if ($this->_subPart) {
4868
+				if ($this->_debugActif) $this->_DEBUG_add('Table n'.$param['num'], true);
4869
+				HTML2PDF::$_tables[$param['num']] = array();
4870
+				HTML2PDF::$_tables[$param['num']]['border']          = isset($param['border']) ? $this->parsingCss->readBorder($param['border']) : null;
4871
+				HTML2PDF::$_tables[$param['num']]['cellpadding']     = $this->parsingCss->ConvertToMM(isset($param['cellpadding']) ? $param['cellpadding'] : '1px');
4872
+				HTML2PDF::$_tables[$param['num']]['cellspacing']     = $this->parsingCss->ConvertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
4873
+				HTML2PDF::$_tables[$param['num']]['cases']           = array();          // properties of each TR/TD
4874
+				HTML2PDF::$_tables[$param['num']]['corr']            = array();          // link between TR/TD and colspan/rowspan
4875
+				HTML2PDF::$_tables[$param['num']]['corr_x']          = 0;                // position in 'cases'
4876
+				HTML2PDF::$_tables[$param['num']]['corr_y']          = 0;                // position in 'cases'
4877
+				HTML2PDF::$_tables[$param['num']]['td_curr']         = 0;                // current column
4878
+				HTML2PDF::$_tables[$param['num']]['tr_curr']         = 0;                // current row
4879
+				HTML2PDF::$_tables[$param['num']]['curr_x']          = $this->pdf->getX();
4880
+				HTML2PDF::$_tables[$param['num']]['curr_y']          = $this->pdf->getY();
4881
+				HTML2PDF::$_tables[$param['num']]['width']           = 0;                // global width
4882
+				HTML2PDF::$_tables[$param['num']]['height']          = 0;                // global height
4883
+				HTML2PDF::$_tables[$param['num']]['align']           = $alignObject;
4884
+				HTML2PDF::$_tables[$param['num']]['marge']           = array();
4885
+				HTML2PDF::$_tables[$param['num']]['marge']['t']      = $this->parsingCss->value['padding']['t']+$this->parsingCss->value['border']['t']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5;
4886
+				HTML2PDF::$_tables[$param['num']]['marge']['r']      = $this->parsingCss->value['padding']['r']+$this->parsingCss->value['border']['r']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5;
4887
+				HTML2PDF::$_tables[$param['num']]['marge']['b']      = $this->parsingCss->value['padding']['b']+$this->parsingCss->value['border']['b']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5;
4888
+				HTML2PDF::$_tables[$param['num']]['marge']['l']      = $this->parsingCss->value['padding']['l']+$this->parsingCss->value['border']['l']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5;
4889
+				HTML2PDF::$_tables[$param['num']]['page']            = 0;                // number of pages
4890
+				HTML2PDF::$_tables[$param['num']]['new_page']        = true;             // flag : new page for the current TR
4891
+				HTML2PDF::$_tables[$param['num']]['style_value']     = null;             // CSS style of the table
4892
+				HTML2PDF::$_tables[$param['num']]['thead']           = array();          // properties on the thead
4893
+				HTML2PDF::$_tables[$param['num']]['tfoot']           = array();          // properties on the tfoot
4894
+				HTML2PDF::$_tables[$param['num']]['thead']['tr']     = array();          // list of the TRs in the thead
4895
+				HTML2PDF::$_tables[$param['num']]['tfoot']['tr']     = array();          // list of the TRs in the tfoot
4896
+				HTML2PDF::$_tables[$param['num']]['thead']['height']    = 0;             // thead height
4897
+				HTML2PDF::$_tables[$param['num']]['tfoot']['height']    = 0;             // tfoot height
4898
+				HTML2PDF::$_tables[$param['num']]['thead']['code'] = array();            // HTML content of the thead
4899
+				HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array();            // HTML content of the tfoot
4900
+				HTML2PDF::$_tables[$param['num']]['cols']        = array();              // properties of the COLs
4901
+
4902
+				$this->_saveMargin($this->pdf->getlMargin(), $this->pdf->gettMargin(), $this->pdf->getrMargin());
4903
+
4904
+				$this->parsingCss->value['width']-= HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r'];
4905
+			} else {
4906
+				// we start from the first page and the first page of the table
4907
+				HTML2PDF::$_tables[$param['num']]['page'] = 0;
4908
+				HTML2PDF::$_tables[$param['num']]['td_curr']    = 0;
4909
+				HTML2PDF::$_tables[$param['num']]['tr_curr']    = 0;
4910
+				HTML2PDF::$_tables[$param['num']]['td_x']        = HTML2PDF::$_tables[$param['num']]['marge']['l']+HTML2PDF::$_tables[$param['num']]['curr_x'];
4911
+				HTML2PDF::$_tables[$param['num']]['td_y']        = HTML2PDF::$_tables[$param['num']]['marge']['t']+HTML2PDF::$_tables[$param['num']]['curr_y'];
4912
+
4913
+				// draw the borders/background of the first page/part of the table
4914
+				$this->_drawRectangle(
4915
+					HTML2PDF::$_tables[$param['num']]['curr_x'],
4916
+					HTML2PDF::$_tables[$param['num']]['curr_y'],
4917
+					HTML2PDF::$_tables[$param['num']]['width'],
4918
+					isset(HTML2PDF::$_tables[$param['num']]['height'][0]) ? HTML2PDF::$_tables[$param['num']]['height'][0] : null,
4919
+					$this->parsingCss->value['border'],
4920
+					$this->parsingCss->value['padding'],
4921
+					0,
4922
+					$this->parsingCss->value['background']
4923
+				);
4924
+
4925
+				HTML2PDF::$_tables[$param['num']]['style_value'] = $this->parsingCss->value;
4926
+			}
4927
+
4928
+			return true;
4929
+		}
4930
+
4931
+		/**
4932
+		 * tag : TABLE
4933
+		 * mode : CLOSE
4934
+		 *
4935
+		 * @param  array $param
4936
+		 * @return boolean
4937
+		 */
4938
+		protected function _tag_close_TABLE($param)
4939
+		{
4940
+			if ($this->_isForOneLine) return false;
4941
+
4942
+			$this->_maxH = 0;
4943
+
4944
+			// if we are in a sub HTML
4945
+			if ($this->_subPart) {
4946
+				// calculate the size of each case
4947
+				$this->_calculateTableCellSize(HTML2PDF::$_tables[$param['num']]['cases'], HTML2PDF::$_tables[$param['num']]['corr']);
4948
+
4949
+				// calculate the height of the thead and the tfoot
4950
+				$lst = array('thead', 'tfoot');
4951
+				foreach ($lst as $mode) {
4952
+					HTML2PDF::$_tables[$param['num']][$mode]['height'] = 0;
4953
+					foreach (HTML2PDF::$_tables[$param['num']][$mode]['tr'] as $tr) {
4954
+						// hauteur de la ligne tr
4955
+						$h = 0;
4956
+						for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++)
4957
+							if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan']==1)
4958
+								$h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['h']);
4959
+						HTML2PDF::$_tables[$param['num']][$mode]['height']+= $h;
4960
+					}
4961
+				}
4962
+
4963
+				// calculate the width of the table
4964
+				HTML2PDF::$_tables[$param['num']]['width'] = HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r'];
4965
+				if (isset(HTML2PDF::$_tables[$param['num']]['cases'][0])) {
4966
+					foreach (HTML2PDF::$_tables[$param['num']]['cases'][0] as $case) {
4967
+						HTML2PDF::$_tables[$param['num']]['width']+= $case['w'];
4968
+					}
4969
+				}
4970
+
4971
+				// X position of the table
4972
+				$old = $this->parsingCss->getOldValues();
4973
+				$parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
4974
+				$x = HTML2PDF::$_tables[$param['num']]['curr_x'];
4975
+				$w = HTML2PDF::$_tables[$param['num']]['width'];
4976
+				if ($parentWidth>$w) {
4977
+					if (HTML2PDF::$_tables[$param['num']]['align']=='center')
4978
+						$x = $x + ($parentWidth-$w)*0.5;
4979
+					else if (HTML2PDF::$_tables[$param['num']]['align']=='right')
4980
+						$x = $x + $parentWidth-$w;
4981
+
4982
+					HTML2PDF::$_tables[$param['num']]['curr_x'] = $x;
4983
+				}
4984
+
4985
+				// calculate the height of the table
4986
+				HTML2PDF::$_tables[$param['num']]['height'] = array();
4987
+
4988
+				// minimum of the height because of margins, and of the thead and tfoot height
4989
+				$h0 = HTML2PDF::$_tables[$param['num']]['marge']['t'] + HTML2PDF::$_tables[$param['num']]['marge']['b'];
4990
+				$h0+= HTML2PDF::$_tables[$param['num']]['thead']['height'] + HTML2PDF::$_tables[$param['num']]['tfoot']['height'];
4991
+
4992
+				// max height of the page
4993
+				$max = $this->pdf->getH() - $this->pdf->getbMargin();
4994
+
4995
+				// current position on the page
4996
+				$y = HTML2PDF::$_tables[$param['num']]['curr_y'];
4997
+				$height = $h0;
4998
+
4999
+				// we get the height of each line
5000
+				for ($k=0; $k<count(HTML2PDF::$_tables[$param['num']]['cases']); $k++) {
5001
+
5002
+					// if it is a TR of the thead or of the tfoot => skip
5003
+					if (in_array($k, HTML2PDF::$_tables[$param['num']]['thead']['tr'])) continue;
5004
+					if (in_array($k, HTML2PDF::$_tables[$param['num']]['tfoot']['tr'])) continue;
5005
+
5006
+					// height of the line
5007
+					$th = 0;
5008
+					$h = 0;
5009
+					for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$k]); $i++) {
5010
+						$h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']);
5011
+
5012
+						if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan']==1)
5013
+							$th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']);
5014
+					}
5015
+
5016
+					// if the row does not fit on the page => new page
5017
+					if ($y+$h+$height>$max) {
5018
+						if ($height==$h0) $height = null;
5019
+						HTML2PDF::$_tables[$param['num']]['height'][] = $height;
5020
+						$height = $h0;
5021
+						$y = $this->_margeTop;
5022
+					}
5023
+					$height+= $th;
5024
+				}
5025
+
5026
+				// if ther is a height at the end, add it
5027
+				if ($height!=$h0 || $k==0) HTML2PDF::$_tables[$param['num']]['height'][] = $height;
5028
+			} else {
5029
+				// if we have tfoor, draw it
5030
+				if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) {
5031
+					$tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr'];
5032
+					$tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr'];
5033
+					$oldParsePos = $this->_parsePos;
5034
+					$oldParseCode = $this->parsingHtml->code;
5035
+
5036
+					HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0];
5037
+					HTML2PDF::$_tables[$param['num']]['td_curr'] = 0;
5038
+					$this->_parsePos = 0;
5039
+					$this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['tfoot']['code'];
5040
+					$this->_isInTfoot = true;
5041
+					$this->_makeHTMLcode();
5042
+					$this->_isInTfoot = false;
5043
+
5044
+					$this->_parsePos =     $oldParsePos;
5045
+					$this->parsingHtml->code = $oldParseCode;
5046
+					HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR;
5047
+					HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD;
5048
+				}
5049
+
5050
+				// get the positions of the end of the table
5051
+				$x = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['width'];
5052
+				if (count(HTML2PDF::$_tables[$param['num']]['height'])>1)
5053
+					$y = $this->_margeTop+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1];
5054
+				else if (count(HTML2PDF::$_tables[$param['num']]['height'])==1)
5055
+					$y = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1];
5056
+				else
5057
+					$y = HTML2PDF::$_tables[$param['num']]['curr_y'];
5058
+
5059
+				$this->_maxX = max($this->_maxX, $x);
5060
+				$this->_maxY = max($this->_maxY, $y);
5061
+
5062
+				$this->pdf->setXY($this->pdf->getlMargin(), $y);
5063
+
5064
+				$this->_loadMargin();
5065
+
5066
+				if ($this->_debugActif) $this->_DEBUG_add('Table '.$param['num'], false);
5067
+			}
5068
+
5069
+			$this->parsingCss->load();
5070
+			$this->parsingCss->fontSet();
5071
+
5072
+
5073
+			return true;
5074
+		}
5075
+
5076
+		/**
5077
+		 * tag : COL
5078
+		 * mode : OPEN
5079
+		 *
5080
+		 * @param  array $param
5081
+		 * @return boolean
5082
+		 */
5083
+		protected function _tag_open_COL($param)
5084
+		{
5085
+			$span = isset($param['span']) ? $param['span'] : 1;
5086
+			for ($k=0; $k<$span; $k++)
5087
+				HTML2PDF::$_tables[$param['num']]['cols'][] = $param;
5088
+		}
5089
+
5090
+		/**
5091
+		 * tag : COL
5092
+		 * mode : CLOSE
5093
+		 *
5094
+		 * @param  array $param
5095
+		 * @return boolean
5096
+		 */
5097
+		protected function _tag_close_COL($param)
5098
+		{
5099
+			// there is nothing to do here
5100
+
5101
+			return true;
5102
+		}
5103
+
5104
+		/**
5105
+		 * tag : TR
5106
+		 * mode : OPEN
5107
+		 *
5108
+		 * @param  array $param
5109
+		 * @return boolean
5110
+		 */
5111
+		protected function _tag_open_TR($param, $other = 'tr')
5112
+		{
5113
+			if ($this->_isForOneLine) return false;
5114
+
5115
+			$this->_maxH = 0;
5116
+
5117
+			$this->parsingCss->save();
5118
+			$this->parsingCss->analyse($other, $param);
5119
+			$this->parsingCss->setPosition();
5120
+			$this->parsingCss->fontSet();
5121
+
5122
+			// position in the table
5123
+			HTML2PDF::$_tables[$param['num']]['tr_curr']++;
5124
+			HTML2PDF::$_tables[$param['num']]['td_curr']= 0;
5125
+
5126
+			// if we are not in a sub html
5127
+			if (!$this->_subPart) {
5128
+
5129
+				// Y after the row
5130
+				$ty=null;
5131
+				for ($ii=0; $ii<count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1]); $ii++) {
5132
+					$ty = max($ty, HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['h']);
5133
+				}
5134
+
5135
+				// height of the tfoot
5136
+				$hfoot = HTML2PDF::$_tables[$param['num']]['tfoot']['height'];
5137
+
5138
+				// if the line does not fit on the page => new page
5139
+				if (!$this->_isInTfoot && HTML2PDF::$_tables[$param['num']]['td_y'] + HTML2PDF::$_tables[$param['num']]['marge']['b'] + $ty +$hfoot> $this->pdf->getH() - $this->pdf->getbMargin()) {
5140
+
5141
+					// fi ther is a tfoot => draw it
5142
+					if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) {
5143
+						$tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr'];
5144
+						$tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr'];
5145
+						$oldParsePos = $this->_parsePos;
5146
+						$oldParseCode = $this->parsingHtml->code;
5147
+
5148
+						HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0];
5149
+						HTML2PDF::$_tables[$param['num']]['td_curr'] = 0;
5150
+						$this->_parsePos = 0;
5151
+						$this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['tfoot']['code'];
5152
+						$this->_isInTfoot = true;
5153
+						$this->_makeHTMLcode();
5154
+						$this->_isInTfoot = false;
5155
+
5156
+						$this->_parsePos =     $oldParsePos;
5157
+						$this->parsingHtml->code = $oldParseCode;
5158
+						HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR;
5159
+						HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD;
5160
+					}
5161
+
5162
+					// new page
5163
+					HTML2PDF::$_tables[$param['num']]['new_page'] = true;
5164
+					$this->_setNewPage();
5165
+
5166
+					// new position
5167
+					HTML2PDF::$_tables[$param['num']]['page']++;
5168
+					HTML2PDF::$_tables[$param['num']]['curr_y'] = $this->pdf->getY();
5169
+					HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['marge']['t'];
5170
+
5171
+					// if we have the height of the tbale on the page => draw borders and background
5172
+					if (isset(HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']])) {
5173
+						$old = $this->parsingCss->value;
5174
+						$this->parsingCss->value = HTML2PDF::$_tables[$param['num']]['style_value'];
5175
+
5176
+						$this->_drawRectangle(
5177
+							HTML2PDF::$_tables[$param['num']]['curr_x'],
5178
+							HTML2PDF::$_tables[$param['num']]['curr_y'],
5179
+							HTML2PDF::$_tables[$param['num']]['width'],
5180
+							HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']],
5181
+							$this->parsingCss->value['border'],
5182
+							$this->parsingCss->value['padding'],
5183
+							HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5,
5184
+							$this->parsingCss->value['background']
5185
+						);
5186
+
5187
+						$this->parsingCss->value = $old;
5188
+					}
5189
+				}
5190
+
5191
+				// if we are in a new page, and if we have a thead => draw it
5192
+				if (HTML2PDF::$_tables[$param['num']]['new_page'] && count(HTML2PDF::$_tables[$param['num']]['thead']['code'])) {
5193
+					HTML2PDF::$_tables[$param['num']]['new_page'] = false;
5194
+					$tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr'];
5195
+					$tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr'];
5196
+					$oldParsePos = $this->_parsePos;
5197
+					$oldParseCode = $this->parsingHtml->code;
5198
+
5199
+					HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['thead']['tr'][0];
5200
+					HTML2PDF::$_tables[$param['num']]['td_curr'] = 0;
5201
+					$this->_parsePos = 0;
5202
+					$this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['thead']['code'];
5203
+					$this->_isInThead = true;
5204
+					$this->_makeHTMLcode();
5205
+					$this->_isInThead = false;
5206
+
5207
+					$this->_parsePos =     $oldParsePos;
5208
+					$this->parsingHtml->code = $oldParseCode;
5209
+					HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR;
5210
+					HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD;
5211
+					HTML2PDF::$_tables[$param['num']]['new_page'] = true;
5212
+				}
5213
+			// else (in a sub HTML)
5214
+			} else {
5215
+				// prepare it
5216
+				HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1] = array();
5217
+				if (!isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']]))
5218
+					HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array();
5219
+
5220
+				HTML2PDF::$_tables[$param['num']]['corr_x']=0;
5221
+				while(isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']]))
5222
+					HTML2PDF::$_tables[$param['num']]['corr_x']++;
5223
+			}
5224
+
5225
+			return true;
5226
+		}
5227
+
5228
+		/**
5229
+		 * tag : TR
5230
+		 * mode : CLOSE
5231
+		 *
5232
+		 * @param  array $param
5233
+		 * @return boolean
5234
+		 */
5235
+		protected function _tag_close_TR($param)
5236
+		{
5237
+			if ($this->_isForOneLine) return false;
5238
+
5239
+			$this->_maxH = 0;
5240
+
5241
+			$this->parsingCss->load();
5242
+			$this->parsingCss->fontSet();
5243
+
5244
+			// if we are not in a sub HTML
5245
+			if (!$this->_subPart) {
5246
+
5247
+				// Y of the current line
5248
+				$ty=null;
5249
+				for ($ii=0; $ii<count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1]); $ii++) {
5250
+					if (HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['rowspan']==1) {
5251
+						$ty = HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['h'];
5252
+					}
5253
+				}
5254
+
5255
+				// new position
5256
+				HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['curr_x']+HTML2PDF::$_tables[$param['num']]['marge']['l'];
5257
+				HTML2PDF::$_tables[$param['num']]['td_y']+= $ty;
5258
+				HTML2PDF::$_tables[$param['num']]['new_page'] = false;
5259
+			} else {
5260
+				HTML2PDF::$_tables[$param['num']]['corr_y']++;
5261
+			}
5262
+
5263
+			return true;
5264
+		}
5265
+
5266
+		/**
5267
+		 * tag : TD
5268
+		 * mode : OPEN
5269
+		 *
5270
+		 * @param  array $param
5271
+		 * @return boolean
5272
+		 */
5273
+		protected function _tag_open_TD($param, $other = 'td')
5274
+		{
5275
+			if ($this->_isForOneLine) return false;
5276
+
5277
+			$this->_maxH = 0;
5278
+
5279
+			$param['cellpadding'] = HTML2PDF::$_tables[$param['num']]['cellpadding'].'mm';
5280
+			$param['cellspacing'] = HTML2PDF::$_tables[$param['num']]['cellspacing'].'mm';
5281
+
5282
+			// specific style for LI
5283
+			if ($other=='li') {
5284
+				$specialLi = true;
5285
+			} else {
5286
+				$specialLi = false;
5287
+				if ($other=='li_sub') {
5288
+					$param['style']['border'] = 'none';
5289
+					$param['style']['background-color']    = 'transparent';
5290
+					$param['style']['background-image']    = 'none';
5291
+					$param['style']['background-position'] = '';
5292
+					$param['style']['background-repeat']   = '';
5293
+					$other = 'li';
5294
+				}
5295
+			}
5296
+
5297
+			// get the properties of the TD
5298
+			$x = HTML2PDF::$_tables[$param['num']]['td_curr'];
5299
+			$y = HTML2PDF::$_tables[$param['num']]['tr_curr']-1;
5300
+			$colspan = isset($param['colspan']) ? $param['colspan'] : 1;
5301
+			$rowspan = isset($param['rowspan']) ? $param['rowspan'] : 1;
5302
+
5303
+			// flag for collapse table
5304
+			$collapse = false;
5305
+
5306
+			// specific traitment for TD and TH
5307
+			if (in_array($other, array('td', 'th'))) {
5308
+				// id of the column
5309
+				$numCol = isset(HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr']) ? HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr'] : HTML2PDF::$_tables[$param['num']]['corr_x'];
5310
+
5311
+				// we get the properties of the COL tag, if exist
5312
+				if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol])) {
5313
+
5314
+					$colParam = HTML2PDF::$_tables[$param['num']]['cols'][$numCol];
5315
+
5316
+					// for colspans => we get all the neede widths
5317
+					$colParam['style']['width'] = array();
5318
+					for ($k=0; $k<$colspan; $k++) {
5319
+						if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol+$k]['style']['width'])) {
5320
+							$colParam['style']['width'][] = HTML2PDF::$_tables[$param['num']]['cols'][$numCol+$k]['style']['width'];
5321
+						}
5322
+					}
5323
+
5324
+					// calculate the total width of the column
5325
+					$total = '';
5326
+					$last = $this->parsingCss->getLastWidth();
5327
+					if (count($colParam['style']['width'])) {
5328
+						$total = $colParam['style']['width'][0]; unset($colParam['style']['width'][0]);
5329
+						foreach ($colParam['style']['width'] as $width) {
5330
+							if (substr($total, -1)=='%' && substr($width, -1)=='%')
5331
+								$total = (str_replace('%', '', $total)+str_replace('%', '', $width)).'%';
5332
+							else
5333
+								$total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm';
5334
+						}
5335
+					}
5336
+
5337
+					// get the final width
5338
+					if ($total) {
5339
+						$colParam['style']['width'] = $total;
5340
+					} else {
5341
+						unset($colParam['style']['width']);
5342
+					}
5343
+
5344
+
5345
+					// merge the styles of the COL and the TD
5346
+					$param['style'] = array_merge($colParam['style'], $param['style']);
5347
+
5348
+					// merge the class of the COL and the TD
5349
+					if (isset($colParam['class'])) {
5350
+						$param['class'] = $colParam['class'].(isset($param['class']) ? ' '.$param['class'] : '');
5351
+					}
5352
+				}
5353
+
5354
+				$collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false;
5355
+			}
5356
+
5357
+			$this->parsingCss->save();
5358
+
5359
+			// legacy for TD and TH
5360
+			$legacy = null;
5361
+			if (in_array($other, array('td', 'th'))) {
5362
+				$legacy = array();
5363
+
5364
+				$old = $this->parsingCss->getLastValue('background');
5365
+				if ($old && ($old['color'] || $old['image']))
5366
+					$legacy['background'] = $old;
5367
+
5368
+				if (HTML2PDF::$_tables[$param['num']]['border']) {
5369
+					$legacy['border'] = array();
5370
+					$legacy['border']['l'] = HTML2PDF::$_tables[$param['num']]['border'];
5371
+					$legacy['border']['t'] = HTML2PDF::$_tables[$param['num']]['border'];
5372
+					$legacy['border']['r'] = HTML2PDF::$_tables[$param['num']]['border'];
5373
+					$legacy['border']['b'] = HTML2PDF::$_tables[$param['num']]['border'];
5374
+				}
5375
+			}
5376
+			$return = $this->parsingCss->analyse($other, $param, $legacy);
5377
+
5378
+			if ($specialLi) {
5379
+				$this->parsingCss->value['width']-= $this->parsingCss->ConvertToMM($this->_listeGetWidth());
5380
+				$this->parsingCss->value['width']-= $this->parsingCss->ConvertToMM($this->_listeGetPadding());
5381
+			}
5382
+			$this->parsingCss->setPosition();
5383
+			$this->parsingCss->fontSet();
5384
+
5385
+			// if tale collapse => modify the borders
5386
+			if ($collapse) {
5387
+				if (!$this->_subPart) {
5388
+					if (
5389
+						(HTML2PDF::$_tables[$param['num']]['tr_curr']>1 && !HTML2PDF::$_tables[$param['num']]['new_page']) ||
5390
+						(!$this->_isInThead && count(HTML2PDF::$_tables[$param['num']]['thead']['code']))
5391
+					) {
5392
+						$this->parsingCss->value['border']['t'] = $this->parsingCss->readBorder('none');
5393
+					}
5394
+				}
5395
+
5396
+				if (HTML2PDF::$_tables[$param['num']]['td_curr']>0) {
5397
+					if (!$return) $this->parsingCss->value['width']+= $this->parsingCss->value['border']['l']['width'];
5398
+					$this->parsingCss->value['border']['l'] = $this->parsingCss->readBorder('none');
5399
+				}
5400
+			}
5401
+
5402
+			// margins of the table
5403
+			$marge = array();
5404
+			$marge['t'] = $this->parsingCss->value['padding']['t']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['t']['width'];
5405
+			$marge['r'] = $this->parsingCss->value['padding']['r']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['r']['width'];
5406
+			$marge['b'] = $this->parsingCss->value['padding']['b']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['b']['width'];
5407
+			$marge['l'] = $this->parsingCss->value['padding']['l']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['l']['width'];
5408
+
5409
+			// if we are in a sub HTML
5410
+			if ($this->_subPart) {
5411
+				// new position in the table
5412
+				HTML2PDF::$_tables[$param['num']]['td_curr']++;
5413
+				HTML2PDF::$_tables[$param['num']]['cases'][$y][$x] = array();
5414
+				HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'] = 0;
5415
+				HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'] = 0;
5416
+				HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw'] = 0;
5417
+				HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['colspan'] = $colspan;
5418
+				HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['rowspan'] = $rowspan;
5419
+				HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr'] = HTML2PDF::$_tables[$param['num']]['corr_x'];
5420
+				HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Yr'] = HTML2PDF::$_tables[$param['num']]['corr_y'];
5421
+
5422
+				// prepare the mapping for rowspan and colspan
5423
+				for ($j=0; $j<$rowspan; $j++) {
5424
+					for ($i=0; $i<$colspan; $i++) {
5425
+						HTML2PDF::$_tables[$param['num']]['corr']
5426
+							[HTML2PDF::$_tables[$param['num']]['corr_y']+$j]
5427
+							[HTML2PDF::$_tables[$param['num']]['corr_x']+$i] = ($i+$j>0) ? '' : array($x,$y,$colspan,$rowspan);
5428
+					}
5429
+				}
5430
+				HTML2PDF::$_tables[$param['num']]['corr_x']+= $colspan;
5431
+				while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) {
5432
+					HTML2PDF::$_tables[$param['num']]['corr_x']++;
5433
+				}
5434
+
5435
+				// extract the content of the TD, and calculate his size
5436
+				$level = $this->parsingHtml->getLevel($this->_tempPos);
5437
+				$this->_createSubHTML($this->_subHtml);
5438
+				$this->_subHtml->parsingHtml->code = $level;
5439
+				$this->_subHtml->_makeHTMLcode();
5440
+				$this->_tempPos+= count($level);
5441
+			} else {
5442
+				// new position in the table
5443
+				HTML2PDF::$_tables[$param['num']]['td_curr']++;
5444
+				HTML2PDF::$_tables[$param['num']]['td_x']+= HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw'];
5445
+
5446
+				// borders and background of the TD
5447
+				$this->_drawRectangle(
5448
+					HTML2PDF::$_tables[$param['num']]['td_x'],
5449
+					HTML2PDF::$_tables[$param['num']]['td_y'],
5450
+					HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'],
5451
+					HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'],
5452
+					$this->parsingCss->value['border'],
5453
+					$this->parsingCss->value['padding'],
5454
+					HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5,
5455
+					$this->parsingCss->value['background']
5456
+				);
5457
+
5458
+				$this->parsingCss->value['width'] = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'] - $marge['l'] - $marge['r'];
5459
+
5460
+				// marges = size of the TD
5461
+				$mL = HTML2PDF::$_tables[$param['num']]['td_x']+$marge['l'];
5462
+				$mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width'];
5463
+				$this->_saveMargin($mL, 0, $mR);
5464
+
5465
+				// position of the content, from vertical-align
5466
+				$hCorr = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'];
5467
+				$hReel = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['real_h'];
5468
+				switch($this->parsingCss->value['vertical-align'])
5469
+				{
5470
+					case 'bottom':
5471
+						$yCorr = $hCorr-$hReel;
5472
+						break;
5473
+
5474
+					case 'middle':
5475
+						$yCorr = ($hCorr-$hReel)*0.5;
5476
+						break;
5477
+
5478
+					case 'top':
5479
+					default:
5480
+						$yCorr = 0;
5481
+						break;
5482
+				}
5483
+
5484
+				//  position of the content
5485
+				$x = HTML2PDF::$_tables[$param['num']]['td_x']+$marge['l'];
5486
+				$y = HTML2PDF::$_tables[$param['num']]['td_y']+$marge['t']+$yCorr;
5487
+				$this->pdf->setXY($x, $y);
5488
+				$this->_setNewPositionForNewLine();
5489
+			}
5490
+
5491
+			return true;
5492
+		}
5493
+
5494
+		/**
5495
+		 * tag : TD
5496
+		 * mode : CLOSE
5497
+		 *
5498
+		 * @param    array $param
5499
+		 * @return boolean
5500
+		 */
5501
+		protected function _tag_close_TD($param)
5502
+		{
5503
+			if ($this->_isForOneLine) return false;
5504
+
5505
+			$this->_maxH = 0;
5506
+
5507
+			// get the margins
5508
+			$marge = array();
5509
+			$marge['t'] = $this->parsingCss->value['padding']['t']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['t']['width'];
5510
+			$marge['r'] = $this->parsingCss->value['padding']['r']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['r']['width'];
5511
+			$marge['b'] = $this->parsingCss->value['padding']['b']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['b']['width'];
5512
+			$marge['l'] = $this->parsingCss->value['padding']['l']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['l']['width'];
5513
+			$marge['t']+= 0.001;
5514
+			$marge['r']+= 0.001;
5515
+			$marge['b']+= 0.001;
5516
+			$marge['l']+= 0.001;
5517
+
5518
+			// if we are in a sub HTML
5519
+			if ($this->_subPart) {
5520
+
5521
+				// it msut take only one page
5522
+				if ($this->_testTdInOnepage && $this->_subHtml->pdf->getPage()>1) {
5523
+					throw new HTML2PDF_exception(7);
5524
+				}
5525
+
5526
+				// size of the content of the TD
5527
+				$w0 = $this->_subHtml->_maxX + $marge['l'] + $marge['r'];
5528
+				$h0 = $this->_subHtml->_maxY + $marge['t'] + $marge['b'];
5529
+
5530
+				// size from the CSS style
5531
+				$w2 = $this->parsingCss->value['width'] + $marge['l'] + $marge['r'];
5532
+				$h2 = $this->parsingCss->value['height'] + $marge['t'] + $marge['b'];
5533
+
5534
+				// final size of the TD
5535
+				HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['w'] = max(array($w0, $w2));
5536
+				HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['h'] = max(array($h0, $h2));
5537
+
5538
+				// real position of the content
5539
+				HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['real_w'] = $w0;
5540
+				HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['real_h'] = $h0;
5541
+
5542
+				// destroy the sub HTML
5543
+				$this->_destroySubHTML($this->_subHtml);
5544
+			} else {
5545
+				$this->_loadMargin();
5546
+
5547
+				HTML2PDF::$_tables[$param['num']]['td_x']+= HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['w'];
5548
+			}
5549
+
5550
+			$this->parsingCss->load();
5551
+			$this->parsingCss->fontSet();
5552
+
5553
+			return true;
5554
+		}
5555
+
5556
+
5557
+		/**
5558
+		 * tag : TH
5559
+		 * mode : OPEN
5560
+		 *
5561
+		 * @param  array $param
5562
+		 * @return boolean
5563
+		 */
5564
+		protected function _tag_open_TH($param)
5565
+		{
5566
+			if ($this->_isForOneLine) return false;
5567
+
5568
+			$this->parsingCss->save();
5569
+			$this->parsingCss->value['font-bold'] = true;
5570
+
5571
+			$this->_tag_open_TD($param, 'th');
5572
+
5573
+			return true;
5574
+		}
5575
+
5576
+		/**
5577
+		 * tag : TH
5578
+		 * mode : CLOSE
5579
+		 *
5580
+		 * @param  array $param
5581
+		 * @return boolean
5582
+		 */
5583
+		protected function _tag_close_TH($param)
5584
+		{
5585
+			if ($this->_isForOneLine) return false;
5586
+
5587
+			$this->_tag_close_TD($param);
5588
+
5589
+			$this->parsingCss->load();
5590
+
5591
+			return true;
5592
+		}
5593
+
5594
+		/**
5595
+		 * tag : IMG
5596
+		 * mode : OPEN
5597
+		 *
5598
+		 * @param  array $param
5599
+		 * @return boolean
5600
+		 */
5601
+		protected function _tag_open_IMG($param)
5602
+		{
5603
+			$src    = str_replace('&amp;', '&', $param['src']);
5604
+
5605
+			$this->parsingCss->save();
5606
+			$this->parsingCss->value['width']    = 0;
5607
+			$this->parsingCss->value['height']    = 0;
5608
+			$this->parsingCss->value['border']    = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0));
5609
+			$this->parsingCss->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null);
5610
+			$this->parsingCss->analyse('img', $param);
5611
+			$this->parsingCss->setPosition();
5612
+			$this->parsingCss->fontSet();
5613
+
5614
+			$res = $this->_drawImage($src, isset($param['sub_li']));
5615
+			if (!$res) return $res;
5616
+
5617
+			$this->parsingCss->load();
5618
+			$this->parsingCss->fontSet();
5619
+			$this->_maxE++;
5620
+
5621
+			return true;
5622
+		}
5623
+
5624
+		/**
5625
+		 * tag : SELECT
5626
+		 * mode : OPEN
5627
+		 *
5628
+		 * @param  array $param
5629
+		 * @return boolean
5630
+		 */
5631
+		protected function _tag_open_SELECT($param)
5632
+		{
5633
+			if (!isset($param['name'])) {
5634
+				$param['name'] = 'champs_pdf_'.(count($this->_lstField)+1);
5635
+			}
5636
+
5637
+			$param['name'] = strtolower($param['name']);
5638
+
5639
+			if (isset($this->_lstField[$param['name']])) {
5640
+				$this->_lstField[$param['name']]++;
5641
+			} else {
5642
+				$this->_lstField[$param['name']] = 1;
5643
+			}
5644
+
5645
+			$this->parsingCss->save();
5646
+			$this->parsingCss->analyse('select', $param);
5647
+			$this->parsingCss->setPosition();
5648
+			$this->parsingCss->fontSet();
5649
+
5650
+			$this->_lstSelect = array();
5651
+			$this->_lstSelect['name']    = $param['name'];
5652
+			$this->_lstSelect['multi']    = isset($param['multiple']) ? true : false;
5653
+			$this->_lstSelect['size']    = isset($param['size']) ? $param['size'] : 1;
5654
+			$this->_lstSelect['options']    = array();
5655
+
5656
+			if ($this->_lstSelect['multi'] && $this->_lstSelect['size']<3) $this->_lstSelect['size'] = 3;
5657
+
5658
+			return true;
5659
+		}
5660
+
5661
+		/**
5662
+		 * tag : OPTION
5663
+		 * mode : OPEN
5664
+		 *
5665
+		 * @param    array $param
5666
+		 * @return boolean
5667
+		 */
5668
+		protected function _tag_open_OPTION($param)
5669
+		{
5670
+			// get the content of the option : it is the text of the option
5671
+			$level = $this->parsingHtml->getLevel($this->_parsePos);
5672
+			$this->_parsePos+= count($level);
5673
+			$value = isset($param['value']) ? $param['value'] : 'aut_tag_open_opt_'.(count($this->_lstSelect)+1);
5674
+
5675
+			$this->_lstSelect['options'][$value] = isset($level[0]['param']['txt']) ? $level[0]['param']['txt'] : '';
5676
+
5677
+			return true;
5678
+		}
5679
+
5680
+		/**
5681
+		 * tag : OPTION
5682
+		 * mode : CLOSE
5683
+		 *
5684
+		 * @param    array $param
5685
+		 * @return boolean
5686
+		 */
5687
+		protected function _tag_close_OPTION($param)
5688
+		{
5689
+			// nothing to do here
5690
+
5691
+			return true;
5692
+		}
5693
+
5694
+		/**
5695
+		 * tag : SELECT
5696
+		 * mode : CLOSE
5697
+		 *
5698
+		 * @param  array $param
5699
+		 * @return boolean
5700
+		 */
5701
+		protected function _tag_close_SELECT()
5702
+		{
5703
+			// position of the select
5704
+			$x = $this->pdf->getX();
5705
+			$y = $this->pdf->getY();
5706
+			$f = 1.08*$this->parsingCss->value['font-size'];
5707
+
5708
+			// width
5709
+			$w = $this->parsingCss->value['width']; if (!$w) $w = 50;
5710
+
5711
+			// height (automatic)
5712
+			$h = ($f*1.07*$this->_lstSelect['size'] + 1);
5713
+
5714
+			$prop = $this->parsingCss->getFormStyle();
5715
+
5716
+			// multy select
5717
+			if ($this->_lstSelect['multi']) {
5718
+				$prop['multipleSelection'] = 'true';
5719
+			}
5720
+
5721
+
5722
+			// single or multi select
5723
+			if ($this->_lstSelect['size']>1) {
5724
+				$this->pdf->ListBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop);
5725
+			} else {
5726
+				$this->pdf->ComboBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop);
5727
+			}
5728
+
5729
+			$this->_maxX = max($this->_maxX, $x+$w);
5730
+			$this->_maxY = max($this->_maxY, $y+$h);
5731
+			$this->_maxH = max($this->_maxH, $h);
5732
+			$this->_maxE++;
5733
+			$this->pdf->setX($x+$w);
5734
+
5735
+			$this->parsingCss->load();
5736
+			$this->parsingCss->fontSet();
5737
+
5738
+			$this->_lstSelect = array();
5739
+
5740
+			return true;
5741
+		}
5742
+
5743
+		/**
5744
+		 * tag : TEXTAREA
5745
+		 * mode : OPEN
5746
+		 *
5747
+		 * @param    array $param
5748
+		 * @return boolean
5749
+		 */
5750
+		protected function _tag_open_TEXTAREA($param)
5751
+		{
5752
+			if (!isset($param['name'])) {
5753
+				$param['name'] = 'champs_pdf_'.(count($this->_lstField)+1);
5754
+			}
5755
+
5756
+			$param['name'] = strtolower($param['name']);
5757
+
5758
+			if (isset($this->_lstField[$param['name']])) {
5759
+				$this->_lstField[$param['name']]++;
5760
+			} else {
5761
+				$this->_lstField[$param['name']] = 1;
5762
+			}
5763
+
5764
+			$this->parsingCss->save();
5765
+			$this->parsingCss->analyse('textarea', $param);
5766
+			$this->parsingCss->setPosition();
5767
+			$this->parsingCss->fontSet();
5768
+
5769
+			$x = $this->pdf->getX();
5770
+			$y = $this->pdf->getY();
5771
+			$fx = 0.65*$this->parsingCss->value['font-size'];
5772
+			$fy = 1.08*$this->parsingCss->value['font-size'];
5773
+
5774
+			// extract the content the textarea : value
5775
+			$level = $this->parsingHtml->getLevel($this->_parsePos);
5776
+			$this->_parsePos+= count($level);
5777
+
5778
+			// automatic size, from cols and rows properties
5779
+			$w = $fx*(isset($param['cols']) ? $param['cols'] : 22)+1;
5780
+			$h = $fy*1.07*(isset($param['rows']) ? $param['rows'] : 3)+3;
5781
+
5782
+			$prop = $this->parsingCss->getFormStyle();
5783
+
5784
+			$prop['multiline'] = true;
5785
+			$prop['value'] = isset($level[0]['param']['txt']) ? $level[0]['param']['txt'] : '';
5786
+
5787
+			$this->pdf->TextField($param['name'], $w, $h, $prop, array(), $x, $y);
5788
+
5789
+			$this->_maxX = max($this->_maxX, $x+$w);
5790
+			$this->_maxY = max($this->_maxY, $y+$h);
5791
+			$this->_maxH = max($this->_maxH, $h);
5792
+			$this->_maxE++;
5793
+			$this->pdf->setX($x+$w);
5794
+
5795
+			return true;
5796
+		}
5797
+
5798
+		/**
5799
+		 * tag : TEXTAREA
5800
+		 * mode : CLOSE
5801
+		 *
5802
+		 * @param  array $param
5803
+		 * @return boolean
5804
+		 */
5805
+		protected function _tag_close_TEXTAREA()
5806
+		{
5807
+			$this->parsingCss->load();
5808
+			$this->parsingCss->fontSet();
5809
+
5810
+			return true;
5811
+		}
5812
+
5813
+		/**
5814
+		 * tag : INPUT
5815
+		 * mode : OPEN
5816
+		 *
5817
+		 * @param  array $param
5818
+		 * @return boolean
5819
+		 */
5820
+		protected function _tag_open_INPUT($param)
5821
+		{
5822
+			if (!isset($param['name']))  $param['name']  = 'champs_pdf_'.(count($this->_lstField)+1);
5823
+			if (!isset($param['value'])) $param['value'] = '';
5824
+			if (!isset($param['type']))  $param['type']  = 'text';
5825
+
5826
+			$param['name'] = strtolower($param['name']);
5827
+			$param['type'] = strtolower($param['type']);
5828
+
5829
+			// the type must be valid
5830
+			if (!in_array($param['type'], array('text', 'checkbox', 'radio', 'hidden', 'submit', 'reset', 'button'))) {
5831
+				$param['type'] = 'text';
5832
+			}
5833
+
5834
+			if (isset($this->_lstField[$param['name']])) {
5835
+				$this->_lstField[$param['name']]++;
5836
+			} else {
5837
+				$this->_lstField[$param['name']] = 1;
5838
+			}
5839
+
5840
+			$this->parsingCss->save();
5841
+			$this->parsingCss->analyse('input', $param);
5842
+			$this->parsingCss->setPosition();
5843
+			$this->parsingCss->fontSet();
5844
+
5845
+			$name = $param['name'];
5846
+
5847
+			$x = $this->pdf->getX();
5848
+			$y = $this->pdf->getY();
5849
+			$f = 1.08*$this->parsingCss->value['font-size'];
5850
+
5851
+			$prop = $this->parsingCss->getFormStyle();
5852
+
5853
+			switch($param['type'])
5854
+			{
5855
+				case 'checkbox':
5856
+					$w = 3;
5857
+					$h = $w;
5858
+					if ($h<$f) $y+= ($f-$h)*0.5;
5859
+					$checked = (isset($param['checked']) && $param['checked']=='checked');
5860
+					$this->pdf->CheckBox($name, $w, $checked, $prop, array(), ($param['value'] ? $param['value'] : 'Yes'), $x, $y);
5861
+					break;
5862
+
5863
+				case 'radio':
5864
+					$w = 3;
5865
+					$h = $w;
5866
+					if ($h<$f) $y+= ($f-$h)*0.5;
5867
+					$checked = (isset($param['checked']) && $param['checked']=='checked');
5868
+					$this->pdf->RadioButton($name, $w, $prop, array(), ($param['value'] ? $param['value'] : 'On'), $checked, $x, $y);
5869
+					break;
5870
+
5871
+				case 'hidden':
5872
+					$w = 0;
5873
+					$h = 0;
5874
+					$prop['value'] = $param['value'];
5875
+					$this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y);
5876
+					break;
5877
+
5878
+				case 'text':
5879
+					$w = $this->parsingCss->value['width']; if (!$w) $w = 40;
5880
+					$h = $f*1.3;
5881
+					$prop['value'] = $param['value'];
5882
+					$this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y);
5883
+					break;
5884
+
5885
+				case 'submit':
5886
+					$w = $this->parsingCss->value['width'];    if (!$w) $w = 40;
5887
+					$h = $this->parsingCss->value['height'];    if (!$h) $h = $f*1.3;
5888
+					$action = array('S'=>'SubmitForm', 'F'=>$this->_isInForm, 'Flags'=>array('ExportFormat'));
5889
+					$this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
5890
+					break;
5891
+
5892
+				case 'reset':
5893
+					$w = $this->parsingCss->value['width'];    if (!$w) $w = 40;
5894
+					$h = $this->parsingCss->value['height'];    if (!$h) $h = $f*1.3;
5895
+					$action = array('S'=>'ResetForm');
5896
+					$this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
5897
+					break;
5898
+
5899
+				case 'button':
5900
+					$w = $this->parsingCss->value['width'];    if (!$w) $w = 40;
5901
+					$h = $this->parsingCss->value['height'];    if (!$h) $h = $f*1.3;
5902
+					$action = isset($param['onclick']) ? $param['onclick'] : '';
5903
+					$this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
5904
+					break;
5905
+
5906
+				default:
5907
+					$w = 0;
5908
+					$h = 0;
5909
+					break;
5910
+			}
5911
+
5912
+			$this->_maxX = max($this->_maxX, $x+$w);
5913
+			$this->_maxY = max($this->_maxY, $y+$h);
5914
+			$this->_maxH = max($this->_maxH, $h);
5915
+			$this->_maxE++;
5916
+			$this->pdf->setX($x+$w);
5917
+
5918
+			$this->parsingCss->load();
5919
+			$this->parsingCss->fontSet();
5920
+
5921
+			return true;
5922
+		}
5923
+
5924
+		/**
5925
+		 * tag : DRAW
5926
+		 * mode : OPEN
5927
+		 *
5928
+		 * @param  array $param
5929
+		 * @return boolean
5930
+		 */
5931
+		protected function _tag_open_DRAW($param)
5932
+		{
5933
+			if ($this->_isForOneLine) return false;
5934
+			if ($this->_debugActif) $this->_DEBUG_add('DRAW', true);
5935
+
5936
+			$this->parsingCss->save();
5937
+			$this->parsingCss->analyse('draw', $param);
5938
+			$this->parsingCss->fontSet();
5939
+
5940
+			$alignObject = null;
5941
+			if ($this->parsingCss->value['margin-auto']) $alignObject = 'center';
5942
+
5943
+			$overW = $this->parsingCss->value['width'];
5944
+			$overH = $this->parsingCss->value['height'];
5945
+			$this->parsingCss->value['old_maxX'] = $this->_maxX;
5946
+			$this->parsingCss->value['old_maxY'] = $this->_maxY;
5947
+			$this->parsingCss->value['old_maxH'] = $this->_maxH;
5948
+
5949
+			$w = $this->parsingCss->value['width'];
5950
+			$h = $this->parsingCss->value['height'];
5951
+
5952
+			if (!$this->parsingCss->value['position']) {
5953
+				if (
5954
+					$w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) &&
5955
+					$this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin())
5956
+					)
5957
+					$this->_tag_open_BR(array());
5958
+
5959
+				if (
5960
+						($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) &&
5961
+						($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) &&
5962
+						!$this->_isInOverflow
5963
+					)
5964
+					$this->_setNewPage();
5965
+
5966
+				$old = $this->parsingCss->getOldValues();
5967
+				$parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
5968
+
5969
+				if ($parentWidth>$w) {
5970
+					if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
5971
+					else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
5972
+				}
5973
+
5974
+				$this->parsingCss->setPosition();
5975
+			} else {
5976
+				$old = $this->parsingCss->getOldValues();
5977
+				$parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
5978
+
5979
+				if ($parentWidth>$w) {
5980
+					if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
5981
+					else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
5982
+				}
5983
+
5984
+				$this->parsingCss->setPosition();
5985
+				$this->_saveMax();
5986
+				$this->_maxX = 0;
5987
+				$this->_maxY = 0;
5988
+				$this->_maxH = 0;
5989
+				$this->_maxE = 0;
5990
+			}
5991
+
5992
+			$this->_drawRectangle(
5993
+				$this->parsingCss->value['x'],
5994
+				$this->parsingCss->value['y'],
5995
+				$this->parsingCss->value['width'],
5996
+				$this->parsingCss->value['height'],
5997
+				$this->parsingCss->value['border'],
5998
+				$this->parsingCss->value['padding'],
5999
+				0,
6000
+				$this->parsingCss->value['background']
6001
+			);
6002
+
6003
+			$marge = array();
6004
+			$marge['l'] = $this->parsingCss->value['border']['l']['width'];
6005
+			$marge['r'] = $this->parsingCss->value['border']['r']['width'];
6006
+			$marge['t'] = $this->parsingCss->value['border']['t']['width'];
6007
+			$marge['b'] = $this->parsingCss->value['border']['b']['width'];
6008
+
6009
+			$this->parsingCss->value['width'] -= $marge['l']+$marge['r'];
6010
+			$this->parsingCss->value['height']-= $marge['t']+$marge['b'];
6011
+
6012
+			$overW-= $marge['l']+$marge['r'];
6013
+			$overH-= $marge['t']+$marge['b'];
6014
+
6015
+			// clipping to draw only in the size opf the DRAW tag
6016
+			$this->pdf->clippingPathStart(
6017
+				$this->parsingCss->value['x']+$marge['l'],
6018
+				$this->parsingCss->value['y']+$marge['t'],
6019
+				$this->parsingCss->value['width'],
6020
+				$this->parsingCss->value['height']
6021
+			);
6022
+
6023
+			// left and right of the DRAW tag
6024
+			$mL = $this->parsingCss->value['x']+$marge['l'];
6025
+			$mR = $this->pdf->getW() - $mL - $overW;
6026
+
6027
+			// position of the DRAW tag
6028
+			$x = $this->parsingCss->value['x']+$marge['l'];
6029
+			$y = $this->parsingCss->value['y']+$marge['t'];
6030
+
6031
+			// prepare the drawing area
6032
+			$this->_saveMargin($mL, 0, $mR);
6033
+			$this->pdf->setXY($x, $y);
6034
+
6035
+			// we are in a draw tag
6036
+			$this->_isInDraw = array(
6037
+				'x' => $x,
6038
+				'y' => $y,
6039
+				'w' => $overW,
6040
+				'h' => $overH,
6041
+			);
6042
+
6043
+			// init the translate matrix : (0,0) => ($x, $y)
6044
+			$this->pdf->doTransform(array(1,0,0,1,$x,$y));
6045
+			$this->pdf->SetAlpha(1.);
6046
+			return true;
6047
+		}
6048
+
6049
+		/**
6050
+		 * tag : DRAW
6051
+		 * mode : CLOSE
6052
+		 *
6053
+		 * @param  array $param
6054
+		 * @return boolean
6055
+		 */
6056
+		protected function _tag_close_DRAW($param)
6057
+		{
6058
+			if ($this->_isForOneLine) return false;
6059
+
6060
+			$this->pdf->SetAlpha(1.);
6061
+			$this->pdf->undoTransform();
6062
+			$this->pdf->clippingPathStop();
6063
+
6064
+			$this->_maxX = $this->parsingCss->value['old_maxX'];
6065
+			$this->_maxY = $this->parsingCss->value['old_maxY'];
6066
+			$this->_maxH = $this->parsingCss->value['old_maxH'];
6067
+
6068
+			$marge = array();
6069
+			$marge['l'] = $this->parsingCss->value['border']['l']['width'];
6070
+			$marge['r'] = $this->parsingCss->value['border']['r']['width'];
6071
+			$marge['t'] = $this->parsingCss->value['border']['t']['width'];
6072
+			$marge['b'] = $this->parsingCss->value['border']['b']['width'];
6073
+
6074
+			$x = $this->parsingCss->value['x'];
6075
+			$y = $this->parsingCss->value['y'];
6076
+			$w = $this->parsingCss->value['width']+$marge['l']+$marge['r'];
6077
+			$h = $this->parsingCss->value['height']+$marge['t']+$marge['b'];
6078
+
6079
+			if ($this->parsingCss->value['position']!='absolute') {
6080
+				$this->pdf->setXY($x+$w, $y);
6081
+
6082
+				$this->_maxX = max($this->_maxX, $x+$w);
6083
+				$this->_maxY = max($this->_maxY, $y+$h);
6084
+				$this->_maxH = max($this->_maxH, $h);
6085
+				$this->_maxE++;
6086
+			} else {
6087
+				// position
6088
+				$this->pdf->setXY($this->parsingCss->value['xc'], $this->parsingCss->value['yc']);
6089
+
6090
+				$this->_loadMax();
6091
+			}
6092
+
6093
+			$block = ($this->parsingCss->value['display']!='inline' && $this->parsingCss->value['position']!='absolute');
6094
+
6095
+			$this->parsingCss->load();
6096
+			$this->parsingCss->fontSet();
6097
+			$this->_loadMargin();
6098
+
6099
+			if ($block) $this->_tag_open_BR(array());
6100
+			if ($this->_debugActif) $this->_DEBUG_add('DRAW', false);
6101
+
6102
+			$this->_isInDraw = null;
6103
+
6104
+			return true;
6105
+		}
6106
+
6107
+		/**
6108
+		 * tag : LINE
6109
+		 * mode : OPEN
6110
+		 *
6111
+		 * @param  array $param
6112
+		 * @return boolean
6113
+		 */
6114
+		protected function _tag_open_LINE($param)
6115
+		{
6116
+			if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'LINE');
6117
+
6118
+			$this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6119
+			$this->parsingCss->save();
6120
+			$styles = $this->parsingCss->getSvgStyle('path', $param);
6121
+			$styles['fill'] = null;
6122
+			$style = $this->pdf->svgSetStyle($styles);
6123
+
6124
+			$x1 = isset($param['x1']) ? $this->parsingCss->ConvertToMM($param['x1'], $this->_isInDraw['w']) : 0.;
6125
+			$y1 = isset($param['y1']) ? $this->parsingCss->ConvertToMM($param['y1'], $this->_isInDraw['h']) : 0.;
6126
+			$x2 = isset($param['x2']) ? $this->parsingCss->ConvertToMM($param['x2'], $this->_isInDraw['w']) : 0.;
6127
+			$y2 = isset($param['y2']) ? $this->parsingCss->ConvertToMM($param['y2'], $this->_isInDraw['h']) : 0.;
6128
+			$this->pdf->svgLine($x1, $y1, $x2, $y2);
6129
+
6130
+			$this->pdf->undoTransform();
6131
+			$this->parsingCss->load();
6132
+		}
6133
+
6134
+		/**
6135
+		 * tag : RECT
6136
+		 * mode : OPEN
6137
+		 *
6138
+		 * @param  array $param
6139
+		 * @return boolean
6140
+		 */
6141
+		protected function _tag_open_RECT($param)
6142
+		{
6143
+			if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'RECT');
6144
+
6145
+			$this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6146
+			$this->parsingCss->save();
6147
+			$styles = $this->parsingCss->getSvgStyle('path', $param);
6148
+			$style = $this->pdf->svgSetStyle($styles);
6149
+
6150
+			$x = isset($param['x']) ? $this->parsingCss->ConvertToMM($param['x'], $this->_isInDraw['w']) : 0.;
6151
+			$y = isset($param['y']) ? $this->parsingCss->ConvertToMM($param['y'], $this->_isInDraw['h']) : 0.;
6152
+			$w = isset($param['w']) ? $this->parsingCss->ConvertToMM($param['w'], $this->_isInDraw['w']) : 0.;
6153
+			$h = isset($param['h']) ? $this->parsingCss->ConvertToMM($param['h'], $this->_isInDraw['h']) : 0.;
6154
+
6155
+			$this->pdf->svgRect($x, $y, $w, $h, $style);
6156
+
6157
+			$this->pdf->undoTransform();
6158
+			$this->parsingCss->load();
6159
+		}
6160
+
6161
+		/**
6162
+		 * tag : CIRCLE
6163
+		 * mode : OPEN
6164
+		 *
6165
+		 * @param  array $param
6166
+		 * @return boolean
6167
+		 */
6168
+		protected function _tag_open_CIRCLE($param)
6169
+		{
6170
+			if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'CIRCLE');
6171
+
6172
+			$this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6173
+			$this->parsingCss->save();
6174
+			$styles = $this->parsingCss->getSvgStyle('path', $param);
6175
+			$style = $this->pdf->svgSetStyle($styles);
6176
+
6177
+			$cx = isset($param['cx']) ? $this->parsingCss->ConvertToMM($param['cx'], $this->_isInDraw['w']) : 0.;
6178
+			$cy = isset($param['cy']) ? $this->parsingCss->ConvertToMM($param['cy'], $this->_isInDraw['h']) : 0.;
6179
+			$r = isset($param['r']) ? $this->parsingCss->ConvertToMM($param['r'], $this->_isInDraw['w']) : 0.;
6180
+			$this->pdf->svgEllipse($cx, $cy, $r, $r, $style);
6181
+
6182
+			$this->pdf->undoTransform();
6183
+			$this->parsingCss->load();
6184
+		}
6185
+
6186
+		/**
6187
+		 * tag : ELLIPSE
6188
+		 * mode : OPEN
6189
+		 *
6190
+		 * @param  array $param
6191
+		 * @return boolean
6192
+		 */
6193
+		protected function _tag_open_ELLIPSE($param)
6194
+		{
6195
+			if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'ELLIPSE');
6196
+
6197
+			$this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6198
+			$this->parsingCss->save();
6199
+			$styles = $this->parsingCss->getSvgStyle('path', $param);
6200
+			$style = $this->pdf->svgSetStyle($styles);
6201
+
6202
+			$cx = isset($param['cx']) ? $this->parsingCss->ConvertToMM($param['cx'], $this->_isInDraw['w']) : 0.;
6203
+			$cy = isset($param['cy']) ? $this->parsingCss->ConvertToMM($param['cy'], $this->_isInDraw['h']) : 0.;
6204
+			$rx = isset($param['ry']) ? $this->parsingCss->ConvertToMM($param['rx'], $this->_isInDraw['w']) : 0.;
6205
+			$ry = isset($param['rx']) ? $this->parsingCss->ConvertToMM($param['ry'], $this->_isInDraw['h']) : 0.;
6206
+			$this->pdf->svgEllipse($cx, $cy, $rx, $ry, $style);
6207
+
6208
+			$this->pdf->undoTransform();
6209
+			$this->parsingCss->load();
6210
+		}
6211
+
6212
+
6213
+		/**
6214
+		 * tag : POLYLINE
6215
+		 * mode : OPEN
6216
+		 *
6217
+		 * @param  array $param
6218
+		 * @return boolean
6219
+		 */
6220
+		protected function _tag_open_POLYLINE($param)
6221
+		{
6222
+			if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON');
6223
+
6224
+			$this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6225
+			$this->parsingCss->save();
6226
+			$styles = $this->parsingCss->getSvgStyle('path', $param);
6227
+			$style = $this->pdf->svgSetStyle($styles);
6228
+
6229
+			$path = isset($param['points']) ? $param['points'] : null;
6230
+			if ($path) {
6231
+				$path = str_replace(',', ' ', $path);
6232
+				$path = preg_replace('/[\s]+/', ' ', trim($path));
6233
+
6234
+				// prepare the path
6235
+				$path = explode(' ', $path);
6236
+				foreach ($path as $k => $v) {
6237
+					$path[$k] = trim($v);
6238
+					if ($path[$k]==='') unset($path[$k]);
6239
+				}
6240
+				$path = array_values($path);
6241
+
6242
+				$actions = array();
6243
+				for ($k=0; $k<count($path); $k+=2) {
6244
+					$actions[] = array(
6245
+						($k ? 'L' : 'M') ,
6246
+						$this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']),
6247
+						$this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h'])
6248
+					);
6249
+				}
6250
+
6251
+				// drawing
6252
+				$this->pdf->svgPolygone($actions, $style);
6253
+			}
6254
+
6255
+			$this->pdf->undoTransform();
6256
+			$this->parsingCss->load();
6257
+		}
6258
+
6259
+		/**
6260
+		 * tag : POLYGON
6261
+		 * mode : OPEN
6262
+		 *
6263
+		 * @param  array $param
6264
+		 * @return boolean
6265
+		 */
6266
+		protected function _tag_open_POLYGON($param)
6267
+		{
6268
+			if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON');
6269
+
6270
+			$this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6271
+			$this->parsingCss->save();
6272
+			$styles = $this->parsingCss->getSvgStyle('path', $param);
6273
+			$style = $this->pdf->svgSetStyle($styles);
6274
+
6275
+			$path = (isset($param['points']) ? $param['points'] : null);
6276
+			if ($path) {
6277
+				$path = str_replace(',', ' ', $path);
6278
+				$path = preg_replace('/[\s]+/', ' ', trim($path));
6279
+
6280
+				// prepare the path
6281
+				$path = explode(' ', $path);
6282
+				foreach ($path as $k => $v) {
6283
+					$path[$k] = trim($v);
6284
+					if ($path[$k]==='') unset($path[$k]);
6285
+				}
6286
+				$path = array_values($path);
6287
+
6288
+				$actions = array();
6289
+				for ($k=0; $k<count($path); $k+=2) {
6290
+					$actions[] = array(
6291
+						($k ? 'L' : 'M') ,
6292
+						$this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']),
6293
+						$this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h'])
6294
+					);
6295
+				}
6296
+				$actions[] = array('z');
6297
+
6298
+				// drawing
6299
+				$this->pdf->svgPolygone($actions, $style);
6300
+			}
6301
+
6302
+			$this->pdf->undoTransform();
6303
+			$this->parsingCss->load();
6304
+		}
6305
+
6306
+		/**
6307
+		 * tag : PATH
6308
+		 * mode : OPEN
6309
+		 *
6310
+		 * @param  array $param
6311
+		 * @return boolean
6312
+		 */
6313
+		protected function _tag_open_PATH($param)
6314
+		{
6315
+			if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'PATH');
6316
+
6317
+			$this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6318
+			$this->parsingCss->save();
6319
+			$styles = $this->parsingCss->getSvgStyle('path', $param);
6320
+			$style = $this->pdf->svgSetStyle($styles);
6321
+
6322
+			$path = isset($param['d']) ? $param['d'] : null;
6323
+
6324
+			if ($path) {
6325
+				// prepare the path
6326
+				$path = str_replace(',', ' ', $path);
6327
+				$path = preg_replace('/([a-zA-Z])([0-9\.\-])/', '$1 $2', $path);
6328
+				$path = preg_replace('/([0-9\.])([a-zA-Z])/', '$1 $2', $path);
6329
+				$path = preg_replace('/[\s]+/', ' ', trim($path));
6330
+				$path = preg_replace('/ ([a-z]{2})/', '$1', $path);
6331
+
6332
+				$path = explode(' ', $path);
6333
+				foreach ($path as $k => $v) {
6334
+					$path[$k] = trim($v);
6335
+					if ($path[$k]==='') unset($path[$k]);
6336
+				}
6337
+				$path = array_values($path);
6338
+
6339
+				// read each actions in the path
6340
+				$actions = array();
6341
+				$action = array();
6342
+				$lastAction = null; // last action found
6343
+				for ($k=0; $k<count($path);true) {
6344
+
6345
+					// for this actions, we can not have multi coordonate
6346
+					if (in_array($lastAction, array('z', 'Z'))) {
6347
+						$lastAction = null;
6348
+					}
6349
+
6350
+					// read the new action (forcing if no action before)
6351
+					if (preg_match('/^[a-z]+$/i', $path[$k]) || $lastAction===null) {
6352
+						$lastAction = $path[$k];
6353
+						$k++;
6354
+					}
6355
+
6356
+					// current action
6357
+					$action = array();
6358
+					$action[] = $lastAction;
6359
+					switch($lastAction)
6360
+					{
6361
+						case 'C':
6362
+						case 'c':
6363
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // x1
6364
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']);    // y1
6365
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+2], $this->_isInDraw['w']);    // x2
6366
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+3], $this->_isInDraw['h']);    // y2
6367
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+4], $this->_isInDraw['w']);    // x
6368
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+5], $this->_isInDraw['h']);    // y
6369
+							$k+= 6;
6370
+							break;
6371
+
6372
+						case 'Q':
6373
+						case 'S':
6374
+						case 'q':
6375
+						case 's':
6376
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // x2
6377
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']);    // y2
6378
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+2], $this->_isInDraw['w']);    // x
6379
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+3], $this->_isInDraw['h']);    // y
6380
+							$k+= 4;
6381
+							break;
6382
+
6383
+						case 'A':
6384
+						case 'a':
6385
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // rx
6386
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']);    // ry
6387
+							$action[] = 1.*$path[$k+2];                                                        // angle de deviation de l'axe X
6388
+							$action[] = ($path[$k+3]=='1') ? 1 : 0;                                            // large-arc-flag
6389
+							$action[] = ($path[$k+4]=='1') ? 1 : 0;                                            // sweep-flag
6390
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+5], $this->_isInDraw['w']);    // x
6391
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+6], $this->_isInDraw['h']);    // y
6392
+							$k+= 7;
6393
+							break;
6394
+
6395
+						case 'M':
6396
+						case 'L':
6397
+						case 'T':
6398
+						case 'm':
6399
+						case 'l':
6400
+						case 't':
6401
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // x
6402
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']);    // y
6403
+							$k+= 2;
6404
+							break;
6405
+
6406
+						case 'H':
6407
+						case 'h':
6408
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // x
6409
+							$k+= 1;
6410
+							break;
6411
+
6412
+						case 'V':
6413
+						case 'v':
6414
+							$action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['h']);    // y
6415
+							$k+= 1;
6416
+							break;
6417
+
6418
+						case 'z':
6419
+						case 'Z':
6420
+						default:
6421
+							break;
6422
+					}
6423
+					// add the action
6424
+					$actions[] = $action;
6425
+				}
6426
+
6427
+				// drawing
6428
+				$this->pdf->svgPolygone($actions, $style);
6429
+			}
6430
+
6431
+			$this->pdf->undoTransform();
6432
+			$this->parsingCss->load();
6433
+		}
6434
+
6435
+		/**
6436
+		 * tag : G
6437
+		 * mode : OPEN
6438
+		 *
6439
+		 * @param  array $param
6440
+		 * @return boolean
6441
+		 */
6442
+		protected function _tag_open_G($param)
6443
+		{
6444
+			if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'G');
6445
+
6446
+			$this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6447
+			$this->parsingCss->save();
6448
+			$styles = $this->parsingCss->getSvgStyle('path', $param);
6449
+			$style = $this->pdf->svgSetStyle($styles);
6450
+		}
6451
+
6452
+		/**
6453
+		 * tag : G
6454
+		 * mode : CLOSE
6455
+		 *
6456
+		 * @param  array $param
6457
+		 * @return boolean
6458
+		 */
6459
+		protected function _tag_close_G($param)
6460
+		{
6461
+			$this->pdf->undoTransform();
6462
+			$this->parsingCss->load();
6463
+		}
6464
+
6465
+		/**
6466
+		 * new page for the automatic Index, does not use thie method. Only HTML2PDF_myPdf could use it !!!!
6467
+		 *
6468
+		 * @param  &int $page
6469
+		 * @return integer $oldPage
6470
+		 */
6471
+		public function _INDEX_NewPage(&$page)
6472
+		{
6473
+			if ($page) {
6474
+				$oldPage = $this->pdf->getPage();
6475
+				$this->pdf->setPage($page);
6476
+				$this->pdf->setXY($this->_margeLeft, $this->_margeTop);
6477
+				$this->_maxH = 0;
6478
+				$page++;
6479
+				return $oldPage;
6480
+			} else {
6481
+				$this->_setNewPage();
6482
+				return null;
6483
+			}
6484
+		}
6485
+
6486
+	}
6488 6487
 }
6489 6488
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +917 added lines, -917 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 - main class
4 4
  *
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
     define('__CLASS_HTML2PDF__', '4.03');
15 15
     define('HTML2PDF_USED_TCPDF_VERSION', '5.0.002');
16 16
 
17
-    require_once(dirname(__FILE__).'/_class/exception.class.php');
18
-    require_once(dirname(__FILE__).'/_class/locale.class.php');
19
-    require_once(dirname(__FILE__).'/_class/myPdf.class.php');
20
-    require_once(dirname(__FILE__).'/_class/parsingHtml.class.php');
21
-    require_once(dirname(__FILE__).'/_class/parsingCss.class.php');
17
+    require_once(dirname(__FILE__) . '/_class/exception.class.php');
18
+    require_once(dirname(__FILE__) . '/_class/locale.class.php');
19
+    require_once(dirname(__FILE__) . '/_class/myPdf.class.php');
20
+    require_once(dirname(__FILE__) . '/_class/parsingHtml.class.php');
21
+    require_once(dirname(__FILE__) . '/_class/parsingCss.class.php');
22 22
 
23 23
     class HTML2PDF
24 24
     {
@@ -40,77 +40,77 @@  discard block
 block discarded – undo
40 40
          */
41 41
         public $parsingHtml = null;
42 42
 
43
-        protected $_langue           = 'fr';        // locale of the messages
44
-        protected $_orientation      = 'P';         // page orientation : Portrait ou Landscape
45
-        protected $_format           = 'A4';        // page format : A4, A3, ...
46
-        protected $_encoding         = '';          // charset encoding
47
-        protected $_unicode          = true;        // means that the input text is unicode (default = true)
48
-
49
-        protected $_testTdInOnepage  = true;        // test of TD that can not take more than one page
50
-        protected $_testIsImage      = true;        // test if the images exist or not
51
-        protected $_testIsDeprecated = false;       // test the deprecated functions
52
-
53
-        protected $_parsePos         = 0;           // position in the parsing
54
-        protected $_tempPos          = 0;           // temporary position for complex table
55
-        protected $_page             = 0;           // current page number
56
-
57
-        protected $_subHtml          = null;        // sub html
58
-        protected $_subPart          = false;       // sub HTML2PDF
59
-        protected $_subHEADER        = array();     // sub action to make the header
60
-        protected $_subFOOTER        = array();     // sub action to make the footer
61
-        protected $_subSTATES        = array();     // array to save some parameters
62
-
63
-        protected $_isSubPart        = false;       // flag : in a sub html2pdf
64
-        protected $_isInThead        = false;       // flag : in a thead
65
-        protected $_isInTfoot        = false;       // flag : in a tfoot
66
-        protected $_isInOverflow     = false;       // flag : in a overflow
67
-        protected $_isInFooter       = false;       // flag : in a footer
68
-        protected $_isInDraw         = null;        // flag : in a draw (svg)
69
-        protected $_isAfterFloat     = false;       // flag : is just after a float
70
-        protected $_isInForm         = false;       // flag : is in a float. false / action of the form
71
-        protected $_isInLink         = '';          // flag : is in a link. empty / href of the link
72
-        protected $_isInParagraph    = false;       // flag : is in a paragraph
73
-        protected $_isForOneLine     = false;       // flag : in a specific sub html2pdf to have the height of the next line
74
-
75
-        protected $_maxX             = 0;           // maximum X of the current zone
76
-        protected $_maxY             = 0;           // maximum Y of the current zone
77
-        protected $_maxE             = 0;           // number of elements in the current zone
78
-        protected $_maxH             = 0;           // maximum height of the line in the current zone
79
-        protected $_maxSave          = array();     // save the maximums of the current zone
80
-        protected $_currentH         = 0;           // height of the current line
81
-
82
-        protected $_defaultLeft      = 0;           // default marges of the page
43
+        protected $_langue           = 'fr'; // locale of the messages
44
+        protected $_orientation      = 'P'; // page orientation : Portrait ou Landscape
45
+        protected $_format           = 'A4'; // page format : A4, A3, ...
46
+        protected $_encoding         = ''; // charset encoding
47
+        protected $_unicode          = true; // means that the input text is unicode (default = true)
48
+
49
+        protected $_testTdInOnepage  = true; // test of TD that can not take more than one page
50
+        protected $_testIsImage      = true; // test if the images exist or not
51
+        protected $_testIsDeprecated = false; // test the deprecated functions
52
+
53
+        protected $_parsePos         = 0; // position in the parsing
54
+        protected $_tempPos          = 0; // temporary position for complex table
55
+        protected $_page             = 0; // current page number
56
+
57
+        protected $_subHtml          = null; // sub html
58
+        protected $_subPart          = false; // sub HTML2PDF
59
+        protected $_subHEADER        = array(); // sub action to make the header
60
+        protected $_subFOOTER        = array(); // sub action to make the footer
61
+        protected $_subSTATES        = array(); // array to save some parameters
62
+
63
+        protected $_isSubPart        = false; // flag : in a sub html2pdf
64
+        protected $_isInThead        = false; // flag : in a thead
65
+        protected $_isInTfoot        = false; // flag : in a tfoot
66
+        protected $_isInOverflow     = false; // flag : in a overflow
67
+        protected $_isInFooter       = false; // flag : in a footer
68
+        protected $_isInDraw         = null; // flag : in a draw (svg)
69
+        protected $_isAfterFloat     = false; // flag : is just after a float
70
+        protected $_isInForm         = false; // flag : is in a float. false / action of the form
71
+        protected $_isInLink         = ''; // flag : is in a link. empty / href of the link
72
+        protected $_isInParagraph    = false; // flag : is in a paragraph
73
+        protected $_isForOneLine     = false; // flag : in a specific sub html2pdf to have the height of the next line
74
+
75
+        protected $_maxX             = 0; // maximum X of the current zone
76
+        protected $_maxY             = 0; // maximum Y of the current zone
77
+        protected $_maxE             = 0; // number of elements in the current zone
78
+        protected $_maxH             = 0; // maximum height of the line in the current zone
79
+        protected $_maxSave          = array(); // save the maximums of the current zone
80
+        protected $_currentH         = 0; // height of the current line
81
+
82
+        protected $_defaultLeft      = 0; // default marges of the page
83 83
         protected $_defaultTop       = 0;
84 84
         protected $_defaultRight     = 0;
85 85
         protected $_defaultBottom    = 0;
86
-        protected $_defaultFont      = null;        // default font to use, is the asked font does not exist
86
+        protected $_defaultFont      = null; // default font to use, is the asked font does not exist
87 87
 
88
-        protected $_margeLeft        = 0;           // current marges of the page
88
+        protected $_margeLeft        = 0; // current marges of the page
89 89
         protected $_margeTop         = 0;
90 90
         protected $_margeRight       = 0;
91 91
         protected $_margeBottom      = 0;
92
-        protected $_marges           = array();     // save the different marges of the current page
93
-        protected $_pageMarges       = array();     // float marges of the current page
94
-        protected $_background       = array();     // background informations
92
+        protected $_marges           = array(); // save the different marges of the current page
93
+        protected $_pageMarges       = array(); // float marges of the current page
94
+        protected $_background       = array(); // background informations
95 95
 
96 96
 
97
-        protected $_firstPage        = true;        // flag : first page
98
-        protected $_defList          = array();     // table to save the stats of the tags UL and OL
97
+        protected $_firstPage        = true; // flag : first page
98
+        protected $_defList          = array(); // table to save the stats of the tags UL and OL
99 99
 
100
-        protected $_lstAnchor        = array();     // list of the anchors
101
-        protected $_lstField         = array();     // list of the fields
102
-        protected $_lstSelect        = array();     // list of the options of the current select
103
-        protected $_previousCall     = null;        // last action called
100
+        protected $_lstAnchor        = array(); // list of the anchors
101
+        protected $_lstField         = array(); // list of the fields
102
+        protected $_lstSelect        = array(); // list of the options of the current select
103
+        protected $_previousCall     = null; // last action called
104 104
 
105
-        protected $_debugActif       = false;       // flag : mode debug is active
106
-        protected $_debugOkUsage     = false;       // flag : the function memory_get_usage exist
107
-        protected $_debugOkPeak      = false;       // flag : the function memory_get_peak_usage exist
108
-        protected $_debugLevel       = 0;           // level in the debug
109
-        protected $_debugStartTime   = 0;           // debug start time
110
-        protected $_debugLastTime    = 0;           // debug stop time
105
+        protected $_debugActif       = false; // flag : mode debug is active
106
+        protected $_debugOkUsage     = false; // flag : the function memory_get_usage exist
107
+        protected $_debugOkPeak      = false; // flag : the function memory_get_peak_usage exist
108
+        protected $_debugLevel       = 0; // level in the debug
109
+        protected $_debugStartTime   = 0; // debug start time
110
+        protected $_debugLastTime    = 0; // debug stop time
111 111
 
112
-        static protected $_subobj    = null;        // object html2pdf prepared in order to accelerate the creation of sub html2pdf
113
-        static protected $_tables    = array();     // static table to prepare the nested html tables
112
+        static protected $_subobj    = null; // object html2pdf prepared in order to accelerate the creation of sub html2pdf
113
+        static protected $_tables    = array(); // static table to prepare the nested html tables
114 114
 
115 115
         /**
116 116
          * class constructor
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
          * @param  array    $marges      Default marges (left, top, right, bottom)
125 125
          * @return HTML2PDF $this
126 126
          */
127
-        public function __construct($orientation = 'P', $format = 'A4', $langue='fr', $unicode=true, $encoding='UTF-8', $marges = array(5, 5, 5, 8))
127
+        public function __construct($orientation = 'P', $format = 'A4', $langue = 'fr', $unicode = true, $encoding = 'UTF-8', $marges = array(5, 5, 5, 8))
128 128
         {
129 129
             // init the page number
130 130
             $this->_page         = 0;
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
          * @return HTML2PDF $this
287 287
          * @see TCPDF::addFont
288 288
          */
289
-        public function addFont($family, $style='', $file='')
289
+        public function addFont($family, $style = '', $file = '')
290 290
         {
291 291
             $this->pdf->AddFont($family, $style, $file);
292 292
 
@@ -356,18 +356,18 @@  discard block
 block discarded – undo
356 356
             }
357 357
 
358 358
             // complete parameters
359
-            if ($dest===false) $dest = 'I';
360
-            if ($dest===true)  $dest = 'S';
361
-            if ($dest==='')    $dest = 'I';
362
-            if ($name=='')     $name='document.pdf';
359
+            if ($dest === false) $dest = 'I';
360
+            if ($dest === true)  $dest = 'S';
361
+            if ($dest === '')    $dest = 'I';
362
+            if ($name == '')     $name = 'document.pdf';
363 363
 
364 364
             // clean up the destination
365 365
             $dest = strtoupper($dest);
366
-            if (!in_array($dest, array('I', 'D', 'F', 'S', 'FI','FD'))) $dest = 'I';
366
+            if (!in_array($dest, array('I', 'D', 'F', 'S', 'FI', 'FD'))) $dest = 'I';
367 367
 
368 368
             // the name must be a PDF name
369
-            if (strtolower(substr($name, -4))!='.pdf') {
370
-                throw new HTML2PDF_exception(0, 'The output document name "'.$name.'" is not a PDF name');
369
+            if (strtolower(substr($name, -4)) != '.pdf') {
370
+                throw new HTML2PDF_exception(0, 'The output document name "' . $name . '" is not a PDF name');
371 371
             }
372 372
 
373 373
             // call the output of TCPDF
@@ -422,20 +422,20 @@  discard block
 block discarded – undo
422 422
 
423 423
             // extract the content
424 424
             $res = explode('<body', $html);
425
-            if (count($res)<2) return $html;
426
-            $content = '<page'.$res[1];
425
+            if (count($res) < 2) return $html;
426
+            $content = '<page' . $res[1];
427 427
             $content = explode('</body', $content);
428
-            $content = $content[0].'</page>';
428
+            $content = $content[0] . '</page>';
429 429
 
430 430
             // extract the link tags
431 431
             preg_match_all('/<link([^>]*)>/isU', $html, $match);
432 432
             foreach ($match[0] as $src)
433
-                $content = $src.'</link>'.$content;
433
+                $content = $src . '</link>' . $content;
434 434
 
435 435
             // extract the css style tags
436 436
             preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match);
437 437
             foreach ($match[0] as $src)
438
-                $content = $src.$content;
438
+                $content = $src . $content;
439 439
 
440 440
             return $content;
441 441
         }
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 
459 459
             $this->parsingCss->setOnlyLeft();
460 460
 
461
-            $this->_setNewPage($format, $orientation, null, null, ($myLastPageGroup!==null));
461
+            $this->_setNewPage($format, $orientation, null, null, ($myLastPageGroup !== null));
462 462
 
463 463
             $this->_saveMargin(0, 0, $marge);
464 464
             $this->_defList = $defLIST;
@@ -478,9 +478,9 @@  discard block
 block discarded – undo
478 478
          */
479 479
         protected function _vueHTML($content)
480 480
         {
481
-            $content = preg_replace('/<page_header([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue01').' : $1<hr><div$1>', $content);
482
-            $content = preg_replace('/<page_footer([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue02').' : $1<hr><div$1>', $content);
483
-            $content = preg_replace('/<page([^>]*)>/isU', '<hr>'.HTML2PDF_locale::get('vue03').' : $1<hr><div$1>', $content);
481
+            $content = preg_replace('/<page_header([^>]*)>/isU', '<hr>' . HTML2PDF_locale::get('vue01') . ' : $1<hr><div$1>', $content);
482
+            $content = preg_replace('/<page_footer([^>]*)>/isU', '<hr>' . HTML2PDF_locale::get('vue02') . ' : $1<hr><div$1>', $content);
483
+            $content = preg_replace('/<page([^>]*)>/isU', '<hr>' . HTML2PDF_locale::get('vue03') . ' : $1<hr><div$1>', $content);
484 484
             $content = preg_replace('/<\/page([^>]*)>/isU', '</div><hr>', $content);
485 485
             $content = preg_replace('/<bookmark([^>]*)>/isU', '<hr>bookmark : $1<hr>', $content);
486 486
             $content = preg_replace('/<\/bookmark([^>]*)>/isU', '', $content);
@@ -492,11 +492,11 @@  discard block
 block discarded – undo
492 492
             echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
493 493
 <html>
494 494
     <head>
495
-        <title>'.HTML2PDF_locale::get('vue04').' HTML</title>
496
-        <meta http-equiv="Content-Type" content="text/html; charset='.$this->_encoding.'" >
495
+        <title>'.HTML2PDF_locale::get('vue04') . ' HTML</title>
496
+        <meta http-equiv="Content-Type" content="text/html; charset='.$this->_encoding . '" >
497 497
     </head>
498 498
     <body style="padding: 10px; font-size: 10pt;font-family:    Verdana;">
499
-'.$content.'
499
+'.$content . '
500 500
     </body>
501 501
 </html>';
502 502
             exit;
@@ -513,13 +513,13 @@  discard block
 block discarded – undo
513 513
          */
514 514
         protected function _setDefaultMargins($left, $top, $right = null, $bottom = null)
515 515
         {
516
-            if ($right===null)  $right = $left;
517
-            if ($bottom===null) $bottom = 8;
516
+            if ($right === null)  $right = $left;
517
+            if ($bottom === null) $bottom = 8;
518 518
 
519
-            $this->_defaultLeft   = $this->parsingCss->ConvertToMM($left.'mm');
520
-            $this->_defaultTop    = $this->parsingCss->ConvertToMM($top.'mm');
521
-            $this->_defaultRight  = $this->parsingCss->ConvertToMM($right.'mm');
522
-            $this->_defaultBottom = $this->parsingCss->ConvertToMM($bottom.'mm');
519
+            $this->_defaultLeft   = $this->parsingCss->ConvertToMM($left . 'mm');
520
+            $this->_defaultTop    = $this->parsingCss->ConvertToMM($top . 'mm');
521
+            $this->_defaultRight  = $this->parsingCss->ConvertToMM($right . 'mm');
522
+            $this->_defaultBottom = $this->parsingCss->ConvertToMM($bottom . 'mm');
523 523
         }
524 524
 
525 525
         /**
@@ -532,13 +532,13 @@  discard block
 block discarded – undo
532 532
          * @param  integer $curr real position in the html parseur (if break line in the write of a text)
533 533
          * @param  boolean $resetPageNumber
534 534
          */
535
-        protected function _setNewPage($format = null, $orientation = '', $background = null, $curr = null, $resetPageNumber=false)
535
+        protected function _setNewPage($format = null, $orientation = '', $background = null, $curr = null, $resetPageNumber = false)
536 536
         {
537 537
             $this->_firstPage = false;
538 538
 
539 539
             $this->_format = $format ? $format : $this->_format;
540 540
             $this->_orientation = $orientation ? $orientation : $this->_orientation;
541
-            $this->_background = $background!==null ? $background : $this->_background;
541
+            $this->_background = $background !== null ? $background : $this->_background;
542 542
             $this->_maxY = 0;
543 543
             $this->_maxX = 0;
544 544
             $this->_maxH = 0;
@@ -588,9 +588,9 @@  discard block
 block discarded – undo
588 588
         protected function _setMargins()
589 589
         {
590 590
             // prepare the margins
591
-            $this->_margeLeft   = $this->_defaultLeft   + (isset($this->_background['left'])   ? $this->_background['left']   : 0);
592
-            $this->_margeRight  = $this->_defaultRight  + (isset($this->_background['right'])  ? $this->_background['right']  : 0);
593
-            $this->_margeTop    = $this->_defaultTop    + (isset($this->_background['top'])    ? $this->_background['top']    : 0);
591
+            $this->_margeLeft   = $this->_defaultLeft + (isset($this->_background['left']) ? $this->_background['left'] : 0);
592
+            $this->_margeRight  = $this->_defaultRight + (isset($this->_background['right']) ? $this->_background['right'] : 0);
593
+            $this->_margeTop    = $this->_defaultTop + (isset($this->_background['top']) ? $this->_background['top'] : 0);
594 594
             $this->_margeBottom = $this->_defaultBottom + (isset($this->_background['bottom']) ? $this->_background['bottom'] : 0);
595 595
 
596 596
             // set the PDF margins
@@ -599,10 +599,10 @@  discard block
 block discarded – undo
599 599
 
600 600
             // set the float Margins
601 601
             $this->_pageMarges = array();
602
-            if ($this->_isInParagraph!==false) {
603
-                $this->_pageMarges[floor($this->_margeTop*100)] = array($this->_isInParagraph[0], $this->pdf->getW()-$this->_isInParagraph[1]);
602
+            if ($this->_isInParagraph !== false) {
603
+                $this->_pageMarges[floor($this->_margeTop * 100)] = array($this->_isInParagraph[0], $this->pdf->getW() - $this->_isInParagraph[1]);
604 604
             } else {
605
-                $this->_pageMarges[floor($this->_margeTop*100)] = array($this->_margeLeft, $this->pdf->getW()-$this->_margeRight);
605
+                $this->_pageMarges[floor($this->_margeTop * 100)] = array($this->_margeLeft, $this->pdf->getW() - $this->_margeRight);
606 606
             }
607 607
         }
608 608
 
@@ -614,28 +614,28 @@  discard block
 block discarded – undo
614 614
          * @param  boolean $level (true=up, false=down, null=nothing to do)
615 615
          * @return $this
616 616
          */
617
-        protected function _DEBUG_add($name, $level=null)
617
+        protected function _DEBUG_add($name, $level = null)
618 618
         {
619 619
             // if true : UP
620
-            if ($level===true) $this->_debugLevel++;
620
+            if ($level === true) $this->_debugLevel++;
621 621
 
622
-            $name   = str_repeat('  ', $this->_debugLevel). $name.($level===true ? ' Begin' : ($level===false ? ' End' : ''));
622
+            $name = str_repeat('  ', $this->_debugLevel) . $name . ($level === true ? ' Begin' : ($level === false ? ' End' : ''));
623 623
             $time  = microtime(true);
624 624
             $usage = ($this->_debugOkUsage ? memory_get_usage() : 0);
625 625
             $peak  = ($this->_debugOkPeak ? memory_get_peak_usage() : 0);
626 626
 
627 627
             $this->_DEBUG_stepline(
628 628
                 $name,
629
-                number_format(($time - $this->_debugStartTime)*1000, 1, '.', ' ').' ms',
630
-                number_format(($time - $this->_debugLastTime)*1000, 1, '.', ' ').' ms',
631
-                number_format($usage/1024, 1, '.', ' ').' Ko',
632
-                number_format($peak/1024, 1, '.', ' ').' Ko'
629
+                number_format(($time - $this->_debugStartTime) * 1000, 1, '.', ' ') . ' ms',
630
+                number_format(($time - $this->_debugLastTime) * 1000, 1, '.', ' ') . ' ms',
631
+                number_format($usage / 1024, 1, '.', ' ') . ' Ko',
632
+                number_format($peak / 1024, 1, '.', ' ') . ' Ko'
633 633
             );
634 634
 
635 635
             $this->_debugLastTime = $time;
636 636
 
637 637
             // it false : DOWN
638
-            if ($level===false) $this->_debugLevel--;
638
+            if ($level === false) $this->_debugLevel--;
639 639
 
640 640
             return $this;
641 641
         }
@@ -653,13 +653,13 @@  discard block
 block discarded – undo
653 653
          */
654 654
         protected function _DEBUG_stepline($name, $timeTotal, $timeStep, $memoryUsage, $memoryPeak)
655 655
         {
656
-            $txt = str_pad($name, 30, ' ', STR_PAD_RIGHT).
657
-                    str_pad($timeTotal, 12, ' ', STR_PAD_LEFT).
658
-                    str_pad($timeStep, 12, ' ', STR_PAD_LEFT).
659
-                    str_pad($memoryUsage, 15, ' ', STR_PAD_LEFT).
656
+            $txt = str_pad($name, 30, ' ', STR_PAD_RIGHT) .
657
+                    str_pad($timeTotal, 12, ' ', STR_PAD_LEFT) .
658
+                    str_pad($timeStep, 12, ' ', STR_PAD_LEFT) .
659
+                    str_pad($memoryUsage, 15, ' ', STR_PAD_LEFT) .
660 660
                     str_pad($memoryPeak, 15, ' ', STR_PAD_LEFT);
661 661
 
662
-            echo '<pre style="padding:0; margin:0">'.$txt.'</pre>';
662
+            echo '<pre style="padding:0; margin:0">' . $txt . '</pre>';
663 663
         }
664 664
 
665 665
         /**
@@ -671,11 +671,11 @@  discard block
 block discarded – undo
671 671
          */
672 672
         protected function _getMargins($y)
673 673
         {
674
-            $y = floor($y*100);
675
-            $x = array($this->pdf->getlMargin(), $this->pdf->getW()-$this->pdf->getrMargin());
674
+            $y = floor($y * 100);
675
+            $x = array($this->pdf->getlMargin(), $this->pdf->getW() - $this->pdf->getrMargin());
676 676
 
677 677
             foreach ($this->_pageMarges as $mY => $mX)
678
-                if ($mY<=$y) $x = $mX;
678
+                if ($mY <= $y) $x = $mX;
679 679
 
680 680
             return $x;
681 681
         }
@@ -697,18 +697,18 @@  discard block
 block discarded – undo
697 697
             $oldBottom = $this->_getMargins($yBottom);
698 698
 
699 699
             // update the top float margin
700
-            if ($float=='left'  && $oldTop[0]<$xRight) $oldTop[0] = $xRight;
701
-            if ($float=='right' && $oldTop[1]>$xLeft)  $oldTop[1] = $xLeft;
700
+            if ($float == 'left' && $oldTop[0] < $xRight) $oldTop[0] = $xRight;
701
+            if ($float == 'right' && $oldTop[1] > $xLeft)  $oldTop[1] = $xLeft;
702 702
 
703
-            $yTop = floor($yTop*100);
704
-            $yBottom = floor($yBottom*100);
703
+            $yTop = floor($yTop * 100);
704
+            $yBottom = floor($yBottom * 100);
705 705
 
706 706
             // erase all the float margins that are smaller than the new one
707 707
             foreach ($this->_pageMarges as $mY => $mX) {
708
-                if ($mY<$yTop) continue;
709
-                if ($mY>$yBottom) break;
710
-                if ($float=='left' && $this->_pageMarges[$mY][0]<$xRight)  unset($this->_pageMarges[$mY]);
711
-                if ($float=='right' && $this->_pageMarges[$mY][1]>$xLeft) unset($this->_pageMarges[$mY]);
708
+                if ($mY < $yTop) continue;
709
+                if ($mY > $yBottom) break;
710
+                if ($float == 'left' && $this->_pageMarges[$mY][0] < $xRight)  unset($this->_pageMarges[$mY]);
711
+                if ($float == 'right' && $this->_pageMarges[$mY][1] > $xLeft) unset($this->_pageMarges[$mY]);
712 712
             }
713 713
 
714 714
             // save the new Top and Bottom margins
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 
741 741
             // prepare for float margins
742 742
             $this->_pageMarges = array();
743
-            $this->_pageMarges[floor($mt*100)] = array($ml, $this->pdf->getW()-$mr);
743
+            $this->_pageMarges[floor($mt * 100)] = array($ml, $this->pdf->getW() - $mr);
744 744
         }
745 745
 
746 746
         /**
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
                 $ml = $this->_margeLeft;
761 761
                 $mt = 0;
762 762
                 $mr = $this->_margeRight;
763
-                $mP = array($mt => array($ml, $this->pdf->getW()-$mr));
763
+                $mP = array($mt => array($ml, $this->pdf->getW() - $mr));
764 764
             }
765 765
 
766 766
             $this->pdf->SetMargins($ml, $mt, $mr);
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
             // get the margins for the current line
866 866
             list($lx, $rx) = $this->_getMargins($this->pdf->getY());
867 867
             $this->pdf->setX($lx);
868
-            $wMax = $rx-$lx;
868
+            $wMax = $rx - $lx;
869 869
             $this->_currentH = 0;
870 870
 
871 871
             // if subPart => return because align left
@@ -877,22 +877,22 @@  discard block
 block discarded – undo
877 877
             // create the sub object
878 878
             $sub = null;
879 879
             $this->_createSubHTML($sub);
880
-            $sub->_saveMargin(0, 0, $sub->pdf->getW()-$wMax);
880
+            $sub->_saveMargin(0, 0, $sub->pdf->getW() - $wMax);
881 881
             $sub->_isForOneLine = true;
882 882
             $sub->_parsePos = $this->_parsePos;
883 883
             $sub->parsingHtml->code = $this->parsingHtml->code;
884 884
 
885 885
             // if $curr => adapt the current position of the parsing
886
-            if ($curr!==null && $sub->parsingHtml->code[$this->_parsePos]['name']=='write') {
886
+            if ($curr !== null && $sub->parsingHtml->code[$this->_parsePos]['name'] == 'write') {
887 887
                 $txt = $sub->parsingHtml->code[$this->_parsePos]['param']['txt'];
888 888
                 $txt = str_replace('[[page_cu]]', $sub->pdf->getMyNumPage($this->_page), $txt);
889
-                $sub->parsingHtml->code[$this->_parsePos]['param']['txt'] = substr($txt, $curr+1);
889
+                $sub->parsingHtml->code[$this->_parsePos]['param']['txt'] = substr($txt, $curr + 1);
890 890
             } else
891 891
                 $sub->_parsePos++;
892 892
 
893 893
             // for each element of the parsing => load the action
894 894
             $res = null;
895
-            for ($sub->_parsePos; $sub->_parsePos<count($sub->parsingHtml->code); $sub->_parsePos++) {
895
+            for ($sub->_parsePos; $sub->_parsePos < count($sub->parsingHtml->code); $sub->_parsePos++) {
896 896
                 $action = $sub->parsingHtml->code[$sub->_parsePos];
897 897
                 $res = $sub->_executeAction($action);
898 898
                 if (!$res) break;
@@ -900,16 +900,16 @@  discard block
 block discarded – undo
900 900
 
901 901
             $w = $sub->_maxX; // max width
902 902
             $h = $sub->_maxH; // max height
903
-            $e = ($res===null ? $sub->_maxE : 0); // maxnumber of elemets on the line
903
+            $e = ($res === null ? $sub->_maxE : 0); // maxnumber of elemets on the line
904 904
 
905 905
             // destroy the sub HTML
906 906
             $this->_destroySubHTML($sub);
907 907
 
908 908
             // adapt the start of the line, depending on the text-align
909
-            if ($this->parsingCss->value['text-align']=='center')
910
-                $this->pdf->setX(($rx+$this->pdf->getX()-$w)*0.5-0.01);
911
-            else if ($this->parsingCss->value['text-align']=='right')
912
-                $this->pdf->setX($rx-$w-0.01);
909
+            if ($this->parsingCss->value['text-align'] == 'center')
910
+                $this->pdf->setX(($rx + $this->pdf->getX() - $w) * 0.5 - 0.01);
911
+            else if ($this->parsingCss->value['text-align'] == 'right')
912
+                $this->pdf->setX($rx - $w - 0.01);
913 913
             else
914 914
                 $this->pdf->setX($lx);
915 915
 
@@ -917,8 +917,8 @@  discard block
 block discarded – undo
917 917
             $this->_currentH = $h;
918 918
 
919 919
             // if justify => set the word spacing
920
-            if ($this->parsingCss->value['text-align']=='justify' && $e>1) {
921
-                $this->pdf->setWordSpacing(($wMax-$w)/($e-1));
920
+            if ($this->parsingCss->value['text-align'] == 'justify' && $e > 1) {
921
+                $this->pdf->setWordSpacing(($wMax - $w) / ($e - 1));
922 922
             } else {
923 923
                 $this->pdf->setWordSpacing(0);
924 924
             }
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
                                         $this->_langue,
941 941
                                         $this->_unicode,
942 942
                                         $this->_encoding,
943
-                                        array($this->_defaultLeft,$this->_defaultTop,$this->_defaultRight,$this->_defaultBottom)
943
+                                        array($this->_defaultLeft, $this->_defaultTop, $this->_defaultRight, $this->_defaultBottom)
944 944
                                     );
945 945
 
946 946
             // init
@@ -965,21 +965,21 @@  discard block
 block discarded – undo
965 965
          * @param  &HTML2PDF $subHtml sub HTML2PDF to create
966 966
          * @param  integer   $cellmargin if in a TD : cellmargin of this td
967 967
          */
968
-        protected function _createSubHTML(&$subHtml, $cellmargin=0)
968
+        protected function _createSubHTML(&$subHtml, $cellmargin = 0)
969 969
         {
970 970
             // prepare the subObject, if never prepare before
971
-            if (HTML2PDF::$_subobj===null) {
971
+            if (HTML2PDF::$_subobj === null) {
972 972
                 $this->_prepareSubObj();
973 973
             }
974 974
 
975 975
             // calculate the width to use
976 976
             if ($this->parsingCss->value['width']) {
977
-                $marge = $cellmargin*2;
978
-                $marge+= $this->parsingCss->value['padding']['l'] + $this->parsingCss->value['padding']['r'];
979
-                $marge+= $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['border']['r']['width'];
977
+                $marge = $cellmargin * 2;
978
+                $marge += $this->parsingCss->value['padding']['l'] + $this->parsingCss->value['padding']['r'];
979
+                $marge += $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['border']['r']['width'];
980 980
                 $marge = $this->pdf->getW() - $this->parsingCss->value['width'] + $marge;
981 981
             } else {
982
-                $marge = $this->_margeLeft+$this->_margeRight;
982
+                $marge = $this->_margeLeft + $this->_margeRight;
983 983
             }
984 984
 
985 985
             // BUGFIX : we have to call the method, because of a bug in php 5.1.6
@@ -1020,29 +1020,29 @@  discard block
 block discarded – undo
1020 1020
          */
1021 1021
         protected function _listeArab2Rom($nbArabic)
1022 1022
         {
1023
-            $nbBaseTen    = array('I','X','C','M');
1024
-            $nbBaseFive    = array('V','L','D');
1025
-            $nbRoman    = '';
1023
+            $nbBaseTen = array('I', 'X', 'C', 'M');
1024
+            $nbBaseFive = array('V', 'L', 'D');
1025
+            $nbRoman = '';
1026 1026
 
1027
-            if ($nbArabic<1)    return $nbArabic;
1028
-            if ($nbArabic>3999) return $nbArabic;
1027
+            if ($nbArabic < 1)    return $nbArabic;
1028
+            if ($nbArabic > 3999) return $nbArabic;
1029 1029
 
1030
-            for ($i=3; $i>=0 ; $i--) {
1031
-                $chiffre=floor($nbArabic/pow(10, $i));
1032
-                if ($chiffre>=1) {
1033
-                    $nbArabic=$nbArabic-$chiffre*pow(10, $i);
1034
-                    if ($chiffre<=3) {
1035
-                        for ($j=$chiffre; $j>=1; $j--) {
1036
-                            $nbRoman=$nbRoman.$nbBaseTen[$i];
1030
+            for ($i = 3; $i >= 0; $i--) {
1031
+                $chiffre = floor($nbArabic / pow(10, $i));
1032
+                if ($chiffre >= 1) {
1033
+                    $nbArabic = $nbArabic - $chiffre * pow(10, $i);
1034
+                    if ($chiffre <= 3) {
1035
+                        for ($j = $chiffre; $j >= 1; $j--) {
1036
+                            $nbRoman = $nbRoman . $nbBaseTen[$i];
1037 1037
                         }
1038
-                    } else if ($chiffre==9) {
1039
-                        $nbRoman=$nbRoman.$nbBaseTen[$i].$nbBaseTen[$i+1];
1040
-                    } else if ($chiffre==4) {
1041
-                    $nbRoman=$nbRoman.$nbBaseTen[$i].$nbBaseFive[$i];
1038
+                    } else if ($chiffre == 9) {
1039
+                        $nbRoman = $nbRoman . $nbBaseTen[$i] . $nbBaseTen[$i + 1];
1040
+                    } else if ($chiffre == 4) {
1041
+                    $nbRoman = $nbRoman . $nbBaseTen[$i] . $nbBaseFive[$i];
1042 1042
                     } else {
1043
-                        $nbRoman=$nbRoman.$nbBaseFive[$i];
1044
-                        for ($j=$chiffre-5; $j>=1; $j--) {
1045
-                            $nbRoman=$nbRoman.$nbBaseTen[$i];
1043
+                        $nbRoman = $nbRoman . $nbBaseFive[$i];
1044
+                        for ($j = $chiffre - 5; $j >= 1; $j--) {
1045
+                            $nbRoman = $nbRoman . $nbBaseTen[$i];
1046 1046
                         }
1047 1047
                     }
1048 1048
                 }
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
          */
1058 1058
         protected function _listeAddLi()
1059 1059
         {
1060
-            $this->_defList[count($this->_defList)-1]['nb']++;
1060
+            $this->_defList[count($this->_defList) - 1]['nb']++;
1061 1061
         }
1062 1062
 
1063 1063
         /**
@@ -1090,14 +1090,14 @@  discard block
 block discarded – undo
1090 1090
          */
1091 1091
         protected function _listeGetLi()
1092 1092
         {
1093
-            $im = $this->_defList[count($this->_defList)-1]['img'];
1094
-            $st = $this->_defList[count($this->_defList)-1]['style'];
1095
-            $nb = $this->_defList[count($this->_defList)-1]['nb'];
1096
-            $up = (substr($st, 0, 6)=='upper-');
1093
+            $im = $this->_defList[count($this->_defList) - 1]['img'];
1094
+            $st = $this->_defList[count($this->_defList) - 1]['style'];
1095
+            $nb = $this->_defList[count($this->_defList) - 1]['nb'];
1096
+            $up = (substr($st, 0, 6) == 'upper-');
1097 1097
 
1098 1098
             if ($im) return array(false, false, $im);
1099 1099
 
1100
-            switch($st)
1100
+            switch ($st)
1101 1101
             {
1102 1102
                 case 'none':
1103 1103
                     return array('helvetica', true, ' ');
@@ -1105,22 +1105,22 @@  discard block
 block discarded – undo
1105 1105
                 case 'upper-alpha':
1106 1106
                 case 'lower-alpha':
1107 1107
                     $str = '';
1108
-                    while ($nb>26) {
1109
-                        $str = chr(96+$nb%26).$str;
1110
-                        $nb = floor($nb/26);
1108
+                    while ($nb > 26) {
1109
+                        $str = chr(96 + $nb % 26) . $str;
1110
+                        $nb = floor($nb / 26);
1111 1111
                     }
1112
-                    $str = chr(96+$nb).$str;
1112
+                    $str = chr(96 + $nb) . $str;
1113 1113
 
1114
-                    return array('helvetica', false, ($up ? strtoupper($str) : $str).'.');
1114
+                    return array('helvetica', false, ($up ? strtoupper($str) : $str) . '.');
1115 1115
 
1116 1116
                 case 'upper-roman':
1117 1117
                 case 'lower-roman':
1118 1118
                     $str = $this->_listeArab2Rom($nb);
1119 1119
 
1120
-                    return array('helvetica', false, ($up ? strtoupper($str) : $str).'.');
1120
+                    return array('helvetica', false, ($up ? strtoupper($str) : $str) . '.');
1121 1121
 
1122 1122
                 case 'decimal':
1123
-                    return array('helvetica', false, $nb.'.');
1123
+                    return array('helvetica', false, $nb . '.');
1124 1124
 
1125 1125
                 case 'square':
1126 1126
                     return array('zapfdingbats', true, chr(110));
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
             if (!in_array($style, array('lower-alpha', 'upper-alpha', 'upper-roman', 'lower-roman', 'decimal', 'square', 'circle', 'disc', 'none'))) $style = '';
1161 1161
 
1162 1162
             if (!$style) {
1163
-                if ($type=='ul')    $style = 'disc';
1163
+                if ($type == 'ul')    $style = 'disc';
1164 1164
                 else                $style = 'decimal';
1165 1165
             }
1166 1166
 
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
         protected function _listeDelLevel()
1177 1177
         {
1178 1178
             if (count($this->_defList)) {
1179
-                unset($this->_defList[count($this->_defList)-1]);
1179
+                unset($this->_defList[count($this->_defList) - 1]);
1180 1180
                 $this->_defList = array_values($this->_defList);
1181 1181
             }
1182 1182
         }
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
         protected function _makeHTMLcode()
1190 1190
         {
1191 1191
             // foreach elements of the parsing
1192
-            for ($this->_parsePos=0; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) {
1192
+            for ($this->_parsePos = 0; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) {
1193 1193
 
1194 1194
                 // get the action to do
1195 1195
                 $action = $this->parsingHtml->code[$this->_parsePos];
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
                     $this->_tempPos = $this->_parsePos;
1208 1208
 
1209 1209
                     // foreach elements, while we are in the opened tag
1210
-                    while (isset($this->parsingHtml->code[$this->_tempPos]) && !($this->parsingHtml->code[$this->_tempPos]['name']==$tagOpen && $this->parsingHtml->code[$this->_tempPos]['close'])) {
1210
+                    while (isset($this->parsingHtml->code[$this->_tempPos]) && !($this->parsingHtml->code[$this->_tempPos]['name'] == $tagOpen && $this->parsingHtml->code[$this->_tempPos]['close'])) {
1211 1211
                         // make the action
1212 1212
                         $this->_executeAction($this->parsingHtml->code[$this->_tempPos]);
1213 1213
                         $this->_tempPos++;
@@ -1236,13 +1236,13 @@  discard block
 block discarded – undo
1236 1236
         protected function _executeAction($action)
1237 1237
         {
1238 1238
             // name of the action
1239
-            $fnc = ($action['close'] ? '_tag_close_' : '_tag_open_').strtoupper($action['name']);
1239
+            $fnc = ($action['close'] ? '_tag_close_' : '_tag_open_') . strtoupper($action['name']);
1240 1240
 
1241 1241
             // parameters of the action
1242 1242
             $param = $action['param'];
1243 1243
 
1244 1244
             // if it the first action of the first page, and if it is not a open tag of PAGE => create the new page
1245
-            if ($fnc!='_tag_open_PAGE' && $this->_firstPage) {
1245
+            if ($fnc != '_tag_open_PAGE' && $this->_firstPage) {
1246 1246
                 $this->_setNewPage();
1247 1247
             }
1248 1248
 
@@ -1270,10 +1270,10 @@  discard block
 block discarded – undo
1270 1270
          */
1271 1271
         protected function _getElementY($h)
1272 1272
         {
1273
-            if ($this->_subPart || $this->_isSubPart || !$this->_currentH || $this->_currentH<$h)
1273
+            if ($this->_subPart || $this->_isSubPart || !$this->_currentH || $this->_currentH < $h)
1274 1274
                 return 0;
1275 1275
 
1276
-            return ($this->_currentH-$h)*0.8;
1276
+            return ($this->_currentH - $h) * 0.8;
1277 1277
         }
1278 1278
 
1279 1279
         /**
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
         protected function _makeBreakLine($h, $curr = null)
1287 1287
         {
1288 1288
             if ($h) {
1289
-                if (($this->pdf->getY()+$h<$this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter)
1289
+                if (($this->pdf->getY() + $h < $this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter)
1290 1290
                     $this->_setNewLine($h, $curr);
1291 1291
                 else
1292 1292
                     $this->_setNewPage(null, '', null, $curr);
@@ -1306,14 +1306,14 @@  discard block
 block discarded – undo
1306 1306
          * @param  boolean $subLi if true=image of a list
1307 1307
          * @return boolean depending on "isForOneLine"
1308 1308
          */
1309
-        protected function _drawImage($src, $subLi=false)
1309
+        protected function _drawImage($src, $subLi = false)
1310 1310
         {
1311 1311
             // get the size of the image
1312 1312
             // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini
1313
-            $infos=@getimagesize($src);
1313
+            $infos = @getimagesize($src);
1314 1314
 
1315 1315
             // if the image does not exist, or can not be loaded
1316
-            if (count($infos)<2) {
1316
+            if (count($infos) < 2) {
1317 1317
                 // if the test is activ => exception
1318 1318
                 if ($this->_testIsImage) {
1319 1319
                     throw new HTML2PDF_exception(6, $src);
@@ -1325,8 +1325,8 @@  discard block
 block discarded – undo
1325 1325
             }
1326 1326
 
1327 1327
             // convert the size of the image in the unit of the PDF
1328
-            $imageWidth = $infos[0]/$this->pdf->getK();
1329
-            $imageHeight = $infos[1]/$this->pdf->getK();
1328
+            $imageWidth = $infos[0] / $this->pdf->getK();
1329
+            $imageHeight = $infos[1] / $this->pdf->getK();
1330 1330
 
1331 1331
             // calculate the size from the css style
1332 1332
             if ($this->parsingCss->value['width'] && $this->parsingCss->value['height']) {
@@ -1334,14 +1334,14 @@  discard block
 block discarded – undo
1334 1334
                 $h = $this->parsingCss->value['height'];
1335 1335
             } else if ($this->parsingCss->value['width']) {
1336 1336
                 $w = $this->parsingCss->value['width'];
1337
-                $h = $imageHeight*$w/$imageWidth;
1337
+                $h = $imageHeight * $w / $imageWidth;
1338 1338
             } else if ($this->parsingCss->value['height']) {
1339 1339
                 $h = $this->parsingCss->value['height'];
1340
-                $w = $imageWidth*$h/$imageHeight;
1340
+                $w = $imageWidth * $h / $imageHeight;
1341 1341
             } else {
1342 1342
                 // convert px to pt
1343
-                $w = 72./96.*$imageWidth;
1344
-                $h = 72./96.*$imageHeight;
1343
+                $w = 72. / 96. * $imageWidth;
1344
+                $h = 72. / 96. * $imageHeight;
1345 1345
             }
1346 1346
 
1347 1347
             // are we in a float
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
             $y = $this->pdf->getY();
1361 1361
 
1362 1362
             // if the image can not be put on the current line => new line
1363
-            if (!$float && ($x + $w>$this->pdf->getW() - $this->pdf->getrMargin()) && $this->_maxH) {
1363
+            if (!$float && ($x + $w > $this->pdf->getW() - $this->pdf->getrMargin()) && $this->_maxH) {
1364 1364
                 if ($this->_isForOneLine) {
1365 1365
                     return false;
1366 1366
                 }
@@ -1375,7 +1375,7 @@  discard block
 block discarded – undo
1375 1375
             }
1376 1376
 
1377 1377
             // if the image can not be put on the current page
1378
-            if (($y + $h>$this->pdf->getH() - $this->pdf->getbMargin()) && !$this->_isInOverflow) {
1378
+            if (($y + $h > $this->pdf->getH() - $this->pdf->getbMargin()) && !$this->_isInOverflow) {
1379 1379
                 // new page
1380 1380
                 $this->_setNewPage();
1381 1381
 
@@ -1385,17 +1385,17 @@  discard block
 block discarded – undo
1385 1385
             }
1386 1386
 
1387 1387
             // correction for display the image of a list
1388
-            $hT = 0.80*$this->parsingCss->value['font-size'];
1389
-            if ($subLi && $h<$hT) {
1390
-                $y+=($hT-$h);
1388
+            $hT = 0.80 * $this->parsingCss->value['font-size'];
1389
+            if ($subLi && $h < $hT) {
1390
+                $y += ($hT - $h);
1391 1391
             }
1392 1392
 
1393 1393
             // add the margin top
1394
-            $yc = $y-$this->parsingCss->value['margin']['t'];
1394
+            $yc = $y - $this->parsingCss->value['margin']['t'];
1395 1395
 
1396 1396
             // get the width and the position of the parent
1397 1397
             $old = $this->parsingCss->getOldValues();
1398
-            if ( $old['width']) {
1398
+            if ($old['width']) {
1399 1399
                 $parentWidth = $old['width'];
1400 1400
                 $parentX = $x;
1401 1401
             } else {
@@ -1407,12 +1407,12 @@  discard block
 block discarded – undo
1407 1407
             if ($float) {
1408 1408
                 list($lx, $rx) = $this->_getMargins($yc);
1409 1409
                 $parentX = $lx;
1410
-                $parentWidth = $rx-$lx;
1410
+                $parentWidth = $rx - $lx;
1411 1411
             }
1412 1412
 
1413 1413
             // calculate the position of the image, if align to the right
1414
-            if ($parentWidth>$w && $float!='left') {
1415
-                if ($float=='right' || $this->parsingCss->value['text-align']=='li_right')    $x = $parentX + $parentWidth - $w-$this->parsingCss->value['margin']['r']-$this->parsingCss->value['margin']['l'];
1414
+            if ($parentWidth > $w && $float != 'left') {
1415
+                if ($float == 'right' || $this->parsingCss->value['text-align'] == 'li_right')    $x = $parentX + $parentWidth - $w - $this->parsingCss->value['margin']['r'] - $this->parsingCss->value['margin']['l'];
1416 1416
             }
1417 1417
 
1418 1418
             // display the image
@@ -1427,39 +1427,39 @@  discard block
 block discarded – undo
1427 1427
             }
1428 1428
 
1429 1429
             // apply the margins
1430
-            $x-= $this->parsingCss->value['margin']['l'];
1431
-            $y-= $this->parsingCss->value['margin']['t'];
1432
-            $w+= $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['margin']['r'];
1433
-            $h+= $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['margin']['b'];
1430
+            $x -= $this->parsingCss->value['margin']['l'];
1431
+            $y -= $this->parsingCss->value['margin']['t'];
1432
+            $w += $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['margin']['r'];
1433
+            $h += $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['margin']['b'];
1434 1434
 
1435
-            if ($float=='left') {
1435
+            if ($float == 'left') {
1436 1436
                 // save the current max
1437
-                $this->_maxX = max($this->_maxX, $x+$w);
1438
-                $this->_maxY = max($this->_maxY, $y+$h);
1437
+                $this->_maxX = max($this->_maxX, $x + $w);
1438
+                $this->_maxY = max($this->_maxY, $y + $h);
1439 1439
 
1440 1440
                 // add the image to the margins
1441
-                $this->_addMargins($float, $x, $y, $x+$w, $y+$h);
1441
+                $this->_addMargins($float, $x, $y, $x + $w, $y + $h);
1442 1442
 
1443 1443
                 // get the new position
1444 1444
                 list($lx, $rx) = $this->_getMargins($yc);
1445 1445
                 $this->pdf->setXY($lx, $yc);
1446
-            } else if ($float=='right') {
1446
+            } else if ($float == 'right') {
1447 1447
                 // save the current max. We don't save the X because it is not the real max of the line
1448
-                $this->_maxY = max($this->_maxY, $y+$h);
1448
+                $this->_maxY = max($this->_maxY, $y + $h);
1449 1449
 
1450 1450
                 // add the image to the margins
1451
-                $this->_addMargins($float, $x, $y, $x+$w, $y+$h);
1451
+                $this->_addMargins($float, $x, $y, $x + $w, $y + $h);
1452 1452
 
1453 1453
                 // get the new position
1454 1454
                 list($lx, $rx) = $this->_getMargins($yc);
1455 1455
                 $this->pdf->setXY($lx, $yc);
1456 1456
             } else {
1457 1457
                 // set the new position at the end of the image
1458
-                $this->pdf->setX($x+$w);
1458
+                $this->pdf->setX($x + $w);
1459 1459
 
1460 1460
                 // save the current max
1461
-                $this->_maxX = max($this->_maxX, $x+$w);
1462
-                $this->_maxY = max($this->_maxY, $y+$h);
1461
+                $this->_maxX = max($this->_maxX, $x + $w);
1462
+                $this->_maxY = max($this->_maxY, $y + $h);
1463 1463
                 $this->_maxH = max($this->_maxH, $h);
1464 1464
             }
1465 1465
 
@@ -1483,13 +1483,13 @@  discard block
 block discarded – undo
1483 1483
         protected function _drawRectangle($x, $y, $w, $h, $border, $padding, $margin, $background)
1484 1484
         {
1485 1485
             // if we are in a subpart or if height is null => return false
1486
-            if ($this->_subPart || $this->_isSubPart || $h===null) return false;
1486
+            if ($this->_subPart || $this->_isSubPart || $h === null) return false;
1487 1487
 
1488 1488
             // add the margin
1489
-            $x+= $margin;
1490
-            $y+= $margin;
1491
-            $w-= $margin*2;
1492
-            $h-= $margin*2;
1489
+            $x += $margin;
1490
+            $y += $margin;
1491
+            $w -= $margin * 2;
1492
+            $h -= $margin * 2;
1493 1493
 
1494 1494
             // get the radius of the border
1495 1495
             $outTL = $border['radius']['tl'];
@@ -1510,32 +1510,32 @@  discard block
 block discarded – undo
1510 1510
             $inBL = $outBL;
1511 1511
 
1512 1512
             if (is_array($inTL)) {
1513
-                $inTL[0]-= $border['l']['width'];
1514
-                $inTL[1]-= $border['t']['width'];
1513
+                $inTL[0] -= $border['l']['width'];
1514
+                $inTL[1] -= $border['t']['width'];
1515 1515
             }
1516 1516
             if (is_array($inTR)) {
1517
-                $inTR[0]-= $border['r']['width'];
1518
-                $inTR[1]-= $border['t']['width'];
1517
+                $inTR[0] -= $border['r']['width'];
1518
+                $inTR[1] -= $border['t']['width'];
1519 1519
             }
1520 1520
             if (is_array($inBR)) {
1521
-                $inBR[0]-= $border['r']['width'];
1522
-                $inBR[1]-= $border['b']['width'];
1521
+                $inBR[0] -= $border['r']['width'];
1522
+                $inBR[1] -= $border['b']['width'];
1523 1523
             }
1524 1524
             if (is_array($inBL)) {
1525
-                $inBL[0]-= $border['l']['width'];
1526
-                $inBL[1]-= $border['b']['width'];
1525
+                $inBL[0] -= $border['l']['width'];
1526
+                $inBL[1] -= $border['b']['width'];
1527 1527
             }
1528 1528
 
1529
-            if ($inTL[0]<=0 || $inTL[1]<=0) $inTL = null;
1530
-            if ($inTR[0]<=0 || $inTR[1]<=0) $inTR = null;
1531
-            if ($inBR[0]<=0 || $inBR[1]<=0) $inBR = null;
1532
-            if ($inBL[0]<=0 || $inBL[1]<=0) $inBL = null;
1529
+            if ($inTL[0] <= 0 || $inTL[1] <= 0) $inTL = null;
1530
+            if ($inTR[0] <= 0 || $inTR[1] <= 0) $inTR = null;
1531
+            if ($inBR[0] <= 0 || $inBR[1] <= 0) $inBR = null;
1532
+            if ($inBL[0] <= 0 || $inBL[1] <= 0) $inBL = null;
1533 1533
 
1534 1534
             // prepare the background color
1535 1535
             $pdfStyle = '';
1536 1536
             if ($background['color']) {
1537 1537
                 $this->pdf->setFillColorArray($background['color']);
1538
-                $pdfStyle.= 'F';
1538
+                $pdfStyle .= 'F';
1539 1539
             }
1540 1540
 
1541 1541
             // if we have a background to fill => fill it with a path (because of the radius)
@@ -1548,8 +1548,8 @@  discard block
 block discarded – undo
1548 1548
             // prepare the background image
1549 1549
             if ($background['image']) {
1550 1550
                 $iName      = $background['image'];
1551
-                $iPosition  = $background['position']!==null ? $background['position'] : array(0, 0);
1552
-                $iRepeat    = $background['repeat']!==null   ? $background['repeat']   : array(true, true);
1551
+                $iPosition  = $background['position'] !== null ? $background['position'] : array(0, 0);
1552
+                $iRepeat    = $background['repeat'] !== null ? $background['repeat'] : array(true, true);
1553 1553
 
1554 1554
                 // size of the background without the borders
1555 1555
                 $bX = $x;
@@ -1558,76 +1558,76 @@  discard block
 block discarded – undo
1558 1558
                 $bH = $h;
1559 1559
 
1560 1560
                 if ($border['b']['width']) {
1561
-                    $bH-= $border['b']['width'];
1561
+                    $bH -= $border['b']['width'];
1562 1562
                 }
1563 1563
                 if ($border['l']['width']) {
1564
-                    $bW-= $border['l']['width'];
1565
-                    $bX+= $border['l']['width'];
1564
+                    $bW -= $border['l']['width'];
1565
+                    $bX += $border['l']['width'];
1566 1566
                 }
1567 1567
                 if ($border['t']['width']) {
1568
-                    $bH-= $border['t']['width'];
1569
-                    $bY+= $border['t']['width'];
1568
+                    $bH -= $border['t']['width'];
1569
+                    $bY += $border['t']['width'];
1570 1570
                 }
1571 1571
                 if ($border['r']['width']) {
1572
-                    $bW-= $border['r']['width'];
1572
+                    $bW -= $border['r']['width'];
1573 1573
                 }
1574 1574
 
1575 1575
                 // get the size of the image
1576 1576
                 // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini
1577
-                $imageInfos=@getimagesize($iName);
1577
+                $imageInfos = @getimagesize($iName);
1578 1578
 
1579 1579
                 // if the image can not be loaded
1580
-                if (count($imageInfos)<2) {
1580
+                if (count($imageInfos) < 2) {
1581 1581
                     if ($this->_testIsImage) {
1582 1582
                         throw new HTML2PDF_exception(6, $iName);
1583 1583
                     }
1584 1584
                 } else {
1585 1585
                     // convert the size of the image from pixel to the unit of the PDF
1586
-                    $imageWidth    = 72./96.*$imageInfos[0]/$this->pdf->getK();
1587
-                    $imageHeight    = 72./96.*$imageInfos[1]/$this->pdf->getK();
1586
+                    $imageWidth = 72. / 96. * $imageInfos[0] / $this->pdf->getK();
1587
+                    $imageHeight = 72. / 96. * $imageInfos[1] / $this->pdf->getK();
1588 1588
 
1589 1589
                     // prepare the position of the backgroung
1590 1590
                     if ($iRepeat[0]) $iPosition[0] = $bX;
1591
-                    else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) $iPosition[0] = $bX + $match[1]*($bW-$imageWidth)/100;
1592
-                    else $iPosition[0] = $bX+$iPosition[0];
1591
+                    else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) $iPosition[0] = $bX + $match[1] * ($bW - $imageWidth) / 100;
1592
+                    else $iPosition[0] = $bX + $iPosition[0];
1593 1593
 
1594 1594
                     if ($iRepeat[1]) $iPosition[1] = $bY;
1595
-                    else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) $iPosition[1] = $bY + $match[1]*($bH-$imageHeight)/100;
1596
-                    else $iPosition[1] = $bY+$iPosition[1];
1595
+                    else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) $iPosition[1] = $bY + $match[1] * ($bH - $imageHeight) / 100;
1596
+                    else $iPosition[1] = $bY + $iPosition[1];
1597 1597
 
1598 1598
                     $imageXmin = $bX;
1599
-                    $imageXmax = $bX+$bW;
1599
+                    $imageXmax = $bX + $bW;
1600 1600
                     $imageYmin = $bY;
1601
-                    $imageYmax = $bY+$bH;
1601
+                    $imageYmax = $bY + $bH;
1602 1602
 
1603 1603
                     if (!$iRepeat[0] && !$iRepeat[1]) {
1604
-                        $imageXmin =     $iPosition[0]; $imageXmax =     $iPosition[0]+$imageWidth;
1605
-                        $imageYmin =     $iPosition[1]; $imageYmax =     $iPosition[1]+$imageHeight;
1604
+                        $imageXmin = $iPosition[0]; $imageXmax = $iPosition[0] + $imageWidth;
1605
+                        $imageYmin = $iPosition[1]; $imageYmax = $iPosition[1] + $imageHeight;
1606 1606
                     } else if ($iRepeat[0] && !$iRepeat[1]) {
1607
-                        $imageYmin =     $iPosition[1]; $imageYmax =     $iPosition[1]+$imageHeight;
1607
+                        $imageYmin = $iPosition[1]; $imageYmax = $iPosition[1] + $imageHeight;
1608 1608
                     } else if (!$iRepeat[0] && $iRepeat[1]) {
1609
-                        $imageXmin =     $iPosition[0]; $imageXmax =     $iPosition[0]+$imageWidth;
1609
+                        $imageXmin = $iPosition[0]; $imageXmax = $iPosition[0] + $imageWidth;
1610 1610
                     }
1611 1611
 
1612 1612
                     // build the path to display the image (because of radius)
1613 1613
                     $this->pdf->clippingPathStart($bX, $bY, $bW, $bH, $inTL, $inTR, $inBL, $inBR);
1614 1614
 
1615 1615
                     // repeat the image
1616
-                    for ($iY=$imageYmin; $iY<$imageYmax; $iY+=$imageHeight) {
1617
-                        for ($iX=$imageXmin; $iX<$imageXmax; $iX+=$imageWidth) {
1616
+                    for ($iY = $imageYmin; $iY < $imageYmax; $iY += $imageHeight) {
1617
+                        for ($iX = $imageXmin; $iX < $imageXmax; $iX += $imageWidth) {
1618 1618
                             $cX = null;
1619 1619
                             $cY = null;
1620 1620
                             $cW = $imageWidth;
1621 1621
                             $cH = $imageHeight;
1622
-                            if ($imageYmax-$iY<$imageHeight) {
1622
+                            if ($imageYmax - $iY < $imageHeight) {
1623 1623
                                 $cX = $iX;
1624 1624
                                 $cY = $iY;
1625
-                                $cH = $imageYmax-$iY;
1625
+                                $cH = $imageYmax - $iY;
1626 1626
                             }
1627
-                            if ($imageXmax-$iX<$imageWidth) {
1627
+                            if ($imageXmax - $iX < $imageWidth) {
1628 1628
                                 $cX = $iX;
1629 1629
                                 $cY = $iY;
1630
-                                $cW = $imageXmax-$iX;
1630
+                                $cW = $imageXmax - $iX;
1631 1631
                             }
1632 1632
 
1633 1633
                             $this->pdf->Image($iName, $iX, $iY, $imageWidth, $imageHeight, '', '');
@@ -1641,36 +1641,36 @@  discard block
 block discarded – undo
1641 1641
 
1642 1642
             // adding some loose (0.01mm)
1643 1643
             $loose = 0.01;
1644
-            $x-= $loose;
1645
-            $y-= $loose;
1646
-            $w+= 2.*$loose;
1647
-            $h+= 2.*$loose;
1648
-            if ($border['l']['width']) $border['l']['width']+= 2.*$loose;
1649
-            if ($border['t']['width']) $border['t']['width']+= 2.*$loose;
1650
-            if ($border['r']['width']) $border['r']['width']+= 2.*$loose;
1651
-            if ($border['b']['width']) $border['b']['width']+= 2.*$loose;
1644
+            $x -= $loose;
1645
+            $y -= $loose;
1646
+            $w += 2. * $loose;
1647
+            $h += 2. * $loose;
1648
+            if ($border['l']['width']) $border['l']['width'] += 2. * $loose;
1649
+            if ($border['t']['width']) $border['t']['width'] += 2. * $loose;
1650
+            if ($border['r']['width']) $border['r']['width'] += 2. * $loose;
1651
+            if ($border['b']['width']) $border['b']['width'] += 2. * $loose;
1652 1652
 
1653 1653
             // prepare the test on borders
1654
-            $testBl = ($border['l']['width'] && $border['l']['color'][0]!==null);
1655
-            $testBt = ($border['t']['width'] && $border['t']['color'][0]!==null);
1656
-            $testBr = ($border['r']['width'] && $border['r']['color'][0]!==null);
1657
-            $testBb = ($border['b']['width'] && $border['b']['color'][0]!==null);
1654
+            $testBl = ($border['l']['width'] && $border['l']['color'][0] !== null);
1655
+            $testBt = ($border['t']['width'] && $border['t']['color'][0] !== null);
1656
+            $testBr = ($border['r']['width'] && $border['r']['color'][0] !== null);
1657
+            $testBb = ($border['b']['width'] && $border['b']['color'][0] !== null);
1658 1658
 
1659 1659
             // draw the radius bottom-left
1660 1660
             if (is_array($outBL) && ($testBb || $testBl)) {
1661 1661
                 if ($inBL) {
1662 1662
                     $courbe = array();
1663
-                    $courbe[] = $x+$outBL[0];              $courbe[] = $y+$h;
1664
-                    $courbe[] = $x;                        $courbe[] = $y+$h-$outBL[1];
1665
-                    $courbe[] = $x+$outBL[0];              $courbe[] = $y+$h-$border['b']['width'];
1666
-                    $courbe[] = $x+$border['l']['width'];  $courbe[] = $y+$h-$outBL[1];
1667
-                    $courbe[] = $x+$outBL[0];              $courbe[] = $y+$h-$outBL[1];
1663
+                    $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h;
1664
+                    $courbe[] = $x; $courbe[] = $y + $h - $outBL[1];
1665
+                    $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h - $border['b']['width'];
1666
+                    $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $h - $outBL[1];
1667
+                    $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h - $outBL[1];
1668 1668
                 } else {
1669 1669
                     $courbe = array();
1670
-                    $courbe[] = $x+$outBL[0];              $courbe[] = $y+$h;
1671
-                    $courbe[] = $x;                        $courbe[] = $y+$h-$outBL[1];
1672
-                    $courbe[] = $x+$border['l']['width'];  $courbe[] = $y+$h-$border['b']['width'];
1673
-                    $courbe[] = $x+$outBL[0];              $courbe[] = $y+$h-$outBL[1];
1670
+                    $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h;
1671
+                    $courbe[] = $x; $courbe[] = $y + $h - $outBL[1];
1672
+                    $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $h - $border['b']['width'];
1673
+                    $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h - $outBL[1];
1674 1674
                 }
1675 1675
                 $this->_drawCurve($courbe, $border['l']['color']);
1676 1676
             }
@@ -1679,17 +1679,17 @@  discard block
 block discarded – undo
1679 1679
             if (is_array($outTL) && ($testBt || $testBl)) {
1680 1680
                 if ($inTL) {
1681 1681
                     $courbe = array();
1682
-                    $courbe[] = $x;                        $courbe[] = $y+$outTL[1];
1683
-                    $courbe[] = $x+$outTL[0];              $courbe[] = $y;
1684
-                    $courbe[] = $x+$border['l']['width'];  $courbe[] = $y+$outTL[1];
1685
-                    $courbe[] = $x+$outTL[0];              $courbe[] = $y+$border['t']['width'];
1686
-                    $courbe[] = $x+$outTL[0];              $courbe[] = $y+$outTL[1];
1682
+                    $courbe[] = $x; $courbe[] = $y + $outTL[1];
1683
+                    $courbe[] = $x + $outTL[0]; $courbe[] = $y;
1684
+                    $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $outTL[1];
1685
+                    $courbe[] = $x + $outTL[0]; $courbe[] = $y + $border['t']['width'];
1686
+                    $courbe[] = $x + $outTL[0]; $courbe[] = $y + $outTL[1];
1687 1687
                 } else {
1688 1688
                     $courbe = array();
1689
-                    $courbe[] = $x;                        $courbe[] = $y+$outTL[1];
1690
-                    $courbe[] = $x+$outTL[0];              $courbe[] = $y;
1691
-                    $courbe[] = $x+$border['l']['width'];  $courbe[] = $y+$border['t']['width'];
1692
-                    $courbe[] = $x+$outTL[0];              $courbe[] = $y+$outTL[1];
1689
+                    $courbe[] = $x; $courbe[] = $y + $outTL[1];
1690
+                    $courbe[] = $x + $outTL[0]; $courbe[] = $y;
1691
+                    $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $border['t']['width'];
1692
+                    $courbe[] = $x + $outTL[0]; $courbe[] = $y + $outTL[1];
1693 1693
                 }
1694 1694
                 $this->_drawCurve($courbe, $border['t']['color']);
1695 1695
             }
@@ -1698,17 +1698,17 @@  discard block
 block discarded – undo
1698 1698
             if (is_array($outTR) && ($testBt || $testBr)) {
1699 1699
                 if ($inTR) {
1700 1700
                     $courbe = array();
1701
-                    $courbe[] = $x+$w-$outTR[0];             $courbe[] = $y;
1702
-                    $courbe[] = $x+$w;                       $courbe[] = $y+$outTR[1];
1703
-                    $courbe[] = $x+$w-$outTR[0];             $courbe[] = $y+$border['t']['width'];
1704
-                    $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$outTR[1];
1705
-                    $courbe[] = $x+$w-$outTR[0];             $courbe[] = $y+$outTR[1];
1701
+                    $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y;
1702
+                    $courbe[] = $x + $w; $courbe[] = $y + $outTR[1];
1703
+                    $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y + $border['t']['width'];
1704
+                    $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $outTR[1];
1705
+                    $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y + $outTR[1];
1706 1706
                 } else {
1707 1707
                     $courbe = array();
1708
-                    $courbe[] = $x+$w-$outTR[0];             $courbe[] = $y;
1709
-                    $courbe[] = $x+$w;                       $courbe[] = $y+$outTR[1];
1710
-                    $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$border['t']['width'];
1711
-                    $courbe[] = $x+$w-$outTR[0];             $courbe[] = $y+$outTR[1];
1708
+                    $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y;
1709
+                    $courbe[] = $x + $w; $courbe[] = $y + $outTR[1];
1710
+                    $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $border['t']['width'];
1711
+                    $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y + $outTR[1];
1712 1712
                 }
1713 1713
                 $this->_drawCurve($courbe, $border['r']['color']);
1714 1714
             }
@@ -1717,17 +1717,17 @@  discard block
 block discarded – undo
1717 1717
             if (is_array($outBR) && ($testBb || $testBr)) {
1718 1718
                 if ($inBR) {
1719 1719
                     $courbe = array();
1720
-                    $courbe[] = $x+$w;                       $courbe[] = $y+$h-$outBR[1];
1721
-                    $courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h;
1722
-                    $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$h-$outBR[1];
1723
-                    $courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h-$border['b']['width'];
1724
-                    $courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h-$outBR[1];
1720
+                    $courbe[] = $x + $w; $courbe[] = $y + $h - $outBR[1];
1721
+                    $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h;
1722
+                    $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $h - $outBR[1];
1723
+                    $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h - $border['b']['width'];
1724
+                    $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h - $outBR[1];
1725 1725
                 } else {
1726 1726
                     $courbe = array();
1727
-                    $courbe[] = $x+$w;                       $courbe[] = $y+$h-$outBR[1];
1728
-                    $courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h;
1729
-                    $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$h-$border['b']['width'];
1730
-                    $courbe[] = $x+$w-$outBR[0];             $courbe[] = $y+$h-$outBR[1];
1727
+                    $courbe[] = $x + $w; $courbe[] = $y + $h - $outBR[1];
1728
+                    $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h;
1729
+                    $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $h - $border['b']['width'];
1730
+                    $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h - $outBR[1];
1731 1731
                 }
1732 1732
                 $this->_drawCurve($courbe, $border['b']['color']);
1733 1733
             }
@@ -1735,25 +1735,25 @@  discard block
 block discarded – undo
1735 1735
             // draw the left border
1736 1736
             if ($testBl) {
1737 1737
                 $pt = array();
1738
-                $pt[] = $x;                       $pt[] = $y+$h;
1739
-                $pt[] = $x;                       $pt[] = $y+$h-$border['b']['width'];
1740
-                $pt[] = $x;                       $pt[] = $y+$border['t']['width'];
1741
-                $pt[] = $x;                       $pt[] = $y;
1742
-                $pt[] = $x+$border['l']['width']; $pt[] = $y+$border['t']['width'];
1743
-                $pt[] = $x+$border['l']['width']; $pt[] = $y+$h-$border['b']['width'];
1738
+                $pt[] = $x; $pt[] = $y + $h;
1739
+                $pt[] = $x; $pt[] = $y + $h - $border['b']['width'];
1740
+                $pt[] = $x; $pt[] = $y + $border['t']['width'];
1741
+                $pt[] = $x; $pt[] = $y;
1742
+                $pt[] = $x + $border['l']['width']; $pt[] = $y + $border['t']['width'];
1743
+                $pt[] = $x + $border['l']['width']; $pt[] = $y + $h - $border['b']['width'];
1744 1744
 
1745 1745
                 $bord = 3;
1746 1746
                 if (is_array($outBL)) {
1747
-                    $bord-=1;
1747
+                    $bord -= 1;
1748 1748
                     $pt[3] -= $outBL[1] - $border['b']['width'];
1749
-                    if ($inBL) $pt[11]-= $inBL[1];
1750
-                    unset($pt[0]);unset($pt[1]);
1749
+                    if ($inBL) $pt[11] -= $inBL[1];
1750
+                    unset($pt[0]); unset($pt[1]);
1751 1751
                 }
1752 1752
                 if (is_array($outTL)) {
1753
-                    $bord-=2;
1754
-                    $pt[5] += $outTL[1]-$border['t']['width'];
1753
+                    $bord -= 2;
1754
+                    $pt[5] += $outTL[1] - $border['t']['width'];
1755 1755
                     if ($inTL) $pt[9] += $inTL[1];
1756
-                    unset($pt[6]);unset($pt[7]);
1756
+                    unset($pt[6]); unset($pt[7]);
1757 1757
                 }
1758 1758
 
1759 1759
                 $pt = array_values($pt);
@@ -1763,25 +1763,25 @@  discard block
 block discarded – undo
1763 1763
             // draw the top border
1764 1764
             if ($testBt) {
1765 1765
                 $pt = array();
1766
-                $pt[] = $x;                          $pt[] = $y;
1767
-                $pt[] = $x+$border['l']['width'];    $pt[] = $y;
1768
-                $pt[] = $x+$w-$border['r']['width']; $pt[] = $y;
1769
-                $pt[] = $x+$w;                       $pt[] = $y;
1770
-                $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$border['t']['width'];
1771
-                $pt[] = $x+$border['l']['width'];    $pt[] = $y+$border['t']['width'];
1766
+                $pt[] = $x; $pt[] = $y;
1767
+                $pt[] = $x + $border['l']['width']; $pt[] = $y;
1768
+                $pt[] = $x + $w - $border['r']['width']; $pt[] = $y;
1769
+                $pt[] = $x + $w; $pt[] = $y;
1770
+                $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $border['t']['width'];
1771
+                $pt[] = $x + $border['l']['width']; $pt[] = $y + $border['t']['width'];
1772 1772
 
1773 1773
                 $bord = 3;
1774 1774
                 if (is_array($outTL)) {
1775
-                    $bord-=1;
1775
+                    $bord -= 1;
1776 1776
                     $pt[2] += $outTL[0] - $border['l']['width'];
1777
-                    if ($inTL) $pt[10]+= $inTL[0];
1778
-                    unset($pt[0]);unset($pt[1]);
1777
+                    if ($inTL) $pt[10] += $inTL[0];
1778
+                    unset($pt[0]); unset($pt[1]);
1779 1779
                 }
1780 1780
                 if (is_array($outTR)) {
1781
-                    $bord-=2;
1781
+                    $bord -= 2;
1782 1782
                     $pt[4] -= $outTR[0] - $border['r']['width'];
1783 1783
                     if ($inTR) $pt[8] -= $inTR[0];
1784
-                    unset($pt[6]);unset($pt[7]);
1784
+                    unset($pt[6]); unset($pt[7]);
1785 1785
                 }
1786 1786
 
1787 1787
                 $pt = array_values($pt);
@@ -1791,25 +1791,25 @@  discard block
 block discarded – undo
1791 1791
             // draw the right border
1792 1792
             if ($testBr) {
1793 1793
                 $pt = array();
1794
-                $pt[] = $x+$w;                       $pt[] = $y;
1795
-                $pt[] = $x+$w;                       $pt[] = $y+$border['t']['width'];
1796
-                $pt[] = $x+$w;                       $pt[] = $y+$h-$border['b']['width'];
1797
-                $pt[] = $x+$w;                       $pt[] = $y+$h;
1798
-                $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h-$border['b']['width'];
1799
-                $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$border['t']['width'];
1794
+                $pt[] = $x + $w; $pt[] = $y;
1795
+                $pt[] = $x + $w; $pt[] = $y + $border['t']['width'];
1796
+                $pt[] = $x + $w; $pt[] = $y + $h - $border['b']['width'];
1797
+                $pt[] = $x + $w; $pt[] = $y + $h;
1798
+                $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $h - $border['b']['width'];
1799
+                $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $border['t']['width'];
1800 1800
 
1801 1801
                 $bord = 3;
1802 1802
                 if (is_array($outTR)) {
1803
-                    $bord-=1;
1803
+                    $bord -= 1;
1804 1804
                     $pt[3] += $outTR[1] - $border['t']['width'];
1805
-                    if ($inTR) $pt[11]+= $inTR[1];
1806
-                    unset($pt[0]);unset($pt[1]);
1805
+                    if ($inTR) $pt[11] += $inTR[1];
1806
+                    unset($pt[0]); unset($pt[1]);
1807 1807
                 }
1808 1808
                 if (is_array($outBR)) {
1809
-                    $bord-=2;
1809
+                    $bord -= 2;
1810 1810
                     $pt[5] -= $outBR[1] - $border['b']['width'];
1811 1811
                     if ($inBR) $pt[9] -= $inBR[1];
1812
-                    unset($pt[6]);unset($pt[7]);
1812
+                    unset($pt[6]); unset($pt[7]);
1813 1813
                 }
1814 1814
 
1815 1815
                 $pt = array_values($pt);
@@ -1819,25 +1819,25 @@  discard block
 block discarded – undo
1819 1819
             // draw the bottom border
1820 1820
             if ($testBb) {
1821 1821
                 $pt = array();
1822
-                $pt[] = $x+$w;                       $pt[] = $y+$h;
1823
-                $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h;
1824
-                $pt[] = $x+$border['l']['width'];    $pt[] = $y+$h;
1825
-                $pt[] = $x;                          $pt[] = $y+$h;
1826
-                $pt[] = $x+$border['l']['width'];    $pt[] = $y+$h-$border['b']['width'];
1827
-                $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h-$border['b']['width'];
1822
+                $pt[] = $x + $w; $pt[] = $y + $h;
1823
+                $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $h;
1824
+                $pt[] = $x + $border['l']['width']; $pt[] = $y + $h;
1825
+                $pt[] = $x; $pt[] = $y + $h;
1826
+                $pt[] = $x + $border['l']['width']; $pt[] = $y + $h - $border['b']['width'];
1827
+                $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $h - $border['b']['width'];
1828 1828
 
1829 1829
                 $bord = 3;
1830 1830
                 if (is_array($outBL)) {
1831
-                    $bord-=2;
1831
+                    $bord -= 2;
1832 1832
                     $pt[4] += $outBL[0] - $border['l']['width'];
1833 1833
                     if ($inBL) $pt[8] += $inBL[0];
1834
-                    unset($pt[6]);unset($pt[7]);
1834
+                    unset($pt[6]); unset($pt[7]);
1835 1835
                 }
1836 1836
                 if (is_array($outBR)) {
1837
-                    $bord-=1;
1837
+                    $bord -= 1;
1838 1838
                     $pt[2] -= $outBR[0] - $border['r']['width'];
1839
-                    if ($inBR) $pt[10]-= $inBR[0];
1840
-                    unset($pt[0]);unset($pt[1]);
1839
+                    if ($inBR) $pt[10] -= $inBR[0];
1840
+                    unset($pt[0]); unset($pt[1]);
1841 1841
 
1842 1842
                 }
1843 1843
 
@@ -1863,7 +1863,7 @@  discard block
 block discarded – undo
1863 1863
         {
1864 1864
             $this->pdf->setFillColorArray($color);
1865 1865
 
1866
-            if (count($pt)==10)
1866
+            if (count($pt) == 10)
1867 1867
                 $this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]);
1868 1868
             else
1869 1869
                 $this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]);
@@ -1879,128 +1879,128 @@  discard block
 block discarded – undo
1879 1879
          * @param  float   $width
1880 1880
          * @param  integer $radius (binary from 0 to 3 with 1=>start with a radius, 2=>end with a radius)
1881 1881
          */
1882
-        protected function _drawLine($pt, $color, $type, $width, $radius=3)
1882
+        protected function _drawLine($pt, $color, $type, $width, $radius = 3)
1883 1883
         {
1884 1884
             // set the fill color
1885 1885
             $this->pdf->setFillColorArray($color);
1886 1886
 
1887 1887
             // if dashed or dotted
1888
-            if ($type=='dashed' || $type=='dotted') {
1888
+            if ($type == 'dashed' || $type == 'dotted') {
1889 1889
 
1890 1890
                 // clean the end of the line, if radius
1891
-                if ($radius==1) {
1892
-                    $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
1891
+                if ($radius == 1) {
1892
+                    $tmp = array(); $tmp[] = $pt[0]; $tmp[] = $pt[1]; $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[8]; $tmp[] = $pt[9];
1893 1893
                     $this->pdf->Polygon($tmp, 'F');
1894 1894
 
1895
-                    $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
1895
+                    $tmp = array(); $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; $tmp[] = $pt[8]; $tmp[] = $pt[9];
1896 1896
                     $pt = $tmp;
1897
-                } else if ($radius==2) {
1898
-                    $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7];
1897
+                } else if ($radius == 2) {
1898
+                    $tmp = array(); $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[6]; $tmp[] = $pt[7];
1899 1899
                     $this->pdf->Polygon($tmp, 'F');
1900 1900
 
1901
-                    $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
1901
+                    $tmp = array(); $tmp[] = $pt[0]; $tmp[] = $pt[1]; $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; $tmp[] = $pt[8]; $tmp[] = $pt[9];
1902 1902
                     $pt = $tmp;
1903
-                } else if ($radius==3) {
1904
-                    $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[10]; $tmp[]=$pt[11];
1903
+                } else if ($radius == 3) {
1904
+                    $tmp = array(); $tmp[] = $pt[0]; $tmp[] = $pt[1]; $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[10]; $tmp[] = $pt[11];
1905 1905
                     $this->pdf->Polygon($tmp, 'F');
1906 1906
 
1907
-                    $tmp = array(); $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
1907
+                    $tmp = array(); $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; $tmp[] = $pt[8]; $tmp[] = $pt[9];
1908 1908
                     $this->pdf->Polygon($tmp, 'F');
1909 1909
 
1910
-                    $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[8]; $tmp[]=$pt[9]; $tmp[]=$pt[10]; $tmp[]=$pt[11];
1910
+                    $tmp = array(); $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; $tmp[] = $pt[10]; $tmp[] = $pt[11];
1911 1911
                     $pt = $tmp;
1912 1912
                 }
1913 1913
 
1914 1914
                 // horisontal or vertical line
1915
-                if ($pt[2]==$pt[0]) {
1916
-                    $l = abs(($pt[3]-$pt[1])*0.5);
1915
+                if ($pt[2] == $pt[0]) {
1916
+                    $l = abs(($pt[3] - $pt[1]) * 0.5);
1917 1917
                     $px = 0;
1918 1918
                     $py = $width;
1919
-                    $x1 = $pt[0]; $y1 = ($pt[3]+$pt[1])*0.5;
1920
-                    $x2 = $pt[6]; $y2 = ($pt[7]+$pt[5])*0.5;
1919
+                    $x1 = $pt[0]; $y1 = ($pt[3] + $pt[1]) * 0.5;
1920
+                    $x2 = $pt[6]; $y2 = ($pt[7] + $pt[5]) * 0.5;
1921 1921
                 } else {
1922
-                    $l = abs(($pt[2]-$pt[0])*0.5);
1922
+                    $l = abs(($pt[2] - $pt[0]) * 0.5);
1923 1923
                     $px = $width;
1924 1924
                     $py = 0;
1925
-                    $x1 = ($pt[2]+$pt[0])*0.5; $y1 = $pt[1];
1926
-                    $x2 = ($pt[6]+$pt[4])*0.5; $y2 = $pt[7];
1925
+                    $x1 = ($pt[2] + $pt[0]) * 0.5; $y1 = $pt[1];
1926
+                    $x2 = ($pt[6] + $pt[4]) * 0.5; $y2 = $pt[7];
1927 1927
                 }
1928 1928
 
1929 1929
                 // if dashed : 3x bigger than dotted
1930
-                if ($type=='dashed') {
1931
-                    $px = $px*3.;
1932
-                    $py = $py*3.;
1930
+                if ($type == 'dashed') {
1931
+                    $px = $px * 3.;
1932
+                    $py = $py * 3.;
1933 1933
                 }
1934
-                $mode = ($l/($px+$py)<.5);
1934
+                $mode = ($l / ($px + $py) < .5);
1935 1935
 
1936 1936
                 // display the dotted/dashed line
1937
-                for ($i=0; $l-($px+$py)*($i-0.5)>0; $i++) {
1938
-                    if (($i%2)==$mode) {
1939
-                        $j = $i-0.5;
1940
-                        $lx1 = $px*($j);   if ($lx1<-$l) $lx1 =-$l;
1941
-                        $ly1 = $py*($j);   if ($ly1<-$l) $ly1 =-$l;
1942
-                        $lx2 = $px*($j+1); if ($lx2>$l)  $lx2 = $l;
1943
-                        $ly2 = $py*($j+1); if ($ly2>$l)  $ly2 = $l;
1937
+                for ($i = 0; $l - ($px + $py) * ($i - 0.5) > 0; $i++) {
1938
+                    if (($i % 2) == $mode) {
1939
+                        $j = $i - 0.5;
1940
+                        $lx1 = $px * ($j); if ($lx1 < -$l) $lx1 = -$l;
1941
+                        $ly1 = $py * ($j); if ($ly1 < -$l) $ly1 = -$l;
1942
+                        $lx2 = $px * ($j + 1); if ($lx2 > $l)  $lx2 = $l;
1943
+                        $ly2 = $py * ($j + 1); if ($ly2 > $l)  $ly2 = $l;
1944 1944
 
1945 1945
                         $tmp = array();
1946
-                        $tmp[] = $x1+$lx1; $tmp[] = $y1+$ly1;
1947
-                        $tmp[] = $x1+$lx2; $tmp[] = $y1+$ly2;
1948
-                        $tmp[] = $x2+$lx2; $tmp[] = $y2+$ly2;
1949
-                        $tmp[] = $x2+$lx1; $tmp[] = $y2+$ly1;
1946
+                        $tmp[] = $x1 + $lx1; $tmp[] = $y1 + $ly1;
1947
+                        $tmp[] = $x1 + $lx2; $tmp[] = $y1 + $ly2;
1948
+                        $tmp[] = $x2 + $lx2; $tmp[] = $y2 + $ly2;
1949
+                        $tmp[] = $x2 + $lx1; $tmp[] = $y2 + $ly1;
1950 1950
                         $this->pdf->Polygon($tmp, 'F');
1951 1951
 
1952
-                        if ($j>0) {
1952
+                        if ($j > 0) {
1953 1953
                             $tmp = array();
1954
-                            $tmp[] = $x1-$lx1; $tmp[] = $y1-$ly1;
1955
-                            $tmp[] = $x1-$lx2; $tmp[] = $y1-$ly2;
1956
-                            $tmp[] = $x2-$lx2; $tmp[] = $y2-$ly2;
1957
-                            $tmp[] = $x2-$lx1; $tmp[] = $y2-$ly1;
1954
+                            $tmp[] = $x1 - $lx1; $tmp[] = $y1 - $ly1;
1955
+                            $tmp[] = $x1 - $lx2; $tmp[] = $y1 - $ly2;
1956
+                            $tmp[] = $x2 - $lx2; $tmp[] = $y2 - $ly2;
1957
+                            $tmp[] = $x2 - $lx1; $tmp[] = $y2 - $ly1;
1958 1958
                             $this->pdf->Polygon($tmp, 'F');
1959 1959
                         }
1960 1960
                     }
1961 1961
                 }
1962
-            } else if ($type=='double') {
1962
+            } else if ($type == 'double') {
1963 1963
 
1964 1964
                 // if double, 2 lines : 0=>1/3 and 2/3=>1
1965 1965
                 $pt1 = $pt;
1966 1966
                 $pt2 = $pt;
1967 1967
 
1968
-                if (count($pt)==12) {
1968
+                if (count($pt) == 12) {
1969 1969
                     // line 1
1970
-                    $pt1[0] = ($pt[0]-$pt[10])*0.33 + $pt[10];
1971
-                    $pt1[1] = ($pt[1]-$pt[11])*0.33 + $pt[11];
1972
-                    $pt1[2] = ($pt[2]-$pt[10])*0.33 + $pt[10];
1973
-                    $pt1[3] = ($pt[3]-$pt[11])*0.33 + $pt[11];
1974
-                    $pt1[4] = ($pt[4]-$pt[8])*0.33 + $pt[8];
1975
-                    $pt1[5] = ($pt[5]-$pt[9])*0.33 + $pt[9];
1976
-                    $pt1[6] = ($pt[6]-$pt[8])*0.33 + $pt[8];
1977
-                    $pt1[7] = ($pt[7]-$pt[9])*0.33 + $pt[9];
1978
-                    $pt2[10]= ($pt[10]-$pt[0])*0.33 + $pt[0];
1979
-                    $pt2[11]= ($pt[11]-$pt[1])*0.33 + $pt[1];
1970
+                    $pt1[0] = ($pt[0] - $pt[10]) * 0.33 + $pt[10];
1971
+                    $pt1[1] = ($pt[1] - $pt[11]) * 0.33 + $pt[11];
1972
+                    $pt1[2] = ($pt[2] - $pt[10]) * 0.33 + $pt[10];
1973
+                    $pt1[3] = ($pt[3] - $pt[11]) * 0.33 + $pt[11];
1974
+                    $pt1[4] = ($pt[4] - $pt[8]) * 0.33 + $pt[8];
1975
+                    $pt1[5] = ($pt[5] - $pt[9]) * 0.33 + $pt[9];
1976
+                    $pt1[6] = ($pt[6] - $pt[8]) * 0.33 + $pt[8];
1977
+                    $pt1[7] = ($pt[7] - $pt[9]) * 0.33 + $pt[9];
1978
+                    $pt2[10] = ($pt[10] - $pt[0]) * 0.33 + $pt[0];
1979
+                    $pt2[11] = ($pt[11] - $pt[1]) * 0.33 + $pt[1];
1980 1980
 
1981 1981
                     // line 2
1982
-                    $pt2[2] = ($pt[2] -$pt[0])*0.33 + $pt[0];
1983
-                    $pt2[3] = ($pt[3] -$pt[1])*0.33 + $pt[1];
1984
-                    $pt2[4] = ($pt[4] -$pt[6])*0.33 + $pt[6];
1985
-                    $pt2[5] = ($pt[5] -$pt[7])*0.33 + $pt[7];
1986
-                    $pt2[8] = ($pt[8] -$pt[6])*0.33 + $pt[6];
1987
-                    $pt2[9] = ($pt[9] -$pt[7])*0.33 + $pt[7];
1982
+                    $pt2[2] = ($pt[2] - $pt[0]) * 0.33 + $pt[0];
1983
+                    $pt2[3] = ($pt[3] - $pt[1]) * 0.33 + $pt[1];
1984
+                    $pt2[4] = ($pt[4] - $pt[6]) * 0.33 + $pt[6];
1985
+                    $pt2[5] = ($pt[5] - $pt[7]) * 0.33 + $pt[7];
1986
+                    $pt2[8] = ($pt[8] - $pt[6]) * 0.33 + $pt[6];
1987
+                    $pt2[9] = ($pt[9] - $pt[7]) * 0.33 + $pt[7];
1988 1988
                 } else {
1989 1989
                     // line 1
1990
-                    $pt1[0] = ($pt[0]-$pt[6])*0.33 + $pt[6];
1991
-                    $pt1[1] = ($pt[1]-$pt[7])*0.33 + $pt[7];
1992
-                    $pt1[2] = ($pt[2]-$pt[4])*0.33 + $pt[4];
1993
-                    $pt1[3] = ($pt[3]-$pt[5])*0.33 + $pt[5];
1990
+                    $pt1[0] = ($pt[0] - $pt[6]) * 0.33 + $pt[6];
1991
+                    $pt1[1] = ($pt[1] - $pt[7]) * 0.33 + $pt[7];
1992
+                    $pt1[2] = ($pt[2] - $pt[4]) * 0.33 + $pt[4];
1993
+                    $pt1[3] = ($pt[3] - $pt[5]) * 0.33 + $pt[5];
1994 1994
 
1995 1995
                     // line 2
1996
-                    $pt2[6] = ($pt[6]-$pt[0])*0.33 + $pt[0];
1997
-                    $pt2[7] = ($pt[7]-$pt[1])*0.33 + $pt[1];
1998
-                    $pt2[4] = ($pt[4]-$pt[2])*0.33 + $pt[2];
1999
-                    $pt2[5] = ($pt[5]-$pt[3])*0.33 + $pt[3];
1996
+                    $pt2[6] = ($pt[6] - $pt[0]) * 0.33 + $pt[0];
1997
+                    $pt2[7] = ($pt[7] - $pt[1]) * 0.33 + $pt[1];
1998
+                    $pt2[4] = ($pt[4] - $pt[2]) * 0.33 + $pt[2];
1999
+                    $pt2[5] = ($pt[5] - $pt[3]) * 0.33 + $pt[3];
2000 2000
                 }
2001 2001
                 $this->pdf->Polygon($pt1, 'F');
2002 2002
                 $this->pdf->Polygon($pt2, 'F');
2003
-            } else if ($type=='solid') {
2003
+            } else if ($type == 'solid') {
2004 2004
                 // solid line : draw directly the polygon
2005 2005
                 $this->pdf->Polygon($pt, 'F');
2006 2006
             }
@@ -2025,7 +2025,7 @@  discard block
 block discarded – undo
2025 2025
             $actions = array();
2026 2026
 
2027 2027
             // for actions
2028
-            for ($k=0; $k<count($match[0]); $k++) {
2028
+            for ($k = 0; $k < count($match[0]); $k++) {
2029 2029
 
2030 2030
                 // get the name of the action
2031 2031
                 $name = strtolower($match[1][$k]);
@@ -2037,46 +2037,46 @@  discard block
 block discarded – undo
2037 2037
                 }
2038 2038
 
2039 2039
                 // prepare the matrix, depending on the action
2040
-                switch($name)
2040
+                switch ($name)
2041 2041
                 {
2042 2042
                     case 'scale':
2043
-                        if (!isset($val[0])) $val[0] = 1.;      else $val[0] = 1.*$val[0];
2044
-                        if (!isset($val[1])) $val[1] = $val[0]; else $val[1] = 1.*$val[1];
2045
-                        $actions[] = array($val[0],0,0,$val[1],0,0);
2043
+                        if (!isset($val[0])) $val[0] = 1.; else $val[0] = 1. * $val[0];
2044
+                        if (!isset($val[1])) $val[1] = $val[0]; else $val[1] = 1. * $val[1];
2045
+                        $actions[] = array($val[0], 0, 0, $val[1], 0, 0);
2046 2046
                         break;
2047 2047
 
2048 2048
                     case 'translate':
2049 2049
                         if (!isset($val[0])) $val[0] = 0.; else $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']);
2050 2050
                         if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']);
2051
-                        $actions[] = array(1,0,0,1,$val[0],$val[1]);
2051
+                        $actions[] = array(1, 0, 0, 1, $val[0], $val[1]);
2052 2052
                         break;
2053 2053
 
2054 2054
                     case 'rotate':
2055
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.;
2055
+                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.;
2056 2056
                         if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']);
2057 2057
                         if (!isset($val[2])) $val[2] = 0.; else $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']);
2058
-                        if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,-$val[1],-$val[2]);
2059
-                        $actions[] = array(cos($val[0]),sin($val[0]),-sin($val[0]),cos($val[0]),0,0);
2060
-                        if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,$val[1],$val[2]);
2058
+                        if ($val[1] || $val[2]) $actions[] = array(1, 0, 0, 1, -$val[1], -$val[2]);
2059
+                        $actions[] = array(cos($val[0]), sin($val[0]), -sin($val[0]), cos($val[0]), 0, 0);
2060
+                        if ($val[1] || $val[2]) $actions[] = array(1, 0, 0, 1, $val[1], $val[2]);
2061 2061
                         break;
2062 2062
 
2063 2063
                     case 'skewx':
2064
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.;
2065
-                        $actions[] = array(1,0,tan($val[0]),1,0,0);
2064
+                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.;
2065
+                        $actions[] = array(1, 0, tan($val[0]), 1, 0, 0);
2066 2066
                         break;
2067 2067
 
2068 2068
                     case 'skewy':
2069
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.;
2070
-                        $actions[] = array(1,tan($val[0]),0,1,0,0);
2069
+                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.;
2070
+                        $actions[] = array(1, tan($val[0]), 0, 1, 0, 0);
2071 2071
                         break;
2072 2072
                     case 'matrix':
2073
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*1.;
2074
-                        if (!isset($val[1])) $val[1] = 0.; else $val[1] = $val[1]*1.;
2075
-                        if (!isset($val[2])) $val[2] = 0.; else $val[2] = $val[2]*1.;
2076
-                        if (!isset($val[3])) $val[3] = 0.; else $val[3] = $val[3]*1.;
2073
+                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * 1.;
2074
+                        if (!isset($val[1])) $val[1] = 0.; else $val[1] = $val[1] * 1.;
2075
+                        if (!isset($val[2])) $val[2] = 0.; else $val[2] = $val[2] * 1.;
2076
+                        if (!isset($val[3])) $val[3] = 0.; else $val[3] = $val[3] * 1.;
2077 2077
                         if (!isset($val[4])) $val[4] = 0.; else $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']);
2078 2078
                         if (!isset($val[5])) $val[5] = 0.; else $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']);
2079
-                        $actions[] =$val;
2079
+                        $actions[] = $val;
2080 2080
                         break;
2081 2081
                 }
2082 2082
             }
@@ -2090,12 +2090,12 @@  discard block
 block discarded – undo
2090 2090
             // foreach matrix => multiply to the last matrix
2091 2091
             foreach ($actions as $n) {
2092 2092
                 $m = array(
2093
-                    $m[0]*$n[0]+$m[2]*$n[1],
2094
-                    $m[1]*$n[0]+$m[3]*$n[1],
2095
-                    $m[0]*$n[2]+$m[2]*$n[3],
2096
-                    $m[1]*$n[2]+$m[3]*$n[3],
2097
-                    $m[0]*$n[4]+$m[2]*$n[5]+$m[4],
2098
-                    $m[1]*$n[4]+$m[3]*$n[5]+$m[5]
2093
+                    $m[0] * $n[0] + $m[2] * $n[1],
2094
+                    $m[1] * $n[0] + $m[3] * $n[1],
2095
+                    $m[0] * $n[2] + $m[2] * $n[3],
2096
+                    $m[1] * $n[2] + $m[3] * $n[3],
2097
+                    $m[0] * $n[4] + $m[2] * $n[5] + $m[4],
2098
+                    $m[1] * $n[4] + $m[3] * $n[5] + $m[5]
2099 2099
                 );
2100 2100
             }
2101 2101
 
@@ -2114,10 +2114,10 @@  discard block
 block discarded – undo
2114 2114
 
2115 2115
             // for each cell without colspan, we get the max width for each column
2116 2116
             $sw = array();
2117
-            for ($x=0; $x<count($corr[0]); $x++) {
2118
-                $m=0;
2119
-                for ($y=0; $y<count($corr); $y++) {
2120
-                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]==1) {
2117
+            for ($x = 0; $x < count($corr[0]); $x++) {
2118
+                $m = 0;
2119
+                for ($y = 0; $y < count($corr); $y++) {
2120
+                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2] == 1) {
2121 2121
                         $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']);
2122 2122
                     }
2123 2123
                 }
@@ -2125,17 +2125,17 @@  discard block
 block discarded – undo
2125 2125
             }
2126 2126
 
2127 2127
             // for each cell with colspan, we adapt the width of each column
2128
-            for ($x=0; $x<count($corr[0]); $x++) {
2129
-                for ($y=0; $y<count($corr); $y++) {
2130
-                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]>1) {
2128
+            for ($x = 0; $x < count($corr[0]); $x++) {
2129
+                for ($y = 0; $y < count($corr); $y++) {
2130
+                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2] > 1) {
2131 2131
 
2132 2132
                         // sum the max width of each column in colspan
2133
-                        $s = 0; for ($i=0; $i<$corr[$y][$x][2]; $i++) $s+= $sw[$x+$i];
2133
+                        $s = 0; for ($i = 0; $i < $corr[$y][$x][2]; $i++) $s += $sw[$x + $i];
2134 2134
 
2135 2135
                         // if the max width is < the width of the cell with colspan => we adapt the width of each max width
2136
-                        if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']) {
2137
-                            for ($i=0; $i<$corr[$y][$x][2]; $i++) {
2138
-                                $sw[$x+$i] = $sw[$x+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
2136
+                        if ($s > 0 && $s < $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']) {
2137
+                            for ($i = 0; $i < $corr[$y][$x][2]; $i++) {
2138
+                                $sw[$x + $i] = $sw[$x + $i] / $s * $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
2139 2139
                             }
2140 2140
                         }
2141 2141
                     }
@@ -2143,17 +2143,17 @@  discard block
 block discarded – undo
2143 2143
             }
2144 2144
 
2145 2145
             // set the new width, for each cell
2146
-            for ($x=0; $x<count($corr[0]); $x++) {
2147
-                for ($y=0; $y<count($corr); $y++) {
2146
+            for ($x = 0; $x < count($corr[0]); $x++) {
2147
+                for ($y = 0; $y < count($corr); $y++) {
2148 2148
                     if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) {
2149 2149
                         // without colspan
2150
-                        if ($corr[$y][$x][2]==1) {
2150
+                        if ($corr[$y][$x][2] == 1) {
2151 2151
                             $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $sw[$x];
2152 2152
                         // with colspan
2153 2153
                         } else {
2154 2154
                             $s = 0;
2155
-                            for ($i=0; $i<$corr[$y][$x][2]; $i++) {
2156
-                                $s+= $sw[$x+$i];
2155
+                            for ($i = 0; $i < $corr[$y][$x][2]; $i++) {
2156
+                                $s += $sw[$x + $i];
2157 2157
                             }
2158 2158
                             $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $s;
2159 2159
                         }
@@ -2163,10 +2163,10 @@  discard block
 block discarded – undo
2163 2163
 
2164 2164
             // for each cell without rowspan, we get the max height for each line
2165 2165
             $sh = array();
2166
-            for ($y=0; $y<count($corr); $y++) {
2167
-                $m=0;
2168
-                for ($x=0; $x<count($corr[0]); $x++) {
2169
-                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]==1) {
2166
+            for ($y = 0; $y < count($corr); $y++) {
2167
+                $m = 0;
2168
+                for ($x = 0; $x < count($corr[0]); $x++) {
2169
+                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3] == 1) {
2170 2170
                         $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']);
2171 2171
                     }
2172 2172
                 }
@@ -2174,17 +2174,17 @@  discard block
 block discarded – undo
2174 2174
             }
2175 2175
 
2176 2176
             // for each cell with rowspan, we adapt the height of each line
2177
-            for ($y=0; $y<count($corr); $y++) {
2178
-                for ($x=0; $x<count($corr[0]); $x++) {
2179
-                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]>1) {
2177
+            for ($y = 0; $y < count($corr); $y++) {
2178
+                for ($x = 0; $x < count($corr[0]); $x++) {
2179
+                    if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3] > 1) {
2180 2180
 
2181 2181
                         // sum the max height of each line in rowspan
2182
-                        $s = 0; for ($i=0; $i<$corr[$y][$x][3]; $i++) $s+= $sh[$y+$i];
2182
+                        $s = 0; for ($i = 0; $i < $corr[$y][$x][3]; $i++) $s += $sh[$y + $i];
2183 2183
 
2184 2184
                         // if the max height is < the height of the cell with rowspan => we adapt the height of each max height
2185
-                        if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']) {
2186
-                            for ($i=0; $i<$corr[$y][$x][3]; $i++) {
2187
-                                $sh[$y+$i] = $sh[$y+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'];
2185
+                        if ($s > 0 && $s < $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']) {
2186
+                            for ($i = 0; $i < $corr[$y][$x][3]; $i++) {
2187
+                                $sh[$y + $i] = $sh[$y + $i] / $s * $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'];
2188 2188
                             }
2189 2189
                         }
2190 2190
                     }
@@ -2192,26 +2192,26 @@  discard block
 block discarded – undo
2192 2192
             }
2193 2193
 
2194 2194
             // set the new height, for each cell
2195
-            for ($y=0; $y<count($corr); $y++) {
2196
-                for ($x=0; $x<count($corr[0]); $x++) {
2195
+            for ($y = 0; $y < count($corr); $y++) {
2196
+                for ($x = 0; $x < count($corr[0]); $x++) {
2197 2197
                     if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) {
2198 2198
                         // without rowspan
2199
-                        if ($corr[$y][$x][3]==1) {
2199
+                        if ($corr[$y][$x][3] == 1) {
2200 2200
                             $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $sh[$y];
2201 2201
                         // with rowspan
2202 2202
                         } else {
2203 2203
                             $s = 0;
2204
-                            for ($i=0; $i<$corr[$y][$x][3]; $i++) {
2205
-                                $s+= $sh[$y+$i];
2204
+                            for ($i = 0; $i < $corr[$y][$x][3]; $i++) {
2205
+                                $s += $sh[$y + $i];
2206 2206
                             }
2207 2207
                             $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $s;
2208 2208
 
2209
-                            for ($j=1; $j<$corr[$y][$x][3]; $j++) {
2210
-                                $tx = $x+1;
2211
-                                $ty = $y+$j;
2209
+                            for ($j = 1; $j < $corr[$y][$x][3]; $j++) {
2210
+                                $tx = $x + 1;
2211
+                                $ty = $y + $j;
2212 2212
                                 for (true; isset($corr[$ty][$tx]) && !is_array($corr[$ty][$tx]); $tx++);
2213 2213
                                 if (isset($corr[$ty][$tx])) {
2214
-                                    $cases[$corr[$ty][$tx][1]][$corr[$ty][$tx][0]]['dw']+= $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
2214
+                                    $cases[$corr[$ty][$tx][1]][$corr[$ty][$tx][0]]['dw'] += $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
2215 2215
                                 }
2216 2216
                             }
2217 2217
                         }
@@ -2230,11 +2230,11 @@  discard block
 block discarded – undo
2230 2230
         protected function _tag_open_PAGE($param)
2231 2231
         {
2232 2232
             if ($this->_isForOneLine) return false;
2233
-            if ($this->_debugActif) $this->_DEBUG_add('PAGE '.($this->_page+1), true);
2233
+            if ($this->_debugActif) $this->_DEBUG_add('PAGE ' . ($this->_page + 1), true);
2234 2234
 
2235
-            $newPageSet= (!isset($param['pageset']) || $param['pageset']!='old');
2235
+            $newPageSet = (!isset($param['pageset']) || $param['pageset'] != 'old');
2236 2236
 
2237
-            $resetPageNumber = (isset($param['pagegroup']) && $param['pagegroup']=='new');
2237
+            $resetPageNumber = (isset($param['pagegroup']) && $param['pagegroup'] == 'new');
2238 2238
 
2239 2239
             $this->_maxH = 0;
2240 2240
 
@@ -2247,12 +2247,12 @@  discard block
 block discarded – undo
2247 2247
                 $orientation = '';
2248 2248
                 if (isset($param['orientation'])) {
2249 2249
                     $param['orientation'] = strtolower($param['orientation']);
2250
-                    if ($param['orientation']=='p')         $orientation = 'P';
2251
-                    if ($param['orientation']=='portrait')  $orientation = 'P';
2250
+                    if ($param['orientation'] == 'p')         $orientation = 'P';
2251
+                    if ($param['orientation'] == 'portrait')  $orientation = 'P';
2252 2252
 
2253
-                    if ($param['orientation']=='l')         $orientation = 'L';
2254
-                    if ($param['orientation']=='paysage')   $orientation = 'L';
2255
-                    if ($param['orientation']=='landscape') $orientation = 'L';
2253
+                    if ($param['orientation'] == 'l')         $orientation = 'L';
2254
+                    if ($param['orientation'] == 'paysage')   $orientation = 'L';
2255
+                    if ($param['orientation'] == 'landscape') $orientation = 'L';
2256 2256
                 }
2257 2257
 
2258 2258
                 // format
@@ -2267,29 +2267,29 @@  discard block
 block discarded – undo
2267 2267
                 // background
2268 2268
                 $background = array();
2269 2269
                 if (isset($param['backimg'])) {
2270
-                    $background['img']    = isset($param['backimg'])  ? $param['backimg']  : '';       // src of the image
2270
+                    $background['img']    = isset($param['backimg']) ? $param['backimg'] : ''; // src of the image
2271 2271
                     $background['posX']   = isset($param['backimgx']) ? $param['backimgx'] : 'center'; // horizontale position of the image
2272 2272
                     $background['posY']   = isset($param['backimgy']) ? $param['backimgy'] : 'middle'; // vertical position of the image
2273
-                    $background['width']  = isset($param['backimgw']) ? $param['backimgw'] : '100%';   // width of the image (100% = page width)
2273
+                    $background['width']  = isset($param['backimgw']) ? $param['backimgw'] : '100%'; // width of the image (100% = page width)
2274 2274
 
2275 2275
                     // convert the src of the image, if parameters
2276 2276
                     $background['img'] = str_replace('&amp;', '&', $background['img']);
2277 2277
 
2278 2278
                     // convert the positions
2279
-                    if ($background['posX']=='left')    $background['posX'] = '0%';
2280
-                    if ($background['posX']=='center')  $background['posX'] = '50%';
2281
-                    if ($background['posX']=='right')   $background['posX'] = '100%';
2282
-                    if ($background['posY']=='top')     $background['posY'] = '0%';
2283
-                    if ($background['posY']=='middle')  $background['posY'] = '50%';
2284
-                    if ($background['posY']=='bottom')  $background['posY'] = '100%';
2279
+                    if ($background['posX'] == 'left')    $background['posX'] = '0%';
2280
+                    if ($background['posX'] == 'center')  $background['posX'] = '50%';
2281
+                    if ($background['posX'] == 'right')   $background['posX'] = '100%';
2282
+                    if ($background['posY'] == 'top')     $background['posY'] = '0%';
2283
+                    if ($background['posY'] == 'middle')  $background['posY'] = '50%';
2284
+                    if ($background['posY'] == 'bottom')  $background['posY'] = '100%';
2285 2285
 
2286 2286
                     if ($background['img']) {
2287 2287
                         // get the size of the image
2288 2288
                         // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini
2289
-                        $infos=@getimagesize($background['img']);
2290
-                        if (count($infos)>1) {
2289
+                        $infos = @getimagesize($background['img']);
2290
+                        if (count($infos) > 1) {
2291 2291
                             $imageWidth = $this->parsingCss->ConvertToMM($background['width'], $this->pdf->getW());
2292
-                            $imageHeight = $imageWidth*$infos[1]/$infos[0];
2292
+                            $imageHeight = $imageWidth * $infos[1] / $infos[0];
2293 2293
 
2294 2294
                             $background['width'] = $imageWidth;
2295 2295
                             $background['posX']  = $this->parsingCss->ConvertToMM($background['posX'], $this->pdf->getW() - $imageWidth);
@@ -2303,10 +2303,10 @@  discard block
 block discarded – undo
2303 2303
                 }
2304 2304
 
2305 2305
                 // margins of the page
2306
-                $background['top']    = isset($param['backtop'])    ? $param['backtop']    : '0';
2306
+                $background['top']    = isset($param['backtop']) ? $param['backtop'] : '0';
2307 2307
                 $background['bottom'] = isset($param['backbottom']) ? $param['backbottom'] : '0';
2308
-                $background['left']   = isset($param['backleft'])   ? $param['backleft']   : '0';
2309
-                $background['right']  = isset($param['backright'])  ? $param['backright']  : '0';
2308
+                $background['left']   = isset($param['backleft']) ? $param['backleft'] : '0';
2309
+                $background['right']  = isset($param['backright']) ? $param['backright'] : '0';
2310 2310
 
2311 2311
                 // if no unit => mm
2312 2312
                 if (preg_match('/^([0-9]*)$/isU', $background['top']))    $background['top']    .= 'mm';
@@ -2322,7 +2322,7 @@  discard block
 block discarded – undo
2322 2322
 
2323 2323
                 // get the background color
2324 2324
                 $res = false;
2325
-                $background['color']    = isset($param['backcolor'])    ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null;
2325
+                $background['color'] = isset($param['backcolor']) ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null;
2326 2326
                 if (!$res) $background['color'] = null;
2327 2327
 
2328 2328
                 $this->parsingCss->save();
@@ -2377,7 +2377,7 @@  discard block
 block discarded – undo
2377 2377
             $this->parsingCss->load();
2378 2378
             $this->parsingCss->fontSet();
2379 2379
 
2380
-            if ($this->_debugActif) $this->_DEBUG_add('PAGE '.$this->_page, false);
2380
+            if ($this->_debugActif) $this->_DEBUG_add('PAGE ' . $this->_page, false);
2381 2381
 
2382 2382
             return true;
2383 2383
         }
@@ -2394,11 +2394,11 @@  discard block
 block discarded – undo
2394 2394
             if ($this->_isForOneLine) return false;
2395 2395
 
2396 2396
             $this->_subHEADER = array();
2397
-            for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) {
2397
+            for ($this->_parsePos; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) {
2398 2398
                 $action = $this->parsingHtml->code[$this->_parsePos];
2399
-                if ($action['name']=='page_header') $action['name']='page_header_sub';
2399
+                if ($action['name'] == 'page_header') $action['name'] = 'page_header_sub';
2400 2400
                 $this->_subHEADER[] = $action;
2401
-                if (strtolower($action['name'])=='page_header_sub' && $action['close']) break;
2401
+                if (strtolower($action['name']) == 'page_header_sub' && $action['close']) break;
2402 2402
             }
2403 2403
 
2404 2404
             $this->_setPageHeader();
@@ -2418,11 +2418,11 @@  discard block
 block discarded – undo
2418 2418
             if ($this->_isForOneLine) return false;
2419 2419
 
2420 2420
             $this->_subFOOTER = array();
2421
-            for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) {
2421
+            for ($this->_parsePos; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) {
2422 2422
                 $action = $this->parsingHtml->code[$this->_parsePos];
2423
-                if ($action['name']=='page_footer') $action['name']='page_footer_sub';
2423
+                if ($action['name'] == 'page_footer') $action['name'] = 'page_footer_sub';
2424 2424
                 $this->_subFOOTER[] = $action;
2425
-                if (strtolower($action['name'])=='page_footer_sub' && $action['close']) break;
2425
+                if (strtolower($action['name']) == 'page_footer_sub' && $action['close']) break;
2426 2426
             }
2427 2427
 
2428 2428
             $this->_setPageFooter();
@@ -2540,8 +2540,8 @@  discard block
 block discarded – undo
2540 2540
 
2541 2541
             $this->parsingCss->initStyle();
2542 2542
             $this->parsingCss->resetStyle();
2543
-            $this->parsingCss->value['width']    = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight;
2544
-            $this->parsingCss->table                = array();
2543
+            $this->parsingCss->value['width'] = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight;
2544
+            $this->parsingCss->table = array();
2545 2545
 
2546 2546
             // we create a sub HTML2PFDF, and we execute on it the content of the footer, to get the height of it
2547 2547
             $sub = null;
@@ -2574,11 +2574,11 @@  discard block
 block discarded – undo
2574 2574
 
2575 2575
             $this->parsingCss->value                = $this->_subSTATES['s'];
2576 2576
             $this->parsingCss->table                = $this->_subSTATES['t'];
2577
-            $this->_pageMarges                 = $this->_subSTATES['mp'];
2578
-            $this->_margeLeft                = $this->_subSTATES['ml'];
2579
-            $this->_margeRight                = $this->_subSTATES['mr'];
2580
-            $this->_margeTop                    = $this->_subSTATES['mt'];
2581
-            $this->_margeBottom                = $this->_subSTATES['mb'];
2577
+            $this->_pageMarges = $this->_subSTATES['mp'];
2578
+            $this->_margeLeft = $this->_subSTATES['ml'];
2579
+            $this->_margeRight = $this->_subSTATES['mr'];
2580
+            $this->_margeTop = $this->_subSTATES['mt'];
2581
+            $this->_margeBottom = $this->_subSTATES['mb'];
2582 2582
             $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight);
2583 2583
             $this->pdf->SetAutoPageBreak(false, $this->_margeBottom);
2584 2584
             $this->pdf->setXY($this->_subSTATES['x'], $this->_subSTATES['y']);
@@ -2611,8 +2611,8 @@  discard block
 block discarded – undo
2611 2611
 
2612 2612
             // if the content does not fit on the page => new page
2613 2613
             if (
2614
-                $sub->_maxY < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin()) &&
2615
-                $y + $sub->_maxY>=($this->pdf->getH() - $this->pdf->getbMargin())
2614
+                $sub->_maxY < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin()) &&
2615
+                $y + $sub->_maxY >= ($this->pdf->getH() - $this->pdf->getbMargin())
2616 2616
             ) {
2617 2617
                 $this->_setNewPage();
2618 2618
             }
@@ -2668,10 +2668,10 @@  discard block
 block discarded – undo
2668 2668
             if ($this->parsingCss->value['margin-auto']) $alignObject = 'center';
2669 2669
 
2670 2670
             $marge = array();
2671
-            $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
2672
-            $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03;
2673
-            $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03;
2674
-            $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03;
2671
+            $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l'] + 0.03;
2672
+            $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r'] + 0.03;
2673
+            $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t'] + 0.03;
2674
+            $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b'] + 0.03;
2675 2675
 
2676 2676
             // extract the content of the div
2677 2677
             $level = $this->parsingHtml->getLevel($this->_parsePos);
@@ -2690,10 +2690,10 @@  discard block
 block discarded – undo
2690 2690
             $wReel = $w;
2691 2691
             $hReel = $h;
2692 2692
 
2693
-            $w+= $marge['l']+$marge['r']+0.001;
2694
-            $h+= $marge['t']+$marge['b']+0.001;
2693
+            $w += $marge['l'] + $marge['r'] + 0.001;
2694
+            $h += $marge['t'] + $marge['b'] + 0.001;
2695 2695
 
2696
-            if ($this->parsingCss->value['overflow']=='hidden') {
2696
+            if ($this->parsingCss->value['overflow'] == 'hidden') {
2697 2697
                 $overW = max($w, $this->parsingCss->value['width']);
2698 2698
                 $overH = max($h, $this->parsingCss->value['height']);
2699 2699
                 $overflow = true;
@@ -2706,11 +2706,11 @@  discard block
 block discarded – undo
2706 2706
                 $overW = null;
2707 2707
                 $overH = null;
2708 2708
                 $overflow = false;
2709
-                $this->parsingCss->value['width']    = max($w, $this->parsingCss->value['width']);
2710
-                $this->parsingCss->value['height']    = max($h, $this->parsingCss->value['height']);
2709
+                $this->parsingCss->value['width'] = max($w, $this->parsingCss->value['width']);
2710
+                $this->parsingCss->value['height'] = max($h, $this->parsingCss->value['height']);
2711 2711
             }
2712 2712
 
2713
-            switch($this->parsingCss->value['rotate'])
2713
+            switch ($this->parsingCss->value['rotate'])
2714 2714
             {
2715 2715
                 case 90:
2716 2716
                     $tmp = $overH; $overH = $overW; $overW = $tmp;
@@ -2718,7 +2718,7 @@  discard block
 block discarded – undo
2718 2718
                     unset($tmp);
2719 2719
                     $w = $this->parsingCss->value['height'];
2720 2720
                     $h = $this->parsingCss->value['width'];
2721
-                    $tX =-$h;
2721
+                    $tX = -$h;
2722 2722
                     $tY = 0;
2723 2723
                     break;
2724 2724
 
@@ -2736,7 +2736,7 @@  discard block
 block discarded – undo
2736 2736
                     $w = $this->parsingCss->value['height'];
2737 2737
                     $h = $this->parsingCss->value['width'];
2738 2738
                     $tX = 0;
2739
-                    $tY =-$w;
2739
+                    $tY = -$w;
2740 2740
                     break;
2741 2741
 
2742 2742
                 default:
@@ -2749,14 +2749,14 @@  discard block
 block discarded – undo
2749 2749
 
2750 2750
             if (!$this->parsingCss->value['position']) {
2751 2751
                 if (
2752
-                    $w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) &&
2753
-                    $this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin())
2752
+                    $w < ($this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin()) &&
2753
+                    $this->pdf->getX() + $w >= ($this->pdf->getW() - $this->pdf->getrMargin())
2754 2754
                     )
2755 2755
                     $this->_tag_open_BR(array());
2756 2756
 
2757 2757
                 if (
2758
-                        ($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) &&
2759
-                        ($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) &&
2758
+                        ($h < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin())) &&
2759
+                        ($this->pdf->getY() + $h >= ($this->pdf->getH() - $this->pdf->getbMargin())) &&
2760 2760
                         !$this->_isInOverflow
2761 2761
                     )
2762 2762
                     $this->_setNewPage();
@@ -2764,9 +2764,9 @@  discard block
 block discarded – undo
2764 2764
                 $old = $this->parsingCss->getOldValues();
2765 2765
                 $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
2766 2766
 
2767
-                if ($parentWidth>$w) {
2768
-                    if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
2769
-                    else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
2767
+                if ($parentWidth > $w) {
2768
+                    if ($alignObject == 'center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5);
2769
+                    else if ($alignObject == 'right')    $this->pdf->setX($this->pdf->getX() + $parentWidth - $w);
2770 2770
                 }
2771 2771
 
2772 2772
                 $this->parsingCss->setPosition();
@@ -2774,9 +2774,9 @@  discard block
 block discarded – undo
2774 2774
                 $old = $this->parsingCss->getOldValues();
2775 2775
                 $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
2776 2776
 
2777
-                if ($parentWidth>$w) {
2778
-                    if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
2779
-                    else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
2777
+                if ($parentWidth > $w) {
2778
+                    if ($alignObject == 'center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5);
2779
+                    else if ($alignObject == 'right')    $this->pdf->setX($this->pdf->getX() + $parentWidth - $w);
2780 2780
                 }
2781 2781
 
2782 2782
                 $this->parsingCss->setPosition();
@@ -2805,61 +2805,61 @@  discard block
 block discarded – undo
2805 2805
             );
2806 2806
 
2807 2807
             $marge = array();
2808
-            $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
2809
-            $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03;
2810
-            $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03;
2811
-            $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03;
2808
+            $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l'] + 0.03;
2809
+            $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r'] + 0.03;
2810
+            $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t'] + 0.03;
2811
+            $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b'] + 0.03;
2812 2812
 
2813
-            $this->parsingCss->value['width'] -= $marge['l']+$marge['r'];
2814
-            $this->parsingCss->value['height']-= $marge['t']+$marge['b'];
2813
+            $this->parsingCss->value['width'] -= $marge['l'] + $marge['r'];
2814
+            $this->parsingCss->value['height'] -= $marge['t'] + $marge['b'];
2815 2815
 
2816 2816
             $xCorr = 0;
2817 2817
             $yCorr = 0;
2818 2818
             if (!$this->_subPart && !$this->_isSubPart) {
2819
-                switch($this->parsingCss->value['text-align'])
2819
+                switch ($this->parsingCss->value['text-align'])
2820 2820
                 {
2821 2821
                     case 'right':
2822
-                        $xCorr = ($this->parsingCss->value['width']-$wReel);
2822
+                        $xCorr = ($this->parsingCss->value['width'] - $wReel);
2823 2823
                         break;
2824 2824
                     case 'center':
2825
-                        $xCorr = ($this->parsingCss->value['width']-$wReel)*0.5;
2825
+                        $xCorr = ($this->parsingCss->value['width'] - $wReel) * 0.5;
2826 2826
                         break;
2827 2827
                 }
2828
-                if ($xCorr>0) $xCorr=0;
2829
-                switch($this->parsingCss->value['vertical-align'])
2828
+                if ($xCorr > 0) $xCorr = 0;
2829
+                switch ($this->parsingCss->value['vertical-align'])
2830 2830
                 {
2831 2831
                     case 'bottom':
2832
-                        $yCorr = ($this->parsingCss->value['height']-$hReel);
2832
+                        $yCorr = ($this->parsingCss->value['height'] - $hReel);
2833 2833
                         break;
2834 2834
                     case 'middle':
2835
-                        $yCorr = ($this->parsingCss->value['height']-$hReel)*0.5;
2835
+                        $yCorr = ($this->parsingCss->value['height'] - $hReel) * 0.5;
2836 2836
                         break;
2837 2837
                 }
2838 2838
             }
2839 2839
 
2840 2840
             if ($overflow) {
2841
-                $overW-= $marge['l']+$marge['r'];
2842
-                $overH-= $marge['t']+$marge['b'];
2841
+                $overW -= $marge['l'] + $marge['r'];
2842
+                $overH -= $marge['t'] + $marge['b'];
2843 2843
                 $this->pdf->clippingPathStart(
2844
-                    $this->parsingCss->value['x']+$marge['l'],
2845
-                    $this->parsingCss->value['y']+$marge['t'],
2844
+                    $this->parsingCss->value['x'] + $marge['l'],
2845
+                    $this->parsingCss->value['y'] + $marge['t'],
2846 2846
                     $this->parsingCss->value['width'],
2847 2847
                     $this->parsingCss->value['height']
2848 2848
                 );
2849 2849
 
2850
-                $this->parsingCss->value['x']+= $xCorr;
2850
+                $this->parsingCss->value['x'] += $xCorr;
2851 2851
 
2852 2852
                 // marges from the dimension of the content
2853
-                $mL = $this->parsingCss->value['x']+$marge['l'];
2853
+                $mL = $this->parsingCss->value['x'] + $marge['l'];
2854 2854
                 $mR = $this->pdf->getW() - $mL - $overW;
2855 2855
             } else {
2856 2856
                 // marges from the dimension of the div
2857
-                $mL = $this->parsingCss->value['x']+$marge['l'];
2857
+                $mL = $this->parsingCss->value['x'] + $marge['l'];
2858 2858
                 $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width'];
2859 2859
             }
2860 2860
 
2861
-            $x = $this->parsingCss->value['x']+$marge['l'];
2862
-            $y = $this->parsingCss->value['y']+$marge['t']+$yCorr;
2861
+            $x = $this->parsingCss->value['x'] + $marge['l'];
2862
+            $y = $this->parsingCss->value['y'] + $marge['t'] + $yCorr;
2863 2863
             $this->_saveMargin($mL, 0, $mR);
2864 2864
             $this->pdf->setXY($x, $y);
2865 2865
 
@@ -2907,7 +2907,7 @@  discard block
 block discarded – undo
2907 2907
             $this->parsingCss->analyse('fieldset', $param);
2908 2908
 
2909 2909
             // get height of LEGEND element and make fieldset corrections
2910
-            for ($tempPos = $this->_parsePos + 1; $tempPos<count($this->parsingHtml->code); $tempPos++) {
2910
+            for ($tempPos = $this->_parsePos + 1; $tempPos < count($this->parsingHtml->code); $tempPos++) {
2911 2911
                 $action = $this->parsingHtml->code[$tempPos];
2912 2912
                 if ($action['name'] == 'fieldset') break;
2913 2913
                 if ($action['name'] == 'legend' && !$action['close']) {
@@ -2918,7 +2918,7 @@  discard block
 block discarded – undo
2918 2918
                     $sub->parsingHtml->code = $this->parsingHtml->getLevel($tempPos - 1);
2919 2919
 
2920 2920
                     $res = null;
2921
-                    for ($sub->_parsePos = 0; $sub->_parsePos<count($sub->parsingHtml->code); $sub->_parsePos++) {
2921
+                    for ($sub->_parsePos = 0; $sub->_parsePos < count($sub->parsingHtml->code); $sub->_parsePos++) {
2922 2922
                         $action = $sub->parsingHtml->code[$sub->_parsePos];
2923 2923
                         $sub->_executeAction($action);
2924 2924
 
@@ -2952,11 +2952,11 @@  discard block
 block discarded – undo
2952 2952
          * @param  string $other name of tag that used the div tag
2953 2953
          * @return boolean
2954 2954
          */
2955
-        protected function _tag_close_DIV($param, $other='div')
2955
+        protected function _tag_close_DIV($param, $other = 'div')
2956 2956
         {
2957 2957
             if ($this->_isForOneLine) return false;
2958 2958
 
2959
-            if ($this->parsingCss->value['overflow']=='hidden') {
2959
+            if ($this->parsingCss->value['overflow'] == 'hidden') {
2960 2960
                 $this->_maxX = $this->parsingCss->value['old_maxX'];
2961 2961
                 $this->_maxY = $this->parsingCss->value['old_maxY'];
2962 2962
                 $this->_maxH = $this->parsingCss->value['old_maxH'];
@@ -2968,17 +2968,17 @@  discard block
 block discarded – undo
2968 2968
                 $this->pdf->stopTransform();
2969 2969
 
2970 2970
             $marge = array();
2971
-            $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
2972
-            $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03;
2973
-            $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03;
2974
-            $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03;
2971
+            $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l'] + 0.03;
2972
+            $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r'] + 0.03;
2973
+            $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t'] + 0.03;
2974
+            $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b'] + 0.03;
2975 2975
 
2976 2976
             $x = $this->parsingCss->value['x'];
2977 2977
             $y = $this->parsingCss->value['y'];
2978
-            $w = $this->parsingCss->value['width']+$marge['l']+$marge['r']+$this->parsingCss->value['margin']['r'];
2979
-            $h = $this->parsingCss->value['height']+$marge['t']+$marge['b']+$this->parsingCss->value['margin']['b'];
2978
+            $w = $this->parsingCss->value['width'] + $marge['l'] + $marge['r'] + $this->parsingCss->value['margin']['r'];
2979
+            $h = $this->parsingCss->value['height'] + $marge['t'] + $marge['b'] + $this->parsingCss->value['margin']['b'];
2980 2980
 
2981
-            switch($this->parsingCss->value['rotate'])
2981
+            switch ($this->parsingCss->value['rotate'])
2982 2982
             {
2983 2983
                 case 90:
2984 2984
                     $t = $w; $w = $h; $h = $t;
@@ -2993,11 +2993,11 @@  discard block
 block discarded – undo
2993 2993
             }
2994 2994
 
2995 2995
 
2996
-            if ($this->parsingCss->value['position']!='absolute') {
2997
-                $this->pdf->setXY($x+$w, $y);
2996
+            if ($this->parsingCss->value['position'] != 'absolute') {
2997
+                $this->pdf->setXY($x + $w, $y);
2998 2998
 
2999
-                $this->_maxX = max($this->_maxX, $x+$w);
3000
-                $this->_maxY = max($this->_maxY, $y+$h);
2999
+                $this->_maxX = max($this->_maxX, $x + $w);
3000
+                $this->_maxY = max($this->_maxY, $y + $h);
3001 3001
                 $this->_maxH = max($this->_maxH, $h);
3002 3002
             } else {
3003 3003
                 $this->pdf->setXY($this->parsingCss->value['xc'], $this->parsingCss->value['yc']);
@@ -3005,7 +3005,7 @@  discard block
 block discarded – undo
3005 3005
                 $this->_loadMax();
3006 3006
             }
3007 3007
 
3008
-            $block = ($this->parsingCss->value['display']!='inline' && $this->parsingCss->value['position']!='absolute');
3008
+            $block = ($this->parsingCss->value['display'] != 'inline' && $this->parsingCss->value['position'] != 'absolute');
3009 3009
 
3010 3010
             $this->parsingCss->load();
3011 3011
             $this->parsingCss->fontSet();
@@ -3064,8 +3064,8 @@  discard block
 block discarded – undo
3064 3064
         {
3065 3065
             // for  compatibility with old versions < 3.29
3066 3066
             $lstBarcode = array();
3067
-            $lstBarcode['UPC_A']  =    'UPCA';
3068
-            $lstBarcode['CODE39'] =    'C39';
3067
+            $lstBarcode['UPC_A']  = 'UPCA';
3068
+            $lstBarcode['CODE39'] = 'C39';
3069 3069
 
3070 3070
             if (!isset($param['type']))     $param['type'] = 'C39';
3071 3071
             if (!isset($param['value']))    $param['value']    = 0;
@@ -3085,18 +3085,18 @@  discard block
 block discarded – undo
3085 3085
 
3086 3086
             $x = $this->pdf->getX();
3087 3087
             $y = $this->pdf->getY();
3088
-            $w = $this->parsingCss->value['width'];    if (!$w) $w = $this->parsingCss->ConvertToMM('50mm');
3089
-            $h = $this->parsingCss->value['height'];    if (!$h) $h = $this->parsingCss->ConvertToMM('10mm');
3090
-            $txt = ($param['label']!=='none' ? $this->parsingCss->value['font-size'] : false);
3088
+            $w = $this->parsingCss->value['width']; if (!$w) $w = $this->parsingCss->ConvertToMM('50mm');
3089
+            $h = $this->parsingCss->value['height']; if (!$h) $h = $this->parsingCss->ConvertToMM('10mm');
3090
+            $txt = ($param['label'] !== 'none' ? $this->parsingCss->value['font-size'] : false);
3091 3091
             $c = $this->parsingCss->value['color'];
3092 3092
             $infos = $this->pdf->myBarcode($param['value'], $param['type'], $x, $y, $w, $h, $txt, $c);
3093 3093
 
3094
-            $this->_maxX = max($this->_maxX, $x+$infos[0]);
3095
-            $this->_maxY = max($this->_maxY, $y+$infos[1]);
3094
+            $this->_maxX = max($this->_maxX, $x + $infos[0]);
3095
+            $this->_maxY = max($this->_maxY, $y + $infos[1]);
3096 3096
             $this->_maxH = max($this->_maxH, $infos[1]);
3097 3097
             $this->_maxE++;
3098 3098
 
3099
-            $this->pdf->setXY($x+$infos[0], $y);
3099
+            $this->pdf->setXY($x + $infos[0], $y);
3100 3100
 
3101 3101
             $this->parsingCss->load();
3102 3102
             $this->parsingCss->fontSet();
@@ -3137,13 +3137,13 @@  discard block
 block discarded – undo
3137 3137
             if (!isset($param['style']['color']))            $param['style']['color'] = '#000000';
3138 3138
             if (!isset($param['style']['background-color'])) $param['style']['background-color'] = '#FFFFFF';
3139 3139
             if (isset($param['style']['border'])) {
3140
-                $borders = $param['style']['border']!='none';
3140
+                $borders = $param['style']['border'] != 'none';
3141 3141
                 unset($param['style']['border']);
3142 3142
             } else {
3143 3143
                 $borders = true;
3144 3144
             }
3145 3145
 
3146
-            if ($param['value']==='') return true;
3146
+            if ($param['value'] === '') return true;
3147 3147
             if (!in_array($param['ec'], array('L', 'M', 'Q', 'H'))) $param['ec'] = 'H';
3148 3148
 
3149 3149
             $this->parsingCss->save();
@@ -3171,15 +3171,15 @@  discard block
 block discarded – undo
3171 3171
             }
3172 3172
 
3173 3173
             if (!$this->_subPart && !$this->_isSubPart) {
3174
-                $this->pdf->write2DBarcode($param['value'], 'QRCODE,'.$param['ec'], $x, $y, $size, $size, $style);
3174
+                $this->pdf->write2DBarcode($param['value'], 'QRCODE,' . $param['ec'], $x, $y, $size, $size, $style);
3175 3175
             }
3176 3176
 
3177
-            $this->_maxX = max($this->_maxX, $x+$size);
3178
-            $this->_maxY = max($this->_maxY, $y+$size);
3177
+            $this->_maxX = max($this->_maxX, $x + $size);
3178
+            $this->_maxY = max($this->_maxY, $y + $size);
3179 3179
             $this->_maxH = max($this->_maxH, $size);
3180 3180
             $this->_maxE++;
3181 3181
 
3182
-            $this->pdf->setX($x+$size);
3182
+            $this->pdf->setX($x + $size);
3183 3183
 
3184 3184
             $this->parsingCss->load();
3185 3185
             $this->parsingCss->fontSet();
@@ -3213,7 +3213,7 @@  discard block
 block discarded – undo
3213 3213
             $titre = isset($param['title']) ? trim($param['title']) : '';
3214 3214
             $level = isset($param['level']) ? floor($param['level']) : 0;
3215 3215
 
3216
-            if ($level<0) $level = 0;
3216
+            if ($level < 0) $level = 0;
3217 3217
             if ($titre) $this->pdf->Bookmark($titre, $level, -1);
3218 3218
 
3219 3219
             return true;
@@ -3241,7 +3241,7 @@  discard block
 block discarded – undo
3241 3241
          */
3242 3242
         protected function _tag_open_WRITE($param)
3243 3243
         {
3244
-            $fill = ($this->parsingCss->value['background']['color']!==null && $this->parsingCss->value['background']['image']===null);
3244
+            $fill = ($this->parsingCss->value['background']['color'] !== null && $this->parsingCss->value['background']['image'] === null);
3245 3245
             if (in_array($this->parsingCss->value['id_tag'], array('fieldset', 'legend', 'div', 'table', 'tr', 'td', 'th'))) {
3246 3246
                 $fill = false;
3247 3247
             }
@@ -3257,23 +3257,23 @@  discard block
 block discarded – undo
3257 3257
             $txt = str_replace('[[page_nb]]', $this->pdf->getMyAliasNbPages(), $txt);
3258 3258
             $txt = str_replace('[[page_cu]]', $this->pdf->getMyNumPage($this->_page), $txt);
3259 3259
 
3260
-            if ($this->parsingCss->value['text-transform']!='none') {
3261
-                if ($this->parsingCss->value['text-transform']=='capitalize')
3260
+            if ($this->parsingCss->value['text-transform'] != 'none') {
3261
+                if ($this->parsingCss->value['text-transform'] == 'capitalize')
3262 3262
                     $txt = ucwords($txt);
3263
-                else if ($this->parsingCss->value['text-transform']=='uppercase')
3263
+                else if ($this->parsingCss->value['text-transform'] == 'uppercase')
3264 3264
                     $txt = strtoupper($txt);
3265
-                else if ($this->parsingCss->value['text-transform']=='lowercase')
3265
+                else if ($this->parsingCss->value['text-transform'] == 'lowercase')
3266 3266
                     $txt = strtolower($txt);
3267 3267
             }
3268 3268
 
3269 3269
             // size of the text
3270
-            $h  = 1.08*$this->parsingCss->value['font-size'];
3271
-            $dh = $h*$this->parsingCss->value['mini-decal'];
3270
+            $h  = 1.08 * $this->parsingCss->value['font-size'];
3271
+            $dh = $h * $this->parsingCss->value['mini-decal'];
3272 3272
             $lh = $this->parsingCss->getLineHeight();
3273 3273
 
3274 3274
             // identify the align
3275 3275
             $align = 'L';
3276
-            if ($this->parsingCss->value['text-align']=='li_right') {
3276
+            if ($this->parsingCss->value['text-align'] == 'li_right') {
3277 3277
                 $w = $this->parsingCss->value['width'];
3278 3278
                 $align = 'R';
3279 3279
             }
@@ -3283,10 +3283,10 @@  discard block
 block discarded – undo
3283 3283
             $words = explode(' ', $txt);
3284 3284
             foreach ($words as $k => $word) {
3285 3285
                 $words[$k] = array($word, $this->pdf->GetStringWidth($word));
3286
-                $w+= $words[$k][1];
3286
+                $w += $words[$k][1];
3287 3287
             }
3288 3288
             $space = $this->pdf->GetStringWidth(' ');
3289
-            $w+= $space*(count($words)-1);
3289
+            $w += $space * (count($words) - 1);
3290 3290
 
3291 3291
             // position in the text
3292 3292
             $currPos = 0;
@@ -3306,13 +3306,13 @@  discard block
 block discarded – undo
3306 3306
             $nb = 0;
3307 3307
 
3308 3308
             // while we have words, and the text does not fit on the line => we cut the sentence
3309
-            while ($x+$w>$right && $x<$right+$space && count($words)) {
3309
+            while ($x + $w > $right && $x < $right + $space && count($words)) {
3310 3310
                 // adding words 1 by 1 to fit on the line
3311
-                $i=0;
3311
+                $i = 0;
3312 3312
                 $old = array('', 0);
3313 3313
                 $str = $words[0];
3314 3314
                 $add = false;
3315
-                while (($x+$str[1])<$right) {
3315
+                while (($x + $str[1]) < $right) {
3316 3316
                     $i++;
3317 3317
                     $add = true;
3318 3318
 
@@ -3320,26 +3320,26 @@  discard block
 block discarded – undo
3320 3320
                     $old = $str;
3321 3321
 
3322 3322
                     if (!count($words)) break;
3323
-                    $str[0].= ' '.$words[0][0];
3324
-                    $str[1]+= $space+$words[0][1];
3323
+                    $str[0] .= ' ' . $words[0][0];
3324
+                    $str[1] += $space + $words[0][1];
3325 3325
                 }
3326 3326
                 $str = $old;
3327 3327
 
3328 3328
                 // if  nothing fit on the line, and if the first word does not fit on the line => the word is too long, we put it
3329
-                if ($i==0 && (($left+$words[0][1])>=$right)) {
3329
+                if ($i == 0 && (($left + $words[0][1]) >= $right)) {
3330 3330
                     $str = $words[0];
3331 3331
                     array_shift($words);
3332 3332
                     $i++;
3333 3333
                     $add = true;
3334 3334
                 }
3335
-                $currPos+= ($currPos ? 1 : 0)+strlen($str[0]);
3335
+                $currPos += ($currPos ? 1 : 0) + strlen($str[0]);
3336 3336
 
3337 3337
                 // write the extract sentence that fit on the page
3338
-                $wc = ($align=='L' ? $str[1] : $this->parsingCss->value['width']);
3339
-                if ($right - $left<$wc) $wc = $right - $left;
3338
+                $wc = ($align == 'L' ? $str[1] : $this->parsingCss->value['width']);
3339
+                if ($right - $left < $wc) $wc = $right - $left;
3340 3340
 
3341 3341
                 if (strlen($str[0])) {
3342
-                    $this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy);
3342
+                    $this->pdf->setXY($this->pdf->getX(), $y + $dh + $dy);
3343 3343
                     $this->pdf->Cell($wc, $h, $str[0], 0, 0, $align, $fill, $this->_isInLink);
3344 3344
                     $this->pdf->setXY($this->pdf->getX(), $y);
3345 3345
                 }
@@ -3349,7 +3349,7 @@  discard block
 block discarded – undo
3349 3349
                 $maxX = max($maxX, $this->pdf->getX());
3350 3350
 
3351 3351
                 // new position and new width for the "while"
3352
-                $w-= $str[1];
3352
+                $w -= $str[1];
3353 3353
                 $y = $this->pdf->getY();
3354 3354
                 $x = $this->pdf->getX();
3355 3355
                 $dy = $this->_getElementY($lh);
@@ -3357,16 +3357,16 @@  discard block
 block discarded – undo
3357 3357
                 // if we have again words to write
3358 3358
                 if (count($words)) {
3359 3359
                     // remove the space at the end
3360
-                    if ($add) $w-= $space;
3360
+                    if ($add) $w -= $space;
3361 3361
 
3362 3362
                     // if we don't add any word, and if the first word is empty => useless space to skip
3363
-                    if (!$add && $words[0][0]==='') {
3363
+                    if (!$add && $words[0][0] === '') {
3364 3364
                         array_shift($words);
3365 3365
                     }
3366 3366
 
3367 3367
                     // if it is just to calculate for one line => adding the number of words
3368 3368
                     if ($this->_isForOneLine) {
3369
-                        $this->_maxE+= $i;
3369
+                        $this->_maxE += $i;
3370 3370
                         $this->_maxX = max($this->_maxX, $maxX);
3371 3371
                         return null;
3372 3372
                     }
@@ -3380,7 +3380,7 @@  discard block
 block discarded – undo
3380 3380
                     $dy = $this->_getElementY($lh);
3381 3381
 
3382 3382
                     // if the next line does  not fit on the page => new page
3383
-                    if ($y + $h>=$this->pdf->getH() - $this->pdf->getbMargin()) {
3383
+                    if ($y + $h >= $this->pdf->getH() - $this->pdf->getbMargin()) {
3384 3384
                         if (!$this->_isInOverflow && !$this->_isInFooter) {
3385 3385
                             $this->_setNewPage(null, '', null, $currPos);
3386 3386
                             $y = $this->pdf->getY();
@@ -3391,9 +3391,9 @@  discard block
 block discarded – undo
3391 3391
 
3392 3392
                     // if more than 10000 line => error
3393 3393
                     $nb++;
3394
-                    if ($nb>10000) {
3395
-                        $txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0];
3396
-                        throw new HTML2PDF_exception(2, array($txt, $right-$left, $w));
3394
+                    if ($nb > 10000) {
3395
+                        $txt = ''; foreach ($words as $k => $word) $txt .= ($k ? ' ' : '') . $word[0];
3396
+                        throw new HTML2PDF_exception(2, array($txt, $right - $left, $w));
3397 3397
                     }
3398 3398
 
3399 3399
                     // new margins for the new line
@@ -3403,17 +3403,17 @@  discard block
 block discarded – undo
3403 3403
 
3404 3404
             // if we have words after automatic cut, it is because they fit on the line => we write the text
3405 3405
             if (count($words)) {
3406
-                $txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0];
3407
-                $w+= $this->pdf->getWordSpacing()*(count($words));
3408
-                $this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy);
3409
-                $this->pdf->Cell(($align=='L' ? $w : $this->parsingCss->value['width']), $h, $txt, 0, 0, $align, $fill, $this->_isInLink);
3406
+                $txt = ''; foreach ($words as $k => $word) $txt .= ($k ? ' ' : '') . $word[0];
3407
+                $w += $this->pdf->getWordSpacing() * (count($words));
3408
+                $this->pdf->setXY($this->pdf->getX(), $y + $dh + $dy);
3409
+                $this->pdf->Cell(($align == 'L' ? $w : $this->parsingCss->value['width']), $h, $txt, 0, 0, $align, $fill, $this->_isInLink);
3410 3410
                 $this->pdf->setXY($this->pdf->getX(), $y);
3411 3411
                 $this->_maxH = max($this->_maxH, $lh);
3412
-                $this->_maxE+= count($words);
3412
+                $this->_maxE += count($words);
3413 3413
             }
3414 3414
 
3415 3415
             $maxX = max($maxX, $this->pdf->getX());
3416
-            $maxY = $this->pdf->getY()+$h;
3416
+            $maxY = $this->pdf->getY() + $h;
3417 3417
 
3418 3418
             $this->_maxX = max($this->_maxX, $maxX);
3419 3419
             $this->_maxY = max($this->_maxY, $maxY);
@@ -3435,7 +3435,7 @@  discard block
 block discarded – undo
3435 3435
 
3436 3436
             $h = max($this->_maxH, $this->parsingCss->getLineHeight());
3437 3437
 
3438
-            if ($this->_maxH==0) $this->_maxY = max($this->_maxY, $this->pdf->getY()+$h);
3438
+            if ($this->_maxH == 0) $this->_maxY = max($this->_maxY, $this->pdf->getY() + $h);
3439 3439
 
3440 3440
             $this->_makeBreakLine($h, $curr);
3441 3441
 
@@ -3461,21 +3461,21 @@  discard block
 block discarded – undo
3461 3461
             if ($this->_maxH) $this->_tag_open_BR($param);
3462 3462
 
3463 3463
             $fontSize = $this->parsingCss->value['font-size'];
3464
-            $this->parsingCss->value['font-size']=$fontSize*0.5; $this->_tag_open_BR($param);
3465
-            $this->parsingCss->value['font-size']=0;
3464
+            $this->parsingCss->value['font-size'] = $fontSize * 0.5; $this->_tag_open_BR($param);
3465
+            $this->parsingCss->value['font-size'] = 0;
3466 3466
 
3467 3467
             $param['style']['width'] = '100%';
3468 3468
 
3469 3469
             $this->parsingCss->save();
3470
-            $this->parsingCss->value['height']=$this->parsingCss->ConvertToMM('1mm');
3470
+            $this->parsingCss->value['height'] = $this->parsingCss->ConvertToMM('1mm');
3471 3471
 
3472 3472
             $this->parsingCss->analyse('hr', $param);
3473 3473
             $this->parsingCss->setPosition();
3474 3474
             $this->parsingCss->fontSet();
3475 3475
 
3476 3476
             $h = $this->parsingCss->value['height'];
3477
-            if ($h)    $h-= $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width'];
3478
-            if ($h<=0) $h = $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width'];
3477
+            if ($h)    $h -= $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['border']['b']['width'];
3478
+            if ($h <= 0) $h = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['border']['b']['width'];
3479 3479
 
3480 3480
             $this->_drawRectangle($this->pdf->getX(), $this->pdf->getY(), $this->parsingCss->value['width'], $h, $this->parsingCss->value['border'], 0, 0, $this->parsingCss->value['background']);
3481 3481
             $this->_maxH = $h;
@@ -3485,8 +3485,8 @@  discard block
 block discarded – undo
3485 3485
 
3486 3486
             $this->_tag_open_BR($param);
3487 3487
 
3488
-            $this->parsingCss->value['font-size']=$fontSize*0.5; $this->_tag_open_BR($param);
3489
-            $this->parsingCss->value['font-size']=$fontSize;
3488
+            $this->parsingCss->value['font-size'] = $fontSize * 0.5; $this->_tag_open_BR($param);
3489
+            $this->parsingCss->value['font-size'] = $fontSize;
3490 3490
 
3491 3491
             $this->parsingCss->value['text-align'] = $oldAlign;
3492 3492
             $this->_setNewPositionForNewLine();
@@ -3748,7 +3748,7 @@  discard block
 block discarded – undo
3748 3748
          * @param  string $other
3749 3749
          * @return boolean
3750 3750
          */
3751
-        protected function _tag_open_U($param, $other='u')
3751
+        protected function _tag_open_U($param, $other = 'u')
3752 3752
         {
3753 3753
             $this->parsingCss->save();
3754 3754
             $this->parsingCss->value['font-underline'] = true;
@@ -3810,7 +3810,7 @@  discard block
 block discarded – undo
3810 3810
             $this->_isInLink = str_replace('&amp;', '&', isset($param['href']) ? $param['href'] : '');
3811 3811
 
3812 3812
             if (isset($param['name'])) {
3813
-                $name =     $param['name'];
3813
+                $name = $param['name'];
3814 3814
                 if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false);
3815 3815
 
3816 3816
                 if (!$this->_lstAnchor[$name][1]) {
@@ -3845,7 +3845,7 @@  discard block
 block discarded – undo
3845 3845
          */
3846 3846
         protected function _tag_close_A($param)
3847 3847
         {
3848
-            $this->_isInLink    = '';
3848
+            $this->_isInLink = '';
3849 3849
             $this->parsingCss->load();
3850 3850
             $this->parsingCss->fontSet();
3851 3851
 
@@ -3954,7 +3954,7 @@  discard block
 block discarded – undo
3954 3954
         {
3955 3955
             if ($this->_isForOneLine) return false;
3956 3956
 
3957
-            $this->_maxH+= $this->parsingCss->value['margin']['b'];
3957
+            $this->_maxH += $this->parsingCss->value['margin']['b'];
3958 3958
             $h = max($this->_maxH, $this->parsingCss->getLineHeight());
3959 3959
 
3960 3960
             $this->parsingCss->load();
@@ -4131,21 +4131,21 @@  discard block
 block discarded – undo
4131 4131
             $this->parsingCss->fontSet();
4132 4132
 
4133 4133
              // cancel the effects of the setPosition
4134
-            $this->pdf->setXY($this->pdf->getX()-$this->parsingCss->value['margin']['l'], $this->pdf->getY()-$this->parsingCss->value['margin']['t']);
4134
+            $this->pdf->setXY($this->pdf->getX() - $this->parsingCss->value['margin']['l'], $this->pdf->getY() - $this->parsingCss->value['margin']['t']);
4135 4135
 
4136 4136
             list($mL, $mR) = $this->_getMargins($this->pdf->getY());
4137
-            $mR = $this->pdf->getW()-$mR;
4138
-            $mL+= $this->parsingCss->value['margin']['l']+$this->parsingCss->value['padding']['l'];
4139
-            $mR+= $this->parsingCss->value['margin']['r']+$this->parsingCss->value['padding']['r'];
4137
+            $mR = $this->pdf->getW() - $mR;
4138
+            $mL += $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['padding']['l'];
4139
+            $mR += $this->parsingCss->value['margin']['r'] + $this->parsingCss->value['padding']['r'];
4140 4140
             $this->_saveMargin($mL, 0, $mR);
4141 4141
 
4142
-            if ($this->parsingCss->value['text-indent']>0) {
4143
-                $y = $this->pdf->getY()+$this->parsingCss->value['margin']['t']+$this->parsingCss->value['padding']['t'];
4144
-                $this->_pageMarges[floor($y*100)] = array($mL+$this->parsingCss->value['text-indent'], $this->pdf->getW()-$mR);
4145
-                $y+= $this->parsingCss->getLineHeight()*0.1;
4146
-                $this->_pageMarges[floor($y*100)] = array($mL, $this->pdf->getW()-$mR);
4142
+            if ($this->parsingCss->value['text-indent'] > 0) {
4143
+                $y = $this->pdf->getY() + $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['padding']['t'];
4144
+                $this->_pageMarges[floor($y * 100)] = array($mL + $this->parsingCss->value['text-indent'], $this->pdf->getW() - $mR);
4145
+                $y += $this->parsingCss->getLineHeight() * 0.1;
4146
+                $this->_pageMarges[floor($y * 100)] = array($mL, $this->pdf->getW() - $mR);
4147 4147
             }
4148
-            $this->_makeBreakLine($this->parsingCss->value['margin']['t']+$this->parsingCss->value['padding']['t']);
4148
+            $this->_makeBreakLine($this->parsingCss->value['margin']['t'] + $this->parsingCss->value['padding']['t']);
4149 4149
             $this->_isInParagraph = array($mL, $mR);
4150 4150
             return true;
4151 4151
         }
@@ -4164,7 +4164,7 @@  discard block
 block discarded – undo
4164 4164
             if ($this->_maxH) $this->_tag_open_BR(array());
4165 4165
             $this->_isInParagraph = false;
4166 4166
             $this->_loadMargin();
4167
-            $h = $this->parsingCss->value['margin']['b']+$this->parsingCss->value['padding']['b'];
4167
+            $h = $this->parsingCss->value['margin']['b'] + $this->parsingCss->value['padding']['b'];
4168 4168
 
4169 4169
             $this->parsingCss->load();
4170 4170
             $this->parsingCss->fontSet();
@@ -4183,7 +4183,7 @@  discard block
 block discarded – undo
4183 4183
          */
4184 4184
         protected function _tag_open_PRE($param, $other = 'pre')
4185 4185
         {
4186
-            if ($other=='pre' && $this->_maxH) $this->_tag_open_BR(array());
4186
+            if ($other == 'pre' && $this->_maxH) $this->_tag_open_BR(array());
4187 4187
 
4188 4188
             $this->parsingCss->save();
4189 4189
             $this->parsingCss->value['font-family'] = 'courier';
@@ -4191,7 +4191,7 @@  discard block
 block discarded – undo
4191 4191
             $this->parsingCss->setPosition();
4192 4192
             $this->parsingCss->fontSet();
4193 4193
 
4194
-            if ($other=='pre') return $this->_tag_open_DIV($param, $other);
4194
+            if ($other == 'pre') return $this->_tag_open_DIV($param, $other);
4195 4195
 
4196 4196
             return true;
4197 4197
         }
@@ -4219,7 +4219,7 @@  discard block
 block discarded – undo
4219 4219
          */
4220 4220
         protected function _tag_close_PRE($param, $other = 'pre')
4221 4221
         {
4222
-            if ($other=='pre') {
4222
+            if ($other == 'pre') {
4223 4223
                 if ($this->_isForOneLine) return false;
4224 4224
 
4225 4225
                 $this->_tag_close_DIV($param, $other);
@@ -4253,7 +4253,7 @@  discard block
 block discarded – undo
4253 4253
         protected function _tag_open_BIG($param)
4254 4254
         {
4255 4255
             $this->parsingCss->save();
4256
-            $this->parsingCss->value['mini-decal']-= $this->parsingCss->value['mini-size']*0.12;
4256
+            $this->parsingCss->value['mini-decal'] -= $this->parsingCss->value['mini-size'] * 0.12;
4257 4257
             $this->parsingCss->value['mini-size'] *= 1.2;
4258 4258
             $this->parsingCss->analyse('big', $param);
4259 4259
             $this->parsingCss->setPosition();
@@ -4286,7 +4286,7 @@  discard block
 block discarded – undo
4286 4286
         protected function _tag_open_SMALL($param)
4287 4287
         {
4288 4288
             $this->parsingCss->save();
4289
-            $this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.05;
4289
+            $this->parsingCss->value['mini-decal'] += $this->parsingCss->value['mini-size'] * 0.05;
4290 4290
             $this->parsingCss->value['mini-size'] *= 0.82;
4291 4291
             $this->parsingCss->analyse('small', $param);
4292 4292
             $this->parsingCss->setPosition();
@@ -4319,7 +4319,7 @@  discard block
 block discarded – undo
4319 4319
         protected function _tag_open_SUP($param)
4320 4320
         {
4321 4321
             $this->parsingCss->save();
4322
-            $this->parsingCss->value['mini-decal']-= $this->parsingCss->value['mini-size']*0.15;
4322
+            $this->parsingCss->value['mini-decal'] -= $this->parsingCss->value['mini-size'] * 0.15;
4323 4323
             $this->parsingCss->value['mini-size'] *= 0.75;
4324 4324
             $this->parsingCss->analyse('sup', $param);
4325 4325
             $this->parsingCss->setPosition();
@@ -4353,7 +4353,7 @@  discard block
 block discarded – undo
4353 4353
         protected function _tag_open_SUB($param)
4354 4354
         {
4355 4355
             $this->parsingCss->save();
4356
-            $this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.15;
4356
+            $this->parsingCss->value['mini-decal'] += $this->parsingCss->value['mini-size'] * 0.15;
4357 4357
             $this->parsingCss->value['mini-size'] *= 0.75;
4358 4358
             $this->parsingCss->analyse('sub', $param);
4359 4359
             $this->parsingCss->setPosition();
@@ -4491,7 +4491,7 @@  discard block
 block discarded – undo
4491 4491
 
4492 4492
             // if small LI
4493 4493
             if ($inf[1]) {
4494
-                $this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.045;
4494
+                $this->parsingCss->value['mini-decal'] += $this->parsingCss->value['mini-size'] * 0.045;
4495 4495
                 $this->parsingCss->value['mini-size'] *= 0.75;
4496 4496
             }
4497 4497
 
@@ -4499,21 +4499,21 @@  discard block
 block discarded – undo
4499 4499
             if ($this->_subPart) {
4500 4500
                 // TD for the puce
4501 4501
                 $tmpPos = $this->_tempPos;
4502
-                $tmpLst1 = $this->parsingHtml->code[$tmpPos+1];
4503
-                $tmpLst2 = $this->parsingHtml->code[$tmpPos+2];
4504
-                $this->parsingHtml->code[$tmpPos+1] = array();
4505
-                $this->parsingHtml->code[$tmpPos+1]['name']    = (isset($paramPUCE['src'])) ? 'img' : 'write';
4506
-                $this->parsingHtml->code[$tmpPos+1]['param']    = $paramPUCE; unset($this->parsingHtml->code[$tmpPos+1]['param']['style']['width']);
4507
-                $this->parsingHtml->code[$tmpPos+1]['close']    = 0;
4508
-                $this->parsingHtml->code[$tmpPos+2] = array();
4509
-                $this->parsingHtml->code[$tmpPos+2]['name']    = 'li';
4510
-                $this->parsingHtml->code[$tmpPos+2]['param']    = $paramPUCE;
4511
-                $this->parsingHtml->code[$tmpPos+2]['close']    = 1;
4502
+                $tmpLst1 = $this->parsingHtml->code[$tmpPos + 1];
4503
+                $tmpLst2 = $this->parsingHtml->code[$tmpPos + 2];
4504
+                $this->parsingHtml->code[$tmpPos + 1] = array();
4505
+                $this->parsingHtml->code[$tmpPos + 1]['name'] = (isset($paramPUCE['src'])) ? 'img' : 'write';
4506
+                $this->parsingHtml->code[$tmpPos + 1]['param']    = $paramPUCE; unset($this->parsingHtml->code[$tmpPos + 1]['param']['style']['width']);
4507
+                $this->parsingHtml->code[$tmpPos + 1]['close']    = 0;
4508
+                $this->parsingHtml->code[$tmpPos + 2] = array();
4509
+                $this->parsingHtml->code[$tmpPos + 2]['name'] = 'li';
4510
+                $this->parsingHtml->code[$tmpPos + 2]['param']    = $paramPUCE;
4511
+                $this->parsingHtml->code[$tmpPos + 2]['close']    = 1;
4512 4512
                 $this->_tag_open_TD($paramPUCE, 'li_sub');
4513 4513
                 $this->_tag_close_TD($param);
4514 4514
                 $this->_tempPos = $tmpPos;
4515
-                $this->parsingHtml->code[$tmpPos+1] = $tmpLst1;
4516
-                $this->parsingHtml->code[$tmpPos+2] = $tmpLst2;
4515
+                $this->parsingHtml->code[$tmpPos + 1] = $tmpLst1;
4516
+                $this->parsingHtml->code[$tmpPos + 2] = $tmpLst2;
4517 4517
             } else {
4518 4518
                 // TD for the puce
4519 4519
                 $this->_tag_open_TD($paramPUCE, 'li_sub');
@@ -4605,16 +4605,16 @@  discard block
 block discarded – undo
4605 4605
             if ($this->_subPart) {
4606 4606
                 HTML2PDF::$_tables[$param['num']]['thead']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr'];
4607 4607
                 HTML2PDF::$_tables[$param['num']]['thead']['code'] = array();
4608
-                for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) {
4608
+                for ($pos = $this->_tempPos; $pos < count($this->parsingHtml->code); $pos++) {
4609 4609
                     $action = $this->parsingHtml->code[$pos];
4610
-                    if (strtolower($action['name'])=='thead') $action['name'] = 'thead_sub';
4610
+                    if (strtolower($action['name']) == 'thead') $action['name'] = 'thead_sub';
4611 4611
                     HTML2PDF::$_tables[$param['num']]['thead']['code'][] = $action;
4612
-                    if (strtolower($action['name'])=='thead_sub' && $action['close']) break;
4612
+                    if (strtolower($action['name']) == 'thead_sub' && $action['close']) break;
4613 4613
                 }
4614 4614
             } else {
4615 4615
                 $level = $this->parsingHtml->getLevel($this->_parsePos);
4616
-                $this->_parsePos+= count($level);
4617
-                HTML2PDF::$_tables[$param['num']]['tr_curr']+= count(HTML2PDF::$_tables[$param['num']]['thead']['tr']);
4616
+                $this->_parsePos += count($level);
4617
+                HTML2PDF::$_tables[$param['num']]['tr_curr'] += count(HTML2PDF::$_tables[$param['num']]['thead']['tr']);
4618 4618
             }
4619 4619
 
4620 4620
             return true;
@@ -4637,7 +4637,7 @@  discard block
 block discarded – undo
4637 4637
             // if we are in a sub HTM, construct the list of the TR in the thead
4638 4638
             if ($this->_subPart) {
4639 4639
                 $min = HTML2PDF::$_tables[$param['num']]['thead']['tr'][0];
4640
-                $max = HTML2PDF::$_tables[$param['num']]['tr_curr']-1;
4640
+                $max = HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1;
4641 4641
                 HTML2PDF::$_tables[$param['num']]['thead']['tr'] = range($min, $max);
4642 4642
             }
4643 4643
 
@@ -4664,16 +4664,16 @@  discard block
 block discarded – undo
4664 4664
             if ($this->_subPart) {
4665 4665
                 HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr'];
4666 4666
                 HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array();
4667
-                for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) {
4667
+                for ($pos = $this->_tempPos; $pos < count($this->parsingHtml->code); $pos++) {
4668 4668
                     $action = $this->parsingHtml->code[$pos];
4669
-                    if (strtolower($action['name'])=='tfoot') $action['name'] = 'tfoot_sub';
4669
+                    if (strtolower($action['name']) == 'tfoot') $action['name'] = 'tfoot_sub';
4670 4670
                     HTML2PDF::$_tables[$param['num']]['tfoot']['code'][] = $action;
4671
-                    if (strtolower($action['name'])=='tfoot_sub' && $action['close']) break;
4671
+                    if (strtolower($action['name']) == 'tfoot_sub' && $action['close']) break;
4672 4672
                 }
4673 4673
             } else {
4674 4674
                 $level = $this->parsingHtml->getLevel($this->_parsePos);
4675
-                $this->_parsePos+= count($level);
4676
-                HTML2PDF::$_tables[$param['num']]['tr_curr']+= count(HTML2PDF::$_tables[$param['num']]['tfoot']['tr']);
4675
+                $this->_parsePos += count($level);
4676
+                HTML2PDF::$_tables[$param['num']]['tr_curr'] += count(HTML2PDF::$_tables[$param['num']]['tfoot']['tr']);
4677 4677
             }
4678 4678
 
4679 4679
             return true;
@@ -4696,7 +4696,7 @@  discard block
 block discarded – undo
4696 4696
             // if we are in a sub HTM, construct the list of the TR in the tfoot
4697 4697
             if ($this->_subPart) {
4698 4698
                 $min = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0];
4699
-                $max = HTML2PDF::$_tables[$param['num']]['tr_curr']-1;
4699
+                $max = HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1;
4700 4700
                 HTML2PDF::$_tables[$param['num']]['tfoot']['tr'] = range($min, $max);
4701 4701
             }
4702 4702
 
@@ -4849,7 +4849,7 @@  discard block
 block discarded – undo
4849 4849
 
4850 4850
             // collapse table ?
4851 4851
             $collapse = false;
4852
-            if ($other=='table') {
4852
+            if ($other == 'table') {
4853 4853
                 $collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false;
4854 4854
             }
4855 4855
 
@@ -4866,50 +4866,50 @@  discard block
 block discarded – undo
4866 4866
 
4867 4867
             // if we are in a SUB html => prepare the properties of the table
4868 4868
             if ($this->_subPart) {
4869
-                if ($this->_debugActif) $this->_DEBUG_add('Table n'.$param['num'], true);
4869
+                if ($this->_debugActif) $this->_DEBUG_add('Table n' . $param['num'], true);
4870 4870
                 HTML2PDF::$_tables[$param['num']] = array();
4871 4871
                 HTML2PDF::$_tables[$param['num']]['border']          = isset($param['border']) ? $this->parsingCss->readBorder($param['border']) : null;
4872 4872
                 HTML2PDF::$_tables[$param['num']]['cellpadding']     = $this->parsingCss->ConvertToMM(isset($param['cellpadding']) ? $param['cellpadding'] : '1px');
4873 4873
                 HTML2PDF::$_tables[$param['num']]['cellspacing']     = $this->parsingCss->ConvertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px');
4874
-                HTML2PDF::$_tables[$param['num']]['cases']           = array();          // properties of each TR/TD
4875
-                HTML2PDF::$_tables[$param['num']]['corr']            = array();          // link between TR/TD and colspan/rowspan
4876
-                HTML2PDF::$_tables[$param['num']]['corr_x']          = 0;                // position in 'cases'
4877
-                HTML2PDF::$_tables[$param['num']]['corr_y']          = 0;                // position in 'cases'
4878
-                HTML2PDF::$_tables[$param['num']]['td_curr']         = 0;                // current column
4879
-                HTML2PDF::$_tables[$param['num']]['tr_curr']         = 0;                // current row
4874
+                HTML2PDF::$_tables[$param['num']]['cases']           = array(); // properties of each TR/TD
4875
+                HTML2PDF::$_tables[$param['num']]['corr']            = array(); // link between TR/TD and colspan/rowspan
4876
+                HTML2PDF::$_tables[$param['num']]['corr_x']          = 0; // position in 'cases'
4877
+                HTML2PDF::$_tables[$param['num']]['corr_y']          = 0; // position in 'cases'
4878
+                HTML2PDF::$_tables[$param['num']]['td_curr']         = 0; // current column
4879
+                HTML2PDF::$_tables[$param['num']]['tr_curr']         = 0; // current row
4880 4880
                 HTML2PDF::$_tables[$param['num']]['curr_x']          = $this->pdf->getX();
4881 4881
                 HTML2PDF::$_tables[$param['num']]['curr_y']          = $this->pdf->getY();
4882
-                HTML2PDF::$_tables[$param['num']]['width']           = 0;                // global width
4883
-                HTML2PDF::$_tables[$param['num']]['height']          = 0;                // global height
4882
+                HTML2PDF::$_tables[$param['num']]['width']           = 0; // global width
4883
+                HTML2PDF::$_tables[$param['num']]['height']          = 0; // global height
4884 4884
                 HTML2PDF::$_tables[$param['num']]['align']           = $alignObject;
4885 4885
                 HTML2PDF::$_tables[$param['num']]['marge']           = array();
4886
-                HTML2PDF::$_tables[$param['num']]['marge']['t']      = $this->parsingCss->value['padding']['t']+$this->parsingCss->value['border']['t']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5;
4887
-                HTML2PDF::$_tables[$param['num']]['marge']['r']      = $this->parsingCss->value['padding']['r']+$this->parsingCss->value['border']['r']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5;
4888
-                HTML2PDF::$_tables[$param['num']]['marge']['b']      = $this->parsingCss->value['padding']['b']+$this->parsingCss->value['border']['b']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5;
4889
-                HTML2PDF::$_tables[$param['num']]['marge']['l']      = $this->parsingCss->value['padding']['l']+$this->parsingCss->value['border']['l']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5;
4890
-                HTML2PDF::$_tables[$param['num']]['page']            = 0;                // number of pages
4891
-                HTML2PDF::$_tables[$param['num']]['new_page']        = true;             // flag : new page for the current TR
4892
-                HTML2PDF::$_tables[$param['num']]['style_value']     = null;             // CSS style of the table
4893
-                HTML2PDF::$_tables[$param['num']]['thead']           = array();          // properties on the thead
4894
-                HTML2PDF::$_tables[$param['num']]['tfoot']           = array();          // properties on the tfoot
4895
-                HTML2PDF::$_tables[$param['num']]['thead']['tr']     = array();          // list of the TRs in the thead
4896
-                HTML2PDF::$_tables[$param['num']]['tfoot']['tr']     = array();          // list of the TRs in the tfoot
4897
-                HTML2PDF::$_tables[$param['num']]['thead']['height']    = 0;             // thead height
4898
-                HTML2PDF::$_tables[$param['num']]['tfoot']['height']    = 0;             // tfoot height
4899
-                HTML2PDF::$_tables[$param['num']]['thead']['code'] = array();            // HTML content of the thead
4900
-                HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array();            // HTML content of the tfoot
4901
-                HTML2PDF::$_tables[$param['num']]['cols']        = array();              // properties of the COLs
4886
+                HTML2PDF::$_tables[$param['num']]['marge']['t']      = $this->parsingCss->value['padding']['t'] + $this->parsingCss->value['border']['t']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5;
4887
+                HTML2PDF::$_tables[$param['num']]['marge']['r']      = $this->parsingCss->value['padding']['r'] + $this->parsingCss->value['border']['r']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5;
4888
+                HTML2PDF::$_tables[$param['num']]['marge']['b']      = $this->parsingCss->value['padding']['b'] + $this->parsingCss->value['border']['b']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5;
4889
+                HTML2PDF::$_tables[$param['num']]['marge']['l']      = $this->parsingCss->value['padding']['l'] + $this->parsingCss->value['border']['l']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5;
4890
+                HTML2PDF::$_tables[$param['num']]['page']            = 0; // number of pages
4891
+                HTML2PDF::$_tables[$param['num']]['new_page']        = true; // flag : new page for the current TR
4892
+                HTML2PDF::$_tables[$param['num']]['style_value']     = null; // CSS style of the table
4893
+                HTML2PDF::$_tables[$param['num']]['thead']           = array(); // properties on the thead
4894
+                HTML2PDF::$_tables[$param['num']]['tfoot']           = array(); // properties on the tfoot
4895
+                HTML2PDF::$_tables[$param['num']]['thead']['tr']     = array(); // list of the TRs in the thead
4896
+                HTML2PDF::$_tables[$param['num']]['tfoot']['tr']     = array(); // list of the TRs in the tfoot
4897
+                HTML2PDF::$_tables[$param['num']]['thead']['height']    = 0; // thead height
4898
+                HTML2PDF::$_tables[$param['num']]['tfoot']['height']    = 0; // tfoot height
4899
+                HTML2PDF::$_tables[$param['num']]['thead']['code'] = array(); // HTML content of the thead
4900
+                HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array(); // HTML content of the tfoot
4901
+                HTML2PDF::$_tables[$param['num']]['cols'] = array(); // properties of the COLs
4902 4902
 
4903 4903
                 $this->_saveMargin($this->pdf->getlMargin(), $this->pdf->gettMargin(), $this->pdf->getrMargin());
4904 4904
 
4905
-                $this->parsingCss->value['width']-= HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r'];
4905
+                $this->parsingCss->value['width'] -= HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r'];
4906 4906
             } else {
4907 4907
                 // we start from the first page and the first page of the table
4908 4908
                 HTML2PDF::$_tables[$param['num']]['page'] = 0;
4909 4909
                 HTML2PDF::$_tables[$param['num']]['td_curr']    = 0;
4910 4910
                 HTML2PDF::$_tables[$param['num']]['tr_curr']    = 0;
4911
-                HTML2PDF::$_tables[$param['num']]['td_x']        = HTML2PDF::$_tables[$param['num']]['marge']['l']+HTML2PDF::$_tables[$param['num']]['curr_x'];
4912
-                HTML2PDF::$_tables[$param['num']]['td_y']        = HTML2PDF::$_tables[$param['num']]['marge']['t']+HTML2PDF::$_tables[$param['num']]['curr_y'];
4911
+                HTML2PDF::$_tables[$param['num']]['td_x']        = HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['curr_x'];
4912
+                HTML2PDF::$_tables[$param['num']]['td_y']        = HTML2PDF::$_tables[$param['num']]['marge']['t'] + HTML2PDF::$_tables[$param['num']]['curr_y'];
4913 4913
 
4914 4914
                 // draw the borders/background of the first page/part of the table
4915 4915
                 $this->_drawRectangle(
@@ -4954,10 +4954,10 @@  discard block
 block discarded – undo
4954 4954
                     foreach (HTML2PDF::$_tables[$param['num']][$mode]['tr'] as $tr) {
4955 4955
                         // hauteur de la ligne tr
4956 4956
                         $h = 0;
4957
-                        for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++)
4958
-                            if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan']==1)
4957
+                        for ($i = 0; $i < count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++)
4958
+                            if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan'] == 1)
4959 4959
                                 $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['h']);
4960
-                        HTML2PDF::$_tables[$param['num']][$mode]['height']+= $h;
4960
+                        HTML2PDF::$_tables[$param['num']][$mode]['height'] += $h;
4961 4961
                     }
4962 4962
                 }
4963 4963
 
@@ -4965,7 +4965,7 @@  discard block
 block discarded – undo
4965 4965
                 HTML2PDF::$_tables[$param['num']]['width'] = HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r'];
4966 4966
                 if (isset(HTML2PDF::$_tables[$param['num']]['cases'][0])) {
4967 4967
                     foreach (HTML2PDF::$_tables[$param['num']]['cases'][0] as $case) {
4968
-                        HTML2PDF::$_tables[$param['num']]['width']+= $case['w'];
4968
+                        HTML2PDF::$_tables[$param['num']]['width'] += $case['w'];
4969 4969
                     }
4970 4970
                 }
4971 4971
 
@@ -4974,11 +4974,11 @@  discard block
 block discarded – undo
4974 4974
                 $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
4975 4975
                 $x = HTML2PDF::$_tables[$param['num']]['curr_x'];
4976 4976
                 $w = HTML2PDF::$_tables[$param['num']]['width'];
4977
-                if ($parentWidth>$w) {
4978
-                    if (HTML2PDF::$_tables[$param['num']]['align']=='center')
4979
-                        $x = $x + ($parentWidth-$w)*0.5;
4980
-                    else if (HTML2PDF::$_tables[$param['num']]['align']=='right')
4981
-                        $x = $x + $parentWidth-$w;
4977
+                if ($parentWidth > $w) {
4978
+                    if (HTML2PDF::$_tables[$param['num']]['align'] == 'center')
4979
+                        $x = $x + ($parentWidth - $w) * 0.5;
4980
+                    else if (HTML2PDF::$_tables[$param['num']]['align'] == 'right')
4981
+                        $x = $x + $parentWidth - $w;
4982 4982
 
4983 4983
                     HTML2PDF::$_tables[$param['num']]['curr_x'] = $x;
4984 4984
                 }
@@ -4988,7 +4988,7 @@  discard block
 block discarded – undo
4988 4988
 
4989 4989
                 // minimum of the height because of margins, and of the thead and tfoot height
4990 4990
                 $h0 = HTML2PDF::$_tables[$param['num']]['marge']['t'] + HTML2PDF::$_tables[$param['num']]['marge']['b'];
4991
-                $h0+= HTML2PDF::$_tables[$param['num']]['thead']['height'] + HTML2PDF::$_tables[$param['num']]['tfoot']['height'];
4991
+                $h0 += HTML2PDF::$_tables[$param['num']]['thead']['height'] + HTML2PDF::$_tables[$param['num']]['tfoot']['height'];
4992 4992
 
4993 4993
                 // max height of the page
4994 4994
                 $max = $this->pdf->getH() - $this->pdf->getbMargin();
@@ -4998,7 +4998,7 @@  discard block
 block discarded – undo
4998 4998
                 $height = $h0;
4999 4999
 
5000 5000
                 // we get the height of each line
5001
-                for ($k=0; $k<count(HTML2PDF::$_tables[$param['num']]['cases']); $k++) {
5001
+                for ($k = 0; $k < count(HTML2PDF::$_tables[$param['num']]['cases']); $k++) {
5002 5002
 
5003 5003
                     // if it is a TR of the thead or of the tfoot => skip
5004 5004
                     if (in_array($k, HTML2PDF::$_tables[$param['num']]['thead']['tr'])) continue;
@@ -5007,25 +5007,25 @@  discard block
 block discarded – undo
5007 5007
                     // height of the line
5008 5008
                     $th = 0;
5009 5009
                     $h = 0;
5010
-                    for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$k]); $i++) {
5010
+                    for ($i = 0; $i < count(HTML2PDF::$_tables[$param['num']]['cases'][$k]); $i++) {
5011 5011
                         $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']);
5012 5012
 
5013
-                        if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan']==1)
5013
+                        if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan'] == 1)
5014 5014
                             $th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']);
5015 5015
                     }
5016 5016
 
5017 5017
                     // if the row does not fit on the page => new page
5018
-                    if ($y+$h+$height>$max) {
5019
-                        if ($height==$h0) $height = null;
5018
+                    if ($y + $h + $height > $max) {
5019
+                        if ($height == $h0) $height = null;
5020 5020
                         HTML2PDF::$_tables[$param['num']]['height'][] = $height;
5021 5021
                         $height = $h0;
5022 5022
                         $y = $this->_margeTop;
5023 5023
                     }
5024
-                    $height+= $th;
5024
+                    $height += $th;
5025 5025
                 }
5026 5026
 
5027 5027
                 // if ther is a height at the end, add it
5028
-                if ($height!=$h0 || $k==0) HTML2PDF::$_tables[$param['num']]['height'][] = $height;
5028
+                if ($height != $h0 || $k == 0) HTML2PDF::$_tables[$param['num']]['height'][] = $height;
5029 5029
             } else {
5030 5030
                 // if we have tfoor, draw it
5031 5031
                 if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) {
@@ -5042,7 +5042,7 @@  discard block
 block discarded – undo
5042 5042
                     $this->_makeHTMLcode();
5043 5043
                     $this->_isInTfoot = false;
5044 5044
 
5045
-                    $this->_parsePos =     $oldParsePos;
5045
+                    $this->_parsePos = $oldParsePos;
5046 5046
                     $this->parsingHtml->code = $oldParseCode;
5047 5047
                     HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR;
5048 5048
                     HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD;
@@ -5050,10 +5050,10 @@  discard block
 block discarded – undo
5050 5050
 
5051 5051
                 // get the positions of the end of the table
5052 5052
                 $x = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['width'];
5053
-                if (count(HTML2PDF::$_tables[$param['num']]['height'])>1)
5054
-                    $y = $this->_margeTop+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1];
5055
-                else if (count(HTML2PDF::$_tables[$param['num']]['height'])==1)
5056
-                    $y = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1];
5053
+                if (count(HTML2PDF::$_tables[$param['num']]['height']) > 1)
5054
+                    $y = $this->_margeTop + HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height']) - 1];
5055
+                else if (count(HTML2PDF::$_tables[$param['num']]['height']) == 1)
5056
+                    $y = HTML2PDF::$_tables[$param['num']]['curr_y'] + HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height']) - 1];
5057 5057
                 else
5058 5058
                     $y = HTML2PDF::$_tables[$param['num']]['curr_y'];
5059 5059
 
@@ -5064,7 +5064,7 @@  discard block
 block discarded – undo
5064 5064
 
5065 5065
                 $this->_loadMargin();
5066 5066
 
5067
-                if ($this->_debugActif) $this->_DEBUG_add('Table '.$param['num'], false);
5067
+                if ($this->_debugActif) $this->_DEBUG_add('Table ' . $param['num'], false);
5068 5068
             }
5069 5069
 
5070 5070
             $this->parsingCss->load();
@@ -5084,7 +5084,7 @@  discard block
 block discarded – undo
5084 5084
         protected function _tag_open_COL($param)
5085 5085
         {
5086 5086
             $span = isset($param['span']) ? $param['span'] : 1;
5087
-            for ($k=0; $k<$span; $k++)
5087
+            for ($k = 0; $k < $span; $k++)
5088 5088
                 HTML2PDF::$_tables[$param['num']]['cols'][] = $param;
5089 5089
         }
5090 5090
 
@@ -5122,22 +5122,22 @@  discard block
 block discarded – undo
5122 5122
 
5123 5123
             // position in the table
5124 5124
             HTML2PDF::$_tables[$param['num']]['tr_curr']++;
5125
-            HTML2PDF::$_tables[$param['num']]['td_curr']= 0;
5125
+            HTML2PDF::$_tables[$param['num']]['td_curr'] = 0;
5126 5126
 
5127 5127
             // if we are not in a sub html
5128 5128
             if (!$this->_subPart) {
5129 5129
 
5130 5130
                 // Y after the row
5131
-                $ty=null;
5132
-                for ($ii=0; $ii<count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1]); $ii++) {
5133
-                    $ty = max($ty, HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['h']);
5131
+                $ty = null;
5132
+                for ($ii = 0; $ii < count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1]); $ii++) {
5133
+                    $ty = max($ty, HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][$ii]['h']);
5134 5134
                 }
5135 5135
 
5136 5136
                 // height of the tfoot
5137 5137
                 $hfoot = HTML2PDF::$_tables[$param['num']]['tfoot']['height'];
5138 5138
 
5139 5139
                 // if the line does not fit on the page => new page
5140
-                if (!$this->_isInTfoot && HTML2PDF::$_tables[$param['num']]['td_y'] + HTML2PDF::$_tables[$param['num']]['marge']['b'] + $ty +$hfoot> $this->pdf->getH() - $this->pdf->getbMargin()) {
5140
+                if (!$this->_isInTfoot && HTML2PDF::$_tables[$param['num']]['td_y'] + HTML2PDF::$_tables[$param['num']]['marge']['b'] + $ty + $hfoot > $this->pdf->getH() - $this->pdf->getbMargin()) {
5141 5141
 
5142 5142
                     // fi ther is a tfoot => draw it
5143 5143
                     if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) {
@@ -5154,7 +5154,7 @@  discard block
 block discarded – undo
5154 5154
                         $this->_makeHTMLcode();
5155 5155
                         $this->_isInTfoot = false;
5156 5156
 
5157
-                        $this->_parsePos =     $oldParsePos;
5157
+                        $this->_parsePos = $oldParsePos;
5158 5158
                         $this->parsingHtml->code = $oldParseCode;
5159 5159
                         HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR;
5160 5160
                         HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD;
@@ -5167,7 +5167,7 @@  discard block
 block discarded – undo
5167 5167
                     // new position
5168 5168
                     HTML2PDF::$_tables[$param['num']]['page']++;
5169 5169
                     HTML2PDF::$_tables[$param['num']]['curr_y'] = $this->pdf->getY();
5170
-                    HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['marge']['t'];
5170
+                    HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['curr_y'] + HTML2PDF::$_tables[$param['num']]['marge']['t'];
5171 5171
 
5172 5172
                     // if we have the height of the tbale on the page => draw borders and background
5173 5173
                     if (isset(HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']])) {
@@ -5181,7 +5181,7 @@  discard block
 block discarded – undo
5181 5181
                             HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']],
5182 5182
                             $this->parsingCss->value['border'],
5183 5183
                             $this->parsingCss->value['padding'],
5184
-                            HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5,
5184
+                            HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5,
5185 5185
                             $this->parsingCss->value['background']
5186 5186
                         );
5187 5187
 
@@ -5205,7 +5205,7 @@  discard block
 block discarded – undo
5205 5205
                     $this->_makeHTMLcode();
5206 5206
                     $this->_isInThead = false;
5207 5207
 
5208
-                    $this->_parsePos =     $oldParsePos;
5208
+                    $this->_parsePos = $oldParsePos;
5209 5209
                     $this->parsingHtml->code = $oldParseCode;
5210 5210
                     HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR;
5211 5211
                     HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD;
@@ -5214,12 +5214,12 @@  discard block
 block discarded – undo
5214 5214
             // else (in a sub HTML)
5215 5215
             } else {
5216 5216
                 // prepare it
5217
-                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1] = array();
5217
+                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1] = array();
5218 5218
                 if (!isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']]))
5219 5219
                     HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array();
5220 5220
 
5221
-                HTML2PDF::$_tables[$param['num']]['corr_x']=0;
5222
-                while(isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']]))
5221
+                HTML2PDF::$_tables[$param['num']]['corr_x'] = 0;
5222
+                while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']]))
5223 5223
                     HTML2PDF::$_tables[$param['num']]['corr_x']++;
5224 5224
             }
5225 5225
 
@@ -5246,16 +5246,16 @@  discard block
 block discarded – undo
5246 5246
             if (!$this->_subPart) {
5247 5247
 
5248 5248
                 // Y of the current line
5249
-                $ty=null;
5250
-                for ($ii=0; $ii<count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1]); $ii++) {
5251
-                    if (HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['rowspan']==1) {
5252
-                        $ty = HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['h'];
5249
+                $ty = null;
5250
+                for ($ii = 0; $ii < count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1]); $ii++) {
5251
+                    if (HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][$ii]['rowspan'] == 1) {
5252
+                        $ty = HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][$ii]['h'];
5253 5253
                     }
5254 5254
                 }
5255 5255
 
5256 5256
                 // new position
5257
-                HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['curr_x']+HTML2PDF::$_tables[$param['num']]['marge']['l'];
5258
-                HTML2PDF::$_tables[$param['num']]['td_y']+= $ty;
5257
+                HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['marge']['l'];
5258
+                HTML2PDF::$_tables[$param['num']]['td_y'] += $ty;
5259 5259
                 HTML2PDF::$_tables[$param['num']]['new_page'] = false;
5260 5260
             } else {
5261 5261
                 HTML2PDF::$_tables[$param['num']]['corr_y']++;
@@ -5277,15 +5277,15 @@  discard block
 block discarded – undo
5277 5277
 
5278 5278
             $this->_maxH = 0;
5279 5279
 
5280
-            $param['cellpadding'] = HTML2PDF::$_tables[$param['num']]['cellpadding'].'mm';
5281
-            $param['cellspacing'] = HTML2PDF::$_tables[$param['num']]['cellspacing'].'mm';
5280
+            $param['cellpadding'] = HTML2PDF::$_tables[$param['num']]['cellpadding'] . 'mm';
5281
+            $param['cellspacing'] = HTML2PDF::$_tables[$param['num']]['cellspacing'] . 'mm';
5282 5282
 
5283 5283
             // specific style for LI
5284
-            if ($other=='li') {
5284
+            if ($other == 'li') {
5285 5285
                 $specialLi = true;
5286 5286
             } else {
5287 5287
                 $specialLi = false;
5288
-                if ($other=='li_sub') {
5288
+                if ($other == 'li_sub') {
5289 5289
                     $param['style']['border'] = 'none';
5290 5290
                     $param['style']['background-color']    = 'transparent';
5291 5291
                     $param['style']['background-image']    = 'none';
@@ -5297,7 +5297,7 @@  discard block
 block discarded – undo
5297 5297
 
5298 5298
             // get the properties of the TD
5299 5299
             $x = HTML2PDF::$_tables[$param['num']]['td_curr'];
5300
-            $y = HTML2PDF::$_tables[$param['num']]['tr_curr']-1;
5300
+            $y = HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1;
5301 5301
             $colspan = isset($param['colspan']) ? $param['colspan'] : 1;
5302 5302
             $rowspan = isset($param['rowspan']) ? $param['rowspan'] : 1;
5303 5303
 
@@ -5316,9 +5316,9 @@  discard block
 block discarded – undo
5316 5316
 
5317 5317
                     // for colspans => we get all the neede widths
5318 5318
                     $colParam['style']['width'] = array();
5319
-                    for ($k=0; $k<$colspan; $k++) {
5320
-                        if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol+$k]['style']['width'])) {
5321
-                            $colParam['style']['width'][] = HTML2PDF::$_tables[$param['num']]['cols'][$numCol+$k]['style']['width'];
5319
+                    for ($k = 0; $k < $colspan; $k++) {
5320
+                        if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol + $k]['style']['width'])) {
5321
+                            $colParam['style']['width'][] = HTML2PDF::$_tables[$param['num']]['cols'][$numCol + $k]['style']['width'];
5322 5322
                         }
5323 5323
                     }
5324 5324
 
@@ -5328,10 +5328,10 @@  discard block
 block discarded – undo
5328 5328
                     if (count($colParam['style']['width'])) {
5329 5329
                         $total = $colParam['style']['width'][0]; unset($colParam['style']['width'][0]);
5330 5330
                         foreach ($colParam['style']['width'] as $width) {
5331
-                            if (substr($total, -1)=='%' && substr($width, -1)=='%')
5332
-                                $total = (str_replace('%', '', $total)+str_replace('%', '', $width)).'%';
5331
+                            if (substr($total, -1) == '%' && substr($width, -1) == '%')
5332
+                                $total = (str_replace('%', '', $total) + str_replace('%', '', $width)) . '%';
5333 5333
                             else
5334
-                                $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm';
5334
+                                $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)) . 'mm';
5335 5335
                         }
5336 5336
                     }
5337 5337
 
@@ -5348,7 +5348,7 @@  discard block
 block discarded – undo
5348 5348
 
5349 5349
                     // merge the class of the COL and the TD
5350 5350
                     if (isset($colParam['class'])) {
5351
-                        $param['class'] = $colParam['class'].(isset($param['class']) ? ' '.$param['class'] : '');
5351
+                        $param['class'] = $colParam['class'] . (isset($param['class']) ? ' ' . $param['class'] : '');
5352 5352
                     }
5353 5353
                 }
5354 5354
 
@@ -5377,8 +5377,8 @@  discard block
 block discarded – undo
5377 5377
             $return = $this->parsingCss->analyse($other, $param, $legacy);
5378 5378
 
5379 5379
             if ($specialLi) {
5380
-                $this->parsingCss->value['width']-= $this->parsingCss->ConvertToMM($this->_listeGetWidth());
5381
-                $this->parsingCss->value['width']-= $this->parsingCss->ConvertToMM($this->_listeGetPadding());
5380
+                $this->parsingCss->value['width'] -= $this->parsingCss->ConvertToMM($this->_listeGetWidth());
5381
+                $this->parsingCss->value['width'] -= $this->parsingCss->ConvertToMM($this->_listeGetPadding());
5382 5382
             }
5383 5383
             $this->parsingCss->setPosition();
5384 5384
             $this->parsingCss->fontSet();
@@ -5387,25 +5387,25 @@  discard block
 block discarded – undo
5387 5387
             if ($collapse) {
5388 5388
                 if (!$this->_subPart) {
5389 5389
                     if (
5390
-                        (HTML2PDF::$_tables[$param['num']]['tr_curr']>1 && !HTML2PDF::$_tables[$param['num']]['new_page']) ||
5390
+                        (HTML2PDF::$_tables[$param['num']]['tr_curr'] > 1 && !HTML2PDF::$_tables[$param['num']]['new_page']) ||
5391 5391
                         (!$this->_isInThead && count(HTML2PDF::$_tables[$param['num']]['thead']['code']))
5392 5392
                     ) {
5393 5393
                         $this->parsingCss->value['border']['t'] = $this->parsingCss->readBorder('none');
5394 5394
                     }
5395 5395
                 }
5396 5396
 
5397
-                if (HTML2PDF::$_tables[$param['num']]['td_curr']>0) {
5398
-                    if (!$return) $this->parsingCss->value['width']+= $this->parsingCss->value['border']['l']['width'];
5397
+                if (HTML2PDF::$_tables[$param['num']]['td_curr'] > 0) {
5398
+                    if (!$return) $this->parsingCss->value['width'] += $this->parsingCss->value['border']['l']['width'];
5399 5399
                     $this->parsingCss->value['border']['l'] = $this->parsingCss->readBorder('none');
5400 5400
                 }
5401 5401
             }
5402 5402
 
5403 5403
             // margins of the table
5404 5404
             $marge = array();
5405
-            $marge['t'] = $this->parsingCss->value['padding']['t']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['t']['width'];
5406
-            $marge['r'] = $this->parsingCss->value['padding']['r']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['r']['width'];
5407
-            $marge['b'] = $this->parsingCss->value['padding']['b']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['b']['width'];
5408
-            $marge['l'] = $this->parsingCss->value['padding']['l']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['l']['width'];
5405
+            $marge['t'] = $this->parsingCss->value['padding']['t'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['t']['width'];
5406
+            $marge['r'] = $this->parsingCss->value['padding']['r'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['r']['width'];
5407
+            $marge['b'] = $this->parsingCss->value['padding']['b'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['b']['width'];
5408
+            $marge['l'] = $this->parsingCss->value['padding']['l'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['l']['width'];
5409 5409
 
5410 5410
             // if we are in a sub HTML
5411 5411
             if ($this->_subPart) {
@@ -5421,14 +5421,14 @@  discard block
 block discarded – undo
5421 5421
                 HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Yr'] = HTML2PDF::$_tables[$param['num']]['corr_y'];
5422 5422
 
5423 5423
                 // prepare the mapping for rowspan and colspan
5424
-                for ($j=0; $j<$rowspan; $j++) {
5425
-                    for ($i=0; $i<$colspan; $i++) {
5424
+                for ($j = 0; $j < $rowspan; $j++) {
5425
+                    for ($i = 0; $i < $colspan; $i++) {
5426 5426
                         HTML2PDF::$_tables[$param['num']]['corr']
5427
-                            [HTML2PDF::$_tables[$param['num']]['corr_y']+$j]
5428
-                            [HTML2PDF::$_tables[$param['num']]['corr_x']+$i] = ($i+$j>0) ? '' : array($x,$y,$colspan,$rowspan);
5427
+                            [HTML2PDF::$_tables[$param['num']]['corr_y'] + $j]
5428
+                            [HTML2PDF::$_tables[$param['num']]['corr_x'] + $i] = ($i + $j > 0) ? '' : array($x, $y, $colspan, $rowspan);
5429 5429
                     }
5430 5430
                 }
5431
-                HTML2PDF::$_tables[$param['num']]['corr_x']+= $colspan;
5431
+                HTML2PDF::$_tables[$param['num']]['corr_x'] += $colspan;
5432 5432
                 while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) {
5433 5433
                     HTML2PDF::$_tables[$param['num']]['corr_x']++;
5434 5434
                 }
@@ -5438,11 +5438,11 @@  discard block
 block discarded – undo
5438 5438
                 $this->_createSubHTML($this->_subHtml);
5439 5439
                 $this->_subHtml->parsingHtml->code = $level;
5440 5440
                 $this->_subHtml->_makeHTMLcode();
5441
-                $this->_tempPos+= count($level);
5441
+                $this->_tempPos += count($level);
5442 5442
             } else {
5443 5443
                 // new position in the table
5444 5444
                 HTML2PDF::$_tables[$param['num']]['td_curr']++;
5445
-                HTML2PDF::$_tables[$param['num']]['td_x']+= HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw'];
5445
+                HTML2PDF::$_tables[$param['num']]['td_x'] += HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw'];
5446 5446
 
5447 5447
                 // borders and background of the TD
5448 5448
                 $this->_drawRectangle(
@@ -5452,28 +5452,28 @@  discard block
 block discarded – undo
5452 5452
                     HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'],
5453 5453
                     $this->parsingCss->value['border'],
5454 5454
                     $this->parsingCss->value['padding'],
5455
-                    HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5,
5455
+                    HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5,
5456 5456
                     $this->parsingCss->value['background']
5457 5457
                 );
5458 5458
 
5459 5459
                 $this->parsingCss->value['width'] = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'] - $marge['l'] - $marge['r'];
5460 5460
 
5461 5461
                 // marges = size of the TD
5462
-                $mL = HTML2PDF::$_tables[$param['num']]['td_x']+$marge['l'];
5462
+                $mL = HTML2PDF::$_tables[$param['num']]['td_x'] + $marge['l'];
5463 5463
                 $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width'];
5464 5464
                 $this->_saveMargin($mL, 0, $mR);
5465 5465
 
5466 5466
                 // position of the content, from vertical-align
5467 5467
                 $hCorr = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'];
5468 5468
                 $hReel = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['real_h'];
5469
-                switch($this->parsingCss->value['vertical-align'])
5469
+                switch ($this->parsingCss->value['vertical-align'])
5470 5470
                 {
5471 5471
                     case 'bottom':
5472
-                        $yCorr = $hCorr-$hReel;
5472
+                        $yCorr = $hCorr - $hReel;
5473 5473
                         break;
5474 5474
 
5475 5475
                     case 'middle':
5476
-                        $yCorr = ($hCorr-$hReel)*0.5;
5476
+                        $yCorr = ($hCorr - $hReel) * 0.5;
5477 5477
                         break;
5478 5478
 
5479 5479
                     case 'top':
@@ -5483,8 +5483,8 @@  discard block
 block discarded – undo
5483 5483
                 }
5484 5484
 
5485 5485
                 //  position of the content
5486
-                $x = HTML2PDF::$_tables[$param['num']]['td_x']+$marge['l'];
5487
-                $y = HTML2PDF::$_tables[$param['num']]['td_y']+$marge['t']+$yCorr;
5486
+                $x = HTML2PDF::$_tables[$param['num']]['td_x'] + $marge['l'];
5487
+                $y = HTML2PDF::$_tables[$param['num']]['td_y'] + $marge['t'] + $yCorr;
5488 5488
                 $this->pdf->setXY($x, $y);
5489 5489
                 $this->_setNewPositionForNewLine();
5490 5490
             }
@@ -5507,20 +5507,20 @@  discard block
 block discarded – undo
5507 5507
 
5508 5508
             // get the margins
5509 5509
             $marge = array();
5510
-            $marge['t'] = $this->parsingCss->value['padding']['t']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['t']['width'];
5511
-            $marge['r'] = $this->parsingCss->value['padding']['r']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['r']['width'];
5512
-            $marge['b'] = $this->parsingCss->value['padding']['b']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['b']['width'];
5513
-            $marge['l'] = $this->parsingCss->value['padding']['l']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['l']['width'];
5514
-            $marge['t']+= 0.001;
5515
-            $marge['r']+= 0.001;
5516
-            $marge['b']+= 0.001;
5517
-            $marge['l']+= 0.001;
5510
+            $marge['t'] = $this->parsingCss->value['padding']['t'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['t']['width'];
5511
+            $marge['r'] = $this->parsingCss->value['padding']['r'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['r']['width'];
5512
+            $marge['b'] = $this->parsingCss->value['padding']['b'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['b']['width'];
5513
+            $marge['l'] = $this->parsingCss->value['padding']['l'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['l']['width'];
5514
+            $marge['t'] += 0.001;
5515
+            $marge['r'] += 0.001;
5516
+            $marge['b'] += 0.001;
5517
+            $marge['l'] += 0.001;
5518 5518
 
5519 5519
             // if we are in a sub HTML
5520 5520
             if ($this->_subPart) {
5521 5521
 
5522 5522
                 // it msut take only one page
5523
-                if ($this->_testTdInOnepage && $this->_subHtml->pdf->getPage()>1) {
5523
+                if ($this->_testTdInOnepage && $this->_subHtml->pdf->getPage() > 1) {
5524 5524
                     throw new HTML2PDF_exception(7);
5525 5525
                 }
5526 5526
 
@@ -5533,19 +5533,19 @@  discard block
 block discarded – undo
5533 5533
                 $h2 = $this->parsingCss->value['height'] + $marge['t'] + $marge['b'];
5534 5534
 
5535 5535
                 // final size of the TD
5536
-                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['w'] = max(array($w0, $w2));
5537
-                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['h'] = max(array($h0, $h2));
5536
+                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['w'] = max(array($w0, $w2));
5537
+                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['h'] = max(array($h0, $h2));
5538 5538
 
5539 5539
                 // real position of the content
5540
-                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['real_w'] = $w0;
5541
-                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['real_h'] = $h0;
5540
+                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['real_w'] = $w0;
5541
+                HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['real_h'] = $h0;
5542 5542
 
5543 5543
                 // destroy the sub HTML
5544 5544
                 $this->_destroySubHTML($this->_subHtml);
5545 5545
             } else {
5546 5546
                 $this->_loadMargin();
5547 5547
 
5548
-                HTML2PDF::$_tables[$param['num']]['td_x']+= HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['w'];
5548
+                HTML2PDF::$_tables[$param['num']]['td_x'] += HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['w'];
5549 5549
             }
5550 5550
 
5551 5551
             $this->parsingCss->load();
@@ -5601,10 +5601,10 @@  discard block
 block discarded – undo
5601 5601
          */
5602 5602
         protected function _tag_open_IMG($param)
5603 5603
         {
5604
-            $src    = str_replace('&amp;', '&', $param['src']);
5604
+            $src = str_replace('&amp;', '&', $param['src']);
5605 5605
 
5606 5606
             $this->parsingCss->save();
5607
-            $this->parsingCss->value['width']    = 0;
5607
+            $this->parsingCss->value['width'] = 0;
5608 5608
             $this->parsingCss->value['height']    = 0;
5609 5609
             $this->parsingCss->value['border']    = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0));
5610 5610
             $this->parsingCss->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null);
@@ -5632,7 +5632,7 @@  discard block
 block discarded – undo
5632 5632
         protected function _tag_open_SELECT($param)
5633 5633
         {
5634 5634
             if (!isset($param['name'])) {
5635
-                $param['name'] = 'champs_pdf_'.(count($this->_lstField)+1);
5635
+                $param['name'] = 'champs_pdf_' . (count($this->_lstField) + 1);
5636 5636
             }
5637 5637
 
5638 5638
             $param['name'] = strtolower($param['name']);
@@ -5650,11 +5650,11 @@  discard block
 block discarded – undo
5650 5650
 
5651 5651
             $this->_lstSelect = array();
5652 5652
             $this->_lstSelect['name']    = $param['name'];
5653
-            $this->_lstSelect['multi']    = isset($param['multiple']) ? true : false;
5653
+            $this->_lstSelect['multi'] = isset($param['multiple']) ? true : false;
5654 5654
             $this->_lstSelect['size']    = isset($param['size']) ? $param['size'] : 1;
5655
-            $this->_lstSelect['options']    = array();
5655
+            $this->_lstSelect['options'] = array();
5656 5656
 
5657
-            if ($this->_lstSelect['multi'] && $this->_lstSelect['size']<3) $this->_lstSelect['size'] = 3;
5657
+            if ($this->_lstSelect['multi'] && $this->_lstSelect['size'] < 3) $this->_lstSelect['size'] = 3;
5658 5658
 
5659 5659
             return true;
5660 5660
         }
@@ -5670,8 +5670,8 @@  discard block
 block discarded – undo
5670 5670
         {
5671 5671
             // get the content of the option : it is the text of the option
5672 5672
             $level = $this->parsingHtml->getLevel($this->_parsePos);
5673
-            $this->_parsePos+= count($level);
5674
-            $value = isset($param['value']) ? $param['value'] : 'aut_tag_open_opt_'.(count($this->_lstSelect)+1);
5673
+            $this->_parsePos += count($level);
5674
+            $value = isset($param['value']) ? $param['value'] : 'aut_tag_open_opt_' . (count($this->_lstSelect) + 1);
5675 5675
 
5676 5676
             $this->_lstSelect['options'][$value] = isset($level[0]['param']['txt']) ? $level[0]['param']['txt'] : '';
5677 5677
 
@@ -5704,13 +5704,13 @@  discard block
 block discarded – undo
5704 5704
             // position of the select
5705 5705
             $x = $this->pdf->getX();
5706 5706
             $y = $this->pdf->getY();
5707
-            $f = 1.08*$this->parsingCss->value['font-size'];
5707
+            $f = 1.08 * $this->parsingCss->value['font-size'];
5708 5708
 
5709 5709
             // width
5710 5710
             $w = $this->parsingCss->value['width']; if (!$w) $w = 50;
5711 5711
 
5712 5712
             // height (automatic)
5713
-            $h = ($f*1.07*$this->_lstSelect['size'] + 1);
5713
+            $h = ($f * 1.07 * $this->_lstSelect['size'] + 1);
5714 5714
 
5715 5715
             $prop = $this->parsingCss->getFormStyle();
5716 5716
 
@@ -5721,17 +5721,17 @@  discard block
 block discarded – undo
5721 5721
 
5722 5722
 
5723 5723
             // single or multi select
5724
-            if ($this->_lstSelect['size']>1) {
5724
+            if ($this->_lstSelect['size'] > 1) {
5725 5725
                 $this->pdf->ListBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop);
5726 5726
             } else {
5727 5727
                 $this->pdf->ComboBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop);
5728 5728
             }
5729 5729
 
5730
-            $this->_maxX = max($this->_maxX, $x+$w);
5731
-            $this->_maxY = max($this->_maxY, $y+$h);
5730
+            $this->_maxX = max($this->_maxX, $x + $w);
5731
+            $this->_maxY = max($this->_maxY, $y + $h);
5732 5732
             $this->_maxH = max($this->_maxH, $h);
5733 5733
             $this->_maxE++;
5734
-            $this->pdf->setX($x+$w);
5734
+            $this->pdf->setX($x + $w);
5735 5735
 
5736 5736
             $this->parsingCss->load();
5737 5737
             $this->parsingCss->fontSet();
@@ -5751,7 +5751,7 @@  discard block
 block discarded – undo
5751 5751
         protected function _tag_open_TEXTAREA($param)
5752 5752
         {
5753 5753
             if (!isset($param['name'])) {
5754
-                $param['name'] = 'champs_pdf_'.(count($this->_lstField)+1);
5754
+                $param['name'] = 'champs_pdf_' . (count($this->_lstField) + 1);
5755 5755
             }
5756 5756
 
5757 5757
             $param['name'] = strtolower($param['name']);
@@ -5769,16 +5769,16 @@  discard block
 block discarded – undo
5769 5769
 
5770 5770
             $x = $this->pdf->getX();
5771 5771
             $y = $this->pdf->getY();
5772
-            $fx = 0.65*$this->parsingCss->value['font-size'];
5773
-            $fy = 1.08*$this->parsingCss->value['font-size'];
5772
+            $fx = 0.65 * $this->parsingCss->value['font-size'];
5773
+            $fy = 1.08 * $this->parsingCss->value['font-size'];
5774 5774
 
5775 5775
             // extract the content the textarea : value
5776 5776
             $level = $this->parsingHtml->getLevel($this->_parsePos);
5777
-            $this->_parsePos+= count($level);
5777
+            $this->_parsePos += count($level);
5778 5778
 
5779 5779
             // automatic size, from cols and rows properties
5780
-            $w = $fx*(isset($param['cols']) ? $param['cols'] : 22)+1;
5781
-            $h = $fy*1.07*(isset($param['rows']) ? $param['rows'] : 3)+3;
5780
+            $w = $fx * (isset($param['cols']) ? $param['cols'] : 22) + 1;
5781
+            $h = $fy * 1.07 * (isset($param['rows']) ? $param['rows'] : 3) + 3;
5782 5782
 
5783 5783
             $prop = $this->parsingCss->getFormStyle();
5784 5784
 
@@ -5787,11 +5787,11 @@  discard block
 block discarded – undo
5787 5787
 
5788 5788
             $this->pdf->TextField($param['name'], $w, $h, $prop, array(), $x, $y);
5789 5789
 
5790
-            $this->_maxX = max($this->_maxX, $x+$w);
5791
-            $this->_maxY = max($this->_maxY, $y+$h);
5790
+            $this->_maxX = max($this->_maxX, $x + $w);
5791
+            $this->_maxY = max($this->_maxY, $y + $h);
5792 5792
             $this->_maxH = max($this->_maxH, $h);
5793 5793
             $this->_maxE++;
5794
-            $this->pdf->setX($x+$w);
5794
+            $this->pdf->setX($x + $w);
5795 5795
 
5796 5796
             return true;
5797 5797
         }
@@ -5820,7 +5820,7 @@  discard block
 block discarded – undo
5820 5820
          */
5821 5821
         protected function _tag_open_INPUT($param)
5822 5822
         {
5823
-            if (!isset($param['name']))  $param['name']  = 'champs_pdf_'.(count($this->_lstField)+1);
5823
+            if (!isset($param['name']))  $param['name']  = 'champs_pdf_' . (count($this->_lstField) + 1);
5824 5824
             if (!isset($param['value'])) $param['value'] = '';
5825 5825
             if (!isset($param['type']))  $param['type']  = 'text';
5826 5826
 
@@ -5847,25 +5847,25 @@  discard block
 block discarded – undo
5847 5847
 
5848 5848
             $x = $this->pdf->getX();
5849 5849
             $y = $this->pdf->getY();
5850
-            $f = 1.08*$this->parsingCss->value['font-size'];
5850
+            $f = 1.08 * $this->parsingCss->value['font-size'];
5851 5851
 
5852 5852
             $prop = $this->parsingCss->getFormStyle();
5853 5853
 
5854
-            switch($param['type'])
5854
+            switch ($param['type'])
5855 5855
             {
5856 5856
                 case 'checkbox':
5857 5857
                     $w = 3;
5858 5858
                     $h = $w;
5859
-                    if ($h<$f) $y+= ($f-$h)*0.5;
5860
-                    $checked = (isset($param['checked']) && $param['checked']=='checked');
5859
+                    if ($h < $f) $y += ($f - $h) * 0.5;
5860
+                    $checked = (isset($param['checked']) && $param['checked'] == 'checked');
5861 5861
                     $this->pdf->CheckBox($name, $w, $checked, $prop, array(), ($param['value'] ? $param['value'] : 'Yes'), $x, $y);
5862 5862
                     break;
5863 5863
 
5864 5864
                 case 'radio':
5865 5865
                     $w = 3;
5866 5866
                     $h = $w;
5867
-                    if ($h<$f) $y+= ($f-$h)*0.5;
5868
-                    $checked = (isset($param['checked']) && $param['checked']=='checked');
5867
+                    if ($h < $f) $y += ($f - $h) * 0.5;
5868
+                    $checked = (isset($param['checked']) && $param['checked'] == 'checked');
5869 5869
                     $this->pdf->RadioButton($name, $w, $prop, array(), ($param['value'] ? $param['value'] : 'On'), $checked, $x, $y);
5870 5870
                     break;
5871 5871
 
@@ -5878,28 +5878,28 @@  discard block
 block discarded – undo
5878 5878
 
5879 5879
                 case 'text':
5880 5880
                     $w = $this->parsingCss->value['width']; if (!$w) $w = 40;
5881
-                    $h = $f*1.3;
5881
+                    $h = $f * 1.3;
5882 5882
                     $prop['value'] = $param['value'];
5883 5883
                     $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y);
5884 5884
                     break;
5885 5885
 
5886 5886
                 case 'submit':
5887
-                    $w = $this->parsingCss->value['width'];    if (!$w) $w = 40;
5888
-                    $h = $this->parsingCss->value['height'];    if (!$h) $h = $f*1.3;
5887
+                    $w = $this->parsingCss->value['width']; if (!$w) $w = 40;
5888
+                    $h = $this->parsingCss->value['height']; if (!$h) $h = $f * 1.3;
5889 5889
                     $action = array('S'=>'SubmitForm', 'F'=>$this->_isInForm, 'Flags'=>array('ExportFormat'));
5890 5890
                     $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
5891 5891
                     break;
5892 5892
 
5893 5893
                 case 'reset':
5894
-                    $w = $this->parsingCss->value['width'];    if (!$w) $w = 40;
5895
-                    $h = $this->parsingCss->value['height'];    if (!$h) $h = $f*1.3;
5894
+                    $w = $this->parsingCss->value['width']; if (!$w) $w = 40;
5895
+                    $h = $this->parsingCss->value['height']; if (!$h) $h = $f * 1.3;
5896 5896
                     $action = array('S'=>'ResetForm');
5897 5897
                     $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
5898 5898
                     break;
5899 5899
 
5900 5900
                 case 'button':
5901
-                    $w = $this->parsingCss->value['width'];    if (!$w) $w = 40;
5902
-                    $h = $this->parsingCss->value['height'];    if (!$h) $h = $f*1.3;
5901
+                    $w = $this->parsingCss->value['width']; if (!$w) $w = 40;
5902
+                    $h = $this->parsingCss->value['height']; if (!$h) $h = $f * 1.3;
5903 5903
                     $action = isset($param['onclick']) ? $param['onclick'] : '';
5904 5904
                     $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
5905 5905
                     break;
@@ -5910,11 +5910,11 @@  discard block
 block discarded – undo
5910 5910
                     break;
5911 5911
             }
5912 5912
 
5913
-            $this->_maxX = max($this->_maxX, $x+$w);
5914
-            $this->_maxY = max($this->_maxY, $y+$h);
5913
+            $this->_maxX = max($this->_maxX, $x + $w);
5914
+            $this->_maxY = max($this->_maxY, $y + $h);
5915 5915
             $this->_maxH = max($this->_maxH, $h);
5916 5916
             $this->_maxE++;
5917
-            $this->pdf->setX($x+$w);
5917
+            $this->pdf->setX($x + $w);
5918 5918
 
5919 5919
             $this->parsingCss->load();
5920 5920
             $this->parsingCss->fontSet();
@@ -5952,14 +5952,14 @@  discard block
 block discarded – undo
5952 5952
 
5953 5953
             if (!$this->parsingCss->value['position']) {
5954 5954
                 if (
5955
-                    $w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) &&
5956
-                    $this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin())
5955
+                    $w < ($this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin()) &&
5956
+                    $this->pdf->getX() + $w >= ($this->pdf->getW() - $this->pdf->getrMargin())
5957 5957
                     )
5958 5958
                     $this->_tag_open_BR(array());
5959 5959
 
5960 5960
                 if (
5961
-                        ($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) &&
5962
-                        ($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) &&
5961
+                        ($h < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin())) &&
5962
+                        ($this->pdf->getY() + $h >= ($this->pdf->getH() - $this->pdf->getbMargin())) &&
5963 5963
                         !$this->_isInOverflow
5964 5964
                     )
5965 5965
                     $this->_setNewPage();
@@ -5967,9 +5967,9 @@  discard block
 block discarded – undo
5967 5967
                 $old = $this->parsingCss->getOldValues();
5968 5968
                 $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
5969 5969
 
5970
-                if ($parentWidth>$w) {
5971
-                    if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
5972
-                    else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
5970
+                if ($parentWidth > $w) {
5971
+                    if ($alignObject == 'center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5);
5972
+                    else if ($alignObject == 'right')    $this->pdf->setX($this->pdf->getX() + $parentWidth - $w);
5973 5973
                 }
5974 5974
 
5975 5975
                 $this->parsingCss->setPosition();
@@ -5977,9 +5977,9 @@  discard block
 block discarded – undo
5977 5977
                 $old = $this->parsingCss->getOldValues();
5978 5978
                 $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
5979 5979
 
5980
-                if ($parentWidth>$w) {
5981
-                    if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
5982
-                    else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
5980
+                if ($parentWidth > $w) {
5981
+                    if ($alignObject == 'center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5);
5982
+                    else if ($alignObject == 'right')    $this->pdf->setX($this->pdf->getX() + $parentWidth - $w);
5983 5983
                 }
5984 5984
 
5985 5985
                 $this->parsingCss->setPosition();
@@ -6007,27 +6007,27 @@  discard block
 block discarded – undo
6007 6007
             $marge['t'] = $this->parsingCss->value['border']['t']['width'];
6008 6008
             $marge['b'] = $this->parsingCss->value['border']['b']['width'];
6009 6009
 
6010
-            $this->parsingCss->value['width'] -= $marge['l']+$marge['r'];
6011
-            $this->parsingCss->value['height']-= $marge['t']+$marge['b'];
6010
+            $this->parsingCss->value['width'] -= $marge['l'] + $marge['r'];
6011
+            $this->parsingCss->value['height'] -= $marge['t'] + $marge['b'];
6012 6012
 
6013
-            $overW-= $marge['l']+$marge['r'];
6014
-            $overH-= $marge['t']+$marge['b'];
6013
+            $overW -= $marge['l'] + $marge['r'];
6014
+            $overH -= $marge['t'] + $marge['b'];
6015 6015
 
6016 6016
             // clipping to draw only in the size opf the DRAW tag
6017 6017
             $this->pdf->clippingPathStart(
6018
-                $this->parsingCss->value['x']+$marge['l'],
6019
-                $this->parsingCss->value['y']+$marge['t'],
6018
+                $this->parsingCss->value['x'] + $marge['l'],
6019
+                $this->parsingCss->value['y'] + $marge['t'],
6020 6020
                 $this->parsingCss->value['width'],
6021 6021
                 $this->parsingCss->value['height']
6022 6022
             );
6023 6023
 
6024 6024
             // left and right of the DRAW tag
6025
-            $mL = $this->parsingCss->value['x']+$marge['l'];
6025
+            $mL = $this->parsingCss->value['x'] + $marge['l'];
6026 6026
             $mR = $this->pdf->getW() - $mL - $overW;
6027 6027
 
6028 6028
             // position of the DRAW tag
6029
-            $x = $this->parsingCss->value['x']+$marge['l'];
6030
-            $y = $this->parsingCss->value['y']+$marge['t'];
6029
+            $x = $this->parsingCss->value['x'] + $marge['l'];
6030
+            $y = $this->parsingCss->value['y'] + $marge['t'];
6031 6031
 
6032 6032
             // prepare the drawing area
6033 6033
             $this->_saveMargin($mL, 0, $mR);
@@ -6042,7 +6042,7 @@  discard block
 block discarded – undo
6042 6042
             );
6043 6043
 
6044 6044
             // init the translate matrix : (0,0) => ($x, $y)
6045
-            $this->pdf->doTransform(array(1,0,0,1,$x,$y));
6045
+            $this->pdf->doTransform(array(1, 0, 0, 1, $x, $y));
6046 6046
             $this->pdf->SetAlpha(1.);
6047 6047
             return true;
6048 6048
         }
@@ -6074,14 +6074,14 @@  discard block
 block discarded – undo
6074 6074
 
6075 6075
             $x = $this->parsingCss->value['x'];
6076 6076
             $y = $this->parsingCss->value['y'];
6077
-            $w = $this->parsingCss->value['width']+$marge['l']+$marge['r'];
6078
-            $h = $this->parsingCss->value['height']+$marge['t']+$marge['b'];
6077
+            $w = $this->parsingCss->value['width'] + $marge['l'] + $marge['r'];
6078
+            $h = $this->parsingCss->value['height'] + $marge['t'] + $marge['b'];
6079 6079
 
6080
-            if ($this->parsingCss->value['position']!='absolute') {
6081
-                $this->pdf->setXY($x+$w, $y);
6080
+            if ($this->parsingCss->value['position'] != 'absolute') {
6081
+                $this->pdf->setXY($x + $w, $y);
6082 6082
 
6083
-                $this->_maxX = max($this->_maxX, $x+$w);
6084
-                $this->_maxY = max($this->_maxY, $y+$h);
6083
+                $this->_maxX = max($this->_maxX, $x + $w);
6084
+                $this->_maxY = max($this->_maxY, $y + $h);
6085 6085
                 $this->_maxH = max($this->_maxH, $h);
6086 6086
                 $this->_maxE++;
6087 6087
             } else {
@@ -6091,7 +6091,7 @@  discard block
 block discarded – undo
6091 6091
                 $this->_loadMax();
6092 6092
             }
6093 6093
 
6094
-            $block = ($this->parsingCss->value['display']!='inline' && $this->parsingCss->value['position']!='absolute');
6094
+            $block = ($this->parsingCss->value['display'] != 'inline' && $this->parsingCss->value['position'] != 'absolute');
6095 6095
 
6096 6096
             $this->parsingCss->load();
6097 6097
             $this->parsingCss->fontSet();
@@ -6236,16 +6236,16 @@  discard block
 block discarded – undo
6236 6236
                 $path = explode(' ', $path);
6237 6237
                 foreach ($path as $k => $v) {
6238 6238
                     $path[$k] = trim($v);
6239
-                    if ($path[$k]==='') unset($path[$k]);
6239
+                    if ($path[$k] === '') unset($path[$k]);
6240 6240
                 }
6241 6241
                 $path = array_values($path);
6242 6242
 
6243 6243
                 $actions = array();
6244
-                for ($k=0; $k<count($path); $k+=2) {
6244
+                for ($k = 0; $k < count($path); $k += 2) {
6245 6245
                     $actions[] = array(
6246
-                        ($k ? 'L' : 'M') ,
6247
-                        $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']),
6248
-                        $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h'])
6246
+                        ($k ? 'L' : 'M'),
6247
+                        $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']),
6248
+                        $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h'])
6249 6249
                     );
6250 6250
                 }
6251 6251
 
@@ -6282,16 +6282,16 @@  discard block
 block discarded – undo
6282 6282
                 $path = explode(' ', $path);
6283 6283
                 foreach ($path as $k => $v) {
6284 6284
                     $path[$k] = trim($v);
6285
-                    if ($path[$k]==='') unset($path[$k]);
6285
+                    if ($path[$k] === '') unset($path[$k]);
6286 6286
                 }
6287 6287
                 $path = array_values($path);
6288 6288
 
6289 6289
                 $actions = array();
6290
-                for ($k=0; $k<count($path); $k+=2) {
6290
+                for ($k = 0; $k < count($path); $k += 2) {
6291 6291
                     $actions[] = array(
6292
-                        ($k ? 'L' : 'M') ,
6293
-                        $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']),
6294
-                        $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h'])
6292
+                        ($k ? 'L' : 'M'),
6293
+                        $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']),
6294
+                        $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h'])
6295 6295
                     );
6296 6296
                 }
6297 6297
                 $actions[] = array('z');
@@ -6333,7 +6333,7 @@  discard block
 block discarded – undo
6333 6333
                 $path = explode(' ', $path);
6334 6334
                 foreach ($path as $k => $v) {
6335 6335
                     $path[$k] = trim($v);
6336
-                    if ($path[$k]==='') unset($path[$k]);
6336
+                    if ($path[$k] === '') unset($path[$k]);
6337 6337
                 }
6338 6338
                 $path = array_values($path);
6339 6339
 
@@ -6341,7 +6341,7 @@  discard block
 block discarded – undo
6341 6341
                 $actions = array();
6342 6342
                 $action = array();
6343 6343
                 $lastAction = null; // last action found
6344
-                for ($k=0; $k<count($path);true) {
6344
+                for ($k = 0; $k < count($path); true) {
6345 6345
 
6346 6346
                     // for this actions, we can not have multi coordonate
6347 6347
                     if (in_array($lastAction, array('z', 'Z'))) {
@@ -6349,7 +6349,7 @@  discard block
 block discarded – undo
6349 6349
                     }
6350 6350
 
6351 6351
                     // read the new action (forcing if no action before)
6352
-                    if (preg_match('/^[a-z]+$/i', $path[$k]) || $lastAction===null) {
6352
+                    if (preg_match('/^[a-z]+$/i', $path[$k]) || $lastAction === null) {
6353 6353
                         $lastAction = $path[$k];
6354 6354
                         $k++;
6355 6355
                     }
@@ -6357,40 +6357,40 @@  discard block
 block discarded – undo
6357 6357
                     // current action
6358 6358
                     $action = array();
6359 6359
                     $action[] = $lastAction;
6360
-                    switch($lastAction)
6360
+                    switch ($lastAction)
6361 6361
                     {
6362 6362
                         case 'C':
6363 6363
                         case 'c':
6364
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // x1
6365
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']);    // y1
6366
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+2], $this->_isInDraw['w']);    // x2
6367
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+3], $this->_isInDraw['h']);    // y2
6368
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+4], $this->_isInDraw['w']);    // x
6369
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+5], $this->_isInDraw['h']);    // y
6370
-                            $k+= 6;
6364
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x1
6365
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y1
6366
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 2], $this->_isInDraw['w']); // x2
6367
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 3], $this->_isInDraw['h']); // y2
6368
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 4], $this->_isInDraw['w']); // x
6369
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 5], $this->_isInDraw['h']); // y
6370
+                            $k += 6;
6371 6371
                             break;
6372 6372
 
6373 6373
                         case 'Q':
6374 6374
                         case 'S':
6375 6375
                         case 'q':
6376 6376
                         case 's':
6377
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // x2
6378
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']);    // y2
6379
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+2], $this->_isInDraw['w']);    // x
6380
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+3], $this->_isInDraw['h']);    // y
6381
-                            $k+= 4;
6377
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x2
6378
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y2
6379
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 2], $this->_isInDraw['w']); // x
6380
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 3], $this->_isInDraw['h']); // y
6381
+                            $k += 4;
6382 6382
                             break;
6383 6383
 
6384 6384
                         case 'A':
6385 6385
                         case 'a':
6386
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // rx
6387
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']);    // ry
6388
-                            $action[] = 1.*$path[$k+2];                                                        // angle de deviation de l'axe X
6389
-                            $action[] = ($path[$k+3]=='1') ? 1 : 0;                                            // large-arc-flag
6390
-                            $action[] = ($path[$k+4]=='1') ? 1 : 0;                                            // sweep-flag
6391
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+5], $this->_isInDraw['w']);    // x
6392
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+6], $this->_isInDraw['h']);    // y
6393
-                            $k+= 7;
6386
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // rx
6387
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // ry
6388
+                            $action[] = 1. * $path[$k + 2]; // angle de deviation de l'axe X
6389
+                            $action[] = ($path[$k + 3] == '1') ? 1 : 0; // large-arc-flag
6390
+                            $action[] = ($path[$k + 4] == '1') ? 1 : 0; // sweep-flag
6391
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 5], $this->_isInDraw['w']); // x
6392
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 6], $this->_isInDraw['h']); // y
6393
+                            $k += 7;
6394 6394
                             break;
6395 6395
 
6396 6396
                         case 'M':
@@ -6399,21 +6399,21 @@  discard block
 block discarded – undo
6399 6399
                         case 'm':
6400 6400
                         case 'l':
6401 6401
                         case 't':
6402
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // x
6403
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']);    // y
6404
-                            $k+= 2;
6402
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x
6403
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y
6404
+                            $k += 2;
6405 6405
                             break;
6406 6406
 
6407 6407
                         case 'H':
6408 6408
                         case 'h':
6409
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']);    // x
6410
-                            $k+= 1;
6409
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x
6410
+                            $k += 1;
6411 6411
                             break;
6412 6412
 
6413 6413
                         case 'V':
6414 6414
                         case 'v':
6415
-                            $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['h']);    // y
6416
-                            $k+= 1;
6415
+                            $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['h']); // y
6416
+                            $k += 1;
6417 6417
                             break;
6418 6418
 
6419 6419
                         case 'z':
Please login to merge, or discard this patch.
Braces   +865 added lines, -323 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 - main class
4 6
  *
@@ -162,7 +164,9 @@  discard block
 block discarded – undo
162 164
             $this->_subPart = false;
163 165
 
164 166
             // init the marges of the page
165
-            if (!is_array($marges)) $marges = array($marges, $marges, $marges, $marges);
167
+            if (!is_array($marges)) {
168
+            	$marges = array($marges, $marges, $marges, $marges);
169
+            }
166 170
             $this->_setDefaultMargins($marges[0], $marges[1], $marges[2], $marges[3]);
167 171
             $this->_setMargins();
168 172
             $this->_marges = array();
@@ -310,7 +314,9 @@  discard block
 block discarded – undo
310 314
         {
311 315
             $oldPage = $this->_INDEX_NewPage($onPage);
312 316
             $this->pdf->createIndex($this, $titre, $sizeTitle, $sizeBookmark, $bookmarkTitle, $displayPage, $onPage, $fontName);
313
-            if ($oldPage) $this->pdf->setPage($oldPage);
317
+            if ($oldPage) {
318
+            	$this->pdf->setPage($oldPage);
319
+            }
314 320
         }
315 321
 
316 322
         /**
@@ -356,14 +362,24 @@  discard block
 block discarded – undo
356 362
             }
357 363
 
358 364
             // complete parameters
359
-            if ($dest===false) $dest = 'I';
360
-            if ($dest===true)  $dest = 'S';
361
-            if ($dest==='')    $dest = 'I';
362
-            if ($name=='')     $name='document.pdf';
365
+            if ($dest===false) {
366
+            	$dest = 'I';
367
+            }
368
+            if ($dest===true) {
369
+            	$dest = 'S';
370
+            }
371
+            if ($dest==='') {
372
+            	$dest = 'I';
373
+            }
374
+            if ($name=='') {
375
+            	$name='document.pdf';
376
+            }
363 377
 
364 378
             // clean up the destination
365 379
             $dest = strtoupper($dest);
366
-            if (!in_array($dest, array('I', 'D', 'F', 'S', 'FI','FD'))) $dest = 'I';
380
+            if (!in_array($dest, array('I', 'D', 'F', 'S', 'FI','FD'))) {
381
+            	$dest = 'I';
382
+            }
367 383
 
368 384
             // the name must be a PDF name
369 385
             if (strtolower(substr($name, -4))!='.pdf') {
@@ -385,8 +401,9 @@  discard block
 block discarded – undo
385 401
         public function writeHTML($html, $debugVue = false)
386 402
         {
387 403
             // if it is a real html page, we have to convert it
388
-            if (preg_match('/<body/isU', $html))
389
-                $html = $this->getHtmlFromPage($html);
404
+            if (preg_match('/<body/isU', $html)) {
405
+                            $html = $this->getHtmlFromPage($html);
406
+            }
390 407
 
391 408
             $html = str_replace('[[date_y]]', date('Y'), $html);
392 409
             $html = str_replace('[[date_m]]', date('m'), $html);
@@ -422,20 +439,24 @@  discard block
 block discarded – undo
422 439
 
423 440
             // extract the content
424 441
             $res = explode('<body', $html);
425
-            if (count($res)<2) return $html;
442
+            if (count($res)<2) {
443
+            	return $html;
444
+            }
426 445
             $content = '<page'.$res[1];
427 446
             $content = explode('</body', $content);
428 447
             $content = $content[0].'</page>';
429 448
 
430 449
             // extract the link tags
431 450
             preg_match_all('/<link([^>]*)>/isU', $html, $match);
432
-            foreach ($match[0] as $src)
433
-                $content = $src.'</link>'.$content;
451
+            foreach ($match[0] as $src) {
452
+                            $content = $src.'</link>'.$content;
453
+            }
434 454
 
435 455
             // extract the css style tags
436 456
             preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match);
437
-            foreach ($match[0] as $src)
438
-                $content = $src.$content;
457
+            foreach ($match[0] as $src) {
458
+                            $content = $src.$content;
459
+            }
439 460
 
440 461
             return $content;
441 462
         }
@@ -513,8 +534,12 @@  discard block
 block discarded – undo
513 534
          */
514 535
         protected function _setDefaultMargins($left, $top, $right = null, $bottom = null)
515 536
         {
516
-            if ($right===null)  $right = $left;
517
-            if ($bottom===null) $bottom = 8;
537
+            if ($right===null) {
538
+            	$right = $left;
539
+            }
540
+            if ($bottom===null) {
541
+            	$bottom = 8;
542
+            }
518 543
 
519 544
             $this->_defaultLeft   = $this->parsingCss->ConvertToMM($left.'mm');
520 545
             $this->_defaultTop    = $this->parsingCss->ConvertToMM($top.'mm');
@@ -565,8 +590,9 @@  discard block
 block discarded – undo
565 590
                         $this->pdf->Rect(0, 0, $this->pdf->getW(), $this->pdf->getH(), 'F');
566 591
                     }
567 592
 
568
-                    if (isset($this->_background['img']) && $this->_background['img'])
569
-                        $this->pdf->Image($this->_background['img'], $this->_background['posX'], $this->_background['posY'], $this->_background['width']);
593
+                    if (isset($this->_background['img']) && $this->_background['img']) {
594
+                                            $this->pdf->Image($this->_background['img'], $this->_background['posX'], $this->_background['posY'], $this->_background['width']);
595
+                    }
570 596
                 }
571 597
 
572 598
                 $this->_setPageHeader();
@@ -617,7 +643,9 @@  discard block
 block discarded – undo
617 643
         protected function _DEBUG_add($name, $level=null)
618 644
         {
619 645
             // if true : UP
620
-            if ($level===true) $this->_debugLevel++;
646
+            if ($level===true) {
647
+            	$this->_debugLevel++;
648
+            }
621 649
 
622 650
             $name   = str_repeat('  ', $this->_debugLevel). $name.($level===true ? ' Begin' : ($level===false ? ' End' : ''));
623 651
             $time  = microtime(true);
@@ -635,7 +663,9 @@  discard block
 block discarded – undo
635 663
             $this->_debugLastTime = $time;
636 664
 
637 665
             // it false : DOWN
638
-            if ($level===false) $this->_debugLevel--;
666
+            if ($level===false) {
667
+            	$this->_debugLevel--;
668
+            }
639 669
 
640 670
             return $this;
641 671
         }
@@ -674,8 +704,9 @@  discard block
 block discarded – undo
674 704
             $y = floor($y*100);
675 705
             $x = array($this->pdf->getlMargin(), $this->pdf->getW()-$this->pdf->getrMargin());
676 706
 
677
-            foreach ($this->_pageMarges as $mY => $mX)
678
-                if ($mY<=$y) $x = $mX;
707
+            foreach ($this->_pageMarges as $mY => $mX) {
708
+                            if ($mY<=$y) $x = $mX;
709
+            }
679 710
 
680 711
             return $x;
681 712
         }
@@ -697,18 +728,30 @@  discard block
 block discarded – undo
697 728
             $oldBottom = $this->_getMargins($yBottom);
698 729
 
699 730
             // update the top float margin
700
-            if ($float=='left'  && $oldTop[0]<$xRight) $oldTop[0] = $xRight;
701
-            if ($float=='right' && $oldTop[1]>$xLeft)  $oldTop[1] = $xLeft;
731
+            if ($float=='left'  && $oldTop[0]<$xRight) {
732
+            	$oldTop[0] = $xRight;
733
+            }
734
+            if ($float=='right' && $oldTop[1]>$xLeft) {
735
+            	$oldTop[1] = $xLeft;
736
+            }
702 737
 
703 738
             $yTop = floor($yTop*100);
704 739
             $yBottom = floor($yBottom*100);
705 740
 
706 741
             // erase all the float margins that are smaller than the new one
707 742
             foreach ($this->_pageMarges as $mY => $mX) {
708
-                if ($mY<$yTop) continue;
709
-                if ($mY>$yBottom) break;
710
-                if ($float=='left' && $this->_pageMarges[$mY][0]<$xRight)  unset($this->_pageMarges[$mY]);
711
-                if ($float=='right' && $this->_pageMarges[$mY][1]>$xLeft) unset($this->_pageMarges[$mY]);
743
+                if ($mY<$yTop) {
744
+                	continue;
745
+                }
746
+                if ($mY>$yBottom) {
747
+                	break;
748
+                }
749
+                if ($float=='left' && $this->_pageMarges[$mY][0]<$xRight) {
750
+                	unset($this->_pageMarges[$mY]);
751
+                }
752
+                if ($float=='right' && $this->_pageMarges[$mY][1]>$xLeft) {
753
+                	unset($this->_pageMarges[$mY]);
754
+                }
712 755
             }
713 756
 
714 757
             // save the new Top and Bottom margins
@@ -806,7 +849,9 @@  discard block
 block discarded – undo
806 849
          */
807 850
         protected function _setPageHeader()
808 851
         {
809
-            if (!count($this->_subHEADER)) return false;
852
+            if (!count($this->_subHEADER)) {
853
+            	return false;
854
+            }
810 855
 
811 856
             $oldParsePos = $this->_parsePos;
812 857
             $oldParseCode = $this->parsingHtml->code;
@@ -826,7 +871,9 @@  discard block
 block discarded – undo
826 871
          */
827 872
         protected function _setPageFooter()
828 873
         {
829
-            if (!count($this->_subFOOTER)) return false;
874
+            if (!count($this->_subFOOTER)) {
875
+            	return false;
876
+            }
830 877
 
831 878
             $oldParsePos = $this->_parsePos;
832 879
             $oldParseCode = $this->parsingHtml->code;
@@ -887,15 +934,18 @@  discard block
 block discarded – undo
887 934
                 $txt = $sub->parsingHtml->code[$this->_parsePos]['param']['txt'];
888 935
                 $txt = str_replace('[[page_cu]]', $sub->pdf->getMyNumPage($this->_page), $txt);
889 936
                 $sub->parsingHtml->code[$this->_parsePos]['param']['txt'] = substr($txt, $curr+1);
890
-            } else
891
-                $sub->_parsePos++;
937
+            } else {
938
+                            $sub->_parsePos++;
939
+            }
892 940
 
893 941
             // for each element of the parsing => load the action
894 942
             $res = null;
895 943
             for ($sub->_parsePos; $sub->_parsePos<count($sub->parsingHtml->code); $sub->_parsePos++) {
896 944
                 $action = $sub->parsingHtml->code[$sub->_parsePos];
897 945
                 $res = $sub->_executeAction($action);
898
-                if (!$res) break;
946
+                if (!$res) {
947
+                	break;
948
+                }
899 949
             }
900 950
 
901 951
             $w = $sub->_maxX; // max width
@@ -906,12 +956,13 @@  discard block
 block discarded – undo
906 956
             $this->_destroySubHTML($sub);
907 957
 
908 958
             // adapt the start of the line, depending on the text-align
909
-            if ($this->parsingCss->value['text-align']=='center')
910
-                $this->pdf->setX(($rx+$this->pdf->getX()-$w)*0.5-0.01);
911
-            else if ($this->parsingCss->value['text-align']=='right')
912
-                $this->pdf->setX($rx-$w-0.01);
913
-            else
914
-                $this->pdf->setX($lx);
959
+            if ($this->parsingCss->value['text-align']=='center') {
960
+                            $this->pdf->setX(($rx+$this->pdf->getX()-$w)*0.5-0.01);
961
+            } else if ($this->parsingCss->value['text-align']=='right') {
962
+                            $this->pdf->setX($rx-$w-0.01);
963
+            } else {
964
+                            $this->pdf->setX($lx);
965
+            }
915 966
 
916 967
             // set the height of the line
917 968
             $this->_currentH = $h;
@@ -1024,8 +1075,12 @@  discard block
 block discarded – undo
1024 1075
             $nbBaseFive    = array('V','L','D');
1025 1076
             $nbRoman    = '';
1026 1077
 
1027
-            if ($nbArabic<1)    return $nbArabic;
1028
-            if ($nbArabic>3999) return $nbArabic;
1078
+            if ($nbArabic<1) {
1079
+            	return $nbArabic;
1080
+            }
1081
+            if ($nbArabic>3999) {
1082
+            	return $nbArabic;
1083
+            }
1029 1084
 
1030 1085
             for ($i=3; $i>=0 ; $i--) {
1031 1086
                 $chiffre=floor($nbArabic/pow(10, $i));
@@ -1095,7 +1150,9 @@  discard block
 block discarded – undo
1095 1150
             $nb = $this->_defList[count($this->_defList)-1]['nb'];
1096 1151
             $up = (substr($st, 0, 6)=='upper-');
1097 1152
 
1098
-            if ($im) return array(false, false, $im);
1153
+            if ($im) {
1154
+            	return array(false, false, $im);
1155
+            }
1099 1156
 
1100 1157
             switch($st)
1101 1158
             {
@@ -1156,12 +1213,19 @@  discard block
 block discarded – undo
1156 1213
             }
1157 1214
 
1158 1215
             // prepare the datas
1159
-            if (!in_array($type, array('ul', 'ol'))) $type = 'ul';
1160
-            if (!in_array($style, array('lower-alpha', 'upper-alpha', 'upper-roman', 'lower-roman', 'decimal', 'square', 'circle', 'disc', 'none'))) $style = '';
1216
+            if (!in_array($type, array('ul', 'ol'))) {
1217
+            	$type = 'ul';
1218
+            }
1219
+            if (!in_array($style, array('lower-alpha', 'upper-alpha', 'upper-roman', 'lower-roman', 'decimal', 'square', 'circle', 'disc', 'none'))) {
1220
+            	$style = '';
1221
+            }
1161 1222
 
1162 1223
             if (!$style) {
1163
-                if ($type=='ul')    $style = 'disc';
1164
-                else                $style = 'decimal';
1224
+                if ($type=='ul') {
1225
+                	$style = 'disc';
1226
+                } else {
1227
+                	$style = 'decimal';
1228
+                }
1165 1229
             }
1166 1230
 
1167 1231
             // add the new level
@@ -1270,8 +1334,9 @@  discard block
 block discarded – undo
1270 1334
          */
1271 1335
         protected function _getElementY($h)
1272 1336
         {
1273
-            if ($this->_subPart || $this->_isSubPart || !$this->_currentH || $this->_currentH<$h)
1274
-                return 0;
1337
+            if ($this->_subPart || $this->_isSubPart || !$this->_currentH || $this->_currentH<$h) {
1338
+                            return 0;
1339
+            }
1275 1340
 
1276 1341
             return ($this->_currentH-$h)*0.8;
1277 1342
         }
@@ -1286,10 +1351,11 @@  discard block
 block discarded – undo
1286 1351
         protected function _makeBreakLine($h, $curr = null)
1287 1352
         {
1288 1353
             if ($h) {
1289
-                if (($this->pdf->getY()+$h<$this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter)
1290
-                    $this->_setNewLine($h, $curr);
1291
-                else
1292
-                    $this->_setNewPage(null, '', null, $curr);
1354
+                if (($this->pdf->getY()+$h<$this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter) {
1355
+                                    $this->_setNewLine($h, $curr);
1356
+                } else {
1357
+                                    $this->_setNewPage(null, '', null, $curr);
1358
+                }
1293 1359
             } else {
1294 1360
                 $this->_setNewPositionForNewLine($curr);
1295 1361
             }
@@ -1412,7 +1478,9 @@  discard block
 block discarded – undo
1412 1478
 
1413 1479
             // calculate the position of the image, if align to the right
1414 1480
             if ($parentWidth>$w && $float!='left') {
1415
-                if ($float=='right' || $this->parsingCss->value['text-align']=='li_right')    $x = $parentX + $parentWidth - $w-$this->parsingCss->value['margin']['r']-$this->parsingCss->value['margin']['l'];
1481
+                if ($float=='right' || $this->parsingCss->value['text-align']=='li_right') {
1482
+                	$x = $parentX + $parentWidth - $w-$this->parsingCss->value['margin']['r']-$this->parsingCss->value['margin']['l'];
1483
+                }
1416 1484
             }
1417 1485
 
1418 1486
             // display the image
@@ -1483,7 +1551,9 @@  discard block
 block discarded – undo
1483 1551
         protected function _drawRectangle($x, $y, $w, $h, $border, $padding, $margin, $background)
1484 1552
         {
1485 1553
             // if we are in a subpart or if height is null => return false
1486
-            if ($this->_subPart || $this->_isSubPart || $h===null) return false;
1554
+            if ($this->_subPart || $this->_isSubPart || $h===null) {
1555
+            	return false;
1556
+            }
1487 1557
 
1488 1558
             // add the margin
1489 1559
             $x+= $margin;
@@ -1526,10 +1596,18 @@  discard block
 block discarded – undo
1526 1596
                 $inBL[1]-= $border['b']['width'];
1527 1597
             }
1528 1598
 
1529
-            if ($inTL[0]<=0 || $inTL[1]<=0) $inTL = null;
1530
-            if ($inTR[0]<=0 || $inTR[1]<=0) $inTR = null;
1531
-            if ($inBR[0]<=0 || $inBR[1]<=0) $inBR = null;
1532
-            if ($inBL[0]<=0 || $inBL[1]<=0) $inBL = null;
1599
+            if ($inTL[0]<=0 || $inTL[1]<=0) {
1600
+            	$inTL = null;
1601
+            }
1602
+            if ($inTR[0]<=0 || $inTR[1]<=0) {
1603
+            	$inTR = null;
1604
+            }
1605
+            if ($inBR[0]<=0 || $inBR[1]<=0) {
1606
+            	$inBR = null;
1607
+            }
1608
+            if ($inBL[0]<=0 || $inBL[1]<=0) {
1609
+            	$inBL = null;
1610
+            }
1533 1611
 
1534 1612
             // prepare the background color
1535 1613
             $pdfStyle = '';
@@ -1587,13 +1665,21 @@  discard block
 block discarded – undo
1587 1665
                     $imageHeight    = 72./96.*$imageInfos[1]/$this->pdf->getK();
1588 1666
 
1589 1667
                     // prepare the position of the backgroung
1590
-                    if ($iRepeat[0]) $iPosition[0] = $bX;
1591
-                    else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) $iPosition[0] = $bX + $match[1]*($bW-$imageWidth)/100;
1592
-                    else $iPosition[0] = $bX+$iPosition[0];
1668
+                    if ($iRepeat[0]) {
1669
+                    	$iPosition[0] = $bX;
1670
+                    } else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) {
1671
+                    	$iPosition[0] = $bX + $match[1]*($bW-$imageWidth)/100;
1672
+                    } else {
1673
+                    	$iPosition[0] = $bX+$iPosition[0];
1674
+                    }
1593 1675
 
1594
-                    if ($iRepeat[1]) $iPosition[1] = $bY;
1595
-                    else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) $iPosition[1] = $bY + $match[1]*($bH-$imageHeight)/100;
1596
-                    else $iPosition[1] = $bY+$iPosition[1];
1676
+                    if ($iRepeat[1]) {
1677
+                    	$iPosition[1] = $bY;
1678
+                    } else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) {
1679
+                    	$iPosition[1] = $bY + $match[1]*($bH-$imageHeight)/100;
1680
+                    } else {
1681
+                    	$iPosition[1] = $bY+$iPosition[1];
1682
+                    }
1597 1683
 
1598 1684
                     $imageXmin = $bX;
1599 1685
                     $imageXmax = $bX+$bW;
@@ -1645,10 +1731,18 @@  discard block
 block discarded – undo
1645 1731
             $y-= $loose;
1646 1732
             $w+= 2.*$loose;
1647 1733
             $h+= 2.*$loose;
1648
-            if ($border['l']['width']) $border['l']['width']+= 2.*$loose;
1649
-            if ($border['t']['width']) $border['t']['width']+= 2.*$loose;
1650
-            if ($border['r']['width']) $border['r']['width']+= 2.*$loose;
1651
-            if ($border['b']['width']) $border['b']['width']+= 2.*$loose;
1734
+            if ($border['l']['width']) {
1735
+            	$border['l']['width']+= 2.*$loose;
1736
+            }
1737
+            if ($border['t']['width']) {
1738
+            	$border['t']['width']+= 2.*$loose;
1739
+            }
1740
+            if ($border['r']['width']) {
1741
+            	$border['r']['width']+= 2.*$loose;
1742
+            }
1743
+            if ($border['b']['width']) {
1744
+            	$border['b']['width']+= 2.*$loose;
1745
+            }
1652 1746
 
1653 1747
             // prepare the test on borders
1654 1748
             $testBl = ($border['l']['width'] && $border['l']['color'][0]!==null);
@@ -1746,13 +1840,17 @@  discard block
 block discarded – undo
1746 1840
                 if (is_array($outBL)) {
1747 1841
                     $bord-=1;
1748 1842
                     $pt[3] -= $outBL[1] - $border['b']['width'];
1749
-                    if ($inBL) $pt[11]-= $inBL[1];
1843
+                    if ($inBL) {
1844
+                    	$pt[11]-= $inBL[1];
1845
+                    }
1750 1846
                     unset($pt[0]);unset($pt[1]);
1751 1847
                 }
1752 1848
                 if (is_array($outTL)) {
1753 1849
                     $bord-=2;
1754 1850
                     $pt[5] += $outTL[1]-$border['t']['width'];
1755
-                    if ($inTL) $pt[9] += $inTL[1];
1851
+                    if ($inTL) {
1852
+                    	$pt[9] += $inTL[1];
1853
+                    }
1756 1854
                     unset($pt[6]);unset($pt[7]);
1757 1855
                 }
1758 1856
 
@@ -1774,13 +1872,17 @@  discard block
 block discarded – undo
1774 1872
                 if (is_array($outTL)) {
1775 1873
                     $bord-=1;
1776 1874
                     $pt[2] += $outTL[0] - $border['l']['width'];
1777
-                    if ($inTL) $pt[10]+= $inTL[0];
1875
+                    if ($inTL) {
1876
+                    	$pt[10]+= $inTL[0];
1877
+                    }
1778 1878
                     unset($pt[0]);unset($pt[1]);
1779 1879
                 }
1780 1880
                 if (is_array($outTR)) {
1781 1881
                     $bord-=2;
1782 1882
                     $pt[4] -= $outTR[0] - $border['r']['width'];
1783
-                    if ($inTR) $pt[8] -= $inTR[0];
1883
+                    if ($inTR) {
1884
+                    	$pt[8] -= $inTR[0];
1885
+                    }
1784 1886
                     unset($pt[6]);unset($pt[7]);
1785 1887
                 }
1786 1888
 
@@ -1802,13 +1904,17 @@  discard block
 block discarded – undo
1802 1904
                 if (is_array($outTR)) {
1803 1905
                     $bord-=1;
1804 1906
                     $pt[3] += $outTR[1] - $border['t']['width'];
1805
-                    if ($inTR) $pt[11]+= $inTR[1];
1907
+                    if ($inTR) {
1908
+                    	$pt[11]+= $inTR[1];
1909
+                    }
1806 1910
                     unset($pt[0]);unset($pt[1]);
1807 1911
                 }
1808 1912
                 if (is_array($outBR)) {
1809 1913
                     $bord-=2;
1810 1914
                     $pt[5] -= $outBR[1] - $border['b']['width'];
1811
-                    if ($inBR) $pt[9] -= $inBR[1];
1915
+                    if ($inBR) {
1916
+                    	$pt[9] -= $inBR[1];
1917
+                    }
1812 1918
                     unset($pt[6]);unset($pt[7]);
1813 1919
                 }
1814 1920
 
@@ -1830,13 +1936,17 @@  discard block
 block discarded – undo
1830 1936
                 if (is_array($outBL)) {
1831 1937
                     $bord-=2;
1832 1938
                     $pt[4] += $outBL[0] - $border['l']['width'];
1833
-                    if ($inBL) $pt[8] += $inBL[0];
1939
+                    if ($inBL) {
1940
+                    	$pt[8] += $inBL[0];
1941
+                    }
1834 1942
                     unset($pt[6]);unset($pt[7]);
1835 1943
                 }
1836 1944
                 if (is_array($outBR)) {
1837 1945
                     $bord-=1;
1838 1946
                     $pt[2] -= $outBR[0] - $border['r']['width'];
1839
-                    if ($inBR) $pt[10]-= $inBR[0];
1947
+                    if ($inBR) {
1948
+                    	$pt[10]-= $inBR[0];
1949
+                    }
1840 1950
                     unset($pt[0]);unset($pt[1]);
1841 1951
 
1842 1952
                 }
@@ -1863,10 +1973,11 @@  discard block
 block discarded – undo
1863 1973
         {
1864 1974
             $this->pdf->setFillColorArray($color);
1865 1975
 
1866
-            if (count($pt)==10)
1867
-                $this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]);
1868
-            else
1869
-                $this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]);
1976
+            if (count($pt)==10) {
1977
+                            $this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]);
1978
+            } else {
1979
+                            $this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]);
1980
+            }
1870 1981
         }
1871 1982
 
1872 1983
         /**
@@ -1937,10 +2048,18 @@  discard block
 block discarded – undo
1937 2048
                 for ($i=0; $l-($px+$py)*($i-0.5)>0; $i++) {
1938 2049
                     if (($i%2)==$mode) {
1939 2050
                         $j = $i-0.5;
1940
-                        $lx1 = $px*($j);   if ($lx1<-$l) $lx1 =-$l;
1941
-                        $ly1 = $py*($j);   if ($ly1<-$l) $ly1 =-$l;
1942
-                        $lx2 = $px*($j+1); if ($lx2>$l)  $lx2 = $l;
1943
-                        $ly2 = $py*($j+1); if ($ly2>$l)  $ly2 = $l;
2051
+                        $lx1 = $px*($j);   if ($lx1<-$l) {
2052
+                        	$lx1 =-$l;
2053
+                        }
2054
+                        $ly1 = $py*($j);   if ($ly1<-$l) {
2055
+                        	$ly1 =-$l;
2056
+                        }
2057
+                        $lx2 = $px*($j+1); if ($lx2>$l) {
2058
+                        	$lx2 = $l;
2059
+                        }
2060
+                        $ly2 = $py*($j+1); if ($ly2>$l) {
2061
+                        	$ly2 = $l;
2062
+                        }
1944 2063
 
1945 2064
                         $tmp = array();
1946 2065
                         $tmp[] = $x1+$lx1; $tmp[] = $y1+$ly1;
@@ -2016,10 +2135,14 @@  discard block
 block discarded – undo
2016 2135
         protected function _prepareTransform($transform)
2017 2136
         {
2018 2137
             // it can not be  empty
2019
-            if (!$transform) return null;
2138
+            if (!$transform) {
2139
+            	return null;
2140
+            }
2020 2141
 
2021 2142
             // sctions must be like scale(...)
2022
-            if (!preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) return null;
2143
+            if (!preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) {
2144
+            	return null;
2145
+            }
2023 2146
 
2024 2147
             // prepare the list of the actions
2025 2148
             $actions = array();
@@ -2040,49 +2163,115 @@  discard block
 block discarded – undo
2040 2163
                 switch($name)
2041 2164
                 {
2042 2165
                     case 'scale':
2043
-                        if (!isset($val[0])) $val[0] = 1.;      else $val[0] = 1.*$val[0];
2044
-                        if (!isset($val[1])) $val[1] = $val[0]; else $val[1] = 1.*$val[1];
2166
+                        if (!isset($val[0])) {
2167
+                        	$val[0] = 1.;
2168
+                        } else {
2169
+                        	$val[0] = 1.*$val[0];
2170
+                        }
2171
+                        if (!isset($val[1])) {
2172
+                        	$val[1] = $val[0];
2173
+                        } else {
2174
+                        	$val[1] = 1.*$val[1];
2175
+                        }
2045 2176
                         $actions[] = array($val[0],0,0,$val[1],0,0);
2046 2177
                         break;
2047 2178
 
2048 2179
                     case 'translate':
2049
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']);
2050
-                        if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']);
2180
+                        if (!isset($val[0])) {
2181
+                        	$val[0] = 0.;
2182
+                        } else {
2183
+                        	$val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']);
2184
+                        }
2185
+                        if (!isset($val[1])) {
2186
+                        	$val[1] = 0.;
2187
+                        } else {
2188
+                        	$val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']);
2189
+                        }
2051 2190
                         $actions[] = array(1,0,0,1,$val[0],$val[1]);
2052 2191
                         break;
2053 2192
 
2054 2193
                     case 'rotate':
2055
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.;
2056
-                        if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']);
2057
-                        if (!isset($val[2])) $val[2] = 0.; else $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']);
2058
-                        if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,-$val[1],-$val[2]);
2194
+                        if (!isset($val[0])) {
2195
+                        	$val[0] = 0.;
2196
+                        } else {
2197
+                        	$val[0] = $val[0]*M_PI/180.;
2198
+                        }
2199
+                        if (!isset($val[1])) {
2200
+                        	$val[1] = 0.;
2201
+                        } else {
2202
+                        	$val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']);
2203
+                        }
2204
+                        if (!isset($val[2])) {
2205
+                        	$val[2] = 0.;
2206
+                        } else {
2207
+                        	$val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']);
2208
+                        }
2209
+                        if ($val[1] || $val[2]) {
2210
+                        	$actions[] = array(1,0,0,1,-$val[1],-$val[2]);
2211
+                        }
2059 2212
                         $actions[] = array(cos($val[0]),sin($val[0]),-sin($val[0]),cos($val[0]),0,0);
2060
-                        if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,$val[1],$val[2]);
2213
+                        if ($val[1] || $val[2]) {
2214
+                        	$actions[] = array(1,0,0,1,$val[1],$val[2]);
2215
+                        }
2061 2216
                         break;
2062 2217
 
2063 2218
                     case 'skewx':
2064
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.;
2219
+                        if (!isset($val[0])) {
2220
+                        	$val[0] = 0.;
2221
+                        } else {
2222
+                        	$val[0] = $val[0]*M_PI/180.;
2223
+                        }
2065 2224
                         $actions[] = array(1,0,tan($val[0]),1,0,0);
2066 2225
                         break;
2067 2226
 
2068 2227
                     case 'skewy':
2069
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.;
2228
+                        if (!isset($val[0])) {
2229
+                        	$val[0] = 0.;
2230
+                        } else {
2231
+                        	$val[0] = $val[0]*M_PI/180.;
2232
+                        }
2070 2233
                         $actions[] = array(1,tan($val[0]),0,1,0,0);
2071 2234
                         break;
2072 2235
                     case 'matrix':
2073
-                        if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*1.;
2074
-                        if (!isset($val[1])) $val[1] = 0.; else $val[1] = $val[1]*1.;
2075
-                        if (!isset($val[2])) $val[2] = 0.; else $val[2] = $val[2]*1.;
2076
-                        if (!isset($val[3])) $val[3] = 0.; else $val[3] = $val[3]*1.;
2077
-                        if (!isset($val[4])) $val[4] = 0.; else $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']);
2078
-                        if (!isset($val[5])) $val[5] = 0.; else $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']);
2236
+                        if (!isset($val[0])) {
2237
+                        	$val[0] = 0.;
2238
+                        } else {
2239
+                        	$val[0] = $val[0]*1.;
2240
+                        }
2241
+                        if (!isset($val[1])) {
2242
+                        	$val[1] = 0.;
2243
+                        } else {
2244
+                        	$val[1] = $val[1]*1.;
2245
+                        }
2246
+                        if (!isset($val[2])) {
2247
+                        	$val[2] = 0.;
2248
+                        } else {
2249
+                        	$val[2] = $val[2]*1.;
2250
+                        }
2251
+                        if (!isset($val[3])) {
2252
+                        	$val[3] = 0.;
2253
+                        } else {
2254
+                        	$val[3] = $val[3]*1.;
2255
+                        }
2256
+                        if (!isset($val[4])) {
2257
+                        	$val[4] = 0.;
2258
+                        } else {
2259
+                        	$val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']);
2260
+                        }
2261
+                        if (!isset($val[5])) {
2262
+                        	$val[5] = 0.;
2263
+                        } else {
2264
+                        	$val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']);
2265
+                        }
2079 2266
                         $actions[] =$val;
2080 2267
                         break;
2081 2268
                 }
2082 2269
             }
2083 2270
 
2084 2271
             // if ther is no actions => return
2085
-            if (!$actions) return null;
2272
+            if (!$actions) {
2273
+            	return null;
2274
+            }
2086 2275
 
2087 2276
             // get the first matrix
2088 2277
             $m = $actions[0]; unset($actions[0]);
@@ -2110,7 +2299,9 @@  discard block
 block discarded – undo
2110 2299
          */
2111 2300
         protected function _calculateTableCellSize(&$cases, &$corr)
2112 2301
         {
2113
-            if (!isset($corr[0])) return true;
2302
+            if (!isset($corr[0])) {
2303
+            	return true;
2304
+            }
2114 2305
 
2115 2306
             // for each cell without colspan, we get the max width for each column
2116 2307
             $sw = array();
@@ -2130,7 +2321,9 @@  discard block
 block discarded – undo
2130 2321
                     if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]>1) {
2131 2322
 
2132 2323
                         // sum the max width of each column in colspan
2133
-                        $s = 0; for ($i=0; $i<$corr[$y][$x][2]; $i++) $s+= $sw[$x+$i];
2324
+                        $s = 0; for ($i=0; $i<$corr[$y][$x][2]; $i++) {
2325
+                        	$s+= $sw[$x+$i];
2326
+                        }
2134 2327
 
2135 2328
                         // if the max width is < the width of the cell with colspan => we adapt the width of each max width
2136 2329
                         if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']) {
@@ -2179,7 +2372,9 @@  discard block
 block discarded – undo
2179 2372
                     if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]>1) {
2180 2373
 
2181 2374
                         // sum the max height of each line in rowspan
2182
-                        $s = 0; for ($i=0; $i<$corr[$y][$x][3]; $i++) $s+= $sh[$y+$i];
2375
+                        $s = 0; for ($i=0; $i<$corr[$y][$x][3]; $i++) {
2376
+                        	$s+= $sh[$y+$i];
2377
+                        }
2183 2378
 
2184 2379
                         // if the max height is < the height of the cell with rowspan => we adapt the height of each max height
2185 2380
                         if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']) {
@@ -2229,8 +2424,12 @@  discard block
 block discarded – undo
2229 2424
          */
2230 2425
         protected function _tag_open_PAGE($param)
2231 2426
         {
2232
-            if ($this->_isForOneLine) return false;
2233
-            if ($this->_debugActif) $this->_DEBUG_add('PAGE '.($this->_page+1), true);
2427
+            if ($this->_isForOneLine) {
2428
+            	return false;
2429
+            }
2430
+            if ($this->_debugActif) {
2431
+            	$this->_DEBUG_add('PAGE '.($this->_page+1), true);
2432
+            }
2234 2433
 
2235 2434
             $newPageSet= (!isset($param['pageset']) || $param['pageset']!='old');
2236 2435
 
@@ -2247,12 +2446,22 @@  discard block
 block discarded – undo
2247 2446
                 $orientation = '';
2248 2447
                 if (isset($param['orientation'])) {
2249 2448
                     $param['orientation'] = strtolower($param['orientation']);
2250
-                    if ($param['orientation']=='p')         $orientation = 'P';
2251
-                    if ($param['orientation']=='portrait')  $orientation = 'P';
2449
+                    if ($param['orientation']=='p') {
2450
+                    	$orientation = 'P';
2451
+                    }
2452
+                    if ($param['orientation']=='portrait') {
2453
+                    	$orientation = 'P';
2454
+                    }
2252 2455
 
2253
-                    if ($param['orientation']=='l')         $orientation = 'L';
2254
-                    if ($param['orientation']=='paysage')   $orientation = 'L';
2255
-                    if ($param['orientation']=='landscape') $orientation = 'L';
2456
+                    if ($param['orientation']=='l') {
2457
+                    	$orientation = 'L';
2458
+                    }
2459
+                    if ($param['orientation']=='paysage') {
2460
+                    	$orientation = 'L';
2461
+                    }
2462
+                    if ($param['orientation']=='landscape') {
2463
+                    	$orientation = 'L';
2464
+                    }
2256 2465
                 }
2257 2466
 
2258 2467
                 // format
@@ -2276,12 +2485,24 @@  discard block
 block discarded – undo
2276 2485
                     $background['img'] = str_replace('&amp;', '&', $background['img']);
2277 2486
 
2278 2487
                     // convert the positions
2279
-                    if ($background['posX']=='left')    $background['posX'] = '0%';
2280
-                    if ($background['posX']=='center')  $background['posX'] = '50%';
2281
-                    if ($background['posX']=='right')   $background['posX'] = '100%';
2282
-                    if ($background['posY']=='top')     $background['posY'] = '0%';
2283
-                    if ($background['posY']=='middle')  $background['posY'] = '50%';
2284
-                    if ($background['posY']=='bottom')  $background['posY'] = '100%';
2488
+                    if ($background['posX']=='left') {
2489
+                    	$background['posX'] = '0%';
2490
+                    }
2491
+                    if ($background['posX']=='center') {
2492
+                    	$background['posX'] = '50%';
2493
+                    }
2494
+                    if ($background['posX']=='right') {
2495
+                    	$background['posX'] = '100%';
2496
+                    }
2497
+                    if ($background['posY']=='top') {
2498
+                    	$background['posY'] = '0%';
2499
+                    }
2500
+                    if ($background['posY']=='middle') {
2501
+                    	$background['posY'] = '50%';
2502
+                    }
2503
+                    if ($background['posY']=='bottom') {
2504
+                    	$background['posY'] = '100%';
2505
+                    }
2285 2506
 
2286 2507
                     if ($background['img']) {
2287 2508
                         // get the size of the image
@@ -2309,10 +2530,18 @@  discard block
 block discarded – undo
2309 2530
                 $background['right']  = isset($param['backright'])  ? $param['backright']  : '0';
2310 2531
 
2311 2532
                 // if no unit => mm
2312
-                if (preg_match('/^([0-9]*)$/isU', $background['top']))    $background['top']    .= 'mm';
2313
-                if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) $background['bottom'] .= 'mm';
2314
-                if (preg_match('/^([0-9]*)$/isU', $background['left']))   $background['left']   .= 'mm';
2315
-                if (preg_match('/^([0-9]*)$/isU', $background['right']))  $background['right']  .= 'mm';
2533
+                if (preg_match('/^([0-9]*)$/isU', $background['top'])) {
2534
+                	$background['top']    .= 'mm';
2535
+                }
2536
+                if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) {
2537
+                	$background['bottom'] .= 'mm';
2538
+                }
2539
+                if (preg_match('/^([0-9]*)$/isU', $background['left'])) {
2540
+                	$background['left']   .= 'mm';
2541
+                }
2542
+                if (preg_match('/^([0-9]*)$/isU', $background['right'])) {
2543
+                	$background['right']  .= 'mm';
2544
+                }
2316 2545
 
2317 2546
                 // convert to mm
2318 2547
                 $background['top']    = $this->parsingCss->ConvertToMM($background['top'], $this->pdf->getH());
@@ -2323,7 +2552,9 @@  discard block
 block discarded – undo
2323 2552
                 // get the background color
2324 2553
                 $res = false;
2325 2554
                 $background['color']    = isset($param['backcolor'])    ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null;
2326
-                if (!$res) $background['color'] = null;
2555
+                if (!$res) {
2556
+                	$background['color'] = null;
2557
+                }
2327 2558
 
2328 2559
                 $this->parsingCss->save();
2329 2560
                 $this->parsingCss->analyse('PAGE', $param);
@@ -2336,7 +2567,9 @@  discard block
 block discarded – undo
2336 2567
                 // automatic footer
2337 2568
                 if (isset($param['footer'])) {
2338 2569
                     $lst = explode(';', $param['footer']);
2339
-                    foreach ($lst as $key => $val) $lst[$key] = trim(strtolower($val));
2570
+                    foreach ($lst as $key => $val) {
2571
+                    	$lst[$key] = trim(strtolower($val));
2572
+                    }
2340 2573
                     $page    = in_array('page', $lst);
2341 2574
                     $date    = in_array('date', $lst);
2342 2575
                     $hour    = in_array('heure', $lst);
@@ -2370,14 +2603,18 @@  discard block
 block discarded – undo
2370 2603
          */
2371 2604
         protected function _tag_close_PAGE($param)
2372 2605
         {
2373
-            if ($this->_isForOneLine) return false;
2606
+            if ($this->_isForOneLine) {
2607
+            	return false;
2608
+            }
2374 2609
 
2375 2610
             $this->_maxH = 0;
2376 2611
 
2377 2612
             $this->parsingCss->load();
2378 2613
             $this->parsingCss->fontSet();
2379 2614
 
2380
-            if ($this->_debugActif) $this->_DEBUG_add('PAGE '.$this->_page, false);
2615
+            if ($this->_debugActif) {
2616
+            	$this->_DEBUG_add('PAGE '.$this->_page, false);
2617
+            }
2381 2618
 
2382 2619
             return true;
2383 2620
         }
@@ -2391,14 +2628,20 @@  discard block
 block discarded – undo
2391 2628
          */
2392 2629
         protected function _tag_open_PAGE_HEADER($param)
2393 2630
         {
2394
-            if ($this->_isForOneLine) return false;
2631
+            if ($this->_isForOneLine) {
2632
+            	return false;
2633
+            }
2395 2634
 
2396 2635
             $this->_subHEADER = array();
2397 2636
             for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) {
2398 2637
                 $action = $this->parsingHtml->code[$this->_parsePos];
2399
-                if ($action['name']=='page_header') $action['name']='page_header_sub';
2638
+                if ($action['name']=='page_header') {
2639
+                	$action['name']='page_header_sub';
2640
+                }
2400 2641
                 $this->_subHEADER[] = $action;
2401
-                if (strtolower($action['name'])=='page_header_sub' && $action['close']) break;
2642
+                if (strtolower($action['name'])=='page_header_sub' && $action['close']) {
2643
+                	break;
2644
+                }
2402 2645
             }
2403 2646
 
2404 2647
             $this->_setPageHeader();
@@ -2415,14 +2658,20 @@  discard block
 block discarded – undo
2415 2658
          */
2416 2659
         protected function _tag_open_PAGE_FOOTER($param)
2417 2660
         {
2418
-            if ($this->_isForOneLine) return false;
2661
+            if ($this->_isForOneLine) {
2662
+            	return false;
2663
+            }
2419 2664
 
2420 2665
             $this->_subFOOTER = array();
2421 2666
             for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) {
2422 2667
                 $action = $this->parsingHtml->code[$this->_parsePos];
2423
-                if ($action['name']=='page_footer') $action['name']='page_footer_sub';
2668
+                if ($action['name']=='page_footer') {
2669
+                	$action['name']='page_footer_sub';
2670
+                }
2424 2671
                 $this->_subFOOTER[] = $action;
2425
-                if (strtolower($action['name'])=='page_footer_sub' && $action['close']) break;
2672
+                if (strtolower($action['name'])=='page_footer_sub' && $action['close']) {
2673
+                	break;
2674
+                }
2426 2675
             }
2427 2676
 
2428 2677
             $this->_setPageFooter();
@@ -2438,7 +2687,9 @@  discard block
 block discarded – undo
2438 2687
          */
2439 2688
         protected function _tag_open_PAGE_HEADER_SUB($param)
2440 2689
         {
2441
-            if ($this->_isForOneLine) return false;
2690
+            if ($this->_isForOneLine) {
2691
+            	return false;
2692
+            }
2442 2693
 
2443 2694
             // save the current stat
2444 2695
             $this->_subSTATES = array();
@@ -2483,7 +2734,9 @@  discard block
 block discarded – undo
2483 2734
          */
2484 2735
         protected function _tag_close_PAGE_HEADER_SUB($param)
2485 2736
         {
2486
-            if ($this->_isForOneLine) return false;
2737
+            if ($this->_isForOneLine) {
2738
+            	return false;
2739
+            }
2487 2740
 
2488 2741
             $this->parsingCss->load();
2489 2742
 
@@ -2514,7 +2767,9 @@  discard block
 block discarded – undo
2514 2767
          */
2515 2768
         protected function _tag_open_PAGE_FOOTER_SUB($param)
2516 2769
         {
2517
-            if ($this->_isForOneLine) return false;
2770
+            if ($this->_isForOneLine) {
2771
+            	return false;
2772
+            }
2518 2773
 
2519 2774
             // save the current stat
2520 2775
             $this->_subSTATES = array();
@@ -2568,7 +2823,9 @@  discard block
 block discarded – undo
2568 2823
          */
2569 2824
         protected function _tag_close_PAGE_FOOTER_SUB($param)
2570 2825
         {
2571
-            if ($this->_isForOneLine) return false;
2826
+            if ($this->_isForOneLine) {
2827
+            	return false;
2828
+            }
2572 2829
 
2573 2830
             $this->parsingCss->load();
2574 2831
 
@@ -2598,7 +2855,9 @@  discard block
 block discarded – undo
2598 2855
          */
2599 2856
         protected function _tag_open_NOBREAK($param)
2600 2857
         {
2601
-            if ($this->_isForOneLine) return false;
2858
+            if ($this->_isForOneLine) {
2859
+            	return false;
2860
+            }
2602 2861
 
2603 2862
             $this->_maxH = 0;
2604 2863
 
@@ -2633,7 +2892,9 @@  discard block
 block discarded – undo
2633 2892
          */
2634 2893
         protected function _tag_close_NOBREAK($param)
2635 2894
         {
2636
-            if ($this->_isForOneLine) return false;
2895
+            if ($this->_isForOneLine) {
2896
+            	return false;
2897
+            }
2637 2898
 
2638 2899
             $this->_maxH = 0;
2639 2900
 
@@ -2650,8 +2911,12 @@  discard block
 block discarded – undo
2650 2911
          */
2651 2912
         protected function _tag_open_DIV($param, $other = 'div')
2652 2913
         {
2653
-            if ($this->_isForOneLine) return false;
2654
-            if ($this->_debugActif) $this->_DEBUG_add(strtoupper($other), true);
2914
+            if ($this->_isForOneLine) {
2915
+            	return false;
2916
+            }
2917
+            if ($this->_debugActif) {
2918
+            	$this->_DEBUG_add(strtoupper($other), true);
2919
+            }
2655 2920
 
2656 2921
             $this->parsingCss->save();
2657 2922
             $this->parsingCss->analyse($other, $param);
@@ -2659,13 +2924,21 @@  discard block
 block discarded – undo
2659 2924
 
2660 2925
             // for fieldset and legend
2661 2926
             if (in_array($other, array('fieldset', 'legend'))) {
2662
-                if (isset($param['moveTop']))  $this->parsingCss->value['margin']['t']    += $param['moveTop'];
2663
-                if (isset($param['moveLeft'])) $this->parsingCss->value['margin']['l']    += $param['moveLeft'];
2664
-                if (isset($param['moveDown'])) $this->parsingCss->value['margin']['b']    += $param['moveDown'];
2927
+                if (isset($param['moveTop'])) {
2928
+                	$this->parsingCss->value['margin']['t']    += $param['moveTop'];
2929
+                }
2930
+                if (isset($param['moveLeft'])) {
2931
+                	$this->parsingCss->value['margin']['l']    += $param['moveLeft'];
2932
+                }
2933
+                if (isset($param['moveDown'])) {
2934
+                	$this->parsingCss->value['margin']['b']    += $param['moveDown'];
2935
+                }
2665 2936
             }
2666 2937
 
2667 2938
             $alignObject = null;
2668
-            if ($this->parsingCss->value['margin-auto']) $alignObject = 'center';
2939
+            if ($this->parsingCss->value['margin-auto']) {
2940
+            	$alignObject = 'center';
2941
+            }
2669 2942
 
2670 2943
             $marge = array();
2671 2944
             $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
@@ -2751,22 +3024,27 @@  discard block
 block discarded – undo
2751 3024
                 if (
2752 3025
                     $w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) &&
2753 3026
                     $this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin())
2754
-                    )
2755
-                    $this->_tag_open_BR(array());
3027
+                    ) {
3028
+                                    $this->_tag_open_BR(array());
3029
+                }
2756 3030
 
2757 3031
                 if (
2758 3032
                         ($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) &&
2759 3033
                         ($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) &&
2760 3034
                         !$this->_isInOverflow
2761
-                    )
2762
-                    $this->_setNewPage();
3035
+                    ) {
3036
+                                    $this->_setNewPage();
3037
+                }
2763 3038
 
2764 3039
                 $old = $this->parsingCss->getOldValues();
2765 3040
                 $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
2766 3041
 
2767 3042
                 if ($parentWidth>$w) {
2768
-                    if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
2769
-                    else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
3043
+                    if ($alignObject=='center') {
3044
+                    	$this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
3045
+                    } else if ($alignObject=='right') {
3046
+                    	$this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
3047
+                    }
2770 3048
                 }
2771 3049
 
2772 3050
                 $this->parsingCss->setPosition();
@@ -2775,8 +3053,11 @@  discard block
 block discarded – undo
2775 3053
                 $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
2776 3054
 
2777 3055
                 if ($parentWidth>$w) {
2778
-                    if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
2779
-                    else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
3056
+                    if ($alignObject=='center') {
3057
+                    	$this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
3058
+                    } else if ($alignObject=='right') {
3059
+                    	$this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
3060
+                    }
2780 3061
                 }
2781 3062
 
2782 3063
                 $this->parsingCss->setPosition();
@@ -2825,7 +3106,9 @@  discard block
 block discarded – undo
2825 3106
                         $xCorr = ($this->parsingCss->value['width']-$wReel)*0.5;
2826 3107
                         break;
2827 3108
                 }
2828
-                if ($xCorr>0) $xCorr=0;
3109
+                if ($xCorr>0) {
3110
+                	$xCorr=0;
3111
+                }
2829 3112
                 switch($this->parsingCss->value['vertical-align'])
2830 3113
                 {
2831 3114
                     case 'bottom':
@@ -2909,7 +3192,9 @@  discard block
 block discarded – undo
2909 3192
             // get height of LEGEND element and make fieldset corrections
2910 3193
             for ($tempPos = $this->_parsePos + 1; $tempPos<count($this->parsingHtml->code); $tempPos++) {
2911 3194
                 $action = $this->parsingHtml->code[$tempPos];
2912
-                if ($action['name'] == 'fieldset') break;
3195
+                if ($action['name'] == 'fieldset') {
3196
+                	break;
3197
+                }
2913 3198
                 if ($action['name'] == 'legend' && !$action['close']) {
2914 3199
                     $legendOpenPos = $tempPos;
2915 3200
 
@@ -2922,8 +3207,9 @@  discard block
 block discarded – undo
2922 3207
                         $action = $sub->parsingHtml->code[$sub->_parsePos];
2923 3208
                         $sub->_executeAction($action);
2924 3209
 
2925
-                        if ($action['name'] == 'legend' && $action['close'])
2926
-                            break;
3210
+                        if ($action['name'] == 'legend' && $action['close']) {
3211
+                                                    break;
3212
+                        }
2927 3213
                     }
2928 3214
 
2929 3215
                     $legendH = $sub->_maxY;
@@ -2954,7 +3240,9 @@  discard block
 block discarded – undo
2954 3240
          */
2955 3241
         protected function _tag_close_DIV($param, $other='div')
2956 3242
         {
2957
-            if ($this->_isForOneLine) return false;
3243
+            if ($this->_isForOneLine) {
3244
+            	return false;
3245
+            }
2958 3246
 
2959 3247
             if ($this->parsingCss->value['overflow']=='hidden') {
2960 3248
                 $this->_maxX = $this->parsingCss->value['old_maxX'];
@@ -2964,8 +3252,9 @@  discard block
 block discarded – undo
2964 3252
                 $this->pdf->clippingPathStop();
2965 3253
             }
2966 3254
 
2967
-            if ($this->parsingCss->value['rotate'])
2968
-                $this->pdf->stopTransform();
3255
+            if ($this->parsingCss->value['rotate']) {
3256
+                            $this->pdf->stopTransform();
3257
+            }
2969 3258
 
2970 3259
             $marge = array();
2971 3260
             $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03;
@@ -3011,8 +3300,12 @@  discard block
 block discarded – undo
3011 3300
             $this->parsingCss->fontSet();
3012 3301
             $this->_loadMargin();
3013 3302
 
3014
-            if ($block) $this->_tag_open_BR(array());
3015
-            if ($this->_debugActif) $this->_DEBUG_add(strtoupper($other), false);
3303
+            if ($block) {
3304
+            	$this->_tag_open_BR(array());
3305
+            }
3306
+            if ($this->_debugActif) {
3307
+            	$this->_DEBUG_add(strtoupper($other), false);
3308
+            }
3016 3309
 
3017 3310
             return true;
3018 3311
         }
@@ -3067,16 +3360,27 @@  discard block
 block discarded – undo
3067 3360
             $lstBarcode['UPC_A']  =    'UPCA';
3068 3361
             $lstBarcode['CODE39'] =    'C39';
3069 3362
 
3070
-            if (!isset($param['type']))     $param['type'] = 'C39';
3071
-            if (!isset($param['value']))    $param['value']    = 0;
3072
-            if (!isset($param['label']))    $param['label']    = 'label';
3073
-            if (!isset($param['style']['color'])) $param['style']['color'] = '#000000';
3363
+            if (!isset($param['type'])) {
3364
+            	$param['type'] = 'C39';
3365
+            }
3366
+            if (!isset($param['value'])) {
3367
+            	$param['value']    = 0;
3368
+            }
3369
+            if (!isset($param['label'])) {
3370
+            	$param['label']    = 'label';
3371
+            }
3372
+            if (!isset($param['style']['color'])) {
3373
+            	$param['style']['color'] = '#000000';
3374
+            }
3074 3375
 
3075
-            if ($this->_testIsDeprecated && (isset($param['bar_h']) || isset($param['bar_w'])))
3076
-                throw new HTML2PDF_exception(9, array('BARCODE', 'bar_h, bar_w'));
3376
+            if ($this->_testIsDeprecated && (isset($param['bar_h']) || isset($param['bar_w']))) {
3377
+                            throw new HTML2PDF_exception(9, array('BARCODE', 'bar_h, bar_w'));
3378
+            }
3077 3379
 
3078 3380
             $param['type'] = strtoupper($param['type']);
3079
-            if (isset($lstBarcode[$param['type']])) $param['type'] = $lstBarcode[$param['type']];
3381
+            if (isset($lstBarcode[$param['type']])) {
3382
+            	$param['type'] = $lstBarcode[$param['type']];
3383
+            }
3080 3384
 
3081 3385
             $this->parsingCss->save();
3082 3386
             $this->parsingCss->analyse('barcode', $param);
@@ -3085,8 +3389,12 @@  discard block
 block discarded – undo
3085 3389
 
3086 3390
             $x = $this->pdf->getX();
3087 3391
             $y = $this->pdf->getY();
3088
-            $w = $this->parsingCss->value['width'];    if (!$w) $w = $this->parsingCss->ConvertToMM('50mm');
3089
-            $h = $this->parsingCss->value['height'];    if (!$h) $h = $this->parsingCss->ConvertToMM('10mm');
3392
+            $w = $this->parsingCss->value['width'];    if (!$w) {
3393
+            	$w = $this->parsingCss->ConvertToMM('50mm');
3394
+            }
3395
+            $h = $this->parsingCss->value['height'];    if (!$h) {
3396
+            	$h = $this->parsingCss->ConvertToMM('10mm');
3397
+            }
3090 3398
             $txt = ($param['label']!=='none' ? $this->parsingCss->value['font-size'] : false);
3091 3399
             $c = $this->parsingCss->value['color'];
3092 3400
             $infos = $this->pdf->myBarcode($param['value'], $param['type'], $x, $y, $w, $h, $txt, $c);
@@ -3127,15 +3435,26 @@  discard block
 block discarded – undo
3127 3435
          */
3128 3436
         protected function _tag_open_QRCODE($param)
3129 3437
         {
3130
-            if ($this->_testIsDeprecated && (isset($param['size']) || isset($param['noborder'])))
3131
-                throw new HTML2PDF_exception(9, array('QRCODE', 'size, noborder'));
3438
+            if ($this->_testIsDeprecated && (isset($param['size']) || isset($param['noborder']))) {
3439
+                            throw new HTML2PDF_exception(9, array('QRCODE', 'size, noborder'));
3440
+            }
3132 3441
 
3133
-            if ($this->_debugActif) $this->_DEBUG_add('QRCODE');
3442
+            if ($this->_debugActif) {
3443
+            	$this->_DEBUG_add('QRCODE');
3444
+            }
3134 3445
 
3135
-            if (!isset($param['value']))                     $param['value'] = '';
3136
-            if (!isset($param['ec']))                        $param['ec'] = 'H';
3137
-            if (!isset($param['style']['color']))            $param['style']['color'] = '#000000';
3138
-            if (!isset($param['style']['background-color'])) $param['style']['background-color'] = '#FFFFFF';
3446
+            if (!isset($param['value'])) {
3447
+            	$param['value'] = '';
3448
+            }
3449
+            if (!isset($param['ec'])) {
3450
+            	$param['ec'] = 'H';
3451
+            }
3452
+            if (!isset($param['style']['color'])) {
3453
+            	$param['style']['color'] = '#000000';
3454
+            }
3455
+            if (!isset($param['style']['background-color'])) {
3456
+            	$param['style']['background-color'] = '#FFFFFF';
3457
+            }
3139 3458
             if (isset($param['style']['border'])) {
3140 3459
                 $borders = $param['style']['border']!='none';
3141 3460
                 unset($param['style']['border']);
@@ -3143,8 +3462,12 @@  discard block
 block discarded – undo
3143 3462
                 $borders = true;
3144 3463
             }
3145 3464
 
3146
-            if ($param['value']==='') return true;
3147
-            if (!in_array($param['ec'], array('L', 'M', 'Q', 'H'))) $param['ec'] = 'H';
3465
+            if ($param['value']==='') {
3466
+            	return true;
3467
+            }
3468
+            if (!in_array($param['ec'], array('L', 'M', 'Q', 'H'))) {
3469
+            	$param['ec'] = 'H';
3470
+            }
3148 3471
 
3149 3472
             $this->parsingCss->save();
3150 3473
             $this->parsingCss->analyse('qrcode', $param);
@@ -3155,7 +3478,9 @@  discard block
 block discarded – undo
3155 3478
             $y = $this->pdf->getY();
3156 3479
             $w = $this->parsingCss->value['width'];
3157 3480
             $h = $this->parsingCss->value['height'];
3158
-            $size = max($w, $h); if (!$size) $size = $this->parsingCss->ConvertToMM('50mm');
3481
+            $size = max($w, $h); if (!$size) {
3482
+            	$size = $this->parsingCss->ConvertToMM('50mm');
3483
+            }
3159 3484
 
3160 3485
             $style = array(
3161 3486
                     'fgcolor' => $this->parsingCss->value['color'],
@@ -3213,8 +3538,12 @@  discard block
 block discarded – undo
3213 3538
             $titre = isset($param['title']) ? trim($param['title']) : '';
3214 3539
             $level = isset($param['level']) ? floor($param['level']) : 0;
3215 3540
 
3216
-            if ($level<0) $level = 0;
3217
-            if ($titre) $this->pdf->Bookmark($titre, $level, -1);
3541
+            if ($level<0) {
3542
+            	$level = 0;
3543
+            }
3544
+            if ($titre) {
3545
+            	$this->pdf->Bookmark($titre, $level, -1);
3546
+            }
3218 3547
 
3219 3548
             return true;
3220 3549
         }
@@ -3258,12 +3587,13 @@  discard block
 block discarded – undo
3258 3587
             $txt = str_replace('[[page_cu]]', $this->pdf->getMyNumPage($this->_page), $txt);
3259 3588
 
3260 3589
             if ($this->parsingCss->value['text-transform']!='none') {
3261
-                if ($this->parsingCss->value['text-transform']=='capitalize')
3262
-                    $txt = ucwords($txt);
3263
-                else if ($this->parsingCss->value['text-transform']=='uppercase')
3264
-                    $txt = strtoupper($txt);
3265
-                else if ($this->parsingCss->value['text-transform']=='lowercase')
3266
-                    $txt = strtolower($txt);
3590
+                if ($this->parsingCss->value['text-transform']=='capitalize') {
3591
+                                    $txt = ucwords($txt);
3592
+                } else if ($this->parsingCss->value['text-transform']=='uppercase') {
3593
+                                    $txt = strtoupper($txt);
3594
+                } else if ($this->parsingCss->value['text-transform']=='lowercase') {
3595
+                                    $txt = strtolower($txt);
3596
+                }
3267 3597
             }
3268 3598
 
3269 3599
             // size of the text
@@ -3319,7 +3649,9 @@  discard block
 block discarded – undo
3319 3649
                     array_shift($words);
3320 3650
                     $old = $str;
3321 3651
 
3322
-                    if (!count($words)) break;
3652
+                    if (!count($words)) {
3653
+                    	break;
3654
+                    }
3323 3655
                     $str[0].= ' '.$words[0][0];
3324 3656
                     $str[1]+= $space+$words[0][1];
3325 3657
                 }
@@ -3336,7 +3668,9 @@  discard block
 block discarded – undo
3336 3668
 
3337 3669
                 // write the extract sentence that fit on the page
3338 3670
                 $wc = ($align=='L' ? $str[1] : $this->parsingCss->value['width']);
3339
-                if ($right - $left<$wc) $wc = $right - $left;
3671
+                if ($right - $left<$wc) {
3672
+                	$wc = $right - $left;
3673
+                }
3340 3674
 
3341 3675
                 if (strlen($str[0])) {
3342 3676
                     $this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy);
@@ -3357,7 +3691,9 @@  discard block
 block discarded – undo
3357 3691
                 // if we have again words to write
3358 3692
                 if (count($words)) {
3359 3693
                     // remove the space at the end
3360
-                    if ($add) $w-= $space;
3694
+                    if ($add) {
3695
+                    	$w-= $space;
3696
+                    }
3361 3697
 
3362 3698
                     // if we don't add any word, and if the first word is empty => useless space to skip
3363 3699
                     if (!$add && $words[0][0]==='') {
@@ -3392,7 +3728,9 @@  discard block
 block discarded – undo
3392 3728
                     // if more than 10000 line => error
3393 3729
                     $nb++;
3394 3730
                     if ($nb>10000) {
3395
-                        $txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0];
3731
+                        $txt = ''; foreach ($words as $k => $word) {
3732
+                        	$txt.= ($k ? ' ' : '').$word[0];
3733
+                        }
3396 3734
                         throw new HTML2PDF_exception(2, array($txt, $right-$left, $w));
3397 3735
                     }
3398 3736
 
@@ -3403,7 +3741,9 @@  discard block
 block discarded – undo
3403 3741
 
3404 3742
             // if we have words after automatic cut, it is because they fit on the line => we write the text
3405 3743
             if (count($words)) {
3406
-                $txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0];
3744
+                $txt = ''; foreach ($words as $k => $word) {
3745
+                	$txt.= ($k ? ' ' : '').$word[0];
3746
+                }
3407 3747
                 $w+= $this->pdf->getWordSpacing()*(count($words));
3408 3748
                 $this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy);
3409 3749
                 $this->pdf->Cell(($align=='L' ? $w : $this->parsingCss->value['width']), $h, $txt, 0, 0, $align, $fill, $this->_isInLink);
@@ -3431,11 +3771,15 @@  discard block
 block discarded – undo
3431 3771
          */
3432 3772
         protected function _tag_open_BR($param, $curr = null)
3433 3773
         {
3434
-            if ($this->_isForOneLine) return false;
3774
+            if ($this->_isForOneLine) {
3775
+            	return false;
3776
+            }
3435 3777
 
3436 3778
             $h = max($this->_maxH, $this->parsingCss->getLineHeight());
3437 3779
 
3438
-            if ($this->_maxH==0) $this->_maxY = max($this->_maxY, $this->pdf->getY()+$h);
3780
+            if ($this->_maxH==0) {
3781
+            	$this->_maxY = max($this->_maxY, $this->pdf->getY()+$h);
3782
+            }
3439 3783
 
3440 3784
             $this->_makeBreakLine($h, $curr);
3441 3785
 
@@ -3454,11 +3798,15 @@  discard block
 block discarded – undo
3454 3798
          */
3455 3799
         protected function _tag_open_HR($param)
3456 3800
         {
3457
-            if ($this->_isForOneLine) return false;
3801
+            if ($this->_isForOneLine) {
3802
+            	return false;
3803
+            }
3458 3804
             $oldAlign = $this->parsingCss->value['text-align'];
3459 3805
             $this->parsingCss->value['text-align'] = 'left';
3460 3806
 
3461
-            if ($this->_maxH) $this->_tag_open_BR($param);
3807
+            if ($this->_maxH) {
3808
+            	$this->_tag_open_BR($param);
3809
+            }
3462 3810
 
3463 3811
             $fontSize = $this->parsingCss->value['font-size'];
3464 3812
             $this->parsingCss->value['font-size']=$fontSize*0.5; $this->_tag_open_BR($param);
@@ -3474,8 +3822,12 @@  discard block
 block discarded – undo
3474 3822
             $this->parsingCss->fontSet();
3475 3823
 
3476 3824
             $h = $this->parsingCss->value['height'];
3477
-            if ($h)    $h-= $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width'];
3478
-            if ($h<=0) $h = $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width'];
3825
+            if ($h) {
3826
+            	$h-= $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width'];
3827
+            }
3828
+            if ($h<=0) {
3829
+            	$h = $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width'];
3830
+            }
3479 3831
 
3480 3832
             $this->_drawRectangle($this->pdf->getX(), $this->pdf->getY(), $this->parsingCss->value['width'], $h, $this->parsingCss->value['border'], 0, 0, $this->parsingCss->value['background']);
3481 3833
             $this->_maxH = $h;
@@ -3811,7 +4163,9 @@  discard block
 block discarded – undo
3811 4163
 
3812 4164
             if (isset($param['name'])) {
3813 4165
                 $name =     $param['name'];
3814
-                if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false);
4166
+                if (!isset($this->_lstAnchor[$name])) {
4167
+                	$this->_lstAnchor[$name] = array($this->pdf->AddLink(), false);
4168
+                }
3815 4169
 
3816 4170
                 if (!$this->_lstAnchor[$name][1]) {
3817 4171
                     $this->_lstAnchor[$name][1] = true;
@@ -3821,7 +4175,9 @@  discard block
 block discarded – undo
3821 4175
 
3822 4176
             if (preg_match('/^#([^#]+)$/isU', $this->_isInLink, $match)) {
3823 4177
                 $name = $match[1];
3824
-                if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false);
4178
+                if (!isset($this->_lstAnchor[$name])) {
4179
+                	$this->_lstAnchor[$name] = array($this->pdf->AddLink(), false);
4180
+                }
3825 4181
 
3826 4182
                 $this->_isInLink = $this->_lstAnchor[$name][0];
3827 4183
             }
@@ -3862,9 +4218,13 @@  discard block
 block discarded – undo
3862 4218
          */
3863 4219
         protected function _tag_open_H1($param, $other = 'h1')
3864 4220
         {
3865
-            if ($this->_isForOneLine) return false;
4221
+            if ($this->_isForOneLine) {
4222
+            	return false;
4223
+            }
3866 4224
 
3867
-            if ($this->_maxH) $this->_tag_open_BR(array());
4225
+            if ($this->_maxH) {
4226
+            	$this->_tag_open_BR(array());
4227
+            }
3868 4228
             $this->parsingCss->save();
3869 4229
             $this->parsingCss->value['font-bold'] = true;
3870 4230
 
@@ -3952,7 +4312,9 @@  discard block
 block discarded – undo
3952 4312
          */
3953 4313
         protected function _tag_close_H1($param)
3954 4314
         {
3955
-            if ($this->_isForOneLine) return false;
4315
+            if ($this->_isForOneLine) {
4316
+            	return false;
4317
+            }
3956 4318
 
3957 4319
             $this->_maxH+= $this->parsingCss->value['margin']['b'];
3958 4320
             $h = max($this->_maxH, $this->parsingCss->getLineHeight());
@@ -4119,10 +4481,14 @@  discard block
 block discarded – undo
4119 4481
          */
4120 4482
         protected function _tag_open_P($param)
4121 4483
         {
4122
-            if ($this->_isForOneLine) return false;
4484
+            if ($this->_isForOneLine) {
4485
+            	return false;
4486
+            }
4123 4487
 
4124 4488
             if (!in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) {
4125
-                if ($this->_maxH) $this->_tag_open_BR(array());
4489
+                if ($this->_maxH) {
4490
+                	$this->_tag_open_BR(array());
4491
+                }
4126 4492
             }
4127 4493
 
4128 4494
             $this->parsingCss->save();
@@ -4159,9 +4525,13 @@  discard block
 block discarded – undo
4159 4525
          */
4160 4526
         protected function _tag_close_P($param)
4161 4527
         {
4162
-            if ($this->_isForOneLine) return false;
4528
+            if ($this->_isForOneLine) {
4529
+            	return false;
4530
+            }
4163 4531
 
4164
-            if ($this->_maxH) $this->_tag_open_BR(array());
4532
+            if ($this->_maxH) {
4533
+            	$this->_tag_open_BR(array());
4534
+            }
4165 4535
             $this->_isInParagraph = false;
4166 4536
             $this->_loadMargin();
4167 4537
             $h = $this->parsingCss->value['margin']['b']+$this->parsingCss->value['padding']['b'];
@@ -4183,7 +4553,9 @@  discard block
 block discarded – undo
4183 4553
          */
4184 4554
         protected function _tag_open_PRE($param, $other = 'pre')
4185 4555
         {
4186
-            if ($other=='pre' && $this->_maxH) $this->_tag_open_BR(array());
4556
+            if ($other=='pre' && $this->_maxH) {
4557
+            	$this->_tag_open_BR(array());
4558
+            }
4187 4559
 
4188 4560
             $this->parsingCss->save();
4189 4561
             $this->parsingCss->value['font-family'] = 'courier';
@@ -4191,7 +4563,9 @@  discard block
 block discarded – undo
4191 4563
             $this->parsingCss->setPosition();
4192 4564
             $this->parsingCss->fontSet();
4193 4565
 
4194
-            if ($other=='pre') return $this->_tag_open_DIV($param, $other);
4566
+            if ($other=='pre') {
4567
+            	return $this->_tag_open_DIV($param, $other);
4568
+            }
4195 4569
 
4196 4570
             return true;
4197 4571
         }
@@ -4220,7 +4594,9 @@  discard block
 block discarded – undo
4220 4594
         protected function _tag_close_PRE($param, $other = 'pre')
4221 4595
         {
4222 4596
             if ($other=='pre') {
4223
-                if ($this->_isForOneLine) return false;
4597
+                if ($this->_isForOneLine) {
4598
+                	return false;
4599
+                }
4224 4600
 
4225 4601
                 $this->_tag_close_DIV($param, $other);
4226 4602
                 $this->_tag_open_BR(array());
@@ -4386,14 +4762,22 @@  discard block
 block discarded – undo
4386 4762
          */
4387 4763
         protected function _tag_open_UL($param, $other = 'ul')
4388 4764
         {
4389
-            if ($this->_isForOneLine) return false;
4765
+            if ($this->_isForOneLine) {
4766
+            	return false;
4767
+            }
4390 4768
 
4391 4769
             if (!in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) {
4392
-                if ($this->_maxH) $this->_tag_open_BR(array());
4393
-                if (!count($this->_defList)) $this->_tag_open_BR(array());
4770
+                if ($this->_maxH) {
4771
+                	$this->_tag_open_BR(array());
4772
+                }
4773
+                if (!count($this->_defList)) {
4774
+                	$this->_tag_open_BR(array());
4775
+                }
4394 4776
             }
4395 4777
 
4396
-            if (!isset($param['style']['width'])) $param['allwidth'] = true;
4778
+            if (!isset($param['style']['width'])) {
4779
+            	$param['allwidth'] = true;
4780
+            }
4397 4781
             $param['cellspacing'] = 0;
4398 4782
 
4399 4783
             // a list is like a table
@@ -4426,14 +4810,18 @@  discard block
 block discarded – undo
4426 4810
          */
4427 4811
         protected function _tag_close_UL($param)
4428 4812
         {
4429
-            if ($this->_isForOneLine) return false;
4813
+            if ($this->_isForOneLine) {
4814
+            	return false;
4815
+            }
4430 4816
 
4431 4817
             $this->_tag_close_TABLE($param);
4432 4818
 
4433 4819
             $this->_listeDelLevel();
4434 4820
 
4435 4821
             if (!$this->_subPart) {
4436
-                if (!count($this->_defList)) $this->_tag_open_BR(array());
4822
+                if (!count($this->_defList)) {
4823
+                	$this->_tag_open_BR(array());
4824
+                }
4437 4825
             }
4438 4826
 
4439 4827
             return true;
@@ -4460,11 +4848,15 @@  discard block
 block discarded – undo
4460 4848
          */
4461 4849
         protected function _tag_open_LI($param)
4462 4850
         {
4463
-            if ($this->_isForOneLine) return false;
4851
+            if ($this->_isForOneLine) {
4852
+            	return false;
4853
+            }
4464 4854
 
4465 4855
             $this->_listeAddLi();
4466 4856
 
4467
-            if (!isset($param['style']['width'])) $param['style']['width'] = '100%';
4857
+            if (!isset($param['style']['width'])) {
4858
+            	$param['style']['width'] = '100%';
4859
+            }
4468 4860
 
4469 4861
             $paramPUCE = $param;
4470 4862
 
@@ -4518,8 +4910,11 @@  discard block
 block discarded – undo
4518 4910
                 // TD for the puce
4519 4911
                 $this->_tag_open_TD($paramPUCE, 'li_sub');
4520 4912
                 unset($paramPUCE['style']['width']);
4521
-                if (isset($paramPUCE['src']))    $this->_tag_open_IMG($paramPUCE);
4522
-                else                            $this->_tag_open_WRITE($paramPUCE);
4913
+                if (isset($paramPUCE['src'])) {
4914
+                	$this->_tag_open_IMG($paramPUCE);
4915
+                } else {
4916
+                	$this->_tag_open_WRITE($paramPUCE);
4917
+                }
4523 4918
                 $this->_tag_close_TD($paramPUCE);
4524 4919
             }
4525 4920
             $this->parsingCss->load();
@@ -4540,7 +4935,9 @@  discard block
 block discarded – undo
4540 4935
          */
4541 4936
         protected function _tag_close_LI($param)
4542 4937
         {
4543
-            if ($this->_isForOneLine) return false;
4938
+            if ($this->_isForOneLine) {
4939
+            	return false;
4940
+            }
4544 4941
 
4545 4942
             $this->_tag_close_TD($param);
4546 4943
 
@@ -4558,7 +4955,9 @@  discard block
 block discarded – undo
4558 4955
          */
4559 4956
         protected function _tag_open_TBODY($param)
4560 4957
         {
4561
-            if ($this->_isForOneLine) return false;
4958
+            if ($this->_isForOneLine) {
4959
+            	return false;
4960
+            }
4562 4961
 
4563 4962
             $this->parsingCss->save();
4564 4963
             $this->parsingCss->analyse('tbody', $param);
@@ -4577,7 +4976,9 @@  discard block
 block discarded – undo
4577 4976
          */
4578 4977
         protected function _tag_close_TBODY($param)
4579 4978
         {
4580
-            if ($this->_isForOneLine) return false;
4979
+            if ($this->_isForOneLine) {
4980
+            	return false;
4981
+            }
4581 4982
 
4582 4983
             $this->parsingCss->load();
4583 4984
             $this->parsingCss->fontSet();
@@ -4594,7 +4995,9 @@  discard block
 block discarded – undo
4594 4995
          */
4595 4996
         protected function _tag_open_THEAD($param)
4596 4997
         {
4597
-            if ($this->_isForOneLine) return false;
4998
+            if ($this->_isForOneLine) {
4999
+            	return false;
5000
+            }
4598 5001
 
4599 5002
             $this->parsingCss->save();
4600 5003
             $this->parsingCss->analyse('thead', $param);
@@ -4607,9 +5010,13 @@  discard block
 block discarded – undo
4607 5010
                 HTML2PDF::$_tables[$param['num']]['thead']['code'] = array();
4608 5011
                 for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) {
4609 5012
                     $action = $this->parsingHtml->code[$pos];
4610
-                    if (strtolower($action['name'])=='thead') $action['name'] = 'thead_sub';
5013
+                    if (strtolower($action['name'])=='thead') {
5014
+                    	$action['name'] = 'thead_sub';
5015
+                    }
4611 5016
                     HTML2PDF::$_tables[$param['num']]['thead']['code'][] = $action;
4612
-                    if (strtolower($action['name'])=='thead_sub' && $action['close']) break;
5017
+                    if (strtolower($action['name'])=='thead_sub' && $action['close']) {
5018
+                    	break;
5019
+                    }
4613 5020
                 }
4614 5021
             } else {
4615 5022
                 $level = $this->parsingHtml->getLevel($this->_parsePos);
@@ -4629,7 +5036,9 @@  discard block
 block discarded – undo
4629 5036
          */
4630 5037
         protected function _tag_close_THEAD($param)
4631 5038
         {
4632
-            if ($this->_isForOneLine) return false;
5039
+            if ($this->_isForOneLine) {
5040
+            	return false;
5041
+            }
4633 5042
 
4634 5043
             $this->parsingCss->load();
4635 5044
             $this->parsingCss->fontSet();
@@ -4653,7 +5062,9 @@  discard block
 block discarded – undo
4653 5062
          */
4654 5063
         protected function _tag_open_TFOOT($param)
4655 5064
         {
4656
-            if ($this->_isForOneLine) return false;
5065
+            if ($this->_isForOneLine) {
5066
+            	return false;
5067
+            }
4657 5068
 
4658 5069
             $this->parsingCss->save();
4659 5070
             $this->parsingCss->analyse('tfoot', $param);
@@ -4666,9 +5077,13 @@  discard block
 block discarded – undo
4666 5077
                 HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array();
4667 5078
                 for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) {
4668 5079
                     $action = $this->parsingHtml->code[$pos];
4669
-                    if (strtolower($action['name'])=='tfoot') $action['name'] = 'tfoot_sub';
5080
+                    if (strtolower($action['name'])=='tfoot') {
5081
+                    	$action['name'] = 'tfoot_sub';
5082
+                    }
4670 5083
                     HTML2PDF::$_tables[$param['num']]['tfoot']['code'][] = $action;
4671
-                    if (strtolower($action['name'])=='tfoot_sub' && $action['close']) break;
5084
+                    if (strtolower($action['name'])=='tfoot_sub' && $action['close']) {
5085
+                    	break;
5086
+                    }
4672 5087
                 }
4673 5088
             } else {
4674 5089
                 $level = $this->parsingHtml->getLevel($this->_parsePos);
@@ -4688,7 +5103,9 @@  discard block
 block discarded – undo
4688 5103
          */
4689 5104
         protected function _tag_close_TFOOT($param)
4690 5105
         {
4691
-            if ($this->_isForOneLine) return false;
5106
+            if ($this->_isForOneLine) {
5107
+            	return false;
5108
+            }
4692 5109
 
4693 5110
             $this->parsingCss->load();
4694 5111
             $this->parsingCss->fontSet();
@@ -4711,7 +5128,9 @@  discard block
 block discarded – undo
4711 5128
          */
4712 5129
         protected function _tag_open_THEAD_SUB($param)
4713 5130
         {
4714
-            if ($this->_isForOneLine) return false;
5131
+            if ($this->_isForOneLine) {
5132
+            	return false;
5133
+            }
4715 5134
 
4716 5135
             $this->parsingCss->save();
4717 5136
             $this->parsingCss->analyse('thead', $param);
@@ -4729,7 +5148,9 @@  discard block
 block discarded – undo
4729 5148
          */
4730 5149
         protected function _tag_close_THEAD_SUB($param)
4731 5150
         {
4732
-            if ($this->_isForOneLine) return false;
5151
+            if ($this->_isForOneLine) {
5152
+            	return false;
5153
+            }
4733 5154
 
4734 5155
             $this->parsingCss->load();
4735 5156
             $this->parsingCss->fontSet();
@@ -4745,7 +5166,9 @@  discard block
 block discarded – undo
4745 5166
          */
4746 5167
         protected function _tag_open_TFOOT_SUB($param)
4747 5168
         {
4748
-            if ($this->_isForOneLine) return false;
5169
+            if ($this->_isForOneLine) {
5170
+            	return false;
5171
+            }
4749 5172
 
4750 5173
             $this->parsingCss->save();
4751 5174
             $this->parsingCss->analyse('tfoot', $param);
@@ -4763,7 +5186,9 @@  discard block
 block discarded – undo
4763 5186
          */
4764 5187
         protected function _tag_close_TFOOT_SUB($param)
4765 5188
         {
4766
-            if ($this->_isForOneLine) return false;
5189
+            if ($this->_isForOneLine) {
5190
+            	return false;
5191
+            }
4767 5192
 
4768 5193
             $this->parsingCss->load();
4769 5194
             $this->parsingCss->fontSet();
@@ -4825,7 +5250,9 @@  discard block
 block discarded – undo
4825 5250
         protected function _tag_open_TABLE($param, $other = 'table')
4826 5251
         {
4827 5252
             if ($this->_maxH) {
4828
-                if ($this->_isForOneLine) return false;
5253
+                if ($this->_isForOneLine) {
5254
+                	return false;
5255
+                }
4829 5256
                 $this->_tag_open_BR(array());
4830 5257
             }
4831 5258
 
@@ -4837,15 +5264,21 @@  discard block
 block discarded – undo
4837 5264
             $this->_maxH = 0;
4838 5265
 
4839 5266
             $alignObject = isset($param['align']) ? strtolower($param['align']) : 'left';
4840
-            if (isset($param['align'])) unset($param['align']);
4841
-            if (!in_array($alignObject, array('left', 'center', 'right'))) $alignObject = 'left';
5267
+            if (isset($param['align'])) {
5268
+            	unset($param['align']);
5269
+            }
5270
+            if (!in_array($alignObject, array('left', 'center', 'right'))) {
5271
+            	$alignObject = 'left';
5272
+            }
4842 5273
 
4843 5274
             $this->parsingCss->save();
4844 5275
             $this->parsingCss->analyse($other, $param);
4845 5276
             $this->parsingCss->setPosition();
4846 5277
             $this->parsingCss->fontSet();
4847 5278
 
4848
-            if ($this->parsingCss->value['margin-auto']) $alignObject = 'center';
5279
+            if ($this->parsingCss->value['margin-auto']) {
5280
+            	$alignObject = 'center';
5281
+            }
4849 5282
 
4850 5283
             // collapse table ?
4851 5284
             $collapse = false;
@@ -4866,7 +5299,9 @@  discard block
 block discarded – undo
4866 5299
 
4867 5300
             // if we are in a SUB html => prepare the properties of the table
4868 5301
             if ($this->_subPart) {
4869
-                if ($this->_debugActif) $this->_DEBUG_add('Table n'.$param['num'], true);
5302
+                if ($this->_debugActif) {
5303
+                	$this->_DEBUG_add('Table n'.$param['num'], true);
5304
+                }
4870 5305
                 HTML2PDF::$_tables[$param['num']] = array();
4871 5306
                 HTML2PDF::$_tables[$param['num']]['border']          = isset($param['border']) ? $this->parsingCss->readBorder($param['border']) : null;
4872 5307
                 HTML2PDF::$_tables[$param['num']]['cellpadding']     = $this->parsingCss->ConvertToMM(isset($param['cellpadding']) ? $param['cellpadding'] : '1px');
@@ -4938,7 +5373,9 @@  discard block
 block discarded – undo
4938 5373
          */
4939 5374
         protected function _tag_close_TABLE($param)
4940 5375
         {
4941
-            if ($this->_isForOneLine) return false;
5376
+            if ($this->_isForOneLine) {
5377
+            	return false;
5378
+            }
4942 5379
 
4943 5380
             $this->_maxH = 0;
4944 5381
 
@@ -4954,9 +5391,10 @@  discard block
 block discarded – undo
4954 5391
                     foreach (HTML2PDF::$_tables[$param['num']][$mode]['tr'] as $tr) {
4955 5392
                         // hauteur de la ligne tr
4956 5393
                         $h = 0;
4957
-                        for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++)
4958
-                            if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan']==1)
5394
+                        for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++) {
5395
+                                                    if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan']==1)
4959 5396
                                 $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['h']);
5397
+                        }
4960 5398
                         HTML2PDF::$_tables[$param['num']][$mode]['height']+= $h;
4961 5399
                     }
4962 5400
                 }
@@ -4975,10 +5413,11 @@  discard block
 block discarded – undo
4975 5413
                 $x = HTML2PDF::$_tables[$param['num']]['curr_x'];
4976 5414
                 $w = HTML2PDF::$_tables[$param['num']]['width'];
4977 5415
                 if ($parentWidth>$w) {
4978
-                    if (HTML2PDF::$_tables[$param['num']]['align']=='center')
4979
-                        $x = $x + ($parentWidth-$w)*0.5;
4980
-                    else if (HTML2PDF::$_tables[$param['num']]['align']=='right')
4981
-                        $x = $x + $parentWidth-$w;
5416
+                    if (HTML2PDF::$_tables[$param['num']]['align']=='center') {
5417
+                                            $x = $x + ($parentWidth-$w)*0.5;
5418
+                    } else if (HTML2PDF::$_tables[$param['num']]['align']=='right') {
5419
+                                            $x = $x + $parentWidth-$w;
5420
+                    }
4982 5421
 
4983 5422
                     HTML2PDF::$_tables[$param['num']]['curr_x'] = $x;
4984 5423
                 }
@@ -5001,8 +5440,12 @@  discard block
 block discarded – undo
5001 5440
                 for ($k=0; $k<count(HTML2PDF::$_tables[$param['num']]['cases']); $k++) {
5002 5441
 
5003 5442
                     // if it is a TR of the thead or of the tfoot => skip
5004
-                    if (in_array($k, HTML2PDF::$_tables[$param['num']]['thead']['tr'])) continue;
5005
-                    if (in_array($k, HTML2PDF::$_tables[$param['num']]['tfoot']['tr'])) continue;
5443
+                    if (in_array($k, HTML2PDF::$_tables[$param['num']]['thead']['tr'])) {
5444
+                    	continue;
5445
+                    }
5446
+                    if (in_array($k, HTML2PDF::$_tables[$param['num']]['tfoot']['tr'])) {
5447
+                    	continue;
5448
+                    }
5006 5449
 
5007 5450
                     // height of the line
5008 5451
                     $th = 0;
@@ -5010,13 +5453,16 @@  discard block
 block discarded – undo
5010 5453
                     for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$k]); $i++) {
5011 5454
                         $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']);
5012 5455
 
5013
-                        if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan']==1)
5014
-                            $th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']);
5456
+                        if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan']==1) {
5457
+                                                    $th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']);
5458
+                        }
5015 5459
                     }
5016 5460
 
5017 5461
                     // if the row does not fit on the page => new page
5018 5462
                     if ($y+$h+$height>$max) {
5019
-                        if ($height==$h0) $height = null;
5463
+                        if ($height==$h0) {
5464
+                        	$height = null;
5465
+                        }
5020 5466
                         HTML2PDF::$_tables[$param['num']]['height'][] = $height;
5021 5467
                         $height = $h0;
5022 5468
                         $y = $this->_margeTop;
@@ -5025,7 +5471,9 @@  discard block
 block discarded – undo
5025 5471
                 }
5026 5472
 
5027 5473
                 // if ther is a height at the end, add it
5028
-                if ($height!=$h0 || $k==0) HTML2PDF::$_tables[$param['num']]['height'][] = $height;
5474
+                if ($height!=$h0 || $k==0) {
5475
+                	HTML2PDF::$_tables[$param['num']]['height'][] = $height;
5476
+                }
5029 5477
             } else {
5030 5478
                 // if we have tfoor, draw it
5031 5479
                 if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) {
@@ -5050,12 +5498,13 @@  discard block
 block discarded – undo
5050 5498
 
5051 5499
                 // get the positions of the end of the table
5052 5500
                 $x = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['width'];
5053
-                if (count(HTML2PDF::$_tables[$param['num']]['height'])>1)
5054
-                    $y = $this->_margeTop+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1];
5055
-                else if (count(HTML2PDF::$_tables[$param['num']]['height'])==1)
5056
-                    $y = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1];
5057
-                else
5058
-                    $y = HTML2PDF::$_tables[$param['num']]['curr_y'];
5501
+                if (count(HTML2PDF::$_tables[$param['num']]['height'])>1) {
5502
+                                    $y = $this->_margeTop+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1];
5503
+                } else if (count(HTML2PDF::$_tables[$param['num']]['height'])==1) {
5504
+                                    $y = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1];
5505
+                } else {
5506
+                                    $y = HTML2PDF::$_tables[$param['num']]['curr_y'];
5507
+                }
5059 5508
 
5060 5509
                 $this->_maxX = max($this->_maxX, $x);
5061 5510
                 $this->_maxY = max($this->_maxY, $y);
@@ -5064,7 +5513,9 @@  discard block
 block discarded – undo
5064 5513
 
5065 5514
                 $this->_loadMargin();
5066 5515
 
5067
-                if ($this->_debugActif) $this->_DEBUG_add('Table '.$param['num'], false);
5516
+                if ($this->_debugActif) {
5517
+                	$this->_DEBUG_add('Table '.$param['num'], false);
5518
+                }
5068 5519
             }
5069 5520
 
5070 5521
             $this->parsingCss->load();
@@ -5084,8 +5535,9 @@  discard block
 block discarded – undo
5084 5535
         protected function _tag_open_COL($param)
5085 5536
         {
5086 5537
             $span = isset($param['span']) ? $param['span'] : 1;
5087
-            for ($k=0; $k<$span; $k++)
5088
-                HTML2PDF::$_tables[$param['num']]['cols'][] = $param;
5538
+            for ($k=0; $k<$span; $k++) {
5539
+                            HTML2PDF::$_tables[$param['num']]['cols'][] = $param;
5540
+            }
5089 5541
         }
5090 5542
 
5091 5543
         /**
@@ -5111,7 +5563,9 @@  discard block
 block discarded – undo
5111 5563
          */
5112 5564
         protected function _tag_open_TR($param, $other = 'tr')
5113 5565
         {
5114
-            if ($this->_isForOneLine) return false;
5566
+            if ($this->_isForOneLine) {
5567
+            	return false;
5568
+            }
5115 5569
 
5116 5570
             $this->_maxH = 0;
5117 5571
 
@@ -5215,12 +5669,14 @@  discard block
 block discarded – undo
5215 5669
             } else {
5216 5670
                 // prepare it
5217 5671
                 HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1] = array();
5218
-                if (!isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']]))
5219
-                    HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array();
5672
+                if (!isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']])) {
5673
+                                    HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array();
5674
+                }
5220 5675
 
5221 5676
                 HTML2PDF::$_tables[$param['num']]['corr_x']=0;
5222
-                while(isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']]))
5223
-                    HTML2PDF::$_tables[$param['num']]['corr_x']++;
5677
+                while(isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) {
5678
+                                    HTML2PDF::$_tables[$param['num']]['corr_x']++;
5679
+                }
5224 5680
             }
5225 5681
 
5226 5682
             return true;
@@ -5235,7 +5691,9 @@  discard block
 block discarded – undo
5235 5691
          */
5236 5692
         protected function _tag_close_TR($param)
5237 5693
         {
5238
-            if ($this->_isForOneLine) return false;
5694
+            if ($this->_isForOneLine) {
5695
+            	return false;
5696
+            }
5239 5697
 
5240 5698
             $this->_maxH = 0;
5241 5699
 
@@ -5273,7 +5731,9 @@  discard block
 block discarded – undo
5273 5731
          */
5274 5732
         protected function _tag_open_TD($param, $other = 'td')
5275 5733
         {
5276
-            if ($this->_isForOneLine) return false;
5734
+            if ($this->_isForOneLine) {
5735
+            	return false;
5736
+            }
5277 5737
 
5278 5738
             $this->_maxH = 0;
5279 5739
 
@@ -5328,10 +5788,11 @@  discard block
 block discarded – undo
5328 5788
                     if (count($colParam['style']['width'])) {
5329 5789
                         $total = $colParam['style']['width'][0]; unset($colParam['style']['width'][0]);
5330 5790
                         foreach ($colParam['style']['width'] as $width) {
5331
-                            if (substr($total, -1)=='%' && substr($width, -1)=='%')
5332
-                                $total = (str_replace('%', '', $total)+str_replace('%', '', $width)).'%';
5333
-                            else
5334
-                                $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm';
5791
+                            if (substr($total, -1)=='%' && substr($width, -1)=='%') {
5792
+                                                            $total = (str_replace('%', '', $total)+str_replace('%', '', $width)).'%';
5793
+                            } else {
5794
+                                                            $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm';
5795
+                            }
5335 5796
                         }
5336 5797
                     }
5337 5798
 
@@ -5363,8 +5824,9 @@  discard block
 block discarded – undo
5363 5824
                 $legacy = array();
5364 5825
 
5365 5826
                 $old = $this->parsingCss->getLastValue('background');
5366
-                if ($old && ($old['color'] || $old['image']))
5367
-                    $legacy['background'] = $old;
5827
+                if ($old && ($old['color'] || $old['image'])) {
5828
+                                    $legacy['background'] = $old;
5829
+                }
5368 5830
 
5369 5831
                 if (HTML2PDF::$_tables[$param['num']]['border']) {
5370 5832
                     $legacy['border'] = array();
@@ -5395,7 +5857,9 @@  discard block
 block discarded – undo
5395 5857
                 }
5396 5858
 
5397 5859
                 if (HTML2PDF::$_tables[$param['num']]['td_curr']>0) {
5398
-                    if (!$return) $this->parsingCss->value['width']+= $this->parsingCss->value['border']['l']['width'];
5860
+                    if (!$return) {
5861
+                    	$this->parsingCss->value['width']+= $this->parsingCss->value['border']['l']['width'];
5862
+                    }
5399 5863
                     $this->parsingCss->value['border']['l'] = $this->parsingCss->readBorder('none');
5400 5864
                 }
5401 5865
             }
@@ -5501,7 +5965,9 @@  discard block
 block discarded – undo
5501 5965
          */
5502 5966
         protected function _tag_close_TD($param)
5503 5967
         {
5504
-            if ($this->_isForOneLine) return false;
5968
+            if ($this->_isForOneLine) {
5969
+            	return false;
5970
+            }
5505 5971
 
5506 5972
             $this->_maxH = 0;
5507 5973
 
@@ -5564,7 +6030,9 @@  discard block
 block discarded – undo
5564 6030
          */
5565 6031
         protected function _tag_open_TH($param)
5566 6032
         {
5567
-            if ($this->_isForOneLine) return false;
6033
+            if ($this->_isForOneLine) {
6034
+            	return false;
6035
+            }
5568 6036
 
5569 6037
             $this->parsingCss->save();
5570 6038
             $this->parsingCss->value['font-bold'] = true;
@@ -5583,7 +6051,9 @@  discard block
 block discarded – undo
5583 6051
          */
5584 6052
         protected function _tag_close_TH($param)
5585 6053
         {
5586
-            if ($this->_isForOneLine) return false;
6054
+            if ($this->_isForOneLine) {
6055
+            	return false;
6056
+            }
5587 6057
 
5588 6058
             $this->_tag_close_TD($param);
5589 6059
 
@@ -5613,7 +6083,9 @@  discard block
 block discarded – undo
5613 6083
             $this->parsingCss->fontSet();
5614 6084
 
5615 6085
             $res = $this->_drawImage($src, isset($param['sub_li']));
5616
-            if (!$res) return $res;
6086
+            if (!$res) {
6087
+            	return $res;
6088
+            }
5617 6089
 
5618 6090
             $this->parsingCss->load();
5619 6091
             $this->parsingCss->fontSet();
@@ -5654,7 +6126,9 @@  discard block
 block discarded – undo
5654 6126
             $this->_lstSelect['size']    = isset($param['size']) ? $param['size'] : 1;
5655 6127
             $this->_lstSelect['options']    = array();
5656 6128
 
5657
-            if ($this->_lstSelect['multi'] && $this->_lstSelect['size']<3) $this->_lstSelect['size'] = 3;
6129
+            if ($this->_lstSelect['multi'] && $this->_lstSelect['size']<3) {
6130
+            	$this->_lstSelect['size'] = 3;
6131
+            }
5658 6132
 
5659 6133
             return true;
5660 6134
         }
@@ -5707,7 +6181,9 @@  discard block
 block discarded – undo
5707 6181
             $f = 1.08*$this->parsingCss->value['font-size'];
5708 6182
 
5709 6183
             // width
5710
-            $w = $this->parsingCss->value['width']; if (!$w) $w = 50;
6184
+            $w = $this->parsingCss->value['width']; if (!$w) {
6185
+            	$w = 50;
6186
+            }
5711 6187
 
5712 6188
             // height (automatic)
5713 6189
             $h = ($f*1.07*$this->_lstSelect['size'] + 1);
@@ -5820,9 +6296,15 @@  discard block
 block discarded – undo
5820 6296
          */
5821 6297
         protected function _tag_open_INPUT($param)
5822 6298
         {
5823
-            if (!isset($param['name']))  $param['name']  = 'champs_pdf_'.(count($this->_lstField)+1);
5824
-            if (!isset($param['value'])) $param['value'] = '';
5825
-            if (!isset($param['type']))  $param['type']  = 'text';
6299
+            if (!isset($param['name'])) {
6300
+            	$param['name']  = 'champs_pdf_'.(count($this->_lstField)+1);
6301
+            }
6302
+            if (!isset($param['value'])) {
6303
+            	$param['value'] = '';
6304
+            }
6305
+            if (!isset($param['type'])) {
6306
+            	$param['type']  = 'text';
6307
+            }
5826 6308
 
5827 6309
             $param['name'] = strtolower($param['name']);
5828 6310
             $param['type'] = strtolower($param['type']);
@@ -5856,7 +6338,9 @@  discard block
 block discarded – undo
5856 6338
                 case 'checkbox':
5857 6339
                     $w = 3;
5858 6340
                     $h = $w;
5859
-                    if ($h<$f) $y+= ($f-$h)*0.5;
6341
+                    if ($h<$f) {
6342
+                    	$y+= ($f-$h)*0.5;
6343
+                    }
5860 6344
                     $checked = (isset($param['checked']) && $param['checked']=='checked');
5861 6345
                     $this->pdf->CheckBox($name, $w, $checked, $prop, array(), ($param['value'] ? $param['value'] : 'Yes'), $x, $y);
5862 6346
                     break;
@@ -5864,7 +6348,9 @@  discard block
 block discarded – undo
5864 6348
                 case 'radio':
5865 6349
                     $w = 3;
5866 6350
                     $h = $w;
5867
-                    if ($h<$f) $y+= ($f-$h)*0.5;
6351
+                    if ($h<$f) {
6352
+                    	$y+= ($f-$h)*0.5;
6353
+                    }
5868 6354
                     $checked = (isset($param['checked']) && $param['checked']=='checked');
5869 6355
                     $this->pdf->RadioButton($name, $w, $prop, array(), ($param['value'] ? $param['value'] : 'On'), $checked, $x, $y);
5870 6356
                     break;
@@ -5877,29 +6363,43 @@  discard block
 block discarded – undo
5877 6363
                     break;
5878 6364
 
5879 6365
                 case 'text':
5880
-                    $w = $this->parsingCss->value['width']; if (!$w) $w = 40;
6366
+                    $w = $this->parsingCss->value['width']; if (!$w) {
6367
+                    	$w = 40;
6368
+                    }
5881 6369
                     $h = $f*1.3;
5882 6370
                     $prop['value'] = $param['value'];
5883 6371
                     $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y);
5884 6372
                     break;
5885 6373
 
5886 6374
                 case 'submit':
5887
-                    $w = $this->parsingCss->value['width'];    if (!$w) $w = 40;
5888
-                    $h = $this->parsingCss->value['height'];    if (!$h) $h = $f*1.3;
6375
+                    $w = $this->parsingCss->value['width'];    if (!$w) {
6376
+                    	$w = 40;
6377
+                    }
6378
+                    $h = $this->parsingCss->value['height'];    if (!$h) {
6379
+                    	$h = $f*1.3;
6380
+                    }
5889 6381
                     $action = array('S'=>'SubmitForm', 'F'=>$this->_isInForm, 'Flags'=>array('ExportFormat'));
5890 6382
                     $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
5891 6383
                     break;
5892 6384
 
5893 6385
                 case 'reset':
5894
-                    $w = $this->parsingCss->value['width'];    if (!$w) $w = 40;
5895
-                    $h = $this->parsingCss->value['height'];    if (!$h) $h = $f*1.3;
6386
+                    $w = $this->parsingCss->value['width'];    if (!$w) {
6387
+                    	$w = 40;
6388
+                    }
6389
+                    $h = $this->parsingCss->value['height'];    if (!$h) {
6390
+                    	$h = $f*1.3;
6391
+                    }
5896 6392
                     $action = array('S'=>'ResetForm');
5897 6393
                     $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
5898 6394
                     break;
5899 6395
 
5900 6396
                 case 'button':
5901
-                    $w = $this->parsingCss->value['width'];    if (!$w) $w = 40;
5902
-                    $h = $this->parsingCss->value['height'];    if (!$h) $h = $f*1.3;
6397
+                    $w = $this->parsingCss->value['width'];    if (!$w) {
6398
+                    	$w = 40;
6399
+                    }
6400
+                    $h = $this->parsingCss->value['height'];    if (!$h) {
6401
+                    	$h = $f*1.3;
6402
+                    }
5903 6403
                     $action = isset($param['onclick']) ? $param['onclick'] : '';
5904 6404
                     $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
5905 6405
                     break;
@@ -5931,15 +6431,21 @@  discard block
 block discarded – undo
5931 6431
          */
5932 6432
         protected function _tag_open_DRAW($param)
5933 6433
         {
5934
-            if ($this->_isForOneLine) return false;
5935
-            if ($this->_debugActif) $this->_DEBUG_add('DRAW', true);
6434
+            if ($this->_isForOneLine) {
6435
+            	return false;
6436
+            }
6437
+            if ($this->_debugActif) {
6438
+            	$this->_DEBUG_add('DRAW', true);
6439
+            }
5936 6440
 
5937 6441
             $this->parsingCss->save();
5938 6442
             $this->parsingCss->analyse('draw', $param);
5939 6443
             $this->parsingCss->fontSet();
5940 6444
 
5941 6445
             $alignObject = null;
5942
-            if ($this->parsingCss->value['margin-auto']) $alignObject = 'center';
6446
+            if ($this->parsingCss->value['margin-auto']) {
6447
+            	$alignObject = 'center';
6448
+            }
5943 6449
 
5944 6450
             $overW = $this->parsingCss->value['width'];
5945 6451
             $overH = $this->parsingCss->value['height'];
@@ -5954,22 +6460,27 @@  discard block
 block discarded – undo
5954 6460
                 if (
5955 6461
                     $w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) &&
5956 6462
                     $this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin())
5957
-                    )
5958
-                    $this->_tag_open_BR(array());
6463
+                    ) {
6464
+                                    $this->_tag_open_BR(array());
6465
+                }
5959 6466
 
5960 6467
                 if (
5961 6468
                         ($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) &&
5962 6469
                         ($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) &&
5963 6470
                         !$this->_isInOverflow
5964
-                    )
5965
-                    $this->_setNewPage();
6471
+                    ) {
6472
+                                    $this->_setNewPage();
6473
+                }
5966 6474
 
5967 6475
                 $old = $this->parsingCss->getOldValues();
5968 6476
                 $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
5969 6477
 
5970 6478
                 if ($parentWidth>$w) {
5971
-                    if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
5972
-                    else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
6479
+                    if ($alignObject=='center') {
6480
+                    	$this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
6481
+                    } else if ($alignObject=='right') {
6482
+                    	$this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
6483
+                    }
5973 6484
                 }
5974 6485
 
5975 6486
                 $this->parsingCss->setPosition();
@@ -5978,8 +6489,11 @@  discard block
 block discarded – undo
5978 6489
                 $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
5979 6490
 
5980 6491
                 if ($parentWidth>$w) {
5981
-                    if ($alignObject=='center')        $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
5982
-                    else if ($alignObject=='right')    $this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
6492
+                    if ($alignObject=='center') {
6493
+                    	$this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5);
6494
+                    } else if ($alignObject=='right') {
6495
+                    	$this->pdf->setX($this->pdf->getX() + $parentWidth-$w);
6496
+                    }
5983 6497
                 }
5984 6498
 
5985 6499
                 $this->parsingCss->setPosition();
@@ -6056,7 +6570,9 @@  discard block
 block discarded – undo
6056 6570
          */
6057 6571
         protected function _tag_close_DRAW($param)
6058 6572
         {
6059
-            if ($this->_isForOneLine) return false;
6573
+            if ($this->_isForOneLine) {
6574
+            	return false;
6575
+            }
6060 6576
 
6061 6577
             $this->pdf->SetAlpha(1.);
6062 6578
             $this->pdf->undoTransform();
@@ -6097,8 +6613,12 @@  discard block
 block discarded – undo
6097 6613
             $this->parsingCss->fontSet();
6098 6614
             $this->_loadMargin();
6099 6615
 
6100
-            if ($block) $this->_tag_open_BR(array());
6101
-            if ($this->_debugActif) $this->_DEBUG_add('DRAW', false);
6616
+            if ($block) {
6617
+            	$this->_tag_open_BR(array());
6618
+            }
6619
+            if ($this->_debugActif) {
6620
+            	$this->_DEBUG_add('DRAW', false);
6621
+            }
6102 6622
 
6103 6623
             $this->_isInDraw = null;
6104 6624
 
@@ -6114,7 +6634,9 @@  discard block
 block discarded – undo
6114 6634
          */
6115 6635
         protected function _tag_open_LINE($param)
6116 6636
         {
6117
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'LINE');
6637
+            if (!$this->_isInDraw) {
6638
+            	throw new HTML2PDF_exception(8, 'LINE');
6639
+            }
6118 6640
 
6119 6641
             $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6120 6642
             $this->parsingCss->save();
@@ -6141,7 +6663,9 @@  discard block
 block discarded – undo
6141 6663
          */
6142 6664
         protected function _tag_open_RECT($param)
6143 6665
         {
6144
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'RECT');
6666
+            if (!$this->_isInDraw) {
6667
+            	throw new HTML2PDF_exception(8, 'RECT');
6668
+            }
6145 6669
 
6146 6670
             $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6147 6671
             $this->parsingCss->save();
@@ -6168,7 +6692,9 @@  discard block
 block discarded – undo
6168 6692
          */
6169 6693
         protected function _tag_open_CIRCLE($param)
6170 6694
         {
6171
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'CIRCLE');
6695
+            if (!$this->_isInDraw) {
6696
+            	throw new HTML2PDF_exception(8, 'CIRCLE');
6697
+            }
6172 6698
 
6173 6699
             $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6174 6700
             $this->parsingCss->save();
@@ -6193,7 +6719,9 @@  discard block
 block discarded – undo
6193 6719
          */
6194 6720
         protected function _tag_open_ELLIPSE($param)
6195 6721
         {
6196
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'ELLIPSE');
6722
+            if (!$this->_isInDraw) {
6723
+            	throw new HTML2PDF_exception(8, 'ELLIPSE');
6724
+            }
6197 6725
 
6198 6726
             $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6199 6727
             $this->parsingCss->save();
@@ -6220,7 +6748,9 @@  discard block
 block discarded – undo
6220 6748
          */
6221 6749
         protected function _tag_open_POLYLINE($param)
6222 6750
         {
6223
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON');
6751
+            if (!$this->_isInDraw) {
6752
+            	throw new HTML2PDF_exception(8, 'POLYGON');
6753
+            }
6224 6754
 
6225 6755
             $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6226 6756
             $this->parsingCss->save();
@@ -6236,7 +6766,9 @@  discard block
 block discarded – undo
6236 6766
                 $path = explode(' ', $path);
6237 6767
                 foreach ($path as $k => $v) {
6238 6768
                     $path[$k] = trim($v);
6239
-                    if ($path[$k]==='') unset($path[$k]);
6769
+                    if ($path[$k]==='') {
6770
+                    	unset($path[$k]);
6771
+                    }
6240 6772
                 }
6241 6773
                 $path = array_values($path);
6242 6774
 
@@ -6266,7 +6798,9 @@  discard block
 block discarded – undo
6266 6798
          */
6267 6799
         protected function _tag_open_POLYGON($param)
6268 6800
         {
6269
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON');
6801
+            if (!$this->_isInDraw) {
6802
+            	throw new HTML2PDF_exception(8, 'POLYGON');
6803
+            }
6270 6804
 
6271 6805
             $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6272 6806
             $this->parsingCss->save();
@@ -6282,7 +6816,9 @@  discard block
 block discarded – undo
6282 6816
                 $path = explode(' ', $path);
6283 6817
                 foreach ($path as $k => $v) {
6284 6818
                     $path[$k] = trim($v);
6285
-                    if ($path[$k]==='') unset($path[$k]);
6819
+                    if ($path[$k]==='') {
6820
+                    	unset($path[$k]);
6821
+                    }
6286 6822
                 }
6287 6823
                 $path = array_values($path);
6288 6824
 
@@ -6313,7 +6849,9 @@  discard block
 block discarded – undo
6313 6849
          */
6314 6850
         protected function _tag_open_PATH($param)
6315 6851
         {
6316
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'PATH');
6852
+            if (!$this->_isInDraw) {
6853
+            	throw new HTML2PDF_exception(8, 'PATH');
6854
+            }
6317 6855
 
6318 6856
             $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6319 6857
             $this->parsingCss->save();
@@ -6333,7 +6871,9 @@  discard block
 block discarded – undo
6333 6871
                 $path = explode(' ', $path);
6334 6872
                 foreach ($path as $k => $v) {
6335 6873
                     $path[$k] = trim($v);
6336
-                    if ($path[$k]==='') unset($path[$k]);
6874
+                    if ($path[$k]==='') {
6875
+                    	unset($path[$k]);
6876
+                    }
6337 6877
                 }
6338 6878
                 $path = array_values($path);
6339 6879
 
@@ -6442,7 +6982,9 @@  discard block
 block discarded – undo
6442 6982
          */
6443 6983
         protected function _tag_open_G($param)
6444 6984
         {
6445
-            if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'G');
6985
+            if (!$this->_isInDraw) {
6986
+            	throw new HTML2PDF_exception(8, 'G');
6987
+            }
6446 6988
 
6447 6989
             $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null);
6448 6990
             $this->parsingCss->save();
Please login to merge, or discard this patch.
includes/librairies/install.class.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @param integer $i The wpshop db version to execute operation for
282 282
 	 *
283
-	 * @return boolean
283
+	 * @return boolean|null
284 284
 	 */
285 285
 	public static function execute_operation_on_db_for_update($i){
286 286
 		global $wpdb, $wpshop_db_table, $wpshop_db_table_list, $wpshop_update_way, $wpshop_db_content_add, $wpshop_db_content_update, $wpshop_db_options_add, $wpshop_eav_content, $wpshop_eav_content_update, $wpshop_db_options_update, $wpshop_db_request, $wpshop_db_delete;
@@ -547,6 +547,7 @@  discard block
 block discarded – undo
547 547
 
548 548
 	/**
549 549
 	 * Manage special operation on wpshop plugin update
550
+	 * @param integer $version
550 551
 	 */
551 552
 	public static function make_specific_operation_on_update($version){
552 553
 		global $wpdb, $wp_rewrite;
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 class wpshop_install {
24 24
 
25 25
 	/**
26
-	*	Define the action launch when plugin is activate
27
-	*
28
-	* @return void
29
-	*/
26
+	 *	Define the action launch when plugin is activate
27
+	 *
28
+	 * @return void
29
+	 */
30 30
 	public static function install_on_activation(){
31 31
 		/*	Create the different option needed for the plugin work properly	*/
32 32
 		add_option('wpshop_db_options', array('db_version' => 0));
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 	 *
443 443
 	 * @param array $eav_content The complete array with all element to create into database
444 444
 	 * @param boolean $do_changes The current state of changes to do
445
-	 	*
445
+	 *
446 446
 	 * @return boolean If there are changes to do or not
447 447
 	 */
448 448
 	public static function update_eav_content( $eav_content, $do_changes ) {
Please login to merge, or discard this patch.
Spacing   +589 added lines, -589 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
 /**
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	*
28 28
 	* @return void
29 29
 	*/
30
-	public static function install_on_activation(){
30
+	public static function install_on_activation() {
31 31
 		/*	Create the different option needed for the plugin work properly	*/
32 32
 		add_option('wpshop_db_options', array('db_version' => 0));
33 33
 		add_option('wpshop_shop_default_currency', WPSHOP_SHOP_DEFAULT_CURRENCY);
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	/**
41 41
 	 *	Create the default pages
42 42
 	 */
43
-	public static function wpshop_insert_default_pages( $pages_type = '' ) {
43
+	public static function wpshop_insert_default_pages($pages_type = '') {
44 44
 		global $wpdb, $wp_rewrite;
45 45
 
46 46
 		/**	if we will create any new pages we need to flush page cache */
@@ -57,48 +57,48 @@  discard block
 block discarded – undo
57 57
 		);
58 58
 
59 59
 		/**	Get defined shop type	*/
60
-		$wpshop_shop_type = !empty( $pages_type ) ? $pages_type : get_option( 'wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE );
60
+		$wpshop_shop_type = !empty($pages_type) ? $pages_type : get_option('wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE);
61 61
 
62 62
 		/**	Get the default datas for installation - Pages	*/
63
-		$xml_default_pages = file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_pages.xml' );
64
-		$defined_default_pages = new SimpleXMLElement( $xml_default_pages );
65
-		foreach ( $defined_default_pages->xpath( '//pages/page' ) as $page ) {
66
-			if ( ( $wpshop_shop_type == $page->attributes()->shop_type ) || ( 'sale' == $wpshop_shop_type ) ) {
63
+		$xml_default_pages = file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_pages.xml');
64
+		$defined_default_pages = new SimpleXMLElement($xml_default_pages);
65
+		foreach ($defined_default_pages->xpath('//pages/page') as $page) {
66
+			if (($wpshop_shop_type == $page->attributes()->shop_type) || ('sale' == $wpshop_shop_type)) {
67 67
 				$page_id = null;
68 68
 
69 69
 				/**	Do a specific check for cart page, for old wpshop installation	*/
70
-				if ( 'wpshop_cart_page_id' == (string)$page->attributes()->code ) {
70
+				if ('wpshop_cart_page_id' == (string)$page->attributes()->code) {
71 71
 					$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_content LIKE %s	AND post_type != %s", '%[wpshop_basket]%', 'revision');
72 72
 					$page_id = $wpdb->get_var($query);
73 73
 
74
-					wp_update_post( array(
74
+					wp_update_post(array(
75 75
 						'ID' => $page_id,
76 76
 						'post_content' => (string)$page->content,
77
-					) );
77
+					));
78 78
 				}
79 79
 
80 80
 				/**	Check if a page exists with the current content readed form xml file	*/
81
-				if ( empty( $page_id ) ) {
81
+				if (empty($page_id)) {
82 82
 					$query = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE %s AND post_type != %s", '%' . (string)$page->content . '%', 'revision');
83 83
 					$page_id = $wpdb->get_var($query);
84 84
 				}
85 85
 
86 86
 				/**	If the page does not exists create it	*/
87
-				if ( empty( $page_id ) ) {
88
-					$default_page_args  = wp_parse_args( array(
89
-						'post_title' 	=> __( (string)$page->title, 'wpshop' ),
90
-						'post_name' 	=> __( (string)$page->slug, 'wpshop' ),
91
-						'post_content' 	=> __( (string)$page->content, 'wpshop' ),
87
+				if (empty($page_id)) {
88
+					$default_page_args = wp_parse_args(array(
89
+						'post_title' 	=> __((string)$page->title, 'wpshop'),
90
+						'post_name' 	=> __((string)$page->slug, 'wpshop'),
91
+						'post_content' 	=> __((string)$page->content, 'wpshop'),
92 92
 						'menu_order' 	=> (string)$page->attributes()->position,
93
-					), $page_default_args );
93
+					), $page_default_args);
94 94
 
95
-					$page_id = wp_insert_post( $default_page_args );
95
+					$page_id = wp_insert_post($default_page_args);
96 96
 					$created_pages[] = (string)$page->attributes()->code;
97 97
 				}
98 98
 
99 99
 				/**	If the page is created or already exists associated the page to the good service	*/
100
-				if ( !empty( $page_id ) ) {
101
-					add_option( (string)$page->attributes()->code, $page_id );
100
+				if (!empty($page_id)) {
101
+					add_option((string)$page->attributes()->code, $page_id);
102 102
 
103 103
 					$page_creation = true;
104 104
 				}
@@ -107,18 +107,18 @@  discard block
 block discarded – undo
107 107
 		}
108 108
 
109 109
 		/**	Check if page have been created in order to do specific action	*/
110
-		if ( !empty( $created_pages ) ) {
110
+		if (!empty($created_pages)) {
111 111
 			/**	If cart page and checkout page have just been created, change cart page id into checkout page id	*/
112
-			if ( in_array( 'wpshop_cart_page_id', $created_pages ) && in_array( 'wpshop_checkout_page_id', $created_pages ) ) {
113
-				update_option( 'wpshop_cart_page_id', get_option( 'wpshop_checkout_page_id' ) );
112
+			if (in_array('wpshop_cart_page_id', $created_pages) && in_array('wpshop_checkout_page_id', $created_pages)) {
113
+				update_option('wpshop_cart_page_id', get_option('wpshop_checkout_page_id'));
114 114
 			}
115 115
 
116 116
 		}
117 117
 
118 118
 		wp_cache_flush();
119 119
 		/** If new page => empty cache */
120
-		if ( $page_creation ) {
121
-			wp_cache_delete( 'all_page_ids', 'pages' );
120
+		if ($page_creation) {
121
+			wp_cache_delete('all_page_ids', 'pages');
122 122
 		//	$wp_rewrite->flush_rules();
123 123
 		}
124 124
 	}
@@ -138,54 +138,54 @@  discard block
 block discarded – undo
138 138
 		);
139 139
 
140 140
 		/**	Get the default datas for installation - sample products	*/
141
-		$sample_datas = file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/sample_datas.xml' );
142
-		$defined_sample_datas = new SimpleXMLElement( $sample_datas, LIBXML_NOCDATA );
141
+		$sample_datas = file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/sample_datas.xml');
142
+		$defined_sample_datas = new SimpleXMLElement($sample_datas, LIBXML_NOCDATA);
143 143
 
144 144
 		$namespaces = $defined_sample_datas->getDocNamespaces();
145
-		if ( ! isset( $namespaces['wp'] ) )
145
+		if (!isset($namespaces['wp']))
146 146
 			$namespaces['wp'] = 'http://wordpress.org/export/1.1/';
147
-		if ( ! isset( $namespaces['excerpt'] ) )
147
+		if (!isset($namespaces['excerpt']))
148 148
 			$namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/';
149 149
 
150
-		foreach ( $defined_sample_datas->xpath( '//wpshop_products/wpshop_product' ) as $product ) {
151
-			$dc = $product->children( 'http://purl.org/dc/elements/1.1/' );
152
-			$content = $product->children( 'http://purl.org/rss/1.0/modules/content/' );
153
-			$excerpt = $product->children( $namespaces['excerpt'] );
154
-			$wp = $product->children( $namespaces['wp'] );
150
+		foreach ($defined_sample_datas->xpath('//wpshop_products/wpshop_product') as $product) {
151
+			$dc = $product->children('http://purl.org/dc/elements/1.1/');
152
+			$content = $product->children('http://purl.org/rss/1.0/modules/content/');
153
+			$excerpt = $product->children($namespaces['excerpt']);
154
+			$wp = $product->children($namespaces['wp']);
155 155
 
156
-			$product_args  = wp_parse_args( array(
156
+			$product_args = wp_parse_args(array(
157 157
 				'post_title' => (string)$product->title,
158
-				'post_name' => (string) $wp->post_name,
159
-				'post_content' => (string) $content->encoded,
160
-				'post_excerpt' => (string) $excerpt->encoded,
161
-				'post_type' => (string) $wp->post_type,
162
-			), $product_default_args );
158
+				'post_name' => (string)$wp->post_name,
159
+				'post_content' => (string)$content->encoded,
160
+				'post_excerpt' => (string)$excerpt->encoded,
161
+				'post_type' => (string)$wp->post_type,
162
+			), $product_default_args);
163 163
 
164
-			$product_id = wp_insert_post( $product_args );
164
+			$product_id = wp_insert_post($product_args);
165 165
 
166
-			foreach ( $wp->postmeta as $meta ) {
167
-				update_post_meta( $product_id, (string)$meta->meta_key, (string)$meta->meta_value);
166
+			foreach ($wp->postmeta as $meta) {
167
+				update_post_meta($product_id, (string)$meta->meta_key, (string)$meta->meta_value);
168 168
 			}
169 169
 
170
-			foreach ( $defined_sample_datas->xpath( '//wps_pdt_variations/wps_pdt_variation/wp:post_parent[. ="' . $wp->post_id . '"]/parent::*' ) as $product_variation ) {
171
-				$wps_pdt_var_dc = $product_variation->children( 'http://purl.org/dc/elements/1.1/' );
172
-				$wps_pdt_var_content = $product_variation->children( 'http://purl.org/rss/1.0/modules/content/' );
173
-				$wps_pdt_var_excerpt = $product_variation->children( $namespaces['excerpt'] );
174
-				$wps_pdt_var_wp = $product_variation->children( $namespaces['wp'] );
170
+			foreach ($defined_sample_datas->xpath('//wps_pdt_variations/wps_pdt_variation/wp:post_parent[. ="' . $wp->post_id . '"]/parent::*') as $product_variation) {
171
+				$wps_pdt_var_dc = $product_variation->children('http://purl.org/dc/elements/1.1/');
172
+				$wps_pdt_var_content = $product_variation->children('http://purl.org/rss/1.0/modules/content/');
173
+				$wps_pdt_var_excerpt = $product_variation->children($namespaces['excerpt']);
174
+				$wps_pdt_var_wp = $product_variation->children($namespaces['wp']);
175 175
 
176
-				$product_args  = wp_parse_args( array(
176
+				$product_args = wp_parse_args(array(
177 177
 						'post_title' => (string)$product_variation->title,
178
-						'post_name' => (string) $wps_pdt_var_wp->post_name,
179
-						'post_content' => (string) $wps_pdt_var_content->encoded,
180
-						'post_excerpt' => (string) $wps_pdt_var_excerpt->encoded,
181
-						'post_type' => (string) $wps_pdt_var_wp->post_type,
178
+						'post_name' => (string)$wps_pdt_var_wp->post_name,
179
+						'post_content' => (string)$wps_pdt_var_content->encoded,
180
+						'post_excerpt' => (string)$wps_pdt_var_excerpt->encoded,
181
+						'post_type' => (string)$wps_pdt_var_wp->post_type,
182 182
 						'post_parent' => $product_id,
183
-				), $product_default_args );
183
+				), $product_default_args);
184 184
 
185
-				$product_variation_id = wp_insert_post( $product_args );
185
+				$product_variation_id = wp_insert_post($product_args);
186 186
 
187
-				foreach ( $wps_pdt_var_wp->postmeta as $meta ) {
188
-					update_post_meta( $product_variation_id, (string)$meta->meta_key, (string)$meta->meta_value);
187
+				foreach ($wps_pdt_var_wp->postmeta as $meta) {
188
+					update_post_meta($product_variation_id, (string)$meta->meta_key, (string)$meta->meta_value);
189 189
 				}
190 190
 			}
191 191
 		}
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
 		$version_nb_delta = $current_def_max_version - $current_db_version;
220 220
 
221 221
 		/*	Check if there are modification to do	*/
222
-		if($current_def_max_version >= $current_db_version){
222
+		if ($current_def_max_version >= $current_db_version) {
223 223
 			/*	Check the lowest version of db to execute	*/
224 224
 			$lowest_version_to_execute = $current_def_max_version - $version_nb_delta;
225 225
 
226
-			for($i = $lowest_version_to_execute; $i <= $current_def_max_version; $i++){
226
+			for ($i = $lowest_version_to_execute; $i <= $current_def_max_version; $i++) {
227 227
 				$do_changes = self::execute_operation_on_db_for_update($i);
228 228
 			}
229 229
 		}
230 230
 
231 231
 		/*	Update the db version option value	*/
232
-		if($do_changes){
232
+		if ($do_changes) {
233 233
 			$db_version = get_option('wpshop_db_options', 0);
234 234
 			$db_version['db_version'] = $new_version;
235 235
 			update_option('wpshop_db_options', $db_version);
@@ -242,31 +242,31 @@  discard block
 block discarded – undo
242 242
 	 * @param integer $i The current plugin db version
243 243
 	 * @return boolean If the changes are done correctly or not
244 244
 	 */
245
-	public static function alter_db_structure_on_update( $i ) {
245
+	public static function alter_db_structure_on_update($i) {
246 246
 		$do_changes = false;
247 247
 		global $wpdb, $wpshop_db_table, $wpshop_db_table_list, $wpshop_update_way, $wpshop_db_request, $wpshop_db_delete;
248 248
 
249 249
 		/*	Check if there are modification to do	*/
250
-		if(isset($wpshop_update_way[$i])){
250
+		if (isset($wpshop_update_way[$i])) {
251 251
 			/*	Check if there are modification to make on table	*/
252
-			if(isset($wpshop_db_table_list[$i])){
253
-				foreach($wpshop_db_table_list[$i] as $table_name){
252
+			if (isset($wpshop_db_table_list[$i])) {
253
+				foreach ($wpshop_db_table_list[$i] as $table_name) {
254 254
 					dbDelta($wpshop_db_table[$table_name]);
255 255
 				}
256 256
 				$do_changes = true;
257 257
 			}
258 258
 
259 259
 			/*	Request maker	*/
260
-			if(isset($wpshop_db_request[$i]) && is_array($wpshop_db_request) && is_array($wpshop_db_request[$i]) && (count($wpshop_db_request[$i]) > 0)){
261
-				foreach($wpshop_db_request[$i] as $request){
260
+			if (isset($wpshop_db_request[$i]) && is_array($wpshop_db_request) && is_array($wpshop_db_request[$i]) && (count($wpshop_db_request[$i]) > 0)) {
261
+				foreach ($wpshop_db_request[$i] as $request) {
262 262
 					$wpdb->query($request);
263 263
 					$do_changes = true;
264 264
 				}
265 265
 			}
266 266
 
267 267
 			/*	Delete datas	*/
268
-			if(isset($wpshop_db_delete[$i]) && is_array($wpshop_db_delete) && is_array($wpshop_db_delete[$i]) && (count($wpshop_db_delete[$i]) > 0)){
269
-				foreach($wpshop_db_delete[$i] as $request){
268
+			if (isset($wpshop_db_delete[$i]) && is_array($wpshop_db_delete) && is_array($wpshop_db_delete[$i]) && (count($wpshop_db_delete[$i]) > 0)) {
269
+				foreach ($wpshop_db_delete[$i] as $request) {
270 270
 					$wpdb->query($request);
271 271
 				}
272 272
 			}
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
 	 *
283 283
 	 * @return boolean
284 284
 	 */
285
-	public static function execute_operation_on_db_for_update($i){
285
+	public static function execute_operation_on_db_for_update($i) {
286 286
 		global $wpdb, $wpshop_db_table, $wpshop_db_table_list, $wpshop_update_way, $wpshop_db_content_add, $wpshop_db_content_update, $wpshop_db_options_add, $wpshop_eav_content, $wpshop_eav_content_update, $wpshop_db_options_update, $wpshop_db_request, $wpshop_db_delete;
287 287
 		$do_changes = false;
288 288
 
289 289
 		/*	Check if there are modification to do	*/
290
-		if(isset($wpshop_update_way[$i])){
290
+		if (isset($wpshop_update_way[$i])) {
291 291
 			$do_changes = self::alter_db_structure_on_update($i);
292 292
 
293 293
 
@@ -295,16 +295,16 @@  discard block
 block discarded – undo
295 295
 			/*		Insert data		*/
296 296
 			/********************/
297 297
 			/*	Options content	*/
298
-			if(isset($wpshop_db_options_add[$i]) && is_array($wpshop_db_options_add) && is_array($wpshop_db_options_add[$i]) && (count($wpshop_db_options_add[$i]) > 0)){
299
-				foreach($wpshop_db_options_add[$i] as $option_name => $option_content){
298
+			if (isset($wpshop_db_options_add[$i]) && is_array($wpshop_db_options_add) && is_array($wpshop_db_options_add[$i]) && (count($wpshop_db_options_add[$i]) > 0)) {
299
+				foreach ($wpshop_db_options_add[$i] as $option_name => $option_content) {
300 300
 					add_option($option_name, $option_content, '', 'yes');
301 301
 				}
302 302
 				$do_changes = true;
303 303
 			}
304
-			if(isset($wpshop_db_options_update[$i]) && is_array($wpshop_db_options_update) && is_array($wpshop_db_options_update[$i]) && (count($wpshop_db_options_update[$i]) > 0)){
305
-				foreach($wpshop_db_options_update[$i] as $option_name => $option_content){
304
+			if (isset($wpshop_db_options_update[$i]) && is_array($wpshop_db_options_update) && is_array($wpshop_db_options_update[$i]) && (count($wpshop_db_options_update[$i]) > 0)) {
305
+				foreach ($wpshop_db_options_update[$i] as $option_name => $option_content) {
306 306
 					$option_current_content = get_option($option_name);
307
-					foreach($option_content as $option_key => $option_value){
307
+					foreach ($option_content as $option_key => $option_value) {
308 308
 						$option_current_content[$option_key] = $option_value;
309 309
 					}
310 310
 					update_option($option_name, $option_current_content);
@@ -313,18 +313,18 @@  discard block
 block discarded – undo
313 313
 			}
314 314
 
315 315
 			/*	Eav content	*/
316
-			if(isset($wpshop_eav_content[$i]) && is_array($wpshop_eav_content) && is_array($wpshop_eav_content[$i]) && (count($wpshop_eav_content[$i]) > 0)){
316
+			if (isset($wpshop_eav_content[$i]) && is_array($wpshop_eav_content) && is_array($wpshop_eav_content[$i]) && (count($wpshop_eav_content[$i]) > 0)) {
317 317
 				$do_changes = self::add_content_to_eav($wpshop_eav_content[$i], $do_changes);
318 318
 			}
319 319
 			/*	Eav content update	*/
320
-			if(isset($wpshop_eav_content_update[$i]) && is_array($wpshop_eav_content_update) && is_array($wpshop_eav_content_update[$i]) && (count($wpshop_eav_content_update[$i]) > 0)){
320
+			if (isset($wpshop_eav_content_update[$i]) && is_array($wpshop_eav_content_update) && is_array($wpshop_eav_content_update[$i]) && (count($wpshop_eav_content_update[$i]) > 0)) {
321 321
 				$do_changes = self::add_content_to_eav($wpshop_eav_content_update[$i], $do_changes);
322 322
 			}
323 323
 
324 324
 			/*	Add datas	*/
325
-			if(isset($wpshop_db_content_add[$i]) && is_array($wpshop_db_content_add) && is_array($wpshop_db_content_add[$i]) && (count($wpshop_db_content_add[$i]) > 0)){
326
-				foreach($wpshop_db_content_add[$i] as $table_name => $def){
327
-					foreach($def as $information_index => $table_information){
325
+			if (isset($wpshop_db_content_add[$i]) && is_array($wpshop_db_content_add) && is_array($wpshop_db_content_add[$i]) && (count($wpshop_db_content_add[$i]) > 0)) {
326
+				foreach ($wpshop_db_content_add[$i] as $table_name => $def) {
327
+					foreach ($def as $information_index => $table_information) {
328 328
 						$wpdb->insert($table_name, $table_information, '%s');
329 329
 						$do_changes = true;
330 330
 					}
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
 			}
333 333
 
334 334
 			/*	Update datas	*/
335
-			if(isset($wpshop_db_content_update[$i]) && is_array($wpshop_db_content_update) && is_array($wpshop_db_content_update[$i]) && (count($wpshop_db_content_update[$i]) > 0)){
336
-				foreach($wpshop_db_content_update[$i] as $table_name => $def){
337
-					foreach($def as $information_index => $table_information){
335
+			if (isset($wpshop_db_content_update[$i]) && is_array($wpshop_db_content_update) && is_array($wpshop_db_content_update[$i]) && (count($wpshop_db_content_update[$i]) > 0)) {
336
+				foreach ($wpshop_db_content_update[$i] as $table_name => $def) {
337
+					foreach ($def as $information_index => $table_information) {
338 338
 						$wpdb->update($table_name, $table_information['datas'], $table_information['where'], '%s', '%s');
339 339
 						$do_changes = true;
340 340
 					}
@@ -355,54 +355,54 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
 	 * @return boolean If there are changes to do or not
357 357
 	 */
358
-	public static function add_content_to_eav( $eav_content, $do_changes ) {
358
+	public static function add_content_to_eav($eav_content, $do_changes) {
359 359
 		global $wpdb;
360 360
 		/*	Create entities if entites are set to be created for the current version	*/
361
-		if(isset($eav_content['entities']) && is_array($eav_content['entities']) && is_array($eav_content['entities']) && (count($eav_content['entities']) > 0)){
362
-			foreach($eav_content['entities'] as $entity){
361
+		if (isset($eav_content['entities']) && is_array($eav_content['entities']) && is_array($eav_content['entities']) && (count($eav_content['entities']) > 0)) {
362
+			foreach ($eav_content['entities'] as $entity) {
363 363
 				/*	Creation de l'entité produit dans la table des posts	*/
364
-				wpshop_entities::create_cpt_from_csv_file( $entity );
364
+				wpshop_entities::create_cpt_from_csv_file($entity);
365 365
 			}
366 366
 			$do_changes = true;
367 367
 		}
368 368
 
369 369
 		/*	Create attributes for a given entity if attributes are set to be created for current version	*/
370 370
 		if (!empty($eav_content['attributes']) && is_array($eav_content['attributes']) && is_array($eav_content['attributes']) && (count($eav_content['attributes']) > 0)) {
371
-			foreach($eav_content['attributes'] as $entity_code){
372
-				wpshop_entities::create_cpt_attributes_from_csv_file( $entity_code );
371
+			foreach ($eav_content['attributes'] as $entity_code) {
372
+				wpshop_entities::create_cpt_attributes_from_csv_file($entity_code);
373 373
 			}
374 374
 			$do_changes = true;
375 375
 		}
376 376
 
377 377
 		/*	Create attribute groups for a given entity if attributes groups are set to be created for current version	*/
378
-		if(isset($eav_content['attribute_groups']) && is_array($eav_content['attribute_groups']) && (count($eav_content['attribute_groups']) > 0)){
379
-			foreach($eav_content['attribute_groups'] as $entity_code => $attribute_set){
378
+		if (isset($eav_content['attribute_groups']) && is_array($eav_content['attribute_groups']) && (count($eav_content['attribute_groups']) > 0)) {
379
+			foreach ($eav_content['attribute_groups'] as $entity_code => $attribute_set) {
380 380
 				$entity_id = wpshop_entities::get_entity_identifier_from_code($entity_code);
381 381
 
382
-				if($entity_id > 0){
383
-					foreach($attribute_set as $set_name => $set_groups){
382
+				if ($entity_id > 0) {
383
+					foreach ($attribute_set as $set_name => $set_groups) {
384 384
 						$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE entity_id = %d AND name = LOWER(%s)", $entity_id, wpshop_tools::slugify($set_name, array('noAccent', 'noSpaces', 'lowerCase')));
385 385
 						$attribute_set_id = $wpdb->get_var($query);
386
-						if($attribute_set_id <= 0){
386
+						if ($attribute_set_id <= 0) {
387 387
 							$attribute_set_content = array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_id' => $entity_id, 'name' => $set_name);
388
-							if($set_name == 'default'){
388
+							if ($set_name == 'default') {
389 389
 								$attribute_set_content['default_set'] = 'yes';
390 390
 							}
391 391
 							$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_SET, $attribute_set_content);
392 392
 							$attribute_set_id = $wpdb->insert_id;
393 393
 						}
394 394
 
395
-						if($attribute_set_id > 0){
396
-							foreach($set_groups as $set_group_infos){
395
+						if ($attribute_set_id > 0) {
396
+							foreach ($set_groups as $set_group_infos) {
397 397
 								$set_group_infos_details = $set_group_infos['details'];
398 398
 								unset($set_group_infos['details']);
399 399
 								/*	Change an attribute set status if definition specify this param 	*/
400
-								if(isset($set_group_infos['status'])){
400
+								if (isset($set_group_infos['status'])) {
401 401
 									$wpdb->update(WPSHOP_DBT_ATTRIBUTE_SET, array('last_update_date' => current_time('mysql', 0), 'status' => $set_group_infos['status']), array('id' => $attribute_set_id));
402 402
 								}
403 403
 								$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %d AND code = LOWER(%s)", $attribute_set_id, $set_group_infos['code']);
404 404
 								$attribute_set_section_id = $wpdb->get_var($query);
405
-								if($attribute_set_section_id <= 0){
405
+								if ($attribute_set_section_id <= 0) {
406 406
 									$new_set_section_infos = $set_group_infos;
407 407
 									$new_set_section_infos['status'] = (isset($new_set_section_infos['status']) ? $new_set_section_infos['status'] : 'valid');
408 408
 									$new_set_section_infos['creation_date'] = current_time('mysql', 0);
@@ -411,15 +411,15 @@  discard block
 block discarded – undo
411 411
 									$attribute_set_section_id = $wpdb->insert_id;
412 412
 								}
413 413
 
414
-								if(($attribute_set_section_id > 0) && (isset($set_group_infos_details) && is_array($set_group_infos_details) && (count($set_group_infos_details) > 0))){
414
+								if (($attribute_set_section_id > 0) && (isset($set_group_infos_details) && is_array($set_group_infos_details) && (count($set_group_infos_details) > 0))) {
415 415
 									$query = $wpdb->prepare("SELECT MAX(position) AS position FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d", $entity_id, $attribute_set_id, $attribute_set_section_id);
416 416
 									$last_position = $wpdb->get_var($query);
417 417
 									$position = (int)$last_position + 1;
418
-									foreach($set_group_infos_details as $attribute_code){
418
+									foreach ($set_group_infos_details as $attribute_code) {
419 419
 										$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $attribute_code, $entity_id);
420 420
 										$attribute_id = $wpdb->get_row($query);
421 421
 
422
-										if($attribute_id->id > 0){
422
+										if ($attribute_id->id > 0) {
423 423
 											$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $attribute_id->id, 'position' => $position));
424 424
 											$position++;
425 425
 										}
@@ -445,13 +445,13 @@  discard block
 block discarded – undo
445 445
 	 	*
446 446
 	 * @return boolean If there are changes to do or not
447 447
 	 */
448
-	public static function update_eav_content( $eav_content, $do_changes ) {
448
+	public static function update_eav_content($eav_content, $do_changes) {
449 449
 		/*	Update attributes fo a given entity if attributes are set to be updated for current version	*/
450
-		if(isset($eav_content['attributes']) && is_array($eav_content['attributes']) && (count($eav_content['attributes']) > 0)){
451
-			foreach($eav_content['attributes'] as $entity_code => $attribute_definition){
452
-				foreach($attribute_definition as $attribute_def){
450
+		if (isset($eav_content['attributes']) && is_array($eav_content['attributes']) && (count($eav_content['attributes']) > 0)) {
451
+			foreach ($eav_content['attributes'] as $entity_code => $attribute_definition) {
452
+				foreach ($attribute_definition as $attribute_def) {
453 453
 					$option_list_for_attribute = '';
454
-					if(isset($attribute_def['backend_input_values'])){
454
+					if (isset($attribute_def['backend_input_values'])) {
455 455
 						$option_list_for_attribute = $attribute_def['backend_input_values'];
456 456
 						unset($attribute_def['backend_input_values']);
457 457
 					}
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
 					$attribute_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_def['code']));
466 466
 
467 467
 					/*	Insert option values if there are some to add for the current attribute	*/
468
-					if(($option_list_for_attribute != '') && (is_array($option_list_for_attribute))){
469
-						foreach($option_list_for_attribute as $option_code => $option_value){
468
+					if (($option_list_for_attribute != '') && (is_array($option_list_for_attribute))) {
469
+						foreach ($option_list_for_attribute as $option_code => $option_value) {
470 470
 							$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' => $attribute_id, 'label' => ((substr($option_code, 0, 2) != '__') ? $option_value : __(substr($option_code, 2), 'wpshop')), 'value' => $option_value));
471
-							if($option_code == $attribute_def['default_value']){
471
+							if ($option_code == $attribute_def['default_value']) {
472 472
 								$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('last_update_date' => current_time('mysql', 0), 'default_value' => $wpdb->insert_id), array('id' => $attribute_id, 'default_value' => $option_code));
473 473
 							}
474 474
 						}
@@ -479,30 +479,30 @@  discard block
 block discarded – undo
479 479
 		}
480 480
 
481 481
 		/*	Update attribute groups fo a given entity if attributes groups are set to be updated for current version	*/
482
-		if(is_array($eav_content['attribute_groups']) && is_array($eav_content['attribute_groups']) && (count($eav_content['attribute_groups']) > 0)){
483
-			foreach($eav_content['attribute_groups'] as $entity_code => $attribute_set){
482
+		if (is_array($eav_content['attribute_groups']) && is_array($eav_content['attribute_groups']) && (count($eav_content['attribute_groups']) > 0)) {
483
+			foreach ($eav_content['attribute_groups'] as $entity_code => $attribute_set) {
484 484
 				$entity_id = wpshop_entities::get_entity_identifier_from_code($entity_code);
485 485
 
486
-				if($entity_id > 0){
487
-					foreach($attribute_set as $set_name => $set_groups){
486
+				if ($entity_id > 0) {
487
+					foreach ($attribute_set as $set_name => $set_groups) {
488 488
 						$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE entity_id = %d AND name = LOWER(%s)", $entity_id, wpshop_tools::slugify($set_name, array('noAccent', 'noSpaces', 'lowerCase')));
489 489
 						$attribute_set_id = $wpdb->get_var($query);
490
-						if($attribute_set_id <= 0){
490
+						if ($attribute_set_id <= 0) {
491 491
 							$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_SET, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_id' => $entity_id, 'name' => $set_name));
492 492
 							$attribute_set_id = $wpdb->insert_id;
493 493
 						}
494 494
 
495
-						if($attribute_set_id > 0){
496
-							foreach($set_groups as $set_group_infos){
495
+						if ($attribute_set_id > 0) {
496
+							foreach ($set_groups as $set_group_infos) {
497 497
 								$set_group_infos_details = $set_group_infos['details'];
498 498
 								unset($set_group_infos['details']);
499 499
 								/*	Change an attribute set status if definition specify this param 	*/
500
-								if(isset($set_group_infos['status'])){
500
+								if (isset($set_group_infos['status'])) {
501 501
 									$wpdb->update(WPSHOP_DBT_ATTRIBUTE_SET, array('last_update_date' => current_time('mysql', 0), 'status' => $set_group_infos['status']), array('id' => $attribute_set_id));
502 502
 								}
503 503
 								$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %d AND code = LOWER(%s)", $attribute_set_id, $set_group_infos['code']);
504 504
 								$attribute_set_section_id = $wpdb->get_var($query);
505
-								if($attribute_set_section_id <= 0){
505
+								if ($attribute_set_section_id <= 0) {
506 506
 									$new_set_section_infos = $set_group_infos;
507 507
 									$new_set_section_infos['status'] = (isset($new_set_section_infos['status']) ? $new_set_section_infos['status'] : 'valid');
508 508
 									$new_set_section_infos['creation_date'] = current_time('mysql', 0);
@@ -510,24 +510,24 @@  discard block
 block discarded – undo
510 510
 									$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, $new_set_section_infos);
511 511
 									$attribute_set_section_id = $wpdb->insert_id;
512 512
 								}
513
-								else{
513
+								else {
514 514
 									$new_set_section_infos = $set_group_infos;
515 515
 									$new_set_section_infos['last_update_date'] = current_time('mysql', 0);
516 516
 									$wpdb->update(WPSHOP_DBT_ATTRIBUTE_GROUP, $new_set_section_infos, array('id' => $attribute_set_section_id));
517 517
 								}
518 518
 
519
-								if(($attribute_set_section_id > 0) && (isset($set_group_infos_details) && is_array($set_group_infos_details))){
520
-									if(count($set_group_infos_details) <= 0){
519
+								if (($attribute_set_section_id > 0) && (isset($set_group_infos_details) && is_array($set_group_infos_details))) {
520
+									if (count($set_group_infos_details) <= 0) {
521 521
 										$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'status' => 'deleted'), array('entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id));
522 522
 									}
523
-									else{
523
+									else {
524 524
 										$query = $wpdb->prepare("SELECT MAX(position) AS position FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d", $entity_id, $attribute_set_id, $attribute_set_section_id);
525 525
 										$last_position = $wpdb->get_var($query);
526 526
 										$position = (int)$last_position + 1;
527
-										foreach($set_group_infos_details as $attribute_code){
527
+										foreach ($set_group_infos_details as $attribute_code) {
528 528
 											$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $attribute_code, $entity_id);
529 529
 											$attribute_id = $wpdb->get_var($query);
530
-											if($attribute_id > 0){
530
+											if ($attribute_id > 0) {
531 531
 												$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $attribute_id, 'position' => $position));
532 532
 												$position++;
533 533
 											}
@@ -548,11 +548,11 @@  discard block
 block discarded – undo
548 548
 	/**
549 549
 	 * Manage special operation on wpshop plugin update
550 550
 	 */
551
-	public static function make_specific_operation_on_update($version){
551
+	public static function make_specific_operation_on_update($version) {
552 552
 		global $wpdb, $wp_rewrite;
553 553
 		$wpshop_shop_type = get_option('wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE);
554 554
 
555
-		switch($version){
555
+		switch ($version) {
556 556
 			case 3:
557 557
 			case 6:
558 558
  				self::wpshop_insert_default_pages($wpshop_shop_type);
@@ -561,38 +561,38 @@  discard block
 block discarded – undo
561 561
 			break;
562 562
 			case 8:
563 563
 				/**	Change metaboxes order for product in case it already exists	*/
564
-				$query = $wpdb->prepare( "SELECT umeta_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key = %s", 'meta-box-order_wpshop_product' );
565
-				$customer_metaboxes_order = $wpdb->get_results( $query );
566
-				if ( !empty( $customer_metaboxes_order ) ) {
567
-					foreach ( $customer_metaboxes_order as $customer_metabox_order ) {
564
+				$query = $wpdb->prepare("SELECT umeta_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key = %s", 'meta-box-order_wpshop_product');
565
+				$customer_metaboxes_order = $wpdb->get_results($query);
566
+				if (!empty($customer_metaboxes_order)) {
567
+					foreach ($customer_metaboxes_order as $customer_metabox_order) {
568 568
 						$do_changes = false;
569
-						$current_order = unserialize( $customer_metabox_order->meta_value );
570
-						if ( array_key_exists( 'normal', $current_order ) && ( false !== strpos( 'wpshop_product_important_datas', $current_order[ 'normal' ] ) ) ) {
571
-							str_replace( 'wpshop_product_important_datas,', '', $current_order[ 'normal' ] );
569
+						$current_order = unserialize($customer_metabox_order->meta_value);
570
+						if (array_key_exists('normal', $current_order) && (false !== strpos('wpshop_product_important_datas', $current_order['normal']))) {
571
+							str_replace('wpshop_product_important_datas,', '', $current_order['normal']);
572 572
 							$do_changes = true;
573 573
 						}
574 574
 
575
-						if ( array_key_exists( 'side', $current_order ) ) {
576
-							str_replace( 'wpshop_product_important_datas,', '', $current_order[ 'side' ] );
577
-							str_replace( 'submitdiv,', 'submitdiv,wpshop_product_important_datas,', $current_order[ 'side' ] );
575
+						if (array_key_exists('side', $current_order)) {
576
+							str_replace('wpshop_product_important_datas,', '', $current_order['side']);
577
+							str_replace('submitdiv,', 'submitdiv,wpshop_product_important_datas,', $current_order['side']);
578 578
 							$do_changes = true;
579 579
 						}
580 580
 
581
-						if ( true === $do_changes ) {
582
-							$wpdb->update( $wpdb->usermeta, array( 'meta_value' => serialize( $current_order ), ), array( 'umeta_id' => $customer_metabox_order->umeta_id ) );
581
+						if (true === $do_changes) {
582
+							$wpdb->update($wpdb->usermeta, array('meta_value' => serialize($current_order),), array('umeta_id' => $customer_metabox_order->umeta_id));
583 583
 						}
584 584
 					}
585 585
 				}
586 586
 				else {
587
-					$users = get_users( array( 'role' => 'administrator', ) );
588
-					if ( !empty( $users ) ) {
589
-						foreach ( $users as $user ) {
587
+					$users = get_users(array('role' => 'administrator',));
588
+					if (!empty($users)) {
589
+						foreach ($users as $user) {
590 590
 							$user_meta = array(
591 591
 								'side' => 'submitdiv,formatdiv,wpshop_product_important_datas,wpshop_product_categorydiv,pageparentdiv,wps_barcode_product,wpshop_product_actions,wpshop_product_options,postimagediv',
592 592
 								'normal' => 'wpshop_product_fixed_tab,postexcerpt,trackbacksdiv,postcustom,commentstatusdiv,slugdiv,authordiv,wpshop_wpshop_variations,wps_media_manager,wpshop_product_order_historic',
593 593
 								'advanced' => '',
594 594
 							);
595
-							update_user_meta( $user->ID, 'meta-box-order_wpshop_product', $user_meta );
595
+							update_user_meta($user->ID, 'meta-box-order_wpshop_product', $user_meta);
596 596
 						}
597 597
 					}
598 598
 				}
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 				$tax_id = $wpdb->get_var($wpdb->prepare("SELECT ATT_OPT.id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " AS ATT_OPT WHERE attribute_id = %d AND value = '20'", $product_prices->tx_tva));
609 609
 				$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . " WHERE attribute_id = %d", $product_prices->product_price);
610 610
 				$price_list = $wpdb->get_results($query);
611
-				foreach($price_list as $existing_ttc_price){
611
+				foreach ($price_list as $existing_ttc_price) {
612 612
 					$tax_rate = 1.20;
613 613
 					$price_ht = $existing_ttc_price->value / $tax_rate;
614 614
 					$tax_amount = $existing_ttc_price->value - $price_ht;
@@ -619,24 +619,24 @@  discard block
 block discarded – undo
619 619
 				}
620 620
 
621 621
 				/*	Update orders structure into database	*/
622
-				$orders_id = $wpdb->get_results('SELECT ID FROM '.$wpdb->posts.' WHERE post_type = "'.WPSHOP_NEWTYPE_IDENTIFIER_ORDER.'"');
622
+				$orders_id = $wpdb->get_results('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '"');
623 623
 				foreach ($orders_id as $o) {
624 624
 					$myorder = get_post_meta($o->ID, '_order_postmeta', true);
625 625
 					$neworder = array();
626 626
 					$items = array();
627 627
 
628
-					if(!isset($myorder['order_tva'])){
628
+					if (!isset($myorder['order_tva'])) {
629 629
 						$order_total_ht = 0;
630 630
 						$order_total_ttc = 0;
631 631
 						$order_tva = array('20'=>0);
632 632
 
633 633
 						foreach ($myorder['order_items'] as $item) {
634 634
 							/* item */
635
-							$pu_ht = $item['cost']/1.20;
636
-							$pu_tva = $item['cost']-$pu_ht;
637
-							$total_ht = $pu_ht*$item['qty'];
638
-							$tva_total_amount = $pu_tva*$item['qty'];
639
-							$total_ttc = $item['cost']*$item['qty'];
635
+							$pu_ht = $item['cost'] / 1.20;
636
+							$pu_tva = $item['cost'] - $pu_ht;
637
+							$total_ht = $pu_ht * $item['qty'];
638
+							$tva_total_amount = $pu_tva * $item['qty'];
639
+							$total_ttc = $item['cost'] * $item['qty'];
640 640
 							/* item */
641 641
 							$order_total_ht += $total_ht;
642 642
 							$order_total_ttc += $total_ttc;
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 							'order_total_ttc' => $order_total_ttc,
684 684
 							'order_grand_total' => $order_total_ttc,
685 685
 							'order_shipping_cost' => number_format(0, 2, '.', ''),
686
-							'order_tva' => array_map(array( 'wpshop_tools', 'number_format_hack' ), $order_tva),
686
+							'order_tva' => array_map(array('wpshop_tools', 'number_format_hack'), $order_tva),
687 687
 							'order_items' => $items
688 688
 						);
689 689
 						/* Update the order postmeta */
@@ -698,29 +698,29 @@  discard block
 block discarded – undo
698 698
 			case 12:
699 699
 				$query = "SELECT ID FROM " . $wpdb->users;
700 700
 				$user_list = $wpdb->get_results($query);
701
-				foreach($user_list as $user){
701
+				foreach ($user_list as $user) {
702 702
 					$user_first_name = get_user_meta($user->ID, 'first_name', true);
703 703
 					$user_last_name = get_user_meta($user->ID, 'last_name', true);
704 704
 					$shipping_info = get_user_meta($user->ID, 'shipping_info', true);
705 705
 
706
-					if(($user_first_name == '') && !empty($shipping_info['first_name'])){
706
+					if (($user_first_name == '') && !empty($shipping_info['first_name'])) {
707 707
 						update_user_meta($user->ID, 'first_name', $shipping_info['first_name']);
708 708
 					}
709 709
 
710
-					if(($user_last_name == '') && !empty($shipping_info['last_name'])){
710
+					if (($user_last_name == '') && !empty($shipping_info['last_name'])) {
711 711
 						update_user_meta($user->ID, 'last_name', $shipping_info['last_name']);
712 712
 					}
713 713
 				}
714 714
 
715 715
 				/*	Update orders structure into database	*/
716
-				$orders_id = $wpdb->get_results('SELECT ID FROM '.$wpdb->posts.' WHERE post_type = "'.WPSHOP_NEWTYPE_IDENTIFIER_ORDER.'"');
717
-				foreach($orders_id as $o){
716
+				$orders_id = $wpdb->get_results('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '"');
717
+				foreach ($orders_id as $o) {
718 718
 					$myorder = get_post_meta($o->ID, '_order_postmeta', true);
719
-					if(!empty($myorder)){
719
+					if (!empty($myorder)) {
720 720
 						$new_items = array();
721
-						foreach($myorder['order_items'] as $item){
721
+						foreach ($myorder['order_items'] as $item) {
722 722
 							$new_items = $item;
723
-							$new_items['item_discount_type'] = !empty($item['item_discount_rate'])?$item['item_discount_rate']:'amount';
723
+							$new_items['item_discount_type'] = !empty($item['item_discount_rate']) ? $item['item_discount_rate'] : 'amount';
724 724
 							// unset($new_items['item_discount_rate']);
725 725
 							$new_items['item_discount_value'] = 0;
726 726
 						}
@@ -740,12 +740,12 @@  discard block
 block discarded – undo
740 740
 			break;
741 741
 			case 13:
742 742
 				$attribute_used_for_sort_by = wpshop_attributes::getElement('yes', "'valid', 'moderated', 'notused'", 'is_used_for_sort_by', true);
743
-				foreach($attribute_used_for_sort_by as $attribute){
743
+				foreach ($attribute_used_for_sort_by as $attribute) {
744 744
 					$data = query_posts(array('posts_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT));
745
-					foreach($data as $post){
745
+					foreach ($data as $post) {
746 746
 						$postmeta = get_post_meta($post->ID, '_wpshop_product_metadata', true);
747
-						if(!empty($postmeta[$attribute->code])) {
748
-							update_post_meta($post->ID, '_'.$attribute->code, $postmeta[$attribute->code]);
747
+						if (!empty($postmeta[$attribute->code])) {
748
+							update_post_meta($post->ID, '_' . $attribute->code, $postmeta[$attribute->code]);
749 749
 						}
750 750
 					}
751 751
 					wp_reset_query();
@@ -758,9 +758,9 @@  discard block
 block discarded – undo
758 758
 				);
759 759
 				$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE default_set = %s", 'yes');
760 760
 				$default_attribute_set = $wpdb->get_var($query);
761
-				foreach($products as $product){
761
+				foreach ($products as $product) {
762 762
 					$p_att_set_id = get_post_meta($product->ID, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true);
763
-					if(empty($p_att_set_id)){
763
+					if (empty($p_att_set_id)) {
764 764
 						/*	Update the attribute set id for the current product	*/
765 765
 						update_post_meta($product->ID, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, $default_attribute_set);
766 766
 					}
@@ -786,16 +786,16 @@  discard block
 block discarded – undo
786 786
 				 */
787 787
 				$query = $wpdb->prepare("SELECT ATTR_OPT.id, ATTR_OPT.value, ATTR_OPT.label, ATTR_OPT.position, ATTR_OPT.attribute_id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " AS ATTR_OPT INNER JOIN " . WPSHOP_DBT_ATTRIBUTE . " AS ATTR ON (ATTR.id = ATTR_OPT.attribute_id) WHERE ATTR_OPT.status=%s AND ATTR.code=%s", 'valid', 'manage_stock');
788 788
 				$manage_stock_option = $wpdb->get_results($query);
789
-				if( !empty( $manage_stock_option ) ){
789
+				if (!empty($manage_stock_option)) {
790 790
 					$no_is_present = false;
791 791
 					$attribute_id = $manage_stock_option[0]->attribute_id;
792 792
 					foreach ($manage_stock_option as $manage_definition) {
793
-						if( strtolower( __( $manage_definition->value, 'wpshop' ) ) == strtolower( __( 'no', 'wpshop' ) ) ) {
793
+						if (strtolower(__($manage_definition->value, 'wpshop')) == strtolower(__('no', 'wpshop'))) {
794 794
 							$no_is_present = true;
795 795
 						}
796 796
 					}
797
-					if ( !$no_is_present ) {
798
-						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql',0), 'last_update_date'=>current_time('mysql',0),'attribute_id'=>$attribute_id, 'value'=>'no', 'label'=>__('No', 'wpshop')));
797
+					if (!$no_is_present) {
798
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'last_update_date'=>current_time('mysql', 0), 'attribute_id'=>$attribute_id, 'value'=>'no', 'label'=>__('No', 'wpshop')));
799 799
 					}
800 800
 				}
801 801
 
@@ -814,29 +814,29 @@  discard block
 block discarded – undo
814 814
 WHERE ATTR_DET.attribute_id IN (" . $attribute_ids . ")"
815 815
 						, 'prices', __('default', 'wpshop'));
816 816
 				$list = $wpdb->get_results($query);
817
-				if(!empty($list)){
817
+				if (!empty($list)) {
818 818
 					$change_order = true;
819 819
 					$old_value = $list[0]->attribute_group_id;
820 820
 					unset($list[0]);
821
-					if(!empty($list)){
821
+					if (!empty($list)) {
822 822
 						foreach ($list as $data) {
823
-							if ( $old_value !=  $data->attribute_group_id) {
823
+							if ($old_value != $data->attribute_group_id) {
824 824
 								$change_order = false;
825 825
 							}
826 826
 						}
827 827
 						if ($change_order) {
828
-							foreach($price_tab as $price_code){
828
+							foreach ($price_tab as $price_code) {
829 829
 								$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $price_code);
830 830
 								$attribute_id = $wpdb->get_var($query);
831
-								switch($price_code){
831
+								switch ($price_code) {
832 832
 									case WPSHOP_PRODUCT_PRICE_HT:
833
-										$position = ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) ? 1 : 3;
833
+										$position = (WPSHOP_PRODUCT_PRICE_PILOT == 'HT') ? 1 : 3;
834 834
 										break;
835 835
 									case WPSHOP_PRODUCT_PRICE_TAX:
836 836
 										$position = 2;
837 837
 										break;
838 838
 									case WPSHOP_PRODUCT_PRICE_TTC:
839
-										$position = ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) ? 3 : 1;
839
+										$position = (WPSHOP_PRODUCT_PRICE_PILOT == 'HT') ? 3 : 1;
840 840
 										break;
841 841
 									case WPSHOP_PRODUCT_PRICE_TAX_AMOUNT:
842 842
 										$position = 4;
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 			case 22:
853 853
 				$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
854 854
 				$product_entity_id = $wpdb->get_var($query);
855
-				if(empty($product_entityd_id) || ($product_entity_id <= 0) || !$product_entity_id){
855
+				if (empty($product_entityd_id) || ($product_entity_id <= 0) || !$product_entity_id) {
856 856
 					/*	Create the product entity into post table	*/
857 857
 					$product_entity = array(
858 858
 						'post_title' => __('Products', 'wpshop'),
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 						'post_author' => 1,
863 863
 						'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES
864 864
 					);
865
-					$product_entity_id = wp_insert_post( $product_entity );
865
+					$product_entity_id = wp_insert_post($product_entity);
866 866
 				}
867 867
 
868 868
 				/*	Update eav table with the new entity id for product	*/
@@ -886,12 +886,12 @@  discard block
 block discarded – undo
886 886
 			break;
887 887
 			case 23:
888 888
 				/*	Delete duplicate entities	*/
889
-				$query = ("SELECT ID FROM " . $wpdb->posts . " WHERE post_name LIKE '%".WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT."%' ");
889
+				$query = ("SELECT ID FROM " . $wpdb->posts . " WHERE post_name LIKE '%" . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . "%' ");
890 890
 				$product_entity_list = $wpdb->get_results($query);
891
-				if ( count($product_entity_list) > 1 ) {
891
+				if (count($product_entity_list) > 1) {
892 892
 					$i = 0;
893
-					foreach($product_entity_list as $product_entity){
894
-						if ($i>0) {
893
+					foreach ($product_entity_list as $product_entity) {
894
+						if ($i > 0) {
895 895
 							wp_delete_post($product_entity->ID);
896 896
 						}
897 897
 					}
@@ -902,16 +902,16 @@  discard block
 block discarded – undo
902 902
 				/*	Update the link status for disabled attribute set	*/
903 903
 				$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE status = %s", 'deleted');
904 904
 				$deleted_attribute_group = $wpdb->get_results($query);
905
-				if(!empty($deleted_attribute_group)) {
906
-					foreach($deleted_attribute_group as $group){
905
+				if (!empty($deleted_attribute_group)) {
906
+					foreach ($deleted_attribute_group as $group) {
907 907
 						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'deleted', 'last_update_date' => current_time('mysql', 0)), array('attribute_group_id' => $group->id));
908 908
 					}
909 909
 				}
910 910
 
911 911
 				/*	Update entities meta management	*/
912 912
 				$entities = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES));
913
-				if(!empty($entities)){
914
-					foreach($entities as $entity){
913
+				if (!empty($entities)) {
914
+					foreach ($entities as $entity) {
915 915
 						$support = get_post_meta($entity->ID, '_wpshop_entity_support', true);
916 916
 						$rewrite = get_post_meta($entity->ID, '_wpshop_entity_rewrite', true);
917 917
 						update_post_meta($entity->ID, '_wpshop_entity_params', array('support' => $support, 'rewrite' => array('slug' => $rewrite)));
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
 				/*	Get entities that have been created a lot of time and delete them	*/
932 932
 				$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE (post_name LIKE '%%" . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . "-%%' OR post_name LIKE '%%" . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . "-%%') AND post_type=%s", WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES);
933 933
 				$entities_to_delete = $wpdb->get_results($query);
934
-				if ( !empty($entities_to_delete) && is_array($entities_to_delete) ) {
934
+				if (!empty($entities_to_delete) && is_array($entities_to_delete)) {
935 935
 					foreach ($entities_to_delete as $entity) {
936 936
 						wp_delete_post($entity->ID, true);
937 937
 					}
@@ -940,14 +940,14 @@  discard block
 block discarded – undo
940 940
 				/*	Get post list that are children of entities created a lot of time */
941 941
 				$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type LIKE %s", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . "-%");
942 942
 				$entities_to_update = $wpdb->get_results($query);
943
-				if ( !empty($entities_to_update) && is_array($entities_to_update) ) {
943
+				if (!empty($entities_to_update) && is_array($entities_to_update)) {
944 944
 					foreach ($entities_to_update as $entity) {
945 945
 						wp_update_post(array('ID' => $entity->ID, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS));
946 946
 					}
947 947
 				}
948 948
 				$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type LIKE %s", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . "-%");
949 949
 				$entities_to_update = $wpdb->get_results($query);
950
-				if ( !empty($entities_to_update) && is_array($entities_to_update) ) {
950
+				if (!empty($entities_to_update) && is_array($entities_to_update)) {
951 951
 					foreach ($entities_to_update as $entity) {
952 952
 						wp_update_post(array('ID' => $entity->ID, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT));
953 953
 					}
@@ -955,12 +955,12 @@  discard block
 block discarded – undo
955 955
 
956 956
 				/*	Change addons managament	*/
957 957
 				$wpshop_addons_options = get_option('wpshop_addons_state', array());
958
-				if ( !empty($wpshop_addons_options) ) {
959
-					foreach ($wpshop_addons_options as $addon_name => $addon_state ) {
958
+				if (!empty($wpshop_addons_options)) {
959
+					foreach ($wpshop_addons_options as $addon_name => $addon_state) {
960 960
 						$options_args = array();
961 961
 						$options_args[$addon_name]['activate'] = $addon_state;
962 962
 						$options_args[$addon_name]['activation_date'] = current_time('mysql', 0);
963
-						if (! $addon_state ) $options_args[$addon_name]['deactivation_date'] = current_time('mysql', 0);
963
+						if (!$addon_state) $options_args[$addon_name]['deactivation_date'] = current_time('mysql', 0);
964 964
 						add_option(WPSHOP_ADDONS_OPTION_NAME, $options_args);
965 965
 					}
966 966
 					delete_option('wpshop_addons_state');
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 				return true;
974 974
 			break;
975 975
 			case 26:
976
-				$query = "SELECT post_id, meta_value FROM " .$wpdb->postmeta. " WHERE meta_key = '_order_postmeta' ";
976
+				$query = "SELECT post_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = '_order_postmeta' ";
977 977
 				$results = $wpdb->get_results($query);
978 978
 				foreach ($results as $result) {
979 979
 					$order_info = unserialize($result->meta_value);
@@ -990,36 +990,36 @@  discard block
 block discarded – undo
990 990
 			break;
991 991
 
992 992
 			case 29:
993
-				$billing_title = __( 'Billing address', 'wpshop' );
994
-				$shipping_title = __( 'Shipping address', 'wpshop' );
993
+				$billing_title = __('Billing address', 'wpshop');
994
+				$shipping_title = __('Shipping address', 'wpshop');
995 995
 
996 996
 				//UPDATE USERS ADDRESSES
997
-				$billing_address_set_id_query = 'SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .$billing_title. '"';
998
-				$shipping_address_set_id_query = 'SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .$shipping_title. '"';
997
+				$billing_address_set_id_query = 'SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . $billing_title . '"';
998
+				$shipping_address_set_id_query = 'SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . $shipping_title . '"';
999 999
 
1000 1000
 				$billing_address_set_id = $wpdb->get_var($billing_address_set_id_query);
1001 1001
 				$shipping_address_set_id = $wpdb->get_var($shipping_address_set_id_query);
1002 1002
 
1003 1003
 
1004 1004
 				//Add Address & Google Map API KEY options
1005
-				add_option( 'wpshop_billing_address', array('choice' => $billing_address_set_id), '', 'yes' );
1006
-				add_option( 'wpshop_shipping_address_choice', array('activate'=>'on', 'choice'=> $shipping_address_set_id), '', 'yes' );
1007
-				add_option( 'wpshop_google_map_api_key', '', '', 'yes' );
1005
+				add_option('wpshop_billing_address', array('choice' => $billing_address_set_id), '', 'yes');
1006
+				add_option('wpshop_shipping_address_choice', array('activate'=>'on', 'choice'=> $shipping_address_set_id), '', 'yes');
1007
+				add_option('wpshop_google_map_api_key', '', '', 'yes');
1008 1008
 
1009 1009
 
1010 1010
 
1011
-				$query = 'SELECT * FROM ' .$wpdb->users. '';
1011
+				$query = 'SELECT * FROM ' . $wpdb->users . '';
1012 1012
 				$results = $wpdb->get_results($query);
1013 1013
 				foreach ($results as $result) {
1014
-					$billing_infos = get_user_meta( $result->ID, 'billing_info', true );
1015
-					$shipping_infos = get_user_meta( $result->ID, 'shipping_info', true );
1016
-					if ( !empty($billing_infos) ) {
1014
+					$billing_infos = get_user_meta($result->ID, 'billing_info', true);
1015
+					$shipping_infos = get_user_meta($result->ID, 'shipping_info', true);
1016
+					if (!empty($billing_infos)) {
1017 1017
 						//Save Billing Infos
1018 1018
 						$billing_address = array();
1019
-						if ( !empty($billing_infos['civility']) ) {
1020
-							switch ( $billing_infos['civility'] ) {
1019
+						if (!empty($billing_infos['civility'])) {
1020
+							switch ($billing_infos['civility']) {
1021 1021
 								case 1:
1022
-									$civility = $mister_id ;
1022
+									$civility = $mister_id;
1023 1023
 								break;
1024 1024
 								case 2:
1025 1025
 									$civility = $madam_id;
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 							}
1031 1031
 						}
1032 1032
 						else {
1033
-							$civility = $mister_id ;
1033
+							$civility = $mister_id;
1034 1034
 						}
1035 1035
 						$billing_address = array('address_title' => $billing_title,
1036 1036
 							'address_last_name' => !empty($billing_infos['last_name']) ? $billing_infos['last_name'] : '',
@@ -1058,16 +1058,16 @@  discard block
 block discarded – undo
1058 1058
 						$post_address_id = wp_insert_post($post_address);
1059 1059
 
1060 1060
 						//Create the post_meta with the address infos
1061
-						update_post_meta($post_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', $billing_address);
1062
-						update_post_meta($post_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_attribute_set_id', $billing_address_set_id);
1061
+						update_post_meta($post_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', $billing_address);
1062
+						update_post_meta($post_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_attribute_set_id', $billing_address_set_id);
1063 1063
 					}
1064 1064
 
1065
-					if ( !empty($shipping_infos) ) {
1065
+					if (!empty($shipping_infos)) {
1066 1066
 						//Save Shipping Infos
1067
-						if ( !empty($shipping_infos['civility']) ) {
1068
-							switch ( $shipping_infos['civility'] ) {
1067
+						if (!empty($shipping_infos['civility'])) {
1068
+							switch ($shipping_infos['civility']) {
1069 1069
 								case 1:
1070
-									$civility = $mister_id ;
1070
+									$civility = $mister_id;
1071 1071
 									break;
1072 1072
 								case 2:
1073 1073
 									$civility = $madam_id;
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 							}
1079 1079
 						}
1080 1080
 						else {
1081
-							$civility = $mister_id ;
1081
+							$civility = $mister_id;
1082 1082
 						}
1083 1083
 						$shipping_address = array();
1084 1084
 						$shipping_address = array('address_title' => $shipping_title,
@@ -1103,22 +1103,22 @@  discard block
 block discarded – undo
1103 1103
 						);
1104 1104
 						$post_address_id = wp_insert_post($post_address);
1105 1105
 						//Create the post_meta with the address infos
1106
-						update_post_meta($post_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', $shipping_address);
1107
-						update_post_meta($post_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_attribute_set_id', $shipping_address_set_id);
1106
+						update_post_meta($post_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', $shipping_address);
1107
+						update_post_meta($post_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_attribute_set_id', $shipping_address_set_id);
1108 1108
 					}
1109 1109
 				}
1110 1110
 
1111 1111
 				// FORMATE THE ORDER ADDRESSES INFOS
1112
-				$results = query_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'posts_per_page' => -1) );
1113
-				foreach ( $results as $result ) {
1112
+				$results = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'posts_per_page' => -1));
1113
+				foreach ($results as $result) {
1114 1114
 					$address = get_post_meta($result->ID, '_order_info', true);
1115 1115
 
1116 1116
 					$billing_address = array();
1117
-					if ( !empty($address['billing']) ) {
1118
-						if ( !empty($address['billing']['civility']) ) {
1119
-							switch ( $address['billing']['civility'] ) {
1117
+					if (!empty($address['billing'])) {
1118
+						if (!empty($address['billing']['civility'])) {
1119
+							switch ($address['billing']['civility']) {
1120 1120
 								case 1:
1121
-									$civility = $mister_id ;
1121
+									$civility = $mister_id;
1122 1122
 									break;
1123 1123
 								case 2:
1124 1124
 									$civility = $madam_id;
@@ -1127,12 +1127,12 @@  discard block
 block discarded – undo
1127 1127
 									$civility = $miss_id;
1128 1128
 									break;
1129 1129
 								default:
1130
-									$civility = $mister_id ;
1130
+									$civility = $mister_id;
1131 1131
 									break;
1132 1132
 							}
1133 1133
 						}
1134 1134
 						else {
1135
-							$civility = $mister_id ;
1135
+							$civility = $mister_id;
1136 1136
 						}
1137 1137
 						$billing_address = array('address_title' => $billing_title,
1138 1138
 							'address_last_name' => !empty($address['billing']['last_name']) ? $address['billing']['last_name'] : '',
@@ -1151,11 +1151,11 @@  discard block
 block discarded – undo
1151 1151
 					}
1152 1152
 
1153 1153
 					$shipping_address = array();
1154
-					if ( !empty($address['shipping']) ) {
1155
-						if ( !empty($address['shipping']['civility']) ) {
1156
-							switch ( $address['shipping']['civility'] ) {
1154
+					if (!empty($address['shipping'])) {
1155
+						if (!empty($address['shipping']['civility'])) {
1156
+							switch ($address['shipping']['civility']) {
1157 1157
 								case 1:
1158
-									$civility = $mister_id ;
1158
+									$civility = $mister_id;
1159 1159
 									break;
1160 1160
 								case 2:
1161 1161
 									$civility = $madam_id;
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 							}
1167 1167
 						}
1168 1168
 						else {
1169
-							$civility = $mister_id ;
1169
+							$civility = $mister_id;
1170 1170
 						}
1171 1171
 						$shipping_address = array('address_title' => $shipping_title,
1172 1172
 							'address_last_name' => !empty($address['shipping']['last_name']) ? $address['shipping']['last_name'] : '',
@@ -1191,11 +1191,11 @@  discard block
 block discarded – undo
1191 1191
 
1192 1192
 				/*	Update entities meta management	*/
1193 1193
 				$entities = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, 'posts_per_page' => -1));
1194
-				if(!empty($entities)){
1195
-					foreach($entities as $entity){
1194
+				if (!empty($entities)) {
1195
+					foreach ($entities as $entity) {
1196 1196
 						$params = get_post_meta($entity->ID, '_wpshop_entity_params', true);
1197
-						$support = ( !empty($params['support']) ) ? $params['support'] : '';
1198
-						$rewrite = ( !empty($params['rewrite']) ) ? $params['rewrite'] : '';
1197
+						$support = (!empty($params['support'])) ? $params['support'] : '';
1198
+						$rewrite = (!empty($params['rewrite'])) ? $params['rewrite'] : '';
1199 1199
 
1200 1200
 						$display_admin_menu = 'on';
1201 1201
 
@@ -1205,35 +1205,35 @@  discard block
 block discarded – undo
1205 1205
 				wp_reset_query();
1206 1206
 
1207 1207
 				// Default Weight unity and Currency Options
1208
-				add_option( 'wpshop_shop_weight_group', 3, '', 'yes' );
1209
-				add_option( 'wpshop_shop_default_weight_unity', 6, '', 'yes' );
1210
-				add_option( 'wpshop_shop_currency_group', 4, '', 'yes' );
1208
+				add_option('wpshop_shop_weight_group', 3, '', 'yes');
1209
+				add_option('wpshop_shop_default_weight_unity', 6, '', 'yes');
1210
+				add_option('wpshop_shop_currency_group', 4, '', 'yes');
1211 1211
 
1212 1212
 				$default_currency = get_option('wpshop_shop_default_currency');
1213
-				foreach ( unserialize(WPSHOP_SHOP_CURRENCIES) as $k => $v ) {
1214
-					if ( $default_currency == $k ) {
1213
+				foreach (unserialize(WPSHOP_SHOP_CURRENCIES) as $k => $v) {
1214
+					if ($default_currency == $k) {
1215 1215
 						$symbol = $v;
1216 1216
 					}
1217 1217
 				}
1218
-				if ( !empty($symbol) ) {
1219
-					$query = 'SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE name = "'.html_entity_decode($symbol, ENT_QUOTES, 'UTF-8').'"';
1218
+				if (!empty($symbol)) {
1219
+					$query = 'SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE name = "' . html_entity_decode($symbol, ENT_QUOTES, 'UTF-8') . '"';
1220 1220
 					$currency = $wpdb->get_row($query);
1221
-					if ( !empty($currency) ) {
1221
+					if (!empty($currency)) {
1222 1222
 						update_option('wpshop_shop_default_currency', $currency->id);
1223 1223
 						// Update the change rate of the default currency
1224
-						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('change_rate' => 1), array('id' => $currency->id) );
1224
+						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('change_rate' => 1), array('id' => $currency->id));
1225 1225
 					}
1226 1226
 				}
1227 1227
 
1228 1228
 				// Update the field for variation and user definition field
1229
-				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('is_used_for_variation' => 'yes'), array('is_user_defined' => 'yes') );
1229
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('is_used_for_variation' => 'yes'), array('is_user_defined' => 'yes'));
1230 1230
 				// Update field type for frontend output selection
1231 1231
 				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'text'), array());
1232
-				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'textarea'), array('backend_input' => 'textarea') );
1233
-				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'select'), array('backend_input' => 'multiple-select') );
1234
-				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'select'), array('backend_input' => 'select') );
1232
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'textarea'), array('backend_input' => 'textarea'));
1233
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'select'), array('backend_input' => 'multiple-select'));
1234
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'select'), array('backend_input' => 'select'));
1235 1235
 
1236
-				add_option('wpshop_cart_option', array( 'product_added_to_cart' => array('dialog_msg'), 'product_added_to_quotation' => array('cart_page')) );
1236
+				add_option('wpshop_cart_option', array('product_added_to_cart' => array('dialog_msg'), 'product_added_to_quotation' => array('cart_page')));
1237 1237
 
1238 1238
 				return true;
1239 1239
 			break;
@@ -1247,22 +1247,22 @@  discard block
 block discarded – undo
1247 1247
 				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('is_used_in_variation' => 'yes', 'last_update_date' => current_time('mysql', 0)), array('code' => 'product_reference'));
1248 1248
 
1249 1249
 				/**	Insert new message for admin when a customer make an order	*/
1250
-				$admin_new_order_message = get_option( 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE' );
1251
-				if ( empty($admin_new_order_message) ) {
1252
-					wps_message_ctr::createMessage( 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE' );
1250
+				$admin_new_order_message = get_option('WPSHOP_NEW_ORDER_ADMIN_MESSAGE');
1251
+				if (empty($admin_new_order_message)) {
1252
+					wps_message_ctr::createMessage('WPSHOP_NEW_ORDER_ADMIN_MESSAGE');
1253 1253
 				}
1254 1254
 				/**	Update all amount for paypal orders	*/
1255 1255
 				$query = $wpdb->prepare("SELECT post_id FROM " . $wpdb->postmeta . " WHERE meta_key = %s AND meta_value = %s ", '_wpshop_payment_method', 'paypal');
1256
-				$paypal_payment_list = $wpdb->get_results( $query );
1257
-				if ( !empty($paypal_payment_list) ) {
1258
-					foreach ( $paypal_payment_list as $post ) {
1259
-						$order_meta = get_post_meta( $post->post_id, '_order_postmeta', true );
1260
-						$order_payment_meta = get_post_meta( $post->post_id, 'wpshop_payment_return_data', true );
1261
-						if ( !empty($order_meta['order_status']) && ($order_meta['order_status'] == 'incorrect_amount') ) {
1262
-							if ( !empty($order_meta['order_grand_total']) && !empty($order_payment_meta['mc_gross']) ) {
1256
+				$paypal_payment_list = $wpdb->get_results($query);
1257
+				if (!empty($paypal_payment_list)) {
1258
+					foreach ($paypal_payment_list as $post) {
1259
+						$order_meta = get_post_meta($post->post_id, '_order_postmeta', true);
1260
+						$order_payment_meta = get_post_meta($post->post_id, 'wpshop_payment_return_data', true);
1261
+						if (!empty($order_meta['order_status']) && ($order_meta['order_status'] == 'incorrect_amount')) {
1262
+							if (!empty($order_meta['order_grand_total']) && !empty($order_payment_meta['mc_gross'])) {
1263 1263
 								$order_amount_to_pay = number_format($order_meta['order_grand_total'], 5);
1264 1264
 								$order_amount_payed = number_format(floatval($order_payment_meta['mc_gross']), 5);
1265
-								if ($order_amount_payed == $order_amount_to_pay ) {
1265
+								if ($order_amount_payed == $order_amount_to_pay) {
1266 1266
 									wpshop_payment::setOrderPaymentStatus($order_id, 'completed');
1267 1267
 								}
1268 1268
 							}
@@ -1273,17 +1273,17 @@  discard block
 block discarded – undo
1273 1273
 				/**	Save existing orders address information	*/
1274 1274
 				$billing_title = __('Billing address', 'wpshop');
1275 1275
 				$shipping_title = __('Shipping address', 'wpshop');
1276
-				$results = query_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'posts_per_page' => -1) );
1277
-				foreach ( $results as $result ) {
1276
+				$results = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'posts_per_page' => -1));
1277
+				foreach ($results as $result) {
1278 1278
 					$address = get_post_meta($result->ID, '_order_info', true);
1279 1279
 					$address_format = array();
1280 1280
 
1281 1281
 					$billing_address = array();
1282
-					if ( !empty($address['billing']) && empty($address['billing']['id']) ) {
1283
-						if ( !empty($address['billing']['civility']) ) {
1284
-							switch ( $address['billing']['civility'] ) {
1282
+					if (!empty($address['billing']) && empty($address['billing']['id'])) {
1283
+						if (!empty($address['billing']['civility'])) {
1284
+							switch ($address['billing']['civility']) {
1285 1285
 								case 1:
1286
-									$civility = $mister_id ;
1286
+									$civility = $mister_id;
1287 1287
 									break;
1288 1288
 								case 2:
1289 1289
 									$civility = $madam_id;
@@ -1292,12 +1292,12 @@  discard block
 block discarded – undo
1292 1292
 									$civility = $miss_id;
1293 1293
 									break;
1294 1294
 								default:
1295
-									$civility = $mister_id ;
1295
+									$civility = $mister_id;
1296 1296
 									break;
1297 1297
 							}
1298 1298
 						}
1299 1299
 						else {
1300
-							$civility = $mister_id ;
1300
+							$civility = $mister_id;
1301 1301
 						}
1302 1302
 						$billing_address = array('address_title' => $billing_title,
1303 1303
 							'address_last_name' => !empty($address['billing']['last_name']) ? $address['billing']['last_name'] : '',
@@ -1313,17 +1313,17 @@  discard block
 block discarded – undo
1313 1313
 							'tva_intra' => !empty($address['billing']['company_tva_intra']) ? $address['billing']['company_tva_intra'] : '',
1314 1314
 							'civility' => $civility
1315 1315
 						);
1316
-						$billing_address_option = get_option( 'wpshop_billing_address' );
1316
+						$billing_address_option = get_option('wpshop_billing_address');
1317 1317
 						$address_format['billing']['id'] = $billing_address_option['choice'];
1318 1318
 						$address_format['billing']['address'] = $shipping_address;
1319 1319
 					}
1320 1320
 
1321 1321
 					$shipping_address = array();
1322
-					if ( !empty($address['shipping']) && empty($address['shipping']['id']) ) {
1323
-						if ( !empty($address['shipping']['civility']) ) {
1324
-							switch ( $address['shipping']['civility'] ) {
1322
+					if (!empty($address['shipping']) && empty($address['shipping']['id'])) {
1323
+						if (!empty($address['shipping']['civility'])) {
1324
+							switch ($address['shipping']['civility']) {
1325 1325
 								case 1:
1326
-									$civility = $mister_id ;
1326
+									$civility = $mister_id;
1327 1327
 									break;
1328 1328
 								case 2:
1329 1329
 									$civility = $madam_id;
@@ -1347,19 +1347,19 @@  discard block
 block discarded – undo
1347 1347
 							'country' => !empty($address['shipping']['country']) ? $address['shipping']['country'] : '',
1348 1348
 							'civility' => $civility
1349 1349
 						);
1350
-						$shipping_address_options = get_option( 'wpshop_shipping_address_choice' );
1350
+						$shipping_address_options = get_option('wpshop_shipping_address_choice');
1351 1351
 						$address_format['shipping']['id'] = $shipping_address_options['choice'];
1352 1352
 						$address_format['shipping']['address'] = $shipping_address;
1353 1353
 					}
1354 1354
 
1355
-					if ( !empty($address_format) ) {
1355
+					if (!empty($address_format)) {
1356 1356
 						update_post_meta($result->ID, '_order_info', $address_format);
1357 1357
 					}
1358 1358
 				}
1359 1359
 
1360 1360
 				/**	Delete username from frontend form	*/
1361 1361
 				$attribute_login = wpshop_attributes::getElement('user_login', "'valid'", 'code');
1362
-				if ( !empty($attribute_login) ) {
1362
+				if (!empty($attribute_login)) {
1363 1363
 					$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'deleted', 'last_update_date' => current_time('mysql', 0), 'position' => 0), array('attribute_id' => $attribute_login->id));
1364 1364
 				}
1365 1365
 
@@ -1370,9 +1370,9 @@  discard block
 block discarded – undo
1370 1370
 
1371 1371
 			case '31':
1372 1372
 				/**	Change order structure in order to support several payment	*/
1373
-				$existing_orders = query_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'posts_per_page' => -1, 'post_status' => array('draft', 'trash', 'publish')) );
1374
-				if ( !empty($existing_orders) ) {
1375
-					foreach ( $existing_orders as $order_main_informations) {
1373
+				$existing_orders = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'posts_per_page' => -1, 'post_status' => array('draft', 'trash', 'publish')));
1374
+				if (!empty($existing_orders)) {
1375
+					foreach ($existing_orders as $order_main_informations) {
1376 1376
 						/**	Transfer payment return data form old meta to new	*/
1377 1377
 						$order_payment_return_data = get_post_meta($order_main_informations->ID, 'wpshop_payment_return_data', true);
1378 1378
 						update_post_meta($order_main_informations->ID, '_wpshop_payment_return_data', $order_payment_return_data);
@@ -1380,7 +1380,7 @@  discard block
 block discarded – undo
1380 1380
 
1381 1381
 						/**	Transfer old payment storage method to new storage method	*/
1382 1382
 						$order_meta = get_post_meta($order_main_informations->ID, '_order_postmeta', true);
1383
-						if ( !empty($order_meta['order_status']) ) {
1383
+						if (!empty($order_meta['order_status'])) {
1384 1384
 							$order_meta['order_payment']['customer_choice'] = array('method' => (!empty($order_meta['payment_method']) ? $order_meta['payment_method'] : (!empty($order_meta['order_payment']['customer_choice']) ? $order_meta['order_payment']['customer_choice'] : '')));
1385 1385
 							unset($order_meta['payment_method']);
1386 1386
 							$order_meta['order_payment']['received'][0]['waited_amount'] = !empty($order_meta['order_grand_total']) ? $order_meta['order_grand_total'] : 0;
@@ -1389,9 +1389,9 @@  discard block
 block discarded – undo
1389 1389
 							$order_meta['order_payment']['received'][0]['status'] = 'waiting_payment';
1390 1390
 							$order_meta['order_payment']['received'][0]['comment'] = '';
1391 1391
 							$order_meta['order_payment']['received'][0]['author'] = $order_meta['order_payment']['customer_choice'] == 'check' ? 1 : $order_meta['customer_id'];
1392
-							if ( in_array($order_meta['order_status'], array('completed', 'shipped')) ) {
1392
+							if (in_array($order_meta['order_status'], array('completed', 'shipped'))) {
1393 1393
 								$order_meta['order_payment']['received'][0]['received_amount'] = $order_meta['order_grand_total'];
1394
-								$order_meta['order_payment']['received'][0]['payment_reference'] = wpshop_payment::get_payment_transaction_number_old_way( $order_main_informations->ID );
1394
+								$order_meta['order_payment']['received'][0]['payment_reference'] = wpshop_payment::get_payment_transaction_number_old_way($order_main_informations->ID);
1395 1395
 								$order_meta['order_payment']['received'][0]['date'] = $order_meta['order_payment_date'];
1396 1396
 								$order_meta['order_payment']['received'][0]['status'] = 'payment_received';
1397 1397
 								$order_meta['order_payment']['received'][0]['comment'] = '';
@@ -1421,43 +1421,43 @@  discard block
 block discarded – undo
1421 1421
 				wp_reset_query();
1422 1422
 
1423 1423
 				$default_currency = get_option('wpshop_shop_default_currency');
1424
-				foreach ( unserialize(WPSHOP_SHOP_CURRENCIES) as $k => $v ) {
1425
-					if ( $default_currency == $k ) {
1424
+				foreach (unserialize(WPSHOP_SHOP_CURRENCIES) as $k => $v) {
1425
+					if ($default_currency == $k) {
1426 1426
 						$symbol = $v;
1427 1427
 					}
1428 1428
 				}
1429
-				if ( !empty($symbol) ) {
1430
-					$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE name = "'.html_entity_decode($symbol, ENT_QUOTES, 'UTF-8').'"', '');
1429
+				if (!empty($symbol)) {
1430
+					$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE name = "' . html_entity_decode($symbol, ENT_QUOTES, 'UTF-8') . '"', '');
1431 1431
 					$currency = $wpdb->get_row($query);
1432
-					if ( !empty($currency) ) {
1432
+					if (!empty($currency)) {
1433 1433
 						update_option('wpshop_shop_default_currency', $currency->id);
1434 1434
 						// Update the change rate of the default currency
1435
-						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('change_rate' => 1), array('id' => $currency->id) );
1435
+						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('change_rate' => 1), array('id' => $currency->id));
1436 1436
 					}
1437 1437
 				}
1438 1438
 
1439 1439
 				$shipping_confirmation_message = get_option('WPSHOP_SHIPPING_CONFIRMATION_MESSAGE');
1440
-				if ( !empty($shipping_confirmation_message) ) {
1440
+				if (!empty($shipping_confirmation_message)) {
1441 1441
 					$message = __('Hello [customer_first_name] [customer_last_name], this email confirms that your order ([order_key]) has just been shipped (order date : [order_date], tracking number : [order_trackingNumber]). Thank you for your loyalty. Have a good day.', 'wpshop');
1442 1442
 					$post = array('ID'=> $shipping_confirmation_message, 'post_content' => $message);
1443
-					wp_update_post( $post );
1443
+					wp_update_post($post);
1444 1444
 				}
1445 1445
 				return true;
1446 1446
 			break;
1447 1447
 			case '32':
1448 1448
 				/**	Update product set id that are null 	*/
1449
-				$query = $wpdb->prepare( "UPDATE " . $wpdb->postmeta . " SET meta_value = (SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE default_set = 'yes' AND entity_id = '" . wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) . "') WHERE meta_key = %s AND ((meta_value = '') OR (meta_value = null))", '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id' );
1449
+				$query = $wpdb->prepare("UPDATE " . $wpdb->postmeta . " SET meta_value = (SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE default_set = 'yes' AND entity_id = '" . wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) . "') WHERE meta_key = %s AND ((meta_value = '') OR (meta_value = null))", '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id');
1450 1450
 				$wpdb->query($query);
1451 1451
 
1452
-				$addons_options = get_option( WPSHOP_ADDONS_OPTION_NAME );
1453
-				if ( !empty($addons_options) && !empty($addons_options['WPSHOP_ADDONS_QUOTATION']) && !empty($addons_options['WPSHOP_ADDONS_QUOTATION']['activate']) && $addons_options['WPSHOP_ADDONS_QUOTATION']['activate'] ) {
1454
-					$admin_new_quotation_message = get_option( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' );
1455
-					if ( empty($admin_new_quotation_message) ) {
1456
-						wps_message_ctr::createMessage( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' );
1452
+				$addons_options = get_option(WPSHOP_ADDONS_OPTION_NAME);
1453
+				if (!empty($addons_options) && !empty($addons_options['WPSHOP_ADDONS_QUOTATION']) && !empty($addons_options['WPSHOP_ADDONS_QUOTATION']['activate']) && $addons_options['WPSHOP_ADDONS_QUOTATION']['activate']) {
1454
+					$admin_new_quotation_message = get_option('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE');
1455
+					if (empty($admin_new_quotation_message)) {
1456
+						wps_message_ctr::createMessage('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE');
1457 1457
 					}
1458
-					$admin_new_quotation_confirm_message = get_option( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' );
1459
-					if ( empty($admin_new_quotation_confirm_message) ) {
1460
-						wps_message_ctr::createMessage( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' );
1458
+					$admin_new_quotation_confirm_message = get_option('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE');
1459
+					if (empty($admin_new_quotation_confirm_message)) {
1460
+						wps_message_ctr::createMessage('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE');
1461 1461
 					}
1462 1462
 				}
1463 1463
 
@@ -1477,8 +1477,8 @@  discard block
 block discarded – undo
1477 1477
 				/** Update VAT Rate*/
1478 1478
 				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s OR code = %s', 'tx_tva', 'eco_taxe_rate_tva');
1479 1479
 				$attribute_ids = $wpdb->get_results($query);
1480
-				foreach ( $attribute_ids as $attribute_id) {
1481
-					$query = $wpdb->prepare('UPDATE ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' SET value = replace(value, "-", ".") WHERE attribute_id = %d', $attribute_id->id);
1480
+				foreach ($attribute_ids as $attribute_id) {
1481
+					$query = $wpdb->prepare('UPDATE ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' SET value = replace(value, "-", ".") WHERE attribute_id = %d', $attribute_id->id);
1482 1482
 					$wpdb->query($query);
1483 1483
 				}
1484 1484
 
@@ -1487,78 +1487,78 @@  discard block
 block discarded – undo
1487 1487
 
1488 1488
 			case '33' :
1489 1489
 				/** Update the user_mail for the new system of log in/register */
1490
-				$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes" WHERE code = "user_email"');
1490
+				$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes" WHERE code = "user_email"');
1491 1491
 
1492 1492
 				/** Put discount attributes in price attribute set section*/
1493
-				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_GROUP. ' WHERE code = %s', 'prices');
1493
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE code = %s', 'prices');
1494 1494
 				$prices_section_id = $wpdb->get_var($query);
1495 1495
 
1496
-				$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s OR code = %s', 'discount_rate', 'discount_amount');
1496
+				$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s OR code = %s', 'discount_rate', 'discount_amount');
1497 1497
 				$attributes = $wpdb->get_results($query);
1498
-				if ( !empty($attributes) && !empty($prices_section_id) ) {
1499
-					foreach ( $attributes as $attribute) {
1500
-						$query = $wpdb->query('UPDATE '.WPSHOP_DBT_ATTRIBUTE_DETAILS.' SET attribute_group_id = '. $prices_section_id .' WHERE attribute_id = '.$attribute->id);
1498
+				if (!empty($attributes) && !empty($prices_section_id)) {
1499
+					foreach ($attributes as $attribute) {
1500
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' SET attribute_group_id = ' . $prices_section_id . ' WHERE attribute_id = ' . $attribute->id);
1501 1501
 					}
1502 1502
 				}
1503 1503
 				return true;
1504 1504
 			break;
1505 1505
 
1506 1506
 			case '34' :
1507
-				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_GROUP. ' WHERE code = %s', 'prices');
1507
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE code = %s', 'prices');
1508 1508
 				$prices_section_id = $wpdb->get_var($query);
1509 1509
 
1510
-				$query = $wpdb->prepare('SELECT MAX(position) AS max_position FROM '.WPSHOP_DBT_ATTRIBUTE_DETAILS.' WHERE attribute_group_id = %d', $prices_section_id);
1510
+				$query = $wpdb->prepare('SELECT MAX(position) AS max_position FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_group_id = %d', $prices_section_id);
1511 1511
 				$last_position_id = $wpdb->get_var($query);
1512 1512
 
1513
-				$query = $wpdb->prepare('SELECT * FROM '.WPSHOP_DBT_ATTRIBUTE_DETAILS.' WHERE  attribute_group_id = %d AND position = %d', $prices_section_id, $last_position_id);
1513
+				$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE  attribute_group_id = %d AND position = %d', $prices_section_id, $last_position_id);
1514 1514
 				$attribute_example = $wpdb->get_row($query);
1515 1515
 
1516
-				$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s OR code = %s', 'special_from', 'special_to');
1516
+				$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s OR code = %s', 'special_from', 'special_to');
1517 1517
 				$attributes = $wpdb->get_results($query);
1518 1518
 				$i = 1;
1519
-				if ( !empty($attributes) && !empty($prices_section_id) ) {
1519
+				if (!empty($attributes) && !empty($prices_section_id)) {
1520 1520
 
1521
-					foreach ( $attributes as $attribute) {
1522
-						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('attribute_group_id' => $prices_section_id), array('attribute_id' => $attribute->id) );
1521
+					foreach ($attributes as $attribute) {
1522
+						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('attribute_group_id' => $prices_section_id), array('attribute_id' => $attribute->id));
1523 1523
 						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $attribute_example->entity_type_id, 'attribute_set_id' => $attribute_example->attribute_set_id, 'attribute_group_id' => $prices_section_id, 'attribute_id' => $attribute->id, 'position' => $last_position_id + $i));
1524 1524
 						$i++;
1525 1525
 					}
1526 1526
 				}
1527 1527
 				$discount_options = get_option('wpshop_catalog_product_option');
1528
-				$status =  ( !empty($discount_options) && !empty($discount_options['discount']) ) ? 'valid' : 'notused';
1529
-				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_label' => __('Discount from', 'wpshop'), 'status' => $status ), array('code' => 'special_from') );
1530
-				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_label' => __('Discount to', 'wpshop'), 'status' => $status ), array('code' => 'special_to') );
1528
+				$status = (!empty($discount_options) && !empty($discount_options['discount'])) ? 'valid' : 'notused';
1529
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_label' => __('Discount from', 'wpshop'), 'status' => $status), array('code' => 'special_from'));
1530
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_label' => __('Discount to', 'wpshop'), 'status' => $status), array('code' => 'special_to'));
1531 1531
 				return true;
1532 1532
 			break;
1533 1533
 
1534 1534
 
1535 1535
 			case '35' :
1536
-				$wpdb->update( $wpdb->posts, array('post_status'=>'draft'), array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS) );
1536
+				$wpdb->update($wpdb->posts, array('post_status'=>'draft'), array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS));
1537 1537
 				return true;
1538 1538
 			break;
1539 1539
 
1540 1540
 			case '36' :
1541 1541
 				wpshop_entities::create_cpt_attributes_from_csv_file(WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
1542
-				@set_time_limit( 900 );
1542
+				@set_time_limit(900);
1543 1543
 				/** Change the path for old categories pictures */
1544
-				@chmod(WPSHOP_UPLOAD_DIR .'wpshop_product_category', 0755);
1544
+				@chmod(WPSHOP_UPLOAD_DIR . 'wpshop_product_category', 0755);
1545 1545
 
1546
-				$query = 'SELECT * FROM ' .$wpdb->terms;
1546
+				$query = 'SELECT * FROM ' . $wpdb->terms;
1547 1547
 				$terms = $wpdb->get_results($query);
1548
-				if ( !empty($terms) ) {
1549
-					foreach ( $terms as $term ) {
1550
-						@chmod(WPSHOP_UPLOAD_DIR .'wpshop_product_category/'.$term->term_id, 0755);
1548
+				if (!empty($terms)) {
1549
+					foreach ($terms as $term) {
1550
+						@chmod(WPSHOP_UPLOAD_DIR . 'wpshop_product_category/' . $term->term_id, 0755);
1551 1551
 						/** Check if a picture exists **/
1552
-						$term_option =  get_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' .$term->term_id );
1553
-						if ( !empty($term_option) && !empty($term_option['wpshop_category_picture']) && is_file(WPSHOP_UPLOAD_DIR . $term_option['wpshop_category_picture']) ) {
1552
+						$term_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $term->term_id);
1553
+						if (!empty($term_option) && !empty($term_option['wpshop_category_picture']) && is_file(WPSHOP_UPLOAD_DIR . $term_option['wpshop_category_picture'])) {
1554 1554
 							$wp_upload_dir = wp_upload_dir();
1555 1555
 							$img_path = WPSHOP_UPLOAD_DIR . $term_option['wpshop_category_picture'];
1556 1556
 							$img_basename = basename($img_path);
1557
-							$wp_filetype = wp_check_filetype($img_basename, null );
1557
+							$wp_filetype = wp_check_filetype($img_basename, null);
1558 1558
 							/** Check if there is an image with the same name, if yes we add a rand number to image's name **/
1559
-							$rand_name = ( is_file($wp_upload_dir['path'] . '/' .$img_basename) ) ? rand() : '';
1560
-							$img_basename = ( !empty($rand_name) ) ? $rand_name.'_'.$img_basename : $img_basename;
1561
-							if ( copy($img_path, $wp_upload_dir['path'] . '/' . $img_basename) ) {
1559
+							$rand_name = (is_file($wp_upload_dir['path'] . '/' . $img_basename)) ? rand() : '';
1560
+							$img_basename = (!empty($rand_name)) ? $rand_name . '_' . $img_basename : $img_basename;
1561
+							if (copy($img_path, $wp_upload_dir['path'] . '/' . $img_basename)) {
1562 1562
 								$attachment = array(
1563 1563
 										'guid' => $wp_upload_dir['url'] . '/' . $img_basename,
1564 1564
 										'post_mime_type' => $wp_filetype['type'],
@@ -1566,14 +1566,14 @@  discard block
 block discarded – undo
1566 1566
 										'post_content' => '',
1567 1567
 										'post_status' => 'inherit'
1568 1568
 								);
1569
-								$attach_id = wp_insert_attachment( $attachment, $wp_upload_dir['path'] . '/' . $img_basename);
1569
+								$attach_id = wp_insert_attachment($attachment, $wp_upload_dir['path'] . '/' . $img_basename);
1570 1570
 								/** Generate differnts sizes for this image **/
1571 1571
 								require_once(ABSPATH . 'wp-admin/includes/image.php');
1572
-								$attach_data = wp_generate_attachment_metadata( $attach_id, $wp_upload_dir['path'] . '/' . $img_basename );
1573
-								wp_update_attachment_metadata( $attach_id, $attach_data );
1572
+								$attach_data = wp_generate_attachment_metadata($attach_id, $wp_upload_dir['path'] . '/' . $img_basename);
1573
+								wp_update_attachment_metadata($attach_id, $attach_data);
1574 1574
 								/** Update option picture **/
1575 1575
 								$term_option['wpshop_category_picture'] = $attach_id;
1576
-								update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' .$term->term_id , $term_option);
1576
+								update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $term->term_id, $term_option);
1577 1577
 							}
1578 1578
 						}
1579 1579
 					}
@@ -1581,16 +1581,16 @@  discard block
 block discarded – undo
1581 1581
 
1582 1582
 
1583 1583
 				/** Change metabox Hidden Nav Menu Definition to display WPShop categories' metabox **/
1584
-				$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->usermeta. ' WHERE meta_key = %s', 'metaboxhidden_nav-menus');
1585
-				$meta_keys = $wpdb->get_results( $query );
1586
-				if ( !empty($meta_keys) && is_array( $meta_keys) ) {
1587
-					foreach ( $meta_keys as $meta_key ) {
1584
+				$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->usermeta . ' WHERE meta_key = %s', 'metaboxhidden_nav-menus');
1585
+				$meta_keys = $wpdb->get_results($query);
1586
+				if (!empty($meta_keys) && is_array($meta_keys)) {
1587
+					foreach ($meta_keys as $meta_key) {
1588 1588
 						$user_id = $meta_key->user_id;
1589 1589
 						$meta_value = unserialize($meta_key->meta_value);
1590
-						if ( !empty( $meta_value) && is_array($meta_value) ) {
1590
+						if (!empty($meta_value) && is_array($meta_value)) {
1591 1591
 							$data_to_delete = array_search('add-wpshop_product_category', $meta_value);
1592
-							if ( $data_to_delete !== false ) {
1593
-								unset( $meta_value[$data_to_delete] );
1592
+							if ($data_to_delete !== false) {
1593
+								unset($meta_value[$data_to_delete]);
1594 1594
 							}
1595 1595
 						}
1596 1596
 						update_user_meta($user_id, 'metaboxhidden_nav-menus', $meta_value);
@@ -1600,39 +1600,39 @@  discard block
 block discarded – undo
1600 1600
 			break;
1601 1601
 
1602 1602
 			case '37' :
1603
-				@set_time_limit( 900 );
1603
+				@set_time_limit(900);
1604 1604
 				/** Change the path for old categories pictures */
1605
-				@chmod(WPSHOP_UPLOAD_DIR .'wpshop/wpshop_product_category', 0755);
1605
+				@chmod(WPSHOP_UPLOAD_DIR . 'wpshop/wpshop_product_category', 0755);
1606 1606
 				/** Read all categories folders **/
1607
-				$categories_main_dir = WPSHOP_UPLOAD_DIR .'wpshop/wpshop_product_category';
1608
-				if ( file_exists($categories_main_dir) ) {
1607
+				$categories_main_dir = WPSHOP_UPLOAD_DIR . 'wpshop/wpshop_product_category';
1608
+				if (file_exists($categories_main_dir)) {
1609 1609
 					$main_folder_content = scandir($categories_main_dir);
1610 1610
 					/** For each category folder **/
1611
-					foreach ( $main_folder_content as $category_folder ) {
1612
-						if ( $category_folder && substr( $category_folder, 0, 1) != '.' ) {
1611
+					foreach ($main_folder_content as $category_folder) {
1612
+						if ($category_folder && substr($category_folder, 0, 1) != '.') {
1613 1613
 							$category_id = $category_folder;
1614
-							@chmod(WPSHOP_UPLOAD_DIR .'wpshop/wpshop_product_category/'.$category_id, 0755);
1615
-							$scan_category_folder = opendir($categories_main_dir.'/'.$category_folder);
1614
+							@chmod(WPSHOP_UPLOAD_DIR . 'wpshop/wpshop_product_category/' . $category_id, 0755);
1615
+							$scan_category_folder = opendir($categories_main_dir . '/' . $category_folder);
1616 1616
 							/** For each Picture of category **/
1617 1617
 							$file_time = 0;
1618 1618
 							$save_this_picture = false;
1619
-							while(false !== ($fichier = readdir($scan_category_folder))) {
1620
-								if ( $fichier && substr( $fichier, 0, 1) != '.' ) {
1621
-									if ( $file_time < filemtime($categories_main_dir . '/'. $category_id . '/'. $fichier) ) {
1619
+							while (false !== ($fichier = readdir($scan_category_folder))) {
1620
+								if ($fichier && substr($fichier, 0, 1) != '.') {
1621
+									if ($file_time < filemtime($categories_main_dir . '/' . $category_id . '/' . $fichier)) {
1622 1622
 										$save_this_picture = true;
1623
-										$file_time = filemtime($categories_main_dir . '/'. $category_id . '/'. $fichier);
1623
+										$file_time = filemtime($categories_main_dir . '/' . $category_id . '/' . $fichier);
1624 1624
 									}
1625 1625
 									/** Select category option **/
1626
-									$term_option =  get_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' .$category_id );
1626
+									$term_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id);
1627 1627
 									$wp_upload_dir = wp_upload_dir();
1628
-									$img_path = $categories_main_dir . '/' . $category_id .'/'. $fichier;
1628
+									$img_path = $categories_main_dir . '/' . $category_id . '/' . $fichier;
1629 1629
 									$img_basename = basename($img_path);
1630
-									$wp_filetype = wp_check_filetype($img_basename, null );
1630
+									$wp_filetype = wp_check_filetype($img_basename, null);
1631 1631
 									/** Check if there is an image with the same name, if yes we add a rand number to image's name **/
1632
-									$rand_name = ( is_file($wp_upload_dir['path'] . '/' .$img_basename) ) ? rand() : '';
1633
-									$img_basename = ( !empty($rand_name) ) ? $rand_name.'_'.$img_basename : $img_basename;
1632
+									$rand_name = (is_file($wp_upload_dir['path'] . '/' . $img_basename)) ? rand() : '';
1633
+									$img_basename = (!empty($rand_name)) ? $rand_name . '_' . $img_basename : $img_basename;
1634 1634
 
1635
-									if ( copy($img_path, $wp_upload_dir['path'] . '/' . $img_basename) ) {
1635
+									if (copy($img_path, $wp_upload_dir['path'] . '/' . $img_basename)) {
1636 1636
 										$attachment = array(
1637 1637
 												'guid' => $wp_upload_dir['url'] . '/' . $img_basename,
1638 1638
 												'post_mime_type' => $wp_filetype['type'],
@@ -1640,15 +1640,15 @@  discard block
 block discarded – undo
1640 1640
 												'post_content' => '',
1641 1641
 												'post_status' => 'inherit'
1642 1642
 										);
1643
-										$attach_id = wp_insert_attachment( $attachment, $wp_upload_dir['path'] . '/' . $img_basename);
1643
+										$attach_id = wp_insert_attachment($attachment, $wp_upload_dir['path'] . '/' . $img_basename);
1644 1644
 										/** Generate differnts sizes for this image **/
1645 1645
 										require_once(ABSPATH . 'wp-admin/includes/image.php');
1646
-										$attach_data = wp_generate_attachment_metadata( $attach_id, $wp_upload_dir['path'] . '/' . $img_basename );
1647
-										wp_update_attachment_metadata( $attach_id, $attach_data );
1646
+										$attach_data = wp_generate_attachment_metadata($attach_id, $wp_upload_dir['path'] . '/' . $img_basename);
1647
+										wp_update_attachment_metadata($attach_id, $attach_data);
1648 1648
 										/** Update option picture **/
1649
-										$term_option['wpshop_category_picture'] =  $attach_id;
1650
-										if ( $save_this_picture ) {
1651
-											update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' .$category_id , $term_option);
1649
+										$term_option['wpshop_category_picture'] = $attach_id;
1650
+										if ($save_this_picture) {
1651
+											update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id, $term_option);
1652 1652
 										}
1653 1653
 										$save_this_picture = false;
1654 1654
 									}
@@ -1661,33 +1661,33 @@  discard block
 block discarded – undo
1661 1661
 				break;
1662 1662
 
1663 1663
 			case '38' :
1664
-				wps_message_ctr::createMessage( 'WPSHOP_QUOTATION_UPDATE_MESSAGE' );
1664
+				wps_message_ctr::createMessage('WPSHOP_QUOTATION_UPDATE_MESSAGE');
1665 1665
 				return true;
1666 1666
 			break;
1667 1667
 
1668 1668
 			case '39' :
1669 1669
 				$attribute_def = wpshop_attributes::getElement('tx_tva', "'valid'", 'code');
1670 1670
 				/** Check if the 7% VAT Rate is not already created **/
1671
-				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE attribute_id = %d AND value = %s',  $attribute_def->id, '7');
1672
-				$exist_vat_rate = $wpdb->get_results( $query );
1671
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE attribute_id = %d AND value = %s', $attribute_def->id, '7');
1672
+				$exist_vat_rate = $wpdb->get_results($query);
1673 1673
 
1674
-				if ( empty($exist_vat_rate) ) {
1674
+				if (empty($exist_vat_rate)) {
1675 1675
 					/** Get Max Position **/
1676
-					$query = $wpdb->prepare('SELECT MAX(position) as max_position FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE attribute_id = %d', $attribute_def->id);
1677
-					$max_position = $wpdb->get_var( $query );
1676
+					$query = $wpdb->prepare('SELECT MAX(position) as max_position FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE attribute_id = %d', $attribute_def->id);
1677
+					$max_position = $wpdb->get_var($query);
1678 1678
 
1679
-					if ( !empty( $attribute_def) && !empty($attribute_def->id)  ) {
1680
-						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' =>  $attribute_def->id, 'position' => (int)$max_position + 1, 'value' => '7', 'label' => '7') );
1679
+					if (!empty($attribute_def) && !empty($attribute_def->id)) {
1680
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' =>  $attribute_def->id, 'position' => (int)$max_position + 1, 'value' => '7', 'label' => '7'));
1681 1681
 					}
1682 1682
 				}
1683 1683
 
1684 1684
 				/** Filter Search optimization **/
1685
-				@set_time_limit( 900 );
1686
-				$query = $wpdb->prepare('SELECT term_id FROM '.$wpdb->term_taxonomy.' WHERE taxonomy = %s ', WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES);
1687
-				$categories = $wpdb->get_results( $query );
1685
+				@set_time_limit(900);
1686
+				$query = $wpdb->prepare('SELECT term_id FROM ' . $wpdb->term_taxonomy . ' WHERE taxonomy = %s ', WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES);
1687
+				$categories = $wpdb->get_results($query);
1688 1688
 				$cats = array();
1689
-				if ( !empty($categories) ) {
1690
-					foreach($categories as $category) {
1689
+				if (!empty($categories)) {
1690
+					foreach ($categories as $category) {
1691 1691
 						$cats[] = $category->term_id;
1692 1692
 					}
1693 1693
 					$wpshop_filter_search = new wps_filter_search();
@@ -1699,116 +1699,116 @@  discard block
 block discarded – undo
1699 1699
 			case '40' :
1700 1700
 				/**	Store watt in puissance unit group	*/
1701 1701
 				$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " WHERE name = %s", __('puissance', 'wpshop'));
1702
-				$puissance_unit_group_id = $wpdb->get_var( $query );
1703
-				$wpdb->update( WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $puissance_unit_group_id), array('unit' => 'watt') );
1702
+				$puissance_unit_group_id = $wpdb->get_var($query);
1703
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $puissance_unit_group_id), array('unit' => 'watt'));
1704 1704
 
1705 1705
 				/**	Store day/week/year in duration unit group	*/
1706 1706
 				$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " WHERE name = %s", __('duration', 'wpshop'));
1707
-				$duration_unit_group_id = $wpdb->get_var( $query );
1708
-				$wpdb->update( WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $duration_unit_group_id), array('unit' => 'day') );
1709
-				$wpdb->update( WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $duration_unit_group_id), array('unit' => 'week') );
1710
-				$wpdb->update( WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $duration_unit_group_id), array('unit' => 'year') );
1707
+				$duration_unit_group_id = $wpdb->get_var($query);
1708
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $duration_unit_group_id), array('unit' => 'day'));
1709
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $duration_unit_group_id), array('unit' => 'week'));
1710
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $duration_unit_group_id), array('unit' => 'year'));
1711 1711
 
1712 1712
 				/**	Store day/week/year in duration unit group	*/
1713 1713
 				$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " WHERE name = %s", __('length', 'wpshop'));
1714
-				$length_unit_group_id = $wpdb->get_var( $query );
1715
-				$wpdb->update( WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $length_unit_group_id), array('unit' => 'cm') );
1714
+				$length_unit_group_id = $wpdb->get_var($query);
1715
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $length_unit_group_id), array('unit' => 'cm'));
1716 1716
 				return true;
1717 1717
 			break;
1718 1718
 
1719 1719
 			case '41':
1720 1720
 				/**	Get distinct attribute set and delete doublons	*/
1721 1721
 				$query = "SELECT DISTINCT( name ) AS name, MIN( id ) as min_id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " GROUP BY name HAVING COUNT(id) > 1";
1722
-				$list_of_set = $wpdb->get_results( $query );
1723
-				foreach ( $list_of_set as $set_infos ) {
1724
-					$query = $wpdb->prepare( "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE name = %s AND id != %d", $set_infos->name, $set_infos->min_id );
1725
-					$wpdb->query( $query );
1722
+				$list_of_set = $wpdb->get_results($query);
1723
+				foreach ($list_of_set as $set_infos) {
1724
+					$query = $wpdb->prepare("DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE name = %s AND id != %d", $set_infos->name, $set_infos->min_id);
1725
+					$wpdb->query($query);
1726 1726
 				}
1727
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_SET );
1727
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_SET);
1728 1728
 
1729 1729
 				/**	Get and delete attribute set section	*/
1730 1730
 				$query = "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id NOT IN ( SELECT DISTINCT(id) FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " )";
1731
-				$wpdb->query( $query );
1732
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_GROUP );
1731
+				$wpdb->query($query);
1732
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_GROUP);
1733 1733
 
1734 1734
 				/**	Get and delete attribute set details	*/
1735 1735
 				$query = "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_set_id NOT IN ( SELECT DISTINCT(id) FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " ) OR attribute_group_id NOT IN ( SELECT DISTINCT(id) FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " )";
1736
-				$wpdb->query( $query );
1737
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_DETAILS );
1736
+				$wpdb->query($query);
1737
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_DETAILS);
1738 1738
 
1739 1739
 				$query = "SELECT attribute_set_id, attribute_group_id, attribute_id, MIN(id) as min_id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " GROUP BY attribute_set_id, attribute_group_id, attribute_id HAVING COUNT(id) > 1";
1740
-				$affectation_list = $wpdb->get_results( $query );
1741
-				foreach ( $affectation_list as $affectation_to_treat ) {
1742
-					$query = $wpdb->prepare( "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_set_id = %d AND attribute_group_id = %d AND attribute_id = %d AND id != %d", $affectation_to_treat->attribute_set_id, $affectation_to_treat->attribute_group_id, $affectation_to_treat->attribute_id, $affectation_to_treat->min_id );
1743
-					$wpdb->query( $query );
1740
+				$affectation_list = $wpdb->get_results($query);
1741
+				foreach ($affectation_list as $affectation_to_treat) {
1742
+					$query = $wpdb->prepare("DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_set_id = %d AND attribute_group_id = %d AND attribute_id = %d AND id != %d", $affectation_to_treat->attribute_set_id, $affectation_to_treat->attribute_group_id, $affectation_to_treat->attribute_id, $affectation_to_treat->min_id);
1743
+					$wpdb->query($query);
1744 1744
 				}
1745
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_DETAILS );
1745
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_DETAILS);
1746 1746
 
1747 1747
 				/**	Get and delete double unit	*/
1748 1748
 				$query = "SELECT DISTINCT( unit ) AS unit, MIN( id ) as min_id FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT . " GROUP BY unit HAVING COUNT(id) > 1";
1749
-				$list_of_set = $wpdb->get_results( $query );
1750
-				foreach ( $list_of_set as $set_infos ) {
1751
-					$query = $wpdb->prepare( "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT . " WHERE unit = %s AND id != %d", $set_infos->unit, $set_infos->min_id );
1752
-					$wpdb->query( $query );
1749
+				$list_of_set = $wpdb->get_results($query);
1750
+				foreach ($list_of_set as $set_infos) {
1751
+					$query = $wpdb->prepare("DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT . " WHERE unit = %s AND id != %d", $set_infos->unit, $set_infos->min_id);
1752
+					$wpdb->query($query);
1753 1753
 				}
1754
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_UNIT );
1754
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_UNIT);
1755 1755
 
1756 1756
 				$query = "SELECT DISTINCT( name ) AS name, MIN( id ) as min_id FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " GROUP BY name HAVING COUNT(id) > 1";
1757
-				$list_of_set = $wpdb->get_results( $query );
1758
-				foreach ( $list_of_set as $set_infos ) {
1759
-					$query = $wpdb->prepare( "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " WHERE name = %s AND id != %d", $set_infos->name, $set_infos->min_id );
1760
-					$wpdb->query( $query );
1757
+				$list_of_set = $wpdb->get_results($query);
1758
+				foreach ($list_of_set as $set_infos) {
1759
+					$query = $wpdb->prepare("DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " WHERE name = %s AND id != %d", $set_infos->name, $set_infos->min_id);
1760
+					$wpdb->query($query);
1761 1761
 				}
1762
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP );
1762
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
1763 1763
 
1764 1764
 				/**	Get and delete attribute set details	*/
1765 1765
 				$query = "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_set_id NOT IN ( SELECT DISTINCT(id) FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " ) OR attribute_group_id NOT IN ( SELECT DISTINCT(id) FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " )";
1766
-				$wpdb->query( $query );
1766
+				$wpdb->query($query);
1767 1767
 				$query = "SELECT GROUP_CONCAT( id ) AS list_id, MIN( id ) as min_id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " GROUP BY attribute_set_id, attribute_group_id, attribute_id HAVING COUNT(id) > 1";
1768
-				$affectation_list = $wpdb->get_results( $query );
1769
-				foreach ( $affectation_list as $list ) {
1770
-					$query = $wpdb->prepare( "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE id IN (" . ( substr($list->list_id, -1) == ',' ? substr($list->list_id, 0, -1) : $list->list_id ) . ") AND id != %d", $list->min_id , '');
1771
-					$wpdb->query( $query );
1768
+				$affectation_list = $wpdb->get_results($query);
1769
+				foreach ($affectation_list as $list) {
1770
+					$query = $wpdb->prepare("DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE id IN (" . (substr($list->list_id, -1) == ',' ? substr($list->list_id, 0, -1) : $list->list_id) . ") AND id != %d", $list->min_id, '');
1771
+					$wpdb->query($query);
1772 1772
 				}
1773
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_DETAILS );
1773
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_DETAILS);
1774 1774
 
1775 1775
 				return true;
1776 1776
 			break;
1777 1777
 
1778 1778
 			case '42' :
1779
-				$available_downloadable_product = get_option( 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE' );
1780
-				if ( empty($available_downloadable_product) ) {
1781
-					wps_message_ctr::createMessage( 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE' );
1779
+				$available_downloadable_product = get_option('WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE');
1780
+				if (empty($available_downloadable_product)) {
1781
+					wps_message_ctr::createMessage('WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE');
1782 1782
 				}
1783 1783
 				return true;
1784 1784
 			break;
1785 1785
 
1786 1786
 			case '43' :
1787
-				$available_downloadable_product = get_option( 'WPSHOP_ORDER_IS_CANCELED' );
1788
-				if ( empty($available_downloadable_product) ) {
1789
-					wps_message_ctr::createMessage( 'WPSHOP_ORDER_IS_CANCELED' );
1787
+				$available_downloadable_product = get_option('WPSHOP_ORDER_IS_CANCELED');
1788
+				if (empty($available_downloadable_product)) {
1789
+					wps_message_ctr::createMessage('WPSHOP_ORDER_IS_CANCELED');
1790 1790
 				}
1791 1791
 				return true;
1792 1792
 			break;
1793 1793
 
1794 1794
 			case '44' :
1795 1795
 				$display_option = get_option('wpshop_display_option');
1796
-				if ( !empty($display_option) && empty($display_option['latest_products_ordered']) ) {
1796
+				if (!empty($display_option) && empty($display_option['latest_products_ordered'])) {
1797 1797
 					$display_option['latest_products_ordered'] = 3;
1798 1798
 					update_option('wpshop_display_option', $display_option);
1799 1799
 				}
1800 1800
 
1801 1801
 				/** Check messages for customization **/
1802
-				$messages = array( 'WPSHOP_SIGNUP_MESSAGE' => WPSHOP_SIGNUP_MESSAGE, 'WPSHOP_PAYPAL_PAYMENT_CONFIRMATION_MESSAGE' => WPSHOP_PAYPAL_PAYMENT_CONFIRMATION_MESSAGE, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE' => WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE, 'WPSHOP_SHIPPING_CONFIRMATION_MESSAGE' => WPSHOP_SHIPPING_CONFIRMATION_MESSAGE, 'WPSHOP_ORDER_UPDATE_MESSAGE' => WPSHOP_ORDER_UPDATE_MESSAGE, 'WPSHOP_ORDER_UPDATE_PRIVATE_MESSAGE' => WPSHOP_ORDER_UPDATE_PRIVATE_MESSAGE, 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE' => WPSHOP_NEW_ORDER_ADMIN_MESSAGE, 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' => WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' => WPSHOP_QUOTATION_CONFIRMATION_MESSAGE, 'WPSHOP_QUOTATION_UPDATE_MESSAGE' => WPSHOP_QUOTATION_UPDATE_MESSAGE, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE' => WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE, 'WPSHOP_ORDER_IS_CANCELED' => WPSHOP_ORDER_IS_CANCELED);
1803
-				if ( !empty( $messages) ) {
1804
-					foreach ($messages as $key => $message ) {
1805
-						$message_option = get_option( $key );
1806
-						if ( !empty( $message_option) ) {
1807
-							$post_message =  get_post( $message_option );
1808
-							$original_message = ( !empty($post_message) && !empty($post_message->post_content) ) ? $post_message->post_content : '';
1802
+				$messages = array('WPSHOP_SIGNUP_MESSAGE' => WPSHOP_SIGNUP_MESSAGE, 'WPSHOP_PAYPAL_PAYMENT_CONFIRMATION_MESSAGE' => WPSHOP_PAYPAL_PAYMENT_CONFIRMATION_MESSAGE, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE' => WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE, 'WPSHOP_SHIPPING_CONFIRMATION_MESSAGE' => WPSHOP_SHIPPING_CONFIRMATION_MESSAGE, 'WPSHOP_ORDER_UPDATE_MESSAGE' => WPSHOP_ORDER_UPDATE_MESSAGE, 'WPSHOP_ORDER_UPDATE_PRIVATE_MESSAGE' => WPSHOP_ORDER_UPDATE_PRIVATE_MESSAGE, 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE' => WPSHOP_NEW_ORDER_ADMIN_MESSAGE, 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' => WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' => WPSHOP_QUOTATION_CONFIRMATION_MESSAGE, 'WPSHOP_QUOTATION_UPDATE_MESSAGE' => WPSHOP_QUOTATION_UPDATE_MESSAGE, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE' => WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE, 'WPSHOP_ORDER_IS_CANCELED' => WPSHOP_ORDER_IS_CANCELED);
1803
+				if (!empty($messages)) {
1804
+					foreach ($messages as $key => $message) {
1805
+						$message_option = get_option($key);
1806
+						if (!empty($message_option)) {
1807
+							$post_message = get_post($message_option);
1808
+							$original_message = (!empty($post_message) && !empty($post_message->post_content)) ? $post_message->post_content : '';
1809 1809
 							$tags = array('<p>', '</p>');
1810
-							if ( str_replace( $tags, '', $original_message) == str_replace( $tags, '', __( $message, 'wpshop' ) ) ) {
1811
-								wp_update_post( array( 'ID' => $message_option, 'post_content' => wps_message_ctr::customize_message($original_message) ) );
1810
+							if (str_replace($tags, '', $original_message) == str_replace($tags, '', __($message, 'wpshop'))) {
1811
+								wp_update_post(array('ID' => $message_option, 'post_content' => wps_message_ctr::customize_message($original_message)));
1812 1812
 							}
1813 1813
 						}
1814 1814
 					}
@@ -1824,8 +1824,8 @@  discard block
 block discarded – undo
1824 1824
 			break;
1825 1825
 
1826 1826
 			case '46':
1827
-				wps_message_ctr::createMessage( 'WPSHOP_FORGOT_PASSWORD_MESSAGE' );
1828
-				wps_message_ctr::customize_message( WPSHOP_FORGOT_PASSWORD_MESSAGE );
1827
+				wps_message_ctr::createMessage('WPSHOP_FORGOT_PASSWORD_MESSAGE');
1828
+				wps_message_ctr::customize_message(WPSHOP_FORGOT_PASSWORD_MESSAGE);
1829 1829
 				return true;
1830 1830
 			break;
1831 1831
 
@@ -1838,17 +1838,17 @@  discard block
 block discarded – undo
1838 1838
 				@ini_set('max_execution_time', '500');
1839 1839
 
1840 1840
 				$count_products = wp_count_posts(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
1841
-				$output_type_option = get_option( 'wpshop_display_option' );
1841
+				$output_type_option = get_option('wpshop_display_option');
1842 1842
 				$output_type = $output_type_option['wpshop_display_list_type'];
1843 1843
 
1844
-				for( $i = 0; $i <= $count_products->publish; $i+= 20 ) {
1845
-					$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' );
1846
-					$products = $wpdb->get_results( $query );
1847
-					if ( !empty($products) ) {
1848
-						foreach( $products as $product ) {
1844
+				for ($i = 0; $i <= $count_products->publish; $i += 20) {
1845
+					$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');
1846
+					$products = $wpdb->get_results($query);
1847
+					if (!empty($products)) {
1848
+						foreach ($products as $product) {
1849 1849
 							$p = wpshop_products::get_product_data($product->ID);
1850
-							$price = wpshop_prices::get_product_price($p, 'just_price_infos', array('mini_output', $output_type) );
1851
-							update_post_meta(  $product->ID, '_wps_price_infos', $price );
1850
+							$price = wpshop_prices::get_product_price($p, 'just_price_infos', array('mini_output', $output_type));
1851
+							update_post_meta($product->ID, '_wps_price_infos', $price);
1852 1852
 						}
1853 1853
 					}
1854 1854
 				}
@@ -1857,15 +1857,15 @@  discard block
 block discarded – undo
1857 1857
 			break;
1858 1858
 
1859 1859
 			case '49' :
1860
-				update_option( 'wpshop_send_invoice', true);
1860
+				update_option('wpshop_send_invoice', true);
1861 1861
 				return true;
1862 1862
 			break;
1863 1863
 
1864 1864
 			case '50' :
1865
-				$price_display_option = get_option( 'wpshop_catalog_product_option' );
1865
+				$price_display_option = get_option('wpshop_catalog_product_option');
1866 1866
 				$price_display_option['price_display']['text_from'] = 'on';
1867 1867
 				$price_display_option['price_display']['lower_price'] = 'on';
1868
-				update_option( 'wpshop_catalog_product_option', $price_display_option );
1868
+				update_option('wpshop_catalog_product_option', $price_display_option);
1869 1869
 
1870 1870
  				self::wpshop_insert_default_pages();
1871 1871
 
@@ -1874,45 +1874,45 @@  discard block
 block discarded – undo
1874 1874
 
1875 1875
 			case '51' :
1876 1876
 				/**	Insert new message for direct payment link	*/
1877
-				$direct_payment_link_message = get_option( 'WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE' );
1878
-				if ( empty($direct_payment_link_message) ) {
1879
-					wps_message_ctr::createMessage( 'WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE' );
1877
+				$direct_payment_link_message = get_option('WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE');
1878
+				if (empty($direct_payment_link_message)) {
1879
+					wps_message_ctr::createMessage('WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE');
1880 1880
 				}
1881 1881
 				return true;
1882 1882
 			break;
1883 1883
 
1884 1884
 			case '52' :
1885
-				$account_page_option = get_option( 'wpshop_myaccount_page_id' );
1886
-				if( !empty($account_page_option) ) {
1887
-					$page_account = get_post( $account_page_option );
1888
-					$page_content = ( !empty($page_account) && !empty($page_account->post_content) ) ? str_replace( '[wpshop_myaccount]', '[wps_account_dashboard]', $page_account->post_content ) : '[wps_account_dashboard]';
1889
-					wp_update_post( array('ID' => $account_page_option, 'post_content' => $page_content ) );
1885
+				$account_page_option = get_option('wpshop_myaccount_page_id');
1886
+				if (!empty($account_page_option)) {
1887
+					$page_account = get_post($account_page_option);
1888
+					$page_content = (!empty($page_account) && !empty($page_account->post_content)) ? str_replace('[wpshop_myaccount]', '[wps_account_dashboard]', $page_account->post_content) : '[wps_account_dashboard]';
1889
+					wp_update_post(array('ID' => $account_page_option, 'post_content' => $page_content));
1890 1890
 				}
1891 1891
 				return true;
1892 1892
 			break;
1893 1893
 
1894 1894
 			case '53' :
1895
-				$payment_modes_option = get_option( 'wps_payment_mode' );
1896
-				if( !empty($payment_modes_option) && !empty($payment_modes_option['mode']) ) {
1895
+				$payment_modes_option = get_option('wps_payment_mode');
1896
+				if (!empty($payment_modes_option) && !empty($payment_modes_option['mode'])) {
1897 1897
 					$payment_modes_option['mode']['cash_on_delivery'] = array(
1898
-							'name' => __( 'Cash on delivery', 'wpshop'),
1899
-							'logo' => WPSHOP_TEMPLATES_URL.'wpshop/cheque.png',
1900
-							'description' => __( 'Pay your order on delivery', 'wpshop') );
1898
+							'name' => __('Cash on delivery', 'wpshop'),
1899
+							'logo' => WPSHOP_TEMPLATES_URL . 'wpshop/cheque.png',
1900
+							'description' => __('Pay your order on delivery', 'wpshop') );
1901 1901
 
1902
-					update_option( 'wps_payment_mode' ,$payment_modes_option );
1902
+					update_option('wps_payment_mode', $payment_modes_option);
1903 1903
 				}
1904 1904
 
1905 1905
 				// Mass action on products to add a flag on variation definition
1906
-				$products = get_posts( array('posts_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) );
1907
-				if( !empty($products) ) {
1908
-					foreach( $products as $p ) {
1906
+				$products = get_posts(array('posts_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT));
1907
+				if (!empty($products)) {
1908
+					foreach ($products as $p) {
1909 1909
 						$post_id = $p->ID;
1910
-						$check_product_have_variations = wpshop_products::get_variation( $post_id );
1911
-						if( !empty($check_product_have_variations) ) {
1912
-							$variation_flag =  wpshop_products::check_variation_type( $post_id );
1913
-							$variation_defining = get_post_meta( $post_id, '_wpshop_variation_defining', true );
1910
+						$check_product_have_variations = wpshop_products::get_variation($post_id);
1911
+						if (!empty($check_product_have_variations)) {
1912
+							$variation_flag = wpshop_products::check_variation_type($post_id);
1913
+							$variation_defining = get_post_meta($post_id, '_wpshop_variation_defining', true);
1914 1914
 							$variation_defining['variation_type'] = $variation_flag;
1915
-							update_post_meta( $post_id, '_wpshop_variation_defining', $variation_defining );
1915
+							update_post_meta($post_id, '_wpshop_variation_defining', $variation_defining);
1916 1916
 						}
1917 1917
 					}
1918 1918
 				}
@@ -1921,28 +1921,28 @@  discard block
 block discarded – undo
1921 1921
 
1922 1922
 			case '54' :
1923 1923
 				// Change shortcode of sign up page
1924
-				$signup_page_id = get_option( 'wpshop_signup_page_id' );
1925
-				if( !empty($signup_page_id) ) {
1926
-					$signup_page = get_post( $signup_page_id );
1927
-					$signup_page_content = ( !empty($signup_page) && !empty($signup_page->post_content) ) ? str_replace( '[wpshop_signup]', '[wps_account_dashboard]', $signup_page->post_content ) : '[wps_account_dashboard]';
1928
-					wp_update_post( array('ID' => $signup_page_id, 'post_content' => $signup_page_content ) );
1924
+				$signup_page_id = get_option('wpshop_signup_page_id');
1925
+				if (!empty($signup_page_id)) {
1926
+					$signup_page = get_post($signup_page_id);
1927
+					$signup_page_content = (!empty($signup_page) && !empty($signup_page->post_content)) ? str_replace('[wpshop_signup]', '[wps_account_dashboard]', $signup_page->post_content) : '[wps_account_dashboard]';
1928
+					wp_update_post(array('ID' => $signup_page_id, 'post_content' => $signup_page_content));
1929 1929
 				}
1930 1930
 
1931 1931
 				// Change Terms of sale default content
1932
-				$terms_page_id = get_option( 'wpshop_terms_of_sale_page_id' );
1933
-				if( !empty($terms_page_id) ) {
1934
-					$terms_sale_page = get_post( $terms_page_id );
1935
-					if( !empty($terms_sale_page) && !empty($terms_sale_page->post_content) && $terms_sale_page->post_content == '[wpshop_terms_of_sale]' ) {
1936
-						$data  = '<h1>'.__( 'Your terms of sale', 'wpshop' ).'</h1>';
1937
-						$data .= '<h3>'.__( 'Rule', 'wpshop' ).' 1</h3>';
1932
+				$terms_page_id = get_option('wpshop_terms_of_sale_page_id');
1933
+				if (!empty($terms_page_id)) {
1934
+					$terms_sale_page = get_post($terms_page_id);
1935
+					if (!empty($terms_sale_page) && !empty($terms_sale_page->post_content) && $terms_sale_page->post_content == '[wpshop_terms_of_sale]') {
1936
+						$data  = '<h1>' . __('Your terms of sale', 'wpshop') . '</h1>';
1937
+						$data .= '<h3>' . __('Rule', 'wpshop') . ' 1</h3>';
1938 1938
 						$data .= '<p>Ut enim quisque sibi plurimum confidit et ut quisque maxime virtute et sapientia sic munitus est, ut nullo egeat suaque omnia in se ipso posita iudicet, ita in amicitiis expetendis colendisque maxime excellit.</p>';
1939
-						$data .= '<h3>'.__( 'Rule', 'wpshop' ).' 2</h3>';
1939
+						$data .= '<h3>' . __('Rule', 'wpshop') . ' 2</h3>';
1940 1940
 						$data .= '<p>Ut enim quisque sibi plurimum confidit et ut quisque maxime virtute et sapientia sic munitus est, ut nullo egeat suaque omnia in se ipso posita iudicet, ita in amicitiis expetendis colendisque maxime excellit.</p>';
1941
-						$data .= '<h3>'.__( 'Rule', 'wpshop' ).' 3</h3>';
1941
+						$data .= '<h3>' . __('Rule', 'wpshop') . ' 3</h3>';
1942 1942
 						$data .= '<p>Ut enim quisque sibi plurimum confidit et ut quisque maxime virtute et sapientia sic munitus est, ut nullo egeat suaque omnia in se ipso posita iudicet, ita in amicitiis expetendis colendisque maxime excellit.</p>';
1943
-						$data .= '<h3>'.__( 'Credits', 'wpshop' ).'</h3>';
1944
-						$data .= sprintf( __( '%s uses <a href="http://www.wpshop.fr/" target="_blank" title="%s uses WPShop e-commerce plug-in for Wordpress">WPShop e-commerce for Wordpress</a>', 'wpshop'), get_bloginfo('name'), get_bloginfo('name') );
1945
-						wp_update_post( array('ID' => $terms_page_id, 'post_content' => $data ) );
1943
+						$data .= '<h3>' . __('Credits', 'wpshop') . '</h3>';
1944
+						$data .= sprintf(__('%s uses <a href="http://www.wpshop.fr/" target="_blank" title="%s uses WPShop e-commerce plug-in for Wordpress">WPShop e-commerce for Wordpress</a>', 'wpshop'), get_bloginfo('name'), get_bloginfo('name'));
1945
+						wp_update_post(array('ID' => $terms_page_id, 'post_content' => $data));
1946 1946
 					}
1947 1947
 				}
1948 1948
 
@@ -1951,58 +1951,58 @@  discard block
 block discarded – undo
1951 1951
 
1952 1952
 
1953 1953
 			case '55' :
1954
-				$checkout_page_id = get_option( 'wpshop_checkout_page_id' );
1955
-				$checkout_page = get_post( $checkout_page_id );
1956
-				$checkout_page_content = ( !empty($checkout_page) && !empty($checkout_page->post_content) ) ? str_replace( '[wpshop_checkout]', '[wps_checkout]', $checkout_page->post_content ) : '[wps_checkout]';
1957
-				wp_update_post( array('ID' => $checkout_page_id, 'post_content' => $checkout_page_content ) );
1954
+				$checkout_page_id = get_option('wpshop_checkout_page_id');
1955
+				$checkout_page = get_post($checkout_page_id);
1956
+				$checkout_page_content = (!empty($checkout_page) && !empty($checkout_page->post_content)) ? str_replace('[wpshop_checkout]', '[wps_checkout]', $checkout_page->post_content) : '[wps_checkout]';
1957
+				wp_update_post(array('ID' => $checkout_page_id, 'post_content' => $checkout_page_content));
1958 1958
 
1959 1959
 				// Update cart page id
1960
-				update_option( 'wpshop_cart_page_id', $checkout_page_id );
1960
+				update_option('wpshop_cart_page_id', $checkout_page_id);
1961 1961
 				return true;
1962 1962
 			break;
1963 1963
 
1964 1964
 
1965 1965
 			case '56' :
1966 1966
 				$wps_entities = new wpshop_entities();
1967
-				$customer_entity_id = $wps_entities->get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
1968
-				$query = $wpdb->prepare( 'SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d ORDER BY id LIMIT 1', $customer_entity_id );
1969
-				$set = $wpdb->get_row( $query );
1970
-				if( !empty($set) ) {
1971
-					$wpdb->update( WPSHOP_DBT_ATTRIBUTE_SET,
1972
-							array( 'default_set' => 'yes' ),
1973
-							array( 'id' => $set->id) );
1967
+				$customer_entity_id = $wps_entities->get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
1968
+				$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d ORDER BY id LIMIT 1', $customer_entity_id);
1969
+				$set = $wpdb->get_row($query);
1970
+				if (!empty($set)) {
1971
+					$wpdb->update(WPSHOP_DBT_ATTRIBUTE_SET,
1972
+							array('default_set' => 'yes'),
1973
+							array('id' => $set->id));
1974 1974
 				}
1975 1975
 				// Update Opinions activation option
1976
-				update_option( 'wps_opinion', array( 'active' => 'on') );
1976
+				update_option('wps_opinion', array('active' => 'on'));
1977 1977
 				return true;
1978 1978
 			break;
1979 1979
 
1980 1980
 			case '57' :
1981
-				$wpshop_cart_option = get_option( 'wpshop_cart_option' );
1981
+				$wpshop_cart_option = get_option('wpshop_cart_option');
1982 1982
 				$wpshop_cart_option['display_newsletter']['site_subscription'][] = 'yes';
1983 1983
 				$wpshop_cart_option['display_newsletter']['partner_subscription'][] = 'yes';
1984 1984
 
1985
-				update_option( 'wpshop_cart_option', $wpshop_cart_option );
1985
+				update_option('wpshop_cart_option', $wpshop_cart_option);
1986 1986
 				return true;
1987 1987
 			break;
1988 1988
 
1989 1989
 			case '58' :
1990 1990
 				/** Turn customers publish into draft **/
1991
-				$query = $wpdb->prepare( "UPDATE {$wpdb->posts} SET post_status = %s WHERE post_type = %s", "draft", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
1992
-				$wpdb->query( $query );
1991
+				$query = $wpdb->prepare("UPDATE {$wpdb->posts} SET post_status = %s WHERE post_type = %s", "draft", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
1992
+				$wpdb->query($query);
1993 1993
 
1994 1994
 				$attribute_def = wpshop_attributes::getElement('tx_tva', "'valid'", 'code');
1995 1995
 				/** Check if the 0% VAT Rate is not already created **/
1996
-				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE attribute_id = %d AND value = %s',  $attribute_def->id, '0');
1997
-				$exist_vat_rate = $wpdb->get_results( $query );
1996
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE attribute_id = %d AND value = %s', $attribute_def->id, '0');
1997
+				$exist_vat_rate = $wpdb->get_results($query);
1998 1998
 
1999
-				if ( empty($exist_vat_rate) ) {
1999
+				if (empty($exist_vat_rate)) {
2000 2000
 					/** Get Max Position **/
2001
-					$query = $wpdb->prepare('SELECT MAX(position) as max_position FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE attribute_id = %d', $attribute_def->id);
2002
-					$max_position = $wpdb->get_var( $query );
2001
+					$query = $wpdb->prepare('SELECT MAX(position) as max_position FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE attribute_id = %d', $attribute_def->id);
2002
+					$max_position = $wpdb->get_var($query);
2003 2003
 
2004
-					if ( !empty( $attribute_def) && !empty($attribute_def->id)  ) {
2005
-						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' =>  $attribute_def->id, 'position' => (int)$max_position + 1, 'value' => '0', 'label' => '0') );
2004
+					if (!empty($attribute_def) && !empty($attribute_def->id)) {
2005
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' =>  $attribute_def->id, 'position' => (int)$max_position + 1, 'value' => '0', 'label' => '0'));
2006 2006
 					}
2007 2007
 				}
2008 2008
 				return true;
@@ -2014,31 +2014,31 @@  discard block
 block discarded – undo
2014 2014
 				$args = array(
2015 2015
 						'posts_per_page'   => -1,
2016 2016
 						'post_type'        => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT,
2017
-						'post_status'	   => array( 'publish', 'draft', 'trash' ),
2017
+						'post_status'	   => array('publish', 'draft', 'trash'),
2018 2018
 				);
2019
-				$posts = get_posts( $args );
2019
+				$posts = get_posts($args);
2020 2020
 				$result = array();
2021
-				foreach( $posts as $post ) {
2021
+				foreach ($posts as $post) {
2022 2022
 					$array = array();
2023 2023
 					$array['Post'] = $post;
2024
-					$array['PrincipalThumbnailID'] = get_post_meta( $post->ID, '_thumbnail_id', true);
2025
-					$array['Attachments'] = get_attached_media( $allowed, $post->ID );
2026
-					$array['TrueAttachmentsString'] = get_post_meta( $post->ID, '_wps_product_media', true );
2027
-					if( !empty( $array['TrueAttachmentsString'] ) ) {
2028
-						$TrueAttachments_id = explode( ',', $array['TrueAttachmentsString'] );
2024
+					$array['PrincipalThumbnailID'] = get_post_meta($post->ID, '_thumbnail_id', true);
2025
+					$array['Attachments'] = get_attached_media($allowed, $post->ID);
2026
+					$array['TrueAttachmentsString'] = get_post_meta($post->ID, '_wps_product_media', true);
2027
+					if (!empty($array['TrueAttachmentsString'])) {
2028
+						$TrueAttachments_id = explode(',', $array['TrueAttachmentsString']);
2029 2029
 					}
2030 2030
 					$array['OldAttachmentsString'] = '';
2031
-					foreach( $array['Attachments'] as $attachment ) {
2032
-						$filename =  basename( get_attached_file( $attachment->ID ) );
2033
-						$pos_ext = strrpos( $filename, '.' );
2034
-						$filename_no_ext = substr( $filename, 0, $pos_ext );
2035
-						if( ( empty($TrueAttachments_id) || !in_array( $attachment->ID, $TrueAttachments_id ) ) && !( preg_match('#'.$filename_no_ext.'#', $post->post_content) ) && ( ( empty( $array['PrincipalThumbnailID'] ) || $attachment->ID != $array['PrincipalThumbnailID'] ) ) ) {
2031
+					foreach ($array['Attachments'] as $attachment) {
2032
+						$filename = basename(get_attached_file($attachment->ID));
2033
+						$pos_ext = strrpos($filename, '.');
2034
+						$filename_no_ext = substr($filename, 0, $pos_ext);
2035
+						if ((empty($TrueAttachments_id) || !in_array($attachment->ID, $TrueAttachments_id)) && !(preg_match('#' . $filename_no_ext . '#', $post->post_content)) && ((empty($array['PrincipalThumbnailID']) || $attachment->ID != $array['PrincipalThumbnailID']))) {
2036 2036
 							$array['OldAttachmentsString'] .= $attachment->ID . ',';
2037 2037
 						}
2038 2038
 					}
2039 2039
 					unset($TrueAttachments_id);
2040 2040
 					$result[$post->ID] = $array['TrueAttachmentsString'] . $array['OldAttachmentsString'];
2041
-					update_post_meta( $post->ID, '_wps_product_media', $result[$post->ID] );
2041
+					update_post_meta($post->ID, '_wps_product_media', $result[$post->ID]);
2042 2042
 				}
2043 2043
 				return true;
2044 2044
 			break;
@@ -2048,26 +2048,26 @@  discard block
 block discarded – undo
2048 2048
 				wps_message_ctr::create_default_message();
2049 2049
 
2050 2050
 				/** Update entries for quick add */
2051
-				$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_required = "yes", is_used_in_quick_add_form = "yes" WHERE code = "barcode"');
2052
-				$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes" WHERE code = "product_stock"');
2053
-				$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes" WHERE code = "manage_stock"');
2054
-				switch( WPSHOP_PRODUCT_PRICE_PILOT ) {
2051
+				$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_required = "yes", is_used_in_quick_add_form = "yes" WHERE code = "barcode"');
2052
+				$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes" WHERE code = "product_stock"');
2053
+				$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes" WHERE code = "manage_stock"');
2054
+				switch (WPSHOP_PRODUCT_PRICE_PILOT) {
2055 2055
 					case 'HT':
2056
-						$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "price_ht"');
2057
-						$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no" WHERE code = "tx_tva"');
2058
-						$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "product_price"');
2056
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "price_ht"');
2057
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "no" WHERE code = "tx_tva"');
2058
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "product_price"');
2059 2059
 						break;
2060 2060
 					default:
2061
-						$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "product_price"');
2062
-						$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes" WHERE code = "tx_tva"');
2063
-						$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "price_ht"');
2061
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "product_price"');
2062
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes" WHERE code = "tx_tva"');
2063
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "price_ht"');
2064 2064
 						break;
2065 2065
 				}
2066 2066
 
2067 2067
 				/* Default country with WP language */
2068 2068
 				$wpshop_country_default_choice_option = get_option('wpshop_country_default_choice');
2069
-				if ( empty($wpshop_country_default_choice_option) ) {
2070
-					update_option( 'wpshop_country_default_choice', substr( get_bloginfo( 'language' ), 3) );
2069
+				if (empty($wpshop_country_default_choice_option)) {
2070
+					update_option('wpshop_country_default_choice', substr(get_bloginfo('language'), 3));
2071 2071
 				}
2072 2072
 				return true;
2073 2073
 			break;
@@ -2078,9 +2078,9 @@  discard block
 block discarded – undo
2078 2078
 
2079 2079
  				/* Hide admin bar */
2080 2080
  				$wpshop_display_option = get_option('wpshop_display_option');
2081
- 				if( !empty($wpshop_display_option) && empty($wpshop_display_option['wpshop_hide_admin_bar']) ) {
2081
+ 				if (!empty($wpshop_display_option) && empty($wpshop_display_option['wpshop_hide_admin_bar'])) {
2082 2082
  					$wpshop_display_option['wpshop_hide_admin_bar'] = 'on';
2083
- 					update_option( 'wpshop_display_option', $wpshop_display_option );
2083
+ 					update_option('wpshop_display_option', $wpshop_display_option);
2084 2084
  				}
2085 2085
 
2086 2086
 				return true;
@@ -2094,30 +2094,30 @@  discard block
 block discarded – undo
2094 2094
 			break;
2095 2095
 
2096 2096
 			case '63':
2097
-				$data = get_option( 'wps_shipping_mode' );
2098
-				if ( empty($data['modes']['default_shipping_mode_for_pos']) ) {
2097
+				$data = get_option('wps_shipping_mode');
2098
+				if (empty($data['modes']['default_shipping_mode_for_pos'])) {
2099 2099
 					$data['modes']['default_shipping_mode_for_pos']['name'] = __('No Delivery', 'wpshop');
2100 2100
 					$data['modes']['default_shipping_mode_for_pos']['explanation'] = __('Delivery method for point of sale.', 'wpshop');
2101
-					update_option( 'wps_shipping_mode', $data );
2101
+					update_option('wps_shipping_mode', $data);
2102 2102
 				}
2103 2103
 				return true;
2104 2104
 			break;
2105 2105
 
2106 2106
 			case '64':
2107
-				$options = get_option( 'wpshop_catalog_product_option' );
2108
-				if ( !empty( $options['wpshop_catalog_product_slug_with_category'] ) ) {
2109
-					unset( $options['wpshop_catalog_product_slug_with_category'] );
2110
-					update_option( 'wpshop_catalog_product_option', $options );
2107
+				$options = get_option('wpshop_catalog_product_option');
2108
+				if (!empty($options['wpshop_catalog_product_slug_with_category'])) {
2109
+					unset($options['wpshop_catalog_product_slug_with_category']);
2110
+					update_option('wpshop_catalog_product_option', $options);
2111 2111
 				}
2112 2112
 				return true;
2113 2113
 			break;
2114 2114
 			
2115 2115
 			case '65':
2116
-				$entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
2117
-				$query = $wpdb->prepare( 'SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s AND entity_id = %d', 'company_customer', $entity_id );
2118
-				$company_id = $wpdb->get_var( $query );
2119
-				if( !isset( $company_id ) ) {
2120
-					$wpdb->insert( WPSHOP_DBT_ATTRIBUTE, array(
2116
+				$entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
2117
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s AND entity_id = %d', 'company_customer', $entity_id);
2118
+				$company_id = $wpdb->get_var($query);
2119
+				if (!isset($company_id)) {
2120
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE, array(
2121 2121
 						'is_visible_in_front' => 'no',
2122 2122
 						'is_visible_in_front_listing' => 'yes',
2123 2123
 						'is_global' => 'no',
@@ -2160,14 +2160,14 @@  discard block
 block discarded – undo
2160 2160
 						'backend_css_class' => NULL,
2161 2161
 						'frontend_help_message' => NULL,
2162 2162
 						'entity_id' => $entity_id
2163
-					) );
2163
+					));
2164 2164
 					$company_id = $wpdb->insert_id;
2165 2165
 				}
2166 2166
 				
2167
-				$query = $wpdb->prepare( 'SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s AND entity_id = %d', 'is_provider', $entity_id );
2168
-				$is_provider_id = $wpdb->get_var( $query );
2169
-				if( !isset( $is_provider_id ) ) {
2170
-					$wpdb->insert( WPSHOP_DBT_ATTRIBUTE, array(
2167
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s AND entity_id = %d', 'is_provider', $entity_id);
2168
+				$is_provider_id = $wpdb->get_var($query);
2169
+				if (!isset($is_provider_id)) {
2170
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE, array(
2171 2171
 						'is_visible_in_front' => 'no',
2172 2172
 						'is_visible_in_front_listing' => 'yes',
2173 2173
 						'is_global' => 'no',
@@ -2210,80 +2210,80 @@  discard block
 block discarded – undo
2210 2210
 						'backend_css_class' => NULL,
2211 2211
 						'frontend_help_message' => NULL,
2212 2212
 						'entity_id' => $entity_id
2213
-					) );
2213
+					));
2214 2214
 					$is_provider_id = $wpdb->insert_id;
2215
-					$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array(
2215
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array(
2216 2216
 						'status'				=> 'valid',
2217 2217
 						'attribute_id' 			=> $is_provider_id,
2218 2218
 						'creation_date_value' 	=> current_time('mysql'),
2219 2219
 						'value' 				=> 'yes',
2220 2220
 						'label' 				=> 'Yes',
2221
-					) );
2222
-					$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array(
2221
+					));
2222
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array(
2223 2223
 						'status'				=> 'valid',
2224 2224
 						'attribute_id' 			=> $is_provider_id,
2225 2225
 						'creation_date_value' 	=> current_time('mysql'),
2226 2226
 						'value' 				=> 'no',
2227 2227
 						'label' 				=> 'No',
2228
-					) );
2228
+					));
2229 2229
 					$default_value = $wpdb->insert_id;
2230
-					$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array( 'default_value' => $default_value ), array( 'id' => $is_provider_id ) );
2230
+					$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('default_value' => $default_value), array('id' => $is_provider_id));
2231 2231
 				}
2232 2232
 				
2233
-				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_id = %s', $company_id );
2233
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_id = %s', $company_id);
2234 2234
 				$company_section_detail_id = $wpdb->get_var($query);
2235 2235
 				
2236
-				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_id = %s', $is_provider_id );
2236
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_id = %s', $is_provider_id);
2237 2237
 				$is_provider_section_detail_id = $wpdb->get_var($query);
2238 2238
 				
2239
-				if( !isset( $is_provider_section_detail_id ) || !isset( $company_section_detail_id ) ) {
2240
-					$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id );
2239
+				if (!isset($is_provider_section_detail_id) || !isset($company_section_detail_id)) {
2240
+					$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id);
2241 2241
 					$attribute_set_id = $wpdb->get_var($query);
2242 2242
 					
2243 2243
 					$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %d AND code = LOWER(%s)", $attribute_set_id, 'account');
2244 2244
 					$attribute_set_section_id = $wpdb->get_var($query);
2245 2245
 					
2246
-					$query = $wpdb->prepare( 'SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', $entity_id, $attribute_set_id, $attribute_set_section_id );
2247
-					$attributes_set_details = $wpdb->get_results( $query );
2246
+					$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', $entity_id, $attribute_set_id, $attribute_set_section_id);
2247
+					$attributes_set_details = $wpdb->get_results($query);
2248 2248
 					$set_details_id_postion_order = array();
2249
-					foreach( $attributes_set_details as $attribute_set_detail ) {
2250
-						$query = $wpdb->prepare( 'SELECT code FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE id = %d', $attribute_set_detail->attribute_id );
2251
-						$attribute_set_detail_code = $wpdb->get_var( $query );
2252
-						if( $attribute_set_detail_code == 'last_name' ) {
2249
+					foreach ($attributes_set_details as $attribute_set_detail) {
2250
+						$query = $wpdb->prepare('SELECT code FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE id = %d', $attribute_set_detail->attribute_id);
2251
+						$attribute_set_detail_code = $wpdb->get_var($query);
2252
+						if ($attribute_set_detail_code == 'last_name') {
2253 2253
 							$set_details_id_postion_order[1] = $attribute_set_detail->attribute_id;
2254 2254
 						}
2255
-						if( $attribute_set_detail_code == 'first_name' ) {
2255
+						if ($attribute_set_detail_code == 'first_name') {
2256 2256
 							$set_details_id_postion_order[2] = $attribute_set_detail->attribute_id;
2257 2257
 						}
2258
-						if( $attribute_set_detail_code == 'user_email' ) {
2258
+						if ($attribute_set_detail_code == 'user_email') {
2259 2259
 							$set_details_id_postion_order[3] = $attribute_set_detail->attribute_id;
2260 2260
 						}
2261
-						if( $attribute_set_detail_code == 'user_pass' ) {
2261
+						if ($attribute_set_detail_code == 'user_pass') {
2262 2262
 							$set_details_id_postion_order[4] = $attribute_set_detail->attribute_id;
2263 2263
 						}
2264 2264
 					}
2265
-					$max_position = count( $set_details_id_postion_order );
2265
+					$max_position = count($set_details_id_postion_order);
2266 2266
 					
2267
-					if( !isset( $company_section_detail_id ) ) {
2267
+					if (!isset($company_section_detail_id)) {
2268 2268
 						$max_position = $max_position + 1;
2269
-						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $company_id, 'position' => (int)$max_position ) );
2269
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $company_id, 'position' => (int)$max_position));
2270 2270
 						$set_details_id_postion_order[$max_position] = $company_id;
2271 2271
 						$company_section_detail_id = $wpdb->insert_id;
2272 2272
 					}
2273 2273
 					
2274
-					if( !isset( $is_provider_section_detail_id ) ) {
2274
+					if (!isset($is_provider_section_detail_id)) {
2275 2275
 						$max_position = $max_position + 1;
2276
-						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $is_provider_id, 'position' => (int)$max_position ) );
2276
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $is_provider_id, 'position' => (int)$max_position));
2277 2277
 						$set_details_id_postion_order[$max_position] = $is_provider_id;
2278 2278
 						$is_provider_section_detail_id = $wpdb->insert_id;
2279 2279
 					}
2280 2280
 					
2281
-					foreach( $set_details_id_postion_order as $pos => $attr_id ) {
2282
-						$wpdb->update( WPSHOP_DBT_ATTRIBUTE_DETAILS, array( 'position' => $pos ), array( 'attribute_id' => $attr_id, 'attribute_set_id' => $attribute_set_id, 'entity_type_id' => $entity_id, 'attribute_group_id' => $attribute_set_section_id ), array( '%d' ), array( '%d', '%d', '%d', '%d' ) );
2281
+					foreach ($set_details_id_postion_order as $pos => $attr_id) {
2282
+						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('position' => $pos), array('attribute_id' => $attr_id, 'attribute_set_id' => $attribute_set_id, 'entity_type_id' => $entity_id, 'attribute_group_id' => $attribute_set_section_id), array('%d'), array('%d', '%d', '%d', '%d'));
2283 2283
 					}
2284 2284
 				}
2285 2285
 				
2286
-				$wpdb->update( WPSHOP_DBT_ATTRIBUTE_SET, array( 'name' => __( 'Free product', 'wpshop' ), 'slug' => 'free_product' ), array( 'name' => 'free_product' ), array( '%s', '%s' ), array( '%s' ) );
2286
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_SET, array('name' => __('Free product', 'wpshop'), 'slug' => 'free_product'), array('name' => 'free_product'), array('%s', '%s'), array('%s'));
2287 2287
 				
2288 2288
 				return true;
2289 2289
 			break;
@@ -2307,23 +2307,23 @@  discard block
 block discarded – undo
2307 2307
 	 * Method called when deactivating the plugin
2308 2308
 	 * @see register_deactivation_hook()
2309 2309
 	 */
2310
-	function uninstall_wpshop(){
2310
+	function uninstall_wpshop() {
2311 2311
 		global $wpdb;
2312 2312
 
2313
-		if(WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION && in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP))){
2313
+		if (WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION && in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP))) {
2314 2314
 			$query = $wpdb->query("DROP TABLE `wp_wpshop__attribute`, `wp_wpshop__attributes_unit`, `wp_wpshop__attributes_unit_groups`, `wp_wpshop__attribute_set`, `wp_wpshop__attribute_set_section`, `wp_wpshop__attribute_set_section_details`, `wp_wpshop__attribute_value_datetime`, `wp_wpshop__attribute_value_decimal`, `wp_wpshop__attribute_value_integer`, `wp_wpshop__attribute_value_text`, `wp_wpshop__attribute_value_varchar`, `wp_wpshop__attribute_value__histo`, `wp_wpshop__cart`, `wp_wpshop__cart_contents`, `wp_wpshop__documentation`, `wp_wpshop__entity`, `wp_wpshop__historique`, `wp_wpshop__message`, `wp_wpshop__attribute_value_options`;");
2315 2315
 			$query = $wpdb->query("DELETE FROM " . $wpdb->options . " WHERE `option_name` LIKE '%wpshop%';");
2316 2316
 
2317 2317
 			$wpshop_products_posts = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type LIKE 'wpshop_%';");
2318 2318
 			$list = '  ';
2319
-			foreach($wpshop_products_posts as $post){
2319
+			foreach ($wpshop_products_posts as $post) {
2320 2320
 				$list .= "'" . $post->ID . "', ";
2321 2321
 			}
2322 2322
 			$list = substr($list, 0, -2);
2323 2323
 
2324 2324
 			$wpshop_products_posts = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_parent IN (" . $list . ");");
2325 2325
 			$list_attachment = '  ';
2326
-			foreach($wpshop_products_posts as $post){
2326
+			foreach ($wpshop_products_posts as $post) {
2327 2327
 				$list_attachment .= "'" . $post->ID . "', ";
2328 2328
 			}
2329 2329
 			$list_attachment = substr($list_attachment, 0, -2);
@@ -2337,9 +2337,9 @@  discard block
 block discarded – undo
2337 2337
 
2338 2338
 		/*	Unset administrator permission	*/
2339 2339
 		$adminRole = get_role('administrator');
2340
-		foreach($adminRole->capabilities as $capabilityName => $capability){
2341
-			if(substr($capabilityName, 0, 7) == 'wpshop_'){
2342
-				if($adminRole->has_cap($capabilityName)){
2340
+		foreach ($adminRole->capabilities as $capabilityName => $capability) {
2341
+			if (substr($capabilityName, 0, 7) == 'wpshop_') {
2342
+				if ($adminRole->has_cap($capabilityName)) {
2343 2343
 					$adminRole->remove_cap($capabilityName);
2344 2344
 				}
2345 2345
 			}
Please login to merge, or discard this patch.
Braces   +21 added lines, -24 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' ) ) {
@@ -142,10 +144,12 @@  discard block
 block discarded – undo
142 144
 		$defined_sample_datas = new SimpleXMLElement( $sample_datas, LIBXML_NOCDATA );
143 145
 
144 146
 		$namespaces = $defined_sample_datas->getDocNamespaces();
145
-		if ( ! isset( $namespaces['wp'] ) )
146
-			$namespaces['wp'] = 'http://wordpress.org/export/1.1/';
147
-		if ( ! isset( $namespaces['excerpt'] ) )
148
-			$namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/';
147
+		if ( ! isset( $namespaces['wp'] ) ) {
148
+					$namespaces['wp'] = 'http://wordpress.org/export/1.1/';
149
+		}
150
+		if ( ! isset( $namespaces['excerpt'] ) ) {
151
+					$namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/';
152
+		}
149 153
 
150 154
 		foreach ( $defined_sample_datas->xpath( '//wpshop_products/wpshop_product' ) as $product ) {
151 155
 			$dc = $product->children( 'http://purl.org/dc/elements/1.1/' );
@@ -509,8 +513,7 @@  discard block
 block discarded – undo
509 513
 									$new_set_section_infos['attribute_set_id'] = $attribute_set_id;
510 514
 									$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, $new_set_section_infos);
511 515
 									$attribute_set_section_id = $wpdb->insert_id;
512
-								}
513
-								else{
516
+								} else{
514 517
 									$new_set_section_infos = $set_group_infos;
515 518
 									$new_set_section_infos['last_update_date'] = current_time('mysql', 0);
516 519
 									$wpdb->update(WPSHOP_DBT_ATTRIBUTE_GROUP, $new_set_section_infos, array('id' => $attribute_set_section_id));
@@ -519,8 +522,7 @@  discard block
 block discarded – undo
519 522
 								if(($attribute_set_section_id > 0) && (isset($set_group_infos_details) && is_array($set_group_infos_details))){
520 523
 									if(count($set_group_infos_details) <= 0){
521 524
 										$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'status' => 'deleted'), array('entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id));
522
-									}
523
-									else{
525
+									} else{
524 526
 										$query = $wpdb->prepare("SELECT MAX(position) AS position FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d", $entity_id, $attribute_set_id, $attribute_set_section_id);
525 527
 										$last_position = $wpdb->get_var($query);
526 528
 										$position = (int)$last_position + 1;
@@ -582,8 +584,7 @@  discard block
 block discarded – undo
582 584
 							$wpdb->update( $wpdb->usermeta, array( 'meta_value' => serialize( $current_order ), ), array( 'umeta_id' => $customer_metabox_order->umeta_id ) );
583 585
 						}
584 586
 					}
585
-				}
586
-				else {
587
+				} else {
587 588
 					$users = get_users( array( 'role' => 'administrator', ) );
588 589
 					if ( !empty( $users ) ) {
589 590
 						foreach ( $users as $user ) {
@@ -960,7 +961,9 @@  discard block
 block discarded – undo
960 961
 						$options_args = array();
961 962
 						$options_args[$addon_name]['activate'] = $addon_state;
962 963
 						$options_args[$addon_name]['activation_date'] = current_time('mysql', 0);
963
-						if (! $addon_state ) $options_args[$addon_name]['deactivation_date'] = current_time('mysql', 0);
964
+						if (! $addon_state ) {
965
+							$options_args[$addon_name]['deactivation_date'] = current_time('mysql', 0);
966
+						}
964 967
 						add_option(WPSHOP_ADDONS_OPTION_NAME, $options_args);
965 968
 					}
966 969
 					delete_option('wpshop_addons_state');
@@ -1028,8 +1031,7 @@  discard block
 block discarded – undo
1028 1031
 									$civility = $miss_id;
1029 1032
 								break;
1030 1033
 							}
1031
-						}
1032
-						else {
1034
+						} else {
1033 1035
 							$civility = $mister_id ;
1034 1036
 						}
1035 1037
 						$billing_address = array('address_title' => $billing_title,
@@ -1076,8 +1078,7 @@  discard block
 block discarded – undo
1076 1078
 									$civility = $miss_id;
1077 1079
 									break;
1078 1080
 							}
1079
-						}
1080
-						else {
1081
+						} else {
1081 1082
 							$civility = $mister_id ;
1082 1083
 						}
1083 1084
 						$shipping_address = array();
@@ -1130,8 +1131,7 @@  discard block
 block discarded – undo
1130 1131
 									$civility = $mister_id ;
1131 1132
 									break;
1132 1133
 							}
1133
-						}
1134
-						else {
1134
+						} else {
1135 1135
 							$civility = $mister_id ;
1136 1136
 						}
1137 1137
 						$billing_address = array('address_title' => $billing_title,
@@ -1164,8 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 									$civility = $miss_id;
1165 1165
 									break;
1166 1166
 							}
1167
-						}
1168
-						else {
1167
+						} else {
1169 1168
 							$civility = $mister_id ;
1170 1169
 						}
1171 1170
 						$shipping_address = array('address_title' => $shipping_title,
@@ -1295,8 +1294,7 @@  discard block
 block discarded – undo
1295 1294
 									$civility = $mister_id ;
1296 1295
 									break;
1297 1296
 							}
1298
-						}
1299
-						else {
1297
+						} else {
1300 1298
 							$civility = $mister_id ;
1301 1299
 						}
1302 1300
 						$billing_address = array('address_title' => $billing_title,
@@ -1332,8 +1330,7 @@  discard block
 block discarded – undo
1332 1330
 									$civility = $miss_id;
1333 1331
 									break;
1334 1332
 							}
1335
-						}
1336
-						else {
1333
+						} else {
1337 1334
 							$civility = $mister_id;
1338 1335
 						}
1339 1336
 						$shipping_address = array('address_title' => $shipping_title,
Please login to merge, or discard this patch.
includes/librairies/payments/cic.class.php 4 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -79,6 +79,9 @@  discard block
 block discarded – undo
79 79
 	//
80 80
 	// ----------------------------------------------------------------------------
81 81
 
82
+	/**
83
+	 * @param string[] $aConstants
84
+	 */
82 85
 	private function _checkTpeParams($aConstants) {
83 86
 
84 87
 		for ($i = 0; $i < count($aConstants); $i++)
@@ -105,6 +108,9 @@  discard block
 block discarded – undo
105 108
 	//
106 109
 	// ----------------------------------------------------------------------------
107 110
 
111
+	/**
112
+	 * @param CMCIC_Tpe $oTpe
113
+	 */
108 114
 	function __construct($oTpe) {
109 115
 
110 116
 		$this->_sUsableKey = $this->_getUsableKey($oTpe);
@@ -147,6 +153,9 @@  discard block
 block discarded – undo
147 153
 	//
148 154
 	// ----------------------------------------------------------------------------
149 155
 
156
+	/**
157
+	 * @param string $sData
158
+	 */
150 159
 	public function computeHmac($sData) {
151 160
 
152 161
 		return strtolower(hash_hmac("sha1", $sData, $this->_sUsableKey));
@@ -196,6 +205,9 @@  discard block
 block discarded – undo
196 205
 //                           ********************
197 206
 //              Encodage des caract�res sp�ciaux au format HTML
198 207
 // ----------------------------------------------------------------------------
208
+/**
209
+ * @param string $data
210
+ */
199 211
 function HtmlEncode ($data)
200 212
 {
201 213
     $SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -198,22 +198,22 @@
 block discarded – undo
198 198
 // ----------------------------------------------------------------------------
199 199
 function HtmlEncode ($data)
200 200
 {
201
-    $SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";
202
-    $encoded_data = "";
203
-    $result = "";
204
-    for ($i=0; $i<strlen($data); $i++)
205
-    {
206
-        if (strchr($SAFE_OUT_CHARS, $data{$i})) {
207
-            $result .= $data{$i};
208
-        }
209
-        else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
210
-            $result .= "&#x" . $var . ";";
211
-        }
212
-        else
213
-            $result .= $data{$i};
214
-
215
-    }
216
-    return $result;
201
+	$SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";
202
+	$encoded_data = "";
203
+	$result = "";
204
+	for ($i=0; $i<strlen($data); $i++)
205
+	{
206
+		if (strchr($SAFE_OUT_CHARS, $data{$i})) {
207
+			$result .= $data{$i};
208
+		}
209
+		else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
210
+			$result .= "&#x" . $var . ";";
211
+		}
212
+		else
213
+			$result .= $data{$i};
214
+
215
+	}
216
+	return $result;
217 217
 }
218 218
 
219 219
 class wpshop_CIC {
Please login to merge, or discard this patch.
Braces   +18 added lines, -16 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' ) ) {
@@ -81,9 +83,10 @@  discard block
 block discarded – undo
81 83
 
82 84
 	private function _checkTpeParams($aConstants) {
83 85
 
84
-		for ($i = 0; $i < count($aConstants); $i++)
85
-			if (!defined($aConstants[$i]))
86
+		for ($i = 0; $i < count($aConstants); $i++) {
87
+					if (!defined($aConstants[$i]))
86 88
 				die ("Erreur param�tre " . $aConstants[$i] . " ind�fini");
89
+		}
87 90
 	}
88 91
 
89 92
 }
@@ -126,13 +129,14 @@  discard block
 block discarded – undo
126 129
 
127 130
 		$cca0=ord($hexFinal);
128 131
 
129
-		if ($cca0>70 && $cca0<97)
130
-			$hexStrKey .= chr($cca0-23) . substr($hexFinal, 1, 1);
131
-		else {
132
-			if (substr($hexFinal, 1, 1)=="M")
133
-				$hexStrKey .= substr($hexFinal, 0, 1) . "0";
134
-			else
135
-				$hexStrKey .= substr($hexFinal, 0, 2);
132
+		if ($cca0>70 && $cca0<97) {
133
+					$hexStrKey .= chr($cca0-23) . substr($hexFinal, 1, 1);
134
+		} else {
135
+			if (substr($hexFinal, 1, 1)=="M") {
136
+							$hexStrKey .= substr($hexFinal, 0, 1) . "0";
137
+			} else {
138
+							$hexStrKey .= substr($hexFinal, 0, 2);
139
+			}
136 140
 		}
137 141
 
138 142
 		return pack("H*", $hexStrKey);
@@ -205,12 +209,11 @@  discard block
 block discarded – undo
205 209
     {
206 210
         if (strchr($SAFE_OUT_CHARS, $data{$i})) {
207 211
             $result .= $data{$i};
208
-        }
209
-        else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
212
+        } else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
210 213
             $result .= "&#x" . $var . ";";
214
+        } else {
215
+                    $result .= $data{$i};
211 216
         }
212
-        else
213
-            $result .= $data{$i};
214 217
 
215 218
     }
216 219
     return $result;
@@ -329,8 +332,7 @@  discard block
 block discarded – undo
329 332
 			wpshop_payment::check_order_payment_total_amount($CMCIC_bruteVars['reference'], $params_array, $payment_status);
330 333
 
331 334
 			$receipt = CMCIC_CGI2_MACOK;
332
-		}
333
-		else {
335
+		} else {
334 336
 			// your code if the HMAC doesn't match
335 337
 			$receipt = CMCIC_CGI2_MACNOTOK.$cgi2_fields;
336 338
 		}
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 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
 
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 ***************************************************************************************/
14 14
 
15 15
 
16
-define("CMCIC_CTLHMAC","V1.04.sha1.php--[CtlHmac%s%s]-%s");
16
+define("CMCIC_CTLHMAC", "V1.04.sha1.php--[CtlHmac%s%s]-%s");
17 17
 define("CMCIC_CTLHMACSTR", "CtlHmac%s%s");
18
-define("CMCIC_CGI2_RECEIPT","version=2\ncdr=%s");
19
-define("CMCIC_CGI2_MACOK","0");
20
-define("CMCIC_CGI2_MACNOTOK","1\n");
18
+define("CMCIC_CGI2_RECEIPT", "version=2\ncdr=%s");
19
+define("CMCIC_CGI2_MACOK", "0");
20
+define("CMCIC_CGI2_MACNOTOK", "1\n");
21 21
 define("CMCIC_CGI2_FIELDS", "%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*");
22 22
 define("CMCIC_CGI1_FIELDS", "%s*%s*%s%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s");
23 23
 define("CMCIC_URLPAIEMENT", "paiement.cgi");
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 class CMCIC_Tpe {
26 26
 
27 27
 
28
-	public $sVersion;	// Version du TPE - TPE Version (Ex : 3.0)
29
-	public $sNumero;	// Numero du TPE - TPE Number (Ex : 1234567)
30
-	public $sCodeSociete;	// Code Societe - Company code (Ex : companyname)
31
-	public $sLangue;	// Langue - Language (Ex : FR, DE, EN, ..)
32
-	public $sUrlOK;		// Url de retour OK - Return URL OK
33
-	public $sUrlKO;		// Url de retour KO - Return URL KO
34
-	public $sUrlPaiement;	// Url du serveur de paiement - Payment Server URL (Ex : https://paiement.creditmutuel.fr/paiement.cgi)
28
+	public $sVersion; // Version du TPE - TPE Version (Ex : 3.0)
29
+	public $sNumero; // Numero du TPE - TPE Number (Ex : 1234567)
30
+	public $sCodeSociete; // Code Societe - Company code (Ex : companyname)
31
+	public $sLangue; // Langue - Language (Ex : FR, DE, EN, ..)
32
+	public $sUrlOK; // Url de retour OK - Return URL OK
33
+	public $sUrlKO; // Url de retour KO - Return URL KO
34
+	public $sUrlPaiement; // Url du serveur de paiement - Payment Server URL (Ex : https://paiement.creditmutuel.fr/paiement.cgi)
35 35
 
36
-	private $_sCle;		// La cl� - The Key
36
+	private $_sCle; // La cl� - The Key
37 37
 
38 38
 
39 39
 	// Constructeur / Constructor
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 		$this->sCodeSociete = CMCIC_CODESOCIETE;
53 53
 		$this->sLangue = $sLangue;
54 54
 
55
-		$this->sUrlOK = wpshop_payment::get_success_payment_url();;
56
-		$this->sUrlKO = wpshop_payment::get_cancel_payment_url();;
55
+		$this->sUrlOK = wpshop_payment::get_success_payment_url(); ;
56
+		$this->sUrlKO = wpshop_payment::get_cancel_payment_url(); ;
57 57
 
58 58
 	}
59 59
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 class CMCIC_Hmac {
99 99
 
100
-	private $_sUsableKey;	// La cl� du TPE en format op�rationnel / The usable TPE key
100
+	private $_sUsableKey; // La cl� du TPE en format op�rationnel / The usable TPE key
101 101
 
102 102
 	// ----------------------------------------------------------------------------
103 103
 	//
@@ -119,17 +119,17 @@  discard block
 block discarded – undo
119 119
 	//
120 120
 	// ----------------------------------------------------------------------------
121 121
 
122
-	private function _getUsableKey($oTpe){
122
+	private function _getUsableKey($oTpe) {
123 123
 
124 124
 		$hexStrKey  = substr($oTpe->getCle(), 0, 38);
125 125
 		$hexFinal   = "" . substr($oTpe->getCle(), 38, 2) . "00";
126 126
 
127
-		$cca0=ord($hexFinal);
127
+		$cca0 = ord($hexFinal);
128 128
 
129
-		if ($cca0>70 && $cca0<97)
130
-			$hexStrKey .= chr($cca0-23) . substr($hexFinal, 1, 1);
129
+		if ($cca0 > 70 && $cca0 < 97)
130
+			$hexStrKey .= chr($cca0 - 23) . substr($hexFinal, 1, 1);
131 131
 		else {
132
-			if (substr($hexFinal, 1, 1)=="M")
132
+			if (substr($hexFinal, 1, 1) == "M")
133 133
 				$hexStrKey .= substr($hexFinal, 0, 1) . "0";
134 134
 			else
135 135
 				$hexStrKey .= substr($hexFinal, 0, 2);
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 	//
171 171
 	// ----------------------------------------------------------------------------
172 172
 
173
-	public function hmac_sha1 ($key, $data) {
173
+	public function hmac_sha1($key, $data) {
174 174
 
175 175
 		$length = 64; // block length for SHA1
176
-		if (strlen($key) > $length) { $key = pack("H*",sha1($key)); }
176
+		if (strlen($key) > $length) { $key = pack("H*", sha1($key)); }
177 177
 		$key  = str_pad($key, $length, chr(0x00));
178 178
 		$ipad = str_pad('', $length, chr(0x36));
179 179
 		$opad = str_pad('', $length, chr(0x5c));
180
-		$k_ipad = $key ^ $ipad ;
180
+		$k_ipad = $key ^ $ipad;
181 181
 		$k_opad = $key ^ $opad;
182 182
 
183
-		return sha1($k_opad  . pack("H*",sha1($k_ipad . $data)));
183
+		return sha1($k_opad . pack("H*", sha1($k_ipad . $data)));
184 184
 	}
185 185
 
186 186
 }
@@ -196,17 +196,17 @@  discard block
 block discarded – undo
196 196
 //                           ********************
197 197
 //              Encodage des caract�res sp�ciaux au format HTML
198 198
 // ----------------------------------------------------------------------------
199
-function HtmlEncode ($data)
199
+function HtmlEncode($data)
200 200
 {
201 201
     $SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";
202 202
     $encoded_data = "";
203 203
     $result = "";
204
-    for ($i=0; $i<strlen($data); $i++)
204
+    for ($i = 0; $i < strlen($data); $i++)
205 205
     {
206 206
         if (strchr($SAFE_OUT_CHARS, $data{$i})) {
207 207
             $result .= $data{$i};
208 208
         }
209
-        else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
209
+        else if (($var = bin2hex(substr($data, $i, 1))) <= "7F") {
210 210
             $result .= "&#x" . $var . ";";
211 211
         }
212 212
         else
@@ -220,21 +220,21 @@  discard block
 block discarded – undo
220 220
 
221 221
 	public function __construct() {
222 222
 		global $wpshop;
223
-		$cic_option = get_option( 'wpshop_addons' );
224
-		if ( !empty($cic_option) && !empty($cic_option['WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC']) ) {
223
+		$cic_option = get_option('wpshop_addons');
224
+		if (!empty($cic_option) && !empty($cic_option['WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC'])) {
225 225
 			/** Check if SystemPay is registred in Payment Main Option **/
226
-			$payment_option = get_option( 'wps_payment_mode' );
227
-			if ( !empty($payment_option) && !empty($payment_option['mode']) && !array_key_exists('cic', $payment_option['mode']) ) {
226
+			$payment_option = get_option('wps_payment_mode');
227
+			if (!empty($payment_option) && !empty($payment_option['mode']) && !array_key_exists('cic', $payment_option['mode'])) {
228 228
 				$payment_option['mode']['cic']['name'] = __('CIC', 'wpshop');
229
-				$payment_option['mode']['cic']['logo'] = WPSHOP_TEMPLATES_URL.'wpshop/medias/cic_payment_logo.jpg';
229
+				$payment_option['mode']['cic']['logo'] = WPSHOP_TEMPLATES_URL . 'wpshop/medias/cic_payment_logo.jpg';
230 230
 				$payment_option['mode']['cic']['description'] = __('Reservation of products upon confirmation of payment.', 'wpshop');
231
-				update_option( 'wps_payment_mode', $payment_option );
231
+				update_option('wps_payment_mode', $payment_option);
232 232
 			}
233 233
 		}
234 234
 
235
-		$paymentListener = !empty( $_GET['paymentListener'] ) ? sanitize_text_field( $_GET['paymentListener'] ) : '';
235
+		$paymentListener = !empty($_GET['paymentListener']) ? sanitize_text_field($_GET['paymentListener']) : '';
236 236
 
237
-		if(!empty($paymentListener) && $paymentListener=='cic') {
237
+		if (!empty($paymentListener) && $paymentListener == 'cic') {
238 238
 			header("Pragma: no-cache");
239 239
 			header("Content-type: text/plain");
240 240
 			self::display_response();
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		if ($oHmac->computeHmac($cgi2_fields) == strtolower($CMCIC_bruteVars['MAC'])) {
279 279
 			wpshop_payment::save_payment_return_data($CMCIC_bruteVars['reference']);
280 280
 			$payment_status = 'denied';
281
-			switch($CMCIC_bruteVars['code-retour']) {
281
+			switch ($CMCIC_bruteVars['code-retour']) {
282 282
 				case "Annulation" :
283 283
 					// Attention : an autorization may still be delivered for this payment
284 284
 					//wpshop_payment::setOrderPaymentStatus($CMCIC_bruteVars['reference'], 'denied');
@@ -319,15 +319,15 @@  discard block
 block discarded – undo
319 319
 				break;
320 320
 			}
321 321
 
322
-			$order_meta = get_post_meta( $CMCIC_bruteVars['reference'], '_order_postmeta', true);
322
+			$order_meta = get_post_meta($CMCIC_bruteVars['reference'], '_order_postmeta', true);
323 323
 			$params_array = array(
324 324
 				'method' => 'cic',
325
-				'waited_amount' => number_format( (float)$order_meta['order_amount_to_pay_now'], 2, '.', ''),
326
-				'status' => (($payment_status == 'completed') ? ( ( number_format( (float)$order_meta['order_amount_to_pay_now'], 2, '.', '') == number_format( (float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '' ) ) ? 'payment_received' : 'incorrect_amount' ) : $payment_status),
325
+				'waited_amount' => number_format((float)$order_meta['order_amount_to_pay_now'], 2, '.', ''),
326
+				'status' => (($payment_status == 'completed') ? ((number_format((float)$order_meta['order_amount_to_pay_now'], 2, '.', '') == number_format((float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '')) ? 'payment_received' : 'incorrect_amount') : $payment_status),
327 327
 				'author' => $order_meta['customer_id'],
328 328
 				'payment_reference' => $CMCIC_bruteVars['numauto'],
329 329
 				'date' => current_time('mysql', 0),
330
-				'received_amount' => number_format( (float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '' )
330
+				'received_amount' => number_format((float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '')
331 331
 			);
332 332
 			wpshop_payment::check_order_payment_total_amount($CMCIC_bruteVars['reference'], $params_array, $payment_status);
333 333
 
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 		}
336 336
 		else {
337 337
 			// your code if the HMAC doesn't match
338
-			$receipt = CMCIC_CGI2_MACNOTOK.$cgi2_fields;
338
+			$receipt = CMCIC_CGI2_MACNOTOK . $cgi2_fields;
339 339
 		}
340 340
 
341 341
 		// Send receipt to CMCIC server
342
-		printf (CMCIC_CGI2_RECEIPT, $receipt);
342
+		printf(CMCIC_CGI2_RECEIPT, $receipt);
343 343
 	}
344 344
 
345 345
 	public static function display_form($oid) {
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
 		$order_customer_info = get_post_meta($oid, '_order_info', true);
350 350
 		//$currency_code = wpshop_tools::wpshop_get_currency($code=true);
351 351
 		$current_currency = get_option('wpshop_shop_default_currency');
352
-		$query = $wpdb->prepare('SELECT code_iso FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id =%d ', $current_currency );
353
-		$currency_code = $wpdb->get_var( $query );
352
+		$query = $wpdb->prepare('SELECT code_iso FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id =%d ', $current_currency);
353
+		$currency_code = $wpdb->get_var($query);
354 354
 
355
-		if(!empty($order) && !empty($currency_code)) {
355
+		if (!empty($order) && !empty($currency_code)) {
356 356
 
357 357
 			$sOptions = "";
358 358
 			// ----------------------------------------------------------------------------
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
 			//  That's your job to set actual order fields. Here is a stub.
361 361
 			// -----------------------------------------------------------------------------
362 362
 			$sReference = $oid; // Reference: unique, alphaNum (A-Z a-z 0-9), 12 characters max
363
-			$sMontant = number_format($order['order_grand_total'],2,'.',''); // Amount : format  "xxxxx.yy" (no spaces)
363
+			$sMontant = number_format($order['order_grand_total'], 2, '.', ''); // Amount : format  "xxxxx.yy" (no spaces)
364 364
 			$sDevise  = $currency_code; // Currency : ISO 4217 compliant
365 365
 			$sTexteLibre = ""; // free texte : a bigger reference, session context for the return on the merchant website
366 366
 			$sDate = date("d/m/Y:H:i:s"); // transaction date : format d/m/y:h:m:s
367 367
 			$sLangue = "FR"; // Language of the company code
368
-			$sEmail = $order_customer_info['billing']['address']['address_user_email'];//"[email protected]"; // customer email
368
+			$sEmail = $order_customer_info['billing']['address']['address_user_email']; //"[email protected]"; // customer email
369 369
 			///////////////////////////////////////////////////////////////////////////////////////////
370 370
 			$sNbrEch = ""; //$sNbrEch = "4"; // between 2 and 4
371 371
 			$sDateEcheance1 = ""; // date echeance 1 - format dd/mm/yyyy //$sDateEcheance1 = date("d/m/Y");
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			$CtlHmac = sprintf(CMCIC_CTLHMAC, $oTpe->sVersion, $oTpe->sNumero, $oHmac->computeHmac(sprintf(CMCIC_CTLHMACSTR, $oTpe->sVersion, $oTpe->sNumero)));
387 387
 
388 388
 			// Data to certify
389
-			$PHP1_FIELDS = sprintf(CMCIC_CGI1_FIELDS,     $oTpe->sNumero,
389
+			$PHP1_FIELDS = sprintf(CMCIC_CGI1_FIELDS, $oTpe->sNumero,
390 390
 															$sDate,
391 391
 															$sMontant,
392 392
 															$sDevise,
@@ -413,30 +413,30 @@  discard block
 block discarded – undo
413 413
 		?>
414 414
 		<script type="text/javascript">jQuery(document).ready(function(){ jQuery('#PaymentRequest_cic').submit(); });</script>
415 415
 		<div class="paypalPaymentLoading"><span><?php _e('Redirect to the CIC site in progress, please wait...', 'wpshop'); ?></span></div>
416
-		<form action="<?php echo $oTpe->sUrlPaiement;?>" method="post" id="PaymentRequest_cic">
417
-			<input type="hidden" name="version"             id="version"        value="<?php echo $oTpe->sVersion;?>" />
418
-			<input type="hidden" name="TPE"                 id="TPE"            value="<?php echo $oTpe->sNumero;?>" />
419
-			<input type="hidden" name="date"                id="date"           value="<?php echo $sDate;?>" />
420
-			<input type="hidden" name="montant"             id="montant"        value="<?php echo $sMontant . $sDevise;?>" />
421
-			<input type="hidden" name="reference"           id="reference"      value="<?php echo $sReference;?>" />
422
-			<input type="hidden" name="MAC"                 id="MAC"            value="<?php echo $sMAC;?>" />
423
-			<input type="hidden" name="url_retour"          id="url_retour"     value="<?php echo $oTpe->sUrlKO;?>" />
424
-			<input type="hidden" name="url_retour_ok"       id="url_retour_ok"  value="<?php echo $oTpe->sUrlOK;?>" />
425
-			<input type="hidden" name="url_retour_err"      id="url_retour_err" value="<?php echo $oTpe->sUrlKO;?>" />
426
-			<input type="hidden" name="lgue"                id="lgue"           value="<?php echo $oTpe->sLangue;?>" />
427
-			<input type="hidden" name="societe"             id="societe"        value="<?php echo $oTpe->sCodeSociete;?>" />
428
-			<input type="hidden" name="texte-libre"         id="texte-libre"    value="<?php echo HtmlEncode($sTexteLibre);?>" />
429
-			<input type="hidden" name="mail"                id="mail"           value="<?php echo $sEmail;?>" />
416
+		<form action="<?php echo $oTpe->sUrlPaiement; ?>" method="post" id="PaymentRequest_cic">
417
+			<input type="hidden" name="version"             id="version"        value="<?php echo $oTpe->sVersion; ?>" />
418
+			<input type="hidden" name="TPE"                 id="TPE"            value="<?php echo $oTpe->sNumero; ?>" />
419
+			<input type="hidden" name="date"                id="date"           value="<?php echo $sDate; ?>" />
420
+			<input type="hidden" name="montant"             id="montant"        value="<?php echo $sMontant . $sDevise; ?>" />
421
+			<input type="hidden" name="reference"           id="reference"      value="<?php echo $sReference; ?>" />
422
+			<input type="hidden" name="MAC"                 id="MAC"            value="<?php echo $sMAC; ?>" />
423
+			<input type="hidden" name="url_retour"          id="url_retour"     value="<?php echo $oTpe->sUrlKO; ?>" />
424
+			<input type="hidden" name="url_retour_ok"       id="url_retour_ok"  value="<?php echo $oTpe->sUrlOK; ?>" />
425
+			<input type="hidden" name="url_retour_err"      id="url_retour_err" value="<?php echo $oTpe->sUrlKO; ?>" />
426
+			<input type="hidden" name="lgue"                id="lgue"           value="<?php echo $oTpe->sLangue; ?>" />
427
+			<input type="hidden" name="societe"             id="societe"        value="<?php echo $oTpe->sCodeSociete; ?>" />
428
+			<input type="hidden" name="texte-libre"         id="texte-libre"    value="<?php echo HtmlEncode($sTexteLibre); ?>" />
429
+			<input type="hidden" name="mail"                id="mail"           value="<?php echo $sEmail; ?>" />
430 430
 			<!-- Uniquement pour le Paiement fractionn� -->
431
-			<input type="hidden" name="nbrech"              id="nbrech"         value="<?php echo $sNbrEch;?>" />
432
-			<input type="hidden" name="dateech1"            id="dateech1"       value="<?php echo $sDateEcheance1;?>" />
433
-			<input type="hidden" name="montantech1"         id="montantech1"    value="<?php echo $sMontantEcheance1;?>" />
434
-			<input type="hidden" name="dateech2"            id="dateech2"       value="<?php echo $sDateEcheance2;?>" />
435
-			<input type="hidden" name="montantech2"         id="montantech2"    value="<?php echo $sMontantEcheance2;?>" />
436
-			<input type="hidden" name="dateech3"            id="dateech3"       value="<?php echo $sDateEcheance3;?>" />
437
-			<input type="hidden" name="montantech3"         id="montantech3"    value="<?php echo $sMontantEcheance3;?>" />
438
-			<input type="hidden" name="dateech4"            id="dateech4"       value="<?php echo $sDateEcheance4;?>" />
439
-			<input type="hidden" name="montantech4"         id="montantech4"    value="<?php echo $sMontantEcheance4;?>" />
431
+			<input type="hidden" name="nbrech"              id="nbrech"         value="<?php echo $sNbrEch; ?>" />
432
+			<input type="hidden" name="dateech1"            id="dateech1"       value="<?php echo $sDateEcheance1; ?>" />
433
+			<input type="hidden" name="montantech1"         id="montantech1"    value="<?php echo $sMontantEcheance1; ?>" />
434
+			<input type="hidden" name="dateech2"            id="dateech2"       value="<?php echo $sDateEcheance2; ?>" />
435
+			<input type="hidden" name="montantech2"         id="montantech2"    value="<?php echo $sMontantEcheance2; ?>" />
436
+			<input type="hidden" name="dateech3"            id="dateech3"       value="<?php echo $sDateEcheance3; ?>" />
437
+			<input type="hidden" name="montantech3"         id="montantech3"    value="<?php echo $sMontantEcheance3; ?>" />
438
+			<input type="hidden" name="dateech4"            id="dateech4"       value="<?php echo $sDateEcheance4; ?>" />
439
+			<input type="hidden" name="montantech4"         id="montantech4"    value="<?php echo $sMontantEcheance4; ?>" />
440 440
 			<!-- -->
441 441
 			<noscript><input type="submit" name="bouton"              id="bouton"         value="Connexion / Connection" /></noscript>
442 442
 		</form>
@@ -448,16 +448,16 @@  discard block
 block discarded – undo
448 448
 	}
449 449
 
450 450
 
451
-	function display_admin_part( $k ) {
451
+	function display_admin_part($k) {
452 452
 		$cmcic_params = get_option('wpshop_cmcic_params', array());
453 453
 		$output = '';
454
-		$output .= '<h2>' .__('CIC configurations', 'wpshop'). '</h2>';
454
+		$output .= '<h2>' . __('CIC configurations', 'wpshop') . '</h2>';
455 455
 		$output .= '<div class="wps_shipping_mode_configuration_part">';
456
-		$output .= '<label class="simple_right">'.__('Key', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[cle]" type="text" value="'.$cmcic_params['cle'].'" /><br />';
457
-		$output .= '<label class="simple_right">'.__('TPE', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[tpe]" type="text" value="'.$cmcic_params['tpe'].'" /><br />';
458
-		$output .= '<label class="simple_right">'.__('Version', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[version]" type="text" value="'.$cmcic_params['version'].'" /> => 3.0<br />';
459
-		$output .= '<label class="simple_right">'.__('Serveur', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[serveur]" type="text" value="'.$cmcic_params['serveur'].'" /><br />';
460
-		$output .= '<label class="simple_right">'.__('Company code', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[codesociete]" type="text" value="'.$cmcic_params['codesociete'].'" /><br />';
456
+		$output .= '<label class="simple_right">' . __('Key', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[cle]" type="text" value="' . $cmcic_params['cle'] . '" /><br />';
457
+		$output .= '<label class="simple_right">' . __('TPE', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[tpe]" type="text" value="' . $cmcic_params['tpe'] . '" /><br />';
458
+		$output .= '<label class="simple_right">' . __('Version', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[version]" type="text" value="' . $cmcic_params['version'] . '" /> => 3.0<br />';
459
+		$output .= '<label class="simple_right">' . __('Serveur', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[serveur]" type="text" value="' . $cmcic_params['serveur'] . '" /><br />';
460
+		$output .= '<label class="simple_right">' . __('Company code', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[codesociete]" type="text" value="' . $cmcic_params['codesociete'] . '" /><br />';
461 461
 		$output .= '</div>';
462 462
 
463 463
 		return $output;
Please login to merge, or discard this patch.
includes/librairies/payments/payment.class.php 4 patches
Doc Comments   +7 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,6 +38,10 @@  discard block
 block discarded – undo
38 38
 		return $url;
39 39
 	}
40 40
 
41
+	/**
42
+	 * @param string $param
43
+	 * @param string $value
44
+	 */
41 45
 	public static function construct_url_parameters($url, $param, $value) {
42 46
 		$interoguation_marker_pos = strpos($url, '?');
43 47
 		if($interoguation_marker_pos===false)
@@ -86,7 +90,7 @@  discard block
 block discarded – undo
86 90
 	 * Display the list of payment methods available
87 91
 	 *
88 92
 	 * @param integer $order_id The order id if existing - Useful when user does not finish its order and want to validateit later
89
-	 * @return string The different payment method
93
+	 * @return string[] The different payment method
90 94
 	 */
91 95
 	function __display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') {
92 96
 		$output = '';
@@ -377,7 +381,7 @@  discard block
 block discarded – undo
377 381
 	 * Allows to inform customer that he would pay a partial amount on this order
378 382
 	 *
379 383
 	 * @param float $current_order_total The current order total to pay before partial amount calcul
380
-	 * @return array The amount to pay / A html output with amount to pay and different information
384
+	 * @return string The amount to pay / A html output with amount to pay and different information
381 385
 	 */
382 386
 	function partial_payment_calcul( $current_order_total, $for = 'for_all' ) {
383 387
 		$output = '';
@@ -482,6 +486,7 @@  discard block
 block discarded – undo
482 486
 	 * @param array $order_meta The complete order meta informations
483 487
 	 * @param integer $payment_index The payment to add/update data for
484 488
 	 * @param array $params : infos sended by the bank, array structure : ('method', 'waited amount', 'status', 'author', 'payment reference', 'date', 'received amount')
489
+	 * @param integer $order_id
485 490
 	 * @return array The order new meta informations
486 491
 	 */
487 492
 	public static function add_new_payment_to_order( $order_id, $order_meta, $payment_index, $params, $bank_response ) {
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 
219 219
 
220 220
 	/**
221
-	* Reduce the stock regarding the order
222
-	*/
221
+	 * Reduce the stock regarding the order
222
+	 */
223 223
 	function the_order_payment_is_completed($order_id, $txn_id = null) {
224 224
 		// Donnees commandes
225 225
 		$order = get_post_meta($order_id, '_order_postmeta', true);
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
 	}
294 294
 
295 295
 	/**
296
-	* Get payment method
297
-	*/
296
+	 * Get payment method
297
+	 */
298 298
 	function get_payment_method($post_id){
299 299
 		$pm = __('Nc','wpshop');
300 300
 		$order_postmeta = get_post_meta($post_id, '_order_postmeta', true);
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
 	}
322 322
 
323 323
 	/**
324
-	* Set payment transaction number
325
-	*/
324
+	 * Set payment transaction number
325
+	 */
326 326
 	function display_payment_receiver_interface($post_id) {
327 327
 		$payment_validation = '';
328 328
 		$display_button = false;
Please login to merge, or discard this patch.
Braces   +13 added lines, -14 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' ) ) {
@@ -40,9 +42,11 @@  discard block
 block discarded – undo
40 42
 
41 43
 	public static function construct_url_parameters($url, $param, $value) {
42 44
 		$interoguation_marker_pos = strpos($url, '?');
43
-		if($interoguation_marker_pos===false)
44
-			return $url.'?'.$param.'='.$value;
45
-		else return $url.'&'.$param.'='.$value;
45
+		if($interoguation_marker_pos===false) {
46
+					return $url.'?'.$param.'='.$value;
47
+		} else {
48
+			return $url.'&'.$param.'='.$value;
49
+		}
46 50
 	}
47 51
 
48 52
 	/**
@@ -167,8 +171,7 @@  discard block
 block discarded – undo
167 171
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier;
168 172
 					if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) {
169 173
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : '';
170
-					}
171
-					else {
174
+					} else {
172 175
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : '';
173 176
 					}
174 177
 					//$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon'];
@@ -200,8 +203,7 @@  discard block
 block discarded – undo
200 203
 
201 204
 						if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) {
202 205
 							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : '';
203
-						}
204
-						else {
206
+						} else {
205 207
 							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : '';
206 208
 						}
207 209
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : '';
@@ -629,8 +631,7 @@  discard block
 block discarded – undo
629 631
 					if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) {
630 632
 						$payment_status = 'pos';
631 633
 					}
632
-				}
633
-				else {
634
+				} else {
634 635
 					$payment_status = 'partially_paid';
635 636
 				}
636 637
 
@@ -655,16 +656,14 @@  discard block
 block discarded – undo
655 656
 				}
656 657
 
657 658
 				$wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file);
658
-			}
659
-			else {
659
+			} else {
660 660
 				$payment_status = $bank_response;
661 661
 			}
662 662
 
663 663
 			$order_meta['order_status'] = $payment_status;
664 664
 			if( !$save_metadata ) {
665 665
 				return 	$order_meta;
666
-			}
667
-			else {
666
+			} else {
668 667
 				update_post_meta( $order_id, '_order_postmeta', $order_meta);
669 668
 			}
670 669
 			update_post_meta( $order_id, '_wpshop_order_status', $payment_status);
Please login to merge, or discard this patch.
Spacing   +192 added lines, -192 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,29 +20,29 @@  discard block
 block discarded – undo
20 20
 
21 21
 		$wpshop_paypal = new wpshop_paypal();
22 22
 		// If the CIC payment method is active
23
-		$wpshop_paymentMethod = get_option( 'wps_payment_mode' );
24
-		if(WPSHOP_PAYMENT_METHOD_CIC && ( !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']) ) ) {
23
+		$wpshop_paymentMethod = get_option('wps_payment_mode');
24
+		if (WPSHOP_PAYMENT_METHOD_CIC && (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']))) {
25 25
 			$wpshop_cic = new wpshop_CIC();
26 26
 		}
27
-		wpshop_tools::create_custom_hook ('wpshop_bankserver_reponse');
27
+		wpshop_tools::create_custom_hook('wpshop_bankserver_reponse');
28 28
 
29 29
 	}
30 30
 
31 31
 	public static function get_success_payment_url() {
32
-		$url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_page_id') ) );
32
+		$url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_page_id')));
33 33
 		return self::construct_url_parameters($url, 'paymentResult', 'success');
34 34
 	}
35 35
 
36 36
 	public static function get_cancel_payment_url() {
37
-		$url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_nok_page_id') ) );
37
+		$url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_nok_page_id')));
38 38
 		return $url;
39 39
 	}
40 40
 
41 41
 	public static function construct_url_parameters($url, $param, $value) {
42 42
 		$interoguation_marker_pos = strpos($url, '?');
43
-		if($interoguation_marker_pos===false)
44
-			return $url.'?'.$param.'='.$value;
45
-		else return $url.'&'.$param.'='.$value;
43
+		if ($interoguation_marker_pos === false)
44
+			return $url . '?' . $param . '=' . $value;
45
+		else return $url . '&' . $param . '=' . $value;
46 46
 	}
47 47
 
48 48
 	/**
@@ -51,23 +51,23 @@  discard block
 block discarded – undo
51 51
 	public static function wpshop_payment_result() {
52 52
 		global $wpdb;
53 53
 		$user_ID = get_current_user_id();
54
-		$query = $wpdb->prepare('SELECT MAX(ID) FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID);
55
-		$order_post_id = $wpdb->get_var( $query );
56
-		if ( !empty($order_post_id) ) {
57
-			$order_postmeta = get_post_meta($order_post_id , '_wpshop_order_status', true);
58
-			if ( !empty($order_postmeta) ) {
59
-				switch ( $order_postmeta ) {
54
+		$query = $wpdb->prepare('SELECT MAX(ID) FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID);
55
+		$order_post_id = $wpdb->get_var($query);
56
+		if (!empty($order_post_id)) {
57
+			$order_postmeta = get_post_meta($order_post_id, '_wpshop_order_status', true);
58
+			if (!empty($order_postmeta)) {
59
+				switch ($order_postmeta) {
60 60
 					case 'awaiting_payment':
61
-						echo __('We wait your payment.','wpshop');
61
+						echo __('We wait your payment.', 'wpshop');
62 62
 					break;
63 63
 					case 'completed':
64
-						echo __('Thank you ! Your payment has been recorded.','wpshop');
64
+						echo __('Thank you ! Your payment has been recorded.', 'wpshop');
65 65
 					break;
66 66
 					case 'partially_paid':
67
-						echo __('Thank you ! Your first payment has been recorded.','wpshop');
67
+						echo __('Thank you ! Your first payment has been recorded.', 'wpshop');
68 68
 					break;
69 69
 					default:
70
-						echo __('Your payment and your order has been cancelled.','wpshop');
70
+						echo __('Your payment and your order has been cancelled.', 'wpshop');
71 71
 					break;
72 72
 				}
73 73
 			}
@@ -88,56 +88,56 @@  discard block
 block discarded – undo
88 88
 	 * @param integer $order_id The order id if existing - Useful when user does not finish its order and want to validateit later
89 89
 	 * @return string The different payment method
90 90
 	 */
91
-	function __display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') {
91
+	function __display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') {
92 92
 		$output = '';
93 93
 		/**	Get available payment method	*/
94 94
 		$paymentMethod = get_option('wpshop_paymentMethod', array());
95 95
 
96
-		if(!empty($order_id) && is_numeric($order_id)) {
97
-			$output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />';
96
+		if (!empty($order_id) && is_numeric($order_id)) {
97
+			$output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />';
98 98
 		}
99 99
 
100 100
 		if ($cart_type == 'cart') {
101 101
 			$payment_methods = array();
102
-			if(!empty($paymentMethod['paypal'])) {
102
+			if (!empty($paymentMethod['paypal'])) {
103 103
 				$payment_methods['paypal'] = array('payment_method_name' => __('CB with Paypal', 'wpshop'),
104 104
 														'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/paypal.png',
105
-														'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.','wpshop')
105
+														'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.', 'wpshop')
106 106
 								 );
107 107
 			}
108
-			if(!empty($paymentMethod['checks'])) {
108
+			if (!empty($paymentMethod['checks'])) {
109 109
 				$payment_methods['check'] = array('payment_method_name' => __('Check', 'wpshop'),
110 110
 						'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png',
111
-						'payment_method_explanation' => __('Reservation of products upon receipt of the check.','wpshop')
111
+						'payment_method_explanation' => __('Reservation of products upon receipt of the check.', 'wpshop')
112 112
 				);
113 113
 			}
114
-			if(!empty($paymentMethod['banktransfer'])) {
114
+			if (!empty($paymentMethod['banktransfer'])) {
115 115
 				$payment_methods['banktransfer'] = array('payment_method_name' => __('Bank transfer', 'wpshop'),
116 116
 						'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png',
117
-						'payment_method_explanation' =>__('Reservation of product receipt of payment.','wpshop')
117
+						'payment_method_explanation' =>__('Reservation of product receipt of payment.', 'wpshop')
118 118
 				);
119 119
 			}
120
-			if(WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) {
120
+			if (WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) {
121 121
 				$payment_methods['cic'] = array('payment_method_name' =>__('Credit card', 'wpshop'),
122 122
 						'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cic_payment_logo.jpg',
123
-						'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.','wpshop')
123
+						'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.', 'wpshop')
124 124
 				);
125 125
 			}
126 126
 			$payment_methods = apply_filters('wpshop_payment_method', $payment_methods);
127 127
 
128 128
 			$payment_method_table = array();
129 129
 
130
-			if ( !empty( $paymentMethod['display_position'] ) ) {
130
+			if (!empty($paymentMethod['display_position'])) {
131 131
 				$position_determinated = false;
132
-				foreach ( $paymentMethod['display_position'] as $key => $position) {
133
-					if ( $position != null) {
132
+				foreach ($paymentMethod['display_position'] as $key => $position) {
133
+					if ($position != null) {
134 134
 						$position_determinated = true;
135 135
 					}
136 136
 				}
137
-				if ( $position_determinated ) {
138
-					for ( $i = 1; $i < count( $paymentMethod['display_position'] ) + 1; $i++) {
139
-						foreach ( $paymentMethod['display_position'] as $key => $position ) {
140
-							if ( $position == $i  && !empty($paymentMethod[$key])) {
137
+				if ($position_determinated) {
138
+					for ($i = 1; $i < count($paymentMethod['display_position']) + 1; $i++) {
139
+						foreach ($paymentMethod['display_position'] as $key => $position) {
140
+							if ($position == $i && !empty($paymentMethod[$key])) {
141 141
 								if ($key == 'checks') {
142 142
 									$key = 'check';
143 143
 								}
@@ -148,16 +148,16 @@  discard block
 block discarded – undo
148 148
 					$payment_methods = $payment_method_table;
149 149
 				}
150 150
 			}
151
-			if (!empty($payment_methods) ) {
151
+			if (!empty($payment_methods)) {
152 152
 
153
-				foreach( $payment_methods as  $payment_method_identifier =>  $payment_method_def ) {
153
+				foreach ($payment_methods as  $payment_method_identifier =>  $payment_method_def) {
154 154
 					$tpl_component = array();
155 155
 					$checked = $active = '';
156 156
 					$payment_identifier_for_test = $payment_method_identifier;
157 157
 					if ($payment_method_identifier == 'check') {
158 158
 						$payment_identifier_for_test = 'checks';
159 159
 					}
160
-					if ( !empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) {
160
+					if (!empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) {
161 161
 						$checked = ' checked="checked"';
162 162
 						$active = ' active';
163 163
 
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = $active;
166 166
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = $checked;
167 167
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier;
168
-					if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) {
169
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : '';
168
+					if (!empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0) {
169
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? wp_get_attachment_image($payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo')) : '';
170 170
 					}
171 171
 					else {
172
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : '';
172
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? '<img src="' . $payment_method_def['payment_method_icon'] . '" alt="" />' : '';
173 173
 					}
174 174
 					//$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon'];
175 175
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = $payment_method_def['payment_method_name'];
@@ -180,32 +180,32 @@  discard block
 block discarded – undo
180 180
 			}
181 181
 		}
182 182
 
183
-		return array( $output, $paymentMethod['mode'] );
183
+		return array($output, $paymentMethod['mode']);
184 184
 	}
185 185
 
186 186
 
187
-	public static function display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') {
188
-		$payment_option = get_option( 'wps_payment_mode' );
187
+	public static function display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') {
188
+		$payment_option = get_option('wps_payment_mode');
189 189
 		$output = '';
190
-		if(!empty($order_id) && is_numeric($order_id)) {
191
-			$output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />';
190
+		if (!empty($order_id) && is_numeric($order_id)) {
191
+			$output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />';
192 192
 		}
193
-		if( $cart_type == 'cart' ) {
194
-			if ( !empty($payment_option) && !empty($payment_option['mode']) ) {
195
-				foreach( $payment_option['mode'] as $payment_id => $payment_config ) {
196
-					if( !empty($payment_config['active']) ) {
197
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? ' active' : '');
198
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? 'checked="checked"' : '');
193
+		if ($cart_type == 'cart') {
194
+			if (!empty($payment_option) && !empty($payment_option['mode'])) {
195
+				foreach ($payment_option['mode'] as $payment_id => $payment_config) {
196
+					if (!empty($payment_config['active'])) {
197
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? ' active' : '');
198
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? 'checked="checked"' : '');
199 199
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_id;
200 200
 
201
-						if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) {
202
-							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : '';
201
+						if (!empty($payment_config['logo']) && (int)$payment_config['logo'] != 0) {
202
+							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? wp_get_attachment_image($payment_config['logo'], 'thumbnail', false) : '';
203 203
 						}
204 204
 						else {
205
-							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : '';
205
+							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? '<img src="' . $payment_config['logo'] . '" alt="' . $payment_config['name'] . '" />' : '';
206 206
 						}
207
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : '';
208
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = ( !empty($payment_config['description']) ) ? $payment_config['description'] : '';
207
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = (!empty($payment_config['name'])) ? $payment_config['name'] : '';
208
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = (!empty($payment_config['description'])) ? $payment_config['description'] : '';
209 209
 						$output .= wpshop_display::display_template_element('wpshop_checkout_page_payment_method_bloc', $tpl_component, array('type' => 'payment_method', 'id' => $payment_id));
210 210
 						unset($tpl_component);
211 211
 					}
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
 
228 228
 		$wps_message = new wps_message_ctr();
229 229
 
230
-		if(!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) {
231
-			$email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '' );
232
-			$first_name = ( !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' );
233
-			$last_name = ( !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' );
230
+		if (!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) {
231
+			$email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '');
232
+			$first_name = (!empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
233
+			$last_name = (!empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
234 234
 
235 235
 			// Envoie du message de confirmation de paiement au client
236
-			switch($order['payment_method']) {
236
+			switch ($order['payment_method']) {
237 237
 				case 'check':
238 238
 					$wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date']));
239 239
 				break;
@@ -250,24 +250,24 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 
252 252
 
253
-	function setOrderPaymentStatus( $order_id, $payment_status ) {
253
+	function setOrderPaymentStatus($order_id, $payment_status) {
254 254
 		/**	Get order main information	*/
255 255
 		$order = get_post_meta($order_id, '_order_postmeta', true);
256 256
 		$send_email = false;
257 257
 
258
-		if ( !empty($order) ) {
258
+		if (!empty($order)) {
259 259
 			/**	Change order status to given status	*/
260 260
 			$order['order_status'] = strtolower($payment_status);
261 261
 			/**	Put order status into a single meta, allowing to use it easily later	*/
262 262
 			update_post_meta($order_id, '_wpshop_order_status', $order['order_status']);
263 263
 
264 264
 			/**	In case the set status is completed, make specific treatment: add the completed date	*/
265
-			if ( $payment_status == 'completed' ) {
265
+			if ($payment_status == 'completed') {
266 266
 				/**	Read order items list, if not empty and check if each item is set to manage stock or not */
267 267
 				if (!empty($order['order_items'])) {
268 268
 					foreach ($order['order_items'] as $o) {
269
-						$product = wpshop_products::get_product_data( $o['item_id'] );
270
-						if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop') ) {
269
+						$product = wpshop_products::get_product_data($o['item_id']);
270
+						if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop')) {
271 271
 							wpshop_products::reduce_product_stock_qty($o['item_id'], $o['item_qty']);
272 272
 						}
273 273
 					}
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			}
282 282
 
283 283
 			/**	Send email to customer when specific case need it	*/
284
-			if ( $send_email ) {
284
+			if ($send_email) {
285 285
 				/**	Get information about customer that make the order	*/
286 286
 				$order_info = get_post_meta($order_id, '_order_info', true);
287 287
 				$mail_tpl_component = array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date']);
@@ -295,25 +295,25 @@  discard block
 block discarded – undo
295 295
 	/**
296 296
 	* Get payment method
297 297
 	*/
298
-	function get_payment_method($post_id){
299
-		$pm = __('Nc','wpshop');
298
+	function get_payment_method($post_id) {
299
+		$pm = __('Nc', 'wpshop');
300 300
 		$order_postmeta = get_post_meta($post_id, '_order_postmeta', true);
301
-		if ( !empty($order_postmeta['payment_method']) ) {
302
-			switch($order_postmeta['payment_method']){
301
+		if (!empty($order_postmeta['payment_method'])) {
302
+			switch ($order_postmeta['payment_method']) {
303 303
 				case 'check':
304
-					$pm = __('Check','wpshop');
304
+					$pm = __('Check', 'wpshop');
305 305
 				break;
306 306
 				case 'paypal':
307
-					$pm = __('Paypal','wpshop');
307
+					$pm = __('Paypal', 'wpshop');
308 308
 				break;
309 309
 				case 'banktransfer':
310
-					$pm = __('Bank transfer','wpshop');
310
+					$pm = __('Bank transfer', 'wpshop');
311 311
 				break;
312 312
 				case 'cic':
313
-					$pm = __('Credit card','wpshop');
313
+					$pm = __('Credit card', 'wpshop');
314 314
 				break;
315 315
 				default:
316
-					$pm = __('Nc','wpshop');
316
+					$pm = __('Nc', 'wpshop');
317 317
 				break;
318 318
 			}
319 319
 		}
@@ -333,38 +333,38 @@  discard block
 block discarded – undo
333 333
 
334 334
 		$paymentMethod = $paymentMethod['mode'];
335 335
 		$payment_validation .= '
336
-<div id="order_payment_method_'.$post_id.'" class="wpshop_cls wpshopHide" >
337
-	<input type="hidden" id="used_method_payment_'.$post_id.'" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/>
338
-	<input type="hidden" id="used_method_payment_transaction_id_'.$post_id.'" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>';
336
+<div id="order_payment_method_'.$post_id . '" class="wpshop_cls wpshopHide" >
337
+	<input type="hidden" id="used_method_payment_'.$post_id . '" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/>
338
+	<input type="hidden" id="used_method_payment_transaction_id_'.$post_id . '" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>';
339 339
 
340
-		if(!empty($order_postmeta['payment_method'])){
340
+		if (!empty($order_postmeta['payment_method'])) {
341 341
 			$payment_validation .= sprintf(__('Selected payment method: %s', 'wpshop'), __($order_postmeta['payment_method'], 'wpshop')) . '<br/>';
342 342
 		}
343 343
 
344
-		if(!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) {
344
+		if (!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) {
345 345
 			$payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="paypal" id="payment_method_paypal" /><label for="payment_method_paypal" >' . __('Paypal', 'wpshop') . '</label><br/>';
346 346
 			$display_button = true;
347 347
 		}
348 348
 
349
-		if(!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) {
349
+		if (!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) {
350 350
 			$payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="check" id="payment_method_check" /><label for="payment_method_check" >' . __('Check', 'wpshop') . '</label><br/>';
351 351
 			$display_button = true;
352 352
 		}
353 353
 
354
-		$wpshop_paymentMethod = get_option( 'wps_payment_mode' );
355
-		if((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic'])) ) && empty($order_postmeta['payment_method'])) {
354
+		$wpshop_paymentMethod = get_option('wps_payment_mode');
355
+		if ((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']))) && empty($order_postmeta['payment_method'])) {
356 356
 			$payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="cb" id="payment_method_cb" /><label for="payment_method_cb" >' . __('Credit card', 'wpshop') . '</label><br/>';
357 357
 			$display_button = true;
358 358
 		}
359 359
 
360
-		if(empty($payment_transaction)){
361
-			$payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . '&nbsp;:&nbsp;<input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_'.$post_id.'" />';
360
+		if (empty($payment_transaction)) {
361
+			$payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . '&nbsp;:&nbsp;<input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_' . $post_id . '" />';
362 362
 			$display_button = true;
363 363
 		}
364 364
 
365
-		if($display_button){
365
+		if ($display_button) {
366 366
 			$payment_validation .= '
367
-		<br/><br/><a class="button payment_method_validate order_'.$post_id.' wpshop_clear" >'.__('Validate payment method', 'wpshop').'</a>';
367
+		<br/><br/><a class="button payment_method_validate order_'.$post_id . ' wpshop_clear" >' . __('Validate payment method', 'wpshop') . '</a>';
368 368
 		}
369 369
 
370 370
 		$payment_validation .= '
@@ -379,21 +379,21 @@  discard block
 block discarded – undo
379 379
 	 * @param float $current_order_total The current order total to pay before partial amount calcul
380 380
 	 * @return array The amount to pay / A html output with amount to pay and different information
381 381
 	 */
382
-	function partial_payment_calcul( $current_order_total, $for = 'for_all' ) {
382
+	function partial_payment_calcul($current_order_total, $for = 'for_all') {
383 383
 		$output = '';
384 384
 		$tpl_component = array();
385 385
 
386 386
 		/**	Get current configuration	*/
387 387
 		$partial_payment_configuration = get_option('wpshop_payment_partial', array($for => array(), 'for_quotation' => array()));
388
-		if ( !empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on') ) {
388
+		if (!empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on')) {
389 389
 			$amount_of_partial_payment = 0;
390
-			if ( !empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate']) ) {
390
+			if (!empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate'])) {
391 391
 				$amount_of_partial_payment = $partial_payment_configuration[$for]['value'];
392 392
 			}
393 393
 
394 394
 			$partial_amount_to_pay = 0;
395 395
 			$type_of_partial_payment = null;
396
-			if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type']) ) {
396
+			if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type'])) {
397 397
 				switch ($partial_payment_configuration[$for]['type']) {
398 398
 					case 'percentage':
399 399
 						$type_of_partial_payment = '%';
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	function set_payment_transaction_number($order_id, $transaction_number) {
454 454
 		$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
455 455
 
456
-		if ( !empty($order_postmeta['order_payment']['received']) ) {
456
+		if (!empty($order_postmeta['order_payment']['received'])) {
457 457
 			if (count($order_postmeta['order_payment']['received']) == 1) {
458 458
 				$order_postmeta['order_payment']['received'][0]['payment_reference'] = $transaction_number;
459 459
 			}
@@ -467,10 +467,10 @@  discard block
 block discarded – undo
467 467
 	 *
468 468
 	 * @param integer $order_id
469 469
 	 */
470
-	function save_payment_return_data( $order_id ) {
470
+	function save_payment_return_data($order_id) {
471 471
 		$data = wpshop_tools::getMethode();
472 472
 
473
-		$current_payment_return = get_post_meta( $order_id, '_wpshop_payment_return_data', true);
473
+		$current_payment_return = get_post_meta($order_id, '_wpshop_payment_return_data', true);
474 474
 		$current_payment_return[] = $data;
475 475
 
476 476
 		update_post_meta($order_id, '_wpshop_payment_return_data', $current_payment_return);
@@ -484,23 +484,23 @@  discard block
 block discarded – undo
484 484
 	 * @param array $params : infos sended by the bank, array structure : ('method', 'waited amount', 'status', 'author', 'payment reference', 'date', 'received amount')
485 485
 	 * @return array The order new meta informations
486 486
 	 */
487
-	public static function add_new_payment_to_order( $order_id, $order_meta, $payment_index, $params, $bank_response ) {
488
-
489
-		$order_meta['order_payment']['received'][$payment_index]['method'] = ( !empty($params['method']) ) ? $params['method'] : null;
490
-		$order_meta['order_payment']['received'][$payment_index]['waited_amount'] = ( !empty($params['waited_amount']) ) ? $params['waited_amount'] : null;
491
-		$order_meta['order_payment']['received'][$payment_index]['status'] = ( !empty($params['status']) ) ? $params['status'] : null;
492
-		$order_meta['order_payment']['received'][$payment_index]['author'] = ( !empty($params['author']) ) ? $params['author'] : get_current_user_id();
493
-		$order_meta['order_payment']['received'][$payment_index]['payment_reference'] =( !empty($params['payment_reference']) ) ? $params['payment_reference'] : null;
494
-		$order_meta['order_payment']['received'][$payment_index]['date'] = ( !empty($params['date']) ) ? $params['date'] : null;
495
-		$order_meta['order_payment']['received'][$payment_index]['received_amount'] = ( !empty($params['received_amount']) ) ? $params['received_amount'] : null;
487
+	public static function add_new_payment_to_order($order_id, $order_meta, $payment_index, $params, $bank_response) {
488
+
489
+		$order_meta['order_payment']['received'][$payment_index]['method'] = (!empty($params['method'])) ? $params['method'] : null;
490
+		$order_meta['order_payment']['received'][$payment_index]['waited_amount'] = (!empty($params['waited_amount'])) ? $params['waited_amount'] : null;
491
+		$order_meta['order_payment']['received'][$payment_index]['status'] = (!empty($params['status'])) ? $params['status'] : null;
492
+		$order_meta['order_payment']['received'][$payment_index]['author'] = (!empty($params['author'])) ? $params['author'] : get_current_user_id();
493
+		$order_meta['order_payment']['received'][$payment_index]['payment_reference'] = (!empty($params['payment_reference'])) ? $params['payment_reference'] : null;
494
+		$order_meta['order_payment']['received'][$payment_index]['date'] = (!empty($params['date'])) ? $params['date'] : null;
495
+		$order_meta['order_payment']['received'][$payment_index]['received_amount'] = (!empty($params['received_amount'])) ? $params['received_amount'] : null;
496 496
 		$order_meta['order_payment']['received'][$payment_index]['comment'] = '';
497 497
 
498 498
 		$order_info = get_post_meta($order_id, '_order_info', true);
499
-		if(!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) {
499
+		if (!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) {
500 500
 
501 501
 			/**	Generate an invoice number for the current payment. Check if the payment is complete or not	*/
502
-			if ( empty($order_meta['order_invoice_ref']) ) {
503
-				$order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number( $order_id );
502
+			if (empty($order_meta['order_invoice_ref'])) {
503
+				$order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number($order_id);
504 504
 			}
505 505
 		}
506 506
 
@@ -513,13 +513,13 @@  discard block
 block discarded – undo
513 513
 	 * @param string $payment_method
514 514
 	 * @return integer $key : array id of [order_payment][received] in the order postmeta
515 515
 	 */
516
-	public static function get_order_waiting_payment_array_id ( $oid, $payment_method ) {
516
+	public static function get_order_waiting_payment_array_id($oid, $payment_method) {
517 517
 		$key = 0;
518
-		$order_meta = get_post_meta( $oid, '_order_postmeta', true);
519
-		if ( !empty($order_meta) ) {
520
-			$key = count( $order_meta['order_payment']['received'] );
521
-			foreach ( $order_meta['order_payment']['received'] as $k => $payment_test) {
522
-				if ( !array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */ ) {
518
+		$order_meta = get_post_meta($oid, '_order_postmeta', true);
519
+		if (!empty($order_meta)) {
520
+			$key = count($order_meta['order_payment']['received']);
521
+			foreach ($order_meta['order_payment']['received'] as $k => $payment_test) {
522
+				if (!array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */) {
523 523
 					$key = $k;
524 524
 				}
525 525
 			}
@@ -534,52 +534,52 @@  discard block
 block discarded – undo
534 534
 	 * @param array $params_array
535 535
 	 * @return string
536 536
 	 */
537
-	public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true ) {
537
+	public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true) {
538 538
 		global $wpshop_payment; global $wpdb;
539
-		$order_meta = ( !empty($order_meta) ) ? $order_meta : get_post_meta( $order_id, '_order_postmeta', true);
539
+		$order_meta = (!empty($order_meta)) ? $order_meta : get_post_meta($order_id, '_order_postmeta', true);
540 540
 
541 541
 		$wps_message = new wps_message_ctr();
542
-		if ( !empty($order_meta) ) {
542
+		if (!empty($order_meta)) {
543 543
 			$order_info = get_post_meta($order_id, '_order_info', true);
544
-			$user_data = get_userdata( $order_meta['customer_id'] );
545
-			$email = ( !empty($user_data) && !empty($user_data->user_email) ) ? $user_data->user_email : '';
544
+			$user_data = get_userdata($order_meta['customer_id']);
545
+			$email = (!empty($user_data) && !empty($user_data->user_email)) ? $user_data->user_email : '';
546 546
 // 			$email = ( !empty($order_info) &&  !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : '' ;
547
-			$first_name = (!empty($order_info) && !empty($order_info['billing']) &&  !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' );
548
-			$last_name = ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' );
547
+			$first_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
548
+			$last_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
549 549
 
550
-			$key = self::get_order_waiting_payment_array_id( $order_id, $params_array['method']);
550
+			$key = self::get_order_waiting_payment_array_id($order_id, $params_array['method']);
551 551
 			$order_grand_total = $order_meta['order_grand_total'];
552
-			$total_received = ( ( !empty($params_array['status']) && ( $params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount']) ) ? $params_array['received_amount'] : 0 );
553
-			foreach ( $order_meta['order_payment']['received'] as $received ) {
554
-				$total_received += ( ( !empty($received['status']) && ( $received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount']) ) ? $received['received_amount'] : 0 );
552
+			$total_received = ((!empty($params_array['status']) && ($params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount'])) ? $params_array['received_amount'] : 0);
553
+			foreach ($order_meta['order_payment']['received'] as $received) {
554
+				$total_received += ((!empty($received['status']) && ($received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount'])) ? $received['received_amount'] : 0);
555 555
 			}
556 556
 			$order_meta['order_amount_to_pay_now'] = $order_grand_total - $total_received;
557
-			$order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order( $order_id, $order_meta, $key, $params_array, $bank_response );
557
+			$order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order($order_id, $order_meta, $key, $params_array, $bank_response);
558 558
 
559 559
 			if ($bank_response == 'completed') {
560 560
 
561
-				if ( number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total,2, '.', '') ) {
561
+				if (number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total, 2, '.', '')) {
562 562
 					$payment_status = 'completed';
563 563
 
564
-					$order_meta['order_invoice_ref'] = ( empty ($order_meta['order_invoice_ref'] ) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref']) ) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : $order_meta['order_invoice_ref'] ;
564
+					$order_meta['order_invoice_ref'] = (empty ($order_meta['order_invoice_ref']) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref'])) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : $order_meta['order_invoice_ref'];
565 565
 					$order_meta['order_invoice_date'] = current_time('mysql', 0);
566 566
 
567 567
 					if (!empty($order_meta['order_items'])) {
568 568
 						foreach ($order_meta['order_items'] as $item_id => $o) {
569 569
 							$pid = $o['item_id'];
570
-							if (strpos($item_id,'__') !== false) {
571
-								$product_data_id = explode( '__', $item_id );
572
-								$pid = ( !empty($product_data_id) && !empty($product_data_id[1]) ) ? $product_data_id[1] : $pid;
570
+							if (strpos($item_id, '__') !== false) {
571
+								$product_data_id = explode('__', $item_id);
572
+								$pid = (!empty($product_data_id) && !empty($product_data_id[1])) ? $product_data_id[1] : $pid;
573 573
 							}
574
-							$product = wpshop_products::get_product_data( $pid );
575
-							if ( get_post_type( $pid ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
576
-								$parent_def = wpshop_products::get_parent_variation ( $pid );
574
+							$product = wpshop_products::get_product_data($pid);
575
+							if (get_post_type($pid) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
576
+								$parent_def = wpshop_products::get_parent_variation($pid);
577 577
 								$parent_post = $parent_def['parent_post'];
578
-								$product = wpshop_products::get_product_data( $parent_post->ID );
578
+								$product = wpshop_products::get_product_data($parent_post->ID);
579 579
 							}
580 580
 
581
-							if (!empty($product) && !empty($product['manage_stock']) && strtolower( __($product['manage_stock'], 'wpshop') ) == strtolower( __('Yes', 'wpshop') ) ) {
582
-								wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid );
581
+							if (!empty($product) && !empty($product['manage_stock']) && strtolower(__($product['manage_stock'], 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
582
+								wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid);
583 583
 							}
584 584
 						}
585 585
 					}
@@ -588,45 +588,45 @@  discard block
 block discarded – undo
588 588
 					update_post_meta($order_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '_completed_date', current_time('mysql', 0));
589 589
 
590 590
 					/** Check if the order content a downloadable product **/
591
-					if ( !empty($order_meta['order_items']) ) {
592
-						foreach( $order_meta['order_items'] as $key_value => $item ) {
591
+					if (!empty($order_meta['order_items'])) {
592
+						foreach ($order_meta['order_items'] as $key_value => $item) {
593 593
 							$key_value = $item['item_id'];
594 594
 							/** Check if it's a product with signle variation, check the parent product **/
595
-							if ( !empty($item['item_id']) && get_post_type( $item['item_id'] ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
596
-								$parent_item = wpshop_products::get_parent_variation( $item['item_id'] );
595
+							if (!empty($item['item_id']) && get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
596
+								$parent_item = wpshop_products::get_parent_variation($item['item_id']);
597 597
 								$key_value = $parent_item['parent_post']->ID;
598 598
 								$parent_post_metadata = $parent_item['parent_post_meta'];
599
-								if ( !empty($parent_post_metadata['is_downloadable_']) ) {
600
-									$query = $wpdb->prepare( 'SELECT value FROM '. WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS .' WHERE id = %d', $parent_post_metadata['is_downloadable_'] );
601
-									$downloadable_option_value = $wpdb->get_var( $query );
602
-									if ( !empty( $downloadable_option_value) ) {
599
+								if (!empty($parent_post_metadata['is_downloadable_'])) {
600
+									$query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_post_metadata['is_downloadable_']);
601
+									$downloadable_option_value = $wpdb->get_var($query);
602
+									if (!empty($downloadable_option_value)) {
603 603
 										$item['item_is_downloadable_'] = $downloadable_option_value;
604 604
 									}
605 605
 
606 606
 								}
607 607
 							}
608 608
 
609
-							if ( !empty($item) && !empty($item['item_is_downloadable_']) && ( __( $item['item_is_downloadable_'], 'wpshop') == __('Yes', 'wpshop') || __( $item['item_is_downloadable_'], 'wpshop') == __('yes', 'wpshop') ) ) {
610
-								$download_codes = get_user_meta($order_meta['customer_id'], '_order_download_codes_'.$order_id, true);
609
+							if (!empty($item) && !empty($item['item_is_downloadable_']) && (__($item['item_is_downloadable_'], 'wpshop') == __('Yes', 'wpshop') || __($item['item_is_downloadable_'], 'wpshop') == __('yes', 'wpshop'))) {
610
+								$download_codes = get_user_meta($order_meta['customer_id'], '_order_download_codes_' . $order_id, true);
611 611
 
612
-								if ( !empty($download_codes) && !empty($download_codes[$key_value]) && !empty($download_codes[$key_value]['download_code']) ) {
613
-									$link = '<a href="' . admin_url( 'admin-post.php?action=download_file&amp;oid=' . $order_id . '&amp;download=' . $download_codes[$key_value]['download_code'] ) . '">' . __('Download','wpshop') . '</a>';
614
-									$wps_message->wpshop_prepared_email($email, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'download_product_link' => $link), array() );
612
+								if (!empty($download_codes) && !empty($download_codes[$key_value]) && !empty($download_codes[$key_value]['download_code'])) {
613
+									$link = '<a href="' . admin_url('admin-post.php?action=download_file&amp;oid=' . $order_id . '&amp;download=' . $download_codes[$key_value]['download_code']) . '">' . __('Download', 'wpshop') . '</a>';
614
+									$wps_message->wpshop_prepared_email($email, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'download_product_link' => $link), array());
615 615
 								}
616 616
 							}
617 617
 						}
618 618
 					}
619 619
 
620 620
 					// Send confirmation e-mail to administrator
621
-					if ( empty($_SESSION['wps-pos-addon']) ) {
621
+					if (empty($_SESSION['wps-pos-addon'])) {
622 622
 						$email_option = get_option('wpshop_emails');
623
-						if(  !empty($email_option) && !empty($email_option['send_confirmation_order_message']) ){
624
-							wpshop_checkout::send_order_email_to_administrator( $order_id, $user_data );
623
+						if (!empty($email_option) && !empty($email_option['send_confirmation_order_message'])) {
624
+							wpshop_checkout::send_order_email_to_administrator($order_id, $user_data);
625 625
 						}
626 626
 					}
627 627
 
628 628
 					// POS Status
629
-					if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) {
629
+					if (!empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos') {
630 630
 						$payment_status = 'pos';
631 631
 					}
632 632
 				}
@@ -635,23 +635,23 @@  discard block
 block discarded – undo
635 635
 				}
636 636
 
637 637
 				$order_meta['order_status'] = $payment_status;
638
-				update_post_meta( $order_id, '_order_postmeta', $order_meta);
638
+				update_post_meta($order_id, '_order_postmeta', $order_meta);
639 639
 				$save_metadata = false;
640 640
 
641
-				$allow_send_invoice = get_option( 'wpshop_send_invoice' );
642
-				$invoice_attachment_file = ( !empty($allow_send_invoice) ) ? wpshop_modules_billing::generate_invoice_for_email( $order_id, $order_meta['order_payment']['received'][$key]['invoice_ref'] ) : '';
641
+				$allow_send_invoice = get_option('wpshop_send_invoice');
642
+				$invoice_attachment_file = (!empty($allow_send_invoice)) ? wpshop_modules_billing::generate_invoice_for_email($order_id, $order_meta['order_payment']['received'][$key]['invoice_ref']) : '';
643 643
 
644
-				$email_option = get_option( 'wpshop_emails' );
644
+				$email_option = get_option('wpshop_emails');
645 645
 
646
-				$shipping_mode_option = get_option( 'wps_shipping_mode' );
647
-				$shipping_method = ( !empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order_meta['order_payment']['shipping_method'] : '' );
646
+				$shipping_mode_option = get_option('wps_shipping_mode');
647
+				$shipping_method = (!empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order_meta['order_payment']['shipping_method'] : '');
648 648
 
649
-				$payment_method_option = get_option( 'wps_payment_mode' );
650
-				$order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode'])  && !empty($order_meta['order_payment']['customer_choice']['method'])  && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])  ) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method'];
649
+				$payment_method_option = get_option('wps_payment_mode');
650
+				$order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method'];
651 651
 
652 652
 
653
-				if ( !empty($email_option) && !empty($email_option['send_confirmation_order_message']) && $payment_status == 'completed' ) {
654
-					$wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ( ( !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : ''),'order_date' => current_time('mysql', 0),  'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '',  'order_shipping_method' => $shipping_method ) );
653
+				if (!empty($email_option) && !empty($email_option['send_confirmation_order_message']) && $payment_status == 'completed') {
654
+					$wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ((!empty($order_meta['order_key'])) ? $order_meta['order_key'] : ''), 'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method));
655 655
 				}
656 656
 
657 657
 				$wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file);
@@ -661,13 +661,13 @@  discard block
 block discarded – undo
661 661
 			}
662 662
 
663 663
 			$order_meta['order_status'] = $payment_status;
664
-			if( !$save_metadata ) {
664
+			if (!$save_metadata) {
665 665
 				return 	$order_meta;
666 666
 			}
667 667
 			else {
668
-				update_post_meta( $order_id, '_order_postmeta', $order_meta);
668
+				update_post_meta($order_id, '_order_postmeta', $order_meta);
669 669
 			}
670
-			update_post_meta( $order_id, '_wpshop_order_status', $payment_status);
670
+			update_post_meta($order_id, '_wpshop_order_status', $payment_status);
671 671
 		}
672 672
 	}
673 673
 
@@ -679,11 +679,11 @@  discard block
 block discarded – undo
679 679
 	 * @param integer $order_id The order identifier we want to get the old transaction reference for
680 680
 	 * @return integer
681 681
 	 */
682
-	public static function get_payment_transaction_number_old_way($order_id){
682
+	public static function get_payment_transaction_number_old_way($order_id) {
683 683
 		$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
684 684
 		$transaction_indentifier = 0;
685
-		if(!empty($order_postmeta['payment_method'])){
686
-			switch($order_postmeta['payment_method']){
685
+		if (!empty($order_postmeta['payment_method'])) {
686
+			switch ($order_postmeta['payment_method']) {
687 687
 				case 'check':
688 688
 					$transaction_indentifier = get_post_meta($order_id, '_order_check_number', true);
689 689
 					break;
@@ -702,26 +702,26 @@  discard block
 block discarded – undo
702 702
 		return $transaction_indentifier;
703 703
 	}
704 704
 
705
-	public static function reverify_payment_invoice_ref( $order_id, $index_payment ) {
705
+	public static function reverify_payment_invoice_ref($order_id, $index_payment) {
706 706
 		$status = false;
707
-		$order_meta = get_post_meta( $order_id, '_order_postmeta', true );
708
-		if( !empty( $order_meta ) && !empty( $order_meta['order_payment'] ) && !empty( $order_meta['order_payment']['received'] ) && !empty( $order_meta['order_payment']['received'][$index_payment] ) && empty( $order_meta['order_payment']['received'][$index_payment]['invoice_ref'] ) ) {
707
+		$order_meta = get_post_meta($order_id, '_order_postmeta', true);
708
+		if (!empty($order_meta) && !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['received']) && !empty($order_meta['order_payment']['received'][$index_payment]) && empty($order_meta['order_payment']['received'][$index_payment]['invoice_ref'])) {
709 709
 			$order_invoice = $invoice_ref = false;
710 710
 
711
-			end( $order_meta['order_payment']['received'] );
712
-			$last_payment = key( $order_meta['order_payment']['received'] );
713
-			if( $last_payment == $index_payment ) {
711
+			end($order_meta['order_payment']['received']);
712
+			$last_payment = key($order_meta['order_payment']['received']);
713
+			if ($last_payment == $index_payment) {
714 714
 				$payments = 0;
715
-				foreach( $order_meta['order_payment']['received'] as $payment ) {
716
-					$payments += ( $payment['status'] == 'payment_received' ) ? $payment['received_amount'] : 0;
715
+				foreach ($order_meta['order_payment']['received'] as $payment) {
716
+					$payments += ($payment['status'] == 'payment_received') ? $payment['received_amount'] : 0;
717 717
 				}
718
-				if( $order_meta['order_grand_total'] <= $payments ) {
719
-					if( $order_meta['order_status'] == 'partially_paid' ) {
720
-						$order_status_meta = get_post_meta( $order_id, '_wpshop_order_status', true );
718
+				if ($order_meta['order_grand_total'] <= $payments) {
719
+					if ($order_meta['order_status'] == 'partially_paid') {
720
+						$order_status_meta = get_post_meta($order_id, '_wpshop_order_status', true);
721 721
 						$order_meta['order_status'] = 'completed';
722
-						$status = (bool)update_post_meta( $order_id, '_wpshop_order_status', 'completed' );
722
+						$status = (bool)update_post_meta($order_id, '_wpshop_order_status', 'completed');
723 723
 					}
724
-					if( !empty( $order_meta['order_invoice_ref'] ) ) {
724
+					if (!empty($order_meta['order_invoice_ref'])) {
725 725
 						$invoice_ref = $order_meta['order_invoice_ref'];
726 726
 						$status = true;
727 727
 					} else {
@@ -732,16 +732,16 @@  discard block
 block discarded – undo
732 732
 				$status = true;
733 733
 			}
734 734
 
735
-			if( $status ) {
736
-				if( empty( $invoice_ref ) ) {
737
-					$invoice_ref = wpshop_modules_billing::generate_invoice_number( $order_id );
738
-					if( $order_invoice ) {
735
+			if ($status) {
736
+				if (empty($invoice_ref)) {
737
+					$invoice_ref = wpshop_modules_billing::generate_invoice_number($order_id);
738
+					if ($order_invoice) {
739 739
 						$order_meta['order_invoice_ref'] = $invoice_ref;
740 740
 					}
741 741
 				}
742 742
 
743 743
 				$order_meta['order_payment']['received'][$index_payment]['invoice_ref'] = $invoice_ref;
744
-				$status = (bool)update_post_meta( $order_id, '_order_postmeta', $order_meta );
744
+				$status = (bool)update_post_meta($order_id, '_order_postmeta', $order_meta);
745 745
 			}
746 746
 		}
747 747
 		return $status;
Please login to merge, or discard this patch.
includes/librairies/pdf/font/makefont/makefont.php 1 patch
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -229,6 +229,10 @@
 block discarded – undo
229 229
 	return rtrim($s);
230 230
 }
231 231
 
232
+/**
233
+ * @param string $file
234
+ * @param string $s
235
+ */
232 236
 function SaveToFile($file, $s, $mode)
233 237
 {
234 238
 	$f=fopen($file,'w'.$mode);
Please login to merge, or discard this patch.
includes/librairies/pdf/fpdf.php 3 patches
Doc Comments   +48 added lines patch added patch discarded remove patch
@@ -165,6 +165,10 @@  discard block
 block discarded – undo
165 165
 	$this->PDFVersion='1.3';
166 166
 }
167 167
 
168
+/**
169
+ * @param double $left
170
+ * @param double $top
171
+ */
168 172
 function SetMargins($left, $top, $right=null)
169 173
 {
170 174
 	//Set left, top and right margins
@@ -195,6 +199,9 @@  discard block
 block discarded – undo
195 199
 	$this->rMargin=$margin;
196 200
 }
197 201
 
202
+/**
203
+ * @param boolean $auto
204
+ */
198 205
 function SetAutoPageBreak($auto, $margin=0)
199 206
 {
200 207
 	//Set auto page break mode and triggering margin
@@ -203,6 +210,9 @@  discard block
 block discarded – undo
203 210
 	$this->PageBreakTrigger=$this->h-$margin;
204 211
 }
205 212
 
213
+/**
214
+ * @param string $zoom
215
+ */
206 216
 function SetDisplayMode($zoom, $layout='continuous')
207 217
 {
208 218
 	//Set display mode in viewer
@@ -216,6 +226,9 @@  discard block
 block discarded – undo
216 226
 		$this->Error('Incorrect layout display mode: '.$layout);
217 227
 }
218 228
 
229
+/**
230
+ * @param boolean $compress
231
+ */
219 232
 function SetCompression($compress)
220 233
 {
221 234
 	//Set page compression
@@ -271,6 +284,9 @@  discard block
 block discarded – undo
271 284
 	$this->AliasNbPages=$alias;
272 285
 }
273 286
 
287
+/**
288
+ * @param string $msg
289
+ */
274 290
 function Error($msg)
275 291
 {
276 292
 	//Fatal error
@@ -444,6 +460,12 @@  discard block
 block discarded – undo
444 460
 	$this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
445 461
 }
446 462
 
463
+/**
464
+ * @param integer $x
465
+ * @param integer $y
466
+ * @param integer $w
467
+ * @param integer $h
468
+ */
447 469
 function Rect($x, $y, $w, $h, $style='')
448 470
 {
449 471
 	//Draw a rectangle
@@ -504,6 +526,9 @@  discard block
 block discarded – undo
504 526
 	}
505 527
 }
506 528
 
529
+/**
530
+ * @param string $family
531
+ */
507 532
 function SetFont($family, $style='', $size=0)
508 533
 {
509 534
 	//Select a font; size given in points
@@ -595,6 +620,10 @@  discard block
 block discarded – undo
595 620
 	$this->links[$link]=array($page, $y);
596 621
 }
597 622
 
623
+/**
624
+ * @param double $y
625
+ * @param string $link
626
+ */
598 627
 function Link($x, $y, $w, $h, $link)
599 628
 {
600 629
 	//Put a link on the page
@@ -697,6 +726,11 @@  discard block
 block discarded – undo
697 726
 		$this->x+=$w;
698 727
 }
699 728
 
729
+/**
730
+ * @param integer $w
731
+ * @param integer $h
732
+ * @param string $txt
733
+ */
700 734
 function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
701 735
 {
702 736
 	//Output text with automatic or explicit line breaks
@@ -988,6 +1022,10 @@  discard block
 block discarded – undo
988 1022
 		$this->y=$this->h+$y;
989 1023
 }
990 1024
 
1025
+/**
1026
+ * @param integer $x
1027
+ * @param integer $y
1028
+ */
991 1029
 function SetXY($x, $y)
992 1030
 {
993 1031
 	//Set x and y positions
@@ -1080,6 +1118,9 @@  discard block
 block discarded – undo
1080 1118
 		@set_magic_quotes_runtime(0);
1081 1119
 }
1082 1120
 
1121
+/**
1122
+ * @param string $format
1123
+ */
1083 1124
 function _getpageformat($format)
1084 1125
 {
1085 1126
 	$format=strtolower($format);
@@ -1096,6 +1137,10 @@  discard block
 block discarded – undo
1096 1137
 	return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
1097 1138
 }
1098 1139
 
1140
+/**
1141
+ * @param string $orientation
1142
+ * @param string $format
1143
+ */
1099 1144
 function _beginpage($orientation, $format)
1100 1145
 {
1101 1146
 	$this->page++;
@@ -1226,6 +1271,9 @@  discard block
 block discarded – undo
1226 1271
 	return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
1227 1272
 }
1228 1273
 
1274
+/**
1275
+ * @param string $file
1276
+ */
1229 1277
 function _parsepng($file)
1230 1278
 {
1231 1279
 	//Extract info from a PNG file
Please login to merge, or discard this patch.
Spacing   +861 added lines, -861 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
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
 /*******************************************************************************
@@ -13,360 +13,360 @@  discard block
 block discarded – undo
13 13
 * Auteur :  Olivier PLATHEY                                                    *
14 14
 *******************************************************************************/
15 15
 
16
-define('FPDF_VERSION','1.6');
16
+define('FPDF_VERSION', '1.6');
17 17
 
18 18
 class wpshop_FPDF
19 19
 {
20
-var $page;               //current page number
21
-var $n;                  //current object number
22
-var $offsets;            //array of object offsets
23
-var $buffer;             //buffer holding in-memory PDF
24
-var $pages;              //array containing pages
25
-var $state;              //current document state
26
-var $compress;           //compression flag
27
-var $k;                  //scale factor (number of points in user unit)
28
-var $DefOrientation;     //default orientation
29
-var $CurOrientation;     //current orientation
30
-var $PageFormats;        //available page formats
31
-var $DefPageFormat;      //default page format
32
-var $CurPageFormat;      //current page format
33
-var $PageSizes;          //array storing non-default page sizes
34
-var $wPt,$hPt;           //dimensions of current page in points
35
-var $w,$h;               //dimensions of current page in user unit
36
-var $lMargin;            //left margin
37
-var $tMargin;            //top margin
38
-var $rMargin;            //right margin
39
-var $bMargin;            //page break margin
40
-var $cMargin;            //cell margin
41
-var $x,$y;               //current position in user unit
42
-var $lasth;              //height of last printed cell
43
-var $LineWidth;          //line width in user unit
44
-var $CoreFonts;          //array of standard font names
45
-var $fonts;              //array of used fonts
46
-var $FontFiles;          //array of font files
47
-var $diffs;              //array of encoding differences
48
-var $FontFamily;         //current font family
49
-var $FontStyle;          //current font style
50
-var $underline;          //underlining flag
51
-var $CurrentFont;        //current font info
52
-var $FontSizePt;         //current font size in points
53
-var $FontSize;           //current font size in user unit
54
-var $DrawColor;          //commands for drawing color
55
-var $FillColor;          //commands for filling color
56
-var $TextColor;          //commands for text color
57
-var $ColorFlag;          //indicates whether fill and text colors are different
58
-var $ws;                 //word spacing
59
-var $images;             //array of used images
60
-var $PageLinks;          //array of links in pages
61
-var $links;              //array of internal links
62
-var $AutoPageBreak;      //automatic page breaking
63
-var $PageBreakTrigger;   //threshold used to trigger page breaks
64
-var $InHeader;           //flag set when processing header
65
-var $InFooter;           //flag set when processing footer
66
-var $ZoomMode;           //zoom display mode
67
-var $LayoutMode;         //layout display mode
68
-var $title;              //title
69
-var $subject;            //subject
70
-var $author;             //author
71
-var $keywords;           //keywords
72
-var $creator;            //creator
73
-var $AliasNbPages;       //alias for total number of pages
74
-var $PDFVersion;         //PDF version number
20
+var $page; //current page number
21
+var $n; //current object number
22
+var $offsets; //array of object offsets
23
+var $buffer; //buffer holding in-memory PDF
24
+var $pages; //array containing pages
25
+var $state; //current document state
26
+var $compress; //compression flag
27
+var $k; //scale factor (number of points in user unit)
28
+var $DefOrientation; //default orientation
29
+var $CurOrientation; //current orientation
30
+var $PageFormats; //available page formats
31
+var $DefPageFormat; //default page format
32
+var $CurPageFormat; //current page format
33
+var $PageSizes; //array storing non-default page sizes
34
+var $wPt, $hPt; //dimensions of current page in points
35
+var $w, $h; //dimensions of current page in user unit
36
+var $lMargin; //left margin
37
+var $tMargin; //top margin
38
+var $rMargin; //right margin
39
+var $bMargin; //page break margin
40
+var $cMargin; //cell margin
41
+var $x, $y; //current position in user unit
42
+var $lasth; //height of last printed cell
43
+var $LineWidth; //line width in user unit
44
+var $CoreFonts; //array of standard font names
45
+var $fonts; //array of used fonts
46
+var $FontFiles; //array of font files
47
+var $diffs; //array of encoding differences
48
+var $FontFamily; //current font family
49
+var $FontStyle; //current font style
50
+var $underline; //underlining flag
51
+var $CurrentFont; //current font info
52
+var $FontSizePt; //current font size in points
53
+var $FontSize; //current font size in user unit
54
+var $DrawColor; //commands for drawing color
55
+var $FillColor; //commands for filling color
56
+var $TextColor; //commands for text color
57
+var $ColorFlag; //indicates whether fill and text colors are different
58
+var $ws; //word spacing
59
+var $images; //array of used images
60
+var $PageLinks; //array of links in pages
61
+var $links; //array of internal links
62
+var $AutoPageBreak; //automatic page breaking
63
+var $PageBreakTrigger; //threshold used to trigger page breaks
64
+var $InHeader; //flag set when processing header
65
+var $InFooter; //flag set when processing footer
66
+var $ZoomMode; //zoom display mode
67
+var $LayoutMode; //layout display mode
68
+var $title; //title
69
+var $subject; //subject
70
+var $author; //author
71
+var $keywords; //keywords
72
+var $creator; //creator
73
+var $AliasNbPages; //alias for total number of pages
74
+var $PDFVersion; //PDF version number
75 75
 
76 76
 /*******************************************************************************
77 77
 *                                                                              *
78 78
 *                               Public methods                                 *
79 79
 *                                                                              *
80 80
 *******************************************************************************/
81
-function wpshop_FPDF($orientation='P', $unit='mm', $format='A4')
81
+function wpshop_FPDF($orientation = 'P', $unit = 'mm', $format = 'A4')
82 82
 {
83 83
 	//Some checks
84 84
 	$this->_dochecks();
85 85
 	//Initialization of properties
86
-	$this->page=0;
87
-	$this->n=2;
88
-	$this->buffer='';
89
-	$this->pages=array();
90
-	$this->PageSizes=array();
91
-	$this->state=0;
92
-	$this->fonts=array();
93
-	$this->FontFiles=array();
94
-	$this->diffs=array();
95
-	$this->images=array();
96
-	$this->links=array();
97
-	$this->InHeader=false;
98
-	$this->InFooter=false;
99
-	$this->lasth=0;
100
-	$this->FontFamily='';
101
-	$this->FontStyle='';
102
-	$this->FontSizePt=12;
103
-	$this->underline=false;
104
-	$this->DrawColor='0 G';
105
-	$this->FillColor='0 g';
106
-	$this->TextColor='0 g';
107
-	$this->ColorFlag=false;
108
-	$this->ws=0;
86
+	$this->page = 0;
87
+	$this->n = 2;
88
+	$this->buffer = '';
89
+	$this->pages = array();
90
+	$this->PageSizes = array();
91
+	$this->state = 0;
92
+	$this->fonts = array();
93
+	$this->FontFiles = array();
94
+	$this->diffs = array();
95
+	$this->images = array();
96
+	$this->links = array();
97
+	$this->InHeader = false;
98
+	$this->InFooter = false;
99
+	$this->lasth = 0;
100
+	$this->FontFamily = '';
101
+	$this->FontStyle = '';
102
+	$this->FontSizePt = 12;
103
+	$this->underline = false;
104
+	$this->DrawColor = '0 G';
105
+	$this->FillColor = '0 g';
106
+	$this->TextColor = '0 g';
107
+	$this->ColorFlag = false;
108
+	$this->ws = 0;
109 109
 	//Standard fonts
110
-	$this->CoreFonts=array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique',
110
+	$this->CoreFonts = array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique',
111 111
 		'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold', 'helveticaI'=>'Helvetica-Oblique', 'helveticaBI'=>'Helvetica-BoldOblique',
112 112
 		'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic',
113 113
 		'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats');
114 114
 	//Scale factor
115
-	if($unit=='pt')
116
-		$this->k=1;
117
-	elseif($unit=='mm')
118
-		$this->k=72/25.4;
119
-	elseif($unit=='cm')
120
-		$this->k=72/2.54;
121
-	elseif($unit=='in')
122
-		$this->k=72;
115
+	if ($unit == 'pt')
116
+		$this->k = 1;
117
+	elseif ($unit == 'mm')
118
+		$this->k = 72 / 25.4;
119
+	elseif ($unit == 'cm')
120
+		$this->k = 72 / 2.54;
121
+	elseif ($unit == 'in')
122
+		$this->k = 72;
123 123
 	else
124
-		$this->Error('Incorrect unit: '.$unit);
124
+		$this->Error('Incorrect unit: ' . $unit);
125 125
 	//Page format
126
-	$this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
127
-		'letter'=>array(612,792), 'legal'=>array(612,1008));
128
-	if(is_string($format))
129
-		$format=$this->_getpageformat($format);
130
-	$this->DefPageFormat=$format;
131
-	$this->CurPageFormat=$format;
126
+	$this->PageFormats = array('a3'=>array(841.89, 1190.55), 'a4'=>array(595.28, 841.89), 'a5'=>array(420.94, 595.28),
127
+		'letter'=>array(612, 792), 'legal'=>array(612, 1008));
128
+	if (is_string($format))
129
+		$format = $this->_getpageformat($format);
130
+	$this->DefPageFormat = $format;
131
+	$this->CurPageFormat = $format;
132 132
 	//Page orientation
133
-	$orientation=strtolower($orientation);
134
-	if($orientation=='p' || $orientation=='portrait')
133
+	$orientation = strtolower($orientation);
134
+	if ($orientation == 'p' || $orientation == 'portrait')
135 135
 	{
136
-		$this->DefOrientation='P';
137
-		$this->w=$this->DefPageFormat[0];
138
-		$this->h=$this->DefPageFormat[1];
136
+		$this->DefOrientation = 'P';
137
+		$this->w = $this->DefPageFormat[0];
138
+		$this->h = $this->DefPageFormat[1];
139 139
 	}
140
-	elseif($orientation=='l' || $orientation=='landscape')
140
+	elseif ($orientation == 'l' || $orientation == 'landscape')
141 141
 	{
142
-		$this->DefOrientation='L';
143
-		$this->w=$this->DefPageFormat[1];
144
-		$this->h=$this->DefPageFormat[0];
142
+		$this->DefOrientation = 'L';
143
+		$this->w = $this->DefPageFormat[1];
144
+		$this->h = $this->DefPageFormat[0];
145 145
 	}
146 146
 	else
147
-		$this->Error('Incorrect orientation: '.$orientation);
148
-	$this->CurOrientation=$this->DefOrientation;
149
-	$this->wPt=$this->w*$this->k;
150
-	$this->hPt=$this->h*$this->k;
147
+		$this->Error('Incorrect orientation: ' . $orientation);
148
+	$this->CurOrientation = $this->DefOrientation;
149
+	$this->wPt = $this->w * $this->k;
150
+	$this->hPt = $this->h * $this->k;
151 151
 	//Page margins (1 cm)
152
-	$margin=28.35/$this->k;
153
-	$this->SetMargins($margin,$margin);
152
+	$margin = 28.35 / $this->k;
153
+	$this->SetMargins($margin, $margin);
154 154
 	//Interior cell margin (1 mm)
155
-	$this->cMargin=$margin/10;
155
+	$this->cMargin = $margin / 10;
156 156
 	//Line width (0.2 mm)
157
-	$this->LineWidth=.567/$this->k;
157
+	$this->LineWidth = .567 / $this->k;
158 158
 	//Automatic page break
159
-	$this->SetAutoPageBreak(true,2*$margin);
159
+	$this->SetAutoPageBreak(true, 2 * $margin);
160 160
 	//Full width display mode
161 161
 	$this->SetDisplayMode('fullwidth');
162 162
 	//Enable compression
163 163
 	$this->SetCompression(true);
164 164
 	//Set default PDF version number
165
-	$this->PDFVersion='1.3';
165
+	$this->PDFVersion = '1.3';
166 166
 }
167 167
 
168
-function SetMargins($left, $top, $right=null)
168
+function SetMargins($left, $top, $right = null)
169 169
 {
170 170
 	//Set left, top and right margins
171
-	$this->lMargin=$left;
172
-	$this->tMargin=$top;
173
-	if($right===null)
174
-		$right=$left;
175
-	$this->rMargin=$right;
171
+	$this->lMargin = $left;
172
+	$this->tMargin = $top;
173
+	if ($right === null)
174
+		$right = $left;
175
+	$this->rMargin = $right;
176 176
 }
177 177
 
178 178
 function SetLeftMargin($margin)
179 179
 {
180 180
 	//Set left margin
181
-	$this->lMargin=$margin;
182
-	if($this->page>0 && $this->x<$margin)
183
-		$this->x=$margin;
181
+	$this->lMargin = $margin;
182
+	if ($this->page > 0 && $this->x < $margin)
183
+		$this->x = $margin;
184 184
 }
185 185
 
186 186
 function SetTopMargin($margin)
187 187
 {
188 188
 	//Set top margin
189
-	$this->tMargin=$margin;
189
+	$this->tMargin = $margin;
190 190
 }
191 191
 
192 192
 function SetRightMargin($margin)
193 193
 {
194 194
 	//Set right margin
195
-	$this->rMargin=$margin;
195
+	$this->rMargin = $margin;
196 196
 }
197 197
 
198
-function SetAutoPageBreak($auto, $margin=0)
198
+function SetAutoPageBreak($auto, $margin = 0)
199 199
 {
200 200
 	//Set auto page break mode and triggering margin
201
-	$this->AutoPageBreak=$auto;
202
-	$this->bMargin=$margin;
203
-	$this->PageBreakTrigger=$this->h-$margin;
201
+	$this->AutoPageBreak = $auto;
202
+	$this->bMargin = $margin;
203
+	$this->PageBreakTrigger = $this->h - $margin;
204 204
 }
205 205
 
206
-function SetDisplayMode($zoom, $layout='continuous')
206
+function SetDisplayMode($zoom, $layout = 'continuous')
207 207
 {
208 208
 	//Set display mode in viewer
209
-	if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
210
-		$this->ZoomMode=$zoom;
209
+	if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || !is_string($zoom))
210
+		$this->ZoomMode = $zoom;
211 211
 	else
212
-		$this->Error('Incorrect zoom display mode: '.$zoom);
213
-	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
214
-		$this->LayoutMode=$layout;
212
+		$this->Error('Incorrect zoom display mode: ' . $zoom);
213
+	if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default')
214
+		$this->LayoutMode = $layout;
215 215
 	else
216
-		$this->Error('Incorrect layout display mode: '.$layout);
216
+		$this->Error('Incorrect layout display mode: ' . $layout);
217 217
 }
218 218
 
219 219
 function SetCompression($compress)
220 220
 {
221 221
 	//Set page compression
222
-	if(function_exists('gzcompress'))
223
-		$this->compress=$compress;
222
+	if (function_exists('gzcompress'))
223
+		$this->compress = $compress;
224 224
 	else
225
-		$this->compress=false;
225
+		$this->compress = false;
226 226
 }
227 227
 
228
-function SetTitle($title, $isUTF8=false)
228
+function SetTitle($title, $isUTF8 = false)
229 229
 {
230 230
 	//Title of document
231
-	if($isUTF8)
232
-		$title=$this->_UTF8toUTF16($title);
233
-	$this->title=$title;
231
+	if ($isUTF8)
232
+		$title = $this->_UTF8toUTF16($title);
233
+	$this->title = $title;
234 234
 }
235 235
 
236
-function SetSubject($subject, $isUTF8=false)
236
+function SetSubject($subject, $isUTF8 = false)
237 237
 {
238 238
 	//Subject of document
239
-	if($isUTF8)
240
-		$subject=$this->_UTF8toUTF16($subject);
241
-	$this->subject=$subject;
239
+	if ($isUTF8)
240
+		$subject = $this->_UTF8toUTF16($subject);
241
+	$this->subject = $subject;
242 242
 }
243 243
 
244
-function SetAuthor($author, $isUTF8=false)
244
+function SetAuthor($author, $isUTF8 = false)
245 245
 {
246 246
 	//Author of document
247
-	if($isUTF8)
248
-		$author=$this->_UTF8toUTF16($author);
249
-	$this->author=$author;
247
+	if ($isUTF8)
248
+		$author = $this->_UTF8toUTF16($author);
249
+	$this->author = $author;
250 250
 }
251 251
 
252
-function SetKeywords($keywords, $isUTF8=false)
252
+function SetKeywords($keywords, $isUTF8 = false)
253 253
 {
254 254
 	//Keywords of document
255
-	if($isUTF8)
256
-		$keywords=$this->_UTF8toUTF16($keywords);
257
-	$this->keywords=$keywords;
255
+	if ($isUTF8)
256
+		$keywords = $this->_UTF8toUTF16($keywords);
257
+	$this->keywords = $keywords;
258 258
 }
259 259
 
260
-function SetCreator($creator, $isUTF8=false)
260
+function SetCreator($creator, $isUTF8 = false)
261 261
 {
262 262
 	//Creator of document
263
-	if($isUTF8)
264
-		$creator=$this->_UTF8toUTF16($creator);
265
-	$this->creator=$creator;
263
+	if ($isUTF8)
264
+		$creator = $this->_UTF8toUTF16($creator);
265
+	$this->creator = $creator;
266 266
 }
267 267
 
268
-function AliasNbPages($alias='{nb}')
268
+function AliasNbPages($alias = '{nb}')
269 269
 {
270 270
 	//Define an alias for total number of pages
271
-	$this->AliasNbPages=$alias;
271
+	$this->AliasNbPages = $alias;
272 272
 }
273 273
 
274 274
 function Error($msg)
275 275
 {
276 276
 	//Fatal error
277
-	die('<b>FPDF error:</b> '.$msg);
277
+	die('<b>FPDF error:</b> ' . $msg);
278 278
 }
279 279
 
280 280
 function Open()
281 281
 {
282 282
 	//Begin document
283
-	$this->state=1;
283
+	$this->state = 1;
284 284
 }
285 285
 
286 286
 function Close()
287 287
 {
288 288
 	//Terminate document
289
-	if($this->state==3)
289
+	if ($this->state == 3)
290 290
 		return;
291
-	if($this->page==0)
291
+	if ($this->page == 0)
292 292
 		$this->AddPage();
293 293
 	//Page footer
294
-	$this->InFooter=true;
294
+	$this->InFooter = true;
295 295
 	$this->Footer();
296
-	$this->InFooter=false;
296
+	$this->InFooter = false;
297 297
 	//Close page
298 298
 	$this->_endpage();
299 299
 	//Close document
300 300
 	$this->_enddoc();
301 301
 }
302 302
 
303
-function AddPage($orientation='', $format='')
303
+function AddPage($orientation = '', $format = '')
304 304
 {
305 305
 	//Start a new page
306
-	if($this->state==0)
306
+	if ($this->state == 0)
307 307
 		$this->Open();
308
-	$family=$this->FontFamily;
309
-	$style=$this->FontStyle.($this->underline ? 'U' : '');
310
-	$size=$this->FontSizePt;
311
-	$lw=$this->LineWidth;
312
-	$dc=$this->DrawColor;
313
-	$fc=$this->FillColor;
314
-	$tc=$this->TextColor;
315
-	$cf=$this->ColorFlag;
316
-	if($this->page>0)
308
+	$family = $this->FontFamily;
309
+	$style = $this->FontStyle . ($this->underline ? 'U' : '');
310
+	$size = $this->FontSizePt;
311
+	$lw = $this->LineWidth;
312
+	$dc = $this->DrawColor;
313
+	$fc = $this->FillColor;
314
+	$tc = $this->TextColor;
315
+	$cf = $this->ColorFlag;
316
+	if ($this->page > 0)
317 317
 	{
318 318
 		//Page footer
319
-		$this->InFooter=true;
319
+		$this->InFooter = true;
320 320
 		$this->Footer();
321
-		$this->InFooter=false;
321
+		$this->InFooter = false;
322 322
 		//Close page
323 323
 		$this->_endpage();
324 324
 	}
325 325
 	//Start new page
326
-	$this->_beginpage($orientation,$format);
326
+	$this->_beginpage($orientation, $format);
327 327
 	//Set line cap style to square
328 328
 	$this->_out('2 J');
329 329
 	//Set line width
330
-	$this->LineWidth=$lw;
331
-	$this->_out(sprintf('%.2F w',$lw*$this->k));
330
+	$this->LineWidth = $lw;
331
+	$this->_out(sprintf('%.2F w', $lw * $this->k));
332 332
 	//Set font
333
-	if($family)
334
-		$this->SetFont($family,$style,$size);
333
+	if ($family)
334
+		$this->SetFont($family, $style, $size);
335 335
 	//Set colors
336
-	$this->DrawColor=$dc;
337
-	if($dc!='0 G')
336
+	$this->DrawColor = $dc;
337
+	if ($dc != '0 G')
338 338
 		$this->_out($dc);
339
-	$this->FillColor=$fc;
340
-	if($fc!='0 g')
339
+	$this->FillColor = $fc;
340
+	if ($fc != '0 g')
341 341
 		$this->_out($fc);
342
-	$this->TextColor=$tc;
343
-	$this->ColorFlag=$cf;
342
+	$this->TextColor = $tc;
343
+	$this->ColorFlag = $cf;
344 344
 	//Page header
345
-	$this->InHeader=true;
345
+	$this->InHeader = true;
346 346
 	$this->Header();
347
-	$this->InHeader=false;
347
+	$this->InHeader = false;
348 348
 	//Restore line width
349
-	if($this->LineWidth!=$lw)
349
+	if ($this->LineWidth != $lw)
350 350
 	{
351
-		$this->LineWidth=$lw;
352
-		$this->_out(sprintf('%.2F w',$lw*$this->k));
351
+		$this->LineWidth = $lw;
352
+		$this->_out(sprintf('%.2F w', $lw * $this->k));
353 353
 	}
354 354
 	//Restore font
355
-	if($family)
356
-		$this->SetFont($family,$style,$size);
355
+	if ($family)
356
+		$this->SetFont($family, $style, $size);
357 357
 	//Restore colors
358
-	if($this->DrawColor!=$dc)
358
+	if ($this->DrawColor != $dc)
359 359
 	{
360
-		$this->DrawColor=$dc;
360
+		$this->DrawColor = $dc;
361 361
 		$this->_out($dc);
362 362
 	}
363
-	if($this->FillColor!=$fc)
363
+	if ($this->FillColor != $fc)
364 364
 	{
365
-		$this->FillColor=$fc;
365
+		$this->FillColor = $fc;
366 366
 		$this->_out($fc);
367 367
 	}
368
-	$this->TextColor=$tc;
369
-	$this->ColorFlag=$cf;
368
+	$this->TextColor = $tc;
369
+	$this->ColorFlag = $cf;
370 370
 }
371 371
 
372 372
 function Header()
@@ -385,230 +385,230 @@  discard block
 block discarded – undo
385 385
 	return $this->page;
386 386
 }
387 387
 
388
-function SetDrawColor($r, $g=null, $b=null)
388
+function SetDrawColor($r, $g = null, $b = null)
389 389
 {
390 390
 	//Set color for all stroking operations
391
-	if(($r==0 && $g==0 && $b==0) || $g===null)
392
-		$this->DrawColor=sprintf('%.3F G',$r/255);
391
+	if (($r == 0 && $g == 0 && $b == 0) || $g === null)
392
+		$this->DrawColor = sprintf('%.3F G', $r / 255);
393 393
 	else
394
-		$this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
395
-	if($this->page>0)
394
+		$this->DrawColor = sprintf('%.3F %.3F %.3F RG', $r / 255, $g / 255, $b / 255);
395
+	if ($this->page > 0)
396 396
 		$this->_out($this->DrawColor);
397 397
 }
398 398
 
399
-function SetFillColor($r, $g=null, $b=null)
399
+function SetFillColor($r, $g = null, $b = null)
400 400
 {
401 401
 	//Set color for all filling operations
402
-	if(($r==0 && $g==0 && $b==0) || $g===null)
403
-		$this->FillColor=sprintf('%.3F g',$r/255);
402
+	if (($r == 0 && $g == 0 && $b == 0) || $g === null)
403
+		$this->FillColor = sprintf('%.3F g', $r / 255);
404 404
 	else
405
-		$this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
406
-	$this->ColorFlag=($this->FillColor!=$this->TextColor);
407
-	if($this->page>0)
405
+		$this->FillColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
406
+	$this->ColorFlag = ($this->FillColor != $this->TextColor);
407
+	if ($this->page > 0)
408 408
 		$this->_out($this->FillColor);
409 409
 }
410 410
 
411
-function SetTextColor($r, $g=null, $b=null)
411
+function SetTextColor($r, $g = null, $b = null)
412 412
 {
413 413
 	//Set color for text
414
-	if(($r==0 && $g==0 && $b==0) || $g===null)
415
-		$this->TextColor=sprintf('%.3F g',$r/255);
414
+	if (($r == 0 && $g == 0 && $b == 0) || $g === null)
415
+		$this->TextColor = sprintf('%.3F g', $r / 255);
416 416
 	else
417
-		$this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
418
-	$this->ColorFlag=($this->FillColor!=$this->TextColor);
417
+		$this->TextColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
418
+	$this->ColorFlag = ($this->FillColor != $this->TextColor);
419 419
 }
420 420
 
421 421
 function GetStringWidth($s)
422 422
 {
423 423
 	//Get width of a string in the current font
424
-	$s=(string)$s;
425
-	$cw=&$this->CurrentFont['cw'];
426
-	$w=0;
427
-	$l=strlen($s);
428
-	for($i=0;$i<$l;$i++)
429
-		$w+=$cw[$s[$i]];
430
-	return $w*$this->FontSize/1000;
424
+	$s = (string)$s;
425
+	$cw = &$this->CurrentFont['cw'];
426
+	$w = 0;
427
+	$l = strlen($s);
428
+	for ($i = 0; $i < $l; $i++)
429
+		$w += $cw[$s[$i]];
430
+	return $w * $this->FontSize / 1000;
431 431
 }
432 432
 
433 433
 function SetLineWidth($width)
434 434
 {
435 435
 	//Set line width
436
-	$this->LineWidth=$width;
437
-	if($this->page>0)
438
-		$this->_out(sprintf('%.2F w',$width*$this->k));
436
+	$this->LineWidth = $width;
437
+	if ($this->page > 0)
438
+		$this->_out(sprintf('%.2F w', $width * $this->k));
439 439
 }
440 440
 
441 441
 function Line($x1, $y1, $x2, $y2)
442 442
 {
443 443
 	//Draw a line
444
-	$this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
444
+	$this->_out(sprintf('%.2F %.2F m %.2F %.2F l S', $x1 * $this->k, ($this->h - $y1) * $this->k, $x2 * $this->k, ($this->h - $y2) * $this->k));
445 445
 }
446 446
 
447
-function Rect($x, $y, $w, $h, $style='')
447
+function Rect($x, $y, $w, $h, $style = '')
448 448
 {
449 449
 	//Draw a rectangle
450
-	if($style=='F')
451
-		$op='f';
452
-	elseif($style=='FD' || $style=='DF')
453
-		$op='B';
450
+	if ($style == 'F')
451
+		$op = 'f';
452
+	elseif ($style == 'FD' || $style == 'DF')
453
+		$op = 'B';
454 454
 	else
455
-		$op='S';
456
-	$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
455
+		$op = 'S';
456
+	$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s', $x * $this->k, ($this->h - $y) * $this->k, $w * $this->k, -$h * $this->k, $op));
457 457
 }
458 458
 
459
-function AddFont($family, $style='', $file='')
459
+function AddFont($family, $style = '', $file = '')
460 460
 {
461 461
 	//Add a TrueType or Type1 font
462
-	$family=strtolower($family);
463
-	if($file=='')
464
-		$file=str_replace(' ','',$family).strtolower($style).'.php';
465
-	if($family=='arial')
466
-		$family='helvetica';
467
-	$style=strtoupper($style);
468
-	if($style=='IB')
469
-		$style='BI';
470
-	$fontkey=$family.$style;
471
-	if(isset($this->fonts[$fontkey]))
462
+	$family = strtolower($family);
463
+	if ($file == '')
464
+		$file = str_replace(' ', '', $family) . strtolower($style) . '.php';
465
+	if ($family == 'arial')
466
+		$family = 'helvetica';
467
+	$style = strtoupper($style);
468
+	if ($style == 'IB')
469
+		$style = 'BI';
470
+	$fontkey = $family . $style;
471
+	if (isset($this->fonts[$fontkey]))
472 472
 		return;
473
-	include($this->_getfontpath().$file);
474
-	if(!isset($name))
473
+	include($this->_getfontpath() . $file);
474
+	if (!isset($name))
475 475
 		$this->Error('Could not include font definition file');
476
-	$i=count($this->fonts)+1;
477
-	$this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file);
478
-	if($diff)
476
+	$i = count($this->fonts) + 1;
477
+	$this->fonts[$fontkey] = array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file);
478
+	if ($diff)
479 479
 	{
480 480
 		//Search existing encodings
481
-		$d=0;
482
-		$nb=count($this->diffs);
483
-		for($i=1;$i<=$nb;$i++)
481
+		$d = 0;
482
+		$nb = count($this->diffs);
483
+		for ($i = 1; $i <= $nb; $i++)
484 484
 		{
485
-			if($this->diffs[$i]==$diff)
485
+			if ($this->diffs[$i] == $diff)
486 486
 			{
487
-				$d=$i;
487
+				$d = $i;
488 488
 				break;
489 489
 			}
490 490
 		}
491
-		if($d==0)
491
+		if ($d == 0)
492 492
 		{
493
-			$d=$nb+1;
494
-			$this->diffs[$d]=$diff;
493
+			$d = $nb + 1;
494
+			$this->diffs[$d] = $diff;
495 495
 		}
496
-		$this->fonts[$fontkey]['diff']=$d;
496
+		$this->fonts[$fontkey]['diff'] = $d;
497 497
 	}
498
-	if($file)
498
+	if ($file)
499 499
 	{
500
-		if($type=='TrueType')
501
-			$this->FontFiles[$file]=array('length1'=>$originalsize);
500
+		if ($type == 'TrueType')
501
+			$this->FontFiles[$file] = array('length1'=>$originalsize);
502 502
 		else
503
-			$this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2);
503
+			$this->FontFiles[$file] = array('length1'=>$size1, 'length2'=>$size2);
504 504
 	}
505 505
 }
506 506
 
507
-function SetFont($family, $style='', $size=0)
507
+function SetFont($family, $style = '', $size = 0)
508 508
 {
509 509
 	//Select a font; size given in points
510 510
 	global $fpdf_charwidths;
511 511
 
512
-	$family=strtolower($family);
513
-	if($family=='')
514
-		$family=$this->FontFamily;
515
-	if($family=='arial')
516
-		$family='helvetica';
517
-	elseif($family=='symbol' || $family=='zapfdingbats')
518
-		$style='';
519
-	$style=strtoupper($style);
520
-	if(strpos($style,'U')!==false)
512
+	$family = strtolower($family);
513
+	if ($family == '')
514
+		$family = $this->FontFamily;
515
+	if ($family == 'arial')
516
+		$family = 'helvetica';
517
+	elseif ($family == 'symbol' || $family == 'zapfdingbats')
518
+		$style = '';
519
+	$style = strtoupper($style);
520
+	if (strpos($style, 'U') !== false)
521 521
 	{
522
-		$this->underline=true;
523
-		$style=str_replace('U','',$style);
522
+		$this->underline = true;
523
+		$style = str_replace('U', '', $style);
524 524
 	}
525 525
 	else
526
-		$this->underline=false;
527
-	if($style=='IB')
528
-		$style='BI';
529
-	if($size==0)
530
-		$size=$this->FontSizePt;
526
+		$this->underline = false;
527
+	if ($style == 'IB')
528
+		$style = 'BI';
529
+	if ($size == 0)
530
+		$size = $this->FontSizePt;
531 531
 	//Test if font is already selected
532
-	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
532
+	if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size)
533 533
 		return;
534 534
 	//Test if used for the first time
535
-	$fontkey=$family.$style;
536
-	if(!isset($this->fonts[$fontkey]))
535
+	$fontkey = $family . $style;
536
+	if (!isset($this->fonts[$fontkey]))
537 537
 	{
538 538
 		//Check if one of the standard fonts
539
-		if(isset($this->CoreFonts[$fontkey]))
539
+		if (isset($this->CoreFonts[$fontkey]))
540 540
 		{
541
-			if(!isset($fpdf_charwidths[$fontkey]))
541
+			if (!isset($fpdf_charwidths[$fontkey]))
542 542
 			{
543 543
 				//Load metric file
544
-				$file=$family;
545
-				if($family=='times' || $family=='helvetica')
546
-					$file.=strtolower($style);
547
-				include($this->_getfontpath().$file.'.php');
548
-				if(!isset($fpdf_charwidths[$fontkey]))
544
+				$file = $family;
545
+				if ($family == 'times' || $family == 'helvetica')
546
+					$file .= strtolower($style);
547
+				include($this->_getfontpath() . $file . '.php');
548
+				if (!isset($fpdf_charwidths[$fontkey]))
549 549
 					$this->Error('Could not include font metric file');
550 550
 			}
551
-			$i=count($this->fonts)+1;
552
-			$name=$this->CoreFonts[$fontkey];
553
-			$cw=$fpdf_charwidths[$fontkey];
554
-			$this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw);
551
+			$i = count($this->fonts) + 1;
552
+			$name = $this->CoreFonts[$fontkey];
553
+			$cw = $fpdf_charwidths[$fontkey];
554
+			$this->fonts[$fontkey] = array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw);
555 555
 		}
556 556
 		else
557
-			$this->Error('Undefined font: '.$family.' '.$style);
557
+			$this->Error('Undefined font: ' . $family . ' ' . $style);
558 558
 	}
559 559
 	//Select it
560
-	$this->FontFamily=$family;
561
-	$this->FontStyle=$style;
562
-	$this->FontSizePt=$size;
563
-	$this->FontSize=$size/$this->k;
564
-	$this->CurrentFont=&$this->fonts[$fontkey];
565
-	if($this->page>0)
566
-		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
560
+	$this->FontFamily = $family;
561
+	$this->FontStyle = $style;
562
+	$this->FontSizePt = $size;
563
+	$this->FontSize = $size / $this->k;
564
+	$this->CurrentFont = &$this->fonts[$fontkey];
565
+	if ($this->page > 0)
566
+		$this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
567 567
 }
568 568
 
569 569
 function SetFontSize($size)
570 570
 {
571 571
 	//Set font size in points
572
-	if($this->FontSizePt==$size)
572
+	if ($this->FontSizePt == $size)
573 573
 		return;
574
-	$this->FontSizePt=$size;
575
-	$this->FontSize=$size/$this->k;
576
-	if($this->page>0)
577
-		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
574
+	$this->FontSizePt = $size;
575
+	$this->FontSize = $size / $this->k;
576
+	if ($this->page > 0)
577
+		$this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
578 578
 }
579 579
 
580 580
 function AddLink()
581 581
 {
582 582
 	//Create a new internal link
583
-	$n=count($this->links)+1;
584
-	$this->links[$n]=array(0, 0);
583
+	$n = count($this->links) + 1;
584
+	$this->links[$n] = array(0, 0);
585 585
 	return $n;
586 586
 }
587 587
 
588
-function SetLink($link, $y=0, $page=-1)
588
+function SetLink($link, $y = 0, $page = -1)
589 589
 {
590 590
 	//Set destination of internal link
591
-	if($y==-1)
592
-		$y=$this->y;
593
-	if($page==-1)
594
-		$page=$this->page;
595
-	$this->links[$link]=array($page, $y);
591
+	if ($y == -1)
592
+		$y = $this->y;
593
+	if ($page == -1)
594
+		$page = $this->page;
595
+	$this->links[$link] = array($page, $y);
596 596
 }
597 597
 
598 598
 function Link($x, $y, $w, $h, $link)
599 599
 {
600 600
 	//Put a link on the page
601
-	$this->PageLinks[$this->page][]=array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link);
601
+	$this->PageLinks[$this->page][] = array($x * $this->k, $this->hPt - $y * $this->k, $w * $this->k, $h * $this->k, $link);
602 602
 }
603 603
 
604 604
 function Text($x, $y, $txt)
605 605
 {
606 606
 	//Output a string
607
-	$s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
608
-	if($this->underline && $txt!='')
609
-		$s.=' '.$this->_dounderline($x,$y,$txt);
610
-	if($this->ColorFlag)
611
-		$s='q '.$this->TextColor.' '.$s.' Q';
607
+	$s = sprintf('BT %.2F %.2F Td (%s) Tj ET', $x * $this->k, ($this->h - $y) * $this->k, $this->_escape($txt));
608
+	if ($this->underline && $txt != '')
609
+		$s .= ' ' . $this->_dounderline($x, $y, $txt);
610
+	if ($this->ColorFlag)
611
+		$s = 'q ' . $this->TextColor . ' ' . $s . ' Q';
612 612
 	$this->_out($s);
613 613
 }
614 614
 
@@ -618,268 +618,268 @@  discard block
 block discarded – undo
618 618
 	return $this->AutoPageBreak;
619 619
 }
620 620
 
621
-function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
621
+function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '')
622 622
 {
623 623
 	//Output a cell
624
-	$k=$this->k;
625
-	if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
624
+	$k = $this->k;
625
+	if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
626 626
 	{
627 627
 		//Automatic page break
628
-		$x=$this->x;
629
-		$ws=$this->ws;
630
-		if($ws>0)
628
+		$x = $this->x;
629
+		$ws = $this->ws;
630
+		if ($ws > 0)
631 631
 		{
632
-			$this->ws=0;
632
+			$this->ws = 0;
633 633
 			$this->_out('0 Tw');
634 634
 		}
635
-		$this->AddPage($this->CurOrientation,$this->CurPageFormat);
636
-		$this->x=$x;
637
-		if($ws>0)
635
+		$this->AddPage($this->CurOrientation, $this->CurPageFormat);
636
+		$this->x = $x;
637
+		if ($ws > 0)
638 638
 		{
639
-			$this->ws=$ws;
640
-			$this->_out(sprintf('%.3F Tw',$ws*$k));
639
+			$this->ws = $ws;
640
+			$this->_out(sprintf('%.3F Tw', $ws * $k));
641 641
 		}
642 642
 	}
643
-	if($w==0)
644
-		$w=$this->w-$this->rMargin-$this->x;
645
-	$s='';
646
-	if($fill || $border==1)
643
+	if ($w == 0)
644
+		$w = $this->w - $this->rMargin - $this->x;
645
+	$s = '';
646
+	if ($fill || $border == 1)
647 647
 	{
648
-		if($fill)
649
-			$op=($border==1) ? 'B' : 'f';
648
+		if ($fill)
649
+			$op = ($border == 1) ? 'B' : 'f';
650 650
 		else
651
-			$op='S';
652
-		$s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
651
+			$op = 'S';
652
+		$s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op);
653 653
 	}
654
-	if(is_string($border))
654
+	if (is_string($border))
655 655
 	{
656
-		$x=$this->x;
657
-		$y=$this->y;
658
-		if(strpos($border,'L')!==false)
659
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
660
-		if(strpos($border,'T')!==false)
661
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
662
-		if(strpos($border,'R')!==false)
663
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
664
-		if(strpos($border,'B')!==false)
665
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
656
+		$x = $this->x;
657
+		$y = $this->y;
658
+		if (strpos($border, 'L') !== false)
659
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k);
660
+		if (strpos($border, 'T') !== false)
661
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k);
662
+		if (strpos($border, 'R') !== false)
663
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
664
+		if (strpos($border, 'B') !== false)
665
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
666 666
 	}
667
-	if($txt!=='')
667
+	if ($txt !== '')
668 668
 	{
669
-		if($align=='R')
670
-			$dx=$w-$this->cMargin-$this->GetStringWidth($txt);
671
-		elseif($align=='C')
672
-			$dx=($w-$this->GetStringWidth($txt))/2;
669
+		if ($align == 'R')
670
+			$dx = $w - $this->cMargin - $this->GetStringWidth($txt);
671
+		elseif ($align == 'C')
672
+			$dx = ($w - $this->GetStringWidth($txt)) / 2;
673 673
 		else
674
-			$dx=$this->cMargin;
675
-		if($this->ColorFlag)
676
-			$s.='q '.$this->TextColor.' ';
677
-		$txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
678
-		$s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
679
-		if($this->underline)
680
-			$s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
681
-		if($this->ColorFlag)
682
-			$s.=' Q';
683
-		if($link)
684
-			$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
674
+			$dx = $this->cMargin;
675
+		if ($this->ColorFlag)
676
+			$s .= 'q ' . $this->TextColor . ' ';
677
+		$txt2 = str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt)));
678
+		$s .= sprintf('BT %.2F %.2F Td (%s) Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k, $txt2);
679
+		if ($this->underline)
680
+			$s .= ' ' . $this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt);
681
+		if ($this->ColorFlag)
682
+			$s .= ' Q';
683
+		if ($link)
684
+			$this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link);
685 685
 	}
686
-	if($s)
686
+	if ($s)
687 687
 		$this->_out($s);
688
-	$this->lasth=$h;
689
-	if($ln>0)
688
+	$this->lasth = $h;
689
+	if ($ln > 0)
690 690
 	{
691 691
 		//Go to next line
692
-		$this->y+=$h;
693
-		if($ln==1)
694
-			$this->x=$this->lMargin;
692
+		$this->y += $h;
693
+		if ($ln == 1)
694
+			$this->x = $this->lMargin;
695 695
 	}
696 696
 	else
697
-		$this->x+=$w;
697
+		$this->x += $w;
698 698
 }
699 699
 
700
-function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
700
+function MultiCell($w, $h, $txt, $border = 0, $align = 'J', $fill = false)
701 701
 {
702 702
 	//Output text with automatic or explicit line breaks
703
-	$cw=&$this->CurrentFont['cw'];
704
-	if($w==0)
705
-		$w=$this->w-$this->rMargin-$this->x;
706
-	$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
707
-	$s=str_replace("\r",'',$txt);
708
-	$nb=strlen($s);
709
-	if($nb>0 && $s[$nb-1]=="\n")
703
+	$cw = &$this->CurrentFont['cw'];
704
+	if ($w == 0)
705
+		$w = $this->w - $this->rMargin - $this->x;
706
+	$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
707
+	$s = str_replace("\r", '', $txt);
708
+	$nb = strlen($s);
709
+	if ($nb > 0 && $s[$nb - 1] == "\n")
710 710
 		$nb--;
711
-	$b=0;
712
-	if($border)
711
+	$b = 0;
712
+	if ($border)
713 713
 	{
714
-		if($border==1)
714
+		if ($border == 1)
715 715
 		{
716
-			$border='LTRB';
717
-			$b='LRT';
718
-			$b2='LR';
716
+			$border = 'LTRB';
717
+			$b = 'LRT';
718
+			$b2 = 'LR';
719 719
 		}
720 720
 		else
721 721
 		{
722
-			$b2='';
723
-			if(strpos($border,'L')!==false)
724
-				$b2.='L';
725
-			if(strpos($border,'R')!==false)
726
-				$b2.='R';
727
-			$b=(strpos($border,'T')!==false) ? $b2.'T' : $b2;
722
+			$b2 = '';
723
+			if (strpos($border, 'L') !== false)
724
+				$b2 .= 'L';
725
+			if (strpos($border, 'R') !== false)
726
+				$b2 .= 'R';
727
+			$b = (strpos($border, 'T') !== false) ? $b2 . 'T' : $b2;
728 728
 		}
729 729
 	}
730
-	$sep=-1;
731
-	$i=0;
732
-	$j=0;
733
-	$l=0;
734
-	$ns=0;
735
-	$nl=1;
736
-	while($i<$nb)
730
+	$sep = -1;
731
+	$i = 0;
732
+	$j = 0;
733
+	$l = 0;
734
+	$ns = 0;
735
+	$nl = 1;
736
+	while ($i < $nb)
737 737
 	{
738 738
 		//Get next character
739
-		$c=$s[$i];
740
-		if($c=="\n")
739
+		$c = $s[$i];
740
+		if ($c == "\n")
741 741
 		{
742 742
 			//Explicit line break
743
-			if($this->ws>0)
743
+			if ($this->ws > 0)
744 744
 			{
745
-				$this->ws=0;
745
+				$this->ws = 0;
746 746
 				$this->_out('0 Tw');
747 747
 			}
748
-			$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
748
+			$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
749 749
 			$i++;
750
-			$sep=-1;
751
-			$j=$i;
752
-			$l=0;
753
-			$ns=0;
750
+			$sep = -1;
751
+			$j = $i;
752
+			$l = 0;
753
+			$ns = 0;
754 754
 			$nl++;
755
-			if($border && $nl==2)
756
-				$b=$b2;
755
+			if ($border && $nl == 2)
756
+				$b = $b2;
757 757
 			continue;
758 758
 		}
759
-		if($c==' ')
759
+		if ($c == ' ')
760 760
 		{
761
-			$sep=$i;
762
-			$ls=$l;
761
+			$sep = $i;
762
+			$ls = $l;
763 763
 			$ns++;
764 764
 		}
765
-		$l+=$cw[$c];
766
-		if($l>$wmax)
765
+		$l += $cw[$c];
766
+		if ($l > $wmax)
767 767
 		{
768 768
 			//Automatic line break
769
-			if($sep==-1)
769
+			if ($sep == -1)
770 770
 			{
771
-				if($i==$j)
771
+				if ($i == $j)
772 772
 					$i++;
773
-				if($this->ws>0)
773
+				if ($this->ws > 0)
774 774
 				{
775
-					$this->ws=0;
775
+					$this->ws = 0;
776 776
 					$this->_out('0 Tw');
777 777
 				}
778
-				$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
778
+				$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
779 779
 			}
780 780
 			else
781 781
 			{
782
-				if($align=='J')
782
+				if ($align == 'J')
783 783
 				{
784
-					$this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
785
-					$this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
784
+					$this->ws = ($ns > 1) ? ($wmax - $ls) / 1000 * $this->FontSize / ($ns - 1) : 0;
785
+					$this->_out(sprintf('%.3F Tw', $this->ws * $this->k));
786 786
 				}
787
-				$this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
788
-				$i=$sep+1;
787
+				$this->Cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill);
788
+				$i = $sep + 1;
789 789
 			}
790
-			$sep=-1;
791
-			$j=$i;
792
-			$l=0;
793
-			$ns=0;
790
+			$sep = -1;
791
+			$j = $i;
792
+			$l = 0;
793
+			$ns = 0;
794 794
 			$nl++;
795
-			if($border && $nl==2)
796
-				$b=$b2;
795
+			if ($border && $nl == 2)
796
+				$b = $b2;
797 797
 		}
798 798
 		else
799 799
 			$i++;
800 800
 	}
801 801
 	//Last chunk
802
-	if($this->ws>0)
802
+	if ($this->ws > 0)
803 803
 	{
804
-		$this->ws=0;
804
+		$this->ws = 0;
805 805
 		$this->_out('0 Tw');
806 806
 	}
807
-	if($border && strpos($border,'B')!==false)
808
-		$b.='B';
809
-	$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
810
-	$this->x=$this->lMargin;
807
+	if ($border && strpos($border, 'B') !== false)
808
+		$b .= 'B';
809
+	$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
810
+	$this->x = $this->lMargin;
811 811
 }
812 812
 
813
-function Write($h, $txt, $link='')
813
+function Write($h, $txt, $link = '')
814 814
 {
815 815
 	//Output text in flowing mode
816
-	$cw=&$this->CurrentFont['cw'];
817
-	$w=$this->w-$this->rMargin-$this->x;
818
-	$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
819
-	$s=str_replace("\r",'',$txt);
820
-	$nb=strlen($s);
821
-	$sep=-1;
822
-	$i=0;
823
-	$j=0;
824
-	$l=0;
825
-	$nl=1;
826
-	while($i<$nb)
816
+	$cw = &$this->CurrentFont['cw'];
817
+	$w = $this->w - $this->rMargin - $this->x;
818
+	$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
819
+	$s = str_replace("\r", '', $txt);
820
+	$nb = strlen($s);
821
+	$sep = -1;
822
+	$i = 0;
823
+	$j = 0;
824
+	$l = 0;
825
+	$nl = 1;
826
+	while ($i < $nb)
827 827
 	{
828 828
 		//Get next character
829
-		$c=$s[$i];
830
-		if($c=="\n")
829
+		$c = $s[$i];
830
+		if ($c == "\n")
831 831
 		{
832 832
 			//Explicit line break
833
-			$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
833
+			$this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
834 834
 			$i++;
835
-			$sep=-1;
836
-			$j=$i;
837
-			$l=0;
838
-			if($nl==1)
835
+			$sep = -1;
836
+			$j = $i;
837
+			$l = 0;
838
+			if ($nl == 1)
839 839
 			{
840
-				$this->x=$this->lMargin;
841
-				$w=$this->w-$this->rMargin-$this->x;
842
-				$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
840
+				$this->x = $this->lMargin;
841
+				$w = $this->w - $this->rMargin - $this->x;
842
+				$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
843 843
 			}
844 844
 			$nl++;
845 845
 			continue;
846 846
 		}
847
-		if($c==' ')
848
-			$sep=$i;
849
-		$l+=$cw[$c];
850
-		if($l>$wmax)
847
+		if ($c == ' ')
848
+			$sep = $i;
849
+		$l += $cw[$c];
850
+		if ($l > $wmax)
851 851
 		{
852 852
 			//Automatic line break
853
-			if($sep==-1)
853
+			if ($sep == -1)
854 854
 			{
855
-				if($this->x>$this->lMargin)
855
+				if ($this->x > $this->lMargin)
856 856
 				{
857 857
 					//Move to next line
858
-					$this->x=$this->lMargin;
859
-					$this->y+=$h;
860
-					$w=$this->w-$this->rMargin-$this->x;
861
-					$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
858
+					$this->x = $this->lMargin;
859
+					$this->y += $h;
860
+					$w = $this->w - $this->rMargin - $this->x;
861
+					$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
862 862
 					$i++;
863 863
 					$nl++;
864 864
 					continue;
865 865
 				}
866
-				if($i==$j)
866
+				if ($i == $j)
867 867
 					$i++;
868
-				$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
868
+				$this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
869 869
 			}
870 870
 			else
871 871
 			{
872
-				$this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
873
-				$i=$sep+1;
872
+				$this->Cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', 0, $link);
873
+				$i = $sep + 1;
874 874
 			}
875
-			$sep=-1;
876
-			$j=$i;
877
-			$l=0;
878
-			if($nl==1)
875
+			$sep = -1;
876
+			$j = $i;
877
+			$l = 0;
878
+			if ($nl == 1)
879 879
 			{
880
-				$this->x=$this->lMargin;
881
-				$w=$this->w-$this->rMargin-$this->x;
882
-				$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
880
+				$this->x = $this->lMargin;
881
+				$w = $this->w - $this->rMargin - $this->x;
882
+				$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
883 883
 			}
884 884
 			$nl++;
885 885
 		}
@@ -887,74 +887,74 @@  discard block
 block discarded – undo
887 887
 			$i++;
888 888
 	}
889 889
 	//Last chunk
890
-	if($i!=$j)
891
-		$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
890
+	if ($i != $j)
891
+		$this->Cell($l / 1000 * $this->FontSize, $h, substr($s, $j), 0, 0, '', 0, $link);
892 892
 }
893 893
 
894
-function Ln($h=null)
894
+function Ln($h = null)
895 895
 {
896 896
 	//Line feed; default value is last cell height
897
-	$this->x=$this->lMargin;
898
-	if($h===null)
899
-		$this->y+=$this->lasth;
897
+	$this->x = $this->lMargin;
898
+	if ($h === null)
899
+		$this->y += $this->lasth;
900 900
 	else
901
-		$this->y+=$h;
901
+		$this->y += $h;
902 902
 }
903 903
 
904
-function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
904
+function Image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '')
905 905
 {
906 906
 	//Put an image on the page
907
-	if(!isset($this->images[$file]))
907
+	if (!isset($this->images[$file]))
908 908
 	{
909 909
 		//First use of this image, get info
910
-		if($type=='')
910
+		if ($type == '')
911 911
 		{
912
-			$pos=strrpos($file,'.');
913
-			if(!$pos)
914
-				$this->Error('Image file has no extension and no type was specified: '.$file);
915
-			$type=substr($file,$pos+1);
912
+			$pos = strrpos($file, '.');
913
+			if (!$pos)
914
+				$this->Error('Image file has no extension and no type was specified: ' . $file);
915
+			$type = substr($file, $pos + 1);
916 916
 		}
917
-		$type=strtolower($type);
918
-		if($type=='jpeg')
919
-			$type='jpg';
920
-		$mtd='_parse'.$type;
921
-		if(!method_exists($this,$mtd))
922
-			$this->Error('Unsupported image type: '.$type);
923
-		$info=$this->$mtd($file);
924
-		$info['i']=count($this->images)+1;
925
-		$this->images[$file]=$info;
917
+		$type = strtolower($type);
918
+		if ($type == 'jpeg')
919
+			$type = 'jpg';
920
+		$mtd = '_parse' . $type;
921
+		if (!method_exists($this, $mtd))
922
+			$this->Error('Unsupported image type: ' . $type);
923
+		$info = $this->$mtd($file);
924
+		$info['i'] = count($this->images) + 1;
925
+		$this->images[$file] = $info;
926 926
 	}
927 927
 	else
928
-		$info=$this->images[$file];
928
+		$info = $this->images[$file];
929 929
 	//Automatic width and height calculation if needed
930
-	if($w==0 && $h==0)
930
+	if ($w == 0 && $h == 0)
931 931
 	{
932 932
 		//Put image at 72 dpi
933
-		$w=$info['w']/$this->k;
934
-		$h=$info['h']/$this->k;
933
+		$w = $info['w'] / $this->k;
934
+		$h = $info['h'] / $this->k;
935 935
 	}
936
-	elseif($w==0)
937
-		$w=$h*$info['w']/$info['h'];
938
-	elseif($h==0)
939
-		$h=$w*$info['h']/$info['w'];
936
+	elseif ($w == 0)
937
+		$w = $h * $info['w'] / $info['h'];
938
+	elseif ($h == 0)
939
+		$h = $w * $info['h'] / $info['w'];
940 940
 	//Flowing mode
941
-	if($y===null)
941
+	if ($y === null)
942 942
 	{
943
-		if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
943
+		if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
944 944
 		{
945 945
 			//Automatic page break
946
-			$x2=$this->x;
947
-			$this->AddPage($this->CurOrientation,$this->CurPageFormat);
948
-			$this->x=$x2;
946
+			$x2 = $this->x;
947
+			$this->AddPage($this->CurOrientation, $this->CurPageFormat);
948
+			$this->x = $x2;
949 949
 		}
950
-		$y=$this->y;
951
-		$this->y+=$h;
950
+		$y = $this->y;
951
+		$this->y += $h;
952 952
 	}
953
-	if($x===null)
954
-		$x=$this->x;
955
-	$this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
956
-	if($link)
957
-		$this->Link($x,$y,$w,$h,$link);
953
+	if ($x === null)
954
+		$x = $this->x;
955
+	$this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q', $w * $this->k, $h * $this->k, $x * $this->k, ($this->h - ($y + $h)) * $this->k, $info['i']));
956
+	if ($link)
957
+		$this->Link($x, $y, $w, $h, $link);
958 958
 }
959 959
 
960 960
 function GetX()
@@ -966,10 +966,10 @@  discard block
 block discarded – undo
966 966
 function SetX($x)
967 967
 {
968 968
 	//Set x position
969
-	if($x>=0)
970
-		$this->x=$x;
969
+	if ($x >= 0)
970
+		$this->x = $x;
971 971
 	else
972
-		$this->x=$this->w+$x;
972
+		$this->x = $this->w + $x;
973 973
 }
974 974
 
975 975
 function GetY()
@@ -981,11 +981,11 @@  discard block
 block discarded – undo
981 981
 function SetY($y)
982 982
 {
983 983
 	//Set y position and reset x
984
-	$this->x=$this->lMargin;
985
-	if($y>=0)
986
-		$this->y=$y;
984
+	$this->x = $this->lMargin;
985
+	if ($y >= 0)
986
+		$this->y = $y;
987 987
 	else
988
-		$this->y=$this->h+$y;
988
+		$this->y = $this->h + $y;
989 989
 }
990 990
 
991 991
 function SetXY($x, $y)
@@ -995,69 +995,69 @@  discard block
 block discarded – undo
995 995
 	$this->SetX($x);
996 996
 }
997 997
 
998
-function Output($name='', $dest='')
998
+function Output($name = '', $dest = '')
999 999
 {
1000 1000
 	//Output PDF to some destination
1001
-	if($this->state<3)
1001
+	if ($this->state < 3)
1002 1002
 		$this->Close();
1003
-	$dest=strtoupper($dest);
1004
-	if($dest=='')
1003
+	$dest = strtoupper($dest);
1004
+	if ($dest == '')
1005 1005
 	{
1006
-		if($name=='')
1006
+		if ($name == '')
1007 1007
 		{
1008
-			$name='doc.pdf';
1009
-			$dest='I';
1008
+			$name = 'doc.pdf';
1009
+			$dest = 'I';
1010 1010
 		}
1011 1011
 		else
1012
-			$dest='F';
1012
+			$dest = 'F';
1013 1013
 	}
1014
-	switch($dest)
1014
+	switch ($dest)
1015 1015
 	{
1016 1016
 		case 'I':
1017 1017
 			//Send to standard output
1018
-			if(ob_get_length())
1018
+			if (ob_get_length())
1019 1019
 				$this->Error('Some data has already been output, can\'t send PDF file');
1020
-			if(php_sapi_name()!='cli')
1020
+			if (php_sapi_name() != 'cli')
1021 1021
 			{
1022 1022
 				//We send to a browser
1023 1023
 				header('Content-Type: application/pdf');
1024
-				if(headers_sent())
1024
+				if (headers_sent())
1025 1025
 					$this->Error('Some data has already been output, can\'t send PDF file');
1026
-				header('Content-Length: '.strlen($this->buffer));
1027
-				header('Content-Disposition: inline; filename="'.$name.'"');
1026
+				header('Content-Length: ' . strlen($this->buffer));
1027
+				header('Content-Disposition: inline; filename="' . $name . '"');
1028 1028
 				header('Cache-Control: private, max-age=0, must-revalidate');
1029 1029
 				header('Pragma: public');
1030
-				ini_set('zlib.output_compression','0');
1030
+				ini_set('zlib.output_compression', '0');
1031 1031
 			}
1032 1032
 			echo $this->buffer;
1033 1033
 			break;
1034 1034
 		case 'D':
1035 1035
 			//Download file
1036
-			if(ob_get_length())
1036
+			if (ob_get_length())
1037 1037
 				$this->Error('Some data has already been output, can\'t send PDF file');
1038 1038
 			header('Content-Type: application/x-download');
1039
-			if(headers_sent())
1039
+			if (headers_sent())
1040 1040
 				$this->Error('Some data has already been output, can\'t send PDF file');
1041
-			header('Content-Length: '.strlen($this->buffer));
1042
-			header('Content-Disposition: attachment; filename="'.$name.'"');
1041
+			header('Content-Length: ' . strlen($this->buffer));
1042
+			header('Content-Disposition: attachment; filename="' . $name . '"');
1043 1043
 			header('Cache-Control: private, max-age=0, must-revalidate');
1044 1044
 			header('Pragma: public');
1045
-			ini_set('zlib.output_compression','0');
1045
+			ini_set('zlib.output_compression', '0');
1046 1046
 			echo $this->buffer;
1047 1047
 			break;
1048 1048
 		case 'F':
1049 1049
 			//Save to local file
1050
-			$f=fopen($name,'wb');
1051
-			if(!$f)
1052
-				$this->Error('Unable to create output file: '.$name);
1053
-			fwrite($f,$this->buffer,strlen($this->buffer));
1050
+			$f = fopen($name, 'wb');
1051
+			if (!$f)
1052
+				$this->Error('Unable to create output file: ' . $name);
1053
+			fwrite($f, $this->buffer, strlen($this->buffer));
1054 1054
 			fclose($f);
1055 1055
 			break;
1056 1056
 		case 'S':
1057 1057
 			//Return as a string
1058 1058
 			return $this->buffer;
1059 1059
 		default:
1060
-			$this->Error('Incorrect output destination: '.$dest);
1060
+			$this->Error('Incorrect output destination: ' . $dest);
1061 1061
 	}
1062 1062
 	return '';
1063 1063
 }
@@ -1070,124 +1070,124 @@  discard block
 block discarded – undo
1070 1070
 function _dochecks()
1071 1071
 {
1072 1072
 	//Check availability of %F
1073
-	if(sprintf('%.1F',1.0)!='1.0')
1073
+	if (sprintf('%.1F', 1.0) != '1.0')
1074 1074
 		$this->Error('This version of PHP is not supported');
1075 1075
 	//Check mbstring overloading
1076
-	if(ini_get('mbstring.func_overload') & 2)
1076
+	if (ini_get('mbstring.func_overload') & 2)
1077 1077
 		$this->Error('mbstring overloading must be disabled');
1078 1078
 	//Disable runtime magic quotes
1079
-	if(get_magic_quotes_runtime())
1079
+	if (get_magic_quotes_runtime())
1080 1080
 		@set_magic_quotes_runtime(0);
1081 1081
 }
1082 1082
 
1083 1083
 function _getpageformat($format)
1084 1084
 {
1085
-	$format=strtolower($format);
1086
-	if(!isset($this->PageFormats[$format]))
1087
-		$this->Error('Unknown page format: '.$format);
1088
-	$a=$this->PageFormats[$format];
1089
-	return array($a[0]/$this->k, $a[1]/$this->k);
1085
+	$format = strtolower($format);
1086
+	if (!isset($this->PageFormats[$format]))
1087
+		$this->Error('Unknown page format: ' . $format);
1088
+	$a = $this->PageFormats[$format];
1089
+	return array($a[0] / $this->k, $a[1] / $this->k);
1090 1090
 }
1091 1091
 
1092 1092
 function _getfontpath()
1093 1093
 {
1094
-	if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font'))
1095
-		define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
1094
+	if (!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__) . '/font'))
1095
+		define('FPDF_FONTPATH', dirname(__FILE__) . '/font/');
1096 1096
 	return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
1097 1097
 }
1098 1098
 
1099 1099
 function _beginpage($orientation, $format)
1100 1100
 {
1101 1101
 	$this->page++;
1102
-	$this->pages[$this->page]='';
1103
-	$this->state=2;
1104
-	$this->x=$this->lMargin;
1105
-	$this->y=$this->tMargin;
1106
-	$this->FontFamily='';
1102
+	$this->pages[$this->page] = '';
1103
+	$this->state = 2;
1104
+	$this->x = $this->lMargin;
1105
+	$this->y = $this->tMargin;
1106
+	$this->FontFamily = '';
1107 1107
 	//Check page size
1108
-	if($orientation=='')
1109
-		$orientation=$this->DefOrientation;
1108
+	if ($orientation == '')
1109
+		$orientation = $this->DefOrientation;
1110 1110
 	else
1111
-		$orientation=strtoupper($orientation[0]);
1112
-	if($format=='')
1113
-		$format=$this->DefPageFormat;
1111
+		$orientation = strtoupper($orientation[0]);
1112
+	if ($format == '')
1113
+		$format = $this->DefPageFormat;
1114 1114
 	else
1115 1115
 	{
1116
-		if(is_string($format))
1117
-			$format=$this->_getpageformat($format);
1116
+		if (is_string($format))
1117
+			$format = $this->_getpageformat($format);
1118 1118
 	}
1119
-	if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1])
1119
+	if ($orientation != $this->CurOrientation || $format[0] != $this->CurPageFormat[0] || $format[1] != $this->CurPageFormat[1])
1120 1120
 	{
1121 1121
 		//New size
1122
-		if($orientation=='P')
1122
+		if ($orientation == 'P')
1123 1123
 		{
1124
-			$this->w=$format[0];
1125
-			$this->h=$format[1];
1124
+			$this->w = $format[0];
1125
+			$this->h = $format[1];
1126 1126
 		}
1127 1127
 		else
1128 1128
 		{
1129
-			$this->w=$format[1];
1130
-			$this->h=$format[0];
1129
+			$this->w = $format[1];
1130
+			$this->h = $format[0];
1131 1131
 		}
1132
-		$this->wPt=$this->w*$this->k;
1133
-		$this->hPt=$this->h*$this->k;
1134
-		$this->PageBreakTrigger=$this->h-$this->bMargin;
1135
-		$this->CurOrientation=$orientation;
1136
-		$this->CurPageFormat=$format;
1132
+		$this->wPt = $this->w * $this->k;
1133
+		$this->hPt = $this->h * $this->k;
1134
+		$this->PageBreakTrigger = $this->h - $this->bMargin;
1135
+		$this->CurOrientation = $orientation;
1136
+		$this->CurPageFormat = $format;
1137 1137
 	}
1138
-	if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1])
1139
-		$this->PageSizes[$this->page]=array($this->wPt, $this->hPt);
1138
+	if ($orientation != $this->DefOrientation || $format[0] != $this->DefPageFormat[0] || $format[1] != $this->DefPageFormat[1])
1139
+		$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
1140 1140
 }
1141 1141
 
1142 1142
 function _endpage()
1143 1143
 {
1144
-	$this->state=1;
1144
+	$this->state = 1;
1145 1145
 }
1146 1146
 
1147 1147
 function _escape($s)
1148 1148
 {
1149 1149
 	//Escape special characters in strings
1150
-	$s=str_replace('\\','\\\\',$s);
1151
-	$s=str_replace('(','\\(',$s);
1152
-	$s=str_replace(')','\\)',$s);
1153
-	$s=str_replace("\r",'\\r',$s);
1150
+	$s = str_replace('\\', '\\\\', $s);
1151
+	$s = str_replace('(', '\\(', $s);
1152
+	$s = str_replace(')', '\\)', $s);
1153
+	$s = str_replace("\r", '\\r', $s);
1154 1154
 	return $s;
1155 1155
 }
1156 1156
 
1157 1157
 function _textstring($s)
1158 1158
 {
1159 1159
 	//Format a text string
1160
-	return '('.$this->_escape($s).')';
1160
+	return '(' . $this->_escape($s) . ')';
1161 1161
 }
1162 1162
 
1163 1163
 function _UTF8toUTF16($s)
1164 1164
 {
1165 1165
 	//Convert UTF-8 to UTF-16BE with BOM
1166
-	$res="\xFE\xFF";
1167
-	$nb=strlen($s);
1168
-	$i=0;
1169
-	while($i<$nb)
1166
+	$res = "\xFE\xFF";
1167
+	$nb = strlen($s);
1168
+	$i = 0;
1169
+	while ($i < $nb)
1170 1170
 	{
1171
-		$c1=ord($s[$i++]);
1172
-		if($c1>=224)
1171
+		$c1 = ord($s[$i++]);
1172
+		if ($c1 >= 224)
1173 1173
 		{
1174 1174
 			//3-byte character
1175
-			$c2=ord($s[$i++]);
1176
-			$c3=ord($s[$i++]);
1177
-			$res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
1178
-			$res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
1175
+			$c2 = ord($s[$i++]);
1176
+			$c3 = ord($s[$i++]);
1177
+			$res .= chr((($c1 & 0x0F) << 4) + (($c2 & 0x3C) >> 2));
1178
+			$res .= chr((($c2 & 0x03) << 6) + ($c3 & 0x3F));
1179 1179
 		}
1180
-		elseif($c1>=192)
1180
+		elseif ($c1 >= 192)
1181 1181
 		{
1182 1182
 			//2-byte character
1183
-			$c2=ord($s[$i++]);
1184
-			$res.=chr(($c1 & 0x1C)>>2);
1185
-			$res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
1183
+			$c2 = ord($s[$i++]);
1184
+			$res .= chr(($c1 & 0x1C) >> 2);
1185
+			$res .= chr((($c1 & 0x03) << 6) + ($c2 & 0x3F));
1186 1186
 		}
1187 1187
 		else
1188 1188
 		{
1189 1189
 			//Single-byte character
1190
-			$res.="\0".chr($c1);
1190
+			$res .= "\0" . chr($c1);
1191 1191
 		}
1192 1192
 	}
1193 1193
 	return $res;
@@ -1196,32 +1196,32 @@  discard block
 block discarded – undo
1196 1196
 function _dounderline($x, $y, $txt)
1197 1197
 {
1198 1198
 	//Underline text
1199
-	$up=$this->CurrentFont['up'];
1200
-	$ut=$this->CurrentFont['ut'];
1201
-	$w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');
1202
-	return sprintf('%.2F %.2F %.2F %.2F re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt);
1199
+	$up = $this->CurrentFont['up'];
1200
+	$ut = $this->CurrentFont['ut'];
1201
+	$w = $this->GetStringWidth($txt) + $this->ws * substr_count($txt, ' ');
1202
+	return sprintf('%.2F %.2F %.2F %.2F re f', $x * $this->k, ($this->h - ($y - $up / 1000 * $this->FontSize)) * $this->k, $w * $this->k, -$ut / 1000 * $this->FontSizePt);
1203 1203
 }
1204 1204
 
1205 1205
 function _parsejpg($file)
1206 1206
 {
1207 1207
 	//Extract info from a JPEG file
1208
-	$a=GetImageSize($file);
1209
-	if(!$a)
1210
-		$this->Error('Missing or incorrect image file: '.$file);
1211
-	if($a[2]!=2)
1212
-		$this->Error('Not a JPEG file: '.$file);
1213
-	if(!isset($a['channels']) || $a['channels']==3)
1214
-		$colspace='DeviceRGB';
1215
-	elseif($a['channels']==4)
1216
-		$colspace='DeviceCMYK';
1208
+	$a = GetImageSize($file);
1209
+	if (!$a)
1210
+		$this->Error('Missing or incorrect image file: ' . $file);
1211
+	if ($a[2] != 2)
1212
+		$this->Error('Not a JPEG file: ' . $file);
1213
+	if (!isset($a['channels']) || $a['channels'] == 3)
1214
+		$colspace = 'DeviceRGB';
1215
+	elseif ($a['channels'] == 4)
1216
+		$colspace = 'DeviceCMYK';
1217 1217
 	else
1218
-		$colspace='DeviceGray';
1219
-	$bpc=isset($a['bits']) ? $a['bits'] : 8;
1218
+		$colspace = 'DeviceGray';
1219
+	$bpc = isset($a['bits']) ? $a['bits'] : 8;
1220 1220
 	//Read whole file
1221
-	$f=fopen($file,'rb');
1222
-	$data='';
1223
-	while(!feof($f))
1224
-		$data.=fread($f,8192);
1221
+	$f = fopen($file, 'rb');
1222
+	$data = '';
1223
+	while (!feof($f))
1224
+		$data .= fread($f, 8192);
1225 1225
 	fclose($f);
1226 1226
 	return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
1227 1227
 }
@@ -1229,82 +1229,82 @@  discard block
 block discarded – undo
1229 1229
 function _parsepng($file)
1230 1230
 {
1231 1231
 	//Extract info from a PNG file
1232
-	$f=fopen($file,'rb');
1233
-	if(!$f)
1234
-		$this->Error('Can\'t open image file: '.$file);
1232
+	$f = fopen($file, 'rb');
1233
+	if (!$f)
1234
+		$this->Error('Can\'t open image file: ' . $file);
1235 1235
 	//Check signature
1236
-	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1237
-		$this->Error('Not a PNG file: '.$file);
1236
+	if ($this->_readstream($f, 8) != chr(137) . 'PNG' . chr(13) . chr(10) . chr(26) . chr(10))
1237
+		$this->Error('Not a PNG file: ' . $file);
1238 1238
 	//Read header chunk
1239
-	$this->_readstream($f,4);
1240
-	if($this->_readstream($f,4)!='IHDR')
1241
-		$this->Error('Incorrect PNG file: '.$file);
1242
-	$w=$this->_readint($f);
1243
-	$h=$this->_readint($f);
1244
-	$bpc=ord($this->_readstream($f,1));
1245
-	if($bpc>8)
1246
-		$this->Error('16-bit depth not supported: '.$file);
1247
-	$ct=ord($this->_readstream($f,1));
1248
-	if($ct==0)
1249
-		$colspace='DeviceGray';
1250
-	elseif($ct==2)
1251
-		$colspace='DeviceRGB';
1252
-	elseif($ct==3)
1253
-		$colspace='Indexed';
1239
+	$this->_readstream($f, 4);
1240
+	if ($this->_readstream($f, 4) != 'IHDR')
1241
+		$this->Error('Incorrect PNG file: ' . $file);
1242
+	$w = $this->_readint($f);
1243
+	$h = $this->_readint($f);
1244
+	$bpc = ord($this->_readstream($f, 1));
1245
+	if ($bpc > 8)
1246
+		$this->Error('16-bit depth not supported: ' . $file);
1247
+	$ct = ord($this->_readstream($f, 1));
1248
+	if ($ct == 0)
1249
+		$colspace = 'DeviceGray';
1250
+	elseif ($ct == 2)
1251
+		$colspace = 'DeviceRGB';
1252
+	elseif ($ct == 3)
1253
+		$colspace = 'Indexed';
1254 1254
 	else
1255
-		$this->Error('Alpha channel not supported: '.$file);
1256
-	if(ord($this->_readstream($f,1))!=0)
1257
-		$this->Error('Unknown compression method: '.$file);
1258
-	if(ord($this->_readstream($f,1))!=0)
1259
-		$this->Error('Unknown filter method: '.$file);
1260
-	if(ord($this->_readstream($f,1))!=0)
1261
-		$this->Error('Interlacing not supported: '.$file);
1262
-	$this->_readstream($f,4);
1263
-	$parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';
1255
+		$this->Error('Alpha channel not supported: ' . $file);
1256
+	if (ord($this->_readstream($f, 1)) != 0)
1257
+		$this->Error('Unknown compression method: ' . $file);
1258
+	if (ord($this->_readstream($f, 1)) != 0)
1259
+		$this->Error('Unknown filter method: ' . $file);
1260
+	if (ord($this->_readstream($f, 1)) != 0)
1261
+		$this->Error('Interlacing not supported: ' . $file);
1262
+	$this->_readstream($f, 4);
1263
+	$parms = '/DecodeParms <</Predictor 15 /Colors ' . ($ct == 2 ? 3 : 1) . ' /BitsPerComponent ' . $bpc . ' /Columns ' . $w . '>>';
1264 1264
 	//Scan chunks looking for palette, transparency and image data
1265
-	$pal='';
1266
-	$trns='';
1267
-	$data='';
1265
+	$pal = '';
1266
+	$trns = '';
1267
+	$data = '';
1268 1268
 	do
1269 1269
 	{
1270
-		$n=$this->_readint($f);
1271
-		$type=$this->_readstream($f,4);
1272
-		if($type=='PLTE')
1270
+		$n = $this->_readint($f);
1271
+		$type = $this->_readstream($f, 4);
1272
+		if ($type == 'PLTE')
1273 1273
 		{
1274 1274
 			//Read palette
1275
-			$pal=$this->_readstream($f,$n);
1276
-			$this->_readstream($f,4);
1275
+			$pal = $this->_readstream($f, $n);
1276
+			$this->_readstream($f, 4);
1277 1277
 		}
1278
-		elseif($type=='tRNS')
1278
+		elseif ($type == 'tRNS')
1279 1279
 		{
1280 1280
 			//Read transparency info
1281
-			$t=$this->_readstream($f,$n);
1282
-			if($ct==0)
1283
-				$trns=array(ord(substr($t,1,1)));
1284
-			elseif($ct==2)
1285
-				$trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
1281
+			$t = $this->_readstream($f, $n);
1282
+			if ($ct == 0)
1283
+				$trns = array(ord(substr($t, 1, 1)));
1284
+			elseif ($ct == 2)
1285
+				$trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1)));
1286 1286
 			else
1287 1287
 			{
1288
-				$pos=strpos($t,chr(0));
1289
-				if($pos!==false)
1290
-					$trns=array($pos);
1288
+				$pos = strpos($t, chr(0));
1289
+				if ($pos !== false)
1290
+					$trns = array($pos);
1291 1291
 			}
1292
-			$this->_readstream($f,4);
1292
+			$this->_readstream($f, 4);
1293 1293
 		}
1294
-		elseif($type=='IDAT')
1294
+		elseif ($type == 'IDAT')
1295 1295
 		{
1296 1296
 			//Read image data block
1297
-			$data.=$this->_readstream($f,$n);
1298
-			$this->_readstream($f,4);
1297
+			$data .= $this->_readstream($f, $n);
1298
+			$this->_readstream($f, 4);
1299 1299
 		}
1300
-		elseif($type=='IEND')
1300
+		elseif ($type == 'IEND')
1301 1301
 			break;
1302 1302
 		else
1303
-			$this->_readstream($f,$n+4);
1303
+			$this->_readstream($f, $n + 4);
1304 1304
 	}
1305
-	while($n);
1306
-	if($colspace=='Indexed' && empty($pal))
1307
-		$this->Error('Missing palette in '.$file);
1305
+	while ($n);
1306
+	if ($colspace == 'Indexed' && empty($pal))
1307
+		$this->Error('Missing palette in ' . $file);
1308 1308
 	fclose($f);
1309 1309
 	return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data);
1310 1310
 }
@@ -1312,16 +1312,16 @@  discard block
 block discarded – undo
1312 1312
 function _readstream($f, $n)
1313 1313
 {
1314 1314
 	//Read n bytes from stream
1315
-	$res='';
1316
-	while($n>0 && !feof($f))
1315
+	$res = '';
1316
+	while ($n > 0 && !feof($f))
1317 1317
 	{
1318
-		$s=fread($f,$n);
1319
-		if($s===false)
1318
+		$s = fread($f, $n);
1319
+		if ($s === false)
1320 1320
 			$this->Error('Error while reading stream');
1321
-		$n-=strlen($s);
1322
-		$res.=$s;
1321
+		$n -= strlen($s);
1322
+		$res .= $s;
1323 1323
 	}
1324
-	if($n>0)
1324
+	if ($n > 0)
1325 1325
 		$this->Error('Unexpected end of stream');
1326 1326
 	return $res;
1327 1327
 }
@@ -1329,28 +1329,28 @@  discard block
 block discarded – undo
1329 1329
 function _readint($f)
1330 1330
 {
1331 1331
 	//Read a 4-byte integer from stream
1332
-	$a=unpack('Ni',$this->_readstream($f,4));
1332
+	$a = unpack('Ni', $this->_readstream($f, 4));
1333 1333
 	return $a['i'];
1334 1334
 }
1335 1335
 
1336 1336
 function _parsegif($file)
1337 1337
 {
1338 1338
 	//Extract info from a GIF file (via PNG conversion)
1339
-	if(!function_exists('imagepng'))
1339
+	if (!function_exists('imagepng'))
1340 1340
 		$this->Error('GD extension is required for GIF support');
1341
-	if(!function_exists('imagecreatefromgif'))
1341
+	if (!function_exists('imagecreatefromgif'))
1342 1342
 		$this->Error('GD has no GIF read support');
1343
-	$im=imagecreatefromgif($file);
1344
-	if(!$im)
1345
-		$this->Error('Missing or incorrect image file: '.$file);
1346
-	imageinterlace($im,0);
1347
-	$tmp=tempnam('.','gif');
1348
-	if(!$tmp)
1343
+	$im = imagecreatefromgif($file);
1344
+	if (!$im)
1345
+		$this->Error('Missing or incorrect image file: ' . $file);
1346
+	imageinterlace($im, 0);
1347
+	$tmp = tempnam('.', 'gif');
1348
+	if (!$tmp)
1349 1349
 		$this->Error('Unable to create a temporary file');
1350
-	if(!imagepng($im,$tmp))
1350
+	if (!imagepng($im, $tmp))
1351 1351
 		$this->Error('Error while saving to temporary file');
1352 1352
 	imagedestroy($im);
1353
-	$info=$this->_parsepng($tmp);
1353
+	$info = $this->_parsepng($tmp);
1354 1354
 	unlink($tmp);
1355 1355
 	return $info;
1356 1356
 }
@@ -1359,8 +1359,8 @@  discard block
 block discarded – undo
1359 1359
 {
1360 1360
 	//Begin a new object
1361 1361
 	$this->n++;
1362
-	$this->offsets[$this->n]=strlen($this->buffer);
1363
-	$this->_out($this->n.' 0 obj');
1362
+	$this->offsets[$this->n] = strlen($this->buffer);
1363
+	$this->_out($this->n . ' 0 obj');
1364 1364
 }
1365 1365
 
1366 1366
 function _putstream($s)
@@ -1373,162 +1373,162 @@  discard block
 block discarded – undo
1373 1373
 function _out($s)
1374 1374
 {
1375 1375
 	//Add a line to the document
1376
-	if($this->state==2)
1377
-		$this->pages[$this->page].=$s."\n";
1376
+	if ($this->state == 2)
1377
+		$this->pages[$this->page] .= $s . "\n";
1378 1378
 	else
1379
-		$this->buffer.=$s."\n";
1379
+		$this->buffer .= $s . "\n";
1380 1380
 }
1381 1381
 
1382 1382
 function _putpages()
1383 1383
 {
1384
-	$nb=$this->page;
1385
-	if(!empty($this->AliasNbPages))
1384
+	$nb = $this->page;
1385
+	if (!empty($this->AliasNbPages))
1386 1386
 	{
1387 1387
 		//Replace number of pages
1388
-		for($n=1;$n<=$nb;$n++)
1389
-			$this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
1388
+		for ($n = 1; $n <= $nb; $n++)
1389
+			$this->pages[$n] = str_replace($this->AliasNbPages, $nb, $this->pages[$n]);
1390 1390
 	}
1391
-	if($this->DefOrientation=='P')
1391
+	if ($this->DefOrientation == 'P')
1392 1392
 	{
1393
-		$wPt=$this->DefPageFormat[0]*$this->k;
1394
-		$hPt=$this->DefPageFormat[1]*$this->k;
1393
+		$wPt = $this->DefPageFormat[0] * $this->k;
1394
+		$hPt = $this->DefPageFormat[1] * $this->k;
1395 1395
 	}
1396 1396
 	else
1397 1397
 	{
1398
-		$wPt=$this->DefPageFormat[1]*$this->k;
1399
-		$hPt=$this->DefPageFormat[0]*$this->k;
1398
+		$wPt = $this->DefPageFormat[1] * $this->k;
1399
+		$hPt = $this->DefPageFormat[0] * $this->k;
1400 1400
 	}
1401
-	$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
1402
-	for($n=1;$n<=$nb;$n++)
1401
+	$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1402
+	for ($n = 1; $n <= $nb; $n++)
1403 1403
 	{
1404 1404
 		//Page
1405 1405
 		$this->_newobj();
1406 1406
 		$this->_out('<</Type /Page');
1407 1407
 		$this->_out('/Parent 1 0 R');
1408
-		if(isset($this->PageSizes[$n]))
1409
-			$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
1408
+		if (isset($this->PageSizes[$n]))
1409
+			$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageSizes[$n][0], $this->PageSizes[$n][1]));
1410 1410
 		$this->_out('/Resources 2 0 R');
1411
-		if(isset($this->PageLinks[$n]))
1411
+		if (isset($this->PageLinks[$n]))
1412 1412
 		{
1413 1413
 			//Links
1414
-			$annots='/Annots [';
1415
-			foreach($this->PageLinks[$n] as $pl)
1414
+			$annots = '/Annots [';
1415
+			foreach ($this->PageLinks[$n] as $pl)
1416 1416
 			{
1417
-				$rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
1418
-				$annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1419
-				if(is_string($pl[4]))
1420
-					$annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1417
+				$rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]);
1418
+				$annots .= '<</Type /Annot /Subtype /Link /Rect [' . $rect . '] /Border [0 0 0] ';
1419
+				if (is_string($pl[4]))
1420
+					$annots .= '/A <</S /URI /URI ' . $this->_textstring($pl[4]) . '>>>>';
1421 1421
 				else
1422 1422
 				{
1423
-					$l=$this->links[$pl[4]];
1424
-					$h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
1425
-					$annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k);
1423
+					$l = $this->links[$pl[4]];
1424
+					$h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
1425
+					$annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>', 1 + 2 * $l[0], $h - $l[1] * $this->k);
1426 1426
 				}
1427 1427
 			}
1428
-			$this->_out($annots.']');
1428
+			$this->_out($annots . ']');
1429 1429
 		}
1430
-		$this->_out('/Contents '.($this->n+1).' 0 R>>');
1430
+		$this->_out('/Contents ' . ($this->n + 1) . ' 0 R>>');
1431 1431
 		$this->_out('endobj');
1432 1432
 		//Page content
1433
-		$p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
1433
+		$p = ($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
1434 1434
 		$this->_newobj();
1435
-		$this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
1435
+		$this->_out('<<' . $filter . '/Length ' . strlen($p) . '>>');
1436 1436
 		$this->_putstream($p);
1437 1437
 		$this->_out('endobj');
1438 1438
 	}
1439 1439
 	//Pages root
1440
-	$this->offsets[1]=strlen($this->buffer);
1440
+	$this->offsets[1] = strlen($this->buffer);
1441 1441
 	$this->_out('1 0 obj');
1442 1442
 	$this->_out('<</Type /Pages');
1443
-	$kids='/Kids [';
1444
-	for($i=0;$i<$nb;$i++)
1445
-		$kids.=(3+2*$i).' 0 R ';
1446
-	$this->_out($kids.']');
1447
-	$this->_out('/Count '.$nb);
1448
-	$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt));
1443
+	$kids = '/Kids [';
1444
+	for ($i = 0; $i < $nb; $i++)
1445
+		$kids .= (3 + 2 * $i) . ' 0 R ';
1446
+	$this->_out($kids . ']');
1447
+	$this->_out('/Count ' . $nb);
1448
+	$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $wPt, $hPt));
1449 1449
 	$this->_out('>>');
1450 1450
 	$this->_out('endobj');
1451 1451
 }
1452 1452
 
1453 1453
 function _putfonts()
1454 1454
 {
1455
-	$nf=$this->n;
1456
-	foreach($this->diffs as $diff)
1455
+	$nf = $this->n;
1456
+	foreach ($this->diffs as $diff)
1457 1457
 	{
1458 1458
 		//Encodings
1459 1459
 		$this->_newobj();
1460
-		$this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
1460
+		$this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [' . $diff . ']>>');
1461 1461
 		$this->_out('endobj');
1462 1462
 	}
1463
-	foreach($this->FontFiles as $file=>$info)
1463
+	foreach ($this->FontFiles as $file=>$info)
1464 1464
 	{
1465 1465
 		//Font file embedding
1466 1466
 		$this->_newobj();
1467
-		$this->FontFiles[$file]['n']=$this->n;
1468
-		$font='';
1469
-		$f=fopen($this->_getfontpath().$file,'rb',1);
1470
-		if(!$f)
1467
+		$this->FontFiles[$file]['n'] = $this->n;
1468
+		$font = '';
1469
+		$f = fopen($this->_getfontpath() . $file, 'rb', 1);
1470
+		if (!$f)
1471 1471
 			$this->Error('Font file not found');
1472
-		while(!feof($f))
1473
-			$font.=fread($f,8192);
1472
+		while (!feof($f))
1473
+			$font .= fread($f, 8192);
1474 1474
 		fclose($f);
1475
-		$compressed=(substr($file,-2)=='.z');
1476
-		if(!$compressed && isset($info['length2']))
1475
+		$compressed = (substr($file, -2) == '.z');
1476
+		if (!$compressed && isset($info['length2']))
1477 1477
 		{
1478
-			$header=(ord($font[0])==128);
1479
-			if($header)
1478
+			$header = (ord($font[0]) == 128);
1479
+			if ($header)
1480 1480
 			{
1481 1481
 				//Strip first binary header
1482
-				$font=substr($font,6);
1482
+				$font = substr($font, 6);
1483 1483
 			}
1484
-			if($header && ord($font[$info['length1']])==128)
1484
+			if ($header && ord($font[$info['length1']]) == 128)
1485 1485
 			{
1486 1486
 				//Strip second binary header
1487
-				$font=substr($font,0,$info['length1']).substr($font,$info['length1']+6);
1487
+				$font = substr($font, 0, $info['length1']) . substr($font, $info['length1'] + 6);
1488 1488
 			}
1489 1489
 		}
1490
-		$this->_out('<</Length '.strlen($font));
1491
-		if($compressed)
1490
+		$this->_out('<</Length ' . strlen($font));
1491
+		if ($compressed)
1492 1492
 			$this->_out('/Filter /FlateDecode');
1493
-		$this->_out('/Length1 '.$info['length1']);
1494
-		if(isset($info['length2']))
1495
-			$this->_out('/Length2 '.$info['length2'].' /Length3 0');
1493
+		$this->_out('/Length1 ' . $info['length1']);
1494
+		if (isset($info['length2']))
1495
+			$this->_out('/Length2 ' . $info['length2'] . ' /Length3 0');
1496 1496
 		$this->_out('>>');
1497 1497
 		$this->_putstream($font);
1498 1498
 		$this->_out('endobj');
1499 1499
 	}
1500
-	foreach($this->fonts as $k=>$font)
1500
+	foreach ($this->fonts as $k=>$font)
1501 1501
 	{
1502 1502
 		//Font objects
1503
-		$this->fonts[$k]['n']=$this->n+1;
1504
-		$type=$font['type'];
1505
-		$name=$font['name'];
1506
-		if($type=='core')
1503
+		$this->fonts[$k]['n'] = $this->n + 1;
1504
+		$type = $font['type'];
1505
+		$name = $font['name'];
1506
+		if ($type == 'core')
1507 1507
 		{
1508 1508
 			//Standard font
1509 1509
 			$this->_newobj();
1510 1510
 			$this->_out('<</Type /Font');
1511
-			$this->_out('/BaseFont /'.$name);
1511
+			$this->_out('/BaseFont /' . $name);
1512 1512
 			$this->_out('/Subtype /Type1');
1513
-			if($name!='Symbol' && $name!='ZapfDingbats')
1513
+			if ($name != 'Symbol' && $name != 'ZapfDingbats')
1514 1514
 				$this->_out('/Encoding /WinAnsiEncoding');
1515 1515
 			$this->_out('>>');
1516 1516
 			$this->_out('endobj');
1517 1517
 		}
1518
-		elseif($type=='Type1' || $type=='TrueType')
1518
+		elseif ($type == 'Type1' || $type == 'TrueType')
1519 1519
 		{
1520 1520
 			//Additional Type1 or TrueType font
1521 1521
 			$this->_newobj();
1522 1522
 			$this->_out('<</Type /Font');
1523
-			$this->_out('/BaseFont /'.$name);
1524
-			$this->_out('/Subtype /'.$type);
1523
+			$this->_out('/BaseFont /' . $name);
1524
+			$this->_out('/Subtype /' . $type);
1525 1525
 			$this->_out('/FirstChar 32 /LastChar 255');
1526
-			$this->_out('/Widths '.($this->n+1).' 0 R');
1527
-			$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
1528
-			if($font['enc'])
1526
+			$this->_out('/Widths ' . ($this->n + 1) . ' 0 R');
1527
+			$this->_out('/FontDescriptor ' . ($this->n + 2) . ' 0 R');
1528
+			if ($font['enc'])
1529 1529
 			{
1530
-				if(isset($font['diff']))
1531
-					$this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
1530
+				if (isset($font['diff']))
1531
+					$this->_out('/Encoding ' . ($nf + $font['diff']) . ' 0 R');
1532 1532
 				else
1533 1533
 					$this->_out('/Encoding /WinAnsiEncoding');
1534 1534
 			}
@@ -1536,29 +1536,29 @@  discard block
 block discarded – undo
1536 1536
 			$this->_out('endobj');
1537 1537
 			//Widths
1538 1538
 			$this->_newobj();
1539
-			$cw=&$font['cw'];
1540
-			$s='[';
1541
-			for($i=32;$i<=255;$i++)
1542
-				$s.=$cw[chr($i)].' ';
1543
-			$this->_out($s.']');
1539
+			$cw = &$font['cw'];
1540
+			$s = '[';
1541
+			for ($i = 32; $i <= 255; $i++)
1542
+				$s .= $cw[chr($i)] . ' ';
1543
+			$this->_out($s . ']');
1544 1544
 			$this->_out('endobj');
1545 1545
 			//Descriptor
1546 1546
 			$this->_newobj();
1547
-			$s='<</Type /FontDescriptor /FontName /'.$name;
1548
-			foreach($font['desc'] as $k=>$v)
1549
-				$s.=' /'.$k.' '.$v;
1550
-			$file=$font['file'];
1551
-			if($file)
1552
-				$s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
1553
-			$this->_out($s.'>>');
1547
+			$s = '<</Type /FontDescriptor /FontName /' . $name;
1548
+			foreach ($font['desc'] as $k=>$v)
1549
+				$s .= ' /' . $k . ' ' . $v;
1550
+			$file = $font['file'];
1551
+			if ($file)
1552
+				$s .= ' /FontFile' . ($type == 'Type1' ? '' : '2') . ' ' . $this->FontFiles[$file]['n'] . ' 0 R';
1553
+			$this->_out($s . '>>');
1554 1554
 			$this->_out('endobj');
1555 1555
 		}
1556 1556
 		else
1557 1557
 		{
1558 1558
 			//Allow for additional types
1559
-			$mtd='_put'.strtolower($type);
1560
-			if(!method_exists($this,$mtd))
1561
-				$this->Error('Unsupported font type: '.$type);
1559
+			$mtd = '_put' . strtolower($type);
1560
+			if (!method_exists($this, $mtd))
1561
+				$this->Error('Unsupported font type: ' . $type);
1562 1562
 			$this->$mtd($font);
1563 1563
 		}
1564 1564
 	}
@@ -1566,46 +1566,46 @@  discard block
 block discarded – undo
1566 1566
 
1567 1567
 function _putimages()
1568 1568
 {
1569
-	$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
1569
+	$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1570 1570
 	reset($this->images);
1571
-	while(list($file,$info)=each($this->images))
1571
+	while (list($file, $info) = each($this->images))
1572 1572
 	{
1573 1573
 		$this->_newobj();
1574
-		$this->images[$file]['n']=$this->n;
1574
+		$this->images[$file]['n'] = $this->n;
1575 1575
 		$this->_out('<</Type /XObject');
1576 1576
 		$this->_out('/Subtype /Image');
1577
-		$this->_out('/Width '.$info['w']);
1578
-		$this->_out('/Height '.$info['h']);
1579
-		if($info['cs']=='Indexed')
1580
-			$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
1577
+		$this->_out('/Width ' . $info['w']);
1578
+		$this->_out('/Height ' . $info['h']);
1579
+		if ($info['cs'] == 'Indexed')
1580
+			$this->_out('/ColorSpace [/Indexed /DeviceRGB ' . (strlen($info['pal']) / 3 - 1) . ' ' . ($this->n + 1) . ' 0 R]');
1581 1581
 		else
1582 1582
 		{
1583
-			$this->_out('/ColorSpace /'.$info['cs']);
1584
-			if($info['cs']=='DeviceCMYK')
1583
+			$this->_out('/ColorSpace /' . $info['cs']);
1584
+			if ($info['cs'] == 'DeviceCMYK')
1585 1585
 				$this->_out('/Decode [1 0 1 0 1 0 1 0]');
1586 1586
 		}
1587
-		$this->_out('/BitsPerComponent '.$info['bpc']);
1588
-		if(isset($info['f']))
1589
-			$this->_out('/Filter /'.$info['f']);
1590
-		if(isset($info['parms']))
1587
+		$this->_out('/BitsPerComponent ' . $info['bpc']);
1588
+		if (isset($info['f']))
1589
+			$this->_out('/Filter /' . $info['f']);
1590
+		if (isset($info['parms']))
1591 1591
 			$this->_out($info['parms']);
1592
-		if(isset($info['trns']) && is_array($info['trns']))
1592
+		if (isset($info['trns']) && is_array($info['trns']))
1593 1593
 		{
1594
-			$trns='';
1595
-			for($i=0;$i<count($info['trns']);$i++)
1596
-				$trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
1597
-			$this->_out('/Mask ['.$trns.']');
1594
+			$trns = '';
1595
+			for ($i = 0; $i < count($info['trns']); $i++)
1596
+				$trns .= $info['trns'][$i] . ' ' . $info['trns'][$i] . ' ';
1597
+			$this->_out('/Mask [' . $trns . ']');
1598 1598
 		}
1599
-		$this->_out('/Length '.strlen($info['data']).'>>');
1599
+		$this->_out('/Length ' . strlen($info['data']) . '>>');
1600 1600
 		$this->_putstream($info['data']);
1601 1601
 		unset($this->images[$file]['data']);
1602 1602
 		$this->_out('endobj');
1603 1603
 		//Palette
1604
-		if($info['cs']=='Indexed')
1604
+		if ($info['cs'] == 'Indexed')
1605 1605
 		{
1606 1606
 			$this->_newobj();
1607
-			$pal=($this->compress) ? gzcompress($info['pal']) : $info['pal'];
1608
-			$this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
1607
+			$pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal'];
1608
+			$this->_out('<<' . $filter . '/Length ' . strlen($pal) . '>>');
1609 1609
 			$this->_putstream($pal);
1610 1610
 			$this->_out('endobj');
1611 1611
 		}
@@ -1614,16 +1614,16 @@  discard block
 block discarded – undo
1614 1614
 
1615 1615
 function _putxobjectdict()
1616 1616
 {
1617
-	foreach($this->images as $image)
1618
-		$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
1617
+	foreach ($this->images as $image)
1618
+		$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
1619 1619
 }
1620 1620
 
1621 1621
 function _putresourcedict()
1622 1622
 {
1623 1623
 	$this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
1624 1624
 	$this->_out('/Font <<');
1625
-	foreach($this->fonts as $font)
1626
-		$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
1625
+	foreach ($this->fonts as $font)
1626
+		$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
1627 1627
 	$this->_out('>>');
1628 1628
 	$this->_out('/XObject <<');
1629 1629
 	$this->_putxobjectdict();
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
 	$this->_putfonts();
1636 1636
 	$this->_putimages();
1637 1637
 	//Resource dictionary
1638
-	$this->offsets[2]=strlen($this->buffer);
1638
+	$this->offsets[2] = strlen($this->buffer);
1639 1639
 	$this->_out('2 0 obj');
1640 1640
 	$this->_out('<<');
1641 1641
 	$this->_putresourcedict();
@@ -1645,50 +1645,50 @@  discard block
 block discarded – undo
1645 1645
 
1646 1646
 function _putinfo()
1647 1647
 {
1648
-	$this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
1649
-	if(!empty($this->title))
1650
-		$this->_out('/Title '.$this->_textstring($this->title));
1651
-	if(!empty($this->subject))
1652
-		$this->_out('/Subject '.$this->_textstring($this->subject));
1653
-	if(!empty($this->author))
1654
-		$this->_out('/Author '.$this->_textstring($this->author));
1655
-	if(!empty($this->keywords))
1656
-		$this->_out('/Keywords '.$this->_textstring($this->keywords));
1657
-	if(!empty($this->creator))
1658
-		$this->_out('/Creator '.$this->_textstring($this->creator));
1659
-	$this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
1648
+	$this->_out('/Producer ' . $this->_textstring('FPDF ' . FPDF_VERSION));
1649
+	if (!empty($this->title))
1650
+		$this->_out('/Title ' . $this->_textstring($this->title));
1651
+	if (!empty($this->subject))
1652
+		$this->_out('/Subject ' . $this->_textstring($this->subject));
1653
+	if (!empty($this->author))
1654
+		$this->_out('/Author ' . $this->_textstring($this->author));
1655
+	if (!empty($this->keywords))
1656
+		$this->_out('/Keywords ' . $this->_textstring($this->keywords));
1657
+	if (!empty($this->creator))
1658
+		$this->_out('/Creator ' . $this->_textstring($this->creator));
1659
+	$this->_out('/CreationDate ' . $this->_textstring('D:' . @date('YmdHis')));
1660 1660
 }
1661 1661
 
1662 1662
 function _putcatalog()
1663 1663
 {
1664 1664
 	$this->_out('/Type /Catalog');
1665 1665
 	$this->_out('/Pages 1 0 R');
1666
-	if($this->ZoomMode=='fullpage')
1666
+	if ($this->ZoomMode == 'fullpage')
1667 1667
 		$this->_out('/OpenAction [3 0 R /Fit]');
1668
-	elseif($this->ZoomMode=='fullwidth')
1668
+	elseif ($this->ZoomMode == 'fullwidth')
1669 1669
 		$this->_out('/OpenAction [3 0 R /FitH null]');
1670
-	elseif($this->ZoomMode=='real')
1670
+	elseif ($this->ZoomMode == 'real')
1671 1671
 		$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
1672
-	elseif(!is_string($this->ZoomMode))
1673
-		$this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');
1674
-	if($this->LayoutMode=='single')
1672
+	elseif (!is_string($this->ZoomMode))
1673
+		$this->_out('/OpenAction [3 0 R /XYZ null null ' . ($this->ZoomMode / 100) . ']');
1674
+	if ($this->LayoutMode == 'single')
1675 1675
 		$this->_out('/PageLayout /SinglePage');
1676
-	elseif($this->LayoutMode=='continuous')
1676
+	elseif ($this->LayoutMode == 'continuous')
1677 1677
 		$this->_out('/PageLayout /OneColumn');
1678
-	elseif($this->LayoutMode=='two')
1678
+	elseif ($this->LayoutMode == 'two')
1679 1679
 		$this->_out('/PageLayout /TwoColumnLeft');
1680 1680
 }
1681 1681
 
1682 1682
 function _putheader()
1683 1683
 {
1684
-	$this->_out('%PDF-'.$this->PDFVersion);
1684
+	$this->_out('%PDF-' . $this->PDFVersion);
1685 1685
 }
1686 1686
 
1687 1687
 function _puttrailer()
1688 1688
 {
1689
-	$this->_out('/Size '.($this->n+1));
1690
-	$this->_out('/Root '.$this->n.' 0 R');
1691
-	$this->_out('/Info '.($this->n-1).' 0 R');
1689
+	$this->_out('/Size ' . ($this->n + 1));
1690
+	$this->_out('/Root ' . $this->n . ' 0 R');
1691
+	$this->_out('/Info ' . ($this->n - 1) . ' 0 R');
1692 1692
 }
1693 1693
 
1694 1694
 function _enddoc()
@@ -1709,12 +1709,12 @@  discard block
 block discarded – undo
1709 1709
 	$this->_out('>>');
1710 1710
 	$this->_out('endobj');
1711 1711
 	//Cross-ref
1712
-	$o=strlen($this->buffer);
1712
+	$o = strlen($this->buffer);
1713 1713
 	$this->_out('xref');
1714
-	$this->_out('0 '.($this->n+1));
1714
+	$this->_out('0 ' . ($this->n + 1));
1715 1715
 	$this->_out('0000000000 65535 f ');
1716
-	for($i=1;$i<=$this->n;$i++)
1717
-		$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
1716
+	for ($i = 1; $i <= $this->n; $i++)
1717
+		$this->_out(sprintf('%010d 00000 n ', $this->offsets[$i]));
1718 1718
 	//Trailer
1719 1719
 	$this->_out('trailer');
1720 1720
 	$this->_out('<<');
@@ -1723,13 +1723,13 @@  discard block
 block discarded – undo
1723 1723
 	$this->_out('startxref');
1724 1724
 	$this->_out($o);
1725 1725
 	$this->_out('%%EOF');
1726
-	$this->state=3;
1726
+	$this->state = 3;
1727 1727
 }
1728 1728
 //End of class
1729 1729
 }
1730 1730
 
1731 1731
 //Handle special IE contype request
1732
-if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype')
1732
+if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] == 'contype')
1733 1733
 {
1734 1734
 	header('Content-Type: application/pdf');
1735 1735
 	exit;
Please login to merge, or discard this patch.
Braces   +562 added lines, -432 removed lines patch added patch discarded remove patch
@@ -112,21 +112,23 @@  discard block
 block discarded – undo
112 112
 		'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic',
113 113
 		'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats');
114 114
 	//Scale factor
115
-	if($unit=='pt')
116
-		$this->k=1;
117
-	elseif($unit=='mm')
118
-		$this->k=72/25.4;
119
-	elseif($unit=='cm')
120
-		$this->k=72/2.54;
121
-	elseif($unit=='in')
122
-		$this->k=72;
123
-	else
124
-		$this->Error('Incorrect unit: '.$unit);
115
+	if($unit=='pt') {
116
+			$this->k=1;
117
+	} elseif($unit=='mm') {
118
+			$this->k=72/25.4;
119
+	} elseif($unit=='cm') {
120
+			$this->k=72/2.54;
121
+	} elseif($unit=='in') {
122
+			$this->k=72;
123
+	} else {
124
+			$this->Error('Incorrect unit: '.$unit);
125
+	}
125 126
 	//Page format
126 127
 	$this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
127 128
 		'letter'=>array(612,792), 'legal'=>array(612,1008));
128
-	if(is_string($format))
129
-		$format=$this->_getpageformat($format);
129
+	if(is_string($format)) {
130
+			$format=$this->_getpageformat($format);
131
+	}
130 132
 	$this->DefPageFormat=$format;
131 133
 	$this->CurPageFormat=$format;
132 134
 	//Page orientation
@@ -136,15 +138,14 @@  discard block
 block discarded – undo
136 138
 		$this->DefOrientation='P';
137 139
 		$this->w=$this->DefPageFormat[0];
138 140
 		$this->h=$this->DefPageFormat[1];
139
-	}
140
-	elseif($orientation=='l' || $orientation=='landscape')
141
+	} elseif($orientation=='l' || $orientation=='landscape')
141 142
 	{
142 143
 		$this->DefOrientation='L';
143 144
 		$this->w=$this->DefPageFormat[1];
144 145
 		$this->h=$this->DefPageFormat[0];
146
+	} else {
147
+			$this->Error('Incorrect orientation: '.$orientation);
145 148
 	}
146
-	else
147
-		$this->Error('Incorrect orientation: '.$orientation);
148 149
 	$this->CurOrientation=$this->DefOrientation;
149 150
 	$this->wPt=$this->w*$this->k;
150 151
 	$this->hPt=$this->h*$this->k;
@@ -170,8 +171,9 @@  discard block
 block discarded – undo
170 171
 	//Set left, top and right margins
171 172
 	$this->lMargin=$left;
172 173
 	$this->tMargin=$top;
173
-	if($right===null)
174
-		$right=$left;
174
+	if($right===null) {
175
+			$right=$left;
176
+	}
175 177
 	$this->rMargin=$right;
176 178
 }
177 179
 
@@ -179,9 +181,10 @@  discard block
 block discarded – undo
179 181
 {
180 182
 	//Set left margin
181 183
 	$this->lMargin=$margin;
182
-	if($this->page>0 && $this->x<$margin)
183
-		$this->x=$margin;
184
-}
184
+	if($this->page>0 && $this->x<$margin) {
185
+			$this->x=$margin;
186
+	}
187
+	}
185 188
 
186 189
 function SetTopMargin($margin)
187 190
 {
@@ -206,62 +209,70 @@  discard block
 block discarded – undo
206 209
 function SetDisplayMode($zoom, $layout='continuous')
207 210
 {
208 211
 	//Set display mode in viewer
209
-	if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
210
-		$this->ZoomMode=$zoom;
211
-	else
212
-		$this->Error('Incorrect zoom display mode: '.$zoom);
213
-	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
214
-		$this->LayoutMode=$layout;
215
-	else
216
-		$this->Error('Incorrect layout display mode: '.$layout);
217
-}
212
+	if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) {
213
+			$this->ZoomMode=$zoom;
214
+	} else {
215
+			$this->Error('Incorrect zoom display mode: '.$zoom);
216
+	}
217
+	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') {
218
+			$this->LayoutMode=$layout;
219
+	} else {
220
+			$this->Error('Incorrect layout display mode: '.$layout);
221
+	}
222
+	}
218 223
 
219 224
 function SetCompression($compress)
220 225
 {
221 226
 	//Set page compression
222
-	if(function_exists('gzcompress'))
223
-		$this->compress=$compress;
224
-	else
225
-		$this->compress=false;
226
-}
227
+	if(function_exists('gzcompress')) {
228
+			$this->compress=$compress;
229
+	} else {
230
+			$this->compress=false;
231
+	}
232
+	}
227 233
 
228 234
 function SetTitle($title, $isUTF8=false)
229 235
 {
230 236
 	//Title of document
231
-	if($isUTF8)
232
-		$title=$this->_UTF8toUTF16($title);
237
+	if($isUTF8) {
238
+			$title=$this->_UTF8toUTF16($title);
239
+	}
233 240
 	$this->title=$title;
234 241
 }
235 242
 
236 243
 function SetSubject($subject, $isUTF8=false)
237 244
 {
238 245
 	//Subject of document
239
-	if($isUTF8)
240
-		$subject=$this->_UTF8toUTF16($subject);
246
+	if($isUTF8) {
247
+			$subject=$this->_UTF8toUTF16($subject);
248
+	}
241 249
 	$this->subject=$subject;
242 250
 }
243 251
 
244 252
 function SetAuthor($author, $isUTF8=false)
245 253
 {
246 254
 	//Author of document
247
-	if($isUTF8)
248
-		$author=$this->_UTF8toUTF16($author);
255
+	if($isUTF8) {
256
+			$author=$this->_UTF8toUTF16($author);
257
+	}
249 258
 	$this->author=$author;
250 259
 }
251 260
 
252 261
 function SetKeywords($keywords, $isUTF8=false)
253 262
 {
254 263
 	//Keywords of document
255
-	if($isUTF8)
256
-		$keywords=$this->_UTF8toUTF16($keywords);
264
+	if($isUTF8) {
265
+			$keywords=$this->_UTF8toUTF16($keywords);
266
+	}
257 267
 	$this->keywords=$keywords;
258 268
 }
259 269
 
260 270
 function SetCreator($creator, $isUTF8=false)
261 271
 {
262 272
 	//Creator of document
263
-	if($isUTF8)
264
-		$creator=$this->_UTF8toUTF16($creator);
273
+	if($isUTF8) {
274
+			$creator=$this->_UTF8toUTF16($creator);
275
+	}
265 276
 	$this->creator=$creator;
266 277
 }
267 278
 
@@ -286,10 +297,12 @@  discard block
 block discarded – undo
286 297
 function Close()
287 298
 {
288 299
 	//Terminate document
289
-	if($this->state==3)
290
-		return;
291
-	if($this->page==0)
292
-		$this->AddPage();
300
+	if($this->state==3) {
301
+			return;
302
+	}
303
+	if($this->page==0) {
304
+			$this->AddPage();
305
+	}
293 306
 	//Page footer
294 307
 	$this->InFooter=true;
295 308
 	$this->Footer();
@@ -303,8 +316,9 @@  discard block
 block discarded – undo
303 316
 function AddPage($orientation='', $format='')
304 317
 {
305 318
 	//Start a new page
306
-	if($this->state==0)
307
-		$this->Open();
319
+	if($this->state==0) {
320
+			$this->Open();
321
+	}
308 322
 	$family=$this->FontFamily;
309 323
 	$style=$this->FontStyle.($this->underline ? 'U' : '');
310 324
 	$size=$this->FontSizePt;
@@ -330,15 +344,18 @@  discard block
 block discarded – undo
330 344
 	$this->LineWidth=$lw;
331 345
 	$this->_out(sprintf('%.2F w',$lw*$this->k));
332 346
 	//Set font
333
-	if($family)
334
-		$this->SetFont($family,$style,$size);
347
+	if($family) {
348
+			$this->SetFont($family,$style,$size);
349
+	}
335 350
 	//Set colors
336 351
 	$this->DrawColor=$dc;
337
-	if($dc!='0 G')
338
-		$this->_out($dc);
352
+	if($dc!='0 G') {
353
+			$this->_out($dc);
354
+	}
339 355
 	$this->FillColor=$fc;
340
-	if($fc!='0 g')
341
-		$this->_out($fc);
356
+	if($fc!='0 g') {
357
+			$this->_out($fc);
358
+	}
342 359
 	$this->TextColor=$tc;
343 360
 	$this->ColorFlag=$cf;
344 361
 	//Page header
@@ -352,8 +369,9 @@  discard block
 block discarded – undo
352 369
 		$this->_out(sprintf('%.2F w',$lw*$this->k));
353 370
 	}
354 371
 	//Restore font
355
-	if($family)
356
-		$this->SetFont($family,$style,$size);
372
+	if($family) {
373
+			$this->SetFont($family,$style,$size);
374
+	}
357 375
 	//Restore colors
358 376
 	if($this->DrawColor!=$dc)
359 377
 	{
@@ -388,33 +406,38 @@  discard block
 block discarded – undo
388 406
 function SetDrawColor($r, $g=null, $b=null)
389 407
 {
390 408
 	//Set color for all stroking operations
391
-	if(($r==0 && $g==0 && $b==0) || $g===null)
392
-		$this->DrawColor=sprintf('%.3F G',$r/255);
393
-	else
394
-		$this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
395
-	if($this->page>0)
396
-		$this->_out($this->DrawColor);
397
-}
409
+	if(($r==0 && $g==0 && $b==0) || $g===null) {
410
+			$this->DrawColor=sprintf('%.3F G',$r/255);
411
+	} else {
412
+			$this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
413
+	}
414
+	if($this->page>0) {
415
+			$this->_out($this->DrawColor);
416
+	}
417
+	}
398 418
 
399 419
 function SetFillColor($r, $g=null, $b=null)
400 420
 {
401 421
 	//Set color for all filling operations
402
-	if(($r==0 && $g==0 && $b==0) || $g===null)
403
-		$this->FillColor=sprintf('%.3F g',$r/255);
404
-	else
405
-		$this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
422
+	if(($r==0 && $g==0 && $b==0) || $g===null) {
423
+			$this->FillColor=sprintf('%.3F g',$r/255);
424
+	} else {
425
+			$this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
426
+	}
406 427
 	$this->ColorFlag=($this->FillColor!=$this->TextColor);
407
-	if($this->page>0)
408
-		$this->_out($this->FillColor);
409
-}
428
+	if($this->page>0) {
429
+			$this->_out($this->FillColor);
430
+	}
431
+	}
410 432
 
411 433
 function SetTextColor($r, $g=null, $b=null)
412 434
 {
413 435
 	//Set color for text
414
-	if(($r==0 && $g==0 && $b==0) || $g===null)
415
-		$this->TextColor=sprintf('%.3F g',$r/255);
416
-	else
417
-		$this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
436
+	if(($r==0 && $g==0 && $b==0) || $g===null) {
437
+			$this->TextColor=sprintf('%.3F g',$r/255);
438
+	} else {
439
+			$this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
440
+	}
418 441
 	$this->ColorFlag=($this->FillColor!=$this->TextColor);
419 442
 }
420 443
 
@@ -425,8 +448,9 @@  discard block
 block discarded – undo
425 448
 	$cw=&$this->CurrentFont['cw'];
426 449
 	$w=0;
427 450
 	$l=strlen($s);
428
-	for($i=0;$i<$l;$i++)
429
-		$w+=$cw[$s[$i]];
451
+	for($i=0;$i<$l;$i++) {
452
+			$w+=$cw[$s[$i]];
453
+	}
430 454
 	return $w*$this->FontSize/1000;
431 455
 }
432 456
 
@@ -434,9 +458,10 @@  discard block
 block discarded – undo
434 458
 {
435 459
 	//Set line width
436 460
 	$this->LineWidth=$width;
437
-	if($this->page>0)
438
-		$this->_out(sprintf('%.2F w',$width*$this->k));
439
-}
461
+	if($this->page>0) {
462
+			$this->_out(sprintf('%.2F w',$width*$this->k));
463
+	}
464
+	}
440 465
 
441 466
 function Line($x1, $y1, $x2, $y2)
442 467
 {
@@ -447,12 +472,13 @@  discard block
 block discarded – undo
447 472
 function Rect($x, $y, $w, $h, $style='')
448 473
 {
449 474
 	//Draw a rectangle
450
-	if($style=='F')
451
-		$op='f';
452
-	elseif($style=='FD' || $style=='DF')
453
-		$op='B';
454
-	else
455
-		$op='S';
475
+	if($style=='F') {
476
+			$op='f';
477
+	} elseif($style=='FD' || $style=='DF') {
478
+			$op='B';
479
+	} else {
480
+			$op='S';
481
+	}
456 482
 	$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
457 483
 }
458 484
 
@@ -460,19 +486,24 @@  discard block
 block discarded – undo
460 486
 {
461 487
 	//Add a TrueType or Type1 font
462 488
 	$family=strtolower($family);
463
-	if($file=='')
464
-		$file=str_replace(' ','',$family).strtolower($style).'.php';
465
-	if($family=='arial')
466
-		$family='helvetica';
489
+	if($file=='') {
490
+			$file=str_replace(' ','',$family).strtolower($style).'.php';
491
+	}
492
+	if($family=='arial') {
493
+			$family='helvetica';
494
+	}
467 495
 	$style=strtoupper($style);
468
-	if($style=='IB')
469
-		$style='BI';
496
+	if($style=='IB') {
497
+			$style='BI';
498
+	}
470 499
 	$fontkey=$family.$style;
471
-	if(isset($this->fonts[$fontkey]))
472
-		return;
500
+	if(isset($this->fonts[$fontkey])) {
501
+			return;
502
+	}
473 503
 	include($this->_getfontpath().$file);
474
-	if(!isset($name))
475
-		$this->Error('Could not include font definition file');
504
+	if(!isset($name)) {
505
+			$this->Error('Could not include font definition file');
506
+	}
476 507
 	$i=count($this->fonts)+1;
477 508
 	$this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file);
478 509
 	if($diff)
@@ -497,10 +528,11 @@  discard block
 block discarded – undo
497 528
 	}
498 529
 	if($file)
499 530
 	{
500
-		if($type=='TrueType')
501
-			$this->FontFiles[$file]=array('length1'=>$originalsize);
502
-		else
503
-			$this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2);
531
+		if($type=='TrueType') {
532
+					$this->FontFiles[$file]=array('length1'=>$originalsize);
533
+		} else {
534
+					$this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2);
535
+		}
504 536
 	}
505 537
 }
506 538
 
@@ -510,27 +542,32 @@  discard block
 block discarded – undo
510 542
 	global $fpdf_charwidths;
511 543
 
512 544
 	$family=strtolower($family);
513
-	if($family=='')
514
-		$family=$this->FontFamily;
515
-	if($family=='arial')
516
-		$family='helvetica';
517
-	elseif($family=='symbol' || $family=='zapfdingbats')
518
-		$style='';
545
+	if($family=='') {
546
+			$family=$this->FontFamily;
547
+	}
548
+	if($family=='arial') {
549
+			$family='helvetica';
550
+	} elseif($family=='symbol' || $family=='zapfdingbats') {
551
+			$style='';
552
+	}
519 553
 	$style=strtoupper($style);
520 554
 	if(strpos($style,'U')!==false)
521 555
 	{
522 556
 		$this->underline=true;
523 557
 		$style=str_replace('U','',$style);
558
+	} else {
559
+			$this->underline=false;
560
+	}
561
+	if($style=='IB') {
562
+			$style='BI';
563
+	}
564
+	if($size==0) {
565
+			$size=$this->FontSizePt;
524 566
 	}
525
-	else
526
-		$this->underline=false;
527
-	if($style=='IB')
528
-		$style='BI';
529
-	if($size==0)
530
-		$size=$this->FontSizePt;
531 567
 	//Test if font is already selected
532
-	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
533
-		return;
568
+	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) {
569
+			return;
570
+	}
534 571
 	//Test if used for the first time
535 572
 	$fontkey=$family.$style;
536 573
 	if(!isset($this->fonts[$fontkey]))
@@ -542,19 +579,21 @@  discard block
 block discarded – undo
542 579
 			{
543 580
 				//Load metric file
544 581
 				$file=$family;
545
-				if($family=='times' || $family=='helvetica')
546
-					$file.=strtolower($style);
582
+				if($family=='times' || $family=='helvetica') {
583
+									$file.=strtolower($style);
584
+				}
547 585
 				include($this->_getfontpath().$file.'.php');
548
-				if(!isset($fpdf_charwidths[$fontkey]))
549
-					$this->Error('Could not include font metric file');
586
+				if(!isset($fpdf_charwidths[$fontkey])) {
587
+									$this->Error('Could not include font metric file');
588
+				}
550 589
 			}
551 590
 			$i=count($this->fonts)+1;
552 591
 			$name=$this->CoreFonts[$fontkey];
553 592
 			$cw=$fpdf_charwidths[$fontkey];
554 593
 			$this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw);
594
+		} else {
595
+					$this->Error('Undefined font: '.$family.' '.$style);
555 596
 		}
556
-		else
557
-			$this->Error('Undefined font: '.$family.' '.$style);
558 597
 	}
559 598
 	//Select it
560 599
 	$this->FontFamily=$family;
@@ -562,20 +601,23 @@  discard block
 block discarded – undo
562 601
 	$this->FontSizePt=$size;
563 602
 	$this->FontSize=$size/$this->k;
564 603
 	$this->CurrentFont=&$this->fonts[$fontkey];
565
-	if($this->page>0)
566
-		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
567
-}
604
+	if($this->page>0) {
605
+			$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
606
+	}
607
+	}
568 608
 
569 609
 function SetFontSize($size)
570 610
 {
571 611
 	//Set font size in points
572
-	if($this->FontSizePt==$size)
573
-		return;
612
+	if($this->FontSizePt==$size) {
613
+			return;
614
+	}
574 615
 	$this->FontSizePt=$size;
575 616
 	$this->FontSize=$size/$this->k;
576
-	if($this->page>0)
577
-		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
578
-}
617
+	if($this->page>0) {
618
+			$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
619
+	}
620
+	}
579 621
 
580 622
 function AddLink()
581 623
 {
@@ -588,10 +630,12 @@  discard block
 block discarded – undo
588 630
 function SetLink($link, $y=0, $page=-1)
589 631
 {
590 632
 	//Set destination of internal link
591
-	if($y==-1)
592
-		$y=$this->y;
593
-	if($page==-1)
594
-		$page=$this->page;
633
+	if($y==-1) {
634
+			$y=$this->y;
635
+	}
636
+	if($page==-1) {
637
+			$page=$this->page;
638
+	}
595 639
 	$this->links[$link]=array($page, $y);
596 640
 }
597 641
 
@@ -605,10 +649,12 @@  discard block
 block discarded – undo
605 649
 {
606 650
 	//Output a string
607 651
 	$s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
608
-	if($this->underline && $txt!='')
609
-		$s.=' '.$this->_dounderline($x,$y,$txt);
610
-	if($this->ColorFlag)
611
-		$s='q '.$this->TextColor.' '.$s.' Q';
652
+	if($this->underline && $txt!='') {
653
+			$s.=' '.$this->_dounderline($x,$y,$txt);
654
+	}
655
+	if($this->ColorFlag) {
656
+			$s='q '.$this->TextColor.' '.$s.' Q';
657
+	}
612 658
 	$this->_out($s);
613 659
 }
614 660
 
@@ -640,74 +686,89 @@  discard block
 block discarded – undo
640 686
 			$this->_out(sprintf('%.3F Tw',$ws*$k));
641 687
 		}
642 688
 	}
643
-	if($w==0)
644
-		$w=$this->w-$this->rMargin-$this->x;
689
+	if($w==0) {
690
+			$w=$this->w-$this->rMargin-$this->x;
691
+	}
645 692
 	$s='';
646 693
 	if($fill || $border==1)
647 694
 	{
648
-		if($fill)
649
-			$op=($border==1) ? 'B' : 'f';
650
-		else
651
-			$op='S';
695
+		if($fill) {
696
+					$op=($border==1) ? 'B' : 'f';
697
+		} else {
698
+					$op='S';
699
+		}
652 700
 		$s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
653 701
 	}
654 702
 	if(is_string($border))
655 703
 	{
656 704
 		$x=$this->x;
657 705
 		$y=$this->y;
658
-		if(strpos($border,'L')!==false)
659
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
660
-		if(strpos($border,'T')!==false)
661
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
662
-		if(strpos($border,'R')!==false)
663
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
664
-		if(strpos($border,'B')!==false)
665
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
706
+		if(strpos($border,'L')!==false) {
707
+					$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
708
+		}
709
+		if(strpos($border,'T')!==false) {
710
+					$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
711
+		}
712
+		if(strpos($border,'R')!==false) {
713
+					$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
714
+		}
715
+		if(strpos($border,'B')!==false) {
716
+					$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
717
+		}
666 718
 	}
667 719
 	if($txt!=='')
668 720
 	{
669
-		if($align=='R')
670
-			$dx=$w-$this->cMargin-$this->GetStringWidth($txt);
671
-		elseif($align=='C')
672
-			$dx=($w-$this->GetStringWidth($txt))/2;
673
-		else
674
-			$dx=$this->cMargin;
675
-		if($this->ColorFlag)
676
-			$s.='q '.$this->TextColor.' ';
721
+		if($align=='R') {
722
+					$dx=$w-$this->cMargin-$this->GetStringWidth($txt);
723
+		} elseif($align=='C') {
724
+					$dx=($w-$this->GetStringWidth($txt))/2;
725
+		} else {
726
+					$dx=$this->cMargin;
727
+		}
728
+		if($this->ColorFlag) {
729
+					$s.='q '.$this->TextColor.' ';
730
+		}
677 731
 		$txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
678 732
 		$s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
679
-		if($this->underline)
680
-			$s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
681
-		if($this->ColorFlag)
682
-			$s.=' Q';
683
-		if($link)
684
-			$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
685
-	}
686
-	if($s)
687
-		$this->_out($s);
733
+		if($this->underline) {
734
+					$s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
735
+		}
736
+		if($this->ColorFlag) {
737
+					$s.=' Q';
738
+		}
739
+		if($link) {
740
+					$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
741
+		}
742
+	}
743
+	if($s) {
744
+			$this->_out($s);
745
+	}
688 746
 	$this->lasth=$h;
689 747
 	if($ln>0)
690 748
 	{
691 749
 		//Go to next line
692 750
 		$this->y+=$h;
693
-		if($ln==1)
694
-			$this->x=$this->lMargin;
751
+		if($ln==1) {
752
+					$this->x=$this->lMargin;
753
+		}
754
+	} else {
755
+			$this->x+=$w;
756
+	}
695 757
 	}
696
-	else
697
-		$this->x+=$w;
698
-}
699 758
 
700 759
 function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
701 760
 {
702 761
 	//Output text with automatic or explicit line breaks
703 762
 	$cw=&$this->CurrentFont['cw'];
704
-	if($w==0)
705
-		$w=$this->w-$this->rMargin-$this->x;
763
+	if($w==0) {
764
+			$w=$this->w-$this->rMargin-$this->x;
765
+	}
706 766
 	$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
707 767
 	$s=str_replace("\r",'',$txt);
708 768
 	$nb=strlen($s);
709
-	if($nb>0 && $s[$nb-1]=="\n")
710
-		$nb--;
769
+	if($nb>0 && $s[$nb-1]=="\n") {
770
+			$nb--;
771
+	}
711 772
 	$b=0;
712 773
 	if($border)
713 774
 	{
@@ -716,14 +777,15 @@  discard block
 block discarded – undo
716 777
 			$border='LTRB';
717 778
 			$b='LRT';
718 779
 			$b2='LR';
719
-		}
720
-		else
780
+		} else
721 781
 		{
722 782
 			$b2='';
723
-			if(strpos($border,'L')!==false)
724
-				$b2.='L';
725
-			if(strpos($border,'R')!==false)
726
-				$b2.='R';
783
+			if(strpos($border,'L')!==false) {
784
+							$b2.='L';
785
+			}
786
+			if(strpos($border,'R')!==false) {
787
+							$b2.='R';
788
+			}
727 789
 			$b=(strpos($border,'T')!==false) ? $b2.'T' : $b2;
728 790
 		}
729 791
 	}
@@ -752,8 +814,9 @@  discard block
 block discarded – undo
752 814
 			$l=0;
753 815
 			$ns=0;
754 816
 			$nl++;
755
-			if($border && $nl==2)
756
-				$b=$b2;
817
+			if($border && $nl==2) {
818
+							$b=$b2;
819
+			}
757 820
 			continue;
758 821
 		}
759 822
 		if($c==' ')
@@ -768,16 +831,16 @@  discard block
 block discarded – undo
768 831
 			//Automatic line break
769 832
 			if($sep==-1)
770 833
 			{
771
-				if($i==$j)
772
-					$i++;
834
+				if($i==$j) {
835
+									$i++;
836
+				}
773 837
 				if($this->ws>0)
774 838
 				{
775 839
 					$this->ws=0;
776 840
 					$this->_out('0 Tw');
777 841
 				}
778 842
 				$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
779
-			}
780
-			else
843
+			} else
781 844
 			{
782 845
 				if($align=='J')
783 846
 				{
@@ -792,11 +855,12 @@  discard block
 block discarded – undo
792 855
 			$l=0;
793 856
 			$ns=0;
794 857
 			$nl++;
795
-			if($border && $nl==2)
796
-				$b=$b2;
858
+			if($border && $nl==2) {
859
+							$b=$b2;
860
+			}
861
+		} else {
862
+					$i++;
797 863
 		}
798
-		else
799
-			$i++;
800 864
 	}
801 865
 	//Last chunk
802 866
 	if($this->ws>0)
@@ -804,8 +868,9 @@  discard block
 block discarded – undo
804 868
 		$this->ws=0;
805 869
 		$this->_out('0 Tw');
806 870
 	}
807
-	if($border && strpos($border,'B')!==false)
808
-		$b.='B';
871
+	if($border && strpos($border,'B')!==false) {
872
+			$b.='B';
873
+	}
809 874
 	$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
810 875
 	$this->x=$this->lMargin;
811 876
 }
@@ -844,8 +909,9 @@  discard block
 block discarded – undo
844 909
 			$nl++;
845 910
 			continue;
846 911
 		}
847
-		if($c==' ')
848
-			$sep=$i;
912
+		if($c==' ') {
913
+					$sep=$i;
914
+		}
849 915
 		$l+=$cw[$c];
850 916
 		if($l>$wmax)
851 917
 		{
@@ -863,11 +929,11 @@  discard block
 block discarded – undo
863 929
 					$nl++;
864 930
 					continue;
865 931
 				}
866
-				if($i==$j)
867
-					$i++;
932
+				if($i==$j) {
933
+									$i++;
934
+				}
868 935
 				$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
869
-			}
870
-			else
936
+			} else
871 937
 			{
872 938
 				$this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
873 939
 				$i=$sep+1;
@@ -882,24 +948,26 @@  discard block
 block discarded – undo
882 948
 				$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
883 949
 			}
884 950
 			$nl++;
951
+		} else {
952
+					$i++;
885 953
 		}
886
-		else
887
-			$i++;
888 954
 	}
889 955
 	//Last chunk
890
-	if($i!=$j)
891
-		$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
892
-}
956
+	if($i!=$j) {
957
+			$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
958
+	}
959
+	}
893 960
 
894 961
 function Ln($h=null)
895 962
 {
896 963
 	//Line feed; default value is last cell height
897 964
 	$this->x=$this->lMargin;
898
-	if($h===null)
899
-		$this->y+=$this->lasth;
900
-	else
901
-		$this->y+=$h;
902
-}
965
+	if($h===null) {
966
+			$this->y+=$this->lasth;
967
+	} else {
968
+			$this->y+=$h;
969
+	}
970
+	}
903 971
 
904 972
 function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
905 973
 {
@@ -910,33 +978,36 @@  discard block
 block discarded – undo
910 978
 		if($type=='')
911 979
 		{
912 980
 			$pos=strrpos($file,'.');
913
-			if(!$pos)
914
-				$this->Error('Image file has no extension and no type was specified: '.$file);
981
+			if(!$pos) {
982
+							$this->Error('Image file has no extension and no type was specified: '.$file);
983
+			}
915 984
 			$type=substr($file,$pos+1);
916 985
 		}
917 986
 		$type=strtolower($type);
918
-		if($type=='jpeg')
919
-			$type='jpg';
987
+		if($type=='jpeg') {
988
+					$type='jpg';
989
+		}
920 990
 		$mtd='_parse'.$type;
921
-		if(!method_exists($this,$mtd))
922
-			$this->Error('Unsupported image type: '.$type);
991
+		if(!method_exists($this,$mtd)) {
992
+					$this->Error('Unsupported image type: '.$type);
993
+		}
923 994
 		$info=$this->$mtd($file);
924 995
 		$info['i']=count($this->images)+1;
925 996
 		$this->images[$file]=$info;
997
+	} else {
998
+			$info=$this->images[$file];
926 999
 	}
927
-	else
928
-		$info=$this->images[$file];
929 1000
 	//Automatic width and height calculation if needed
930 1001
 	if($w==0 && $h==0)
931 1002
 	{
932 1003
 		//Put image at 72 dpi
933 1004
 		$w=$info['w']/$this->k;
934 1005
 		$h=$info['h']/$this->k;
1006
+	} elseif($w==0) {
1007
+			$w=$h*$info['w']/$info['h'];
1008
+	} elseif($h==0) {
1009
+			$h=$w*$info['h']/$info['w'];
935 1010
 	}
936
-	elseif($w==0)
937
-		$w=$h*$info['w']/$info['h'];
938
-	elseif($h==0)
939
-		$h=$w*$info['h']/$info['w'];
940 1011
 	//Flowing mode
941 1012
 	if($y===null)
942 1013
 	{
@@ -950,12 +1021,14 @@  discard block
 block discarded – undo
950 1021
 		$y=$this->y;
951 1022
 		$this->y+=$h;
952 1023
 	}
953
-	if($x===null)
954
-		$x=$this->x;
1024
+	if($x===null) {
1025
+			$x=$this->x;
1026
+	}
955 1027
 	$this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
956
-	if($link)
957
-		$this->Link($x,$y,$w,$h,$link);
958
-}
1028
+	if($link) {
1029
+			$this->Link($x,$y,$w,$h,$link);
1030
+	}
1031
+	}
959 1032
 
960 1033
 function GetX()
961 1034
 {
@@ -966,11 +1039,12 @@  discard block
 block discarded – undo
966 1039
 function SetX($x)
967 1040
 {
968 1041
 	//Set x position
969
-	if($x>=0)
970
-		$this->x=$x;
971
-	else
972
-		$this->x=$this->w+$x;
973
-}
1042
+	if($x>=0) {
1043
+			$this->x=$x;
1044
+	} else {
1045
+			$this->x=$this->w+$x;
1046
+	}
1047
+	}
974 1048
 
975 1049
 function GetY()
976 1050
 {
@@ -982,11 +1056,12 @@  discard block
 block discarded – undo
982 1056
 {
983 1057
 	//Set y position and reset x
984 1058
 	$this->x=$this->lMargin;
985
-	if($y>=0)
986
-		$this->y=$y;
987
-	else
988
-		$this->y=$this->h+$y;
989
-}
1059
+	if($y>=0) {
1060
+			$this->y=$y;
1061
+	} else {
1062
+			$this->y=$this->h+$y;
1063
+	}
1064
+	}
990 1065
 
991 1066
 function SetXY($x, $y)
992 1067
 {
@@ -998,8 +1073,9 @@  discard block
 block discarded – undo
998 1073
 function Output($name='', $dest='')
999 1074
 {
1000 1075
 	//Output PDF to some destination
1001
-	if($this->state<3)
1002
-		$this->Close();
1076
+	if($this->state<3) {
1077
+			$this->Close();
1078
+	}
1003 1079
 	$dest=strtoupper($dest);
1004 1080
 	if($dest=='')
1005 1081
 	{
@@ -1007,22 +1083,24 @@  discard block
 block discarded – undo
1007 1083
 		{
1008 1084
 			$name='doc.pdf';
1009 1085
 			$dest='I';
1086
+		} else {
1087
+					$dest='F';
1010 1088
 		}
1011
-		else
1012
-			$dest='F';
1013 1089
 	}
1014 1090
 	switch($dest)
1015 1091
 	{
1016 1092
 		case 'I':
1017 1093
 			//Send to standard output
1018
-			if(ob_get_length())
1019
-				$this->Error('Some data has already been output, can\'t send PDF file');
1094
+			if(ob_get_length()) {
1095
+							$this->Error('Some data has already been output, can\'t send PDF file');
1096
+			}
1020 1097
 			if(php_sapi_name()!='cli')
1021 1098
 			{
1022 1099
 				//We send to a browser
1023 1100
 				header('Content-Type: application/pdf');
1024
-				if(headers_sent())
1025
-					$this->Error('Some data has already been output, can\'t send PDF file');
1101
+				if(headers_sent()) {
1102
+									$this->Error('Some data has already been output, can\'t send PDF file');
1103
+				}
1026 1104
 				header('Content-Length: '.strlen($this->buffer));
1027 1105
 				header('Content-Disposition: inline; filename="'.$name.'"');
1028 1106
 				header('Cache-Control: private, max-age=0, must-revalidate');
@@ -1033,11 +1111,13 @@  discard block
 block discarded – undo
1033 1111
 			break;
1034 1112
 		case 'D':
1035 1113
 			//Download file
1036
-			if(ob_get_length())
1037
-				$this->Error('Some data has already been output, can\'t send PDF file');
1114
+			if(ob_get_length()) {
1115
+							$this->Error('Some data has already been output, can\'t send PDF file');
1116
+			}
1038 1117
 			header('Content-Type: application/x-download');
1039
-			if(headers_sent())
1040
-				$this->Error('Some data has already been output, can\'t send PDF file');
1118
+			if(headers_sent()) {
1119
+							$this->Error('Some data has already been output, can\'t send PDF file');
1120
+			}
1041 1121
 			header('Content-Length: '.strlen($this->buffer));
1042 1122
 			header('Content-Disposition: attachment; filename="'.$name.'"');
1043 1123
 			header('Cache-Control: private, max-age=0, must-revalidate');
@@ -1048,8 +1128,9 @@  discard block
 block discarded – undo
1048 1128
 		case 'F':
1049 1129
 			//Save to local file
1050 1130
 			$f=fopen($name,'wb');
1051
-			if(!$f)
1052
-				$this->Error('Unable to create output file: '.$name);
1131
+			if(!$f) {
1132
+							$this->Error('Unable to create output file: '.$name);
1133
+			}
1053 1134
 			fwrite($f,$this->buffer,strlen($this->buffer));
1054 1135
 			fclose($f);
1055 1136
 			break;
@@ -1070,29 +1151,34 @@  discard block
 block discarded – undo
1070 1151
 function _dochecks()
1071 1152
 {
1072 1153
 	//Check availability of %F
1073
-	if(sprintf('%.1F',1.0)!='1.0')
1074
-		$this->Error('This version of PHP is not supported');
1154
+	if(sprintf('%.1F',1.0)!='1.0') {
1155
+			$this->Error('This version of PHP is not supported');
1156
+	}
1075 1157
 	//Check mbstring overloading
1076
-	if(ini_get('mbstring.func_overload') & 2)
1077
-		$this->Error('mbstring overloading must be disabled');
1158
+	if(ini_get('mbstring.func_overload') & 2) {
1159
+			$this->Error('mbstring overloading must be disabled');
1160
+	}
1078 1161
 	//Disable runtime magic quotes
1079
-	if(get_magic_quotes_runtime())
1080
-		@set_magic_quotes_runtime(0);
1081
-}
1162
+	if(get_magic_quotes_runtime()) {
1163
+			@set_magic_quotes_runtime(0);
1164
+	}
1165
+	}
1082 1166
 
1083 1167
 function _getpageformat($format)
1084 1168
 {
1085 1169
 	$format=strtolower($format);
1086
-	if(!isset($this->PageFormats[$format]))
1087
-		$this->Error('Unknown page format: '.$format);
1170
+	if(!isset($this->PageFormats[$format])) {
1171
+			$this->Error('Unknown page format: '.$format);
1172
+	}
1088 1173
 	$a=$this->PageFormats[$format];
1089 1174
 	return array($a[0]/$this->k, $a[1]/$this->k);
1090 1175
 }
1091 1176
 
1092 1177
 function _getfontpath()
1093 1178
 {
1094
-	if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font'))
1095
-		define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
1179
+	if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) {
1180
+			define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
1181
+	}
1096 1182
 	return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
1097 1183
 }
1098 1184
 
@@ -1105,16 +1191,18 @@  discard block
 block discarded – undo
1105 1191
 	$this->y=$this->tMargin;
1106 1192
 	$this->FontFamily='';
1107 1193
 	//Check page size
1108
-	if($orientation=='')
1109
-		$orientation=$this->DefOrientation;
1110
-	else
1111
-		$orientation=strtoupper($orientation[0]);
1112
-	if($format=='')
1113
-		$format=$this->DefPageFormat;
1114
-	else
1194
+	if($orientation=='') {
1195
+			$orientation=$this->DefOrientation;
1196
+	} else {
1197
+			$orientation=strtoupper($orientation[0]);
1198
+	}
1199
+	if($format=='') {
1200
+			$format=$this->DefPageFormat;
1201
+	} else
1115 1202
 	{
1116
-		if(is_string($format))
1117
-			$format=$this->_getpageformat($format);
1203
+		if(is_string($format)) {
1204
+					$format=$this->_getpageformat($format);
1205
+		}
1118 1206
 	}
1119 1207
 	if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1])
1120 1208
 	{
@@ -1123,8 +1211,7 @@  discard block
 block discarded – undo
1123 1211
 		{
1124 1212
 			$this->w=$format[0];
1125 1213
 			$this->h=$format[1];
1126
-		}
1127
-		else
1214
+		} else
1128 1215
 		{
1129 1216
 			$this->w=$format[1];
1130 1217
 			$this->h=$format[0];
@@ -1135,9 +1222,10 @@  discard block
 block discarded – undo
1135 1222
 		$this->CurOrientation=$orientation;
1136 1223
 		$this->CurPageFormat=$format;
1137 1224
 	}
1138
-	if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1])
1139
-		$this->PageSizes[$this->page]=array($this->wPt, $this->hPt);
1140
-}
1225
+	if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1]) {
1226
+			$this->PageSizes[$this->page]=array($this->wPt, $this->hPt);
1227
+	}
1228
+	}
1141 1229
 
1142 1230
 function _endpage()
1143 1231
 {
@@ -1176,15 +1264,13 @@  discard block
 block discarded – undo
1176 1264
 			$c3=ord($s[$i++]);
1177 1265
 			$res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
1178 1266
 			$res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
1179
-		}
1180
-		elseif($c1>=192)
1267
+		} elseif($c1>=192)
1181 1268
 		{
1182 1269
 			//2-byte character
1183 1270
 			$c2=ord($s[$i++]);
1184 1271
 			$res.=chr(($c1 & 0x1C)>>2);
1185 1272
 			$res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
1186
-		}
1187
-		else
1273
+		} else
1188 1274
 		{
1189 1275
 			//Single-byte character
1190 1276
 			$res.="\0".chr($c1);
@@ -1206,22 +1292,26 @@  discard block
 block discarded – undo
1206 1292
 {
1207 1293
 	//Extract info from a JPEG file
1208 1294
 	$a=GetImageSize($file);
1209
-	if(!$a)
1210
-		$this->Error('Missing or incorrect image file: '.$file);
1211
-	if($a[2]!=2)
1212
-		$this->Error('Not a JPEG file: '.$file);
1213
-	if(!isset($a['channels']) || $a['channels']==3)
1214
-		$colspace='DeviceRGB';
1215
-	elseif($a['channels']==4)
1216
-		$colspace='DeviceCMYK';
1217
-	else
1218
-		$colspace='DeviceGray';
1295
+	if(!$a) {
1296
+			$this->Error('Missing or incorrect image file: '.$file);
1297
+	}
1298
+	if($a[2]!=2) {
1299
+			$this->Error('Not a JPEG file: '.$file);
1300
+	}
1301
+	if(!isset($a['channels']) || $a['channels']==3) {
1302
+			$colspace='DeviceRGB';
1303
+	} elseif($a['channels']==4) {
1304
+			$colspace='DeviceCMYK';
1305
+	} else {
1306
+			$colspace='DeviceGray';
1307
+	}
1219 1308
 	$bpc=isset($a['bits']) ? $a['bits'] : 8;
1220 1309
 	//Read whole file
1221 1310
 	$f=fopen($file,'rb');
1222 1311
 	$data='';
1223
-	while(!feof($f))
1224
-		$data.=fread($f,8192);
1312
+	while(!feof($f)) {
1313
+			$data.=fread($f,8192);
1314
+	}
1225 1315
 	fclose($f);
1226 1316
 	return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
1227 1317
 }
@@ -1230,35 +1320,43 @@  discard block
 block discarded – undo
1230 1320
 {
1231 1321
 	//Extract info from a PNG file
1232 1322
 	$f=fopen($file,'rb');
1233
-	if(!$f)
1234
-		$this->Error('Can\'t open image file: '.$file);
1323
+	if(!$f) {
1324
+			$this->Error('Can\'t open image file: '.$file);
1325
+	}
1235 1326
 	//Check signature
1236
-	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1237
-		$this->Error('Not a PNG file: '.$file);
1327
+	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
1328
+			$this->Error('Not a PNG file: '.$file);
1329
+	}
1238 1330
 	//Read header chunk
1239 1331
 	$this->_readstream($f,4);
1240
-	if($this->_readstream($f,4)!='IHDR')
1241
-		$this->Error('Incorrect PNG file: '.$file);
1332
+	if($this->_readstream($f,4)!='IHDR') {
1333
+			$this->Error('Incorrect PNG file: '.$file);
1334
+	}
1242 1335
 	$w=$this->_readint($f);
1243 1336
 	$h=$this->_readint($f);
1244 1337
 	$bpc=ord($this->_readstream($f,1));
1245
-	if($bpc>8)
1246
-		$this->Error('16-bit depth not supported: '.$file);
1338
+	if($bpc>8) {
1339
+			$this->Error('16-bit depth not supported: '.$file);
1340
+	}
1247 1341
 	$ct=ord($this->_readstream($f,1));
1248
-	if($ct==0)
1249
-		$colspace='DeviceGray';
1250
-	elseif($ct==2)
1251
-		$colspace='DeviceRGB';
1252
-	elseif($ct==3)
1253
-		$colspace='Indexed';
1254
-	else
1255
-		$this->Error('Alpha channel not supported: '.$file);
1256
-	if(ord($this->_readstream($f,1))!=0)
1257
-		$this->Error('Unknown compression method: '.$file);
1258
-	if(ord($this->_readstream($f,1))!=0)
1259
-		$this->Error('Unknown filter method: '.$file);
1260
-	if(ord($this->_readstream($f,1))!=0)
1261
-		$this->Error('Interlacing not supported: '.$file);
1342
+	if($ct==0) {
1343
+			$colspace='DeviceGray';
1344
+	} elseif($ct==2) {
1345
+			$colspace='DeviceRGB';
1346
+	} elseif($ct==3) {
1347
+			$colspace='Indexed';
1348
+	} else {
1349
+			$this->Error('Alpha channel not supported: '.$file);
1350
+	}
1351
+	if(ord($this->_readstream($f,1))!=0) {
1352
+			$this->Error('Unknown compression method: '.$file);
1353
+	}
1354
+	if(ord($this->_readstream($f,1))!=0) {
1355
+			$this->Error('Unknown filter method: '.$file);
1356
+	}
1357
+	if(ord($this->_readstream($f,1))!=0) {
1358
+			$this->Error('Interlacing not supported: '.$file);
1359
+	}
1262 1360
 	$this->_readstream($f,4);
1263 1361
 	$parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';
1264 1362
 	//Scan chunks looking for palette, transparency and image data
@@ -1274,37 +1372,37 @@  discard block
 block discarded – undo
1274 1372
 			//Read palette
1275 1373
 			$pal=$this->_readstream($f,$n);
1276 1374
 			$this->_readstream($f,4);
1277
-		}
1278
-		elseif($type=='tRNS')
1375
+		} elseif($type=='tRNS')
1279 1376
 		{
1280 1377
 			//Read transparency info
1281 1378
 			$t=$this->_readstream($f,$n);
1282
-			if($ct==0)
1283
-				$trns=array(ord(substr($t,1,1)));
1284
-			elseif($ct==2)
1285
-				$trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
1286
-			else
1379
+			if($ct==0) {
1380
+							$trns=array(ord(substr($t,1,1)));
1381
+			} elseif($ct==2) {
1382
+							$trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
1383
+			} else
1287 1384
 			{
1288 1385
 				$pos=strpos($t,chr(0));
1289
-				if($pos!==false)
1290
-					$trns=array($pos);
1386
+				if($pos!==false) {
1387
+									$trns=array($pos);
1388
+				}
1291 1389
 			}
1292 1390
 			$this->_readstream($f,4);
1293
-		}
1294
-		elseif($type=='IDAT')
1391
+		} elseif($type=='IDAT')
1295 1392
 		{
1296 1393
 			//Read image data block
1297 1394
 			$data.=$this->_readstream($f,$n);
1298 1395
 			$this->_readstream($f,4);
1396
+		} elseif($type=='IEND') {
1397
+					break;
1398
+		} else {
1399
+					$this->_readstream($f,$n+4);
1299 1400
 		}
1300
-		elseif($type=='IEND')
1301
-			break;
1302
-		else
1303
-			$this->_readstream($f,$n+4);
1304 1401
 	}
1305 1402
 	while($n);
1306
-	if($colspace=='Indexed' && empty($pal))
1307
-		$this->Error('Missing palette in '.$file);
1403
+	if($colspace=='Indexed' && empty($pal)) {
1404
+			$this->Error('Missing palette in '.$file);
1405
+	}
1308 1406
 	fclose($f);
1309 1407
 	return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data);
1310 1408
 }
@@ -1316,13 +1414,15 @@  discard block
 block discarded – undo
1316 1414
 	while($n>0 && !feof($f))
1317 1415
 	{
1318 1416
 		$s=fread($f,$n);
1319
-		if($s===false)
1320
-			$this->Error('Error while reading stream');
1417
+		if($s===false) {
1418
+					$this->Error('Error while reading stream');
1419
+		}
1321 1420
 		$n-=strlen($s);
1322 1421
 		$res.=$s;
1323 1422
 	}
1324
-	if($n>0)
1325
-		$this->Error('Unexpected end of stream');
1423
+	if($n>0) {
1424
+			$this->Error('Unexpected end of stream');
1425
+	}
1326 1426
 	return $res;
1327 1427
 }
1328 1428
 
@@ -1336,19 +1436,24 @@  discard block
 block discarded – undo
1336 1436
 function _parsegif($file)
1337 1437
 {
1338 1438
 	//Extract info from a GIF file (via PNG conversion)
1339
-	if(!function_exists('imagepng'))
1340
-		$this->Error('GD extension is required for GIF support');
1341
-	if(!function_exists('imagecreatefromgif'))
1342
-		$this->Error('GD has no GIF read support');
1439
+	if(!function_exists('imagepng')) {
1440
+			$this->Error('GD extension is required for GIF support');
1441
+	}
1442
+	if(!function_exists('imagecreatefromgif')) {
1443
+			$this->Error('GD has no GIF read support');
1444
+	}
1343 1445
 	$im=imagecreatefromgif($file);
1344
-	if(!$im)
1345
-		$this->Error('Missing or incorrect image file: '.$file);
1446
+	if(!$im) {
1447
+			$this->Error('Missing or incorrect image file: '.$file);
1448
+	}
1346 1449
 	imageinterlace($im,0);
1347 1450
 	$tmp=tempnam('.','gif');
1348
-	if(!$tmp)
1349
-		$this->Error('Unable to create a temporary file');
1350
-	if(!imagepng($im,$tmp))
1351
-		$this->Error('Error while saving to temporary file');
1451
+	if(!$tmp) {
1452
+			$this->Error('Unable to create a temporary file');
1453
+	}
1454
+	if(!imagepng($im,$tmp)) {
1455
+			$this->Error('Error while saving to temporary file');
1456
+	}
1352 1457
 	imagedestroy($im);
1353 1458
 	$info=$this->_parsepng($tmp);
1354 1459
 	unlink($tmp);
@@ -1373,11 +1478,12 @@  discard block
 block discarded – undo
1373 1478
 function _out($s)
1374 1479
 {
1375 1480
 	//Add a line to the document
1376
-	if($this->state==2)
1377
-		$this->pages[$this->page].=$s."\n";
1378
-	else
1379
-		$this->buffer.=$s."\n";
1380
-}
1481
+	if($this->state==2) {
1482
+			$this->pages[$this->page].=$s."\n";
1483
+	} else {
1484
+			$this->buffer.=$s."\n";
1485
+	}
1486
+	}
1381 1487
 
1382 1488
 function _putpages()
1383 1489
 {
@@ -1385,15 +1491,15 @@  discard block
 block discarded – undo
1385 1491
 	if(!empty($this->AliasNbPages))
1386 1492
 	{
1387 1493
 		//Replace number of pages
1388
-		for($n=1;$n<=$nb;$n++)
1389
-			$this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
1494
+		for($n=1;$n<=$nb;$n++) {
1495
+					$this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
1496
+		}
1390 1497
 	}
1391 1498
 	if($this->DefOrientation=='P')
1392 1499
 	{
1393 1500
 		$wPt=$this->DefPageFormat[0]*$this->k;
1394 1501
 		$hPt=$this->DefPageFormat[1]*$this->k;
1395
-	}
1396
-	else
1502
+	} else
1397 1503
 	{
1398 1504
 		$wPt=$this->DefPageFormat[1]*$this->k;
1399 1505
 		$hPt=$this->DefPageFormat[0]*$this->k;
@@ -1405,8 +1511,9 @@  discard block
 block discarded – undo
1405 1511
 		$this->_newobj();
1406 1512
 		$this->_out('<</Type /Page');
1407 1513
 		$this->_out('/Parent 1 0 R');
1408
-		if(isset($this->PageSizes[$n]))
1409
-			$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
1514
+		if(isset($this->PageSizes[$n])) {
1515
+					$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
1516
+		}
1410 1517
 		$this->_out('/Resources 2 0 R');
1411 1518
 		if(isset($this->PageLinks[$n]))
1412 1519
 		{
@@ -1416,9 +1523,9 @@  discard block
 block discarded – undo
1416 1523
 			{
1417 1524
 				$rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
1418 1525
 				$annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1419
-				if(is_string($pl[4]))
1420
-					$annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1421
-				else
1526
+				if(is_string($pl[4])) {
1527
+									$annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1528
+				} else
1422 1529
 				{
1423 1530
 					$l=$this->links[$pl[4]];
1424 1531
 					$h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
@@ -1441,8 +1548,9 @@  discard block
 block discarded – undo
1441 1548
 	$this->_out('1 0 obj');
1442 1549
 	$this->_out('<</Type /Pages');
1443 1550
 	$kids='/Kids [';
1444
-	for($i=0;$i<$nb;$i++)
1445
-		$kids.=(3+2*$i).' 0 R ';
1551
+	for($i=0;$i<$nb;$i++) {
1552
+			$kids.=(3+2*$i).' 0 R ';
1553
+	}
1446 1554
 	$this->_out($kids.']');
1447 1555
 	$this->_out('/Count '.$nb);
1448 1556
 	$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt));
@@ -1467,10 +1575,12 @@  discard block
 block discarded – undo
1467 1575
 		$this->FontFiles[$file]['n']=$this->n;
1468 1576
 		$font='';
1469 1577
 		$f=fopen($this->_getfontpath().$file,'rb',1);
1470
-		if(!$f)
1471
-			$this->Error('Font file not found');
1472
-		while(!feof($f))
1473
-			$font.=fread($f,8192);
1578
+		if(!$f) {
1579
+					$this->Error('Font file not found');
1580
+		}
1581
+		while(!feof($f)) {
1582
+					$font.=fread($f,8192);
1583
+		}
1474 1584
 		fclose($f);
1475 1585
 		$compressed=(substr($file,-2)=='.z');
1476 1586
 		if(!$compressed && isset($info['length2']))
@@ -1488,11 +1598,13 @@  discard block
 block discarded – undo
1488 1598
 			}
1489 1599
 		}
1490 1600
 		$this->_out('<</Length '.strlen($font));
1491
-		if($compressed)
1492
-			$this->_out('/Filter /FlateDecode');
1601
+		if($compressed) {
1602
+					$this->_out('/Filter /FlateDecode');
1603
+		}
1493 1604
 		$this->_out('/Length1 '.$info['length1']);
1494
-		if(isset($info['length2']))
1495
-			$this->_out('/Length2 '.$info['length2'].' /Length3 0');
1605
+		if(isset($info['length2'])) {
1606
+					$this->_out('/Length2 '.$info['length2'].' /Length3 0');
1607
+		}
1496 1608
 		$this->_out('>>');
1497 1609
 		$this->_putstream($font);
1498 1610
 		$this->_out('endobj');
@@ -1510,12 +1622,12 @@  discard block
 block discarded – undo
1510 1622
 			$this->_out('<</Type /Font');
1511 1623
 			$this->_out('/BaseFont /'.$name);
1512 1624
 			$this->_out('/Subtype /Type1');
1513
-			if($name!='Symbol' && $name!='ZapfDingbats')
1514
-				$this->_out('/Encoding /WinAnsiEncoding');
1625
+			if($name!='Symbol' && $name!='ZapfDingbats') {
1626
+							$this->_out('/Encoding /WinAnsiEncoding');
1627
+			}
1515 1628
 			$this->_out('>>');
1516 1629
 			$this->_out('endobj');
1517
-		}
1518
-		elseif($type=='Type1' || $type=='TrueType')
1630
+		} elseif($type=='Type1' || $type=='TrueType')
1519 1631
 		{
1520 1632
 			//Additional Type1 or TrueType font
1521 1633
 			$this->_newobj();
@@ -1527,10 +1639,11 @@  discard block
 block discarded – undo
1527 1639
 			$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
1528 1640
 			if($font['enc'])
1529 1641
 			{
1530
-				if(isset($font['diff']))
1531
-					$this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
1532
-				else
1533
-					$this->_out('/Encoding /WinAnsiEncoding');
1642
+				if(isset($font['diff'])) {
1643
+									$this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
1644
+				} else {
1645
+									$this->_out('/Encoding /WinAnsiEncoding');
1646
+				}
1534 1647
 			}
1535 1648
 			$this->_out('>>');
1536 1649
 			$this->_out('endobj');
@@ -1538,27 +1651,30 @@  discard block
 block discarded – undo
1538 1651
 			$this->_newobj();
1539 1652
 			$cw=&$font['cw'];
1540 1653
 			$s='[';
1541
-			for($i=32;$i<=255;$i++)
1542
-				$s.=$cw[chr($i)].' ';
1654
+			for($i=32;$i<=255;$i++) {
1655
+							$s.=$cw[chr($i)].' ';
1656
+			}
1543 1657
 			$this->_out($s.']');
1544 1658
 			$this->_out('endobj');
1545 1659
 			//Descriptor
1546 1660
 			$this->_newobj();
1547 1661
 			$s='<</Type /FontDescriptor /FontName /'.$name;
1548
-			foreach($font['desc'] as $k=>$v)
1549
-				$s.=' /'.$k.' '.$v;
1662
+			foreach($font['desc'] as $k=>$v) {
1663
+							$s.=' /'.$k.' '.$v;
1664
+			}
1550 1665
 			$file=$font['file'];
1551
-			if($file)
1552
-				$s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
1666
+			if($file) {
1667
+							$s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
1668
+			}
1553 1669
 			$this->_out($s.'>>');
1554 1670
 			$this->_out('endobj');
1555
-		}
1556
-		else
1671
+		} else
1557 1672
 		{
1558 1673
 			//Allow for additional types
1559 1674
 			$mtd='_put'.strtolower($type);
1560
-			if(!method_exists($this,$mtd))
1561
-				$this->Error('Unsupported font type: '.$type);
1675
+			if(!method_exists($this,$mtd)) {
1676
+							$this->Error('Unsupported font type: '.$type);
1677
+			}
1562 1678
 			$this->$mtd($font);
1563 1679
 		}
1564 1680
 	}
@@ -1576,24 +1692,28 @@  discard block
 block discarded – undo
1576 1692
 		$this->_out('/Subtype /Image');
1577 1693
 		$this->_out('/Width '.$info['w']);
1578 1694
 		$this->_out('/Height '.$info['h']);
1579
-		if($info['cs']=='Indexed')
1580
-			$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
1581
-		else
1695
+		if($info['cs']=='Indexed') {
1696
+					$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
1697
+		} else
1582 1698
 		{
1583 1699
 			$this->_out('/ColorSpace /'.$info['cs']);
1584
-			if($info['cs']=='DeviceCMYK')
1585
-				$this->_out('/Decode [1 0 1 0 1 0 1 0]');
1700
+			if($info['cs']=='DeviceCMYK') {
1701
+							$this->_out('/Decode [1 0 1 0 1 0 1 0]');
1702
+			}
1586 1703
 		}
1587 1704
 		$this->_out('/BitsPerComponent '.$info['bpc']);
1588
-		if(isset($info['f']))
1589
-			$this->_out('/Filter /'.$info['f']);
1590
-		if(isset($info['parms']))
1591
-			$this->_out($info['parms']);
1705
+		if(isset($info['f'])) {
1706
+					$this->_out('/Filter /'.$info['f']);
1707
+		}
1708
+		if(isset($info['parms'])) {
1709
+					$this->_out($info['parms']);
1710
+		}
1592 1711
 		if(isset($info['trns']) && is_array($info['trns']))
1593 1712
 		{
1594 1713
 			$trns='';
1595
-			for($i=0;$i<count($info['trns']);$i++)
1596
-				$trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
1714
+			for($i=0;$i<count($info['trns']);$i++) {
1715
+							$trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
1716
+			}
1597 1717
 			$this->_out('/Mask ['.$trns.']');
1598 1718
 		}
1599 1719
 		$this->_out('/Length '.strlen($info['data']).'>>');
@@ -1614,16 +1734,18 @@  discard block
 block discarded – undo
1614 1734
 
1615 1735
 function _putxobjectdict()
1616 1736
 {
1617
-	foreach($this->images as $image)
1618
-		$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
1619
-}
1737
+	foreach($this->images as $image) {
1738
+			$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
1739
+	}
1740
+	}
1620 1741
 
1621 1742
 function _putresourcedict()
1622 1743
 {
1623 1744
 	$this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
1624 1745
 	$this->_out('/Font <<');
1625
-	foreach($this->fonts as $font)
1626
-		$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
1746
+	foreach($this->fonts as $font) {
1747
+			$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
1748
+	}
1627 1749
 	$this->_out('>>');
1628 1750
 	$this->_out('/XObject <<');
1629 1751
 	$this->_putxobjectdict();
@@ -1646,16 +1768,21 @@  discard block
 block discarded – undo
1646 1768
 function _putinfo()
1647 1769
 {
1648 1770
 	$this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
1649
-	if(!empty($this->title))
1650
-		$this->_out('/Title '.$this->_textstring($this->title));
1651
-	if(!empty($this->subject))
1652
-		$this->_out('/Subject '.$this->_textstring($this->subject));
1653
-	if(!empty($this->author))
1654
-		$this->_out('/Author '.$this->_textstring($this->author));
1655
-	if(!empty($this->keywords))
1656
-		$this->_out('/Keywords '.$this->_textstring($this->keywords));
1657
-	if(!empty($this->creator))
1658
-		$this->_out('/Creator '.$this->_textstring($this->creator));
1771
+	if(!empty($this->title)) {
1772
+			$this->_out('/Title '.$this->_textstring($this->title));
1773
+	}
1774
+	if(!empty($this->subject)) {
1775
+			$this->_out('/Subject '.$this->_textstring($this->subject));
1776
+	}
1777
+	if(!empty($this->author)) {
1778
+			$this->_out('/Author '.$this->_textstring($this->author));
1779
+	}
1780
+	if(!empty($this->keywords)) {
1781
+			$this->_out('/Keywords '.$this->_textstring($this->keywords));
1782
+	}
1783
+	if(!empty($this->creator)) {
1784
+			$this->_out('/Creator '.$this->_textstring($this->creator));
1785
+	}
1659 1786
 	$this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
1660 1787
 }
1661 1788
 
@@ -1663,21 +1790,23 @@  discard block
 block discarded – undo
1663 1790
 {
1664 1791
 	$this->_out('/Type /Catalog');
1665 1792
 	$this->_out('/Pages 1 0 R');
1666
-	if($this->ZoomMode=='fullpage')
1667
-		$this->_out('/OpenAction [3 0 R /Fit]');
1668
-	elseif($this->ZoomMode=='fullwidth')
1669
-		$this->_out('/OpenAction [3 0 R /FitH null]');
1670
-	elseif($this->ZoomMode=='real')
1671
-		$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
1672
-	elseif(!is_string($this->ZoomMode))
1673
-		$this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');
1674
-	if($this->LayoutMode=='single')
1675
-		$this->_out('/PageLayout /SinglePage');
1676
-	elseif($this->LayoutMode=='continuous')
1677
-		$this->_out('/PageLayout /OneColumn');
1678
-	elseif($this->LayoutMode=='two')
1679
-		$this->_out('/PageLayout /TwoColumnLeft');
1680
-}
1793
+	if($this->ZoomMode=='fullpage') {
1794
+			$this->_out('/OpenAction [3 0 R /Fit]');
1795
+	} elseif($this->ZoomMode=='fullwidth') {
1796
+			$this->_out('/OpenAction [3 0 R /FitH null]');
1797
+	} elseif($this->ZoomMode=='real') {
1798
+			$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
1799
+	} elseif(!is_string($this->ZoomMode)) {
1800
+			$this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');
1801
+	}
1802
+	if($this->LayoutMode=='single') {
1803
+			$this->_out('/PageLayout /SinglePage');
1804
+	} elseif($this->LayoutMode=='continuous') {
1805
+			$this->_out('/PageLayout /OneColumn');
1806
+	} elseif($this->LayoutMode=='two') {
1807
+			$this->_out('/PageLayout /TwoColumnLeft');
1808
+	}
1809
+	}
1681 1810
 
1682 1811
 function _putheader()
1683 1812
 {
@@ -1713,8 +1842,9 @@  discard block
 block discarded – undo
1713 1842
 	$this->_out('xref');
1714 1843
 	$this->_out('0 '.($this->n+1));
1715 1844
 	$this->_out('0000000000 65535 f ');
1716
-	for($i=1;$i<=$this->n;$i++)
1717
-		$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
1845
+	for($i=1;$i<=$this->n;$i++) {
1846
+			$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
1847
+	}
1718 1848
 	//Trailer
1719 1849
 	$this->_out('trailer');
1720 1850
 	$this->_out('<<');
Please login to merge, or discard this patch.
includes/librairies/pdf/fpdf_extends.class.php 3 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -57,6 +57,10 @@  discard block
 block discarded – undo
57 57
 	}
58 58
 
59 59
 	// Cr�ation r�cursive de dossiers
60
+
61
+	/**
62
+	 * @param string $path
63
+	 */
60 64
 	function make_recursiv_dir($path, $rights = 0777) {
61 65
 		if (!@is_dir($path)) {
62 66
 			$folder_path = array($path);
@@ -313,6 +317,11 @@  discard block
 block discarded – undo
313 317
 	}
314 318
 
315 319
 	// Affiche un ligne de la facture
320
+
321
+	/**
322
+	 * @param integer[] $dim_array
323
+	 * @param string $currency
324
+	 */
316 325
 	function row($row, $dim_array, $currency) {
317 326
 
318 327
 		// S�curit�
@@ -336,6 +345,9 @@  discard block
 block discarded – undo
336 345
 		$this->Ln();
337 346
 	}
338 347
 
348
+	/**
349
+	 * @param string $currency
350
+	 */
339 351
 	function total($order_id, $currency, $invoice_id = null) {
340 352
 
341 353
 		/* Donn�es commande */
Please login to merge, or discard this patch.
Spacing   +108 added lines, -108 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
 DEFINE('EUR', chr(128)); // Sigle �
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 	function WordWrap(&$text, $maxwidth) {
23 23
 		$text = trim($text);
24
-		if ($text==='')
24
+		if ($text === '')
25 25
 			return 0;
26 26
 		$space = $this->GetStringWidth(' ');
27 27
 		$lines = explode("\n", $text);
@@ -39,16 +39,16 @@  discard block
 block discarded – undo
39 39
 				if ($width + $wordwidth <= $maxwidth)
40 40
 				{
41 41
 					$width += $wordwidth + $space;
42
-					$text .= $word.' ';
42
+					$text .= $word . ' ';
43 43
 				}
44 44
 				else
45 45
 				{
46 46
 					$width = $wordwidth + $space;
47
-					$text = rtrim($text)."\n".$word.' ';
47
+					$text = rtrim($text) . "\n" . $word . ' ';
48 48
 					$count++;
49 49
 				}
50 50
 			}
51
-			$text = rtrim($text)."\n";
51
+			$text = rtrim($text) . "\n";
52 52
 			$count++;
53 53
 		}
54 54
 		$text = rtrim($text);
@@ -65,28 +65,28 @@  discard block
 block discarded – undo
65 65
 			return;
66 66
 		}
67 67
 
68
-		while(!@is_dir(dirname(end($folder_path))) && dirname(end($folder_path)) != '/' && dirname(end($folder_path)) != '.' && dirname(end($folder_path)) != '') {
68
+		while (!@is_dir(dirname(end($folder_path))) && dirname(end($folder_path)) != '/' && dirname(end($folder_path)) != '.' && dirname(end($folder_path)) != '') {
69 69
 			array_push($folder_path, dirname(end($folder_path)));
70 70
 		}
71 71
 
72
-		while($parent_folder_path = array_pop($folder_path)) {
73
-			if(!@mkdir($parent_folder_path, $rights)) {
72
+		while ($parent_folder_path = array_pop($folder_path)) {
73
+			if (!@mkdir($parent_folder_path, $rights)) {
74 74
 				user_error("Can't create folder \"$parent_folder_path\".\n");
75 75
 			}
76 76
 		}
77 77
 	}
78 78
 
79
-	function invoice_export( $order_id, $invoice_id = null ) {
79
+	function invoice_export($order_id, $invoice_id = null) {
80 80
 
81 81
 		$current_user_id = get_current_user_id();
82 82
 		$order = get_post_meta($order_id, '_order_postmeta', true);
83 83
 
84
-		if($order['customer_id']==$current_user_id OR is_admin()) {
84
+		if ($order['customer_id'] == $current_user_id OR is_admin()) {
85 85
 
86 86
 			if (in_array($order['order_status'], array('completed', 'shipped', 'partially_paid'))) {
87 87
 				$invoice_dir = WP_CONTENT_DIR . "/uploads/wpshop_invoices/";
88 88
 				$filename = $this->get_invoice_filename($order_id);
89
-				$invoice_url = $invoice_dir.$filename;
89
+				$invoice_url = $invoice_dir . $filename;
90 90
 
91 91
 				// If the invoice has not been already generated
92 92
 // 				if ( !file_exists($invoice_url) ) {
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 
95 95
 					// Currency management
96 96
 					$currency = $order['order_currency'];
97
-					if($currency == 'EUR')$currency = EUR;
98
-					else $currency = html_entity_decode( wpshop_tools::wpshop_get_sigle($currency) );
97
+					if ($currency == 'EUR')$currency = EUR;
98
+					else $currency = html_entity_decode(wpshop_tools::wpshop_get_sigle($currency));
99 99
 
100 100
 					// On d�finit un alias pour le nombre de pages total
101 101
 					$this->AliasNbPages();
102 102
 					// On ajoute une page au document
103 103
 					$this->AddPage();
104 104
 					// On lui applique une police
105
-					$this->SetFont('Arial','',10);
105
+					$this->SetFont('Arial', '', 10);
106 106
 					// Coordonn�es magasin
107 107
 					$this->store_head($order_id);
108 108
 					// Coordonn�es client
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
 					$path = $invoice_url;
126 126
 					$this->Output($path, "F");
127 127
 					// On force le t�l�chargement de la facture
128
-					$Fichier_a_telecharger = $refdate.".pdf";
128
+					$Fichier_a_telecharger = $refdate . ".pdf";
129 129
 					$this->forceDownload($Fichier_a_telecharger, $path, filesize($path));
130 130
 // 				}
131 131
 // 				else $this->forceDownload($filename, $invoice_url, filesize($invoice_url));
132 132
 			}
133
-			else echo __('The payment regarding the invoice you requested isn\'t completed','wpshop');
133
+			else echo __('The payment regarding the invoice you requested isn\'t completed', 'wpshop');
134 134
 		}
135
-		else echo __('You don\'t have the rights to access this invoice.','wpshop');
135
+		else echo __('You don\'t have the rights to access this invoice.', 'wpshop');
136 136
 	}
137 137
 
138 138
 	/** Force le t�l�chargement d'un fichier */
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
 		$emails = get_option('wpshop_emails', array());
158 158
 
159 159
 		//Positionnement
160
-		$this->SetY(55);$this->SetX(12);
160
+		$this->SetY(55); $this->SetX(12);
161 161
 		// Cadre client destinataire
162 162
 		$this->rect(10, 52, 80, 40);
163 163
 
164 164
 		$xsize = 80;
165 165
 
166
-		if(!empty($company) && !empty($emails)) {
166
+		if (!empty($company) && !empty($emails)) {
167 167
 			// Infos
168 168
 			$store_name = utf8_decode(utf8_encode($company['company_name']));
169 169
 			$store_email = !empty($emails['contact_email']) ? $emails['contact_email'] : null;
@@ -176,19 +176,19 @@  discard block
 block discarded – undo
176 176
 			$store_country = utf8_decode(utf8_encode($company['company_country']));
177 177
 
178 178
 			// Gras pour le titre
179
-			$this->SetFont('','B',10);
180
-			$this->Cell($xsize,5,$store_name,0,1,'L'); $this->SetX(12);
179
+			$this->SetFont('', 'B', 10);
180
+			$this->Cell($xsize, 5, $store_name, 0, 1, 'L'); $this->SetX(12);
181 181
 			// Police normale pour le reste
182
-			$this->SetFont('','',9);
183
-			$this->Cell($xsize,4,$store_street_adress,0,1,'L'); $this->SetX(12);
184
-			if (!empty($store_suburb)){$this->Cell(80,4,$store_suburb,0,1,'L');} $this->SetX(12);
185
-			$this->Cell($xsize,4,$store_postcode . ' ' . $store_city,0,1,'L'); $this->SetX(12);
182
+			$this->SetFont('', '', 9);
183
+			$this->Cell($xsize, 4, $store_street_adress, 0, 1, 'L'); $this->SetX(12);
184
+			if (!empty($store_suburb)) {$this->Cell(80, 4, $store_suburb, 0, 1, 'L'); } $this->SetX(12);
185
+			$this->Cell($xsize, 4, $store_postcode . ' ' . $store_city, 0, 1, 'L'); $this->SetX(12);
186 186
 			//if ($store_state != ''){$this->Cell(80,4,$store_state,0,1,'L');} $this->SetX(12);
187
-			$this->Cell($xsize,4,$store_country,0,1,'L'); $this->SetX(12);
188
-			$this->Cell($xsize,4,$store_email,0,1,'L'); $this->SetX(12);
187
+			$this->Cell($xsize, 4, $store_country, 0, 1, 'L'); $this->SetX(12);
188
+			$this->Cell($xsize, 4, $store_email, 0, 1, 'L'); $this->SetX(12);
189 189
 		}
190 190
 		else {
191
-			$this->Cell($xsize,5,_('Nc','wpshop'),0,1,'L');
191
+			$this->Cell($xsize, 5, _('Nc', 'wpshop'), 0, 1, 'L');
192 192
 		}
193 193
 	}
194 194
 
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
 		$customer_data = $customer_data['billing']['address'];
199 199
 
200 200
 		// FPDF ne d�codant pas l'UTF-8, on le fait via PHP
201
-		$customer_firstname = ( !empty($customer_data['address_first_name']) ) ? utf8_decode(utf8_encode($customer_data['address_first_name'])) : null;
202
-		$customer_lastname = ( !empty($customer_data['address_last_name']) ) ? utf8_decode(utf8_encode($customer_data['address_last_name'])) : null;
203
-		$customer_company = ( !empty($customer_data['company']) ) ? utf8_decode(utf8_encode($customer_data['company'])) : null;
204
-		$customer_street_adress = ( !empty($customer_data['address']) ) ? utf8_decode(utf8_encode($customer_data['address'])) : null;
205
-		$customer_city = ( !empty($customer_data['city']) ) ? utf8_decode(utf8_encode($customer_data['city'])) : null;
206
-		$customer_postcode = ( !empty($customer_data['postcode']) ) ? utf8_decode(utf8_encode($customer_data['postcode'])) : null;
207
-		$customer_state = ( !empty($customer_data['state']) ) ? utf8_decode(utf8_encode($customer_data['state'])) : null;
208
-		$customer_country = ( !empty($customer_data['country']) ) ? utf8_decode(utf8_encode($customer_data['country'])) : null;
201
+		$customer_firstname = (!empty($customer_data['address_first_name'])) ? utf8_decode(utf8_encode($customer_data['address_first_name'])) : null;
202
+		$customer_lastname = (!empty($customer_data['address_last_name'])) ? utf8_decode(utf8_encode($customer_data['address_last_name'])) : null;
203
+		$customer_company = (!empty($customer_data['company'])) ? utf8_decode(utf8_encode($customer_data['company'])) : null;
204
+		$customer_street_adress = (!empty($customer_data['address'])) ? utf8_decode(utf8_encode($customer_data['address'])) : null;
205
+		$customer_city = (!empty($customer_data['city'])) ? utf8_decode(utf8_encode($customer_data['city'])) : null;
206
+		$customer_postcode = (!empty($customer_data['postcode'])) ? utf8_decode(utf8_encode($customer_data['postcode'])) : null;
207
+		$customer_state = (!empty($customer_data['state'])) ? utf8_decode(utf8_encode($customer_data['state'])) : null;
208
+		$customer_country = (!empty($customer_data['country'])) ? utf8_decode(utf8_encode($customer_data['country'])) : null;
209 209
 
210
-		$customer_tva_intra = ( !empty($customer_data['company_tva_intra']) ) ? utf8_decode(utf8_encode($customer_data['company_tva_intra'])) : null;
210
+		$customer_tva_intra = (!empty($customer_data['company_tva_intra'])) ? utf8_decode(utf8_encode($customer_data['company_tva_intra'])) : null;
211 211
 
212 212
 		$xsize = 80;
213 213
 
@@ -219,16 +219,16 @@  discard block
 block discarded – undo
219 219
 		// Et on �cris
220 220
 		// On r�gle la police d'�criture
221 221
 		// gras pour le titre
222
-		$this->SetFont('','B',10);
223
-		$this->Cell($xsize,5,$customer_lastname.' '.$customer_firstname.(!empty($customer_company)?', '.$customer_company:null),0,1,'L'); $this->SetX(102);
222
+		$this->SetFont('', 'B', 10);
223
+		$this->Cell($xsize, 5, $customer_lastname . ' ' . $customer_firstname . (!empty($customer_company) ? ', ' . $customer_company : null), 0, 1, 'L'); $this->SetX(102);
224 224
 		// Police normale pour le reste
225
-		$this->SetFont('','',9);
226
-		$this->Cell($xsize,4,$customer_street_adress,0,1,'L'); $this->SetX(102);
227
-		if (!empty($customer_suburb)){$this->Cell($xsize,4,$customer_suburb,0,1,'L');} $this->SetX(102);
228
-		$this->Cell($xsize,4,$customer_postcode . ' ' . $customer_city,0,1,'L'); $this->SetX(102);
229
-		if ($customer_state != ''){$this->Cell($xsize,4,$customer_state,0,1,'L');} $this->SetX(102);
230
-		$this->Cell($xsize,4,$customer_country . ' ',0,1,'L'); $this->SetX(102);
231
-		if ($customer_tva_intra != ''){$this->Cell($xsize,4,__('TVA Intracommunautaire','wpshop').' : '.$customer_tva_intra,0,1,'L');}
225
+		$this->SetFont('', '', 9);
226
+		$this->Cell($xsize, 4, $customer_street_adress, 0, 1, 'L'); $this->SetX(102);
227
+		if (!empty($customer_suburb)) {$this->Cell($xsize, 4, $customer_suburb, 0, 1, 'L'); } $this->SetX(102);
228
+		$this->Cell($xsize, 4, $customer_postcode . ' ' . $customer_city, 0, 1, 'L'); $this->SetX(102);
229
+		if ($customer_state != '') {$this->Cell($xsize, 4, $customer_state, 0, 1, 'L'); } $this->SetX(102);
230
+		$this->Cell($xsize, 4, $customer_country . ' ', 0, 1, 'L'); $this->SetX(102);
231
+		if ($customer_tva_intra != '') {$this->Cell($xsize, 4, __('TVA Intracommunautaire', 'wpshop') . ' : ' . $customer_tva_intra, 0, 1, 'L'); }
232 232
 	}
233 233
 
234 234
 	// R�f�rence et date de facturation
@@ -238,34 +238,34 @@  discard block
 block discarded – undo
238 238
 		// On r�cup�re la r�f�rence
239 239
 		//$invoice_ref = 'FA'.date('ym').'-0001';
240 240
 		// On r�cup�re la date de facturation
241
-		$invoice_add_date = substr($order['order_date'],0,10);
241
+		$invoice_add_date = substr($order['order_date'], 0, 10);
242 242
 		// On r�cup�re la date d'�ch�ance
243 243
 		//$invoice_max_date = '';
244 244
 
245 245
 		// Positionnement
246
-		$this->SetY(25); $this->SetX(135); $this->SetFont('','B',14);
247
-		$this->Cell(50, 5, utf8_decode(__( 'Ref. : ', 'wpshop' )) . $invoice_ref,0,1,'L');
246
+		$this->SetY(25); $this->SetX(135); $this->SetFont('', 'B', 14);
247
+		$this->Cell(50, 5, utf8_decode(__('Ref. : ', 'wpshop')) . $invoice_ref, 0, 1, 'L');
248 248
 		// Positionnement
249
-		$this->SetX(135); $this->SetFont('','',9);
250
-		$this->Cell(50, 4, utf8_decode(__( 'Billing date : ', 'wpshop' )) . $invoice_add_date,0,1,'L');
249
+		$this->SetX(135); $this->SetFont('', '', 9);
250
+		$this->Cell(50, 4, utf8_decode(__('Billing date : ', 'wpshop')) . $invoice_add_date, 0, 1, 'L');
251 251
 
252
-		$this->SetX(135); $this->SetFont('','',9);
253
-		$this->Cell(50, 4, utf8_decode(__( 'Payment method : ', 'wpshop' )) . utf8_decode(wpshop_payment::get_payment_method($order_id)), 0, 1, 'L');
252
+		$this->SetX(135); $this->SetFont('', '', 9);
253
+		$this->Cell(50, 4, utf8_decode(__('Payment method : ', 'wpshop')) . utf8_decode(wpshop_payment::get_payment_method($order_id)), 0, 1, 'L');
254 254
 
255
-		$this->SetX(135); $this->SetFont('','',9);
256
-		$this->Cell(50, 4, utf8_decode(__( 'Transaction id : ', 'wpshop' )) . wpshop_payment::get_payment_transaction_number($order_id), 0, 1, 'L');
255
+		$this->SetX(135); $this->SetFont('', '', 9);
256
+		$this->Cell(50, 4, utf8_decode(__('Transaction id : ', 'wpshop')) . wpshop_payment::get_payment_transaction_number($order_id), 0, 1, 'L');
257 257
 
258 258
 		//$this->SetX(135);
259 259
 		//$this->Cell(50, 4, utf8_decode(__( 'Date d\'�ch�ance : ', 'wpshop' )) . $invoice_max_date,0,1,'L');
260 260
 
261
-		return $invoice_ref.'_'.$invoice_add_date;
261
+		return $invoice_ref . '_' . $invoice_add_date;
262 262
 	}
263 263
 
264 264
 	function get_invoice_filename($order_id) {
265 265
 		$order = get_post_meta($order_id, '_order_postmeta', true);
266
-		$invoice_add_date = substr($order['order_date'],0,10);
266
+		$invoice_add_date = substr($order['order_date'], 0, 10);
267 267
 		$order_invoice_ref = $order['order_invoice_ref'];
268
-		return $order_invoice_ref.'_'.$invoice_add_date.'.pdf';
268
+		return $order_invoice_ref . '_' . $invoice_add_date . '.pdf';
269 269
 	}
270 270
 
271 271
 	/**
@@ -275,13 +275,13 @@  discard block
 block discarded – undo
275 275
 	 * @param integer $invoice_id Optionnal An invoice ID, this parameter could be used to call an invoice for a partial payment
276 276
 	 */
277 277
 	function rows($order_id, $currency, $invoice_id = null) {
278
-		$title_ref = utf8_decode(__( 'Reference', 'wpshop' ));
279
-		$title_name = utf8_decode(__( 'Designation', 'wpshop' ));
280
-		$title_qty = utf8_decode(__( 'Qty', 'wpshop' ));
281
-		$title_baseprice = utf8_decode(__( 'PU HT', 'wpshop' ));
282
-		$title_discount = utf8_decode(__( 'Discount', 'wpshop' ));
283
-		$title_tax = utf8_decode(__( 'TVA (Tax)', 'wpshop' ));
284
-		$title_price = utf8_decode(__( 'Total ET', 'wpshop' ));
278
+		$title_ref = utf8_decode(__('Reference', 'wpshop'));
279
+		$title_name = utf8_decode(__('Designation', 'wpshop'));
280
+		$title_qty = utf8_decode(__('Qty', 'wpshop'));
281
+		$title_baseprice = utf8_decode(__('PU HT', 'wpshop'));
282
+		$title_discount = utf8_decode(__('Discount', 'wpshop'));
283
+		$title_tax = utf8_decode(__('TVA (Tax)', 'wpshop'));
284
+		$title_price = utf8_decode(__('Total ET', 'wpshop'));
285 285
 
286 286
 		/**	Set title for invoice line table	*/
287 287
 		$header = array($title_ref, $title_name, $title_qty, $title_baseprice, $title_discount, $title_tax, $title_price);
@@ -289,23 +289,23 @@  discard block
 block discarded – undo
289 289
 		/**	Set column size	*/
290 290
 		$w = array(26, 75, 10, 15, 15, 30, 20);
291 291
 
292
-		$this->setXY(10,100);
293
-		for($i=0;$i<count($header);$i++) {
294
-			$this->Cell($w[$i],5,$header[$i],1,0,'C');
292
+		$this->setXY(10, 100);
293
+		for ($i = 0; $i < count($header); $i++) {
294
+			$this->Cell($w[$i], 5, $header[$i], 1, 0, 'C');
295 295
 		}
296 296
 		$this->Ln();
297 297
 
298 298
 		/**	Get the order content	*/
299 299
 		$order_data = get_post_meta($order_id, '_order_postmeta', true);
300
-		if ( in_array($order_data['order_status'], array('completed', 'shipped') ) ) {
300
+		if (in_array($order_data['order_status'], array('completed', 'shipped'))) {
301 301
 			/**	Foreach item in order: add a row to invoice	*/
302 302
 			foreach ($order_data['order_items'] as $o) {
303 303
 				$this->row($o, $w, $currency);
304 304
 			}
305 305
 		}
306
-		else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received']) ) {
307
-			foreach ( $order_data['order_payment']['received'] as $payment_info ) {
308
-				if ( !is_array($payment_info) ) {
306
+		else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received'])) {
307
+			foreach ($order_data['order_payment']['received'] as $payment_info) {
308
+				if (!is_array($payment_info)) {
309 309
 
310 310
 				}
311 311
 			}
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
 		$total_ht = !empty($row['item_total_ht']) ? $row['item_total_ht'] : 'Nc';
327 327
 
328 328
 		// On affiche les valeurs
329
-		$this->Cell($dim_array[0],8,$product_reference,'LRB',0,'C');
330
-		$this->Cell($dim_array[1],8,$product_name,'LRB',0,'L');
331
-		$this->Cell($dim_array[2],8,$qty_invoiced,'LRB',0,'C');
332
-		$this->Cell($dim_array[3],8,number_format($item_pu_ht,2,'.',' ').' '.$currency,'LRB',0,'C');
333
-		$this->Cell($dim_array[4],8,number_format($discount_amount,2,'.',' ').' '.$currency,'LRB',0,'C');
334
-		$this->Cell($dim_array[5],8,number_format($item_tva_total_amount,2,'.',' ').' '.$currency.' (' . round($tax_rate, 2) . '%)','LRB',0,'C');
335
-		$this->Cell($dim_array[6],8,number_format($total_ht,2,'.',' ').' '.$currency,'LRB',0,'C');
329
+		$this->Cell($dim_array[0], 8, $product_reference, 'LRB', 0, 'C');
330
+		$this->Cell($dim_array[1], 8, $product_name, 'LRB', 0, 'L');
331
+		$this->Cell($dim_array[2], 8, $qty_invoiced, 'LRB', 0, 'C');
332
+		$this->Cell($dim_array[3], 8, number_format($item_pu_ht, 2, '.', ' ') . ' ' . $currency, 'LRB', 0, 'C');
333
+		$this->Cell($dim_array[4], 8, number_format($discount_amount, 2, '.', ' ') . ' ' . $currency, 'LRB', 0, 'C');
334
+		$this->Cell($dim_array[5], 8, number_format($item_tva_total_amount, 2, '.', ' ') . ' ' . $currency . ' (' . round($tax_rate, 2) . '%)', 'LRB', 0, 'C');
335
+		$this->Cell($dim_array[6], 8, number_format($total_ht, 2, '.', ' ') . ' ' . $currency, 'LRB', 0, 'C');
336 336
 		$this->Ln();
337 337
 	}
338 338
 
@@ -344,30 +344,30 @@  discard block
 block discarded – undo
344 344
 		// D�calage
345 345
 		$this->Ln();
346 346
 
347
-		$this->Cell(105,10);
348
-		$this->Cell(50,8,__('Total ET','wpshop'),1);
349
-		$this->Cell(35,8,number_format($order['order_total_ht'],2,'.',' ') . ' ' . $currency,1,0,'C'); $this->Ln();
347
+		$this->Cell(105, 10);
348
+		$this->Cell(50, 8, __('Total ET', 'wpshop'), 1);
349
+		$this->Cell(35, 8, number_format($order['order_total_ht'], 2, '.', ' ') . ' ' . $currency, 1, 0, 'C'); $this->Ln();
350 350
 
351
-		foreach($order['order_tva'] as $k => $v) {
352
-			$this->Cell(105,10);
353
-			$this->Cell(50,8,__('Tax','wpshop').' '.$k.'%',1); $this->Cell(35,8,number_format($v,2,'.',' ') . ' ' . $currency,1,0,'C'); $this->Ln();
351
+		foreach ($order['order_tva'] as $k => $v) {
352
+			$this->Cell(105, 10);
353
+			$this->Cell(50, 8, __('Tax', 'wpshop') . ' ' . $k . '%', 1); $this->Cell(35, 8, number_format($v, 2, '.', ' ') . ' ' . $currency, 1, 0, 'C'); $this->Ln();
354 354
 		}
355 355
 
356
-		$this->Cell(105,10);
357
-		$this->Cell(50,8,__('Shipping','wpshop'),1); $this->Cell(35,8,number_format($order['order_shipping_cost'],2,'.',' ') . ' ' . $currency,1,0,'C'); $this->Ln();
356
+		$this->Cell(105, 10);
357
+		$this->Cell(50, 8, __('Shipping', 'wpshop'), 1); $this->Cell(35, 8, number_format($order['order_shipping_cost'], 2, '.', ' ') . ' ' . $currency, 1, 0, 'C'); $this->Ln();
358 358
 
359
-		if(!empty($order['order_grand_total_before_discount']) && $order['order_grand_total_before_discount'] != $order['order_grand_total']){
360
-			$this->Cell(105,10);
361
-			$this->Cell(50,8,utf8_decode(__('Total ATI before discount','wpshop')),1);
362
-			$this->Cell(35,8,number_format($order['order_grand_total_before_discount'],2).' '.$currency,1,0,'C'); $this->Ln();
359
+		if (!empty($order['order_grand_total_before_discount']) && $order['order_grand_total_before_discount'] != $order['order_grand_total']) {
360
+			$this->Cell(105, 10);
361
+			$this->Cell(50, 8, utf8_decode(__('Total ATI before discount', 'wpshop')), 1);
362
+			$this->Cell(35, 8, number_format($order['order_grand_total_before_discount'], 2) . ' ' . $currency, 1, 0, 'C'); $this->Ln();
363 363
 
364
-			$this->Cell(105,10);
365
-			$this->Cell(50,8,__('Discount','wpshop'),1);
366
-			$this->Cell(35,8,'-'.number_format($order['order_discount_amount_total_cart'],2).' '.$currency,1,0,'C'); $this->Ln();
364
+			$this->Cell(105, 10);
365
+			$this->Cell(50, 8, __('Discount', 'wpshop'), 1);
366
+			$this->Cell(35, 8, '-' . number_format($order['order_discount_amount_total_cart'], 2) . ' ' . $currency, 1, 0, 'C'); $this->Ln();
367 367
 		}
368 368
 
369
-		$this->Cell(105,10);
370
-		$this->Cell(50,8,__('Total ATI','wpshop'),1); $this->SetFont('','B',10); $this->Cell(35,8,number_format($order['order_grand_total'],2,'.',' ') . ' ' . $currency,1,0,'C'); $this->Ln();
369
+		$this->Cell(105, 10);
370
+		$this->Cell(50, 8, __('Total ATI', 'wpshop'), 1); $this->SetFont('', 'B', 10); $this->Cell(35, 8, number_format($order['order_grand_total'], 2, '.', ' ') . ' ' . $currency, 1, 0, 'C'); $this->Ln();
371 371
 	}
372 372
 
373 373
 	function rib($store_number)
@@ -414,25 +414,25 @@  discard block
 block discarded – undo
414 414
 		$tva_intra = $store['company_tva_intra'];
415 415
 		$currency = wpshop_tools::wpshop_get_currency(true);
416 416
 
417
-		$this->SetFont('','',10);
418
-		$this->SetXY(10,-50);
417
+		$this->SetFont('', '', 10);
418
+		$this->SetXY(10, -50);
419 419
 
420
-		if(isset($store['company_member_of_a_approved_management_center']) && $store['company_member_of_a_approved_management_center']) {
421
-			$this->MultiCell(190,4,utf8_decode(__('Member of an approved management center, accepting as such payments by check.', 'wpshop')),0,'L',FALSE);
420
+		if (isset($store['company_member_of_a_approved_management_center']) && $store['company_member_of_a_approved_management_center']) {
421
+			$this->MultiCell(190, 4, utf8_decode(__('Member of an approved management center, accepting as such payments by check.', 'wpshop')), 0, 'L', FALSE);
422 422
 			$this->Ln();
423 423
 		}
424
-		$this->MultiCell(190,4,utf8_decode(__('Law 83-629 of 07.12.83, Art. 8: "The administrative authorization does not confer any official character to the company or persons who benefit. It is in no way the responsibility of government."', 'wpshop')),0,'L',FALSE);
424
+		$this->MultiCell(190, 4, utf8_decode(__('Law 83-629 of 07.12.83, Art. 8: "The administrative authorization does not confer any official character to the company or persons who benefit. It is in no way the responsibility of government."', 'wpshop')), 0, 'L', FALSE);
425 425
 		$this->Ln();
426
-		$this->MultiCell(190,4,utf8_decode($store_name.', '.$society_type.__(' capital of ', 'wpshop').$society_capital.' '.$currency.'. SIRET : '.$siret.'. TVA Intracommunautaire : '.$tva_intra),0,'L',FALSE);
426
+		$this->MultiCell(190, 4, utf8_decode($store_name . ', ' . $society_type . __(' capital of ', 'wpshop') . $society_capital . ' ' . $currency . '. SIRET : ' . $siret . '. TVA Intracommunautaire : ' . $tva_intra), 0, 'L', FALSE);
427 427
 	}
428 428
 
429 429
 	//En-t�te
430 430
 	function Header( ) {
431
-		$this->SetFont('Arial','B',15);
431
+		$this->SetFont('Arial', 'B', 15);
432 432
 		//D�calage � droite
433 433
 		$this->Cell(70);
434 434
 		//Titre
435
-		$this->Cell(30,10,'FACTURE',0,0,'L');
435
+		$this->Cell(30, 10, 'FACTURE', 0, 0, 'L');
436 436
 	}
437 437
 
438 438
 	//Pied de page
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
 		//Positionnement � 1,5 cm du bas
441 441
 		$this->SetY(-15);
442 442
 		//Police Arial italique 8
443
-		$this->SetFont('Arial','I',8);
443
+		$this->SetFont('Arial', 'I', 8);
444 444
 		//Num�ro de page
445
-		$this->Cell(0,10,$this->PageNo() . '/{nb}',0,0,'C');
445
+		$this->Cell(0, 10, $this->PageNo() . '/{nb}', 0, 0, 'C');
446 446
 	}
447 447
 }
448 448
 
Please login to merge, or discard this patch.
Braces   +19 added lines, -15 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' ) ) {
@@ -21,8 +23,9 @@  discard block
 block discarded – undo
21 23
 
22 24
 	function WordWrap(&$text, $maxwidth) {
23 25
 		$text = trim($text);
24
-		if ($text==='')
25
-			return 0;
26
+		if ($text==='') {
27
+					return 0;
28
+		}
26 29
 		$space = $this->GetStringWidth(' ');
27 30
 		$lines = explode("\n", $text);
28 31
 		$text = '';
@@ -40,8 +43,7 @@  discard block
 block discarded – undo
40 43
 				{
41 44
 					$width += $wordwidth + $space;
42 45
 					$text .= $word.' ';
43
-				}
44
-				else
46
+				} else
45 47
 				{
46 48
 					$width = $wordwidth + $space;
47 49
 					$text = rtrim($text)."\n".$word.' ';
@@ -60,8 +62,7 @@  discard block
 block discarded – undo
60 62
 	function make_recursiv_dir($path, $rights = 0777) {
61 63
 		if (!@is_dir($path)) {
62 64
 			$folder_path = array($path);
63
-		}
64
-		else {
65
+		} else {
65 66
 			return;
66 67
 		}
67 68
 
@@ -94,8 +95,11 @@  discard block
 block discarded – undo
94 95
 
95 96
 					// Currency management
96 97
 					$currency = $order['order_currency'];
97
-					if($currency == 'EUR')$currency = EUR;
98
-					else $currency = html_entity_decode( wpshop_tools::wpshop_get_sigle($currency) );
98
+					if($currency == 'EUR') {
99
+						$currency = EUR;
100
+					} else {
101
+						$currency = html_entity_decode( wpshop_tools::wpshop_get_sigle($currency) );
102
+					}
99 103
 
100 104
 					// On d�finit un alias pour le nombre de pages total
101 105
 					$this->AliasNbPages();
@@ -129,10 +133,12 @@  discard block
 block discarded – undo
129 133
 					$this->forceDownload($Fichier_a_telecharger, $path, filesize($path));
130 134
 // 				}
131 135
 // 				else $this->forceDownload($filename, $invoice_url, filesize($invoice_url));
136
+			} else {
137
+				echo __('The payment regarding the invoice you requested isn\'t completed','wpshop');
132 138
 			}
133
-			else echo __('The payment regarding the invoice you requested isn\'t completed','wpshop');
139
+		} else {
140
+			echo __('You don\'t have the rights to access this invoice.','wpshop');
134 141
 		}
135
-		else echo __('You don\'t have the rights to access this invoice.','wpshop');
136 142
 	}
137 143
 
138 144
 	/** Force le t�l�chargement d'un fichier */
@@ -186,8 +192,7 @@  discard block
 block discarded – undo
186 192
 			//if ($store_state != ''){$this->Cell(80,4,$store_state,0,1,'L');} $this->SetX(12);
187 193
 			$this->Cell($xsize,4,$store_country,0,1,'L'); $this->SetX(12);
188 194
 			$this->Cell($xsize,4,$store_email,0,1,'L'); $this->SetX(12);
189
-		}
190
-		else {
195
+		} else {
191 196
 			$this->Cell($xsize,5,_('Nc','wpshop'),0,1,'L');
192 197
 		}
193 198
 	}
@@ -302,8 +307,7 @@  discard block
 block discarded – undo
302 307
 			foreach ($order_data['order_items'] as $o) {
303 308
 				$this->row($o, $w, $currency);
304 309
 			}
305
-		}
306
-		else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received']) ) {
310
+		} else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received']) ) {
307 311
 			foreach ( $order_data['order_payment']['received'] as $payment_info ) {
308 312
 				if ( !is_array($payment_info) ) {
309 313
 
Please login to merge, or discard this patch.
includes/librairies/purchase/checkout.class.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -260,6 +260,10 @@
 block discarded – undo
260 260
 		}
261 261
 	}
262 262
 
263
+	/**
264
+	 * @param string $token
265
+	 * @param string $login
266
+	 */
263 267
 	public static function direct_payment_link( $token, $order_id, $login ) {
264 268
 
265 269
 		global $wpdb;
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@
 block discarded – undo
23 23
 	var $creating_account = true;
24 24
 
25 25
 	/** Constructor of the class
26
-	* @return void
27
-	*/
26
+	 * @return void
27
+	 */
28 28
 	function __construct () {
29 29
 	}
30 30
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -14 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' ) ) {
@@ -58,12 +60,13 @@  discard block
 block discarded – undo
58 60
 						// On enregistre la commande
59 61
 						update_post_meta($order_id, '_order_postmeta', $order);
60 62
 						update_post_meta($order_id, '_wpshop_order_customer_id', $user_id);
63
+					} else {
64
+						$wpshop->add_error(__('You don\'t own the order', 'wpshop'));
61 65
 					}
62
-					else $wpshop->add_error(__('You don\'t own the order', 'wpshop'));
66
+				} else {
67
+					$wpshop->add_error(__('The order doesn\'t exist.', 'wpshop'));
63 68
 				}
64
-				else $wpshop->add_error(__('The order doesn\'t exist.', 'wpshop'));
65
-			}
66
-			else{
69
+			} else{
67 70
 				$order_data = array(
68 71
 					'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER,
69 72
 					'post_title' => sprintf(__('Order - %s','wpshop'), mysql2date('d M Y\, H:i:s', current_time('mysql', 0), true)),
@@ -106,7 +109,9 @@  discard block
 block discarded – undo
106 109
 
107 110
 				}
108 111
 				}
109
-				if(!empty($download_codes)) update_user_meta($user_id, '_order_download_codes_'.$order_id, $download_codes);
112
+				if(!empty($download_codes)) {
113
+					update_user_meta($user_id, '_order_download_codes_'.$order_id, $download_codes);
114
+				}
110 115
 
111 116
 				// Informations de commande � stocker
112 117
 				$currency = wpshop_tools::wpshop_get_currency(true);
@@ -128,8 +133,7 @@  discard block
 block discarded – undo
128 133
 				// Si c'est un devis
129 134
 				if ( $paymentMethod == 'quotation' ) {
130 135
 					$order['order_temporary_key'] = wpshop_orders::get_new_pre_order_reference();
131
-				}
132
-				else {
136
+				} else {
133 137
 					$order['order_key'] = wpshop_orders::get_new_order_reference();
134 138
 				}
135 139
 
@@ -190,8 +194,7 @@  discard block
 block discarded – undo
190 194
 
191 195
 				if ( !empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key']) ) {
192 196
 					$wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '') );
193
-				}
194
-				else {
197
+				} else {
195 198
 					$email_option = get_option( 'wpshop_emails' );
196 199
 					if ( empty($email_option['send_confirmation_order_message']) ) {
197 200
 						$payment_method_option = get_option( 'wps_payment_mode' );
@@ -245,8 +248,7 @@  discard block
 block discarded – undo
245 248
 
246 249
 			if( !empty( $order_infos ) && !empty($order_infos['cart_type']) && $order_infos['cart_type'] == 'normal' && !empty($order_infos['order_key']) ){
247 250
 				$message_type = 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE';
248
-			}
249
-			else {
251
+			} else {
250 252
 				$message_type = 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE';
251 253
 				$order_tmp_key = $order_infos['order_temporary_key'];
252 254
 			}
@@ -288,8 +290,7 @@  discard block
 block discarded – undo
288 290
 				$_SESSION['order_id'] = $order_id;
289 291
 				$wpdb->update($wpdb->users, array('user_activation_key' => ''), array('user_login' => $login) );
290 292
 				wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ) );
291
-			}
292
-			else {
293
+			} else {
293 294
 				wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_myaccount_page_id') ) ) );
294 295
 			}
295 296
 
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 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
 /**
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 	/** Constructor of the class
26 26
 	* @return void
27 27
 	*/
28
-	function __construct () {
28
+	function __construct() {
29 29
 	}
30 30
 
31 31
 
32
-	public static function process_checkout($paymentMethod='paypal', $order_id = 0, $customer_id = 0, $customer_billing_address_id = 0, $customer_shipping_address_id = 0) {
32
+	public static function process_checkout($paymentMethod = 'paypal', $order_id = 0, $customer_id = 0, $customer_billing_address_id = 0, $customer_shipping_address_id = 0) {
33 33
 
34 34
 		global $wpdb, $wpshop, $wpshop_cart;
35 35
 		$wps_message = new wps_message_ctr();
@@ -38,22 +38,22 @@  discard block
 block discarded – undo
38 38
 		if (is_user_logged_in()) :
39 39
 			$user_id = get_current_user_id();
40 40
 
41
-		if ( $customer_id != 0 ) {
41
+		if ($customer_id != 0) {
42 42
 			$user_id = $customer_id;
43 43
 		}
44 44
 
45 45
 			// If the order is already created in the db
46
-			if(!empty($order_id) && is_numeric($order_id)) {
46
+			if (!empty($order_id) && is_numeric($order_id)) {
47 47
 				$order = get_post_meta($order_id, '_order_postmeta', true);
48 48
 
49
-				if(!empty($order)) {
50
-					if($order['customer_id'] == $user_id) {
49
+				if (!empty($order)) {
50
+					if ($order['customer_id'] == $user_id) {
51 51
 						$order['payment_method'] = $paymentMethod;
52
-						$_SESSION['order_id'] = wpshop_tools::varSanitizer( $order_id );
52
+						$_SESSION['order_id'] = wpshop_tools::varSanitizer($order_id);
53 53
 						// Store cart in session
54 54
 						//wpshop_cart::store_cart_in_session($order);
55 55
 						// Add a payment
56
-						$order['order_payment']['received'][] = array( 'method' => $paymentMethod, 'waited_amount' => $order['order_amount_to_pay_now'], 'status' => 'waiting_payment', 'author' => get_current_user_id() );
56
+						$order['order_payment']['received'][] = array('method' => $paymentMethod, 'waited_amount' => $order['order_amount_to_pay_now'], 'status' => 'waiting_payment', 'author' => get_current_user_id());
57 57
 
58 58
 						// On enregistre la commande
59 59
 						update_post_meta($order_id, '_order_postmeta', $order);
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
 				}
64 64
 				else $wpshop->add_error(__('The order doesn\'t exist.', 'wpshop'));
65 65
 			}
66
-			else{
66
+			else {
67 67
 				$order_data = array(
68 68
 					'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER,
69
-					'post_title' => sprintf(__('Order - %s','wpshop'), mysql2date('d M Y\, H:i:s', current_time('mysql', 0), true)),
69
+					'post_title' => sprintf(__('Order - %s', 'wpshop'), mysql2date('d M Y\, H:i:s', current_time('mysql', 0), true)),
70 70
 					'post_status' => 'publish',
71
-					'post_excerpt' => !empty($_POST['wps-customer-comment']) ? sanitize_text_field( $_POST['wps-customer-comment'] ) : '',
71
+					'post_excerpt' => !empty($_POST['wps-customer-comment']) ? sanitize_text_field($_POST['wps-customer-comment']) : '',
72 72
 					'post_author' => $user_id,
73 73
 					'comment_status' => 'closed'
74 74
 				);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 				$order_tva = array();
79 79
 
80 80
 				//$cart = (array)$wpshop_cart->cart;
81
-				if ( !empty($_SESSION['cart']) && !empty( $_SESSION['cart']['shipping_method']) ) {
81
+				if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['shipping_method'])) {
82 82
 					$_SESSION['cart']['shipping_method'] = __('Standard shipping method', 'wpshop');
83 83
 				}
84 84
 				$cart = (array)$_SESSION['cart'];
@@ -90,23 +90,23 @@  discard block
 block discarded – undo
90 90
 				$_SESSION['order_id'] = $order_id;
91 91
 
92 92
 				// Cr�ation des codes de t�l�chargement si il y a des produits t�l�chargeable dans le panier
93
-				if ( !empty( $cart['order_items']  ) ) {
94
-				foreach($cart['order_items'] as $c) {
93
+				if (!empty($cart['order_items'])) {
94
+				foreach ($cart['order_items'] as $c) {
95 95
 					$product = wpshop_products::get_product_data($c['item_id']);
96 96
 					/** Check if it's a variation and check the parent product **/
97
-					if ( get_post_type( $c['item_id'] ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
98
-						$parent_def = wpshop_products::get_parent_variation( $c['item_id'] );
99
-						if ( !empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_']) ) {
97
+					if (get_post_type($c['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
98
+						$parent_def = wpshop_products::get_parent_variation($c['item_id']);
99
+						if (!empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_'])) {
100 100
 							$product['is_downloadable_'] = $parent_def['parent_post_meta']['is_downloadable_'];
101 101
 						}
102 102
 					}
103
-					if(!empty($product['is_downloadable_'])) {
103
+					if (!empty($product['is_downloadable_'])) {
104 104
 						$download_codes[$c['item_id']] = array('item_id' => $c['item_id'], 'download_code' => uniqid('', true));
105 105
 					}
106 106
 
107 107
 				}
108 108
 				}
109
-				if(!empty($download_codes)) update_user_meta($user_id, '_order_download_codes_'.$order_id, $download_codes);
109
+				if (!empty($download_codes)) update_user_meta($user_id, '_order_download_codes_' . $order_id, $download_codes);
110 110
 
111 111
 				// Informations de commande � stocker
112 112
 				$currency = wpshop_tools::wpshop_get_currency(true);
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 					'order_payment' 		=> array(
122 122
 					'customer_choice' 		=> array('method' => $paymentMethod),
123 123
 					'received'				=> array('0' => array('method' => $paymentMethod, 'waited_amount' => $cart['order_amount_to_pay_now'], 'status' =>  'waiting_payment', 'author' => $user_id)),
124
-					'shipping_method'       => ( ( !empty( $_SESSION['shipping_method']) ) ? wpshop_tools::varSanitizer( $_SESSION['shipping_method']) : __('Standard shipping method', 'wpshop') )
124
+					'shipping_method'       => ((!empty($_SESSION['shipping_method'])) ? wpshop_tools::varSanitizer($_SESSION['shipping_method']) : __('Standard shipping method', 'wpshop'))
125 125
 					),
126 126
 				), $cart);
127 127
 
128 128
 				// Si c'est un devis
129
-				if ( $paymentMethod == 'quotation' ) {
129
+				if ($paymentMethod == 'quotation') {
130 130
 					$order['order_temporary_key'] = wpshop_orders::get_new_pre_order_reference();
131 131
 				}
132 132
 				else {
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 				}
135 135
 
136 136
 				//Round final amount
137
-				$order['order_grand_total'] = number_format( round($order['order_grand_total'], 2), 2, '.', '');
138
-				$order['order_total_ttc'] = number_format( round($order['order_total_ttc'], 2), 2, '.', '');
139
-				$order['order_amount_to_pay_now'] = number_format( round($order['order_amount_to_pay_now'], 2), 2, '.', '');
137
+				$order['order_grand_total'] = number_format(round($order['order_grand_total'], 2), 2, '.', '');
138
+				$order['order_total_ttc'] = number_format(round($order['order_total_ttc'], 2), 2, '.', '');
139
+				$order['order_amount_to_pay_now'] = number_format(round($order['order_amount_to_pay_now'], 2), 2, '.', '');
140 140
 
141 141
 				/** On enregistre la commande	*/
142 142
 				update_post_meta($order_id, '_order_postmeta', $order);
@@ -145,75 +145,75 @@  discard block
 block discarded – undo
145 145
 				update_post_meta($order_id, '_wpshop_order_status', $order['order_status']);
146 146
 
147 147
 
148
-				do_action( 'wps_order_extra_save', $order_id );
148
+				do_action('wps_order_extra_save', $order_id);
149 149
 
150 150
 				//Add an action to extra actions on order save
151 151
 				// @TODO : REQUEST
152
-				$args = array( 'order_id' => $order_id, 'posted_data' => $_REQUEST);
153
-				wpshop_tools::create_custom_hook( 'wps_order_extra_save_action', $args );
152
+				$args = array('order_id' => $order_id, 'posted_data' => $_REQUEST);
153
+				wpshop_tools::create_custom_hook('wps_order_extra_save_action', $args);
154 154
 
155 155
 				/**	Set custmer information for the order	*/
156
-				$shipping_address =  ( !empty($shipping_address_option) && !empty($shipping_address_option['activate']) ) ? ( ( !empty($_SESSION['shipping_address']) ) ? wpshop_tools::varSanitizer($_SESSION['shipping_address']) : $customer_shipping_address_id ) : '';
157
-				$billing_address =  ( !empty($_SESSION['billing_address']) ) ? wpshop_tools::varSanitizer($_SESSION['billing_address']) : $customer_billing_address_id;
156
+				$shipping_address = (!empty($shipping_address_option) && !empty($shipping_address_option['activate'])) ? ((!empty($_SESSION['shipping_address'])) ? wpshop_tools::varSanitizer($_SESSION['shipping_address']) : $customer_shipping_address_id) : '';
157
+				$billing_address = (!empty($_SESSION['billing_address'])) ? wpshop_tools::varSanitizer($_SESSION['billing_address']) : $customer_billing_address_id;
158 158
 
159 159
 
160
-				if ( !empty( $billing_address) ) {
160
+				if (!empty($billing_address)) {
161 161
 					wpshop_orders::set_order_customer_addresses($user_id, $order_id, $shipping_address, $billing_address);
162 162
 				}
163 163
 
164
-				if ( !empty($_SESSION['shipping_address_to_save']) ) {
164
+				if (!empty($_SESSION['shipping_address_to_save'])) {
165 165
 					$order_infos_postmeta = get_post_meta($order_id, '_order_info', true);
166 166
 					$order_infos_postmeta['shipping']['address'] = $_SESSION['shipping_address_to_save'];
167 167
 					$order_infos_postmeta['shipping']['address_id'] = '';
168 168
 					update_post_meta($order_id, '_order_info', $order_infos_postmeta);
169
-					unset( $_SESSION['shipping_address_to_save'] );
169
+					unset($_SESSION['shipping_address_to_save']);
170 170
 				}
171 171
 
172 172
 
173 173
 				/** Save Coupon use **/
174
-				if ( !empty($_SESSION['cart']['coupon_id']) ) {
174
+				if (!empty($_SESSION['cart']['coupon_id'])) {
175 175
 					$wps_coupon_mdl = new wps_coupon_model();
176
-					$wps_coupon_mdl->save_coupon_use( $_SESSION['cart']['coupon_id'] );
176
+					$wps_coupon_mdl->save_coupon_use($_SESSION['cart']['coupon_id']);
177 177
 				}
178 178
 
179 179
 				/**	Notify the customer as the case	*/
180 180
 				$user_info = get_userdata($user_id);
181 181
 				$email = $user_info->user_email;
182
-				$first_name = $user_info->user_firstname ;
182
+				$first_name = $user_info->user_firstname;
183 183
 				$last_name = $user_info->user_lastname;
184 184
 
185 185
 				// Envoie du message de confirmation de commande au client
186
-				$order_meta = get_post_meta( $order_id, '_order_postmeta', true);
186
+				$order_meta = get_post_meta($order_id, '_order_postmeta', true);
187 187
 
188
-				$shipping_mode_option = get_option( 'wps_shipping_mode' );
189
-				$shipping_method = ( !empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order_meta['order_payment']['shipping_method'] : '' );
188
+				$shipping_mode_option = get_option('wps_shipping_mode');
189
+				$shipping_method = (!empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order_meta['order_payment']['shipping_method'] : '');
190 190
 
191
-				if ( !empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key']) ) {
192
-					$wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '') );
191
+				if (!empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key'])) {
192
+					$wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => ''));
193 193
 				}
194 194
 				else {
195
-					$email_option = get_option( 'wpshop_emails' );
196
-					if ( empty($email_option['send_confirmation_order_message']) ) {
197
-						$payment_method_option = get_option( 'wps_payment_mode' );
198
-						$order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])  ) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method'];
195
+					$email_option = get_option('wpshop_emails');
196
+					if (empty($email_option['send_confirmation_order_message'])) {
197
+						$payment_method_option = get_option('wps_payment_mode');
198
+						$order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method'];
199 199
 
200
-						$wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ( ( !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : ''),'order_date' => current_time('mysql', 0),  'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '',  'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '' ) );
200
+						$wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ((!empty($order_meta['order_key'])) ? $order_meta['order_key'] : ''), 'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => ''));
201 201
 					}
202 202
 				}
203 203
 
204
-				if ( empty($_SESSION['wps-pos-addon']) ) {
204
+				if (empty($_SESSION['wps-pos-addon'])) {
205 205
 					$email_option = get_option('wpshop_emails');
206
-					if( empty($email_option) || ( !empty($email_option) && empty($email_option['send_confirmation_order_message']) ) ){
207
-						self::send_order_email_to_administrator( $order_id, $user_info );
206
+					if (empty($email_option) || (!empty($email_option) && empty($email_option['send_confirmation_order_message']))) {
207
+						self::send_order_email_to_administrator($order_id, $user_info);
208 208
 					}
209 209
 				}
210 210
 
211 211
 
212 212
 				/** IF Order amount is 0, Finish the Order **/
213
-				if ( $cart['order_amount_to_pay_now'] == 0 ) {
213
+				if ($cart['order_amount_to_pay_now'] == 0) {
214 214
 					$order_meta = get_post_meta($order_id, '_order_postmeta', true);
215 215
 					$payment_status = 'completed';
216
-					$params_array = array (
216
+					$params_array = array(
217 217
 						'method' =>'free',
218 218
 						'waited_amount' => $order_meta['order_amount_to_pay_now'],
219 219
 						'status' =>  'payment_received',
@@ -224,14 +224,14 @@  discard block
 block discarded – undo
224 224
 					);
225 225
 					wpshop_payment::check_order_payment_total_amount($order_id, $params_array, $payment_status);
226 226
 				}
227
-				apply_filters( 'wpshop_finish_order_extra_actions', $order_id);
227
+				apply_filters('wpshop_finish_order_extra_actions', $order_id);
228 228
 			}
229 229
 		endif;
230 230
 		return $order_id;
231 231
 	}
232 232
 
233
-	public static function send_order_email_to_administrator ( $order_id, $customer_infos = ''  ) {
234
-		if ( !empty($order_id) ) {
233
+	public static function send_order_email_to_administrator($order_id, $customer_infos = '') {
234
+		if (!empty($order_id)) {
235 235
 			$wps_message = new wps_message_ctr();
236 236
 			$order_infos = get_post_meta($order_id, '_order_postmeta', true);
237 237
 			//Send email to administrator(s)
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
 			$shop_admin_email = $shop_admin_email_option['contact_email'];
240 240
 			$order_tmp_key = '';
241 241
 
242
-			$shipping_mode_option = get_option( 'wps_shipping_mode' );
243
-			$shipping_method = ( !empty($order_infos['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_infos['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_infos['order_payment']['shipping_method']]['name'] : ( (!empty($order_infos['order_payment']['shipping_method']) ) ? $order_infos['order_payment']['shipping_method'] : '' );
242
+			$shipping_mode_option = get_option('wps_shipping_mode');
243
+			$shipping_method = (!empty($order_infos['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_infos['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_infos['order_payment']['shipping_method']]['name'] : ((!empty($order_infos['order_payment']['shipping_method'])) ? $order_infos['order_payment']['shipping_method'] : '');
244 244
 
245 245
 
246
-			if( !empty( $order_infos ) && !empty($order_infos['cart_type']) && $order_infos['cart_type'] == 'normal' && !empty($order_infos['order_key']) ){
246
+			if (!empty($order_infos) && !empty($order_infos['cart_type']) && $order_infos['cart_type'] == 'normal' && !empty($order_infos['order_key'])) {
247 247
 				$message_type = 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE';
248 248
 			}
249 249
 			else {
@@ -251,23 +251,23 @@  discard block
 block discarded – undo
251 251
 				$order_tmp_key = $order_infos['order_temporary_key'];
252 252
 			}
253 253
 
254
-			$payment_method_option = get_option( 'wps_payment_mode' );
255
-			$order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_infos['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']])  ) ? $payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']]['name'] : $order_infos['order_payment']['customer_choice']['method'];
254
+			$payment_method_option = get_option('wps_payment_mode');
255
+			$order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_infos['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']]['name'] : $order_infos['order_payment']['customer_choice']['method'];
256 256
 
257
-			$data_to_send = array('order_id' => $order_id, 'order_key' => $order_infos['order_key'], 'customer_email' => ( !empty($customer_infos) && !empty($customer_infos->user_email) ) ? $customer_infos->user_email : '' , 'customer_last_name' => ( !empty($customer_infos) && !empty($customer_infos->user_lastname) ) ? $customer_infos->user_lastname : '', 'customer_first_name' => ( !empty($customer_infos) && !empty($customer_infos->user_firstname) ) ? $customer_infos->user_firstname : '', 'order_date' => $order_infos['order_date'], 'order_payment_method' => $order_payment_method, 'order_temporary_key' => $order_tmp_key, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '','order_shipping_method' => $shipping_method, 'order_personnal_informations' => '' );
257
+			$data_to_send = array('order_id' => $order_id, 'order_key' => $order_infos['order_key'], 'customer_email' => (!empty($customer_infos) && !empty($customer_infos->user_email)) ? $customer_infos->user_email : '', 'customer_last_name' => (!empty($customer_infos) && !empty($customer_infos->user_lastname)) ? $customer_infos->user_lastname : '', 'customer_first_name' => (!empty($customer_infos) && !empty($customer_infos->user_firstname)) ? $customer_infos->user_firstname : '', 'order_date' => $order_infos['order_date'], 'order_payment_method' => $order_payment_method, 'order_temporary_key' => $order_tmp_key, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '');
258 258
 
259
-			$wps_message->wpshop_prepared_email( $shop_admin_email, $message_type, $data_to_send, array('object_type' => 'order', 'object_id' => $order_id));
259
+			$wps_message->wpshop_prepared_email($shop_admin_email, $message_type, $data_to_send, array('object_type' => 'order', 'object_id' => $order_id));
260 260
 		}
261 261
 	}
262 262
 
263
-	public static function direct_payment_link( $token, $order_id, $login ) {
263
+	public static function direct_payment_link($token, $order_id, $login) {
264 264
 
265 265
 		global $wpdb;
266
-		if( !empty($token) && !empty($order_id) && !empty($login) ) {
266
+		if (!empty($token) && !empty($order_id) && !empty($login)) {
267 267
 			/** Verify informations **/
268
-			$query = $wpdb->prepare( 'SELECT * FROM ' .$wpdb->users. ' WHERE user_login = %s AND user_activation_key = %s', $login, $token);
269
-			$user_infos = $wpdb->get_row( $query );
270
-			if( !empty($user_infos) ) {
268
+			$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->users . ' WHERE user_login = %s AND user_activation_key = %s', $login, $token);
269
+			$user_infos = $wpdb->get_row($query);
270
+			if (!empty($user_infos)) {
271 271
 				/** Connect the user **/
272 272
 				$secure_cookie = is_ssl() ? true : false;
273 273
 				wp_set_auth_cookie($user_infos->ID, true, $secure_cookie);
@@ -276,21 +276,21 @@  discard block
 block discarded – undo
276 276
 				$order_meta = get_post_meta($order_id, '_order_postmeta', true);
277 277
 				$_SESSION['cart'] = array();
278 278
 				$_SESSION['cart']['order_items'] = array();
279
-				if ( !empty($order_meta) && !empty( $order_meta['order_items']) ) {
279
+				if (!empty($order_meta) && !empty($order_meta['order_items'])) {
280 280
 					$wpshop_cart_type = 'cart';
281
-					foreach( $order_meta['order_items'] as $item ) {;
281
+					foreach ($order_meta['order_items'] as $item) {;
282 282
 						$_SESSION['cart']['order_items'][$item['item_id']] = $item;
283 283
 					}
284 284
 					$wps_cart_ctr = new wps_cart();
285
-					$order = $wps_cart_ctr->calcul_cart_information( array() );
286
-					$wps_cart_ctr->store_cart_in_session( $order );
285
+					$order = $wps_cart_ctr->calcul_cart_information(array());
286
+					$wps_cart_ctr->store_cart_in_session($order);
287 287
 				}
288 288
 				$_SESSION['order_id'] = $order_id;
289
-				$wpdb->update($wpdb->users, array('user_activation_key' => ''), array('user_login' => $login) );
290
-				wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ) );
289
+				$wpdb->update($wpdb->users, array('user_activation_key' => ''), array('user_login' => $login));
290
+				wpshop_tools::wpshop_safe_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))));
291 291
 			}
292 292
 			else {
293
-				wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_myaccount_page_id') ) ) );
293
+				wpshop_tools::wpshop_safe_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))));
294 294
 			}
295 295
 
296 296
 		}
Please login to merge, or discard this patch.
includes/librairies/purchase/orders.class.php 4 patches
Doc Comments   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
 
266 266
 	/** Renvoi une nouvelle r�f�rence unique pour une commande
267
-	* @return int
267
+	* @return string
268 268
 	*/
269 269
 	public static function get_new_order_reference(){
270 270
 		$number_figures = get_option('wpshop_order_number_figures', false);
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	}
286 286
 
287 287
 	/** Renvoi une nouvelle r�f�rence unique pour un devis
288
-	* @return int
288
+	* @return string
289 289
 	*/
290 290
 	public static function get_new_pre_order_reference($save = true){
291 291
 		$number_figures = get_option('wpshop_order_number_figures', false);
@@ -650,6 +650,10 @@  discard block
 block discarded – undo
650 650
 
651 651
 		return $output;
652 652
 	}
653
+
654
+	/**
655
+	 * @param boolean $state
656
+	 */
653 657
 	static function display_customer_pay_quotation( $state, $oid ) {
654 658
 		$btn = '<a role="button" class="wps-bton-' . ( ( $state ) ? 'third' : 'second' ) . '-mini-rounded quotation_is_payable_by_customer" href="#" >'.__('Customer can pay', 'wpshop').'</a>';
655 659
 		if( $state ) {
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 	/** Generate the billing reference regarding the order $order_id
245 245
 	 * @return void
246
-	*/
246
+	 */
247 247
 	function order_generate_billing_number($order_id, $force_invoicing = false){
248 248
 		global $wpdb, $wpshop_modules_billing;
249 249
 
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 
265 265
 
266 266
 	/** Renvoi une nouvelle r�f�rence unique pour une commande
267
-	* @return int
268
-	*/
267
+	 * @return int
268
+	 */
269 269
 	public static function get_new_order_reference(){
270 270
 		$number_figures = get_option('wpshop_order_number_figures', false);
271 271
 		/* If the number doesn't exist, we create a default one */
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 	}
286 286
 
287 287
 	/** Renvoi une nouvelle r�f�rence unique pour un devis
288
-	* @return int
289
-	*/
288
+	 * @return int
289
+	 */
290 290
 	public static function get_new_pre_order_reference($save = true){
291 291
 		$number_figures = get_option('wpshop_order_number_figures', false);
292 292
 		/* If the number doesn't exist, we create a default one */
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 
349 349
 	/** Set the custom colums
350 350
 	 * @return array
351
-	*/
351
+	 */
352 352
 	static function orders_edit_columns($columns){
353 353
 	  $columns = array(
354 354
 		'cb' => '<input type="checkbox" />',
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 
368 368
 	/** Give the content by column
369 369
 	 * @return array
370
-	*/
370
+	 */
371 371
 	public static function orders_custom_columns($column, $post_id) {
372 372
 		if ( get_post_type( $post_id ) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) {
373 373
 			global $civility, $order_status;
Please login to merge, or discard this patch.
Braces   +14 added lines, -23 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
  * Products management method file
4 6
  *
@@ -132,8 +134,7 @@  discard block
 block discarded – undo
132 134
 		$order_main_info .= '<div class="wps-product-section">';
133 135
 		if(empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))){
134 136
 			$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Temporary quotation reference','wpshop').': </strong>'.self::get_new_pre_order_reference(false).'<br/>';
135
-		}
136
-		else{
137
+		} else{
137 138
 			if(!empty($order_postmeta['order_key'])){
138 139
 				$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Order reference','wpshop').' : </strong>'.$order_postmeta['order_key'].'<br/>';
139 140
 			}
@@ -148,8 +149,7 @@  discard block
 block discarded – undo
148 149
 				$sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $order->ID;
149 150
 				$order_invoice_download = wpshop_display::display_template_element('wpshop_admin_order_payment_received_invoice_download_links', $sub_tpl_component, array(), 'admin');
150 151
 				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'. __('Invoice number','wpshop').': </strong>'.$order_postmeta['order_invoice_ref'].'<br/>' . $order_invoice_download . '';
151
-			}
152
-			else {
152
+			} else {
153 153
 				$order_main_info .= wpshop_display::display_template_element('wpshop_admin_order_generate_invoice_button', array(), array(), 'admin');
154 154
 			}
155 155
 		}
@@ -195,8 +195,7 @@  discard block
 block discarded – undo
195 195
 			if ( empty($credit_meta) ) {
196 196
 				if( $order_postmeta['order_status'] == 'refunded') {
197 197
 					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' .__('Credit Slip number', 'wpshop'). ' : <strong>'. ( (!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref']) ) ? '<a href="' .WPSHOP_TEMPLATES_URL. 'invoice.php?order_id=' .$order->ID. '&amp;invoice_ref=' .$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'&credit_slip=ok" target="_blank">'.$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'</a>' : '') .'</strong></div>';
198
-				}
199
-				else {
198
+				} else {
200 199
 					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' .$order->ID. '">' .__('Refund this order', 'wpshop'). '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>';
201 200
 				}
202 201
 			}
@@ -276,8 +275,7 @@  discard block
 block discarded – undo
276 275
 
277 276
 		$order_current_number = get_option('wpshop_order_current_number', false);
278 277
 		/* If the counter doesn't exist, we initiate it */
279
-		if(!$order_current_number) { $order_current_number = 1; }
280
-		else { $order_current_number++; }
278
+		if(!$order_current_number) { $order_current_number = 1; } else { $order_current_number++; }
281 279
 		update_option('wpshop_order_current_number', $order_current_number);
282 280
 
283 281
 		$order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number);
@@ -297,8 +295,7 @@  discard block
 block discarded – undo
297 295
 
298 296
 		$order_current_number = get_option('wpshop_preorder_current_number', false);
299 297
 		/* If the counter doesn't exist, we initiate it */
300
-		if(!$order_current_number) { $order_current_number = 1; }
301
-		else { $order_current_number++; }
298
+		if(!$order_current_number) { $order_current_number = 1; } else { $order_current_number++; }
302 299
 		if($save){
303 300
 			update_option('wpshop_preorder_current_number', $order_current_number);
304 301
 		}
@@ -332,8 +329,7 @@  discard block
 block discarded – undo
332 329
 					$shipping_info['address'] = get_post_meta( $address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
333 330
 				}
334 331
 			}
335
-		}
336
-		else {
332
+		} else {
337 333
 			$shipping_info['id'] = get_post_meta($shipping_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
338 334
 			$shipping_info['address'] = get_post_meta($shipping_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
339 335
 			$shipping_info['address_id'] = ( !empty($_SESSION['shipping_address']) ) ? intval( $_SESSION['shipping_address'] ) : '';
@@ -394,8 +390,7 @@  discard block
 block discarded – undo
394 390
 				case "order_billing":
395 391
 					if ( !empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address']) ) {
396 392
 						$billing = $addresses['billing']['address'];
397
-					}
398
-					else if ( !empty($addresses['billing']) ) {
393
+					} else if ( !empty($addresses['billing']) ) {
399 394
 						$billing = $addresses['billing'];
400 395
 					}
401 396
 					if ( !empty($billing) ) {
@@ -403,8 +398,7 @@  discard block
 block discarded – undo
403 398
 						echo empty($billing['company'])?'<br />':', <i>'.$billing['company'].'</i><br />';
404 399
 						echo (!empty($billing['address']) ? $billing['address'] : null).'<br />';
405 400
 						echo (!empty($billing['postcode']) ? $billing['postcode'] : null).' '.(!empty($billing['city']) ? $billing['city'] : null).', '.(!empty($billing['country']) ? $billing['country'] : null);
406
-					}
407
-					else {
401
+					} else {
408 402
 						echo __('No information available for user billing', 'wpshop');
409 403
 					}
410 404
 				break;
@@ -412,8 +406,7 @@  discard block
 block discarded – undo
412 406
 				case "order_shipping":
413 407
 					if ( !empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address']) ) {
414 408
 						$shipping = $addresses['shipping']['address'];
415
-					}
416
-					else if ( !empty($addresses['shipping']) ) {
409
+					} else if ( !empty($addresses['shipping']) ) {
417 410
 						$shipping = $addresses['shipping'];
418 411
 					}
419 412
 					if ( !empty($shipping) ) {
@@ -421,8 +414,7 @@  discard block
 block discarded – undo
421 414
 						echo empty($shipping['company'])?'<br />':', <i>'.$shipping['company'].'</i><br />';
422 415
 						echo (!empty($shipping['address']) ? $shipping['address'] : null).'<br />';
423 416
 						echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null).' '.(!empty($shipping['city']) ? $shipping['city'] : null).', '.(!empty($shipping['country']) ? $shipping['country'] : null);
424
-					}
425
-					else{
417
+					} else{
426 418
 						echo __('No information available for user shipping', 'wpshop');
427 419
 					}
428 420
 				break;
@@ -435,8 +427,7 @@  discard block
 block discarded – undo
435 427
 						// Marquer comme envoy�
436 428
 						if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'completed')) {
437 429
 							$buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_'.$post_id.' wps-bton-loader">'.__('Mark as shipped', 'wpshop').'</a> ';
438
-						}
439
-						else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) {
430
+						} else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) {
440 431
 							//		$buttons .= '<a class="button markAsCompleted order_'.$post_id.' alignleft" >'.__('Payment received', 'wpshop').'</a>' . wpshop_payment::display_payment_receiver_interface($post_id) . ' ';
441 432
 						}
442 433
 						$buttons .= '</p>';
Please login to merge, or discard this patch.
Spacing   +138 added lines, -138 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
  * Products management method file
4 4
  *
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 /*	Check if file is include. No direct access possible with file url	*/
13
-if ( !defined( 'WPSHOP_VERSION' ) ) {
14
-	die( __('Access is not allowed by this way', 'wpshop') );
13
+if (!defined('WPSHOP_VERSION')) {
14
+	die(__('Access is not allowed by this way', 'wpshop'));
15 15
 }
16 16
 
17 17
 /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		/**	Add action button	*/
71 71
 		add_meta_box(
72 72
 			'wpshop_order_actions',
73
-			'<span class="dashicons dashicons-info"></span> '.__('Actions on order', 'wpshop'),
73
+			'<span class="dashicons dashicons-info"></span> ' . __('Actions on order', 'wpshop'),
74 74
 			array('wpshop_orders', 'order_actions'),
75 75
 				WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'high'
76 76
 		);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @param object $order The current order being edited
112 112
 	 */
113
-	public static function order_actions( $order ) {
113
+	public static function order_actions($order) {
114 114
 		$output = '';
115 115
 
116 116
 		$order_status = unserialize(WPSHOP_ORDER_STATUS);
@@ -118,37 +118,37 @@  discard block
 block discarded – undo
118 118
 
119 119
 		$tpl_component = array();
120 120
 
121
-		$delete_button = wpshop_display::display_template_element('wpshop_admin_order_action_del_button', array('ADMIN_ORDER_DELETE_LINK' => esc_url( get_delete_post_link($order->ID) ) , 'ADMIN_ORDER_DELETE_TEXT' => (!EMPTY_TRASH_DAYS ? __('Delete Permanently', 'wpshop') :  __('Move to Trash', 'wpshop'))), array(), 'admin');
122
-		$tpl_component['ADMIN_ORDER_DELETE_ORDER'] = current_user_can( "delete_post", $order->ID ) ? $delete_button : '';
121
+		$delete_button = wpshop_display::display_template_element('wpshop_admin_order_action_del_button', array('ADMIN_ORDER_DELETE_LINK' => esc_url(get_delete_post_link($order->ID)), 'ADMIN_ORDER_DELETE_TEXT' => (!EMPTY_TRASH_DAYS ? __('Delete Permanently', 'wpshop') : __('Move to Trash', 'wpshop'))), array(), 'admin');
122
+		$tpl_component['ADMIN_ORDER_DELETE_ORDER'] = current_user_can("delete_post", $order->ID) ? $delete_button : '';
123 123
 
124 124
 		/**	Add an action list	*/
125 125
 		$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] = '';
126 126
 
127 127
 		/**	Display main information about the order	*/
128 128
 		$order_main_info = '';
129
-		if(!empty($order_postmeta['order_date'])){
130
-			$order_main_info .=  '<div class="wps-product-section"><span class="dashicons dashicons-calendar-alt"></span> <strong>'.__('Order date','wpshop').' : </strong><br/>'.mysql2date('d F Y H:i:s', $order_postmeta['order_date'], true).'</div>';
129
+		if (!empty($order_postmeta['order_date'])) {
130
+			$order_main_info .= '<div class="wps-product-section"><span class="dashicons dashicons-calendar-alt"></span> <strong>' . __('Order date', 'wpshop') . ' : </strong><br/>' . mysql2date('d F Y H:i:s', $order_postmeta['order_date'], true) . '</div>';
131 131
 		}
132 132
 		$order_main_info .= '<div class="wps-product-section">';
133
-		if(empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))){
134
-			$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Temporary quotation reference','wpshop').': </strong>'.self::get_new_pre_order_reference(false).'<br/>';
133
+		if (empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))) {
134
+			$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Temporary quotation reference', 'wpshop') . ': </strong>' . self::get_new_pre_order_reference(false) . '<br/>';
135 135
 		}
136
-		else{
137
-			if(!empty($order_postmeta['order_key'])){
138
-				$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Order reference','wpshop').' : </strong>'.$order_postmeta['order_key'].'<br/>';
136
+		else {
137
+			if (!empty($order_postmeta['order_key'])) {
138
+				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Order reference', 'wpshop') . ' : </strong>' . $order_postmeta['order_key'] . '<br/>';
139 139
 			}
140
-			if(!empty($order_postmeta['order_temporary_key'])){
141
-				$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Pre-order reference','wpshop').': </strong>'.$order_postmeta['order_temporary_key'].'<br/>';
142
-				$post_ID = !empty( $_GET['post'] ) ? (int) $_GET['post'] : 0;
143
-				$order_main_info .= '<a href="' .WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $post_ID . '&mode=pdf">' .__('Download the quotation', 'wpshop'). '</a><br />';
140
+			if (!empty($order_postmeta['order_temporary_key'])) {
141
+				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Pre-order reference', 'wpshop') . ': </strong>' . $order_postmeta['order_temporary_key'] . '<br/>';
142
+				$post_ID = !empty($_GET['post']) ? (int)$_GET['post'] : 0;
143
+				$order_main_info .= '<a href="' . WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $post_ID . '&mode=pdf">' . __('Download the quotation', 'wpshop') . '</a><br />';
144 144
 			}
145
-			if(!empty($order_postmeta['order_invoice_ref'])){
145
+			if (!empty($order_postmeta['order_invoice_ref'])) {
146 146
 				$sub_tpl_component = array();
147 147
 				$sub_tpl_component['ADMIN_ORDER_RECEIVED_PAYMENT_INVOICE_REF'] = $order_postmeta['order_invoice_ref'];
148 148
 				$sub_tpl_component['ADMIN_ORDER_PAYMENT_RECEIVED_LINE_CLASSES'] = '';
149 149
 				$sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $order->ID;
150 150
 				$order_invoice_download = wpshop_display::display_template_element('wpshop_admin_order_payment_received_invoice_download_links', $sub_tpl_component, array(), 'admin');
151
-				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'. __('Invoice number','wpshop').': </strong>'.$order_postmeta['order_invoice_ref'].'<br/>' . $order_invoice_download . '';
151
+				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Invoice number', 'wpshop') . ': </strong>' . $order_postmeta['order_invoice_ref'] . '<br/>' . $order_invoice_download . '';
152 152
 			}
153 153
 			else {
154 154
 				$order_main_info .= wpshop_display::display_template_element('wpshop_admin_order_generate_invoice_button', array(), array(), 'admin');
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 
160 160
 		/*Add the current order status in display**/
161
-			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= ( !empty($order_postmeta['order_status']) ) ? (sprintf('<span class="order_status_' . $order->ID . ' wpshop_order_status_container wpshop_order_status_%1$s ">%2$s</span>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) ) : '';
161
+			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= (!empty($order_postmeta['order_status'])) ? (sprintf('<span class="order_status_' . $order->ID . ' wpshop_order_status_container wpshop_order_status_%1$s ">%2$s</span>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop'))) : '';
162 162
 
163 163
 			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= $order_main_info;
164 164
 
@@ -168,37 +168,37 @@  discard block
 block discarded – undo
168 168
 		 * To check because notification is not really send
169 169
 		 *
170 170
 		 */
171
-		if ( !empty($order->post_author) ) {
171
+		if (!empty($order->post_author)) {
172 172
 			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '
173 173
 			<div class="wps-product-section wpshop_order_notify_customer_on_update_container" >
174
-				<input type="checkbox" name="notif_the_customer" id="wpshop_order_notif_the_customer_on_update" /> <label for="wpshop_order_notif_the_customer_on_update" >'.__('Send a notification to the customer', 'wpshop').'</label>
175
-				<!-- <br/><input type="checkbox" name="notif_the_customer_sendsms" id="wpshop_order_notif_the_customer_sendsms_on_update" /> <label for="wpshop_order_nnotif_the_customer_sendsms_on_update" >'.__('Send a SMS to the customer', 'wpshop').'</label> -->
174
+				<input type="checkbox" name="notif_the_customer" id="wpshop_order_notif_the_customer_on_update" /> <label for="wpshop_order_notif_the_customer_on_update" >'.__('Send a notification to the customer', 'wpshop') . '</label>
175
+				<!-- <br/><input type="checkbox" name="notif_the_customer_sendsms" id="wpshop_order_notif_the_customer_sendsms_on_update" /> <label for="wpshop_order_nnotif_the_customer_sendsms_on_update" >'.__('Send a SMS to the customer', 'wpshop') . '</label> -->
176 176
 			</div>';
177 177
 		}
178 178
 
179
-		if( ( ( !empty($order_postmeta['cart_type']) && $order_postmeta['cart_type'] == 'quotation' ) || !empty( $order_postmeta['order_temporary_key'] ) ) && $order_postmeta['order_status'] != 'canceled' && (float) $order_postmeta['order_amount_to_pay_now'] != (float) 0 ) {
180
-			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section">' . self::display_customer_pay_quotation( isset( $order_postmeta['pay_quotation'] ), $order->ID ) . '</div>';
179
+		if (((!empty($order_postmeta['cart_type']) && $order_postmeta['cart_type'] == 'quotation') || !empty($order_postmeta['order_temporary_key'])) && $order_postmeta['order_status'] != 'canceled' && (float)$order_postmeta['order_amount_to_pay_now'] != (float)0) {
180
+			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section">' . self::display_customer_pay_quotation(isset($order_postmeta['pay_quotation']), $order->ID) . '</div>';
181 181
 		}
182 182
 
183 183
 		/*Add the button regarding the order status**/
184
-		if ( !empty($order_postmeta['order_status']) ) {
185
-			switch ( $order_postmeta['order_status'] ) {
184
+		if (!empty($order_postmeta['order_status'])) {
185
+			switch ($order_postmeta['order_status']) {
186 186
 				case 'awaiting_payment':
187
-					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><a role="button" class="wps-bton-second-mini-rounded send_direct_payment_link" href="#" >'.__('Send a payment link to customer', 'wpshop').'</a></div>';
188
-					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><button class="wps-bton-second-mini-rounded markAsCanceled order_'.$order->ID.'" >'.__('Cancel this order', 'wpshop').'</button><input type="hidden" id="markascanceled_order_hidden_indicator" name="markascanceled_order_hidden_indicator" /></div>';
187
+					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><a role="button" class="wps-bton-second-mini-rounded send_direct_payment_link" href="#" >' . __('Send a payment link to customer', 'wpshop') . '</a></div>';
188
+					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><button class="wps-bton-second-mini-rounded markAsCanceled order_' . $order->ID . '" >' . __('Cancel this order', 'wpshop') . '</button><input type="hidden" id="markascanceled_order_hidden_indicator" name="markascanceled_order_hidden_indicator" /></div>';
189 189
 				break;
190 190
 				/*case 'completed' || 'shipped':
191 191
 					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_resend_order_to_customer" ><button class="wps-bton-second-mini-rounded wps_resend_order_to_customer order_' .$order->ID. '">' . __('Resend this order to customer', 'wpshop') . '</button><input type="hidden" id="resendordertocustomer_order_hidden_indicator" name="resendordertocustomer_order_hidden_indicator" /></div>';
192 192
 				break;*/
193 193
 			}
194
-			$credit_meta = get_post_meta( $order->ID, '_wps_order_credit', true );
194
+			$credit_meta = get_post_meta($order->ID, '_wps_order_credit', true);
195 195
 
196
-			if ( empty($credit_meta) ) {
197
-				if( $order_postmeta['order_status'] == 'refunded') {
198
-					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' .__('Credit Slip number', 'wpshop'). ' : <strong>'. ( (!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref']) ) ? '<a href="' .WPSHOP_TEMPLATES_URL. 'invoice.php?order_id=' .$order->ID. '&amp;invoice_ref=' .$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'&credit_slip=ok" target="_blank">'.$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'</a>' : '') .'</strong></div>';
196
+			if (empty($credit_meta)) {
197
+				if ($order_postmeta['order_status'] == 'refunded') {
198
+					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' . __('Credit Slip number', 'wpshop') . ' : <strong>' . ((!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref'])) ? '<a href="' . WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $order->ID . '&amp;invoice_ref=' . $order_postmeta['order_payment']['refunded_action']['credit_slip_ref'] . '&credit_slip=ok" target="_blank">' . $order_postmeta['order_payment']['refunded_action']['credit_slip_ref'] . '</a>' : '') . '</strong></div>';
199 199
 				}
200 200
 				else {
201
-					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' .$order->ID. '">' .__('Refund this order', 'wpshop'). '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>';
201
+					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' . $order->ID . '">' . __('Refund this order', 'wpshop') . '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>';
202 202
 				}
203 203
 			}
204 204
 		}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	function order_container_in_admin() {
211 211
 		global $post;
212 212
 		$output  = '<div id="wps_order_content_container">';
213
-		$output .= self::order_content( $post );
213
+		$output .= self::order_content($post);
214 214
 		$output .= '</div>';
215 215
 		echo $output;
216 216
 	}
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @param order $post The complete order content
223 223
 	 */
224
-	function order_content( $post ) {
224
+	function order_content($post) {
225 225
 		$order_content = '';
226 226
 
227 227
 		$order = get_post_meta($post->ID, '_order_postmeta', true);
228 228
 
229 229
 		$order_content .= '<div id="order_product_container" class="order_product_container wpshop_cls" >';
230
-		if($order){/*	Read the order content if the order has product	*/
230
+		if ($order) {/*	Read the order content if the order has product	*/
231 231
 			$order_content .= '<input type="hidden" value="" name="order_products_to_delete" id="order_products_to_delete" />' . wpshop_cart::display_cart(true, $order, 'admin');
232 232
 			if (empty($order['order_invoice_ref'])) {
233 233
 				$order_content .= '<div id="order_refresh_button_container" class="wpshop_clear_block" ><input type="button" class="button-primary alignright wpshopHide" id="wpshop_admin_order_recalculate" value="' . __('Refresh order informations', 'wpshop') . '" /></div>';
@@ -245,18 +245,18 @@  discard block
 block discarded – undo
245 245
 	/** Generate the billing reference regarding the order $order_id
246 246
 	 * @return void
247 247
 	*/
248
-	function order_generate_billing_number($order_id, $force_invoicing = false){
248
+	function order_generate_billing_number($order_id, $force_invoicing = false) {
249 249
 		global $wpdb, $wpshop_modules_billing;
250 250
 
251 251
 		// Get the order from the db
252 252
 		$order = get_post_meta($order_id, '_order_postmeta', true);
253 253
 
254 254
 		// If the payment is completed
255
-		if(($order['order_status']=='completed') || $force_invoicing) {
255
+		if (($order['order_status'] == 'completed') || $force_invoicing) {
256 256
 
257 257
 			// If the reference hasn't been generated yet
258
-			if(empty($order['order_invoice_ref'])) {
259
-				$order['order_invoice_ref'] = $wpshop_modules_billing->generate_invoice_number( $order_id );
258
+			if (empty($order['order_invoice_ref'])) {
259
+				$order['order_invoice_ref'] = $wpshop_modules_billing->generate_invoice_number($order_id);
260 260
 
261 261
 				update_post_meta($order_id, '_order_postmeta', $order);
262 262
 			}
@@ -267,45 +267,45 @@  discard block
 block discarded – undo
267 267
 	/** Renvoi une nouvelle r�f�rence unique pour une commande
268 268
 	* @return int
269 269
 	*/
270
-	public static function get_new_order_reference(){
270
+	public static function get_new_order_reference() {
271 271
 		$number_figures = get_option('wpshop_order_number_figures', false);
272 272
 		/* If the number doesn't exist, we create a default one */
273
-		if(!$number_figures){
273
+		if (!$number_figures) {
274 274
 			$number_figures = 5;
275 275
 			update_option('wpshop_order_number_figures', $number_figures);
276 276
 		}
277 277
 
278 278
 		$order_current_number = get_option('wpshop_order_current_number', false);
279 279
 		/* If the counter doesn't exist, we initiate it */
280
-		if(!$order_current_number) { $order_current_number = 1; }
280
+		if (!$order_current_number) { $order_current_number = 1; }
281 281
 		else { $order_current_number++; }
282 282
 		update_option('wpshop_order_current_number', $order_current_number);
283 283
 
284
-		$order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number);
285
-		return WPSHOP_ORDER_REFERENCE_PREFIX.$order_ref;
284
+		$order_ref = (string)sprintf('%0' . $number_figures . 'd', $order_current_number);
285
+		return WPSHOP_ORDER_REFERENCE_PREFIX . $order_ref;
286 286
 	}
287 287
 
288 288
 	/** Renvoi une nouvelle r�f�rence unique pour un devis
289 289
 	* @return int
290 290
 	*/
291
-	public static function get_new_pre_order_reference($save = true){
291
+	public static function get_new_pre_order_reference($save = true) {
292 292
 		$number_figures = get_option('wpshop_order_number_figures', false);
293 293
 		/* If the number doesn't exist, we create a default one */
294
-		if(!$number_figures){
294
+		if (!$number_figures) {
295 295
 			$number_figures = 5;
296 296
 			update_option('wpshop_order_number_figures', $number_figures);
297 297
 		}
298 298
 
299 299
 		$order_current_number = get_option('wpshop_preorder_current_number', false);
300 300
 		/* If the counter doesn't exist, we initiate it */
301
-		if(!$order_current_number) { $order_current_number = 1; }
301
+		if (!$order_current_number) { $order_current_number = 1; }
302 302
 		else { $order_current_number++; }
303
-		if($save){
303
+		if ($save) {
304 304
 			update_option('wpshop_preorder_current_number', $order_current_number);
305 305
 		}
306 306
 
307
-		$order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number);
308
-		return WPSHOP_PREORDER_REFERENCE_PREFIX.$order_ref;
307
+		$order_ref = (string)sprintf('%0' . $number_figures . 'd', $order_current_number);
308
+		return WPSHOP_PREORDER_REFERENCE_PREFIX . $order_ref;
309 309
 	}
310 310
 
311 311
 
@@ -320,24 +320,24 @@  discard block
 block discarded – undo
320 320
 	 *
321 321
 	 *	@return void
322 322
 	 */
323
-	public static function set_order_customer_addresses($user_id, $order_id, $shipping_address_id='', $billing_address_id=''){
323
+	public static function set_order_customer_addresses($user_id, $order_id, $shipping_address_id = '', $billing_address_id = '') {
324 324
 		/**	Get order informations	*/
325 325
 		$billing_info['id'] = get_post_meta($billing_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
326
-		$billing_info['address'] = get_post_meta($billing_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
327
-		$billing_info['address_id'] = ( !empty($_SESSION['billing_address']) ) ? intval( $_SESSION['billing_address'] ) : '';
328
-		if ( !empty($_SESSION['shipping_partner_id']) ) {
329
-			$partner_address_id = get_post_meta( $_SESSION['shipping_partner_id'], '_wpshop_attached_address', true);
326
+		$billing_info['address'] = get_post_meta($billing_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
327
+		$billing_info['address_id'] = (!empty($_SESSION['billing_address'])) ? intval($_SESSION['billing_address']) : '';
328
+		if (!empty($_SESSION['shipping_partner_id'])) {
329
+			$partner_address_id = get_post_meta($_SESSION['shipping_partner_id'], '_wpshop_attached_address', true);
330 330
 			if (!empty($partner_address_id)) {
331
-				foreach( $partner_address_id as $address_id ) {
331
+				foreach ($partner_address_id as $address_id) {
332 332
 					$shipping_info['id'] = get_post_meta($address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
333
-					$shipping_info['address'] = get_post_meta( $address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
333
+					$shipping_info['address'] = get_post_meta($address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
334 334
 				}
335 335
 			}
336 336
 		}
337 337
 		else {
338 338
 			$shipping_info['id'] = get_post_meta($shipping_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
339
-			$shipping_info['address'] = get_post_meta($shipping_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
340
-			$shipping_info['address_id'] = ( !empty($_SESSION['shipping_address']) ) ? intval( $_SESSION['shipping_address'] ) : '';
339
+			$shipping_info['address'] = get_post_meta($shipping_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
340
+			$shipping_info['address_id'] = (!empty($_SESSION['shipping_address'])) ? intval($_SESSION['shipping_address']) : '';
341 341
 		}
342 342
 
343 343
 		$order_info = array('billing' => $billing_info, 'shipping' => $shipping_info);
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	/** Set the custom colums
351 351
 	 * @return array
352 352
 	*/
353
-	static function orders_edit_columns($columns){
353
+	static function orders_edit_columns($columns) {
354 354
 	  $columns = array(
355 355
 		'cb' => '<input type="checkbox" />',
356 356
 		'order_identifier' => __('Identifiers', 'wpshop'),
@@ -370,40 +370,40 @@  discard block
 block discarded – undo
370 370
 	 * @return array
371 371
 	*/
372 372
 	public static function orders_custom_columns($column, $post_id) {
373
-		if ( get_post_type( $post_id ) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) {
373
+		if (get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) {
374 374
 			global $civility, $order_status;
375 375
 
376 376
 			$metadata = get_post_custom();
377 377
 
378
-			$order_postmeta = isset($metadata['_order_postmeta'][0])?unserialize($metadata['_order_postmeta'][0]):'';
379
-			$addresses = get_post_meta($post_id,'_order_info', true);
378
+			$order_postmeta = isset($metadata['_order_postmeta'][0]) ? unserialize($metadata['_order_postmeta'][0]) : '';
379
+			$addresses = get_post_meta($post_id, '_order_info', true);
380 380
 
381
-			switch($column){
381
+			switch ($column) {
382 382
 				case "order_identifier":
383
-					if( !empty( $order_postmeta['order_key'] ) ) {
383
+					if (!empty($order_postmeta['order_key'])) {
384 384
 						echo '<b>' . $order_postmeta['order_key'] . '</b><br>';
385 385
 					}
386
-					if( !empty( $order_postmeta['order_invoice_ref'] ) ) {
387
-						echo ( !empty($order_postmeta['order_temporary_key'] ) ? '<b>' . $order_postmeta['order_invoice_ref'] . '</b>' :  '<i>' . $order_postmeta['order_invoice_ref'] . '</i>' );
386
+					if (!empty($order_postmeta['order_invoice_ref'])) {
387
+						echo (!empty($order_postmeta['order_temporary_key']) ? '<b>' . $order_postmeta['order_invoice_ref'] . '</b>' : '<i>' . $order_postmeta['order_invoice_ref'] . '</i>');
388 388
 					}
389 389
 				break;
390 390
 
391 391
 				case "order_status":
392
-					echo !empty($order_postmeta['order_status']) ? sprintf('<mark class="%s" id="order_status_'.$post_id.'">%s</mark>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) : __('Unknown Status', 'wpshop');
392
+					echo !empty($order_postmeta['order_status']) ? sprintf('<mark class="%s" id="order_status_' . $post_id . '">%s</mark>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) : __('Unknown Status', 'wpshop');
393 393
 				break;
394 394
 
395 395
 				case "order_billing":
396
-					if ( !empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address']) ) {
396
+					if (!empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address'])) {
397 397
 						$billing = $addresses['billing']['address'];
398 398
 					}
399
-					else if ( !empty($addresses['billing']) ) {
399
+					else if (!empty($addresses['billing'])) {
400 400
 						$billing = $addresses['billing'];
401 401
 					}
402
-					if ( !empty($billing) ) {
403
-						echo (!empty($billing['civility']) ? __(wpshop_attributes::get_attribute_type_select_option_info($billing['civility'], 'label', 'custom'), 'wpshop') : null).' <strong>'.(!empty($billing['address_first_name']) ? $billing['address_first_name'] : null).' '.(!empty($billing['address_last_name']) ? $billing['address_last_name'] : null).'</strong>';
404
-						echo empty($billing['company'])?'<br />':', <i>'.$billing['company'].'</i><br />';
405
-						echo (!empty($billing['address']) ? $billing['address'] : null).'<br />';
406
-						echo (!empty($billing['postcode']) ? $billing['postcode'] : null).' '.(!empty($billing['city']) ? $billing['city'] : null).', '.(!empty($billing['country']) ? $billing['country'] : null);
402
+					if (!empty($billing)) {
403
+						echo (!empty($billing['civility']) ? __(wpshop_attributes::get_attribute_type_select_option_info($billing['civility'], 'label', 'custom'), 'wpshop') : null) . ' <strong>' . (!empty($billing['address_first_name']) ? $billing['address_first_name'] : null) . ' ' . (!empty($billing['address_last_name']) ? $billing['address_last_name'] : null) . '</strong>';
404
+						echo empty($billing['company']) ? '<br />' : ', <i>' . $billing['company'] . '</i><br />';
405
+						echo (!empty($billing['address']) ? $billing['address'] : null) . '<br />';
406
+						echo (!empty($billing['postcode']) ? $billing['postcode'] : null) . ' ' . (!empty($billing['city']) ? $billing['city'] : null) . ', ' . (!empty($billing['country']) ? $billing['country'] : null);
407 407
 					}
408 408
 					else {
409 409
 						echo __('No information available for user billing', 'wpshop');
@@ -411,33 +411,33 @@  discard block
 block discarded – undo
411 411
 				break;
412 412
 
413 413
 				case "order_shipping":
414
-					if ( !empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address']) ) {
414
+					if (!empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address'])) {
415 415
 						$shipping = $addresses['shipping']['address'];
416 416
 					}
417
-					else if ( !empty($addresses['shipping']) ) {
417
+					else if (!empty($addresses['shipping'])) {
418 418
 						$shipping = $addresses['shipping'];
419 419
 					}
420
-					if ( !empty($shipping) ) {
421
-						echo '<strong>'.(!empty($shipping['address_first_name']) ? $shipping['address_first_name'] : null).' '.(!empty($shipping['address_last_name']) ? $shipping['address_last_name'] : null).'</strong>';
422
-						echo empty($shipping['company'])?'<br />':', <i>'.$shipping['company'].'</i><br />';
423
-						echo (!empty($shipping['address']) ? $shipping['address'] : null).'<br />';
424
-						echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null).' '.(!empty($shipping['city']) ? $shipping['city'] : null).', '.(!empty($shipping['country']) ? $shipping['country'] : null);
420
+					if (!empty($shipping)) {
421
+						echo '<strong>' . (!empty($shipping['address_first_name']) ? $shipping['address_first_name'] : null) . ' ' . (!empty($shipping['address_last_name']) ? $shipping['address_last_name'] : null) . '</strong>';
422
+						echo empty($shipping['company']) ? '<br />' : ', <i>' . $shipping['company'] . '</i><br />';
423
+						echo (!empty($shipping['address']) ? $shipping['address'] : null) . '<br />';
424
+						echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null) . ' ' . (!empty($shipping['city']) ? $shipping['city'] : null) . ', ' . (!empty($shipping['country']) ? $shipping['country'] : null);
425 425
 					}
426
-					else{
426
+					else {
427 427
 						echo __('No information available for user shipping', 'wpshop');
428 428
 					}
429 429
 				break;
430 430
 
431 431
 				case "order_type":
432
-						echo '<a href="'.admin_url('post.php?post='.$post_id.'&action=edit').'">'.(!empty($order_postmeta['order_temporary_key']) ? __('Quotation','wpshop') :  __('Basic order','wpshop')).'</a>';
432
+						echo '<a href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . (!empty($order_postmeta['order_temporary_key']) ? __('Quotation', 'wpshop') : __('Basic order', 'wpshop')) . '</a>';
433 433
 						$buttons = '<p class="row-actions">';
434 434
 						// Voir la commande
435
-						$buttons .= '<a class="button button-small" href="'.admin_url('post.php?post='.$post_id.'&action=edit').'">'.__('View', 'wpshop').'</a>';
435
+						$buttons .= '<a class="button button-small" href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . __('View', 'wpshop') . '</a>';
436 436
 						// Marquer comme envoy�
437 437
 						if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'completed')) {
438
-							$buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_'.$post_id.' wps-bton-loader">'.__('Mark as shipped', 'wpshop').'</a> ';
438
+							$buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_' . $post_id . ' wps-bton-loader">' . __('Mark as shipped', 'wpshop') . '</a> ';
439 439
 						}
440
-						else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) {
440
+						else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment')) {
441 441
 							//		$buttons .= '<a class="button markAsCompleted order_'.$post_id.' alignleft" >'.__('Payment received', 'wpshop').'</a>' . wpshop_payment::display_payment_receiver_interface($post_id) . ' ';
442 442
 						}
443 443
 						$buttons .= '</p>';
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 
451 451
 				case "order_total":
452 452
 					$currency = !empty($order_postmeta['order_currency']) ? $order_postmeta['order_currency'] : get_option('wpshop_shop_default_currency');
453
-					echo isset( $order_postmeta['order_grand_total'] ) ? number_format( $order_postmeta['order_grand_total'], 2, '.', '' ).' '.  wpshop_tools::wpshop_get_sigle($currency) : 'NaN';
453
+					echo isset($order_postmeta['order_grand_total']) ? number_format($order_postmeta['order_grand_total'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_sigle($currency) : 'NaN';
454 454
 				break;
455 455
 
456 456
 				/*case "order_actions":
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
 	}
479 479
 
480 480
 	public static function list_table_filters() {
481
-		$post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : '';
482
-		$entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : '';
483
-		$entity_filter_btpf = !empty( $_GET['entity_filter_btpf'] ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : '';
484
-		$entity_filter_btps = !empty( $_GET['entity_filter_btps'] ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : '';
481
+		$post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : '';
482
+		$entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : '';
483
+		$entity_filter_btpf = !empty($_GET['entity_filter_btpf']) ? sanitize_text_field($_GET['entity_filter_btpf']) : '';
484
+		$entity_filter_btps = !empty($_GET['entity_filter_btps']) ? sanitize_text_field($_GET['entity_filter_btps']) : '';
485 485
 
486 486
 		if (isset($post_type)) {
487 487
 			if (post_type_exists($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER)) {
@@ -493,23 +493,23 @@  discard block
 block discarded – undo
493 493
 				echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, $entity_filter, '', 'index');
494 494
 				$min = $entity_filter_btpf;
495 495
 				$max = $entity_filter_btps;
496
-				echo ' <label for="entity_filter_btpf">'.__('Between two prices', 'wpshop').'</label> ';
497
-				echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="'.__('Minimum price', 'wpshop').'"', null);
498
-				echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="'.__('Maximum price', 'wpshop').'"', null);
496
+				echo ' <label for="entity_filter_btpf">' . __('Between two prices', 'wpshop') . '</label> ';
497
+				echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="' . __('Minimum price', 'wpshop') . '"', null);
498
+				echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="' . __('Maximum price', 'wpshop') . '"', null);
499 499
 			}
500 500
 		}
501 501
 	}
502 502
 
503 503
 	public static function list_table_filter_parse_query($query) {
504 504
 		global $pagenow, $wpdb;
505
-		$post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : '';
506
-		$entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : '';
507
-		$entity_filter_btpf = !empty( $_GET['entity_filter_btpf'] ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : '';
508
-		$entity_filter_btps = !empty( $_GET['entity_filter_btps'] ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : '';
505
+		$post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : '';
506
+		$entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : '';
507
+		$entity_filter_btpf = !empty($_GET['entity_filter_btpf']) ? sanitize_text_field($_GET['entity_filter_btpf']) : '';
508
+		$entity_filter_btps = !empty($_GET['entity_filter_btps']) ? sanitize_text_field($_GET['entity_filter_btps']) : '';
509 509
 
510
-		if ( is_admin() && ($pagenow == 'edit.php') && !empty( $post_type ) && ( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) && !empty( $entity_filter ) ) {
510
+		if (is_admin() && ($pagenow == 'edit.php') && !empty($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) && !empty($entity_filter)) {
511 511
 			$check = null;
512
-			switch ( $entity_filter ) {
512
+			switch ($entity_filter) {
513 513
 				case 'all':
514 514
 					$sql_query = $wpdb->prepare(
515 515
 						"SELECT ID
@@ -573,27 +573,27 @@  discard block
 block discarded – undo
573 573
 						break;
574 574
 			}
575 575
 
576
-			if ( !empty( $check ) ) {
577
-				if( !empty($no_btp) && $no_btp == 'yes' ) {
576
+			if (!empty($check)) {
577
+				if (!empty($no_btp) && $no_btp == 'yes') {
578 578
 					$min = 'minimum';
579 579
 					$max = 'maximum';
580 580
 				} else {
581
-					$min = ( !empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf']) ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : 'minimum';
582
-					$max = ( !empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps']) ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : 'maximum';
581
+					$min = (!empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf'])) ? sanitize_text_field($_GET['entity_filter_btpf']) : 'minimum';
582
+					$max = (!empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps'])) ? sanitize_text_field($_GET['entity_filter_btps']) : 'maximum';
583 583
 				}
584 584
 				$results = $wpdb->get_results($sql_query);
585 585
 				$post_id_list = array();
586 586
 				$i = 0;
587
-				foreach($results as $item){
587
+				foreach ($results as $item) {
588 588
 					$meta_value = get_post_meta($item->ID, '_order_postmeta');
589
-					$price = ( !empty( $meta_value[0]['order_grand_total'] ) ) ? $meta_value[0]['order_grand_total'] : '';
590
-					if( $price >= $min || $min == 'minimum' ) {
591
-						if( $price <= $max || $max == 'maximum' ) {
589
+					$price = (!empty($meta_value[0]['order_grand_total'])) ? $meta_value[0]['order_grand_total'] : '';
590
+					if ($price >= $min || $min == 'minimum') {
591
+						if ($price <= $max || $max == 'maximum') {
592 592
 							$post_id_list[] = $item->ID;
593 593
 						}
594 594
 					}
595 595
 				}
596
-				if( empty($post_id_list) ) {
596
+				if (empty($post_id_list)) {
597 597
 					$post_id_list[] = 'no_result';
598 598
 				}
599 599
 				$query->query_vars[$check] = $post_id_list;
@@ -604,66 +604,66 @@  discard block
 block discarded – undo
604 604
 
605 605
 
606 606
 
607
-	function latest_products_ordered ( $orders ) {
607
+	function latest_products_ordered($orders) {
608 608
 		global $wpdb;
609 609
 		$product_id = $output = '';
610 610
 		$products = array();
611 611
 		$display_option = get_option('wpshop_display_option');
612
-		if ( !empty($orders) && !empty($display_option) && !empty($display_option['latest_products_ordered']) ) {
613
-			foreach( $orders as $order ) {
614
-				$order_content = get_post_meta( $order->ID, '_order_postmeta', true );
615
-				if ( !empty($order_content) && !empty( $order_content['order_items']) ) {
612
+		if (!empty($orders) && !empty($display_option) && !empty($display_option['latest_products_ordered'])) {
613
+			foreach ($orders as $order) {
614
+				$order_content = get_post_meta($order->ID, '_order_postmeta', true);
615
+				if (!empty($order_content) && !empty($order_content['order_items'])) {
616 616
 
617
-					foreach( $order_content['order_items'] as $item ) {
618
-						if ( count( $products) >= $display_option['latest_products_ordered'] ) {
617
+					foreach ($order_content['order_items'] as $item) {
618
+						if (count($products) >= $display_option['latest_products_ordered']) {
619 619
 							continue;
620 620
 						}
621 621
 						$product_id = $item['item_id'];
622
-						if ( !empty( $item) && !empty($item['item_meta']) && !empty($item['item_meta']['variation_definition']) ) {
623
-							$parent_def = wpshop_products::get_parent_variation( $item['item_id'] );
624
-							if ( !empty( $parent_def ) ) {
622
+						if (!empty($item) && !empty($item['item_meta']) && !empty($item['item_meta']['variation_definition'])) {
623
+							$parent_def = wpshop_products::get_parent_variation($item['item_id']);
624
+							if (!empty($parent_def)) {
625 625
 								$parent_post = $parent_def['parent_post'];
626 626
 								$product_id = $parent_post->ID;
627 627
 							}
628 628
 						}
629 629
 
630
-						if ( !in_array($product_id, $products) ) {
630
+						if (!in_array($product_id, $products)) {
631 631
 							$products[] = $product_id;
632 632
 						}
633 633
 					}
634 634
 				}
635 635
 			}
636
-			if ( !empty($products) ) {
636
+			if (!empty($products)) {
637 637
 				$products_id = implode(",", $products);
638
-				$output = wpshop_display::display_template_element('latest_products_ordered', array('LATEST_PRODUCTS_ORDERED' => do_shortcode('[wpshop_products pid="' .$products_id. '"]')) );
638
+				$output = wpshop_display::display_template_element('latest_products_ordered', array('LATEST_PRODUCTS_ORDERED' => do_shortcode('[wpshop_products pid="' . $products_id . '"]')));
639 639
 			}
640 640
 		}
641 641
 		return $output;
642 642
 	}
643 643
 
644
-	function get_order_list_for_customer( $customer_id ) {
644
+	function get_order_list_for_customer($customer_id) {
645 645
 		global $wpdb;
646 646
 		$output = '';
647 647
 
648
-		if( !empty($customer_id) ) {
649
-			 $query = $wpdb->prepare( 'SELECT *
650
-							 		   FROM ' .$wpdb->posts. '
648
+		if (!empty($customer_id)) {
649
+			 $query = $wpdb->prepare('SELECT *
650
+							 		   FROM ' .$wpdb->posts . '
651 651
 							 		   WHERE post_author = %d
652
-							 		   AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
653
-			 $orders = $wpdb->get_results( $query );
652
+							 		   AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
653
+			 $orders = $wpdb->get_results($query);
654 654
 
655
-			 foreach( $orders as $order ) {
655
+			 foreach ($orders as $order) {
656 656
 
657 657
 			 }
658 658
 		}
659 659
 
660 660
 		return $output;
661 661
 	}
662
-	static function display_customer_pay_quotation( $state, $oid ) {
663
-		$btn = '<a role="button" class="wps-bton-' . ( ( $state ) ? 'third' : 'second' ) . '-mini-rounded quotation_is_payable_by_customer" href="#" >'.__('Customer can pay', 'wpshop').'</a>';
664
-		if( $state ) {
665
-			$url = wp_nonce_url( admin_url( 'admin-ajax.php?action=wps_checkout_quotation&order_id=' . $oid . '&is_link=link' ), 'wps_checkout_quotation', '_wpnonce' );
666
-			$btn .= '<br><a href="' . $url . '">' . __( 'Pay link', 'wpshop' ) . '</a>';
662
+	static function display_customer_pay_quotation($state, $oid) {
663
+		$btn = '<a role="button" class="wps-bton-' . (($state) ? 'third' : 'second') . '-mini-rounded quotation_is_payable_by_customer" href="#" >' . __('Customer can pay', 'wpshop') . '</a>';
664
+		if ($state) {
665
+			$url = wp_nonce_url(admin_url('admin-ajax.php?action=wps_checkout_quotation&order_id=' . $oid . '&is_link=link'), 'wps_checkout_quotation', '_wpnonce');
666
+			$btn .= '<br><a href="' . $url . '">' . __('Pay link', 'wpshop') . '</a>';
667 667
 		}
668 668
 		return $btn;
669 669
 	}
Please login to merge, or discard this patch.