| @@ -4,9 +4,13 @@ | ||
| 4 | 4 | |
| 5 | 5 | var $mpdf = null; |
| 6 | 6 | var $_toc; |
| 7 | 7 | var $TOCmark; |
| 8 | -var $TOCoutdent; // mPDF 5.6.31 | |
| 8 | +var $TOCfont; | |
| 9 | +var $TOCfontsize; | |
| 10 | +var $TOCindent; | |
| 11 | +var $TOCheader; | |
| 12 | +var $TOCfooter; | |
| 9 | 13 | var $TOCpreHTML; |
| 10 | 14 | var $TOCpostHTML; |
| 11 | 15 | var $TOCbookmarkText; |
| 12 | 16 | var $TOCusePaging; |
| @@ -26,11 +30,8 @@ | ||
| 26 | 30 | var $TOC_even_header_value; |
| 27 | 31 | var $TOC_odd_footer_value; |
| 28 | 32 | var $TOC_even_footer_value; |
| 29 | 33 | var $TOC_page_selector; |
| 30 | -var $TOC_resetpagenum; // mPDF 6 | |
| 31 | -var $TOC_pagenumstyle; // mPDF 6 | |
| 32 | -var $TOC_suppress; // mPDF 6 | |
| 33 | 34 | var $m_TOC; |
| 34 | 35 | |
| 35 | 36 | function tocontents(&$mpdf) { |
| 36 | 37 | $this->mpdf = $mpdf; |
| @@ -38,19 +39,24 @@ | ||
| 38 | 39 | $this->TOCmark = 0; |
| 39 | 40 | $this->m_TOC=array(); |
| 40 | 41 | } |
| 41 | 42 | |
| 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 | +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='') { | |
| 43 | 44 | if (strtoupper($toc_id)=='ALL') { $toc_id = '_mpdf_all'; } |
| 44 | 45 | else if (!$toc_id) { $toc_id = 0; } |
| 45 | 46 | else { $toc_id = strtolower($toc_id); } |
| 46 | 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; } | |
| 47 | 51 | if ($TOCusePaging === false || strtolower($TOCusePaging) == "off" || $TOCusePaging === 0 || $TOCusePaging === "0" || $TOCusePaging === "") { $TOCusePaging = false; } |
| 48 | 52 | else { $TOCusePaging = true; } |
| 49 | 53 | if (!$TOCuseLinking) { $TOCuseLinking = false; } |
| 50 | 54 | if ($toc_id) { |
| 51 | 55 | $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page; |
| 52 | - $this->m_TOC[$toc_id]['TOCoutdent'] = $tocoutdent; | |
| 56 | + $this->m_TOC[$toc_id]['TOCfont'] = $tocfont; | |
| 57 | + $this->m_TOC[$toc_id]['TOCfontsize'] = $tocfontsize; | |
| 58 | + $this->m_TOC[$toc_id]['TOCindent'] = $tocindent; | |
| 53 | 59 | $this->m_TOC[$toc_id]['TOCorientation'] = $toc_orientation; |
| 54 | 60 | $this->m_TOC[$toc_id]['TOCuseLinking'] = $TOCuseLinking; |
| 55 | 61 | $this->m_TOC[$toc_id]['TOCusePaging'] = $TOCusePaging; |
| 56 | 62 | |
| @@ -72,16 +78,15 @@ | ||
| 72 | 78 | $this->m_TOC[$toc_id]['TOC_even_header_value'] = $toc_ehvalue; |
| 73 | 79 | $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = $toc_ofvalue; |
| 74 | 80 | $this->m_TOC[$toc_id]['TOC_even_footer_value'] = $toc_efvalue; |
| 75 | 81 | $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 | 82 | $this->m_TOC[$toc_id]['TOCsheetsize'] = $toc_sheetsize; |
| 80 | 83 | } |
| 81 | 84 | else { |
| 82 | 85 | $this->TOCmark = $this->mpdf->page; |
| 83 | - $this->TOCoutdent = $tocoutdent; | |
| 86 | + $this->TOCfont = $tocfont; | |
| 87 | + $this->TOCfontsize = $tocfontsize; | |
| 88 | + $this->TOCindent = $tocindent; | |
| 84 | 89 | $this->TOCorientation = $toc_orientation; |
| 85 | 90 | $this->TOCuseLinking = $TOCuseLinking; |
| 86 | 91 | $this->TOCusePaging = $TOCusePaging; |
| 87 | 92 | |
| @@ -103,17 +108,14 @@ | ||
| 103 | 108 | $this->TOC_even_header_value = $toc_ehvalue; |
| 104 | 109 | $this->TOC_odd_footer_value = $toc_ofvalue; |
| 105 | 110 | $this->TOC_even_footer_value = $toc_efvalue; |
| 106 | 111 | $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 | 112 | $this->TOCsheetsize = $toc_sheetsize; |
| 111 | 113 | } |
| 112 | 114 | } |
| 113 | 115 | |
| 114 | 116 | // 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 | |
| 117 | +function TOC($tocfont='', $tocfontsize=8, $tocindent=5, $resetpagenum='', $pagenumstyle='', $suppress='', $toc_orientation='', $TOCusePaging=true, $TOCuseLinking=false, $toc_id=0) { | |
| 116 | 118 | if (strtoupper($toc_id)=='ALL') { $toc_id = '_mpdf_all'; } |
| 117 | 119 | else if (!$toc_id) { $toc_id = 0; } |
| 118 | 120 | else { $toc_id = strtolower($toc_id); } |
| 119 | 121 | // To use odd and even pages |
| @@ -126,27 +128,27 @@ | ||
| 126 | 128 | } |
| 127 | 129 | else { |
| 128 | 130 | $this->mpdf->PageNumSubstitutions[] = array('from'=>$this->mpdf->page, 'reset'=> $resetpagenum, 'type'=>$pagenumstyle, 'suppress'=>$suppress); |
| 129 | 131 | } |
| 132 | + if (!$tocfont) { $tocfont = $this->mpdf->default_font; } | |
| 133 | + if (!$tocfontsize) { $tocfontsize = $this->mpdf->default_font_size; } | |
| 130 | 134 | if ($toc_id) { |
| 131 | 135 | $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page; |
| 132 | - $this->m_TOC[$toc_id]['TOCoutdent'] = $tocoutdent; | |
| 136 | + $this->m_TOC[$toc_id]['TOCfont'] = $tocfont; | |
| 137 | + $this->m_TOC[$toc_id]['TOCfontsize'] = $tocfontsize; | |
| 138 | + $this->m_TOC[$toc_id]['TOCindent'] = $tocindent; | |
| 133 | 139 | $this->m_TOC[$toc_id]['TOCorientation'] = $toc_orientation; |
| 134 | 140 | $this->m_TOC[$toc_id]['TOCuseLinking'] = $TOCuseLinking; |
| 135 | 141 | $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 | 142 | } |
| 140 | 143 | else { |
| 141 | 144 | $this->TOCmark = $this->mpdf->page; |
| 142 | - $this->TOCoutdent = $tocoutdent; | |
| 145 | + $this->TOCfont = $tocfont; | |
| 146 | + $this->TOCfontsize = $tocfontsize; | |
| 147 | + $this->TOCindent = $tocindent; | |
| 143 | 148 | $this->TOCorientation = $toc_orientation; |
| 144 | 149 | $this->TOCuseLinking = $TOCuseLinking; |
| 145 | 150 | $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 | 151 | } |
| 150 | 152 | } |
| 151 | 153 | |
| 152 | 154 | |
| @@ -170,9 +172,11 @@ | ||
| 170 | 172 | for ($toci = 0; $toci<$notocs; $toci++) { |
| 171 | 173 | if ($toci==0 && $this->TOCmark) { |
| 172 | 174 | $toc_id = 0; |
| 173 | 175 | $toc_page = $this->TOCmark; |
| 174 | - $tocoutdent = $this->TOCoutdent; | |
| 176 | + $tocfont = $this->TOCfont; | |
| 177 | + $tocfontsize = $this->TOCfontsize; | |
| 178 | + $tocindent = $this->TOCindent; | |
| 175 | 179 | $toc_orientation = $this->TOCorientation; |
| 176 | 180 | $TOCuseLinking = $this->TOCuseLinking; |
| 177 | 181 | $TOCusePaging = $this->TOCusePaging; |
| 178 | 182 | $toc_preHTML = $this->TOCpreHTML; |
| @@ -192,12 +196,9 @@ | ||
| 192 | 196 | $toc_ehvalue = $this->TOC_even_header_value; |
| 193 | 197 | $toc_ofvalue = $this->TOC_odd_footer_value; |
| 194 | 198 | $toc_efvalue = $this->TOC_even_footer_value; |
| 195 | 199 | $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 | + $toc_sheet_size = $this->TOCsheetsize; | |
| 200 | 201 | } |
| 201 | 202 | else { |
| 202 | 203 | $arr = current($this->m_TOC); |
| 203 | 204 | |
| @@ -202,9 +203,11 @@ | ||
| 202 | 203 | $arr = current($this->m_TOC); |
| 203 | 204 | |
| 204 | 205 | $toc_id = key($this->m_TOC); |
| 205 | 206 | $toc_page = $this->m_TOC[$toc_id]['TOCmark']; |
| 206 | - $tocoutdent = $this->m_TOC[$toc_id]['TOCoutdent']; | |
| 207 | + $tocfont = $this->m_TOC[$toc_id]['TOCfont']; | |
| 208 | + $tocfontsize = $this->m_TOC[$toc_id]['TOCfontsize']; | |
| 209 | + $tocindent = $this->m_TOC[$toc_id]['TOCindent']; | |
| 207 | 210 | $toc_orientation = $this->m_TOC[$toc_id]['TOCorientation']; |
| 208 | 211 | $TOCuseLinking = $this->m_TOC[$toc_id]['TOCuseLinking']; |
| 209 | 212 | $TOCusePaging = $this->m_TOC[$toc_id]['TOCusePaging']; |
| 210 | 213 | if (isset($this->m_TOC[$toc_id]['TOCpreHTML'])) { $toc_preHTML = $this->m_TOC[$toc_id]['TOCpreHTML']; } |
| @@ -227,56 +230,139 @@ | ||
| 227 | 230 | $toc_ehvalue = $this->m_TOC[$toc_id]['TOC_even_header_value']; |
| 228 | 231 | $toc_ofvalue = $this->m_TOC[$toc_id]['TOC_odd_footer_value']; |
| 229 | 232 | $toc_efvalue = $this->m_TOC[$toc_id]['TOC_even_footer_value']; |
| 230 | 233 | $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'] : ''); | |
| 234 | + $toc_sheet_size = $this->m_TOC[$toc_id]['TOCsheetsize']; | |
| 235 | 235 | next($this->m_TOC); |
| 236 | 236 | } |
| 237 | + if ($this->TOCheader) { $this->mpdf->SetHeader($this->TOCheader); } | |
| 238 | + else if ($this->TOCheader !== false) { $this->mpdf->SetHeader(); } | |
| 237 | 239 | |
| 238 | - // mPDF 5.6.31 | |
| 240 | + if (!$tocindent && $tocindent !== 0) { $tocindent = 5; } | |
| 239 | 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 ); | |
| 240 | 243 | |
| 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); | |
| 244 | + if ($this->TOCfooter) { $this->mpdf->SetFooter($this->TOCfooter); } | |
| 245 | + else if ($this->TOCfooter !== false) { $this->mpdf->SetFooter(); } | |
| 243 | 246 | |
| 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 | + $tocstart=count($this->mpdf->pages); | |
| 248 | + if ($toc_preHTML) { $this->mpdf->WriteHTML($toc_preHTML); } | |
| 247 | 249 | |
| 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 | |
| 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']; | |
| 249 | 256 | |
| 257 | + if ($TOCuseLinking) { $tlink = $t['link']; } | |
| 258 | + else { $tlink = ''; } | |
| 250 | 259 | |
| 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); } | |
| 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)); | |
| 255 | 278 | |
| 279 | + $this->mpdf->magic_reverse_dir($str, true, $this->mpdf->directionality); // *RTL* | |
| 256 | 280 | |
| 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>'; } | |
| 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); | |
| 270 | 296 | } |
| 271 | - $html .= '</div>'; | |
| 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* | |
| 272 | 361 | } |
| 273 | 362 | } |
| 274 | - $html .= '</div>'; | |
| 275 | - $this->mpdf->WriteHTML($html); | |
| 276 | 363 | |
| 277 | - if (isset($toc_postHTML) && $toc_postHTML) { $this->mpdf->WriteHTML($toc_postHTML); } | |
| 278 | - $this->mpdf->writingToC = false; // mPDF 5.6.38 | |
| 364 | + if ($toc_postHTML) { $this->mpdf->WriteHTML($toc_postHTML); } | |
| 279 | 365 | $this->mpdf->AddPage($toc_orientation,'E'); |
| 280 | 366 | |
| 281 | 367 | $n_toc = $this->mpdf->page - $tocstart + 1; |
| 282 | 368 | |
| @@ -296,9 +382,9 @@ | ||
| 296 | 382 | |
| 297 | 383 | $s .= $this->mpdf->PrintBodyBackgrounds(); |
| 298 | 384 | |
| 299 | 385 | $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]); | |
| 386 | + $this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', "\n".$s."\n".'\\1', $this->mpdf->pages[$this->mpdf->page]); | |
| 301 | 387 | $this->mpdf->pageBackgrounds = array(); |
| 302 | 388 | |
| 303 | 389 | //Page footer |
| 304 | 390 | $this->mpdf->InFooter=true; |
| @@ -375,9 +461,11 @@ | ||
| 375 | 461 | } |
| 376 | 462 | |
| 377 | 463 | |
| 378 | 464 | function openTagTOC($attr) { |
| 379 | - if (isset($attr['OUTDENT']) && $attr['OUTDENT']) { $tocoutdent = $attr['OUTDENT']; } else { $tocoutdent = ''; } // mPDF 5.6.19 | |
| 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 = ''; } | |
| 380 | 468 | if (isset($attr['RESETPAGENUM']) && $attr['RESETPAGENUM']) { $resetpagenum = $attr['RESETPAGENUM']; } else { $resetpagenum = ''; } |
| 381 | 469 | if (isset($attr['PAGENUMSTYLE']) && $attr['PAGENUMSTYLE']) { $pagenumstyle = $attr['PAGENUMSTYLE']; } else { $pagenumstyle= ''; } |
| 382 | 470 | if (isset($attr['SUPPRESS']) && $attr['SUPPRESS']) { $suppress = $attr['SUPPRESS']; } else { $suppress = ''; } |
| 383 | 471 | if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) { $toc_orientation = $attr['TOC-ORIENTATION']; } else { $toc_orientation = ''; } |
| @@ -385,9 +473,9 @@ | ||
| 385 | 473 | else { $paging = true; } |
| 386 | 474 | if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $links = true; } |
| 387 | 475 | else { $links = false; } |
| 388 | 476 | 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 | |
| 477 | + $this->TOC($tocfont,$tocfontsize,$tocindent,$resetpagenum, $pagenumstyle, $suppress, $toc_orientation, $paging, $links, $toc_id); | |
| 390 | 478 | } |
| 391 | 479 | |
| 392 | 480 | |
| 393 | 481 | function openTagTOCPAGEBREAK($attr) { |
| @@ -392,9 +480,11 @@ | ||
| 392 | 480 | |
| 393 | 481 | function openTagTOCPAGEBREAK($attr) { |
| 394 | 482 | if (isset($attr['NAME']) && $attr['NAME']) { $toc_id = strtolower($attr['NAME']); } else { $toc_id = 0; } |
| 395 | 483 | 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 | |
| 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'] = ''; } | |
| 397 | 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'] = ''; } |
| 398 | 488 | if (isset($attr['PAGING']) && (strtoupper($attr['PAGING'])=='OFF' || $attr['PAGING']==='0')) { $this->m_TOC[$toc_id]['TOCusePaging'] = false; } |
| 399 | 489 | else { $this->m_TOC[$toc_id]['TOCusePaging'] = true; } |
| 400 | 490 | if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $this->m_TOC[$toc_id]['TOCuseLinking'] = true; } |
| @@ -420,14 +510,8 @@ | ||
| 420 | 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; } |
| 421 | 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; } |
| 422 | 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; } |
| 423 | 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; } |
| 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 | 514 | if (isset($attr['TOC-PAGE-SELECTOR']) && $attr['TOC-PAGE-SELECTOR']) { $this->m_TOC[$toc_id]['TOC_page_selector'] = $attr['TOC-PAGE-SELECTOR']; } |
| 431 | 515 | else { $this->m_TOC[$toc_id]['TOC_page_selector'] = ''; } |
| 432 | 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'] = ''; } |
| 433 | 517 | |
| @@ -437,9 +521,11 @@ | ||
| 437 | 521 | |
| 438 | 522 | if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) { $this->m_TOC[$toc_id]['TOCbookmarkText'] = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'],ENT_QUOTES); } // *BOOKMARKS* |
| 439 | 523 | } |
| 440 | 524 | else { |
| 441 | - if (isset($attr['OUTDENT']) && $attr['OUTDENT']) { $this->TOCoutdent = $attr['OUTDENT']; } else { $this->TOCoutdent = ''; } // mPDF 5.6.19 | |
| 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 = ''; } | |
| 442 | 528 | if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) { $this->TOCorientation = $attr['TOC-ORIENTATION']; } else { $this->TOCorientation = ''; } |
| 443 | 529 | if (isset($attr['PAGING']) && (strtoupper($attr['PAGING'])=='OFF' || $attr['PAGING']==='0')) { $this->TOCusePaging = false; } |
| 444 | 530 | else { $this->TOCusePaging = true; } |
| 445 | 531 | if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $this->TOCuseLinking = true; } |
| @@ -461,9 +547,8 @@ | ||
| 461 | 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; } |
| 462 | 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; } |
| 463 | 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; } |
| 464 | 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; } |
| 465 | - | |
| 466 | 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; } |
| 467 | 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; } |
| 468 | 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; } |
| 469 | 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; } |
| @@ -468,15 +553,10 @@ | ||
| 468 | 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; } |
| 469 | 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; } |
| 470 | 555 | if (isset($attr['TOC-PAGE-SELECTOR']) && $attr['TOC-PAGE-SELECTOR']) { $this->TOC_page_selector = $attr['TOC-PAGE-SELECTOR']; } |
| 471 | 556 | 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 | 557 | if (isset($attr['TOC-SHEET-SIZE']) && $attr['TOC-SHEET-SIZE']) { $this->TOCsheetsize = $attr['TOC-SHEET-SIZE']; } else { $this->TOCsheetsize = ''; } |
| 558 | + | |
| 479 | 559 | |
| 480 | 560 | if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) { $this->TOCpreHTML = htmlspecialchars_decode($attr['TOC-PREHTML'],ENT_QUOTES); } |
| 481 | 561 | if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) { $this->TOCpostHTML = htmlspecialchars_decode($attr['TOC-POSTHTML'],ENT_QUOTES); } |
| 482 | 562 | if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) { $this->TOCbookmarkText = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'],ENT_QUOTES); } |