Skip to content

Commit

Permalink
Fixed issue #05686: Dynamic Image with Expression Manager (SPAN problem)
Browse files Browse the repository at this point in the history
Dev Expressions that are only comprised solely of off-screen variables will be statically substituted  (e.g. not use a <span> tag)

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@12188 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
TMSWhite committed Jan 24, 2012
1 parent 8eeb72e commit fde2044
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions application/helpers/expressions/em_core_helper.php
Expand Up @@ -1074,6 +1074,36 @@ public function GetAllJsVarsUsed()
return array_unique($jsNames);
}

/**
* Return the list of all of the JavaScript variables used by the most recent expression - only those that are set on the current page
* This is used to control static vs dynamic substitution. If an expression is entirely made up of off-page changes, it can be statically replaced.
* @return <type>
*/
public function GetOnPageJsVarsUsed()
{
if (is_null($this->varsUsed)){
return array();
}
if ($this->allOnOnePage)
{
return GetJsVarsUsed();
}
$names = array_unique($this->varsUsed);
if (is_null($names)) {
return array();
}
$jsNames = array();
foreach ($names as $name)
{
$val = $this->GetVarAttribute($name,'jsName','');
$gseq = $this->GetVarAttribute($name,'gseq','');
if ($val != '' && $gseq == $this->groupSeq) {
$jsNames[] = $val;
}
}
return array_unique($jsNames);
}

/**
* Return the list of all of the JavaScript variables used by the most recent expression
* @return <type>
Expand Down Expand Up @@ -1939,11 +1969,12 @@ public function sProcessStringContainingExpressionsHelper($src, $questionNum, $s
$resolvedPart = $this->GetPrettyPrintString();
$allErrors[] = $this->GetErrors();
}
$onpageJsVarsUsed = $this->GetOnPageJsVarsUsed();
$jsVarsUsed = $this->GetJsVarsUsed();
$prettyPrintParts[] = $this->GetPrettyPrintString();
$this->allVarsUsed = array_merge($this->allVarsUsed,$this->GetVarsUsed());

if (count($jsVarsUsed) > 0 && !$staticReplacement)
if (count($onpageJsVarsUsed) > 0 && !$staticReplacement)
{
$idName = "LEMtailor_Q_" . $questionNum . "_" . $this->substitutionNum;
// $resolvedParts[] = "<span id='" . $idName . "'>" . htmlspecialchars($resolvedPart,ENT_QUOTES,'UTF-8',false) . "</span>"; // TODO - encode within SPAN?
Expand All @@ -1955,7 +1986,7 @@ public function sProcessStringContainingExpressionsHelper($src, $questionNum, $s
'id' => $idName,
'raw' => $stringPart[0],
'result' => $resolvedPart,
'vars' => implode('|',$this->GetJsVarsUsed()),
'vars' => implode('|',$jsVarsUsed),
'js' => $this->GetJavaScriptFunctionForReplacement($questionNum, $idName, substr($stringPart[0],1,-1)),
);
}
Expand Down

0 comments on commit fde2044

Please sign in to comment.