if(isset($ff->Pman_Cms['powerpoint'])) {
foreach($ff->Pman_Cms['powerpoint'] as $dir) {
- $this->scanFilesBase($base);
+ $this->scanText($dir);
}
}
}
+
+ /**
+ * scan translatable text items in a powerpoint folder
+ * translatable text items should have names starting with 'tr-'
+ *
+ * @param String $path path of the powerpoint folder to be scanned
+ * @return Array $strings 2d array containing translatable strings grouped by slide name
+ *
+ */
+ function scanText($path = false)
+ {
+ if(!$path) {
+ $path = $this->tmpPath;
+ }
+
+ // get id of slides from presentation xml
+ $slideRids = array();
+
+ $xmlString = file_get_contents($path . '/ppt/presentation.xml');
+ $sxe = new SimpleXMLElement($xmlString);
+ $slides = $sxe->xpath('./p:sldIdLst/p:sldId');
+
+ foreach($slides as $slide) {
+ $slideRids[] = $slide->attributes('r', true)->id->__toString();
+
+ }
+
+ // get id and name of slides from presentation xml rels
+ $slideNames = array();
+
+ $xmlString = file_get_contents($path . '/ppt/_rels/presentation.xml.rels');
+ $sxe = new SimpleXMLElement($xmlString);
+ $relationships = $sxe->xpath('.')[0];
+
+ foreach($relationships->children() as $relationship) {
+ // a slide
+ if($relationship->attributes()->Type->__toString() == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide") {
+ $target = $relationship->attributes()->Target->__toString();
+ $slideName = substr(substr($target, 0 , strlen($target) - strlen('.xml')), strlen('slides/'));
+ $slideNames[$relationship->attributes()->Id->__toString()] = $slideName;
+ }
+ }
+
+ // get strings from slides
+ $strings = array();
+
+ foreach($slideRids as $slideRid) {
+ $slide = $slideNames[$slideRid];
+ $strings[$slide] = array();
+
+ $xmlString = file_get_contents($path . '/ppt/slides/' . $slide . '.xml');
+ $sxe = new SimpleXMLElement($xmlString);
+ $texts = $sxe->xpath('./p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:t');
+
+ foreach($texts as $text) {
+ $property = $text->xpath('../../../../p:nvSpPr/p:cNvPr');
+
+ // cannot find property (It won't happen in theory)
+ if(empty($property)) {
+ continue;
+ }
+
+ $textName = $property[0]->attributes()->name->__toString();
+
+ // a text is translatable if its name starts with 'tr-'
+ if(strpos($textName, 'tr-') === 0) {
+ $strings[$slide][$textName] = $text->__toString();
+ }
+ }
+ }
+
+ return $strings;
+ }
function scanTables()