diff -r dc6026376919 -r 5bd429428101 plugins/admin/LangManager.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/admin/LangManager.php Thu Jan 24 22:06:09 2008 -0500 @@ -0,0 +1,131 @@ +auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) + { + $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true); + echo '

' . $lang->get('adm_err_not_auth_title') . '

'; + echo '

' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '

'; + return; + } + if ( isset($_POST['action']) ) + { + $action =& $_POST['action']; + if ( strpos($action, ';') ) + { + $parms = substr($action, strpos($action, ';') + 1); + $action = substr($action, 0, strpos($action, ';')); + preg_match_all('/([a-z0-9_]+)=(.+?)(;|$)/', $parms, $matches); + $parms = array(); + foreach ( $matches[0] as $i => $_ ) + { + $parms[$matches[1][$i]] = $matches[2][$i]; + } + } + switch ( $action ) + { + case 'edit_language': + break; + case 'install_language': + $lang_list = list_available_languages(); + // Verify that we have this language's metadata + if ( isset($lang_list[@$parms['iso639']]) ) + { + // From here it's all downhill :-) + $lang_code =& $parms['iso639']; + $lang_data =& $lang_list[$lang_code]; + + $result = install_language($lang_code, $lang_data['name_eng'], $lang_data['name']); + if ( $result ) + { + // Language installed. Import the language files. + $lang_local = new Language($lang_code); + foreach ( array('core', 'admin', 'tools', 'user') as $file ) + { + $lang_local->import(ENANO_ROOT . "/language/{$lang_data['dir']}/$file.json"); + } + unset($lang_local); + + echo '
' . $lang->get('acplm_msg_lang_install_success', array('lang_name' => htmlspecialchars($lang_data['name_eng']))) . '
'; + } + } + break; + } + } + + // $lang_list is fetched by the posthandler sometimes + if ( !isset($lang_list) ) + { + // Build a list of languages in the languages/ directory, then + // eliminate the ones that are already installed. + $lang_list = list_available_languages(); + } + + // Select current languages + $q = $db->sql_query('SELECT lang_code FROM ' . table_prefix . "language;"); + if ( !$q ) + $db->_die(); + + while ( $row = $db->fetchrow() ) + { + $lang_code =& $row['lang_code']; + if ( isset($lang_list[$lang_code]) ) + { + unset($lang_list[$lang_code]); + unset($lang_list[$lang_code]); // PHP <5.1.4 Zend bug + } + } + + if ( count($lang_list) > 0 ) + { + echo '
'; + echo '

' . $lang->get('acplm_heading_install') . '

'; + echo '
+ + + + + + + '; + + $cls = 'row2'; + foreach ( $lang_list as $lang_code => $lang_data ) + { + $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; + + echo ''; + + $lang_code = htmlspecialchars($lang_code); + $lang_data['name'] = htmlspecialchars($lang_data['name']); + $lang_data['name_eng'] = htmlspecialchars($lang_data['name_eng']); + + echo ""; + echo ""; + echo ""; + echo ""; + + echo ''; + } + echo ' +
' . $lang->get('acplm_col_lang_code') . '' . $lang->get('acplm_col_lang_name') . '' . $lang->get('acplm_col_lang_name_eng') . '
$lang_code{$lang_data['name']}{$lang_data['name_eng']}
+
'; + echo '
'; + } +} +