Ejemplo n.º 1
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Config\Ini;
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Using the Public LiveDocx Service with \\Zend\\Config\\Config' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use the Zend Framework LiveDocx component with a \\Zend\\Config\\Config object. This is useful, for example, to store connection credentials in an external ini file.' . PHP_EOL . PHP_EOL);
$options = new Ini('credentials.ini');
$mailMerge = new 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);
Ejemplo n.º 2
0
}
// -----------------------------------------------------------------------------
if (defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME') && defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD') && defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL') && false !== DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME && false !== DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD && false !== DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL) {
    $errorMessage = null;
    try {
        $microtime = microtime(true);
        $mailMerge = new MailMerge();
        $mailMerge->setWsdl(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL)->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD)->listTemplates();
        $duration = microtime(true) - $microtime;
        unset($mailMerge);
    } catch (Exception $e) {
        $duration = -1;
        $errorMessage = $e->getMessage();
    }
    if (is_null($errorMessage)) {
        $result = TEST_PASS;
    } else {
        $result = TEST_FAIL;
        $failed = true;
    }
    Helper::printLineToc($counter, sprintf('[PREMIUM] 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 the Zend Framework LiveDocx component.';
} else {
    $message = 'Congratulations! All tests passed. The server environment, in which this script is running, is suitable for the Zend Framework LiveDocx component.';
}
Helper::printLine(PHP_EOL . $message . PHP_EOL . PHP_EOL);
// -----------------------------------------------------------------------------
Ejemplo n.º 3
0
Archivo: public.php Proyecto: raZ3l/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Using the Free Public Server' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use the Zend Framework LiveDocx component with the free, public LiveDocx server.' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$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);
// -----------------------------------------------------------------------------
// Alternatively, you can pass username and password in the constructor.
$mailMerge = new MailMerge(array('username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME, 'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD));
$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);
Ejemplo n.º 4
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Using Hosted Solution and Fully-Licensed Servers' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use the Zend Framework LiveDocx component with hosted and fully-licensed LiveDocx servers, by specifying the server\'s WSDL.' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setWsdl(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL)->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD);
$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);
Ejemplo n.º 5
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Deleting All Remotely Stored Images' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$counter = 1;
foreach ($mailMerge->listImages() as $result) {
    printf('%d) %s', $counter, $result['filename']);
    $mailMerge->deleteImage($result['filename']);
    print ' - DELETED.' . PHP_EOL;
    $counter++;
}
print PHP_EOL;
unset($mailMerge);
Ejemplo n.º 6
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Checking For Remotely Stored Templates' . PHP_EOL . PHP_EOL);
$mailMerge = new 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);
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\MailMerge;
use Zend\Service\LiveDocx\Helper;
Helper::printLine(PHP_EOL . 'Document Access Options' . PHP_EOL . PHP_EOL . 'Documents can be protected using one or more document access option:' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
// Set WSDL of your *premium* service server
$mailMerge->setWsdl(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL);
// Set username and password of your *premium* service server
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD);
Helper::printLine(implode(', ', $mailMerge->getDocumentAccessOptions()) . '.' . PHP_EOL . PHP_EOL);
unset($mailMerge);
Ejemplo n.º 8
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Uploading Locally Stored Images to Server' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
print 'Uploading image... ';
$mailMerge->uploadImage('image-01.png');
print 'DONE.' . PHP_EOL;
print 'Uploading image... ';
$mailMerge->uploadImage('image-02.png');
print 'DONE.' . PHP_EOL;
print PHP_EOL;
unset($mailMerge);
Ejemplo n.º 9
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Downloading Remotely Stored Templates' . PHP_EOL . PHP_EOL);
$mailMerge = new 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.' . PHP_EOL;
    $counter++;
}
print PHP_EOL;
unset($mailMerge);
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Cache\Cache;
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(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' => __DIR__ . '/cache');
if (!is_dir($cacheBackendOptions['cache_dir'])) {
    mkdir($cacheBackendOptions['cache_dir']);
}
$cache = Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions);
if (!($formats = $cache->load($cacheId))) {
    // Cache miss. Connect to backend service (expensive).
    $mailMerge = new 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->image = $mailMerge->getImageFormats();
    $cache->save($formats, $cacheId);
    unset($mailMerge);
} else {
    // Cache hit. Continue.
}
unset($cache);
printf("Supported TEMPLATE file formats (input)  : %s%s", Helper::arrayDecorator($formats->template), PHP_EOL);
printf("Supported DOCUMENT file formats (output) : %s%s", Helper::arrayDecorator($formats->document), PHP_EOL);
printf("Supported IMAGE file formats (output)    : %s%s", Helper::arrayDecorator($formats->image), PHP_EOL);
Ejemplo n.º 11
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Deleting All Remotely Stored Templates' . PHP_EOL . PHP_EOL);
$mailMerge = new 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);
Ejemplo n.º 12
0
<?php

