PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.5
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.5
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Reader / Xlsx / Properties.php

Properties.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.4.5, at vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Properties.php

92 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
4
5 use PhpOffice\PhpSpreadsheet\Document\Properties as DocumentProperties;
6 use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
7 use PhpOffice\PhpSpreadsheet\Settings;
8
9 class Properties
10 {
11 private $securityScanner;
12
13 private $docProps;
14
15 public function __construct(XmlScanner $securityScanner, DocumentProperties $docProps)
16 {
17 $this->securityScanner = $securityScanner;
18 $this->docProps = $docProps;
19 }
20
21 private function extractPropertyData($propertyData)
22 {
23 return simplexml_load_string(
24 $this->securityScanner->scan($propertyData),
25 'SimpleXMLElement',
26 Settings::getLibXmlLoaderOptions()
27 );
28 }
29
30 public function readCoreProperties($propertyData)
31 {
32 $xmlCore = $this->extractPropertyData($propertyData);
33
34 if (is_object($xmlCore)) {
35 $xmlCore->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/');
36 $xmlCore->registerXPathNamespace('dcterms', 'http://purl.org/dc/terms/');
37 $xmlCore->registerXPathNamespace('cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
38
39 $this->docProps->setCreator((string) self::getArrayItem($xmlCore->xpath('dc:creator')));
40 $this->docProps->setLastModifiedBy((string) self::getArrayItem($xmlCore->xpath('cp:lastModifiedBy')));
41 $this->docProps->setCreated(strtotime(self::getArrayItem($xmlCore->xpath('dcterms:created')))); //! respect xsi:type
42 $this->docProps->setModified(strtotime(self::getArrayItem($xmlCore->xpath('dcterms:modified')))); //! respect xsi:type
43 $this->docProps->setTitle((string) self::getArrayItem($xmlCore->xpath('dc:title')));
44 $this->docProps->setDescription((string) self::getArrayItem($xmlCore->xpath('dc:description')));
45 $this->docProps->setSubject((string) self::getArrayItem($xmlCore->xpath('dc:subject')));
46 $this->docProps->setKeywords((string) self::getArrayItem($xmlCore->xpath('cp:keywords')));
47 $this->docProps->setCategory((string) self::getArrayItem($xmlCore->xpath('cp:category')));
48 }
49 }
50
51 public function readExtendedProperties($propertyData)
52 {
53 $xmlCore = $this->extractPropertyData($propertyData);
54
55 if (is_object($xmlCore)) {
56 if (isset($xmlCore->Company)) {
57 $this->docProps->setCompany((string) $xmlCore->Company);
58 }
59 if (isset($xmlCore->Manager)) {
60 $this->docProps->setManager((string) $xmlCore->Manager);
61 }
62 }
63 }
64
65 public function readCustomProperties($propertyData)
66 {
67 $xmlCore = $this->extractPropertyData($propertyData);
68
69 if (is_object($xmlCore)) {
70 foreach ($xmlCore as $xmlProperty) {
71 /** @var \SimpleXMLElement $xmlProperty */
72 $cellDataOfficeAttributes = $xmlProperty->attributes();
73 if (isset($cellDataOfficeAttributes['name'])) {
74 $propertyName = (string) $cellDataOfficeAttributes['name'];
75 $cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
76
77 $attributeType = $cellDataOfficeChildren->getName();
78 $attributeValue = (string) $cellDataOfficeChildren->{$attributeType};
79 $attributeValue = DocumentProperties::convertProperty($attributeValue, $attributeType);
80 $attributeType = DocumentProperties::convertPropertyType($attributeType);
81 $this->docProps->setCustomProperty($propertyName, $attributeValue, $attributeType);
82 }
83 }
84 }
85 }
86
87 private static function getArrayItem(array $array, $key = 0)
88 {
89 return isset($array[$key]) ? $array[$key] : null;
90 }
91 }
92