Skip to content

Commit

Permalink
Dev: Clean up merge problems
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed May 25, 2018
1 parent 4caa8b8 commit 35f7146
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 36 deletions.
56 changes: 28 additions & 28 deletions application/controllers/admin/questions.php
Expand Up @@ -16,6 +16,8 @@
*
*/

use \LimeSurvey\Helpers\questionHelper;

/**
* question
*
Expand Down Expand Up @@ -1218,12 +1220,10 @@ public function index($sa, $surveyid, $gid, $qid = null)
$aData['oQuestion'] = $oQuestion;
$aData['surveyid'] = $surveyid;
$aData['gid'] = $gid;
$questionTemplateAttributes = Question::model()->getAdvancedSettingsWithValues($qid, $eqrow['type'], $surveyid);
$aData['aQuestionTemplateAttributes'] = $questionTemplateAttributes['question_template'];
} else {
$aData['aQuestionTemplateAttributes']['core'] = array('title'=>'Default', 'preview'=>\LimeSurvey\Helpers\questionHelper::getQuestionThemePreviewUrl($eqrow['type']));
}

$questionTemplateAttributes = Question::model()->getAdvancedSettingsWithValues($qid, $oQuestion->type, $surveyid);
$aData['aQuestionTemplateAttributes'] = $questionTemplateAttributes['question_template'];
$aData['aQuestionTemplateAttributes']['core'] = array('title'=>'Default', 'preview' => questionHelper::getQuestionThemePreviewUrl($oQuestion->type));
$aData['aQuestionTemplateList'] = \QuestionTemplate::getQuestionTemplateList($oQuestion->type);

if (!$adding) {
$criteria = new CDbCriteria;
Expand All @@ -1244,7 +1244,7 @@ public function index($sa, $surveyid, $gid, $qid = null)
if (Yii::app()->session['questionselectormode'] !== 'default') {
$selectormodeclass = Yii::app()->session['questionselectormode'];
} else {
$selectormodeclass = getGlobalSetting('defaultquestionselectormode');
$selectormodeclass = getGlobalSetting('defaultquestionselectormode');
}

$aData['selectormodeclass'] = $selectormodeclass;
Expand Down Expand Up @@ -1275,7 +1275,7 @@ public function index($sa, $surveyid, $gid, $qid = null)
$aViewUrls['editQuestion_view'][] = $aData;
App()->getClientScript()->registerScript("EditQuestionView_question_jsviews_".$surveyid.$gid.$qid, "OtherSelection('".$oQuestion->type."');", LSYii_ClientScript::POS_POSTSCRIPT);
} else {
include('accessDenied.php');
include('accessDenied.php');
}


Expand Down Expand Up @@ -1569,26 +1569,26 @@ public function ajaxquestionattributes()

// INSERTING CUSTOM ATTRIBUTES FROM CORE QUESTION THEME XML FILE
if (!empty($question_template) && $question_template !== 'core') {
$questionTypeList = QuestionTemplate::getTypeToFolder();
$themeAttributes = \LimeSurvey\Helpers\questionHelper::getQuestionThemeAttributeValues($question_template, $questionTypeList[$type]);
// CHECK TO SEE IF ARRAY CONTAINS INDEX 0, IF NOT - INDEX 0 WOULD BE CREATED ( OTHERWISE DATA MERGE WOULD FAIL IF INDEX ÍS MISSING )
if (!array_key_exists('0', $themeAttributes)){$themeTemp[0] = $themeAttributes; $themeAttributes = $themeTemp;}
foreach ($themeAttributes as $key =>$attribute) {
// INSERTING EACH OF THIS KEYS TO THE ARRAY IF KEYS ARE MISSING
if (empty($attribute['name'])){$attribute['name'] = 'default_theme_attribute_name';}
if (empty($attribute['readonly'])){$attribute['readonly'] = '';}
if (empty($attribute['default'])){$attribute['default'] = '';}
if (empty($attribute['readonly_when_active'])){$attribute['readonly_when_active'] = '';}
if (empty($attribute['value'])){$attribute['value'] = '';}
if (empty($attribute['i18n'])){$attribute['i18n'] = '';}
if (empty($attribute['category'])){$attribute['category'] = 'Display Theme Options';}
if (empty($attribute['sortorder'])){$attribute['sortorder'] = '';}
if (empty($attribute['help'])){$attribute['help'] = '';}
if (empty($attribute['caption'])){$attribute['caption'] = '';}
if (empty($attribute['inputtype'])){$attribute['inputtype'] = '';}
$aAttributesWithValues[$attribute['name']] = $attribute;
}
$questionTypeList = QuestionTemplate::getTypeToFolder();
$themeAttributes = \LimeSurvey\Helpers\questionHelper::getQuestionThemeAttributeValues($question_template, $questionTypeList[$type]);
// CHECK TO SEE IF ARRAY CONTAINS INDEX 0, IF NOT - INDEX 0 WOULD BE CREATED ( OTHERWISE DATA MERGE WOULD FAIL IF INDEX ÍS MISSING )
if (!array_key_exists('0', $themeAttributes)){$themeTemp[0] = $themeAttributes; $themeAttributes = $themeTemp;}

foreach ($themeAttributes as $key => $attribute) {
// INSERTING EACH OF THIS KEYS TO THE ARRAY IF KEYS ARE MISSING
if (empty($attribute['name'])){$attribute['name'] = 'default_theme_attribute_name';}
if (empty($attribute['readonly'])){$attribute['readonly'] = '';}
if (empty($attribute['default'])){$attribute['default'] = '';}
if (empty($attribute['readonly_when_active'])){$attribute['readonly_when_active'] = '';}
if (empty($attribute['value'])){$attribute['value'] = '';}
if (empty($attribute['i18n'])){$attribute['i18n'] = '';}
if (empty($attribute['category'])){$attribute['category'] = 'Display Theme Options';}
if (empty($attribute['sortorder'])){$attribute['sortorder'] = '';}
if (empty($attribute['help'])){$attribute['help'] = '';}
if (empty($attribute['caption'])){$attribute['caption'] = '';}
if (empty($attribute['inputtype'])){$attribute['inputtype'] = '';}
$aAttributesWithValues[$attribute['name']] = $attribute;
}
}
uasort($aAttributesWithValues, 'categorySort');
unset($aAttributesWithValues['question_template']);
Expand Down
4 changes: 4 additions & 0 deletions application/helpers/questionHelper.php
Expand Up @@ -11,8 +11,12 @@
* See COPYRIGHT.php for copyright notices and details.
*
*/

