1<?php 2 3namespace Mpdf\Tag; 4 5use Mpdf\Css\Border; 6 7class Tr extends Tag 8{ 9 10 public function open($attr, &$ahtml, &$ihtml) 11 { 12 13 $this->mpdf->lastoptionaltag = 'TR'; // Save current HTML specified optional endtag 14 $this->cssManager->tbCSSlvl++; 15 $this->mpdf->row++; 16 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nr'] ++; 17 $this->mpdf->col = -1; 18 $properties = $this->cssManager->MergeCSS('TABLE', 'TR', $attr); 19 20 if (!$this->mpdf->simpleTables && (!isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['borders_separate']) 21 || !$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['borders_separate'])) { 22 if (!empty($properties['BORDER-LEFT'])) { 23 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-left'][$this->mpdf->row] = $properties['BORDER-LEFT']; 24 } 25 if (!empty($properties['BORDER-RIGHT'])) { 26 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-right'][$this->mpdf->row] = $properties['BORDER-RIGHT']; 27 } 28 if (!empty($properties['BORDER-TOP'])) { 29 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-top'][$this->mpdf->row] = $properties['BORDER-TOP']; 30 } 31 if (!empty($properties['BORDER-BOTTOM'])) { 32 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-bottom'][$this->mpdf->row] = $properties['BORDER-BOTTOM']; 33 } 34 } 35 36 if (isset($properties['BACKGROUND-COLOR'])) { 37 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$this->mpdf->row] = $properties['BACKGROUND-COLOR']; 38 } elseif (isset($attr['BGCOLOR'])) { 39 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$this->mpdf->row] = $attr['BGCOLOR']; 40 } 41 42 /* -- BACKGROUNDS -- */ 43 if (isset($properties['BACKGROUND-GRADIENT']) && !$this->mpdf->kwt && !$this->mpdf->ColActive) { 44 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'][$this->mpdf->row] = $properties['BACKGROUND-GRADIENT']; 45 } 46 47 // FIXME: undefined variable $currblk 48 if (!empty($properties['BACKGROUND-IMAGE']) && !$this->mpdf->kwt && !$this->mpdf->ColActive) { 49 $ret = $this->mpdf->SetBackground($properties, $currblk['inner_width']); 50 if ($ret) { 51 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'][$this->mpdf->row] = $ret; 52 } 53 } 54 /* -- END BACKGROUNDS -- */ 55 56 if (isset($properties['TEXT-ROTATE'])) { 57 $this->mpdf->trow_text_rotate = $properties['TEXT-ROTATE']; 58 } 59 if (isset($attr['TEXT-ROTATE'])) { 60 $this->mpdf->trow_text_rotate = $attr['TEXT-ROTATE']; 61 } 62 63 if ($this->mpdf->tablethead) { 64 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead'][$this->mpdf->row] = true; 65 } 66 if ($this->mpdf->tabletfoot) { 67 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'][$this->mpdf->row] = true; 68 } 69 } 70 71 public function close(&$ahtml, &$ihtml) 72 { 73 if ($this->mpdf->tableLevel) { 74 // If Border set on TR - Update right border 75 if (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-left'][$this->mpdf->row])) { 76 $c = & $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]; 77 if ($c) { 78 if ($this->mpdf->packTableData) { 79 $cell = $this->mpdf->_unpackCellBorder($c['borderbin']); 80 } else { 81 $cell = $c; 82 } 83 $cell['border_details']['R'] = $this->mpdf->border_details( 84 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-right'][$this->mpdf->row] 85 ); 86 $this->mpdf->setBorder($cell['border'], Border::RIGHT, $cell['border_details']['R']['s']); 87 if ($this->mpdf->packTableData) { 88 $c['borderbin'] = $this->mpdf->_packCellBorder($cell); 89 unset($c['border'], $c['border_details']); 90 } else { 91 $c = $cell; 92 } 93 } 94 } 95 $this->mpdf->lastoptionaltag = ''; 96 unset($this->cssManager->tablecascadeCSS[$this->cssManager->tbCSSlvl]); 97 $this->cssManager->tbCSSlvl--; 98 $this->mpdf->trow_text_rotate = ''; 99 $this->mpdf->tabletheadjustfinished = false; 100 } 101 } 102} 103