1<?php
2
3namespace Mpdf\Tag;
4
5class A extends Tag
6{
7
8	public function open($attr, &$ahtml, &$ihtml)
9	{
10		if (isset($attr['NAME']) && $attr['NAME'] != '') {
11			$e = '';
12			/* -- BOOKMARKS -- */
13			if ($this->mpdf->anchor2Bookmark) {
14				$objattr = [];
15				$objattr['CONTENT'] = htmlspecialchars_decode($attr['NAME'], ENT_QUOTES);
16				$objattr['type'] = 'bookmark';
17				if (!empty($attr['LEVEL'])) {
18					$objattr['bklevel'] = $attr['LEVEL'];
19				} else {
20					$objattr['bklevel'] = 0;
21				}
22				$e = "\xbb\xa4\xactype=bookmark,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
23			}
24			/* -- END BOOKMARKS -- */
25			if ($this->mpdf->tableLevel) { // *TABLES*
26				$this->mpdf->_saveCellTextBuffer($e, '', $attr['NAME']); // *TABLES*
27			} // *TABLES*
28			else { // *TABLES*
29				$this->mpdf->_saveTextBuffer($e, '', $attr['NAME']); //an internal link (adds a space for recognition)
30			} // *TABLES*
31		}
32		if (isset($attr['HREF'])) {
33			$this->mpdf->InlineProperties['A'] = $this->mpdf->saveInlineProperties();
34			$properties = $this->cssManager->MergeCSS('INLINE', 'A', $attr);
35			if (!empty($properties)) {
36				$this->mpdf->setCSS($properties, 'INLINE');
37			}
38			$this->mpdf->HREF = $attr['HREF']; // mPDF 5.7.4 URLs
39		}
40	}
41
42	public function close(&$ahtml, &$ihtml)
43	{
44		$this->mpdf->HREF = '';
45		if (isset($this->mpdf->InlineProperties['A'])) {
46			$this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties['A']);
47		}
48		unset($this->mpdf->InlineProperties['A']);
49	}
50}
51