Example #1
0
<?php

// require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Deleting All Remotely Stored Templates' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$counter = 1;
foreach ($mailMerge->listTemplates() as $result) {
    printf('%d) %s', $counter, $result['filename']);
    $mailMerge->deleteTemplate($result['filename']);
    print ' - DELETED.' . PHP_EOL;
    $counter++;
}
print PHP_EOL;
unset($mailMerge);
Example #2
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Using the Free Public Server' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use Zend_Service_LiveDocx_MailMerge with the free, public LiveDocx server.' . PHP_EOL . PHP_EOL);
$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
$phpLiveDocx->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$phpLiveDocx->getTemplateFormats();
// then call methods as usual
printf('Username : %s%sPassword : %s%s    WSDL : %s%s%s', $phpLiveDocx->getUsername(), PHP_EOL, $phpLiveDocx->getPassword(), PHP_EOL, $phpLiveDocx->getWsdl(), PHP_EOL, PHP_EOL);
unset($phpLiveDocx);
// -----------------------------------------------------------------------------
// Alternatively, you can pass username and password in the constructor.
$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge(array('username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME, 'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD));
$phpLiveDocx->getTemplateFormats();
// then call methods as usual
printf('Username : %s%sPassword : %s%s    WSDL : %s%s%s', $phpLiveDocx->getUsername(), PHP_EOL, $phpLiveDocx->getPassword(), PHP_EOL, $phpLiveDocx->getWsdl(), PHP_EOL, PHP_EOL);
unset($phpLiveDocx);
}
if (is_null($errorMessage)) {
    $result = TEST_PASS;
} else {
    $result = TEST_FAIL;
    $failed = true;
}
printLine($counter, sprintf('Logging into backend service (%01.2fs)', $duration), $result);
$counter++;
// -----------------------------------------------------------------------------
if (true === $failed) {
    $message = 'One or more tests failed. The web server environment, in which this script is running, does not meet the requirements for Zend_Service_LiveDocx_*.';
} else {
    $message = 'Congratulations! All tests passed. The server environment, in which this script is running, is suitable for Zend_Service_LiveDocx_*.';
}
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . $message . PHP_EOL . PHP_EOL);
// -----------------------------------------------------------------------------
/**
 * Print result line
 *
 * @param $counter
 * @param $testString
 * @param $testResult
 */
function printLine($counter, $testString, $testResult)
{
    $lineLength = Demos_Zend_Service_LiveDocx_Helper::LINE_LENGTH;
    //                        counter     result
    $padding = $lineLength - (4 + strlen(TEST_PASS));
    $counter = sprintf('%2s: ', $counter);
    $testString = str_pad($testString, $padding, '.', STR_PAD_RIGHT);
<?php

require_once dirname(__FILE__) . '/../../common.php';
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Supported Fonts' . PHP_EOL . PHP_EOL . 'The following fonts are installed on the backend server and may be used in templates. Fonts used in templates, which are NOT listed below, will be substituted. If you would like to use a font, which is not installed on the backend server, please contact your LiveDocx provider.' . PHP_EOL . PHP_EOL . Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getFontNames()) . PHP_EOL . PHP_EOL);
unset($mailMerge);
Example #5
0
<?php

// require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Checking For Remotely Stored Templates' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
print 'Checking whether a template is available... ';
if (true === $mailMerge->templateExists('template-1.docx')) {
    print 'EXISTS. ';
} else {
    print 'DOES NOT EXIST. ';
}
print 'DONE' . PHP_EOL;
print PHP_EOL;
unset($mailMerge);
Example #6
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Using Hosted Solution and Fully-Licensed Servers' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use Zend_Service_LiveDocx_MailMerge with hosted and fully-licensed LiveDocx servers, by specifying an alternative SOAP client (must be instance of Zend_Soap_Client).' . PHP_EOL . PHP_EOL);
$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
$phpLiveDocx->setWsdl('https://api.example.com/1.2/mailmerge.asmx?WSDL')->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$phpLiveDocx->getTemplateFormats();
// then call methods as usual
printf('Username : %s%sPassword : %s%s    WSDL : %s%s%s', $phpLiveDocx->getUsername(), PHP_EOL, $phpLiveDocx->getPassword(), PHP_EOL, $phpLiveDocx->getWsdl(), PHP_EOL, PHP_EOL);
unset($phpLiveDocx, $mySoapClient);
Example #7
0
File: list.php Project: netvlies/zf
<?php

