LimeSurvey API - Master branch

QuickTranslation
in package

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

Tags
todo

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

SuppressWarnings

(PHPMD.ExcessiveClassComplexity)

Table of Contents

Properties

$survey  : Survey
$translateFields  : mixed

Methods

__construct()  : mixed
Quicktranslation constructor.
getAllTranslateFields()  : array<string|int, mixed>
Get all single array elements from setupTranslateFields() in one array which are in getTabNames().
getAnswerTranslations()  : mixed
getQuestionTranslations()  : mixed
getSubquestionTranslations()  : mixed
getSurvey()  : Survey
Returns the survey object
getTabNames()  : array<string|int, string>
Returns all tab names.
getTranslations()  : array<string|int, mixed>|CActiveRecord|mixed|array<string|int, Question>|array<string|int, SurveyLanguageSetting>|void|null
This function gets the translation for a specific type.
setupTranslateFields()  : array<string|int, mixed>
Creates a customised array with database information for use by survey translation.
updateTranslations()  : int|null
Updates the translation for a given field name (e.g. surveyls_title)

Properties

$translateFields

private static mixed $translateFields = ['title' => [ 'type' => 1, 'dbColumn' => 'surveyls_title', 'id1' => '', 'id2' => '', 'gid' => false, //boolean value to indicate if used or not 'qid' => false, //boolean value to indicate if used or not 'HTMLeditorType' => "title", 'HTMLeditorDisplay' => "Inline", 'associated' => "description", ], 'description' => ['type' => 1, 'dbColumn' => 'surveyls_description', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "description", 'HTMLeditorDisplay' => "Inline", 'associated' => ""], 'welcome' => ['type' => 1, 'dbColumn' => 'surveyls_welcometext', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "welcome", 'HTMLeditorDisplay' => "Inline", 'associated' => "end"], 'end' => ['type' => 1, 'dbColumn' => 'surveyls_endtext', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "end", 'HTMLeditorDisplay' => "Inline", 'associated' => ""], 'group' => ['type' => 2, 'dbColumn' => 'group_name', 'id1' => 'gid', 'id2' => '', 'gid' => true, 'qid' => false, 'HTMLeditorType' => "group", 'HTMLeditorDisplay' => "Modal", 'associated' => "group_desc"], 'group_desc' => ['type' => 2, 'dbColumn' => 'description', 'id1' => 'gid', 'id2' => '', 'gid' => true, 'qid' => false, 'HTMLeditorType' => "group_desc", 'HTMLeditorDisplay' => "Modal", 'associated' => ""], 'question' => ['type' => 3, 'dbColumn' => 'question', 'id1' => 'qid', 'id2' => '', 'gid' => true, 'qid' => true, 'HTMLeditorType' => "question", 'HTMLeditorDisplay' => "Modal", 'associated' => "question_help"], 'question_help' => ['type' => 3, 'dbColumn' => 'help', 'id1' => 'qid', 'id2' => '', 'gid' => true, 'qid' => true, 'HTMLeditorType' => "question_help", 'HTMLeditorDisplay' => "Modal", 'associated' => ""], 'subquestion' => ['type' => 4, 'dbColumn' => 'question', 'id1' => 'qid', 'id2' => '', 'gid' => true, 'qid' => true, 'HTMLeditorType' => "question", 'HTMLeditorDisplay' => "Modal", 'associated' => ""], 'answer' => ['type' => 5, 'dbColumn' => 'answer', 'id1' => 'qid', 'id2' => 'code', 'scaleid' => 'scale_id', 'gid' => false, 'qid' => true, 'HTMLeditorType' => "subquestion", 'HTMLeditorDisplay' => "Modal", 'associated' => ""], 'emailinvite' => ['type' => 1, 'dbColumn' => 'surveyls_email_invite_subj', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "email", 'HTMLeditorDisplay' => "", 'associated' => "emailinvitebody"], 'emailinvitebody' => ['type' => 1, 'dbColumn' => 'surveyls_email_invite', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "email", 'HTMLeditorDisplay' => "Modal", 'associated' => ""], 'emailreminder' => ['type' => 1, 'dbColumn' => 'surveyls_email_remind_subj', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "email", 'HTMLeditorDisplay' => "", 'associated' => "emailreminderbody"], 'emailreminderbody' => ['type' => 1, 'dbColumn' => 'surveyls_email_remind', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "email", 'HTMLeditorDisplay' => "Modal", 'associated' => ""], 'emailconfirmation' => ['type' => 1, 'dbColumn' => 'surveyls_email_confirm_subj', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "email", 'HTMLeditorDisplay' => "", 'associated' => "emailconfirmationbody"], 'emailconfirmationbody' => ['type' => 1, 'dbColumn' => 'surveyls_email_confirm', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "email", 'HTMLeditorDisplay' => "Modal", 'associated' => ""], 'emailregistration' => ['type' => 1, 'dbColumn' => 'surveyls_email_register_subj', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "email", 'HTMLeditorDisplay' => "", 'associated' => "emailregistrationbody"], 'emailregistrationbody' => ['type' => 1, 'dbColumn' => 'surveyls_email_register', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "email", 'HTMLeditorDisplay' => "Modal", 'associated' => ""], 'emailbasicadminnotification' => ['type' => 1, 'dbColumn' => 'email_admin_notification_subj', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "email", 'HTMLeditorDisplay' => "", 'associated' => "emailbasicadminnotificationbody"], 'emailbasicadminnotificationbody' => ['type' => 1, 'dbColumn' => 'email_admin_notification', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "email", 'HTMLeditorDisplay' => "Modal", 'associated' => ""], 'emaildetailedadminnotification' => ['type' => 1, 'dbColumn' => 'email_admin_responses_subj', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "email", 'HTMLeditorDisplay' => "", 'associated' => "emaildetailedadminnotificationbody"], 'emaildetailedadminnotificationbody' => ['type' => 1, 'dbColumn' => 'email_admin_responses', 'id1' => '', 'id2' => '', 'gid' => false, 'qid' => false, 'HTMLeditorType' => "email", 'HTMLeditorDisplay' => "Modal", 'associated' => ""]]

Methods

__construct()

Quicktranslation constructor.

public __construct(Survey $survey) : mixed
Parameters
$survey : Survey

the survey object

getAllTranslateFields()

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

public getAllTranslateFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAnswerTranslations()

public getAnswerTranslations(mixed $baselang) : mixed
Parameters
$baselang : mixed

getQuestionTranslations()

public getQuestionTranslations(mixed $baselang) : mixed
Parameters
$baselang : mixed

getSubquestionTranslations()

public getSubquestionTranslations(mixed $baselang) : mixed
Parameters
$baselang : mixed

getTabNames()

Returns all tab names.

public getTabNames() : array<string|int, string>
Return values
array<string|int, string>

getTranslations()

This function gets the translation for a specific type.

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

Different types need different query.

Parameters
$type :
$baselang :
Return values
array<string|int, mixed>|CActiveRecord|mixed|array<string|int, Question>|array<string|int, SurveyLanguageSetting>|void|null

setupTranslateFields()

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

public setupTranslateFields(string $type) : array<string|int, mixed>

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

Parameters
$type : string

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

Return values
array<string|int, mixed>

updateTranslations()

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

public updateTranslations( $fieldName,  $tolang,  $new[,  $qidOrgid = 0 ][,  $answerCode = '' ][,  $iScaleID = '' ]) : int|null
Parameters
$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 : = 0

int groupid or questionid

$answerCode : = ''

string the answer code

$iScaleID : = ''
Return values
int|null

        
On this page

Search results