Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
Conflicts:
	application/config/version.php
	application/helpers/update/updatedb_helper.php
  • Loading branch information
olleharstedt committed Jun 6, 2018
2 parents b68f1d0 + 0642064 commit dd2b5ad
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 7 deletions.
39 changes: 38 additions & 1 deletion application/core/LSETwigViewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,43 @@ public function renderTemplateFromFile($sLayout, $aDatas, $bReturn)
}


/**
* Main method to render an admin page or block.
* Extendable to use admin templates in the future currently running on pathes, like the yii render methods go.
* @param string $sLayout the name of the layout to render
* @param array $aDatas the datas needed to fill the layout
* @param boolean $bReturn if true, it will return the html string without rendering the whole page.
* Usefull for debuging, and used for Print Answers
* @param boolean $bUseRootDir Prepend application root dir to sLayoutFilePath if true.
* @return string HTML
*/
public function renderViewFromFile($sLayoutFilePath, $aDatas, $bReturn = false, $bUseRootDir = true)
{
if ($bUseRootDir) {
$viewFile = Yii::app()->getConfig('rootdir').$sLayoutFilePath;
} else {
$viewFile = $sLayoutFilePath;
}

if (file_exists($viewFile)) {
$line = file_get_contents($viewFile);
$sHtml = $this->convertTwigToHtml($line, $aDatas);

if ($bReturn) {
return $sHtml;
} else {
$this->renderHtmlPage($sHtml, $oTemplate);
}
} else {
throw new CException(
sprintf(
gT("Can't render layout %s. Please check the view exists or contact your admin."),
$viewFile
)
);
}
}

/**
* Main method to render an admin page or block.
* Extendable to use admin templates in the future currently running on pathes, like the yii render methods go.
Expand Down Expand Up @@ -327,7 +364,7 @@ private function renderHtmlPage($sHtml, $oTemplate)
*
* @param string $sString The string of HTML/Twig to convert
* @param array $aDatas Array containing the datas needed to render the view ($thissurvey)
* @param TemplateConfiguration $oTemplate
* @param TemplateConfiguration|null $oTemplate
* @return string
*/
public function convertTwigToHtml($sString, $aDatas, $oTemplate = null)
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/SurveyRuntimeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1437,8 +1437,8 @@ private function manageClearAll()
$restartparam['token'] = Token::sanitizeToken($token);
}

if (Yii::app()->request->getQuery('lang')) {
$restartparam['lang'] = sanitize_languagecode(Yii::app()->request->getQuery('lang'));
if (!empty(App()->getLanguage())) {
$restartparam['lang'] = sanitize_languagecode(App()->getLanguage());
} else {
$s_lang = isset(Yii::app()->session['survey_'.$this->iSurveyid]['s_lang']) ? Yii::app()->session['survey_'.$this->iSurveyid]['s_lang'] : 'en';
$restartparam['lang'] = $s_lang;
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/admin/token_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function emailTokens($iSurveyID, $aResultTokens, $sType)
foreach (array('OPTOUT', 'OPTIN', 'SURVEY') as $key) {
$url = $fieldsarray["{{$key}URL}"];
$fieldsarray["{{$key}URL}"] = "<a href='{$url}'>".htmlspecialchars($url).'</a>';
$aBareboneURLs['@@'.$key.'URL@@'] = $fieldsarray["{{$key}URL}"];
$aBareboneURLs['@@'.$key.'URL@@'] = $url;
}
}

Expand Down
4 changes: 2 additions & 2 deletions application/helpers/questionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public static function getAttributesDefinitions()
'sortorder'=>100,
'inputtype'=>'integer',
'default'=>'',
"help"=>gT('Repeat headings every X subquestions (Set to 0 to deactivate heading repeat, deactivate minimum repeat headings from config).'),
"caption"=>gT('Repeat headers')
"help"=>gT('Repeat answer options every X subquestions (Set to 0 to deactivate answer options repeat, deactivate minimum answer options repeat from config).'),
"caption"=>gT('Repeat answer options')
);

self::$attributes["array_filter"] = array(
Expand Down
19 changes: 18 additions & 1 deletion application/helpers/update/updatedb_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,7 @@ function db_upgrade_all($iOldDBVersion, $bSilent = false)
$oDB->createCommand()->update('{{settings_global}}', ['stg_value'=>349], "stg_name='DBVersion'");
$oTransaction->commit();
}

/**
* Adding asset version to allow to reset asset without write inside
*/
Expand All @@ -2225,6 +2225,23 @@ function db_upgrade_all($iOldDBVersion, $bSilent = false)
$oTransaction->commit();
}

/**
* Turning on ajax mode at global level for all themes (survey level not affected)
*/
if ($iOldDBVersion < 351) {
$oTransaction = $oDB->beginTransaction();

$aTHemes = TemplateConfiguration::model()->findAll();

foreach ($aTHemes as $oTheme){
$oTheme->setGlobalOptionOn("ajaxmode");
}

$oDB->createCommand()->update('{{settings_global}}', ['stg_value'=>351], "stg_name='DBVersion'");
$oTransaction->commit();
}



if ($iOldDBVersion < 400) {
// This update moves localization-dependant strings from question group/question/answer tables to related localization tables
Expand Down
2 changes: 2 additions & 0 deletions application/views/admin/responses/browsemenubar_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,13 @@
<?php endif;?>
<?php if (isset($menu['view'])): ?>
<?php if ($exist): ?>
<?php if (Permission::model()->hasSurveyPermission($surveyid, 'responses', 'update') && isset($rlanguage)): ?>
<a class="btn btn-default" href='<?php echo $this->createUrl("admin/dataentry/sa/editdata/subaction/edit/surveyid/{$surveyid}/id/{$id}/lang/$rlanguage"); ?>' role="button">

<span class="fa fa-pencil text-success"></span>
<?php eT("Edit this entry"); ?>
</a>
<?php endif;?>
<?php if (Permission::model()->hasSurveyPermission($surveyid, 'responses', 'delete') && isset($rlanguage)): ?>
<a class="btn btn-default" href='#' role="button" onclick="if (confirm('<?php eT("Are you sure you want to delete this entry?", "js"); ?>')) { <?php echo convertGETtoPOST($this->createUrl("admin/dataentry/sa/delete/id/$id/sid/$surveyid")); ?>}">
<span class="fa fa-trash text-warning"></span>
Expand Down

0 comments on commit dd2b5ad

Please sign in to comment.