Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

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