当前位置: 首页>>代码示例>>PHP>>正文


PHP buildLabelSetCheckSumArray函数代码示例

本文整理汇总了PHP中buildLabelSetCheckSumArray函数的典型用法代码示例。如果您正苦于以下问题:PHP buildLabelSetCheckSumArray函数的具体用法?PHP buildLabelSetCheckSumArray怎么用?PHP buildLabelSetCheckSumArray使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了buildLabelSetCheckSumArray函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: XMLImportLabelsets

function XMLImportLabelsets($sFullFilepath, $options)
{
    global $connect, $dbprefix, $clang;
    $xml = simplexml_load_file($sFullFilepath);
    if ($xml->LimeSurveyDocType != 'Label set') {
        safe_die('This is not a valid LimeSurvey label set structure XML file.');
    }
    $dbversion = (double) $xml->DBVersion;
    $csarray = buildLabelSetCheckSumArray();
    $aLSIDReplacements = array();
    $results['labelsets'] = 0;
    $results['labels'] = 0;
    $results['warnings'] = array();
    // Import labels table ===================================================================================
    $tablename = $dbprefix . 'labelsets';
    foreach ($xml->labelsets->rows->row as $row) {
        $insertdata = array();
        foreach ($row as $key => $value) {
            $insertdata[(string) $key] = (string) $value;
        }
        $oldlsid = $insertdata['lid'];
        unset($insertdata['lid']);
        // save the old qid
        // Insert the new question
        $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['labelsets']++;
        $newlsid = $connect->Insert_ID($tablename, "lid");
        // save this for later
        $aLSIDReplacements[$oldlsid] = $newlsid;
        // add old and new lsid to the mapping array
    }
    // Import labels table ===================================================================================
    $tablename = $dbprefix . 'labels';
    if (isset($xml->labels->rows->row)) {
        foreach ($xml->labels->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['lid'] = $aLSIDReplacements[$insertdata['lid']];
            $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['labels']++;
        }
    }
    //CHECK FOR DUPLICATE LABELSETS
    if (isset($_POST['checkforduplicates'])) {
        foreach (array_values($aLSIDReplacements) as $newlid) {
            $thisset = "";
            $query2 = "SELECT code, title, sortorder, language, assessment_value\n                       FROM " . db_table_name('labels') . "\n                       WHERE lid=" . $newlid . "\n                       ORDER BY language, sortorder, code";
            $result2 = db_execute_num($query2) or safe_die("Died querying labelset {$lid}<br />{$query2}<br />" . $connect->ErrorMsg());
            while ($row2 = $result2->FetchRow()) {
                $thisset .= implode('.', $row2);
            }
            // while
            $newcs = dechex(crc32($thisset) * 1);
            unset($lsmatch);
            if (isset($csarray) && $options['checkforduplicates'] == 'on') {
                foreach ($csarray as $key => $val) {
                    if ($val == $newcs) {
                        $lsmatch = $key;
                    }
                }
            }
            if (isset($lsmatch)) {
                //There is a matching labelset. So, we will delete this one and refer
                //to the matched one.
                $query = "DELETE FROM {$dbprefix}labels WHERE lid={$newlid}";
                $result = $connect->Execute($query) or safe_die("Couldn't delete labels<br />{$query}<br />" . $connect->ErrorMsg());
                $results['labels'] = $results['labels'] - $connect->Affected_Rows();
                $query = "DELETE FROM {$dbprefix}labelsets WHERE lid={$newlid}";
                $result = $connect->Execute($query) or safe_die("Couldn't delete labelset<br />{$query}<br />" . $connect->ErrorMsg());
                $results['labelsets']--;
                $newlid = $lsmatch;
                $results['warnings'][] = $clang->gT("Label set was not imported because the same label set already exists.") . " " . sprintf($clang->gT("Existing LID: %s"), $newlid);
            }
        }
        //END CHECK FOR DUPLICATES
    }
    return $results;
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:82,代码来源:importlabel.php

示例2: CSVImportSurvey


//.........这里部分代码省略.........
        // Convert the \n return char from welcometext to <br />
        // translate internal links
        if ($bTranslateLinks) {
            $surveylsrowdata['surveyls_title'] = translateLinks('survey', $iOldSID, $iNewSID, $surveylsrowdata['surveyls_title']);
            $surveylsrowdata['surveyls_description'] = translateLinks('survey', $iOldSID, $iNewSID, $surveylsrowdata['surveyls_description']);
            $surveylsrowdata['surveyls_welcometext'] = translateLinks('survey', $iOldSID, $iNewSID, $surveylsrowdata['surveyls_welcometext']);
            $surveylsrowdata['surveyls_urldescription'] = translateLinks('survey', $iOldSID, $iNewSID, $surveylsrowdata['surveyls_urldescription']);
            $surveylsrowdata['surveyls_email_invite'] = translateLinks('survey', $iOldSID, $iNewSID, $surveylsrowdata['surveyls_email_invite']);
            $surveylsrowdata['surveyls_email_remind'] = translateLinks('survey', $iOldSID, $iNewSID, $surveylsrowdata['surveyls_email_remind']);
            $surveylsrowdata['surveyls_email_register'] = translateLinks('survey', $iOldSID, $iNewSID, $surveylsrowdata['surveyls_email_register']);
            $surveylsrowdata['surveyls_email_confirm'] = translateLinks('survey', $iOldSID, $iNewSID, $surveylsrowdata['surveyls_email_confirm']);
        }
        unset($surveylsrowdata['lastpage']);
        $surveylsrowdata['surveyls_survey_id'] = $iNewSID;
        $lsiresult = Surveys_languagesettings::model()->insertNewSurvey($surveylsrowdata) or safeDie("<br />" . $clang->gT("Import of this survey file failed") . "<br />");
    }
    // The survey languagesettings are imported now
    $aLanguagesSupported = array();
    // this array will keep all the languages supported for the survey
    $sBaseLanguage = Survey::model()->findByPk($iNewSID)->language;
    $aLanguagesSupported[] = $sBaseLanguage;
    // adds the base language to the list of supported languages
    $aLanguagesSupported = array_merge($aLanguagesSupported, Survey::model()->findByPk($iNewSID)->additionalLanguages);
    // DO SURVEY_RIGHTS
    Survey_permissions::model()->giveAllSurveyPermissions(Yii::app()->session['loginID'], $iNewSID);
    $importresults['deniedcountls'] = 0;
    $qtypes = getQuestionTypeList("", "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']);
            $lblsets = Labelsets::model();
            $lsiresult = $lblsets->insertRecords($labelsetrowdata);
            $results['labelsets']++;
            // Get the new insert id for the labels inside this labelset
            $newlid = Yii::app()->db->createCommand('Select LAST_INSERT_ID()')->query()->read();
            $newlid = $newlid['LAST_INSERT_ID()'];
            if ($labelsarray) {
                $count = 0;
                foreach ($labelsarray as $la) {
                    $lfieldorders = convertCSVRowToArray($labelsarray[0], ',', '"');
                    $lfieldcontents = convertCSVRowToArray($la, ',', '"');
                    if ($count == 0) {
                        $count++;
                        continue;
                    }
                    // Combine into one array with keys and values since its easier to handle
                    $labelrowdata = array_combine($lfieldorders, $lfieldcontents);
                    $labellid = $labelrowdata['lid'];
                    if ($importversion <= 132) {
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:67,代码来源:import_helper.php

示例3: importQuestion


//.........这里部分代码省略.........
     //	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);
             return "You can't import label sets which don't support the current survey's base language";
         }
     }
     // I assume that if a labelset supports the survey's baselang,
     // then it's labels do support it as well
     // GET SURVEY AND GROUP DETAILS
     //$surveyid=$postsid;
     //$gid=$postgid;
     $newsid = $surveyid;
     $newgid = $gid;
     $this->debugLsrc("wir sind in " . __FILE__ . " - " . __FUNCTION__ . " Line " . __LINE__ . ", OK ");
     //DO ANY LABELSETS FIRST, SO WE CAN KNOW WHAT THEIR NEW LID IS FOR THE QUESTIONS
     if (isset($labelsetsarray) && $labelsetsarray) {
         $csarray = buildLabelSetCheckSumArray();
         // build checksums over all existing labelsets
         $count = 0;
         $this->debugLsrc("wir sind in " . __FILE__ . " - " . __FUNCTION__ . " Line " . __LINE__ . ", OK ");
         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'];
             // set the new language
             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
             $lsiresult = $connect->Execute($lsainsert);
             // Get the new insert id for the labels inside this labelset
             $newlid = $connect->Insert_ID("{$dbprefix}labelsets", "lid");
             if ($labelsarray) {
                 $count = 0;
                 foreach ($labelsarray as $la) {
                     $lfieldorders = convertCSVRowToArray($labelsarray[0], ',', '"');
                     $lfieldcontents = convertCSVRowToArray($la, ',', '"');
                     if ($count == 0) {
                         $count++;
                         continue;
                     }
开发者ID:rkaldung,项目名称:LimeSurvey,代码行数:67,代码来源:lsrc.helper.php

示例4: XMLImportLabelsets

/**
* XMLImportLabelsets()
* Function resp[onsible to import a labelset from XML format.
* @param mixed $sFullFilePath
* @param mixed $options
* @return
*/
function XMLImportLabelsets($sFullFilePath, $options)
{
    $sXMLdata = file_get_contents($sFullFilePath);
    $xml = simplexml_load_string($sXMLdata, 'SimpleXMLElement', LIBXML_NONET);
    if ($xml->LimeSurveyDocType != 'Label set') {
        safeDie('This is not a valid LimeSurvey label set structure XML file.');
    }
    $iDBVersion = (int) $xml->DBVersion;
    $csarray = buildLabelSetCheckSumArray();
    $aLSIDReplacements = array();
    $results['labelsets'] = 0;
    $results['labels'] = 0;
    $results['warnings'] = array();
    // Import labels table ===================================================================================
    foreach ($xml->labelsets->rows->row as $row) {
        $insertdata = array();
        foreach ($row as $key => $value) {
            $insertdata[(string) $key] = (string) $value;
        }
        $oldlsid = $insertdata['lid'];
        unset($insertdata['lid']);
        // save the old qid
        if ($insertdata) {
            XSSFilterArray($insertdata);
        }
        // Insert the new question
        $result = Yii::app()->db->createCommand()->insert('{{labelsets}}', $insertdata);
        $results['labelsets']++;
        $newlsid = getLastInsertID('{{labelsets}}');
        $aLSIDReplacements[$oldlsid] = $newlsid;
        // add old and new lsid to the mapping array
    }
    // Import labels table ===================================================================================
    if (isset($xml->labels->rows->row)) {
        foreach ($xml->labels->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['lid'] = $aLSIDReplacements[$insertdata['lid']];
            if ($insertdata) {
                XSSFilterArray($insertdata);
            }
            $result = Yii::app()->db->createCommand()->insert('{{labels}}', $insertdata);
            $results['labels']++;
        }
    }
    //CHECK FOR DUPLICATE LABELSETS
    if (isset($_POST['checkforduplicates'])) {
        foreach (array_values($aLSIDReplacements) as $newlid) {
            $thisset = "";
            $query2 = "SELECT code, title, sortorder, language, assessment_value\n            FROM {{labels}}\n            WHERE lid=" . $newlid . "\n            ORDER BY language, sortorder, code";
            $result2 = Yii::app()->db->createCommand($query2)->query();
            foreach ($result2->readAll() as $row2) {
                $row2 = array_values($row2);
                $thisset .= implode('.', $row2);
            }
            // while
            $newcs = dechex(crc32($thisset) * 1);
            unset($lsmatch);
            if (isset($csarray) && $options['checkforduplicates'] == 'on') {
                foreach ($csarray as $key => $val) {
                    if ($val == $newcs) {
                        $lsmatch = $key;
                    }
                }
            }
            if (isset($lsmatch)) {
                //There is a matching labelset. So, we will delete this one and refer
                //to the matched one.
                $query = "DELETE FROM {{labels}} WHERE lid={$newlid}";
                $result = Yii::app()->db->createCommand($query)->execute();
                $results['labels'] = $results['labels'] - $result;
                $query = "DELETE FROM {{labelsets}} WHERE lid={$newlid}";
                $result = Yii::app()->db->createCommand($query)->query();
                $results['labelsets']--;
                $newlid = $lsmatch;
                $results['warnings'][] = gT("Label set was not imported because the same label set already exists.") . " " . sprintf(gT("Existing LID: %s"), $newlid);
            }
        }
        //END CHECK FOR DUPLICATES
    }
    return $results;
}
开发者ID:wrenchpilot,项目名称:LimeSurvey,代码行数:91,代码来源:import_helper.php

示例5: CSVImportSurvey


//.........这里部分代码省略.........
        $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
            $lsiresult=$connect->Execute($lsainsert);
            $results['labelsets']++;
            // Get the new insert id for the labels inside this labelset
            $newlid=$connect->Insert_ID("{$dbprefix}labelsets",'lid');

            if ($labelsarray) {
                $count=0;
                foreach ($labelsarray as $la) {
                    $lfieldorders  =convertCSVRowToArray($labelsarray[0],',','"');
                    $lfieldcontents=convertCSVRowToArray($la,',','"');
                    if ($count==0) {$count++; continue;}

                    // Combine into one array with keys and values since its easier to handle
                    $labelrowdata=array_combine($lfieldorders,$lfieldcontents);
                    $labellid=$labelrowdata['lid'];
                    if ($importversion<=132)
                    {
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:67,代码来源:import_functions.php

示例6: CSVImportGroup


//.........这里部分代码省略.........
    }
    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, $sBaseLanguage);
        if (!$answerssupportbaselang) {
            $results['fatalerror'] = $clang->gT("You can't import answers which doesn't support at least the survey base language.");
            return $results;
        }
    }
    if (count($labelsetsarray) > 1) {
        $labelsetfieldname = convertCSVRowToArray($labelsetsarray[0], ',', '"');
        $langfieldnum = array_search("languages", $labelsetfieldname);
        $lidfilednum = array_search("lid", $labelsetfieldname);
        $labelsetssupportbaselang = bDoesImportarraySupportsLanguage($labelsetsarray, array($lidfilednum), $langfieldnum, $sBaseLanguage, true);
        if (!$labelsetssupportbaselang) {
            $results['fatalerror'] = $clang->gT("You can't import label sets which don't support the current survey's base language");
            return $results;
        }
    }
    // I assume that if a labelset supports the survey's baselang,
    // then it's labels do support it as well
    //DO ANY LABELSETS FIRST, SO WE CAN KNOW WHAT THEIR NEW LID IS FOR THE QUESTIONS
    $results['labelsets'] = 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
            $lsiresult = $connect->Execute($lsainsert);
            $results['labelsets']++;
            // Get the new insert id for the labels inside this labelset
            $newlid = $connect->Insert_ID("{$dbprefix}labelsets", 'lid');
            if ($labelsarray) {
                $count = 0;
                foreach ($labelsarray as $la) {
                    $lfieldorders = convertCSVRowToArray($labelsarray[0], ',', '"');
                    $lfieldcontents = convertCSVRowToArray($la, ',', '"');
                    if ($count == 0) {
                        $count++;
                        continue;
                    }
                    // Combine into one array with keys and values since its easier to handle
开发者ID:ddrmoscow,项目名称:queXS,代码行数:67,代码来源:importgroup.php

示例7: CSVImportQuestion


//.........这里部分代码省略.........
        $langfieldnum = array_search("language", $questionfieldnames);
        $qidfieldnum = array_search("qid", $questionfieldnames);
        $questionssupportbaselang = bDoesImportarraySupportsLanguage($questionarray, array($qidfieldnum), $langfieldnum, $sBaseLanguage, true);
        if (!$questionssupportbaselang) {
            $results['fatalerror'] = $clang->gT("You can't import a question which doesn't support at least the survey base language.");
            return $results;
        }
    }
    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, $sBaseLanguage);
        if (!$answerssupportbaselang) {
            $results['fatalerror'] = $clang->gT("You can't import answers which doesn't support at least the survey base language.");
            return $results;
        }
    }
    if ($countlabelsets > 0) {
        $labelsetfieldname = convertCSVRowToArray($labelsetsarray[0], ',', '"');
        $langfieldnum = array_search("languages", $labelsetfieldname);
        $lidfilednum = array_search("lid", $labelsetfieldname);
        $labelsetssupportbaselang = bDoesImportarraySupportsLanguage($labelsetsarray, array($lidfilednum), $langfieldnum, $sBaseLanguage, true);
        if (!$labelsetssupportbaselang) {
            $results['fatalerror'] = $clang->gT("You can't import label sets which don't support the current survey's base language");
            return $results;
        }
    }
    // I assume that if a labelset supports the survey's baselang,
    // then it's labels do support it as well
    //DO ANY LABELSETS FIRST, SO WE CAN KNOW WHAT THEIR NEW LID IS FOR THE QUESTIONS
    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;
            }
            $results['labelsets']++;
            $labelsetrowdata = array_combine($fieldorders, $fieldcontents);
            // Save old labelid
            $oldlid = $labelsetrowdata['lid'];
            // set the new language
            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
            $lsiresult = $connect->Execute($lsainsert);
            // Get the new insert id for the labels inside this labelset
            $newlid = $connect->Insert_ID("{$dbprefix}labelsets", 'lid');
            if ($labelsarray) {
                $count = 0;
                foreach ($labelsarray as $la) {
                    $lfieldorders = convertCSVRowToArray($labelsarray[0], ',', '"');
                    $lfieldcontents = convertCSVRowToArray($la, ',', '"');
                    if ($count == 0) {
                        $count++;
                        continue;
                    }
开发者ID:ddrmoscow,项目名称:queXS,代码行数:67,代码来源:importquestion.php


注:本文中的buildLabelSetCheckSumArray函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。