24 return simplexml_load_string(
25 $this->securityScanner->scan($propertyData),
35 if (is_object($xmlCore)) {
36 $xmlCore->registerXPathNamespace(
'dc',
'http://purl.org/dc/elements/1.1/');
37 $xmlCore->registerXPathNamespace(
'dcterms',
'http://purl.org/dc/terms/');
38 $xmlCore->registerXPathNamespace(
'cp',
'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
40 $this->docProps->setCreator((
string) self::getArrayItem($xmlCore->xpath(
'dc:creator')));
41 $this->docProps->setLastModifiedBy((
string) self::getArrayItem($xmlCore->xpath(
'cp:lastModifiedBy')));
42 $created = (string) self::getArrayItem($xmlCore->xpath(
'dcterms:created'));
43 $this->docProps->setCreated($created);
44 $modified = (string) self::getArrayItem($xmlCore->xpath(
'dcterms:modified'));
45 $this->docProps->setModified($modified);
46 $this->docProps->setTitle((
string) self::getArrayItem($xmlCore->xpath(
'dc:title')));
47 $this->docProps->setDescription((
string) self::getArrayItem($xmlCore->xpath(
'dc:description')));
48 $this->docProps->setSubject((
string) self::getArrayItem($xmlCore->xpath(
'dc:subject')));
49 $this->docProps->setKeywords((
string) self::getArrayItem($xmlCore->xpath(
'cp:keywords')));
50 $this->docProps->setCategory((
string) self::getArrayItem($xmlCore->xpath(
'cp:category')));
58 if (is_object($xmlCore)) {
59 if (isset($xmlCore->Company)) {
60 $this->docProps->setCompany((
string) $xmlCore->Company);
62 if (isset($xmlCore->Manager)) {
63 $this->docProps->setManager((
string) $xmlCore->Manager);
68 public function readCustomProperties($propertyData):
void 72 if (is_object($xmlCore)) {
73 foreach ($xmlCore as $xmlProperty) {
75 $cellDataOfficeAttributes = $xmlProperty->attributes();
76 if (isset($cellDataOfficeAttributes[
'name'])) {
77 $propertyName = (string) $cellDataOfficeAttributes[
'name'];
78 $cellDataOfficeChildren = $xmlProperty->children(
'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
80 $attributeType = $cellDataOfficeChildren->getName();
81 $attributeValue = (string) $cellDataOfficeChildren->{$attributeType};
82 $attributeValue = DocumentProperties::convertProperty($attributeValue, $attributeType);
83 $attributeType = DocumentProperties::convertPropertyType($attributeType);
84 $this->docProps->setCustomProperty($propertyName, $attributeValue, $attributeType);
92 return $array[
$key] ?? null;
static getArrayItem(array $array, $key=0)
readCoreProperties($propertyData)
extractPropertyData($propertyData)
readExtendedProperties($propertyData)
static getLibXmlLoaderOptions()
Get default options for libxml loader.
__construct(XmlScanner $securityScanner, DocumentProperties $docProps)