Skip to content

Commit

Permalink
Merge branch 'livedocx-2.0' of https://github.com/jonathanmaron/zf2 i…
Browse files Browse the repository at this point in the history
…nto hotfix/maron-livedocx-2.0
  • Loading branch information
weierophinney committed Dec 17, 2010
2 parents 149042f + 1f244fb commit 2a121f8
Show file tree
Hide file tree
Showing 24 changed files with 518 additions and 134 deletions.
21 changes: 11 additions & 10 deletions demos/Zend/Service/LiveDocx/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<?php

// Set used namespaces
use Zend\Loader\Autoloader;
use Zend\Locale\Locale;
use Zend\Registry;
use Zend\Service\LiveDocx\Helper;

// Turn up error reporting
error_reporting(E_ALL | E_STRICT);

// Set path to libraries
set_include_path(
__DIR__ . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR .
dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'library'
);
// Set up autoloader
$base = dirname(dirname(dirname(dirname(__DIR__))));
require_once "{$base}/library/Zend/Loader/StandardAutoloader.php";
$loader = new \Zend\Loader\StandardAutoloader();
$loader->registerNamespace('Zend', "{$base}/library/Zend");
$loader->register();

// Set autoloader to autoload libraries
require_once 'Zend/Loader/Autoloader.php';
Autoloader::getInstance();
// Include utility class
require_once "{$base}/demos/Zend/Service/LiveDocx/library/Zend/Service/LiveDocx/Helper.php";

// Set default locale
Locale::setDefault(Helper::LOCALE);
Expand All @@ -28,4 +27,6 @@
if (false === Helper::credentialsAvailable()) {
Helper::printLine(Helper::credentialsHowTo());
exit();
}
}

unset($base);
Empty file modified demos/Zend/Service/LiveDocx/DemoConfiguration.php.dist
100644 → 100755
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';


use Zend\Date\Date;
use Zend\Service\LiveDocx\MailMerge;

$mailMerge = new MailMerge();

$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)
->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);

/**
* Image Source:
* iStock_000003413016Medium_business-man-with-hands-up.jpg
*/
$photoFilename = 'dailemaitre.jpg';

if (!$mailMerge->imageExists($photoFilename)) {
$mailMerge->uploadImage($photoFilename);
}

$mailMerge->setLocalTemplate('template.docx');

$mailMerge->assign('name', 'Daï Lemaitre')
->assign('company', 'Megasoft Co-operation')
->assign('date', Date::now()->toString(Date::DATE_LONG))
->assign('image:photo', $photoFilename);

$mailMerge->createDocument();

$document = $mailMerge->retrieveDocument('pdf');

file_put_contents('document.pdf', $document);

$mailMerge->deleteImage($photoFilename);

unset($mailMerge);
Binary file not shown.
30 changes: 30 additions & 0 deletions demos/Zend/Service/LiveDocx/MailMerge/images/delete-all.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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);
31 changes: 31 additions & 0 deletions demos/Zend/Service/LiveDocx/MailMerge/images/download.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions demos/Zend/Service/LiveDocx/MailMerge/images/image-exists.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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);
24 changes: 24 additions & 0 deletions demos/Zend/Service/LiveDocx/MailMerge/images/list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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 Images' .
PHP_EOL .
PHP_EOL . 'The following images 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->listImages()));

unset($mailMerge);
30 changes: 30 additions & 0 deletions demos/Zend/Service/LiveDocx/MailMerge/images/upload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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);
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

$formats->template = $mailMerge->getTemplateFormats();
$formats->document = $mailMerge->getDocumentFormats();
$formats->image = $mailMerge->getImageFormats();
$formats->image = $mailMerge->getImageExportFormats();

$cache->save($formats, $cacheId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Helper::arrayDecorator($mailMerge->getDocumentFormats()), PHP_EOL);

printf("Supported IMAGE file formats (output) : %s%s",
Helper::arrayDecorator($mailMerge->getImageFormats()), PHP_EOL);
Helper::arrayDecorator($mailMerge->getImageExportFormats()), PHP_EOL);

print PHP_EOL;

Expand Down
2 changes: 1 addition & 1 deletion demos/Zend/Service/LiveDocx/check-environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@

try {
$microtime = microtime(true);
$mailMerge = new Zend_Service_LiveDocx_MailMerge(
$mailMerge = new MailMerge(
array (
'username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME,
'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD
Expand Down
43 changes: 0 additions & 43 deletions demos/Zend/Service/LiveDocx/configuration.php.dist

This file was deleted.

Empty file.
14 changes: 7 additions & 7 deletions library/Zend/Service/LiveDocx/AbstractLiveDocx.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
* @namespace
*/
namespace Zend\Service\LiveDocx;
use Zend\Service\LiveDocx\Exception;
use Zend\Soap\Client\Client;

use Zend\Soap\Client as SoapClient;

/**
* @uses Exception
* @uses Zend\Soap\Client\Client
* @uses Zend\Soap\Client
* @category Zend
* @package Zend_Service
* @subpackage LiveDocx
Expand All @@ -46,7 +46,7 @@ abstract class AbstractLiveDocx

/**
* SOAP client used to connect to LiveDocx service
* @var Zend\Soap\Client\Client
* @var Zend\Soap\Client
* @since LiveDocx 1.0
*/
protected $_soapClient;
Expand Down Expand Up @@ -135,14 +135,14 @@ public function __destruct()
*/
protected function _initSoapClient($endpoint)
{
$this->_soapClient = new Client();
$this->_soapClient = new SoapClient();
$this->_soapClient->setWSDL($endpoint);
}

/**
* Get SOAP client
*
* @return Zend\Soap\Client\Client
* @return Zend\Soap\Client
* @since LiveDocx 1.2
*/
public function getSoapClient()
Expand All @@ -153,7 +153,7 @@ public function getSoapClient()
/**
* Set SOAP client
*
* @param Zend\Soap\Client\Client $soapClient
* @param Zend\Soap\Client $soapClient
* @return Zend\Service\AbstractLiveDocx
* @since LiveDocx 1.2
*/
Expand Down
Empty file modified library/Zend/Service/LiveDocx/Exception.php
100644 → 100755
Empty file.
Loading

0 comments on commit 2a121f8

Please sign in to comment.