Skip to content

Commit

Permalink
Fixed issue #10800: Setting conditions to a question: html codes are …
Browse files Browse the repository at this point in the history
…shown in GUI
  • Loading branch information
c-schmitz committed Mar 21, 2016
1 parent 857d2b9 commit 4a8b70d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 96 deletions.
158 changes: 64 additions & 94 deletions application/controllers/admin/conditionsaction.php
Expand Up @@ -16,8 +16,8 @@
*
* This controller performs token actions
*
* @package LimeSurvey
* @subpackage Backend
* @package LimeSurvey
* @subpackage Backend
*/
class conditionsaction extends Survey_Common_Action {

Expand Down Expand Up @@ -91,17 +91,17 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
if (Yii::app()->getConfig('stringcomparizonoperators') == 1)
{
$method = array(
"<" => gT("Less than"),
"<=" => gT("Less than or equal to"),
"==" => gT("equals"),
"!=" => gT("Not equal to"),
">=" => gT("Greater than or equal to"),
">" => gT("Greater than"),
"RX" => gT("Regular expression"),
"a<b" => gT("Less than (Strings)"),
"a<=b" => gT("Less than or equal to (Strings)"),
"a>=b" => gT("Greater than or equal to (Strings)"),
"a>b" => gT("Greater than (Strings)")
"<" => gT("Less than"),
"<=" => gT("Less than or equal to"),
"==" => gT("equals"),
"!=" => gT("Not equal to"),
">=" => gT("Greater than or equal to"),
">" => gT("Greater than"),
"RX" => gT("Regular expression"),
"a<b" => gT("Less than (Strings)"),
"a<=b" => gT("Less than or equal to (Strings)"),
"a>=b" => gT("Greater than or equal to (Strings)"),
"a>b" => gT("Greater than (Strings)")
);
}
else
Expand Down Expand Up @@ -256,11 +256,11 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
}

$condition_data = array(
'qid' => $qid,
'scenario' => $p_scenario,
'cqid' => $p_cqid,
'cfieldname' => $conditionCfieldname,
'method' => $p_method
'qid' => $qid,
'scenario' => $p_scenario,
'cqid' => $p_cqid,
'cfieldname' => $conditionCfieldname,
'method' => $p_method
);

