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'; // instantiate a TBS OOo class $OOo = new clsTinyButStrongOOo(); // setting the object $OOo->SetZipBinary('zip'); $OOo->SetUnzipBinary('unzip'); $OOo->SetProcessDir('tmp/'); // create a new openoffice document from the template with an unique id $OOo->NewDocFromTpl('tbsooo_us_examples_hello.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();
// setting the object $OOo->SetProcessDir($nom_dossier_temporaire ); //dossier où se fait le traitement (décompression / traitement / compression) // create a new openoffice document from the template with an unique id //$OOo->createFrom($nom_dossier_modele_a_utiliser.$nom_fichier_modele_ooo); // le chemin du fichier est indiqué à partir de l'emplacement de ce fichier // create a new openoffice document from the template with an unique id $OOo->NewDocFromTpl($nom_dossier_modele_a_utiliser.$nom_fichier_modele_ooo); // le chemin du fichier est indiqué à partir de l'emplacement de ce fichier // merge data with openoffice file named 'content.xml' //$OOo->loadXml($nom_fichier_xml_a_traiter); //Le fichier qui contient les variables et doit être parsé (il sera extrait) $OOo->LoadXmlFromDoc($nom_fichier_xml_a_traiter); //Le fichier qui contient les variables et doit être parsé (il sera extrait) // Traitement des tableaux // On insère ici les lignes concernant la gestion des tableaux $OOo->MergeBlock('eleves',$tab_eleves_OOo); $OOo->SaveXmlToDoc(); //traitement du fichier extrait //Génération du nom du fichier $now = gmdate('d_M_Y_H:i:s'); $nom_fichier_modele = explode('.',$nom_fichier_modele_ooo); $nom_fic = $nom_fichier_modele[0]."_".$now.".".$nom_fichier_modele[1]; /* header('Expires: ' . $now); if (my_ereg('MSIE', $_SERVER['HTTP_USER_AGENT'])) { header('Content-Disposition: inline; filename="' . $nom_fic . '"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Content-Disposition: attachment; filename="' . $nom_fic . '"'); header('Pragma: no-cache');
function export2odt($template_full_path, $template_mime_type, $data, $display, $save_path=""){ $data_vars = $data["data_vars"]; $data_blocks = $data["data_blocks"]; // instantiate a TBS OOo class $OOo = new clsTinyButStrongOOo; // setting the object if ($OOo->SetZipBinary('zip', true) == false) { // erreur zip non présent } if ($OOo->SetUnzipBinary('unzip', true) == false) { // erreur unzip non présent } if ($OOo->SetProcessDir('/tmp/') == false) { // erreur /tmp inaccessible } // create a new openoffice document from the template with an unique id $OOo->NewDocFromTpl($template_full_path); // merge data with OOo file content.xml $OOo->LoadXmlFromDoc('content.xml'); // load Data foreach($data_vars as $key => $value){ $GLOBALS[$key] = $value; } // Merge Data foreach ($data_blocks as $key => $value) { $OOo->MergeBlock($key, $value); } $OOo->SaveXmlToDoc(); if ($display){ if ($template_mime_type == "") $template_mime_type = $OOo->GetMimetypeDoc(); if ($template_mime_type == "") $template_mime_type = "sxw"; header('Content-type: '.$template_mime_type); header('Content-Length: '.filesize($OOo->GetPathnameDoc())); header('Content-Disposition: inline; filename=cv.'.$template_mime_type); $OOo->FlushDoc(); $OOo->RemoveDoc(); } else { if ($save_path != "") { rename($OOo->GetPathnameDoc(), $save_path); // affichage des document sauvés ????? } } }
$Mes=$io_funsob->uf_convertir_numeromes($Mes); $Ano=date("Y"); $Fecha=date("d/m/Y"); // setting the object $OOo->SetZipBinary('zip'); $OOo->SetUnzipBinary('unzip'); $OOo->SetProcessDir('tmp/'); // create a new openoffice document from the template with an unique id $lb_valido=$OOo->NewDocFromTpl($ls_ruta); //merge data with openoffice file named 'content.xml' $OOo->LoadXmlFromDoc('content.xml',$ls_ruta); if(is_array($la_condiciones)) $OOo->MergeBlock('tblCondicionPago',$la_condiciones); if(is_array($la_retenciones)) $OOo->MergeBlock('tblRetenciones',$la_retenciones); if(is_array($la_garantias)) $OOo->MergeBlock('tblGarantias',$la_garantias); $OOo->SaveXmlToDoc($ls_ruta); // display header('Content-type: '.$OOo->GetMimetypeDoc()); header('Content-Length: '.filesize($OOo->GetPathnameDoc())); $OOo->FlushDoc(); $OOo->RemoveDoc(); ?>
$MotivoSuspension=$la_acta["motact"]; $Observacion=$la_acta["obsact"]; //--------------------------Datos Generales--------------------------------------------// $Dia=date("d"); $Mes=date("m"); $Mes=$io_funsob->uf_convertir_numeromes($Mes); $Ano=date("Y"); $Fecha=date("d/m/Y"); // setting the object $OOo->SetZipBinary('zip'); $OOo->SetUnzipBinary('unzip'); $OOo->SetProcessDir('tmp/'); // create a new openoffice document from the template with an unique id $lb_valido=$OOo->NewDocFromTpl($ls_ruta); //merge data with openoffice file named 'content.xml' $lb_valido=$OOo->LoadXmlFromDoc('content.xml',$ls_ruta); $lb_valido=$OOo->SaveXmlToDoc($ls_ruta); // display header('Content-type: '.$OOo->GetMimetypeDoc()); header('Content-Length: '.filesize($OOo->GetPathnameDoc())); $OOo->FlushDoc(); $OOo->RemoveDoc(); ?>