Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Include classes
- include_once('tbs_class.php'); // Load the TinyButStrong template engine
- include_once('../tbs_plugin_opentbs.php'); // Load the OpenTBS plugin
- $recset = array();
- $recset[] = array('title'=>'Iyy will love you' , 'rank'=>'A');
- $recset[] = array('title'=>'Tender thender' , 'rank'=>'B');
- $recset[] = array('title'=>'I got you babe' , 'rank'=>'C');
- $recset[] = array('title'=>'Only with you' , 'rank'=>'D');
- $recset[] = array('title'=>'Love me tender' , 'rank'=>'E');
- $recset[] = array('title'=>'Wait for me' , 'rank'=>'F');
- $recset[] = array('title'=>'Happy pop' , 'rank'=>'G');
- $recset[] = array('title'=>'Kiss me like that', 'rank'=>'H');
- $recset[] = array('title'=>'Love me so' , 'rank'=>'I');
- $recset[] = array('title'=>'Us, you and I' , 'rank'=>'J');
- // Initialize the TBS instance
- $TBS = new clsTinyButStrong; // new instance of TBS
- $TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load the OpenTBS plugin
- $TBS->LoadTemplate('test.odt', OPENTBS_ALREADY_UTF8);
- // ----------------------
- // Debug mode of the demo
- // ----------------------
- if (isset($_POST['debug']) && ($_POST['debug']=='current')) $TBS->Plugin(OPENTBS_DEBUG_XML_CURRENT, true); // Display the intented XML of the current sub-file, and exit.
- if (isset($_POST['debug']) && ($_POST['debug']=='info')) $TBS->Plugin(OPENTBS_DEBUG_INFO, true); // Display information about the document, and exit.
- if (isset($_POST['debug']) && ($_POST['debug']=='show')) $TBS->Plugin(OPENTBS_DEBUG_XML_SHOW); // Tells TBS to display information when the document is merged. No exit.
- $TBS->MergeBlock('bx',$recset);
- // Define the name of the output file
- $save_as = (isset($_POST['save_as']) && (trim($_POST['save_as'])!=='') && ($_SERVER['SERVER_NAME']=='localhost')) ? trim($_POST['save_as']) : '';
- $output_file_name = str_replace('.', '_'.date('Y-m-d').$save_as.'.', $template);
- if ($save_as==='') {
- // Output the result as a downloadable file (only streaming, no data saved in the server)
- $TBS->Show(OPENTBS_DOWNLOAD, $output_file_name); // Also merges all [onshow] automatic fields.
- // Be sure that no more output is done, otherwise the download file is corrupted with extra data.
- exit();
- } else {
- // Output the result as a file on the server.
- $TBS->Show(OPENTBS_FILE, $output_file_name); // Also merges all [onshow] automatic fields.
- // The script can continue.
- exit("File [$output_file_name] has been created.");
- }
Advertisement
Add Comment
Please, Sign In to add comment