OpenTBS is a plug-in for the TinyButStrong Template Engine.
TinyButStrong is a PHP Template Engine which has special template syntax and allows you to design templates in their natural editing tools. But it normally works only for XML, HTML and Text files.
With TinyButStrong and its plug-in OpenTBS, you can use the template engine to merge OpenOffice documents and Ms Office 2007-2010 documents with lot of facilities. All OpenDocument Format (ODF) and Office Open XML (OOXML) can be merged with OpenTBS,and also XPS files. All zip archives containing Xml/Html/Text files can be merged with OpenTBS.
What is special to OpenTBS:
• Design your templates directly with OpenOffice or MS Office >=2007.
• No exe file needed to merge documents.
• No temporary files needed to merge documents.
• Output directly as an http download, a new file on the disk, or as a string (for file attachment for example).
• Works with both PHP 4 and PHP 5.
• No PHP extension is required (If the Zlib extension is enabled it becomes easier to use templates, see more detail below)
You should know Template Engines and more specifically TinyButStrong to use
OpenTBS.
Requirements:
- TinyButStrong version 3.5.0 or higher ("tbs_class.php" or "tbs_class_php5.php").
- PHP 4.3 or higher, PHP 5
- It is better to have the Zlib extension for PHP enabled (version 1.2.3 or higher, a lower version can makes corrupted documents).
Installation:
Just add the file "tbs_plugin_opentbs.php".
What difference if the Zlib extension
is not enabled in the PHP configuration?
OpenTBS uses Zlib functions in order to automatically uncompress and recompress files stored in the zip archive. If Zlib is not enabled, then you have to use your own uncompress/compress tool, or to prepare the template to have files uncompressed in the zip archive (see below).
It is important to figure out that OpenOffice and Ms Office (since version 2007) documents are technically zip archives containing XML files, even if the extension of the document is not ".zip". Those zip archives can contains other file types like pictures or sounds, but the document structure and the text contents are saved as XML files.
TinyButStrong can merge XML files, but cannot read zip archives by itself. The plug-in OpenTBS extends the TinyButStrong methods LoadTemplate() and Show() to make them working with zip archives.
Thus, LoadTemplate() becomes able to first load a zip archive (an OpenOffice or Ms Office document), and then to load for a merge the contents of any XML or Text files stored in the archive. You can then merge the contents of XML or Text files with all features of the TinyButStrong template engine. At the end, the Show() method is able to output the entire zip archive including modified stored files. The output can be done as an HTTP download, a news file on the server's disk, or in a PHP string.
Please note that this version of OpenTBS can only modify exiting files in the archive. It cannot delete an existing file, and cannot add new files in the archive.
OpenTBS has an automatic extension recognition. When you load a document (an archive) which has one of the following extensions (odt, odg, ods, odf, odp, docx, xlsx and pptx), then the main XML file of the archive are automatically loaded, and some special character conversion are preset. For example, for all OpenDocument files, the stored file "content.xml" is automatically loaded.
Even if you can edit your template using directly OpenOffice or Ms Office >=2007, you will probably need to understand the XML tags and attributes you will merge. Here is a small synopsis of the files supported by OpenTBS in native : xml_synopsis.txt
Prepare the TinyButStrong Template Engine with the OpenTBS plug-in
Run the following demo under PHP: OpenTBS demo
version 1.1, on 2009-11-19
- New ouput mode : OPENTBS_STRING
- New feature: can reset changes in the current archive using $TBS->Plugin(OPENTBS_PLUGIN, OPENTBS_RESET);
- New behavior: extension of the archive is ignored by LoadTemplate() if the name is ended with '#'
- Bug fixed: in case of several files to take from the archive in one shot, then only the last one had [onload] fields merged.
OpenTBS is under LGPL (Lesser General Public License)