if (isset($p_canswers))
Expand Down Expand Up @@ -313,7 +313,7 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
// UPDATE ENTRY IF THIS IS AN EDIT
if (isset($p_subaction) && $p_subaction == "updatecondition")
{
if (( !isset($p_canswers) &&
if (( !isset($p_canswers) &&
!isset($_POST['ConditionConst']) &&
!isset($_POST['prevQuestionSGQA']) &&
!isset($_POST['tokenAttr']) &&
Expand Down Expand Up @@ -461,11 +461,11 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
foreach ($result->readAll() as $row)
{
$proformaconditions[] = array(
"scenario" => $row['scenario'],
"cqid" => $row['cqid'],
"cfieldname" => $row['cfieldname'],
"method" => $row['method'],
"value" => $row['value']
"scenario" => $row['scenario'],
"cqid" => $row['cqid'],
"cfieldname" => $row['cfieldname'],
"method" => $row['method'],
"value" => $row['value']
);
} // while

Expand All @@ -477,12 +477,12 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)

//First lets make sure there isn't already an exact replica of this condition
$conditions_data = array(
'qid' => $newqid,
'scenario' => $pfc['scenario'],
'cqid' => $pfc['cqid'],
'cfieldname' => $pfc['cfieldname'],
'method' => $pfc['method'],
'value' => $pfc['value']
'qid' => $newqid,
'scenario' => $pfc['scenario'],
'cqid' => $pfc['cqid'],
'cfieldname' => $pfc['cfieldname'],
'method' => $pfc['method'],
'value' => $pfc['value']
);

$result = Condition::model()->findAllByAttributes($conditions_data);
Expand Down Expand Up @@ -541,7 +541,7 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
//END PROCESS ACTIONS

$cquestions = Array();
$canswers = Array();
$canswers = Array();

//BEGIN: GATHER INFORMATION
// 1: Get information for this question
Expand All @@ -553,7 +553,7 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
$qresult = Question::model()->with('groups')->findByAttributes(array('qid' => $qid, 'parent_qid' => 0, 'language' => Survey::model()->findByPk($iSurveyID)->language));
$questiongroupname = $qresult->groups->group_name;
$questiontitle = $qresult['title'];
$questiontext = $qresult['question'];
$sCurrentFullQuestionText = $qresult['question'];
$questiontype = $qresult['type'];

// 2: Get all other questions that occur before this question that are pre-determined answer types
Expand Down Expand Up @@ -626,14 +626,14 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
foreach ($result as $myrows)
{ //key => value
$theserows[] = array(
"qid" => $myrows['qid'],
"sid" => $myrows['sid'],
"gid" => $myrows['gid'],
"question" => $myrows['question'],
"type" => $myrows['type'],
"mandatory" => $myrows['mandatory'],
"other" => $myrows['other'],
"title" => $myrows['title']
"qid" => $myrows['qid'],
"sid" => $myrows['sid'],
"gid" => $myrows['gid'],
"question" => $myrows['question'],
"type" => $myrows['type'],
"mandatory" => $myrows['mandatory'],
"other" => $myrows['other'],
"title" => $myrows['title']
);
}
}
Expand All @@ -655,14 +655,14 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
foreach ($result as $myrows)
{
$postrows[]=array(
"qid" => $myrows['qid'],
"sid" => $myrows['sid'],
"gid" => $myrows['gid'],
"question" => $myrows['question'],
"type" => $myrows['type'],
"mandatory" => $myrows['mandatory'],
"other" => $myrows['other'],
"title" => $myrows['title']
"qid" => $myrows['qid'],
"sid" => $myrows['sid'],
"gid" => $myrows['gid'],
"question" => $myrows['question'],
"type" => $myrows['type'],
"mandatory" => $myrows['mandatory'],
"other" => $myrows['other'],
"title" => $myrows['title']
);
} // while
}
Expand Down Expand Up @@ -1034,7 +1034,7 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
{
// For dropdown questions
// optinnaly add the 'Other' answer
if ( ( $rows['type'] == "L" ||
if ( ( $rows['type'] == "L" ||
$rows['type'] == "!") &&
$rows['other'] == "Y" )
{
Expand All @@ -1060,34 +1060,16 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
{
$question=$row['question'];
$question=strip_tags($question);
if (strlen($question)<35)
{
$questionselecter = $question;
}
else
{
//$questionselecter = substr($question, 0, 35)."..";
$questionselecter = htmlspecialchars(mb_strcut(html_entity_decode($question,ENT_QUOTES,'UTF-8'), 0, 35, 'UTF-8'))."...";
}

$questionselecter = viewHelper::flatEllipsizeText($question,true,'40');
$questionNavOptions .= CHtml::tag('option', array(
'value' => $this->getController()->createUrl("/admin/conditions/sa/index/subaction/editconditionsform/surveyid/$iSurveyID/gid/{$row['gid']}/qid/{$row['qid']}")),
strip_tags($row['title']).':'.$questionselecter
);
}
$questionNavOptions .= CHtml::closeTag('optgroup');
$questionNavOptions .= CHtml::openTag('optgroup', array('class'=>'activesurveyselect', 'label'=>gT("Current","js")));
$question = strip_tags($questiontext);
if (strlen($question)<35)
{
$questiontextshort = $question;
}
else
{
//$questiontextshort = substr($question, 0, 35)."..";
$questiontextshort = htmlspecialchars(mb_strcut(html_entity_decode($question,ENT_QUOTES,'UTF-8'), 0, 35, 'UTF-8'))."...";
}

$question = strip_tags($sCurrentFullQuestionText);
$questiontextshort=viewHelper::flatEllipsizeText($question,true,'40');
$questionNavOptions .= CHtml::tag('option', array(
'value'=>$this->getController()->createUrl("/admin/conditions/sa/index/subaction/editconditionsform/surveyid/$iSurveyID/gid/$gid/qid/$qid"),
'selected'=>'selected'),
Expand All @@ -1099,15 +1081,7 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
{
$question=$row['question'];
$question=strip_tags($question);
if (strlen($question)<35)
{
$questionselecter = $question;
}
else
{
//$questionselecter = substr($question, 0, 35)."..";
$questionselecter = htmlspecialchars(mb_strcut(html_entity_decode($question,ENT_QUOTES,'UTF-8'), 0, 35, 'UTF-8'))."...";
}
$questionselecter=viewHelper::flatEllipsizeText($question,true,'40');
$questionNavOptions .= CHtml::tag('option', array(
'value' => $this->getController()->createUrl("/admin/conditions/sa/index/subaction/editconditionsform/surveyid/$iSurveyID/gid/{$row['gid']}/qid/{$row['qid']}")),
strip_tags($row['title']).':'.$questionselecter
Expand Down Expand Up @@ -1204,17 +1178,13 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
$scenarioresult = Condition::model()->findAll($criteria);
$scenariocount=count($scenarioresult);

//$showreplace="$questiontitle". $this->_showSpeaker($questiontext);
$showreplace=$questiontitle . $this->_showSpeaker($questiontext);
$onlyshow=sprintf(gT("Only show question %s IF"),$showreplace);

$aData['conditionsoutput'] = '';
$aData['extraGetParams'] = $extraGetParams;
$aData['quesitonNavOptions'] = $questionNavOptions;
$aData['conditionsoutput_action_error'] = $conditionsoutput_action_error;
$aData['javascriptpre'] = $javascriptpre;
$aData['onlyshow'] = $onlyshow;
$aData['showreplace'] = $showreplace;
$aData['onlyshow'] = sprintf(gT("Only show question %s IF"),$questiontitle .': '. $sCurrentFullQuestionText);
$aData['sCurrentQuestionText'] = $questiontitle .': '.viewHelper::flatEllipsizeText($sCurrentFullQuestionText,true,'120');
$aData['subaction'] = $subaction;
$aData['scenariocount'] = $scenariocount;

Expand Down Expand Up @@ -1246,7 +1216,7 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
$initialCheckbox = "";
}

if ( $scenariotext != "" && ($subaction == "editconditionsform" || $subaction == "insertcondition" ||
if ( $scenariotext != "" && ($subaction == "editconditionsform" || $subaction == "insertcondition" ||
$subaction == "updatecondition" || $subaction == "editthiscondition" ||
$subaction == "renumberscenarios" || $subaction == "updatescenario" ||
$subaction == "deletescenario" || $subaction == "delete")
Expand All @@ -1259,8 +1229,8 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)

$img_tag = '<span class="glyphicon glyphicon-pencil"></span>';
$additional_main_content .= CHtml::link($img_tag, '#', array(
'id' => 'editscenariobtn'.$scenarionr['scenario'],
'onclick' => "$('#editscenario{$scenarionr['scenario']}').toggle('slow');"
'id' => 'editscenariobtn'.$scenarionr['scenario'],
'onclick' => "$('#editscenario{$scenarionr['scenario']}').toggle('slow');"
));

$aData['additional_content'] = $additional_main_content;
Expand Down Expand Up @@ -1600,9 +1570,9 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
}
}

$aViewUrls['output'] .= CHtml::closeTag('td') . CHtml::closeTag('tr') .
$aViewUrls['output'] .= CHtml::closeTag('td') . CHtml::closeTag('tr') .
CHtml::closeTag('table'). CHtml::closeTag('form') .
CHtml::closeTag('td') . CHtml::closeTag('tr');
CHtml::closeTag('td') . CHtml::closeTag('tr');

$currentfield = $rows['cfieldname'];
}
Expand Down Expand Up @@ -1793,14 +1763,14 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
$aViewUrls['output'] .= "<option value='{TOKEN:".strtoupper($tokenattr)."}' $selectThisSrcTokenAttr>".HTMLEscape($tokenattrName['description'])."</option>\n";
}

$aViewUrls['output'] .= "</select>\n"
."</div>\n\n";
$aViewUrls['output'] .= "</select>
</div>\n\n";

$aViewUrls['output'] .= "\t</div>\n"; // end conditionsource div
$aViewUrls['output'] .= "\t</div>\n"; // end tab-content div

$aViewUrls['output'] .= "</div>\n"
."</div>\n";
$aViewUrls['output'] .= "</div>
</div>\n";

// Begin "Comparison operator" row
$aViewUrls['output'] .="<div class='condition-tbl-row'>\n"
Expand Down
4 changes: 2 additions & 2 deletions application/views/admin/conditions/conditionslist_view.php
Expand Up @@ -6,7 +6,7 @@
$subaction == "updatescenario" ||
$subaction == "renumberscenarios") : ?>

<div class="col-sm-4">
<div class="col-sm-8">
<strong>
<?php
// echo $onlyshow;
Expand All @@ -16,7 +16,7 @@
<br/><br/>
<blockquote>
<em>
<?php echo $showreplace;?>
<?php echo $sCurrentQuestionText;?>
</em>
</blockquote>
<br/>
Expand Down

0 comments on commit 4a8b70d

Please sign in to comment.