// Set used namespaces
use Zend\Loader\StandardAutoloader;
use Zend\Locale\Locale;
use Zend\Service\LiveDocx\Helper;
// Turn up error reporting
error_reporting(E_ALL | E_STRICT);
// Library base
$base = dirname(dirname(dirname(dirname(__DIR__))));
// Set up autoloader
require_once "{$base}/library/Zend/Loader/StandardAutoloader.php";
$loader = new StandardAutoloader();
$loader->registerNamespace('Zend', "{$base}/library/Zend");
$loader->register();
// Include utility class
require_once "{$base}/demos/Zend/Service/LiveDocx/library/Zend/Service/LiveDocx/Helper.php";
// Set fallback locale
Locale::setFallback(Helper::LOCALE);
// Ensure LiveDocx credentials are available
if (false === Helper::credentialsAvailable()) {
    Helper::printLine(Helper::credentialsHowTo());
    exit;
}
unset($base);
Ejemplo n.º 13
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Downloading Remotely Stored Images' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$counter = 1;
foreach ($mailMerge->listImages() as $result) {
    printf('%d) %s', $counter, $result['filename']);
    $image = $mailMerge->downloadImage($result['filename']);
    file_put_contents('downloaded-' . $result['filename'], $image);
    print ' - DOWNLOADED.' . PHP_EOL;
    $counter++;
}
print PHP_EOL;
unset($mailMerge);
Ejemplo n.º 14
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Template, Document and Image Formats' . PHP_EOL . PHP_EOL . 'The following formats are supported by LiveDocx:' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
printf("Supported TEMPLATE file formats (input)  : %s%s", Helper::arrayDecorator($mailMerge->getTemplateFormats()), PHP_EOL);
printf("Supported DOCUMENT file formats (output) : %s%s", Helper::arrayDecorator($mailMerge->getDocumentFormats()), PHP_EOL);
printf("Supported IMAGE file formats (output)    : %s%s", Helper::arrayDecorator($mailMerge->getImageFormats()), PHP_EOL);
print PHP_EOL;
unset($mailMerge);
Ejemplo n.º 15
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Cache\StorageFactory;
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
$cacheId = md5(__FILE__);
$cache = array('adapter' => 'FileSystem', 'options' => array('cache_dir' => __DIR__ . '/cache'));
if (!is_dir($cache['options']['cache_dir'])) {
    mkdir($cache['options']['cache_dir']);
}
$cache = StorageFactory::factory($cache);
if (!($fonts = $cache->getItem($cacheId))) {
    // Cache miss. Connect to backend service (expensive).
    $mailMerge = new MailMerge();
    $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
    $fonts = $mailMerge->getFontNames();
    $cache->addItem($fonts, $cacheId);
    unset($mailMerge);
} else {
    // Cache hit. Continue.
}
unset($cache);
Helper::printLine(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 . Helper::arrayDecorator($fonts) . PHP_EOL . PHP_EOL);
print PHP_EOL;
unset($mailMerge);
Ejemplo n.º 16
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(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 MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
print Helper::listDecorator($mailMerge->listTemplates());
unset($mailMerge);
Ejemplo n.º 17
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(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 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);
Ejemplo n.º 18
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
Helper::printLine(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 . Helper::arrayDecorator($mailMerge->getFontNames()) . PHP_EOL . PHP_EOL);
unset($mailMerge);
Ejemplo n.º 19
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Checking For Remotely Stored Images' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
print 'Checking whether an image is available... ';
if (true === $mailMerge->imageExists('image-01.png')) {
    print 'EXISTS. ';
} else {
    print 'DOES NOT EXIST. ';
}
print 'DONE' . PHP_EOL;
print PHP_EOL;
unset($mailMerge);