@@ -30,6 +30,7 @@ discard block |
||
| 30 | 30 | * Constructor |
| 31 | 31 | * |
| 32 | 32 | * @param &HTML2PDF_myPdf reference to the PDF $object |
| 33 | + * @param HTML2PDF_myPdf $pdf |
|
| 33 | 34 | * @access public |
| 34 | 35 | */ |
| 35 | 36 | public function __construct(&$pdf) |
@@ -75,6 +76,7 @@ discard block |
||
| 75 | 76 | * define the Default Font to use, if the font does not exist, or if no font asked |
| 76 | 77 | * |
| 77 | 78 | * @param string default font-family. If null : Arial for no font asked, and error fot ont does not exist |
| 79 | + * @param string $default |
|
| 78 | 80 | * @return string old default font-family |
| 79 | 81 | * @access public |
| 80 | 82 | */ |
@@ -473,6 +475,7 @@ discard block |
||
| 473 | 475 | * @access public |
| 474 | 476 | * @param string tag name |
| 475 | 477 | * @param array styles |
| 478 | + * @param string $tagName |
|
| 476 | 479 | */ |
| 477 | 480 | public function getSvgStyle($tagName, &$param) |
| 478 | 481 | { |
@@ -1661,7 +1664,7 @@ discard block |
||
| 1661 | 1664 | * read a css content |
| 1662 | 1665 | * |
| 1663 | 1666 | * @access protected |
| 1664 | - * @param &string $code |
|
| 1667 | + * @param string $code |
|
| 1665 | 1668 | */ |
| 1666 | 1669 | protected function _analyseStyle(&$code) |
| 1667 | 1670 | { |
@@ -1725,6 +1728,7 @@ discard block |
||
| 1725 | 1728 | * |
| 1726 | 1729 | * @access public |
| 1727 | 1730 | * @param string &$html |
| 1731 | + * @param string $html |
|
| 1728 | 1732 | */ |
| 1729 | 1733 | public function readStyle(&$html) |
| 1730 | 1734 | { |
@@ -11,1802 +11,1802 @@ |
||
| 11 | 11 | |
| 12 | 12 | class HTML2PDF_parsingCss |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * reference to the pdf object |
|
| 16 | - * @var TCPDF |
|
| 17 | - */ |
|
| 18 | - protected $_pdf = null; |
|
| 19 | - |
|
| 20 | - protected $_htmlColor = array(); // list of the HTML colors |
|
| 21 | - protected $_onlyLeft = false; // flag if we are in a sub html => only "text-align:left" is used |
|
| 22 | - protected $_defaultFont = null; // default font to use if the asked font does not exist |
|
| 23 | - |
|
| 24 | - public $value = array(); // current values |
|
| 25 | - public $css = array(); // css values |
|
| 26 | - public $cssKeys = array(); // css key, for the execution order |
|
| 27 | - public $table = array(); // level history |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Constructor |
|
| 31 | - * |
|
| 32 | - * @param &HTML2PDF_myPdf reference to the PDF $object |
|
| 33 | - * @access public |
|
| 34 | - */ |
|
| 35 | - public function __construct(&$pdf) |
|
| 36 | - { |
|
| 37 | - $this->_init(); |
|
| 38 | - $this->setPdfParent($pdf); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Set the HTML2PDF parent object |
|
| 43 | - * |
|
| 44 | - * @param &HTML2PDF reference to the HTML2PDF parent $object |
|
| 45 | - * @access public |
|
| 46 | - */ |
|
| 47 | - public function setPdfParent(&$pdf) |
|
| 48 | - { |
|
| 49 | - $this->_pdf = &$pdf; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Inform that we want only "test-align:left" because we are in a sub HTML |
|
| 54 | - * |
|
| 55 | - * @access public |
|
| 56 | - */ |
|
| 57 | - public function setOnlyLeft() |
|
| 58 | - { |
|
| 59 | - $this->value['text-align'] = 'left'; |
|
| 60 | - $this->_onlyLeft = true; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Get the vales of the parent, if exist |
|
| 65 | - * |
|
| 66 | - * @return array CSS values |
|
| 67 | - * @access public |
|
| 68 | - */ |
|
| 69 | - public function getOldValues() |
|
| 70 | - { |
|
| 71 | - return isset($this->table[count($this->table)-1]) ? $this->table[count($this->table)-1] : $this->value; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * define the Default Font to use, if the font does not exist, or if no font asked |
|
| 76 | - * |
|
| 77 | - * @param string default font-family. If null : Arial for no font asked, and error fot ont does not exist |
|
| 78 | - * @return string old default font-family |
|
| 79 | - * @access public |
|
| 80 | - */ |
|
| 81 | - public function setDefaultFont($default = null) |
|
| 82 | - { |
|
| 83 | - $old = $this->_defaultFont; |
|
| 84 | - $this->_defaultFont = $default; |
|
| 85 | - if ($default) $this->value['font-family'] = $default; |
|
| 86 | - return $old; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Init the object |
|
| 91 | - * |
|
| 92 | - * @access protected |
|
| 93 | - */ |
|
| 94 | - protected function _init() |
|
| 95 | - { |
|
| 96 | - // get the Web Colors from TCPDF |
|
| 97 | - require(K_PATH_MAIN.'htmlcolors.php'); |
|
| 98 | - $this->_htmlColor = $webcolor; |
|
| 99 | - |
|
| 100 | - // init the Style |
|
| 101 | - $this->table = array(); |
|
| 102 | - $this->value = array(); |
|
| 103 | - $this->initStyle(); |
|
| 104 | - |
|
| 105 | - // Init the styles without legacy |
|
| 106 | - $this->resetStyle(); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Init the CSS Style |
|
| 111 | - * |
|
| 112 | - * @access public |
|
| 113 | - */ |
|
| 114 | - public function initStyle() |
|
| 115 | - { |
|
| 116 | - $this->value['id_tag'] = 'body'; // tag name |
|
| 117 | - $this->value['id_name'] = null; // tag - attribute name |
|
| 118 | - $this->value['id_id'] = null; // tag - attribute id |
|
| 119 | - $this->value['id_class'] = null; // tag - attribute class |
|
| 120 | - $this->value['id_lst'] = array('*'); // tag - list of legacy |
|
| 121 | - $this->value['mini-size'] = 1.; // specific size report for sup, sub |
|
| 122 | - $this->value['mini-decal'] = 0; // specific position report for sup, sub |
|
| 123 | - $this->value['font-family'] = 'Arial'; |
|
| 124 | - $this->value['font-bold'] = false; |
|
| 125 | - $this->value['font-italic'] = false; |
|
| 126 | - $this->value['font-underline'] = false; |
|
| 127 | - $this->value['font-overline'] = false; |
|
| 128 | - $this->value['font-linethrough'] = false; |
|
| 129 | - $this->value['text-transform'] = 'none'; |
|
| 130 | - $this->value['font-size'] = $this->convertToMM('10pt'); |
|
| 131 | - $this->value['text-indent'] = 0; |
|
| 132 | - $this->value['text-align'] = 'left'; |
|
| 133 | - $this->value['vertical-align'] = 'middle'; |
|
| 134 | - $this->value['line-height'] = 'normal'; |
|
| 135 | - |
|
| 136 | - $this->value['position'] = null; |
|
| 137 | - $this->value['x'] = null; |
|
| 138 | - $this->value['y'] = null; |
|
| 139 | - $this->value['width'] = 0; |
|
| 140 | - $this->value['height'] = 0; |
|
| 141 | - $this->value['top'] = null; |
|
| 142 | - $this->value['right'] = null; |
|
| 143 | - $this->value['bottom'] = null; |
|
| 144 | - $this->value['left'] = null; |
|
| 145 | - $this->value['float'] = null; |
|
| 146 | - $this->value['display'] = null; |
|
| 147 | - $this->value['rotate'] = null; |
|
| 148 | - $this->value['overflow'] = 'visible'; |
|
| 149 | - |
|
| 150 | - $this->value['color'] = array(0, 0, 0); |
|
| 151 | - $this->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null); |
|
| 152 | - $this->value['border'] = array(); |
|
| 153 | - $this->value['padding'] = array(); |
|
| 154 | - $this->value['margin'] = array(); |
|
| 155 | - $this->value['margin-auto'] = false; |
|
| 156 | - |
|
| 157 | - $this->value['list-style-type'] = ''; |
|
| 158 | - $this->value['list-style-image'] = ''; |
|
| 159 | - |
|
| 160 | - $this->value['xc'] = null; |
|
| 161 | - $this->value['yc'] = null; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Init the CSS Style without legacy |
|
| 166 | - * |
|
| 167 | - * @param string tag name |
|
| 168 | - * @access public |
|
| 169 | - */ |
|
| 170 | - public function resetStyle($tagName = '') |
|
| 171 | - { |
|
| 172 | - // prepare somme values |
|
| 173 | - $border = $this->readBorder('solid 1px #000000'); |
|
| 174 | - $units = array( |
|
| 175 | - '1px' => $this->convertToMM('1px'), |
|
| 176 | - '5px' => $this->convertToMM('5px'), |
|
| 177 | - ); |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - // prepare the Collapse attribute |
|
| 181 | - $collapse = isset($this->value['border']['collapse']) ? $this->value['border']['collapse'] : false; |
|
| 182 | - if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) $collapse = false; |
|
| 183 | - |
|
| 184 | - // set the global css values |
|
| 185 | - $this->value['position'] = null; |
|
| 186 | - $this->value['x'] = null; |
|
| 187 | - $this->value['y'] = null; |
|
| 188 | - $this->value['width'] = 0; |
|
| 189 | - $this->value['height'] = 0; |
|
| 190 | - $this->value['top'] = null; |
|
| 191 | - $this->value['right'] = null; |
|
| 192 | - $this->value['bottom'] = null; |
|
| 193 | - $this->value['left'] = null; |
|
| 194 | - $this->value['float'] = null; |
|
| 195 | - $this->value['display'] = null; |
|
| 196 | - $this->value['rotate'] = null; |
|
| 197 | - $this->value['overflow'] = 'visible'; |
|
| 198 | - $this->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null); |
|
| 199 | - $this->value['border'] = array( |
|
| 200 | - 't' => $this->readBorder('none'), |
|
| 201 | - 'r' => $this->readBorder('none'), |
|
| 202 | - 'b' => $this->readBorder('none'), |
|
| 203 | - 'l' => $this->readBorder('none'), |
|
| 204 | - 'radius' => array( |
|
| 205 | - 'tl' => array(0, 0), |
|
| 206 | - 'tr' => array(0, 0), |
|
| 207 | - 'br' => array(0, 0), |
|
| 208 | - 'bl' => array(0, 0) |
|
| 209 | - ), |
|
| 210 | - 'collapse' => $collapse, |
|
| 211 | - ); |
|
| 212 | - |
|
| 213 | - // specific values for some tags |
|
| 214 | - if (!in_array($tagName, array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) { |
|
| 215 | - $this->value['margin'] = array('t'=>0,'r'=>0,'b'=>0,'l'=>0); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - if (in_array($tagName, array('input', 'select', 'textarea'))) { |
|
| 219 | - $this->value['border']['t'] = null; |
|
| 220 | - $this->value['border']['r'] = null; |
|
| 221 | - $this->value['border']['b'] = null; |
|
| 222 | - $this->value['border']['l'] = null; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - if ($tagName=='p') { |
|
| 226 | - $this->value['margin']['t'] = null; |
|
| 227 | - $this->value['margin']['b'] = null; |
|
| 228 | - } |
|
| 229 | - if ($tagName=='blockquote') { |
|
| 230 | - $this->value['margin']['t'] = 3; |
|
| 231 | - $this->value['margin']['r'] = 3; |
|
| 232 | - $this->value['margin']['b'] = 3; |
|
| 233 | - $this->value['margin']['l'] = 6; |
|
| 234 | - } |
|
| 235 | - $this->value['margin-auto'] = false; |
|
| 236 | - |
|
| 237 | - if (in_array($tagName, array('blockquote', 'div', 'fieldset'))) { |
|
| 238 | - $this->value['vertical-align'] = 'top'; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - if (in_array($tagName, array('fieldset', 'legend'))) { |
|
| 242 | - $this->value['border'] = array( |
|
| 243 | - 't' => $border, |
|
| 244 | - 'r' => $border, |
|
| 245 | - 'b' => $border, |
|
| 246 | - 'l' => $border, |
|
| 247 | - 'radius' => array( |
|
| 248 | - 'tl' => array($units['5px'], $units['5px']), |
|
| 249 | - 'tr' => array($units['5px'], $units['5px']), |
|
| 250 | - 'br' => array($units['5px'], $units['5px']), |
|
| 251 | - 'bl' => array($units['5px'], $units['5px']) |
|
| 252 | - ), |
|
| 253 | - 'collapse' => false, |
|
| 254 | - ); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - if (in_array($tagName, array('ul', 'li'))) { |
|
| 258 | - $this->value['list-style-type'] = ''; |
|
| 259 | - $this->value['list-style-image'] = ''; |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - if (!in_array($tagName, array('tr', 'td'))) { |
|
| 263 | - $this->value['padding'] = array( |
|
| 264 | - 't' => 0, |
|
| 265 | - 'r' => 0, |
|
| 266 | - 'b' => 0, |
|
| 267 | - 'l' => 0 |
|
| 268 | - ); |
|
| 269 | - } else { |
|
| 270 | - $this->value['padding'] = array( |
|
| 271 | - 't' => $units['1px'], |
|
| 272 | - 'r' => $units['1px'], |
|
| 273 | - 'b' => $units['1px'], |
|
| 274 | - 'l' => $units['1px'] |
|
| 275 | - ); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - if ($tagName=='hr') { |
|
| 279 | - $this->value['border'] = array( |
|
| 280 | - 't' => $border, |
|
| 281 | - 'r' => $border, |
|
| 282 | - 'b' => $border, |
|
| 283 | - 'l' => $border, |
|
| 284 | - 'radius' => array( |
|
| 285 | - 'tl' => array(0, 0), |
|
| 286 | - 'tr' => array(0, 0), |
|
| 287 | - 'br' => array(0, 0), |
|
| 288 | - 'bl' => array(0, 0) |
|
| 289 | - ), |
|
| 290 | - 'collapse' => false, |
|
| 291 | - ); |
|
| 292 | - $this->convertBackground('#FFFFFF', $this->value['background']); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - $this->value['xc'] = null; |
|
| 296 | - $this->value['yc'] = null; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - /** |
|
| 300 | - * Init the PDF Font |
|
| 301 | - * |
|
| 302 | - * @access public |
|
| 303 | - */ |
|
| 304 | - public function fontSet() |
|
| 305 | - { |
|
| 306 | - $family = strtolower($this->value['font-family']); |
|
| 307 | - |
|
| 308 | - $b = ($this->value['font-bold'] ? 'B' : ''); |
|
| 309 | - $i = ($this->value['font-italic'] ? 'I' : ''); |
|
| 310 | - $u = ($this->value['font-underline'] ? 'U' : ''); |
|
| 311 | - $d = ($this->value['font-linethrough'] ? 'D' : ''); |
|
| 312 | - $o = ($this->value['font-overline'] ? 'O' : ''); |
|
| 313 | - |
|
| 314 | - // font style |
|
| 315 | - $style = $b.$i; |
|
| 316 | - |
|
| 317 | - if ($this->_defaultFont) { |
|
| 318 | - if($family=='arial') |
|
| 319 | - $family='helvetica'; |
|
| 320 | - elseif($family=='symbol' || $family=='zapfdingbats') |
|
| 321 | - $style=''; |
|
| 322 | - |
|
| 323 | - $fontkey = $family.$style; |
|
| 324 | - if (!$this->_pdf->isLoadedFont($fontkey)) |
|
| 325 | - $family = $this->_defaultFont; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - if($family=='arial') |
|
| 329 | - $family='helvetica'; |
|
| 330 | - elseif($family=='symbol' || $family=='zapfdingbats') |
|
| 331 | - $style=''; |
|
| 332 | - |
|
| 333 | - // complete style |
|
| 334 | - $style.= $u.$d.$o; |
|
| 335 | - |
|
| 336 | - // size : mm => pt |
|
| 337 | - $size = $this->value['font-size']; |
|
| 338 | - $size = 72 * $size / 25.4; |
|
| 339 | - |
|
| 340 | - // apply the font |
|
| 341 | - $this->_pdf->SetFont($family, $style, $this->value['mini-size']*$size); |
|
| 342 | - $this->_pdf->setTextColorArray($this->value['color']); |
|
| 343 | - if ($this->value['background']['color']) |
|
| 344 | - $this->_pdf->setFillColorArray($this->value['background']['color']); |
|
| 345 | - else |
|
| 346 | - $this->_pdf->setFillColor(255); |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * add a level in the CSS history |
|
| 351 | - * |
|
| 352 | - * @access public |
|
| 353 | - */ |
|
| 354 | - public function save() |
|
| 355 | - { |
|
| 356 | - array_push($this->table, $this->value); |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * remove a level in the CSS history |
|
| 361 | - * |
|
| 362 | - * @access public |
|
| 363 | - */ |
|
| 364 | - public function load() |
|
| 365 | - { |
|
| 366 | - if (count($this->table)) { |
|
| 367 | - $this->value = array_pop($this->table); |
|
| 368 | - } |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * restore the Y positiony (used after a span) |
|
| 373 | - * |
|
| 374 | - * @access public |
|
| 375 | - */ |
|
| 376 | - public function restorePosition() |
|
| 377 | - { |
|
| 378 | - if ($this->value['y']==$this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * set the New position for the current Tag |
|
| 383 | - * |
|
| 384 | - * @access public |
|
| 385 | - */ |
|
| 386 | - public function setPosition() |
|
| 387 | - { |
|
| 388 | - // get the current position |
|
| 389 | - $currentX = $this->_pdf->getX(); |
|
| 390 | - $currentY = $this->_pdf->getY(); |
|
| 391 | - |
|
| 392 | - // save it |
|
| 393 | - $this->value['xc'] = $currentX; |
|
| 394 | - $this->value['yc'] = $currentY; |
|
| 395 | - |
|
| 396 | - if ($this->value['position']=='relative' || $this->value['position']=='absolute') { |
|
| 397 | - if ($this->value['right']!==null) { |
|
| 398 | - $x = $this->getLastWidth(true) - $this->value['right'] - $this->value['width']; |
|
| 399 | - if ($this->value['margin']['r']) $x-= $this->value['margin']['r']; |
|
| 400 | - } else { |
|
| 401 | - $x = $this->value['left']; |
|
| 402 | - if ($this->value['margin']['l']) $x+= $this->value['margin']['l']; |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - if ($this->value['bottom']!==null) { |
|
| 406 | - $y = $this->getLastHeight(true) - $this->value['bottom'] - $this->value['height']; |
|
| 407 | - if ($this->value['margin']['b']) $y-= $this->value['margin']['b']; |
|
| 408 | - } else { |
|
| 409 | - $y = $this->value['top']; |
|
| 410 | - if ($this->value['margin']['t']) $y+= $this->value['margin']['t']; |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - if ($this->value['position']=='relative') { |
|
| 414 | - $this->value['x'] = $currentX + $x; |
|
| 415 | - $this->value['y'] = $currentY + $y; |
|
| 416 | - } else { |
|
| 417 | - $this->value['x'] = $this->_getLastAbsoluteX()+$x; |
|
| 418 | - $this->value['y'] = $this->_getLastAbsoluteY()+$y; |
|
| 419 | - } |
|
| 420 | - } else { |
|
| 421 | - $this->value['x'] = $currentX; |
|
| 422 | - $this->value['y'] = $currentY; |
|
| 423 | - if ($this->value['margin']['l']) $this->value['x']+= $this->value['margin']['l']; |
|
| 424 | - if ($this->value['margin']['t']) $this->value['y']+= $this->value['margin']['t']; |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - // save the new position |
|
| 428 | - $this->_pdf->setXY($this->value['x'], $this->value['y']); |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * Analise the CSS style to convert it into Form style |
|
| 433 | - * |
|
| 434 | - * @access public |
|
| 435 | - * @param array styles |
|
| 436 | - */ |
|
| 437 | - public function getFormStyle() |
|
| 438 | - { |
|
| 439 | - $prop = array(); |
|
| 440 | - |
|
| 441 | - $prop['alignment'] = $this->value['text-align']; |
|
| 442 | - |
|
| 443 | - if (isset($this->value['background']['color']) && is_array($this->value['background']['color'])) { |
|
| 444 | - $prop['fillColor'] = $this->value['background']['color']; |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - if (isset($this->value['border']['t']['color'])) { |
|
| 448 | - $prop['strokeColor'] = $this->value['border']['t']['color']; |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - if (isset($this->value['border']['t']['width'])) { |
|
| 452 | - $prop['lineWidth'] = $this->value['border']['t']['width']; |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - if (isset($this->value['border']['t']['type'])) { |
|
| 456 | - $prop['borderStyle'] = $this->value['border']['t']['type']; |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - if (!empty($this->value['color'])) { |
|
| 460 | - $prop['textColor'] = $this->value['color']; |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - if (!empty($this->value['font-size'])) { |
|
| 464 | - $prop['textSize'] = $this->value['font-size']; |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - return $prop; |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - /** |
|
| 471 | - * Analise the CSS style to convert it into SVG style |
|
| 472 | - * |
|
| 473 | - * @access public |
|
| 474 | - * @param string tag name |
|
| 475 | - * @param array styles |
|
| 476 | - */ |
|
| 477 | - public function getSvgStyle($tagName, &$param) |
|
| 478 | - { |
|
| 479 | - // prepare |
|
| 480 | - $tagName = strtolower($tagName); |
|
| 481 | - $id = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id) $id = null; |
|
| 482 | - $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null; |
|
| 483 | - |
|
| 484 | - // read the class attribute |
|
| 485 | - $class = array(); |
|
| 486 | - $tmp = isset($param['class']) ? strtolower(trim($param['class'])) : ''; |
|
| 487 | - $tmp = explode(' ', $tmp); |
|
| 488 | - foreach ($tmp as $k => $v) { |
|
| 489 | - $v = trim($v); |
|
| 490 | - if ($v) $class[] = $v; |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - // identify the tag, and the direct styles |
|
| 494 | - $this->value['id_tag'] = $tagName; |
|
| 495 | - $this->value['id_name'] = $name; |
|
| 496 | - $this->value['id_id'] = $id; |
|
| 497 | - $this->value['id_class'] = $class; |
|
| 498 | - $this->value['id_lst'] = array(); |
|
| 499 | - $this->value['id_lst'][] = '*'; |
|
| 500 | - $this->value['id_lst'][] = $tagName; |
|
| 501 | - if (!isset($this->value['svg'])) { |
|
| 502 | - $this->value['svg'] = array( |
|
| 503 | - 'stroke' => null, |
|
| 504 | - 'stroke-width' => $this->convertToMM('1pt'), |
|
| 505 | - 'fill' => null, |
|
| 506 | - 'fill-opacity' => null, |
|
| 507 | - ); |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - if (count($class)) { |
|
| 511 | - foreach ($class as $v) { |
|
| 512 | - $this->value['id_lst'][] = '*.'.$v; |
|
| 513 | - $this->value['id_lst'][] = '.'.$v; |
|
| 514 | - $this->value['id_lst'][] = $tagName.'.'.$v; |
|
| 515 | - } |
|
| 516 | - } |
|
| 517 | - if ($id) { |
|
| 518 | - $this->value['id_lst'][] = '*#'.$id; |
|
| 519 | - $this->value['id_lst'][] = '#'.$id; |
|
| 520 | - $this->value['id_lst'][] = $tagName.'#'.$id; |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - // CSS style |
|
| 524 | - $styles = $this->_getFromCSS(); |
|
| 525 | - |
|
| 526 | - // adding the style from the tag |
|
| 527 | - $styles = array_merge($styles, $param['style']); |
|
| 528 | - |
|
| 529 | - if (isset($styles['stroke'])) $this->value['svg']['stroke'] = $this->convertToColor($styles['stroke'], $res); |
|
| 530 | - if (isset($styles['stroke-width'])) $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']); |
|
| 531 | - if (isset($styles['fill'])) $this->value['svg']['fill'] = $this->convertToColor($styles['fill'], $res); |
|
| 532 | - if (isset($styles['fill-opacity'])) $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity']; |
|
| 533 | - |
|
| 534 | - return $this->value['svg']; |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * analyse the css properties from the HTML parsing |
|
| 539 | - * |
|
| 540 | - * @access public |
|
| 541 | - * @param string $tagName |
|
| 542 | - * @param array $param |
|
| 543 | - * @param array $legacy |
|
| 544 | - */ |
|
| 545 | - public function analyse($tagName, &$param, $legacy = null) |
|
| 546 | - { |
|
| 547 | - // prepare the informations |
|
| 548 | - $tagName = strtolower($tagName); |
|
| 549 | - $id = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id) $id = null; |
|
| 550 | - $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null; |
|
| 551 | - |
|
| 552 | - // get the class names to use |
|
| 553 | - $class = array(); |
|
| 554 | - $tmp = isset($param['class']) ? strtolower(trim($param['class'])) : ''; |
|
| 555 | - $tmp = explode(' ', $tmp); |
|
| 556 | - foreach ($tmp as $k => $v) { |
|
| 557 | - $v = trim($v); |
|
| 558 | - if ($v) $class[] = $v; |
|
| 559 | - } |
|
| 560 | - |
|
| 561 | - // prepare the values, and the list of css tags to identify |
|
| 562 | - $this->value['id_tag'] = $tagName; |
|
| 563 | - $this->value['id_name'] = $name; |
|
| 564 | - $this->value['id_id'] = $id; |
|
| 565 | - $this->value['id_class'] = $class; |
|
| 566 | - $this->value['id_lst'] = array(); |
|
| 567 | - $this->value['id_lst'][] = '*'; |
|
| 568 | - $this->value['id_lst'][] = $tagName; |
|
| 569 | - if (count($class)) { |
|
| 570 | - foreach ($class as $v) { |
|
| 571 | - $this->value['id_lst'][] = '*.'.$v; |
|
| 572 | - $this->value['id_lst'][] = '.'.$v; |
|
| 573 | - $this->value['id_lst'][] = $tagName.'.'.$v; |
|
| 574 | - } |
|
| 575 | - } |
|
| 576 | - if ($id) { |
|
| 577 | - $this->value['id_lst'][] = '*#'.$id; |
|
| 578 | - $this->value['id_lst'][] = '#'.$id; |
|
| 579 | - $this->value['id_lst'][] = $tagName.'#'.$id; |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - // get the css styles from class |
|
| 583 | - $styles = $this->_getFromCSS(); |
|
| 584 | - |
|
| 585 | - // merge with the css styles from tag |
|
| 586 | - $styles = array_merge($styles, $param['style']); |
|
| 587 | - if (isset($param['allwidth']) && !isset($styles['width'])) $styles['width'] = '100%'; |
|
| 588 | - |
|
| 589 | - // reset some styles, depending on the tag name |
|
| 590 | - $this->resetStyle($tagName); |
|
| 591 | - |
|
| 592 | - // add the legacy values |
|
| 593 | - if ($legacy) { |
|
| 594 | - foreach ($legacy as $legacyName => $legacyValue) { |
|
| 595 | - if (is_array($legacyValue)) { |
|
| 596 | - foreach($legacyValue as $legacy2Name => $legacy2Value) |
|
| 597 | - $this->value[$legacyName][$legacy2Name] = $legacy2Value; |
|
| 598 | - } else { |
|
| 599 | - $this->value[$legacyName] = $legacyValue; |
|
| 600 | - } |
|
| 601 | - } |
|
| 602 | - } |
|
| 603 | - |
|
| 604 | - // some flags |
|
| 605 | - $correctWidth = false; |
|
| 606 | - $noWidth = true; |
|
| 607 | - |
|
| 608 | - // read all the css styles |
|
| 609 | - foreach ($styles as $nom => $val) { |
|
| 610 | - switch($nom) |
|
| 611 | - { |
|
| 612 | - case 'font-family': |
|
| 613 | - $val = explode(',', $val); |
|
| 614 | - $val = trim($val[0]); |
|
| 615 | - if ($val) $this->value['font-family'] = $val; |
|
| 616 | - break; |
|
| 617 | - |
|
| 618 | - case 'font-weight': |
|
| 619 | - $this->value['font-bold'] = ($val=='bold'); |
|
| 620 | - break; |
|
| 621 | - |
|
| 622 | - case 'font-style': |
|
| 623 | - $this->value['font-italic'] = ($val=='italic'); |
|
| 624 | - break; |
|
| 625 | - |
|
| 626 | - case 'text-decoration': |
|
| 627 | - $val = explode(' ', $val); |
|
| 628 | - $this->value['font-underline'] = (in_array('underline', $val)); |
|
| 629 | - $this->value['font-overline'] = (in_array('overline', $val)); |
|
| 630 | - $this->value['font-linethrough'] = (in_array('line-through', $val)); |
|
| 631 | - break; |
|
| 632 | - |
|
| 633 | - case 'text-indent': |
|
| 634 | - $this->value['text-indent'] = $this->convertToMM($val); |
|
| 635 | - break; |
|
| 636 | - |
|
| 637 | - case 'text-transform': |
|
| 638 | - if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none'; |
|
| 639 | - $this->value['text-transform'] = $val; |
|
| 640 | - break; |
|
| 641 | - |
|
| 642 | - case 'font-size': |
|
| 643 | - $val = $this->convertToMM($val, $this->value['font-size']); |
|
| 644 | - if ($val) $this->value['font-size'] = $val; |
|
| 645 | - break; |
|
| 646 | - |
|
| 647 | - case 'color': |
|
| 648 | - $res = null; |
|
| 649 | - $this->value['color'] = $this->convertToColor($val, $res); |
|
| 650 | - if ($tagName=='hr') { |
|
| 651 | - $this->value['border']['l']['color'] = $this->value['color']; |
|
| 652 | - $this->value['border']['t']['color'] = $this->value['color']; |
|
| 653 | - $this->value['border']['r']['color'] = $this->value['color']; |
|
| 654 | - $this->value['border']['b']['color'] = $this->value['color']; |
|
| 655 | - } |
|
| 656 | - break; |
|
| 657 | - |
|
| 658 | - case 'text-align': |
|
| 659 | - $val = strtolower($val); |
|
| 660 | - if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) $val = 'left'; |
|
| 661 | - $this->value['text-align'] = $val; |
|
| 662 | - break; |
|
| 663 | - |
|
| 664 | - case 'vertical-align': |
|
| 665 | - $this->value['vertical-align'] = $val; |
|
| 666 | - break; |
|
| 667 | - |
|
| 668 | - case 'width': |
|
| 669 | - $this->value['width'] = $this->convertToMM($val, $this->getLastWidth()); |
|
| 670 | - if ($this->value['width'] && substr($val, -1)=='%') $correctWidth=true; |
|
| 671 | - $noWidth = false; |
|
| 672 | - break; |
|
| 673 | - |
|
| 674 | - case 'height': |
|
| 675 | - $this->value['height'] = $this->convertToMM($val, $this->getLastHeight()); |
|
| 676 | - break; |
|
| 677 | - |
|
| 678 | - case 'line-height': |
|
| 679 | - if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val*100).'%'; |
|
| 680 | - $this->value['line-height'] = $val; |
|
| 681 | - break; |
|
| 682 | - |
|
| 683 | - case 'rotate': |
|
| 684 | - if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null; |
|
| 685 | - if ($val<0) $val+= 360; |
|
| 686 | - $this->value['rotate'] = $val; |
|
| 687 | - break; |
|
| 688 | - |
|
| 689 | - case 'overflow': |
|
| 690 | - if (!in_array($val, array('visible', 'hidden'))) $val = 'visible'; |
|
| 691 | - $this->value['overflow'] = $val; |
|
| 692 | - break; |
|
| 693 | - |
|
| 694 | - case 'padding': |
|
| 695 | - $val = explode(' ', $val); |
|
| 696 | - foreach ($val as $k => $v) { |
|
| 697 | - $v = trim($v); |
|
| 698 | - if ($v!='') { |
|
| 699 | - $val[$k] = $v; |
|
| 700 | - } else { |
|
| 701 | - unset($val[$k]); |
|
| 702 | - } |
|
| 703 | - } |
|
| 704 | - $val = array_values($val); |
|
| 705 | - $this->_duplicateBorder($val); |
|
| 706 | - $this->value['padding']['t'] = $this->convertToMM($val[0], 0); |
|
| 707 | - $this->value['padding']['r'] = $this->convertToMM($val[1], 0); |
|
| 708 | - $this->value['padding']['b'] = $this->convertToMM($val[2], 0); |
|
| 709 | - $this->value['padding']['l'] = $this->convertToMM($val[3], 0); |
|
| 710 | - break; |
|
| 711 | - |
|
| 712 | - case 'padding-top': |
|
| 713 | - $this->value['padding']['t'] = $this->convertToMM($val, 0); |
|
| 714 | - break; |
|
| 715 | - |
|
| 716 | - case 'padding-right': |
|
| 717 | - $this->value['padding']['r'] = $this->convertToMM($val, 0); |
|
| 718 | - break; |
|
| 719 | - |
|
| 720 | - case 'padding-bottom': |
|
| 721 | - $this->value['padding']['b'] = $this->convertToMM($val, 0); |
|
| 722 | - break; |
|
| 723 | - |
|
| 724 | - case 'padding-left': |
|
| 725 | - $this->value['padding']['l'] = $this->convertToMM($val, 0); |
|
| 726 | - break; |
|
| 727 | - |
|
| 728 | - case 'margin': |
|
| 729 | - if ($val=='auto') { |
|
| 730 | - $this->value['margin-auto'] = true; |
|
| 731 | - break; |
|
| 732 | - } |
|
| 733 | - $val = explode(' ', $val); |
|
| 734 | - foreach ($val as $k => $v) { |
|
| 735 | - $v = trim($v); |
|
| 736 | - if ($v!='') { |
|
| 737 | - $val[$k] = $v; |
|
| 738 | - } else { |
|
| 739 | - unset($val[$k]); |
|
| 740 | - } |
|
| 741 | - } |
|
| 742 | - $val = array_values($val); |
|
| 743 | - $this->_duplicateBorder($val); |
|
| 744 | - $this->value['margin']['t'] = $this->convertToMM($val[0], 0); |
|
| 745 | - $this->value['margin']['r'] = $this->convertToMM($val[1], 0); |
|
| 746 | - $this->value['margin']['b'] = $this->convertToMM($val[2], 0); |
|
| 747 | - $this->value['margin']['l'] = $this->convertToMM($val[3], 0); |
|
| 748 | - break; |
|
| 749 | - |
|
| 750 | - case 'margin-top': |
|
| 751 | - $this->value['margin']['t'] = $this->convertToMM($val, 0); |
|
| 752 | - break; |
|
| 753 | - |
|
| 754 | - case 'margin-right': |
|
| 755 | - $this->value['margin']['r'] = $this->convertToMM($val, 0); |
|
| 756 | - break; |
|
| 757 | - |
|
| 758 | - case 'margin-bottom': |
|
| 759 | - $this->value['margin']['b'] = $this->convertToMM($val, 0); |
|
| 760 | - break; |
|
| 761 | - |
|
| 762 | - case 'margin-left': |
|
| 763 | - $this->value['margin']['l'] = $this->convertToMM($val, 0); |
|
| 764 | - break; |
|
| 765 | - |
|
| 766 | - case 'border': |
|
| 767 | - $val = $this->readBorder($val); |
|
| 768 | - $this->value['border']['t'] = $val; |
|
| 769 | - $this->value['border']['r'] = $val; |
|
| 770 | - $this->value['border']['b'] = $val; |
|
| 771 | - $this->value['border']['l'] = $val; |
|
| 772 | - break; |
|
| 773 | - |
|
| 774 | - case 'border-style': |
|
| 775 | - $val = explode(' ', $val); |
|
| 776 | - foreach ($val as $valK => $valV) { |
|
| 777 | - if (!in_array($valV, array('solid', 'dotted', 'dashed'))) { |
|
| 778 | - $val[$valK] = null; |
|
| 779 | - } |
|
| 780 | - } |
|
| 781 | - $this->_duplicateBorder($val); |
|
| 782 | - if ($val[0]) $this->value['border']['t']['type'] = $val[0]; |
|
| 783 | - if ($val[1]) $this->value['border']['r']['type'] = $val[1]; |
|
| 784 | - if ($val[2]) $this->value['border']['b']['type'] = $val[2]; |
|
| 785 | - if ($val[3]) $this->value['border']['l']['type'] = $val[3]; |
|
| 786 | - break; |
|
| 787 | - |
|
| 788 | - case 'border-top-style': |
|
| 789 | - if (in_array($val, array('solid', 'dotted', 'dashed'))) { |
|
| 790 | - $this->value['border']['t']['type'] = $val; |
|
| 791 | - } |
|
| 792 | - break; |
|
| 793 | - |
|
| 794 | - case 'border-right-style': |
|
| 795 | - if (in_array($val, array('solid', 'dotted', 'dashed'))) { |
|
| 796 | - $this->value['border']['r']['type'] = $val; |
|
| 797 | - } |
|
| 798 | - break; |
|
| 799 | - |
|
| 800 | - case 'border-bottom-style': |
|
| 801 | - if (in_array($val, array('solid', 'dotted', 'dashed'))) { |
|
| 802 | - $this->value['border']['b']['type'] = $val; |
|
| 803 | - } |
|
| 804 | - break; |
|
| 805 | - |
|
| 806 | - case 'border-left-style': |
|
| 807 | - if (in_array($val, array('solid', 'dotted', 'dashed'))) |
|
| 808 | - $this->value['border']['l']['type'] = $val; |
|
| 809 | - break; |
|
| 810 | - |
|
| 811 | - case 'border-color': |
|
| 812 | - $res = false; |
|
| 813 | - $val = preg_replace('/,[\s]+/', ',', $val); |
|
| 814 | - $val = explode(' ', $val); |
|
| 815 | - foreach ($val as $valK => $valV) { |
|
| 816 | - $val[$valK] = $this->convertToColor($valV, $res); |
|
| 817 | - if (!$res) { |
|
| 818 | - $val[$valK] = null; |
|
| 819 | - } |
|
| 820 | - } |
|
| 821 | - $this->_duplicateBorder($val); |
|
| 822 | - if (is_array($val[0])) $this->value['border']['t']['color'] = $val[0]; |
|
| 823 | - if (is_array($val[1])) $this->value['border']['r']['color'] = $val[1]; |
|
| 824 | - if (is_array($val[2])) $this->value['border']['b']['color'] = $val[2]; |
|
| 825 | - if (is_array($val[3])) $this->value['border']['l']['color'] = $val[3]; |
|
| 826 | - |
|
| 827 | - break; |
|
| 828 | - |
|
| 829 | - case 'border-top-color': |
|
| 830 | - $res = false; |
|
| 831 | - $val = $this->convertToColor($val, $res); |
|
| 832 | - if ($res) $this->value['border']['t']['color'] = $val; |
|
| 833 | - break; |
|
| 834 | - |
|
| 835 | - case 'border-right-color': |
|
| 836 | - $res = false; |
|
| 837 | - $val = $this->convertToColor($val, $res); |
|
| 838 | - if ($res) $this->value['border']['r']['color'] = $val; |
|
| 839 | - break; |
|
| 840 | - |
|
| 841 | - case 'border-bottom-color': |
|
| 842 | - $res = false; |
|
| 843 | - $val = $this->convertToColor($val, $res); |
|
| 844 | - if ($res) $this->value['border']['b']['color'] = $val; |
|
| 845 | - break; |
|
| 846 | - |
|
| 847 | - case 'border-left-color': |
|
| 848 | - $res = false; |
|
| 849 | - $val = $this->convertToColor($val, $res); |
|
| 850 | - if ($res) $this->value['border']['l']['color'] = $val; |
|
| 851 | - break; |
|
| 852 | - |
|
| 853 | - case 'border-width': |
|
| 854 | - $val = explode(' ', $val); |
|
| 855 | - foreach ($val as $valK => $valV) { |
|
| 856 | - $val[$valK] = $this->convertToMM($valV, 0); |
|
| 857 | - } |
|
| 858 | - $this->_duplicateBorder($val); |
|
| 859 | - if ($val[0]) $this->value['border']['t']['width'] = $val[0]; |
|
| 860 | - if ($val[1]) $this->value['border']['r']['width'] = $val[1]; |
|
| 861 | - if ($val[2]) $this->value['border']['b']['width'] = $val[2]; |
|
| 862 | - if ($val[3]) $this->value['border']['l']['width'] = $val[3]; |
|
| 863 | - break; |
|
| 864 | - |
|
| 865 | - case 'border-top-width': |
|
| 866 | - $val = $this->convertToMM($val, 0); |
|
| 867 | - if ($val) $this->value['border']['t']['width'] = $val; |
|
| 868 | - break; |
|
| 869 | - |
|
| 870 | - case 'border-right-width': |
|
| 871 | - $val = $this->convertToMM($val, 0); |
|
| 872 | - if ($val) $this->value['border']['r']['width'] = $val; |
|
| 873 | - break; |
|
| 874 | - |
|
| 875 | - case 'border-bottom-width': |
|
| 876 | - $val = $this->convertToMM($val, 0); |
|
| 877 | - if ($val) $this->value['border']['b']['width'] = $val; |
|
| 878 | - break; |
|
| 879 | - |
|
| 880 | - case 'border-left-width': |
|
| 881 | - $val = $this->convertToMM($val, 0); |
|
| 882 | - if ($val) $this->value['border']['l']['width'] = $val; |
|
| 883 | - break; |
|
| 884 | - |
|
| 885 | - case 'border-collapse': |
|
| 886 | - if ($tagName=='table') $this->value['border']['collapse'] = ($val=='collapse'); |
|
| 887 | - break; |
|
| 888 | - |
|
| 889 | - case 'border-radius': |
|
| 890 | - $val = explode('/', $val); |
|
| 891 | - if (count($val)>2) { |
|
| 892 | - break; |
|
| 893 | - } |
|
| 894 | - $valH = $this->convertToRadius(trim($val[0])); |
|
| 895 | - if (count($valH)<1 || count($valH)>4) { |
|
| 896 | - break; |
|
| 897 | - } |
|
| 898 | - if (!isset($valH[1])) $valH[1] = $valH[0]; |
|
| 899 | - if (!isset($valH[2])) $valH = array($valH[0], $valH[0], $valH[1], $valH[1]); |
|
| 900 | - if (!isset($valH[3])) $valH[3] = $valH[1]; |
|
| 901 | - if (isset($val[1])) { |
|
| 902 | - $valV = $this->convertToRadius(trim($val[1])); |
|
| 903 | - if (count($valV)<1 || count($valV)>4) { |
|
| 904 | - break; |
|
| 905 | - } |
|
| 906 | - if (!isset($valV[1])) $valV[1] = $valV[0]; |
|
| 907 | - if (!isset($valV[2])) $valV = array($valV[0], $valV[0], $valV[1], $valV[1]); |
|
| 908 | - if (!isset($valV[3])) $valV[3] = $valV[1]; |
|
| 909 | - } else { |
|
| 910 | - $valV = $valH; |
|
| 911 | - } |
|
| 912 | - $this->value['border']['radius'] = array( |
|
| 913 | - 'tl' => array($valH[0], $valV[0]), |
|
| 914 | - 'tr' => array($valH[1], $valV[1]), |
|
| 915 | - 'br' => array($valH[2], $valV[2]), |
|
| 916 | - 'bl' => array($valH[3], $valV[3]) |
|
| 917 | - ); |
|
| 918 | - break; |
|
| 919 | - |
|
| 920 | - case 'border-top-left-radius': |
|
| 921 | - $val = $this->convertToRadius($val); |
|
| 922 | - if (count($val)<1 || count($val)>2) { |
|
| 923 | - break; |
|
| 924 | - } |
|
| 925 | - $this->value['border']['radius']['tl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]); |
|
| 926 | - break; |
|
| 927 | - |
|
| 928 | - case 'border-top-right-radius': |
|
| 929 | - $val = $this->convertToRadius($val); |
|
| 930 | - if (count($val)<1 || count($val)>2) { |
|
| 931 | - break; |
|
| 932 | - } |
|
| 933 | - $this->value['border']['radius']['tr'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]); |
|
| 934 | - break; |
|
| 935 | - |
|
| 936 | - case 'border-bottom-right-radius': |
|
| 937 | - $val = $this->convertToRadius($val); |
|
| 938 | - if (count($val)<1 || count($val)>2) { |
|
| 939 | - break; |
|
| 940 | - } |
|
| 941 | - $this->value['border']['radius']['br'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]); |
|
| 942 | - break; |
|
| 943 | - |
|
| 944 | - case 'border-bottom-left-radius': |
|
| 945 | - $val = $this->convertToRadius($val); |
|
| 946 | - if (count($val)<1 || count($val)>2) { |
|
| 947 | - break; |
|
| 948 | - } |
|
| 949 | - $this->value['border']['radius']['bl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]); |
|
| 950 | - break; |
|
| 951 | - |
|
| 952 | - case 'border-top': |
|
| 953 | - $this->value['border']['t'] = $this->readBorder($val); |
|
| 954 | - break; |
|
| 955 | - |
|
| 956 | - case 'border-right': |
|
| 957 | - $this->value['border']['r'] = $this->readBorder($val); |
|
| 958 | - break; |
|
| 959 | - |
|
| 960 | - case 'border-bottom': |
|
| 961 | - $this->value['border']['b'] = $this->readBorder($val); |
|
| 962 | - break; |
|
| 963 | - |
|
| 964 | - case 'border-left': |
|
| 965 | - $this->value['border']['l'] = $this->readBorder($val); |
|
| 966 | - break; |
|
| 967 | - |
|
| 968 | - case 'background-color': |
|
| 969 | - $this->value['background']['color'] = $this->convertBackgroundColor($val); |
|
| 970 | - break; |
|
| 971 | - |
|
| 972 | - case 'background-image': |
|
| 973 | - $this->value['background']['image'] = $this->convertBackgroundImage($val); |
|
| 974 | - break; |
|
| 975 | - |
|
| 976 | - case 'background-position': |
|
| 977 | - $res = null; |
|
| 978 | - $this->value['background']['position'] = $this->convertBackgroundPosition($val, $res); |
|
| 979 | - break; |
|
| 980 | - |
|
| 981 | - case 'background-repeat': |
|
| 982 | - $this->value['background']['repeat'] = $this->convertBackgroundRepeat($val); |
|
| 983 | - break; |
|
| 984 | - |
|
| 985 | - case 'background': |
|
| 986 | - $this->convertBackground($val, $this->value['background']); |
|
| 987 | - break; |
|
| 988 | - |
|
| 989 | - case 'position': |
|
| 990 | - if ($val=='absolute') $this->value['position'] = 'absolute'; |
|
| 991 | - else if ($val=='relative') $this->value['position'] = 'relative'; |
|
| 992 | - else $this->value['position'] = null; |
|
| 993 | - break; |
|
| 994 | - |
|
| 995 | - case 'float': |
|
| 996 | - if ($val=='left') $this->value['float'] = 'left'; |
|
| 997 | - else if ($val=='right') $this->value['float'] = 'right'; |
|
| 998 | - else $this->value['float'] = null; |
|
| 999 | - break; |
|
| 1000 | - |
|
| 1001 | - case 'display': |
|
| 1002 | - if ($val=='inline') $this->value['display'] = 'inline'; |
|
| 1003 | - else if ($val=='block') $this->value['display'] = 'block'; |
|
| 1004 | - else if ($val=='none') $this->value['display'] = 'none'; |
|
| 1005 | - else $this->value['display'] = null; |
|
| 1006 | - break; |
|
| 1007 | - |
|
| 1008 | - case 'top': |
|
| 1009 | - case 'bottom': |
|
| 1010 | - case 'left': |
|
| 1011 | - case 'right': |
|
| 1012 | - $this->value[$nom] = $val; |
|
| 1013 | - break; |
|
| 1014 | - |
|
| 1015 | - case 'list-style': |
|
| 1016 | - case 'list-style-type': |
|
| 1017 | - case 'list-style-image': |
|
| 1018 | - if ($nom=='list-style') $nom = 'list-style-type'; |
|
| 1019 | - $this->value[$nom] = $val; |
|
| 1020 | - break; |
|
| 1021 | - |
|
| 1022 | - default: |
|
| 1023 | - break; |
|
| 1024 | - } |
|
| 1025 | - } |
|
| 1026 | - |
|
| 1027 | - $return = true; |
|
| 1028 | - |
|
| 1029 | - // only for P tag |
|
| 1030 | - if ($this->value['margin']['t']===null) $this->value['margin']['t'] = $this->value['font-size']; |
|
| 1031 | - if ($this->value['margin']['b']===null) $this->value['margin']['b'] = $this->value['font-size']; |
|
| 1032 | - |
|
| 1033 | - // force the text align to left, if asked by html2pdf |
|
| 1034 | - if ($this->_onlyLeft) $this->value['text-align'] = 'left'; |
|
| 1035 | - |
|
| 1036 | - // correction on the width (quick box) |
|
| 1037 | - if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position']!='absolute') { |
|
| 1038 | - $this->value['width'] = $this->getLastWidth(); |
|
| 1039 | - $this->value['width']-= $this->value['margin']['l'] + $this->value['margin']['r']; |
|
| 1040 | - } else { |
|
| 1041 | - if ($correctWidth) { |
|
| 1042 | - if (!in_array($tagName, array('table', 'div', 'blockquote', 'fieldset', 'hr'))) { |
|
| 1043 | - $this->value['width']-= $this->value['padding']['l'] + $this->value['padding']['r']; |
|
| 1044 | - $this->value['width']-= $this->value['border']['l']['width'] + $this->value['border']['r']['width']; |
|
| 1045 | - } |
|
| 1046 | - if (in_array($tagName, array('th', 'td'))) { |
|
| 1047 | - $this->value['width']-= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px'); |
|
| 1048 | - $return = false; |
|
| 1049 | - } |
|
| 1050 | - if ($this->value['width']<0) $this->value['width']=0; |
|
| 1051 | - } else { |
|
| 1052 | - if ($this->value['width']) { |
|
| 1053 | - if ($this->value['border']['l']['width']) $this->value['width'] += $this->value['border']['l']['width']; |
|
| 1054 | - if ($this->value['border']['r']['width']) $this->value['width'] += $this->value['border']['r']['width']; |
|
| 1055 | - if ($this->value['padding']['l']) $this->value['width'] += $this->value['padding']['l']; |
|
| 1056 | - if ($this->value['padding']['r']) $this->value['width'] += $this->value['padding']['r']; |
|
| 1057 | - } |
|
| 1058 | - } |
|
| 1059 | - } |
|
| 1060 | - if ($this->value['height']) { |
|
| 1061 | - if ($this->value['border']['b']['width']) $this->value['height'] += $this->value['border']['b']['width']; |
|
| 1062 | - if ($this->value['border']['t']['width']) $this->value['height'] += $this->value['border']['t']['width']; |
|
| 1063 | - if ($this->value['padding']['b']) $this->value['height'] += $this->value['padding']['b']; |
|
| 1064 | - if ($this->value['padding']['t']) $this->value['height'] += $this->value['padding']['t']; |
|
| 1065 | - } |
|
| 1066 | - |
|
| 1067 | - if ($this->value['top']!=null) $this->value['top'] = $this->convertToMM($this->value['top'], $this->getLastHeight(true)); |
|
| 1068 | - if ($this->value['bottom']!=null) $this->value['bottom'] = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true)); |
|
| 1069 | - if ($this->value['left']!=null) $this->value['left'] = $this->convertToMM($this->value['left'], $this->getLastWidth(true)); |
|
| 1070 | - if ($this->value['right']!=null) $this->value['right'] = $this->convertToMM($this->value['right'], $this->getLastWidth(true)); |
|
| 1071 | - |
|
| 1072 | - if ($this->value['top'] && $this->value['bottom'] && $this->value['height']) $this->value['bottom'] = null; |
|
| 1073 | - if ($this->value['left'] && $this->value['right'] && $this->value['width']) $this->value['right'] = null; |
|
| 1074 | - |
|
| 1075 | - return $return; |
|
| 1076 | - } |
|
| 1077 | - |
|
| 1078 | - /** |
|
| 1079 | - * get the height of the current line |
|
| 1080 | - * |
|
| 1081 | - * @access public |
|
| 1082 | - * @return float $height in mm |
|
| 1083 | - */ |
|
| 1084 | - public function getLineHeight() |
|
| 1085 | - { |
|
| 1086 | - $val = $this->value['line-height']; |
|
| 1087 | - if ($val=='normal') $val = '108%'; |
|
| 1088 | - return $this->convertToMM($val, $this->value['font-size']); |
|
| 1089 | - } |
|
| 1090 | - |
|
| 1091 | - /** |
|
| 1092 | - * get the width of the parent |
|
| 1093 | - * |
|
| 1094 | - * @access public |
|
| 1095 | - * @param boolean $mode true => adding padding and border |
|
| 1096 | - * @return float $width in mm |
|
| 1097 | - */ |
|
| 1098 | - public function getLastWidth($mode = false) |
|
| 1099 | - { |
|
| 1100 | - for ($k=count($this->table)-1; $k>=0; $k--) { |
|
| 1101 | - if ($this->table[$k]['width']) { |
|
| 1102 | - $w = $this->table[$k]['width']; |
|
| 1103 | - if ($mode) { |
|
| 1104 | - $w+= $this->table[$k]['border']['l']['width'] + $this->table[$k]['padding']['l'] + 0.02; |
|
| 1105 | - $w+= $this->table[$k]['border']['r']['width'] + $this->table[$k]['padding']['r'] + 0.02; |
|
| 1106 | - } |
|
| 1107 | - return $w; |
|
| 1108 | - } |
|
| 1109 | - } |
|
| 1110 | - return $this->_pdf->getW() - $this->_pdf->getlMargin() - $this->_pdf->getrMargin(); |
|
| 1111 | - } |
|
| 1112 | - |
|
| 1113 | - /** |
|
| 1114 | - * get the height of the parent |
|
| 1115 | - * |
|
| 1116 | - * @access public |
|
| 1117 | - * @param boolean $mode true => adding padding and border |
|
| 1118 | - * @return float $height in mm |
|
| 1119 | - */ |
|
| 1120 | - public function getLastHeight($mode = false) |
|
| 1121 | - { |
|
| 1122 | - for ($k=count($this->table)-1; $k>=0; $k--) { |
|
| 1123 | - if ($this->table[$k]['height']) { |
|
| 1124 | - $h = $this->table[$k]['height']; |
|
| 1125 | - if ($mode) { |
|
| 1126 | - $h+= $this->table[$k]['border']['t']['width'] + $this->table[$k]['padding']['t'] + 0.02; |
|
| 1127 | - $h+= $this->table[$k]['border']['b']['width'] + $this->table[$k]['padding']['b'] + 0.02; |
|
| 1128 | - } |
|
| 1129 | - return $h; |
|
| 1130 | - } |
|
| 1131 | - } |
|
| 1132 | - return $this->_pdf->getH() - $this->_pdf->gettMargin() - $this->_pdf->getbMargin(); |
|
| 1133 | - } |
|
| 1134 | - |
|
| 1135 | - /** |
|
| 1136 | - * get the value of the float property |
|
| 1137 | - * |
|
| 1138 | - * @access public |
|
| 1139 | - * @return $float left/right |
|
| 1140 | - */ |
|
| 1141 | - public function getFloat() |
|
| 1142 | - { |
|
| 1143 | - if ($this->value['float']=='left') return 'left'; |
|
| 1144 | - if ($this->value['float']=='right') return 'right'; |
|
| 1145 | - return null; |
|
| 1146 | - } |
|
| 1147 | - |
|
| 1148 | - /** |
|
| 1149 | - * get the last value for a specific key |
|
| 1150 | - * |
|
| 1151 | - * @access public |
|
| 1152 | - * @param string $key |
|
| 1153 | - * @return mixed |
|
| 1154 | - */ |
|
| 1155 | - public function getLastValue($key) |
|
| 1156 | - { |
|
| 1157 | - $nb = count($this->table); |
|
| 1158 | - if ($nb>0) { |
|
| 1159 | - return $this->table[$nb-1][$key]; |
|
| 1160 | - } else { |
|
| 1161 | - return null; |
|
| 1162 | - } |
|
| 1163 | - } |
|
| 1164 | - |
|
| 1165 | - /** |
|
| 1166 | - * get the last absolute X |
|
| 1167 | - * |
|
| 1168 | - * @access protected |
|
| 1169 | - * @return float $x |
|
| 1170 | - */ |
|
| 1171 | - protected function _getLastAbsoluteX() |
|
| 1172 | - { |
|
| 1173 | - for ($k=count($this->table)-1; $k>=0; $k--) { |
|
| 1174 | - if ($this->table[$k]['x'] && $this->table[$k]['position']) return $this->table[$k]['x']; |
|
| 1175 | - } |
|
| 1176 | - return $this->_pdf->getlMargin(); |
|
| 1177 | - } |
|
| 1178 | - |
|
| 1179 | - /** |
|
| 1180 | - * get the last absolute Y |
|
| 1181 | - * |
|
| 1182 | - * @access protected |
|
| 1183 | - * @return float $y |
|
| 1184 | - */ |
|
| 1185 | - protected function _getLastAbsoluteY() |
|
| 1186 | - { |
|
| 1187 | - for ($k=count($this->table)-1; $k>=0; $k--) { |
|
| 1188 | - if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y']; |
|
| 1189 | - } |
|
| 1190 | - return $this->_pdf->gettMargin(); |
|
| 1191 | - } |
|
| 1192 | - |
|
| 1193 | - /** |
|
| 1194 | - * get the CSS properties of the current tag |
|
| 1195 | - * |
|
| 1196 | - * @access protected |
|
| 1197 | - * @return array $styles |
|
| 1198 | - */ |
|
| 1199 | - protected function _getFromCSS() |
|
| 1200 | - { |
|
| 1201 | - // styles to apply |
|
| 1202 | - $styles = array(); |
|
| 1203 | - |
|
| 1204 | - // list of the selectors to get in the CSS files |
|
| 1205 | - $getit = array(); |
|
| 1206 | - |
|
| 1207 | - // get the list of the selectors of each tags |
|
| 1208 | - $lst = array(); |
|
| 1209 | - $lst[] = $this->value['id_lst']; |
|
| 1210 | - for ($i=count($this->table)-1; $i>=0; $i--) { |
|
| 1211 | - $lst[] = $this->table[$i]['id_lst']; |
|
| 1212 | - } |
|
| 1213 | - |
|
| 1214 | - // foreach selectors in the CSS files, verify if it match with the list of selectors |
|
| 1215 | - foreach ($this->cssKeys as $key => $num) { |
|
| 1216 | - if ($this->_getReccursiveStyle($key, $lst)) { |
|
| 1217 | - $getit[$key] = $num; |
|
| 1218 | - } |
|
| 1219 | - } |
|
| 1220 | - |
|
| 1221 | - // if we have selectors |
|
| 1222 | - if (count($getit)) { |
|
| 1223 | - // get them, but in the definition order, because of priority |
|
| 1224 | - asort($getit); |
|
| 1225 | - foreach ($getit as $key => $val) $styles = array_merge($styles, $this->css[$key]); |
|
| 1226 | - } |
|
| 1227 | - |
|
| 1228 | - return $styles; |
|
| 1229 | - } |
|
| 1230 | - |
|
| 1231 | - /** |
|
| 1232 | - * identify if the selector $key match with the list of tag selectors |
|
| 1233 | - * |
|
| 1234 | - * @access protected |
|
| 1235 | - * @param string $key CSS selector to analyse |
|
| 1236 | - * @param array $lst list of the selectors of each tags |
|
| 1237 | - * @param string $next next step of parsing the selector |
|
| 1238 | - * @return boolean |
|
| 1239 | - */ |
|
| 1240 | - protected function _getReccursiveStyle($key, $lst, $next = null) |
|
| 1241 | - { |
|
| 1242 | - // if next step |
|
| 1243 | - if ($next!==null) { |
|
| 1244 | - // we remove this step |
|
| 1245 | - if ($next) $key = trim(substr($key, 0, -strlen($next))); |
|
| 1246 | - array_shift($lst); |
|
| 1247 | - |
|
| 1248 | - // if no more step to identify => return false |
|
| 1249 | - if (!count($lst)) { |
|
| 1250 | - return false; |
|
| 1251 | - } |
|
| 1252 | - } |
|
| 1253 | - |
|
| 1254 | - // for each selector of the current step |
|
| 1255 | - foreach ($lst[0] as $name) { |
|
| 1256 | - // if selector = key => ok |
|
| 1257 | - if ($key==$name) { |
|
| 1258 | - return true; |
|
| 1259 | - } |
|
| 1260 | - |
|
| 1261 | - // if the end of the key = the selector and the next step is ok => ok |
|
| 1262 | - if (substr($key, -strlen(' '.$name))==' '.$name && $this->_getReccursiveStyle($key, $lst, $name)) { |
|
| 1263 | - return true; |
|
| 1264 | - } |
|
| 1265 | - } |
|
| 1266 | - |
|
| 1267 | - // if we are not in the first step, we analyse the sub steps (the pareng tag of the current tag) |
|
| 1268 | - if ($next!==null && $this->_getReccursiveStyle($key, $lst, '')) { |
|
| 1269 | - return true; |
|
| 1270 | - } |
|
| 1271 | - |
|
| 1272 | - // no corresponding found |
|
| 1273 | - return false; |
|
| 1274 | - } |
|
| 1275 | - |
|
| 1276 | - /** |
|
| 1277 | - * Analyse a border |
|
| 1278 | - * |
|
| 1279 | - * @access public |
|
| 1280 | - * @param string $css css border properties |
|
| 1281 | - * @return array border properties |
|
| 1282 | - */ |
|
| 1283 | - public function readBorder($css) |
|
| 1284 | - { |
|
| 1285 | - // border none |
|
| 1286 | - $none = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0)); |
|
| 1287 | - |
|
| 1288 | - // default value |
|
| 1289 | - $type = 'solid'; |
|
| 1290 | - $width = $this->convertToMM('1pt'); |
|
| 1291 | - $color = array(0, 0, 0); |
|
| 1292 | - |
|
| 1293 | - // clean up the values |
|
| 1294 | - $css = explode(' ', $css); |
|
| 1295 | - foreach ($css as $k => $v) { |
|
| 1296 | - $v = trim($v); |
|
| 1297 | - if ($v) $css[$k] = $v; |
|
| 1298 | - else unset($css[$k]); |
|
| 1299 | - } |
|
| 1300 | - $css = array_values($css); |
|
| 1301 | - |
|
| 1302 | - // read the values |
|
| 1303 | - $res = null; |
|
| 1304 | - foreach ($css as $value) { |
|
| 1305 | - |
|
| 1306 | - // if no border => return none |
|
| 1307 | - if ($value=='none' || $value=='hidden') { |
|
| 1308 | - return $none; |
|
| 1309 | - } |
|
| 1310 | - |
|
| 1311 | - // try to convert the value as a distance |
|
| 1312 | - $tmp = $this->convertToMM($value); |
|
| 1313 | - |
|
| 1314 | - // if the convert is ok => it is a width |
|
| 1315 | - if ($tmp!==null) { |
|
| 1316 | - $width = $tmp; |
|
| 1317 | - // else, it could be the type |
|
| 1318 | - } else if (in_array($value, array('solid', 'dotted', 'dashed', 'double'))) { |
|
| 1319 | - $type = $value; |
|
| 1320 | - // else, it could be the color |
|
| 1321 | - } else { |
|
| 1322 | - $tmp = $this->convertToColor($value, $res); |
|
| 1323 | - if ($res) $color = $tmp; |
|
| 1324 | - } |
|
| 1325 | - } |
|
| 1326 | - |
|
| 1327 | - // if no witdh => return none |
|
| 1328 | - if (!$width) return $none; |
|
| 1329 | - |
|
| 1330 | - // return the border properties |
|
| 1331 | - return array('type' => $type, 'width' => $width, 'color' => $color); |
|
| 1332 | - } |
|
| 1333 | - |
|
| 1334 | - /** |
|
| 1335 | - * duplicate the borders if needed |
|
| 1336 | - * |
|
| 1337 | - * @access protected |
|
| 1338 | - * @param &array $val |
|
| 1339 | - */ |
|
| 1340 | - protected function _duplicateBorder(&$val) |
|
| 1341 | - { |
|
| 1342 | - // 1 value => L => RTB |
|
| 1343 | - if (count($val)==1) { |
|
| 1344 | - $val[1] = $val[0]; |
|
| 1345 | - $val[2] = $val[0]; |
|
| 1346 | - $val[3] = $val[0]; |
|
| 1347 | - // 2 values => L => R & T => B |
|
| 1348 | - } else if (count($val)==2) { |
|
| 1349 | - $val[2] = $val[0]; |
|
| 1350 | - $val[3] = $val[1]; |
|
| 1351 | - // 3 values => T => B |
|
| 1352 | - } else if (count($val)==3) { |
|
| 1353 | - $val[3] = $val[1]; |
|
| 1354 | - } |
|
| 1355 | - } |
|
| 1356 | - |
|
| 1357 | - /** |
|
| 1358 | - * Analyse a background |
|
| 1359 | - * |
|
| 1360 | - * @access public |
|
| 1361 | - * @param string $css css background properties |
|
| 1362 | - * @param &array $value parsed values (by reference, because, ther is a legacy of the parent CSS properties) |
|
| 1363 | - */ |
|
| 1364 | - public function convertBackground($css, &$value) |
|
| 1365 | - { |
|
| 1366 | - // is there a image ? |
|
| 1367 | - $text = '/url\(([^)]*)\)/isU'; |
|
| 1368 | - if (preg_match($text, $css, $match)) { |
|
| 1369 | - // get the image |
|
| 1370 | - $value['image'] = $this->convertBackgroundImage($match[0]); |
|
| 1371 | - |
|
| 1372 | - // remove if from the css properties |
|
| 1373 | - $css = preg_replace($text, '', $css); |
|
| 1374 | - $css = preg_replace('/[\s]+/', ' ', $css); |
|
| 1375 | - } |
|
| 1376 | - |
|
| 1377 | - // protect some spaces |
|
| 1378 | - $css = preg_replace('/,[\s]+/', ',', $css); |
|
| 1379 | - |
|
| 1380 | - // explode the values |
|
| 1381 | - $css = explode(' ', $css); |
|
| 1382 | - |
|
| 1383 | - // background position to parse |
|
| 1384 | - $pos = ''; |
|
| 1385 | - |
|
| 1386 | - // foreach value |
|
| 1387 | - foreach ($css as $val) { |
|
| 1388 | - // try to parse the value as a color |
|
| 1389 | - $ok = false; |
|
| 1390 | - $color = $this->convertToColor($val, $ok); |
|
| 1391 | - |
|
| 1392 | - // if ok => it is a color |
|
| 1393 | - if ($ok) { |
|
| 1394 | - $value['color'] = $color; |
|
| 1395 | - // else if transparent => no coloàr |
|
| 1396 | - } else if ($val=='transparent') { |
|
| 1397 | - $value['color'] = null; |
|
| 1398 | - // else |
|
| 1399 | - } else { |
|
| 1400 | - // try to parse the value as a repeat |
|
| 1401 | - $repeat = $this->convertBackgroundRepeat($val); |
|
| 1402 | - |
|
| 1403 | - // if ok => it is repeat |
|
| 1404 | - if ($repeat) { |
|
| 1405 | - $value['repeat'] = $repeat; |
|
| 1406 | - // else => it could only be a position |
|
| 1407 | - } else { |
|
| 1408 | - $pos.= ($pos ? ' ' : '').$val; |
|
| 1409 | - } |
|
| 1410 | - } |
|
| 1411 | - } |
|
| 1412 | - |
|
| 1413 | - // if we have a position to parse |
|
| 1414 | - if ($pos) { |
|
| 1415 | - // try to read it |
|
| 1416 | - $pos = $this->convertBackgroundPosition($pos, $ok); |
|
| 1417 | - if ($ok) $value['position'] = $pos; |
|
| 1418 | - } |
|
| 1419 | - } |
|
| 1420 | - |
|
| 1421 | - /** |
|
| 1422 | - * parse a background color |
|
| 1423 | - * |
|
| 1424 | - * @access public |
|
| 1425 | - * @param string $css |
|
| 1426 | - * @return string $value |
|
| 1427 | - */ |
|
| 1428 | - public function convertBackgroundColor($css) |
|
| 1429 | - { |
|
| 1430 | - $res = null; |
|
| 1431 | - if ($css=='transparent') return null; |
|
| 1432 | - else return $this->convertToColor($css, $res); |
|
| 1433 | - } |
|
| 1434 | - |
|
| 1435 | - /** |
|
| 1436 | - * parse a background image |
|
| 1437 | - * |
|
| 1438 | - * @access public |
|
| 1439 | - * @param string $css |
|
| 1440 | - * @return string $value |
|
| 1441 | - */ |
|
| 1442 | - public function convertBackgroundImage($css) |
|
| 1443 | - { |
|
| 1444 | - if ($css=='none') |
|
| 1445 | - return null; |
|
| 1446 | - else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match)) |
|
| 1447 | - return $match[1]; |
|
| 1448 | - else |
|
| 1449 | - return null; |
|
| 1450 | - } |
|
| 1451 | - |
|
| 1452 | - /** |
|
| 1453 | - * parse a background position |
|
| 1454 | - * |
|
| 1455 | - * @access public |
|
| 1456 | - * @param string $css |
|
| 1457 | - * @param &boolean $res flag if conver is ok or not |
|
| 1458 | - * @return array ($x, $y) |
|
| 1459 | - */ |
|
| 1460 | - public function convertBackgroundPosition($css, &$res) |
|
| 1461 | - { |
|
| 1462 | - // init the res |
|
| 1463 | - $res = false; |
|
| 1464 | - |
|
| 1465 | - // explode the value |
|
| 1466 | - $css = explode(' ', $css); |
|
| 1467 | - |
|
| 1468 | - // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2 |
|
| 1469 | - if (count($css)<2) { |
|
| 1470 | - if (!$css[0]) return null; |
|
| 1471 | - $css[1] = 'center'; |
|
| 1472 | - } |
|
| 1473 | - if (count($css)>2) return null; |
|
| 1474 | - |
|
| 1475 | - // prepare the values |
|
| 1476 | - $x = 0; |
|
| 1477 | - $y = 0; |
|
| 1478 | - $res = true; |
|
| 1479 | - |
|
| 1480 | - // convert the first value |
|
| 1481 | - if ($css[0]=='left') $x = '0%'; |
|
| 1482 | - else if ($css[0]=='center') $x = '50%'; |
|
| 1483 | - else if ($css[0]=='right') $x = '100%'; |
|
| 1484 | - else if ($css[0]=='top') $y = '0%'; |
|
| 1485 | - else if ($css[0]=='bottom') $y = '100%'; |
|
| 1486 | - else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0]; |
|
| 1487 | - else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]); |
|
| 1488 | - else $res = false; |
|
| 1489 | - |
|
| 1490 | - // convert the second value |
|
| 1491 | - if ($css[1]=='left') $x = '0%'; |
|
| 1492 | - else if ($css[1]=='right') $x = '100%'; |
|
| 1493 | - else if ($css[1]=='top') $y = '0%'; |
|
| 1494 | - else if ($css[1]=='center') $y = '50%'; |
|
| 1495 | - else if ($css[1]=='bottom') $y = '100%'; |
|
| 1496 | - else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1]; |
|
| 1497 | - else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]); |
|
| 1498 | - else $res = false; |
|
| 1499 | - |
|
| 1500 | - // return the values |
|
| 1501 | - return array($x, $y); |
|
| 1502 | - } |
|
| 1503 | - |
|
| 1504 | - /** |
|
| 1505 | - * parse a background repeat |
|
| 1506 | - * |
|
| 1507 | - * @access public |
|
| 1508 | - * @param string $css |
|
| 1509 | - * @return string $value |
|
| 1510 | - */ |
|
| 1511 | - public function convertBackgroundRepeat($css) |
|
| 1512 | - { |
|
| 1513 | - switch($css) |
|
| 1514 | - { |
|
| 1515 | - case 'repeat': |
|
| 1516 | - return array(true, true); |
|
| 1517 | - case 'repeat-x': |
|
| 1518 | - return array(true, false); |
|
| 1519 | - case 'repeat-y': |
|
| 1520 | - return array(false, true); |
|
| 1521 | - case 'no-repeat': |
|
| 1522 | - return array(false, false); |
|
| 1523 | - } |
|
| 1524 | - return null; |
|
| 1525 | - } |
|
| 1526 | - |
|
| 1527 | - /** |
|
| 1528 | - * convert a distance to mm |
|
| 1529 | - * |
|
| 1530 | - * @access public |
|
| 1531 | - * @param string $css distance to convert |
|
| 1532 | - * @param float $old parent distance |
|
| 1533 | - * @return float $value |
|
| 1534 | - */ |
|
| 1535 | - public function convertToMM($css, $old=0.) |
|
| 1536 | - { |
|
| 1537 | - $css = trim($css); |
|
| 1538 | - if (preg_match('/^[0-9\.\-]+$/isU', $css)) $css.= 'px'; |
|
| 1539 | - if (preg_match('/^[0-9\.\-]+px$/isU', $css)) $css = 25.4/96. * str_replace('px', '', $css); |
|
| 1540 | - else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css); |
|
| 1541 | - else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css); |
|
| 1542 | - else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css); |
|
| 1543 | - else if (preg_match('/^[0-9\.\-]+%$/isU', $css)) $css = 1.*$old*str_replace('%', '', $css)/100.; |
|
| 1544 | - else $css = null; |
|
| 1545 | - |
|
| 1546 | - return $css; |
|
| 1547 | - } |
|
| 1548 | - |
|
| 1549 | - /** |
|
| 1550 | - * convert a css radius |
|
| 1551 | - * |
|
| 1552 | - * @access public |
|
| 1553 | - * @param string $css |
|
| 1554 | - * @return float $value |
|
| 1555 | - */ |
|
| 1556 | - public function convertToRadius($css) |
|
| 1557 | - { |
|
| 1558 | - // explode the value |
|
| 1559 | - $css = explode(' ', $css); |
|
| 1560 | - |
|
| 1561 | - foreach ($css as $k => $v) { |
|
| 1562 | - $v = trim($v); |
|
| 1563 | - if ($v) { |
|
| 1564 | - $v = $this->convertToMM($v, 0); |
|
| 1565 | - if ($v!==null) { |
|
| 1566 | - $css[$k] = $v; |
|
| 1567 | - } else { |
|
| 1568 | - unset($css[$k]); |
|
| 1569 | - } |
|
| 1570 | - } else { |
|
| 1571 | - unset($css[$k]); |
|
| 1572 | - } |
|
| 1573 | - } |
|
| 1574 | - |
|
| 1575 | - return array_values($css); |
|
| 1576 | - } |
|
| 1577 | - |
|
| 1578 | - /** |
|
| 1579 | - * convert a css color |
|
| 1580 | - * |
|
| 1581 | - * @access public |
|
| 1582 | - * @param string $css |
|
| 1583 | - * @param &boolean $res |
|
| 1584 | - * @return array (r,g, b) |
|
| 1585 | - */ |
|
| 1586 | - public function convertToColor($css, &$res) |
|
| 1587 | - { |
|
| 1588 | - // prepare the value |
|
| 1589 | - $css = trim($css); |
|
| 1590 | - $res = true; |
|
| 1591 | - |
|
| 1592 | - // if transparent => return null |
|
| 1593 | - if (strtolower($css)=='transparent') return array(null, null, null); |
|
| 1594 | - |
|
| 1595 | - // HTML color |
|
| 1596 | - if (isset($this->_htmlColor[strtolower($css)])) { |
|
| 1597 | - $css = $this->_htmlColor[strtolower($css)]; |
|
| 1598 | - $r = floatVal(hexdec(substr($css, 0, 2))); |
|
| 1599 | - $v = floatVal(hexdec(substr($css, 2, 2))); |
|
| 1600 | - $b = floatVal(hexdec(substr($css, 4, 2))); |
|
| 1601 | - return array($r, $v, $b); |
|
| 1602 | - } |
|
| 1603 | - |
|
| 1604 | - // like #FFFFFF |
|
| 1605 | - if (preg_match('/^#[0-9A-Fa-f]{6}$/isU', $css)) { |
|
| 1606 | - $r = floatVal(hexdec(substr($css, 1, 2))); |
|
| 1607 | - $v = floatVal(hexdec(substr($css, 3, 2))); |
|
| 1608 | - $b = floatVal(hexdec(substr($css, 5, 2))); |
|
| 1609 | - return array($r, $v, $b); |
|
| 1610 | - } |
|
| 1611 | - |
|
| 1612 | - // like #FFF |
|
| 1613 | - if (preg_match('/^#[0-9A-F]{3}$/isU', $css)) { |
|
| 1614 | - $r = floatVal(hexdec(substr($css, 1, 1).substr($css, 1, 1))); |
|
| 1615 | - $v = floatVal(hexdec(substr($css, 2, 1).substr($css, 2, 1))); |
|
| 1616 | - $b = floatVal(hexdec(substr($css, 3, 1).substr($css, 3, 1))); |
|
| 1617 | - return array($r, $v, $b); |
|
| 1618 | - } |
|
| 1619 | - |
|
| 1620 | - // like rgb(100, 100, 100) |
|
| 1621 | - if (preg_match('/rgb\([\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*\)/isU', $css, $match)) { |
|
| 1622 | - $r = $this->_convertSubColor($match[1]); |
|
| 1623 | - $v = $this->_convertSubColor($match[2]); |
|
| 1624 | - $b = $this->_convertSubColor($match[3]); |
|
| 1625 | - return array($r*255., $v*255., $b*255.); |
|
| 1626 | - } |
|
| 1627 | - |
|
| 1628 | - // like cmyk(100, 100, 100, 100) |
|
| 1629 | - if (preg_match('/cmyk\([\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*\)/isU', $css, $match)) { |
|
| 1630 | - $c = $this->_convertSubColor($match[1]); |
|
| 1631 | - $m = $this->_convertSubColor($match[2]); |
|
| 1632 | - $y = $this->_convertSubColor($match[3]); |
|
| 1633 | - $k = $this->_convertSubColor($match[4]); |
|
| 1634 | - return array($c*100., $m*100., $y*100., $k*100.); |
|
| 1635 | - } |
|
| 1636 | - |
|
| 1637 | - $res = false; |
|
| 1638 | - return array(0., 0., 0.); |
|
| 1639 | - } |
|
| 1640 | - |
|
| 1641 | - /** |
|
| 1642 | - * color value to convert |
|
| 1643 | - * |
|
| 1644 | - * @access protected |
|
| 1645 | - * @param string $c |
|
| 1646 | - * @return float $c 0.->1. |
|
| 1647 | - */ |
|
| 1648 | - protected function _convertSubColor($c) |
|
| 1649 | - { |
|
| 1650 | - if (substr($c, -1)=='%') { |
|
| 1651 | - $c = floatVal(substr($c, 0, -1))/100.; |
|
| 1652 | - } else { |
|
| 1653 | - $c = floatVal($c); |
|
| 1654 | - if ($c>1) $c = $c/255.; |
|
| 1655 | - } |
|
| 1656 | - |
|
| 1657 | - return $c; |
|
| 1658 | - } |
|
| 1659 | - |
|
| 1660 | - /** |
|
| 1661 | - * read a css content |
|
| 1662 | - * |
|
| 1663 | - * @access protected |
|
| 1664 | - * @param &string $code |
|
| 1665 | - */ |
|
| 1666 | - protected function _analyseStyle(&$code) |
|
| 1667 | - { |
|
| 1668 | - // clean the spaces |
|
| 1669 | - $code = preg_replace('/[\s]+/', ' ', $code); |
|
| 1670 | - |
|
| 1671 | - // remove the comments |
|
| 1672 | - $code = preg_replace('/\/\*.*?\*\//s', '', $code); |
|
| 1673 | - |
|
| 1674 | - // split each CSS code "selector { value }" |
|
| 1675 | - preg_match_all('/([^{}]+){([^}]*)}/isU', $code, $match); |
|
| 1676 | - |
|
| 1677 | - // for each CSS code |
|
| 1678 | - for ($k=0; $k<count($match[0]); $k++) { |
|
| 1679 | - |
|
| 1680 | - // selectors |
|
| 1681 | - $names = strtolower(trim($match[1][$k])); |
|
| 1682 | - |
|
| 1683 | - // css style |
|
| 1684 | - $styles = trim($match[2][$k]); |
|
| 1685 | - |
|
| 1686 | - // explode each value |
|
| 1687 | - $styles = explode(';', $styles); |
|
| 1688 | - |
|
| 1689 | - // parse each value |
|
| 1690 | - $css = array(); |
|
| 1691 | - foreach ($styles as $style) { |
|
| 1692 | - $tmp = explode(':', $style); |
|
| 1693 | - if (count($tmp)>1) { |
|
| 1694 | - $cod = $tmp[0]; unset($tmp[0]); $tmp = implode(':', $tmp); |
|
| 1695 | - $css[trim(strtolower($cod))] = trim($tmp); |
|
| 1696 | - } |
|
| 1697 | - } |
|
| 1698 | - |
|
| 1699 | - // explode the names |
|
| 1700 | - $names = explode(',', $names); |
|
| 1701 | - |
|
| 1702 | - // save the values for each names |
|
| 1703 | - foreach ($names as $name) { |
|
| 1704 | - // clean the name |
|
| 1705 | - $name = trim($name); |
|
| 1706 | - |
|
| 1707 | - // if a selector with somethink lige :hover => continue |
|
| 1708 | - if (strpos($name, ':')!==false) continue; |
|
| 1709 | - |
|
| 1710 | - // save the value |
|
| 1711 | - if (!isset($this->css[$name])) |
|
| 1712 | - $this->css[$name] = $css; |
|
| 1713 | - else |
|
| 1714 | - $this->css[$name] = array_merge($this->css[$name], $css); |
|
| 1715 | - |
|
| 1716 | - } |
|
| 1717 | - } |
|
| 1718 | - |
|
| 1719 | - // get he list of the keys |
|
| 1720 | - $this->cssKeys = array_flip(array_keys($this->css)); |
|
| 1721 | - } |
|
| 1722 | - |
|
| 1723 | - /** |
|
| 1724 | - * Extract the css files from a html code |
|
| 1725 | - * |
|
| 1726 | - * @access public |
|
| 1727 | - * @param string &$html |
|
| 1728 | - */ |
|
| 1729 | - public function readStyle(&$html) |
|
| 1730 | - { |
|
| 1731 | - // the CSS content |
|
| 1732 | - $style = ' '; |
|
| 1733 | - |
|
| 1734 | - // extract the link tags, and remove them in the html code |
|
| 1735 | - preg_match_all('/<link([^>]*)>/isU', $html, $match); |
|
| 1736 | - $html = preg_replace('/<link[^>]*>/isU', '', $html); |
|
| 1737 | - $html = preg_replace('/<\/link[^>]*>/isU', '', $html); |
|
| 1738 | - |
|
| 1739 | - // analyse each link tag |
|
| 1740 | - foreach ($match[1] as $code) { |
|
| 1741 | - $tmp = array(); |
|
| 1742 | - |
|
| 1743 | - // read the attributes name=value |
|
| 1744 | - $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)'; |
|
| 1745 | - preg_match_all('/'.$prop.'/is', $code, $match); |
|
| 1746 | - for ($k=0; $k<count($match[0]); $k++) { |
|
| 1747 | - $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 1748 | - } |
|
| 1749 | - |
|
| 1750 | - // read the attributes name="value" |
|
| 1751 | - $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]'; |
|
| 1752 | - preg_match_all('/'.$prop.'/is', $code, $match); |
|
| 1753 | - for ($k=0; $k<count($match[0]); $k++) { |
|
| 1754 | - $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 1755 | - } |
|
| 1756 | - |
|
| 1757 | - // read the attributes name='value' |
|
| 1758 | - $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']"; |
|
| 1759 | - preg_match_all('/'.$prop.'/is', $code, $match); |
|
| 1760 | - for ($k=0; $k<count($match[0]); $k++) { |
|
| 1761 | - $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 1762 | - } |
|
| 1763 | - |
|
| 1764 | - // if type text/css => we keep it |
|
| 1765 | - if (isset($tmp['type']) && strtolower($tmp['type'])=='text/css' && isset($tmp['href'])) { |
|
| 1766 | - |
|
| 1767 | - // get the href |
|
| 1768 | - $url = $tmp['href']; |
|
| 1769 | - |
|
| 1770 | - // get the content of the css file |
|
| 1771 | - $content = @file_get_contents($url); |
|
| 1772 | - |
|
| 1773 | - // if "http://" in the url |
|
| 1774 | - if (strpos($url, 'http://')!==false) { |
|
| 1775 | - |
|
| 1776 | - // get the domain "http://xxx/" |
|
| 1777 | - $url = str_replace('http://', '', $url); |
|
| 1778 | - $url = explode('/', $url); |
|
| 1779 | - $urlMain = 'http://'.$url[0].'/'; |
|
| 1780 | - |
|
| 1781 | - // get the absolute url of the path |
|
| 1782 | - $urlSelf = $url; unset($urlSelf[count($urlSelf)-1]); $urlSelf = 'http://'.implode('/', $urlSelf).'/'; |
|
| 1783 | - |
|
| 1784 | - // adapt the url in the css content |
|
| 1785 | - $content = preg_replace('/url\(([^\\\\][^)]*)\)/isU', 'url('.$urlSelf.'$1)', $content); |
|
| 1786 | - $content = preg_replace('/url\((\\\\[^)]*)\)/isU', 'url('.$urlMain.'$1)', $content); |
|
| 1787 | - } else { |
|
| 14 | + /** |
|
| 15 | + * reference to the pdf object |
|
| 16 | + * @var TCPDF |
|
| 17 | + */ |
|
| 18 | + protected $_pdf = null; |
|
| 19 | + |
|
| 20 | + protected $_htmlColor = array(); // list of the HTML colors |
|
| 21 | + protected $_onlyLeft = false; // flag if we are in a sub html => only "text-align:left" is used |
|
| 22 | + protected $_defaultFont = null; // default font to use if the asked font does not exist |
|
| 23 | + |
|
| 24 | + public $value = array(); // current values |
|
| 25 | + public $css = array(); // css values |
|
| 26 | + public $cssKeys = array(); // css key, for the execution order |
|
| 27 | + public $table = array(); // level history |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Constructor |
|
| 31 | + * |
|
| 32 | + * @param &HTML2PDF_myPdf reference to the PDF $object |
|
| 33 | + * @access public |
|
| 34 | + */ |
|
| 35 | + public function __construct(&$pdf) |
|
| 36 | + { |
|
| 37 | + $this->_init(); |
|
| 38 | + $this->setPdfParent($pdf); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Set the HTML2PDF parent object |
|
| 43 | + * |
|
| 44 | + * @param &HTML2PDF reference to the HTML2PDF parent $object |
|
| 45 | + * @access public |
|
| 46 | + */ |
|
| 47 | + public function setPdfParent(&$pdf) |
|
| 48 | + { |
|
| 49 | + $this->_pdf = &$pdf; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Inform that we want only "test-align:left" because we are in a sub HTML |
|
| 54 | + * |
|
| 55 | + * @access public |
|
| 56 | + */ |
|
| 57 | + public function setOnlyLeft() |
|
| 58 | + { |
|
| 59 | + $this->value['text-align'] = 'left'; |
|
| 60 | + $this->_onlyLeft = true; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Get the vales of the parent, if exist |
|
| 65 | + * |
|
| 66 | + * @return array CSS values |
|
| 67 | + * @access public |
|
| 68 | + */ |
|
| 69 | + public function getOldValues() |
|
| 70 | + { |
|
| 71 | + return isset($this->table[count($this->table)-1]) ? $this->table[count($this->table)-1] : $this->value; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * define the Default Font to use, if the font does not exist, or if no font asked |
|
| 76 | + * |
|
| 77 | + * @param string default font-family. If null : Arial for no font asked, and error fot ont does not exist |
|
| 78 | + * @return string old default font-family |
|
| 79 | + * @access public |
|
| 80 | + */ |
|
| 81 | + public function setDefaultFont($default = null) |
|
| 82 | + { |
|
| 83 | + $old = $this->_defaultFont; |
|
| 84 | + $this->_defaultFont = $default; |
|
| 85 | + if ($default) $this->value['font-family'] = $default; |
|
| 86 | + return $old; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Init the object |
|
| 91 | + * |
|
| 92 | + * @access protected |
|
| 93 | + */ |
|
| 94 | + protected function _init() |
|
| 95 | + { |
|
| 96 | + // get the Web Colors from TCPDF |
|
| 97 | + require(K_PATH_MAIN.'htmlcolors.php'); |
|
| 98 | + $this->_htmlColor = $webcolor; |
|
| 99 | + |
|
| 100 | + // init the Style |
|
| 101 | + $this->table = array(); |
|
| 102 | + $this->value = array(); |
|
| 103 | + $this->initStyle(); |
|
| 104 | + |
|
| 105 | + // Init the styles without legacy |
|
| 106 | + $this->resetStyle(); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Init the CSS Style |
|
| 111 | + * |
|
| 112 | + * @access public |
|
| 113 | + */ |
|
| 114 | + public function initStyle() |
|
| 115 | + { |
|
| 116 | + $this->value['id_tag'] = 'body'; // tag name |
|
| 117 | + $this->value['id_name'] = null; // tag - attribute name |
|
| 118 | + $this->value['id_id'] = null; // tag - attribute id |
|
| 119 | + $this->value['id_class'] = null; // tag - attribute class |
|
| 120 | + $this->value['id_lst'] = array('*'); // tag - list of legacy |
|
| 121 | + $this->value['mini-size'] = 1.; // specific size report for sup, sub |
|
| 122 | + $this->value['mini-decal'] = 0; // specific position report for sup, sub |
|
| 123 | + $this->value['font-family'] = 'Arial'; |
|
| 124 | + $this->value['font-bold'] = false; |
|
| 125 | + $this->value['font-italic'] = false; |
|
| 126 | + $this->value['font-underline'] = false; |
|
| 127 | + $this->value['font-overline'] = false; |
|
| 128 | + $this->value['font-linethrough'] = false; |
|
| 129 | + $this->value['text-transform'] = 'none'; |
|
| 130 | + $this->value['font-size'] = $this->convertToMM('10pt'); |
|
| 131 | + $this->value['text-indent'] = 0; |
|
| 132 | + $this->value['text-align'] = 'left'; |
|
| 133 | + $this->value['vertical-align'] = 'middle'; |
|
| 134 | + $this->value['line-height'] = 'normal'; |
|
| 135 | + |
|
| 136 | + $this->value['position'] = null; |
|
| 137 | + $this->value['x'] = null; |
|
| 138 | + $this->value['y'] = null; |
|
| 139 | + $this->value['width'] = 0; |
|
| 140 | + $this->value['height'] = 0; |
|
| 141 | + $this->value['top'] = null; |
|
| 142 | + $this->value['right'] = null; |
|
| 143 | + $this->value['bottom'] = null; |
|
| 144 | + $this->value['left'] = null; |
|
| 145 | + $this->value['float'] = null; |
|
| 146 | + $this->value['display'] = null; |
|
| 147 | + $this->value['rotate'] = null; |
|
| 148 | + $this->value['overflow'] = 'visible'; |
|
| 149 | + |
|
| 150 | + $this->value['color'] = array(0, 0, 0); |
|
| 151 | + $this->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null); |
|
| 152 | + $this->value['border'] = array(); |
|
| 153 | + $this->value['padding'] = array(); |
|
| 154 | + $this->value['margin'] = array(); |
|
| 155 | + $this->value['margin-auto'] = false; |
|
| 156 | + |
|
| 157 | + $this->value['list-style-type'] = ''; |
|
| 158 | + $this->value['list-style-image'] = ''; |
|
| 159 | + |
|
| 160 | + $this->value['xc'] = null; |
|
| 161 | + $this->value['yc'] = null; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Init the CSS Style without legacy |
|
| 166 | + * |
|
| 167 | + * @param string tag name |
|
| 168 | + * @access public |
|
| 169 | + */ |
|
| 170 | + public function resetStyle($tagName = '') |
|
| 171 | + { |
|
| 172 | + // prepare somme values |
|
| 173 | + $border = $this->readBorder('solid 1px #000000'); |
|
| 174 | + $units = array( |
|
| 175 | + '1px' => $this->convertToMM('1px'), |
|
| 176 | + '5px' => $this->convertToMM('5px'), |
|
| 177 | + ); |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + // prepare the Collapse attribute |
|
| 181 | + $collapse = isset($this->value['border']['collapse']) ? $this->value['border']['collapse'] : false; |
|
| 182 | + if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) $collapse = false; |
|
| 183 | + |
|
| 184 | + // set the global css values |
|
| 185 | + $this->value['position'] = null; |
|
| 186 | + $this->value['x'] = null; |
|
| 187 | + $this->value['y'] = null; |
|
| 188 | + $this->value['width'] = 0; |
|
| 189 | + $this->value['height'] = 0; |
|
| 190 | + $this->value['top'] = null; |
|
| 191 | + $this->value['right'] = null; |
|
| 192 | + $this->value['bottom'] = null; |
|
| 193 | + $this->value['left'] = null; |
|
| 194 | + $this->value['float'] = null; |
|
| 195 | + $this->value['display'] = null; |
|
| 196 | + $this->value['rotate'] = null; |
|
| 197 | + $this->value['overflow'] = 'visible'; |
|
| 198 | + $this->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null); |
|
| 199 | + $this->value['border'] = array( |
|
| 200 | + 't' => $this->readBorder('none'), |
|
| 201 | + 'r' => $this->readBorder('none'), |
|
| 202 | + 'b' => $this->readBorder('none'), |
|
| 203 | + 'l' => $this->readBorder('none'), |
|
| 204 | + 'radius' => array( |
|
| 205 | + 'tl' => array(0, 0), |
|
| 206 | + 'tr' => array(0, 0), |
|
| 207 | + 'br' => array(0, 0), |
|
| 208 | + 'bl' => array(0, 0) |
|
| 209 | + ), |
|
| 210 | + 'collapse' => $collapse, |
|
| 211 | + ); |
|
| 212 | + |
|
| 213 | + // specific values for some tags |
|
| 214 | + if (!in_array($tagName, array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) { |
|
| 215 | + $this->value['margin'] = array('t'=>0,'r'=>0,'b'=>0,'l'=>0); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + if (in_array($tagName, array('input', 'select', 'textarea'))) { |
|
| 219 | + $this->value['border']['t'] = null; |
|
| 220 | + $this->value['border']['r'] = null; |
|
| 221 | + $this->value['border']['b'] = null; |
|
| 222 | + $this->value['border']['l'] = null; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + if ($tagName=='p') { |
|
| 226 | + $this->value['margin']['t'] = null; |
|
| 227 | + $this->value['margin']['b'] = null; |
|
| 228 | + } |
|
| 229 | + if ($tagName=='blockquote') { |
|
| 230 | + $this->value['margin']['t'] = 3; |
|
| 231 | + $this->value['margin']['r'] = 3; |
|
| 232 | + $this->value['margin']['b'] = 3; |
|
| 233 | + $this->value['margin']['l'] = 6; |
|
| 234 | + } |
|
| 235 | + $this->value['margin-auto'] = false; |
|
| 236 | + |
|
| 237 | + if (in_array($tagName, array('blockquote', 'div', 'fieldset'))) { |
|
| 238 | + $this->value['vertical-align'] = 'top'; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + if (in_array($tagName, array('fieldset', 'legend'))) { |
|
| 242 | + $this->value['border'] = array( |
|
| 243 | + 't' => $border, |
|
| 244 | + 'r' => $border, |
|
| 245 | + 'b' => $border, |
|
| 246 | + 'l' => $border, |
|
| 247 | + 'radius' => array( |
|
| 248 | + 'tl' => array($units['5px'], $units['5px']), |
|
| 249 | + 'tr' => array($units['5px'], $units['5px']), |
|
| 250 | + 'br' => array($units['5px'], $units['5px']), |
|
| 251 | + 'bl' => array($units['5px'], $units['5px']) |
|
| 252 | + ), |
|
| 253 | + 'collapse' => false, |
|
| 254 | + ); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + if (in_array($tagName, array('ul', 'li'))) { |
|
| 258 | + $this->value['list-style-type'] = ''; |
|
| 259 | + $this->value['list-style-image'] = ''; |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + if (!in_array($tagName, array('tr', 'td'))) { |
|
| 263 | + $this->value['padding'] = array( |
|
| 264 | + 't' => 0, |
|
| 265 | + 'r' => 0, |
|
| 266 | + 'b' => 0, |
|
| 267 | + 'l' => 0 |
|
| 268 | + ); |
|
| 269 | + } else { |
|
| 270 | + $this->value['padding'] = array( |
|
| 271 | + 't' => $units['1px'], |
|
| 272 | + 'r' => $units['1px'], |
|
| 273 | + 'b' => $units['1px'], |
|
| 274 | + 'l' => $units['1px'] |
|
| 275 | + ); |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + if ($tagName=='hr') { |
|
| 279 | + $this->value['border'] = array( |
|
| 280 | + 't' => $border, |
|
| 281 | + 'r' => $border, |
|
| 282 | + 'b' => $border, |
|
| 283 | + 'l' => $border, |
|
| 284 | + 'radius' => array( |
|
| 285 | + 'tl' => array(0, 0), |
|
| 286 | + 'tr' => array(0, 0), |
|
| 287 | + 'br' => array(0, 0), |
|
| 288 | + 'bl' => array(0, 0) |
|
| 289 | + ), |
|
| 290 | + 'collapse' => false, |
|
| 291 | + ); |
|
| 292 | + $this->convertBackground('#FFFFFF', $this->value['background']); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + $this->value['xc'] = null; |
|
| 296 | + $this->value['yc'] = null; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + /** |
|
| 300 | + * Init the PDF Font |
|
| 301 | + * |
|
| 302 | + * @access public |
|
| 303 | + */ |
|
| 304 | + public function fontSet() |
|
| 305 | + { |
|
| 306 | + $family = strtolower($this->value['font-family']); |
|
| 307 | + |
|
| 308 | + $b = ($this->value['font-bold'] ? 'B' : ''); |
|
| 309 | + $i = ($this->value['font-italic'] ? 'I' : ''); |
|
| 310 | + $u = ($this->value['font-underline'] ? 'U' : ''); |
|
| 311 | + $d = ($this->value['font-linethrough'] ? 'D' : ''); |
|
| 312 | + $o = ($this->value['font-overline'] ? 'O' : ''); |
|
| 313 | + |
|
| 314 | + // font style |
|
| 315 | + $style = $b.$i; |
|
| 316 | + |
|
| 317 | + if ($this->_defaultFont) { |
|
| 318 | + if($family=='arial') |
|
| 319 | + $family='helvetica'; |
|
| 320 | + elseif($family=='symbol' || $family=='zapfdingbats') |
|
| 321 | + $style=''; |
|
| 322 | + |
|
| 323 | + $fontkey = $family.$style; |
|
| 324 | + if (!$this->_pdf->isLoadedFont($fontkey)) |
|
| 325 | + $family = $this->_defaultFont; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + if($family=='arial') |
|
| 329 | + $family='helvetica'; |
|
| 330 | + elseif($family=='symbol' || $family=='zapfdingbats') |
|
| 331 | + $style=''; |
|
| 332 | + |
|
| 333 | + // complete style |
|
| 334 | + $style.= $u.$d.$o; |
|
| 335 | + |
|
| 336 | + // size : mm => pt |
|
| 337 | + $size = $this->value['font-size']; |
|
| 338 | + $size = 72 * $size / 25.4; |
|
| 339 | + |
|
| 340 | + // apply the font |
|
| 341 | + $this->_pdf->SetFont($family, $style, $this->value['mini-size']*$size); |
|
| 342 | + $this->_pdf->setTextColorArray($this->value['color']); |
|
| 343 | + if ($this->value['background']['color']) |
|
| 344 | + $this->_pdf->setFillColorArray($this->value['background']['color']); |
|
| 345 | + else |
|
| 346 | + $this->_pdf->setFillColor(255); |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + /** |
|
| 350 | + * add a level in the CSS history |
|
| 351 | + * |
|
| 352 | + * @access public |
|
| 353 | + */ |
|
| 354 | + public function save() |
|
| 355 | + { |
|
| 356 | + array_push($this->table, $this->value); |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * remove a level in the CSS history |
|
| 361 | + * |
|
| 362 | + * @access public |
|
| 363 | + */ |
|
| 364 | + public function load() |
|
| 365 | + { |
|
| 366 | + if (count($this->table)) { |
|
| 367 | + $this->value = array_pop($this->table); |
|
| 368 | + } |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * restore the Y positiony (used after a span) |
|
| 373 | + * |
|
| 374 | + * @access public |
|
| 375 | + */ |
|
| 376 | + public function restorePosition() |
|
| 377 | + { |
|
| 378 | + if ($this->value['y']==$this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * set the New position for the current Tag |
|
| 383 | + * |
|
| 384 | + * @access public |
|
| 385 | + */ |
|
| 386 | + public function setPosition() |
|
| 387 | + { |
|
| 388 | + // get the current position |
|
| 389 | + $currentX = $this->_pdf->getX(); |
|
| 390 | + $currentY = $this->_pdf->getY(); |
|
| 391 | + |
|
| 392 | + // save it |
|
| 393 | + $this->value['xc'] = $currentX; |
|
| 394 | + $this->value['yc'] = $currentY; |
|
| 395 | + |
|
| 396 | + if ($this->value['position']=='relative' || $this->value['position']=='absolute') { |
|
| 397 | + if ($this->value['right']!==null) { |
|
| 398 | + $x = $this->getLastWidth(true) - $this->value['right'] - $this->value['width']; |
|
| 399 | + if ($this->value['margin']['r']) $x-= $this->value['margin']['r']; |
|
| 400 | + } else { |
|
| 401 | + $x = $this->value['left']; |
|
| 402 | + if ($this->value['margin']['l']) $x+= $this->value['margin']['l']; |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + if ($this->value['bottom']!==null) { |
|
| 406 | + $y = $this->getLastHeight(true) - $this->value['bottom'] - $this->value['height']; |
|
| 407 | + if ($this->value['margin']['b']) $y-= $this->value['margin']['b']; |
|
| 408 | + } else { |
|
| 409 | + $y = $this->value['top']; |
|
| 410 | + if ($this->value['margin']['t']) $y+= $this->value['margin']['t']; |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + if ($this->value['position']=='relative') { |
|
| 414 | + $this->value['x'] = $currentX + $x; |
|
| 415 | + $this->value['y'] = $currentY + $y; |
|
| 416 | + } else { |
|
| 417 | + $this->value['x'] = $this->_getLastAbsoluteX()+$x; |
|
| 418 | + $this->value['y'] = $this->_getLastAbsoluteY()+$y; |
|
| 419 | + } |
|
| 420 | + } else { |
|
| 421 | + $this->value['x'] = $currentX; |
|
| 422 | + $this->value['y'] = $currentY; |
|
| 423 | + if ($this->value['margin']['l']) $this->value['x']+= $this->value['margin']['l']; |
|
| 424 | + if ($this->value['margin']['t']) $this->value['y']+= $this->value['margin']['t']; |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + // save the new position |
|
| 428 | + $this->_pdf->setXY($this->value['x'], $this->value['y']); |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * Analise the CSS style to convert it into Form style |
|
| 433 | + * |
|
| 434 | + * @access public |
|
| 435 | + * @param array styles |
|
| 436 | + */ |
|
| 437 | + public function getFormStyle() |
|
| 438 | + { |
|
| 439 | + $prop = array(); |
|
| 440 | + |
|
| 441 | + $prop['alignment'] = $this->value['text-align']; |
|
| 442 | + |
|
| 443 | + if (isset($this->value['background']['color']) && is_array($this->value['background']['color'])) { |
|
| 444 | + $prop['fillColor'] = $this->value['background']['color']; |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + if (isset($this->value['border']['t']['color'])) { |
|
| 448 | + $prop['strokeColor'] = $this->value['border']['t']['color']; |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + if (isset($this->value['border']['t']['width'])) { |
|
| 452 | + $prop['lineWidth'] = $this->value['border']['t']['width']; |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + if (isset($this->value['border']['t']['type'])) { |
|
| 456 | + $prop['borderStyle'] = $this->value['border']['t']['type']; |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + if (!empty($this->value['color'])) { |
|
| 460 | + $prop['textColor'] = $this->value['color']; |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + if (!empty($this->value['font-size'])) { |
|
| 464 | + $prop['textSize'] = $this->value['font-size']; |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + return $prop; |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + /** |
|
| 471 | + * Analise the CSS style to convert it into SVG style |
|
| 472 | + * |
|
| 473 | + * @access public |
|
| 474 | + * @param string tag name |
|
| 475 | + * @param array styles |
|
| 476 | + */ |
|
| 477 | + public function getSvgStyle($tagName, &$param) |
|
| 478 | + { |
|
| 479 | + // prepare |
|
| 480 | + $tagName = strtolower($tagName); |
|
| 481 | + $id = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id) $id = null; |
|
| 482 | + $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null; |
|
| 483 | + |
|
| 484 | + // read the class attribute |
|
| 485 | + $class = array(); |
|
| 486 | + $tmp = isset($param['class']) ? strtolower(trim($param['class'])) : ''; |
|
| 487 | + $tmp = explode(' ', $tmp); |
|
| 488 | + foreach ($tmp as $k => $v) { |
|
| 489 | + $v = trim($v); |
|
| 490 | + if ($v) $class[] = $v; |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + // identify the tag, and the direct styles |
|
| 494 | + $this->value['id_tag'] = $tagName; |
|
| 495 | + $this->value['id_name'] = $name; |
|
| 496 | + $this->value['id_id'] = $id; |
|
| 497 | + $this->value['id_class'] = $class; |
|
| 498 | + $this->value['id_lst'] = array(); |
|
| 499 | + $this->value['id_lst'][] = '*'; |
|
| 500 | + $this->value['id_lst'][] = $tagName; |
|
| 501 | + if (!isset($this->value['svg'])) { |
|
| 502 | + $this->value['svg'] = array( |
|
| 503 | + 'stroke' => null, |
|
| 504 | + 'stroke-width' => $this->convertToMM('1pt'), |
|
| 505 | + 'fill' => null, |
|
| 506 | + 'fill-opacity' => null, |
|
| 507 | + ); |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + if (count($class)) { |
|
| 511 | + foreach ($class as $v) { |
|
| 512 | + $this->value['id_lst'][] = '*.'.$v; |
|
| 513 | + $this->value['id_lst'][] = '.'.$v; |
|
| 514 | + $this->value['id_lst'][] = $tagName.'.'.$v; |
|
| 515 | + } |
|
| 516 | + } |
|
| 517 | + if ($id) { |
|
| 518 | + $this->value['id_lst'][] = '*#'.$id; |
|
| 519 | + $this->value['id_lst'][] = '#'.$id; |
|
| 520 | + $this->value['id_lst'][] = $tagName.'#'.$id; |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + // CSS style |
|
| 524 | + $styles = $this->_getFromCSS(); |
|
| 525 | + |
|
| 526 | + // adding the style from the tag |
|
| 527 | + $styles = array_merge($styles, $param['style']); |
|
| 528 | + |
|
| 529 | + if (isset($styles['stroke'])) $this->value['svg']['stroke'] = $this->convertToColor($styles['stroke'], $res); |
|
| 530 | + if (isset($styles['stroke-width'])) $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']); |
|
| 531 | + if (isset($styles['fill'])) $this->value['svg']['fill'] = $this->convertToColor($styles['fill'], $res); |
|
| 532 | + if (isset($styles['fill-opacity'])) $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity']; |
|
| 533 | + |
|
| 534 | + return $this->value['svg']; |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * analyse the css properties from the HTML parsing |
|
| 539 | + * |
|
| 540 | + * @access public |
|
| 541 | + * @param string $tagName |
|
| 542 | + * @param array $param |
|
| 543 | + * @param array $legacy |
|
| 544 | + */ |
|
| 545 | + public function analyse($tagName, &$param, $legacy = null) |
|
| 546 | + { |
|
| 547 | + // prepare the informations |
|
| 548 | + $tagName = strtolower($tagName); |
|
| 549 | + $id = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id) $id = null; |
|
| 550 | + $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null; |
|
| 551 | + |
|
| 552 | + // get the class names to use |
|
| 553 | + $class = array(); |
|
| 554 | + $tmp = isset($param['class']) ? strtolower(trim($param['class'])) : ''; |
|
| 555 | + $tmp = explode(' ', $tmp); |
|
| 556 | + foreach ($tmp as $k => $v) { |
|
| 557 | + $v = trim($v); |
|
| 558 | + if ($v) $class[] = $v; |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + // prepare the values, and the list of css tags to identify |
|
| 562 | + $this->value['id_tag'] = $tagName; |
|
| 563 | + $this->value['id_name'] = $name; |
|
| 564 | + $this->value['id_id'] = $id; |
|
| 565 | + $this->value['id_class'] = $class; |
|
| 566 | + $this->value['id_lst'] = array(); |
|
| 567 | + $this->value['id_lst'][] = '*'; |
|
| 568 | + $this->value['id_lst'][] = $tagName; |
|
| 569 | + if (count($class)) { |
|
| 570 | + foreach ($class as $v) { |
|
| 571 | + $this->value['id_lst'][] = '*.'.$v; |
|
| 572 | + $this->value['id_lst'][] = '.'.$v; |
|
| 573 | + $this->value['id_lst'][] = $tagName.'.'.$v; |
|
| 574 | + } |
|
| 575 | + } |
|
| 576 | + if ($id) { |
|
| 577 | + $this->value['id_lst'][] = '*#'.$id; |
|
| 578 | + $this->value['id_lst'][] = '#'.$id; |
|
| 579 | + $this->value['id_lst'][] = $tagName.'#'.$id; |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + // get the css styles from class |
|
| 583 | + $styles = $this->_getFromCSS(); |
|
| 584 | + |
|
| 585 | + // merge with the css styles from tag |
|
| 586 | + $styles = array_merge($styles, $param['style']); |
|
| 587 | + if (isset($param['allwidth']) && !isset($styles['width'])) $styles['width'] = '100%'; |
|
| 588 | + |
|
| 589 | + // reset some styles, depending on the tag name |
|
| 590 | + $this->resetStyle($tagName); |
|
| 591 | + |
|
| 592 | + // add the legacy values |
|
| 593 | + if ($legacy) { |
|
| 594 | + foreach ($legacy as $legacyName => $legacyValue) { |
|
| 595 | + if (is_array($legacyValue)) { |
|
| 596 | + foreach($legacyValue as $legacy2Name => $legacy2Value) |
|
| 597 | + $this->value[$legacyName][$legacy2Name] = $legacy2Value; |
|
| 598 | + } else { |
|
| 599 | + $this->value[$legacyName] = $legacyValue; |
|
| 600 | + } |
|
| 601 | + } |
|
| 602 | + } |
|
| 603 | + |
|
| 604 | + // some flags |
|
| 605 | + $correctWidth = false; |
|
| 606 | + $noWidth = true; |
|
| 607 | + |
|
| 608 | + // read all the css styles |
|
| 609 | + foreach ($styles as $nom => $val) { |
|
| 610 | + switch($nom) |
|
| 611 | + { |
|
| 612 | + case 'font-family': |
|
| 613 | + $val = explode(',', $val); |
|
| 614 | + $val = trim($val[0]); |
|
| 615 | + if ($val) $this->value['font-family'] = $val; |
|
| 616 | + break; |
|
| 617 | + |
|
| 618 | + case 'font-weight': |
|
| 619 | + $this->value['font-bold'] = ($val=='bold'); |
|
| 620 | + break; |
|
| 621 | + |
|
| 622 | + case 'font-style': |
|
| 623 | + $this->value['font-italic'] = ($val=='italic'); |
|
| 624 | + break; |
|
| 625 | + |
|
| 626 | + case 'text-decoration': |
|
| 627 | + $val = explode(' ', $val); |
|
| 628 | + $this->value['font-underline'] = (in_array('underline', $val)); |
|
| 629 | + $this->value['font-overline'] = (in_array('overline', $val)); |
|
| 630 | + $this->value['font-linethrough'] = (in_array('line-through', $val)); |
|
| 631 | + break; |
|
| 632 | + |
|
| 633 | + case 'text-indent': |
|
| 634 | + $this->value['text-indent'] = $this->convertToMM($val); |
|
| 635 | + break; |
|
| 636 | + |
|
| 637 | + case 'text-transform': |
|
| 638 | + if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none'; |
|
| 639 | + $this->value['text-transform'] = $val; |
|
| 640 | + break; |
|
| 641 | + |
|
| 642 | + case 'font-size': |
|
| 643 | + $val = $this->convertToMM($val, $this->value['font-size']); |
|
| 644 | + if ($val) $this->value['font-size'] = $val; |
|
| 645 | + break; |
|
| 646 | + |
|
| 647 | + case 'color': |
|
| 648 | + $res = null; |
|
| 649 | + $this->value['color'] = $this->convertToColor($val, $res); |
|
| 650 | + if ($tagName=='hr') { |
|
| 651 | + $this->value['border']['l']['color'] = $this->value['color']; |
|
| 652 | + $this->value['border']['t']['color'] = $this->value['color']; |
|
| 653 | + $this->value['border']['r']['color'] = $this->value['color']; |
|
| 654 | + $this->value['border']['b']['color'] = $this->value['color']; |
|
| 655 | + } |
|
| 656 | + break; |
|
| 657 | + |
|
| 658 | + case 'text-align': |
|
| 659 | + $val = strtolower($val); |
|
| 660 | + if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) $val = 'left'; |
|
| 661 | + $this->value['text-align'] = $val; |
|
| 662 | + break; |
|
| 663 | + |
|
| 664 | + case 'vertical-align': |
|
| 665 | + $this->value['vertical-align'] = $val; |
|
| 666 | + break; |
|
| 667 | + |
|
| 668 | + case 'width': |
|
| 669 | + $this->value['width'] = $this->convertToMM($val, $this->getLastWidth()); |
|
| 670 | + if ($this->value['width'] && substr($val, -1)=='%') $correctWidth=true; |
|
| 671 | + $noWidth = false; |
|
| 672 | + break; |
|
| 673 | + |
|
| 674 | + case 'height': |
|
| 675 | + $this->value['height'] = $this->convertToMM($val, $this->getLastHeight()); |
|
| 676 | + break; |
|
| 677 | + |
|
| 678 | + case 'line-height': |
|
| 679 | + if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val*100).'%'; |
|
| 680 | + $this->value['line-height'] = $val; |
|
| 681 | + break; |
|
| 682 | + |
|
| 683 | + case 'rotate': |
|
| 684 | + if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null; |
|
| 685 | + if ($val<0) $val+= 360; |
|
| 686 | + $this->value['rotate'] = $val; |
|
| 687 | + break; |
|
| 688 | + |
|
| 689 | + case 'overflow': |
|
| 690 | + if (!in_array($val, array('visible', 'hidden'))) $val = 'visible'; |
|
| 691 | + $this->value['overflow'] = $val; |
|
| 692 | + break; |
|
| 693 | + |
|
| 694 | + case 'padding': |
|
| 695 | + $val = explode(' ', $val); |
|
| 696 | + foreach ($val as $k => $v) { |
|
| 697 | + $v = trim($v); |
|
| 698 | + if ($v!='') { |
|
| 699 | + $val[$k] = $v; |
|
| 700 | + } else { |
|
| 701 | + unset($val[$k]); |
|
| 702 | + } |
|
| 703 | + } |
|
| 704 | + $val = array_values($val); |
|
| 705 | + $this->_duplicateBorder($val); |
|
| 706 | + $this->value['padding']['t'] = $this->convertToMM($val[0], 0); |
|
| 707 | + $this->value['padding']['r'] = $this->convertToMM($val[1], 0); |
|
| 708 | + $this->value['padding']['b'] = $this->convertToMM($val[2], 0); |
|
| 709 | + $this->value['padding']['l'] = $this->convertToMM($val[3], 0); |
|
| 710 | + break; |
|
| 711 | + |
|
| 712 | + case 'padding-top': |
|
| 713 | + $this->value['padding']['t'] = $this->convertToMM($val, 0); |
|
| 714 | + break; |
|
| 715 | + |
|
| 716 | + case 'padding-right': |
|
| 717 | + $this->value['padding']['r'] = $this->convertToMM($val, 0); |
|
| 718 | + break; |
|
| 719 | + |
|
| 720 | + case 'padding-bottom': |
|
| 721 | + $this->value['padding']['b'] = $this->convertToMM($val, 0); |
|
| 722 | + break; |
|
| 723 | + |
|
| 724 | + case 'padding-left': |
|
| 725 | + $this->value['padding']['l'] = $this->convertToMM($val, 0); |
|
| 726 | + break; |
|
| 727 | + |
|
| 728 | + case 'margin': |
|
| 729 | + if ($val=='auto') { |
|
| 730 | + $this->value['margin-auto'] = true; |
|
| 731 | + break; |
|
| 732 | + } |
|
| 733 | + $val = explode(' ', $val); |
|
| 734 | + foreach ($val as $k => $v) { |
|
| 735 | + $v = trim($v); |
|
| 736 | + if ($v!='') { |
|
| 737 | + $val[$k] = $v; |
|
| 738 | + } else { |
|
| 739 | + unset($val[$k]); |
|
| 740 | + } |
|
| 741 | + } |
|
| 742 | + $val = array_values($val); |
|
| 743 | + $this->_duplicateBorder($val); |
|
| 744 | + $this->value['margin']['t'] = $this->convertToMM($val[0], 0); |
|
| 745 | + $this->value['margin']['r'] = $this->convertToMM($val[1], 0); |
|
| 746 | + $this->value['margin']['b'] = $this->convertToMM($val[2], 0); |
|
| 747 | + $this->value['margin']['l'] = $this->convertToMM($val[3], 0); |
|
| 748 | + break; |
|
| 749 | + |
|
| 750 | + case 'margin-top': |
|
| 751 | + $this->value['margin']['t'] = $this->convertToMM($val, 0); |
|
| 752 | + break; |
|
| 753 | + |
|
| 754 | + case 'margin-right': |
|
| 755 | + $this->value['margin']['r'] = $this->convertToMM($val, 0); |
|
| 756 | + break; |
|
| 757 | + |
|
| 758 | + case 'margin-bottom': |
|
| 759 | + $this->value['margin']['b'] = $this->convertToMM($val, 0); |
|
| 760 | + break; |
|
| 761 | + |
|
| 762 | + case 'margin-left': |
|
| 763 | + $this->value['margin']['l'] = $this->convertToMM($val, 0); |
|
| 764 | + break; |
|
| 765 | + |
|
| 766 | + case 'border': |
|
| 767 | + $val = $this->readBorder($val); |
|
| 768 | + $this->value['border']['t'] = $val; |
|
| 769 | + $this->value['border']['r'] = $val; |
|
| 770 | + $this->value['border']['b'] = $val; |
|
| 771 | + $this->value['border']['l'] = $val; |
|
| 772 | + break; |
|
| 773 | + |
|
| 774 | + case 'border-style': |
|
| 775 | + $val = explode(' ', $val); |
|
| 776 | + foreach ($val as $valK => $valV) { |
|
| 777 | + if (!in_array($valV, array('solid', 'dotted', 'dashed'))) { |
|
| 778 | + $val[$valK] = null; |
|
| 779 | + } |
|
| 780 | + } |
|
| 781 | + $this->_duplicateBorder($val); |
|
| 782 | + if ($val[0]) $this->value['border']['t']['type'] = $val[0]; |
|
| 783 | + if ($val[1]) $this->value['border']['r']['type'] = $val[1]; |
|
| 784 | + if ($val[2]) $this->value['border']['b']['type'] = $val[2]; |
|
| 785 | + if ($val[3]) $this->value['border']['l']['type'] = $val[3]; |
|
| 786 | + break; |
|
| 787 | + |
|
| 788 | + case 'border-top-style': |
|
| 789 | + if (in_array($val, array('solid', 'dotted', 'dashed'))) { |
|
| 790 | + $this->value['border']['t']['type'] = $val; |
|
| 791 | + } |
|
| 792 | + break; |
|
| 793 | + |
|
| 794 | + case 'border-right-style': |
|
| 795 | + if (in_array($val, array('solid', 'dotted', 'dashed'))) { |
|
| 796 | + $this->value['border']['r']['type'] = $val; |
|
| 797 | + } |
|
| 798 | + break; |
|
| 799 | + |
|
| 800 | + case 'border-bottom-style': |
|
| 801 | + if (in_array($val, array('solid', 'dotted', 'dashed'))) { |
|
| 802 | + $this->value['border']['b']['type'] = $val; |
|
| 803 | + } |
|
| 804 | + break; |
|
| 805 | + |
|
| 806 | + case 'border-left-style': |
|
| 807 | + if (in_array($val, array('solid', 'dotted', 'dashed'))) |
|
| 808 | + $this->value['border']['l']['type'] = $val; |
|
| 809 | + break; |
|
| 810 | + |
|
| 811 | + case 'border-color': |
|
| 812 | + $res = false; |
|
| 813 | + $val = preg_replace('/,[\s]+/', ',', $val); |
|
| 814 | + $val = explode(' ', $val); |
|
| 815 | + foreach ($val as $valK => $valV) { |
|
| 816 | + $val[$valK] = $this->convertToColor($valV, $res); |
|
| 817 | + if (!$res) { |
|
| 818 | + $val[$valK] = null; |
|
| 819 | + } |
|
| 820 | + } |
|
| 821 | + $this->_duplicateBorder($val); |
|
| 822 | + if (is_array($val[0])) $this->value['border']['t']['color'] = $val[0]; |
|
| 823 | + if (is_array($val[1])) $this->value['border']['r']['color'] = $val[1]; |
|
| 824 | + if (is_array($val[2])) $this->value['border']['b']['color'] = $val[2]; |
|
| 825 | + if (is_array($val[3])) $this->value['border']['l']['color'] = $val[3]; |
|
| 826 | + |
|
| 827 | + break; |
|
| 828 | + |
|
| 829 | + case 'border-top-color': |
|
| 830 | + $res = false; |
|
| 831 | + $val = $this->convertToColor($val, $res); |
|
| 832 | + if ($res) $this->value['border']['t']['color'] = $val; |
|
| 833 | + break; |
|
| 834 | + |
|
| 835 | + case 'border-right-color': |
|
| 836 | + $res = false; |
|
| 837 | + $val = $this->convertToColor($val, $res); |
|
| 838 | + if ($res) $this->value['border']['r']['color'] = $val; |
|
| 839 | + break; |
|
| 840 | + |
|
| 841 | + case 'border-bottom-color': |
|
| 842 | + $res = false; |
|
| 843 | + $val = $this->convertToColor($val, $res); |
|
| 844 | + if ($res) $this->value['border']['b']['color'] = $val; |
|
| 845 | + break; |
|
| 846 | + |
|
| 847 | + case 'border-left-color': |
|
| 848 | + $res = false; |
|
| 849 | + $val = $this->convertToColor($val, $res); |
|
| 850 | + if ($res) $this->value['border']['l']['color'] = $val; |
|
| 851 | + break; |
|
| 852 | + |
|
| 853 | + case 'border-width': |
|
| 854 | + $val = explode(' ', $val); |
|
| 855 | + foreach ($val as $valK => $valV) { |
|
| 856 | + $val[$valK] = $this->convertToMM($valV, 0); |
|
| 857 | + } |
|
| 858 | + $this->_duplicateBorder($val); |
|
| 859 | + if ($val[0]) $this->value['border']['t']['width'] = $val[0]; |
|
| 860 | + if ($val[1]) $this->value['border']['r']['width'] = $val[1]; |
|
| 861 | + if ($val[2]) $this->value['border']['b']['width'] = $val[2]; |
|
| 862 | + if ($val[3]) $this->value['border']['l']['width'] = $val[3]; |
|
| 863 | + break; |
|
| 864 | + |
|
| 865 | + case 'border-top-width': |
|
| 866 | + $val = $this->convertToMM($val, 0); |
|
| 867 | + if ($val) $this->value['border']['t']['width'] = $val; |
|
| 868 | + break; |
|
| 869 | + |
|
| 870 | + case 'border-right-width': |
|
| 871 | + $val = $this->convertToMM($val, 0); |
|
| 872 | + if ($val) $this->value['border']['r']['width'] = $val; |
|
| 873 | + break; |
|
| 874 | + |
|
| 875 | + case 'border-bottom-width': |
|
| 876 | + $val = $this->convertToMM($val, 0); |
|
| 877 | + if ($val) $this->value['border']['b']['width'] = $val; |
|
| 878 | + break; |
|
| 879 | + |
|
| 880 | + case 'border-left-width': |
|
| 881 | + $val = $this->convertToMM($val, 0); |
|
| 882 | + if ($val) $this->value['border']['l']['width'] = $val; |
|
| 883 | + break; |
|
| 884 | + |
|
| 885 | + case 'border-collapse': |
|
| 886 | + if ($tagName=='table') $this->value['border']['collapse'] = ($val=='collapse'); |
|
| 887 | + break; |
|
| 888 | + |
|
| 889 | + case 'border-radius': |
|
| 890 | + $val = explode('/', $val); |
|
| 891 | + if (count($val)>2) { |
|
| 892 | + break; |
|
| 893 | + } |
|
| 894 | + $valH = $this->convertToRadius(trim($val[0])); |
|
| 895 | + if (count($valH)<1 || count($valH)>4) { |
|
| 896 | + break; |
|
| 897 | + } |
|
| 898 | + if (!isset($valH[1])) $valH[1] = $valH[0]; |
|
| 899 | + if (!isset($valH[2])) $valH = array($valH[0], $valH[0], $valH[1], $valH[1]); |
|
| 900 | + if (!isset($valH[3])) $valH[3] = $valH[1]; |
|
| 901 | + if (isset($val[1])) { |
|
| 902 | + $valV = $this->convertToRadius(trim($val[1])); |
|
| 903 | + if (count($valV)<1 || count($valV)>4) { |
|
| 904 | + break; |
|
| 905 | + } |
|
| 906 | + if (!isset($valV[1])) $valV[1] = $valV[0]; |
|
| 907 | + if (!isset($valV[2])) $valV = array($valV[0], $valV[0], $valV[1], $valV[1]); |
|
| 908 | + if (!isset($valV[3])) $valV[3] = $valV[1]; |
|
| 909 | + } else { |
|
| 910 | + $valV = $valH; |
|
| 911 | + } |
|
| 912 | + $this->value['border']['radius'] = array( |
|
| 913 | + 'tl' => array($valH[0], $valV[0]), |
|
| 914 | + 'tr' => array($valH[1], $valV[1]), |
|
| 915 | + 'br' => array($valH[2], $valV[2]), |
|
| 916 | + 'bl' => array($valH[3], $valV[3]) |
|
| 917 | + ); |
|
| 918 | + break; |
|
| 919 | + |
|
| 920 | + case 'border-top-left-radius': |
|
| 921 | + $val = $this->convertToRadius($val); |
|
| 922 | + if (count($val)<1 || count($val)>2) { |
|
| 923 | + break; |
|
| 924 | + } |
|
| 925 | + $this->value['border']['radius']['tl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]); |
|
| 926 | + break; |
|
| 927 | + |
|
| 928 | + case 'border-top-right-radius': |
|
| 929 | + $val = $this->convertToRadius($val); |
|
| 930 | + if (count($val)<1 || count($val)>2) { |
|
| 931 | + break; |
|
| 932 | + } |
|
| 933 | + $this->value['border']['radius']['tr'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]); |
|
| 934 | + break; |
|
| 935 | + |
|
| 936 | + case 'border-bottom-right-radius': |
|
| 937 | + $val = $this->convertToRadius($val); |
|
| 938 | + if (count($val)<1 || count($val)>2) { |
|
| 939 | + break; |
|
| 940 | + } |
|
| 941 | + $this->value['border']['radius']['br'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]); |
|
| 942 | + break; |
|
| 943 | + |
|
| 944 | + case 'border-bottom-left-radius': |
|
| 945 | + $val = $this->convertToRadius($val); |
|
| 946 | + if (count($val)<1 || count($val)>2) { |
|
| 947 | + break; |
|
| 948 | + } |
|
| 949 | + $this->value['border']['radius']['bl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]); |
|
| 950 | + break; |
|
| 951 | + |
|
| 952 | + case 'border-top': |
|
| 953 | + $this->value['border']['t'] = $this->readBorder($val); |
|
| 954 | + break; |
|
| 955 | + |
|
| 956 | + case 'border-right': |
|
| 957 | + $this->value['border']['r'] = $this->readBorder($val); |
|
| 958 | + break; |
|
| 959 | + |
|
| 960 | + case 'border-bottom': |
|
| 961 | + $this->value['border']['b'] = $this->readBorder($val); |
|
| 962 | + break; |
|
| 963 | + |
|
| 964 | + case 'border-left': |
|
| 965 | + $this->value['border']['l'] = $this->readBorder($val); |
|
| 966 | + break; |
|
| 967 | + |
|
| 968 | + case 'background-color': |
|
| 969 | + $this->value['background']['color'] = $this->convertBackgroundColor($val); |
|
| 970 | + break; |
|
| 971 | + |
|
| 972 | + case 'background-image': |
|
| 973 | + $this->value['background']['image'] = $this->convertBackgroundImage($val); |
|
| 974 | + break; |
|
| 975 | + |
|
| 976 | + case 'background-position': |
|
| 977 | + $res = null; |
|
| 978 | + $this->value['background']['position'] = $this->convertBackgroundPosition($val, $res); |
|
| 979 | + break; |
|
| 980 | + |
|
| 981 | + case 'background-repeat': |
|
| 982 | + $this->value['background']['repeat'] = $this->convertBackgroundRepeat($val); |
|
| 983 | + break; |
|
| 984 | + |
|
| 985 | + case 'background': |
|
| 986 | + $this->convertBackground($val, $this->value['background']); |
|
| 987 | + break; |
|
| 988 | + |
|
| 989 | + case 'position': |
|
| 990 | + if ($val=='absolute') $this->value['position'] = 'absolute'; |
|
| 991 | + else if ($val=='relative') $this->value['position'] = 'relative'; |
|
| 992 | + else $this->value['position'] = null; |
|
| 993 | + break; |
|
| 994 | + |
|
| 995 | + case 'float': |
|
| 996 | + if ($val=='left') $this->value['float'] = 'left'; |
|
| 997 | + else if ($val=='right') $this->value['float'] = 'right'; |
|
| 998 | + else $this->value['float'] = null; |
|
| 999 | + break; |
|
| 1000 | + |
|
| 1001 | + case 'display': |
|
| 1002 | + if ($val=='inline') $this->value['display'] = 'inline'; |
|
| 1003 | + else if ($val=='block') $this->value['display'] = 'block'; |
|
| 1004 | + else if ($val=='none') $this->value['display'] = 'none'; |
|
| 1005 | + else $this->value['display'] = null; |
|
| 1006 | + break; |
|
| 1007 | + |
|
| 1008 | + case 'top': |
|
| 1009 | + case 'bottom': |
|
| 1010 | + case 'left': |
|
| 1011 | + case 'right': |
|
| 1012 | + $this->value[$nom] = $val; |
|
| 1013 | + break; |
|
| 1014 | + |
|
| 1015 | + case 'list-style': |
|
| 1016 | + case 'list-style-type': |
|
| 1017 | + case 'list-style-image': |
|
| 1018 | + if ($nom=='list-style') $nom = 'list-style-type'; |
|
| 1019 | + $this->value[$nom] = $val; |
|
| 1020 | + break; |
|
| 1021 | + |
|
| 1022 | + default: |
|
| 1023 | + break; |
|
| 1024 | + } |
|
| 1025 | + } |
|
| 1026 | + |
|
| 1027 | + $return = true; |
|
| 1028 | + |
|
| 1029 | + // only for P tag |
|
| 1030 | + if ($this->value['margin']['t']===null) $this->value['margin']['t'] = $this->value['font-size']; |
|
| 1031 | + if ($this->value['margin']['b']===null) $this->value['margin']['b'] = $this->value['font-size']; |
|
| 1032 | + |
|
| 1033 | + // force the text align to left, if asked by html2pdf |
|
| 1034 | + if ($this->_onlyLeft) $this->value['text-align'] = 'left'; |
|
| 1035 | + |
|
| 1036 | + // correction on the width (quick box) |
|
| 1037 | + if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position']!='absolute') { |
|
| 1038 | + $this->value['width'] = $this->getLastWidth(); |
|
| 1039 | + $this->value['width']-= $this->value['margin']['l'] + $this->value['margin']['r']; |
|
| 1040 | + } else { |
|
| 1041 | + if ($correctWidth) { |
|
| 1042 | + if (!in_array($tagName, array('table', 'div', 'blockquote', 'fieldset', 'hr'))) { |
|
| 1043 | + $this->value['width']-= $this->value['padding']['l'] + $this->value['padding']['r']; |
|
| 1044 | + $this->value['width']-= $this->value['border']['l']['width'] + $this->value['border']['r']['width']; |
|
| 1045 | + } |
|
| 1046 | + if (in_array($tagName, array('th', 'td'))) { |
|
| 1047 | + $this->value['width']-= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px'); |
|
| 1048 | + $return = false; |
|
| 1049 | + } |
|
| 1050 | + if ($this->value['width']<0) $this->value['width']=0; |
|
| 1051 | + } else { |
|
| 1052 | + if ($this->value['width']) { |
|
| 1053 | + if ($this->value['border']['l']['width']) $this->value['width'] += $this->value['border']['l']['width']; |
|
| 1054 | + if ($this->value['border']['r']['width']) $this->value['width'] += $this->value['border']['r']['width']; |
|
| 1055 | + if ($this->value['padding']['l']) $this->value['width'] += $this->value['padding']['l']; |
|
| 1056 | + if ($this->value['padding']['r']) $this->value['width'] += $this->value['padding']['r']; |
|
| 1057 | + } |
|
| 1058 | + } |
|
| 1059 | + } |
|
| 1060 | + if ($this->value['height']) { |
|
| 1061 | + if ($this->value['border']['b']['width']) $this->value['height'] += $this->value['border']['b']['width']; |
|
| 1062 | + if ($this->value['border']['t']['width']) $this->value['height'] += $this->value['border']['t']['width']; |
|
| 1063 | + if ($this->value['padding']['b']) $this->value['height'] += $this->value['padding']['b']; |
|
| 1064 | + if ($this->value['padding']['t']) $this->value['height'] += $this->value['padding']['t']; |
|
| 1065 | + } |
|
| 1066 | + |
|
| 1067 | + if ($this->value['top']!=null) $this->value['top'] = $this->convertToMM($this->value['top'], $this->getLastHeight(true)); |
|
| 1068 | + if ($this->value['bottom']!=null) $this->value['bottom'] = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true)); |
|
| 1069 | + if ($this->value['left']!=null) $this->value['left'] = $this->convertToMM($this->value['left'], $this->getLastWidth(true)); |
|
| 1070 | + if ($this->value['right']!=null) $this->value['right'] = $this->convertToMM($this->value['right'], $this->getLastWidth(true)); |
|
| 1071 | + |
|
| 1072 | + if ($this->value['top'] && $this->value['bottom'] && $this->value['height']) $this->value['bottom'] = null; |
|
| 1073 | + if ($this->value['left'] && $this->value['right'] && $this->value['width']) $this->value['right'] = null; |
|
| 1074 | + |
|
| 1075 | + return $return; |
|
| 1076 | + } |
|
| 1077 | + |
|
| 1078 | + /** |
|
| 1079 | + * get the height of the current line |
|
| 1080 | + * |
|
| 1081 | + * @access public |
|
| 1082 | + * @return float $height in mm |
|
| 1083 | + */ |
|
| 1084 | + public function getLineHeight() |
|
| 1085 | + { |
|
| 1086 | + $val = $this->value['line-height']; |
|
| 1087 | + if ($val=='normal') $val = '108%'; |
|
| 1088 | + return $this->convertToMM($val, $this->value['font-size']); |
|
| 1089 | + } |
|
| 1090 | + |
|
| 1091 | + /** |
|
| 1092 | + * get the width of the parent |
|
| 1093 | + * |
|
| 1094 | + * @access public |
|
| 1095 | + * @param boolean $mode true => adding padding and border |
|
| 1096 | + * @return float $width in mm |
|
| 1097 | + */ |
|
| 1098 | + public function getLastWidth($mode = false) |
|
| 1099 | + { |
|
| 1100 | + for ($k=count($this->table)-1; $k>=0; $k--) { |
|
| 1101 | + if ($this->table[$k]['width']) { |
|
| 1102 | + $w = $this->table[$k]['width']; |
|
| 1103 | + if ($mode) { |
|
| 1104 | + $w+= $this->table[$k]['border']['l']['width'] + $this->table[$k]['padding']['l'] + 0.02; |
|
| 1105 | + $w+= $this->table[$k]['border']['r']['width'] + $this->table[$k]['padding']['r'] + 0.02; |
|
| 1106 | + } |
|
| 1107 | + return $w; |
|
| 1108 | + } |
|
| 1109 | + } |
|
| 1110 | + return $this->_pdf->getW() - $this->_pdf->getlMargin() - $this->_pdf->getrMargin(); |
|
| 1111 | + } |
|
| 1112 | + |
|
| 1113 | + /** |
|
| 1114 | + * get the height of the parent |
|
| 1115 | + * |
|
| 1116 | + * @access public |
|
| 1117 | + * @param boolean $mode true => adding padding and border |
|
| 1118 | + * @return float $height in mm |
|
| 1119 | + */ |
|
| 1120 | + public function getLastHeight($mode = false) |
|
| 1121 | + { |
|
| 1122 | + for ($k=count($this->table)-1; $k>=0; $k--) { |
|
| 1123 | + if ($this->table[$k]['height']) { |
|
| 1124 | + $h = $this->table[$k]['height']; |
|
| 1125 | + if ($mode) { |
|
| 1126 | + $h+= $this->table[$k]['border']['t']['width'] + $this->table[$k]['padding']['t'] + 0.02; |
|
| 1127 | + $h+= $this->table[$k]['border']['b']['width'] + $this->table[$k]['padding']['b'] + 0.02; |
|
| 1128 | + } |
|
| 1129 | + return $h; |
|
| 1130 | + } |
|
| 1131 | + } |
|
| 1132 | + return $this->_pdf->getH() - $this->_pdf->gettMargin() - $this->_pdf->getbMargin(); |
|
| 1133 | + } |
|
| 1134 | + |
|
| 1135 | + /** |
|
| 1136 | + * get the value of the float property |
|
| 1137 | + * |
|
| 1138 | + * @access public |
|
| 1139 | + * @return $float left/right |
|
| 1140 | + */ |
|
| 1141 | + public function getFloat() |
|
| 1142 | + { |
|
| 1143 | + if ($this->value['float']=='left') return 'left'; |
|
| 1144 | + if ($this->value['float']=='right') return 'right'; |
|
| 1145 | + return null; |
|
| 1146 | + } |
|
| 1147 | + |
|
| 1148 | + /** |
|
| 1149 | + * get the last value for a specific key |
|
| 1150 | + * |
|
| 1151 | + * @access public |
|
| 1152 | + * @param string $key |
|
| 1153 | + * @return mixed |
|
| 1154 | + */ |
|
| 1155 | + public function getLastValue($key) |
|
| 1156 | + { |
|
| 1157 | + $nb = count($this->table); |
|
| 1158 | + if ($nb>0) { |
|
| 1159 | + return $this->table[$nb-1][$key]; |
|
| 1160 | + } else { |
|
| 1161 | + return null; |
|
| 1162 | + } |
|
| 1163 | + } |
|
| 1164 | + |
|
| 1165 | + /** |
|
| 1166 | + * get the last absolute X |
|
| 1167 | + * |
|
| 1168 | + * @access protected |
|
| 1169 | + * @return float $x |
|
| 1170 | + */ |
|
| 1171 | + protected function _getLastAbsoluteX() |
|
| 1172 | + { |
|
| 1173 | + for ($k=count($this->table)-1; $k>=0; $k--) { |
|
| 1174 | + if ($this->table[$k]['x'] && $this->table[$k]['position']) return $this->table[$k]['x']; |
|
| 1175 | + } |
|
| 1176 | + return $this->_pdf->getlMargin(); |
|
| 1177 | + } |
|
| 1178 | + |
|
| 1179 | + /** |
|
| 1180 | + * get the last absolute Y |
|
| 1181 | + * |
|
| 1182 | + * @access protected |
|
| 1183 | + * @return float $y |
|
| 1184 | + */ |
|
| 1185 | + protected function _getLastAbsoluteY() |
|
| 1186 | + { |
|
| 1187 | + for ($k=count($this->table)-1; $k>=0; $k--) { |
|
| 1188 | + if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y']; |
|
| 1189 | + } |
|
| 1190 | + return $this->_pdf->gettMargin(); |
|
| 1191 | + } |
|
| 1192 | + |
|
| 1193 | + /** |
|
| 1194 | + * get the CSS properties of the current tag |
|
| 1195 | + * |
|
| 1196 | + * @access protected |
|
| 1197 | + * @return array $styles |
|
| 1198 | + */ |
|
| 1199 | + protected function _getFromCSS() |
|
| 1200 | + { |
|
| 1201 | + // styles to apply |
|
| 1202 | + $styles = array(); |
|
| 1203 | + |
|
| 1204 | + // list of the selectors to get in the CSS files |
|
| 1205 | + $getit = array(); |
|
| 1206 | + |
|
| 1207 | + // get the list of the selectors of each tags |
|
| 1208 | + $lst = array(); |
|
| 1209 | + $lst[] = $this->value['id_lst']; |
|
| 1210 | + for ($i=count($this->table)-1; $i>=0; $i--) { |
|
| 1211 | + $lst[] = $this->table[$i]['id_lst']; |
|
| 1212 | + } |
|
| 1213 | + |
|
| 1214 | + // foreach selectors in the CSS files, verify if it match with the list of selectors |
|
| 1215 | + foreach ($this->cssKeys as $key => $num) { |
|
| 1216 | + if ($this->_getReccursiveStyle($key, $lst)) { |
|
| 1217 | + $getit[$key] = $num; |
|
| 1218 | + } |
|
| 1219 | + } |
|
| 1220 | + |
|
| 1221 | + // if we have selectors |
|
| 1222 | + if (count($getit)) { |
|
| 1223 | + // get them, but in the definition order, because of priority |
|
| 1224 | + asort($getit); |
|
| 1225 | + foreach ($getit as $key => $val) $styles = array_merge($styles, $this->css[$key]); |
|
| 1226 | + } |
|
| 1227 | + |
|
| 1228 | + return $styles; |
|
| 1229 | + } |
|
| 1230 | + |
|
| 1231 | + /** |
|
| 1232 | + * identify if the selector $key match with the list of tag selectors |
|
| 1233 | + * |
|
| 1234 | + * @access protected |
|
| 1235 | + * @param string $key CSS selector to analyse |
|
| 1236 | + * @param array $lst list of the selectors of each tags |
|
| 1237 | + * @param string $next next step of parsing the selector |
|
| 1238 | + * @return boolean |
|
| 1239 | + */ |
|
| 1240 | + protected function _getReccursiveStyle($key, $lst, $next = null) |
|
| 1241 | + { |
|
| 1242 | + // if next step |
|
| 1243 | + if ($next!==null) { |
|
| 1244 | + // we remove this step |
|
| 1245 | + if ($next) $key = trim(substr($key, 0, -strlen($next))); |
|
| 1246 | + array_shift($lst); |
|
| 1247 | + |
|
| 1248 | + // if no more step to identify => return false |
|
| 1249 | + if (!count($lst)) { |
|
| 1250 | + return false; |
|
| 1251 | + } |
|
| 1252 | + } |
|
| 1253 | + |
|
| 1254 | + // for each selector of the current step |
|
| 1255 | + foreach ($lst[0] as $name) { |
|
| 1256 | + // if selector = key => ok |
|
| 1257 | + if ($key==$name) { |
|
| 1258 | + return true; |
|
| 1259 | + } |
|
| 1260 | + |
|
| 1261 | + // if the end of the key = the selector and the next step is ok => ok |
|
| 1262 | + if (substr($key, -strlen(' '.$name))==' '.$name && $this->_getReccursiveStyle($key, $lst, $name)) { |
|
| 1263 | + return true; |
|
| 1264 | + } |
|
| 1265 | + } |
|
| 1266 | + |
|
| 1267 | + // if we are not in the first step, we analyse the sub steps (the pareng tag of the current tag) |
|
| 1268 | + if ($next!==null && $this->_getReccursiveStyle($key, $lst, '')) { |
|
| 1269 | + return true; |
|
| 1270 | + } |
|
| 1271 | + |
|
| 1272 | + // no corresponding found |
|
| 1273 | + return false; |
|
| 1274 | + } |
|
| 1275 | + |
|
| 1276 | + /** |
|
| 1277 | + * Analyse a border |
|
| 1278 | + * |
|
| 1279 | + * @access public |
|
| 1280 | + * @param string $css css border properties |
|
| 1281 | + * @return array border properties |
|
| 1282 | + */ |
|
| 1283 | + public function readBorder($css) |
|
| 1284 | + { |
|
| 1285 | + // border none |
|
| 1286 | + $none = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0)); |
|
| 1287 | + |
|
| 1288 | + // default value |
|
| 1289 | + $type = 'solid'; |
|
| 1290 | + $width = $this->convertToMM('1pt'); |
|
| 1291 | + $color = array(0, 0, 0); |
|
| 1292 | + |
|
| 1293 | + // clean up the values |
|
| 1294 | + $css = explode(' ', $css); |
|
| 1295 | + foreach ($css as $k => $v) { |
|
| 1296 | + $v = trim($v); |
|
| 1297 | + if ($v) $css[$k] = $v; |
|
| 1298 | + else unset($css[$k]); |
|
| 1299 | + } |
|
| 1300 | + $css = array_values($css); |
|
| 1301 | + |
|
| 1302 | + // read the values |
|
| 1303 | + $res = null; |
|
| 1304 | + foreach ($css as $value) { |
|
| 1305 | + |
|
| 1306 | + // if no border => return none |
|
| 1307 | + if ($value=='none' || $value=='hidden') { |
|
| 1308 | + return $none; |
|
| 1309 | + } |
|
| 1310 | + |
|
| 1311 | + // try to convert the value as a distance |
|
| 1312 | + $tmp = $this->convertToMM($value); |
|
| 1313 | + |
|
| 1314 | + // if the convert is ok => it is a width |
|
| 1315 | + if ($tmp!==null) { |
|
| 1316 | + $width = $tmp; |
|
| 1317 | + // else, it could be the type |
|
| 1318 | + } else if (in_array($value, array('solid', 'dotted', 'dashed', 'double'))) { |
|
| 1319 | + $type = $value; |
|
| 1320 | + // else, it could be the color |
|
| 1321 | + } else { |
|
| 1322 | + $tmp = $this->convertToColor($value, $res); |
|
| 1323 | + if ($res) $color = $tmp; |
|
| 1324 | + } |
|
| 1325 | + } |
|
| 1326 | + |
|
| 1327 | + // if no witdh => return none |
|
| 1328 | + if (!$width) return $none; |
|
| 1329 | + |
|
| 1330 | + // return the border properties |
|
| 1331 | + return array('type' => $type, 'width' => $width, 'color' => $color); |
|
| 1332 | + } |
|
| 1333 | + |
|
| 1334 | + /** |
|
| 1335 | + * duplicate the borders if needed |
|
| 1336 | + * |
|
| 1337 | + * @access protected |
|
| 1338 | + * @param &array $val |
|
| 1339 | + */ |
|
| 1340 | + protected function _duplicateBorder(&$val) |
|
| 1341 | + { |
|
| 1342 | + // 1 value => L => RTB |
|
| 1343 | + if (count($val)==1) { |
|
| 1344 | + $val[1] = $val[0]; |
|
| 1345 | + $val[2] = $val[0]; |
|
| 1346 | + $val[3] = $val[0]; |
|
| 1347 | + // 2 values => L => R & T => B |
|
| 1348 | + } else if (count($val)==2) { |
|
| 1349 | + $val[2] = $val[0]; |
|
| 1350 | + $val[3] = $val[1]; |
|
| 1351 | + // 3 values => T => B |
|
| 1352 | + } else if (count($val)==3) { |
|
| 1353 | + $val[3] = $val[1]; |
|
| 1354 | + } |
|
| 1355 | + } |
|
| 1356 | + |
|
| 1357 | + /** |
|
| 1358 | + * Analyse a background |
|
| 1359 | + * |
|
| 1360 | + * @access public |
|
| 1361 | + * @param string $css css background properties |
|
| 1362 | + * @param &array $value parsed values (by reference, because, ther is a legacy of the parent CSS properties) |
|
| 1363 | + */ |
|
| 1364 | + public function convertBackground($css, &$value) |
|
| 1365 | + { |
|
| 1366 | + // is there a image ? |
|
| 1367 | + $text = '/url\(([^)]*)\)/isU'; |
|
| 1368 | + if (preg_match($text, $css, $match)) { |
|
| 1369 | + // get the image |
|
| 1370 | + $value['image'] = $this->convertBackgroundImage($match[0]); |
|
| 1371 | + |
|
| 1372 | + // remove if from the css properties |
|
| 1373 | + $css = preg_replace($text, '', $css); |
|
| 1374 | + $css = preg_replace('/[\s]+/', ' ', $css); |
|
| 1375 | + } |
|
| 1376 | + |
|
| 1377 | + // protect some spaces |
|
| 1378 | + $css = preg_replace('/,[\s]+/', ',', $css); |
|
| 1379 | + |
|
| 1380 | + // explode the values |
|
| 1381 | + $css = explode(' ', $css); |
|
| 1382 | + |
|
| 1383 | + // background position to parse |
|
| 1384 | + $pos = ''; |
|
| 1385 | + |
|
| 1386 | + // foreach value |
|
| 1387 | + foreach ($css as $val) { |
|
| 1388 | + // try to parse the value as a color |
|
| 1389 | + $ok = false; |
|
| 1390 | + $color = $this->convertToColor($val, $ok); |
|
| 1391 | + |
|
| 1392 | + // if ok => it is a color |
|
| 1393 | + if ($ok) { |
|
| 1394 | + $value['color'] = $color; |
|
| 1395 | + // else if transparent => no coloàr |
|
| 1396 | + } else if ($val=='transparent') { |
|
| 1397 | + $value['color'] = null; |
|
| 1398 | + // else |
|
| 1399 | + } else { |
|
| 1400 | + // try to parse the value as a repeat |
|
| 1401 | + $repeat = $this->convertBackgroundRepeat($val); |
|
| 1402 | + |
|
| 1403 | + // if ok => it is repeat |
|
| 1404 | + if ($repeat) { |
|
| 1405 | + $value['repeat'] = $repeat; |
|
| 1406 | + // else => it could only be a position |
|
| 1407 | + } else { |
|
| 1408 | + $pos.= ($pos ? ' ' : '').$val; |
|
| 1409 | + } |
|
| 1410 | + } |
|
| 1411 | + } |
|
| 1412 | + |
|
| 1413 | + // if we have a position to parse |
|
| 1414 | + if ($pos) { |
|
| 1415 | + // try to read it |
|
| 1416 | + $pos = $this->convertBackgroundPosition($pos, $ok); |
|
| 1417 | + if ($ok) $value['position'] = $pos; |
|
| 1418 | + } |
|
| 1419 | + } |
|
| 1420 | + |
|
| 1421 | + /** |
|
| 1422 | + * parse a background color |
|
| 1423 | + * |
|
| 1424 | + * @access public |
|
| 1425 | + * @param string $css |
|
| 1426 | + * @return string $value |
|
| 1427 | + */ |
|
| 1428 | + public function convertBackgroundColor($css) |
|
| 1429 | + { |
|
| 1430 | + $res = null; |
|
| 1431 | + if ($css=='transparent') return null; |
|
| 1432 | + else return $this->convertToColor($css, $res); |
|
| 1433 | + } |
|
| 1434 | + |
|
| 1435 | + /** |
|
| 1436 | + * parse a background image |
|
| 1437 | + * |
|
| 1438 | + * @access public |
|
| 1439 | + * @param string $css |
|
| 1440 | + * @return string $value |
|
| 1441 | + */ |
|
| 1442 | + public function convertBackgroundImage($css) |
|
| 1443 | + { |
|
| 1444 | + if ($css=='none') |
|
| 1445 | + return null; |
|
| 1446 | + else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match)) |
|
| 1447 | + return $match[1]; |
|
| 1448 | + else |
|
| 1449 | + return null; |
|
| 1450 | + } |
|
| 1451 | + |
|
| 1452 | + /** |
|
| 1453 | + * parse a background position |
|
| 1454 | + * |
|
| 1455 | + * @access public |
|
| 1456 | + * @param string $css |
|
| 1457 | + * @param &boolean $res flag if conver is ok or not |
|
| 1458 | + * @return array ($x, $y) |
|
| 1459 | + */ |
|
| 1460 | + public function convertBackgroundPosition($css, &$res) |
|
| 1461 | + { |
|
| 1462 | + // init the res |
|
| 1463 | + $res = false; |
|
| 1464 | + |
|
| 1465 | + // explode the value |
|
| 1466 | + $css = explode(' ', $css); |
|
| 1467 | + |
|
| 1468 | + // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2 |
|
| 1469 | + if (count($css)<2) { |
|
| 1470 | + if (!$css[0]) return null; |
|
| 1471 | + $css[1] = 'center'; |
|
| 1472 | + } |
|
| 1473 | + if (count($css)>2) return null; |
|
| 1474 | + |
|
| 1475 | + // prepare the values |
|
| 1476 | + $x = 0; |
|
| 1477 | + $y = 0; |
|
| 1478 | + $res = true; |
|
| 1479 | + |
|
| 1480 | + // convert the first value |
|
| 1481 | + if ($css[0]=='left') $x = '0%'; |
|
| 1482 | + else if ($css[0]=='center') $x = '50%'; |
|
| 1483 | + else if ($css[0]=='right') $x = '100%'; |
|
| 1484 | + else if ($css[0]=='top') $y = '0%'; |
|
| 1485 | + else if ($css[0]=='bottom') $y = '100%'; |
|
| 1486 | + else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0]; |
|
| 1487 | + else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]); |
|
| 1488 | + else $res = false; |
|
| 1489 | + |
|
| 1490 | + // convert the second value |
|
| 1491 | + if ($css[1]=='left') $x = '0%'; |
|
| 1492 | + else if ($css[1]=='right') $x = '100%'; |
|
| 1493 | + else if ($css[1]=='top') $y = '0%'; |
|
| 1494 | + else if ($css[1]=='center') $y = '50%'; |
|
| 1495 | + else if ($css[1]=='bottom') $y = '100%'; |
|
| 1496 | + else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1]; |
|
| 1497 | + else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]); |
|
| 1498 | + else $res = false; |
|
| 1499 | + |
|
| 1500 | + // return the values |
|
| 1501 | + return array($x, $y); |
|
| 1502 | + } |
|
| 1503 | + |
|
| 1504 | + /** |
|
| 1505 | + * parse a background repeat |
|
| 1506 | + * |
|
| 1507 | + * @access public |
|
| 1508 | + * @param string $css |
|
| 1509 | + * @return string $value |
|
| 1510 | + */ |
|
| 1511 | + public function convertBackgroundRepeat($css) |
|
| 1512 | + { |
|
| 1513 | + switch($css) |
|
| 1514 | + { |
|
| 1515 | + case 'repeat': |
|
| 1516 | + return array(true, true); |
|
| 1517 | + case 'repeat-x': |
|
| 1518 | + return array(true, false); |
|
| 1519 | + case 'repeat-y': |
|
| 1520 | + return array(false, true); |
|
| 1521 | + case 'no-repeat': |
|
| 1522 | + return array(false, false); |
|
| 1523 | + } |
|
| 1524 | + return null; |
|
| 1525 | + } |
|
| 1526 | + |
|
| 1527 | + /** |
|
| 1528 | + * convert a distance to mm |
|
| 1529 | + * |
|
| 1530 | + * @access public |
|
| 1531 | + * @param string $css distance to convert |
|
| 1532 | + * @param float $old parent distance |
|
| 1533 | + * @return float $value |
|
| 1534 | + */ |
|
| 1535 | + public function convertToMM($css, $old=0.) |
|
| 1536 | + { |
|
| 1537 | + $css = trim($css); |
|
| 1538 | + if (preg_match('/^[0-9\.\-]+$/isU', $css)) $css.= 'px'; |
|
| 1539 | + if (preg_match('/^[0-9\.\-]+px$/isU', $css)) $css = 25.4/96. * str_replace('px', '', $css); |
|
| 1540 | + else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css); |
|
| 1541 | + else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css); |
|
| 1542 | + else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css); |
|
| 1543 | + else if (preg_match('/^[0-9\.\-]+%$/isU', $css)) $css = 1.*$old*str_replace('%', '', $css)/100.; |
|
| 1544 | + else $css = null; |
|
| 1545 | + |
|
| 1546 | + return $css; |
|
| 1547 | + } |
|
| 1548 | + |
|
| 1549 | + /** |
|
| 1550 | + * convert a css radius |
|
| 1551 | + * |
|
| 1552 | + * @access public |
|
| 1553 | + * @param string $css |
|
| 1554 | + * @return float $value |
|
| 1555 | + */ |
|
| 1556 | + public function convertToRadius($css) |
|
| 1557 | + { |
|
| 1558 | + // explode the value |
|
| 1559 | + $css = explode(' ', $css); |
|
| 1560 | + |
|
| 1561 | + foreach ($css as $k => $v) { |
|
| 1562 | + $v = trim($v); |
|
| 1563 | + if ($v) { |
|
| 1564 | + $v = $this->convertToMM($v, 0); |
|
| 1565 | + if ($v!==null) { |
|
| 1566 | + $css[$k] = $v; |
|
| 1567 | + } else { |
|
| 1568 | + unset($css[$k]); |
|
| 1569 | + } |
|
| 1570 | + } else { |
|
| 1571 | + unset($css[$k]); |
|
| 1572 | + } |
|
| 1573 | + } |
|
| 1574 | + |
|
| 1575 | + return array_values($css); |
|
| 1576 | + } |
|
| 1577 | + |
|
| 1578 | + /** |
|
| 1579 | + * convert a css color |
|
| 1580 | + * |
|
| 1581 | + * @access public |
|
| 1582 | + * @param string $css |
|
| 1583 | + * @param &boolean $res |
|
| 1584 | + * @return array (r,g, b) |
|
| 1585 | + */ |
|
| 1586 | + public function convertToColor($css, &$res) |
|
| 1587 | + { |
|
| 1588 | + // prepare the value |
|
| 1589 | + $css = trim($css); |
|
| 1590 | + $res = true; |
|
| 1591 | + |
|
| 1592 | + // if transparent => return null |
|
| 1593 | + if (strtolower($css)=='transparent') return array(null, null, null); |
|
| 1594 | + |
|
| 1595 | + // HTML color |
|
| 1596 | + if (isset($this->_htmlColor[strtolower($css)])) { |
|
| 1597 | + $css = $this->_htmlColor[strtolower($css)]; |
|
| 1598 | + $r = floatVal(hexdec(substr($css, 0, 2))); |
|
| 1599 | + $v = floatVal(hexdec(substr($css, 2, 2))); |
|
| 1600 | + $b = floatVal(hexdec(substr($css, 4, 2))); |
|
| 1601 | + return array($r, $v, $b); |
|
| 1602 | + } |
|
| 1603 | + |
|
| 1604 | + // like #FFFFFF |
|
| 1605 | + if (preg_match('/^#[0-9A-Fa-f]{6}$/isU', $css)) { |
|
| 1606 | + $r = floatVal(hexdec(substr($css, 1, 2))); |
|
| 1607 | + $v = floatVal(hexdec(substr($css, 3, 2))); |
|
| 1608 | + $b = floatVal(hexdec(substr($css, 5, 2))); |
|
| 1609 | + return array($r, $v, $b); |
|
| 1610 | + } |
|
| 1611 | + |
|
| 1612 | + // like #FFF |
|
| 1613 | + if (preg_match('/^#[0-9A-F]{3}$/isU', $css)) { |
|
| 1614 | + $r = floatVal(hexdec(substr($css, 1, 1).substr($css, 1, 1))); |
|
| 1615 | + $v = floatVal(hexdec(substr($css, 2, 1).substr($css, 2, 1))); |
|
| 1616 | + $b = floatVal(hexdec(substr($css, 3, 1).substr($css, 3, 1))); |
|
| 1617 | + return array($r, $v, $b); |
|
| 1618 | + } |
|
| 1619 | + |
|
| 1620 | + // like rgb(100, 100, 100) |
|
| 1621 | + if (preg_match('/rgb\([\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*\)/isU', $css, $match)) { |
|
| 1622 | + $r = $this->_convertSubColor($match[1]); |
|
| 1623 | + $v = $this->_convertSubColor($match[2]); |
|
| 1624 | + $b = $this->_convertSubColor($match[3]); |
|
| 1625 | + return array($r*255., $v*255., $b*255.); |
|
| 1626 | + } |
|
| 1627 | + |
|
| 1628 | + // like cmyk(100, 100, 100, 100) |
|
| 1629 | + if (preg_match('/cmyk\([\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*,[\s]*([0-9%\.]+)[\s]*\)/isU', $css, $match)) { |
|
| 1630 | + $c = $this->_convertSubColor($match[1]); |
|
| 1631 | + $m = $this->_convertSubColor($match[2]); |
|
| 1632 | + $y = $this->_convertSubColor($match[3]); |
|
| 1633 | + $k = $this->_convertSubColor($match[4]); |
|
| 1634 | + return array($c*100., $m*100., $y*100., $k*100.); |
|
| 1635 | + } |
|
| 1636 | + |
|
| 1637 | + $res = false; |
|
| 1638 | + return array(0., 0., 0.); |
|
| 1639 | + } |
|
| 1640 | + |
|
| 1641 | + /** |
|
| 1642 | + * color value to convert |
|
| 1643 | + * |
|
| 1644 | + * @access protected |
|
| 1645 | + * @param string $c |
|
| 1646 | + * @return float $c 0.->1. |
|
| 1647 | + */ |
|
| 1648 | + protected function _convertSubColor($c) |
|
| 1649 | + { |
|
| 1650 | + if (substr($c, -1)=='%') { |
|
| 1651 | + $c = floatVal(substr($c, 0, -1))/100.; |
|
| 1652 | + } else { |
|
| 1653 | + $c = floatVal($c); |
|
| 1654 | + if ($c>1) $c = $c/255.; |
|
| 1655 | + } |
|
| 1656 | + |
|
| 1657 | + return $c; |
|
| 1658 | + } |
|
| 1659 | + |
|
| 1660 | + /** |
|
| 1661 | + * read a css content |
|
| 1662 | + * |
|
| 1663 | + * @access protected |
|
| 1664 | + * @param &string $code |
|
| 1665 | + */ |
|
| 1666 | + protected function _analyseStyle(&$code) |
|
| 1667 | + { |
|
| 1668 | + // clean the spaces |
|
| 1669 | + $code = preg_replace('/[\s]+/', ' ', $code); |
|
| 1670 | + |
|
| 1671 | + // remove the comments |
|
| 1672 | + $code = preg_replace('/\/\*.*?\*\//s', '', $code); |
|
| 1673 | + |
|
| 1674 | + // split each CSS code "selector { value }" |
|
| 1675 | + preg_match_all('/([^{}]+){([^}]*)}/isU', $code, $match); |
|
| 1676 | + |
|
| 1677 | + // for each CSS code |
|
| 1678 | + for ($k=0; $k<count($match[0]); $k++) { |
|
| 1679 | + |
|
| 1680 | + // selectors |
|
| 1681 | + $names = strtolower(trim($match[1][$k])); |
|
| 1682 | + |
|
| 1683 | + // css style |
|
| 1684 | + $styles = trim($match[2][$k]); |
|
| 1685 | + |
|
| 1686 | + // explode each value |
|
| 1687 | + $styles = explode(';', $styles); |
|
| 1688 | + |
|
| 1689 | + // parse each value |
|
| 1690 | + $css = array(); |
|
| 1691 | + foreach ($styles as $style) { |
|
| 1692 | + $tmp = explode(':', $style); |
|
| 1693 | + if (count($tmp)>1) { |
|
| 1694 | + $cod = $tmp[0]; unset($tmp[0]); $tmp = implode(':', $tmp); |
|
| 1695 | + $css[trim(strtolower($cod))] = trim($tmp); |
|
| 1696 | + } |
|
| 1697 | + } |
|
| 1698 | + |
|
| 1699 | + // explode the names |
|
| 1700 | + $names = explode(',', $names); |
|
| 1701 | + |
|
| 1702 | + // save the values for each names |
|
| 1703 | + foreach ($names as $name) { |
|
| 1704 | + // clean the name |
|
| 1705 | + $name = trim($name); |
|
| 1706 | + |
|
| 1707 | + // if a selector with somethink lige :hover => continue |
|
| 1708 | + if (strpos($name, ':')!==false) continue; |
|
| 1709 | + |
|
| 1710 | + // save the value |
|
| 1711 | + if (!isset($this->css[$name])) |
|
| 1712 | + $this->css[$name] = $css; |
|
| 1713 | + else |
|
| 1714 | + $this->css[$name] = array_merge($this->css[$name], $css); |
|
| 1715 | + |
|
| 1716 | + } |
|
| 1717 | + } |
|
| 1718 | + |
|
| 1719 | + // get he list of the keys |
|
| 1720 | + $this->cssKeys = array_flip(array_keys($this->css)); |
|
| 1721 | + } |
|
| 1722 | + |
|
| 1723 | + /** |
|
| 1724 | + * Extract the css files from a html code |
|
| 1725 | + * |
|
| 1726 | + * @access public |
|
| 1727 | + * @param string &$html |
|
| 1728 | + */ |
|
| 1729 | + public function readStyle(&$html) |
|
| 1730 | + { |
|
| 1731 | + // the CSS content |
|
| 1732 | + $style = ' '; |
|
| 1733 | + |
|
| 1734 | + // extract the link tags, and remove them in the html code |
|
| 1735 | + preg_match_all('/<link([^>]*)>/isU', $html, $match); |
|
| 1736 | + $html = preg_replace('/<link[^>]*>/isU', '', $html); |
|
| 1737 | + $html = preg_replace('/<\/link[^>]*>/isU', '', $html); |
|
| 1738 | + |
|
| 1739 | + // analyse each link tag |
|
| 1740 | + foreach ($match[1] as $code) { |
|
| 1741 | + $tmp = array(); |
|
| 1742 | + |
|
| 1743 | + // read the attributes name=value |
|
| 1744 | + $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)'; |
|
| 1745 | + preg_match_all('/'.$prop.'/is', $code, $match); |
|
| 1746 | + for ($k=0; $k<count($match[0]); $k++) { |
|
| 1747 | + $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 1748 | + } |
|
| 1749 | + |
|
| 1750 | + // read the attributes name="value" |
|
| 1751 | + $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]'; |
|
| 1752 | + preg_match_all('/'.$prop.'/is', $code, $match); |
|
| 1753 | + for ($k=0; $k<count($match[0]); $k++) { |
|
| 1754 | + $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 1755 | + } |
|
| 1756 | + |
|
| 1757 | + // read the attributes name='value' |
|
| 1758 | + $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']"; |
|
| 1759 | + preg_match_all('/'.$prop.'/is', $code, $match); |
|
| 1760 | + for ($k=0; $k<count($match[0]); $k++) { |
|
| 1761 | + $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 1762 | + } |
|
| 1763 | + |
|
| 1764 | + // if type text/css => we keep it |
|
| 1765 | + if (isset($tmp['type']) && strtolower($tmp['type'])=='text/css' && isset($tmp['href'])) { |
|
| 1766 | + |
|
| 1767 | + // get the href |
|
| 1768 | + $url = $tmp['href']; |
|
| 1769 | + |
|
| 1770 | + // get the content of the css file |
|
| 1771 | + $content = @file_get_contents($url); |
|
| 1772 | + |
|
| 1773 | + // if "http://" in the url |
|
| 1774 | + if (strpos($url, 'http://')!==false) { |
|
| 1775 | + |
|
| 1776 | + // get the domain "http://xxx/" |
|
| 1777 | + $url = str_replace('http://', '', $url); |
|
| 1778 | + $url = explode('/', $url); |
|
| 1779 | + $urlMain = 'http://'.$url[0].'/'; |
|
| 1780 | + |
|
| 1781 | + // get the absolute url of the path |
|
| 1782 | + $urlSelf = $url; unset($urlSelf[count($urlSelf)-1]); $urlSelf = 'http://'.implode('/', $urlSelf).'/'; |
|
| 1783 | + |
|
| 1784 | + // adapt the url in the css content |
|
| 1785 | + $content = preg_replace('/url\(([^\\\\][^)]*)\)/isU', 'url('.$urlSelf.'$1)', $content); |
|
| 1786 | + $content = preg_replace('/url\((\\\\[^)]*)\)/isU', 'url('.$urlMain.'$1)', $content); |
|
| 1787 | + } else { |
|
| 1788 | 1788 | // @TODO correction on url in absolute on a local css content |
| 1789 | - // $content = preg_replace('/url\(([^)]*)\)/isU', 'url('.dirname($url).'/$1)', $content); |
|
| 1790 | - } |
|
| 1791 | - |
|
| 1792 | - // add to the CSS content |
|
| 1793 | - $style.= $content."\n"; |
|
| 1794 | - } |
|
| 1795 | - } |
|
| 1796 | - |
|
| 1797 | - // extract the style tags des tags style, and remove them in the html code |
|
| 1798 | - preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match); |
|
| 1799 | - $html = preg_replace('/<style[^>]*>(.*)<\/style[^>]*>/isU', '', $html); |
|
| 1800 | - |
|
| 1801 | - // analyse each style tags |
|
| 1802 | - foreach ($match[1] as $code) { |
|
| 1803 | - // add to the CSS content |
|
| 1804 | - $code = str_replace('<!--', '', $code); |
|
| 1805 | - $code = str_replace('-->', '', $code); |
|
| 1806 | - $style.= $code."\n"; |
|
| 1807 | - } |
|
| 1808 | - |
|
| 1809 | - //analyse the css content |
|
| 1810 | - $this->_analyseStyle($style); |
|
| 1811 | - } |
|
| 1789 | + // $content = preg_replace('/url\(([^)]*)\)/isU', 'url('.dirname($url).'/$1)', $content); |
|
| 1790 | + } |
|
| 1791 | + |
|
| 1792 | + // add to the CSS content |
|
| 1793 | + $style.= $content."\n"; |
|
| 1794 | + } |
|
| 1795 | + } |
|
| 1796 | + |
|
| 1797 | + // extract the style tags des tags style, and remove them in the html code |
|
| 1798 | + preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match); |
|
| 1799 | + $html = preg_replace('/<style[^>]*>(.*)<\/style[^>]*>/isU', '', $html); |
|
| 1800 | + |
|
| 1801 | + // analyse each style tags |
|
| 1802 | + foreach ($match[1] as $code) { |
|
| 1803 | + // add to the CSS content |
|
| 1804 | + $code = str_replace('<!--', '', $code); |
|
| 1805 | + $code = str_replace('-->', '', $code); |
|
| 1806 | + $style.= $code."\n"; |
|
| 1807 | + } |
|
| 1808 | + |
|
| 1809 | + //analyse the css content |
|
| 1810 | + $this->_analyseStyle($style); |
|
| 1811 | + } |
|
| 1812 | 1812 | } |
| 1813 | 1813 | \ No newline at end of file |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | protected $_pdf = null; |
| 19 | 19 | |
| 20 | 20 | protected $_htmlColor = array(); // list of the HTML colors |
| 21 | - protected $_onlyLeft = false; // flag if we are in a sub html => only "text-align:left" is used |
|
| 22 | - protected $_defaultFont = null; // default font to use if the asked font does not exist |
|
| 21 | + protected $_onlyLeft = false; // flag if we are in a sub html => only "text-align:left" is used |
|
| 22 | + protected $_defaultFont = null; // default font to use if the asked font does not exist |
|
| 23 | 23 | |
| 24 | 24 | public $value = array(); // current values |
| 25 | 25 | public $css = array(); // css values |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function getOldValues() |
| 70 | 70 | { |
| 71 | - return isset($this->table[count($this->table)-1]) ? $this->table[count($this->table)-1] : $this->value; |
|
| 71 | + return isset($this->table[count($this->table) - 1]) ? $this->table[count($this->table) - 1] : $this->value; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function initStyle() |
| 115 | 115 | { |
| 116 | - $this->value['id_tag'] = 'body'; // tag name |
|
| 117 | - $this->value['id_name'] = null; // tag - attribute name |
|
| 118 | - $this->value['id_id'] = null; // tag - attribute id |
|
| 119 | - $this->value['id_class'] = null; // tag - attribute class |
|
| 120 | - $this->value['id_lst'] = array('*'); // tag - list of legacy |
|
| 121 | - $this->value['mini-size'] = 1.; // specific size report for sup, sub |
|
| 122 | - $this->value['mini-decal'] = 0; // specific position report for sup, sub |
|
| 116 | + $this->value['id_tag'] = 'body'; // tag name |
|
| 117 | + $this->value['id_name'] = null; // tag - attribute name |
|
| 118 | + $this->value['id_id'] = null; // tag - attribute id |
|
| 119 | + $this->value['id_class'] = null; // tag - attribute class |
|
| 120 | + $this->value['id_lst'] = array('*'); // tag - list of legacy |
|
| 121 | + $this->value['mini-size'] = 1.; // specific size report for sup, sub |
|
| 122 | + $this->value['mini-decal'] = 0; // specific position report for sup, sub |
|
| 123 | 123 | $this->value['font-family'] = 'Arial'; |
| 124 | 124 | $this->value['font-bold'] = false; |
| 125 | 125 | $this->value['font-italic'] = false; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | // prepare the Collapse attribute |
| 181 | 181 | $collapse = isset($this->value['border']['collapse']) ? $this->value['border']['collapse'] : false; |
| 182 | - if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) $collapse = false; |
|
| 182 | + if ( ! in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) $collapse = false; |
|
| 183 | 183 | |
| 184 | 184 | // set the global css values |
| 185 | 185 | $this->value['position'] = null; |
@@ -211,8 +211,8 @@ discard block |
||
| 211 | 211 | ); |
| 212 | 212 | |
| 213 | 213 | // specific values for some tags |
| 214 | - if (!in_array($tagName, array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) { |
|
| 215 | - $this->value['margin'] = array('t'=>0,'r'=>0,'b'=>0,'l'=>0); |
|
| 214 | + if ( ! in_array($tagName, array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) { |
|
| 215 | + $this->value['margin'] = array('t'=>0, 'r'=>0, 'b'=>0, 'l'=>0); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | if (in_array($tagName, array('input', 'select', 'textarea'))) { |
@@ -222,11 +222,11 @@ discard block |
||
| 222 | 222 | $this->value['border']['l'] = null; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ($tagName=='p') { |
|
| 225 | + if ($tagName == 'p') { |
|
| 226 | 226 | $this->value['margin']['t'] = null; |
| 227 | 227 | $this->value['margin']['b'] = null; |
| 228 | 228 | } |
| 229 | - if ($tagName=='blockquote') { |
|
| 229 | + if ($tagName == 'blockquote') { |
|
| 230 | 230 | $this->value['margin']['t'] = 3; |
| 231 | 231 | $this->value['margin']['r'] = 3; |
| 232 | 232 | $this->value['margin']['b'] = 3; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | $this->value['list-style-image'] = ''; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if (!in_array($tagName, array('tr', 'td'))) { |
|
| 262 | + if ( ! in_array($tagName, array('tr', 'td'))) { |
|
| 263 | 263 | $this->value['padding'] = array( |
| 264 | 264 | 't' => 0, |
| 265 | 265 | 'r' => 0, |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | ); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if ($tagName=='hr') { |
|
| 278 | + if ($tagName == 'hr') { |
|
| 279 | 279 | $this->value['border'] = array( |
| 280 | 280 | 't' => $border, |
| 281 | 281 | 'r' => $border, |
@@ -305,40 +305,40 @@ discard block |
||
| 305 | 305 | { |
| 306 | 306 | $family = strtolower($this->value['font-family']); |
| 307 | 307 | |
| 308 | - $b = ($this->value['font-bold'] ? 'B' : ''); |
|
| 309 | - $i = ($this->value['font-italic'] ? 'I' : ''); |
|
| 310 | - $u = ($this->value['font-underline'] ? 'U' : ''); |
|
| 308 | + $b = ($this->value['font-bold'] ? 'B' : ''); |
|
| 309 | + $i = ($this->value['font-italic'] ? 'I' : ''); |
|
| 310 | + $u = ($this->value['font-underline'] ? 'U' : ''); |
|
| 311 | 311 | $d = ($this->value['font-linethrough'] ? 'D' : ''); |
| 312 | - $o = ($this->value['font-overline'] ? 'O' : ''); |
|
| 312 | + $o = ($this->value['font-overline'] ? 'O' : ''); |
|
| 313 | 313 | |
| 314 | 314 | // font style |
| 315 | 315 | $style = $b.$i; |
| 316 | 316 | |
| 317 | 317 | if ($this->_defaultFont) { |
| 318 | - if($family=='arial') |
|
| 319 | - $family='helvetica'; |
|
| 320 | - elseif($family=='symbol' || $family=='zapfdingbats') |
|
| 321 | - $style=''; |
|
| 318 | + if ($family == 'arial') |
|
| 319 | + $family = 'helvetica'; |
|
| 320 | + elseif ($family == 'symbol' || $family == 'zapfdingbats') |
|
| 321 | + $style = ''; |
|
| 322 | 322 | |
| 323 | 323 | $fontkey = $family.$style; |
| 324 | - if (!$this->_pdf->isLoadedFont($fontkey)) |
|
| 324 | + if ( ! $this->_pdf->isLoadedFont($fontkey)) |
|
| 325 | 325 | $family = $this->_defaultFont; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if($family=='arial') |
|
| 329 | - $family='helvetica'; |
|
| 330 | - elseif($family=='symbol' || $family=='zapfdingbats') |
|
| 331 | - $style=''; |
|
| 328 | + if ($family == 'arial') |
|
| 329 | + $family = 'helvetica'; |
|
| 330 | + elseif ($family == 'symbol' || $family == 'zapfdingbats') |
|
| 331 | + $style = ''; |
|
| 332 | 332 | |
| 333 | 333 | // complete style |
| 334 | - $style.= $u.$d.$o; |
|
| 334 | + $style .= $u.$d.$o; |
|
| 335 | 335 | |
| 336 | 336 | // size : mm => pt |
| 337 | 337 | $size = $this->value['font-size']; |
| 338 | 338 | $size = 72 * $size / 25.4; |
| 339 | 339 | |
| 340 | 340 | // apply the font |
| 341 | - $this->_pdf->SetFont($family, $style, $this->value['mini-size']*$size); |
|
| 341 | + $this->_pdf->SetFont($family, $style, $this->value['mini-size'] * $size); |
|
| 342 | 342 | $this->_pdf->setTextColorArray($this->value['color']); |
| 343 | 343 | if ($this->value['background']['color']) |
| 344 | 344 | $this->_pdf->setFillColorArray($this->value['background']['color']); |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | public function restorePosition() |
| 377 | 377 | { |
| 378 | - if ($this->value['y']==$this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false); |
|
| 378 | + if ($this->value['y'] == $this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -393,35 +393,35 @@ discard block |
||
| 393 | 393 | $this->value['xc'] = $currentX; |
| 394 | 394 | $this->value['yc'] = $currentY; |
| 395 | 395 | |
| 396 | - if ($this->value['position']=='relative' || $this->value['position']=='absolute') { |
|
| 397 | - if ($this->value['right']!==null) { |
|
| 396 | + if ($this->value['position'] == 'relative' || $this->value['position'] == 'absolute') { |
|
| 397 | + if ($this->value['right'] !== null) { |
|
| 398 | 398 | $x = $this->getLastWidth(true) - $this->value['right'] - $this->value['width']; |
| 399 | - if ($this->value['margin']['r']) $x-= $this->value['margin']['r']; |
|
| 399 | + if ($this->value['margin']['r']) $x -= $this->value['margin']['r']; |
|
| 400 | 400 | } else { |
| 401 | 401 | $x = $this->value['left']; |
| 402 | - if ($this->value['margin']['l']) $x+= $this->value['margin']['l']; |
|
| 402 | + if ($this->value['margin']['l']) $x += $this->value['margin']['l']; |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if ($this->value['bottom']!==null) { |
|
| 405 | + if ($this->value['bottom'] !== null) { |
|
| 406 | 406 | $y = $this->getLastHeight(true) - $this->value['bottom'] - $this->value['height']; |
| 407 | - if ($this->value['margin']['b']) $y-= $this->value['margin']['b']; |
|
| 407 | + if ($this->value['margin']['b']) $y -= $this->value['margin']['b']; |
|
| 408 | 408 | } else { |
| 409 | 409 | $y = $this->value['top']; |
| 410 | - if ($this->value['margin']['t']) $y+= $this->value['margin']['t']; |
|
| 410 | + if ($this->value['margin']['t']) $y += $this->value['margin']['t']; |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if ($this->value['position']=='relative') { |
|
| 413 | + if ($this->value['position'] == 'relative') { |
|
| 414 | 414 | $this->value['x'] = $currentX + $x; |
| 415 | 415 | $this->value['y'] = $currentY + $y; |
| 416 | 416 | } else { |
| 417 | - $this->value['x'] = $this->_getLastAbsoluteX()+$x; |
|
| 418 | - $this->value['y'] = $this->_getLastAbsoluteY()+$y; |
|
| 417 | + $this->value['x'] = $this->_getLastAbsoluteX() + $x; |
|
| 418 | + $this->value['y'] = $this->_getLastAbsoluteY() + $y; |
|
| 419 | 419 | } |
| 420 | 420 | } else { |
| 421 | 421 | $this->value['x'] = $currentX; |
| 422 | 422 | $this->value['y'] = $currentY; |
| 423 | - if ($this->value['margin']['l']) $this->value['x']+= $this->value['margin']['l']; |
|
| 424 | - if ($this->value['margin']['t']) $this->value['y']+= $this->value['margin']['t']; |
|
| 423 | + if ($this->value['margin']['l']) $this->value['x'] += $this->value['margin']['l']; |
|
| 424 | + if ($this->value['margin']['t']) $this->value['y'] += $this->value['margin']['t']; |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | // save the new position |
@@ -456,11 +456,11 @@ discard block |
||
| 456 | 456 | $prop['borderStyle'] = $this->value['border']['t']['type']; |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - if (!empty($this->value['color'])) { |
|
| 459 | + if ( ! empty($this->value['color'])) { |
|
| 460 | 460 | $prop['textColor'] = $this->value['color']; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - if (!empty($this->value['font-size'])) { |
|
| 463 | + if ( ! empty($this->value['font-size'])) { |
|
| 464 | 464 | $prop['textSize'] = $this->value['font-size']; |
| 465 | 465 | } |
| 466 | 466 | |
@@ -478,8 +478,8 @@ discard block |
||
| 478 | 478 | { |
| 479 | 479 | // prepare |
| 480 | 480 | $tagName = strtolower($tagName); |
| 481 | - $id = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id) $id = null; |
|
| 482 | - $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null; |
|
| 481 | + $id = isset($param['id']) ? strtolower(trim($param['id'])) : null; if ( ! $id) $id = null; |
|
| 482 | + $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if ( ! $name) $name = null; |
|
| 483 | 483 | |
| 484 | 484 | // read the class attribute |
| 485 | 485 | $class = array(); |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | $this->value['id_lst'] = array(); |
| 499 | 499 | $this->value['id_lst'][] = '*'; |
| 500 | 500 | $this->value['id_lst'][] = $tagName; |
| 501 | - if (!isset($this->value['svg'])) { |
|
| 501 | + if ( ! isset($this->value['svg'])) { |
|
| 502 | 502 | $this->value['svg'] = array( |
| 503 | 503 | 'stroke' => null, |
| 504 | 504 | 'stroke-width' => $this->convertToMM('1pt'), |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | if (isset($styles['stroke'])) $this->value['svg']['stroke'] = $this->convertToColor($styles['stroke'], $res); |
| 530 | 530 | if (isset($styles['stroke-width'])) $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']); |
| 531 | 531 | if (isset($styles['fill'])) $this->value['svg']['fill'] = $this->convertToColor($styles['fill'], $res); |
| 532 | - if (isset($styles['fill-opacity'])) $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity']; |
|
| 532 | + if (isset($styles['fill-opacity'])) $this->value['svg']['fill-opacity'] = 1. * $styles['fill-opacity']; |
|
| 533 | 533 | |
| 534 | 534 | return $this->value['svg']; |
| 535 | 535 | } |
@@ -546,8 +546,8 @@ discard block |
||
| 546 | 546 | { |
| 547 | 547 | // prepare the informations |
| 548 | 548 | $tagName = strtolower($tagName); |
| 549 | - $id = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id) $id = null; |
|
| 550 | - $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null; |
|
| 549 | + $id = isset($param['id']) ? strtolower(trim($param['id'])) : null; if ( ! $id) $id = null; |
|
| 550 | + $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if ( ! $name) $name = null; |
|
| 551 | 551 | |
| 552 | 552 | // get the class names to use |
| 553 | 553 | $class = array(); |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | |
| 585 | 585 | // merge with the css styles from tag |
| 586 | 586 | $styles = array_merge($styles, $param['style']); |
| 587 | - if (isset($param['allwidth']) && !isset($styles['width'])) $styles['width'] = '100%'; |
|
| 587 | + if (isset($param['allwidth']) && ! isset($styles['width'])) $styles['width'] = '100%'; |
|
| 588 | 588 | |
| 589 | 589 | // reset some styles, depending on the tag name |
| 590 | 590 | $this->resetStyle($tagName); |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | if ($legacy) { |
| 594 | 594 | foreach ($legacy as $legacyName => $legacyValue) { |
| 595 | 595 | if (is_array($legacyValue)) { |
| 596 | - foreach($legacyValue as $legacy2Name => $legacy2Value) |
|
| 596 | + foreach ($legacyValue as $legacy2Name => $legacy2Value) |
|
| 597 | 597 | $this->value[$legacyName][$legacy2Name] = $legacy2Value; |
| 598 | 598 | } else { |
| 599 | 599 | $this->value[$legacyName] = $legacyValue; |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | |
| 608 | 608 | // read all the css styles |
| 609 | 609 | foreach ($styles as $nom => $val) { |
| 610 | - switch($nom) |
|
| 610 | + switch ($nom) |
|
| 611 | 611 | { |
| 612 | 612 | case 'font-family': |
| 613 | 613 | $val = explode(',', $val); |
@@ -616,11 +616,11 @@ discard block |
||
| 616 | 616 | break; |
| 617 | 617 | |
| 618 | 618 | case 'font-weight': |
| 619 | - $this->value['font-bold'] = ($val=='bold'); |
|
| 619 | + $this->value['font-bold'] = ($val == 'bold'); |
|
| 620 | 620 | break; |
| 621 | 621 | |
| 622 | 622 | case 'font-style': |
| 623 | - $this->value['font-italic'] = ($val=='italic'); |
|
| 623 | + $this->value['font-italic'] = ($val == 'italic'); |
|
| 624 | 624 | break; |
| 625 | 625 | |
| 626 | 626 | case 'text-decoration': |
@@ -635,8 +635,8 @@ discard block |
||
| 635 | 635 | break; |
| 636 | 636 | |
| 637 | 637 | case 'text-transform': |
| 638 | - if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none'; |
|
| 639 | - $this->value['text-transform'] = $val; |
|
| 638 | + if ( ! in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none'; |
|
| 639 | + $this->value['text-transform'] = $val; |
|
| 640 | 640 | break; |
| 641 | 641 | |
| 642 | 642 | case 'font-size': |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | case 'color': |
| 648 | 648 | $res = null; |
| 649 | 649 | $this->value['color'] = $this->convertToColor($val, $res); |
| 650 | - if ($tagName=='hr') { |
|
| 650 | + if ($tagName == 'hr') { |
|
| 651 | 651 | $this->value['border']['l']['color'] = $this->value['color']; |
| 652 | 652 | $this->value['border']['t']['color'] = $this->value['color']; |
| 653 | 653 | $this->value['border']['r']['color'] = $this->value['color']; |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | |
| 658 | 658 | case 'text-align': |
| 659 | 659 | $val = strtolower($val); |
| 660 | - if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) $val = 'left'; |
|
| 660 | + if ( ! in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) $val = 'left'; |
|
| 661 | 661 | $this->value['text-align'] = $val; |
| 662 | 662 | break; |
| 663 | 663 | |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | |
| 668 | 668 | case 'width': |
| 669 | 669 | $this->value['width'] = $this->convertToMM($val, $this->getLastWidth()); |
| 670 | - if ($this->value['width'] && substr($val, -1)=='%') $correctWidth=true; |
|
| 670 | + if ($this->value['width'] && substr($val, -1) == '%') $correctWidth = true; |
|
| 671 | 671 | $noWidth = false; |
| 672 | 672 | break; |
| 673 | 673 | |
@@ -676,18 +676,18 @@ discard block |
||
| 676 | 676 | break; |
| 677 | 677 | |
| 678 | 678 | case 'line-height': |
| 679 | - if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val*100).'%'; |
|
| 679 | + if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val * 100).'%'; |
|
| 680 | 680 | $this->value['line-height'] = $val; |
| 681 | 681 | break; |
| 682 | 682 | |
| 683 | 683 | case 'rotate': |
| 684 | - if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null; |
|
| 685 | - if ($val<0) $val+= 360; |
|
| 684 | + if ( ! in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null; |
|
| 685 | + if ($val < 0) $val += 360; |
|
| 686 | 686 | $this->value['rotate'] = $val; |
| 687 | 687 | break; |
| 688 | 688 | |
| 689 | 689 | case 'overflow': |
| 690 | - if (!in_array($val, array('visible', 'hidden'))) $val = 'visible'; |
|
| 690 | + if ( ! in_array($val, array('visible', 'hidden'))) $val = 'visible'; |
|
| 691 | 691 | $this->value['overflow'] = $val; |
| 692 | 692 | break; |
| 693 | 693 | |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | $val = explode(' ', $val); |
| 696 | 696 | foreach ($val as $k => $v) { |
| 697 | 697 | $v = trim($v); |
| 698 | - if ($v!='') { |
|
| 698 | + if ($v != '') { |
|
| 699 | 699 | $val[$k] = $v; |
| 700 | 700 | } else { |
| 701 | 701 | unset($val[$k]); |
@@ -726,14 +726,14 @@ discard block |
||
| 726 | 726 | break; |
| 727 | 727 | |
| 728 | 728 | case 'margin': |
| 729 | - if ($val=='auto') { |
|
| 729 | + if ($val == 'auto') { |
|
| 730 | 730 | $this->value['margin-auto'] = true; |
| 731 | 731 | break; |
| 732 | 732 | } |
| 733 | 733 | $val = explode(' ', $val); |
| 734 | 734 | foreach ($val as $k => $v) { |
| 735 | 735 | $v = trim($v); |
| 736 | - if ($v!='') { |
|
| 736 | + if ($v != '') { |
|
| 737 | 737 | $val[$k] = $v; |
| 738 | 738 | } else { |
| 739 | 739 | unset($val[$k]); |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | case 'border-style': |
| 775 | 775 | $val = explode(' ', $val); |
| 776 | 776 | foreach ($val as $valK => $valV) { |
| 777 | - if (!in_array($valV, array('solid', 'dotted', 'dashed'))) { |
|
| 777 | + if ( ! in_array($valV, array('solid', 'dotted', 'dashed'))) { |
|
| 778 | 778 | $val[$valK] = null; |
| 779 | 779 | } |
| 780 | 780 | } |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | $val = explode(' ', $val); |
| 815 | 815 | foreach ($val as $valK => $valV) { |
| 816 | 816 | $val[$valK] = $this->convertToColor($valV, $res); |
| 817 | - if (!$res) { |
|
| 817 | + if ( ! $res) { |
|
| 818 | 818 | $val[$valK] = null; |
| 819 | 819 | } |
| 820 | 820 | } |
@@ -883,29 +883,29 @@ discard block |
||
| 883 | 883 | break; |
| 884 | 884 | |
| 885 | 885 | case 'border-collapse': |
| 886 | - if ($tagName=='table') $this->value['border']['collapse'] = ($val=='collapse'); |
|
| 886 | + if ($tagName == 'table') $this->value['border']['collapse'] = ($val == 'collapse'); |
|
| 887 | 887 | break; |
| 888 | 888 | |
| 889 | 889 | case 'border-radius': |
| 890 | 890 | $val = explode('/', $val); |
| 891 | - if (count($val)>2) { |
|
| 891 | + if (count($val) > 2) { |
|
| 892 | 892 | break; |
| 893 | 893 | } |
| 894 | 894 | $valH = $this->convertToRadius(trim($val[0])); |
| 895 | - if (count($valH)<1 || count($valH)>4) { |
|
| 895 | + if (count($valH) < 1 || count($valH) > 4) { |
|
| 896 | 896 | break; |
| 897 | 897 | } |
| 898 | - if (!isset($valH[1])) $valH[1] = $valH[0]; |
|
| 899 | - if (!isset($valH[2])) $valH = array($valH[0], $valH[0], $valH[1], $valH[1]); |
|
| 900 | - if (!isset($valH[3])) $valH[3] = $valH[1]; |
|
| 898 | + if ( ! isset($valH[1])) $valH[1] = $valH[0]; |
|
| 899 | + if ( ! isset($valH[2])) $valH = array($valH[0], $valH[0], $valH[1], $valH[1]); |
|
| 900 | + if ( ! isset($valH[3])) $valH[3] = $valH[1]; |
|
| 901 | 901 | if (isset($val[1])) { |
| 902 | 902 | $valV = $this->convertToRadius(trim($val[1])); |
| 903 | - if (count($valV)<1 || count($valV)>4) { |
|
| 903 | + if (count($valV) < 1 || count($valV) > 4) { |
|
| 904 | 904 | break; |
| 905 | 905 | } |
| 906 | - if (!isset($valV[1])) $valV[1] = $valV[0]; |
|
| 907 | - if (!isset($valV[2])) $valV = array($valV[0], $valV[0], $valV[1], $valV[1]); |
|
| 908 | - if (!isset($valV[3])) $valV[3] = $valV[1]; |
|
| 906 | + if ( ! isset($valV[1])) $valV[1] = $valV[0]; |
|
| 907 | + if ( ! isset($valV[2])) $valV = array($valV[0], $valV[0], $valV[1], $valV[1]); |
|
| 908 | + if ( ! isset($valV[3])) $valV[3] = $valV[1]; |
|
| 909 | 909 | } else { |
| 910 | 910 | $valV = $valH; |
| 911 | 911 | } |
@@ -919,7 +919,7 @@ discard block |
||
| 919 | 919 | |
| 920 | 920 | case 'border-top-left-radius': |
| 921 | 921 | $val = $this->convertToRadius($val); |
| 922 | - if (count($val)<1 || count($val)>2) { |
|
| 922 | + if (count($val) < 1 || count($val) > 2) { |
|
| 923 | 923 | break; |
| 924 | 924 | } |
| 925 | 925 | $this->value['border']['radius']['tl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]); |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | |
| 928 | 928 | case 'border-top-right-radius': |
| 929 | 929 | $val = $this->convertToRadius($val); |
| 930 | - if (count($val)<1 || count($val)>2) { |
|
| 930 | + if (count($val) < 1 || count($val) > 2) { |
|
| 931 | 931 | break; |
| 932 | 932 | } |
| 933 | 933 | $this->value['border']['radius']['tr'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]); |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | |
| 936 | 936 | case 'border-bottom-right-radius': |
| 937 | 937 | $val = $this->convertToRadius($val); |
| 938 | - if (count($val)<1 || count($val)>2) { |
|
| 938 | + if (count($val) < 1 || count($val) > 2) { |
|
| 939 | 939 | break; |
| 940 | 940 | } |
| 941 | 941 | $this->value['border']['radius']['br'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]); |
@@ -943,7 +943,7 @@ discard block |
||
| 943 | 943 | |
| 944 | 944 | case 'border-bottom-left-radius': |
| 945 | 945 | $val = $this->convertToRadius($val); |
| 946 | - if (count($val)<1 || count($val)>2) { |
|
| 946 | + if (count($val) < 1 || count($val) > 2) { |
|
| 947 | 947 | break; |
| 948 | 948 | } |
| 949 | 949 | $this->value['border']['radius']['bl'] = array($val[0], isset($val[1]) ? $val[1] : $val[0]); |
@@ -987,21 +987,21 @@ discard block |
||
| 987 | 987 | break; |
| 988 | 988 | |
| 989 | 989 | case 'position': |
| 990 | - if ($val=='absolute') $this->value['position'] = 'absolute'; |
|
| 991 | - else if ($val=='relative') $this->value['position'] = 'relative'; |
|
| 990 | + if ($val == 'absolute') $this->value['position'] = 'absolute'; |
|
| 991 | + else if ($val == 'relative') $this->value['position'] = 'relative'; |
|
| 992 | 992 | else $this->value['position'] = null; |
| 993 | 993 | break; |
| 994 | 994 | |
| 995 | 995 | case 'float': |
| 996 | - if ($val=='left') $this->value['float'] = 'left'; |
|
| 997 | - else if ($val=='right') $this->value['float'] = 'right'; |
|
| 996 | + if ($val == 'left') $this->value['float'] = 'left'; |
|
| 997 | + else if ($val == 'right') $this->value['float'] = 'right'; |
|
| 998 | 998 | else $this->value['float'] = null; |
| 999 | 999 | break; |
| 1000 | 1000 | |
| 1001 | 1001 | case 'display': |
| 1002 | - if ($val=='inline') $this->value['display'] = 'inline'; |
|
| 1003 | - else if ($val=='block') $this->value['display'] = 'block'; |
|
| 1004 | - else if ($val=='none') $this->value['display'] = 'none'; |
|
| 1002 | + if ($val == 'inline') $this->value['display'] = 'inline'; |
|
| 1003 | + else if ($val == 'block') $this->value['display'] = 'block'; |
|
| 1004 | + else if ($val == 'none') $this->value['display'] = 'none'; |
|
| 1005 | 1005 | else $this->value['display'] = null; |
| 1006 | 1006 | break; |
| 1007 | 1007 | |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | case 'list-style': |
| 1016 | 1016 | case 'list-style-type': |
| 1017 | 1017 | case 'list-style-image': |
| 1018 | - if ($nom=='list-style') $nom = 'list-style-type'; |
|
| 1018 | + if ($nom == 'list-style') $nom = 'list-style-type'; |
|
| 1019 | 1019 | $this->value[$nom] = $val; |
| 1020 | 1020 | break; |
| 1021 | 1021 | |
@@ -1027,27 +1027,27 @@ discard block |
||
| 1027 | 1027 | $return = true; |
| 1028 | 1028 | |
| 1029 | 1029 | // only for P tag |
| 1030 | - if ($this->value['margin']['t']===null) $this->value['margin']['t'] = $this->value['font-size']; |
|
| 1031 | - if ($this->value['margin']['b']===null) $this->value['margin']['b'] = $this->value['font-size']; |
|
| 1030 | + if ($this->value['margin']['t'] === null) $this->value['margin']['t'] = $this->value['font-size']; |
|
| 1031 | + if ($this->value['margin']['b'] === null) $this->value['margin']['b'] = $this->value['font-size']; |
|
| 1032 | 1032 | |
| 1033 | 1033 | // force the text align to left, if asked by html2pdf |
| 1034 | 1034 | if ($this->_onlyLeft) $this->value['text-align'] = 'left'; |
| 1035 | 1035 | |
| 1036 | 1036 | // correction on the width (quick box) |
| 1037 | - if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position']!='absolute') { |
|
| 1037 | + if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position'] != 'absolute') { |
|
| 1038 | 1038 | $this->value['width'] = $this->getLastWidth(); |
| 1039 | - $this->value['width']-= $this->value['margin']['l'] + $this->value['margin']['r']; |
|
| 1039 | + $this->value['width'] -= $this->value['margin']['l'] + $this->value['margin']['r']; |
|
| 1040 | 1040 | } else { |
| 1041 | 1041 | if ($correctWidth) { |
| 1042 | - if (!in_array($tagName, array('table', 'div', 'blockquote', 'fieldset', 'hr'))) { |
|
| 1043 | - $this->value['width']-= $this->value['padding']['l'] + $this->value['padding']['r']; |
|
| 1044 | - $this->value['width']-= $this->value['border']['l']['width'] + $this->value['border']['r']['width']; |
|
| 1042 | + if ( ! in_array($tagName, array('table', 'div', 'blockquote', 'fieldset', 'hr'))) { |
|
| 1043 | + $this->value['width'] -= $this->value['padding']['l'] + $this->value['padding']['r']; |
|
| 1044 | + $this->value['width'] -= $this->value['border']['l']['width'] + $this->value['border']['r']['width']; |
|
| 1045 | 1045 | } |
| 1046 | 1046 | if (in_array($tagName, array('th', 'td'))) { |
| 1047 | - $this->value['width']-= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px'); |
|
| 1047 | + $this->value['width'] -= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px'); |
|
| 1048 | 1048 | $return = false; |
| 1049 | 1049 | } |
| 1050 | - if ($this->value['width']<0) $this->value['width']=0; |
|
| 1050 | + if ($this->value['width'] < 0) $this->value['width'] = 0; |
|
| 1051 | 1051 | } else { |
| 1052 | 1052 | if ($this->value['width']) { |
| 1053 | 1053 | if ($this->value['border']['l']['width']) $this->value['width'] += $this->value['border']['l']['width']; |
@@ -1064,10 +1064,10 @@ discard block |
||
| 1064 | 1064 | if ($this->value['padding']['t']) $this->value['height'] += $this->value['padding']['t']; |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | - if ($this->value['top']!=null) $this->value['top'] = $this->convertToMM($this->value['top'], $this->getLastHeight(true)); |
|
| 1068 | - if ($this->value['bottom']!=null) $this->value['bottom'] = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true)); |
|
| 1069 | - if ($this->value['left']!=null) $this->value['left'] = $this->convertToMM($this->value['left'], $this->getLastWidth(true)); |
|
| 1070 | - if ($this->value['right']!=null) $this->value['right'] = $this->convertToMM($this->value['right'], $this->getLastWidth(true)); |
|
| 1067 | + if ($this->value['top'] != null) $this->value['top'] = $this->convertToMM($this->value['top'], $this->getLastHeight(true)); |
|
| 1068 | + if ($this->value['bottom'] != null) $this->value['bottom'] = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true)); |
|
| 1069 | + if ($this->value['left'] != null) $this->value['left'] = $this->convertToMM($this->value['left'], $this->getLastWidth(true)); |
|
| 1070 | + if ($this->value['right'] != null) $this->value['right'] = $this->convertToMM($this->value['right'], $this->getLastWidth(true)); |
|
| 1071 | 1071 | |
| 1072 | 1072 | if ($this->value['top'] && $this->value['bottom'] && $this->value['height']) $this->value['bottom'] = null; |
| 1073 | 1073 | if ($this->value['left'] && $this->value['right'] && $this->value['width']) $this->value['right'] = null; |
@@ -1084,7 +1084,7 @@ discard block |
||
| 1084 | 1084 | public function getLineHeight() |
| 1085 | 1085 | { |
| 1086 | 1086 | $val = $this->value['line-height']; |
| 1087 | - if ($val=='normal') $val = '108%'; |
|
| 1087 | + if ($val == 'normal') $val = '108%'; |
|
| 1088 | 1088 | return $this->convertToMM($val, $this->value['font-size']); |
| 1089 | 1089 | } |
| 1090 | 1090 | |
@@ -1097,12 +1097,12 @@ discard block |
||
| 1097 | 1097 | */ |
| 1098 | 1098 | public function getLastWidth($mode = false) |
| 1099 | 1099 | { |
| 1100 | - for ($k=count($this->table)-1; $k>=0; $k--) { |
|
| 1100 | + for ($k = count($this->table) - 1; $k >= 0; $k--) { |
|
| 1101 | 1101 | if ($this->table[$k]['width']) { |
| 1102 | 1102 | $w = $this->table[$k]['width']; |
| 1103 | 1103 | if ($mode) { |
| 1104 | - $w+= $this->table[$k]['border']['l']['width'] + $this->table[$k]['padding']['l'] + 0.02; |
|
| 1105 | - $w+= $this->table[$k]['border']['r']['width'] + $this->table[$k]['padding']['r'] + 0.02; |
|
| 1104 | + $w += $this->table[$k]['border']['l']['width'] + $this->table[$k]['padding']['l'] + 0.02; |
|
| 1105 | + $w += $this->table[$k]['border']['r']['width'] + $this->table[$k]['padding']['r'] + 0.02; |
|
| 1106 | 1106 | } |
| 1107 | 1107 | return $w; |
| 1108 | 1108 | } |
@@ -1119,12 +1119,12 @@ discard block |
||
| 1119 | 1119 | */ |
| 1120 | 1120 | public function getLastHeight($mode = false) |
| 1121 | 1121 | { |
| 1122 | - for ($k=count($this->table)-1; $k>=0; $k--) { |
|
| 1122 | + for ($k = count($this->table) - 1; $k >= 0; $k--) { |
|
| 1123 | 1123 | if ($this->table[$k]['height']) { |
| 1124 | 1124 | $h = $this->table[$k]['height']; |
| 1125 | 1125 | if ($mode) { |
| 1126 | - $h+= $this->table[$k]['border']['t']['width'] + $this->table[$k]['padding']['t'] + 0.02; |
|
| 1127 | - $h+= $this->table[$k]['border']['b']['width'] + $this->table[$k]['padding']['b'] + 0.02; |
|
| 1126 | + $h += $this->table[$k]['border']['t']['width'] + $this->table[$k]['padding']['t'] + 0.02; |
|
| 1127 | + $h += $this->table[$k]['border']['b']['width'] + $this->table[$k]['padding']['b'] + 0.02; |
|
| 1128 | 1128 | } |
| 1129 | 1129 | return $h; |
| 1130 | 1130 | } |
@@ -1140,8 +1140,8 @@ discard block |
||
| 1140 | 1140 | */ |
| 1141 | 1141 | public function getFloat() |
| 1142 | 1142 | { |
| 1143 | - if ($this->value['float']=='left') return 'left'; |
|
| 1144 | - if ($this->value['float']=='right') return 'right'; |
|
| 1143 | + if ($this->value['float'] == 'left') return 'left'; |
|
| 1144 | + if ($this->value['float'] == 'right') return 'right'; |
|
| 1145 | 1145 | return null; |
| 1146 | 1146 | } |
| 1147 | 1147 | |
@@ -1155,8 +1155,8 @@ discard block |
||
| 1155 | 1155 | public function getLastValue($key) |
| 1156 | 1156 | { |
| 1157 | 1157 | $nb = count($this->table); |
| 1158 | - if ($nb>0) { |
|
| 1159 | - return $this->table[$nb-1][$key]; |
|
| 1158 | + if ($nb > 0) { |
|
| 1159 | + return $this->table[$nb - 1][$key]; |
|
| 1160 | 1160 | } else { |
| 1161 | 1161 | return null; |
| 1162 | 1162 | } |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | */ |
| 1171 | 1171 | protected function _getLastAbsoluteX() |
| 1172 | 1172 | { |
| 1173 | - for ($k=count($this->table)-1; $k>=0; $k--) { |
|
| 1173 | + for ($k = count($this->table) - 1; $k >= 0; $k--) { |
|
| 1174 | 1174 | if ($this->table[$k]['x'] && $this->table[$k]['position']) return $this->table[$k]['x']; |
| 1175 | 1175 | } |
| 1176 | 1176 | return $this->_pdf->getlMargin(); |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | */ |
| 1185 | 1185 | protected function _getLastAbsoluteY() |
| 1186 | 1186 | { |
| 1187 | - for ($k=count($this->table)-1; $k>=0; $k--) { |
|
| 1187 | + for ($k = count($this->table) - 1; $k >= 0; $k--) { |
|
| 1188 | 1188 | if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y']; |
| 1189 | 1189 | } |
| 1190 | 1190 | return $this->_pdf->gettMargin(); |
@@ -1207,7 +1207,7 @@ discard block |
||
| 1207 | 1207 | // get the list of the selectors of each tags |
| 1208 | 1208 | $lst = array(); |
| 1209 | 1209 | $lst[] = $this->value['id_lst']; |
| 1210 | - for ($i=count($this->table)-1; $i>=0; $i--) { |
|
| 1210 | + for ($i = count($this->table) - 1; $i >= 0; $i--) { |
|
| 1211 | 1211 | $lst[] = $this->table[$i]['id_lst']; |
| 1212 | 1212 | } |
| 1213 | 1213 | |
@@ -1240,13 +1240,13 @@ discard block |
||
| 1240 | 1240 | protected function _getReccursiveStyle($key, $lst, $next = null) |
| 1241 | 1241 | { |
| 1242 | 1242 | // if next step |
| 1243 | - if ($next!==null) { |
|
| 1243 | + if ($next !== null) { |
|
| 1244 | 1244 | // we remove this step |
| 1245 | 1245 | if ($next) $key = trim(substr($key, 0, -strlen($next))); |
| 1246 | 1246 | array_shift($lst); |
| 1247 | 1247 | |
| 1248 | 1248 | // if no more step to identify => return false |
| 1249 | - if (!count($lst)) { |
|
| 1249 | + if ( ! count($lst)) { |
|
| 1250 | 1250 | return false; |
| 1251 | 1251 | } |
| 1252 | 1252 | } |
@@ -1254,18 +1254,18 @@ discard block |
||
| 1254 | 1254 | // for each selector of the current step |
| 1255 | 1255 | foreach ($lst[0] as $name) { |
| 1256 | 1256 | // if selector = key => ok |
| 1257 | - if ($key==$name) { |
|
| 1257 | + if ($key == $name) { |
|
| 1258 | 1258 | return true; |
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | // if the end of the key = the selector and the next step is ok => ok |
| 1262 | - if (substr($key, -strlen(' '.$name))==' '.$name && $this->_getReccursiveStyle($key, $lst, $name)) { |
|
| 1262 | + if (substr($key, -strlen(' '.$name)) == ' '.$name && $this->_getReccursiveStyle($key, $lst, $name)) { |
|
| 1263 | 1263 | return true; |
| 1264 | 1264 | } |
| 1265 | 1265 | } |
| 1266 | 1266 | |
| 1267 | 1267 | // if we are not in the first step, we analyse the sub steps (the pareng tag of the current tag) |
| 1268 | - if ($next!==null && $this->_getReccursiveStyle($key, $lst, '')) { |
|
| 1268 | + if ($next !== null && $this->_getReccursiveStyle($key, $lst, '')) { |
|
| 1269 | 1269 | return true; |
| 1270 | 1270 | } |
| 1271 | 1271 | |
@@ -1304,7 +1304,7 @@ discard block |
||
| 1304 | 1304 | foreach ($css as $value) { |
| 1305 | 1305 | |
| 1306 | 1306 | // if no border => return none |
| 1307 | - if ($value=='none' || $value=='hidden') { |
|
| 1307 | + if ($value == 'none' || $value == 'hidden') { |
|
| 1308 | 1308 | return $none; |
| 1309 | 1309 | } |
| 1310 | 1310 | |
@@ -1312,7 +1312,7 @@ discard block |
||
| 1312 | 1312 | $tmp = $this->convertToMM($value); |
| 1313 | 1313 | |
| 1314 | 1314 | // if the convert is ok => it is a width |
| 1315 | - if ($tmp!==null) { |
|
| 1315 | + if ($tmp !== null) { |
|
| 1316 | 1316 | $width = $tmp; |
| 1317 | 1317 | // else, it could be the type |
| 1318 | 1318 | } else if (in_array($value, array('solid', 'dotted', 'dashed', 'double'))) { |
@@ -1325,7 +1325,7 @@ discard block |
||
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | 1327 | // if no witdh => return none |
| 1328 | - if (!$width) return $none; |
|
| 1328 | + if ( ! $width) return $none; |
|
| 1329 | 1329 | |
| 1330 | 1330 | // return the border properties |
| 1331 | 1331 | return array('type' => $type, 'width' => $width, 'color' => $color); |
@@ -1340,16 +1340,16 @@ discard block |
||
| 1340 | 1340 | protected function _duplicateBorder(&$val) |
| 1341 | 1341 | { |
| 1342 | 1342 | // 1 value => L => RTB |
| 1343 | - if (count($val)==1) { |
|
| 1343 | + if (count($val) == 1) { |
|
| 1344 | 1344 | $val[1] = $val[0]; |
| 1345 | 1345 | $val[2] = $val[0]; |
| 1346 | 1346 | $val[3] = $val[0]; |
| 1347 | 1347 | // 2 values => L => R & T => B |
| 1348 | - } else if (count($val)==2) { |
|
| 1348 | + } else if (count($val) == 2) { |
|
| 1349 | 1349 | $val[2] = $val[0]; |
| 1350 | 1350 | $val[3] = $val[1]; |
| 1351 | 1351 | // 3 values => T => B |
| 1352 | - } else if (count($val)==3) { |
|
| 1352 | + } else if (count($val) == 3) { |
|
| 1353 | 1353 | $val[3] = $val[1]; |
| 1354 | 1354 | } |
| 1355 | 1355 | } |
@@ -1393,7 +1393,7 @@ discard block |
||
| 1393 | 1393 | if ($ok) { |
| 1394 | 1394 | $value['color'] = $color; |
| 1395 | 1395 | // else if transparent => no coloàr |
| 1396 | - } else if ($val=='transparent') { |
|
| 1396 | + } else if ($val == 'transparent') { |
|
| 1397 | 1397 | $value['color'] = null; |
| 1398 | 1398 | // else |
| 1399 | 1399 | } else { |
@@ -1405,7 +1405,7 @@ discard block |
||
| 1405 | 1405 | $value['repeat'] = $repeat; |
| 1406 | 1406 | // else => it could only be a position |
| 1407 | 1407 | } else { |
| 1408 | - $pos.= ($pos ? ' ' : '').$val; |
|
| 1408 | + $pos .= ($pos ? ' ' : '').$val; |
|
| 1409 | 1409 | } |
| 1410 | 1410 | } |
| 1411 | 1411 | } |
@@ -1428,7 +1428,7 @@ discard block |
||
| 1428 | 1428 | public function convertBackgroundColor($css) |
| 1429 | 1429 | { |
| 1430 | 1430 | $res = null; |
| 1431 | - if ($css=='transparent') return null; |
|
| 1431 | + if ($css == 'transparent') return null; |
|
| 1432 | 1432 | else return $this->convertToColor($css, $res); |
| 1433 | 1433 | } |
| 1434 | 1434 | |
@@ -1441,7 +1441,7 @@ discard block |
||
| 1441 | 1441 | */ |
| 1442 | 1442 | public function convertBackgroundImage($css) |
| 1443 | 1443 | { |
| 1444 | - if ($css=='none') |
|
| 1444 | + if ($css == 'none') |
|
| 1445 | 1445 | return null; |
| 1446 | 1446 | else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match)) |
| 1447 | 1447 | return $match[1]; |
@@ -1466,11 +1466,11 @@ discard block |
||
| 1466 | 1466 | $css = explode(' ', $css); |
| 1467 | 1467 | |
| 1468 | 1468 | // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2 |
| 1469 | - if (count($css)<2) { |
|
| 1470 | - if (!$css[0]) return null; |
|
| 1469 | + if (count($css) < 2) { |
|
| 1470 | + if ( ! $css[0]) return null; |
|
| 1471 | 1471 | $css[1] = 'center'; |
| 1472 | 1472 | } |
| 1473 | - if (count($css)>2) return null; |
|
| 1473 | + if (count($css) > 2) return null; |
|
| 1474 | 1474 | |
| 1475 | 1475 | // prepare the values |
| 1476 | 1476 | $x = 0; |
@@ -1478,21 +1478,21 @@ discard block |
||
| 1478 | 1478 | $res = true; |
| 1479 | 1479 | |
| 1480 | 1480 | // convert the first value |
| 1481 | - if ($css[0]=='left') $x = '0%'; |
|
| 1482 | - else if ($css[0]=='center') $x = '50%'; |
|
| 1483 | - else if ($css[0]=='right') $x = '100%'; |
|
| 1484 | - else if ($css[0]=='top') $y = '0%'; |
|
| 1485 | - else if ($css[0]=='bottom') $y = '100%'; |
|
| 1481 | + if ($css[0] == 'left') $x = '0%'; |
|
| 1482 | + else if ($css[0] == 'center') $x = '50%'; |
|
| 1483 | + else if ($css[0] == 'right') $x = '100%'; |
|
| 1484 | + else if ($css[0] == 'top') $y = '0%'; |
|
| 1485 | + else if ($css[0] == 'bottom') $y = '100%'; |
|
| 1486 | 1486 | else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0]; |
| 1487 | 1487 | else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]); |
| 1488 | 1488 | else $res = false; |
| 1489 | 1489 | |
| 1490 | 1490 | // convert the second value |
| 1491 | - if ($css[1]=='left') $x = '0%'; |
|
| 1492 | - else if ($css[1]=='right') $x = '100%'; |
|
| 1493 | - else if ($css[1]=='top') $y = '0%'; |
|
| 1494 | - else if ($css[1]=='center') $y = '50%'; |
|
| 1495 | - else if ($css[1]=='bottom') $y = '100%'; |
|
| 1491 | + if ($css[1] == 'left') $x = '0%'; |
|
| 1492 | + else if ($css[1] == 'right') $x = '100%'; |
|
| 1493 | + else if ($css[1] == 'top') $y = '0%'; |
|
| 1494 | + else if ($css[1] == 'center') $y = '50%'; |
|
| 1495 | + else if ($css[1] == 'bottom') $y = '100%'; |
|
| 1496 | 1496 | else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1]; |
| 1497 | 1497 | else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]); |
| 1498 | 1498 | else $res = false; |
@@ -1510,7 +1510,7 @@ discard block |
||
| 1510 | 1510 | */ |
| 1511 | 1511 | public function convertBackgroundRepeat($css) |
| 1512 | 1512 | { |
| 1513 | - switch($css) |
|
| 1513 | + switch ($css) |
|
| 1514 | 1514 | { |
| 1515 | 1515 | case 'repeat': |
| 1516 | 1516 | return array(true, true); |
@@ -1532,15 +1532,15 @@ discard block |
||
| 1532 | 1532 | * @param float $old parent distance |
| 1533 | 1533 | * @return float $value |
| 1534 | 1534 | */ |
| 1535 | - public function convertToMM($css, $old=0.) |
|
| 1535 | + public function convertToMM($css, $old = 0.) |
|
| 1536 | 1536 | { |
| 1537 | 1537 | $css = trim($css); |
| 1538 | - if (preg_match('/^[0-9\.\-]+$/isU', $css)) $css.= 'px'; |
|
| 1539 | - if (preg_match('/^[0-9\.\-]+px$/isU', $css)) $css = 25.4/96. * str_replace('px', '', $css); |
|
| 1540 | - else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css); |
|
| 1538 | + if (preg_match('/^[0-9\.\-]+$/isU', $css)) $css .= 'px'; |
|
| 1539 | + if (preg_match('/^[0-9\.\-]+px$/isU', $css)) $css = 25.4 / 96. * str_replace('px', '', $css); |
|
| 1540 | + else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4 / 72. * str_replace('pt', '', $css); |
|
| 1541 | 1541 | else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css); |
| 1542 | - else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css); |
|
| 1543 | - else if (preg_match('/^[0-9\.\-]+%$/isU', $css)) $css = 1.*$old*str_replace('%', '', $css)/100.; |
|
| 1542 | + else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1. * str_replace('mm', '', $css); |
|
| 1543 | + else if (preg_match('/^[0-9\.\-]+%$/isU', $css)) $css = 1. * $old * str_replace('%', '', $css) / 100.; |
|
| 1544 | 1544 | else $css = null; |
| 1545 | 1545 | |
| 1546 | 1546 | return $css; |
@@ -1562,7 +1562,7 @@ discard block |
||
| 1562 | 1562 | $v = trim($v); |
| 1563 | 1563 | if ($v) { |
| 1564 | 1564 | $v = $this->convertToMM($v, 0); |
| 1565 | - if ($v!==null) { |
|
| 1565 | + if ($v !== null) { |
|
| 1566 | 1566 | $css[$k] = $v; |
| 1567 | 1567 | } else { |
| 1568 | 1568 | unset($css[$k]); |
@@ -1590,7 +1590,7 @@ discard block |
||
| 1590 | 1590 | $res = true; |
| 1591 | 1591 | |
| 1592 | 1592 | // if transparent => return null |
| 1593 | - if (strtolower($css)=='transparent') return array(null, null, null); |
|
| 1593 | + if (strtolower($css) == 'transparent') return array(null, null, null); |
|
| 1594 | 1594 | |
| 1595 | 1595 | // HTML color |
| 1596 | 1596 | if (isset($this->_htmlColor[strtolower($css)])) { |
@@ -1622,7 +1622,7 @@ discard block |
||
| 1622 | 1622 | $r = $this->_convertSubColor($match[1]); |
| 1623 | 1623 | $v = $this->_convertSubColor($match[2]); |
| 1624 | 1624 | $b = $this->_convertSubColor($match[3]); |
| 1625 | - return array($r*255., $v*255., $b*255.); |
|
| 1625 | + return array($r * 255., $v * 255., $b * 255.); |
|
| 1626 | 1626 | } |
| 1627 | 1627 | |
| 1628 | 1628 | // like cmyk(100, 100, 100, 100) |
@@ -1631,7 +1631,7 @@ discard block |
||
| 1631 | 1631 | $m = $this->_convertSubColor($match[2]); |
| 1632 | 1632 | $y = $this->_convertSubColor($match[3]); |
| 1633 | 1633 | $k = $this->_convertSubColor($match[4]); |
| 1634 | - return array($c*100., $m*100., $y*100., $k*100.); |
|
| 1634 | + return array($c * 100., $m * 100., $y * 100., $k * 100.); |
|
| 1635 | 1635 | } |
| 1636 | 1636 | |
| 1637 | 1637 | $res = false; |
@@ -1647,11 +1647,11 @@ discard block |
||
| 1647 | 1647 | */ |
| 1648 | 1648 | protected function _convertSubColor($c) |
| 1649 | 1649 | { |
| 1650 | - if (substr($c, -1)=='%') { |
|
| 1651 | - $c = floatVal(substr($c, 0, -1))/100.; |
|
| 1650 | + if (substr($c, -1) == '%') { |
|
| 1651 | + $c = floatVal(substr($c, 0, -1)) / 100.; |
|
| 1652 | 1652 | } else { |
| 1653 | 1653 | $c = floatVal($c); |
| 1654 | - if ($c>1) $c = $c/255.; |
|
| 1654 | + if ($c > 1) $c = $c / 255.; |
|
| 1655 | 1655 | } |
| 1656 | 1656 | |
| 1657 | 1657 | return $c; |
@@ -1675,7 +1675,7 @@ discard block |
||
| 1675 | 1675 | preg_match_all('/([^{}]+){([^}]*)}/isU', $code, $match); |
| 1676 | 1676 | |
| 1677 | 1677 | // for each CSS code |
| 1678 | - for ($k=0; $k<count($match[0]); $k++) { |
|
| 1678 | + for ($k = 0; $k < count($match[0]); $k++) { |
|
| 1679 | 1679 | |
| 1680 | 1680 | // selectors |
| 1681 | 1681 | $names = strtolower(trim($match[1][$k])); |
@@ -1690,7 +1690,7 @@ discard block |
||
| 1690 | 1690 | $css = array(); |
| 1691 | 1691 | foreach ($styles as $style) { |
| 1692 | 1692 | $tmp = explode(':', $style); |
| 1693 | - if (count($tmp)>1) { |
|
| 1693 | + if (count($tmp) > 1) { |
|
| 1694 | 1694 | $cod = $tmp[0]; unset($tmp[0]); $tmp = implode(':', $tmp); |
| 1695 | 1695 | $css[trim(strtolower($cod))] = trim($tmp); |
| 1696 | 1696 | } |
@@ -1705,10 +1705,10 @@ discard block |
||
| 1705 | 1705 | $name = trim($name); |
| 1706 | 1706 | |
| 1707 | 1707 | // if a selector with somethink lige :hover => continue |
| 1708 | - if (strpos($name, ':')!==false) continue; |
|
| 1708 | + if (strpos($name, ':') !== false) continue; |
|
| 1709 | 1709 | |
| 1710 | 1710 | // save the value |
| 1711 | - if (!isset($this->css[$name])) |
|
| 1711 | + if ( ! isset($this->css[$name])) |
|
| 1712 | 1712 | $this->css[$name] = $css; |
| 1713 | 1713 | else |
| 1714 | 1714 | $this->css[$name] = array_merge($this->css[$name], $css); |
@@ -1743,26 +1743,26 @@ discard block |
||
| 1743 | 1743 | // read the attributes name=value |
| 1744 | 1744 | $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)'; |
| 1745 | 1745 | preg_match_all('/'.$prop.'/is', $code, $match); |
| 1746 | - for ($k=0; $k<count($match[0]); $k++) { |
|
| 1746 | + for ($k = 0; $k < count($match[0]); $k++) { |
|
| 1747 | 1747 | $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | 1750 | // read the attributes name="value" |
| 1751 | 1751 | $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]'; |
| 1752 | 1752 | preg_match_all('/'.$prop.'/is', $code, $match); |
| 1753 | - for ($k=0; $k<count($match[0]); $k++) { |
|
| 1753 | + for ($k = 0; $k < count($match[0]); $k++) { |
|
| 1754 | 1754 | $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
| 1755 | 1755 | } |
| 1756 | 1756 | |
| 1757 | 1757 | // read the attributes name='value' |
| 1758 | 1758 | $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']"; |
| 1759 | 1759 | preg_match_all('/'.$prop.'/is', $code, $match); |
| 1760 | - for ($k=0; $k<count($match[0]); $k++) { |
|
| 1760 | + for ($k = 0; $k < count($match[0]); $k++) { |
|
| 1761 | 1761 | $tmp[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
| 1762 | 1762 | } |
| 1763 | 1763 | |
| 1764 | 1764 | // if type text/css => we keep it |
| 1765 | - if (isset($tmp['type']) && strtolower($tmp['type'])=='text/css' && isset($tmp['href'])) { |
|
| 1765 | + if (isset($tmp['type']) && strtolower($tmp['type']) == 'text/css' && isset($tmp['href'])) { |
|
| 1766 | 1766 | |
| 1767 | 1767 | // get the href |
| 1768 | 1768 | $url = $tmp['href']; |
@@ -1771,7 +1771,7 @@ discard block |
||
| 1771 | 1771 | $content = @file_get_contents($url); |
| 1772 | 1772 | |
| 1773 | 1773 | // if "http://" in the url |
| 1774 | - if (strpos($url, 'http://')!==false) { |
|
| 1774 | + if (strpos($url, 'http://') !== false) { |
|
| 1775 | 1775 | |
| 1776 | 1776 | // get the domain "http://xxx/" |
| 1777 | 1777 | $url = str_replace('http://', '', $url); |
@@ -1779,7 +1779,7 @@ discard block |
||
| 1779 | 1779 | $urlMain = 'http://'.$url[0].'/'; |
| 1780 | 1780 | |
| 1781 | 1781 | // get the absolute url of the path |
| 1782 | - $urlSelf = $url; unset($urlSelf[count($urlSelf)-1]); $urlSelf = 'http://'.implode('/', $urlSelf).'/'; |
|
| 1782 | + $urlSelf = $url; unset($urlSelf[count($urlSelf) - 1]); $urlSelf = 'http://'.implode('/', $urlSelf).'/'; |
|
| 1783 | 1783 | |
| 1784 | 1784 | // adapt the url in the css content |
| 1785 | 1785 | $content = preg_replace('/url\(([^\\\\][^)]*)\)/isU', 'url('.$urlSelf.'$1)', $content); |
@@ -1790,7 +1790,7 @@ discard block |
||
| 1790 | 1790 | } |
| 1791 | 1791 | |
| 1792 | 1792 | // add to the CSS content |
| 1793 | - $style.= $content."\n"; |
|
| 1793 | + $style .= $content."\n"; |
|
| 1794 | 1794 | } |
| 1795 | 1795 | } |
| 1796 | 1796 | |
@@ -1803,7 +1803,7 @@ discard block |
||
| 1803 | 1803 | // add to the CSS content |
| 1804 | 1804 | $code = str_replace('<!--', '', $code); |
| 1805 | 1805 | $code = str_replace('-->', '', $code); |
| 1806 | - $style.= $code."\n"; |
|
| 1806 | + $style .= $code."\n"; |
|
| 1807 | 1807 | } |
| 1808 | 1808 | |
| 1809 | 1809 | //analyse the css content |
@@ -82,7 +82,9 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | $old = $this->_defaultFont; |
| 84 | 84 | $this->_defaultFont = $default; |
| 85 | - if ($default) $this->value['font-family'] = $default; |
|
| 85 | + if ($default) { |
|
| 86 | + $this->value['font-family'] = $default; |
|
| 87 | + } |
|
| 86 | 88 | return $old; |
| 87 | 89 | } |
| 88 | 90 | |
@@ -179,7 +181,9 @@ discard block |
||
| 179 | 181 | |
| 180 | 182 | // prepare the Collapse attribute |
| 181 | 183 | $collapse = isset($this->value['border']['collapse']) ? $this->value['border']['collapse'] : false; |
| 182 | - if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) $collapse = false; |
|
| 184 | + if (!in_array($tagName, array('tr', 'td', 'th', 'thead', 'tbody', 'tfoot'))) { |
|
| 185 | + $collapse = false; |
|
| 186 | + } |
|
| 183 | 187 | |
| 184 | 188 | // set the global css values |
| 185 | 189 | $this->value['position'] = null; |
@@ -315,20 +319,23 @@ discard block |
||
| 315 | 319 | $style = $b.$i; |
| 316 | 320 | |
| 317 | 321 | if ($this->_defaultFont) { |
| 318 | - if($family=='arial') |
|
| 319 | - $family='helvetica'; |
|
| 320 | - elseif($family=='symbol' || $family=='zapfdingbats') |
|
| 321 | - $style=''; |
|
| 322 | + if($family=='arial') { |
|
| 323 | + $family='helvetica'; |
|
| 324 | + } elseif($family=='symbol' || $family=='zapfdingbats') { |
|
| 325 | + $style=''; |
|
| 326 | + } |
|
| 322 | 327 | |
| 323 | 328 | $fontkey = $family.$style; |
| 324 | - if (!$this->_pdf->isLoadedFont($fontkey)) |
|
| 325 | - $family = $this->_defaultFont; |
|
| 329 | + if (!$this->_pdf->isLoadedFont($fontkey)) { |
|
| 330 | + $family = $this->_defaultFont; |
|
| 331 | + } |
|
| 326 | 332 | } |
| 327 | 333 | |
| 328 | - if($family=='arial') |
|
| 329 | - $family='helvetica'; |
|
| 330 | - elseif($family=='symbol' || $family=='zapfdingbats') |
|
| 331 | - $style=''; |
|
| 334 | + if($family=='arial') { |
|
| 335 | + $family='helvetica'; |
|
| 336 | + } elseif($family=='symbol' || $family=='zapfdingbats') { |
|
| 337 | + $style=''; |
|
| 338 | + } |
|
| 332 | 339 | |
| 333 | 340 | // complete style |
| 334 | 341 | $style.= $u.$d.$o; |
@@ -340,10 +347,11 @@ discard block |
||
| 340 | 347 | // apply the font |
| 341 | 348 | $this->_pdf->SetFont($family, $style, $this->value['mini-size']*$size); |
| 342 | 349 | $this->_pdf->setTextColorArray($this->value['color']); |
| 343 | - if ($this->value['background']['color']) |
|
| 344 | - $this->_pdf->setFillColorArray($this->value['background']['color']); |
|
| 345 | - else |
|
| 346 | - $this->_pdf->setFillColor(255); |
|
| 350 | + if ($this->value['background']['color']) { |
|
| 351 | + $this->_pdf->setFillColorArray($this->value['background']['color']); |
|
| 352 | + } else { |
|
| 353 | + $this->_pdf->setFillColor(255); |
|
| 354 | + } |
|
| 347 | 355 | } |
| 348 | 356 | |
| 349 | 357 | /** |
@@ -375,7 +383,9 @@ discard block |
||
| 375 | 383 | */ |
| 376 | 384 | public function restorePosition() |
| 377 | 385 | { |
| 378 | - if ($this->value['y']==$this->_pdf->getY()) $this->_pdf->setY($this->value['yc'], false); |
|
| 386 | + if ($this->value['y']==$this->_pdf->getY()) { |
|
| 387 | + $this->_pdf->setY($this->value['yc'], false); |
|
| 388 | + } |
|
| 379 | 389 | } |
| 380 | 390 | |
| 381 | 391 | /** |
@@ -396,18 +406,26 @@ discard block |
||
| 396 | 406 | if ($this->value['position']=='relative' || $this->value['position']=='absolute') { |
| 397 | 407 | if ($this->value['right']!==null) { |
| 398 | 408 | $x = $this->getLastWidth(true) - $this->value['right'] - $this->value['width']; |
| 399 | - if ($this->value['margin']['r']) $x-= $this->value['margin']['r']; |
|
| 409 | + if ($this->value['margin']['r']) { |
|
| 410 | + $x-= $this->value['margin']['r']; |
|
| 411 | + } |
|
| 400 | 412 | } else { |
| 401 | 413 | $x = $this->value['left']; |
| 402 | - if ($this->value['margin']['l']) $x+= $this->value['margin']['l']; |
|
| 414 | + if ($this->value['margin']['l']) { |
|
| 415 | + $x+= $this->value['margin']['l']; |
|
| 416 | + } |
|
| 403 | 417 | } |
| 404 | 418 | |
| 405 | 419 | if ($this->value['bottom']!==null) { |
| 406 | 420 | $y = $this->getLastHeight(true) - $this->value['bottom'] - $this->value['height']; |
| 407 | - if ($this->value['margin']['b']) $y-= $this->value['margin']['b']; |
|
| 421 | + if ($this->value['margin']['b']) { |
|
| 422 | + $y-= $this->value['margin']['b']; |
|
| 423 | + } |
|
| 408 | 424 | } else { |
| 409 | 425 | $y = $this->value['top']; |
| 410 | - if ($this->value['margin']['t']) $y+= $this->value['margin']['t']; |
|
| 426 | + if ($this->value['margin']['t']) { |
|
| 427 | + $y+= $this->value['margin']['t']; |
|
| 428 | + } |
|
| 411 | 429 | } |
| 412 | 430 | |
| 413 | 431 | if ($this->value['position']=='relative') { |
@@ -420,8 +438,12 @@ discard block |
||
| 420 | 438 | } else { |
| 421 | 439 | $this->value['x'] = $currentX; |
| 422 | 440 | $this->value['y'] = $currentY; |
| 423 | - if ($this->value['margin']['l']) $this->value['x']+= $this->value['margin']['l']; |
|
| 424 | - if ($this->value['margin']['t']) $this->value['y']+= $this->value['margin']['t']; |
|
| 441 | + if ($this->value['margin']['l']) { |
|
| 442 | + $this->value['x']+= $this->value['margin']['l']; |
|
| 443 | + } |
|
| 444 | + if ($this->value['margin']['t']) { |
|
| 445 | + $this->value['y']+= $this->value['margin']['t']; |
|
| 446 | + } |
|
| 425 | 447 | } |
| 426 | 448 | |
| 427 | 449 | // save the new position |
@@ -478,8 +500,12 @@ discard block |
||
| 478 | 500 | { |
| 479 | 501 | // prepare |
| 480 | 502 | $tagName = strtolower($tagName); |
| 481 | - $id = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id) $id = null; |
|
| 482 | - $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null; |
|
| 503 | + $id = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id) { |
|
| 504 | + $id = null; |
|
| 505 | + } |
|
| 506 | + $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) { |
|
| 507 | + $name = null; |
|
| 508 | + } |
|
| 483 | 509 | |
| 484 | 510 | // read the class attribute |
| 485 | 511 | $class = array(); |
@@ -487,7 +513,9 @@ discard block |
||
| 487 | 513 | $tmp = explode(' ', $tmp); |
| 488 | 514 | foreach ($tmp as $k => $v) { |
| 489 | 515 | $v = trim($v); |
| 490 | - if ($v) $class[] = $v; |
|
| 516 | + if ($v) { |
|
| 517 | + $class[] = $v; |
|
| 518 | + } |
|
| 491 | 519 | } |
| 492 | 520 | |
| 493 | 521 | // identify the tag, and the direct styles |
@@ -526,10 +554,18 @@ discard block |
||
| 526 | 554 | // adding the style from the tag |
| 527 | 555 | $styles = array_merge($styles, $param['style']); |
| 528 | 556 | |
| 529 | - if (isset($styles['stroke'])) $this->value['svg']['stroke'] = $this->convertToColor($styles['stroke'], $res); |
|
| 530 | - if (isset($styles['stroke-width'])) $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']); |
|
| 531 | - if (isset($styles['fill'])) $this->value['svg']['fill'] = $this->convertToColor($styles['fill'], $res); |
|
| 532 | - if (isset($styles['fill-opacity'])) $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity']; |
|
| 557 | + if (isset($styles['stroke'])) { |
|
| 558 | + $this->value['svg']['stroke'] = $this->convertToColor($styles['stroke'], $res); |
|
| 559 | + } |
|
| 560 | + if (isset($styles['stroke-width'])) { |
|
| 561 | + $this->value['svg']['stroke-width'] = $this->convertToMM($styles['stroke-width']); |
|
| 562 | + } |
|
| 563 | + if (isset($styles['fill'])) { |
|
| 564 | + $this->value['svg']['fill'] = $this->convertToColor($styles['fill'], $res); |
|
| 565 | + } |
|
| 566 | + if (isset($styles['fill-opacity'])) { |
|
| 567 | + $this->value['svg']['fill-opacity'] = 1.*$styles['fill-opacity']; |
|
| 568 | + } |
|
| 533 | 569 | |
| 534 | 570 | return $this->value['svg']; |
| 535 | 571 | } |
@@ -546,8 +582,12 @@ discard block |
||
| 546 | 582 | { |
| 547 | 583 | // prepare the informations |
| 548 | 584 | $tagName = strtolower($tagName); |
| 549 | - $id = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id) $id = null; |
|
| 550 | - $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) $name = null; |
|
| 585 | + $id = isset($param['id']) ? strtolower(trim($param['id'])) : null; if (!$id) { |
|
| 586 | + $id = null; |
|
| 587 | + } |
|
| 588 | + $name = isset($param['name']) ? strtolower(trim($param['name'])) : null; if (!$name) { |
|
| 589 | + $name = null; |
|
| 590 | + } |
|
| 551 | 591 | |
| 552 | 592 | // get the class names to use |
| 553 | 593 | $class = array(); |
@@ -555,7 +595,9 @@ discard block |
||
| 555 | 595 | $tmp = explode(' ', $tmp); |
| 556 | 596 | foreach ($tmp as $k => $v) { |
| 557 | 597 | $v = trim($v); |
| 558 | - if ($v) $class[] = $v; |
|
| 598 | + if ($v) { |
|
| 599 | + $class[] = $v; |
|
| 600 | + } |
|
| 559 | 601 | } |
| 560 | 602 | |
| 561 | 603 | // prepare the values, and the list of css tags to identify |
@@ -584,7 +626,9 @@ discard block |
||
| 584 | 626 | |
| 585 | 627 | // merge with the css styles from tag |
| 586 | 628 | $styles = array_merge($styles, $param['style']); |
| 587 | - if (isset($param['allwidth']) && !isset($styles['width'])) $styles['width'] = '100%'; |
|
| 629 | + if (isset($param['allwidth']) && !isset($styles['width'])) { |
|
| 630 | + $styles['width'] = '100%'; |
|
| 631 | + } |
|
| 588 | 632 | |
| 589 | 633 | // reset some styles, depending on the tag name |
| 590 | 634 | $this->resetStyle($tagName); |
@@ -593,8 +637,9 @@ discard block |
||
| 593 | 637 | if ($legacy) { |
| 594 | 638 | foreach ($legacy as $legacyName => $legacyValue) { |
| 595 | 639 | if (is_array($legacyValue)) { |
| 596 | - foreach($legacyValue as $legacy2Name => $legacy2Value) |
|
| 597 | - $this->value[$legacyName][$legacy2Name] = $legacy2Value; |
|
| 640 | + foreach($legacyValue as $legacy2Name => $legacy2Value) { |
|
| 641 | + $this->value[$legacyName][$legacy2Name] = $legacy2Value; |
|
| 642 | + } |
|
| 598 | 643 | } else { |
| 599 | 644 | $this->value[$legacyName] = $legacyValue; |
| 600 | 645 | } |
@@ -612,7 +657,9 @@ discard block |
||
| 612 | 657 | case 'font-family': |
| 613 | 658 | $val = explode(',', $val); |
| 614 | 659 | $val = trim($val[0]); |
| 615 | - if ($val) $this->value['font-family'] = $val; |
|
| 660 | + if ($val) { |
|
| 661 | + $this->value['font-family'] = $val; |
|
| 662 | + } |
|
| 616 | 663 | break; |
| 617 | 664 | |
| 618 | 665 | case 'font-weight': |
@@ -635,13 +682,17 @@ discard block |
||
| 635 | 682 | break; |
| 636 | 683 | |
| 637 | 684 | case 'text-transform': |
| 638 | - if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) $val = 'none'; |
|
| 685 | + if (!in_array($val, array('none', 'capitalize', 'uppercase', 'lowercase'))) { |
|
| 686 | + $val = 'none'; |
|
| 687 | + } |
|
| 639 | 688 | $this->value['text-transform'] = $val; |
| 640 | 689 | break; |
| 641 | 690 | |
| 642 | 691 | case 'font-size': |
| 643 | 692 | $val = $this->convertToMM($val, $this->value['font-size']); |
| 644 | - if ($val) $this->value['font-size'] = $val; |
|
| 693 | + if ($val) { |
|
| 694 | + $this->value['font-size'] = $val; |
|
| 695 | + } |
|
| 645 | 696 | break; |
| 646 | 697 | |
| 647 | 698 | case 'color': |
@@ -657,7 +708,9 @@ discard block |
||
| 657 | 708 | |
| 658 | 709 | case 'text-align': |
| 659 | 710 | $val = strtolower($val); |
| 660 | - if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) $val = 'left'; |
|
| 711 | + if (!in_array($val, array('left', 'right', 'center', 'justify', 'li_right'))) { |
|
| 712 | + $val = 'left'; |
|
| 713 | + } |
|
| 661 | 714 | $this->value['text-align'] = $val; |
| 662 | 715 | break; |
| 663 | 716 | |
@@ -667,7 +720,9 @@ discard block |
||
| 667 | 720 | |
| 668 | 721 | case 'width': |
| 669 | 722 | $this->value['width'] = $this->convertToMM($val, $this->getLastWidth()); |
| 670 | - if ($this->value['width'] && substr($val, -1)=='%') $correctWidth=true; |
|
| 723 | + if ($this->value['width'] && substr($val, -1)=='%') { |
|
| 724 | + $correctWidth=true; |
|
| 725 | + } |
|
| 671 | 726 | $noWidth = false; |
| 672 | 727 | break; |
| 673 | 728 | |
@@ -676,18 +731,26 @@ discard block |
||
| 676 | 731 | break; |
| 677 | 732 | |
| 678 | 733 | case 'line-height': |
| 679 | - if (preg_match('/^[0-9\.]+$/isU', $val)) $val = floor($val*100).'%'; |
|
| 734 | + if (preg_match('/^[0-9\.]+$/isU', $val)) { |
|
| 735 | + $val = floor($val*100).'%'; |
|
| 736 | + } |
|
| 680 | 737 | $this->value['line-height'] = $val; |
| 681 | 738 | break; |
| 682 | 739 | |
| 683 | 740 | case 'rotate': |
| 684 | - if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) $val = null; |
|
| 685 | - if ($val<0) $val+= 360; |
|
| 741 | + if (!in_array($val, array(0, -90, 90, 180, 270, -180, -270))) { |
|
| 742 | + $val = null; |
|
| 743 | + } |
|
| 744 | + if ($val<0) { |
|
| 745 | + $val+= 360; |
|
| 746 | + } |
|
| 686 | 747 | $this->value['rotate'] = $val; |
| 687 | 748 | break; |
| 688 | 749 | |
| 689 | 750 | case 'overflow': |
| 690 | - if (!in_array($val, array('visible', 'hidden'))) $val = 'visible'; |
|
| 751 | + if (!in_array($val, array('visible', 'hidden'))) { |
|
| 752 | + $val = 'visible'; |
|
| 753 | + } |
|
| 691 | 754 | $this->value['overflow'] = $val; |
| 692 | 755 | break; |
| 693 | 756 | |
@@ -779,10 +842,18 @@ discard block |
||
| 779 | 842 | } |
| 780 | 843 | } |
| 781 | 844 | $this->_duplicateBorder($val); |
| 782 | - if ($val[0]) $this->value['border']['t']['type'] = $val[0]; |
|
| 783 | - if ($val[1]) $this->value['border']['r']['type'] = $val[1]; |
|
| 784 | - if ($val[2]) $this->value['border']['b']['type'] = $val[2]; |
|
| 785 | - if ($val[3]) $this->value['border']['l']['type'] = $val[3]; |
|
| 845 | + if ($val[0]) { |
|
| 846 | + $this->value['border']['t']['type'] = $val[0]; |
|
| 847 | + } |
|
| 848 | + if ($val[1]) { |
|
| 849 | + $this->value['border']['r']['type'] = $val[1]; |
|
| 850 | + } |
|
| 851 | + if ($val[2]) { |
|
| 852 | + $this->value['border']['b']['type'] = $val[2]; |
|
| 853 | + } |
|
| 854 | + if ($val[3]) { |
|
| 855 | + $this->value['border']['l']['type'] = $val[3]; |
|
| 856 | + } |
|
| 786 | 857 | break; |
| 787 | 858 | |
| 788 | 859 | case 'border-top-style': |
@@ -804,8 +875,9 @@ discard block |
||
| 804 | 875 | break; |
| 805 | 876 | |
| 806 | 877 | case 'border-left-style': |
| 807 | - if (in_array($val, array('solid', 'dotted', 'dashed'))) |
|
| 808 | - $this->value['border']['l']['type'] = $val; |
|
| 878 | + if (in_array($val, array('solid', 'dotted', 'dashed'))) { |
|
| 879 | + $this->value['border']['l']['type'] = $val; |
|
| 880 | + } |
|
| 809 | 881 | break; |
| 810 | 882 | |
| 811 | 883 | case 'border-color': |
@@ -819,35 +891,51 @@ discard block |
||
| 819 | 891 | } |
| 820 | 892 | } |
| 821 | 893 | $this->_duplicateBorder($val); |
| 822 | - if (is_array($val[0])) $this->value['border']['t']['color'] = $val[0]; |
|
| 823 | - if (is_array($val[1])) $this->value['border']['r']['color'] = $val[1]; |
|
| 824 | - if (is_array($val[2])) $this->value['border']['b']['color'] = $val[2]; |
|
| 825 | - if (is_array($val[3])) $this->value['border']['l']['color'] = $val[3]; |
|
| 894 | + if (is_array($val[0])) { |
|
| 895 | + $this->value['border']['t']['color'] = $val[0]; |
|
| 896 | + } |
|
| 897 | + if (is_array($val[1])) { |
|
| 898 | + $this->value['border']['r']['color'] = $val[1]; |
|
| 899 | + } |
|
| 900 | + if (is_array($val[2])) { |
|
| 901 | + $this->value['border']['b']['color'] = $val[2]; |
|
| 902 | + } |
|
| 903 | + if (is_array($val[3])) { |
|
| 904 | + $this->value['border']['l']['color'] = $val[3]; |
|
| 905 | + } |
|
| 826 | 906 | |
| 827 | 907 | break; |
| 828 | 908 | |
| 829 | 909 | case 'border-top-color': |
| 830 | 910 | $res = false; |
| 831 | 911 | $val = $this->convertToColor($val, $res); |
| 832 | - if ($res) $this->value['border']['t']['color'] = $val; |
|
| 912 | + if ($res) { |
|
| 913 | + $this->value['border']['t']['color'] = $val; |
|
| 914 | + } |
|
| 833 | 915 | break; |
| 834 | 916 | |
| 835 | 917 | case 'border-right-color': |
| 836 | 918 | $res = false; |
| 837 | 919 | $val = $this->convertToColor($val, $res); |
| 838 | - if ($res) $this->value['border']['r']['color'] = $val; |
|
| 920 | + if ($res) { |
|
| 921 | + $this->value['border']['r']['color'] = $val; |
|
| 922 | + } |
|
| 839 | 923 | break; |
| 840 | 924 | |
| 841 | 925 | case 'border-bottom-color': |
| 842 | 926 | $res = false; |
| 843 | 927 | $val = $this->convertToColor($val, $res); |
| 844 | - if ($res) $this->value['border']['b']['color'] = $val; |
|
| 928 | + if ($res) { |
|
| 929 | + $this->value['border']['b']['color'] = $val; |
|
| 930 | + } |
|
| 845 | 931 | break; |
| 846 | 932 | |
| 847 | 933 | case 'border-left-color': |
| 848 | 934 | $res = false; |
| 849 | 935 | $val = $this->convertToColor($val, $res); |
| 850 | - if ($res) $this->value['border']['l']['color'] = $val; |
|
| 936 | + if ($res) { |
|
| 937 | + $this->value['border']['l']['color'] = $val; |
|
| 938 | + } |
|
| 851 | 939 | break; |
| 852 | 940 | |
| 853 | 941 | case 'border-width': |
@@ -856,34 +944,52 @@ discard block |
||
| 856 | 944 | $val[$valK] = $this->convertToMM($valV, 0); |
| 857 | 945 | } |
| 858 | 946 | $this->_duplicateBorder($val); |
| 859 | - if ($val[0]) $this->value['border']['t']['width'] = $val[0]; |
|
| 860 | - if ($val[1]) $this->value['border']['r']['width'] = $val[1]; |
|
| 861 | - if ($val[2]) $this->value['border']['b']['width'] = $val[2]; |
|
| 862 | - if ($val[3]) $this->value['border']['l']['width'] = $val[3]; |
|
| 947 | + if ($val[0]) { |
|
| 948 | + $this->value['border']['t']['width'] = $val[0]; |
|
| 949 | + } |
|
| 950 | + if ($val[1]) { |
|
| 951 | + $this->value['border']['r']['width'] = $val[1]; |
|
| 952 | + } |
|
| 953 | + if ($val[2]) { |
|
| 954 | + $this->value['border']['b']['width'] = $val[2]; |
|
| 955 | + } |
|
| 956 | + if ($val[3]) { |
|
| 957 | + $this->value['border']['l']['width'] = $val[3]; |
|
| 958 | + } |
|
| 863 | 959 | break; |
| 864 | 960 | |
| 865 | 961 | case 'border-top-width': |
| 866 | 962 | $val = $this->convertToMM($val, 0); |
| 867 | - if ($val) $this->value['border']['t']['width'] = $val; |
|
| 963 | + if ($val) { |
|
| 964 | + $this->value['border']['t']['width'] = $val; |
|
| 965 | + } |
|
| 868 | 966 | break; |
| 869 | 967 | |
| 870 | 968 | case 'border-right-width': |
| 871 | 969 | $val = $this->convertToMM($val, 0); |
| 872 | - if ($val) $this->value['border']['r']['width'] = $val; |
|
| 970 | + if ($val) { |
|
| 971 | + $this->value['border']['r']['width'] = $val; |
|
| 972 | + } |
|
| 873 | 973 | break; |
| 874 | 974 | |
| 875 | 975 | case 'border-bottom-width': |
| 876 | 976 | $val = $this->convertToMM($val, 0); |
| 877 | - if ($val) $this->value['border']['b']['width'] = $val; |
|
| 977 | + if ($val) { |
|
| 978 | + $this->value['border']['b']['width'] = $val; |
|
| 979 | + } |
|
| 878 | 980 | break; |
| 879 | 981 | |
| 880 | 982 | case 'border-left-width': |
| 881 | 983 | $val = $this->convertToMM($val, 0); |
| 882 | - if ($val) $this->value['border']['l']['width'] = $val; |
|
| 984 | + if ($val) { |
|
| 985 | + $this->value['border']['l']['width'] = $val; |
|
| 986 | + } |
|
| 883 | 987 | break; |
| 884 | 988 | |
| 885 | 989 | case 'border-collapse': |
| 886 | - if ($tagName=='table') $this->value['border']['collapse'] = ($val=='collapse'); |
|
| 990 | + if ($tagName=='table') { |
|
| 991 | + $this->value['border']['collapse'] = ($val=='collapse'); |
|
| 992 | + } |
|
| 887 | 993 | break; |
| 888 | 994 | |
| 889 | 995 | case 'border-radius': |
@@ -895,17 +1001,29 @@ discard block |
||
| 895 | 1001 | if (count($valH)<1 || count($valH)>4) { |
| 896 | 1002 | break; |
| 897 | 1003 | } |
| 898 | - if (!isset($valH[1])) $valH[1] = $valH[0]; |
|
| 899 | - if (!isset($valH[2])) $valH = array($valH[0], $valH[0], $valH[1], $valH[1]); |
|
| 900 | - if (!isset($valH[3])) $valH[3] = $valH[1]; |
|
| 1004 | + if (!isset($valH[1])) { |
|
| 1005 | + $valH[1] = $valH[0]; |
|
| 1006 | + } |
|
| 1007 | + if (!isset($valH[2])) { |
|
| 1008 | + $valH = array($valH[0], $valH[0], $valH[1], $valH[1]); |
|
| 1009 | + } |
|
| 1010 | + if (!isset($valH[3])) { |
|
| 1011 | + $valH[3] = $valH[1]; |
|
| 1012 | + } |
|
| 901 | 1013 | if (isset($val[1])) { |
| 902 | 1014 | $valV = $this->convertToRadius(trim($val[1])); |
| 903 | 1015 | if (count($valV)<1 || count($valV)>4) { |
| 904 | 1016 | break; |
| 905 | 1017 | } |
| 906 | - if (!isset($valV[1])) $valV[1] = $valV[0]; |
|
| 907 | - if (!isset($valV[2])) $valV = array($valV[0], $valV[0], $valV[1], $valV[1]); |
|
| 908 | - if (!isset($valV[3])) $valV[3] = $valV[1]; |
|
| 1018 | + if (!isset($valV[1])) { |
|
| 1019 | + $valV[1] = $valV[0]; |
|
| 1020 | + } |
|
| 1021 | + if (!isset($valV[2])) { |
|
| 1022 | + $valV = array($valV[0], $valV[0], $valV[1], $valV[1]); |
|
| 1023 | + } |
|
| 1024 | + if (!isset($valV[3])) { |
|
| 1025 | + $valV[3] = $valV[1]; |
|
| 1026 | + } |
|
| 909 | 1027 | } else { |
| 910 | 1028 | $valV = $valH; |
| 911 | 1029 | } |
@@ -987,22 +1105,35 @@ discard block |
||
| 987 | 1105 | break; |
| 988 | 1106 | |
| 989 | 1107 | case 'position': |
| 990 | - if ($val=='absolute') $this->value['position'] = 'absolute'; |
|
| 991 | - else if ($val=='relative') $this->value['position'] = 'relative'; |
|
| 992 | - else $this->value['position'] = null; |
|
| 1108 | + if ($val=='absolute') { |
|
| 1109 | + $this->value['position'] = 'absolute'; |
|
| 1110 | + } else if ($val=='relative') { |
|
| 1111 | + $this->value['position'] = 'relative'; |
|
| 1112 | + } else { |
|
| 1113 | + $this->value['position'] = null; |
|
| 1114 | + } |
|
| 993 | 1115 | break; |
| 994 | 1116 | |
| 995 | 1117 | case 'float': |
| 996 | - if ($val=='left') $this->value['float'] = 'left'; |
|
| 997 | - else if ($val=='right') $this->value['float'] = 'right'; |
|
| 998 | - else $this->value['float'] = null; |
|
| 1118 | + if ($val=='left') { |
|
| 1119 | + $this->value['float'] = 'left'; |
|
| 1120 | + } else if ($val=='right') { |
|
| 1121 | + $this->value['float'] = 'right'; |
|
| 1122 | + } else { |
|
| 1123 | + $this->value['float'] = null; |
|
| 1124 | + } |
|
| 999 | 1125 | break; |
| 1000 | 1126 | |
| 1001 | 1127 | case 'display': |
| 1002 | - if ($val=='inline') $this->value['display'] = 'inline'; |
|
| 1003 | - else if ($val=='block') $this->value['display'] = 'block'; |
|
| 1004 | - else if ($val=='none') $this->value['display'] = 'none'; |
|
| 1005 | - else $this->value['display'] = null; |
|
| 1128 | + if ($val=='inline') { |
|
| 1129 | + $this->value['display'] = 'inline'; |
|
| 1130 | + } else if ($val=='block') { |
|
| 1131 | + $this->value['display'] = 'block'; |
|
| 1132 | + } else if ($val=='none') { |
|
| 1133 | + $this->value['display'] = 'none'; |
|
| 1134 | + } else { |
|
| 1135 | + $this->value['display'] = null; |
|
| 1136 | + } |
|
| 1006 | 1137 | break; |
| 1007 | 1138 | |
| 1008 | 1139 | case 'top': |
@@ -1015,7 +1146,9 @@ discard block |
||
| 1015 | 1146 | case 'list-style': |
| 1016 | 1147 | case 'list-style-type': |
| 1017 | 1148 | case 'list-style-image': |
| 1018 | - if ($nom=='list-style') $nom = 'list-style-type'; |
|
| 1149 | + if ($nom=='list-style') { |
|
| 1150 | + $nom = 'list-style-type'; |
|
| 1151 | + } |
|
| 1019 | 1152 | $this->value[$nom] = $val; |
| 1020 | 1153 | break; |
| 1021 | 1154 | |
@@ -1027,11 +1160,17 @@ discard block |
||
| 1027 | 1160 | $return = true; |
| 1028 | 1161 | |
| 1029 | 1162 | // only for P tag |
| 1030 | - if ($this->value['margin']['t']===null) $this->value['margin']['t'] = $this->value['font-size']; |
|
| 1031 | - if ($this->value['margin']['b']===null) $this->value['margin']['b'] = $this->value['font-size']; |
|
| 1163 | + if ($this->value['margin']['t']===null) { |
|
| 1164 | + $this->value['margin']['t'] = $this->value['font-size']; |
|
| 1165 | + } |
|
| 1166 | + if ($this->value['margin']['b']===null) { |
|
| 1167 | + $this->value['margin']['b'] = $this->value['font-size']; |
|
| 1168 | + } |
|
| 1032 | 1169 | |
| 1033 | 1170 | // force the text align to left, if asked by html2pdf |
| 1034 | - if ($this->_onlyLeft) $this->value['text-align'] = 'left'; |
|
| 1171 | + if ($this->_onlyLeft) { |
|
| 1172 | + $this->value['text-align'] = 'left'; |
|
| 1173 | + } |
|
| 1035 | 1174 | |
| 1036 | 1175 | // correction on the width (quick box) |
| 1037 | 1176 | if ($noWidth && in_array($tagName, array('div', 'blockquote', 'fieldset')) && $this->value['position']!='absolute') { |
@@ -1047,30 +1186,60 @@ discard block |
||
| 1047 | 1186 | $this->value['width']-= $this->convertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px'); |
| 1048 | 1187 | $return = false; |
| 1049 | 1188 | } |
| 1050 | - if ($this->value['width']<0) $this->value['width']=0; |
|
| 1189 | + if ($this->value['width']<0) { |
|
| 1190 | + $this->value['width']=0; |
|
| 1191 | + } |
|
| 1051 | 1192 | } else { |
| 1052 | 1193 | if ($this->value['width']) { |
| 1053 | - if ($this->value['border']['l']['width']) $this->value['width'] += $this->value['border']['l']['width']; |
|
| 1054 | - if ($this->value['border']['r']['width']) $this->value['width'] += $this->value['border']['r']['width']; |
|
| 1055 | - if ($this->value['padding']['l']) $this->value['width'] += $this->value['padding']['l']; |
|
| 1056 | - if ($this->value['padding']['r']) $this->value['width'] += $this->value['padding']['r']; |
|
| 1194 | + if ($this->value['border']['l']['width']) { |
|
| 1195 | + $this->value['width'] += $this->value['border']['l']['width']; |
|
| 1196 | + } |
|
| 1197 | + if ($this->value['border']['r']['width']) { |
|
| 1198 | + $this->value['width'] += $this->value['border']['r']['width']; |
|
| 1199 | + } |
|
| 1200 | + if ($this->value['padding']['l']) { |
|
| 1201 | + $this->value['width'] += $this->value['padding']['l']; |
|
| 1202 | + } |
|
| 1203 | + if ($this->value['padding']['r']) { |
|
| 1204 | + $this->value['width'] += $this->value['padding']['r']; |
|
| 1205 | + } |
|
| 1057 | 1206 | } |
| 1058 | 1207 | } |
| 1059 | 1208 | } |
| 1060 | 1209 | if ($this->value['height']) { |
| 1061 | - if ($this->value['border']['b']['width']) $this->value['height'] += $this->value['border']['b']['width']; |
|
| 1062 | - if ($this->value['border']['t']['width']) $this->value['height'] += $this->value['border']['t']['width']; |
|
| 1063 | - if ($this->value['padding']['b']) $this->value['height'] += $this->value['padding']['b']; |
|
| 1064 | - if ($this->value['padding']['t']) $this->value['height'] += $this->value['padding']['t']; |
|
| 1210 | + if ($this->value['border']['b']['width']) { |
|
| 1211 | + $this->value['height'] += $this->value['border']['b']['width']; |
|
| 1212 | + } |
|
| 1213 | + if ($this->value['border']['t']['width']) { |
|
| 1214 | + $this->value['height'] += $this->value['border']['t']['width']; |
|
| 1215 | + } |
|
| 1216 | + if ($this->value['padding']['b']) { |
|
| 1217 | + $this->value['height'] += $this->value['padding']['b']; |
|
| 1218 | + } |
|
| 1219 | + if ($this->value['padding']['t']) { |
|
| 1220 | + $this->value['height'] += $this->value['padding']['t']; |
|
| 1221 | + } |
|
| 1065 | 1222 | } |
| 1066 | 1223 | |
| 1067 | - if ($this->value['top']!=null) $this->value['top'] = $this->convertToMM($this->value['top'], $this->getLastHeight(true)); |
|
| 1068 | - if ($this->value['bottom']!=null) $this->value['bottom'] = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true)); |
|
| 1069 | - if ($this->value['left']!=null) $this->value['left'] = $this->convertToMM($this->value['left'], $this->getLastWidth(true)); |
|
| 1070 | - if ($this->value['right']!=null) $this->value['right'] = $this->convertToMM($this->value['right'], $this->getLastWidth(true)); |
|
| 1224 | + if ($this->value['top']!=null) { |
|
| 1225 | + $this->value['top'] = $this->convertToMM($this->value['top'], $this->getLastHeight(true)); |
|
| 1226 | + } |
|
| 1227 | + if ($this->value['bottom']!=null) { |
|
| 1228 | + $this->value['bottom'] = $this->convertToMM($this->value['bottom'], $this->getLastHeight(true)); |
|
| 1229 | + } |
|
| 1230 | + if ($this->value['left']!=null) { |
|
| 1231 | + $this->value['left'] = $this->convertToMM($this->value['left'], $this->getLastWidth(true)); |
|
| 1232 | + } |
|
| 1233 | + if ($this->value['right']!=null) { |
|
| 1234 | + $this->value['right'] = $this->convertToMM($this->value['right'], $this->getLastWidth(true)); |
|
| 1235 | + } |
|
| 1071 | 1236 | |
| 1072 | - if ($this->value['top'] && $this->value['bottom'] && $this->value['height']) $this->value['bottom'] = null; |
|
| 1073 | - if ($this->value['left'] && $this->value['right'] && $this->value['width']) $this->value['right'] = null; |
|
| 1237 | + if ($this->value['top'] && $this->value['bottom'] && $this->value['height']) { |
|
| 1238 | + $this->value['bottom'] = null; |
|
| 1239 | + } |
|
| 1240 | + if ($this->value['left'] && $this->value['right'] && $this->value['width']) { |
|
| 1241 | + $this->value['right'] = null; |
|
| 1242 | + } |
|
| 1074 | 1243 | |
| 1075 | 1244 | return $return; |
| 1076 | 1245 | } |
@@ -1084,7 +1253,9 @@ discard block |
||
| 1084 | 1253 | public function getLineHeight() |
| 1085 | 1254 | { |
| 1086 | 1255 | $val = $this->value['line-height']; |
| 1087 | - if ($val=='normal') $val = '108%'; |
|
| 1256 | + if ($val=='normal') { |
|
| 1257 | + $val = '108%'; |
|
| 1258 | + } |
|
| 1088 | 1259 | return $this->convertToMM($val, $this->value['font-size']); |
| 1089 | 1260 | } |
| 1090 | 1261 | |
@@ -1140,8 +1311,12 @@ discard block |
||
| 1140 | 1311 | */ |
| 1141 | 1312 | public function getFloat() |
| 1142 | 1313 | { |
| 1143 | - if ($this->value['float']=='left') return 'left'; |
|
| 1144 | - if ($this->value['float']=='right') return 'right'; |
|
| 1314 | + if ($this->value['float']=='left') { |
|
| 1315 | + return 'left'; |
|
| 1316 | + } |
|
| 1317 | + if ($this->value['float']=='right') { |
|
| 1318 | + return 'right'; |
|
| 1319 | + } |
|
| 1145 | 1320 | return null; |
| 1146 | 1321 | } |
| 1147 | 1322 | |
@@ -1171,7 +1346,9 @@ discard block |
||
| 1171 | 1346 | protected function _getLastAbsoluteX() |
| 1172 | 1347 | { |
| 1173 | 1348 | for ($k=count($this->table)-1; $k>=0; $k--) { |
| 1174 | - if ($this->table[$k]['x'] && $this->table[$k]['position']) return $this->table[$k]['x']; |
|
| 1349 | + if ($this->table[$k]['x'] && $this->table[$k]['position']) { |
|
| 1350 | + return $this->table[$k]['x']; |
|
| 1351 | + } |
|
| 1175 | 1352 | } |
| 1176 | 1353 | return $this->_pdf->getlMargin(); |
| 1177 | 1354 | } |
@@ -1185,7 +1362,9 @@ discard block |
||
| 1185 | 1362 | protected function _getLastAbsoluteY() |
| 1186 | 1363 | { |
| 1187 | 1364 | for ($k=count($this->table)-1; $k>=0; $k--) { |
| 1188 | - if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y']; |
|
| 1365 | + if ($this->table[$k]['y'] && $this->table[$k]['position']) { |
|
| 1366 | + return $this->table[$k]['y']; |
|
| 1367 | + } |
|
| 1189 | 1368 | } |
| 1190 | 1369 | return $this->_pdf->gettMargin(); |
| 1191 | 1370 | } |
@@ -1222,7 +1401,9 @@ discard block |
||
| 1222 | 1401 | if (count($getit)) { |
| 1223 | 1402 | // get them, but in the definition order, because of priority |
| 1224 | 1403 | asort($getit); |
| 1225 | - foreach ($getit as $key => $val) $styles = array_merge($styles, $this->css[$key]); |
|
| 1404 | + foreach ($getit as $key => $val) { |
|
| 1405 | + $styles = array_merge($styles, $this->css[$key]); |
|
| 1406 | + } |
|
| 1226 | 1407 | } |
| 1227 | 1408 | |
| 1228 | 1409 | return $styles; |
@@ -1242,7 +1423,9 @@ discard block |
||
| 1242 | 1423 | // if next step |
| 1243 | 1424 | if ($next!==null) { |
| 1244 | 1425 | // we remove this step |
| 1245 | - if ($next) $key = trim(substr($key, 0, -strlen($next))); |
|
| 1426 | + if ($next) { |
|
| 1427 | + $key = trim(substr($key, 0, -strlen($next))); |
|
| 1428 | + } |
|
| 1246 | 1429 | array_shift($lst); |
| 1247 | 1430 | |
| 1248 | 1431 | // if no more step to identify => return false |
@@ -1294,8 +1477,11 @@ discard block |
||
| 1294 | 1477 | $css = explode(' ', $css); |
| 1295 | 1478 | foreach ($css as $k => $v) { |
| 1296 | 1479 | $v = trim($v); |
| 1297 | - if ($v) $css[$k] = $v; |
|
| 1298 | - else unset($css[$k]); |
|
| 1480 | + if ($v) { |
|
| 1481 | + $css[$k] = $v; |
|
| 1482 | + } else { |
|
| 1483 | + unset($css[$k]); |
|
| 1484 | + } |
|
| 1299 | 1485 | } |
| 1300 | 1486 | $css = array_values($css); |
| 1301 | 1487 | |
@@ -1320,12 +1506,16 @@ discard block |
||
| 1320 | 1506 | // else, it could be the color |
| 1321 | 1507 | } else { |
| 1322 | 1508 | $tmp = $this->convertToColor($value, $res); |
| 1323 | - if ($res) $color = $tmp; |
|
| 1509 | + if ($res) { |
|
| 1510 | + $color = $tmp; |
|
| 1511 | + } |
|
| 1324 | 1512 | } |
| 1325 | 1513 | } |
| 1326 | 1514 | |
| 1327 | 1515 | // if no witdh => return none |
| 1328 | - if (!$width) return $none; |
|
| 1516 | + if (!$width) { |
|
| 1517 | + return $none; |
|
| 1518 | + } |
|
| 1329 | 1519 | |
| 1330 | 1520 | // return the border properties |
| 1331 | 1521 | return array('type' => $type, 'width' => $width, 'color' => $color); |
@@ -1414,7 +1604,9 @@ discard block |
||
| 1414 | 1604 | if ($pos) { |
| 1415 | 1605 | // try to read it |
| 1416 | 1606 | $pos = $this->convertBackgroundPosition($pos, $ok); |
| 1417 | - if ($ok) $value['position'] = $pos; |
|
| 1607 | + if ($ok) { |
|
| 1608 | + $value['position'] = $pos; |
|
| 1609 | + } |
|
| 1418 | 1610 | } |
| 1419 | 1611 | } |
| 1420 | 1612 | |
@@ -1428,8 +1620,11 @@ discard block |
||
| 1428 | 1620 | public function convertBackgroundColor($css) |
| 1429 | 1621 | { |
| 1430 | 1622 | $res = null; |
| 1431 | - if ($css=='transparent') return null; |
|
| 1432 | - else return $this->convertToColor($css, $res); |
|
| 1623 | + if ($css=='transparent') { |
|
| 1624 | + return null; |
|
| 1625 | + } else { |
|
| 1626 | + return $this->convertToColor($css, $res); |
|
| 1627 | + } |
|
| 1433 | 1628 | } |
| 1434 | 1629 | |
| 1435 | 1630 | /** |
@@ -1441,12 +1636,13 @@ discard block |
||
| 1441 | 1636 | */ |
| 1442 | 1637 | public function convertBackgroundImage($css) |
| 1443 | 1638 | { |
| 1444 | - if ($css=='none') |
|
| 1445 | - return null; |
|
| 1446 | - else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match)) |
|
| 1447 | - return $match[1]; |
|
| 1448 | - else |
|
| 1449 | - return null; |
|
| 1639 | + if ($css=='none') { |
|
| 1640 | + return null; |
|
| 1641 | + } else if (preg_match('/^url\(([^)]*)\)$/isU', $css, $match)) { |
|
| 1642 | + return $match[1]; |
|
| 1643 | + } else { |
|
| 1644 | + return null; |
|
| 1645 | + } |
|
| 1450 | 1646 | } |
| 1451 | 1647 | |
| 1452 | 1648 | /** |
@@ -1467,10 +1663,14 @@ discard block |
||
| 1467 | 1663 | |
| 1468 | 1664 | // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2 |
| 1469 | 1665 | if (count($css)<2) { |
| 1470 | - if (!$css[0]) return null; |
|
| 1666 | + if (!$css[0]) { |
|
| 1667 | + return null; |
|
| 1668 | + } |
|
| 1471 | 1669 | $css[1] = 'center'; |
| 1472 | 1670 | } |
| 1473 | - if (count($css)>2) return null; |
|
| 1671 | + if (count($css)>2) { |
|
| 1672 | + return null; |
|
| 1673 | + } |
|
| 1474 | 1674 | |
| 1475 | 1675 | // prepare the values |
| 1476 | 1676 | $x = 0; |
@@ -1478,24 +1678,42 @@ discard block |
||
| 1478 | 1678 | $res = true; |
| 1479 | 1679 | |
| 1480 | 1680 | // convert the first value |
| 1481 | - if ($css[0]=='left') $x = '0%'; |
|
| 1482 | - else if ($css[0]=='center') $x = '50%'; |
|
| 1483 | - else if ($css[0]=='right') $x = '100%'; |
|
| 1484 | - else if ($css[0]=='top') $y = '0%'; |
|
| 1485 | - else if ($css[0]=='bottom') $y = '100%'; |
|
| 1486 | - else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0]; |
|
| 1487 | - else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]); |
|
| 1488 | - else $res = false; |
|
| 1681 | + if ($css[0]=='left') { |
|
| 1682 | + $x = '0%'; |
|
| 1683 | + } else if ($css[0]=='center') { |
|
| 1684 | + $x = '50%'; |
|
| 1685 | + } else if ($css[0]=='right') { |
|
| 1686 | + $x = '100%'; |
|
| 1687 | + } else if ($css[0]=='top') { |
|
| 1688 | + $y = '0%'; |
|
| 1689 | + } else if ($css[0]=='bottom') { |
|
| 1690 | + $y = '100%'; |
|
| 1691 | + } else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) { |
|
| 1692 | + $x = $css[0]; |
|
| 1693 | + } else if ($this->convertToMM($css[0])) { |
|
| 1694 | + $x = $this->convertToMM($css[0]); |
|
| 1695 | + } else { |
|
| 1696 | + $res = false; |
|
| 1697 | + } |
|
| 1489 | 1698 | |
| 1490 | 1699 | // convert the second value |
| 1491 | - if ($css[1]=='left') $x = '0%'; |
|
| 1492 | - else if ($css[1]=='right') $x = '100%'; |
|
| 1493 | - else if ($css[1]=='top') $y = '0%'; |
|
| 1494 | - else if ($css[1]=='center') $y = '50%'; |
|
| 1495 | - else if ($css[1]=='bottom') $y = '100%'; |
|
| 1496 | - else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1]; |
|
| 1497 | - else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]); |
|
| 1498 | - else $res = false; |
|
| 1700 | + if ($css[1]=='left') { |
|
| 1701 | + $x = '0%'; |
|
| 1702 | + } else if ($css[1]=='right') { |
|
| 1703 | + $x = '100%'; |
|
| 1704 | + } else if ($css[1]=='top') { |
|
| 1705 | + $y = '0%'; |
|
| 1706 | + } else if ($css[1]=='center') { |
|
| 1707 | + $y = '50%'; |
|
| 1708 | + } else if ($css[1]=='bottom') { |
|
| 1709 | + $y = '100%'; |
|
| 1710 | + } else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) { |
|
| 1711 | + $y = $css[1]; |
|
| 1712 | + } else if ($this->convertToMM($css[1])) { |
|
| 1713 | + $y = $this->convertToMM($css[1]); |
|
| 1714 | + } else { |
|
| 1715 | + $res = false; |
|
| 1716 | + } |
|
| 1499 | 1717 | |
| 1500 | 1718 | // return the values |
| 1501 | 1719 | return array($x, $y); |
@@ -1535,13 +1753,22 @@ discard block |
||
| 1535 | 1753 | public function convertToMM($css, $old=0.) |
| 1536 | 1754 | { |
| 1537 | 1755 | $css = trim($css); |
| 1538 | - if (preg_match('/^[0-9\.\-]+$/isU', $css)) $css.= 'px'; |
|
| 1539 | - if (preg_match('/^[0-9\.\-]+px$/isU', $css)) $css = 25.4/96. * str_replace('px', '', $css); |
|
| 1540 | - else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) $css = 25.4/72. * str_replace('pt', '', $css); |
|
| 1541 | - else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) $css = 25.4 * str_replace('in', '', $css); |
|
| 1542 | - else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) $css = 1.*str_replace('mm', '', $css); |
|
| 1543 | - else if (preg_match('/^[0-9\.\-]+%$/isU', $css)) $css = 1.*$old*str_replace('%', '', $css)/100.; |
|
| 1544 | - else $css = null; |
|
| 1756 | + if (preg_match('/^[0-9\.\-]+$/isU', $css)) { |
|
| 1757 | + $css.= 'px'; |
|
| 1758 | + } |
|
| 1759 | + if (preg_match('/^[0-9\.\-]+px$/isU', $css)) { |
|
| 1760 | + $css = 25.4/96. * str_replace('px', '', $css); |
|
| 1761 | + } else if (preg_match('/^[0-9\.\-]+pt$/isU', $css)) { |
|
| 1762 | + $css = 25.4/72. * str_replace('pt', '', $css); |
|
| 1763 | + } else if (preg_match('/^[0-9\.\-]+in$/isU', $css)) { |
|
| 1764 | + $css = 25.4 * str_replace('in', '', $css); |
|
| 1765 | + } else if (preg_match('/^[0-9\.\-]+mm$/isU', $css)) { |
|
| 1766 | + $css = 1.*str_replace('mm', '', $css); |
|
| 1767 | + } else if (preg_match('/^[0-9\.\-]+%$/isU', $css)) { |
|
| 1768 | + $css = 1.*$old*str_replace('%', '', $css)/100.; |
|
| 1769 | + } else { |
|
| 1770 | + $css = null; |
|
| 1771 | + } |
|
| 1545 | 1772 | |
| 1546 | 1773 | return $css; |
| 1547 | 1774 | } |
@@ -1590,7 +1817,9 @@ discard block |
||
| 1590 | 1817 | $res = true; |
| 1591 | 1818 | |
| 1592 | 1819 | // if transparent => return null |
| 1593 | - if (strtolower($css)=='transparent') return array(null, null, null); |
|
| 1820 | + if (strtolower($css)=='transparent') { |
|
| 1821 | + return array(null, null, null); |
|
| 1822 | + } |
|
| 1594 | 1823 | |
| 1595 | 1824 | // HTML color |
| 1596 | 1825 | if (isset($this->_htmlColor[strtolower($css)])) { |
@@ -1651,7 +1880,9 @@ discard block |
||
| 1651 | 1880 | $c = floatVal(substr($c, 0, -1))/100.; |
| 1652 | 1881 | } else { |
| 1653 | 1882 | $c = floatVal($c); |
| 1654 | - if ($c>1) $c = $c/255.; |
|
| 1883 | + if ($c>1) { |
|
| 1884 | + $c = $c/255.; |
|
| 1885 | + } |
|
| 1655 | 1886 | } |
| 1656 | 1887 | |
| 1657 | 1888 | return $c; |
@@ -1705,13 +1936,16 @@ discard block |
||
| 1705 | 1936 | $name = trim($name); |
| 1706 | 1937 | |
| 1707 | 1938 | // if a selector with somethink lige :hover => continue |
| 1708 | - if (strpos($name, ':')!==false) continue; |
|
| 1939 | + if (strpos($name, ':')!==false) { |
|
| 1940 | + continue; |
|
| 1941 | + } |
|
| 1709 | 1942 | |
| 1710 | 1943 | // save the value |
| 1711 | - if (!isset($this->css[$name])) |
|
| 1712 | - $this->css[$name] = $css; |
|
| 1713 | - else |
|
| 1714 | - $this->css[$name] = array_merge($this->css[$name], $css); |
|
| 1944 | + if (!isset($this->css[$name])) { |
|
| 1945 | + $this->css[$name] = $css; |
|
| 1946 | + } else { |
|
| 1947 | + $this->css[$name] = array_merge($this->css[$name], $css); |
|
| 1948 | + } |
|
| 1715 | 1949 | |
| 1716 | 1950 | } |
| 1717 | 1951 | } |
@@ -38,6 +38,7 @@ discard block |
||
| 38 | 38 | * change the encoding |
| 39 | 39 | * |
| 40 | 40 | * @param string encoding |
| 41 | + * @param string $encoding |
|
| 41 | 42 | * @access public |
| 42 | 43 | */ |
| 43 | 44 | public function setEncoding($encoding) |
@@ -440,6 +441,7 @@ discard block |
||
| 440 | 441 | * get a full level of HTML, between an opening and closing corresponding |
| 441 | 442 | * |
| 442 | 443 | * @param integer key |
| 444 | + * @param integer $k |
|
| 443 | 445 | * @return array actions |
| 444 | 446 | */ |
| 445 | 447 | public function getLevel($k) |
@@ -11,511 +11,511 @@ |
||
| 11 | 11 | |
| 12 | 12 | class HTML2PDF_parsingHtml |
| 13 | 13 | { |
| 14 | - protected $_html = ''; // HTML code to parse |
|
| 15 | - protected $_num = 0; // table number |
|
| 16 | - protected $_level = 0; // table level |
|
| 17 | - protected $_encoding = ''; // encoding |
|
| 18 | - public $code = array(); // parsed HTML codfe |
|
| 19 | - |
|
| 20 | - const HTML_TAB = ' '; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * main constructor |
|
| 24 | - * |
|
| 25 | - * @param string encoding |
|
| 26 | - * @access public |
|
| 27 | - */ |
|
| 28 | - public function __construct($encoding = 'UTF-8') |
|
| 29 | - { |
|
| 30 | - $this->_num = 0; |
|
| 31 | - $this->_level = array($this->_num); |
|
| 32 | - $this->_html = ''; |
|
| 33 | - $this->code = array(); |
|
| 34 | - $this->setEncoding($encoding); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * change the encoding |
|
| 39 | - * |
|
| 40 | - * @param string encoding |
|
| 41 | - * @access public |
|
| 42 | - */ |
|
| 43 | - public function setEncoding($encoding) |
|
| 44 | - { |
|
| 45 | - $this->_encoding = $encoding; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Define the HTML code to parse |
|
| 50 | - * |
|
| 51 | - * @param string HTML code |
|
| 52 | - * @access public |
|
| 53 | - */ |
|
| 54 | - public function setHTML($html) |
|
| 55 | - { |
|
| 56 | - // remove the HTML in comment |
|
| 57 | - $html = preg_replace('/<!--(.*)-->/isU', '', $html); |
|
| 58 | - |
|
| 59 | - // save the HTML code |
|
| 60 | - $this->_html = $html; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * parse the HTML code |
|
| 65 | - * |
|
| 66 | - * @access public |
|
| 67 | - */ |
|
| 68 | - public function parse() |
|
| 69 | - { |
|
| 70 | - $parents = array(); |
|
| 71 | - |
|
| 72 | - // flag : are we in a <pre> Tag ? |
|
| 73 | - $tagPreIn = false; |
|
| 74 | - |
|
| 75 | - // action to use for each line of the content of a <pre> Tag |
|
| 76 | - $tagPreBr = array( |
|
| 77 | - 'name' => 'br', |
|
| 78 | - 'close' => false, |
|
| 79 | - 'param' => array( |
|
| 80 | - 'style' => array(), |
|
| 81 | - 'num' => 0 |
|
| 82 | - ) |
|
| 83 | - ); |
|
| 84 | - |
|
| 85 | - // tag that can be not closed |
|
| 86 | - $tagsNotClosed = array( |
|
| 87 | - 'br', 'hr', 'img', 'col', |
|
| 88 | - 'input', 'link', 'option', |
|
| 89 | - 'circle', 'ellipse', 'path', 'rect', 'line', 'polygon', 'polyline' |
|
| 90 | - ); |
|
| 91 | - |
|
| 92 | - // search the HTML tags |
|
| 93 | - $tmp = array(); |
|
| 94 | - $this->_searchCode($tmp); |
|
| 95 | - |
|
| 96 | - // all the actions to do |
|
| 97 | - $actions = array(); |
|
| 98 | - |
|
| 99 | - // foreach part of the HTML code |
|
| 100 | - foreach ($tmp as $part) { |
|
| 101 | - // if it is a tag code |
|
| 102 | - if ($part[0]=='code') { |
|
| 103 | - // analise the HTML code |
|
| 104 | - $res = $this->_analiseCode($part[1]); |
|
| 14 | + protected $_html = ''; // HTML code to parse |
|
| 15 | + protected $_num = 0; // table number |
|
| 16 | + protected $_level = 0; // table level |
|
| 17 | + protected $_encoding = ''; // encoding |
|
| 18 | + public $code = array(); // parsed HTML codfe |
|
| 19 | + |
|
| 20 | + const HTML_TAB = ' '; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * main constructor |
|
| 24 | + * |
|
| 25 | + * @param string encoding |
|
| 26 | + * @access public |
|
| 27 | + */ |
|
| 28 | + public function __construct($encoding = 'UTF-8') |
|
| 29 | + { |
|
| 30 | + $this->_num = 0; |
|
| 31 | + $this->_level = array($this->_num); |
|
| 32 | + $this->_html = ''; |
|
| 33 | + $this->code = array(); |
|
| 34 | + $this->setEncoding($encoding); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * change the encoding |
|
| 39 | + * |
|
| 40 | + * @param string encoding |
|
| 41 | + * @access public |
|
| 42 | + */ |
|
| 43 | + public function setEncoding($encoding) |
|
| 44 | + { |
|
| 45 | + $this->_encoding = $encoding; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Define the HTML code to parse |
|
| 50 | + * |
|
| 51 | + * @param string HTML code |
|
| 52 | + * @access public |
|
| 53 | + */ |
|
| 54 | + public function setHTML($html) |
|
| 55 | + { |
|
| 56 | + // remove the HTML in comment |
|
| 57 | + $html = preg_replace('/<!--(.*)-->/isU', '', $html); |
|
| 58 | + |
|
| 59 | + // save the HTML code |
|
| 60 | + $this->_html = $html; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * parse the HTML code |
|
| 65 | + * |
|
| 66 | + * @access public |
|
| 67 | + */ |
|
| 68 | + public function parse() |
|
| 69 | + { |
|
| 70 | + $parents = array(); |
|
| 71 | + |
|
| 72 | + // flag : are we in a <pre> Tag ? |
|
| 73 | + $tagPreIn = false; |
|
| 74 | + |
|
| 75 | + // action to use for each line of the content of a <pre> Tag |
|
| 76 | + $tagPreBr = array( |
|
| 77 | + 'name' => 'br', |
|
| 78 | + 'close' => false, |
|
| 79 | + 'param' => array( |
|
| 80 | + 'style' => array(), |
|
| 81 | + 'num' => 0 |
|
| 82 | + ) |
|
| 83 | + ); |
|
| 84 | + |
|
| 85 | + // tag that can be not closed |
|
| 86 | + $tagsNotClosed = array( |
|
| 87 | + 'br', 'hr', 'img', 'col', |
|
| 88 | + 'input', 'link', 'option', |
|
| 89 | + 'circle', 'ellipse', 'path', 'rect', 'line', 'polygon', 'polyline' |
|
| 90 | + ); |
|
| 91 | + |
|
| 92 | + // search the HTML tags |
|
| 93 | + $tmp = array(); |
|
| 94 | + $this->_searchCode($tmp); |
|
| 95 | + |
|
| 96 | + // all the actions to do |
|
| 97 | + $actions = array(); |
|
| 98 | + |
|
| 99 | + // foreach part of the HTML code |
|
| 100 | + foreach ($tmp as $part) { |
|
| 101 | + // if it is a tag code |
|
| 102 | + if ($part[0]=='code') { |
|
| 103 | + // analise the HTML code |
|
| 104 | + $res = $this->_analiseCode($part[1]); |
|
| 105 | 105 | |
| 106 | 106 | //echo "<pre>"; print_r($tagsNotClosed); exit; |
| 107 | - // if it is a real HTML tag |
|
| 108 | - if ($res) { |
|
| 109 | - // save the current posistion in the HTML code |
|
| 110 | - $res['html_pos'] = $part[2]; |
|
| 111 | - |
|
| 112 | - // if the tag must be closed |
|
| 113 | - if (!in_array($res['name'], $tagsNotClosed)) { |
|
| 114 | - // if it is a closure tag |
|
| 115 | - if ($res['close']) { |
|
| 116 | - // HTML validation |
|
| 117 | - if (count($parents)<1) |
|
| 118 | - throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos'])); |
|
| 119 | - else if ($parents[count($parents)-1]!=$res['name']) |
|
| 120 | - throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos'])); |
|
| 121 | - else |
|
| 122 | - unset($parents[count($parents)-1]); |
|
| 123 | - } else { |
|
| 124 | - // if it is a autoclosed tag |
|
| 125 | - if ($res['autoclose']) { |
|
| 126 | - // save the opened tag |
|
| 127 | - $actions[] = $res; |
|
| 128 | - |
|
| 129 | - // prepare the closed tag |
|
| 130 | - $res['params'] = array(); |
|
| 131 | - $res['close'] = true; |
|
| 132 | - } |
|
| 133 | - // else :add a child for validation |
|
| 134 | - else |
|
| 135 | - $parents[count($parents)] = $res['name']; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - // if it is a <pre> tag (or <code> tag) not auclosed => update the flag |
|
| 139 | - if (($res['name']=='pre' || $res['name']=='code') && !$res['autoclose']) { |
|
| 140 | - $tagPreIn = !$res['close']; |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - // save the actions to convert |
|
| 145 | - $actions[] = $res; |
|
| 146 | - } else { // else (it is not a real HTML tag => we transform it in Texte |
|
| 147 | - $part[0]='txt'; |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - // if it is text |
|
| 151 | - if ($part[0]=='txt') { |
|
| 152 | - // if we are not in a <pre> tag |
|
| 153 | - if (!$tagPreIn) { |
|
| 154 | - // save the action |
|
| 155 | - $actions[] = array( |
|
| 156 | - 'name' => 'write', |
|
| 157 | - 'close' => false, |
|
| 158 | - 'param' => array('txt' => $this->_prepareTxt($part[1])), |
|
| 159 | - ); |
|
| 160 | - } else { // else (if we are in a <pre> tag) |
|
| 161 | - // prepare the text |
|
| 162 | - $part[1] = str_replace("\r", '', $part[1]); |
|
| 163 | - $part[1] = explode("\n", $part[1]); |
|
| 164 | - |
|
| 165 | - // foreach line of the text |
|
| 166 | - foreach ($part[1] as $k => $txt) { |
|
| 167 | - // transform the line |
|
| 168 | - $txt = str_replace("\t", self::HTML_TAB, $txt); |
|
| 169 | - $txt = str_replace(' ', ' ', $txt); |
|
| 170 | - |
|
| 171 | - // add a break line |
|
| 172 | - if ($k>0) $actions[] = $tagPreBr; |
|
| 173 | - |
|
| 174 | - // save the action |
|
| 175 | - $actions[] = array( |
|
| 176 | - 'name' => 'write', |
|
| 177 | - 'close' => false, |
|
| 178 | - 'param' => array('txt' => $this->_prepareTxt($txt, false)), |
|
| 179 | - ); |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - // for each indentified action, we have to clean up the begin and the end of the texte |
|
| 186 | - // based on tags that surround it |
|
| 187 | - |
|
| 188 | - // list of the tags to clean |
|
| 189 | - $tagsToClean = array( |
|
| 190 | - 'page', 'page_header', 'page_footer', 'form', |
|
| 191 | - 'table', 'thead', 'tfoot', 'tr', 'td', 'th', 'br', |
|
| 192 | - 'div', 'hr', 'p', 'ul', 'ol', 'li', |
|
| 193 | - 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', |
|
| 194 | - 'bookmark', 'fieldset', 'legend', |
|
| 195 | - 'draw', 'circle', 'ellipse', 'path', 'rect', 'line', 'g', 'polygon', 'polyline', |
|
| 196 | - 'option' |
|
| 197 | - ); |
|
| 198 | - |
|
| 199 | - // foreach action |
|
| 200 | - $nb = count($actions); |
|
| 201 | - for ($k=0; $k<$nb; $k++) { |
|
| 202 | - // if it is a Text |
|
| 203 | - if ($actions[$k]['name']=='write') { |
|
| 204 | - // if the tag before the text is a tag to clean => ltrim on the text |
|
| 205 | - if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean)) |
|
| 206 | - $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']); |
|
| 207 | - |
|
| 208 | - // if the tag after the text is a tag to clean => rtrim on the text |
|
| 209 | - if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean)) |
|
| 210 | - $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']); |
|
| 211 | - |
|
| 212 | - // if the text is empty => remove the action |
|
| 213 | - if (!strlen($actions[$k]['param']['txt'])) |
|
| 214 | - unset($actions[$k]); |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - // if we are not on the level 0 => HTML validator ERROR |
|
| 219 | - if (count($parents)) throw new HTML2PDF_exception(5, $parents); |
|
| 220 | - |
|
| 221 | - // save the actions to do |
|
| 222 | - $this->code = array_values($actions); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - /** |
|
| 226 | - * prepare the text |
|
| 227 | - * |
|
| 228 | - * @param string texte |
|
| 229 | - * @param boolean true => replace multiple space+\t+\r+\n by a single space |
|
| 230 | - * @return string texte |
|
| 231 | - * @access protected |
|
| 232 | - */ |
|
| 233 | - protected function _prepareTxt($txt, $spaces = true) |
|
| 234 | - { |
|
| 235 | - if ($spaces) $txt = preg_replace('/\s+/is', ' ', $txt); |
|
| 236 | - $txt = str_replace('€', '€', $txt); |
|
| 237 | - $txt = html_entity_decode($txt, ENT_QUOTES, $this->_encoding); |
|
| 238 | - return $txt; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * parse the HTML code |
|
| 243 | - * |
|
| 244 | - * @param &array array's result |
|
| 245 | - * @return null |
|
| 246 | - */ |
|
| 247 | - protected function _searchCode(&$tmp) |
|
| 248 | - { |
|
| 249 | - // initialise the array |
|
| 250 | - $tmp = array(); |
|
| 251 | - |
|
| 252 | - // regexp to separate the tags from the texts |
|
| 253 | - $reg = '/(<[^>]+>)|([^<]+)+/isU'; |
|
| 254 | - |
|
| 255 | - // last match found |
|
| 256 | - $str = ''; |
|
| 257 | - $offset = 0; |
|
| 258 | - |
|
| 259 | - // As it finds a match |
|
| 260 | - while (preg_match($reg, $this->_html, $parse, PREG_OFFSET_CAPTURE, $offset)) { |
|
| 261 | - // if it is a tag |
|
| 262 | - if ($parse[1][0]) { |
|
| 263 | - // save the previous text if it exists |
|
| 264 | - if ($str!=='') $tmp[] = array('txt', $str); |
|
| 265 | - |
|
| 266 | - // save the tag, with the offset |
|
| 267 | - $tmp[] = array('code', trim($parse[1][0]), $offset); |
|
| 268 | - |
|
| 269 | - // init the current text |
|
| 270 | - $str = ''; |
|
| 271 | - } else { // else (if it is a text) |
|
| 272 | - // add the new text to the current text |
|
| 273 | - $str.= $parse[2][0]; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - // Update offset to the end of the match |
|
| 277 | - $offset = $parse[0][1] + strlen($parse[0][0]); |
|
| 278 | - unset($parse); |
|
| 279 | - } |
|
| 280 | - // if a text is present in the end, we save it |
|
| 281 | - if ($str!='') $tmp[] = array('txt', $str); |
|
| 282 | - unset($str); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * analise a HTML tag |
|
| 287 | - * |
|
| 288 | - * @param string HTML code to analise |
|
| 289 | - * @return array corresponding action |
|
| 290 | - */ |
|
| 291 | - protected function _analiseCode($code) |
|
| 292 | - { |
|
| 293 | - // name of the tag, opening, closure, autoclosure |
|
| 294 | - $tag = '<([\/]{0,1})([_a-z0-9]+)([\/>\s]+)'; |
|
| 295 | - if (!preg_match('/'.$tag.'/isU', $code, $match)) return null; |
|
| 296 | - $close = ($match[1]=='/' ? true : false); |
|
| 297 | - $autoclose = preg_match('/\/>$/isU', $code); |
|
| 298 | - $name = strtolower($match[2]); |
|
| 299 | - |
|
| 300 | - // required parameters (depends on the tag name) |
|
| 301 | - $param = array(); |
|
| 302 | - $param['style'] = ''; |
|
| 303 | - if ($name=='img') { |
|
| 304 | - $param['alt'] = ''; |
|
| 305 | - $param['src'] = ''; |
|
| 306 | - } |
|
| 307 | - if ($name=='a') { |
|
| 308 | - $param['href'] = ''; |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - // read the parameters : nom=valeur |
|
| 312 | - $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)'; |
|
| 313 | - preg_match_all('/'.$prop.'/is', $code, $match); |
|
| 314 | - for($k=0; $k<count($match[0]); $k++) |
|
| 315 | - $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 316 | - |
|
| 317 | - // read the parameters : nom="valeur" |
|
| 318 | - $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]'; |
|
| 319 | - preg_match_all('/'.$prop.'/is', $code, $match); |
|
| 320 | - for($k=0; $k<count($match[0]); $k++) |
|
| 321 | - $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 322 | - |
|
| 323 | - // read the parameters : nom='valeur' |
|
| 324 | - $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']"; |
|
| 325 | - preg_match_all('/'.$prop.'/is', $code, $match); |
|
| 326 | - for($k=0; $k<count($match[0]); $k++) |
|
| 327 | - $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 328 | - |
|
| 329 | - // compliance of each parameter |
|
| 330 | - $color = "#000000"; |
|
| 331 | - $border = null; |
|
| 332 | - foreach ($param as $key => $val) { |
|
| 333 | - $key = strtolower($key); |
|
| 334 | - switch($key) |
|
| 335 | - { |
|
| 336 | - case 'width': |
|
| 337 | - unset($param[$key]); |
|
| 338 | - $param['style'] .= 'width: '.$val.'px; '; |
|
| 339 | - break; |
|
| 340 | - |
|
| 341 | - case 'align': |
|
| 342 | - if ($name==='img') { |
|
| 343 | - unset($param[$key]); |
|
| 344 | - $param['style'] .= 'float: '.$val.'; '; |
|
| 345 | - } elseif ($name!=='table') { |
|
| 346 | - unset($param[$key]); |
|
| 347 | - $param['style'] .= 'text-align: '.$val.'; '; |
|
| 348 | - } |
|
| 349 | - break; |
|
| 350 | - |
|
| 351 | - case 'valign': |
|
| 352 | - unset($param[$key]); |
|
| 353 | - $param['style'] .= 'vertical-align: '.$val.'; '; |
|
| 354 | - break; |
|
| 355 | - |
|
| 356 | - case 'height': |
|
| 357 | - unset($param[$key]); |
|
| 358 | - $param['style'] .= 'height: '.$val.'px; '; |
|
| 359 | - break; |
|
| 360 | - |
|
| 361 | - case 'bgcolor': |
|
| 362 | - unset($param[$key]); |
|
| 363 | - $param['style'] .= 'background: '.$val.'; '; |
|
| 364 | - break; |
|
| 365 | - |
|
| 366 | - case 'bordercolor': |
|
| 367 | - unset($param[$key]); |
|
| 368 | - $color = $val; |
|
| 369 | - break; |
|
| 370 | - |
|
| 371 | - case 'border': |
|
| 372 | - unset($param[$key]); |
|
| 373 | - if (preg_match('/^[0-9]+$/isU', $val)) $val = $val.'px'; |
|
| 374 | - $border = $val; |
|
| 375 | - break; |
|
| 376 | - |
|
| 377 | - case 'cellpadding': |
|
| 378 | - case 'cellspacing': |
|
| 379 | - if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val.'px'; |
|
| 380 | - break; |
|
| 381 | - |
|
| 382 | - case 'colspan': |
|
| 383 | - case 'rowspan': |
|
| 384 | - $val = preg_replace('/[^0-9]/isU', '', $val); |
|
| 385 | - if (!$val) $val = 1; |
|
| 386 | - $param[$key] = $val; |
|
| 387 | - break; |
|
| 388 | - } |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - // compliance of the border |
|
| 392 | - if ($border!==null) { |
|
| 393 | - if ($border) $border = 'border: solid '.$border.' '.$color; |
|
| 394 | - else $border = 'border: none'; |
|
| 395 | - |
|
| 396 | - $param['style'] .= $border.'; '; |
|
| 397 | - $param['border'] = $border; |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - // reading styles: decomposition and standardization |
|
| 401 | - $styles = explode(';', $param['style']); |
|
| 402 | - $param['style'] = array(); |
|
| 403 | - foreach ($styles as $style) { |
|
| 404 | - $tmp = explode(':', $style); |
|
| 405 | - if (count($tmp)>1) { |
|
| 406 | - $cod = $tmp[0]; |
|
| 407 | - unset($tmp[0]); |
|
| 408 | - $tmp = implode(':', $tmp); |
|
| 409 | - $param['style'][trim(strtolower($cod))] = preg_replace('/[\s]+/isU', ' ', trim($tmp)); |
|
| 410 | - } |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - // determining the level of table opening, with an added level |
|
| 414 | - if (in_array($name, array('ul', 'ol', 'table')) && !$close) { |
|
| 415 | - $this->_num++; |
|
| 416 | - $this->_level[count($this->_level)] = $this->_num; |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - // get the level of the table containing the element |
|
| 420 | - if (!isset($param['num'])) { |
|
| 421 | - $param['num'] = $this->_level[count($this->_level)-1]; |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - // for closures table: remove a level |
|
| 425 | - if (in_array($name, array('ul', 'ol', 'table')) && $close) { |
|
| 426 | - unset($this->_level[count($this->_level)-1]); |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - // prepare the parameters |
|
| 430 | - if (isset($param['value'])) $param['value'] = $this->_prepareTxt($param['value']); |
|
| 431 | - if (isset($param['alt'])) $param['alt'] = $this->_prepareTxt($param['alt']); |
|
| 432 | - if (isset($param['title'])) $param['title'] = $this->_prepareTxt($param['title']); |
|
| 433 | - if (isset($param['class'])) $param['class'] = $this->_prepareTxt($param['class']); |
|
| 434 | - |
|
| 435 | - // return the new action to do |
|
| 436 | - return array('name' => $name, 'close' => $close ? 1 : 0, 'autoclose' => $autoclose, 'param' => $param); |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - /** |
|
| 440 | - * get a full level of HTML, between an opening and closing corresponding |
|
| 441 | - * |
|
| 442 | - * @param integer key |
|
| 443 | - * @return array actions |
|
| 444 | - */ |
|
| 445 | - public function getLevel($k) |
|
| 446 | - { |
|
| 447 | - // if the code does not exist => return empty |
|
| 448 | - if (!isset($this->code[$k])) return array(); |
|
| 449 | - |
|
| 450 | - // the tag to detect |
|
| 451 | - $detect = $this->code[$k]['name']; |
|
| 452 | - |
|
| 453 | - // if it is a text => return |
|
| 454 | - if ($detect=='write') { |
|
| 455 | - return array($this->code[$k]); |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - // |
|
| 459 | - $level = 0; // depth level |
|
| 460 | - $end = false; // end of the search |
|
| 461 | - $code = array(); // extract code |
|
| 462 | - |
|
| 463 | - // while it's not ended |
|
| 464 | - while (!$end) { |
|
| 465 | - // current action |
|
| 466 | - $row = $this->code[$k]; |
|
| 467 | - |
|
| 468 | - // if 'write' => we add the text |
|
| 469 | - if ($row['name']=='write') { |
|
| 470 | - $code[] = $row; |
|
| 471 | - } else { // else, it is a html tag |
|
| 472 | - $not = false; // flag for not taking into account the current tag |
|
| 473 | - |
|
| 474 | - // if it is the searched tag |
|
| 475 | - if ($row['name']==$detect) { |
|
| 476 | - // if we are just at the root level => dont take it |
|
| 477 | - if ($level==0) { |
|
| 478 | - $not = true; |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - // update the level |
|
| 482 | - $level+= ($row['close'] ? -1 : 1); |
|
| 483 | - |
|
| 484 | - // if we are now at the root level => it is the end, and dont take it |
|
| 485 | - if ($level==0) { |
|
| 486 | - $not = true; |
|
| 487 | - $end = true; |
|
| 488 | - } |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - // if we can takin into account the current tag => save it |
|
| 492 | - if (!$not) { |
|
| 493 | - if (isset($row['style']['text-align'])) unset($row['style']['text-align']); |
|
| 494 | - $code[] = $row; |
|
| 495 | - } |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - // it continues as long as there has code to analise |
|
| 499 | - if (isset($this->code[$k+1])) |
|
| 500 | - $k++; |
|
| 501 | - else |
|
| 502 | - $end = true; |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - // return the extract |
|
| 506 | - return $code; |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - /** |
|
| 510 | - * return a part of the HTML code, for error message |
|
| 511 | - * |
|
| 512 | - * @param integer position |
|
| 513 | - * @param integer take before |
|
| 514 | - * @param integer take after |
|
| 515 | - * @return string part of the html code |
|
| 516 | - */ |
|
| 517 | - public function getHtmlErrorCode($pos, $before=30, $after=40) |
|
| 518 | - { |
|
| 519 | - return substr($this->_html, $pos-$before, $before+$after); |
|
| 520 | - } |
|
| 107 | + // if it is a real HTML tag |
|
| 108 | + if ($res) { |
|
| 109 | + // save the current posistion in the HTML code |
|
| 110 | + $res['html_pos'] = $part[2]; |
|
| 111 | + |
|
| 112 | + // if the tag must be closed |
|
| 113 | + if (!in_array($res['name'], $tagsNotClosed)) { |
|
| 114 | + // if it is a closure tag |
|
| 115 | + if ($res['close']) { |
|
| 116 | + // HTML validation |
|
| 117 | + if (count($parents)<1) |
|
| 118 | + throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos'])); |
|
| 119 | + else if ($parents[count($parents)-1]!=$res['name']) |
|
| 120 | + throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos'])); |
|
| 121 | + else |
|
| 122 | + unset($parents[count($parents)-1]); |
|
| 123 | + } else { |
|
| 124 | + // if it is a autoclosed tag |
|
| 125 | + if ($res['autoclose']) { |
|
| 126 | + // save the opened tag |
|
| 127 | + $actions[] = $res; |
|
| 128 | + |
|
| 129 | + // prepare the closed tag |
|
| 130 | + $res['params'] = array(); |
|
| 131 | + $res['close'] = true; |
|
| 132 | + } |
|
| 133 | + // else :add a child for validation |
|
| 134 | + else |
|
| 135 | + $parents[count($parents)] = $res['name']; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + // if it is a <pre> tag (or <code> tag) not auclosed => update the flag |
|
| 139 | + if (($res['name']=='pre' || $res['name']=='code') && !$res['autoclose']) { |
|
| 140 | + $tagPreIn = !$res['close']; |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + // save the actions to convert |
|
| 145 | + $actions[] = $res; |
|
| 146 | + } else { // else (it is not a real HTML tag => we transform it in Texte |
|
| 147 | + $part[0]='txt'; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + // if it is text |
|
| 151 | + if ($part[0]=='txt') { |
|
| 152 | + // if we are not in a <pre> tag |
|
| 153 | + if (!$tagPreIn) { |
|
| 154 | + // save the action |
|
| 155 | + $actions[] = array( |
|
| 156 | + 'name' => 'write', |
|
| 157 | + 'close' => false, |
|
| 158 | + 'param' => array('txt' => $this->_prepareTxt($part[1])), |
|
| 159 | + ); |
|
| 160 | + } else { // else (if we are in a <pre> tag) |
|
| 161 | + // prepare the text |
|
| 162 | + $part[1] = str_replace("\r", '', $part[1]); |
|
| 163 | + $part[1] = explode("\n", $part[1]); |
|
| 164 | + |
|
| 165 | + // foreach line of the text |
|
| 166 | + foreach ($part[1] as $k => $txt) { |
|
| 167 | + // transform the line |
|
| 168 | + $txt = str_replace("\t", self::HTML_TAB, $txt); |
|
| 169 | + $txt = str_replace(' ', ' ', $txt); |
|
| 170 | + |
|
| 171 | + // add a break line |
|
| 172 | + if ($k>0) $actions[] = $tagPreBr; |
|
| 173 | + |
|
| 174 | + // save the action |
|
| 175 | + $actions[] = array( |
|
| 176 | + 'name' => 'write', |
|
| 177 | + 'close' => false, |
|
| 178 | + 'param' => array('txt' => $this->_prepareTxt($txt, false)), |
|
| 179 | + ); |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + // for each indentified action, we have to clean up the begin and the end of the texte |
|
| 186 | + // based on tags that surround it |
|
| 187 | + |
|
| 188 | + // list of the tags to clean |
|
| 189 | + $tagsToClean = array( |
|
| 190 | + 'page', 'page_header', 'page_footer', 'form', |
|
| 191 | + 'table', 'thead', 'tfoot', 'tr', 'td', 'th', 'br', |
|
| 192 | + 'div', 'hr', 'p', 'ul', 'ol', 'li', |
|
| 193 | + 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', |
|
| 194 | + 'bookmark', 'fieldset', 'legend', |
|
| 195 | + 'draw', 'circle', 'ellipse', 'path', 'rect', 'line', 'g', 'polygon', 'polyline', |
|
| 196 | + 'option' |
|
| 197 | + ); |
|
| 198 | + |
|
| 199 | + // foreach action |
|
| 200 | + $nb = count($actions); |
|
| 201 | + for ($k=0; $k<$nb; $k++) { |
|
| 202 | + // if it is a Text |
|
| 203 | + if ($actions[$k]['name']=='write') { |
|
| 204 | + // if the tag before the text is a tag to clean => ltrim on the text |
|
| 205 | + if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean)) |
|
| 206 | + $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']); |
|
| 207 | + |
|
| 208 | + // if the tag after the text is a tag to clean => rtrim on the text |
|
| 209 | + if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean)) |
|
| 210 | + $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']); |
|
| 211 | + |
|
| 212 | + // if the text is empty => remove the action |
|
| 213 | + if (!strlen($actions[$k]['param']['txt'])) |
|
| 214 | + unset($actions[$k]); |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + // if we are not on the level 0 => HTML validator ERROR |
|
| 219 | + if (count($parents)) throw new HTML2PDF_exception(5, $parents); |
|
| 220 | + |
|
| 221 | + // save the actions to do |
|
| 222 | + $this->code = array_values($actions); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * prepare the text |
|
| 227 | + * |
|
| 228 | + * @param string texte |
|
| 229 | + * @param boolean true => replace multiple space+\t+\r+\n by a single space |
|
| 230 | + * @return string texte |
|
| 231 | + * @access protected |
|
| 232 | + */ |
|
| 233 | + protected function _prepareTxt($txt, $spaces = true) |
|
| 234 | + { |
|
| 235 | + if ($spaces) $txt = preg_replace('/\s+/is', ' ', $txt); |
|
| 236 | + $txt = str_replace('€', '€', $txt); |
|
| 237 | + $txt = html_entity_decode($txt, ENT_QUOTES, $this->_encoding); |
|
| 238 | + return $txt; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * parse the HTML code |
|
| 243 | + * |
|
| 244 | + * @param &array array's result |
|
| 245 | + * @return null |
|
| 246 | + */ |
|
| 247 | + protected function _searchCode(&$tmp) |
|
| 248 | + { |
|
| 249 | + // initialise the array |
|
| 250 | + $tmp = array(); |
|
| 251 | + |
|
| 252 | + // regexp to separate the tags from the texts |
|
| 253 | + $reg = '/(<[^>]+>)|([^<]+)+/isU'; |
|
| 254 | + |
|
| 255 | + // last match found |
|
| 256 | + $str = ''; |
|
| 257 | + $offset = 0; |
|
| 258 | + |
|
| 259 | + // As it finds a match |
|
| 260 | + while (preg_match($reg, $this->_html, $parse, PREG_OFFSET_CAPTURE, $offset)) { |
|
| 261 | + // if it is a tag |
|
| 262 | + if ($parse[1][0]) { |
|
| 263 | + // save the previous text if it exists |
|
| 264 | + if ($str!=='') $tmp[] = array('txt', $str); |
|
| 265 | + |
|
| 266 | + // save the tag, with the offset |
|
| 267 | + $tmp[] = array('code', trim($parse[1][0]), $offset); |
|
| 268 | + |
|
| 269 | + // init the current text |
|
| 270 | + $str = ''; |
|
| 271 | + } else { // else (if it is a text) |
|
| 272 | + // add the new text to the current text |
|
| 273 | + $str.= $parse[2][0]; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + // Update offset to the end of the match |
|
| 277 | + $offset = $parse[0][1] + strlen($parse[0][0]); |
|
| 278 | + unset($parse); |
|
| 279 | + } |
|
| 280 | + // if a text is present in the end, we save it |
|
| 281 | + if ($str!='') $tmp[] = array('txt', $str); |
|
| 282 | + unset($str); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * analise a HTML tag |
|
| 287 | + * |
|
| 288 | + * @param string HTML code to analise |
|
| 289 | + * @return array corresponding action |
|
| 290 | + */ |
|
| 291 | + protected function _analiseCode($code) |
|
| 292 | + { |
|
| 293 | + // name of the tag, opening, closure, autoclosure |
|
| 294 | + $tag = '<([\/]{0,1})([_a-z0-9]+)([\/>\s]+)'; |
|
| 295 | + if (!preg_match('/'.$tag.'/isU', $code, $match)) return null; |
|
| 296 | + $close = ($match[1]=='/' ? true : false); |
|
| 297 | + $autoclose = preg_match('/\/>$/isU', $code); |
|
| 298 | + $name = strtolower($match[2]); |
|
| 299 | + |
|
| 300 | + // required parameters (depends on the tag name) |
|
| 301 | + $param = array(); |
|
| 302 | + $param['style'] = ''; |
|
| 303 | + if ($name=='img') { |
|
| 304 | + $param['alt'] = ''; |
|
| 305 | + $param['src'] = ''; |
|
| 306 | + } |
|
| 307 | + if ($name=='a') { |
|
| 308 | + $param['href'] = ''; |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + // read the parameters : nom=valeur |
|
| 312 | + $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)'; |
|
| 313 | + preg_match_all('/'.$prop.'/is', $code, $match); |
|
| 314 | + for($k=0; $k<count($match[0]); $k++) |
|
| 315 | + $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 316 | + |
|
| 317 | + // read the parameters : nom="valeur" |
|
| 318 | + $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]'; |
|
| 319 | + preg_match_all('/'.$prop.'/is', $code, $match); |
|
| 320 | + for($k=0; $k<count($match[0]); $k++) |
|
| 321 | + $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 322 | + |
|
| 323 | + // read the parameters : nom='valeur' |
|
| 324 | + $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']"; |
|
| 325 | + preg_match_all('/'.$prop.'/is', $code, $match); |
|
| 326 | + for($k=0; $k<count($match[0]); $k++) |
|
| 327 | + $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 328 | + |
|
| 329 | + // compliance of each parameter |
|
| 330 | + $color = "#000000"; |
|
| 331 | + $border = null; |
|
| 332 | + foreach ($param as $key => $val) { |
|
| 333 | + $key = strtolower($key); |
|
| 334 | + switch($key) |
|
| 335 | + { |
|
| 336 | + case 'width': |
|
| 337 | + unset($param[$key]); |
|
| 338 | + $param['style'] .= 'width: '.$val.'px; '; |
|
| 339 | + break; |
|
| 340 | + |
|
| 341 | + case 'align': |
|
| 342 | + if ($name==='img') { |
|
| 343 | + unset($param[$key]); |
|
| 344 | + $param['style'] .= 'float: '.$val.'; '; |
|
| 345 | + } elseif ($name!=='table') { |
|
| 346 | + unset($param[$key]); |
|
| 347 | + $param['style'] .= 'text-align: '.$val.'; '; |
|
| 348 | + } |
|
| 349 | + break; |
|
| 350 | + |
|
| 351 | + case 'valign': |
|
| 352 | + unset($param[$key]); |
|
| 353 | + $param['style'] .= 'vertical-align: '.$val.'; '; |
|
| 354 | + break; |
|
| 355 | + |
|
| 356 | + case 'height': |
|
| 357 | + unset($param[$key]); |
|
| 358 | + $param['style'] .= 'height: '.$val.'px; '; |
|
| 359 | + break; |
|
| 360 | + |
|
| 361 | + case 'bgcolor': |
|
| 362 | + unset($param[$key]); |
|
| 363 | + $param['style'] .= 'background: '.$val.'; '; |
|
| 364 | + break; |
|
| 365 | + |
|
| 366 | + case 'bordercolor': |
|
| 367 | + unset($param[$key]); |
|
| 368 | + $color = $val; |
|
| 369 | + break; |
|
| 370 | + |
|
| 371 | + case 'border': |
|
| 372 | + unset($param[$key]); |
|
| 373 | + if (preg_match('/^[0-9]+$/isU', $val)) $val = $val.'px'; |
|
| 374 | + $border = $val; |
|
| 375 | + break; |
|
| 376 | + |
|
| 377 | + case 'cellpadding': |
|
| 378 | + case 'cellspacing': |
|
| 379 | + if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val.'px'; |
|
| 380 | + break; |
|
| 381 | + |
|
| 382 | + case 'colspan': |
|
| 383 | + case 'rowspan': |
|
| 384 | + $val = preg_replace('/[^0-9]/isU', '', $val); |
|
| 385 | + if (!$val) $val = 1; |
|
| 386 | + $param[$key] = $val; |
|
| 387 | + break; |
|
| 388 | + } |
|
| 389 | + } |
|
| 390 | + |
|
| 391 | + // compliance of the border |
|
| 392 | + if ($border!==null) { |
|
| 393 | + if ($border) $border = 'border: solid '.$border.' '.$color; |
|
| 394 | + else $border = 'border: none'; |
|
| 395 | + |
|
| 396 | + $param['style'] .= $border.'; '; |
|
| 397 | + $param['border'] = $border; |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + // reading styles: decomposition and standardization |
|
| 401 | + $styles = explode(';', $param['style']); |
|
| 402 | + $param['style'] = array(); |
|
| 403 | + foreach ($styles as $style) { |
|
| 404 | + $tmp = explode(':', $style); |
|
| 405 | + if (count($tmp)>1) { |
|
| 406 | + $cod = $tmp[0]; |
|
| 407 | + unset($tmp[0]); |
|
| 408 | + $tmp = implode(':', $tmp); |
|
| 409 | + $param['style'][trim(strtolower($cod))] = preg_replace('/[\s]+/isU', ' ', trim($tmp)); |
|
| 410 | + } |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + // determining the level of table opening, with an added level |
|
| 414 | + if (in_array($name, array('ul', 'ol', 'table')) && !$close) { |
|
| 415 | + $this->_num++; |
|
| 416 | + $this->_level[count($this->_level)] = $this->_num; |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + // get the level of the table containing the element |
|
| 420 | + if (!isset($param['num'])) { |
|
| 421 | + $param['num'] = $this->_level[count($this->_level)-1]; |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + // for closures table: remove a level |
|
| 425 | + if (in_array($name, array('ul', 'ol', 'table')) && $close) { |
|
| 426 | + unset($this->_level[count($this->_level)-1]); |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + // prepare the parameters |
|
| 430 | + if (isset($param['value'])) $param['value'] = $this->_prepareTxt($param['value']); |
|
| 431 | + if (isset($param['alt'])) $param['alt'] = $this->_prepareTxt($param['alt']); |
|
| 432 | + if (isset($param['title'])) $param['title'] = $this->_prepareTxt($param['title']); |
|
| 433 | + if (isset($param['class'])) $param['class'] = $this->_prepareTxt($param['class']); |
|
| 434 | + |
|
| 435 | + // return the new action to do |
|
| 436 | + return array('name' => $name, 'close' => $close ? 1 : 0, 'autoclose' => $autoclose, 'param' => $param); |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + /** |
|
| 440 | + * get a full level of HTML, between an opening and closing corresponding |
|
| 441 | + * |
|
| 442 | + * @param integer key |
|
| 443 | + * @return array actions |
|
| 444 | + */ |
|
| 445 | + public function getLevel($k) |
|
| 446 | + { |
|
| 447 | + // if the code does not exist => return empty |
|
| 448 | + if (!isset($this->code[$k])) return array(); |
|
| 449 | + |
|
| 450 | + // the tag to detect |
|
| 451 | + $detect = $this->code[$k]['name']; |
|
| 452 | + |
|
| 453 | + // if it is a text => return |
|
| 454 | + if ($detect=='write') { |
|
| 455 | + return array($this->code[$k]); |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + // |
|
| 459 | + $level = 0; // depth level |
|
| 460 | + $end = false; // end of the search |
|
| 461 | + $code = array(); // extract code |
|
| 462 | + |
|
| 463 | + // while it's not ended |
|
| 464 | + while (!$end) { |
|
| 465 | + // current action |
|
| 466 | + $row = $this->code[$k]; |
|
| 467 | + |
|
| 468 | + // if 'write' => we add the text |
|
| 469 | + if ($row['name']=='write') { |
|
| 470 | + $code[] = $row; |
|
| 471 | + } else { // else, it is a html tag |
|
| 472 | + $not = false; // flag for not taking into account the current tag |
|
| 473 | + |
|
| 474 | + // if it is the searched tag |
|
| 475 | + if ($row['name']==$detect) { |
|
| 476 | + // if we are just at the root level => dont take it |
|
| 477 | + if ($level==0) { |
|
| 478 | + $not = true; |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + // update the level |
|
| 482 | + $level+= ($row['close'] ? -1 : 1); |
|
| 483 | + |
|
| 484 | + // if we are now at the root level => it is the end, and dont take it |
|
| 485 | + if ($level==0) { |
|
| 486 | + $not = true; |
|
| 487 | + $end = true; |
|
| 488 | + } |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + // if we can takin into account the current tag => save it |
|
| 492 | + if (!$not) { |
|
| 493 | + if (isset($row['style']['text-align'])) unset($row['style']['text-align']); |
|
| 494 | + $code[] = $row; |
|
| 495 | + } |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + // it continues as long as there has code to analise |
|
| 499 | + if (isset($this->code[$k+1])) |
|
| 500 | + $k++; |
|
| 501 | + else |
|
| 502 | + $end = true; |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + // return the extract |
|
| 506 | + return $code; |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + /** |
|
| 510 | + * return a part of the HTML code, for error message |
|
| 511 | + * |
|
| 512 | + * @param integer position |
|
| 513 | + * @param integer take before |
|
| 514 | + * @param integer take after |
|
| 515 | + * @return string part of the html code |
|
| 516 | + */ |
|
| 517 | + public function getHtmlErrorCode($pos, $before=30, $after=40) |
|
| 518 | + { |
|
| 519 | + return substr($this->_html, $pos-$before, $before+$after); |
|
| 520 | + } |
|
| 521 | 521 | } |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class HTML2PDF_parsingHtml |
| 13 | 13 | { |
| 14 | - protected $_html = ''; // HTML code to parse |
|
| 15 | - protected $_num = 0; // table number |
|
| 16 | - protected $_level = 0; // table level |
|
| 17 | - protected $_encoding = ''; // encoding |
|
| 18 | - public $code = array(); // parsed HTML codfe |
|
| 14 | + protected $_html = ''; // HTML code to parse |
|
| 15 | + protected $_num = 0; // table number |
|
| 16 | + protected $_level = 0; // table level |
|
| 17 | + protected $_encoding = ''; // encoding |
|
| 18 | + public $code = array(); // parsed HTML codfe |
|
| 19 | 19 | |
| 20 | 20 | const HTML_TAB = ' '; |
| 21 | 21 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $this->_num = 0; |
| 31 | 31 | $this->_level = array($this->_num); |
| 32 | 32 | $this->_html = ''; |
| 33 | - $this->code = array(); |
|
| 33 | + $this->code = array(); |
|
| 34 | 34 | $this->setEncoding($encoding); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | // foreach part of the HTML code |
| 100 | 100 | foreach ($tmp as $part) { |
| 101 | 101 | // if it is a tag code |
| 102 | - if ($part[0]=='code') { |
|
| 102 | + if ($part[0] == 'code') { |
|
| 103 | 103 | // analise the HTML code |
| 104 | 104 | $res = $this->_analiseCode($part[1]); |
| 105 | 105 | |
@@ -110,16 +110,16 @@ discard block |
||
| 110 | 110 | $res['html_pos'] = $part[2]; |
| 111 | 111 | |
| 112 | 112 | // if the tag must be closed |
| 113 | - if (!in_array($res['name'], $tagsNotClosed)) { |
|
| 113 | + if ( ! in_array($res['name'], $tagsNotClosed)) { |
|
| 114 | 114 | // if it is a closure tag |
| 115 | 115 | if ($res['close']) { |
| 116 | 116 | // HTML validation |
| 117 | - if (count($parents)<1) |
|
| 117 | + if (count($parents) < 1) |
|
| 118 | 118 | throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos'])); |
| 119 | - else if ($parents[count($parents)-1]!=$res['name']) |
|
| 119 | + else if ($parents[count($parents) - 1] != $res['name']) |
|
| 120 | 120 | throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos'])); |
| 121 | 121 | else |
| 122 | - unset($parents[count($parents)-1]); |
|
| 122 | + unset($parents[count($parents) - 1]); |
|
| 123 | 123 | } else { |
| 124 | 124 | // if it is a autoclosed tag |
| 125 | 125 | if ($res['autoclose']) { |
@@ -136,21 +136,21 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // if it is a <pre> tag (or <code> tag) not auclosed => update the flag |
| 139 | - if (($res['name']=='pre' || $res['name']=='code') && !$res['autoclose']) { |
|
| 140 | - $tagPreIn = !$res['close']; |
|
| 139 | + if (($res['name'] == 'pre' || $res['name'] == 'code') && ! $res['autoclose']) { |
|
| 140 | + $tagPreIn = ! $res['close']; |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // save the actions to convert |
| 145 | 145 | $actions[] = $res; |
| 146 | 146 | } else { // else (it is not a real HTML tag => we transform it in Texte |
| 147 | - $part[0]='txt'; |
|
| 147 | + $part[0] = 'txt'; |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | // if it is text |
| 151 | - if ($part[0]=='txt') { |
|
| 151 | + if ($part[0] == 'txt') { |
|
| 152 | 152 | // if we are not in a <pre> tag |
| 153 | - if (!$tagPreIn) { |
|
| 153 | + if ( ! $tagPreIn) { |
|
| 154 | 154 | // save the action |
| 155 | 155 | $actions[] = array( |
| 156 | 156 | 'name' => 'write', |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | $txt = str_replace(' ', ' ', $txt); |
| 170 | 170 | |
| 171 | 171 | // add a break line |
| 172 | - if ($k>0) $actions[] = $tagPreBr; |
|
| 172 | + if ($k > 0) $actions[] = $tagPreBr; |
|
| 173 | 173 | |
| 174 | 174 | // save the action |
| 175 | 175 | $actions[] = array( |
@@ -198,19 +198,19 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | // foreach action |
| 200 | 200 | $nb = count($actions); |
| 201 | - for ($k=0; $k<$nb; $k++) { |
|
| 201 | + for ($k = 0; $k < $nb; $k++) { |
|
| 202 | 202 | // if it is a Text |
| 203 | - if ($actions[$k]['name']=='write') { |
|
| 203 | + if ($actions[$k]['name'] == 'write') { |
|
| 204 | 204 | // if the tag before the text is a tag to clean => ltrim on the text |
| 205 | - if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean)) |
|
| 205 | + if ($k > 0 && in_array($actions[$k - 1]['name'], $tagsToClean)) |
|
| 206 | 206 | $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']); |
| 207 | 207 | |
| 208 | 208 | // if the tag after the text is a tag to clean => rtrim on the text |
| 209 | - if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean)) |
|
| 209 | + if ($k < $nb - 1 && in_array($actions[$k + 1]['name'], $tagsToClean)) |
|
| 210 | 210 | $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']); |
| 211 | 211 | |
| 212 | 212 | // if the text is empty => remove the action |
| 213 | - if (!strlen($actions[$k]['param']['txt'])) |
|
| 213 | + if ( ! strlen($actions[$k]['param']['txt'])) |
|
| 214 | 214 | unset($actions[$k]); |
| 215 | 215 | } |
| 216 | 216 | } |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | // if it is a tag |
| 262 | 262 | if ($parse[1][0]) { |
| 263 | 263 | // save the previous text if it exists |
| 264 | - if ($str!=='') $tmp[] = array('txt', $str); |
|
| 264 | + if ($str !== '') $tmp[] = array('txt', $str); |
|
| 265 | 265 | |
| 266 | 266 | // save the tag, with the offset |
| 267 | 267 | $tmp[] = array('code', trim($parse[1][0]), $offset); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $str = ''; |
| 271 | 271 | } else { // else (if it is a text) |
| 272 | 272 | // add the new text to the current text |
| 273 | - $str.= $parse[2][0]; |
|
| 273 | + $str .= $parse[2][0]; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // Update offset to the end of the match |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | unset($parse); |
| 279 | 279 | } |
| 280 | 280 | // if a text is present in the end, we save it |
| 281 | - if ($str!='') $tmp[] = array('txt', $str); |
|
| 281 | + if ($str != '') $tmp[] = array('txt', $str); |
|
| 282 | 282 | unset($str); |
| 283 | 283 | } |
| 284 | 284 | |
@@ -292,38 +292,38 @@ discard block |
||
| 292 | 292 | { |
| 293 | 293 | // name of the tag, opening, closure, autoclosure |
| 294 | 294 | $tag = '<([\/]{0,1})([_a-z0-9]+)([\/>\s]+)'; |
| 295 | - if (!preg_match('/'.$tag.'/isU', $code, $match)) return null; |
|
| 296 | - $close = ($match[1]=='/' ? true : false); |
|
| 295 | + if ( ! preg_match('/'.$tag.'/isU', $code, $match)) return null; |
|
| 296 | + $close = ($match[1] == '/' ? true : false); |
|
| 297 | 297 | $autoclose = preg_match('/\/>$/isU', $code); |
| 298 | 298 | $name = strtolower($match[2]); |
| 299 | 299 | |
| 300 | 300 | // required parameters (depends on the tag name) |
| 301 | - $param = array(); |
|
| 301 | + $param = array(); |
|
| 302 | 302 | $param['style'] = ''; |
| 303 | - if ($name=='img') { |
|
| 303 | + if ($name == 'img') { |
|
| 304 | 304 | $param['alt'] = ''; |
| 305 | 305 | $param['src'] = ''; |
| 306 | 306 | } |
| 307 | - if ($name=='a') { |
|
| 307 | + if ($name == 'a') { |
|
| 308 | 308 | $param['href'] = ''; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // read the parameters : nom=valeur |
| 312 | 312 | $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)'; |
| 313 | 313 | preg_match_all('/'.$prop.'/is', $code, $match); |
| 314 | - for($k=0; $k<count($match[0]); $k++) |
|
| 314 | + for ($k = 0; $k < count($match[0]); $k++) |
|
| 315 | 315 | $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
| 316 | 316 | |
| 317 | 317 | // read the parameters : nom="valeur" |
| 318 | 318 | $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]'; |
| 319 | 319 | preg_match_all('/'.$prop.'/is', $code, $match); |
| 320 | - for($k=0; $k<count($match[0]); $k++) |
|
| 320 | + for ($k = 0; $k < count($match[0]); $k++) |
|
| 321 | 321 | $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
| 322 | 322 | |
| 323 | 323 | // read the parameters : nom='valeur' |
| 324 | 324 | $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']"; |
| 325 | 325 | preg_match_all('/'.$prop.'/is', $code, $match); |
| 326 | - for($k=0; $k<count($match[0]); $k++) |
|
| 326 | + for ($k = 0; $k < count($match[0]); $k++) |
|
| 327 | 327 | $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
| 328 | 328 | |
| 329 | 329 | // compliance of each parameter |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | $border = null; |
| 332 | 332 | foreach ($param as $key => $val) { |
| 333 | 333 | $key = strtolower($key); |
| 334 | - switch($key) |
|
| 334 | + switch ($key) |
|
| 335 | 335 | { |
| 336 | 336 | case 'width': |
| 337 | 337 | unset($param[$key]); |
@@ -339,10 +339,10 @@ discard block |
||
| 339 | 339 | break; |
| 340 | 340 | |
| 341 | 341 | case 'align': |
| 342 | - if ($name==='img') { |
|
| 342 | + if ($name === 'img') { |
|
| 343 | 343 | unset($param[$key]); |
| 344 | 344 | $param['style'] .= 'float: '.$val.'; '; |
| 345 | - } elseif ($name!=='table') { |
|
| 345 | + } elseif ($name !== 'table') { |
|
| 346 | 346 | unset($param[$key]); |
| 347 | 347 | $param['style'] .= 'text-align: '.$val.'; '; |
| 348 | 348 | } |
@@ -382,14 +382,14 @@ discard block |
||
| 382 | 382 | case 'colspan': |
| 383 | 383 | case 'rowspan': |
| 384 | 384 | $val = preg_replace('/[^0-9]/isU', '', $val); |
| 385 | - if (!$val) $val = 1; |
|
| 385 | + if ( ! $val) $val = 1; |
|
| 386 | 386 | $param[$key] = $val; |
| 387 | 387 | break; |
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | // compliance of the border |
| 392 | - if ($border!==null) { |
|
| 392 | + if ($border !== null) { |
|
| 393 | 393 | if ($border) $border = 'border: solid '.$border.' '.$color; |
| 394 | 394 | else $border = 'border: none'; |
| 395 | 395 | |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | $param['style'] = array(); |
| 403 | 403 | foreach ($styles as $style) { |
| 404 | 404 | $tmp = explode(':', $style); |
| 405 | - if (count($tmp)>1) { |
|
| 405 | + if (count($tmp) > 1) { |
|
| 406 | 406 | $cod = $tmp[0]; |
| 407 | 407 | unset($tmp[0]); |
| 408 | 408 | $tmp = implode(':', $tmp); |
@@ -411,19 +411,19 @@ discard block |
||
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | // determining the level of table opening, with an added level |
| 414 | - if (in_array($name, array('ul', 'ol', 'table')) && !$close) { |
|
| 414 | + if (in_array($name, array('ul', 'ol', 'table')) && ! $close) { |
|
| 415 | 415 | $this->_num++; |
| 416 | 416 | $this->_level[count($this->_level)] = $this->_num; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | // get the level of the table containing the element |
| 420 | - if (!isset($param['num'])) { |
|
| 421 | - $param['num'] = $this->_level[count($this->_level)-1]; |
|
| 420 | + if ( ! isset($param['num'])) { |
|
| 421 | + $param['num'] = $this->_level[count($this->_level) - 1]; |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | // for closures table: remove a level |
| 425 | 425 | if (in_array($name, array('ul', 'ol', 'table')) && $close) { |
| 426 | - unset($this->_level[count($this->_level)-1]); |
|
| 426 | + unset($this->_level[count($this->_level) - 1]); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | // prepare the parameters |
@@ -445,58 +445,58 @@ discard block |
||
| 445 | 445 | public function getLevel($k) |
| 446 | 446 | { |
| 447 | 447 | // if the code does not exist => return empty |
| 448 | - if (!isset($this->code[$k])) return array(); |
|
| 448 | + if ( ! isset($this->code[$k])) return array(); |
|
| 449 | 449 | |
| 450 | 450 | // the tag to detect |
| 451 | 451 | $detect = $this->code[$k]['name']; |
| 452 | 452 | |
| 453 | 453 | // if it is a text => return |
| 454 | - if ($detect=='write') { |
|
| 454 | + if ($detect == 'write') { |
|
| 455 | 455 | return array($this->code[$k]); |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | // |
| 459 | - $level = 0; // depth level |
|
| 460 | - $end = false; // end of the search |
|
| 459 | + $level = 0; // depth level |
|
| 460 | + $end = false; // end of the search |
|
| 461 | 461 | $code = array(); // extract code |
| 462 | 462 | |
| 463 | 463 | // while it's not ended |
| 464 | - while (!$end) { |
|
| 464 | + while ( ! $end) { |
|
| 465 | 465 | // current action |
| 466 | 466 | $row = $this->code[$k]; |
| 467 | 467 | |
| 468 | 468 | // if 'write' => we add the text |
| 469 | - if ($row['name']=='write') { |
|
| 469 | + if ($row['name'] == 'write') { |
|
| 470 | 470 | $code[] = $row; |
| 471 | 471 | } else { // else, it is a html tag |
| 472 | 472 | $not = false; // flag for not taking into account the current tag |
| 473 | 473 | |
| 474 | 474 | // if it is the searched tag |
| 475 | - if ($row['name']==$detect) { |
|
| 475 | + if ($row['name'] == $detect) { |
|
| 476 | 476 | // if we are just at the root level => dont take it |
| 477 | - if ($level==0) { |
|
| 477 | + if ($level == 0) { |
|
| 478 | 478 | $not = true; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | // update the level |
| 482 | - $level+= ($row['close'] ? -1 : 1); |
|
| 482 | + $level += ($row['close'] ? -1 : 1); |
|
| 483 | 483 | |
| 484 | 484 | // if we are now at the root level => it is the end, and dont take it |
| 485 | - if ($level==0) { |
|
| 485 | + if ($level == 0) { |
|
| 486 | 486 | $not = true; |
| 487 | 487 | $end = true; |
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | // if we can takin into account the current tag => save it |
| 492 | - if (!$not) { |
|
| 492 | + if ( ! $not) { |
|
| 493 | 493 | if (isset($row['style']['text-align'])) unset($row['style']['text-align']); |
| 494 | 494 | $code[] = $row; |
| 495 | 495 | } |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | // it continues as long as there has code to analise |
| 499 | - if (isset($this->code[$k+1])) |
|
| 499 | + if (isset($this->code[$k + 1])) |
|
| 500 | 500 | $k++; |
| 501 | 501 | else |
| 502 | 502 | $end = true; |
@@ -514,8 +514,8 @@ discard block |
||
| 514 | 514 | * @param integer take after |
| 515 | 515 | * @return string part of the html code |
| 516 | 516 | */ |
| 517 | - public function getHtmlErrorCode($pos, $before=30, $after=40) |
|
| 517 | + public function getHtmlErrorCode($pos, $before = 30, $after = 40) |
|
| 518 | 518 | { |
| 519 | - return substr($this->_html, $pos-$before, $before+$after); |
|
| 519 | + return substr($this->_html, $pos - $before, $before + $after); |
|
| 520 | 520 | } |
| 521 | 521 | } |
@@ -114,12 +114,13 @@ discard block |
||
| 114 | 114 | // if it is a closure tag |
| 115 | 115 | if ($res['close']) { |
| 116 | 116 | // HTML validation |
| 117 | - if (count($parents)<1) |
|
| 118 | - throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos'])); |
|
| 119 | - else if ($parents[count($parents)-1]!=$res['name']) |
|
| 120 | - throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos'])); |
|
| 121 | - else |
|
| 122 | - unset($parents[count($parents)-1]); |
|
| 117 | + if (count($parents)<1) { |
|
| 118 | + throw new HTML2PDF_exception(3, $res['name'], $this->getHtmlErrorCode($res['html_pos'])); |
|
| 119 | + } else if ($parents[count($parents)-1]!=$res['name']) { |
|
| 120 | + throw new HTML2PDF_exception(4, $parents, $this->getHtmlErrorCode($res['html_pos'])); |
|
| 121 | + } else { |
|
| 122 | + unset($parents[count($parents)-1]); |
|
| 123 | + } |
|
| 123 | 124 | } else { |
| 124 | 125 | // if it is a autoclosed tag |
| 125 | 126 | if ($res['autoclose']) { |
@@ -131,8 +132,9 @@ discard block |
||
| 131 | 132 | $res['close'] = true; |
| 132 | 133 | } |
| 133 | 134 | // else :add a child for validation |
| 134 | - else |
|
| 135 | - $parents[count($parents)] = $res['name']; |
|
| 135 | + else { |
|
| 136 | + $parents[count($parents)] = $res['name']; |
|
| 137 | + } |
|
| 136 | 138 | } |
| 137 | 139 | |
| 138 | 140 | // if it is a <pre> tag (or <code> tag) not auclosed => update the flag |
@@ -169,7 +171,9 @@ discard block |
||
| 169 | 171 | $txt = str_replace(' ', ' ', $txt); |
| 170 | 172 | |
| 171 | 173 | // add a break line |
| 172 | - if ($k>0) $actions[] = $tagPreBr; |
|
| 174 | + if ($k>0) { |
|
| 175 | + $actions[] = $tagPreBr; |
|
| 176 | + } |
|
| 173 | 177 | |
| 174 | 178 | // save the action |
| 175 | 179 | $actions[] = array( |
@@ -202,21 +206,26 @@ discard block |
||
| 202 | 206 | // if it is a Text |
| 203 | 207 | if ($actions[$k]['name']=='write') { |
| 204 | 208 | // if the tag before the text is a tag to clean => ltrim on the text |
| 205 | - if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean)) |
|
| 206 | - $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']); |
|
| 209 | + if ($k>0 && in_array($actions[$k-1]['name'], $tagsToClean)) { |
|
| 210 | + $actions[$k]['param']['txt'] = ltrim($actions[$k]['param']['txt']); |
|
| 211 | + } |
|
| 207 | 212 | |
| 208 | 213 | // if the tag after the text is a tag to clean => rtrim on the text |
| 209 | - if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean)) |
|
| 210 | - $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']); |
|
| 214 | + if ($k<$nb-1 && in_array($actions[$k+1]['name'], $tagsToClean)) { |
|
| 215 | + $actions[$k]['param']['txt'] = rtrim($actions[$k]['param']['txt']); |
|
| 216 | + } |
|
| 211 | 217 | |
| 212 | 218 | // if the text is empty => remove the action |
| 213 | - if (!strlen($actions[$k]['param']['txt'])) |
|
| 214 | - unset($actions[$k]); |
|
| 219 | + if (!strlen($actions[$k]['param']['txt'])) { |
|
| 220 | + unset($actions[$k]); |
|
| 221 | + } |
|
| 215 | 222 | } |
| 216 | 223 | } |
| 217 | 224 | |
| 218 | 225 | // if we are not on the level 0 => HTML validator ERROR |
| 219 | - if (count($parents)) throw new HTML2PDF_exception(5, $parents); |
|
| 226 | + if (count($parents)) { |
|
| 227 | + throw new HTML2PDF_exception(5, $parents); |
|
| 228 | + } |
|
| 220 | 229 | |
| 221 | 230 | // save the actions to do |
| 222 | 231 | $this->code = array_values($actions); |
@@ -232,7 +241,9 @@ discard block |
||
| 232 | 241 | */ |
| 233 | 242 | protected function _prepareTxt($txt, $spaces = true) |
| 234 | 243 | { |
| 235 | - if ($spaces) $txt = preg_replace('/\s+/is', ' ', $txt); |
|
| 244 | + if ($spaces) { |
|
| 245 | + $txt = preg_replace('/\s+/is', ' ', $txt); |
|
| 246 | + } |
|
| 236 | 247 | $txt = str_replace('€', '€', $txt); |
| 237 | 248 | $txt = html_entity_decode($txt, ENT_QUOTES, $this->_encoding); |
| 238 | 249 | return $txt; |
@@ -261,7 +272,9 @@ discard block |
||
| 261 | 272 | // if it is a tag |
| 262 | 273 | if ($parse[1][0]) { |
| 263 | 274 | // save the previous text if it exists |
| 264 | - if ($str!=='') $tmp[] = array('txt', $str); |
|
| 275 | + if ($str!=='') { |
|
| 276 | + $tmp[] = array('txt', $str); |
|
| 277 | + } |
|
| 265 | 278 | |
| 266 | 279 | // save the tag, with the offset |
| 267 | 280 | $tmp[] = array('code', trim($parse[1][0]), $offset); |
@@ -278,7 +291,9 @@ discard block |
||
| 278 | 291 | unset($parse); |
| 279 | 292 | } |
| 280 | 293 | // if a text is present in the end, we save it |
| 281 | - if ($str!='') $tmp[] = array('txt', $str); |
|
| 294 | + if ($str!='') { |
|
| 295 | + $tmp[] = array('txt', $str); |
|
| 296 | + } |
|
| 282 | 297 | unset($str); |
| 283 | 298 | } |
| 284 | 299 | |
@@ -292,7 +307,9 @@ discard block |
||
| 292 | 307 | { |
| 293 | 308 | // name of the tag, opening, closure, autoclosure |
| 294 | 309 | $tag = '<([\/]{0,1})([_a-z0-9]+)([\/>\s]+)'; |
| 295 | - if (!preg_match('/'.$tag.'/isU', $code, $match)) return null; |
|
| 310 | + if (!preg_match('/'.$tag.'/isU', $code, $match)) { |
|
| 311 | + return null; |
|
| 312 | + } |
|
| 296 | 313 | $close = ($match[1]=='/' ? true : false); |
| 297 | 314 | $autoclose = preg_match('/\/>$/isU', $code); |
| 298 | 315 | $name = strtolower($match[2]); |
@@ -311,20 +328,23 @@ discard block |
||
| 311 | 328 | // read the parameters : nom=valeur |
| 312 | 329 | $prop = '([a-zA-Z0-9_]+)=([^"\'\s>]+)'; |
| 313 | 330 | preg_match_all('/'.$prop.'/is', $code, $match); |
| 314 | - for($k=0; $k<count($match[0]); $k++) |
|
| 315 | - $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 331 | + for($k=0; $k<count($match[0]); $k++) { |
|
| 332 | + $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 333 | + } |
|
| 316 | 334 | |
| 317 | 335 | // read the parameters : nom="valeur" |
| 318 | 336 | $prop = '([a-zA-Z0-9_]+)=["]([^"]*)["]'; |
| 319 | 337 | preg_match_all('/'.$prop.'/is', $code, $match); |
| 320 | - for($k=0; $k<count($match[0]); $k++) |
|
| 321 | - $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 338 | + for($k=0; $k<count($match[0]); $k++) { |
|
| 339 | + $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 340 | + } |
|
| 322 | 341 | |
| 323 | 342 | // read the parameters : nom='valeur' |
| 324 | 343 | $prop = "([a-zA-Z0-9_]+)=[']([^']*)[']"; |
| 325 | 344 | preg_match_all('/'.$prop.'/is', $code, $match); |
| 326 | - for($k=0; $k<count($match[0]); $k++) |
|
| 327 | - $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 345 | + for($k=0; $k<count($match[0]); $k++) { |
|
| 346 | + $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]); |
|
| 347 | + } |
|
| 328 | 348 | |
| 329 | 349 | // compliance of each parameter |
| 330 | 350 | $color = "#000000"; |
@@ -370,19 +390,25 @@ discard block |
||
| 370 | 390 | |
| 371 | 391 | case 'border': |
| 372 | 392 | unset($param[$key]); |
| 373 | - if (preg_match('/^[0-9]+$/isU', $val)) $val = $val.'px'; |
|
| 393 | + if (preg_match('/^[0-9]+$/isU', $val)) { |
|
| 394 | + $val = $val.'px'; |
|
| 395 | + } |
|
| 374 | 396 | $border = $val; |
| 375 | 397 | break; |
| 376 | 398 | |
| 377 | 399 | case 'cellpadding': |
| 378 | 400 | case 'cellspacing': |
| 379 | - if (preg_match('/^([0-9]+)$/isU', $val)) $param[$key] = $val.'px'; |
|
| 401 | + if (preg_match('/^([0-9]+)$/isU', $val)) { |
|
| 402 | + $param[$key] = $val.'px'; |
|
| 403 | + } |
|
| 380 | 404 | break; |
| 381 | 405 | |
| 382 | 406 | case 'colspan': |
| 383 | 407 | case 'rowspan': |
| 384 | 408 | $val = preg_replace('/[^0-9]/isU', '', $val); |
| 385 | - if (!$val) $val = 1; |
|
| 409 | + if (!$val) { |
|
| 410 | + $val = 1; |
|
| 411 | + } |
|
| 386 | 412 | $param[$key] = $val; |
| 387 | 413 | break; |
| 388 | 414 | } |
@@ -390,8 +416,11 @@ discard block |
||
| 390 | 416 | |
| 391 | 417 | // compliance of the border |
| 392 | 418 | if ($border!==null) { |
| 393 | - if ($border) $border = 'border: solid '.$border.' '.$color; |
|
| 394 | - else $border = 'border: none'; |
|
| 419 | + if ($border) { |
|
| 420 | + $border = 'border: solid '.$border.' '.$color; |
|
| 421 | + } else { |
|
| 422 | + $border = 'border: none'; |
|
| 423 | + } |
|
| 395 | 424 | |
| 396 | 425 | $param['style'] .= $border.'; '; |
| 397 | 426 | $param['border'] = $border; |
@@ -427,10 +456,18 @@ discard block |
||
| 427 | 456 | } |
| 428 | 457 | |
| 429 | 458 | // prepare the parameters |
| 430 | - if (isset($param['value'])) $param['value'] = $this->_prepareTxt($param['value']); |
|
| 431 | - if (isset($param['alt'])) $param['alt'] = $this->_prepareTxt($param['alt']); |
|
| 432 | - if (isset($param['title'])) $param['title'] = $this->_prepareTxt($param['title']); |
|
| 433 | - if (isset($param['class'])) $param['class'] = $this->_prepareTxt($param['class']); |
|
| 459 | + if (isset($param['value'])) { |
|
| 460 | + $param['value'] = $this->_prepareTxt($param['value']); |
|
| 461 | + } |
|
| 462 | + if (isset($param['alt'])) { |
|
| 463 | + $param['alt'] = $this->_prepareTxt($param['alt']); |
|
| 464 | + } |
|
| 465 | + if (isset($param['title'])) { |
|
| 466 | + $param['title'] = $this->_prepareTxt($param['title']); |
|
| 467 | + } |
|
| 468 | + if (isset($param['class'])) { |
|
| 469 | + $param['class'] = $this->_prepareTxt($param['class']); |
|
| 470 | + } |
|
| 434 | 471 | |
| 435 | 472 | // return the new action to do |
| 436 | 473 | return array('name' => $name, 'close' => $close ? 1 : 0, 'autoclose' => $autoclose, 'param' => $param); |
@@ -445,7 +482,9 @@ discard block |
||
| 445 | 482 | public function getLevel($k) |
| 446 | 483 | { |
| 447 | 484 | // if the code does not exist => return empty |
| 448 | - if (!isset($this->code[$k])) return array(); |
|
| 485 | + if (!isset($this->code[$k])) { |
|
| 486 | + return array(); |
|
| 487 | + } |
|
| 449 | 488 | |
| 450 | 489 | // the tag to detect |
| 451 | 490 | $detect = $this->code[$k]['name']; |
@@ -490,16 +529,19 @@ discard block |
||
| 490 | 529 | |
| 491 | 530 | // if we can takin into account the current tag => save it |
| 492 | 531 | if (!$not) { |
| 493 | - if (isset($row['style']['text-align'])) unset($row['style']['text-align']); |
|
| 532 | + if (isset($row['style']['text-align'])) { |
|
| 533 | + unset($row['style']['text-align']); |
|
| 534 | + } |
|
| 494 | 535 | $code[] = $row; |
| 495 | 536 | } |
| 496 | 537 | } |
| 497 | 538 | |
| 498 | 539 | // it continues as long as there has code to analise |
| 499 | - if (isset($this->code[$k+1])) |
|
| 500 | - $k++; |
|
| 501 | - else |
|
| 502 | - $end = true; |
|
| 540 | + if (isset($this->code[$k+1])) { |
|
| 541 | + $k++; |
|
| 542 | + } else { |
|
| 543 | + $end = true; |
|
| 544 | + } |
|
| 503 | 545 | } |
| 504 | 546 | |
| 505 | 547 | // return the extract |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | /** |
| 326 | 326 | * Encode a string to be used for CODE 39 Extended mode. |
| 327 | 327 | * @param string $code code to represent. |
| 328 | - * @return encoded string. |
|
| 328 | + * @return false|string string. |
|
| 329 | 329 | * @access protected |
| 330 | 330 | */ |
| 331 | 331 | protected function encode_code39_ext($code) { |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | /** |
| 377 | 377 | * Calculate CODE 39 checksum (modulo 43). |
| 378 | 378 | * @param string $code code to represent. |
| 379 | - * @return char checksum. |
|
| 379 | + * @return string checksum. |
|
| 380 | 380 | * @access protected |
| 381 | 381 | */ |
| 382 | 382 | protected function checksum_code39($code) { |
@@ -399,7 +399,6 @@ discard block |
||
| 399 | 399 | * CODE 93 - USS-93 |
| 400 | 400 | * Compact code similar to Code 39 |
| 401 | 401 | * @param string $code code to represent. |
| 402 | - * @param boolean $checksum if true add a checksum to the code |
|
| 403 | 402 | * @return array barcode representation. |
| 404 | 403 | * @access protected |
| 405 | 404 | */ |
@@ -988,7 +987,7 @@ discard block |
||
| 988 | 987 | * UPC-A: Universal product code seen on almost all retail products in the USA and Canada |
| 989 | 988 | * UPC-E: Short version of UPC symbol |
| 990 | 989 | * @param string $code code to represent. |
| 991 | - * @param string $len barcode type: 6 = UPC-E, 8 = EAN8, 13 = EAN13, 12 = UPC-A |
|
| 990 | + * @param integer $len barcode type: 6 = UPC-E, 8 = EAN8, 13 = EAN13, 12 = UPC-A |
|
| 992 | 991 | * @return array barcode representation. |
| 993 | 992 | * @access protected |
| 994 | 993 | */ |
@@ -1181,7 +1180,7 @@ discard block |
||
| 1181 | 1180 | * 2-Digit Ext.: Used to indicate magazines and newspaper issue numbers |
| 1182 | 1181 | * 5-Digit Ext.: Used to mark suggested retail price of books |
| 1183 | 1182 | * @param string $code code to represent. |
| 1184 | - * @param string $len barcode type: 2 = 2-Digit, 5 = 5-Digit |
|
| 1183 | + * @param integer $len barcode type: 2 = 2-Digit, 5 = 5-Digit |
|
| 1185 | 1184 | * @return array barcode representation. |
| 1186 | 1185 | * @access protected |
| 1187 | 1186 | */ |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | - * PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www.tcpdf.org).<br> |
|
| 55 | - * @name TCPDFBarcode |
|
| 56 | - * @package com.tecnick.tcpdf |
|
| 57 | - * @version 1.0.008 |
|
| 58 | - * @author Nicola Asuni |
|
| 59 | - * @link http://www.tcpdf.org |
|
| 60 | - * @license http://www.gnu.org/copyleft/lesser.html LGPL |
|
| 61 | - */ |
|
| 54 | + * PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www.tcpdf.org).<br> |
|
| 55 | + * @name TCPDFBarcode |
|
| 56 | + * @package com.tecnick.tcpdf |
|
| 57 | + * @version 1.0.008 |
|
| 58 | + * @author Nicola Asuni |
|
| 59 | + * @link http://www.tcpdf.org |
|
| 60 | + * @license http://www.gnu.org/copyleft/lesser.html LGPL |
|
| 61 | + */ |
|
| 62 | 62 | class TCPDFBarcode { |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * <li>$arrcode['bcode'][$k]['h'] bar height in units.</li> |
| 80 | 80 | * <li>$arrcode['bcode'][$k]['p'] bar top position (0 = top, 1 = middle)</li></ul> |
| 81 | 81 | * @param string $code code to print |
| 82 | - * @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul> |
|
| 82 | + * @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul> |
|
| 83 | 83 | */ |
| 84 | 84 | public function __construct($code, $type) { |
| 85 | 85 | $this->setBarcode($code, $type); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Return an array representations of barcode. |
| 90 | - * @return array |
|
| 90 | + * @return array |
|
| 91 | 91 | */ |
| 92 | 92 | public function getBarcodeArray() { |
| 93 | 93 | return $this->barcode_array; |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | /** |
| 97 | 97 | * Set the barcode. |
| 98 | 98 | * @param string $code code to print |
| 99 | - * @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul> |
|
| 100 | - * @return array |
|
| 99 | + * @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul> |
|
| 100 | + * @return array |
|
| 101 | 101 | */ |
| 102 | 102 | public function setBarcode($code, $type) { |
| 103 | 103 | switch (strtoupper($type)) { |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @return array barcode representation. |
| 235 | 235 | * @access protected |
| 236 | 236 | */ |
| 237 | - protected function barcode_code39($code, $extended=false, $checksum=false) { |
|
| 237 | + protected function barcode_code39($code, $extended = false, $checksum = false) { |
|
| 238 | 238 | $chr['0'] = '111221211'; |
| 239 | 239 | $chr['1'] = '211211112'; |
| 240 | 240 | $chr['2'] = '112211112'; |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | $clen = strlen($code); |
| 301 | 301 | for ($i = 0; $i < $clen; ++$i) { |
| 302 | 302 | $char = $code{$i}; |
| 303 | - if(!isset($chr[$char])) { |
|
| 303 | + if ( ! isset($chr[$char])) { |
|
| 304 | 304 | // invalid character |
| 305 | 305 | return false; |
| 306 | 306 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | chr(124) => '%Q', chr(125) => '%R', chr(126) => '%S', chr(127) => '%T'); |
| 365 | 365 | $code_ext = ''; |
| 366 | 366 | $clen = strlen($code); |
| 367 | - for ($i = 0 ; $i < $clen; ++$i) { |
|
| 367 | + for ($i = 0; $i < $clen; ++$i) { |
|
| 368 | 368 | if (ord($code{$i}) > 127) { |
| 369 | 369 | return false; |
| 370 | 370 | } |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%'); |
| 388 | 388 | $sum = 0; |
| 389 | 389 | $clen = strlen($code); |
| 390 | - for ($i = 0 ; $i < $clen; ++$i) { |
|
| 390 | + for ($i = 0; $i < $clen; ++$i) { |
|
| 391 | 391 | $k = array_keys($chars, $code{$i}); |
| 392 | 392 | $sum += $k[0]; |
| 393 | 393 | } |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | chr(124) => chr(131).'Q', chr(125) => chr(131).'R', chr(126) => chr(131).'S', chr(127) => chr(131).'T'); |
| 489 | 489 | $code_ext = ''; |
| 490 | 490 | $clen = strlen($code); |
| 491 | - for ($i = 0 ; $i < $clen; ++$i) { |
|
| 491 | + for ($i = 0; $i < $clen; ++$i) { |
|
| 492 | 492 | if (ord($code{$i}) > 127) { |
| 493 | 493 | return false; |
| 494 | 494 | } |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | $clen = strlen($code); |
| 504 | 504 | for ($i = 0; $i < $clen; ++$i) { |
| 505 | 505 | $char = $code{$i}; |
| 506 | - if(!isset($chr[$char])) { |
|
| 506 | + if ( ! isset($chr[$char])) { |
|
| 507 | 507 | // invalid character |
| 508 | 508 | return false; |
| 509 | 509 | } |
@@ -579,15 +579,15 @@ discard block |
||
| 579 | 579 | protected function checksum_s25($code) { |
| 580 | 580 | $len = strlen($code); |
| 581 | 581 | $sum = 0; |
| 582 | - for ($i = 0; $i < $len; $i+=2) { |
|
| 582 | + for ($i = 0; $i < $len; $i += 2) { |
|
| 583 | 583 | $sum += $code{$i}; |
| 584 | 584 | } |
| 585 | 585 | $sum *= 3; |
| 586 | - for ($i = 1; $i < $len; $i+=2) { |
|
| 586 | + for ($i = 1; $i < $len; $i += 2) { |
|
| 587 | 587 | $sum += ($code{$i}); |
| 588 | 588 | } |
| 589 | 589 | $r = $sum % 10; |
| 590 | - if($r > 0) { |
|
| 590 | + if ($r > 0) { |
|
| 591 | 591 | $r = (10 - $r); |
| 592 | 592 | } |
| 593 | 593 | return $r; |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | * @return array barcode representation. |
| 603 | 603 | * @access protected |
| 604 | 604 | */ |
| 605 | - protected function barcode_msi($code, $checksum=false) { |
|
| 605 | + protected function barcode_msi($code, $checksum = false) { |
|
| 606 | 606 | $chr['0'] = '100100100100'; |
| 607 | 607 | $chr['1'] = '100100100110'; |
| 608 | 608 | $chr['2'] = '100100110100'; |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | $clen = strlen($code); |
| 642 | 642 | for ($i = 0; $i < $clen; ++$i) { |
| 643 | 643 | $digit = $code{$i}; |
| 644 | - if (!isset($chr[$digit])) { |
|
| 644 | + if ( ! isset($chr[$digit])) { |
|
| 645 | 645 | // invalid character |
| 646 | 646 | return false; |
| 647 | 647 | } |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | * @return array barcode representation. |
| 662 | 662 | * @access protected |
| 663 | 663 | */ |
| 664 | - protected function barcode_s25($code, $checksum=false) { |
|
| 664 | + protected function barcode_s25($code, $checksum = false) { |
|
| 665 | 665 | $chr['0'] = '10101110111010'; |
| 666 | 666 | $chr['1'] = '11101010101110'; |
| 667 | 667 | $chr['2'] = '10111010101110'; |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | // add checksum |
| 677 | 677 | $code .= $this->checksum_s25($code); |
| 678 | 678 | } |
| 679 | - if((strlen($code) % 2) != 0) { |
|
| 679 | + if ((strlen($code) % 2) != 0) { |
|
| 680 | 680 | // add leading zero if code-length is odd |
| 681 | 681 | $code = '0'.$code; |
| 682 | 682 | } |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | $clen = strlen($code); |
| 685 | 685 | for ($i = 0; $i < $clen; ++$i) { |
| 686 | 686 | $digit = $code{$i}; |
| 687 | - if (!isset($chr[$digit])) { |
|
| 687 | + if ( ! isset($chr[$digit])) { |
|
| 688 | 688 | // invalid character |
| 689 | 689 | return false; |
| 690 | 690 | } |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | $k = 0; |
| 709 | 709 | for ($i = 0; $i < $len; ++$i) { |
| 710 | 710 | $w += 1; |
| 711 | - if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq{$i} != $seq{($i+1)}))) { |
|
| 711 | + if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq{$i} != $seq{($i + 1)}))) { |
|
| 712 | 712 | if ($seq{$i} == '1') { |
| 713 | 713 | $t = true; // bar |
| 714 | 714 | } else { |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | * @return array barcode representation. |
| 733 | 733 | * @access protected |
| 734 | 734 | */ |
| 735 | - protected function barcode_i25($code, $checksum=false) { |
|
| 735 | + protected function barcode_i25($code, $checksum = false) { |
|
| 736 | 736 | $chr['0'] = '11221'; |
| 737 | 737 | $chr['1'] = '21112'; |
| 738 | 738 | $chr['2'] = '12112'; |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | // add checksum |
| 750 | 750 | $code .= $this->checksum_s25($code); |
| 751 | 751 | } |
| 752 | - if((strlen($code) % 2) != 0) { |
|
| 752 | + if ((strlen($code) % 2) != 0) { |
|
| 753 | 753 | // add leading zero if code-length is odd |
| 754 | 754 | $code = '0'.$code; |
| 755 | 755 | } |
@@ -761,16 +761,16 @@ discard block |
||
| 761 | 761 | $clen = strlen($code); |
| 762 | 762 | for ($i = 0; $i < $clen; $i = ($i + 2)) { |
| 763 | 763 | $char_bar = $code{$i}; |
| 764 | - $char_space = $code{$i+1}; |
|
| 765 | - if((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) { |
|
| 764 | + $char_space = $code{$i + 1}; |
|
| 765 | + if (( ! isset($chr[$char_bar])) OR ( ! isset($chr[$char_space]))) { |
|
| 766 | 766 | // invalid character |
| 767 | 767 | return false; |
| 768 | 768 | } |
| 769 | 769 | // create a bar-space sequence |
| 770 | 770 | $seq = ''; |
| 771 | 771 | $chrlen = strlen($chr[$char_bar]); |
| 772 | - for ($s = 0; $s < $chrlen; $s++){ |
|
| 773 | - $seq .= $chr[$char_bar]{$s} . $chr[$char_space]{$s}; |
|
| 772 | + for ($s = 0; $s < $chrlen; $s++) { |
|
| 773 | + $seq .= $chr[$char_bar]{$s}.$chr[$char_space]{$s}; |
|
| 774 | 774 | } |
| 775 | 775 | $seqlen = strlen($seq); |
| 776 | 776 | for ($j = 0; $j < $seqlen; ++$j) { |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | * @return array barcode representation. |
| 797 | 797 | * @access protected |
| 798 | 798 | */ |
| 799 | - protected function barcode_c128($code, $type='B') { |
|
| 799 | + protected function barcode_c128($code, $type = 'B') { |
|
| 800 | 800 | $chr = array( |
| 801 | 801 | '212222', /* 00 */ |
| 802 | 802 | '222122', /* 01 */ |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | '200000' /* END */ |
| 909 | 909 | ); |
| 910 | 910 | $keys = ''; |
| 911 | - switch(strtoupper($type)) { |
|
| 911 | + switch (strtoupper($type)) { |
|
| 912 | 912 | case 'A': { |
| 913 | 913 | $startid = 103; |
| 914 | 914 | $keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_'; |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | $sum = $startid; |
| 949 | 949 | $clen = strlen($code); |
| 950 | 950 | for ($i = 0; $i < $clen; ++$i) { |
| 951 | - $sum += (strpos($keys, $code{$i}) * ($i+1)); |
|
| 951 | + $sum += (strpos($keys, $code{$i}) * ($i + 1)); |
|
| 952 | 952 | } |
| 953 | 953 | $check = ($sum % 103); |
| 954 | 954 | // add start, check and stop codes |
@@ -958,10 +958,10 @@ discard block |
||
| 958 | 958 | $len = strlen($code); |
| 959 | 959 | for ($i = 0; $i < $len; ++$i) { |
| 960 | 960 | $ck = strpos($keys, $code{$i}); |
| 961 | - if (($i == 0) OR ($i > ($len-4))) { |
|
| 961 | + if (($i == 0) OR ($i > ($len - 4))) { |
|
| 962 | 962 | $char_num = ord($code{$i}); |
| 963 | 963 | $seq = $chr[$char_num]; |
| 964 | - } elseif(($ck >= 0) AND isset($chr[$ck])) { |
|
| 964 | + } elseif (($ck >= 0) AND isset($chr[$ck])) { |
|
| 965 | 965 | $seq = $chr[$ck]; |
| 966 | 966 | } else { |
| 967 | 967 | // invalid character |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | * @return array barcode representation. |
| 993 | 993 | * @access protected |
| 994 | 994 | */ |
| 995 | - protected function barcode_eanupc($code, $len=13) { |
|
| 995 | + protected function barcode_eanupc($code, $len = 13) { |
|
| 996 | 996 | $upce = false; |
| 997 | 997 | if ($len == 6) { |
| 998 | 998 | $len = 12; // UPC-A |
@@ -1004,21 +1004,21 @@ discard block |
||
| 1004 | 1004 | $code_len = strlen($code); |
| 1005 | 1005 | // calculate check digit |
| 1006 | 1006 | $sum_a = 0; |
| 1007 | - for ($i = 1; $i < $data_len; $i+=2) { |
|
| 1007 | + for ($i = 1; $i < $data_len; $i += 2) { |
|
| 1008 | 1008 | $sum_a += $code{$i}; |
| 1009 | 1009 | } |
| 1010 | 1010 | if ($len > 12) { |
| 1011 | 1011 | $sum_a *= 3; |
| 1012 | 1012 | } |
| 1013 | 1013 | $sum_b = 0; |
| 1014 | - for ($i = 0; $i < $data_len; $i+=2) { |
|
| 1014 | + for ($i = 0; $i < $data_len; $i += 2) { |
|
| 1015 | 1015 | $sum_b += ($code{$i}); |
| 1016 | 1016 | } |
| 1017 | 1017 | if ($len < 13) { |
| 1018 | 1018 | $sum_b *= 3; |
| 1019 | 1019 | } |
| 1020 | 1020 | $r = ($sum_a + $sum_b) % 10; |
| 1021 | - if($r > 0) { |
|
| 1021 | + if ($r > 0) { |
|
| 1022 | 1022 | $r = (10 - $r); |
| 1023 | 1023 | } |
| 1024 | 1024 | if ($code_len == $data_len) { |
@@ -1093,41 +1093,41 @@ discard block |
||
| 1093 | 1093 | '9'=>'1110100') |
| 1094 | 1094 | ); |
| 1095 | 1095 | $parities = array( |
| 1096 | - '0'=>array('A','A','A','A','A','A'), |
|
| 1097 | - '1'=>array('A','A','B','A','B','B'), |
|
| 1098 | - '2'=>array('A','A','B','B','A','B'), |
|
| 1099 | - '3'=>array('A','A','B','B','B','A'), |
|
| 1100 | - '4'=>array('A','B','A','A','B','B'), |
|
| 1101 | - '5'=>array('A','B','B','A','A','B'), |
|
| 1102 | - '6'=>array('A','B','B','B','A','A'), |
|
| 1103 | - '7'=>array('A','B','A','B','A','B'), |
|
| 1104 | - '8'=>array('A','B','A','B','B','A'), |
|
| 1105 | - '9'=>array('A','B','B','A','B','A') |
|
| 1096 | + '0'=>array('A', 'A', 'A', 'A', 'A', 'A'), |
|
| 1097 | + '1'=>array('A', 'A', 'B', 'A', 'B', 'B'), |
|
| 1098 | + '2'=>array('A', 'A', 'B', 'B', 'A', 'B'), |
|
| 1099 | + '3'=>array('A', 'A', 'B', 'B', 'B', 'A'), |
|
| 1100 | + '4'=>array('A', 'B', 'A', 'A', 'B', 'B'), |
|
| 1101 | + '5'=>array('A', 'B', 'B', 'A', 'A', 'B'), |
|
| 1102 | + '6'=>array('A', 'B', 'B', 'B', 'A', 'A'), |
|
| 1103 | + '7'=>array('A', 'B', 'A', 'B', 'A', 'B'), |
|
| 1104 | + '8'=>array('A', 'B', 'A', 'B', 'B', 'A'), |
|
| 1105 | + '9'=>array('A', 'B', 'B', 'A', 'B', 'A') |
|
| 1106 | 1106 | ); |
| 1107 | 1107 | $upce_parities = array(); |
| 1108 | 1108 | $upce_parities[0] = array( |
| 1109 | - '0'=>array('B','B','B','A','A','A'), |
|
| 1110 | - '1'=>array('B','B','A','B','A','A'), |
|
| 1111 | - '2'=>array('B','B','A','A','B','A'), |
|
| 1112 | - '3'=>array('B','B','A','A','A','B'), |
|
| 1113 | - '4'=>array('B','A','B','B','A','A'), |
|
| 1114 | - '5'=>array('B','A','A','B','B','A'), |
|
| 1115 | - '6'=>array('B','A','A','A','B','B'), |
|
| 1116 | - '7'=>array('B','A','B','A','B','A'), |
|
| 1117 | - '8'=>array('B','A','B','A','A','B'), |
|
| 1118 | - '9'=>array('B','A','A','B','A','B') |
|
| 1109 | + '0'=>array('B', 'B', 'B', 'A', 'A', 'A'), |
|
| 1110 | + '1'=>array('B', 'B', 'A', 'B', 'A', 'A'), |
|
| 1111 | + '2'=>array('B', 'B', 'A', 'A', 'B', 'A'), |
|
| 1112 | + '3'=>array('B', 'B', 'A', 'A', 'A', 'B'), |
|
| 1113 | + '4'=>array('B', 'A', 'B', 'B', 'A', 'A'), |
|
| 1114 | + '5'=>array('B', 'A', 'A', 'B', 'B', 'A'), |
|
| 1115 | + '6'=>array('B', 'A', 'A', 'A', 'B', 'B'), |
|
| 1116 | + '7'=>array('B', 'A', 'B', 'A', 'B', 'A'), |
|
| 1117 | + '8'=>array('B', 'A', 'B', 'A', 'A', 'B'), |
|
| 1118 | + '9'=>array('B', 'A', 'A', 'B', 'A', 'B') |
|
| 1119 | 1119 | ); |
| 1120 | 1120 | $upce_parities[1] = array( |
| 1121 | - '0'=>array('A','A','A','B','B','B'), |
|
| 1122 | - '1'=>array('A','A','B','A','B','B'), |
|
| 1123 | - '2'=>array('A','A','B','B','A','B'), |
|
| 1124 | - '3'=>array('A','A','B','B','B','A'), |
|
| 1125 | - '4'=>array('A','B','A','A','B','B'), |
|
| 1126 | - '5'=>array('A','B','B','A','A','B'), |
|
| 1127 | - '6'=>array('A','B','B','B','A','A'), |
|
| 1128 | - '7'=>array('A','B','A','B','A','B'), |
|
| 1129 | - '8'=>array('A','B','A','B','B','A'), |
|
| 1130 | - '9'=>array('A','B','B','A','B','A') |
|
| 1121 | + '0'=>array('A', 'A', 'A', 'B', 'B', 'B'), |
|
| 1122 | + '1'=>array('A', 'A', 'B', 'A', 'B', 'B'), |
|
| 1123 | + '2'=>array('A', 'A', 'B', 'B', 'A', 'B'), |
|
| 1124 | + '3'=>array('A', 'A', 'B', 'B', 'B', 'A'), |
|
| 1125 | + '4'=>array('A', 'B', 'A', 'A', 'B', 'B'), |
|
| 1126 | + '5'=>array('A', 'B', 'B', 'A', 'A', 'B'), |
|
| 1127 | + '6'=>array('A', 'B', 'B', 'B', 'A', 'A'), |
|
| 1128 | + '7'=>array('A', 'B', 'A', 'B', 'A', 'B'), |
|
| 1129 | + '8'=>array('A', 'B', 'A', 'B', 'B', 'A'), |
|
| 1130 | + '9'=>array('A', 'B', 'B', 'A', 'B', 'A') |
|
| 1131 | 1131 | ); |
| 1132 | 1132 | $k = 0; |
| 1133 | 1133 | $seq = '101'; // left guard bar |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | } else { |
| 1149 | 1149 | $p = $parities[$code{0}]; |
| 1150 | 1150 | for ($i = 1; $i < $half_len; ++$i) { |
| 1151 | - $seq .= $codes[$p[$i-1]][$code{$i}]; |
|
| 1151 | + $seq .= $codes[$p[$i - 1]][$code{$i}]; |
|
| 1152 | 1152 | } |
| 1153 | 1153 | } |
| 1154 | 1154 | $seq .= '01010'; // center guard bar |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | $w = 0; |
| 1162 | 1162 | for ($i = 0; $i < $clen; ++$i) { |
| 1163 | 1163 | $w += 1; |
| 1164 | - if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq{$i} != $seq{($i+1)}))) { |
|
| 1164 | + if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq{$i} != $seq{($i + 1)}))) { |
|
| 1165 | 1165 | if ($seq{$i} == '1') { |
| 1166 | 1166 | $t = true; // bar |
| 1167 | 1167 | } else { |
@@ -1185,14 +1185,14 @@ discard block |
||
| 1185 | 1185 | * @return array barcode representation. |
| 1186 | 1186 | * @access protected |
| 1187 | 1187 | */ |
| 1188 | - protected function barcode_eanext($code, $len=5) { |
|
| 1188 | + protected function barcode_eanext($code, $len = 5) { |
|
| 1189 | 1189 | //Padding |
| 1190 | 1190 | $code = str_pad($code, $len, '0', STR_PAD_LEFT); |
| 1191 | 1191 | // calculate check digit |
| 1192 | 1192 | if ($len == 2) { |
| 1193 | 1193 | $r = $code % 4; |
| 1194 | 1194 | } elseif ($len == 5) { |
| 1195 | - $r = (3 * ($code{0} + $code{2} + $code{4})) + (9 * ($code{1} + $code{3})); |
|
| 1195 | + $r = (3 * ($code{0} +$code{2} +$code{4})) + (9 * ($code{1} +$code{3})); |
|
| 1196 | 1196 | $r %= 10; |
| 1197 | 1197 | } else { |
| 1198 | 1198 | return false; |
@@ -1224,22 +1224,22 @@ discard block |
||
| 1224 | 1224 | ); |
| 1225 | 1225 | $parities = array(); |
| 1226 | 1226 | $parities[2] = array( |
| 1227 | - '0'=>array('A','A'), |
|
| 1228 | - '1'=>array('A','B'), |
|
| 1229 | - '2'=>array('B','A'), |
|
| 1230 | - '3'=>array('B','B') |
|
| 1227 | + '0'=>array('A', 'A'), |
|
| 1228 | + '1'=>array('A', 'B'), |
|
| 1229 | + '2'=>array('B', 'A'), |
|
| 1230 | + '3'=>array('B', 'B') |
|
| 1231 | 1231 | ); |
| 1232 | 1232 | $parities[5] = array( |
| 1233 | - '0'=>array('B','B','A','A','A'), |
|
| 1234 | - '1'=>array('B','A','B','A','A'), |
|
| 1235 | - '2'=>array('B','A','A','B','A'), |
|
| 1236 | - '3'=>array('B','A','A','A','B'), |
|
| 1237 | - '4'=>array('A','B','B','A','A'), |
|
| 1238 | - '5'=>array('A','A','B','B','A'), |
|
| 1239 | - '6'=>array('A','A','A','B','B'), |
|
| 1240 | - '7'=>array('A','B','A','B','A'), |
|
| 1241 | - '8'=>array('A','B','A','A','B'), |
|
| 1242 | - '9'=>array('A','A','B','A','B') |
|
| 1233 | + '0'=>array('B', 'B', 'A', 'A', 'A'), |
|
| 1234 | + '1'=>array('B', 'A', 'B', 'A', 'A'), |
|
| 1235 | + '2'=>array('B', 'A', 'A', 'B', 'A'), |
|
| 1236 | + '3'=>array('B', 'A', 'A', 'A', 'B'), |
|
| 1237 | + '4'=>array('A', 'B', 'B', 'A', 'A'), |
|
| 1238 | + '5'=>array('A', 'A', 'B', 'B', 'A'), |
|
| 1239 | + '6'=>array('A', 'A', 'A', 'B', 'B'), |
|
| 1240 | + '7'=>array('A', 'B', 'A', 'B', 'A'), |
|
| 1241 | + '8'=>array('A', 'B', 'A', 'A', 'B'), |
|
| 1242 | + '9'=>array('A', 'A', 'B', 'A', 'B') |
|
| 1243 | 1243 | ); |
| 1244 | 1244 | $p = $parities[$len][$r]; |
| 1245 | 1245 | $seq = '1011'; // left guard bar |
@@ -1260,33 +1260,33 @@ discard block |
||
| 1260 | 1260 | * @return array barcode representation. |
| 1261 | 1261 | * @access protected |
| 1262 | 1262 | */ |
| 1263 | - protected function barcode_postnet($code, $planet=false) { |
|
| 1263 | + protected function barcode_postnet($code, $planet = false) { |
|
| 1264 | 1264 | // bar lenght |
| 1265 | 1265 | if ($planet) { |
| 1266 | 1266 | $barlen = Array( |
| 1267 | - 0 => Array(1,1,2,2,2), |
|
| 1268 | - 1 => Array(2,2,2,1,1), |
|
| 1269 | - 2 => Array(2,2,1,2,1), |
|
| 1270 | - 3 => Array(2,2,1,1,2), |
|
| 1271 | - 4 => Array(2,1,2,2,1), |
|
| 1272 | - 5 => Array(2,1,2,1,2), |
|
| 1273 | - 6 => Array(2,1,1,2,2), |
|
| 1274 | - 7 => Array(1,2,2,2,1), |
|
| 1275 | - 8 => Array(1,2,2,1,2), |
|
| 1276 | - 9 => Array(1,2,1,2,2) |
|
| 1267 | + 0 => Array(1, 1, 2, 2, 2), |
|
| 1268 | + 1 => Array(2, 2, 2, 1, 1), |
|
| 1269 | + 2 => Array(2, 2, 1, 2, 1), |
|
| 1270 | + 3 => Array(2, 2, 1, 1, 2), |
|
| 1271 | + 4 => Array(2, 1, 2, 2, 1), |
|
| 1272 | + 5 => Array(2, 1, 2, 1, 2), |
|
| 1273 | + 6 => Array(2, 1, 1, 2, 2), |
|
| 1274 | + 7 => Array(1, 2, 2, 2, 1), |
|
| 1275 | + 8 => Array(1, 2, 2, 1, 2), |
|
| 1276 | + 9 => Array(1, 2, 1, 2, 2) |
|
| 1277 | 1277 | ); |
| 1278 | 1278 | } else { |
| 1279 | 1279 | $barlen = Array( |
| 1280 | - 0 => Array(2,2,1,1,1), |
|
| 1281 | - 1 => Array(1,1,1,2,2), |
|
| 1282 | - 2 => Array(1,1,2,1,2), |
|
| 1283 | - 3 => Array(1,1,2,2,1), |
|
| 1284 | - 4 => Array(1,2,1,1,2), |
|
| 1285 | - 5 => Array(1,2,1,2,1), |
|
| 1286 | - 6 => Array(1,2,2,1,1), |
|
| 1287 | - 7 => Array(2,1,1,1,2), |
|
| 1288 | - 8 => Array(2,1,1,2,1), |
|
| 1289 | - 9 => Array(2,1,2,1,1) |
|
| 1280 | + 0 => Array(2, 2, 1, 1, 1), |
|
| 1281 | + 1 => Array(1, 1, 1, 2, 2), |
|
| 1282 | + 2 => Array(1, 1, 2, 1, 2), |
|
| 1283 | + 3 => Array(1, 1, 2, 2, 1), |
|
| 1284 | + 4 => Array(1, 2, 1, 1, 2), |
|
| 1285 | + 5 => Array(1, 2, 1, 2, 1), |
|
| 1286 | + 6 => Array(1, 2, 2, 1, 1), |
|
| 1287 | + 7 => Array(2, 1, 1, 1, 2), |
|
| 1288 | + 8 => Array(2, 1, 1, 2, 1), |
|
| 1289 | + 9 => Array(2, 1, 2, 1, 1) |
|
| 1290 | 1290 | ); |
| 1291 | 1291 | } |
| 1292 | 1292 | $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array()); |
@@ -1300,7 +1300,7 @@ discard block |
||
| 1300 | 1300 | $sum += intval($code{$i}); |
| 1301 | 1301 | } |
| 1302 | 1302 | $chkd = ($sum % 10); |
| 1303 | - if($chkd > 0) { |
|
| 1303 | + if ($chkd > 0) { |
|
| 1304 | 1304 | $chkd = (10 - $chkd); |
| 1305 | 1305 | } |
| 1306 | 1306 | $code .= $chkd; |
@@ -1333,50 +1333,50 @@ discard block |
||
| 1333 | 1333 | * @return array barcode representation. |
| 1334 | 1334 | * @access protected |
| 1335 | 1335 | */ |
| 1336 | - protected function barcode_rms4cc($code, $kix=false) { |
|
| 1337 | - $notkix = !$kix; |
|
| 1336 | + protected function barcode_rms4cc($code, $kix = false) { |
|
| 1337 | + $notkix = ! $kix; |
|
| 1338 | 1338 | // bar mode |
| 1339 | 1339 | // 1 = pos 1, length 2 |
| 1340 | 1340 | // 2 = pos 1, length 3 |
| 1341 | 1341 | // 3 = pos 2, length 1 |
| 1342 | 1342 | // 4 = pos 2, length 2 |
| 1343 | 1343 | $barmode = array( |
| 1344 | - '0' => array(3,3,2,2), |
|
| 1345 | - '1' => array(3,4,1,2), |
|
| 1346 | - '2' => array(3,4,2,1), |
|
| 1347 | - '3' => array(4,3,1,2), |
|
| 1348 | - '4' => array(4,3,2,1), |
|
| 1349 | - '5' => array(4,4,1,1), |
|
| 1350 | - '6' => array(3,1,4,2), |
|
| 1351 | - '7' => array(3,2,3,2), |
|
| 1352 | - '8' => array(3,2,4,1), |
|
| 1353 | - '9' => array(4,1,3,2), |
|
| 1354 | - 'A' => array(4,1,4,1), |
|
| 1355 | - 'B' => array(4,2,3,1), |
|
| 1356 | - 'C' => array(3,1,2,4), |
|
| 1357 | - 'D' => array(3,2,1,4), |
|
| 1358 | - 'E' => array(3,2,2,3), |
|
| 1359 | - 'F' => array(4,1,1,4), |
|
| 1360 | - 'G' => array(4,1,2,3), |
|
| 1361 | - 'H' => array(4,2,1,3), |
|
| 1362 | - 'I' => array(1,3,4,2), |
|
| 1363 | - 'J' => array(1,4,3,2), |
|
| 1364 | - 'K' => array(1,4,4,1), |
|
| 1365 | - 'L' => array(2,3,3,2), |
|
| 1366 | - 'M' => array(2,3,4,1), |
|
| 1367 | - 'N' => array(2,4,3,1), |
|
| 1368 | - 'O' => array(1,3,2,4), |
|
| 1369 | - 'P' => array(1,4,1,4), |
|
| 1370 | - 'Q' => array(1,4,2,3), |
|
| 1371 | - 'R' => array(2,3,1,4), |
|
| 1372 | - 'S' => array(2,3,2,3), |
|
| 1373 | - 'T' => array(2,4,1,3), |
|
| 1374 | - 'U' => array(1,1,4,4), |
|
| 1375 | - 'V' => array(1,2,3,4), |
|
| 1376 | - 'W' => array(1,2,4,3), |
|
| 1377 | - 'X' => array(2,1,3,4), |
|
| 1378 | - 'Y' => array(2,1,4,3), |
|
| 1379 | - 'Z' => array(2,2,3,3) |
|
| 1344 | + '0' => array(3, 3, 2, 2), |
|
| 1345 | + '1' => array(3, 4, 1, 2), |
|
| 1346 | + '2' => array(3, 4, 2, 1), |
|
| 1347 | + '3' => array(4, 3, 1, 2), |
|
| 1348 | + '4' => array(4, 3, 2, 1), |
|
| 1349 | + '5' => array(4, 4, 1, 1), |
|
| 1350 | + '6' => array(3, 1, 4, 2), |
|
| 1351 | + '7' => array(3, 2, 3, 2), |
|
| 1352 | + '8' => array(3, 2, 4, 1), |
|
| 1353 | + '9' => array(4, 1, 3, 2), |
|
| 1354 | + 'A' => array(4, 1, 4, 1), |
|
| 1355 | + 'B' => array(4, 2, 3, 1), |
|
| 1356 | + 'C' => array(3, 1, 2, 4), |
|
| 1357 | + 'D' => array(3, 2, 1, 4), |
|
| 1358 | + 'E' => array(3, 2, 2, 3), |
|
| 1359 | + 'F' => array(4, 1, 1, 4), |
|
| 1360 | + 'G' => array(4, 1, 2, 3), |
|
| 1361 | + 'H' => array(4, 2, 1, 3), |
|
| 1362 | + 'I' => array(1, 3, 4, 2), |
|
| 1363 | + 'J' => array(1, 4, 3, 2), |
|
| 1364 | + 'K' => array(1, 4, 4, 1), |
|
| 1365 | + 'L' => array(2, 3, 3, 2), |
|
| 1366 | + 'M' => array(2, 3, 4, 1), |
|
| 1367 | + 'N' => array(2, 4, 3, 1), |
|
| 1368 | + 'O' => array(1, 3, 2, 4), |
|
| 1369 | + 'P' => array(1, 4, 1, 4), |
|
| 1370 | + 'Q' => array(1, 4, 2, 3), |
|
| 1371 | + 'R' => array(2, 3, 1, 4), |
|
| 1372 | + 'S' => array(2, 3, 2, 3), |
|
| 1373 | + 'T' => array(2, 4, 1, 3), |
|
| 1374 | + 'U' => array(1, 1, 4, 4), |
|
| 1375 | + 'V' => array(1, 2, 3, 4), |
|
| 1376 | + 'W' => array(1, 2, 4, 3), |
|
| 1377 | + 'X' => array(2, 1, 3, 4), |
|
| 1378 | + 'Y' => array(2, 1, 4, 3), |
|
| 1379 | + 'Z' => array(2, 2, 3, 3) |
|
| 1380 | 1380 | ); |
| 1381 | 1381 | $code = strtoupper($code); |
| 1382 | 1382 | $len = strlen($code); |
@@ -1384,42 +1384,42 @@ discard block |
||
| 1384 | 1384 | if ($notkix) { |
| 1385 | 1385 | // table for checksum calculation (row,col) |
| 1386 | 1386 | $checktable = array( |
| 1387 | - '0' => array(1,1), |
|
| 1388 | - '1' => array(1,2), |
|
| 1389 | - '2' => array(1,3), |
|
| 1390 | - '3' => array(1,4), |
|
| 1391 | - '4' => array(1,5), |
|
| 1392 | - '5' => array(1,0), |
|
| 1393 | - '6' => array(2,1), |
|
| 1394 | - '7' => array(2,2), |
|
| 1395 | - '8' => array(2,3), |
|
| 1396 | - '9' => array(2,4), |
|
| 1397 | - 'A' => array(2,5), |
|
| 1398 | - 'B' => array(2,0), |
|
| 1399 | - 'C' => array(3,1), |
|
| 1400 | - 'D' => array(3,2), |
|
| 1401 | - 'E' => array(3,3), |
|
| 1402 | - 'F' => array(3,4), |
|
| 1403 | - 'G' => array(3,5), |
|
| 1404 | - 'H' => array(3,0), |
|
| 1405 | - 'I' => array(4,1), |
|
| 1406 | - 'J' => array(4,2), |
|
| 1407 | - 'K' => array(4,3), |
|
| 1408 | - 'L' => array(4,4), |
|
| 1409 | - 'M' => array(4,5), |
|
| 1410 | - 'N' => array(4,0), |
|
| 1411 | - 'O' => array(5,1), |
|
| 1412 | - 'P' => array(5,2), |
|
| 1413 | - 'Q' => array(5,3), |
|
| 1414 | - 'R' => array(5,4), |
|
| 1415 | - 'S' => array(5,5), |
|
| 1416 | - 'T' => array(5,0), |
|
| 1417 | - 'U' => array(0,1), |
|
| 1418 | - 'V' => array(0,2), |
|
| 1419 | - 'W' => array(0,3), |
|
| 1420 | - 'X' => array(0,4), |
|
| 1421 | - 'Y' => array(0,5), |
|
| 1422 | - 'Z' => array(0,0) |
|
| 1387 | + '0' => array(1, 1), |
|
| 1388 | + '1' => array(1, 2), |
|
| 1389 | + '2' => array(1, 3), |
|
| 1390 | + '3' => array(1, 4), |
|
| 1391 | + '4' => array(1, 5), |
|
| 1392 | + '5' => array(1, 0), |
|
| 1393 | + '6' => array(2, 1), |
|
| 1394 | + '7' => array(2, 2), |
|
| 1395 | + '8' => array(2, 3), |
|
| 1396 | + '9' => array(2, 4), |
|
| 1397 | + 'A' => array(2, 5), |
|
| 1398 | + 'B' => array(2, 0), |
|
| 1399 | + 'C' => array(3, 1), |
|
| 1400 | + 'D' => array(3, 2), |
|
| 1401 | + 'E' => array(3, 3), |
|
| 1402 | + 'F' => array(3, 4), |
|
| 1403 | + 'G' => array(3, 5), |
|
| 1404 | + 'H' => array(3, 0), |
|
| 1405 | + 'I' => array(4, 1), |
|
| 1406 | + 'J' => array(4, 2), |
|
| 1407 | + 'K' => array(4, 3), |
|
| 1408 | + 'L' => array(4, 4), |
|
| 1409 | + 'M' => array(4, 5), |
|
| 1410 | + 'N' => array(4, 0), |
|
| 1411 | + 'O' => array(5, 1), |
|
| 1412 | + 'P' => array(5, 2), |
|
| 1413 | + 'Q' => array(5, 3), |
|
| 1414 | + 'R' => array(5, 4), |
|
| 1415 | + 'S' => array(5, 5), |
|
| 1416 | + 'T' => array(5, 0), |
|
| 1417 | + 'U' => array(0, 1), |
|
| 1418 | + 'V' => array(0, 2), |
|
| 1419 | + 'W' => array(0, 3), |
|
| 1420 | + 'X' => array(0, 4), |
|
| 1421 | + 'Y' => array(0, 5), |
|
| 1422 | + 'Z' => array(0, 0) |
|
| 1423 | 1423 | ); |
| 1424 | 1424 | $row = 0; |
| 1425 | 1425 | $col = 0; |
@@ -1429,7 +1429,7 @@ discard block |
||
| 1429 | 1429 | } |
| 1430 | 1430 | $row %= 6; |
| 1431 | 1431 | $col %= 6; |
| 1432 | - $chk = array_keys($checktable, array($row,$col)); |
|
| 1432 | + $chk = array_keys($checktable, array($row, $col)); |
|
| 1433 | 1433 | $code .= $chk[0]; |
| 1434 | 1434 | ++$len; |
| 1435 | 1435 | } |
@@ -1514,7 +1514,7 @@ discard block |
||
| 1514 | 1514 | $code = 'A'.strtoupper($code).'A'; |
| 1515 | 1515 | $len = strlen($code); |
| 1516 | 1516 | for ($i = 0; $i < $len; ++$i) { |
| 1517 | - if (!isset($chr[$code{$i}])) { |
|
| 1517 | + if ( ! isset($chr[$code{$i}])) { |
|
| 1518 | 1518 | return false; |
| 1519 | 1519 | } |
| 1520 | 1520 | $seq = $chr[$code{$i}]; |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | $code = 'S'.$code.'S'; |
| 1607 | 1607 | $len += 3; |
| 1608 | 1608 | for ($i = 0; $i < $len; ++$i) { |
| 1609 | - if (!isset($chr[$code{$i}])) { |
|
| 1609 | + if ( ! isset($chr[$code{$i}])) { |
|
| 1610 | 1610 | return false; |
| 1611 | 1611 | } |
| 1612 | 1612 | $seq = $chr[$code{$i}]; |
@@ -1679,7 +1679,7 @@ discard block |
||
| 1679 | 1679 | break; |
| 1680 | 1680 | } |
| 1681 | 1681 | } |
| 1682 | - } while($code != 0); |
|
| 1682 | + } while ($code != 0); |
|
| 1683 | 1683 | $seq = strrev($seq); |
| 1684 | 1684 | $k = 0; |
| 1685 | 1685 | $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array()); |
@@ -1722,10 +1722,10 @@ discard block |
||
| 1722 | 1722 | * @access protected |
| 1723 | 1723 | */ |
| 1724 | 1724 | protected function barcode_imb($code) { |
| 1725 | - $asc_chr = array(4,0,2,6,3,5,1,9,8,7,1,2,0,6,4,8,2,9,5,3,0,1,3,7,4,6,8,9,2,0,5,1,9,4,3,8,6,7,1,2,4,3,9,5,7,8,3,0,2,1,4,0,9,1,7,0,2,4,6,3,7,1,9,5,8); |
|
| 1726 | - $dsc_chr = array(7,1,9,5,8,0,2,4,6,3,5,8,9,7,3,0,6,1,7,4,6,8,9,2,5,1,7,5,4,3,8,7,6,0,2,5,4,9,3,0,1,6,8,2,0,4,5,9,6,7,5,2,6,3,8,5,1,9,8,7,4,0,2,6,3); |
|
| 1727 | - $asc_pos = array(3,0,8,11,1,12,8,11,10,6,4,12,2,7,9,6,7,9,2,8,4,0,12,7,10,9,0,7,10,5,7,9,6,8,2,12,1,4,2,0,1,5,4,6,12,1,0,9,4,7,5,10,2,6,9,11,2,12,6,7,5,11,0,3,2); |
|
| 1728 | - $dsc_pos = array(2,10,12,5,9,1,5,4,3,9,11,5,10,1,6,3,4,1,10,0,2,11,8,6,1,12,3,8,6,4,4,11,0,6,1,9,11,5,3,7,3,10,7,11,8,2,10,3,5,8,0,3,12,11,8,4,5,1,3,0,7,12,9,8,10); |
|
| 1725 | + $asc_chr = array(4, 0, 2, 6, 3, 5, 1, 9, 8, 7, 1, 2, 0, 6, 4, 8, 2, 9, 5, 3, 0, 1, 3, 7, 4, 6, 8, 9, 2, 0, 5, 1, 9, 4, 3, 8, 6, 7, 1, 2, 4, 3, 9, 5, 7, 8, 3, 0, 2, 1, 4, 0, 9, 1, 7, 0, 2, 4, 6, 3, 7, 1, 9, 5, 8); |
|
| 1726 | + $dsc_chr = array(7, 1, 9, 5, 8, 0, 2, 4, 6, 3, 5, 8, 9, 7, 3, 0, 6, 1, 7, 4, 6, 8, 9, 2, 5, 1, 7, 5, 4, 3, 8, 7, 6, 0, 2, 5, 4, 9, 3, 0, 1, 6, 8, 2, 0, 4, 5, 9, 6, 7, 5, 2, 6, 3, 8, 5, 1, 9, 8, 7, 4, 0, 2, 6, 3); |
|
| 1727 | + $asc_pos = array(3, 0, 8, 11, 1, 12, 8, 11, 10, 6, 4, 12, 2, 7, 9, 6, 7, 9, 2, 8, 4, 0, 12, 7, 10, 9, 0, 7, 10, 5, 7, 9, 6, 8, 2, 12, 1, 4, 2, 0, 1, 5, 4, 6, 12, 1, 0, 9, 4, 7, 5, 10, 2, 6, 9, 11, 2, 12, 6, 7, 5, 11, 0, 3, 2); |
|
| 1728 | + $dsc_pos = array(2, 10, 12, 5, 9, 1, 5, 4, 3, 9, 11, 5, 10, 1, 6, 3, 4, 1, 10, 0, 2, 11, 8, 6, 1, 12, 3, 8, 6, 4, 4, 11, 0, 6, 1, 9, 11, 5, 3, 7, 3, 10, 7, 11, 8, 2, 10, 3, 5, 8, 0, 3, 12, 11, 8, 4, 5, 1, 3, 0, 7, 12, 9, 8, 10); |
|
| 1729 | 1729 | $code_arr = explode('-', $code); |
| 1730 | 1730 | $tracking_number = $code_arr[0]; |
| 1731 | 1731 | if (isset($code_arr[1])) { |
@@ -1793,7 +1793,7 @@ discard block |
||
| 1793 | 1793 | // convert codewords to characters |
| 1794 | 1794 | $characters = array(); |
| 1795 | 1795 | $bitmask = 512; |
| 1796 | - foreach($codewords as $k => $val) { |
|
| 1796 | + foreach ($codewords as $k => $val) { |
|
| 1797 | 1797 | if ($val <= 1286) { |
| 1798 | 1798 | $chrcode = $table5of13[$val]; |
| 1799 | 1799 | } else { |
@@ -1848,11 +1848,11 @@ discard block |
||
| 1848 | 1848 | public function dec_to_hex($number) { |
| 1849 | 1849 | $i = 0; |
| 1850 | 1850 | $hex = array(); |
| 1851 | - if($number == 0) { |
|
| 1851 | + if ($number == 0) { |
|
| 1852 | 1852 | return '00'; |
| 1853 | 1853 | } |
| 1854 | - while($number > 0) { |
|
| 1855 | - if($number == 0) { |
|
| 1854 | + while ($number > 0) { |
|
| 1855 | + if ($number == 0) { |
|
| 1856 | 1856 | array_push($hex, '0'); |
| 1857 | 1857 | } else { |
| 1858 | 1858 | array_push($hex, strtoupper(dechex(bcmod($number, '16')))); |
@@ -1873,7 +1873,7 @@ discard block |
||
| 1873 | 1873 | $dec = 0; |
| 1874 | 1874 | $bitval = 1; |
| 1875 | 1875 | $len = strlen($hex); |
| 1876 | - for($pos = ($len - 1); $pos >= 0; --$pos) { |
|
| 1876 | + for ($pos = ($len - 1); $pos >= 0; --$pos) { |
|
| 1877 | 1877 | $dec = bcadd($dec, bcmul(hexdec($hex{$pos}), $bitval)); |
| 1878 | 1878 | $bitval = bcmul($bitval, 16); |
| 1879 | 1879 | } |
@@ -234,6 +234,8 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | /** |
| 236 | 236 | * Read UFM file |
| 237 | + * @param string $file |
|
| 238 | + * @param string $cidtogidmap |
|
| 237 | 239 | */ |
| 238 | 240 | function ReadUFM($file, &$cidtogidmap) { |
| 239 | 241 | //Prepare empty CIDToGIDMap |
@@ -309,6 +311,7 @@ discard block |
||
| 309 | 311 | |
| 310 | 312 | /** |
| 311 | 313 | * Read AFM file |
| 314 | + * @param string $file |
|
| 312 | 315 | */ |
| 313 | 316 | function ReadAFM($file,&$map) { |
| 314 | 317 | //Read a font metric file |
@@ -526,6 +529,10 @@ discard block |
||
| 526 | 529 | return rtrim($s); |
| 527 | 530 | } |
| 528 | 531 | |
| 532 | +/** |
|
| 533 | + * @param string $file |
|
| 534 | + * @param string $s |
|
| 535 | + */ |
|
| 529 | 536 | function SaveToFile($file, $s, $mode='t') { |
| 530 | 537 | $f = fopen($file, 'w'.$mode); |
| 531 | 538 | if(!$f) { |
@@ -545,6 +552,9 @@ discard block |
||
| 545 | 552 | return $a['N']; |
| 546 | 553 | } |
| 547 | 554 | |
| 555 | +/** |
|
| 556 | + * @param string $file |
|
| 557 | + */ |
|
| 548 | 558 | function CheckTTF($file) { |
| 549 | 559 | //Check if font license allows embedding |
| 550 | 560 | $f = fopen($file, 'rb'); |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | * @param string $enc Name of the encoding table to use. Omit this parameter for TrueType Unicode, OpenType Unicode and symbolic fonts like Symbol or ZapfDingBats. |
| 56 | 56 | * @param array $patch Optional modification of the encoding |
| 57 | 57 | */ |
| 58 | -function MakeFont($fontfile, $fmfile, $embedded=true, $enc='cp1252', $patch=array()) { |
|
| 58 | +function MakeFont($fontfile, $fmfile, $embedded = true, $enc = 'cp1252', $patch = array()) { |
|
| 59 | 59 | //Generate a font definition file |
| 60 | 60 | set_magic_quotes_runtime(0); |
| 61 | 61 | ini_set('auto_detect_line_endings', '1'); |
| 62 | - if (!file_exists($fontfile)) { |
|
| 62 | + if ( ! file_exists($fontfile)) { |
|
| 63 | 63 | die('Error: file not found: '.$fontfile); |
| 64 | 64 | } |
| 65 | - if (!file_exists($fmfile)) { |
|
| 65 | + if ( ! file_exists($fmfile)) { |
|
| 66 | 66 | die('Error: file not found: '.$fmfile); |
| 67 | 67 | } |
| 68 | 68 | $cidtogidmap = ''; |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | $s .= '$type=\''.$type."';\n"; |
| 110 | 110 | $s .= '$name=\''.$fm['FontName']."';\n"; |
| 111 | 111 | $s .= '$desc='.$fd.";\n"; |
| 112 | - if (!isset($fm['UnderlinePosition'])) { |
|
| 112 | + if ( ! isset($fm['UnderlinePosition'])) { |
|
| 113 | 113 | $fm['UnderlinePosition'] = -100; |
| 114 | 114 | } |
| 115 | - if (!isset($fm['UnderlineThickness'])) { |
|
| 115 | + if ( ! isset($fm['UnderlineThickness'])) { |
|
| 116 | 116 | $fm['UnderlineThickness'] = 50; |
| 117 | 117 | } |
| 118 | 118 | $s .= '$up='.$fm['UnderlinePosition'].";\n"; |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | if (($type == 'TrueType') OR ($type == 'TrueTypeUnicode')) { |
| 137 | 137 | CheckTTF($fontfile); |
| 138 | 138 | } |
| 139 | - $f = fopen($fontfile,'rb'); |
|
| 140 | - if (!$f) { |
|
| 139 | + $f = fopen($fontfile, 'rb'); |
|
| 140 | + if ( ! $f) { |
|
| 141 | 141 | die('Error: Unable to open '.$fontfile); |
| 142 | 142 | } |
| 143 | 143 | $file = fread($f, filesize($fontfile)); |
@@ -150,16 +150,16 @@ discard block |
||
| 150 | 150 | $file = substr($file, 6); |
| 151 | 151 | } |
| 152 | 152 | $pos = strpos($file, 'eexec'); |
| 153 | - if (!$pos) { |
|
| 153 | + if ( ! $pos) { |
|
| 154 | 154 | die('Error: font file does not seem to be valid Type1'); |
| 155 | 155 | } |
| 156 | 156 | $size1 = $pos + 6; |
| 157 | 157 | if ($header AND (ord($file{$size1}) == 128)) { |
| 158 | 158 | //Strip second binary header |
| 159 | - $file = substr($file, 0, $size1).substr($file, $size1+6); |
|
| 159 | + $file = substr($file, 0, $size1).substr($file, $size1 + 6); |
|
| 160 | 160 | } |
| 161 | 161 | $pos = strpos($file, '00000000'); |
| 162 | - if (!$pos) { |
|
| 162 | + if ( ! $pos) { |
|
| 163 | 163 | die('Error: font file does not seem to be valid Type1'); |
| 164 | 164 | } |
| 165 | 165 | $size2 = $pos - $size1; |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | SaveToFile($cmp, gzcompress($file, 9), 'b'); |
| 172 | 172 | $s .= '$file=\''.$cmp."';\n"; |
| 173 | 173 | print "Font file compressed (".$cmp.")\n"; |
| 174 | - if (!empty($cidtogidmap)) { |
|
| 174 | + if ( ! empty($cidtogidmap)) { |
|
| 175 | 175 | $cmp = $basename.'.ctg.z'; |
| 176 | 176 | SaveToFile($cmp, gzcompress($cidtogidmap, 9), 'b'); |
| 177 | 177 | print "CIDToGIDMap created and compressed (".$cmp.")\n"; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | } else { |
| 181 | 181 | $s .= '$file=\''.basename($fontfile)."';\n"; |
| 182 | 182 | print "Notice: font file could not be compressed (zlib extension not available)\n"; |
| 183 | - if (!empty($cidtogidmap)) { |
|
| 183 | + if ( ! empty($cidtogidmap)) { |
|
| 184 | 184 | $cmp = $basename.'.ctg'; |
| 185 | 185 | $f = fopen($cmp, 'wb'); |
| 186 | 186 | fwrite($f, $cidtogidmap); |
@@ -189,18 +189,18 @@ discard block |
||
| 189 | 189 | $s .= '$ctg=\''.$cmp."';\n"; |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | - if($type == 'Type1') { |
|
| 192 | + if ($type == 'Type1') { |
|
| 193 | 193 | $s .= '$size1='.$size1.";\n"; |
| 194 | 194 | $s .= '$size2='.$size2.";\n"; |
| 195 | 195 | } else { |
| 196 | - $s.='$originalsize='.filesize($fontfile).";\n"; |
|
| 196 | + $s .= '$originalsize='.filesize($fontfile).";\n"; |
|
| 197 | 197 | } |
| 198 | 198 | } else { |
| 199 | 199 | //Not embedded font |
| 200 | 200 | $s .= '$file='."'';\n"; |
| 201 | 201 | } |
| 202 | 202 | $s .= "?>"; |
| 203 | - SaveToFile($basename.'.php',$s); |
|
| 203 | + SaveToFile($basename.'.php', $s); |
|
| 204 | 204 | print "Font definition file generated (".$basename.".php)\n"; |
| 205 | 205 | } |
| 206 | 206 | |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | $cc2gn = array(); |
| 219 | 219 | foreach ($a as $l) { |
| 220 | 220 | if ($l{0} == '!') { |
| 221 | - $e = preg_split('/[ \\t]+/',rtrim($l)); |
|
| 222 | - $cc = hexdec(substr($e[0],1)); |
|
| 221 | + $e = preg_split('/[ \\t]+/', rtrim($l)); |
|
| 222 | + $cc = hexdec(substr($e[0], 1)); |
|
| 223 | 223 | $gn = $e[2]; |
| 224 | 224 | $cc2gn[$cc] = $gn; |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | - for($i = 0; $i <= 255; $i++) { |
|
| 228 | - if(!isset($cc2gn[$i])) { |
|
| 227 | + for ($i = 0; $i <= 255; $i++) { |
|
| 228 | + if ( ! isset($cc2gn[$i])) { |
|
| 229 | 229 | $cc2gn[$i] = '.notdef'; |
| 230 | 230 | } |
| 231 | 231 | } |
@@ -245,14 +245,14 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | $widths = array(); |
| 247 | 247 | $fm = array(); |
| 248 | - foreach($a as $l) { |
|
| 249 | - $e = explode(' ',chop($l)); |
|
| 250 | - if(count($e) < 2) { |
|
| 248 | + foreach ($a as $l) { |
|
| 249 | + $e = explode(' ', chop($l)); |
|
| 250 | + if (count($e) < 2) { |
|
| 251 | 251 | continue; |
| 252 | 252 | } |
| 253 | 253 | $code = $e[0]; |
| 254 | 254 | $param = $e[1]; |
| 255 | - if($code == 'U') { |
|
| 255 | + if ($code == 'U') { |
|
| 256 | 256 | // U 827 ; WX 0 ; N squaresubnosp ; G 675 ; |
| 257 | 257 | //Character metrics |
| 258 | 258 | $cc = (int)$e[1]; |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | $w = $e[4]; |
| 262 | 262 | $glyph = $e[10]; |
| 263 | 263 | $widths[$cc] = $w; |
| 264 | - if($cc == ord('X')) { |
|
| 264 | + if ($cc == ord('X')) { |
|
| 265 | 265 | $fm['CapXHeight'] = $e[13]; |
| 266 | 266 | } |
| 267 | 267 | // Set GID |
@@ -270,37 +270,37 @@ discard block |
||
| 270 | 270 | $cidtogidmap{(($cc * 2) + 1)} = chr($glyph & 0xFF); |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | - if((isset($gn) AND ($gn == '.notdef')) AND (!isset($fm['MissingWidth']))) { |
|
| 273 | + if ((isset($gn) AND ($gn == '.notdef')) AND ( ! isset($fm['MissingWidth']))) { |
|
| 274 | 274 | $fm['MissingWidth'] = $w; |
| 275 | 275 | } |
| 276 | - } elseif($code == 'FontName') { |
|
| 276 | + } elseif ($code == 'FontName') { |
|
| 277 | 277 | $fm['FontName'] = $param; |
| 278 | - } elseif($code == 'Weight') { |
|
| 278 | + } elseif ($code == 'Weight') { |
|
| 279 | 279 | $fm['Weight'] = $param; |
| 280 | - } elseif($code == 'ItalicAngle') { |
|
| 280 | + } elseif ($code == 'ItalicAngle') { |
|
| 281 | 281 | $fm['ItalicAngle'] = (double)$param; |
| 282 | - } elseif($code == 'Ascender') { |
|
| 282 | + } elseif ($code == 'Ascender') { |
|
| 283 | 283 | $fm['Ascender'] = (int)$param; |
| 284 | - } elseif($code == 'Descender') { |
|
| 284 | + } elseif ($code == 'Descender') { |
|
| 285 | 285 | $fm['Descender'] = (int)$param; |
| 286 | - } elseif($code == 'UnderlineThickness') { |
|
| 286 | + } elseif ($code == 'UnderlineThickness') { |
|
| 287 | 287 | $fm['UnderlineThickness'] = (int)$param; |
| 288 | - } elseif($code == 'UnderlinePosition') { |
|
| 288 | + } elseif ($code == 'UnderlinePosition') { |
|
| 289 | 289 | $fm['UnderlinePosition'] = (int)$param; |
| 290 | - } elseif($code == 'IsFixedPitch') { |
|
| 290 | + } elseif ($code == 'IsFixedPitch') { |
|
| 291 | 291 | $fm['IsFixedPitch'] = ($param == 'true'); |
| 292 | - } elseif($code == 'FontBBox') { |
|
| 292 | + } elseif ($code == 'FontBBox') { |
|
| 293 | 293 | $fm['FontBBox'] = array($e[1], $e[2], $e[3], $e[4]); |
| 294 | - } elseif($code == 'CapHeight') { |
|
| 294 | + } elseif ($code == 'CapHeight') { |
|
| 295 | 295 | $fm['CapHeight'] = (int)$param; |
| 296 | - } elseif($code == 'StdVW') { |
|
| 296 | + } elseif ($code == 'StdVW') { |
|
| 297 | 297 | $fm['StdVW'] = (int)$param; |
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | - if(!isset($fm['MissingWidth'])) { |
|
| 300 | + if ( ! isset($fm['MissingWidth'])) { |
|
| 301 | 301 | $fm['MissingWidth'] = 600; |
| 302 | 302 | } |
| 303 | - if(!isset($fm['FontName'])) { |
|
| 303 | + if ( ! isset($fm['FontName'])) { |
|
| 304 | 304 | die('FontName not found'); |
| 305 | 305 | } |
| 306 | 306 | $fm['Widths'] = $widths; |
@@ -310,10 +310,10 @@ discard block |
||
| 310 | 310 | /** |
| 311 | 311 | * Read AFM file |
| 312 | 312 | */ |
| 313 | -function ReadAFM($file,&$map) { |
|
| 313 | +function ReadAFM($file, &$map) { |
|
| 314 | 314 | //Read a font metric file |
| 315 | 315 | $a = file($file); |
| 316 | - if(empty($a)) { |
|
| 316 | + if (empty($a)) { |
|
| 317 | 317 | die('File not found'); |
| 318 | 318 | } |
| 319 | 319 | $widths = array(); |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | 'combiningdotbelow'=>'dotbelowcomb', |
| 354 | 354 | 'dongsign'=>'dong' |
| 355 | 355 | ); |
| 356 | - foreach($a as $l) { |
|
| 356 | + foreach ($a as $l) { |
|
| 357 | 357 | $e = explode(' ', rtrim($l)); |
| 358 | 358 | if (count($e) < 2) { |
| 359 | 359 | continue; |
@@ -381,50 +381,50 @@ discard block |
||
| 381 | 381 | $widths[$cc] = $w; |
| 382 | 382 | } else { |
| 383 | 383 | $widths[$gn] = $w; |
| 384 | - if($gn == 'X') { |
|
| 384 | + if ($gn == 'X') { |
|
| 385 | 385 | $fm['CapXHeight'] = $e[13]; |
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | - if($gn == '.notdef') { |
|
| 388 | + if ($gn == '.notdef') { |
|
| 389 | 389 | $fm['MissingWidth'] = $w; |
| 390 | 390 | } |
| 391 | - } elseif($code == 'FontName') { |
|
| 391 | + } elseif ($code == 'FontName') { |
|
| 392 | 392 | $fm['FontName'] = $param; |
| 393 | - } elseif($code == 'Weight') { |
|
| 393 | + } elseif ($code == 'Weight') { |
|
| 394 | 394 | $fm['Weight'] = $param; |
| 395 | - } elseif($code == 'ItalicAngle') { |
|
| 395 | + } elseif ($code == 'ItalicAngle') { |
|
| 396 | 396 | $fm['ItalicAngle'] = (double)$param; |
| 397 | - } elseif($code == 'Ascender') { |
|
| 397 | + } elseif ($code == 'Ascender') { |
|
| 398 | 398 | $fm['Ascender'] = (int)$param; |
| 399 | - } elseif($code == 'Descender') { |
|
| 399 | + } elseif ($code == 'Descender') { |
|
| 400 | 400 | $fm['Descender'] = (int)$param; |
| 401 | - } elseif($code == 'UnderlineThickness') { |
|
| 401 | + } elseif ($code == 'UnderlineThickness') { |
|
| 402 | 402 | $fm['UnderlineThickness'] = (int)$param; |
| 403 | - } elseif($code == 'UnderlinePosition') { |
|
| 403 | + } elseif ($code == 'UnderlinePosition') { |
|
| 404 | 404 | $fm['UnderlinePosition'] = (int)$param; |
| 405 | - } elseif($code == 'IsFixedPitch') { |
|
| 405 | + } elseif ($code == 'IsFixedPitch') { |
|
| 406 | 406 | $fm['IsFixedPitch'] = ($param == 'true'); |
| 407 | - } elseif($code == 'FontBBox') { |
|
| 407 | + } elseif ($code == 'FontBBox') { |
|
| 408 | 408 | $fm['FontBBox'] = array($e[1], $e[2], $e[3], $e[4]); |
| 409 | - } elseif($code == 'CapHeight') { |
|
| 409 | + } elseif ($code == 'CapHeight') { |
|
| 410 | 410 | $fm['CapHeight'] = (int)$param; |
| 411 | - } elseif($code == 'StdVW') { |
|
| 411 | + } elseif ($code == 'StdVW') { |
|
| 412 | 412 | $fm['StdVW'] = (int)$param; |
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | - if (!isset($fm['FontName'])) { |
|
| 415 | + if ( ! isset($fm['FontName'])) { |
|
| 416 | 416 | die('FontName not found'); |
| 417 | 417 | } |
| 418 | - if (!empty($map)) { |
|
| 419 | - if (!isset($widths['.notdef'])) { |
|
| 418 | + if ( ! empty($map)) { |
|
| 419 | + if ( ! isset($widths['.notdef'])) { |
|
| 420 | 420 | $widths['.notdef'] = 600; |
| 421 | 421 | } |
| 422 | - if (!isset($widths['Delta']) AND isset($widths['increment'])) { |
|
| 422 | + if ( ! isset($widths['Delta']) AND isset($widths['increment'])) { |
|
| 423 | 423 | $widths['Delta'] = $widths['increment']; |
| 424 | 424 | } |
| 425 | 425 | //Order widths according to map |
| 426 | 426 | for ($i = 0; $i <= 255; $i++) { |
| 427 | - if (!isset($widths[$map[$i]])) { |
|
| 427 | + if ( ! isset($widths[$map[$i]])) { |
|
| 428 | 428 | print "Warning: character ".$map[$i]." is missing\n"; |
| 429 | 429 | $widths[$i] = $widths['.notdef']; |
| 430 | 430 | } else { |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | return $fm; |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | -function MakeFontDescriptor($fm, $symbolic=false) { |
|
| 439 | +function MakeFontDescriptor($fm, $symbolic = false) { |
|
| 440 | 440 | //Ascent |
| 441 | 441 | $asc = (isset($fm['Ascender']) ? $fm['Ascender'] : 1000); |
| 442 | 442 | $fd = "array('Ascent'=>".$asc; |
@@ -455,15 +455,15 @@ discard block |
||
| 455 | 455 | //Flags |
| 456 | 456 | $flags = 0; |
| 457 | 457 | if (isset($fm['IsFixedPitch']) AND $fm['IsFixedPitch']) { |
| 458 | - $flags += 1<<0; |
|
| 458 | + $flags += 1 << 0; |
|
| 459 | 459 | } |
| 460 | 460 | if ($symbolic) { |
| 461 | - $flags += 1<<2; |
|
| 461 | + $flags += 1 << 2; |
|
| 462 | 462 | } else { |
| 463 | - $flags += 1<<5; |
|
| 463 | + $flags += 1 << 5; |
|
| 464 | 464 | } |
| 465 | 465 | if (isset($fm['ItalicAngle']) AND ($fm['ItalicAngle'] != 0)) { |
| 466 | - $flags += 1<<6; |
|
| 466 | + $flags += 1 << 6; |
|
| 467 | 467 | } |
| 468 | 468 | $fd .= ",'Flags'=>".$flags; |
| 469 | 469 | //FontBBox |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | } |
| 487 | 487 | $fd .= ",'StemV'=>".$stemv; |
| 488 | 488 | //MissingWidth |
| 489 | - if(isset($fm['MissingWidth'])) { |
|
| 489 | + if (isset($fm['MissingWidth'])) { |
|
| 490 | 490 | $fd .= ",'MissingWidth'=>".$fm['MissingWidth']; |
| 491 | 491 | } |
| 492 | 492 | $fd .= ')'; |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | $c = 0; |
| 502 | 502 | foreach ($cw as $i => $w) { |
| 503 | 503 | if (is_numeric($i)) { |
| 504 | - $els[] = (((($c++)%10) == 0) ? "\n" : '').$i.'=>'.$w; |
|
| 504 | + $els[] = (((($c++) % 10) == 0) ? "\n" : '').$i.'=>'.$w; |
|
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | 507 | $s .= implode(',', $els); |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | $last = 0; |
| 517 | 517 | for ($i = 32; $i <= 255; $i++) { |
| 518 | 518 | if ($map[$i] != $ref[$i]) { |
| 519 | - if ($i != $last+1) { |
|
| 519 | + if ($i != $last + 1) { |
|
| 520 | 520 | $s .= $i.' '; |
| 521 | 521 | } |
| 522 | 522 | $last = $i; |
@@ -526,9 +526,9 @@ discard block |
||
| 526 | 526 | return rtrim($s); |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | -function SaveToFile($file, $s, $mode='t') { |
|
| 529 | +function SaveToFile($file, $s, $mode = 't') { |
|
| 530 | 530 | $f = fopen($file, 'w'.$mode); |
| 531 | - if(!$f) { |
|
| 531 | + if ( ! $f) { |
|
| 532 | 532 | die('Can\'t write to file '.$file); |
| 533 | 533 | } |
| 534 | 534 | fwrite($f, $s, strlen($s)); |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | function CheckTTF($file) { |
| 549 | 549 | //Check if font license allows embedding |
| 550 | 550 | $f = fopen($file, 'rb'); |
| 551 | - if (!$f) { |
|
| 551 | + if ( ! $f) { |
|
| 552 | 552 | die('Error: unable to open '.$file); |
| 553 | 553 | } |
| 554 | 554 | //Extract number of tables |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | fseek($f, 12, SEEK_CUR); |
| 566 | 566 | } |
| 567 | - if (!$found) { |
|
| 567 | + if ( ! $found) { |
|
| 568 | 568 | fclose($f); |
| 569 | 569 | return; |
| 570 | 570 | } |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | $pp = ($fsType & 0x04) != 0; |
| 579 | 579 | $e = ($fsType & 0x08) != 0; |
| 580 | 580 | fclose($f); |
| 581 | - if($rl AND (!$pp) AND (!$e)) { |
|
| 581 | + if ($rl AND ( ! $pp) AND ( ! $e)) { |
|
| 582 | 582 | print "Warning: font license does not allow embedding\n"; |
| 583 | 583 | } |
| 584 | 584 | } |
@@ -591,14 +591,14 @@ discard block |
||
| 591 | 591 | $arg[3] = $arg[2]; |
| 592 | 592 | $arg[2] = true; |
| 593 | 593 | } else { |
| 594 | - if (!isset($arg[2])) { |
|
| 594 | + if ( ! isset($arg[2])) { |
|
| 595 | 595 | $arg[2] = true; |
| 596 | 596 | } |
| 597 | - if (!isset($arg[3])) { |
|
| 597 | + if ( ! isset($arg[3])) { |
|
| 598 | 598 | $arg[3] = 'cp1252'; |
| 599 | 599 | } |
| 600 | 600 | } |
| 601 | - if (!isset($arg[4])) { |
|
| 601 | + if ( ! isset($arg[4])) { |
|
| 602 | 602 | $arg[4] = array(); |
| 603 | 603 | } |
| 604 | 604 | MakeFont($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]); |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * Convert a string to an array (needed for PHP4 compatibility) |
| 269 | 269 | * @param string $string The input string. |
| 270 | 270 | * @param int $split_length Maximum length of the chunk. |
| 271 | - * @return If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element. |
|
| 271 | + * @return string[] the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element. |
|
| 272 | 272 | */ |
| 273 | 273 | function str_split($string, $split_length=1) { |
| 274 | 274 | if ((strlen($string) > $split_length) OR (!$split_length)) { |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | /** |
| 804 | 804 | * Get frame value at specified position |
| 805 | 805 | * @param array $at x,y position |
| 806 | - * @return value at specified position |
|
| 806 | + * @return integer at specified position |
|
| 807 | 807 | */ |
| 808 | 808 | protected function getFrameAt($at) { |
| 809 | 809 | return ord($this->frame[$at['y']][$at['x']]); |
@@ -946,8 +946,8 @@ discard block |
||
| 946 | 946 | /** |
| 947 | 947 | * Write Format Information on frame and returns the number of black bits |
| 948 | 948 | * @param int $width frame width |
| 949 | - * @param array $frame frame |
|
| 950 | - * @param array $mask masking mode |
|
| 949 | + * @param integer $frame frame |
|
| 950 | + * @param integer $mask masking mode |
|
| 951 | 951 | * @param int $level error correction level |
| 952 | 952 | * @return int blacks |
| 953 | 953 | */ |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | * Return bitmask |
| 1072 | 1072 | * @param int $maskNo mask number |
| 1073 | 1073 | * @param int $width width |
| 1074 | - * @param array $frame frame |
|
| 1074 | + * @param integer $frame frame |
|
| 1075 | 1075 | * @return array bitmask |
| 1076 | 1076 | */ |
| 1077 | 1077 | protected function generateMaskNo($maskNo, $width, $frame) { |
@@ -1703,7 +1703,7 @@ discard block |
||
| 1703 | 1703 | * @param array items input items |
| 1704 | 1704 | * @param int $mode encoding mode. |
| 1705 | 1705 | * @param int $size size of data (byte). |
| 1706 | - * @param array $data array of input data. |
|
| 1706 | + * @param string[] $data array of input data. |
|
| 1707 | 1707 | * @return items |
| 1708 | 1708 | * |
| 1709 | 1709 | */ |
@@ -1792,7 +1792,7 @@ discard block |
||
| 1792 | 1792 | /** |
| 1793 | 1793 | * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). |
| 1794 | 1794 | * @param int $c character value |
| 1795 | - * @return value |
|
| 1795 | + * @return integer |
|
| 1796 | 1796 | */ |
| 1797 | 1797 | protected function lookAnTable($c) { |
| 1798 | 1798 | return (($c > 127)?-1:$this->anTable[$c]); |
@@ -2094,7 +2094,7 @@ discard block |
||
| 2094 | 2094 | |
| 2095 | 2095 | /** |
| 2096 | 2096 | * mergeBitStream |
| 2097 | - * @param array $bstream |
|
| 2097 | + * @param integer $items |
|
| 2098 | 2098 | * @return array bitstream |
| 2099 | 2099 | */ |
| 2100 | 2100 | protected function mergeBitStream($items) { |
@@ -2231,7 +2231,7 @@ discard block |
||
| 2231 | 2231 | |
| 2232 | 2232 | /** |
| 2233 | 2233 | * Convert bitstream to bytes |
| 2234 | - * @param array $bitstream original bitstream |
|
| 2234 | + * @param array $bstream original bitstream |
|
| 2235 | 2235 | * @return array of bytes |
| 2236 | 2236 | */ |
| 2237 | 2237 | protected function bitstreamToByte($bstream) { |
@@ -2384,7 +2384,7 @@ discard block |
||
| 2384 | 2384 | * Return an array of ECC specification. |
| 2385 | 2385 | * @param int $version version |
| 2386 | 2386 | * @param int $level error correction level |
| 2387 | - * @param array $spec an array of ECC specification contains as following: {# of type1 blocks, # of data code, # of ecc code, # of type2 blocks, # of data code} |
|
| 2387 | + * @param integer[] $spec an array of ECC specification contains as following: {# of type1 blocks, # of data code, # of ecc code, # of type2 blocks, # of data code} |
|
| 2388 | 2388 | * @return array spec |
| 2389 | 2389 | */ |
| 2390 | 2390 | protected function getEccSpec($version, $level, $spec) { |
@@ -2414,7 +2414,6 @@ discard block |
||
| 2414 | 2414 | /** |
| 2415 | 2415 | * Put an alignment marker. |
| 2416 | 2416 | * @param array $frame frame |
| 2417 | - * @param int $width width |
|
| 2418 | 2417 | * @param int $ox X center coordinate of the pattern |
| 2419 | 2418 | * @param int $oy Y center coordinate of the pattern |
| 2420 | 2419 | * @return array frame |
@@ -2438,7 +2437,7 @@ discard block |
||
| 2438 | 2437 | /** |
| 2439 | 2438 | * Put an alignment pattern. |
| 2440 | 2439 | * @param int $version version |
| 2441 | - * @param array $fram frame |
|
| 2440 | + * @param array $frame frame |
|
| 2442 | 2441 | * @param int $width width |
| 2443 | 2442 | * @return array frame |
| 2444 | 2443 | */ |
@@ -2508,7 +2507,6 @@ discard block |
||
| 2508 | 2507 | /** |
| 2509 | 2508 | * Put a finder pattern. |
| 2510 | 2509 | * @param array $frame frame |
| 2511 | - * @param int $width width |
|
| 2512 | 2510 | * @param int $ox X center coordinate of the pattern |
| 2513 | 2511 | * @param int $oy Y center coordinate of the pattern |
| 2514 | 2512 | * @return array frame |
@@ -2678,7 +2676,7 @@ discard block |
||
| 2678 | 2676 | /** |
| 2679 | 2677 | * Return data length |
| 2680 | 2678 | * @param array $spec |
| 2681 | - * @return int value |
|
| 2679 | + * @return double value |
|
| 2682 | 2680 | */ |
| 2683 | 2681 | protected function rsDataLength($spec) { |
| 2684 | 2682 | return ($spec[0] * $spec[1]) + ($spec[3] * $spec[4]); |
@@ -173,29 +173,29 @@ discard block |
||
| 173 | 173 | /** |
| 174 | 174 | * Maximum matrix size for maximum version (version 40 is 177*177 matrix). |
| 175 | 175 | */ |
| 176 | - define('QRSPEC_WIDTH_MAX', 177); |
|
| 176 | + define('QRSPEC_WIDTH_MAX', 177); |
|
| 177 | 177 | |
| 178 | 178 | // ----------------------------------------------------- |
| 179 | 179 | |
| 180 | 180 | /** |
| 181 | 181 | * Matrix index to get width from $capacity array. |
| 182 | 182 | */ |
| 183 | - define('QRCAP_WIDTH', 0); |
|
| 183 | + define('QRCAP_WIDTH', 0); |
|
| 184 | 184 | |
| 185 | - /** |
|
| 185 | + /** |
|
| 186 | 186 | * Matrix index to get number of words from $capacity array. |
| 187 | 187 | */ |
| 188 | - define('QRCAP_WORDS', 1); |
|
| 188 | + define('QRCAP_WORDS', 1); |
|
| 189 | 189 | |
| 190 | - /** |
|
| 190 | + /** |
|
| 191 | 191 | * Matrix index to get remainder from $capacity array. |
| 192 | 192 | */ |
| 193 | - define('QRCAP_REMINDER', 2); |
|
| 193 | + define('QRCAP_REMINDER', 2); |
|
| 194 | 194 | |
| 195 | - /** |
|
| 195 | + /** |
|
| 196 | 196 | * Matrix index to get error correction level from $capacity array. |
| 197 | 197 | */ |
| 198 | - define('QRCAP_EC', 3); |
|
| 198 | + define('QRCAP_EC', 3); |
|
| 199 | 199 | |
| 200 | 200 | // ----------------------------------------------------- |
| 201 | 201 | |
@@ -204,33 +204,33 @@ discard block |
||
| 204 | 204 | /** |
| 205 | 205 | * Number of header bits for structured mode |
| 206 | 206 | */ |
| 207 | - define('STRUCTURE_HEADER_BITS', 20); |
|
| 207 | + define('STRUCTURE_HEADER_BITS', 20); |
|
| 208 | 208 | |
| 209 | - /** |
|
| 209 | + /** |
|
| 210 | 210 | * Max number of symbols for structured mode |
| 211 | 211 | */ |
| 212 | - define('MAX_STRUCTURED_SYMBOLS', 16); |
|
| 212 | + define('MAX_STRUCTURED_SYMBOLS', 16); |
|
| 213 | 213 | |
| 214 | 214 | // ----------------------------------------------------- |
| 215 | 215 | |
| 216 | - // Masks |
|
| 216 | + // Masks |
|
| 217 | 217 | |
| 218 | - /** |
|
| 218 | + /** |
|
| 219 | 219 | * Down point base value for case 1 mask pattern (concatenation of same color in a line or a column) |
| 220 | 220 | */ |
| 221 | - define('N1', 3); |
|
| 221 | + define('N1', 3); |
|
| 222 | 222 | |
| 223 | - /** |
|
| 223 | + /** |
|
| 224 | 224 | * Down point base value for case 2 mask pattern (module block of same color) |
| 225 | 225 | */ |
| 226 | 226 | define('N2', 3); |
| 227 | 227 | |
| 228 | - /** |
|
| 228 | + /** |
|
| 229 | 229 | * Down point base value for case 3 mask pattern (1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column) |
| 230 | 230 | */ |
| 231 | 231 | define('N3', 40); |
| 232 | 232 | |
| 233 | - /** |
|
| 233 | + /** |
|
| 234 | 234 | * Down point base value for case 4 mask pattern (ration of dark modules in whole) |
| 235 | 235 | */ |
| 236 | 236 | define('N4', 10); |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | // for compaibility with PHP4 |
| 266 | 266 | if (!function_exists('str_split')) { |
| 267 | - /** |
|
| 268 | - * Convert a string to an array (needed for PHP4 compatibility) |
|
| 269 | - * @param string $string The input string. |
|
| 270 | - * @param int $split_length Maximum length of the chunk. |
|
| 271 | - * @return If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element. |
|
| 272 | - */ |
|
| 267 | + /** |
|
| 268 | + * Convert a string to an array (needed for PHP4 compatibility) |
|
| 269 | + * @param string $string The input string. |
|
| 270 | + * @param int $split_length Maximum length of the chunk. |
|
| 271 | + * @return If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element. |
|
| 272 | + */ |
|
| 273 | 273 | function str_split($string, $split_length=1) { |
| 274 | 274 | if ((strlen($string) > $split_length) OR (!$split_length)) { |
| 275 | 275 | do { |
@@ -2622,7 +2622,7 @@ discard block |
||
| 2622 | 2622 | } |
| 2623 | 2623 | |
| 2624 | 2624 | /** |
| 2625 | - * Return block number 1 |
|
| 2625 | + * Return block number 1 |
|
| 2626 | 2626 | * @param array $spec |
| 2627 | 2627 | * @return int value |
| 2628 | 2628 | */ |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | |
| 93 | 93 | // definitions |
| 94 | -if (!defined('QRCODEDEFS')) { |
|
| 94 | +if ( ! defined('QRCODEDEFS')) { |
|
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * Indicate that definitions for this class are set |
@@ -180,12 +180,12 @@ discard block |
||
| 180 | 180 | /** |
| 181 | 181 | * Matrix index to get width from $capacity array. |
| 182 | 182 | */ |
| 183 | - define('QRCAP_WIDTH', 0); |
|
| 183 | + define('QRCAP_WIDTH', 0); |
|
| 184 | 184 | |
| 185 | 185 | /** |
| 186 | 186 | * Matrix index to get number of words from $capacity array. |
| 187 | 187 | */ |
| 188 | - define('QRCAP_WORDS', 1); |
|
| 188 | + define('QRCAP_WORDS', 1); |
|
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | 191 | * Matrix index to get remainder from $capacity array. |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | /** |
| 196 | 196 | * Matrix index to get error correction level from $capacity array. |
| 197 | 197 | */ |
| 198 | - define('QRCAP_EC', 3); |
|
| 198 | + define('QRCAP_EC', 3); |
|
| 199 | 199 | |
| 200 | 200 | // ----------------------------------------------------- |
| 201 | 201 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | /** |
| 205 | 205 | * Number of header bits for structured mode |
| 206 | 206 | */ |
| 207 | - define('STRUCTURE_HEADER_BITS', 20); |
|
| 207 | + define('STRUCTURE_HEADER_BITS', 20); |
|
| 208 | 208 | |
| 209 | 209 | /** |
| 210 | 210 | * Max number of symbols for structured mode |
@@ -218,12 +218,12 @@ discard block |
||
| 218 | 218 | /** |
| 219 | 219 | * Down point base value for case 1 mask pattern (concatenation of same color in a line or a column) |
| 220 | 220 | */ |
| 221 | - define('N1', 3); |
|
| 221 | + define('N1', 3); |
|
| 222 | 222 | |
| 223 | 223 | /** |
| 224 | 224 | * Down point base value for case 2 mask pattern (module block of same color) |
| 225 | 225 | */ |
| 226 | - define('N2', 3); |
|
| 226 | + define('N2', 3); |
|
| 227 | 227 | |
| 228 | 228 | /** |
| 229 | 229 | * Down point base value for case 3 mask pattern (1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column) |
@@ -260,18 +260,18 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | // #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# |
| 262 | 262 | |
| 263 | -if (!class_exists('QRcode', false)) { |
|
| 263 | +if ( ! class_exists('QRcode', false)) { |
|
| 264 | 264 | |
| 265 | 265 | // for compaibility with PHP4 |
| 266 | - if (!function_exists('str_split')) { |
|
| 266 | + if ( ! function_exists('str_split')) { |
|
| 267 | 267 | /** |
| 268 | 268 | * Convert a string to an array (needed for PHP4 compatibility) |
| 269 | 269 | * @param string $string The input string. |
| 270 | 270 | * @param int $split_length Maximum length of the chunk. |
| 271 | 271 | * @return If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element. |
| 272 | 272 | */ |
| 273 | - function str_split($string, $split_length=1) { |
|
| 274 | - if ((strlen($string) > $split_length) OR (!$split_length)) { |
|
| 273 | + function str_split($string, $split_length = 1) { |
|
| 274 | + if ((strlen($string) > $split_length) OR ( ! $split_length)) { |
|
| 275 | 275 | do { |
| 276 | 276 | $c = strlen($string); |
| 277 | 277 | $parts[] = substr($string, 0, $split_length); |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // |
| 482 | 482 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // |
| 483 | 483 | 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, // |
| 484 | - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, // |
|
| 484 | + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, // |
|
| 485 | 485 | -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, // |
| 486 | 486 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, // |
| 487 | 487 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // |
@@ -494,47 +494,47 @@ discard block |
||
| 494 | 494 | * @access protected |
| 495 | 495 | */ |
| 496 | 496 | protected $capacity = array( |
| 497 | - array( 0, 0, 0, array( 0, 0, 0, 0)), // |
|
| 498 | - array( 21, 26, 0, array( 7, 10, 13, 17)), // 1 |
|
| 499 | - array( 25, 44, 7, array( 10, 16, 22, 28)), // |
|
| 500 | - array( 29, 70, 7, array( 15, 26, 36, 44)), // |
|
| 501 | - array( 33, 100, 7, array( 20, 36, 52, 64)), // |
|
| 502 | - array( 37, 134, 7, array( 26, 48, 72, 88)), // 5 |
|
| 503 | - array( 41, 172, 7, array( 36, 64, 96, 112)), // |
|
| 504 | - array( 45, 196, 0, array( 40, 72, 108, 130)), // |
|
| 505 | - array( 49, 242, 0, array( 48, 88, 132, 156)), // |
|
| 506 | - array( 53, 292, 0, array( 60, 110, 160, 192)), // |
|
| 507 | - array( 57, 346, 0, array( 72, 130, 192, 224)), // 10 |
|
| 508 | - array( 61, 404, 0, array( 80, 150, 224, 264)), // |
|
| 509 | - array( 65, 466, 0, array( 96, 176, 260, 308)), // |
|
| 510 | - array( 69, 532, 0, array( 104, 198, 288, 352)), // |
|
| 511 | - array( 73, 581, 3, array( 120, 216, 320, 384)), // |
|
| 512 | - array( 77, 655, 3, array( 132, 240, 360, 432)), // 15 |
|
| 513 | - array( 81, 733, 3, array( 144, 280, 408, 480)), // |
|
| 514 | - array( 85, 815, 3, array( 168, 308, 448, 532)), // |
|
| 515 | - array( 89, 901, 3, array( 180, 338, 504, 588)), // |
|
| 516 | - array( 93, 991, 3, array( 196, 364, 546, 650)), // |
|
| 517 | - array( 97, 1085, 3, array( 224, 416, 600, 700)), // 20 |
|
| 518 | - array(101, 1156, 4, array( 224, 442, 644, 750)), // |
|
| 519 | - array(105, 1258, 4, array( 252, 476, 690, 816)), // |
|
| 520 | - array(109, 1364, 4, array( 270, 504, 750, 900)), // |
|
| 521 | - array(113, 1474, 4, array( 300, 560, 810, 960)), // |
|
| 522 | - array(117, 1588, 4, array( 312, 588, 870, 1050)), // 25 |
|
| 523 | - array(121, 1706, 4, array( 336, 644, 952, 1110)), // |
|
| 524 | - array(125, 1828, 4, array( 360, 700, 1020, 1200)), // |
|
| 525 | - array(129, 1921, 3, array( 390, 728, 1050, 1260)), // |
|
| 526 | - array(133, 2051, 3, array( 420, 784, 1140, 1350)), // |
|
| 527 | - array(137, 2185, 3, array( 450, 812, 1200, 1440)), // 30 |
|
| 528 | - array(141, 2323, 3, array( 480, 868, 1290, 1530)), // |
|
| 529 | - array(145, 2465, 3, array( 510, 924, 1350, 1620)), // |
|
| 530 | - array(149, 2611, 3, array( 540, 980, 1440, 1710)), // |
|
| 531 | - array(153, 2761, 3, array( 570, 1036, 1530, 1800)), // |
|
| 532 | - array(157, 2876, 0, array( 570, 1064, 1590, 1890)), // 35 |
|
| 533 | - array(161, 3034, 0, array( 600, 1120, 1680, 1980)), // |
|
| 534 | - array(165, 3196, 0, array( 630, 1204, 1770, 2100)), // |
|
| 535 | - array(169, 3362, 0, array( 660, 1260, 1860, 2220)), // |
|
| 536 | - array(173, 3532, 0, array( 720, 1316, 1950, 2310)), // |
|
| 537 | - array(177, 3706, 0, array( 750, 1372, 2040, 2430)) // 40 |
|
| 497 | + array(0, 0, 0, array(0, 0, 0, 0)), // |
|
| 498 | + array(21, 26, 0, array(7, 10, 13, 17)), // 1 |
|
| 499 | + array(25, 44, 7, array(10, 16, 22, 28)), // |
|
| 500 | + array(29, 70, 7, array(15, 26, 36, 44)), // |
|
| 501 | + array(33, 100, 7, array(20, 36, 52, 64)), // |
|
| 502 | + array(37, 134, 7, array(26, 48, 72, 88)), // 5 |
|
| 503 | + array(41, 172, 7, array(36, 64, 96, 112)), // |
|
| 504 | + array(45, 196, 0, array(40, 72, 108, 130)), // |
|
| 505 | + array(49, 242, 0, array(48, 88, 132, 156)), // |
|
| 506 | + array(53, 292, 0, array(60, 110, 160, 192)), // |
|
| 507 | + array(57, 346, 0, array(72, 130, 192, 224)), // 10 |
|
| 508 | + array(61, 404, 0, array(80, 150, 224, 264)), // |
|
| 509 | + array(65, 466, 0, array(96, 176, 260, 308)), // |
|
| 510 | + array(69, 532, 0, array(104, 198, 288, 352)), // |
|
| 511 | + array(73, 581, 3, array(120, 216, 320, 384)), // |
|
| 512 | + array(77, 655, 3, array(132, 240, 360, 432)), // 15 |
|
| 513 | + array(81, 733, 3, array(144, 280, 408, 480)), // |
|
| 514 | + array(85, 815, 3, array(168, 308, 448, 532)), // |
|
| 515 | + array(89, 901, 3, array(180, 338, 504, 588)), // |
|
| 516 | + array(93, 991, 3, array(196, 364, 546, 650)), // |
|
| 517 | + array(97, 1085, 3, array(224, 416, 600, 700)), // 20 |
|
| 518 | + array(101, 1156, 4, array(224, 442, 644, 750)), // |
|
| 519 | + array(105, 1258, 4, array(252, 476, 690, 816)), // |
|
| 520 | + array(109, 1364, 4, array(270, 504, 750, 900)), // |
|
| 521 | + array(113, 1474, 4, array(300, 560, 810, 960)), // |
|
| 522 | + array(117, 1588, 4, array(312, 588, 870, 1050)), // 25 |
|
| 523 | + array(121, 1706, 4, array(336, 644, 952, 1110)), // |
|
| 524 | + array(125, 1828, 4, array(360, 700, 1020, 1200)), // |
|
| 525 | + array(129, 1921, 3, array(390, 728, 1050, 1260)), // |
|
| 526 | + array(133, 2051, 3, array(420, 784, 1140, 1350)), // |
|
| 527 | + array(137, 2185, 3, array(450, 812, 1200, 1440)), // 30 |
|
| 528 | + array(141, 2323, 3, array(480, 868, 1290, 1530)), // |
|
| 529 | + array(145, 2465, 3, array(510, 924, 1350, 1620)), // |
|
| 530 | + array(149, 2611, 3, array(540, 980, 1440, 1710)), // |
|
| 531 | + array(153, 2761, 3, array(570, 1036, 1530, 1800)), // |
|
| 532 | + array(157, 2876, 0, array(570, 1064, 1590, 1890)), // 35 |
|
| 533 | + array(161, 3034, 0, array(600, 1120, 1680, 1980)), // |
|
| 534 | + array(165, 3196, 0, array(630, 1204, 1770, 2100)), // |
|
| 535 | + array(169, 3362, 0, array(660, 1260, 1860, 2220)), // |
|
| 536 | + array(173, 3532, 0, array(720, 1316, 1950, 2310)), // |
|
| 537 | + array(177, 3706, 0, array(750, 1372, 2040, 2430)) // 40 |
|
| 538 | 538 | ); |
| 539 | 539 | |
| 540 | 540 | /** |
@@ -543,9 +543,9 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | protected $lengthTableBits = array( |
| 545 | 545 | array(10, 12, 14), |
| 546 | - array( 9, 11, 13), |
|
| 547 | - array( 8, 16, 16), |
|
| 548 | - array( 8, 10, 12) |
|
| 546 | + array(9, 11, 13), |
|
| 547 | + array(8, 16, 16), |
|
| 548 | + array(8, 10, 12) |
|
| 549 | 549 | ); |
| 550 | 550 | |
| 551 | 551 | /** |
@@ -554,47 +554,47 @@ discard block |
||
| 554 | 554 | * @access protected |
| 555 | 555 | */ |
| 556 | 556 | protected $eccTable = array( |
| 557 | - array(array( 0, 0), array( 0, 0), array( 0, 0), array( 0, 0)), // |
|
| 558 | - array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), // 1 |
|
| 559 | - array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), // |
|
| 560 | - array(array( 1, 0), array( 1, 0), array( 2, 0), array( 2, 0)), // |
|
| 561 | - array(array( 1, 0), array( 2, 0), array( 2, 0), array( 4, 0)), // |
|
| 562 | - array(array( 1, 0), array( 2, 0), array( 2, 2), array( 2, 2)), // 5 |
|
| 563 | - array(array( 2, 0), array( 4, 0), array( 4, 0), array( 4, 0)), // |
|
| 564 | - array(array( 2, 0), array( 4, 0), array( 2, 4), array( 4, 1)), // |
|
| 565 | - array(array( 2, 0), array( 2, 2), array( 4, 2), array( 4, 2)), // |
|
| 566 | - array(array( 2, 0), array( 3, 2), array( 4, 4), array( 4, 4)), // |
|
| 567 | - array(array( 2, 2), array( 4, 1), array( 6, 2), array( 6, 2)), // 10 |
|
| 568 | - array(array( 4, 0), array( 1, 4), array( 4, 4), array( 3, 8)), // |
|
| 569 | - array(array( 2, 2), array( 6, 2), array( 4, 6), array( 7, 4)), // |
|
| 570 | - array(array( 4, 0), array( 8, 1), array( 8, 4), array(12, 4)), // |
|
| 571 | - array(array( 3, 1), array( 4, 5), array(11, 5), array(11, 5)), // |
|
| 572 | - array(array( 5, 1), array( 5, 5), array( 5, 7), array(11, 7)), // 15 |
|
| 573 | - array(array( 5, 1), array( 7, 3), array(15, 2), array( 3, 13)), // |
|
| 574 | - array(array( 1, 5), array(10, 1), array( 1, 15), array( 2, 17)), // |
|
| 575 | - array(array( 5, 1), array( 9, 4), array(17, 1), array( 2, 19)), // |
|
| 576 | - array(array( 3, 4), array( 3, 11), array(17, 4), array( 9, 16)), // |
|
| 577 | - array(array( 3, 5), array( 3, 13), array(15, 5), array(15, 10)), // 20 |
|
| 578 | - array(array( 4, 4), array(17, 0), array(17, 6), array(19, 6)), // |
|
| 579 | - array(array( 2, 7), array(17, 0), array( 7, 16), array(34, 0)), // |
|
| 580 | - array(array( 4, 5), array( 4, 14), array(11, 14), array(16, 14)), // |
|
| 581 | - array(array( 6, 4), array( 6, 14), array(11, 16), array(30, 2)), // |
|
| 582 | - array(array( 8, 4), array( 8, 13), array( 7, 22), array(22, 13)), // 25 |
|
| 583 | - array(array(10, 2), array(19, 4), array(28, 6), array(33, 4)), // |
|
| 584 | - array(array( 8, 4), array(22, 3), array( 8, 26), array(12, 28)), // |
|
| 585 | - array(array( 3, 10), array( 3, 23), array( 4, 31), array(11, 31)), // |
|
| 586 | - array(array( 7, 7), array(21, 7), array( 1, 37), array(19, 26)), // |
|
| 587 | - array(array( 5, 10), array(19, 10), array(15, 25), array(23, 25)), // 30 |
|
| 588 | - array(array(13, 3), array( 2, 29), array(42, 1), array(23, 28)), // |
|
| 589 | - array(array(17, 0), array(10, 23), array(10, 35), array(19, 35)), // |
|
| 590 | - array(array(17, 1), array(14, 21), array(29, 19), array(11, 46)), // |
|
| 591 | - array(array(13, 6), array(14, 23), array(44, 7), array(59, 1)), // |
|
| 592 | - array(array(12, 7), array(12, 26), array(39, 14), array(22, 41)), // 35 |
|
| 593 | - array(array( 6, 14), array( 6, 34), array(46, 10), array( 2, 64)), // |
|
| 594 | - array(array(17, 4), array(29, 14), array(49, 10), array(24, 46)), // |
|
| 595 | - array(array( 4, 18), array(13, 32), array(48, 14), array(42, 32)), // |
|
| 596 | - array(array(20, 4), array(40, 7), array(43, 22), array(10, 67)), // |
|
| 597 | - array(array(19, 6), array(18, 31), array(34, 34), array(20, 61)) // 40 |
|
| 557 | + array(array(0, 0), array(0, 0), array(0, 0), array(0, 0)), // |
|
| 558 | + array(array(1, 0), array(1, 0), array(1, 0), array(1, 0)), // 1 |
|
| 559 | + array(array(1, 0), array(1, 0), array(1, 0), array(1, 0)), // |
|
| 560 | + array(array(1, 0), array(1, 0), array(2, 0), array(2, 0)), // |
|
| 561 | + array(array(1, 0), array(2, 0), array(2, 0), array(4, 0)), // |
|
| 562 | + array(array(1, 0), array(2, 0), array(2, 2), array(2, 2)), // 5 |
|
| 563 | + array(array(2, 0), array(4, 0), array(4, 0), array(4, 0)), // |
|
| 564 | + array(array(2, 0), array(4, 0), array(2, 4), array(4, 1)), // |
|
| 565 | + array(array(2, 0), array(2, 2), array(4, 2), array(4, 2)), // |
|
| 566 | + array(array(2, 0), array(3, 2), array(4, 4), array(4, 4)), // |
|
| 567 | + array(array(2, 2), array(4, 1), array(6, 2), array(6, 2)), // 10 |
|
| 568 | + array(array(4, 0), array(1, 4), array(4, 4), array(3, 8)), // |
|
| 569 | + array(array(2, 2), array(6, 2), array(4, 6), array(7, 4)), // |
|
| 570 | + array(array(4, 0), array(8, 1), array(8, 4), array(12, 4)), // |
|
| 571 | + array(array(3, 1), array(4, 5), array(11, 5), array(11, 5)), // |
|
| 572 | + array(array(5, 1), array(5, 5), array(5, 7), array(11, 7)), // 15 |
|
| 573 | + array(array(5, 1), array(7, 3), array(15, 2), array(3, 13)), // |
|
| 574 | + array(array(1, 5), array(10, 1), array(1, 15), array(2, 17)), // |
|
| 575 | + array(array(5, 1), array(9, 4), array(17, 1), array(2, 19)), // |
|
| 576 | + array(array(3, 4), array(3, 11), array(17, 4), array(9, 16)), // |
|
| 577 | + array(array(3, 5), array(3, 13), array(15, 5), array(15, 10)), // 20 |
|
| 578 | + array(array(4, 4), array(17, 0), array(17, 6), array(19, 6)), // |
|
| 579 | + array(array(2, 7), array(17, 0), array(7, 16), array(34, 0)), // |
|
| 580 | + array(array(4, 5), array(4, 14), array(11, 14), array(16, 14)), // |
|
| 581 | + array(array(6, 4), array(6, 14), array(11, 16), array(30, 2)), // |
|
| 582 | + array(array(8, 4), array(8, 13), array(7, 22), array(22, 13)), // 25 |
|
| 583 | + array(array(10, 2), array(19, 4), array(28, 6), array(33, 4)), // |
|
| 584 | + array(array(8, 4), array(22, 3), array(8, 26), array(12, 28)), // |
|
| 585 | + array(array(3, 10), array(3, 23), array(4, 31), array(11, 31)), // |
|
| 586 | + array(array(7, 7), array(21, 7), array(1, 37), array(19, 26)), // |
|
| 587 | + array(array(5, 10), array(19, 10), array(15, 25), array(23, 25)), // 30 |
|
| 588 | + array(array(13, 3), array(2, 29), array(42, 1), array(23, 28)), // |
|
| 589 | + array(array(17, 0), array(10, 23), array(10, 35), array(19, 35)), // |
|
| 590 | + array(array(17, 1), array(14, 21), array(29, 19), array(11, 46)), // |
|
| 591 | + array(array(13, 6), array(14, 23), array(44, 7), array(59, 1)), // |
|
| 592 | + array(array(12, 7), array(12, 26), array(39, 14), array(22, 41)), // 35 |
|
| 593 | + array(array(6, 14), array(6, 34), array(46, 10), array(2, 64)), // |
|
| 594 | + array(array(17, 4), array(29, 14), array(49, 10), array(24, 46)), // |
|
| 595 | + array(array(4, 18), array(13, 32), array(48, 14), array(42, 32)), // |
|
| 596 | + array(array(20, 4), array(40, 7), array(43, 22), array(10, 67)), // |
|
| 597 | + array(array(19, 6), array(18, 31), array(34, 34), array(20, 61)) // 40 |
|
| 598 | 598 | ); |
| 599 | 599 | |
| 600 | 600 | /** |
@@ -604,9 +604,9 @@ discard block |
||
| 604 | 604 | * @access protected |
| 605 | 605 | */ |
| 606 | 606 | protected $alignmentPattern = array( |
| 607 | - array( 0, 0), |
|
| 608 | - array( 0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), // 1- 5 |
|
| 609 | - array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), // 6-10 |
|
| 607 | + array(0, 0), |
|
| 608 | + array(0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), // 1- 5 |
|
| 609 | + array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), // 6-10 |
|
| 610 | 610 | array(30, 54), array(32, 58), array(34, 62), array(26, 46), array(26, 48), // 11-15 |
| 611 | 611 | array(26, 50), array(30, 54), array(30, 56), array(30, 58), array(34, 62), // 16-20 |
| 612 | 612 | array(28, 50), array(26, 50), array(30, 54), array(28, 54), array(32, 58), // 21-25 |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | foreach ($qrTab as $line) { |
| 680 | 680 | $arrAdd = array(); |
| 681 | 681 | foreach (str_split($line) as $char) { |
| 682 | - $arrAdd[] = ($char=='1')?1:0; |
|
| 682 | + $arrAdd[] = ($char == '1') ? 1 : 0; |
|
| 683 | 683 | } |
| 684 | 684 | $barcode_array['bcode'][] = $arrAdd; |
| 685 | 685 | } |
@@ -704,8 +704,8 @@ discard block |
||
| 704 | 704 | $len = count($frame); |
| 705 | 705 | // the frame is square (width = height) |
| 706 | 706 | foreach ($frame as &$frameLine) { |
| 707 | - for ($i=0; $i<$len; $i++) { |
|
| 708 | - $frameLine[$i] = (ord($frameLine[$i])&1)?'1':'0'; |
|
| 707 | + for ($i = 0; $i < $len; $i++) { |
|
| 708 | + $frameLine[$i] = (ord($frameLine[$i]) & 1) ? '1' : '0'; |
|
| 709 | 709 | } |
| 710 | 710 | } |
| 711 | 711 | return $frame; |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | */ |
| 718 | 718 | protected function encodeString($string) { |
| 719 | 719 | $this->dataStr = $string; |
| 720 | - if (!$this->casesensitive) { |
|
| 720 | + if ( ! $this->casesensitive) { |
|
| 721 | 721 | $this->toUpper(); |
| 722 | 722 | } |
| 723 | 723 | $ret = $this->splitString(); |
@@ -755,10 +755,10 @@ discard block |
||
| 755 | 755 | $this->dir = -1; |
| 756 | 756 | $this->bit = -1; |
| 757 | 757 | // inteleaved data and ecc codes |
| 758 | - for ($i=0; $i < ($this->dataLength + $this->eccLength); $i++) { |
|
| 758 | + for ($i = 0; $i < ($this->dataLength + $this->eccLength); $i++) { |
|
| 759 | 759 | $code = $this->getCode(); |
| 760 | 760 | $bit = 0x80; |
| 761 | - for ($j=0; $j<8; $j++) { |
|
| 761 | + for ($j = 0; $j < 8; $j++) { |
|
| 762 | 762 | $addr = $this->getNextPosition(); |
| 763 | 763 | $this->setFrameAt($addr, 0x02 | (($bit & $code) != 0)); |
| 764 | 764 | $bit = $bit >> 1; |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | } |
| 767 | 767 | // remainder bits |
| 768 | 768 | $j = $this->getRemainder($this->version); |
| 769 | - for ($i=0; $i<$j; $i++) { |
|
| 769 | + for ($i = 0; $i < $j; $i++) { |
|
| 770 | 770 | $addr = $this->getNextPosition(); |
| 771 | 771 | $this->setFrameAt($addr, 0x02); |
| 772 | 772 | } |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | } |
| 857 | 857 | $this->x = $x; |
| 858 | 858 | $this->y = $y; |
| 859 | - } while(ord($this->frame[$y][$x]) & 0x80); |
|
| 859 | + } while (ord($this->frame[$y][$x]) & 0x80); |
|
| 860 | 860 | return array('x'=>$x, 'y'=>$y); |
| 861 | 861 | } |
| 862 | 862 | |
@@ -877,7 +877,7 @@ discard block |
||
| 877 | 877 | $dataPos = 0; |
| 878 | 878 | $eccPos = 0; |
| 879 | 879 | $endfor = $this->rsBlockNum1($spec); |
| 880 | - for ($i=0; $i < $endfor; ++$i) { |
|
| 880 | + for ($i = 0; $i < $endfor; ++$i) { |
|
| 881 | 881 | $ecc = array_slice($this->ecccode, $eccPos); |
| 882 | 882 | $this->rsblocks[$blockNo] = array(); |
| 883 | 883 | $this->rsblocks[$blockNo]['dataLength'] = $dl; |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | $this->rsblocks[$blockNo]['eccLength'] = $el; |
| 886 | 886 | $ecc = $this->encode_rs_char($rs, $this->rsblocks[$blockNo]['data'], $ecc); |
| 887 | 887 | $this->rsblocks[$blockNo]['ecc'] = $ecc; |
| 888 | - $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc); |
|
| 888 | + $this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc); |
|
| 889 | 889 | $dataPos += $dl; |
| 890 | 890 | $eccPos += $el; |
| 891 | 891 | $blockNo++; |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | return -1; |
| 901 | 901 | } |
| 902 | 902 | $endfor = $this->rsBlockNum2($spec); |
| 903 | - for ($i=0; $i < $endfor; ++$i) { |
|
| 903 | + for ($i = 0; $i < $endfor; ++$i) { |
|
| 904 | 904 | $ecc = array_slice($this->ecccode, $eccPos); |
| 905 | 905 | $this->rsblocks[$blockNo] = array(); |
| 906 | 906 | $this->rsblocks[$blockNo]['dataLength'] = $dl; |
@@ -953,8 +953,8 @@ discard block |
||
| 953 | 953 | */ |
| 954 | 954 | protected function writeFormatInformation($width, &$frame, $mask, $level) { |
| 955 | 955 | $blacks = 0; |
| 956 | - $format = $this->getFormatInfo($mask, $level); |
|
| 957 | - for ($i=0; $i<8; ++$i) { |
|
| 956 | + $format = $this->getFormatInfo($mask, $level); |
|
| 957 | + for ($i = 0; $i < 8; ++$i) { |
|
| 958 | 958 | if ($format & 1) { |
| 959 | 959 | $blacks += 2; |
| 960 | 960 | $v = 0x85; |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | } |
| 970 | 970 | $format = $format >> 1; |
| 971 | 971 | } |
| 972 | - for ($i=0; $i<7; ++$i) { |
|
| 972 | + for ($i = 0; $i < 7; ++$i) { |
|
| 973 | 973 | if ($format & 1) { |
| 974 | 974 | $blacks += 2; |
| 975 | 975 | $v = 0x85; |
@@ -1076,13 +1076,13 @@ discard block |
||
| 1076 | 1076 | */ |
| 1077 | 1077 | protected function generateMaskNo($maskNo, $width, $frame) { |
| 1078 | 1078 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
| 1079 | - for ($y=0; $y<$width; ++$y) { |
|
| 1080 | - for ($x=0; $x<$width; ++$x) { |
|
| 1079 | + for ($y = 0; $y < $width; ++$y) { |
|
| 1080 | + for ($x = 0; $x < $width; ++$x) { |
|
| 1081 | 1081 | if (ord($frame[$y][$x]) & 0x80) { |
| 1082 | 1082 | $bitMask[$y][$x] = 0; |
| 1083 | 1083 | } else { |
| 1084 | 1084 | $maskFunc = call_user_func(array($this, 'mask'.$maskNo), $x, $y); |
| 1085 | - $bitMask[$y][$x] = ($maskFunc == 0)?1:0; |
|
| 1085 | + $bitMask[$y][$x] = ($maskFunc == 0) ? 1 : 0; |
|
| 1086 | 1086 | } |
| 1087 | 1087 | } |
| 1088 | 1088 | } |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | * @param boolean $maskGenOnly |
| 1099 | 1099 | * @return int b |
| 1100 | 1100 | */ |
| 1101 | - protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly=false) { |
|
| 1101 | + protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly = false) { |
|
| 1102 | 1102 | $b = 0; |
| 1103 | 1103 | $bitMask = array(); |
| 1104 | 1104 | $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); |
@@ -1106,8 +1106,8 @@ discard block |
||
| 1106 | 1106 | return; |
| 1107 | 1107 | } |
| 1108 | 1108 | $d = $s; |
| 1109 | - for ($y=0; $y<$width; ++$y) { |
|
| 1110 | - for ($x=0; $x<$width; ++$x) { |
|
| 1109 | + for ($y = 0; $y < $width; ++$y) { |
|
| 1110 | + for ($x = 0; $x < $width; ++$x) { |
|
| 1111 | 1111 | if ($bitMask[$y][$x] == 1) { |
| 1112 | 1112 | $d[$y][$x] = chr(ord($s[$y][$x]) ^ (int)$bitMask[$y][$x]); |
| 1113 | 1113 | } |
@@ -1139,20 +1139,20 @@ discard block |
||
| 1139 | 1139 | */ |
| 1140 | 1140 | protected function calcN1N3($length) { |
| 1141 | 1141 | $demerit = 0; |
| 1142 | - for ($i=0; $i<$length; ++$i) { |
|
| 1142 | + for ($i = 0; $i < $length; ++$i) { |
|
| 1143 | 1143 | if ($this->runLength[$i] >= 5) { |
| 1144 | 1144 | $demerit += (N1 + ($this->runLength[$i] - 5)); |
| 1145 | 1145 | } |
| 1146 | 1146 | if ($i & 1) { |
| 1147 | - if (($i >= 3) AND ($i < ($length-2)) AND ($this->runLength[$i] % 3 == 0)) { |
|
| 1147 | + if (($i >= 3) AND ($i < ($length - 2)) AND ($this->runLength[$i] % 3 == 0)) { |
|
| 1148 | 1148 | $fact = (int)($this->runLength[$i] / 3); |
| 1149 | - if (($this->runLength[$i-2] == $fact) |
|
| 1150 | - AND ($this->runLength[$i-1] == $fact) |
|
| 1151 | - AND ($this->runLength[$i+1] == $fact) |
|
| 1152 | - AND ($this->runLength[$i+2] == $fact)) { |
|
| 1153 | - if (($this->runLength[$i-3] < 0) OR ($this->runLength[$i-3] >= (4 * $fact))) { |
|
| 1149 | + if (($this->runLength[$i - 2] == $fact) |
|
| 1150 | + AND ($this->runLength[$i - 1] == $fact) |
|
| 1151 | + AND ($this->runLength[$i + 1] == $fact) |
|
| 1152 | + AND ($this->runLength[$i + 2] == $fact)) { |
|
| 1153 | + if (($this->runLength[$i - 3] < 0) OR ($this->runLength[$i - 3] >= (4 * $fact))) { |
|
| 1154 | 1154 | $demerit += N3; |
| 1155 | - } elseif ((($i+3) >= $length) OR ($this->runLength[$i+3] >= (4 * $fact))) { |
|
| 1155 | + } elseif ((($i + 3) >= $length) OR ($this->runLength[$i + 3] >= (4 * $fact))) { |
|
| 1156 | 1156 | $demerit += N3; |
| 1157 | 1157 | } |
| 1158 | 1158 | } |
@@ -1171,17 +1171,17 @@ discard block |
||
| 1171 | 1171 | protected function evaluateSymbol($width, $frame) { |
| 1172 | 1172 | $head = 0; |
| 1173 | 1173 | $demerit = 0; |
| 1174 | - for ($y=0; $y<$width; ++$y) { |
|
| 1174 | + for ($y = 0; $y < $width; ++$y) { |
|
| 1175 | 1175 | $head = 0; |
| 1176 | 1176 | $this->runLength[0] = 1; |
| 1177 | 1177 | $frameY = $frame[$y]; |
| 1178 | 1178 | if ($y > 0) { |
| 1179 | - $frameYM = $frame[$y-1]; |
|
| 1179 | + $frameYM = $frame[$y - 1]; |
|
| 1180 | 1180 | } |
| 1181 | - for ($x=0; $x<$width; ++$x) { |
|
| 1181 | + for ($x = 0; $x < $width; ++$x) { |
|
| 1182 | 1182 | if (($x > 0) AND ($y > 0)) { |
| 1183 | - $b22 = ord($frameY[$x]) & ord($frameY[$x-1]) & ord($frameYM[$x]) & ord($frameYM[$x-1]); |
|
| 1184 | - $w22 = ord($frameY[$x]) | ord($frameY[$x-1]) | ord($frameYM[$x]) | ord($frameYM[$x-1]); |
|
| 1183 | + $b22 = ord($frameY[$x]) & ord($frameY[$x - 1]) & ord($frameYM[$x]) & ord($frameYM[$x - 1]); |
|
| 1184 | + $w22 = ord($frameY[$x]) | ord($frameY[$x - 1]) | ord($frameYM[$x]) | ord($frameYM[$x - 1]); |
|
| 1185 | 1185 | if (($b22 | ($w22 ^ 1)) & 1) { |
| 1186 | 1186 | $demerit += N2; |
| 1187 | 1187 | } |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | $head = 1; |
| 1192 | 1192 | $this->runLength[$head] = 1; |
| 1193 | 1193 | } elseif ($x > 0) { |
| 1194 | - if ((ord($frameY[$x]) ^ ord($frameY[$x-1])) & 1) { |
|
| 1194 | + if ((ord($frameY[$x]) ^ ord($frameY[$x - 1])) & 1) { |
|
| 1195 | 1195 | $head++; |
| 1196 | 1196 | $this->runLength[$head] = 1; |
| 1197 | 1197 | } else { |
@@ -1199,18 +1199,18 @@ discard block |
||
| 1199 | 1199 | } |
| 1200 | 1200 | } |
| 1201 | 1201 | } |
| 1202 | - $demerit += $this->calcN1N3($head+1); |
|
| 1202 | + $demerit += $this->calcN1N3($head + 1); |
|
| 1203 | 1203 | } |
| 1204 | - for ($x=0; $x<$width; ++$x) { |
|
| 1204 | + for ($x = 0; $x < $width; ++$x) { |
|
| 1205 | 1205 | $head = 0; |
| 1206 | 1206 | $this->runLength[0] = 1; |
| 1207 | - for ($y=0; $y<$width; ++$y) { |
|
| 1207 | + for ($y = 0; $y < $width; ++$y) { |
|
| 1208 | 1208 | if (($y == 0) AND (ord($frame[$y][$x]) & 1)) { |
| 1209 | 1209 | $this->runLength[0] = -1; |
| 1210 | 1210 | $head = 1; |
| 1211 | 1211 | $this->runLength[$head] = 1; |
| 1212 | 1212 | } elseif ($y > 0) { |
| 1213 | - if ((ord($frame[$y][$x]) ^ ord($frame[$y-1][$x])) & 1) { |
|
| 1213 | + if ((ord($frame[$y][$x]) ^ ord($frame[$y - 1][$x])) & 1) { |
|
| 1214 | 1214 | $head++; |
| 1215 | 1215 | $this->runLength[$head] = 1; |
| 1216 | 1216 | } else { |
@@ -1218,7 +1218,7 @@ discard block |
||
| 1218 | 1218 | } |
| 1219 | 1219 | } |
| 1220 | 1220 | } |
| 1221 | - $demerit += $this->calcN1N3($head+1); |
|
| 1221 | + $demerit += $this->calcN1N3($head + 1); |
|
| 1222 | 1222 | } |
| 1223 | 1223 | return $demerit; |
| 1224 | 1224 | } |
@@ -1237,8 +1237,8 @@ discard block |
||
| 1237 | 1237 | $checked_masks = array(0, 1, 2, 3, 4, 5, 6, 7); |
| 1238 | 1238 | if (QR_FIND_FROM_RANDOM !== false) { |
| 1239 | 1239 | $howManuOut = 8 - (QR_FIND_FROM_RANDOM % 9); |
| 1240 | - for ($i = 0; $i < $howManuOut; ++$i) { |
|
| 1241 | - $remPos = rand (0, count($checked_masks)-1); |
|
| 1240 | + for ($i = 0; $i < $howManuOut; ++$i) { |
|
| 1241 | + $remPos = rand(0, count($checked_masks) - 1); |
|
| 1242 | 1242 | unset($checked_masks[$remPos]); |
| 1243 | 1243 | $checked_masks = array_values($checked_masks); |
| 1244 | 1244 | } |
@@ -1276,7 +1276,7 @@ discard block |
||
| 1276 | 1276 | if ($pos >= strlen($str)) { |
| 1277 | 1277 | return false; |
| 1278 | 1278 | } |
| 1279 | - return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9'))); |
|
| 1279 | + return ((ord($str[$pos]) >= ord('0')) && (ord($str[$pos]) <= ord('9'))); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | /** |
@@ -1307,8 +1307,8 @@ discard block |
||
| 1307 | 1307 | } elseif ($this->isalnumat($this->dataStr, $pos)) { |
| 1308 | 1308 | return QR_MODE_AN; |
| 1309 | 1309 | } elseif ($this->hint == QR_MODE_KJ) { |
| 1310 | - if ($pos+1 < strlen($this->dataStr)) { |
|
| 1311 | - $d = $this->dataStr[$pos+1]; |
|
| 1310 | + if ($pos + 1 < strlen($this->dataStr)) { |
|
| 1311 | + $d = $this->dataStr[$pos + 1]; |
|
| 1312 | 1312 | $word = (ord($c) << 8) | ord($d); |
| 1313 | 1313 | if (($word >= 0x8140 && $word <= 0x9ffc) OR ($word >= 0xe040 && $word <= 0xebbf)) { |
| 1314 | 1314 | return QR_MODE_KJ; |
@@ -1325,7 +1325,7 @@ discard block |
||
| 1325 | 1325 | protected function eatNum() { |
| 1326 | 1326 | $ln = $this->lengthIndicator(QR_MODE_NM, $this->version); |
| 1327 | 1327 | $p = 0; |
| 1328 | - while($this->isdigitat($this->dataStr, $p)) { |
|
| 1328 | + while ($this->isdigitat($this->dataStr, $p)) { |
|
| 1329 | 1329 | $p++; |
| 1330 | 1330 | } |
| 1331 | 1331 | $run = $p; |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | if ($mode == QR_MODE_AN) { |
| 1342 | 1342 | $dif = $this->estimateBitsModeNum($run) + 4 + $ln |
| 1343 | 1343 | + $this->estimateBitsModeAn(1) // + 4 + la |
| 1344 | - - $this->estimateBitsModeAn($run + 1);// - 4 - la |
|
| 1344 | + - $this->estimateBitsModeAn($run + 1); // - 4 - la |
|
| 1345 | 1345 | if ($dif > 0) { |
| 1346 | 1346 | return $this->eatAn(); |
| 1347 | 1347 | } |
@@ -1355,13 +1355,13 @@ discard block |
||
| 1355 | 1355 | * @return int run |
| 1356 | 1356 | */ |
| 1357 | 1357 | protected function eatAn() { |
| 1358 | - $la = $this->lengthIndicator(QR_MODE_AN, $this->version); |
|
| 1358 | + $la = $this->lengthIndicator(QR_MODE_AN, $this->version); |
|
| 1359 | 1359 | $ln = $this->lengthIndicator(QR_MODE_NM, $this->version); |
| 1360 | 1360 | $p = 0; |
| 1361 | - while($this->isalnumat($this->dataStr, $p)) { |
|
| 1361 | + while ($this->isalnumat($this->dataStr, $p)) { |
|
| 1362 | 1362 | if ($this->isdigitat($this->dataStr, $p)) { |
| 1363 | 1363 | $q = $p; |
| 1364 | - while($this->isdigitat($this->dataStr, $q)) { |
|
| 1364 | + while ($this->isdigitat($this->dataStr, $q)) { |
|
| 1365 | 1365 | $q++; |
| 1366 | 1366 | } |
| 1367 | 1367 | $dif = $this->estimateBitsModeAn($p) // + 4 + la |
@@ -1377,7 +1377,7 @@ discard block |
||
| 1377 | 1377 | } |
| 1378 | 1378 | } |
| 1379 | 1379 | $run = $p; |
| 1380 | - if (!$this->isalnumat($this->dataStr, $p)) { |
|
| 1380 | + if ( ! $this->isalnumat($this->dataStr, $p)) { |
|
| 1381 | 1381 | $dif = $this->estimateBitsModeAn($run) + 4 + $la |
| 1382 | 1382 | + $this->estimateBitsMode8(1) // + 4 + l8 |
| 1383 | 1383 | - $this->estimateBitsMode8($run + 1); // - 4 - l8 |
@@ -1395,7 +1395,7 @@ discard block |
||
| 1395 | 1395 | */ |
| 1396 | 1396 | protected function eatKanji() { |
| 1397 | 1397 | $p = 0; |
| 1398 | - while($this->identifyMode($p) == QR_MODE_KJ) { |
|
| 1398 | + while ($this->identifyMode($p) == QR_MODE_KJ) { |
|
| 1399 | 1399 | $p += 2; |
| 1400 | 1400 | } |
| 1401 | 1401 | $this->items = $this->appendNewInputItem($this->items, QR_MODE_KJ, $p, str_split($this->dataStr)); |
@@ -1411,14 +1411,14 @@ discard block |
||
| 1411 | 1411 | $ln = $this->lengthIndicator(QR_MODE_NM, $this->version); |
| 1412 | 1412 | $p = 1; |
| 1413 | 1413 | $dataStrLen = strlen($this->dataStr); |
| 1414 | - while($p < $dataStrLen) { |
|
| 1414 | + while ($p < $dataStrLen) { |
|
| 1415 | 1415 | $mode = $this->identifyMode($p); |
| 1416 | 1416 | if ($mode == QR_MODE_KJ) { |
| 1417 | 1417 | break; |
| 1418 | 1418 | } |
| 1419 | 1419 | if ($mode == QR_MODE_NM) { |
| 1420 | 1420 | $q = $p; |
| 1421 | - while($this->isdigitat($this->dataStr, $q)) { |
|
| 1421 | + while ($this->isdigitat($this->dataStr, $q)) { |
|
| 1422 | 1422 | $q++; |
| 1423 | 1423 | } |
| 1424 | 1424 | $dif = $this->estimateBitsMode8($p) // + 4 + l8 |
@@ -1431,7 +1431,7 @@ discard block |
||
| 1431 | 1431 | } |
| 1432 | 1432 | } elseif ($mode == QR_MODE_AN) { |
| 1433 | 1433 | $q = $p; |
| 1434 | - while($this->isalnumat($this->dataStr, $q)) { |
|
| 1434 | + while ($this->isalnumat($this->dataStr, $q)) { |
|
| 1435 | 1435 | $q++; |
| 1436 | 1436 | } |
| 1437 | 1437 | $dif = $this->estimateBitsMode8($p) // + 4 + l8 |
@@ -1524,12 +1524,12 @@ discard block |
||
| 1524 | 1524 | * @param array $bstream |
| 1525 | 1525 | * @return array input item |
| 1526 | 1526 | */ |
| 1527 | - protected function newInputItem($mode, $size, $data, $bstream=null) { |
|
| 1527 | + protected function newInputItem($mode, $size, $data, $bstream = null) { |
|
| 1528 | 1528 | $setData = array_slice($data, 0, $size); |
| 1529 | 1529 | if (count($setData) < $size) { |
| 1530 | 1530 | $setData = array_merge($setData, array_fill(0, ($size - count($setData)), 0)); |
| 1531 | 1531 | } |
| 1532 | - if (!$this->check($mode, $size, $setData)) { |
|
| 1532 | + if ( ! $this->check($mode, $size, $setData)) { |
|
| 1533 | 1533 | return NULL; |
| 1534 | 1534 | } |
| 1535 | 1535 | $inputitem = array(); |
@@ -1552,18 +1552,18 @@ discard block |
||
| 1552 | 1552 | $val = 0x1; |
| 1553 | 1553 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val); |
| 1554 | 1554 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_NM, $version), $inputitem['size']); |
| 1555 | - for ($i=0; $i < $words; ++$i) { |
|
| 1556 | - $val = (ord($inputitem['data'][$i*3 ]) - ord('0')) * 100; |
|
| 1557 | - $val += (ord($inputitem['data'][$i*3+1]) - ord('0')) * 10; |
|
| 1558 | - $val += (ord($inputitem['data'][$i*3+2]) - ord('0')); |
|
| 1555 | + for ($i = 0; $i < $words; ++$i) { |
|
| 1556 | + $val = (ord($inputitem['data'][$i * 3]) - ord('0')) * 100; |
|
| 1557 | + $val += (ord($inputitem['data'][$i * 3 + 1]) - ord('0')) * 10; |
|
| 1558 | + $val += (ord($inputitem['data'][$i * 3 + 2]) - ord('0')); |
|
| 1559 | 1559 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 10, $val); |
| 1560 | 1560 | } |
| 1561 | 1561 | if ($inputitem['size'] - $words * 3 == 1) { |
| 1562 | - $val = ord($inputitem['data'][$words*3]) - ord('0'); |
|
| 1562 | + $val = ord($inputitem['data'][$words * 3]) - ord('0'); |
|
| 1563 | 1563 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val); |
| 1564 | 1564 | } elseif (($inputitem['size'] - ($words * 3)) == 2) { |
| 1565 | - $val = (ord($inputitem['data'][$words*3 ]) - ord('0')) * 10; |
|
| 1566 | - $val += (ord($inputitem['data'][$words*3+1]) - ord('0')); |
|
| 1565 | + $val = (ord($inputitem['data'][$words * 3]) - ord('0')) * 10; |
|
| 1566 | + $val += (ord($inputitem['data'][$words * 3 + 1]) - ord('0')); |
|
| 1567 | 1567 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 7, $val); |
| 1568 | 1568 | } |
| 1569 | 1569 | return $inputitem; |
@@ -1580,9 +1580,9 @@ discard block |
||
| 1580 | 1580 | $inputitem['bstream'] = array(); |
| 1581 | 1581 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x02); |
| 1582 | 1582 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_AN, $version), $inputitem['size']); //DEBUG |
| 1583 | - for ($i=0; $i < $words; ++$i) { |
|
| 1584 | - $val = (int)$this->lookAnTable(ord($inputitem['data'][$i*2 ])) * 45; |
|
| 1585 | - $val += (int)$this->lookAnTable(ord($inputitem['data'][$i*2+1])); |
|
| 1583 | + for ($i = 0; $i < $words; ++$i) { |
|
| 1584 | + $val = (int)$this->lookAnTable(ord($inputitem['data'][$i * 2])) * 45; |
|
| 1585 | + $val += (int)$this->lookAnTable(ord($inputitem['data'][$i * 2 + 1])); |
|
| 1586 | 1586 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 11, $val); |
| 1587 | 1587 | } |
| 1588 | 1588 | if ($inputitem['size'] & 1) { |
@@ -1602,7 +1602,7 @@ discard block |
||
| 1602 | 1602 | $inputitem['bstream'] = array(); |
| 1603 | 1603 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x4); |
| 1604 | 1604 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_8B, $version), $inputitem['size']); |
| 1605 | - for ($i=0; $i < $inputitem['size']; ++$i) { |
|
| 1605 | + for ($i = 0; $i < $inputitem['size']; ++$i) { |
|
| 1606 | 1606 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, ord($inputitem['data'][$i])); |
| 1607 | 1607 | } |
| 1608 | 1608 | return $inputitem; |
@@ -1618,8 +1618,8 @@ discard block |
||
| 1618 | 1618 | $inputitem['bstream'] = array(); |
| 1619 | 1619 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x8); |
| 1620 | 1620 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_KJ, $version), (int)($inputitem['size'] / 2)); |
| 1621 | - for ($i=0; $i<$inputitem['size']; $i+=2) { |
|
| 1622 | - $val = (ord($inputitem['data'][$i]) << 8) | ord($inputitem['data'][$i+1]); |
|
| 1621 | + for ($i = 0; $i < $inputitem['size']; $i += 2) { |
|
| 1622 | + $val = (ord($inputitem['data'][$i]) << 8) | ord($inputitem['data'][$i + 1]); |
|
| 1623 | 1623 | if ($val <= 0x9ffc) { |
| 1624 | 1624 | $val -= 0x8140; |
| 1625 | 1625 | } else { |
@@ -1664,7 +1664,7 @@ discard block |
||
| 1664 | 1664 | $inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st1['bstream']); |
| 1665 | 1665 | $inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st2['bstream']); |
| 1666 | 1666 | } else { |
| 1667 | - switch($inputitem['mode']) { |
|
| 1667 | + switch ($inputitem['mode']) { |
|
| 1668 | 1668 | case QR_MODE_NM: { |
| 1669 | 1669 | $inputitem = $this->encodeModeNum($inputitem, $version); |
| 1670 | 1670 | break; |
@@ -1742,7 +1742,7 @@ discard block |
||
| 1742 | 1742 | $parity = 0; |
| 1743 | 1743 | foreach ($items as $item) { |
| 1744 | 1744 | if ($item['mode'] != QR_MODE_ST) { |
| 1745 | - for ($i=$item['size']-1; $i>=0; --$i) { |
|
| 1745 | + for ($i = $item['size'] - 1; $i >= 0; --$i) { |
|
| 1746 | 1746 | $parity ^= $item['data'][$i]; |
| 1747 | 1747 | } |
| 1748 | 1748 | } |
@@ -1757,8 +1757,8 @@ discard block |
||
| 1757 | 1757 | * @return boolean true or false |
| 1758 | 1758 | */ |
| 1759 | 1759 | protected function checkModeNum($size, $data) { |
| 1760 | - for ($i=0; $i<$size; ++$i) { |
|
| 1761 | - if ((ord($data[$i]) < ord('0')) OR (ord($data[$i]) > ord('9'))){ |
|
| 1760 | + for ($i = 0; $i < $size; ++$i) { |
|
| 1761 | + if ((ord($data[$i]) < ord('0')) OR (ord($data[$i]) > ord('9'))) { |
|
| 1762 | 1762 | return false; |
| 1763 | 1763 | } |
| 1764 | 1764 | } |
@@ -1773,7 +1773,7 @@ discard block |
||
| 1773 | 1773 | protected function estimateBitsModeNum($size) { |
| 1774 | 1774 | $w = (int)$size / 3; |
| 1775 | 1775 | $bits = $w * 10; |
| 1776 | - switch($size - $w * 3) { |
|
| 1776 | + switch ($size - $w * 3) { |
|
| 1777 | 1777 | case 1: { |
| 1778 | 1778 | $bits += 4; |
| 1779 | 1779 | break; |
@@ -1795,7 +1795,7 @@ discard block |
||
| 1795 | 1795 | * @return value |
| 1796 | 1796 | */ |
| 1797 | 1797 | protected function lookAnTable($c) { |
| 1798 | - return (($c > 127)?-1:$this->anTable[$c]); |
|
| 1798 | + return (($c > 127) ?-1 : $this->anTable[$c]); |
|
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | 1801 | /** |
@@ -1805,7 +1805,7 @@ discard block |
||
| 1805 | 1805 | * @return boolean true or false |
| 1806 | 1806 | */ |
| 1807 | 1807 | protected function checkModeAn($size, $data) { |
| 1808 | - for ($i=0; $i<$size; ++$i) { |
|
| 1808 | + for ($i = 0; $i < $size; ++$i) { |
|
| 1809 | 1809 | if ($this->lookAnTable(ord($data[$i])) == -1) { |
| 1810 | 1810 | return false; |
| 1811 | 1811 | } |
@@ -1855,8 +1855,8 @@ discard block |
||
| 1855 | 1855 | if ($size & 1) { |
| 1856 | 1856 | return false; |
| 1857 | 1857 | } |
| 1858 | - for ($i=0; $i<$size; $i+=2) { |
|
| 1859 | - $val = (ord($data[$i]) << 8) | ord($data[$i+1]); |
|
| 1858 | + for ($i = 0; $i < $size; $i += 2) { |
|
| 1859 | + $val = (ord($data[$i]) << 8) | ord($data[$i + 1]); |
|
| 1860 | 1860 | if (($val < 0x8140) OR (($val > 0x9ffc) AND ($val < 0xe040)) OR ($val > 0xebbf)) { |
| 1861 | 1861 | return false; |
| 1862 | 1862 | } |
@@ -1875,7 +1875,7 @@ discard block |
||
| 1875 | 1875 | if ($size <= 0) { |
| 1876 | 1876 | return false; |
| 1877 | 1877 | } |
| 1878 | - switch($mode) { |
|
| 1878 | + switch ($mode) { |
|
| 1879 | 1879 | case QR_MODE_NM: { |
| 1880 | 1880 | return $this->checkModeNum($size, $data); |
| 1881 | 1881 | } |
@@ -1910,7 +1910,7 @@ discard block |
||
| 1910 | 1910 | $version = 1; |
| 1911 | 1911 | } |
| 1912 | 1912 | foreach ($items as $item) { |
| 1913 | - switch($item['mode']) { |
|
| 1913 | + switch ($item['mode']) { |
|
| 1914 | 1914 | case QR_MODE_NM: { |
| 1915 | 1915 | $bits = $this->estimateBitsModeNum($item['size']); |
| 1916 | 1916 | break; |
@@ -1970,7 +1970,7 @@ discard block |
||
| 1970 | 1970 | */ |
| 1971 | 1971 | protected function lengthOfCode($mode, $version, $bits) { |
| 1972 | 1972 | $payload = $bits - 4 - $this->lengthIndicator($mode, $version); |
| 1973 | - switch($mode) { |
|
| 1973 | + switch ($mode) { |
|
| 1974 | 1974 | case QR_MODE_NM: { |
| 1975 | 1975 | $chunks = (int)($payload / 10); |
| 1976 | 1976 | $remain = $payload - $chunks * 10; |
@@ -2084,8 +2084,8 @@ discard block |
||
| 2084 | 2084 | $padlen = $maxwords - $words; |
| 2085 | 2085 | if ($padlen > 0) { |
| 2086 | 2086 | $padbuf = array(); |
| 2087 | - for ($i=0; $i<$padlen; ++$i) { |
|
| 2088 | - $padbuf[$i] = ($i&1)?0x11:0xec; |
|
| 2087 | + for ($i = 0; $i < $padlen; ++$i) { |
|
| 2088 | + $padbuf[$i] = ($i & 1) ? 0x11 : 0xec; |
|
| 2089 | 2089 | } |
| 2090 | 2090 | $padding = $this->appendBytes($padding, $padlen, $padbuf); |
| 2091 | 2091 | } |
@@ -2148,7 +2148,7 @@ discard block |
||
| 2148 | 2148 | protected function newFromNum($bits, $num) { |
| 2149 | 2149 | $bstream = $this->allocate($bits); |
| 2150 | 2150 | $mask = 1 << ($bits - 1); |
| 2151 | - for ($i=0; $i<$bits; ++$i) { |
|
| 2151 | + for ($i = 0; $i < $bits; ++$i) { |
|
| 2152 | 2152 | if ($num & $mask) { |
| 2153 | 2153 | $bstream[$i] = 1; |
| 2154 | 2154 | } else { |
@@ -2167,10 +2167,10 @@ discard block |
||
| 2167 | 2167 | */ |
| 2168 | 2168 | protected function newFromBytes($size, $data) { |
| 2169 | 2169 | $bstream = $this->allocate($size * 8); |
| 2170 | - $p=0; |
|
| 2171 | - for ($i=0; $i<$size; ++$i) { |
|
| 2170 | + $p = 0; |
|
| 2171 | + for ($i = 0; $i < $size; ++$i) { |
|
| 2172 | 2172 | $mask = 0x80; |
| 2173 | - for ($j=0; $j<8; ++$j) { |
|
| 2173 | + for ($j = 0; $j < 8; ++$j) { |
|
| 2174 | 2174 | if ($data[$i] & $mask) { |
| 2175 | 2175 | $bstream[$p] = 1; |
| 2176 | 2176 | } else { |
@@ -2190,7 +2190,7 @@ discard block |
||
| 2190 | 2190 | * @return array bitstream |
| 2191 | 2191 | */ |
| 2192 | 2192 | protected function appendBitstream($bitstream, $append) { |
| 2193 | - if ((!is_array($append)) OR (count($append) == 0)) { |
|
| 2193 | + if (( ! is_array($append)) OR (count($append) == 0)) { |
|
| 2194 | 2194 | return $bitstream; |
| 2195 | 2195 | } |
| 2196 | 2196 | if (count($bitstream) == 0) { |
@@ -2242,9 +2242,9 @@ discard block |
||
| 2242 | 2242 | $data = array_fill(0, (int)(($size + 7) / 8), 0); |
| 2243 | 2243 | $bytes = (int)($size / 8); |
| 2244 | 2244 | $p = 0; |
| 2245 | - for ($i=0; $i<$bytes; $i++) { |
|
| 2245 | + for ($i = 0; $i < $bytes; $i++) { |
|
| 2246 | 2246 | $v = 0; |
| 2247 | - for ($j=0; $j<8; $j++) { |
|
| 2247 | + for ($j = 0; $j < 8; $j++) { |
|
| 2248 | 2248 | $v = $v << 1; |
| 2249 | 2249 | $v |= $bstream[$p]; |
| 2250 | 2250 | $p++; |
@@ -2253,7 +2253,7 @@ discard block |
||
| 2253 | 2253 | } |
| 2254 | 2254 | if ($size & 7) { |
| 2255 | 2255 | $v = 0; |
| 2256 | - for ($j=0; $j<($size & 7); $j++) { |
|
| 2256 | + for ($j = 0; $j < ($size & 7); $j++) { |
|
| 2257 | 2257 | $v = $v << 1; |
| 2258 | 2258 | $v |= $bstream[$p]; |
| 2259 | 2259 | $p++; |
@@ -2276,8 +2276,8 @@ discard block |
||
| 2276 | 2276 | * @param int $replLen length of the repl string |
| 2277 | 2277 | * @return array srctab |
| 2278 | 2278 | */ |
| 2279 | - protected function qrstrset($srctab, $x, $y, $repl, $replLen=false) { |
|
| 2280 | - $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); |
|
| 2279 | + protected function qrstrset($srctab, $x, $y, $repl, $replLen = false) { |
|
| 2280 | + $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false) ? substr($repl, 0, $replLen) : $repl, $x, ($replLen !== false) ? $replLen : strlen($repl)); |
|
| 2281 | 2281 | return $srctab; |
| 2282 | 2282 | } |
| 2283 | 2283 | |
@@ -2297,7 +2297,7 @@ discard block |
||
| 2297 | 2297 | * @param int $level error correction level |
| 2298 | 2298 | * @return int ECC size (bytes) |
| 2299 | 2299 | */ |
| 2300 | - protected function getECCLength($version, $level){ |
|
| 2300 | + protected function getECCLength($version, $level) { |
|
| 2301 | 2301 | return $this->capacity[$version][QRCAP_EC][$level]; |
| 2302 | 2302 | } |
| 2303 | 2303 | |
@@ -2326,8 +2326,8 @@ discard block |
||
| 2326 | 2326 | * @return int version number |
| 2327 | 2327 | */ |
| 2328 | 2328 | protected function getMinimumVersion($size, $level) { |
| 2329 | - for ($i=1; $i <= QRSPEC_VERSION_MAX; ++$i) { |
|
| 2330 | - $words = $this->capacity[$i][QRCAP_WORDS] - $this->capacity[$i][QRCAP_EC][$level]; |
|
| 2329 | + for ($i = 1; $i <= QRSPEC_VERSION_MAX; ++$i) { |
|
| 2330 | + $words = $this->capacity[$i][QRCAP_WORDS] - $this->capacity[$i][QRCAP_EC][$level]; |
|
| 2331 | 2331 | if ($words >= $size) { |
| 2332 | 2332 | return $i; |
| 2333 | 2333 | } |
@@ -2404,7 +2404,7 @@ discard block |
||
| 2404 | 2404 | } else { |
| 2405 | 2405 | $spec[0] = $b1; |
| 2406 | 2406 | $spec[1] = (int)($data / ($b1 + $b2)); |
| 2407 | - $spec[2] = (int)($ecc / ($b1 + $b2)); |
|
| 2407 | + $spec[2] = (int)($ecc / ($b1 + $b2)); |
|
| 2408 | 2408 | $spec[3] = $b2; |
| 2409 | 2409 | $spec[4] = $spec[1] + 1; |
| 2410 | 2410 | } |
@@ -2429,8 +2429,8 @@ discard block |
||
| 2429 | 2429 | ); |
| 2430 | 2430 | $yStart = $oy - 2; |
| 2431 | 2431 | $xStart = $ox - 2; |
| 2432 | - for ($y=0; $y < 5; $y++) { |
|
| 2433 | - $frame = $this->qrstrset($frame, $xStart, $yStart+$y, $finder[$y]); |
|
| 2432 | + for ($y = 0; $y < 5; $y++) { |
|
| 2433 | + $frame = $this->qrstrset($frame, $xStart, $yStart + $y, $finder[$y]); |
|
| 2434 | 2434 | } |
| 2435 | 2435 | return $frame; |
| 2436 | 2436 | } |
@@ -2460,15 +2460,15 @@ discard block |
||
| 2460 | 2460 | } |
| 2461 | 2461 | $cx = $this->alignmentPattern[$version][0]; |
| 2462 | 2462 | $wo = $w - 1; |
| 2463 | - for ($x=1; $x < $wo; ++$x) { |
|
| 2463 | + for ($x = 1; $x < $wo; ++$x) { |
|
| 2464 | 2464 | $frame = $this->putAlignmentMarker($frame, 6, $cx); |
| 2465 | - $frame = $this->putAlignmentMarker($frame, $cx, 6); |
|
| 2465 | + $frame = $this->putAlignmentMarker($frame, $cx, 6); |
|
| 2466 | 2466 | $cx += $d; |
| 2467 | 2467 | } |
| 2468 | 2468 | $cy = $this->alignmentPattern[$version][0]; |
| 2469 | - for ($y=0; $y < $wo; ++$y) { |
|
| 2469 | + for ($y = 0; $y < $wo; ++$y) { |
|
| 2470 | 2470 | $cx = $this->alignmentPattern[$version][0]; |
| 2471 | - for ($x=0; $x < $wo; ++$x) { |
|
| 2471 | + for ($x = 0; $x < $wo; ++$x) { |
|
| 2472 | 2472 | $frame = $this->putAlignmentMarker($frame, $cx, $cy); |
| 2473 | 2473 | $cx += $d; |
| 2474 | 2474 | } |
@@ -2523,7 +2523,7 @@ discard block |
||
| 2523 | 2523 | "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", |
| 2524 | 2524 | "\xc1\xc1\xc1\xc1\xc1\xc1\xc1" |
| 2525 | 2525 | ); |
| 2526 | - for ($y=0; $y < 7; $y++) { |
|
| 2526 | + for ($y = 0; $y < 7; $y++) { |
|
| 2527 | 2527 | $frame = $this->qrstrset($frame, $ox, ($oy + $y), $finder[$y]); |
| 2528 | 2528 | } |
| 2529 | 2529 | return $frame; |
@@ -2536,7 +2536,7 @@ discard block |
||
| 2536 | 2536 | */ |
| 2537 | 2537 | protected function createFrame($version) { |
| 2538 | 2538 | $width = $this->capacity[$version][QRCAP_WIDTH]; |
| 2539 | - $frameLine = str_repeat ("\0", $width); |
|
| 2539 | + $frameLine = str_repeat("\0", $width); |
|
| 2540 | 2540 | $frame = array_fill(0, $width, $frameLine); |
| 2541 | 2541 | // Finder pattern |
| 2542 | 2542 | $frame = $this->putFinderPattern($frame, 0, 0); |
@@ -2544,7 +2544,7 @@ discard block |
||
| 2544 | 2544 | $frame = $this->putFinderPattern($frame, 0, $width - 7); |
| 2545 | 2545 | // Separator |
| 2546 | 2546 | $yOffset = $width - 7; |
| 2547 | - for ($y=0; $y < 7; ++$y) { |
|
| 2547 | + for ($y = 0; $y < 7; ++$y) { |
|
| 2548 | 2548 | $frame[$y][7] = "\xc0"; |
| 2549 | 2549 | $frame[$y][$width - 8] = "\xc0"; |
| 2550 | 2550 | $frame[$yOffset][7] = "\xc0"; |
@@ -2552,22 +2552,22 @@ discard block |
||
| 2552 | 2552 | } |
| 2553 | 2553 | $setPattern = str_repeat("\xc0", 8); |
| 2554 | 2554 | $frame = $this->qrstrset($frame, 0, 7, $setPattern); |
| 2555 | - $frame = $this->qrstrset($frame, $width-8, 7, $setPattern); |
|
| 2555 | + $frame = $this->qrstrset($frame, $width - 8, 7, $setPattern); |
|
| 2556 | 2556 | $frame = $this->qrstrset($frame, 0, $width - 8, $setPattern); |
| 2557 | 2557 | // Format info |
| 2558 | 2558 | $setPattern = str_repeat("\x84", 9); |
| 2559 | 2559 | $frame = $this->qrstrset($frame, 0, 8, $setPattern); |
| 2560 | 2560 | $frame = $this->qrstrset($frame, $width - 8, 8, $setPattern, 8); |
| 2561 | 2561 | $yOffset = $width - 8; |
| 2562 | - for ($y=0; $y < 8; ++$y,++$yOffset) { |
|
| 2562 | + for ($y = 0; $y < 8; ++$y, ++$yOffset) { |
|
| 2563 | 2563 | $frame[$y][8] = "\x84"; |
| 2564 | 2564 | $frame[$yOffset][8] = "\x84"; |
| 2565 | 2565 | } |
| 2566 | 2566 | // Timing pattern |
| 2567 | 2567 | $wo = $width - 15; |
| 2568 | - for ($i=1; $i < $wo; ++$i) { |
|
| 2569 | - $frame[6][7+$i] = chr(0x90 | ($i & 1)); |
|
| 2570 | - $frame[7+$i][6] = chr(0x90 | ($i & 1)); |
|
| 2568 | + for ($i = 1; $i < $wo; ++$i) { |
|
| 2569 | + $frame[6][7 + $i] = chr(0x90 | ($i & 1)); |
|
| 2570 | + $frame[7 + $i][6] = chr(0x90 | ($i & 1)); |
|
| 2571 | 2571 | } |
| 2572 | 2572 | // Alignment pattern |
| 2573 | 2573 | $frame = $this->putAlignmentPattern($version, $frame, $width); |
@@ -2575,16 +2575,16 @@ discard block |
||
| 2575 | 2575 | if ($version >= 7) { |
| 2576 | 2576 | $vinf = $this->getVersionPattern($version); |
| 2577 | 2577 | $v = $vinf; |
| 2578 | - for ($x=0; $x<6; ++$x) { |
|
| 2579 | - for ($y=0; $y<3; ++$y) { |
|
| 2580 | - $frame[($width - 11)+$y][$x] = chr(0x88 | ($v & 1)); |
|
| 2578 | + for ($x = 0; $x < 6; ++$x) { |
|
| 2579 | + for ($y = 0; $y < 3; ++$y) { |
|
| 2580 | + $frame[($width - 11) + $y][$x] = chr(0x88 | ($v & 1)); |
|
| 2581 | 2581 | $v = $v >> 1; |
| 2582 | 2582 | } |
| 2583 | 2583 | } |
| 2584 | 2584 | $v = $vinf; |
| 2585 | - for ($y=0; $y<6; ++$y) { |
|
| 2586 | - for ($x=0; $x<3; ++$x) { |
|
| 2587 | - $frame[$y][$x+($width - 11)] = chr(0x88 | ($v & 1)); |
|
| 2585 | + for ($y = 0; $y < 6; ++$y) { |
|
| 2586 | + for ($x = 0; $x < 3; ++$x) { |
|
| 2587 | + $frame[$y][$x + ($width - 11)] = chr(0x88 | ($v & 1)); |
|
| 2588 | 2588 | $v = $v >> 1; |
| 2589 | 2589 | } |
| 2590 | 2590 | } |
@@ -2603,7 +2603,7 @@ discard block |
||
| 2603 | 2603 | if (($version < 1) OR ($version > QRSPEC_VERSION_MAX)) { |
| 2604 | 2604 | return NULL; |
| 2605 | 2605 | } |
| 2606 | - if (!isset($this->frames[$version])) { |
|
| 2606 | + if ( ! isset($this->frames[$version])) { |
|
| 2607 | 2607 | $this->frames[$version] = $this->createFrame($version); |
| 2608 | 2608 | } |
| 2609 | 2609 | if (is_null($this->frames[$version])) { |
@@ -2755,16 +2755,16 @@ discard block |
||
| 2755 | 2755 | if (($symsize < 0) OR ($symsize > 8)) { |
| 2756 | 2756 | return $rs; |
| 2757 | 2757 | } |
| 2758 | - if (($fcr < 0) OR ($fcr >= (1<<$symsize))) { |
|
| 2758 | + if (($fcr < 0) OR ($fcr >= (1 << $symsize))) { |
|
| 2759 | 2759 | return $rs; |
| 2760 | 2760 | } |
| 2761 | - if (($prim <= 0) OR ($prim >= (1<<$symsize))) { |
|
| 2761 | + if (($prim <= 0) OR ($prim >= (1 << $symsize))) { |
|
| 2762 | 2762 | return $rs; |
| 2763 | 2763 | } |
| 2764 | - if (($nroots < 0) OR ($nroots >= (1<<$symsize))) { |
|
| 2764 | + if (($nroots < 0) OR ($nroots >= (1 << $symsize))) { |
|
| 2765 | 2765 | return $rs; |
| 2766 | 2766 | } |
| 2767 | - if (($pad < 0) OR ($pad >= ((1<<$symsize) -1 - $nroots))) { |
|
| 2767 | + if (($pad < 0) OR ($pad >= ((1 << $symsize) - 1 - $nroots))) { |
|
| 2768 | 2768 | return $rs; |
| 2769 | 2769 | } |
| 2770 | 2770 | $rs = array(); |
@@ -2774,13 +2774,13 @@ discard block |
||
| 2774 | 2774 | $rs['alpha_to'] = array_fill(0, ($rs['nn'] + 1), 0); |
| 2775 | 2775 | $rs['index_of'] = array_fill(0, ($rs['nn'] + 1), 0); |
| 2776 | 2776 | // PHP style macro replacement ;) |
| 2777 | - $NN =& $rs['nn']; |
|
| 2778 | - $A0 =& $NN; |
|
| 2777 | + $NN = & $rs['nn']; |
|
| 2778 | + $A0 = & $NN; |
|
| 2779 | 2779 | // Generate Galois field lookup tables |
| 2780 | 2780 | $rs['index_of'][0] = $A0; // log(zero) = -inf |
| 2781 | 2781 | $rs['alpha_to'][$A0] = 0; // alpha**-inf = 0 |
| 2782 | 2782 | $sr = 1; |
| 2783 | - for ($i=0; $i<$rs['nn']; ++$i) { |
|
| 2783 | + for ($i = 0; $i < $rs['nn']; ++$i) { |
|
| 2784 | 2784 | $rs['index_of'][$sr] = $i; |
| 2785 | 2785 | $rs['alpha_to'][$i] = $sr; |
| 2786 | 2786 | $sr <<= 1; |
@@ -2800,21 +2800,21 @@ discard block |
||
| 2800 | 2800 | $rs['nroots'] = $nroots; |
| 2801 | 2801 | $rs['gfpoly'] = $gfpoly; |
| 2802 | 2802 | // Find prim-th root of 1, used in decoding |
| 2803 | - for ($iprim=1; ($iprim % $prim) != 0; $iprim += $rs['nn']) { |
|
| 2803 | + for ($iprim = 1; ($iprim % $prim) != 0; $iprim += $rs['nn']) { |
|
| 2804 | 2804 | ; // intentional empty-body loop! |
| 2805 | 2805 | } |
| 2806 | 2806 | $rs['iprim'] = (int)($iprim / $prim); |
| 2807 | 2807 | $rs['genpoly'][0] = 1; |
| 2808 | 2808 | |
| 2809 | 2809 | |
| 2810 | - for ($i = 0,$root=$fcr*$prim; $i < $nroots; $i++, $root += $prim) { |
|
| 2811 | - $rs['genpoly'][$i+1] = 1; |
|
| 2810 | + for ($i = 0, $root = $fcr * $prim; $i < $nroots; $i++, $root += $prim) { |
|
| 2811 | + $rs['genpoly'][$i + 1] = 1; |
|
| 2812 | 2812 | // Multiply rs->genpoly[] by @**(root + x) |
| 2813 | 2813 | for ($j = $i; $j > 0; --$j) { |
| 2814 | 2814 | if ($rs['genpoly'][$j] != 0) { |
| 2815 | - $rs['genpoly'][$j] = $rs['genpoly'][$j-1] ^ $rs['alpha_to'][$this->modnn($rs, $rs['index_of'][$rs['genpoly'][$j]] + $root)]; |
|
| 2815 | + $rs['genpoly'][$j] = $rs['genpoly'][$j - 1] ^ $rs['alpha_to'][$this->modnn($rs, $rs['index_of'][$rs['genpoly'][$j]] + $root)]; |
|
| 2816 | 2816 | } else { |
| 2817 | - $rs['genpoly'][$j] = $rs['genpoly'][$j-1]; |
|
| 2817 | + $rs['genpoly'][$j] = $rs['genpoly'][$j - 1]; |
|
| 2818 | 2818 | } |
| 2819 | 2819 | } |
| 2820 | 2820 | // rs->genpoly[0] can never be zero |
@@ -2835,26 +2835,26 @@ discard block |
||
| 2835 | 2835 | * @return parity array |
| 2836 | 2836 | */ |
| 2837 | 2837 | protected function encode_rs_char($rs, $data, $parity) { |
| 2838 | - $MM =& $rs['mm']; // bits per symbol |
|
| 2839 | - $NN =& $rs['nn']; // the total number of symbols in a RS block |
|
| 2840 | - $ALPHA_TO =& $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form |
|
| 2841 | - $INDEX_OF =& $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form |
|
| 2842 | - $GENPOLY =& $rs['genpoly']; // an array of NROOTS+1 elements containing the generator polynomial in index form |
|
| 2843 | - $NROOTS =& $rs['nroots']; // the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block |
|
| 2844 | - $FCR =& $rs['fcr']; // first consecutive root, index form |
|
| 2845 | - $PRIM =& $rs['prim']; // primitive element, index form |
|
| 2846 | - $IPRIM =& $rs['iprim']; // prim-th root of 1, index form |
|
| 2847 | - $PAD =& $rs['pad']; // the number of pad symbols in a block |
|
| 2848 | - $A0 =& $NN; |
|
| 2838 | + $MM = & $rs['mm']; // bits per symbol |
|
| 2839 | + $NN = & $rs['nn']; // the total number of symbols in a RS block |
|
| 2840 | + $ALPHA_TO = & $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form |
|
| 2841 | + $INDEX_OF = & $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form |
|
| 2842 | + $GENPOLY = & $rs['genpoly']; // an array of NROOTS+1 elements containing the generator polynomial in index form |
|
| 2843 | + $NROOTS = & $rs['nroots']; // the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block |
|
| 2844 | + $FCR = & $rs['fcr']; // first consecutive root, index form |
|
| 2845 | + $PRIM = & $rs['prim']; // primitive element, index form |
|
| 2846 | + $IPRIM = & $rs['iprim']; // prim-th root of 1, index form |
|
| 2847 | + $PAD = & $rs['pad']; // the number of pad symbols in a block |
|
| 2848 | + $A0 = & $NN; |
|
| 2849 | 2849 | $parity = array_fill(0, $NROOTS, 0); |
| 2850 | - for ($i=0; $i < ($NN - $NROOTS - $PAD); $i++) { |
|
| 2850 | + for ($i = 0; $i < ($NN - $NROOTS - $PAD); $i++) { |
|
| 2851 | 2851 | $feedback = $INDEX_OF[$data[$i] ^ $parity[0]]; |
| 2852 | 2852 | if ($feedback != $A0) { |
| 2853 | 2853 | // feedback term is non-zero |
| 2854 | 2854 | // This line is unnecessary when GENPOLY[NROOTS] is unity, as it must |
| 2855 | 2855 | // always be for the polynomials constructed by init_rs() |
| 2856 | 2856 | $feedback = $this->modnn($rs, $NN - $GENPOLY[$NROOTS] + $feedback); |
| 2857 | - for ($j=1; $j < $NROOTS; ++$j) { |
|
| 2857 | + for ($j = 1; $j < $NROOTS; ++$j) { |
|
| 2858 | 2858 | $parity[$j] ^= $ALPHA_TO[$this->modnn($rs, $feedback + $GENPOLY[($NROOTS - $j)])]; |
| 2859 | 2859 | } |
| 2860 | 2860 | } |
@@ -117,11 +117,11 @@ discard block |
||
| 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='en', $unicode=true, $encoding='UTF-8', $marges = array(5, 5, 5, 8)) |
@@ -282,7 +282,6 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | { |
@@ -1857,7 +1857,7 @@ discard block |
||
| 1857 | 1857 | * draw a curve (for border radius) |
| 1858 | 1858 | * |
| 1859 | 1859 | * @access protected |
| 1860 | - * @param array $pt |
|
| 1860 | + * @param double[] $pt |
|
| 1861 | 1861 | * @param array $color |
| 1862 | 1862 | */ |
| 1863 | 1863 | protected function _drawCurve($pt, $color) |
@@ -3238,7 +3238,7 @@ discard block |
||
| 3238 | 3238 | * this is not a real TAG, it is just to write texts |
| 3239 | 3239 | * |
| 3240 | 3240 | * @param array $param |
| 3241 | - * @return boolean |
|
| 3241 | + * @return null|boolean |
|
| 3242 | 3242 | */ |
| 3243 | 3243 | protected function _tag_open_WRITE($param) |
| 3244 | 3244 | { |
@@ -4202,7 +4202,6 @@ discard block |
||
| 4202 | 4202 | * mode : OPEN |
| 4203 | 4203 | * |
| 4204 | 4204 | * @param array $param |
| 4205 | - * @param string $other |
|
| 4206 | 4205 | * @return boolean |
| 4207 | 4206 | */ |
| 4208 | 4207 | protected function _tag_open_CODE($param) |
@@ -5080,7 +5079,7 @@ discard block |
||
| 5080 | 5079 | * mode : OPEN |
| 5081 | 5080 | * |
| 5082 | 5081 | * @param array $param |
| 5083 | - * @return boolean |
|
| 5082 | + * @return boolean|null |
|
| 5084 | 5083 | */ |
| 5085 | 5084 | protected function _tag_open_COL($param) |
| 5086 | 5085 | { |
@@ -5697,7 +5696,6 @@ discard block |
||
| 5697 | 5696 | * tag : SELECT |
| 5698 | 5697 | * mode : CLOSE |
| 5699 | 5698 | * |
| 5700 | - * @param array $param |
|
| 5701 | 5699 | * @return boolean |
| 5702 | 5700 | */ |
| 5703 | 5701 | protected function _tag_close_SELECT() |
@@ -5801,7 +5799,6 @@ discard block |
||
| 5801 | 5799 | * tag : TEXTAREA |
| 5802 | 5800 | * mode : CLOSE |
| 5803 | 5801 | * |
| 5804 | - * @param array $param |
|
| 5805 | 5802 | * @return boolean |
| 5806 | 5803 | */ |
| 5807 | 5804 | protected function _tag_close_TEXTAREA() |
@@ -6111,7 +6108,7 @@ discard block |
||
| 6111 | 6108 | * mode : OPEN |
| 6112 | 6109 | * |
| 6113 | 6110 | * @param array $param |
| 6114 | - * @return boolean |
|
| 6111 | + * @return boolean|null |
|
| 6115 | 6112 | */ |
| 6116 | 6113 | protected function _tag_open_LINE($param) |
| 6117 | 6114 | { |
@@ -6138,7 +6135,7 @@ discard block |
||
| 6138 | 6135 | * mode : OPEN |
| 6139 | 6136 | * |
| 6140 | 6137 | * @param array $param |
| 6141 | - * @return boolean |
|
| 6138 | + * @return boolean|null |
|
| 6142 | 6139 | */ |
| 6143 | 6140 | protected function _tag_open_RECT($param) |
| 6144 | 6141 | { |
@@ -6165,7 +6162,7 @@ discard block |
||
| 6165 | 6162 | * mode : OPEN |
| 6166 | 6163 | * |
| 6167 | 6164 | * @param array $param |
| 6168 | - * @return boolean |
|
| 6165 | + * @return boolean|null |
|
| 6169 | 6166 | */ |
| 6170 | 6167 | protected function _tag_open_CIRCLE($param) |
| 6171 | 6168 | { |
@@ -6190,7 +6187,7 @@ discard block |
||
| 6190 | 6187 | * mode : OPEN |
| 6191 | 6188 | * |
| 6192 | 6189 | * @param array $param |
| 6193 | - * @return boolean |
|
| 6190 | + * @return boolean|null |
|
| 6194 | 6191 | */ |
| 6195 | 6192 | protected function _tag_open_ELLIPSE($param) |
| 6196 | 6193 | { |
@@ -6217,7 +6214,7 @@ discard block |
||
| 6217 | 6214 | * mode : OPEN |
| 6218 | 6215 | * |
| 6219 | 6216 | * @param array $param |
| 6220 | - * @return boolean |
|
| 6217 | + * @return boolean|null |
|
| 6221 | 6218 | */ |
| 6222 | 6219 | protected function _tag_open_POLYLINE($param) |
| 6223 | 6220 | { |
@@ -6263,7 +6260,7 @@ discard block |
||
| 6263 | 6260 | * mode : OPEN |
| 6264 | 6261 | * |
| 6265 | 6262 | * @param array $param |
| 6266 | - * @return boolean |
|
| 6263 | + * @return boolean|null |
|
| 6267 | 6264 | */ |
| 6268 | 6265 | protected function _tag_open_POLYGON($param) |
| 6269 | 6266 | { |
@@ -6310,7 +6307,7 @@ discard block |
||
| 6310 | 6307 | * mode : OPEN |
| 6311 | 6308 | * |
| 6312 | 6309 | * @param array $param |
| 6313 | - * @return boolean |
|
| 6310 | + * @return boolean|null |
|
| 6314 | 6311 | */ |
| 6315 | 6312 | protected function _tag_open_PATH($param) |
| 6316 | 6313 | { |
@@ -6439,7 +6436,7 @@ discard block |
||
| 6439 | 6436 | * mode : OPEN |
| 6440 | 6437 | * |
| 6441 | 6438 | * @param array $param |
| 6442 | - * @return boolean |
|
| 6439 | + * @return boolean|null |
|
| 6443 | 6440 | */ |
| 6444 | 6441 | protected function _tag_open_G($param) |
| 6445 | 6442 | { |
@@ -6456,7 +6453,7 @@ discard block |
||
| 6456 | 6453 | * mode : CLOSE |
| 6457 | 6454 | * |
| 6458 | 6455 | * @param array $param |
| 6459 | - * @return boolean |
|
| 6456 | + * @return boolean|null |
|
| 6460 | 6457 | */ |
| 6461 | 6458 | protected function _tag_close_G($param) |
| 6462 | 6459 | { |
@@ -11,485 +11,484 @@ discard block |
||
| 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('_class/exception.class.php'); |
|
| 18 | - require_once('_class/locale.class.php'); |
|
| 19 | - require_once('_class/myPdf.class.php'); |
|
| 20 | - require_once('_class/parsingHtml.class.php'); |
|
| 21 | - require_once('_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='en', $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('_class/exception.class.php'); |
|
| 18 | + require_once('_class/locale.class.php'); |
|
| 19 | + require_once('_class/myPdf.class.php'); |
|
| 20 | + require_once('_class/parsingHtml.class.php'); |
|
| 21 | + require_once('_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='en', $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,5991 +498,5991 @@ discard block |
||
| 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 | - |
|
| 1314 | - $infos=@getimagesize($src); |
|
| 1315 | - |
|
| 1316 | - // if the image does not exist, or can not be loaded |
|
| 1317 | - if (count($infos)<2) { |
|
| 1318 | - // if the test is activ => exception |
|
| 1319 | - if ($this->_testIsImage) { |
|
| 1320 | - throw new HTML2PDF_exception(6, $src); |
|
| 1321 | - } |
|
| 1322 | - |
|
| 1323 | - // else, display a gray rectangle |
|
| 1324 | - $src = null; |
|
| 1325 | - $infos = array(16, 16); |
|
| 1326 | - } |
|
| 1327 | - |
|
| 1328 | - // convert the size of the image in the unit of the PDF |
|
| 1329 | - $imageWidth = $infos[0]/$this->pdf->getK(); |
|
| 1330 | - $imageHeight = $infos[1]/$this->pdf->getK(); |
|
| 1331 | - |
|
| 1332 | - // calculate the size from the css style |
|
| 1333 | - if ($this->parsingCss->value['width'] && $this->parsingCss->value['height']) { |
|
| 1334 | - $w = $this->parsingCss->value['width']; |
|
| 1335 | - $h = $this->parsingCss->value['height']; |
|
| 1336 | - } else if ($this->parsingCss->value['width']) { |
|
| 1337 | - $w = $this->parsingCss->value['width']; |
|
| 1338 | - $h = $imageHeight*$w/$imageWidth; |
|
| 1339 | - } else if ($this->parsingCss->value['height']) { |
|
| 1340 | - $h = $this->parsingCss->value['height']; |
|
| 1341 | - $w = $imageWidth*$h/$imageHeight; |
|
| 1342 | - } else { |
|
| 1343 | - // convert px to pt |
|
| 1344 | - $w = 72./96.*$imageWidth; |
|
| 1345 | - $h = 72./96.*$imageHeight; |
|
| 1346 | - } |
|
| 1347 | - |
|
| 1348 | - // are we in a float |
|
| 1349 | - $float = $this->parsingCss->getFloat(); |
|
| 1350 | - |
|
| 1351 | - // if we are in a float, but if something else if on the line => Break Line |
|
| 1352 | - if ($float && $this->_maxH) { |
|
| 1353 | - // make the break line (false if we are in "_isForOneLine" mode) |
|
| 1354 | - if (!$this->_tag_open_BR(array())) { |
|
| 1355 | - return false; |
|
| 1356 | - } |
|
| 1357 | - } |
|
| 1358 | - |
|
| 1359 | - // position of the image |
|
| 1360 | - $x = $this->pdf->getX(); |
|
| 1361 | - $y = $this->pdf->getY(); |
|
| 1362 | - |
|
| 1363 | - // if the image can not be put on the current line => new line |
|
| 1364 | - if (!$float && ($x + $w>$this->pdf->getW() - $this->pdf->getrMargin()) && $this->_maxH) { |
|
| 1365 | - if ($this->_isForOneLine) { |
|
| 1366 | - return false; |
|
| 1367 | - } |
|
| 1368 | - |
|
| 1369 | - // set the new line |
|
| 1370 | - $hnl = max($this->_maxH, $this->parsingCss->getLineHeight()); |
|
| 1371 | - $this->_setNewLine($hnl); |
|
| 1372 | - |
|
| 1373 | - // get the new position |
|
| 1374 | - $x = $this->pdf->getX(); |
|
| 1375 | - $y = $this->pdf->getY(); |
|
| 1376 | - } |
|
| 1377 | - |
|
| 1378 | - // if the image can not be put on the current page |
|
| 1379 | - if (($y + $h>$this->pdf->getH() - $this->pdf->getbMargin()) && !$this->_isInOverflow) { |
|
| 1380 | - // new page |
|
| 1381 | - $this->_setNewPage(); |
|
| 1382 | - |
|
| 1383 | - // get the new position |
|
| 1384 | - $x = $this->pdf->getX(); |
|
| 1385 | - $y = $this->pdf->getY(); |
|
| 1386 | - } |
|
| 1387 | - |
|
| 1388 | - // correction for display the image of a list |
|
| 1389 | - $hT = 0.80*$this->parsingCss->value['font-size']; |
|
| 1390 | - if ($subLi && $h<$hT) { |
|
| 1391 | - $y+=($hT-$h); |
|
| 1392 | - } |
|
| 1393 | - |
|
| 1394 | - // add the margin top |
|
| 1395 | - $yc = $y-$this->parsingCss->value['margin']['t']; |
|
| 1396 | - |
|
| 1397 | - // get the width and the position of the parent |
|
| 1398 | - $old = $this->parsingCss->getOldValues(); |
|
| 1399 | - if ( $old['width']) { |
|
| 1400 | - $parentWidth = $old['width']; |
|
| 1401 | - $parentX = $x; |
|
| 1402 | - } else { |
|
| 1403 | - $parentWidth = $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 1404 | - $parentX = $this->pdf->getlMargin(); |
|
| 1405 | - } |
|
| 1406 | - |
|
| 1407 | - // if we are in a gloat => adapt the parent position and width |
|
| 1408 | - if ($float) { |
|
| 1409 | - list($lx, $rx) = $this->_getMargins($yc); |
|
| 1410 | - $parentX = $lx; |
|
| 1411 | - $parentWidth = $rx-$lx; |
|
| 1412 | - } |
|
| 1413 | - |
|
| 1414 | - // calculate the position of the image, if align to the right |
|
| 1415 | - if ($parentWidth>$w && $float!='left') { |
|
| 1416 | - if ($float=='right' || $this->parsingCss->value['text-align']=='li_right') $x = $parentX + $parentWidth - $w-$this->parsingCss->value['margin']['r']-$this->parsingCss->value['margin']['l']; |
|
| 1417 | - } |
|
| 1418 | - |
|
| 1419 | - // display the image |
|
| 1420 | - if (!$this->_subPart && !$this->_isSubPart) { |
|
| 1421 | - if ($src) { |
|
| 1422 | - $this->pdf->Image($src, $x, $y, $w, $h, '', $this->_isInLink); |
|
| 1423 | - } else { |
|
| 1424 | - // rectangle if the image can not be loaded |
|
| 1425 | - $this->pdf->setFillColorArray(array(240, 220, 220)); |
|
| 1426 | - $this->pdf->Rect($x, $y, $w, $h, 'F'); |
|
| 1427 | - } |
|
| 1428 | - } |
|
| 1429 | - |
|
| 1430 | - // apply the margins |
|
| 1431 | - $x-= $this->parsingCss->value['margin']['l']; |
|
| 1432 | - $y-= $this->parsingCss->value['margin']['t']; |
|
| 1433 | - $w+= $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['margin']['r']; |
|
| 1434 | - $h+= $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['margin']['b']; |
|
| 1435 | - |
|
| 1436 | - if ($float=='left') { |
|
| 1437 | - // save the current max |
|
| 1438 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 1439 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 1440 | - |
|
| 1441 | - // add the image to the margins |
|
| 1442 | - $this->_addMargins($float, $x, $y, $x+$w, $y+$h); |
|
| 1443 | - |
|
| 1444 | - // get the new position |
|
| 1445 | - list($lx, $rx) = $this->_getMargins($yc); |
|
| 1446 | - $this->pdf->setXY($lx, $yc); |
|
| 1447 | - } else if ($float=='right') { |
|
| 1448 | - // save the current max. We don't save the X because it is not the real max of the line |
|
| 1449 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 1450 | - |
|
| 1451 | - // add the image to the margins |
|
| 1452 | - $this->_addMargins($float, $x, $y, $x+$w, $y+$h); |
|
| 1453 | - |
|
| 1454 | - // get the new position |
|
| 1455 | - list($lx, $rx) = $this->_getMargins($yc); |
|
| 1456 | - $this->pdf->setXY($lx, $yc); |
|
| 1457 | - } else { |
|
| 1458 | - // set the new position at the end of the image |
|
| 1459 | - $this->pdf->setX($x+$w); |
|
| 1460 | - |
|
| 1461 | - // save the current max |
|
| 1462 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 1463 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 1464 | - $this->_maxH = max($this->_maxH, $h); |
|
| 1465 | - } |
|
| 1466 | - |
|
| 1467 | - return true; |
|
| 1468 | - } |
|
| 1469 | - |
|
| 1470 | - /** |
|
| 1471 | - * draw a rectangle |
|
| 1472 | - * |
|
| 1473 | - * @access protected |
|
| 1474 | - * @param float $x |
|
| 1475 | - * @param float $y |
|
| 1476 | - * @param float $w |
|
| 1477 | - * @param float $h |
|
| 1478 | - * @param array $border |
|
| 1479 | - * @param float $padding - internal marge of the rectanble => not used, but... |
|
| 1480 | - * @param float $margin - external marge of the rectanble |
|
| 1481 | - * @param array $background |
|
| 1482 | - * @return boolean |
|
| 1483 | - */ |
|
| 1484 | - protected function _drawRectangle($x, $y, $w, $h, $border, $padding, $margin, $background) |
|
| 1485 | - { |
|
| 1486 | - // if we are in a subpart or if height is null => return false |
|
| 1487 | - if ($this->_subPart || $this->_isSubPart || $h===null) return false; |
|
| 1488 | - |
|
| 1489 | - // add the margin |
|
| 1490 | - $x+= $margin; |
|
| 1491 | - $y+= $margin; |
|
| 1492 | - $w-= $margin*2; |
|
| 1493 | - $h-= $margin*2; |
|
| 1494 | - |
|
| 1495 | - // get the radius of the border |
|
| 1496 | - $outTL = $border['radius']['tl']; |
|
| 1497 | - $outTR = $border['radius']['tr']; |
|
| 1498 | - $outBR = $border['radius']['br']; |
|
| 1499 | - $outBL = $border['radius']['bl']; |
|
| 1500 | - |
|
| 1501 | - // prepare the out radius |
|
| 1502 | - $outTL = ($outTL[0] && $outTL[1]) ? $outTL : null; |
|
| 1503 | - $outTR = ($outTR[0] && $outTR[1]) ? $outTR : null; |
|
| 1504 | - $outBR = ($outBR[0] && $outBR[1]) ? $outBR : null; |
|
| 1505 | - $outBL = ($outBL[0] && $outBL[1]) ? $outBL : null; |
|
| 1506 | - |
|
| 1507 | - // prepare the in radius |
|
| 1508 | - $inTL = $outTL; |
|
| 1509 | - $inTR = $outTR; |
|
| 1510 | - $inBR = $outBR; |
|
| 1511 | - $inBL = $outBL; |
|
| 1512 | - |
|
| 1513 | - if (is_array($inTL)) { |
|
| 1514 | - $inTL[0]-= $border['l']['width']; |
|
| 1515 | - $inTL[1]-= $border['t']['width']; |
|
| 1516 | - } |
|
| 1517 | - if (is_array($inTR)) { |
|
| 1518 | - $inTR[0]-= $border['r']['width']; |
|
| 1519 | - $inTR[1]-= $border['t']['width']; |
|
| 1520 | - } |
|
| 1521 | - if (is_array($inBR)) { |
|
| 1522 | - $inBR[0]-= $border['r']['width']; |
|
| 1523 | - $inBR[1]-= $border['b']['width']; |
|
| 1524 | - } |
|
| 1525 | - if (is_array($inBL)) { |
|
| 1526 | - $inBL[0]-= $border['l']['width']; |
|
| 1527 | - $inBL[1]-= $border['b']['width']; |
|
| 1528 | - } |
|
| 1529 | - |
|
| 1530 | - if ($inTL[0]<=0 || $inTL[1]<=0) $inTL = null; |
|
| 1531 | - if ($inTR[0]<=0 || $inTR[1]<=0) $inTR = null; |
|
| 1532 | - if ($inBR[0]<=0 || $inBR[1]<=0) $inBR = null; |
|
| 1533 | - if ($inBL[0]<=0 || $inBL[1]<=0) $inBL = null; |
|
| 1534 | - |
|
| 1535 | - // prepare the background color |
|
| 1536 | - $pdfStyle = ''; |
|
| 1537 | - if ($background['color']) { |
|
| 1538 | - $this->pdf->setFillColorArray($background['color']); |
|
| 1539 | - $pdfStyle.= 'F'; |
|
| 1540 | - } |
|
| 1541 | - |
|
| 1542 | - // if we have a background to fill => fill it with a path (because of the radius) |
|
| 1543 | - if ($pdfStyle) { |
|
| 1544 | - $this->pdf->clippingPathStart($x, $y, $w, $h, $outTL, $outTR, $outBL, $outBR); |
|
| 1545 | - $this->pdf->Rect($x, $y, $w, $h, $pdfStyle); |
|
| 1546 | - $this->pdf->clippingPathStop(); |
|
| 1547 | - } |
|
| 1548 | - |
|
| 1549 | - // prepare the background image |
|
| 1550 | - if ($background['image']) { |
|
| 1551 | - $iName = $background['image']; |
|
| 1552 | - $iPosition = $background['position']!==null ? $background['position'] : array(0, 0); |
|
| 1553 | - $iRepeat = $background['repeat']!==null ? $background['repeat'] : array(true, true); |
|
| 1554 | - |
|
| 1555 | - // size of the background without the borders |
|
| 1556 | - $bX = $x; |
|
| 1557 | - $bY = $y; |
|
| 1558 | - $bW = $w; |
|
| 1559 | - $bH = $h; |
|
| 1560 | - |
|
| 1561 | - if ($border['b']['width']) { |
|
| 1562 | - $bH-= $border['b']['width']; |
|
| 1563 | - } |
|
| 1564 | - if ($border['l']['width']) { |
|
| 1565 | - $bW-= $border['l']['width']; |
|
| 1566 | - $bX+= $border['l']['width']; |
|
| 1567 | - } |
|
| 1568 | - if ($border['t']['width']) { |
|
| 1569 | - $bH-= $border['t']['width']; |
|
| 1570 | - $bY+= $border['t']['width']; |
|
| 1571 | - } |
|
| 1572 | - if ($border['r']['width']) { |
|
| 1573 | - $bW-= $border['r']['width']; |
|
| 1574 | - } |
|
| 1575 | - |
|
| 1576 | - // get the size of the image |
|
| 1577 | - // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini |
|
| 1578 | - $imageInfos=@getimagesize($iName); |
|
| 1579 | - |
|
| 1580 | - // if the image can not be loaded |
|
| 1581 | - if (count($imageInfos)<2) { |
|
| 1582 | - if ($this->_testIsImage) { |
|
| 1583 | - throw new HTML2PDF_exception(6, $iName); |
|
| 1584 | - } |
|
| 1585 | - } else { |
|
| 1586 | - // convert the size of the image from pixel to the unit of the PDF |
|
| 1587 | - $imageWidth = 72./96.*$imageInfos[0]/$this->pdf->getK(); |
|
| 1588 | - $imageHeight = 72./96.*$imageInfos[1]/$this->pdf->getK(); |
|
| 1589 | - |
|
| 1590 | - // prepare the position of the backgroung |
|
| 1591 | - if ($iRepeat[0]) $iPosition[0] = $bX; |
|
| 1592 | - else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) $iPosition[0] = $bX + $match[1]*($bW-$imageWidth)/100; |
|
| 1593 | - else $iPosition[0] = $bX+$iPosition[0]; |
|
| 1594 | - |
|
| 1595 | - if ($iRepeat[1]) $iPosition[1] = $bY; |
|
| 1596 | - else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) $iPosition[1] = $bY + $match[1]*($bH-$imageHeight)/100; |
|
| 1597 | - else $iPosition[1] = $bY+$iPosition[1]; |
|
| 1598 | - |
|
| 1599 | - $imageXmin = $bX; |
|
| 1600 | - $imageXmax = $bX+$bW; |
|
| 1601 | - $imageYmin = $bY; |
|
| 1602 | - $imageYmax = $bY+$bH; |
|
| 1603 | - |
|
| 1604 | - if (!$iRepeat[0] && !$iRepeat[1]) { |
|
| 1605 | - $imageXmin = $iPosition[0]; $imageXmax = $iPosition[0]+$imageWidth; |
|
| 1606 | - $imageYmin = $iPosition[1]; $imageYmax = $iPosition[1]+$imageHeight; |
|
| 1607 | - } else if ($iRepeat[0] && !$iRepeat[1]) { |
|
| 1608 | - $imageYmin = $iPosition[1]; $imageYmax = $iPosition[1]+$imageHeight; |
|
| 1609 | - } else if (!$iRepeat[0] && $iRepeat[1]) { |
|
| 1610 | - $imageXmin = $iPosition[0]; $imageXmax = $iPosition[0]+$imageWidth; |
|
| 1611 | - } |
|
| 1612 | - |
|
| 1613 | - // build the path to display the image (because of radius) |
|
| 1614 | - $this->pdf->clippingPathStart($bX, $bY, $bW, $bH, $inTL, $inTR, $inBL, $inBR); |
|
| 1615 | - |
|
| 1616 | - // repeat the image |
|
| 1617 | - for ($iY=$imageYmin; $iY<$imageYmax; $iY+=$imageHeight) { |
|
| 1618 | - for ($iX=$imageXmin; $iX<$imageXmax; $iX+=$imageWidth) { |
|
| 1619 | - $cX = null; |
|
| 1620 | - $cY = null; |
|
| 1621 | - $cW = $imageWidth; |
|
| 1622 | - $cH = $imageHeight; |
|
| 1623 | - if ($imageYmax-$iY<$imageHeight) { |
|
| 1624 | - $cX = $iX; |
|
| 1625 | - $cY = $iY; |
|
| 1626 | - $cH = $imageYmax-$iY; |
|
| 1627 | - } |
|
| 1628 | - if ($imageXmax-$iX<$imageWidth) { |
|
| 1629 | - $cX = $iX; |
|
| 1630 | - $cY = $iY; |
|
| 1631 | - $cW = $imageXmax-$iX; |
|
| 1632 | - } |
|
| 1633 | - |
|
| 1634 | - $this->pdf->Image($iName, $iX, $iY, $imageWidth, $imageHeight, '', ''); |
|
| 1635 | - } |
|
| 1636 | - } |
|
| 1637 | - |
|
| 1638 | - // end of the path |
|
| 1639 | - $this->pdf->clippingPathStop(); |
|
| 1640 | - } |
|
| 1641 | - } |
|
| 1642 | - |
|
| 1643 | - // adding some loose (0.01mm) |
|
| 1644 | - $loose = 0.01; |
|
| 1645 | - $x-= $loose; |
|
| 1646 | - $y-= $loose; |
|
| 1647 | - $w+= 2.*$loose; |
|
| 1648 | - $h+= 2.*$loose; |
|
| 1649 | - if ($border['l']['width']) $border['l']['width']+= 2.*$loose; |
|
| 1650 | - if ($border['t']['width']) $border['t']['width']+= 2.*$loose; |
|
| 1651 | - if ($border['r']['width']) $border['r']['width']+= 2.*$loose; |
|
| 1652 | - if ($border['b']['width']) $border['b']['width']+= 2.*$loose; |
|
| 1653 | - |
|
| 1654 | - // prepare the test on borders |
|
| 1655 | - $testBl = ($border['l']['width'] && $border['l']['color'][0]!==null); |
|
| 1656 | - $testBt = ($border['t']['width'] && $border['t']['color'][0]!==null); |
|
| 1657 | - $testBr = ($border['r']['width'] && $border['r']['color'][0]!==null); |
|
| 1658 | - $testBb = ($border['b']['width'] && $border['b']['color'][0]!==null); |
|
| 1659 | - |
|
| 1660 | - // draw the radius bottom-left |
|
| 1661 | - if (is_array($outBL) && ($testBb || $testBl)) { |
|
| 1662 | - if ($inBL) { |
|
| 1663 | - $courbe = array(); |
|
| 1664 | - $courbe[] = $x+$outBL[0]; $courbe[] = $y+$h; |
|
| 1665 | - $courbe[] = $x; $courbe[] = $y+$h-$outBL[1]; |
|
| 1666 | - $courbe[] = $x+$outBL[0]; $courbe[] = $y+$h-$border['b']['width']; |
|
| 1667 | - $courbe[] = $x+$border['l']['width']; $courbe[] = $y+$h-$outBL[1]; |
|
| 1668 | - $courbe[] = $x+$outBL[0]; $courbe[] = $y+$h-$outBL[1]; |
|
| 1669 | - } else { |
|
| 1670 | - $courbe = array(); |
|
| 1671 | - $courbe[] = $x+$outBL[0]; $courbe[] = $y+$h; |
|
| 1672 | - $courbe[] = $x; $courbe[] = $y+$h-$outBL[1]; |
|
| 1673 | - $courbe[] = $x+$border['l']['width']; $courbe[] = $y+$h-$border['b']['width']; |
|
| 1674 | - $courbe[] = $x+$outBL[0]; $courbe[] = $y+$h-$outBL[1]; |
|
| 1675 | - } |
|
| 1676 | - $this->_drawCurve($courbe, $border['l']['color']); |
|
| 1677 | - } |
|
| 1678 | - |
|
| 1679 | - // draw the radius left-top |
|
| 1680 | - if (is_array($outTL) && ($testBt || $testBl)) { |
|
| 1681 | - if ($inTL) { |
|
| 1682 | - $courbe = array(); |
|
| 1683 | - $courbe[] = $x; $courbe[] = $y+$outTL[1]; |
|
| 1684 | - $courbe[] = $x+$outTL[0]; $courbe[] = $y; |
|
| 1685 | - $courbe[] = $x+$border['l']['width']; $courbe[] = $y+$outTL[1]; |
|
| 1686 | - $courbe[] = $x+$outTL[0]; $courbe[] = $y+$border['t']['width']; |
|
| 1687 | - $courbe[] = $x+$outTL[0]; $courbe[] = $y+$outTL[1]; |
|
| 1688 | - } else { |
|
| 1689 | - $courbe = array(); |
|
| 1690 | - $courbe[] = $x; $courbe[] = $y+$outTL[1]; |
|
| 1691 | - $courbe[] = $x+$outTL[0]; $courbe[] = $y; |
|
| 1692 | - $courbe[] = $x+$border['l']['width']; $courbe[] = $y+$border['t']['width']; |
|
| 1693 | - $courbe[] = $x+$outTL[0]; $courbe[] = $y+$outTL[1]; |
|
| 1694 | - } |
|
| 1695 | - $this->_drawCurve($courbe, $border['t']['color']); |
|
| 1696 | - } |
|
| 1697 | - |
|
| 1698 | - // draw the radius top-right |
|
| 1699 | - if (is_array($outTR) && ($testBt || $testBr)) { |
|
| 1700 | - if ($inTR) { |
|
| 1701 | - $courbe = array(); |
|
| 1702 | - $courbe[] = $x+$w-$outTR[0]; $courbe[] = $y; |
|
| 1703 | - $courbe[] = $x+$w; $courbe[] = $y+$outTR[1]; |
|
| 1704 | - $courbe[] = $x+$w-$outTR[0]; $courbe[] = $y+$border['t']['width']; |
|
| 1705 | - $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$outTR[1]; |
|
| 1706 | - $courbe[] = $x+$w-$outTR[0]; $courbe[] = $y+$outTR[1]; |
|
| 1707 | - } else { |
|
| 1708 | - $courbe = array(); |
|
| 1709 | - $courbe[] = $x+$w-$outTR[0]; $courbe[] = $y; |
|
| 1710 | - $courbe[] = $x+$w; $courbe[] = $y+$outTR[1]; |
|
| 1711 | - $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$border['t']['width']; |
|
| 1712 | - $courbe[] = $x+$w-$outTR[0]; $courbe[] = $y+$outTR[1]; |
|
| 1713 | - } |
|
| 1714 | - $this->_drawCurve($courbe, $border['r']['color']); |
|
| 1715 | - } |
|
| 1716 | - |
|
| 1717 | - // draw the radius right-bottom |
|
| 1718 | - if (is_array($outBR) && ($testBb || $testBr)) { |
|
| 1719 | - if ($inBR) { |
|
| 1720 | - $courbe = array(); |
|
| 1721 | - $courbe[] = $x+$w; $courbe[] = $y+$h-$outBR[1]; |
|
| 1722 | - $courbe[] = $x+$w-$outBR[0]; $courbe[] = $y+$h; |
|
| 1723 | - $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$h-$outBR[1]; |
|
| 1724 | - $courbe[] = $x+$w-$outBR[0]; $courbe[] = $y+$h-$border['b']['width']; |
|
| 1725 | - $courbe[] = $x+$w-$outBR[0]; $courbe[] = $y+$h-$outBR[1]; |
|
| 1726 | - } else { |
|
| 1727 | - $courbe = array(); |
|
| 1728 | - $courbe[] = $x+$w; $courbe[] = $y+$h-$outBR[1]; |
|
| 1729 | - $courbe[] = $x+$w-$outBR[0]; $courbe[] = $y+$h; |
|
| 1730 | - $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$h-$border['b']['width']; |
|
| 1731 | - $courbe[] = $x+$w-$outBR[0]; $courbe[] = $y+$h-$outBR[1]; |
|
| 1732 | - } |
|
| 1733 | - $this->_drawCurve($courbe, $border['b']['color']); |
|
| 1734 | - } |
|
| 1735 | - |
|
| 1736 | - // draw the left border |
|
| 1737 | - if ($testBl) { |
|
| 1738 | - $pt = array(); |
|
| 1739 | - $pt[] = $x; $pt[] = $y+$h; |
|
| 1740 | - $pt[] = $x; $pt[] = $y+$h-$border['b']['width']; |
|
| 1741 | - $pt[] = $x; $pt[] = $y+$border['t']['width']; |
|
| 1742 | - $pt[] = $x; $pt[] = $y; |
|
| 1743 | - $pt[] = $x+$border['l']['width']; $pt[] = $y+$border['t']['width']; |
|
| 1744 | - $pt[] = $x+$border['l']['width']; $pt[] = $y+$h-$border['b']['width']; |
|
| 1745 | - |
|
| 1746 | - $bord = 3; |
|
| 1747 | - if (is_array($outBL)) { |
|
| 1748 | - $bord-=1; |
|
| 1749 | - $pt[3] -= $outBL[1] - $border['b']['width']; |
|
| 1750 | - if ($inBL) $pt[11]-= $inBL[1]; |
|
| 1751 | - unset($pt[0]);unset($pt[1]); |
|
| 1752 | - } |
|
| 1753 | - if (is_array($outTL)) { |
|
| 1754 | - $bord-=2; |
|
| 1755 | - $pt[5] += $outTL[1]-$border['t']['width']; |
|
| 1756 | - if ($inTL) $pt[9] += $inTL[1]; |
|
| 1757 | - unset($pt[6]);unset($pt[7]); |
|
| 1758 | - } |
|
| 1759 | - |
|
| 1760 | - $pt = array_values($pt); |
|
| 1761 | - $this->_drawLine($pt, $border['l']['color'], $border['l']['type'], $border['l']['width'], $bord); |
|
| 1762 | - } |
|
| 1763 | - |
|
| 1764 | - // draw the top border |
|
| 1765 | - if ($testBt) { |
|
| 1766 | - $pt = array(); |
|
| 1767 | - $pt[] = $x; $pt[] = $y; |
|
| 1768 | - $pt[] = $x+$border['l']['width']; $pt[] = $y; |
|
| 1769 | - $pt[] = $x+$w-$border['r']['width']; $pt[] = $y; |
|
| 1770 | - $pt[] = $x+$w; $pt[] = $y; |
|
| 1771 | - $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$border['t']['width']; |
|
| 1772 | - $pt[] = $x+$border['l']['width']; $pt[] = $y+$border['t']['width']; |
|
| 1773 | - |
|
| 1774 | - $bord = 3; |
|
| 1775 | - if (is_array($outTL)) { |
|
| 1776 | - $bord-=1; |
|
| 1777 | - $pt[2] += $outTL[0] - $border['l']['width']; |
|
| 1778 | - if ($inTL) $pt[10]+= $inTL[0]; |
|
| 1779 | - unset($pt[0]);unset($pt[1]); |
|
| 1780 | - } |
|
| 1781 | - if (is_array($outTR)) { |
|
| 1782 | - $bord-=2; |
|
| 1783 | - $pt[4] -= $outTR[0] - $border['r']['width']; |
|
| 1784 | - if ($inTR) $pt[8] -= $inTR[0]; |
|
| 1785 | - unset($pt[6]);unset($pt[7]); |
|
| 1786 | - } |
|
| 1787 | - |
|
| 1788 | - $pt = array_values($pt); |
|
| 1789 | - $this->_drawLine($pt, $border['t']['color'], $border['t']['type'], $border['t']['width'], $bord); |
|
| 1790 | - } |
|
| 1791 | - |
|
| 1792 | - // draw the right border |
|
| 1793 | - if ($testBr) { |
|
| 1794 | - $pt = array(); |
|
| 1795 | - $pt[] = $x+$w; $pt[] = $y; |
|
| 1796 | - $pt[] = $x+$w; $pt[] = $y+$border['t']['width']; |
|
| 1797 | - $pt[] = $x+$w; $pt[] = $y+$h-$border['b']['width']; |
|
| 1798 | - $pt[] = $x+$w; $pt[] = $y+$h; |
|
| 1799 | - $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h-$border['b']['width']; |
|
| 1800 | - $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$border['t']['width']; |
|
| 1801 | - |
|
| 1802 | - $bord = 3; |
|
| 1803 | - if (is_array($outTR)) { |
|
| 1804 | - $bord-=1; |
|
| 1805 | - $pt[3] += $outTR[1] - $border['t']['width']; |
|
| 1806 | - if ($inTR) $pt[11]+= $inTR[1]; |
|
| 1807 | - unset($pt[0]);unset($pt[1]); |
|
| 1808 | - } |
|
| 1809 | - if (is_array($outBR)) { |
|
| 1810 | - $bord-=2; |
|
| 1811 | - $pt[5] -= $outBR[1] - $border['b']['width']; |
|
| 1812 | - if ($inBR) $pt[9] -= $inBR[1]; |
|
| 1813 | - unset($pt[6]);unset($pt[7]); |
|
| 1814 | - } |
|
| 1815 | - |
|
| 1816 | - $pt = array_values($pt); |
|
| 1817 | - $this->_drawLine($pt, $border['r']['color'], $border['r']['type'], $border['r']['width'], $bord); |
|
| 1818 | - } |
|
| 1819 | - |
|
| 1820 | - // draw the bottom border |
|
| 1821 | - if ($testBb) { |
|
| 1822 | - $pt = array(); |
|
| 1823 | - $pt[] = $x+$w; $pt[] = $y+$h; |
|
| 1824 | - $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h; |
|
| 1825 | - $pt[] = $x+$border['l']['width']; $pt[] = $y+$h; |
|
| 1826 | - $pt[] = $x; $pt[] = $y+$h; |
|
| 1827 | - $pt[] = $x+$border['l']['width']; $pt[] = $y+$h-$border['b']['width']; |
|
| 1828 | - $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h-$border['b']['width']; |
|
| 1829 | - |
|
| 1830 | - $bord = 3; |
|
| 1831 | - if (is_array($outBL)) { |
|
| 1832 | - $bord-=2; |
|
| 1833 | - $pt[4] += $outBL[0] - $border['l']['width']; |
|
| 1834 | - if ($inBL) $pt[8] += $inBL[0]; |
|
| 1835 | - unset($pt[6]);unset($pt[7]); |
|
| 1836 | - } |
|
| 1837 | - if (is_array($outBR)) { |
|
| 1838 | - $bord-=1; |
|
| 1839 | - $pt[2] -= $outBR[0] - $border['r']['width']; |
|
| 1840 | - if ($inBR) $pt[10]-= $inBR[0]; |
|
| 1841 | - unset($pt[0]);unset($pt[1]); |
|
| 1842 | - |
|
| 1843 | - } |
|
| 1844 | - |
|
| 1845 | - $pt = array_values($pt); |
|
| 1846 | - $this->_drawLine($pt, $border['b']['color'], $border['b']['type'], $border['b']['width'], $bord); |
|
| 1847 | - } |
|
| 1848 | - |
|
| 1849 | - if ($background['color']) { |
|
| 1850 | - $this->pdf->setFillColorArray($background['color']); |
|
| 1851 | - } |
|
| 1852 | - |
|
| 1853 | - return true; |
|
| 1854 | - } |
|
| 1855 | - |
|
| 1856 | - /** |
|
| 1857 | - * draw a curve (for border radius) |
|
| 1858 | - * |
|
| 1859 | - * @access protected |
|
| 1860 | - * @param array $pt |
|
| 1861 | - * @param array $color |
|
| 1862 | - */ |
|
| 1863 | - protected function _drawCurve($pt, $color) |
|
| 1864 | - { |
|
| 1865 | - $this->pdf->setFillColorArray($color); |
|
| 1866 | - |
|
| 1867 | - if (count($pt)==10) |
|
| 1868 | - $this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]); |
|
| 1869 | - else |
|
| 1870 | - $this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]); |
|
| 1871 | - } |
|
| 1872 | - |
|
| 1873 | - /** |
|
| 1874 | - * draw a ligne with a specific type, and specific start and end for radius |
|
| 1875 | - * |
|
| 1876 | - * @access protected |
|
| 1877 | - * @param array $pt |
|
| 1878 | - * @param float $color |
|
| 1879 | - * @param string $type (dashed, dotted, double, solid) |
|
| 1880 | - * @param float $width |
|
| 1881 | - * @param integer $radius (binary from 0 to 3 with 1=>start with a radius, 2=>end with a radius) |
|
| 1882 | - */ |
|
| 1883 | - protected function _drawLine($pt, $color, $type, $width, $radius=3) |
|
| 1884 | - { |
|
| 1885 | - // set the fill color |
|
| 1886 | - $this->pdf->setFillColorArray($color); |
|
| 1887 | - |
|
| 1888 | - // if dashed or dotted |
|
| 1889 | - if ($type=='dashed' || $type=='dotted') { |
|
| 1890 | - |
|
| 1891 | - // clean the end of the line, if radius |
|
| 1892 | - if ($radius==1) { |
|
| 1893 | - $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[8]; $tmp[]=$pt[9]; |
|
| 1894 | - $this->pdf->Polygon($tmp, 'F'); |
|
| 1895 | - |
|
| 1896 | - $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]; |
|
| 1897 | - $pt = $tmp; |
|
| 1898 | - } else if ($radius==2) { |
|
| 1899 | - $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; |
|
| 1900 | - $this->pdf->Polygon($tmp, 'F'); |
|
| 1901 | - |
|
| 1902 | - $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]; |
|
| 1903 | - $pt = $tmp; |
|
| 1904 | - } else if ($radius==3) { |
|
| 1905 | - $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[10]; $tmp[]=$pt[11]; |
|
| 1906 | - $this->pdf->Polygon($tmp, 'F'); |
|
| 1907 | - |
|
| 1908 | - $tmp = array(); $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9]; |
|
| 1909 | - $this->pdf->Polygon($tmp, 'F'); |
|
| 1910 | - |
|
| 1911 | - $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]; |
|
| 1912 | - $pt = $tmp; |
|
| 1913 | - } |
|
| 1914 | - |
|
| 1915 | - // horisontal or vertical line |
|
| 1916 | - if ($pt[2]==$pt[0]) { |
|
| 1917 | - $l = abs(($pt[3]-$pt[1])*0.5); |
|
| 1918 | - $px = 0; |
|
| 1919 | - $py = $width; |
|
| 1920 | - $x1 = $pt[0]; $y1 = ($pt[3]+$pt[1])*0.5; |
|
| 1921 | - $x2 = $pt[6]; $y2 = ($pt[7]+$pt[5])*0.5; |
|
| 1922 | - } else { |
|
| 1923 | - $l = abs(($pt[2]-$pt[0])*0.5); |
|
| 1924 | - $px = $width; |
|
| 1925 | - $py = 0; |
|
| 1926 | - $x1 = ($pt[2]+$pt[0])*0.5; $y1 = $pt[1]; |
|
| 1927 | - $x2 = ($pt[6]+$pt[4])*0.5; $y2 = $pt[7]; |
|
| 1928 | - } |
|
| 1929 | - |
|
| 1930 | - // if dashed : 3x bigger than dotted |
|
| 1931 | - if ($type=='dashed') { |
|
| 1932 | - $px = $px*3.; |
|
| 1933 | - $py = $py*3.; |
|
| 1934 | - } |
|
| 1935 | - $mode = ($l/($px+$py)<.5); |
|
| 1936 | - |
|
| 1937 | - // display the dotted/dashed line |
|
| 1938 | - for ($i=0; $l-($px+$py)*($i-0.5)>0; $i++) { |
|
| 1939 | - if (($i%2)==$mode) { |
|
| 1940 | - $j = $i-0.5; |
|
| 1941 | - $lx1 = $px*($j); if ($lx1<-$l) $lx1 =-$l; |
|
| 1942 | - $ly1 = $py*($j); if ($ly1<-$l) $ly1 =-$l; |
|
| 1943 | - $lx2 = $px*($j+1); if ($lx2>$l) $lx2 = $l; |
|
| 1944 | - $ly2 = $py*($j+1); if ($ly2>$l) $ly2 = $l; |
|
| 1945 | - |
|
| 1946 | - $tmp = array(); |
|
| 1947 | - $tmp[] = $x1+$lx1; $tmp[] = $y1+$ly1; |
|
| 1948 | - $tmp[] = $x1+$lx2; $tmp[] = $y1+$ly2; |
|
| 1949 | - $tmp[] = $x2+$lx2; $tmp[] = $y2+$ly2; |
|
| 1950 | - $tmp[] = $x2+$lx1; $tmp[] = $y2+$ly1; |
|
| 1951 | - $this->pdf->Polygon($tmp, 'F'); |
|
| 1952 | - |
|
| 1953 | - if ($j>0) { |
|
| 1954 | - $tmp = array(); |
|
| 1955 | - $tmp[] = $x1-$lx1; $tmp[] = $y1-$ly1; |
|
| 1956 | - $tmp[] = $x1-$lx2; $tmp[] = $y1-$ly2; |
|
| 1957 | - $tmp[] = $x2-$lx2; $tmp[] = $y2-$ly2; |
|
| 1958 | - $tmp[] = $x2-$lx1; $tmp[] = $y2-$ly1; |
|
| 1959 | - $this->pdf->Polygon($tmp, 'F'); |
|
| 1960 | - } |
|
| 1961 | - } |
|
| 1962 | - } |
|
| 1963 | - } else if ($type=='double') { |
|
| 1964 | - |
|
| 1965 | - // if double, 2 lines : 0=>1/3 and 2/3=>1 |
|
| 1966 | - $pt1 = $pt; |
|
| 1967 | - $pt2 = $pt; |
|
| 1968 | - |
|
| 1969 | - if (count($pt)==12) { |
|
| 1970 | - // line 1 |
|
| 1971 | - $pt1[0] = ($pt[0]-$pt[10])*0.33 + $pt[10]; |
|
| 1972 | - $pt1[1] = ($pt[1]-$pt[11])*0.33 + $pt[11]; |
|
| 1973 | - $pt1[2] = ($pt[2]-$pt[10])*0.33 + $pt[10]; |
|
| 1974 | - $pt1[3] = ($pt[3]-$pt[11])*0.33 + $pt[11]; |
|
| 1975 | - $pt1[4] = ($pt[4]-$pt[8])*0.33 + $pt[8]; |
|
| 1976 | - $pt1[5] = ($pt[5]-$pt[9])*0.33 + $pt[9]; |
|
| 1977 | - $pt1[6] = ($pt[6]-$pt[8])*0.33 + $pt[8]; |
|
| 1978 | - $pt1[7] = ($pt[7]-$pt[9])*0.33 + $pt[9]; |
|
| 1979 | - $pt2[10]= ($pt[10]-$pt[0])*0.33 + $pt[0]; |
|
| 1980 | - $pt2[11]= ($pt[11]-$pt[1])*0.33 + $pt[1]; |
|
| 1981 | - |
|
| 1982 | - // line 2 |
|
| 1983 | - $pt2[2] = ($pt[2] -$pt[0])*0.33 + $pt[0]; |
|
| 1984 | - $pt2[3] = ($pt[3] -$pt[1])*0.33 + $pt[1]; |
|
| 1985 | - $pt2[4] = ($pt[4] -$pt[6])*0.33 + $pt[6]; |
|
| 1986 | - $pt2[5] = ($pt[5] -$pt[7])*0.33 + $pt[7]; |
|
| 1987 | - $pt2[8] = ($pt[8] -$pt[6])*0.33 + $pt[6]; |
|
| 1988 | - $pt2[9] = ($pt[9] -$pt[7])*0.33 + $pt[7]; |
|
| 1989 | - } else { |
|
| 1990 | - // line 1 |
|
| 1991 | - $pt1[0] = ($pt[0]-$pt[6])*0.33 + $pt[6]; |
|
| 1992 | - $pt1[1] = ($pt[1]-$pt[7])*0.33 + $pt[7]; |
|
| 1993 | - $pt1[2] = ($pt[2]-$pt[4])*0.33 + $pt[4]; |
|
| 1994 | - $pt1[3] = ($pt[3]-$pt[5])*0.33 + $pt[5]; |
|
| 1995 | - |
|
| 1996 | - // line 2 |
|
| 1997 | - $pt2[6] = ($pt[6]-$pt[0])*0.33 + $pt[0]; |
|
| 1998 | - $pt2[7] = ($pt[7]-$pt[1])*0.33 + $pt[1]; |
|
| 1999 | - $pt2[4] = ($pt[4]-$pt[2])*0.33 + $pt[2]; |
|
| 2000 | - $pt2[5] = ($pt[5]-$pt[3])*0.33 + $pt[3]; |
|
| 2001 | - } |
|
| 2002 | - $this->pdf->Polygon($pt1, 'F'); |
|
| 2003 | - $this->pdf->Polygon($pt2, 'F'); |
|
| 2004 | - } else if ($type=='solid') { |
|
| 2005 | - // solid line : draw directly the polygon |
|
| 2006 | - $this->pdf->Polygon($pt, 'F'); |
|
| 2007 | - } |
|
| 2008 | - } |
|
| 2009 | - |
|
| 2010 | - /** |
|
| 2011 | - * prepare a transform matrix, only for drawing a SVG graphic |
|
| 2012 | - * |
|
| 2013 | - * @access protected |
|
| 2014 | - * @param string $transform |
|
| 2015 | - * @return array $matrix |
|
| 2016 | - */ |
|
| 2017 | - protected function _prepareTransform($transform) |
|
| 2018 | - { |
|
| 2019 | - // it can not be empty |
|
| 2020 | - if (!$transform) return null; |
|
| 2021 | - |
|
| 2022 | - // sctions must be like scale(...) |
|
| 2023 | - if (!preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) return null; |
|
| 2024 | - |
|
| 2025 | - // prepare the list of the actions |
|
| 2026 | - $actions = array(); |
|
| 2027 | - |
|
| 2028 | - // for actions |
|
| 2029 | - for ($k=0; $k<count($match[0]); $k++) { |
|
| 2030 | - |
|
| 2031 | - // get the name of the action |
|
| 2032 | - $name = strtolower($match[1][$k]); |
|
| 2033 | - |
|
| 2034 | - // get the parameters of the action |
|
| 2035 | - $val = explode(',', trim($match[2][$k])); |
|
| 2036 | - foreach ($val as $i => $j) { |
|
| 2037 | - $val[$i] = trim($j); |
|
| 2038 | - } |
|
| 2039 | - |
|
| 2040 | - // prepare the matrix, depending on the action |
|
| 2041 | - switch($name) |
|
| 2042 | - { |
|
| 2043 | - case 'scale': |
|
| 2044 | - if (!isset($val[0])) $val[0] = 1.; else $val[0] = 1.*$val[0]; |
|
| 2045 | - if (!isset($val[1])) $val[1] = $val[0]; else $val[1] = 1.*$val[1]; |
|
| 2046 | - $actions[] = array($val[0],0,0,$val[1],0,0); |
|
| 2047 | - break; |
|
| 2048 | - |
|
| 2049 | - case 'translate': |
|
| 2050 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']); |
|
| 2051 | - if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']); |
|
| 2052 | - $actions[] = array(1,0,0,1,$val[0],$val[1]); |
|
| 2053 | - break; |
|
| 2054 | - |
|
| 2055 | - case 'rotate': |
|
| 2056 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.; |
|
| 2057 | - if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']); |
|
| 2058 | - if (!isset($val[2])) $val[2] = 0.; else $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']); |
|
| 2059 | - if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,-$val[1],-$val[2]); |
|
| 2060 | - $actions[] = array(cos($val[0]),sin($val[0]),-sin($val[0]),cos($val[0]),0,0); |
|
| 2061 | - if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,$val[1],$val[2]); |
|
| 2062 | - break; |
|
| 2063 | - |
|
| 2064 | - case 'skewx': |
|
| 2065 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.; |
|
| 2066 | - $actions[] = array(1,0,tan($val[0]),1,0,0); |
|
| 2067 | - break; |
|
| 2068 | - |
|
| 2069 | - case 'skewy': |
|
| 2070 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.; |
|
| 2071 | - $actions[] = array(1,tan($val[0]),0,1,0,0); |
|
| 2072 | - break; |
|
| 2073 | - case 'matrix': |
|
| 2074 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*1.; |
|
| 2075 | - if (!isset($val[1])) $val[1] = 0.; else $val[1] = $val[1]*1.; |
|
| 2076 | - if (!isset($val[2])) $val[2] = 0.; else $val[2] = $val[2]*1.; |
|
| 2077 | - if (!isset($val[3])) $val[3] = 0.; else $val[3] = $val[3]*1.; |
|
| 2078 | - if (!isset($val[4])) $val[4] = 0.; else $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']); |
|
| 2079 | - if (!isset($val[5])) $val[5] = 0.; else $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']); |
|
| 2080 | - $actions[] =$val; |
|
| 2081 | - break; |
|
| 2082 | - } |
|
| 2083 | - } |
|
| 2084 | - |
|
| 2085 | - // if ther is no actions => return |
|
| 2086 | - if (!$actions) return null; |
|
| 2087 | - |
|
| 2088 | - // get the first matrix |
|
| 2089 | - $m = $actions[0]; unset($actions[0]); |
|
| 2090 | - |
|
| 2091 | - // foreach matrix => multiply to the last matrix |
|
| 2092 | - foreach ($actions as $n) { |
|
| 2093 | - $m = array( |
|
| 2094 | - $m[0]*$n[0]+$m[2]*$n[1], |
|
| 2095 | - $m[1]*$n[0]+$m[3]*$n[1], |
|
| 2096 | - $m[0]*$n[2]+$m[2]*$n[3], |
|
| 2097 | - $m[1]*$n[2]+$m[3]*$n[3], |
|
| 2098 | - $m[0]*$n[4]+$m[2]*$n[5]+$m[4], |
|
| 2099 | - $m[1]*$n[4]+$m[3]*$n[5]+$m[5] |
|
| 2100 | - ); |
|
| 2101 | - } |
|
| 2102 | - |
|
| 2103 | - // return the matrix |
|
| 2104 | - return $m; |
|
| 2105 | - } |
|
| 2106 | - |
|
| 2107 | - /** |
|
| 2108 | - * @access protected |
|
| 2109 | - * @param &array $cases |
|
| 2110 | - * @param &array $corr |
|
| 2111 | - */ |
|
| 2112 | - protected function _calculateTableCellSize(&$cases, &$corr) |
|
| 2113 | - { |
|
| 2114 | - if (!isset($corr[0])) return true; |
|
| 2115 | - |
|
| 2116 | - // for each cell without colspan, we get the max width for each column |
|
| 2117 | - $sw = array(); |
|
| 2118 | - for ($x=0; $x<count($corr[0]); $x++) { |
|
| 2119 | - $m=0; |
|
| 2120 | - for ($y=0; $y<count($corr); $y++) { |
|
| 2121 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]==1) { |
|
| 2122 | - $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']); |
|
| 2123 | - } |
|
| 2124 | - } |
|
| 2125 | - $sw[$x] = $m; |
|
| 2126 | - } |
|
| 2127 | - |
|
| 2128 | - // for each cell with colspan, we adapt the width of each column |
|
| 2129 | - for ($x=0; $x<count($corr[0]); $x++) { |
|
| 2130 | - for ($y=0; $y<count($corr); $y++) { |
|
| 2131 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]>1) { |
|
| 2132 | - |
|
| 2133 | - // sum the max width of each column in colspan |
|
| 2134 | - $s = 0; for ($i=0; $i<$corr[$y][$x][2]; $i++) $s+= $sw[$x+$i]; |
|
| 2135 | - |
|
| 2136 | - // if the max width is < the width of the cell with colspan => we adapt the width of each max width |
|
| 2137 | - if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']) { |
|
| 2138 | - for ($i=0; $i<$corr[$y][$x][2]; $i++) { |
|
| 2139 | - $sw[$x+$i] = $sw[$x+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']; |
|
| 2140 | - } |
|
| 2141 | - } |
|
| 2142 | - } |
|
| 2143 | - } |
|
| 2144 | - } |
|
| 2145 | - |
|
| 2146 | - // set the new width, for each cell |
|
| 2147 | - for ($x=0; $x<count($corr[0]); $x++) { |
|
| 2148 | - for ($y=0; $y<count($corr); $y++) { |
|
| 2149 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) { |
|
| 2150 | - // without colspan |
|
| 2151 | - if ($corr[$y][$x][2]==1) { |
|
| 2152 | - $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $sw[$x]; |
|
| 2153 | - // with colspan |
|
| 2154 | - } else { |
|
| 2155 | - $s = 0; |
|
| 2156 | - for ($i=0; $i<$corr[$y][$x][2]; $i++) { |
|
| 2157 | - $s+= $sw[$x+$i]; |
|
| 2158 | - } |
|
| 2159 | - $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $s; |
|
| 2160 | - } |
|
| 2161 | - } |
|
| 2162 | - } |
|
| 2163 | - } |
|
| 2164 | - |
|
| 2165 | - // for each cell without rowspan, we get the max height for each line |
|
| 2166 | - $sh = array(); |
|
| 2167 | - for ($y=0; $y<count($corr); $y++) { |
|
| 2168 | - $m=0; |
|
| 2169 | - for ($x=0; $x<count($corr[0]); $x++) { |
|
| 2170 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]==1) { |
|
| 2171 | - $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']); |
|
| 2172 | - } |
|
| 2173 | - } |
|
| 2174 | - $sh[$y] = $m; |
|
| 2175 | - } |
|
| 2176 | - |
|
| 2177 | - // for each cell with rowspan, we adapt the height of each line |
|
| 2178 | - for ($y=0; $y<count($corr); $y++) { |
|
| 2179 | - for ($x=0; $x<count($corr[0]); $x++) { |
|
| 2180 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]>1) { |
|
| 2181 | - |
|
| 2182 | - // sum the max height of each line in rowspan |
|
| 2183 | - $s = 0; for ($i=0; $i<$corr[$y][$x][3]; $i++) $s+= $sh[$y+$i]; |
|
| 2184 | - |
|
| 2185 | - // if the max height is < the height of the cell with rowspan => we adapt the height of each max height |
|
| 2186 | - if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']) { |
|
| 2187 | - for ($i=0; $i<$corr[$y][$x][3]; $i++) { |
|
| 2188 | - $sh[$y+$i] = $sh[$y+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']; |
|
| 2189 | - } |
|
| 2190 | - } |
|
| 2191 | - } |
|
| 2192 | - } |
|
| 2193 | - } |
|
| 2194 | - |
|
| 2195 | - // set the new height, for each cell |
|
| 2196 | - for ($y=0; $y<count($corr); $y++) { |
|
| 2197 | - for ($x=0; $x<count($corr[0]); $x++) { |
|
| 2198 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) { |
|
| 2199 | - // without rowspan |
|
| 2200 | - if ($corr[$y][$x][3]==1) { |
|
| 2201 | - $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $sh[$y]; |
|
| 2202 | - // with rowspan |
|
| 2203 | - } else { |
|
| 2204 | - $s = 0; |
|
| 2205 | - for ($i=0; $i<$corr[$y][$x][3]; $i++) { |
|
| 2206 | - $s+= $sh[$y+$i]; |
|
| 2207 | - } |
|
| 2208 | - $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $s; |
|
| 2209 | - |
|
| 2210 | - for ($j=1; $j<$corr[$y][$x][3]; $j++) { |
|
| 2211 | - $tx = $x+1; |
|
| 2212 | - $ty = $y+$j; |
|
| 2213 | - for (true; isset($corr[$ty][$tx]) && !is_array($corr[$ty][$tx]); $tx++); |
|
| 2214 | - if (isset($corr[$ty][$tx])) { |
|
| 2215 | - $cases[$corr[$ty][$tx][1]][$corr[$ty][$tx][0]]['dw']+= $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']; |
|
| 2216 | - } |
|
| 2217 | - } |
|
| 2218 | - } |
|
| 2219 | - } |
|
| 2220 | - } |
|
| 2221 | - } |
|
| 2222 | - } |
|
| 2223 | - |
|
| 2224 | - /** |
|
| 2225 | - * tag : PAGE |
|
| 2226 | - * mode : OPEN |
|
| 2227 | - * |
|
| 2228 | - * @param array $param |
|
| 2229 | - * @return boolean |
|
| 2230 | - */ |
|
| 2231 | - protected function _tag_open_PAGE($param) |
|
| 2232 | - { |
|
| 2233 | - if ($this->_isForOneLine) return false; |
|
| 2234 | - if ($this->_debugActif) $this->_DEBUG_add('PAGE '.($this->_page+1), true); |
|
| 2235 | - |
|
| 2236 | - $newPageSet= (!isset($param['pageset']) || $param['pageset']!='old'); |
|
| 2237 | - |
|
| 2238 | - $resetPageNumber = (isset($param['pagegroup']) && $param['pagegroup']=='new'); |
|
| 2239 | - |
|
| 2240 | - $this->_maxH = 0; |
|
| 2241 | - |
|
| 2242 | - // if new page set asked |
|
| 2243 | - if ($newPageSet) { |
|
| 2244 | - $this->_subHEADER = array(); |
|
| 2245 | - $this->_subFOOTER = array(); |
|
| 2246 | - |
|
| 2247 | - // orientation |
|
| 2248 | - $orientation = ''; |
|
| 2249 | - if (isset($param['orientation'])) { |
|
| 2250 | - $param['orientation'] = strtolower($param['orientation']); |
|
| 2251 | - if ($param['orientation']=='p') $orientation = 'P'; |
|
| 2252 | - if ($param['orientation']=='portrait') $orientation = 'P'; |
|
| 2253 | - |
|
| 2254 | - if ($param['orientation']=='l') $orientation = 'L'; |
|
| 2255 | - if ($param['orientation']=='paysage') $orientation = 'L'; |
|
| 2256 | - if ($param['orientation']=='landscape') $orientation = 'L'; |
|
| 2257 | - } |
|
| 2258 | - |
|
| 2259 | - // format |
|
| 2260 | - $format = null; |
|
| 2261 | - if (isset($param['format'])) { |
|
| 2262 | - $format = strtolower($param['format']); |
|
| 2263 | - if (preg_match('/^([0-9]+)x([0-9]+)$/isU', $format, $match)) { |
|
| 2264 | - $format = array(intval($match[1]), intval($match[2])); |
|
| 2265 | - } |
|
| 2266 | - } |
|
| 2267 | - |
|
| 2268 | - // background |
|
| 2269 | - $background = array(); |
|
| 2270 | - if (isset($param['backimg'])) { |
|
| 2271 | - $background['img'] = isset($param['backimg']) ? $param['backimg'] : ''; // src of the image |
|
| 2272 | - $background['posX'] = isset($param['backimgx']) ? $param['backimgx'] : 'center'; // horizontale position of the image |
|
| 2273 | - $background['posY'] = isset($param['backimgy']) ? $param['backimgy'] : 'middle'; // vertical position of the image |
|
| 2274 | - $background['width'] = isset($param['backimgw']) ? $param['backimgw'] : '100%'; // width of the image (100% = page width) |
|
| 2275 | - |
|
| 2276 | - // convert the src of the image, if parameters |
|
| 2277 | - $background['img'] = str_replace('&', '&', $background['img']); |
|
| 2278 | - |
|
| 2279 | - // convert the positions |
|
| 2280 | - if ($background['posX']=='left') $background['posX'] = '0%'; |
|
| 2281 | - if ($background['posX']=='center') $background['posX'] = '50%'; |
|
| 2282 | - if ($background['posX']=='right') $background['posX'] = '100%'; |
|
| 2283 | - if ($background['posY']=='top') $background['posY'] = '0%'; |
|
| 2284 | - if ($background['posY']=='middle') $background['posY'] = '50%'; |
|
| 2285 | - if ($background['posY']=='bottom') $background['posY'] = '100%'; |
|
| 2286 | - |
|
| 2287 | - if ($background['img']) { |
|
| 2288 | - // get the size of the image |
|
| 2289 | - // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini |
|
| 2290 | - $infos=@getimagesize($background['img']); |
|
| 2291 | - if (count($infos)>1) { |
|
| 2292 | - $imageWidth = $this->parsingCss->ConvertToMM($background['width'], $this->pdf->getW()); |
|
| 2293 | - $imageHeight = $imageWidth*$infos[1]/$infos[0]; |
|
| 2294 | - |
|
| 2295 | - $background['width'] = $imageWidth; |
|
| 2296 | - $background['posX'] = $this->parsingCss->ConvertToMM($background['posX'], $this->pdf->getW() - $imageWidth); |
|
| 2297 | - $background['posY'] = $this->parsingCss->ConvertToMM($background['posY'], $this->pdf->getH() - $imageHeight); |
|
| 2298 | - } else { |
|
| 2299 | - $background = array(); |
|
| 2300 | - } |
|
| 2301 | - } else { |
|
| 2302 | - $background = array(); |
|
| 2303 | - } |
|
| 2304 | - } |
|
| 2305 | - |
|
| 2306 | - // margins of the page |
|
| 2307 | - $background['top'] = isset($param['backtop']) ? $param['backtop'] : '0'; |
|
| 2308 | - $background['bottom'] = isset($param['backbottom']) ? $param['backbottom'] : '0'; |
|
| 2309 | - $background['left'] = isset($param['backleft']) ? $param['backleft'] : '0'; |
|
| 2310 | - $background['right'] = isset($param['backright']) ? $param['backright'] : '0'; |
|
| 2311 | - |
|
| 2312 | - // if no unit => mm |
|
| 2313 | - if (preg_match('/^([0-9]*)$/isU', $background['top'])) $background['top'] .= 'mm'; |
|
| 2314 | - if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) $background['bottom'] .= 'mm'; |
|
| 2315 | - if (preg_match('/^([0-9]*)$/isU', $background['left'])) $background['left'] .= 'mm'; |
|
| 2316 | - if (preg_match('/^([0-9]*)$/isU', $background['right'])) $background['right'] .= 'mm'; |
|
| 2317 | - |
|
| 2318 | - // convert to mm |
|
| 2319 | - $background['top'] = $this->parsingCss->ConvertToMM($background['top'], $this->pdf->getH()); |
|
| 2320 | - $background['bottom'] = $this->parsingCss->ConvertToMM($background['bottom'], $this->pdf->getH()); |
|
| 2321 | - $background['left'] = $this->parsingCss->ConvertToMM($background['left'], $this->pdf->getW()); |
|
| 2322 | - $background['right'] = $this->parsingCss->ConvertToMM($background['right'], $this->pdf->getW()); |
|
| 2323 | - |
|
| 2324 | - // get the background color |
|
| 2325 | - $res = false; |
|
| 2326 | - $background['color'] = isset($param['backcolor']) ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null; |
|
| 2327 | - if (!$res) $background['color'] = null; |
|
| 2328 | - |
|
| 2329 | - $this->parsingCss->save(); |
|
| 2330 | - $this->parsingCss->analyse('PAGE', $param); |
|
| 2331 | - $this->parsingCss->setPosition(); |
|
| 2332 | - $this->parsingCss->fontSet(); |
|
| 2333 | - |
|
| 2334 | - // new page |
|
| 2335 | - $this->_setNewPage($format, $orientation, $background, null, $resetPageNumber); |
|
| 2336 | - |
|
| 2337 | - // automatic footer |
|
| 2338 | - if (isset($param['footer'])) { |
|
| 2339 | - $lst = explode(';', $param['footer']); |
|
| 2340 | - foreach ($lst as $key => $val) $lst[$key] = trim(strtolower($val)); |
|
| 2341 | - $page = in_array('page', $lst); |
|
| 2342 | - $date = in_array('date', $lst); |
|
| 2343 | - $hour = in_array('heure', $lst); |
|
| 2344 | - $form = in_array('form', $lst); |
|
| 2345 | - } else { |
|
| 2346 | - $page = null; |
|
| 2347 | - $date = null; |
|
| 2348 | - $hour = null; |
|
| 2349 | - $form = null; |
|
| 2350 | - } |
|
| 2351 | - $this->pdf->SetMyFooter($page, $date, $hour, $form); |
|
| 2352 | - // else => we use the last page set used |
|
| 2353 | - } else { |
|
| 2354 | - $this->parsingCss->save(); |
|
| 2355 | - $this->parsingCss->analyse('PAGE', $param); |
|
| 2356 | - $this->parsingCss->setPosition(); |
|
| 2357 | - $this->parsingCss->fontSet(); |
|
| 2358 | - |
|
| 2359 | - $this->_setNewPage(null, null, null, null, $resetPageNumber); |
|
| 2360 | - } |
|
| 2361 | - |
|
| 2362 | - return true; |
|
| 2363 | - } |
|
| 2364 | - |
|
| 2365 | - /** |
|
| 2366 | - * tag : PAGE |
|
| 2367 | - * mode : CLOSE |
|
| 2368 | - * |
|
| 2369 | - * @param array $param |
|
| 2370 | - * @return boolean |
|
| 2371 | - */ |
|
| 2372 | - protected function _tag_close_PAGE($param) |
|
| 2373 | - { |
|
| 2374 | - if ($this->_isForOneLine) return false; |
|
| 2375 | - |
|
| 2376 | - $this->_maxH = 0; |
|
| 2377 | - |
|
| 2378 | - $this->parsingCss->load(); |
|
| 2379 | - $this->parsingCss->fontSet(); |
|
| 2380 | - |
|
| 2381 | - if ($this->_debugActif) $this->_DEBUG_add('PAGE '.$this->_page, false); |
|
| 2382 | - |
|
| 2383 | - return true; |
|
| 2384 | - } |
|
| 2385 | - |
|
| 2386 | - /** |
|
| 2387 | - * tag : PAGE_HEADER |
|
| 2388 | - * mode : OPEN |
|
| 2389 | - * |
|
| 2390 | - * @param array $param |
|
| 2391 | - * @return boolean |
|
| 2392 | - */ |
|
| 2393 | - protected function _tag_open_PAGE_HEADER($param) |
|
| 2394 | - { |
|
| 2395 | - if ($this->_isForOneLine) return false; |
|
| 2396 | - |
|
| 2397 | - $this->_subHEADER = array(); |
|
| 2398 | - for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) { |
|
| 2399 | - $action = $this->parsingHtml->code[$this->_parsePos]; |
|
| 2400 | - if ($action['name']=='page_header') $action['name']='page_header_sub'; |
|
| 2401 | - $this->_subHEADER[] = $action; |
|
| 2402 | - if (strtolower($action['name'])=='page_header_sub' && $action['close']) break; |
|
| 2403 | - } |
|
| 2404 | - |
|
| 2405 | - $this->_setPageHeader(); |
|
| 2406 | - |
|
| 2407 | - return true; |
|
| 2408 | - } |
|
| 2409 | - |
|
| 2410 | - /** |
|
| 2411 | - * tag : PAGE_FOOTER |
|
| 2412 | - * mode : OPEN |
|
| 2413 | - * |
|
| 2414 | - * @param array $param |
|
| 2415 | - * @return boolean |
|
| 2416 | - */ |
|
| 2417 | - protected function _tag_open_PAGE_FOOTER($param) |
|
| 2418 | - { |
|
| 2419 | - if ($this->_isForOneLine) return false; |
|
| 2420 | - |
|
| 2421 | - $this->_subFOOTER = array(); |
|
| 2422 | - for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) { |
|
| 2423 | - $action = $this->parsingHtml->code[$this->_parsePos]; |
|
| 2424 | - if ($action['name']=='page_footer') $action['name']='page_footer_sub'; |
|
| 2425 | - $this->_subFOOTER[] = $action; |
|
| 2426 | - if (strtolower($action['name'])=='page_footer_sub' && $action['close']) break; |
|
| 2427 | - } |
|
| 2428 | - |
|
| 2429 | - $this->_setPageFooter(); |
|
| 2430 | - |
|
| 2431 | - return true; |
|
| 2432 | - } |
|
| 2433 | - |
|
| 2434 | - /** |
|
| 2435 | - * It is not a real tag. Does not use it directly |
|
| 2436 | - * |
|
| 2437 | - * @param array $param |
|
| 2438 | - * @return boolean |
|
| 2439 | - */ |
|
| 2440 | - protected function _tag_open_PAGE_HEADER_SUB($param) |
|
| 2441 | - { |
|
| 2442 | - if ($this->_isForOneLine) return false; |
|
| 2443 | - |
|
| 2444 | - // save the current stat |
|
| 2445 | - $this->_subSTATES = array(); |
|
| 2446 | - $this->_subSTATES['x'] = $this->pdf->getX(); |
|
| 2447 | - $this->_subSTATES['y'] = $this->pdf->getY(); |
|
| 2448 | - $this->_subSTATES['s'] = $this->parsingCss->value; |
|
| 2449 | - $this->_subSTATES['t'] = $this->parsingCss->table; |
|
| 2450 | - $this->_subSTATES['ml'] = $this->_margeLeft; |
|
| 2451 | - $this->_subSTATES['mr'] = $this->_margeRight; |
|
| 2452 | - $this->_subSTATES['mt'] = $this->_margeTop; |
|
| 2453 | - $this->_subSTATES['mb'] = $this->_margeBottom; |
|
| 2454 | - $this->_subSTATES['mp'] = $this->_pageMarges; |
|
| 2455 | - |
|
| 2456 | - // new stat for the header |
|
| 2457 | - $this->_pageMarges = array(); |
|
| 2458 | - $this->_margeLeft = $this->_defaultLeft; |
|
| 2459 | - $this->_margeRight = $this->_defaultRight; |
|
| 2460 | - $this->_margeTop = $this->_defaultTop; |
|
| 2461 | - $this->_margeBottom = $this->_defaultBottom; |
|
| 2462 | - $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 2463 | - $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 2464 | - $this->pdf->setXY($this->_defaultLeft, $this->_defaultTop); |
|
| 2465 | - |
|
| 2466 | - $this->parsingCss->initStyle(); |
|
| 2467 | - $this->parsingCss->resetStyle(); |
|
| 2468 | - $this->parsingCss->value['width'] = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight; |
|
| 2469 | - $this->parsingCss->table = array(); |
|
| 2470 | - |
|
| 2471 | - $this->parsingCss->save(); |
|
| 2472 | - $this->parsingCss->analyse('page_header_sub', $param); |
|
| 2473 | - $this->parsingCss->setPosition(); |
|
| 2474 | - $this->parsingCss->fontSet(); |
|
| 2475 | - $this->_setNewPositionForNewLine(); |
|
| 2476 | - return true; |
|
| 2477 | - } |
|
| 2478 | - |
|
| 2479 | - /** |
|
| 2480 | - * It is not a real tag. Does not use it directly |
|
| 2481 | - * |
|
| 2482 | - * @param array $param |
|
| 2483 | - * @return boolean |
|
| 2484 | - */ |
|
| 2485 | - protected function _tag_close_PAGE_HEADER_SUB($param) |
|
| 2486 | - { |
|
| 2487 | - if ($this->_isForOneLine) return false; |
|
| 2488 | - |
|
| 2489 | - $this->parsingCss->load(); |
|
| 2490 | - |
|
| 2491 | - // restore the stat |
|
| 2492 | - $this->parsingCss->value = $this->_subSTATES['s']; |
|
| 2493 | - $this->parsingCss->table = $this->_subSTATES['t']; |
|
| 2494 | - $this->_pageMarges = $this->_subSTATES['mp']; |
|
| 2495 | - $this->_margeLeft = $this->_subSTATES['ml']; |
|
| 2496 | - $this->_margeRight = $this->_subSTATES['mr']; |
|
| 2497 | - $this->_margeTop = $this->_subSTATES['mt']; |
|
| 2498 | - $this->_margeBottom = $this->_subSTATES['mb']; |
|
| 2499 | - $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 2500 | - $this->pdf->setbMargin($this->_margeBottom); |
|
| 2501 | - $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 2502 | - $this->pdf->setXY($this->_subSTATES['x'], $this->_subSTATES['y']); |
|
| 2503 | - |
|
| 2504 | - $this->parsingCss->fontSet(); |
|
| 2505 | - $this->_maxH = 0; |
|
| 2506 | - |
|
| 2507 | - return true; |
|
| 2508 | - } |
|
| 2509 | - |
|
| 2510 | - /** |
|
| 2511 | - * It is not a real tag. Does not use it directly |
|
| 2512 | - * |
|
| 2513 | - * @param array $param |
|
| 2514 | - * @return boolean |
|
| 2515 | - */ |
|
| 2516 | - protected function _tag_open_PAGE_FOOTER_SUB($param) |
|
| 2517 | - { |
|
| 2518 | - if ($this->_isForOneLine) return false; |
|
| 2519 | - |
|
| 2520 | - // save the current stat |
|
| 2521 | - $this->_subSTATES = array(); |
|
| 2522 | - $this->_subSTATES['x'] = $this->pdf->getX(); |
|
| 2523 | - $this->_subSTATES['y'] = $this->pdf->getY(); |
|
| 2524 | - $this->_subSTATES['s'] = $this->parsingCss->value; |
|
| 2525 | - $this->_subSTATES['t'] = $this->parsingCss->table; |
|
| 2526 | - $this->_subSTATES['ml'] = $this->_margeLeft; |
|
| 2527 | - $this->_subSTATES['mr'] = $this->_margeRight; |
|
| 2528 | - $this->_subSTATES['mt'] = $this->_margeTop; |
|
| 2529 | - $this->_subSTATES['mb'] = $this->_margeBottom; |
|
| 2530 | - $this->_subSTATES['mp'] = $this->_pageMarges; |
|
| 2531 | - |
|
| 2532 | - // new stat for the footer |
|
| 2533 | - $this->_pageMarges = array(); |
|
| 2534 | - $this->_margeLeft = $this->_defaultLeft; |
|
| 2535 | - $this->_margeRight = $this->_defaultRight; |
|
| 2536 | - $this->_margeTop = $this->_defaultTop; |
|
| 2537 | - $this->_margeBottom = $this->_defaultBottom; |
|
| 2538 | - $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 2539 | - $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 2540 | - $this->pdf->setXY($this->_defaultLeft, $this->_defaultTop); |
|
| 2541 | - |
|
| 2542 | - $this->parsingCss->initStyle(); |
|
| 2543 | - $this->parsingCss->resetStyle(); |
|
| 2544 | - $this->parsingCss->value['width'] = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight; |
|
| 2545 | - $this->parsingCss->table = array(); |
|
| 2546 | - |
|
| 2547 | - // we create a sub HTML2PFDF, and we execute on it the content of the footer, to get the height of it |
|
| 2548 | - $sub = null; |
|
| 2549 | - $this->_createSubHTML($sub); |
|
| 2550 | - $sub->parsingHtml->code = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 2551 | - $sub->_makeHTMLcode(); |
|
| 2552 | - $this->pdf->setY($this->pdf->getH() - $sub->_maxY - $this->_defaultBottom - 0.01); |
|
| 2553 | - $this->_destroySubHTML($sub); |
|
| 2554 | - |
|
| 2555 | - $this->parsingCss->save(); |
|
| 2556 | - $this->parsingCss->analyse('page_footer_sub', $param); |
|
| 2557 | - $this->parsingCss->setPosition(); |
|
| 2558 | - $this->parsingCss->fontSet(); |
|
| 2559 | - $this->_setNewPositionForNewLine(); |
|
| 2560 | - |
|
| 2561 | - return true; |
|
| 2562 | - } |
|
| 2563 | - |
|
| 2564 | - /** |
|
| 2565 | - * It is not a real tag. Does not use it directly |
|
| 2566 | - * |
|
| 2567 | - * @param array $param |
|
| 2568 | - * @return boolean |
|
| 2569 | - */ |
|
| 2570 | - protected function _tag_close_PAGE_FOOTER_SUB($param) |
|
| 2571 | - { |
|
| 2572 | - if ($this->_isForOneLine) return false; |
|
| 2573 | - |
|
| 2574 | - $this->parsingCss->load(); |
|
| 2575 | - |
|
| 2576 | - $this->parsingCss->value = $this->_subSTATES['s']; |
|
| 2577 | - $this->parsingCss->table = $this->_subSTATES['t']; |
|
| 2578 | - $this->_pageMarges = $this->_subSTATES['mp']; |
|
| 2579 | - $this->_margeLeft = $this->_subSTATES['ml']; |
|
| 2580 | - $this->_margeRight = $this->_subSTATES['mr']; |
|
| 2581 | - $this->_margeTop = $this->_subSTATES['mt']; |
|
| 2582 | - $this->_margeBottom = $this->_subSTATES['mb']; |
|
| 2583 | - $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
|
| 2584 | - $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
|
| 2585 | - $this->pdf->setXY($this->_subSTATES['x'], $this->_subSTATES['y']); |
|
| 2586 | - |
|
| 2587 | - $this->parsingCss->fontSet(); |
|
| 2588 | - $this->_maxH = 0; |
|
| 2589 | - |
|
| 2590 | - return true; |
|
| 2591 | - } |
|
| 2592 | - |
|
| 2593 | - /** |
|
| 2594 | - * tag : NOBREAK |
|
| 2595 | - * mode : OPEN |
|
| 2596 | - * |
|
| 2597 | - * @param array $param |
|
| 2598 | - * @return boolean |
|
| 2599 | - */ |
|
| 2600 | - protected function _tag_open_NOBREAK($param) |
|
| 2601 | - { |
|
| 2602 | - if ($this->_isForOneLine) return false; |
|
| 2603 | - |
|
| 2604 | - $this->_maxH = 0; |
|
| 2605 | - |
|
| 2606 | - // create a sub HTML2PDF to execute the content of the tag, to get the dimensions |
|
| 2607 | - $sub = null; |
|
| 2608 | - $this->_createSubHTML($sub); |
|
| 2609 | - $sub->parsingHtml->code = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 2610 | - $sub->_makeHTMLcode(); |
|
| 2611 | - $y = $this->pdf->getY(); |
|
| 2612 | - |
|
| 2613 | - // if the content does not fit on the page => new page |
|
| 2614 | - if ( |
|
| 2615 | - $sub->_maxY < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin()) && |
|
| 2616 | - $y + $sub->_maxY>=($this->pdf->getH() - $this->pdf->getbMargin()) |
|
| 2617 | - ) { |
|
| 2618 | - $this->_setNewPage(); |
|
| 2619 | - } |
|
| 2620 | - |
|
| 2621 | - // destroy the sub HTML2PDF |
|
| 2622 | - $this->_destroySubHTML($sub); |
|
| 2623 | - |
|
| 2624 | - return true; |
|
| 2625 | - } |
|
| 2626 | - |
|
| 2627 | - |
|
| 2628 | - /** |
|
| 2629 | - * tag : NOBREAK |
|
| 2630 | - * mode : CLOSE |
|
| 2631 | - * |
|
| 2632 | - * @param array $param |
|
| 2633 | - * @return boolean |
|
| 2634 | - */ |
|
| 2635 | - protected function _tag_close_NOBREAK($param) |
|
| 2636 | - { |
|
| 2637 | - if ($this->_isForOneLine) return false; |
|
| 2638 | - |
|
| 2639 | - $this->_maxH = 0; |
|
| 2640 | - |
|
| 2641 | - return true; |
|
| 2642 | - } |
|
| 2643 | - |
|
| 2644 | - /** |
|
| 2645 | - * tag : DIV |
|
| 2646 | - * mode : OPEN |
|
| 2647 | - * |
|
| 2648 | - * @param array $param |
|
| 2649 | - * @param string $other name of tag that used the div tag |
|
| 2650 | - * @return boolean |
|
| 2651 | - */ |
|
| 2652 | - protected function _tag_open_DIV($param, $other = 'div') |
|
| 2653 | - { |
|
| 2654 | - if ($this->_isForOneLine) return false; |
|
| 2655 | - if ($this->_debugActif) $this->_DEBUG_add(strtoupper($other), true); |
|
| 2656 | - |
|
| 2657 | - $this->parsingCss->save(); |
|
| 2658 | - $this->parsingCss->analyse($other, $param); |
|
| 2659 | - $this->parsingCss->fontSet(); |
|
| 2660 | - |
|
| 2661 | - // for fieldset and legend |
|
| 2662 | - if (in_array($other, array('fieldset', 'legend'))) { |
|
| 2663 | - if (isset($param['moveTop'])) $this->parsingCss->value['margin']['t'] += $param['moveTop']; |
|
| 2664 | - if (isset($param['moveLeft'])) $this->parsingCss->value['margin']['l'] += $param['moveLeft']; |
|
| 2665 | - if (isset($param['moveDown'])) $this->parsingCss->value['margin']['b'] += $param['moveDown']; |
|
| 2666 | - } |
|
| 2667 | - |
|
| 2668 | - $alignObject = null; |
|
| 2669 | - if ($this->parsingCss->value['margin-auto']) $alignObject = 'center'; |
|
| 2670 | - |
|
| 2671 | - $marge = array(); |
|
| 2672 | - $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03; |
|
| 2673 | - $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03; |
|
| 2674 | - $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03; |
|
| 2675 | - $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03; |
|
| 2676 | - |
|
| 2677 | - // extract the content of the div |
|
| 2678 | - $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 2679 | - |
|
| 2680 | - // create a sub HTML2PDF to get the dimensions of the content of the div |
|
| 2681 | - $w = 0; $h = 0; |
|
| 2682 | - if (count($level)) { |
|
| 2683 | - $sub = null; |
|
| 2684 | - $this->_createSubHTML($sub); |
|
| 2685 | - $sub->parsingHtml->code = $level; |
|
| 2686 | - $sub->_makeHTMLcode(); |
|
| 2687 | - $w = $sub->_maxX; |
|
| 2688 | - $h = $sub->_maxY; |
|
| 2689 | - $this->_destroySubHTML($sub); |
|
| 2690 | - } |
|
| 2691 | - $wReel = $w; |
|
| 2692 | - $hReel = $h; |
|
| 2693 | - |
|
| 2694 | - $w+= $marge['l']+$marge['r']+0.001; |
|
| 2695 | - $h+= $marge['t']+$marge['b']+0.001; |
|
| 2696 | - |
|
| 2697 | - if ($this->parsingCss->value['overflow']=='hidden') { |
|
| 2698 | - $overW = max($w, $this->parsingCss->value['width']); |
|
| 2699 | - $overH = max($h, $this->parsingCss->value['height']); |
|
| 2700 | - $overflow = true; |
|
| 2701 | - $this->parsingCss->value['old_maxX'] = $this->_maxX; |
|
| 2702 | - $this->parsingCss->value['old_maxY'] = $this->_maxY; |
|
| 2703 | - $this->parsingCss->value['old_maxH'] = $this->_maxH; |
|
| 2704 | - $this->parsingCss->value['old_overflow'] = $this->_isInOverflow; |
|
| 2705 | - $this->_isInOverflow = true; |
|
| 2706 | - } else { |
|
| 2707 | - $overW = null; |
|
| 2708 | - $overH = null; |
|
| 2709 | - $overflow = false; |
|
| 2710 | - $this->parsingCss->value['width'] = max($w, $this->parsingCss->value['width']); |
|
| 2711 | - $this->parsingCss->value['height'] = max($h, $this->parsingCss->value['height']); |
|
| 2712 | - } |
|
| 2713 | - |
|
| 2714 | - switch($this->parsingCss->value['rotate']) |
|
| 2715 | - { |
|
| 2716 | - case 90: |
|
| 2717 | - $tmp = $overH; $overH = $overW; $overW = $tmp; |
|
| 2718 | - $tmp = $hReel; $hReel = $wReel; $wReel = $tmp; |
|
| 2719 | - unset($tmp); |
|
| 2720 | - $w = $this->parsingCss->value['height']; |
|
| 2721 | - $h = $this->parsingCss->value['width']; |
|
| 2722 | - $tX =-$h; |
|
| 2723 | - $tY = 0; |
|
| 2724 | - break; |
|
| 2725 | - |
|
| 2726 | - case 180: |
|
| 2727 | - $w = $this->parsingCss->value['width']; |
|
| 2728 | - $h = $this->parsingCss->value['height']; |
|
| 2729 | - $tX = -$w; |
|
| 2730 | - $tY = -$h; |
|
| 2731 | - break; |
|
| 2732 | - |
|
| 2733 | - case 270: |
|
| 2734 | - $tmp = $overH; $overH = $overW; $overW = $tmp; |
|
| 2735 | - $tmp = $hReel; $hReel = $wReel; $wReel = $tmp; |
|
| 2736 | - unset($tmp); |
|
| 2737 | - $w = $this->parsingCss->value['height']; |
|
| 2738 | - $h = $this->parsingCss->value['width']; |
|
| 2739 | - $tX = 0; |
|
| 2740 | - $tY =-$w; |
|
| 2741 | - break; |
|
| 2742 | - |
|
| 2743 | - default: |
|
| 2744 | - $w = $this->parsingCss->value['width']; |
|
| 2745 | - $h = $this->parsingCss->value['height']; |
|
| 2746 | - $tX = 0; |
|
| 2747 | - $tY = 0; |
|
| 2748 | - break; |
|
| 2749 | - } |
|
| 2750 | - |
|
| 2751 | - if (!$this->parsingCss->value['position']) { |
|
| 2752 | - if ( |
|
| 2753 | - $w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) && |
|
| 2754 | - $this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin()) |
|
| 2755 | - ) |
|
| 2756 | - $this->_tag_open_BR(array()); |
|
| 2757 | - |
|
| 2758 | - if ( |
|
| 2759 | - ($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) && |
|
| 2760 | - ($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) && |
|
| 2761 | - !$this->_isInOverflow |
|
| 2762 | - ) |
|
| 2763 | - $this->_setNewPage(); |
|
| 2764 | - |
|
| 2765 | - $old = $this->parsingCss->getOldValues(); |
|
| 2766 | - $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 2767 | - |
|
| 2768 | - if ($parentWidth>$w) { |
|
| 2769 | - if ($alignObject=='center') $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 2770 | - else if ($alignObject=='right') $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 2771 | - } |
|
| 2772 | - |
|
| 2773 | - $this->parsingCss->setPosition(); |
|
| 2774 | - } else { |
|
| 2775 | - $old = $this->parsingCss->getOldValues(); |
|
| 2776 | - $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 2777 | - |
|
| 2778 | - if ($parentWidth>$w) { |
|
| 2779 | - if ($alignObject=='center') $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 2780 | - else if ($alignObject=='right') $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 2781 | - } |
|
| 2782 | - |
|
| 2783 | - $this->parsingCss->setPosition(); |
|
| 2784 | - $this->_saveMax(); |
|
| 2785 | - $this->_maxX = 0; |
|
| 2786 | - $this->_maxY = 0; |
|
| 2787 | - $this->_maxH = 0; |
|
| 2788 | - $this->_maxE = 0; |
|
| 2789 | - } |
|
| 2790 | - |
|
| 2791 | - if ($this->parsingCss->value['rotate']) { |
|
| 2792 | - $this->pdf->startTransform(); |
|
| 2793 | - $this->pdf->setRotation($this->parsingCss->value['rotate']); |
|
| 2794 | - $this->pdf->setTranslate($tX, $tY); |
|
| 2795 | - } |
|
| 2796 | - |
|
| 2797 | - $this->_drawRectangle( |
|
| 2798 | - $this->parsingCss->value['x'], |
|
| 2799 | - $this->parsingCss->value['y'], |
|
| 2800 | - $this->parsingCss->value['width'], |
|
| 2801 | - $this->parsingCss->value['height'], |
|
| 2802 | - $this->parsingCss->value['border'], |
|
| 2803 | - $this->parsingCss->value['padding'], |
|
| 2804 | - 0, |
|
| 2805 | - $this->parsingCss->value['background'] |
|
| 2806 | - ); |
|
| 2807 | - |
|
| 2808 | - $marge = array(); |
|
| 2809 | - $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03; |
|
| 2810 | - $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03; |
|
| 2811 | - $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03; |
|
| 2812 | - $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03; |
|
| 2813 | - |
|
| 2814 | - $this->parsingCss->value['width'] -= $marge['l']+$marge['r']; |
|
| 2815 | - $this->parsingCss->value['height']-= $marge['t']+$marge['b']; |
|
| 2816 | - |
|
| 2817 | - $xCorr = 0; |
|
| 2818 | - $yCorr = 0; |
|
| 2819 | - if (!$this->_subPart && !$this->_isSubPart) { |
|
| 2820 | - switch($this->parsingCss->value['text-align']) |
|
| 2821 | - { |
|
| 2822 | - case 'right': |
|
| 2823 | - $xCorr = ($this->parsingCss->value['width']-$wReel); |
|
| 2824 | - break; |
|
| 2825 | - case 'center': |
|
| 2826 | - $xCorr = ($this->parsingCss->value['width']-$wReel)*0.5; |
|
| 2827 | - break; |
|
| 2828 | - } |
|
| 2829 | - if ($xCorr>0) $xCorr=0; |
|
| 2830 | - switch($this->parsingCss->value['vertical-align']) |
|
| 2831 | - { |
|
| 2832 | - case 'bottom': |
|
| 2833 | - $yCorr = ($this->parsingCss->value['height']-$hReel); |
|
| 2834 | - break; |
|
| 2835 | - case 'middle': |
|
| 2836 | - $yCorr = ($this->parsingCss->value['height']-$hReel)*0.5; |
|
| 2837 | - break; |
|
| 2838 | - } |
|
| 2839 | - } |
|
| 2840 | - |
|
| 2841 | - if ($overflow) { |
|
| 2842 | - $overW-= $marge['l']+$marge['r']; |
|
| 2843 | - $overH-= $marge['t']+$marge['b']; |
|
| 2844 | - $this->pdf->clippingPathStart( |
|
| 2845 | - $this->parsingCss->value['x']+$marge['l'], |
|
| 2846 | - $this->parsingCss->value['y']+$marge['t'], |
|
| 2847 | - $this->parsingCss->value['width'], |
|
| 2848 | - $this->parsingCss->value['height'] |
|
| 2849 | - ); |
|
| 2850 | - |
|
| 2851 | - $this->parsingCss->value['x']+= $xCorr; |
|
| 2852 | - |
|
| 2853 | - // marges from the dimension of the content |
|
| 2854 | - $mL = $this->parsingCss->value['x']+$marge['l']; |
|
| 2855 | - $mR = $this->pdf->getW() - $mL - $overW; |
|
| 2856 | - } else { |
|
| 2857 | - // marges from the dimension of the div |
|
| 2858 | - $mL = $this->parsingCss->value['x']+$marge['l']; |
|
| 2859 | - $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width']; |
|
| 2860 | - } |
|
| 2861 | - |
|
| 2862 | - $x = $this->parsingCss->value['x']+$marge['l']; |
|
| 2863 | - $y = $this->parsingCss->value['y']+$marge['t']+$yCorr; |
|
| 2864 | - $this->_saveMargin($mL, 0, $mR); |
|
| 2865 | - $this->pdf->setXY($x, $y); |
|
| 2866 | - |
|
| 2867 | - $this->_setNewPositionForNewLine(); |
|
| 2868 | - |
|
| 2869 | - return true; |
|
| 2870 | - } |
|
| 2871 | - |
|
| 2872 | - /** |
|
| 2873 | - * tag : BLOCKQUOTE |
|
| 2874 | - * mode : OPEN |
|
| 2875 | - * |
|
| 2876 | - * @param array $param |
|
| 2877 | - * @return boolean |
|
| 2878 | - */ |
|
| 2879 | - protected function _tag_open_BLOCKQUOTE($param) |
|
| 2880 | - { |
|
| 2881 | - return $this->_tag_open_DIV($param, 'blockquote'); |
|
| 2882 | - } |
|
| 2883 | - |
|
| 2884 | - /** |
|
| 2885 | - * tag : LEGEND |
|
| 2886 | - * mode : OPEN |
|
| 2887 | - * |
|
| 2888 | - * @param array $param |
|
| 2889 | - * @return boolean |
|
| 2890 | - */ |
|
| 2891 | - protected function _tag_open_LEGEND($param) |
|
| 2892 | - { |
|
| 2893 | - return $this->_tag_open_DIV($param, 'legend'); |
|
| 2894 | - } |
|
| 2895 | - |
|
| 2896 | - /** |
|
| 2897 | - * tag : FIELDSET |
|
| 2898 | - * mode : OPEN |
|
| 2899 | - * |
|
| 2900 | - * @author Pavel Kochman |
|
| 2901 | - * @param array $param |
|
| 2902 | - * @return boolean |
|
| 2903 | - */ |
|
| 2904 | - protected function _tag_open_FIELDSET($param) |
|
| 2905 | - { |
|
| 2906 | - |
|
| 2907 | - $this->parsingCss->save(); |
|
| 2908 | - $this->parsingCss->analyse('fieldset', $param); |
|
| 2909 | - |
|
| 2910 | - // get height of LEGEND element and make fieldset corrections |
|
| 2911 | - for ($tempPos = $this->_parsePos + 1; $tempPos<count($this->parsingHtml->code); $tempPos++) { |
|
| 2912 | - $action = $this->parsingHtml->code[$tempPos]; |
|
| 2913 | - if ($action['name'] == 'fieldset') break; |
|
| 2914 | - if ($action['name'] == 'legend' && !$action['close']) { |
|
| 2915 | - $legendOpenPos = $tempPos; |
|
| 2916 | - |
|
| 2917 | - $sub = null; |
|
| 2918 | - $this->_createSubHTML($sub); |
|
| 2919 | - $sub->parsingHtml->code = $this->parsingHtml->getLevel($tempPos - 1); |
|
| 2920 | - |
|
| 2921 | - $res = null; |
|
| 2922 | - for ($sub->_parsePos = 0; $sub->_parsePos<count($sub->parsingHtml->code); $sub->_parsePos++) { |
|
| 2923 | - $action = $sub->parsingHtml->code[$sub->_parsePos]; |
|
| 2924 | - $sub->_executeAction($action); |
|
| 2925 | - |
|
| 2926 | - if ($action['name'] == 'legend' && $action['close']) |
|
| 2927 | - break; |
|
| 2928 | - } |
|
| 2929 | - |
|
| 2930 | - $legendH = $sub->_maxY; |
|
| 2931 | - $this->_destroySubHTML($sub); |
|
| 2932 | - |
|
| 2933 | - $move = $this->parsingCss->value['padding']['t'] + $this->parsingCss->value['border']['t']['width'] + 0.03; |
|
| 2934 | - |
|
| 2935 | - $param['moveTop'] = $legendH / 2; |
|
| 2936 | - |
|
| 2937 | - $this->parsingHtml->code[$legendOpenPos]['param']['moveTop'] = - ($legendH / 2 + $move); |
|
| 2938 | - $this->parsingHtml->code[$legendOpenPos]['param']['moveLeft'] = 2 - $this->parsingCss->value['border']['l']['width'] - $this->parsingCss->value['padding']['l']; |
|
| 2939 | - $this->parsingHtml->code[$legendOpenPos]['param']['moveDown'] = $move; |
|
| 2940 | - break; |
|
| 2941 | - } |
|
| 2942 | - } |
|
| 2943 | - $this->parsingCss->load(); |
|
| 2944 | - |
|
| 2945 | - return $this->_tag_open_DIV($param, 'fieldset'); |
|
| 2946 | - } |
|
| 2947 | - |
|
| 2948 | - /** |
|
| 2949 | - * tag : DIV |
|
| 2950 | - * mode : CLOSE |
|
| 2951 | - * |
|
| 2952 | - * @param array $param |
|
| 2953 | - * @param string $other name of tag that used the div tag |
|
| 2954 | - * @return boolean |
|
| 2955 | - */ |
|
| 2956 | - protected function _tag_close_DIV($param, $other='div') |
|
| 2957 | - { |
|
| 2958 | - if ($this->_isForOneLine) return false; |
|
| 2959 | - |
|
| 2960 | - if ($this->parsingCss->value['overflow']=='hidden') { |
|
| 2961 | - $this->_maxX = $this->parsingCss->value['old_maxX']; |
|
| 2962 | - $this->_maxY = $this->parsingCss->value['old_maxY']; |
|
| 2963 | - $this->_maxH = $this->parsingCss->value['old_maxH']; |
|
| 2964 | - $this->_isInOverflow = $this->parsingCss->value['old_overflow']; |
|
| 2965 | - $this->pdf->clippingPathStop(); |
|
| 2966 | - } |
|
| 2967 | - |
|
| 2968 | - if ($this->parsingCss->value['rotate']) |
|
| 2969 | - $this->pdf->stopTransform(); |
|
| 2970 | - |
|
| 2971 | - $marge = array(); |
|
| 2972 | - $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03; |
|
| 2973 | - $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03; |
|
| 2974 | - $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03; |
|
| 2975 | - $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03; |
|
| 2976 | - |
|
| 2977 | - $x = $this->parsingCss->value['x']; |
|
| 2978 | - $y = $this->parsingCss->value['y']; |
|
| 2979 | - $w = $this->parsingCss->value['width']+$marge['l']+$marge['r']+$this->parsingCss->value['margin']['r']; |
|
| 2980 | - $h = $this->parsingCss->value['height']+$marge['t']+$marge['b']+$this->parsingCss->value['margin']['b']; |
|
| 2981 | - |
|
| 2982 | - switch($this->parsingCss->value['rotate']) |
|
| 2983 | - { |
|
| 2984 | - case 90: |
|
| 2985 | - $t = $w; $w = $h; $h = $t; |
|
| 2986 | - break; |
|
| 2987 | - |
|
| 2988 | - case 270: |
|
| 2989 | - $t = $w; $w = $h; $h = $t; |
|
| 2990 | - break; |
|
| 2991 | - |
|
| 2992 | - default: |
|
| 2993 | - break; |
|
| 2994 | - } |
|
| 2995 | - |
|
| 2996 | - |
|
| 2997 | - if ($this->parsingCss->value['position']!='absolute') { |
|
| 2998 | - $this->pdf->setXY($x+$w, $y); |
|
| 2999 | - |
|
| 3000 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 3001 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 3002 | - $this->_maxH = max($this->_maxH, $h); |
|
| 3003 | - } else { |
|
| 3004 | - $this->pdf->setXY($this->parsingCss->value['xc'], $this->parsingCss->value['yc']); |
|
| 3005 | - |
|
| 3006 | - $this->_loadMax(); |
|
| 3007 | - } |
|
| 3008 | - |
|
| 3009 | - $block = ($this->parsingCss->value['display']!='inline' && $this->parsingCss->value['position']!='absolute'); |
|
| 3010 | - |
|
| 3011 | - $this->parsingCss->load(); |
|
| 3012 | - $this->parsingCss->fontSet(); |
|
| 3013 | - $this->_loadMargin(); |
|
| 3014 | - |
|
| 3015 | - if ($block) $this->_tag_open_BR(array()); |
|
| 3016 | - if ($this->_debugActif) $this->_DEBUG_add(strtoupper($other), false); |
|
| 3017 | - |
|
| 3018 | - return true; |
|
| 3019 | - } |
|
| 3020 | - |
|
| 3021 | - /** |
|
| 3022 | - * tag : BLOCKQUOTE |
|
| 3023 | - * mode : CLOSE |
|
| 3024 | - * |
|
| 3025 | - * @param array $param |
|
| 3026 | - * @return boolean |
|
| 3027 | - */ |
|
| 3028 | - protected function _tag_close_BLOCKQUOTE($param) |
|
| 3029 | - { |
|
| 3030 | - return $this->_tag_close_DIV($param, 'blockquote'); |
|
| 3031 | - } |
|
| 3032 | - |
|
| 3033 | - /** |
|
| 3034 | - * tag : FIELDSET |
|
| 3035 | - * mode : CLOSE |
|
| 3036 | - * |
|
| 3037 | - * @param array $param |
|
| 3038 | - * @return boolean |
|
| 3039 | - */ |
|
| 3040 | - protected function _tag_close_FIELDSET($param) |
|
| 3041 | - { |
|
| 3042 | - return $this->_tag_close_DIV($param, 'fieldset'); |
|
| 3043 | - } |
|
| 3044 | - |
|
| 3045 | - /** |
|
| 3046 | - * tag : LEGEND |
|
| 3047 | - * mode : CLOSE |
|
| 3048 | - * |
|
| 3049 | - * @param array $param |
|
| 3050 | - * @return boolean |
|
| 3051 | - */ |
|
| 3052 | - protected function _tag_close_LEGEND($param) |
|
| 3053 | - { |
|
| 3054 | - return $this->_tag_close_DIV($param, 'legend'); |
|
| 3055 | - } |
|
| 3056 | - |
|
| 3057 | - /** |
|
| 3058 | - * tag : BARCODE |
|
| 3059 | - * mode : OPEN |
|
| 3060 | - * |
|
| 3061 | - * @param array $param |
|
| 3062 | - * @return boolean |
|
| 3063 | - */ |
|
| 3064 | - protected function _tag_open_BARCODE($param) |
|
| 3065 | - { |
|
| 3066 | - // for compatibility with old versions < 3.29 |
|
| 3067 | - $lstBarcode = array(); |
|
| 3068 | - $lstBarcode['UPC_A'] = 'UPCA'; |
|
| 3069 | - $lstBarcode['CODE39'] = 'C39'; |
|
| 3070 | - |
|
| 3071 | - if (!isset($param['type'])) $param['type'] = 'C39'; |
|
| 3072 | - if (!isset($param['value'])) $param['value'] = 0; |
|
| 3073 | - if (!isset($param['label'])) $param['label'] = 'label'; |
|
| 3074 | - if (!isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3075 | - |
|
| 3076 | - if ($this->_testIsDeprecated && (isset($param['bar_h']) || isset($param['bar_w']))) |
|
| 3077 | - throw new HTML2PDF_exception(9, array('BARCODE', 'bar_h, bar_w')); |
|
| 3078 | - |
|
| 3079 | - $param['type'] = strtoupper($param['type']); |
|
| 3080 | - if (isset($lstBarcode[$param['type']])) $param['type'] = $lstBarcode[$param['type']]; |
|
| 3081 | - |
|
| 3082 | - $this->parsingCss->save(); |
|
| 3083 | - $this->parsingCss->analyse('barcode', $param); |
|
| 3084 | - $this->parsingCss->setPosition(); |
|
| 3085 | - $this->parsingCss->fontSet(); |
|
| 3086 | - |
|
| 3087 | - $x = $this->pdf->getX(); |
|
| 3088 | - $y = $this->pdf->getY(); |
|
| 3089 | - $w = $this->parsingCss->value['width']; if (!$w) $w = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3090 | - $h = $this->parsingCss->value['height']; if (!$h) $h = $this->parsingCss->ConvertToMM('10mm'); |
|
| 3091 | - $txt = ($param['label']!=='none' ? $this->parsingCss->value['font-size'] : false); |
|
| 3092 | - $c = $this->parsingCss->value['color']; |
|
| 3093 | - $infos = $this->pdf->myBarcode($param['value'], $param['type'], $x, $y, $w, $h, $txt, $c); |
|
| 3094 | - |
|
| 3095 | - $this->_maxX = max($this->_maxX, $x+$infos[0]); |
|
| 3096 | - $this->_maxY = max($this->_maxY, $y+$infos[1]); |
|
| 3097 | - $this->_maxH = max($this->_maxH, $infos[1]); |
|
| 3098 | - $this->_maxE++; |
|
| 3099 | - |
|
| 3100 | - $this->pdf->setXY($x+$infos[0], $y); |
|
| 3101 | - |
|
| 3102 | - $this->parsingCss->load(); |
|
| 3103 | - $this->parsingCss->fontSet(); |
|
| 3104 | - |
|
| 3105 | - return true; |
|
| 3106 | - } |
|
| 3107 | - |
|
| 3108 | - /** |
|
| 3109 | - * tag : BARCODE |
|
| 3110 | - * mode : CLOSE |
|
| 3111 | - * |
|
| 3112 | - * @param array $param |
|
| 3113 | - * @return boolean |
|
| 3114 | - */ |
|
| 3115 | - protected function _tag_close_BARCODE($param) |
|
| 3116 | - { |
|
| 3117 | - // there is nothing to do here |
|
| 3118 | - |
|
| 3119 | - return true; |
|
| 3120 | - } |
|
| 3121 | - |
|
| 3122 | - /** |
|
| 3123 | - * tag : QRCODE |
|
| 3124 | - * mode : OPEN |
|
| 3125 | - * |
|
| 3126 | - * @param array $param |
|
| 3127 | - * @return boolean |
|
| 3128 | - */ |
|
| 3129 | - protected function _tag_open_QRCODE($param) |
|
| 3130 | - { |
|
| 3131 | - if ($this->_testIsDeprecated && (isset($param['size']) || isset($param['noborder']))) |
|
| 3132 | - throw new HTML2PDF_exception(9, array('QRCODE', 'size, noborder')); |
|
| 3133 | - |
|
| 3134 | - if ($this->_debugActif) $this->_DEBUG_add('QRCODE'); |
|
| 3135 | - |
|
| 3136 | - if (!isset($param['value'])) $param['value'] = ''; |
|
| 3137 | - if (!isset($param['ec'])) $param['ec'] = 'H'; |
|
| 3138 | - if (!isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3139 | - if (!isset($param['style']['background-color'])) $param['style']['background-color'] = '#FFFFFF'; |
|
| 3140 | - if (isset($param['style']['border'])) { |
|
| 3141 | - $borders = $param['style']['border']!='none'; |
|
| 3142 | - unset($param['style']['border']); |
|
| 3143 | - } else { |
|
| 3144 | - $borders = true; |
|
| 3145 | - } |
|
| 3146 | - |
|
| 3147 | - if ($param['value']==='') return true; |
|
| 3148 | - if (!in_array($param['ec'], array('L', 'M', 'Q', 'H'))) $param['ec'] = 'H'; |
|
| 3149 | - |
|
| 3150 | - $this->parsingCss->save(); |
|
| 3151 | - $this->parsingCss->analyse('qrcode', $param); |
|
| 3152 | - $this->parsingCss->setPosition(); |
|
| 3153 | - $this->parsingCss->fontSet(); |
|
| 3154 | - |
|
| 3155 | - $x = $this->pdf->getX(); |
|
| 3156 | - $y = $this->pdf->getY(); |
|
| 3157 | - $w = $this->parsingCss->value['width']; |
|
| 3158 | - $h = $this->parsingCss->value['height']; |
|
| 3159 | - $size = max($w, $h); if (!$size) $size = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3160 | - |
|
| 3161 | - $style = array( |
|
| 3162 | - 'fgcolor' => $this->parsingCss->value['color'], |
|
| 3163 | - 'bgcolor' => $this->parsingCss->value['background']['color'], |
|
| 3164 | - ); |
|
| 3165 | - |
|
| 3166 | - if ($borders) { |
|
| 3167 | - $style['border'] = true; |
|
| 3168 | - $style['padding'] = 'auto'; |
|
| 3169 | - } else { |
|
| 3170 | - $style['border'] = false; |
|
| 3171 | - $style['padding'] = 0; |
|
| 3172 | - } |
|
| 3173 | - |
|
| 3174 | - if (!$this->_subPart && !$this->_isSubPart) { |
|
| 3175 | - $this->pdf->write2DBarcode($param['value'], 'QRCODE,'.$param['ec'], $x, $y, $size, $size, $style); |
|
| 3176 | - } |
|
| 3177 | - |
|
| 3178 | - $this->_maxX = max($this->_maxX, $x+$size); |
|
| 3179 | - $this->_maxY = max($this->_maxY, $y+$size); |
|
| 3180 | - $this->_maxH = max($this->_maxH, $size); |
|
| 3181 | - $this->_maxE++; |
|
| 3182 | - |
|
| 3183 | - $this->pdf->setX($x+$size); |
|
| 3184 | - |
|
| 3185 | - $this->parsingCss->load(); |
|
| 3186 | - $this->parsingCss->fontSet(); |
|
| 3187 | - |
|
| 3188 | - return true; |
|
| 3189 | - } |
|
| 3190 | - |
|
| 3191 | - /** |
|
| 3192 | - * tag : QRCODE |
|
| 3193 | - * mode : CLOSE |
|
| 3194 | - * |
|
| 3195 | - * @param array $param |
|
| 3196 | - * @return boolean |
|
| 3197 | - */ |
|
| 3198 | - protected function _tag_close_QRCODE($param) |
|
| 3199 | - { |
|
| 3200 | - // there is nothing to do here |
|
| 3201 | - |
|
| 3202 | - return true; |
|
| 3203 | - } |
|
| 3204 | - |
|
| 3205 | - /** |
|
| 3206 | - * tag : BOOKMARK |
|
| 3207 | - * mode : OPEN |
|
| 3208 | - * |
|
| 3209 | - * @param array $param |
|
| 3210 | - * @return boolean |
|
| 3211 | - */ |
|
| 3212 | - protected function _tag_open_BOOKMARK($param) |
|
| 3213 | - { |
|
| 3214 | - $titre = isset($param['title']) ? trim($param['title']) : ''; |
|
| 3215 | - $level = isset($param['level']) ? floor($param['level']) : 0; |
|
| 3216 | - |
|
| 3217 | - if ($level<0) $level = 0; |
|
| 3218 | - if ($titre) $this->pdf->Bookmark($titre, $level, -1); |
|
| 3219 | - |
|
| 3220 | - return true; |
|
| 3221 | - } |
|
| 3222 | - |
|
| 3223 | - /** |
|
| 3224 | - * tag : BOOKMARK |
|
| 3225 | - * mode : CLOSE |
|
| 3226 | - * |
|
| 3227 | - * @param array $param |
|
| 3228 | - * @return boolean |
|
| 3229 | - */ |
|
| 3230 | - protected function _tag_close_BOOKMARK($param) |
|
| 3231 | - { |
|
| 3232 | - // there is nothing to do here |
|
| 3233 | - |
|
| 3234 | - return true; |
|
| 3235 | - } |
|
| 3236 | - |
|
| 3237 | - /** |
|
| 3238 | - * this is not a real TAG, it is just to write texts |
|
| 3239 | - * |
|
| 3240 | - * @param array $param |
|
| 3241 | - * @return boolean |
|
| 3242 | - */ |
|
| 3243 | - protected function _tag_open_WRITE($param) |
|
| 3244 | - { |
|
| 3245 | - $fill = ($this->parsingCss->value['background']['color']!==null && $this->parsingCss->value['background']['image']===null); |
|
| 3246 | - if (in_array($this->parsingCss->value['id_tag'], array('fieldset', 'legend', 'div', 'table', 'tr', 'td', 'th'))) { |
|
| 3247 | - $fill = false; |
|
| 3248 | - } |
|
| 3249 | - |
|
| 3250 | - // get the text to write |
|
| 3251 | - $txt = $param['txt']; |
|
| 3252 | - |
|
| 3253 | - if ($this->_isAfterFloat) { |
|
| 3254 | - $txt = ltrim($txt); |
|
| 3255 | - $this->_isAfterFloat = false; |
|
| 3256 | - } |
|
| 3257 | - |
|
| 3258 | - $txt = str_replace('[[page_nb]]', $this->pdf->getMyAliasNbPages(), $txt); |
|
| 3259 | - $txt = str_replace('[[page_cu]]', $this->pdf->getMyNumPage($this->_page), $txt); |
|
| 3260 | - |
|
| 3261 | - if ($this->parsingCss->value['text-transform']!='none') { |
|
| 3262 | - if ($this->parsingCss->value['text-transform']=='capitalize') |
|
| 3263 | - $txt = ucwords($txt); |
|
| 3264 | - else if ($this->parsingCss->value['text-transform']=='uppercase') |
|
| 3265 | - $txt = strtoupper($txt); |
|
| 3266 | - else if ($this->parsingCss->value['text-transform']=='lowercase') |
|
| 3267 | - $txt = strtolower($txt); |
|
| 3268 | - } |
|
| 3269 | - |
|
| 3270 | - // size of the text |
|
| 3271 | - $h = 1.08*$this->parsingCss->value['font-size']; |
|
| 3272 | - $dh = $h*$this->parsingCss->value['mini-decal']; |
|
| 3273 | - $lh = $this->parsingCss->getLineHeight(); |
|
| 3274 | - |
|
| 3275 | - // identify the align |
|
| 3276 | - $align = 'L'; |
|
| 3277 | - if ($this->parsingCss->value['text-align']=='li_right') { |
|
| 3278 | - $w = $this->parsingCss->value['width']; |
|
| 3279 | - $align = 'R'; |
|
| 3280 | - } |
|
| 3281 | - |
|
| 3282 | - // calculate the width of each words, and of all the sentence |
|
| 3283 | - $w = 0; |
|
| 3284 | - $words = explode(' ', $txt); |
|
| 3285 | - foreach ($words as $k => $word) { |
|
| 3286 | - $words[$k] = array($word, $this->pdf->GetStringWidth($word)); |
|
| 3287 | - $w+= $words[$k][1]; |
|
| 3288 | - } |
|
| 3289 | - $space = $this->pdf->GetStringWidth(' '); |
|
| 3290 | - $w+= $space*(count($words)-1); |
|
| 3291 | - |
|
| 3292 | - // position in the text |
|
| 3293 | - $currPos = 0; |
|
| 3294 | - |
|
| 3295 | - // the bigger width of the text, after automatic break line |
|
| 3296 | - $maxX = 0; |
|
| 3297 | - |
|
| 3298 | - // position of the text |
|
| 3299 | - $x = $this->pdf->getX(); |
|
| 3300 | - $y = $this->pdf->getY(); |
|
| 3301 | - $dy = $this->_getElementY($lh); |
|
| 3302 | - |
|
| 3303 | - // margins |
|
| 3304 | - list($left, $right) = $this->_getMargins($y); |
|
| 3305 | - |
|
| 3306 | - // number of lines after automatic break line |
|
| 3307 | - $nb = 0; |
|
| 3308 | - |
|
| 3309 | - // while we have words, and the text does not fit on the line => we cut the sentence |
|
| 3310 | - while ($x+$w>$right && $x<$right+$space && count($words)) { |
|
| 3311 | - // adding words 1 by 1 to fit on the line |
|
| 3312 | - $i=0; |
|
| 3313 | - $old = array('', 0); |
|
| 3314 | - $str = $words[0]; |
|
| 3315 | - $add = false; |
|
| 3316 | - while (($x+$str[1])<$right) { |
|
| 3317 | - $i++; |
|
| 3318 | - $add = true; |
|
| 3319 | - |
|
| 3320 | - array_shift($words); |
|
| 3321 | - $old = $str; |
|
| 3322 | - |
|
| 3323 | - if (!count($words)) break; |
|
| 3324 | - $str[0].= ' '.$words[0][0]; |
|
| 3325 | - $str[1]+= $space+$words[0][1]; |
|
| 3326 | - } |
|
| 3327 | - $str = $old; |
|
| 3328 | - |
|
| 3329 | - // 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 |
|
| 3330 | - if ($i==0 && (($left+$words[0][1])>=$right)) { |
|
| 3331 | - $str = $words[0]; |
|
| 3332 | - array_shift($words); |
|
| 3333 | - $i++; |
|
| 3334 | - $add = true; |
|
| 3335 | - } |
|
| 3336 | - $currPos+= ($currPos ? 1 : 0)+strlen($str[0]); |
|
| 3337 | - |
|
| 3338 | - // write the extract sentence that fit on the page |
|
| 3339 | - $wc = ($align=='L' ? $str[1] : $this->parsingCss->value['width']); |
|
| 3340 | - if ($right - $left<$wc) $wc = $right - $left; |
|
| 3341 | - |
|
| 3342 | - if (strlen($str[0])) { |
|
| 3343 | - $this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy); |
|
| 3344 | - $this->pdf->Cell($wc, $h, $str[0], 0, 0, $align, $fill, $this->_isInLink); |
|
| 3345 | - $this->pdf->setXY($this->pdf->getX(), $y); |
|
| 3346 | - } |
|
| 3347 | - $this->_maxH = max($this->_maxH, $lh); |
|
| 3348 | - |
|
| 3349 | - // max width |
|
| 3350 | - $maxX = max($maxX, $this->pdf->getX()); |
|
| 3351 | - |
|
| 3352 | - // new position and new width for the "while" |
|
| 3353 | - $w-= $str[1]; |
|
| 3354 | - $y = $this->pdf->getY(); |
|
| 3355 | - $x = $this->pdf->getX(); |
|
| 3356 | - $dy = $this->_getElementY($lh); |
|
| 3357 | - |
|
| 3358 | - // if we have again words to write |
|
| 3359 | - if (count($words)) { |
|
| 3360 | - // remove the space at the end |
|
| 3361 | - if ($add) $w-= $space; |
|
| 3362 | - |
|
| 3363 | - // if we don't add any word, and if the first word is empty => useless space to skip |
|
| 3364 | - if (!$add && $words[0][0]==='') { |
|
| 3365 | - array_shift($words); |
|
| 3366 | - } |
|
| 3367 | - |
|
| 3368 | - // if it is just to calculate for one line => adding the number of words |
|
| 3369 | - if ($this->_isForOneLine) { |
|
| 3370 | - $this->_maxE+= $i; |
|
| 3371 | - $this->_maxX = max($this->_maxX, $maxX); |
|
| 3372 | - return null; |
|
| 3373 | - } |
|
| 3374 | - |
|
| 3375 | - // automatic line break |
|
| 3376 | - $this->_tag_open_BR(array('style' => ''), $currPos); |
|
| 3377 | - |
|
| 3378 | - // new position |
|
| 3379 | - $y = $this->pdf->getY(); |
|
| 3380 | - $x = $this->pdf->getX(); |
|
| 3381 | - $dy = $this->_getElementY($lh); |
|
| 3382 | - |
|
| 3383 | - // if the next line does not fit on the page => new page |
|
| 3384 | - if ($y + $h>=$this->pdf->getH() - $this->pdf->getbMargin()) { |
|
| 3385 | - if (!$this->_isInOverflow && !$this->_isInFooter) { |
|
| 3386 | - $this->_setNewPage(null, '', null, $currPos); |
|
| 3387 | - $y = $this->pdf->getY(); |
|
| 3388 | - $x = $this->pdf->getX(); |
|
| 3389 | - $dy = $this->_getElementY($lh); |
|
| 3390 | - } |
|
| 3391 | - } |
|
| 3392 | - |
|
| 3393 | - // if more than 10000 line => error |
|
| 3394 | - $nb++; |
|
| 3395 | - if ($nb>10000) { |
|
| 3396 | - $txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0]; |
|
| 3397 | - throw new HTML2PDF_exception(2, array($txt, $right-$left, $w)); |
|
| 3398 | - } |
|
| 3399 | - |
|
| 3400 | - // new margins for the new line |
|
| 3401 | - list($left, $right) = $this->_getMargins($y); |
|
| 3402 | - } |
|
| 3403 | - } |
|
| 3404 | - |
|
| 3405 | - // if we have words after automatic cut, it is because they fit on the line => we write the text |
|
| 3406 | - if (count($words)) { |
|
| 3407 | - $txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0]; |
|
| 3408 | - $w+= $this->pdf->getWordSpacing()*(count($words)); |
|
| 3409 | - $this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy); |
|
| 3410 | - $this->pdf->Cell(($align=='L' ? $w : $this->parsingCss->value['width']), $h, $txt, 0, 0, $align, $fill, $this->_isInLink); |
|
| 3411 | - $this->pdf->setXY($this->pdf->getX(), $y); |
|
| 3412 | - $this->_maxH = max($this->_maxH, $lh); |
|
| 3413 | - $this->_maxE+= count($words); |
|
| 3414 | - } |
|
| 3415 | - |
|
| 3416 | - $maxX = max($maxX, $this->pdf->getX()); |
|
| 3417 | - $maxY = $this->pdf->getY()+$h; |
|
| 3418 | - |
|
| 3419 | - $this->_maxX = max($this->_maxX, $maxX); |
|
| 3420 | - $this->_maxY = max($this->_maxY, $maxY); |
|
| 3421 | - |
|
| 3422 | - return true; |
|
| 3423 | - } |
|
| 3424 | - |
|
| 3425 | - /** |
|
| 3426 | - * tag : BR |
|
| 3427 | - * mode : OPEN |
|
| 3428 | - * |
|
| 3429 | - * @param array $param |
|
| 3430 | - * @param integer $curr real position in the html parseur (if break line in the write of a text) |
|
| 3431 | - * @return boolean |
|
| 3432 | - */ |
|
| 3433 | - protected function _tag_open_BR($param, $curr = null) |
|
| 3434 | - { |
|
| 3435 | - if ($this->_isForOneLine) return false; |
|
| 3436 | - |
|
| 3437 | - $h = max($this->_maxH, $this->parsingCss->getLineHeight()); |
|
| 3438 | - |
|
| 3439 | - if ($this->_maxH==0) $this->_maxY = max($this->_maxY, $this->pdf->getY()+$h); |
|
| 3440 | - |
|
| 3441 | - $this->_makeBreakLine($h, $curr); |
|
| 3442 | - |
|
| 3443 | - $this->_maxH = 0; |
|
| 3444 | - $this->_maxE = 0; |
|
| 3445 | - |
|
| 3446 | - return true; |
|
| 3447 | - } |
|
| 3448 | - |
|
| 3449 | - /** |
|
| 3450 | - * tag : HR |
|
| 3451 | - * mode : OPEN |
|
| 3452 | - * |
|
| 3453 | - * @param array $param |
|
| 3454 | - * @return boolean |
|
| 3455 | - */ |
|
| 3456 | - protected function _tag_open_HR($param) |
|
| 3457 | - { |
|
| 3458 | - if ($this->_isForOneLine) return false; |
|
| 3459 | - $oldAlign = $this->parsingCss->value['text-align']; |
|
| 3460 | - $this->parsingCss->value['text-align'] = 'left'; |
|
| 3461 | - |
|
| 3462 | - if ($this->_maxH) $this->_tag_open_BR($param); |
|
| 3463 | - |
|
| 3464 | - $fontSize = $this->parsingCss->value['font-size']; |
|
| 3465 | - $this->parsingCss->value['font-size']=$fontSize*0.5; $this->_tag_open_BR($param); |
|
| 3466 | - $this->parsingCss->value['font-size']=0; |
|
| 3467 | - |
|
| 3468 | - $param['style']['width'] = '100%'; |
|
| 3469 | - |
|
| 3470 | - $this->parsingCss->save(); |
|
| 3471 | - $this->parsingCss->value['height']=$this->parsingCss->ConvertToMM('1mm'); |
|
| 3472 | - |
|
| 3473 | - $this->parsingCss->analyse('hr', $param); |
|
| 3474 | - $this->parsingCss->setPosition(); |
|
| 3475 | - $this->parsingCss->fontSet(); |
|
| 3476 | - |
|
| 3477 | - $h = $this->parsingCss->value['height']; |
|
| 3478 | - if ($h) $h-= $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width']; |
|
| 3479 | - if ($h<=0) $h = $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width']; |
|
| 3480 | - |
|
| 3481 | - $this->_drawRectangle($this->pdf->getX(), $this->pdf->getY(), $this->parsingCss->value['width'], $h, $this->parsingCss->value['border'], 0, 0, $this->parsingCss->value['background']); |
|
| 3482 | - $this->_maxH = $h; |
|
| 3483 | - |
|
| 3484 | - $this->parsingCss->load(); |
|
| 3485 | - $this->parsingCss->fontSet(); |
|
| 3486 | - |
|
| 3487 | - $this->_tag_open_BR($param); |
|
| 3488 | - |
|
| 3489 | - $this->parsingCss->value['font-size']=$fontSize*0.5; $this->_tag_open_BR($param); |
|
| 3490 | - $this->parsingCss->value['font-size']=$fontSize; |
|
| 3491 | - |
|
| 3492 | - $this->parsingCss->value['text-align'] = $oldAlign; |
|
| 3493 | - $this->_setNewPositionForNewLine(); |
|
| 3494 | - |
|
| 3495 | - return true; |
|
| 3496 | - } |
|
| 3497 | - |
|
| 3498 | - /** |
|
| 3499 | - * tag : B |
|
| 3500 | - * mode : OPEN |
|
| 3501 | - * |
|
| 3502 | - * @param array $param |
|
| 3503 | - * @param string $other |
|
| 3504 | - * @return boolean |
|
| 3505 | - */ |
|
| 3506 | - protected function _tag_open_B($param, $other = 'b') |
|
| 3507 | - { |
|
| 3508 | - $this->parsingCss->save(); |
|
| 3509 | - $this->parsingCss->value['font-bold'] = true; |
|
| 3510 | - $this->parsingCss->analyse($other, $param); |
|
| 3511 | - $this->parsingCss->setPosition(); |
|
| 3512 | - $this->parsingCss->fontSet(); |
|
| 3513 | - |
|
| 3514 | - return true; |
|
| 3515 | - } |
|
| 3516 | - |
|
| 3517 | - /** |
|
| 3518 | - * tag : STRONG |
|
| 3519 | - * mode : OPEN |
|
| 3520 | - * |
|
| 3521 | - * @param array $param |
|
| 3522 | - * @return boolean |
|
| 3523 | - */ |
|
| 3524 | - protected function _tag_open_STRONG($param) |
|
| 3525 | - { |
|
| 3526 | - return $this->_tag_open_B($param, 'strong'); |
|
| 3527 | - } |
|
| 3528 | - |
|
| 3529 | - /** |
|
| 3530 | - * tag : B |
|
| 3531 | - * mode : CLOSE |
|
| 3532 | - * |
|
| 3533 | - * @param array $param |
|
| 3534 | - * @return boolean |
|
| 3535 | - */ |
|
| 3536 | - protected function _tag_close_B($param) |
|
| 3537 | - { |
|
| 3538 | - $this->parsingCss->load(); |
|
| 3539 | - $this->parsingCss->fontSet(); |
|
| 3540 | - |
|
| 3541 | - return true; |
|
| 3542 | - } |
|
| 3543 | - |
|
| 3544 | - /** |
|
| 3545 | - * tag : STRONG |
|
| 3546 | - * mode : CLOSE |
|
| 3547 | - * |
|
| 3548 | - * @param array $param |
|
| 3549 | - * @return boolean |
|
| 3550 | - */ |
|
| 3551 | - protected function _tag_close_STRONG($param) |
|
| 3552 | - { |
|
| 3553 | - return $this->_tag_close_B($param); |
|
| 3554 | - } |
|
| 3555 | - |
|
| 3556 | - /** |
|
| 3557 | - * tag : I |
|
| 3558 | - * mode : OPEN |
|
| 3559 | - * |
|
| 3560 | - * @param array $param |
|
| 3561 | - * @param string $other |
|
| 3562 | - * @return boolean |
|
| 3563 | - */ |
|
| 3564 | - protected function _tag_open_I($param, $other = 'i') |
|
| 3565 | - { |
|
| 3566 | - $this->parsingCss->save(); |
|
| 3567 | - $this->parsingCss->value['font-italic'] = true; |
|
| 3568 | - $this->parsingCss->analyse($other, $param); |
|
| 3569 | - $this->parsingCss->setPosition(); |
|
| 3570 | - $this->parsingCss->fontSet(); |
|
| 3571 | - |
|
| 3572 | - return true; |
|
| 3573 | - } |
|
| 3574 | - |
|
| 3575 | - /** |
|
| 3576 | - * tag : ADDRESS |
|
| 3577 | - * mode : OPEN |
|
| 3578 | - * |
|
| 3579 | - * @param array $param |
|
| 3580 | - * @return boolean |
|
| 3581 | - */ |
|
| 3582 | - protected function _tag_open_ADDRESS($param) |
|
| 3583 | - { |
|
| 3584 | - return $this->_tag_open_I($param, 'address'); |
|
| 3585 | - } |
|
| 3586 | - |
|
| 3587 | - /** |
|
| 3588 | - * tag : CITE |
|
| 3589 | - * mode : OPEN |
|
| 3590 | - * |
|
| 3591 | - * @param array $param |
|
| 3592 | - * @return boolean |
|
| 3593 | - */ |
|
| 3594 | - protected function _tag_open_CITE($param) |
|
| 3595 | - { |
|
| 3596 | - return $this->_tag_open_I($param, 'cite'); |
|
| 3597 | - } |
|
| 3598 | - |
|
| 3599 | - /** |
|
| 3600 | - * tag : EM |
|
| 3601 | - * mode : OPEN |
|
| 3602 | - * |
|
| 3603 | - * @param array $param |
|
| 3604 | - * @return boolean |
|
| 3605 | - */ |
|
| 3606 | - protected function _tag_open_EM($param) |
|
| 3607 | - { |
|
| 3608 | - return $this->_tag_open_I($param, 'em'); |
|
| 3609 | - } |
|
| 3610 | - |
|
| 3611 | - /** |
|
| 3612 | - * tag : SAMP |
|
| 3613 | - * mode : OPEN |
|
| 3614 | - * |
|
| 3615 | - * @param array $param |
|
| 3616 | - * @return boolean |
|
| 3617 | - */ |
|
| 3618 | - protected function _tag_open_SAMP($param) |
|
| 3619 | - { |
|
| 3620 | - return $this->_tag_open_I($param, 'samp'); |
|
| 3621 | - } |
|
| 3622 | - |
|
| 3623 | - /** |
|
| 3624 | - * tag : I |
|
| 3625 | - * mode : CLOSE |
|
| 3626 | - * |
|
| 3627 | - * @param array $param |
|
| 3628 | - * @return boolean |
|
| 3629 | - */ |
|
| 3630 | - protected function _tag_close_I($param) |
|
| 3631 | - { |
|
| 3632 | - $this->parsingCss->load(); |
|
| 3633 | - $this->parsingCss->fontSet(); |
|
| 3634 | - |
|
| 3635 | - return true; |
|
| 3636 | - } |
|
| 3637 | - |
|
| 3638 | - /** |
|
| 3639 | - * tag : ADDRESS |
|
| 3640 | - * mode : CLOSE |
|
| 3641 | - * |
|
| 3642 | - * @param array $param |
|
| 3643 | - * @return boolean |
|
| 3644 | - */ |
|
| 3645 | - protected function _tag_close_ADDRESS($param) |
|
| 3646 | - { |
|
| 3647 | - return $this->_tag_close_I($param); |
|
| 3648 | - } |
|
| 3649 | - |
|
| 3650 | - /** |
|
| 3651 | - * tag : CITE |
|
| 3652 | - * mode : CLOSE |
|
| 3653 | - * |
|
| 3654 | - * @param array $param |
|
| 3655 | - * @return boolean |
|
| 3656 | - */ |
|
| 3657 | - protected function _tag_close_CITE($param) |
|
| 3658 | - { |
|
| 3659 | - return $this->_tag_close_I($param); |
|
| 3660 | - } |
|
| 3661 | - |
|
| 3662 | - /** |
|
| 3663 | - * tag : EM |
|
| 3664 | - * mode : CLOSE |
|
| 3665 | - * |
|
| 3666 | - * @param array $param |
|
| 3667 | - * @return boolean |
|
| 3668 | - */ |
|
| 3669 | - protected function _tag_close_EM($param) |
|
| 3670 | - { |
|
| 3671 | - return $this->_tag_close_I($param); |
|
| 3672 | - } |
|
| 3673 | - |
|
| 3674 | - /** |
|
| 3675 | - * tag : SAMP |
|
| 3676 | - * mode : CLOSE |
|
| 3677 | - * |
|
| 3678 | - * @param array $param |
|
| 3679 | - * @return boolean |
|
| 3680 | - */ |
|
| 3681 | - protected function _tag_close_SAMP($param) |
|
| 3682 | - { |
|
| 3683 | - return $this->_tag_close_I($param); |
|
| 3684 | - } |
|
| 3685 | - |
|
| 3686 | - /** |
|
| 3687 | - * tag : S |
|
| 3688 | - * mode : OPEN |
|
| 3689 | - * |
|
| 3690 | - * @param array $param |
|
| 3691 | - * @param string $other |
|
| 3692 | - * @return boolean |
|
| 3693 | - */ |
|
| 3694 | - protected function _tag_open_S($param, $other = 's') |
|
| 3695 | - { |
|
| 3696 | - $this->parsingCss->save(); |
|
| 3697 | - $this->parsingCss->value['font-linethrough'] = true; |
|
| 3698 | - $this->parsingCss->analyse($other, $param); |
|
| 3699 | - $this->parsingCss->setPosition(); |
|
| 3700 | - $this->parsingCss->fontSet(); |
|
| 3701 | - |
|
| 3702 | - return true; |
|
| 3703 | - } |
|
| 3704 | - |
|
| 3705 | - /** |
|
| 3706 | - * tag : DEL |
|
| 3707 | - * mode : OPEN |
|
| 3708 | - * |
|
| 3709 | - * @param array $param |
|
| 3710 | - * @return boolean |
|
| 3711 | - */ |
|
| 3712 | - protected function _tag_open_DEL($param) |
|
| 3713 | - { |
|
| 3714 | - return $this->_tag_open_S($param, 'del'); |
|
| 3715 | - } |
|
| 3716 | - |
|
| 3717 | - /** |
|
| 3718 | - * tag : S |
|
| 3719 | - * mode : CLOSE |
|
| 3720 | - * |
|
| 3721 | - * @param array $param |
|
| 3722 | - * @return boolean |
|
| 3723 | - */ |
|
| 3724 | - protected function _tag_close_S($param) |
|
| 3725 | - { |
|
| 3726 | - $this->parsingCss->load(); |
|
| 3727 | - $this->parsingCss->fontSet(); |
|
| 3728 | - |
|
| 3729 | - return true; |
|
| 3730 | - } |
|
| 3731 | - |
|
| 3732 | - /** |
|
| 3733 | - * tag : DEL |
|
| 3734 | - * mode : CLOSE |
|
| 3735 | - * |
|
| 3736 | - * @param array $param |
|
| 3737 | - * @return boolean |
|
| 3738 | - */ |
|
| 3739 | - protected function _tag_close_DEL($param) |
|
| 3740 | - { |
|
| 3741 | - return $this->_tag_close_S($param); |
|
| 3742 | - } |
|
| 3743 | - |
|
| 3744 | - /** |
|
| 3745 | - * tag : U |
|
| 3746 | - * mode : OPEN |
|
| 3747 | - * |
|
| 3748 | - * @param array $param |
|
| 3749 | - * @param string $other |
|
| 3750 | - * @return boolean |
|
| 3751 | - */ |
|
| 3752 | - protected function _tag_open_U($param, $other='u') |
|
| 3753 | - { |
|
| 3754 | - $this->parsingCss->save(); |
|
| 3755 | - $this->parsingCss->value['font-underline'] = true; |
|
| 3756 | - $this->parsingCss->analyse($other, $param); |
|
| 3757 | - $this->parsingCss->setPosition(); |
|
| 3758 | - $this->parsingCss->fontSet(); |
|
| 3759 | - |
|
| 3760 | - return true; |
|
| 3761 | - } |
|
| 3762 | - |
|
| 3763 | - /** |
|
| 3764 | - * tag : INS |
|
| 3765 | - * mode : OPEN |
|
| 3766 | - * |
|
| 3767 | - * @param array $param |
|
| 3768 | - * @return boolean |
|
| 3769 | - */ |
|
| 3770 | - protected function _tag_open_INS($param) |
|
| 3771 | - { |
|
| 3772 | - return $this->_tag_open_U($param, 'ins'); |
|
| 3773 | - } |
|
| 3774 | - |
|
| 3775 | - /** |
|
| 3776 | - * tag : U |
|
| 3777 | - * mode : CLOSE |
|
| 3778 | - * |
|
| 3779 | - * @param array $param |
|
| 3780 | - * @return boolean |
|
| 3781 | - */ |
|
| 3782 | - protected function _tag_close_U($param) |
|
| 3783 | - { |
|
| 3784 | - $this->parsingCss->load(); |
|
| 3785 | - $this->parsingCss->fontSet(); |
|
| 3786 | - |
|
| 3787 | - return true; |
|
| 3788 | - } |
|
| 3789 | - |
|
| 3790 | - /** |
|
| 3791 | - * tag : INS |
|
| 3792 | - * mode : CLOSE |
|
| 3793 | - * |
|
| 3794 | - * @param array $param |
|
| 3795 | - * @return boolean |
|
| 3796 | - */ |
|
| 3797 | - protected function _tag_close_INS($param) |
|
| 3798 | - { |
|
| 3799 | - return $this->_tag_close_U($param); |
|
| 3800 | - } |
|
| 3801 | - |
|
| 3802 | - /** |
|
| 3803 | - * tag : A |
|
| 3804 | - * mode : OPEN |
|
| 3805 | - * |
|
| 3806 | - * @param array $param |
|
| 3807 | - * @return boolean |
|
| 3808 | - */ |
|
| 3809 | - protected function _tag_open_A($param) |
|
| 3810 | - { |
|
| 3811 | - $this->_isInLink = str_replace('&', '&', isset($param['href']) ? $param['href'] : ''); |
|
| 3812 | - |
|
| 3813 | - if (isset($param['name'])) { |
|
| 3814 | - $name = $param['name']; |
|
| 3815 | - if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 3816 | - |
|
| 3817 | - if (!$this->_lstAnchor[$name][1]) { |
|
| 3818 | - $this->_lstAnchor[$name][1] = true; |
|
| 3819 | - $this->pdf->SetLink($this->_lstAnchor[$name][0], -1, -1); |
|
| 3820 | - } |
|
| 3821 | - } |
|
| 3822 | - |
|
| 3823 | - if (preg_match('/^#([^#]+)$/isU', $this->_isInLink, $match)) { |
|
| 3824 | - $name = $match[1]; |
|
| 3825 | - if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 3826 | - |
|
| 3827 | - $this->_isInLink = $this->_lstAnchor[$name][0]; |
|
| 3828 | - } |
|
| 3829 | - |
|
| 3830 | - $this->parsingCss->save(); |
|
| 3831 | - $this->parsingCss->value['font-underline'] = true; |
|
| 3832 | - $this->parsingCss->value['color'] = array(20, 20, 250); |
|
| 3833 | - $this->parsingCss->analyse('a', $param); |
|
| 3834 | - $this->parsingCss->setPosition(); |
|
| 3835 | - $this->parsingCss->fontSet(); |
|
| 3836 | - |
|
| 3837 | - return true; |
|
| 3838 | - } |
|
| 3839 | - |
|
| 3840 | - /** |
|
| 3841 | - * tag : A |
|
| 3842 | - * mode : CLOSE |
|
| 3843 | - * |
|
| 3844 | - * @param array $param |
|
| 3845 | - * @return boolean |
|
| 3846 | - */ |
|
| 3847 | - protected function _tag_close_A($param) |
|
| 3848 | - { |
|
| 3849 | - $this->_isInLink = ''; |
|
| 3850 | - $this->parsingCss->load(); |
|
| 3851 | - $this->parsingCss->fontSet(); |
|
| 3852 | - |
|
| 3853 | - return true; |
|
| 3854 | - } |
|
| 3855 | - |
|
| 3856 | - /** |
|
| 3857 | - * tag : H1 |
|
| 3858 | - * mode : OPEN |
|
| 3859 | - * |
|
| 3860 | - * @param array $param |
|
| 3861 | - * @param string $other |
|
| 3862 | - * @return boolean |
|
| 3863 | - */ |
|
| 3864 | - protected function _tag_open_H1($param, $other = 'h1') |
|
| 3865 | - { |
|
| 3866 | - if ($this->_isForOneLine) return false; |
|
| 3867 | - |
|
| 3868 | - if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 3869 | - $this->parsingCss->save(); |
|
| 3870 | - $this->parsingCss->value['font-bold'] = true; |
|
| 3871 | - |
|
| 3872 | - $size = array('h1' => '28px', 'h2' => '24px', 'h3' => '20px', 'h4' => '16px', 'h5' => '12px', 'h6' => '9px'); |
|
| 3873 | - $this->parsingCss->value['margin']['l'] = 0; |
|
| 3874 | - $this->parsingCss->value['margin']['r'] = 0; |
|
| 3875 | - $this->parsingCss->value['margin']['t'] = $this->parsingCss->ConvertToMM('16px'); |
|
| 3876 | - $this->parsingCss->value['margin']['b'] = $this->parsingCss->ConvertToMM('16px'); |
|
| 3877 | - $this->parsingCss->value['font-size'] = $this->parsingCss->ConvertToMM($size[$other]); |
|
| 3878 | - |
|
| 3879 | - $this->parsingCss->analyse($other, $param); |
|
| 3880 | - $this->parsingCss->setPosition(); |
|
| 3881 | - $this->parsingCss->fontSet(); |
|
| 3882 | - $this->_setNewPositionForNewLine(); |
|
| 3883 | - |
|
| 3884 | - return true; |
|
| 3885 | - } |
|
| 3886 | - |
|
| 3887 | - /** |
|
| 3888 | - * tag : H2 |
|
| 3889 | - * mode : OPEN |
|
| 3890 | - * |
|
| 3891 | - * @param array $param |
|
| 3892 | - * @return boolean |
|
| 3893 | - */ |
|
| 3894 | - protected function _tag_open_H2($param) |
|
| 3895 | - { |
|
| 3896 | - return $this->_tag_open_H1($param, 'h2'); |
|
| 3897 | - } |
|
| 3898 | - |
|
| 3899 | - /** |
|
| 3900 | - * tag : H3 |
|
| 3901 | - * mode : OPEN |
|
| 3902 | - * |
|
| 3903 | - * @param array $param |
|
| 3904 | - * @return boolean |
|
| 3905 | - */ |
|
| 3906 | - protected function _tag_open_H3($param) |
|
| 3907 | - { |
|
| 3908 | - return $this->_tag_open_H1($param, 'h3'); |
|
| 3909 | - } |
|
| 3910 | - |
|
| 3911 | - /** |
|
| 3912 | - * tag : H4 |
|
| 3913 | - * mode : OPEN |
|
| 3914 | - * |
|
| 3915 | - * @param array $param |
|
| 3916 | - * @return boolean |
|
| 3917 | - */ |
|
| 3918 | - protected function _tag_open_H4($param) |
|
| 3919 | - { |
|
| 3920 | - return $this->_tag_open_H1($param, 'h4'); |
|
| 3921 | - } |
|
| 3922 | - |
|
| 3923 | - /** |
|
| 3924 | - * tag : H5 |
|
| 3925 | - * mode : OPEN |
|
| 3926 | - * |
|
| 3927 | - * @param array $param |
|
| 3928 | - * @return boolean |
|
| 3929 | - */ |
|
| 3930 | - protected function _tag_open_H5($param) |
|
| 3931 | - { |
|
| 3932 | - return $this->_tag_open_H1($param, 'h5'); |
|
| 3933 | - } |
|
| 3934 | - |
|
| 3935 | - /** |
|
| 3936 | - * tag : H6 |
|
| 3937 | - * mode : OPEN |
|
| 3938 | - * |
|
| 3939 | - * @param array $param |
|
| 3940 | - * @return boolean |
|
| 3941 | - */ |
|
| 3942 | - protected function _tag_open_H6($param) |
|
| 3943 | - { |
|
| 3944 | - return $this->_tag_open_H1($param, 'h6'); |
|
| 3945 | - } |
|
| 3946 | - |
|
| 3947 | - /** |
|
| 3948 | - * tag : H1 |
|
| 3949 | - * mode : CLOSE |
|
| 3950 | - * |
|
| 3951 | - * @param array $param |
|
| 3952 | - * @return boolean |
|
| 3953 | - */ |
|
| 3954 | - protected function _tag_close_H1($param) |
|
| 3955 | - { |
|
| 3956 | - if ($this->_isForOneLine) return false; |
|
| 3957 | - |
|
| 3958 | - $this->_maxH+= $this->parsingCss->value['margin']['b']; |
|
| 3959 | - $h = max($this->_maxH, $this->parsingCss->getLineHeight()); |
|
| 3960 | - |
|
| 3961 | - $this->parsingCss->load(); |
|
| 3962 | - $this->parsingCss->fontSet(); |
|
| 3963 | - |
|
| 3964 | - $this->_makeBreakLine($h); |
|
| 3965 | - $this->_maxH = 0; |
|
| 3966 | - |
|
| 3967 | - $this->_maxY = max($this->_maxY, $this->pdf->getY()); |
|
| 3968 | - |
|
| 3969 | - return true; |
|
| 3970 | - } |
|
| 3971 | - |
|
| 3972 | - /** |
|
| 3973 | - * tag : H2 |
|
| 3974 | - * mode : CLOSE |
|
| 3975 | - * |
|
| 3976 | - * @param array $param |
|
| 3977 | - * @return boolean |
|
| 3978 | - */ |
|
| 3979 | - protected function _tag_close_H2($param) |
|
| 3980 | - { |
|
| 3981 | - return $this->_tag_close_H1($param); |
|
| 3982 | - } |
|
| 3983 | - |
|
| 3984 | - /** |
|
| 3985 | - * tag : H3 |
|
| 3986 | - * mode : CLOSE |
|
| 3987 | - * |
|
| 3988 | - * @param array $param |
|
| 3989 | - * @return boolean |
|
| 3990 | - */ |
|
| 3991 | - protected function _tag_close_H3($param) |
|
| 3992 | - { |
|
| 3993 | - return $this->_tag_close_H1($param); |
|
| 3994 | - } |
|
| 3995 | - |
|
| 3996 | - /** |
|
| 3997 | - * tag : H4 |
|
| 3998 | - * mode : CLOSE |
|
| 3999 | - * |
|
| 4000 | - * @param array $param |
|
| 4001 | - * @return boolean |
|
| 4002 | - */ |
|
| 4003 | - protected function _tag_close_H4($param) |
|
| 4004 | - { |
|
| 4005 | - return $this->_tag_close_H1($param); |
|
| 4006 | - } |
|
| 4007 | - |
|
| 4008 | - /** |
|
| 4009 | - * tag : H5 |
|
| 4010 | - * mode : CLOSE |
|
| 4011 | - * |
|
| 4012 | - * @param array $param |
|
| 4013 | - * @return boolean |
|
| 4014 | - */ |
|
| 4015 | - protected function _tag_close_H5($param) |
|
| 4016 | - { |
|
| 4017 | - return $this->_tag_close_H1($param); |
|
| 4018 | - } |
|
| 4019 | - |
|
| 4020 | - /** |
|
| 4021 | - * tag : H6 |
|
| 4022 | - * mode : CLOSE |
|
| 4023 | - * |
|
| 4024 | - * @param array $param |
|
| 4025 | - * @return boolean |
|
| 4026 | - */ |
|
| 4027 | - protected function _tag_close_H6($param) |
|
| 4028 | - { |
|
| 4029 | - return $this->_tag_close_H1($param); |
|
| 4030 | - } |
|
| 4031 | - |
|
| 4032 | - /** |
|
| 4033 | - * tag : SPAN |
|
| 4034 | - * mode : OPEN |
|
| 4035 | - * |
|
| 4036 | - * @param array $param |
|
| 4037 | - * @param string $other |
|
| 4038 | - * @return boolean |
|
| 4039 | - */ |
|
| 4040 | - protected function _tag_open_SPAN($param, $other = 'span') |
|
| 4041 | - { |
|
| 4042 | - $this->parsingCss->save(); |
|
| 4043 | - $this->parsingCss->analyse($other, $param); |
|
| 4044 | - $this->parsingCss->setPosition(); |
|
| 4045 | - $this->parsingCss->fontSet(); |
|
| 4046 | - |
|
| 4047 | - return true; |
|
| 4048 | - } |
|
| 4049 | - |
|
| 4050 | - /** |
|
| 4051 | - * tag : FONT |
|
| 4052 | - * mode : OPEN |
|
| 4053 | - * |
|
| 4054 | - * @param array $param |
|
| 4055 | - * @return boolean |
|
| 4056 | - */ |
|
| 4057 | - protected function _tag_open_FONT($param) |
|
| 4058 | - { |
|
| 4059 | - return $this->_tag_open_SPAN($param, 'font'); |
|
| 4060 | - } |
|
| 4061 | - |
|
| 4062 | - /** |
|
| 4063 | - * tag : LABEL |
|
| 4064 | - * mode : OPEN |
|
| 4065 | - * |
|
| 4066 | - * @param array $param |
|
| 4067 | - * @return boolean |
|
| 4068 | - */ |
|
| 4069 | - protected function _tag_open_LABEL($param) |
|
| 4070 | - { |
|
| 4071 | - return $this->_tag_open_SPAN($param, 'label'); |
|
| 4072 | - } |
|
| 4073 | - |
|
| 4074 | - /** |
|
| 4075 | - * tag : SPAN |
|
| 4076 | - * mode : CLOSE |
|
| 4077 | - * |
|
| 4078 | - * @param array $param |
|
| 4079 | - * @return boolean |
|
| 4080 | - */ |
|
| 4081 | - protected function _tag_close_SPAN($param) |
|
| 4082 | - { |
|
| 4083 | - $this->parsingCss->restorePosition(); |
|
| 4084 | - $this->parsingCss->load(); |
|
| 4085 | - $this->parsingCss->fontSet(); |
|
| 4086 | - |
|
| 4087 | - return true; |
|
| 4088 | - } |
|
| 4089 | - |
|
| 4090 | - /** |
|
| 4091 | - * tag : FONT |
|
| 4092 | - * mode : CLOSE |
|
| 4093 | - * |
|
| 4094 | - * @param array $param |
|
| 4095 | - * @return boolean |
|
| 4096 | - */ |
|
| 4097 | - protected function _tag_close_FONT($param) |
|
| 4098 | - { |
|
| 4099 | - return $this->_tag_close_SPAN($param); |
|
| 4100 | - } |
|
| 4101 | - |
|
| 4102 | - /** |
|
| 4103 | - * tag : LABEL |
|
| 4104 | - * mode : CLOSE |
|
| 4105 | - * |
|
| 4106 | - * @param array $param |
|
| 4107 | - * @return boolean |
|
| 4108 | - */ |
|
| 4109 | - protected function _tag_close_LABEL($param) |
|
| 4110 | - { |
|
| 4111 | - return $this->_tag_close_SPAN($param); |
|
| 4112 | - } |
|
| 4113 | - |
|
| 4114 | - /** |
|
| 4115 | - * tag : P |
|
| 4116 | - * mode : OPEN |
|
| 4117 | - * |
|
| 4118 | - * @param array $param |
|
| 4119 | - * @return boolean |
|
| 4120 | - */ |
|
| 4121 | - protected function _tag_open_P($param) |
|
| 4122 | - { |
|
| 4123 | - if ($this->_isForOneLine) return false; |
|
| 4124 | - |
|
| 4125 | - if (!in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
|
| 4126 | - if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4127 | - } |
|
| 4128 | - |
|
| 4129 | - $this->parsingCss->save(); |
|
| 4130 | - $this->parsingCss->analyse('p', $param); |
|
| 4131 | - $this->parsingCss->setPosition(); |
|
| 4132 | - $this->parsingCss->fontSet(); |
|
| 4133 | - |
|
| 4134 | - // cancel the effects of the setPosition |
|
| 4135 | - $this->pdf->setXY($this->pdf->getX()-$this->parsingCss->value['margin']['l'], $this->pdf->getY()-$this->parsingCss->value['margin']['t']); |
|
| 4136 | - |
|
| 4137 | - list($mL, $mR) = $this->_getMargins($this->pdf->getY()); |
|
| 4138 | - $mR = $this->pdf->getW()-$mR; |
|
| 4139 | - $mL+= $this->parsingCss->value['margin']['l']+$this->parsingCss->value['padding']['l']; |
|
| 4140 | - $mR+= $this->parsingCss->value['margin']['r']+$this->parsingCss->value['padding']['r']; |
|
| 4141 | - $this->_saveMargin($mL, 0, $mR); |
|
| 4142 | - |
|
| 4143 | - if ($this->parsingCss->value['text-indent']>0) { |
|
| 4144 | - $y = $this->pdf->getY()+$this->parsingCss->value['margin']['t']+$this->parsingCss->value['padding']['t']; |
|
| 4145 | - $this->_pageMarges[floor($y*100)] = array($mL+$this->parsingCss->value['text-indent'], $this->pdf->getW()-$mR); |
|
| 4146 | - $y+= $this->parsingCss->getLineHeight()*0.1; |
|
| 4147 | - $this->_pageMarges[floor($y*100)] = array($mL, $this->pdf->getW()-$mR); |
|
| 4148 | - } |
|
| 4149 | - $this->_makeBreakLine($this->parsingCss->value['margin']['t']+$this->parsingCss->value['padding']['t']); |
|
| 4150 | - $this->_isInParagraph = array($mL, $mR); |
|
| 4151 | - return true; |
|
| 4152 | - } |
|
| 4153 | - |
|
| 4154 | - /** |
|
| 4155 | - * tag : P |
|
| 4156 | - * mode : CLOSE |
|
| 4157 | - * |
|
| 4158 | - * @param array $param |
|
| 4159 | - * @return boolean |
|
| 4160 | - */ |
|
| 4161 | - protected function _tag_close_P($param) |
|
| 4162 | - { |
|
| 4163 | - if ($this->_isForOneLine) return false; |
|
| 4164 | - |
|
| 4165 | - if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4166 | - $this->_isInParagraph = false; |
|
| 4167 | - $this->_loadMargin(); |
|
| 4168 | - $h = $this->parsingCss->value['margin']['b']+$this->parsingCss->value['padding']['b']; |
|
| 4169 | - |
|
| 4170 | - $this->parsingCss->load(); |
|
| 4171 | - $this->parsingCss->fontSet(); |
|
| 4172 | - $this->_makeBreakLine($h); |
|
| 4173 | - |
|
| 4174 | - return true; |
|
| 4175 | - } |
|
| 4176 | - |
|
| 4177 | - /** |
|
| 4178 | - * tag : PRE |
|
| 4179 | - * mode : OPEN |
|
| 4180 | - * |
|
| 4181 | - * @param array $param |
|
| 4182 | - * @param string $other |
|
| 4183 | - * @return boolean |
|
| 4184 | - */ |
|
| 4185 | - protected function _tag_open_PRE($param, $other = 'pre') |
|
| 4186 | - { |
|
| 4187 | - if ($other=='pre' && $this->_maxH) $this->_tag_open_BR(array()); |
|
| 4188 | - |
|
| 4189 | - $this->parsingCss->save(); |
|
| 4190 | - $this->parsingCss->value['font-family'] = 'courier'; |
|
| 4191 | - $this->parsingCss->analyse($other, $param); |
|
| 4192 | - $this->parsingCss->setPosition(); |
|
| 4193 | - $this->parsingCss->fontSet(); |
|
| 4194 | - |
|
| 4195 | - if ($other=='pre') return $this->_tag_open_DIV($param, $other); |
|
| 4196 | - |
|
| 4197 | - return true; |
|
| 4198 | - } |
|
| 4199 | - |
|
| 4200 | - /** |
|
| 4201 | - * tag : CODE |
|
| 4202 | - * mode : OPEN |
|
| 4203 | - * |
|
| 4204 | - * @param array $param |
|
| 4205 | - * @param string $other |
|
| 4206 | - * @return boolean |
|
| 4207 | - */ |
|
| 4208 | - protected function _tag_open_CODE($param) |
|
| 4209 | - { |
|
| 4210 | - return $this->_tag_open_PRE($param, 'code'); |
|
| 4211 | - } |
|
| 4212 | - |
|
| 4213 | - /** |
|
| 4214 | - * tag : PRE |
|
| 4215 | - * mode : CLOSE |
|
| 4216 | - * |
|
| 4217 | - * @param array $param |
|
| 4218 | - * @param string $other |
|
| 4219 | - * @return boolean |
|
| 4220 | - */ |
|
| 4221 | - protected function _tag_close_PRE($param, $other = 'pre') |
|
| 4222 | - { |
|
| 4223 | - if ($other=='pre') { |
|
| 4224 | - if ($this->_isForOneLine) return false; |
|
| 4225 | - |
|
| 4226 | - $this->_tag_close_DIV($param, $other); |
|
| 4227 | - $this->_tag_open_BR(array()); |
|
| 4228 | - } |
|
| 4229 | - $this->parsingCss->load(); |
|
| 4230 | - $this->parsingCss->fontSet(); |
|
| 4231 | - |
|
| 4232 | - return true; |
|
| 4233 | - } |
|
| 4234 | - |
|
| 4235 | - /** |
|
| 4236 | - * tag : CODE |
|
| 4237 | - * mode : CLOSE |
|
| 4238 | - * |
|
| 4239 | - * @param array $param |
|
| 4240 | - * @return boolean |
|
| 4241 | - */ |
|
| 4242 | - protected function _tag_close_CODE($param) |
|
| 4243 | - { |
|
| 4244 | - return $this->_tag_close_PRE($param, 'code'); |
|
| 4245 | - } |
|
| 4246 | - |
|
| 4247 | - /** |
|
| 4248 | - * tag : BIG |
|
| 4249 | - * mode : OPEN |
|
| 4250 | - * |
|
| 4251 | - * @param array $param |
|
| 4252 | - * @return boolean |
|
| 4253 | - */ |
|
| 4254 | - protected function _tag_open_BIG($param) |
|
| 4255 | - { |
|
| 4256 | - $this->parsingCss->save(); |
|
| 4257 | - $this->parsingCss->value['mini-decal']-= $this->parsingCss->value['mini-size']*0.12; |
|
| 4258 | - $this->parsingCss->value['mini-size'] *= 1.2; |
|
| 4259 | - $this->parsingCss->analyse('big', $param); |
|
| 4260 | - $this->parsingCss->setPosition(); |
|
| 4261 | - $this->parsingCss->fontSet(); |
|
| 4262 | - return true; |
|
| 4263 | - } |
|
| 4264 | - |
|
| 4265 | - /** |
|
| 4266 | - * tag : BIG |
|
| 4267 | - * mode : CLOSE |
|
| 4268 | - * |
|
| 4269 | - * @param array $param |
|
| 4270 | - * @return boolean |
|
| 4271 | - */ |
|
| 4272 | - protected function _tag_close_BIG($param) |
|
| 4273 | - { |
|
| 4274 | - $this->parsingCss->load(); |
|
| 4275 | - $this->parsingCss->fontSet(); |
|
| 4276 | - |
|
| 4277 | - return true; |
|
| 4278 | - } |
|
| 4279 | - |
|
| 4280 | - /** |
|
| 4281 | - * tag : SMALL |
|
| 4282 | - * mode : OPEN |
|
| 4283 | - * |
|
| 4284 | - * @param array $param |
|
| 4285 | - * @return boolean |
|
| 4286 | - */ |
|
| 4287 | - protected function _tag_open_SMALL($param) |
|
| 4288 | - { |
|
| 4289 | - $this->parsingCss->save(); |
|
| 4290 | - $this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.05; |
|
| 4291 | - $this->parsingCss->value['mini-size'] *= 0.82; |
|
| 4292 | - $this->parsingCss->analyse('small', $param); |
|
| 4293 | - $this->parsingCss->setPosition(); |
|
| 4294 | - $this->parsingCss->fontSet(); |
|
| 4295 | - return true; |
|
| 4296 | - } |
|
| 4297 | - |
|
| 4298 | - /** |
|
| 4299 | - * tag : SMALL |
|
| 4300 | - * mode : CLOSE |
|
| 4301 | - * |
|
| 4302 | - * @param array $param |
|
| 4303 | - * @return boolean |
|
| 4304 | - */ |
|
| 4305 | - protected function _tag_close_SMALL($param) |
|
| 4306 | - { |
|
| 4307 | - $this->parsingCss->load(); |
|
| 4308 | - $this->parsingCss->fontSet(); |
|
| 4309 | - |
|
| 4310 | - return true; |
|
| 4311 | - } |
|
| 4312 | - |
|
| 4313 | - /** |
|
| 4314 | - * tag : SUP |
|
| 4315 | - * mode : OPEN |
|
| 4316 | - * |
|
| 4317 | - * @param array $param |
|
| 4318 | - * @return boolean |
|
| 4319 | - */ |
|
| 4320 | - protected function _tag_open_SUP($param) |
|
| 4321 | - { |
|
| 4322 | - $this->parsingCss->save(); |
|
| 4323 | - $this->parsingCss->value['mini-decal']-= $this->parsingCss->value['mini-size']*0.15; |
|
| 4324 | - $this->parsingCss->value['mini-size'] *= 0.75; |
|
| 4325 | - $this->parsingCss->analyse('sup', $param); |
|
| 4326 | - $this->parsingCss->setPosition(); |
|
| 4327 | - $this->parsingCss->fontSet(); |
|
| 4328 | - |
|
| 4329 | - return true; |
|
| 4330 | - } |
|
| 4331 | - |
|
| 4332 | - /** |
|
| 4333 | - * tag : SUP |
|
| 4334 | - * mode : CLOSE |
|
| 4335 | - * |
|
| 4336 | - * @param array $param |
|
| 4337 | - * @return boolean |
|
| 4338 | - */ |
|
| 4339 | - protected function _tag_close_SUP($param) |
|
| 4340 | - { |
|
| 4341 | - $this->parsingCss->load(); |
|
| 4342 | - $this->parsingCss->fontSet(); |
|
| 4343 | - |
|
| 4344 | - return true; |
|
| 4345 | - } |
|
| 4346 | - |
|
| 4347 | - /** |
|
| 4348 | - * tag : SUB |
|
| 4349 | - * mode : OPEN |
|
| 4350 | - * |
|
| 4351 | - * @param array $param |
|
| 4352 | - * @return boolean |
|
| 4353 | - */ |
|
| 4354 | - protected function _tag_open_SUB($param) |
|
| 4355 | - { |
|
| 4356 | - $this->parsingCss->save(); |
|
| 4357 | - $this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.15; |
|
| 4358 | - $this->parsingCss->value['mini-size'] *= 0.75; |
|
| 4359 | - $this->parsingCss->analyse('sub', $param); |
|
| 4360 | - $this->parsingCss->setPosition(); |
|
| 4361 | - $this->parsingCss->fontSet(); |
|
| 4362 | - return true; |
|
| 4363 | - } |
|
| 4364 | - |
|
| 4365 | - /** |
|
| 4366 | - * tag : SUB |
|
| 4367 | - * mode : CLOSE |
|
| 4368 | - * |
|
| 4369 | - * @param array $param |
|
| 4370 | - * @return boolean |
|
| 4371 | - */ |
|
| 4372 | - protected function _tag_close_SUB($param) |
|
| 4373 | - { |
|
| 4374 | - $this->parsingCss->load(); |
|
| 4375 | - $this->parsingCss->fontSet(); |
|
| 4376 | - |
|
| 4377 | - return true; |
|
| 4378 | - } |
|
| 4379 | - |
|
| 4380 | - /** |
|
| 4381 | - * tag : UL |
|
| 4382 | - * mode : OPEN |
|
| 4383 | - * |
|
| 4384 | - * @param array $param |
|
| 4385 | - * @param string $other |
|
| 4386 | - * @return boolean |
|
| 4387 | - */ |
|
| 4388 | - protected function _tag_open_UL($param, $other = 'ul') |
|
| 4389 | - { |
|
| 4390 | - if ($this->_isForOneLine) return false; |
|
| 4391 | - |
|
| 4392 | - if (!in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
|
| 4393 | - if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4394 | - if (!count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4395 | - } |
|
| 4396 | - |
|
| 4397 | - if (!isset($param['style']['width'])) $param['allwidth'] = true; |
|
| 4398 | - $param['cellspacing'] = 0; |
|
| 4399 | - |
|
| 4400 | - // a list is like a table |
|
| 4401 | - $this->_tag_open_TABLE($param, $other); |
|
| 4402 | - |
|
| 4403 | - // add a level of list |
|
| 4404 | - $this->_listeAddLevel($other, $this->parsingCss->value['list-style-type'], $this->parsingCss->value['list-style-image']); |
|
| 4405 | - |
|
| 4406 | - return true; |
|
| 4407 | - } |
|
| 4408 | - |
|
| 4409 | - /** |
|
| 4410 | - * tag : OL |
|
| 4411 | - * mode : OPEN |
|
| 4412 | - * |
|
| 4413 | - * @param array $param |
|
| 4414 | - * @return boolean |
|
| 4415 | - */ |
|
| 4416 | - protected function _tag_open_OL($param) |
|
| 4417 | - { |
|
| 4418 | - return $this->_tag_open_UL($param, 'ol'); |
|
| 4419 | - } |
|
| 4420 | - |
|
| 4421 | - /** |
|
| 4422 | - * tag : UL |
|
| 4423 | - * mode : CLOSE |
|
| 4424 | - * |
|
| 4425 | - * @param array $param |
|
| 4426 | - * @return boolean |
|
| 4427 | - */ |
|
| 4428 | - protected function _tag_close_UL($param) |
|
| 4429 | - { |
|
| 4430 | - if ($this->_isForOneLine) return false; |
|
| 4431 | - |
|
| 4432 | - $this->_tag_close_TABLE($param); |
|
| 4433 | - |
|
| 4434 | - $this->_listeDelLevel(); |
|
| 4435 | - |
|
| 4436 | - if (!$this->_subPart) { |
|
| 4437 | - if (!count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4438 | - } |
|
| 4439 | - |
|
| 4440 | - return true; |
|
| 4441 | - } |
|
| 4442 | - |
|
| 4443 | - /** |
|
| 4444 | - * tag : OL |
|
| 4445 | - * mode : CLOSE |
|
| 4446 | - * |
|
| 4447 | - * @param array $param |
|
| 4448 | - * @return boolean |
|
| 4449 | - */ |
|
| 4450 | - protected function _tag_close_OL($param) |
|
| 4451 | - { |
|
| 4452 | - return $this->_tag_close_UL($param); |
|
| 4453 | - } |
|
| 4454 | - |
|
| 4455 | - /** |
|
| 4456 | - * tag : LI |
|
| 4457 | - * mode : OPEN |
|
| 4458 | - * |
|
| 4459 | - * @param array $param |
|
| 4460 | - * @return boolean |
|
| 4461 | - */ |
|
| 4462 | - protected function _tag_open_LI($param) |
|
| 4463 | - { |
|
| 4464 | - if ($this->_isForOneLine) return false; |
|
| 4465 | - |
|
| 4466 | - $this->_listeAddLi(); |
|
| 4467 | - |
|
| 4468 | - if (!isset($param['style']['width'])) $param['style']['width'] = '100%'; |
|
| 4469 | - |
|
| 4470 | - $paramPUCE = $param; |
|
| 4471 | - |
|
| 4472 | - $inf = $this->_listeGetLi(); |
|
| 4473 | - if ($inf[0]) { |
|
| 4474 | - $paramPUCE['style']['font-family'] = $inf[0]; |
|
| 4475 | - $paramPUCE['style']['text-align'] = 'li_right'; |
|
| 4476 | - $paramPUCE['style']['vertical-align'] = 'top'; |
|
| 4477 | - $paramPUCE['style']['width'] = $this->_listeGetWidth(); |
|
| 4478 | - $paramPUCE['style']['padding-right'] = $this->_listeGetPadding(); |
|
| 4479 | - $paramPUCE['txt'] = $inf[2]; |
|
| 4480 | - } else { |
|
| 4481 | - $paramPUCE['style']['text-align'] = 'li_right'; |
|
| 4482 | - $paramPUCE['style']['vertical-align'] = 'top'; |
|
| 4483 | - $paramPUCE['style']['width'] = $this->_listeGetWidth(); |
|
| 4484 | - $paramPUCE['style']['padding-right'] = $this->_listeGetPadding(); |
|
| 4485 | - $paramPUCE['src'] = $inf[2]; |
|
| 4486 | - $paramPUCE['sub_li'] = true; |
|
| 4487 | - } |
|
| 4488 | - |
|
| 4489 | - $this->_tag_open_TR($param, 'li'); |
|
| 4490 | - |
|
| 4491 | - $this->parsingCss->save(); |
|
| 4492 | - |
|
| 4493 | - // if small LI |
|
| 4494 | - if ($inf[1]) { |
|
| 4495 | - $this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.045; |
|
| 4496 | - $this->parsingCss->value['mini-size'] *= 0.75; |
|
| 4497 | - } |
|
| 4498 | - |
|
| 4499 | - // if we are in a sub html => prepare. Else : display |
|
| 4500 | - if ($this->_subPart) { |
|
| 4501 | - // TD for the puce |
|
| 4502 | - $tmpPos = $this->_tempPos; |
|
| 4503 | - $tmpLst1 = $this->parsingHtml->code[$tmpPos+1]; |
|
| 4504 | - $tmpLst2 = $this->parsingHtml->code[$tmpPos+2]; |
|
| 4505 | - $this->parsingHtml->code[$tmpPos+1] = array(); |
|
| 4506 | - $this->parsingHtml->code[$tmpPos+1]['name'] = (isset($paramPUCE['src'])) ? 'img' : 'write'; |
|
| 4507 | - $this->parsingHtml->code[$tmpPos+1]['param'] = $paramPUCE; unset($this->parsingHtml->code[$tmpPos+1]['param']['style']['width']); |
|
| 4508 | - $this->parsingHtml->code[$tmpPos+1]['close'] = 0; |
|
| 4509 | - $this->parsingHtml->code[$tmpPos+2] = array(); |
|
| 4510 | - $this->parsingHtml->code[$tmpPos+2]['name'] = 'li'; |
|
| 4511 | - $this->parsingHtml->code[$tmpPos+2]['param'] = $paramPUCE; |
|
| 4512 | - $this->parsingHtml->code[$tmpPos+2]['close'] = 1; |
|
| 4513 | - $this->_tag_open_TD($paramPUCE, 'li_sub'); |
|
| 4514 | - $this->_tag_close_TD($param); |
|
| 4515 | - $this->_tempPos = $tmpPos; |
|
| 4516 | - $this->parsingHtml->code[$tmpPos+1] = $tmpLst1; |
|
| 4517 | - $this->parsingHtml->code[$tmpPos+2] = $tmpLst2; |
|
| 4518 | - } else { |
|
| 4519 | - // TD for the puce |
|
| 4520 | - $this->_tag_open_TD($paramPUCE, 'li_sub'); |
|
| 4521 | - unset($paramPUCE['style']['width']); |
|
| 4522 | - if (isset($paramPUCE['src'])) $this->_tag_open_IMG($paramPUCE); |
|
| 4523 | - else $this->_tag_open_WRITE($paramPUCE); |
|
| 4524 | - $this->_tag_close_TD($paramPUCE); |
|
| 4525 | - } |
|
| 4526 | - $this->parsingCss->load(); |
|
| 4527 | - |
|
| 4528 | - |
|
| 4529 | - // TD for the content |
|
| 4530 | - $this->_tag_open_TD($param, 'li'); |
|
| 4531 | - |
|
| 4532 | - return true; |
|
| 4533 | - } |
|
| 4534 | - |
|
| 4535 | - /** |
|
| 4536 | - * tag : LI |
|
| 4537 | - * mode : CLOSE |
|
| 4538 | - * |
|
| 4539 | - * @param array $param |
|
| 4540 | - * @return boolean |
|
| 4541 | - */ |
|
| 4542 | - protected function _tag_close_LI($param) |
|
| 4543 | - { |
|
| 4544 | - if ($this->_isForOneLine) return false; |
|
| 4545 | - |
|
| 4546 | - $this->_tag_close_TD($param); |
|
| 4547 | - |
|
| 4548 | - $this->_tag_close_TR($param); |
|
| 4549 | - |
|
| 4550 | - return true; |
|
| 4551 | - } |
|
| 4552 | - |
|
| 4553 | - /** |
|
| 4554 | - * tag : TBODY |
|
| 4555 | - * mode : OPEN |
|
| 4556 | - * |
|
| 4557 | - * @param array $param |
|
| 4558 | - * @return boolean |
|
| 4559 | - */ |
|
| 4560 | - protected function _tag_open_TBODY($param) |
|
| 4561 | - { |
|
| 4562 | - if ($this->_isForOneLine) return false; |
|
| 4563 | - |
|
| 4564 | - $this->parsingCss->save(); |
|
| 4565 | - $this->parsingCss->analyse('tbody', $param); |
|
| 4566 | - $this->parsingCss->setPosition(); |
|
| 4567 | - $this->parsingCss->fontSet(); |
|
| 4568 | - |
|
| 4569 | - return true; |
|
| 4570 | - } |
|
| 4571 | - |
|
| 4572 | - /** |
|
| 4573 | - * tag : TBODY |
|
| 4574 | - * mode : CLOSE |
|
| 4575 | - * |
|
| 4576 | - * @param array $param |
|
| 4577 | - * @return boolean |
|
| 4578 | - */ |
|
| 4579 | - protected function _tag_close_TBODY($param) |
|
| 4580 | - { |
|
| 4581 | - if ($this->_isForOneLine) return false; |
|
| 4582 | - |
|
| 4583 | - $this->parsingCss->load(); |
|
| 4584 | - $this->parsingCss->fontSet(); |
|
| 4585 | - |
|
| 4586 | - return true; |
|
| 4587 | - } |
|
| 4588 | - |
|
| 4589 | - /** |
|
| 4590 | - * tag : THEAD |
|
| 4591 | - * mode : OPEN |
|
| 4592 | - * |
|
| 4593 | - * @param array $param |
|
| 4594 | - * @return boolean |
|
| 4595 | - */ |
|
| 4596 | - protected function _tag_open_THEAD($param) |
|
| 4597 | - { |
|
| 4598 | - if ($this->_isForOneLine) return false; |
|
| 4599 | - |
|
| 4600 | - $this->parsingCss->save(); |
|
| 4601 | - $this->parsingCss->analyse('thead', $param); |
|
| 4602 | - $this->parsingCss->setPosition(); |
|
| 4603 | - $this->parsingCss->fontSet(); |
|
| 4604 | - |
|
| 4605 | - // if we are in a sub part, save the number of the first TR in the thead |
|
| 4606 | - if ($this->_subPart) { |
|
| 4607 | - HTML2PDF::$_tables[$param['num']]['thead']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 4608 | - HTML2PDF::$_tables[$param['num']]['thead']['code'] = array(); |
|
| 4609 | - for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) { |
|
| 4610 | - $action = $this->parsingHtml->code[$pos]; |
|
| 4611 | - if (strtolower($action['name'])=='thead') $action['name'] = 'thead_sub'; |
|
| 4612 | - HTML2PDF::$_tables[$param['num']]['thead']['code'][] = $action; |
|
| 4613 | - if (strtolower($action['name'])=='thead_sub' && $action['close']) break; |
|
| 4614 | - } |
|
| 4615 | - } else { |
|
| 4616 | - $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 4617 | - $this->_parsePos+= count($level); |
|
| 4618 | - HTML2PDF::$_tables[$param['num']]['tr_curr']+= count(HTML2PDF::$_tables[$param['num']]['thead']['tr']); |
|
| 4619 | - } |
|
| 4620 | - |
|
| 4621 | - return true; |
|
| 4622 | - } |
|
| 4623 | - |
|
| 4624 | - /** |
|
| 4625 | - * tag : THEAD |
|
| 4626 | - * mode : CLOSE |
|
| 4627 | - * |
|
| 4628 | - * @param array $param |
|
| 4629 | - * @return boolean |
|
| 4630 | - */ |
|
| 4631 | - protected function _tag_close_THEAD($param) |
|
| 4632 | - { |
|
| 4633 | - if ($this->_isForOneLine) return false; |
|
| 4634 | - |
|
| 4635 | - $this->parsingCss->load(); |
|
| 4636 | - $this->parsingCss->fontSet(); |
|
| 4637 | - |
|
| 4638 | - // if we are in a sub HTM, construct the list of the TR in the thead |
|
| 4639 | - if ($this->_subPart) { |
|
| 4640 | - $min = HTML2PDF::$_tables[$param['num']]['thead']['tr'][0]; |
|
| 4641 | - $max = HTML2PDF::$_tables[$param['num']]['tr_curr']-1; |
|
| 4642 | - HTML2PDF::$_tables[$param['num']]['thead']['tr'] = range($min, $max); |
|
| 4643 | - } |
|
| 4644 | - |
|
| 4645 | - return true; |
|
| 4646 | - } |
|
| 4647 | - |
|
| 4648 | - /** |
|
| 4649 | - * tag : TFOOT |
|
| 4650 | - * mode : OPEN |
|
| 4651 | - * |
|
| 4652 | - * @param array $param |
|
| 4653 | - * @return boolean |
|
| 4654 | - */ |
|
| 4655 | - protected function _tag_open_TFOOT($param) |
|
| 4656 | - { |
|
| 4657 | - if ($this->_isForOneLine) return false; |
|
| 4658 | - |
|
| 4659 | - $this->parsingCss->save(); |
|
| 4660 | - $this->parsingCss->analyse('tfoot', $param); |
|
| 4661 | - $this->parsingCss->setPosition(); |
|
| 4662 | - $this->parsingCss->fontSet(); |
|
| 4663 | - |
|
| 4664 | - // if we are in a sub part, save the number of the first TR in the tfoot |
|
| 4665 | - if ($this->_subPart) { |
|
| 4666 | - HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 4667 | - HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array(); |
|
| 4668 | - for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) { |
|
| 4669 | - $action = $this->parsingHtml->code[$pos]; |
|
| 4670 | - if (strtolower($action['name'])=='tfoot') $action['name'] = 'tfoot_sub'; |
|
| 4671 | - HTML2PDF::$_tables[$param['num']]['tfoot']['code'][] = $action; |
|
| 4672 | - if (strtolower($action['name'])=='tfoot_sub' && $action['close']) break; |
|
| 4673 | - } |
|
| 4674 | - } else { |
|
| 4675 | - $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 4676 | - $this->_parsePos+= count($level); |
|
| 4677 | - HTML2PDF::$_tables[$param['num']]['tr_curr']+= count(HTML2PDF::$_tables[$param['num']]['tfoot']['tr']); |
|
| 4678 | - } |
|
| 4679 | - |
|
| 4680 | - return true; |
|
| 4681 | - } |
|
| 4682 | - |
|
| 4683 | - /** |
|
| 4684 | - * tag : TFOOT |
|
| 4685 | - * mode : CLOSE |
|
| 4686 | - * |
|
| 4687 | - * @param array $param |
|
| 4688 | - * @return boolean |
|
| 4689 | - */ |
|
| 4690 | - protected function _tag_close_TFOOT($param) |
|
| 4691 | - { |
|
| 4692 | - if ($this->_isForOneLine) return false; |
|
| 4693 | - |
|
| 4694 | - $this->parsingCss->load(); |
|
| 4695 | - $this->parsingCss->fontSet(); |
|
| 4696 | - |
|
| 4697 | - // if we are in a sub HTM, construct the list of the TR in the tfoot |
|
| 4698 | - if ($this->_subPart) { |
|
| 4699 | - $min = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0]; |
|
| 4700 | - $max = HTML2PDF::$_tables[$param['num']]['tr_curr']-1; |
|
| 4701 | - HTML2PDF::$_tables[$param['num']]['tfoot']['tr'] = range($min, $max); |
|
| 4702 | - } |
|
| 4703 | - |
|
| 4704 | - return true; |
|
| 4705 | - } |
|
| 4706 | - |
|
| 4707 | - /** |
|
| 4708 | - * It is not a real TAG, does not use it ! |
|
| 4709 | - * |
|
| 4710 | - * @param array $param |
|
| 4711 | - * @return boolean |
|
| 4712 | - */ |
|
| 4713 | - protected function _tag_open_THEAD_SUB($param) |
|
| 4714 | - { |
|
| 4715 | - if ($this->_isForOneLine) return false; |
|
| 4716 | - |
|
| 4717 | - $this->parsingCss->save(); |
|
| 4718 | - $this->parsingCss->analyse('thead', $param); |
|
| 4719 | - $this->parsingCss->setPosition(); |
|
| 4720 | - $this->parsingCss->fontSet(); |
|
| 4721 | - |
|
| 4722 | - return true; |
|
| 4723 | - } |
|
| 4724 | - |
|
| 4725 | - /** |
|
| 4726 | - * It is not a real TAG, does not use it ! |
|
| 4727 | - * |
|
| 4728 | - * @param array $param |
|
| 4729 | - * @return boolean |
|
| 4730 | - */ |
|
| 4731 | - protected function _tag_close_THEAD_SUB($param) |
|
| 4732 | - { |
|
| 4733 | - if ($this->_isForOneLine) return false; |
|
| 4734 | - |
|
| 4735 | - $this->parsingCss->load(); |
|
| 4736 | - $this->parsingCss->fontSet(); |
|
| 4737 | - |
|
| 4738 | - return true; |
|
| 4739 | - } |
|
| 4740 | - |
|
| 4741 | - /** |
|
| 4742 | - * It is not a real TAG, does not use it ! |
|
| 4743 | - * |
|
| 4744 | - * @param array $param |
|
| 4745 | - * @return boolean |
|
| 4746 | - */ |
|
| 4747 | - protected function _tag_open_TFOOT_SUB($param) |
|
| 4748 | - { |
|
| 4749 | - if ($this->_isForOneLine) return false; |
|
| 4750 | - |
|
| 4751 | - $this->parsingCss->save(); |
|
| 4752 | - $this->parsingCss->analyse('tfoot', $param); |
|
| 4753 | - $this->parsingCss->setPosition(); |
|
| 4754 | - $this->parsingCss->fontSet(); |
|
| 4755 | - |
|
| 4756 | - return true; |
|
| 4757 | - } |
|
| 4758 | - |
|
| 4759 | - /** |
|
| 4760 | - * It is not a real TAG, does not use it ! |
|
| 4761 | - * |
|
| 4762 | - * @param array $param |
|
| 4763 | - * @return boolean |
|
| 4764 | - */ |
|
| 4765 | - protected function _tag_close_TFOOT_SUB($param) |
|
| 4766 | - { |
|
| 4767 | - if ($this->_isForOneLine) return false; |
|
| 4768 | - |
|
| 4769 | - $this->parsingCss->load(); |
|
| 4770 | - $this->parsingCss->fontSet(); |
|
| 4771 | - |
|
| 4772 | - return true; |
|
| 4773 | - } |
|
| 4774 | - |
|
| 4775 | - /** |
|
| 4776 | - * tag : FORM |
|
| 4777 | - * mode : OPEN |
|
| 4778 | - * |
|
| 4779 | - * @param array $param |
|
| 4780 | - * @return boolean |
|
| 4781 | - */ |
|
| 4782 | - protected function _tag_open_FORM($param) |
|
| 4783 | - { |
|
| 4784 | - $this->parsingCss->save(); |
|
| 4785 | - $this->parsingCss->analyse('form', $param); |
|
| 4786 | - $this->parsingCss->setPosition(); |
|
| 4787 | - $this->parsingCss->fontSet(); |
|
| 4788 | - |
|
| 4789 | - $this->pdf->setFormDefaultProp( |
|
| 4790 | - array( |
|
| 4791 | - 'lineWidth'=>1, |
|
| 4792 | - 'borderStyle'=>'solid', |
|
| 4793 | - 'fillColor'=>array(220, 220, 255), |
|
| 4794 | - 'strokeColor'=>array(128, 128, 200) |
|
| 4795 | - ) |
|
| 4796 | - ); |
|
| 4797 | - |
|
| 4798 | - $this->_isInForm = isset($param['action']) ? $param['action'] : ''; |
|
| 4799 | - |
|
| 4800 | - return true; |
|
| 4801 | - } |
|
| 4802 | - |
|
| 4803 | - /** |
|
| 4804 | - * tag : FORM |
|
| 4805 | - * mode : CLOSE |
|
| 4806 | - * |
|
| 4807 | - * @param array $param |
|
| 4808 | - * @return boolean |
|
| 4809 | - */ |
|
| 4810 | - protected function _tag_close_FORM($param) |
|
| 4811 | - { |
|
| 4812 | - $this->_isInForm = false; |
|
| 4813 | - $this->parsingCss->load(); |
|
| 4814 | - $this->parsingCss->fontSet(); |
|
| 4815 | - |
|
| 4816 | - return true; |
|
| 4817 | - } |
|
| 4818 | - |
|
| 4819 | - /** |
|
| 4820 | - * tag : TABLE |
|
| 4821 | - * mode : OPEN |
|
| 4822 | - * |
|
| 4823 | - * @param array $param |
|
| 4824 | - * @return boolean |
|
| 4825 | - */ |
|
| 4826 | - protected function _tag_open_TABLE($param, $other = 'table') |
|
| 4827 | - { |
|
| 4828 | - if ($this->_maxH) { |
|
| 4829 | - if ($this->_isForOneLine) return false; |
|
| 4830 | - $this->_tag_open_BR(array()); |
|
| 4831 | - } |
|
| 4832 | - |
|
| 4833 | - if ($this->_isForOneLine) { |
|
| 4834 | - $this->_maxX = $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 4835 | - return false; |
|
| 4836 | - } |
|
| 4837 | - |
|
| 4838 | - $this->_maxH = 0; |
|
| 4839 | - |
|
| 4840 | - $alignObject = isset($param['align']) ? strtolower($param['align']) : 'left'; |
|
| 4841 | - if (isset($param['align'])) unset($param['align']); |
|
| 4842 | - if (!in_array($alignObject, array('left', 'center', 'right'))) $alignObject = 'left'; |
|
| 4843 | - |
|
| 4844 | - $this->parsingCss->save(); |
|
| 4845 | - $this->parsingCss->analyse($other, $param); |
|
| 4846 | - $this->parsingCss->setPosition(); |
|
| 4847 | - $this->parsingCss->fontSet(); |
|
| 4848 | - |
|
| 4849 | - if ($this->parsingCss->value['margin-auto']) $alignObject = 'center'; |
|
| 4850 | - |
|
| 4851 | - // collapse table ? |
|
| 4852 | - $collapse = false; |
|
| 4853 | - if ($other=='table') { |
|
| 4854 | - $collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false; |
|
| 4855 | - } |
|
| 4856 | - |
|
| 4857 | - // if collapse => no borders for the table, only for TD |
|
| 4858 | - if ($collapse) { |
|
| 4859 | - $param['style']['border'] = 'none'; |
|
| 4860 | - $param['cellspacing'] = 0; |
|
| 4861 | - $none = $this->parsingCss->readBorder('none'); |
|
| 4862 | - $this->parsingCss->value['border']['t'] = $none; |
|
| 4863 | - $this->parsingCss->value['border']['r'] = $none; |
|
| 4864 | - $this->parsingCss->value['border']['b'] = $none; |
|
| 4865 | - $this->parsingCss->value['border']['l'] = $none; |
|
| 4866 | - } |
|
| 4867 | - |
|
| 4868 | - // if we are in a SUB html => prepare the properties of the table |
|
| 4869 | - if ($this->_subPart) { |
|
| 4870 | - if ($this->_debugActif) $this->_DEBUG_add('Table n'.$param['num'], true); |
|
| 4871 | - HTML2PDF::$_tables[$param['num']] = array(); |
|
| 4872 | - HTML2PDF::$_tables[$param['num']]['border'] = isset($param['border']) ? $this->parsingCss->readBorder($param['border']) : null; |
|
| 4873 | - HTML2PDF::$_tables[$param['num']]['cellpadding'] = $this->parsingCss->ConvertToMM(isset($param['cellpadding']) ? $param['cellpadding'] : '1px'); |
|
| 4874 | - HTML2PDF::$_tables[$param['num']]['cellspacing'] = $this->parsingCss->ConvertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px'); |
|
| 4875 | - HTML2PDF::$_tables[$param['num']]['cases'] = array(); // properties of each TR/TD |
|
| 4876 | - HTML2PDF::$_tables[$param['num']]['corr'] = array(); // link between TR/TD and colspan/rowspan |
|
| 4877 | - HTML2PDF::$_tables[$param['num']]['corr_x'] = 0; // position in 'cases' |
|
| 4878 | - HTML2PDF::$_tables[$param['num']]['corr_y'] = 0; // position in 'cases' |
|
| 4879 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; // current column |
|
| 4880 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = 0; // current row |
|
| 4881 | - HTML2PDF::$_tables[$param['num']]['curr_x'] = $this->pdf->getX(); |
|
| 4882 | - HTML2PDF::$_tables[$param['num']]['curr_y'] = $this->pdf->getY(); |
|
| 4883 | - HTML2PDF::$_tables[$param['num']]['width'] = 0; // global width |
|
| 4884 | - HTML2PDF::$_tables[$param['num']]['height'] = 0; // global height |
|
| 4885 | - HTML2PDF::$_tables[$param['num']]['align'] = $alignObject; |
|
| 4886 | - HTML2PDF::$_tables[$param['num']]['marge'] = array(); |
|
| 4887 | - HTML2PDF::$_tables[$param['num']]['marge']['t'] = $this->parsingCss->value['padding']['t']+$this->parsingCss->value['border']['t']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5; |
|
| 4888 | - HTML2PDF::$_tables[$param['num']]['marge']['r'] = $this->parsingCss->value['padding']['r']+$this->parsingCss->value['border']['r']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5; |
|
| 4889 | - HTML2PDF::$_tables[$param['num']]['marge']['b'] = $this->parsingCss->value['padding']['b']+$this->parsingCss->value['border']['b']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5; |
|
| 4890 | - HTML2PDF::$_tables[$param['num']]['marge']['l'] = $this->parsingCss->value['padding']['l']+$this->parsingCss->value['border']['l']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5; |
|
| 4891 | - HTML2PDF::$_tables[$param['num']]['page'] = 0; // number of pages |
|
| 4892 | - HTML2PDF::$_tables[$param['num']]['new_page'] = true; // flag : new page for the current TR |
|
| 4893 | - HTML2PDF::$_tables[$param['num']]['style_value'] = null; // CSS style of the table |
|
| 4894 | - HTML2PDF::$_tables[$param['num']]['thead'] = array(); // properties on the thead |
|
| 4895 | - HTML2PDF::$_tables[$param['num']]['tfoot'] = array(); // properties on the tfoot |
|
| 4896 | - HTML2PDF::$_tables[$param['num']]['thead']['tr'] = array(); // list of the TRs in the thead |
|
| 4897 | - HTML2PDF::$_tables[$param['num']]['tfoot']['tr'] = array(); // list of the TRs in the tfoot |
|
| 4898 | - HTML2PDF::$_tables[$param['num']]['thead']['height'] = 0; // thead height |
|
| 4899 | - HTML2PDF::$_tables[$param['num']]['tfoot']['height'] = 0; // tfoot height |
|
| 4900 | - HTML2PDF::$_tables[$param['num']]['thead']['code'] = array(); // HTML content of the thead |
|
| 4901 | - HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array(); // HTML content of the tfoot |
|
| 4902 | - HTML2PDF::$_tables[$param['num']]['cols'] = array(); // properties of the COLs |
|
| 4903 | - |
|
| 4904 | - $this->_saveMargin($this->pdf->getlMargin(), $this->pdf->gettMargin(), $this->pdf->getrMargin()); |
|
| 4905 | - |
|
| 4906 | - $this->parsingCss->value['width']-= HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r']; |
|
| 4907 | - } else { |
|
| 4908 | - // we start from the first page and the first page of the table |
|
| 4909 | - HTML2PDF::$_tables[$param['num']]['page'] = 0; |
|
| 4910 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 4911 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = 0; |
|
| 4912 | - HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['marge']['l']+HTML2PDF::$_tables[$param['num']]['curr_x']; |
|
| 4913 | - HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['marge']['t']+HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 4914 | - |
|
| 4915 | - // draw the borders/background of the first page/part of the table |
|
| 4916 | - $this->_drawRectangle( |
|
| 4917 | - HTML2PDF::$_tables[$param['num']]['curr_x'], |
|
| 4918 | - HTML2PDF::$_tables[$param['num']]['curr_y'], |
|
| 4919 | - HTML2PDF::$_tables[$param['num']]['width'], |
|
| 4920 | - isset(HTML2PDF::$_tables[$param['num']]['height'][0]) ? HTML2PDF::$_tables[$param['num']]['height'][0] : null, |
|
| 4921 | - $this->parsingCss->value['border'], |
|
| 4922 | - $this->parsingCss->value['padding'], |
|
| 4923 | - 0, |
|
| 4924 | - $this->parsingCss->value['background'] |
|
| 4925 | - ); |
|
| 4926 | - |
|
| 4927 | - HTML2PDF::$_tables[$param['num']]['style_value'] = $this->parsingCss->value; |
|
| 4928 | - } |
|
| 4929 | - |
|
| 4930 | - return true; |
|
| 4931 | - } |
|
| 4932 | - |
|
| 4933 | - /** |
|
| 4934 | - * tag : TABLE |
|
| 4935 | - * mode : CLOSE |
|
| 4936 | - * |
|
| 4937 | - * @param array $param |
|
| 4938 | - * @return boolean |
|
| 4939 | - */ |
|
| 4940 | - protected function _tag_close_TABLE($param) |
|
| 4941 | - { |
|
| 4942 | - if ($this->_isForOneLine) return false; |
|
| 4943 | - |
|
| 4944 | - $this->_maxH = 0; |
|
| 4945 | - |
|
| 4946 | - // if we are in a sub HTML |
|
| 4947 | - if ($this->_subPart) { |
|
| 4948 | - // calculate the size of each case |
|
| 4949 | - $this->_calculateTableCellSize(HTML2PDF::$_tables[$param['num']]['cases'], HTML2PDF::$_tables[$param['num']]['corr']); |
|
| 4950 | - |
|
| 4951 | - // calculate the height of the thead and the tfoot |
|
| 4952 | - $lst = array('thead', 'tfoot'); |
|
| 4953 | - foreach ($lst as $mode) { |
|
| 4954 | - HTML2PDF::$_tables[$param['num']][$mode]['height'] = 0; |
|
| 4955 | - foreach (HTML2PDF::$_tables[$param['num']][$mode]['tr'] as $tr) { |
|
| 4956 | - // hauteur de la ligne tr |
|
| 4957 | - $h = 0; |
|
| 4958 | - for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++) |
|
| 4959 | - if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan']==1) |
|
| 4960 | - $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['h']); |
|
| 4961 | - HTML2PDF::$_tables[$param['num']][$mode]['height']+= $h; |
|
| 4962 | - } |
|
| 4963 | - } |
|
| 4964 | - |
|
| 4965 | - // calculate the width of the table |
|
| 4966 | - HTML2PDF::$_tables[$param['num']]['width'] = HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r']; |
|
| 4967 | - if (isset(HTML2PDF::$_tables[$param['num']]['cases'][0])) { |
|
| 4968 | - foreach (HTML2PDF::$_tables[$param['num']]['cases'][0] as $case) { |
|
| 4969 | - HTML2PDF::$_tables[$param['num']]['width']+= $case['w']; |
|
| 4970 | - } |
|
| 4971 | - } |
|
| 4972 | - |
|
| 4973 | - // X position of the table |
|
| 4974 | - $old = $this->parsingCss->getOldValues(); |
|
| 4975 | - $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 4976 | - $x = HTML2PDF::$_tables[$param['num']]['curr_x']; |
|
| 4977 | - $w = HTML2PDF::$_tables[$param['num']]['width']; |
|
| 4978 | - if ($parentWidth>$w) { |
|
| 4979 | - if (HTML2PDF::$_tables[$param['num']]['align']=='center') |
|
| 4980 | - $x = $x + ($parentWidth-$w)*0.5; |
|
| 4981 | - else if (HTML2PDF::$_tables[$param['num']]['align']=='right') |
|
| 4982 | - $x = $x + $parentWidth-$w; |
|
| 4983 | - |
|
| 4984 | - HTML2PDF::$_tables[$param['num']]['curr_x'] = $x; |
|
| 4985 | - } |
|
| 4986 | - |
|
| 4987 | - // calculate the height of the table |
|
| 4988 | - HTML2PDF::$_tables[$param['num']]['height'] = array(); |
|
| 4989 | - |
|
| 4990 | - // minimum of the height because of margins, and of the thead and tfoot height |
|
| 4991 | - $h0 = HTML2PDF::$_tables[$param['num']]['marge']['t'] + HTML2PDF::$_tables[$param['num']]['marge']['b']; |
|
| 4992 | - $h0+= HTML2PDF::$_tables[$param['num']]['thead']['height'] + HTML2PDF::$_tables[$param['num']]['tfoot']['height']; |
|
| 4993 | - |
|
| 4994 | - // max height of the page |
|
| 4995 | - $max = $this->pdf->getH() - $this->pdf->getbMargin(); |
|
| 4996 | - |
|
| 4997 | - // current position on the page |
|
| 4998 | - $y = HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 4999 | - $height = $h0; |
|
| 5000 | - |
|
| 5001 | - // we get the height of each line |
|
| 5002 | - for ($k=0; $k<count(HTML2PDF::$_tables[$param['num']]['cases']); $k++) { |
|
| 5003 | - |
|
| 5004 | - // if it is a TR of the thead or of the tfoot => skip |
|
| 5005 | - if (in_array($k, HTML2PDF::$_tables[$param['num']]['thead']['tr'])) continue; |
|
| 5006 | - if (in_array($k, HTML2PDF::$_tables[$param['num']]['tfoot']['tr'])) continue; |
|
| 5007 | - |
|
| 5008 | - // height of the line |
|
| 5009 | - $th = 0; |
|
| 5010 | - $h = 0; |
|
| 5011 | - for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$k]); $i++) { |
|
| 5012 | - $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
|
| 5013 | - |
|
| 5014 | - if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan']==1) |
|
| 5015 | - $th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
|
| 5016 | - } |
|
| 5017 | - |
|
| 5018 | - // if the row does not fit on the page => new page |
|
| 5019 | - if ($y+$h+$height>$max) { |
|
| 5020 | - if ($height==$h0) $height = null; |
|
| 5021 | - HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
|
| 5022 | - $height = $h0; |
|
| 5023 | - $y = $this->_margeTop; |
|
| 5024 | - } |
|
| 5025 | - $height+= $th; |
|
| 5026 | - } |
|
| 5027 | - |
|
| 5028 | - // if ther is a height at the end, add it |
|
| 5029 | - if ($height!=$h0 || $k==0) HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
|
| 5030 | - } else { |
|
| 5031 | - // if we have tfoor, draw it |
|
| 5032 | - if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) { |
|
| 5033 | - $tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 5034 | - $tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr']; |
|
| 5035 | - $oldParsePos = $this->_parsePos; |
|
| 5036 | - $oldParseCode = $this->parsingHtml->code; |
|
| 5037 | - |
|
| 5038 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0]; |
|
| 5039 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5040 | - $this->_parsePos = 0; |
|
| 5041 | - $this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['tfoot']['code']; |
|
| 5042 | - $this->_isInTfoot = true; |
|
| 5043 | - $this->_makeHTMLcode(); |
|
| 5044 | - $this->_isInTfoot = false; |
|
| 5045 | - |
|
| 5046 | - $this->_parsePos = $oldParsePos; |
|
| 5047 | - $this->parsingHtml->code = $oldParseCode; |
|
| 5048 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR; |
|
| 5049 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD; |
|
| 5050 | - } |
|
| 5051 | - |
|
| 5052 | - // get the positions of the end of the table |
|
| 5053 | - $x = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['width']; |
|
| 5054 | - if (count(HTML2PDF::$_tables[$param['num']]['height'])>1) |
|
| 5055 | - $y = $this->_margeTop+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1]; |
|
| 5056 | - else if (count(HTML2PDF::$_tables[$param['num']]['height'])==1) |
|
| 5057 | - $y = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1]; |
|
| 5058 | - else |
|
| 5059 | - $y = HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 5060 | - |
|
| 5061 | - $this->_maxX = max($this->_maxX, $x); |
|
| 5062 | - $this->_maxY = max($this->_maxY, $y); |
|
| 5063 | - |
|
| 5064 | - $this->pdf->setXY($this->pdf->getlMargin(), $y); |
|
| 5065 | - |
|
| 5066 | - $this->_loadMargin(); |
|
| 5067 | - |
|
| 5068 | - if ($this->_debugActif) $this->_DEBUG_add('Table '.$param['num'], false); |
|
| 5069 | - } |
|
| 5070 | - |
|
| 5071 | - $this->parsingCss->load(); |
|
| 5072 | - $this->parsingCss->fontSet(); |
|
| 5073 | - |
|
| 5074 | - |
|
| 5075 | - return true; |
|
| 5076 | - } |
|
| 5077 | - |
|
| 5078 | - /** |
|
| 5079 | - * tag : COL |
|
| 5080 | - * mode : OPEN |
|
| 5081 | - * |
|
| 5082 | - * @param array $param |
|
| 5083 | - * @return boolean |
|
| 5084 | - */ |
|
| 5085 | - protected function _tag_open_COL($param) |
|
| 5086 | - { |
|
| 5087 | - $span = isset($param['span']) ? $param['span'] : 1; |
|
| 5088 | - for ($k=0; $k<$span; $k++) |
|
| 5089 | - HTML2PDF::$_tables[$param['num']]['cols'][] = $param; |
|
| 5090 | - } |
|
| 5091 | - |
|
| 5092 | - /** |
|
| 5093 | - * tag : COL |
|
| 5094 | - * mode : CLOSE |
|
| 5095 | - * |
|
| 5096 | - * @param array $param |
|
| 5097 | - * @return boolean |
|
| 5098 | - */ |
|
| 5099 | - protected function _tag_close_COL($param) |
|
| 5100 | - { |
|
| 5101 | - // there is nothing to do here |
|
| 5102 | - |
|
| 5103 | - return true; |
|
| 5104 | - } |
|
| 5105 | - |
|
| 5106 | - /** |
|
| 5107 | - * tag : TR |
|
| 5108 | - * mode : OPEN |
|
| 5109 | - * |
|
| 5110 | - * @param array $param |
|
| 5111 | - * @return boolean |
|
| 5112 | - */ |
|
| 5113 | - protected function _tag_open_TR($param, $other = 'tr') |
|
| 5114 | - { |
|
| 5115 | - if ($this->_isForOneLine) return false; |
|
| 5116 | - |
|
| 5117 | - $this->_maxH = 0; |
|
| 5118 | - |
|
| 5119 | - $this->parsingCss->save(); |
|
| 5120 | - $this->parsingCss->analyse($other, $param); |
|
| 5121 | - $this->parsingCss->setPosition(); |
|
| 5122 | - $this->parsingCss->fontSet(); |
|
| 5123 | - |
|
| 5124 | - // position in the table |
|
| 5125 | - HTML2PDF::$_tables[$param['num']]['tr_curr']++; |
|
| 5126 | - HTML2PDF::$_tables[$param['num']]['td_curr']= 0; |
|
| 5127 | - |
|
| 5128 | - // if we are not in a sub html |
|
| 5129 | - if (!$this->_subPart) { |
|
| 5130 | - |
|
| 5131 | - // Y after the row |
|
| 5132 | - $ty=null; |
|
| 5133 | - for ($ii=0; $ii<count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1]); $ii++) { |
|
| 5134 | - $ty = max($ty, HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['h']); |
|
| 5135 | - } |
|
| 5136 | - |
|
| 5137 | - // height of the tfoot |
|
| 5138 | - $hfoot = HTML2PDF::$_tables[$param['num']]['tfoot']['height']; |
|
| 5139 | - |
|
| 5140 | - // if the line does not fit on the page => new page |
|
| 5141 | - if (!$this->_isInTfoot && HTML2PDF::$_tables[$param['num']]['td_y'] + HTML2PDF::$_tables[$param['num']]['marge']['b'] + $ty +$hfoot> $this->pdf->getH() - $this->pdf->getbMargin()) { |
|
| 5142 | - |
|
| 5143 | - // fi ther is a tfoot => draw it |
|
| 5144 | - if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) { |
|
| 5145 | - $tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 5146 | - $tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr']; |
|
| 5147 | - $oldParsePos = $this->_parsePos; |
|
| 5148 | - $oldParseCode = $this->parsingHtml->code; |
|
| 5149 | - |
|
| 5150 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0]; |
|
| 5151 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5152 | - $this->_parsePos = 0; |
|
| 5153 | - $this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['tfoot']['code']; |
|
| 5154 | - $this->_isInTfoot = true; |
|
| 5155 | - $this->_makeHTMLcode(); |
|
| 5156 | - $this->_isInTfoot = false; |
|
| 5157 | - |
|
| 5158 | - $this->_parsePos = $oldParsePos; |
|
| 5159 | - $this->parsingHtml->code = $oldParseCode; |
|
| 5160 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR; |
|
| 5161 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD; |
|
| 5162 | - } |
|
| 5163 | - |
|
| 5164 | - // new page |
|
| 5165 | - HTML2PDF::$_tables[$param['num']]['new_page'] = true; |
|
| 5166 | - $this->_setNewPage(); |
|
| 5167 | - |
|
| 5168 | - // new position |
|
| 5169 | - HTML2PDF::$_tables[$param['num']]['page']++; |
|
| 5170 | - HTML2PDF::$_tables[$param['num']]['curr_y'] = $this->pdf->getY(); |
|
| 5171 | - HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['marge']['t']; |
|
| 5172 | - |
|
| 5173 | - // if we have the height of the tbale on the page => draw borders and background |
|
| 5174 | - if (isset(HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']])) { |
|
| 5175 | - $old = $this->parsingCss->value; |
|
| 5176 | - $this->parsingCss->value = HTML2PDF::$_tables[$param['num']]['style_value']; |
|
| 5177 | - |
|
| 5178 | - $this->_drawRectangle( |
|
| 5179 | - HTML2PDF::$_tables[$param['num']]['curr_x'], |
|
| 5180 | - HTML2PDF::$_tables[$param['num']]['curr_y'], |
|
| 5181 | - HTML2PDF::$_tables[$param['num']]['width'], |
|
| 5182 | - HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']], |
|
| 5183 | - $this->parsingCss->value['border'], |
|
| 5184 | - $this->parsingCss->value['padding'], |
|
| 5185 | - HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5, |
|
| 5186 | - $this->parsingCss->value['background'] |
|
| 5187 | - ); |
|
| 5188 | - |
|
| 5189 | - $this->parsingCss->value = $old; |
|
| 5190 | - } |
|
| 5191 | - } |
|
| 5192 | - |
|
| 5193 | - // if we are in a new page, and if we have a thead => draw it |
|
| 5194 | - if (HTML2PDF::$_tables[$param['num']]['new_page'] && count(HTML2PDF::$_tables[$param['num']]['thead']['code'])) { |
|
| 5195 | - HTML2PDF::$_tables[$param['num']]['new_page'] = false; |
|
| 5196 | - $tmpTR = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
|
| 5197 | - $tmpTD = HTML2PDF::$_tables[$param['num']]['td_curr']; |
|
| 5198 | - $oldParsePos = $this->_parsePos; |
|
| 5199 | - $oldParseCode = $this->parsingHtml->code; |
|
| 5200 | - |
|
| 5201 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = HTML2PDF::$_tables[$param['num']]['thead']['tr'][0]; |
|
| 5202 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5203 | - $this->_parsePos = 0; |
|
| 5204 | - $this->parsingHtml->code = HTML2PDF::$_tables[$param['num']]['thead']['code']; |
|
| 5205 | - $this->_isInThead = true; |
|
| 5206 | - $this->_makeHTMLcode(); |
|
| 5207 | - $this->_isInThead = false; |
|
| 5208 | - |
|
| 5209 | - $this->_parsePos = $oldParsePos; |
|
| 5210 | - $this->parsingHtml->code = $oldParseCode; |
|
| 5211 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR; |
|
| 5212 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD; |
|
| 5213 | - HTML2PDF::$_tables[$param['num']]['new_page'] = true; |
|
| 5214 | - } |
|
| 5215 | - // else (in a sub HTML) |
|
| 5216 | - } else { |
|
| 5217 | - // prepare it |
|
| 5218 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1] = array(); |
|
| 5219 | - if (!isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']])) |
|
| 5220 | - HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array(); |
|
| 5221 | - |
|
| 5222 | - HTML2PDF::$_tables[$param['num']]['corr_x']=0; |
|
| 5223 | - while(isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) |
|
| 5224 | - HTML2PDF::$_tables[$param['num']]['corr_x']++; |
|
| 5225 | - } |
|
| 5226 | - |
|
| 5227 | - return true; |
|
| 5228 | - } |
|
| 5229 | - |
|
| 5230 | - /** |
|
| 5231 | - * tag : TR |
|
| 5232 | - * mode : CLOSE |
|
| 5233 | - * |
|
| 5234 | - * @param array $param |
|
| 5235 | - * @return boolean |
|
| 5236 | - */ |
|
| 5237 | - protected function _tag_close_TR($param) |
|
| 5238 | - { |
|
| 5239 | - if ($this->_isForOneLine) return false; |
|
| 5240 | - |
|
| 5241 | - $this->_maxH = 0; |
|
| 5242 | - |
|
| 5243 | - $this->parsingCss->load(); |
|
| 5244 | - $this->parsingCss->fontSet(); |
|
| 5245 | - |
|
| 5246 | - // if we are not in a sub HTML |
|
| 5247 | - if (!$this->_subPart) { |
|
| 5248 | - |
|
| 5249 | - // Y of the current line |
|
| 5250 | - $ty=null; |
|
| 5251 | - for ($ii=0; $ii<count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1]); $ii++) { |
|
| 5252 | - if (HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['rowspan']==1) { |
|
| 5253 | - $ty = HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['h']; |
|
| 5254 | - } |
|
| 5255 | - } |
|
| 5256 | - |
|
| 5257 | - // new position |
|
| 5258 | - HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['curr_x']+HTML2PDF::$_tables[$param['num']]['marge']['l']; |
|
| 5259 | - HTML2PDF::$_tables[$param['num']]['td_y']+= $ty; |
|
| 5260 | - HTML2PDF::$_tables[$param['num']]['new_page'] = false; |
|
| 5261 | - } else { |
|
| 5262 | - HTML2PDF::$_tables[$param['num']]['corr_y']++; |
|
| 5263 | - } |
|
| 5264 | - |
|
| 5265 | - return true; |
|
| 5266 | - } |
|
| 5267 | - |
|
| 5268 | - /** |
|
| 5269 | - * tag : TD |
|
| 5270 | - * mode : OPEN |
|
| 5271 | - * |
|
| 5272 | - * @param array $param |
|
| 5273 | - * @return boolean |
|
| 5274 | - */ |
|
| 5275 | - protected function _tag_open_TD($param, $other = 'td') |
|
| 5276 | - { |
|
| 5277 | - if ($this->_isForOneLine) return false; |
|
| 5278 | - |
|
| 5279 | - $this->_maxH = 0; |
|
| 5280 | - |
|
| 5281 | - $param['cellpadding'] = HTML2PDF::$_tables[$param['num']]['cellpadding'].'mm'; |
|
| 5282 | - $param['cellspacing'] = HTML2PDF::$_tables[$param['num']]['cellspacing'].'mm'; |
|
| 5283 | - |
|
| 5284 | - // specific style for LI |
|
| 5285 | - if ($other=='li') { |
|
| 5286 | - $specialLi = true; |
|
| 5287 | - } else { |
|
| 5288 | - $specialLi = false; |
|
| 5289 | - if ($other=='li_sub') { |
|
| 5290 | - $param['style']['border'] = 'none'; |
|
| 5291 | - $param['style']['background-color'] = 'transparent'; |
|
| 5292 | - $param['style']['background-image'] = 'none'; |
|
| 5293 | - $param['style']['background-position'] = ''; |
|
| 5294 | - $param['style']['background-repeat'] = ''; |
|
| 5295 | - $other = 'li'; |
|
| 5296 | - } |
|
| 5297 | - } |
|
| 5298 | - |
|
| 5299 | - // get the properties of the TD |
|
| 5300 | - $x = HTML2PDF::$_tables[$param['num']]['td_curr']; |
|
| 5301 | - $y = HTML2PDF::$_tables[$param['num']]['tr_curr']-1; |
|
| 5302 | - $colspan = isset($param['colspan']) ? $param['colspan'] : 1; |
|
| 5303 | - $rowspan = isset($param['rowspan']) ? $param['rowspan'] : 1; |
|
| 5304 | - |
|
| 5305 | - // flag for collapse table |
|
| 5306 | - $collapse = false; |
|
| 5307 | - |
|
| 5308 | - // specific traitment for TD and TH |
|
| 5309 | - if (in_array($other, array('td', 'th'))) { |
|
| 5310 | - // id of the column |
|
| 5311 | - $numCol = isset(HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr']) ? HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr'] : HTML2PDF::$_tables[$param['num']]['corr_x']; |
|
| 5312 | - |
|
| 5313 | - // we get the properties of the COL tag, if exist |
|
| 5314 | - if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol])) { |
|
| 5315 | - |
|
| 5316 | - $colParam = HTML2PDF::$_tables[$param['num']]['cols'][$numCol]; |
|
| 5317 | - |
|
| 5318 | - // for colspans => we get all the neede widths |
|
| 5319 | - $colParam['style']['width'] = array(); |
|
| 5320 | - for ($k=0; $k<$colspan; $k++) { |
|
| 5321 | - if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol+$k]['style']['width'])) { |
|
| 5322 | - $colParam['style']['width'][] = HTML2PDF::$_tables[$param['num']]['cols'][$numCol+$k]['style']['width']; |
|
| 5323 | - } |
|
| 5324 | - } |
|
| 5325 | - |
|
| 5326 | - // calculate the total width of the column |
|
| 5327 | - $total = ''; |
|
| 5328 | - $last = $this->parsingCss->getLastWidth(); |
|
| 5329 | - if (count($colParam['style']['width'])) { |
|
| 5330 | - $total = $colParam['style']['width'][0]; unset($colParam['style']['width'][0]); |
|
| 5331 | - foreach ($colParam['style']['width'] as $width) { |
|
| 5332 | - if (substr($total, -1)=='%' && substr($width, -1)=='%') |
|
| 5333 | - $total = (str_replace('%', '', $total)+str_replace('%', '', $width)).'%'; |
|
| 5334 | - else |
|
| 5335 | - $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm'; |
|
| 5336 | - } |
|
| 5337 | - } |
|
| 5338 | - |
|
| 5339 | - // get the final width |
|
| 5340 | - if ($total) { |
|
| 5341 | - $colParam['style']['width'] = $total; |
|
| 5342 | - } else { |
|
| 5343 | - unset($colParam['style']['width']); |
|
| 5344 | - } |
|
| 5345 | - |
|
| 5346 | - |
|
| 5347 | - // merge the styles of the COL and the TD |
|
| 5348 | - $param['style'] = array_merge($colParam['style'], $param['style']); |
|
| 5349 | - |
|
| 5350 | - // merge the class of the COL and the TD |
|
| 5351 | - if (isset($colParam['class'])) { |
|
| 5352 | - $param['class'] = $colParam['class'].(isset($param['class']) ? ' '.$param['class'] : ''); |
|
| 5353 | - } |
|
| 5354 | - } |
|
| 5355 | - |
|
| 5356 | - $collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false; |
|
| 5357 | - } |
|
| 5358 | - |
|
| 5359 | - $this->parsingCss->save(); |
|
| 5360 | - |
|
| 5361 | - // legacy for TD and TH |
|
| 5362 | - $legacy = null; |
|
| 5363 | - if (in_array($other, array('td', 'th'))) { |
|
| 5364 | - $legacy = array(); |
|
| 5365 | - |
|
| 5366 | - $old = $this->parsingCss->getLastValue('background'); |
|
| 5367 | - if ($old && ($old['color'] || $old['image'])) |
|
| 5368 | - $legacy['background'] = $old; |
|
| 5369 | - |
|
| 5370 | - if (HTML2PDF::$_tables[$param['num']]['border']) { |
|
| 5371 | - $legacy['border'] = array(); |
|
| 5372 | - $legacy['border']['l'] = HTML2PDF::$_tables[$param['num']]['border']; |
|
| 5373 | - $legacy['border']['t'] = HTML2PDF::$_tables[$param['num']]['border']; |
|
| 5374 | - $legacy['border']['r'] = HTML2PDF::$_tables[$param['num']]['border']; |
|
| 5375 | - $legacy['border']['b'] = HTML2PDF::$_tables[$param['num']]['border']; |
|
| 5376 | - } |
|
| 5377 | - } |
|
| 5378 | - $return = $this->parsingCss->analyse($other, $param, $legacy); |
|
| 5379 | - |
|
| 5380 | - if ($specialLi) { |
|
| 5381 | - $this->parsingCss->value['width']-= $this->parsingCss->ConvertToMM($this->_listeGetWidth()); |
|
| 5382 | - $this->parsingCss->value['width']-= $this->parsingCss->ConvertToMM($this->_listeGetPadding()); |
|
| 5383 | - } |
|
| 5384 | - $this->parsingCss->setPosition(); |
|
| 5385 | - $this->parsingCss->fontSet(); |
|
| 5386 | - |
|
| 5387 | - // if tale collapse => modify the borders |
|
| 5388 | - if ($collapse) { |
|
| 5389 | - if (!$this->_subPart) { |
|
| 5390 | - if ( |
|
| 5391 | - (HTML2PDF::$_tables[$param['num']]['tr_curr']>1 && !HTML2PDF::$_tables[$param['num']]['new_page']) || |
|
| 5392 | - (!$this->_isInThead && count(HTML2PDF::$_tables[$param['num']]['thead']['code'])) |
|
| 5393 | - ) { |
|
| 5394 | - $this->parsingCss->value['border']['t'] = $this->parsingCss->readBorder('none'); |
|
| 5395 | - } |
|
| 5396 | - } |
|
| 5397 | - |
|
| 5398 | - if (HTML2PDF::$_tables[$param['num']]['td_curr']>0) { |
|
| 5399 | - if (!$return) $this->parsingCss->value['width']+= $this->parsingCss->value['border']['l']['width']; |
|
| 5400 | - $this->parsingCss->value['border']['l'] = $this->parsingCss->readBorder('none'); |
|
| 5401 | - } |
|
| 5402 | - } |
|
| 5403 | - |
|
| 5404 | - // margins of the table |
|
| 5405 | - $marge = array(); |
|
| 5406 | - $marge['t'] = $this->parsingCss->value['padding']['t']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['t']['width']; |
|
| 5407 | - $marge['r'] = $this->parsingCss->value['padding']['r']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['r']['width']; |
|
| 5408 | - $marge['b'] = $this->parsingCss->value['padding']['b']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['b']['width']; |
|
| 5409 | - $marge['l'] = $this->parsingCss->value['padding']['l']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['l']['width']; |
|
| 5410 | - |
|
| 5411 | - // if we are in a sub HTML |
|
| 5412 | - if ($this->_subPart) { |
|
| 5413 | - // new position in the table |
|
| 5414 | - HTML2PDF::$_tables[$param['num']]['td_curr']++; |
|
| 5415 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x] = array(); |
|
| 5416 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'] = 0; |
|
| 5417 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'] = 0; |
|
| 5418 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw'] = 0; |
|
| 5419 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['colspan'] = $colspan; |
|
| 5420 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['rowspan'] = $rowspan; |
|
| 5421 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Xr'] = HTML2PDF::$_tables[$param['num']]['corr_x']; |
|
| 5422 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Yr'] = HTML2PDF::$_tables[$param['num']]['corr_y']; |
|
| 5423 | - |
|
| 5424 | - // prepare the mapping for rowspan and colspan |
|
| 5425 | - for ($j=0; $j<$rowspan; $j++) { |
|
| 5426 | - for ($i=0; $i<$colspan; $i++) { |
|
| 5427 | - HTML2PDF::$_tables[$param['num']]['corr'] |
|
| 5428 | - [HTML2PDF::$_tables[$param['num']]['corr_y']+$j] |
|
| 5429 | - [HTML2PDF::$_tables[$param['num']]['corr_x']+$i] = ($i+$j>0) ? '' : array($x,$y,$colspan,$rowspan); |
|
| 5430 | - } |
|
| 5431 | - } |
|
| 5432 | - HTML2PDF::$_tables[$param['num']]['corr_x']+= $colspan; |
|
| 5433 | - while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) { |
|
| 5434 | - HTML2PDF::$_tables[$param['num']]['corr_x']++; |
|
| 5435 | - } |
|
| 5436 | - |
|
| 5437 | - // extract the content of the TD, and calculate his size |
|
| 5438 | - $level = $this->parsingHtml->getLevel($this->_tempPos); |
|
| 5439 | - $this->_createSubHTML($this->_subHtml); |
|
| 5440 | - $this->_subHtml->parsingHtml->code = $level; |
|
| 5441 | - $this->_subHtml->_makeHTMLcode(); |
|
| 5442 | - $this->_tempPos+= count($level); |
|
| 5443 | - } else { |
|
| 5444 | - // new position in the table |
|
| 5445 | - HTML2PDF::$_tables[$param['num']]['td_curr']++; |
|
| 5446 | - HTML2PDF::$_tables[$param['num']]['td_x']+= HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw']; |
|
| 5447 | - |
|
| 5448 | - // borders and background of the TD |
|
| 5449 | - $this->_drawRectangle( |
|
| 5450 | - HTML2PDF::$_tables[$param['num']]['td_x'], |
|
| 5451 | - HTML2PDF::$_tables[$param['num']]['td_y'], |
|
| 5452 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'], |
|
| 5453 | - HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'], |
|
| 5454 | - $this->parsingCss->value['border'], |
|
| 5455 | - $this->parsingCss->value['padding'], |
|
| 5456 | - HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5, |
|
| 5457 | - $this->parsingCss->value['background'] |
|
| 5458 | - ); |
|
| 5459 | - |
|
| 5460 | - $this->parsingCss->value['width'] = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'] - $marge['l'] - $marge['r']; |
|
| 5461 | - |
|
| 5462 | - // marges = size of the TD |
|
| 5463 | - $mL = HTML2PDF::$_tables[$param['num']]['td_x']+$marge['l']; |
|
| 5464 | - $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width']; |
|
| 5465 | - $this->_saveMargin($mL, 0, $mR); |
|
| 5466 | - |
|
| 5467 | - // position of the content, from vertical-align |
|
| 5468 | - $hCorr = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h']; |
|
| 5469 | - $hReel = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['real_h']; |
|
| 5470 | - switch($this->parsingCss->value['vertical-align']) |
|
| 5471 | - { |
|
| 5472 | - case 'bottom': |
|
| 5473 | - $yCorr = $hCorr-$hReel; |
|
| 5474 | - break; |
|
| 5475 | - |
|
| 5476 | - case 'middle': |
|
| 5477 | - $yCorr = ($hCorr-$hReel)*0.5; |
|
| 5478 | - break; |
|
| 5479 | - |
|
| 5480 | - case 'top': |
|
| 5481 | - default: |
|
| 5482 | - $yCorr = 0; |
|
| 5483 | - break; |
|
| 5484 | - } |
|
| 5485 | - |
|
| 5486 | - // position of the content |
|
| 5487 | - $x = HTML2PDF::$_tables[$param['num']]['td_x']+$marge['l']; |
|
| 5488 | - $y = HTML2PDF::$_tables[$param['num']]['td_y']+$marge['t']+$yCorr; |
|
| 5489 | - $this->pdf->setXY($x, $y); |
|
| 5490 | - $this->_setNewPositionForNewLine(); |
|
| 5491 | - } |
|
| 5492 | - |
|
| 5493 | - return true; |
|
| 5494 | - } |
|
| 5495 | - |
|
| 5496 | - /** |
|
| 5497 | - * tag : TD |
|
| 5498 | - * mode : CLOSE |
|
| 5499 | - * |
|
| 5500 | - * @param array $param |
|
| 5501 | - * @return boolean |
|
| 5502 | - */ |
|
| 5503 | - protected function _tag_close_TD($param) |
|
| 5504 | - { |
|
| 5505 | - if ($this->_isForOneLine) return false; |
|
| 5506 | - |
|
| 5507 | - $this->_maxH = 0; |
|
| 5508 | - |
|
| 5509 | - // get the margins |
|
| 5510 | - $marge = array(); |
|
| 5511 | - $marge['t'] = $this->parsingCss->value['padding']['t']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['t']['width']; |
|
| 5512 | - $marge['r'] = $this->parsingCss->value['padding']['r']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['r']['width']; |
|
| 5513 | - $marge['b'] = $this->parsingCss->value['padding']['b']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['b']['width']; |
|
| 5514 | - $marge['l'] = $this->parsingCss->value['padding']['l']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['l']['width']; |
|
| 5515 | - $marge['t']+= 0.001; |
|
| 5516 | - $marge['r']+= 0.001; |
|
| 5517 | - $marge['b']+= 0.001; |
|
| 5518 | - $marge['l']+= 0.001; |
|
| 5519 | - |
|
| 5520 | - // if we are in a sub HTML |
|
| 5521 | - if ($this->_subPart) { |
|
| 5522 | - |
|
| 5523 | - // it msut take only one page |
|
| 5524 | - if ($this->_testTdInOnepage && $this->_subHtml->pdf->getPage()>1) { |
|
| 5525 | - throw new HTML2PDF_exception(7); |
|
| 5526 | - } |
|
| 5527 | - |
|
| 5528 | - // size of the content of the TD |
|
| 5529 | - $w0 = $this->_subHtml->_maxX + $marge['l'] + $marge['r']; |
|
| 5530 | - $h0 = $this->_subHtml->_maxY + $marge['t'] + $marge['b']; |
|
| 5531 | - |
|
| 5532 | - // size from the CSS style |
|
| 5533 | - $w2 = $this->parsingCss->value['width'] + $marge['l'] + $marge['r']; |
|
| 5534 | - $h2 = $this->parsingCss->value['height'] + $marge['t'] + $marge['b']; |
|
| 5535 | - |
|
| 5536 | - // final size of the TD |
|
| 5537 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['w'] = max(array($w0, $w2)); |
|
| 5538 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['h'] = max(array($h0, $h2)); |
|
| 5539 | - |
|
| 5540 | - // real position of the content |
|
| 5541 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['real_w'] = $w0; |
|
| 5542 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['real_h'] = $h0; |
|
| 5543 | - |
|
| 5544 | - // destroy the sub HTML |
|
| 5545 | - $this->_destroySubHTML($this->_subHtml); |
|
| 5546 | - } else { |
|
| 5547 | - $this->_loadMargin(); |
|
| 5548 | - |
|
| 5549 | - 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']; |
|
| 5550 | - } |
|
| 5551 | - |
|
| 5552 | - $this->parsingCss->load(); |
|
| 5553 | - $this->parsingCss->fontSet(); |
|
| 5554 | - |
|
| 5555 | - return true; |
|
| 5556 | - } |
|
| 5557 | - |
|
| 5558 | - |
|
| 5559 | - /** |
|
| 5560 | - * tag : TH |
|
| 5561 | - * mode : OPEN |
|
| 5562 | - * |
|
| 5563 | - * @param array $param |
|
| 5564 | - * @return boolean |
|
| 5565 | - */ |
|
| 5566 | - protected function _tag_open_TH($param) |
|
| 5567 | - { |
|
| 5568 | - if ($this->_isForOneLine) return false; |
|
| 5569 | - |
|
| 5570 | - $this->parsingCss->save(); |
|
| 5571 | - $this->parsingCss->value['font-bold'] = true; |
|
| 5572 | - |
|
| 5573 | - $this->_tag_open_TD($param, 'th'); |
|
| 5574 | - |
|
| 5575 | - return true; |
|
| 5576 | - } |
|
| 5577 | - |
|
| 5578 | - /** |
|
| 5579 | - * tag : TH |
|
| 5580 | - * mode : CLOSE |
|
| 5581 | - * |
|
| 5582 | - * @param array $param |
|
| 5583 | - * @return boolean |
|
| 5584 | - */ |
|
| 5585 | - protected function _tag_close_TH($param) |
|
| 5586 | - { |
|
| 5587 | - if ($this->_isForOneLine) return false; |
|
| 5588 | - |
|
| 5589 | - $this->_tag_close_TD($param); |
|
| 5590 | - |
|
| 5591 | - $this->parsingCss->load(); |
|
| 5592 | - |
|
| 5593 | - return true; |
|
| 5594 | - } |
|
| 5595 | - |
|
| 5596 | - /** |
|
| 5597 | - * tag : IMG |
|
| 5598 | - * mode : OPEN |
|
| 5599 | - * |
|
| 5600 | - * @param array $param |
|
| 5601 | - * @return boolean |
|
| 5602 | - */ |
|
| 5603 | - protected function _tag_open_IMG($param) |
|
| 5604 | - { |
|
| 5605 | - $src = str_replace('&', '&', $param['src']); |
|
| 5606 | - |
|
| 5607 | - $this->parsingCss->save(); |
|
| 5608 | - $this->parsingCss->value['width'] = 0; |
|
| 5609 | - $this->parsingCss->value['height'] = 0; |
|
| 5610 | - $this->parsingCss->value['border'] = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0)); |
|
| 5611 | - $this->parsingCss->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null); |
|
| 5612 | - $this->parsingCss->analyse('img', $param); |
|
| 5613 | - $this->parsingCss->setPosition(); |
|
| 5614 | - $this->parsingCss->fontSet(); |
|
| 5615 | - |
|
| 5616 | - $res = $this->_drawImage($src, isset($param['sub_li'])); |
|
| 5617 | - if (!$res) return $res; |
|
| 5618 | - |
|
| 5619 | - $this->parsingCss->load(); |
|
| 5620 | - $this->parsingCss->fontSet(); |
|
| 5621 | - $this->_maxE++; |
|
| 5622 | - |
|
| 5623 | - return true; |
|
| 5624 | - } |
|
| 5625 | - |
|
| 5626 | - /** |
|
| 5627 | - * tag : SELECT |
|
| 5628 | - * mode : OPEN |
|
| 5629 | - * |
|
| 5630 | - * @param array $param |
|
| 5631 | - * @return boolean |
|
| 5632 | - */ |
|
| 5633 | - protected function _tag_open_SELECT($param) |
|
| 5634 | - { |
|
| 5635 | - if (!isset($param['name'])) { |
|
| 5636 | - $param['name'] = 'champs_pdf_'.(count($this->_lstField)+1); |
|
| 5637 | - } |
|
| 5638 | - |
|
| 5639 | - $param['name'] = strtolower($param['name']); |
|
| 5640 | - |
|
| 5641 | - if (isset($this->_lstField[$param['name']])) { |
|
| 5642 | - $this->_lstField[$param['name']]++; |
|
| 5643 | - } else { |
|
| 5644 | - $this->_lstField[$param['name']] = 1; |
|
| 5645 | - } |
|
| 5646 | - |
|
| 5647 | - $this->parsingCss->save(); |
|
| 5648 | - $this->parsingCss->analyse('select', $param); |
|
| 5649 | - $this->parsingCss->setPosition(); |
|
| 5650 | - $this->parsingCss->fontSet(); |
|
| 5651 | - |
|
| 5652 | - $this->_lstSelect = array(); |
|
| 5653 | - $this->_lstSelect['name'] = $param['name']; |
|
| 5654 | - $this->_lstSelect['multi'] = isset($param['multiple']) ? true : false; |
|
| 5655 | - $this->_lstSelect['size'] = isset($param['size']) ? $param['size'] : 1; |
|
| 5656 | - $this->_lstSelect['options'] = array(); |
|
| 5657 | - |
|
| 5658 | - if ($this->_lstSelect['multi'] && $this->_lstSelect['size']<3) $this->_lstSelect['size'] = 3; |
|
| 5659 | - |
|
| 5660 | - return true; |
|
| 5661 | - } |
|
| 5662 | - |
|
| 5663 | - /** |
|
| 5664 | - * tag : OPTION |
|
| 5665 | - * mode : OPEN |
|
| 5666 | - * |
|
| 5667 | - * @param array $param |
|
| 5668 | - * @return boolean |
|
| 5669 | - */ |
|
| 5670 | - protected function _tag_open_OPTION($param) |
|
| 5671 | - { |
|
| 5672 | - // get the content of the option : it is the text of the option |
|
| 5673 | - $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 5674 | - $this->_parsePos+= count($level); |
|
| 5675 | - $value = isset($param['value']) ? $param['value'] : 'aut_tag_open_opt_'.(count($this->_lstSelect)+1); |
|
| 5676 | - |
|
| 5677 | - $this->_lstSelect['options'][$value] = isset($level[0]['param']['txt']) ? $level[0]['param']['txt'] : ''; |
|
| 5678 | - |
|
| 5679 | - return true; |
|
| 5680 | - } |
|
| 5681 | - |
|
| 5682 | - /** |
|
| 5683 | - * tag : OPTION |
|
| 5684 | - * mode : CLOSE |
|
| 5685 | - * |
|
| 5686 | - * @param array $param |
|
| 5687 | - * @return boolean |
|
| 5688 | - */ |
|
| 5689 | - protected function _tag_close_OPTION($param) |
|
| 5690 | - { |
|
| 5691 | - // nothing to do here |
|
| 5692 | - |
|
| 5693 | - return true; |
|
| 5694 | - } |
|
| 5695 | - |
|
| 5696 | - /** |
|
| 5697 | - * tag : SELECT |
|
| 5698 | - * mode : CLOSE |
|
| 5699 | - * |
|
| 5700 | - * @param array $param |
|
| 5701 | - * @return boolean |
|
| 5702 | - */ |
|
| 5703 | - protected function _tag_close_SELECT() |
|
| 5704 | - { |
|
| 5705 | - // position of the select |
|
| 5706 | - $x = $this->pdf->getX(); |
|
| 5707 | - $y = $this->pdf->getY(); |
|
| 5708 | - $f = 1.08*$this->parsingCss->value['font-size']; |
|
| 5709 | - |
|
| 5710 | - // width |
|
| 5711 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 50; |
|
| 5712 | - |
|
| 5713 | - // height (automatic) |
|
| 5714 | - $h = ($f*1.07*$this->_lstSelect['size'] + 1); |
|
| 5715 | - |
|
| 5716 | - $prop = $this->parsingCss->getFormStyle(); |
|
| 5717 | - |
|
| 5718 | - // multy select |
|
| 5719 | - if ($this->_lstSelect['multi']) { |
|
| 5720 | - $prop['multipleSelection'] = 'true'; |
|
| 5721 | - } |
|
| 5722 | - |
|
| 5723 | - |
|
| 5724 | - // single or multi select |
|
| 5725 | - if ($this->_lstSelect['size']>1) { |
|
| 5726 | - $this->pdf->ListBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop); |
|
| 5727 | - } else { |
|
| 5728 | - $this->pdf->ComboBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop); |
|
| 5729 | - } |
|
| 5730 | - |
|
| 5731 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 5732 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 5733 | - $this->_maxH = max($this->_maxH, $h); |
|
| 5734 | - $this->_maxE++; |
|
| 5735 | - $this->pdf->setX($x+$w); |
|
| 5736 | - |
|
| 5737 | - $this->parsingCss->load(); |
|
| 5738 | - $this->parsingCss->fontSet(); |
|
| 5739 | - |
|
| 5740 | - $this->_lstSelect = array(); |
|
| 5741 | - |
|
| 5742 | - return true; |
|
| 5743 | - } |
|
| 5744 | - |
|
| 5745 | - /** |
|
| 5746 | - * tag : TEXTAREA |
|
| 5747 | - * mode : OPEN |
|
| 5748 | - * |
|
| 5749 | - * @param array $param |
|
| 5750 | - * @return boolean |
|
| 5751 | - */ |
|
| 5752 | - protected function _tag_open_TEXTAREA($param) |
|
| 5753 | - { |
|
| 5754 | - if (!isset($param['name'])) { |
|
| 5755 | - $param['name'] = 'champs_pdf_'.(count($this->_lstField)+1); |
|
| 5756 | - } |
|
| 5757 | - |
|
| 5758 | - $param['name'] = strtolower($param['name']); |
|
| 5759 | - |
|
| 5760 | - if (isset($this->_lstField[$param['name']])) { |
|
| 5761 | - $this->_lstField[$param['name']]++; |
|
| 5762 | - } else { |
|
| 5763 | - $this->_lstField[$param['name']] = 1; |
|
| 5764 | - } |
|
| 5765 | - |
|
| 5766 | - $this->parsingCss->save(); |
|
| 5767 | - $this->parsingCss->analyse('textarea', $param); |
|
| 5768 | - $this->parsingCss->setPosition(); |
|
| 5769 | - $this->parsingCss->fontSet(); |
|
| 5770 | - |
|
| 5771 | - $x = $this->pdf->getX(); |
|
| 5772 | - $y = $this->pdf->getY(); |
|
| 5773 | - $fx = 0.65*$this->parsingCss->value['font-size']; |
|
| 5774 | - $fy = 1.08*$this->parsingCss->value['font-size']; |
|
| 5775 | - |
|
| 5776 | - // extract the content the textarea : value |
|
| 5777 | - $level = $this->parsingHtml->getLevel($this->_parsePos); |
|
| 5778 | - $this->_parsePos+= count($level); |
|
| 5779 | - |
|
| 5780 | - // automatic size, from cols and rows properties |
|
| 5781 | - $w = $fx*(isset($param['cols']) ? $param['cols'] : 22)+1; |
|
| 5782 | - $h = $fy*1.07*(isset($param['rows']) ? $param['rows'] : 3)+3; |
|
| 5783 | - |
|
| 5784 | - $prop = $this->parsingCss->getFormStyle(); |
|
| 5785 | - |
|
| 5786 | - $prop['multiline'] = true; |
|
| 5787 | - $prop['value'] = isset($level[0]['param']['txt']) ? $level[0]['param']['txt'] : ''; |
|
| 5788 | - |
|
| 5789 | - $this->pdf->TextField($param['name'], $w, $h, $prop, array(), $x, $y); |
|
| 5790 | - |
|
| 5791 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 5792 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 5793 | - $this->_maxH = max($this->_maxH, $h); |
|
| 5794 | - $this->_maxE++; |
|
| 5795 | - $this->pdf->setX($x+$w); |
|
| 5796 | - |
|
| 5797 | - return true; |
|
| 5798 | - } |
|
| 5799 | - |
|
| 5800 | - /** |
|
| 5801 | - * tag : TEXTAREA |
|
| 5802 | - * mode : CLOSE |
|
| 5803 | - * |
|
| 5804 | - * @param array $param |
|
| 5805 | - * @return boolean |
|
| 5806 | - */ |
|
| 5807 | - protected function _tag_close_TEXTAREA() |
|
| 5808 | - { |
|
| 5809 | - $this->parsingCss->load(); |
|
| 5810 | - $this->parsingCss->fontSet(); |
|
| 5811 | - |
|
| 5812 | - return true; |
|
| 5813 | - } |
|
| 5814 | - |
|
| 5815 | - /** |
|
| 5816 | - * tag : INPUT |
|
| 5817 | - * mode : OPEN |
|
| 5818 | - * |
|
| 5819 | - * @param array $param |
|
| 5820 | - * @return boolean |
|
| 5821 | - */ |
|
| 5822 | - protected function _tag_open_INPUT($param) |
|
| 5823 | - { |
|
| 5824 | - if (!isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->_lstField)+1); |
|
| 5825 | - if (!isset($param['value'])) $param['value'] = ''; |
|
| 5826 | - if (!isset($param['type'])) $param['type'] = 'text'; |
|
| 5827 | - |
|
| 5828 | - $param['name'] = strtolower($param['name']); |
|
| 5829 | - $param['type'] = strtolower($param['type']); |
|
| 5830 | - |
|
| 5831 | - // the type must be valid |
|
| 5832 | - if (!in_array($param['type'], array('text', 'checkbox', 'radio', 'hidden', 'submit', 'reset', 'button'))) { |
|
| 5833 | - $param['type'] = 'text'; |
|
| 5834 | - } |
|
| 5835 | - |
|
| 5836 | - if (isset($this->_lstField[$param['name']])) { |
|
| 5837 | - $this->_lstField[$param['name']]++; |
|
| 5838 | - } else { |
|
| 5839 | - $this->_lstField[$param['name']] = 1; |
|
| 5840 | - } |
|
| 5841 | - |
|
| 5842 | - $this->parsingCss->save(); |
|
| 5843 | - $this->parsingCss->analyse('input', $param); |
|
| 5844 | - $this->parsingCss->setPosition(); |
|
| 5845 | - $this->parsingCss->fontSet(); |
|
| 5846 | - |
|
| 5847 | - $name = $param['name']; |
|
| 5848 | - |
|
| 5849 | - $x = $this->pdf->getX(); |
|
| 5850 | - $y = $this->pdf->getY(); |
|
| 5851 | - $f = 1.08*$this->parsingCss->value['font-size']; |
|
| 5852 | - |
|
| 5853 | - $prop = $this->parsingCss->getFormStyle(); |
|
| 5854 | - |
|
| 5855 | - switch($param['type']) |
|
| 5856 | - { |
|
| 5857 | - case 'checkbox': |
|
| 5858 | - $w = 3; |
|
| 5859 | - $h = $w; |
|
| 5860 | - if ($h<$f) $y+= ($f-$h)*0.5; |
|
| 5861 | - $checked = (isset($param['checked']) && $param['checked']=='checked'); |
|
| 5862 | - $this->pdf->CheckBox($name, $w, $checked, $prop, array(), ($param['value'] ? $param['value'] : 'Yes'), $x, $y); |
|
| 5863 | - break; |
|
| 5864 | - |
|
| 5865 | - case 'radio': |
|
| 5866 | - $w = 3; |
|
| 5867 | - $h = $w; |
|
| 5868 | - if ($h<$f) $y+= ($f-$h)*0.5; |
|
| 5869 | - $checked = (isset($param['checked']) && $param['checked']=='checked'); |
|
| 5870 | - $this->pdf->RadioButton($name, $w, $prop, array(), ($param['value'] ? $param['value'] : 'On'), $checked, $x, $y); |
|
| 5871 | - break; |
|
| 5872 | - |
|
| 5873 | - case 'hidden': |
|
| 5874 | - $w = 0; |
|
| 5875 | - $h = 0; |
|
| 5876 | - $prop['value'] = $param['value']; |
|
| 5877 | - $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y); |
|
| 5878 | - break; |
|
| 5879 | - |
|
| 5880 | - case 'text': |
|
| 5881 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 40; |
|
| 5882 | - $h = $f*1.3; |
|
| 5883 | - $prop['value'] = $param['value']; |
|
| 5884 | - $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y); |
|
| 5885 | - break; |
|
| 5886 | - |
|
| 5887 | - case 'submit': |
|
| 5888 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 40; |
|
| 5889 | - $h = $this->parsingCss->value['height']; if (!$h) $h = $f*1.3; |
|
| 5890 | - $action = array('S'=>'SubmitForm', 'F'=>$this->_isInForm, 'Flags'=>array('ExportFormat')); |
|
| 5891 | - $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
|
| 5892 | - break; |
|
| 5893 | - |
|
| 5894 | - case 'reset': |
|
| 5895 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 40; |
|
| 5896 | - $h = $this->parsingCss->value['height']; if (!$h) $h = $f*1.3; |
|
| 5897 | - $action = array('S'=>'ResetForm'); |
|
| 5898 | - $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
|
| 5899 | - break; |
|
| 5900 | - |
|
| 5901 | - case 'button': |
|
| 5902 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 40; |
|
| 5903 | - $h = $this->parsingCss->value['height']; if (!$h) $h = $f*1.3; |
|
| 5904 | - $action = isset($param['onclick']) ? $param['onclick'] : ''; |
|
| 5905 | - $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
|
| 5906 | - break; |
|
| 5907 | - |
|
| 5908 | - default: |
|
| 5909 | - $w = 0; |
|
| 5910 | - $h = 0; |
|
| 5911 | - break; |
|
| 5912 | - } |
|
| 5913 | - |
|
| 5914 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 5915 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 5916 | - $this->_maxH = max($this->_maxH, $h); |
|
| 5917 | - $this->_maxE++; |
|
| 5918 | - $this->pdf->setX($x+$w); |
|
| 5919 | - |
|
| 5920 | - $this->parsingCss->load(); |
|
| 5921 | - $this->parsingCss->fontSet(); |
|
| 5922 | - |
|
| 5923 | - return true; |
|
| 5924 | - } |
|
| 5925 | - |
|
| 5926 | - /** |
|
| 5927 | - * tag : DRAW |
|
| 5928 | - * mode : OPEN |
|
| 5929 | - * |
|
| 5930 | - * @param array $param |
|
| 5931 | - * @return boolean |
|
| 5932 | - */ |
|
| 5933 | - protected function _tag_open_DRAW($param) |
|
| 5934 | - { |
|
| 5935 | - if ($this->_isForOneLine) return false; |
|
| 5936 | - if ($this->_debugActif) $this->_DEBUG_add('DRAW', true); |
|
| 5937 | - |
|
| 5938 | - $this->parsingCss->save(); |
|
| 5939 | - $this->parsingCss->analyse('draw', $param); |
|
| 5940 | - $this->parsingCss->fontSet(); |
|
| 5941 | - |
|
| 5942 | - $alignObject = null; |
|
| 5943 | - if ($this->parsingCss->value['margin-auto']) $alignObject = 'center'; |
|
| 5944 | - |
|
| 5945 | - $overW = $this->parsingCss->value['width']; |
|
| 5946 | - $overH = $this->parsingCss->value['height']; |
|
| 5947 | - $this->parsingCss->value['old_maxX'] = $this->_maxX; |
|
| 5948 | - $this->parsingCss->value['old_maxY'] = $this->_maxY; |
|
| 5949 | - $this->parsingCss->value['old_maxH'] = $this->_maxH; |
|
| 5950 | - |
|
| 5951 | - $w = $this->parsingCss->value['width']; |
|
| 5952 | - $h = $this->parsingCss->value['height']; |
|
| 5953 | - |
|
| 5954 | - if (!$this->parsingCss->value['position']) { |
|
| 5955 | - if ( |
|
| 5956 | - $w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) && |
|
| 5957 | - $this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin()) |
|
| 5958 | - ) |
|
| 5959 | - $this->_tag_open_BR(array()); |
|
| 5960 | - |
|
| 5961 | - if ( |
|
| 5962 | - ($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) && |
|
| 5963 | - ($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) && |
|
| 5964 | - !$this->_isInOverflow |
|
| 5965 | - ) |
|
| 5966 | - $this->_setNewPage(); |
|
| 5967 | - |
|
| 5968 | - $old = $this->parsingCss->getOldValues(); |
|
| 5969 | - $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 5970 | - |
|
| 5971 | - if ($parentWidth>$w) { |
|
| 5972 | - if ($alignObject=='center') $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 5973 | - else if ($alignObject=='right') $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 5974 | - } |
|
| 5975 | - |
|
| 5976 | - $this->parsingCss->setPosition(); |
|
| 5977 | - } else { |
|
| 5978 | - $old = $this->parsingCss->getOldValues(); |
|
| 5979 | - $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
|
| 5980 | - |
|
| 5981 | - if ($parentWidth>$w) { |
|
| 5982 | - if ($alignObject=='center') $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 5983 | - else if ($alignObject=='right') $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 5984 | - } |
|
| 5985 | - |
|
| 5986 | - $this->parsingCss->setPosition(); |
|
| 5987 | - $this->_saveMax(); |
|
| 5988 | - $this->_maxX = 0; |
|
| 5989 | - $this->_maxY = 0; |
|
| 5990 | - $this->_maxH = 0; |
|
| 5991 | - $this->_maxE = 0; |
|
| 5992 | - } |
|
| 5993 | - |
|
| 5994 | - $this->_drawRectangle( |
|
| 5995 | - $this->parsingCss->value['x'], |
|
| 5996 | - $this->parsingCss->value['y'], |
|
| 5997 | - $this->parsingCss->value['width'], |
|
| 5998 | - $this->parsingCss->value['height'], |
|
| 5999 | - $this->parsingCss->value['border'], |
|
| 6000 | - $this->parsingCss->value['padding'], |
|
| 6001 | - 0, |
|
| 6002 | - $this->parsingCss->value['background'] |
|
| 6003 | - ); |
|
| 6004 | - |
|
| 6005 | - $marge = array(); |
|
| 6006 | - $marge['l'] = $this->parsingCss->value['border']['l']['width']; |
|
| 6007 | - $marge['r'] = $this->parsingCss->value['border']['r']['width']; |
|
| 6008 | - $marge['t'] = $this->parsingCss->value['border']['t']['width']; |
|
| 6009 | - $marge['b'] = $this->parsingCss->value['border']['b']['width']; |
|
| 6010 | - |
|
| 6011 | - $this->parsingCss->value['width'] -= $marge['l']+$marge['r']; |
|
| 6012 | - $this->parsingCss->value['height']-= $marge['t']+$marge['b']; |
|
| 6013 | - |
|
| 6014 | - $overW-= $marge['l']+$marge['r']; |
|
| 6015 | - $overH-= $marge['t']+$marge['b']; |
|
| 6016 | - |
|
| 6017 | - // clipping to draw only in the size opf the DRAW tag |
|
| 6018 | - $this->pdf->clippingPathStart( |
|
| 6019 | - $this->parsingCss->value['x']+$marge['l'], |
|
| 6020 | - $this->parsingCss->value['y']+$marge['t'], |
|
| 6021 | - $this->parsingCss->value['width'], |
|
| 6022 | - $this->parsingCss->value['height'] |
|
| 6023 | - ); |
|
| 6024 | - |
|
| 6025 | - // left and right of the DRAW tag |
|
| 6026 | - $mL = $this->parsingCss->value['x']+$marge['l']; |
|
| 6027 | - $mR = $this->pdf->getW() - $mL - $overW; |
|
| 6028 | - |
|
| 6029 | - // position of the DRAW tag |
|
| 6030 | - $x = $this->parsingCss->value['x']+$marge['l']; |
|
| 6031 | - $y = $this->parsingCss->value['y']+$marge['t']; |
|
| 6032 | - |
|
| 6033 | - // prepare the drawing area |
|
| 6034 | - $this->_saveMargin($mL, 0, $mR); |
|
| 6035 | - $this->pdf->setXY($x, $y); |
|
| 6036 | - |
|
| 6037 | - // we are in a draw tag |
|
| 6038 | - $this->_isInDraw = array( |
|
| 6039 | - 'x' => $x, |
|
| 6040 | - 'y' => $y, |
|
| 6041 | - 'w' => $overW, |
|
| 6042 | - 'h' => $overH, |
|
| 6043 | - ); |
|
| 6044 | - |
|
| 6045 | - // init the translate matrix : (0,0) => ($x, $y) |
|
| 6046 | - $this->pdf->doTransform(array(1,0,0,1,$x,$y)); |
|
| 6047 | - $this->pdf->SetAlpha(1.); |
|
| 6048 | - return true; |
|
| 6049 | - } |
|
| 6050 | - |
|
| 6051 | - /** |
|
| 6052 | - * tag : DRAW |
|
| 6053 | - * mode : CLOSE |
|
| 6054 | - * |
|
| 6055 | - * @param array $param |
|
| 6056 | - * @return boolean |
|
| 6057 | - */ |
|
| 6058 | - protected function _tag_close_DRAW($param) |
|
| 6059 | - { |
|
| 6060 | - if ($this->_isForOneLine) return false; |
|
| 6061 | - |
|
| 6062 | - $this->pdf->SetAlpha(1.); |
|
| 6063 | - $this->pdf->undoTransform(); |
|
| 6064 | - $this->pdf->clippingPathStop(); |
|
| 6065 | - |
|
| 6066 | - $this->_maxX = $this->parsingCss->value['old_maxX']; |
|
| 6067 | - $this->_maxY = $this->parsingCss->value['old_maxY']; |
|
| 6068 | - $this->_maxH = $this->parsingCss->value['old_maxH']; |
|
| 6069 | - |
|
| 6070 | - $marge = array(); |
|
| 6071 | - $marge['l'] = $this->parsingCss->value['border']['l']['width']; |
|
| 6072 | - $marge['r'] = $this->parsingCss->value['border']['r']['width']; |
|
| 6073 | - $marge['t'] = $this->parsingCss->value['border']['t']['width']; |
|
| 6074 | - $marge['b'] = $this->parsingCss->value['border']['b']['width']; |
|
| 6075 | - |
|
| 6076 | - $x = $this->parsingCss->value['x']; |
|
| 6077 | - $y = $this->parsingCss->value['y']; |
|
| 6078 | - $w = $this->parsingCss->value['width']+$marge['l']+$marge['r']; |
|
| 6079 | - $h = $this->parsingCss->value['height']+$marge['t']+$marge['b']; |
|
| 6080 | - |
|
| 6081 | - if ($this->parsingCss->value['position']!='absolute') { |
|
| 6082 | - $this->pdf->setXY($x+$w, $y); |
|
| 6083 | - |
|
| 6084 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 6085 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 6086 | - $this->_maxH = max($this->_maxH, $h); |
|
| 6087 | - $this->_maxE++; |
|
| 6088 | - } else { |
|
| 6089 | - // position |
|
| 6090 | - $this->pdf->setXY($this->parsingCss->value['xc'], $this->parsingCss->value['yc']); |
|
| 6091 | - |
|
| 6092 | - $this->_loadMax(); |
|
| 6093 | - } |
|
| 6094 | - |
|
| 6095 | - $block = ($this->parsingCss->value['display']!='inline' && $this->parsingCss->value['position']!='absolute'); |
|
| 6096 | - |
|
| 6097 | - $this->parsingCss->load(); |
|
| 6098 | - $this->parsingCss->fontSet(); |
|
| 6099 | - $this->_loadMargin(); |
|
| 6100 | - |
|
| 6101 | - if ($block) $this->_tag_open_BR(array()); |
|
| 6102 | - if ($this->_debugActif) $this->_DEBUG_add('DRAW', false); |
|
| 6103 | - |
|
| 6104 | - $this->_isInDraw = null; |
|
| 6105 | - |
|
| 6106 | - return true; |
|
| 6107 | - } |
|
| 6108 | - |
|
| 6109 | - /** |
|
| 6110 | - * tag : LINE |
|
| 6111 | - * mode : OPEN |
|
| 6112 | - * |
|
| 6113 | - * @param array $param |
|
| 6114 | - * @return boolean |
|
| 6115 | - */ |
|
| 6116 | - protected function _tag_open_LINE($param) |
|
| 6117 | - { |
|
| 6118 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'LINE'); |
|
| 6119 | - |
|
| 6120 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6121 | - $this->parsingCss->save(); |
|
| 6122 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6123 | - $styles['fill'] = null; |
|
| 6124 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6125 | - |
|
| 6126 | - $x1 = isset($param['x1']) ? $this->parsingCss->ConvertToMM($param['x1'], $this->_isInDraw['w']) : 0.; |
|
| 6127 | - $y1 = isset($param['y1']) ? $this->parsingCss->ConvertToMM($param['y1'], $this->_isInDraw['h']) : 0.; |
|
| 6128 | - $x2 = isset($param['x2']) ? $this->parsingCss->ConvertToMM($param['x2'], $this->_isInDraw['w']) : 0.; |
|
| 6129 | - $y2 = isset($param['y2']) ? $this->parsingCss->ConvertToMM($param['y2'], $this->_isInDraw['h']) : 0.; |
|
| 6130 | - $this->pdf->svgLine($x1, $y1, $x2, $y2); |
|
| 6131 | - |
|
| 6132 | - $this->pdf->undoTransform(); |
|
| 6133 | - $this->parsingCss->load(); |
|
| 6134 | - } |
|
| 6135 | - |
|
| 6136 | - /** |
|
| 6137 | - * tag : RECT |
|
| 6138 | - * mode : OPEN |
|
| 6139 | - * |
|
| 6140 | - * @param array $param |
|
| 6141 | - * @return boolean |
|
| 6142 | - */ |
|
| 6143 | - protected function _tag_open_RECT($param) |
|
| 6144 | - { |
|
| 6145 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'RECT'); |
|
| 6146 | - |
|
| 6147 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6148 | - $this->parsingCss->save(); |
|
| 6149 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6150 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6151 | - |
|
| 6152 | - $x = isset($param['x']) ? $this->parsingCss->ConvertToMM($param['x'], $this->_isInDraw['w']) : 0.; |
|
| 6153 | - $y = isset($param['y']) ? $this->parsingCss->ConvertToMM($param['y'], $this->_isInDraw['h']) : 0.; |
|
| 6154 | - $w = isset($param['w']) ? $this->parsingCss->ConvertToMM($param['w'], $this->_isInDraw['w']) : 0.; |
|
| 6155 | - $h = isset($param['h']) ? $this->parsingCss->ConvertToMM($param['h'], $this->_isInDraw['h']) : 0.; |
|
| 6156 | - |
|
| 6157 | - $this->pdf->svgRect($x, $y, $w, $h, $style); |
|
| 6158 | - |
|
| 6159 | - $this->pdf->undoTransform(); |
|
| 6160 | - $this->parsingCss->load(); |
|
| 6161 | - } |
|
| 6162 | - |
|
| 6163 | - /** |
|
| 6164 | - * tag : CIRCLE |
|
| 6165 | - * mode : OPEN |
|
| 6166 | - * |
|
| 6167 | - * @param array $param |
|
| 6168 | - * @return boolean |
|
| 6169 | - */ |
|
| 6170 | - protected function _tag_open_CIRCLE($param) |
|
| 6171 | - { |
|
| 6172 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'CIRCLE'); |
|
| 6173 | - |
|
| 6174 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6175 | - $this->parsingCss->save(); |
|
| 6176 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6177 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6178 | - |
|
| 6179 | - $cx = isset($param['cx']) ? $this->parsingCss->ConvertToMM($param['cx'], $this->_isInDraw['w']) : 0.; |
|
| 6180 | - $cy = isset($param['cy']) ? $this->parsingCss->ConvertToMM($param['cy'], $this->_isInDraw['h']) : 0.; |
|
| 6181 | - $r = isset($param['r']) ? $this->parsingCss->ConvertToMM($param['r'], $this->_isInDraw['w']) : 0.; |
|
| 6182 | - $this->pdf->svgEllipse($cx, $cy, $r, $r, $style); |
|
| 6183 | - |
|
| 6184 | - $this->pdf->undoTransform(); |
|
| 6185 | - $this->parsingCss->load(); |
|
| 6186 | - } |
|
| 6187 | - |
|
| 6188 | - /** |
|
| 6189 | - * tag : ELLIPSE |
|
| 6190 | - * mode : OPEN |
|
| 6191 | - * |
|
| 6192 | - * @param array $param |
|
| 6193 | - * @return boolean |
|
| 6194 | - */ |
|
| 6195 | - protected function _tag_open_ELLIPSE($param) |
|
| 6196 | - { |
|
| 6197 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'ELLIPSE'); |
|
| 6198 | - |
|
| 6199 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6200 | - $this->parsingCss->save(); |
|
| 6201 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6202 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6203 | - |
|
| 6204 | - $cx = isset($param['cx']) ? $this->parsingCss->ConvertToMM($param['cx'], $this->_isInDraw['w']) : 0.; |
|
| 6205 | - $cy = isset($param['cy']) ? $this->parsingCss->ConvertToMM($param['cy'], $this->_isInDraw['h']) : 0.; |
|
| 6206 | - $rx = isset($param['ry']) ? $this->parsingCss->ConvertToMM($param['rx'], $this->_isInDraw['w']) : 0.; |
|
| 6207 | - $ry = isset($param['rx']) ? $this->parsingCss->ConvertToMM($param['ry'], $this->_isInDraw['h']) : 0.; |
|
| 6208 | - $this->pdf->svgEllipse($cx, $cy, $rx, $ry, $style); |
|
| 6209 | - |
|
| 6210 | - $this->pdf->undoTransform(); |
|
| 6211 | - $this->parsingCss->load(); |
|
| 6212 | - } |
|
| 6213 | - |
|
| 6214 | - |
|
| 6215 | - /** |
|
| 6216 | - * tag : POLYLINE |
|
| 6217 | - * mode : OPEN |
|
| 6218 | - * |
|
| 6219 | - * @param array $param |
|
| 6220 | - * @return boolean |
|
| 6221 | - */ |
|
| 6222 | - protected function _tag_open_POLYLINE($param) |
|
| 6223 | - { |
|
| 6224 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6225 | - |
|
| 6226 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6227 | - $this->parsingCss->save(); |
|
| 6228 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6229 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6230 | - |
|
| 6231 | - $path = isset($param['points']) ? $param['points'] : null; |
|
| 6232 | - if ($path) { |
|
| 6233 | - $path = str_replace(',', ' ', $path); |
|
| 6234 | - $path = preg_replace('/[\s]+/', ' ', trim($path)); |
|
| 6235 | - |
|
| 6236 | - // prepare the path |
|
| 6237 | - $path = explode(' ', $path); |
|
| 6238 | - foreach ($path as $k => $v) { |
|
| 6239 | - $path[$k] = trim($v); |
|
| 6240 | - if ($path[$k]==='') unset($path[$k]); |
|
| 6241 | - } |
|
| 6242 | - $path = array_values($path); |
|
| 6243 | - |
|
| 6244 | - $actions = array(); |
|
| 6245 | - for ($k=0; $k<count($path); $k+=2) { |
|
| 6246 | - $actions[] = array( |
|
| 6247 | - ($k ? 'L' : 'M') , |
|
| 6248 | - $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']), |
|
| 6249 | - $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']) |
|
| 6250 | - ); |
|
| 6251 | - } |
|
| 6252 | - |
|
| 6253 | - // drawing |
|
| 6254 | - $this->pdf->svgPolygone($actions, $style); |
|
| 6255 | - } |
|
| 6256 | - |
|
| 6257 | - $this->pdf->undoTransform(); |
|
| 6258 | - $this->parsingCss->load(); |
|
| 6259 | - } |
|
| 6260 | - |
|
| 6261 | - /** |
|
| 6262 | - * tag : POLYGON |
|
| 6263 | - * mode : OPEN |
|
| 6264 | - * |
|
| 6265 | - * @param array $param |
|
| 6266 | - * @return boolean |
|
| 6267 | - */ |
|
| 6268 | - protected function _tag_open_POLYGON($param) |
|
| 6269 | - { |
|
| 6270 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6271 | - |
|
| 6272 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6273 | - $this->parsingCss->save(); |
|
| 6274 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6275 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6276 | - |
|
| 6277 | - $path = (isset($param['points']) ? $param['points'] : null); |
|
| 6278 | - if ($path) { |
|
| 6279 | - $path = str_replace(',', ' ', $path); |
|
| 6280 | - $path = preg_replace('/[\s]+/', ' ', trim($path)); |
|
| 6281 | - |
|
| 6282 | - // prepare the path |
|
| 6283 | - $path = explode(' ', $path); |
|
| 6284 | - foreach ($path as $k => $v) { |
|
| 6285 | - $path[$k] = trim($v); |
|
| 6286 | - if ($path[$k]==='') unset($path[$k]); |
|
| 6287 | - } |
|
| 6288 | - $path = array_values($path); |
|
| 6289 | - |
|
| 6290 | - $actions = array(); |
|
| 6291 | - for ($k=0; $k<count($path); $k+=2) { |
|
| 6292 | - $actions[] = array( |
|
| 6293 | - ($k ? 'L' : 'M') , |
|
| 6294 | - $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']), |
|
| 6295 | - $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']) |
|
| 6296 | - ); |
|
| 6297 | - } |
|
| 6298 | - $actions[] = array('z'); |
|
| 6299 | - |
|
| 6300 | - // drawing |
|
| 6301 | - $this->pdf->svgPolygone($actions, $style); |
|
| 6302 | - } |
|
| 6303 | - |
|
| 6304 | - $this->pdf->undoTransform(); |
|
| 6305 | - $this->parsingCss->load(); |
|
| 6306 | - } |
|
| 6307 | - |
|
| 6308 | - /** |
|
| 6309 | - * tag : PATH |
|
| 6310 | - * mode : OPEN |
|
| 6311 | - * |
|
| 6312 | - * @param array $param |
|
| 6313 | - * @return boolean |
|
| 6314 | - */ |
|
| 6315 | - protected function _tag_open_PATH($param) |
|
| 6316 | - { |
|
| 6317 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'PATH'); |
|
| 6318 | - |
|
| 6319 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6320 | - $this->parsingCss->save(); |
|
| 6321 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6322 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6323 | - |
|
| 6324 | - $path = isset($param['d']) ? $param['d'] : null; |
|
| 6325 | - |
|
| 6326 | - if ($path) { |
|
| 6327 | - // prepare the path |
|
| 6328 | - $path = str_replace(',', ' ', $path); |
|
| 6329 | - $path = preg_replace('/([a-zA-Z])([0-9\.\-])/', '$1 $2', $path); |
|
| 6330 | - $path = preg_replace('/([0-9\.])([a-zA-Z])/', '$1 $2', $path); |
|
| 6331 | - $path = preg_replace('/[\s]+/', ' ', trim($path)); |
|
| 6332 | - $path = preg_replace('/ ([a-z]{2})/', '$1', $path); |
|
| 6333 | - |
|
| 6334 | - $path = explode(' ', $path); |
|
| 6335 | - foreach ($path as $k => $v) { |
|
| 6336 | - $path[$k] = trim($v); |
|
| 6337 | - if ($path[$k]==='') unset($path[$k]); |
|
| 6338 | - } |
|
| 6339 | - $path = array_values($path); |
|
| 6340 | - |
|
| 6341 | - // read each actions in the path |
|
| 6342 | - $actions = array(); |
|
| 6343 | - $action = array(); |
|
| 6344 | - $lastAction = null; // last action found |
|
| 6345 | - for ($k=0; $k<count($path);true) { |
|
| 6346 | - |
|
| 6347 | - // for this actions, we can not have multi coordonate |
|
| 6348 | - if (in_array($lastAction, array('z', 'Z'))) { |
|
| 6349 | - $lastAction = null; |
|
| 6350 | - } |
|
| 6351 | - |
|
| 6352 | - // read the new action (forcing if no action before) |
|
| 6353 | - if (preg_match('/^[a-z]+$/i', $path[$k]) || $lastAction===null) { |
|
| 6354 | - $lastAction = $path[$k]; |
|
| 6355 | - $k++; |
|
| 6356 | - } |
|
| 6357 | - |
|
| 6358 | - // current action |
|
| 6359 | - $action = array(); |
|
| 6360 | - $action[] = $lastAction; |
|
| 6361 | - switch($lastAction) |
|
| 6362 | - { |
|
| 6363 | - case 'C': |
|
| 6364 | - case 'c': |
|
| 6365 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']); // x1 |
|
| 6366 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']); // y1 |
|
| 6367 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+2], $this->_isInDraw['w']); // x2 |
|
| 6368 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+3], $this->_isInDraw['h']); // y2 |
|
| 6369 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+4], $this->_isInDraw['w']); // x |
|
| 6370 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+5], $this->_isInDraw['h']); // y |
|
| 6371 | - $k+= 6; |
|
| 6372 | - break; |
|
| 6373 | - |
|
| 6374 | - case 'Q': |
|
| 6375 | - case 'S': |
|
| 6376 | - case 'q': |
|
| 6377 | - case 's': |
|
| 6378 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']); // x2 |
|
| 6379 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']); // y2 |
|
| 6380 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+2], $this->_isInDraw['w']); // x |
|
| 6381 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+3], $this->_isInDraw['h']); // y |
|
| 6382 | - $k+= 4; |
|
| 6383 | - break; |
|
| 6384 | - |
|
| 6385 | - case 'A': |
|
| 6386 | - case 'a': |
|
| 6387 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']); // rx |
|
| 6388 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']); // ry |
|
| 6389 | - $action[] = 1.*$path[$k+2]; // angle de deviation de l'axe X |
|
| 6390 | - $action[] = ($path[$k+3]=='1') ? 1 : 0; // large-arc-flag |
|
| 6391 | - $action[] = ($path[$k+4]=='1') ? 1 : 0; // sweep-flag |
|
| 6392 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+5], $this->_isInDraw['w']); // x |
|
| 6393 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+6], $this->_isInDraw['h']); // y |
|
| 6394 | - $k+= 7; |
|
| 6395 | - break; |
|
| 6396 | - |
|
| 6397 | - case 'M': |
|
| 6398 | - case 'L': |
|
| 6399 | - case 'T': |
|
| 6400 | - case 'm': |
|
| 6401 | - case 'l': |
|
| 6402 | - case 't': |
|
| 6403 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']); // x |
|
| 6404 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']); // y |
|
| 6405 | - $k+= 2; |
|
| 6406 | - break; |
|
| 6407 | - |
|
| 6408 | - case 'H': |
|
| 6409 | - case 'h': |
|
| 6410 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']); // x |
|
| 6411 | - $k+= 1; |
|
| 6412 | - break; |
|
| 6413 | - |
|
| 6414 | - case 'V': |
|
| 6415 | - case 'v': |
|
| 6416 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['h']); // y |
|
| 6417 | - $k+= 1; |
|
| 6418 | - break; |
|
| 6419 | - |
|
| 6420 | - case 'z': |
|
| 6421 | - case 'Z': |
|
| 6422 | - default: |
|
| 6423 | - break; |
|
| 6424 | - } |
|
| 6425 | - // add the action |
|
| 6426 | - $actions[] = $action; |
|
| 6427 | - } |
|
| 6428 | - |
|
| 6429 | - // drawing |
|
| 6430 | - $this->pdf->svgPolygone($actions, $style); |
|
| 6431 | - } |
|
| 6432 | - |
|
| 6433 | - $this->pdf->undoTransform(); |
|
| 6434 | - $this->parsingCss->load(); |
|
| 6435 | - } |
|
| 6436 | - |
|
| 6437 | - /** |
|
| 6438 | - * tag : G |
|
| 6439 | - * mode : OPEN |
|
| 6440 | - * |
|
| 6441 | - * @param array $param |
|
| 6442 | - * @return boolean |
|
| 6443 | - */ |
|
| 6444 | - protected function _tag_open_G($param) |
|
| 6445 | - { |
|
| 6446 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'G'); |
|
| 6447 | - |
|
| 6448 | - $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
|
| 6449 | - $this->parsingCss->save(); |
|
| 6450 | - $styles = $this->parsingCss->getSvgStyle('path', $param); |
|
| 6451 | - $style = $this->pdf->svgSetStyle($styles); |
|
| 6452 | - } |
|
| 6453 | - |
|
| 6454 | - /** |
|
| 6455 | - * tag : G |
|
| 6456 | - * mode : CLOSE |
|
| 6457 | - * |
|
| 6458 | - * @param array $param |
|
| 6459 | - * @return boolean |
|
| 6460 | - */ |
|
| 6461 | - protected function _tag_close_G($param) |
|
| 6462 | - { |
|
| 6463 | - $this->pdf->undoTransform(); |
|
| 6464 | - $this->parsingCss->load(); |
|
| 6465 | - } |
|
| 6466 | - |
|
| 6467 | - /** |
|
| 6468 | - * new page for the automatic Index, does not use thie method. Only HTML2PDF_myPdf could use it !!!! |
|
| 6469 | - * |
|
| 6470 | - * @param &int $page |
|
| 6471 | - * @return integer $oldPage |
|
| 6472 | - */ |
|
| 6473 | - public function _INDEX_NewPage(&$page) |
|
| 6474 | - { |
|
| 6475 | - if ($page) { |
|
| 6476 | - $oldPage = $this->pdf->getPage(); |
|
| 6477 | - $this->pdf->setPage($page); |
|
| 6478 | - $this->pdf->setXY($this->_margeLeft, $this->_margeTop); |
|
| 6479 | - $this->_maxH = 0; |
|
| 6480 | - $page++; |
|
| 6481 | - return $oldPage; |
|
| 6482 | - } else { |
|
| 6483 | - $this->_setNewPage(); |
|
| 6484 | - return null; |
|
| 6485 | - } |
|
| 6486 | - } |
|
| 6487 | - |
|
| 6488 | - } |
|
| 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 | + |
|
| 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('&', '&', $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('&', '&', 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('&', '&', $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 | + } |
|
| 6489 | 6488 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @version 4.03 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if (!defined('__CLASS_HTML2PDF__')) { |
|
| 12 | +if ( ! defined('__CLASS_HTML2PDF__')) { |
|
| 13 | 13 | |
| 14 | 14 | define('__CLASS_HTML2PDF__', '4.03'); |
| 15 | 15 | define('HTML2PDF_USED_TCPDF_VERSION', '5.0.002'); |
@@ -40,77 +40,77 @@ discard block |
||
| 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 |
||
| 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='en', $unicode=true, $encoding='UTF-8', $marges = array(5, 5, 5, 8)) |
|
| 127 | + public function __construct($orientation = 'P', $format = 'A4', $langue = 'en', $unicode = true, $encoding = 'UTF-8', $marges = array(5, 5, 5, 8)) |
|
| 128 | 128 | { |
| 129 | 129 | // init the page number |
| 130 | 130 | $this->_page = 0; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $this->_subPart = false; |
| 163 | 163 | |
| 164 | 164 | // init the marges of the page |
| 165 | - if (!is_array($marges)) $marges = array($marges, $marges, $marges, $marges); |
|
| 165 | + if ( ! is_array($marges)) $marges = array($marges, $marges, $marges, $marges); |
|
| 166 | 166 | $this->_setDefaultMargins($marges[0], $marges[1], $marges[2], $marges[3]); |
| 167 | 167 | $this->_setMargins(); |
| 168 | 168 | $this->_marges = array(); |
@@ -286,7 +286,7 @@ discard block |
||
| 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,17 +356,17 @@ discard block |
||
| 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') { |
|
| 369 | + if (strtolower(substr($name, -4)) != '.pdf') { |
|
| 370 | 370 | throw new HTML2PDF_exception(0, 'The output document name "'.$name.'" is not a PDF name'); |
| 371 | 371 | } |
| 372 | 372 | |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | |
| 423 | 423 | // extract the content |
| 424 | 424 | $res = explode('<body', $html); |
| 425 | - if (count($res)<2) return $html; |
|
| 425 | + if (count($res) < 2) return $html; |
|
| 426 | 426 | $content = '<page'.$res[1]; |
| 427 | 427 | $content = explode('</body', $content); |
| 428 | 428 | $content = $content[0].'</page>'; |
@@ -458,7 +458,7 @@ discard block |
||
| 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; |
@@ -513,8 +513,8 @@ discard block |
||
| 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 | 519 | $this->_defaultLeft = $this->parsingCss->ConvertToMM($left.'mm'); |
| 520 | 520 | $this->_defaultTop = $this->parsingCss->ConvertToMM($top.'mm'); |
@@ -532,13 +532,13 @@ discard block |
||
| 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; |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | |
| 559 | 559 | $this->_page++; |
| 560 | 560 | |
| 561 | - if (!$this->_subPart && !$this->_isSubPart) { |
|
| 561 | + if ( ! $this->_subPart && ! $this->_isSubPart) { |
|
| 562 | 562 | if (is_array($this->_background)) { |
| 563 | 563 | if (isset($this->_background['color']) && $this->_background['color']) { |
| 564 | 564 | $this->pdf->setFillColorArray($this->_background['color']); |
@@ -588,9 +588,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -671,11 +671,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | */ |
| 807 | 807 | protected function _setPageHeader() |
| 808 | 808 | { |
| 809 | - if (!count($this->_subHEADER)) return false; |
|
| 809 | + if ( ! count($this->_subHEADER)) return false; |
|
| 810 | 810 | |
| 811 | 811 | $oldParsePos = $this->_parsePos; |
| 812 | 812 | $oldParseCode = $this->parsingHtml->code; |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | */ |
| 827 | 827 | protected function _setPageFooter() |
| 828 | 828 | { |
| 829 | - if (!count($this->_subFOOTER)) return false; |
|
| 829 | + if ( ! count($this->_subFOOTER)) return false; |
|
| 830 | 830 | |
| 831 | 831 | $oldParsePos = $this->_parsePos; |
| 832 | 832 | $oldParseCode = $this->parsingHtml->code; |
@@ -865,7 +865,7 @@ discard block |
||
| 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,39 +877,39 @@ discard block |
||
| 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 | - if (!$res) break; |
|
| 898 | + if ( ! $res) break; |
|
| 899 | 899 | } |
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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,11 +1105,11 @@ discard block |
||
| 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 | 1114 | return array('helvetica', false, ($up ? strtoupper($str) : $str).'.'); |
| 1115 | 1115 | |
@@ -1156,11 +1156,11 @@ discard block |
||
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | 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 = ''; |
|
| 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 | 1161 | |
| 1162 | - if (!$style) { |
|
| 1163 | - if ($type=='ul') $style = 'disc'; |
|
| 1162 | + if ( ! $style) { |
|
| 1163 | + if ($type == 'ul') $style = 'disc'; |
|
| 1164 | 1164 | else $style = 'decimal'; |
| 1165 | 1165 | } |
| 1166 | 1166 | |
@@ -1176,7 +1176,7 @@ discard block |
||
| 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,13 +1189,13 @@ discard block |
||
| 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]; |
| 1196 | 1196 | |
| 1197 | 1197 | // if it is a opening of table / ul / ol |
| 1198 | - if (in_array($action['name'], array('table', 'ul', 'ol')) && !$action['close']) { |
|
| 1198 | + if (in_array($action['name'], array('table', 'ul', 'ol')) && ! $action['close']) { |
|
| 1199 | 1199 | |
| 1200 | 1200 | // we will work as a sub HTML to calculate the size of the element |
| 1201 | 1201 | $this->_subPart = true; |
@@ -1207,7 +1207,7 @@ discard block |
||
| 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++; |
@@ -1242,12 +1242,12 @@ discard block |
||
| 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 | |
| 1249 | 1249 | // the action must exist |
| 1250 | - if (!is_callable(array(&$this, $fnc))) { |
|
| 1250 | + if ( ! is_callable(array(&$this, $fnc))) { |
|
| 1251 | 1251 | throw new HTML2PDF_exception(1, strtoupper($action['name']), $this->parsingHtml->getHtmlErrorCode($action['html_pos'])); |
| 1252 | 1252 | } |
| 1253 | 1253 | |
@@ -1270,10 +1270,10 @@ discard block |
||
| 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 |
||
| 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,15 +1306,15 @@ discard block |
||
| 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 | 1313 | |
| 1314 | - $infos=@getimagesize($src); |
|
| 1314 | + $infos = @getimagesize($src); |
|
| 1315 | 1315 | |
| 1316 | 1316 | // if the image does not exist, or can not be loaded |
| 1317 | - if (count($infos)<2) { |
|
| 1317 | + if (count($infos) < 2) { |
|
| 1318 | 1318 | // if the test is activ => exception |
| 1319 | 1319 | if ($this->_testIsImage) { |
| 1320 | 1320 | throw new HTML2PDF_exception(6, $src); |
@@ -1326,8 +1326,8 @@ discard block |
||
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | 1328 | // convert the size of the image in the unit of the PDF |
| 1329 | - $imageWidth = $infos[0]/$this->pdf->getK(); |
|
| 1330 | - $imageHeight = $infos[1]/$this->pdf->getK(); |
|
| 1329 | + $imageWidth = $infos[0] / $this->pdf->getK(); |
|
| 1330 | + $imageHeight = $infos[1] / $this->pdf->getK(); |
|
| 1331 | 1331 | |
| 1332 | 1332 | // calculate the size from the css style |
| 1333 | 1333 | if ($this->parsingCss->value['width'] && $this->parsingCss->value['height']) { |
@@ -1335,14 +1335,14 @@ discard block |
||
| 1335 | 1335 | $h = $this->parsingCss->value['height']; |
| 1336 | 1336 | } else if ($this->parsingCss->value['width']) { |
| 1337 | 1337 | $w = $this->parsingCss->value['width']; |
| 1338 | - $h = $imageHeight*$w/$imageWidth; |
|
| 1338 | + $h = $imageHeight * $w / $imageWidth; |
|
| 1339 | 1339 | } else if ($this->parsingCss->value['height']) { |
| 1340 | 1340 | $h = $this->parsingCss->value['height']; |
| 1341 | - $w = $imageWidth*$h/$imageHeight; |
|
| 1341 | + $w = $imageWidth * $h / $imageHeight; |
|
| 1342 | 1342 | } else { |
| 1343 | 1343 | // convert px to pt |
| 1344 | - $w = 72./96.*$imageWidth; |
|
| 1345 | - $h = 72./96.*$imageHeight; |
|
| 1344 | + $w = 72. / 96. * $imageWidth; |
|
| 1345 | + $h = 72. / 96. * $imageHeight; |
|
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | 1348 | // are we in a float |
@@ -1351,7 +1351,7 @@ discard block |
||
| 1351 | 1351 | // if we are in a float, but if something else if on the line => Break Line |
| 1352 | 1352 | if ($float && $this->_maxH) { |
| 1353 | 1353 | // make the break line (false if we are in "_isForOneLine" mode) |
| 1354 | - if (!$this->_tag_open_BR(array())) { |
|
| 1354 | + if ( ! $this->_tag_open_BR(array())) { |
|
| 1355 | 1355 | return false; |
| 1356 | 1356 | } |
| 1357 | 1357 | } |
@@ -1361,7 +1361,7 @@ discard block |
||
| 1361 | 1361 | $y = $this->pdf->getY(); |
| 1362 | 1362 | |
| 1363 | 1363 | // if the image can not be put on the current line => new line |
| 1364 | - if (!$float && ($x + $w>$this->pdf->getW() - $this->pdf->getrMargin()) && $this->_maxH) { |
|
| 1364 | + if ( ! $float && ($x + $w > $this->pdf->getW() - $this->pdf->getrMargin()) && $this->_maxH) { |
|
| 1365 | 1365 | if ($this->_isForOneLine) { |
| 1366 | 1366 | return false; |
| 1367 | 1367 | } |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | // if the image can not be put on the current page |
| 1379 | - if (($y + $h>$this->pdf->getH() - $this->pdf->getbMargin()) && !$this->_isInOverflow) { |
|
| 1379 | + if (($y + $h > $this->pdf->getH() - $this->pdf->getbMargin()) && ! $this->_isInOverflow) { |
|
| 1380 | 1380 | // new page |
| 1381 | 1381 | $this->_setNewPage(); |
| 1382 | 1382 | |
@@ -1386,17 +1386,17 @@ discard block |
||
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | 1388 | // correction for display the image of a list |
| 1389 | - $hT = 0.80*$this->parsingCss->value['font-size']; |
|
| 1390 | - if ($subLi && $h<$hT) { |
|
| 1391 | - $y+=($hT-$h); |
|
| 1389 | + $hT = 0.80 * $this->parsingCss->value['font-size']; |
|
| 1390 | + if ($subLi && $h < $hT) { |
|
| 1391 | + $y += ($hT - $h); |
|
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | 1394 | // add the margin top |
| 1395 | - $yc = $y-$this->parsingCss->value['margin']['t']; |
|
| 1395 | + $yc = $y - $this->parsingCss->value['margin']['t']; |
|
| 1396 | 1396 | |
| 1397 | 1397 | // get the width and the position of the parent |
| 1398 | 1398 | $old = $this->parsingCss->getOldValues(); |
| 1399 | - if ( $old['width']) { |
|
| 1399 | + if ($old['width']) { |
|
| 1400 | 1400 | $parentWidth = $old['width']; |
| 1401 | 1401 | $parentX = $x; |
| 1402 | 1402 | } else { |
@@ -1408,16 +1408,16 @@ discard block |
||
| 1408 | 1408 | if ($float) { |
| 1409 | 1409 | list($lx, $rx) = $this->_getMargins($yc); |
| 1410 | 1410 | $parentX = $lx; |
| 1411 | - $parentWidth = $rx-$lx; |
|
| 1411 | + $parentWidth = $rx - $lx; |
|
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | 1414 | // calculate the position of the image, if align to the right |
| 1415 | - if ($parentWidth>$w && $float!='left') { |
|
| 1416 | - 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 | + if ($parentWidth > $w && $float != 'left') { |
|
| 1416 | + if ($float == 'right' || $this->parsingCss->value['text-align'] == 'li_right') $x = $parentX + $parentWidth - $w - $this->parsingCss->value['margin']['r'] - $this->parsingCss->value['margin']['l']; |
|
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | // display the image |
| 1420 | - if (!$this->_subPart && !$this->_isSubPart) { |
|
| 1420 | + if ( ! $this->_subPart && ! $this->_isSubPart) { |
|
| 1421 | 1421 | if ($src) { |
| 1422 | 1422 | $this->pdf->Image($src, $x, $y, $w, $h, '', $this->_isInLink); |
| 1423 | 1423 | } else { |
@@ -1428,39 +1428,39 @@ discard block |
||
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | 1430 | // apply the margins |
| 1431 | - $x-= $this->parsingCss->value['margin']['l']; |
|
| 1432 | - $y-= $this->parsingCss->value['margin']['t']; |
|
| 1433 | - $w+= $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['margin']['r']; |
|
| 1434 | - $h+= $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['margin']['b']; |
|
| 1431 | + $x -= $this->parsingCss->value['margin']['l']; |
|
| 1432 | + $y -= $this->parsingCss->value['margin']['t']; |
|
| 1433 | + $w += $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['margin']['r']; |
|
| 1434 | + $h += $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['margin']['b']; |
|
| 1435 | 1435 | |
| 1436 | - if ($float=='left') { |
|
| 1436 | + if ($float == 'left') { |
|
| 1437 | 1437 | // save the current max |
| 1438 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 1439 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 1438 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 1439 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 1440 | 1440 | |
| 1441 | 1441 | // add the image to the margins |
| 1442 | - $this->_addMargins($float, $x, $y, $x+$w, $y+$h); |
|
| 1442 | + $this->_addMargins($float, $x, $y, $x + $w, $y + $h); |
|
| 1443 | 1443 | |
| 1444 | 1444 | // get the new position |
| 1445 | 1445 | list($lx, $rx) = $this->_getMargins($yc); |
| 1446 | 1446 | $this->pdf->setXY($lx, $yc); |
| 1447 | - } else if ($float=='right') { |
|
| 1447 | + } else if ($float == 'right') { |
|
| 1448 | 1448 | // save the current max. We don't save the X because it is not the real max of the line |
| 1449 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 1449 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 1450 | 1450 | |
| 1451 | 1451 | // add the image to the margins |
| 1452 | - $this->_addMargins($float, $x, $y, $x+$w, $y+$h); |
|
| 1452 | + $this->_addMargins($float, $x, $y, $x + $w, $y + $h); |
|
| 1453 | 1453 | |
| 1454 | 1454 | // get the new position |
| 1455 | 1455 | list($lx, $rx) = $this->_getMargins($yc); |
| 1456 | 1456 | $this->pdf->setXY($lx, $yc); |
| 1457 | 1457 | } else { |
| 1458 | 1458 | // set the new position at the end of the image |
| 1459 | - $this->pdf->setX($x+$w); |
|
| 1459 | + $this->pdf->setX($x + $w); |
|
| 1460 | 1460 | |
| 1461 | 1461 | // save the current max |
| 1462 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 1463 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 1462 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 1463 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 1464 | 1464 | $this->_maxH = max($this->_maxH, $h); |
| 1465 | 1465 | } |
| 1466 | 1466 | |
@@ -1484,13 +1484,13 @@ discard block |
||
| 1484 | 1484 | protected function _drawRectangle($x, $y, $w, $h, $border, $padding, $margin, $background) |
| 1485 | 1485 | { |
| 1486 | 1486 | // if we are in a subpart or if height is null => return false |
| 1487 | - if ($this->_subPart || $this->_isSubPart || $h===null) return false; |
|
| 1487 | + if ($this->_subPart || $this->_isSubPart || $h === null) return false; |
|
| 1488 | 1488 | |
| 1489 | 1489 | // add the margin |
| 1490 | - $x+= $margin; |
|
| 1491 | - $y+= $margin; |
|
| 1492 | - $w-= $margin*2; |
|
| 1493 | - $h-= $margin*2; |
|
| 1490 | + $x += $margin; |
|
| 1491 | + $y += $margin; |
|
| 1492 | + $w -= $margin * 2; |
|
| 1493 | + $h -= $margin * 2; |
|
| 1494 | 1494 | |
| 1495 | 1495 | // get the radius of the border |
| 1496 | 1496 | $outTL = $border['radius']['tl']; |
@@ -1511,32 +1511,32 @@ discard block |
||
| 1511 | 1511 | $inBL = $outBL; |
| 1512 | 1512 | |
| 1513 | 1513 | if (is_array($inTL)) { |
| 1514 | - $inTL[0]-= $border['l']['width']; |
|
| 1515 | - $inTL[1]-= $border['t']['width']; |
|
| 1514 | + $inTL[0] -= $border['l']['width']; |
|
| 1515 | + $inTL[1] -= $border['t']['width']; |
|
| 1516 | 1516 | } |
| 1517 | 1517 | if (is_array($inTR)) { |
| 1518 | - $inTR[0]-= $border['r']['width']; |
|
| 1519 | - $inTR[1]-= $border['t']['width']; |
|
| 1518 | + $inTR[0] -= $border['r']['width']; |
|
| 1519 | + $inTR[1] -= $border['t']['width']; |
|
| 1520 | 1520 | } |
| 1521 | 1521 | if (is_array($inBR)) { |
| 1522 | - $inBR[0]-= $border['r']['width']; |
|
| 1523 | - $inBR[1]-= $border['b']['width']; |
|
| 1522 | + $inBR[0] -= $border['r']['width']; |
|
| 1523 | + $inBR[1] -= $border['b']['width']; |
|
| 1524 | 1524 | } |
| 1525 | 1525 | if (is_array($inBL)) { |
| 1526 | - $inBL[0]-= $border['l']['width']; |
|
| 1527 | - $inBL[1]-= $border['b']['width']; |
|
| 1526 | + $inBL[0] -= $border['l']['width']; |
|
| 1527 | + $inBL[1] -= $border['b']['width']; |
|
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | - if ($inTL[0]<=0 || $inTL[1]<=0) $inTL = null; |
|
| 1531 | - if ($inTR[0]<=0 || $inTR[1]<=0) $inTR = null; |
|
| 1532 | - if ($inBR[0]<=0 || $inBR[1]<=0) $inBR = null; |
|
| 1533 | - if ($inBL[0]<=0 || $inBL[1]<=0) $inBL = null; |
|
| 1530 | + if ($inTL[0] <= 0 || $inTL[1] <= 0) $inTL = null; |
|
| 1531 | + if ($inTR[0] <= 0 || $inTR[1] <= 0) $inTR = null; |
|
| 1532 | + if ($inBR[0] <= 0 || $inBR[1] <= 0) $inBR = null; |
|
| 1533 | + if ($inBL[0] <= 0 || $inBL[1] <= 0) $inBL = null; |
|
| 1534 | 1534 | |
| 1535 | 1535 | // prepare the background color |
| 1536 | 1536 | $pdfStyle = ''; |
| 1537 | 1537 | if ($background['color']) { |
| 1538 | 1538 | $this->pdf->setFillColorArray($background['color']); |
| 1539 | - $pdfStyle.= 'F'; |
|
| 1539 | + $pdfStyle .= 'F'; |
|
| 1540 | 1540 | } |
| 1541 | 1541 | |
| 1542 | 1542 | // if we have a background to fill => fill it with a path (because of the radius) |
@@ -1549,8 +1549,8 @@ discard block |
||
| 1549 | 1549 | // prepare the background image |
| 1550 | 1550 | if ($background['image']) { |
| 1551 | 1551 | $iName = $background['image']; |
| 1552 | - $iPosition = $background['position']!==null ? $background['position'] : array(0, 0); |
|
| 1553 | - $iRepeat = $background['repeat']!==null ? $background['repeat'] : array(true, true); |
|
| 1552 | + $iPosition = $background['position'] !== null ? $background['position'] : array(0, 0); |
|
| 1553 | + $iRepeat = $background['repeat'] !== null ? $background['repeat'] : array(true, true); |
|
| 1554 | 1554 | |
| 1555 | 1555 | // size of the background without the borders |
| 1556 | 1556 | $bX = $x; |
@@ -1559,76 +1559,76 @@ discard block |
||
| 1559 | 1559 | $bH = $h; |
| 1560 | 1560 | |
| 1561 | 1561 | if ($border['b']['width']) { |
| 1562 | - $bH-= $border['b']['width']; |
|
| 1562 | + $bH -= $border['b']['width']; |
|
| 1563 | 1563 | } |
| 1564 | 1564 | if ($border['l']['width']) { |
| 1565 | - $bW-= $border['l']['width']; |
|
| 1566 | - $bX+= $border['l']['width']; |
|
| 1565 | + $bW -= $border['l']['width']; |
|
| 1566 | + $bX += $border['l']['width']; |
|
| 1567 | 1567 | } |
| 1568 | 1568 | if ($border['t']['width']) { |
| 1569 | - $bH-= $border['t']['width']; |
|
| 1570 | - $bY+= $border['t']['width']; |
|
| 1569 | + $bH -= $border['t']['width']; |
|
| 1570 | + $bY += $border['t']['width']; |
|
| 1571 | 1571 | } |
| 1572 | 1572 | if ($border['r']['width']) { |
| 1573 | - $bW-= $border['r']['width']; |
|
| 1573 | + $bW -= $border['r']['width']; |
|
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | 1576 | // get the size of the image |
| 1577 | 1577 | // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini |
| 1578 | - $imageInfos=@getimagesize($iName); |
|
| 1578 | + $imageInfos = @getimagesize($iName); |
|
| 1579 | 1579 | |
| 1580 | 1580 | // if the image can not be loaded |
| 1581 | - if (count($imageInfos)<2) { |
|
| 1581 | + if (count($imageInfos) < 2) { |
|
| 1582 | 1582 | if ($this->_testIsImage) { |
| 1583 | 1583 | throw new HTML2PDF_exception(6, $iName); |
| 1584 | 1584 | } |
| 1585 | 1585 | } else { |
| 1586 | 1586 | // convert the size of the image from pixel to the unit of the PDF |
| 1587 | - $imageWidth = 72./96.*$imageInfos[0]/$this->pdf->getK(); |
|
| 1588 | - $imageHeight = 72./96.*$imageInfos[1]/$this->pdf->getK(); |
|
| 1587 | + $imageWidth = 72. / 96. * $imageInfos[0] / $this->pdf->getK(); |
|
| 1588 | + $imageHeight = 72. / 96. * $imageInfos[1] / $this->pdf->getK(); |
|
| 1589 | 1589 | |
| 1590 | 1590 | // prepare the position of the backgroung |
| 1591 | 1591 | if ($iRepeat[0]) $iPosition[0] = $bX; |
| 1592 | - else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) $iPosition[0] = $bX + $match[1]*($bW-$imageWidth)/100; |
|
| 1593 | - else $iPosition[0] = $bX+$iPosition[0]; |
|
| 1592 | + else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) $iPosition[0] = $bX + $match[1] * ($bW - $imageWidth) / 100; |
|
| 1593 | + else $iPosition[0] = $bX + $iPosition[0]; |
|
| 1594 | 1594 | |
| 1595 | 1595 | if ($iRepeat[1]) $iPosition[1] = $bY; |
| 1596 | - else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) $iPosition[1] = $bY + $match[1]*($bH-$imageHeight)/100; |
|
| 1597 | - else $iPosition[1] = $bY+$iPosition[1]; |
|
| 1596 | + else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) $iPosition[1] = $bY + $match[1] * ($bH - $imageHeight) / 100; |
|
| 1597 | + else $iPosition[1] = $bY + $iPosition[1]; |
|
| 1598 | 1598 | |
| 1599 | 1599 | $imageXmin = $bX; |
| 1600 | - $imageXmax = $bX+$bW; |
|
| 1600 | + $imageXmax = $bX + $bW; |
|
| 1601 | 1601 | $imageYmin = $bY; |
| 1602 | - $imageYmax = $bY+$bH; |
|
| 1603 | - |
|
| 1604 | - if (!$iRepeat[0] && !$iRepeat[1]) { |
|
| 1605 | - $imageXmin = $iPosition[0]; $imageXmax = $iPosition[0]+$imageWidth; |
|
| 1606 | - $imageYmin = $iPosition[1]; $imageYmax = $iPosition[1]+$imageHeight; |
|
| 1607 | - } else if ($iRepeat[0] && !$iRepeat[1]) { |
|
| 1608 | - $imageYmin = $iPosition[1]; $imageYmax = $iPosition[1]+$imageHeight; |
|
| 1609 | - } else if (!$iRepeat[0] && $iRepeat[1]) { |
|
| 1610 | - $imageXmin = $iPosition[0]; $imageXmax = $iPosition[0]+$imageWidth; |
|
| 1602 | + $imageYmax = $bY + $bH; |
|
| 1603 | + |
|
| 1604 | + if ( ! $iRepeat[0] && ! $iRepeat[1]) { |
|
| 1605 | + $imageXmin = $iPosition[0]; $imageXmax = $iPosition[0] + $imageWidth; |
|
| 1606 | + $imageYmin = $iPosition[1]; $imageYmax = $iPosition[1] + $imageHeight; |
|
| 1607 | + } else if ($iRepeat[0] && ! $iRepeat[1]) { |
|
| 1608 | + $imageYmin = $iPosition[1]; $imageYmax = $iPosition[1] + $imageHeight; |
|
| 1609 | + } else if ( ! $iRepeat[0] && $iRepeat[1]) { |
|
| 1610 | + $imageXmin = $iPosition[0]; $imageXmax = $iPosition[0] + $imageWidth; |
|
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | 1613 | // build the path to display the image (because of radius) |
| 1614 | 1614 | $this->pdf->clippingPathStart($bX, $bY, $bW, $bH, $inTL, $inTR, $inBL, $inBR); |
| 1615 | 1615 | |
| 1616 | 1616 | // repeat the image |
| 1617 | - for ($iY=$imageYmin; $iY<$imageYmax; $iY+=$imageHeight) { |
|
| 1618 | - for ($iX=$imageXmin; $iX<$imageXmax; $iX+=$imageWidth) { |
|
| 1617 | + for ($iY = $imageYmin; $iY < $imageYmax; $iY += $imageHeight) { |
|
| 1618 | + for ($iX = $imageXmin; $iX < $imageXmax; $iX += $imageWidth) { |
|
| 1619 | 1619 | $cX = null; |
| 1620 | 1620 | $cY = null; |
| 1621 | 1621 | $cW = $imageWidth; |
| 1622 | 1622 | $cH = $imageHeight; |
| 1623 | - if ($imageYmax-$iY<$imageHeight) { |
|
| 1623 | + if ($imageYmax - $iY < $imageHeight) { |
|
| 1624 | 1624 | $cX = $iX; |
| 1625 | 1625 | $cY = $iY; |
| 1626 | - $cH = $imageYmax-$iY; |
|
| 1626 | + $cH = $imageYmax - $iY; |
|
| 1627 | 1627 | } |
| 1628 | - if ($imageXmax-$iX<$imageWidth) { |
|
| 1628 | + if ($imageXmax - $iX < $imageWidth) { |
|
| 1629 | 1629 | $cX = $iX; |
| 1630 | 1630 | $cY = $iY; |
| 1631 | - $cW = $imageXmax-$iX; |
|
| 1631 | + $cW = $imageXmax - $iX; |
|
| 1632 | 1632 | } |
| 1633 | 1633 | |
| 1634 | 1634 | $this->pdf->Image($iName, $iX, $iY, $imageWidth, $imageHeight, '', ''); |
@@ -1642,36 +1642,36 @@ discard block |
||
| 1642 | 1642 | |
| 1643 | 1643 | // adding some loose (0.01mm) |
| 1644 | 1644 | $loose = 0.01; |
| 1645 | - $x-= $loose; |
|
| 1646 | - $y-= $loose; |
|
| 1647 | - $w+= 2.*$loose; |
|
| 1648 | - $h+= 2.*$loose; |
|
| 1649 | - if ($border['l']['width']) $border['l']['width']+= 2.*$loose; |
|
| 1650 | - if ($border['t']['width']) $border['t']['width']+= 2.*$loose; |
|
| 1651 | - if ($border['r']['width']) $border['r']['width']+= 2.*$loose; |
|
| 1652 | - if ($border['b']['width']) $border['b']['width']+= 2.*$loose; |
|
| 1645 | + $x -= $loose; |
|
| 1646 | + $y -= $loose; |
|
| 1647 | + $w += 2. * $loose; |
|
| 1648 | + $h += 2. * $loose; |
|
| 1649 | + if ($border['l']['width']) $border['l']['width'] += 2. * $loose; |
|
| 1650 | + if ($border['t']['width']) $border['t']['width'] += 2. * $loose; |
|
| 1651 | + if ($border['r']['width']) $border['r']['width'] += 2. * $loose; |
|
| 1652 | + if ($border['b']['width']) $border['b']['width'] += 2. * $loose; |
|
| 1653 | 1653 | |
| 1654 | 1654 | // prepare the test on borders |
| 1655 | - $testBl = ($border['l']['width'] && $border['l']['color'][0]!==null); |
|
| 1656 | - $testBt = ($border['t']['width'] && $border['t']['color'][0]!==null); |
|
| 1657 | - $testBr = ($border['r']['width'] && $border['r']['color'][0]!==null); |
|
| 1658 | - $testBb = ($border['b']['width'] && $border['b']['color'][0]!==null); |
|
| 1655 | + $testBl = ($border['l']['width'] && $border['l']['color'][0] !== null); |
|
| 1656 | + $testBt = ($border['t']['width'] && $border['t']['color'][0] !== null); |
|
| 1657 | + $testBr = ($border['r']['width'] && $border['r']['color'][0] !== null); |
|
| 1658 | + $testBb = ($border['b']['width'] && $border['b']['color'][0] !== null); |
|
| 1659 | 1659 | |
| 1660 | 1660 | // draw the radius bottom-left |
| 1661 | 1661 | if (is_array($outBL) && ($testBb || $testBl)) { |
| 1662 | 1662 | if ($inBL) { |
| 1663 | 1663 | $courbe = array(); |
| 1664 | - $courbe[] = $x+$outBL[0]; $courbe[] = $y+$h; |
|
| 1665 | - $courbe[] = $x; $courbe[] = $y+$h-$outBL[1]; |
|
| 1666 | - $courbe[] = $x+$outBL[0]; $courbe[] = $y+$h-$border['b']['width']; |
|
| 1667 | - $courbe[] = $x+$border['l']['width']; $courbe[] = $y+$h-$outBL[1]; |
|
| 1668 | - $courbe[] = $x+$outBL[0]; $courbe[] = $y+$h-$outBL[1]; |
|
| 1664 | + $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h; |
|
| 1665 | + $courbe[] = $x; $courbe[] = $y + $h - $outBL[1]; |
|
| 1666 | + $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h - $border['b']['width']; |
|
| 1667 | + $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $h - $outBL[1]; |
|
| 1668 | + $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h - $outBL[1]; |
|
| 1669 | 1669 | } else { |
| 1670 | 1670 | $courbe = array(); |
| 1671 | - $courbe[] = $x+$outBL[0]; $courbe[] = $y+$h; |
|
| 1672 | - $courbe[] = $x; $courbe[] = $y+$h-$outBL[1]; |
|
| 1673 | - $courbe[] = $x+$border['l']['width']; $courbe[] = $y+$h-$border['b']['width']; |
|
| 1674 | - $courbe[] = $x+$outBL[0]; $courbe[] = $y+$h-$outBL[1]; |
|
| 1671 | + $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h; |
|
| 1672 | + $courbe[] = $x; $courbe[] = $y + $h - $outBL[1]; |
|
| 1673 | + $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $h - $border['b']['width']; |
|
| 1674 | + $courbe[] = $x + $outBL[0]; $courbe[] = $y + $h - $outBL[1]; |
|
| 1675 | 1675 | } |
| 1676 | 1676 | $this->_drawCurve($courbe, $border['l']['color']); |
| 1677 | 1677 | } |
@@ -1680,17 +1680,17 @@ discard block |
||
| 1680 | 1680 | if (is_array($outTL) && ($testBt || $testBl)) { |
| 1681 | 1681 | if ($inTL) { |
| 1682 | 1682 | $courbe = array(); |
| 1683 | - $courbe[] = $x; $courbe[] = $y+$outTL[1]; |
|
| 1684 | - $courbe[] = $x+$outTL[0]; $courbe[] = $y; |
|
| 1685 | - $courbe[] = $x+$border['l']['width']; $courbe[] = $y+$outTL[1]; |
|
| 1686 | - $courbe[] = $x+$outTL[0]; $courbe[] = $y+$border['t']['width']; |
|
| 1687 | - $courbe[] = $x+$outTL[0]; $courbe[] = $y+$outTL[1]; |
|
| 1683 | + $courbe[] = $x; $courbe[] = $y + $outTL[1]; |
|
| 1684 | + $courbe[] = $x + $outTL[0]; $courbe[] = $y; |
|
| 1685 | + $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $outTL[1]; |
|
| 1686 | + $courbe[] = $x + $outTL[0]; $courbe[] = $y + $border['t']['width']; |
|
| 1687 | + $courbe[] = $x + $outTL[0]; $courbe[] = $y + $outTL[1]; |
|
| 1688 | 1688 | } else { |
| 1689 | 1689 | $courbe = array(); |
| 1690 | - $courbe[] = $x; $courbe[] = $y+$outTL[1]; |
|
| 1691 | - $courbe[] = $x+$outTL[0]; $courbe[] = $y; |
|
| 1692 | - $courbe[] = $x+$border['l']['width']; $courbe[] = $y+$border['t']['width']; |
|
| 1693 | - $courbe[] = $x+$outTL[0]; $courbe[] = $y+$outTL[1]; |
|
| 1690 | + $courbe[] = $x; $courbe[] = $y + $outTL[1]; |
|
| 1691 | + $courbe[] = $x + $outTL[0]; $courbe[] = $y; |
|
| 1692 | + $courbe[] = $x + $border['l']['width']; $courbe[] = $y + $border['t']['width']; |
|
| 1693 | + $courbe[] = $x + $outTL[0]; $courbe[] = $y + $outTL[1]; |
|
| 1694 | 1694 | } |
| 1695 | 1695 | $this->_drawCurve($courbe, $border['t']['color']); |
| 1696 | 1696 | } |
@@ -1699,17 +1699,17 @@ discard block |
||
| 1699 | 1699 | if (is_array($outTR) && ($testBt || $testBr)) { |
| 1700 | 1700 | if ($inTR) { |
| 1701 | 1701 | $courbe = array(); |
| 1702 | - $courbe[] = $x+$w-$outTR[0]; $courbe[] = $y; |
|
| 1703 | - $courbe[] = $x+$w; $courbe[] = $y+$outTR[1]; |
|
| 1704 | - $courbe[] = $x+$w-$outTR[0]; $courbe[] = $y+$border['t']['width']; |
|
| 1705 | - $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$outTR[1]; |
|
| 1706 | - $courbe[] = $x+$w-$outTR[0]; $courbe[] = $y+$outTR[1]; |
|
| 1702 | + $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y; |
|
| 1703 | + $courbe[] = $x + $w; $courbe[] = $y + $outTR[1]; |
|
| 1704 | + $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y + $border['t']['width']; |
|
| 1705 | + $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $outTR[1]; |
|
| 1706 | + $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y + $outTR[1]; |
|
| 1707 | 1707 | } else { |
| 1708 | 1708 | $courbe = array(); |
| 1709 | - $courbe[] = $x+$w-$outTR[0]; $courbe[] = $y; |
|
| 1710 | - $courbe[] = $x+$w; $courbe[] = $y+$outTR[1]; |
|
| 1711 | - $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$border['t']['width']; |
|
| 1712 | - $courbe[] = $x+$w-$outTR[0]; $courbe[] = $y+$outTR[1]; |
|
| 1709 | + $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y; |
|
| 1710 | + $courbe[] = $x + $w; $courbe[] = $y + $outTR[1]; |
|
| 1711 | + $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $border['t']['width']; |
|
| 1712 | + $courbe[] = $x + $w - $outTR[0]; $courbe[] = $y + $outTR[1]; |
|
| 1713 | 1713 | } |
| 1714 | 1714 | $this->_drawCurve($courbe, $border['r']['color']); |
| 1715 | 1715 | } |
@@ -1718,17 +1718,17 @@ discard block |
||
| 1718 | 1718 | if (is_array($outBR) && ($testBb || $testBr)) { |
| 1719 | 1719 | if ($inBR) { |
| 1720 | 1720 | $courbe = array(); |
| 1721 | - $courbe[] = $x+$w; $courbe[] = $y+$h-$outBR[1]; |
|
| 1722 | - $courbe[] = $x+$w-$outBR[0]; $courbe[] = $y+$h; |
|
| 1723 | - $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$h-$outBR[1]; |
|
| 1724 | - $courbe[] = $x+$w-$outBR[0]; $courbe[] = $y+$h-$border['b']['width']; |
|
| 1725 | - $courbe[] = $x+$w-$outBR[0]; $courbe[] = $y+$h-$outBR[1]; |
|
| 1721 | + $courbe[] = $x + $w; $courbe[] = $y + $h - $outBR[1]; |
|
| 1722 | + $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h; |
|
| 1723 | + $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $h - $outBR[1]; |
|
| 1724 | + $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h - $border['b']['width']; |
|
| 1725 | + $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h - $outBR[1]; |
|
| 1726 | 1726 | } else { |
| 1727 | 1727 | $courbe = array(); |
| 1728 | - $courbe[] = $x+$w; $courbe[] = $y+$h-$outBR[1]; |
|
| 1729 | - $courbe[] = $x+$w-$outBR[0]; $courbe[] = $y+$h; |
|
| 1730 | - $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$h-$border['b']['width']; |
|
| 1731 | - $courbe[] = $x+$w-$outBR[0]; $courbe[] = $y+$h-$outBR[1]; |
|
| 1728 | + $courbe[] = $x + $w; $courbe[] = $y + $h - $outBR[1]; |
|
| 1729 | + $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h; |
|
| 1730 | + $courbe[] = $x + $w - $border['r']['width']; $courbe[] = $y + $h - $border['b']['width']; |
|
| 1731 | + $courbe[] = $x + $w - $outBR[0]; $courbe[] = $y + $h - $outBR[1]; |
|
| 1732 | 1732 | } |
| 1733 | 1733 | $this->_drawCurve($courbe, $border['b']['color']); |
| 1734 | 1734 | } |
@@ -1736,25 +1736,25 @@ discard block |
||
| 1736 | 1736 | // draw the left border |
| 1737 | 1737 | if ($testBl) { |
| 1738 | 1738 | $pt = array(); |
| 1739 | - $pt[] = $x; $pt[] = $y+$h; |
|
| 1740 | - $pt[] = $x; $pt[] = $y+$h-$border['b']['width']; |
|
| 1741 | - $pt[] = $x; $pt[] = $y+$border['t']['width']; |
|
| 1742 | - $pt[] = $x; $pt[] = $y; |
|
| 1743 | - $pt[] = $x+$border['l']['width']; $pt[] = $y+$border['t']['width']; |
|
| 1744 | - $pt[] = $x+$border['l']['width']; $pt[] = $y+$h-$border['b']['width']; |
|
| 1739 | + $pt[] = $x; $pt[] = $y + $h; |
|
| 1740 | + $pt[] = $x; $pt[] = $y + $h - $border['b']['width']; |
|
| 1741 | + $pt[] = $x; $pt[] = $y + $border['t']['width']; |
|
| 1742 | + $pt[] = $x; $pt[] = $y; |
|
| 1743 | + $pt[] = $x + $border['l']['width']; $pt[] = $y + $border['t']['width']; |
|
| 1744 | + $pt[] = $x + $border['l']['width']; $pt[] = $y + $h - $border['b']['width']; |
|
| 1745 | 1745 | |
| 1746 | 1746 | $bord = 3; |
| 1747 | 1747 | if (is_array($outBL)) { |
| 1748 | - $bord-=1; |
|
| 1748 | + $bord -= 1; |
|
| 1749 | 1749 | $pt[3] -= $outBL[1] - $border['b']['width']; |
| 1750 | - if ($inBL) $pt[11]-= $inBL[1]; |
|
| 1751 | - unset($pt[0]);unset($pt[1]); |
|
| 1750 | + if ($inBL) $pt[11] -= $inBL[1]; |
|
| 1751 | + unset($pt[0]); unset($pt[1]); |
|
| 1752 | 1752 | } |
| 1753 | 1753 | if (is_array($outTL)) { |
| 1754 | - $bord-=2; |
|
| 1755 | - $pt[5] += $outTL[1]-$border['t']['width']; |
|
| 1754 | + $bord -= 2; |
|
| 1755 | + $pt[5] += $outTL[1] - $border['t']['width']; |
|
| 1756 | 1756 | if ($inTL) $pt[9] += $inTL[1]; |
| 1757 | - unset($pt[6]);unset($pt[7]); |
|
| 1757 | + unset($pt[6]); unset($pt[7]); |
|
| 1758 | 1758 | } |
| 1759 | 1759 | |
| 1760 | 1760 | $pt = array_values($pt); |
@@ -1764,25 +1764,25 @@ discard block |
||
| 1764 | 1764 | // draw the top border |
| 1765 | 1765 | if ($testBt) { |
| 1766 | 1766 | $pt = array(); |
| 1767 | - $pt[] = $x; $pt[] = $y; |
|
| 1768 | - $pt[] = $x+$border['l']['width']; $pt[] = $y; |
|
| 1769 | - $pt[] = $x+$w-$border['r']['width']; $pt[] = $y; |
|
| 1770 | - $pt[] = $x+$w; $pt[] = $y; |
|
| 1771 | - $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$border['t']['width']; |
|
| 1772 | - $pt[] = $x+$border['l']['width']; $pt[] = $y+$border['t']['width']; |
|
| 1767 | + $pt[] = $x; $pt[] = $y; |
|
| 1768 | + $pt[] = $x + $border['l']['width']; $pt[] = $y; |
|
| 1769 | + $pt[] = $x + $w - $border['r']['width']; $pt[] = $y; |
|
| 1770 | + $pt[] = $x + $w; $pt[] = $y; |
|
| 1771 | + $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $border['t']['width']; |
|
| 1772 | + $pt[] = $x + $border['l']['width']; $pt[] = $y + $border['t']['width']; |
|
| 1773 | 1773 | |
| 1774 | 1774 | $bord = 3; |
| 1775 | 1775 | if (is_array($outTL)) { |
| 1776 | - $bord-=1; |
|
| 1776 | + $bord -= 1; |
|
| 1777 | 1777 | $pt[2] += $outTL[0] - $border['l']['width']; |
| 1778 | - if ($inTL) $pt[10]+= $inTL[0]; |
|
| 1779 | - unset($pt[0]);unset($pt[1]); |
|
| 1778 | + if ($inTL) $pt[10] += $inTL[0]; |
|
| 1779 | + unset($pt[0]); unset($pt[1]); |
|
| 1780 | 1780 | } |
| 1781 | 1781 | if (is_array($outTR)) { |
| 1782 | - $bord-=2; |
|
| 1782 | + $bord -= 2; |
|
| 1783 | 1783 | $pt[4] -= $outTR[0] - $border['r']['width']; |
| 1784 | 1784 | if ($inTR) $pt[8] -= $inTR[0]; |
| 1785 | - unset($pt[6]);unset($pt[7]); |
|
| 1785 | + unset($pt[6]); unset($pt[7]); |
|
| 1786 | 1786 | } |
| 1787 | 1787 | |
| 1788 | 1788 | $pt = array_values($pt); |
@@ -1792,25 +1792,25 @@ discard block |
||
| 1792 | 1792 | // draw the right border |
| 1793 | 1793 | if ($testBr) { |
| 1794 | 1794 | $pt = array(); |
| 1795 | - $pt[] = $x+$w; $pt[] = $y; |
|
| 1796 | - $pt[] = $x+$w; $pt[] = $y+$border['t']['width']; |
|
| 1797 | - $pt[] = $x+$w; $pt[] = $y+$h-$border['b']['width']; |
|
| 1798 | - $pt[] = $x+$w; $pt[] = $y+$h; |
|
| 1799 | - $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h-$border['b']['width']; |
|
| 1800 | - $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$border['t']['width']; |
|
| 1795 | + $pt[] = $x + $w; $pt[] = $y; |
|
| 1796 | + $pt[] = $x + $w; $pt[] = $y + $border['t']['width']; |
|
| 1797 | + $pt[] = $x + $w; $pt[] = $y + $h - $border['b']['width']; |
|
| 1798 | + $pt[] = $x + $w; $pt[] = $y + $h; |
|
| 1799 | + $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $h - $border['b']['width']; |
|
| 1800 | + $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $border['t']['width']; |
|
| 1801 | 1801 | |
| 1802 | 1802 | $bord = 3; |
| 1803 | 1803 | if (is_array($outTR)) { |
| 1804 | - $bord-=1; |
|
| 1804 | + $bord -= 1; |
|
| 1805 | 1805 | $pt[3] += $outTR[1] - $border['t']['width']; |
| 1806 | - if ($inTR) $pt[11]+= $inTR[1]; |
|
| 1807 | - unset($pt[0]);unset($pt[1]); |
|
| 1806 | + if ($inTR) $pt[11] += $inTR[1]; |
|
| 1807 | + unset($pt[0]); unset($pt[1]); |
|
| 1808 | 1808 | } |
| 1809 | 1809 | if (is_array($outBR)) { |
| 1810 | - $bord-=2; |
|
| 1810 | + $bord -= 2; |
|
| 1811 | 1811 | $pt[5] -= $outBR[1] - $border['b']['width']; |
| 1812 | 1812 | if ($inBR) $pt[9] -= $inBR[1]; |
| 1813 | - unset($pt[6]);unset($pt[7]); |
|
| 1813 | + unset($pt[6]); unset($pt[7]); |
|
| 1814 | 1814 | } |
| 1815 | 1815 | |
| 1816 | 1816 | $pt = array_values($pt); |
@@ -1820,25 +1820,25 @@ discard block |
||
| 1820 | 1820 | // draw the bottom border |
| 1821 | 1821 | if ($testBb) { |
| 1822 | 1822 | $pt = array(); |
| 1823 | - $pt[] = $x+$w; $pt[] = $y+$h; |
|
| 1824 | - $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h; |
|
| 1825 | - $pt[] = $x+$border['l']['width']; $pt[] = $y+$h; |
|
| 1826 | - $pt[] = $x; $pt[] = $y+$h; |
|
| 1827 | - $pt[] = $x+$border['l']['width']; $pt[] = $y+$h-$border['b']['width']; |
|
| 1828 | - $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h-$border['b']['width']; |
|
| 1823 | + $pt[] = $x + $w; $pt[] = $y + $h; |
|
| 1824 | + $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $h; |
|
| 1825 | + $pt[] = $x + $border['l']['width']; $pt[] = $y + $h; |
|
| 1826 | + $pt[] = $x; $pt[] = $y + $h; |
|
| 1827 | + $pt[] = $x + $border['l']['width']; $pt[] = $y + $h - $border['b']['width']; |
|
| 1828 | + $pt[] = $x + $w - $border['r']['width']; $pt[] = $y + $h - $border['b']['width']; |
|
| 1829 | 1829 | |
| 1830 | 1830 | $bord = 3; |
| 1831 | 1831 | if (is_array($outBL)) { |
| 1832 | - $bord-=2; |
|
| 1832 | + $bord -= 2; |
|
| 1833 | 1833 | $pt[4] += $outBL[0] - $border['l']['width']; |
| 1834 | 1834 | if ($inBL) $pt[8] += $inBL[0]; |
| 1835 | - unset($pt[6]);unset($pt[7]); |
|
| 1835 | + unset($pt[6]); unset($pt[7]); |
|
| 1836 | 1836 | } |
| 1837 | 1837 | if (is_array($outBR)) { |
| 1838 | - $bord-=1; |
|
| 1838 | + $bord -= 1; |
|
| 1839 | 1839 | $pt[2] -= $outBR[0] - $border['r']['width']; |
| 1840 | - if ($inBR) $pt[10]-= $inBR[0]; |
|
| 1841 | - unset($pt[0]);unset($pt[1]); |
|
| 1840 | + if ($inBR) $pt[10] -= $inBR[0]; |
|
| 1841 | + unset($pt[0]); unset($pt[1]); |
|
| 1842 | 1842 | |
| 1843 | 1843 | } |
| 1844 | 1844 | |
@@ -1864,7 +1864,7 @@ discard block |
||
| 1864 | 1864 | { |
| 1865 | 1865 | $this->pdf->setFillColorArray($color); |
| 1866 | 1866 | |
| 1867 | - if (count($pt)==10) |
|
| 1867 | + if (count($pt) == 10) |
|
| 1868 | 1868 | $this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]); |
| 1869 | 1869 | else |
| 1870 | 1870 | $this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]); |
@@ -1880,128 +1880,128 @@ discard block |
||
| 1880 | 1880 | * @param float $width |
| 1881 | 1881 | * @param integer $radius (binary from 0 to 3 with 1=>start with a radius, 2=>end with a radius) |
| 1882 | 1882 | */ |
| 1883 | - protected function _drawLine($pt, $color, $type, $width, $radius=3) |
|
| 1883 | + protected function _drawLine($pt, $color, $type, $width, $radius = 3) |
|
| 1884 | 1884 | { |
| 1885 | 1885 | // set the fill color |
| 1886 | 1886 | $this->pdf->setFillColorArray($color); |
| 1887 | 1887 | |
| 1888 | 1888 | // if dashed or dotted |
| 1889 | - if ($type=='dashed' || $type=='dotted') { |
|
| 1889 | + if ($type == 'dashed' || $type == 'dotted') { |
|
| 1890 | 1890 | |
| 1891 | 1891 | // clean the end of the line, if radius |
| 1892 | - if ($radius==1) { |
|
| 1893 | - $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[8]; $tmp[]=$pt[9]; |
|
| 1892 | + if ($radius == 1) { |
|
| 1893 | + $tmp = array(); $tmp[] = $pt[0]; $tmp[] = $pt[1]; $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; |
|
| 1894 | 1894 | $this->pdf->Polygon($tmp, 'F'); |
| 1895 | 1895 | |
| 1896 | - $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 | + $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]; |
|
| 1897 | 1897 | $pt = $tmp; |
| 1898 | - } else if ($radius==2) { |
|
| 1899 | - $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; |
|
| 1898 | + } else if ($radius == 2) { |
|
| 1899 | + $tmp = array(); $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; |
|
| 1900 | 1900 | $this->pdf->Polygon($tmp, 'F'); |
| 1901 | 1901 | |
| 1902 | - $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 | + $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]; |
|
| 1903 | 1903 | $pt = $tmp; |
| 1904 | - } else if ($radius==3) { |
|
| 1905 | - $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[10]; $tmp[]=$pt[11]; |
|
| 1904 | + } else if ($radius == 3) { |
|
| 1905 | + $tmp = array(); $tmp[] = $pt[0]; $tmp[] = $pt[1]; $tmp[] = $pt[2]; $tmp[] = $pt[3]; $tmp[] = $pt[10]; $tmp[] = $pt[11]; |
|
| 1906 | 1906 | $this->pdf->Polygon($tmp, 'F'); |
| 1907 | 1907 | |
| 1908 | - $tmp = array(); $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9]; |
|
| 1908 | + $tmp = array(); $tmp[] = $pt[4]; $tmp[] = $pt[5]; $tmp[] = $pt[6]; $tmp[] = $pt[7]; $tmp[] = $pt[8]; $tmp[] = $pt[9]; |
|
| 1909 | 1909 | $this->pdf->Polygon($tmp, 'F'); |
| 1910 | 1910 | |
| 1911 | - $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 | + $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]; |
|
| 1912 | 1912 | $pt = $tmp; |
| 1913 | 1913 | } |
| 1914 | 1914 | |
| 1915 | 1915 | // horisontal or vertical line |
| 1916 | - if ($pt[2]==$pt[0]) { |
|
| 1917 | - $l = abs(($pt[3]-$pt[1])*0.5); |
|
| 1916 | + if ($pt[2] == $pt[0]) { |
|
| 1917 | + $l = abs(($pt[3] - $pt[1]) * 0.5); |
|
| 1918 | 1918 | $px = 0; |
| 1919 | 1919 | $py = $width; |
| 1920 | - $x1 = $pt[0]; $y1 = ($pt[3]+$pt[1])*0.5; |
|
| 1921 | - $x2 = $pt[6]; $y2 = ($pt[7]+$pt[5])*0.5; |
|
| 1920 | + $x1 = $pt[0]; $y1 = ($pt[3] + $pt[1]) * 0.5; |
|
| 1921 | + $x2 = $pt[6]; $y2 = ($pt[7] + $pt[5]) * 0.5; |
|
| 1922 | 1922 | } else { |
| 1923 | - $l = abs(($pt[2]-$pt[0])*0.5); |
|
| 1923 | + $l = abs(($pt[2] - $pt[0]) * 0.5); |
|
| 1924 | 1924 | $px = $width; |
| 1925 | 1925 | $py = 0; |
| 1926 | - $x1 = ($pt[2]+$pt[0])*0.5; $y1 = $pt[1]; |
|
| 1927 | - $x2 = ($pt[6]+$pt[4])*0.5; $y2 = $pt[7]; |
|
| 1926 | + $x1 = ($pt[2] + $pt[0]) * 0.5; $y1 = $pt[1]; |
|
| 1927 | + $x2 = ($pt[6] + $pt[4]) * 0.5; $y2 = $pt[7]; |
|
| 1928 | 1928 | } |
| 1929 | 1929 | |
| 1930 | 1930 | // if dashed : 3x bigger than dotted |
| 1931 | - if ($type=='dashed') { |
|
| 1932 | - $px = $px*3.; |
|
| 1933 | - $py = $py*3.; |
|
| 1931 | + if ($type == 'dashed') { |
|
| 1932 | + $px = $px * 3.; |
|
| 1933 | + $py = $py * 3.; |
|
| 1934 | 1934 | } |
| 1935 | - $mode = ($l/($px+$py)<.5); |
|
| 1935 | + $mode = ($l / ($px + $py) < .5); |
|
| 1936 | 1936 | |
| 1937 | 1937 | // display the dotted/dashed line |
| 1938 | - for ($i=0; $l-($px+$py)*($i-0.5)>0; $i++) { |
|
| 1939 | - if (($i%2)==$mode) { |
|
| 1940 | - $j = $i-0.5; |
|
| 1941 | - $lx1 = $px*($j); if ($lx1<-$l) $lx1 =-$l; |
|
| 1942 | - $ly1 = $py*($j); if ($ly1<-$l) $ly1 =-$l; |
|
| 1943 | - $lx2 = $px*($j+1); if ($lx2>$l) $lx2 = $l; |
|
| 1944 | - $ly2 = $py*($j+1); if ($ly2>$l) $ly2 = $l; |
|
| 1938 | + for ($i = 0; $l - ($px + $py) * ($i - 0.5) > 0; $i++) { |
|
| 1939 | + if (($i % 2) == $mode) { |
|
| 1940 | + $j = $i - 0.5; |
|
| 1941 | + $lx1 = $px * ($j); if ($lx1 < -$l) $lx1 = -$l; |
|
| 1942 | + $ly1 = $py * ($j); if ($ly1 < -$l) $ly1 = -$l; |
|
| 1943 | + $lx2 = $px * ($j + 1); if ($lx2 > $l) $lx2 = $l; |
|
| 1944 | + $ly2 = $py * ($j + 1); if ($ly2 > $l) $ly2 = $l; |
|
| 1945 | 1945 | |
| 1946 | 1946 | $tmp = array(); |
| 1947 | - $tmp[] = $x1+$lx1; $tmp[] = $y1+$ly1; |
|
| 1948 | - $tmp[] = $x1+$lx2; $tmp[] = $y1+$ly2; |
|
| 1949 | - $tmp[] = $x2+$lx2; $tmp[] = $y2+$ly2; |
|
| 1950 | - $tmp[] = $x2+$lx1; $tmp[] = $y2+$ly1; |
|
| 1947 | + $tmp[] = $x1 + $lx1; $tmp[] = $y1 + $ly1; |
|
| 1948 | + $tmp[] = $x1 + $lx2; $tmp[] = $y1 + $ly2; |
|
| 1949 | + $tmp[] = $x2 + $lx2; $tmp[] = $y2 + $ly2; |
|
| 1950 | + $tmp[] = $x2 + $lx1; $tmp[] = $y2 + $ly1; |
|
| 1951 | 1951 | $this->pdf->Polygon($tmp, 'F'); |
| 1952 | 1952 | |
| 1953 | - if ($j>0) { |
|
| 1953 | + if ($j > 0) { |
|
| 1954 | 1954 | $tmp = array(); |
| 1955 | - $tmp[] = $x1-$lx1; $tmp[] = $y1-$ly1; |
|
| 1956 | - $tmp[] = $x1-$lx2; $tmp[] = $y1-$ly2; |
|
| 1957 | - $tmp[] = $x2-$lx2; $tmp[] = $y2-$ly2; |
|
| 1958 | - $tmp[] = $x2-$lx1; $tmp[] = $y2-$ly1; |
|
| 1955 | + $tmp[] = $x1 - $lx1; $tmp[] = $y1 - $ly1; |
|
| 1956 | + $tmp[] = $x1 - $lx2; $tmp[] = $y1 - $ly2; |
|
| 1957 | + $tmp[] = $x2 - $lx2; $tmp[] = $y2 - $ly2; |
|
| 1958 | + $tmp[] = $x2 - $lx1; $tmp[] = $y2 - $ly1; |
|
| 1959 | 1959 | $this->pdf->Polygon($tmp, 'F'); |
| 1960 | 1960 | } |
| 1961 | 1961 | } |
| 1962 | 1962 | } |
| 1963 | - } else if ($type=='double') { |
|
| 1963 | + } else if ($type == 'double') { |
|
| 1964 | 1964 | |
| 1965 | 1965 | // if double, 2 lines : 0=>1/3 and 2/3=>1 |
| 1966 | 1966 | $pt1 = $pt; |
| 1967 | 1967 | $pt2 = $pt; |
| 1968 | 1968 | |
| 1969 | - if (count($pt)==12) { |
|
| 1969 | + if (count($pt) == 12) { |
|
| 1970 | 1970 | // line 1 |
| 1971 | - $pt1[0] = ($pt[0]-$pt[10])*0.33 + $pt[10]; |
|
| 1972 | - $pt1[1] = ($pt[1]-$pt[11])*0.33 + $pt[11]; |
|
| 1973 | - $pt1[2] = ($pt[2]-$pt[10])*0.33 + $pt[10]; |
|
| 1974 | - $pt1[3] = ($pt[3]-$pt[11])*0.33 + $pt[11]; |
|
| 1975 | - $pt1[4] = ($pt[4]-$pt[8])*0.33 + $pt[8]; |
|
| 1976 | - $pt1[5] = ($pt[5]-$pt[9])*0.33 + $pt[9]; |
|
| 1977 | - $pt1[6] = ($pt[6]-$pt[8])*0.33 + $pt[8]; |
|
| 1978 | - $pt1[7] = ($pt[7]-$pt[9])*0.33 + $pt[9]; |
|
| 1979 | - $pt2[10]= ($pt[10]-$pt[0])*0.33 + $pt[0]; |
|
| 1980 | - $pt2[11]= ($pt[11]-$pt[1])*0.33 + $pt[1]; |
|
| 1971 | + $pt1[0] = ($pt[0] - $pt[10]) * 0.33 + $pt[10]; |
|
| 1972 | + $pt1[1] = ($pt[1] - $pt[11]) * 0.33 + $pt[11]; |
|
| 1973 | + $pt1[2] = ($pt[2] - $pt[10]) * 0.33 + $pt[10]; |
|
| 1974 | + $pt1[3] = ($pt[3] - $pt[11]) * 0.33 + $pt[11]; |
|
| 1975 | + $pt1[4] = ($pt[4] - $pt[8]) * 0.33 + $pt[8]; |
|
| 1976 | + $pt1[5] = ($pt[5] - $pt[9]) * 0.33 + $pt[9]; |
|
| 1977 | + $pt1[6] = ($pt[6] - $pt[8]) * 0.33 + $pt[8]; |
|
| 1978 | + $pt1[7] = ($pt[7] - $pt[9]) * 0.33 + $pt[9]; |
|
| 1979 | + $pt2[10] = ($pt[10] - $pt[0]) * 0.33 + $pt[0]; |
|
| 1980 | + $pt2[11] = ($pt[11] - $pt[1]) * 0.33 + $pt[1]; |
|
| 1981 | 1981 | |
| 1982 | 1982 | // line 2 |
| 1983 | - $pt2[2] = ($pt[2] -$pt[0])*0.33 + $pt[0]; |
|
| 1984 | - $pt2[3] = ($pt[3] -$pt[1])*0.33 + $pt[1]; |
|
| 1985 | - $pt2[4] = ($pt[4] -$pt[6])*0.33 + $pt[6]; |
|
| 1986 | - $pt2[5] = ($pt[5] -$pt[7])*0.33 + $pt[7]; |
|
| 1987 | - $pt2[8] = ($pt[8] -$pt[6])*0.33 + $pt[6]; |
|
| 1988 | - $pt2[9] = ($pt[9] -$pt[7])*0.33 + $pt[7]; |
|
| 1983 | + $pt2[2] = ($pt[2] - $pt[0]) * 0.33 + $pt[0]; |
|
| 1984 | + $pt2[3] = ($pt[3] - $pt[1]) * 0.33 + $pt[1]; |
|
| 1985 | + $pt2[4] = ($pt[4] - $pt[6]) * 0.33 + $pt[6]; |
|
| 1986 | + $pt2[5] = ($pt[5] - $pt[7]) * 0.33 + $pt[7]; |
|
| 1987 | + $pt2[8] = ($pt[8] - $pt[6]) * 0.33 + $pt[6]; |
|
| 1988 | + $pt2[9] = ($pt[9] - $pt[7]) * 0.33 + $pt[7]; |
|
| 1989 | 1989 | } else { |
| 1990 | 1990 | // line 1 |
| 1991 | - $pt1[0] = ($pt[0]-$pt[6])*0.33 + $pt[6]; |
|
| 1992 | - $pt1[1] = ($pt[1]-$pt[7])*0.33 + $pt[7]; |
|
| 1993 | - $pt1[2] = ($pt[2]-$pt[4])*0.33 + $pt[4]; |
|
| 1994 | - $pt1[3] = ($pt[3]-$pt[5])*0.33 + $pt[5]; |
|
| 1991 | + $pt1[0] = ($pt[0] - $pt[6]) * 0.33 + $pt[6]; |
|
| 1992 | + $pt1[1] = ($pt[1] - $pt[7]) * 0.33 + $pt[7]; |
|
| 1993 | + $pt1[2] = ($pt[2] - $pt[4]) * 0.33 + $pt[4]; |
|
| 1994 | + $pt1[3] = ($pt[3] - $pt[5]) * 0.33 + $pt[5]; |
|
| 1995 | 1995 | |
| 1996 | 1996 | // line 2 |
| 1997 | - $pt2[6] = ($pt[6]-$pt[0])*0.33 + $pt[0]; |
|
| 1998 | - $pt2[7] = ($pt[7]-$pt[1])*0.33 + $pt[1]; |
|
| 1999 | - $pt2[4] = ($pt[4]-$pt[2])*0.33 + $pt[2]; |
|
| 2000 | - $pt2[5] = ($pt[5]-$pt[3])*0.33 + $pt[3]; |
|
| 1997 | + $pt2[6] = ($pt[6] - $pt[0]) * 0.33 + $pt[0]; |
|
| 1998 | + $pt2[7] = ($pt[7] - $pt[1]) * 0.33 + $pt[1]; |
|
| 1999 | + $pt2[4] = ($pt[4] - $pt[2]) * 0.33 + $pt[2]; |
|
| 2000 | + $pt2[5] = ($pt[5] - $pt[3]) * 0.33 + $pt[3]; |
|
| 2001 | 2001 | } |
| 2002 | 2002 | $this->pdf->Polygon($pt1, 'F'); |
| 2003 | 2003 | $this->pdf->Polygon($pt2, 'F'); |
| 2004 | - } else if ($type=='solid') { |
|
| 2004 | + } else if ($type == 'solid') { |
|
| 2005 | 2005 | // solid line : draw directly the polygon |
| 2006 | 2006 | $this->pdf->Polygon($pt, 'F'); |
| 2007 | 2007 | } |
@@ -2017,16 +2017,16 @@ discard block |
||
| 2017 | 2017 | protected function _prepareTransform($transform) |
| 2018 | 2018 | { |
| 2019 | 2019 | // it can not be empty |
| 2020 | - if (!$transform) return null; |
|
| 2020 | + if ( ! $transform) return null; |
|
| 2021 | 2021 | |
| 2022 | 2022 | // sctions must be like scale(...) |
| 2023 | - if (!preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) return null; |
|
| 2023 | + if ( ! preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) return null; |
|
| 2024 | 2024 | |
| 2025 | 2025 | // prepare the list of the actions |
| 2026 | 2026 | $actions = array(); |
| 2027 | 2027 | |
| 2028 | 2028 | // for actions |
| 2029 | - for ($k=0; $k<count($match[0]); $k++) { |
|
| 2029 | + for ($k = 0; $k < count($match[0]); $k++) { |
|
| 2030 | 2030 | |
| 2031 | 2031 | // get the name of the action |
| 2032 | 2032 | $name = strtolower($match[1][$k]); |
@@ -2038,52 +2038,52 @@ discard block |
||
| 2038 | 2038 | } |
| 2039 | 2039 | |
| 2040 | 2040 | // prepare the matrix, depending on the action |
| 2041 | - switch($name) |
|
| 2041 | + switch ($name) |
|
| 2042 | 2042 | { |
| 2043 | 2043 | case 'scale': |
| 2044 | - if (!isset($val[0])) $val[0] = 1.; else $val[0] = 1.*$val[0]; |
|
| 2045 | - if (!isset($val[1])) $val[1] = $val[0]; else $val[1] = 1.*$val[1]; |
|
| 2046 | - $actions[] = array($val[0],0,0,$val[1],0,0); |
|
| 2044 | + if ( ! isset($val[0])) $val[0] = 1.; else $val[0] = 1. * $val[0]; |
|
| 2045 | + if ( ! isset($val[1])) $val[1] = $val[0]; else $val[1] = 1. * $val[1]; |
|
| 2046 | + $actions[] = array($val[0], 0, 0, $val[1], 0, 0); |
|
| 2047 | 2047 | break; |
| 2048 | 2048 | |
| 2049 | 2049 | case 'translate': |
| 2050 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']); |
|
| 2051 | - if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']); |
|
| 2052 | - $actions[] = array(1,0,0,1,$val[0],$val[1]); |
|
| 2050 | + if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']); |
|
| 2051 | + if ( ! isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']); |
|
| 2052 | + $actions[] = array(1, 0, 0, 1, $val[0], $val[1]); |
|
| 2053 | 2053 | break; |
| 2054 | 2054 | |
| 2055 | 2055 | case 'rotate': |
| 2056 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.; |
|
| 2057 | - if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']); |
|
| 2058 | - if (!isset($val[2])) $val[2] = 0.; else $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']); |
|
| 2059 | - if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,-$val[1],-$val[2]); |
|
| 2060 | - $actions[] = array(cos($val[0]),sin($val[0]),-sin($val[0]),cos($val[0]),0,0); |
|
| 2061 | - if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,$val[1],$val[2]); |
|
| 2056 | + if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.; |
|
| 2057 | + if ( ! isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']); |
|
| 2058 | + if ( ! isset($val[2])) $val[2] = 0.; else $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']); |
|
| 2059 | + if ($val[1] || $val[2]) $actions[] = array(1, 0, 0, 1, -$val[1], -$val[2]); |
|
| 2060 | + $actions[] = array(cos($val[0]), sin($val[0]), -sin($val[0]), cos($val[0]), 0, 0); |
|
| 2061 | + if ($val[1] || $val[2]) $actions[] = array(1, 0, 0, 1, $val[1], $val[2]); |
|
| 2062 | 2062 | break; |
| 2063 | 2063 | |
| 2064 | 2064 | case 'skewx': |
| 2065 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.; |
|
| 2066 | - $actions[] = array(1,0,tan($val[0]),1,0,0); |
|
| 2065 | + if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.; |
|
| 2066 | + $actions[] = array(1, 0, tan($val[0]), 1, 0, 0); |
|
| 2067 | 2067 | break; |
| 2068 | 2068 | |
| 2069 | 2069 | case 'skewy': |
| 2070 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.; |
|
| 2071 | - $actions[] = array(1,tan($val[0]),0,1,0,0); |
|
| 2070 | + if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * M_PI / 180.; |
|
| 2071 | + $actions[] = array(1, tan($val[0]), 0, 1, 0, 0); |
|
| 2072 | 2072 | break; |
| 2073 | 2073 | case 'matrix': |
| 2074 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*1.; |
|
| 2075 | - if (!isset($val[1])) $val[1] = 0.; else $val[1] = $val[1]*1.; |
|
| 2076 | - if (!isset($val[2])) $val[2] = 0.; else $val[2] = $val[2]*1.; |
|
| 2077 | - if (!isset($val[3])) $val[3] = 0.; else $val[3] = $val[3]*1.; |
|
| 2078 | - if (!isset($val[4])) $val[4] = 0.; else $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']); |
|
| 2079 | - if (!isset($val[5])) $val[5] = 0.; else $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']); |
|
| 2080 | - $actions[] =$val; |
|
| 2074 | + if ( ! isset($val[0])) $val[0] = 0.; else $val[0] = $val[0] * 1.; |
|
| 2075 | + if ( ! isset($val[1])) $val[1] = 0.; else $val[1] = $val[1] * 1.; |
|
| 2076 | + if ( ! isset($val[2])) $val[2] = 0.; else $val[2] = $val[2] * 1.; |
|
| 2077 | + if ( ! isset($val[3])) $val[3] = 0.; else $val[3] = $val[3] * 1.; |
|
| 2078 | + if ( ! isset($val[4])) $val[4] = 0.; else $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']); |
|
| 2079 | + if ( ! isset($val[5])) $val[5] = 0.; else $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']); |
|
| 2080 | + $actions[] = $val; |
|
| 2081 | 2081 | break; |
| 2082 | 2082 | } |
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | 2085 | // if ther is no actions => return |
| 2086 | - if (!$actions) return null; |
|
| 2086 | + if ( ! $actions) return null; |
|
| 2087 | 2087 | |
| 2088 | 2088 | // get the first matrix |
| 2089 | 2089 | $m = $actions[0]; unset($actions[0]); |
@@ -2091,12 +2091,12 @@ discard block |
||
| 2091 | 2091 | // foreach matrix => multiply to the last matrix |
| 2092 | 2092 | foreach ($actions as $n) { |
| 2093 | 2093 | $m = array( |
| 2094 | - $m[0]*$n[0]+$m[2]*$n[1], |
|
| 2095 | - $m[1]*$n[0]+$m[3]*$n[1], |
|
| 2096 | - $m[0]*$n[2]+$m[2]*$n[3], |
|
| 2097 | - $m[1]*$n[2]+$m[3]*$n[3], |
|
| 2098 | - $m[0]*$n[4]+$m[2]*$n[5]+$m[4], |
|
| 2099 | - $m[1]*$n[4]+$m[3]*$n[5]+$m[5] |
|
| 2094 | + $m[0] * $n[0] + $m[2] * $n[1], |
|
| 2095 | + $m[1] * $n[0] + $m[3] * $n[1], |
|
| 2096 | + $m[0] * $n[2] + $m[2] * $n[3], |
|
| 2097 | + $m[1] * $n[2] + $m[3] * $n[3], |
|
| 2098 | + $m[0] * $n[4] + $m[2] * $n[5] + $m[4], |
|
| 2099 | + $m[1] * $n[4] + $m[3] * $n[5] + $m[5] |
|
| 2100 | 2100 | ); |
| 2101 | 2101 | } |
| 2102 | 2102 | |
@@ -2111,14 +2111,14 @@ discard block |
||
| 2111 | 2111 | */ |
| 2112 | 2112 | protected function _calculateTableCellSize(&$cases, &$corr) |
| 2113 | 2113 | { |
| 2114 | - if (!isset($corr[0])) return true; |
|
| 2114 | + if ( ! isset($corr[0])) return true; |
|
| 2115 | 2115 | |
| 2116 | 2116 | // for each cell without colspan, we get the max width for each column |
| 2117 | 2117 | $sw = array(); |
| 2118 | - for ($x=0; $x<count($corr[0]); $x++) { |
|
| 2119 | - $m=0; |
|
| 2120 | - for ($y=0; $y<count($corr); $y++) { |
|
| 2121 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]==1) { |
|
| 2118 | + for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2119 | + $m = 0; |
|
| 2120 | + for ($y = 0; $y < count($corr); $y++) { |
|
| 2121 | + if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2] == 1) { |
|
| 2122 | 2122 | $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']); |
| 2123 | 2123 | } |
| 2124 | 2124 | } |
@@ -2126,17 +2126,17 @@ discard block |
||
| 2126 | 2126 | } |
| 2127 | 2127 | |
| 2128 | 2128 | // for each cell with colspan, we adapt the width of each column |
| 2129 | - for ($x=0; $x<count($corr[0]); $x++) { |
|
| 2130 | - for ($y=0; $y<count($corr); $y++) { |
|
| 2131 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]>1) { |
|
| 2129 | + for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2130 | + for ($y = 0; $y < count($corr); $y++) { |
|
| 2131 | + if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2] > 1) { |
|
| 2132 | 2132 | |
| 2133 | 2133 | // sum the max width of each column in colspan |
| 2134 | - $s = 0; for ($i=0; $i<$corr[$y][$x][2]; $i++) $s+= $sw[$x+$i]; |
|
| 2134 | + $s = 0; for ($i = 0; $i < $corr[$y][$x][2]; $i++) $s += $sw[$x + $i]; |
|
| 2135 | 2135 | |
| 2136 | 2136 | // if the max width is < the width of the cell with colspan => we adapt the width of each max width |
| 2137 | - if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']) { |
|
| 2138 | - for ($i=0; $i<$corr[$y][$x][2]; $i++) { |
|
| 2139 | - $sw[$x+$i] = $sw[$x+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']; |
|
| 2137 | + if ($s > 0 && $s < $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']) { |
|
| 2138 | + for ($i = 0; $i < $corr[$y][$x][2]; $i++) { |
|
| 2139 | + $sw[$x + $i] = $sw[$x + $i] / $s * $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']; |
|
| 2140 | 2140 | } |
| 2141 | 2141 | } |
| 2142 | 2142 | } |
@@ -2144,17 +2144,17 @@ discard block |
||
| 2144 | 2144 | } |
| 2145 | 2145 | |
| 2146 | 2146 | // set the new width, for each cell |
| 2147 | - for ($x=0; $x<count($corr[0]); $x++) { |
|
| 2148 | - for ($y=0; $y<count($corr); $y++) { |
|
| 2147 | + for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2148 | + for ($y = 0; $y < count($corr); $y++) { |
|
| 2149 | 2149 | if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) { |
| 2150 | 2150 | // without colspan |
| 2151 | - if ($corr[$y][$x][2]==1) { |
|
| 2151 | + if ($corr[$y][$x][2] == 1) { |
|
| 2152 | 2152 | $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $sw[$x]; |
| 2153 | 2153 | // with colspan |
| 2154 | 2154 | } else { |
| 2155 | 2155 | $s = 0; |
| 2156 | - for ($i=0; $i<$corr[$y][$x][2]; $i++) { |
|
| 2157 | - $s+= $sw[$x+$i]; |
|
| 2156 | + for ($i = 0; $i < $corr[$y][$x][2]; $i++) { |
|
| 2157 | + $s += $sw[$x + $i]; |
|
| 2158 | 2158 | } |
| 2159 | 2159 | $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $s; |
| 2160 | 2160 | } |
@@ -2164,10 +2164,10 @@ discard block |
||
| 2164 | 2164 | |
| 2165 | 2165 | // for each cell without rowspan, we get the max height for each line |
| 2166 | 2166 | $sh = array(); |
| 2167 | - for ($y=0; $y<count($corr); $y++) { |
|
| 2168 | - $m=0; |
|
| 2169 | - for ($x=0; $x<count($corr[0]); $x++) { |
|
| 2170 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]==1) { |
|
| 2167 | + for ($y = 0; $y < count($corr); $y++) { |
|
| 2168 | + $m = 0; |
|
| 2169 | + for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2170 | + if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3] == 1) { |
|
| 2171 | 2171 | $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']); |
| 2172 | 2172 | } |
| 2173 | 2173 | } |
@@ -2175,17 +2175,17 @@ discard block |
||
| 2175 | 2175 | } |
| 2176 | 2176 | |
| 2177 | 2177 | // for each cell with rowspan, we adapt the height of each line |
| 2178 | - for ($y=0; $y<count($corr); $y++) { |
|
| 2179 | - for ($x=0; $x<count($corr[0]); $x++) { |
|
| 2180 | - if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]>1) { |
|
| 2178 | + for ($y = 0; $y < count($corr); $y++) { |
|
| 2179 | + for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2180 | + if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3] > 1) { |
|
| 2181 | 2181 | |
| 2182 | 2182 | // sum the max height of each line in rowspan |
| 2183 | - $s = 0; for ($i=0; $i<$corr[$y][$x][3]; $i++) $s+= $sh[$y+$i]; |
|
| 2183 | + $s = 0; for ($i = 0; $i < $corr[$y][$x][3]; $i++) $s += $sh[$y + $i]; |
|
| 2184 | 2184 | |
| 2185 | 2185 | // if the max height is < the height of the cell with rowspan => we adapt the height of each max height |
| 2186 | - if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']) { |
|
| 2187 | - for ($i=0; $i<$corr[$y][$x][3]; $i++) { |
|
| 2188 | - $sh[$y+$i] = $sh[$y+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']; |
|
| 2186 | + if ($s > 0 && $s < $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']) { |
|
| 2187 | + for ($i = 0; $i < $corr[$y][$x][3]; $i++) { |
|
| 2188 | + $sh[$y + $i] = $sh[$y + $i] / $s * $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']; |
|
| 2189 | 2189 | } |
| 2190 | 2190 | } |
| 2191 | 2191 | } |
@@ -2193,26 +2193,26 @@ discard block |
||
| 2193 | 2193 | } |
| 2194 | 2194 | |
| 2195 | 2195 | // set the new height, for each cell |
| 2196 | - for ($y=0; $y<count($corr); $y++) { |
|
| 2197 | - for ($x=0; $x<count($corr[0]); $x++) { |
|
| 2196 | + for ($y = 0; $y < count($corr); $y++) { |
|
| 2197 | + for ($x = 0; $x < count($corr[0]); $x++) { |
|
| 2198 | 2198 | if (isset($corr[$y][$x]) && is_array($corr[$y][$x])) { |
| 2199 | 2199 | // without rowspan |
| 2200 | - if ($corr[$y][$x][3]==1) { |
|
| 2200 | + if ($corr[$y][$x][3] == 1) { |
|
| 2201 | 2201 | $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $sh[$y]; |
| 2202 | 2202 | // with rowspan |
| 2203 | 2203 | } else { |
| 2204 | 2204 | $s = 0; |
| 2205 | - for ($i=0; $i<$corr[$y][$x][3]; $i++) { |
|
| 2206 | - $s+= $sh[$y+$i]; |
|
| 2205 | + for ($i = 0; $i < $corr[$y][$x][3]; $i++) { |
|
| 2206 | + $s += $sh[$y + $i]; |
|
| 2207 | 2207 | } |
| 2208 | 2208 | $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $s; |
| 2209 | 2209 | |
| 2210 | - for ($j=1; $j<$corr[$y][$x][3]; $j++) { |
|
| 2211 | - $tx = $x+1; |
|
| 2212 | - $ty = $y+$j; |
|
| 2213 | - for (true; isset($corr[$ty][$tx]) && !is_array($corr[$ty][$tx]); $tx++); |
|
| 2210 | + for ($j = 1; $j < $corr[$y][$x][3]; $j++) { |
|
| 2211 | + $tx = $x + 1; |
|
| 2212 | + $ty = $y + $j; |
|
| 2213 | + for (true; isset($corr[$ty][$tx]) && ! is_array($corr[$ty][$tx]); $tx++); |
|
| 2214 | 2214 | if (isset($corr[$ty][$tx])) { |
| 2215 | - $cases[$corr[$ty][$tx][1]][$corr[$ty][$tx][0]]['dw']+= $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']; |
|
| 2215 | + $cases[$corr[$ty][$tx][1]][$corr[$ty][$tx][0]]['dw'] += $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']; |
|
| 2216 | 2216 | } |
| 2217 | 2217 | } |
| 2218 | 2218 | } |
@@ -2231,11 +2231,11 @@ discard block |
||
| 2231 | 2231 | protected function _tag_open_PAGE($param) |
| 2232 | 2232 | { |
| 2233 | 2233 | if ($this->_isForOneLine) return false; |
| 2234 | - if ($this->_debugActif) $this->_DEBUG_add('PAGE '.($this->_page+1), true); |
|
| 2234 | + if ($this->_debugActif) $this->_DEBUG_add('PAGE '.($this->_page + 1), true); |
|
| 2235 | 2235 | |
| 2236 | - $newPageSet= (!isset($param['pageset']) || $param['pageset']!='old'); |
|
| 2236 | + $newPageSet = ( ! isset($param['pageset']) || $param['pageset'] != 'old'); |
|
| 2237 | 2237 | |
| 2238 | - $resetPageNumber = (isset($param['pagegroup']) && $param['pagegroup']=='new'); |
|
| 2238 | + $resetPageNumber = (isset($param['pagegroup']) && $param['pagegroup'] == 'new'); |
|
| 2239 | 2239 | |
| 2240 | 2240 | $this->_maxH = 0; |
| 2241 | 2241 | |
@@ -2248,12 +2248,12 @@ discard block |
||
| 2248 | 2248 | $orientation = ''; |
| 2249 | 2249 | if (isset($param['orientation'])) { |
| 2250 | 2250 | $param['orientation'] = strtolower($param['orientation']); |
| 2251 | - if ($param['orientation']=='p') $orientation = 'P'; |
|
| 2252 | - if ($param['orientation']=='portrait') $orientation = 'P'; |
|
| 2251 | + if ($param['orientation'] == 'p') $orientation = 'P'; |
|
| 2252 | + if ($param['orientation'] == 'portrait') $orientation = 'P'; |
|
| 2253 | 2253 | |
| 2254 | - if ($param['orientation']=='l') $orientation = 'L'; |
|
| 2255 | - if ($param['orientation']=='paysage') $orientation = 'L'; |
|
| 2256 | - if ($param['orientation']=='landscape') $orientation = 'L'; |
|
| 2254 | + if ($param['orientation'] == 'l') $orientation = 'L'; |
|
| 2255 | + if ($param['orientation'] == 'paysage') $orientation = 'L'; |
|
| 2256 | + if ($param['orientation'] == 'landscape') $orientation = 'L'; |
|
| 2257 | 2257 | } |
| 2258 | 2258 | |
| 2259 | 2259 | // format |
@@ -2268,29 +2268,29 @@ discard block |
||
| 2268 | 2268 | // background |
| 2269 | 2269 | $background = array(); |
| 2270 | 2270 | if (isset($param['backimg'])) { |
| 2271 | - $background['img'] = isset($param['backimg']) ? $param['backimg'] : ''; // src of the image |
|
| 2271 | + $background['img'] = isset($param['backimg']) ? $param['backimg'] : ''; // src of the image |
|
| 2272 | 2272 | $background['posX'] = isset($param['backimgx']) ? $param['backimgx'] : 'center'; // horizontale position of the image |
| 2273 | 2273 | $background['posY'] = isset($param['backimgy']) ? $param['backimgy'] : 'middle'; // vertical position of the image |
| 2274 | - $background['width'] = isset($param['backimgw']) ? $param['backimgw'] : '100%'; // width of the image (100% = page width) |
|
| 2274 | + $background['width'] = isset($param['backimgw']) ? $param['backimgw'] : '100%'; // width of the image (100% = page width) |
|
| 2275 | 2275 | |
| 2276 | 2276 | // convert the src of the image, if parameters |
| 2277 | 2277 | $background['img'] = str_replace('&', '&', $background['img']); |
| 2278 | 2278 | |
| 2279 | 2279 | // convert the positions |
| 2280 | - if ($background['posX']=='left') $background['posX'] = '0%'; |
|
| 2281 | - if ($background['posX']=='center') $background['posX'] = '50%'; |
|
| 2282 | - if ($background['posX']=='right') $background['posX'] = '100%'; |
|
| 2283 | - if ($background['posY']=='top') $background['posY'] = '0%'; |
|
| 2284 | - if ($background['posY']=='middle') $background['posY'] = '50%'; |
|
| 2285 | - if ($background['posY']=='bottom') $background['posY'] = '100%'; |
|
| 2280 | + if ($background['posX'] == 'left') $background['posX'] = '0%'; |
|
| 2281 | + if ($background['posX'] == 'center') $background['posX'] = '50%'; |
|
| 2282 | + if ($background['posX'] == 'right') $background['posX'] = '100%'; |
|
| 2283 | + if ($background['posY'] == 'top') $background['posY'] = '0%'; |
|
| 2284 | + if ($background['posY'] == 'middle') $background['posY'] = '50%'; |
|
| 2285 | + if ($background['posY'] == 'bottom') $background['posY'] = '100%'; |
|
| 2286 | 2286 | |
| 2287 | 2287 | if ($background['img']) { |
| 2288 | 2288 | // get the size of the image |
| 2289 | 2289 | // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini |
| 2290 | - $infos=@getimagesize($background['img']); |
|
| 2291 | - if (count($infos)>1) { |
|
| 2290 | + $infos = @getimagesize($background['img']); |
|
| 2291 | + if (count($infos) > 1) { |
|
| 2292 | 2292 | $imageWidth = $this->parsingCss->ConvertToMM($background['width'], $this->pdf->getW()); |
| 2293 | - $imageHeight = $imageWidth*$infos[1]/$infos[0]; |
|
| 2293 | + $imageHeight = $imageWidth * $infos[1] / $infos[0]; |
|
| 2294 | 2294 | |
| 2295 | 2295 | $background['width'] = $imageWidth; |
| 2296 | 2296 | $background['posX'] = $this->parsingCss->ConvertToMM($background['posX'], $this->pdf->getW() - $imageWidth); |
@@ -2304,10 +2304,10 @@ discard block |
||
| 2304 | 2304 | } |
| 2305 | 2305 | |
| 2306 | 2306 | // margins of the page |
| 2307 | - $background['top'] = isset($param['backtop']) ? $param['backtop'] : '0'; |
|
| 2307 | + $background['top'] = isset($param['backtop']) ? $param['backtop'] : '0'; |
|
| 2308 | 2308 | $background['bottom'] = isset($param['backbottom']) ? $param['backbottom'] : '0'; |
| 2309 | - $background['left'] = isset($param['backleft']) ? $param['backleft'] : '0'; |
|
| 2310 | - $background['right'] = isset($param['backright']) ? $param['backright'] : '0'; |
|
| 2309 | + $background['left'] = isset($param['backleft']) ? $param['backleft'] : '0'; |
|
| 2310 | + $background['right'] = isset($param['backright']) ? $param['backright'] : '0'; |
|
| 2311 | 2311 | |
| 2312 | 2312 | // if no unit => mm |
| 2313 | 2313 | if (preg_match('/^([0-9]*)$/isU', $background['top'])) $background['top'] .= 'mm'; |
@@ -2323,8 +2323,8 @@ discard block |
||
| 2323 | 2323 | |
| 2324 | 2324 | // get the background color |
| 2325 | 2325 | $res = false; |
| 2326 | - $background['color'] = isset($param['backcolor']) ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null; |
|
| 2327 | - if (!$res) $background['color'] = null; |
|
| 2326 | + $background['color'] = isset($param['backcolor']) ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null; |
|
| 2327 | + if ( ! $res) $background['color'] = null; |
|
| 2328 | 2328 | |
| 2329 | 2329 | $this->parsingCss->save(); |
| 2330 | 2330 | $this->parsingCss->analyse('PAGE', $param); |
@@ -2395,11 +2395,11 @@ discard block |
||
| 2395 | 2395 | if ($this->_isForOneLine) return false; |
| 2396 | 2396 | |
| 2397 | 2397 | $this->_subHEADER = array(); |
| 2398 | - for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) { |
|
| 2398 | + for ($this->_parsePos; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) { |
|
| 2399 | 2399 | $action = $this->parsingHtml->code[$this->_parsePos]; |
| 2400 | - if ($action['name']=='page_header') $action['name']='page_header_sub'; |
|
| 2400 | + if ($action['name'] == 'page_header') $action['name'] = 'page_header_sub'; |
|
| 2401 | 2401 | $this->_subHEADER[] = $action; |
| 2402 | - if (strtolower($action['name'])=='page_header_sub' && $action['close']) break; |
|
| 2402 | + if (strtolower($action['name']) == 'page_header_sub' && $action['close']) break; |
|
| 2403 | 2403 | } |
| 2404 | 2404 | |
| 2405 | 2405 | $this->_setPageHeader(); |
@@ -2419,11 +2419,11 @@ discard block |
||
| 2419 | 2419 | if ($this->_isForOneLine) return false; |
| 2420 | 2420 | |
| 2421 | 2421 | $this->_subFOOTER = array(); |
| 2422 | - for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) { |
|
| 2422 | + for ($this->_parsePos; $this->_parsePos < count($this->parsingHtml->code); $this->_parsePos++) { |
|
| 2423 | 2423 | $action = $this->parsingHtml->code[$this->_parsePos]; |
| 2424 | - if ($action['name']=='page_footer') $action['name']='page_footer_sub'; |
|
| 2424 | + if ($action['name'] == 'page_footer') $action['name'] = 'page_footer_sub'; |
|
| 2425 | 2425 | $this->_subFOOTER[] = $action; |
| 2426 | - if (strtolower($action['name'])=='page_footer_sub' && $action['close']) break; |
|
| 2426 | + if (strtolower($action['name']) == 'page_footer_sub' && $action['close']) break; |
|
| 2427 | 2427 | } |
| 2428 | 2428 | |
| 2429 | 2429 | $this->_setPageFooter(); |
@@ -2541,8 +2541,8 @@ discard block |
||
| 2541 | 2541 | |
| 2542 | 2542 | $this->parsingCss->initStyle(); |
| 2543 | 2543 | $this->parsingCss->resetStyle(); |
| 2544 | - $this->parsingCss->value['width'] = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight; |
|
| 2545 | - $this->parsingCss->table = array(); |
|
| 2544 | + $this->parsingCss->value['width'] = $this->pdf->getW() - $this->_defaultLeft - $this->_defaultRight; |
|
| 2545 | + $this->parsingCss->table = array(); |
|
| 2546 | 2546 | |
| 2547 | 2547 | // we create a sub HTML2PFDF, and we execute on it the content of the footer, to get the height of it |
| 2548 | 2548 | $sub = null; |
@@ -2575,11 +2575,11 @@ discard block |
||
| 2575 | 2575 | |
| 2576 | 2576 | $this->parsingCss->value = $this->_subSTATES['s']; |
| 2577 | 2577 | $this->parsingCss->table = $this->_subSTATES['t']; |
| 2578 | - $this->_pageMarges = $this->_subSTATES['mp']; |
|
| 2579 | - $this->_margeLeft = $this->_subSTATES['ml']; |
|
| 2580 | - $this->_margeRight = $this->_subSTATES['mr']; |
|
| 2581 | - $this->_margeTop = $this->_subSTATES['mt']; |
|
| 2582 | - $this->_margeBottom = $this->_subSTATES['mb']; |
|
| 2578 | + $this->_pageMarges = $this->_subSTATES['mp']; |
|
| 2579 | + $this->_margeLeft = $this->_subSTATES['ml']; |
|
| 2580 | + $this->_margeRight = $this->_subSTATES['mr']; |
|
| 2581 | + $this->_margeTop = $this->_subSTATES['mt']; |
|
| 2582 | + $this->_margeBottom = $this->_subSTATES['mb']; |
|
| 2583 | 2583 | $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight); |
| 2584 | 2584 | $this->pdf->SetAutoPageBreak(false, $this->_margeBottom); |
| 2585 | 2585 | $this->pdf->setXY($this->_subSTATES['x'], $this->_subSTATES['y']); |
@@ -2612,8 +2612,8 @@ discard block |
||
| 2612 | 2612 | |
| 2613 | 2613 | // if the content does not fit on the page => new page |
| 2614 | 2614 | if ( |
| 2615 | - $sub->_maxY < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin()) && |
|
| 2616 | - $y + $sub->_maxY>=($this->pdf->getH() - $this->pdf->getbMargin()) |
|
| 2615 | + $sub->_maxY < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin()) && |
|
| 2616 | + $y + $sub->_maxY >= ($this->pdf->getH() - $this->pdf->getbMargin()) |
|
| 2617 | 2617 | ) { |
| 2618 | 2618 | $this->_setNewPage(); |
| 2619 | 2619 | } |
@@ -2669,10 +2669,10 @@ discard block |
||
| 2669 | 2669 | if ($this->parsingCss->value['margin-auto']) $alignObject = 'center'; |
| 2670 | 2670 | |
| 2671 | 2671 | $marge = array(); |
| 2672 | - $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03; |
|
| 2673 | - $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03; |
|
| 2674 | - $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03; |
|
| 2675 | - $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03; |
|
| 2672 | + $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l'] + 0.03; |
|
| 2673 | + $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r'] + 0.03; |
|
| 2674 | + $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t'] + 0.03; |
|
| 2675 | + $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b'] + 0.03; |
|
| 2676 | 2676 | |
| 2677 | 2677 | // extract the content of the div |
| 2678 | 2678 | $level = $this->parsingHtml->getLevel($this->_parsePos); |
@@ -2691,10 +2691,10 @@ discard block |
||
| 2691 | 2691 | $wReel = $w; |
| 2692 | 2692 | $hReel = $h; |
| 2693 | 2693 | |
| 2694 | - $w+= $marge['l']+$marge['r']+0.001; |
|
| 2695 | - $h+= $marge['t']+$marge['b']+0.001; |
|
| 2694 | + $w += $marge['l'] + $marge['r'] + 0.001; |
|
| 2695 | + $h += $marge['t'] + $marge['b'] + 0.001; |
|
| 2696 | 2696 | |
| 2697 | - if ($this->parsingCss->value['overflow']=='hidden') { |
|
| 2697 | + if ($this->parsingCss->value['overflow'] == 'hidden') { |
|
| 2698 | 2698 | $overW = max($w, $this->parsingCss->value['width']); |
| 2699 | 2699 | $overH = max($h, $this->parsingCss->value['height']); |
| 2700 | 2700 | $overflow = true; |
@@ -2707,11 +2707,11 @@ discard block |
||
| 2707 | 2707 | $overW = null; |
| 2708 | 2708 | $overH = null; |
| 2709 | 2709 | $overflow = false; |
| 2710 | - $this->parsingCss->value['width'] = max($w, $this->parsingCss->value['width']); |
|
| 2711 | - $this->parsingCss->value['height'] = max($h, $this->parsingCss->value['height']); |
|
| 2710 | + $this->parsingCss->value['width'] = max($w, $this->parsingCss->value['width']); |
|
| 2711 | + $this->parsingCss->value['height'] = max($h, $this->parsingCss->value['height']); |
|
| 2712 | 2712 | } |
| 2713 | 2713 | |
| 2714 | - switch($this->parsingCss->value['rotate']) |
|
| 2714 | + switch ($this->parsingCss->value['rotate']) |
|
| 2715 | 2715 | { |
| 2716 | 2716 | case 90: |
| 2717 | 2717 | $tmp = $overH; $overH = $overW; $overW = $tmp; |
@@ -2719,7 +2719,7 @@ discard block |
||
| 2719 | 2719 | unset($tmp); |
| 2720 | 2720 | $w = $this->parsingCss->value['height']; |
| 2721 | 2721 | $h = $this->parsingCss->value['width']; |
| 2722 | - $tX =-$h; |
|
| 2722 | + $tX = -$h; |
|
| 2723 | 2723 | $tY = 0; |
| 2724 | 2724 | break; |
| 2725 | 2725 | |
@@ -2737,7 +2737,7 @@ discard block |
||
| 2737 | 2737 | $w = $this->parsingCss->value['height']; |
| 2738 | 2738 | $h = $this->parsingCss->value['width']; |
| 2739 | 2739 | $tX = 0; |
| 2740 | - $tY =-$w; |
|
| 2740 | + $tY = -$w; |
|
| 2741 | 2741 | break; |
| 2742 | 2742 | |
| 2743 | 2743 | default: |
@@ -2748,26 +2748,26 @@ discard block |
||
| 2748 | 2748 | break; |
| 2749 | 2749 | } |
| 2750 | 2750 | |
| 2751 | - if (!$this->parsingCss->value['position']) { |
|
| 2751 | + if ( ! $this->parsingCss->value['position']) { |
|
| 2752 | 2752 | if ( |
| 2753 | - $w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) && |
|
| 2754 | - $this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin()) |
|
| 2753 | + $w < ($this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin()) && |
|
| 2754 | + $this->pdf->getX() + $w >= ($this->pdf->getW() - $this->pdf->getrMargin()) |
|
| 2755 | 2755 | ) |
| 2756 | 2756 | $this->_tag_open_BR(array()); |
| 2757 | 2757 | |
| 2758 | 2758 | if ( |
| 2759 | - ($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) && |
|
| 2760 | - ($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) && |
|
| 2761 | - !$this->_isInOverflow |
|
| 2759 | + ($h < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin())) && |
|
| 2760 | + ($this->pdf->getY() + $h >= ($this->pdf->getH() - $this->pdf->getbMargin())) && |
|
| 2761 | + ! $this->_isInOverflow |
|
| 2762 | 2762 | ) |
| 2763 | 2763 | $this->_setNewPage(); |
| 2764 | 2764 | |
| 2765 | 2765 | $old = $this->parsingCss->getOldValues(); |
| 2766 | 2766 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 2767 | 2767 | |
| 2768 | - if ($parentWidth>$w) { |
|
| 2769 | - if ($alignObject=='center') $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 2770 | - else if ($alignObject=='right') $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 2768 | + if ($parentWidth > $w) { |
|
| 2769 | + if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 2770 | + else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 2771 | 2771 | } |
| 2772 | 2772 | |
| 2773 | 2773 | $this->parsingCss->setPosition(); |
@@ -2775,9 +2775,9 @@ discard block |
||
| 2775 | 2775 | $old = $this->parsingCss->getOldValues(); |
| 2776 | 2776 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 2777 | 2777 | |
| 2778 | - if ($parentWidth>$w) { |
|
| 2779 | - if ($alignObject=='center') $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 2780 | - else if ($alignObject=='right') $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 2778 | + if ($parentWidth > $w) { |
|
| 2779 | + if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 2780 | + else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 2781 | 2781 | } |
| 2782 | 2782 | |
| 2783 | 2783 | $this->parsingCss->setPosition(); |
@@ -2806,61 +2806,61 @@ discard block |
||
| 2806 | 2806 | ); |
| 2807 | 2807 | |
| 2808 | 2808 | $marge = array(); |
| 2809 | - $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03; |
|
| 2810 | - $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03; |
|
| 2811 | - $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03; |
|
| 2812 | - $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03; |
|
| 2809 | + $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l'] + 0.03; |
|
| 2810 | + $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r'] + 0.03; |
|
| 2811 | + $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t'] + 0.03; |
|
| 2812 | + $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b'] + 0.03; |
|
| 2813 | 2813 | |
| 2814 | - $this->parsingCss->value['width'] -= $marge['l']+$marge['r']; |
|
| 2815 | - $this->parsingCss->value['height']-= $marge['t']+$marge['b']; |
|
| 2814 | + $this->parsingCss->value['width'] -= $marge['l'] + $marge['r']; |
|
| 2815 | + $this->parsingCss->value['height'] -= $marge['t'] + $marge['b']; |
|
| 2816 | 2816 | |
| 2817 | 2817 | $xCorr = 0; |
| 2818 | 2818 | $yCorr = 0; |
| 2819 | - if (!$this->_subPart && !$this->_isSubPart) { |
|
| 2820 | - switch($this->parsingCss->value['text-align']) |
|
| 2819 | + if ( ! $this->_subPart && ! $this->_isSubPart) { |
|
| 2820 | + switch ($this->parsingCss->value['text-align']) |
|
| 2821 | 2821 | { |
| 2822 | 2822 | case 'right': |
| 2823 | - $xCorr = ($this->parsingCss->value['width']-$wReel); |
|
| 2823 | + $xCorr = ($this->parsingCss->value['width'] - $wReel); |
|
| 2824 | 2824 | break; |
| 2825 | 2825 | case 'center': |
| 2826 | - $xCorr = ($this->parsingCss->value['width']-$wReel)*0.5; |
|
| 2826 | + $xCorr = ($this->parsingCss->value['width'] - $wReel) * 0.5; |
|
| 2827 | 2827 | break; |
| 2828 | 2828 | } |
| 2829 | - if ($xCorr>0) $xCorr=0; |
|
| 2830 | - switch($this->parsingCss->value['vertical-align']) |
|
| 2829 | + if ($xCorr > 0) $xCorr = 0; |
|
| 2830 | + switch ($this->parsingCss->value['vertical-align']) |
|
| 2831 | 2831 | { |
| 2832 | 2832 | case 'bottom': |
| 2833 | - $yCorr = ($this->parsingCss->value['height']-$hReel); |
|
| 2833 | + $yCorr = ($this->parsingCss->value['height'] - $hReel); |
|
| 2834 | 2834 | break; |
| 2835 | 2835 | case 'middle': |
| 2836 | - $yCorr = ($this->parsingCss->value['height']-$hReel)*0.5; |
|
| 2836 | + $yCorr = ($this->parsingCss->value['height'] - $hReel) * 0.5; |
|
| 2837 | 2837 | break; |
| 2838 | 2838 | } |
| 2839 | 2839 | } |
| 2840 | 2840 | |
| 2841 | 2841 | if ($overflow) { |
| 2842 | - $overW-= $marge['l']+$marge['r']; |
|
| 2843 | - $overH-= $marge['t']+$marge['b']; |
|
| 2842 | + $overW -= $marge['l'] + $marge['r']; |
|
| 2843 | + $overH -= $marge['t'] + $marge['b']; |
|
| 2844 | 2844 | $this->pdf->clippingPathStart( |
| 2845 | - $this->parsingCss->value['x']+$marge['l'], |
|
| 2846 | - $this->parsingCss->value['y']+$marge['t'], |
|
| 2845 | + $this->parsingCss->value['x'] + $marge['l'], |
|
| 2846 | + $this->parsingCss->value['y'] + $marge['t'], |
|
| 2847 | 2847 | $this->parsingCss->value['width'], |
| 2848 | 2848 | $this->parsingCss->value['height'] |
| 2849 | 2849 | ); |
| 2850 | 2850 | |
| 2851 | - $this->parsingCss->value['x']+= $xCorr; |
|
| 2851 | + $this->parsingCss->value['x'] += $xCorr; |
|
| 2852 | 2852 | |
| 2853 | 2853 | // marges from the dimension of the content |
| 2854 | - $mL = $this->parsingCss->value['x']+$marge['l']; |
|
| 2854 | + $mL = $this->parsingCss->value['x'] + $marge['l']; |
|
| 2855 | 2855 | $mR = $this->pdf->getW() - $mL - $overW; |
| 2856 | 2856 | } else { |
| 2857 | 2857 | // marges from the dimension of the div |
| 2858 | - $mL = $this->parsingCss->value['x']+$marge['l']; |
|
| 2858 | + $mL = $this->parsingCss->value['x'] + $marge['l']; |
|
| 2859 | 2859 | $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width']; |
| 2860 | 2860 | } |
| 2861 | 2861 | |
| 2862 | - $x = $this->parsingCss->value['x']+$marge['l']; |
|
| 2863 | - $y = $this->parsingCss->value['y']+$marge['t']+$yCorr; |
|
| 2862 | + $x = $this->parsingCss->value['x'] + $marge['l']; |
|
| 2863 | + $y = $this->parsingCss->value['y'] + $marge['t'] + $yCorr; |
|
| 2864 | 2864 | $this->_saveMargin($mL, 0, $mR); |
| 2865 | 2865 | $this->pdf->setXY($x, $y); |
| 2866 | 2866 | |
@@ -2908,10 +2908,10 @@ discard block |
||
| 2908 | 2908 | $this->parsingCss->analyse('fieldset', $param); |
| 2909 | 2909 | |
| 2910 | 2910 | // get height of LEGEND element and make fieldset corrections |
| 2911 | - for ($tempPos = $this->_parsePos + 1; $tempPos<count($this->parsingHtml->code); $tempPos++) { |
|
| 2911 | + for ($tempPos = $this->_parsePos + 1; $tempPos < count($this->parsingHtml->code); $tempPos++) { |
|
| 2912 | 2912 | $action = $this->parsingHtml->code[$tempPos]; |
| 2913 | 2913 | if ($action['name'] == 'fieldset') break; |
| 2914 | - if ($action['name'] == 'legend' && !$action['close']) { |
|
| 2914 | + if ($action['name'] == 'legend' && ! $action['close']) { |
|
| 2915 | 2915 | $legendOpenPos = $tempPos; |
| 2916 | 2916 | |
| 2917 | 2917 | $sub = null; |
@@ -2919,7 +2919,7 @@ discard block |
||
| 2919 | 2919 | $sub->parsingHtml->code = $this->parsingHtml->getLevel($tempPos - 1); |
| 2920 | 2920 | |
| 2921 | 2921 | $res = null; |
| 2922 | - for ($sub->_parsePos = 0; $sub->_parsePos<count($sub->parsingHtml->code); $sub->_parsePos++) { |
|
| 2922 | + for ($sub->_parsePos = 0; $sub->_parsePos < count($sub->parsingHtml->code); $sub->_parsePos++) { |
|
| 2923 | 2923 | $action = $sub->parsingHtml->code[$sub->_parsePos]; |
| 2924 | 2924 | $sub->_executeAction($action); |
| 2925 | 2925 | |
@@ -2953,11 +2953,11 @@ discard block |
||
| 2953 | 2953 | * @param string $other name of tag that used the div tag |
| 2954 | 2954 | * @return boolean |
| 2955 | 2955 | */ |
| 2956 | - protected function _tag_close_DIV($param, $other='div') |
|
| 2956 | + protected function _tag_close_DIV($param, $other = 'div') |
|
| 2957 | 2957 | { |
| 2958 | 2958 | if ($this->_isForOneLine) return false; |
| 2959 | 2959 | |
| 2960 | - if ($this->parsingCss->value['overflow']=='hidden') { |
|
| 2960 | + if ($this->parsingCss->value['overflow'] == 'hidden') { |
|
| 2961 | 2961 | $this->_maxX = $this->parsingCss->value['old_maxX']; |
| 2962 | 2962 | $this->_maxY = $this->parsingCss->value['old_maxY']; |
| 2963 | 2963 | $this->_maxH = $this->parsingCss->value['old_maxH']; |
@@ -2969,17 +2969,17 @@ discard block |
||
| 2969 | 2969 | $this->pdf->stopTransform(); |
| 2970 | 2970 | |
| 2971 | 2971 | $marge = array(); |
| 2972 | - $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03; |
|
| 2973 | - $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r']+0.03; |
|
| 2974 | - $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t']+0.03; |
|
| 2975 | - $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b']+0.03; |
|
| 2972 | + $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l'] + 0.03; |
|
| 2973 | + $marge['r'] = $this->parsingCss->value['border']['r']['width'] + $this->parsingCss->value['padding']['r'] + 0.03; |
|
| 2974 | + $marge['t'] = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['padding']['t'] + 0.03; |
|
| 2975 | + $marge['b'] = $this->parsingCss->value['border']['b']['width'] + $this->parsingCss->value['padding']['b'] + 0.03; |
|
| 2976 | 2976 | |
| 2977 | 2977 | $x = $this->parsingCss->value['x']; |
| 2978 | 2978 | $y = $this->parsingCss->value['y']; |
| 2979 | - $w = $this->parsingCss->value['width']+$marge['l']+$marge['r']+$this->parsingCss->value['margin']['r']; |
|
| 2980 | - $h = $this->parsingCss->value['height']+$marge['t']+$marge['b']+$this->parsingCss->value['margin']['b']; |
|
| 2979 | + $w = $this->parsingCss->value['width'] + $marge['l'] + $marge['r'] + $this->parsingCss->value['margin']['r']; |
|
| 2980 | + $h = $this->parsingCss->value['height'] + $marge['t'] + $marge['b'] + $this->parsingCss->value['margin']['b']; |
|
| 2981 | 2981 | |
| 2982 | - switch($this->parsingCss->value['rotate']) |
|
| 2982 | + switch ($this->parsingCss->value['rotate']) |
|
| 2983 | 2983 | { |
| 2984 | 2984 | case 90: |
| 2985 | 2985 | $t = $w; $w = $h; $h = $t; |
@@ -2994,11 +2994,11 @@ discard block |
||
| 2994 | 2994 | } |
| 2995 | 2995 | |
| 2996 | 2996 | |
| 2997 | - if ($this->parsingCss->value['position']!='absolute') { |
|
| 2998 | - $this->pdf->setXY($x+$w, $y); |
|
| 2997 | + if ($this->parsingCss->value['position'] != 'absolute') { |
|
| 2998 | + $this->pdf->setXY($x + $w, $y); |
|
| 2999 | 2999 | |
| 3000 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 3001 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 3000 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 3001 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 3002 | 3002 | $this->_maxH = max($this->_maxH, $h); |
| 3003 | 3003 | } else { |
| 3004 | 3004 | $this->pdf->setXY($this->parsingCss->value['xc'], $this->parsingCss->value['yc']); |
@@ -3006,7 +3006,7 @@ discard block |
||
| 3006 | 3006 | $this->_loadMax(); |
| 3007 | 3007 | } |
| 3008 | 3008 | |
| 3009 | - $block = ($this->parsingCss->value['display']!='inline' && $this->parsingCss->value['position']!='absolute'); |
|
| 3009 | + $block = ($this->parsingCss->value['display'] != 'inline' && $this->parsingCss->value['position'] != 'absolute'); |
|
| 3010 | 3010 | |
| 3011 | 3011 | $this->parsingCss->load(); |
| 3012 | 3012 | $this->parsingCss->fontSet(); |
@@ -3065,13 +3065,13 @@ discard block |
||
| 3065 | 3065 | { |
| 3066 | 3066 | // for compatibility with old versions < 3.29 |
| 3067 | 3067 | $lstBarcode = array(); |
| 3068 | - $lstBarcode['UPC_A'] = 'UPCA'; |
|
| 3069 | - $lstBarcode['CODE39'] = 'C39'; |
|
| 3068 | + $lstBarcode['UPC_A'] = 'UPCA'; |
|
| 3069 | + $lstBarcode['CODE39'] = 'C39'; |
|
| 3070 | 3070 | |
| 3071 | - if (!isset($param['type'])) $param['type'] = 'C39'; |
|
| 3072 | - if (!isset($param['value'])) $param['value'] = 0; |
|
| 3073 | - if (!isset($param['label'])) $param['label'] = 'label'; |
|
| 3074 | - if (!isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3071 | + if ( ! isset($param['type'])) $param['type'] = 'C39'; |
|
| 3072 | + if ( ! isset($param['value'])) $param['value'] = 0; |
|
| 3073 | + if ( ! isset($param['label'])) $param['label'] = 'label'; |
|
| 3074 | + if ( ! isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3075 | 3075 | |
| 3076 | 3076 | if ($this->_testIsDeprecated && (isset($param['bar_h']) || isset($param['bar_w']))) |
| 3077 | 3077 | throw new HTML2PDF_exception(9, array('BARCODE', 'bar_h, bar_w')); |
@@ -3086,18 +3086,18 @@ discard block |
||
| 3086 | 3086 | |
| 3087 | 3087 | $x = $this->pdf->getX(); |
| 3088 | 3088 | $y = $this->pdf->getY(); |
| 3089 | - $w = $this->parsingCss->value['width']; if (!$w) $w = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3090 | - $h = $this->parsingCss->value['height']; if (!$h) $h = $this->parsingCss->ConvertToMM('10mm'); |
|
| 3091 | - $txt = ($param['label']!=='none' ? $this->parsingCss->value['font-size'] : false); |
|
| 3089 | + $w = $this->parsingCss->value['width']; if ( ! $w) $w = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3090 | + $h = $this->parsingCss->value['height']; if ( ! $h) $h = $this->parsingCss->ConvertToMM('10mm'); |
|
| 3091 | + $txt = ($param['label'] !== 'none' ? $this->parsingCss->value['font-size'] : false); |
|
| 3092 | 3092 | $c = $this->parsingCss->value['color']; |
| 3093 | 3093 | $infos = $this->pdf->myBarcode($param['value'], $param['type'], $x, $y, $w, $h, $txt, $c); |
| 3094 | 3094 | |
| 3095 | - $this->_maxX = max($this->_maxX, $x+$infos[0]); |
|
| 3096 | - $this->_maxY = max($this->_maxY, $y+$infos[1]); |
|
| 3095 | + $this->_maxX = max($this->_maxX, $x + $infos[0]); |
|
| 3096 | + $this->_maxY = max($this->_maxY, $y + $infos[1]); |
|
| 3097 | 3097 | $this->_maxH = max($this->_maxH, $infos[1]); |
| 3098 | 3098 | $this->_maxE++; |
| 3099 | 3099 | |
| 3100 | - $this->pdf->setXY($x+$infos[0], $y); |
|
| 3100 | + $this->pdf->setXY($x + $infos[0], $y); |
|
| 3101 | 3101 | |
| 3102 | 3102 | $this->parsingCss->load(); |
| 3103 | 3103 | $this->parsingCss->fontSet(); |
@@ -3133,19 +3133,19 @@ discard block |
||
| 3133 | 3133 | |
| 3134 | 3134 | if ($this->_debugActif) $this->_DEBUG_add('QRCODE'); |
| 3135 | 3135 | |
| 3136 | - if (!isset($param['value'])) $param['value'] = ''; |
|
| 3137 | - if (!isset($param['ec'])) $param['ec'] = 'H'; |
|
| 3138 | - if (!isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3139 | - if (!isset($param['style']['background-color'])) $param['style']['background-color'] = '#FFFFFF'; |
|
| 3136 | + if ( ! isset($param['value'])) $param['value'] = ''; |
|
| 3137 | + if ( ! isset($param['ec'])) $param['ec'] = 'H'; |
|
| 3138 | + if ( ! isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3139 | + if ( ! isset($param['style']['background-color'])) $param['style']['background-color'] = '#FFFFFF'; |
|
| 3140 | 3140 | if (isset($param['style']['border'])) { |
| 3141 | - $borders = $param['style']['border']!='none'; |
|
| 3141 | + $borders = $param['style']['border'] != 'none'; |
|
| 3142 | 3142 | unset($param['style']['border']); |
| 3143 | 3143 | } else { |
| 3144 | 3144 | $borders = true; |
| 3145 | 3145 | } |
| 3146 | 3146 | |
| 3147 | - if ($param['value']==='') return true; |
|
| 3148 | - if (!in_array($param['ec'], array('L', 'M', 'Q', 'H'))) $param['ec'] = 'H'; |
|
| 3147 | + if ($param['value'] === '') return true; |
|
| 3148 | + if ( ! in_array($param['ec'], array('L', 'M', 'Q', 'H'))) $param['ec'] = 'H'; |
|
| 3149 | 3149 | |
| 3150 | 3150 | $this->parsingCss->save(); |
| 3151 | 3151 | $this->parsingCss->analyse('qrcode', $param); |
@@ -3156,7 +3156,7 @@ discard block |
||
| 3156 | 3156 | $y = $this->pdf->getY(); |
| 3157 | 3157 | $w = $this->parsingCss->value['width']; |
| 3158 | 3158 | $h = $this->parsingCss->value['height']; |
| 3159 | - $size = max($w, $h); if (!$size) $size = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3159 | + $size = max($w, $h); if ( ! $size) $size = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3160 | 3160 | |
| 3161 | 3161 | $style = array( |
| 3162 | 3162 | 'fgcolor' => $this->parsingCss->value['color'], |
@@ -3171,16 +3171,16 @@ discard block |
||
| 3171 | 3171 | $style['padding'] = 0; |
| 3172 | 3172 | } |
| 3173 | 3173 | |
| 3174 | - if (!$this->_subPart && !$this->_isSubPart) { |
|
| 3174 | + if ( ! $this->_subPart && ! $this->_isSubPart) { |
|
| 3175 | 3175 | $this->pdf->write2DBarcode($param['value'], 'QRCODE,'.$param['ec'], $x, $y, $size, $size, $style); |
| 3176 | 3176 | } |
| 3177 | 3177 | |
| 3178 | - $this->_maxX = max($this->_maxX, $x+$size); |
|
| 3179 | - $this->_maxY = max($this->_maxY, $y+$size); |
|
| 3178 | + $this->_maxX = max($this->_maxX, $x + $size); |
|
| 3179 | + $this->_maxY = max($this->_maxY, $y + $size); |
|
| 3180 | 3180 | $this->_maxH = max($this->_maxH, $size); |
| 3181 | 3181 | $this->_maxE++; |
| 3182 | 3182 | |
| 3183 | - $this->pdf->setX($x+$size); |
|
| 3183 | + $this->pdf->setX($x + $size); |
|
| 3184 | 3184 | |
| 3185 | 3185 | $this->parsingCss->load(); |
| 3186 | 3186 | $this->parsingCss->fontSet(); |
@@ -3214,7 +3214,7 @@ discard block |
||
| 3214 | 3214 | $titre = isset($param['title']) ? trim($param['title']) : ''; |
| 3215 | 3215 | $level = isset($param['level']) ? floor($param['level']) : 0; |
| 3216 | 3216 | |
| 3217 | - if ($level<0) $level = 0; |
|
| 3217 | + if ($level < 0) $level = 0; |
|
| 3218 | 3218 | if ($titre) $this->pdf->Bookmark($titre, $level, -1); |
| 3219 | 3219 | |
| 3220 | 3220 | return true; |
@@ -3242,7 +3242,7 @@ discard block |
||
| 3242 | 3242 | */ |
| 3243 | 3243 | protected function _tag_open_WRITE($param) |
| 3244 | 3244 | { |
| 3245 | - $fill = ($this->parsingCss->value['background']['color']!==null && $this->parsingCss->value['background']['image']===null); |
|
| 3245 | + $fill = ($this->parsingCss->value['background']['color'] !== null && $this->parsingCss->value['background']['image'] === null); |
|
| 3246 | 3246 | if (in_array($this->parsingCss->value['id_tag'], array('fieldset', 'legend', 'div', 'table', 'tr', 'td', 'th'))) { |
| 3247 | 3247 | $fill = false; |
| 3248 | 3248 | } |
@@ -3258,23 +3258,23 @@ discard block |
||
| 3258 | 3258 | $txt = str_replace('[[page_nb]]', $this->pdf->getMyAliasNbPages(), $txt); |
| 3259 | 3259 | $txt = str_replace('[[page_cu]]', $this->pdf->getMyNumPage($this->_page), $txt); |
| 3260 | 3260 | |
| 3261 | - if ($this->parsingCss->value['text-transform']!='none') { |
|
| 3262 | - if ($this->parsingCss->value['text-transform']=='capitalize') |
|
| 3261 | + if ($this->parsingCss->value['text-transform'] != 'none') { |
|
| 3262 | + if ($this->parsingCss->value['text-transform'] == 'capitalize') |
|
| 3263 | 3263 | $txt = ucwords($txt); |
| 3264 | - else if ($this->parsingCss->value['text-transform']=='uppercase') |
|
| 3264 | + else if ($this->parsingCss->value['text-transform'] == 'uppercase') |
|
| 3265 | 3265 | $txt = strtoupper($txt); |
| 3266 | - else if ($this->parsingCss->value['text-transform']=='lowercase') |
|
| 3266 | + else if ($this->parsingCss->value['text-transform'] == 'lowercase') |
|
| 3267 | 3267 | $txt = strtolower($txt); |
| 3268 | 3268 | } |
| 3269 | 3269 | |
| 3270 | 3270 | // size of the text |
| 3271 | - $h = 1.08*$this->parsingCss->value['font-size']; |
|
| 3272 | - $dh = $h*$this->parsingCss->value['mini-decal']; |
|
| 3271 | + $h = 1.08 * $this->parsingCss->value['font-size']; |
|
| 3272 | + $dh = $h * $this->parsingCss->value['mini-decal']; |
|
| 3273 | 3273 | $lh = $this->parsingCss->getLineHeight(); |
| 3274 | 3274 | |
| 3275 | 3275 | // identify the align |
| 3276 | 3276 | $align = 'L'; |
| 3277 | - if ($this->parsingCss->value['text-align']=='li_right') { |
|
| 3277 | + if ($this->parsingCss->value['text-align'] == 'li_right') { |
|
| 3278 | 3278 | $w = $this->parsingCss->value['width']; |
| 3279 | 3279 | $align = 'R'; |
| 3280 | 3280 | } |
@@ -3284,10 +3284,10 @@ discard block |
||
| 3284 | 3284 | $words = explode(' ', $txt); |
| 3285 | 3285 | foreach ($words as $k => $word) { |
| 3286 | 3286 | $words[$k] = array($word, $this->pdf->GetStringWidth($word)); |
| 3287 | - $w+= $words[$k][1]; |
|
| 3287 | + $w += $words[$k][1]; |
|
| 3288 | 3288 | } |
| 3289 | 3289 | $space = $this->pdf->GetStringWidth(' '); |
| 3290 | - $w+= $space*(count($words)-1); |
|
| 3290 | + $w += $space * (count($words) - 1); |
|
| 3291 | 3291 | |
| 3292 | 3292 | // position in the text |
| 3293 | 3293 | $currPos = 0; |
@@ -3307,40 +3307,40 @@ discard block |
||
| 3307 | 3307 | $nb = 0; |
| 3308 | 3308 | |
| 3309 | 3309 | // while we have words, and the text does not fit on the line => we cut the sentence |
| 3310 | - while ($x+$w>$right && $x<$right+$space && count($words)) { |
|
| 3310 | + while ($x + $w > $right && $x < $right + $space && count($words)) { |
|
| 3311 | 3311 | // adding words 1 by 1 to fit on the line |
| 3312 | - $i=0; |
|
| 3312 | + $i = 0; |
|
| 3313 | 3313 | $old = array('', 0); |
| 3314 | 3314 | $str = $words[0]; |
| 3315 | 3315 | $add = false; |
| 3316 | - while (($x+$str[1])<$right) { |
|
| 3316 | + while (($x + $str[1]) < $right) { |
|
| 3317 | 3317 | $i++; |
| 3318 | 3318 | $add = true; |
| 3319 | 3319 | |
| 3320 | 3320 | array_shift($words); |
| 3321 | 3321 | $old = $str; |
| 3322 | 3322 | |
| 3323 | - if (!count($words)) break; |
|
| 3324 | - $str[0].= ' '.$words[0][0]; |
|
| 3325 | - $str[1]+= $space+$words[0][1]; |
|
| 3323 | + if ( ! count($words)) break; |
|
| 3324 | + $str[0] .= ' '.$words[0][0]; |
|
| 3325 | + $str[1] += $space + $words[0][1]; |
|
| 3326 | 3326 | } |
| 3327 | 3327 | $str = $old; |
| 3328 | 3328 | |
| 3329 | 3329 | // 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 |
| 3330 | - if ($i==0 && (($left+$words[0][1])>=$right)) { |
|
| 3330 | + if ($i == 0 && (($left + $words[0][1]) >= $right)) { |
|
| 3331 | 3331 | $str = $words[0]; |
| 3332 | 3332 | array_shift($words); |
| 3333 | 3333 | $i++; |
| 3334 | 3334 | $add = true; |
| 3335 | 3335 | } |
| 3336 | - $currPos+= ($currPos ? 1 : 0)+strlen($str[0]); |
|
| 3336 | + $currPos += ($currPos ? 1 : 0) + strlen($str[0]); |
|
| 3337 | 3337 | |
| 3338 | 3338 | // write the extract sentence that fit on the page |
| 3339 | - $wc = ($align=='L' ? $str[1] : $this->parsingCss->value['width']); |
|
| 3340 | - if ($right - $left<$wc) $wc = $right - $left; |
|
| 3339 | + $wc = ($align == 'L' ? $str[1] : $this->parsingCss->value['width']); |
|
| 3340 | + if ($right - $left < $wc) $wc = $right - $left; |
|
| 3341 | 3341 | |
| 3342 | 3342 | if (strlen($str[0])) { |
| 3343 | - $this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy); |
|
| 3343 | + $this->pdf->setXY($this->pdf->getX(), $y + $dh + $dy); |
|
| 3344 | 3344 | $this->pdf->Cell($wc, $h, $str[0], 0, 0, $align, $fill, $this->_isInLink); |
| 3345 | 3345 | $this->pdf->setXY($this->pdf->getX(), $y); |
| 3346 | 3346 | } |
@@ -3350,7 +3350,7 @@ discard block |
||
| 3350 | 3350 | $maxX = max($maxX, $this->pdf->getX()); |
| 3351 | 3351 | |
| 3352 | 3352 | // new position and new width for the "while" |
| 3353 | - $w-= $str[1]; |
|
| 3353 | + $w -= $str[1]; |
|
| 3354 | 3354 | $y = $this->pdf->getY(); |
| 3355 | 3355 | $x = $this->pdf->getX(); |
| 3356 | 3356 | $dy = $this->_getElementY($lh); |
@@ -3358,16 +3358,16 @@ discard block |
||
| 3358 | 3358 | // if we have again words to write |
| 3359 | 3359 | if (count($words)) { |
| 3360 | 3360 | // remove the space at the end |
| 3361 | - if ($add) $w-= $space; |
|
| 3361 | + if ($add) $w -= $space; |
|
| 3362 | 3362 | |
| 3363 | 3363 | // if we don't add any word, and if the first word is empty => useless space to skip |
| 3364 | - if (!$add && $words[0][0]==='') { |
|
| 3364 | + if ( ! $add && $words[0][0] === '') { |
|
| 3365 | 3365 | array_shift($words); |
| 3366 | 3366 | } |
| 3367 | 3367 | |
| 3368 | 3368 | // if it is just to calculate for one line => adding the number of words |
| 3369 | 3369 | if ($this->_isForOneLine) { |
| 3370 | - $this->_maxE+= $i; |
|
| 3370 | + $this->_maxE += $i; |
|
| 3371 | 3371 | $this->_maxX = max($this->_maxX, $maxX); |
| 3372 | 3372 | return null; |
| 3373 | 3373 | } |
@@ -3381,8 +3381,8 @@ discard block |
||
| 3381 | 3381 | $dy = $this->_getElementY($lh); |
| 3382 | 3382 | |
| 3383 | 3383 | // if the next line does not fit on the page => new page |
| 3384 | - if ($y + $h>=$this->pdf->getH() - $this->pdf->getbMargin()) { |
|
| 3385 | - if (!$this->_isInOverflow && !$this->_isInFooter) { |
|
| 3384 | + if ($y + $h >= $this->pdf->getH() - $this->pdf->getbMargin()) { |
|
| 3385 | + if ( ! $this->_isInOverflow && ! $this->_isInFooter) { |
|
| 3386 | 3386 | $this->_setNewPage(null, '', null, $currPos); |
| 3387 | 3387 | $y = $this->pdf->getY(); |
| 3388 | 3388 | $x = $this->pdf->getX(); |
@@ -3392,9 +3392,9 @@ discard block |
||
| 3392 | 3392 | |
| 3393 | 3393 | // if more than 10000 line => error |
| 3394 | 3394 | $nb++; |
| 3395 | - if ($nb>10000) { |
|
| 3396 | - $txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0]; |
|
| 3397 | - throw new HTML2PDF_exception(2, array($txt, $right-$left, $w)); |
|
| 3395 | + if ($nb > 10000) { |
|
| 3396 | + $txt = ''; foreach ($words as $k => $word) $txt .= ($k ? ' ' : '').$word[0]; |
|
| 3397 | + throw new HTML2PDF_exception(2, array($txt, $right - $left, $w)); |
|
| 3398 | 3398 | } |
| 3399 | 3399 | |
| 3400 | 3400 | // new margins for the new line |
@@ -3404,17 +3404,17 @@ discard block |
||
| 3404 | 3404 | |
| 3405 | 3405 | // if we have words after automatic cut, it is because they fit on the line => we write the text |
| 3406 | 3406 | if (count($words)) { |
| 3407 | - $txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0]; |
|
| 3408 | - $w+= $this->pdf->getWordSpacing()*(count($words)); |
|
| 3409 | - $this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy); |
|
| 3410 | - $this->pdf->Cell(($align=='L' ? $w : $this->parsingCss->value['width']), $h, $txt, 0, 0, $align, $fill, $this->_isInLink); |
|
| 3407 | + $txt = ''; foreach ($words as $k => $word) $txt .= ($k ? ' ' : '').$word[0]; |
|
| 3408 | + $w += $this->pdf->getWordSpacing() * (count($words)); |
|
| 3409 | + $this->pdf->setXY($this->pdf->getX(), $y + $dh + $dy); |
|
| 3410 | + $this->pdf->Cell(($align == 'L' ? $w : $this->parsingCss->value['width']), $h, $txt, 0, 0, $align, $fill, $this->_isInLink); |
|
| 3411 | 3411 | $this->pdf->setXY($this->pdf->getX(), $y); |
| 3412 | 3412 | $this->_maxH = max($this->_maxH, $lh); |
| 3413 | - $this->_maxE+= count($words); |
|
| 3413 | + $this->_maxE += count($words); |
|
| 3414 | 3414 | } |
| 3415 | 3415 | |
| 3416 | 3416 | $maxX = max($maxX, $this->pdf->getX()); |
| 3417 | - $maxY = $this->pdf->getY()+$h; |
|
| 3417 | + $maxY = $this->pdf->getY() + $h; |
|
| 3418 | 3418 | |
| 3419 | 3419 | $this->_maxX = max($this->_maxX, $maxX); |
| 3420 | 3420 | $this->_maxY = max($this->_maxY, $maxY); |
@@ -3436,7 +3436,7 @@ discard block |
||
| 3436 | 3436 | |
| 3437 | 3437 | $h = max($this->_maxH, $this->parsingCss->getLineHeight()); |
| 3438 | 3438 | |
| 3439 | - if ($this->_maxH==0) $this->_maxY = max($this->_maxY, $this->pdf->getY()+$h); |
|
| 3439 | + if ($this->_maxH == 0) $this->_maxY = max($this->_maxY, $this->pdf->getY() + $h); |
|
| 3440 | 3440 | |
| 3441 | 3441 | $this->_makeBreakLine($h, $curr); |
| 3442 | 3442 | |
@@ -3462,21 +3462,21 @@ discard block |
||
| 3462 | 3462 | if ($this->_maxH) $this->_tag_open_BR($param); |
| 3463 | 3463 | |
| 3464 | 3464 | $fontSize = $this->parsingCss->value['font-size']; |
| 3465 | - $this->parsingCss->value['font-size']=$fontSize*0.5; $this->_tag_open_BR($param); |
|
| 3466 | - $this->parsingCss->value['font-size']=0; |
|
| 3465 | + $this->parsingCss->value['font-size'] = $fontSize * 0.5; $this->_tag_open_BR($param); |
|
| 3466 | + $this->parsingCss->value['font-size'] = 0; |
|
| 3467 | 3467 | |
| 3468 | 3468 | $param['style']['width'] = '100%'; |
| 3469 | 3469 | |
| 3470 | 3470 | $this->parsingCss->save(); |
| 3471 | - $this->parsingCss->value['height']=$this->parsingCss->ConvertToMM('1mm'); |
|
| 3471 | + $this->parsingCss->value['height'] = $this->parsingCss->ConvertToMM('1mm'); |
|
| 3472 | 3472 | |
| 3473 | 3473 | $this->parsingCss->analyse('hr', $param); |
| 3474 | 3474 | $this->parsingCss->setPosition(); |
| 3475 | 3475 | $this->parsingCss->fontSet(); |
| 3476 | 3476 | |
| 3477 | 3477 | $h = $this->parsingCss->value['height']; |
| 3478 | - if ($h) $h-= $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width']; |
|
| 3479 | - if ($h<=0) $h = $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width']; |
|
| 3478 | + if ($h) $h -= $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['border']['b']['width']; |
|
| 3479 | + if ($h <= 0) $h = $this->parsingCss->value['border']['t']['width'] + $this->parsingCss->value['border']['b']['width']; |
|
| 3480 | 3480 | |
| 3481 | 3481 | $this->_drawRectangle($this->pdf->getX(), $this->pdf->getY(), $this->parsingCss->value['width'], $h, $this->parsingCss->value['border'], 0, 0, $this->parsingCss->value['background']); |
| 3482 | 3482 | $this->_maxH = $h; |
@@ -3486,8 +3486,8 @@ discard block |
||
| 3486 | 3486 | |
| 3487 | 3487 | $this->_tag_open_BR($param); |
| 3488 | 3488 | |
| 3489 | - $this->parsingCss->value['font-size']=$fontSize*0.5; $this->_tag_open_BR($param); |
|
| 3490 | - $this->parsingCss->value['font-size']=$fontSize; |
|
| 3489 | + $this->parsingCss->value['font-size'] = $fontSize * 0.5; $this->_tag_open_BR($param); |
|
| 3490 | + $this->parsingCss->value['font-size'] = $fontSize; |
|
| 3491 | 3491 | |
| 3492 | 3492 | $this->parsingCss->value['text-align'] = $oldAlign; |
| 3493 | 3493 | $this->_setNewPositionForNewLine(); |
@@ -3749,7 +3749,7 @@ discard block |
||
| 3749 | 3749 | * @param string $other |
| 3750 | 3750 | * @return boolean |
| 3751 | 3751 | */ |
| 3752 | - protected function _tag_open_U($param, $other='u') |
|
| 3752 | + protected function _tag_open_U($param, $other = 'u') |
|
| 3753 | 3753 | { |
| 3754 | 3754 | $this->parsingCss->save(); |
| 3755 | 3755 | $this->parsingCss->value['font-underline'] = true; |
@@ -3811,10 +3811,10 @@ discard block |
||
| 3811 | 3811 | $this->_isInLink = str_replace('&', '&', isset($param['href']) ? $param['href'] : ''); |
| 3812 | 3812 | |
| 3813 | 3813 | if (isset($param['name'])) { |
| 3814 | - $name = $param['name']; |
|
| 3815 | - if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 3814 | + $name = $param['name']; |
|
| 3815 | + if ( ! isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 3816 | 3816 | |
| 3817 | - if (!$this->_lstAnchor[$name][1]) { |
|
| 3817 | + if ( ! $this->_lstAnchor[$name][1]) { |
|
| 3818 | 3818 | $this->_lstAnchor[$name][1] = true; |
| 3819 | 3819 | $this->pdf->SetLink($this->_lstAnchor[$name][0], -1, -1); |
| 3820 | 3820 | } |
@@ -3822,7 +3822,7 @@ discard block |
||
| 3822 | 3822 | |
| 3823 | 3823 | if (preg_match('/^#([^#]+)$/isU', $this->_isInLink, $match)) { |
| 3824 | 3824 | $name = $match[1]; |
| 3825 | - if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 3825 | + if ( ! isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 3826 | 3826 | |
| 3827 | 3827 | $this->_isInLink = $this->_lstAnchor[$name][0]; |
| 3828 | 3828 | } |
@@ -3846,7 +3846,7 @@ discard block |
||
| 3846 | 3846 | */ |
| 3847 | 3847 | protected function _tag_close_A($param) |
| 3848 | 3848 | { |
| 3849 | - $this->_isInLink = ''; |
|
| 3849 | + $this->_isInLink = ''; |
|
| 3850 | 3850 | $this->parsingCss->load(); |
| 3851 | 3851 | $this->parsingCss->fontSet(); |
| 3852 | 3852 | |
@@ -3955,7 +3955,7 @@ discard block |
||
| 3955 | 3955 | { |
| 3956 | 3956 | if ($this->_isForOneLine) return false; |
| 3957 | 3957 | |
| 3958 | - $this->_maxH+= $this->parsingCss->value['margin']['b']; |
|
| 3958 | + $this->_maxH += $this->parsingCss->value['margin']['b']; |
|
| 3959 | 3959 | $h = max($this->_maxH, $this->parsingCss->getLineHeight()); |
| 3960 | 3960 | |
| 3961 | 3961 | $this->parsingCss->load(); |
@@ -4122,7 +4122,7 @@ discard block |
||
| 4122 | 4122 | { |
| 4123 | 4123 | if ($this->_isForOneLine) return false; |
| 4124 | 4124 | |
| 4125 | - if (!in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
|
| 4125 | + if ( ! in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
|
| 4126 | 4126 | if ($this->_maxH) $this->_tag_open_BR(array()); |
| 4127 | 4127 | } |
| 4128 | 4128 | |
@@ -4132,21 +4132,21 @@ discard block |
||
| 4132 | 4132 | $this->parsingCss->fontSet(); |
| 4133 | 4133 | |
| 4134 | 4134 | // cancel the effects of the setPosition |
| 4135 | - $this->pdf->setXY($this->pdf->getX()-$this->parsingCss->value['margin']['l'], $this->pdf->getY()-$this->parsingCss->value['margin']['t']); |
|
| 4135 | + $this->pdf->setXY($this->pdf->getX() - $this->parsingCss->value['margin']['l'], $this->pdf->getY() - $this->parsingCss->value['margin']['t']); |
|
| 4136 | 4136 | |
| 4137 | 4137 | list($mL, $mR) = $this->_getMargins($this->pdf->getY()); |
| 4138 | - $mR = $this->pdf->getW()-$mR; |
|
| 4139 | - $mL+= $this->parsingCss->value['margin']['l']+$this->parsingCss->value['padding']['l']; |
|
| 4140 | - $mR+= $this->parsingCss->value['margin']['r']+$this->parsingCss->value['padding']['r']; |
|
| 4138 | + $mR = $this->pdf->getW() - $mR; |
|
| 4139 | + $mL += $this->parsingCss->value['margin']['l'] + $this->parsingCss->value['padding']['l']; |
|
| 4140 | + $mR += $this->parsingCss->value['margin']['r'] + $this->parsingCss->value['padding']['r']; |
|
| 4141 | 4141 | $this->_saveMargin($mL, 0, $mR); |
| 4142 | 4142 | |
| 4143 | - if ($this->parsingCss->value['text-indent']>0) { |
|
| 4144 | - $y = $this->pdf->getY()+$this->parsingCss->value['margin']['t']+$this->parsingCss->value['padding']['t']; |
|
| 4145 | - $this->_pageMarges[floor($y*100)] = array($mL+$this->parsingCss->value['text-indent'], $this->pdf->getW()-$mR); |
|
| 4146 | - $y+= $this->parsingCss->getLineHeight()*0.1; |
|
| 4147 | - $this->_pageMarges[floor($y*100)] = array($mL, $this->pdf->getW()-$mR); |
|
| 4143 | + if ($this->parsingCss->value['text-indent'] > 0) { |
|
| 4144 | + $y = $this->pdf->getY() + $this->parsingCss->value['margin']['t'] + $this->parsingCss->value['padding']['t']; |
|
| 4145 | + $this->_pageMarges[floor($y * 100)] = array($mL + $this->parsingCss->value['text-indent'], $this->pdf->getW() - $mR); |
|
| 4146 | + $y += $this->parsingCss->getLineHeight() * 0.1; |
|
| 4147 | + $this->_pageMarges[floor($y * 100)] = array($mL, $this->pdf->getW() - $mR); |
|
| 4148 | 4148 | } |
| 4149 | - $this->_makeBreakLine($this->parsingCss->value['margin']['t']+$this->parsingCss->value['padding']['t']); |
|
| 4149 | + $this->_makeBreakLine($this->parsingCss->value['margin']['t'] + $this->parsingCss->value['padding']['t']); |
|
| 4150 | 4150 | $this->_isInParagraph = array($mL, $mR); |
| 4151 | 4151 | return true; |
| 4152 | 4152 | } |
@@ -4165,7 +4165,7 @@ discard block |
||
| 4165 | 4165 | if ($this->_maxH) $this->_tag_open_BR(array()); |
| 4166 | 4166 | $this->_isInParagraph = false; |
| 4167 | 4167 | $this->_loadMargin(); |
| 4168 | - $h = $this->parsingCss->value['margin']['b']+$this->parsingCss->value['padding']['b']; |
|
| 4168 | + $h = $this->parsingCss->value['margin']['b'] + $this->parsingCss->value['padding']['b']; |
|
| 4169 | 4169 | |
| 4170 | 4170 | $this->parsingCss->load(); |
| 4171 | 4171 | $this->parsingCss->fontSet(); |
@@ -4184,7 +4184,7 @@ discard block |
||
| 4184 | 4184 | */ |
| 4185 | 4185 | protected function _tag_open_PRE($param, $other = 'pre') |
| 4186 | 4186 | { |
| 4187 | - if ($other=='pre' && $this->_maxH) $this->_tag_open_BR(array()); |
|
| 4187 | + if ($other == 'pre' && $this->_maxH) $this->_tag_open_BR(array()); |
|
| 4188 | 4188 | |
| 4189 | 4189 | $this->parsingCss->save(); |
| 4190 | 4190 | $this->parsingCss->value['font-family'] = 'courier'; |
@@ -4192,7 +4192,7 @@ discard block |
||
| 4192 | 4192 | $this->parsingCss->setPosition(); |
| 4193 | 4193 | $this->parsingCss->fontSet(); |
| 4194 | 4194 | |
| 4195 | - if ($other=='pre') return $this->_tag_open_DIV($param, $other); |
|
| 4195 | + if ($other == 'pre') return $this->_tag_open_DIV($param, $other); |
|
| 4196 | 4196 | |
| 4197 | 4197 | return true; |
| 4198 | 4198 | } |
@@ -4220,7 +4220,7 @@ discard block |
||
| 4220 | 4220 | */ |
| 4221 | 4221 | protected function _tag_close_PRE($param, $other = 'pre') |
| 4222 | 4222 | { |
| 4223 | - if ($other=='pre') { |
|
| 4223 | + if ($other == 'pre') { |
|
| 4224 | 4224 | if ($this->_isForOneLine) return false; |
| 4225 | 4225 | |
| 4226 | 4226 | $this->_tag_close_DIV($param, $other); |
@@ -4254,7 +4254,7 @@ discard block |
||
| 4254 | 4254 | protected function _tag_open_BIG($param) |
| 4255 | 4255 | { |
| 4256 | 4256 | $this->parsingCss->save(); |
| 4257 | - $this->parsingCss->value['mini-decal']-= $this->parsingCss->value['mini-size']*0.12; |
|
| 4257 | + $this->parsingCss->value['mini-decal'] -= $this->parsingCss->value['mini-size'] * 0.12; |
|
| 4258 | 4258 | $this->parsingCss->value['mini-size'] *= 1.2; |
| 4259 | 4259 | $this->parsingCss->analyse('big', $param); |
| 4260 | 4260 | $this->parsingCss->setPosition(); |
@@ -4287,7 +4287,7 @@ discard block |
||
| 4287 | 4287 | protected function _tag_open_SMALL($param) |
| 4288 | 4288 | { |
| 4289 | 4289 | $this->parsingCss->save(); |
| 4290 | - $this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.05; |
|
| 4290 | + $this->parsingCss->value['mini-decal'] += $this->parsingCss->value['mini-size'] * 0.05; |
|
| 4291 | 4291 | $this->parsingCss->value['mini-size'] *= 0.82; |
| 4292 | 4292 | $this->parsingCss->analyse('small', $param); |
| 4293 | 4293 | $this->parsingCss->setPosition(); |
@@ -4320,7 +4320,7 @@ discard block |
||
| 4320 | 4320 | protected function _tag_open_SUP($param) |
| 4321 | 4321 | { |
| 4322 | 4322 | $this->parsingCss->save(); |
| 4323 | - $this->parsingCss->value['mini-decal']-= $this->parsingCss->value['mini-size']*0.15; |
|
| 4323 | + $this->parsingCss->value['mini-decal'] -= $this->parsingCss->value['mini-size'] * 0.15; |
|
| 4324 | 4324 | $this->parsingCss->value['mini-size'] *= 0.75; |
| 4325 | 4325 | $this->parsingCss->analyse('sup', $param); |
| 4326 | 4326 | $this->parsingCss->setPosition(); |
@@ -4354,7 +4354,7 @@ discard block |
||
| 4354 | 4354 | protected function _tag_open_SUB($param) |
| 4355 | 4355 | { |
| 4356 | 4356 | $this->parsingCss->save(); |
| 4357 | - $this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.15; |
|
| 4357 | + $this->parsingCss->value['mini-decal'] += $this->parsingCss->value['mini-size'] * 0.15; |
|
| 4358 | 4358 | $this->parsingCss->value['mini-size'] *= 0.75; |
| 4359 | 4359 | $this->parsingCss->analyse('sub', $param); |
| 4360 | 4360 | $this->parsingCss->setPosition(); |
@@ -4389,12 +4389,12 @@ discard block |
||
| 4389 | 4389 | { |
| 4390 | 4390 | if ($this->_isForOneLine) return false; |
| 4391 | 4391 | |
| 4392 | - if (!in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
|
| 4392 | + if ( ! in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
|
| 4393 | 4393 | if ($this->_maxH) $this->_tag_open_BR(array()); |
| 4394 | - if (!count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4394 | + if ( ! count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4395 | 4395 | } |
| 4396 | 4396 | |
| 4397 | - if (!isset($param['style']['width'])) $param['allwidth'] = true; |
|
| 4397 | + if ( ! isset($param['style']['width'])) $param['allwidth'] = true; |
|
| 4398 | 4398 | $param['cellspacing'] = 0; |
| 4399 | 4399 | |
| 4400 | 4400 | // a list is like a table |
@@ -4433,8 +4433,8 @@ discard block |
||
| 4433 | 4433 | |
| 4434 | 4434 | $this->_listeDelLevel(); |
| 4435 | 4435 | |
| 4436 | - if (!$this->_subPart) { |
|
| 4437 | - if (!count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4436 | + if ( ! $this->_subPart) { |
|
| 4437 | + if ( ! count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4438 | 4438 | } |
| 4439 | 4439 | |
| 4440 | 4440 | return true; |
@@ -4465,7 +4465,7 @@ discard block |
||
| 4465 | 4465 | |
| 4466 | 4466 | $this->_listeAddLi(); |
| 4467 | 4467 | |
| 4468 | - if (!isset($param['style']['width'])) $param['style']['width'] = '100%'; |
|
| 4468 | + if ( ! isset($param['style']['width'])) $param['style']['width'] = '100%'; |
|
| 4469 | 4469 | |
| 4470 | 4470 | $paramPUCE = $param; |
| 4471 | 4471 | |
@@ -4492,7 +4492,7 @@ discard block |
||
| 4492 | 4492 | |
| 4493 | 4493 | // if small LI |
| 4494 | 4494 | if ($inf[1]) { |
| 4495 | - $this->parsingCss->value['mini-decal']+= $this->parsingCss->value['mini-size']*0.045; |
|
| 4495 | + $this->parsingCss->value['mini-decal'] += $this->parsingCss->value['mini-size'] * 0.045; |
|
| 4496 | 4496 | $this->parsingCss->value['mini-size'] *= 0.75; |
| 4497 | 4497 | } |
| 4498 | 4498 | |
@@ -4500,21 +4500,21 @@ discard block |
||
| 4500 | 4500 | if ($this->_subPart) { |
| 4501 | 4501 | // TD for the puce |
| 4502 | 4502 | $tmpPos = $this->_tempPos; |
| 4503 | - $tmpLst1 = $this->parsingHtml->code[$tmpPos+1]; |
|
| 4504 | - $tmpLst2 = $this->parsingHtml->code[$tmpPos+2]; |
|
| 4505 | - $this->parsingHtml->code[$tmpPos+1] = array(); |
|
| 4506 | - $this->parsingHtml->code[$tmpPos+1]['name'] = (isset($paramPUCE['src'])) ? 'img' : 'write'; |
|
| 4507 | - $this->parsingHtml->code[$tmpPos+1]['param'] = $paramPUCE; unset($this->parsingHtml->code[$tmpPos+1]['param']['style']['width']); |
|
| 4508 | - $this->parsingHtml->code[$tmpPos+1]['close'] = 0; |
|
| 4509 | - $this->parsingHtml->code[$tmpPos+2] = array(); |
|
| 4510 | - $this->parsingHtml->code[$tmpPos+2]['name'] = 'li'; |
|
| 4511 | - $this->parsingHtml->code[$tmpPos+2]['param'] = $paramPUCE; |
|
| 4512 | - $this->parsingHtml->code[$tmpPos+2]['close'] = 1; |
|
| 4503 | + $tmpLst1 = $this->parsingHtml->code[$tmpPos + 1]; |
|
| 4504 | + $tmpLst2 = $this->parsingHtml->code[$tmpPos + 2]; |
|
| 4505 | + $this->parsingHtml->code[$tmpPos + 1] = array(); |
|
| 4506 | + $this->parsingHtml->code[$tmpPos + 1]['name'] = (isset($paramPUCE['src'])) ? 'img' : 'write'; |
|
| 4507 | + $this->parsingHtml->code[$tmpPos + 1]['param'] = $paramPUCE; unset($this->parsingHtml->code[$tmpPos + 1]['param']['style']['width']); |
|
| 4508 | + $this->parsingHtml->code[$tmpPos + 1]['close'] = 0; |
|
| 4509 | + $this->parsingHtml->code[$tmpPos + 2] = array(); |
|
| 4510 | + $this->parsingHtml->code[$tmpPos + 2]['name'] = 'li'; |
|
| 4511 | + $this->parsingHtml->code[$tmpPos + 2]['param'] = $paramPUCE; |
|
| 4512 | + $this->parsingHtml->code[$tmpPos + 2]['close'] = 1; |
|
| 4513 | 4513 | $this->_tag_open_TD($paramPUCE, 'li_sub'); |
| 4514 | 4514 | $this->_tag_close_TD($param); |
| 4515 | 4515 | $this->_tempPos = $tmpPos; |
| 4516 | - $this->parsingHtml->code[$tmpPos+1] = $tmpLst1; |
|
| 4517 | - $this->parsingHtml->code[$tmpPos+2] = $tmpLst2; |
|
| 4516 | + $this->parsingHtml->code[$tmpPos + 1] = $tmpLst1; |
|
| 4517 | + $this->parsingHtml->code[$tmpPos + 2] = $tmpLst2; |
|
| 4518 | 4518 | } else { |
| 4519 | 4519 | // TD for the puce |
| 4520 | 4520 | $this->_tag_open_TD($paramPUCE, 'li_sub'); |
@@ -4606,16 +4606,16 @@ discard block |
||
| 4606 | 4606 | if ($this->_subPart) { |
| 4607 | 4607 | HTML2PDF::$_tables[$param['num']]['thead']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
| 4608 | 4608 | HTML2PDF::$_tables[$param['num']]['thead']['code'] = array(); |
| 4609 | - for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) { |
|
| 4609 | + for ($pos = $this->_tempPos; $pos < count($this->parsingHtml->code); $pos++) { |
|
| 4610 | 4610 | $action = $this->parsingHtml->code[$pos]; |
| 4611 | - if (strtolower($action['name'])=='thead') $action['name'] = 'thead_sub'; |
|
| 4611 | + if (strtolower($action['name']) == 'thead') $action['name'] = 'thead_sub'; |
|
| 4612 | 4612 | HTML2PDF::$_tables[$param['num']]['thead']['code'][] = $action; |
| 4613 | - if (strtolower($action['name'])=='thead_sub' && $action['close']) break; |
|
| 4613 | + if (strtolower($action['name']) == 'thead_sub' && $action['close']) break; |
|
| 4614 | 4614 | } |
| 4615 | 4615 | } else { |
| 4616 | 4616 | $level = $this->parsingHtml->getLevel($this->_parsePos); |
| 4617 | - $this->_parsePos+= count($level); |
|
| 4618 | - HTML2PDF::$_tables[$param['num']]['tr_curr']+= count(HTML2PDF::$_tables[$param['num']]['thead']['tr']); |
|
| 4617 | + $this->_parsePos += count($level); |
|
| 4618 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] += count(HTML2PDF::$_tables[$param['num']]['thead']['tr']); |
|
| 4619 | 4619 | } |
| 4620 | 4620 | |
| 4621 | 4621 | return true; |
@@ -4638,7 +4638,7 @@ discard block |
||
| 4638 | 4638 | // if we are in a sub HTM, construct the list of the TR in the thead |
| 4639 | 4639 | if ($this->_subPart) { |
| 4640 | 4640 | $min = HTML2PDF::$_tables[$param['num']]['thead']['tr'][0]; |
| 4641 | - $max = HTML2PDF::$_tables[$param['num']]['tr_curr']-1; |
|
| 4641 | + $max = HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1; |
|
| 4642 | 4642 | HTML2PDF::$_tables[$param['num']]['thead']['tr'] = range($min, $max); |
| 4643 | 4643 | } |
| 4644 | 4644 | |
@@ -4665,16 +4665,16 @@ discard block |
||
| 4665 | 4665 | if ($this->_subPart) { |
| 4666 | 4666 | HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0] = HTML2PDF::$_tables[$param['num']]['tr_curr']; |
| 4667 | 4667 | HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array(); |
| 4668 | - for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) { |
|
| 4668 | + for ($pos = $this->_tempPos; $pos < count($this->parsingHtml->code); $pos++) { |
|
| 4669 | 4669 | $action = $this->parsingHtml->code[$pos]; |
| 4670 | - if (strtolower($action['name'])=='tfoot') $action['name'] = 'tfoot_sub'; |
|
| 4670 | + if (strtolower($action['name']) == 'tfoot') $action['name'] = 'tfoot_sub'; |
|
| 4671 | 4671 | HTML2PDF::$_tables[$param['num']]['tfoot']['code'][] = $action; |
| 4672 | - if (strtolower($action['name'])=='tfoot_sub' && $action['close']) break; |
|
| 4672 | + if (strtolower($action['name']) == 'tfoot_sub' && $action['close']) break; |
|
| 4673 | 4673 | } |
| 4674 | 4674 | } else { |
| 4675 | 4675 | $level = $this->parsingHtml->getLevel($this->_parsePos); |
| 4676 | - $this->_parsePos+= count($level); |
|
| 4677 | - HTML2PDF::$_tables[$param['num']]['tr_curr']+= count(HTML2PDF::$_tables[$param['num']]['tfoot']['tr']); |
|
| 4676 | + $this->_parsePos += count($level); |
|
| 4677 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] += count(HTML2PDF::$_tables[$param['num']]['tfoot']['tr']); |
|
| 4678 | 4678 | } |
| 4679 | 4679 | |
| 4680 | 4680 | return true; |
@@ -4697,7 +4697,7 @@ discard block |
||
| 4697 | 4697 | // if we are in a sub HTM, construct the list of the TR in the tfoot |
| 4698 | 4698 | if ($this->_subPart) { |
| 4699 | 4699 | $min = HTML2PDF::$_tables[$param['num']]['tfoot']['tr'][0]; |
| 4700 | - $max = HTML2PDF::$_tables[$param['num']]['tr_curr']-1; |
|
| 4700 | + $max = HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1; |
|
| 4701 | 4701 | HTML2PDF::$_tables[$param['num']]['tfoot']['tr'] = range($min, $max); |
| 4702 | 4702 | } |
| 4703 | 4703 | |
@@ -4839,7 +4839,7 @@ discard block |
||
| 4839 | 4839 | |
| 4840 | 4840 | $alignObject = isset($param['align']) ? strtolower($param['align']) : 'left'; |
| 4841 | 4841 | if (isset($param['align'])) unset($param['align']); |
| 4842 | - if (!in_array($alignObject, array('left', 'center', 'right'))) $alignObject = 'left'; |
|
| 4842 | + if ( ! in_array($alignObject, array('left', 'center', 'right'))) $alignObject = 'left'; |
|
| 4843 | 4843 | |
| 4844 | 4844 | $this->parsingCss->save(); |
| 4845 | 4845 | $this->parsingCss->analyse($other, $param); |
@@ -4850,7 +4850,7 @@ discard block |
||
| 4850 | 4850 | |
| 4851 | 4851 | // collapse table ? |
| 4852 | 4852 | $collapse = false; |
| 4853 | - if ($other=='table') { |
|
| 4853 | + if ($other == 'table') { |
|
| 4854 | 4854 | $collapse = isset($this->parsingCss->value['border']['collapse']) ? $this->parsingCss->value['border']['collapse'] : false; |
| 4855 | 4855 | } |
| 4856 | 4856 | |
@@ -4872,45 +4872,45 @@ discard block |
||
| 4872 | 4872 | HTML2PDF::$_tables[$param['num']]['border'] = isset($param['border']) ? $this->parsingCss->readBorder($param['border']) : null; |
| 4873 | 4873 | HTML2PDF::$_tables[$param['num']]['cellpadding'] = $this->parsingCss->ConvertToMM(isset($param['cellpadding']) ? $param['cellpadding'] : '1px'); |
| 4874 | 4874 | HTML2PDF::$_tables[$param['num']]['cellspacing'] = $this->parsingCss->ConvertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px'); |
| 4875 | - HTML2PDF::$_tables[$param['num']]['cases'] = array(); // properties of each TR/TD |
|
| 4876 | - HTML2PDF::$_tables[$param['num']]['corr'] = array(); // link between TR/TD and colspan/rowspan |
|
| 4877 | - HTML2PDF::$_tables[$param['num']]['corr_x'] = 0; // position in 'cases' |
|
| 4878 | - HTML2PDF::$_tables[$param['num']]['corr_y'] = 0; // position in 'cases' |
|
| 4879 | - HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; // current column |
|
| 4880 | - HTML2PDF::$_tables[$param['num']]['tr_curr'] = 0; // current row |
|
| 4875 | + HTML2PDF::$_tables[$param['num']]['cases'] = array(); // properties of each TR/TD |
|
| 4876 | + HTML2PDF::$_tables[$param['num']]['corr'] = array(); // link between TR/TD and colspan/rowspan |
|
| 4877 | + HTML2PDF::$_tables[$param['num']]['corr_x'] = 0; // position in 'cases' |
|
| 4878 | + HTML2PDF::$_tables[$param['num']]['corr_y'] = 0; // position in 'cases' |
|
| 4879 | + HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; // current column |
|
| 4880 | + HTML2PDF::$_tables[$param['num']]['tr_curr'] = 0; // current row |
|
| 4881 | 4881 | HTML2PDF::$_tables[$param['num']]['curr_x'] = $this->pdf->getX(); |
| 4882 | 4882 | HTML2PDF::$_tables[$param['num']]['curr_y'] = $this->pdf->getY(); |
| 4883 | - HTML2PDF::$_tables[$param['num']]['width'] = 0; // global width |
|
| 4884 | - HTML2PDF::$_tables[$param['num']]['height'] = 0; // global height |
|
| 4883 | + HTML2PDF::$_tables[$param['num']]['width'] = 0; // global width |
|
| 4884 | + HTML2PDF::$_tables[$param['num']]['height'] = 0; // global height |
|
| 4885 | 4885 | HTML2PDF::$_tables[$param['num']]['align'] = $alignObject; |
| 4886 | 4886 | HTML2PDF::$_tables[$param['num']]['marge'] = array(); |
| 4887 | - HTML2PDF::$_tables[$param['num']]['marge']['t'] = $this->parsingCss->value['padding']['t']+$this->parsingCss->value['border']['t']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5; |
|
| 4888 | - HTML2PDF::$_tables[$param['num']]['marge']['r'] = $this->parsingCss->value['padding']['r']+$this->parsingCss->value['border']['r']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5; |
|
| 4889 | - HTML2PDF::$_tables[$param['num']]['marge']['b'] = $this->parsingCss->value['padding']['b']+$this->parsingCss->value['border']['b']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5; |
|
| 4890 | - HTML2PDF::$_tables[$param['num']]['marge']['l'] = $this->parsingCss->value['padding']['l']+$this->parsingCss->value['border']['l']['width']+HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5; |
|
| 4891 | - HTML2PDF::$_tables[$param['num']]['page'] = 0; // number of pages |
|
| 4892 | - HTML2PDF::$_tables[$param['num']]['new_page'] = true; // flag : new page for the current TR |
|
| 4893 | - HTML2PDF::$_tables[$param['num']]['style_value'] = null; // CSS style of the table |
|
| 4894 | - HTML2PDF::$_tables[$param['num']]['thead'] = array(); // properties on the thead |
|
| 4895 | - HTML2PDF::$_tables[$param['num']]['tfoot'] = array(); // properties on the tfoot |
|
| 4896 | - HTML2PDF::$_tables[$param['num']]['thead']['tr'] = array(); // list of the TRs in the thead |
|
| 4897 | - HTML2PDF::$_tables[$param['num']]['tfoot']['tr'] = array(); // list of the TRs in the tfoot |
|
| 4898 | - HTML2PDF::$_tables[$param['num']]['thead']['height'] = 0; // thead height |
|
| 4899 | - HTML2PDF::$_tables[$param['num']]['tfoot']['height'] = 0; // tfoot height |
|
| 4900 | - HTML2PDF::$_tables[$param['num']]['thead']['code'] = array(); // HTML content of the thead |
|
| 4901 | - HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array(); // HTML content of the tfoot |
|
| 4902 | - HTML2PDF::$_tables[$param['num']]['cols'] = array(); // properties of the COLs |
|
| 4887 | + HTML2PDF::$_tables[$param['num']]['marge']['t'] = $this->parsingCss->value['padding']['t'] + $this->parsingCss->value['border']['t']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5; |
|
| 4888 | + HTML2PDF::$_tables[$param['num']]['marge']['r'] = $this->parsingCss->value['padding']['r'] + $this->parsingCss->value['border']['r']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5; |
|
| 4889 | + HTML2PDF::$_tables[$param['num']]['marge']['b'] = $this->parsingCss->value['padding']['b'] + $this->parsingCss->value['border']['b']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5; |
|
| 4890 | + HTML2PDF::$_tables[$param['num']]['marge']['l'] = $this->parsingCss->value['padding']['l'] + $this->parsingCss->value['border']['l']['width'] + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5; |
|
| 4891 | + HTML2PDF::$_tables[$param['num']]['page'] = 0; // number of pages |
|
| 4892 | + HTML2PDF::$_tables[$param['num']]['new_page'] = true; // flag : new page for the current TR |
|
| 4893 | + HTML2PDF::$_tables[$param['num']]['style_value'] = null; // CSS style of the table |
|
| 4894 | + HTML2PDF::$_tables[$param['num']]['thead'] = array(); // properties on the thead |
|
| 4895 | + HTML2PDF::$_tables[$param['num']]['tfoot'] = array(); // properties on the tfoot |
|
| 4896 | + HTML2PDF::$_tables[$param['num']]['thead']['tr'] = array(); // list of the TRs in the thead |
|
| 4897 | + HTML2PDF::$_tables[$param['num']]['tfoot']['tr'] = array(); // list of the TRs in the tfoot |
|
| 4898 | + HTML2PDF::$_tables[$param['num']]['thead']['height'] = 0; // thead height |
|
| 4899 | + HTML2PDF::$_tables[$param['num']]['tfoot']['height'] = 0; // tfoot height |
|
| 4900 | + HTML2PDF::$_tables[$param['num']]['thead']['code'] = array(); // HTML content of the thead |
|
| 4901 | + HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array(); // HTML content of the tfoot |
|
| 4902 | + HTML2PDF::$_tables[$param['num']]['cols'] = array(); // properties of the COLs |
|
| 4903 | 4903 | |
| 4904 | 4904 | $this->_saveMargin($this->pdf->getlMargin(), $this->pdf->gettMargin(), $this->pdf->getrMargin()); |
| 4905 | 4905 | |
| 4906 | - $this->parsingCss->value['width']-= HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r']; |
|
| 4906 | + $this->parsingCss->value['width'] -= HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r']; |
|
| 4907 | 4907 | } else { |
| 4908 | 4908 | // we start from the first page and the first page of the table |
| 4909 | 4909 | HTML2PDF::$_tables[$param['num']]['page'] = 0; |
| 4910 | 4910 | HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
| 4911 | 4911 | HTML2PDF::$_tables[$param['num']]['tr_curr'] = 0; |
| 4912 | - HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['marge']['l']+HTML2PDF::$_tables[$param['num']]['curr_x']; |
|
| 4913 | - HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['marge']['t']+HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 4912 | + HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['curr_x']; |
|
| 4913 | + HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['marge']['t'] + HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 4914 | 4914 | |
| 4915 | 4915 | // draw the borders/background of the first page/part of the table |
| 4916 | 4916 | $this->_drawRectangle( |
@@ -4955,10 +4955,10 @@ discard block |
||
| 4955 | 4955 | foreach (HTML2PDF::$_tables[$param['num']][$mode]['tr'] as $tr) { |
| 4956 | 4956 | // hauteur de la ligne tr |
| 4957 | 4957 | $h = 0; |
| 4958 | - for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++) |
|
| 4959 | - if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan']==1) |
|
| 4958 | + for ($i = 0; $i < count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++) |
|
| 4959 | + if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan'] == 1) |
|
| 4960 | 4960 | $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['h']); |
| 4961 | - HTML2PDF::$_tables[$param['num']][$mode]['height']+= $h; |
|
| 4961 | + HTML2PDF::$_tables[$param['num']][$mode]['height'] += $h; |
|
| 4962 | 4962 | } |
| 4963 | 4963 | } |
| 4964 | 4964 | |
@@ -4966,7 +4966,7 @@ discard block |
||
| 4966 | 4966 | HTML2PDF::$_tables[$param['num']]['width'] = HTML2PDF::$_tables[$param['num']]['marge']['l'] + HTML2PDF::$_tables[$param['num']]['marge']['r']; |
| 4967 | 4967 | if (isset(HTML2PDF::$_tables[$param['num']]['cases'][0])) { |
| 4968 | 4968 | foreach (HTML2PDF::$_tables[$param['num']]['cases'][0] as $case) { |
| 4969 | - HTML2PDF::$_tables[$param['num']]['width']+= $case['w']; |
|
| 4969 | + HTML2PDF::$_tables[$param['num']]['width'] += $case['w']; |
|
| 4970 | 4970 | } |
| 4971 | 4971 | } |
| 4972 | 4972 | |
@@ -4975,11 +4975,11 @@ discard block |
||
| 4975 | 4975 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 4976 | 4976 | $x = HTML2PDF::$_tables[$param['num']]['curr_x']; |
| 4977 | 4977 | $w = HTML2PDF::$_tables[$param['num']]['width']; |
| 4978 | - if ($parentWidth>$w) { |
|
| 4979 | - if (HTML2PDF::$_tables[$param['num']]['align']=='center') |
|
| 4980 | - $x = $x + ($parentWidth-$w)*0.5; |
|
| 4981 | - else if (HTML2PDF::$_tables[$param['num']]['align']=='right') |
|
| 4982 | - $x = $x + $parentWidth-$w; |
|
| 4978 | + if ($parentWidth > $w) { |
|
| 4979 | + if (HTML2PDF::$_tables[$param['num']]['align'] == 'center') |
|
| 4980 | + $x = $x + ($parentWidth - $w) * 0.5; |
|
| 4981 | + else if (HTML2PDF::$_tables[$param['num']]['align'] == 'right') |
|
| 4982 | + $x = $x + $parentWidth - $w; |
|
| 4983 | 4983 | |
| 4984 | 4984 | HTML2PDF::$_tables[$param['num']]['curr_x'] = $x; |
| 4985 | 4985 | } |
@@ -4989,7 +4989,7 @@ discard block |
||
| 4989 | 4989 | |
| 4990 | 4990 | // minimum of the height because of margins, and of the thead and tfoot height |
| 4991 | 4991 | $h0 = HTML2PDF::$_tables[$param['num']]['marge']['t'] + HTML2PDF::$_tables[$param['num']]['marge']['b']; |
| 4992 | - $h0+= HTML2PDF::$_tables[$param['num']]['thead']['height'] + HTML2PDF::$_tables[$param['num']]['tfoot']['height']; |
|
| 4992 | + $h0 += HTML2PDF::$_tables[$param['num']]['thead']['height'] + HTML2PDF::$_tables[$param['num']]['tfoot']['height']; |
|
| 4993 | 4993 | |
| 4994 | 4994 | // max height of the page |
| 4995 | 4995 | $max = $this->pdf->getH() - $this->pdf->getbMargin(); |
@@ -4999,7 +4999,7 @@ discard block |
||
| 4999 | 4999 | $height = $h0; |
| 5000 | 5000 | |
| 5001 | 5001 | // we get the height of each line |
| 5002 | - for ($k=0; $k<count(HTML2PDF::$_tables[$param['num']]['cases']); $k++) { |
|
| 5002 | + for ($k = 0; $k < count(HTML2PDF::$_tables[$param['num']]['cases']); $k++) { |
|
| 5003 | 5003 | |
| 5004 | 5004 | // if it is a TR of the thead or of the tfoot => skip |
| 5005 | 5005 | if (in_array($k, HTML2PDF::$_tables[$param['num']]['thead']['tr'])) continue; |
@@ -5008,25 +5008,25 @@ discard block |
||
| 5008 | 5008 | // height of the line |
| 5009 | 5009 | $th = 0; |
| 5010 | 5010 | $h = 0; |
| 5011 | - for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$k]); $i++) { |
|
| 5011 | + for ($i = 0; $i < count(HTML2PDF::$_tables[$param['num']]['cases'][$k]); $i++) { |
|
| 5012 | 5012 | $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
| 5013 | 5013 | |
| 5014 | - if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan']==1) |
|
| 5014 | + if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan'] == 1) |
|
| 5015 | 5015 | $th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
| 5016 | 5016 | } |
| 5017 | 5017 | |
| 5018 | 5018 | // if the row does not fit on the page => new page |
| 5019 | - if ($y+$h+$height>$max) { |
|
| 5020 | - if ($height==$h0) $height = null; |
|
| 5019 | + if ($y + $h + $height > $max) { |
|
| 5020 | + if ($height == $h0) $height = null; |
|
| 5021 | 5021 | HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
| 5022 | 5022 | $height = $h0; |
| 5023 | 5023 | $y = $this->_margeTop; |
| 5024 | 5024 | } |
| 5025 | - $height+= $th; |
|
| 5025 | + $height += $th; |
|
| 5026 | 5026 | } |
| 5027 | 5027 | |
| 5028 | 5028 | // if ther is a height at the end, add it |
| 5029 | - if ($height!=$h0 || $k==0) HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
|
| 5029 | + if ($height != $h0 || $k == 0) HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
|
| 5030 | 5030 | } else { |
| 5031 | 5031 | // if we have tfoor, draw it |
| 5032 | 5032 | if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) { |
@@ -5043,7 +5043,7 @@ discard block |
||
| 5043 | 5043 | $this->_makeHTMLcode(); |
| 5044 | 5044 | $this->_isInTfoot = false; |
| 5045 | 5045 | |
| 5046 | - $this->_parsePos = $oldParsePos; |
|
| 5046 | + $this->_parsePos = $oldParsePos; |
|
| 5047 | 5047 | $this->parsingHtml->code = $oldParseCode; |
| 5048 | 5048 | HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR; |
| 5049 | 5049 | HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD; |
@@ -5051,10 +5051,10 @@ discard block |
||
| 5051 | 5051 | |
| 5052 | 5052 | // get the positions of the end of the table |
| 5053 | 5053 | $x = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['width']; |
| 5054 | - if (count(HTML2PDF::$_tables[$param['num']]['height'])>1) |
|
| 5055 | - $y = $this->_margeTop+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1]; |
|
| 5056 | - else if (count(HTML2PDF::$_tables[$param['num']]['height'])==1) |
|
| 5057 | - $y = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1]; |
|
| 5054 | + if (count(HTML2PDF::$_tables[$param['num']]['height']) > 1) |
|
| 5055 | + $y = $this->_margeTop + HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height']) - 1]; |
|
| 5056 | + else if (count(HTML2PDF::$_tables[$param['num']]['height']) == 1) |
|
| 5057 | + $y = HTML2PDF::$_tables[$param['num']]['curr_y'] + HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height']) - 1]; |
|
| 5058 | 5058 | else |
| 5059 | 5059 | $y = HTML2PDF::$_tables[$param['num']]['curr_y']; |
| 5060 | 5060 | |
@@ -5085,7 +5085,7 @@ discard block |
||
| 5085 | 5085 | protected function _tag_open_COL($param) |
| 5086 | 5086 | { |
| 5087 | 5087 | $span = isset($param['span']) ? $param['span'] : 1; |
| 5088 | - for ($k=0; $k<$span; $k++) |
|
| 5088 | + for ($k = 0; $k < $span; $k++) |
|
| 5089 | 5089 | HTML2PDF::$_tables[$param['num']]['cols'][] = $param; |
| 5090 | 5090 | } |
| 5091 | 5091 | |
@@ -5123,22 +5123,22 @@ discard block |
||
| 5123 | 5123 | |
| 5124 | 5124 | // position in the table |
| 5125 | 5125 | HTML2PDF::$_tables[$param['num']]['tr_curr']++; |
| 5126 | - HTML2PDF::$_tables[$param['num']]['td_curr']= 0; |
|
| 5126 | + HTML2PDF::$_tables[$param['num']]['td_curr'] = 0; |
|
| 5127 | 5127 | |
| 5128 | 5128 | // if we are not in a sub html |
| 5129 | - if (!$this->_subPart) { |
|
| 5129 | + if ( ! $this->_subPart) { |
|
| 5130 | 5130 | |
| 5131 | 5131 | // Y after the row |
| 5132 | - $ty=null; |
|
| 5133 | - for ($ii=0; $ii<count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1]); $ii++) { |
|
| 5134 | - $ty = max($ty, HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['h']); |
|
| 5132 | + $ty = null; |
|
| 5133 | + for ($ii = 0; $ii < count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1]); $ii++) { |
|
| 5134 | + $ty = max($ty, HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][$ii]['h']); |
|
| 5135 | 5135 | } |
| 5136 | 5136 | |
| 5137 | 5137 | // height of the tfoot |
| 5138 | 5138 | $hfoot = HTML2PDF::$_tables[$param['num']]['tfoot']['height']; |
| 5139 | 5139 | |
| 5140 | 5140 | // if the line does not fit on the page => new page |
| 5141 | - if (!$this->_isInTfoot && HTML2PDF::$_tables[$param['num']]['td_y'] + HTML2PDF::$_tables[$param['num']]['marge']['b'] + $ty +$hfoot> $this->pdf->getH() - $this->pdf->getbMargin()) { |
|
| 5141 | + if ( ! $this->_isInTfoot && HTML2PDF::$_tables[$param['num']]['td_y'] + HTML2PDF::$_tables[$param['num']]['marge']['b'] + $ty + $hfoot > $this->pdf->getH() - $this->pdf->getbMargin()) { |
|
| 5142 | 5142 | |
| 5143 | 5143 | // fi ther is a tfoot => draw it |
| 5144 | 5144 | if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) { |
@@ -5155,7 +5155,7 @@ discard block |
||
| 5155 | 5155 | $this->_makeHTMLcode(); |
| 5156 | 5156 | $this->_isInTfoot = false; |
| 5157 | 5157 | |
| 5158 | - $this->_parsePos = $oldParsePos; |
|
| 5158 | + $this->_parsePos = $oldParsePos; |
|
| 5159 | 5159 | $this->parsingHtml->code = $oldParseCode; |
| 5160 | 5160 | HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR; |
| 5161 | 5161 | HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD; |
@@ -5168,7 +5168,7 @@ discard block |
||
| 5168 | 5168 | // new position |
| 5169 | 5169 | HTML2PDF::$_tables[$param['num']]['page']++; |
| 5170 | 5170 | HTML2PDF::$_tables[$param['num']]['curr_y'] = $this->pdf->getY(); |
| 5171 | - HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['marge']['t']; |
|
| 5171 | + HTML2PDF::$_tables[$param['num']]['td_y'] = HTML2PDF::$_tables[$param['num']]['curr_y'] + HTML2PDF::$_tables[$param['num']]['marge']['t']; |
|
| 5172 | 5172 | |
| 5173 | 5173 | // if we have the height of the tbale on the page => draw borders and background |
| 5174 | 5174 | if (isset(HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']])) { |
@@ -5182,7 +5182,7 @@ discard block |
||
| 5182 | 5182 | HTML2PDF::$_tables[$param['num']]['height'][HTML2PDF::$_tables[$param['num']]['page']], |
| 5183 | 5183 | $this->parsingCss->value['border'], |
| 5184 | 5184 | $this->parsingCss->value['padding'], |
| 5185 | - HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5, |
|
| 5185 | + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5, |
|
| 5186 | 5186 | $this->parsingCss->value['background'] |
| 5187 | 5187 | ); |
| 5188 | 5188 | |
@@ -5206,7 +5206,7 @@ discard block |
||
| 5206 | 5206 | $this->_makeHTMLcode(); |
| 5207 | 5207 | $this->_isInThead = false; |
| 5208 | 5208 | |
| 5209 | - $this->_parsePos = $oldParsePos; |
|
| 5209 | + $this->_parsePos = $oldParsePos; |
|
| 5210 | 5210 | $this->parsingHtml->code = $oldParseCode; |
| 5211 | 5211 | HTML2PDF::$_tables[$param['num']]['tr_curr'] = $tmpTR; |
| 5212 | 5212 | HTML2PDF::$_tables[$param['num']]['td_curr'] = $tmpTD; |
@@ -5215,12 +5215,12 @@ discard block |
||
| 5215 | 5215 | // else (in a sub HTML) |
| 5216 | 5216 | } else { |
| 5217 | 5217 | // prepare it |
| 5218 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1] = array(); |
|
| 5219 | - if (!isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']])) |
|
| 5218 | + HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1] = array(); |
|
| 5219 | + if ( ! isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']])) |
|
| 5220 | 5220 | HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array(); |
| 5221 | 5221 | |
| 5222 | - HTML2PDF::$_tables[$param['num']]['corr_x']=0; |
|
| 5223 | - 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'] = 0; |
|
| 5223 | + while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) |
|
| 5224 | 5224 | HTML2PDF::$_tables[$param['num']]['corr_x']++; |
| 5225 | 5225 | } |
| 5226 | 5226 | |
@@ -5244,19 +5244,19 @@ discard block |
||
| 5244 | 5244 | $this->parsingCss->fontSet(); |
| 5245 | 5245 | |
| 5246 | 5246 | // if we are not in a sub HTML |
| 5247 | - if (!$this->_subPart) { |
|
| 5247 | + if ( ! $this->_subPart) { |
|
| 5248 | 5248 | |
| 5249 | 5249 | // Y of the current line |
| 5250 | - $ty=null; |
|
| 5251 | - for ($ii=0; $ii<count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1]); $ii++) { |
|
| 5252 | - if (HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['rowspan']==1) { |
|
| 5253 | - $ty = HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][$ii]['h']; |
|
| 5250 | + $ty = null; |
|
| 5251 | + for ($ii = 0; $ii < count(HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1]); $ii++) { |
|
| 5252 | + if (HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][$ii]['rowspan'] == 1) { |
|
| 5253 | + $ty = HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][$ii]['h']; |
|
| 5254 | 5254 | } |
| 5255 | 5255 | } |
| 5256 | 5256 | |
| 5257 | 5257 | // new position |
| 5258 | - HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['curr_x']+HTML2PDF::$_tables[$param['num']]['marge']['l']; |
|
| 5259 | - HTML2PDF::$_tables[$param['num']]['td_y']+= $ty; |
|
| 5258 | + HTML2PDF::$_tables[$param['num']]['td_x'] = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['marge']['l']; |
|
| 5259 | + HTML2PDF::$_tables[$param['num']]['td_y'] += $ty; |
|
| 5260 | 5260 | HTML2PDF::$_tables[$param['num']]['new_page'] = false; |
| 5261 | 5261 | } else { |
| 5262 | 5262 | HTML2PDF::$_tables[$param['num']]['corr_y']++; |
@@ -5282,11 +5282,11 @@ discard block |
||
| 5282 | 5282 | $param['cellspacing'] = HTML2PDF::$_tables[$param['num']]['cellspacing'].'mm'; |
| 5283 | 5283 | |
| 5284 | 5284 | // specific style for LI |
| 5285 | - if ($other=='li') { |
|
| 5285 | + if ($other == 'li') { |
|
| 5286 | 5286 | $specialLi = true; |
| 5287 | 5287 | } else { |
| 5288 | 5288 | $specialLi = false; |
| 5289 | - if ($other=='li_sub') { |
|
| 5289 | + if ($other == 'li_sub') { |
|
| 5290 | 5290 | $param['style']['border'] = 'none'; |
| 5291 | 5291 | $param['style']['background-color'] = 'transparent'; |
| 5292 | 5292 | $param['style']['background-image'] = 'none'; |
@@ -5298,7 +5298,7 @@ discard block |
||
| 5298 | 5298 | |
| 5299 | 5299 | // get the properties of the TD |
| 5300 | 5300 | $x = HTML2PDF::$_tables[$param['num']]['td_curr']; |
| 5301 | - $y = HTML2PDF::$_tables[$param['num']]['tr_curr']-1; |
|
| 5301 | + $y = HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1; |
|
| 5302 | 5302 | $colspan = isset($param['colspan']) ? $param['colspan'] : 1; |
| 5303 | 5303 | $rowspan = isset($param['rowspan']) ? $param['rowspan'] : 1; |
| 5304 | 5304 | |
@@ -5317,9 +5317,9 @@ discard block |
||
| 5317 | 5317 | |
| 5318 | 5318 | // for colspans => we get all the neede widths |
| 5319 | 5319 | $colParam['style']['width'] = array(); |
| 5320 | - for ($k=0; $k<$colspan; $k++) { |
|
| 5321 | - if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol+$k]['style']['width'])) { |
|
| 5322 | - $colParam['style']['width'][] = HTML2PDF::$_tables[$param['num']]['cols'][$numCol+$k]['style']['width']; |
|
| 5320 | + for ($k = 0; $k < $colspan; $k++) { |
|
| 5321 | + if (isset(HTML2PDF::$_tables[$param['num']]['cols'][$numCol + $k]['style']['width'])) { |
|
| 5322 | + $colParam['style']['width'][] = HTML2PDF::$_tables[$param['num']]['cols'][$numCol + $k]['style']['width']; |
|
| 5323 | 5323 | } |
| 5324 | 5324 | } |
| 5325 | 5325 | |
@@ -5329,8 +5329,8 @@ discard block |
||
| 5329 | 5329 | if (count($colParam['style']['width'])) { |
| 5330 | 5330 | $total = $colParam['style']['width'][0]; unset($colParam['style']['width'][0]); |
| 5331 | 5331 | foreach ($colParam['style']['width'] as $width) { |
| 5332 | - if (substr($total, -1)=='%' && substr($width, -1)=='%') |
|
| 5333 | - $total = (str_replace('%', '', $total)+str_replace('%', '', $width)).'%'; |
|
| 5332 | + if (substr($total, -1) == '%' && substr($width, -1) == '%') |
|
| 5333 | + $total = (str_replace('%', '', $total) + str_replace('%', '', $width)).'%'; |
|
| 5334 | 5334 | else |
| 5335 | 5335 | $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm'; |
| 5336 | 5336 | } |
@@ -5378,35 +5378,35 @@ discard block |
||
| 5378 | 5378 | $return = $this->parsingCss->analyse($other, $param, $legacy); |
| 5379 | 5379 | |
| 5380 | 5380 | if ($specialLi) { |
| 5381 | - $this->parsingCss->value['width']-= $this->parsingCss->ConvertToMM($this->_listeGetWidth()); |
|
| 5382 | - $this->parsingCss->value['width']-= $this->parsingCss->ConvertToMM($this->_listeGetPadding()); |
|
| 5381 | + $this->parsingCss->value['width'] -= $this->parsingCss->ConvertToMM($this->_listeGetWidth()); |
|
| 5382 | + $this->parsingCss->value['width'] -= $this->parsingCss->ConvertToMM($this->_listeGetPadding()); |
|
| 5383 | 5383 | } |
| 5384 | 5384 | $this->parsingCss->setPosition(); |
| 5385 | 5385 | $this->parsingCss->fontSet(); |
| 5386 | 5386 | |
| 5387 | 5387 | // if tale collapse => modify the borders |
| 5388 | 5388 | if ($collapse) { |
| 5389 | - if (!$this->_subPart) { |
|
| 5389 | + if ( ! $this->_subPart) { |
|
| 5390 | 5390 | if ( |
| 5391 | - (HTML2PDF::$_tables[$param['num']]['tr_curr']>1 && !HTML2PDF::$_tables[$param['num']]['new_page']) || |
|
| 5392 | - (!$this->_isInThead && count(HTML2PDF::$_tables[$param['num']]['thead']['code'])) |
|
| 5391 | + (HTML2PDF::$_tables[$param['num']]['tr_curr'] > 1 && ! HTML2PDF::$_tables[$param['num']]['new_page']) || |
|
| 5392 | + ( ! $this->_isInThead && count(HTML2PDF::$_tables[$param['num']]['thead']['code'])) |
|
| 5393 | 5393 | ) { |
| 5394 | 5394 | $this->parsingCss->value['border']['t'] = $this->parsingCss->readBorder('none'); |
| 5395 | 5395 | } |
| 5396 | 5396 | } |
| 5397 | 5397 | |
| 5398 | - if (HTML2PDF::$_tables[$param['num']]['td_curr']>0) { |
|
| 5399 | - if (!$return) $this->parsingCss->value['width']+= $this->parsingCss->value['border']['l']['width']; |
|
| 5398 | + if (HTML2PDF::$_tables[$param['num']]['td_curr'] > 0) { |
|
| 5399 | + if ( ! $return) $this->parsingCss->value['width'] += $this->parsingCss->value['border']['l']['width']; |
|
| 5400 | 5400 | $this->parsingCss->value['border']['l'] = $this->parsingCss->readBorder('none'); |
| 5401 | 5401 | } |
| 5402 | 5402 | } |
| 5403 | 5403 | |
| 5404 | 5404 | // margins of the table |
| 5405 | 5405 | $marge = array(); |
| 5406 | - $marge['t'] = $this->parsingCss->value['padding']['t']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['t']['width']; |
|
| 5407 | - $marge['r'] = $this->parsingCss->value['padding']['r']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['r']['width']; |
|
| 5408 | - $marge['b'] = $this->parsingCss->value['padding']['b']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['b']['width']; |
|
| 5409 | - $marge['l'] = $this->parsingCss->value['padding']['l']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['l']['width']; |
|
| 5406 | + $marge['t'] = $this->parsingCss->value['padding']['t'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['t']['width']; |
|
| 5407 | + $marge['r'] = $this->parsingCss->value['padding']['r'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['r']['width']; |
|
| 5408 | + $marge['b'] = $this->parsingCss->value['padding']['b'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['b']['width']; |
|
| 5409 | + $marge['l'] = $this->parsingCss->value['padding']['l'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['l']['width']; |
|
| 5410 | 5410 | |
| 5411 | 5411 | // if we are in a sub HTML |
| 5412 | 5412 | if ($this->_subPart) { |
@@ -5422,14 +5422,14 @@ discard block |
||
| 5422 | 5422 | HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['Yr'] = HTML2PDF::$_tables[$param['num']]['corr_y']; |
| 5423 | 5423 | |
| 5424 | 5424 | // prepare the mapping for rowspan and colspan |
| 5425 | - for ($j=0; $j<$rowspan; $j++) { |
|
| 5426 | - for ($i=0; $i<$colspan; $i++) { |
|
| 5425 | + for ($j = 0; $j < $rowspan; $j++) { |
|
| 5426 | + for ($i = 0; $i < $colspan; $i++) { |
|
| 5427 | 5427 | HTML2PDF::$_tables[$param['num']]['corr'] |
| 5428 | - [HTML2PDF::$_tables[$param['num']]['corr_y']+$j] |
|
| 5429 | - [HTML2PDF::$_tables[$param['num']]['corr_x']+$i] = ($i+$j>0) ? '' : array($x,$y,$colspan,$rowspan); |
|
| 5428 | + [HTML2PDF::$_tables[$param['num']]['corr_y'] + $j] |
|
| 5429 | + [HTML2PDF::$_tables[$param['num']]['corr_x'] + $i] = ($i + $j > 0) ? '' : array($x, $y, $colspan, $rowspan); |
|
| 5430 | 5430 | } |
| 5431 | 5431 | } |
| 5432 | - HTML2PDF::$_tables[$param['num']]['corr_x']+= $colspan; |
|
| 5432 | + HTML2PDF::$_tables[$param['num']]['corr_x'] += $colspan; |
|
| 5433 | 5433 | while (isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) { |
| 5434 | 5434 | HTML2PDF::$_tables[$param['num']]['corr_x']++; |
| 5435 | 5435 | } |
@@ -5439,11 +5439,11 @@ discard block |
||
| 5439 | 5439 | $this->_createSubHTML($this->_subHtml); |
| 5440 | 5440 | $this->_subHtml->parsingHtml->code = $level; |
| 5441 | 5441 | $this->_subHtml->_makeHTMLcode(); |
| 5442 | - $this->_tempPos+= count($level); |
|
| 5442 | + $this->_tempPos += count($level); |
|
| 5443 | 5443 | } else { |
| 5444 | 5444 | // new position in the table |
| 5445 | 5445 | HTML2PDF::$_tables[$param['num']]['td_curr']++; |
| 5446 | - HTML2PDF::$_tables[$param['num']]['td_x']+= HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw']; |
|
| 5446 | + HTML2PDF::$_tables[$param['num']]['td_x'] += HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['dw']; |
|
| 5447 | 5447 | |
| 5448 | 5448 | // borders and background of the TD |
| 5449 | 5449 | $this->_drawRectangle( |
@@ -5453,28 +5453,28 @@ discard block |
||
| 5453 | 5453 | HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h'], |
| 5454 | 5454 | $this->parsingCss->value['border'], |
| 5455 | 5455 | $this->parsingCss->value['padding'], |
| 5456 | - HTML2PDF::$_tables[$param['num']]['cellspacing']*0.5, |
|
| 5456 | + HTML2PDF::$_tables[$param['num']]['cellspacing'] * 0.5, |
|
| 5457 | 5457 | $this->parsingCss->value['background'] |
| 5458 | 5458 | ); |
| 5459 | 5459 | |
| 5460 | 5460 | $this->parsingCss->value['width'] = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['w'] - $marge['l'] - $marge['r']; |
| 5461 | 5461 | |
| 5462 | 5462 | // marges = size of the TD |
| 5463 | - $mL = HTML2PDF::$_tables[$param['num']]['td_x']+$marge['l']; |
|
| 5463 | + $mL = HTML2PDF::$_tables[$param['num']]['td_x'] + $marge['l']; |
|
| 5464 | 5464 | $mR = $this->pdf->getW() - $mL - $this->parsingCss->value['width']; |
| 5465 | 5465 | $this->_saveMargin($mL, 0, $mR); |
| 5466 | 5466 | |
| 5467 | 5467 | // position of the content, from vertical-align |
| 5468 | 5468 | $hCorr = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['h']; |
| 5469 | 5469 | $hReel = HTML2PDF::$_tables[$param['num']]['cases'][$y][$x]['real_h']; |
| 5470 | - switch($this->parsingCss->value['vertical-align']) |
|
| 5470 | + switch ($this->parsingCss->value['vertical-align']) |
|
| 5471 | 5471 | { |
| 5472 | 5472 | case 'bottom': |
| 5473 | - $yCorr = $hCorr-$hReel; |
|
| 5473 | + $yCorr = $hCorr - $hReel; |
|
| 5474 | 5474 | break; |
| 5475 | 5475 | |
| 5476 | 5476 | case 'middle': |
| 5477 | - $yCorr = ($hCorr-$hReel)*0.5; |
|
| 5477 | + $yCorr = ($hCorr - $hReel) * 0.5; |
|
| 5478 | 5478 | break; |
| 5479 | 5479 | |
| 5480 | 5480 | case 'top': |
@@ -5484,8 +5484,8 @@ discard block |
||
| 5484 | 5484 | } |
| 5485 | 5485 | |
| 5486 | 5486 | // position of the content |
| 5487 | - $x = HTML2PDF::$_tables[$param['num']]['td_x']+$marge['l']; |
|
| 5488 | - $y = HTML2PDF::$_tables[$param['num']]['td_y']+$marge['t']+$yCorr; |
|
| 5487 | + $x = HTML2PDF::$_tables[$param['num']]['td_x'] + $marge['l']; |
|
| 5488 | + $y = HTML2PDF::$_tables[$param['num']]['td_y'] + $marge['t'] + $yCorr; |
|
| 5489 | 5489 | $this->pdf->setXY($x, $y); |
| 5490 | 5490 | $this->_setNewPositionForNewLine(); |
| 5491 | 5491 | } |
@@ -5508,20 +5508,20 @@ discard block |
||
| 5508 | 5508 | |
| 5509 | 5509 | // get the margins |
| 5510 | 5510 | $marge = array(); |
| 5511 | - $marge['t'] = $this->parsingCss->value['padding']['t']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['t']['width']; |
|
| 5512 | - $marge['r'] = $this->parsingCss->value['padding']['r']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['r']['width']; |
|
| 5513 | - $marge['b'] = $this->parsingCss->value['padding']['b']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['b']['width']; |
|
| 5514 | - $marge['l'] = $this->parsingCss->value['padding']['l']+0.5*HTML2PDF::$_tables[$param['num']]['cellspacing']+$this->parsingCss->value['border']['l']['width']; |
|
| 5515 | - $marge['t']+= 0.001; |
|
| 5516 | - $marge['r']+= 0.001; |
|
| 5517 | - $marge['b']+= 0.001; |
|
| 5518 | - $marge['l']+= 0.001; |
|
| 5511 | + $marge['t'] = $this->parsingCss->value['padding']['t'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['t']['width']; |
|
| 5512 | + $marge['r'] = $this->parsingCss->value['padding']['r'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['r']['width']; |
|
| 5513 | + $marge['b'] = $this->parsingCss->value['padding']['b'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['b']['width']; |
|
| 5514 | + $marge['l'] = $this->parsingCss->value['padding']['l'] + 0.5 * HTML2PDF::$_tables[$param['num']]['cellspacing'] + $this->parsingCss->value['border']['l']['width']; |
|
| 5515 | + $marge['t'] += 0.001; |
|
| 5516 | + $marge['r'] += 0.001; |
|
| 5517 | + $marge['b'] += 0.001; |
|
| 5518 | + $marge['l'] += 0.001; |
|
| 5519 | 5519 | |
| 5520 | 5520 | // if we are in a sub HTML |
| 5521 | 5521 | if ($this->_subPart) { |
| 5522 | 5522 | |
| 5523 | 5523 | // it msut take only one page |
| 5524 | - if ($this->_testTdInOnepage && $this->_subHtml->pdf->getPage()>1) { |
|
| 5524 | + if ($this->_testTdInOnepage && $this->_subHtml->pdf->getPage() > 1) { |
|
| 5525 | 5525 | throw new HTML2PDF_exception(7); |
| 5526 | 5526 | } |
| 5527 | 5527 | |
@@ -5534,19 +5534,19 @@ discard block |
||
| 5534 | 5534 | $h2 = $this->parsingCss->value['height'] + $marge['t'] + $marge['b']; |
| 5535 | 5535 | |
| 5536 | 5536 | // final size of the TD |
| 5537 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['w'] = max(array($w0, $w2)); |
|
| 5538 | - 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 | + HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['w'] = max(array($w0, $w2)); |
|
| 5538 | + HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['h'] = max(array($h0, $h2)); |
|
| 5539 | 5539 | |
| 5540 | 5540 | // real position of the content |
| 5541 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['real_w'] = $w0; |
|
| 5542 | - HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1][HTML2PDF::$_tables[$param['num']]['td_curr']-1]['real_h'] = $h0; |
|
| 5541 | + HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['real_w'] = $w0; |
|
| 5542 | + HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr'] - 1][HTML2PDF::$_tables[$param['num']]['td_curr'] - 1]['real_h'] = $h0; |
|
| 5543 | 5543 | |
| 5544 | 5544 | // destroy the sub HTML |
| 5545 | 5545 | $this->_destroySubHTML($this->_subHtml); |
| 5546 | 5546 | } else { |
| 5547 | 5547 | $this->_loadMargin(); |
| 5548 | 5548 | |
| 5549 | - 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 | + 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']; |
|
| 5550 | 5550 | } |
| 5551 | 5551 | |
| 5552 | 5552 | $this->parsingCss->load(); |
@@ -5602,10 +5602,10 @@ discard block |
||
| 5602 | 5602 | */ |
| 5603 | 5603 | protected function _tag_open_IMG($param) |
| 5604 | 5604 | { |
| 5605 | - $src = str_replace('&', '&', $param['src']); |
|
| 5605 | + $src = str_replace('&', '&', $param['src']); |
|
| 5606 | 5606 | |
| 5607 | 5607 | $this->parsingCss->save(); |
| 5608 | - $this->parsingCss->value['width'] = 0; |
|
| 5608 | + $this->parsingCss->value['width'] = 0; |
|
| 5609 | 5609 | $this->parsingCss->value['height'] = 0; |
| 5610 | 5610 | $this->parsingCss->value['border'] = array('type' => 'none', 'width' => 0, 'color' => array(0, 0, 0)); |
| 5611 | 5611 | $this->parsingCss->value['background'] = array('color' => null, 'image' => null, 'position' => null, 'repeat' => null); |
@@ -5614,7 +5614,7 @@ discard block |
||
| 5614 | 5614 | $this->parsingCss->fontSet(); |
| 5615 | 5615 | |
| 5616 | 5616 | $res = $this->_drawImage($src, isset($param['sub_li'])); |
| 5617 | - if (!$res) return $res; |
|
| 5617 | + if ( ! $res) return $res; |
|
| 5618 | 5618 | |
| 5619 | 5619 | $this->parsingCss->load(); |
| 5620 | 5620 | $this->parsingCss->fontSet(); |
@@ -5632,8 +5632,8 @@ discard block |
||
| 5632 | 5632 | */ |
| 5633 | 5633 | protected function _tag_open_SELECT($param) |
| 5634 | 5634 | { |
| 5635 | - if (!isset($param['name'])) { |
|
| 5636 | - $param['name'] = 'champs_pdf_'.(count($this->_lstField)+1); |
|
| 5635 | + if ( ! isset($param['name'])) { |
|
| 5636 | + $param['name'] = 'champs_pdf_'.(count($this->_lstField) + 1); |
|
| 5637 | 5637 | } |
| 5638 | 5638 | |
| 5639 | 5639 | $param['name'] = strtolower($param['name']); |
@@ -5651,11 +5651,11 @@ discard block |
||
| 5651 | 5651 | |
| 5652 | 5652 | $this->_lstSelect = array(); |
| 5653 | 5653 | $this->_lstSelect['name'] = $param['name']; |
| 5654 | - $this->_lstSelect['multi'] = isset($param['multiple']) ? true : false; |
|
| 5654 | + $this->_lstSelect['multi'] = isset($param['multiple']) ? true : false; |
|
| 5655 | 5655 | $this->_lstSelect['size'] = isset($param['size']) ? $param['size'] : 1; |
| 5656 | - $this->_lstSelect['options'] = array(); |
|
| 5656 | + $this->_lstSelect['options'] = array(); |
|
| 5657 | 5657 | |
| 5658 | - if ($this->_lstSelect['multi'] && $this->_lstSelect['size']<3) $this->_lstSelect['size'] = 3; |
|
| 5658 | + if ($this->_lstSelect['multi'] && $this->_lstSelect['size'] < 3) $this->_lstSelect['size'] = 3; |
|
| 5659 | 5659 | |
| 5660 | 5660 | return true; |
| 5661 | 5661 | } |
@@ -5671,8 +5671,8 @@ discard block |
||
| 5671 | 5671 | { |
| 5672 | 5672 | // get the content of the option : it is the text of the option |
| 5673 | 5673 | $level = $this->parsingHtml->getLevel($this->_parsePos); |
| 5674 | - $this->_parsePos+= count($level); |
|
| 5675 | - $value = isset($param['value']) ? $param['value'] : 'aut_tag_open_opt_'.(count($this->_lstSelect)+1); |
|
| 5674 | + $this->_parsePos += count($level); |
|
| 5675 | + $value = isset($param['value']) ? $param['value'] : 'aut_tag_open_opt_'.(count($this->_lstSelect) + 1); |
|
| 5676 | 5676 | |
| 5677 | 5677 | $this->_lstSelect['options'][$value] = isset($level[0]['param']['txt']) ? $level[0]['param']['txt'] : ''; |
| 5678 | 5678 | |
@@ -5705,13 +5705,13 @@ discard block |
||
| 5705 | 5705 | // position of the select |
| 5706 | 5706 | $x = $this->pdf->getX(); |
| 5707 | 5707 | $y = $this->pdf->getY(); |
| 5708 | - $f = 1.08*$this->parsingCss->value['font-size']; |
|
| 5708 | + $f = 1.08 * $this->parsingCss->value['font-size']; |
|
| 5709 | 5709 | |
| 5710 | 5710 | // width |
| 5711 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 50; |
|
| 5711 | + $w = $this->parsingCss->value['width']; if ( ! $w) $w = 50; |
|
| 5712 | 5712 | |
| 5713 | 5713 | // height (automatic) |
| 5714 | - $h = ($f*1.07*$this->_lstSelect['size'] + 1); |
|
| 5714 | + $h = ($f * 1.07 * $this->_lstSelect['size'] + 1); |
|
| 5715 | 5715 | |
| 5716 | 5716 | $prop = $this->parsingCss->getFormStyle(); |
| 5717 | 5717 | |
@@ -5722,17 +5722,17 @@ discard block |
||
| 5722 | 5722 | |
| 5723 | 5723 | |
| 5724 | 5724 | // single or multi select |
| 5725 | - if ($this->_lstSelect['size']>1) { |
|
| 5725 | + if ($this->_lstSelect['size'] > 1) { |
|
| 5726 | 5726 | $this->pdf->ListBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop); |
| 5727 | 5727 | } else { |
| 5728 | 5728 | $this->pdf->ComboBox($this->_lstSelect['name'], $w, $h, $this->_lstSelect['options'], $prop); |
| 5729 | 5729 | } |
| 5730 | 5730 | |
| 5731 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 5732 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 5731 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 5732 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 5733 | 5733 | $this->_maxH = max($this->_maxH, $h); |
| 5734 | 5734 | $this->_maxE++; |
| 5735 | - $this->pdf->setX($x+$w); |
|
| 5735 | + $this->pdf->setX($x + $w); |
|
| 5736 | 5736 | |
| 5737 | 5737 | $this->parsingCss->load(); |
| 5738 | 5738 | $this->parsingCss->fontSet(); |
@@ -5751,8 +5751,8 @@ discard block |
||
| 5751 | 5751 | */ |
| 5752 | 5752 | protected function _tag_open_TEXTAREA($param) |
| 5753 | 5753 | { |
| 5754 | - if (!isset($param['name'])) { |
|
| 5755 | - $param['name'] = 'champs_pdf_'.(count($this->_lstField)+1); |
|
| 5754 | + if ( ! isset($param['name'])) { |
|
| 5755 | + $param['name'] = 'champs_pdf_'.(count($this->_lstField) + 1); |
|
| 5756 | 5756 | } |
| 5757 | 5757 | |
| 5758 | 5758 | $param['name'] = strtolower($param['name']); |
@@ -5770,16 +5770,16 @@ discard block |
||
| 5770 | 5770 | |
| 5771 | 5771 | $x = $this->pdf->getX(); |
| 5772 | 5772 | $y = $this->pdf->getY(); |
| 5773 | - $fx = 0.65*$this->parsingCss->value['font-size']; |
|
| 5774 | - $fy = 1.08*$this->parsingCss->value['font-size']; |
|
| 5773 | + $fx = 0.65 * $this->parsingCss->value['font-size']; |
|
| 5774 | + $fy = 1.08 * $this->parsingCss->value['font-size']; |
|
| 5775 | 5775 | |
| 5776 | 5776 | // extract the content the textarea : value |
| 5777 | 5777 | $level = $this->parsingHtml->getLevel($this->_parsePos); |
| 5778 | - $this->_parsePos+= count($level); |
|
| 5778 | + $this->_parsePos += count($level); |
|
| 5779 | 5779 | |
| 5780 | 5780 | // automatic size, from cols and rows properties |
| 5781 | - $w = $fx*(isset($param['cols']) ? $param['cols'] : 22)+1; |
|
| 5782 | - $h = $fy*1.07*(isset($param['rows']) ? $param['rows'] : 3)+3; |
|
| 5781 | + $w = $fx * (isset($param['cols']) ? $param['cols'] : 22) + 1; |
|
| 5782 | + $h = $fy * 1.07 * (isset($param['rows']) ? $param['rows'] : 3) + 3; |
|
| 5783 | 5783 | |
| 5784 | 5784 | $prop = $this->parsingCss->getFormStyle(); |
| 5785 | 5785 | |
@@ -5788,11 +5788,11 @@ discard block |
||
| 5788 | 5788 | |
| 5789 | 5789 | $this->pdf->TextField($param['name'], $w, $h, $prop, array(), $x, $y); |
| 5790 | 5790 | |
| 5791 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 5792 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 5791 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 5792 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 5793 | 5793 | $this->_maxH = max($this->_maxH, $h); |
| 5794 | 5794 | $this->_maxE++; |
| 5795 | - $this->pdf->setX($x+$w); |
|
| 5795 | + $this->pdf->setX($x + $w); |
|
| 5796 | 5796 | |
| 5797 | 5797 | return true; |
| 5798 | 5798 | } |
@@ -5821,15 +5821,15 @@ discard block |
||
| 5821 | 5821 | */ |
| 5822 | 5822 | protected function _tag_open_INPUT($param) |
| 5823 | 5823 | { |
| 5824 | - if (!isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->_lstField)+1); |
|
| 5825 | - if (!isset($param['value'])) $param['value'] = ''; |
|
| 5826 | - if (!isset($param['type'])) $param['type'] = 'text'; |
|
| 5824 | + if ( ! isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->_lstField) + 1); |
|
| 5825 | + if ( ! isset($param['value'])) $param['value'] = ''; |
|
| 5826 | + if ( ! isset($param['type'])) $param['type'] = 'text'; |
|
| 5827 | 5827 | |
| 5828 | 5828 | $param['name'] = strtolower($param['name']); |
| 5829 | 5829 | $param['type'] = strtolower($param['type']); |
| 5830 | 5830 | |
| 5831 | 5831 | // the type must be valid |
| 5832 | - if (!in_array($param['type'], array('text', 'checkbox', 'radio', 'hidden', 'submit', 'reset', 'button'))) { |
|
| 5832 | + if ( ! in_array($param['type'], array('text', 'checkbox', 'radio', 'hidden', 'submit', 'reset', 'button'))) { |
|
| 5833 | 5833 | $param['type'] = 'text'; |
| 5834 | 5834 | } |
| 5835 | 5835 | |
@@ -5848,25 +5848,25 @@ discard block |
||
| 5848 | 5848 | |
| 5849 | 5849 | $x = $this->pdf->getX(); |
| 5850 | 5850 | $y = $this->pdf->getY(); |
| 5851 | - $f = 1.08*$this->parsingCss->value['font-size']; |
|
| 5851 | + $f = 1.08 * $this->parsingCss->value['font-size']; |
|
| 5852 | 5852 | |
| 5853 | 5853 | $prop = $this->parsingCss->getFormStyle(); |
| 5854 | 5854 | |
| 5855 | - switch($param['type']) |
|
| 5855 | + switch ($param['type']) |
|
| 5856 | 5856 | { |
| 5857 | 5857 | case 'checkbox': |
| 5858 | 5858 | $w = 3; |
| 5859 | 5859 | $h = $w; |
| 5860 | - if ($h<$f) $y+= ($f-$h)*0.5; |
|
| 5861 | - $checked = (isset($param['checked']) && $param['checked']=='checked'); |
|
| 5860 | + if ($h < $f) $y += ($f - $h) * 0.5; |
|
| 5861 | + $checked = (isset($param['checked']) && $param['checked'] == 'checked'); |
|
| 5862 | 5862 | $this->pdf->CheckBox($name, $w, $checked, $prop, array(), ($param['value'] ? $param['value'] : 'Yes'), $x, $y); |
| 5863 | 5863 | break; |
| 5864 | 5864 | |
| 5865 | 5865 | case 'radio': |
| 5866 | 5866 | $w = 3; |
| 5867 | 5867 | $h = $w; |
| 5868 | - if ($h<$f) $y+= ($f-$h)*0.5; |
|
| 5869 | - $checked = (isset($param['checked']) && $param['checked']=='checked'); |
|
| 5868 | + if ($h < $f) $y += ($f - $h) * 0.5; |
|
| 5869 | + $checked = (isset($param['checked']) && $param['checked'] == 'checked'); |
|
| 5870 | 5870 | $this->pdf->RadioButton($name, $w, $prop, array(), ($param['value'] ? $param['value'] : 'On'), $checked, $x, $y); |
| 5871 | 5871 | break; |
| 5872 | 5872 | |
@@ -5878,29 +5878,29 @@ discard block |
||
| 5878 | 5878 | break; |
| 5879 | 5879 | |
| 5880 | 5880 | case 'text': |
| 5881 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 40; |
|
| 5882 | - $h = $f*1.3; |
|
| 5881 | + $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 5882 | + $h = $f * 1.3; |
|
| 5883 | 5883 | $prop['value'] = $param['value']; |
| 5884 | 5884 | $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y); |
| 5885 | 5885 | break; |
| 5886 | 5886 | |
| 5887 | 5887 | case 'submit': |
| 5888 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 40; |
|
| 5889 | - $h = $this->parsingCss->value['height']; if (!$h) $h = $f*1.3; |
|
| 5888 | + $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 5889 | + $h = $this->parsingCss->value['height']; if ( ! $h) $h = $f * 1.3; |
|
| 5890 | 5890 | $action = array('S'=>'SubmitForm', 'F'=>$this->_isInForm, 'Flags'=>array('ExportFormat')); |
| 5891 | 5891 | $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
| 5892 | 5892 | break; |
| 5893 | 5893 | |
| 5894 | 5894 | case 'reset': |
| 5895 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 40; |
|
| 5896 | - $h = $this->parsingCss->value['height']; if (!$h) $h = $f*1.3; |
|
| 5895 | + $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 5896 | + $h = $this->parsingCss->value['height']; if ( ! $h) $h = $f * 1.3; |
|
| 5897 | 5897 | $action = array('S'=>'ResetForm'); |
| 5898 | 5898 | $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
| 5899 | 5899 | break; |
| 5900 | 5900 | |
| 5901 | 5901 | case 'button': |
| 5902 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 40; |
|
| 5903 | - $h = $this->parsingCss->value['height']; if (!$h) $h = $f*1.3; |
|
| 5902 | + $w = $this->parsingCss->value['width']; if ( ! $w) $w = 40; |
|
| 5903 | + $h = $this->parsingCss->value['height']; if ( ! $h) $h = $f * 1.3; |
|
| 5904 | 5904 | $action = isset($param['onclick']) ? $param['onclick'] : ''; |
| 5905 | 5905 | $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
| 5906 | 5906 | break; |
@@ -5911,11 +5911,11 @@ discard block |
||
| 5911 | 5911 | break; |
| 5912 | 5912 | } |
| 5913 | 5913 | |
| 5914 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 5915 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 5914 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 5915 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 5916 | 5916 | $this->_maxH = max($this->_maxH, $h); |
| 5917 | 5917 | $this->_maxE++; |
| 5918 | - $this->pdf->setX($x+$w); |
|
| 5918 | + $this->pdf->setX($x + $w); |
|
| 5919 | 5919 | |
| 5920 | 5920 | $this->parsingCss->load(); |
| 5921 | 5921 | $this->parsingCss->fontSet(); |
@@ -5951,26 +5951,26 @@ discard block |
||
| 5951 | 5951 | $w = $this->parsingCss->value['width']; |
| 5952 | 5952 | $h = $this->parsingCss->value['height']; |
| 5953 | 5953 | |
| 5954 | - if (!$this->parsingCss->value['position']) { |
|
| 5954 | + if ( ! $this->parsingCss->value['position']) { |
|
| 5955 | 5955 | if ( |
| 5956 | - $w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) && |
|
| 5957 | - $this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin()) |
|
| 5956 | + $w < ($this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin()) && |
|
| 5957 | + $this->pdf->getX() + $w >= ($this->pdf->getW() - $this->pdf->getrMargin()) |
|
| 5958 | 5958 | ) |
| 5959 | 5959 | $this->_tag_open_BR(array()); |
| 5960 | 5960 | |
| 5961 | 5961 | if ( |
| 5962 | - ($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) && |
|
| 5963 | - ($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) && |
|
| 5964 | - !$this->_isInOverflow |
|
| 5962 | + ($h < ($this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin())) && |
|
| 5963 | + ($this->pdf->getY() + $h >= ($this->pdf->getH() - $this->pdf->getbMargin())) && |
|
| 5964 | + ! $this->_isInOverflow |
|
| 5965 | 5965 | ) |
| 5966 | 5966 | $this->_setNewPage(); |
| 5967 | 5967 | |
| 5968 | 5968 | $old = $this->parsingCss->getOldValues(); |
| 5969 | 5969 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 5970 | 5970 | |
| 5971 | - if ($parentWidth>$w) { |
|
| 5972 | - if ($alignObject=='center') $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 5973 | - else if ($alignObject=='right') $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 5971 | + if ($parentWidth > $w) { |
|
| 5972 | + if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 5973 | + else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 5974 | 5974 | } |
| 5975 | 5975 | |
| 5976 | 5976 | $this->parsingCss->setPosition(); |
@@ -5978,9 +5978,9 @@ discard block |
||
| 5978 | 5978 | $old = $this->parsingCss->getOldValues(); |
| 5979 | 5979 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 5980 | 5980 | |
| 5981 | - if ($parentWidth>$w) { |
|
| 5982 | - if ($alignObject=='center') $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 5983 | - else if ($alignObject=='right') $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 5981 | + if ($parentWidth > $w) { |
|
| 5982 | + if ($alignObject == 'center') $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5); |
|
| 5983 | + else if ($alignObject == 'right') $this->pdf->setX($this->pdf->getX() + $parentWidth - $w); |
|
| 5984 | 5984 | } |
| 5985 | 5985 | |
| 5986 | 5986 | $this->parsingCss->setPosition(); |
@@ -6008,27 +6008,27 @@ discard block |
||
| 6008 | 6008 | $marge['t'] = $this->parsingCss->value['border']['t']['width']; |
| 6009 | 6009 | $marge['b'] = $this->parsingCss->value['border']['b']['width']; |
| 6010 | 6010 | |
| 6011 | - $this->parsingCss->value['width'] -= $marge['l']+$marge['r']; |
|
| 6012 | - $this->parsingCss->value['height']-= $marge['t']+$marge['b']; |
|
| 6011 | + $this->parsingCss->value['width'] -= $marge['l'] + $marge['r']; |
|
| 6012 | + $this->parsingCss->value['height'] -= $marge['t'] + $marge['b']; |
|
| 6013 | 6013 | |
| 6014 | - $overW-= $marge['l']+$marge['r']; |
|
| 6015 | - $overH-= $marge['t']+$marge['b']; |
|
| 6014 | + $overW -= $marge['l'] + $marge['r']; |
|
| 6015 | + $overH -= $marge['t'] + $marge['b']; |
|
| 6016 | 6016 | |
| 6017 | 6017 | // clipping to draw only in the size opf the DRAW tag |
| 6018 | 6018 | $this->pdf->clippingPathStart( |
| 6019 | - $this->parsingCss->value['x']+$marge['l'], |
|
| 6020 | - $this->parsingCss->value['y']+$marge['t'], |
|
| 6019 | + $this->parsingCss->value['x'] + $marge['l'], |
|
| 6020 | + $this->parsingCss->value['y'] + $marge['t'], |
|
| 6021 | 6021 | $this->parsingCss->value['width'], |
| 6022 | 6022 | $this->parsingCss->value['height'] |
| 6023 | 6023 | ); |
| 6024 | 6024 | |
| 6025 | 6025 | // left and right of the DRAW tag |
| 6026 | - $mL = $this->parsingCss->value['x']+$marge['l']; |
|
| 6026 | + $mL = $this->parsingCss->value['x'] + $marge['l']; |
|
| 6027 | 6027 | $mR = $this->pdf->getW() - $mL - $overW; |
| 6028 | 6028 | |
| 6029 | 6029 | // position of the DRAW tag |
| 6030 | - $x = $this->parsingCss->value['x']+$marge['l']; |
|
| 6031 | - $y = $this->parsingCss->value['y']+$marge['t']; |
|
| 6030 | + $x = $this->parsingCss->value['x'] + $marge['l']; |
|
| 6031 | + $y = $this->parsingCss->value['y'] + $marge['t']; |
|
| 6032 | 6032 | |
| 6033 | 6033 | // prepare the drawing area |
| 6034 | 6034 | $this->_saveMargin($mL, 0, $mR); |
@@ -6043,7 +6043,7 @@ discard block |
||
| 6043 | 6043 | ); |
| 6044 | 6044 | |
| 6045 | 6045 | // init the translate matrix : (0,0) => ($x, $y) |
| 6046 | - $this->pdf->doTransform(array(1,0,0,1,$x,$y)); |
|
| 6046 | + $this->pdf->doTransform(array(1, 0, 0, 1, $x, $y)); |
|
| 6047 | 6047 | $this->pdf->SetAlpha(1.); |
| 6048 | 6048 | return true; |
| 6049 | 6049 | } |
@@ -6075,14 +6075,14 @@ discard block |
||
| 6075 | 6075 | |
| 6076 | 6076 | $x = $this->parsingCss->value['x']; |
| 6077 | 6077 | $y = $this->parsingCss->value['y']; |
| 6078 | - $w = $this->parsingCss->value['width']+$marge['l']+$marge['r']; |
|
| 6079 | - $h = $this->parsingCss->value['height']+$marge['t']+$marge['b']; |
|
| 6078 | + $w = $this->parsingCss->value['width'] + $marge['l'] + $marge['r']; |
|
| 6079 | + $h = $this->parsingCss->value['height'] + $marge['t'] + $marge['b']; |
|
| 6080 | 6080 | |
| 6081 | - if ($this->parsingCss->value['position']!='absolute') { |
|
| 6082 | - $this->pdf->setXY($x+$w, $y); |
|
| 6081 | + if ($this->parsingCss->value['position'] != 'absolute') { |
|
| 6082 | + $this->pdf->setXY($x + $w, $y); |
|
| 6083 | 6083 | |
| 6084 | - $this->_maxX = max($this->_maxX, $x+$w); |
|
| 6085 | - $this->_maxY = max($this->_maxY, $y+$h); |
|
| 6084 | + $this->_maxX = max($this->_maxX, $x + $w); |
|
| 6085 | + $this->_maxY = max($this->_maxY, $y + $h); |
|
| 6086 | 6086 | $this->_maxH = max($this->_maxH, $h); |
| 6087 | 6087 | $this->_maxE++; |
| 6088 | 6088 | } else { |
@@ -6092,7 +6092,7 @@ discard block |
||
| 6092 | 6092 | $this->_loadMax(); |
| 6093 | 6093 | } |
| 6094 | 6094 | |
| 6095 | - $block = ($this->parsingCss->value['display']!='inline' && $this->parsingCss->value['position']!='absolute'); |
|
| 6095 | + $block = ($this->parsingCss->value['display'] != 'inline' && $this->parsingCss->value['position'] != 'absolute'); |
|
| 6096 | 6096 | |
| 6097 | 6097 | $this->parsingCss->load(); |
| 6098 | 6098 | $this->parsingCss->fontSet(); |
@@ -6115,7 +6115,7 @@ discard block |
||
| 6115 | 6115 | */ |
| 6116 | 6116 | protected function _tag_open_LINE($param) |
| 6117 | 6117 | { |
| 6118 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'LINE'); |
|
| 6118 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'LINE'); |
|
| 6119 | 6119 | |
| 6120 | 6120 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6121 | 6121 | $this->parsingCss->save(); |
@@ -6142,7 +6142,7 @@ discard block |
||
| 6142 | 6142 | */ |
| 6143 | 6143 | protected function _tag_open_RECT($param) |
| 6144 | 6144 | { |
| 6145 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'RECT'); |
|
| 6145 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'RECT'); |
|
| 6146 | 6146 | |
| 6147 | 6147 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6148 | 6148 | $this->parsingCss->save(); |
@@ -6169,7 +6169,7 @@ discard block |
||
| 6169 | 6169 | */ |
| 6170 | 6170 | protected function _tag_open_CIRCLE($param) |
| 6171 | 6171 | { |
| 6172 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'CIRCLE'); |
|
| 6172 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'CIRCLE'); |
|
| 6173 | 6173 | |
| 6174 | 6174 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6175 | 6175 | $this->parsingCss->save(); |
@@ -6194,7 +6194,7 @@ discard block |
||
| 6194 | 6194 | */ |
| 6195 | 6195 | protected function _tag_open_ELLIPSE($param) |
| 6196 | 6196 | { |
| 6197 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'ELLIPSE'); |
|
| 6197 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'ELLIPSE'); |
|
| 6198 | 6198 | |
| 6199 | 6199 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6200 | 6200 | $this->parsingCss->save(); |
@@ -6221,7 +6221,7 @@ discard block |
||
| 6221 | 6221 | */ |
| 6222 | 6222 | protected function _tag_open_POLYLINE($param) |
| 6223 | 6223 | { |
| 6224 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6224 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6225 | 6225 | |
| 6226 | 6226 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6227 | 6227 | $this->parsingCss->save(); |
@@ -6237,16 +6237,16 @@ discard block |
||
| 6237 | 6237 | $path = explode(' ', $path); |
| 6238 | 6238 | foreach ($path as $k => $v) { |
| 6239 | 6239 | $path[$k] = trim($v); |
| 6240 | - if ($path[$k]==='') unset($path[$k]); |
|
| 6240 | + if ($path[$k] === '') unset($path[$k]); |
|
| 6241 | 6241 | } |
| 6242 | 6242 | $path = array_values($path); |
| 6243 | 6243 | |
| 6244 | 6244 | $actions = array(); |
| 6245 | - for ($k=0; $k<count($path); $k+=2) { |
|
| 6245 | + for ($k = 0; $k < count($path); $k += 2) { |
|
| 6246 | 6246 | $actions[] = array( |
| 6247 | - ($k ? 'L' : 'M') , |
|
| 6248 | - $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']), |
|
| 6249 | - $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']) |
|
| 6247 | + ($k ? 'L' : 'M'), |
|
| 6248 | + $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']), |
|
| 6249 | + $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']) |
|
| 6250 | 6250 | ); |
| 6251 | 6251 | } |
| 6252 | 6252 | |
@@ -6267,7 +6267,7 @@ discard block |
||
| 6267 | 6267 | */ |
| 6268 | 6268 | protected function _tag_open_POLYGON($param) |
| 6269 | 6269 | { |
| 6270 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6270 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6271 | 6271 | |
| 6272 | 6272 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6273 | 6273 | $this->parsingCss->save(); |
@@ -6283,16 +6283,16 @@ discard block |
||
| 6283 | 6283 | $path = explode(' ', $path); |
| 6284 | 6284 | foreach ($path as $k => $v) { |
| 6285 | 6285 | $path[$k] = trim($v); |
| 6286 | - if ($path[$k]==='') unset($path[$k]); |
|
| 6286 | + if ($path[$k] === '') unset($path[$k]); |
|
| 6287 | 6287 | } |
| 6288 | 6288 | $path = array_values($path); |
| 6289 | 6289 | |
| 6290 | 6290 | $actions = array(); |
| 6291 | - for ($k=0; $k<count($path); $k+=2) { |
|
| 6291 | + for ($k = 0; $k < count($path); $k += 2) { |
|
| 6292 | 6292 | $actions[] = array( |
| 6293 | - ($k ? 'L' : 'M') , |
|
| 6294 | - $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']), |
|
| 6295 | - $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']) |
|
| 6293 | + ($k ? 'L' : 'M'), |
|
| 6294 | + $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']), |
|
| 6295 | + $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']) |
|
| 6296 | 6296 | ); |
| 6297 | 6297 | } |
| 6298 | 6298 | $actions[] = array('z'); |
@@ -6314,7 +6314,7 @@ discard block |
||
| 6314 | 6314 | */ |
| 6315 | 6315 | protected function _tag_open_PATH($param) |
| 6316 | 6316 | { |
| 6317 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'PATH'); |
|
| 6317 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'PATH'); |
|
| 6318 | 6318 | |
| 6319 | 6319 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6320 | 6320 | $this->parsingCss->save(); |
@@ -6334,7 +6334,7 @@ discard block |
||
| 6334 | 6334 | $path = explode(' ', $path); |
| 6335 | 6335 | foreach ($path as $k => $v) { |
| 6336 | 6336 | $path[$k] = trim($v); |
| 6337 | - if ($path[$k]==='') unset($path[$k]); |
|
| 6337 | + if ($path[$k] === '') unset($path[$k]); |
|
| 6338 | 6338 | } |
| 6339 | 6339 | $path = array_values($path); |
| 6340 | 6340 | |
@@ -6342,7 +6342,7 @@ discard block |
||
| 6342 | 6342 | $actions = array(); |
| 6343 | 6343 | $action = array(); |
| 6344 | 6344 | $lastAction = null; // last action found |
| 6345 | - for ($k=0; $k<count($path);true) { |
|
| 6345 | + for ($k = 0; $k < count($path); true) { |
|
| 6346 | 6346 | |
| 6347 | 6347 | // for this actions, we can not have multi coordonate |
| 6348 | 6348 | if (in_array($lastAction, array('z', 'Z'))) { |
@@ -6350,7 +6350,7 @@ discard block |
||
| 6350 | 6350 | } |
| 6351 | 6351 | |
| 6352 | 6352 | // read the new action (forcing if no action before) |
| 6353 | - if (preg_match('/^[a-z]+$/i', $path[$k]) || $lastAction===null) { |
|
| 6353 | + if (preg_match('/^[a-z]+$/i', $path[$k]) || $lastAction === null) { |
|
| 6354 | 6354 | $lastAction = $path[$k]; |
| 6355 | 6355 | $k++; |
| 6356 | 6356 | } |
@@ -6358,40 +6358,40 @@ discard block |
||
| 6358 | 6358 | // current action |
| 6359 | 6359 | $action = array(); |
| 6360 | 6360 | $action[] = $lastAction; |
| 6361 | - switch($lastAction) |
|
| 6361 | + switch ($lastAction) |
|
| 6362 | 6362 | { |
| 6363 | 6363 | case 'C': |
| 6364 | 6364 | case 'c': |
| 6365 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']); // x1 |
|
| 6366 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']); // y1 |
|
| 6367 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+2], $this->_isInDraw['w']); // x2 |
|
| 6368 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+3], $this->_isInDraw['h']); // y2 |
|
| 6369 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+4], $this->_isInDraw['w']); // x |
|
| 6370 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+5], $this->_isInDraw['h']); // y |
|
| 6371 | - $k+= 6; |
|
| 6365 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x1 |
|
| 6366 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y1 |
|
| 6367 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 2], $this->_isInDraw['w']); // x2 |
|
| 6368 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 3], $this->_isInDraw['h']); // y2 |
|
| 6369 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 4], $this->_isInDraw['w']); // x |
|
| 6370 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 5], $this->_isInDraw['h']); // y |
|
| 6371 | + $k += 6; |
|
| 6372 | 6372 | break; |
| 6373 | 6373 | |
| 6374 | 6374 | case 'Q': |
| 6375 | 6375 | case 'S': |
| 6376 | 6376 | case 'q': |
| 6377 | 6377 | case 's': |
| 6378 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']); // x2 |
|
| 6379 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']); // y2 |
|
| 6380 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+2], $this->_isInDraw['w']); // x |
|
| 6381 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+3], $this->_isInDraw['h']); // y |
|
| 6382 | - $k+= 4; |
|
| 6378 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x2 |
|
| 6379 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y2 |
|
| 6380 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 2], $this->_isInDraw['w']); // x |
|
| 6381 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 3], $this->_isInDraw['h']); // y |
|
| 6382 | + $k += 4; |
|
| 6383 | 6383 | break; |
| 6384 | 6384 | |
| 6385 | 6385 | case 'A': |
| 6386 | 6386 | case 'a': |
| 6387 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']); // rx |
|
| 6388 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']); // ry |
|
| 6389 | - $action[] = 1.*$path[$k+2]; // angle de deviation de l'axe X |
|
| 6390 | - $action[] = ($path[$k+3]=='1') ? 1 : 0; // large-arc-flag |
|
| 6391 | - $action[] = ($path[$k+4]=='1') ? 1 : 0; // sweep-flag |
|
| 6392 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+5], $this->_isInDraw['w']); // x |
|
| 6393 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+6], $this->_isInDraw['h']); // y |
|
| 6394 | - $k+= 7; |
|
| 6387 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // rx |
|
| 6388 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // ry |
|
| 6389 | + $action[] = 1. * $path[$k + 2]; // angle de deviation de l'axe X |
|
| 6390 | + $action[] = ($path[$k + 3] == '1') ? 1 : 0; // large-arc-flag |
|
| 6391 | + $action[] = ($path[$k + 4] == '1') ? 1 : 0; // sweep-flag |
|
| 6392 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 5], $this->_isInDraw['w']); // x |
|
| 6393 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 6], $this->_isInDraw['h']); // y |
|
| 6394 | + $k += 7; |
|
| 6395 | 6395 | break; |
| 6396 | 6396 | |
| 6397 | 6397 | case 'M': |
@@ -6400,21 +6400,21 @@ discard block |
||
| 6400 | 6400 | case 'm': |
| 6401 | 6401 | case 'l': |
| 6402 | 6402 | case 't': |
| 6403 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']); // x |
|
| 6404 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+1], $this->_isInDraw['h']); // y |
|
| 6405 | - $k+= 2; |
|
| 6403 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x |
|
| 6404 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y |
|
| 6405 | + $k += 2; |
|
| 6406 | 6406 | break; |
| 6407 | 6407 | |
| 6408 | 6408 | case 'H': |
| 6409 | 6409 | case 'h': |
| 6410 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['w']); // x |
|
| 6411 | - $k+= 1; |
|
| 6410 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x |
|
| 6411 | + $k += 1; |
|
| 6412 | 6412 | break; |
| 6413 | 6413 | |
| 6414 | 6414 | case 'V': |
| 6415 | 6415 | case 'v': |
| 6416 | - $action[] = $this->parsingCss->ConvertToMM($path[$k+0], $this->_isInDraw['h']); // y |
|
| 6417 | - $k+= 1; |
|
| 6416 | + $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['h']); // y |
|
| 6417 | + $k += 1; |
|
| 6418 | 6418 | break; |
| 6419 | 6419 | |
| 6420 | 6420 | case 'z': |
@@ -6443,7 +6443,7 @@ discard block |
||
| 6443 | 6443 | */ |
| 6444 | 6444 | protected function _tag_open_G($param) |
| 6445 | 6445 | { |
| 6446 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'G'); |
|
| 6446 | + if ( ! $this->_isInDraw) throw new HTML2PDF_exception(8, 'G'); |
|
| 6447 | 6447 | |
| 6448 | 6448 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6449 | 6449 | $this->parsingCss->save(); |
@@ -162,7 +162,9 @@ discard block |
||
| 162 | 162 | $this->_subPart = false; |
| 163 | 163 | |
| 164 | 164 | // init the marges of the page |
| 165 | - if (!is_array($marges)) $marges = array($marges, $marges, $marges, $marges); |
|
| 165 | + if (!is_array($marges)) { |
|
| 166 | + $marges = array($marges, $marges, $marges, $marges); |
|
| 167 | + } |
|
| 166 | 168 | $this->_setDefaultMargins($marges[0], $marges[1], $marges[2], $marges[3]); |
| 167 | 169 | $this->_setMargins(); |
| 168 | 170 | $this->_marges = array(); |
@@ -310,7 +312,9 @@ discard block |
||
| 310 | 312 | { |
| 311 | 313 | $oldPage = $this->_INDEX_NewPage($onPage); |
| 312 | 314 | $this->pdf->createIndex($this, $titre, $sizeTitle, $sizeBookmark, $bookmarkTitle, $displayPage, $onPage, $fontName); |
| 313 | - if ($oldPage) $this->pdf->setPage($oldPage); |
|
| 315 | + if ($oldPage) { |
|
| 316 | + $this->pdf->setPage($oldPage); |
|
| 317 | + } |
|
| 314 | 318 | } |
| 315 | 319 | |
| 316 | 320 | /** |
@@ -356,14 +360,24 @@ discard block |
||
| 356 | 360 | } |
| 357 | 361 | |
| 358 | 362 | // 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 | + if ($dest===false) { |
|
| 364 | + $dest = 'I'; |
|
| 365 | + } |
|
| 366 | + if ($dest===true) { |
|
| 367 | + $dest = 'S'; |
|
| 368 | + } |
|
| 369 | + if ($dest==='') { |
|
| 370 | + $dest = 'I'; |
|
| 371 | + } |
|
| 372 | + if ($name=='') { |
|
| 373 | + $name='document.pdf'; |
|
| 374 | + } |
|
| 363 | 375 | |
| 364 | 376 | // clean up the destination |
| 365 | 377 | $dest = strtoupper($dest); |
| 366 | - if (!in_array($dest, array('I', 'D', 'F', 'S', 'FI','FD'))) $dest = 'I'; |
|
| 378 | + if (!in_array($dest, array('I', 'D', 'F', 'S', 'FI','FD'))) { |
|
| 379 | + $dest = 'I'; |
|
| 380 | + } |
|
| 367 | 381 | |
| 368 | 382 | // the name must be a PDF name |
| 369 | 383 | if (strtolower(substr($name, -4))!='.pdf') { |
@@ -385,8 +399,9 @@ discard block |
||
| 385 | 399 | public function writeHTML($html, $debugVue = false) |
| 386 | 400 | { |
| 387 | 401 | // if it is a real html page, we have to convert it |
| 388 | - if (preg_match('/<body/isU', $html)) |
|
| 389 | - $html = $this->getHtmlFromPage($html); |
|
| 402 | + if (preg_match('/<body/isU', $html)) { |
|
| 403 | + $html = $this->getHtmlFromPage($html); |
|
| 404 | + } |
|
| 390 | 405 | |
| 391 | 406 | $html = str_replace('[[date_y]]', date('Y'), $html); |
| 392 | 407 | $html = str_replace('[[date_m]]', date('m'), $html); |
@@ -422,20 +437,24 @@ discard block |
||
| 422 | 437 | |
| 423 | 438 | // extract the content |
| 424 | 439 | $res = explode('<body', $html); |
| 425 | - if (count($res)<2) return $html; |
|
| 440 | + if (count($res)<2) { |
|
| 441 | + return $html; |
|
| 442 | + } |
|
| 426 | 443 | $content = '<page'.$res[1]; |
| 427 | 444 | $content = explode('</body', $content); |
| 428 | 445 | $content = $content[0].'</page>'; |
| 429 | 446 | |
| 430 | 447 | // extract the link tags |
| 431 | 448 | preg_match_all('/<link([^>]*)>/isU', $html, $match); |
| 432 | - foreach ($match[0] as $src) |
|
| 433 | - $content = $src.'</link>'.$content; |
|
| 449 | + foreach ($match[0] as $src) { |
|
| 450 | + $content = $src.'</link>'.$content; |
|
| 451 | + } |
|
| 434 | 452 | |
| 435 | 453 | // extract the css style tags |
| 436 | 454 | preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match); |
| 437 | - foreach ($match[0] as $src) |
|
| 438 | - $content = $src.$content; |
|
| 455 | + foreach ($match[0] as $src) { |
|
| 456 | + $content = $src.$content; |
|
| 457 | + } |
|
| 439 | 458 | |
| 440 | 459 | return $content; |
| 441 | 460 | } |
@@ -513,8 +532,12 @@ discard block |
||
| 513 | 532 | */ |
| 514 | 533 | protected function _setDefaultMargins($left, $top, $right = null, $bottom = null) |
| 515 | 534 | { |
| 516 | - if ($right===null) $right = $left; |
|
| 517 | - if ($bottom===null) $bottom = 8; |
|
| 535 | + if ($right===null) { |
|
| 536 | + $right = $left; |
|
| 537 | + } |
|
| 538 | + if ($bottom===null) { |
|
| 539 | + $bottom = 8; |
|
| 540 | + } |
|
| 518 | 541 | |
| 519 | 542 | $this->_defaultLeft = $this->parsingCss->ConvertToMM($left.'mm'); |
| 520 | 543 | $this->_defaultTop = $this->parsingCss->ConvertToMM($top.'mm'); |
@@ -565,8 +588,9 @@ discard block |
||
| 565 | 588 | $this->pdf->Rect(0, 0, $this->pdf->getW(), $this->pdf->getH(), 'F'); |
| 566 | 589 | } |
| 567 | 590 | |
| 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']); |
|
| 591 | + if (isset($this->_background['img']) && $this->_background['img']) { |
|
| 592 | + $this->pdf->Image($this->_background['img'], $this->_background['posX'], $this->_background['posY'], $this->_background['width']); |
|
| 593 | + } |
|
| 570 | 594 | } |
| 571 | 595 | |
| 572 | 596 | $this->_setPageHeader(); |
@@ -617,7 +641,9 @@ discard block |
||
| 617 | 641 | protected function _DEBUG_add($name, $level=null) |
| 618 | 642 | { |
| 619 | 643 | // if true : UP |
| 620 | - if ($level===true) $this->_debugLevel++; |
|
| 644 | + if ($level===true) { |
|
| 645 | + $this->_debugLevel++; |
|
| 646 | + } |
|
| 621 | 647 | |
| 622 | 648 | $name = str_repeat(' ', $this->_debugLevel). $name.($level===true ? ' Begin' : ($level===false ? ' End' : '')); |
| 623 | 649 | $time = microtime(true); |
@@ -635,7 +661,9 @@ discard block |
||
| 635 | 661 | $this->_debugLastTime = $time; |
| 636 | 662 | |
| 637 | 663 | // it false : DOWN |
| 638 | - if ($level===false) $this->_debugLevel--; |
|
| 664 | + if ($level===false) { |
|
| 665 | + $this->_debugLevel--; |
|
| 666 | + } |
|
| 639 | 667 | |
| 640 | 668 | return $this; |
| 641 | 669 | } |
@@ -674,8 +702,9 @@ discard block |
||
| 674 | 702 | $y = floor($y*100); |
| 675 | 703 | $x = array($this->pdf->getlMargin(), $this->pdf->getW()-$this->pdf->getrMargin()); |
| 676 | 704 | |
| 677 | - foreach ($this->_pageMarges as $mY => $mX) |
|
| 678 | - if ($mY<=$y) $x = $mX; |
|
| 705 | + foreach ($this->_pageMarges as $mY => $mX) { |
|
| 706 | + if ($mY<=$y) $x = $mX; |
|
| 707 | + } |
|
| 679 | 708 | |
| 680 | 709 | return $x; |
| 681 | 710 | } |
@@ -697,18 +726,30 @@ discard block |
||
| 697 | 726 | $oldBottom = $this->_getMargins($yBottom); |
| 698 | 727 | |
| 699 | 728 | // 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; |
|
| 729 | + if ($float=='left' && $oldTop[0]<$xRight) { |
|
| 730 | + $oldTop[0] = $xRight; |
|
| 731 | + } |
|
| 732 | + if ($float=='right' && $oldTop[1]>$xLeft) { |
|
| 733 | + $oldTop[1] = $xLeft; |
|
| 734 | + } |
|
| 702 | 735 | |
| 703 | 736 | $yTop = floor($yTop*100); |
| 704 | 737 | $yBottom = floor($yBottom*100); |
| 705 | 738 | |
| 706 | 739 | // erase all the float margins that are smaller than the new one |
| 707 | 740 | 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]); |
|
| 741 | + if ($mY<$yTop) { |
|
| 742 | + continue; |
|
| 743 | + } |
|
| 744 | + if ($mY>$yBottom) { |
|
| 745 | + break; |
|
| 746 | + } |
|
| 747 | + if ($float=='left' && $this->_pageMarges[$mY][0]<$xRight) { |
|
| 748 | + unset($this->_pageMarges[$mY]); |
|
| 749 | + } |
|
| 750 | + if ($float=='right' && $this->_pageMarges[$mY][1]>$xLeft) { |
|
| 751 | + unset($this->_pageMarges[$mY]); |
|
| 752 | + } |
|
| 712 | 753 | } |
| 713 | 754 | |
| 714 | 755 | // save the new Top and Bottom margins |
@@ -806,7 +847,9 @@ discard block |
||
| 806 | 847 | */ |
| 807 | 848 | protected function _setPageHeader() |
| 808 | 849 | { |
| 809 | - if (!count($this->_subHEADER)) return false; |
|
| 850 | + if (!count($this->_subHEADER)) { |
|
| 851 | + return false; |
|
| 852 | + } |
|
| 810 | 853 | |
| 811 | 854 | $oldParsePos = $this->_parsePos; |
| 812 | 855 | $oldParseCode = $this->parsingHtml->code; |
@@ -826,7 +869,9 @@ discard block |
||
| 826 | 869 | */ |
| 827 | 870 | protected function _setPageFooter() |
| 828 | 871 | { |
| 829 | - if (!count($this->_subFOOTER)) return false; |
|
| 872 | + if (!count($this->_subFOOTER)) { |
|
| 873 | + return false; |
|
| 874 | + } |
|
| 830 | 875 | |
| 831 | 876 | $oldParsePos = $this->_parsePos; |
| 832 | 877 | $oldParseCode = $this->parsingHtml->code; |
@@ -887,15 +932,18 @@ discard block |
||
| 887 | 932 | $txt = $sub->parsingHtml->code[$this->_parsePos]['param']['txt']; |
| 888 | 933 | $txt = str_replace('[[page_cu]]', $sub->pdf->getMyNumPage($this->_page), $txt); |
| 889 | 934 | $sub->parsingHtml->code[$this->_parsePos]['param']['txt'] = substr($txt, $curr+1); |
| 890 | - } else |
|
| 891 | - $sub->_parsePos++; |
|
| 935 | + } else { |
|
| 936 | + $sub->_parsePos++; |
|
| 937 | + } |
|
| 892 | 938 | |
| 893 | 939 | // for each element of the parsing => load the action |
| 894 | 940 | $res = null; |
| 895 | 941 | for ($sub->_parsePos; $sub->_parsePos<count($sub->parsingHtml->code); $sub->_parsePos++) { |
| 896 | 942 | $action = $sub->parsingHtml->code[$sub->_parsePos]; |
| 897 | 943 | $res = $sub->_executeAction($action); |
| 898 | - if (!$res) break; |
|
| 944 | + if (!$res) { |
|
| 945 | + break; |
|
| 946 | + } |
|
| 899 | 947 | } |
| 900 | 948 | |
| 901 | 949 | $w = $sub->_maxX; // max width |
@@ -906,12 +954,13 @@ discard block |
||
| 906 | 954 | $this->_destroySubHTML($sub); |
| 907 | 955 | |
| 908 | 956 | // 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); |
|
| 957 | + if ($this->parsingCss->value['text-align']=='center') { |
|
| 958 | + $this->pdf->setX(($rx+$this->pdf->getX()-$w)*0.5-0.01); |
|
| 959 | + } else if ($this->parsingCss->value['text-align']=='right') { |
|
| 960 | + $this->pdf->setX($rx-$w-0.01); |
|
| 961 | + } else { |
|
| 962 | + $this->pdf->setX($lx); |
|
| 963 | + } |
|
| 915 | 964 | |
| 916 | 965 | // set the height of the line |
| 917 | 966 | $this->_currentH = $h; |
@@ -1024,8 +1073,12 @@ discard block |
||
| 1024 | 1073 | $nbBaseFive = array('V','L','D'); |
| 1025 | 1074 | $nbRoman = ''; |
| 1026 | 1075 | |
| 1027 | - if ($nbArabic<1) return $nbArabic; |
|
| 1028 | - if ($nbArabic>3999) return $nbArabic; |
|
| 1076 | + if ($nbArabic<1) { |
|
| 1077 | + return $nbArabic; |
|
| 1078 | + } |
|
| 1079 | + if ($nbArabic>3999) { |
|
| 1080 | + return $nbArabic; |
|
| 1081 | + } |
|
| 1029 | 1082 | |
| 1030 | 1083 | for ($i=3; $i>=0 ; $i--) { |
| 1031 | 1084 | $chiffre=floor($nbArabic/pow(10, $i)); |
@@ -1095,7 +1148,9 @@ discard block |
||
| 1095 | 1148 | $nb = $this->_defList[count($this->_defList)-1]['nb']; |
| 1096 | 1149 | $up = (substr($st, 0, 6)=='upper-'); |
| 1097 | 1150 | |
| 1098 | - if ($im) return array(false, false, $im); |
|
| 1151 | + if ($im) { |
|
| 1152 | + return array(false, false, $im); |
|
| 1153 | + } |
|
| 1099 | 1154 | |
| 1100 | 1155 | switch($st) |
| 1101 | 1156 | { |
@@ -1156,12 +1211,19 @@ discard block |
||
| 1156 | 1211 | } |
| 1157 | 1212 | |
| 1158 | 1213 | // 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 = ''; |
|
| 1214 | + if (!in_array($type, array('ul', 'ol'))) { |
|
| 1215 | + $type = 'ul'; |
|
| 1216 | + } |
|
| 1217 | + if (!in_array($style, array('lower-alpha', 'upper-alpha', 'upper-roman', 'lower-roman', 'decimal', 'square', 'circle', 'disc', 'none'))) { |
|
| 1218 | + $style = ''; |
|
| 1219 | + } |
|
| 1161 | 1220 | |
| 1162 | 1221 | if (!$style) { |
| 1163 | - if ($type=='ul') $style = 'disc'; |
|
| 1164 | - else $style = 'decimal'; |
|
| 1222 | + if ($type=='ul') { |
|
| 1223 | + $style = 'disc'; |
|
| 1224 | + } else { |
|
| 1225 | + $style = 'decimal'; |
|
| 1226 | + } |
|
| 1165 | 1227 | } |
| 1166 | 1228 | |
| 1167 | 1229 | // add the new level |
@@ -1270,8 +1332,9 @@ discard block |
||
| 1270 | 1332 | */ |
| 1271 | 1333 | protected function _getElementY($h) |
| 1272 | 1334 | { |
| 1273 | - if ($this->_subPart || $this->_isSubPart || !$this->_currentH || $this->_currentH<$h) |
|
| 1274 | - return 0; |
|
| 1335 | + if ($this->_subPart || $this->_isSubPart || !$this->_currentH || $this->_currentH<$h) { |
|
| 1336 | + return 0; |
|
| 1337 | + } |
|
| 1275 | 1338 | |
| 1276 | 1339 | return ($this->_currentH-$h)*0.8; |
| 1277 | 1340 | } |
@@ -1286,10 +1349,11 @@ discard block |
||
| 1286 | 1349 | protected function _makeBreakLine($h, $curr = null) |
| 1287 | 1350 | { |
| 1288 | 1351 | 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); |
|
| 1352 | + if (($this->pdf->getY()+$h<$this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter) { |
|
| 1353 | + $this->_setNewLine($h, $curr); |
|
| 1354 | + } else { |
|
| 1355 | + $this->_setNewPage(null, '', null, $curr); |
|
| 1356 | + } |
|
| 1293 | 1357 | } else { |
| 1294 | 1358 | $this->_setNewPositionForNewLine($curr); |
| 1295 | 1359 | } |
@@ -1413,7 +1477,9 @@ discard block |
||
| 1413 | 1477 | |
| 1414 | 1478 | // calculate the position of the image, if align to the right |
| 1415 | 1479 | if ($parentWidth>$w && $float!='left') { |
| 1416 | - if ($float=='right' || $this->parsingCss->value['text-align']=='li_right') $x = $parentX + $parentWidth - $w-$this->parsingCss->value['margin']['r']-$this->parsingCss->value['margin']['l']; |
|
| 1480 | + if ($float=='right' || $this->parsingCss->value['text-align']=='li_right') { |
|
| 1481 | + $x = $parentX + $parentWidth - $w-$this->parsingCss->value['margin']['r']-$this->parsingCss->value['margin']['l']; |
|
| 1482 | + } |
|
| 1417 | 1483 | } |
| 1418 | 1484 | |
| 1419 | 1485 | // display the image |
@@ -1484,7 +1550,9 @@ discard block |
||
| 1484 | 1550 | protected function _drawRectangle($x, $y, $w, $h, $border, $padding, $margin, $background) |
| 1485 | 1551 | { |
| 1486 | 1552 | // if we are in a subpart or if height is null => return false |
| 1487 | - if ($this->_subPart || $this->_isSubPart || $h===null) return false; |
|
| 1553 | + if ($this->_subPart || $this->_isSubPart || $h===null) { |
|
| 1554 | + return false; |
|
| 1555 | + } |
|
| 1488 | 1556 | |
| 1489 | 1557 | // add the margin |
| 1490 | 1558 | $x+= $margin; |
@@ -1527,10 +1595,18 @@ discard block |
||
| 1527 | 1595 | $inBL[1]-= $border['b']['width']; |
| 1528 | 1596 | } |
| 1529 | 1597 | |
| 1530 | - if ($inTL[0]<=0 || $inTL[1]<=0) $inTL = null; |
|
| 1531 | - if ($inTR[0]<=0 || $inTR[1]<=0) $inTR = null; |
|
| 1532 | - if ($inBR[0]<=0 || $inBR[1]<=0) $inBR = null; |
|
| 1533 | - if ($inBL[0]<=0 || $inBL[1]<=0) $inBL = null; |
|
| 1598 | + if ($inTL[0]<=0 || $inTL[1]<=0) { |
|
| 1599 | + $inTL = null; |
|
| 1600 | + } |
|
| 1601 | + if ($inTR[0]<=0 || $inTR[1]<=0) { |
|
| 1602 | + $inTR = null; |
|
| 1603 | + } |
|
| 1604 | + if ($inBR[0]<=0 || $inBR[1]<=0) { |
|
| 1605 | + $inBR = null; |
|
| 1606 | + } |
|
| 1607 | + if ($inBL[0]<=0 || $inBL[1]<=0) { |
|
| 1608 | + $inBL = null; |
|
| 1609 | + } |
|
| 1534 | 1610 | |
| 1535 | 1611 | // prepare the background color |
| 1536 | 1612 | $pdfStyle = ''; |
@@ -1588,13 +1664,21 @@ discard block |
||
| 1588 | 1664 | $imageHeight = 72./96.*$imageInfos[1]/$this->pdf->getK(); |
| 1589 | 1665 | |
| 1590 | 1666 | // prepare the position of the backgroung |
| 1591 | - if ($iRepeat[0]) $iPosition[0] = $bX; |
|
| 1592 | - else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) $iPosition[0] = $bX + $match[1]*($bW-$imageWidth)/100; |
|
| 1593 | - else $iPosition[0] = $bX+$iPosition[0]; |
|
| 1667 | + if ($iRepeat[0]) { |
|
| 1668 | + $iPosition[0] = $bX; |
|
| 1669 | + } else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[0], $match)) { |
|
| 1670 | + $iPosition[0] = $bX + $match[1]*($bW-$imageWidth)/100; |
|
| 1671 | + } else { |
|
| 1672 | + $iPosition[0] = $bX+$iPosition[0]; |
|
| 1673 | + } |
|
| 1594 | 1674 | |
| 1595 | - if ($iRepeat[1]) $iPosition[1] = $bY; |
|
| 1596 | - else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) $iPosition[1] = $bY + $match[1]*($bH-$imageHeight)/100; |
|
| 1597 | - else $iPosition[1] = $bY+$iPosition[1]; |
|
| 1675 | + if ($iRepeat[1]) { |
|
| 1676 | + $iPosition[1] = $bY; |
|
| 1677 | + } else if (preg_match('/^([-]?[0-9\.]+)%/isU', $iPosition[1], $match)) { |
|
| 1678 | + $iPosition[1] = $bY + $match[1]*($bH-$imageHeight)/100; |
|
| 1679 | + } else { |
|
| 1680 | + $iPosition[1] = $bY+$iPosition[1]; |
|
| 1681 | + } |
|
| 1598 | 1682 | |
| 1599 | 1683 | $imageXmin = $bX; |
| 1600 | 1684 | $imageXmax = $bX+$bW; |
@@ -1646,10 +1730,18 @@ discard block |
||
| 1646 | 1730 | $y-= $loose; |
| 1647 | 1731 | $w+= 2.*$loose; |
| 1648 | 1732 | $h+= 2.*$loose; |
| 1649 | - if ($border['l']['width']) $border['l']['width']+= 2.*$loose; |
|
| 1650 | - if ($border['t']['width']) $border['t']['width']+= 2.*$loose; |
|
| 1651 | - if ($border['r']['width']) $border['r']['width']+= 2.*$loose; |
|
| 1652 | - if ($border['b']['width']) $border['b']['width']+= 2.*$loose; |
|
| 1733 | + if ($border['l']['width']) { |
|
| 1734 | + $border['l']['width']+= 2.*$loose; |
|
| 1735 | + } |
|
| 1736 | + if ($border['t']['width']) { |
|
| 1737 | + $border['t']['width']+= 2.*$loose; |
|
| 1738 | + } |
|
| 1739 | + if ($border['r']['width']) { |
|
| 1740 | + $border['r']['width']+= 2.*$loose; |
|
| 1741 | + } |
|
| 1742 | + if ($border['b']['width']) { |
|
| 1743 | + $border['b']['width']+= 2.*$loose; |
|
| 1744 | + } |
|
| 1653 | 1745 | |
| 1654 | 1746 | // prepare the test on borders |
| 1655 | 1747 | $testBl = ($border['l']['width'] && $border['l']['color'][0]!==null); |
@@ -1747,13 +1839,17 @@ discard block |
||
| 1747 | 1839 | if (is_array($outBL)) { |
| 1748 | 1840 | $bord-=1; |
| 1749 | 1841 | $pt[3] -= $outBL[1] - $border['b']['width']; |
| 1750 | - if ($inBL) $pt[11]-= $inBL[1]; |
|
| 1842 | + if ($inBL) { |
|
| 1843 | + $pt[11]-= $inBL[1]; |
|
| 1844 | + } |
|
| 1751 | 1845 | unset($pt[0]);unset($pt[1]); |
| 1752 | 1846 | } |
| 1753 | 1847 | if (is_array($outTL)) { |
| 1754 | 1848 | $bord-=2; |
| 1755 | 1849 | $pt[5] += $outTL[1]-$border['t']['width']; |
| 1756 | - if ($inTL) $pt[9] += $inTL[1]; |
|
| 1850 | + if ($inTL) { |
|
| 1851 | + $pt[9] += $inTL[1]; |
|
| 1852 | + } |
|
| 1757 | 1853 | unset($pt[6]);unset($pt[7]); |
| 1758 | 1854 | } |
| 1759 | 1855 | |
@@ -1775,13 +1871,17 @@ discard block |
||
| 1775 | 1871 | if (is_array($outTL)) { |
| 1776 | 1872 | $bord-=1; |
| 1777 | 1873 | $pt[2] += $outTL[0] - $border['l']['width']; |
| 1778 | - if ($inTL) $pt[10]+= $inTL[0]; |
|
| 1874 | + if ($inTL) { |
|
| 1875 | + $pt[10]+= $inTL[0]; |
|
| 1876 | + } |
|
| 1779 | 1877 | unset($pt[0]);unset($pt[1]); |
| 1780 | 1878 | } |
| 1781 | 1879 | if (is_array($outTR)) { |
| 1782 | 1880 | $bord-=2; |
| 1783 | 1881 | $pt[4] -= $outTR[0] - $border['r']['width']; |
| 1784 | - if ($inTR) $pt[8] -= $inTR[0]; |
|
| 1882 | + if ($inTR) { |
|
| 1883 | + $pt[8] -= $inTR[0]; |
|
| 1884 | + } |
|
| 1785 | 1885 | unset($pt[6]);unset($pt[7]); |
| 1786 | 1886 | } |
| 1787 | 1887 | |
@@ -1803,13 +1903,17 @@ discard block |
||
| 1803 | 1903 | if (is_array($outTR)) { |
| 1804 | 1904 | $bord-=1; |
| 1805 | 1905 | $pt[3] += $outTR[1] - $border['t']['width']; |
| 1806 | - if ($inTR) $pt[11]+= $inTR[1]; |
|
| 1906 | + if ($inTR) { |
|
| 1907 | + $pt[11]+= $inTR[1]; |
|
| 1908 | + } |
|
| 1807 | 1909 | unset($pt[0]);unset($pt[1]); |
| 1808 | 1910 | } |
| 1809 | 1911 | if (is_array($outBR)) { |
| 1810 | 1912 | $bord-=2; |
| 1811 | 1913 | $pt[5] -= $outBR[1] - $border['b']['width']; |
| 1812 | - if ($inBR) $pt[9] -= $inBR[1]; |
|
| 1914 | + if ($inBR) { |
|
| 1915 | + $pt[9] -= $inBR[1]; |
|
| 1916 | + } |
|
| 1813 | 1917 | unset($pt[6]);unset($pt[7]); |
| 1814 | 1918 | } |
| 1815 | 1919 | |
@@ -1831,13 +1935,17 @@ discard block |
||
| 1831 | 1935 | if (is_array($outBL)) { |
| 1832 | 1936 | $bord-=2; |
| 1833 | 1937 | $pt[4] += $outBL[0] - $border['l']['width']; |
| 1834 | - if ($inBL) $pt[8] += $inBL[0]; |
|
| 1938 | + if ($inBL) { |
|
| 1939 | + $pt[8] += $inBL[0]; |
|
| 1940 | + } |
|
| 1835 | 1941 | unset($pt[6]);unset($pt[7]); |
| 1836 | 1942 | } |
| 1837 | 1943 | if (is_array($outBR)) { |
| 1838 | 1944 | $bord-=1; |
| 1839 | 1945 | $pt[2] -= $outBR[0] - $border['r']['width']; |
| 1840 | - if ($inBR) $pt[10]-= $inBR[0]; |
|
| 1946 | + if ($inBR) { |
|
| 1947 | + $pt[10]-= $inBR[0]; |
|
| 1948 | + } |
|
| 1841 | 1949 | unset($pt[0]);unset($pt[1]); |
| 1842 | 1950 | |
| 1843 | 1951 | } |
@@ -1864,10 +1972,11 @@ discard block |
||
| 1864 | 1972 | { |
| 1865 | 1973 | $this->pdf->setFillColorArray($color); |
| 1866 | 1974 | |
| 1867 | - if (count($pt)==10) |
|
| 1868 | - $this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]); |
|
| 1869 | - else |
|
| 1870 | - $this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]); |
|
| 1975 | + if (count($pt)==10) { |
|
| 1976 | + $this->pdf->drawCurve($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]); |
|
| 1977 | + } else { |
|
| 1978 | + $this->pdf->drawCorner($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7]); |
|
| 1979 | + } |
|
| 1871 | 1980 | } |
| 1872 | 1981 | |
| 1873 | 1982 | /** |
@@ -1938,10 +2047,18 @@ discard block |
||
| 1938 | 2047 | for ($i=0; $l-($px+$py)*($i-0.5)>0; $i++) { |
| 1939 | 2048 | if (($i%2)==$mode) { |
| 1940 | 2049 | $j = $i-0.5; |
| 1941 | - $lx1 = $px*($j); if ($lx1<-$l) $lx1 =-$l; |
|
| 1942 | - $ly1 = $py*($j); if ($ly1<-$l) $ly1 =-$l; |
|
| 1943 | - $lx2 = $px*($j+1); if ($lx2>$l) $lx2 = $l; |
|
| 1944 | - $ly2 = $py*($j+1); if ($ly2>$l) $ly2 = $l; |
|
| 2050 | + $lx1 = $px*($j); if ($lx1<-$l) { |
|
| 2051 | + $lx1 =-$l; |
|
| 2052 | + } |
|
| 2053 | + $ly1 = $py*($j); if ($ly1<-$l) { |
|
| 2054 | + $ly1 =-$l; |
|
| 2055 | + } |
|
| 2056 | + $lx2 = $px*($j+1); if ($lx2>$l) { |
|
| 2057 | + $lx2 = $l; |
|
| 2058 | + } |
|
| 2059 | + $ly2 = $py*($j+1); if ($ly2>$l) { |
|
| 2060 | + $ly2 = $l; |
|
| 2061 | + } |
|
| 1945 | 2062 | |
| 1946 | 2063 | $tmp = array(); |
| 1947 | 2064 | $tmp[] = $x1+$lx1; $tmp[] = $y1+$ly1; |
@@ -2017,10 +2134,14 @@ discard block |
||
| 2017 | 2134 | protected function _prepareTransform($transform) |
| 2018 | 2135 | { |
| 2019 | 2136 | // it can not be empty |
| 2020 | - if (!$transform) return null; |
|
| 2137 | + if (!$transform) { |
|
| 2138 | + return null; |
|
| 2139 | + } |
|
| 2021 | 2140 | |
| 2022 | 2141 | // sctions must be like scale(...) |
| 2023 | - if (!preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) return null; |
|
| 2142 | + if (!preg_match_all('/([a-z]+)\(([^\)]*)\)/isU', $transform, $match)) { |
|
| 2143 | + return null; |
|
| 2144 | + } |
|
| 2024 | 2145 | |
| 2025 | 2146 | // prepare the list of the actions |
| 2026 | 2147 | $actions = array(); |
@@ -2041,49 +2162,115 @@ discard block |
||
| 2041 | 2162 | switch($name) |
| 2042 | 2163 | { |
| 2043 | 2164 | case 'scale': |
| 2044 | - if (!isset($val[0])) $val[0] = 1.; else $val[0] = 1.*$val[0]; |
|
| 2045 | - if (!isset($val[1])) $val[1] = $val[0]; else $val[1] = 1.*$val[1]; |
|
| 2165 | + if (!isset($val[0])) { |
|
| 2166 | + $val[0] = 1.; |
|
| 2167 | + } else { |
|
| 2168 | + $val[0] = 1.*$val[0]; |
|
| 2169 | + } |
|
| 2170 | + if (!isset($val[1])) { |
|
| 2171 | + $val[1] = $val[0]; |
|
| 2172 | + } else { |
|
| 2173 | + $val[1] = 1.*$val[1]; |
|
| 2174 | + } |
|
| 2046 | 2175 | $actions[] = array($val[0],0,0,$val[1],0,0); |
| 2047 | 2176 | break; |
| 2048 | 2177 | |
| 2049 | 2178 | case 'translate': |
| 2050 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']); |
|
| 2051 | - if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']); |
|
| 2179 | + if (!isset($val[0])) { |
|
| 2180 | + $val[0] = 0.; |
|
| 2181 | + } else { |
|
| 2182 | + $val[0] = $this->parsingCss->ConvertToMM($val[0], $this->_isInDraw['w']); |
|
| 2183 | + } |
|
| 2184 | + if (!isset($val[1])) { |
|
| 2185 | + $val[1] = 0.; |
|
| 2186 | + } else { |
|
| 2187 | + $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['h']); |
|
| 2188 | + } |
|
| 2052 | 2189 | $actions[] = array(1,0,0,1,$val[0],$val[1]); |
| 2053 | 2190 | break; |
| 2054 | 2191 | |
| 2055 | 2192 | case 'rotate': |
| 2056 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.; |
|
| 2057 | - if (!isset($val[1])) $val[1] = 0.; else $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']); |
|
| 2058 | - if (!isset($val[2])) $val[2] = 0.; else $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']); |
|
| 2059 | - if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,-$val[1],-$val[2]); |
|
| 2193 | + if (!isset($val[0])) { |
|
| 2194 | + $val[0] = 0.; |
|
| 2195 | + } else { |
|
| 2196 | + $val[0] = $val[0]*M_PI/180.; |
|
| 2197 | + } |
|
| 2198 | + if (!isset($val[1])) { |
|
| 2199 | + $val[1] = 0.; |
|
| 2200 | + } else { |
|
| 2201 | + $val[1] = $this->parsingCss->ConvertToMM($val[1], $this->_isInDraw['w']); |
|
| 2202 | + } |
|
| 2203 | + if (!isset($val[2])) { |
|
| 2204 | + $val[2] = 0.; |
|
| 2205 | + } else { |
|
| 2206 | + $val[2] = $this->parsingCss->ConvertToMM($val[2], $this->_isInDraw['h']); |
|
| 2207 | + } |
|
| 2208 | + if ($val[1] || $val[2]) { |
|
| 2209 | + $actions[] = array(1,0,0,1,-$val[1],-$val[2]); |
|
| 2210 | + } |
|
| 2060 | 2211 | $actions[] = array(cos($val[0]),sin($val[0]),-sin($val[0]),cos($val[0]),0,0); |
| 2061 | - if ($val[1] || $val[2]) $actions[] = array(1,0,0,1,$val[1],$val[2]); |
|
| 2212 | + if ($val[1] || $val[2]) { |
|
| 2213 | + $actions[] = array(1,0,0,1,$val[1],$val[2]); |
|
| 2214 | + } |
|
| 2062 | 2215 | break; |
| 2063 | 2216 | |
| 2064 | 2217 | case 'skewx': |
| 2065 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.; |
|
| 2218 | + if (!isset($val[0])) { |
|
| 2219 | + $val[0] = 0.; |
|
| 2220 | + } else { |
|
| 2221 | + $val[0] = $val[0]*M_PI/180.; |
|
| 2222 | + } |
|
| 2066 | 2223 | $actions[] = array(1,0,tan($val[0]),1,0,0); |
| 2067 | 2224 | break; |
| 2068 | 2225 | |
| 2069 | 2226 | case 'skewy': |
| 2070 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*M_PI/180.; |
|
| 2227 | + if (!isset($val[0])) { |
|
| 2228 | + $val[0] = 0.; |
|
| 2229 | + } else { |
|
| 2230 | + $val[0] = $val[0]*M_PI/180.; |
|
| 2231 | + } |
|
| 2071 | 2232 | $actions[] = array(1,tan($val[0]),0,1,0,0); |
| 2072 | 2233 | break; |
| 2073 | 2234 | case 'matrix': |
| 2074 | - if (!isset($val[0])) $val[0] = 0.; else $val[0] = $val[0]*1.; |
|
| 2075 | - if (!isset($val[1])) $val[1] = 0.; else $val[1] = $val[1]*1.; |
|
| 2076 | - if (!isset($val[2])) $val[2] = 0.; else $val[2] = $val[2]*1.; |
|
| 2077 | - if (!isset($val[3])) $val[3] = 0.; else $val[3] = $val[3]*1.; |
|
| 2078 | - if (!isset($val[4])) $val[4] = 0.; else $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']); |
|
| 2079 | - if (!isset($val[5])) $val[5] = 0.; else $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']); |
|
| 2235 | + if (!isset($val[0])) { |
|
| 2236 | + $val[0] = 0.; |
|
| 2237 | + } else { |
|
| 2238 | + $val[0] = $val[0]*1.; |
|
| 2239 | + } |
|
| 2240 | + if (!isset($val[1])) { |
|
| 2241 | + $val[1] = 0.; |
|
| 2242 | + } else { |
|
| 2243 | + $val[1] = $val[1]*1.; |
|
| 2244 | + } |
|
| 2245 | + if (!isset($val[2])) { |
|
| 2246 | + $val[2] = 0.; |
|
| 2247 | + } else { |
|
| 2248 | + $val[2] = $val[2]*1.; |
|
| 2249 | + } |
|
| 2250 | + if (!isset($val[3])) { |
|
| 2251 | + $val[3] = 0.; |
|
| 2252 | + } else { |
|
| 2253 | + $val[3] = $val[3]*1.; |
|
| 2254 | + } |
|
| 2255 | + if (!isset($val[4])) { |
|
| 2256 | + $val[4] = 0.; |
|
| 2257 | + } else { |
|
| 2258 | + $val[4] = $this->parsingCss->ConvertToMM($val[4], $this->_isInDraw['w']); |
|
| 2259 | + } |
|
| 2260 | + if (!isset($val[5])) { |
|
| 2261 | + $val[5] = 0.; |
|
| 2262 | + } else { |
|
| 2263 | + $val[5] = $this->parsingCss->ConvertToMM($val[5], $this->_isInDraw['h']); |
|
| 2264 | + } |
|
| 2080 | 2265 | $actions[] =$val; |
| 2081 | 2266 | break; |
| 2082 | 2267 | } |
| 2083 | 2268 | } |
| 2084 | 2269 | |
| 2085 | 2270 | // if ther is no actions => return |
| 2086 | - if (!$actions) return null; |
|
| 2271 | + if (!$actions) { |
|
| 2272 | + return null; |
|
| 2273 | + } |
|
| 2087 | 2274 | |
| 2088 | 2275 | // get the first matrix |
| 2089 | 2276 | $m = $actions[0]; unset($actions[0]); |
@@ -2111,7 +2298,9 @@ discard block |
||
| 2111 | 2298 | */ |
| 2112 | 2299 | protected function _calculateTableCellSize(&$cases, &$corr) |
| 2113 | 2300 | { |
| 2114 | - if (!isset($corr[0])) return true; |
|
| 2301 | + if (!isset($corr[0])) { |
|
| 2302 | + return true; |
|
| 2303 | + } |
|
| 2115 | 2304 | |
| 2116 | 2305 | // for each cell without colspan, we get the max width for each column |
| 2117 | 2306 | $sw = array(); |
@@ -2131,7 +2320,9 @@ discard block |
||
| 2131 | 2320 | if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]>1) { |
| 2132 | 2321 | |
| 2133 | 2322 | // sum the max width of each column in colspan |
| 2134 | - $s = 0; for ($i=0; $i<$corr[$y][$x][2]; $i++) $s+= $sw[$x+$i]; |
|
| 2323 | + $s = 0; for ($i=0; $i<$corr[$y][$x][2]; $i++) { |
|
| 2324 | + $s+= $sw[$x+$i]; |
|
| 2325 | + } |
|
| 2135 | 2326 | |
| 2136 | 2327 | // if the max width is < the width of the cell with colspan => we adapt the width of each max width |
| 2137 | 2328 | if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']) { |
@@ -2180,7 +2371,9 @@ discard block |
||
| 2180 | 2371 | if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]>1) { |
| 2181 | 2372 | |
| 2182 | 2373 | // sum the max height of each line in rowspan |
| 2183 | - $s = 0; for ($i=0; $i<$corr[$y][$x][3]; $i++) $s+= $sh[$y+$i]; |
|
| 2374 | + $s = 0; for ($i=0; $i<$corr[$y][$x][3]; $i++) { |
|
| 2375 | + $s+= $sh[$y+$i]; |
|
| 2376 | + } |
|
| 2184 | 2377 | |
| 2185 | 2378 | // if the max height is < the height of the cell with rowspan => we adapt the height of each max height |
| 2186 | 2379 | if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']) { |
@@ -2230,8 +2423,12 @@ discard block |
||
| 2230 | 2423 | */ |
| 2231 | 2424 | protected function _tag_open_PAGE($param) |
| 2232 | 2425 | { |
| 2233 | - if ($this->_isForOneLine) return false; |
|
| 2234 | - if ($this->_debugActif) $this->_DEBUG_add('PAGE '.($this->_page+1), true); |
|
| 2426 | + if ($this->_isForOneLine) { |
|
| 2427 | + return false; |
|
| 2428 | + } |
|
| 2429 | + if ($this->_debugActif) { |
|
| 2430 | + $this->_DEBUG_add('PAGE '.($this->_page+1), true); |
|
| 2431 | + } |
|
| 2235 | 2432 | |
| 2236 | 2433 | $newPageSet= (!isset($param['pageset']) || $param['pageset']!='old'); |
| 2237 | 2434 | |
@@ -2248,12 +2445,22 @@ discard block |
||
| 2248 | 2445 | $orientation = ''; |
| 2249 | 2446 | if (isset($param['orientation'])) { |
| 2250 | 2447 | $param['orientation'] = strtolower($param['orientation']); |
| 2251 | - if ($param['orientation']=='p') $orientation = 'P'; |
|
| 2252 | - if ($param['orientation']=='portrait') $orientation = 'P'; |
|
| 2448 | + if ($param['orientation']=='p') { |
|
| 2449 | + $orientation = 'P'; |
|
| 2450 | + } |
|
| 2451 | + if ($param['orientation']=='portrait') { |
|
| 2452 | + $orientation = 'P'; |
|
| 2453 | + } |
|
| 2253 | 2454 | |
| 2254 | - if ($param['orientation']=='l') $orientation = 'L'; |
|
| 2255 | - if ($param['orientation']=='paysage') $orientation = 'L'; |
|
| 2256 | - if ($param['orientation']=='landscape') $orientation = 'L'; |
|
| 2455 | + if ($param['orientation']=='l') { |
|
| 2456 | + $orientation = 'L'; |
|
| 2457 | + } |
|
| 2458 | + if ($param['orientation']=='paysage') { |
|
| 2459 | + $orientation = 'L'; |
|
| 2460 | + } |
|
| 2461 | + if ($param['orientation']=='landscape') { |
|
| 2462 | + $orientation = 'L'; |
|
| 2463 | + } |
|
| 2257 | 2464 | } |
| 2258 | 2465 | |
| 2259 | 2466 | // format |
@@ -2277,12 +2484,24 @@ discard block |
||
| 2277 | 2484 | $background['img'] = str_replace('&', '&', $background['img']); |
| 2278 | 2485 | |
| 2279 | 2486 | // convert the positions |
| 2280 | - if ($background['posX']=='left') $background['posX'] = '0%'; |
|
| 2281 | - if ($background['posX']=='center') $background['posX'] = '50%'; |
|
| 2282 | - if ($background['posX']=='right') $background['posX'] = '100%'; |
|
| 2283 | - if ($background['posY']=='top') $background['posY'] = '0%'; |
|
| 2284 | - if ($background['posY']=='middle') $background['posY'] = '50%'; |
|
| 2285 | - if ($background['posY']=='bottom') $background['posY'] = '100%'; |
|
| 2487 | + if ($background['posX']=='left') { |
|
| 2488 | + $background['posX'] = '0%'; |
|
| 2489 | + } |
|
| 2490 | + if ($background['posX']=='center') { |
|
| 2491 | + $background['posX'] = '50%'; |
|
| 2492 | + } |
|
| 2493 | + if ($background['posX']=='right') { |
|
| 2494 | + $background['posX'] = '100%'; |
|
| 2495 | + } |
|
| 2496 | + if ($background['posY']=='top') { |
|
| 2497 | + $background['posY'] = '0%'; |
|
| 2498 | + } |
|
| 2499 | + if ($background['posY']=='middle') { |
|
| 2500 | + $background['posY'] = '50%'; |
|
| 2501 | + } |
|
| 2502 | + if ($background['posY']=='bottom') { |
|
| 2503 | + $background['posY'] = '100%'; |
|
| 2504 | + } |
|
| 2286 | 2505 | |
| 2287 | 2506 | if ($background['img']) { |
| 2288 | 2507 | // get the size of the image |
@@ -2310,10 +2529,18 @@ discard block |
||
| 2310 | 2529 | $background['right'] = isset($param['backright']) ? $param['backright'] : '0'; |
| 2311 | 2530 | |
| 2312 | 2531 | // if no unit => mm |
| 2313 | - if (preg_match('/^([0-9]*)$/isU', $background['top'])) $background['top'] .= 'mm'; |
|
| 2314 | - if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) $background['bottom'] .= 'mm'; |
|
| 2315 | - if (preg_match('/^([0-9]*)$/isU', $background['left'])) $background['left'] .= 'mm'; |
|
| 2316 | - if (preg_match('/^([0-9]*)$/isU', $background['right'])) $background['right'] .= 'mm'; |
|
| 2532 | + if (preg_match('/^([0-9]*)$/isU', $background['top'])) { |
|
| 2533 | + $background['top'] .= 'mm'; |
|
| 2534 | + } |
|
| 2535 | + if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) { |
|
| 2536 | + $background['bottom'] .= 'mm'; |
|
| 2537 | + } |
|
| 2538 | + if (preg_match('/^([0-9]*)$/isU', $background['left'])) { |
|
| 2539 | + $background['left'] .= 'mm'; |
|
| 2540 | + } |
|
| 2541 | + if (preg_match('/^([0-9]*)$/isU', $background['right'])) { |
|
| 2542 | + $background['right'] .= 'mm'; |
|
| 2543 | + } |
|
| 2317 | 2544 | |
| 2318 | 2545 | // convert to mm |
| 2319 | 2546 | $background['top'] = $this->parsingCss->ConvertToMM($background['top'], $this->pdf->getH()); |
@@ -2324,7 +2551,9 @@ discard block |
||
| 2324 | 2551 | // get the background color |
| 2325 | 2552 | $res = false; |
| 2326 | 2553 | $background['color'] = isset($param['backcolor']) ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null; |
| 2327 | - if (!$res) $background['color'] = null; |
|
| 2554 | + if (!$res) { |
|
| 2555 | + $background['color'] = null; |
|
| 2556 | + } |
|
| 2328 | 2557 | |
| 2329 | 2558 | $this->parsingCss->save(); |
| 2330 | 2559 | $this->parsingCss->analyse('PAGE', $param); |
@@ -2337,7 +2566,9 @@ discard block |
||
| 2337 | 2566 | // automatic footer |
| 2338 | 2567 | if (isset($param['footer'])) { |
| 2339 | 2568 | $lst = explode(';', $param['footer']); |
| 2340 | - foreach ($lst as $key => $val) $lst[$key] = trim(strtolower($val)); |
|
| 2569 | + foreach ($lst as $key => $val) { |
|
| 2570 | + $lst[$key] = trim(strtolower($val)); |
|
| 2571 | + } |
|
| 2341 | 2572 | $page = in_array('page', $lst); |
| 2342 | 2573 | $date = in_array('date', $lst); |
| 2343 | 2574 | $hour = in_array('heure', $lst); |
@@ -2371,14 +2602,18 @@ discard block |
||
| 2371 | 2602 | */ |
| 2372 | 2603 | protected function _tag_close_PAGE($param) |
| 2373 | 2604 | { |
| 2374 | - if ($this->_isForOneLine) return false; |
|
| 2605 | + if ($this->_isForOneLine) { |
|
| 2606 | + return false; |
|
| 2607 | + } |
|
| 2375 | 2608 | |
| 2376 | 2609 | $this->_maxH = 0; |
| 2377 | 2610 | |
| 2378 | 2611 | $this->parsingCss->load(); |
| 2379 | 2612 | $this->parsingCss->fontSet(); |
| 2380 | 2613 | |
| 2381 | - if ($this->_debugActif) $this->_DEBUG_add('PAGE '.$this->_page, false); |
|
| 2614 | + if ($this->_debugActif) { |
|
| 2615 | + $this->_DEBUG_add('PAGE '.$this->_page, false); |
|
| 2616 | + } |
|
| 2382 | 2617 | |
| 2383 | 2618 | return true; |
| 2384 | 2619 | } |
@@ -2392,14 +2627,20 @@ discard block |
||
| 2392 | 2627 | */ |
| 2393 | 2628 | protected function _tag_open_PAGE_HEADER($param) |
| 2394 | 2629 | { |
| 2395 | - if ($this->_isForOneLine) return false; |
|
| 2630 | + if ($this->_isForOneLine) { |
|
| 2631 | + return false; |
|
| 2632 | + } |
|
| 2396 | 2633 | |
| 2397 | 2634 | $this->_subHEADER = array(); |
| 2398 | 2635 | for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) { |
| 2399 | 2636 | $action = $this->parsingHtml->code[$this->_parsePos]; |
| 2400 | - if ($action['name']=='page_header') $action['name']='page_header_sub'; |
|
| 2637 | + if ($action['name']=='page_header') { |
|
| 2638 | + $action['name']='page_header_sub'; |
|
| 2639 | + } |
|
| 2401 | 2640 | $this->_subHEADER[] = $action; |
| 2402 | - if (strtolower($action['name'])=='page_header_sub' && $action['close']) break; |
|
| 2641 | + if (strtolower($action['name'])=='page_header_sub' && $action['close']) { |
|
| 2642 | + break; |
|
| 2643 | + } |
|
| 2403 | 2644 | } |
| 2404 | 2645 | |
| 2405 | 2646 | $this->_setPageHeader(); |
@@ -2416,14 +2657,20 @@ discard block |
||
| 2416 | 2657 | */ |
| 2417 | 2658 | protected function _tag_open_PAGE_FOOTER($param) |
| 2418 | 2659 | { |
| 2419 | - if ($this->_isForOneLine) return false; |
|
| 2660 | + if ($this->_isForOneLine) { |
|
| 2661 | + return false; |
|
| 2662 | + } |
|
| 2420 | 2663 | |
| 2421 | 2664 | $this->_subFOOTER = array(); |
| 2422 | 2665 | for ($this->_parsePos; $this->_parsePos<count($this->parsingHtml->code); $this->_parsePos++) { |
| 2423 | 2666 | $action = $this->parsingHtml->code[$this->_parsePos]; |
| 2424 | - if ($action['name']=='page_footer') $action['name']='page_footer_sub'; |
|
| 2667 | + if ($action['name']=='page_footer') { |
|
| 2668 | + $action['name']='page_footer_sub'; |
|
| 2669 | + } |
|
| 2425 | 2670 | $this->_subFOOTER[] = $action; |
| 2426 | - if (strtolower($action['name'])=='page_footer_sub' && $action['close']) break; |
|
| 2671 | + if (strtolower($action['name'])=='page_footer_sub' && $action['close']) { |
|
| 2672 | + break; |
|
| 2673 | + } |
|
| 2427 | 2674 | } |
| 2428 | 2675 | |
| 2429 | 2676 | $this->_setPageFooter(); |
@@ -2439,7 +2686,9 @@ discard block |
||
| 2439 | 2686 | */ |
| 2440 | 2687 | protected function _tag_open_PAGE_HEADER_SUB($param) |
| 2441 | 2688 | { |
| 2442 | - if ($this->_isForOneLine) return false; |
|
| 2689 | + if ($this->_isForOneLine) { |
|
| 2690 | + return false; |
|
| 2691 | + } |
|
| 2443 | 2692 | |
| 2444 | 2693 | // save the current stat |
| 2445 | 2694 | $this->_subSTATES = array(); |
@@ -2484,7 +2733,9 @@ discard block |
||
| 2484 | 2733 | */ |
| 2485 | 2734 | protected function _tag_close_PAGE_HEADER_SUB($param) |
| 2486 | 2735 | { |
| 2487 | - if ($this->_isForOneLine) return false; |
|
| 2736 | + if ($this->_isForOneLine) { |
|
| 2737 | + return false; |
|
| 2738 | + } |
|
| 2488 | 2739 | |
| 2489 | 2740 | $this->parsingCss->load(); |
| 2490 | 2741 | |
@@ -2515,7 +2766,9 @@ discard block |
||
| 2515 | 2766 | */ |
| 2516 | 2767 | protected function _tag_open_PAGE_FOOTER_SUB($param) |
| 2517 | 2768 | { |
| 2518 | - if ($this->_isForOneLine) return false; |
|
| 2769 | + if ($this->_isForOneLine) { |
|
| 2770 | + return false; |
|
| 2771 | + } |
|
| 2519 | 2772 | |
| 2520 | 2773 | // save the current stat |
| 2521 | 2774 | $this->_subSTATES = array(); |
@@ -2569,7 +2822,9 @@ discard block |
||
| 2569 | 2822 | */ |
| 2570 | 2823 | protected function _tag_close_PAGE_FOOTER_SUB($param) |
| 2571 | 2824 | { |
| 2572 | - if ($this->_isForOneLine) return false; |
|
| 2825 | + if ($this->_isForOneLine) { |
|
| 2826 | + return false; |
|
| 2827 | + } |
|
| 2573 | 2828 | |
| 2574 | 2829 | $this->parsingCss->load(); |
| 2575 | 2830 | |
@@ -2599,7 +2854,9 @@ discard block |
||
| 2599 | 2854 | */ |
| 2600 | 2855 | protected function _tag_open_NOBREAK($param) |
| 2601 | 2856 | { |
| 2602 | - if ($this->_isForOneLine) return false; |
|
| 2857 | + if ($this->_isForOneLine) { |
|
| 2858 | + return false; |
|
| 2859 | + } |
|
| 2603 | 2860 | |
| 2604 | 2861 | $this->_maxH = 0; |
| 2605 | 2862 | |
@@ -2634,7 +2891,9 @@ discard block |
||
| 2634 | 2891 | */ |
| 2635 | 2892 | protected function _tag_close_NOBREAK($param) |
| 2636 | 2893 | { |
| 2637 | - if ($this->_isForOneLine) return false; |
|
| 2894 | + if ($this->_isForOneLine) { |
|
| 2895 | + return false; |
|
| 2896 | + } |
|
| 2638 | 2897 | |
| 2639 | 2898 | $this->_maxH = 0; |
| 2640 | 2899 | |
@@ -2651,8 +2910,12 @@ discard block |
||
| 2651 | 2910 | */ |
| 2652 | 2911 | protected function _tag_open_DIV($param, $other = 'div') |
| 2653 | 2912 | { |
| 2654 | - if ($this->_isForOneLine) return false; |
|
| 2655 | - if ($this->_debugActif) $this->_DEBUG_add(strtoupper($other), true); |
|
| 2913 | + if ($this->_isForOneLine) { |
|
| 2914 | + return false; |
|
| 2915 | + } |
|
| 2916 | + if ($this->_debugActif) { |
|
| 2917 | + $this->_DEBUG_add(strtoupper($other), true); |
|
| 2918 | + } |
|
| 2656 | 2919 | |
| 2657 | 2920 | $this->parsingCss->save(); |
| 2658 | 2921 | $this->parsingCss->analyse($other, $param); |
@@ -2660,13 +2923,21 @@ discard block |
||
| 2660 | 2923 | |
| 2661 | 2924 | // for fieldset and legend |
| 2662 | 2925 | if (in_array($other, array('fieldset', 'legend'))) { |
| 2663 | - if (isset($param['moveTop'])) $this->parsingCss->value['margin']['t'] += $param['moveTop']; |
|
| 2664 | - if (isset($param['moveLeft'])) $this->parsingCss->value['margin']['l'] += $param['moveLeft']; |
|
| 2665 | - if (isset($param['moveDown'])) $this->parsingCss->value['margin']['b'] += $param['moveDown']; |
|
| 2926 | + if (isset($param['moveTop'])) { |
|
| 2927 | + $this->parsingCss->value['margin']['t'] += $param['moveTop']; |
|
| 2928 | + } |
|
| 2929 | + if (isset($param['moveLeft'])) { |
|
| 2930 | + $this->parsingCss->value['margin']['l'] += $param['moveLeft']; |
|
| 2931 | + } |
|
| 2932 | + if (isset($param['moveDown'])) { |
|
| 2933 | + $this->parsingCss->value['margin']['b'] += $param['moveDown']; |
|
| 2934 | + } |
|
| 2666 | 2935 | } |
| 2667 | 2936 | |
| 2668 | 2937 | $alignObject = null; |
| 2669 | - if ($this->parsingCss->value['margin-auto']) $alignObject = 'center'; |
|
| 2938 | + if ($this->parsingCss->value['margin-auto']) { |
|
| 2939 | + $alignObject = 'center'; |
|
| 2940 | + } |
|
| 2670 | 2941 | |
| 2671 | 2942 | $marge = array(); |
| 2672 | 2943 | $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03; |
@@ -2752,22 +3023,27 @@ discard block |
||
| 2752 | 3023 | if ( |
| 2753 | 3024 | $w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) && |
| 2754 | 3025 | $this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin()) |
| 2755 | - ) |
|
| 2756 | - $this->_tag_open_BR(array()); |
|
| 3026 | + ) { |
|
| 3027 | + $this->_tag_open_BR(array()); |
|
| 3028 | + } |
|
| 2757 | 3029 | |
| 2758 | 3030 | if ( |
| 2759 | 3031 | ($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) && |
| 2760 | 3032 | ($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) && |
| 2761 | 3033 | !$this->_isInOverflow |
| 2762 | - ) |
|
| 2763 | - $this->_setNewPage(); |
|
| 3034 | + ) { |
|
| 3035 | + $this->_setNewPage(); |
|
| 3036 | + } |
|
| 2764 | 3037 | |
| 2765 | 3038 | $old = $this->parsingCss->getOldValues(); |
| 2766 | 3039 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 2767 | 3040 | |
| 2768 | 3041 | if ($parentWidth>$w) { |
| 2769 | - if ($alignObject=='center') $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 2770 | - else if ($alignObject=='right') $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 3042 | + if ($alignObject=='center') { |
|
| 3043 | + $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 3044 | + } else if ($alignObject=='right') { |
|
| 3045 | + $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 3046 | + } |
|
| 2771 | 3047 | } |
| 2772 | 3048 | |
| 2773 | 3049 | $this->parsingCss->setPosition(); |
@@ -2776,8 +3052,11 @@ discard block |
||
| 2776 | 3052 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 2777 | 3053 | |
| 2778 | 3054 | if ($parentWidth>$w) { |
| 2779 | - if ($alignObject=='center') $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 2780 | - else if ($alignObject=='right') $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 3055 | + if ($alignObject=='center') { |
|
| 3056 | + $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 3057 | + } else if ($alignObject=='right') { |
|
| 3058 | + $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 3059 | + } |
|
| 2781 | 3060 | } |
| 2782 | 3061 | |
| 2783 | 3062 | $this->parsingCss->setPosition(); |
@@ -2826,7 +3105,9 @@ discard block |
||
| 2826 | 3105 | $xCorr = ($this->parsingCss->value['width']-$wReel)*0.5; |
| 2827 | 3106 | break; |
| 2828 | 3107 | } |
| 2829 | - if ($xCorr>0) $xCorr=0; |
|
| 3108 | + if ($xCorr>0) { |
|
| 3109 | + $xCorr=0; |
|
| 3110 | + } |
|
| 2830 | 3111 | switch($this->parsingCss->value['vertical-align']) |
| 2831 | 3112 | { |
| 2832 | 3113 | case 'bottom': |
@@ -2910,7 +3191,9 @@ discard block |
||
| 2910 | 3191 | // get height of LEGEND element and make fieldset corrections |
| 2911 | 3192 | for ($tempPos = $this->_parsePos + 1; $tempPos<count($this->parsingHtml->code); $tempPos++) { |
| 2912 | 3193 | $action = $this->parsingHtml->code[$tempPos]; |
| 2913 | - if ($action['name'] == 'fieldset') break; |
|
| 3194 | + if ($action['name'] == 'fieldset') { |
|
| 3195 | + break; |
|
| 3196 | + } |
|
| 2914 | 3197 | if ($action['name'] == 'legend' && !$action['close']) { |
| 2915 | 3198 | $legendOpenPos = $tempPos; |
| 2916 | 3199 | |
@@ -2923,8 +3206,9 @@ discard block |
||
| 2923 | 3206 | $action = $sub->parsingHtml->code[$sub->_parsePos]; |
| 2924 | 3207 | $sub->_executeAction($action); |
| 2925 | 3208 | |
| 2926 | - if ($action['name'] == 'legend' && $action['close']) |
|
| 2927 | - break; |
|
| 3209 | + if ($action['name'] == 'legend' && $action['close']) { |
|
| 3210 | + break; |
|
| 3211 | + } |
|
| 2928 | 3212 | } |
| 2929 | 3213 | |
| 2930 | 3214 | $legendH = $sub->_maxY; |
@@ -2955,7 +3239,9 @@ discard block |
||
| 2955 | 3239 | */ |
| 2956 | 3240 | protected function _tag_close_DIV($param, $other='div') |
| 2957 | 3241 | { |
| 2958 | - if ($this->_isForOneLine) return false; |
|
| 3242 | + if ($this->_isForOneLine) { |
|
| 3243 | + return false; |
|
| 3244 | + } |
|
| 2959 | 3245 | |
| 2960 | 3246 | if ($this->parsingCss->value['overflow']=='hidden') { |
| 2961 | 3247 | $this->_maxX = $this->parsingCss->value['old_maxX']; |
@@ -2965,8 +3251,9 @@ discard block |
||
| 2965 | 3251 | $this->pdf->clippingPathStop(); |
| 2966 | 3252 | } |
| 2967 | 3253 | |
| 2968 | - if ($this->parsingCss->value['rotate']) |
|
| 2969 | - $this->pdf->stopTransform(); |
|
| 3254 | + if ($this->parsingCss->value['rotate']) { |
|
| 3255 | + $this->pdf->stopTransform(); |
|
| 3256 | + } |
|
| 2970 | 3257 | |
| 2971 | 3258 | $marge = array(); |
| 2972 | 3259 | $marge['l'] = $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['padding']['l']+0.03; |
@@ -3012,8 +3299,12 @@ discard block |
||
| 3012 | 3299 | $this->parsingCss->fontSet(); |
| 3013 | 3300 | $this->_loadMargin(); |
| 3014 | 3301 | |
| 3015 | - if ($block) $this->_tag_open_BR(array()); |
|
| 3016 | - if ($this->_debugActif) $this->_DEBUG_add(strtoupper($other), false); |
|
| 3302 | + if ($block) { |
|
| 3303 | + $this->_tag_open_BR(array()); |
|
| 3304 | + } |
|
| 3305 | + if ($this->_debugActif) { |
|
| 3306 | + $this->_DEBUG_add(strtoupper($other), false); |
|
| 3307 | + } |
|
| 3017 | 3308 | |
| 3018 | 3309 | return true; |
| 3019 | 3310 | } |
@@ -3068,16 +3359,27 @@ discard block |
||
| 3068 | 3359 | $lstBarcode['UPC_A'] = 'UPCA'; |
| 3069 | 3360 | $lstBarcode['CODE39'] = 'C39'; |
| 3070 | 3361 | |
| 3071 | - if (!isset($param['type'])) $param['type'] = 'C39'; |
|
| 3072 | - if (!isset($param['value'])) $param['value'] = 0; |
|
| 3073 | - if (!isset($param['label'])) $param['label'] = 'label'; |
|
| 3074 | - if (!isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3362 | + if (!isset($param['type'])) { |
|
| 3363 | + $param['type'] = 'C39'; |
|
| 3364 | + } |
|
| 3365 | + if (!isset($param['value'])) { |
|
| 3366 | + $param['value'] = 0; |
|
| 3367 | + } |
|
| 3368 | + if (!isset($param['label'])) { |
|
| 3369 | + $param['label'] = 'label'; |
|
| 3370 | + } |
|
| 3371 | + if (!isset($param['style']['color'])) { |
|
| 3372 | + $param['style']['color'] = '#000000'; |
|
| 3373 | + } |
|
| 3075 | 3374 | |
| 3076 | - if ($this->_testIsDeprecated && (isset($param['bar_h']) || isset($param['bar_w']))) |
|
| 3077 | - throw new HTML2PDF_exception(9, array('BARCODE', 'bar_h, bar_w')); |
|
| 3375 | + if ($this->_testIsDeprecated && (isset($param['bar_h']) || isset($param['bar_w']))) { |
|
| 3376 | + throw new HTML2PDF_exception(9, array('BARCODE', 'bar_h, bar_w')); |
|
| 3377 | + } |
|
| 3078 | 3378 | |
| 3079 | 3379 | $param['type'] = strtoupper($param['type']); |
| 3080 | - if (isset($lstBarcode[$param['type']])) $param['type'] = $lstBarcode[$param['type']]; |
|
| 3380 | + if (isset($lstBarcode[$param['type']])) { |
|
| 3381 | + $param['type'] = $lstBarcode[$param['type']]; |
|
| 3382 | + } |
|
| 3081 | 3383 | |
| 3082 | 3384 | $this->parsingCss->save(); |
| 3083 | 3385 | $this->parsingCss->analyse('barcode', $param); |
@@ -3086,8 +3388,12 @@ discard block |
||
| 3086 | 3388 | |
| 3087 | 3389 | $x = $this->pdf->getX(); |
| 3088 | 3390 | $y = $this->pdf->getY(); |
| 3089 | - $w = $this->parsingCss->value['width']; if (!$w) $w = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3090 | - $h = $this->parsingCss->value['height']; if (!$h) $h = $this->parsingCss->ConvertToMM('10mm'); |
|
| 3391 | + $w = $this->parsingCss->value['width']; if (!$w) { |
|
| 3392 | + $w = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3393 | + } |
|
| 3394 | + $h = $this->parsingCss->value['height']; if (!$h) { |
|
| 3395 | + $h = $this->parsingCss->ConvertToMM('10mm'); |
|
| 3396 | + } |
|
| 3091 | 3397 | $txt = ($param['label']!=='none' ? $this->parsingCss->value['font-size'] : false); |
| 3092 | 3398 | $c = $this->parsingCss->value['color']; |
| 3093 | 3399 | $infos = $this->pdf->myBarcode($param['value'], $param['type'], $x, $y, $w, $h, $txt, $c); |
@@ -3128,15 +3434,26 @@ discard block |
||
| 3128 | 3434 | */ |
| 3129 | 3435 | protected function _tag_open_QRCODE($param) |
| 3130 | 3436 | { |
| 3131 | - if ($this->_testIsDeprecated && (isset($param['size']) || isset($param['noborder']))) |
|
| 3132 | - throw new HTML2PDF_exception(9, array('QRCODE', 'size, noborder')); |
|
| 3437 | + if ($this->_testIsDeprecated && (isset($param['size']) || isset($param['noborder']))) { |
|
| 3438 | + throw new HTML2PDF_exception(9, array('QRCODE', 'size, noborder')); |
|
| 3439 | + } |
|
| 3133 | 3440 | |
| 3134 | - if ($this->_debugActif) $this->_DEBUG_add('QRCODE'); |
|
| 3441 | + if ($this->_debugActif) { |
|
| 3442 | + $this->_DEBUG_add('QRCODE'); |
|
| 3443 | + } |
|
| 3135 | 3444 | |
| 3136 | - if (!isset($param['value'])) $param['value'] = ''; |
|
| 3137 | - if (!isset($param['ec'])) $param['ec'] = 'H'; |
|
| 3138 | - if (!isset($param['style']['color'])) $param['style']['color'] = '#000000'; |
|
| 3139 | - if (!isset($param['style']['background-color'])) $param['style']['background-color'] = '#FFFFFF'; |
|
| 3445 | + if (!isset($param['value'])) { |
|
| 3446 | + $param['value'] = ''; |
|
| 3447 | + } |
|
| 3448 | + if (!isset($param['ec'])) { |
|
| 3449 | + $param['ec'] = 'H'; |
|
| 3450 | + } |
|
| 3451 | + if (!isset($param['style']['color'])) { |
|
| 3452 | + $param['style']['color'] = '#000000'; |
|
| 3453 | + } |
|
| 3454 | + if (!isset($param['style']['background-color'])) { |
|
| 3455 | + $param['style']['background-color'] = '#FFFFFF'; |
|
| 3456 | + } |
|
| 3140 | 3457 | if (isset($param['style']['border'])) { |
| 3141 | 3458 | $borders = $param['style']['border']!='none'; |
| 3142 | 3459 | unset($param['style']['border']); |
@@ -3144,8 +3461,12 @@ discard block |
||
| 3144 | 3461 | $borders = true; |
| 3145 | 3462 | } |
| 3146 | 3463 | |
| 3147 | - if ($param['value']==='') return true; |
|
| 3148 | - if (!in_array($param['ec'], array('L', 'M', 'Q', 'H'))) $param['ec'] = 'H'; |
|
| 3464 | + if ($param['value']==='') { |
|
| 3465 | + return true; |
|
| 3466 | + } |
|
| 3467 | + if (!in_array($param['ec'], array('L', 'M', 'Q', 'H'))) { |
|
| 3468 | + $param['ec'] = 'H'; |
|
| 3469 | + } |
|
| 3149 | 3470 | |
| 3150 | 3471 | $this->parsingCss->save(); |
| 3151 | 3472 | $this->parsingCss->analyse('qrcode', $param); |
@@ -3156,7 +3477,9 @@ discard block |
||
| 3156 | 3477 | $y = $this->pdf->getY(); |
| 3157 | 3478 | $w = $this->parsingCss->value['width']; |
| 3158 | 3479 | $h = $this->parsingCss->value['height']; |
| 3159 | - $size = max($w, $h); if (!$size) $size = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3480 | + $size = max($w, $h); if (!$size) { |
|
| 3481 | + $size = $this->parsingCss->ConvertToMM('50mm'); |
|
| 3482 | + } |
|
| 3160 | 3483 | |
| 3161 | 3484 | $style = array( |
| 3162 | 3485 | 'fgcolor' => $this->parsingCss->value['color'], |
@@ -3214,8 +3537,12 @@ discard block |
||
| 3214 | 3537 | $titre = isset($param['title']) ? trim($param['title']) : ''; |
| 3215 | 3538 | $level = isset($param['level']) ? floor($param['level']) : 0; |
| 3216 | 3539 | |
| 3217 | - if ($level<0) $level = 0; |
|
| 3218 | - if ($titre) $this->pdf->Bookmark($titre, $level, -1); |
|
| 3540 | + if ($level<0) { |
|
| 3541 | + $level = 0; |
|
| 3542 | + } |
|
| 3543 | + if ($titre) { |
|
| 3544 | + $this->pdf->Bookmark($titre, $level, -1); |
|
| 3545 | + } |
|
| 3219 | 3546 | |
| 3220 | 3547 | return true; |
| 3221 | 3548 | } |
@@ -3259,12 +3586,13 @@ discard block |
||
| 3259 | 3586 | $txt = str_replace('[[page_cu]]', $this->pdf->getMyNumPage($this->_page), $txt); |
| 3260 | 3587 | |
| 3261 | 3588 | if ($this->parsingCss->value['text-transform']!='none') { |
| 3262 | - if ($this->parsingCss->value['text-transform']=='capitalize') |
|
| 3263 | - $txt = ucwords($txt); |
|
| 3264 | - else if ($this->parsingCss->value['text-transform']=='uppercase') |
|
| 3265 | - $txt = strtoupper($txt); |
|
| 3266 | - else if ($this->parsingCss->value['text-transform']=='lowercase') |
|
| 3267 | - $txt = strtolower($txt); |
|
| 3589 | + if ($this->parsingCss->value['text-transform']=='capitalize') { |
|
| 3590 | + $txt = ucwords($txt); |
|
| 3591 | + } else if ($this->parsingCss->value['text-transform']=='uppercase') { |
|
| 3592 | + $txt = strtoupper($txt); |
|
| 3593 | + } else if ($this->parsingCss->value['text-transform']=='lowercase') { |
|
| 3594 | + $txt = strtolower($txt); |
|
| 3595 | + } |
|
| 3268 | 3596 | } |
| 3269 | 3597 | |
| 3270 | 3598 | // size of the text |
@@ -3320,7 +3648,9 @@ discard block |
||
| 3320 | 3648 | array_shift($words); |
| 3321 | 3649 | $old = $str; |
| 3322 | 3650 | |
| 3323 | - if (!count($words)) break; |
|
| 3651 | + if (!count($words)) { |
|
| 3652 | + break; |
|
| 3653 | + } |
|
| 3324 | 3654 | $str[0].= ' '.$words[0][0]; |
| 3325 | 3655 | $str[1]+= $space+$words[0][1]; |
| 3326 | 3656 | } |
@@ -3337,7 +3667,9 @@ discard block |
||
| 3337 | 3667 | |
| 3338 | 3668 | // write the extract sentence that fit on the page |
| 3339 | 3669 | $wc = ($align=='L' ? $str[1] : $this->parsingCss->value['width']); |
| 3340 | - if ($right - $left<$wc) $wc = $right - $left; |
|
| 3670 | + if ($right - $left<$wc) { |
|
| 3671 | + $wc = $right - $left; |
|
| 3672 | + } |
|
| 3341 | 3673 | |
| 3342 | 3674 | if (strlen($str[0])) { |
| 3343 | 3675 | $this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy); |
@@ -3358,7 +3690,9 @@ discard block |
||
| 3358 | 3690 | // if we have again words to write |
| 3359 | 3691 | if (count($words)) { |
| 3360 | 3692 | // remove the space at the end |
| 3361 | - if ($add) $w-= $space; |
|
| 3693 | + if ($add) { |
|
| 3694 | + $w-= $space; |
|
| 3695 | + } |
|
| 3362 | 3696 | |
| 3363 | 3697 | // if we don't add any word, and if the first word is empty => useless space to skip |
| 3364 | 3698 | if (!$add && $words[0][0]==='') { |
@@ -3393,7 +3727,9 @@ discard block |
||
| 3393 | 3727 | // if more than 10000 line => error |
| 3394 | 3728 | $nb++; |
| 3395 | 3729 | if ($nb>10000) { |
| 3396 | - $txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0]; |
|
| 3730 | + $txt = ''; foreach ($words as $k => $word) { |
|
| 3731 | + $txt.= ($k ? ' ' : '').$word[0]; |
|
| 3732 | + } |
|
| 3397 | 3733 | throw new HTML2PDF_exception(2, array($txt, $right-$left, $w)); |
| 3398 | 3734 | } |
| 3399 | 3735 | |
@@ -3404,7 +3740,9 @@ discard block |
||
| 3404 | 3740 | |
| 3405 | 3741 | // if we have words after automatic cut, it is because they fit on the line => we write the text |
| 3406 | 3742 | if (count($words)) { |
| 3407 | - $txt = ''; foreach ($words as $k => $word) $txt.= ($k ? ' ' : '').$word[0]; |
|
| 3743 | + $txt = ''; foreach ($words as $k => $word) { |
|
| 3744 | + $txt.= ($k ? ' ' : '').$word[0]; |
|
| 3745 | + } |
|
| 3408 | 3746 | $w+= $this->pdf->getWordSpacing()*(count($words)); |
| 3409 | 3747 | $this->pdf->setXY($this->pdf->getX(), $y+$dh+$dy); |
| 3410 | 3748 | $this->pdf->Cell(($align=='L' ? $w : $this->parsingCss->value['width']), $h, $txt, 0, 0, $align, $fill, $this->_isInLink); |
@@ -3432,11 +3770,15 @@ discard block |
||
| 3432 | 3770 | */ |
| 3433 | 3771 | protected function _tag_open_BR($param, $curr = null) |
| 3434 | 3772 | { |
| 3435 | - if ($this->_isForOneLine) return false; |
|
| 3773 | + if ($this->_isForOneLine) { |
|
| 3774 | + return false; |
|
| 3775 | + } |
|
| 3436 | 3776 | |
| 3437 | 3777 | $h = max($this->_maxH, $this->parsingCss->getLineHeight()); |
| 3438 | 3778 | |
| 3439 | - if ($this->_maxH==0) $this->_maxY = max($this->_maxY, $this->pdf->getY()+$h); |
|
| 3779 | + if ($this->_maxH==0) { |
|
| 3780 | + $this->_maxY = max($this->_maxY, $this->pdf->getY()+$h); |
|
| 3781 | + } |
|
| 3440 | 3782 | |
| 3441 | 3783 | $this->_makeBreakLine($h, $curr); |
| 3442 | 3784 | |
@@ -3455,11 +3797,15 @@ discard block |
||
| 3455 | 3797 | */ |
| 3456 | 3798 | protected function _tag_open_HR($param) |
| 3457 | 3799 | { |
| 3458 | - if ($this->_isForOneLine) return false; |
|
| 3800 | + if ($this->_isForOneLine) { |
|
| 3801 | + return false; |
|
| 3802 | + } |
|
| 3459 | 3803 | $oldAlign = $this->parsingCss->value['text-align']; |
| 3460 | 3804 | $this->parsingCss->value['text-align'] = 'left'; |
| 3461 | 3805 | |
| 3462 | - if ($this->_maxH) $this->_tag_open_BR($param); |
|
| 3806 | + if ($this->_maxH) { |
|
| 3807 | + $this->_tag_open_BR($param); |
|
| 3808 | + } |
|
| 3463 | 3809 | |
| 3464 | 3810 | $fontSize = $this->parsingCss->value['font-size']; |
| 3465 | 3811 | $this->parsingCss->value['font-size']=$fontSize*0.5; $this->_tag_open_BR($param); |
@@ -3475,8 +3821,12 @@ discard block |
||
| 3475 | 3821 | $this->parsingCss->fontSet(); |
| 3476 | 3822 | |
| 3477 | 3823 | $h = $this->parsingCss->value['height']; |
| 3478 | - if ($h) $h-= $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width']; |
|
| 3479 | - if ($h<=0) $h = $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width']; |
|
| 3824 | + if ($h) { |
|
| 3825 | + $h-= $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width']; |
|
| 3826 | + } |
|
| 3827 | + if ($h<=0) { |
|
| 3828 | + $h = $this->parsingCss->value['border']['t']['width']+$this->parsingCss->value['border']['b']['width']; |
|
| 3829 | + } |
|
| 3480 | 3830 | |
| 3481 | 3831 | $this->_drawRectangle($this->pdf->getX(), $this->pdf->getY(), $this->parsingCss->value['width'], $h, $this->parsingCss->value['border'], 0, 0, $this->parsingCss->value['background']); |
| 3482 | 3832 | $this->_maxH = $h; |
@@ -3812,7 +4162,9 @@ discard block |
||
| 3812 | 4162 | |
| 3813 | 4163 | if (isset($param['name'])) { |
| 3814 | 4164 | $name = $param['name']; |
| 3815 | - if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 4165 | + if (!isset($this->_lstAnchor[$name])) { |
|
| 4166 | + $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 4167 | + } |
|
| 3816 | 4168 | |
| 3817 | 4169 | if (!$this->_lstAnchor[$name][1]) { |
| 3818 | 4170 | $this->_lstAnchor[$name][1] = true; |
@@ -3822,7 +4174,9 @@ discard block |
||
| 3822 | 4174 | |
| 3823 | 4175 | if (preg_match('/^#([^#]+)$/isU', $this->_isInLink, $match)) { |
| 3824 | 4176 | $name = $match[1]; |
| 3825 | - if (!isset($this->_lstAnchor[$name])) $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 4177 | + if (!isset($this->_lstAnchor[$name])) { |
|
| 4178 | + $this->_lstAnchor[$name] = array($this->pdf->AddLink(), false); |
|
| 4179 | + } |
|
| 3826 | 4180 | |
| 3827 | 4181 | $this->_isInLink = $this->_lstAnchor[$name][0]; |
| 3828 | 4182 | } |
@@ -3863,9 +4217,13 @@ discard block |
||
| 3863 | 4217 | */ |
| 3864 | 4218 | protected function _tag_open_H1($param, $other = 'h1') |
| 3865 | 4219 | { |
| 3866 | - if ($this->_isForOneLine) return false; |
|
| 4220 | + if ($this->_isForOneLine) { |
|
| 4221 | + return false; |
|
| 4222 | + } |
|
| 3867 | 4223 | |
| 3868 | - if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4224 | + if ($this->_maxH) { |
|
| 4225 | + $this->_tag_open_BR(array()); |
|
| 4226 | + } |
|
| 3869 | 4227 | $this->parsingCss->save(); |
| 3870 | 4228 | $this->parsingCss->value['font-bold'] = true; |
| 3871 | 4229 | |
@@ -3953,7 +4311,9 @@ discard block |
||
| 3953 | 4311 | */ |
| 3954 | 4312 | protected function _tag_close_H1($param) |
| 3955 | 4313 | { |
| 3956 | - if ($this->_isForOneLine) return false; |
|
| 4314 | + if ($this->_isForOneLine) { |
|
| 4315 | + return false; |
|
| 4316 | + } |
|
| 3957 | 4317 | |
| 3958 | 4318 | $this->_maxH+= $this->parsingCss->value['margin']['b']; |
| 3959 | 4319 | $h = max($this->_maxH, $this->parsingCss->getLineHeight()); |
@@ -4120,10 +4480,14 @@ discard block |
||
| 4120 | 4480 | */ |
| 4121 | 4481 | protected function _tag_open_P($param) |
| 4122 | 4482 | { |
| 4123 | - if ($this->_isForOneLine) return false; |
|
| 4483 | + if ($this->_isForOneLine) { |
|
| 4484 | + return false; |
|
| 4485 | + } |
|
| 4124 | 4486 | |
| 4125 | 4487 | if (!in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
| 4126 | - if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4488 | + if ($this->_maxH) { |
|
| 4489 | + $this->_tag_open_BR(array()); |
|
| 4490 | + } |
|
| 4127 | 4491 | } |
| 4128 | 4492 | |
| 4129 | 4493 | $this->parsingCss->save(); |
@@ -4160,9 +4524,13 @@ discard block |
||
| 4160 | 4524 | */ |
| 4161 | 4525 | protected function _tag_close_P($param) |
| 4162 | 4526 | { |
| 4163 | - if ($this->_isForOneLine) return false; |
|
| 4527 | + if ($this->_isForOneLine) { |
|
| 4528 | + return false; |
|
| 4529 | + } |
|
| 4164 | 4530 | |
| 4165 | - if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4531 | + if ($this->_maxH) { |
|
| 4532 | + $this->_tag_open_BR(array()); |
|
| 4533 | + } |
|
| 4166 | 4534 | $this->_isInParagraph = false; |
| 4167 | 4535 | $this->_loadMargin(); |
| 4168 | 4536 | $h = $this->parsingCss->value['margin']['b']+$this->parsingCss->value['padding']['b']; |
@@ -4184,7 +4552,9 @@ discard block |
||
| 4184 | 4552 | */ |
| 4185 | 4553 | protected function _tag_open_PRE($param, $other = 'pre') |
| 4186 | 4554 | { |
| 4187 | - if ($other=='pre' && $this->_maxH) $this->_tag_open_BR(array()); |
|
| 4555 | + if ($other=='pre' && $this->_maxH) { |
|
| 4556 | + $this->_tag_open_BR(array()); |
|
| 4557 | + } |
|
| 4188 | 4558 | |
| 4189 | 4559 | $this->parsingCss->save(); |
| 4190 | 4560 | $this->parsingCss->value['font-family'] = 'courier'; |
@@ -4192,7 +4562,9 @@ discard block |
||
| 4192 | 4562 | $this->parsingCss->setPosition(); |
| 4193 | 4563 | $this->parsingCss->fontSet(); |
| 4194 | 4564 | |
| 4195 | - if ($other=='pre') return $this->_tag_open_DIV($param, $other); |
|
| 4565 | + if ($other=='pre') { |
|
| 4566 | + return $this->_tag_open_DIV($param, $other); |
|
| 4567 | + } |
|
| 4196 | 4568 | |
| 4197 | 4569 | return true; |
| 4198 | 4570 | } |
@@ -4221,7 +4593,9 @@ discard block |
||
| 4221 | 4593 | protected function _tag_close_PRE($param, $other = 'pre') |
| 4222 | 4594 | { |
| 4223 | 4595 | if ($other=='pre') { |
| 4224 | - if ($this->_isForOneLine) return false; |
|
| 4596 | + if ($this->_isForOneLine) { |
|
| 4597 | + return false; |
|
| 4598 | + } |
|
| 4225 | 4599 | |
| 4226 | 4600 | $this->_tag_close_DIV($param, $other); |
| 4227 | 4601 | $this->_tag_open_BR(array()); |
@@ -4387,14 +4761,22 @@ discard block |
||
| 4387 | 4761 | */ |
| 4388 | 4762 | protected function _tag_open_UL($param, $other = 'ul') |
| 4389 | 4763 | { |
| 4390 | - if ($this->_isForOneLine) return false; |
|
| 4764 | + if ($this->_isForOneLine) { |
|
| 4765 | + return false; |
|
| 4766 | + } |
|
| 4391 | 4767 | |
| 4392 | 4768 | if (!in_array($this->_previousCall, array('_tag_close_P', '_tag_close_UL'))) { |
| 4393 | - if ($this->_maxH) $this->_tag_open_BR(array()); |
|
| 4394 | - if (!count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4769 | + if ($this->_maxH) { |
|
| 4770 | + $this->_tag_open_BR(array()); |
|
| 4771 | + } |
|
| 4772 | + if (!count($this->_defList)) { |
|
| 4773 | + $this->_tag_open_BR(array()); |
|
| 4774 | + } |
|
| 4395 | 4775 | } |
| 4396 | 4776 | |
| 4397 | - if (!isset($param['style']['width'])) $param['allwidth'] = true; |
|
| 4777 | + if (!isset($param['style']['width'])) { |
|
| 4778 | + $param['allwidth'] = true; |
|
| 4779 | + } |
|
| 4398 | 4780 | $param['cellspacing'] = 0; |
| 4399 | 4781 | |
| 4400 | 4782 | // a list is like a table |
@@ -4427,14 +4809,18 @@ discard block |
||
| 4427 | 4809 | */ |
| 4428 | 4810 | protected function _tag_close_UL($param) |
| 4429 | 4811 | { |
| 4430 | - if ($this->_isForOneLine) return false; |
|
| 4812 | + if ($this->_isForOneLine) { |
|
| 4813 | + return false; |
|
| 4814 | + } |
|
| 4431 | 4815 | |
| 4432 | 4816 | $this->_tag_close_TABLE($param); |
| 4433 | 4817 | |
| 4434 | 4818 | $this->_listeDelLevel(); |
| 4435 | 4819 | |
| 4436 | 4820 | if (!$this->_subPart) { |
| 4437 | - if (!count($this->_defList)) $this->_tag_open_BR(array()); |
|
| 4821 | + if (!count($this->_defList)) { |
|
| 4822 | + $this->_tag_open_BR(array()); |
|
| 4823 | + } |
|
| 4438 | 4824 | } |
| 4439 | 4825 | |
| 4440 | 4826 | return true; |
@@ -4461,11 +4847,15 @@ discard block |
||
| 4461 | 4847 | */ |
| 4462 | 4848 | protected function _tag_open_LI($param) |
| 4463 | 4849 | { |
| 4464 | - if ($this->_isForOneLine) return false; |
|
| 4850 | + if ($this->_isForOneLine) { |
|
| 4851 | + return false; |
|
| 4852 | + } |
|
| 4465 | 4853 | |
| 4466 | 4854 | $this->_listeAddLi(); |
| 4467 | 4855 | |
| 4468 | - if (!isset($param['style']['width'])) $param['style']['width'] = '100%'; |
|
| 4856 | + if (!isset($param['style']['width'])) { |
|
| 4857 | + $param['style']['width'] = '100%'; |
|
| 4858 | + } |
|
| 4469 | 4859 | |
| 4470 | 4860 | $paramPUCE = $param; |
| 4471 | 4861 | |
@@ -4519,8 +4909,11 @@ discard block |
||
| 4519 | 4909 | // TD for the puce |
| 4520 | 4910 | $this->_tag_open_TD($paramPUCE, 'li_sub'); |
| 4521 | 4911 | unset($paramPUCE['style']['width']); |
| 4522 | - if (isset($paramPUCE['src'])) $this->_tag_open_IMG($paramPUCE); |
|
| 4523 | - else $this->_tag_open_WRITE($paramPUCE); |
|
| 4912 | + if (isset($paramPUCE['src'])) { |
|
| 4913 | + $this->_tag_open_IMG($paramPUCE); |
|
| 4914 | + } else { |
|
| 4915 | + $this->_tag_open_WRITE($paramPUCE); |
|
| 4916 | + } |
|
| 4524 | 4917 | $this->_tag_close_TD($paramPUCE); |
| 4525 | 4918 | } |
| 4526 | 4919 | $this->parsingCss->load(); |
@@ -4541,7 +4934,9 @@ discard block |
||
| 4541 | 4934 | */ |
| 4542 | 4935 | protected function _tag_close_LI($param) |
| 4543 | 4936 | { |
| 4544 | - if ($this->_isForOneLine) return false; |
|
| 4937 | + if ($this->_isForOneLine) { |
|
| 4938 | + return false; |
|
| 4939 | + } |
|
| 4545 | 4940 | |
| 4546 | 4941 | $this->_tag_close_TD($param); |
| 4547 | 4942 | |
@@ -4559,7 +4954,9 @@ discard block |
||
| 4559 | 4954 | */ |
| 4560 | 4955 | protected function _tag_open_TBODY($param) |
| 4561 | 4956 | { |
| 4562 | - if ($this->_isForOneLine) return false; |
|
| 4957 | + if ($this->_isForOneLine) { |
|
| 4958 | + return false; |
|
| 4959 | + } |
|
| 4563 | 4960 | |
| 4564 | 4961 | $this->parsingCss->save(); |
| 4565 | 4962 | $this->parsingCss->analyse('tbody', $param); |
@@ -4578,7 +4975,9 @@ discard block |
||
| 4578 | 4975 | */ |
| 4579 | 4976 | protected function _tag_close_TBODY($param) |
| 4580 | 4977 | { |
| 4581 | - if ($this->_isForOneLine) return false; |
|
| 4978 | + if ($this->_isForOneLine) { |
|
| 4979 | + return false; |
|
| 4980 | + } |
|
| 4582 | 4981 | |
| 4583 | 4982 | $this->parsingCss->load(); |
| 4584 | 4983 | $this->parsingCss->fontSet(); |
@@ -4595,7 +4994,9 @@ discard block |
||
| 4595 | 4994 | */ |
| 4596 | 4995 | protected function _tag_open_THEAD($param) |
| 4597 | 4996 | { |
| 4598 | - if ($this->_isForOneLine) return false; |
|
| 4997 | + if ($this->_isForOneLine) { |
|
| 4998 | + return false; |
|
| 4999 | + } |
|
| 4599 | 5000 | |
| 4600 | 5001 | $this->parsingCss->save(); |
| 4601 | 5002 | $this->parsingCss->analyse('thead', $param); |
@@ -4608,9 +5009,13 @@ discard block |
||
| 4608 | 5009 | HTML2PDF::$_tables[$param['num']]['thead']['code'] = array(); |
| 4609 | 5010 | for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) { |
| 4610 | 5011 | $action = $this->parsingHtml->code[$pos]; |
| 4611 | - if (strtolower($action['name'])=='thead') $action['name'] = 'thead_sub'; |
|
| 5012 | + if (strtolower($action['name'])=='thead') { |
|
| 5013 | + $action['name'] = 'thead_sub'; |
|
| 5014 | + } |
|
| 4612 | 5015 | HTML2PDF::$_tables[$param['num']]['thead']['code'][] = $action; |
| 4613 | - if (strtolower($action['name'])=='thead_sub' && $action['close']) break; |
|
| 5016 | + if (strtolower($action['name'])=='thead_sub' && $action['close']) { |
|
| 5017 | + break; |
|
| 5018 | + } |
|
| 4614 | 5019 | } |
| 4615 | 5020 | } else { |
| 4616 | 5021 | $level = $this->parsingHtml->getLevel($this->_parsePos); |
@@ -4630,7 +5035,9 @@ discard block |
||
| 4630 | 5035 | */ |
| 4631 | 5036 | protected function _tag_close_THEAD($param) |
| 4632 | 5037 | { |
| 4633 | - if ($this->_isForOneLine) return false; |
|
| 5038 | + if ($this->_isForOneLine) { |
|
| 5039 | + return false; |
|
| 5040 | + } |
|
| 4634 | 5041 | |
| 4635 | 5042 | $this->parsingCss->load(); |
| 4636 | 5043 | $this->parsingCss->fontSet(); |
@@ -4654,7 +5061,9 @@ discard block |
||
| 4654 | 5061 | */ |
| 4655 | 5062 | protected function _tag_open_TFOOT($param) |
| 4656 | 5063 | { |
| 4657 | - if ($this->_isForOneLine) return false; |
|
| 5064 | + if ($this->_isForOneLine) { |
|
| 5065 | + return false; |
|
| 5066 | + } |
|
| 4658 | 5067 | |
| 4659 | 5068 | $this->parsingCss->save(); |
| 4660 | 5069 | $this->parsingCss->analyse('tfoot', $param); |
@@ -4667,9 +5076,13 @@ discard block |
||
| 4667 | 5076 | HTML2PDF::$_tables[$param['num']]['tfoot']['code'] = array(); |
| 4668 | 5077 | for ($pos=$this->_tempPos; $pos<count($this->parsingHtml->code); $pos++) { |
| 4669 | 5078 | $action = $this->parsingHtml->code[$pos]; |
| 4670 | - if (strtolower($action['name'])=='tfoot') $action['name'] = 'tfoot_sub'; |
|
| 5079 | + if (strtolower($action['name'])=='tfoot') { |
|
| 5080 | + $action['name'] = 'tfoot_sub'; |
|
| 5081 | + } |
|
| 4671 | 5082 | HTML2PDF::$_tables[$param['num']]['tfoot']['code'][] = $action; |
| 4672 | - if (strtolower($action['name'])=='tfoot_sub' && $action['close']) break; |
|
| 5083 | + if (strtolower($action['name'])=='tfoot_sub' && $action['close']) { |
|
| 5084 | + break; |
|
| 5085 | + } |
|
| 4673 | 5086 | } |
| 4674 | 5087 | } else { |
| 4675 | 5088 | $level = $this->parsingHtml->getLevel($this->_parsePos); |
@@ -4689,7 +5102,9 @@ discard block |
||
| 4689 | 5102 | */ |
| 4690 | 5103 | protected function _tag_close_TFOOT($param) |
| 4691 | 5104 | { |
| 4692 | - if ($this->_isForOneLine) return false; |
|
| 5105 | + if ($this->_isForOneLine) { |
|
| 5106 | + return false; |
|
| 5107 | + } |
|
| 4693 | 5108 | |
| 4694 | 5109 | $this->parsingCss->load(); |
| 4695 | 5110 | $this->parsingCss->fontSet(); |
@@ -4712,7 +5127,9 @@ discard block |
||
| 4712 | 5127 | */ |
| 4713 | 5128 | protected function _tag_open_THEAD_SUB($param) |
| 4714 | 5129 | { |
| 4715 | - if ($this->_isForOneLine) return false; |
|
| 5130 | + if ($this->_isForOneLine) { |
|
| 5131 | + return false; |
|
| 5132 | + } |
|
| 4716 | 5133 | |
| 4717 | 5134 | $this->parsingCss->save(); |
| 4718 | 5135 | $this->parsingCss->analyse('thead', $param); |
@@ -4730,7 +5147,9 @@ discard block |
||
| 4730 | 5147 | */ |
| 4731 | 5148 | protected function _tag_close_THEAD_SUB($param) |
| 4732 | 5149 | { |
| 4733 | - if ($this->_isForOneLine) return false; |
|
| 5150 | + if ($this->_isForOneLine) { |
|
| 5151 | + return false; |
|
| 5152 | + } |
|
| 4734 | 5153 | |
| 4735 | 5154 | $this->parsingCss->load(); |
| 4736 | 5155 | $this->parsingCss->fontSet(); |
@@ -4746,7 +5165,9 @@ discard block |
||
| 4746 | 5165 | */ |
| 4747 | 5166 | protected function _tag_open_TFOOT_SUB($param) |
| 4748 | 5167 | { |
| 4749 | - if ($this->_isForOneLine) return false; |
|
| 5168 | + if ($this->_isForOneLine) { |
|
| 5169 | + return false; |
|
| 5170 | + } |
|
| 4750 | 5171 | |
| 4751 | 5172 | $this->parsingCss->save(); |
| 4752 | 5173 | $this->parsingCss->analyse('tfoot', $param); |
@@ -4764,7 +5185,9 @@ discard block |
||
| 4764 | 5185 | */ |
| 4765 | 5186 | protected function _tag_close_TFOOT_SUB($param) |
| 4766 | 5187 | { |
| 4767 | - if ($this->_isForOneLine) return false; |
|
| 5188 | + if ($this->_isForOneLine) { |
|
| 5189 | + return false; |
|
| 5190 | + } |
|
| 4768 | 5191 | |
| 4769 | 5192 | $this->parsingCss->load(); |
| 4770 | 5193 | $this->parsingCss->fontSet(); |
@@ -4826,7 +5249,9 @@ discard block |
||
| 4826 | 5249 | protected function _tag_open_TABLE($param, $other = 'table') |
| 4827 | 5250 | { |
| 4828 | 5251 | if ($this->_maxH) { |
| 4829 | - if ($this->_isForOneLine) return false; |
|
| 5252 | + if ($this->_isForOneLine) { |
|
| 5253 | + return false; |
|
| 5254 | + } |
|
| 4830 | 5255 | $this->_tag_open_BR(array()); |
| 4831 | 5256 | } |
| 4832 | 5257 | |
@@ -4838,15 +5263,21 @@ discard block |
||
| 4838 | 5263 | $this->_maxH = 0; |
| 4839 | 5264 | |
| 4840 | 5265 | $alignObject = isset($param['align']) ? strtolower($param['align']) : 'left'; |
| 4841 | - if (isset($param['align'])) unset($param['align']); |
|
| 4842 | - if (!in_array($alignObject, array('left', 'center', 'right'))) $alignObject = 'left'; |
|
| 5266 | + if (isset($param['align'])) { |
|
| 5267 | + unset($param['align']); |
|
| 5268 | + } |
|
| 5269 | + if (!in_array($alignObject, array('left', 'center', 'right'))) { |
|
| 5270 | + $alignObject = 'left'; |
|
| 5271 | + } |
|
| 4843 | 5272 | |
| 4844 | 5273 | $this->parsingCss->save(); |
| 4845 | 5274 | $this->parsingCss->analyse($other, $param); |
| 4846 | 5275 | $this->parsingCss->setPosition(); |
| 4847 | 5276 | $this->parsingCss->fontSet(); |
| 4848 | 5277 | |
| 4849 | - if ($this->parsingCss->value['margin-auto']) $alignObject = 'center'; |
|
| 5278 | + if ($this->parsingCss->value['margin-auto']) { |
|
| 5279 | + $alignObject = 'center'; |
|
| 5280 | + } |
|
| 4850 | 5281 | |
| 4851 | 5282 | // collapse table ? |
| 4852 | 5283 | $collapse = false; |
@@ -4867,7 +5298,9 @@ discard block |
||
| 4867 | 5298 | |
| 4868 | 5299 | // if we are in a SUB html => prepare the properties of the table |
| 4869 | 5300 | if ($this->_subPart) { |
| 4870 | - if ($this->_debugActif) $this->_DEBUG_add('Table n'.$param['num'], true); |
|
| 5301 | + if ($this->_debugActif) { |
|
| 5302 | + $this->_DEBUG_add('Table n'.$param['num'], true); |
|
| 5303 | + } |
|
| 4871 | 5304 | HTML2PDF::$_tables[$param['num']] = array(); |
| 4872 | 5305 | HTML2PDF::$_tables[$param['num']]['border'] = isset($param['border']) ? $this->parsingCss->readBorder($param['border']) : null; |
| 4873 | 5306 | HTML2PDF::$_tables[$param['num']]['cellpadding'] = $this->parsingCss->ConvertToMM(isset($param['cellpadding']) ? $param['cellpadding'] : '1px'); |
@@ -4939,7 +5372,9 @@ discard block |
||
| 4939 | 5372 | */ |
| 4940 | 5373 | protected function _tag_close_TABLE($param) |
| 4941 | 5374 | { |
| 4942 | - if ($this->_isForOneLine) return false; |
|
| 5375 | + if ($this->_isForOneLine) { |
|
| 5376 | + return false; |
|
| 5377 | + } |
|
| 4943 | 5378 | |
| 4944 | 5379 | $this->_maxH = 0; |
| 4945 | 5380 | |
@@ -4955,9 +5390,10 @@ discard block |
||
| 4955 | 5390 | foreach (HTML2PDF::$_tables[$param['num']][$mode]['tr'] as $tr) { |
| 4956 | 5391 | // hauteur de la ligne tr |
| 4957 | 5392 | $h = 0; |
| 4958 | - for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++) |
|
| 4959 | - if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan']==1) |
|
| 5393 | + for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$tr]); $i++) { |
|
| 5394 | + if (HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['rowspan']==1) |
|
| 4960 | 5395 | $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$tr][$i]['h']); |
| 5396 | + } |
|
| 4961 | 5397 | HTML2PDF::$_tables[$param['num']][$mode]['height']+= $h; |
| 4962 | 5398 | } |
| 4963 | 5399 | } |
@@ -4976,10 +5412,11 @@ discard block |
||
| 4976 | 5412 | $x = HTML2PDF::$_tables[$param['num']]['curr_x']; |
| 4977 | 5413 | $w = HTML2PDF::$_tables[$param['num']]['width']; |
| 4978 | 5414 | if ($parentWidth>$w) { |
| 4979 | - if (HTML2PDF::$_tables[$param['num']]['align']=='center') |
|
| 4980 | - $x = $x + ($parentWidth-$w)*0.5; |
|
| 4981 | - else if (HTML2PDF::$_tables[$param['num']]['align']=='right') |
|
| 4982 | - $x = $x + $parentWidth-$w; |
|
| 5415 | + if (HTML2PDF::$_tables[$param['num']]['align']=='center') { |
|
| 5416 | + $x = $x + ($parentWidth-$w)*0.5; |
|
| 5417 | + } else if (HTML2PDF::$_tables[$param['num']]['align']=='right') { |
|
| 5418 | + $x = $x + $parentWidth-$w; |
|
| 5419 | + } |
|
| 4983 | 5420 | |
| 4984 | 5421 | HTML2PDF::$_tables[$param['num']]['curr_x'] = $x; |
| 4985 | 5422 | } |
@@ -5002,8 +5439,12 @@ discard block |
||
| 5002 | 5439 | for ($k=0; $k<count(HTML2PDF::$_tables[$param['num']]['cases']); $k++) { |
| 5003 | 5440 | |
| 5004 | 5441 | // if it is a TR of the thead or of the tfoot => skip |
| 5005 | - if (in_array($k, HTML2PDF::$_tables[$param['num']]['thead']['tr'])) continue; |
|
| 5006 | - if (in_array($k, HTML2PDF::$_tables[$param['num']]['tfoot']['tr'])) continue; |
|
| 5442 | + if (in_array($k, HTML2PDF::$_tables[$param['num']]['thead']['tr'])) { |
|
| 5443 | + continue; |
|
| 5444 | + } |
|
| 5445 | + if (in_array($k, HTML2PDF::$_tables[$param['num']]['tfoot']['tr'])) { |
|
| 5446 | + continue; |
|
| 5447 | + } |
|
| 5007 | 5448 | |
| 5008 | 5449 | // height of the line |
| 5009 | 5450 | $th = 0; |
@@ -5011,13 +5452,16 @@ discard block |
||
| 5011 | 5452 | for ($i=0; $i<count(HTML2PDF::$_tables[$param['num']]['cases'][$k]); $i++) { |
| 5012 | 5453 | $h = max($h, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
| 5013 | 5454 | |
| 5014 | - if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan']==1) |
|
| 5015 | - $th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
|
| 5455 | + if (HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['rowspan']==1) { |
|
| 5456 | + $th = max($th, HTML2PDF::$_tables[$param['num']]['cases'][$k][$i]['h']); |
|
| 5457 | + } |
|
| 5016 | 5458 | } |
| 5017 | 5459 | |
| 5018 | 5460 | // if the row does not fit on the page => new page |
| 5019 | 5461 | if ($y+$h+$height>$max) { |
| 5020 | - if ($height==$h0) $height = null; |
|
| 5462 | + if ($height==$h0) { |
|
| 5463 | + $height = null; |
|
| 5464 | + } |
|
| 5021 | 5465 | HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
| 5022 | 5466 | $height = $h0; |
| 5023 | 5467 | $y = $this->_margeTop; |
@@ -5026,7 +5470,9 @@ discard block |
||
| 5026 | 5470 | } |
| 5027 | 5471 | |
| 5028 | 5472 | // if ther is a height at the end, add it |
| 5029 | - if ($height!=$h0 || $k==0) HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
|
| 5473 | + if ($height!=$h0 || $k==0) { |
|
| 5474 | + HTML2PDF::$_tables[$param['num']]['height'][] = $height; |
|
| 5475 | + } |
|
| 5030 | 5476 | } else { |
| 5031 | 5477 | // if we have tfoor, draw it |
| 5032 | 5478 | if (count(HTML2PDF::$_tables[$param['num']]['tfoot']['code'])) { |
@@ -5051,12 +5497,13 @@ discard block |
||
| 5051 | 5497 | |
| 5052 | 5498 | // get the positions of the end of the table |
| 5053 | 5499 | $x = HTML2PDF::$_tables[$param['num']]['curr_x'] + HTML2PDF::$_tables[$param['num']]['width']; |
| 5054 | - if (count(HTML2PDF::$_tables[$param['num']]['height'])>1) |
|
| 5055 | - $y = $this->_margeTop+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1]; |
|
| 5056 | - else if (count(HTML2PDF::$_tables[$param['num']]['height'])==1) |
|
| 5057 | - $y = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1]; |
|
| 5058 | - else |
|
| 5059 | - $y = HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 5500 | + if (count(HTML2PDF::$_tables[$param['num']]['height'])>1) { |
|
| 5501 | + $y = $this->_margeTop+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1]; |
|
| 5502 | + } else if (count(HTML2PDF::$_tables[$param['num']]['height'])==1) { |
|
| 5503 | + $y = HTML2PDF::$_tables[$param['num']]['curr_y']+HTML2PDF::$_tables[$param['num']]['height'][count(HTML2PDF::$_tables[$param['num']]['height'])-1]; |
|
| 5504 | + } else { |
|
| 5505 | + $y = HTML2PDF::$_tables[$param['num']]['curr_y']; |
|
| 5506 | + } |
|
| 5060 | 5507 | |
| 5061 | 5508 | $this->_maxX = max($this->_maxX, $x); |
| 5062 | 5509 | $this->_maxY = max($this->_maxY, $y); |
@@ -5065,7 +5512,9 @@ discard block |
||
| 5065 | 5512 | |
| 5066 | 5513 | $this->_loadMargin(); |
| 5067 | 5514 | |
| 5068 | - if ($this->_debugActif) $this->_DEBUG_add('Table '.$param['num'], false); |
|
| 5515 | + if ($this->_debugActif) { |
|
| 5516 | + $this->_DEBUG_add('Table '.$param['num'], false); |
|
| 5517 | + } |
|
| 5069 | 5518 | } |
| 5070 | 5519 | |
| 5071 | 5520 | $this->parsingCss->load(); |
@@ -5085,8 +5534,9 @@ discard block |
||
| 5085 | 5534 | protected function _tag_open_COL($param) |
| 5086 | 5535 | { |
| 5087 | 5536 | $span = isset($param['span']) ? $param['span'] : 1; |
| 5088 | - for ($k=0; $k<$span; $k++) |
|
| 5089 | - HTML2PDF::$_tables[$param['num']]['cols'][] = $param; |
|
| 5537 | + for ($k=0; $k<$span; $k++) { |
|
| 5538 | + HTML2PDF::$_tables[$param['num']]['cols'][] = $param; |
|
| 5539 | + } |
|
| 5090 | 5540 | } |
| 5091 | 5541 | |
| 5092 | 5542 | /** |
@@ -5112,7 +5562,9 @@ discard block |
||
| 5112 | 5562 | */ |
| 5113 | 5563 | protected function _tag_open_TR($param, $other = 'tr') |
| 5114 | 5564 | { |
| 5115 | - if ($this->_isForOneLine) return false; |
|
| 5565 | + if ($this->_isForOneLine) { |
|
| 5566 | + return false; |
|
| 5567 | + } |
|
| 5116 | 5568 | |
| 5117 | 5569 | $this->_maxH = 0; |
| 5118 | 5570 | |
@@ -5216,12 +5668,14 @@ discard block |
||
| 5216 | 5668 | } else { |
| 5217 | 5669 | // prepare it |
| 5218 | 5670 | HTML2PDF::$_tables[$param['num']]['cases'][HTML2PDF::$_tables[$param['num']]['tr_curr']-1] = array(); |
| 5219 | - if (!isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']])) |
|
| 5220 | - HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array(); |
|
| 5671 | + if (!isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']])) { |
|
| 5672 | + HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']] = array(); |
|
| 5673 | + } |
|
| 5221 | 5674 | |
| 5222 | 5675 | HTML2PDF::$_tables[$param['num']]['corr_x']=0; |
| 5223 | - while(isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) |
|
| 5224 | - HTML2PDF::$_tables[$param['num']]['corr_x']++; |
|
| 5676 | + while(isset(HTML2PDF::$_tables[$param['num']]['corr'][HTML2PDF::$_tables[$param['num']]['corr_y']][HTML2PDF::$_tables[$param['num']]['corr_x']])) { |
|
| 5677 | + HTML2PDF::$_tables[$param['num']]['corr_x']++; |
|
| 5678 | + } |
|
| 5225 | 5679 | } |
| 5226 | 5680 | |
| 5227 | 5681 | return true; |
@@ -5236,7 +5690,9 @@ discard block |
||
| 5236 | 5690 | */ |
| 5237 | 5691 | protected function _tag_close_TR($param) |
| 5238 | 5692 | { |
| 5239 | - if ($this->_isForOneLine) return false; |
|
| 5693 | + if ($this->_isForOneLine) { |
|
| 5694 | + return false; |
|
| 5695 | + } |
|
| 5240 | 5696 | |
| 5241 | 5697 | $this->_maxH = 0; |
| 5242 | 5698 | |
@@ -5274,7 +5730,9 @@ discard block |
||
| 5274 | 5730 | */ |
| 5275 | 5731 | protected function _tag_open_TD($param, $other = 'td') |
| 5276 | 5732 | { |
| 5277 | - if ($this->_isForOneLine) return false; |
|
| 5733 | + if ($this->_isForOneLine) { |
|
| 5734 | + return false; |
|
| 5735 | + } |
|
| 5278 | 5736 | |
| 5279 | 5737 | $this->_maxH = 0; |
| 5280 | 5738 | |
@@ -5329,10 +5787,11 @@ discard block |
||
| 5329 | 5787 | if (count($colParam['style']['width'])) { |
| 5330 | 5788 | $total = $colParam['style']['width'][0]; unset($colParam['style']['width'][0]); |
| 5331 | 5789 | foreach ($colParam['style']['width'] as $width) { |
| 5332 | - if (substr($total, -1)=='%' && substr($width, -1)=='%') |
|
| 5333 | - $total = (str_replace('%', '', $total)+str_replace('%', '', $width)).'%'; |
|
| 5334 | - else |
|
| 5335 | - $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm'; |
|
| 5790 | + if (substr($total, -1)=='%' && substr($width, -1)=='%') { |
|
| 5791 | + $total = (str_replace('%', '', $total)+str_replace('%', '', $width)).'%'; |
|
| 5792 | + } else { |
|
| 5793 | + $total = ($this->parsingCss->ConvertToMM($total, $last) + $this->parsingCss->ConvertToMM($width, $last)).'mm'; |
|
| 5794 | + } |
|
| 5336 | 5795 | } |
| 5337 | 5796 | } |
| 5338 | 5797 | |
@@ -5364,8 +5823,9 @@ discard block |
||
| 5364 | 5823 | $legacy = array(); |
| 5365 | 5824 | |
| 5366 | 5825 | $old = $this->parsingCss->getLastValue('background'); |
| 5367 | - if ($old && ($old['color'] || $old['image'])) |
|
| 5368 | - $legacy['background'] = $old; |
|
| 5826 | + if ($old && ($old['color'] || $old['image'])) { |
|
| 5827 | + $legacy['background'] = $old; |
|
| 5828 | + } |
|
| 5369 | 5829 | |
| 5370 | 5830 | if (HTML2PDF::$_tables[$param['num']]['border']) { |
| 5371 | 5831 | $legacy['border'] = array(); |
@@ -5396,7 +5856,9 @@ discard block |
||
| 5396 | 5856 | } |
| 5397 | 5857 | |
| 5398 | 5858 | if (HTML2PDF::$_tables[$param['num']]['td_curr']>0) { |
| 5399 | - if (!$return) $this->parsingCss->value['width']+= $this->parsingCss->value['border']['l']['width']; |
|
| 5859 | + if (!$return) { |
|
| 5860 | + $this->parsingCss->value['width']+= $this->parsingCss->value['border']['l']['width']; |
|
| 5861 | + } |
|
| 5400 | 5862 | $this->parsingCss->value['border']['l'] = $this->parsingCss->readBorder('none'); |
| 5401 | 5863 | } |
| 5402 | 5864 | } |
@@ -5502,7 +5964,9 @@ discard block |
||
| 5502 | 5964 | */ |
| 5503 | 5965 | protected function _tag_close_TD($param) |
| 5504 | 5966 | { |
| 5505 | - if ($this->_isForOneLine) return false; |
|
| 5967 | + if ($this->_isForOneLine) { |
|
| 5968 | + return false; |
|
| 5969 | + } |
|
| 5506 | 5970 | |
| 5507 | 5971 | $this->_maxH = 0; |
| 5508 | 5972 | |
@@ -5565,7 +6029,9 @@ discard block |
||
| 5565 | 6029 | */ |
| 5566 | 6030 | protected function _tag_open_TH($param) |
| 5567 | 6031 | { |
| 5568 | - if ($this->_isForOneLine) return false; |
|
| 6032 | + if ($this->_isForOneLine) { |
|
| 6033 | + return false; |
|
| 6034 | + } |
|
| 5569 | 6035 | |
| 5570 | 6036 | $this->parsingCss->save(); |
| 5571 | 6037 | $this->parsingCss->value['font-bold'] = true; |
@@ -5584,7 +6050,9 @@ discard block |
||
| 5584 | 6050 | */ |
| 5585 | 6051 | protected function _tag_close_TH($param) |
| 5586 | 6052 | { |
| 5587 | - if ($this->_isForOneLine) return false; |
|
| 6053 | + if ($this->_isForOneLine) { |
|
| 6054 | + return false; |
|
| 6055 | + } |
|
| 5588 | 6056 | |
| 5589 | 6057 | $this->_tag_close_TD($param); |
| 5590 | 6058 | |
@@ -5614,7 +6082,9 @@ discard block |
||
| 5614 | 6082 | $this->parsingCss->fontSet(); |
| 5615 | 6083 | |
| 5616 | 6084 | $res = $this->_drawImage($src, isset($param['sub_li'])); |
| 5617 | - if (!$res) return $res; |
|
| 6085 | + if (!$res) { |
|
| 6086 | + return $res; |
|
| 6087 | + } |
|
| 5618 | 6088 | |
| 5619 | 6089 | $this->parsingCss->load(); |
| 5620 | 6090 | $this->parsingCss->fontSet(); |
@@ -5655,7 +6125,9 @@ discard block |
||
| 5655 | 6125 | $this->_lstSelect['size'] = isset($param['size']) ? $param['size'] : 1; |
| 5656 | 6126 | $this->_lstSelect['options'] = array(); |
| 5657 | 6127 | |
| 5658 | - if ($this->_lstSelect['multi'] && $this->_lstSelect['size']<3) $this->_lstSelect['size'] = 3; |
|
| 6128 | + if ($this->_lstSelect['multi'] && $this->_lstSelect['size']<3) { |
|
| 6129 | + $this->_lstSelect['size'] = 3; |
|
| 6130 | + } |
|
| 5659 | 6131 | |
| 5660 | 6132 | return true; |
| 5661 | 6133 | } |
@@ -5708,7 +6180,9 @@ discard block |
||
| 5708 | 6180 | $f = 1.08*$this->parsingCss->value['font-size']; |
| 5709 | 6181 | |
| 5710 | 6182 | // width |
| 5711 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 50; |
|
| 6183 | + $w = $this->parsingCss->value['width']; if (!$w) { |
|
| 6184 | + $w = 50; |
|
| 6185 | + } |
|
| 5712 | 6186 | |
| 5713 | 6187 | // height (automatic) |
| 5714 | 6188 | $h = ($f*1.07*$this->_lstSelect['size'] + 1); |
@@ -5821,9 +6295,15 @@ discard block |
||
| 5821 | 6295 | */ |
| 5822 | 6296 | protected function _tag_open_INPUT($param) |
| 5823 | 6297 | { |
| 5824 | - if (!isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->_lstField)+1); |
|
| 5825 | - if (!isset($param['value'])) $param['value'] = ''; |
|
| 5826 | - if (!isset($param['type'])) $param['type'] = 'text'; |
|
| 6298 | + if (!isset($param['name'])) { |
|
| 6299 | + $param['name'] = 'champs_pdf_'.(count($this->_lstField)+1); |
|
| 6300 | + } |
|
| 6301 | + if (!isset($param['value'])) { |
|
| 6302 | + $param['value'] = ''; |
|
| 6303 | + } |
|
| 6304 | + if (!isset($param['type'])) { |
|
| 6305 | + $param['type'] = 'text'; |
|
| 6306 | + } |
|
| 5827 | 6307 | |
| 5828 | 6308 | $param['name'] = strtolower($param['name']); |
| 5829 | 6309 | $param['type'] = strtolower($param['type']); |
@@ -5857,7 +6337,9 @@ discard block |
||
| 5857 | 6337 | case 'checkbox': |
| 5858 | 6338 | $w = 3; |
| 5859 | 6339 | $h = $w; |
| 5860 | - if ($h<$f) $y+= ($f-$h)*0.5; |
|
| 6340 | + if ($h<$f) { |
|
| 6341 | + $y+= ($f-$h)*0.5; |
|
| 6342 | + } |
|
| 5861 | 6343 | $checked = (isset($param['checked']) && $param['checked']=='checked'); |
| 5862 | 6344 | $this->pdf->CheckBox($name, $w, $checked, $prop, array(), ($param['value'] ? $param['value'] : 'Yes'), $x, $y); |
| 5863 | 6345 | break; |
@@ -5865,7 +6347,9 @@ discard block |
||
| 5865 | 6347 | case 'radio': |
| 5866 | 6348 | $w = 3; |
| 5867 | 6349 | $h = $w; |
| 5868 | - if ($h<$f) $y+= ($f-$h)*0.5; |
|
| 6350 | + if ($h<$f) { |
|
| 6351 | + $y+= ($f-$h)*0.5; |
|
| 6352 | + } |
|
| 5869 | 6353 | $checked = (isset($param['checked']) && $param['checked']=='checked'); |
| 5870 | 6354 | $this->pdf->RadioButton($name, $w, $prop, array(), ($param['value'] ? $param['value'] : 'On'), $checked, $x, $y); |
| 5871 | 6355 | break; |
@@ -5878,29 +6362,43 @@ discard block |
||
| 5878 | 6362 | break; |
| 5879 | 6363 | |
| 5880 | 6364 | case 'text': |
| 5881 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 40; |
|
| 6365 | + $w = $this->parsingCss->value['width']; if (!$w) { |
|
| 6366 | + $w = 40; |
|
| 6367 | + } |
|
| 5882 | 6368 | $h = $f*1.3; |
| 5883 | 6369 | $prop['value'] = $param['value']; |
| 5884 | 6370 | $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y); |
| 5885 | 6371 | break; |
| 5886 | 6372 | |
| 5887 | 6373 | case 'submit': |
| 5888 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 40; |
|
| 5889 | - $h = $this->parsingCss->value['height']; if (!$h) $h = $f*1.3; |
|
| 6374 | + $w = $this->parsingCss->value['width']; if (!$w) { |
|
| 6375 | + $w = 40; |
|
| 6376 | + } |
|
| 6377 | + $h = $this->parsingCss->value['height']; if (!$h) { |
|
| 6378 | + $h = $f*1.3; |
|
| 6379 | + } |
|
| 5890 | 6380 | $action = array('S'=>'SubmitForm', 'F'=>$this->_isInForm, 'Flags'=>array('ExportFormat')); |
| 5891 | 6381 | $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
| 5892 | 6382 | break; |
| 5893 | 6383 | |
| 5894 | 6384 | case 'reset': |
| 5895 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 40; |
|
| 5896 | - $h = $this->parsingCss->value['height']; if (!$h) $h = $f*1.3; |
|
| 6385 | + $w = $this->parsingCss->value['width']; if (!$w) { |
|
| 6386 | + $w = 40; |
|
| 6387 | + } |
|
| 6388 | + $h = $this->parsingCss->value['height']; if (!$h) { |
|
| 6389 | + $h = $f*1.3; |
|
| 6390 | + } |
|
| 5897 | 6391 | $action = array('S'=>'ResetForm'); |
| 5898 | 6392 | $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
| 5899 | 6393 | break; |
| 5900 | 6394 | |
| 5901 | 6395 | case 'button': |
| 5902 | - $w = $this->parsingCss->value['width']; if (!$w) $w = 40; |
|
| 5903 | - $h = $this->parsingCss->value['height']; if (!$h) $h = $f*1.3; |
|
| 6396 | + $w = $this->parsingCss->value['width']; if (!$w) { |
|
| 6397 | + $w = 40; |
|
| 6398 | + } |
|
| 6399 | + $h = $this->parsingCss->value['height']; if (!$h) { |
|
| 6400 | + $h = $f*1.3; |
|
| 6401 | + } |
|
| 5904 | 6402 | $action = isset($param['onclick']) ? $param['onclick'] : ''; |
| 5905 | 6403 | $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y); |
| 5906 | 6404 | break; |
@@ -5932,15 +6430,21 @@ discard block |
||
| 5932 | 6430 | */ |
| 5933 | 6431 | protected function _tag_open_DRAW($param) |
| 5934 | 6432 | { |
| 5935 | - if ($this->_isForOneLine) return false; |
|
| 5936 | - if ($this->_debugActif) $this->_DEBUG_add('DRAW', true); |
|
| 6433 | + if ($this->_isForOneLine) { |
|
| 6434 | + return false; |
|
| 6435 | + } |
|
| 6436 | + if ($this->_debugActif) { |
|
| 6437 | + $this->_DEBUG_add('DRAW', true); |
|
| 6438 | + } |
|
| 5937 | 6439 | |
| 5938 | 6440 | $this->parsingCss->save(); |
| 5939 | 6441 | $this->parsingCss->analyse('draw', $param); |
| 5940 | 6442 | $this->parsingCss->fontSet(); |
| 5941 | 6443 | |
| 5942 | 6444 | $alignObject = null; |
| 5943 | - if ($this->parsingCss->value['margin-auto']) $alignObject = 'center'; |
|
| 6445 | + if ($this->parsingCss->value['margin-auto']) { |
|
| 6446 | + $alignObject = 'center'; |
|
| 6447 | + } |
|
| 5944 | 6448 | |
| 5945 | 6449 | $overW = $this->parsingCss->value['width']; |
| 5946 | 6450 | $overH = $this->parsingCss->value['height']; |
@@ -5955,22 +6459,27 @@ discard block |
||
| 5955 | 6459 | if ( |
| 5956 | 6460 | $w < ($this->pdf->getW() - $this->pdf->getlMargin()-$this->pdf->getrMargin()) && |
| 5957 | 6461 | $this->pdf->getX() + $w>=($this->pdf->getW() - $this->pdf->getrMargin()) |
| 5958 | - ) |
|
| 5959 | - $this->_tag_open_BR(array()); |
|
| 6462 | + ) { |
|
| 6463 | + $this->_tag_open_BR(array()); |
|
| 6464 | + } |
|
| 5960 | 6465 | |
| 5961 | 6466 | if ( |
| 5962 | 6467 | ($h < ($this->pdf->getH() - $this->pdf->gettMargin()-$this->pdf->getbMargin())) && |
| 5963 | 6468 | ($this->pdf->getY() + $h>=($this->pdf->getH() - $this->pdf->getbMargin())) && |
| 5964 | 6469 | !$this->_isInOverflow |
| 5965 | - ) |
|
| 5966 | - $this->_setNewPage(); |
|
| 6470 | + ) { |
|
| 6471 | + $this->_setNewPage(); |
|
| 6472 | + } |
|
| 5967 | 6473 | |
| 5968 | 6474 | $old = $this->parsingCss->getOldValues(); |
| 5969 | 6475 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 5970 | 6476 | |
| 5971 | 6477 | if ($parentWidth>$w) { |
| 5972 | - if ($alignObject=='center') $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 5973 | - else if ($alignObject=='right') $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 6478 | + if ($alignObject=='center') { |
|
| 6479 | + $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 6480 | + } else if ($alignObject=='right') { |
|
| 6481 | + $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 6482 | + } |
|
| 5974 | 6483 | } |
| 5975 | 6484 | |
| 5976 | 6485 | $this->parsingCss->setPosition(); |
@@ -5979,8 +6488,11 @@ discard block |
||
| 5979 | 6488 | $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin(); |
| 5980 | 6489 | |
| 5981 | 6490 | if ($parentWidth>$w) { |
| 5982 | - if ($alignObject=='center') $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 5983 | - else if ($alignObject=='right') $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 6491 | + if ($alignObject=='center') { |
|
| 6492 | + $this->pdf->setX($this->pdf->getX() + ($parentWidth-$w)*0.5); |
|
| 6493 | + } else if ($alignObject=='right') { |
|
| 6494 | + $this->pdf->setX($this->pdf->getX() + $parentWidth-$w); |
|
| 6495 | + } |
|
| 5984 | 6496 | } |
| 5985 | 6497 | |
| 5986 | 6498 | $this->parsingCss->setPosition(); |
@@ -6057,7 +6569,9 @@ discard block |
||
| 6057 | 6569 | */ |
| 6058 | 6570 | protected function _tag_close_DRAW($param) |
| 6059 | 6571 | { |
| 6060 | - if ($this->_isForOneLine) return false; |
|
| 6572 | + if ($this->_isForOneLine) { |
|
| 6573 | + return false; |
|
| 6574 | + } |
|
| 6061 | 6575 | |
| 6062 | 6576 | $this->pdf->SetAlpha(1.); |
| 6063 | 6577 | $this->pdf->undoTransform(); |
@@ -6098,8 +6612,12 @@ discard block |
||
| 6098 | 6612 | $this->parsingCss->fontSet(); |
| 6099 | 6613 | $this->_loadMargin(); |
| 6100 | 6614 | |
| 6101 | - if ($block) $this->_tag_open_BR(array()); |
|
| 6102 | - if ($this->_debugActif) $this->_DEBUG_add('DRAW', false); |
|
| 6615 | + if ($block) { |
|
| 6616 | + $this->_tag_open_BR(array()); |
|
| 6617 | + } |
|
| 6618 | + if ($this->_debugActif) { |
|
| 6619 | + $this->_DEBUG_add('DRAW', false); |
|
| 6620 | + } |
|
| 6103 | 6621 | |
| 6104 | 6622 | $this->_isInDraw = null; |
| 6105 | 6623 | |
@@ -6115,7 +6633,9 @@ discard block |
||
| 6115 | 6633 | */ |
| 6116 | 6634 | protected function _tag_open_LINE($param) |
| 6117 | 6635 | { |
| 6118 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'LINE'); |
|
| 6636 | + if (!$this->_isInDraw) { |
|
| 6637 | + throw new HTML2PDF_exception(8, 'LINE'); |
|
| 6638 | + } |
|
| 6119 | 6639 | |
| 6120 | 6640 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6121 | 6641 | $this->parsingCss->save(); |
@@ -6142,7 +6662,9 @@ discard block |
||
| 6142 | 6662 | */ |
| 6143 | 6663 | protected function _tag_open_RECT($param) |
| 6144 | 6664 | { |
| 6145 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'RECT'); |
|
| 6665 | + if (!$this->_isInDraw) { |
|
| 6666 | + throw new HTML2PDF_exception(8, 'RECT'); |
|
| 6667 | + } |
|
| 6146 | 6668 | |
| 6147 | 6669 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6148 | 6670 | $this->parsingCss->save(); |
@@ -6169,7 +6691,9 @@ discard block |
||
| 6169 | 6691 | */ |
| 6170 | 6692 | protected function _tag_open_CIRCLE($param) |
| 6171 | 6693 | { |
| 6172 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'CIRCLE'); |
|
| 6694 | + if (!$this->_isInDraw) { |
|
| 6695 | + throw new HTML2PDF_exception(8, 'CIRCLE'); |
|
| 6696 | + } |
|
| 6173 | 6697 | |
| 6174 | 6698 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6175 | 6699 | $this->parsingCss->save(); |
@@ -6194,7 +6718,9 @@ discard block |
||
| 6194 | 6718 | */ |
| 6195 | 6719 | protected function _tag_open_ELLIPSE($param) |
| 6196 | 6720 | { |
| 6197 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'ELLIPSE'); |
|
| 6721 | + if (!$this->_isInDraw) { |
|
| 6722 | + throw new HTML2PDF_exception(8, 'ELLIPSE'); |
|
| 6723 | + } |
|
| 6198 | 6724 | |
| 6199 | 6725 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6200 | 6726 | $this->parsingCss->save(); |
@@ -6221,7 +6747,9 @@ discard block |
||
| 6221 | 6747 | */ |
| 6222 | 6748 | protected function _tag_open_POLYLINE($param) |
| 6223 | 6749 | { |
| 6224 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6750 | + if (!$this->_isInDraw) { |
|
| 6751 | + throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6752 | + } |
|
| 6225 | 6753 | |
| 6226 | 6754 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6227 | 6755 | $this->parsingCss->save(); |
@@ -6237,7 +6765,9 @@ discard block |
||
| 6237 | 6765 | $path = explode(' ', $path); |
| 6238 | 6766 | foreach ($path as $k => $v) { |
| 6239 | 6767 | $path[$k] = trim($v); |
| 6240 | - if ($path[$k]==='') unset($path[$k]); |
|
| 6768 | + if ($path[$k]==='') { |
|
| 6769 | + unset($path[$k]); |
|
| 6770 | + } |
|
| 6241 | 6771 | } |
| 6242 | 6772 | $path = array_values($path); |
| 6243 | 6773 | |
@@ -6267,7 +6797,9 @@ discard block |
||
| 6267 | 6797 | */ |
| 6268 | 6798 | protected function _tag_open_POLYGON($param) |
| 6269 | 6799 | { |
| 6270 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6800 | + if (!$this->_isInDraw) { |
|
| 6801 | + throw new HTML2PDF_exception(8, 'POLYGON'); |
|
| 6802 | + } |
|
| 6271 | 6803 | |
| 6272 | 6804 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6273 | 6805 | $this->parsingCss->save(); |
@@ -6283,7 +6815,9 @@ discard block |
||
| 6283 | 6815 | $path = explode(' ', $path); |
| 6284 | 6816 | foreach ($path as $k => $v) { |
| 6285 | 6817 | $path[$k] = trim($v); |
| 6286 | - if ($path[$k]==='') unset($path[$k]); |
|
| 6818 | + if ($path[$k]==='') { |
|
| 6819 | + unset($path[$k]); |
|
| 6820 | + } |
|
| 6287 | 6821 | } |
| 6288 | 6822 | $path = array_values($path); |
| 6289 | 6823 | |
@@ -6314,7 +6848,9 @@ discard block |
||
| 6314 | 6848 | */ |
| 6315 | 6849 | protected function _tag_open_PATH($param) |
| 6316 | 6850 | { |
| 6317 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'PATH'); |
|
| 6851 | + if (!$this->_isInDraw) { |
|
| 6852 | + throw new HTML2PDF_exception(8, 'PATH'); |
|
| 6853 | + } |
|
| 6318 | 6854 | |
| 6319 | 6855 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6320 | 6856 | $this->parsingCss->save(); |
@@ -6334,7 +6870,9 @@ discard block |
||
| 6334 | 6870 | $path = explode(' ', $path); |
| 6335 | 6871 | foreach ($path as $k => $v) { |
| 6336 | 6872 | $path[$k] = trim($v); |
| 6337 | - if ($path[$k]==='') unset($path[$k]); |
|
| 6873 | + if ($path[$k]==='') { |
|
| 6874 | + unset($path[$k]); |
|
| 6875 | + } |
|
| 6338 | 6876 | } |
| 6339 | 6877 | $path = array_values($path); |
| 6340 | 6878 | |
@@ -6443,7 +6981,9 @@ discard block |
||
| 6443 | 6981 | */ |
| 6444 | 6982 | protected function _tag_open_G($param) |
| 6445 | 6983 | { |
| 6446 | - if (!$this->_isInDraw) throw new HTML2PDF_exception(8, 'G'); |
|
| 6984 | + if (!$this->_isInDraw) { |
|
| 6985 | + throw new HTML2PDF_exception(8, 'G'); |
|
| 6986 | + } |
|
| 6447 | 6987 | |
| 6448 | 6988 | $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); |
| 6449 | 6989 | $this->parsingCss->save(); |
@@ -56,6 +56,11 @@ |
||
| 56 | 56 | function quote($inp) { |
| 57 | 57 | return "'" . $this->db->escape_str($inp) . "'"; |
| 58 | 58 | } |
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @param string $q |
|
| 62 | + * @param string $colname |
|
| 63 | + */ |
|
| 59 | 64 | function db_get_item($q, $colname) { |
| 60 | 65 | $item_arr = array(); |
| 61 | 66 | $query = $this->db->query($q); |
@@ -22,128 +22,128 @@ |
||
| 22 | 22 | ############################################################################### |
| 23 | 23 | |
| 24 | 24 | class Astpp_common extends CI_Model { |
| 25 | - // ------------------------------------------------------------------------ |
|
| 26 | - /** |
|
| 27 | - * initialises the class inheriting the methods of the class Model |
|
| 28 | - * |
|
| 29 | - * @return Usermodel |
|
| 30 | - */ |
|
| 31 | - function Astpp_common() { |
|
| 32 | - parent::__construct(); |
|
| 33 | - } |
|
| 34 | - /** |
|
| 35 | - * -------Here we write code for model astpp_common_model functions list_applyable_charges------ |
|
| 36 | - * Purpose: build array for applyable charge dropdown list. |
|
| 37 | - * @param |
|
| 38 | - * @return return array of applyable chargelist. |
|
| 39 | - */ |
|
| 40 | - function list_applyable_charges($accountid = '') { |
|
| 41 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
| 42 | - $reseller_id=$accountinfo['type']==1 ? $accountinfo['id'] : 0; |
|
| 25 | + // ------------------------------------------------------------------------ |
|
| 26 | + /** |
|
| 27 | + * initialises the class inheriting the methods of the class Model |
|
| 28 | + * |
|
| 29 | + * @return Usermodel |
|
| 30 | + */ |
|
| 31 | + function Astpp_common() { |
|
| 32 | + parent::__construct(); |
|
| 33 | + } |
|
| 34 | + /** |
|
| 35 | + * -------Here we write code for model astpp_common_model functions list_applyable_charges------ |
|
| 36 | + * Purpose: build array for applyable charge dropdown list. |
|
| 37 | + * @param |
|
| 38 | + * @return return array of applyable chargelist. |
|
| 39 | + */ |
|
| 40 | + function list_applyable_charges($accountid = '') { |
|
| 41 | + $accountinfo=$this->session->userdata('accountinfo'); |
|
| 42 | + $reseller_id=$accountinfo['type']==1 ? $accountinfo['id'] : 0; |
|
| 43 | 43 | $q= " SELECT * FROM `charges` where reseller_id =$reseller_id and id NOT IN(select charge_id from charge_to_account where accountid =$accountid) AND pricelist_id = '0'"; |
| 44 | - $item_arr = array(); |
|
| 45 | - $query = $this->db->query($q); |
|
| 46 | - if ($query->num_rows() > 0) { |
|
| 47 | - foreach ($query->result_array() as $row) { |
|
| 48 | - if ($row['charge'] > 0) { |
|
| 49 | - $row['charge'] = $this->common_model->calculate_currency($row['charge']); |
|
| 50 | - } |
|
| 51 | - $item_arr[$row['id']] = $row['description'] . ' - ' . $row['charge']; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - return $item_arr; |
|
| 55 | - } |
|
| 56 | - function quote($inp) { |
|
| 57 | - return "'" . $this->db->escape_str($inp) . "'"; |
|
| 58 | - } |
|
| 59 | - function db_get_item($q, $colname) { |
|
| 60 | - $item_arr = array(); |
|
| 61 | - $query = $this->db->query($q); |
|
| 62 | - if ($query->num_rows() > 0) { |
|
| 63 | - $row = $query->row_array(); |
|
| 64 | - return $row[$colname]; |
|
| 65 | - } |
|
| 66 | - return ''; |
|
| 67 | - } |
|
| 68 | - // Return the balance for a specific ASTPP account. |
|
| 69 | - function accountbalance($account) { |
|
| 70 | - $debit = 0; |
|
| 71 | - $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE accountid=" . $this->quote($account) . " AND status NOT IN (1, 2)"; |
|
| 72 | - $query = $this->db->query($q); |
|
| 73 | - if ($query->num_rows() > 0) { |
|
| 74 | - $row = $query->row_array(); |
|
| 75 | - $debit = $row['val1']; |
|
| 76 | - } |
|
| 77 | - $credit = 0; |
|
| 78 | - $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE accountid= " . $this->quote($account) . " AND status NOT IN (1, 2)"; |
|
| 79 | - $query = $this->db->query($q); |
|
| 80 | - if ($query->num_rows() > 0) { |
|
| 81 | - $row = $query->row_array(); |
|
| 82 | - $credit = $row['val1']; |
|
| 83 | - } |
|
| 84 | - $posted_balance = 0; |
|
| 85 | - $q = "SELECT * FROM accounts WHERE id = " . $this->quote($account); |
|
| 86 | - $query = $this->db->query($q); |
|
| 87 | - if ($query->num_rows() > 0) { |
|
| 88 | - $row = $query->row_array(); |
|
| 89 | - $posted_balance = $row['balance']; |
|
| 90 | - } |
|
| 91 | - $balance = ( $debit - $credit + $posted_balance ); |
|
| 92 | - return $balance; |
|
| 93 | - } |
|
| 94 | - function accounts_total_balance($reseller) { |
|
| 95 | - $debit = 0; |
|
| 96 | - $credit = 0; |
|
| 97 | - if ($reseller == "") { |
|
| 98 | - $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE status NOT IN (1, 2)"; |
|
| 99 | - $debit = $this->db_get_item($q, 'val1'); |
|
| 44 | + $item_arr = array(); |
|
| 45 | + $query = $this->db->query($q); |
|
| 46 | + if ($query->num_rows() > 0) { |
|
| 47 | + foreach ($query->result_array() as $row) { |
|
| 48 | + if ($row['charge'] > 0) { |
|
| 49 | + $row['charge'] = $this->common_model->calculate_currency($row['charge']); |
|
| 50 | + } |
|
| 51 | + $item_arr[$row['id']] = $row['description'] . ' - ' . $row['charge']; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + return $item_arr; |
|
| 55 | + } |
|
| 56 | + function quote($inp) { |
|
| 57 | + return "'" . $this->db->escape_str($inp) . "'"; |
|
| 58 | + } |
|
| 59 | + function db_get_item($q, $colname) { |
|
| 60 | + $item_arr = array(); |
|
| 61 | + $query = $this->db->query($q); |
|
| 62 | + if ($query->num_rows() > 0) { |
|
| 63 | + $row = $query->row_array(); |
|
| 64 | + return $row[$colname]; |
|
| 65 | + } |
|
| 66 | + return ''; |
|
| 67 | + } |
|
| 68 | + // Return the balance for a specific ASTPP account. |
|
| 69 | + function accountbalance($account) { |
|
| 70 | + $debit = 0; |
|
| 71 | + $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE accountid=" . $this->quote($account) . " AND status NOT IN (1, 2)"; |
|
| 72 | + $query = $this->db->query($q); |
|
| 73 | + if ($query->num_rows() > 0) { |
|
| 74 | + $row = $query->row_array(); |
|
| 75 | + $debit = $row['val1']; |
|
| 76 | + } |
|
| 77 | + $credit = 0; |
|
| 78 | + $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE accountid= " . $this->quote($account) . " AND status NOT IN (1, 2)"; |
|
| 79 | + $query = $this->db->query($q); |
|
| 80 | + if ($query->num_rows() > 0) { |
|
| 81 | + $row = $query->row_array(); |
|
| 82 | + $credit = $row['val1']; |
|
| 83 | + } |
|
| 84 | + $posted_balance = 0; |
|
| 85 | + $q = "SELECT * FROM accounts WHERE id = " . $this->quote($account); |
|
| 86 | + $query = $this->db->query($q); |
|
| 87 | + if ($query->num_rows() > 0) { |
|
| 88 | + $row = $query->row_array(); |
|
| 89 | + $posted_balance = $row['balance']; |
|
| 90 | + } |
|
| 91 | + $balance = ( $debit - $credit + $posted_balance ); |
|
| 92 | + return $balance; |
|
| 93 | + } |
|
| 94 | + function accounts_total_balance($reseller) { |
|
| 95 | + $debit = 0; |
|
| 96 | + $credit = 0; |
|
| 97 | + if ($reseller == "") { |
|
| 98 | + $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE status NOT IN (1, 2)"; |
|
| 99 | + $debit = $this->db_get_item($q, 'val1'); |
|
| 100 | 100 | |
| 101 | - $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE status NOT IN (1, 2)"; |
|
| 102 | - $credit = $this->db_get_item($q, 'val1'); |
|
| 101 | + $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE status NOT IN (1, 2)"; |
|
| 102 | + $credit = $this->db_get_item($q, 'val1'); |
|
| 103 | 103 | |
| 104 | - $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = ''"; |
|
| 105 | - } else { |
|
| 106 | - $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = " . $this->quote($reseller); |
|
| 107 | - } |
|
| 108 | - $posted_balance = $this->db_get_item($tmp, "val1"); |
|
| 104 | + $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = ''"; |
|
| 105 | + } else { |
|
| 106 | + $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = " . $this->quote($reseller); |
|
| 107 | + } |
|
| 108 | + $posted_balance = $this->db_get_item($tmp, "val1"); |
|
| 109 | 109 | |
| 110 | - $balance = ( $debit - $credit + $posted_balance ); |
|
| 111 | - return $balance; |
|
| 112 | - } |
|
| 113 | - function count_dids($test) { |
|
| 114 | - $tmp = "SELECT COUNT(*) as val1 FROM dids " . $test; |
|
| 115 | - return $this->db_get_item($tmp, 'val1'); |
|
| 116 | - } |
|
| 110 | + $balance = ( $debit - $credit + $posted_balance ); |
|
| 111 | + return $balance; |
|
| 112 | + } |
|
| 113 | + function count_dids($test) { |
|
| 114 | + $tmp = "SELECT COUNT(*) as val1 FROM dids " . $test; |
|
| 115 | + return $this->db_get_item($tmp, 'val1'); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - function count_callingcards($where, $field = 'COUNT(*)') { |
|
| 119 | - $tmp = "SELECT $field as val FROM callingcards " . $where; |
|
| 120 | - return $this->db_get_item($tmp, 'val'); |
|
| 121 | - } |
|
| 118 | + function count_callingcards($where, $field = 'COUNT(*)') { |
|
| 119 | + $tmp = "SELECT $field as val FROM callingcards " . $where; |
|
| 120 | + return $this->db_get_item($tmp, 'val'); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - function count_accounts($test) { |
|
| 124 | - $tmp = "SELECT COUNT(*) as val1 FROM accounts " . $test; |
|
| 125 | - return $this->db_get_item($tmp, 'val1'); |
|
| 126 | - } |
|
| 123 | + function count_accounts($test) { |
|
| 124 | + $tmp = "SELECT COUNT(*) as val1 FROM accounts " . $test; |
|
| 125 | + return $this->db_get_item($tmp, 'val1'); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - function count_rategroup($test){ |
|
| 128 | + function count_rategroup($test){ |
|
| 129 | 129 | $tmp = "SELECT COUNT(*) as val1 FROM pricelists " . $test; |
| 130 | - return $this->db_get_item($tmp, 'val1'); |
|
| 131 | - } |
|
| 130 | + return $this->db_get_item($tmp, 'val1'); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - function count_termination($test = ''){ |
|
| 133 | + function count_termination($test = ''){ |
|
| 134 | 134 | $tmp = "SELECT COUNT(*) as val1 FROM outbound_routes " . $test; |
| 135 | - return $this->db_get_item($tmp, 'val1'); |
|
| 136 | - } |
|
| 135 | + return $this->db_get_item($tmp, 'val1'); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - function count_trunk($test = ''){ |
|
| 138 | + function count_trunk($test = ''){ |
|
| 139 | 139 | $tmp = "SELECT COUNT(*) as val1 FROM trunks " . $test; |
| 140 | - return $this->db_get_item($tmp, 'val1'); |
|
| 141 | - } |
|
| 140 | + return $this->db_get_item($tmp, 'val1'); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - function count_origination($test = ''){ |
|
| 143 | + function count_origination($test = ''){ |
|
| 144 | 144 | $tmp = "SELECT COUNT(*) as val1 FROM routes " . $test; |
| 145 | - return $this->db_get_item($tmp, 'val1'); |
|
| 146 | - } |
|
| 145 | + return $this->db_get_item($tmp, 'val1'); |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | 148 | } |
| 149 | 149 | ?> |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | * @return return array of applyable chargelist. |
| 39 | 39 | */ |
| 40 | 40 | function list_applyable_charges($accountid = '') { |
| 41 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
| 42 | - $reseller_id=$accountinfo['type']==1 ? $accountinfo['id'] : 0; |
|
| 43 | - $q= " SELECT * FROM `charges` where reseller_id =$reseller_id and id NOT IN(select charge_id from charge_to_account where accountid =$accountid) AND pricelist_id = '0'"; |
|
| 41 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 42 | + $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
|
| 43 | + $q = " SELECT * FROM `charges` where reseller_id =$reseller_id and id NOT IN(select charge_id from charge_to_account where accountid =$accountid) AND pricelist_id = '0'"; |
|
| 44 | 44 | $item_arr = array(); |
| 45 | 45 | $query = $this->db->query($q); |
| 46 | 46 | if ($query->num_rows() > 0) { |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | if ($row['charge'] > 0) { |
| 49 | 49 | $row['charge'] = $this->common_model->calculate_currency($row['charge']); |
| 50 | 50 | } |
| 51 | - $item_arr[$row['id']] = $row['description'] . ' - ' . $row['charge']; |
|
| 51 | + $item_arr[$row['id']] = $row['description'].' - '.$row['charge']; |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | return $item_arr; |
| 55 | 55 | } |
| 56 | 56 | function quote($inp) { |
| 57 | - return "'" . $this->db->escape_str($inp) . "'"; |
|
| 57 | + return "'".$this->db->escape_str($inp)."'"; |
|
| 58 | 58 | } |
| 59 | 59 | function db_get_item($q, $colname) { |
| 60 | 60 | $item_arr = array(); |
@@ -68,27 +68,27 @@ discard block |
||
| 68 | 68 | // Return the balance for a specific ASTPP account. |
| 69 | 69 | function accountbalance($account) { |
| 70 | 70 | $debit = 0; |
| 71 | - $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE accountid=" . $this->quote($account) . " AND status NOT IN (1, 2)"; |
|
| 71 | + $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE accountid=".$this->quote($account)." AND status NOT IN (1, 2)"; |
|
| 72 | 72 | $query = $this->db->query($q); |
| 73 | 73 | if ($query->num_rows() > 0) { |
| 74 | 74 | $row = $query->row_array(); |
| 75 | 75 | $debit = $row['val1']; |
| 76 | 76 | } |
| 77 | 77 | $credit = 0; |
| 78 | - $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE accountid= " . $this->quote($account) . " AND status NOT IN (1, 2)"; |
|
| 78 | + $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE accountid= ".$this->quote($account)." AND status NOT IN (1, 2)"; |
|
| 79 | 79 | $query = $this->db->query($q); |
| 80 | 80 | if ($query->num_rows() > 0) { |
| 81 | 81 | $row = $query->row_array(); |
| 82 | 82 | $credit = $row['val1']; |
| 83 | 83 | } |
| 84 | 84 | $posted_balance = 0; |
| 85 | - $q = "SELECT * FROM accounts WHERE id = " . $this->quote($account); |
|
| 85 | + $q = "SELECT * FROM accounts WHERE id = ".$this->quote($account); |
|
| 86 | 86 | $query = $this->db->query($q); |
| 87 | 87 | if ($query->num_rows() > 0) { |
| 88 | 88 | $row = $query->row_array(); |
| 89 | 89 | $posted_balance = $row['balance']; |
| 90 | 90 | } |
| 91 | - $balance = ( $debit - $credit + $posted_balance ); |
|
| 91 | + $balance = ($debit - $credit + $posted_balance); |
|
| 92 | 92 | return $balance; |
| 93 | 93 | } |
| 94 | 94 | function accounts_total_balance($reseller) { |
@@ -103,45 +103,45 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = ''"; |
| 105 | 105 | } else { |
| 106 | - $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = " . $this->quote($reseller); |
|
| 106 | + $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = ".$this->quote($reseller); |
|
| 107 | 107 | } |
| 108 | 108 | $posted_balance = $this->db_get_item($tmp, "val1"); |
| 109 | 109 | |
| 110 | - $balance = ( $debit - $credit + $posted_balance ); |
|
| 110 | + $balance = ($debit - $credit + $posted_balance); |
|
| 111 | 111 | return $balance; |
| 112 | 112 | } |
| 113 | 113 | function count_dids($test) { |
| 114 | - $tmp = "SELECT COUNT(*) as val1 FROM dids " . $test; |
|
| 114 | + $tmp = "SELECT COUNT(*) as val1 FROM dids ".$test; |
|
| 115 | 115 | return $this->db_get_item($tmp, 'val1'); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | function count_callingcards($where, $field = 'COUNT(*)') { |
| 119 | - $tmp = "SELECT $field as val FROM callingcards " . $where; |
|
| 119 | + $tmp = "SELECT $field as val FROM callingcards ".$where; |
|
| 120 | 120 | return $this->db_get_item($tmp, 'val'); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | function count_accounts($test) { |
| 124 | - $tmp = "SELECT COUNT(*) as val1 FROM accounts " . $test; |
|
| 124 | + $tmp = "SELECT COUNT(*) as val1 FROM accounts ".$test; |
|
| 125 | 125 | return $this->db_get_item($tmp, 'val1'); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - function count_rategroup($test){ |
|
| 129 | - $tmp = "SELECT COUNT(*) as val1 FROM pricelists " . $test; |
|
| 128 | + function count_rategroup($test) { |
|
| 129 | + $tmp = "SELECT COUNT(*) as val1 FROM pricelists ".$test; |
|
| 130 | 130 | return $this->db_get_item($tmp, 'val1'); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - function count_termination($test = ''){ |
|
| 134 | - $tmp = "SELECT COUNT(*) as val1 FROM outbound_routes " . $test; |
|
| 133 | + function count_termination($test = '') { |
|
| 134 | + $tmp = "SELECT COUNT(*) as val1 FROM outbound_routes ".$test; |
|
| 135 | 135 | return $this->db_get_item($tmp, 'val1'); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - function count_trunk($test = ''){ |
|
| 139 | - $tmp = "SELECT COUNT(*) as val1 FROM trunks " . $test; |
|
| 138 | + function count_trunk($test = '') { |
|
| 139 | + $tmp = "SELECT COUNT(*) as val1 FROM trunks ".$test; |
|
| 140 | 140 | return $this->db_get_item($tmp, 'val1'); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - function count_origination($test = ''){ |
|
| 144 | - $tmp = "SELECT COUNT(*) as val1 FROM routes " . $test; |
|
| 143 | + function count_origination($test = '') { |
|
| 144 | + $tmp = "SELECT COUNT(*) as val1 FROM routes ".$test; |
|
| 145 | 145 | return $this->db_get_item($tmp, 'val1'); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | * -------Here we write code for model auth_model functions verify_login------ |
| 31 | 31 | * Purpose: Validate Login Name and Password. |
| 32 | 32 | * @param $username,$password. |
| 33 | - * @return If login user name and password is valid then return true else return false. |
|
| 33 | + * @return integer login user name and password is valid then return true else return false. |
|
| 34 | 34 | */ |
| 35 | 35 | function verify_login($username, $password) { |
| 36 | 36 | $q = "SELECT COUNT(*) as cnt FROM accounts WHERE (number = '".$this->db->escape_str($username)."'"; |
@@ -23,33 +23,33 @@ |
||
| 23 | 23 | |
| 24 | 24 | class Auth_model extends CI_Model { |
| 25 | 25 | |
| 26 | - function Auth_model() { |
|
| 27 | - parent::__construct(); |
|
| 28 | - } |
|
| 29 | - /** |
|
| 30 | - * -------Here we write code for model auth_model functions verify_login------ |
|
| 31 | - * Purpose: Validate Login Name and Password. |
|
| 32 | - * @param $username,$password. |
|
| 33 | - * @return If login user name and password is valid then return true else return false. |
|
| 34 | - */ |
|
| 35 | - function verify_login($username, $password) { |
|
| 36 | - $q = "SELECT COUNT(*) as cnt FROM accounts WHERE (number = '".$this->db->escape_str($username)."'"; |
|
| 26 | + function Auth_model() { |
|
| 27 | + parent::__construct(); |
|
| 28 | + } |
|
| 29 | + /** |
|
| 30 | + * -------Here we write code for model auth_model functions verify_login------ |
|
| 31 | + * Purpose: Validate Login Name and Password. |
|
| 32 | + * @param $username,$password. |
|
| 33 | + * @return If login user name and password is valid then return true else return false. |
|
| 34 | + */ |
|
| 35 | + function verify_login($username, $password) { |
|
| 36 | + $q = "SELECT COUNT(*) as cnt FROM accounts WHERE (number = '".$this->db->escape_str($username)."'"; |
|
| 37 | 37 | $q .= " OR email = '".$this->db->escape_str($username)."')"; |
| 38 | - $q .= " AND password = '".$this->db->escape_str($password)."'"; |
|
| 39 | - $q .= " AND status = 0 AND type IN (1,2,3,4,5,0,-1) AND deleted = 0"; |
|
| 40 | - $query = $this->db->query($q); |
|
| 41 | - if ($query->num_rows() > 0) { |
|
| 42 | - $row = $query->row(); |
|
| 43 | - if ($row->cnt > 0) { |
|
| 44 | - $this->session->set_userdata('user_name', $username); |
|
| 45 | - return 1; |
|
| 46 | - } else { |
|
| 47 | - return 0; |
|
| 48 | - } |
|
| 49 | - } |
|
| 38 | + $q .= " AND password = '".$this->db->escape_str($password)."'"; |
|
| 39 | + $q .= " AND status = 0 AND type IN (1,2,3,4,5,0,-1) AND deleted = 0"; |
|
| 40 | + $query = $this->db->query($q); |
|
| 41 | + if ($query->num_rows() > 0) { |
|
| 42 | + $row = $query->row(); |
|
| 43 | + if ($row->cnt > 0) { |
|
| 44 | + $this->session->set_userdata('user_name', $username); |
|
| 45 | + return 1; |
|
| 46 | + } else { |
|
| 47 | + return 0; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - return 0; |
|
| 52 | - } |
|
| 51 | + return 0; |
|
| 52 | + } |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | //end class |
@@ -1410,6 +1410,10 @@ |
||
| 1410 | 1410 | } |
| 1411 | 1411 | $this->load->view('view_accounts_process_payment', $data); |
| 1412 | 1412 | } |
| 1413 | + |
|
| 1414 | + /** |
|
| 1415 | + * @param string $select |
|
| 1416 | + */ |
|
| 1413 | 1417 | function get_invoice_date($select,$accountid){ |
| 1414 | 1418 | $query = $this->db_model->select($select, "invoices", '',"id","DESC","1","0"); |
| 1415 | 1419 | if($query->num_rows >0){ |
@@ -24,1359 +24,1359 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | class Accounts extends MX_Controller { |
| 26 | 26 | |
| 27 | - function Accounts() { |
|
| 28 | - parent::__construct(); |
|
| 29 | - $this->load->helper('template_inheritance'); |
|
| 30 | - |
|
| 31 | - $this->load->library('accounts_form'); |
|
| 32 | - $this->load->library('astpp/form'); |
|
| 33 | - |
|
| 34 | - $this->load->model('common_model'); |
|
| 35 | - $this->load->library('session'); |
|
| 36 | - $this->load->helper('form'); |
|
| 37 | - $this->load->model('accounts_model'); |
|
| 38 | - $this->load->model('Astpp_common'); |
|
| 39 | - $this->protected_pages = array('account_list'); |
|
| 40 | - if ($this->session->userdata('user_login') == FALSE) |
|
| 41 | - redirect(base_url() . '/login/login'); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - function customer_list() { |
|
| 45 | - $data['username'] = $this->session->userdata('user_name'); |
|
| 46 | - $data['page_title'] = 'Customers'; |
|
| 47 | - $data['search_flag'] = true; |
|
| 48 | - /** |
|
| 27 | + function Accounts() { |
|
| 28 | + parent::__construct(); |
|
| 29 | + $this->load->helper('template_inheritance'); |
|
| 30 | + |
|
| 31 | + $this->load->library('accounts_form'); |
|
| 32 | + $this->load->library('astpp/form'); |
|
| 33 | + |
|
| 34 | + $this->load->model('common_model'); |
|
| 35 | + $this->load->library('session'); |
|
| 36 | + $this->load->helper('form'); |
|
| 37 | + $this->load->model('accounts_model'); |
|
| 38 | + $this->load->model('Astpp_common'); |
|
| 39 | + $this->protected_pages = array('account_list'); |
|
| 40 | + if ($this->session->userdata('user_login') == FALSE) |
|
| 41 | + redirect(base_url() . '/login/login'); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + function customer_list() { |
|
| 45 | + $data['username'] = $this->session->userdata('user_name'); |
|
| 46 | + $data['page_title'] = 'Customers'; |
|
| 47 | + $data['search_flag'] = true; |
|
| 48 | + /** |
|
| 49 | 49 | ASTPP 3.0 |
| 50 | 50 | Customer Batch Update. |
| 51 | - * */ |
|
| 52 | - $data['batch_update_flag'] = true; |
|
| 53 | - /* * *********************************** */ |
|
| 54 | - $this->session->set_userdata('advance_search', 0); |
|
| 55 | - $data['grid_fields'] = $this->accounts_form->build_account_list_for_customer(); |
|
| 56 | - $data["grid_buttons"] = $this->accounts_form->build_grid_buttons_customer(); |
|
| 57 | - $data['form_search'] = $this->form->build_serach_form($this->accounts_form->get_search_customer_form()); |
|
| 58 | - /** |
|
| 51 | + * */ |
|
| 52 | + $data['batch_update_flag'] = true; |
|
| 53 | + /* * *********************************** */ |
|
| 54 | + $this->session->set_userdata('advance_search', 0); |
|
| 55 | + $data['grid_fields'] = $this->accounts_form->build_account_list_for_customer(); |
|
| 56 | + $data["grid_buttons"] = $this->accounts_form->build_grid_buttons_customer(); |
|
| 57 | + $data['form_search'] = $this->form->build_serach_form($this->accounts_form->get_search_customer_form()); |
|
| 58 | + /** |
|
| 59 | 59 | ASTPP 3.0 |
| 60 | 60 | Customer Batch Update. |
| 61 | - * */ |
|
| 61 | + * */ |
|
| 62 | 62 | |
| 63 | - $data['form_batch_update'] = $this->form->build_batchupdate_form($this->accounts_form->customer_batch_update_form()); |
|
| 64 | - /* * *****************************************************************************************8 */ |
|
| 65 | - $this->load->view('view_accounts_list', $data); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * -------Here we write code for controller accounts functions account_list------ |
|
| 70 | - * Listing of Accounts table data through php function json_encode |
|
| 71 | - */ |
|
| 72 | - function customer_list_json() { |
|
| 73 | - $json_data = array(); |
|
| 74 | - $count_all = $this->accounts_model->get_customer_Account_list(false); |
|
| 75 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 76 | - $json_data = $paging_data["json_paging"]; |
|
| 77 | - $query = $this->accounts_model->get_customer_Account_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
| 78 | - $grid_fields = json_decode($this->accounts_form->build_account_list_for_customer()); |
|
| 79 | - $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
| 80 | - echo json_encode($json_data); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - function customer_list_search() { |
|
| 84 | - $ajax_search = $this->input->post('ajax_search', 0); |
|
| 85 | - |
|
| 86 | - if ($this->input->post('advance_search', TRUE) == 1) { |
|
| 87 | - $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
| 88 | - $action = $this->input->post(); |
|
| 89 | - unset($action['action']); |
|
| 90 | - unset($action['advance_search']); |
|
| 91 | - if (isset($action['balance']['balance']) && $action['balance']['balance'] != '') { |
|
| 92 | - $action['balance']['balance'] = $this->common_model->add_calculate_currency($action['balance']['balance'], "", '', false, false); |
|
| 93 | - } |
|
| 94 | - if (isset($action['credit_limit']['credit_limit']) && $action['credit_limit']['credit_limit'] != '') { |
|
| 95 | - $action['credit_limit']['credit_limit'] = $this->common_model->add_calculate_currency($action['credit_limit']['credit_limit'], "", '', false, false); |
|
| 96 | - } |
|
| 97 | - $this->session->set_userdata('customer_list_search', $action); |
|
| 98 | - } |
|
| 99 | - if (@$ajax_search != 1) { |
|
| 100 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - function customer_list_clearsearchfilter() { |
|
| 105 | - $this->session->set_userdata('advance_search', 0); |
|
| 106 | - $this->session->set_userdata('customer_list_search', ""); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - function customer_export_cdr_xls() { |
|
| 110 | - $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
|
| 111 | - $currency_id=$account_info['currency_id']; |
|
| 112 | - $currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
|
| 113 | - $query = $this->accounts_model->get_customer_Account_list(true, '', '', true); |
|
| 114 | - ob_clean(); |
|
| 115 | - $customer_array[] = array("Account", "First Name", "Last Name", "Company", "Rate Group ", "Balance ($currency)", "Credit Limit ($currency)", "First Used", "Expiry Date","CC","Status","Created Date"); |
|
| 116 | - if ($query->num_rows() > 0) { |
|
| 117 | - |
|
| 118 | - foreach ($query->result_array() as $row) { |
|
| 119 | - $customer_array[] = array( |
|
| 120 | - $row['number'], |
|
| 121 | - $row['first_name'], |
|
| 122 | - $row['last_name'], |
|
| 123 | - $row['company_name'], |
|
| 124 | - $this->common->get_field_name('name', 'pricelists', $row['pricelist_id']), |
|
| 125 | - $this->common_model->calculate_currency_customer($row['balance']), |
|
| 126 | - $this->common_model->calculate_currency_customer($row['credit_limit']), |
|
| 127 | - $row['first_used'], |
|
| 128 | - $row['expiry'], |
|
| 129 | - $row['maxchannels'], |
|
| 130 | - $this->common->get_status('export', '', $row['status']), |
|
| 131 | - $row['creation'], |
|
| 132 | - ); |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - $this->load->helper('csv'); |
|
| 136 | - array_to_csv($customer_array, 'Customers_' . date("Y-m-d") . '.csv'); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - function provider_add() { |
|
| 140 | - $this->customer_add(3); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - function provider_edit($edit_id = '') { |
|
| 144 | - $this->customer_edit($edit_id); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - function provider_save() { |
|
| 148 | - $add_array = $this->input->post(); |
|
| 149 | - $this->customer_save($add_array); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - function customer_add($type = 0) { |
|
| 63 | + $data['form_batch_update'] = $this->form->build_batchupdate_form($this->accounts_form->customer_batch_update_form()); |
|
| 64 | + /* * *****************************************************************************************8 */ |
|
| 65 | + $this->load->view('view_accounts_list', $data); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * -------Here we write code for controller accounts functions account_list------ |
|
| 70 | + * Listing of Accounts table data through php function json_encode |
|
| 71 | + */ |
|
| 72 | + function customer_list_json() { |
|
| 73 | + $json_data = array(); |
|
| 74 | + $count_all = $this->accounts_model->get_customer_Account_list(false); |
|
| 75 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 76 | + $json_data = $paging_data["json_paging"]; |
|
| 77 | + $query = $this->accounts_model->get_customer_Account_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
| 78 | + $grid_fields = json_decode($this->accounts_form->build_account_list_for_customer()); |
|
| 79 | + $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
| 80 | + echo json_encode($json_data); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + function customer_list_search() { |
|
| 84 | + $ajax_search = $this->input->post('ajax_search', 0); |
|
| 85 | + |
|
| 86 | + if ($this->input->post('advance_search', TRUE) == 1) { |
|
| 87 | + $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
| 88 | + $action = $this->input->post(); |
|
| 89 | + unset($action['action']); |
|
| 90 | + unset($action['advance_search']); |
|
| 91 | + if (isset($action['balance']['balance']) && $action['balance']['balance'] != '') { |
|
| 92 | + $action['balance']['balance'] = $this->common_model->add_calculate_currency($action['balance']['balance'], "", '', false, false); |
|
| 93 | + } |
|
| 94 | + if (isset($action['credit_limit']['credit_limit']) && $action['credit_limit']['credit_limit'] != '') { |
|
| 95 | + $action['credit_limit']['credit_limit'] = $this->common_model->add_calculate_currency($action['credit_limit']['credit_limit'], "", '', false, false); |
|
| 96 | + } |
|
| 97 | + $this->session->set_userdata('customer_list_search', $action); |
|
| 98 | + } |
|
| 99 | + if (@$ajax_search != 1) { |
|
| 100 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + function customer_list_clearsearchfilter() { |
|
| 105 | + $this->session->set_userdata('advance_search', 0); |
|
| 106 | + $this->session->set_userdata('customer_list_search', ""); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + function customer_export_cdr_xls() { |
|
| 110 | + $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
|
| 111 | + $currency_id=$account_info['currency_id']; |
|
| 112 | + $currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
|
| 113 | + $query = $this->accounts_model->get_customer_Account_list(true, '', '', true); |
|
| 114 | + ob_clean(); |
|
| 115 | + $customer_array[] = array("Account", "First Name", "Last Name", "Company", "Rate Group ", "Balance ($currency)", "Credit Limit ($currency)", "First Used", "Expiry Date","CC","Status","Created Date"); |
|
| 116 | + if ($query->num_rows() > 0) { |
|
| 117 | + |
|
| 118 | + foreach ($query->result_array() as $row) { |
|
| 119 | + $customer_array[] = array( |
|
| 120 | + $row['number'], |
|
| 121 | + $row['first_name'], |
|
| 122 | + $row['last_name'], |
|
| 123 | + $row['company_name'], |
|
| 124 | + $this->common->get_field_name('name', 'pricelists', $row['pricelist_id']), |
|
| 125 | + $this->common_model->calculate_currency_customer($row['balance']), |
|
| 126 | + $this->common_model->calculate_currency_customer($row['credit_limit']), |
|
| 127 | + $row['first_used'], |
|
| 128 | + $row['expiry'], |
|
| 129 | + $row['maxchannels'], |
|
| 130 | + $this->common->get_status('export', '', $row['status']), |
|
| 131 | + $row['creation'], |
|
| 132 | + ); |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + $this->load->helper('csv'); |
|
| 136 | + array_to_csv($customer_array, 'Customers_' . date("Y-m-d") . '.csv'); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + function provider_add() { |
|
| 140 | + $this->customer_add(3); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + function provider_edit($edit_id = '') { |
|
| 144 | + $this->customer_edit($edit_id); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + function provider_save() { |
|
| 148 | + $add_array = $this->input->post(); |
|
| 149 | + $this->customer_save($add_array); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + function customer_add($type = 0) { |
|
| 153 | 153 | $accountinfo = $this->session->userdata('accountinfo'); |
| 154 | - $entity_type = strtolower($this->common->get_entity_type('', '', $type)); |
|
| 155 | - $data['username'] = $this->session->userdata('user_name'); |
|
| 156 | - $data['flag'] = 'create'; |
|
| 157 | - $data['page_title'] = 'Create ' . $entity_type; |
|
| 158 | - $data['back_flag'] = true; |
|
| 159 | - $data['country_id'] = $accountinfo['country_id']; |
|
| 160 | - $data['callingcard'] = Common_model::$global_config['system_config']['pinlength']; |
|
| 161 | - $data['currency_id'] = $accountinfo['currency_id']; |
|
| 162 | - $data['timezone_id'] = $accountinfo['timezone_id']; |
|
| 163 | - $data['form'] = $this->form->build_form($this->accounts_form->get_customer_form_fields($entity_type), ''); |
|
| 164 | - if (!$data['timezone_id']) { |
|
| 165 | - $data['timezone_id'] = 1; |
|
| 166 | - } |
|
| 167 | - if (!$data['currency_id']) { |
|
| 168 | - $data['currency_id'] = 1; |
|
| 169 | - } |
|
| 170 | - if (!$data['country_id']) { |
|
| 171 | - $data['country_id'] = 1; |
|
| 172 | - } |
|
| 173 | - $data['entity_name'] = $entity_type; |
|
| 174 | - $this->load->view('view_accounts_create', $data); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - function customer_edit($edit_id = '') { |
|
| 178 | - //Get Account information from session. |
|
| 179 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 180 | - //Get Parent informartion |
|
| 181 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 182 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 183 | - $account = $this->db_model->getSelect("*", "accounts", $where); |
|
| 184 | - if ($account->num_rows > 0) { |
|
| 185 | - $account_data = (array) $account->first_row(); |
|
| 186 | - $entity_name = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 187 | - $data['page_title'] =ucfirst($entity_name) . " Profile"; |
|
| 188 | - $data['invoice_date'] = $account_data['invoice_day']; |
|
| 189 | - $data["account_data"] = $account_data; |
|
| 190 | - $data['callingcard'] = Common_model::$global_config['system_config']['pinlength']; |
|
| 191 | - $data['entity_name'] = $entity_name; |
|
| 192 | - //Purpose : Get assigned taxes value for customer |
|
| 193 | - $taxes_data = $this->db_model->getSelect("group_concat(taxes_id) as taxes_id", "taxes_to_accounts", array("accountid" => $edit_id)); |
|
| 194 | - if (isset($taxes_data) && $taxes_data->num_rows() > 0) { |
|
| 195 | - $taxes_data = $taxes_data->result_array(); |
|
| 196 | - $account_data["tax_id"] = explode(",", $taxes_data[0]['taxes_id']); |
|
| 197 | - } |
|
| 198 | - /* * *** |
|
| 154 | + $entity_type = strtolower($this->common->get_entity_type('', '', $type)); |
|
| 155 | + $data['username'] = $this->session->userdata('user_name'); |
|
| 156 | + $data['flag'] = 'create'; |
|
| 157 | + $data['page_title'] = 'Create ' . $entity_type; |
|
| 158 | + $data['back_flag'] = true; |
|
| 159 | + $data['country_id'] = $accountinfo['country_id']; |
|
| 160 | + $data['callingcard'] = Common_model::$global_config['system_config']['pinlength']; |
|
| 161 | + $data['currency_id'] = $accountinfo['currency_id']; |
|
| 162 | + $data['timezone_id'] = $accountinfo['timezone_id']; |
|
| 163 | + $data['form'] = $this->form->build_form($this->accounts_form->get_customer_form_fields($entity_type), ''); |
|
| 164 | + if (!$data['timezone_id']) { |
|
| 165 | + $data['timezone_id'] = 1; |
|
| 166 | + } |
|
| 167 | + if (!$data['currency_id']) { |
|
| 168 | + $data['currency_id'] = 1; |
|
| 169 | + } |
|
| 170 | + if (!$data['country_id']) { |
|
| 171 | + $data['country_id'] = 1; |
|
| 172 | + } |
|
| 173 | + $data['entity_name'] = $entity_type; |
|
| 174 | + $this->load->view('view_accounts_create', $data); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + function customer_edit($edit_id = '') { |
|
| 178 | + //Get Account information from session. |
|
| 179 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 180 | + //Get Parent informartion |
|
| 181 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 182 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 183 | + $account = $this->db_model->getSelect("*", "accounts", $where); |
|
| 184 | + if ($account->num_rows > 0) { |
|
| 185 | + $account_data = (array) $account->first_row(); |
|
| 186 | + $entity_name = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 187 | + $data['page_title'] =ucfirst($entity_name) . " Profile"; |
|
| 188 | + $data['invoice_date'] = $account_data['invoice_day']; |
|
| 189 | + $data["account_data"] = $account_data; |
|
| 190 | + $data['callingcard'] = Common_model::$global_config['system_config']['pinlength']; |
|
| 191 | + $data['entity_name'] = $entity_name; |
|
| 192 | + //Purpose : Get assigned taxes value for customer |
|
| 193 | + $taxes_data = $this->db_model->getSelect("group_concat(taxes_id) as taxes_id", "taxes_to_accounts", array("accountid" => $edit_id)); |
|
| 194 | + if (isset($taxes_data) && $taxes_data->num_rows() > 0) { |
|
| 195 | + $taxes_data = $taxes_data->result_array(); |
|
| 196 | + $account_data["tax_id"] = explode(",", $taxes_data[0]['taxes_id']); |
|
| 197 | + } |
|
| 198 | + /* * *** |
|
| 199 | 199 | ASTPP 3.0 |
| 200 | 200 | Password decode |
| 201 | 201 | * **** */ |
| 202 | - $account_data['password'] = $this->common->decode($account_data['password']); |
|
| 203 | - /* * ********************** */ |
|
| 204 | - $data['form'] = $this->form->build_form($this->accounts_form->get_customer_form_fields($entity_name, $edit_id), $account_data); |
|
| 205 | - $data['edit_id']=$edit_id; |
|
| 206 | - $this->load->view('view_customer_details', $data); |
|
| 207 | - } else { |
|
| 208 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - function customer_save($add_array = false) { |
|
| 213 | - $add_array = $this->input->post(); |
|
| 214 | - $entity_name = strtolower($this->common->get_entity_type('', '', $add_array['type'])); |
|
| 215 | - $data['country_id'] = $add_array['country_id']; |
|
| 216 | - $data['timezone_id'] = $add_array['timezone_id']; |
|
| 217 | - $data['currency_id'] = $add_array['currency_id']; |
|
| 218 | - $data['entity_name'] = $entity_name; |
|
| 219 | - $data['callingcard'] = Common_model::$global_config['system_config']['pinlength']; |
|
| 220 | - $data['edit_id']=$add_array['id']; |
|
| 221 | - $data['form'] = $this->form->build_form($this->accounts_form->get_customer_form_fields($entity_name, $add_array['id']), $add_array); |
|
| 222 | - if ($add_array['id'] != '') { |
|
| 223 | - $data['page_title'] = 'Edit ' . $this->common->get_entity_type('', '', $add_array['type']); |
|
| 224 | - if ($this->form_validation->run() == FALSE) { |
|
| 225 | - $data['validation_errors'] = validation_errors(); |
|
| 226 | - } else { |
|
| 227 | - /* * **** |
|
| 202 | + $account_data['password'] = $this->common->decode($account_data['password']); |
|
| 203 | + /* * ********************** */ |
|
| 204 | + $data['form'] = $this->form->build_form($this->accounts_form->get_customer_form_fields($entity_name, $edit_id), $account_data); |
|
| 205 | + $data['edit_id']=$edit_id; |
|
| 206 | + $this->load->view('view_customer_details', $data); |
|
| 207 | + } else { |
|
| 208 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + function customer_save($add_array = false) { |
|
| 213 | + $add_array = $this->input->post(); |
|
| 214 | + $entity_name = strtolower($this->common->get_entity_type('', '', $add_array['type'])); |
|
| 215 | + $data['country_id'] = $add_array['country_id']; |
|
| 216 | + $data['timezone_id'] = $add_array['timezone_id']; |
|
| 217 | + $data['currency_id'] = $add_array['currency_id']; |
|
| 218 | + $data['entity_name'] = $entity_name; |
|
| 219 | + $data['callingcard'] = Common_model::$global_config['system_config']['pinlength']; |
|
| 220 | + $data['edit_id']=$add_array['id']; |
|
| 221 | + $data['form'] = $this->form->build_form($this->accounts_form->get_customer_form_fields($entity_name, $add_array['id']), $add_array); |
|
| 222 | + if ($add_array['id'] != '') { |
|
| 223 | + $data['page_title'] = 'Edit ' . $this->common->get_entity_type('', '', $add_array['type']); |
|
| 224 | + if ($this->form_validation->run() == FALSE) { |
|
| 225 | + $data['validation_errors'] = validation_errors(); |
|
| 226 | + } else { |
|
| 227 | + /* * **** |
|
| 228 | 228 | ASTPP 3.0 |
| 229 | 229 | Password encode |
| 230 | 230 | * **** */ |
| 231 | - $add_array['password'] = $this->common->encode($add_array['password']); |
|
| 232 | - /* * ****************** */ |
|
| 233 | - $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
|
| 234 | - //Purpose : Get assigned taxes value for customer |
|
| 235 | - |
|
| 236 | - $query = $this->accounts_model->remove_all_account_tax($add_array['id']); |
|
| 237 | - if (isset($add_array['tax_id'])) { |
|
| 238 | - foreach ($add_array['tax_id'] as $key => $val) { |
|
| 239 | - $data1 = array( |
|
| 240 | - 'accountid' => $add_array['id'], |
|
| 241 | - 'taxes_id' => $val, |
|
| 242 | - ); |
|
| 243 | - $this->accounts_model->add_account_tax($data1); |
|
| 244 | - } |
|
| 245 | - unset($add_array['tax_id']); |
|
| 246 | - } |
|
| 247 | - //Completed |
|
| 248 | - unset($add_array['posttoexternal'],$add_array['number']); |
|
| 249 | - $this->accounts_model->edit_account($add_array, $add_array['id']); |
|
| 250 | - $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_name) . ' updated successfully!'); |
|
| 251 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 252 | - exit; |
|
| 253 | - } |
|
| 254 | - $data["account_data"]["0"] = $add_array; |
|
| 255 | - $this->load->view('view_customer_details', $data); |
|
| 256 | - } else { |
|
| 257 | - $data['page_title'] = 'Create ' . $entity_name; |
|
| 258 | - if ($this->form_validation->run() == FALSE) { |
|
| 259 | - $data['validation_errors'] = validation_errors(); |
|
| 260 | - } else { |
|
| 261 | - /* * **** |
|
| 231 | + $add_array['password'] = $this->common->encode($add_array['password']); |
|
| 232 | + /* * ****************** */ |
|
| 233 | + $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
|
| 234 | + //Purpose : Get assigned taxes value for customer |
|
| 235 | + |
|
| 236 | + $query = $this->accounts_model->remove_all_account_tax($add_array['id']); |
|
| 237 | + if (isset($add_array['tax_id'])) { |
|
| 238 | + foreach ($add_array['tax_id'] as $key => $val) { |
|
| 239 | + $data1 = array( |
|
| 240 | + 'accountid' => $add_array['id'], |
|
| 241 | + 'taxes_id' => $val, |
|
| 242 | + ); |
|
| 243 | + $this->accounts_model->add_account_tax($data1); |
|
| 244 | + } |
|
| 245 | + unset($add_array['tax_id']); |
|
| 246 | + } |
|
| 247 | + //Completed |
|
| 248 | + unset($add_array['posttoexternal'],$add_array['number']); |
|
| 249 | + $this->accounts_model->edit_account($add_array, $add_array['id']); |
|
| 250 | + $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_name) . ' updated successfully!'); |
|
| 251 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 252 | + exit; |
|
| 253 | + } |
|
| 254 | + $data["account_data"]["0"] = $add_array; |
|
| 255 | + $this->load->view('view_customer_details', $data); |
|
| 256 | + } else { |
|
| 257 | + $data['page_title'] = 'Create ' . $entity_name; |
|
| 258 | + if ($this->form_validation->run() == FALSE) { |
|
| 259 | + $data['validation_errors'] = validation_errors(); |
|
| 260 | + } else { |
|
| 261 | + /* * **** |
|
| 262 | 262 | ASTPP 3.0 |
| 263 | 263 | Password encode |
| 264 | 264 | * **** */ |
| 265 | - $add_array['password'] = $this->common->encode($add_array['password']); |
|
| 266 | - /* * ****************** */ |
|
| 267 | - $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
|
| 268 | - $last_id = $this->accounts_model->add_account($add_array); |
|
| 269 | - |
|
| 270 | - if (isset($add_array['tax_id'])) { |
|
| 271 | - foreach ($add_array['tax_id'] as $key => $val) { |
|
| 272 | - $data1 = array( |
|
| 273 | - 'accountid' => $last_id, |
|
| 274 | - 'taxes_id' => $val, |
|
| 275 | - ); |
|
| 276 | - $this->accounts_model->add_account_tax($data1); |
|
| 277 | - } |
|
| 278 | - unset($add_array['tax_id']); |
|
| 279 | - } |
|
| 280 | - $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_name) . ' added successfully!'); |
|
| 281 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 282 | - exit; |
|
| 283 | - } |
|
| 284 | - $this->load->view('view_accounts_create', $data); |
|
| 285 | - } |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - function provider_speeddial($edit_id) { |
|
| 289 | - $this->customer_speeddial($edit_id); |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - function customer_speeddial($edit_id) { |
|
| 293 | - //Get Account information from session. |
|
| 294 | - $data['page_title'] = "Speed Dial"; |
|
| 295 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 296 | - //Get Parent informartion |
|
| 297 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 298 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 299 | - $account = $this->db_model->getSelect("*", "accounts", $where); |
|
| 300 | - |
|
| 301 | - if ($account->num_rows > 0) { |
|
| 302 | - $account_data = (array) $account->first_row(); |
|
| 303 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 304 | - $data['page_title'] = 'Speed Dial'; |
|
| 305 | - $data['accounttype'] = $accounttype; |
|
| 306 | - $data['invoice_date'] = $account_data['invoice_day']; |
|
| 307 | - $data["account_data"] = $account_data; |
|
| 308 | - $data['edit_id'] = $edit_id; |
|
| 309 | - $speeddial_res = $this->db->get_where("speed_dial", array("accountid" => $edit_id)); |
|
| 310 | - $speeddial_info = array(); |
|
| 311 | - if ($speeddial_res->num_rows() > 0) { |
|
| 312 | - $speeddial_res = $speeddial_res->result_array(); |
|
| 313 | - foreach ($speeddial_res as $key => $value) { |
|
| 314 | - $speeddial_info[$value['speed_num']] = $value['number']; |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - $data['speeddial'] = $speeddial_info; |
|
| 318 | - $data['form'] = $this->form->build_form($this->accounts_form->get_customer_form_fields($accounttype, $edit_id), $account_data); |
|
| 319 | - $this->load->view('view_customer_speed_dial', $data); |
|
| 320 | - } else { |
|
| 321 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 322 | - } |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - function customer_speeddial_save($number, $accountid, $speed_num) { |
|
| 326 | - $where = array("accountid" => $accountid); |
|
| 327 | - $account = $this->db_model->getSelect("*", "speed_dial", $where); |
|
| 328 | - if ($account->num_rows() == 0) { |
|
| 329 | - for ($i = 0; $i <= 9; $i++) { |
|
| 330 | - $dest_number = $speed_num == $i ? $number : ''; |
|
| 331 | - $data[$i] = array("number" => $dest_number, "speed_num" => $i, 'accountid' => $accountid); |
|
| 332 | - } |
|
| 333 | - $this->db->insert_batch('speed_dial', $data); |
|
| 334 | - } else { |
|
| 335 | - $updateinfo = array('number' => $number); |
|
| 336 | - $this->db->where('speed_num', $speed_num); |
|
| 337 | - $this->db->where('accountid', $accountid); |
|
| 338 | - $result = $this->db->update('speed_dial', $updateinfo); |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - function customer_speeddial_remove($accountid, $speed_num) { |
|
| 343 | - $updateinfo = array('number' => ''); |
|
| 344 | - $this->db->where('speed_num', $speed_num); |
|
| 345 | - $this->db->where('accountid', $accountid); |
|
| 346 | - $result = $this->db->update('speed_dial', $updateinfo); |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - function provider_ipmap($edit_id) { |
|
| 350 | - $this->customer_ipmap($edit_id); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - function customer_ipmap($edit_id) { |
|
| 354 | - $data['page_title'] = "IP Settings"; |
|
| 355 | - $data['add_form']=true; |
|
| 356 | - //Get Account information from session. |
|
| 357 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 358 | - //Get Parent informartion |
|
| 359 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 360 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 361 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 362 | - if ($account_res->num_rows > 0) { |
|
| 363 | - $account_data = (array) $account_res->first_row(); |
|
| 364 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 365 | - $data["grid_fields"] = $this->accounts_form->build_ip_list_for_customer($edit_id, $accounttype); |
|
| 366 | - $data['edit_id'] = $edit_id; |
|
| 367 | - $data['accounttype'] = $accounttype; |
|
| 368 | - $this->load->view('view_customer_ipmap', $data); |
|
| 369 | - } else { |
|
| 370 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 371 | - exit; |
|
| 372 | - } |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - function customer_ipmap_json($accountid, $accounttype) { |
|
| 376 | - $json_data = array(); |
|
| 377 | - $where = array("accountid" => $accountid); |
|
| 378 | - $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_ipmap'); |
|
| 379 | - $like_str=!empty($instant_search) ? "(name like '%$instant_search%' OR ip like '%$instant_search%' OR prefix like '%$instant_search%' OR created_date like '%$instant_search%' )" :null; |
|
| 380 | - if(!empty($like_str)) |
|
| 381 | - $this->db->where($like_str); |
|
| 382 | - $count_all = $this->db_model->countQuery("*", "ip_map", $where); |
|
| 383 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 384 | - $json_data = $paging_data["json_paging"]; |
|
| 385 | - if(!empty($like_str)) |
|
| 386 | - $this->db->where($like_str); |
|
| 387 | - $query = $this->db_model->select("*", "ip_map", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
|
| 388 | - $grid_fields = json_decode($this->accounts_form->build_ip_list_for_customer($accountid, $accounttype)); |
|
| 389 | - $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
| 265 | + $add_array['password'] = $this->common->encode($add_array['password']); |
|
| 266 | + /* * ****************** */ |
|
| 267 | + $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
|
| 268 | + $last_id = $this->accounts_model->add_account($add_array); |
|
| 269 | + |
|
| 270 | + if (isset($add_array['tax_id'])) { |
|
| 271 | + foreach ($add_array['tax_id'] as $key => $val) { |
|
| 272 | + $data1 = array( |
|
| 273 | + 'accountid' => $last_id, |
|
| 274 | + 'taxes_id' => $val, |
|
| 275 | + ); |
|
| 276 | + $this->accounts_model->add_account_tax($data1); |
|
| 277 | + } |
|
| 278 | + unset($add_array['tax_id']); |
|
| 279 | + } |
|
| 280 | + $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_name) . ' added successfully!'); |
|
| 281 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 282 | + exit; |
|
| 283 | + } |
|
| 284 | + $this->load->view('view_accounts_create', $data); |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + function provider_speeddial($edit_id) { |
|
| 289 | + $this->customer_speeddial($edit_id); |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + function customer_speeddial($edit_id) { |
|
| 293 | + //Get Account information from session. |
|
| 294 | + $data['page_title'] = "Speed Dial"; |
|
| 295 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 296 | + //Get Parent informartion |
|
| 297 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 298 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 299 | + $account = $this->db_model->getSelect("*", "accounts", $where); |
|
| 300 | + |
|
| 301 | + if ($account->num_rows > 0) { |
|
| 302 | + $account_data = (array) $account->first_row(); |
|
| 303 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 304 | + $data['page_title'] = 'Speed Dial'; |
|
| 305 | + $data['accounttype'] = $accounttype; |
|
| 306 | + $data['invoice_date'] = $account_data['invoice_day']; |
|
| 307 | + $data["account_data"] = $account_data; |
|
| 308 | + $data['edit_id'] = $edit_id; |
|
| 309 | + $speeddial_res = $this->db->get_where("speed_dial", array("accountid" => $edit_id)); |
|
| 310 | + $speeddial_info = array(); |
|
| 311 | + if ($speeddial_res->num_rows() > 0) { |
|
| 312 | + $speeddial_res = $speeddial_res->result_array(); |
|
| 313 | + foreach ($speeddial_res as $key => $value) { |
|
| 314 | + $speeddial_info[$value['speed_num']] = $value['number']; |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + $data['speeddial'] = $speeddial_info; |
|
| 318 | + $data['form'] = $this->form->build_form($this->accounts_form->get_customer_form_fields($accounttype, $edit_id), $account_data); |
|
| 319 | + $this->load->view('view_customer_speed_dial', $data); |
|
| 320 | + } else { |
|
| 321 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + function customer_speeddial_save($number, $accountid, $speed_num) { |
|
| 326 | + $where = array("accountid" => $accountid); |
|
| 327 | + $account = $this->db_model->getSelect("*", "speed_dial", $where); |
|
| 328 | + if ($account->num_rows() == 0) { |
|
| 329 | + for ($i = 0; $i <= 9; $i++) { |
|
| 330 | + $dest_number = $speed_num == $i ? $number : ''; |
|
| 331 | + $data[$i] = array("number" => $dest_number, "speed_num" => $i, 'accountid' => $accountid); |
|
| 332 | + } |
|
| 333 | + $this->db->insert_batch('speed_dial', $data); |
|
| 334 | + } else { |
|
| 335 | + $updateinfo = array('number' => $number); |
|
| 336 | + $this->db->where('speed_num', $speed_num); |
|
| 337 | + $this->db->where('accountid', $accountid); |
|
| 338 | + $result = $this->db->update('speed_dial', $updateinfo); |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + function customer_speeddial_remove($accountid, $speed_num) { |
|
| 343 | + $updateinfo = array('number' => ''); |
|
| 344 | + $this->db->where('speed_num', $speed_num); |
|
| 345 | + $this->db->where('accountid', $accountid); |
|
| 346 | + $result = $this->db->update('speed_dial', $updateinfo); |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + function provider_ipmap($edit_id) { |
|
| 350 | + $this->customer_ipmap($edit_id); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + function customer_ipmap($edit_id) { |
|
| 354 | + $data['page_title'] = "IP Settings"; |
|
| 355 | + $data['add_form']=true; |
|
| 356 | + //Get Account information from session. |
|
| 357 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 358 | + //Get Parent informartion |
|
| 359 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 360 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 361 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 362 | + if ($account_res->num_rows > 0) { |
|
| 363 | + $account_data = (array) $account_res->first_row(); |
|
| 364 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 365 | + $data["grid_fields"] = $this->accounts_form->build_ip_list_for_customer($edit_id, $accounttype); |
|
| 366 | + $data['edit_id'] = $edit_id; |
|
| 367 | + $data['accounttype'] = $accounttype; |
|
| 368 | + $this->load->view('view_customer_ipmap', $data); |
|
| 369 | + } else { |
|
| 370 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 371 | + exit; |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + function customer_ipmap_json($accountid, $accounttype) { |
|
| 376 | + $json_data = array(); |
|
| 377 | + $where = array("accountid" => $accountid); |
|
| 378 | + $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_ipmap'); |
|
| 379 | + $like_str=!empty($instant_search) ? "(name like '%$instant_search%' OR ip like '%$instant_search%' OR prefix like '%$instant_search%' OR created_date like '%$instant_search%' )" :null; |
|
| 380 | + if(!empty($like_str)) |
|
| 381 | + $this->db->where($like_str); |
|
| 382 | + $count_all = $this->db_model->countQuery("*", "ip_map", $where); |
|
| 383 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 384 | + $json_data = $paging_data["json_paging"]; |
|
| 385 | + if(!empty($like_str)) |
|
| 386 | + $this->db->where($like_str); |
|
| 387 | + $query = $this->db_model->select("*", "ip_map", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
|
| 388 | + $grid_fields = json_decode($this->accounts_form->build_ip_list_for_customer($accountid, $accounttype)); |
|
| 389 | + $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
| 390 | 390 | |
| 391 | - echo json_encode($json_data); |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - function provider_ipmap_action($action, $accountid, $accounttype, $ipmapid = "") { |
|
| 395 | - $this->customer_ipmap_action($action, $accountid, $accounttype, $ipmapid); |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - function customer_ipmap_action($action, $accountid, $accounttype, $ipmapid = "") { |
|
| 399 | - $add_array = $this->input->post(); |
|
| 400 | - if ($action == "add") { |
|
| 401 | - if ($add_array['ip'] != "") { |
|
| 402 | - $ip = $add_array['ip']; |
|
| 403 | - if (strpos($ip, '/') !== false) { |
|
| 404 | - $add_array['ip'] = $add_array['ip']; |
|
| 405 | - } else { |
|
| 406 | - $add_array['ip'] = $add_array['ip'] . '/32'; |
|
| 407 | - } |
|
| 408 | - $where = array("ip" => trim($add_array['ip']), "prefix" => trim($add_array['prefix'])); |
|
| 409 | - $getdata = $this->db_model->countQuery("*", "ip_map", $where); |
|
| 410 | - if ($getdata > 0) { |
|
| 411 | - $this->session->set_flashdata('astpp_notification', 'IP already exist in system.'); |
|
| 412 | - } else { |
|
| 413 | - if ($accounttype == "provider") { |
|
| 414 | - $add_array['pricelist_id'] = 0; |
|
| 415 | - } |
|
| 416 | - unset($add_array['action']); |
|
| 417 | - $add_array['context'] = 'default'; |
|
| 418 | - $add_array['accountid'] = $accountid; |
|
| 419 | - $ip_flag = $this->db->insert("ip_map", $add_array); |
|
| 420 | - if ($ip_flag) { |
|
| 421 | - $this->load->library('freeswitch_lib'); |
|
| 422 | - $this->load->module('freeswitch/freeswitch'); |
|
| 423 | - $command = "api reloadacl"; |
|
| 424 | - $response = $this->freeswitch_model->reload_freeswitch($command); |
|
| 425 | - $this->session->set_userdata('astpp_notification', $response); |
|
| 426 | - } |
|
| 427 | - $this->session->set_flashdata('astpp_errormsg', 'IP added sucessfully.'); |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - } |
|
| 431 | - if ($action == "delete") { |
|
| 432 | - $ip_flag = $this->db_model->delete("ip_map", array("id" => $ipmapid)); |
|
| 433 | - if ($ip_flag) { |
|
| 434 | - $this->load->library('freeswitch_lib'); |
|
| 435 | - $this->load->model("freeswitch_model"); |
|
| 436 | - $command = "api reloadacl"; |
|
| 437 | - $this->freeswitch_model->reload_freeswitch($command); |
|
| 438 | - } |
|
| 439 | - $this->session->set_flashdata('astpp_notification', 'IP removed sucessfully.'); |
|
| 440 | - } |
|
| 441 | - redirect(base_url() . "accounts/" . $accounttype . "_ipmap/" . $accountid . "/"); |
|
| 442 | - } |
|
| 443 | - |
|
| 444 | - //This function using for provider t |
|
| 445 | - function provider_animap($edit_id) { |
|
| 446 | - $this->customer_animap($edit_id, 'provider'); |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - // This function using for showing data of customer/provider CallerID Tab |
|
| 450 | - function customer_animap($edit_id, $entity_type = 'customer') { |
|
| 451 | - //Get Account information from session. |
|
| 452 | - $data['page_title'] = "Caller ID"; |
|
| 453 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 454 | - //Get Parent informartion |
|
| 455 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 456 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 457 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 458 | - if ($account_res->num_rows > 0) { |
|
| 459 | - $account_data = (array) $account_res->first_row(); |
|
| 460 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 461 | - $data["grid_fields"] = $this->accounts_form->build_animap_list_for_customer($edit_id, $accounttype); |
|
| 462 | - $data['edit_id'] = $edit_id; |
|
| 463 | - $data['accounttype'] = $accounttype; |
|
| 464 | - $this->load->view('view_customer_animap', $data); |
|
| 465 | - } else { |
|
| 466 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 467 | - exit; |
|
| 468 | - } |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - function customer_animap_json($accountid, $accounttype) { |
|
| 472 | - $json_data = array(); |
|
| 473 | - $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_animap'); |
|
| 474 | - $like_str=!empty($instant_search) ? "(number like '%$instant_search%' OR creation_date like '%$instant_search%' )" :null; |
|
| 475 | - if(!empty($like_str)) |
|
| 476 | - $this->db->where($like_str); |
|
| 477 | - $where = array("accountid" => $accountid); |
|
| 478 | - $count_all = $this->db_model->countQuery("*", "ani_map", $where); |
|
| 479 | - |
|
| 480 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 481 | - $json_data = $paging_data["json_paging"]; |
|
| 482 | - if(!empty($like_str)) |
|
| 483 | - $this->db->where($like_str); |
|
| 484 | - $query = $this->db_model->select("*", "ani_map", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
|
| 485 | - |
|
| 486 | - $grid_fields = json_decode($this->accounts_form->build_animap_list_for_customer($accountid, $accounttype)); |
|
| 487 | - $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
| 488 | - |
|
| 489 | - echo json_encode($json_data); |
|
| 490 | - } |
|
| 491 | - |
|
| 492 | - function provider_animap_action($action, $accountid, $aniid = "") { |
|
| 493 | - $this->customer_animap_action($action, $accountid, $aniid); |
|
| 494 | - } |
|
| 495 | - |
|
| 496 | - //This function using for customer/provider callerID add/delete |
|
| 497 | - function customer_animap_action($action, $accountid, $aniid = "") { |
|
| 498 | - $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
|
| 499 | - $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
|
| 500 | - $url = "accounts/" . $entity_type . "_animap/$accountid/"; |
|
| 501 | - if ($action == "add") { |
|
| 502 | - $ani = $this->input->post(); |
|
| 503 | - $this->db->where('number', $ani['number']); |
|
| 504 | - $this->db->select('count(id) as count'); |
|
| 505 | - $cnt_result = $this->db->get('ani_map'); |
|
| 506 | - $cnt_result = $cnt_result->result_array(); |
|
| 507 | - $count = $cnt_result[0]['count']; |
|
| 508 | - if ($count == 0) { |
|
| 509 | - if ($ani['number'] != "") { |
|
| 510 | - /* |
|
| 391 | + echo json_encode($json_data); |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + function provider_ipmap_action($action, $accountid, $accounttype, $ipmapid = "") { |
|
| 395 | + $this->customer_ipmap_action($action, $accountid, $accounttype, $ipmapid); |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + function customer_ipmap_action($action, $accountid, $accounttype, $ipmapid = "") { |
|
| 399 | + $add_array = $this->input->post(); |
|
| 400 | + if ($action == "add") { |
|
| 401 | + if ($add_array['ip'] != "") { |
|
| 402 | + $ip = $add_array['ip']; |
|
| 403 | + if (strpos($ip, '/') !== false) { |
|
| 404 | + $add_array['ip'] = $add_array['ip']; |
|
| 405 | + } else { |
|
| 406 | + $add_array['ip'] = $add_array['ip'] . '/32'; |
|
| 407 | + } |
|
| 408 | + $where = array("ip" => trim($add_array['ip']), "prefix" => trim($add_array['prefix'])); |
|
| 409 | + $getdata = $this->db_model->countQuery("*", "ip_map", $where); |
|
| 410 | + if ($getdata > 0) { |
|
| 411 | + $this->session->set_flashdata('astpp_notification', 'IP already exist in system.'); |
|
| 412 | + } else { |
|
| 413 | + if ($accounttype == "provider") { |
|
| 414 | + $add_array['pricelist_id'] = 0; |
|
| 415 | + } |
|
| 416 | + unset($add_array['action']); |
|
| 417 | + $add_array['context'] = 'default'; |
|
| 418 | + $add_array['accountid'] = $accountid; |
|
| 419 | + $ip_flag = $this->db->insert("ip_map", $add_array); |
|
| 420 | + if ($ip_flag) { |
|
| 421 | + $this->load->library('freeswitch_lib'); |
|
| 422 | + $this->load->module('freeswitch/freeswitch'); |
|
| 423 | + $command = "api reloadacl"; |
|
| 424 | + $response = $this->freeswitch_model->reload_freeswitch($command); |
|
| 425 | + $this->session->set_userdata('astpp_notification', $response); |
|
| 426 | + } |
|
| 427 | + $this->session->set_flashdata('astpp_errormsg', 'IP added sucessfully.'); |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + if ($action == "delete") { |
|
| 432 | + $ip_flag = $this->db_model->delete("ip_map", array("id" => $ipmapid)); |
|
| 433 | + if ($ip_flag) { |
|
| 434 | + $this->load->library('freeswitch_lib'); |
|
| 435 | + $this->load->model("freeswitch_model"); |
|
| 436 | + $command = "api reloadacl"; |
|
| 437 | + $this->freeswitch_model->reload_freeswitch($command); |
|
| 438 | + } |
|
| 439 | + $this->session->set_flashdata('astpp_notification', 'IP removed sucessfully.'); |
|
| 440 | + } |
|
| 441 | + redirect(base_url() . "accounts/" . $accounttype . "_ipmap/" . $accountid . "/"); |
|
| 442 | + } |
|
| 443 | + |
|
| 444 | + //This function using for provider t |
|
| 445 | + function provider_animap($edit_id) { |
|
| 446 | + $this->customer_animap($edit_id, 'provider'); |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + // This function using for showing data of customer/provider CallerID Tab |
|
| 450 | + function customer_animap($edit_id, $entity_type = 'customer') { |
|
| 451 | + //Get Account information from session. |
|
| 452 | + $data['page_title'] = "Caller ID"; |
|
| 453 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 454 | + //Get Parent informartion |
|
| 455 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 456 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 457 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 458 | + if ($account_res->num_rows > 0) { |
|
| 459 | + $account_data = (array) $account_res->first_row(); |
|
| 460 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 461 | + $data["grid_fields"] = $this->accounts_form->build_animap_list_for_customer($edit_id, $accounttype); |
|
| 462 | + $data['edit_id'] = $edit_id; |
|
| 463 | + $data['accounttype'] = $accounttype; |
|
| 464 | + $this->load->view('view_customer_animap', $data); |
|
| 465 | + } else { |
|
| 466 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 467 | + exit; |
|
| 468 | + } |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + function customer_animap_json($accountid, $accounttype) { |
|
| 472 | + $json_data = array(); |
|
| 473 | + $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_animap'); |
|
| 474 | + $like_str=!empty($instant_search) ? "(number like '%$instant_search%' OR creation_date like '%$instant_search%' )" :null; |
|
| 475 | + if(!empty($like_str)) |
|
| 476 | + $this->db->where($like_str); |
|
| 477 | + $where = array("accountid" => $accountid); |
|
| 478 | + $count_all = $this->db_model->countQuery("*", "ani_map", $where); |
|
| 479 | + |
|
| 480 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 481 | + $json_data = $paging_data["json_paging"]; |
|
| 482 | + if(!empty($like_str)) |
|
| 483 | + $this->db->where($like_str); |
|
| 484 | + $query = $this->db_model->select("*", "ani_map", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
|
| 485 | + |
|
| 486 | + $grid_fields = json_decode($this->accounts_form->build_animap_list_for_customer($accountid, $accounttype)); |
|
| 487 | + $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
| 488 | + |
|
| 489 | + echo json_encode($json_data); |
|
| 490 | + } |
|
| 491 | + |
|
| 492 | + function provider_animap_action($action, $accountid, $aniid = "") { |
|
| 493 | + $this->customer_animap_action($action, $accountid, $aniid); |
|
| 494 | + } |
|
| 495 | + |
|
| 496 | + //This function using for customer/provider callerID add/delete |
|
| 497 | + function customer_animap_action($action, $accountid, $aniid = "") { |
|
| 498 | + $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
|
| 499 | + $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
|
| 500 | + $url = "accounts/" . $entity_type . "_animap/$accountid/"; |
|
| 501 | + if ($action == "add") { |
|
| 502 | + $ani = $this->input->post(); |
|
| 503 | + $this->db->where('number', $ani['number']); |
|
| 504 | + $this->db->select('count(id) as count'); |
|
| 505 | + $cnt_result = $this->db->get('ani_map'); |
|
| 506 | + $cnt_result = $cnt_result->result_array(); |
|
| 507 | + $count = $cnt_result[0]['count']; |
|
| 508 | + if ($count == 0) { |
|
| 509 | + if ($ani['number'] != "") { |
|
| 510 | + /* |
|
| 511 | 511 | ASTPP 3.0 |
| 512 | 512 | Add creation field |
| 513 | 513 | */ |
| 514 | - $insert_arr = array('creation_date' => gmdate('Y-m-d H:i:s'), "number" => $this->input->post('number'), "accountid" => $accountid, |
|
| 515 | - "context" => "default"); |
|
| 516 | - /* * *********************************** */ |
|
| 517 | - $this->db->insert("ani_map", $insert_arr); |
|
| 518 | - $this->session->set_flashdata('astpp_errormsg', 'Caller ID added successfully!'); |
|
| 519 | - } else { |
|
| 520 | - $this->session->set_flashdata('astpp_notification', 'Please Enter Caller ID value.'); |
|
| 521 | - } |
|
| 522 | - } else { |
|
| 523 | - $this->session->set_flashdata('astpp_notification', ' Caller ID already Exists.'); |
|
| 524 | - } |
|
| 525 | - } |
|
| 526 | - if ($action == "delete") { |
|
| 527 | - $this->session->set_flashdata('astpp_notification', 'Caller ID removed sucessfully!'); |
|
| 528 | - $this->db_model->delete("ani_map", array("id" => $aniid)); |
|
| 529 | - } |
|
| 530 | - redirect(base_url() . $url); |
|
| 531 | - } |
|
| 532 | - |
|
| 533 | - //This function using by Customer/Provider edit tab |
|
| 534 | - function customer_details_json($module, $accountid) { |
|
| 535 | - $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
|
| 536 | - $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
|
| 537 | - if ($module == "pattern") { |
|
| 538 | - $this->load->module('rates/rates'); |
|
| 539 | - $this->rates->customer_block_pattern_list($accountid, $entity_type); |
|
| 540 | - } |
|
| 541 | - if ($module == "freeswitch") { |
|
| 542 | - $this->load->module('freeswitch/freeswitch'); |
|
| 543 | - $this->freeswitch->customer_fssipdevices_json($accountid, $entity_type); |
|
| 544 | - } |
|
| 545 | - if ($module == "did") { |
|
| 546 | - $this->load->module('did/did'); |
|
| 547 | - $this->did->customer_did($accountid, $entity_type); |
|
| 548 | - } |
|
| 549 | - if ($module == "invoices") { |
|
| 550 | - $this->load->module('invoices/invoices'); |
|
| 551 | - $this->invoices->customer_invoices($accountid,$entity_type, false); |
|
| 552 | - } |
|
| 553 | - if ($module == "subscription") { |
|
| 554 | - $this->load->module('charges/charges'); |
|
| 555 | - $this->charges->customer_charge_list($accountid, $entity_type); |
|
| 556 | - } |
|
| 557 | - if ($module == "cdrs") { |
|
| 558 | - $this->load->module('reports/reports'); |
|
| 559 | - $this->reports->customer_cdrreport($accountid, $entity_type); |
|
| 560 | - } |
|
| 561 | - if ($module == "charges") { |
|
| 562 | - $this->load->module('reports/reports'); |
|
| 563 | - $this->reports->customer_charge_history($accountid,$entity_type); |
|
| 564 | - } |
|
| 565 | - if ($module == "refill") { |
|
| 566 | - $this->load->module('reports/reports'); |
|
| 567 | - $this->reports->customer_refillreport($accountid,$entity_type); |
|
| 568 | - } |
|
| 569 | - if ($module == "emailhistory") { |
|
| 570 | - $this->load->module('email/email'); |
|
| 571 | - $this->email->customer_mail_record($accountid, $entity_type); |
|
| 572 | - } |
|
| 573 | - if ($module == "opensips") { |
|
| 574 | - $this->load->module('opensips/opensips'); |
|
| 575 | - $this->opensips->customer_opensips_json($accountid,$entity_type); |
|
| 576 | - } |
|
| 577 | - } |
|
| 578 | - function customer_details_search($module_name){ |
|
| 579 | - $action = $this->input->post(); |
|
| 580 | - $this->session->set_userdata('left_panel_search_'.$module_name,""); |
|
| 581 | - if(!empty($action['left_panel_search'])){ |
|
| 582 | - $this->session->set_userdata('left_panel_search_'.$module_name, $action['left_panel_search']); |
|
| 583 | - } |
|
| 584 | - } |
|
| 585 | - function provider_sipdevices($edit_id) { |
|
| 586 | - $this->customer_sipdevices($edit_id); |
|
| 587 | - } |
|
| 588 | - |
|
| 589 | - function customer_sipdevices($edit_id) { |
|
| 590 | - $data['page_title'] = "SIP Devices"; |
|
| 591 | - //Get Account information from session. |
|
| 592 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 593 | - //Get Parent informartion |
|
| 594 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 595 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 596 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 597 | - if ($account_res->num_rows > 0) { |
|
| 598 | - $account_data = (array) $account_res->first_row(); |
|
| 599 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 600 | - $this->load->module('freeswitch/freeswitch'); |
|
| 601 | - $data["grid_buttons"] = $this->freeswitch->freeswitch_form->fsdevices_build_grid_buttons($edit_id, $accounttype); |
|
| 602 | - $data['grid_fields'] = $this->freeswitch->freeswitch_form->build_devices_list_for_customer(); |
|
| 603 | - $data['edit_id'] = $edit_id; |
|
| 604 | - $data['accounttype'] = $accounttype; |
|
| 605 | - $this->load->view('view_customer_sipdevices', $data); |
|
| 606 | - } else { |
|
| 607 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 608 | - exit; |
|
| 609 | - } |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - function provider_fssipdevices_action($action, $id, $accountid) { |
|
| 613 | - $this->customer_fssipdevices_action($action, $id, $accountid); |
|
| 614 | - } |
|
| 615 | - |
|
| 616 | - function customer_fssipdevices_action($action, $id, $accountid) { |
|
| 617 | - $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
|
| 618 | - $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
|
| 619 | - $this->load->module('freeswitch/freeswitch'); |
|
| 620 | - if ($action == "delete") { |
|
| 621 | - $this->freeswitch->freeswitch_model->delete_freeswith_devices($id); |
|
| 622 | - $this->session->set_flashdata('astpp_notification', 'Sip Device removed successfully!'); |
|
| 623 | - redirect(base_url() . "accounts/" . $entity_type . "_sipdevices/$accountid/"); |
|
| 624 | - } |
|
| 625 | - if ($action == "edit") { |
|
| 626 | - $this->freeswitch->customer_fssipdevices_edit($id, $accountid); |
|
| 627 | - $this->session->set_flashdata('astpp_errormsg', 'Sip updated successfully!'); |
|
| 628 | - } |
|
| 629 | - } |
|
| 630 | - |
|
| 631 | - function provider_opensips($edit_id) { |
|
| 632 | - $this->customer_opensips($edit_id); |
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - function customer_opensips($edit_id) { |
|
| 636 | - $data['page_title'] = "Opensips Devices"; |
|
| 637 | - //Get Account information from session. |
|
| 638 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 639 | - //Get Parent informartion |
|
| 640 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 641 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 642 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 643 | - if ($account_res->num_rows > 0) { |
|
| 644 | - $account_data = (array) $account_res->first_row(); |
|
| 645 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 646 | - $this->load->module('freeswitch/freeswitch'); |
|
| 647 | - $this->load->module('opensips/opensips'); |
|
| 648 | - $data["grid_buttons"] = $this->opensips->opensips_form->opensips_customer_build_grid_buttons($edit_id); |
|
| 649 | - $data['grid_fields'] = $this->opensips->opensips_form->opensips_customer_build_opensips_list($edit_id); |
|
| 650 | - $data['edit_id'] = $edit_id; |
|
| 651 | - $data['accounttype'] = $accounttype; |
|
| 652 | - $this->load->view('view_customer_opensips_devices', $data); |
|
| 653 | - } else { |
|
| 654 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 655 | - exit; |
|
| 656 | - } |
|
| 657 | - } |
|
| 658 | - |
|
| 659 | - function customer_opensips_action($action, $accountid, $id) { |
|
| 660 | - $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
|
| 661 | - $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
|
| 662 | - $url = "accounts/" . $entity_type . "_opensips/$accountid/"; |
|
| 663 | - $this->load->module('opensips/opensips'); |
|
| 664 | - if ($action == "delete") { |
|
| 665 | - $this->opensips->opensips_model->remove_opensips($id); |
|
| 666 | - $this->session->set_flashdata('astpp_notification', 'Opensips removed successfully!'); |
|
| 667 | - redirect(base_url() . $url); |
|
| 668 | - } |
|
| 669 | - if ($action == "edit") { |
|
| 670 | - $this->opensips->customer_opensips_edit($accountid, $id); |
|
| 671 | - $this->session->set_flashdata('astpp_errormsg', 'Opensips updated successfully!'); |
|
| 672 | - } |
|
| 673 | - } |
|
| 674 | - |
|
| 675 | - function provider_charges($edit_id) { |
|
| 676 | - $this->customer_charges($edit_id); |
|
| 677 | - } |
|
| 678 | - |
|
| 679 | - function reseller_charges($edit_id) { |
|
| 680 | - $this->customer_charges($edit_id); |
|
| 681 | - } |
|
| 682 | - |
|
| 683 | - function customer_charges($edit_id) { |
|
| 684 | - $data['page_title'] = "Charges History"; |
|
| 685 | - //Get Account information from session. |
|
| 686 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 687 | - //Get Parent informartion |
|
| 688 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 689 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 690 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 691 | - if ($account_res->num_rows > 0) { |
|
| 692 | - $account_data = (array) $account_res->first_row(); |
|
| 693 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 694 | - $data['chargelist'] = form_dropdown('applayable_charge', $this->Astpp_common->list_applyable_charges($edit_id), ''); |
|
| 695 | - $this->load->module('reports/reports'); |
|
| 696 | - $data['grid_fields'] = $this->reports->reports_form->build_charge_list_for_customer($edit_id, $accounttype); |
|
| 697 | - $data['edit_id'] = $edit_id; |
|
| 698 | - $data['accounttype'] = $accounttype; |
|
| 699 | - $this->load->view('view_customer_charges', $data); |
|
| 700 | - } else { |
|
| 701 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 702 | - exit; |
|
| 703 | - } |
|
| 704 | - } |
|
| 705 | - |
|
| 706 | - function provider_subscription($edit_id) { |
|
| 707 | - $this->customer_subscription($edit_id); |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - function reseller_subscription($edit_id) { |
|
| 711 | - $this->customer_subscription($edit_id); |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - function customer_subscription($edit_id) { |
|
| 715 | - $data['page_title'] = "Subscription"; |
|
| 716 | - //Get Account information from session. |
|
| 717 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 718 | - //Get Parent informartion |
|
| 719 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 720 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 721 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 722 | - if ($account_res->num_rows > 0) { |
|
| 723 | - $account_data = (array) $account_res->first_row(); |
|
| 724 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 725 | - $data['chargelist'] = form_dropdown_all(array("name" => 'applayable_charge', 'id' => 'applayable_charge', 'class' => ""), $this->Astpp_common->list_applyable_charges($edit_id), ''); |
|
| 726 | - $this->load->module('charges/charges'); |
|
| 727 | - $data['grid_fields'] = $this->charges->charges_form->build_charges_list_for_customer($edit_id, $accounttype); |
|
| 728 | - $data['edit_id'] = $edit_id; |
|
| 729 | - $data['accounttype'] = $accounttype; |
|
| 730 | - $this->load->view('view_customer_subscriptions', $data); |
|
| 731 | - } else { |
|
| 732 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 733 | - exit; |
|
| 734 | - } |
|
| 735 | - } |
|
| 736 | - |
|
| 737 | - function reseller_subscription_action($action, $accountid, $accounttype, $chargeid = "") { |
|
| 738 | - $this->customer_subscription_action($action, $accountid, $accounttype, $chargeid); |
|
| 739 | - } |
|
| 740 | - |
|
| 741 | - function provider_subscription_action($action, $accountid, $accounttype, $chargeid = "") { |
|
| 742 | - $this->customer_subscription_action($action, $accountid, $accounttype, $chargeid); |
|
| 743 | - } |
|
| 744 | - |
|
| 745 | - function customer_subscription_action($action, $accountid, $accounttype, $chargeid = "") { |
|
| 746 | - |
|
| 747 | - /** |
|
| 514 | + $insert_arr = array('creation_date' => gmdate('Y-m-d H:i:s'), "number" => $this->input->post('number'), "accountid" => $accountid, |
|
| 515 | + "context" => "default"); |
|
| 516 | + /* * *********************************** */ |
|
| 517 | + $this->db->insert("ani_map", $insert_arr); |
|
| 518 | + $this->session->set_flashdata('astpp_errormsg', 'Caller ID added successfully!'); |
|
| 519 | + } else { |
|
| 520 | + $this->session->set_flashdata('astpp_notification', 'Please Enter Caller ID value.'); |
|
| 521 | + } |
|
| 522 | + } else { |
|
| 523 | + $this->session->set_flashdata('astpp_notification', ' Caller ID already Exists.'); |
|
| 524 | + } |
|
| 525 | + } |
|
| 526 | + if ($action == "delete") { |
|
| 527 | + $this->session->set_flashdata('astpp_notification', 'Caller ID removed sucessfully!'); |
|
| 528 | + $this->db_model->delete("ani_map", array("id" => $aniid)); |
|
| 529 | + } |
|
| 530 | + redirect(base_url() . $url); |
|
| 531 | + } |
|
| 532 | + |
|
| 533 | + //This function using by Customer/Provider edit tab |
|
| 534 | + function customer_details_json($module, $accountid) { |
|
| 535 | + $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
|
| 536 | + $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
|
| 537 | + if ($module == "pattern") { |
|
| 538 | + $this->load->module('rates/rates'); |
|
| 539 | + $this->rates->customer_block_pattern_list($accountid, $entity_type); |
|
| 540 | + } |
|
| 541 | + if ($module == "freeswitch") { |
|
| 542 | + $this->load->module('freeswitch/freeswitch'); |
|
| 543 | + $this->freeswitch->customer_fssipdevices_json($accountid, $entity_type); |
|
| 544 | + } |
|
| 545 | + if ($module == "did") { |
|
| 546 | + $this->load->module('did/did'); |
|
| 547 | + $this->did->customer_did($accountid, $entity_type); |
|
| 548 | + } |
|
| 549 | + if ($module == "invoices") { |
|
| 550 | + $this->load->module('invoices/invoices'); |
|
| 551 | + $this->invoices->customer_invoices($accountid,$entity_type, false); |
|
| 552 | + } |
|
| 553 | + if ($module == "subscription") { |
|
| 554 | + $this->load->module('charges/charges'); |
|
| 555 | + $this->charges->customer_charge_list($accountid, $entity_type); |
|
| 556 | + } |
|
| 557 | + if ($module == "cdrs") { |
|
| 558 | + $this->load->module('reports/reports'); |
|
| 559 | + $this->reports->customer_cdrreport($accountid, $entity_type); |
|
| 560 | + } |
|
| 561 | + if ($module == "charges") { |
|
| 562 | + $this->load->module('reports/reports'); |
|
| 563 | + $this->reports->customer_charge_history($accountid,$entity_type); |
|
| 564 | + } |
|
| 565 | + if ($module == "refill") { |
|
| 566 | + $this->load->module('reports/reports'); |
|
| 567 | + $this->reports->customer_refillreport($accountid,$entity_type); |
|
| 568 | + } |
|
| 569 | + if ($module == "emailhistory") { |
|
| 570 | + $this->load->module('email/email'); |
|
| 571 | + $this->email->customer_mail_record($accountid, $entity_type); |
|
| 572 | + } |
|
| 573 | + if ($module == "opensips") { |
|
| 574 | + $this->load->module('opensips/opensips'); |
|
| 575 | + $this->opensips->customer_opensips_json($accountid,$entity_type); |
|
| 576 | + } |
|
| 577 | + } |
|
| 578 | + function customer_details_search($module_name){ |
|
| 579 | + $action = $this->input->post(); |
|
| 580 | + $this->session->set_userdata('left_panel_search_'.$module_name,""); |
|
| 581 | + if(!empty($action['left_panel_search'])){ |
|
| 582 | + $this->session->set_userdata('left_panel_search_'.$module_name, $action['left_panel_search']); |
|
| 583 | + } |
|
| 584 | + } |
|
| 585 | + function provider_sipdevices($edit_id) { |
|
| 586 | + $this->customer_sipdevices($edit_id); |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + function customer_sipdevices($edit_id) { |
|
| 590 | + $data['page_title'] = "SIP Devices"; |
|
| 591 | + //Get Account information from session. |
|
| 592 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 593 | + //Get Parent informartion |
|
| 594 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 595 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 596 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 597 | + if ($account_res->num_rows > 0) { |
|
| 598 | + $account_data = (array) $account_res->first_row(); |
|
| 599 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 600 | + $this->load->module('freeswitch/freeswitch'); |
|
| 601 | + $data["grid_buttons"] = $this->freeswitch->freeswitch_form->fsdevices_build_grid_buttons($edit_id, $accounttype); |
|
| 602 | + $data['grid_fields'] = $this->freeswitch->freeswitch_form->build_devices_list_for_customer(); |
|
| 603 | + $data['edit_id'] = $edit_id; |
|
| 604 | + $data['accounttype'] = $accounttype; |
|
| 605 | + $this->load->view('view_customer_sipdevices', $data); |
|
| 606 | + } else { |
|
| 607 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 608 | + exit; |
|
| 609 | + } |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + function provider_fssipdevices_action($action, $id, $accountid) { |
|
| 613 | + $this->customer_fssipdevices_action($action, $id, $accountid); |
|
| 614 | + } |
|
| 615 | + |
|
| 616 | + function customer_fssipdevices_action($action, $id, $accountid) { |
|
| 617 | + $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
|
| 618 | + $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
|
| 619 | + $this->load->module('freeswitch/freeswitch'); |
|
| 620 | + if ($action == "delete") { |
|
| 621 | + $this->freeswitch->freeswitch_model->delete_freeswith_devices($id); |
|
| 622 | + $this->session->set_flashdata('astpp_notification', 'Sip Device removed successfully!'); |
|
| 623 | + redirect(base_url() . "accounts/" . $entity_type . "_sipdevices/$accountid/"); |
|
| 624 | + } |
|
| 625 | + if ($action == "edit") { |
|
| 626 | + $this->freeswitch->customer_fssipdevices_edit($id, $accountid); |
|
| 627 | + $this->session->set_flashdata('astpp_errormsg', 'Sip updated successfully!'); |
|
| 628 | + } |
|
| 629 | + } |
|
| 630 | + |
|
| 631 | + function provider_opensips($edit_id) { |
|
| 632 | + $this->customer_opensips($edit_id); |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + function customer_opensips($edit_id) { |
|
| 636 | + $data['page_title'] = "Opensips Devices"; |
|
| 637 | + //Get Account information from session. |
|
| 638 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 639 | + //Get Parent informartion |
|
| 640 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 641 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 642 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 643 | + if ($account_res->num_rows > 0) { |
|
| 644 | + $account_data = (array) $account_res->first_row(); |
|
| 645 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 646 | + $this->load->module('freeswitch/freeswitch'); |
|
| 647 | + $this->load->module('opensips/opensips'); |
|
| 648 | + $data["grid_buttons"] = $this->opensips->opensips_form->opensips_customer_build_grid_buttons($edit_id); |
|
| 649 | + $data['grid_fields'] = $this->opensips->opensips_form->opensips_customer_build_opensips_list($edit_id); |
|
| 650 | + $data['edit_id'] = $edit_id; |
|
| 651 | + $data['accounttype'] = $accounttype; |
|
| 652 | + $this->load->view('view_customer_opensips_devices', $data); |
|
| 653 | + } else { |
|
| 654 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 655 | + exit; |
|
| 656 | + } |
|
| 657 | + } |
|
| 658 | + |
|
| 659 | + function customer_opensips_action($action, $accountid, $id) { |
|
| 660 | + $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
|
| 661 | + $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
|
| 662 | + $url = "accounts/" . $entity_type . "_opensips/$accountid/"; |
|
| 663 | + $this->load->module('opensips/opensips'); |
|
| 664 | + if ($action == "delete") { |
|
| 665 | + $this->opensips->opensips_model->remove_opensips($id); |
|
| 666 | + $this->session->set_flashdata('astpp_notification', 'Opensips removed successfully!'); |
|
| 667 | + redirect(base_url() . $url); |
|
| 668 | + } |
|
| 669 | + if ($action == "edit") { |
|
| 670 | + $this->opensips->customer_opensips_edit($accountid, $id); |
|
| 671 | + $this->session->set_flashdata('astpp_errormsg', 'Opensips updated successfully!'); |
|
| 672 | + } |
|
| 673 | + } |
|
| 674 | + |
|
| 675 | + function provider_charges($edit_id) { |
|
| 676 | + $this->customer_charges($edit_id); |
|
| 677 | + } |
|
| 678 | + |
|
| 679 | + function reseller_charges($edit_id) { |
|
| 680 | + $this->customer_charges($edit_id); |
|
| 681 | + } |
|
| 682 | + |
|
| 683 | + function customer_charges($edit_id) { |
|
| 684 | + $data['page_title'] = "Charges History"; |
|
| 685 | + //Get Account information from session. |
|
| 686 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 687 | + //Get Parent informartion |
|
| 688 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 689 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 690 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 691 | + if ($account_res->num_rows > 0) { |
|
| 692 | + $account_data = (array) $account_res->first_row(); |
|
| 693 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 694 | + $data['chargelist'] = form_dropdown('applayable_charge', $this->Astpp_common->list_applyable_charges($edit_id), ''); |
|
| 695 | + $this->load->module('reports/reports'); |
|
| 696 | + $data['grid_fields'] = $this->reports->reports_form->build_charge_list_for_customer($edit_id, $accounttype); |
|
| 697 | + $data['edit_id'] = $edit_id; |
|
| 698 | + $data['accounttype'] = $accounttype; |
|
| 699 | + $this->load->view('view_customer_charges', $data); |
|
| 700 | + } else { |
|
| 701 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 702 | + exit; |
|
| 703 | + } |
|
| 704 | + } |
|
| 705 | + |
|
| 706 | + function provider_subscription($edit_id) { |
|
| 707 | + $this->customer_subscription($edit_id); |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + function reseller_subscription($edit_id) { |
|
| 711 | + $this->customer_subscription($edit_id); |
|
| 712 | + } |
|
| 713 | + |
|
| 714 | + function customer_subscription($edit_id) { |
|
| 715 | + $data['page_title'] = "Subscription"; |
|
| 716 | + //Get Account information from session. |
|
| 717 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 718 | + //Get Parent informartion |
|
| 719 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 720 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 721 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 722 | + if ($account_res->num_rows > 0) { |
|
| 723 | + $account_data = (array) $account_res->first_row(); |
|
| 724 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 725 | + $data['chargelist'] = form_dropdown_all(array("name" => 'applayable_charge', 'id' => 'applayable_charge', 'class' => ""), $this->Astpp_common->list_applyable_charges($edit_id), ''); |
|
| 726 | + $this->load->module('charges/charges'); |
|
| 727 | + $data['grid_fields'] = $this->charges->charges_form->build_charges_list_for_customer($edit_id, $accounttype); |
|
| 728 | + $data['edit_id'] = $edit_id; |
|
| 729 | + $data['accounttype'] = $accounttype; |
|
| 730 | + $this->load->view('view_customer_subscriptions', $data); |
|
| 731 | + } else { |
|
| 732 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 733 | + exit; |
|
| 734 | + } |
|
| 735 | + } |
|
| 736 | + |
|
| 737 | + function reseller_subscription_action($action, $accountid, $accounttype, $chargeid = "") { |
|
| 738 | + $this->customer_subscription_action($action, $accountid, $accounttype, $chargeid); |
|
| 739 | + } |
|
| 740 | + |
|
| 741 | + function provider_subscription_action($action, $accountid, $accounttype, $chargeid = "") { |
|
| 742 | + $this->customer_subscription_action($action, $accountid, $accounttype, $chargeid); |
|
| 743 | + } |
|
| 744 | + |
|
| 745 | + function customer_subscription_action($action, $accountid, $accounttype, $chargeid = "") { |
|
| 746 | + |
|
| 747 | + /** |
|
| 748 | 748 | ASTPP 3.0 |
| 749 | 749 | For Email Broadcast when Subscription Add - Delete |
| 750 | - * */ |
|
| 751 | - $accountinfo = $this->db_model->getSelect("*", "accounts", array("id" => $accountid)); |
|
| 752 | - $accountinfo = (array) $accountinfo->first_row(); |
|
| 753 | - /* * ****************************** */ |
|
| 754 | - if ($action == "add") { |
|
| 755 | - $charge_id = $this->input->post("applayable_charge", true); |
|
| 756 | - if ($charge_id != "") { |
|
| 757 | - $insert_arr = array("charge_id" => $charge_id, "accountid" => $accountid, "assign_date" => gmdate("Y-m-d H:i:s")); |
|
| 758 | - $this->db->insert("charge_to_account", $insert_arr); |
|
| 759 | - $this->session->set_flashdata('astpp_errormsg', 'Subscripton Added Sucessfully.'); |
|
| 760 | - $template_name = 'add_subscription'; |
|
| 761 | - } |
|
| 762 | - } |
|
| 763 | - if ($action == "delete") { |
|
| 764 | - $this->db_model->delete("charge_to_account", array("id" => $chargeid)); |
|
| 765 | - $this->session->set_flashdata('astpp_notification', 'Subscription Removed Sucessfully.'); |
|
| 766 | - $template_name = 'remove_subscription'; |
|
| 767 | - } |
|
| 768 | - /** |
|
| 750 | + * */ |
|
| 751 | + $accountinfo = $this->db_model->getSelect("*", "accounts", array("id" => $accountid)); |
|
| 752 | + $accountinfo = (array) $accountinfo->first_row(); |
|
| 753 | + /* * ****************************** */ |
|
| 754 | + if ($action == "add") { |
|
| 755 | + $charge_id = $this->input->post("applayable_charge", true); |
|
| 756 | + if ($charge_id != "") { |
|
| 757 | + $insert_arr = array("charge_id" => $charge_id, "accountid" => $accountid, "assign_date" => gmdate("Y-m-d H:i:s")); |
|
| 758 | + $this->db->insert("charge_to_account", $insert_arr); |
|
| 759 | + $this->session->set_flashdata('astpp_errormsg', 'Subscripton Added Sucessfully.'); |
|
| 760 | + $template_name = 'add_subscription'; |
|
| 761 | + } |
|
| 762 | + } |
|
| 763 | + if ($action == "delete") { |
|
| 764 | + $this->db_model->delete("charge_to_account", array("id" => $chargeid)); |
|
| 765 | + $this->session->set_flashdata('astpp_notification', 'Subscription Removed Sucessfully.'); |
|
| 766 | + $template_name = 'remove_subscription'; |
|
| 767 | + } |
|
| 768 | + /** |
|
| 769 | 769 | ASTPP 3.0 |
| 770 | 770 | For Email Broadcast when Subscription Delete |
| 771 | - * */ |
|
| 772 | - $this->common->mail_to_users($template_name, $accountinfo); |
|
| 773 | - /* * ********************************* */ |
|
| 774 | - redirect(base_url() . "accounts/" . $accounttype . "_subscription/$accountid/"); |
|
| 775 | - } |
|
| 776 | - |
|
| 777 | - function provider_dids($edit_id) { |
|
| 778 | - $this->customer_dids($edit_id); |
|
| 779 | - } |
|
| 780 | - |
|
| 781 | - function customer_dids($edit_id) { |
|
| 782 | - $data['page_title'] = "DID"; |
|
| 783 | - //Get Account information from session. |
|
| 784 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 785 | - //Get Parent informartion |
|
| 786 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 787 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 788 | - $account_res = $this->db_model->getSelect("type,country_id", "accounts", $where); |
|
| 789 | - if ($account_res->num_rows > 0) { |
|
| 790 | - $account_data = (array) $account_res->first_row(); |
|
| 791 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 792 | - $this->load->module('did/did'); |
|
| 793 | - $data['grid_fields'] = $this->did->did_form->build_did_list_for_customer($edit_id, $accounttype); |
|
| 794 | - $data['edit_id'] = $edit_id; |
|
| 795 | - $data['accounttype'] = $accounttype; |
|
| 796 | - $result_did_final = array(); |
|
| 797 | - $did_info = array("name" => "free_didlist", "id" => "free_didlist", "class" => "free_didlist"); |
|
| 798 | - $data['didlist'] = form_dropdown_all($did_info, $result_did_final, ''); |
|
| 799 | - $data['country_id'] = $account_data['country_id']; |
|
| 800 | - $this->load->view('view_customer_dids', $data); |
|
| 801 | - } else { |
|
| 802 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 803 | - exit; |
|
| 804 | - } |
|
| 805 | - } |
|
| 806 | - |
|
| 807 | - function provider_dids_action($action, $accountid, $accounttype, $did_id = "") { |
|
| 808 | - $this->customer_dids_action($action, $accountid, $accounttype, $did_id); |
|
| 809 | - } |
|
| 810 | - |
|
| 811 | - function reseller_dids_action($action, $accountid, $accounttype, $did_id = "") { |
|
| 812 | - $this->customer_dids_action($action, $accountid, $accounttype, $did_id); |
|
| 813 | - } |
|
| 814 | - |
|
| 815 | - function customer_dids_action($action, $accountid, $accounttype, $did_id = "") { |
|
| 816 | - //Get account information from session. |
|
| 817 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 818 | - //Get Parent informartion |
|
| 819 | - $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
|
| 820 | - $did_id = empty($did_id) ? $this->input->post("free_didlist", true) : $did_id; |
|
| 821 | - if ($did_id != "") { |
|
| 822 | - $account_arr = (array)$this->db->get_where("accounts", array("id" => $accountid))->first_row(); |
|
| 823 | - $did_arr = (array) $this->db->get_where("dids", array("id" => $did_id))->first_row(); |
|
| 824 | - $field_name = $account_arr['type'] ==1 ? "parent_id" : 'accountid'; |
|
| 825 | - if ($action == "add") { |
|
| 826 | - if ($did_arr['accountid'] == 0 && $did_arr['parent_id'] == $reseller_id) { |
|
| 827 | - if ($accountinfo['type'] == 1) { |
|
| 828 | - //for getting reseller setup price if reseller customer purchase |
|
| 829 | - $reseller_pricing_query = $this->db_model->getSelect("*", "reseller_pricing", array("note" => $did_arr['number'], 'reseller_id' => $reseller_id)); |
|
| 830 | - if ($reseller_pricing_query->num_rows() > 0) { |
|
| 831 | - $reseller_pricing = (array) $reseller_pricing_query->first_row(); |
|
| 832 | - $did_arr=array_merge($did_arr,$reseller_pricing); |
|
| 833 | - } |
|
| 834 | - } |
|
| 835 | - $available_bal = $this->db_model->get_available_bal($account_arr); |
|
| 836 | - if ($available_bal >= $did_arr['setup']) { |
|
| 837 | - $available_bal = $this->db_model->update_balance($did_arr['setup'], $accountid, "debit"); |
|
| 838 | - $this->db_model->update("dids", array($field_name => $accountid, "assign_date" => gmdate("Y-m-d H:i:s")), array("id" => $did_id)); |
|
| 839 | - if ($account_arr['type'] == 1) { |
|
| 840 | - $this->load->module('did/did'); |
|
| 841 | - $this->did->did_model->insert_reseller_pricing($account_arr, $did_arr); |
|
| 842 | - } |
|
| 843 | - $this->common->add_invoice_details($account_arr, "DIDCHRG", $did_arr['setup'], $did_arr['number']); |
|
| 844 | - $account_arr['did_number'] = $did_arr['number']; |
|
| 845 | - $account_arr['did_country_id'] = $this->common->get_field_name('country', 'countrycode', $did_arr['country_id']); |
|
| 771 | + * */ |
|
| 772 | + $this->common->mail_to_users($template_name, $accountinfo); |
|
| 773 | + /* * ********************************* */ |
|
| 774 | + redirect(base_url() . "accounts/" . $accounttype . "_subscription/$accountid/"); |
|
| 775 | + } |
|
| 776 | + |
|
| 777 | + function provider_dids($edit_id) { |
|
| 778 | + $this->customer_dids($edit_id); |
|
| 779 | + } |
|
| 780 | + |
|
| 781 | + function customer_dids($edit_id) { |
|
| 782 | + $data['page_title'] = "DID"; |
|
| 783 | + //Get Account information from session. |
|
| 784 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 785 | + //Get Parent informartion |
|
| 786 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 787 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 788 | + $account_res = $this->db_model->getSelect("type,country_id", "accounts", $where); |
|
| 789 | + if ($account_res->num_rows > 0) { |
|
| 790 | + $account_data = (array) $account_res->first_row(); |
|
| 791 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 792 | + $this->load->module('did/did'); |
|
| 793 | + $data['grid_fields'] = $this->did->did_form->build_did_list_for_customer($edit_id, $accounttype); |
|
| 794 | + $data['edit_id'] = $edit_id; |
|
| 795 | + $data['accounttype'] = $accounttype; |
|
| 796 | + $result_did_final = array(); |
|
| 797 | + $did_info = array("name" => "free_didlist", "id" => "free_didlist", "class" => "free_didlist"); |
|
| 798 | + $data['didlist'] = form_dropdown_all($did_info, $result_did_final, ''); |
|
| 799 | + $data['country_id'] = $account_data['country_id']; |
|
| 800 | + $this->load->view('view_customer_dids', $data); |
|
| 801 | + } else { |
|
| 802 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 803 | + exit; |
|
| 804 | + } |
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + function provider_dids_action($action, $accountid, $accounttype, $did_id = "") { |
|
| 808 | + $this->customer_dids_action($action, $accountid, $accounttype, $did_id); |
|
| 809 | + } |
|
| 810 | + |
|
| 811 | + function reseller_dids_action($action, $accountid, $accounttype, $did_id = "") { |
|
| 812 | + $this->customer_dids_action($action, $accountid, $accounttype, $did_id); |
|
| 813 | + } |
|
| 814 | + |
|
| 815 | + function customer_dids_action($action, $accountid, $accounttype, $did_id = "") { |
|
| 816 | + //Get account information from session. |
|
| 817 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 818 | + //Get Parent informartion |
|
| 819 | + $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
|
| 820 | + $did_id = empty($did_id) ? $this->input->post("free_didlist", true) : $did_id; |
|
| 821 | + if ($did_id != "") { |
|
| 822 | + $account_arr = (array)$this->db->get_where("accounts", array("id" => $accountid))->first_row(); |
|
| 823 | + $did_arr = (array) $this->db->get_where("dids", array("id" => $did_id))->first_row(); |
|
| 824 | + $field_name = $account_arr['type'] ==1 ? "parent_id" : 'accountid'; |
|
| 825 | + if ($action == "add") { |
|
| 826 | + if ($did_arr['accountid'] == 0 && $did_arr['parent_id'] == $reseller_id) { |
|
| 827 | + if ($accountinfo['type'] == 1) { |
|
| 828 | + //for getting reseller setup price if reseller customer purchase |
|
| 829 | + $reseller_pricing_query = $this->db_model->getSelect("*", "reseller_pricing", array("note" => $did_arr['number'], 'reseller_id' => $reseller_id)); |
|
| 830 | + if ($reseller_pricing_query->num_rows() > 0) { |
|
| 831 | + $reseller_pricing = (array) $reseller_pricing_query->first_row(); |
|
| 832 | + $did_arr=array_merge($did_arr,$reseller_pricing); |
|
| 833 | + } |
|
| 834 | + } |
|
| 835 | + $available_bal = $this->db_model->get_available_bal($account_arr); |
|
| 836 | + if ($available_bal >= $did_arr['setup']) { |
|
| 837 | + $available_bal = $this->db_model->update_balance($did_arr['setup'], $accountid, "debit"); |
|
| 838 | + $this->db_model->update("dids", array($field_name => $accountid, "assign_date" => gmdate("Y-m-d H:i:s")), array("id" => $did_id)); |
|
| 839 | + if ($account_arr['type'] == 1) { |
|
| 840 | + $this->load->module('did/did'); |
|
| 841 | + $this->did->did_model->insert_reseller_pricing($account_arr, $did_arr); |
|
| 842 | + } |
|
| 843 | + $this->common->add_invoice_details($account_arr, "DIDCHRG", $did_arr['setup'], $did_arr['number']); |
|
| 844 | + $account_arr['did_number'] = $did_arr['number']; |
|
| 845 | + $account_arr['did_country_id'] = $this->common->get_field_name('country', 'countrycode', $did_arr['country_id']); |
|
| 846 | 846 | $account_arr['did_setup'] = $this->common_model->to_calculate_currency($did_arr['setup'], "", '', true, true); |
| 847 | 847 | $account_arr['did_monthlycost'] = $this->common_model->to_calculate_currency($did_arr['monthlycost'], "", '', true,true); |
| 848 | 848 | $account_arr['did_maxchannels'] = $did_arr['maxchannels']; |
| 849 | 849 | |
| 850 | - $this->common->mail_to_users('email_add_did', $account_arr); |
|
| 851 | - $this->session->set_flashdata('astpp_errormsg', 'DID Purchased Successfully.'); |
|
| 852 | - } else { |
|
| 853 | - $this->session->set_flashdata('astpp_notification', 'Insuffiecient fund to purchase this DID'); |
|
| 854 | - } |
|
| 855 | - } else { |
|
| 856 | - $this->session->set_flashdata('astpp_notification', 'This DID already purchased by someone.'); |
|
| 857 | - } |
|
| 858 | - } |
|
| 859 | - if ($action == "delete") { |
|
| 860 | - $data = array("accountid" => "0", "assign_date" => "0000-00-00 00:00:00", "charge_upto" => "0000-00-00 00:00:00"); |
|
| 861 | - if ($accounttype == 'reseller') { |
|
| 862 | - $data = array("accountid" => "0", "parent_id" => $reseller_id, "assign_date" => "0000-00-00 00:00:00", "charge_upto" => "0000-00-00 00:00:00"); |
|
| 863 | - } |
|
| 864 | - $this->db_model->update("dids", $data, array("id" => $did_id)); |
|
| 865 | - if ($accounttype == 'reseller') { |
|
| 866 | - $this->db->where('reseller_id', $account_arr['id']); |
|
| 867 | - $this->db->where('note', $did_arr['number']); |
|
| 868 | - $this->db->delete('reseller_pricing'); |
|
| 869 | - } |
|
| 870 | - $account_arr['did_number']=$did_arr['number']; |
|
| 871 | - $this->common->mail_to_users('email_remove_did', $account_arr); |
|
| 872 | - $this->session->set_flashdata('astpp_notification', 'Did Removed Successfully.'); |
|
| 873 | - } |
|
| 874 | - } |
|
| 875 | - redirect(base_url() . "accounts/" . $accounttype . "_dids/$accountid/"); |
|
| 876 | - } |
|
| 877 | - |
|
| 878 | - function provider_invoices($edit_id) { |
|
| 879 | - $this->customer_invoices($edit_id); |
|
| 880 | - } |
|
| 881 | - |
|
| 882 | - function reseller_invoices($edit_id) { |
|
| 883 | - $this->customer_invoices($edit_id); |
|
| 884 | - } |
|
| 885 | - |
|
| 886 | - function customer_invoices($edit_id) { |
|
| 887 | - $data['page_title'] = "Invoice"; |
|
| 888 | - //Get Account information from session. |
|
| 889 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 890 | - //Get Parent informartion |
|
| 891 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 892 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 893 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 894 | - if ($account_res->num_rows > 0) { |
|
| 895 | - $account_data = (array) $account_res->first_row(); |
|
| 896 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 897 | - $this->load->module('invoices/invoices'); |
|
| 898 | - $data['grid_fields'] = $this->invoices->invoices_form->build_invoices_list_for_customer_admin(false); |
|
| 899 | - $data['edit_id'] = $edit_id; |
|
| 900 | - $data['accounttype'] = $accounttype; |
|
| 901 | - $this->load->view('view_customer_invoices', $data); |
|
| 902 | - } else { |
|
| 903 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 904 | - exit; |
|
| 905 | - } |
|
| 906 | - } |
|
| 907 | - |
|
| 908 | - function provider_blocked_prefixes($edit_id) { |
|
| 909 | - $this->customer_blocked_prefixes($edit_id); |
|
| 910 | - } |
|
| 911 | - |
|
| 912 | - function customer_blocked_prefixes($edit_id) { |
|
| 913 | - $data['page_title'] = "Blocked Codes"; |
|
| 914 | - //Get Account information from session. |
|
| 915 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 916 | - //Get Parent informartion |
|
| 917 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 918 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 919 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 920 | - if ($account_res->num_rows > 0) { |
|
| 921 | - $account_data = (array) $account_res->first_row(); |
|
| 922 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 923 | - $this->load->module('rates/rates'); |
|
| 924 | - $data['grid_fields'] = $this->rates->rates_form->build_pattern_list_for_customer($edit_id, $accounttype); |
|
| 925 | - $data['grid_buttons'] = $this->rates->rates_form->set_pattern_grid_buttons($edit_id); |
|
| 926 | - $data['edit_id'] = $edit_id; |
|
| 927 | - $data['accounttype'] = $accounttype; |
|
| 928 | - $this->load->view('view_customer_blocked_prefixes', $data); |
|
| 929 | - } else { |
|
| 930 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 931 | - exit; |
|
| 932 | - } |
|
| 933 | - } |
|
| 934 | - |
|
| 935 | - function customer_add_blockpatterns($accountid) { |
|
| 936 | - $data['username'] = $this->session->userdata('user_name'); |
|
| 937 | - $data['page_title'] = 'Unblocked Codes'; |
|
| 938 | - $this->session->set_userdata('advance_search', 0); |
|
| 939 | - $this->load->module('rates/rates'); |
|
| 940 | - $data['patters_grid_fields'] = $this->rates->rates_form->build_block_pattern_list_for_customer(); |
|
| 941 | - $data["accountid"] = $accountid; |
|
| 942 | - $this->load->view('view_block_prefix_list', $data); |
|
| 943 | - } |
|
| 944 | - |
|
| 945 | - function customer_add_blockpatterns_json($accountid) { |
|
| 946 | - $this->load->module('rates/rates'); |
|
| 947 | - $json_data = array(); |
|
| 948 | - $count_all = $this->rates_model->getunblocked_pattern_list($accountid, false); |
|
| 949 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 950 | - $json_data = $paging_data["json_paging"]; |
|
| 951 | - |
|
| 952 | - $query = $this->rates->rates_model->getunblocked_pattern_list($accountid, true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
| 953 | - $grid_fields = json_decode($this->rates->rates_form->build_block_pattern_list_for_customer()); |
|
| 954 | - $json_data['rows'] = $this->rates->form->build_grid($query, $grid_fields); |
|
| 955 | - echo json_encode($json_data); |
|
| 956 | - } |
|
| 957 | - |
|
| 958 | - function customer_block_prefix($accountid) { |
|
| 959 | - $result = $this->accounts_model->insert_block($this->input->post('prefixies', true), $accountid); |
|
| 960 | - echo $result; |
|
| 961 | - exit; |
|
| 962 | - } |
|
| 963 | - |
|
| 964 | - function provider_delete_block_pattern($accountid, $patternid) { |
|
| 965 | - $this->customer_delete_block_pattern($accountid, $patternid); |
|
| 966 | - } |
|
| 967 | - |
|
| 968 | - function customer_delete_block_pattern($accountid, $patternid) { |
|
| 969 | - $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
|
| 970 | - $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
|
| 971 | - $url = "accounts/" . $entity_type . "_blocked_prefixes/$accountid"; |
|
| 972 | - $this->db_model->delete("block_patterns", array("id" => $patternid)); |
|
| 973 | - $this->session->set_flashdata('astpp_notification', 'Block Code Removed Sucessfully!'); |
|
| 850 | + $this->common->mail_to_users('email_add_did', $account_arr); |
|
| 851 | + $this->session->set_flashdata('astpp_errormsg', 'DID Purchased Successfully.'); |
|
| 852 | + } else { |
|
| 853 | + $this->session->set_flashdata('astpp_notification', 'Insuffiecient fund to purchase this DID'); |
|
| 854 | + } |
|
| 855 | + } else { |
|
| 856 | + $this->session->set_flashdata('astpp_notification', 'This DID already purchased by someone.'); |
|
| 857 | + } |
|
| 858 | + } |
|
| 859 | + if ($action == "delete") { |
|
| 860 | + $data = array("accountid" => "0", "assign_date" => "0000-00-00 00:00:00", "charge_upto" => "0000-00-00 00:00:00"); |
|
| 861 | + if ($accounttype == 'reseller') { |
|
| 862 | + $data = array("accountid" => "0", "parent_id" => $reseller_id, "assign_date" => "0000-00-00 00:00:00", "charge_upto" => "0000-00-00 00:00:00"); |
|
| 863 | + } |
|
| 864 | + $this->db_model->update("dids", $data, array("id" => $did_id)); |
|
| 865 | + if ($accounttype == 'reseller') { |
|
| 866 | + $this->db->where('reseller_id', $account_arr['id']); |
|
| 867 | + $this->db->where('note', $did_arr['number']); |
|
| 868 | + $this->db->delete('reseller_pricing'); |
|
| 869 | + } |
|
| 870 | + $account_arr['did_number']=$did_arr['number']; |
|
| 871 | + $this->common->mail_to_users('email_remove_did', $account_arr); |
|
| 872 | + $this->session->set_flashdata('astpp_notification', 'Did Removed Successfully.'); |
|
| 873 | + } |
|
| 874 | + } |
|
| 875 | + redirect(base_url() . "accounts/" . $accounttype . "_dids/$accountid/"); |
|
| 876 | + } |
|
| 877 | + |
|
| 878 | + function provider_invoices($edit_id) { |
|
| 879 | + $this->customer_invoices($edit_id); |
|
| 880 | + } |
|
| 881 | + |
|
| 882 | + function reseller_invoices($edit_id) { |
|
| 883 | + $this->customer_invoices($edit_id); |
|
| 884 | + } |
|
| 885 | + |
|
| 886 | + function customer_invoices($edit_id) { |
|
| 887 | + $data['page_title'] = "Invoice"; |
|
| 888 | + //Get Account information from session. |
|
| 889 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 890 | + //Get Parent informartion |
|
| 891 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 892 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 893 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 894 | + if ($account_res->num_rows > 0) { |
|
| 895 | + $account_data = (array) $account_res->first_row(); |
|
| 896 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 897 | + $this->load->module('invoices/invoices'); |
|
| 898 | + $data['grid_fields'] = $this->invoices->invoices_form->build_invoices_list_for_customer_admin(false); |
|
| 899 | + $data['edit_id'] = $edit_id; |
|
| 900 | + $data['accounttype'] = $accounttype; |
|
| 901 | + $this->load->view('view_customer_invoices', $data); |
|
| 902 | + } else { |
|
| 903 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 904 | + exit; |
|
| 905 | + } |
|
| 906 | + } |
|
| 907 | + |
|
| 908 | + function provider_blocked_prefixes($edit_id) { |
|
| 909 | + $this->customer_blocked_prefixes($edit_id); |
|
| 910 | + } |
|
| 911 | + |
|
| 912 | + function customer_blocked_prefixes($edit_id) { |
|
| 913 | + $data['page_title'] = "Blocked Codes"; |
|
| 914 | + //Get Account information from session. |
|
| 915 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 916 | + //Get Parent informartion |
|
| 917 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 918 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 919 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 920 | + if ($account_res->num_rows > 0) { |
|
| 921 | + $account_data = (array) $account_res->first_row(); |
|
| 922 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 923 | + $this->load->module('rates/rates'); |
|
| 924 | + $data['grid_fields'] = $this->rates->rates_form->build_pattern_list_for_customer($edit_id, $accounttype); |
|
| 925 | + $data['grid_buttons'] = $this->rates->rates_form->set_pattern_grid_buttons($edit_id); |
|
| 926 | + $data['edit_id'] = $edit_id; |
|
| 927 | + $data['accounttype'] = $accounttype; |
|
| 928 | + $this->load->view('view_customer_blocked_prefixes', $data); |
|
| 929 | + } else { |
|
| 930 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 931 | + exit; |
|
| 932 | + } |
|
| 933 | + } |
|
| 934 | + |
|
| 935 | + function customer_add_blockpatterns($accountid) { |
|
| 936 | + $data['username'] = $this->session->userdata('user_name'); |
|
| 937 | + $data['page_title'] = 'Unblocked Codes'; |
|
| 938 | + $this->session->set_userdata('advance_search', 0); |
|
| 939 | + $this->load->module('rates/rates'); |
|
| 940 | + $data['patters_grid_fields'] = $this->rates->rates_form->build_block_pattern_list_for_customer(); |
|
| 941 | + $data["accountid"] = $accountid; |
|
| 942 | + $this->load->view('view_block_prefix_list', $data); |
|
| 943 | + } |
|
| 944 | + |
|
| 945 | + function customer_add_blockpatterns_json($accountid) { |
|
| 946 | + $this->load->module('rates/rates'); |
|
| 947 | + $json_data = array(); |
|
| 948 | + $count_all = $this->rates_model->getunblocked_pattern_list($accountid, false); |
|
| 949 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 950 | + $json_data = $paging_data["json_paging"]; |
|
| 951 | + |
|
| 952 | + $query = $this->rates->rates_model->getunblocked_pattern_list($accountid, true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
| 953 | + $grid_fields = json_decode($this->rates->rates_form->build_block_pattern_list_for_customer()); |
|
| 954 | + $json_data['rows'] = $this->rates->form->build_grid($query, $grid_fields); |
|
| 955 | + echo json_encode($json_data); |
|
| 956 | + } |
|
| 957 | + |
|
| 958 | + function customer_block_prefix($accountid) { |
|
| 959 | + $result = $this->accounts_model->insert_block($this->input->post('prefixies', true), $accountid); |
|
| 960 | + echo $result; |
|
| 961 | + exit; |
|
| 962 | + } |
|
| 963 | + |
|
| 964 | + function provider_delete_block_pattern($accountid, $patternid) { |
|
| 965 | + $this->customer_delete_block_pattern($accountid, $patternid); |
|
| 966 | + } |
|
| 967 | + |
|
| 968 | + function customer_delete_block_pattern($accountid, $patternid) { |
|
| 969 | + $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
|
| 970 | + $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
|
| 971 | + $url = "accounts/" . $entity_type . "_blocked_prefixes/$accountid"; |
|
| 972 | + $this->db_model->delete("block_patterns", array("id" => $patternid)); |
|
| 973 | + $this->session->set_flashdata('astpp_notification', 'Block Code Removed Sucessfully!'); |
|
| 974 | 974 | |
| 975 | - redirect(base_url() . $url); |
|
| 976 | - } |
|
| 977 | - function customer_blockedprefixes_delete_multiple(){ |
|
| 978 | - $ids = $this->input->post("selected_ids", true); |
|
| 979 | - $where = "id IN ($ids)"; |
|
| 980 | - $this->db->delete("block_patterns",$where); |
|
| 981 | - echo TRUE; |
|
| 982 | - } |
|
| 983 | - |
|
| 984 | - /* ASTPP 3.0 |
|
| 975 | + redirect(base_url() . $url); |
|
| 976 | + } |
|
| 977 | + function customer_blockedprefixes_delete_multiple(){ |
|
| 978 | + $ids = $this->input->post("selected_ids", true); |
|
| 979 | + $where = "id IN ($ids)"; |
|
| 980 | + $this->db->delete("block_patterns",$where); |
|
| 981 | + echo TRUE; |
|
| 982 | + } |
|
| 983 | + |
|
| 984 | + /* ASTPP 3.0 |
|
| 985 | 985 | * Using function using for provider cdrs tab |
| 986 | 986 | */ |
| 987 | 987 | |
| 988 | - function provider_cdrs($edit_id) { |
|
| 989 | - $this->customer_cdrs($edit_id); |
|
| 990 | - } |
|
| 988 | + function provider_cdrs($edit_id) { |
|
| 989 | + $this->customer_cdrs($edit_id); |
|
| 990 | + } |
|
| 991 | 991 | |
| 992 | - /* * ************************************************ */ |
|
| 993 | - /* ASTPP 3.0 |
|
| 992 | + /* * ************************************************ */ |
|
| 993 | + /* ASTPP 3.0 |
|
| 994 | 994 | * Using function using for reseller cdrs tab |
| 995 | 995 | */ |
| 996 | 996 | |
| 997 | - function reseller_cdrs($edit_id) { |
|
| 998 | - $this->customer_cdrs($edit_id); |
|
| 999 | - } |
|
| 997 | + function reseller_cdrs($edit_id) { |
|
| 998 | + $this->customer_cdrs($edit_id); |
|
| 999 | + } |
|
| 1000 | 1000 | |
| 1001 | - /* * ************************************************ */ |
|
| 1002 | - /* ASTPP 3.0 |
|
| 1001 | + /* * ************************************************ */ |
|
| 1002 | + /* ASTPP 3.0 |
|
| 1003 | 1003 | * Using function using for customer cdrs tab |
| 1004 | 1004 | */ |
| 1005 | 1005 | |
| 1006 | - function customer_cdrs($edit_id) { |
|
| 1007 | - $data['page_title'] = "CDRs"; |
|
| 1008 | - //Get Account information from session. |
|
| 1009 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1010 | - //Get Parent informartion |
|
| 1011 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 1012 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 1013 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 1014 | - if ($account_res->num_rows > 0) { |
|
| 1015 | - $account_data = (array) $account_res->first_row(); |
|
| 1016 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 1017 | - $this->load->module('reports/reports'); |
|
| 1018 | - $data['grid_fields'] = $this->reports->reports_form->build_report_list_for_user($accounttype); |
|
| 1019 | - $data['edit_id'] = $edit_id; |
|
| 1020 | - $data['accounttype'] = $accounttype; |
|
| 1021 | - $this->load->view('view_customer_cdrs_list', $data); |
|
| 1022 | - } else { |
|
| 1023 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1024 | - exit; |
|
| 1025 | - } |
|
| 1026 | - } |
|
| 1027 | - |
|
| 1028 | - /* * ***************************************** */ |
|
| 1029 | - /* ASTPP 3.0 |
|
| 1006 | + function customer_cdrs($edit_id) { |
|
| 1007 | + $data['page_title'] = "CDRs"; |
|
| 1008 | + //Get Account information from session. |
|
| 1009 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1010 | + //Get Parent informartion |
|
| 1011 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 1012 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 1013 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 1014 | + if ($account_res->num_rows > 0) { |
|
| 1015 | + $account_data = (array) $account_res->first_row(); |
|
| 1016 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 1017 | + $this->load->module('reports/reports'); |
|
| 1018 | + $data['grid_fields'] = $this->reports->reports_form->build_report_list_for_user($accounttype); |
|
| 1019 | + $data['edit_id'] = $edit_id; |
|
| 1020 | + $data['accounttype'] = $accounttype; |
|
| 1021 | + $this->load->view('view_customer_cdrs_list', $data); |
|
| 1022 | + } else { |
|
| 1023 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 1024 | + exit; |
|
| 1025 | + } |
|
| 1026 | + } |
|
| 1027 | + |
|
| 1028 | + /* * ***************************************** */ |
|
| 1029 | + /* ASTPP 3.0 |
|
| 1030 | 1030 | * Using for provider refillreporttab. |
| 1031 | 1031 | */ |
| 1032 | - function reseller_packages($edit_id){ |
|
| 1033 | - $data['page_title'] = "Packages"; |
|
| 1034 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1035 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 1036 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 1037 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 1038 | - if ($account_res->num_rows > 0) { |
|
| 1039 | - $account_data = (array) $account_res->first_row(); |
|
| 1040 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 1041 | - $this->load->module('package/package'); |
|
| 1042 | - $data['grid_fields'] = $this->package->package_form->build_package_list_for_reseller(); |
|
| 1043 | - $data['edit_id'] = $edit_id; |
|
| 1044 | - $data['accounttype'] = $accounttype; |
|
| 1045 | - $this->load->view('view_reseller_package_list', $data); |
|
| 1046 | - }else { |
|
| 1047 | - redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1048 | - exit; |
|
| 1049 | - } |
|
| 1050 | - } |
|
| 1032 | + function reseller_packages($edit_id){ |
|
| 1033 | + $data['page_title'] = "Packages"; |
|
| 1034 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1035 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 1036 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 1037 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 1038 | + if ($account_res->num_rows > 0) { |
|
| 1039 | + $account_data = (array) $account_res->first_row(); |
|
| 1040 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 1041 | + $this->load->module('package/package'); |
|
| 1042 | + $data['grid_fields'] = $this->package->package_form->build_package_list_for_reseller(); |
|
| 1043 | + $data['edit_id'] = $edit_id; |
|
| 1044 | + $data['accounttype'] = $accounttype; |
|
| 1045 | + $this->load->view('view_reseller_package_list', $data); |
|
| 1046 | + }else { |
|
| 1047 | + redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1048 | + exit; |
|
| 1049 | + } |
|
| 1050 | + } |
|
| 1051 | 1051 | |
| 1052 | - function reseller_refillreport($edit_id){ |
|
| 1053 | - $this->customer_refillreport($edit_id); |
|
| 1054 | - } |
|
| 1055 | - function provider_refillreport($edit_id) { |
|
| 1056 | - $this->customer_refillreport($edit_id); |
|
| 1057 | - } |
|
| 1058 | - |
|
| 1059 | - /* * ***************************************** */ |
|
| 1060 | - /* ASTPP 3.0 |
|
| 1052 | + function reseller_refillreport($edit_id){ |
|
| 1053 | + $this->customer_refillreport($edit_id); |
|
| 1054 | + } |
|
| 1055 | + function provider_refillreport($edit_id) { |
|
| 1056 | + $this->customer_refillreport($edit_id); |
|
| 1057 | + } |
|
| 1058 | + |
|
| 1059 | + /* * ***************************************** */ |
|
| 1060 | + /* ASTPP 3.0 |
|
| 1061 | 1061 | * Using for customer refill report tab. |
| 1062 | 1062 | */ |
| 1063 | 1063 | |
| 1064 | - function customer_refillreport($edit_id) { |
|
| 1065 | - $data['page_title'] = "Refill Report"; |
|
| 1066 | - //Get Account information from session. |
|
| 1067 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1068 | - //Get Parent informartion |
|
| 1069 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 1070 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 1071 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 1072 | - if ($account_res->num_rows > 0) { |
|
| 1073 | - $account_data = (array) $account_res->first_row(); |
|
| 1074 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 1075 | - $this->load->module('reports/reports'); |
|
| 1076 | - $data['grid_fields'] = $this->reports->reports_form->build_refillreport_for_customer(); |
|
| 1077 | - $data['edit_id'] = $edit_id; |
|
| 1078 | - $data['accounttype'] = $accounttype; |
|
| 1079 | - $this->load->view('view_customer_refill_report', $data); |
|
| 1080 | - } else { |
|
| 1081 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1082 | - exit; |
|
| 1083 | - } |
|
| 1084 | - } |
|
| 1085 | - |
|
| 1086 | - /* * ***************************************** */ |
|
| 1087 | - /* ASTPP 3.0 |
|
| 1064 | + function customer_refillreport($edit_id) { |
|
| 1065 | + $data['page_title'] = "Refill Report"; |
|
| 1066 | + //Get Account information from session. |
|
| 1067 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1068 | + //Get Parent informartion |
|
| 1069 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 1070 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 1071 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 1072 | + if ($account_res->num_rows > 0) { |
|
| 1073 | + $account_data = (array) $account_res->first_row(); |
|
| 1074 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 1075 | + $this->load->module('reports/reports'); |
|
| 1076 | + $data['grid_fields'] = $this->reports->reports_form->build_refillreport_for_customer(); |
|
| 1077 | + $data['edit_id'] = $edit_id; |
|
| 1078 | + $data['accounttype'] = $accounttype; |
|
| 1079 | + $this->load->view('view_customer_refill_report', $data); |
|
| 1080 | + } else { |
|
| 1081 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 1082 | + exit; |
|
| 1083 | + } |
|
| 1084 | + } |
|
| 1085 | + |
|
| 1086 | + /* * ***************************************** */ |
|
| 1087 | + /* ASTPP 3.0 |
|
| 1088 | 1088 | * Using for provider email history tab. |
| 1089 | 1089 | */ |
| 1090 | - function reseller_emailhistory($edit_id) { |
|
| 1091 | - $this->customer_emailhistory($edit_id); |
|
| 1092 | - } |
|
| 1093 | - function provider_emailhistory($edit_id) { |
|
| 1094 | - $this->customer_emailhistory($edit_id); |
|
| 1095 | - } |
|
| 1096 | - |
|
| 1097 | - /* * ***************************************** */ |
|
| 1098 | - /* ASTPP 3.0 |
|
| 1090 | + function reseller_emailhistory($edit_id) { |
|
| 1091 | + $this->customer_emailhistory($edit_id); |
|
| 1092 | + } |
|
| 1093 | + function provider_emailhistory($edit_id) { |
|
| 1094 | + $this->customer_emailhistory($edit_id); |
|
| 1095 | + } |
|
| 1096 | + |
|
| 1097 | + /* * ***************************************** */ |
|
| 1098 | + /* ASTPP 3.0 |
|
| 1099 | 1099 | * Using for customer email history tab. |
| 1100 | 1100 | */ |
| 1101 | 1101 | |
| 1102 | - function customer_emailhistory($edit_id) { |
|
| 1103 | - $data['page_title'] = "Emails"; |
|
| 1104 | - //Get Account information from session. |
|
| 1105 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1106 | - //Get Parent informartion |
|
| 1107 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 1108 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 1109 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 1110 | - if ($account_res->num_rows > 0) { |
|
| 1111 | - $account_data = (array) $account_res->first_row(); |
|
| 1112 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 1113 | - $this->load->module('email/email'); |
|
| 1114 | - $data['grid_fields'] = $this->email->email_form->build_list_for_email_customer($edit_id, $accounttype); |
|
| 1115 | - $data['edit_id'] = $edit_id; |
|
| 1116 | - $data['accounttype'] = $accounttype; |
|
| 1117 | - $this->load->view('view_customer_email_history', $data); |
|
| 1118 | - } else { |
|
| 1119 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1120 | - exit; |
|
| 1121 | - } |
|
| 1122 | - } |
|
| 1123 | - |
|
| 1124 | - /* * *********************************************** */ |
|
| 1125 | - /* ASTPP 3.0 |
|
| 1102 | + function customer_emailhistory($edit_id) { |
|
| 1103 | + $data['page_title'] = "Emails"; |
|
| 1104 | + //Get Account information from session. |
|
| 1105 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1106 | + //Get Parent informartion |
|
| 1107 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 1108 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 1109 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 1110 | + if ($account_res->num_rows > 0) { |
|
| 1111 | + $account_data = (array) $account_res->first_row(); |
|
| 1112 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 1113 | + $this->load->module('email/email'); |
|
| 1114 | + $data['grid_fields'] = $this->email->email_form->build_list_for_email_customer($edit_id, $accounttype); |
|
| 1115 | + $data['edit_id'] = $edit_id; |
|
| 1116 | + $data['accounttype'] = $accounttype; |
|
| 1117 | + $this->load->view('view_customer_email_history', $data); |
|
| 1118 | + } else { |
|
| 1119 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 1120 | + exit; |
|
| 1121 | + } |
|
| 1122 | + } |
|
| 1123 | + |
|
| 1124 | + /* * *********************************************** */ |
|
| 1125 | + /* ASTPP 3.0 |
|
| 1126 | 1126 | * Using for provider Alert threshold history tab. |
| 1127 | 1127 | */ |
| 1128 | 1128 | |
| 1129 | - function reseller_alert_threshold($edit_id) { |
|
| 1130 | - $this->customer_alert_threshold($edit_id); |
|
| 1131 | - } |
|
| 1132 | - function provider_alert_threshold($edit_id) { |
|
| 1133 | - $this->customer_alert_threshold($edit_id); |
|
| 1134 | - } |
|
| 1129 | + function reseller_alert_threshold($edit_id) { |
|
| 1130 | + $this->customer_alert_threshold($edit_id); |
|
| 1131 | + } |
|
| 1132 | + function provider_alert_threshold($edit_id) { |
|
| 1133 | + $this->customer_alert_threshold($edit_id); |
|
| 1134 | + } |
|
| 1135 | 1135 | |
| 1136 | - /* * *********************************************** */ |
|
| 1137 | - /* ASTPP 3.0 |
|
| 1136 | + /* * *********************************************** */ |
|
| 1137 | + /* ASTPP 3.0 |
|
| 1138 | 1138 | * Using for customer Alert threshold history tab. |
| 1139 | 1139 | */ |
| 1140 | 1140 | |
| 1141 | - function customer_alert_threshold($edit_id) { |
|
| 1142 | - $data['page_title'] = "Alert Threshold"; |
|
| 1143 | - //Get Account information from session. |
|
| 1144 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1145 | - //Get Parent informartion |
|
| 1146 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 1147 | - $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 1148 | - $account_res = $this->db_model->getSelect("notify_credit_limit,notify_flag,notify_email,type,id", "accounts", $where); |
|
| 1149 | - if ($account_res->num_rows > 0) { |
|
| 1150 | - $account_data = (array) $account_res->first_row(); |
|
| 1151 | - $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 1152 | - unset($account_data['type']); |
|
| 1153 | - $data['form'] = $this->form->build_form($this->accounts_form->customer_alert_threshold($accounttype), $account_data); |
|
| 1154 | - $data['edit_id'] = $edit_id; |
|
| 1155 | - $data['accounttype'] = $accounttype; |
|
| 1156 | - $this->load->view('view_customer_alert_threshold', $data); |
|
| 1157 | - } else { |
|
| 1158 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1159 | - exit; |
|
| 1160 | - } |
|
| 1161 | - } |
|
| 1162 | - function reseller_alert_threshold_save($entity_type) { |
|
| 1163 | - $this->customer_alert_threshold_save($entity_type); |
|
| 1164 | - } |
|
| 1165 | - function provider_alert_threshold_save($entity_type) { |
|
| 1166 | - $this->customer_alert_threshold_save($entity_type); |
|
| 1167 | - } |
|
| 1168 | - |
|
| 1169 | - function customer_alert_threshold_save($entity_type) { |
|
| 1170 | - $add_array = $this->input->post(); |
|
| 1171 | - if (isset($add_array['id']) && !empty($add_array['id'])) { |
|
| 1172 | - $data['page_title'] = "Alert Threshold"; |
|
| 1173 | - $data['form'] = $this->form->build_form($this->accounts_form->customer_alert_threshold($entity_type), $add_array); |
|
| 1174 | - $data['edit_id'] = $add_array['id']; |
|
| 1175 | - $data['accounttype'] = $entity_type; |
|
| 1176 | - //Get Account information from session. |
|
| 1177 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1178 | - //Get Parent informartion |
|
| 1179 | - $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 1180 | - $where = array('id' => $add_array['id'], "reseller_id" => $reseller_id); |
|
| 1181 | - $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 1182 | - if ($account_res->num_rows > 0) { |
|
| 1183 | - if ($this->form_validation->run() == FALSE) { |
|
| 1184 | - $data['validation_errors'] = validation_errors(); |
|
| 1185 | - } else { |
|
| 1186 | - $this->db->where('id', $add_array['id']); |
|
| 1187 | - $id=$add_array['id']; |
|
| 1188 | - unset($add_array['id'], $add_array['action']); |
|
| 1189 | - $this->db->update('accounts', $add_array); |
|
| 1190 | - $this->session->set_flashdata('astpp_errormsg','Alert threshold updated successfully!'); |
|
| 1191 | - redirect(base_url() . 'accounts/'.$entity_type.'_alert_threshold/'.$id."/"); |
|
| 1192 | - exit; |
|
| 1193 | - } |
|
| 1194 | - } else { |
|
| 1195 | - redirect(base_url() . 'accounts/'.$entity_type.'_list/'); |
|
| 1196 | - exit; |
|
| 1197 | - } |
|
| 1198 | - $this->load->view('view_customer_alert_threshold', $data); |
|
| 1199 | - } else { |
|
| 1200 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1201 | - exit; |
|
| 1202 | - } |
|
| 1203 | - } |
|
| 1204 | - |
|
| 1205 | - function customer_bulk_creation() { |
|
| 1206 | - $type=0; |
|
| 1207 | - $data['entity_name'] = strtolower($this->common->get_entity_type('', '', $type)); |
|
| 1208 | - $data['page_title'] = 'Mass Customer'; |
|
| 1209 | - $data['country_id'] = Common_model::$global_config['system_config']['country']; |
|
| 1210 | - $data['currency_id'] = $this->common->get_field_name('id', 'currency', array('currency' => Common_model::$global_config['system_config']['base_currency'])); |
|
| 1211 | - $data['timezone_id'] = Common_model::$global_config['system_config']['default_timezone']; |
|
| 1212 | - if (!$data['timezone_id']) { |
|
| 1213 | - $data['timezone_id'] = 1; |
|
| 1214 | - } |
|
| 1215 | - if (!$data['currency_id']) { |
|
| 1216 | - $data['currency_id'] = 1; |
|
| 1217 | - } |
|
| 1218 | - if (!$data['country_id']) { |
|
| 1219 | - $data['country_id'] = 1; |
|
| 1220 | - } |
|
| 1221 | - $data['form'] = $this->form->build_form($this->accounts_form->customer_bulk_generate_form(), ''); |
|
| 1222 | - $this->load->view('view_bulk_account_creation', $data); |
|
| 1223 | - } |
|
| 1224 | - |
|
| 1225 | - function customer_bulk_save() { |
|
| 1226 | - $data['page_title'] = 'Create Bulk Customer'; |
|
| 1227 | - $add_array = $this->input->post(); |
|
| 1228 | - if (!empty($add_array) && isset($add_array)) { |
|
| 1229 | - $currentlength = $this->accounts_model->get_max_limit($add_array); |
|
| 1230 | - $account_data = $this->session->userdata("accountinfo"); |
|
| 1231 | - $add_array['reseller_id'] = $account_data['type']==1 ? $account_data['id']:0; |
|
| 1232 | - $data['form'] = $this->form->build_form($this->accounts_form->customer_bulk_generate_form(), $add_array); |
|
| 1233 | - if ($this->form_validation->run() == FALSE) { |
|
| 1234 | - $data['validation_errors'] = validation_errors(); |
|
| 1235 | - echo $data['validation_errors']; |
|
| 1236 | - exit; |
|
| 1237 | - } |
|
| 1238 | - if($currentlength <= 0){ |
|
| 1141 | + function customer_alert_threshold($edit_id) { |
|
| 1142 | + $data['page_title'] = "Alert Threshold"; |
|
| 1143 | + //Get Account information from session. |
|
| 1144 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1145 | + //Get Parent informartion |
|
| 1146 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 1147 | + $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
|
| 1148 | + $account_res = $this->db_model->getSelect("notify_credit_limit,notify_flag,notify_email,type,id", "accounts", $where); |
|
| 1149 | + if ($account_res->num_rows > 0) { |
|
| 1150 | + $account_data = (array) $account_res->first_row(); |
|
| 1151 | + $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
|
| 1152 | + unset($account_data['type']); |
|
| 1153 | + $data['form'] = $this->form->build_form($this->accounts_form->customer_alert_threshold($accounttype), $account_data); |
|
| 1154 | + $data['edit_id'] = $edit_id; |
|
| 1155 | + $data['accounttype'] = $accounttype; |
|
| 1156 | + $this->load->view('view_customer_alert_threshold', $data); |
|
| 1157 | + } else { |
|
| 1158 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 1159 | + exit; |
|
| 1160 | + } |
|
| 1161 | + } |
|
| 1162 | + function reseller_alert_threshold_save($entity_type) { |
|
| 1163 | + $this->customer_alert_threshold_save($entity_type); |
|
| 1164 | + } |
|
| 1165 | + function provider_alert_threshold_save($entity_type) { |
|
| 1166 | + $this->customer_alert_threshold_save($entity_type); |
|
| 1167 | + } |
|
| 1168 | + |
|
| 1169 | + function customer_alert_threshold_save($entity_type) { |
|
| 1170 | + $add_array = $this->input->post(); |
|
| 1171 | + if (isset($add_array['id']) && !empty($add_array['id'])) { |
|
| 1172 | + $data['page_title'] = "Alert Threshold"; |
|
| 1173 | + $data['form'] = $this->form->build_form($this->accounts_form->customer_alert_threshold($entity_type), $add_array); |
|
| 1174 | + $data['edit_id'] = $add_array['id']; |
|
| 1175 | + $data['accounttype'] = $entity_type; |
|
| 1176 | + //Get Account information from session. |
|
| 1177 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1178 | + //Get Parent informartion |
|
| 1179 | + $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
|
| 1180 | + $where = array('id' => $add_array['id'], "reseller_id" => $reseller_id); |
|
| 1181 | + $account_res = $this->db_model->getSelect("type", "accounts", $where); |
|
| 1182 | + if ($account_res->num_rows > 0) { |
|
| 1183 | + if ($this->form_validation->run() == FALSE) { |
|
| 1184 | + $data['validation_errors'] = validation_errors(); |
|
| 1185 | + } else { |
|
| 1186 | + $this->db->where('id', $add_array['id']); |
|
| 1187 | + $id=$add_array['id']; |
|
| 1188 | + unset($add_array['id'], $add_array['action']); |
|
| 1189 | + $this->db->update('accounts', $add_array); |
|
| 1190 | + $this->session->set_flashdata('astpp_errormsg','Alert threshold updated successfully!'); |
|
| 1191 | + redirect(base_url() . 'accounts/'.$entity_type.'_alert_threshold/'.$id."/"); |
|
| 1192 | + exit; |
|
| 1193 | + } |
|
| 1194 | + } else { |
|
| 1195 | + redirect(base_url() . 'accounts/'.$entity_type.'_list/'); |
|
| 1196 | + exit; |
|
| 1197 | + } |
|
| 1198 | + $this->load->view('view_customer_alert_threshold', $data); |
|
| 1199 | + } else { |
|
| 1200 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 1201 | + exit; |
|
| 1202 | + } |
|
| 1203 | + } |
|
| 1204 | + |
|
| 1205 | + function customer_bulk_creation() { |
|
| 1206 | + $type=0; |
|
| 1207 | + $data['entity_name'] = strtolower($this->common->get_entity_type('', '', $type)); |
|
| 1208 | + $data['page_title'] = 'Mass Customer'; |
|
| 1209 | + $data['country_id'] = Common_model::$global_config['system_config']['country']; |
|
| 1210 | + $data['currency_id'] = $this->common->get_field_name('id', 'currency', array('currency' => Common_model::$global_config['system_config']['base_currency'])); |
|
| 1211 | + $data['timezone_id'] = Common_model::$global_config['system_config']['default_timezone']; |
|
| 1212 | + if (!$data['timezone_id']) { |
|
| 1213 | + $data['timezone_id'] = 1; |
|
| 1214 | + } |
|
| 1215 | + if (!$data['currency_id']) { |
|
| 1216 | + $data['currency_id'] = 1; |
|
| 1217 | + } |
|
| 1218 | + if (!$data['country_id']) { |
|
| 1219 | + $data['country_id'] = 1; |
|
| 1220 | + } |
|
| 1221 | + $data['form'] = $this->form->build_form($this->accounts_form->customer_bulk_generate_form(), ''); |
|
| 1222 | + $this->load->view('view_bulk_account_creation', $data); |
|
| 1223 | + } |
|
| 1224 | + |
|
| 1225 | + function customer_bulk_save() { |
|
| 1226 | + $data['page_title'] = 'Create Bulk Customer'; |
|
| 1227 | + $add_array = $this->input->post(); |
|
| 1228 | + if (!empty($add_array) && isset($add_array)) { |
|
| 1229 | + $currentlength = $this->accounts_model->get_max_limit($add_array); |
|
| 1230 | + $account_data = $this->session->userdata("accountinfo"); |
|
| 1231 | + $add_array['reseller_id'] = $account_data['type']==1 ? $account_data['id']:0; |
|
| 1232 | + $data['form'] = $this->form->build_form($this->accounts_form->customer_bulk_generate_form(), $add_array); |
|
| 1233 | + if ($this->form_validation->run() == FALSE) { |
|
| 1234 | + $data['validation_errors'] = validation_errors(); |
|
| 1235 | + echo $data['validation_errors']; |
|
| 1236 | + exit; |
|
| 1237 | + } |
|
| 1238 | + if($currentlength <= 0){ |
|
| 1239 | 1239 | echo json_encode(array("prefix_error" => "Your Account Limit has been reached.Please Change Your Prefix.")); |
| 1240 | - exit; |
|
| 1241 | - } |
|
| 1242 | - if ($add_array['account_length'] <= strlen($add_array['prefix'])) { |
|
| 1243 | - echo json_encode(array("account_length_error" => "Please Enter Proper Account Length.")); |
|
| 1244 | - exit; |
|
| 1245 | - } |
|
| 1246 | - if ($currentlength > 0 && $add_array['count'] > $currentlength) { |
|
| 1247 | - echo json_encode(array("count_error" => "You Can Create Maximum " . $currentlength . " accounts with " . $add_array['prefix'] . " prefix")); |
|
| 1248 | - exit; |
|
| 1249 | - } else { |
|
| 1250 | - $this->accounts_model->bulk_insert_accounts($add_array); |
|
| 1251 | - echo json_encode(array("SUCCESS" => "Bulk customer generate successfully!")); |
|
| 1252 | - exit; |
|
| 1253 | - } |
|
| 1254 | - } else { |
|
| 1255 | - redirect(base_url() . "accounts/customer_list/"); |
|
| 1256 | - } |
|
| 1257 | - } |
|
| 1258 | - |
|
| 1259 | - function customer_invoice_option($value = false) { |
|
| 1260 | - $sweepid = $this->input->post("sweepid", true); |
|
| 1261 | - $invoice_dropdown = $this->common->set_invoice_option($sweepid, "", "", $value); |
|
| 1262 | - echo $invoice_dropdown; |
|
| 1263 | - } |
|
| 1264 | - |
|
| 1265 | - /* * ***** |
|
| 1240 | + exit; |
|
| 1241 | + } |
|
| 1242 | + if ($add_array['account_length'] <= strlen($add_array['prefix'])) { |
|
| 1243 | + echo json_encode(array("account_length_error" => "Please Enter Proper Account Length.")); |
|
| 1244 | + exit; |
|
| 1245 | + } |
|
| 1246 | + if ($currentlength > 0 && $add_array['count'] > $currentlength) { |
|
| 1247 | + echo json_encode(array("count_error" => "You Can Create Maximum " . $currentlength . " accounts with " . $add_array['prefix'] . " prefix")); |
|
| 1248 | + exit; |
|
| 1249 | + } else { |
|
| 1250 | + $this->accounts_model->bulk_insert_accounts($add_array); |
|
| 1251 | + echo json_encode(array("SUCCESS" => "Bulk customer generate successfully!")); |
|
| 1252 | + exit; |
|
| 1253 | + } |
|
| 1254 | + } else { |
|
| 1255 | + redirect(base_url() . "accounts/customer_list/"); |
|
| 1256 | + } |
|
| 1257 | + } |
|
| 1258 | + |
|
| 1259 | + function customer_invoice_option($value = false) { |
|
| 1260 | + $sweepid = $this->input->post("sweepid", true); |
|
| 1261 | + $invoice_dropdown = $this->common->set_invoice_option($sweepid, "", "", $value); |
|
| 1262 | + echo $invoice_dropdown; |
|
| 1263 | + } |
|
| 1264 | + |
|
| 1265 | + /* * ***** |
|
| 1266 | 1266 | ASTPP 3.0 |
| 1267 | 1267 | in customer Edit put one dropdown with the name of country and change with Purchase dropdown. |
| 1268 | 1268 | * ***** */ |
| 1269 | 1269 | |
| 1270 | - function customer_did_country() { |
|
| 1271 | - $country_id = $_POST['country_id']; |
|
| 1272 | - $accountid= $this->input->post('accountid',true); |
|
| 1273 | - $accountinfo = $this->session->userdata("accountinfo"); |
|
| 1274 | - $entity_info=(array)$this->db->get_where('accounts',array("id"=>$accountid))->first_row(); |
|
| 1275 | - $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
|
| 1276 | - if ($entity_info['reseller_id'] > 0) { |
|
| 1277 | - $parent_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : $accountinfo['reseller_id']; |
|
| 1278 | - $query = 'select dids.id as id,dids.number as number,reseller_pricing.setup as setup, reseller_pricing.monthlycost as monthlycost from dids,reseller_pricing where dids.number= reseller_pricing.note and reseller_pricing.reseller_id =' . $parent_id . " and dids.accountid=0 and dids.country_id =" . $country_id; |
|
| 1279 | - $did_list = $this->db->query($query); |
|
| 1280 | - } else { |
|
| 1281 | - $did_list = $this->db_model->getSelect("id,number,setup,monthlycost", "dids", array('country_id' => $country_id, 'accountid' => '0', 'parent_id' => $reseller_id)); |
|
| 1282 | - } |
|
| 1283 | - $did_arr = array(); |
|
| 1284 | - if ($did_list->num_rows > 0) { |
|
| 1285 | - $did_data = $did_list->result_array(); |
|
| 1286 | - foreach ($did_data as $key => $value) { |
|
| 1287 | - $did_arr[$value['id']] = $value['number'] . " (Setup Cost : " . $this->common_model->calculate_currency($value['setup'], '', '', true) . ") (Monthly cost : " . $this->common_model->calculate_currency($value['monthlycost'], '', '', true) . ")"; |
|
| 1288 | - } |
|
| 1289 | - } |
|
| 1290 | - $did_info = array("name" => "free_didlist", "id" => "free_didlist", "class" => "free_didlist"); |
|
| 1291 | - echo form_dropdown_all($did_info, $did_arr, ''); |
|
| 1292 | - exit; |
|
| 1293 | - } |
|
| 1294 | - |
|
| 1295 | - /* * ************************************************************** */ |
|
| 1296 | - |
|
| 1297 | - function customer_payment_process_add($id = '') { |
|
| 1298 | - $account = $this->accounts_model->get_account_by_number($id); |
|
| 1299 | - $currency = $this->accounts_model->get_currency_by_id($account['currency_id']); |
|
| 1300 | - $data['username'] = $this->session->userdata('user_name'); |
|
| 1301 | - $data['page_title'] = 'Refill Process'; |
|
| 1302 | - $data['form'] = $this->form->build_form($this->accounts_form->get_customer_payment_fields($currency['currency'], $account['number'], $currency['currency'], $id), ''); |
|
| 1303 | - $this->load->view('view_accounts_process_payment', $data); |
|
| 1304 | - } |
|
| 1305 | - function customer_payment_save($id = '') { |
|
| 1270 | + function customer_did_country() { |
|
| 1271 | + $country_id = $_POST['country_id']; |
|
| 1272 | + $accountid= $this->input->post('accountid',true); |
|
| 1273 | + $accountinfo = $this->session->userdata("accountinfo"); |
|
| 1274 | + $entity_info=(array)$this->db->get_where('accounts',array("id"=>$accountid))->first_row(); |
|
| 1275 | + $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
|
| 1276 | + if ($entity_info['reseller_id'] > 0) { |
|
| 1277 | + $parent_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : $accountinfo['reseller_id']; |
|
| 1278 | + $query = 'select dids.id as id,dids.number as number,reseller_pricing.setup as setup, reseller_pricing.monthlycost as monthlycost from dids,reseller_pricing where dids.number= reseller_pricing.note and reseller_pricing.reseller_id =' . $parent_id . " and dids.accountid=0 and dids.country_id =" . $country_id; |
|
| 1279 | + $did_list = $this->db->query($query); |
|
| 1280 | + } else { |
|
| 1281 | + $did_list = $this->db_model->getSelect("id,number,setup,monthlycost", "dids", array('country_id' => $country_id, 'accountid' => '0', 'parent_id' => $reseller_id)); |
|
| 1282 | + } |
|
| 1283 | + $did_arr = array(); |
|
| 1284 | + if ($did_list->num_rows > 0) { |
|
| 1285 | + $did_data = $did_list->result_array(); |
|
| 1286 | + foreach ($did_data as $key => $value) { |
|
| 1287 | + $did_arr[$value['id']] = $value['number'] . " (Setup Cost : " . $this->common_model->calculate_currency($value['setup'], '', '', true) . ") (Monthly cost : " . $this->common_model->calculate_currency($value['monthlycost'], '', '', true) . ")"; |
|
| 1288 | + } |
|
| 1289 | + } |
|
| 1290 | + $did_info = array("name" => "free_didlist", "id" => "free_didlist", "class" => "free_didlist"); |
|
| 1291 | + echo form_dropdown_all($did_info, $did_arr, ''); |
|
| 1292 | + exit; |
|
| 1293 | + } |
|
| 1294 | + |
|
| 1295 | + /* * ************************************************************** */ |
|
| 1296 | + |
|
| 1297 | + function customer_payment_process_add($id = '') { |
|
| 1298 | + $account = $this->accounts_model->get_account_by_number($id); |
|
| 1299 | + $currency = $this->accounts_model->get_currency_by_id($account['currency_id']); |
|
| 1300 | + $data['username'] = $this->session->userdata('user_name'); |
|
| 1301 | + $data['page_title'] = 'Refill Process'; |
|
| 1302 | + $data['form'] = $this->form->build_form($this->accounts_form->get_customer_payment_fields($currency['currency'], $account['number'], $currency['currency'], $id), ''); |
|
| 1303 | + $this->load->view('view_accounts_process_payment', $data); |
|
| 1304 | + } |
|
| 1305 | + function customer_payment_save($id = '') { |
|
| 1306 | 1306 | $post_array = $this->input->post(); |
| 1307 | 1307 | $data['username'] = $this->session->userdata('user_name'); |
| 1308 | - $data['page_title'] = 'Process Payment'; |
|
| 1309 | - $account = $this->accounts_model->get_account_by_number($post_array['id']); |
|
| 1310 | - $currency = $this->accounts_model->get_currency_by_id($account['currency_id']); |
|
| 1311 | - $data['form'] = $this->form->build_form($this->accounts_form->get_customer_payment_fields($currency['currency'], $account['number'], $currency['currency'], $id), ''); |
|
| 1308 | + $data['page_title'] = 'Process Payment'; |
|
| 1309 | + $account = $this->accounts_model->get_account_by_number($post_array['id']); |
|
| 1310 | + $currency = $this->accounts_model->get_currency_by_id($account['currency_id']); |
|
| 1311 | + $data['form'] = $this->form->build_form($this->accounts_form->get_customer_payment_fields($currency['currency'], $account['number'], $currency['currency'], $id), ''); |
|
| 1312 | 1312 | if ($this->form_validation->run() == FALSE) { |
| 1313 | - $data['validation_errors'] = validation_errors(); |
|
| 1314 | - echo $data['validation_errors']; |
|
| 1315 | - exit; |
|
| 1313 | + $data['validation_errors'] = validation_errors(); |
|
| 1314 | + echo $data['validation_errors']; |
|
| 1315 | + exit; |
|
| 1316 | 1316 | } else { |
| 1317 | - $post_array['credit'] = $this->common_model->add_calculate_currency($post_array['credit'], "", '', false, false); |
|
| 1318 | - $logintype = $this->session->userdata('logintype'); |
|
| 1319 | - $username = $this->session->userdata('username'); |
|
| 1320 | - $login_user_data = $this->session->userdata("accountinfo"); |
|
| 1321 | - $accountinfo = $this->accounts_model->get_account_by_number($post_array['id']); |
|
| 1322 | - if($accountinfo['reseller_id'] == 0){ |
|
| 1323 | - $where = array("accountid"=> 1); |
|
| 1317 | + $post_array['credit'] = $this->common_model->add_calculate_currency($post_array['credit'], "", '', false, false); |
|
| 1318 | + $logintype = $this->session->userdata('logintype'); |
|
| 1319 | + $username = $this->session->userdata('username'); |
|
| 1320 | + $login_user_data = $this->session->userdata("accountinfo"); |
|
| 1321 | + $accountinfo = $this->accounts_model->get_account_by_number($post_array['id']); |
|
| 1322 | + if($accountinfo['reseller_id'] == 0){ |
|
| 1323 | + $where = array("accountid"=> 1); |
|
| 1324 | 1324 | }else{ |
| 1325 | - $where = array("accountid"=> $accountinfo['id']); |
|
| 1325 | + $where = array("accountid"=> $accountinfo['id']); |
|
| 1326 | 1326 | } |
| 1327 | 1327 | $query = $this->db_model->getSelect("*", "invoice_conf", $where); |
| 1328 | 1328 | if($query->num_rows >0){ |
| 1329 | - $invoice_conf = $query->result_array(); |
|
| 1330 | - $invoice_conf = $invoice_conf[0]; |
|
| 1329 | + $invoice_conf = $query->result_array(); |
|
| 1330 | + $invoice_conf = $invoice_conf[0]; |
|
| 1331 | 1331 | }else{ |
| 1332 | - $query = $this->db_model->getSelect("*", "invoice_conf",array("accountid"=> 1)); |
|
| 1333 | - $invoice_conf = $query->result_array(); |
|
| 1334 | - $invoice_conf = $invoice_conf[0]; |
|
| 1335 | - } |
|
| 1336 | - $last_invoice_ID = $this->get_invoice_date("invoiceid",$accountinfo["id"]); |
|
| 1337 | - $invoice_prefix=$invoice_conf['invoice_prefix']; |
|
| 1338 | - $due_date = gmdate("Y-m-d H:i:s",strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf['interval']." days")); |
|
| 1339 | - $response = $this->accounts_model->account_process_payment($post_array); |
|
| 1340 | - |
|
| 1341 | - if($post_array['payment_type']== 1 ){ |
|
| 1342 | - $this->load->module('invoices/invoices'); |
|
| 1343 | - $invoice_id=$this->invoices->invoices->generate_receipt($post_array['id'],$post_array['credit'],$accountinfo,$last_invoice_ID+1,$invoice_prefix,$due_date); |
|
| 1332 | + $query = $this->db_model->getSelect("*", "invoice_conf",array("accountid"=> 1)); |
|
| 1333 | + $invoice_conf = $query->result_array(); |
|
| 1334 | + $invoice_conf = $invoice_conf[0]; |
|
| 1335 | + } |
|
| 1336 | + $last_invoice_ID = $this->get_invoice_date("invoiceid",$accountinfo["id"]); |
|
| 1337 | + $invoice_prefix=$invoice_conf['invoice_prefix']; |
|
| 1338 | + $due_date = gmdate("Y-m-d H:i:s",strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf['interval']." days")); |
|
| 1339 | + $response = $this->accounts_model->account_process_payment($post_array); |
|
| 1340 | + |
|
| 1341 | + if($post_array['payment_type']== 1 ){ |
|
| 1342 | + $this->load->module('invoices/invoices'); |
|
| 1343 | + $invoice_id=$this->invoices->invoices->generate_receipt($post_array['id'],$post_array['credit'],$accountinfo,$last_invoice_ID+1,$invoice_prefix,$due_date); |
|
| 1344 | 1344 | $account_balance = $this->common->get_field_name('balance', 'accounts', $post_array['id']); |
| 1345 | - $insert_arr = array("accountid" => $post_array['id'], |
|
| 1346 | - "description" => trim($post_array['notes']), |
|
| 1347 | - "debit" => $post_array['credit'], |
|
| 1348 | - "credit" => '0', |
|
| 1349 | - "created_date" => gmdate("Y-m-d H:i:s"), |
|
| 1350 | - "invoiceid"=>$invoice_id, |
|
| 1351 | - "reseller_id"=>'0', |
|
| 1352 | - "item_type"=>'POSTCHARG', |
|
| 1353 | - "item_id"=>'0', |
|
| 1354 | - 'before_balance'=>$account_balance+$post_array['credit'], |
|
| 1355 | - 'after_balance'=>$account_balance, |
|
| 1356 | - ); |
|
| 1357 | - $this->db->insert("invoice_details", $insert_arr); |
|
| 1358 | - }else{ |
|
| 1359 | - $this->load->module('invoices/invoices'); |
|
| 1360 | - $invoice_id=$this->invoices->invoices->generate_receipt($post_array['id'],$post_array['credit'],$accountinfo,$last_invoice_ID+1,$invoice_prefix,$due_date); |
|
| 1361 | - $account_balance = $this->common->get_field_name('balance', 'accounts', $post_array['id']); |
|
| 1362 | - $insert_arr = array("accountid" => $post_array['id'], |
|
| 1363 | - "description" => trim($post_array['notes']), |
|
| 1364 | - "debit" => 0, |
|
| 1365 | - "credit" => $post_array['credit'], |
|
| 1366 | - "created_date" => gmdate("Y-m-d H:i:s"), |
|
| 1367 | - "invoiceid"=>$invoice_id, |
|
| 1368 | - "reseller_id"=>$accountinfo['reseller_id'], |
|
| 1369 | - "item_type"=>'Refill', |
|
| 1370 | - "item_id"=>'0', |
|
| 1371 | - 'before_balance'=>$account_balance-$post_array['credit'], |
|
| 1372 | - 'after_balance'=>$account_balance, |
|
| 1373 | - ); |
|
| 1374 | - $this->db->insert("invoice_details", $insert_arr); |
|
| 1375 | - if($login_user_data['type'] ==1){ |
|
| 1376 | - $reseller_ids=$this->common->get_parent_info($login_user_data['id'],0); |
|
| 1377 | - $reseller_ids=rtrim($reseller_ids,","); |
|
| 1378 | - $reseller_arr=explode(",",$reseller_ids); |
|
| 1379 | - if(!empty($reseller_arr)){ |
|
| 1345 | + $insert_arr = array("accountid" => $post_array['id'], |
|
| 1346 | + "description" => trim($post_array['notes']), |
|
| 1347 | + "debit" => $post_array['credit'], |
|
| 1348 | + "credit" => '0', |
|
| 1349 | + "created_date" => gmdate("Y-m-d H:i:s"), |
|
| 1350 | + "invoiceid"=>$invoice_id, |
|
| 1351 | + "reseller_id"=>'0', |
|
| 1352 | + "item_type"=>'POSTCHARG', |
|
| 1353 | + "item_id"=>'0', |
|
| 1354 | + 'before_balance'=>$account_balance+$post_array['credit'], |
|
| 1355 | + 'after_balance'=>$account_balance, |
|
| 1356 | + ); |
|
| 1357 | + $this->db->insert("invoice_details", $insert_arr); |
|
| 1358 | + }else{ |
|
| 1359 | + $this->load->module('invoices/invoices'); |
|
| 1360 | + $invoice_id=$this->invoices->invoices->generate_receipt($post_array['id'],$post_array['credit'],$accountinfo,$last_invoice_ID+1,$invoice_prefix,$due_date); |
|
| 1361 | + $account_balance = $this->common->get_field_name('balance', 'accounts', $post_array['id']); |
|
| 1362 | + $insert_arr = array("accountid" => $post_array['id'], |
|
| 1363 | + "description" => trim($post_array['notes']), |
|
| 1364 | + "debit" => 0, |
|
| 1365 | + "credit" => $post_array['credit'], |
|
| 1366 | + "created_date" => gmdate("Y-m-d H:i:s"), |
|
| 1367 | + "invoiceid"=>$invoice_id, |
|
| 1368 | + "reseller_id"=>$accountinfo['reseller_id'], |
|
| 1369 | + "item_type"=>'Refill', |
|
| 1370 | + "item_id"=>'0', |
|
| 1371 | + 'before_balance'=>$account_balance-$post_array['credit'], |
|
| 1372 | + 'after_balance'=>$account_balance, |
|
| 1373 | + ); |
|
| 1374 | + $this->db->insert("invoice_details", $insert_arr); |
|
| 1375 | + if($login_user_data['type'] ==1){ |
|
| 1376 | + $reseller_ids=$this->common->get_parent_info($login_user_data['id'],0); |
|
| 1377 | + $reseller_ids=rtrim($reseller_ids,","); |
|
| 1378 | + $reseller_arr=explode(",",$reseller_ids); |
|
| 1379 | + if(!empty($reseller_arr)){ |
|
| 1380 | 1380 | $custom_array=$post_array; |
| 1381 | 1381 | foreach($reseller_arr as $key=>$reseller_id){ |
| 1382 | 1382 | $custom_array['id']=$reseller_id; |
@@ -1386,31 +1386,31 @@ discard block |
||
| 1386 | 1386 | $invoice_id=$this->invoices->invoices->generate_receipt($reseller_info['id'],$custom_array['credit'],$reseller_info,$last_invoice_ID+1,$invoice_prefix,$due_date); |
| 1387 | 1387 | $account_balance = $this->common->get_field_name('balance', 'accounts', $reseller_info['id']); |
| 1388 | 1388 | $insert_arr = array("accountid" => $reseller_info['id'], |
| 1389 | - "description" => trim($custom_array['notes']), |
|
| 1390 | - "debit" => 0, |
|
| 1391 | - "credit" => $custom_array['credit'], |
|
| 1392 | - "created_date" => gmdate("Y-m-d H:i:s"), |
|
| 1393 | - "invoiceid"=>$invoice_id, |
|
| 1394 | - "reseller_id"=>$reseller_info['reseller_id'], |
|
| 1395 | - "item_type"=>'Refill', |
|
| 1396 | - "item_id"=>'0', |
|
| 1397 | - 'before_balance'=>$account_balance-$custom_array['credit'], |
|
| 1398 | - 'after_balance'=>$account_balance, |
|
| 1399 | - ); |
|
| 1400 | - $this->db->insert("invoice_details", $insert_arr); |
|
| 1389 | + "description" => trim($custom_array['notes']), |
|
| 1390 | + "debit" => 0, |
|
| 1391 | + "credit" => $custom_array['credit'], |
|
| 1392 | + "created_date" => gmdate("Y-m-d H:i:s"), |
|
| 1393 | + "invoiceid"=>$invoice_id, |
|
| 1394 | + "reseller_id"=>$reseller_info['reseller_id'], |
|
| 1395 | + "item_type"=>'Refill', |
|
| 1396 | + "item_id"=>'0', |
|
| 1397 | + 'before_balance'=>$account_balance-$custom_array['credit'], |
|
| 1398 | + 'after_balance'=>$account_balance, |
|
| 1399 | + ); |
|
| 1400 | + $this->db->insert("invoice_details", $insert_arr); |
|
| 1401 | + } |
|
| 1402 | + } |
|
| 1401 | 1403 | } |
| 1402 | - } |
|
| 1403 | - } |
|
| 1404 | 1404 | } |
| 1405 | - $message = $post_array['payment_type']== 0 ? "Recharge successfully!" : "Post charge applied successfully."; |
|
| 1405 | + $message = $post_array['payment_type']== 0 ? "Recharge successfully!" : "Post charge applied successfully."; |
|
| 1406 | 1406 | /***********************************************************************************************/ |
| 1407 | - echo json_encode(array("SUCCESS"=> $message)); |
|
| 1408 | - exit; |
|
| 1409 | - // } |
|
| 1410 | - } |
|
| 1411 | - $this->load->view('view_accounts_process_payment', $data); |
|
| 1412 | - } |
|
| 1413 | - function get_invoice_date($select,$accountid){ |
|
| 1407 | + echo json_encode(array("SUCCESS"=> $message)); |
|
| 1408 | + exit; |
|
| 1409 | + // } |
|
| 1410 | + } |
|
| 1411 | + $this->load->view('view_accounts_process_payment', $data); |
|
| 1412 | + } |
|
| 1413 | + function get_invoice_date($select,$accountid){ |
|
| 1414 | 1414 | $query = $this->db_model->select($select, "invoices", '',"id","DESC","1","0"); |
| 1415 | 1415 | if($query->num_rows >0){ |
| 1416 | 1416 | $invoiceid = $query->result_array(); |
@@ -1418,1058 +1418,1058 @@ discard block |
||
| 1418 | 1418 | return $invoice_date; |
| 1419 | 1419 | } |
| 1420 | 1420 | return false; |
| 1421 | - } |
|
| 1421 | + } |
|
| 1422 | 1422 | /***************************************Completed********************************************************/ |
| 1423 | 1423 | |
| 1424 | 1424 | |
| 1425 | - /** |
|
| 1426 | - * -------Here we write code for controller accounts functions add_callerid------ |
|
| 1427 | - * Add caller ids against account no |
|
| 1428 | - * @account_number: Account No |
|
| 1429 | - */ |
|
| 1430 | - function customer_add_callerid($id = "") { |
|
| 1431 | - $data['username'] = $this->session->userdata('user_name'); |
|
| 1432 | - $data['page_title'] = 'Force Caller Id'; |
|
| 1433 | - $account_num = $this->accounts_model->get_account_number($id); |
|
| 1434 | - $result = $this->accounts_model->get_callerid($id); |
|
| 1435 | - if ($result->num_rows() > 0) { |
|
| 1436 | - foreach ($result->result_array() as $values) { |
|
| 1437 | - $data['accountid'] = $values['accountid']; |
|
| 1438 | - $data['callerid_name'] = $values['callerid_name']; |
|
| 1439 | - $data['callerid_number'] = $values['callerid_number']; |
|
| 1440 | - $data['status'] = $values['status']; |
|
| 1441 | - $data['flag'] = '1'; |
|
| 1442 | - } |
|
| 1443 | - } else { |
|
| 1444 | - $data['accountid'] = $id; |
|
| 1445 | - $data['callerid_name'] = ''; |
|
| 1446 | - $data['callerid_number'] = ''; |
|
| 1447 | - $data['status'] = '0'; |
|
| 1448 | - $data['flag'] = '0'; |
|
| 1449 | - } |
|
| 1450 | - $data['accountid'] = $account_num['number']; |
|
| 1451 | - $data['form'] = $this->form->build_form($this->accounts_form->get_customer_callerid_fields(), $data); |
|
| 1452 | - $post_array = $this->input->post(); |
|
| 1425 | + /** |
|
| 1426 | + * -------Here we write code for controller accounts functions add_callerid------ |
|
| 1427 | + * Add caller ids against account no |
|
| 1428 | + * @account_number: Account No |
|
| 1429 | + */ |
|
| 1430 | + function customer_add_callerid($id = "") { |
|
| 1431 | + $data['username'] = $this->session->userdata('user_name'); |
|
| 1432 | + $data['page_title'] = 'Force Caller Id'; |
|
| 1433 | + $account_num = $this->accounts_model->get_account_number($id); |
|
| 1434 | + $result = $this->accounts_model->get_callerid($id); |
|
| 1435 | + if ($result->num_rows() > 0) { |
|
| 1436 | + foreach ($result->result_array() as $values) { |
|
| 1437 | + $data['accountid'] = $values['accountid']; |
|
| 1438 | + $data['callerid_name'] = $values['callerid_name']; |
|
| 1439 | + $data['callerid_number'] = $values['callerid_number']; |
|
| 1440 | + $data['status'] = $values['status']; |
|
| 1441 | + $data['flag'] = '1'; |
|
| 1442 | + } |
|
| 1443 | + } else { |
|
| 1444 | + $data['accountid'] = $id; |
|
| 1445 | + $data['callerid_name'] = ''; |
|
| 1446 | + $data['callerid_number'] = ''; |
|
| 1447 | + $data['status'] = '0'; |
|
| 1448 | + $data['flag'] = '0'; |
|
| 1449 | + } |
|
| 1450 | + $data['accountid'] = $account_num['number']; |
|
| 1451 | + $data['form'] = $this->form->build_form($this->accounts_form->get_customer_callerid_fields(), $data); |
|
| 1452 | + $post_array = $this->input->post(); |
|
| 1453 | 1453 | |
| 1454 | - if (!empty($post_array)) { |
|
| 1455 | - if ($this->form_validation->run() == FALSE) { |
|
| 1456 | - $data['validation_errors'] = validation_errors(); |
|
| 1457 | - echo $data['validation_errors']; |
|
| 1458 | - exit; |
|
| 1459 | - } else { |
|
| 1460 | - if ($post_array['flag'] == '1') { |
|
| 1461 | - $this->accounts_model->edit_callerid($post_array); |
|
| 1462 | - echo json_encode(array("SUCCESS"=> "Account callerID updated successfully!")); |
|
| 1463 | - exit; |
|
| 1464 | - } else { |
|
| 1465 | - $this->accounts_model->add_callerid($post_array); |
|
| 1466 | - echo json_encode(array("SUCCESS"=> "Account callerID added successfully!")); |
|
| 1467 | - exit; |
|
| 1468 | - } |
|
| 1469 | - } |
|
| 1470 | - } |
|
| 1471 | - $this->load->view('view_accounts_add_callerid', $data); |
|
| 1472 | - } |
|
| 1473 | - function reseller_add($type = "") { |
|
| 1454 | + if (!empty($post_array)) { |
|
| 1455 | + if ($this->form_validation->run() == FALSE) { |
|
| 1456 | + $data['validation_errors'] = validation_errors(); |
|
| 1457 | + echo $data['validation_errors']; |
|
| 1458 | + exit; |
|
| 1459 | + } else { |
|
| 1460 | + if ($post_array['flag'] == '1') { |
|
| 1461 | + $this->accounts_model->edit_callerid($post_array); |
|
| 1462 | + echo json_encode(array("SUCCESS"=> "Account callerID updated successfully!")); |
|
| 1463 | + exit; |
|
| 1464 | + } else { |
|
| 1465 | + $this->accounts_model->add_callerid($post_array); |
|
| 1466 | + echo json_encode(array("SUCCESS"=> "Account callerID added successfully!")); |
|
| 1467 | + exit; |
|
| 1468 | + } |
|
| 1469 | + } |
|
| 1470 | + } |
|
| 1471 | + $this->load->view('view_accounts_add_callerid', $data); |
|
| 1472 | + } |
|
| 1473 | + function reseller_add($type = "") { |
|
| 1474 | 1474 | $accountinfo = $this->session->userdata('accountinfo'); |
| 1475 | - $data['username'] = $this->session->userdata('user_name'); |
|
| 1476 | - $data['flag'] = 'create'; |
|
| 1477 | - $data['page_title'] = 'Create Reseller'; |
|
| 1478 | - $data['back_flag'] = true; |
|
| 1479 | - $data['form'] = $this->form->build_form($this->accounts_form->get_form_reseller_fields(), ''); |
|
| 1480 | - $data['country_id'] = $accountinfo['country_id']; |
|
| 1475 | + $data['username'] = $this->session->userdata('user_name'); |
|
| 1476 | + $data['flag'] = 'create'; |
|
| 1477 | + $data['page_title'] = 'Create Reseller'; |
|
| 1478 | + $data['back_flag'] = true; |
|
| 1479 | + $data['form'] = $this->form->build_form($this->accounts_form->get_form_reseller_fields(), ''); |
|
| 1480 | + $data['country_id'] = $accountinfo['country_id']; |
|
| 1481 | 1481 | $data['currency_id'] = $accountinfo['currency_id']; |
| 1482 | - $data['timezone_id'] = $accountinfo['timezone_id']; |
|
| 1483 | - if (!$data['timezone_id']) { |
|
| 1484 | - $data['timezone_id'] = 1; |
|
| 1485 | - } |
|
| 1486 | - if (!$data['currency_id']) { |
|
| 1487 | - $data['currency_id'] = 1; |
|
| 1488 | - } |
|
| 1489 | - if (!$data['country_id']) { |
|
| 1490 | - $data['country_id'] = 1; |
|
| 1491 | - } |
|
| 1492 | - |
|
| 1493 | - $this->load->view('view_accounts_create', $data); |
|
| 1494 | - } |
|
| 1495 | - |
|
| 1496 | - function reseller_edit($edit_id = '') { |
|
| 1497 | - $data['page_title'] = 'Edit Reseller'; |
|
| 1498 | - $where = array('id' => $edit_id); |
|
| 1499 | - $account = $this->db_model->getSelect("*", "accounts", $where); |
|
| 1500 | - $data["account_data"] = $account->result_array(); |
|
| 1501 | - $acc_data = $this->session->userdata("accountinfo"); |
|
| 1502 | - foreach ($account->result_array() as $key => $value) { |
|
| 1503 | - $edit_data = $value; |
|
| 1504 | - } |
|
| 1505 | - $taxes_data = $this->db_model->getSelect("group_concat(taxes_id) as taxes_id", "taxes_to_accounts", array("accountid" => $edit_id)); |
|
| 1506 | - if (isset($taxes_data) && $taxes_data->num_rows() > 0) { |
|
| 1507 | - $taxes_data = $taxes_data->result_array(); |
|
| 1508 | - $edit_data["tax_id"] = explode(",", $taxes_data[0]['taxes_id']); |
|
| 1509 | - } |
|
| 1510 | - |
|
| 1511 | - /** |
|
| 1482 | + $data['timezone_id'] = $accountinfo['timezone_id']; |
|
| 1483 | + if (!$data['timezone_id']) { |
|
| 1484 | + $data['timezone_id'] = 1; |
|
| 1485 | + } |
|
| 1486 | + if (!$data['currency_id']) { |
|
| 1487 | + $data['currency_id'] = 1; |
|
| 1488 | + } |
|
| 1489 | + if (!$data['country_id']) { |
|
| 1490 | + $data['country_id'] = 1; |
|
| 1491 | + } |
|
| 1492 | + |
|
| 1493 | + $this->load->view('view_accounts_create', $data); |
|
| 1494 | + } |
|
| 1495 | + |
|
| 1496 | + function reseller_edit($edit_id = '') { |
|
| 1497 | + $data['page_title'] = 'Edit Reseller'; |
|
| 1498 | + $where = array('id' => $edit_id); |
|
| 1499 | + $account = $this->db_model->getSelect("*", "accounts", $where); |
|
| 1500 | + $data["account_data"] = $account->result_array(); |
|
| 1501 | + $acc_data = $this->session->userdata("accountinfo"); |
|
| 1502 | + foreach ($account->result_array() as $key => $value) { |
|
| 1503 | + $edit_data = $value; |
|
| 1504 | + } |
|
| 1505 | + $taxes_data = $this->db_model->getSelect("group_concat(taxes_id) as taxes_id", "taxes_to_accounts", array("accountid" => $edit_id)); |
|
| 1506 | + if (isset($taxes_data) && $taxes_data->num_rows() > 0) { |
|
| 1507 | + $taxes_data = $taxes_data->result_array(); |
|
| 1508 | + $edit_data["tax_id"] = explode(",", $taxes_data[0]['taxes_id']); |
|
| 1509 | + } |
|
| 1510 | + |
|
| 1511 | + /** |
|
| 1512 | 1512 | ASTPP 3.0 |
| 1513 | 1513 | Add For Signup module |
| 1514 | - * */ |
|
| 1515 | - $encrypted_string = $this->common->encode($edit_data['id']); |
|
| 1516 | - $encrypt = $this->common->encode_params($encrypted_string); |
|
| 1517 | - $edit_data['registration_url'] = base_url() . "signup/" . $encrypt; |
|
| 1518 | - /* * *********************************************************** */ |
|
| 1519 | - /* * *** |
|
| 1514 | + * */ |
|
| 1515 | + $encrypted_string = $this->common->encode($edit_data['id']); |
|
| 1516 | + $encrypt = $this->common->encode_params($encrypted_string); |
|
| 1517 | + $edit_data['registration_url'] = base_url() . "signup/" . $encrypt; |
|
| 1518 | + /* * *********************************************************** */ |
|
| 1519 | + /* * *** |
|
| 1520 | 1520 | ASTPP 3.0 |
| 1521 | 1521 | Password decode |
| 1522 | 1522 | * **** */ |
| 1523 | - $edit_data['password'] = $this->common->decode($edit_data['password']); |
|
| 1524 | - $edit_data['credit_limit']=$this->common_model->calculate_currency(($edit_data['credit_limit']),'','',true,false); |
|
| 1525 | - $entity_name = strtolower($this->common->get_entity_type('', '', $edit_data['type'])); |
|
| 1526 | - $data['edit_id']=$edit_id; |
|
| 1527 | - $data['page_title'] =ucfirst($entity_name)." Profile"; |
|
| 1528 | - $data['entity_name'] = $entity_name; |
|
| 1529 | - /* * ********************** */ |
|
| 1530 | - $data['form'] = $this->form->build_form($this->accounts_form->get_form_reseller_fields($edit_id), $edit_data); |
|
| 1531 | - $this->load->view('view_reseller_details', $data); |
|
| 1532 | - } |
|
| 1533 | - |
|
| 1534 | - /* * *********************************************************** */ |
|
| 1535 | - |
|
| 1536 | - function reseller_save() { |
|
| 1537 | - $add_array = $this->input->post(); |
|
| 1538 | - $entity_name = strtolower($this->common->get_entity_type('', '', $add_array['type'])); |
|
| 1539 | - $data['country_id'] = $add_array['country_id']; |
|
| 1540 | - $data['timezone_id'] = $add_array['timezone_id']; |
|
| 1541 | - $data['currency_id'] = $add_array['currency_id']; |
|
| 1542 | - $data['entity_name'] = $entity_name; |
|
| 1543 | - $data['edit_id']=$add_array['id']; |
|
| 1544 | - $data['form'] = $this->form->build_form($this->accounts_form->get_form_reseller_fields($add_array['id']), $add_array); |
|
| 1545 | - if ($add_array['id'] != '') { |
|
| 1546 | - $data['page_title'] = 'Edit Reseller'; |
|
| 1547 | - if ($this->form_validation->run() == FALSE) { |
|
| 1548 | - $data['validation_errors'] = validation_errors(); |
|
| 1549 | - } else { |
|
| 1550 | - /* * **** |
|
| 1523 | + $edit_data['password'] = $this->common->decode($edit_data['password']); |
|
| 1524 | + $edit_data['credit_limit']=$this->common_model->calculate_currency(($edit_data['credit_limit']),'','',true,false); |
|
| 1525 | + $entity_name = strtolower($this->common->get_entity_type('', '', $edit_data['type'])); |
|
| 1526 | + $data['edit_id']=$edit_id; |
|
| 1527 | + $data['page_title'] =ucfirst($entity_name)." Profile"; |
|
| 1528 | + $data['entity_name'] = $entity_name; |
|
| 1529 | + /* * ********************** */ |
|
| 1530 | + $data['form'] = $this->form->build_form($this->accounts_form->get_form_reseller_fields($edit_id), $edit_data); |
|
| 1531 | + $this->load->view('view_reseller_details', $data); |
|
| 1532 | + } |
|
| 1533 | + |
|
| 1534 | + /* * *********************************************************** */ |
|
| 1535 | + |
|
| 1536 | + function reseller_save() { |
|
| 1537 | + $add_array = $this->input->post(); |
|
| 1538 | + $entity_name = strtolower($this->common->get_entity_type('', '', $add_array['type'])); |
|
| 1539 | + $data['country_id'] = $add_array['country_id']; |
|
| 1540 | + $data['timezone_id'] = $add_array['timezone_id']; |
|
| 1541 | + $data['currency_id'] = $add_array['currency_id']; |
|
| 1542 | + $data['entity_name'] = $entity_name; |
|
| 1543 | + $data['edit_id']=$add_array['id']; |
|
| 1544 | + $data['form'] = $this->form->build_form($this->accounts_form->get_form_reseller_fields($add_array['id']), $add_array); |
|
| 1545 | + if ($add_array['id'] != '') { |
|
| 1546 | + $data['page_title'] = 'Edit Reseller'; |
|
| 1547 | + if ($this->form_validation->run() == FALSE) { |
|
| 1548 | + $data['validation_errors'] = validation_errors(); |
|
| 1549 | + } else { |
|
| 1550 | + /* * **** |
|
| 1551 | 1551 | ASTPP 3.0 |
| 1552 | 1552 | Password encode |
| 1553 | 1553 | * **** */ |
| 1554 | - $add_array['password'] = $this->common->encode($add_array['password']); |
|
| 1555 | - /* * ****************** */ |
|
| 1556 | - $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
|
| 1557 | - $query = $this->accounts_model->remove_all_account_tax($add_array['id']); |
|
| 1558 | - if (isset($add_array['tax_id'])) { |
|
| 1559 | - foreach ($add_array['tax_id'] as $key => $val) { |
|
| 1560 | - $data1 = array( |
|
| 1561 | - 'accountid' => $add_array['id'], |
|
| 1562 | - 'taxes_id' => $val, |
|
| 1563 | - ); |
|
| 1564 | - $this->accounts_model->add_account_tax($data1); |
|
| 1565 | - } |
|
| 1566 | - unset($add_array['tax_id']); |
|
| 1567 | - } |
|
| 1568 | - unset($add_array['number'],$add_array['registration_url']); |
|
| 1569 | - $this->accounts_model->edit_account($add_array, $add_array['id']); |
|
| 1570 | - $this->session->set_flashdata('astpp_errormsg', 'Reseller updated successfully!'); |
|
| 1571 | - |
|
| 1572 | - redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1573 | - exit; |
|
| 1574 | - } |
|
| 1575 | - $data["account_data"]["0"] = $add_array; |
|
| 1576 | - $edit_id = $add_array["id"]; |
|
| 1577 | - $data['chargelist'] = form_dropdown('applayable_charge', $this->Astpp_common->list_applyable_charges($edit_id), ''); |
|
| 1578 | - |
|
| 1579 | - $this->load->module('charges/charges'); |
|
| 1580 | - $data['charges_grid_field'] = $this->charges->charges_form->build_charges_list_for_customer($edit_id, "reseller"); |
|
| 1581 | - |
|
| 1582 | - $data["sipiax_grid_field"] = json_decode($this->accounts_form->build_sipiax_list_for_customer()); |
|
| 1583 | - |
|
| 1584 | - $this->load->module('did/did'); |
|
| 1585 | - $data['did_grid_fields'] = $this->did->did_form->build_did_list_for_customer($edit_id, "reseller"); |
|
| 1586 | - $data['didlist'] = form_dropdown('free_did_list', $this->db_model->build_dropdown("id,number", "dids", "accountid", "0"), ''); |
|
| 1587 | - |
|
| 1588 | - |
|
| 1589 | - $this->load->module('invoices/invoices'); |
|
| 1590 | - $data['invoice_grid_fields'] = $this->invoices->invoices_form->build_invoices_list_for_admin(); |
|
| 1591 | - |
|
| 1592 | - $this->load->module('reports/reports'); |
|
| 1593 | - $data['cdrs_grid_fields'] = $this->reports->reports_form->build_report_list_for_user(); |
|
| 1594 | - $this->load->view('view_reseller_details', $data); |
|
| 1595 | - } else { |
|
| 1596 | - |
|
| 1597 | - $data['page_title'] = 'Create Reseller'; |
|
| 1598 | - if ($this->form_validation->run() == FALSE) { |
|
| 1599 | - $data['validation_errors'] = validation_errors(); |
|
| 1600 | - } else { |
|
| 1601 | - /* * **** |
|
| 1554 | + $add_array['password'] = $this->common->encode($add_array['password']); |
|
| 1555 | + /* * ****************** */ |
|
| 1556 | + $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
|
| 1557 | + $query = $this->accounts_model->remove_all_account_tax($add_array['id']); |
|
| 1558 | + if (isset($add_array['tax_id'])) { |
|
| 1559 | + foreach ($add_array['tax_id'] as $key => $val) { |
|
| 1560 | + $data1 = array( |
|
| 1561 | + 'accountid' => $add_array['id'], |
|
| 1562 | + 'taxes_id' => $val, |
|
| 1563 | + ); |
|
| 1564 | + $this->accounts_model->add_account_tax($data1); |
|
| 1565 | + } |
|
| 1566 | + unset($add_array['tax_id']); |
|
| 1567 | + } |
|
| 1568 | + unset($add_array['number'],$add_array['registration_url']); |
|
| 1569 | + $this->accounts_model->edit_account($add_array, $add_array['id']); |
|
| 1570 | + $this->session->set_flashdata('astpp_errormsg', 'Reseller updated successfully!'); |
|
| 1571 | + |
|
| 1572 | + redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1573 | + exit; |
|
| 1574 | + } |
|
| 1575 | + $data["account_data"]["0"] = $add_array; |
|
| 1576 | + $edit_id = $add_array["id"]; |
|
| 1577 | + $data['chargelist'] = form_dropdown('applayable_charge', $this->Astpp_common->list_applyable_charges($edit_id), ''); |
|
| 1578 | + |
|
| 1579 | + $this->load->module('charges/charges'); |
|
| 1580 | + $data['charges_grid_field'] = $this->charges->charges_form->build_charges_list_for_customer($edit_id, "reseller"); |
|
| 1581 | + |
|
| 1582 | + $data["sipiax_grid_field"] = json_decode($this->accounts_form->build_sipiax_list_for_customer()); |
|
| 1583 | + |
|
| 1584 | + $this->load->module('did/did'); |
|
| 1585 | + $data['did_grid_fields'] = $this->did->did_form->build_did_list_for_customer($edit_id, "reseller"); |
|
| 1586 | + $data['didlist'] = form_dropdown('free_did_list', $this->db_model->build_dropdown("id,number", "dids", "accountid", "0"), ''); |
|
| 1587 | + |
|
| 1588 | + |
|
| 1589 | + $this->load->module('invoices/invoices'); |
|
| 1590 | + $data['invoice_grid_fields'] = $this->invoices->invoices_form->build_invoices_list_for_admin(); |
|
| 1591 | + |
|
| 1592 | + $this->load->module('reports/reports'); |
|
| 1593 | + $data['cdrs_grid_fields'] = $this->reports->reports_form->build_report_list_for_user(); |
|
| 1594 | + $this->load->view('view_reseller_details', $data); |
|
| 1595 | + } else { |
|
| 1596 | + |
|
| 1597 | + $data['page_title'] = 'Create Reseller'; |
|
| 1598 | + if ($this->form_validation->run() == FALSE) { |
|
| 1599 | + $data['validation_errors'] = validation_errors(); |
|
| 1600 | + } else { |
|
| 1601 | + /* * **** |
|
| 1602 | 1602 | ASTPP 3.0 |
| 1603 | 1603 | Password encode |
| 1604 | 1604 | * **** */ |
| 1605 | - $add_array['password'] = $this->common->encode($add_array['password']); |
|
| 1606 | - /* * ****************** */ |
|
| 1607 | - $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
|
| 1608 | - $last_id = $this->accounts_model->add_account($add_array); |
|
| 1609 | - if (isset($add_array['tax_id'])) { |
|
| 1610 | - foreach ($add_array['tax_id'] as $key => $val) { |
|
| 1611 | - $data1 = array( |
|
| 1612 | - 'accountid' => $last_id, |
|
| 1613 | - 'taxes_id' => $val, |
|
| 1614 | - ); |
|
| 1615 | - $this->accounts_model->add_account_tax($data1); |
|
| 1616 | - } |
|
| 1617 | - unset($add_array['tax_id']); |
|
| 1618 | - } |
|
| 1619 | - $this->session->set_flashdata('astpp_errormsg', 'Reseller added successfully!'); |
|
| 1620 | - redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1621 | - exit; |
|
| 1622 | - } |
|
| 1623 | - $this->load->view('view_accounts_create', $data); |
|
| 1624 | - } |
|
| 1625 | - } |
|
| 1626 | - |
|
| 1627 | - function reseller_dids($edit_id) { |
|
| 1628 | - $this->customer_dids($edit_id); |
|
| 1629 | - } |
|
| 1630 | - |
|
| 1631 | - function customer_generate_password() { |
|
| 1632 | - echo $this->common->generate_password(); |
|
| 1633 | - } |
|
| 1634 | - |
|
| 1635 | - function customer_generate_number($digit='') { |
|
| 1605 | + $add_array['password'] = $this->common->encode($add_array['password']); |
|
| 1606 | + /* * ****************** */ |
|
| 1607 | + $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
|
| 1608 | + $last_id = $this->accounts_model->add_account($add_array); |
|
| 1609 | + if (isset($add_array['tax_id'])) { |
|
| 1610 | + foreach ($add_array['tax_id'] as $key => $val) { |
|
| 1611 | + $data1 = array( |
|
| 1612 | + 'accountid' => $last_id, |
|
| 1613 | + 'taxes_id' => $val, |
|
| 1614 | + ); |
|
| 1615 | + $this->accounts_model->add_account_tax($data1); |
|
| 1616 | + } |
|
| 1617 | + unset($add_array['tax_id']); |
|
| 1618 | + } |
|
| 1619 | + $this->session->set_flashdata('astpp_errormsg', 'Reseller added successfully!'); |
|
| 1620 | + redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1621 | + exit; |
|
| 1622 | + } |
|
| 1623 | + $this->load->view('view_accounts_create', $data); |
|
| 1624 | + } |
|
| 1625 | + } |
|
| 1626 | + |
|
| 1627 | + function reseller_dids($edit_id) { |
|
| 1628 | + $this->customer_dids($edit_id); |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + function customer_generate_password() { |
|
| 1632 | + echo $this->common->generate_password(); |
|
| 1633 | + } |
|
| 1634 | + |
|
| 1635 | + function customer_generate_number($digit='') { |
|
| 1636 | 1636 | |
| 1637 | - echo $this->common->find_uniq_rendno($digit, 'number', 'accounts'); |
|
| 1638 | - } |
|
| 1637 | + echo $this->common->find_uniq_rendno($digit, 'number', 'accounts'); |
|
| 1638 | + } |
|
| 1639 | 1639 | |
| 1640 | - function admin_add($type = 2) { |
|
| 1640 | + function admin_add($type = 2) { |
|
| 1641 | 1641 | $accountinfo = $this->session->userdata('accountinfo'); |
| 1642 | 1642 | $entity_type = strtolower($this->common->get_entity_type('', '', $type)); |
| 1643 | - $entitytype = str_replace(' ', '', $entity_type); |
|
| 1644 | - $data['username'] = $this->session->userdata('user_name'); |
|
| 1645 | - $data['flag'] = 'create'; |
|
| 1646 | - $data['page_title'] = 'Create ' . ucfirst($entity_type); |
|
| 1647 | - $data['back_flag'] = true; |
|
| 1648 | - $data['form'] = $this->form->build_form($this->accounts_form->get_form_admin_fields($entitytype), ''); |
|
| 1649 | - $data['country_id'] = $accountinfo['country_id']; |
|
| 1650 | - $data['currency_id'] = $accountinfo['currency_id']; |
|
| 1651 | - $data['timezone_id'] = $accountinfo['timezone_id']; |
|
| 1652 | - if (!$data['timezone_id']) { |
|
| 1653 | - $data['timezone_id'] = 1; |
|
| 1654 | - } |
|
| 1655 | - if (!$data['currency_id']) { |
|
| 1656 | - $data['currency_id'] = 1; |
|
| 1657 | - } |
|
| 1658 | - if (!$data['country_id']) { |
|
| 1659 | - $data['country_id'] = 1; |
|
| 1660 | - } |
|
| 1661 | - $data['entity_name'] = $entity_type; |
|
| 1662 | - $this->load->view('view_accounts_create', $data); |
|
| 1663 | - } |
|
| 1664 | - |
|
| 1665 | - function admin_edit($edit_id = '') { |
|
| 1643 | + $entitytype = str_replace(' ', '', $entity_type); |
|
| 1644 | + $data['username'] = $this->session->userdata('user_name'); |
|
| 1645 | + $data['flag'] = 'create'; |
|
| 1646 | + $data['page_title'] = 'Create ' . ucfirst($entity_type); |
|
| 1647 | + $data['back_flag'] = true; |
|
| 1648 | + $data['form'] = $this->form->build_form($this->accounts_form->get_form_admin_fields($entitytype), ''); |
|
| 1649 | + $data['country_id'] = $accountinfo['country_id']; |
|
| 1650 | + $data['currency_id'] = $accountinfo['currency_id']; |
|
| 1651 | + $data['timezone_id'] = $accountinfo['timezone_id']; |
|
| 1652 | + if (!$data['timezone_id']) { |
|
| 1653 | + $data['timezone_id'] = 1; |
|
| 1654 | + } |
|
| 1655 | + if (!$data['currency_id']) { |
|
| 1656 | + $data['currency_id'] = 1; |
|
| 1657 | + } |
|
| 1658 | + if (!$data['country_id']) { |
|
| 1659 | + $data['country_id'] = 1; |
|
| 1660 | + } |
|
| 1661 | + $data['entity_name'] = $entity_type; |
|
| 1662 | + $this->load->view('view_accounts_create', $data); |
|
| 1663 | + } |
|
| 1664 | + |
|
| 1665 | + function admin_edit($edit_id = '') { |
|
| 1666 | 1666 | $data['back_flag'] = true; |
| 1667 | - $accountinfo=(array)$this->db->get_where('accounts',array("id"=>$edit_id))->first_row(); |
|
| 1668 | - $type = $accountinfo['type'] == -1 ? 2 : $accountinfo['type']; |
|
| 1669 | - $entity_type = strtolower($this->common->get_entity_type('', '', $type)); |
|
| 1670 | - $entitytype = str_replace(' ', '', $entity_type); |
|
| 1671 | - $accountinfo['password'] = $this->common->decode($accountinfo['password']); |
|
| 1672 | - $data['form'] = $this->form->build_form($this->accounts_form->get_form_admin_fields($entitytype, $edit_id), $accountinfo); |
|
| 1673 | - $data['page_title'] = 'Edit ' . ucfirst($entity_type); |
|
| 1674 | - $this->load->view('view_admin_details', $data); |
|
| 1667 | + $accountinfo=(array)$this->db->get_where('accounts',array("id"=>$edit_id))->first_row(); |
|
| 1668 | + $type = $accountinfo['type'] == -1 ? 2 : $accountinfo['type']; |
|
| 1669 | + $entity_type = strtolower($this->common->get_entity_type('', '', $type)); |
|
| 1670 | + $entitytype = str_replace(' ', '', $entity_type); |
|
| 1671 | + $accountinfo['password'] = $this->common->decode($accountinfo['password']); |
|
| 1672 | + $data['form'] = $this->form->build_form($this->accounts_form->get_form_admin_fields($entitytype, $edit_id), $accountinfo); |
|
| 1673 | + $data['page_title'] = 'Edit ' . ucfirst($entity_type); |
|
| 1674 | + $this->load->view('view_admin_details', $data); |
|
| 1675 | 1675 | |
| 1676 | - } |
|
| 1677 | - |
|
| 1678 | - function admin_save($add_array = false) { |
|
| 1679 | - $add_array = $this->input->post(); |
|
| 1680 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1681 | - $type = $add_array['type'] == -1 ? 2 : $add_array['type']; |
|
| 1682 | - $entity_type = strtolower($this->common->get_entity_type('', '', $type)); |
|
| 1683 | - $entitytype = str_replace(' ', '', $entity_type); |
|
| 1684 | - $data['username'] = $this->session->userdata('user_name'); |
|
| 1685 | - $data['flag'] = 'create'; |
|
| 1686 | - $data['page_title'] = 'Create ' . $entity_type; |
|
| 1687 | - $data['form'] = $this->form->build_form($this->accounts_form->get_form_admin_fields($entitytype, $add_array['id']), $add_array); |
|
| 1688 | - if ($add_array['id'] != '') { |
|
| 1689 | - $data['page_title'] = 'Edit ' . $entity_type; |
|
| 1690 | - if ($this->form_validation->run() == FALSE) { |
|
| 1691 | - $data['validation_errors'] = validation_errors(); |
|
| 1692 | - } else { |
|
| 1693 | - /* * **** |
|
| 1676 | + } |
|
| 1677 | + |
|
| 1678 | + function admin_save($add_array = false) { |
|
| 1679 | + $add_array = $this->input->post(); |
|
| 1680 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1681 | + $type = $add_array['type'] == -1 ? 2 : $add_array['type']; |
|
| 1682 | + $entity_type = strtolower($this->common->get_entity_type('', '', $type)); |
|
| 1683 | + $entitytype = str_replace(' ', '', $entity_type); |
|
| 1684 | + $data['username'] = $this->session->userdata('user_name'); |
|
| 1685 | + $data['flag'] = 'create'; |
|
| 1686 | + $data['page_title'] = 'Create ' . $entity_type; |
|
| 1687 | + $data['form'] = $this->form->build_form($this->accounts_form->get_form_admin_fields($entitytype, $add_array['id']), $add_array); |
|
| 1688 | + if ($add_array['id'] != '') { |
|
| 1689 | + $data['page_title'] = 'Edit ' . $entity_type; |
|
| 1690 | + if ($this->form_validation->run() == FALSE) { |
|
| 1691 | + $data['validation_errors'] = validation_errors(); |
|
| 1692 | + } else { |
|
| 1693 | + /* * **** |
|
| 1694 | 1694 | ASTPP 3.0 |
| 1695 | 1695 | Password encode |
| 1696 | 1696 | * **** */ |
| 1697 | - $add_array['password'] = $this->common->encode($add_array['password']); |
|
| 1698 | - /* * ****************** */ |
|
| 1699 | - $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
|
| 1700 | - $query = $this->accounts_model->remove_all_account_tax($add_array['id']); |
|
| 1701 | - if (isset($add_array['tax_id'])) { |
|
| 1702 | - foreach ($add_array['tax_id'] as $key => $val) { |
|
| 1703 | - $data1 = array( |
|
| 1704 | - 'accountid' => $add_array['id'], |
|
| 1705 | - 'taxes_id' => $val, |
|
| 1706 | - ); |
|
| 1707 | - $this->accounts_model->add_account_tax($data1); |
|
| 1708 | - } |
|
| 1709 | - unset($add_array['tax_id']); |
|
| 1710 | - } |
|
| 1711 | - unset($add_array['number']); |
|
| 1712 | - $this->accounts_model->edit_account($add_array, $add_array['id']); |
|
| 1713 | - if ($add_array['id'] == $accountinfo['id']) { |
|
| 1714 | - $result = $this->db->get_where('accounts', array('id' => $add_array['id'])); |
|
| 1715 | - $result = $result->result_array(); |
|
| 1716 | - $this->session->set_userdata('accountinfo', $result[0]); |
|
| 1717 | - } |
|
| 1718 | - $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_type) . ' updated successfully!'); |
|
| 1719 | - redirect(base_url() . 'accounts/admin_list/'); |
|
| 1720 | - exit; |
|
| 1721 | - } |
|
| 1722 | - $this->load->view('view_admin_details', $data); |
|
| 1723 | - } else { |
|
| 1724 | - $data['page_title'] = 'Create ' . ucfirst($entity_type); |
|
| 1725 | - if ($this->form_validation->run() == FALSE) { |
|
| 1726 | - $data['validation_errors'] = validation_errors(); |
|
| 1727 | - } else { |
|
| 1728 | - $add_array['password'] = $this->common->encode($add_array['password']); |
|
| 1729 | - $last_id = $this->accounts_model->add_account($add_array); |
|
| 1730 | - if (isset($add_array['tax_id'])) { |
|
| 1731 | - foreach ($add_array['tax_id'] as $key => $val) { |
|
| 1732 | - $data1 = array( |
|
| 1733 | - 'accountid' => $last_id, |
|
| 1734 | - 'taxes_id' => $val, |
|
| 1735 | - ); |
|
| 1736 | - $this->accounts_model->add_account_tax($data1); |
|
| 1737 | - } |
|
| 1738 | - unset($add_array['tax_id']); |
|
| 1739 | - } |
|
| 1740 | - $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
|
| 1741 | - |
|
| 1742 | - $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_type) . ' added successfully!'); |
|
| 1743 | - redirect(base_url() . 'accounts/admin_list/'); |
|
| 1744 | - exit; |
|
| 1745 | - }$this->load->view('view_accounts_create', $data); |
|
| 1746 | - } |
|
| 1747 | - } |
|
| 1748 | - |
|
| 1749 | - function subadmin_add($type = "") { |
|
| 1750 | - $this->admin_add(4); |
|
| 1751 | - } |
|
| 1752 | - |
|
| 1753 | - function subadmin_edit($edit_id = '') { |
|
| 1754 | - $this->admin_edit($edit_id); |
|
| 1755 | - } |
|
| 1756 | - |
|
| 1757 | - function subadmin_save() { |
|
| 1758 | - $add_array = $this->input->post(); |
|
| 1759 | - $this->admin_save($add_array); |
|
| 1760 | - } |
|
| 1761 | - |
|
| 1762 | - function chargelist_json($accountid) { |
|
| 1763 | - $json_data = array(); |
|
| 1764 | - $sweeplist = $this->common_model->get_sweep_list(); |
|
| 1765 | - |
|
| 1766 | - $select = "charges.description,charges.charge,charges.sweep"; |
|
| 1767 | - $table = "charges"; |
|
| 1768 | - $jionTable = array('charge_to_account', 'accounts'); |
|
| 1769 | - $jionCondition = array('charges.id = charge_to_account.charge_id', 'accounts.number = charge_to_account.cardnum'); |
|
| 1770 | - $type = array('left', 'inner'); |
|
| 1771 | - $where = array('accounts.accountid' => $accountid); |
|
| 1772 | - $order_type = 'charges.id'; |
|
| 1773 | - $order_by = "ASC"; |
|
| 1774 | - |
|
| 1775 | - $account_charge_count = $this->db_model->getCountWithJion($table, $select, $where, $jionTable, $jionCondition, $type); |
|
| 1776 | - |
|
| 1777 | - $count_all = $account_charge_count; |
|
| 1778 | - $config['total_rows'] = $count_all; |
|
| 1779 | - $config['per_page'] = $_GET['rp']; |
|
| 1780 | - |
|
| 1781 | - $page_no = $_GET['page']; |
|
| 1782 | - $json_data['page'] = $page_no; |
|
| 1783 | - |
|
| 1784 | - $json_data['total'] = $config['total_rows']; |
|
| 1785 | - $perpage = $config['per_page']; |
|
| 1786 | - $start = ($page_no - 1) * $perpage; |
|
| 1787 | - if ($start < 0) |
|
| 1788 | - $start = 0; |
|
| 1789 | - |
|
| 1790 | - $account_charge_list = $this->db_model->getAllJionQuery($table, $select, $where, $jionTable, $jionCondition, $type, $perpage, $start, $order_by, $order_type, ""); |
|
| 1791 | - if ($account_charge_list->num_rows > 0) { |
|
| 1792 | - foreach ($account_charge_list->result() as $key => $charges_value) { |
|
| 1793 | - $json_data['rows'][] = array('cell' => array( |
|
| 1794 | - $charges_value->description, |
|
| 1795 | - $charges_value->charge, |
|
| 1796 | - $sweeplist[$charges_value->sweep] |
|
| 1797 | - )); |
|
| 1798 | - } |
|
| 1799 | - } |
|
| 1800 | - echo json_encode($json_data); |
|
| 1801 | - } |
|
| 1802 | - |
|
| 1803 | - function admin_list() { |
|
| 1804 | - $data['username'] = $this->session->userdata('user_name'); |
|
| 1805 | - $data['page_title'] = 'Admins'; |
|
| 1806 | - $data['search_flag'] = true; |
|
| 1807 | - $data['cur_menu_no'] = 1; |
|
| 1808 | - $this->session->set_userdata('advance_search', 0); |
|
| 1809 | - $data['grid_fields'] = $this->accounts_form->build_account_list_for_admin(); |
|
| 1810 | - $data["grid_buttons"] = $this->accounts_form->build_grid_buttons_admin(); |
|
| 1811 | - $data['form_search'] = $this->form->build_serach_form($this->accounts_form->get_admin_search_form()); |
|
| 1812 | - $this->load->view('view_accounts_list', $data); |
|
| 1813 | - } |
|
| 1814 | - |
|
| 1815 | - /** |
|
| 1816 | - * -------Here we write code for controller accounts functions account_list------ |
|
| 1817 | - * Listing of Accounts table data through php function json_encode |
|
| 1818 | - */ |
|
| 1819 | - function admin_list_json() { |
|
| 1820 | - $json_data = array(); |
|
| 1821 | - $account_data = $this->session->userdata("accountinfo"); |
|
| 1822 | - $reseller_id = $account_data['type'] == 1 ? $account_data['id'] : 0; |
|
| 1823 | - $count_all = $this->accounts_model->get_admin_Account_list(false, '', '', $reseller_id); |
|
| 1824 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 1825 | - $json_data = $paging_data["json_paging"]; |
|
| 1826 | - |
|
| 1827 | - $query = $this->accounts_model->get_admin_Account_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $reseller_id); |
|
| 1828 | - $grid_fields = json_decode($this->accounts_form->build_account_list_for_admin()); |
|
| 1829 | - $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
| 1830 | - |
|
| 1831 | - echo json_encode($json_data); |
|
| 1832 | - } |
|
| 1833 | - |
|
| 1834 | - /** |
|
| 1697 | + $add_array['password'] = $this->common->encode($add_array['password']); |
|
| 1698 | + /* * ****************** */ |
|
| 1699 | + $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
|
| 1700 | + $query = $this->accounts_model->remove_all_account_tax($add_array['id']); |
|
| 1701 | + if (isset($add_array['tax_id'])) { |
|
| 1702 | + foreach ($add_array['tax_id'] as $key => $val) { |
|
| 1703 | + $data1 = array( |
|
| 1704 | + 'accountid' => $add_array['id'], |
|
| 1705 | + 'taxes_id' => $val, |
|
| 1706 | + ); |
|
| 1707 | + $this->accounts_model->add_account_tax($data1); |
|
| 1708 | + } |
|
| 1709 | + unset($add_array['tax_id']); |
|
| 1710 | + } |
|
| 1711 | + unset($add_array['number']); |
|
| 1712 | + $this->accounts_model->edit_account($add_array, $add_array['id']); |
|
| 1713 | + if ($add_array['id'] == $accountinfo['id']) { |
|
| 1714 | + $result = $this->db->get_where('accounts', array('id' => $add_array['id'])); |
|
| 1715 | + $result = $result->result_array(); |
|
| 1716 | + $this->session->set_userdata('accountinfo', $result[0]); |
|
| 1717 | + } |
|
| 1718 | + $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_type) . ' updated successfully!'); |
|
| 1719 | + redirect(base_url() . 'accounts/admin_list/'); |
|
| 1720 | + exit; |
|
| 1721 | + } |
|
| 1722 | + $this->load->view('view_admin_details', $data); |
|
| 1723 | + } else { |
|
| 1724 | + $data['page_title'] = 'Create ' . ucfirst($entity_type); |
|
| 1725 | + if ($this->form_validation->run() == FALSE) { |
|
| 1726 | + $data['validation_errors'] = validation_errors(); |
|
| 1727 | + } else { |
|
| 1728 | + $add_array['password'] = $this->common->encode($add_array['password']); |
|
| 1729 | + $last_id = $this->accounts_model->add_account($add_array); |
|
| 1730 | + if (isset($add_array['tax_id'])) { |
|
| 1731 | + foreach ($add_array['tax_id'] as $key => $val) { |
|
| 1732 | + $data1 = array( |
|
| 1733 | + 'accountid' => $last_id, |
|
| 1734 | + 'taxes_id' => $val, |
|
| 1735 | + ); |
|
| 1736 | + $this->accounts_model->add_account_tax($data1); |
|
| 1737 | + } |
|
| 1738 | + unset($add_array['tax_id']); |
|
| 1739 | + } |
|
| 1740 | + $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
|
| 1741 | + |
|
| 1742 | + $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_type) . ' added successfully!'); |
|
| 1743 | + redirect(base_url() . 'accounts/admin_list/'); |
|
| 1744 | + exit; |
|
| 1745 | + }$this->load->view('view_accounts_create', $data); |
|
| 1746 | + } |
|
| 1747 | + } |
|
| 1748 | + |
|
| 1749 | + function subadmin_add($type = "") { |
|
| 1750 | + $this->admin_add(4); |
|
| 1751 | + } |
|
| 1752 | + |
|
| 1753 | + function subadmin_edit($edit_id = '') { |
|
| 1754 | + $this->admin_edit($edit_id); |
|
| 1755 | + } |
|
| 1756 | + |
|
| 1757 | + function subadmin_save() { |
|
| 1758 | + $add_array = $this->input->post(); |
|
| 1759 | + $this->admin_save($add_array); |
|
| 1760 | + } |
|
| 1761 | + |
|
| 1762 | + function chargelist_json($accountid) { |
|
| 1763 | + $json_data = array(); |
|
| 1764 | + $sweeplist = $this->common_model->get_sweep_list(); |
|
| 1765 | + |
|
| 1766 | + $select = "charges.description,charges.charge,charges.sweep"; |
|
| 1767 | + $table = "charges"; |
|
| 1768 | + $jionTable = array('charge_to_account', 'accounts'); |
|
| 1769 | + $jionCondition = array('charges.id = charge_to_account.charge_id', 'accounts.number = charge_to_account.cardnum'); |
|
| 1770 | + $type = array('left', 'inner'); |
|
| 1771 | + $where = array('accounts.accountid' => $accountid); |
|
| 1772 | + $order_type = 'charges.id'; |
|
| 1773 | + $order_by = "ASC"; |
|
| 1774 | + |
|
| 1775 | + $account_charge_count = $this->db_model->getCountWithJion($table, $select, $where, $jionTable, $jionCondition, $type); |
|
| 1776 | + |
|
| 1777 | + $count_all = $account_charge_count; |
|
| 1778 | + $config['total_rows'] = $count_all; |
|
| 1779 | + $config['per_page'] = $_GET['rp']; |
|
| 1780 | + |
|
| 1781 | + $page_no = $_GET['page']; |
|
| 1782 | + $json_data['page'] = $page_no; |
|
| 1783 | + |
|
| 1784 | + $json_data['total'] = $config['total_rows']; |
|
| 1785 | + $perpage = $config['per_page']; |
|
| 1786 | + $start = ($page_no - 1) * $perpage; |
|
| 1787 | + if ($start < 0) |
|
| 1788 | + $start = 0; |
|
| 1789 | + |
|
| 1790 | + $account_charge_list = $this->db_model->getAllJionQuery($table, $select, $where, $jionTable, $jionCondition, $type, $perpage, $start, $order_by, $order_type, ""); |
|
| 1791 | + if ($account_charge_list->num_rows > 0) { |
|
| 1792 | + foreach ($account_charge_list->result() as $key => $charges_value) { |
|
| 1793 | + $json_data['rows'][] = array('cell' => array( |
|
| 1794 | + $charges_value->description, |
|
| 1795 | + $charges_value->charge, |
|
| 1796 | + $sweeplist[$charges_value->sweep] |
|
| 1797 | + )); |
|
| 1798 | + } |
|
| 1799 | + } |
|
| 1800 | + echo json_encode($json_data); |
|
| 1801 | + } |
|
| 1802 | + |
|
| 1803 | + function admin_list() { |
|
| 1804 | + $data['username'] = $this->session->userdata('user_name'); |
|
| 1805 | + $data['page_title'] = 'Admins'; |
|
| 1806 | + $data['search_flag'] = true; |
|
| 1807 | + $data['cur_menu_no'] = 1; |
|
| 1808 | + $this->session->set_userdata('advance_search', 0); |
|
| 1809 | + $data['grid_fields'] = $this->accounts_form->build_account_list_for_admin(); |
|
| 1810 | + $data["grid_buttons"] = $this->accounts_form->build_grid_buttons_admin(); |
|
| 1811 | + $data['form_search'] = $this->form->build_serach_form($this->accounts_form->get_admin_search_form()); |
|
| 1812 | + $this->load->view('view_accounts_list', $data); |
|
| 1813 | + } |
|
| 1814 | + |
|
| 1815 | + /** |
|
| 1816 | + * -------Here we write code for controller accounts functions account_list------ |
|
| 1817 | + * Listing of Accounts table data through php function json_encode |
|
| 1818 | + */ |
|
| 1819 | + function admin_list_json() { |
|
| 1820 | + $json_data = array(); |
|
| 1821 | + $account_data = $this->session->userdata("accountinfo"); |
|
| 1822 | + $reseller_id = $account_data['type'] == 1 ? $account_data['id'] : 0; |
|
| 1823 | + $count_all = $this->accounts_model->get_admin_Account_list(false, '', '', $reseller_id); |
|
| 1824 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 1825 | + $json_data = $paging_data["json_paging"]; |
|
| 1826 | + |
|
| 1827 | + $query = $this->accounts_model->get_admin_Account_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $reseller_id); |
|
| 1828 | + $grid_fields = json_decode($this->accounts_form->build_account_list_for_admin()); |
|
| 1829 | + $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
| 1830 | + |
|
| 1831 | + echo json_encode($json_data); |
|
| 1832 | + } |
|
| 1833 | + |
|
| 1834 | + /** |
|
| 1835 | 1835 | ASTPP 3.0 |
| 1836 | 1836 | Customer Batch Update. |
| 1837 | - * */ |
|
| 1838 | - function customer_batch_update() { |
|
| 1839 | - $batch_update_arr = $this->input->post(); |
|
| 1840 | - $result = $this->accounts_model->customer_rates_batch_update($batch_update_arr); |
|
| 1841 | - echo json_encode(array("SUCCESS" => "Customer batch updated successfully!")); |
|
| 1842 | - exit; |
|
| 1843 | - } |
|
| 1844 | - |
|
| 1845 | - /* * ********************************************************************* */ |
|
| 1846 | - |
|
| 1847 | - function reseller_list() { |
|
| 1848 | - $data['username'] = $this->session->userdata('user_name'); |
|
| 1849 | - $data['page_title'] = 'Resellers'; |
|
| 1850 | - $data['search_flag'] = true; |
|
| 1851 | - /** |
|
| 1837 | + * */ |
|
| 1838 | + function customer_batch_update() { |
|
| 1839 | + $batch_update_arr = $this->input->post(); |
|
| 1840 | + $result = $this->accounts_model->customer_rates_batch_update($batch_update_arr); |
|
| 1841 | + echo json_encode(array("SUCCESS" => "Customer batch updated successfully!")); |
|
| 1842 | + exit; |
|
| 1843 | + } |
|
| 1844 | + |
|
| 1845 | + /* * ********************************************************************* */ |
|
| 1846 | + |
|
| 1847 | + function reseller_list() { |
|
| 1848 | + $data['username'] = $this->session->userdata('user_name'); |
|
| 1849 | + $data['page_title'] = 'Resellers'; |
|
| 1850 | + $data['search_flag'] = true; |
|
| 1851 | + /** |
|
| 1852 | 1852 | ASTPP 3.0 |
| 1853 | 1853 | Reseller Batch Update |
| 1854 | - * */ |
|
| 1855 | - $data['batch_update_flag'] = true; |
|
| 1856 | - /* * *************************************** */ |
|
| 1857 | - $this->session->set_userdata('advance_search', 0); |
|
| 1858 | - $data['grid_fields'] = $this->accounts_form->build_account_list_for_reseller(); |
|
| 1859 | - $data["grid_buttons"] = $this->accounts_form->build_grid_buttons_reseller(); |
|
| 1860 | - $data['form_search'] = $this->form->build_serach_form($this->accounts_form->get_reseller_search_form()); |
|
| 1861 | - $data['form_batch_update'] = $this->form->build_batchupdate_form($this->accounts_form->reseller_batch_update_form()); |
|
| 1862 | - /* * ************************************************************************************************************ */ |
|
| 1863 | - $this->load->view('view_accounts_list', $data); |
|
| 1864 | - } |
|
| 1865 | - |
|
| 1866 | - /** |
|
| 1867 | - * -------Here we write code for controller accounts functions account_list------ |
|
| 1868 | - * Listing of Accounts table data through php function json_encode |
|
| 1869 | - */ |
|
| 1870 | - function reseller_list_json() { |
|
| 1871 | - $json_data = array(); |
|
| 1872 | - $count_all = $this->accounts_model->get_reseller_Account_list(false); |
|
| 1873 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 1874 | - $json_data = $paging_data["json_paging"]; |
|
| 1875 | - |
|
| 1876 | - $query = $this->accounts_model->get_reseller_Account_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
| 1877 | - $grid_fields = json_decode($this->accounts_form->build_account_list_for_reseller()); |
|
| 1878 | - $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
| 1879 | - |
|
| 1880 | - echo json_encode($json_data); |
|
| 1881 | - } |
|
| 1882 | - |
|
| 1883 | - function reseller_list_search() { |
|
| 1884 | - $ajax_search = $this->input->post('ajax_search', 0); |
|
| 1885 | - if ($this->input->post('advance_search', TRUE) == 1) { |
|
| 1886 | - $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
| 1887 | - $action = $this->input->post(); |
|
| 1888 | - unset($action['action']); |
|
| 1889 | - unset($action['advance_search']); |
|
| 1890 | - if (isset($action['balance']['balance']) && $action['balance']['balance'] != '') { |
|
| 1891 | - $action['balance']['balance'] = $this->common_model->add_calculate_currency($action['balance']['balance'], "", '', true, false); |
|
| 1892 | - } |
|
| 1893 | - if (isset($action['credit_limit']['credit_limit']) && $action['credit_limit']['credit_limit'] != '') { |
|
| 1894 | - $action['credit_limit']['credit_limit'] = $this->common_model->add_calculate_currency($action['credit_limit']['credit_limit'], "", '',true, false); |
|
| 1895 | - } |
|
| 1896 | - $this->session->set_userdata('reseller_list_search', $action); |
|
| 1897 | - } |
|
| 1898 | - if (@$ajax_search != 1) { |
|
| 1899 | - redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1900 | - } |
|
| 1901 | - } |
|
| 1902 | - |
|
| 1903 | - function reseller_batch_update() { |
|
| 1904 | - $batch_update_arr = $this->input->post(); |
|
| 1905 | - $result = $this->accounts_model->reseller_rates_batch_update($batch_update_arr); |
|
| 1906 | - echo json_encode(array("SUCCESS" => "Reseller batch updated successfully!")); |
|
| 1907 | - exit; |
|
| 1908 | - } |
|
| 1909 | - |
|
| 1910 | - function admin_list_clearsearchfilter() { |
|
| 1911 | - $this->session->set_userdata('advance_search', 0); |
|
| 1912 | - $this->session->set_userdata('admin_list_search', ""); |
|
| 1913 | - } |
|
| 1914 | - |
|
| 1915 | - function admin_list_search() { |
|
| 1916 | - $ajax_search = $this->input->post('ajax_search', 0); |
|
| 1917 | - if ($this->input->post('advance_search', TRUE) == 1) { |
|
| 1918 | - $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
| 1919 | - $action = $this->input->post(); |
|
| 1920 | - unset($action['action']); |
|
| 1921 | - unset($action['advance_search']); |
|
| 1922 | - $this->session->set_userdata('admin_list_search', $action); |
|
| 1923 | - } |
|
| 1924 | - if (@$ajax_search != 1) { |
|
| 1925 | - redirect(base_url() . 'accounts/admin_list/'); |
|
| 1926 | - } |
|
| 1927 | - } |
|
| 1928 | - |
|
| 1929 | - function reseller_list_clearsearchfilter() { |
|
| 1930 | - $this->session->set_userdata('advance_search', 0); |
|
| 1931 | - $this->session->set_userdata('reseller_list_search', ""); |
|
| 1932 | - } |
|
| 1933 | - |
|
| 1934 | - |
|
| 1935 | - function customer_delete($id) { |
|
| 1936 | - $this->common->customer_delete_dependencies($id); |
|
| 1937 | - $this->session->set_flashdata('astpp_notification', 'Customer removed successfully!'); |
|
| 1938 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1939 | - } |
|
| 1940 | - |
|
| 1941 | - function reseller_delete($id) { |
|
| 1942 | - $this->common->subreseller_list($id); |
|
| 1943 | - $this->session->set_flashdata('astpp_notification', 'Reseller removed successfully!'); |
|
| 1944 | - redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1945 | - } |
|
| 1946 | - |
|
| 1947 | - function free_customer_did($accountid) { |
|
| 1948 | - $this->db->where(array("accountid" => $accountid)); |
|
| 1949 | - $this->db->update("dids", array('accountid' => "0")); |
|
| 1950 | - return true; |
|
| 1951 | - } |
|
| 1952 | - |
|
| 1953 | - function free_ani_map($accountid) { |
|
| 1954 | - $this->db->where(array("accountid" => $accountid)); |
|
| 1955 | - $this->db->delete('ani_map'); |
|
| 1956 | - return true; |
|
| 1957 | - } |
|
| 1958 | - |
|
| 1959 | - function free_reseller_did($ids) { |
|
| 1960 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1961 | - $reseller_id = $accountinfo['type'] != 1 ? 0 : $accountinfo['id']; |
|
| 1962 | - $data = array('parent_id' => $reseller_id, 'accountid' => 0); |
|
| 1963 | - $where = "parent_id IN ($ids)"; |
|
| 1964 | - $this->db->where($where); |
|
| 1965 | - $this->db->update('dids', $data); |
|
| 1966 | - $where = "reseller_id IN ($ids)"; |
|
| 1967 | - $this->db->where($where); |
|
| 1968 | - $this->db->delete('reseller_pricing'); |
|
| 1969 | - return true; |
|
| 1970 | - } |
|
| 1971 | - |
|
| 1972 | - function provider_delete($id) { |
|
| 1973 | - $this->accounts_model->remove_customer($id); |
|
| 1974 | - $this->session->set_flashdata('astpp_notification', 'Provider removed successfully!'); |
|
| 1975 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1976 | - } |
|
| 1977 | - |
|
| 1978 | - function admin_delete($id) { |
|
| 1979 | - $this->accounts_model->remove_customer($id); |
|
| 1980 | - $this->session->set_flashdata('astpp_notification', 'Admin removed successfully!'); |
|
| 1981 | - redirect(base_url() . 'accounts/admin_list/'); |
|
| 1982 | - } |
|
| 1983 | - |
|
| 1984 | - function subadmin_delete($id) { |
|
| 1985 | - $this->accounts_model->remove_customer($id); |
|
| 1986 | - $this->session->set_flashdata('astpp_notification', 'Sub admin removed successfully!'); |
|
| 1987 | - redirect(base_url() . 'accounts/admin_list/'); |
|
| 1988 | - } |
|
| 1854 | + * */ |
|
| 1855 | + $data['batch_update_flag'] = true; |
|
| 1856 | + /* * *************************************** */ |
|
| 1857 | + $this->session->set_userdata('advance_search', 0); |
|
| 1858 | + $data['grid_fields'] = $this->accounts_form->build_account_list_for_reseller(); |
|
| 1859 | + $data["grid_buttons"] = $this->accounts_form->build_grid_buttons_reseller(); |
|
| 1860 | + $data['form_search'] = $this->form->build_serach_form($this->accounts_form->get_reseller_search_form()); |
|
| 1861 | + $data['form_batch_update'] = $this->form->build_batchupdate_form($this->accounts_form->reseller_batch_update_form()); |
|
| 1862 | + /* * ************************************************************************************************************ */ |
|
| 1863 | + $this->load->view('view_accounts_list', $data); |
|
| 1864 | + } |
|
| 1865 | + |
|
| 1866 | + /** |
|
| 1867 | + * -------Here we write code for controller accounts functions account_list------ |
|
| 1868 | + * Listing of Accounts table data through php function json_encode |
|
| 1869 | + */ |
|
| 1870 | + function reseller_list_json() { |
|
| 1871 | + $json_data = array(); |
|
| 1872 | + $count_all = $this->accounts_model->get_reseller_Account_list(false); |
|
| 1873 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 1874 | + $json_data = $paging_data["json_paging"]; |
|
| 1875 | + |
|
| 1876 | + $query = $this->accounts_model->get_reseller_Account_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
| 1877 | + $grid_fields = json_decode($this->accounts_form->build_account_list_for_reseller()); |
|
| 1878 | + $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
| 1879 | + |
|
| 1880 | + echo json_encode($json_data); |
|
| 1881 | + } |
|
| 1882 | + |
|
| 1883 | + function reseller_list_search() { |
|
| 1884 | + $ajax_search = $this->input->post('ajax_search', 0); |
|
| 1885 | + if ($this->input->post('advance_search', TRUE) == 1) { |
|
| 1886 | + $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
| 1887 | + $action = $this->input->post(); |
|
| 1888 | + unset($action['action']); |
|
| 1889 | + unset($action['advance_search']); |
|
| 1890 | + if (isset($action['balance']['balance']) && $action['balance']['balance'] != '') { |
|
| 1891 | + $action['balance']['balance'] = $this->common_model->add_calculate_currency($action['balance']['balance'], "", '', true, false); |
|
| 1892 | + } |
|
| 1893 | + if (isset($action['credit_limit']['credit_limit']) && $action['credit_limit']['credit_limit'] != '') { |
|
| 1894 | + $action['credit_limit']['credit_limit'] = $this->common_model->add_calculate_currency($action['credit_limit']['credit_limit'], "", '',true, false); |
|
| 1895 | + } |
|
| 1896 | + $this->session->set_userdata('reseller_list_search', $action); |
|
| 1897 | + } |
|
| 1898 | + if (@$ajax_search != 1) { |
|
| 1899 | + redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1900 | + } |
|
| 1901 | + } |
|
| 1902 | + |
|
| 1903 | + function reseller_batch_update() { |
|
| 1904 | + $batch_update_arr = $this->input->post(); |
|
| 1905 | + $result = $this->accounts_model->reseller_rates_batch_update($batch_update_arr); |
|
| 1906 | + echo json_encode(array("SUCCESS" => "Reseller batch updated successfully!")); |
|
| 1907 | + exit; |
|
| 1908 | + } |
|
| 1909 | + |
|
| 1910 | + function admin_list_clearsearchfilter() { |
|
| 1911 | + $this->session->set_userdata('advance_search', 0); |
|
| 1912 | + $this->session->set_userdata('admin_list_search', ""); |
|
| 1913 | + } |
|
| 1914 | + |
|
| 1915 | + function admin_list_search() { |
|
| 1916 | + $ajax_search = $this->input->post('ajax_search', 0); |
|
| 1917 | + if ($this->input->post('advance_search', TRUE) == 1) { |
|
| 1918 | + $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
| 1919 | + $action = $this->input->post(); |
|
| 1920 | + unset($action['action']); |
|
| 1921 | + unset($action['advance_search']); |
|
| 1922 | + $this->session->set_userdata('admin_list_search', $action); |
|
| 1923 | + } |
|
| 1924 | + if (@$ajax_search != 1) { |
|
| 1925 | + redirect(base_url() . 'accounts/admin_list/'); |
|
| 1926 | + } |
|
| 1927 | + } |
|
| 1928 | + |
|
| 1929 | + function reseller_list_clearsearchfilter() { |
|
| 1930 | + $this->session->set_userdata('advance_search', 0); |
|
| 1931 | + $this->session->set_userdata('reseller_list_search', ""); |
|
| 1932 | + } |
|
| 1933 | + |
|
| 1934 | + |
|
| 1935 | + function customer_delete($id) { |
|
| 1936 | + $this->common->customer_delete_dependencies($id); |
|
| 1937 | + $this->session->set_flashdata('astpp_notification', 'Customer removed successfully!'); |
|
| 1938 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 1939 | + } |
|
| 1940 | + |
|
| 1941 | + function reseller_delete($id) { |
|
| 1942 | + $this->common->subreseller_list($id); |
|
| 1943 | + $this->session->set_flashdata('astpp_notification', 'Reseller removed successfully!'); |
|
| 1944 | + redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1945 | + } |
|
| 1946 | + |
|
| 1947 | + function free_customer_did($accountid) { |
|
| 1948 | + $this->db->where(array("accountid" => $accountid)); |
|
| 1949 | + $this->db->update("dids", array('accountid' => "0")); |
|
| 1950 | + return true; |
|
| 1951 | + } |
|
| 1952 | + |
|
| 1953 | + function free_ani_map($accountid) { |
|
| 1954 | + $this->db->where(array("accountid" => $accountid)); |
|
| 1955 | + $this->db->delete('ani_map'); |
|
| 1956 | + return true; |
|
| 1957 | + } |
|
| 1958 | + |
|
| 1959 | + function free_reseller_did($ids) { |
|
| 1960 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 1961 | + $reseller_id = $accountinfo['type'] != 1 ? 0 : $accountinfo['id']; |
|
| 1962 | + $data = array('parent_id' => $reseller_id, 'accountid' => 0); |
|
| 1963 | + $where = "parent_id IN ($ids)"; |
|
| 1964 | + $this->db->where($where); |
|
| 1965 | + $this->db->update('dids', $data); |
|
| 1966 | + $where = "reseller_id IN ($ids)"; |
|
| 1967 | + $this->db->where($where); |
|
| 1968 | + $this->db->delete('reseller_pricing'); |
|
| 1969 | + return true; |
|
| 1970 | + } |
|
| 1971 | + |
|
| 1972 | + function provider_delete($id) { |
|
| 1973 | + $this->accounts_model->remove_customer($id); |
|
| 1974 | + $this->session->set_flashdata('astpp_notification', 'Provider removed successfully!'); |
|
| 1975 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 1976 | + } |
|
| 1977 | + |
|
| 1978 | + function admin_delete($id) { |
|
| 1979 | + $this->accounts_model->remove_customer($id); |
|
| 1980 | + $this->session->set_flashdata('astpp_notification', 'Admin removed successfully!'); |
|
| 1981 | + redirect(base_url() . 'accounts/admin_list/'); |
|
| 1982 | + } |
|
| 1983 | + |
|
| 1984 | + function subadmin_delete($id) { |
|
| 1985 | + $this->accounts_model->remove_customer($id); |
|
| 1986 | + $this->session->set_flashdata('astpp_notification', 'Sub admin removed successfully!'); |
|
| 1987 | + redirect(base_url() . 'accounts/admin_list/'); |
|
| 1988 | + } |
|
| 1989 | 1989 | |
| 1990 | - function reseller_details_json($module, $accountid) { |
|
| 1991 | - |
|
| 1992 | - if ($module == "did") { |
|
| 1993 | - $this->load->module('did/did'); |
|
| 1994 | - $this->did->reseller_did($accountid, "reseller"); |
|
| 1995 | - } |
|
| 1996 | - if ($module == "invoices") { |
|
| 1997 | - $this->load->module('invoices/invoices'); |
|
| 1998 | - $this->invoices->customer_invoices($accountid,"reseller"); |
|
| 1999 | - } |
|
| 2000 | - if ($module == "charges") { |
|
| 2001 | - $this->load->module('charges/charges'); |
|
| 2002 | - $this->charges->customer_charge_list($accountid, "reseller"); |
|
| 2003 | - } |
|
| 2004 | - if($module =='packages'){ |
|
| 1990 | + function reseller_details_json($module, $accountid) { |
|
| 1991 | + |
|
| 1992 | + if ($module == "did") { |
|
| 1993 | + $this->load->module('did/did'); |
|
| 1994 | + $this->did->reseller_did($accountid, "reseller"); |
|
| 1995 | + } |
|
| 1996 | + if ($module == "invoices") { |
|
| 1997 | + $this->load->module('invoices/invoices'); |
|
| 1998 | + $this->invoices->customer_invoices($accountid,"reseller"); |
|
| 1999 | + } |
|
| 2000 | + if ($module == "charges") { |
|
| 2001 | + $this->load->module('charges/charges'); |
|
| 2002 | + $this->charges->customer_charge_list($accountid, "reseller"); |
|
| 2003 | + } |
|
| 2004 | + if($module =='packages'){ |
|
| 2005 | 2005 | $this->load->module('package/package'); |
| 2006 | 2006 | $this->package->package_list_reseller($accountid, "reseller"); |
| 2007 | - } |
|
| 2008 | - } |
|
| 2009 | - |
|
| 2010 | - function provider_details_json($module, $accountid) { |
|
| 2011 | - if ($module == "invoices") { |
|
| 2012 | - $this->load->module('invoices/invoices'); |
|
| 2013 | - $this->invoices->customer_invoices($accountid); |
|
| 2014 | - } |
|
| 2015 | - } |
|
| 2016 | - |
|
| 2017 | - function customer_add_postcharges($accounttype, $accountid) { |
|
| 2018 | - $charge = $this->input->post("amount", true); |
|
| 2019 | - if ($charge != "") { |
|
| 2020 | - $charge = $this->common_model->add_calculate_currency($charge, "", '', false, false); |
|
| 2021 | - $date = date('Y-m-d H:i:s'); |
|
| 2022 | - $insert_arr = array("accountid" => $accountid, "description" => $this->input->post("desc", true), |
|
| 2023 | - "created_date" => $date, "debit" => $charge, "charge_type" => "post_charge"); |
|
| 2024 | - $this->db->insert("invoice_item", $insert_arr); |
|
| 2025 | - |
|
| 2026 | - $this->accounts_model->update_balance($charge, $accountid, "debit"); |
|
| 2027 | - redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#packages"); |
|
| 2028 | - } else { |
|
| 2029 | - redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#packages"); |
|
| 2030 | - } |
|
| 2031 | - } |
|
| 2032 | - |
|
| 2033 | - function reseller_did_action($action, $accountid, $accounttype, $did_id = "") { |
|
| 2034 | - if ($action == "add") { |
|
| 2035 | - $did_id = $this->input->post("free_did_list", true); |
|
| 2036 | - if ($did_id != "") { |
|
| 2037 | - $account_query = $this->db_model->getSelect("*", "accounts", array("id" => $accountid)); |
|
| 2038 | - |
|
| 2039 | - $account_arr = $account_query->result_array(); |
|
| 2040 | - $idofaccount = $accountid; |
|
| 2041 | - $this->db_model->update("dids", array("parent_id" => $accountid, 'assign_date' => gmdate('Y-m-d H:i:s')), array("id" => $did_id)); |
|
| 2042 | - $accountid = $idofaccount; |
|
| 2043 | - $this->load->module('did/did'); |
|
| 2044 | - $this->did->did_model->add_reseller_pricing($accountid, $did_id); |
|
| 2045 | - |
|
| 2046 | - $this->session->set_flashdata('astpp_errormsg', 'DID added successfully.'); |
|
| 2047 | - redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#did"); |
|
| 2048 | - } else { |
|
| 2049 | - redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#did"); |
|
| 2050 | - } |
|
| 2051 | - } |
|
| 2052 | - if ($action == "delete") { |
|
| 2053 | - $this->db->where('id', $did_id); |
|
| 2054 | - $this->db->select('note'); |
|
| 2055 | - $pricing_res = $this->db->get('reseller_pricing'); |
|
| 2056 | - if ($pricing_res->num_rows() > 0) { |
|
| 2057 | - $pricing_res = $pricing_res->result_array(); |
|
| 2058 | - $did_number = $pricing_res[0]['note']; |
|
| 2059 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 2060 | - if ($this->session->userdata['userlevel_logintype'] == -1) { |
|
| 2061 | - $parent_id = 0; |
|
| 2062 | - } else { |
|
| 2063 | - $parent_id = $this->session->userdata['accountinfo']['id']; |
|
| 2064 | - } |
|
| 2065 | - |
|
| 2066 | - $reseller_ids = $this->common->subreseller_list($accountinfo['id']); |
|
| 2067 | - $pricing_where = "parent_id = $parent_id AND note = $did_number"; |
|
| 2068 | - $this->db->where($pricing_where); |
|
| 2069 | - $this->db->delete('reseller_pricing'); |
|
| 2070 | - $dids_where = "parent_id IN ($reseller_ids) AND number = $did_number"; |
|
| 2071 | - $this->db->where($dids_where); |
|
| 2072 | - $data = array('accountid' => 0, 'parent_id' => $accountinfo['id']); |
|
| 2073 | - $this->db->update('dids', $data); |
|
| 2074 | - $this->session->set_flashdata('astpp_notification', 'DID removed successfully.'); |
|
| 2075 | - } else { |
|
| 2076 | - $this->session->set_flashdata('astpp_notification', 'DID already removed before.'); |
|
| 2077 | - } |
|
| 2078 | - redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#did"); |
|
| 2079 | - } |
|
| 2080 | - } |
|
| 2081 | - |
|
| 2082 | - function customer_selected_delete() { |
|
| 2083 | - $ids = $this->input->post("selected_ids", true); |
|
| 2084 | - $customer_ids=explode(",",$ids); |
|
| 2085 | - foreach($customer_ids as $customer_id){ |
|
| 2007 | + } |
|
| 2008 | + } |
|
| 2009 | + |
|
| 2010 | + function provider_details_json($module, $accountid) { |
|
| 2011 | + if ($module == "invoices") { |
|
| 2012 | + $this->load->module('invoices/invoices'); |
|
| 2013 | + $this->invoices->customer_invoices($accountid); |
|
| 2014 | + } |
|
| 2015 | + } |
|
| 2016 | + |
|
| 2017 | + function customer_add_postcharges($accounttype, $accountid) { |
|
| 2018 | + $charge = $this->input->post("amount", true); |
|
| 2019 | + if ($charge != "") { |
|
| 2020 | + $charge = $this->common_model->add_calculate_currency($charge, "", '', false, false); |
|
| 2021 | + $date = date('Y-m-d H:i:s'); |
|
| 2022 | + $insert_arr = array("accountid" => $accountid, "description" => $this->input->post("desc", true), |
|
| 2023 | + "created_date" => $date, "debit" => $charge, "charge_type" => "post_charge"); |
|
| 2024 | + $this->db->insert("invoice_item", $insert_arr); |
|
| 2025 | + |
|
| 2026 | + $this->accounts_model->update_balance($charge, $accountid, "debit"); |
|
| 2027 | + redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#packages"); |
|
| 2028 | + } else { |
|
| 2029 | + redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#packages"); |
|
| 2030 | + } |
|
| 2031 | + } |
|
| 2032 | + |
|
| 2033 | + function reseller_did_action($action, $accountid, $accounttype, $did_id = "") { |
|
| 2034 | + if ($action == "add") { |
|
| 2035 | + $did_id = $this->input->post("free_did_list", true); |
|
| 2036 | + if ($did_id != "") { |
|
| 2037 | + $account_query = $this->db_model->getSelect("*", "accounts", array("id" => $accountid)); |
|
| 2038 | + |
|
| 2039 | + $account_arr = $account_query->result_array(); |
|
| 2040 | + $idofaccount = $accountid; |
|
| 2041 | + $this->db_model->update("dids", array("parent_id" => $accountid, 'assign_date' => gmdate('Y-m-d H:i:s')), array("id" => $did_id)); |
|
| 2042 | + $accountid = $idofaccount; |
|
| 2043 | + $this->load->module('did/did'); |
|
| 2044 | + $this->did->did_model->add_reseller_pricing($accountid, $did_id); |
|
| 2045 | + |
|
| 2046 | + $this->session->set_flashdata('astpp_errormsg', 'DID added successfully.'); |
|
| 2047 | + redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#did"); |
|
| 2048 | + } else { |
|
| 2049 | + redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#did"); |
|
| 2050 | + } |
|
| 2051 | + } |
|
| 2052 | + if ($action == "delete") { |
|
| 2053 | + $this->db->where('id', $did_id); |
|
| 2054 | + $this->db->select('note'); |
|
| 2055 | + $pricing_res = $this->db->get('reseller_pricing'); |
|
| 2056 | + if ($pricing_res->num_rows() > 0) { |
|
| 2057 | + $pricing_res = $pricing_res->result_array(); |
|
| 2058 | + $did_number = $pricing_res[0]['note']; |
|
| 2059 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 2060 | + if ($this->session->userdata['userlevel_logintype'] == -1) { |
|
| 2061 | + $parent_id = 0; |
|
| 2062 | + } else { |
|
| 2063 | + $parent_id = $this->session->userdata['accountinfo']['id']; |
|
| 2064 | + } |
|
| 2065 | + |
|
| 2066 | + $reseller_ids = $this->common->subreseller_list($accountinfo['id']); |
|
| 2067 | + $pricing_where = "parent_id = $parent_id AND note = $did_number"; |
|
| 2068 | + $this->db->where($pricing_where); |
|
| 2069 | + $this->db->delete('reseller_pricing'); |
|
| 2070 | + $dids_where = "parent_id IN ($reseller_ids) AND number = $did_number"; |
|
| 2071 | + $this->db->where($dids_where); |
|
| 2072 | + $data = array('accountid' => 0, 'parent_id' => $accountinfo['id']); |
|
| 2073 | + $this->db->update('dids', $data); |
|
| 2074 | + $this->session->set_flashdata('astpp_notification', 'DID removed successfully.'); |
|
| 2075 | + } else { |
|
| 2076 | + $this->session->set_flashdata('astpp_notification', 'DID already removed before.'); |
|
| 2077 | + } |
|
| 2078 | + redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#did"); |
|
| 2079 | + } |
|
| 2080 | + } |
|
| 2081 | + |
|
| 2082 | + function customer_selected_delete() { |
|
| 2083 | + $ids = $this->input->post("selected_ids", true); |
|
| 2084 | + $customer_ids=explode(",",$ids); |
|
| 2085 | + foreach($customer_ids as $customer_id){ |
|
| 2086 | 2086 | $customer_id = str_replace("'", "", $customer_id); |
| 2087 | - $this->common->customer_delete_dependencies($customer_id); |
|
| 2088 | - } |
|
| 2089 | - echo TRUE; |
|
| 2090 | - } |
|
| 2091 | - |
|
| 2092 | - function reseller_selected_delete() { |
|
| 2093 | - $ids = $this->input->post("selected_ids", true); |
|
| 2094 | - $id_arr = explode(',', $ids); |
|
| 2095 | - foreach ($id_arr as $data) { |
|
| 2087 | + $this->common->customer_delete_dependencies($customer_id); |
|
| 2088 | + } |
|
| 2089 | + echo TRUE; |
|
| 2090 | + } |
|
| 2091 | + |
|
| 2092 | + function reseller_selected_delete() { |
|
| 2093 | + $ids = $this->input->post("selected_ids", true); |
|
| 2094 | + $id_arr = explode(',', $ids); |
|
| 2095 | + foreach ($id_arr as $data) { |
|
| 2096 | 2096 | $data = str_replace("'", "", $data); |
| 2097 | 2097 | $this->common->subreseller_list($data); |
| 2098 | - } |
|
| 2099 | - echo TRUE; |
|
| 2100 | - } |
|
| 2101 | - |
|
| 2102 | - function callshop_selected_delete() { |
|
| 2103 | - echo $this->delete_multiple(); |
|
| 2104 | - } |
|
| 2105 | - |
|
| 2106 | - function provider_selected_delete() { |
|
| 2107 | - echo $this->delete_multiple(); |
|
| 2108 | - } |
|
| 2109 | - |
|
| 2110 | - function subadmin_selected_delete() { |
|
| 2111 | - echo $this->delete_multiple(); |
|
| 2112 | - } |
|
| 2113 | - |
|
| 2114 | - function admin_selected_delete() { |
|
| 2115 | - echo $this->delete_multiple(); |
|
| 2116 | - } |
|
| 2117 | - |
|
| 2118 | - function delete_multiple() { |
|
| 2119 | - $ids = $this->input->post("selected_ids", true); |
|
| 2120 | - $where = "id IN ($ids)"; |
|
| 2121 | - $data = array('deleted' => 1); |
|
| 2122 | - $this->db->where($where); |
|
| 2123 | - $this->db->update("accounts", $data); |
|
| 2124 | - echo TRUE; |
|
| 2125 | - } |
|
| 2126 | - |
|
| 2127 | - function customer_account_taxes($action = false, $id = false) { |
|
| 2128 | - $data['username'] = $this->session->userdata('user_name'); |
|
| 2129 | - $data['page_title'] = 'Account Taxes'; |
|
| 2130 | - |
|
| 2131 | - if ($action == false) |
|
| 2132 | - $action = "list"; |
|
| 2133 | - |
|
| 2134 | - if ($action == 'list') { |
|
| 2135 | - $this->load->view('view_account_taxes_list', $data); |
|
| 2136 | - } elseif ($action == 'add') { |
|
| 2137 | - |
|
| 2138 | - if (($this->input->post())) { |
|
| 2139 | - $post_array = $this->input->post(); |
|
| 2140 | - $query = $this->accounts_model->remove_all_account_tax($post_array['account_id']); |
|
| 2141 | - |
|
| 2142 | - foreach ($post_array as $key => $value) { |
|
| 2143 | - $id = explode("_", $key); |
|
| 2144 | - if ($id[0] == 'tax') { |
|
| 2145 | - $data = array( |
|
| 2146 | - 'accountid' => $post_array['account_id'], |
|
| 2147 | - 'taxes_id' => $post_array[$key], |
|
| 2148 | - ); |
|
| 2149 | - $this->accounts_model->add_account_tax($data); |
|
| 2150 | - } |
|
| 2151 | - } |
|
| 2152 | - $this->session->set_flashdata('astpp_errormsg', 'Account tax added successfully!'); |
|
| 2153 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 2154 | - } |
|
| 2155 | - $data['id'] = array(); |
|
| 2156 | - $data['taxesList'] = $this->common_model->get_list_taxes(); |
|
| 2157 | - $this->load->view('view_accounting_taxes_add', $data); |
|
| 2158 | - } elseif ($action == 'edit') { |
|
| 2159 | - $taxes_id = $this->accounts_model->get_accounttax_by_id($id); |
|
| 2160 | - $account_num = $this->accounts_model->get_account_number($id); |
|
| 2161 | - $data['accountnum'] = $account_num['number']; |
|
| 2162 | - $data['account_id'] = $id; |
|
| 2163 | - for ($i = 0; $i < count($taxes_id); $i++) { |
|
| 2164 | - $tax_ids[] = $taxes_id[$i]['taxes_id']; |
|
| 2165 | - } |
|
| 2166 | - $data['tax_ids'] = $tax_ids; |
|
| 2167 | - |
|
| 2168 | - $data['tax_id'] = $taxes_id; |
|
| 2169 | - |
|
| 2170 | - if (($this->input->post())) { |
|
| 2171 | - $post_array = $this->input->post(); |
|
| 2172 | - $accountinfo = $this->accounts_model->get_account_by_number($post_array['account_id']); |
|
| 2173 | - $query = $this->accounts_model->remove_all_account_tax($post_array['account_id']); |
|
| 2174 | - foreach ($post_array as $key => $value) { |
|
| 2175 | - $id = explode("_", $key); |
|
| 2176 | - if ($id[0] == 'tax') { |
|
| 2177 | - $data = array( |
|
| 2178 | - 'accountid' => $post_array['account_id'], |
|
| 2179 | - 'taxes_id' => $post_array[$key], |
|
| 2180 | - ); |
|
| 2181 | - $this->accounts_model->add_account_tax($data); |
|
| 2182 | - } |
|
| 2183 | - } |
|
| 2184 | - if ($accountinfo['type'] == '0') { |
|
| 2185 | - $link = base_url() . '/accounts/customer_list/'; |
|
| 2186 | - } else { |
|
| 2187 | - $link = base_url() . '/accounts/reseller_list/'; |
|
| 2188 | - } |
|
| 2189 | - $this->session->set_flashdata('astpp_errormsg', 'Account tax added successfully!'); |
|
| 2190 | - redirect($link); |
|
| 2191 | - } |
|
| 2192 | - $data['taxesList'] = $this->common_model->get_list_taxes(); |
|
| 2193 | - $this->load->view('view_accounting_taxes_add', $data); |
|
| 2194 | - } elseif ($action == 'delete') { |
|
| 2195 | - $this->accounting_model->remove_account_tax($id); |
|
| 2196 | - $this->session->set_flashdata('astpp_notification', 'Account tax removed successfully!'); |
|
| 2197 | - redirect(base_url() . 'accounting/account_taxes/'); |
|
| 2198 | - } |
|
| 2199 | - } |
|
| 2200 | - |
|
| 2201 | - /** |
|
| 2202 | - * -------Here we write code for controller accounting functions vallid_account_tax------ |
|
| 2203 | - * here this function called by ajax form and vallidate the account number |
|
| 2204 | - * @$_POST['username']: Account Number |
|
| 2205 | - */ |
|
| 2206 | - function valid_account_tax() { |
|
| 2207 | - $tax_id = ''; |
|
| 2208 | - if (!empty($_POST['username'])) { |
|
| 2209 | - |
|
| 2210 | - $account_num = mysql_real_escape_string($_POST['username']); |
|
| 2211 | - $row = $this->accounts_model->check_account_num($account_num); |
|
| 2212 | - if (isset($row['accountid']) && $row['accountid'] != '') { |
|
| 2213 | - $taxes_id = $this->accounts_model->get_accounttax_by_id($row['accountid']); |
|
| 2214 | - if ($taxes_id) { |
|
| 2215 | - foreach ($taxes_id as $id) { |
|
| 2216 | - $tax_id.=$id['taxes_id'] . ","; |
|
| 2217 | - } |
|
| 2218 | - |
|
| 2219 | - $tax_id = rtrim($tax_id, ","); |
|
| 2220 | - echo $row['accountid'] . ',' . $tax_id; |
|
| 2221 | - } else { |
|
| 2222 | - echo $row['accountid']; |
|
| 2223 | - } |
|
| 2224 | - } |
|
| 2225 | - } |
|
| 2226 | - } |
|
| 2227 | - |
|
| 2228 | - function reseller_edit_account() { |
|
| 2229 | - $account_data = $this->session->userdata("accountinfo"); |
|
| 2230 | - |
|
| 2231 | - $add_array = $this->input->post(); |
|
| 2232 | - $data['form'] = $this->form->build_form($this->accounts_form->get_reseller_own_form_fields(), $add_array); |
|
| 2233 | - if ($add_array['id'] != '') { |
|
| 2234 | - $data['page_title'] = 'Edit Reseller'; |
|
| 2235 | - if ($this->form_validation->run() == FALSE) { |
|
| 2236 | - $data['validation_errors'] = validation_errors(); |
|
| 2237 | - } else { |
|
| 2238 | - $this->accounts_model->edit_account($add_array, $add_array['id']); |
|
| 2239 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 2240 | - if ($add_array['id'] == $accountinfo['id']) { |
|
| 2241 | - $result = $this->db->get_where('accounts', array('id' => $add_array['id'])); |
|
| 2242 | - $result = $result->result_array(); |
|
| 2243 | - $this->session->set_userdata('accountinfo', $result[0]); |
|
| 2244 | - } |
|
| 2245 | - $this->session->set_flashdata('astpp_errormsg', 'Reseller updated successfully!'); |
|
| 2246 | - redirect(base_url() . '/dashboard/'); |
|
| 2247 | - } |
|
| 2248 | - $this->load->view('view_reseller_edit_details_own', $data); |
|
| 2249 | - } else { |
|
| 2250 | - $data['page_title'] = 'Edit Reseller'; |
|
| 2251 | - $where = array('id' => $account_data["id"]); |
|
| 2252 | - $account = $this->db_model->getSelect("*", "accounts", $where); |
|
| 2253 | - $data["account_data"] = $account->result_array(); |
|
| 2254 | - foreach ($account->result_array() as $key => $value) { |
|
| 2255 | - $editable_data = $value; |
|
| 2256 | - } |
|
| 2257 | - $data['form'] = $this->form->build_form($this->accounts_form->get_reseller_own_form_fields(), $editable_data); |
|
| 2258 | - $this->load->view('view_reseller_edit_details_own', $data); |
|
| 2259 | - } |
|
| 2260 | - } |
|
| 2261 | - /** |
|
| 2262 | - * -------Here we write code for controller accounts functions add_callerid------ |
|
| 2263 | - * Add caller ids against account no |
|
| 2264 | - * @account_number: Account No |
|
| 2265 | - */ |
|
| 2266 | - function customer_animap_list($id = '') { |
|
| 2267 | - $data['animap_id'] = $id; |
|
| 2268 | - $data['username'] = $this->session->userdata('user_name'); |
|
| 2269 | - $data['page_title'] = "Caller Id List"; |
|
| 2270 | - $this->session->set_userdata('animap_search', 0); |
|
| 2271 | - $data['grid_fields'] = $this->accounts_form->build_animap_list(); |
|
| 2272 | - $data["grid_buttons"] = $this->accounts_form->build_grid_buttons_destination(); |
|
| 2273 | - $this->load->view('view_ani_map', $data); |
|
| 2274 | - } |
|
| 2275 | - |
|
| 2276 | - function customer_animap_list_json($id = '') { |
|
| 2277 | - $json_data = array(); |
|
| 2278 | - $count_all = $this->accounts_model->get_animap(false, '', '', $id); |
|
| 2279 | - $data['callingcard_id'] = $id; |
|
| 2280 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 2281 | - $json_data = $paging_data["json_paging"]; |
|
| 2282 | - $query = $this->accounts_model->get_animap(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $id); |
|
| 2283 | - $grid_fields = json_decode($this->accounts_form->build_animap_list()); |
|
| 2284 | - $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
| 2285 | - echo json_encode($json_data); |
|
| 2286 | - exit; |
|
| 2287 | - } |
|
| 2288 | - |
|
| 2289 | - function customer_animap_list_action($id = '') { |
|
| 2290 | - $add_array = $this->input->post(); |
|
| 2291 | - $add_array['id'] = trim($add_array['id']); |
|
| 2292 | - $add_array['number'] = trim($add_array['number']); |
|
| 2293 | - if (isset($add_array['id']) && $add_array['id'] != '') { |
|
| 2294 | - $add_array['id'] = trim($add_array['id']); |
|
| 2295 | - $id = $add_array['id']; |
|
| 2296 | - } |
|
| 2297 | - $where = array("number" => $add_array['number']); |
|
| 2298 | - $pro = $this->accounts_model->animap_authentication($where, $id); |
|
| 2299 | - if ($pro > 0) { |
|
| 2300 | - echo "2"; |
|
| 2301 | - exit; |
|
| 2302 | - } |
|
| 2303 | - if (isset($add_array['number']) && !empty($add_array['number'])) { |
|
| 2304 | - if (isset($add_array['id']) && $add_array['id'] != '') { |
|
| 2305 | - unset($add_array['animap_id']); |
|
| 2306 | - $response = $this->accounts_model->edit_animap($add_array, $add_array['id']); |
|
| 2307 | - echo "1"; |
|
| 2308 | - exit; |
|
| 2309 | - } else { |
|
| 2310 | - $add_array['context'] = "default"; |
|
| 2311 | - unset($add_array['animap_id']); |
|
| 2312 | - $add_array['accountid'] = $id; |
|
| 2313 | - $response = $this->accounts_model->add_animap($add_array); |
|
| 2314 | - echo "0"; |
|
| 2315 | - exit; |
|
| 2316 | - } |
|
| 2317 | - } else { |
|
| 2318 | - echo "3"; |
|
| 2319 | - exit; |
|
| 2320 | - } |
|
| 2321 | - } |
|
| 2322 | - |
|
| 2323 | - function customer_animap_list_remove($id) { |
|
| 2324 | - $this->accounts_model->remove_ani_map($id); |
|
| 2325 | - echo "1"; |
|
| 2326 | - exit; |
|
| 2327 | - } |
|
| 2328 | - |
|
| 2329 | - function customer_animap_list_edit($id) { |
|
| 2330 | - $where = array('id' => $id); |
|
| 2331 | - $account = $this->db_model->getSelect("*", "ani_map", $where); |
|
| 2332 | - foreach ($account->result_array() as $key => $value) { |
|
| 2333 | - $edit_data = $value; |
|
| 2334 | - } |
|
| 2335 | - $value_edit = ''; |
|
| 2336 | - foreach ($edit_data as $key => $value) { |
|
| 2337 | - $value_edit.=$value . ","; |
|
| 2338 | - } |
|
| 2339 | - echo rtrim($value_edit, ','); |
|
| 2340 | - exit; |
|
| 2341 | - } |
|
| 2342 | - |
|
| 2343 | - function provider_edit_account() { |
|
| 2344 | - $this->customer_edit_account(); |
|
| 2345 | - } |
|
| 2346 | - |
|
| 2347 | - function customer_show_password($id) { |
|
| 2348 | - $account = $this->db_model->getSelect("password", "accounts", array('id' => $id)); |
|
| 2349 | - $account_data = $account->result_array(); |
|
| 2350 | - $password = $this->common->decode($account_data[0]['password']); |
|
| 2351 | - echo $password; |
|
| 2352 | - } |
|
| 2353 | - |
|
| 2354 | - function reseller_export_cdr_xls() { |
|
| 2098 | + } |
|
| 2099 | + echo TRUE; |
|
| 2100 | + } |
|
| 2101 | + |
|
| 2102 | + function callshop_selected_delete() { |
|
| 2103 | + echo $this->delete_multiple(); |
|
| 2104 | + } |
|
| 2105 | + |
|
| 2106 | + function provider_selected_delete() { |
|
| 2107 | + echo $this->delete_multiple(); |
|
| 2108 | + } |
|
| 2109 | + |
|
| 2110 | + function subadmin_selected_delete() { |
|
| 2111 | + echo $this->delete_multiple(); |
|
| 2112 | + } |
|
| 2113 | + |
|
| 2114 | + function admin_selected_delete() { |
|
| 2115 | + echo $this->delete_multiple(); |
|
| 2116 | + } |
|
| 2117 | + |
|
| 2118 | + function delete_multiple() { |
|
| 2119 | + $ids = $this->input->post("selected_ids", true); |
|
| 2120 | + $where = "id IN ($ids)"; |
|
| 2121 | + $data = array('deleted' => 1); |
|
| 2122 | + $this->db->where($where); |
|
| 2123 | + $this->db->update("accounts", $data); |
|
| 2124 | + echo TRUE; |
|
| 2125 | + } |
|
| 2126 | + |
|
| 2127 | + function customer_account_taxes($action = false, $id = false) { |
|
| 2128 | + $data['username'] = $this->session->userdata('user_name'); |
|
| 2129 | + $data['page_title'] = 'Account Taxes'; |
|
| 2130 | + |
|
| 2131 | + if ($action == false) |
|
| 2132 | + $action = "list"; |
|
| 2133 | + |
|
| 2134 | + if ($action == 'list') { |
|
| 2135 | + $this->load->view('view_account_taxes_list', $data); |
|
| 2136 | + } elseif ($action == 'add') { |
|
| 2137 | + |
|
| 2138 | + if (($this->input->post())) { |
|
| 2139 | + $post_array = $this->input->post(); |
|
| 2140 | + $query = $this->accounts_model->remove_all_account_tax($post_array['account_id']); |
|
| 2141 | + |
|
| 2142 | + foreach ($post_array as $key => $value) { |
|
| 2143 | + $id = explode("_", $key); |
|
| 2144 | + if ($id[0] == 'tax') { |
|
| 2145 | + $data = array( |
|
| 2146 | + 'accountid' => $post_array['account_id'], |
|
| 2147 | + 'taxes_id' => $post_array[$key], |
|
| 2148 | + ); |
|
| 2149 | + $this->accounts_model->add_account_tax($data); |
|
| 2150 | + } |
|
| 2151 | + } |
|
| 2152 | + $this->session->set_flashdata('astpp_errormsg', 'Account tax added successfully!'); |
|
| 2153 | + redirect(base_url() . 'accounts/customer_list/'); |
|
| 2154 | + } |
|
| 2155 | + $data['id'] = array(); |
|
| 2156 | + $data['taxesList'] = $this->common_model->get_list_taxes(); |
|
| 2157 | + $this->load->view('view_accounting_taxes_add', $data); |
|
| 2158 | + } elseif ($action == 'edit') { |
|
| 2159 | + $taxes_id = $this->accounts_model->get_accounttax_by_id($id); |
|
| 2160 | + $account_num = $this->accounts_model->get_account_number($id); |
|
| 2161 | + $data['accountnum'] = $account_num['number']; |
|
| 2162 | + $data['account_id'] = $id; |
|
| 2163 | + for ($i = 0; $i < count($taxes_id); $i++) { |
|
| 2164 | + $tax_ids[] = $taxes_id[$i]['taxes_id']; |
|
| 2165 | + } |
|
| 2166 | + $data['tax_ids'] = $tax_ids; |
|
| 2167 | + |
|
| 2168 | + $data['tax_id'] = $taxes_id; |
|
| 2169 | + |
|
| 2170 | + if (($this->input->post())) { |
|
| 2171 | + $post_array = $this->input->post(); |
|
| 2172 | + $accountinfo = $this->accounts_model->get_account_by_number($post_array['account_id']); |
|
| 2173 | + $query = $this->accounts_model->remove_all_account_tax($post_array['account_id']); |
|
| 2174 | + foreach ($post_array as $key => $value) { |
|
| 2175 | + $id = explode("_", $key); |
|
| 2176 | + if ($id[0] == 'tax') { |
|
| 2177 | + $data = array( |
|
| 2178 | + 'accountid' => $post_array['account_id'], |
|
| 2179 | + 'taxes_id' => $post_array[$key], |
|
| 2180 | + ); |
|
| 2181 | + $this->accounts_model->add_account_tax($data); |
|
| 2182 | + } |
|
| 2183 | + } |
|
| 2184 | + if ($accountinfo['type'] == '0') { |
|
| 2185 | + $link = base_url() . '/accounts/customer_list/'; |
|
| 2186 | + } else { |
|
| 2187 | + $link = base_url() . '/accounts/reseller_list/'; |
|
| 2188 | + } |
|
| 2189 | + $this->session->set_flashdata('astpp_errormsg', 'Account tax added successfully!'); |
|
| 2190 | + redirect($link); |
|
| 2191 | + } |
|
| 2192 | + $data['taxesList'] = $this->common_model->get_list_taxes(); |
|
| 2193 | + $this->load->view('view_accounting_taxes_add', $data); |
|
| 2194 | + } elseif ($action == 'delete') { |
|
| 2195 | + $this->accounting_model->remove_account_tax($id); |
|
| 2196 | + $this->session->set_flashdata('astpp_notification', 'Account tax removed successfully!'); |
|
| 2197 | + redirect(base_url() . 'accounting/account_taxes/'); |
|
| 2198 | + } |
|
| 2199 | + } |
|
| 2200 | + |
|
| 2201 | + /** |
|
| 2202 | + * -------Here we write code for controller accounting functions vallid_account_tax------ |
|
| 2203 | + * here this function called by ajax form and vallidate the account number |
|
| 2204 | + * @$_POST['username']: Account Number |
|
| 2205 | + */ |
|
| 2206 | + function valid_account_tax() { |
|
| 2207 | + $tax_id = ''; |
|
| 2208 | + if (!empty($_POST['username'])) { |
|
| 2209 | + |
|
| 2210 | + $account_num = mysql_real_escape_string($_POST['username']); |
|
| 2211 | + $row = $this->accounts_model->check_account_num($account_num); |
|
| 2212 | + if (isset($row['accountid']) && $row['accountid'] != '') { |
|
| 2213 | + $taxes_id = $this->accounts_model->get_accounttax_by_id($row['accountid']); |
|
| 2214 | + if ($taxes_id) { |
|
| 2215 | + foreach ($taxes_id as $id) { |
|
| 2216 | + $tax_id.=$id['taxes_id'] . ","; |
|
| 2217 | + } |
|
| 2218 | + |
|
| 2219 | + $tax_id = rtrim($tax_id, ","); |
|
| 2220 | + echo $row['accountid'] . ',' . $tax_id; |
|
| 2221 | + } else { |
|
| 2222 | + echo $row['accountid']; |
|
| 2223 | + } |
|
| 2224 | + } |
|
| 2225 | + } |
|
| 2226 | + } |
|
| 2227 | + |
|
| 2228 | + function reseller_edit_account() { |
|
| 2229 | + $account_data = $this->session->userdata("accountinfo"); |
|
| 2230 | + |
|
| 2231 | + $add_array = $this->input->post(); |
|
| 2232 | + $data['form'] = $this->form->build_form($this->accounts_form->get_reseller_own_form_fields(), $add_array); |
|
| 2233 | + if ($add_array['id'] != '') { |
|
| 2234 | + $data['page_title'] = 'Edit Reseller'; |
|
| 2235 | + if ($this->form_validation->run() == FALSE) { |
|
| 2236 | + $data['validation_errors'] = validation_errors(); |
|
| 2237 | + } else { |
|
| 2238 | + $this->accounts_model->edit_account($add_array, $add_array['id']); |
|
| 2239 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 2240 | + if ($add_array['id'] == $accountinfo['id']) { |
|
| 2241 | + $result = $this->db->get_where('accounts', array('id' => $add_array['id'])); |
|
| 2242 | + $result = $result->result_array(); |
|
| 2243 | + $this->session->set_userdata('accountinfo', $result[0]); |
|
| 2244 | + } |
|
| 2245 | + $this->session->set_flashdata('astpp_errormsg', 'Reseller updated successfully!'); |
|
| 2246 | + redirect(base_url() . '/dashboard/'); |
|
| 2247 | + } |
|
| 2248 | + $this->load->view('view_reseller_edit_details_own', $data); |
|
| 2249 | + } else { |
|
| 2250 | + $data['page_title'] = 'Edit Reseller'; |
|
| 2251 | + $where = array('id' => $account_data["id"]); |
|
| 2252 | + $account = $this->db_model->getSelect("*", "accounts", $where); |
|
| 2253 | + $data["account_data"] = $account->result_array(); |
|
| 2254 | + foreach ($account->result_array() as $key => $value) { |
|
| 2255 | + $editable_data = $value; |
|
| 2256 | + } |
|
| 2257 | + $data['form'] = $this->form->build_form($this->accounts_form->get_reseller_own_form_fields(), $editable_data); |
|
| 2258 | + $this->load->view('view_reseller_edit_details_own', $data); |
|
| 2259 | + } |
|
| 2260 | + } |
|
| 2261 | + /** |
|
| 2262 | + * -------Here we write code for controller accounts functions add_callerid------ |
|
| 2263 | + * Add caller ids against account no |
|
| 2264 | + * @account_number: Account No |
|
| 2265 | + */ |
|
| 2266 | + function customer_animap_list($id = '') { |
|
| 2267 | + $data['animap_id'] = $id; |
|
| 2268 | + $data['username'] = $this->session->userdata('user_name'); |
|
| 2269 | + $data['page_title'] = "Caller Id List"; |
|
| 2270 | + $this->session->set_userdata('animap_search', 0); |
|
| 2271 | + $data['grid_fields'] = $this->accounts_form->build_animap_list(); |
|
| 2272 | + $data["grid_buttons"] = $this->accounts_form->build_grid_buttons_destination(); |
|
| 2273 | + $this->load->view('view_ani_map', $data); |
|
| 2274 | + } |
|
| 2275 | + |
|
| 2276 | + function customer_animap_list_json($id = '') { |
|
| 2277 | + $json_data = array(); |
|
| 2278 | + $count_all = $this->accounts_model->get_animap(false, '', '', $id); |
|
| 2279 | + $data['callingcard_id'] = $id; |
|
| 2280 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
| 2281 | + $json_data = $paging_data["json_paging"]; |
|
| 2282 | + $query = $this->accounts_model->get_animap(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"], $id); |
|
| 2283 | + $grid_fields = json_decode($this->accounts_form->build_animap_list()); |
|
| 2284 | + $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
| 2285 | + echo json_encode($json_data); |
|
| 2286 | + exit; |
|
| 2287 | + } |
|
| 2288 | + |
|
| 2289 | + function customer_animap_list_action($id = '') { |
|
| 2290 | + $add_array = $this->input->post(); |
|
| 2291 | + $add_array['id'] = trim($add_array['id']); |
|
| 2292 | + $add_array['number'] = trim($add_array['number']); |
|
| 2293 | + if (isset($add_array['id']) && $add_array['id'] != '') { |
|
| 2294 | + $add_array['id'] = trim($add_array['id']); |
|
| 2295 | + $id = $add_array['id']; |
|
| 2296 | + } |
|
| 2297 | + $where = array("number" => $add_array['number']); |
|
| 2298 | + $pro = $this->accounts_model->animap_authentication($where, $id); |
|
| 2299 | + if ($pro > 0) { |
|
| 2300 | + echo "2"; |
|
| 2301 | + exit; |
|
| 2302 | + } |
|
| 2303 | + if (isset($add_array['number']) && !empty($add_array['number'])) { |
|
| 2304 | + if (isset($add_array['id']) && $add_array['id'] != '') { |
|
| 2305 | + unset($add_array['animap_id']); |
|
| 2306 | + $response = $this->accounts_model->edit_animap($add_array, $add_array['id']); |
|
| 2307 | + echo "1"; |
|
| 2308 | + exit; |
|
| 2309 | + } else { |
|
| 2310 | + $add_array['context'] = "default"; |
|
| 2311 | + unset($add_array['animap_id']); |
|
| 2312 | + $add_array['accountid'] = $id; |
|
| 2313 | + $response = $this->accounts_model->add_animap($add_array); |
|
| 2314 | + echo "0"; |
|
| 2315 | + exit; |
|
| 2316 | + } |
|
| 2317 | + } else { |
|
| 2318 | + echo "3"; |
|
| 2319 | + exit; |
|
| 2320 | + } |
|
| 2321 | + } |
|
| 2322 | + |
|
| 2323 | + function customer_animap_list_remove($id) { |
|
| 2324 | + $this->accounts_model->remove_ani_map($id); |
|
| 2325 | + echo "1"; |
|
| 2326 | + exit; |
|
| 2327 | + } |
|
| 2328 | + |
|
| 2329 | + function customer_animap_list_edit($id) { |
|
| 2330 | + $where = array('id' => $id); |
|
| 2331 | + $account = $this->db_model->getSelect("*", "ani_map", $where); |
|
| 2332 | + foreach ($account->result_array() as $key => $value) { |
|
| 2333 | + $edit_data = $value; |
|
| 2334 | + } |
|
| 2335 | + $value_edit = ''; |
|
| 2336 | + foreach ($edit_data as $key => $value) { |
|
| 2337 | + $value_edit.=$value . ","; |
|
| 2338 | + } |
|
| 2339 | + echo rtrim($value_edit, ','); |
|
| 2340 | + exit; |
|
| 2341 | + } |
|
| 2342 | + |
|
| 2343 | + function provider_edit_account() { |
|
| 2344 | + $this->customer_edit_account(); |
|
| 2345 | + } |
|
| 2346 | + |
|
| 2347 | + function customer_show_password($id) { |
|
| 2348 | + $account = $this->db_model->getSelect("password", "accounts", array('id' => $id)); |
|
| 2349 | + $account_data = $account->result_array(); |
|
| 2350 | + $password = $this->common->decode($account_data[0]['password']); |
|
| 2351 | + echo $password; |
|
| 2352 | + } |
|
| 2353 | + |
|
| 2354 | + function reseller_export_cdr_xls() { |
|
| 2355 | 2355 | $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
| 2356 | 2356 | $currency_id=$account_info['currency_id']; |
| 2357 | 2357 | $currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
| 2358 | 2358 | ob_clean(); |
| 2359 | - $query = $this->accounts_model->get_reseller_Account_list(true, '', '', true); |
|
| 2360 | - $customer_array[] = array("Account", "First Name", "Last Name", "Company", "Rate Group ", "Account type", "Balance($currency)", "Credit Limit($currency)", "Status","Created Date"); |
|
| 2361 | - if ($query->num_rows() > 0) { |
|
| 2362 | - |
|
| 2363 | - foreach ($query->result_array() as $row) { |
|
| 2364 | - $customer_array[] = array( |
|
| 2365 | - $row['number'], |
|
| 2366 | - $row['first_name'], |
|
| 2367 | - $row['last_name'], |
|
| 2368 | - $row['company_name'], |
|
| 2369 | - $this->common->get_field_name('name', 'pricelists', $row['pricelist_id']), |
|
| 2370 | - $this->common->get_account_type('', '', $row['posttoexternal']), |
|
| 2371 | - $this->common_model->calculate_currency($row['balance'],false,false), |
|
| 2372 | - $this->common_model->calculate_currency($row['credit_limit'],false,false), |
|
| 2373 | - $this->common->get_status('export', '', $row['status']), |
|
| 2374 | - $row['creation'], |
|
| 2375 | - ); |
|
| 2376 | - } |
|
| 2377 | - } |
|
| 2378 | - $this->load->helper('csv'); |
|
| 2379 | - array_to_csv($customer_array, 'Resellers_' . date("Y-m-d") . '.csv'); |
|
| 2380 | - } |
|
| 2381 | - function customer_validate_ip(){ |
|
| 2382 | - $add_array=$this->input->post(); |
|
| 2383 | - if(!empty($add_array)){ |
|
| 2384 | - $ip = $add_array['ip']; |
|
| 2385 | - if (strpos($ip, '/') !== false) { |
|
| 2386 | - $add_array['ip'] = $add_array['ip']; |
|
| 2387 | - } else { |
|
| 2388 | - $add_array['ip'] = $add_array['ip'] . '/32'; |
|
| 2389 | - } |
|
| 2390 | - $this->db->where('ip',$add_array['ip']); |
|
| 2391 | - $this->db->where('prefix',$add_array['prefix']); |
|
| 2392 | - $this->db->select('count(ip) as count'); |
|
| 2393 | - $ip_map_result=(array)$this->db->get('ip_map')->first_row(); |
|
| 2394 | - if($ip_map_result['count'] > 0 ){ |
|
| 2395 | - echo 'FALSE'; |
|
| 2396 | - }else{ |
|
| 2397 | - echo 'TRUE'; |
|
| 2398 | - } |
|
| 2399 | - }else{ |
|
| 2400 | - echo 'FALSE'; |
|
| 2401 | - } |
|
| 2359 | + $query = $this->accounts_model->get_reseller_Account_list(true, '', '', true); |
|
| 2360 | + $customer_array[] = array("Account", "First Name", "Last Name", "Company", "Rate Group ", "Account type", "Balance($currency)", "Credit Limit($currency)", "Status","Created Date"); |
|
| 2361 | + if ($query->num_rows() > 0) { |
|
| 2362 | + |
|
| 2363 | + foreach ($query->result_array() as $row) { |
|
| 2364 | + $customer_array[] = array( |
|
| 2365 | + $row['number'], |
|
| 2366 | + $row['first_name'], |
|
| 2367 | + $row['last_name'], |
|
| 2368 | + $row['company_name'], |
|
| 2369 | + $this->common->get_field_name('name', 'pricelists', $row['pricelist_id']), |
|
| 2370 | + $this->common->get_account_type('', '', $row['posttoexternal']), |
|
| 2371 | + $this->common_model->calculate_currency($row['balance'],false,false), |
|
| 2372 | + $this->common_model->calculate_currency($row['credit_limit'],false,false), |
|
| 2373 | + $this->common->get_status('export', '', $row['status']), |
|
| 2374 | + $row['creation'], |
|
| 2375 | + ); |
|
| 2376 | + } |
|
| 2377 | + } |
|
| 2378 | + $this->load->helper('csv'); |
|
| 2379 | + array_to_csv($customer_array, 'Resellers_' . date("Y-m-d") . '.csv'); |
|
| 2380 | + } |
|
| 2381 | + function customer_validate_ip(){ |
|
| 2382 | + $add_array=$this->input->post(); |
|
| 2383 | + if(!empty($add_array)){ |
|
| 2384 | + $ip = $add_array['ip']; |
|
| 2385 | + if (strpos($ip, '/') !== false) { |
|
| 2386 | + $add_array['ip'] = $add_array['ip']; |
|
| 2387 | + } else { |
|
| 2388 | + $add_array['ip'] = $add_array['ip'] . '/32'; |
|
| 2389 | + } |
|
| 2390 | + $this->db->where('ip',$add_array['ip']); |
|
| 2391 | + $this->db->where('prefix',$add_array['prefix']); |
|
| 2392 | + $this->db->select('count(ip) as count'); |
|
| 2393 | + $ip_map_result=(array)$this->db->get('ip_map')->first_row(); |
|
| 2394 | + if($ip_map_result['count'] > 0 ){ |
|
| 2395 | + echo 'FALSE'; |
|
| 2396 | + }else{ |
|
| 2397 | + echo 'TRUE'; |
|
| 2398 | + } |
|
| 2399 | + }else{ |
|
| 2400 | + echo 'FALSE'; |
|
| 2401 | + } |
|
| 2402 | 2402 | |
| 2403 | - } |
|
| 2403 | + } |
|
| 2404 | 2404 | function reseller_invoice_config($id=''){ |
| 2405 | - $data['page_title'] = 'Company Profile'; |
|
| 2406 | - $accountinfo = $this->session->userdata("accountinfo"); |
|
| 2407 | - $add_array = $this->input->post(); |
|
| 2408 | - $data["account_data"] = $add_array; |
|
| 2409 | - if (isset($add_array['submit'])) { |
|
| 2410 | - if ($_FILES['file']['name'] == '') { |
|
| 2411 | - $this->load->module('invoices/invoices'); |
|
| 2412 | - $this->load->model("invoices_model"); |
|
| 2413 | - $invoiceconf = $this->invoices_model->get_invoiceconf(); |
|
| 2414 | - $file_name=($invoiceconf['logo'] != '') ? $invoiceconf['logo'] : ''; |
|
| 2415 | - } |
|
| 2416 | - if (isset($_FILES['file']['name']) && $_FILES['file']['name'] != '') { |
|
| 2417 | - $files = $_FILES['file']; |
|
| 2418 | - if ($files['size'] < 0) { |
|
| 2419 | - $this->session->set_flashdata('astpp_notification', 'PLease upload maximum file'); |
|
| 2420 | - redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
| 2421 | - } |
|
| 2422 | - $file = $_FILES['file']; |
|
| 2423 | - $uploadedFile = $file["tmp_name"]; |
|
| 2424 | - $file_name = $file['name']; |
|
| 2425 | - $file_type = $file['type']; |
|
| 2426 | - if ($file_type == 'image/jpg' || $file_type == 'image/png' || $file_type == 'image/jpeg') { |
|
| 2427 | - $dir_path = FCPATH. "upload/"; |
|
| 2428 | - $path = $dir_path . $add_array['accountid']."_".$file['name']; |
|
| 2429 | - if (move_uploaded_file($uploadedFile, $path)) { |
|
| 2430 | - $this->session->set_flashdata('astpp_errormsg', gettext('files added successfully!')); |
|
| 2431 | - } else { |
|
| 2432 | - $this->session->set_flashdata('astpp_notification', "File Uploading Fail Please Try Again"); |
|
| 2433 | - redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
| 2434 | - } |
|
| 2435 | - } else { |
|
| 2436 | - $this->session->set_flashdata('astpp_notification', 'Please upload only image!'); |
|
| 2437 | - redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
| 2438 | - } |
|
| 2439 | - } |
|
| 2440 | - $add_array['logo'] = $file_name; |
|
| 2441 | - unset($add_array['submit']); |
|
| 2442 | - if ($add_array['id'] == '') { |
|
| 2443 | - $this->accounts_model->add_invoice_config($add_array); |
|
| 2444 | - } else { |
|
| 2445 | - $this->accounts_model->edit_invoice_config($add_array, $add_array['id']); |
|
| 2446 | - } |
|
| 2447 | - $this->session->set_flashdata('astpp_errormsg', 'Invoice config updated successfully!'); |
|
| 2448 | - redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
| 2449 | - } else { |
|
| 2450 | - $data["account_data"] =(array)$this->db->get_where('invoice_conf',array("accountid"=>$id))->first_row(); |
|
| 2451 | - $data["accounttype"]='Reseller'; |
|
| 2452 | - $data["edit_id"]=$id; |
|
| 2453 | - if(isset($data["account_data"]['logo'])){ |
|
| 2454 | - $data["account_data"]['file']=$id."_".$data["account_data"]['logo']; |
|
| 2455 | - } |
|
| 2456 | - $this->load->view('view_reseller_invoices_config', $data); |
|
| 2457 | - } |
|
| 2405 | + $data['page_title'] = 'Company Profile'; |
|
| 2406 | + $accountinfo = $this->session->userdata("accountinfo"); |
|
| 2407 | + $add_array = $this->input->post(); |
|
| 2408 | + $data["account_data"] = $add_array; |
|
| 2409 | + if (isset($add_array['submit'])) { |
|
| 2410 | + if ($_FILES['file']['name'] == '') { |
|
| 2411 | + $this->load->module('invoices/invoices'); |
|
| 2412 | + $this->load->model("invoices_model"); |
|
| 2413 | + $invoiceconf = $this->invoices_model->get_invoiceconf(); |
|
| 2414 | + $file_name=($invoiceconf['logo'] != '') ? $invoiceconf['logo'] : ''; |
|
| 2415 | + } |
|
| 2416 | + if (isset($_FILES['file']['name']) && $_FILES['file']['name'] != '') { |
|
| 2417 | + $files = $_FILES['file']; |
|
| 2418 | + if ($files['size'] < 0) { |
|
| 2419 | + $this->session->set_flashdata('astpp_notification', 'PLease upload maximum file'); |
|
| 2420 | + redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
| 2421 | + } |
|
| 2422 | + $file = $_FILES['file']; |
|
| 2423 | + $uploadedFile = $file["tmp_name"]; |
|
| 2424 | + $file_name = $file['name']; |
|
| 2425 | + $file_type = $file['type']; |
|
| 2426 | + if ($file_type == 'image/jpg' || $file_type == 'image/png' || $file_type == 'image/jpeg') { |
|
| 2427 | + $dir_path = FCPATH. "upload/"; |
|
| 2428 | + $path = $dir_path . $add_array['accountid']."_".$file['name']; |
|
| 2429 | + if (move_uploaded_file($uploadedFile, $path)) { |
|
| 2430 | + $this->session->set_flashdata('astpp_errormsg', gettext('files added successfully!')); |
|
| 2431 | + } else { |
|
| 2432 | + $this->session->set_flashdata('astpp_notification', "File Uploading Fail Please Try Again"); |
|
| 2433 | + redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
| 2434 | + } |
|
| 2435 | + } else { |
|
| 2436 | + $this->session->set_flashdata('astpp_notification', 'Please upload only image!'); |
|
| 2437 | + redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
| 2438 | + } |
|
| 2439 | + } |
|
| 2440 | + $add_array['logo'] = $file_name; |
|
| 2441 | + unset($add_array['submit']); |
|
| 2442 | + if ($add_array['id'] == '') { |
|
| 2443 | + $this->accounts_model->add_invoice_config($add_array); |
|
| 2444 | + } else { |
|
| 2445 | + $this->accounts_model->edit_invoice_config($add_array, $add_array['id']); |
|
| 2446 | + } |
|
| 2447 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice config updated successfully!'); |
|
| 2448 | + redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
| 2449 | + } else { |
|
| 2450 | + $data["account_data"] =(array)$this->db->get_where('invoice_conf',array("accountid"=>$id))->first_row(); |
|
| 2451 | + $data["accounttype"]='Reseller'; |
|
| 2452 | + $data["edit_id"]=$id; |
|
| 2453 | + if(isset($data["account_data"]['logo'])){ |
|
| 2454 | + $data["account_data"]['file']=$id."_".$data["account_data"]['logo']; |
|
| 2455 | + } |
|
| 2456 | + $this->load->view('view_reseller_invoices_config', $data); |
|
| 2457 | + } |
|
| 2458 | 2458 | } |
| 2459 | 2459 | |
| 2460 | - function reseller_invoice_logo_delete($accountid){ |
|
| 2461 | - $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> $accountid)); |
|
| 2462 | - $result=$invoiceconf->result_array(); |
|
| 2463 | - $logo=$result[0]['logo']; |
|
| 2464 | - $post_arr=array('logo'=>''); |
|
| 2465 | - $where_arr=array('logo'=>$logo); |
|
| 2466 | - $this->db->where($where_arr); |
|
| 2467 | - $this->db->update('invoice_conf',$post_arr); |
|
| 2468 | - } |
|
| 2460 | + function reseller_invoice_logo_delete($accountid){ |
|
| 2461 | + $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> $accountid)); |
|
| 2462 | + $result=$invoiceconf->result_array(); |
|
| 2463 | + $logo=$result[0]['logo']; |
|
| 2464 | + $post_arr=array('logo'=>''); |
|
| 2465 | + $where_arr=array('logo'=>$logo); |
|
| 2466 | + $this->db->where($where_arr); |
|
| 2467 | + $this->db->update('invoice_conf',$post_arr); |
|
| 2468 | + } |
|
| 2469 | 2469 | |
| 2470 | 2470 | |
| 2471 | - function customer_global_grid_list(){ |
|
| 2472 | - echo gettext($_POST['display']); |
|
| 2471 | + function customer_global_grid_list(){ |
|
| 2472 | + echo gettext($_POST['display']); |
|
| 2473 | 2473 | } |
| 2474 | 2474 | |
| 2475 | 2475 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $this->load->model('Astpp_common'); |
| 39 | 39 | $this->protected_pages = array('account_list'); |
| 40 | 40 | if ($this->session->userdata('user_login') == FALSE) |
| 41 | - redirect(base_url() . '/login/login'); |
|
| 41 | + redirect(base_url().'/login/login'); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | function customer_list() { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $this->session->set_userdata('customer_list_search', $action); |
| 98 | 98 | } |
| 99 | 99 | if (@$ajax_search != 1) { |
| 100 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 100 | + redirect(base_url().'accounts/customer_list/'); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | function customer_export_cdr_xls() { |
| 110 | 110 | $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
| 111 | - $currency_id=$account_info['currency_id']; |
|
| 112 | - $currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
|
| 111 | + $currency_id = $account_info['currency_id']; |
|
| 112 | + $currency = $this->common->get_field_name('currency', 'currency', $currency_id); |
|
| 113 | 113 | $query = $this->accounts_model->get_customer_Account_list(true, '', '', true); |
| 114 | 114 | ob_clean(); |
| 115 | - $customer_array[] = array("Account", "First Name", "Last Name", "Company", "Rate Group ", "Balance ($currency)", "Credit Limit ($currency)", "First Used", "Expiry Date","CC","Status","Created Date"); |
|
| 115 | + $customer_array[] = array("Account", "First Name", "Last Name", "Company", "Rate Group ", "Balance ($currency)", "Credit Limit ($currency)", "First Used", "Expiry Date", "CC", "Status", "Created Date"); |
|
| 116 | 116 | if ($query->num_rows() > 0) { |
| 117 | 117 | |
| 118 | 118 | foreach ($query->result_array() as $row) { |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | $this->load->helper('csv'); |
| 136 | - array_to_csv($customer_array, 'Customers_' . date("Y-m-d") . '.csv'); |
|
| 136 | + array_to_csv($customer_array, 'Customers_'.date("Y-m-d").'.csv'); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | function provider_add() { |
@@ -154,20 +154,20 @@ discard block |
||
| 154 | 154 | $entity_type = strtolower($this->common->get_entity_type('', '', $type)); |
| 155 | 155 | $data['username'] = $this->session->userdata('user_name'); |
| 156 | 156 | $data['flag'] = 'create'; |
| 157 | - $data['page_title'] = 'Create ' . $entity_type; |
|
| 157 | + $data['page_title'] = 'Create '.$entity_type; |
|
| 158 | 158 | $data['back_flag'] = true; |
| 159 | 159 | $data['country_id'] = $accountinfo['country_id']; |
| 160 | 160 | $data['callingcard'] = Common_model::$global_config['system_config']['pinlength']; |
| 161 | 161 | $data['currency_id'] = $accountinfo['currency_id']; |
| 162 | 162 | $data['timezone_id'] = $accountinfo['timezone_id']; |
| 163 | 163 | $data['form'] = $this->form->build_form($this->accounts_form->get_customer_form_fields($entity_type), ''); |
| 164 | - if (!$data['timezone_id']) { |
|
| 164 | + if ( ! $data['timezone_id']) { |
|
| 165 | 165 | $data['timezone_id'] = 1; |
| 166 | 166 | } |
| 167 | - if (!$data['currency_id']) { |
|
| 167 | + if ( ! $data['currency_id']) { |
|
| 168 | 168 | $data['currency_id'] = 1; |
| 169 | 169 | } |
| 170 | - if (!$data['country_id']) { |
|
| 170 | + if ( ! $data['country_id']) { |
|
| 171 | 171 | $data['country_id'] = 1; |
| 172 | 172 | } |
| 173 | 173 | $data['entity_name'] = $entity_type; |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 183 | 183 | $account = $this->db_model->getSelect("*", "accounts", $where); |
| 184 | 184 | if ($account->num_rows > 0) { |
| 185 | - $account_data = (array) $account->first_row(); |
|
| 185 | + $account_data = (array)$account->first_row(); |
|
| 186 | 186 | $entity_name = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 187 | - $data['page_title'] =ucfirst($entity_name) . " Profile"; |
|
| 187 | + $data['page_title'] = ucfirst($entity_name)." Profile"; |
|
| 188 | 188 | $data['invoice_date'] = $account_data['invoice_day']; |
| 189 | 189 | $data["account_data"] = $account_data; |
| 190 | 190 | $data['callingcard'] = Common_model::$global_config['system_config']['pinlength']; |
@@ -202,10 +202,10 @@ discard block |
||
| 202 | 202 | $account_data['password'] = $this->common->decode($account_data['password']); |
| 203 | 203 | /* * ********************** */ |
| 204 | 204 | $data['form'] = $this->form->build_form($this->accounts_form->get_customer_form_fields($entity_name, $edit_id), $account_data); |
| 205 | - $data['edit_id']=$edit_id; |
|
| 205 | + $data['edit_id'] = $edit_id; |
|
| 206 | 206 | $this->load->view('view_customer_details', $data); |
| 207 | 207 | } else { |
| 208 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 208 | + redirect(base_url().'accounts/customer_list/'); |
|
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | $data['currency_id'] = $add_array['currency_id']; |
| 218 | 218 | $data['entity_name'] = $entity_name; |
| 219 | 219 | $data['callingcard'] = Common_model::$global_config['system_config']['pinlength']; |
| 220 | - $data['edit_id']=$add_array['id']; |
|
| 220 | + $data['edit_id'] = $add_array['id']; |
|
| 221 | 221 | $data['form'] = $this->form->build_form($this->accounts_form->get_customer_form_fields($entity_name, $add_array['id']), $add_array); |
| 222 | 222 | if ($add_array['id'] != '') { |
| 223 | - $data['page_title'] = 'Edit ' . $this->common->get_entity_type('', '', $add_array['type']); |
|
| 223 | + $data['page_title'] = 'Edit '.$this->common->get_entity_type('', '', $add_array['type']); |
|
| 224 | 224 | if ($this->form_validation->run() == FALSE) { |
| 225 | 225 | $data['validation_errors'] = validation_errors(); |
| 226 | 226 | } else { |
@@ -245,16 +245,16 @@ discard block |
||
| 245 | 245 | unset($add_array['tax_id']); |
| 246 | 246 | } |
| 247 | 247 | //Completed |
| 248 | - unset($add_array['posttoexternal'],$add_array['number']); |
|
| 248 | + unset($add_array['posttoexternal'], $add_array['number']); |
|
| 249 | 249 | $this->accounts_model->edit_account($add_array, $add_array['id']); |
| 250 | - $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_name) . ' updated successfully!'); |
|
| 251 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 250 | + $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_name).' updated successfully!'); |
|
| 251 | + redirect(base_url().'accounts/customer_list/'); |
|
| 252 | 252 | exit; |
| 253 | 253 | } |
| 254 | 254 | $data["account_data"]["0"] = $add_array; |
| 255 | 255 | $this->load->view('view_customer_details', $data); |
| 256 | 256 | } else { |
| 257 | - $data['page_title'] = 'Create ' . $entity_name; |
|
| 257 | + $data['page_title'] = 'Create '.$entity_name; |
|
| 258 | 258 | if ($this->form_validation->run() == FALSE) { |
| 259 | 259 | $data['validation_errors'] = validation_errors(); |
| 260 | 260 | } else { |
@@ -277,8 +277,8 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | unset($add_array['tax_id']); |
| 279 | 279 | } |
| 280 | - $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_name) . ' added successfully!'); |
|
| 281 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 280 | + $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_name).' added successfully!'); |
|
| 281 | + redirect(base_url().'accounts/customer_list/'); |
|
| 282 | 282 | exit; |
| 283 | 283 | } |
| 284 | 284 | $this->load->view('view_accounts_create', $data); |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $account = $this->db_model->getSelect("*", "accounts", $where); |
| 300 | 300 | |
| 301 | 301 | if ($account->num_rows > 0) { |
| 302 | - $account_data = (array) $account->first_row(); |
|
| 302 | + $account_data = (array)$account->first_row(); |
|
| 303 | 303 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 304 | 304 | $data['page_title'] = 'Speed Dial'; |
| 305 | 305 | $data['accounttype'] = $accounttype; |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | $data['form'] = $this->form->build_form($this->accounts_form->get_customer_form_fields($accounttype, $edit_id), $account_data); |
| 319 | 319 | $this->load->view('view_customer_speed_dial', $data); |
| 320 | 320 | } else { |
| 321 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 321 | + redirect(base_url().'accounts/customer_list/'); |
|
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | |
| 353 | 353 | function customer_ipmap($edit_id) { |
| 354 | 354 | $data['page_title'] = "IP Settings"; |
| 355 | - $data['add_form']=true; |
|
| 355 | + $data['add_form'] = true; |
|
| 356 | 356 | //Get Account information from session. |
| 357 | 357 | $accountinfo = $this->session->userdata('accountinfo'); |
| 358 | 358 | //Get Parent informartion |
@@ -360,14 +360,14 @@ discard block |
||
| 360 | 360 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 361 | 361 | $account_res = $this->db_model->getSelect("type", "accounts", $where); |
| 362 | 362 | if ($account_res->num_rows > 0) { |
| 363 | - $account_data = (array) $account_res->first_row(); |
|
| 363 | + $account_data = (array)$account_res->first_row(); |
|
| 364 | 364 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 365 | 365 | $data["grid_fields"] = $this->accounts_form->build_ip_list_for_customer($edit_id, $accounttype); |
| 366 | 366 | $data['edit_id'] = $edit_id; |
| 367 | 367 | $data['accounttype'] = $accounttype; |
| 368 | 368 | $this->load->view('view_customer_ipmap', $data); |
| 369 | 369 | } else { |
| 370 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 370 | + redirect(base_url().'accounts/customer_list/'); |
|
| 371 | 371 | exit; |
| 372 | 372 | } |
| 373 | 373 | } |
@@ -375,14 +375,14 @@ discard block |
||
| 375 | 375 | function customer_ipmap_json($accountid, $accounttype) { |
| 376 | 376 | $json_data = array(); |
| 377 | 377 | $where = array("accountid" => $accountid); |
| 378 | - $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_ipmap'); |
|
| 379 | - $like_str=!empty($instant_search) ? "(name like '%$instant_search%' OR ip like '%$instant_search%' OR prefix like '%$instant_search%' OR created_date like '%$instant_search%' )" :null; |
|
| 380 | - if(!empty($like_str)) |
|
| 378 | + $instant_search = $this->session->userdata('left_panel_search_'.$accounttype.'_ipmap'); |
|
| 379 | + $like_str = ! empty($instant_search) ? "(name like '%$instant_search%' OR ip like '%$instant_search%' OR prefix like '%$instant_search%' OR created_date like '%$instant_search%' )" : null; |
|
| 380 | + if ( ! empty($like_str)) |
|
| 381 | 381 | $this->db->where($like_str); |
| 382 | 382 | $count_all = $this->db_model->countQuery("*", "ip_map", $where); |
| 383 | 383 | $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
| 384 | 384 | $json_data = $paging_data["json_paging"]; |
| 385 | - if(!empty($like_str)) |
|
| 385 | + if ( ! empty($like_str)) |
|
| 386 | 386 | $this->db->where($like_str); |
| 387 | 387 | $query = $this->db_model->select("*", "ip_map", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
| 388 | 388 | $grid_fields = json_decode($this->accounts_form->build_ip_list_for_customer($accountid, $accounttype)); |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | if (strpos($ip, '/') !== false) { |
| 404 | 404 | $add_array['ip'] = $add_array['ip']; |
| 405 | 405 | } else { |
| 406 | - $add_array['ip'] = $add_array['ip'] . '/32'; |
|
| 406 | + $add_array['ip'] = $add_array['ip'].'/32'; |
|
| 407 | 407 | } |
| 408 | 408 | $where = array("ip" => trim($add_array['ip']), "prefix" => trim($add_array['prefix'])); |
| 409 | 409 | $getdata = $this->db_model->countQuery("*", "ip_map", $where); |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | } |
| 439 | 439 | $this->session->set_flashdata('astpp_notification', 'IP removed sucessfully.'); |
| 440 | 440 | } |
| 441 | - redirect(base_url() . "accounts/" . $accounttype . "_ipmap/" . $accountid . "/"); |
|
| 441 | + redirect(base_url()."accounts/".$accounttype."_ipmap/".$accountid."/"); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | //This function using for provider t |
@@ -456,30 +456,30 @@ discard block |
||
| 456 | 456 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 457 | 457 | $account_res = $this->db_model->getSelect("type", "accounts", $where); |
| 458 | 458 | if ($account_res->num_rows > 0) { |
| 459 | - $account_data = (array) $account_res->first_row(); |
|
| 459 | + $account_data = (array)$account_res->first_row(); |
|
| 460 | 460 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 461 | 461 | $data["grid_fields"] = $this->accounts_form->build_animap_list_for_customer($edit_id, $accounttype); |
| 462 | 462 | $data['edit_id'] = $edit_id; |
| 463 | 463 | $data['accounttype'] = $accounttype; |
| 464 | 464 | $this->load->view('view_customer_animap', $data); |
| 465 | 465 | } else { |
| 466 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 466 | + redirect(base_url().'accounts/customer_list/'); |
|
| 467 | 467 | exit; |
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | function customer_animap_json($accountid, $accounttype) { |
| 472 | 472 | $json_data = array(); |
| 473 | - $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_animap'); |
|
| 474 | - $like_str=!empty($instant_search) ? "(number like '%$instant_search%' OR creation_date like '%$instant_search%' )" :null; |
|
| 475 | - if(!empty($like_str)) |
|
| 473 | + $instant_search = $this->session->userdata('left_panel_search_'.$accounttype.'_animap'); |
|
| 474 | + $like_str = ! empty($instant_search) ? "(number like '%$instant_search%' OR creation_date like '%$instant_search%' )" : null; |
|
| 475 | + if ( ! empty($like_str)) |
|
| 476 | 476 | $this->db->where($like_str); |
| 477 | 477 | $where = array("accountid" => $accountid); |
| 478 | 478 | $count_all = $this->db_model->countQuery("*", "ani_map", $where); |
| 479 | 479 | |
| 480 | 480 | $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
| 481 | 481 | $json_data = $paging_data["json_paging"]; |
| 482 | - if(!empty($like_str)) |
|
| 482 | + if ( ! empty($like_str)) |
|
| 483 | 483 | $this->db->where($like_str); |
| 484 | 484 | $query = $this->db_model->select("*", "ani_map", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
| 485 | 485 | |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | function customer_animap_action($action, $accountid, $aniid = "") { |
| 498 | 498 | $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
| 499 | 499 | $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
| 500 | - $url = "accounts/" . $entity_type . "_animap/$accountid/"; |
|
| 500 | + $url = "accounts/".$entity_type."_animap/$accountid/"; |
|
| 501 | 501 | if ($action == "add") { |
| 502 | 502 | $ani = $this->input->post(); |
| 503 | 503 | $this->db->where('number', $ani['number']); |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | $this->session->set_flashdata('astpp_notification', 'Caller ID removed sucessfully!'); |
| 528 | 528 | $this->db_model->delete("ani_map", array("id" => $aniid)); |
| 529 | 529 | } |
| 530 | - redirect(base_url() . $url); |
|
| 530 | + redirect(base_url().$url); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | //This function using by Customer/Provider edit tab |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | } |
| 549 | 549 | if ($module == "invoices") { |
| 550 | 550 | $this->load->module('invoices/invoices'); |
| 551 | - $this->invoices->customer_invoices($accountid,$entity_type, false); |
|
| 551 | + $this->invoices->customer_invoices($accountid, $entity_type, false); |
|
| 552 | 552 | } |
| 553 | 553 | if ($module == "subscription") { |
| 554 | 554 | $this->load->module('charges/charges'); |
@@ -560,11 +560,11 @@ discard block |
||
| 560 | 560 | } |
| 561 | 561 | if ($module == "charges") { |
| 562 | 562 | $this->load->module('reports/reports'); |
| 563 | - $this->reports->customer_charge_history($accountid,$entity_type); |
|
| 563 | + $this->reports->customer_charge_history($accountid, $entity_type); |
|
| 564 | 564 | } |
| 565 | 565 | if ($module == "refill") { |
| 566 | 566 | $this->load->module('reports/reports'); |
| 567 | - $this->reports->customer_refillreport($accountid,$entity_type); |
|
| 567 | + $this->reports->customer_refillreport($accountid, $entity_type); |
|
| 568 | 568 | } |
| 569 | 569 | if ($module == "emailhistory") { |
| 570 | 570 | $this->load->module('email/email'); |
@@ -572,13 +572,13 @@ discard block |
||
| 572 | 572 | } |
| 573 | 573 | if ($module == "opensips") { |
| 574 | 574 | $this->load->module('opensips/opensips'); |
| 575 | - $this->opensips->customer_opensips_json($accountid,$entity_type); |
|
| 575 | + $this->opensips->customer_opensips_json($accountid, $entity_type); |
|
| 576 | 576 | } |
| 577 | 577 | } |
| 578 | - function customer_details_search($module_name){ |
|
| 578 | + function customer_details_search($module_name) { |
|
| 579 | 579 | $action = $this->input->post(); |
| 580 | - $this->session->set_userdata('left_panel_search_'.$module_name,""); |
|
| 581 | - if(!empty($action['left_panel_search'])){ |
|
| 580 | + $this->session->set_userdata('left_panel_search_'.$module_name, ""); |
|
| 581 | + if ( ! empty($action['left_panel_search'])) { |
|
| 582 | 582 | $this->session->set_userdata('left_panel_search_'.$module_name, $action['left_panel_search']); |
| 583 | 583 | } |
| 584 | 584 | } |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 596 | 596 | $account_res = $this->db_model->getSelect("type", "accounts", $where); |
| 597 | 597 | if ($account_res->num_rows > 0) { |
| 598 | - $account_data = (array) $account_res->first_row(); |
|
| 598 | + $account_data = (array)$account_res->first_row(); |
|
| 599 | 599 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 600 | 600 | $this->load->module('freeswitch/freeswitch'); |
| 601 | 601 | $data["grid_buttons"] = $this->freeswitch->freeswitch_form->fsdevices_build_grid_buttons($edit_id, $accounttype); |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | $data['accounttype'] = $accounttype; |
| 605 | 605 | $this->load->view('view_customer_sipdevices', $data); |
| 606 | 606 | } else { |
| 607 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 607 | + redirect(base_url().'accounts/customer_list/'); |
|
| 608 | 608 | exit; |
| 609 | 609 | } |
| 610 | 610 | } |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | if ($action == "delete") { |
| 621 | 621 | $this->freeswitch->freeswitch_model->delete_freeswith_devices($id); |
| 622 | 622 | $this->session->set_flashdata('astpp_notification', 'Sip Device removed successfully!'); |
| 623 | - redirect(base_url() . "accounts/" . $entity_type . "_sipdevices/$accountid/"); |
|
| 623 | + redirect(base_url()."accounts/".$entity_type."_sipdevices/$accountid/"); |
|
| 624 | 624 | } |
| 625 | 625 | if ($action == "edit") { |
| 626 | 626 | $this->freeswitch->customer_fssipdevices_edit($id, $accountid); |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 642 | 642 | $account_res = $this->db_model->getSelect("type", "accounts", $where); |
| 643 | 643 | if ($account_res->num_rows > 0) { |
| 644 | - $account_data = (array) $account_res->first_row(); |
|
| 644 | + $account_data = (array)$account_res->first_row(); |
|
| 645 | 645 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 646 | 646 | $this->load->module('freeswitch/freeswitch'); |
| 647 | 647 | $this->load->module('opensips/opensips'); |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | $data['accounttype'] = $accounttype; |
| 652 | 652 | $this->load->view('view_customer_opensips_devices', $data); |
| 653 | 653 | } else { |
| 654 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 654 | + redirect(base_url().'accounts/customer_list/'); |
|
| 655 | 655 | exit; |
| 656 | 656 | } |
| 657 | 657 | } |
@@ -659,12 +659,12 @@ discard block |
||
| 659 | 659 | function customer_opensips_action($action, $accountid, $id) { |
| 660 | 660 | $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
| 661 | 661 | $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
| 662 | - $url = "accounts/" . $entity_type . "_opensips/$accountid/"; |
|
| 662 | + $url = "accounts/".$entity_type."_opensips/$accountid/"; |
|
| 663 | 663 | $this->load->module('opensips/opensips'); |
| 664 | 664 | if ($action == "delete") { |
| 665 | 665 | $this->opensips->opensips_model->remove_opensips($id); |
| 666 | 666 | $this->session->set_flashdata('astpp_notification', 'Opensips removed successfully!'); |
| 667 | - redirect(base_url() . $url); |
|
| 667 | + redirect(base_url().$url); |
|
| 668 | 668 | } |
| 669 | 669 | if ($action == "edit") { |
| 670 | 670 | $this->opensips->customer_opensips_edit($accountid, $id); |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 690 | 690 | $account_res = $this->db_model->getSelect("type", "accounts", $where); |
| 691 | 691 | if ($account_res->num_rows > 0) { |
| 692 | - $account_data = (array) $account_res->first_row(); |
|
| 692 | + $account_data = (array)$account_res->first_row(); |
|
| 693 | 693 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 694 | 694 | $data['chargelist'] = form_dropdown('applayable_charge', $this->Astpp_common->list_applyable_charges($edit_id), ''); |
| 695 | 695 | $this->load->module('reports/reports'); |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | $data['accounttype'] = $accounttype; |
| 699 | 699 | $this->load->view('view_customer_charges', $data); |
| 700 | 700 | } else { |
| 701 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 701 | + redirect(base_url().'accounts/customer_list/'); |
|
| 702 | 702 | exit; |
| 703 | 703 | } |
| 704 | 704 | } |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 721 | 721 | $account_res = $this->db_model->getSelect("type", "accounts", $where); |
| 722 | 722 | if ($account_res->num_rows > 0) { |
| 723 | - $account_data = (array) $account_res->first_row(); |
|
| 723 | + $account_data = (array)$account_res->first_row(); |
|
| 724 | 724 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 725 | 725 | $data['chargelist'] = form_dropdown_all(array("name" => 'applayable_charge', 'id' => 'applayable_charge', 'class' => ""), $this->Astpp_common->list_applyable_charges($edit_id), ''); |
| 726 | 726 | $this->load->module('charges/charges'); |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | $data['accounttype'] = $accounttype; |
| 730 | 730 | $this->load->view('view_customer_subscriptions', $data); |
| 731 | 731 | } else { |
| 732 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 732 | + redirect(base_url().'accounts/customer_list/'); |
|
| 733 | 733 | exit; |
| 734 | 734 | } |
| 735 | 735 | } |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | For Email Broadcast when Subscription Add - Delete |
| 750 | 750 | * */ |
| 751 | 751 | $accountinfo = $this->db_model->getSelect("*", "accounts", array("id" => $accountid)); |
| 752 | - $accountinfo = (array) $accountinfo->first_row(); |
|
| 752 | + $accountinfo = (array)$accountinfo->first_row(); |
|
| 753 | 753 | /* * ****************************** */ |
| 754 | 754 | if ($action == "add") { |
| 755 | 755 | $charge_id = $this->input->post("applayable_charge", true); |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | * */ |
| 772 | 772 | $this->common->mail_to_users($template_name, $accountinfo); |
| 773 | 773 | /* * ********************************* */ |
| 774 | - redirect(base_url() . "accounts/" . $accounttype . "_subscription/$accountid/"); |
|
| 774 | + redirect(base_url()."accounts/".$accounttype."_subscription/$accountid/"); |
|
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | function provider_dids($edit_id) { |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 788 | 788 | $account_res = $this->db_model->getSelect("type,country_id", "accounts", $where); |
| 789 | 789 | if ($account_res->num_rows > 0) { |
| 790 | - $account_data = (array) $account_res->first_row(); |
|
| 790 | + $account_data = (array)$account_res->first_row(); |
|
| 791 | 791 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 792 | 792 | $this->load->module('did/did'); |
| 793 | 793 | $data['grid_fields'] = $this->did->did_form->build_did_list_for_customer($edit_id, $accounttype); |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | $data['country_id'] = $account_data['country_id']; |
| 800 | 800 | $this->load->view('view_customer_dids', $data); |
| 801 | 801 | } else { |
| 802 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 802 | + redirect(base_url().'accounts/customer_list/'); |
|
| 803 | 803 | exit; |
| 804 | 804 | } |
| 805 | 805 | } |
@@ -820,16 +820,16 @@ discard block |
||
| 820 | 820 | $did_id = empty($did_id) ? $this->input->post("free_didlist", true) : $did_id; |
| 821 | 821 | if ($did_id != "") { |
| 822 | 822 | $account_arr = (array)$this->db->get_where("accounts", array("id" => $accountid))->first_row(); |
| 823 | - $did_arr = (array) $this->db->get_where("dids", array("id" => $did_id))->first_row(); |
|
| 824 | - $field_name = $account_arr['type'] ==1 ? "parent_id" : 'accountid'; |
|
| 823 | + $did_arr = (array)$this->db->get_where("dids", array("id" => $did_id))->first_row(); |
|
| 824 | + $field_name = $account_arr['type'] == 1 ? "parent_id" : 'accountid'; |
|
| 825 | 825 | if ($action == "add") { |
| 826 | 826 | if ($did_arr['accountid'] == 0 && $did_arr['parent_id'] == $reseller_id) { |
| 827 | 827 | if ($accountinfo['type'] == 1) { |
| 828 | 828 | //for getting reseller setup price if reseller customer purchase |
| 829 | 829 | $reseller_pricing_query = $this->db_model->getSelect("*", "reseller_pricing", array("note" => $did_arr['number'], 'reseller_id' => $reseller_id)); |
| 830 | 830 | if ($reseller_pricing_query->num_rows() > 0) { |
| 831 | - $reseller_pricing = (array) $reseller_pricing_query->first_row(); |
|
| 832 | - $did_arr=array_merge($did_arr,$reseller_pricing); |
|
| 831 | + $reseller_pricing = (array)$reseller_pricing_query->first_row(); |
|
| 832 | + $did_arr = array_merge($did_arr, $reseller_pricing); |
|
| 833 | 833 | } |
| 834 | 834 | } |
| 835 | 835 | $available_bal = $this->db_model->get_available_bal($account_arr); |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | $account_arr['did_number'] = $did_arr['number']; |
| 845 | 845 | $account_arr['did_country_id'] = $this->common->get_field_name('country', 'countrycode', $did_arr['country_id']); |
| 846 | 846 | $account_arr['did_setup'] = $this->common_model->to_calculate_currency($did_arr['setup'], "", '', true, true); |
| 847 | - $account_arr['did_monthlycost'] = $this->common_model->to_calculate_currency($did_arr['monthlycost'], "", '', true,true); |
|
| 847 | + $account_arr['did_monthlycost'] = $this->common_model->to_calculate_currency($did_arr['monthlycost'], "", '', true, true); |
|
| 848 | 848 | $account_arr['did_maxchannels'] = $did_arr['maxchannels']; |
| 849 | 849 | |
| 850 | 850 | $this->common->mail_to_users('email_add_did', $account_arr); |
@@ -867,12 +867,12 @@ discard block |
||
| 867 | 867 | $this->db->where('note', $did_arr['number']); |
| 868 | 868 | $this->db->delete('reseller_pricing'); |
| 869 | 869 | } |
| 870 | - $account_arr['did_number']=$did_arr['number']; |
|
| 870 | + $account_arr['did_number'] = $did_arr['number']; |
|
| 871 | 871 | $this->common->mail_to_users('email_remove_did', $account_arr); |
| 872 | 872 | $this->session->set_flashdata('astpp_notification', 'Did Removed Successfully.'); |
| 873 | 873 | } |
| 874 | 874 | } |
| 875 | - redirect(base_url() . "accounts/" . $accounttype . "_dids/$accountid/"); |
|
| 875 | + redirect(base_url()."accounts/".$accounttype."_dids/$accountid/"); |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | function provider_invoices($edit_id) { |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 893 | 893 | $account_res = $this->db_model->getSelect("type", "accounts", $where); |
| 894 | 894 | if ($account_res->num_rows > 0) { |
| 895 | - $account_data = (array) $account_res->first_row(); |
|
| 895 | + $account_data = (array)$account_res->first_row(); |
|
| 896 | 896 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 897 | 897 | $this->load->module('invoices/invoices'); |
| 898 | 898 | $data['grid_fields'] = $this->invoices->invoices_form->build_invoices_list_for_customer_admin(false); |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | $data['accounttype'] = $accounttype; |
| 901 | 901 | $this->load->view('view_customer_invoices', $data); |
| 902 | 902 | } else { |
| 903 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 903 | + redirect(base_url().'accounts/customer_list/'); |
|
| 904 | 904 | exit; |
| 905 | 905 | } |
| 906 | 906 | } |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 919 | 919 | $account_res = $this->db_model->getSelect("type", "accounts", $where); |
| 920 | 920 | if ($account_res->num_rows > 0) { |
| 921 | - $account_data = (array) $account_res->first_row(); |
|
| 921 | + $account_data = (array)$account_res->first_row(); |
|
| 922 | 922 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 923 | 923 | $this->load->module('rates/rates'); |
| 924 | 924 | $data['grid_fields'] = $this->rates->rates_form->build_pattern_list_for_customer($edit_id, $accounttype); |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | $data['accounttype'] = $accounttype; |
| 928 | 928 | $this->load->view('view_customer_blocked_prefixes', $data); |
| 929 | 929 | } else { |
| 930 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 930 | + redirect(base_url().'accounts/customer_list/'); |
|
| 931 | 931 | exit; |
| 932 | 932 | } |
| 933 | 933 | } |
@@ -968,16 +968,16 @@ discard block |
||
| 968 | 968 | function customer_delete_block_pattern($accountid, $patternid) { |
| 969 | 969 | $entity_type = $this->common->get_field_name('type', 'accounts', array('id' => $accountid)); |
| 970 | 970 | $entity_type = strtolower($this->common->get_entity_type('', '', $entity_type)); |
| 971 | - $url = "accounts/" . $entity_type . "_blocked_prefixes/$accountid"; |
|
| 971 | + $url = "accounts/".$entity_type."_blocked_prefixes/$accountid"; |
|
| 972 | 972 | $this->db_model->delete("block_patterns", array("id" => $patternid)); |
| 973 | 973 | $this->session->set_flashdata('astpp_notification', 'Block Code Removed Sucessfully!'); |
| 974 | 974 | |
| 975 | - redirect(base_url() . $url); |
|
| 975 | + redirect(base_url().$url); |
|
| 976 | 976 | } |
| 977 | - function customer_blockedprefixes_delete_multiple(){ |
|
| 977 | + function customer_blockedprefixes_delete_multiple() { |
|
| 978 | 978 | $ids = $this->input->post("selected_ids", true); |
| 979 | 979 | $where = "id IN ($ids)"; |
| 980 | - $this->db->delete("block_patterns",$where); |
|
| 980 | + $this->db->delete("block_patterns", $where); |
|
| 981 | 981 | echo TRUE; |
| 982 | 982 | } |
| 983 | 983 | |
@@ -1012,7 +1012,7 @@ discard block |
||
| 1012 | 1012 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 1013 | 1013 | $account_res = $this->db_model->getSelect("type", "accounts", $where); |
| 1014 | 1014 | if ($account_res->num_rows > 0) { |
| 1015 | - $account_data = (array) $account_res->first_row(); |
|
| 1015 | + $account_data = (array)$account_res->first_row(); |
|
| 1016 | 1016 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 1017 | 1017 | $this->load->module('reports/reports'); |
| 1018 | 1018 | $data['grid_fields'] = $this->reports->reports_form->build_report_list_for_user($accounttype); |
@@ -1020,7 +1020,7 @@ discard block |
||
| 1020 | 1020 | $data['accounttype'] = $accounttype; |
| 1021 | 1021 | $this->load->view('view_customer_cdrs_list', $data); |
| 1022 | 1022 | } else { |
| 1023 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1023 | + redirect(base_url().'accounts/customer_list/'); |
|
| 1024 | 1024 | exit; |
| 1025 | 1025 | } |
| 1026 | 1026 | } |
@@ -1029,27 +1029,27 @@ discard block |
||
| 1029 | 1029 | /* ASTPP 3.0 |
| 1030 | 1030 | * Using for provider refillreporttab. |
| 1031 | 1031 | */ |
| 1032 | - function reseller_packages($edit_id){ |
|
| 1032 | + function reseller_packages($edit_id) { |
|
| 1033 | 1033 | $data['page_title'] = "Packages"; |
| 1034 | 1034 | $accountinfo = $this->session->userdata('accountinfo'); |
| 1035 | 1035 | $reseller_id = ($accountinfo['type'] == 1 || $accountinfo['type'] == 5) ? $accountinfo['id'] : 0; |
| 1036 | 1036 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 1037 | 1037 | $account_res = $this->db_model->getSelect("type", "accounts", $where); |
| 1038 | 1038 | if ($account_res->num_rows > 0) { |
| 1039 | - $account_data = (array) $account_res->first_row(); |
|
| 1039 | + $account_data = (array)$account_res->first_row(); |
|
| 1040 | 1040 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 1041 | 1041 | $this->load->module('package/package'); |
| 1042 | 1042 | $data['grid_fields'] = $this->package->package_form->build_package_list_for_reseller(); |
| 1043 | 1043 | $data['edit_id'] = $edit_id; |
| 1044 | 1044 | $data['accounttype'] = $accounttype; |
| 1045 | 1045 | $this->load->view('view_reseller_package_list', $data); |
| 1046 | - }else { |
|
| 1047 | - redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1046 | + } else { |
|
| 1047 | + redirect(base_url().'accounts/reseller_list/'); |
|
| 1048 | 1048 | exit; |
| 1049 | 1049 | } |
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | - function reseller_refillreport($edit_id){ |
|
| 1052 | + function reseller_refillreport($edit_id) { |
|
| 1053 | 1053 | $this->customer_refillreport($edit_id); |
| 1054 | 1054 | } |
| 1055 | 1055 | function provider_refillreport($edit_id) { |
@@ -1070,7 +1070,7 @@ discard block |
||
| 1070 | 1070 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 1071 | 1071 | $account_res = $this->db_model->getSelect("type", "accounts", $where); |
| 1072 | 1072 | if ($account_res->num_rows > 0) { |
| 1073 | - $account_data = (array) $account_res->first_row(); |
|
| 1073 | + $account_data = (array)$account_res->first_row(); |
|
| 1074 | 1074 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 1075 | 1075 | $this->load->module('reports/reports'); |
| 1076 | 1076 | $data['grid_fields'] = $this->reports->reports_form->build_refillreport_for_customer(); |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | $data['accounttype'] = $accounttype; |
| 1079 | 1079 | $this->load->view('view_customer_refill_report', $data); |
| 1080 | 1080 | } else { |
| 1081 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1081 | + redirect(base_url().'accounts/customer_list/'); |
|
| 1082 | 1082 | exit; |
| 1083 | 1083 | } |
| 1084 | 1084 | } |
@@ -1108,7 +1108,7 @@ discard block |
||
| 1108 | 1108 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 1109 | 1109 | $account_res = $this->db_model->getSelect("type", "accounts", $where); |
| 1110 | 1110 | if ($account_res->num_rows > 0) { |
| 1111 | - $account_data = (array) $account_res->first_row(); |
|
| 1111 | + $account_data = (array)$account_res->first_row(); |
|
| 1112 | 1112 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 1113 | 1113 | $this->load->module('email/email'); |
| 1114 | 1114 | $data['grid_fields'] = $this->email->email_form->build_list_for_email_customer($edit_id, $accounttype); |
@@ -1116,7 +1116,7 @@ discard block |
||
| 1116 | 1116 | $data['accounttype'] = $accounttype; |
| 1117 | 1117 | $this->load->view('view_customer_email_history', $data); |
| 1118 | 1118 | } else { |
| 1119 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1119 | + redirect(base_url().'accounts/customer_list/'); |
|
| 1120 | 1120 | exit; |
| 1121 | 1121 | } |
| 1122 | 1122 | } |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | $where = array('id' => $edit_id, "reseller_id" => $reseller_id); |
| 1148 | 1148 | $account_res = $this->db_model->getSelect("notify_credit_limit,notify_flag,notify_email,type,id", "accounts", $where); |
| 1149 | 1149 | if ($account_res->num_rows > 0) { |
| 1150 | - $account_data = (array) $account_res->first_row(); |
|
| 1150 | + $account_data = (array)$account_res->first_row(); |
|
| 1151 | 1151 | $accounttype = strtolower($this->common->get_entity_type('', '', $account_data['type'])); |
| 1152 | 1152 | unset($account_data['type']); |
| 1153 | 1153 | $data['form'] = $this->form->build_form($this->accounts_form->customer_alert_threshold($accounttype), $account_data); |
@@ -1155,7 +1155,7 @@ discard block |
||
| 1155 | 1155 | $data['accounttype'] = $accounttype; |
| 1156 | 1156 | $this->load->view('view_customer_alert_threshold', $data); |
| 1157 | 1157 | } else { |
| 1158 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1158 | + redirect(base_url().'accounts/customer_list/'); |
|
| 1159 | 1159 | exit; |
| 1160 | 1160 | } |
| 1161 | 1161 | } |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | |
| 1169 | 1169 | function customer_alert_threshold_save($entity_type) { |
| 1170 | 1170 | $add_array = $this->input->post(); |
| 1171 | - if (isset($add_array['id']) && !empty($add_array['id'])) { |
|
| 1171 | + if (isset($add_array['id']) && ! empty($add_array['id'])) { |
|
| 1172 | 1172 | $data['page_title'] = "Alert Threshold"; |
| 1173 | 1173 | $data['form'] = $this->form->build_form($this->accounts_form->customer_alert_threshold($entity_type), $add_array); |
| 1174 | 1174 | $data['edit_id'] = $add_array['id']; |
@@ -1184,38 +1184,38 @@ discard block |
||
| 1184 | 1184 | $data['validation_errors'] = validation_errors(); |
| 1185 | 1185 | } else { |
| 1186 | 1186 | $this->db->where('id', $add_array['id']); |
| 1187 | - $id=$add_array['id']; |
|
| 1187 | + $id = $add_array['id']; |
|
| 1188 | 1188 | unset($add_array['id'], $add_array['action']); |
| 1189 | 1189 | $this->db->update('accounts', $add_array); |
| 1190 | - $this->session->set_flashdata('astpp_errormsg','Alert threshold updated successfully!'); |
|
| 1191 | - redirect(base_url() . 'accounts/'.$entity_type.'_alert_threshold/'.$id."/"); |
|
| 1190 | + $this->session->set_flashdata('astpp_errormsg', 'Alert threshold updated successfully!'); |
|
| 1191 | + redirect(base_url().'accounts/'.$entity_type.'_alert_threshold/'.$id."/"); |
|
| 1192 | 1192 | exit; |
| 1193 | 1193 | } |
| 1194 | 1194 | } else { |
| 1195 | - redirect(base_url() . 'accounts/'.$entity_type.'_list/'); |
|
| 1195 | + redirect(base_url().'accounts/'.$entity_type.'_list/'); |
|
| 1196 | 1196 | exit; |
| 1197 | 1197 | } |
| 1198 | 1198 | $this->load->view('view_customer_alert_threshold', $data); |
| 1199 | 1199 | } else { |
| 1200 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1200 | + redirect(base_url().'accounts/customer_list/'); |
|
| 1201 | 1201 | exit; |
| 1202 | 1202 | } |
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | function customer_bulk_creation() { |
| 1206 | - $type=0; |
|
| 1206 | + $type = 0; |
|
| 1207 | 1207 | $data['entity_name'] = strtolower($this->common->get_entity_type('', '', $type)); |
| 1208 | 1208 | $data['page_title'] = 'Mass Customer'; |
| 1209 | 1209 | $data['country_id'] = Common_model::$global_config['system_config']['country']; |
| 1210 | 1210 | $data['currency_id'] = $this->common->get_field_name('id', 'currency', array('currency' => Common_model::$global_config['system_config']['base_currency'])); |
| 1211 | 1211 | $data['timezone_id'] = Common_model::$global_config['system_config']['default_timezone']; |
| 1212 | - if (!$data['timezone_id']) { |
|
| 1212 | + if ( ! $data['timezone_id']) { |
|
| 1213 | 1213 | $data['timezone_id'] = 1; |
| 1214 | 1214 | } |
| 1215 | - if (!$data['currency_id']) { |
|
| 1215 | + if ( ! $data['currency_id']) { |
|
| 1216 | 1216 | $data['currency_id'] = 1; |
| 1217 | 1217 | } |
| 1218 | - if (!$data['country_id']) { |
|
| 1218 | + if ( ! $data['country_id']) { |
|
| 1219 | 1219 | $data['country_id'] = 1; |
| 1220 | 1220 | } |
| 1221 | 1221 | $data['form'] = $this->form->build_form($this->accounts_form->customer_bulk_generate_form(), ''); |
@@ -1225,17 +1225,17 @@ discard block |
||
| 1225 | 1225 | function customer_bulk_save() { |
| 1226 | 1226 | $data['page_title'] = 'Create Bulk Customer'; |
| 1227 | 1227 | $add_array = $this->input->post(); |
| 1228 | - if (!empty($add_array) && isset($add_array)) { |
|
| 1228 | + if ( ! empty($add_array) && isset($add_array)) { |
|
| 1229 | 1229 | $currentlength = $this->accounts_model->get_max_limit($add_array); |
| 1230 | 1230 | $account_data = $this->session->userdata("accountinfo"); |
| 1231 | - $add_array['reseller_id'] = $account_data['type']==1 ? $account_data['id']:0; |
|
| 1231 | + $add_array['reseller_id'] = $account_data['type'] == 1 ? $account_data['id'] : 0; |
|
| 1232 | 1232 | $data['form'] = $this->form->build_form($this->accounts_form->customer_bulk_generate_form(), $add_array); |
| 1233 | 1233 | if ($this->form_validation->run() == FALSE) { |
| 1234 | 1234 | $data['validation_errors'] = validation_errors(); |
| 1235 | 1235 | echo $data['validation_errors']; |
| 1236 | 1236 | exit; |
| 1237 | 1237 | } |
| 1238 | - if($currentlength <= 0){ |
|
| 1238 | + if ($currentlength <= 0) { |
|
| 1239 | 1239 | echo json_encode(array("prefix_error" => "Your Account Limit has been reached.Please Change Your Prefix.")); |
| 1240 | 1240 | exit; |
| 1241 | 1241 | } |
@@ -1244,7 +1244,7 @@ discard block |
||
| 1244 | 1244 | exit; |
| 1245 | 1245 | } |
| 1246 | 1246 | if ($currentlength > 0 && $add_array['count'] > $currentlength) { |
| 1247 | - echo json_encode(array("count_error" => "You Can Create Maximum " . $currentlength . " accounts with " . $add_array['prefix'] . " prefix")); |
|
| 1247 | + echo json_encode(array("count_error" => "You Can Create Maximum ".$currentlength." accounts with ".$add_array['prefix']." prefix")); |
|
| 1248 | 1248 | exit; |
| 1249 | 1249 | } else { |
| 1250 | 1250 | $this->accounts_model->bulk_insert_accounts($add_array); |
@@ -1252,7 +1252,7 @@ discard block |
||
| 1252 | 1252 | exit; |
| 1253 | 1253 | } |
| 1254 | 1254 | } else { |
| 1255 | - redirect(base_url() . "accounts/customer_list/"); |
|
| 1255 | + redirect(base_url()."accounts/customer_list/"); |
|
| 1256 | 1256 | } |
| 1257 | 1257 | } |
| 1258 | 1258 | |
@@ -1269,13 +1269,13 @@ discard block |
||
| 1269 | 1269 | |
| 1270 | 1270 | function customer_did_country() { |
| 1271 | 1271 | $country_id = $_POST['country_id']; |
| 1272 | - $accountid= $this->input->post('accountid',true); |
|
| 1272 | + $accountid = $this->input->post('accountid', true); |
|
| 1273 | 1273 | $accountinfo = $this->session->userdata("accountinfo"); |
| 1274 | - $entity_info=(array)$this->db->get_where('accounts',array("id"=>$accountid))->first_row(); |
|
| 1274 | + $entity_info = (array)$this->db->get_where('accounts', array("id"=>$accountid))->first_row(); |
|
| 1275 | 1275 | $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
| 1276 | 1276 | if ($entity_info['reseller_id'] > 0) { |
| 1277 | 1277 | $parent_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : $accountinfo['reseller_id']; |
| 1278 | - $query = 'select dids.id as id,dids.number as number,reseller_pricing.setup as setup, reseller_pricing.monthlycost as monthlycost from dids,reseller_pricing where dids.number= reseller_pricing.note and reseller_pricing.reseller_id =' . $parent_id . " and dids.accountid=0 and dids.country_id =" . $country_id; |
|
| 1278 | + $query = 'select dids.id as id,dids.number as number,reseller_pricing.setup as setup, reseller_pricing.monthlycost as monthlycost from dids,reseller_pricing where dids.number= reseller_pricing.note and reseller_pricing.reseller_id ='.$parent_id." and dids.accountid=0 and dids.country_id =".$country_id; |
|
| 1279 | 1279 | $did_list = $this->db->query($query); |
| 1280 | 1280 | } else { |
| 1281 | 1281 | $did_list = $this->db_model->getSelect("id,number,setup,monthlycost", "dids", array('country_id' => $country_id, 'accountid' => '0', 'parent_id' => $reseller_id)); |
@@ -1284,7 +1284,7 @@ discard block |
||
| 1284 | 1284 | if ($did_list->num_rows > 0) { |
| 1285 | 1285 | $did_data = $did_list->result_array(); |
| 1286 | 1286 | foreach ($did_data as $key => $value) { |
| 1287 | - $did_arr[$value['id']] = $value['number'] . " (Setup Cost : " . $this->common_model->calculate_currency($value['setup'], '', '', true) . ") (Monthly cost : " . $this->common_model->calculate_currency($value['monthlycost'], '', '', true) . ")"; |
|
| 1287 | + $did_arr[$value['id']] = $value['number']." (Setup Cost : ".$this->common_model->calculate_currency($value['setup'], '', '', true).") (Monthly cost : ".$this->common_model->calculate_currency($value['monthlycost'], '', '', true).")"; |
|
| 1288 | 1288 | } |
| 1289 | 1289 | } |
| 1290 | 1290 | $did_info = array("name" => "free_didlist", "id" => "free_didlist", "class" => "free_didlist"); |
@@ -1319,28 +1319,28 @@ discard block |
||
| 1319 | 1319 | $username = $this->session->userdata('username'); |
| 1320 | 1320 | $login_user_data = $this->session->userdata("accountinfo"); |
| 1321 | 1321 | $accountinfo = $this->accounts_model->get_account_by_number($post_array['id']); |
| 1322 | - if($accountinfo['reseller_id'] == 0){ |
|
| 1322 | + if ($accountinfo['reseller_id'] == 0) { |
|
| 1323 | 1323 | $where = array("accountid"=> 1); |
| 1324 | - }else{ |
|
| 1324 | + } else { |
|
| 1325 | 1325 | $where = array("accountid"=> $accountinfo['id']); |
| 1326 | 1326 | } |
| 1327 | 1327 | $query = $this->db_model->getSelect("*", "invoice_conf", $where); |
| 1328 | - if($query->num_rows >0){ |
|
| 1328 | + if ($query->num_rows > 0) { |
|
| 1329 | 1329 | $invoice_conf = $query->result_array(); |
| 1330 | 1330 | $invoice_conf = $invoice_conf[0]; |
| 1331 | - }else{ |
|
| 1332 | - $query = $this->db_model->getSelect("*", "invoice_conf",array("accountid"=> 1)); |
|
| 1331 | + } else { |
|
| 1332 | + $query = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> 1)); |
|
| 1333 | 1333 | $invoice_conf = $query->result_array(); |
| 1334 | 1334 | $invoice_conf = $invoice_conf[0]; |
| 1335 | 1335 | } |
| 1336 | - $last_invoice_ID = $this->get_invoice_date("invoiceid",$accountinfo["id"]); |
|
| 1337 | - $invoice_prefix=$invoice_conf['invoice_prefix']; |
|
| 1338 | - $due_date = gmdate("Y-m-d H:i:s",strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf['interval']." days")); |
|
| 1336 | + $last_invoice_ID = $this->get_invoice_date("invoiceid", $accountinfo["id"]); |
|
| 1337 | + $invoice_prefix = $invoice_conf['invoice_prefix']; |
|
| 1338 | + $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf['interval']." days")); |
|
| 1339 | 1339 | $response = $this->accounts_model->account_process_payment($post_array); |
| 1340 | 1340 | |
| 1341 | - if($post_array['payment_type']== 1 ){ |
|
| 1341 | + if ($post_array['payment_type'] == 1) { |
|
| 1342 | 1342 | $this->load->module('invoices/invoices'); |
| 1343 | - $invoice_id=$this->invoices->invoices->generate_receipt($post_array['id'],$post_array['credit'],$accountinfo,$last_invoice_ID+1,$invoice_prefix,$due_date); |
|
| 1343 | + $invoice_id = $this->invoices->invoices->generate_receipt($post_array['id'], $post_array['credit'], $accountinfo, $last_invoice_ID + 1, $invoice_prefix, $due_date); |
|
| 1344 | 1344 | $account_balance = $this->common->get_field_name('balance', 'accounts', $post_array['id']); |
| 1345 | 1345 | $insert_arr = array("accountid" => $post_array['id'], |
| 1346 | 1346 | "description" => trim($post_array['notes']), |
@@ -1351,13 +1351,13 @@ discard block |
||
| 1351 | 1351 | "reseller_id"=>'0', |
| 1352 | 1352 | "item_type"=>'POSTCHARG', |
| 1353 | 1353 | "item_id"=>'0', |
| 1354 | - 'before_balance'=>$account_balance+$post_array['credit'], |
|
| 1354 | + 'before_balance'=>$account_balance + $post_array['credit'], |
|
| 1355 | 1355 | 'after_balance'=>$account_balance, |
| 1356 | 1356 | ); |
| 1357 | 1357 | $this->db->insert("invoice_details", $insert_arr); |
| 1358 | - }else{ |
|
| 1358 | + } else { |
|
| 1359 | 1359 | $this->load->module('invoices/invoices'); |
| 1360 | - $invoice_id=$this->invoices->invoices->generate_receipt($post_array['id'],$post_array['credit'],$accountinfo,$last_invoice_ID+1,$invoice_prefix,$due_date); |
|
| 1360 | + $invoice_id = $this->invoices->invoices->generate_receipt($post_array['id'], $post_array['credit'], $accountinfo, $last_invoice_ID + 1, $invoice_prefix, $due_date); |
|
| 1361 | 1361 | $account_balance = $this->common->get_field_name('balance', 'accounts', $post_array['id']); |
| 1362 | 1362 | $insert_arr = array("accountid" => $post_array['id'], |
| 1363 | 1363 | "description" => trim($post_array['notes']), |
@@ -1368,22 +1368,22 @@ discard block |
||
| 1368 | 1368 | "reseller_id"=>$accountinfo['reseller_id'], |
| 1369 | 1369 | "item_type"=>'Refill', |
| 1370 | 1370 | "item_id"=>'0', |
| 1371 | - 'before_balance'=>$account_balance-$post_array['credit'], |
|
| 1371 | + 'before_balance'=>$account_balance - $post_array['credit'], |
|
| 1372 | 1372 | 'after_balance'=>$account_balance, |
| 1373 | 1373 | ); |
| 1374 | 1374 | $this->db->insert("invoice_details", $insert_arr); |
| 1375 | - if($login_user_data['type'] ==1){ |
|
| 1376 | - $reseller_ids=$this->common->get_parent_info($login_user_data['id'],0); |
|
| 1377 | - $reseller_ids=rtrim($reseller_ids,","); |
|
| 1378 | - $reseller_arr=explode(",",$reseller_ids); |
|
| 1379 | - if(!empty($reseller_arr)){ |
|
| 1380 | - $custom_array=$post_array; |
|
| 1381 | - foreach($reseller_arr as $key=>$reseller_id){ |
|
| 1382 | - $custom_array['id']=$reseller_id; |
|
| 1375 | + if ($login_user_data['type'] == 1) { |
|
| 1376 | + $reseller_ids = $this->common->get_parent_info($login_user_data['id'], 0); |
|
| 1377 | + $reseller_ids = rtrim($reseller_ids, ","); |
|
| 1378 | + $reseller_arr = explode(",", $reseller_ids); |
|
| 1379 | + if ( ! empty($reseller_arr)) { |
|
| 1380 | + $custom_array = $post_array; |
|
| 1381 | + foreach ($reseller_arr as $key=>$reseller_id) { |
|
| 1382 | + $custom_array['id'] = $reseller_id; |
|
| 1383 | 1383 | $response = $this->accounts_model->account_process_payment($custom_array); |
| 1384 | - $reseller_info=(array)$this->db->get_where('accounts',array("id"=>$reseller_id))->first_row(); |
|
| 1385 | - $last_invoice_ID = $this->get_invoice_date("invoiceid",$reseller_info["id"]); |
|
| 1386 | - $invoice_id=$this->invoices->invoices->generate_receipt($reseller_info['id'],$custom_array['credit'],$reseller_info,$last_invoice_ID+1,$invoice_prefix,$due_date); |
|
| 1384 | + $reseller_info = (array)$this->db->get_where('accounts', array("id"=>$reseller_id))->first_row(); |
|
| 1385 | + $last_invoice_ID = $this->get_invoice_date("invoiceid", $reseller_info["id"]); |
|
| 1386 | + $invoice_id = $this->invoices->invoices->generate_receipt($reseller_info['id'], $custom_array['credit'], $reseller_info, $last_invoice_ID + 1, $invoice_prefix, $due_date); |
|
| 1387 | 1387 | $account_balance = $this->common->get_field_name('balance', 'accounts', $reseller_info['id']); |
| 1388 | 1388 | $insert_arr = array("accountid" => $reseller_info['id'], |
| 1389 | 1389 | "description" => trim($custom_array['notes']), |
@@ -1394,7 +1394,7 @@ discard block |
||
| 1394 | 1394 | "reseller_id"=>$reseller_info['reseller_id'], |
| 1395 | 1395 | "item_type"=>'Refill', |
| 1396 | 1396 | "item_id"=>'0', |
| 1397 | - 'before_balance'=>$account_balance-$custom_array['credit'], |
|
| 1397 | + 'before_balance'=>$account_balance - $custom_array['credit'], |
|
| 1398 | 1398 | 'after_balance'=>$account_balance, |
| 1399 | 1399 | ); |
| 1400 | 1400 | $this->db->insert("invoice_details", $insert_arr); |
@@ -1402,7 +1402,7 @@ discard block |
||
| 1402 | 1402 | } |
| 1403 | 1403 | } |
| 1404 | 1404 | } |
| 1405 | - $message = $post_array['payment_type']== 0 ? "Recharge successfully!" : "Post charge applied successfully."; |
|
| 1405 | + $message = $post_array['payment_type'] == 0 ? "Recharge successfully!" : "Post charge applied successfully."; |
|
| 1406 | 1406 | /***********************************************************************************************/ |
| 1407 | 1407 | echo json_encode(array("SUCCESS"=> $message)); |
| 1408 | 1408 | exit; |
@@ -1410,11 +1410,11 @@ discard block |
||
| 1410 | 1410 | } |
| 1411 | 1411 | $this->load->view('view_accounts_process_payment', $data); |
| 1412 | 1412 | } |
| 1413 | - function get_invoice_date($select,$accountid){ |
|
| 1414 | - $query = $this->db_model->select($select, "invoices", '',"id","DESC","1","0"); |
|
| 1415 | - if($query->num_rows >0){ |
|
| 1413 | + function get_invoice_date($select, $accountid) { |
|
| 1414 | + $query = $this->db_model->select($select, "invoices", '', "id", "DESC", "1", "0"); |
|
| 1415 | + if ($query->num_rows > 0) { |
|
| 1416 | 1416 | $invoiceid = $query->result_array(); |
| 1417 | - $invoice_date=$invoiceid[0][$select]; |
|
| 1417 | + $invoice_date = $invoiceid[0][$select]; |
|
| 1418 | 1418 | return $invoice_date; |
| 1419 | 1419 | } |
| 1420 | 1420 | return false; |
@@ -1451,7 +1451,7 @@ discard block |
||
| 1451 | 1451 | $data['form'] = $this->form->build_form($this->accounts_form->get_customer_callerid_fields(), $data); |
| 1452 | 1452 | $post_array = $this->input->post(); |
| 1453 | 1453 | |
| 1454 | - if (!empty($post_array)) { |
|
| 1454 | + if ( ! empty($post_array)) { |
|
| 1455 | 1455 | if ($this->form_validation->run() == FALSE) { |
| 1456 | 1456 | $data['validation_errors'] = validation_errors(); |
| 1457 | 1457 | echo $data['validation_errors']; |
@@ -1480,13 +1480,13 @@ discard block |
||
| 1480 | 1480 | $data['country_id'] = $accountinfo['country_id']; |
| 1481 | 1481 | $data['currency_id'] = $accountinfo['currency_id']; |
| 1482 | 1482 | $data['timezone_id'] = $accountinfo['timezone_id']; |
| 1483 | - if (!$data['timezone_id']) { |
|
| 1483 | + if ( ! $data['timezone_id']) { |
|
| 1484 | 1484 | $data['timezone_id'] = 1; |
| 1485 | 1485 | } |
| 1486 | - if (!$data['currency_id']) { |
|
| 1486 | + if ( ! $data['currency_id']) { |
|
| 1487 | 1487 | $data['currency_id'] = 1; |
| 1488 | 1488 | } |
| 1489 | - if (!$data['country_id']) { |
|
| 1489 | + if ( ! $data['country_id']) { |
|
| 1490 | 1490 | $data['country_id'] = 1; |
| 1491 | 1491 | } |
| 1492 | 1492 | |
@@ -1514,17 +1514,17 @@ discard block |
||
| 1514 | 1514 | * */ |
| 1515 | 1515 | $encrypted_string = $this->common->encode($edit_data['id']); |
| 1516 | 1516 | $encrypt = $this->common->encode_params($encrypted_string); |
| 1517 | - $edit_data['registration_url'] = base_url() . "signup/" . $encrypt; |
|
| 1517 | + $edit_data['registration_url'] = base_url()."signup/".$encrypt; |
|
| 1518 | 1518 | /* * *********************************************************** */ |
| 1519 | 1519 | /* * *** |
| 1520 | 1520 | ASTPP 3.0 |
| 1521 | 1521 | Password decode |
| 1522 | 1522 | * **** */ |
| 1523 | 1523 | $edit_data['password'] = $this->common->decode($edit_data['password']); |
| 1524 | - $edit_data['credit_limit']=$this->common_model->calculate_currency(($edit_data['credit_limit']),'','',true,false); |
|
| 1524 | + $edit_data['credit_limit'] = $this->common_model->calculate_currency(($edit_data['credit_limit']), '', '', true, false); |
|
| 1525 | 1525 | $entity_name = strtolower($this->common->get_entity_type('', '', $edit_data['type'])); |
| 1526 | - $data['edit_id']=$edit_id; |
|
| 1527 | - $data['page_title'] =ucfirst($entity_name)." Profile"; |
|
| 1526 | + $data['edit_id'] = $edit_id; |
|
| 1527 | + $data['page_title'] = ucfirst($entity_name)." Profile"; |
|
| 1528 | 1528 | $data['entity_name'] = $entity_name; |
| 1529 | 1529 | /* * ********************** */ |
| 1530 | 1530 | $data['form'] = $this->form->build_form($this->accounts_form->get_form_reseller_fields($edit_id), $edit_data); |
@@ -1540,7 +1540,7 @@ discard block |
||
| 1540 | 1540 | $data['timezone_id'] = $add_array['timezone_id']; |
| 1541 | 1541 | $data['currency_id'] = $add_array['currency_id']; |
| 1542 | 1542 | $data['entity_name'] = $entity_name; |
| 1543 | - $data['edit_id']=$add_array['id']; |
|
| 1543 | + $data['edit_id'] = $add_array['id']; |
|
| 1544 | 1544 | $data['form'] = $this->form->build_form($this->accounts_form->get_form_reseller_fields($add_array['id']), $add_array); |
| 1545 | 1545 | if ($add_array['id'] != '') { |
| 1546 | 1546 | $data['page_title'] = 'Edit Reseller'; |
@@ -1565,11 +1565,11 @@ discard block |
||
| 1565 | 1565 | } |
| 1566 | 1566 | unset($add_array['tax_id']); |
| 1567 | 1567 | } |
| 1568 | - unset($add_array['number'],$add_array['registration_url']); |
|
| 1568 | + unset($add_array['number'], $add_array['registration_url']); |
|
| 1569 | 1569 | $this->accounts_model->edit_account($add_array, $add_array['id']); |
| 1570 | 1570 | $this->session->set_flashdata('astpp_errormsg', 'Reseller updated successfully!'); |
| 1571 | 1571 | |
| 1572 | - redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1572 | + redirect(base_url().'accounts/reseller_list/'); |
|
| 1573 | 1573 | exit; |
| 1574 | 1574 | } |
| 1575 | 1575 | $data["account_data"]["0"] = $add_array; |
@@ -1617,7 +1617,7 @@ discard block |
||
| 1617 | 1617 | unset($add_array['tax_id']); |
| 1618 | 1618 | } |
| 1619 | 1619 | $this->session->set_flashdata('astpp_errormsg', 'Reseller added successfully!'); |
| 1620 | - redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1620 | + redirect(base_url().'accounts/reseller_list/'); |
|
| 1621 | 1621 | exit; |
| 1622 | 1622 | } |
| 1623 | 1623 | $this->load->view('view_accounts_create', $data); |
@@ -1632,7 +1632,7 @@ discard block |
||
| 1632 | 1632 | echo $this->common->generate_password(); |
| 1633 | 1633 | } |
| 1634 | 1634 | |
| 1635 | - function customer_generate_number($digit='') { |
|
| 1635 | + function customer_generate_number($digit = '') { |
|
| 1636 | 1636 | |
| 1637 | 1637 | echo $this->common->find_uniq_rendno($digit, 'number', 'accounts'); |
| 1638 | 1638 | } |
@@ -1643,19 +1643,19 @@ discard block |
||
| 1643 | 1643 | $entitytype = str_replace(' ', '', $entity_type); |
| 1644 | 1644 | $data['username'] = $this->session->userdata('user_name'); |
| 1645 | 1645 | $data['flag'] = 'create'; |
| 1646 | - $data['page_title'] = 'Create ' . ucfirst($entity_type); |
|
| 1646 | + $data['page_title'] = 'Create '.ucfirst($entity_type); |
|
| 1647 | 1647 | $data['back_flag'] = true; |
| 1648 | 1648 | $data['form'] = $this->form->build_form($this->accounts_form->get_form_admin_fields($entitytype), ''); |
| 1649 | 1649 | $data['country_id'] = $accountinfo['country_id']; |
| 1650 | 1650 | $data['currency_id'] = $accountinfo['currency_id']; |
| 1651 | 1651 | $data['timezone_id'] = $accountinfo['timezone_id']; |
| 1652 | - if (!$data['timezone_id']) { |
|
| 1652 | + if ( ! $data['timezone_id']) { |
|
| 1653 | 1653 | $data['timezone_id'] = 1; |
| 1654 | 1654 | } |
| 1655 | - if (!$data['currency_id']) { |
|
| 1655 | + if ( ! $data['currency_id']) { |
|
| 1656 | 1656 | $data['currency_id'] = 1; |
| 1657 | 1657 | } |
| 1658 | - if (!$data['country_id']) { |
|
| 1658 | + if ( ! $data['country_id']) { |
|
| 1659 | 1659 | $data['country_id'] = 1; |
| 1660 | 1660 | } |
| 1661 | 1661 | $data['entity_name'] = $entity_type; |
@@ -1664,13 +1664,13 @@ discard block |
||
| 1664 | 1664 | |
| 1665 | 1665 | function admin_edit($edit_id = '') { |
| 1666 | 1666 | $data['back_flag'] = true; |
| 1667 | - $accountinfo=(array)$this->db->get_where('accounts',array("id"=>$edit_id))->first_row(); |
|
| 1667 | + $accountinfo = (array)$this->db->get_where('accounts', array("id"=>$edit_id))->first_row(); |
|
| 1668 | 1668 | $type = $accountinfo['type'] == -1 ? 2 : $accountinfo['type']; |
| 1669 | 1669 | $entity_type = strtolower($this->common->get_entity_type('', '', $type)); |
| 1670 | 1670 | $entitytype = str_replace(' ', '', $entity_type); |
| 1671 | 1671 | $accountinfo['password'] = $this->common->decode($accountinfo['password']); |
| 1672 | 1672 | $data['form'] = $this->form->build_form($this->accounts_form->get_form_admin_fields($entitytype, $edit_id), $accountinfo); |
| 1673 | - $data['page_title'] = 'Edit ' . ucfirst($entity_type); |
|
| 1673 | + $data['page_title'] = 'Edit '.ucfirst($entity_type); |
|
| 1674 | 1674 | $this->load->view('view_admin_details', $data); |
| 1675 | 1675 | |
| 1676 | 1676 | } |
@@ -1683,10 +1683,10 @@ discard block |
||
| 1683 | 1683 | $entitytype = str_replace(' ', '', $entity_type); |
| 1684 | 1684 | $data['username'] = $this->session->userdata('user_name'); |
| 1685 | 1685 | $data['flag'] = 'create'; |
| 1686 | - $data['page_title'] = 'Create ' . $entity_type; |
|
| 1686 | + $data['page_title'] = 'Create '.$entity_type; |
|
| 1687 | 1687 | $data['form'] = $this->form->build_form($this->accounts_form->get_form_admin_fields($entitytype, $add_array['id']), $add_array); |
| 1688 | 1688 | if ($add_array['id'] != '') { |
| 1689 | - $data['page_title'] = 'Edit ' . $entity_type; |
|
| 1689 | + $data['page_title'] = 'Edit '.$entity_type; |
|
| 1690 | 1690 | if ($this->form_validation->run() == FALSE) { |
| 1691 | 1691 | $data['validation_errors'] = validation_errors(); |
| 1692 | 1692 | } else { |
@@ -1715,13 +1715,13 @@ discard block |
||
| 1715 | 1715 | $result = $result->result_array(); |
| 1716 | 1716 | $this->session->set_userdata('accountinfo', $result[0]); |
| 1717 | 1717 | } |
| 1718 | - $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_type) . ' updated successfully!'); |
|
| 1719 | - redirect(base_url() . 'accounts/admin_list/'); |
|
| 1718 | + $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_type).' updated successfully!'); |
|
| 1719 | + redirect(base_url().'accounts/admin_list/'); |
|
| 1720 | 1720 | exit; |
| 1721 | 1721 | } |
| 1722 | 1722 | $this->load->view('view_admin_details', $data); |
| 1723 | 1723 | } else { |
| 1724 | - $data['page_title'] = 'Create ' . ucfirst($entity_type); |
|
| 1724 | + $data['page_title'] = 'Create '.ucfirst($entity_type); |
|
| 1725 | 1725 | if ($this->form_validation->run() == FALSE) { |
| 1726 | 1726 | $data['validation_errors'] = validation_errors(); |
| 1727 | 1727 | } else { |
@@ -1739,8 +1739,8 @@ discard block |
||
| 1739 | 1739 | } |
| 1740 | 1740 | $add_array['credit_limit'] = $this->common_model->add_calculate_currency($add_array['credit_limit'], '', '', false, false); |
| 1741 | 1741 | |
| 1742 | - $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_type) . ' added successfully!'); |
|
| 1743 | - redirect(base_url() . 'accounts/admin_list/'); |
|
| 1742 | + $this->session->set_flashdata('astpp_errormsg', ucfirst($entity_type).' added successfully!'); |
|
| 1743 | + redirect(base_url().'accounts/admin_list/'); |
|
| 1744 | 1744 | exit; |
| 1745 | 1745 | }$this->load->view('view_accounts_create', $data); |
| 1746 | 1746 | } |
@@ -1891,12 +1891,12 @@ discard block |
||
| 1891 | 1891 | $action['balance']['balance'] = $this->common_model->add_calculate_currency($action['balance']['balance'], "", '', true, false); |
| 1892 | 1892 | } |
| 1893 | 1893 | if (isset($action['credit_limit']['credit_limit']) && $action['credit_limit']['credit_limit'] != '') { |
| 1894 | - $action['credit_limit']['credit_limit'] = $this->common_model->add_calculate_currency($action['credit_limit']['credit_limit'], "", '',true, false); |
|
| 1894 | + $action['credit_limit']['credit_limit'] = $this->common_model->add_calculate_currency($action['credit_limit']['credit_limit'], "", '', true, false); |
|
| 1895 | 1895 | } |
| 1896 | 1896 | $this->session->set_userdata('reseller_list_search', $action); |
| 1897 | 1897 | } |
| 1898 | 1898 | if (@$ajax_search != 1) { |
| 1899 | - redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1899 | + redirect(base_url().'accounts/reseller_list/'); |
|
| 1900 | 1900 | } |
| 1901 | 1901 | } |
| 1902 | 1902 | |
@@ -1922,7 +1922,7 @@ discard block |
||
| 1922 | 1922 | $this->session->set_userdata('admin_list_search', $action); |
| 1923 | 1923 | } |
| 1924 | 1924 | if (@$ajax_search != 1) { |
| 1925 | - redirect(base_url() . 'accounts/admin_list/'); |
|
| 1925 | + redirect(base_url().'accounts/admin_list/'); |
|
| 1926 | 1926 | } |
| 1927 | 1927 | } |
| 1928 | 1928 | |
@@ -1935,13 +1935,13 @@ discard block |
||
| 1935 | 1935 | function customer_delete($id) { |
| 1936 | 1936 | $this->common->customer_delete_dependencies($id); |
| 1937 | 1937 | $this->session->set_flashdata('astpp_notification', 'Customer removed successfully!'); |
| 1938 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1938 | + redirect(base_url().'accounts/customer_list/'); |
|
| 1939 | 1939 | } |
| 1940 | 1940 | |
| 1941 | 1941 | function reseller_delete($id) { |
| 1942 | 1942 | $this->common->subreseller_list($id); |
| 1943 | 1943 | $this->session->set_flashdata('astpp_notification', 'Reseller removed successfully!'); |
| 1944 | - redirect(base_url() . 'accounts/reseller_list/'); |
|
| 1944 | + redirect(base_url().'accounts/reseller_list/'); |
|
| 1945 | 1945 | } |
| 1946 | 1946 | |
| 1947 | 1947 | function free_customer_did($accountid) { |
@@ -1972,19 +1972,19 @@ discard block |
||
| 1972 | 1972 | function provider_delete($id) { |
| 1973 | 1973 | $this->accounts_model->remove_customer($id); |
| 1974 | 1974 | $this->session->set_flashdata('astpp_notification', 'Provider removed successfully!'); |
| 1975 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 1975 | + redirect(base_url().'accounts/customer_list/'); |
|
| 1976 | 1976 | } |
| 1977 | 1977 | |
| 1978 | 1978 | function admin_delete($id) { |
| 1979 | 1979 | $this->accounts_model->remove_customer($id); |
| 1980 | 1980 | $this->session->set_flashdata('astpp_notification', 'Admin removed successfully!'); |
| 1981 | - redirect(base_url() . 'accounts/admin_list/'); |
|
| 1981 | + redirect(base_url().'accounts/admin_list/'); |
|
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | 1984 | function subadmin_delete($id) { |
| 1985 | 1985 | $this->accounts_model->remove_customer($id); |
| 1986 | 1986 | $this->session->set_flashdata('astpp_notification', 'Sub admin removed successfully!'); |
| 1987 | - redirect(base_url() . 'accounts/admin_list/'); |
|
| 1987 | + redirect(base_url().'accounts/admin_list/'); |
|
| 1988 | 1988 | } |
| 1989 | 1989 | |
| 1990 | 1990 | function reseller_details_json($module, $accountid) { |
@@ -1995,13 +1995,13 @@ discard block |
||
| 1995 | 1995 | } |
| 1996 | 1996 | if ($module == "invoices") { |
| 1997 | 1997 | $this->load->module('invoices/invoices'); |
| 1998 | - $this->invoices->customer_invoices($accountid,"reseller"); |
|
| 1998 | + $this->invoices->customer_invoices($accountid, "reseller"); |
|
| 1999 | 1999 | } |
| 2000 | 2000 | if ($module == "charges") { |
| 2001 | 2001 | $this->load->module('charges/charges'); |
| 2002 | 2002 | $this->charges->customer_charge_list($accountid, "reseller"); |
| 2003 | 2003 | } |
| 2004 | - if($module =='packages'){ |
|
| 2004 | + if ($module == 'packages') { |
|
| 2005 | 2005 | $this->load->module('package/package'); |
| 2006 | 2006 | $this->package->package_list_reseller($accountid, "reseller"); |
| 2007 | 2007 | } |
@@ -2024,9 +2024,9 @@ discard block |
||
| 2024 | 2024 | $this->db->insert("invoice_item", $insert_arr); |
| 2025 | 2025 | |
| 2026 | 2026 | $this->accounts_model->update_balance($charge, $accountid, "debit"); |
| 2027 | - redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#packages"); |
|
| 2027 | + redirect(base_url()."accounts/".$accounttype."_edit/$accountid#packages"); |
|
| 2028 | 2028 | } else { |
| 2029 | - redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#packages"); |
|
| 2029 | + redirect(base_url()."accounts/".$accounttype."_edit/$accountid#packages"); |
|
| 2030 | 2030 | } |
| 2031 | 2031 | } |
| 2032 | 2032 | |
@@ -2044,9 +2044,9 @@ discard block |
||
| 2044 | 2044 | $this->did->did_model->add_reseller_pricing($accountid, $did_id); |
| 2045 | 2045 | |
| 2046 | 2046 | $this->session->set_flashdata('astpp_errormsg', 'DID added successfully.'); |
| 2047 | - redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#did"); |
|
| 2047 | + redirect(base_url()."accounts/".$accounttype."_edit/$accountid#did"); |
|
| 2048 | 2048 | } else { |
| 2049 | - redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#did"); |
|
| 2049 | + redirect(base_url()."accounts/".$accounttype."_edit/$accountid#did"); |
|
| 2050 | 2050 | } |
| 2051 | 2051 | } |
| 2052 | 2052 | if ($action == "delete") { |
@@ -2075,14 +2075,14 @@ discard block |
||
| 2075 | 2075 | } else { |
| 2076 | 2076 | $this->session->set_flashdata('astpp_notification', 'DID already removed before.'); |
| 2077 | 2077 | } |
| 2078 | - redirect(base_url() . "accounts/" . $accounttype . "_edit/$accountid#did"); |
|
| 2078 | + redirect(base_url()."accounts/".$accounttype."_edit/$accountid#did"); |
|
| 2079 | 2079 | } |
| 2080 | 2080 | } |
| 2081 | 2081 | |
| 2082 | 2082 | function customer_selected_delete() { |
| 2083 | 2083 | $ids = $this->input->post("selected_ids", true); |
| 2084 | - $customer_ids=explode(",",$ids); |
|
| 2085 | - foreach($customer_ids as $customer_id){ |
|
| 2084 | + $customer_ids = explode(",", $ids); |
|
| 2085 | + foreach ($customer_ids as $customer_id) { |
|
| 2086 | 2086 | $customer_id = str_replace("'", "", $customer_id); |
| 2087 | 2087 | $this->common->customer_delete_dependencies($customer_id); |
| 2088 | 2088 | } |
@@ -2150,7 +2150,7 @@ discard block |
||
| 2150 | 2150 | } |
| 2151 | 2151 | } |
| 2152 | 2152 | $this->session->set_flashdata('astpp_errormsg', 'Account tax added successfully!'); |
| 2153 | - redirect(base_url() . 'accounts/customer_list/'); |
|
| 2153 | + redirect(base_url().'accounts/customer_list/'); |
|
| 2154 | 2154 | } |
| 2155 | 2155 | $data['id'] = array(); |
| 2156 | 2156 | $data['taxesList'] = $this->common_model->get_list_taxes(); |
@@ -2182,9 +2182,9 @@ discard block |
||
| 2182 | 2182 | } |
| 2183 | 2183 | } |
| 2184 | 2184 | if ($accountinfo['type'] == '0') { |
| 2185 | - $link = base_url() . '/accounts/customer_list/'; |
|
| 2185 | + $link = base_url().'/accounts/customer_list/'; |
|
| 2186 | 2186 | } else { |
| 2187 | - $link = base_url() . '/accounts/reseller_list/'; |
|
| 2187 | + $link = base_url().'/accounts/reseller_list/'; |
|
| 2188 | 2188 | } |
| 2189 | 2189 | $this->session->set_flashdata('astpp_errormsg', 'Account tax added successfully!'); |
| 2190 | 2190 | redirect($link); |
@@ -2194,7 +2194,7 @@ discard block |
||
| 2194 | 2194 | } elseif ($action == 'delete') { |
| 2195 | 2195 | $this->accounting_model->remove_account_tax($id); |
| 2196 | 2196 | $this->session->set_flashdata('astpp_notification', 'Account tax removed successfully!'); |
| 2197 | - redirect(base_url() . 'accounting/account_taxes/'); |
|
| 2197 | + redirect(base_url().'accounting/account_taxes/'); |
|
| 2198 | 2198 | } |
| 2199 | 2199 | } |
| 2200 | 2200 | |
@@ -2205,7 +2205,7 @@ discard block |
||
| 2205 | 2205 | */ |
| 2206 | 2206 | function valid_account_tax() { |
| 2207 | 2207 | $tax_id = ''; |
| 2208 | - if (!empty($_POST['username'])) { |
|
| 2208 | + if ( ! empty($_POST['username'])) { |
|
| 2209 | 2209 | |
| 2210 | 2210 | $account_num = mysql_real_escape_string($_POST['username']); |
| 2211 | 2211 | $row = $this->accounts_model->check_account_num($account_num); |
@@ -2213,11 +2213,11 @@ discard block |
||
| 2213 | 2213 | $taxes_id = $this->accounts_model->get_accounttax_by_id($row['accountid']); |
| 2214 | 2214 | if ($taxes_id) { |
| 2215 | 2215 | foreach ($taxes_id as $id) { |
| 2216 | - $tax_id.=$id['taxes_id'] . ","; |
|
| 2216 | + $tax_id .= $id['taxes_id'].","; |
|
| 2217 | 2217 | } |
| 2218 | 2218 | |
| 2219 | 2219 | $tax_id = rtrim($tax_id, ","); |
| 2220 | - echo $row['accountid'] . ',' . $tax_id; |
|
| 2220 | + echo $row['accountid'].','.$tax_id; |
|
| 2221 | 2221 | } else { |
| 2222 | 2222 | echo $row['accountid']; |
| 2223 | 2223 | } |
@@ -2243,7 +2243,7 @@ discard block |
||
| 2243 | 2243 | $this->session->set_userdata('accountinfo', $result[0]); |
| 2244 | 2244 | } |
| 2245 | 2245 | $this->session->set_flashdata('astpp_errormsg', 'Reseller updated successfully!'); |
| 2246 | - redirect(base_url() . '/dashboard/'); |
|
| 2246 | + redirect(base_url().'/dashboard/'); |
|
| 2247 | 2247 | } |
| 2248 | 2248 | $this->load->view('view_reseller_edit_details_own', $data); |
| 2249 | 2249 | } else { |
@@ -2300,7 +2300,7 @@ discard block |
||
| 2300 | 2300 | echo "2"; |
| 2301 | 2301 | exit; |
| 2302 | 2302 | } |
| 2303 | - if (isset($add_array['number']) && !empty($add_array['number'])) { |
|
| 2303 | + if (isset($add_array['number']) && ! empty($add_array['number'])) { |
|
| 2304 | 2304 | if (isset($add_array['id']) && $add_array['id'] != '') { |
| 2305 | 2305 | unset($add_array['animap_id']); |
| 2306 | 2306 | $response = $this->accounts_model->edit_animap($add_array, $add_array['id']); |
@@ -2334,7 +2334,7 @@ discard block |
||
| 2334 | 2334 | } |
| 2335 | 2335 | $value_edit = ''; |
| 2336 | 2336 | foreach ($edit_data as $key => $value) { |
| 2337 | - $value_edit.=$value . ","; |
|
| 2337 | + $value_edit .= $value.","; |
|
| 2338 | 2338 | } |
| 2339 | 2339 | echo rtrim($value_edit, ','); |
| 2340 | 2340 | exit; |
@@ -2353,11 +2353,11 @@ discard block |
||
| 2353 | 2353 | |
| 2354 | 2354 | function reseller_export_cdr_xls() { |
| 2355 | 2355 | $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
| 2356 | - $currency_id=$account_info['currency_id']; |
|
| 2357 | - $currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
|
| 2356 | + $currency_id = $account_info['currency_id']; |
|
| 2357 | + $currency = $this->common->get_field_name('currency', 'currency', $currency_id); |
|
| 2358 | 2358 | ob_clean(); |
| 2359 | 2359 | $query = $this->accounts_model->get_reseller_Account_list(true, '', '', true); |
| 2360 | - $customer_array[] = array("Account", "First Name", "Last Name", "Company", "Rate Group ", "Account type", "Balance($currency)", "Credit Limit($currency)", "Status","Created Date"); |
|
| 2360 | + $customer_array[] = array("Account", "First Name", "Last Name", "Company", "Rate Group ", "Account type", "Balance($currency)", "Credit Limit($currency)", "Status", "Created Date"); |
|
| 2361 | 2361 | if ($query->num_rows() > 0) { |
| 2362 | 2362 | |
| 2363 | 2363 | foreach ($query->result_array() as $row) { |
@@ -2368,40 +2368,40 @@ discard block |
||
| 2368 | 2368 | $row['company_name'], |
| 2369 | 2369 | $this->common->get_field_name('name', 'pricelists', $row['pricelist_id']), |
| 2370 | 2370 | $this->common->get_account_type('', '', $row['posttoexternal']), |
| 2371 | - $this->common_model->calculate_currency($row['balance'],false,false), |
|
| 2372 | - $this->common_model->calculate_currency($row['credit_limit'],false,false), |
|
| 2371 | + $this->common_model->calculate_currency($row['balance'], false, false), |
|
| 2372 | + $this->common_model->calculate_currency($row['credit_limit'], false, false), |
|
| 2373 | 2373 | $this->common->get_status('export', '', $row['status']), |
| 2374 | 2374 | $row['creation'], |
| 2375 | 2375 | ); |
| 2376 | 2376 | } |
| 2377 | 2377 | } |
| 2378 | 2378 | $this->load->helper('csv'); |
| 2379 | - array_to_csv($customer_array, 'Resellers_' . date("Y-m-d") . '.csv'); |
|
| 2379 | + array_to_csv($customer_array, 'Resellers_'.date("Y-m-d").'.csv'); |
|
| 2380 | 2380 | } |
| 2381 | - function customer_validate_ip(){ |
|
| 2382 | - $add_array=$this->input->post(); |
|
| 2383 | - if(!empty($add_array)){ |
|
| 2381 | + function customer_validate_ip() { |
|
| 2382 | + $add_array = $this->input->post(); |
|
| 2383 | + if ( ! empty($add_array)) { |
|
| 2384 | 2384 | $ip = $add_array['ip']; |
| 2385 | 2385 | if (strpos($ip, '/') !== false) { |
| 2386 | 2386 | $add_array['ip'] = $add_array['ip']; |
| 2387 | 2387 | } else { |
| 2388 | - $add_array['ip'] = $add_array['ip'] . '/32'; |
|
| 2388 | + $add_array['ip'] = $add_array['ip'].'/32'; |
|
| 2389 | 2389 | } |
| 2390 | - $this->db->where('ip',$add_array['ip']); |
|
| 2391 | - $this->db->where('prefix',$add_array['prefix']); |
|
| 2390 | + $this->db->where('ip', $add_array['ip']); |
|
| 2391 | + $this->db->where('prefix', $add_array['prefix']); |
|
| 2392 | 2392 | $this->db->select('count(ip) as count'); |
| 2393 | - $ip_map_result=(array)$this->db->get('ip_map')->first_row(); |
|
| 2394 | - if($ip_map_result['count'] > 0 ){ |
|
| 2393 | + $ip_map_result = (array)$this->db->get('ip_map')->first_row(); |
|
| 2394 | + if ($ip_map_result['count'] > 0) { |
|
| 2395 | 2395 | echo 'FALSE'; |
| 2396 | - }else{ |
|
| 2396 | + } else { |
|
| 2397 | 2397 | echo 'TRUE'; |
| 2398 | 2398 | } |
| 2399 | - }else{ |
|
| 2399 | + } else { |
|
| 2400 | 2400 | echo 'FALSE'; |
| 2401 | 2401 | } |
| 2402 | 2402 | |
| 2403 | 2403 | } |
| 2404 | -function reseller_invoice_config($id=''){ |
|
| 2404 | +function reseller_invoice_config($id = '') { |
|
| 2405 | 2405 | $data['page_title'] = 'Company Profile'; |
| 2406 | 2406 | $accountinfo = $this->session->userdata("accountinfo"); |
| 2407 | 2407 | $add_array = $this->input->post(); |
@@ -2411,30 +2411,30 @@ discard block |
||
| 2411 | 2411 | $this->load->module('invoices/invoices'); |
| 2412 | 2412 | $this->load->model("invoices_model"); |
| 2413 | 2413 | $invoiceconf = $this->invoices_model->get_invoiceconf(); |
| 2414 | - $file_name=($invoiceconf['logo'] != '') ? $invoiceconf['logo'] : ''; |
|
| 2414 | + $file_name = ($invoiceconf['logo'] != '') ? $invoiceconf['logo'] : ''; |
|
| 2415 | 2415 | } |
| 2416 | 2416 | if (isset($_FILES['file']['name']) && $_FILES['file']['name'] != '') { |
| 2417 | 2417 | $files = $_FILES['file']; |
| 2418 | 2418 | if ($files['size'] < 0) { |
| 2419 | 2419 | $this->session->set_flashdata('astpp_notification', 'PLease upload maximum file'); |
| 2420 | - redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
| 2420 | + redirect(base_url()."accounts/reseller_invoice_config/".$add_array['accountid']."/"); |
|
| 2421 | 2421 | } |
| 2422 | 2422 | $file = $_FILES['file']; |
| 2423 | 2423 | $uploadedFile = $file["tmp_name"]; |
| 2424 | 2424 | $file_name = $file['name']; |
| 2425 | 2425 | $file_type = $file['type']; |
| 2426 | 2426 | if ($file_type == 'image/jpg' || $file_type == 'image/png' || $file_type == 'image/jpeg') { |
| 2427 | - $dir_path = FCPATH. "upload/"; |
|
| 2428 | - $path = $dir_path . $add_array['accountid']."_".$file['name']; |
|
| 2427 | + $dir_path = FCPATH."upload/"; |
|
| 2428 | + $path = $dir_path.$add_array['accountid']."_".$file['name']; |
|
| 2429 | 2429 | if (move_uploaded_file($uploadedFile, $path)) { |
| 2430 | 2430 | $this->session->set_flashdata('astpp_errormsg', gettext('files added successfully!')); |
| 2431 | 2431 | } else { |
| 2432 | 2432 | $this->session->set_flashdata('astpp_notification', "File Uploading Fail Please Try Again"); |
| 2433 | - redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
| 2433 | + redirect(base_url()."accounts/reseller_invoice_config/".$add_array['accountid']."/"); |
|
| 2434 | 2434 | } |
| 2435 | 2435 | } else { |
| 2436 | 2436 | $this->session->set_flashdata('astpp_notification', 'Please upload only image!'); |
| 2437 | - redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
| 2437 | + redirect(base_url()."accounts/reseller_invoice_config/".$add_array['accountid']."/"); |
|
| 2438 | 2438 | } |
| 2439 | 2439 | } |
| 2440 | 2440 | $add_array['logo'] = $file_name; |
@@ -2445,30 +2445,30 @@ discard block |
||
| 2445 | 2445 | $this->accounts_model->edit_invoice_config($add_array, $add_array['id']); |
| 2446 | 2446 | } |
| 2447 | 2447 | $this->session->set_flashdata('astpp_errormsg', 'Invoice config updated successfully!'); |
| 2448 | - redirect(base_url() . "accounts/reseller_invoice_config/". $add_array['accountid']."/"); |
|
| 2448 | + redirect(base_url()."accounts/reseller_invoice_config/".$add_array['accountid']."/"); |
|
| 2449 | 2449 | } else { |
| 2450 | - $data["account_data"] =(array)$this->db->get_where('invoice_conf',array("accountid"=>$id))->first_row(); |
|
| 2451 | - $data["accounttype"]='Reseller'; |
|
| 2452 | - $data["edit_id"]=$id; |
|
| 2453 | - if(isset($data["account_data"]['logo'])){ |
|
| 2454 | - $data["account_data"]['file']=$id."_".$data["account_data"]['logo']; |
|
| 2450 | + $data["account_data"] = (array)$this->db->get_where('invoice_conf', array("accountid"=>$id))->first_row(); |
|
| 2451 | + $data["accounttype"] = 'Reseller'; |
|
| 2452 | + $data["edit_id"] = $id; |
|
| 2453 | + if (isset($data["account_data"]['logo'])) { |
|
| 2454 | + $data["account_data"]['file'] = $id."_".$data["account_data"]['logo']; |
|
| 2455 | 2455 | } |
| 2456 | 2456 | $this->load->view('view_reseller_invoices_config', $data); |
| 2457 | 2457 | } |
| 2458 | 2458 | } |
| 2459 | 2459 | |
| 2460 | - function reseller_invoice_logo_delete($accountid){ |
|
| 2461 | - $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> $accountid)); |
|
| 2462 | - $result=$invoiceconf->result_array(); |
|
| 2463 | - $logo=$result[0]['logo']; |
|
| 2464 | - $post_arr=array('logo'=>''); |
|
| 2465 | - $where_arr=array('logo'=>$logo); |
|
| 2460 | + function reseller_invoice_logo_delete($accountid) { |
|
| 2461 | + $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> $accountid)); |
|
| 2462 | + $result = $invoiceconf->result_array(); |
|
| 2463 | + $logo = $result[0]['logo']; |
|
| 2464 | + $post_arr = array('logo'=>''); |
|
| 2465 | + $where_arr = array('logo'=>$logo); |
|
| 2466 | 2466 | $this->db->where($where_arr); |
| 2467 | - $this->db->update('invoice_conf',$post_arr); |
|
| 2467 | + $this->db->update('invoice_conf', $post_arr); |
|
| 2468 | 2468 | } |
| 2469 | 2469 | |
| 2470 | 2470 | |
| 2471 | - function customer_global_grid_list(){ |
|
| 2471 | + function customer_global_grid_list() { |
|
| 2472 | 2472 | echo gettext($_POST['display']); |
| 2473 | 2473 | } |
| 2474 | 2474 | |
@@ -37,8 +37,9 @@ discard block |
||
| 37 | 37 | $this->load->model('accounts_model'); |
| 38 | 38 | $this->load->model('Astpp_common'); |
| 39 | 39 | $this->protected_pages = array('account_list'); |
| 40 | - if ($this->session->userdata('user_login') == FALSE) |
|
| 41 | - redirect(base_url() . '/login/login'); |
|
| 40 | + if ($this->session->userdata('user_login') == FALSE) { |
|
| 41 | + redirect(base_url() . '/login/login'); |
|
| 42 | + } |
|
| 42 | 43 | } |
| 43 | 44 | |
| 44 | 45 | function customer_list() { |
@@ -377,13 +378,15 @@ discard block |
||
| 377 | 378 | $where = array("accountid" => $accountid); |
| 378 | 379 | $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_ipmap'); |
| 379 | 380 | $like_str=!empty($instant_search) ? "(name like '%$instant_search%' OR ip like '%$instant_search%' OR prefix like '%$instant_search%' OR created_date like '%$instant_search%' )" :null; |
| 380 | - if(!empty($like_str)) |
|
| 381 | - $this->db->where($like_str); |
|
| 381 | + if(!empty($like_str)) { |
|
| 382 | + $this->db->where($like_str); |
|
| 383 | + } |
|
| 382 | 384 | $count_all = $this->db_model->countQuery("*", "ip_map", $where); |
| 383 | 385 | $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
| 384 | 386 | $json_data = $paging_data["json_paging"]; |
| 385 | - if(!empty($like_str)) |
|
| 386 | - $this->db->where($like_str); |
|
| 387 | + if(!empty($like_str)) { |
|
| 388 | + $this->db->where($like_str); |
|
| 389 | + } |
|
| 387 | 390 | $query = $this->db_model->select("*", "ip_map", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
| 388 | 391 | $grid_fields = json_decode($this->accounts_form->build_ip_list_for_customer($accountid, $accounttype)); |
| 389 | 392 | $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
@@ -472,15 +475,17 @@ discard block |
||
| 472 | 475 | $json_data = array(); |
| 473 | 476 | $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_animap'); |
| 474 | 477 | $like_str=!empty($instant_search) ? "(number like '%$instant_search%' OR creation_date like '%$instant_search%' )" :null; |
| 475 | - if(!empty($like_str)) |
|
| 476 | - $this->db->where($like_str); |
|
| 478 | + if(!empty($like_str)) { |
|
| 479 | + $this->db->where($like_str); |
|
| 480 | + } |
|
| 477 | 481 | $where = array("accountid" => $accountid); |
| 478 | 482 | $count_all = $this->db_model->countQuery("*", "ani_map", $where); |
| 479 | 483 | |
| 480 | 484 | $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
| 481 | 485 | $json_data = $paging_data["json_paging"]; |
| 482 | - if(!empty($like_str)) |
|
| 483 | - $this->db->where($like_str); |
|
| 486 | + if(!empty($like_str)) { |
|
| 487 | + $this->db->where($like_str); |
|
| 488 | + } |
|
| 484 | 489 | $query = $this->db_model->select("*", "ani_map", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); |
| 485 | 490 | |
| 486 | 491 | $grid_fields = json_decode($this->accounts_form->build_animap_list_for_customer($accountid, $accounttype)); |
@@ -1043,7 +1048,7 @@ discard block |
||
| 1043 | 1048 | $data['edit_id'] = $edit_id; |
| 1044 | 1049 | $data['accounttype'] = $accounttype; |
| 1045 | 1050 | $this->load->view('view_reseller_package_list', $data); |
| 1046 | - }else { |
|
| 1051 | + } else { |
|
| 1047 | 1052 | redirect(base_url() . 'accounts/reseller_list/'); |
| 1048 | 1053 | exit; |
| 1049 | 1054 | } |
@@ -1321,14 +1326,14 @@ discard block |
||
| 1321 | 1326 | $accountinfo = $this->accounts_model->get_account_by_number($post_array['id']); |
| 1322 | 1327 | if($accountinfo['reseller_id'] == 0){ |
| 1323 | 1328 | $where = array("accountid"=> 1); |
| 1324 | - }else{ |
|
| 1329 | + } else{ |
|
| 1325 | 1330 | $where = array("accountid"=> $accountinfo['id']); |
| 1326 | 1331 | } |
| 1327 | 1332 | $query = $this->db_model->getSelect("*", "invoice_conf", $where); |
| 1328 | 1333 | if($query->num_rows >0){ |
| 1329 | 1334 | $invoice_conf = $query->result_array(); |
| 1330 | 1335 | $invoice_conf = $invoice_conf[0]; |
| 1331 | - }else{ |
|
| 1336 | + } else{ |
|
| 1332 | 1337 | $query = $this->db_model->getSelect("*", "invoice_conf",array("accountid"=> 1)); |
| 1333 | 1338 | $invoice_conf = $query->result_array(); |
| 1334 | 1339 | $invoice_conf = $invoice_conf[0]; |
@@ -1355,7 +1360,7 @@ discard block |
||
| 1355 | 1360 | 'after_balance'=>$account_balance, |
| 1356 | 1361 | ); |
| 1357 | 1362 | $this->db->insert("invoice_details", $insert_arr); |
| 1358 | - }else{ |
|
| 1363 | + } else{ |
|
| 1359 | 1364 | $this->load->module('invoices/invoices'); |
| 1360 | 1365 | $invoice_id=$this->invoices->invoices->generate_receipt($post_array['id'],$post_array['credit'],$accountinfo,$last_invoice_ID+1,$invoice_prefix,$due_date); |
| 1361 | 1366 | $account_balance = $this->common->get_field_name('balance', 'accounts', $post_array['id']); |
@@ -1784,8 +1789,9 @@ discard block |
||
| 1784 | 1789 | $json_data['total'] = $config['total_rows']; |
| 1785 | 1790 | $perpage = $config['per_page']; |
| 1786 | 1791 | $start = ($page_no - 1) * $perpage; |
| 1787 | - if ($start < 0) |
|
| 1788 | - $start = 0; |
|
| 1792 | + if ($start < 0) { |
|
| 1793 | + $start = 0; |
|
| 1794 | + } |
|
| 1789 | 1795 | |
| 1790 | 1796 | $account_charge_list = $this->db_model->getAllJionQuery($table, $select, $where, $jionTable, $jionCondition, $type, $perpage, $start, $order_by, $order_type, ""); |
| 1791 | 1797 | if ($account_charge_list->num_rows > 0) { |
@@ -2128,8 +2134,9 @@ discard block |
||
| 2128 | 2134 | $data['username'] = $this->session->userdata('user_name'); |
| 2129 | 2135 | $data['page_title'] = 'Account Taxes'; |
| 2130 | 2136 | |
| 2131 | - if ($action == false) |
|
| 2132 | - $action = "list"; |
|
| 2137 | + if ($action == false) { |
|
| 2138 | + $action = "list"; |
|
| 2139 | + } |
|
| 2133 | 2140 | |
| 2134 | 2141 | if ($action == 'list') { |
| 2135 | 2142 | $this->load->view('view_account_taxes_list', $data); |
@@ -2393,10 +2400,10 @@ discard block |
||
| 2393 | 2400 | $ip_map_result=(array)$this->db->get('ip_map')->first_row(); |
| 2394 | 2401 | if($ip_map_result['count'] > 0 ){ |
| 2395 | 2402 | echo 'FALSE'; |
| 2396 | - }else{ |
|
| 2403 | + } else{ |
|
| 2397 | 2404 | echo 'TRUE'; |
| 2398 | 2405 | } |
| 2399 | - }else{ |
|
| 2406 | + } else{ |
|
| 2400 | 2407 | echo 'FALSE'; |
| 2401 | 2408 | } |
| 2402 | 2409 | |