namespace LimeSurvey\Helpers;
use QuestionAttribute;
use Yii;
use Question;

/**
* General helper class for question + question setting system
*/
Expand Down
2 changes: 1 addition & 1 deletion application/models/Question.php
Expand Up @@ -15,6 +15,7 @@
*
*/

use \LimeSurvey\Helpers\questionHelper;

/**
* Class Question
Expand Down Expand Up @@ -1109,5 +1110,4 @@ public function getAllSubQuestionIds()
}
return $result;
}

}
2 changes: 1 addition & 1 deletion application/models/QuestionAttribute.php
Expand Up @@ -199,7 +199,7 @@ public function getQuestionAttributes($iQuestionID, $sLanguage = null)
throw new \CException("Question is corrupt: no type defined for question ".$iQuestionID);
}

$aAttributeNames = questionHelper::getQuestionAttributesSettings($sType);
$aAttributeNames = \LimeSurvey\Helpers\questionHelper::getQuestionAttributesSettings($sType);

/* Get whole existing attribute for this question in an array*/
$oAttributeValues = QuestionAttribute::model()->findAll("qid=:qid", array('qid'=>$iQuestionID));
Expand Down
10 changes: 4 additions & 6 deletions application/views/admin/survey/Question/editQuestion_view.php
Expand Up @@ -16,14 +16,12 @@
<?php
$aQuestionTypeGroups = array();
$aQuestionTypeList = Question::typeList();
$question_template_preview = \LimeSurvey\Helpers\questionHelper::getQuestionThemePreviewUrl($eqrow['type']);
$question_template_preview = \LimeSurvey\Helpers\questionHelper::getQuestionThemePreviewUrl($oQuestion->type);
$selected = null;

foreach ( $aQuestionTypeList as $key=> $questionType)
{
foreach ($aQuestionTypeList as $key=> $questionType) {
$htmlReadyGroup = str_replace(' ', '_', strtolower($questionType['group']));
if (!isset($aQuestionTypeGroups[$htmlReadyGroup]))
{
if (!isset($aQuestionTypeGroups[$htmlReadyGroup])) {
$aQuestionTypeGroups[$htmlReadyGroup] = array(
'questionGroupName' => $questionType['group']
);
Expand Down Expand Up @@ -262,7 +260,7 @@
?>
</select>
<?php if ($activated == "Y"): ?>
<input type='hidden' name='gid' value='<?php echo $eqrow['gid'];?>' />
<input type='hidden' name='gid' value='<?php echo $oQuestion->gid;?>' />
<?php endif; ?>
</div>
</div>
Expand Down

0 comments on commit 35f7146

Please sign in to comment.