1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26:
27:
28: 29: 30:
31: class extends PHPWord_Writer_Word2007_Base
32: {
33:
34: public function (PHPWord_Section_Header $header)
35: {
36:
37: if ($this->getParentWriter()->getUseDiskCaching()) {
38: $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
39: } else {
40: $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
41: }
42:
43:
44: $objWriter->startDocument('1.0', 'UTF-8', 'yes');
45:
46: $objWriter->startElement('w:hdr');
47: $objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
48: $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
49: $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
50: $objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
51: $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
52: $objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
53: $objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
54: $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
55: $objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
56:
57:
58: $_elements = $header->getElements();
59:
60: foreach ($_elements as $element) {
61: if ($element instanceof PHPWord_Section_Text) {
62: $this->_writeText($objWriter, $element);
63: } elseif ($element instanceof PHPWord_Section_TextRun) {
64: $this->_writeTextRun($objWriter, $element);
65: } elseif ($element instanceof PHPWord_Section_TextBreak) {
66: $this->_writeTextBreak($objWriter);
67: } elseif ($element instanceof PHPWord_Section_Table) {
68: $this->_writeTable($objWriter, $element);
69: } elseif ($element instanceof PHPWord_Section_Image ||
70: $element instanceof PHPWord_Section_MemoryImage
71: ) {
72: if (!$element->getIsWatermark()) {
73: $this->_writeImage($objWriter, $element);
74: } else {
75: $this->_writeWatermark($objWriter, $element);
76: }
77: } elseif ($element instanceof PHPWord_Section_Footer_PreserveText) {
78: $this->_writePreserveText($objWriter, $element);
79: }
80: }
81:
82: $objWriter->endElement();
83:
84:
85: return $objWriter->getData();
86: }
87: }
88: