Skip to content

Commit

Permalink
Merge branch 'master' of github.com:LimeSurvey/LimeSurvey
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Jan 9, 2014
2 parents 25da2e8 + 0730c83 commit 001a6cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
22 changes: 11 additions & 11 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -518,7 +518,7 @@ function run($surveyid,$args) {
//Before doing the "templatereplace()" function, check the $thissurvey['url']
//field for limereplace stuff, and do transformations!
$thissurvey['surveyls_url'] = passthruReplace($thissurvey['surveyls_url'], $thissurvey);
$thissurvey['surveyls_url'] = templatereplace($thissurvey['surveyls_url'], array(), $redata); // to do INSERTANS substitutions
$thissurvey['surveyls_url'] = templatereplace($thissurvey['surveyls_url'], array(), $redata, 'URLReplace', false, NULL, array(), true ); // to do INSERTANS substitutions

//END PAGE - COMMIT CHANGES TO DATABASE
if ($thissurvey['active'] != "Y") //If survey is not active, don't really commit
Expand All @@ -530,12 +530,12 @@ function run($surveyid,$args) {
sendCacheHeaders();
doHeader();

echo templatereplace(file_get_contents($sTemplatePath."startpage.pstpl"), array(), $redata);
echo templatereplace(file_get_contents($sTemplatePath."startpage.pstpl"), array(), $redata, 'SubmitStartpageI', false, NULL, array(), true );

//Check for assessments
if ($thissurvey['assessments'] == "Y" && $assessments)
{
echo templatereplace(file_get_contents($sTemplatePath."assessment.pstpl"), array(), $redata);
echo templatereplace(file_get_contents($sTemplatePath."assessment.pstpl"), array(), $redata, 'SubmitAssessmentI', false, NULL, array(), true );
}

// fetch all filenames from $_SESSIONS['files'] and delete them all
Expand All @@ -547,7 +547,7 @@ function run($surveyid,$args) {
}
*/
// can't kill session before end message, otherwise INSERTANS doesn't work.
$completed = templatereplace($thissurvey['surveyls_endtext'], array(), $redata);
$completed = templatereplace($thissurvey['surveyls_endtext'], array(), $redata, 'SubmitEndtextI', false, NULL, array(), true );
$completed .= "<br /><strong><font size='2' color='red'>" . $clang->gT("Did Not Save") . "</font></strong><br /><br />\n\n";
$completed .= $clang->gT("Your survey responses have not been recorded. This survey is not yet active.") . "<br /><br />\n";
if ($thissurvey['printanswers'] == 'Y')
Expand All @@ -568,15 +568,15 @@ function run($surveyid,$args) {


$content = '';
$content .= templatereplace(file_get_contents($sTemplatePath."startpage.pstpl"), array(), $redata);
$content .= templatereplace(file_get_contents($sTemplatePath."startpage.pstpl"), array(), $redata, 'SubmitStartpage', false, NULL, array(), true );

//Check for assessments
if ($thissurvey['assessments'] == "Y")
{
$assessments = doAssessment($surveyid);
if ($assessments)
{
$content .= templatereplace(file_get_contents($sTemplatePath."assessment.pstpl"), array(), $redata);
$content .= templatereplace(file_get_contents($sTemplatePath."assessment.pstpl"), array(), $redata, 'SubmitAssessment', false, NULL, array(), true );
}
}

Expand All @@ -593,7 +593,7 @@ function run($surveyid,$args) {

$content = '';

$content .= templatereplace(file_get_contents($sTemplatePath."startpage.pstpl"), array(), $redata);
$content .= templatereplace(file_get_contents($sTemplatePath."startpage.pstpl"), array(), $redata, 'SubmitStartpage', false, NULL, array(), true );

//echo $thissurvey['url'];
//Check for assessments
Expand All @@ -602,7 +602,7 @@ function run($surveyid,$args) {
$assessments = doAssessment($surveyid);
if ($assessments)
{
$content .= templatereplace(file_get_contents($sTemplatePath."assessment.pstpl"), array(), $redata);
$content .= templatereplace(file_get_contents($sTemplatePath."assessment.pstpl"), array(), $redata, 'SubmitAssessment', false, NULL, array(), true );
}
}

Expand All @@ -614,7 +614,7 @@ function run($surveyid,$args) {
}
else
{
$completed = templatereplace($thissurvey['surveyls_endtext'], array(), $redata);
$completed = templatereplace($thissurvey['surveyls_endtext'], array(), $redata, 'SubmitAssessment', false, NULL, array(), true );
}

// Link to Print Answer Preview **********
Expand Down Expand Up @@ -678,7 +678,7 @@ function run($surveyid,$args) {
$redata['completed'] = implode("\n", $blocks) ."\n". $redata['completed'];
$redata['thissurvey']['surveyls_url'] = $thissurvey['surveyls_url'];

echo templatereplace(file_get_contents($sTemplatePath."completed.pstpl"), array('completed' => $completed), $redata);
echo templatereplace(file_get_contents($sTemplatePath."completed.pstpl"), array('completed' => $completed), $redata, 'SubmitCompleted', false, NULL, array(), true );
echo "\n";
if ((($LEMdebugLevel & LEM_DEBUG_TIMING) == LEM_DEBUG_TIMING))
{
Expand All @@ -688,7 +688,7 @@ function run($surveyid,$args) {
{
echo "<table><tr><td align='left'><b>Group/Question Validation Results:</b>" . $moveResult['message'] . "</td></tr></table>\n";
}
echo templatereplace(file_get_contents($sTemplatePath."endpage.pstpl"), array(), $redata);
echo templatereplace(file_get_contents($sTemplatePath."endpage.pstpl"), array(), $redata, 'SubmitEndpage', false, NULL, array(), true );
doFooter();

// The session cannot be killed until the page is completely rendered
Expand Down
10 changes: 6 additions & 4 deletions application/helpers/replacements_helper.php
Expand Up @@ -22,9 +22,10 @@
* @param mixed $replacements Array of replacements: Array( <stringtosearch>=><stringtoreplacewith>
* @param boolean $anonymized Determines if token data is being used or just replaced with blanks
* @param questionNum - needed to support dynamic JavaScript-based tailoring within questions
* @param bStaticReplacement - Default off, forces non-dynamic replacements without <SPAN> tags (e.g. for the Completed page)
* @return string Text with replaced strings
*/
function templatereplace($line, $replacements = array(), &$redata = array(), $debugSrc = 'Unspecified', $anonymized = false, $questionNum = NULL, $registerdata = array())
function templatereplace($line, $replacements = array(), &$redata = array(), $debugSrc = 'Unspecified', $anonymized = false, $questionNum = NULL, $registerdata = array(), $bStaticReplacement = false)
{
/*
global $clienttoken,$token,$sitename,$move,$showxquestions,$showqnumcode,$questioncode;
Expand Down Expand Up @@ -734,7 +735,7 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de

// Set the array of replacement variables here - don't include curly braces
$coreReplacements = array();
$coreReplacements['ACTIVE'] = (isset($thissurvey['active']) && !($thissurvey['active'] != "Y"));
$coreReplacements['ACTIVE'] = (isset($thissurvey['active']) && !($thissurvey['active'] != "Y"));
$coreReplacements['AID'] = isset($questiondetails['aid']) ? $questiondetails['aid'] : '';
$coreReplacements['ANSWER'] = isset($answer) ? $answer : ''; // global
$coreReplacements['ANSWERSCLEARED'] = $clang->gT("Answers cleared");
Expand All @@ -746,7 +747,7 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de
$coreReplacements['CLOSEWINDOW'] = "<a href='javascript:%20self.close()'>".$clang->gT("Close this window")."</a>";
$coreReplacements['COMPLETED'] = isset($redata['completed']) ? $redata['completed'] : ''; // global
$coreReplacements['DATESTAMP'] = $_datestamp;
$coreReplacements['ENDTEXT'] = $_endtext;
$coreReplacements['ENDTEXT'] = $_endtext;
$coreReplacements['EXPIRY'] = $_dateoutput;
$coreReplacements['GID'] = isset($questiondetails['gid']) ? $questiondetails['gid']: '';
$coreReplacements['GOOGLE_ANALYTICS_API_KEY'] = $_googleAnalyticsAPIKey;
Expand Down Expand Up @@ -826,7 +827,8 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de
}

// Now do all of the replacements - In rare cases, need to do 3 deep recursion, that that is default
$line = LimeExpressionManager::ProcessString($line, $questionNum, $doTheseReplacements, false, 3, 1);
$line = LimeExpressionManager::ProcessString($line, $questionNum, $doTheseReplacements, false, 3, 1, false, true, $bStaticReplacement);

return $line;

}
Expand Down

0 comments on commit 001a6cc

Please sign in to comment.