#!/usr/bin/php
<?php 
require_once dirname(__FILE__) . '/../../common.php';
$phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD);
printf("Supported TEMPLATE file formats (input)  : %s.\n", arrayDecorator($phpLiveDocx->getTemplateFormats()));
printf("Supported DOCUMENT file formats (output) : %s.\n", arrayDecorator($phpLiveDocx->getDocumentFormats()));
unset($phpLiveDocx);
示例#2
0
     $opts->parse();
 } catch (Zend_Console_Getopt_Exception $e) {
     echo $e->getUsageMessage();
     exit;
 }
 $outputFormat = $opts->getOption('output-format');
 $outputFormat = strtolower($outputFormat);
 if (!in_array($outputFormat, $outputFormats)) {
     echo $opts->getUsageMessage();
     exit;
 }
 // -------------------------------------------------------------------------
 touch(FILENAME_LOCK);
 // -------------------------------------------------------------------------
 $path = new DirectoryIterator(PATH_INPUT);
 $inputFormats = $phpLiveDocx->getTemplateFormats();
 foreach ($path as $file) {
     $inputFormat = Tis_Service_LiveDocx::getFormat($file->getFilename());
     if (in_array($inputFormat, $inputFormats)) {
         $inputFilename = PATH_INPUT . DIRECTORY_SEPARATOR . $file->getFilename();
         $inputDoneFilename = PATH_INPUT_DONE . DIRECTORY_SEPARATOR . $file->getFilename();
         $outputFilename = PATH_OUTPUT . DIRECTORY_SEPARATOR . Converter::getFilename($file->getFilename(), $outputFormat);
         printf('Converting %s to %s... ', basename($inputFilename), basename($outputFilename));
         if ($inputFormat === $outputFormat) {
             rename($inputFilename, $inputDoneFilename);
             print "SKIPPED.\n";
         } else {
             $convertedDocument = Converter::convert($inputFilename, $outputFormat);
             if (false !== $convertedDocument) {
                 file_put_contents($outputFilename, $convertedDocument);
                 rename($inputFilename, $inputDoneFilename);