Skip to content

Commit

Permalink
Merge remote branch 'jonathanmaron/zend-service-livedocx-1.3' into jm
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jun 16, 2010
2 parents 7ae9686 + 2bbf906 commit d1682e1
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

$mailMerge = new MailMerge();

$mailMerge->setWsdl(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL)
$mailMerge->setWSDL(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL)
->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME)
->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD);

Expand All @@ -27,7 +27,7 @@
PHP_EOL,
$mailMerge->getPassword(),
PHP_EOL,
$mailMerge->getWsdl(),
$mailMerge->getWSDL(),
PHP_EOL,
PHP_EOL
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PHP_EOL,
$mailMerge->getPassword(),
PHP_EOL,
$mailMerge->getWsdl(),
$mailMerge->getWSDL(),
PHP_EOL,
PHP_EOL
);
Expand Down
4 changes: 2 additions & 2 deletions demos/Zend/Service/LiveDocx/MailMerge/constructors/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PHP_EOL,
$mailMerge->getPassword(),
PHP_EOL,
$mailMerge->getWsdl(),
$mailMerge->getWSDL(),
PHP_EOL,
PHP_EOL
);
Expand All @@ -51,7 +51,7 @@
PHP_EOL,
$mailMerge->getPassword(),
PHP_EOL,
$mailMerge->getWsdl(),
$mailMerge->getWSDL(),
PHP_EOL,
PHP_EOL
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
$mailMerge = new MailMerge();

// Set WSDL of your *premium* service server
$mailMerge->setWsdl(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL);
$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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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);
9 changes: 6 additions & 3 deletions demos/Zend/Service/LiveDocx/check-environment.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<?php

set_time_limit(0);

require_once __DIR__ . DIRECTORY_SEPARATOR . 'Bootstrap.php';


use Zend\Version;
use Zend\Service\LiveDocx\MailMerge;
use Zend\Service\LiveDocx\Helper;

define('TEST_PASS', 'PASS');
define('TEST_FAIL', 'FAIL');

define('MIN_PHP_VERSION', '5.2.4');
define('MIN_ZF_VERSION', '1.10.0');
define('MIN_PHP_VERSION', '5.3');
define('MIN_ZF_VERSION', '2.0.0dev1');

define('SOCKET_TIMEOUT', 5); // seconds

Expand Down Expand Up @@ -281,7 +284,7 @@
try {
$microtime = microtime(true);
$mailMerge = new MailMerge();
$mailMerge->setWsdl(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL);
$mailMerge->setWSDL(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL);
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME);
$mailMerge->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD);
$mailMerge->logIn();
Expand Down
37 changes: 37 additions & 0 deletions demos/Zend/Service/LiveDocx/run-all-demos.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

set_time_limit(0);

require_once __DIR__ . DIRECTORY_SEPARATOR . 'Bootstrap.php';


/**
* Run all demonstration applications
*
* This script recursively runs all demonstration applications, which ship with
* the Zend Framework LiveDocx component. The demonstration applications
* do not necessarily output anything to stdout. Those that do not, generate a
* file in the same directory as the PHP script.
*/

exec('which php', $php);

if (!isset($php[0])) {
exit('Cannot find PHP exec on your system.');
}

$php = $php[0];

$path = __DIR__ . DIRECTORY_SEPARATOR . 'MailMerge';

$it = new \RecursiveDirectoryIterator($path);
foreach (new \RecursiveIteratorIterator($it) as $file) {
if ('php' === substr($file->getFilename(), -3)) {
$cmd = sprintf('cd %s && %s %s', dirname($file->getPathname()),
$php, $file->getFilename());
print($cmd . PHP_EOL);
passthru($cmd);
}
}

chdir(__DIR__);
30 changes: 15 additions & 15 deletions library/Zend/Service/LiveDocx/AbstractLiveDocx.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,8 @@ public function __destruct()
*/
protected function _initSoapClient($endpoint)
{
try {
$this->_soapClient = new Client();
$this->_soapClient->setWsdl($endpoint);
} catch (\SoapFault $e) { // @todo -- which exception to catch here?
throw new Exception('Cannot connect to LiveDocx service at ' . $endpoint, 0, $e);
}
$this->_soapClient = new Client();
$this->_soapClient->setWSDL($endpoint);
}

