PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 1.7.3
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v1.7.3
trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 All 71 releases
← All changes | mpdf/classes/cssmgr.php +29 -115 1.8.01.7.3 View file →
@@ -220,10 +220,11 @@
220 220 }
221 221 }
222 222 }
223 223
224 + // mPDF 5.5.13
224 225 // Replace any background: url(data:image... with temporary image file reference
225 - 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);
226 227 if (count($idata[0])) {
227 228 for($i=0;$i<count($idata[0]);$i++) {
228 229 $file = _MPDF_TEMP_PATH.'_tempCSSidata'.RAND(1,10000).'_'.$i.'.'.$idata[2][$i];
229 230 //Save to local file
@@ -233,33 +234,8 @@
233 234 }
234 235 }
235 236
236 237 $CSSstr = preg_replace('/(<\!\-\-|\-\->)/s',' ',$CSSstr);
237 -
238 - // mPDF 5.7.4 URLs
239 - // Characters "(" ")" and ";" in url() e.g. background-image, cause problems parsing the CSS string
240 - // URLencode ( and ), but change ";" to a code which can be converted back after parsing (so as not to confuse ;
241 - // with a segment delimiter in the URI)
242 - $tempmarker = '%ZZ';
243 - if (strpos($CSSstr,'url(')!==false) {
244 - preg_match_all( '/url\(\"(.*?)\"\)/', $CSSstr, $m);
245 - for($i = 0; $i < count($m[1]) ; $i++) {
246 - $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
247 - $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $CSSstr);
248 - }
249 - preg_match_all( '/url\(\'(.*?)\'\)/', $CSSstr, $m);
250 - for($i = 0; $i < count($m[1]) ; $i++) {
251 - $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
252 - $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $CSSstr);
253 - }
254 - preg_match_all( '/url\(([^\'\"].*?[^\'\"])\)/', $CSSstr, $m);
255 - for($i = 0; $i < count($m[1]) ; $i++) {
256 - $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
257 - $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $CSSstr);
258 - }
259 - }
260 -
261 -
262 238 if ($CSSstr ) {
263 239 preg_match_all('/(.*?)\{(.*?)\}/',$CSSstr,$styles);
264 240 for($i=0; $i < count($styles[1]) ; $i++) {
265 241 // SET array e.g. $classproperties['COLOR'] = '#ffffff';
@@ -269,9 +245,8 @@
269 245 if (trim($sta)) {
270 246 // Changed to allow style="background: url('http://www.bpm1.com/bg.jpg')"
271 247 list($property,$value) = explode(':',$sta,2);
272 248 $property = trim($property);
273 - $value = str_replace($tempmarker,';',$value); // mPDF 5.7.4 URLs
274 249 $value = preg_replace('/\s*!important/i','',$value);
275 250 $value = trim($value);
276 251 if ($property && ($value || $value==='0')) {
277 252 // Ignores -webkit-gradient so doesn't override -moz-
@@ -286,12 +261,8 @@
286 261 $tagstr = strtoupper(trim($styles[1][$i]));
287 262 $tagarr = explode(',',$tagstr);
288 263 $pageselectors = false; // used to turn on $this->mpdf->mirrorMargins
289 264 foreach($tagarr AS $tg) {
290 - // mPDF 5.7.4
291 - if (preg_match('/NTH-CHILD\((\s*(([\-+]?\d*)N(\s*[\-+]\s*\d+)?|[\-+]?\d+|ODD|EVEN)\s*)\)/',$tg,$m) ) {
292 - $tg = preg_replace('/NTH-CHILD\(.*\)/', 'NTH-CHILD('.str_replace(' ','',$m[1]).')', $tg);
293 - }
294 265 $tags = preg_split('/\s+/',trim($tg));
295 266 $level = count($tags);
296 267 $t = '';
297 268 $t2 = '';
@@ -315,9 +286,9 @@
315 286 else if ($tag) { $this->CSS[$tag] = $classproperties; }
316 287 }
317 288
318 289 else if ($level == 1) { // e.g. p or .class or #id or p.class or p#id
319 - if (isset($tags[0])) { $t = trim($tags[0]); }
290 + if (isset($tags[0])) { $t = trim($tags[0]); }
320 291 if ($t) {
321 292 $tag = '';
322 293 if (preg_match('/^[.](.*)$/',$t,$m)) { $tag = 'CLASS>>'.$m[1]; }
323 294 else if (preg_match('/^[#](.*)$/',$t,$m)) { $tag = 'ID>>'.$m[1]; }
@@ -372,31 +343,8 @@
372 343
373 344
374 345
375 346 function readInlineCSS($html) {
376 - $html=htmlspecialchars_decode($html); // mPDF 5.7.4 URLs
377 - // mPDF 5.7.4 URLs
378 - // Characters "(" ")" and ";" in url() e.g. background-image, cause probems parsing the CSS string
379 - // URLencode ( and ), but change ";" to a code which can be converted back after parsing (so as not to confuse ;
380 - // with a segment delimiter in the URI)
381 - $tempmarker = '%ZZ';
382 - if (strpos($html,'url(')!==false) {
383 - preg_match_all( '/url\(\"(.*?)\"\)/', $html, $m);
384 - for($i = 0; $i < count($m[1]) ; $i++) {
385 - $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
386 - $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $html);
387 - }
388 - preg_match_all( '/url\(\'(.*?)\'\)/', $html, $m);
389 - for($i = 0; $i < count($m[1]) ; $i++) {
390 - $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
391 - $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $html);
392 - }
393 - preg_match_all( '/url\(([^\'\"].*?[^\'\"])\)/', $html, $m);
394 - for($i = 0; $i < count($m[1]) ; $i++) {
395 - $tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
396 - $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $html);
397 - }
398 - }
399 347 //Fix incomplete CSS code
400 348 $size = strlen($html)-1;
401 349 if (substr($html,$size,1) != ';') $html .= ';';
402 350 //Make CSS[Name-of-the-class] = array(key => value)
@@ -410,9 +358,8 @@
410 358 // Ignores -webkit-gradient so doesn't override -moz-
411 359 if ((strtoupper($properties[$i])=='BACKGROUND-IMAGE' || strtoupper($properties[$i])=='BACKGROUND') && preg_match('/-webkit-gradient/i',$values[$i])) {
412 360 continue;
413 361 }
414 - $values[$i] = str_replace($tempmarker,';',$values[$i]); // mPDF 5.7.4 URLs
415 362 $classproperties[strtoupper($properties[$i])] = trim($values[$i]);
416 363 }
417 364 return $this->fixCSS($classproperties);
418 365 }
@@ -751,16 +698,9 @@
751 698 else { $newprop['TEXT-ALIGN'] .= 'R'; } // default = R
752 699 }
753 700 else { $newprop[$k] = $v; }
754 701 }
755 - else if ($k == 'LIST-STYLE') { // mPDF 5.7.2
756 - if (preg_match('/(lower-roman|upper-roman|lower-latin|lower-alpha|upper-latin|upper-alpha|none|decimal|disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao)/i',$v,$m)
757 - || preg_match('/U\+([a-fA-F0-9]+)/i',$v,$m)) {
758 - $newprop['LIST-STYLE-TYPE'] = strtolower(trim($m[1]));
759 - }
760 - }
761 702
762 -
763 703 else {
764 704 $newprop[$k] = $v;
765 705 }
766 706 }
@@ -1038,15 +978,19 @@
1038 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);
1039 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);
1040 980 if ($this->mpdf->tabletfoot) { $row -= $thnr; }
1041 981 else if (!$this->mpdf->tablethead) { $row -= ($thnr + $tfnr); }
1042 - if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4
1043 - $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; }
1044 986 }
1045 987 }
1046 988 else if ($tag=='TD' || $tag=='TH') {
1047 - if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4
1048 - $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; }
1049 993 }
1050 994 }
1051 995 if ($select) {
1052 996 $this->_mergeCSS($p[$tag.'>>SELECTORNTHCHILD>>'.$m[1]], $t);
@@ -1296,15 +1240,10 @@
1296 1240 }
1297 1241 }
1298 1242 //===============================================
1299 1243 /*-- TABLES --*/
1300 - // mPDF 5.7.3
1301 - // cellSpacing overwrites TABLE default but not specific CSS set on table
1302 - if ($tag=='TABLE' && isset($attr['CELLSPACING'])) {
1303 - $p['BORDER-SPACING-H'] = $p['BORDER-SPACING-V'] = $attr['CELLSPACING'];
1304 - }
1305 1244 // cellPadding overwrites TD/TH default but not specific CSS set on cell
1306 - 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)) {
1307 1246 $p['PADDING-LEFT'] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding'];
1308 1247 $p['PADDING-RIGHT'] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding'];
1309 1248 $p['PADDING-TOP'] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding'];
1310 1249 $p['PADDING-BOTTOM'] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding'];
@@ -1343,15 +1282,19 @@
1343 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);
1344 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);
1345 1284 if ($this->mpdf->tabletfoot) { $row -= $thnr; }
1346 1285 else if (!$this->mpdf->tablethead) { $row -= ($thnr + $tfnr); }
1347 - if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4
1348 - $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; }
1349 1290 }
1350 1291 }
1351 1292 else if ($tag=='TD' || $tag=='TH') {
1352 - if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4
1353 - $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; }
1354 1297 }
1355 1298 }
1356 1299 if ($select) {
1357 1300 $zp = $this->CSS[$tag.'>>SELECTORNTHCHILD>>'.$m[1]];
@@ -1437,15 +1380,19 @@
1437 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);
1438 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);
1439 1382 if ($this->mpdf->tabletfoot) { $row -= $thnr; }
1440 1383 else if (!$this->mpdf->tablethead) { $row -= ($thnr + $tfnr); }
1441 - if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4
1442 - $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; }
1443 1388 }
1444 1389 }
1445 1390 else if ($tag=='TD' || $tag=='TH') {
1446 - if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) { // mPDF 5.7.4
1447 - $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; }
1448 1395 }
1449 1396 }
1450 1397 if ($select) {
1451 1398 $this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1][$tag.'>>SELECTORNTHCHILD>>'.$m[1]], $p, false, 9);
@@ -1609,42 +1556,9 @@
1609 1556 //===============================================
1610 1557 return $p;
1611 1558 }
1612 1559
1613 -// mPDF 5.7.4 nth-child
1614 -function _nthchild($f, $c) {
1615 - // $f is formual e.g. 2N+1 spilt into a preg_match array
1616 - // $c is the comparator value e.g row or column number
1617 - $c += 1;
1618 - $select = false;
1619 - $a=1; $b=1;
1620 - if ($f[0]=='ODD') { $a=2; $b=1; }
1621 - else if ($f[0]=='EVEN') { $a=2; $b=0; }
1622 - else if (count($f)==2) { $a=0; $b=$f[1]+0; } // e.g. (+6)
1623 - else if (count($f)==3) { // e.g. (2N)
1624 - if ($f[2]=='') { $a=1; }
1625 - else if ($f[2]=='-') { $a=-1; }
1626 - else { $a=$f[2]+0; }
1627 - $b=0;
1628 - }
1629 - else if (count($f)==4) { // e.g. (2N+6)
1630 - if ($f[2]=='') { $a=1; }
1631 - else if ($f[2]=='-') { $a=-1; }
1632 - else { $a=$f[2]+0; }
1633 - $b=$f[3]+0;
1634 - }
1635 - else { return false; }
1636 - if ($a>0) {
1637 - if (((($c % $a) - $b) % $a) == 0 && $c >= $b) { $select = true; }
1638 - }
1639 - else if ($a==0) {
1640 - if ($c == $b) { $select = true; }
1641 - }
1642 - else { // if ($a<0)
1643 - if (((($c % $a) - $b) % $a) == 0 && $c <= $b) { $select = true; }
1644 - }
1645 - return $select;
1646 -}
1560 +
1647 1561
1648 1562
1649 1563
1650 1564 } // end of class