Exemplo n.º 1
0
 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();
<?php

include_once '../tbs_class.php';
include_once '../tbsooo_class.php';
// datas
$country = array('France', 'England', 'Spain', 'Italy', 'Germany');
// 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_blocks.sxw');
// merge data with openoffice file named 'content.xml'
$OOo->LoadXmlFromDoc('content.xml');
$OOo->MergeBlock('blk1', $country);
$OOo->MergeBlock('blk2', $country);
$OOo->MergeBlock('blk3', $country);
$OOo->MergeBlock('blk4', $country);
$OOo->MergeBlock('blk5', $country);
$OOo->SaveXmlToDoc();
// display
header('Content-type: ' . $OOo->GetMimetypeDoc());
header('Content-Length: ' . filesize($OOo->GetPathnameDoc()));
$OOo->FlushDoc(true);
$OOo->DeleteDoc();
Exemplo n.º 4
0
	header('Pragma: public');
}
else {
	header('Content-Disposition: attachment; filename="' . $nom_fic . '"');
	header('Pragma: no-cache');
}
// display
*/
send_file_download_headers($OOo->GetMimetypeDoc(), $nom_fic, 'attachment');
//header('Content-type: '.$OOo->GetMimetypeDoc());
//header('Content-type: '.$OOo->getMimetype());
header('Content-Length: '.filesize($OOo->GetPathnameDoc()));
//header('Content-Length: '.filesize($OOo->GetPathname()));


$OOo->FlushDoc(); //envoi du fichier traité
$OOo->RemoveDoc(); //suppression des fichiers de travail

//$OOo->sendResponse(); //envoi du fichier traité
$OOo->remove(); //suppression des fichiers de travail
// Fin de traitement des tableaux
$OOo->close();

//=======================================
// FIN AFFICHAGE DES DONNÉES
//=======================================



?>
Exemplo n.º 5
0
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 ?????
    }
  }
}