" .""
          .$jsMenuText."\n" ."\n"; return $menu; } /** * menuSeparator() creates a separator bar in the admin screen menus * @global string $imageurl * @return string */ function menuSeparator() { global $imageurl; return ("\n"); } /** * showTranslateAdminmenu() creates the main menu options for the survey translation page * @param string $surveyid The survey ID * @param string $survey_title * @param string $tolang * @param string $activated * @param string $scriptname * @global string $imageurl, $clang, $publicurl * @return string */ function showTranslateAdminmenu($surveyid, $survey_title, $tolang, $scriptname) { global $imageurl, $clang, $publicurl; $baselang = GetBaseLanguageFromSurveyID($surveyid); $supportedLanguages = getLanguageData(false); $langs = GetAdditionalLanguagesFromSurveyID($surveyid); $adminmenu = "" ."\n"; return($adminmenu); } /** * setupTranslateFields() creates a customised array with database query * information for use by survey translation * @global $dbprefix, $clang; * @param string $surveyid Survey id * @param string $type Type of database field that is being translated, e.g. title, question, etc. * @param string $baselang The source translation language code, e.g. "En" * @param string $tolang The target translation language code, e.g. "De" * @param string $new The new value of the translated string * @param string $id1 An index variable used in the database select and update query * @param string $id2 An index variable used in the database select and update query * @return array */ function setupTranslateFields($surveyid, $type, $tolang, $baselang, $id1="", $id2="", $new="") { global $dbprefix, $clang; switch ( $type ) { case 'title': $amTypeOptions = array( "querybase" => "SELECT * " ." FROM ".db_table_name('surveys_languagesettings') ." WHERE surveyls_survey_id=".db_quoteall($surveyid,true) ." AND surveyls_language=".db_quoteall($baselang,true), "queryto" => "SELECT * " ." FROM ".db_table_name('surveys_languagesettings') ." WHERE surveyls_survey_id=".db_quoteall($surveyid,true) ." AND surveyls_language=".db_quoteall($tolang,true), "queryupdate" => "UPDATE ".db_table_name('surveys_languagesettings') ." SET surveyls_title = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=".db_quoteall($surveyid,true) ." AND surveyls_language=".db_quoteall($tolang,true), "id1" => "", "id2" => "", "gid" => FALSE, "qid" => FALSE, "dbColumn" => 'surveyls_title', "description" => $clang->gT("Survey title and description"), "HTMLeditorType" => "title", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "Inline", // Allowed values: Inline, Popup or None "associated" => "description" ); break; case 'description': $amTypeOptions = array( "querybase" => "SELECT * " ." FROM ".db_table_name('surveys_languagesettings') ." WHERE surveyls_survey_id=".db_quoteall($surveyid,true) ." AND surveyls_language='{$baselang}' ", "queryto" => "SELECT * " ." FROM ".db_table_name('surveys_languagesettings') ." WHERE surveyls_survey_id=".db_quoteall($surveyid,true) ." AND surveyls_language='{$tolang}' ", "queryupdate" => "UPDATE ".db_table_name('surveys_languagesettings') ." SET surveyls_description = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=".db_quoteall($surveyid,true) ." AND surveyls_language='{$tolang}'", "id1" => "", "id2" => "", "gid" => FALSE, "qid" => FALSE, "dbColumn" => 'surveyls_description', "description" => $clang->gT("Description:"), "HTMLeditorType" => "description", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "Inline", // Allowed values: Inline, Popup or None "associated" => "" ); break; case 'welcome': $amTypeOptions = array( "querybase" => "SELECT * " ." FROM ".db_table_name('surveys_languagesettings') ." WHERE surveyls_survey_id=".db_quoteall($surveyid,true) ." AND surveyls_language='{$baselang}' ", "queryto" => "SELECT * " ." FROM ".db_table_name('surveys_languagesettings') ." WHERE surveyls_survey_id=".db_quoteall($surveyid,true) ." AND surveyls_language='{$tolang}' ", "queryupdate" => "UPDATE ".db_table_name('surveys_languagesettings') ." SET surveyls_welcometext = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=".db_quoteall($surveyid,true) ."AND surveyls_language='{$tolang}'", "id1" => "", "id2" => "", "gid" => FALSE, "qid" => FALSE, "dbColumn" => 'surveyls_welcometext', "description" => $clang->gT("Welcome and end text"), "HTMLeditorType" => "welcome", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "Inline", // Allowed values: Inline, Popup or None "associated" => "end" ); break; case 'end': $amTypeOptions = array( "querybase" => "SELECT * " ." FROM ".db_table_name('surveys_languagesettings') ." WHERE surveyls_survey_id=".db_quoteall($surveyid,true) ." AND surveyls_language='{$baselang}' ", "queryto" => "SELECT * " ."FROM ".db_table_name('surveys_languagesettings') ." WHERE surveyls_survey_id=".db_quoteall($surveyid,true) ." AND surveyls_language='{$tolang}' ", "queryupdate" => "UPDATE ".db_table_name('surveys_languagesettings') ." SET surveyls_endtext = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=".db_quoteall($surveyid,true) ." AND surveyls_language='{$tolang}'", "id1" => "", "id2" => "", "gid" => FALSE, "qid" => FALSE, "dbColumn" => 'surveyls_endtext', "description" => $clang->gT("End message:"), "HTMLeditorType" => "end", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "Inline", // Allowed values: Inline, Popup or None "associated" => "" ); break; case 'group': $amTypeOptions = array( "querybase" => "SELECT * " ." FROM ".db_table_name('groups') ." WHERE sid=".db_quoteall($surveyid,true) ." AND language='{$baselang}' " ." ORDER BY group_order ", "queryto" => "SELECT * " ."FROM ".db_table_name('groups') ." WHERE sid=".db_quoteall($surveyid,true) ." AND language=".db_quoteall($tolang,true) ." ORDER BY group_order ", "queryupdate" => "UPDATE ".db_table_name('groups') ." SET group_name = ".db_quoteall($new,true) ." WHERE gid = '{$id1}' " ." AND sid=".db_quoteall($surveyid,true) ." AND language='{$tolang}'", "id1" => "gid", "id2" => "", "gid" => TRUE, "qid" => FALSE, "dbColumn" => "group_name", "description" => $clang->gT("Question groups"), "HTMLeditorType" => "group", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "Popup", // Allowed values: Inline, Popup or None "associated" => "group_desc" ); break; case 'group_desc': $amTypeOptions = array( "querybase" => "SELECT * " ." FROM ".db_table_name('groups') ." WHERE sid=".db_quoteall($surveyid,true) ." AND language='{$baselang}' " ."ORDER BY group_order ", "queryto" => "SELECT *" ." FROM ".db_table_name('groups') ." WHERE sid=".db_quoteall($surveyid,true) ."AND language=".db_quoteall($tolang,true) ."ORDER BY group_order ", "queryupdate" => "UPDATE ".db_table_name('groups') ."SET description = ".db_quoteall($new,true) ."WHERE gid = '{$id1}' " ."AND sid=".db_quoteall($surveyid,true) ."AND language='{$tolang}'", "id1" => "gid", "id2" => "", "gid" => TRUE, "qid" => FALSE, "dbColumn" => "description", "description" => $clang->gT("Group description"), "HTMLeditorType" => "group_desc", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "Popup", // Allowed values: Inline, Popup or None "associated" => "" ); break; case 'question': $amTypeOptions = array( "querybase" => "SELECT q.qid as questionid, q.title, q.question, q.qid, q.gid " ." FROM ".db_table_name('questions')." q " ." JOIN ".db_table_name('groups')." g ON g.gid=q.gid " ." WHERE q.sid=".db_quoteall($surveyid,true) ." AND q.language='{$baselang}' " ." AND g.language='{$baselang}' " ." AND q.parent_qid=0 " ." ORDER BY g.group_order,q.question_order, q.scale_id ", "queryto" => "SELECT q.qid as questionid, q.title, q.question, q.qid, q.gid " ." FROM ".db_table_name('questions')." q " ." JOIN ".db_table_name('groups')." g ON g.gid=q.gid " ." WHERE q.sid=".db_quoteall($surveyid,true) ." AND q.language='{$tolang}' " ." AND g.language='{$tolang}' " ." AND q.parent_qid=0 " ." ORDER BY g.group_order,q.question_order, q.scale_id ", "queryupdate" => "UPDATE ".db_table_name('questions') ." SET question = ".db_quoteall($new,true) ." WHERE qid = '{$id1}' " ." AND sid=".db_quoteall($surveyid,true) ." AND parent_qid=0 " ." AND language='{$tolang}'", "dbColumn" => 'question', "id1" => 'qid', "id2" => "", "gid" => TRUE, "qid" => TRUE, "description" => $clang->gT("Questions"), "HTMLeditorType" => "question", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "Popup", // Allowed values: Inline, Popup or "" "associated" => "question_help" ); break; case 'question_help': $amTypeOptions = array( "querybase" => "SELECT q.qid as questionid, q.help, q.qid, q.title " ." FROM ".db_table_name('questions')." q " ." JOIN ".db_table_name('groups')." g ON g.gid=q.gid " ." WHERE g.sid=".db_quoteall($surveyid,true) ." AND q.language='{$baselang}' " ." AND g.language='{$baselang}' " ." AND parent_qid=0 " ." ORDER BY g.group_order,q.question_order ", "queryto" => "SELECT q.qid as questionid, q.help, q.qid, q.title " ." FROM ".db_table_name('questions')." q " ." JOIN ".db_table_name('groups')." g ON g.gid=q.gid " ." WHERE g.sid=".db_quoteall($surveyid,true) ." AND q.language='{$tolang}' " ." AND g.language='{$tolang}' " ." AND parent_qid=0 " ." ORDER BY g.group_order,q.question_order ", "queryupdate" => "UPDATE ".db_table_name('questions') ." SET help = ".db_quoteall($new,true) ." WHERE qid = '{$id1}' " ." AND sid=".db_quoteall($surveyid,true) ." AND parent_qid=0 " ." AND language='{$tolang}'", "dbColumn" => 'help', "id1" => 'qid', "id2" => "", "gid" => TRUE, "qid" => TRUE, "description" => "", "HTMLeditorType" => "question_help", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "Popup", // Allowed values: Inline, Popup or "" "associated" => "" ); break; case 'subquestion': $amTypeOptions = array( "querybase" => "SELECT q.qid as questionid, q.title, sq.qid, sq.question, sq.gid " ." FROM ".db_table_name('questions')." sq " ." JOIN ".db_table_name('questions')." q ON sq.parent_qid=q.qid " ." JOIN ".db_table_name('groups')." g ON g.gid=q.gid " ." WHERE sq.sid=".db_quoteall($surveyid,true) ." AND sq.language='{$baselang}' AND q.language='{$baselang}' AND g.language='{$baselang}' AND sq.parent_qid>0 " ." ORDER BY g.group_order, q.question_order,q.scale_id, sq.scale_id, sq.question_order ", "queryto" => "SELECT sq.question " ." FROM ".db_table_name('questions')." sq " ." JOIN ".db_table_name('questions')." q ON sq.parent_qid=q.qid " ." JOIN ".db_table_name('groups')." g ON g.gid=q.gid " ." WHERE sq.sid=".db_quoteall($surveyid,true) ." AND sq.language=".db_quoteall($tolang,true)." AND q.language=".db_quoteall($tolang,true)." AND g.language=".db_quoteall($tolang,true)." AND sq.parent_qid>0 " ." ORDER BY g.group_order, q.question_order,q.scale_id, sq.scale_id, sq.question_order ", "queryupdate" => "UPDATE ".db_table_name('questions') ." SET question = ".db_quoteall($new,true) ." WHERE qid = '{$id1}' " ." AND sid=".db_quoteall($surveyid,true) ." AND language='{$tolang}'", "dbColumn" => 'question', "id1" => 'qid', "id2" => "", "gid" => TRUE, "qid" => TRUE, "description" => $clang->gT("Subquestions"), "HTMLeditorType" => "question", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "Popup", // Allowed values: Inline, Popup or None "associated" => "" ); break; case 'answer': $amTypeOptions = array( "querybase" => "SELECT q.qid as questionid, a.code, a.answer, q.qid, q.title " ." FROM ".db_table_name('answers')." a " ." JOIN ".db_table_name('questions')." q ON a.qid=q.qid " ." JOIN ".db_table_name('groups')." g ON g.gid=q.gid " ." WHERE q.sid ='{$surveyid}' " ." AND q.qid = q.qid " ." AND a.language = '{$baselang}'" ." AND q.language = '{$baselang}'" ." AND g.language = '{$baselang}'" ." ORDER BY g.group_order, q.question_order, a.scale_id, a.sortorder", "queryto" => "SELECT a.code, a.answer, q.qid, q.title " ." FROM ".db_table_name('answers')." a " ." JOIN ".db_table_name('questions')." q ON a.qid=q.qid " ." JOIN ".db_table_name('groups')." g ON g.gid=q.gid " ." WHERE q.sid ='{$surveyid}' " ." AND q.qid = q.qid " ." AND a.language = ".db_quoteall($tolang,true) ." AND q.language = ".db_quoteall($tolang,true) ." AND g.language = ".db_quoteall($tolang,true) ." ORDER BY g.group_order, q.question_order, a.sortorder, a.scale_id", "queryupdate" => "UPDATE ".db_table_name('answers') ." SET answer = ".db_quoteall($new,true) ." WHERE qid = '{$id1}' " ." AND code='{$id2}' " ." AND language='{$tolang}'", "dbColumn" => 'answer', "id1" => 'qid', "id2" => 'code', "gid" => FALSE, "qid" => TRUE, "description" => $clang->gT("Answer options"), "HTMLeditorType" => "subquestion", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "Popup", // Allowed values: Inline, Popup or None "associated" => "" ); break; case 'emailinvite': $amTypeOptions = array( "querybase" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$baselang'" , "queryto" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$tolang'" , "queryupdate" => "UPDATE ".db_table_name("surveys_languagesettings") ." SET surveyls_email_invite_subj = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=$surveyid " ." AND surveyls_language='$tolang'", "dbColumn" => 'surveyls_email_invite_subj', "id1" => '', "id2" => '', "gid" => FALSE, "qid" => FALSE, "description" => $clang->gT("Invitation email"), "HTMLeditorType" => "email", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "", // Allowed values: Inline, Popup or "" "associated" => "emailinvitebody" ); break; case 'emailinvitebody': $amTypeOptions = array( "querybase" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$baselang'" , "queryto" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$tolang'" , "queryupdate" => "UPDATE ".db_table_name("surveys_languagesettings") ." SET surveyls_email_invite = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=$surveyid " ." AND surveyls_language='$tolang'", "dbColumn" => 'surveyls_email_invite', "id1" => '', "id2" => '', "gid" => FALSE, "qid" => FALSE, "description" => "", "HTMLeditorType" => "email", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "", // Allowed values: Inline, Popup or "" "associated" => "" ); break; case 'emailreminder': $amTypeOptions = array( "querybase" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$baselang'" , "queryto" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$tolang'" , "queryupdate" => "UPDATE ".db_table_name("surveys_languagesettings") ." SET surveyls_email_remind_subj = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=$surveyid " ." AND surveyls_language='$tolang'", "dbColumn" => 'surveyls_email_remind_subj', "id1" => '', "id2" => '', "gid" => FALSE, "qid" => FALSE, "description" => $clang->gT("Reminder email"), "HTMLeditorType" => "email", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "", // Allowed values: Inline, Popup or "" "associated" => "emailreminderbody" ); break; case 'emailreminderbody': $amTypeOptions = array( "querybase" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$baselang'" , "queryto" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$tolang'" , "queryupdate" => "UPDATE ".db_table_name("surveys_languagesettings") ." SET surveyls_email_remind = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=$surveyid " ." AND surveyls_language='$tolang'", "dbColumn" => 'surveyls_email_remind', "id1" => '', "id2" => '', "gid" => FALSE, "qid" => FALSE, "description" => "", "HTMLeditorType" => "email", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "", // Allowed values: Inline, Popup or "" "associated" => "" ); break; case 'emailconfirmation': $amTypeOptions = array( "querybase" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$baselang'" , "queryto" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$tolang'" , "queryupdate" => "UPDATE ".db_table_name("surveys_languagesettings") ." SET surveyls_email_confirm_subj = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=$surveyid " ." AND surveyls_language='$tolang'", "dbColumn" => 'surveyls_email_confirm_subj', "id1" => '', "id2" => '', "gid" => FALSE, "qid" => FALSE, "description" => $clang->gT("Confirmation email"), "HTMLeditorType" => "email", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "", // Allowed values: Inline, Popup or "" "associated" => "emailconfirmationbody" ); break; case 'emailconfirmationbody': $amTypeOptions = array( "querybase" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$baselang'" , "queryto" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$tolang'" , "queryupdate" => "UPDATE ".db_table_name("surveys_languagesettings") ." SET surveyls_email_confirm = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=$surveyid " ." AND surveyls_language='$tolang'", "dbColumn" => 'surveyls_email_confirm', "id1" => '', "id2" => '', "gid" => FALSE, "qid" => FALSE, "description" => "", "HTMLeditorType" => "email", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "", // Allowed values: Inline, Popup or "" "associated" => "" ); break; case 'emailregistration': $amTypeOptions = array( "querybase" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$baselang'" , "queryto" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$tolang'" , "queryupdate" => "UPDATE ".db_table_name("surveys_languagesettings") ." SET surveyls_email_register_subj = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=$surveyid " ." AND surveyls_language='$tolang'", "dbColumn" => 'surveyls_email_register_subj', "id1" => '', "id2" => '', "gid" => FALSE, "qid" => FALSE, "description" => $clang->gT("Registration email"), "HTMLeditorType" => "email", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "", // Allowed values: Inline, Popup or "" "associated" => "emailregistrationbody" ); break; case 'emailregistrationbody': $amTypeOptions = array( "querybase" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$baselang'" , "queryto" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$tolang'" , "queryupdate" => "UPDATE ".db_table_name("surveys_languagesettings") ." SET surveyls_email_register = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=$surveyid " ." AND surveyls_language='$tolang'", "dbColumn" => 'surveyls_email_register', "id1" => '', "id2" => '', "gid" => FALSE, "qid" => FALSE, "description" => "", "HTMLeditorType" => "email", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "", // Allowed values: Inline, Popup or "" "associated" => "" ); break; case 'email_confirm': $amTypeOptions = array( "querybase" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$baselang'" , "queryto" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$tolang'" , "queryupdate" => "UPDATE ".db_table_name("surveys_languagesettings") ." SET surveyls_email_confirm_subj = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=$surveyid " ." AND surveyls_language='$tolang'", "dbColumn" => 'surveyls_email_confirm_subj', "id1" => '', "id2" => '', "gid" => FALSE, "qid" => FALSE, "description" => $clang->gT("Confirmation email"), "HTMLeditorType" => "email", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "", // Allowed values: Inline, Popup or "" "associated" => "email_confirmbody" ); break; case 'email_confirmbody': $amTypeOptions = array( "querybase" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$baselang'" , "queryto" => "SELECT * FROM ".db_table_name("surveys_languagesettings") ." WHERE surveyls_survey_id=$surveyid and surveyls_language='$tolang'" , "queryupdate" => "UPDATE ".db_table_name("surveys_languagesettings") ." SET surveyls_email_confirm = ".db_quoteall($new,true) ." WHERE surveyls_survey_id=$surveyid " ." AND surveyls_language='$tolang'", "dbColumn" => 'surveyls_email_confirm', "id1" => '', "id2" => '', "gid" => FALSE, "qid" => FALSE, "description" => "", "HTMLeditorType" => "email", // This value is passed to HTML editor and determines LimeReplacementFields "HTMLeditorDisplay" => "", // Allowed values: Inline, Popup or "" "associated" => "" ); break; } return($amTypeOptions); } /** * displayTranslateFieldsHeader() Formats and displays header of translation fields table * @param string $baselangdesc The source translation language, e.g. "English" * @param string $tolangdesc The target translation language, e.g. "German" * @param string $type The target translation language, e.g. "German" * @return string $translateoutput */ function displayTranslateFieldsHeader($baselangdesc, $tolangdesc, $type) { global $clang; $translateoutput = ''; if ($type=='question' || $type=='subquestion' || $type=='question_help' || $type=='answer') { $translateoutput.=''; } $translateoutput.='' . '' . "\n"; if ($type=='question' || $type=='subquestion' || $type=='question_help' || $type=='answer') { $translateoutput.="\n"; } $translateoutput.="\n" . "\n" . "\n"; return($translateoutput); } /** * displayTranslateFieldsFooter() Formats and displays footer of translation fields table * @return string $translateoutput */ function displayTranslateFieldsFooter() { $translateoutput = "" . "
{$clang->gT('Question code / ID')}{$baselangdesc}{$tolangdesc}
\n"; return($translateoutput); } /** * displayTranslateFields() Formats and displays translation fields (base language as well as to language) * @global $dbprefix, $clang; * @param string $surveyid Survey id * @param string $gid Group id * @param string $qid Question id * @param string $type Type of database field that is being translated, e.g. title, question, etc. * @param array $amTypeOptions Array containing options associated with each $type * @param string $baselangdesc The source translation language, e.g. "English" * @param string $tolangdesc The target translation language, e.g. "German" * @param string $textfrom The text to be translated in source language * @param string $textto The text to be translated in target language * @param integer $i Counter * @param string $rowfrom Contains current row of database query * @param boolean $evenRow True for even rows, false for odd rows * @return string $translateoutput */ function displayTranslateFields($surveyid, $gid, $qid, $type, $amTypeOptions, $baselangdesc, $tolangdesc, $textfrom, $textto, $i, $rowfrom, $evenRow) { $translateoutput = ""; if ($evenRow) { $translateoutput .= ""; } else { $translateoutput .= ""; } $value1 = ""; if ($amTypeOptions["id1"] != "") $value1 = $rowfrom[$amTypeOptions["id1"]]; $value2 = ""; if ($amTypeOptions["id2"] != "") $value2 = $rowfrom[$amTypeOptions["id2"]]; // 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=='question' || $type=='subquestion' || $type=='question_help' || $type=='answer') { $translateoutput .= "" . "".htmlspecialchars($rowfrom['title'])." ({$rowfrom['questionid']})\n"; } $translateoutput .= "$textfrom\n" . "\n"; $translateoutput .= "\n"; $translateoutput .= "\n"; $nrows = max(calc_nrows($textfrom), calc_nrows($textto)); $translateoutput .= "\n"; $translateoutput .= "\n"; if ($amTypeOptions["HTMLeditorDisplay"]=="Inline") { $translateoutput .= "" .getEditor("edit".$type , $type."_newvalue_".$i, htmlspecialchars($textto), $surveyid, $gid, $qid, "translate".$amTypeOptions["HTMLeditorType"]); } if ($amTypeOptions["HTMLeditorDisplay"]=="Popup") { $translateoutput .= "" .getPopupEditor("edit".$type , $type."_newvalue_".$i, urlencode($amTypeOptions['description']), $surveyid, $gid, $qid, "translate".$amTypeOptions["HTMLeditorType"]); } $translateoutput .= "\n\n" . "\n"; return($translateoutput); } /** * calc_nrows($subject) calculates the vertical size of textbox for survey translation. * The function adds the number of line breaks
to the number of times a string wrap occurs. * @param string $subject The text string that is being translated * @return integer */ function calc_nrows( $subject ) { // Determines the size of the text box // A proxy for box sixe is string length divided by 80 $pattern = "()"; //$pattern = "/\n/"; $pattern = '[()|(/\n/)]'; $nrows_newline = preg_match_all($pattern, $subject, $matches); $nrows_char = ceil(strlen((string)$subject)/80); return $nrows_newline + $nrows_char; } ?>