Skip to content

Commit

Permalink
Dev : Fixed issue #10266: fix templateNameFilter
Browse files Browse the repository at this point in the history
Dev : 5eabd85 child
Dev: fix standard template list with actual list
  • Loading branch information
Shnoulle committed Feb 2, 2016
1 parent ca8069a commit 8a47592
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions application/models/Template.php
Expand Up @@ -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';
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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'
)
);
}
Expand Down

0 comments on commit 8a47592

Please sign in to comment.