1<?php
2
3namespace Mpdf\Tag;
4
5use Mpdf\Mpdf;
6
7class Legend extends Tag
8{
9
10	public function open($attr, &$ahtml, &$ihtml)
11	{
12		$this->mpdf->InlineProperties['LEGEND'] = $this->mpdf->saveInlineProperties();
13		$properties = $this->cssManager->MergeCSS('INLINE', 'LEGEND', $attr);
14		if (!empty($properties)) {
15			$this->mpdf->setCSS($properties, 'INLINE');
16		}
17	}
18
19	public function close(&$ahtml, &$ihtml)
20	{
21		if (count($this->mpdf->textbuffer) && !$this->mpdf->tableLevel) {
22			$leg = $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1];
23			unset($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1]);
24			$this->mpdf->textbuffer = array_values($this->mpdf->textbuffer);
25			$this->mpdf->blk[$this->mpdf->blklvl]['border_legend'] = $leg;
26			$this->mpdf->blk[$this->mpdf->blklvl]['margin_top'] += ($leg[11] / 2) / Mpdf::SCALE;
27			$this->mpdf->blk[$this->mpdf->blklvl]['padding_top'] += ($leg[11] / 2) / Mpdf::SCALE;
28		}
29		if (isset($this->mpdf->InlineProperties['LEGEND'])) {
30			$this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties['LEGEND']);
31		}
32		unset($this->mpdf->InlineProperties['LEGEND']);
33		$this->mpdf->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
34	}
35}
36