PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 1.8.3
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v1.8.3
trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 All 71 releases
pdf-print / mpdf / classes / tocontents.php

tocontents.php in PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin 1.8.3, at mpdf/classes/tocontents.php

509 lines 29.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class tocontents {
4
5 var $mpdf = null;
6 var $_toc;
7 var $TOCmark;
8 var $TOCoutdent; // mPDF 5.6.31
9 var $TOCpreHTML;
10 var $TOCpostHTML;
11 var $TOCbookmarkText;
12 var $TOCusePaging;
13 var $TOCuseLinking;
14 var $TOCorientation;
15 var $TOC_margin_left;
16 var $TOC_margin_right;
17 var $TOC_margin_top;
18 var $TOC_margin_bottom;
19 var $TOC_margin_header;
20 var $TOC_margin_footer;
21 var $TOC_odd_header_name;
22 var $TOC_even_header_name;
23 var $TOC_odd_footer_name;
24 var $TOC_even_footer_name;
25 var $TOC_odd_header_value;
26 var $TOC_even_header_value;
27 var $TOC_odd_footer_value;
28 var $TOC_even_footer_value;
29 var $TOC_page_selector;
30 var $TOC_resetpagenum; // mPDF 6
31 var $TOC_pagenumstyle; // mPDF 6
32 var $TOC_suppress; // mPDF 6
33 var $m_TOC;
34
35 function tocontents(&$mpdf) {
36 $this->mpdf = $mpdf;
37 $this->_toc=array();
38 $this->TOCmark = 0;
39 $this->m_TOC=array();
40 }
41
42 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='') { // mPDF 5.6.19 // mPDF 6
43 if (strtoupper($toc_id)=='ALL') { $toc_id = '_mpdf_all'; }
44 else if (!$toc_id) { $toc_id = 0; }
45 else { $toc_id = strtolower($toc_id); }
46
47 if ($TOCusePaging === false || strtolower($TOCusePaging) == "off" || $TOCusePaging === 0 || $TOCusePaging === "0" || $TOCusePaging === "") { $TOCusePaging = false; }
48 else { $TOCusePaging = true; }
49 if (!$TOCuseLinking) { $TOCuseLinking = false; }
50 if ($toc_id) {
51 $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page;
52 $this->m_TOC[$toc_id]['TOCoutdent'] = $tocoutdent;
53 $this->m_TOC[$toc_id]['TOCorientation'] = $toc_orientation;
54 $this->m_TOC[$toc_id]['TOCuseLinking'] = $TOCuseLinking;
55 $this->m_TOC[$toc_id]['TOCusePaging'] = $TOCusePaging;
56
57 if ($toc_preHTML) { $this->m_TOC[$toc_id]['TOCpreHTML'] = $toc_preHTML; }
58 if ($toc_postHTML) { $this->m_TOC[$toc_id]['TOCpostHTML'] = $toc_postHTML; }
59 if ($toc_bookmarkText) { $this->m_TOC[$toc_id]['TOCbookmarkText'] = $toc_bookmarkText; }
60
61 $this->m_TOC[$toc_id]['TOC_margin_left'] = $toc_mgl;
62 $this->m_TOC[$toc_id]['TOC_margin_right'] = $toc_mgr;
63 $this->m_TOC[$toc_id]['TOC_margin_top'] = $toc_mgt;
64 $this->m_TOC[$toc_id]['TOC_margin_bottom'] = $toc_mgb;
65 $this->m_TOC[$toc_id]['TOC_margin_header'] = $toc_mgh;
66 $this->m_TOC[$toc_id]['TOC_margin_footer'] = $toc_mgf;
67 $this->m_TOC[$toc_id]['TOC_odd_header_name'] = $toc_ohname;
68 $this->m_TOC[$toc_id]['TOC_even_header_name'] = $toc_ehname;
69 $this->m_TOC[$toc_id]['TOC_odd_footer_name'] = $toc_ofname;
70 $this->m_TOC[$toc_id]['TOC_even_footer_name'] = $toc_efname;
71 $this->m_TOC[$toc_id]['TOC_odd_header_value'] = $toc_ohvalue;
72 $this->m_TOC[$toc_id]['TOC_even_header_value'] = $toc_ehvalue;
73 $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = $toc_ofvalue;
74 $this->m_TOC[$toc_id]['TOC_even_footer_value'] = $toc_efvalue;
75 $this->m_TOC[$toc_id]['TOC_page_selector'] = $toc_pagesel;
76 $this->m_TOC[$toc_id]['TOC_resetpagenum'] = $toc_resetpagenum; // mPDF 6
77 $this->m_TOC[$toc_id]['TOC_pagenumstyle'] = $toc_pagenumstyle; // mPDF 6
78 $this->m_TOC[$toc_id]['TOC_suppress'] = $toc_suppress; // mPDF 6
79 $this->m_TOC[$toc_id]['TOCsheetsize'] = $toc_sheetsize;
80 }
81 else {
82 $this->TOCmark = $this->mpdf->page;
83 $this->TOCoutdent = $tocoutdent;
84 $this->TOCorientation = $toc_orientation;
85 $this->TOCuseLinking = $TOCuseLinking;
86 $this->TOCusePaging = $TOCusePaging;
87
88 if ($toc_preHTML) { $this->TOCpreHTML = $toc_preHTML; }
89 if ($toc_postHTML) { $this->TOCpostHTML = $toc_postHTML; }
90 if ($toc_bookmarkText) { $this->TOCbookmarkText = $toc_bookmarkText; }
91
92 $this->TOC_margin_left = $toc_mgl;
93 $this->TOC_margin_right = $toc_mgr;
94 $this->TOC_margin_top = $toc_mgt;
95 $this->TOC_margin_bottom = $toc_mgb;
96 $this->TOC_margin_header = $toc_mgh;
97 $this->TOC_margin_footer = $toc_mgf;
98 $this->TOC_odd_header_name = $toc_ohname;
99 $this->TOC_even_header_name = $toc_ehname;
100 $this->TOC_odd_footer_name = $toc_ofname;
101 $this->TOC_even_footer_name = $toc_efname;
102 $this->TOC_odd_header_value = $toc_ohvalue;
103 $this->TOC_even_header_value = $toc_ehvalue;
104 $this->TOC_odd_footer_value = $toc_ofvalue;
105 $this->TOC_even_footer_value = $toc_efvalue;
106 $this->TOC_page_selector = $toc_pagesel;
107 $this->TOC_resetpagenum = $toc_resetpagenum; // mPDF 6
108 $this->TOC_pagenumstyle = $toc_pagenumstyle; // mPDF 6
109 $this->TOC_suppress = $toc_suppress; // mPDF 6
110 $this->TOCsheetsize = $toc_sheetsize;
111 }
112 }
113
114 // Initiate, and Mark a place for the Table of Contents to be inserted
115 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='') { // mPDF 5.6.19 // mPDF 6
116 if (strtoupper($toc_id)=='ALL') { $toc_id = '_mpdf_all'; }
117 else if (!$toc_id) { $toc_id = 0; }
118 else { $toc_id = strtolower($toc_id); }
119 // To use odd and even pages
120 // Cannot start table of contents on an even page
121 if (($this->mpdf->mirrorMargins) && (($this->mpdf->page)%2==0)) { // EVEN
122 if ($this->mpdf->ColActive) {
123 if (count($this->mpdf->columnbuffer)) { $this->mpdf->printcolumnbuffer(); }
124 }
125 $this->mpdf->AddPage($this->mpdf->CurOrientation,'',$resetpagenum, $pagenumstyle, $suppress);
126 }
127 else {
128 $this->mpdf->PageNumSubstitutions[] = array('from'=>$this->mpdf->page, 'reset'=> $resetpagenum, 'type'=>$pagenumstyle, 'suppress'=>$suppress);
129 }
130 if ($toc_id) {
131 $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page;
132 $this->m_TOC[$toc_id]['TOCoutdent'] = $tocoutdent;
133 $this->m_TOC[$toc_id]['TOCorientation'] = $toc_orientation;
134 $this->m_TOC[$toc_id]['TOCuseLinking'] = $TOCuseLinking;
135 $this->m_TOC[$toc_id]['TOCusePaging'] = $TOCusePaging;
136 $this->m_TOC[$toc_id]['TOC_resetpagenum'] = $toc_resetpagenum; // mPDF 6
137 $this->m_TOC[$toc_id]['TOC_pagenumstyle'] = $toc_pagenumstyle; // mPDF 6
138 $this->m_TOC[$toc_id]['TOC_suppress'] = $toc_suppress; // mPDF 6
139 }
140 else {
141 $this->TOCmark = $this->mpdf->page;
142 $this->TOCoutdent = $tocoutdent;
143 $this->TOCorientation = $toc_orientation;
144 $this->TOCuseLinking = $TOCuseLinking;
145 $this->TOCusePaging = $TOCusePaging;
146 $this->TOC_resetpagenum = $toc_resetpagenum; // mPDF 6
147 $this->TOC_pagenumstyle = $toc_pagenumstyle; // mPDF 6
148 $this->TOC_suppress = $toc_suppress; // mPDF 6
149 }
150 }
151
152
153 function insertTOC() {
154 $notocs = 0;
155 if ($this->TOCmark) { $notocs = 1; }
156 $notocs += count($this->m_TOC);
157
158 if ($notocs==0) { return; }
159
160 if (count($this->m_TOC)) { reset($this->m_TOC); }
161 $added_toc_pages = 0;
162
163 if ($this->mpdf->ColActive) { $this->mpdf->SetColumns(0); }
164 if (($this->mpdf->mirrorMargins) && (($this->mpdf->page)%2==1)) { // ODD
165 $this->mpdf->AddPage($this->mpdf->CurOrientation);
166 $extrapage = true;
167 }
168 else { $extrapage = false; }
169
170 for ($toci = 0; $toci<$notocs; $toci++) {
171 if ($toci==0 && $this->TOCmark) {
172 $toc_id = 0;
173 $toc_page = $this->TOCmark;
174 $tocoutdent = $this->TOCoutdent;
175 $toc_orientation = $this->TOCorientation;
176 $TOCuseLinking = $this->TOCuseLinking;
177 $TOCusePaging = $this->TOCusePaging;
178 $toc_preHTML = $this->TOCpreHTML;
179 $toc_postHTML = $this->TOCpostHTML;
180 $toc_bookmarkText = $this->TOCbookmarkText;
181 $toc_mgl = $this->TOC_margin_left;
182 $toc_mgr = $this->TOC_margin_right;
183 $toc_mgt = $this->TOC_margin_top;
184 $toc_mgb = $this->TOC_margin_bottom;
185 $toc_mgh = $this->TOC_margin_header;
186 $toc_mgf = $this->TOC_margin_footer;
187 $toc_ohname = $this->TOC_odd_header_name;
188 $toc_ehname = $this->TOC_even_header_name;
189 $toc_ofname = $this->TOC_odd_footer_name;
190 $toc_efname = $this->TOC_even_footer_name;
191 $toc_ohvalue = $this->TOC_odd_header_value;
192 $toc_ehvalue = $this->TOC_even_header_value;
193 $toc_ofvalue = $this->TOC_odd_footer_value;
194 $toc_efvalue = $this->TOC_even_footer_value;
195 $toc_page_selector = $this->TOC_page_selector;
196 $toc_resetpagenum = $this->TOC_resetpagenum; // mPDF 6
197 $toc_pagenumstyle = $this->TOC_pagenumstyle; // mPDF 6
198 $toc_suppress = $this->TOC_suppress; // mPDF 6
199 $toc_sheet_size = (isset($this->TOCsheetsize) ? $this->TOCsheetsize : '');
200 }
201 else {
202 $arr = current($this->m_TOC);
203
204 $toc_id = key($this->m_TOC);
205 $toc_page = $this->m_TOC[$toc_id]['TOCmark'];
206 $tocoutdent = $this->m_TOC[$toc_id]['TOCoutdent'];
207 $toc_orientation = $this->m_TOC[$toc_id]['TOCorientation'];
208 $TOCuseLinking = $this->m_TOC[$toc_id]['TOCuseLinking'];
209 $TOCusePaging = $this->m_TOC[$toc_id]['TOCusePaging'];
210 if (isset($this->m_TOC[$toc_id]['TOCpreHTML'])) { $toc_preHTML = $this->m_TOC[$toc_id]['TOCpreHTML']; }
211 else { $toc_preHTML = ''; }
212 if (isset($this->m_TOC[$toc_id]['TOCpostHTML'])) { $toc_postHTML = $this->m_TOC[$toc_id]['TOCpostHTML']; }
213 else { $toc_postHTML = ''; }
214 if (isset($this->m_TOC[$toc_id]['TOCbookmarkText'])) { $toc_bookmarkText = $this->m_TOC[$toc_id]['TOCbookmarkText']; }
215 else { $toc_bookmarkText = ''; } // *BOOKMARKS*
216 $toc_mgl = $this->m_TOC[$toc_id]['TOC_margin_left'];
217 $toc_mgr = $this->m_TOC[$toc_id]['TOC_margin_right'];
218 $toc_mgt = $this->m_TOC[$toc_id]['TOC_margin_top'];
219 $toc_mgb = $this->m_TOC[$toc_id]['TOC_margin_bottom'];
220 $toc_mgh = $this->m_TOC[$toc_id]['TOC_margin_header'];
221 $toc_mgf = $this->m_TOC[$toc_id]['TOC_margin_footer'];
222 $toc_ohname = $this->m_TOC[$toc_id]['TOC_odd_header_name'];
223 $toc_ehname = $this->m_TOC[$toc_id]['TOC_even_header_name'];
224 $toc_ofname = $this->m_TOC[$toc_id]['TOC_odd_footer_name'];
225 $toc_efname = $this->m_TOC[$toc_id]['TOC_even_footer_name'];
226 $toc_ohvalue = $this->m_TOC[$toc_id]['TOC_odd_header_value'];
227 $toc_ehvalue = $this->m_TOC[$toc_id]['TOC_even_header_value'];
228 $toc_ofvalue = $this->m_TOC[$toc_id]['TOC_odd_footer_value'];
229 $toc_efvalue = $this->m_TOC[$toc_id]['TOC_even_footer_value'];
230 $toc_page_selector = $this->m_TOC[$toc_id]['TOC_page_selector'];
231 $toc_resetpagenum = $this->m_TOC[$toc_id]['TOC_resetpagenum']; // mPDF 6
232 $toc_pagenumstyle = $this->m_TOC[$toc_id]['TOC_pagenumstyle']; // mPDF 6
233 $toc_suppress = $this->m_TOC[$toc_id]['TOC_suppress']; // mPDF 6
234 $toc_sheet_size = (isset($this->m_TOC[$toc_id]['TOCsheetsize']) ? $this->m_TOC[$toc_id]['TOCsheetsize'] : '');
235 next($this->m_TOC);
236 }
237
238 // mPDF 5.6.31
239 if (!$toc_orientation) { $toc_orientation= $this->mpdf->DefOrientation; }
240
241 // mPDF 6 number style and suppress now picked up from section preceding ToC
242 list($tp_pagenumstyle, $tp_suppress, $tp_reset) = $this->mpdf->docPageSettings($toc_page-1);
243
244 if ($toc_resetpagenum) $tp_reset = $toc_resetpagenum; // mPDF 6
245 if ($toc_pagenumstyle) $tp_pagenumstyle = $toc_pagenumstyle; // mPDF 6
246 if ($toc_suppress || $toc_suppress==='0') $tp_suppress = $toc_suppress; // mPDF 6
247
248 $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
249
250
251 $this->mpdf->writingToC = true; // mPDF 5.6.38
252 // mPDF 5.6.31
253 $tocstart=count($this->mpdf->pages);
254 if (isset($toc_preHTML) && $toc_preHTML) { $this->mpdf->WriteHTML($toc_preHTML); }
255
256
257 // mPDF 5.6.19
258 $html ='<div class="mpdf_toc" id="mpdf_toc_'.$toc_id.'">';
259 foreach($this->_toc as $t) {
260 if ($t['toc_id']==='_mpdf_all' || $t['toc_id']===$toc_id ) {
261 $html .= '<div class="mpdf_toc_level_'.$t['l'].'">';
262 if ($TOCuseLinking) { $html .= '<a class="mpdf_toc_a" href="#__mpdfinternallink_'.$t['link'].'">'; }
263 $html .= '<span class="mpdf_toc_t_level_'.$t['l'].'">'.$t['t'].'</span>';
264 if ($TOCuseLinking) { $html .= '</a>'; }
265 if (!$tocoutdent) { $tocoutdent = '0'; }
266 if ($TOCusePaging) { $html .= ' <dottab outdent="'.$tocoutdent.'" /> ';
267 if ($TOCuseLinking) { $html .= '<a class="mpdf_toc_a" href="#__mpdfinternallink_'.$t['link'].'">'; }
268 $html .= '<span class="mpdf_toc_p_level_'.$t['l'].'">'.$this->mpdf->docPageNum($t['p']).'</span>';
269 if ($TOCuseLinking) { $html .= '</a>'; }
270 }
271 $html .= '</div>';
272 }
273 }
274 $html .= '</div>';
275 $this->mpdf->WriteHTML($html);
276
277 if (isset($toc_postHTML) && $toc_postHTML) { $this->mpdf->WriteHTML($toc_postHTML); }
278 $this->mpdf->writingToC = false; // mPDF 5.6.38
279 $this->mpdf->AddPage($toc_orientation,'E');
280
281 $n_toc = $this->mpdf->page - $tocstart + 1;
282
283 if ($toci==0 && $this->TOCmark) {
284 $TOC_start = $tocstart ;
285 $TOC_end = $this->mpdf->page;
286 $TOC_npages = $n_toc;
287 }
288 else {
289 $this->m_TOC[$toc_id]['start'] = $tocstart ;
290 $this->m_TOC[$toc_id]['end'] = $this->mpdf->page;
291 $this->m_TOC[$toc_id]['npages'] = $n_toc;
292 }
293 }
294
295 $s = '';
296
297 $s .= $this->mpdf->PrintBodyBackgrounds();
298
299 $s .= $this->mpdf->PrintPageBackgrounds();
300 $this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->mpdf->uniqstr.')/', "\n".$s."\n".'\\1', $this->mpdf->pages[$this->mpdf->page]);
301 $this->mpdf->pageBackgrounds = array();
302
303 //Page footer
304 $this->mpdf->InFooter=true;
305 $this->mpdf->Footer();
306 $this->mpdf->InFooter=false;
307
308 // 2nd time through to move pages etc.
309 $added_toc_pages = 0;
310 if (count($this->m_TOC)) { reset($this->m_TOC); }
311
312 for ($toci = 0; $toci<$notocs; $toci++) {
313 if ($toci==0 && $this->TOCmark) {
314 $toc_id = 0;
315 $toc_page = $this->TOCmark + $added_toc_pages;
316 $toc_orientation = $this->TOCorientation;
317 $TOCuseLinking = $this->TOCuseLinking;
318 $TOCusePaging = $this->TOCusePaging;
319 $toc_bookmarkText = $this->TOCbookmarkText; // *BOOKMARKS*
320
321 $tocstart = $TOC_start ;
322 $tocend = $n = $TOC_end;
323 $n_toc = $TOC_npages;
324 }
325 else {
326 $arr = current($this->m_TOC);
327
328 $toc_id = key($this->m_TOC);
329 $toc_page = $this->m_TOC[$toc_id]['TOCmark'] + $added_toc_pages;
330 $toc_orientation = $this->m_TOC[$toc_id]['TOCorientation'];
331 $TOCuseLinking = $this->m_TOC[$toc_id]['TOCuseLinking'];
332 $TOCusePaging = $this->m_TOC[$toc_id]['TOCusePaging'];
333 $toc_bookmarkText = $this->m_TOC[$toc_id]['TOCbookmarkText']; // *BOOKMARKS*
334
335 $tocstart = $this->m_TOC[$toc_id]['start'] ;
336 $tocend = $n = $this->m_TOC[$toc_id]['end'] ;
337 $n_toc = $this->m_TOC[$toc_id]['npages'] ;
338
339 next($this->m_TOC);
340 }
341
342 // Now pages moved
343 $added_toc_pages += $n_toc;
344
345 $this->mpdf->MovePages($toc_page, $tocstart, $tocend) ;
346 $this->mpdf->pgsIns[$toc_page] = $tocend - $tocstart + 1;
347
348 /*-- BOOKMARKS --*/
349 // Insert new Bookmark for Bookmark
350 if ($toc_bookmarkText) {
351 $insert = -1;
352 foreach($this->mpdf->BMoutlines as $i=>$o) {
353 if($o['p']<$toc_page) { // i.e. before point of insertion
354 $insert = $i;
355 }
356 }
357 $txt = $this->mpdf->purify_utf8_text($toc_bookmarkText);
358 if ($this->mpdf->text_input_as_HTML) {
359 $txt = $this->mpdf->all_entities_to_utf8($txt);
360 }
361 $newBookmark[0] = array('t'=>$txt,'l'=>0,'y'=>0,'p'=>$toc_page );
362 array_splice($this->mpdf->BMoutlines,($insert+1),0,$newBookmark);
363 }
364 /*-- END BOOKMARKS --*/
365
366 }
367
368 // Delete empty page that was inserted earlier
369 if ($extrapage) {
370 unset($this->mpdf->pages[count($this->mpdf->pages)]);
371 $this->mpdf->page--; // Reset page pointer
372 }
373
374
375 }
376
377
378 function openTagTOC($attr) {
379 if (isset($attr['OUTDENT']) && $attr['OUTDENT']) { $tocoutdent = $attr['OUTDENT']; } else { $tocoutdent = ''; } // mPDF 5.6.19
380 if (isset($attr['RESETPAGENUM']) && $attr['RESETPAGENUM']) { $resetpagenum = $attr['RESETPAGENUM']; } else { $resetpagenum = ''; }
381 if (isset($attr['PAGENUMSTYLE']) && $attr['PAGENUMSTYLE']) { $pagenumstyle = $attr['PAGENUMSTYLE']; } else { $pagenumstyle= ''; }
382 if (isset($attr['SUPPRESS']) && $attr['SUPPRESS']) { $suppress = $attr['SUPPRESS']; } else { $suppress = ''; }
383 if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) { $toc_orientation = $attr['TOC-ORIENTATION']; } else { $toc_orientation = ''; }
384 if (isset($attr['PAGING']) && (strtoupper($attr['PAGING'])=='OFF' || $attr['PAGING']==='0')) { $paging = false; }
385 else { $paging = true; }
386 if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $links = true; }
387 else { $links = false; }
388 if (isset($attr['NAME']) && $attr['NAME']) { $toc_id = strtolower($attr['NAME']); } else { $toc_id = 0; }
389 $this->TOC('',0,0,$resetpagenum, $pagenumstyle, $suppress, $toc_orientation, $paging, $links, $toc_id, $tocoutdent); // mPDF 5.6.19 5.6.31
390 }
391
392
393 function openTagTOCPAGEBREAK($attr) {
394 if (isset($attr['NAME']) && $attr['NAME']) { $toc_id = strtolower($attr['NAME']); } else { $toc_id = 0; }
395 if ($toc_id) {
396 if (isset($attr['OUTDENT']) && $attr['OUTDENT']) { $this->m_TOC[$toc_id]['TOCoutdent'] = $attr['OUTDENT']; } else { $this->m_TOC[$toc_id]['TOCoutdent'] = ''; } // mPDF 5.6.19
397 if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) { $this->m_TOC[$toc_id]['TOCorientation'] = $attr['TOC-ORIENTATION']; } else { $this->m_TOC[$toc_id]['TOCorientation'] = ''; }
398 if (isset($attr['PAGING']) && (strtoupper($attr['PAGING'])=='OFF' || $attr['PAGING']==='0')) { $this->m_TOC[$toc_id]['TOCusePaging'] = false; }
399 else { $this->m_TOC[$toc_id]['TOCusePaging'] = true; }
400 if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $this->m_TOC[$toc_id]['TOCuseLinking'] = true; }
401 else { $this->m_TOC[$toc_id]['TOCuseLinking'] = false; }
402
403 $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'] = '';
404 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); }
405 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); }
406 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); }
407 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); }
408 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); }
409 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); }
410 $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'] = '';
411 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']; }
412 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']; }
413 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']; }
414 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']; }
415 $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;
416 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; }
417 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; }
418 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; }
419 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; }
420 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; }
421 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; }
422 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; }
423 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; }
424 if (isset($attr['TOC-RESETPAGENUM']) && $attr['TOC-RESETPAGENUM']) { $this->m_TOC[$toc_id]['TOC_resetpagenum'] = $attr['TOC-RESETPAGENUM']; }
425 else { $this->m_TOC[$toc_id]['TOC_resetpagenum'] = ''; } // mPDF 6
426 if (isset($attr['TOC-PAGENUMSTYLE']) && $attr['TOC-PAGENUMSTYLE']) { $this->m_TOC[$toc_id]['TOC_pagenumstyle'] = $attr['TOC-PAGENUMSTYLE']; }
427 else { $this->m_TOC[$toc_id]['TOC_pagenumstyle'] = ''; } // mPDF 6
428 if (isset($attr['TOC-SUPPRESS']) && ($attr['TOC-SUPPRESS'] || $attr['TOC-SUPPRESS']==='0')) { $this->m_TOC[$toc_id]['TOC_suppress'] = $attr['TOC-SUPPRESS']; }
429 else { $this->m_TOC[$toc_id]['TOC_suppress'] = ''; } // mPDF 6
430 if (isset($attr['TOC-PAGE-SELECTOR']) && $attr['TOC-PAGE-SELECTOR']) { $this->m_TOC[$toc_id]['TOC_page_selector'] = $attr['TOC-PAGE-SELECTOR']; }
431 else { $this->m_TOC[$toc_id]['TOC_page_selector'] = ''; }
432 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'] = ''; }
433
434
435 if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) { $this->m_TOC[$toc_id]['TOCpreHTML'] = htmlspecialchars_decode($attr['TOC-PREHTML'],ENT_QUOTES); }
436 if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) { $this->m_TOC[$toc_id]['TOCpostHTML'] = htmlspecialchars_decode($attr['TOC-POSTHTML'],ENT_QUOTES); }
437
438 if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) { $this->m_TOC[$toc_id]['TOCbookmarkText'] = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'],ENT_QUOTES); } // *BOOKMARKS*
439 }
440 else {
441 if (isset($attr['OUTDENT']) && $attr['OUTDENT']) { $this->TOCoutdent = $attr['OUTDENT']; } else { $this->TOCoutdent = ''; } // mPDF 5.6.19
442 if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) { $this->TOCorientation = $attr['TOC-ORIENTATION']; } else { $this->TOCorientation = ''; }
443 if (isset($attr['PAGING']) && (strtoupper($attr['PAGING'])=='OFF' || $attr['PAGING']==='0')) { $this->TOCusePaging = false; }
444 else { $this->TOCusePaging = true; }
445 if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $this->TOCuseLinking = true; }
446 else { $this->TOCuseLinking = false; }
447
448 $this->TOC_margin_left = $this->TOC_margin_right = $this->TOC_margin_top = $this->TOC_margin_bottom = $this->TOC_margin_header = $this->TOC_margin_footer = '';
449 if (isset($attr['TOC-MARGIN-RIGHT'])) { $this->TOC_margin_right = $this->mpdf->ConvertSize($attr['TOC-MARGIN-RIGHT'],$this->mpdf->w,$this->mpdf->FontSize,false); }
450 if (isset($attr['TOC-MARGIN-LEFT'])) { $this->TOC_margin_left = $this->mpdf->ConvertSize($attr['TOC-MARGIN-LEFT'],$this->mpdf->w,$this->mpdf->FontSize,false); }
451 if (isset($attr['TOC-MARGIN-TOP'])) { $this->TOC_margin_top = $this->mpdf->ConvertSize($attr['TOC-MARGIN-TOP'],$this->mpdf->w,$this->mpdf->FontSize,false); }
452 if (isset($attr['TOC-MARGIN-BOTTOM'])) { $this->TOC_margin_bottom = $this->mpdf->ConvertSize($attr['TOC-MARGIN-BOTTOM'],$this->mpdf->w,$this->mpdf->FontSize,false); }
453 if (isset($attr['TOC-MARGIN-HEADER'])) { $this->TOC_margin_header = $this->mpdf->ConvertSize($attr['TOC-MARGIN-HEADER'],$this->mpdf->w,$this->mpdf->FontSize,false); }
454 if (isset($attr['TOC-MARGIN-FOOTER'])) { $this->TOC_margin_footer = $this->mpdf->ConvertSize($attr['TOC-MARGIN-FOOTER'],$this->mpdf->w,$this->mpdf->FontSize,false); }
455 $this->TOC_odd_header_name = $this->TOC_even_header_name = $this->TOC_odd_footer_name = $this->TOC_even_footer_name = '';
456 if (isset($attr['TOC-ODD-HEADER-NAME']) && $attr['TOC-ODD-HEADER-NAME']) { $this->TOC_odd_header_name = $attr['TOC-ODD-HEADER-NAME']; }
457 if (isset($attr['TOC-EVEN-HEADER-NAME']) && $attr['TOC-EVEN-HEADER-NAME']) { $this->TOC_even_header_name = $attr['TOC-EVEN-HEADER-NAME']; }
458 if (isset($attr['TOC-ODD-FOOTER-NAME']) && $attr['TOC-ODD-FOOTER-NAME']) { $this->TOC_odd_footer_name = $attr['TOC-ODD-FOOTER-NAME']; }
459 if (isset($attr['TOC-EVEN-FOOTER-NAME']) && $attr['TOC-EVEN-FOOTER-NAME']) { $this->TOC_even_footer_name = $attr['TOC-EVEN-FOOTER-NAME']; }
460 $this->TOC_odd_header_value = $this->TOC_even_header_value = $this->TOC_odd_footer_value = $this->TOC_even_footer_value = 0;
461 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; }
462 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; }
463 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; }
464 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; }
465
466 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; }
467 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; }
468 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; }
469 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; }
470 if (isset($attr['TOC-PAGE-SELECTOR']) && $attr['TOC-PAGE-SELECTOR']) { $this->TOC_page_selector = $attr['TOC-PAGE-SELECTOR']; }
471 else { $this->TOC_page_selector = ''; }
472 if (isset($attr['TOC-RESETPAGENUM']) && $attr['TOC-RESETPAGENUM']) { $this->TOC_resetpagenum = $attr['TOC-RESETPAGENUM']; }
473 else { $this->TOC_resetpagenum = ''; } // mPDF 6
474 if (isset($attr['TOC-PAGENUMSTYLE']) && $attr['TOC-PAGENUMSTYLE']) { $this->TOC_pagenumstyle = $attr['TOC-PAGENUMSTYLE']; }
475 else { $this->TOC_pagenumstyle = ''; } // mPDF 6
476 if (isset($attr['TOC-SUPPRESS']) && ($attr['TOC-SUPPRESS'] || $attr['TOC-SUPPRESS']==='0')) { $this->TOC_suppress = $attr['TOC-SUPPRESS']; }
477 else { $this->TOC_suppress = ''; } // mPDF 6
478 if (isset($attr['TOC-SHEET-SIZE']) && $attr['TOC-SHEET-SIZE']) { $this->TOCsheetsize = $attr['TOC-SHEET-SIZE']; } else { $this->TOCsheetsize = ''; }
479
480 if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) { $this->TOCpreHTML = htmlspecialchars_decode($attr['TOC-PREHTML'],ENT_QUOTES); }
481 if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) { $this->TOCpostHTML = htmlspecialchars_decode($attr['TOC-POSTHTML'],ENT_QUOTES); }
482 if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) { $this->TOCbookmarkText = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'],ENT_QUOTES); }
483 }
484
485 if ($this->mpdf->y == $this->mpdf->tMargin && (!$this->mpdf->mirrorMargins ||($this->mpdf->mirrorMargins && $this->mpdf->page % 2==1))) {
486 if ($toc_id) { $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page; }
487 else { $this->TOCmark = $this->mpdf->page; }
488 // Don't add a page
489 if ($this->mpdf->page==1 && count($this->mpdf->PageNumSubstitutions)==0) {
490 $resetpagenum = '';
491 $pagenumstyle = '';
492 $suppress = '';
493 if (isset($attr['RESETPAGENUM'])) { $resetpagenum = $attr['RESETPAGENUM']; }
494 if (isset($attr['PAGENUMSTYLE'])) { $pagenumstyle = $attr['PAGENUMSTYLE']; }
495 if (isset($attr['SUPPRESS'])) { $suppress = $attr['SUPPRESS']; }
496 if (!$suppress) { $suppress = 'off'; }
497 if (!$resetpagenum) { $resetpagenum= 1; }
498 $this->mpdf->PageNumSubstitutions[] = array('from'=>1, 'reset'=> $resetpagenum, 'type'=>$pagenumstyle, 'suppress'=> $suppress);
499 }
500 return array(true, $toc_id);
501 }
502 // No break - continues as PAGEBREAK...
503 return array(false, $toc_id);
504 }
505
506
507 }
508
509 ?>