Skip to content

Commit

Permalink
Dev: Fixed issue #14385: PHP warning on data entry page in debug mode
Browse files Browse the repository at this point in the history
Dev: fix some questionL10ns related bug in view
  • Loading branch information
Shnoulle committed Jan 3, 2019
1 parent f26b07c commit 6347619
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 28 deletions.
19 changes: 12 additions & 7 deletions application/controllers/admin/dataentry.php
Expand Up @@ -1680,12 +1680,17 @@ public function view($surveyid)
} else {
$sDataEntryLanguage = $lang;
}

$langlistbox = languageDropdown($surveyid, $sDataEntryLanguage);
$thissurvey = getSurveyInfo($surveyid);

$aSurveyOption = array(
'startlanguage' => $sDataEntryLanguage,
);
// Unsure we use EM with current sid and language
LimeExpressionManager::SetSurveyId($surveyid);
LimeExpressionManager::SetEMLanguage($sDataEntryLanguage);
//This is the default, presenting a blank dataentry form
LimeExpressionManager::StartSurvey($surveyid, 'survey', null, false, LEM_PRETTY_PRINT_ALL_SYNTAX);
LimeExpressionManager::StartSurvey($surveyid, 'survey', $aSurveyOption, false, LEM_PRETTY_PRINT_ALL_SYNTAX);
LimeExpressionManager::NavigateForwards();

