From d1549c1537182933bf109eb73d55b7931ed5bd42 Mon Sep 17 00:00:00 2001 From: LouisGac Date: Fri, 23 Jun 2017 13:08:27 +0200 Subject: [PATCH] Dev: added TemplateConfiguration::getValidScreenFiles() --- application/models/TemplateConfiguration.php | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/application/models/TemplateConfiguration.php b/application/models/TemplateConfiguration.php index b72c15d6f26..d385014f9f2 100644 --- a/application/models/TemplateConfiguration.php +++ b/application/models/TemplateConfiguration.php @@ -134,9 +134,32 @@ public function getTemplateURL() return $this->sTemplateurl; } + /** + * Used from the template editor. + * It returns an array of editable files by screen for a given file type + * + * @param string $sType the type of files (view/css/js) + * @return array array ( [screen name] => array([files]) ) + */ + public function getValidScreenFiles($sType = "view") + { + $aScreenFiles = array(); + $filesFromXML = (array) $this->templateEditor->screens->xpath('//file'); + + foreach( $filesFromXML as $file){ + + if ( $file->attributes()->type == $sType ){ + $aScreenFiles[] = (string) $file; + } + } + + $aScreenFiles = array_unique($aScreenFiles); + return $aScreenFiles; + } + /** * This function will update the config file of a given template so that it extends another one - * + * * It will: * 1. Delete files and engine nodes * 2. Update the name of the template