mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
utf8 migration support scripts
This commit is contained in:
parent
bbbb201364
commit
1e4d9ff6dc
36 changed files with 4767 additions and 0 deletions
68
mod/survey/db/migrate2utf8.php
Executable file
68
mod/survey/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,68 @@
|
|||
<?
|
||||
|
||||
function migrate2utf8_survey_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$survey = get_record('survey','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($survey->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($survey->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($survey->name, $fromenc);
|
||||
|
||||
$newsurvey = new object;
|
||||
$newsurvey->id = $recordid;
|
||||
$newsurvey->name = $result;
|
||||
update_record('survey',$newsurvey);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_survey_intro($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$survey = get_record('survey','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($survey->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($survey->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($survey->intro, $fromenc);
|
||||
|
||||
$newsurvey = new object;
|
||||
$newsurvey->id = $recordid;
|
||||
$newsurvey->intro = $result;
|
||||
update_record('survey',$newsurvey);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue