|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of PHPPresentation - A pure PHP library for reading and writing |
|
4
|
|
|
* presentations documents. |
|
5
|
|
|
* |
|
6
|
|
|
* PHPPresentation 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/PHPPresentation/contributors. |
|
12
|
|
|
* |
|
13
|
|
|
* @link https://github.com/PHPOffice/PHPPresentation |
|
14
|
|
|
* @copyright 2009-2015 PHPPresentation contributors |
|
15
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace PhpOffice\PhpPresentation; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* \PhpOffice\PhpPresentation\DocumentProperties |
|
22
|
|
|
*/ |
|
23
|
|
|
class DocumentProperties |
|
24
|
|
|
{ |
|
25
|
|
|
/** Constants */ |
|
26
|
|
|
const PROPERTY_TYPE_BOOLEAN = 'b'; |
|
27
|
|
|
const PROPERTY_TYPE_INTEGER = 'i'; |
|
28
|
|
|
const PROPERTY_TYPE_FLOAT = 'f'; |
|
29
|
|
|
const PROPERTY_TYPE_DATE = 'd'; |
|
30
|
|
|
const PROPERTY_TYPE_STRING = 's'; |
|
31
|
|
|
const PROPERTY_TYPE_UNKNOWN = 'u'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Creator |
|
35
|
|
|
* |
|
36
|
|
|
* @var string |
|
37
|
|
|
*/ |
|
38
|
|
|
private $creator; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* LastModifiedBy |
|
42
|
|
|
* |
|
43
|
|
|
* @var string |
|
44
|
|
|
*/ |
|
45
|
|
|
private $lastModifiedBy; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Created |
|
49
|
|
|
* |
|
50
|
|
|
* @var int |
|
51
|
|
|
*/ |
|
52
|
|
|
private $created; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Modified |
|
56
|
|
|
* |
|
57
|
|
|
* @var int |
|
58
|
|
|
*/ |
|
59
|
|
|
private $modified; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Title |
|
63
|
|
|
* |
|
64
|
|
|
* @var string |
|
65
|
|
|
*/ |
|
66
|
|
|
private $title; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Description |
|
70
|
|
|
* |
|
71
|
|
|
* @var string |
|
72
|
|
|
*/ |
|
73
|
|
|
private $description; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Subject |
|
77
|
|
|
* |
|
78
|
|
|
* @var string |
|
79
|
|
|
*/ |
|
80
|
|
|
private $subject; |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Keywords |
|
84
|
|
|
* |
|
85
|
|
|
* @var string |
|
86
|
|
|
*/ |
|
87
|
|
|
private $keywords; |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Category |
|
91
|
|
|
* |
|
92
|
|
|
* @var string |
|
93
|
|
|
*/ |
|
94
|
|
|
private $category; |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Company |
|
98
|
|
|
* |
|
99
|
|
|
* @var string |
|
100
|
|
|
*/ |
|
101
|
|
|
private $company; |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Custom Properties. |
|
105
|
|
|
* |
|
106
|
|
|
* @var string[] |
|
107
|
|
|
*/ |
|
108
|
|
|
private $customProperties = array(); |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Create a new \PhpOffice\PhpPresentation\DocumentProperties |
|
112
|
|
|
*/ |
|
113
|
234 |
|
public function __construct() |
|
114
|
|
|
{ |
|
115
|
|
|
// Initialise values |
|
116
|
234 |
|
$this->creator = 'Unknown Creator'; |
|
117
|
234 |
|
$this->lastModifiedBy = $this->creator; |
|
118
|
234 |
|
$this->created = time(); |
|
119
|
234 |
|
$this->modified = time(); |
|
120
|
234 |
|
$this->title = "Untitled Presentation"; |
|
121
|
234 |
|
$this->subject = ''; |
|
122
|
234 |
|
$this->description = ''; |
|
123
|
234 |
|
$this->keywords = ''; |
|
124
|
234 |
|
$this->category = ''; |
|
125
|
234 |
|
$this->company = 'Microsoft Corporation'; |
|
126
|
234 |
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Get Creator |
|
130
|
|
|
* |
|
131
|
|
|
* @return string |
|
132
|
|
|
*/ |
|
133
|
188 |
|
public function getCreator() |
|
134
|
|
|
{ |
|
135
|
188 |
|
return $this->creator; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* Set Creator |
|
140
|
|
|
* |
|
141
|
|
|
* @param string $pValue |
|
142
|
|
|
* @return \PhpOffice\PhpPresentation\DocumentProperties |
|
143
|
|
|
*/ |
|
144
|
7 |
|
public function setCreator($pValue = '') |
|
145
|
|
|
{ |
|
146
|
7 |
|
$this->creator = $pValue; |
|
147
|
|
|
|
|
148
|
7 |
|
return $this; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* Get Last Modified By |
|
153
|
|
|
* |
|
154
|
|
|
* @return string |
|
155
|
|
|
*/ |
|
156
|
188 |
|
public function getLastModifiedBy() |
|
157
|
|
|
{ |
|
158
|
188 |
|
return $this->lastModifiedBy; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* Set Last Modified By |
|
163
|
|
|
* |
|
164
|
|
|
* @param string $pValue |
|
165
|
|
|
* @return \PhpOffice\PhpPresentation\DocumentProperties |
|
166
|
|
|
*/ |
|
167
|
6 |
|
public function setLastModifiedBy($pValue = '') |
|
168
|
|
|
{ |
|
169
|
6 |
|
$this->lastModifiedBy = $pValue; |
|
170
|
|
|
|
|
171
|
6 |
|
return $this; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* Get Created |
|
176
|
|
|
* |
|
177
|
|
|
* @return int |
|
178
|
|
|
*/ |
|
179
|
187 |
|
public function getCreated() |
|
180
|
|
|
{ |
|
181
|
187 |
|
return $this->created; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* Set Created |
|
186
|
|
|
* |
|
187
|
|
|
* @param int $pValue |
|
188
|
|
|
* @return \PhpOffice\PhpPresentation\DocumentProperties |
|
189
|
|
|
*/ |
|
190
|
9 |
|
public function setCreated($pValue = null) |
|
191
|
|
|
{ |
|
192
|
9 |
|
if (is_null($pValue)) { |
|
193
|
1 |
|
$pValue = time(); |
|
194
|
|
|
} |
|
195
|
9 |
|
$this->created = $pValue; |
|
196
|
|
|
|
|
197
|
9 |
|
return $this; |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* Get Modified |
|
202
|
|
|
* |
|
203
|
|
|
* @return int |
|
204
|
|
|
*/ |
|
205
|
187 |
|
public function getModified() |
|
206
|
|
|
{ |
|
207
|
187 |
|
return $this->modified; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* Set Modified |
|
212
|
|
|
* |
|
213
|
|
|
* @param int $pValue |
|
214
|
|
|
* @return \PhpOffice\PhpPresentation\DocumentProperties |
|
215
|
|
|
*/ |
|
216
|
9 |
|
public function setModified($pValue = null) |
|
217
|
|
|
{ |
|
218
|
9 |
|
if (is_null($pValue)) { |
|
219
|
1 |
|
$pValue = time(); |
|
220
|
|
|
} |
|
221
|
9 |
|
$this->modified = $pValue; |
|
222
|
|
|
|
|
223
|
9 |
|
return $this; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* Get Title |
|
228
|
|
|
* |
|
229
|
|
|
* @return string |
|
230
|
|
|
*/ |
|
231
|
188 |
|
public function getTitle() |
|
232
|
|
|
{ |
|
233
|
188 |
|
return $this->title; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
/** |
|
237
|
|
|
* Set Title |
|
238
|
|
|
* |
|
239
|
|
|
* @param string $pValue |
|
240
|
|
|
* @return \PhpOffice\PhpPresentation\DocumentProperties |
|
241
|
|
|
*/ |
|
242
|
7 |
|
public function setTitle($pValue = '') |
|
243
|
|
|
{ |
|
244
|
7 |
|
$this->title = $pValue; |
|
245
|
|
|
|
|
246
|
7 |
|
return $this; |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* Get Description |
|
251
|
|
|
* |
|
252
|
|
|
* @return string |
|
253
|
|
|
*/ |
|
254
|
188 |
|
public function getDescription() |
|
255
|
|
|
{ |
|
256
|
188 |
|
return $this->description; |
|
257
|
|
|
} |
|
258
|
|
|
|
|
259
|
|
|
/** |
|
260
|
|
|
* Set Description |
|
261
|
|
|
* |
|
262
|
|
|
* @param string $pValue |
|
263
|
|
|
* @return \PhpOffice\PhpPresentation\DocumentProperties |
|
264
|
|
|
*/ |
|
265
|
6 |
|
public function setDescription($pValue = '') |
|
266
|
|
|
{ |
|
267
|
6 |
|
$this->description = $pValue; |
|
268
|
|
|
|
|
269
|
6 |
|
return $this; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* Get Subject |
|
274
|
|
|
* |
|
275
|
|
|
* @return string |
|
276
|
|
|
*/ |
|
277
|
188 |
|
public function getSubject() |
|
278
|
|
|
{ |
|
279
|
188 |
|
return $this->subject; |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
/** |
|
283
|
|
|
* Set Subject |
|
284
|
|
|
* |
|
285
|
|
|
* @param string $pValue |
|
286
|
|
|
* @return \PhpOffice\PhpPresentation\DocumentProperties |
|
287
|
|
|
*/ |
|
288
|
6 |
|
public function setSubject($pValue = '') |
|
289
|
|
|
{ |
|
290
|
6 |
|
$this->subject = $pValue; |
|
291
|
|
|
|
|
292
|
6 |
|
return $this; |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
/** |
|
296
|
|
|
* Get Keywords |
|
297
|
|
|
* |
|
298
|
|
|
* @return string |
|
299
|
|
|
*/ |
|
300
|
188 |
|
public function getKeywords() |
|
301
|
|
|
{ |
|
302
|
188 |
|
return $this->keywords; |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
/** |
|
306
|
|
|
* Set Keywords |
|
307
|
|
|
* |
|
308
|
|
|
* @param string $pValue |
|
309
|
|
|
* @return \PhpOffice\PhpPresentation\DocumentProperties |
|
310
|
|
|
*/ |
|
311
|
6 |
|
public function setKeywords($pValue = '') |
|
312
|
|
|
{ |
|
313
|
6 |
|
$this->keywords = $pValue; |
|
314
|
|
|
|
|
315
|
6 |
|
return $this; |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
/** |
|
319
|
|
|
* Get Category |
|
320
|
|
|
* |
|
321
|
|
|
* @return string |
|
322
|
|
|
*/ |
|
323
|
124 |
|
public function getCategory() |
|
324
|
|
|
{ |
|
325
|
124 |
|
return $this->category; |
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
/** |
|
329
|
|
|
* Set Category |
|
330
|
|
|
* |
|
331
|
|
|
* @param string $pValue |
|
332
|
|
|
* @return \PhpOffice\PhpPresentation\DocumentProperties |
|
333
|
|
|
*/ |
|
334
|
5 |
|
public function setCategory($pValue = '') |
|
335
|
|
|
{ |
|
336
|
5 |
|
$this->category = $pValue; |
|
337
|
|
|
|
|
338
|
5 |
|
return $this; |
|
339
|
|
|
} |
|
340
|
|
|
|
|
341
|
|
|
/** |
|
342
|
|
|
* Get Company |
|
343
|
|
|
* |
|
344
|
|
|
* @return string |
|
345
|
|
|
*/ |
|
346
|
123 |
|
public function getCompany() |
|
347
|
|
|
{ |
|
348
|
123 |
|
return $this->company; |
|
349
|
|
|
} |
|
350
|
|
|
|
|
351
|
|
|
/** |
|
352
|
|
|
* Set Company |
|
353
|
|
|
* |
|
354
|
|
|
* @param string $pValue |
|
355
|
|
|
* @return \PhpOffice\PhpPresentation\DocumentProperties |
|
356
|
|
|
*/ |
|
357
|
2 |
|
public function setCompany($pValue = '') |
|
358
|
|
|
{ |
|
359
|
2 |
|
$this->company = $pValue; |
|
360
|
|
|
|
|
361
|
2 |
|
return $this; |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
/** |
|
365
|
|
|
* Get a List of Custom Property Names. |
|
366
|
|
|
* |
|
367
|
|
|
* @return array of string |
|
368
|
|
|
*/ |
|
369
|
123 |
|
public function getCustomProperties() |
|
370
|
|
|
{ |
|
371
|
123 |
|
return array_keys($this->customProperties); |
|
372
|
|
|
} |
|
373
|
|
|
|
|
374
|
|
|
/** |
|
375
|
|
|
* Check if a Custom Property is defined. |
|
376
|
|
|
* |
|
377
|
|
|
* @param string $propertyName |
|
378
|
|
|
* |
|
379
|
|
|
* @return bool |
|
380
|
|
|
*/ |
|
381
|
1 |
|
public function isCustomPropertySet($propertyName) |
|
382
|
|
|
{ |
|
383
|
1 |
|
return isset($this->customProperties[$propertyName]); |
|
384
|
|
|
} |
|
385
|
|
|
|
|
386
|
|
|
/** |
|
387
|
|
|
* Get a Custom Property Value. |
|
388
|
|
|
* |
|
389
|
|
|
* @param string $propertyName |
|
390
|
|
|
* |
|
391
|
|
|
* @return string |
|
392
|
|
|
*/ |
|
393
|
8 |
|
public function getCustomPropertyValue($propertyName) |
|
394
|
|
|
{ |
|
395
|
8 |
|
if (isset($this->customProperties[$propertyName])) { |
|
396
|
8 |
|
return $this->customProperties[$propertyName]['value']; |
|
397
|
|
|
} |
|
398
|
1 |
|
return null; |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
/** |
|
402
|
|
|
* Get a Custom Property Type. |
|
403
|
|
|
* |
|
404
|
|
|
* @param string $propertyName |
|
405
|
|
|
* |
|
406
|
|
|
* @return string |
|
407
|
|
|
*/ |
|
408
|
8 |
|
public function getCustomPropertyType($propertyName) |
|
409
|
|
|
{ |
|
410
|
8 |
|
if (isset($this->customProperties[$propertyName])) { |
|
411
|
8 |
|
return $this->customProperties[$propertyName]['type']; |
|
412
|
|
|
} |
|
413
|
1 |
|
return null; |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
/** |
|
417
|
|
|
* Set a Custom Property. |
|
418
|
|
|
* |
|
419
|
|
|
* @param string $propertyName |
|
420
|
|
|
* @param mixed $propertyValue |
|
421
|
|
|
* @param string $propertyType |
|
422
|
|
|
* 'i' : Integer |
|
423
|
|
|
* 'f' : Floating Point |
|
424
|
|
|
* 's' : String |
|
425
|
|
|
* 'd' : Date/Time |
|
426
|
|
|
* 'b' : Boolean |
|
427
|
|
|
* |
|
428
|
|
|
* @return $this |
|
429
|
|
|
*/ |
|
430
|
8 |
|
public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null) |
|
431
|
|
|
{ |
|
432
|
8 |
|
if (($propertyType === null) |
|
433
|
3 |
|
|| (!in_array($propertyType, array( |
|
434
|
3 |
|
self::PROPERTY_TYPE_INTEGER, |
|
435
|
3 |
|
self::PROPERTY_TYPE_FLOAT, |
|
436
|
3 |
|
self::PROPERTY_TYPE_STRING, |
|
437
|
3 |
|
self::PROPERTY_TYPE_DATE, |
|
438
|
8 |
|
self::PROPERTY_TYPE_BOOLEAN, |
|
439
|
|
|
)))) { |
|
440
|
7 |
|
if ($propertyValue === null) { |
|
441
|
2 |
|
$propertyType = self::PROPERTY_TYPE_STRING; |
|
442
|
6 |
|
} elseif (is_float($propertyValue)) { |
|
443
|
2 |
|
$propertyType = self::PROPERTY_TYPE_FLOAT; |
|
444
|
5 |
|
} elseif (is_int($propertyValue)) { |
|
445
|
2 |
|
$propertyType = self::PROPERTY_TYPE_INTEGER; |
|
446
|
4 |
|
} elseif (is_bool($propertyValue)) { |
|
447
|
2 |
|
$propertyType = self::PROPERTY_TYPE_BOOLEAN; |
|
448
|
|
|
} else { |
|
449
|
3 |
|
$propertyType = self::PROPERTY_TYPE_STRING; |
|
450
|
|
|
} |
|
451
|
|
|
} |
|
452
|
8 |
|
$this->customProperties[$propertyName] = [ |
|
453
|
8 |
|
'value' => $propertyValue, |
|
454
|
8 |
|
'type' => $propertyType, |
|
455
|
|
|
]; |
|
456
|
8 |
|
return $this; |
|
457
|
|
|
} |
|
458
|
|
|
} |
|
459
|
|
|
|