$aData = [];
Expand Down Expand Up @@ -1984,19 +1989,19 @@ private function _array_filter_help($qidattributes, $surveyprintlang, $surveyid)
if (!empty($qidattributes['array_filter'])) {

/** @var Question $question */
$question = Question::model()->findByAttributes(array('title' => $qidattributes['array_filter'], 'language' => $surveyprintlang, 'sid' => $surveyid));
$question = Question::model()->findByAttributes(array('title' => $qidattributes['array_filter'], 'sid' => $surveyid));
if ($question) {
$output .= "\n<p class='extrahelp'>
".sprintf(gT("Only answer this question for the items you selected in question %s ('%s')"), $qidattributes['array_filter'], flattenText(breakToNewline($question->question)))."
".sprintf(gT("Only answer this question for the items you selected in question %s ('%s')"), $qidattributes['array_filter'], flattenText(breakToNewline($question->questionL10ns[$surveyprintlang]->question)))."
</p>\n";
}
}
if (!empty($qidattributes['array_filter_exclude'])) {
/** @var Question $question */
$question = Question::model()->findByAttributes(array('title' => $qidattributes['array_filter_exclude'], 'language' => $surveyprintlang, 'sid' => $surveyid));
$question = Question::model()->findByAttributes(array('title' => $qidattributes['array_filter_exclude'], 'sid' => $surveyid));
if ($question) {
$output .= "\n <p class='extrahelp'>
".sprintf(gT("Only answer this question for the items you did not select in question %s ('%s')"), $qidattributes['array_filter_exclude'], breakToNewline($question->question))."
".sprintf(gT("Only answer this question for the items you did not select in question %s ('%s')"), $qidattributes['array_filter_exclude'], breakToNewline($question->questionL10ns[$surveyprintlang]->question))."
</p>\n";
}
}
Expand Down Expand Up @@ -2030,4 +2035,4 @@ protected function _renderWrappedTemplate($sAction = 'dataentry', $aViewUrls = a
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData, $sRenderFile);
}

}
}
4 changes: 2 additions & 2 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -3639,7 +3639,7 @@ public function setVariableAndTokenMappingsForExpressionManager($surveyid,$force
unset($_SESSION['LEMforceRefresh']);
$forceRefresh=true;
}
else if ($forceRefresh===false && isset($this->knownVars) && !$this->sPreviewMode ) {
else if ($forceRefresh===false && !empty($this->knownVars) && !$this->sPreviewMode ) {
return false; // means that those variables have been cached and no changes needed
}
$now = microtime(true);
Expand Down Expand Up @@ -8037,7 +8037,7 @@ public static function GetRelevanceAndTailoringJavaScript($bReturnArray=false)
// Now figure out which variables have not been declared (those not on the current page)
$undeclaredJsVars = array();
$undeclaredVal = array();
if ($LEM->knownVars)
if (!empty($LEM->knownVars))
{
if (!$LEM->allOnOnePage)
{
Expand Down
38 changes: 19 additions & 19 deletions application/views/admin/dataentry/content_view.php
Expand Up @@ -115,7 +115,7 @@
<?php foreach ($dearesult as $dearow):?>
<tr>
<td align='right'>
<?php echo $dearow['question']; ?>
<?php echo $dearow->questionL10ns[$sDataEntryLanguage]->question; ?>
</td>
<td>
<input type='text' name='<?php echo $fieldname.$dearow['title']; ?>' />
Expand Down Expand Up @@ -144,13 +144,13 @@
$delresult = Answer::model()->findAll("qid={$deqrow['qid']} and scale_id=0");
?>
<tr>
<td><?php echo $dearow['question']; ?></td>
<td><?php echo $dearow->questionL10ns[$sDataEntryLanguage]->question; ?></td>
<td>
<div class="col-sm-10">
<select name='<?php echo $fieldname.$dearow['title']; ?>#0' class='form-control'>
<option selected='selected' value=''><?php eT("Please choose..."); ?></option>
<?php foreach ($delresult as $delrow): ?>
<option value='<?php echo $delrow['code']; ?>'><?php echo $delrow->AnswerL10ns[$sDataEntryLanguage]->answer; ?></option>
<option value='<?php echo $delrow['code']; ?>'><?php echo $delrow->answerL10ns[$sDataEntryLanguage]->answer; ?></option>
<?php endforeach; ?>
</select>
</div>
Expand All @@ -162,7 +162,7 @@
<option selected='selected' value=''><?php eT("Please choose..."); ?></option>
<?php foreach ($delresult as $delrow)
{ ?>
<option value='<?php echo $delrow['code']; ?>'><?php echo $delrow->AnswerL10ns[$sDataEntryLanguage]->answer; ?></option>
<option value='<?php echo $delrow['code']; ?>'><?php echo $delrow->answerL10ns[$sDataEntryLanguage]->answer; ?></option>
<?php } ?>
</select>
</div>
Expand Down Expand Up @@ -357,7 +357,7 @@ function checkconditions(){
<tr>
<td>
<input type='checkbox' class='checkboxbtn' name='<?php echo $fieldname.$mearow['title']; ?>' value='Y'
/><?php echo $mearow['question']; ?>
/><?php echo $mearow->questionL10ns[$sDataEntryLanguage]->question; ?>
</td>

<td>
Expand Down Expand Up @@ -635,7 +635,7 @@ function updateJSON<?php echo $fieldname; ?>() {
<?php foreach ($mearesult as $mearow)
{ ?>
<tr>
<td align='right'><?php echo $mearow['question']; ?></td>
<td align='right'><?php echo $mearow->questionL10ns[$sDataEntryLanguage]->question; ?></td>
<td>
<select name='<?php echo $fieldname.$mearow['title']; ?>' class='form-control'>
<option value=''><?php eT("Please choose",'html',$sDataEntryLanguage); ?>..</option>
Expand All @@ -659,7 +659,7 @@ function updateJSON<?php echo $fieldname; ?>() {
<?php foreach ($mearesult as $mearow)
{ ?>
<tr>
<td align='right'><?php echo $mearow['question']; ?></td>
<td align='right'><?php echo $mearow->questionL10ns[$sDataEntryLanguage]->question; ?></td>
<td>
<select name='<?php echo $fieldname.$mearow['title']; ?>' class='form-control'>
<option value=''><?php eT("Please choose",'html',$sDataEntryLanguage); ?>..</option>
Expand All @@ -684,7 +684,7 @@ function updateJSON<?php echo $fieldname; ?>() {
<?php foreach ($mearesult as $mearow)
{ ?>
<tr>
<td align='right'><?php echo $mearow['question']; ?></td>
<td align='right'><?php echo $mearow->questionL10ns[$sDataEntryLanguage]->question; ?></td>
<td>
<select name='<?php echo $fieldname.$mearow['title']; ?>' class='form-control'>
<option value=''><?php eT("Please choose",'html',$sDataEntryLanguage); ?>..</option>
Expand All @@ -709,7 +709,7 @@ function updateJSON<?php echo $fieldname; ?>() {
<?php foreach ($mearesult as $mearow)
{ ?>
<tr>
<td align='right'><?php echo $mearow['question']; ?></td>
<td align='right'><?php echo $mearow->questionL10ns[$sDataEntryLanguage]->question; ?></td>
<td>
<select name='<?php echo $fieldname.$mearow['title']; ?>' class='form-control'>
<option value=''><?php eT("Please choose",'html',$sDataEntryLanguage); ?>..</option>
Expand All @@ -734,7 +734,7 @@ function updateJSON<?php echo $fieldname; ?>() {
<tr><td></td>
<?php foreach($lresult as $data)
{ ?>
<th><?php echo $data['question']; ?></th>
<th><?php echo $data->questionL10ns[$sDataEntryLanguage]->question; ?></th>
<?php $labelcodes[]=$data['title'];
}
?>
Expand All @@ -743,14 +743,14 @@ function updateJSON<?php echo $fieldname; ?>() {
foreach ($mearesult as $mearow)
{

if (strpos($mearow['question'],'|'))
if (strpos($mearow->questionL10ns[$sDataEntryLanguage]->question,'|'))
{
$answerleft=substr($mearow['question'],0,strpos($mearow['question'],'|'));
$answerright=substr($mearow['question'],strpos($mearow['question'],'|')+1);
$answerleft=substr($mearow->questionL10ns[$sDataEntryLanguage]->question,0,strpos($mearow->questionL10ns[$sDataEntryLanguage]->question,'|'));
$answerright=substr($mearow->questionL10ns[$sDataEntryLanguage]->question,strpos($mearow->questionL10ns[$sDataEntryLanguage]->question,'|')+1);
}
else
{
$answerleft=$mearow['question'];
$answerleft=$mearow->questionL10ns[$sDataEntryLanguage]->question;
$answerright='';
} ?>

Expand Down Expand Up @@ -789,7 +789,7 @@ function updateJSON<?php echo $fieldname; ?>() {
<?php $labelcodes=array();
foreach ($lresult as $data)
{ ?>
<th><?php echo $data['question']; ?></th>
<th><?php echo $data->questionL10ns[$sDataEntryLanguage]->question; ?></th>
<?php $labelcodes[]=$data['title'];
} ?>

Expand All @@ -798,14 +798,14 @@ function updateJSON<?php echo $fieldname; ?>() {
<?php $i=0;
foreach ($mearesult as $mearow)
{
if (strpos($mearow['question'],'|'))
if (strpos($mearow->questionL10ns[$sDataEntryLanguage]->question,'|'))
{
$answerleft=substr($mearow['question'],0,strpos($mearow['question'],'|'));
$answerright=substr($mearow['question'],strpos($mearow['question'],'|')+1);
$answerleft=substr($mearow->questionL10ns[$sDataEntryLanguage]->question,0,strpos($mearow->questionL10ns[$sDataEntryLanguage]->question,'|'));
$answerright=substr($mearow->questionL10ns[$sDataEntryLanguage]->question,strpos($mearow->questionL10ns[$sDataEntryLanguage]->question,'|')+1);
}
else
{
$answerleft=$mearow['question'];
$answerleft=$mearow->questionL10ns[$sDataEntryLanguage]->question;
$answerright='';
}
?>
Expand Down

0 comments on commit 6347619

Please sign in to comment.