Browse Source

Updated Zend_Service_MailMerge to use new fluent interface

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19368 44c647ce-9c0f-0410-b52a-842ac1e357ba
jonathan_maron 16 years ago
parent
commit
8bd2c601ec

+ 10 - 10
demos/Zend/Service/LiveDocx/MailMerge/bitmaps/generate-bitmaps.php

@@ -10,18 +10,18 @@ $date->setLocale(Demos_Zend_Service_LiveDocx_Helper::LOCALE);
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 $phpLiveDocx->setLocalTemplate('template.docx');
 
-$phpLiveDocx->assign('software', 'Magic Graphical Compression Suite v1.9');
-$phpLiveDocx->assign('licensee', 'Daï Lemaitre');
-$phpLiveDocx->assign('company',  'Megasoft Co-operation');
-$phpLiveDocx->assign('date',     $date->get(Zend_Date::DATE_LONG));
-$phpLiveDocx->assign('time',     $date->get(Zend_Date::TIME_LONG));
-$phpLiveDocx->assign('city',     'Lyon');
-$phpLiveDocx->assign('country',  'France');
+$phpLiveDocx->assign('software', 'Magic Graphical Compression Suite v1.9')
+            ->assign('licensee', 'Daï Lemaitre')
+            ->assign('company',  'Megasoft Co-operation')
+            ->assign('date',     $date->get(Zend_Date::DATE_LONG))
+            ->assign('time',     $date->get(Zend_Date::TIME_LONG))
+            ->assign('city',     'Lyon')
+            ->assign('country',  'France');
 
 $phpLiveDocx->createDocument();
 
@@ -32,7 +32,7 @@ $bitmaps = $phpLiveDocx->getAllBitmaps(100, 'png');      // zoomFactor, format
 //$bitmaps = $phpLiveDocx->getBitmaps(2, 2, 100, 'png');   // fromPage, toPage, zoomFactor, format
 
 foreach ($bitmaps as $pageNumber => $bitmapData) {
-    $filename = sprintf('documentPage%d.png', $pageNumber);
+    $filename = sprintf('document-page-%d.png', $pageNumber);
     file_put_contents($filename, $bitmapData);
 }
 

+ 2 - 2
demos/Zend/Service/LiveDocx/MailMerge/constructors/hosted-licensed.php

@@ -22,8 +22,8 @@ $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
 $phpLiveDocx->setSoapClient($mySoapClient);
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 $phpLiveDocx->getTemplateFormats(); // then call methods as usual
 

+ 2 - 2
demos/Zend/Service/LiveDocx/MailMerge/constructors/public.php

