示例#1
0
 public static function run($refresh = FALSE)
 {
     global $wpdb;
     $msgs = array();
     // If this is a full refresh, then start by dropping all the possible translation tables
     if ($refresh) {
         $installed = BfoxTrans::get_installed();
         $msgs[] = 'Refresh: Dropping all installed translation tables';
         foreach ($installed as $trans) {
             $wpdb->query("DROP TABLE IF EXISTS {$trans->table}");
             $msgs[] = "Dropped {$trans->table}";
         }
     }
     // Get the translation files
     $files = array();
     $trans_ids = BfoxTrans::get_ids_by_short_name();
     $translations_dir = opendir(self::dir);
     if ($translations_dir) {
         while (($file_name = readdir($translations_dir)) !== false) {
             if (substr($file_name, -9) == '-usfx.xml') {
                 $trans_name = strtoupper(substr($file_name, 0, -9));
                 if (isset($trans_ids[$trans_name])) {
                     $files[$trans_ids[$trans_name]] = $file_name;
                     $msgs[] = "Found translations file: {$file_name}";
                 }
             }
         }
     }
     @closedir($translations_dir);
     $installed = BfoxTrans::get_installed();
     $done_installing = FALSE;
     // Loop through all the translation files we have, and if not installed, install them
     foreach ($files as $id => $file) {
         if (!isset($installed[$id])) {
             if (!$done_installing) {
                 $trans = new BfoxTrans($id);
                 self::create_translation_table($trans);
                 self::load_usfx($trans, $file);
                 $msgs[] = "Installed: {$file} ({$trans->short_name} (ID: {$trans->id}) - {$trans->long_name})";
                 $installed[$id] = $trans;
                 $done_installing = TRUE;
             } else {
                 $msgs[] = "NOTE: Still need to install: {$file}";
             }
         } else {
             $msgs[] = "Skipped: {$file} (already installed)";
         }
     }
     // Enable all the installed translations
     BfoxTrans::set_enabled($installed);
     return $msgs;
 }
示例#2
0
 public function trans_select_options()
 {
     $content = '';
     $curr_value = $this->display_translation->short_name;
     foreach (BfoxTrans::get_installed() as $translation) {
         $value = $translation->short_name;
         $label = $translation->long_name;
         $selected = $value == $curr_value ? ' selected' : '';
         $content .= "<option value='{$value}'{$selected}>{$label}</option>";
     }
     return $content;
 }