Permalink
Browse files

backup-restore, utfmigrate for rsstitletemplate field

  • Loading branch information...
1 parent 3141843 commit f6c74641dd76f59b656537ebb321e151f76e246d toyomoyo committed May 25, 2006
Showing with 45 additions and 0 deletions.
  1. +1 −0 mod/data/backuplib.php
  2. +38 −0 mod/data/db/migrate2utf8.php
  3. +5 −0 mod/data/db/migrate2utf8.xml
  4. +1 −0 mod/data/restorelib.php
View
1 mod/data/backuplib.php
@@ -85,6 +85,7 @@ function data_backup_one_mod($bf,$preferences,$data) {
fwrite ($bf,full_tag("LISTTEMPLATE",4,false,$data->listtemplate));
fwrite ($bf,full_tag("ADDTEMPLATE",4,false,$data->addtemplate));
fwrite ($bf,full_tag("RSSTEMPLATE",4,false,$data->rsstemplate));
+ fwrite ($bf,full_tag("RSSTITLETEMPLATE",4,false,$data->rsstitletemplate));
fwrite ($bf,full_tag("LISTTEMPLATEHEADER",4,false,$data->listtemplateheader));
fwrite ($bf,full_tag("LISTTEMPLATEFOOTER",4,false,$data->listtemplatefooter));
fwrite ($bf,full_tag("APPROVAL",4,false,$data->approval));
View
38 mod/data/db/migrate2utf8.php
@@ -328,6 +328,44 @@ function migrate2utf8_data_rsstemplate($recordid){
return $result;
}
+function migrate2utf8_data_rsstitletemplate($recordid){
+ global $CFG, $globallang;
+
+/// Some trivial checks
+ if (empty($recordid)) {
+ log_the_problem_somewhere();
+ return false;
+ }
+
+ if (!$data = get_record('data','id',$recordid)) {
+ log_the_problem_somewhere();
+ return false;
+ }
+
+ if ($globallang) {
+ $fromenc = $globallang;
+ } else {
+ $sitelang = $CFG->lang;
+ $courselang = get_course_lang($data->course); //Non existing!
+ $userlang = get_main_teacher_lang($data->course); //N.E.!!
+ $fromenc = get_original_encoding($sitelang, $courselang, $userlang);
+ }
+
+/// We are going to use textlib facilities
+
+/// Convert the text
+ if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
+ $result = utfconvert($data->rsstitletemplate, $fromenc);
+
+ $newdata= new object;
+ $newdata->id = $recordid;
+ $newdata->rsstitletemplate = $result;
+ migrate2utf8_update_record('data',$newdata);
+ }
+/// And finally, just return the converted field
+ return $result;
+}
+
function migrate2utf8_data_csstemplate($recordid){
global $CFG, $globallang;
View
5 mod/data/db/migrate2utf8.xml
@@ -163,6 +163,11 @@
migrate2utf_data_rsstemplate(RECORDID)
</PHP_FUNCTION>
</FIELD>
+ <FIELD name="rsstitletemplate" method="PHP_FUNCTION" type="text" length="0">
+ <PHP_FUNCTION>
+ migrate2utf_data_rsstitletemplate(RECORDID)
+ </PHP_FUNCTION>
+ </FIELD>
<FIELD name="listtemplateheader" method="PHP_FUNCTION" type="text" length="0">
<PHP_FUNCTION>
migrate2utf_data_listtemplateheader(RECORDID)
View
1 mod/data/restorelib.php
@@ -70,6 +70,7 @@ function data_restore_mods($mod,$restore) {
$database->listtemplate = backup_todb($info['MOD']['#']['LISTTEMPLATE']['0']['#']);
$database->addtemplate = backup_todb($info['MOD']['#']['ADDTEMPLATE']['0']['#']);
$database->rsstemplate = backup_todb($info['MOD']['#']['RSSTEMPLATE']['0']['#']);
+ $database->rsstitletemplate = backup_todb($info['MOD']['#']['RSSTITLETEMPLATE']['0']['#']);
$database->listtemplateheader = backup_todb($info['MOD']['#']['LISTTEMPLATEHEADER']['0']['#']);
$database->listtemplatefooter = backup_todb($info['MOD']['#']['LISTTEMPLATEFOOTER']['0']['#']);
$database->approval = backup_todb($info['MOD']['#']['APPROVAL']['0']['#']);

0 comments on commit f6c7464

Please sign in to comment.