list-template-info.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. require_once dirname(__FILE__) . '/../../common.php';
  3. system('clear');
  4. print(Demos_Zend_Service_LiveDocx_Helper::wrapLine(
  5. PHP_EOL . 'Field and Block Field Names (merge fields)' .
  6. PHP_EOL .
  7. PHP_EOL . 'The following templates contain the listed field or block field names:' .
  8. PHP_EOL .
  9. PHP_EOL)
  10. );
  11. $mailMerge = new Zend_Service_LiveDocx_MailMerge();
  12. $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)
  13. ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
  14. // -----------------------------------------------------------------------------
  15. $templateName = 'template-1-text-field.docx';
  16. $mailMerge->setLocalTemplate($templateName);
  17. printf('Field names in %s:%s', $templateName, PHP_EOL);
  18. $fieldNames = $mailMerge->getFieldNames();
  19. foreach ($fieldNames as $fieldName) {
  20. printf('- %s%s', $fieldName, PHP_EOL);
  21. }
  22. // -----------------------------------------------------------------------------
  23. $templateName = 'template-2-text-fields.doc';
  24. $mailMerge->setLocalTemplate($templateName);
  25. printf('%sField names in %s:%s', PHP_EOL, $templateName, PHP_EOL);
  26. $fieldNames = $mailMerge->getFieldNames();
  27. foreach ($fieldNames as $fieldName) {
  28. printf('- %s%s', $fieldName, PHP_EOL);
  29. }
  30. // -----------------------------------------------------------------------------
  31. $templateName = 'template-block-fields.doc';
  32. $mailMerge->setLocalTemplate($templateName);
  33. printf('%sField names in %s:%s', PHP_EOL, $templateName, PHP_EOL);
  34. $fieldNames = $mailMerge->getFieldNames();
  35. foreach ($fieldNames as $fieldName) {
  36. printf('- %s%s', $fieldName, PHP_EOL);
  37. }
  38. printf('%sBlock names in %s:%s', PHP_EOL, $templateName, PHP_EOL);
  39. $blockNames = $mailMerge->getBlockNames();
  40. foreach ($blockNames as $blockName) {
  41. printf('- %s%s', $blockName, PHP_EOL);
  42. }
  43. printf('%sBlock field names in %s:%s', PHP_EOL, $templateName, PHP_EOL);
  44. foreach ($blockNames as $blockName) {
  45. $blockFieldNames = $mailMerge->getBlockFieldNames($blockName);
  46. foreach ($blockFieldNames as $blockFieldName) {
  47. printf('- %s::%s%s', $blockName, $blockFieldName, PHP_EOL);
  48. }
  49. }
  50. print(PHP_EOL);
  51. // -----------------------------------------------------------------------------
  52. unset($mailMerge);