Changeset 1666 in ExiteCMS for branches/PLi-Fusion/administration/settings_languages.php
- Timestamp:
- 08/21/08 21:06:15 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PLi-Fusion/administration/settings_languages.php
r1538 r1666 28 28 if (!checkrights("S8") || !defined("iAUTH") || $aid != iAUTH) fallback(BASEDIR."index.php"); 29 29 30 /*---------------------------------------------------+ 31 | Local functions | 32 +----------------------------------------------------*/ 33 function migrate($tablename, $fieldname, $from_setting, $to_setting) { 34 global $db_prefix, $settings; 35 36 if ($from_setting == "none" && $to_setting == "single") { 37 // not implemented yet 38 } elseif ($from_setting == "none" && $to_setting == "multiple") { 39 // set everything to the current locale 40 $result = dbquery("UPDATE ".$db_prefix.$tablename. " SET ".$fieldname." = '".$settings['locale_code']."'"); 41 // and copy it to all other active locales 42 $result = dbquery("SELECT * FROM ".$db_prefix."locale WHERE locale_code <> '".$settings['locale_code']."' AND locale_active = 1"); 43 while ($data = dbarray($result)) { 44 $result2 = dbquery("SELECT * FROM ".$db_prefix.$tablename); 45 while ($data2 = dbarray($result2)) { 46 $key = 0; 47 $fields = ""; 48 $values = ""; 49 foreach($data2 as $name => $value) { 50 // skip the primary key 51 if ($key++ == 0) continue; 52 $fields .= ($fields == "" ? "" : ", ") . $name; 53 if ($name == $fieldname) { 54 $values .= ($values == "" ? "" : ", ") . "'".$data['locale_code']."'"; 55 } else { 56 $values .= ($values == "" ? "" : ", ") . "'".mysql_escape_string($value)."'"; 57 } 58 } 59 // insert the duplicated record with the new locale code 60 $result3 = dbquery("INSERT INTO ".$db_prefix.$tablename." (".$fields.") VALUES (".$values.")"); 61 } 62 } 63 } elseif ($from_setting == "single" && $to_setting == "none") { 64 // not implemented yet 65 } elseif ($from_setting == "single" && $to_setting == "multiple") { 66 // not implemented yet 67 } elseif ($from_setting == "multiple" && $to_setting == "none") { 68 $result = dbquery("UPDATE ".$db_prefix.$tablename. " SET ".$fieldname." = ''"); 69 } elseif ($from_setting == "multiple" && $to_setting == "single") { 70 // not implemented yet 71 } else { 72 terminate("invalid migration strategy detected when migrating ".$tablename."!"); 73 } 74 75 } 76 77 /*---------------------------------------------------+ 78 | Main code | 79 +----------------------------------------------------*/ 80 30 81 if (isset($_POST['savesettings'])) { 31 82 // use browser language … … 46 97 $panels_localisation = stripinput($_POST['panels_localisation']); 47 98 if ($panels_localisation != $settings['panels_localisation']) { 48 // migration required99 migrate('panels', 'panel_locale', $settings['panels_localisation'], $panels_localisation); 49 100 } 50 101 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$panels_localisation."' WHERE cfg_name = 'panels_localisation'"); … … 53 104 $sitelinks_localisation = stripinput($_POST['sitelinks_localisation']); 54 105 if ($sitelinks_localisation != $settings['sitelinks_localisation']) { 55 // migration required106 migrate('site_links', 'link_locale', $settings['sitelinks_localisation'], $sitelinks_localisation); 56 107 } 57 108 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$sitelinks_localisation."' WHERE cfg_name = 'sitelinks_localisation'"); … … 60 111 $news_localisation = stripinput($_POST['news_localisation']); 61 112 if ($news_localisation != $settings['news_localisation']) { 62 // migration required 113 migrate('news', 'news_locale', $settings['news_localisation'], $news_localisation); 114 migrate('news_frontpage', 'frontpage_locale', $settings['news_localisation'], $news_localisation); 63 115 } 64 116 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$news_localisation."' WHERE cfg_name = 'news_localisation'"); … … 67 119 $download_localisation = stripinput($_POST['download_localisation']); 68 120 if ($download_localisation != $settings['download_localisation']) { 69 // migration required121 migrate('download_cats', 'download_cat_locale', $settings['download_localisation'], $download_localisation); 70 122 } 71 123 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$download_localisation."' WHERE cfg_name = 'download_localisation'"); … … 74 126 $article_localisation = stripinput($_POST['article_localisation']); 75 127 if ($article_localisation != $settings['article_localisation']) { 76 // migration required128 migrate('article', 'article_locale', $settings['article_localisation'], $download_localisation); 77 129 } 78 130 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$article_localisation."' WHERE cfg_name = 'article_localisation'");
Note: See TracChangeset
for help on using the changeset viewer.
