Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/LimeSurvey/LimeSurvey
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Mar 1, 2016
2 parents 23fffcb + c46f965 commit afde111
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
3 changes: 1 addition & 2 deletions application/helpers/replacements_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,7 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de
$_endtext = $thissurvey['surveyls_endtext'];
}

// App()->getAssetManager()->publish( $oTemplate->path.'/'.$oTemplate->siteLogo);
$sitelogo = ($oTemplate->siteLogo != '')?'<img src="'.App()->getAssetManager()->publish( $oTemplate->path.'/'.$oTemplate->siteLogo).'"/>':'';
$sitelogo = (!empty($oTemplate->siteLogo))?'<img src="'.App()->getAssetManager()->publish( $oTemplate->path.'/'.$oTemplate->siteLogo).'"/>':'';

// Set the array of replacement variables here - don't include curly braces
$coreReplacements = array();
Expand Down
32 changes: 16 additions & 16 deletions application/models/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,36 +181,36 @@ public static function getTemplateConfiguration($sTemplateName='', $iSurveyId=''
{
$oTemplate->name = $sTemplateName;
$oTemplate->path = Yii::app()->getConfig("usertemplaterootdir").DIRECTORY_SEPARATOR.$oTemplate->name;
}

// If the template don't have a config file (maybe it has been deleted, or whatever),
// then, we load the default template
if(!self::hasConfigFile($oTemplate->path))
{
// If it's an imported template from 2.06, we return default values
if ( self::isOldTemplate($oTemplate->path) )
{
$oTemplate->config = simplexml_load_file(Yii::app()->getConfig("standardtemplaterootdir").DIRECTORY_SEPARATOR.'/minimal-config.xml');
$oTemplate->cssFramework = null;
$oTemplate->viewPath = $oTemplate->path.DIRECTORY_SEPARATOR;
$oTemplate->filesPath = $oTemplate->path.DIRECTORY_SEPARATOR;
$oTemplate->packages = (array) $oTemplate->config->engine->packages->package;
$oTemplate->otherFiles = self::getOtherFiles($oTemplate->filesPath);
return $oTemplate;
$oTemplate->->config->engine->cssframework = null;
}
else
{
$oTemplate->name = 'default';
$oTemplate->path = Yii::app()->getConfig("standardtemplaterootdir").DIRECTORY_SEPARATOR.$oTemplate->name;
$oTemplate->config = simplexml_load_file($oTemplate->path.'/config.xml');
}

}

// If the template don't have a config file (maybe it has been deleted, or whatever),
// then, we load the default template
if(! self::hasConfigFile($oTemplate->path))
else
{
$oTemplate->name = 'default';
$oTemplate->path = Yii::app()->getConfig("standardtemplaterootdir").DIRECTORY_SEPARATOR.$oTemplate->name;
$oTemplate->config = simplexml_load_file($oTemplate->path.'/config.xml');
}

// The template configuration.
$oTemplate->config = simplexml_load_file($oTemplate->path.'/config.xml');
$oTemplate->viewPath = $oTemplate->path.DIRECTORY_SEPARATOR.$oTemplate->config->engine->pstpldirectory.DIRECTORY_SEPARATOR;
$oTemplate->siteLogo = (isset($oTemplate->config->files->logo))?$oTemplate->config->files->logo->filename:'';

// condition for user's template prior to 160219
$oTemplate->filesPath = (isset($oTemplate->config->engine->filesdirectory))?$oTemplate->path.DIRECTORY_SEPARATOR.$oTemplate->config->engine->filesdirectory.DIRECTORY_SEPARATOR:$oTemplate->path . '/files/';
$oTemplate->filesPath = (isset($oTemplate->config->engine->filesdirectory))? $oTemplate->path.DIRECTORY_SEPARATOR.$oTemplate->config->engine->filesdirectory.DIRECTORY_SEPARATOR : $oTemplate->path . '/files/';
$oTemplate->cssFramework = $oTemplate->config->engine->cssframework;
$oTemplate->packages = (array) $oTemplate->config->engine->packages->package;
$oTemplate->otherFiles = self::getOtherFiles($oTemplate->filesPath);
Expand Down Expand Up @@ -372,6 +372,6 @@ public static function hasConfigFile($sTemplatePath)
*/
public static function isOldTemplate($sTemplatePath)
{
return (! self::hasConfigFile($sTemplatePath) && is_file($oTemplate->path.DIRECTORY_SEPARATOR.'startpage.pstpl'));
return (!self::hasConfigFile($sTemplatePath) && is_file($sTemplatePath.DIRECTORY_SEPARATOR.'startpage.pstpl'));
}
}
20 changes: 17 additions & 3 deletions templates/minimal-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,25 @@
</js>
</rtl>
</files>

<!-- For template editor : need fix : allow edit even if not exist-->
<files_editable>
<css>
<filename>template.css</filename>
<filename>template-rtl.css</filename>
<filename>jquery-ui.css</filename>
<filename>jquery-ui-custom.css</filename>
</css>
<js>
<filename>template.js</filename>
</js>
</files_editable>

<engine>
<filesdirectory>.</filesdirectory>
<cssframework></cssframework>
<pstpldirectory>.</pstpldirectory> <!-- Broken edit pstpl file in template editor actually -->
<packages>
<cssframework></cssframework>
<pstpldirectory>.</pstpldirectory>
<filesdirectory>.</filesdirectory>
<package>jqueryui</package>
<package>jquery-touch-punch</package>
</packages>
Expand Down

0 comments on commit afde111

Please sign in to comment.