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