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