@@ -587,14 +587,14 @@ |
||
587 | 587 | foreach ($this->name as $i => $name) { |
588 | 588 | if ($name == 'input' && isset($this->attribute[$i]['type'])) { |
589 | 589 | switch ($this->attribute[$i]['type']) { |
590 | - case 'text': |
|
591 | - $this->attribute[$i]['readonly'] = 'true'; |
|
592 | - $this->attribute[$i]['style'] = 'border: 1 dotted #999999'; |
|
593 | - break; |
|
594 | - case 'select': |
|
595 | - case 'checkbox': |
|
596 | - $this->attribute[$i]['disabled'] = 1; |
|
597 | - break; |
|
590 | + case 'text': |
|
591 | + $this->attribute[$i]['readonly'] = 'true'; |
|
592 | + $this->attribute[$i]['style'] = 'border: 1 dotted #999999'; |
|
593 | + break; |
|
594 | + case 'select': |
|
595 | + case 'checkbox': |
|
596 | + $this->attribute[$i]['disabled'] = 1; |
|
597 | + break; |
|
598 | 598 | } |
599 | 599 | } elseif ($name == 'textarea') { |
600 | 600 | $this->attribute[$i]['readonly'] = 'true'; |
@@ -310,154 +310,154 @@ |
||
310 | 310 | continue; |
311 | 311 | } |
312 | 312 | switch ($element) { |
313 | - case 'table': |
|
314 | - $tdopen = 0; |
|
315 | - $a = &$t->attribute[$i]; |
|
316 | - if (isset($a['width'])) { |
|
317 | - $table['w'] = $this->_calWidth($a['width']); |
|
318 | - } |
|
319 | - if (isset($a['height'])) { |
|
320 | - $table['h'] = intval($a['height']); |
|
321 | - } |
|
322 | - if (isset($a['align'])) { |
|
323 | - $table['a'] = $this->getAlign(strtolower($a['align'])); |
|
324 | - } |
|
325 | - $table['border'] = (isset($a['border'])) ? $a['border'] : 0; |
|
326 | - if (isset($a['bgcolor'])) { |
|
327 | - $table['bgcolor'][-1] = $a['bgcolor']; |
|
328 | - } |
|
329 | - $table['nobreak'] = isset($a['nobreak']); |
|
330 | - break; |
|
331 | - case 'tr': |
|
332 | - $tdopen = 0; |
|
333 | - $row++; |
|
334 | - $table['nr']++; |
|
335 | - $col = -1; |
|
336 | - $a = &$t->attribute[$i]; |
|
337 | - if (isset($a['bgcolor'])) { |
|
338 | - $table['bgcolor'][$row] = $a['bgcolor']; |
|
339 | - } |
|
340 | - if (isset($a['repeat'])) { |
|
341 | - $table['repeat'][] = $row; |
|
342 | - } else { |
|
343 | - if (isset($a['pbr'])) { |
|
344 | - $table['pbr'][$row] = 1; |
|
345 | - } |
|
346 | - if (isset($a['knext'])) { |
|
347 | - $table['knext'][$row] = 1; |
|
348 | - } |
|
349 | - } |
|
350 | - break; |
|
351 | - case 'td': |
|
352 | - $tdopen = 1; |
|
353 | - $col++; while (isset($cell[$row][$col])) { |
|
354 | - $col++; |
|
355 | - } |
|
356 | - //Update number column |
|
357 | - if ($table['nc'] < $col + 1) { |
|
358 | - $table['nc'] = $col + 1; |
|
359 | - } |
|
360 | - $cell[$row][$col] = []; |
|
361 | - $c = &$cell[$row][$col]; |
|
362 | - $a = &$t->attribute[$i]; |
|
363 | - if (isset($a['width'])) { |
|
364 | - $c['w'] = intval($a['width']); |
|
365 | - } |
|
366 | - if (isset($a['height'])) { |
|
367 | - $c['h'] = intval($a['height']); |
|
368 | - } |
|
369 | - $c['a'] = isset($a['align']) ? $this->getAlign($a['align']) : 'L'; |
|
370 | - $c['va'] = isset($a['valign']) ? $this->getVAlign($a['valign']) : 'T'; |
|
371 | - if (isset($a['border'])) { |
|
372 | - $c['border'] = $a['border']; |
|
373 | - } else { |
|
374 | - $c['border'] = $table['border']; |
|
375 | - } |
|
376 | - if (isset($a['bgcolor'])) { |
|
377 | - $c['bgcolor'] = $a['bgcolor']; |
|
378 | - } |
|
379 | - $cs = $rs = 1; |
|
380 | - if (isset($a['colspan']) && $a['colspan'] > 1) { |
|
381 | - $cs = $c['colspan'] = intval($a['colspan']); |
|
382 | - } |
|
383 | - if (isset($a['rowspan']) && $a['rowspan'] > 1) { |
|
384 | - $rs = $c['rowspan'] = intval($a['rowspan']); |
|
385 | - } |
|
386 | - if (isset($a['size'])) { |
|
387 | - $c['font'][0]['size'] = $a['size']; |
|
388 | - } |
|
389 | - if (isset($a['family'])) { |
|
390 | - $c['font'][0]['family'] = $a['family']; |
|
391 | - } |
|
392 | - if (isset($a['style'])) { |
|
393 | - $STYLE = explode(',', strtoupper($a['style'])); |
|
394 | - $fontStyle = ''; |
|
395 | - foreach ($STYLE as $style) { |
|
396 | - $fontStyle .= substr(trim($style), 0, 1); |
|
397 | - } |
|
398 | - $c['font'][0]['style'] = $fontStyle; |
|
399 | - } |
|
400 | - if (isset($a['color'])) { |
|
401 | - $c['font'][0]['color'] = $a['color']; |
|
402 | - } |
|
403 | - //Chiem dung vi tri de danh cho cell span |
|
404 | - for ($k = $row; $k < $row + $rs; $k++) { |
|
405 | - for ($l = $col; $l < $col + $cs; $l++) { |
|
406 | - if ($k - $row || $l - $col) { |
|
407 | - $cell[$k][$l] = 0; |
|
408 | - } |
|
409 | - } |
|
410 | - } |
|
411 | - if (isset($a['nowrap'])) { |
|
412 | - $c['nowrap'] = 1; |
|
413 | - } |
|
414 | - $fontopen = true; |
|
415 | - if (!isset($c['font'])) { |
|
416 | - $c['font'][] = []; |
|
417 | - } |
|
418 | - break; |
|
419 | - case 'Text': |
|
420 | - $c = &$cell[$row][$col]; |
|
421 | - if (!$fontopen || !isset($c['font'])) { |
|
422 | - $c['font'][] = []; |
|
423 | - } |
|
424 | - $f = &$c['font'][count($c['font']) - 1]; |
|
425 | - $this->_setTextAndSize($c, $f, $this->_html2text($t->value[$i])); |
|
426 | - break; |
|
427 | - case 'font': |
|
428 | - $a = &$t->attribute[$i]; |
|
429 | - $c = &$cell[$row][$col]; |
|
430 | - $c['font'][] = []; |
|
431 | - $f = &$c['font'][count($c['font']) - 1]; |
|
432 | - if (isset($a['size'])) { |
|
433 | - $f['size'] = $a['size']; |
|
434 | - } |
|
435 | - if (isset($a['family'])) { |
|
436 | - $f['family'] = $a['family']; |
|
437 | - } |
|
438 | - if (isset($a['style'])) { |
|
439 | - $STYLE = explode(',', strtoupper($a['style'])); |
|
440 | - $fontStyle = ''; |
|
441 | - foreach ($STYLE as $style) { |
|
442 | - $fontStyle .= substr(trim($style), 0, 1); |
|
443 | - } |
|
444 | - $f['style'] = $fontStyle; |
|
445 | - } |
|
446 | - if (isset($a['color'])) { |
|
447 | - $f['color'] = $a['color']; |
|
448 | - } |
|
449 | - break; |
|
450 | - case 'img': |
|
451 | - $a = &$t->attribute[$i]; |
|
452 | - if (isset($a['src'])) { |
|
453 | - $this->_setImage($c, $a); |
|
454 | - } |
|
455 | - break; |
|
456 | - case 'br': |
|
457 | - $c = &$cell[$row][$col]; |
|
458 | - $cn = isset($c['font']) ? count($c['font']) - 1 : 0; |
|
459 | - $c['font'][$cn]['line'][] = 'br'; |
|
460 | - break; |
|
313 | + case 'table': |
|
314 | + $tdopen = 0; |
|
315 | + $a = &$t->attribute[$i]; |
|
316 | + if (isset($a['width'])) { |
|
317 | + $table['w'] = $this->_calWidth($a['width']); |
|
318 | + } |
|
319 | + if (isset($a['height'])) { |
|
320 | + $table['h'] = intval($a['height']); |
|
321 | + } |
|
322 | + if (isset($a['align'])) { |
|
323 | + $table['a'] = $this->getAlign(strtolower($a['align'])); |
|
324 | + } |
|
325 | + $table['border'] = (isset($a['border'])) ? $a['border'] : 0; |
|
326 | + if (isset($a['bgcolor'])) { |
|
327 | + $table['bgcolor'][-1] = $a['bgcolor']; |
|
328 | + } |
|
329 | + $table['nobreak'] = isset($a['nobreak']); |
|
330 | + break; |
|
331 | + case 'tr': |
|
332 | + $tdopen = 0; |
|
333 | + $row++; |
|
334 | + $table['nr']++; |
|
335 | + $col = -1; |
|
336 | + $a = &$t->attribute[$i]; |
|
337 | + if (isset($a['bgcolor'])) { |
|
338 | + $table['bgcolor'][$row] = $a['bgcolor']; |
|
339 | + } |
|
340 | + if (isset($a['repeat'])) { |
|
341 | + $table['repeat'][] = $row; |
|
342 | + } else { |
|
343 | + if (isset($a['pbr'])) { |
|
344 | + $table['pbr'][$row] = 1; |
|
345 | + } |
|
346 | + if (isset($a['knext'])) { |
|
347 | + $table['knext'][$row] = 1; |
|
348 | + } |
|
349 | + } |
|
350 | + break; |
|
351 | + case 'td': |
|
352 | + $tdopen = 1; |
|
353 | + $col++; while (isset($cell[$row][$col])) { |
|
354 | + $col++; |
|
355 | + } |
|
356 | + //Update number column |
|
357 | + if ($table['nc'] < $col + 1) { |
|
358 | + $table['nc'] = $col + 1; |
|
359 | + } |
|
360 | + $cell[$row][$col] = []; |
|
361 | + $c = &$cell[$row][$col]; |
|
362 | + $a = &$t->attribute[$i]; |
|
363 | + if (isset($a['width'])) { |
|
364 | + $c['w'] = intval($a['width']); |
|
365 | + } |
|
366 | + if (isset($a['height'])) { |
|
367 | + $c['h'] = intval($a['height']); |
|
368 | + } |
|
369 | + $c['a'] = isset($a['align']) ? $this->getAlign($a['align']) : 'L'; |
|
370 | + $c['va'] = isset($a['valign']) ? $this->getVAlign($a['valign']) : 'T'; |
|
371 | + if (isset($a['border'])) { |
|
372 | + $c['border'] = $a['border']; |
|
373 | + } else { |
|
374 | + $c['border'] = $table['border']; |
|
375 | + } |
|
376 | + if (isset($a['bgcolor'])) { |
|
377 | + $c['bgcolor'] = $a['bgcolor']; |
|
378 | + } |
|
379 | + $cs = $rs = 1; |
|
380 | + if (isset($a['colspan']) && $a['colspan'] > 1) { |
|
381 | + $cs = $c['colspan'] = intval($a['colspan']); |
|
382 | + } |
|
383 | + if (isset($a['rowspan']) && $a['rowspan'] > 1) { |
|
384 | + $rs = $c['rowspan'] = intval($a['rowspan']); |
|
385 | + } |
|
386 | + if (isset($a['size'])) { |
|
387 | + $c['font'][0]['size'] = $a['size']; |
|
388 | + } |
|
389 | + if (isset($a['family'])) { |
|
390 | + $c['font'][0]['family'] = $a['family']; |
|
391 | + } |
|
392 | + if (isset($a['style'])) { |
|
393 | + $STYLE = explode(',', strtoupper($a['style'])); |
|
394 | + $fontStyle = ''; |
|
395 | + foreach ($STYLE as $style) { |
|
396 | + $fontStyle .= substr(trim($style), 0, 1); |
|
397 | + } |
|
398 | + $c['font'][0]['style'] = $fontStyle; |
|
399 | + } |
|
400 | + if (isset($a['color'])) { |
|
401 | + $c['font'][0]['color'] = $a['color']; |
|
402 | + } |
|
403 | + //Chiem dung vi tri de danh cho cell span |
|
404 | + for ($k = $row; $k < $row + $rs; $k++) { |
|
405 | + for ($l = $col; $l < $col + $cs; $l++) { |
|
406 | + if ($k - $row || $l - $col) { |
|
407 | + $cell[$k][$l] = 0; |
|
408 | + } |
|
409 | + } |
|
410 | + } |
|
411 | + if (isset($a['nowrap'])) { |
|
412 | + $c['nowrap'] = 1; |
|
413 | + } |
|
414 | + $fontopen = true; |
|
415 | + if (!isset($c['font'])) { |
|
416 | + $c['font'][] = []; |
|
417 | + } |
|
418 | + break; |
|
419 | + case 'Text': |
|
420 | + $c = &$cell[$row][$col]; |
|
421 | + if (!$fontopen || !isset($c['font'])) { |
|
422 | + $c['font'][] = []; |
|
423 | + } |
|
424 | + $f = &$c['font'][count($c['font']) - 1]; |
|
425 | + $this->_setTextAndSize($c, $f, $this->_html2text($t->value[$i])); |
|
426 | + break; |
|
427 | + case 'font': |
|
428 | + $a = &$t->attribute[$i]; |
|
429 | + $c = &$cell[$row][$col]; |
|
430 | + $c['font'][] = []; |
|
431 | + $f = &$c['font'][count($c['font']) - 1]; |
|
432 | + if (isset($a['size'])) { |
|
433 | + $f['size'] = $a['size']; |
|
434 | + } |
|
435 | + if (isset($a['family'])) { |
|
436 | + $f['family'] = $a['family']; |
|
437 | + } |
|
438 | + if (isset($a['style'])) { |
|
439 | + $STYLE = explode(',', strtoupper($a['style'])); |
|
440 | + $fontStyle = ''; |
|
441 | + foreach ($STYLE as $style) { |
|
442 | + $fontStyle .= substr(trim($style), 0, 1); |
|
443 | + } |
|
444 | + $f['style'] = $fontStyle; |
|
445 | + } |
|
446 | + if (isset($a['color'])) { |
|
447 | + $f['color'] = $a['color']; |
|
448 | + } |
|
449 | + break; |
|
450 | + case 'img': |
|
451 | + $a = &$t->attribute[$i]; |
|
452 | + if (isset($a['src'])) { |
|
453 | + $this->_setImage($c, $a); |
|
454 | + } |
|
455 | + break; |
|
456 | + case 'br': |
|
457 | + $c = &$cell[$row][$col]; |
|
458 | + $cn = isset($c['font']) ? count($c['font']) - 1 : 0; |
|
459 | + $c['font'][$cn]['line'][] = 'br'; |
|
460 | + break; |
|
461 | 461 | } |
462 | 462 | } |
463 | 463 | $table['cells'] = $cell; |
@@ -1037,55 +1037,55 @@ |
||
1037 | 1037 | } |
1038 | 1038 | } |
1039 | 1039 | switch ($dest) { |
1040 | - case 'I': |
|
1041 | - //Send to standard output |
|
1042 | - if (ob_get_length()) { |
|
1043 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1044 | - } |
|
1045 | - if (php_sapi_name() != 'cli') { |
|
1046 | - //We send to a browser |
|
1047 | - header('Content-Type: application/pdf'); |
|
1048 | - if (headers_sent()) { |
|
1049 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1050 | - } |
|
1051 | - header('Content-Length: '.strlen($this->buffer)); |
|
1052 | - header('Content-Disposition: inline; filename="'.$name.'"'); |
|
1053 | - header('Cache-Control: private, max-age=0, must-revalidate'); |
|
1054 | - header('Pragma: public'); |
|
1055 | - ini_set('zlib.output_compression', '0'); |
|
1056 | - } |
|
1057 | - echo $this->buffer; |
|
1058 | - break; |
|
1059 | - case 'D': |
|
1060 | - //Download file |
|
1061 | - if (ob_get_length()) { |
|
1062 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1063 | - } |
|
1064 | - header('Content-Type: application/x-download'); |
|
1065 | - if (headers_sent()) { |
|
1066 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1067 | - } |
|
1068 | - header('Content-Length: '.strlen($this->buffer)); |
|
1069 | - header('Content-Disposition: attachment; filename="'.$name.'"'); |
|
1070 | - header('Cache-Control: private, max-age=0, must-revalidate'); |
|
1071 | - header('Pragma: public'); |
|
1072 | - ini_set('zlib.output_compression', '0'); |
|
1073 | - echo $this->buffer; |
|
1074 | - break; |
|
1075 | - case 'F': |
|
1076 | - //Save to local file |
|
1077 | - $f = fopen($name, 'wb'); |
|
1078 | - if (!$f) { |
|
1079 | - $this->Error('Unable to create output file: '.$name); |
|
1080 | - } |
|
1081 | - fwrite($f, $this->buffer, strlen($this->buffer)); |
|
1082 | - fclose($f); |
|
1083 | - break; |
|
1084 | - case 'S': |
|
1085 | - //Return as a string |
|
1086 | - return $this->buffer; |
|
1087 | - default: |
|
1088 | - $this->Error('Incorrect output destination: '.$dest); |
|
1040 | + case 'I': |
|
1041 | + //Send to standard output |
|
1042 | + if (ob_get_length()) { |
|
1043 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1044 | + } |
|
1045 | + if (php_sapi_name() != 'cli') { |
|
1046 | + //We send to a browser |
|
1047 | + header('Content-Type: application/pdf'); |
|
1048 | + if (headers_sent()) { |
|
1049 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1050 | + } |
|
1051 | + header('Content-Length: '.strlen($this->buffer)); |
|
1052 | + header('Content-Disposition: inline; filename="'.$name.'"'); |
|
1053 | + header('Cache-Control: private, max-age=0, must-revalidate'); |
|
1054 | + header('Pragma: public'); |
|
1055 | + ini_set('zlib.output_compression', '0'); |
|
1056 | + } |
|
1057 | + echo $this->buffer; |
|
1058 | + break; |
|
1059 | + case 'D': |
|
1060 | + //Download file |
|
1061 | + if (ob_get_length()) { |
|
1062 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1063 | + } |
|
1064 | + header('Content-Type: application/x-download'); |
|
1065 | + if (headers_sent()) { |
|
1066 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1067 | + } |
|
1068 | + header('Content-Length: '.strlen($this->buffer)); |
|
1069 | + header('Content-Disposition: attachment; filename="'.$name.'"'); |
|
1070 | + header('Cache-Control: private, max-age=0, must-revalidate'); |
|
1071 | + header('Pragma: public'); |
|
1072 | + ini_set('zlib.output_compression', '0'); |
|
1073 | + echo $this->buffer; |
|
1074 | + break; |
|
1075 | + case 'F': |
|
1076 | + //Save to local file |
|
1077 | + $f = fopen($name, 'wb'); |
|
1078 | + if (!$f) { |
|
1079 | + $this->Error('Unable to create output file: '.$name); |
|
1080 | + } |
|
1081 | + fwrite($f, $this->buffer, strlen($this->buffer)); |
|
1082 | + fclose($f); |
|
1083 | + break; |
|
1084 | + case 'S': |
|
1085 | + //Return as a string |
|
1086 | + return $this->buffer; |
|
1087 | + default: |
|
1088 | + $this->Error('Incorrect output destination: '.$dest); |
|
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | return ''; |