/** * Initialize the rendering */ function document_start() { global $ID; // Reset TOC. $this->toc = array(); // First, get export mode. $warning = ''; $this->mode = $this->config->load($warning); // Load and import CSS files, setup Units $this->load_css(); $this->setupUnits(); switch ($this->mode) { case 'ODT template': // Document based on ODT template. $this->docHandler = new ODTTemplateDH(); $this->docHandler->setTemplate($this->config->getParam('odt_template')); $this->docHandler->setDirectory($this->config->getParam('tpl_dir')); break; case 'CSS template': // Document based on DokuWiki CSS template. $this->docHandler = new CSSTemplateDH(); $media_sel = $this->config->getParam('media_sel'); $template = $this->config->getParam('odt_template'); $directory = $this->config->getParam('tpl_dir'); $template_path = $this->config->getParam('mediadir') . '/' . $directory . "/" . $template; $this->docHandler->import($template_path, $media_sel); break; default: // Document from scratch. $this->docHandler = new scratchDH(); break; } // Setup page format. $this->page = new pageFormat(); $this->setPageFormat($this->config->getParam('format'), $this->config->getParam('orientation'), $this->config->getParam('margin_top'), $this->config->getParam('margin_right'), $this->config->getParam('margin_bottom'), $this->config->getParam('margin_left')); // Set title in meta info. $this->meta->setTitle($ID); //FIXME article title != book title SOLUTION: overwrite at the end for book // If older or equal to 2007-06-26, we need to disable caching $dw_version = preg_replace('/[^\\d]/', '', getversion()); //FIXME DEPRECATED if (version_compare($dw_version, "20070626", "<=")) { $this->info["cache"] = false; } //$headers = array('Content-Type'=>'text/plain'); p_set_metadata($ID,array('format' => array('odt' => $headers) )); return ; // DEBUG // send the content type header, new method after 2007-06-26 (handles caching) $output_filename = str_replace(':', '-', $ID) . ".odt"; if (version_compare($dw_version, "20070626")) { // store the content type headers in metadata $headers = array('Content-Type' => 'application/vnd.oasis.opendocument.text', 'Content-Disposition' => 'attachment; filename="' . $output_filename . '";'); p_set_metadata($ID, array('format' => array('odt_page' => $headers))); } else { // older method FIXME DEPRECATED header('Content-Type: application/vnd.oasis.opendocument.text'); header('Content-Disposition: attachment; filename="' . $output_filename . '";'); } $this->set_page_bookmark($ID); $this->p_open(); }
/** * Initialize the rendering */ function document_start() { global $ID; // Reset TOC. $this->toc = array(); // First, get export mode. $warning = ''; $this->mode = $this->config->load($warning); //$this->config->setParam ($, $this->getConf('format')); //FIXME: output warning to document, like: /* // template chosen but not found : warn the user and use the default template $warning = '<text:p text:style-name="'.$this->styleset->getStyleName('body').'"><text:span text:style-name="'.$this->styleset->getStyleName('strong').'">' .$this->_xmlEntities( sprintf($this->getLang('tpl_not_found'),$this->config ['odt_template'],$this->getConf("tpl_dir")) ) .'</text:span></text:p>'.$this->doc;*/ // Load and import CSS files, setup Units $this->load_css(); $this->setupUnits(); switch ($this->mode) { case 'ODT template': // Document based on ODT template. $this->docHandler = new ODTTemplateDH(); $this->docHandler->setTemplate($this->config->getParam('odt_template')); $this->docHandler->setDirectory($this->config->getParam('tpl_dir')); break; default: // Document from scratch. $this->docHandler = new scratchDH(); break; } // Setup page format. $this->page = new pageFormat(); $this->setPageFormat($this->config->getParam('format'), $this->config->getParam('orientation'), $this->config->getParam('margin_top'), $this->config->getParam('margin_right'), $this->config->getParam('margin_bottom'), $this->config->getParam('margin_left')); //$this->page->setFormat('A4', 'portrait'); // Load Styleset. $this->styleset = new ODTDefaultStyles(); $this->styleset->import(); $this->autostyles = $this->styleset->getAutoStyles($this->page); $this->styles = $this->styleset->getStyles(); // Set title in meta info. $this->meta->setTitle($ID); //FIXME article title != book title SOLUTION: overwrite at the end for book // If older or equal to 2007-06-26, we need to disable caching $dw_version = preg_replace('/[^\\d]/', '', getversion()); //FIXME DEPRECATED if (version_compare($dw_version, "20070626", "<=")) { $this->info["cache"] = false; } //$headers = array('Content-Type'=>'text/plain'); p_set_metadata($ID,array('format' => array('odt' => $headers) )); return ; // DEBUG // send the content type header, new method after 2007-06-26 (handles caching) $output_filename = str_replace(':', '-', $ID) . ".odt"; if (version_compare($dw_version, "20070626")) { // store the content type headers in metadata $headers = array('Content-Type' => 'application/vnd.oasis.opendocument.text', 'Content-Disposition' => 'attachment; filename="' . $output_filename . '";'); p_set_metadata($ID, array('format' => array('odt_page' => $headers))); } else { // older method FIXME DEPRECATED header('Content-Type: application/vnd.oasis.opendocument.text'); header('Content-Disposition: attachment; filename="' . $output_filename . '";'); } $this->set_page_bookmark($ID); }