From 8a47592fb737c20f9940a8f1ce6215f997762b0f Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Tue, 2 Feb 2016 12:00:59 +0100 Subject: [PATCH] Dev : Fixed issue #10266: fix templateNameFilter Dev : https://github.com/LimeSurvey/LimeSurvey/commit/5eabd85feb759e2fabcdd16ee81e97720d7fee94 child Dev: fix standard template list with actual list --- application/models/Template.php | 35 +++++++++++++-------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/application/models/Template.php b/application/models/Template.php index 3fe37c29be1..fbf76dc91f1 100644 --- a/application/models/Template.php +++ b/application/models/Template.php @@ -64,17 +64,20 @@ public static function templateNameFilter($sTemplateName) $sDefaulttemplate=Yii::app()->getConfig('defaulttemplate','default'); $sTemplateName=empty($sTemplateName) ? $sDefaulttemplate : $sTemplateName; - /* Validate it's a real dir included in template allowed dir - * Alternative : use realpath("$dir/$sTemplateName")=="$dir/$sTemplateName" and is_dir - */ - if(array_key_exists($sTemplateName,self::getTemplateList())) + /* Standard Template return it without testing */ + if(self::isStandardTemplate($sTemplateName)) + { return $sTemplateName; - - // If needed recall the function with default template + } + /* Validate if template is OK in user dir, DIRECTORY_SEPARATOR not needed "/" is OK */ + if(is_file(Yii::app()->getConfig("usertemplaterootdir").DIRECTORY_SEPARATOR.$sTemplateName.DIRECTORY_SEPARATOR.'config.xml')) + { + return $sTemplateName; + } + /* Then try with the global default template */ if($sTemplateName!=$sDefaulttemplate) return self::templateNameFilter($sDefaulttemplate); - - // Last solution is default + /* Last solution : default */ return 'default'; } @@ -152,7 +155,7 @@ public static function getTemplateConfiguration($sTemplateName='', $iSurveyId='' } else { - if(is_file(Yii::app()->getConfig("usertemplaterootdir").DIRECTORY_SEPARATOR.$sTemplateName).DIRECTORY_SEPARATOR.'config.xml') + if(is_file(Yii::app()->getConfig("usertemplaterootdir").DIRECTORY_SEPARATOR.$sTemplateName.DIRECTORY_SEPARATOR.'config.xml')) { $oTemplate->name = $sTemplateName; $oTemplate->path = Yii::app()->getConfig("usertemplaterootdir").DIRECTORY_SEPARATOR.$oTemplate->name; @@ -286,21 +289,11 @@ public static function isStandardTemplate($sTemplateName) return in_array($sTemplateName, array( 'default', - 'blue_sky', + 'material_design', 'metro_ode', - 'electric_black', - 'night_mode', - 'flat_and_modern', 'news_paper', - 'light_and_shadow', - 'material_design', - 'readable', - 'sandstone', - 'minimalist', - 'gunmetal', - 'super_blue', + 'night_mode', 'ubuntu_orange', - 'yeti' ) ); }