Skip to content

Commit

Permalink
Dev: some fix for old template : don't return config
Browse files Browse the repository at this point in the history
Dev: some dir have "/./" : solution : return before "default" fix
Dev: editable files allow edit if not exist
Dev: actually : view aren't editable in template editor
  • Loading branch information
Shnoulle committed Mar 1, 2016
1 parent 0fc1540 commit c46f965
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
31 changes: 16 additions & 15 deletions application/models/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,35 +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
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

1 comment on commit c46f965

@Shnoulle
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.