/**
Expand Down Expand Up @@ -184,18 +180,18 @@ public function logIn()

if (null === $this->getUsername()) {
throw new Exception(
'Username has not been set. To set username specify the options array in the constructor or call setUsername($username) after instantiation'
'Username has not been set. To set username specify the options array in the constructor or call setUsername($username) after instantiation.'
);
}

if (null === $this->getPassword()) {
throw new Exception(
'Password has not been set. To set password specify the options array in the constructor or call setPassword($password) after instantiation'
'Password has not been set. To set password specify the options array in the constructor or call setPassword($password) after instantiation.'
);
}

if (null === $this->getSoapClient()) {
$this->_initSoapClient($this->_wsdl);
$this->_initSoapClient($this->getWSDL());
}

try {
Expand All @@ -204,9 +200,9 @@ public function logIn()
'password' => $this->getPassword(),
));
$this->_loggedIn = true;
} catch (Exception $e) {
} catch (\SoapFault $e) {
throw new Exception(
'Cannot login into LiveDocx service - username and/or password are invalid', 0, $e
'Cannot login into LiveDocx service. Please check that your server can download the WSDL (' . $this->getWSDL() . ') and that your username and password are valid.', 0, $e
);
}
}
Expand All @@ -229,7 +225,7 @@ public function logOut()
$this->_loggedIn = false;
} catch (Exception $e) {
throw new Exception(
'Cannot log out of LiveDocx service', 0, $e
'Cannot log out of LiveDocx service.', 0, $e
);
}
}
Expand Down Expand Up @@ -278,7 +274,7 @@ public function setPassword($password)
* @return Zend\Service\AbstractLiveDocx
* @since LiveDocx 1.0
*/
public function setWsdl($wsdl)
public function setWSDL($wsdl)
{
$this->_wsdl = $wsdl;
return $this;
Expand Down Expand Up @@ -320,9 +316,13 @@ public function getPassword()
* @return Zend\Service\AbstractLiveDocx
* @since LiveDocx 1.0
*/
public function getWsdl()
public function getWSDL()
{
return $this->_wsdl;
if (null !== $this->getSoapClient()) {
return $this->getSoapClient()->getWSDL();
} else {
return $this->_wsdl;
}
}

/**
Expand Down
29 changes: 16 additions & 13 deletions library/Zend/Service/LiveDocx/MailMerge.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ class MailMerge extends AbstractLiveDocx
*/
public function __construct($options = null)
{
$this->_wsdl = self::WSDL;
$this->_fieldValues = array();
$this->_blockFieldValues = array();

$this->setWSDL(self::WSDL);

parent::__construct($options);
}

Expand All @@ -149,7 +150,7 @@ public function setLocalTemplate($filename)
{
if (!is_readable($filename)) {
throw new Exception(
'Cannot read local template from disk'
'Cannot read local template from disk.'
);
}

Expand All @@ -162,7 +163,7 @@ public function setLocalTemplate($filename)
));
} catch (Exception $e) {
throw new Exception(
'Cannot set local template', 0, $e
'Cannot set local template.', 0, $e
);
}

Expand All @@ -188,7 +189,7 @@ public function setRemoteTemplate($filename)
));
} catch (Exception $e) {
throw new Exception(
'Cannot set remote template', 0, $e
'Cannot set remote template.', 0, $e
);
}

Expand Down Expand Up @@ -222,7 +223,7 @@ public function setFieldValues($values)
));
} catch (Exception $e) {
throw new Exception(
'Cannot set field values', 0, $e
'Cannot set field values.', 0, $e
);
}

Expand Down Expand Up @@ -267,7 +268,7 @@ public function setBlockFieldValues($blockName, $blockFieldValues)
));
} catch (Exception $e) {
throw new Exception(
'Cannot set block field values', 0, $e
'Cannot set block field values.', 0, $e
);
}

Expand Down Expand Up @@ -297,7 +298,7 @@ public function assign($field, $value = null)
}
} catch (Exception $e) {
throw new Exception(
'Cannot assign data to template', 0, $e
'Cannot assign data to template.', 0, $e
);
}

Expand Down Expand Up @@ -334,6 +335,8 @@ public function setDocumentPassword($password)
/**
* Set a master password for document and determine which security features
* are accessible without using the master password.
*
* An array of supported permissions can be retrieved with getDocumentAccessOptions().
*
* This method can only be used for PDF documents
*
Expand All @@ -354,7 +357,7 @@ public function setDocumentAccessPermissions($permissions, $password)
));
} catch (Exception $e) {
throw new Exception(
'Cannot set document access permissions', 0, $e
'Cannot set document access permissions.', 0, $e
);
}

Expand Down Expand Up @@ -383,7 +386,7 @@ public function createDocument()
$this->getSoapClient()->CreateDocument();
} catch (Exception $e) {
throw new Exception(
'Cannot create document', 0, $e
'Cannot create document.', 0, $e
);
}
}
Expand All @@ -409,7 +412,7 @@ public function retrieveDocument($format)
));
} catch (Exception $e) {
throw new Exception(
'Cannot retrieve document - call setLocalTemplate() or setRemoteTemplate() first', 0, $e
'Cannot retrieve document - call setLocalTemplate() or setRemoteTemplate() first.', 0, $e
);
}

Expand Down Expand Up @@ -639,7 +642,7 @@ public function uploadTemplate($filename)
{
if (!is_readable($filename)) {
throw new Exception(
'Cannot read local template from disk'
'Cannot read local template from disk.'
);
}

Expand All @@ -652,7 +655,7 @@ public function uploadTemplate($filename)
));
} catch (Exception $e) {
throw new Exception(
'Cannot upload template', 0, $e
'Cannot upload template.', 0, $e
);
}
}
Expand Down Expand Up @@ -813,7 +816,7 @@ public function downloadSharedDocument($filename)
));
} catch (Exception $e) {
throw new Exception(
'Cannot download shared document', 0, $e
'Cannot download shared document.', 0, $e
);
}

Expand Down
Loading

0 comments on commit d1682e1

Please sign in to comment.