ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
DocumentProperties.php
Go to the documentation of this file.
1<?php
37{
42 const PROPERTY_TYPE_DATE = 'd';
45
51 private $_creator = 'Unknown Creator';
52
59
65 private $_created;
66
72 private $_modified;
73
79 private $_title = 'Untitled Spreadsheet';
80
86 private $_description = '';
87
93 private $_subject = '';
94
100 private $_keywords = '';
101
107 private $_category = '';
108
114 private $_manager = '';
115
121 private $_company = 'Microsoft Corporation';
122
128 private $_customProperties = array();
129
130
134 public function __construct()
135 {
136 // Initialise values
137 $this->_lastModifiedBy = $this->_creator;
138 $this->_created = time();
139 $this->_modified = time();
140 }
141
147 public function getCreator() {
148 return $this->_creator;
149 }
150
157 public function setCreator($pValue = '') {
158 $this->_creator = $pValue;
159 return $this;
160 }
161
167 public function getLastModifiedBy() {
169 }
170
177 public function setLastModifiedBy($pValue = '') {
178 $this->_lastModifiedBy = $pValue;
179 return $this;
180 }
181
187 public function getCreated() {
188 return $this->_created;
189 }
190
197 public function setCreated($pValue = null) {
198 if ($pValue === NULL) {
199 $pValue = time();
200 } elseif (is_string($pValue)) {
201 if (is_numeric($pValue)) {
202 $pValue = intval($pValue);
203 } else {
204 $pValue = strtotime($pValue);
205 }
206 }
207
208 $this->_created = $pValue;
209 return $this;
210 }
211
217 public function getModified() {
218 return $this->_modified;
219 }
220
227 public function setModified($pValue = null) {
228 if ($pValue === NULL) {
229 $pValue = time();
230 } elseif (is_string($pValue)) {
231 if (is_numeric($pValue)) {
232 $pValue = intval($pValue);
233 } else {
234 $pValue = strtotime($pValue);
235 }
236 }
237
238 $this->_modified = $pValue;
239 return $this;
240 }
241
247 public function getTitle() {
248 return $this->_title;
249 }
250
257 public function setTitle($pValue = '') {
258 $this->_title = $pValue;
259 return $this;
260 }
261
267 public function getDescription() {
268 return $this->_description;
269 }
270
277 public function setDescription($pValue = '') {
278 $this->_description = $pValue;
279 return $this;
280 }
281
287 public function getSubject() {
288 return $this->_subject;
289 }
290
297 public function setSubject($pValue = '') {
298 $this->_subject = $pValue;
299 return $this;
300 }
301
307 public function getKeywords() {
308 return $this->_keywords;
309 }
310
317 public function setKeywords($pValue = '') {
318 $this->_keywords = $pValue;
319 return $this;
320 }
321
327 public function getCategory() {
328 return $this->_category;
329 }
330
337 public function setCategory($pValue = '') {
338 $this->_category = $pValue;
339 return $this;
340 }
341
347 public function getCompany() {
348 return $this->_company;
349 }
350
357 public function setCompany($pValue = '') {
358 $this->_company = $pValue;
359 return $this;
360 }
361
367 public function getManager() {
368 return $this->_manager;
369 }
370
377 public function setManager($pValue = '') {
378 $this->_manager = $pValue;
379 return $this;
380 }
381
387 public function getCustomProperties() {
388 return array_keys($this->_customProperties);
389 }
390
397 public function isCustomPropertySet($propertyName) {
398 return isset($this->_customProperties[$propertyName]);
399 }
400
407 public function getCustomPropertyValue($propertyName) {
408 if (isset($this->_customProperties[$propertyName])) {
409 return $this->_customProperties[$propertyName]['value'];
410 }
411
412 }
413
420 public function getCustomPropertyType($propertyName) {
421 if (isset($this->_customProperties[$propertyName])) {
422 return $this->_customProperties[$propertyName]['type'];
423 }
424
425 }
426
440 public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) {
441 if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,
442 self::PROPERTY_TYPE_FLOAT,
443 self::PROPERTY_TYPE_STRING,
444 self::PROPERTY_TYPE_DATE,
445 self::PROPERTY_TYPE_BOOLEAN)))) {
446 if ($propertyValue === NULL) {
447 $propertyType = self::PROPERTY_TYPE_STRING;
448 } elseif (is_float($propertyValue)) {
449 $propertyType = self::PROPERTY_TYPE_FLOAT;
450 } elseif(is_int($propertyValue)) {
451 $propertyType = self::PROPERTY_TYPE_INTEGER;
452 } elseif (is_bool($propertyValue)) {
453 $propertyType = self::PROPERTY_TYPE_BOOLEAN;
454 } else {
455 $propertyType = self::PROPERTY_TYPE_STRING;
456 }
457 }
458
459 $this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType);
460 return $this;
461 }
462
466 public function __clone() {
467 $vars = get_object_vars($this);
468 foreach ($vars as $key => $value) {
469 if (is_object($value)) {
470 $this->$key = clone $value;
471 } else {
472 $this->$key = $value;
473 }
474 }
475 }
476
477 public static function convertProperty($propertyValue,$propertyType) {
478 switch ($propertyType) {
479 case 'empty' : // Empty
480 return '';
481 break;
482 case 'null' : // Null
483 return NULL;
484 break;
485 case 'i1' : // 1-Byte Signed Integer
486 case 'i2' : // 2-Byte Signed Integer
487 case 'i4' : // 4-Byte Signed Integer
488 case 'i8' : // 8-Byte Signed Integer
489 case 'int' : // Integer
490 return (int) $propertyValue;
491 break;
492 case 'ui1' : // 1-Byte Unsigned Integer
493 case 'ui2' : // 2-Byte Unsigned Integer
494 case 'ui4' : // 4-Byte Unsigned Integer
495 case 'ui8' : // 8-Byte Unsigned Integer
496 case 'uint' : // Unsigned Integer
497 return abs((int) $propertyValue);
498 break;
499 case 'r4' : // 4-Byte Real Number
500 case 'r8' : // 8-Byte Real Number
501 case 'decimal' : // Decimal
502 return (float) $propertyValue;
503 break;
504 case 'lpstr' : // LPSTR
505 case 'lpwstr' : // LPWSTR
506 case 'bstr' : // Basic String
507 return $propertyValue;
508 break;
509 case 'date' : // Date and Time
510 case 'filetime' : // File Time
511 return strtotime($propertyValue);
512 break;
513 case 'bool' : // Boolean
514 return ($propertyValue == 'true') ? True : False;
515 break;
516 case 'cy' : // Currency
517 case 'error' : // Error Status Code
518 case 'vector' : // Vector
519 case 'array' : // Array
520 case 'blob' : // Binary Blob
521 case 'oblob' : // Binary Blob Object
522 case 'stream' : // Binary Stream
523 case 'ostream' : // Binary Stream Object
524 case 'storage' : // Binary Storage
525 case 'ostorage' : // Binary Storage Object
526 case 'vstream' : // Binary Versioned Stream
527 case 'clsid' : // Class ID
528 case 'cf' : // Clipboard Data
529 return $propertyValue;
530 break;
531 }
532 return $propertyValue;
533 }
534
535 public static function convertPropertyType($propertyType) {
536 switch ($propertyType) {
537 case 'i1' : // 1-Byte Signed Integer
538 case 'i2' : // 2-Byte Signed Integer
539 case 'i4' : // 4-Byte Signed Integer
540 case 'i8' : // 8-Byte Signed Integer
541 case 'int' : // Integer
542 case 'ui1' : // 1-Byte Unsigned Integer
543 case 'ui2' : // 2-Byte Unsigned Integer
544 case 'ui4' : // 4-Byte Unsigned Integer
545 case 'ui8' : // 8-Byte Unsigned Integer
546 case 'uint' : // Unsigned Integer
548 break;
549 case 'r4' : // 4-Byte Real Number
550 case 'r8' : // 8-Byte Real Number
551 case 'decimal' : // Decimal
553 break;
554 case 'empty' : // Empty
555 case 'null' : // Null
556 case 'lpstr' : // LPSTR
557 case 'lpwstr' : // LPWSTR
558 case 'bstr' : // Basic String
560 break;
561 case 'date' : // Date and Time
562 case 'filetime' : // File Time
564 break;
565 case 'bool' : // Boolean
567 break;
568 case 'cy' : // Currency
569 case 'error' : // Error Status Code
570 case 'vector' : // Vector
571 case 'array' : // Array
572 case 'blob' : // Binary Blob
573 case 'oblob' : // Binary Blob Object
574 case 'stream' : // Binary Stream
575 case 'ostream' : // Binary Stream Object
576 case 'storage' : // Binary Storage
577 case 'ostorage' : // Binary Storage Object
578 case 'vstream' : // Binary Versioned Stream
579 case 'clsid' : // Class ID
580 case 'cf' : // Clipboard Data
582 break;
583 }
585 }
586
587}
An exception for terminatinating execution or to throw for unit testing.
setCreator($pValue='')
Set Creator.
__construct()
Create a new PHPExcel_DocumentProperties.
setKeywords($pValue='')
Set Keywords.
getCustomProperties()
Get a List of Custom Property Names.
setDescription($pValue='')
Set Description.
setCategory($pValue='')
Set Category.
setLastModifiedBy($pValue='')
Set Last Modified By.
setCustomProperty($propertyName, $propertyValue='', $propertyType=NULL)
Set a Custom Property.
getCustomPropertyType($propertyName)
Get a Custom Property Type.
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
setSubject($pValue='')
Set Subject.
setTitle($pValue='')
Set Title.
isCustomPropertySet($propertyName)
Check if a Custom Property is defined.
setManager($pValue='')
Set Manager.
setModified($pValue=null)
Set Modified.
getLastModifiedBy()
Get Last Modified By.
getCustomPropertyValue($propertyName)
Get a Custom Property Value.
setCreated($pValue=null)
Set Created.
setCompany($pValue='')
Set Company.
static convertPropertyType($propertyType)
static convertProperty($propertyValue, $propertyType)
$key
Definition: croninfo.php:18