documenthandler.inc.php 897 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. require('includes/PhpWord/Autoloader.php');
  3. \PhpOffice\PhpWord\Autoloader::register();
  4. class DocumentHandler {
  5. private $documentId = NULL;
  6. private $filename = "";
  7. private $documentDraft = "";
  8. private $documentHandle = NULL;
  9. public function __construct($filename, $draft) {
  10. $this->filename = $filename;
  11. $this->documentDraft = $draft;
  12. $this->documentHandle = new \PhpOffice\PhpWord\TemplateProcessor('drafts/' . $this->documentDraft);
  13. }
  14. public function getFilename() {
  15. return $this->filename;
  16. }
  17. public function saveFile() {
  18. $this->documentHandle->saveAs('documents/' . $this->filename);
  19. }
  20. public function getVariables() {
  21. return $this->documentHandle->getVariables();
  22. }
  23. public function setVal($key, $val) {
  24. $this->documentHandle->setValue($key, $val);
  25. }
  26. }
  27. ?>