list-template-info.php 2.3 KB

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