No Description

Footer.php 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
  12. *
  13. * @link https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2014 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Writer\Word2007\Part;
  18. use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
  19. /**
  20. * Word2007 footer part writer: word/footerx.xml
  21. */
  22. class Footer extends AbstractPart
  23. {
  24. /**
  25. * Root element name
  26. *
  27. * @var string
  28. */
  29. protected $rootElement = 'w:ftr';
  30. /**
  31. * Footer/header element to be written
  32. *
  33. * @var \PhpOffice\PhpWord\Element\Footer
  34. */
  35. protected $element;
  36. /**
  37. * Write part
  38. *
  39. * @return string
  40. */
  41. public function write()
  42. {
  43. $xmlWriter = $this->getXmlWriter();
  44. $drawingSchema = 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing';
  45. $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
  46. $xmlWriter->startElement($this->rootElement);
  47. $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
  48. $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
  49. $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
  50. $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
  51. $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
  52. $xmlWriter->writeAttribute('xmlns:wp', $drawingSchema);
  53. $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
  54. $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
  55. $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
  56. $containerWriter = new Container($xmlWriter, $this->element);
  57. $containerWriter->write();
  58. $xmlWriter->endElement(); // $this->rootElement
  59. return $xmlWriter->getData();
  60. }
  61. /**
  62. * Set element
  63. *
  64. * @param \PhpOffice\PhpWord\Element\Footer|\PhpOffice\PhpWord\Element\Header $element
  65. * @return self
  66. */
  67. public function setElement($element)
  68. {
  69. $this->element = $element;
  70. return $this;
  71. }
  72. }