1<?php 2/** 3 * dw2Pdf Plugin: Conversion from dokuwiki content to pdf. 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Luigi Micco <l.micco@tiscali.it> 7 * @author Andreas Gohr <andi@splitbrain.org> 8 */ 9 10// must be run within Dokuwiki 11if(!defined('DOKU_INC')) die(); 12 13/** 14 * Class action_plugin_dw2pdf 15 * 16 * Export hmtl content to pdf, for different url parameter configurations 17 * DokuPDF which extends mPDF is used for generating the pdf from html. 18 */ 19class action_plugin_dw2pdf extends DokuWiki_Action_Plugin { 20 /** 21 * Settings for current export, collected from url param, plugin config, global config 22 * 23 * @var array 24 */ 25 protected $exportConfig = null; 26 protected $tpl; 27 protected $list = array(); 28 29 /** 30 * Constructor. Sets the correct template 31 */ 32 public function __construct() { 33 $this->tpl = $this->getExportConfig('template'); 34 } 35 36 /** 37 * Register the events 38 */ 39 public function register(Doku_Event_Handler $controller) { 40 $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'convert', array()); 41 $controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'addbutton', array()); 42 } 43 44 /** 45 * Do the HTML to PDF conversion work 46 * 47 * @param Doku_Event $event 48 * @param array $param 49 * @return bool 50 */ 51 public function convert(Doku_Event $event, $param) { 52 global $ACT; 53 global $REV; 54 global $ID; 55 56 // our event? 57 if(($ACT != 'export_pdfbook') && ($ACT != 'export_pdf') && ($ACT != 'export_pdfns')) return false; 58 59 // check user's rights 60 if(auth_quickaclcheck($ID) < AUTH_READ) return false; 61 62 if($data = $this->collectExportPages($event)) { 63 list($title, $this->list) = $data; 64 } else { 65 return false; 66 } 67 68 // it's ours, no one else's 69 $event->preventDefault(); 70 71 // prepare cache 72 $cachekey = join(',', $this->list) 73 . $REV 74 . $this->getExportConfig('template') 75 . $this->getExportConfig('pagesize') 76 . $this->getExportConfig('orientation') 77 . $this->getExportConfig('doublesided') 78 . ($this->getExportConfig('hasToC') ? join('-', $this->getExportConfig('levels')) : '0') 79 . $title; 80 $cache = new cache($cachekey, '.dw2.pdf'); 81 82 $depends['files'] = array_map('wikiFN', $this->list); 83 $depends['files'][] = __FILE__; 84 $depends['files'][] = dirname(__FILE__) . '/renderer.php'; 85 $depends['files'][] = dirname(__FILE__) . '/mpdf/mpdf.php'; 86 $depends['files'] = array_merge($depends['files'], getConfigFiles('main')); 87 88 // hard work only when no cache available 89 if(!$this->getConf('usecache') || !$cache->useCache($depends)) { 90 $this->generatePDF($cache->cache, $title); 91 } 92 93 // deliver the file 94 $this->sendPDFFile($cache->cache, $title); 95 return true; 96 } 97 98 99 /** 100 * Obtain list of pages and title, based on url parameters 101 * 102 * @param Doku_Event $event 103 * @return string|bool 104 */ 105 protected function collectExportPages(Doku_Event $event) { 106 global $ACT; 107 global $ID; 108 global $INPUT; 109 global $conf; 110 111 // list of one or multiple pages 112 $list = array(); 113 114 if($ACT == 'export_pdf') { 115 $list[0] = $ID; 116 $title = $INPUT->str('pdftitle'); 117 if(!$title) { 118 $title = p_get_first_heading($ID); 119 } 120 121 } elseif($ACT == 'export_pdfns') { 122 //check input for title and ns 123 if(!$title = $INPUT->str('pdfns_title')) { 124 $this->showPageWithErrorMsg($event, 'needtitle'); 125 return false; 126 } 127 $pdfnamespace = cleanID($INPUT->str('pdfns_ns')); 128 if(!@is_dir(dirname(wikiFN($pdfnamespace . ':dummy')))) { 129 $this->showPageWithErrorMsg($event, 'needns'); 130 return false; 131 } 132 133 //sort order 134 $order = $INPUT->str('pdfns_order', 'natural', true); 135 $sortoptions = array('pagename', 'date', 'natural'); 136 if(!in_array($order, $sortoptions)) { 137 $order = 'natural'; 138 } 139 140 //search depth 141 $depth = $INPUT->int('pdfns_depth', 0); 142 if($depth < 0) { 143 $depth = 0; 144 } 145 146 //page search 147 $result = array(); 148 $opts = array('depth' => $depth); //recursive all levels 149 $dir = utf8_encodeFN(str_replace(':', '/', $pdfnamespace)); 150 search($result, $conf['datadir'], 'search_allpages', $opts, $dir); 151 152 //sorting 153 if(count($result) > 0) { 154 if($order == 'date') { 155 usort($result, array($this, '_datesort')); 156 } elseif($order == 'pagename') { 157 usort($result, array($this, '_pagenamesort')); 158 } 159 } 160 161 foreach($result as $item) { 162 $list[] = $item['id']; 163 } 164 165 } elseif(isset($_COOKIE['list-pagelist']) && !empty($_COOKIE['list-pagelist'])) { 166 //is in Bookmanager of bookcreator plugin a title given? 167 if(!$title = $INPUT->str('pdfbook_title')) { 168 $this->showPageWithErrorMsg($event, 'needtitle'); 169 return false; 170 } else { 171 $list = explode("|", $_COOKIE['list-pagelist']); 172 } 173 174 } else { 175 //show empty bookcreator message 176 $this->showPageWithErrorMsg($event, 'empty'); 177 return false; 178 } 179 180 return array($title, $list); 181 } 182 183 184 /** 185 * Set error notification and reload page again 186 * 187 * @param Doku_Event $event 188 * @param string $msglangkey key of translation key 189 */ 190 private function showPageWithErrorMsg(Doku_Event $event, $msglangkey) { 191 msg($this->getLang($msglangkey), -1); 192 193 $event->data = 'show'; 194 $_SERVER['REQUEST_METHOD'] = 'POST'; //clears url 195 } 196 197 /** 198 * Build a pdf from the html 199 * 200 * @param string $cachefile 201 * @param string $title 202 */ 203 protected function generatePDF($cachefile, $title) { 204 global $ID; 205 global $REV; 206 global $INPUT; 207 208 //some shortcuts to export settings 209 $hasToC = $this->getExportConfig('hasToC'); 210 $levels = $this->getExportConfig('levels'); 211 $isDebug = $this->getExportConfig('isDebug'); 212 213 // initialize PDF library 214 require_once(dirname(__FILE__) . "/DokuPDF.class.php"); 215 216 $mpdf = new DokuPDF($this->getExportConfig('pagesize'), $this->getExportConfig('orientation')); 217 218 // let mpdf fix local links 219 $self = parse_url(DOKU_URL); 220 $url = $self['scheme'] . '://' . $self['host']; 221 if($self['port']) { 222 $url .= ':' . $self['port']; 223 } 224 $mpdf->setBasePath($url); 225 226 // Set the title 227 $mpdf->SetTitle($title); 228 229 // some default document settings 230 //note: double-sided document, starts at an odd page (first page is a right-hand side page) 231 // single-side document has only odd pages 232 $mpdf->mirrorMargins = $this->getExportConfig('doublesided'); 233 $mpdf->useOddEven = $this->getExportConfig('doublesided'); //duplicate of mirrorMargins 234 $mpdf->setAutoTopMargin = 'stretch'; 235 $mpdf->setAutoBottomMargin = 'stretch'; 236// $mpdf->pagenumSuffix = '/'; //prefix for {nbpg} 237 if($hasToC) { 238 $mpdf->PageNumSubstitutions[] = array('from' => 1, 'reset' => 0, 'type' => 'i', 'suppress' => 'off'); //use italic pageno until ToC 239 $mpdf->h2toc = $levels; 240 } else { 241 $mpdf->PageNumSubstitutions[] = array('from' => 1, 'reset' => 0, 'type' => '1', 'suppress' => 'off'); 242 } 243 244 // load the template 245 $template = $this->load_template($title); 246 247 // prepare HTML header styles 248 $html = ''; 249 if($isDebug) { 250 $html .= '<html><head>'; 251 $html .= '<style type="text/css">'; 252 } 253 $styles = $this->load_css(); 254 $styles .= '@page { size:auto; ' . $template['page'] . '}'; 255 $styles .= '@page :first {' . $template['first'] . '}'; 256 $mpdf->WriteHTML($styles, 1); 257 258 if($isDebug) { 259 $html .= $styles; 260 $html .= '</style>'; 261 $html .= '</head><body>'; 262 } 263 264 $body_start = $template['html']; 265 $body_start .= '<div class="dokuwiki">'; 266 267 // insert the cover page 268 $body_start .= $template['cover']; 269 270 $mpdf->WriteHTML($body_start, 2, true, false); //start body html 271 if($isDebug) { 272 $html .= $body_start; 273 } 274 if($hasToC) { 275 //Note: - for double-sided document the ToC is always on an even number of pages, so that the following content is on a correct odd/even page 276 // - first page of ToC starts always at odd page (so eventually an additional blank page is included before) 277 // - there is no page numbering at the pages of the ToC 278 $mpdf->TOCpagebreakByArray( 279 array( 280 'toc-preHTML' => '<h2>Table of contents</h2>', 281 'toc-bookmarkText' => 'Table of Content', 282 'links' => true, 283 'outdent' => '1em', 284 'resetpagenum' => true, //start pagenumbering after ToC 285 'pagenumstyle' => '1' 286 ) 287 ); 288 $html .= '<tocpagebreak>'; 289 } 290 291 // store original pageid 292 $keep = $ID; 293 294 // loop over all pages 295 $cnt = count($this->list); 296 for($n = 0; $n < $cnt; $n++) { 297 $page = $this->list[$n]; 298 299 // set global pageid to the rendered page 300 $ID = $page; 301 302 $pagehtml = p_cached_output(wikiFN($page, $REV), 'dw2pdf', $page); 303 $pagehtml .= $this->page_depend_replacements($template['cite'], cleanID($page)); 304 if($n < ($cnt - 1)) { 305 $pagehtml .= '<pagebreak />'; 306 } 307 308 $mpdf->WriteHTML($pagehtml, 2, false, false); //intermediate body html 309 if($isDebug) { 310 $html .= $pagehtml; 311 } 312 } 313 //restore ID 314 $ID = $keep; 315 316 // insert the back page 317 $body_end = $template['back']; 318 319 $body_end .= '</div>'; 320 321 $mpdf->WriteHTML($body_end, 2, false, true); // finish body html 322 if($isDebug) { 323 $html .= $body_end; 324 $html .= '</body>'; 325 $html .= '</html>'; 326 } 327 328 //Return html for debugging 329 if($isDebug) { 330 if($INPUT->str('debughtml', 'text', true) == 'html') { 331 echo $html; 332 } else { 333 header('Content-Type: text/plain; charset=utf-8'); 334 echo $html; 335 } 336 exit(); 337 }; 338 339 // write to cache file 340 $mpdf->Output($cachefile, 'F'); 341 } 342 343 /** 344 * @param string $cachefile 345 * @param string $title 346 */ 347 protected function sendPDFFile($cachefile, $title) { 348 header('Content-Type: application/pdf'); 349 header('Cache-Control: must-revalidate, no-transform, post-check=0, pre-check=0'); 350 header('Pragma: public'); 351 http_conditionalRequest(filemtime($cachefile)); 352 353 $filename = rawurlencode(cleanID(strtr($title, ':/;"', ' '))); 354 if($this->getConf('output') == 'file') { 355 header('Content-Disposition: attachment; filename="' . $filename . '.pdf";'); 356 } else { 357 header('Content-Disposition: inline; filename="' . $filename . '.pdf";'); 358 } 359 360 //try to send file, and exit if done 361 http_sendfile($cachefile); 362 363 $fp = @fopen($cachefile, "rb"); 364 if($fp) { 365 http_rangeRequest($fp, filesize($cachefile), 'application/pdf'); 366 } else { 367 header("HTTP/1.0 500 Internal Server Error"); 368 print "Could not read file - bad permissions?"; 369 } 370 exit(); 371 } 372 373 /** 374 * Load the various template files and prepare the HTML/CSS for insertion 375 */ 376 protected function load_template($title) { 377 global $ID; 378 global $conf; 379 380 // this is what we'll return 381 $output = array( 382 'cover' => '', 383 'html' => '', 384 'page' => '', 385 'first' => '', 386 'cite' => '', 387 ); 388 389 // prepare header/footer elements 390 $html = ''; 391 foreach(array('header', 'footer') as $section) { 392 foreach(array('', '_odd', '_even', '_first') as $order) { 393 $file = DOKU_PLUGIN . 'dw2pdf/tpl/' . $this->tpl . '/' . $section . $order . '.html'; 394 if(file_exists($file)) { 395 $html .= '<htmlpage' . $section . ' name="' . $section . $order . '">' . DOKU_LF; 396 $html .= file_get_contents($file) . DOKU_LF; 397 $html .= '</htmlpage' . $section . '>' . DOKU_LF; 398 399 // register the needed pseudo CSS 400 if($order == '_first') { 401 $output['first'] .= $section . ': html_' . $section . $order . ';' . DOKU_LF; 402 } elseif($order == '_even') { 403 $output['page'] .= 'even-' . $section . '-name: html_' . $section . $order . ';' . DOKU_LF; 404 } elseif($order == '_odd') { 405 $output['page'] .= 'odd-' . $section . '-name: html_' . $section . $order . ';' . DOKU_LF; 406 } else { 407 $output['page'] .= $section . ': html_' . $section . $order . ';' . DOKU_LF; 408 } 409 } 410 } 411 } 412 413 // prepare replacements 414 $replace = array( 415 '@PAGE@' => '{PAGENO}', 416 '@PAGES@' => '{nbpg}', //see also $mpdf->pagenumSuffix = ' / ' 417 '@TITLE@' => hsc($title), 418 '@WIKI@' => $conf['title'], 419 '@WIKIURL@' => DOKU_URL, 420 '@DATE@' => dformat(time()), 421 '@BASE@' => DOKU_BASE, 422 '@TPLBASE@' => DOKU_BASE . 'lib/plugins/dw2pdf/tpl/' . $this->tpl . '/' 423 ); 424 425 // set HTML element 426 $html = str_replace(array_keys($replace), array_values($replace), $html); 427 //TODO For bookcreator $ID (= bookmanager page) makes no sense 428 $output['html'] = $this->page_depend_replacements($html, $ID); 429 430 // cover page 431 $coverfile = DOKU_PLUGIN . 'dw2pdf/tpl/' . $this->tpl . '/cover.html'; 432 if(file_exists($coverfile)) { 433 $output['cover'] = file_get_contents($coverfile); 434 $output['cover'] = str_replace(array_keys($replace), array_values($replace), $output['cover']); 435 $output['cover'] .= '<pagebreak />'; 436 } 437 438 // cover page 439 $backfile = DOKU_PLUGIN . 'dw2pdf/tpl/' . $this->tpl . '/back.html'; 440 if(file_exists($backfile)) { 441 $output['back'] = '<pagebreak />'; 442 $output['back'] .= file_get_contents($backfile); 443 $output['back'] = str_replace(array_keys($replace), array_values($replace), $output['back']); 444 } 445 446 // citation box 447 $citationfile = DOKU_PLUGIN . 'dw2pdf/tpl/' . $this->tpl . '/citation.html'; 448 if(file_exists($citationfile)) { 449 $output['cite'] = file_get_contents($citationfile); 450 $output['cite'] = str_replace(array_keys($replace), array_values($replace), $output['cite']); 451 } 452 453 return $output; 454 } 455 456 /** 457 * @param string $raw code with placeholders 458 * @param string $id pageid 459 * @return string 460 */ 461 protected function page_depend_replacements($raw, $id) { 462 global $REV; 463 464 // generate qr code for this page using google infographics api 465 $qr_code = ''; 466 if($this->getConf('qrcodesize')) { 467 $url = urlencode(wl($id, '', '&', true)); 468 $qr_code = '<img src="https://chart.googleapis.com/chart?chs=' . 469 $this->getConf('qrcodesize') . '&cht=qr&chl=' . $url . '" />'; 470 } 471 // prepare replacements 472 $replace['@ID@'] = $id; 473 $replace['@UPDATE@'] = dformat(filemtime(wikiFN($id, $REV))); 474 $replace['@PAGEURL@'] = wl($id, ($REV) ? array('rev' => $REV) : false, true, "&"); 475 $replace['@QRCODE@'] = $qr_code; 476 477 return str_replace(array_keys($replace), array_values($replace), $raw); 478 } 479 480 /** 481 * Load all the style sheets and apply the needed replacements 482 */ 483 protected function load_css() { 484 global $conf; 485 //reusue the CSS dispatcher functions without triggering the main function 486 define('SIMPLE_TEST', 1); 487 require_once(DOKU_INC . 'lib/exe/css.php'); 488 489 // prepare CSS files 490 $files = array_merge( 491 array( 492 DOKU_INC . 'lib/styles/screen.css' 493 => DOKU_BASE . 'lib/styles/', 494 DOKU_INC . 'lib/styles/print.css' 495 => DOKU_BASE . 'lib/styles/', 496 ), 497 css_pluginstyles('all'), 498 $this->css_pluginPDFstyles(), 499 array( 500 DOKU_PLUGIN . 'dw2pdf/conf/style.css' 501 => DOKU_BASE . 'lib/plugins/dw2pdf/conf/', 502 DOKU_PLUGIN . 'dw2pdf/tpl/' . $this->tpl . '/style.css' 503 => DOKU_BASE . 'lib/plugins/dw2pdf/tpl/' . $this->tpl . '/', 504 DOKU_PLUGIN . 'dw2pdf/conf/style.local.css' 505 => DOKU_BASE . 'lib/plugins/dw2pdf/conf/', 506 ) 507 ); 508 $css = ''; 509 foreach($files as $file => $location) { 510 $display = str_replace(fullpath(DOKU_INC), '', fullpath($file)); 511 $css .= "\n/* XXXXXXXXX $display XXXXXXXXX */\n"; 512 $css .= css_loadfile($file, $location); 513 } 514 515 if(function_exists('css_parseless')) { 516 // apply pattern replacements 517 $styleini = css_styleini($conf['template']); 518 $css = css_applystyle($css, $styleini['replacements']); 519 520 // parse less 521 $css = css_parseless($css); 522 } else { 523 // @deprecated 2013-12-19: fix backward compatibility 524 $css = css_applystyle($css, DOKU_INC . 'lib/tpl/' . $conf['template'] . '/'); 525 } 526 527 return $css; 528 } 529 530 /** 531 * Returns a list of possible Plugin PDF Styles 532 * 533 * Checks for a pdf.css, falls back to print.css 534 * 535 * @author Andreas Gohr <andi@splitbrain.org> 536 */ 537 protected function css_pluginPDFstyles() { 538 $list = array(); 539 $plugins = plugin_list(); 540 541 $usestyle = explode(',', $this->getConf('usestyles')); 542 foreach($plugins as $p) { 543 if(in_array($p, $usestyle)) { 544 $list[DOKU_PLUGIN . "$p/screen.css"] = DOKU_BASE . "lib/plugins/$p/"; 545 $list[DOKU_PLUGIN . "$p/style.css"] = DOKU_BASE . "lib/plugins/$p/"; 546 } 547 548 if(file_exists(DOKU_PLUGIN . "$p/pdf.css")) { 549 $list[DOKU_PLUGIN . "$p/pdf.css"] = DOKU_BASE . "lib/plugins/$p/"; 550 } else { 551 $list[DOKU_PLUGIN . "$p/print.css"] = DOKU_BASE . "lib/plugins/$p/"; 552 } 553 } 554 return $list; 555 } 556 557 /** 558 * Returns array of pages which will be included in the exported pdf 559 * 560 * @return array 561 */ 562 public function getExportedPages() { 563 return $this->list; 564 } 565 566 /** 567 * usort callback to sort by file lastmodified time 568 */ 569 public function _datesort($a, $b) { 570 if($b['rev'] < $a['rev']) return -1; 571 if($b['rev'] > $a['rev']) return 1; 572 return strcmp($b['id'], $a['id']); 573 } 574 575 /** 576 * usort callback to sort by page id 577 */ 578 public function _pagenamesort($a, $b) { 579 if($a['id'] <= $b['id']) return -1; 580 if($a['id'] > $b['id']) return 1; 581 return 0; 582 } 583 584 /** 585 * Return settings read from: 586 * 1. url parameters 587 * 2. plugin config 588 * 3. global config 589 * 590 * @return array 591 */ 592 protected function loadExportConfig() { 593 global $INPUT; 594 global $conf; 595 596 $this->exportConfig = array(); 597 598 // decide on the paper setup from param or config 599 $this->exportConfig['pagesize'] = $INPUT->str('pagesize', $this->getConf('pagesize'), true); 600 $this->exportConfig['orientation'] = $INPUT->str('orientation', $this->getConf('orientation'), true); 601 602 $doublesided = $INPUT->bool('doublesided', (bool) $this->getConf('doublesided')); 603 $this->exportConfig['doublesided'] = $doublesided ? '1' : '0'; 604 605 $hasToC = $INPUT->bool('toc', (bool) $this->getConf('toc')); 606 $levels = array(); 607 if($hasToC) { 608 $toclevels = $INPUT->str('toclevels', $this->getConf('toclevels'), true); 609 list($top_input, $max_input) = explode('-', $toclevels, 2); 610 list($top_conf, $max_conf) = explode('-', $this->getConf('toclevels'), 2); 611 $bounds_input = array( 612 'top' => array( 613 (int) $top_input, 614 (int) $top_conf 615 ), 616 'max' => array( 617 (int) $max_input, 618 (int) $max_conf 619 ) 620 ); 621 $bounds = array( 622 'top' => $conf['toptoclevel'], 623 'max' => $conf['maxtoclevel'] 624 625 ); 626 foreach($bounds_input as $bound => $values) { 627 foreach($values as $value) { 628 if($value > 0 && $value <= 5) { 629 //stop at valid value and store 630 $bounds[$bound] = $value; 631 break; 632 } 633 } 634 } 635 636 if($bounds['max'] < $bounds['top']) { 637 $bounds['max'] = $bounds['top']; 638 } 639 640 for($level = $bounds['top']; $level <= $bounds['max']; $level++) { 641 $levels["H$level"] = $level - 1; 642 } 643 } 644 $this->exportConfig['hasToC'] = $hasToC; 645 $this->exportConfig['levels'] = $levels; 646 647 $this->exportConfig['maxbookmarks'] = $INPUT->int('maxbookmarks', $this->getConf('maxbookmarks'), true); 648 649 $tplconf = $this->getConf('template'); 650 $tpl = $INPUT->str('template', $tplconf, true); 651 if(!is_dir(DOKU_PLUGIN . 'dw2pdf/tpl/' . $tpl)) { 652 $tpl = $tplconf; 653 } 654 if(!$tpl){ 655 $tpl = 'default'; 656 } 657 $this->exportConfig['template'] = $tpl; 658 659 $this->exportConfig['isDebug'] = $conf['allowdebug'] && $INPUT->has('debughtml'); 660 } 661 662 /** 663 * Returns requested config 664 * 665 * @param string $name 666 * @param mixed $notset 667 * @return mixed|bool 668 */ 669 public function getExportConfig($name, $notset = false) { 670 if ($this->exportConfig === null){ 671 $this->loadExportConfig(); 672 } 673 674 if(isset($this->exportConfig[$name])){ 675 return $this->exportConfig[$name]; 676 }else{ 677 return $notset; 678 } 679 } 680 681 /** 682 * Add 'export pdf'-button to pagetools 683 * 684 * @param Doku_Event $event 685 * @param mixed $param not defined 686 */ 687 public function addbutton(Doku_Event $event, $param) { 688 global $ID, $REV; 689 690 if($this->getConf('showexportbutton') && $event->data['view'] == 'main') { 691 $params = array('do' => 'export_pdf'); 692 if($REV) { 693 $params['rev'] = $REV; 694 } 695 696 // insert button at position before last (up to top) 697 $event->data['items'] = array_slice($event->data['items'], 0, -1, true) + 698 array('export_pdf' => 699 '<li>' 700 . '<a href=' . wl($ID, $params) . ' class="action export_pdf" rel="nofollow" title="' . $this->getLang('export_pdf_button') . '">' 701 . '<span>' . $this->getLang('export_pdf_button') . '</span>' 702 . '</a>' 703 . '</li>' 704 ) + 705 array_slice($event->data['items'], -1, 1, true); 706 } 707 } 708} 709