The Zip and Unzip binaries are required on server to extract/update XML files of OpenOffice documents with the class.
The default values in class for the binaries path are set to 'zip' and 'unzip'.
By the way, the server environment var 'path' could be set where the binary are installed to have the same setting for Linux and DOS environment and leave the default value.
On Linux, the typical path where ZIP and UNZIP are installed are '/usr/bin/zip' and '/usr/bin/unzip'.
On Win32, install ZIP and UNZIP from info-zip, by example to 'c:\program files\bin\zip.exe' and 'c:\program files\bin\unzip.exe' and add to the PATH environment var the following path: Set PATH=c:\program files\bin;%PATH%
Ask your administrator for assistance.
The process directory is required to generate new OpenOffice documents. All the operations (extract, merge, ...) are made in this directory with a unique name.
This directory had to be writable for the PHP script (usually the Apache user).
The default value in class is set to 'tmp/' relative to the PHP scripts.
Otherwise you can use the 'tmp' system directory by example :
OpenOffice is required on client side to create templates and to visualize result after processing.
To know more on the OpenOffice file format, go to the tips section.
<?
include_once('tbs_class.php');
include_once('tbsooo_class.php');
// data
$x = 'Hello World';
// instantiate a TBS OOo class
$OOo = new clsTinyButStrongOOo;
// setting the object
$OOo->SetZipBinary('zip');
$OOo->SetUnzipBinary('unzip');
$OOo->SetProcessDir('tmp/');
$OOo->SetDataCharset('ISO 8859-1');
// create a new openoffice document from the template with an unique id
$OOo->NewDocFromTpl('hello.sxw');
// merge data with OOo file content.xml
$OOo->LoadXmlFromDoc('content.xml');
$OOo->SaveXmlToDoc();
// display
header('Content-type: '.$OOo->GetMimetypeDoc());
header('Content-Length: '.filesize($OOo->GetPathnameDoc()));
$OOo->FlushDoc();
$OOo->RemoveDoc();
?>
Before everything, install OpenOffice on your machine to visualize these examples.
| HTML tags | OOo XML tags | |
|---|---|---|
| table | <table> | <table:table> |
| row | <tr> | <table:table-row> |
| cell | <td> | <table:table-cell> |
| boolean SetZipBinary (string $path_binary[, $test=false]) | Set the zip binary to compress XML files to OpenOffice documents |
| boolean SetUnzipBinary (string $path_binary [, $test=false]) | Set the unzip binary to uncompress XML files from OpenOffice documents |
| boolean SetProcessDir (string $process_path) | Set the folder to process temporary OpenOffice documents |
| void SetDataCharset (string $charset) | Fix the source data's charset (ISO 8859-1 or UTF8) |
| mixed NewDocFromTpl (string $ooo_template_filename) | Create an new OpenOffice document from the OpenOffice template |
| boolean LoadXmlFromDoc (string $xml_file) | Unzip the XML file from the OpenOffice file and load as a TBS template to be merged |
| boolean SaveXmlToDoc (void) | Save the result from TBS into the XML file and zip into the OpenOffice document |
| void AddFileToDoc (string $filename) | Add a file into the OpenOffice document |
| string GetPathnameDoc (void) | Get the path of the new OpenOffice document |
| string GetMimetypeDoc (void) | Get the document mime type |
| stream FlushDoc (void) | Flush the document to STDOUT |
| void RemoveDoc (void) | Unlink the document |
| void ClearProcessDir ([int $hour=2 [, int $minut=0]]) | Clean the process directory |