本文整理汇总了PHP中GetAdditionalLanguagesFromSurveyID函数的典型用法代码示例。如果您正苦于以下问题:PHP GetAdditionalLanguagesFromSurveyID函数的具体用法?PHP GetAdditionalLanguagesFromSurveyID怎么用?PHP GetAdditionalLanguagesFromSurveyID使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetAdditionalLanguagesFromSurveyID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade_question_attributes148
function upgrade_question_attributes148()
{
global $modifyoutput, $dbprefix;
$sDBPrefix = $dbprefix;
$sSurveyQuery = "SELECT sid FROM {$sDBPrefix}surveys";
$oSurveyResult = db_execute_assoc($sSurveyQuery);
foreach ($oSurveyResult->FetchRow() as $aSurveyRow) {
$surveyid = $aSurveyRow['sid'];
$languages = array_merge(array(GetBaseLanguageFromSurveyID($surveyid)), GetAdditionalLanguagesFromSurveyID($surveyid));
$sAttributeQuery = "select q.qid,attribute,value from {$sDBPrefix}question_attributes qa , {$sDBPrefix}questions q where q.qid=qa.qid and sid={$surveyid}";
$oAttributeResult = db_execute_assoc($sAttributeQuery);
$aAllAttributes = questionAttributes(true);
foreach ($oAttributeResult->FetchRow() as $aAttributeRow) {
if (isset($aAllAttributes[$aAttributeRow['attribute']]['i18n']) && $aAllAttributes[$aAttributeRow['attribute']]['i18n']) {
modify_database("delete from {$sDBPrefix}question_attributes where qid={$aAttributeRow['qid']} and attribute='{$aAttributeRow['attribute']}'");
echo $modifyoutput;
flush();
@ob_flush();
foreach ($languages as $language) {
$sAttributeInsertQuery = "insert into {$sDBPrefix}question_attributes (qid,attribute,value,language) VALUES({$aAttributeRow['qid']},'{$aAttributeRow['attribute']}','{$aAttributeRow['value']}','{$language}' )";
modify_database("", $sAttributeInsertQuery);
echo $modifyoutput;
flush();
@ob_flush();
}
}
}
}
}
示例2: getQuotaAnswers
function getQuotaAnswers($qid, $surveyid, $quota_id)
{
global $clang;
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$query = "SELECT type, title FROM " . db_table_name('questions') . "q JOIN " . db_table_name('groups') . "g on g.gid=q.gid WHERE qid='{$qid}' AND q.language='{$baselang}' AND g.language='{$baselang}' order by group_order, question_order";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$qtype = $result->FetchRow();
if ($qtype['type'] == 'G') {
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array('M' => array('Title' => $qtype['title'], 'Display' => $clang->gT("Male"), 'code' => 'M'), 'F' => array('Title' => $qtype['title'], 'Display' => $clang->gT("Female"), 'code' => 'F'));
if ($result->RecordCount() > 0) {
while ($quotalist = $result->FetchRow()) {
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'M') {
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$query = "SELECT title,question FROM " . db_table_name('questions') . " WHERE parent_qid='{$qid}'";
$ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array();
while ($dbanslist = $ansresult->FetchRow()) {
$tmparrayans = array('Title' => $qtype['title'], 'Display' => substr($dbanslist['question'], 0, 40), 'code' => $dbanslist['title']);
$answerlist[$dbanslist['title']] = $tmparrayans;
}
if ($result->RecordCount() > 0) {
while ($quotalist = $result->FetchRow()) {
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'L' || $qtype['type'] == 'O' || $qtype['type'] == '!') {
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$query = "SELECT code,answer FROM " . db_table_name('answers') . " WHERE qid='{$qid}' and language='{$baselang}'";
$ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array();
while ($dbanslist = $ansresult->FetchRow()) {
$answerlist[$dbanslist['code']] = array('Title' => $qtype['title'], 'Display' => substr($dbanslist['answer'], 0, 40), 'code' => $dbanslist['code']);
}
if ($result->RecordCount() > 0) {
while ($quotalist = $result->FetchRow()) {
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'A') {
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$query = "SELECT title,question FROM " . db_table_name('questions') . " WHERE parent_qid='{$qid}'";
$ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array();
while ($dbanslist = $ansresult->FetchRow()) {
for ($x = 1; $x < 6; $x++) {
$tmparrayans = array('Title' => $qtype['title'], 'Display' => substr($dbanslist['question'], 0, 40) . ' [' . $x . ']', 'code' => $dbanslist['title']);
$answerlist[$dbanslist['title'] . "-" . $x] = $tmparrayans;
}
}
if ($result->RecordCount() > 0) {
while ($quotalist = $result->FetchRow()) {
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'B') {
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$query = "SELECT code,answer FROM " . db_table_name('answers') . " WHERE qid='{$qid}' and language='{$baselang}'";
$ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array();
while ($dbanslist = $ansresult->FetchRow()) {
for ($x = 1; $x < 11; $x++) {
$tmparrayans = array('Title' => $qtype['title'], 'Display' => substr($dbanslist['answer'], 0, 40) . ' [' . $x . ']', 'code' => $dbanslist['code']);
$answerlist[$dbanslist['code'] . "-" . $x] = $tmparrayans;
}
}
if ($result->RecordCount() > 0) {
while ($quotalist = $result->FetchRow()) {
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'Y') {
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array('Y' => array('Title' => $qtype['title'], 'Display' => $clang->gT("Yes"), 'code' => 'Y'), 'N' => array('Title' => $qtype['title'], 'Display' => $clang->gT("No"), 'code' => 'N'));
if ($result->RecordCount() > 0) {
while ($quotalist = $result->FetchRow()) {
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'I') {
$slangs = GetAdditionalLanguagesFromSurveyID($surveyid);
array_unshift($slangs, $baselang);
$query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
while (list($key, $value) = each($slangs)) {
//.........这里部分代码省略.........
示例3: showTranslateAdminmenu
/**
* 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 = "" . "<div class='menubar'>\n" . "<div class='menubar-title ui-widget-header'>\n" . "<strong>" . $clang->gT("Translate survey") . ": {$survey_title}</strong>\n" . "</div>\n" . "<div class='menubar-main'>\n";
$adminmenu .= "" . "<div class='menubar-left'>\n";
// Return to survey administration button
$adminmenu .= menuItem($clang->gT("Return to survey administration"), $clang->gTview("Return to survey administration"), "Administration", "home.png", "{$scriptname}?sid={$surveyid}");
// Separator
$adminmenu .= menuSeparator();
// Test / execute survey button
if ($tolang != "") {
$sumquery1 = "SELECT * FROM " . db_table_name('surveys') . " inner join " . db_table_name('surveys_languagesettings') . " on (surveyls_survey_id=sid and surveyls_language=language) WHERE sid={$surveyid}";
//Getting data for this survey
$sumresult1 = db_select_limit_assoc($sumquery1, 1);
//Checked
$surveyinfo = $sumresult1->FetchRow();
$surveyinfo = array_map('FlattenText', $surveyinfo);
$activated = $surveyinfo['active'];
if ($activated == "N") {
$menutext = $clang->gT("Test This Survey");
$menutext2 = $clang->gTview("Test This Survey");
} else {
$menutext = $clang->gT("Execute This Survey");
$menutext2 = $clang->gTview("Execute This Survey");
}
if (count(GetAdditionalLanguagesFromSurveyID($surveyid)) == 0) {
$adminmenu .= menuItem($menutext, $menutext2, "do.png", "{$publicurl}/index.php?sid={$surveyid}&newtest=Y&lang={$baselang}");
} else {
$icontext = $clang->gT($menutext);
$icontext2 = $clang->gT($menutext);
$adminmenu .= "<a href='#' id='dosurvey' class='dosurvey'" . "title=\"" . $icontext2 . "\" accesskey='d'>" . "<img src='{$imageurl}/do.png' alt='{$icontext}' />" . "</a>\n";
$tmp_survlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$tmp_survlangs[] = $baselang;
rsort($tmp_survlangs);
// Test Survey Language Selection Popup
$adminmenu .= "<div class=\"langpopup\" id=\"dosurveylangpopup\">" . $clang->gT("Please select a language:") . "<ul>";
foreach ($tmp_survlangs as $tmp_lang) {
$adminmenu .= "<li><a accesskey='d' onclick=\"\$('.dosurvey').qtip('hide');" . "\" target='_blank' href='{$publicurl}/index.php?sid={$surveyid}&" . "newtest=Y&lang={$tmp_lang}'>" . getLanguageNameFromCode($tmp_lang, false) . "</a></li>";
}
$adminmenu .= "</ul></div>";
}
}
// End of survey-bar-left
$adminmenu .= "</div>";
// Survey language list
$selected = "";
if (!isset($tolang)) {
$selected = " selected='selected' ";
}
$adminmenu .= "" . "<div class='menubar-right'>\n" . "<span class=\"boxcaption\">" . $clang->gT("Translate to") . ":</span>" . "<select onchange=\"window.open(this.options[this.selectedIndex].value,'_top')\">\n";
if (count(GetAdditionalLanguagesFromSurveyID($surveyid)) > 1) {
$adminmenu .= "<option {$selected} value='{$scriptname}?action=translate&sid={$surveyid}'>" . $clang->gT("Please choose...") . "</option>\n";
}
foreach ($langs as $lang) {
$selected = "";
if ($tolang == $lang) {
$selected = " selected='selected' ";
}
$tolangtext = $supportedLanguages[$lang]['description'];
$adminmenu .= "<option {$selected} value='{$scriptname}?action=translate&sid={$surveyid}&tolang={$lang}'> " . $tolangtext . " </option>\n";
}
$adminmenu .= "" . "</select>\n" . "</div>\n";
// End of menubar-right
$adminmenu .= "" . "</div>\n";
$adminmenu .= "" . "</div>\n";
return $adminmenu;
}
示例4: importQuestion
//.........这里部分代码省略.........
$countlabelsets = 0;
}
if (isset($labelsarray)) {
$countlabels = count($labelsarray) - 1;
} else {
$countlabels = 0;
}
if (isset($question_attributesarray)) {
$countquestion_attributes = count($question_attributesarray) - 1;
} else {
$countquestion_attributes = 0;
}
$languagesSupported = array();
// this array will keep all the languages supported for the survey
// Let's check that imported objects support at least the survey's baselang
$langcode = GetBaseLanguageFromSurveyID($surveyid);
$languagesSupported[$langcode] = 1;
// adds the base language to the list of supported languages
$this->debugLsrc("wir sind in " . __FILE__ . " - " . __FUNCTION__ . " Line " . __LINE__ . ", OK ");
if ($countquestions > 0) {
$questionfieldnames = convertCSVRowToArray($questionarray[0], ',', '"');
$langfieldnum = array_search("language", $questionfieldnames);
$qidfieldnum = array_search("qid", $questionfieldnames);
$questionssupportbaselang = bDoesImportarraySupportsLanguage($questionarray, array($qidfieldnum), $langfieldnum, $langcode, true);
if (!$questionssupportbaselang) {
// $importquestion .= "<strong><font color='red'>".("Error")."</font></strong>\n"
// .("You can't import a question which doesn't support the current survey's base language")."\n"
// ."</td></tr></table>\n";
// unlink($the_full_file_path);
return "You can't import a question which doesn't support the current survey's base language";
}
}
$this->debugLsrc("wir sind in " . __FILE__ . " - " . __FUNCTION__ . " Line " . __LINE__ . ", OK ");
foreach (GetAdditionalLanguagesFromSurveyID($surveyid) as $language) {
$languagesSupported[$language] = 1;
}
// Let's assume that if the questions do support tye baselang
// Then the answers do support it as well.
// ==> So the following section is commented for now
//if ($countanswers > 0)
//{
// $langfieldnum = array_search("language", $answerfieldnames);
// $answercodefilednum1 = array_search("qid", $answerfieldnames);
// $answercodefilednum2 = array_search("code", $answerfieldnames);
// $answercodekeysarr = Array($answercodefilednum1,$answercodefilednum2);
// $answerssupportbaselang = bDoesImportarraySupportsLanguage($answerarray,$answercodekeysarr,$langfieldnum,$langcode);
// if (!$answerssupportbaselang)
// {
// $importquestion .= "<strong><font color='red'>".("Error")."</font></strong>\n"
// .("You can't import answers which don't support current survey's base language")."\n"
// ."</td></tr></table>\n";
// return;
// }
//
//}
$this->debugLsrc("wir sind in " . __FILE__ . " - " . __FUNCTION__ . " Line " . __LINE__ . ", OK ");
if ($countlabelsets > 0) {
$labelsetfieldname = convertCSVRowToArray($labelsetsarray[0], ',', '"');
$langfieldnum = array_search("languages", $labelsetfieldname);
$lidfilednum = array_search("lid", $labelsetfieldname);
$labelsetssupportbaselang = bDoesImportarraySupportsLanguage($labelsetsarray, array($lidfilednum), $langfieldnum, $langcode, true);
if (!$labelsetssupportbaselang) {
// $importquestion .= "<strong><font color='red'>".("Error")."</font></strong>\n"
// .("You can't import label sets which don't support the current survey's base language")."\n"
// ."</td></tr></table>\n";
// unlink($the_full_file_path);
示例5: array_map
$eqrow = array_map('htmlspecialchars', $eqrow);
$editquestion .= "\t<div class='settingrow'><span class='settingcaption'>" . $clang->gT("Code:") . "</span>\n" . "<span class='settingentry'><input type='text' size='20' maxlength='20' id='title' name='title' value=\"{$eqrow['title']}\" />\n" . "\t</span></div>\n";
$editquestion .= "\t<div class='settingrow'><span class='settingcaption'>" . $clang->gT("Question:") . "</span>\n" . "<span class='settingentry'><textarea cols='50' rows='4' name='question_{$eqrow['language']}'>{$eqrow['question']}</textarea>\n" . getEditor("question-text", "question_" . $eqrow['language'], "[" . $clang->gT("Question:", "js") . "](" . $eqrow['language'] . ")", $surveyid, $gid, $qid, $action) . "\t</span></div>\n" . "\t<div class='settingrow'><span class='settingcaption'>" . $clang->gT("Help:") . "</span>\n" . "<span class='settingentry'><textarea cols='50' rows='4' name='help_{$eqrow['language']}'>{$eqrow['help']}</textarea>\n" . getEditor("question-help", "help_" . $eqrow['language'], "[" . $clang->gT("Help:", "js") . "](" . $eqrow['language'] . ")", $surveyid, $gid, $qid, $action) . "\t</span></div>\n" . "\t<div class='settingrow'><span class='settingcaption'> </span>\n" . "<span class='settingentry'> \n" . "\t</span></div>\n";
$editquestion .= ' </div>';
if (!$adding) {
$aqquery = "SELECT * FROM {$dbprefix}questions WHERE sid={$surveyid} AND gid={$gid} AND qid={$qid} AND language != '{$baselang}'";
$aqresult = db_execute_assoc($aqquery);
while (!$aqresult->EOF) {
$aqrow = $aqresult->FetchRow();
$editquestion .= '<div id="' . $aqrow['language'] . '">';
$aqrow = array_map('htmlspecialchars', $aqrow);
$editquestion .= "\t<div class='settingrow'><span class='settingcaption'>" . $clang->gT("Question:") . "</span>\n" . "<span class='settingentry'><textarea cols='50' rows='4' name='question_{$aqrow['language']}'>{$aqrow['question']}</textarea>\n" . getEditor("question-text", "question_" . $aqrow['language'], "[" . $clang->gT("Question:", "js") . "](" . $aqrow['language'] . ")", $surveyid, $gid, $qid, $action) . "\t</span></div>\n" . "\t<div class='settingrow'><span class='settingcaption'>" . $clang->gT("Help:") . "</span>\n" . "<span class='settingentry'><textarea cols='50' rows='4' name='help_{$aqrow['language']}'>{$aqrow['help']}</textarea>\n" . getEditor("question-help", "help_" . $aqrow['language'], "[" . $clang->gT("Help:", "js") . "](" . $aqrow['language'] . ")", $surveyid, $gid, $qid, $action) . "\t</span></div>\n";
$editquestion .= '</div>';
}
} else {
$addlanguages = GetAdditionalLanguagesFromSurveyID($surveyid);
foreach ($addlanguages as $addlanguage) {
$editquestion .= '<div id="' . $addlanguage . '">';
$editquestion .= '</h2>';
$editquestion .= "\t<div class='settingrow'><span class='settingcaption'>" . $clang->gT("Question:") . "</span>\n" . "<span class='settingentry'><textarea cols='50' rows='4' name='question_{$addlanguage}'></textarea>\n" . getEditor("question-text", "question_" . $addlanguage, "[" . $clang->gT("Question:", "js") . "](" . $addlanguage . ")", $surveyid, $gid, $qid, $action) . "\t</span></div>\n" . "\t<div class='settingrow'><span class='settingcaption'>" . $clang->gT("Help:") . "</span>\n" . "<span class='settingentry'><textarea cols='50' rows='4' name='help_{$addlanguage}'></textarea>\n" . getEditor("question-help", "help_" . $addlanguage, "[" . $clang->gT("Help:", "js") . "](" . $addlanguage . ")", $surveyid, $gid, $qid, $action) . "\t</span></div>\n" . "\t<div class='settingrow'><span class='settingcaption'> </span>\n" . "<span class='settingentry'> \n" . "\t</span></div>\n";
$editquestion .= '</div>';
}
}
//question type:
$editquestion .= "\t<div id='questionbottom'><ul>\n" . "<li><label for='question_type'>" . $clang->gT("Question Type:") . "</label>\n";
if ($activated != "Y") {
$editquestion .= "<select id='question_type' style='margin-bottom:5px' name='type' " . ">\n" . getqtypelist($eqrow['type'], 'group') . "</select>\n";
} else {
$qtypelist = getqtypelist('', 'array');
$editquestion .= "{$qtypelist[$eqrow['type']]['description']} - " . $clang->gT("Cannot be changed (survey is active)") . "\n" . "<input type='hidden' name='type' id='question_type' value='{$eqrow['type']}' />\n";
}
示例6: makelanguagechanger
function makelanguagechanger()
{
global $relativeurl;
if (!isset($surveyid)) {
$surveyid = returnglobal('sid');
}
if (isset($surveyid)) {
$slangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$sBaseLanguage = GetBaseLanguageFromSurveyID($surveyid);
}
$token = sanitize_token(returnglobal('token'));
if ($token != '') {
$tokenparam = "&token={$token}";
} else {
$tokenparam = "";
}
$previewgrp = false;
if (isset($_REQUEST['action'])) {
if ($_REQUEST['action'] == 'previewgroup') {
$previewgrp = true;
}
}
if (!empty($slangs)) {
if (isset($_SESSION['s_lang']) && $_SESSION['s_lang'] != '') {
$lang = sanitize_languagecode($_SESSION['s_lang']);
} else {
if (isset($_POST['lang']) && $_POST['lang'] != '') {
$lang = sanitize_languagecode($_POST['lang']);
} else {
if (isset($_GET['lang']) && $_GET['lang'] != '') {
$lang = sanitize_languagecode($_GET['lang']);
} else {
$lang = $sBaseLanguage;
}
}
}
$slangs[] = $sBaseLanguage;
$aAllLanguages = getLanguageData();
$slangs = array_keys(array_intersect_key($aAllLanguages, array_flip($slangs)));
// Sort languages by their locale name
$htmlcode = "<select name=\"select\" class='languagechanger' onchange=\"javascript:window.location=this.value\">\n";
$sAddToURL = "";
$sTargetURL = "{$relativeurl}/index.php";
if ($previewgrp) {
$sAddToURL = "&action=previewgroup&gid={$_REQUEST['gid']}";
$sTargetURL = "";
}
foreach ($slangs as $otherlang) {
$htmlcode .= "\t<option value=\"{$sTargetURL}?sid=" . $surveyid . "&lang=" . $otherlang . "{$tokenparam}{$sAddToURL}\" ";
if ($otherlang == $lang) {
$htmlcode .= " selected=\"selected\" ";
}
$htmlcode .= ">" . getLanguageNameFromCode($otherlang, false) . "</option>\n";
}
$htmlcode .= "</select>\n";
// . "</form>";
return $htmlcode;
} elseif (!isset($surveyid)) {
global $defaultlang, $baselang;
$htmlcode = "<select name=\"select\" class='languagechanger' onchange=\"javascript:window.location=this.value\">\n";
$htmlcode .= "<option value=\"{$relativeurl}/index.php?lang=" . $defaultlang . "{$tokenparam}\">" . getLanguageNameFromCode($defaultlang, false) . "</option>\n";
foreach (getlanguagedata() as $key => $val) {
$htmlcode .= "\t<option value=\"{$relativeurl}/index.php?lang=" . $key . "{$tokenparam}\" ";
$htmlcode .= ">" . getLanguageNameFromCode($key, false) . "</option>\n";
}
$htmlcode .= "</select>\n";
return $htmlcode;
}
}
示例7: generate_statistics
/**
* Generates statistics
*
* @param int $surveyid The survey id
* @param mixed $allfields
* @param mixed $q2show
* @param mixed $usegraph
* @param string $outputType Optional - Can be xls, html or pdf - Defaults to pdf
* @param string $pdfOutput Sets the target for the PDF output: DD=File download , F=Save file to local disk
* @param string $statlangcode Lamguage for statistics
* @param mixed $browse Show browse buttons
* @return buffer
*/
function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, $outputType='pdf', $pdfOutput='I',$statlangcode=null, $browse = true)
{
//$allfields ="";
global $connect, $dbprefix, $clang,
$rooturl, $rootdir, $homedir, $homeurl, $tempdir, $tempurl, $scriptname, $imagedir,
$chartfontfile, $chartfontsize, $admintheme, $pdfdefaultfont, $pdffontsize;
$fieldmap=createFieldMap($surveyid, "full");
if (is_null($statlangcode))
{
$statlang=$clang;
}
else
{
$statlang = new limesurvey_lang($statlangcode);
}
/*
* this variable is used in the function shortencode() which cuts off a question/answer title
* after $maxchars and shows the rest as tooltip (in html mode)
*/
$maxchars = 13;
//we collect all the html-output within this variable
$statisticsoutput ='';
/**
* $outputType: html || pdf ||
*/
/**
* get/set Survey Details
*/
//no survey ID? -> come and get one
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
//Get an array of codes of all available languages in this survey
$surveylanguagecodes = GetAdditionalLanguagesFromSurveyID($surveyid);
$surveylanguagecodes[] = GetBaseLanguageFromSurveyID($surveyid);
// Set language for questions and answers to base language of this survey
$language=$statlangcode;
if ($usegraph==1)
{
//for creating graphs we need some more scripts which are included here
require_once(dirname(__FILE__).'/../classes/pchart/pchart/pChart.class');
require_once(dirname(__FILE__).'/../classes/pchart/pchart/pData.class');
require_once(dirname(__FILE__).'/../classes/pchart/pchart/pCache.class');
$MyCache = new pCache($tempdir.'/');
//pick the best font file if font setting is 'auto'
if ($chartfontfile=='auto')
{
$chartfontfile='vera.ttf';
if ( $language=='ar')
{
$chartfontfile='KacstOffice.ttf';
}
elseif ($language=='fa' )
{
$chartfontfile='KacstFarsi.ttf';
}
}
}
if($q2show=='all' )
{
$summarySql=" SELECT gid, parent_qid, qid, type "
." FROM {$dbprefix}questions WHERE parent_qid=0"
." AND sid=$surveyid ";
$summaryRs = db_execute_assoc($summarySql);
foreach($summaryRs as $field)
{
$myField = $surveyid."X".$field['gid']."X".$field['qid'];
// Multiple choice get special treatment
if ($field['type'] == "M") {$myField = "M$myField";}
if ($field['type'] == "P") {$myField = "P$myField";}
//numerical input will get special treatment (arihtmetic mean, standard derivation, ...)
if ($field['type'] == "N") {$myField = "N$myField";}
if ($field['type'] == "|") {$myField = "|$myField";}
if ($field['type'] == "Q") {$myField = "Q$myField";}
//.........这里部分代码省略.........
示例8: FixLanguageConsistency
/**
* FixLanguageConsistency() fixes missing groups,questions,answers & assessments for languages on a survey
* @param string $sid - the currently selected survey
* @param string $availlangs - space seperated list of additional languages in survey - if empty all additional languages of a survey are checked against the base language
* @return bool - always returns true
*/
function FixLanguageConsistency($sid, $availlangs = '')
{
global $connect, $databasetype;
if (trim($availlangs) != '') {
$availlangs = sanitize_languagecodeS($availlangs);
$langs = explode(" ", $availlangs);
if ($langs[count($langs) - 1] == "") {
array_pop($langs);
}
} else {
$langs = GetAdditionalLanguagesFromSurveyID($sid);
}
$baselang = GetBaseLanguageFromSurveyID($sid);
$sid = sanitize_int($sid);
$query = "SELECT * FROM " . db_table_name('groups') . " WHERE sid='{$sid}' AND language='{$baselang}' ORDER BY group_order";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
//Checked
if ($result->RecordCount() > 0) {
while ($group = $result->FetchRow()) {
foreach ($langs as $lang) {
$query = "SELECT gid FROM " . db_table_name('groups') . " WHERE sid='{$sid}' AND gid='{$group['gid']}' AND language='{$lang}'";
$gresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
//Checked
if ($gresult->RecordCount() < 1) {
db_switchIDInsert('groups', true);
$query = "INSERT INTO " . db_table_name('groups') . " (gid,sid,group_name,group_order,description,language) VALUES('{$group['gid']}','{$group['sid']}'," . db_quoteall($group['group_name']) . ",'{$group['group_order']}'," . db_quoteall($group['description']) . ",'{$lang}')";
$connect->Execute($query) or safe_die($connect->ErrorMsg());
//Checked
db_switchIDInsert('groups', false);
}
}
reset($langs);
}
}
$quests = array();
$query = "SELECT * FROM " . db_table_name('questions') . " WHERE sid='{$sid}' AND language='{$baselang}' ORDER BY question_order";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
//Checked
if ($result->RecordCount() > 0) {
while ($question = $result->FetchRow()) {
array_push($quests, $question['qid']);
foreach ($langs as $lang) {
$query = "SELECT qid FROM " . db_table_name('questions') . " WHERE sid='{$sid}' AND qid='{$question['qid']}' AND language='{$lang}'";
$gresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
//Checked
if ($gresult->RecordCount() < 1) {
db_switchIDInsert('questions', true);
$query = "INSERT INTO " . db_table_name('questions') . " (qid,sid,gid,type,title,question,preg,help,other,mandatory,question_order,language, scale_id,parent_qid) VALUES('{$question['qid']}','{$question['sid']}','{$question['gid']}','{$question['type']}'," . db_quoteall($question['title']) . "," . db_quoteall($question['question']) . "," . db_quoteall($question['preg']) . "," . db_quoteall($question['help']) . ",'{$question['other']}','{$question['mandatory']}','{$question['question_order']}','{$lang}',{$question['scale_id']},{$question['parent_qid']})";
$connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
//Checked
db_switchIDInsert('questions', false);
}
}
reset($langs);
}
$sqlans = "";
foreach ($quests as $quest) {
$sqlans .= " OR qid = '" . $quest . "' ";
}
$query = "SELECT * FROM " . db_table_name('answers') . " WHERE language='{$baselang}' and (" . trim($sqlans, ' OR') . ") ORDER BY qid, code";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
//Checked
if ($result->RecordCount() > 0) {
while ($answer = $result->FetchRow()) {
foreach ($langs as $lang) {
$query = "SELECT qid FROM " . db_table_name('answers') . " WHERE code='{$answer['code']}' AND qid='{$answer['qid']}' AND language='{$lang}'";
$gresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
//Checked
if ($gresult->RecordCount() < 1) {
db_switchIDInsert('answers', true);
$query = "INSERT INTO " . db_table_name('answers') . " (qid,code,answer,scale_id,sortorder,language,assessment_value) VALUES('{$answer['qid']}'," . db_quoteall($answer['code']) . "," . db_quoteall($answer['answer']) . ",{$answer['scale_id']},'{$answer['sortorder']}','{$lang}',{$answer['assessment_value']})";
$connect->Execute($query) or safe_die($connect->ErrorMsg());
//Checked
db_switchIDInsert('answers', false);
}
}
reset($langs);
}
}
}
$query = "SELECT * FROM " . db_table_name('assessments') . " WHERE sid='{$sid}' AND language='{$baselang}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
//Checked
if ($result->RecordCount() > 0) {
while ($assessment = $result->FetchRow()) {
foreach ($langs as $lang) {
$query = "SELECT id FROM " . db_table_name('assessments') . " WHERE sid='{$sid}' AND id='{$assessment['id']}' AND language='{$lang}'";
$gresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
//Checked
if ($gresult->RecordCount() < 1) {
db_switchIDInsert('assessments', true);
$query = "INSERT INTO " . db_table_name('assessments') . " (id,sid,scope,gid,name,minimum,maximum,message,language) " . "VALUES('{$assessment['id']}','{$assessment['sid']}'," . db_quoteall($assessment['scope']) . "," . db_quoteall($assessment['gid']) . "," . db_quoteall($assessment['name']) . "," . db_quoteall($assessment['minimum']) . "," . db_quoteall($assessment['maximum']) . "," . db_quoteall($assessment['message']) . ",'{$lang}')";
$connect->Execute($query) or safe_die($connect->ErrorMsg());
//Checked
//.........这里部分代码省略.........
示例9: XMLImportGroup
/**
* This function imports a LimeSurvey .lsg question group XML file
*
* @param mixed $sFullFilepath The full filepath of the uploaded file
* @param mixed $newsid The new survey id - the group will always be added after the last group in the survey
*/
function XMLImportGroup($sFullFilepath, $newsid)
{
global $connect, $dbprefix, $clang;
$aLanguagesSupported = array();
// this array will keep all the languages supported for the survey
$sBaseLanguage = GetBaseLanguageFromSurveyID($newsid);
$aLanguagesSupported[] = $sBaseLanguage;
// adds the base language to the list of supported languages
$aLanguagesSupported = array_merge($aLanguagesSupported, GetAdditionalLanguagesFromSurveyID($newsid));
$xml = @simplexml_load_file($sFullFilepath);
if ($xml == false || $xml->LimeSurveyDocType != 'Group') {
safe_die('This is not a valid LimeSurvey group structure XML file.');
}
$dbversion = (double) $xml->DBVersion;
$aQIDReplacements = array();
$results['defaultvalues'] = 0;
$results['answers'] = 0;
$results['question_attributes'] = 0;
$results['subquestions'] = 0;
$results['conditions'] = 0;
$results['groups'] = 0;
$importlanguages = array();
foreach ($xml->languages->language as $language) {
$importlanguages[] = (string) $language;
}
if (!in_array($sBaseLanguage, $importlanguages)) {
$results['fatalerror'] = $clang->gT("The languages of the imported group file must at least include the base language of this survey.");
return $results;
}
// First get an overview of fieldnames - it's not useful for the moment but might be with newer versions
/*
$fieldnames=array();
foreach ($xml->questions->fields->fieldname as $fieldname )
{
$fieldnames[]=(string)$fieldname;
};*/
// Import group table ===================================================================================
$tablename = $dbprefix . 'groups';
$newgrouporder = $connect->GetOne("SELECT MAX(group_order) AS maxqo FROM " . db_table_name('groups') . " WHERE sid={$newsid}");
if (is_null($newgrouporder)) {
$newgrouporder = 0;
} else {
$newgrouporder++;
}
foreach ($xml->groups->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$oldsid = $insertdata['sid'];
$insertdata['sid'] = $newsid;
$insertdata['group_order'] = $newgrouporder;
$oldgid = $insertdata['gid'];
unset($insertdata['gid']);
// save the old qid
// now translate any links
$insertdata['group_name'] = translink('survey', $oldsid, $newsid, $insertdata['group_name']);
$insertdata['description'] = translink('survey', $oldsid, $newsid, $insertdata['description']);
// Insert the new question
if (isset($aGIDReplacements[$oldgid])) {
$insertdata['gid'] = $aGIDReplacements[$oldgid];
db_switchIDInsert('groups', true);
}
$query = $connect->GetInsertSQL($tablename, $insertdata);
$result = $connect->Execute($query) or safe_die($clang->gT("Error") . ": Failed to insert data<br />{$query}<br />\n" . $connect->ErrorMsg());
$results['groups']++;
if (!isset($aGIDReplacements[$oldgid])) {
$newgid = $connect->Insert_ID($tablename, "gid");
// save this for later
$aGIDReplacements[$oldgid] = $newgid;
// add old and new qid to the mapping array
} else {
db_switchIDInsert('groups', false);
}
}
// Import questions table ===================================================================================
// We have to run the question table data two times - first to find all main questions
// then for subquestions (because we need to determine the new qids for the main questions first)
$tablename = $dbprefix . 'questions';
$results['questions'] = 0;
if (isset($xml->questions)) {
foreach ($xml->questions->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$oldsid = $insertdata['sid'];
$insertdata['sid'] = $newsid;
if (!isset($aGIDReplacements[$insertdata['gid']]) || trim($insertdata['title']) == '') {
continue;
}
// Skip questions with invalid group id
$insertdata['gid'] = $aGIDReplacements[$insertdata['gid']];
$oldqid = $insertdata['qid'];
//.........这里部分代码省略.........
示例10: do_language
function do_language($ia)
{
global $dbprefix, $surveyid, $clang;
if ($ia[8] == 'Y')
{
$checkconditionFunction = "checkconditions";
}
else
{
$checkconditionFunction = "noop_checkconditions";
}
$answerlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$answerlangs [] = GetBaseLanguageFromSurveyID($surveyid);
$answer = "\n\t<p class=\"question\">\n<select name=\"$ia[1]\" id=\"answer$ia[1]\" onchange=\"document.getElementById('lang').value=this.value; $checkconditionFunction(this.value, this.name, this.type);\">\n";
if (!$_SESSION[$ia[1]]) {$answer .= "\t<option value=\"\" selected=\"selected\">".$clang->gT('Please choose...')."</option>\n";}
foreach ($answerlangs as $ansrow)
{
$answer .= "\t<option value=\"{$ansrow}\"";
if ($_SESSION[$ia[1]] == $ansrow)
{
$answer .= SELECTED;
}
$answer .= '>'.getLanguageNameFromCode($ansrow, true)."</option>\n";
}
$answer .= "</select>\n";
$answer .= "<input type=\"hidden\" name=\"java$ia[1]\" id=\"java$ia[1]\" value=\"{$_SESSION[$ia[1]]}\" />\n";
$inputnames[]=$ia[1];
$answer .= "\n<input type=\"hidden\" name=\"lang\" id=\"lang\" value=\"\" />\n\t</p>\n";
return array($answer, $inputnames);
}
示例11: XMLImportQuestion
/**
* This function imports a LimeSurvey .lsq question XML file
*
* @param mixed $sFullFilepath The full filepath of the uploaded file
* @param mixed $newsid The new survey id
* @param mixed $newgid The new question group id -the question will always be added after the last question in the group
*/
function XMLImportQuestion($sFullFilepath, $newsid, $newgid)
{
global $connect, $dbprefix, $clang;
$aLanguagesSupported = array();
// this array will keep all the languages supported for the survey
$sBaseLanguage = GetBaseLanguageFromSurveyID($newsid);
$aLanguagesSupported[] = $sBaseLanguage;
// adds the base language to the list of supported languages
$aLanguagesSupported = array_merge($aLanguagesSupported, GetAdditionalLanguagesFromSurveyID($newsid));
$xml = simplexml_load_file($sFullFilepath);
if ($xml->LimeSurveyDocType != 'Question') {
safe_die('This is not a valid LimeSurvey question structure XML file.');
}
$dbversion = (double) $xml->DBVersion;
$aQIDReplacements = array();
$aSQIDReplacements = array(0 => 0);
$results['defaultvalues'] = 0;
$results['answers'] = 0;
$results['question_attributes'] = 0;
$results['subquestions'] = 0;
$importlanguages = array();
foreach ($xml->languages->language as $language) {
$importlanguages[] = (string) $language;
}
if (!in_array($sBaseLanguage, $importlanguages)) {
$results['fatalerror'] = $clang->gT("The languages of the imported question file must at least include the base language of this survey.");
return $results;
}
// First get an overview of fieldnames - it's not useful for the moment but might be with newer versions
/*
$fieldnames=array();
foreach ($xml->questions->fields->fieldname as $fieldname )
{
$fieldnames[]=(string)$fieldname;
};*/
// Import questions table ===================================================================================
// We have to run the question table data two times - first to find all main questions
// then for subquestions (because we need to determine the new qids for the main questions first)
$tablename = $dbprefix . 'questions';
$newquestionorder = $connect->GetOne("SELECT MAX(question_order) AS maxqo FROM " . db_table_name('questions') . " WHERE sid={$newsid} AND gid={$newgid}") + 1;
if (is_null($newquestionorder)) {
$newquestionorder = 0;
} else {
$newquestionorder++;
}
foreach ($xml->questions->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$oldsid = $insertdata['sid'];
$insertdata['sid'] = $newsid;
$insertdata['gid'] = $newgid;
$insertdata['question_order'] = $newquestionorder;
$oldqid = $insertdata['qid'];
unset($insertdata['qid']);
// save the old qid
// now translate any links
$insertdata['title'] = translink('survey', $oldsid, $newsid, $insertdata['title']);
$insertdata['question'] = translink('survey', $oldsid, $newsid, $insertdata['question']);
$insertdata['help'] = translink('survey', $oldsid, $newsid, $insertdata['help']);
// Insert the new question
if (isset($aQIDReplacements[$oldqid])) {
$insertdata['qid'] = $aQIDReplacements[$oldqid];
db_switchIDInsert('questions', true);
}
$query = $connect->GetInsertSQL($tablename, $insertdata);
$result = $connect->Execute($query) or safe_die($clang->gT("Error") . ": Failed to insert data<br />{$query}<br />\n" . $connect->ErrorMsg());
if (!isset($aQIDReplacements[$oldqid])) {
$newqid = $connect->Insert_ID($tablename, "qid");
// save this for later
$aQIDReplacements[$oldqid] = $newqid;
// add old and new qid to the mapping array
} else {
db_switchIDInsert('questions', false);
}
}
// Import subquestions --------------------------------------------------------------
if (isset($xml->subquestions)) {
foreach ($xml->subquestions->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$insertdata['sid'] = $newsid;
$insertdata['gid'] = $newgid;
$oldsqid = (int) $insertdata['qid'];
unset($insertdata['qid']);
// save the old qid
$insertdata['parent_qid'] = $aQIDReplacements[(int) $insertdata['parent_qid']];
// remap the parent_qid
// now translate any links
$insertdata['title'] = translink('survey', $oldsid, $newsid, $insertdata['title']);
//.........这里部分代码省略.........
示例12: getSurveyInfo
}
}
} else {
$browseoutput = "\t<div class='messagebox ui-corner-all'><div class='header ui-widget-header'>" . $clang->gT("Browse Responses") . "</div><div class='warningheader'>" . $clang->gT("Error") . "\t</div>\n" . $clang->gT("There is no matching survey.") . "<br />\n" . "<input type='submit' value='" . $clang->gT("Main Admin Screen") . "' onclick=\"window.open('{$scriptname}', '_top')\" /><br />\n" . "</div>";
return;
}
//OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
$surveyinfo = getSurveyInfo($surveyid);
require_once dirname(__FILE__) . '/sessioncontrol.php';
// Set language for questions and labels to base language of this survey
if (isset($browselang) && $browselang != '') {
$_SESSION['browselang'] = $browselang;
$language = $_SESSION['browselang'];
} elseif (isset($_SESSION['browselang'])) {
$language = $_SESSION['browselang'];
$languagelist = GetAdditionalLanguagesFromSurveyID($surveyid);
$languagelist[] = GetBaseLanguageFromSurveyID($surveyid);
if (!in_array($language, $languagelist)) {
$language = GetBaseLanguageFromSurveyID($surveyid);
}
} else {
$language = GetBaseLanguageFromSurveyID($surveyid);
}
$surveyoptions = browsemenubar($clang->gT("Browse Responses"));
$browseoutput = "";
$js_admin_includes[] = 'scripts/browse.js';
$qulanguage = GetBaseLanguageFromSurveyID($surveyid);
// Looking at a SINGLE entry
if ($subaction == "id") {
$dateformatdetails = getDateFormatData($_SESSION['dateformat']);
//SHOW HEADER
示例13: Array
$jsX = 0;
$jsRemLang = "<script type=\"text/javascript\">\n var mylangs = new Array();\n standardtemplaterooturl='{$standardtemplaterooturl}';\n templaterooturl='{$usertemplaterooturl}'; \n";
foreach (GetAdditionalLanguagesFromSurveyID($surveyid) as $langname) {
if ($langname && $langname != $esrow['language']) {
// base languag must not be shown here
$jsRemLang .= "mylangs[{$jsX}] = \"{$langname}\"\n";
$editsurvey .= "<option id='" . $langname . "' value='" . $langname . "'";
$editsurvey .= ">" . getLanguageNameFromCode($langname, false) . "</option>\n";
$jsX++;
}
}
$jsRemLang .= "</script>\n";
$editsurvey .= $jsRemLang;
// Add/Remove Buttons
$editsurvey .= "</select></td>" . "<td align='left'><input type=\"button\" value=\"<< " . $clang->gT("Add") . "\" onclick=\"DoAdd()\" id=\"AddBtn\" /><br /> <input type=\"button\" value=\"" . $clang->gT("Remove") . " >>\" onclick=\"DoRemove(0,'')\" id=\"RemoveBtn\" /></td>\n" . "<td align='left'><select size='5' style='min-width:220px;' id='available_languages' name='available_languages'>";
$tempLang = GetAdditionalLanguagesFromSurveyID($surveyid);
foreach (getLanguageData() as $langkey2 => $langname) {
if ($langkey2 != $esrow['language'] && in_array($langkey2, $tempLang) == false) {
// base languag must not be shown here
$editsurvey .= "<option id='" . $langkey2 . "' value='" . $langkey2 . "'";
$editsurvey .= ">" . $langname['description'] . "</option>\n";
}
}
$editsurvey .= "</select></td>" . " </tr></table></li>\n";
// Administrator...
$editsurvey .= "" . "<li><label for='admin'>" . $clang->gT("Administrator:") . "</label>\n" . "<input type='text' size='50' id='admin' name='admin' value=\"{$esrow['admin']}\" /></li>\n" . "<li><label for='adminemail'>" . $clang->gT("Admin Email:") . "</label>\n" . "<input type='text' size='50' id='adminemail' name='adminemail' value=\"{$esrow['adminemail']}\" /></li>\n" . "<li><label for='bounce_email'>" . $clang->gT("Bounce Email:") . "</label>\n" . "<input type='text' size='50' id='bounce_email' name='bounce_email' value=\"{$esrow['bounce_email']}\" /></li>\n" . "<li><label for='faxto'>" . $clang->gT("Fax to:") . "</label>\n" . "<input type='text' size='50' id='faxto' name='faxto' value=\"{$esrow['faxto']}\" /></li></ul>\n";
// End General TAB
$editsurvey .= "</div>\n";
}
// Presentation and navigation TAB
$editsurvey .= "<div id='presentation'><ul>\n";
示例14: returnglobal
}
if (!isset($action)) {
$action = returnglobal('action');
}
include_once 'translate_functions.php';
$js_admin_includes[] = $homeurl . '/scripts/translation.js';
// TODO need to do some validation here on surveyid
$surveyinfo = getSurveyInfo($surveyid);
$tolang = "";
if (isset($_GET['tolang'])) {
$tolang = $_GET['tolang'];
} elseif (isset($_POST['tolang'])) {
$tolang = $_POST['tolang'];
}
if ($tolang == "" && count(GetAdditionalLanguagesFromSurveyID($surveyid)) == 1) {
$tmp_langs = GetAdditionalLanguagesFromSurveyID($surveyid);
$tolang = $tmp_langs[0];
}
$actionvalue = "";
if (isset($_POST['actionvalue'])) {
$actionvalue = $_POST['actionvalue'];
}
// if(isset($_GET['actionvalue'])) {$actionvalue = $_GET['actionvalue'];}
$survey_title = $surveyinfo['name'];
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$supportedLanguages = getLanguageData(false);
$baselangdesc = $supportedLanguages[$baselang]['description'];
if ($tolang != "") {
$tolangdesc = $supportedLanguages[$tolang]['description'];
}
$translateoutput = "";
示例15: CSVImportSurvey
//.........这里部分代码省略.........
// Now import the survey language settings
$fieldorders=convertCSVRowToArray($surveylsarray[0],',','"');
unset($surveylsarray[0]);
foreach ($surveylsarray as $slsrow) {
$fieldcontents=convertCSVRowToArray($slsrow,',','"');
$surveylsrowdata=array_combine($fieldorders,$fieldcontents);
// convert back the '\'.'n' char from the CSV file to true return char "\n"
$surveylsrowdata=array_map('convertCsvreturn2return', $surveylsrowdata);
// Convert the \n return char from welcometext to <br />
// translate internal links
$surveylsrowdata['surveyls_title']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_title']);
$surveylsrowdata['surveyls_description']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_description']);
$surveylsrowdata['surveyls_welcometext']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_welcometext']);
$surveylsrowdata['surveyls_urldescription']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_urldescription']);
$surveylsrowdata['surveyls_email_invite']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_email_invite']);
$surveylsrowdata['surveyls_email_remind']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_email_remind']);
$surveylsrowdata['surveyls_email_register']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_email_register']);
$surveylsrowdata['surveyls_email_confirm']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_email_confirm']);
unset($surveylsrowdata['lastpage']);
$surveylsrowdata['surveyls_survey_id']=$newsid;
$newvalues=array_values($surveylsrowdata);
$newvalues=array_map(array(&$connect, "qstr"),$newvalues); // quote everything accordingly
$lsainsert = "INSERT INTO {$dbprefix}surveys_languagesettings (".implode(',',array_keys($surveylsrowdata)).") VALUES (".implode(',',$newvalues).")"; //handle db prefix
$lsiresult=$connect->Execute($lsainsert) or safe_die("<br />".$clang->gT("Import of this survey file failed")."<br />\n[$lsainsert]<br />\n" . $connect->ErrorMsg() );
}
// The survey languagesettings are imported now
$aLanguagesSupported = array(); // this array will keep all the languages supported for the survey
$sBaseLanguage = GetBaseLanguageFromSurveyID($newsid);
$aLanguagesSupported[]=$sBaseLanguage; // adds the base language to the list of supported languages
$aLanguagesSupported=array_merge($aLanguagesSupported,GetAdditionalLanguagesFromSurveyID($newsid));
// DO SURVEY_RIGHTS
GiveAllSurveyPermissions($_SESSION['loginID'],$newsid);
$importresults['deniedcountls'] =0;
$qtypes = getqtypelist("" ,"array");
$results['labels']=0;
$results['labelsets']=0;
$results['answers']=0;
$results['subquestions']=0;
//Do label sets
if (isset($labelsetsarray) && $labelsetsarray)
{
$csarray=buildLabelSetCheckSumArray(); // build checksums over all existing labelsets
$count=0;
foreach ($labelsetsarray as $lsa) {
$fieldorders =convertCSVRowToArray($labelsetsarray[0],',','"');
$fieldcontents=convertCSVRowToArray($lsa,',','"');
if ($count==0) {$count++; continue;}
$labelsetrowdata=array_combine($fieldorders,$fieldcontents);
// Save old labelid
$oldlid=$labelsetrowdata['lid'];
unset($labelsetrowdata['lid']);
$newvalues=array_values($labelsetrowdata);
$newvalues=array_map(array(&$connect, "qstr"),$newvalues); // quote everything accordingly
$lsainsert = "INSERT INTO {$dbprefix}labelsets (".implode(',',array_keys($labelsetrowdata)).") VALUES (".implode(',',$newvalues).")"; //handle db prefix