utf8 migration support scripts

This commit is contained in:
toyomoyo 2006-01-09 06:06:49 +00:00
parent bbbb201364
commit 1e4d9ff6dc
36 changed files with 4767 additions and 0 deletions

67
mod/lams/db/migrate2utf8.php Executable file
View file

@ -0,0 +1,67 @@
<?
function migrate2utf_lams_name($recordid){
global $CFG;
/// Some trivial checks
if (empty($recordid)) {
log_the_problem_somewhere();
return false;
}
if (!$lams = get_record('lams','id',$recordid) {
log_the_problem_somewhere();
return false;
}
$sitelang = $CFG->lang;
$courselang = get_course_lang($lams->course); //Non existing!
$userlang = get_main_teacher_lang($lams->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($lams->name, $fromenc);
$newlams = new object;
$newlams->id = $recordid;
$newlams->name = $result;
update_record('lams',$newlams);
/// And finally, just return the converted field
return $result;
}
function migrate2utf_lams_introduction($recordid){
global $CFG;
/// Some trivial checks
if (empty($recordid)) {
log_the_problem_somewhere();
return false;
}
if (!$lams = get_record('lams','id',$recordid) {
log_the_problem_somewhere();
return false;
}
$sitelang = $CFG->lang;
$courselang = get_course_lang($lams->course); //Non existing!
$userlang = get_main_teacher_lang($lams->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($lams->introduction, $fromenc);
$newlams = new object;
$newlams->id = $recordid;
$newlams->introduction = $result;
update_record('lams',$newlams);
/// And finally, just return the converted field
return $result;
}
?>

18
mod/lams/db/migrate2utf8.xml Executable file
View file

@ -0,0 +1,18 @@
<DBMIGRATION type="mod/lams" VERSION="2005120100">
<TABLES>
<TABLE name="lams">
<FIELDS>
<FIELD name="name" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
<PHP_FUNCTION>
migrate2utf8_lams_name(RECORDID)
</PHP_FUNCTION>
</FIELD>
<FIELD name="introduction" method="PLAIN_SQL_UPDATE" type="text" length="0">
<PHP_FUNCTION>
migrate2utf8_lams_introduction(RECORDID)
</PHP_FUNCTION>
</FIELD>
</FIELDS>
</TABLE>
</TABLES>
</DBMIGRATION>