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
32: {
33:
34: 35: 36: 37: 38:
39: private ;
40:
41: 42: 43: 44: 45:
46: private $_rId;
47:
48: 49: 50: 51: 52:
53: private $_elementCollection = array();
54:
55: 56: 57:
58: public function __construct($sectionCount)
59: {
60: $this->_footerCount = $sectionCount;
61: }
62:
63: 64: 65: 66: 67: 68: 69: 70:
71: public function addText($text, $styleFont = null, $styleParagraph = null)
72: {
73: if (!PHPWord_Shared_String::IsUTF8($text)) {
74: $text = utf8_encode($text);
75: }
76: $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
77: $this->_elementCollection[] = $text;
78: return $text;
79: }
80:
81: 82: 83: 84: 85:
86: public function addTextBreak($count = 1)
87: {
88: for ($i = 1; $i <= $count; $i++) {
89: $this->_elementCollection[] = new PHPWord_Section_TextBreak();
90: }
91: }
92:
93: 94: 95: 96: 97:
98: public function createTextRun($styleParagraph = null)
99: {
100: $textRun = new PHPWord_Section_TextRun($styleParagraph);
101: $this->_elementCollection[] = $textRun;
102: return $textRun;
103: }
104:
105: 106: 107: 108: 109: 110:
111: public function addTable($style = null)
112: {
113: $table = new PHPWord_Section_Table('footer', $this->_footerCount, $style);
114: $this->_elementCollection[] = $table;
115: return $table;
116: }
117:
118: 119: 120: 121: 122: 123: 124:
125: public function addImage($src, $style = null)
126: {
127: $image = new PHPWord_Section_Image($src, $style);
128:
129: if (!is_null($image->getSource())) {
130: $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $src);
131: $image->setRelationId($rID);
132:
133: $this->_elementCollection[] = $image;
134: return $image;
135: } else {
136: trigger_error('Src does not exist or invalid image type.', E_USER_ERROR);
137: }
138: }
139:
140: 141: 142: 143: 144: 145: 146:
147: public function addMemoryImage($link, $style = null)
148: {
149: $memoryImage = new PHPWord_Section_MemoryImage($link, $style);
150: if (!is_null($memoryImage->getSource())) {
151: $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage);
152: $memoryImage->setRelationId($rID);
153:
154: $this->_elementCollection[] = $memoryImage;
155: return $memoryImage;
156: } else {
157: trigger_error('Unsupported image type.');
158: }
159: }
160:
161: 162: 163: 164: 165: 166: 167: 168:
169: public function addPreserveText($text, $styleFont = null, $styleParagraph = null)
170: {
171: if (!PHPWord_Shared_String::IsUTF8($text)) {
172: $text = utf8_encode($text);
173: }
174: $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph);
175: $this->_elementCollection[] = $ptext;
176: return $ptext;
177: }
178:
179: 180: 181:
182: public function getRelationId()
183: {
184: return $this->_rId;
185: }
186:
187: 188: 189: 190: 191:
192: public function setRelationId($rId)
193: {
194: $this->_rId = $rId;
195: }
196:
197: 198: 199:
200: public function getElements()
201: {
202: return $this->_elementCollection;
203: }
204:
205: 206: 207:
208: public function ()
209: {
210: return $this->_footerCount;
211: }
212: }