| @@ -4,21 +4,75 @@ | ||
| 4 | 4 | |
| 5 | 5 | var $mpdf = null; |
| 6 | 6 | |
| 7 | 7 | var $tablecascadeCSS; |
| 8 | +var $listcascadeCSS; | |
| 8 | 9 | var $cascadeCSS; |
| 9 | 10 | var $CSS; |
| 10 | 11 | var $tbCSSlvl; |
| 12 | +var $listCSSlvl; | |
| 11 | 13 | |
| 12 | 14 | |
| 13 | 15 | function cssmgr(&$mpdf) { |
| 14 | 16 | $this->mpdf = $mpdf; |
| 15 | 17 | $this->tablecascadeCSS = array(); |
| 18 | + $this->listcascadeCSS = array(); | |
| 16 | 19 | $this->CSS=array(); |
| 17 | 20 | $this->cascadeCSS = array(); |
| 18 | 21 | $this->tbCSSlvl = 0; |
| 22 | + $this->listCSSlvl = 0; | |
| 19 | 23 | } |
| 20 | 24 | |
| 25 | + | |
| 26 | +function ReadDefaultCSS($CSSstr) { | |
| 27 | + $CSS = array(); | |
| 28 | + $CSSstr = preg_replace('|/\*.*?\*/|s',' ',$CSSstr); | |
| 29 | + $CSSstr = preg_replace('/[\s\n\r\t\f]/s',' ',$CSSstr); | |
| 30 | + $CSSstr = preg_replace('/(<\!\-\-|\-\->)/s',' ',$CSSstr); | |
| 31 | + if ($CSSstr ) { | |
| 32 | + preg_match_all('/(.*?)\{(.*?)\}/',$CSSstr,$styles); | |
| 33 | + for($i=0; $i < count($styles[1]) ; $i++) { | |
| 34 | + $stylestr= trim($styles[2][$i]); | |
| 35 | + $stylearr = explode(';',$stylestr); | |
| 36 | + foreach($stylearr AS $sta) { | |
| 37 | + if (trim($sta)) { | |
| 38 | + // Changed to allow style="background: url('http://www.bpm1.com/bg.jpg')" | |
| 39 | + list($property,$value) = explode(':',$sta,2); | |
| 40 | + $property = trim($property); | |
| 41 | + $value = preg_replace('/\s*!important/i','',$value); | |
| 42 | + $value = trim($value); | |
| 43 | + if ($property && ($value || $value==='0')) { | |
| 44 | + $classproperties[strtoupper($property)] = $value; | |
| 45 | + } | |
| 46 | + } | |
| 47 | + } | |
| 48 | + $classproperties = $this->fixCSS($classproperties); | |
| 49 | + $tagstr = strtoupper(trim($styles[1][$i])); | |
| 50 | + $tagarr = explode(',',$tagstr); | |
| 51 | + foreach($tagarr AS $tg) { | |
| 52 | + $tags = preg_split('/\s+/',trim($tg)); | |
| 53 | + $level = count($tags); | |
| 54 | + if ($level == 1) { // e.g. p or .class or #id or p.class or p#id | |
| 55 | + $t = trim($tags[0]); | |
| 56 | + if ($t) { | |
| 57 | + $tag = ''; | |
| 58 | + if (preg_match('/^('.$this->mpdf->allowedCSStags.')$/',$t)) { $tag= $t; } | |
| 59 | + if ($this->CSS[$tag] && $tag) { $CSS[$tag] = $this->array_merge_recursive_unique($CSS[$tag], $classproperties); } | |
| 60 | + else if ($tag) { $CSS[$tag] = $classproperties; } | |
| 61 | + } | |
| 62 | + } | |
| 63 | + } | |
| 64 | + $properties = array(); | |
| 65 | + $values = array(); | |
| 66 | + $classproperties = array(); | |
| 67 | + } | |
| 68 | + | |
| 69 | + } // end of if | |
| 70 | + return $CSS; | |
| 71 | +} | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 21 | 75 | function ReadCSS($html) { |
| 22 | 76 | preg_match_all('/<style[^>]*media=["\']([^"\'>]*)["\'].*?<\/style>/is',$html,$m); |
| 23 | 77 | for($i=0; $i<count($m[0]); $i++) { |
| 24 | 78 | if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) { |
| @@ -63,8 +117,9 @@ | ||
| 63 | 117 | if ($x) { |
| 64 | 118 | $match += $x; |
| 65 | 119 | $CSSext = $cxt[1]; |
| 66 | 120 | } |
| 121 | + | |
| 67 | 122 | $regexp = '/<link[^>]*href=["\']([^>"\']*)["\'][^>]*?rel=["\']stylesheet["\'].*?>/si'; |
| 68 | 123 | $x = preg_match_all($regexp,$html,$cxt); |
| 69 | 124 | if ($x) { |
| 70 | 125 | $match += $x; |
| @@ -95,11 +150,8 @@ | ||
| 95 | 150 | if (!is_array($this->cascadeCSS)) $this->cascadeCSS = array(); |
| 96 | 151 | |
| 97 | 152 | while($match){ |
| 98 | 153 | $path = $CSSext[$ind]; |
| 99 | - | |
| 100 | - $path = htmlspecialchars_decode($path); // mPDF 6 | |
| 101 | - | |
| 102 | 154 | $this->mpdf->GetFullPath($path); |
| 103 | 155 | $CSSextblock = $this->mpdf->_get_file($path); |
| 104 | 156 | if ($CSSextblock) { |
| 105 | 157 | // look for embedded @import stylesheets in other stylesheets |
| @@ -168,10 +220,11 @@ | ||
| 168 | 220 | } |
| 169 | 221 | } |
| 170 | 222 | } |
| 171 | 223 | |
| 224 | + // mPDF 5.5.13 | |
| 172 | 225 | // Replace any background: url(data:image... with temporary image file reference |
| 173 | - preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*?)\))/si", $CSSstr, $idata); // mPDF 5.7.2 | |
| 226 | + preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*)\))/si", $CSSstr, $idata); | |
| 174 | 227 | if (count($idata[0])) { |
| 175 | 228 | for($i=0;$i<count($idata[0]);$i++) { |
| 176 | 229 | $file = _MPDF_TEMP_PATH.'_tempCSSidata'.RAND(1,10000).'_'.$i.'.'.$idata[2][$i]; |
| 177 | 230 | //Save to local file |
| @@ -181,36 +234,9 @@ | ||
| 181 | 234 | } |
| 182 | 235 | } |
| 183 | 236 | |
| 184 | 237 | $CSSstr = preg_replace('/(<\!\-\-|\-\->)/s',' ',$CSSstr); |
| 185 | - | |
| 186 | - // mPDF 5.7.4 URLs | |
| 187 | - // Characters "(" ")" and ";" in url() e.g. background-image, cause problems parsing the CSS string | |
| 188 | - // URLencode ( and ), but change ";" to a code which can be converted back after parsing (so as not to confuse ; | |
| 189 | - // with a segment delimiter in the URI) | |
| 190 | - $tempmarker = '%ZZ'; | |
| 191 | - if (strpos($CSSstr,'url(')!==false) { | |
| 192 | - preg_match_all( '/url\(\"(.*?)\"\)/', $CSSstr, $m); | |
| 193 | - for($i = 0; $i < count($m[1]) ; $i++) { | |
| 194 | - $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]); | |
| 195 | - $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $CSSstr); | |
| 196 | - } | |
| 197 | - preg_match_all( '/url\(\'(.*?)\'\)/', $CSSstr, $m); | |
| 198 | - for($i = 0; $i < count($m[1]) ; $i++) { | |
| 199 | - $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]); | |
| 200 | - $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $CSSstr); | |
| 201 | - } | |
| 202 | - preg_match_all( '/url\(([^\'\"].*?[^\'\"])\)/', $CSSstr, $m); | |
| 203 | - for($i = 0; $i < count($m[1]) ; $i++) { | |
| 204 | - $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]); | |
| 205 | - $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $CSSstr); | |
| 206 | - } | |
| 207 | - } | |
| 208 | - | |
| 209 | - | |
| 210 | - | |
| 211 | 238 | if ($CSSstr ) { |
| 212 | - $classproperties = array(); // mPDF 6 | |
| 213 | 239 | preg_match_all('/(.*?)\{(.*?)\}/',$CSSstr,$styles); |
| 214 | 240 | for($i=0; $i < count($styles[1]) ; $i++) { |
| 215 | 241 | // SET array e.g. $classproperties['COLOR'] = '#ffffff'; |
| 216 | 242 | $stylestr= trim($styles[2][$i]); |
| @@ -217,13 +243,9 @@ | ||
| 217 | 243 | $stylearr = explode(';',$stylestr); |
| 218 | 244 | foreach($stylearr AS $sta) { |
| 219 | 245 | if (trim($sta)) { |
| 220 | 246 | // Changed to allow style="background: url('http://www.bpm1.com/bg.jpg')" |
| 221 | - $tmp = explode(':',$sta,2); | |
| 222 | - $property = $tmp[0]; | |
| 223 | - if (isset($tmp[1])) { $value = $tmp[1]; } | |
| 224 | - else { $value = ''; } | |
| 225 | - $value = str_replace($tempmarker,';',$value); // mPDF 5.7.4 URLs | |
| 247 | + list($property,$value) = explode(':',$sta,2); | |
| 226 | 248 | $property = trim($property); |
| 227 | 249 | $value = preg_replace('/\s*!important/i','',$value); |
| 228 | 250 | $value = trim($value); |
| 229 | 251 | if ($property && ($value || $value==='0')) { |
| @@ -239,12 +261,8 @@ | ||
| 239 | 261 | $tagstr = strtoupper(trim($styles[1][$i])); |
| 240 | 262 | $tagarr = explode(',',$tagstr); |
| 241 | 263 | $pageselectors = false; // used to turn on $this->mpdf->mirrorMargins |
| 242 | 264 | foreach($tagarr AS $tg) { |
| 243 | - // mPDF 5.7.4 | |
| 244 | - if (preg_match('/NTH-CHILD\((\s*(([\-+]?\d*)N(\s*[\-+]\s*\d+)?|[\-+]?\d+|ODD|EVEN)\s*)\)/',$tg,$m) ) { | |
| 245 | - $tg = preg_replace('/NTH-CHILD\(.*\)/', 'NTH-CHILD('.str_replace(' ','',$m[1]).')', $tg); | |
| 246 | - } | |
| 247 | 265 | $tags = preg_split('/\s+/',trim($tg)); |
| 248 | 266 | $level = count($tags); |
| 249 | 267 | $t = ''; |
| 250 | 268 | $t2 = ''; |
| @@ -273,15 +291,11 @@ | ||
| 273 | 291 | if ($t) { |
| 274 | 292 | $tag = ''; |
| 275 | 293 | if (preg_match('/^[.](.*)$/',$t,$m)) { $tag = 'CLASS>>'.$m[1]; } |
| 276 | 294 | else if (preg_match('/^[#](.*)$/',$t,$m)) { $tag = 'ID>>'.$m[1]; } |
| 277 | - else if (preg_match('/^\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',$t,$m)) { $tag = 'LANG>>'.strtolower($m[1]); } // mPDF 6 Special case for lang as attribute selector | |
| 278 | - else if (preg_match('/^:LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',$t,$m)) { $tag = 'LANG>>'.strtolower($m[1]); } // mPDF 6 Special case for lang as attribute selector | |
| 279 | 295 | else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[.](.*)$/',$t,$m)) { $tag = $m[1].'>>CLASS>>'.$m[2]; } |
| 280 | 296 | else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\s*:NTH-CHILD\((.*)\)$/',$t,$m)) { $tag = $m[1].'>>SELECTORNTHCHILD>>'.$m[2]; } |
| 281 | 297 | else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[#](.*)$/',$t,$m)) { $tag = $m[1].'>>ID>>'.$m[2]; } |
| 282 | - else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',$t,$m)) { $tag = $m[1].'>>LANG>>'.strtolower($m[2]); } // mPDF 6 Special case for lang as attribute selector | |
| 283 | - else if (preg_match('/^('.$this->mpdf->allowedCSStags.'):LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',$t,$m)) { $tag = $m[1].'>>LANG>>'.strtolower($m[2]); } // mPDF 6 Special case for lang as attribute selector | |
| 284 | 298 | else if (preg_match('/^('.$this->mpdf->allowedCSStags.')$/',$t)) { $tag= $t; } |
| 285 | 299 | if (isset($this->CSS[$tag]) && $tag) { $this->CSS[$tag] = $this->array_merge_recursive_unique($this->CSS[$tag], $classproperties); } |
| 286 | 300 | else if ($tag) { $this->CSS[$tag] = $classproperties; } |
| 287 | 301 | } |
| @@ -294,15 +308,11 @@ | ||
| 294 | 308 | if ($t) { |
| 295 | 309 | $tag = ''; |
| 296 | 310 | if (preg_match('/^[.](.*)$/',$t,$m)) { $tag = 'CLASS>>'.$m[1]; } |
| 297 | 311 | else if (preg_match('/^[#](.*)$/',$t,$m)) { $tag = 'ID>>'.$m[1]; } |
| 298 | - else if (preg_match('/^\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',$t,$m)) { $tag = 'LANG>>'.strtolower($m[1]); } // mPDF 6 Special case for lang as attribute selector | |
| 299 | - else if (preg_match('/^:LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',$t,$m)) { $tag = 'LANG>>'.strtolower($m[1]); } // mPDF 6 Special case for lang as attribute selector | |
| 300 | 312 | else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[.](.*)$/',$t,$m)) { $tag = $m[1].'>>CLASS>>'.$m[2]; } |
| 301 | 313 | else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\s*:NTH-CHILD\((.*)\)$/',$t,$m)) { $tag = $m[1].'>>SELECTORNTHCHILD>>'.$m[2]; } |
| 302 | 314 | else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[#](.*)$/',$t,$m)) { $tag = $m[1].'>>ID>>'.$m[2]; } |
| 303 | - else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',$t,$m)) { $tag = $m[1].'>>LANG>>'.strtolower($m[2]); } // mPDF 6 Special case for lang as attribute selector | |
| 304 | - else if (preg_match('/^('.$this->mpdf->allowedCSStags.'):LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',$t,$m)) { $tag = $m[1].'>>LANG>>'.strtolower($m[2]); } // mPDF 6 Special case for lang as attribute selector | |
| 305 | 315 | else if (preg_match('/^('.$this->mpdf->allowedCSStags.')$/',$t)) { $tag= $t; } |
| 306 | 316 | |
| 307 | 317 | if ($tag) $tmp[] = $tag; |
| 308 | 318 | else { break; } |
| @@ -333,31 +343,8 @@ | ||
| 333 | 343 | |
| 334 | 344 | |
| 335 | 345 | |
| 336 | 346 | function readInlineCSS($html) { |
| 337 | - $html=htmlspecialchars_decode($html); // mPDF 5.7.4 URLs | |
| 338 | - // mPDF 5.7.4 URLs | |
| 339 | - // Characters "(" ")" and ";" in url() e.g. background-image, cause probems parsing the CSS string | |
| 340 | - // URLencode ( and ), but change ";" to a code which can be converted back after parsing (so as not to confuse ; | |
| 341 | - // with a segment delimiter in the URI) | |
| 342 | - $tempmarker = '%ZZ'; | |
| 343 | - if (strpos($html,'url(')!==false) { | |
| 344 | - preg_match_all( '/url\(\"(.*?)\"\)/', $html, $m); | |
| 345 | - for($i = 0; $i < count($m[1]) ; $i++) { | |
| 346 | - $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]); | |
| 347 | - $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $html); | |
| 348 | - } | |
| 349 | - preg_match_all( '/url\(\'(.*?)\'\)/', $html, $m); | |
| 350 | - for($i = 0; $i < count($m[1]) ; $i++) { | |
| 351 | - $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]); | |
| 352 | - $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $html); | |
| 353 | - } | |
| 354 | - preg_match_all( '/url\(([^\'\"].*?[^\'\"])\)/', $html, $m); | |
| 355 | - for($i = 0; $i < count($m[1]) ; $i++) { | |
| 356 | - $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]); | |
| 357 | - $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $html); | |
| 358 | - } | |
| 359 | - } | |
| 360 | 347 | //Fix incomplete CSS code |
| 361 | 348 | $size = strlen($html)-1; |
| 362 | 349 | if (substr($html,$size,1) != ';') $html .= ';'; |
| 363 | 350 | //Make CSS[Name-of-the-class] = array(key => value) |
| @@ -371,9 +358,8 @@ | ||
| 371 | 358 | // Ignores -webkit-gradient so doesn't override -moz- |
| 372 | 359 | if ((strtoupper($properties[$i])=='BACKGROUND-IMAGE' || strtoupper($properties[$i])=='BACKGROUND') && preg_match('/-webkit-gradient/i',$values[$i])) { |
| 373 | 360 | continue; |
| 374 | 361 | } |
| 375 | - $values[$i] = str_replace($tempmarker,';',$values[$i]); // mPDF 5.7.4 URLs | |
| 376 | 362 | $classproperties[strtoupper($properties[$i])] = trim($values[$i]); |
| 377 | 363 | } |
| 378 | 364 | return $this->fixCSS($classproperties); |
| 379 | 365 | } |
| @@ -468,9 +454,9 @@ | ||
| 468 | 454 | else { $newprop['FONT-WEIGHT'] = 'normal'; } |
| 469 | 455 | if (preg_match('/small-caps/i',$s)) { $newprop['TEXT-TRANSFORM'] = 'uppercase'; } |
| 470 | 456 | } |
| 471 | 457 | } |
| 472 | - else if ($k == 'FONT-FAMILY') { | |
| 458 | + if ($k == 'FONT-FAMILY') { | |
| 473 | 459 | $aux_fontlist = explode(",",$v); |
| 474 | 460 | $found = 0; |
| 475 | 461 | foreach($aux_fontlist AS $f) { |
| 476 | 462 | $fonttype = trim($f); |
| @@ -500,31 +486,8 @@ | ||
| 500 | 486 | } |
| 501 | 487 | } |
| 502 | 488 | } |
| 503 | 489 | } |
| 504 | - // mPDF 5.7.1 | |
| 505 | - else if ($k == 'FONT-VARIANT') { | |
| 506 | - if (preg_match('/(normal|none)/',$v, $m)) { // mPDF 6 | |
| 507 | - $newprop['FONT-VARIANT-LIGATURES'] = $m[1]; | |
| 508 | - $newprop['FONT-VARIANT-CAPS'] = $m[1]; | |
| 509 | - $newprop['FONT-VARIANT-NUMERIC'] = $m[1]; | |
| 510 | - $newprop['FONT-VARIANT-ALTERNATES'] = $m[1]; | |
| 511 | - } | |
| 512 | - else { | |
| 513 | - if (preg_match_all('/(no-common-ligatures|\bcommon-ligatures|no-discretionary-ligatures|\bdiscretionary-ligatures|no-historical-ligatures|\bhistorical-ligatures|no-contextual|\bcontextual)/i',$v, $m)) { | |
| 514 | - $newprop['FONT-VARIANT-LIGATURES'] = implode(' ',$m[1]); | |
| 515 | - } | |
| 516 | - if (preg_match('/(all-small-caps|\bsmall-caps|all-petite-caps|\bpetite-caps|unicase|titling-caps)/i',$v, $m)) { | |
| 517 | - $newprop['FONT-VARIANT-CAPS'] = $m[1]; | |
| 518 | - } | |
| 519 | - if (preg_match_all('/(lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions)/i',$v, $m)) { | |
| 520 | - $newprop['FONT-VARIANT-NUMERIC'] = implode(' ',$m[1]); | |
| 521 | - } | |
| 522 | - if (preg_match('/(historical-forms)/i',$v, $m)) { | |
| 523 | - $newprop['FONT-VARIANT-ALTERNATES'] = $m[1]; | |
| 524 | - } | |
| 525 | - } | |
| 526 | - } | |
| 527 | 490 | else if ($k == 'MARGIN') { |
| 528 | 491 | $tmp = $this->expand24($v); |
| 529 | 492 | $newprop['MARGIN-TOP'] = $tmp['T']; |
| 530 | 493 | $newprop['MARGIN-RIGHT'] = $tmp['R']; |
| @@ -572,32 +535,26 @@ | ||
| 572 | 535 | $newprop['BORDER-LEFT'] = $this->_fix_borderStr($v); |
| 573 | 536 | } |
| 574 | 537 | else if ($k == 'BORDER-STYLE') { |
| 575 | 538 | $e = $this->expand24($v); |
| 576 | - if (!empty($e)) { | |
| 577 | - $newprop['BORDER-TOP-STYLE'] = $e['T']; | |
| 578 | - $newprop['BORDER-RIGHT-STYLE'] = $e['R']; | |
| 579 | - $newprop['BORDER-BOTTOM-STYLE'] = $e['B']; | |
| 580 | - $newprop['BORDER-LEFT-STYLE'] = $e['L']; | |
| 581 | - } | |
| 539 | + $newprop['BORDER-TOP-STYLE'] = $e['T']; | |
| 540 | + $newprop['BORDER-RIGHT-STYLE'] = $e['R']; | |
| 541 | + $newprop['BORDER-BOTTOM-STYLE'] = $e['B']; | |
| 542 | + $newprop['BORDER-LEFT-STYLE'] = $e['L']; | |
| 582 | 543 | } |
| 583 | 544 | else if ($k == 'BORDER-WIDTH') { |
| 584 | 545 | $e = $this->expand24($v); |
| 585 | - if (!empty($e)) { | |
| 586 | - $newprop['BORDER-TOP-WIDTH'] = $e['T']; | |
| 587 | - $newprop['BORDER-RIGHT-WIDTH'] = $e['R']; | |
| 588 | - $newprop['BORDER-BOTTOM-WIDTH'] = $e['B']; | |
| 589 | - $newprop['BORDER-LEFT-WIDTH'] = $e['L']; | |
| 590 | - } | |
| 546 | + $newprop['BORDER-TOP-WIDTH'] = $e['T']; | |
| 547 | + $newprop['BORDER-RIGHT-WIDTH'] = $e['R']; | |
| 548 | + $newprop['BORDER-BOTTOM-WIDTH'] = $e['B']; | |
| 549 | + $newprop['BORDER-LEFT-WIDTH'] = $e['L']; | |
| 591 | 550 | } |
| 592 | 551 | else if ($k == 'BORDER-COLOR') { |
| 593 | 552 | $e = $this->expand24($v); |
| 594 | - if (!empty($e)) { | |
| 595 | - $newprop['BORDER-TOP-COLOR'] = $e['T']; | |
| 596 | - $newprop['BORDER-RIGHT-COLOR'] = $e['R']; | |
| 597 | - $newprop['BORDER-BOTTOM-COLOR'] = $e['B']; | |
| 598 | - $newprop['BORDER-LEFT-COLOR'] = $e['L']; | |
| 599 | - } | |
| 553 | + $newprop['BORDER-TOP-COLOR'] = $e['T']; | |
| 554 | + $newprop['BORDER-RIGHT-COLOR'] = $e['R']; | |
| 555 | + $newprop['BORDER-BOTTOM-COLOR'] = $e['B']; | |
| 556 | + $newprop['BORDER-LEFT-COLOR'] = $e['L']; | |
| 600 | 557 | } |
| 601 | 558 | |
| 602 | 559 | else if ($k == 'BORDER-SPACING') { |
| 603 | 560 | $prop = preg_split('/\s+/',trim($v)); |
| @@ -724,8 +681,9 @@ | ||
| 724 | 681 | $angle = round($angle) * 90; |
| 725 | 682 | $newprop['IMAGE-ORIENTATION'] = $angle; |
| 726 | 683 | } |
| 727 | 684 | } |
| 685 | + // mPDF 5.6.13 | |
| 728 | 686 | else if ($k == 'TEXT-ALIGN') { |
| 729 | 687 | if (preg_match('/["\'](.){1}["\']/i',$v,$m)) { |
| 730 | 688 | $d = array_search($m[1],$this->mpdf->decimal_align); |
| 731 | 689 | if ($d !== false) { $newprop['TEXT-ALIGN'] = $d; } |
| @@ -740,27 +698,8 @@ | ||
| 740 | 698 | else { $newprop['TEXT-ALIGN'] .= 'R'; } // default = R |
| 741 | 699 | } |
| 742 | 700 | else { $newprop[$k] = $v; } |
| 743 | 701 | } |
| 744 | - // mpDF 6 Lists | |
| 745 | - else if ($k == 'LIST-STYLE') { | |
| 746 | - if (preg_match('/none/i',$v,$m)) { | |
| 747 | - $newprop['LIST-STYLE-TYPE'] = 'none'; | |
| 748 | - $newprop['LIST-STYLE-IMAGE'] = 'none'; | |
| 749 | - } | |
| 750 | - if (preg_match('/(lower-roman|upper-roman|lower-latin|lower-alpha|upper-latin|upper-alpha|decimal|disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao|cjk-decimal|hebrew)/i',$v,$m)) { | |
| 751 | - $newprop['LIST-STYLE-TYPE'] = strtolower(trim($m[1])); | |
| 752 | - } | |
| 753 | - else if (preg_match('/U\+([a-fA-F0-9]+)/i',$v,$m)) { | |
| 754 | - $newprop['LIST-STYLE-TYPE'] = strtolower(trim($m[1])); | |
| 755 | - } | |
| 756 | - if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)/i',$v,$m)) { | |
| 757 | - $newprop['LIST-STYLE-IMAGE'] = strtolower(trim($m[1])); | |
| 758 | - } | |
| 759 | - if (preg_match('/(inside|outside)/i',$v,$m)) { | |
| 760 | - $newprop['LIST-STYLE-POSITION'] = strtolower(trim($m[1])); | |
| 761 | - } | |
| 762 | - } | |
| 763 | 702 | |
| 764 | 703 | else { |
| 765 | 704 | $newprop[$k] = $v; |
| 766 | 705 | } |
| @@ -814,13 +753,13 @@ | ||
| 814 | 753 | $ss = explode(',',$v); |
| 815 | 754 | foreach ($ss AS $s) { |
| 816 | 755 | $new = array('blur'=>0); |
| 817 | 756 | $p = explode(' ',trim($s)); |
| 818 | - if (isset($p[0])) { $new['x'] = $this->mpdf->ConvertSize(trim($p[0]),$this->mpdf->FontSize,$this->mpdf->FontSize,false); } | |
| 819 | - if (isset($p[1])) { $new['y'] = $this->mpdf->ConvertSize(trim($p[1]),$this->mpdf->FontSize,$this->mpdf->FontSize,false); } | |
| 757 | + if (isset($p[0])) { $new['x'] = $this->mpdf->ConvertSize(trim($p[0]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); } | |
| 758 | + if (isset($p[1])) { $new['y'] = $this->mpdf->ConvertSize(trim($p[1]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); } | |
| 820 | 759 | if (isset($p[2])) { |
| 821 | 760 | if (preg_match('/^\s*[\.\-0-9]/',$p[2])) { |
| 822 | - $new['blur'] = $this->mpdf->ConvertSize(trim($p[2]),$this->mpdf->blk[$this->mpdf->blklvl]['inner_width'],$this->mpdf->FontSize,false); | |
| 761 | + $new['blur'] = $this->mpdf->ConvertSize(trim($p[2]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); | |
| 823 | 762 | } |
| 824 | 763 | else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[2])); } |
| 825 | 764 | if (isset($p[3])) { |
| 826 | 765 | $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[3])); |
| @@ -825,9 +764,9 @@ | ||
| 825 | 764 | if (isset($p[3])) { |
| 826 | 765 | $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[3])); |
| 827 | 766 | } |
| 828 | 767 | } |
| 829 | - if (!isset($new['col']) || !$new['col']) { $new['col'] = $this->mpdf->ConvertColor('#888888'); } | |
| 768 | + if (!$new['col']) { $new['col'] = $this->mpdf->ConvertColor('#888888'); } | |
| 830 | 769 | if (isset($new['y'])) { array_unshift($sh, $new); } |
| 831 | 770 | } |
| 832 | 771 | return $sh; |
| 833 | 772 | } |
| @@ -1022,13 +961,13 @@ | ||
| 1022 | 961 | } |
| 1023 | 962 | |
| 1024 | 963 | |
| 1025 | 964 | |
| 1026 | -function _mergeFullCSS($p, &$t, $tag, $classes, $id, $lang) { // mPDF 6 | |
| 1027 | - if (isset($p[$tag])) { $this->_mergeCSS($p[$tag], $t); } | |
| 965 | +function _mergeFullCSS($p, &$t, $tag, $classes, $id) { | |
| 966 | + $this->_mergeCSS($p[$tag], $t); | |
| 1028 | 967 | // STYLESHEET CLASS e.g. .smallone{} .redletter{} |
| 1029 | 968 | foreach($classes AS $class) { |
| 1030 | - if (isset($p['CLASS>>'.$class])) { $this->_mergeCSS($p['CLASS>>'.$class], $t); } | |
| 969 | + $this->_mergeCSS($p['CLASS>>'.$class], $t); | |
| 1031 | 970 | } |
| 1032 | 971 | // STYLESHEET nth-child SELECTOR e.g. tr:nth-child(odd) td:nth-child(2n+1) |
| 1033 | 972 | if ($tag=='TR' && isset($p) && $p) { |
| 1034 | 973 | foreach($p AS $k=>$val) { |
| @@ -1039,15 +978,19 @@ | ||
| 1039 | 978 | $thnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) : 0); |
| 1040 | 979 | $tfnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) : 0); |
| 1041 | 980 | if ($this->mpdf->tabletfoot) { $row -= $thnr; } |
| 1042 | 981 | else if (!$this->mpdf->tablethead) { $row -= ($thnr + $tfnr); } |
| 1043 | - if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4 | |
| 1044 | - $select = $this->_nthchild($a, $row); | |
| 982 | + if ($m[1]=='ODD' && ($row % 2) == 0) { $select = true; } | |
| 983 | + else if ($m[1]=='EVEN' && ($row % 2) == 1) { $select = true; } | |
| 984 | + else if (preg_match('/(\d+)N\+(\d+)/',$m[1],$a)) { | |
| 985 | + if ((($row + 1) % $a[1]) == $a[2]) { $select = true; } | |
| 1045 | 986 | } |
| 1046 | 987 | } |
| 1047 | 988 | else if ($tag=='TD' || $tag=='TH') { |
| 1048 | - if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4 | |
| 1049 | - $select = $this->_nthchild($a, $this->mpdf->col); | |
| 989 | + if ($m[1]=='ODD' && ($this->mpdf->col % 2) == 0) { $select = true; } | |
| 990 | + else if ($m[1]=='EVEN' && ($this->mpdf->col % 2) == 1) { $select = true; } | |
| 991 | + else if (preg_match('/(\d+)N\+(\d+)/',$m[1],$a)) { | |
| 992 | + if ((($this->mpdf->col + 1) % $a[1]) == $a[2]) { $select = true; } | |
| 1050 | 993 | } |
| 1051 | 994 | } |
| 1052 | 995 | if ($select) { |
| 1053 | 996 | $this->_mergeCSS($p[$tag.'>>SELECTORNTHCHILD>>'.$m[1]], $t); |
| @@ -1054,27 +997,18 @@ | ||
| 1054 | 997 | } |
| 1055 | 998 | } |
| 1056 | 999 | } |
| 1057 | 1000 | } |
| 1058 | - // STYLESHEET CLASS e.g. [lang=fr]{} or :lang(fr) | |
| 1059 | - if (isset($lang) && isset($p['LANG>>'.$lang])) { | |
| 1060 | - $this->_mergeCSS($p['LANG>>'.$lang], $t); | |
| 1061 | - } | |
| 1062 | 1001 | // STYLESHEET CLASS e.g. #smallone{} #redletter{} |
| 1063 | - if (isset($id) && isset($p['ID>>'.$id])) { | |
| 1002 | + if (isset($id) && $id) { | |
| 1064 | 1003 | $this->_mergeCSS($p['ID>>'.$id], $t); |
| 1065 | 1004 | } |
| 1066 | - | |
| 1067 | 1005 | // STYLESHEET CLASS e.g. .smallone{} .redletter{} |
| 1068 | 1006 | foreach($classes AS $class) { |
| 1069 | - if (isset($p[$tag.'>>CLASS>>'.$class])) { $this->_mergeCSS($p[$tag.'>>CLASS>>'.$class], $t); } | |
| 1007 | + $this->_mergeCSS($p[$tag.'>>CLASS>>'.$class], $t); | |
| 1070 | 1008 | } |
| 1071 | - // STYLESHEET CLASS e.g. [lang=fr]{} or :lang(fr) | |
| 1072 | - if (isset($lang) && isset($p[$tag.'>>LANG>>'.$lang])) { | |
| 1073 | - $this->_mergeCSS($p[$tag.'>>LANG>>'.$lang], $t); | |
| 1074 | - } | |
| 1075 | 1009 | // STYLESHEET CLASS e.g. #smallone{} #redletter{} |
| 1076 | - if (isset($id) && isset($p[$tag.'>>ID>>'.$id])) { | |
| 1010 | + if (isset($id)) { | |
| 1077 | 1011 | $this->_mergeCSS($p[$tag.'>>ID>>'.$id], $t); |
| 1078 | 1012 | } |
| 1079 | 1013 | } |
| 1080 | 1014 | |
| @@ -1133,17 +1067,8 @@ | ||
| 1133 | 1067 | if (isset($attr['CLASS'])) { |
| 1134 | 1068 | $classes = preg_split('/\s+/',$attr['CLASS']); |
| 1135 | 1069 | } |
| 1136 | 1070 | if (!isset($attr['ID'])) { $attr['ID']=''; } |
| 1137 | - // mPDF 6 | |
| 1138 | - $shortlang = ''; | |
| 1139 | - if (!isset($attr['LANG'])) { $attr['LANG']=''; } | |
| 1140 | - else { | |
| 1141 | - $attr['LANG'] = strtolower($attr['LANG']); | |
| 1142 | - if (strlen($attr['LANG']) == 5) { | |
| 1143 | - $shortlang = substr($attr['LANG'],0,2); | |
| 1144 | - } | |
| 1145 | - } | |
| 1146 | 1071 | //=============================================== |
| 1147 | 1072 | /*-- TABLES --*/ |
| 1148 | 1073 | // Set Inherited properties |
| 1149 | 1074 | if ($inherit == 'TOPTABLE') { // $tag = TABLE |
| @@ -1165,19 +1090,50 @@ | ||
| 1165 | 1090 | foreach($this->tablecascadeCSS[$this->tbCSSlvl-1] AS $k=>$v) { |
| 1166 | 1091 | $this->tablecascadeCSS[$this->tbCSSlvl][$k] = $v; |
| 1167 | 1092 | } |
| 1168 | 1093 | } |
| 1169 | - $this->_mergeFullCSS($this->cascadeCSS, $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID'], $attr['LANG']); | |
| 1094 | + $this->_mergeFullCSS($this->cascadeCSS, $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID']); | |
| 1170 | 1095 | //=============================================== |
| 1171 | 1096 | // Cascading forward CSS e.g. "table.topic td" for this table in $this->tablecascadeCSS |
| 1172 | 1097 | //=============================================== |
| 1173 | 1098 | // STYLESHEET TAG e.g. table |
| 1174 | - $this->_mergeFullCSS($this->tablecascadeCSS[$this->tbCSSlvl-1], $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID'], $attr['LANG']); | |
| 1099 | + $this->_mergeFullCSS($this->tablecascadeCSS[$this->tbCSSlvl-1], $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID']); | |
| 1175 | 1100 | //=============================================== |
| 1176 | 1101 | } |
| 1177 | 1102 | /*-- END TABLES --*/ |
| 1178 | 1103 | //=============================================== |
| 1104 | +/*-- LISTS --*/ | |
| 1179 | 1105 | // Set Inherited properties |
| 1106 | + if ($inherit == 'TOPLIST') { // $tag = UL,OL | |
| 1107 | + //=============================================== | |
| 1108 | + // Save Cascading CSS e.g. "div.topic p" at this block level | |
| 1109 | + if (isset($this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'])) { | |
| 1110 | + $this->listcascadeCSS[0] = $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS']; | |
| 1111 | + } | |
| 1112 | + else { | |
| 1113 | + $this->listcascadeCSS[0] = $this->cascadeCSS; | |
| 1114 | + } | |
| 1115 | + } | |
| 1116 | + //=============================================== | |
| 1117 | + // Set Inherited properties | |
| 1118 | + if ($inherit == 'TOPLIST' || $inherit == 'LIST') { | |
| 1119 | + //Cascade everything from last level that is not an actual property, or defined by current tag/attributes | |
| 1120 | + if (isset($this->listcascadeCSS[$this->listCSSlvl-1]) && is_array($this->listcascadeCSS[$this->listCSSlvl-1])) { | |
| 1121 | + foreach($this->listcascadeCSS[$this->listCSSlvl-1] AS $k=>$v) { | |
| 1122 | + $this->listcascadeCSS[$this->listCSSlvl][$k] = $v; | |
| 1123 | + } | |
| 1124 | + } | |
| 1125 | + $this->_mergeFullCSS($this->cascadeCSS, $this->listcascadeCSS[$this->listCSSlvl], $tag, $classes, $attr['ID']); | |
| 1126 | + //=============================================== | |
| 1127 | + // Cascading forward CSS e.g. "table.topic td" for this list in $this->listcascadeCSS | |
| 1128 | + //=============================================== | |
| 1129 | + // STYLESHEET TAG e.g. table | |
| 1130 | + $this->_mergeFullCSS($this->listcascadeCSS[$this->listCSSlvl-1], $this->listcascadeCSS[$this->listCSSlvl], $tag, $classes, $attr['ID']); | |
| 1131 | + //=============================================== | |
| 1132 | + } | |
| 1133 | +/*-- END LISTS --*/ | |
| 1134 | + //=============================================== | |
| 1135 | + // Set Inherited properties | |
| 1180 | 1136 | if ($inherit == 'BLOCK') { |
| 1181 | 1137 | if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS']) && is_array($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS'])) { |
| 1182 | 1138 | foreach($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS'] AS $k=>$v) { |
| 1183 | 1139 | $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'][$k] = $v; |
| @@ -1186,30 +1142,19 @@ | ||
| 1186 | 1142 | } |
| 1187 | 1143 | |
| 1188 | 1144 | //=============================================== |
| 1189 | 1145 | // Save Cascading CSS e.g. "div.topic p" at this block level |
| 1190 | - $this->_mergeFullCSS($this->cascadeCSS, $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'], $tag, $classes, $attr['ID'], $attr['LANG']); | |
| 1146 | + $this->_mergeFullCSS($this->cascadeCSS, $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'], $tag, $classes, $attr['ID']); | |
| 1191 | 1147 | //=============================================== |
| 1192 | 1148 | // Cascading forward CSS |
| 1193 | 1149 | //=============================================== |
| 1194 | - if (isset($this->mpdf->blk[$this->mpdf->blklvl-1])) { | |
| 1195 | - $this->_mergeFullCSS($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS'], $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'], $tag, $classes, $attr['ID'], $attr['LANG']); | |
| 1196 | - } | |
| 1150 | + $this->_mergeFullCSS($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS'], $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'], $tag, $classes, $attr['ID']); | |
| 1197 | 1151 | //=============================================== |
| 1198 | - // Block properties which are inherited | |
| 1152 | + // Block properties | |
| 1199 | 1153 | if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['margin_collapse']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['margin_collapse']) { $p['MARGIN-COLLAPSE'] = 'COLLAPSE'; } // custom tag, but follows CSS principle that border-collapse is inherited |
| 1200 | 1154 | if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['line_height']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['line_height']) { $p['LINE-HEIGHT'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['line_height']; } |
| 1201 | - // mPDF 6 | |
| 1202 | - if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['line_stacking_strategy']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['line_stacking_strategy']) { $p['LINE-STACKING-STRATEGY'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['line_stacking_strategy']; } | |
| 1203 | - if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['line_stacking_shift']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['line_stacking_shift']) { $p['LINE-STACKING-SHIFT'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['line_stacking_shift']; } | |
| 1204 | 1155 | |
| 1205 | 1156 | if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['direction']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['direction']) { $p['DIRECTION'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['direction']; } |
| 1206 | - // mPDF 6 Lists | |
| 1207 | - if ($tag == 'LI') { | |
| 1208 | - if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_type']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_type']) { $p['LIST-STYLE-TYPE'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_type']; } | |
| 1209 | - } | |
| 1210 | - if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_image']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_image']) { $p['LIST-STYLE-IMAGE'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_image']; } | |
| 1211 | - if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_position']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_position']) { $p['LIST-STYLE-POSITION'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['list_style_position']; } | |
| 1212 | 1157 | |
| 1213 | 1158 | if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['align']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['align']) { |
| 1214 | 1159 | if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'L') { $p['TEXT-ALIGN'] = 'left'; } |
| 1215 | 1160 | else if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'J') { $p['TEXT-ALIGN'] = 'justify'; } |
| @@ -1225,64 +1170,66 @@ | ||
| 1225 | 1170 | |
| 1226 | 1171 | if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['text_indent']) && ($this->mpdf->blk[$this->mpdf->blklvl-1]['text_indent'] || $this->mpdf->blk[$this->mpdf->blklvl-1]['text_indent']===0)) { $p['TEXT-INDENT'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['text_indent']; } |
| 1227 | 1172 | if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['InlineProperties'])) { |
| 1228 | 1173 | $biilp = $this->mpdf->blk[$this->mpdf->blklvl-1]['InlineProperties']; |
| 1229 | - $this->inlinePropsToCSS($biilp, $p); // mPDF 5.7.1 | |
| 1230 | 1174 | } |
| 1231 | 1175 | else { $biilp = null; } |
| 1176 | + if (isset($biilp[ 'family' ]) && $biilp[ 'family' ]) { $p['FONT-FAMILY'] = $biilp[ 'family' ]; } | |
| 1177 | + if (isset($biilp[ 'I' ]) && $biilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; } | |
| 1178 | + if (isset($biilp[ 'sizePt' ]) && $biilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $biilp[ 'sizePt' ] . 'pt'; } | |
| 1179 | + if (isset($biilp[ 'B' ]) && $biilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; } | |
| 1180 | + if (isset($biilp[ 'colorarray' ]) && $biilp[ 'colorarray' ]) { | |
| 1181 | + $cor = $biilp[ 'colorarray' ]; | |
| 1182 | + $p['COLOR'] = $this->mpdf->_colAtoString($cor); | |
| 1183 | + } | |
| 1184 | + if (isset($biilp[ 'fontkerning' ])) { | |
| 1185 | + if ($biilp[ 'fontkerning' ]) { $p['FONT-KERNING'] = 'normal'; } | |
| 1186 | + else { $p['FONT-KERNING'] = 'none'; } | |
| 1187 | + } | |
| 1188 | + if (isset($biilp[ 'lSpacingCSS' ]) && $biilp[ 'lSpacingCSS' ]) { $p['LETTER-SPACING'] = $biilp[ 'lSpacingCSS' ]; } | |
| 1189 | + if (isset($biilp[ 'wSpacingCSS' ]) && $biilp[ 'wSpacingCSS' ]) { $p['WORD-SPACING'] = $biilp[ 'wSpacingCSS' ]; } | |
| 1190 | + if (isset($biilp[ 'toupper' ]) && $biilp[ 'toupper' ]) { $p['TEXT-TRANSFORM'] = 'uppercase'; } | |
| 1191 | + else if (isset($biilp[ 'tolower' ]) && $biilp[ 'tolower' ]) { $p['TEXT-TRANSFORM'] = 'lowercase'; } | |
| 1192 | + else if (isset($biilp[ 'capitalize' ]) && $biilp[ 'capitalize' ]) { $p['TEXT-TRANSFORM'] = 'capitalize'; } | |
| 1193 | + // CSS says text-decoration is not inherited, but IE7 does?? | |
| 1194 | + if (isset($biilp[ 'underline' ]) && $biilp[ 'underline' ]) { $p['TEXT-DECORATION'] = 'underline'; } | |
| 1195 | + if (isset($biilp[ 'smCaps' ]) && $biilp[ 'smCaps' ]) { $p['FONT-VARIANT'] = 'small-caps'; } | |
| 1196 | + | |
| 1232 | 1197 | } |
| 1233 | 1198 | //=============================================== |
| 1234 | 1199 | //=============================================== |
| 1235 | - // INLINE HTML ATTRIBUTES e.g. .. ALIGN="CENTER"> | |
| 1236 | - // mPDF 6 (added) | |
| 1237 | - if (isset($attr['DIR']) and $attr['DIR']!='') { | |
| 1238 | - $p['DIRECTION'] = $attr['DIR']; | |
| 1239 | - } | |
| 1240 | - // mPDF 6 (moved) | |
| 1241 | - if (isset($attr['LANG']) and $attr['LANG']!='') { | |
| 1242 | - $p['LANG'] = $attr['LANG']; | |
| 1243 | - } | |
| 1244 | - if (isset($attr['COLOR']) and $attr['COLOR']!='') { | |
| 1245 | - $p['COLOR'] = $attr['COLOR']; | |
| 1246 | - } | |
| 1247 | - | |
| 1248 | - if ($tag != 'INPUT') { | |
| 1249 | - if (isset($attr['WIDTH']) and $attr['WIDTH']!='') { | |
| 1250 | - $p['WIDTH'] = $attr['WIDTH']; | |
| 1200 | +/*-- LISTS --*/ | |
| 1201 | + // Set Inherited properties | |
| 1202 | + if ($inherit == 'TOPLIST') { | |
| 1203 | + if ($this->listCSSlvl == 1) { | |
| 1204 | + $bilp = $this->mpdf->blk[$this->mpdf->blklvl]['InlineProperties']; | |
| 1205 | + if (isset($bilp[ 'family' ]) && $bilp[ 'family' ]) { $p['FONT-FAMILY'] = $bilp[ 'family' ]; } | |
| 1206 | + if (isset($bilp[ 'I' ]) && $bilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; } | |
| 1207 | + if (isset($bilp[ 'sizePt' ]) && $bilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $bilp[ 'sizePt' ] . 'pt'; } | |
| 1208 | + if (isset($bilp[ 'B' ]) && $bilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; } | |
| 1209 | + if (isset($bilp[ 'colorarray' ]) && $bilp[ 'colorarray' ]) { | |
| 1210 | + $cor = $bilp[ 'colorarray' ]; | |
| 1211 | + $p['COLOR'] = $this->mpdf->_colAtoString($cor); | |
| 1212 | + } | |
| 1213 | + if (isset($bilp[ 'toupper' ]) && $bilp[ 'toupper' ]) { $p['TEXT-TRANSFORM'] = 'uppercase'; } | |
| 1214 | + else if (isset($bilp[ 'tolower' ]) && $bilp[ 'tolower' ]) { $p['TEXT-TRANSFORM'] = 'lowercase'; } | |
| 1215 | + else if (isset($bilp[ 'capitalize' ]) && $bilp[ 'capitalize' ]) { $p['TEXT-TRANSFORM'] = 'capitalize'; } | |
| 1216 | + if (isset($bilp[ 'fontkerning' ])) { | |
| 1217 | + if ($bilp[ 'fontkerning' ]) { $p['FONT-KERNING'] = 'normal'; } | |
| 1218 | + else { $p['FONT-KERNING'] = 'none'; } | |
| 1219 | + } | |
| 1220 | + if (isset($bilp[ 'lSpacingCSS' ]) && $bilp[ 'lSpacingCSS' ]) { $p['LETTER-SPACING'] = $bilp[ 'lSpacingCSS' ]; } | |
| 1221 | + if (isset($bilp[ 'wSpacingCSS' ]) && $bilp[ 'wSpacingCSS' ]) { $p['WORD-SPACING'] = $bilp[ 'wSpacingCSS' ]; } | |
| 1222 | + // CSS says text-decoration is not inherited, but IE7 does?? | |
| 1223 | + if (isset($bilp[ 'underline' ]) && $bilp[ 'underline' ]) { $p['TEXT-DECORATION'] = 'underline'; } | |
| 1224 | + if (isset($bilp[ 'smCaps' ]) && $bilp[ 'smCaps' ]) { $p['FONT-VARIANT'] = 'small-caps'; } | |
| 1225 | + if ($tag=='LI') { | |
| 1226 | + // Note to self - this should never work, as TOPLIST is not called when LI (see code removed in v5.3) | |
| 1227 | + $this->mpdf->Error("If you see this message, please report this as a bug to the mPDF Forum."); | |
| 1228 | + } | |
| 1251 | 1229 | } |
| 1252 | - if (isset($attr['HEIGHT']) and $attr['HEIGHT']!='') { | |
| 1253 | - $p['HEIGHT'] = $attr['HEIGHT']; | |
| 1254 | - } | |
| 1255 | 1230 | } |
| 1256 | - if ($tag == 'FONT') { | |
| 1257 | - if (isset($attr['FACE'])) { | |
| 1258 | - $p['FONT-FAMILY'] = $attr['FACE']; | |
| 1259 | - } | |
| 1260 | - if (isset($attr['SIZE']) and $attr['SIZE']!='') { | |
| 1261 | - $s = ''; | |
| 1262 | - if ($attr['SIZE'] === '+1') { $s = '120%'; } | |
| 1263 | - else if ($attr['SIZE'] === '-1') { $s = '86%'; } | |
| 1264 | - else if ($attr['SIZE'] === '1') { $s = 'XX-SMALL'; } | |
| 1265 | - else if ($attr['SIZE'] == '2') { $s = 'X-SMALL'; } | |
| 1266 | - else if ($attr['SIZE'] == '3') { $s = 'SMALL'; } | |
| 1267 | - else if ($attr['SIZE'] == '4') { $s = 'MEDIUM'; } | |
| 1268 | - else if ($attr['SIZE'] == '5') { $s = 'LARGE'; } | |
| 1269 | - else if ($attr['SIZE'] == '6') { $s = 'X-LARGE'; } | |
| 1270 | - else if ($attr['SIZE'] == '7') { $s = 'XX-LARGE'; } | |
| 1271 | - if ($s) $p['FONT-SIZE'] = $s; | |
| 1272 | - } | |
| 1273 | - } | |
| 1274 | - if (isset($attr['VALIGN']) and $attr['VALIGN']!='') { | |
| 1275 | - $p['VERTICAL-ALIGN'] = $attr['VALIGN']; | |
| 1276 | - } | |
| 1277 | - if (isset($attr['VSPACE']) and $attr['VSPACE']!='') { | |
| 1278 | - $p['MARGIN-TOP'] = $attr['VSPACE']; | |
| 1279 | - $p['MARGIN-BOTTOM'] = $attr['VSPACE']; | |
| 1280 | - } | |
| 1281 | - if (isset($attr['HSPACE']) and $attr['HSPACE']!='') { | |
| 1282 | - $p['MARGIN-LEFT'] = $attr['HSPACE']; | |
| 1283 | - $p['MARGIN-RIGHT'] = $attr['HSPACE']; | |
| 1284 | - } | |
| 1231 | +/*-- END LISTS --*/ | |
| 1285 | 1232 | //=============================================== |
| 1286 | 1233 | //=============================================== |
| 1287 | 1234 | // DEFAULT for this TAG set in DefaultCSS |
| 1288 | 1235 | if (isset($this->mpdf->defaultCSS[$tag])) { |
| @@ -1293,15 +1240,10 @@ | ||
| 1293 | 1240 | } |
| 1294 | 1241 | } |
| 1295 | 1242 | //=============================================== |
| 1296 | 1243 | /*-- TABLES --*/ |
| 1297 | - // mPDF 5.7.3 | |
| 1298 | - // cellSpacing overwrites TABLE default but not specific CSS set on table | |
| 1299 | - if ($tag=='TABLE' && isset($attr['CELLSPACING'])) { | |
| 1300 | - $p['BORDER-SPACING-H'] = $p['BORDER-SPACING-V'] = $attr['CELLSPACING']; | |
| 1301 | - } | |
| 1302 | 1244 | // cellPadding overwrites TD/TH default but not specific CSS set on cell |
| 1303 | - if (($tag=='TD' || $tag=='TH') && isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']) && ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding'] || $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']==='0')) { // mPDF 5.7.3 | |
| 1245 | + if (($tag=='TD' || $tag=='TH') && isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']) && ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding'] || $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']===0)) { | |
| 1304 | 1246 | $p['PADDING-LEFT'] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']; |
| 1305 | 1247 | $p['PADDING-RIGHT'] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']; |
| 1306 | 1248 | $p['PADDING-TOP'] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']; |
| 1307 | 1249 | $p['PADDING-BOTTOM'] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']; |
| @@ -1340,15 +1282,19 @@ | ||
| 1340 | 1282 | $thnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) : 0); |
| 1341 | 1283 | $tfnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) : 0); |
| 1342 | 1284 | if ($this->mpdf->tabletfoot) { $row -= $thnr; } |
| 1343 | 1285 | else if (!$this->mpdf->tablethead) { $row -= ($thnr + $tfnr); } |
| 1344 | - if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4 | |
| 1345 | - $select = $this->_nthchild($a, $row); | |
| 1286 | + if ($m[1]=='ODD' && ($row % 2) == 0) { $select = true; } | |
| 1287 | + else if ($m[1]=='EVEN' && ($row % 2) == 1) { $select = true; } | |
| 1288 | + else if (preg_match('/(\d+)N\+(\d+)/',$m[1],$a)) { | |
| 1289 | + if ((($row + 1) % $a[1]) == $a[2]) { $select = true; } | |
| 1346 | 1290 | } |
| 1347 | 1291 | } |
| 1348 | 1292 | else if ($tag=='TD' || $tag=='TH') { |
| 1349 | - if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4 | |
| 1350 | - $select = $this->_nthchild($a, $this->mpdf->col); | |
| 1293 | + if ($m[1]=='ODD' && ($this->mpdf->col % 2) == 0) { $select = true; } | |
| 1294 | + else if ($m[1]=='EVEN' && ($this->mpdf->col % 2) == 1) { $select = true; } | |
| 1295 | + else if (preg_match('/(\d+)N\+(\d+)/',$m[1],$a)) { | |
| 1296 | + if ((($this->mpdf->col+1) % $a[1]) == $a[2]) { $select = true; } | |
| 1351 | 1297 | } |
| 1352 | 1298 | } |
| 1353 | 1299 | if ($select) { |
| 1354 | 1300 | $zp = $this->CSS[$tag.'>>SELECTORNTHCHILD>>'.$m[1]]; |
| @@ -1362,28 +1308,8 @@ | ||
| 1362 | 1308 | } |
| 1363 | 1309 | } |
| 1364 | 1310 | /*-- END TABLES --*/ |
| 1365 | 1311 | //=============================================== |
| 1366 | - // STYLESHEET LANG e.g. [lang=fr]{} or :lang(fr) | |
| 1367 | - if (isset($attr['LANG'])) { | |
| 1368 | - if (isset($this->CSS['LANG>>'.$attr['LANG']]) && $this->CSS['LANG>>'.$attr['LANG']]) { | |
| 1369 | - $zp = $this->CSS['LANG>>'.$attr['LANG']]; | |
| 1370 | - if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS* | |
| 1371 | - if (is_array($zp)) { | |
| 1372 | - $p = array_merge($p,$zp); | |
| 1373 | - $this->_mergeBorders($p,$zp); | |
| 1374 | - } | |
| 1375 | - } | |
| 1376 | - else if (isset($this->CSS['LANG>>'.$shortlang]) && $this->CSS['LANG>>'.$shortlang]) { | |
| 1377 | - $zp = $this->CSS['LANG>>'.$shortlang]; | |
| 1378 | - if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS* | |
| 1379 | - if (is_array($zp)) { | |
| 1380 | - $p = array_merge($p,$zp); | |
| 1381 | - $this->_mergeBorders($p,$zp); | |
| 1382 | - } | |
| 1383 | - } | |
| 1384 | - } | |
| 1385 | - //=============================================== | |
| 1386 | 1312 | // STYLESHEET ID e.g. #smallone{} #redletter{} |
| 1387 | 1313 | if (isset($attr['ID']) && isset($this->CSS['ID>>'.$attr['ID']]) && $this->CSS['ID>>'.$attr['ID']]) { |
| 1388 | 1314 | $zp = $this->CSS['ID>>'.$attr['ID']]; |
| 1389 | 1315 | if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS* |
| @@ -1391,9 +1317,8 @@ | ||
| 1391 | 1317 | $p = array_merge($p,$zp); |
| 1392 | 1318 | $this->_mergeBorders($p,$zp); |
| 1393 | 1319 | } |
| 1394 | 1320 | } |
| 1395 | - | |
| 1396 | 1321 | //=============================================== |
| 1397 | 1322 | // STYLESHEET CLASS e.g. p.smallone{} div.redletter{} |
| 1398 | 1323 | foreach($classes AS $class) { |
| 1399 | 1324 | $zp = array(); |
| @@ -1404,28 +1329,8 @@ | ||
| 1404 | 1329 | $this->_mergeBorders($p,$zp); |
| 1405 | 1330 | } |
| 1406 | 1331 | } |
| 1407 | 1332 | //=============================================== |
| 1408 | - // STYLESHEET LANG e.g. [lang=fr]{} or :lang(fr) | |
| 1409 | - if (isset($attr['LANG'])) { | |
| 1410 | - if (isset($this->CSS[$tag.'>>LANG>>'.$attr['LANG']]) && $this->CSS[$tag.'>>LANG>>'.$attr['LANG']]) { | |
| 1411 | - $zp = $this->CSS[$tag.'>>LANG>>'.$attr['LANG']]; | |
| 1412 | - if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS* | |
| 1413 | - if (is_array($zp)) { | |
| 1414 | - $p = array_merge($p,$zp); | |
| 1415 | - $this->_mergeBorders($p,$zp); | |
| 1416 | - } | |
| 1417 | - } | |
| 1418 | - else if (isset($this->CSS[$tag.'>>LANG>>'.$shortlang]) && $this->CSS[$tag.'>>LANG>>'.$shortlang]) { | |
| 1419 | - $zp = $this->CSS[$tag.'>>LANG>>'.$shortlang]; | |
| 1420 | - if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS* | |
| 1421 | - if (is_array($zp)) { | |
| 1422 | - $p = array_merge($p,$zp); | |
| 1423 | - $this->_mergeBorders($p,$zp); | |
| 1424 | - } | |
| 1425 | - } | |
| 1426 | - } | |
| 1427 | - //=============================================== | |
| 1428 | 1333 | // STYLESHEET CLASS e.g. p#smallone{} div#redletter{} |
| 1429 | 1334 | if (isset($attr['ID']) && isset($this->CSS[$tag.'>>ID>>'.$attr['ID']]) && $this->CSS[$tag.'>>ID>>'.$attr['ID']]) { |
| 1430 | 1335 | $zp = $this->CSS[$tag.'>>ID>>'.$attr['ID']]; |
| 1431 | 1336 | if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS* |
| @@ -1436,9 +1341,8 @@ | ||
| 1436 | 1341 | } |
| 1437 | 1342 | //=============================================== |
| 1438 | 1343 | // Cascaded e.g. div.class p only works for block level |
| 1439 | 1344 | if ($inherit == 'BLOCK') { |
| 1440 | - if (isset($this->mpdf->blk[$this->mpdf->blklvl-1])) { // mPDF 6 | |
| 1441 | 1345 | $this->_set_mergedCSS($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS'][$tag], $p); |
| 1442 | 1346 | foreach($classes AS $class) { |
| 1443 | 1347 | $this->_set_mergedCSS($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS']['CLASS>>'.$class], $p); |
| 1444 | 1348 | } |
| @@ -1446,9 +1350,8 @@ | ||
| 1446 | 1350 | foreach($classes AS $class) { |
| 1447 | 1351 | $this->_set_mergedCSS($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS'][$tag.'>>CLASS>>'.$class], $p); |
| 1448 | 1352 | } |
| 1449 | 1353 | $this->_set_mergedCSS($this->mpdf->blk[$this->mpdf->blklvl-1]['cascadeCSS'][$tag.'>>ID>>'.$attr['ID']], $p); |
| 1450 | - } | |
| 1451 | 1354 | } |
| 1452 | 1355 | else if ($inherit == 'INLINE') { |
| 1453 | 1356 | $this->_set_mergedCSS($this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'][$tag], $p); |
| 1454 | 1357 | foreach($classes AS $class) { |
| @@ -1461,9 +1364,8 @@ | ||
| 1461 | 1364 | $this->_set_mergedCSS($this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'][$tag.'>>ID>>'.$attr['ID']], $p); |
| 1462 | 1365 | } |
| 1463 | 1366 | /*-- TABLES --*/ |
| 1464 | 1367 | else if ($inherit == 'TOPTABLE' || $inherit == 'TABLE') { // NB looks at $this->tablecascadeCSS-1 for cascading CSS |
| 1465 | - if (isset($this->tablecascadeCSS[$this->tbCSSlvl-1])) { // mPDF 6 | |
| 1466 | 1368 | // false, 9 = don't check for 'depth' and do set border dominance |
| 1467 | 1369 | $this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1][$tag], $p, false, 9); |
| 1468 | 1370 | foreach($classes AS $class) { |
| 1469 | 1371 | $this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1]['CLASS>>'.$class], $p, false, 9); |
| @@ -1478,15 +1380,19 @@ | ||
| 1478 | 1380 | $thnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) : 0); |
| 1479 | 1381 | $tfnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) : 0); |
| 1480 | 1382 | if ($this->mpdf->tabletfoot) { $row -= $thnr; } |
| 1481 | 1383 | else if (!$this->mpdf->tablethead) { $row -= ($thnr + $tfnr); } |
| 1482 | - if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4 | |
| 1483 | - $select = $this->_nthchild($a, $row); | |
| 1384 | + if ($m[1]=='ODD' && ($row % 2) == 0) { $select = true; } | |
| 1385 | + else if ($m[1]=='EVEN' && ($row % 2) == 1) { $select = true; } | |
| 1386 | + else if (preg_match('/(\d+)N\+(\d+)/',$m[1],$a)) { | |
| 1387 | + if ((($row + 1) % $a[1]) == $a[2]) { $select = true; } | |
| 1484 | 1388 | } |
| 1485 | 1389 | } |
| 1486 | 1390 | else if ($tag=='TD' || $tag=='TH') { |
| 1487 | - if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4 | |
| 1488 | - $select = $this->_nthchild($a, $this->mpdf->col); | |
| 1391 | + if ($m[1]=='ODD' && ($this->mpdf->col % 2) == 0) { $select = true; } | |
| 1392 | + else if ($m[1]=='EVEN' && ($this->mpdf->col % 2) == 1) { $select = true; } | |
| 1393 | + else if (preg_match('/(\d+)N\+(\d+)/',$m[1],$a)) { | |
| 1394 | + if ((($this->mpdf->col + 1) % $a[1]) == $a[2]) { $select = true; } | |
| 1489 | 1395 | } |
| 1490 | 1396 | } |
| 1491 | 1397 | if ($select) { |
| 1492 | 1398 | $this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1][$tag.'>>SELECTORNTHCHILD>>'.$m[1]], $p, false, 9); |
| @@ -1492,9 +1398,8 @@ | ||
| 1492 | 1398 | $this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1][$tag.'>>SELECTORNTHCHILD>>'.$m[1]], $p, false, 9); |
| 1493 | 1399 | } |
| 1494 | 1400 | } |
| 1495 | 1401 | } |
| 1496 | - } | |
| 1497 | 1402 | } |
| 1498 | 1403 | $this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1]['ID>>'.$attr['ID']], $p, false, 9); |
| 1499 | 1404 | foreach($classes AS $class) { |
| 1500 | 1405 | $this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1][$tag.'>>CLASS>>'.$class], $p, false, 9); |
| @@ -1502,9 +1407,24 @@ | ||
| 1502 | 1407 | $this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1][$tag.'>>ID>>'.$attr['ID']], $p, false, 9); |
| 1503 | 1408 | } |
| 1504 | 1409 | /*-- END TABLES --*/ |
| 1505 | 1410 | //=============================================== |
| 1411 | +/*-- LISTS --*/ | |
| 1412 | + else if ($inherit == 'TOPLIST' || $inherit == 'LIST') { // NB looks at $this->listcascadeCSS-1 for cascading CSS | |
| 1413 | + // false = don't check for 'depth' | |
| 1414 | + $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1][$tag], $p, false); | |
| 1415 | + foreach($classes AS $class) { | |
| 1416 | + $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1]['CLASS>>'.$class], $p, false); | |
| 1417 | + } | |
| 1418 | + $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1]['ID>>'.$attr['ID']], $p, false); | |
| 1419 | + foreach($classes AS $class) { | |
| 1420 | + $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1][$tag.'>>CLASS>>'.$class], $p, false); | |
| 1421 | + } | |
| 1422 | + $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1][$tag.'>>ID>>'.$attr['ID']], $p, false); | |
| 1423 | + } | |
| 1424 | +/*-- END LISTS --*/ | |
| 1506 | 1425 | //=============================================== |
| 1426 | + //=============================================== | |
| 1507 | 1427 | // INLINE STYLE e.g. style="CSS:property" |
| 1508 | 1428 | if (isset($attr['STYLE'])) { |
| 1509 | 1429 | $zp = $this->readInlineCSS($attr['STYLE']); |
| 1510 | 1430 | if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS* |
| @@ -1514,95 +1434,54 @@ | ||
| 1514 | 1434 | } |
| 1515 | 1435 | } |
| 1516 | 1436 | //=============================================== |
| 1517 | 1437 | //=============================================== |
| 1518 | - return $p; | |
| 1519 | -} | |
| 1520 | - | |
| 1521 | - | |
| 1522 | -// Convert inline Properties back to CSS | |
| 1523 | -function inlinePropsToCSS($bilp, &$p) { | |
| 1524 | - if (isset($bilp[ 'family' ]) && $bilp[ 'family' ]) { $p['FONT-FAMILY'] = $bilp[ 'family' ]; } | |
| 1525 | - if (isset($bilp[ 'I' ]) && $bilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; } | |
| 1526 | - if (isset($bilp[ 'sizePt' ]) && $bilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $bilp[ 'sizePt' ] . 'pt'; } | |
| 1527 | - if (isset($bilp[ 'B' ]) && $bilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; } | |
| 1528 | - if (isset($bilp[ 'colorarray' ]) && $bilp[ 'colorarray' ]) { | |
| 1529 | - $cor = $bilp[ 'colorarray' ]; | |
| 1530 | - $p['COLOR'] = $this->mpdf->_colAtoString($cor); | |
| 1438 | + // INLINE ATTRIBUTES e.g. .. ALIGN="CENTER"> | |
| 1439 | + if (isset($attr['LANG']) and $attr['LANG']!='') { | |
| 1440 | + $p['LANG'] = $attr['LANG']; | |
| 1531 | 1441 | } |
| 1532 | - if (isset($bilp[ 'lSpacingCSS' ]) && $bilp[ 'lSpacingCSS' ]) { $p['LETTER-SPACING'] = $bilp[ 'lSpacingCSS' ]; } | |
| 1533 | - if (isset($bilp[ 'wSpacingCSS' ]) && $bilp[ 'wSpacingCSS' ]) { $p['WORD-SPACING'] = $bilp[ 'wSpacingCSS' ]; } | |
| 1534 | - | |
| 1535 | - if (isset($bilp[ 'textparam' ]) && $bilp[ 'textparam' ]) { | |
| 1536 | - if (isset($bilp[ 'textparam' ]['hyphens'])) { | |
| 1537 | - if ($bilp[ 'textparam' ]['hyphens']==2) { $p['HYPHENS'] = 'none'; } | |
| 1538 | - if ($bilp[ 'textparam' ]['hyphens']==1) { $p['HYPHENS'] = 'auto'; } | |
| 1539 | - if ($bilp[ 'textparam' ]['hyphens']==0) { $p['HYPHENS'] = 'manual'; } | |
| 1442 | + if (isset($attr['COLOR']) and $attr['COLOR']!='') { | |
| 1443 | + $p['COLOR'] = $attr['COLOR']; | |
| 1444 | + } | |
| 1445 | + if ($tag != 'INPUT') { | |
| 1446 | + if (isset($attr['WIDTH']) and $attr['WIDTH']!='') { | |
| 1447 | + $p['WIDTH'] = $attr['WIDTH']; | |
| 1540 | 1448 | } |
| 1541 | - if (isset($bilp[ 'textparam' ]['outline-s']) && !$bilp[ 'textparam' ]['outline-s']) { $p['TEXT-OUTLINE'] = 'none'; } | |
| 1542 | - if (isset($bilp[ 'textparam' ]['outline-COLOR']) && $bilp[ 'textparam' ]['outline-COLOR']) { $p['TEXT-OUTLINE-COLOR'] = $this->mpdf->_colAtoString($bilp[ 'textparam' ]['outline-COLOR']); } | |
| 1543 | - if (isset($bilp[ 'textparam' ]['outline-WIDTH']) && $bilp[ 'textparam' ]['outline-WIDTH']) { $p['TEXT-OUTLINE-WIDTH'] = $bilp[ 'textparam' ]['outline-WIDTH'].'mm'; } | |
| 1449 | + if (isset($attr['HEIGHT']) and $attr['HEIGHT']!='') { | |
| 1450 | + $p['HEIGHT'] = $attr['HEIGHT']; | |
| 1451 | + } | |
| 1544 | 1452 | } |
| 1545 | - | |
| 1546 | - if (isset($bilp[ 'textvar' ]) && $bilp[ 'textvar' ]) { | |
| 1547 | - // CSS says text-decoration is not inherited, but IE7 does?? | |
| 1548 | - if ($bilp[ 'textvar' ] & FD_LINETHROUGH) { | |
| 1549 | - if ($bilp[ 'textvar' ] & FD_UNDERLINE) { $p['TEXT-DECORATION'] = 'underline line-through'; } | |
| 1550 | - else { $p['TEXT-DECORATION'] = 'line-through'; } | |
| 1453 | + if ($tag == 'FONT') { | |
| 1454 | + if (isset($attr['FACE'])) { | |
| 1455 | + $p['FONT-FAMILY'] = $attr['FACE']; | |
| 1551 | 1456 | } |
| 1552 | - else if ($bilp[ 'textvar' ] & FD_UNDERLINE) { $p['TEXT-DECORATION'] = 'underline'; } | |
| 1553 | - else { $p['TEXT-DECORATION'] = 'none'; } | |
| 1554 | - | |
| 1555 | - if ($bilp[ 'textvar' ] & FA_SUPERSCRIPT) { $p['VERTICAL-ALIGN'] = 'super'; } | |
| 1556 | - else if ($bilp[ 'textvar' ] & FA_SUBSCRIPT) { $p['VERTICAL-ALIGN'] = 'sub'; } | |
| 1557 | - else { $p['VERTICAL-ALIGN'] = 'baseline'; } | |
| 1558 | - | |
| 1559 | - if ($bilp[ 'textvar' ] & FT_CAPITALIZE) { $p['TEXT-TRANSFORM'] = 'capitalize'; } | |
| 1560 | - else if ($bilp[ 'textvar' ] & FT_UPPERCASE) { $p['TEXT-TRANSFORM'] = 'uppercase'; } | |
| 1561 | - else if ($bilp[ 'textvar' ] & FT_LOWERCASE) { $p['TEXT-TRANSFORM'] = 'lowercase'; } | |
| 1562 | - else { $p['TEXT-TRANSFORM'] = 'none'; } | |
| 1563 | - | |
| 1564 | - if ($bilp[ 'textvar' ] & FC_KERNING) { $p['FONT-KERNING'] = 'normal'; } // ignore 'auto' as default already applied | |
| 1565 | - //if (isset($bilp[ 'OTLtags' ]) && $bilp[ 'OTLtags' ]['Plus'] contains 'kern' | |
| 1566 | - else { $p['FONT-KERNING'] = 'none'; } | |
| 1567 | - | |
| 1568 | - if ($bilp[ 'textvar' ] & FA_SUPERSCRIPT) { $p['FONT-VARIANT-POSITION'] = 'super'; } | |
| 1569 | - //if (isset($bilp[ 'OTLtags' ]) && $bilp[ 'OTLtags' ]['Plus'] contains 'sups' / 'subs' | |
| 1570 | - else if ($bilp[ 'textvar' ] & FA_SUBSCRIPT) { $p['FONT-VARIANT-POSITION'] = 'sub'; } | |
| 1571 | - else { $p['FONT-VARIANT-POSITION'] = 'normal'; } | |
| 1572 | - | |
| 1573 | - if ($bilp[ 'textvar' ] & FC_SMALLCAPS) { $p['FONT-VARIANT-CAPS'] = 'small-caps'; } | |
| 1457 | + if (isset($attr['SIZE']) and $attr['SIZE']!='') { | |
| 1458 | + $s = ''; | |
| 1459 | + if ($attr['SIZE'] === '+1') { $s = '120%'; } | |
| 1460 | + else if ($attr['SIZE'] === '-1') { $s = '86%'; } | |
| 1461 | + else if ($attr['SIZE'] === '1') { $s = 'XX-SMALL'; } | |
| 1462 | + else if ($attr['SIZE'] == '2') { $s = 'X-SMALL'; } | |
| 1463 | + else if ($attr['SIZE'] == '3') { $s = 'SMALL'; } | |
| 1464 | + else if ($attr['SIZE'] == '4') { $s = 'MEDIUM'; } | |
| 1465 | + else if ($attr['SIZE'] == '5') { $s = 'LARGE'; } | |
| 1466 | + else if ($attr['SIZE'] == '6') { $s = 'X-LARGE'; } | |
| 1467 | + else if ($attr['SIZE'] == '7') { $s = 'XX-LARGE'; } | |
| 1468 | + if ($s) $p['FONT-SIZE'] = $s; | |
| 1469 | + } | |
| 1574 | 1470 | } |
| 1575 | - if (isset($bilp[ 'fontLanguageOverride' ])) { | |
| 1576 | - if ($bilp[ 'fontLanguageOverride' ]) { $p['FONT-LANGUAGE-OVERRIDE'] = $bilp[ 'fontLanguageOverride' ]; } | |
| 1577 | - else { $p['FONT-LANGUAGE-OVERRIDE'] = 'normal'; } | |
| 1471 | + if (isset($attr['VALIGN']) and $attr['VALIGN']!='') { | |
| 1472 | + $p['VERTICAL-ALIGN'] = $attr['VALIGN']; | |
| 1578 | 1473 | } |
| 1579 | - // All the variations of font-variant-* we are going to set as font-feature-settings... | |
| 1580 | - if (isset($bilp[ 'OTLtags' ]) && $bilp[ 'OTLtags' ]) { | |
| 1581 | - $ffs = array(); | |
| 1582 | - if (isset($bilp['OTLtags']['Minus']) && $bilp['OTLtags']['Minus']) { | |
| 1583 | - $f = preg_split('/\s+/', trim($bilp['OTLtags']['Minus'])); | |
| 1584 | - foreach($f AS $ff) { $ffs[] = "'".$ff."' 0"; } | |
| 1585 | - } | |
| 1586 | - if (isset($bilp['OTLtags']['FFMinus']) && $bilp['OTLtags']['FFMinus']) { | |
| 1587 | - $f = preg_split('/\s+/', trim($bilp['OTLtags']['FFMinus'])); | |
| 1588 | - foreach($f AS $ff) { $ffs[] = "'".$ff."' 0"; } | |
| 1589 | - } | |
| 1590 | - if (isset($bilp['OTLtags']['Plus']) && $bilp['OTLtags']['Plus']) { | |
| 1591 | - $f = preg_split('/\s+/', trim($bilp['OTLtags']['Plus'])); | |
| 1592 | - foreach($f AS $ff) { $ffs[] = "'".$ff."' 1"; } | |
| 1593 | - } | |
| 1594 | - if (isset($bilp['OTLtags']['FFPlus']) && $bilp['OTLtags']['FFPlus']) { // May contain numeric value e.g. salt4 | |
| 1595 | - $f = preg_split('/\s+/', trim($bilp['OTLtags']['FFPlus'])); | |
| 1596 | - foreach($f AS $ff) { | |
| 1597 | - if (strlen($ff)>4) { $ffs[] = "'".substr($ff,0,4)."' ".substr($ff,4); } | |
| 1598 | - else { $ffs[] = "'".$ff."' 1"; } | |
| 1599 | - } | |
| 1600 | - } | |
| 1601 | - $p['FONT-FEATURE-SETTINGS'] = implode(', ', $ffs); | |
| 1474 | + if (isset($attr['VSPACE']) and $attr['VSPACE']!='') { | |
| 1475 | + $p['MARGIN-TOP'] = $attr['VSPACE']; | |
| 1476 | + $p['MARGIN-BOTTOM'] = $attr['VSPACE']; | |
| 1602 | 1477 | } |
| 1603 | - | |
| 1604 | - | |
| 1478 | + if (isset($attr['HSPACE']) and $attr['HSPACE']!='') { | |
| 1479 | + $p['MARGIN-LEFT'] = $attr['HSPACE']; | |
| 1480 | + $p['MARGIN-RIGHT'] = $attr['HSPACE']; | |
| 1481 | + } | |
| 1482 | + //=============================================== | |
| 1483 | + return $p; | |
| 1605 | 1484 | } |
| 1606 | 1485 | |
| 1607 | 1486 | function PreviewBlockCSS($tag,$attr) { |
| 1608 | 1487 | // Looks ahead from current block level to a new level |
| @@ -1678,42 +1557,8 @@ | ||
| 1678 | 1557 | return $p; |
| 1679 | 1558 | } |
| 1680 | 1559 | |
| 1681 | 1560 | |
| 1682 | -// mPDF 5.7.4 nth-child | |
| 1683 | -function _nthchild($f, $c) { | |
| 1684 | - // $f is formual e.g. 2N+1 spilt into a preg_match array | |
| 1685 | - // $c is the comparator value e.g row or column number | |
| 1686 | - $c += 1; | |
| 1687 | - $select = false; | |
| 1688 | - $a=1; $b=1; | |
| 1689 | - if ($f[0]=='ODD') { $a=2; $b=1; } | |
| 1690 | - else if ($f[0]=='EVEN') { $a=2; $b=0; } | |
| 1691 | - else if (count($f)==2) { $a=0; $b=$f[1]+0; } // e.g. (+6) | |
| 1692 | - else if (count($f)==3) { // e.g. (2N) | |
| 1693 | - if ($f[2]=='') { $a=1; } | |
| 1694 | - else if ($f[2]=='-') { $a=-1; } | |
| 1695 | - else { $a=$f[2]+0; } | |
| 1696 | - $b=0; | |
| 1697 | - } | |
| 1698 | - else if (count($f)==4) { // e.g. (2N+6) | |
| 1699 | - if ($f[2]=='') { $a=1; } | |
| 1700 | - else if ($f[2]=='-') { $a=-1; } | |
| 1701 | - else { $a=$f[2]+0; } | |
| 1702 | - $b=$f[3]+0; | |
| 1703 | - } | |
| 1704 | - else { return false; } | |
| 1705 | - if ($a>0) { | |
| 1706 | - if (((($c % $a) - $b) % $a) == 0 && $c >= $b) { $select = true; } | |
| 1707 | - } | |
| 1708 | - else if ($a==0) { | |
| 1709 | - if ($c == $b) { $select = true; } | |
| 1710 | - } | |
| 1711 | - else { // if ($a<0) | |
| 1712 | - if (((($c % $a) - $b) % $a) == 0 && $c <= $b) { $select = true; } | |
| 1713 | - } | |
| 1714 | - return $select; | |
| 1715 | -} | |
| 1716 | 1561 | |
| 1717 | 1562 | |
| 1718 | 1563 | |
| 1719 | 1564 | } // end of class |