aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/acp/acp_language.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/acp/acp_language.php')
-rw-r--r--phpBB/includes/acp/acp_language.php79
1 files changed, 37 insertions, 42 deletions
diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php
index bddc2be9cb..8881f624e3 100644
--- a/phpBB/includes/acp/acp_language.php
+++ b/phpBB/includes/acp/acp_language.php
@@ -31,8 +31,8 @@ class acp_language
function main($id, $mode)
{
- global $config, $db, $user, $template;
- global $phpbb_root_path, $phpEx, $request;
+ global $config, $db, $user, $template, $phpbb_log, $phpbb_container;
+ global $phpbb_root_path, $phpEx, $request, $phpbb_dispatcher;
if (!function_exists('validate_language_iso_name'))
{
@@ -44,14 +44,14 @@ class acp_language
$action = (isset($_POST['remove_store'])) ? 'details' : $action;
$submit = (empty($action) && !isset($_POST['update']) && !isset($_POST['test_connection'])) ? false : true;
- $action = (empty($action)) ? request_var('action', '') : $action;
+ $action = (empty($action)) ? $request->variable('action', '') : $action;
$form_name = 'acp_lang';
add_form_key('acp_lang');
- $lang_id = request_var('id', 0);
+ $lang_id = $request->variable('id', 0);
- $selected_lang_file = request_var('language_file', '|common.' . $phpEx);
+ $selected_lang_file = $request->variable('language_file', '|common.' . $phpEx);
list($this->language_directory, $this->language_file) = explode('|', $selected_lang_file);
@@ -84,16 +84,16 @@ class acp_language
$db->sql_freeresult($result);
$sql_ary = array(
- 'lang_english_name' => request_var('lang_english_name', $row['lang_english_name']),
- 'lang_local_name' => utf8_normalize_nfc(request_var('lang_local_name', $row['lang_local_name'], true)),
- 'lang_author' => utf8_normalize_nfc(request_var('lang_author', $row['lang_author'], true)),
+ 'lang_english_name' => $request->variable('lang_english_name', $row['lang_english_name']),
+ 'lang_local_name' => $request->variable('lang_local_name', $row['lang_local_name'], true),
+ 'lang_author' => $request->variable('lang_author', $row['lang_author'], true),
);
$db->sql_query('UPDATE ' . LANG_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE lang_id = ' . $lang_id);
- add_log('admin', 'LOG_LANGUAGE_PACK_UPDATED', $sql_ary['lang_english_name']);
+ $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_LANGUAGE_PACK_UPDATED', false, array($sql_ary['lang_english_name']));
trigger_error($user->lang['LANGUAGE_DETAILS_UPDATED'] . adm_back_link($this->u_action));
break;
@@ -227,9 +227,22 @@ class acp_language
$sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' WHERE lang_id = ' . $lang_id;
$db->sql_query($sql);
- add_log('admin', 'LOG_LANGUAGE_PACK_DELETED', $row['lang_english_name']);
-
- trigger_error(sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']) . adm_back_link($this->u_action));
+ $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_LANGUAGE_PACK_DELETED', false, array($row['lang_english_name']));
+
+ $delete_message = sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']);
+ $lang_iso = $row['lang_iso'];
+ /**
+ * Run code after language deleted
+ *
+ * @event core.acp_language_after_delete
+ * @var string lang_iso Language ISO code
+ * @var string delete_message Delete message appear to user
+ * @since 3.2.2-RC1
+ */
+ $vars = array('lang_iso', 'delete_message');
+ extract($phpbb_dispatcher->trigger_event('core.acp_language_after_delete', compact($vars)));
+
+ trigger_error($delete_message . adm_back_link($this->u_action));
}
else
{
@@ -249,7 +262,7 @@ class acp_language
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
- $lang_iso = request_var('iso', '');
+ $lang_iso = $request->variable('iso', '');
$lang_iso = basename($lang_iso);
if (!$lang_iso || !file_exists("{$phpbb_root_path}language/$lang_iso/iso.txt"))
@@ -337,7 +350,7 @@ class acp_language
}
$db->sql_freeresult($result);
- add_log('admin', 'LOG_LANGUAGE_PACK_INSTALLED', $lang_pack['name']);
+ $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_LANGUAGE_PACK_INSTALLED', false, array($lang_pack['name']));
$message = sprintf($user->lang['LANGUAGE_PACK_INSTALLED'], $lang_pack['name']);
$message .= ($notify_cpf_update) ? '<br /><br />' . $user->lang['LANGUAGE_PACK_CPF_UPDATE'] : '';
@@ -385,42 +398,24 @@ class acp_language
$db->sql_freeresult($result);
$new_ary = $iso = array();
- $dp = @opendir("{$phpbb_root_path}language");
- if ($dp)
+ /** @var \phpbb\language\language_file_helper $language_helper */
+ $language_helper = $phpbb_container->get('language.helper.language_file');
+ $iso = $language_helper->get_available_languages();
+
+ foreach ($iso as $lang_array)
{
- while (($file = readdir($dp)) !== false)
- {
- if ($file[0] == '.' || !is_dir($phpbb_root_path . 'language/' . $file))
- {
- continue;
- }
+ $lang_iso = $lang_array['iso'];
- if (file_exists("{$phpbb_root_path}language/$file/iso.txt"))
- {
- if (!in_array($file, $installed))
- {
- if ($iso = file("{$phpbb_root_path}language/$file/iso.txt"))
- {
- if (sizeof($iso) == 3)
- {
- $new_ary[$file] = array(
- 'iso' => $file,
- 'name' => trim($iso[0]),
- 'local_name'=> trim($iso[1]),
- 'author' => trim($iso[2])
- );
- }
- }
- }
- }
+ if (!in_array($lang_iso, $installed))
+ {
+ $new_ary[$lang_iso] = $lang_array;
}
- closedir($dp);
}
unset($installed);
- if (sizeof($new_ary))
+ if (count($new_ary))
{
foreach ($new_ary as $iso => $lang_ary)
{