Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

779 Zeilen
31KB

  1. <?php
  2. class tocontents
  3. {
  4. var $mpdf = null;
  5. var $_toc;
  6. var $TOCmark;
  7. var $TOCoutdent; // mPDF 5.6.31
  8. var $TOCpreHTML;
  9. var $TOCpostHTML;
  10. var $TOCbookmarkText;
  11. var $TOCusePaging;
  12. var $TOCuseLinking;
  13. var $TOCorientation;
  14. var $TOC_margin_left;
  15. var $TOC_margin_right;
  16. var $TOC_margin_top;
  17. var $TOC_margin_bottom;
  18. var $TOC_margin_header;
  19. var $TOC_margin_footer;
  20. var $TOC_odd_header_name;
  21. var $TOC_even_header_name;
  22. var $TOC_odd_footer_name;
  23. var $TOC_even_footer_name;
  24. var $TOC_odd_header_value;
  25. var $TOC_even_header_value;
  26. var $TOC_odd_footer_value;
  27. var $TOC_even_footer_value;
  28. var $TOC_page_selector;
  29. var $TOC_resetpagenum; // mPDF 6
  30. var $TOC_pagenumstyle; // mPDF 6
  31. var $TOC_suppress; // mPDF 6
  32. var $m_TOC;
  33. public function __construct(mPDF $mpdf)
  34. {
  35. $this->mpdf = $mpdf;
  36. $this->_toc = array();
  37. $this->TOCmark = 0;
  38. $this->m_TOC = array();
  39. }
  40. function TOCpagebreak($tocfont = '', $tocfontsize = '', $tocindent = '', $TOCusePaging = true, $TOCuseLinking = '', $toc_orientation = '', $toc_mgl = '', $toc_mgr = '', $toc_mgt = '', $toc_mgb = '', $toc_mgh = '', $toc_mgf = '', $toc_ohname = '', $toc_ehname = '', $toc_ofname = '', $toc_efname = '', $toc_ohvalue = 0, $toc_ehvalue = 0, $toc_ofvalue = 0, $toc_efvalue = 0, $toc_preHTML = '', $toc_postHTML = '', $toc_bookmarkText = '', $resetpagenum = '', $pagenumstyle = '', $suppress = '', $orientation = '', $mgl = '', $mgr = '', $mgt = '', $mgb = '', $mgh = '', $mgf = '', $ohname = '', $ehname = '', $ofname = '', $efname = '', $ohvalue = 0, $ehvalue = 0, $ofvalue = 0, $efvalue = 0, $toc_id = 0, $pagesel = '', $toc_pagesel = '', $sheetsize = '', $toc_sheetsize = '', $tocoutdent = '', $toc_resetpagenum = '', $toc_pagenumstyle = '', $toc_suppress = '')
  41. { // mPDF 5.6.19 // mPDF 6
  42. if (strtoupper($toc_id) == 'ALL') {
  43. $toc_id = '_mpdf_all';
  44. } else if (!$toc_id) {
  45. $toc_id = 0;
  46. } else {
  47. $toc_id = strtolower($toc_id);
  48. }
  49. if ($TOCusePaging === false || strtolower($TOCusePaging) == "off" || $TOCusePaging === 0 || $TOCusePaging === "0" || $TOCusePaging === "") {
  50. $TOCusePaging = false;
  51. } else {
  52. $TOCusePaging = true;
  53. }
  54. if (!$TOCuseLinking) {
  55. $TOCuseLinking = false;
  56. }
  57. if ($toc_id) {
  58. $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page;
  59. $this->m_TOC[$toc_id]['TOCoutdent'] = $tocoutdent;
  60. $this->m_TOC[$toc_id]['TOCorientation'] = $toc_orientation;
  61. $this->m_TOC[$toc_id]['TOCuseLinking'] = $TOCuseLinking;
  62. $this->m_TOC[$toc_id]['TOCusePaging'] = $TOCusePaging;
  63. if ($toc_preHTML) {
  64. $this->m_TOC[$toc_id]['TOCpreHTML'] = $toc_preHTML;
  65. }
  66. if ($toc_postHTML) {
  67. $this->m_TOC[$toc_id]['TOCpostHTML'] = $toc_postHTML;
  68. }
  69. if ($toc_bookmarkText) {
  70. $this->m_TOC[$toc_id]['TOCbookmarkText'] = $toc_bookmarkText;
  71. }
  72. $this->m_TOC[$toc_id]['TOC_margin_left'] = $toc_mgl;
  73. $this->m_TOC[$toc_id]['TOC_margin_right'] = $toc_mgr;
  74. $this->m_TOC[$toc_id]['TOC_margin_top'] = $toc_mgt;
  75. $this->m_TOC[$toc_id]['TOC_margin_bottom'] = $toc_mgb;
  76. $this->m_TOC[$toc_id]['TOC_margin_header'] = $toc_mgh;
  77. $this->m_TOC[$toc_id]['TOC_margin_footer'] = $toc_mgf;
  78. $this->m_TOC[$toc_id]['TOC_odd_header_name'] = $toc_ohname;
  79. $this->m_TOC[$toc_id]['TOC_even_header_name'] = $toc_ehname;
  80. $this->m_TOC[$toc_id]['TOC_odd_footer_name'] = $toc_ofname;
  81. $this->m_TOC[$toc_id]['TOC_even_footer_name'] = $toc_efname;
  82. $this->m_TOC[$toc_id]['TOC_odd_header_value'] = $toc_ohvalue;
  83. $this->m_TOC[$toc_id]['TOC_even_header_value'] = $toc_ehvalue;
  84. $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = $toc_ofvalue;
  85. $this->m_TOC[$toc_id]['TOC_even_footer_value'] = $toc_efvalue;
  86. $this->m_TOC[$toc_id]['TOC_page_selector'] = $toc_pagesel;
  87. $this->m_TOC[$toc_id]['TOC_resetpagenum'] = $toc_resetpagenum; // mPDF 6
  88. $this->m_TOC[$toc_id]['TOC_pagenumstyle'] = $toc_pagenumstyle; // mPDF 6
  89. $this->m_TOC[$toc_id]['TOC_suppress'] = $toc_suppress; // mPDF 6
  90. $this->m_TOC[$toc_id]['TOCsheetsize'] = $toc_sheetsize;
  91. } else {
  92. $this->TOCmark = $this->mpdf->page;
  93. $this->TOCoutdent = $tocoutdent;
  94. $this->TOCorientation = $toc_orientation;
  95. $this->TOCuseLinking = $TOCuseLinking;
  96. $this->TOCusePaging = $TOCusePaging;
  97. if ($toc_preHTML) {
  98. $this->TOCpreHTML = $toc_preHTML;
  99. }
  100. if ($toc_postHTML) {
  101. $this->TOCpostHTML = $toc_postHTML;
  102. }
  103. if ($toc_bookmarkText) {
  104. $this->TOCbookmarkText = $toc_bookmarkText;
  105. }
  106. $this->TOC_margin_left = $toc_mgl;
  107. $this->TOC_margin_right = $toc_mgr;
  108. $this->TOC_margin_top = $toc_mgt;
  109. $this->TOC_margin_bottom = $toc_mgb;
  110. $this->TOC_margin_header = $toc_mgh;
  111. $this->TOC_margin_footer = $toc_mgf;
  112. $this->TOC_odd_header_name = $toc_ohname;
  113. $this->TOC_even_header_name = $toc_ehname;
  114. $this->TOC_odd_footer_name = $toc_ofname;
  115. $this->TOC_even_footer_name = $toc_efname;
  116. $this->TOC_odd_header_value = $toc_ohvalue;
  117. $this->TOC_even_header_value = $toc_ehvalue;
  118. $this->TOC_odd_footer_value = $toc_ofvalue;
  119. $this->TOC_even_footer_value = $toc_efvalue;
  120. $this->TOC_page_selector = $toc_pagesel;
  121. $this->TOC_resetpagenum = $toc_resetpagenum; // mPDF 6
  122. $this->TOC_pagenumstyle = $toc_pagenumstyle; // mPDF 6
  123. $this->TOC_suppress = $toc_suppress; // mPDF 6
  124. $this->TOCsheetsize = $toc_sheetsize;
  125. }
  126. }
  127. // Initiate, and Mark a place for the Table of Contents to be inserted
  128. function TOC($tocfont = '', $tocfontsize = 0, $tocindent = 0, $resetpagenum = '', $pagenumstyle = '', $suppress = '', $toc_orientation = '', $TOCusePaging = true, $TOCuseLinking = false, $toc_id = 0, $tocoutdent = '', $toc_resetpagenum = '', $toc_pagenumstyle = '', $toc_suppress = '')
  129. { // mPDF 5.6.19 // mPDF 6
  130. if (strtoupper($toc_id) == 'ALL') {
  131. $toc_id = '_mpdf_all';
  132. } else if (!$toc_id) {
  133. $toc_id = 0;
  134. } else {
  135. $toc_id = strtolower($toc_id);
  136. }
  137. // To use odd and even pages
  138. // Cannot start table of contents on an even page
  139. if (($this->mpdf->mirrorMargins) && (($this->mpdf->page) % 2 == 0)) { // EVEN
  140. if ($this->mpdf->ColActive) {
  141. if (count($this->mpdf->columnbuffer)) {
  142. $this->mpdf->printcolumnbuffer();
  143. }
  144. }
  145. $this->mpdf->AddPage($this->mpdf->CurOrientation, '', $resetpagenum, $pagenumstyle, $suppress);
  146. } else {
  147. $this->mpdf->PageNumSubstitutions[] = array('from' => $this->mpdf->page, 'reset' => $resetpagenum, 'type' => $pagenumstyle, 'suppress' => $suppress);
  148. }
  149. if ($toc_id) {
  150. $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page;
  151. $this->m_TOC[$toc_id]['TOCoutdent'] = $tocoutdent;
  152. $this->m_TOC[$toc_id]['TOCorientation'] = $toc_orientation;
  153. $this->m_TOC[$toc_id]['TOCuseLinking'] = $TOCuseLinking;
  154. $this->m_TOC[$toc_id]['TOCusePaging'] = $TOCusePaging;
  155. $this->m_TOC[$toc_id]['TOC_resetpagenum'] = $toc_resetpagenum; // mPDF 6
  156. $this->m_TOC[$toc_id]['TOC_pagenumstyle'] = $toc_pagenumstyle; // mPDF 6
  157. $this->m_TOC[$toc_id]['TOC_suppress'] = $toc_suppress; // mPDF 6
  158. } else {
  159. $this->TOCmark = $this->mpdf->page;
  160. $this->TOCoutdent = $tocoutdent;
  161. $this->TOCorientation = $toc_orientation;
  162. $this->TOCuseLinking = $TOCuseLinking;
  163. $this->TOCusePaging = $TOCusePaging;
  164. $this->TOC_resetpagenum = $toc_resetpagenum; // mPDF 6
  165. $this->TOC_pagenumstyle = $toc_pagenumstyle; // mPDF 6
  166. $this->TOC_suppress = $toc_suppress; // mPDF 6
  167. }
  168. }
  169. function insertTOC()
  170. {
  171. $notocs = 0;
  172. if ($this->TOCmark) {
  173. $notocs = 1;
  174. }
  175. $notocs += count($this->m_TOC);
  176. if ($notocs == 0) {
  177. return;
  178. }
  179. if (count($this->m_TOC)) {
  180. reset($this->m_TOC);
  181. }
  182. $added_toc_pages = 0;
  183. if ($this->mpdf->ColActive) {
  184. $this->mpdf->SetColumns(0);
  185. }
  186. if (($this->mpdf->mirrorMargins) && (($this->mpdf->page) % 2 == 1)) { // ODD
  187. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  188. $extrapage = true;
  189. } else {
  190. $extrapage = false;
  191. }
  192. for ($toci = 0; $toci < $notocs; $toci++) {
  193. if ($toci == 0 && $this->TOCmark) {
  194. $toc_id = 0;
  195. $toc_page = $this->TOCmark;
  196. $tocoutdent = $this->TOCoutdent;
  197. $toc_orientation = $this->TOCorientation;
  198. $TOCuseLinking = $this->TOCuseLinking;
  199. $TOCusePaging = $this->TOCusePaging;
  200. $toc_preHTML = $this->TOCpreHTML;
  201. $toc_postHTML = $this->TOCpostHTML;
  202. $toc_bookmarkText = $this->TOCbookmarkText;
  203. $toc_mgl = $this->TOC_margin_left;
  204. $toc_mgr = $this->TOC_margin_right;
  205. $toc_mgt = $this->TOC_margin_top;
  206. $toc_mgb = $this->TOC_margin_bottom;
  207. $toc_mgh = $this->TOC_margin_header;
  208. $toc_mgf = $this->TOC_margin_footer;
  209. $toc_ohname = $this->TOC_odd_header_name;
  210. $toc_ehname = $this->TOC_even_header_name;
  211. $toc_ofname = $this->TOC_odd_footer_name;
  212. $toc_efname = $this->TOC_even_footer_name;
  213. $toc_ohvalue = $this->TOC_odd_header_value;
  214. $toc_ehvalue = $this->TOC_even_header_value;
  215. $toc_ofvalue = $this->TOC_odd_footer_value;
  216. $toc_efvalue = $this->TOC_even_footer_value;
  217. $toc_page_selector = $this->TOC_page_selector;
  218. $toc_resetpagenum = $this->TOC_resetpagenum; // mPDF 6
  219. $toc_pagenumstyle = $this->TOC_pagenumstyle; // mPDF 6
  220. $toc_suppress = $this->TOC_suppress; // mPDF 6
  221. $toc_sheet_size = (isset($this->TOCsheetsize) ? $this->TOCsheetsize : '');
  222. } else {
  223. $arr = current($this->m_TOC);
  224. $toc_id = key($this->m_TOC);
  225. $toc_page = $this->m_TOC[$toc_id]['TOCmark'];
  226. $tocoutdent = $this->m_TOC[$toc_id]['TOCoutdent'];
  227. $toc_orientation = $this->m_TOC[$toc_id]['TOCorientation'];
  228. $TOCuseLinking = $this->m_TOC[$toc_id]['TOCuseLinking'];
  229. $TOCusePaging = $this->m_TOC[$toc_id]['TOCusePaging'];
  230. if (isset($this->m_TOC[$toc_id]['TOCpreHTML'])) {
  231. $toc_preHTML = $this->m_TOC[$toc_id]['TOCpreHTML'];
  232. } else {
  233. $toc_preHTML = '';
  234. }
  235. if (isset($this->m_TOC[$toc_id]['TOCpostHTML'])) {
  236. $toc_postHTML = $this->m_TOC[$toc_id]['TOCpostHTML'];
  237. } else {
  238. $toc_postHTML = '';
  239. }
  240. if (isset($this->m_TOC[$toc_id]['TOCbookmarkText'])) {
  241. $toc_bookmarkText = $this->m_TOC[$toc_id]['TOCbookmarkText'];
  242. } else {
  243. $toc_bookmarkText = '';
  244. } // *BOOKMARKS*
  245. $toc_mgl = $this->m_TOC[$toc_id]['TOC_margin_left'];
  246. $toc_mgr = $this->m_TOC[$toc_id]['TOC_margin_right'];
  247. $toc_mgt = $this->m_TOC[$toc_id]['TOC_margin_top'];
  248. $toc_mgb = $this->m_TOC[$toc_id]['TOC_margin_bottom'];
  249. $toc_mgh = $this->m_TOC[$toc_id]['TOC_margin_header'];
  250. $toc_mgf = $this->m_TOC[$toc_id]['TOC_margin_footer'];
  251. $toc_ohname = $this->m_TOC[$toc_id]['TOC_odd_header_name'];
  252. $toc_ehname = $this->m_TOC[$toc_id]['TOC_even_header_name'];
  253. $toc_ofname = $this->m_TOC[$toc_id]['TOC_odd_footer_name'];
  254. $toc_efname = $this->m_TOC[$toc_id]['TOC_even_footer_name'];
  255. $toc_ohvalue = $this->m_TOC[$toc_id]['TOC_odd_header_value'];
  256. $toc_ehvalue = $this->m_TOC[$toc_id]['TOC_even_header_value'];
  257. $toc_ofvalue = $this->m_TOC[$toc_id]['TOC_odd_footer_value'];
  258. $toc_efvalue = $this->m_TOC[$toc_id]['TOC_even_footer_value'];
  259. $toc_page_selector = $this->m_TOC[$toc_id]['TOC_page_selector'];
  260. $toc_resetpagenum = $this->m_TOC[$toc_id]['TOC_resetpagenum']; // mPDF 6
  261. $toc_pagenumstyle = $this->m_TOC[$toc_id]['TOC_pagenumstyle']; // mPDF 6
  262. $toc_suppress = $this->m_TOC[$toc_id]['TOC_suppress']; // mPDF 6
  263. $toc_sheet_size = (isset($this->m_TOC[$toc_id]['TOCsheetsize']) ? $this->m_TOC[$toc_id]['TOCsheetsize'] : '');
  264. next($this->m_TOC);
  265. }
  266. // mPDF 5.6.31
  267. if (!$toc_orientation) {
  268. $toc_orientation = $this->mpdf->DefOrientation;
  269. }
  270. // mPDF 6 number style and suppress now picked up from section preceding ToC
  271. list($tp_pagenumstyle, $tp_suppress, $tp_reset) = $this->mpdf->docPageSettings($toc_page - 1);
  272. if ($toc_resetpagenum)
  273. $tp_reset = $toc_resetpagenum; // mPDF 6
  274. if ($toc_pagenumstyle)
  275. $tp_pagenumstyle = $toc_pagenumstyle; // mPDF 6
  276. if ($toc_suppress || $toc_suppress === '0')
  277. $tp_suppress = $toc_suppress; // mPDF 6
  278. $this->mpdf->AddPage($toc_orientation, '', $tp_reset, $tp_pagenumstyle, $tp_suppress, $toc_mgl, $toc_mgr, $toc_mgt, $toc_mgb, $toc_mgh, $toc_mgf, $toc_ohname, $toc_ehname, $toc_ofname, $toc_efname, $toc_ohvalue, $toc_ehvalue, $toc_ofvalue, $toc_efvalue, $toc_page_selector, $toc_sheet_size); // mPDF 6
  279. $this->mpdf->writingToC = true; // mPDF 5.6.38
  280. // mPDF 5.6.31
  281. $tocstart = count($this->mpdf->pages);
  282. if (isset($toc_preHTML) && $toc_preHTML) {
  283. $this->mpdf->WriteHTML($toc_preHTML);
  284. }
  285. // mPDF 5.6.19
  286. $html = '<div class="mpdf_toc" id="mpdf_toc_' . $toc_id . '">';
  287. foreach ($this->_toc as $t) {
  288. if ($t['toc_id'] === '_mpdf_all' || $t['toc_id'] === $toc_id) {
  289. $html .= '<div class="mpdf_toc_level_' . $t['l'] . '">';
  290. if ($TOCuseLinking) {
  291. $html .= '<a class="mpdf_toc_a" href="#__mpdfinternallink_' . $t['link'] . '">';
  292. }
  293. $html .= '<span class="mpdf_toc_t_level_' . $t['l'] . '">' . $t['t'] . '</span>';
  294. if ($TOCuseLinking) {
  295. $html .= '</a>';
  296. }
  297. if (!$tocoutdent) {
  298. $tocoutdent = '0';
  299. }
  300. if ($TOCusePaging) {
  301. $html .= ' <dottab outdent="' . $tocoutdent . '" /> ';
  302. if ($TOCuseLinking) {
  303. $html .= '<a class="mpdf_toc_a" href="#__mpdfinternallink_' . $t['link'] . '">';
  304. }
  305. $html .= '<span class="mpdf_toc_p_level_' . $t['l'] . '">' . $this->mpdf->docPageNum($t['p']) . '</span>';
  306. if ($TOCuseLinking) {
  307. $html .= '</a>';
  308. }
  309. }
  310. $html .= '</div>';
  311. }
  312. }
  313. $html .= '</div>';
  314. $this->mpdf->WriteHTML($html);
  315. if (isset($toc_postHTML) && $toc_postHTML) {
  316. $this->mpdf->WriteHTML($toc_postHTML);
  317. }
  318. $this->mpdf->writingToC = false; // mPDF 5.6.38
  319. $this->mpdf->AddPage($toc_orientation, 'E');
  320. $n_toc = $this->mpdf->page - $tocstart + 1;
  321. if ($toci == 0 && $this->TOCmark) {
  322. $TOC_start = $tocstart;
  323. $TOC_end = $this->mpdf->page;
  324. $TOC_npages = $n_toc;
  325. } else {
  326. $this->m_TOC[$toc_id]['start'] = $tocstart;
  327. $this->m_TOC[$toc_id]['end'] = $this->mpdf->page;
  328. $this->m_TOC[$toc_id]['npages'] = $n_toc;
  329. }
  330. }
  331. $s = '';
  332. $s .= $this->mpdf->PrintBodyBackgrounds();
  333. $s .= $this->mpdf->PrintPageBackgrounds();
  334. $this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS' . $this->mpdf->uniqstr . ')/', "\n" . $s . "\n" . '\\1', $this->mpdf->pages[$this->mpdf->page]);
  335. $this->mpdf->pageBackgrounds = array();
  336. //Page footer
  337. $this->mpdf->InFooter = true;
  338. $this->mpdf->Footer();
  339. $this->mpdf->InFooter = false;
  340. // 2nd time through to move pages etc.
  341. $added_toc_pages = 0;
  342. if (count($this->m_TOC)) {
  343. reset($this->m_TOC);
  344. }
  345. for ($toci = 0; $toci < $notocs; $toci++) {
  346. if ($toci == 0 && $this->TOCmark) {
  347. $toc_id = 0;
  348. $toc_page = $this->TOCmark + $added_toc_pages;
  349. $toc_orientation = $this->TOCorientation;
  350. $TOCuseLinking = $this->TOCuseLinking;
  351. $TOCusePaging = $this->TOCusePaging;
  352. $toc_bookmarkText = $this->TOCbookmarkText; // *BOOKMARKS*
  353. $tocstart = $TOC_start;
  354. $tocend = $n = $TOC_end;
  355. $n_toc = $TOC_npages;
  356. } else {
  357. $arr = current($this->m_TOC);
  358. $toc_id = key($this->m_TOC);
  359. $toc_page = $this->m_TOC[$toc_id]['TOCmark'] + $added_toc_pages;
  360. $toc_orientation = $this->m_TOC[$toc_id]['TOCorientation'];
  361. $TOCuseLinking = $this->m_TOC[$toc_id]['TOCuseLinking'];
  362. $TOCusePaging = $this->m_TOC[$toc_id]['TOCusePaging'];
  363. $toc_bookmarkText = $this->m_TOC[$toc_id]['TOCbookmarkText']; // *BOOKMARKS*
  364. $tocstart = $this->m_TOC[$toc_id]['start'];
  365. $tocend = $n = $this->m_TOC[$toc_id]['end'];
  366. $n_toc = $this->m_TOC[$toc_id]['npages'];
  367. next($this->m_TOC);
  368. }
  369. // Now pages moved
  370. $added_toc_pages += $n_toc;
  371. $this->mpdf->MovePages($toc_page, $tocstart, $tocend);
  372. $this->mpdf->pgsIns[$toc_page] = $tocend - $tocstart + 1;
  373. /* -- BOOKMARKS -- */
  374. // Insert new Bookmark for Bookmark
  375. if ($toc_bookmarkText) {
  376. $insert = -1;
  377. foreach ($this->mpdf->BMoutlines as $i => $o) {
  378. if ($o['p'] < $toc_page) { // i.e. before point of insertion
  379. $insert = $i;
  380. }
  381. }
  382. $txt = $this->mpdf->purify_utf8_text($toc_bookmarkText);
  383. if ($this->mpdf->text_input_as_HTML) {
  384. $txt = $this->mpdf->all_entities_to_utf8($txt);
  385. }
  386. $newBookmark[0] = array('t' => $txt, 'l' => 0, 'y' => 0, 'p' => $toc_page);
  387. array_splice($this->mpdf->BMoutlines, ($insert + 1), 0, $newBookmark);
  388. }
  389. /* -- END BOOKMARKS -- */
  390. }
  391. // Delete empty page that was inserted earlier
  392. if ($extrapage) {
  393. unset($this->mpdf->pages[count($this->mpdf->pages)]);
  394. $this->mpdf->page--; // Reset page pointer
  395. }
  396. }
  397. function openTagTOC($attr)
  398. {
  399. if (isset($attr['OUTDENT']) && $attr['OUTDENT']) {
  400. $tocoutdent = $attr['OUTDENT'];
  401. } else {
  402. $tocoutdent = '';
  403. } // mPDF 5.6.19
  404. if (isset($attr['RESETPAGENUM']) && $attr['RESETPAGENUM']) {
  405. $resetpagenum = $attr['RESETPAGENUM'];
  406. } else {
  407. $resetpagenum = '';
  408. }
  409. if (isset($attr['PAGENUMSTYLE']) && $attr['PAGENUMSTYLE']) {
  410. $pagenumstyle = $attr['PAGENUMSTYLE'];
  411. } else {
  412. $pagenumstyle = '';
  413. }
  414. if (isset($attr['SUPPRESS']) && $attr['SUPPRESS']) {
  415. $suppress = $attr['SUPPRESS'];
  416. } else {
  417. $suppress = '';
  418. }
  419. if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) {
  420. $toc_orientation = $attr['TOC-ORIENTATION'];
  421. } else {
  422. $toc_orientation = '';
  423. }
  424. if (isset($attr['PAGING']) && (strtoupper($attr['PAGING']) == 'OFF' || $attr['PAGING'] === '0')) {
  425. $paging = false;
  426. } else {
  427. $paging = true;
  428. }
  429. if (isset($attr['LINKS']) && (strtoupper($attr['LINKS']) == 'ON' || $attr['LINKS'] == 1)) {
  430. $links = true;
  431. } else {
  432. $links = false;
  433. }
  434. if (isset($attr['NAME']) && $attr['NAME']) {
  435. $toc_id = strtolower($attr['NAME']);
  436. } else {
  437. $toc_id = 0;
  438. }
  439. $this->TOC('', 0, 0, $resetpagenum, $pagenumstyle, $suppress, $toc_orientation, $paging, $links, $toc_id, $tocoutdent); // mPDF 5.6.19 5.6.31
  440. }
  441. function openTagTOCPAGEBREAK($attr)
  442. {
  443. if (isset($attr['NAME']) && $attr['NAME']) {
  444. $toc_id = strtolower($attr['NAME']);
  445. } else {
  446. $toc_id = 0;
  447. }
  448. if ($toc_id) {
  449. if (isset($attr['OUTDENT']) && $attr['OUTDENT']) {
  450. $this->m_TOC[$toc_id]['TOCoutdent'] = $attr['OUTDENT'];
  451. } else {
  452. $this->m_TOC[$toc_id]['TOCoutdent'] = '';
  453. } // mPDF 5.6.19
  454. if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) {
  455. $this->m_TOC[$toc_id]['TOCorientation'] = $attr['TOC-ORIENTATION'];
  456. } else {
  457. $this->m_TOC[$toc_id]['TOCorientation'] = '';
  458. }
  459. if (isset($attr['PAGING']) && (strtoupper($attr['PAGING']) == 'OFF' || $attr['PAGING'] === '0')) {
  460. $this->m_TOC[$toc_id]['TOCusePaging'] = false;
  461. } else {
  462. $this->m_TOC[$toc_id]['TOCusePaging'] = true;
  463. }
  464. if (isset($attr['LINKS']) && (strtoupper($attr['LINKS']) == 'ON' || $attr['LINKS'] == 1)) {
  465. $this->m_TOC[$toc_id]['TOCuseLinking'] = true;
  466. } else {
  467. $this->m_TOC[$toc_id]['TOCuseLinking'] = false;
  468. }
  469. $this->m_TOC[$toc_id]['TOC_margin_left'] = $this->m_TOC[$toc_id]['TOC_margin_right'] = $this->m_TOC[$toc_id]['TOC_margin_top'] = $this->m_TOC[$toc_id]['TOC_margin_bottom'] = $this->m_TOC[$toc_id]['TOC_margin_header'] = $this->m_TOC[$toc_id]['TOC_margin_footer'] = '';
  470. if (isset($attr['TOC-MARGIN-RIGHT'])) {
  471. $this->m_TOC[$toc_id]['TOC_margin_right'] = $this->mpdf->ConvertSize($attr['TOC-MARGIN-RIGHT'], $this->mpdf->w, $this->mpdf->FontSize, false);
  472. }
  473. if (isset($attr['TOC-MARGIN-LEFT'])) {
  474. $this->m_TOC[$toc_id]['TOC_margin_left'] = $this->mpdf->ConvertSize($attr['TOC-MARGIN-LEFT'], $this->mpdf->w, $this->mpdf->FontSize, false);
  475. }
  476. if (isset($attr['TOC-MARGIN-TOP'])) {
  477. $this->m_TOC[$toc_id]['TOC_margin_top'] = $this->mpdf->ConvertSize($attr['TOC-MARGIN-TOP'], $this->mpdf->w, $this->mpdf->FontSize, false);
  478. }
  479. if (isset($attr['TOC-MARGIN-BOTTOM'])) {
  480. $this->m_TOC[$toc_id]['TOC_margin_bottom'] = $this->mpdf->ConvertSize($attr['TOC-MARGIN-BOTTOM'], $this->mpdf->w, $this->mpdf->FontSize, false);
  481. }
  482. if (isset($attr['TOC-MARGIN-HEADER'])) {
  483. $this->m_TOC[$toc_id]['TOC_margin_header'] = $this->mpdf->ConvertSize($attr['TOC-MARGIN-HEADER'], $this->mpdf->w, $this->mpdf->FontSize, false);
  484. }
  485. if (isset($attr['TOC-MARGIN-FOOTER'])) {
  486. $this->m_TOC[$toc_id]['TOC_margin_footer'] = $this->mpdf->ConvertSize($attr['TOC-MARGIN-FOOTER'], $this->mpdf->w, $this->mpdf->FontSize, false);
  487. }
  488. $this->m_TOC[$toc_id]['TOC_odd_header_name'] = $this->m_TOC[$toc_id]['TOC_even_header_name'] = $this->m_TOC[$toc_id]['TOC_odd_footer_name'] = $this->m_TOC[$toc_id]['TOC_even_footer_name'] = '';
  489. if (isset($attr['TOC-ODD-HEADER-NAME']) && $attr['TOC-ODD-HEADER-NAME']) {
  490. $this->m_TOC[$toc_id]['TOC_odd_header_name'] = $attr['TOC-ODD-HEADER-NAME'];
  491. }
  492. if (isset($attr['TOC-EVEN-HEADER-NAME']) && $attr['TOC-EVEN-HEADER-NAME']) {
  493. $this->m_TOC[$toc_id]['TOC_even_header_name'] = $attr['TOC-EVEN-HEADER-NAME'];
  494. }
  495. if (isset($attr['TOC-ODD-FOOTER-NAME']) && $attr['TOC-ODD-FOOTER-NAME']) {
  496. $this->m_TOC[$toc_id]['TOC_odd_footer_name'] = $attr['TOC-ODD-FOOTER-NAME'];
  497. }
  498. if (isset($attr['TOC-EVEN-FOOTER-NAME']) && $attr['TOC-EVEN-FOOTER-NAME']) {
  499. $this->m_TOC[$toc_id]['TOC_even_footer_name'] = $attr['TOC-EVEN-FOOTER-NAME'];
  500. }
  501. $this->m_TOC[$toc_id]['TOC_odd_header_value'] = $this->m_TOC[$toc_id]['TOC_even_header_value'] = $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = $this->m_TOC[$toc_id]['TOC_even_footer_value'] = 0;
  502. if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE'] == '1' || strtoupper($attr['TOC-ODD-HEADER-VALUE']) == 'ON')) {
  503. $this->m_TOC[$toc_id]['TOC_odd_header_value'] = 1;
  504. } else if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE'] == '-1' || strtoupper($attr['TOC-ODD-HEADER-VALUE']) == 'OFF')) {
  505. $this->m_TOC[$toc_id]['TOC_odd_header_value'] = -1;
  506. }
  507. if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE'] == '1' || strtoupper($attr['TOC-EVEN-HEADER-VALUE']) == 'ON')) {
  508. $this->m_TOC[$toc_id]['TOC_even_header_value'] = 1;
  509. } else if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE'] == '-1' || strtoupper($attr['TOC-EVEN-HEADER-VALUE']) == 'OFF')) {
  510. $this->m_TOC[$toc_id]['TOC_even_header_value'] = -1;
  511. }
  512. if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE'] == '1' || strtoupper($attr['TOC-ODD-FOOTER-VALUE']) == 'ON')) {
  513. $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = 1;
  514. } else if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE'] == '-1' || strtoupper($attr['TOC-ODD-FOOTER-VALUE']) == 'OFF')) {
  515. $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = -1;
  516. }
  517. if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE'] == '1' || strtoupper($attr['TOC-EVEN-FOOTER-VALUE']) == 'ON')) {
  518. $this->m_TOC[$toc_id]['TOC_even_footer_value'] = 1;
  519. } else if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE'] == '-1' || strtoupper($attr['TOC-EVEN-FOOTER-VALUE']) == 'OFF')) {
  520. $this->m_TOC[$toc_id]['TOC_even_footer_value'] = -1;
  521. }
  522. if (isset($attr['TOC-RESETPAGENUM']) && $attr['TOC-RESETPAGENUM']) {
  523. $this->m_TOC[$toc_id]['TOC_resetpagenum'] = $attr['TOC-RESETPAGENUM'];
  524. } else {
  525. $this->m_TOC[$toc_id]['TOC_resetpagenum'] = '';
  526. } // mPDF 6
  527. if (isset($attr['TOC-PAGENUMSTYLE']) && $attr['TOC-PAGENUMSTYLE']) {
  528. $this->m_TOC[$toc_id]['TOC_pagenumstyle'] = $attr['TOC-PAGENUMSTYLE'];
  529. } else {
  530. $this->m_TOC[$toc_id]['TOC_pagenumstyle'] = '';
  531. } // mPDF 6
  532. if (isset($attr['TOC-SUPPRESS']) && ($attr['TOC-SUPPRESS'] || $attr['TOC-SUPPRESS'] === '0')) {
  533. $this->m_TOC[$toc_id]['TOC_suppress'] = $attr['TOC-SUPPRESS'];
  534. } else {
  535. $this->m_TOC[$toc_id]['TOC_suppress'] = '';
  536. } // mPDF 6
  537. if (isset($attr['TOC-PAGE-SELECTOR']) && $attr['TOC-PAGE-SELECTOR']) {
  538. $this->m_TOC[$toc_id]['TOC_page_selector'] = $attr['TOC-PAGE-SELECTOR'];
  539. } else {
  540. $this->m_TOC[$toc_id]['TOC_page_selector'] = '';
  541. }
  542. if (isset($attr['TOC-SHEET-SIZE']) && $attr['TOC-SHEET-SIZE']) {
  543. $this->m_TOC[$toc_id]['TOCsheetsize'] = $attr['TOC-SHEET-SIZE'];
  544. } else {
  545. $this->m_TOC[$toc_id]['TOCsheetsize'] = '';
  546. }
  547. if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) {
  548. $this->m_TOC[$toc_id]['TOCpreHTML'] = htmlspecialchars_decode($attr['TOC-PREHTML'], ENT_QUOTES);
  549. }
  550. if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) {
  551. $this->m_TOC[$toc_id]['TOCpostHTML'] = htmlspecialchars_decode($attr['TOC-POSTHTML'], ENT_QUOTES);
  552. }
  553. if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) {
  554. $this->m_TOC[$toc_id]['TOCbookmarkText'] = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'], ENT_QUOTES);
  555. } // *BOOKMARKS*
  556. } else {
  557. if (isset($attr['OUTDENT']) && $attr['OUTDENT']) {
  558. $this->TOCoutdent = $attr['OUTDENT'];
  559. } else {
  560. $this->TOCoutdent = '';
  561. } // mPDF 5.6.19
  562. if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) {
  563. $this->TOCorientation = $attr['TOC-ORIENTATION'];
  564. } else {
  565. $this->TOCorientation = '';
  566. }
  567. if (isset($attr['PAGING']) && (strtoupper($attr['PAGING']) == 'OFF' || $attr['PAGING'] === '0')) {
  568. $this->TOCusePaging = false;
  569. } else {
  570. $this->TOCusePaging = true;
  571. }
  572. if (isset($attr['LINKS']) && (strtoupper($attr['LINKS']) == 'ON' || $attr['LINKS'] == 1)) {
  573. $this->TOCuseLinking = true;
  574. } else {
  575. $this->TOCuseLinking = false;
  576. }
  577. $this->TOC_margin_left = $this->TOC_margin_right = $this->TOC_margin_top = $this->TOC_margin_bottom = $this->TOC_margin_header = $this->TOC_margin_footer = '';
  578. if (isset($attr['TOC-MARGIN-RIGHT'])) {
  579. $this->TOC_margin_right = $this->mpdf->ConvertSize($attr['TOC-MARGIN-RIGHT'], $this->mpdf->w, $this->mpdf->FontSize, false);
  580. }
  581. if (isset($attr['TOC-MARGIN-LEFT'])) {
  582. $this->TOC_margin_left = $this->mpdf->ConvertSize($attr['TOC-MARGIN-LEFT'], $this->mpdf->w, $this->mpdf->FontSize, false);
  583. }
  584. if (isset($attr['TOC-MARGIN-TOP'])) {
  585. $this->TOC_margin_top = $this->mpdf->ConvertSize($attr['TOC-MARGIN-TOP'], $this->mpdf->w, $this->mpdf->FontSize, false);
  586. }
  587. if (isset($attr['TOC-MARGIN-BOTTOM'])) {
  588. $this->TOC_margin_bottom = $this->mpdf->ConvertSize($attr['TOC-MARGIN-BOTTOM'], $this->mpdf->w, $this->mpdf->FontSize, false);
  589. }
  590. if (isset($attr['TOC-MARGIN-HEADER'])) {
  591. $this->TOC_margin_header = $this->mpdf->ConvertSize($attr['TOC-MARGIN-HEADER'], $this->mpdf->w, $this->mpdf->FontSize, false);
  592. }
  593. if (isset($attr['TOC-MARGIN-FOOTER'])) {
  594. $this->TOC_margin_footer = $this->mpdf->ConvertSize($attr['TOC-MARGIN-FOOTER'], $this->mpdf->w, $this->mpdf->FontSize, false);
  595. }
  596. $this->TOC_odd_header_name = $this->TOC_even_header_name = $this->TOC_odd_footer_name = $this->TOC_even_footer_name = '';
  597. if (isset($attr['TOC-ODD-HEADER-NAME']) && $attr['TOC-ODD-HEADER-NAME']) {
  598. $this->TOC_odd_header_name = $attr['TOC-ODD-HEADER-NAME'];
  599. }
  600. if (isset($attr['TOC-EVEN-HEADER-NAME']) && $attr['TOC-EVEN-HEADER-NAME']) {
  601. $this->TOC_even_header_name = $attr['TOC-EVEN-HEADER-NAME'];
  602. }
  603. if (isset($attr['TOC-ODD-FOOTER-NAME']) && $attr['TOC-ODD-FOOTER-NAME']) {
  604. $this->TOC_odd_footer_name = $attr['TOC-ODD-FOOTER-NAME'];
  605. }
  606. if (isset($attr['TOC-EVEN-FOOTER-NAME']) && $attr['TOC-EVEN-FOOTER-NAME']) {
  607. $this->TOC_even_footer_name = $attr['TOC-EVEN-FOOTER-NAME'];
  608. }
  609. $this->TOC_odd_header_value = $this->TOC_even_header_value = $this->TOC_odd_footer_value = $this->TOC_even_footer_value = 0;
  610. if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE'] == '1' || strtoupper($attr['TOC-ODD-HEADER-VALUE']) == 'ON')) {
  611. $this->TOC_odd_header_value = 1;
  612. } else if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE'] == '-1' || strtoupper($attr['TOC-ODD-HEADER-VALUE']) == 'OFF')) {
  613. $this->TOC_odd_header_value = -1;
  614. }
  615. if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE'] == '1' || strtoupper($attr['TOC-EVEN-HEADER-VALUE']) == 'ON')) {
  616. $this->TOC_even_header_value = 1;
  617. } else if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE'] == '-1' || strtoupper($attr['TOC-EVEN-HEADER-VALUE']) == 'OFF')) {
  618. $this->TOC_even_header_value = -1;
  619. }
  620. if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE'] == '1' || strtoupper($attr['TOC-ODD-FOOTER-VALUE']) == 'ON')) {
  621. $this->TOC_odd_footer_value = 1;
  622. } else if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE'] == '-1' || strtoupper($attr['TOC-ODD-FOOTER-VALUE']) == 'OFF')) {
  623. $this->TOC_odd_footer_value = -1;
  624. }
  625. if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE'] == '1' || strtoupper($attr['TOC-EVEN-FOOTER-VALUE']) == 'ON')) {
  626. $this->TOC_even_footer_value = 1;
  627. } else if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE'] == '-1' || strtoupper($attr['TOC-EVEN-FOOTER-VALUE']) == 'OFF')) {
  628. $this->TOC_even_footer_value = -1;
  629. }
  630. if (isset($attr['TOC-PAGE-SELECTOR']) && $attr['TOC-PAGE-SELECTOR']) {
  631. $this->TOC_page_selector = $attr['TOC-PAGE-SELECTOR'];
  632. } else {
  633. $this->TOC_page_selector = '';
  634. }
  635. if (isset($attr['TOC-RESETPAGENUM']) && $attr['TOC-RESETPAGENUM']) {
  636. $this->TOC_resetpagenum = $attr['TOC-RESETPAGENUM'];
  637. } else {
  638. $this->TOC_resetpagenum = '';
  639. } // mPDF 6
  640. if (isset($attr['TOC-PAGENUMSTYLE']) && $attr['TOC-PAGENUMSTYLE']) {
  641. $this->TOC_pagenumstyle = $attr['TOC-PAGENUMSTYLE'];
  642. } else {
  643. $this->TOC_pagenumstyle = '';
  644. } // mPDF 6
  645. if (isset($attr['TOC-SUPPRESS']) && ($attr['TOC-SUPPRESS'] || $attr['TOC-SUPPRESS'] === '0')) {
  646. $this->TOC_suppress = $attr['TOC-SUPPRESS'];
  647. } else {
  648. $this->TOC_suppress = '';
  649. } // mPDF 6
  650. if (isset($attr['TOC-SHEET-SIZE']) && $attr['TOC-SHEET-SIZE']) {
  651. $this->TOCsheetsize = $attr['TOC-SHEET-SIZE'];
  652. } else {
  653. $this->TOCsheetsize = '';
  654. }
  655. if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) {
  656. $this->TOCpreHTML = htmlspecialchars_decode($attr['TOC-PREHTML'], ENT_QUOTES);
  657. }
  658. if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) {
  659. $this->TOCpostHTML = htmlspecialchars_decode($attr['TOC-POSTHTML'], ENT_QUOTES);
  660. }
  661. if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) {
  662. $this->TOCbookmarkText = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'], ENT_QUOTES);
  663. }
  664. }
  665. if ($this->mpdf->y == $this->mpdf->tMargin && (!$this->mpdf->mirrorMargins || ($this->mpdf->mirrorMargins && $this->mpdf->page % 2 == 1))) {
  666. if ($toc_id) {
  667. $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page;
  668. } else {
  669. $this->TOCmark = $this->mpdf->page;
  670. }
  671. // Don't add a page
  672. if ($this->mpdf->page == 1 && count($this->mpdf->PageNumSubstitutions) == 0) {
  673. $resetpagenum = '';
  674. $pagenumstyle = '';
  675. $suppress = '';
  676. if (isset($attr['RESETPAGENUM'])) {
  677. $resetpagenum = $attr['RESETPAGENUM'];
  678. }
  679. if (isset($attr['PAGENUMSTYLE'])) {
  680. $pagenumstyle = $attr['PAGENUMSTYLE'];
  681. }
  682. if (isset($attr['SUPPRESS'])) {
  683. $suppress = $attr['SUPPRESS'];
  684. }
  685. if (!$suppress) {
  686. $suppress = 'off';
  687. }
  688. if (!$resetpagenum) {
  689. $resetpagenum = 1;
  690. }
  691. $this->mpdf->PageNumSubstitutions[] = array('from' => 1, 'reset' => $resetpagenum, 'type' => $pagenumstyle, 'suppress' => $suppress);
  692. }
  693. return array(true, $toc_id);
  694. }
  695. // No break - continues as PAGEBREAK...
  696. return array(false, $toc_id);
  697. }
  698. }