Exemplo n.º 1
0
define('PATH_INPUT', PATH_BASE . DIRECTORY_SEPARATOR . 'queue');
define('PATH_INPUT_DONE', PATH_BASE . DIRECTORY_SEPARATOR . 'queue_done');
define('PATH_OUTPUT', PATH_BASE . DIRECTORY_SEPARATOR . 'output');
define('FILENAME_LOCK', PATH_BASE . DIRECTORY_SEPARATOR . 'job.lock');
// -----------------------------------------------------------------------------
$date = new Zend_Date(LOCALE);
echo "### " . basename($_SERVER['SCRIPT_NAME']) . " Batch Converter\n\n";
echo "### Start: " . $date->get(Zend_Date::W3C) . "\n\n";
unset($date);
// -----------------------------------------------------------------------------
if (is_file(FILENAME_LOCK)) {
    printf("ERROR: There is already an instance running (%s)\n", FILENAME_LOCK);
    // -------------------------------------------------------------------------
} else {
    $phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD);
    $outputFormats = $phpLiveDocx->getDocumentFormats();
    // -------------------------------------------------------------------------
    $options = array('output-format|of=s' => sprintf('Output file format (%s).', implode(', ', $outputFormats)));
    try {
        $opts = new Zend_Console_Getopt($options);
        $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;
    }
#!/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);
#!/usr/bin/php
<?php 
require_once dirname(__FILE__) . '/../../common.php';
$date = new Zend_Date();
$date->setLocale(LOCALE);
$phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD);
$phpLiveDocx->setLocalTemplate('template.docx');
$phpLiveDocx->assign('software', 'ACE Downloader 2.8');
$phpLiveDocx->assign('licensee', 'Paul Peterson');
$phpLiveDocx->assign('company', 'Bresoft Ltd');
$phpLiveDocx->assign('date', $date->get(Zend_Date::DATE_LONG));
$phpLiveDocx->assign('time', $date->get(Zend_Date::TIME_LONG));
$phpLiveDocx->assign('city', 'Royal Tunbridge Wells');
$phpLiveDocx->assign('country', 'United Kingdom');
$phpLiveDocx->createDocument();
foreach ($phpLiveDocx->getDocumentFormats() as $format) {
    $documentFile = sprintf('document.%s', $format);
    printf('Retrieving %s version (%s)... ', strtoupper($format), $documentFile);
    $document = $phpLiveDocx->retrieveDocument($format);
    file_put_contents($documentFile, $document);
    print "DONE.\n";
}
unset($phpLiveDocx);