QuickTranslation

This class is responsible for quick translation and all DB actions needed.

todo

All the swithc-statements could be remade using OOP instead.

SuppressWarnings

(PHPMD.ExcessiveClassComplexity)

package

Default

Methods

Quicktranslation constructor.

__construct(\Survey $survey)

Arguments

$survey

\Survey

the survey object

Get all single array elements from setupTranslateFields() in one array which are in getTabNames().

getAllTranslateFields(): array

Response

array

getAnswerTranslations

getAnswerTranslations( $baselang)

Arguments

$baselang

getQuestionTranslations

getQuestionTranslations( $baselang)

Arguments

$baselang

getSubquestionTranslations

getSubquestionTranslations( $baselang)

Arguments

$baselang

Returns the survey object

getSurvey(): \Survey

Response

\Survey

Returns all tab names.

getTabNames(): array<mixed,string>

Response

array<mixed,string>

This function gets the translation for a specific type.

getTranslations( $type, $baselang): array|\CActiveRecord|mixed|array<mixed,\Question>|array<mixed,\SurveyLanguageSetting>|void|null

Different types need different query.

Arguments

$type

$baselang

Response

array|\CActiveRecord|mixed|array<mixed,\Question>|array<mixed,\SurveyLanguageSetting>|void|null

Creates a customised array with database information for use by survey translation.

setupTranslateFields(string $type): array

This array structure is the base for the whole algorithm. Each returned array consists of the following information

type --> this seems to be the db table in types (e.g. 1 --> surveys_languagesettings etc.) dbColumn --> the name of the db column where to find the id1 --> id2 --> gid --> qid --> description --> the tab title HTMLeditorType --> parameter for CKEditor HTMLeditorDisplay --> inline, modal for CKEditor to load it associated --> the associated field for the current one. If empty string this one has no associated field

Arguments

$type

string

Type of database field that is being translated, e.g. title, question, etc.

Response

array

Updates the translation for a given field name (e.g. surveyls_title)

updateTranslations( $fieldName, $tolang, $new, $qidOrgid, $answerCode = '', $iScaleID = ''): integer|null

Arguments

$fieldName

string the field name from frontend

$tolang

string shortcut for language (e.g. 'de')

$new

string the new value to save as translation

$qidOrgid

int groupid or questionid

$answerCode

string the answer code

$iScaleID

Response

integer|null

Properties

the survey

survey :\Survey
var

the survey

Type(s)

\Survey

translateFields

translateFields :
static

Type(s)