Skip to content
Permalink
Browse files

Fixed issue #15342: Error message when opening survey quick translate…

… page
  • Loading branch information...
dominikvitt committed Oct 8, 2019
1 parent 6cba3e0 commit 17aa5e2794fb3293143658fc2045ecb44adf7b27
Showing with 58 additions and 22 deletions.
  1. +58 −22 application/controllers/admin/translate.php
@@ -178,17 +178,48 @@ private function _displayUntranslatedFields($iSurveyID, $tolang, $baselang, $tab
$countResultBase = count($resultbase);
for ($j = 0; $j < $countResultBase; $j++) {
$rowfrom = $resultbase[$j];
$textfrom = htmlspecialchars_decode($rowfrom[$amTypeOptions["dbColumn"]]);
$textto = $resultto[$j][$amTypeOptions["dbColumn"]];
$oRowfrom = $resultbase[$j];
$oResultBase2 = $resultbase2[$j];
$oResultTo = $resultto[$j];
$oResultTo2 = $resultto2[$j];
$aRowfrom = array();
$aResultBase2 = array();
$aResultTo = array();
$aResultTo2 = array();
$class = get_class($oRowfrom);
if ($class == 'QuestionGroup'){
$aRowfrom = $oRowfrom->questionGroupL10ns[$baselang]->getAttributes();
$aResultBase2 = !empty($type2) ? $oResultBase2->questionGroupL10ns[$baselang]->getAttributes() : $aRowfrom;
$aResultTo = $oResultTo->questionGroupL10ns[$baselang]->getAttributes();
$aResultTo2 = !empty($type2) ? $oResultTo2->questionGroupL10ns[$baselang]->getAttributes() : $aResultTo;
} elseif ($class == 'Question' || $class == 'Subquestion'){
$aRowfrom = $oRowfrom->questionL10ns[$baselang]->getAttributes();
$aResultBase2 = !empty($type2) ? $oResultBase2->questionL10ns[$baselang]->getAttributes() : $aRowfrom;
$aResultTo = $oResultTo->questionL10ns[$baselang]->getAttributes();
$aResultTo2 = !empty($type2) ? $oResultTo2->questionL10ns[$baselang]->getAttributes() : $aResultTo;
} elseif ($class == 'Answer'){
$aRowfrom = $oRowfrom->answerL10ns[$baselang]->getAttributes();
$aResultBase2 = !empty($type2) ? $oResultBase2->answerL10ns[$baselang]->getAttributes() : $aRowfrom;
$aResultTo = $oResultTo->answerL10ns[$baselang]->getAttributes();
$aResultTo2 = !empty($type2) ? $oResultTo2->answerL10ns[$baselang]->getAttributes() : $aResultTo;
}
$aRowfrom = array_merge($aRowfrom, $oRowfrom->getAttributes());
$aResultBase2 = array_merge($aResultBase2, $oResultBase2->getAttributes());
$aResultTo = array_merge($aResultTo, $oResultTo->getAttributes());
$aResultTo2 = array_merge($aResultTo2, $oResultTo2->getAttributes());
$textfrom = htmlspecialchars_decode($aRowfrom[$amTypeOptions["dbColumn"]]);
//
$textto = $aResultTo[$amTypeOptions["dbColumn"]];
if ($associated) {
$textfrom2 = htmlspecialchars_decode($resultbase2[$j][$amTypeOptions2["dbColumn"]]);
$textto2 = $resultto2[$j][$amTypeOptions2["dbColumn"]];
$textfrom2 = htmlspecialchars_decode($aResultBase2[$amTypeOptions2["dbColumn"]]);
$textto2 = $aResultTo2[$amTypeOptions2["dbColumn"]];
}
$gid = ($amTypeOptions["gid"] == true) ? $gid = $rowfrom['gid'] : null;
$qid = ($amTypeOptions["qid"] == true) ? $qid = $rowfrom['qid'] : null;
$gid = ($amTypeOptions["gid"] == true) ? $gid = $aRowfrom['gid'] : null;
$qid = ($amTypeOptions["qid"] == true) ? $qid = $aRowfrom['qid'] : null;
$textform_length = strlen(trim($textfrom));
@@ -199,8 +230,8 @@ private function _displayUntranslatedFields($iSurveyID, $tolang, $baselang, $tab
'textfrom2' => $this->_cleanup($textfrom2, array()),
'textto' => $this->_cleanup($textto, array()),
'textto2' => $this->_cleanup($textto2, array()),
'rowfrom' => $rowfrom,
'rowfrom2' => $resultbase2,
'rowfrom' => $aRowfrom,
'rowfrom2' => $aResultBase2,
'evenRow' => $evenRow,
'gid' => $gid,
'qid' => $qid,
@@ -213,10 +244,10 @@ private function _displayUntranslatedFields($iSurveyID, $tolang, $baselang, $tab
));
$aData['translateFields'] = $this->displayTranslateFields($iSurveyID, $gid, $qid, $type,
$amTypeOptions, $baselangdesc, $tolangdesc, $textfrom, $textto, $j, $rowfrom, $evenRow);
$amTypeOptions, $baselangdesc, $tolangdesc, $textfrom, $textto, $j, $aRowfrom, $evenRow);
if ($associated && strlen(trim((string) $textfrom2)) > 0) {
$aData['translateFields'] .= $this->displayTranslateFields($iSurveyID, $gid, $qid, $type2,
$amTypeOptions2, $baselangdesc, $tolangdesc, $textfrom2, $textto2, $j, $resultbase2[$j], $evenRow);
$amTypeOptions2, $baselangdesc, $tolangdesc, $textfrom2, $textto2, $j, $aResultBase2, $evenRow);
}
$aViewUrls['output'] .= $this->getController()->renderPartial("/admin/translate/translatefields_view", $aData, true);
@@ -742,14 +773,22 @@ private function query($type, $action, $iSurveyID, $tolang, $baselang, $id1 = ""
return SurveyLanguageSetting::model()->resetScope()->findAllByPk(array('surveyls_survey_id'=>$iSurveyID, 'surveyls_language'=>$baselang));
case 'group':
case 'group_desc':
return QuestionGroup::model()->findAllByAttributes(array('sid'=>$iSurveyID, 'language'=>$baselang), array('order' => 'gid'));
return QuestionGroup::model()->with('questionGroupL10ns', array('condition' => 'language = ' . $baselang))->findAllByAttributes(array('sid'=>$iSurveyID), array('order' => 't.gid'));
case 'question':
case 'question_help':
return Question::model()->with('parents', 'groups')->findAllByAttributes(array('sid' => $iSurveyID, 'language' => $baselang, 'parent_qid' => 0), array('order' => 'groups.group_order, t.question_order, t.scale_id'));
return Question::model()->with('questionL10ns', array('condition' => 'language = ' . $baselang))->with('parent', 'group')->findAllByAttributes(array('sid' => $iSurveyID, 'parent_qid' => 0), array('order' => 'group.group_order, t.question_order, t.scale_id'));
case 'subquestion':
return Question::model()->with('parents', 'groups')->findAllByAttributes(array('sid' => $iSurveyID, 'language' => $baselang), array('order' => 'groups.group_order, parents.question_order, t.scale_id, t.question_order', 'condition'=>'parents.language=:baselang1 AND groups.language=:baselang2 AND t.parent_qid>0', 'params'=>array(':baselang1'=>$baselang, ':baselang2'=>$baselang)));
return Question::model()
->with('questionL10ns', array('condition' => 'language = ' . $baselang))
->with('parent', array('condition' => 'language = ' . $baselang))
->with('group', array('condition' => 'language = ' . $baselang))
->findAllByAttributes(array('sid' => $iSurveyID), array('order' => 'group.group_order, parent.question_order, t.scale_id, t.question_order', 'condition'=>'t.parent_qid>0', 'params'=>array()));
case 'answer':
return Answer::model()->with('questions', 'groups')->findAllByAttributes(array('language' => $baselang), array('order' => 'groups.group_order, questions.question_order, t.scale_id, t.sortorder', 'condition'=>'questions.sid=:sid AND questions.language=:baselang1 AND groups.language=:baselang2', 'params'=>array(':baselang1'=>$baselang, ':baselang2'=>$baselang, ':sid' => $iSurveyID)));
return Answer::model()
->with('answerL10ns', array('condition' => 'language = ' . $baselang))
->with('question')
->with('group')
->findAllByAttributes(array(), array('order' => 'group.group_order, question.question_order, t.scale_id, t.sortorder', 'condition'=>'question.sid=:sid', 'params'=>array(':sid' => $iSurveyID)));
}
case "queryupdate":
switch ($type) {
@@ -846,15 +885,12 @@ private function displayTranslateFields($iSurveyID, $gid, $qid, $type, $amTypeOp
// Display text in original language
// Display text in foreign language. Save a copy in type_oldvalue_i to identify changes before db update
if ($type == 'answer') {
//print_r($rowfrom->attributes);die();
$translateoutput .= "<td class='col-sm-2'>".htmlspecialchars($rowfrom->questions->title)." (".$rowfrom->questions->qid.") </td>";
$translateoutput .= "<td class='col-sm-2'>".htmlspecialchars($rowfrom['answer'])." (".$rowfrom['qid'].") </td>";
}
if ($type == 'question_help' || $type == 'question') {
//print_r($rowfrom->attributes);die();
$translateoutput .= "<td class='col-sm-2'>".htmlspecialchars($rowfrom->title)." ({$rowfrom->qid}) </td>";
$translateoutput .= "<td class='col-sm-2'>".htmlspecialchars($rowfrom['question'])." ({$rowfrom['qid']}) </td>";
} else if ($type == 'subquestion') {
//print_r($rowfrom->attributes);die();
$translateoutput .= "<td class='col-sm-2'>".htmlspecialchars($rowfrom->parents->title)." ({$rowfrom->parents->qid}) </td>";
$translateoutput .= "<td class='col-sm-2'>".htmlspecialchars($rowfrom['question'])." ({$rowfrom['qid']}) </td>";
}
$translateoutput .= "<td class='_from_ col-sm-5' id='".$type."_from_".$i."'>"

0 comments on commit 17aa5e2

Please sign in to comment.
You can’t perform that action at this time.