Subversion Repositories eFlore/Applications.cel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2390 jpm 1
<?php
2
/**
3
 * PHPExcel
4
 *
5
 * Copyright (c) 2006 - 2013 PHPExcel
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
 *
21
 * @category    PHPExcel
22
 * @package    PHPExcel
23
 * @copyright    Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
24
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
25
 * @version    ##VERSION##, ##DATE##
26
 */
27
 
28
 
29
/**
30
 * PHPExcel_DocumentProperties
31
 *
32
 * @category    PHPExcel
33
 * @package        PHPExcel
34
 * @copyright    Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
35
 */
36
class PHPExcel_DocumentProperties
37
{
38
    /** constants */
39
    const PROPERTY_TYPE_BOOLEAN	= 'b';
40
    const PROPERTY_TYPE_INTEGER = 'i';
41
    const PROPERTY_TYPE_FLOAT   = 'f';
42
    const PROPERTY_TYPE_DATE    = 'd';
43
    const PROPERTY_TYPE_STRING  = 's';
44
    const PROPERTY_TYPE_UNKNOWN = 'u';
45
 
46
    /**
47
     * Creator
48
     *
49
     * @var string
50
     */
51
    private $_creator    = 'Unknown Creator';
52
 
53
    /**
54
     * LastModifiedBy
55
     *
56
     * @var string
57
     */
58
    private $_lastModifiedBy;
59
 
60
    /**
61
     * Created
62
     *
63
     * @var datetime
64
     */
65
    private $_created;
66
 
67
    /**
68
     * Modified
69
     *
70
     * @var datetime
71
     */
72
    private $_modified;
73
 
74
    /**
75
     * Title
76
     *
77
     * @var string
78
     */
79
    private $_title            = 'Untitled Spreadsheet';
80
 
81
    /**
82
     * Description
83
     *
84
     * @var string
85
     */
86
    private $_description    = '';
87
 
88
    /**
89
     * Subject
90
     *
91
     * @var string
92
     */
93
    private $_subject        = '';
94
 
95
    /**
96
     * Keywords
97
     *
98
     * @var string
99
     */
100
    private $_keywords        = '';
101
 
102
    /**
103
     * Category
104
     *
105
     * @var string
106
     */
107
    private $_category        = '';
108
 
109
    /**
110
     * Manager
111
     *
112
     * @var string
113
     */
114
    private $_manager        = '';
115
 
116
    /**
117
     * Company
118
     *
119
     * @var string
120
     */
121
    private $_company        = 'Microsoft Corporation';
122
 
123
    /**
124
     * Custom Properties
125
     *
126
     * @var string
127
     */
128
    private $_customProperties    = array();
129
 
130
 
131
    /**
132
     * Create a new PHPExcel_DocumentProperties
133
     */
134
    public function __construct()
135
    {
136
        // Initialise values
137
        $this->_lastModifiedBy    = $this->_creator;
138
        $this->_created        = time();
139
        $this->_modified    = time();
140
    }
141
 
142
    /**
143
     * Get Creator
144
     *
145
     * @return string
146
     */
147
    public function getCreator() {
148
        return $this->_creator;
149
    }
150
 
151
    /**
152
     * Set Creator
153
     *
154
     * @param string $pValue
155
     * @return PHPExcel_DocumentProperties
156
     */
157
    public function setCreator($pValue = '') {
158
        $this->_creator = $pValue;
159
        return $this;
160
    }
161
 
162
    /**
163
     * Get Last Modified By
164
     *
165
     * @return string
166
     */
167
    public function getLastModifiedBy() {
168
        return $this->_lastModifiedBy;
169
    }
170
 
171
    /**
172
     * Set Last Modified By
173
     *
174
     * @param string $pValue
175
     * @return PHPExcel_DocumentProperties
176
     */
177
    public function setLastModifiedBy($pValue = '') {
178
        $this->_lastModifiedBy = $pValue;
179
        return $this;
180
    }
181
 
182
    /**
183
     * Get Created
184
     *
185
     * @return datetime
186
     */
187
    public function getCreated() {
188
        return $this->_created;
189
    }
190
 
191
    /**
192
     * Set Created
193
     *
194
     * @param datetime $pValue
195
     * @return PHPExcel_DocumentProperties
196
     */
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
 
212
    /**
213
     * Get Modified
214
     *
215
     * @return datetime
216
     */
217
    public function getModified() {
218
        return $this->_modified;
219
    }
220
 
221
    /**
222
     * Set Modified
223
     *
224
     * @param datetime $pValue
225
     * @return PHPExcel_DocumentProperties
226
     */
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
 
242
    /**
243
     * Get Title
244
     *
245
     * @return string
246
     */
247
    public function getTitle() {
248
        return $this->_title;
249
    }
250
 
251
    /**
252
     * Set Title
253
     *
254
     * @param string $pValue
255
     * @return PHPExcel_DocumentProperties
256
     */
257
    public function setTitle($pValue = '') {
258
        $this->_title = $pValue;
259
        return $this;
260
    }
261
 
262
    /**
263
     * Get Description
264
     *
265
     * @return string
266
     */
267
    public function getDescription() {
268
        return $this->_description;
269
    }
270
 
271
    /**
272
     * Set Description
273
     *
274
     * @param string $pValue
275
     * @return PHPExcel_DocumentProperties
276
     */
277
    public function setDescription($pValue = '') {
278
        $this->_description = $pValue;
279
        return $this;
280
    }
281
 
282
    /**
283
     * Get Subject
284
     *
285
     * @return string
286
     */
287
    public function getSubject() {
288
        return $this->_subject;
289
    }
290
 
291
    /**
292
     * Set Subject
293
     *
294
     * @param string $pValue
295
     * @return PHPExcel_DocumentProperties
296
     */
297
    public function setSubject($pValue = '') {
298
        $this->_subject = $pValue;
299
        return $this;
300
    }
301
 
302
    /**
303
     * Get Keywords
304
     *
305
     * @return string
306
     */
307
    public function getKeywords() {
308
        return $this->_keywords;
309
    }
310
 
311
    /**
312
     * Set Keywords
313
     *
314
     * @param string $pValue
315
     * @return PHPExcel_DocumentProperties
316
     */
317
    public function setKeywords($pValue = '') {
318
        $this->_keywords = $pValue;
319
        return $this;
320
    }
321
 
322
    /**
323
     * Get Category
324
     *
325
     * @return string
326
     */
327
    public function getCategory() {
328
        return $this->_category;
329
    }
330
 
331
    /**
332
     * Set Category
333
     *
334
     * @param string $pValue
335
     * @return PHPExcel_DocumentProperties
336
     */
337
    public function setCategory($pValue = '') {
338
        $this->_category = $pValue;
339
        return $this;
340
    }
341
 
342
    /**
343
     * Get Company
344
     *
345
     * @return string
346
     */
347
    public function getCompany() {
348
        return $this->_company;
349
    }
350
 
351
    /**
352
     * Set Company
353
     *
354
     * @param string $pValue
355
     * @return PHPExcel_DocumentProperties
356
     */
357
    public function setCompany($pValue = '') {
358
        $this->_company = $pValue;
359
        return $this;
360
    }
361
 
362
    /**
363
     * Get Manager
364
     *
365
     * @return string
366
     */
367
    public function getManager() {
368
        return $this->_manager;
369
    }
370
 
371
    /**
372
     * Set Manager
373
     *
374
     * @param string $pValue
375
     * @return PHPExcel_DocumentProperties
376
     */
377
    public function setManager($pValue = '') {
378
        $this->_manager = $pValue;
379
        return $this;
380
    }
381
 
382
    /**
383
     * Get a List of Custom Property Names
384
     *
385
     * @return array of string
386
     */
387
    public function getCustomProperties() {
388
        return array_keys($this->_customProperties);
389
    }
390
 
391
    /**
392
     * Check if a Custom Property is defined
393
     *
394
     * @param string $propertyName
395
     * @return boolean
396
     */
397
    public function isCustomPropertySet($propertyName) {
398
        return isset($this->_customProperties[$propertyName]);
399
    }
400
 
401
    /**
402
     * Get a Custom Property Value
403
     *
404
     * @param string $propertyName
405
     * @return string
406
     */
407
    public function getCustomPropertyValue($propertyName) {
408
        if (isset($this->_customProperties[$propertyName])) {
409
            return $this->_customProperties[$propertyName]['value'];
410
        }
411
 
412
    }
413
 
414
    /**
415
     * Get a Custom Property Type
416
     *
417
     * @param string $propertyName
418
     * @return string
419
     */
420
    public function getCustomPropertyType($propertyName) {
421
        if (isset($this->_customProperties[$propertyName])) {
422
            return $this->_customProperties[$propertyName]['type'];
423
        }
424
 
425
    }
426
 
427
    /**
428
     * Set a Custom Property
429
     *
430
     * @param string $propertyName
431
     * @param mixed $propertyValue
432
     * @param string $propertyType
433
     * 	 'i'    : Integer
434
     *   'f' : Floating Point
435
     *   's' : String
436
     *   'd' : Date/Time
437
     *   'b' : Boolean
438
     * @return PHPExcel_DocumentProperties
439
     */
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
 
463
    /**
464
     * Implement PHP __clone to create a deep clone, not just a shallow copy.
465
     */
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
547
                return self::PROPERTY_TYPE_INTEGER;
548
                break;
549
            case 'r4'        :    //    4-Byte Real Number
550
            case 'r8'        :    //    8-Byte Real Number
551
            case 'decimal'    :    //    Decimal
552
                return self::PROPERTY_TYPE_FLOAT;
553
                break;
554
            case 'empty'    :    //    Empty
555
            case 'null'        :    //    Null
556
            case 'lpstr'    :    //    LPSTR
557
            case 'lpwstr'    :    //    LPWSTR
558
            case 'bstr'        :    //    Basic String
559
                return self::PROPERTY_TYPE_STRING;
560
                break;
561
            case 'date'        :    //    Date and Time
562
            case 'filetime'    :    //    File Time
563
                return self::PROPERTY_TYPE_DATE;
564
                break;
565
            case 'bool'        :    //    Boolean
566
                return self::PROPERTY_TYPE_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
581
                return self::PROPERTY_TYPE_UNKNOWN;
582
                break;
583
        }
584
        return self::PROPERTY_TYPE_UNKNOWN;
585
    }
586
 
587
}