private function reporteTBSOO($informe) { define('BASE', sfConfig::get('sf_app_module_dir') . '/informes/lib/'); require_once BASE . 'tbs_class_php5.php'; require_once BASE . 'tbsooo_class.php'; $OOo = new clsTinyButStrongOOo(); $OOo->noErr = true; $OOo->SetZipBinary('zip'); $OOo->SetUnzipBinary('unzip'); $OOo->SetProcessDir(sfConfig::get('sf_informe_dir')); $OOo->SetDataCharset('UTF8'); $OOo->NewDocFromTpl(sfConfig::get('sf_informe_dir') . DIRECTORY_SEPARATOR . $informe->getAdjunto()->getRuta()); $OOo->LoadXmlFromDoc('content.xml'); $aVariable = $this->leerTemplate($OOo->Source); $aDato = array(); //busco en las variables encontradas en el template y reemplaza contenido $aDato = $this->llenarVariables($aVariable); //agregando datos del registro informe $aDato['informe'] = $informe->toArray(); // variables adicionales dinamicas de los formulario if ($informe->getVariables()) { $aDato['variable'] = array(); $variables = explode(";", $informe->getVariables()); foreach ($variables as $variable) { $pos = stripos($variable, ":"); if ($pos) { $variable = substr($variable, 0, $pos); } $aDato['variable'] = array_merge($aDato['variable'], array($variable => $this->getRequestParameter($variable))); } } // lleno finalmente de diferente forma si es un array (ciclo) o no (variable comun) if (is_array($aDato)) { foreach ($aDato as $idx => $dato) { if ($this->isNotAssocArray($dato)) { $OOo->MergeBlock($idx, "array", $dato); } else { $OOo->MergeField($idx, $dato); } } } $OOo->SaveXmlToDoc(); // OJO hay headers locos para que funcione en internet explorer header('Content-type: ' . $OOo->GetMimetypeDoc()); //header("Content-Type: application/force-download"); //para que funcione en konqueror header("Cache-Control: public, must-revalidate"); header("Pragma: hack"); header('Content-Length: ' . filesize($OOo->GetPathnameDoc())); header('Content-Disposition: attachment; filename="informe' . $informe->getNombre() . '.odt"'); header("Content-Transfer-Encoding: binary"); $OOo->FlushDoc(); $OOo->RemoveDoc(); }
<?php include_once '../tbs_class.php'; include_once '../tbsooo_class.php'; // datas $x = 'Hello World'; $d = '2005-10-04'; $n = 0.1234; // instantiate a TBS OOo class $OOo = new clsTinyButStrongOOo(); // setting the object $OOo->SetZipBinary('zip'); $OOo->SetUnzipBinary('unzip'); $OOo->SetProcessDir('tmp/'); $OOo->SetDataCharset('UTF8'); // create a new openoffice document from the template with an unique id $OOo->NewDocFromTpl('charset_utf8.sxw'); // merge data with openoffice file named 'content.xml' $OOo->LoadXmlFromDoc('content.xml'); $OOo->SaveXmlToDoc(); // display header('Content-type: ' . $OOo->GetMimetypeDoc()); header('Content-Length: ' . filesize($OOo->GetPathnameDoc())); $OOo->FlushDoc(); $OOo->RemoveDoc();