// require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Remotely Stored Templates' . PHP_EOL . PHP_EOL . 'The following templates are currently stored on the LiveDocx server:' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
print Demos_Zend_Service_LiveDocx_Helper::listDecorator($mailMerge->listTemplates());
unset($mailMerge);
Example #8
0
<?php

// require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Uploading Locally Stored Templates to Server' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
print 'Uploading template... ';
$mailMerge->uploadTemplate('template-1.docx');
print 'DONE.' . PHP_EOL;
print 'Uploading template... ';
$mailMerge->uploadTemplate('template-2.docx');
print 'DONE.' . PHP_EOL;
print PHP_EOL;
unset($mailMerge);
Example #9
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Template, Document and Image Formats' . PHP_EOL . PHP_EOL . 'The following formats are supported by LiveDocx:' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
printf("Supported TEMPLATE file formats (input)  : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getTemplateFormats()), PHP_EOL);
printf("Supported DOCUMENT file formats (output) : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getDocumentFormats()), PHP_EOL);
printf("Supported IMAGE file formats (output)    : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getImageFormats()), PHP_EOL);
print PHP_EOL;
unset($mailMerge);
Example #10
0
<?php

// require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Using the Public LiveDocx Service with Zend_Config' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use Zend_Service_LiveDocx_MailMerge with a Zend_Config object. This is useful, for example, to store connection credentials in an external ini file.' . PHP_EOL . PHP_EOL);
$options = new Zend_Config_Ini('credentials.ini');
$mailMerge = new Zend_Service_LiveDocx_MailMerge($options);
$mailMerge->getTemplateFormats();
// then call methods as usual
printf('Username : %s%sPassword : %s%s    WSDL : %s%s%s', $mailMerge->getUsername(), PHP_EOL, $mailMerge->getPassword(), PHP_EOL, $mailMerge->getWsdl(), PHP_EOL, PHP_EOL);
unset($mailMerge, $options);
Example #11
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Downloading Remotely Stored Templates' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$counter = 1;
foreach ($mailMerge->listTemplates() as $result) {
    printf('%d) %s', $counter, $result['filename']);
    $template = $mailMerge->downloadTemplate($result['filename']);
    file_put_contents('downloaded-' . $result['filename'], $template);
    print " - DOWNLOADED.\n";
    $counter++;
}
print PHP_EOL;
unset($mailMerge);
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
$cacheId = md5(__FILE__);
$cacheFrontendOptions = array('lifetime' => 2592000, 'automatic_serialization' => true);
$cacheBackendOptions = array('cache_dir' => dirname(__FILE__) . '/cache');
$cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions);
if (!($fonts = $cache->load($cacheId))) {
    // Cache miss. Connect to backend service (expensive).
    $mailMerge = new Zend_Service_LiveDocx_MailMerge();
    $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
    $fonts = $mailMerge->getFontNames();
    $cache->save($fonts, $cacheId);
    unset($mailMerge);
} else {
    // Cache hit. Continue.
}
unset($cache);
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Supported Fonts' . PHP_EOL . PHP_EOL . 'The following fonts are installed on the backend server and may be used in templates. Fonts used in templates, which are NOT listed below, will be substituted. If you would like to use a font, which is not installed on the backend server, please contact your LiveDocx provider.' . PHP_EOL . PHP_EOL . '(Note this method call is cached for maximum performance. The supported formats change very infrequently, hence, they are good candidates to be cached.)' . PHP_EOL . PHP_EOL . Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($fonts) . PHP_EOL . PHP_EOL);
print PHP_EOL;
unset($mailMerge);
Example #13
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Field and Block Field Names (merge fields)' . PHP_EOL . PHP_EOL . 'The following templates contain the listed field or block field names:' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
// -----------------------------------------------------------------------------
$templateName = 'template-1-text-field.docx';
$mailMerge->setLocalTemplate($templateName);
printf('Field names in %s:%s', $templateName, PHP_EOL);
$fieldNames = $mailMerge->getFieldNames();
foreach ($fieldNames as $fieldName) {
    printf('- %s%s', $fieldName, PHP_EOL);
}
// -----------------------------------------------------------------------------
$templateName = 'template-2-text-fields.doc';
$mailMerge->setLocalTemplate($templateName);
printf('%sField names in %s:%s', PHP_EOL, $templateName, PHP_EOL);
$fieldNames = $mailMerge->getFieldNames();
foreach ($fieldNames as $fieldName) {
    printf('- %s%s', $fieldName, PHP_EOL);
}
// -----------------------------------------------------------------------------
$templateName = 'template-block-fields.doc';
$mailMerge->setLocalTemplate($templateName);
printf('%sField names in %s:%s', PHP_EOL, $templateName, PHP_EOL);
$fieldNames = $mailMerge->getFieldNames();
foreach ($fieldNames as $fieldName) {
    printf('- %s%s', $fieldName, PHP_EOL);
}
Example #14
0
<?php

// Turn up error reporting
error_reporting(E_ALL | E_STRICT);
// Set path to libraries
set_include_path(realpath(dirname(__FILE__) . '/../../../../library'));
// Demos_Zend_Service_LiveDocx_Helper
require_once dirname(__FILE__) . '/Helper.php';
// Set autoloader to autoload libraries
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
// Set default locale
Zend_Locale::setDefault(Demos_Zend_Service_LiveDocx_Helper::LOCALE);
$locale = new Zend_Locale(Zend_Locale::ZFDEFAULT);
Zend_Registry::set('Zend_Locale', $locale);
// Ensure LiveDocx credentials are available
if (false === Demos_Zend_Service_LiveDocx_Helper::credentialsAvailable()) {
    echo Demos_Zend_Service_LiveDocx_Helper::wrapLine(Demos_Zend_Service_LiveDocx_Helper::credentialsHowTo());
    exit;
}
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Template, Document and Image Formats' . PHP_EOL . PHP_EOL . 'The following formats are supported by LiveDocx:' . PHP_EOL . PHP_EOL . '(Note these method calls are cached for maximum performance. The supported formats change very infrequently, hence, they are good candidates to be cached.)' . PHP_EOL . PHP_EOL);
$cacheId = md5(__FILE__);
$cacheFrontendOptions = array('lifetime' => 2592000, 'automatic_serialization' => true);
$cacheBackendOptions = array('cache_dir' => dirname(__FILE__) . '/cache');
$cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions);
if (!($formats = $cache->load($cacheId))) {
    // Cache miss. Connect to backend service (expensive).
    $mailMerge = new Zend_Service_LiveDocx_MailMerge();
    $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
    $formats = new StdClass();
    $formats->template = $mailMerge->getTemplateFormats();
    $formats->document = $mailMerge->getDocumentFormats();
    $formats->imageImport = $mailMerge->getImageImportFormats();
    $formats->imageExport = $mailMerge->getImageExportFormats();
    $cache->save($formats, $cacheId);
    unset($mailMerge);
} else {
    // Cache hit. Continue.
}
unset($cache);
printf("Supported TEMPLATE file formats (input)  : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->template), PHP_EOL);
printf("Supported DOCUMENT file formats (output) : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->document), PHP_EOL . PHP_EOL);
printf("Supported IMAGE file formats (import)    : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->imageImport), PHP_EOL);
printf("Supported IMAGE file formats (export)    : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->imageExport), PHP_EOL);
print PHP_EOL;
Example #16
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Remotely Stored Templates' . PHP_EOL . PHP_EOL . 'The following templates are currently stored on the LiveDocx server:' . PHP_EOL . PHP_EOL);
$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
$phpLiveDocx->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
print Demos_Zend_Service_LiveDocx_Helper::listDecorator($phpLiveDocx->listTemplates());
unset($phpLiveDocx);