@@ -16,8 +16,8 @@ print(Demos_Zend_Service_LiveDocx_Helper::wrapLine(
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 $phpLiveDocx->getTemplateFormats(); // then call methods as usual
 

+ 11 - 11
demos/Zend/Service/LiveDocx/MailMerge/license-agreement/generate-document-concat.php

@@ -60,7 +60,7 @@ $processor = PROCESSOR_PDFTK;
 
 // Number of documents (populated with random strings) to concatenate.
 
-$iterations = 10;
+$iterations = 3;
 
 // -----------------------------------------------------------------------------
 
@@ -95,8 +95,8 @@ $date->setLocale(Demos_Zend_Service_LiveDocx_Helper::LOCALE);
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 $phpLiveDocx->setLocalTemplate('template.docx');
 
@@ -105,13 +105,13 @@ for ($iteration = 1; $iteration <= $iterations; $iteration ++) {
     $tempFilename = sprintf('%s/%010s.pdf', $tempDirectory, $iteration);
     $tempFilenames[] = $tempFilename;
     
-    $phpLiveDocx->assign('software', randomString());
-    $phpLiveDocx->assign('licensee', randomString());
-    $phpLiveDocx->assign('company',  randomString());
-    $phpLiveDocx->assign('date',     $date->now()->get(Zend_Date::DATE_LONG));
-    $phpLiveDocx->assign('time',     $date->now()->get(Zend_Date::TIME_LONG));
-    $phpLiveDocx->assign('city',     randomString());
-    $phpLiveDocx->assign('country',  randomString());
+    $phpLiveDocx->assign('software', randomString())
+                ->assign('licensee', randomString())
+                ->assign('company',  randomString())
+                ->assign('date',     $date->now()->get(Zend_Date::DATE_LONG))
+                ->assign('time',     $date->now()->get(Zend_Date::TIME_LONG))
+                ->assign('city',     randomString())
+                ->assign('country',  randomString());
         
     $phpLiveDocx->createDocument();
     
@@ -126,7 +126,7 @@ unset($phpLiveDocx, $date);
 
 // Concatenate temporary documents and write output document
 
-$outputFilename = './document.pdf';
+$outputFilename = './document-concat.pdf';
 
 $logger->log('Concatenating temporary documents...', Zend_Log::INFO);
 

+ 9 - 9
demos/Zend/Service/LiveDocx/MailMerge/license-agreement/generate-document.php

@@ -10,18 +10,18 @@ $date->setLocale(Demos_Zend_Service_LiveDocx_Helper::LOCALE);
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 $phpLiveDocx->setLocalTemplate('template.docx');
 
-$phpLiveDocx->assign('software', 'Magic Graphical Compression Suite v1.9');
-$phpLiveDocx->assign('licensee', 'Henry Döner-Meyer');
-$phpLiveDocx->assign('company',  'Co-Operation');
-$phpLiveDocx->assign('date',     $date->get(Zend_Date::DATE_LONG));
-$phpLiveDocx->assign('time',     $date->get(Zend_Date::TIME_LONG));
-$phpLiveDocx->assign('city',     'Berlin');
-$phpLiveDocx->assign('country',  'Germany');
+$phpLiveDocx->assign('software', 'Magic Graphical Compression Suite v1.9')
+            ->assign('licensee', 'Henry Döner-Meyer')
+            ->assign('company',  'Co-Operation')
+            ->assign('date',     $date->get(Zend_Date::DATE_LONG))
+            ->assign('time',     $date->get(Zend_Date::TIME_LONG))
+            ->assign('city',     'Berlin')
+            ->assign('country',  'Germany');
 
 /**
  * ALTERNATIVE: Concatenating PDF files locally - basic

+ 13 - 11
demos/Zend/Service/LiveDocx/MailMerge/metafiles/generate-metafiles.php

@@ -10,16 +10,18 @@ $date->setLocale(Demos_Zend_Service_LiveDocx_Helper::LOCALE);
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
-
-$phpLiveDocx->setFieldValue('software', 'Magic Graphical Compression Suite v1.9');
-$phpLiveDocx->setFieldValue('licensee', 'Henry Döner-Meyer');
-$phpLiveDocx->setFieldValue('company',  'Megasoft Co-operation');
-$phpLiveDocx->setFieldValue('date',     $date->get(Zend_Date::DATE_LONG));
-$phpLiveDocx->setFieldValue('time',     $date->get(Zend_Date::TIME_LONG));
-$phpLiveDocx->setFieldValue('city',     'Bremen');
-$phpLiveDocx->setFieldValue('country',  'Germany');
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+
+$phpLiveDocx->setLocalTemplate('template.docx');
+            
+$phpLiveDocx->setFieldValue('software', 'Magic Graphical Compression Suite v1.9')
+            ->setFieldValue('licensee', 'Henry Döner-Meyer')
+            ->setFieldValue('company',  'Megasoft Co-operation')
+            ->setFieldValue('date',     $date->get(Zend_Date::DATE_LONG))
+            ->setFieldValue('time',     $date->get(Zend_Date::TIME_LONG))
+            ->setFieldValue('city',     'Bremen')
+            ->setFieldValue('country',  'Germany');
 
 $phpLiveDocx->createDocument();
 
@@ -30,7 +32,7 @@ $metaFiles = $phpLiveDocx->getAllMetafiles();
 //$metaFiles = $phpLiveDocx->getMetafiles(1, 2);    // fromPage, toPage
 
 foreach ($metaFiles as $pageNumber => $metaFileData) {
-    $filename = sprintf('documentPage%d.wmf', $pageNumber);
+    $filename = sprintf('document-page-%d.wmf', $pageNumber);
     file_put_contents($filename, $metaFileData);
 }
 

+ 2 - 2
demos/Zend/Service/LiveDocx/MailMerge/supported-fonts/show-supported-fonts-cached.php

@@ -25,8 +25,8 @@ if (! $fonts = $cache->load($cacheId)) {
     
     $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
     
-    $phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-    $phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+    $phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+                ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
     
     $fonts = $phpLiveDocx->getFontNames();
     

+ 2 - 2
demos/Zend/Service/LiveDocx/MailMerge/supported-fonts/show-supported-fonts.php

@@ -6,8 +6,8 @@ require_once dirname(__FILE__) . '/../../common.php';
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 system('clear');
 

+ 2 - 2
demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats-cached.php

@@ -35,8 +35,8 @@ if (! $formats = $cache->load($cacheId)) {
     
     $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
     
-    $phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-    $phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+    $phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+                ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
     
     $formats = new StdClass();
     

+ 2 - 2
demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats.php

@@ -16,8 +16,8 @@ print(Demos_Zend_Service_LiveDocx_Helper::wrapLine(
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 printf("Supported TEMPLATE file formats (input)  : %s%s",
     Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($phpLiveDocx->getTemplateFormats()), PHP_EOL);

+ 6 - 5
demos/Zend/Service/LiveDocx/MailMerge/telephone-bill/generate-document.php

@@ -10,12 +10,13 @@ $date->setLocale(Demos_Zend_Service_LiveDocx_Helper::LOCALE);
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 /*
  * ALTERNATIVE: Specify username and password in constructor
  */
+            
 /*
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge(
     array (
@@ -28,9 +29,9 @@ $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge(
 $phpLiveDocx->setLocalTemplate('template.doc');
 
 
-$phpLiveDocx->assign('customer_number', sprintf("#%'10s",  rand(0,1000000000)));
-$phpLiveDocx->assign('invoice_number',  sprintf("#%'10s",  rand(0,1000000000)));
-$phpLiveDocx->assign('account_number',  sprintf("#%'10s",  rand(0,1000000000)));
+$phpLiveDocx->assign('customer_number', sprintf("#%'10s",  rand(0,1000000000)))
+            ->assign('invoice_number',  sprintf("#%'10s",  rand(0,1000000000)))
+            ->assign('account_number',  sprintf("#%'10s",  rand(0,1000000000)));
 
 
 $billData = array (  

+ 2 - 2
demos/Zend/Service/LiveDocx/MailMerge/template-info/list-template-info.php

@@ -16,8 +16,8 @@ print(Demos_Zend_Service_LiveDocx_Helper::wrapLine(
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 // -----------------------------------------------------------------------------
 

+ 2 - 2
demos/Zend/Service/LiveDocx/MailMerge/templates/delete-all.php

@@ -14,8 +14,8 @@ print(Demos_Zend_Service_LiveDocx_Helper::wrapLine(
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 $counter = 1;
 foreach ($phpLiveDocx->listTemplates() as $result) {

+ 2 - 2
demos/Zend/Service/LiveDocx/MailMerge/templates/download.php

@@ -14,8 +14,8 @@ print(Demos_Zend_Service_LiveDocx_Helper::wrapLine(
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 $counter = 1;
 foreach ($phpLiveDocx->listTemplates() as $result) {

+ 2 - 2
demos/Zend/Service/LiveDocx/MailMerge/templates/list.php

@@ -16,8 +16,8 @@ print(Demos_Zend_Service_LiveDocx_Helper::wrapLine(
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 print(Demos_Zend_Service_LiveDocx_Helper::listDecorator($phpLiveDocx->listTemplates()));
 

+ 2 - 2
demos/Zend/Service/LiveDocx/MailMerge/templates/template-exists.php

@@ -14,8 +14,8 @@ print(Demos_Zend_Service_LiveDocx_Helper::wrapLine(
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 print('Checking whether a template is available... ');
 if (true === $phpLiveDocx->templateExists('template-1.docx')) {

+ 2 - 2
demos/Zend/Service/LiveDocx/MailMerge/templates/upload.php

@@ -14,8 +14,8 @@ print(Demos_Zend_Service_LiveDocx_Helper::wrapLine(
 
 $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
 
-$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME);
-$phpLiveDocx->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
+$phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
+            ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
 
 print('Uploading template... ');
 $phpLiveDocx->uploadTemplate('template-1.docx');