1<?php 2 3namespace dokuwiki\plugin\totext\Extractor; 4 5/** 6 * Shared metadata reader for the OOXML family (DOCX/XLSX/PPTX). 7 * 8 * All three store their package metadata in the same two parts: 9 * docProps/core.xml (Dublin Core + core properties) and docProps/app.xml 10 * (the authoring application). The element local name => canonical key maps 11 * are declared here once; subclasses only implement extractText(). 12 */ 13abstract class AbstractOoxmlExtractor extends AbstractZipXmlExtractor 14{ 15 /** 16 * docProps/core.xml element local name => canonical metadata key. 17 * 18 * @var array<string, string> 19 */ 20 protected const CORE_META_MAP = [ 21 'title' => 'Title', 22 'creator' => 'Author', 23 'subject' => 'Subject', 24 'keywords' => 'Keywords', 25 'description' => 'Description', 26 'created' => 'Created', 27 'modified' => 'Modified', 28 'language' => 'Language', 29 ]; 30 31 /** 32 * docProps/app.xml element local name => canonical metadata key. 33 * 34 * @var array<string, string> 35 */ 36 protected const APP_META_MAP = [ 37 'Application' => 'Producer', 38 ]; 39 40 /** @inheritDoc */ 41 protected function extractMetadata(): array 42 { 43 $meta = []; 44 45 $core = $this->readPart('docProps/core.xml'); 46 if ($core !== null) { 47 $meta = $this->mapMetadataFromXml($core, self::CORE_META_MAP); 48 } 49 50 $app = $this->readPart('docProps/app.xml'); 51 if ($app !== null) { 52 $meta += $this->mapMetadataFromXml($app, self::APP_META_MAP); 53 } 54 55 return $meta; 56 } 57} 58