From e146c91318d586bb2a21fc4cb6af296ea88ee5a5 Mon Sep 17 00:00:00 2001 From: LouisGac Date: Wed, 28 Jun 2017 13:11:26 +0200 Subject: [PATCH] Dev: added TemplateConfiguration::extendsFile() --- application/models/TemplateConfiguration.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/application/models/TemplateConfiguration.php b/application/models/TemplateConfiguration.php index f6f7235625e..bfcb7ad7f8a 100644 --- a/application/models/TemplateConfiguration.php +++ b/application/models/TemplateConfiguration.php @@ -198,6 +198,21 @@ public function getFilePathForEdition($sFile, $aAllowedFiles=null) return $this->getFilePath($sFile, $this); } + + public function extendsFile($sFile) + { + + if( !file_exists($this->path.'/'.$sFile) && !file_exists($this->viewPath.$sFile) ){ + + // Copy file from mother template to local directory + $sRfilePath = $this->getFilePath($sFile, $this); + $sLfilePath = (pathinfo($sFile, PATHINFO_EXTENSION) == 'twig')?$this->viewPath.$sFile:$this->path.'/'.$sFile; + copy ( $sRfilePath, $sLfilePath ); + } + + return $this->getFilePath($sFile, $this); + } + /** * This function will update the config file of a given template so that it extends another one *