Zeile 44 | Zeile 44 |
---|
{ $info = str_replace("\\", "\\\\", $info); $info = str_replace('$', '\$', $info);
|
{ $info = str_replace("\\", "\\\\", $info); $info = str_replace('$', '\$', $info);
|
|
|
if($key == 'admin' || $key == 'rtl') { $info = (int)$info; }
|
if($key == 'admin' || $key == 'rtl') { $info = (int)$info; }
|
|
|
$newlanginfo[$key] = str_replace("\"", '\"', $info); }
| $newlanginfo[$key] = str_replace("\"", '\"', $info); }
|
Zeile 80 | Zeile 80 |
---|
\$langinfo['htmllang'] = \"{$newlanginfo['htmllang']}\";
// Sets the character set, blank uses the default.
|
\$langinfo['htmllang'] = \"{$newlanginfo['htmllang']}\";
// Sets the character set, blank uses the default.
|
\$langinfo['charset'] = \"{$newlanginfo['charset']}\";\n". "?".">";
| \$langinfo['charset'] = \"{$newlanginfo['charset']}\";\n";
|
// Put it in! if($file = fopen($file, "w"))
| // Put it in! if($file = fopen($file, "w"))
|
Zeile 103 | Zeile 102 |
---|
} }
|
} }
|
$page->add_breadcrumb_item($languages[$editlang], "index.php?module=config-languages&action=edit&lang={$editlang}");
| $page->add_breadcrumb_item(preg_replace("<\?|\?>", "<span>?</span>", $languages[$editlang]), "index.php?module=config-languages&action=edit&lang={$editlang}");
|
$page->add_breadcrumb_item($lang->nav_editing_set);
$page->output_header($lang->languages);
| $page->add_breadcrumb_item($lang->nav_editing_set);
$page->output_header($lang->languages);
|
Zeile 179 | Zeile 178 |
---|
}
if($mybb->input['action'] == "quick_phrases")
|
}
if($mybb->input['action'] == "quick_phrases")
|
{ // Validate input $editlang = basename($mybb->input['lang']); $folder = MYBB_ROOT."inc/languages/".$editlang."/";
$page->add_breadcrumb_item($languages[$editlang], "index.php?module=config-languages&action=quick_edit&lang={$editlang}");
| { // Validate input $editlang = basename($mybb->input['lang']); $folder = MYBB_ROOT."inc/languages/".$editlang."/";
$page->add_breadcrumb_item(preg_replace("<\?|\?>", "<span>?</span>", $languages[$editlang]), "index.php?module=config-languages&action=quick_edit&lang={$editlang}");
// Validate that this language pack really exists if(file_exists(MYBB_ROOT."inc/languages/".$editlang.".php")) { // Then validate language pack folders (and try to fix them if missing) @mkdir($folder); @mkdir($folder."admin"); }
|
|
|
if(!file_exists($folder) || ($editwithfolder && !file_exists($editwithfolder)))
| if(!file_exists($folder) || !file_exists($folder."admin"))
|
{
|
{
|
flash_message($lang->error_invalid_set, 'error');
| flash_message($lang->error_folders_fail, 'error');
|
admin_redirect("index.php?module=config-languages"); }
| admin_redirect("index.php?module=config-languages"); }
|
Zeile 215 | Zeile 222 |
---|
{ if($mybb->request_method == 'post') {
|
{ if($mybb->request_method == 'post') {
|
| // We have more than one file to edit, lets set flag for all of them. $editsuccess = true;
|
foreach($quick_phrases as $file => $phrases)
|
foreach($quick_phrases as $file => $phrases)
|
{ $lines = file($folder.$file);
$fp = fopen($folder.$file, 'w'); fwrite($fp, '<?php'.PHP_EOL);
for($i = 1; $i < count($lines); $i++) { preg_match_all('/\$l\[\'([a-z].+)\'\]/', $lines[$i], $matches); $phrase = $matches[1][0];
if($mybb->input['edit'][$phrase])
| { @include $folder.$file; $contents_file = (array)$l; unset($l);
foreach($phrases as $key => $value) { // validation - we fetch from input only variables that are defined in $quick_phrases array $contents_file[$key] = $mybb->input['edit'][$key]; } // Save edited language file if($fp = @fopen($folder.$file, "w")) { // We need info about edited language files to generate credits for our file require MYBB_ROOT."inc/languages/".$editlang.".php";
// Lets make nice credits header in language file $lang_file_credits = "<?php\n/**\n"; $lang_file_credits .= " * MyBB Copyright 2014 MyBB Group, All Rights Reserved\n *\n"; $lang_file_credits .= " * Website: https://mybb.com\n"; $lang_file_credits .= " * License: https://mybb.com/about/license\n *\n */\n\n"; $lang_file_credits .= "// ".str_repeat('-',80)."\n"; $lang_file_credits .= "// MyBB Language Pack File.\n"; $lang_file_credits .= "// This file has been generated by MyBB - buildin language pack editor.\n"; $lang_file_credits .= "// ".str_repeat('=',80)."\n"; $lang_file_credits .= "// Friendly name of the language : ".preg_replace("#<\?|\?>#i", " ", $langinfo['name'])."\n"; $lang_file_credits .= "// Author of the language pack : ".preg_replace("#<\?|\?>#i", " ", $langinfo['author'])."\n"; $lang_file_credits .= "// Language pack translators website : ".preg_replace("#<\?|\?>#i", " ", $langinfo['website'])."\n"; $lang_file_credits .= "// Compatible version of MyBB : ".preg_replace("#<\?|\?>#i", " ", $langinfo['version'])."\n"; $lang_file_credits .= "// Last edited in MyBB Editor by : ".preg_replace("#<\?|\?>#i", " ", $mybb->user['username'])."\n"; $lang_file_credits .= "// Last edited date : ".gmdate("r")."\n"; $lang_file_credits .= "// ".str_repeat('-',80)."\n\n";
$contents_wfile = $lang_file_credits; foreach($contents_file as $key => $value)
|
{
|
{
|
$new_line = '$l[\''.$phrase.'\'] = "'.str_replace('"', '\"', $mybb->input['edit'][$phrase]).'";'.PHP_EOL; fwrite($fp, $new_line);
| $contents_wfile .= "\$l['".$key."'] = ".var_export($value, true).";\n";
|
}
|
}
|
else { fwrite($fp, $lines[$i]); } }
| |
|
|
fclose($fp);
| flock($fp, LOCK_EX); fwrite($fp, $contents_wfile); flock($fp, LOCK_UN); fclose($fp); } else { // One of files failed $editsuccess = false; }
|
}
|
}
|
// Log admin action log_admin_action($editlang);
flash_message($lang->success_quickphrases_updated, 'success'); admin_redirect('index.php?module=config-languages&action=edit&lang='.$editlang);
| if($editsuccess == true) { // Log admin action log_admin_action($editlang);
flash_message($lang->success_quickphrases_updated, 'success'); admin_redirect('index.php?module=config-languages&action=edit&lang='.$editlang); }
|
} }
|
} }
|
|
|
$page->output_header($lang->languages);
$sub_tabs['language_files'] = array(
| $page->output_header($lang->languages);
$sub_tabs['language_files'] = array(
|
Zeile 261 | Zeile 299 |
---|
'title' => $lang->quick_phrases, 'link' => "index.php?module=config-languages&action=quick_phrases&lang=".$editlang, 'description' => $lang->quick_phrases_desc
|
'title' => $lang->quick_phrases, 'link' => "index.php?module=config-languages&action=quick_phrases&lang=".$editlang, 'description' => $lang->quick_phrases_desc
|
);
$page->output_nav_tabs($sub_tabs, 'quick_phrases');
| );
$page->output_nav_tabs($sub_tabs, 'quick_phrases');
|
$form = new Form('index.php?module=config-languages&action=quick_phrases&lang='.$editlang, 'post', 'quick_phrases');
if($errors)
|
$form = new Form('index.php?module=config-languages&action=quick_phrases&lang='.$editlang, 'post', 'quick_phrases');
if($errors)
|
{
| {
|
$page->output_inline_error($errors);
|
$page->output_inline_error($errors);
|
}
| }
|
$table = new Table;
|
$table = new Table;
|
// Check if file is writable, before allowing submission
| // Check if files are writable, before allowing submission
|
$no_write = null;
|
$no_write = null;
|
foreach($quick_phrases as $file => $phrases) { if(!is_writable($folder.$file))
| foreach($quick_phrases as $file => $phrases) { if(file_exists($folder.$file) && !is_writable($folder.$file) || !is_writable($folder))
|
{ $no_write = 1;
|
{ $no_write = 1;
|
} }
| } }
|
if($no_write)
|
if($no_write)
|
{
| {
|
$page->output_alert($lang->alert_note_cannot_write); }
| $page->output_alert($lang->alert_note_cannot_write); }
|
Zeile 294 | Zeile 331 |
---|
foreach($quick_phrases as $file => $phrases) {
|
foreach($quick_phrases as $file => $phrases) {
|
require $folder.$file;
| unset($langinfo); @include MYBB_ROOT."inc/languages/".$editlang.".php"; $quickphrases_dir_class = " langeditor_ltr"; if((int)$langinfo['rtl'] > 0) { $quickphrases_dir_class = " langeditor_rtl"; }
|
|
|
| @include $folder.$file;
|
foreach($phrases as $phrase => $description) { $value = $l[$phrase];
| foreach($phrases as $phrase => $description) { $value = $l[$phrase];
|
Zeile 308 | Zeile 352 |
---|
$value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return "&#".hexdec($matches[1]).";";'), $value); }
|
$value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return "&#".hexdec($matches[1]).";";'), $value); }
|
$form_container->output_row($description, $phrase, $form->generate_text_area("edit[$phrase]", $value, array('id' => 'lang_'.$phrase, 'rows' => 2, 'style' => "width: 98%; padding: 4px;")), 'lang_'.$phrase, array('width' => '50%'));
| $form_container->output_row($description, $phrase, $form->generate_text_area("edit[$phrase]", $value, array('id' => 'lang_'.$phrase, 'rows' => 2, 'class' => "langeditor_textarea_edit {$quickphrases_dir_class}")), 'lang_'.$phrase, array('width' => '50%'));
|
} }
| } }
|
Zeile 328 | Zeile 372 |
---|
$editlang = basename($mybb->input['lang']); $folder = MYBB_ROOT."inc/languages/".$editlang."/";
|
$editlang = basename($mybb->input['lang']); $folder = MYBB_ROOT."inc/languages/".$editlang."/";
|
$page->add_breadcrumb_item($languages[$editlang], "index.php?module=config-languages&action=edit&lang={$editlang}");
| $page->add_breadcrumb_item(preg_replace("<\?|\?>", "<span>?</span>", $languages[$editlang]), "index.php?module=config-languages&action=edit&lang={$editlang}");
|
$editwith = basename($mybb->input['editwith']); $editwithfolder = '';
| $editwith = basename($mybb->input['editwith']); $editwithfolder = '';
|
Zeile 338 | Zeile 382 |
---|
$editwithfolder = MYBB_ROOT."inc/languages/".$editwith."/"; }
|
$editwithfolder = MYBB_ROOT."inc/languages/".$editwith."/"; }
|
if(!file_exists($folder) || ($editwithfolder && !file_exists($editwithfolder)))
| // Validate that edited language pack really exists if(file_exists(MYBB_ROOT."inc/languages/".$editlang.".php")) { // Then validate edited language pack folders (and try to fix them if missing) @mkdir($folder); @mkdir($folder."admin"); }
if(!file_exists($folder) || !file_exists($folder."admin")) { flash_message($lang->error_folders_fail, 'error'); admin_redirect("index.php?module=config-languages"); }
// If we edit in compare mode, verify that at least folders of compared language exists if($editwithfolder && (!file_exists($editwithfolder) || !file_exists($editwithfolder)))
|
{ flash_message($lang->error_invalid_set, 'error'); admin_redirect("index.php?module=config-languages");
| { flash_message($lang->error_invalid_set, 'error'); admin_redirect("index.php?module=config-languages");
|
Zeile 355 | Zeile 414 |
---|
$file = 'admin/'.$file; } $page->add_breadcrumb_item($file);
|
$file = 'admin/'.$file; } $page->add_breadcrumb_item($file);
|
|
|
$editfile = $folder.$file; $withfile = '';
| $editfile = $folder.$file; $withfile = '';
|
Zeile 363 | Zeile 422 |
---|
if($editwithfolder) { $editwithfile = $editwithfolder.$file;
|
if($editwithfolder) { $editwithfile = $editwithfolder.$file;
|
}
if(!file_exists($editfile) || ($editwithfile && !file_exists($editwithfile)) || $file == '.' || $file == '..') { flash_message($lang->error_invalid_file, 'error'); admin_redirect("index.php?module=config-languages");
| |
}
if($mybb->request_method == "post")
|
}
if($mybb->request_method == "post")
|
{ // Make the contents of the new file
// Load the old file $contents = implode('', file($editfile));
| { // Save edited phrases to language file
// To validate input - build array of keys that allready exist in files @include $editfile; $valid_keys = (array)$l; unset($l); @include $editwithfile; $valid_keys = array_merge($valid_keys, (array)$l); unset($l);
|
|
|
// Loop through and change entries foreach($mybb->input['edit'] as $key => $phrase)
| // Then fetch from input only valid keys foreach($valid_keys as $key => $value)
|
{
|
{
|
// Sanitize (but it doesn't work well) $phrase = str_replace('$', '\$', $phrase); $phrase = str_replace("\\", "\\\\", $phrase); $phrase = str_replace("\"", '\"', $phrase); $key = str_replace("\\", '', $key); $key = str_replace('$', '', $key); $key = str_replace("'", '', $key);
// Ugly regexp to find a variable and replace it. $contents = preg_replace('@\n\$l\[\''.$key.'\']([\s]*)=([\s]*)("(.*?)"|\'(.*?)\');([\s]*)\n@si', "\n\$l['{$key}'] = \"{$phrase}\";\n", $contents);
| $contents_wfile .= "\$l['".$key."'] = ".var_export($mybb->input['edit'][$key], true).";\n";
|
}
|
}
|
// Put it back!
| // Save edited language file
|
if($fp = @fopen($editfile, "w"))
|
if($fp = @fopen($editfile, "w"))
|
{ fwrite($fp, $contents);
| { // We need info about edited language files to generate credits for our file require MYBB_ROOT."inc/languages/".$editlang.".php";
// Lets make nice credits header in language file $lang_file_credits = "<?php\n/**\n"; $lang_file_credits .= " * MyBB Copyright 2014 MyBB Group, All Rights Reserved\n *\n"; $lang_file_credits .= " * Website: https://mybb.com\n"; $lang_file_credits .= " * License: https://mybb.com/about/license\n *\n */\n\n"; $lang_file_credits .= "// ".str_repeat('-',80)."\n"; $lang_file_credits .= "// MyBB Language Pack File.\n"; $lang_file_credits .= "// This file has been generated by MyBB - buildin language pack editor.\n"; $lang_file_credits .= "// ".str_repeat('=',80)."\n"; $lang_file_credits .= "// Friendly name of the language : ".preg_replace("#<\?|\?>#i", " ", $langinfo['name'])."\n"; $lang_file_credits .= "// Author of the language pack : ".preg_replace("#<\?|\?>#i", " ", $langinfo['author'])."\n"; $lang_file_credits .= "// Language pack translators website : ".preg_replace("#<\?|\?>#i", " ", $langinfo['website'])."\n"; $lang_file_credits .= "// Compatible version of MyBB : ".preg_replace("#<\?|\?>#i", " ", $langinfo['version'])."\n"; $lang_file_credits .= "// Last edited in MyBB Editor by : ".preg_replace("#<\?|\?>#i", " ", $mybb->user['username'])."\n"; $lang_file_credits .= "// Last edited date : ".gmdate("r")."\n"; $lang_file_credits .= "// ".str_repeat('-',80)."\n\n";
$contents_wfile = $lang_file_credits.$contents_wfile;
flock($fp, LOCK_EX); fwrite($fp, $contents_wfile); flock($fp, LOCK_UN);
|
fclose($fp);
$plugins->run_hooks("admin_config_languages_edit_commit");
// Log admin action
|
fclose($fp);
$plugins->run_hooks("admin_config_languages_edit_commit");
// Log admin action
|
log_admin_action($editlang, $editfile, $mybb->input['inadmin']);
| log_admin_action($editlang, $editfile, $mybb->get_input('inadmin', MyBB::INPUT_INT));
|
flash_message($lang->success_langfile_updated, 'success'); admin_redirect("index.php?module=config-languages&action=edit&lang={$editlang}&editwith={$editwith}");
| flash_message($lang->success_langfile_updated, 'success'); admin_redirect("index.php?module=config-languages&action=edit&lang={$editlang}&editwith={$editwith}");
|
Zeile 412 | Zeile 485 |
---|
$errors[] = $lang->error_cannot_write_to_file; } }
|
$errors[] = $lang->error_cannot_write_to_file; } }
|
| unset($langinfo); @include MYBB_ROOT."inc/languages/".$editwith.".php"; $editwith_dir_class = " langeditor_ltr"; if((int)$langinfo['rtl'] > 0) { $editwith_dir_class = " langeditor_rtl"; } unset($langinfo); @include MYBB_ROOT."inc/languages/".$editlang.".php"; $editlang_dir_class = " langeditor_ltr"; if((int)$langinfo['rtl'] > 0) { $editlang_dir_class = " langeditor_rtl"; }
// Build and output form with edited phrases
|
// Get file being edited in an array
|
// Get file being edited in an array
|
require $editfile;
if(count($l) > 0) { $editvars = $l; } else { $editvars = array(); }
| @include $editfile; $editvars = (array)$l;
|
unset($l);
$withvars = array();
|
unset($l);
$withvars = array();
|
// Get edit with file in an array
| // Get edit with file in an array if exists
|
if($editwithfile) {
|
if($editwithfile) {
|
require $editwithfile; $withvars = $l;
| // File we will compare to, may not exists, but dont worry we will auto switch to solo mode later if so @include $editwithfile; $withvars = (array)$l;
|
unset($l); }
| unset($l); }
|
Zeile 446 | Zeile 529 |
---|
$page->output_nav_tabs($sub_tabs, "edit_language_variables");
$form = new Form("index.php?module=config-languages&action=edit", "post", "edit");
|
$page->output_nav_tabs($sub_tabs, "edit_language_variables");
$form = new Form("index.php?module=config-languages&action=edit", "post", "edit");
|
echo $form->generate_hidden_field("file", $file);
| echo $form->generate_hidden_field("file", htmlspecialchars_uni($file));
|
echo $form->generate_hidden_field("lang", $editlang); echo $form->generate_hidden_field("editwith", $editwith);
|
echo $form->generate_hidden_field("lang", $editlang); echo $form->generate_hidden_field("editwith", $editwith);
|
echo $form->generate_hidden_field("inadmin", (int)$mybb->input['inadmin']);
| echo $form->generate_hidden_field("inadmin", $mybb->get_input('inadmin', MyBB::INPUT_INT));
|
if($errors) { $page->output_inline_error($errors);
| if($errors) { $page->output_inline_error($errors);
|
Zeile 457 | Zeile 540 |
---|
// Check if file is writable, before allowing submission $no_write = null;
|
// Check if file is writable, before allowing submission $no_write = null;
|
if(!is_writable($editfile))
| if(file_exists($editfile) && !is_writable($editfile) || !is_writable($folder))
|
{ $no_write = 1; $page->output_alert($lang->alert_note_cannot_write); }
|
{ $no_write = 1; $page->output_alert($lang->alert_note_cannot_write); }
|
$form_container = new FormContainer($file); if($editwithfile)
| $form_container = new FormContainer(htmlspecialchars_uni($file)); if($editwithfile && $withvars)
|
{ // Editing with another file
|
{ // Editing with another file
|
$form_container->output_row_header($languages[$editwith]); $form_container->output_row_header($languages[$editlang]);
// Make each editing row foreach($editvars as $key => $value) { if(my_strtolower($langinfo['charset']) == "utf-8") { $withvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return dec_to_utf8(hexdec($matches[1]));'), $withvars[$key]); $value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return dec_to_utf8(hexdec($matches[1]));'), $value); } else
| $form_container->output_row_header(preg_replace("<\?|\?>", "<span>?</span>", $languages[$editwith])); $form_container->output_row_header(preg_replace("<\?|\?>", "<span>?</span>", $languages[$editlang]));
foreach($withvars as $key => $value) { if(my_strtolower($langinfo['charset']) == "utf-8")
|
{ $withvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return dec_to_utf8(hexdec($matches[1]));'), $withvars[$key]);
|
{ $withvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return dec_to_utf8(hexdec($matches[1]));'), $withvars[$key]);
|
$value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return "&#".hexdec($matches[1]).";";'), $value);
| $editvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return dec_to_utf8(hexdec($matches[1]));'), $editvars[$key]); } else { $withvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return dec_to_utf8(hexdec($matches[1]));'), $withvars[$key]); $editvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return "&#".hexdec($matches[1]).";";'), $editvars[$key]); }
// Find problems and differences in editfile in comparision to editwithfile
// Count {x} in left and right variable $withvars_value_cbvCount = preg_match_all("/{[ \t]*\d+[ \t]*}/", $withvars[$key], $matches); $editvars_value_cbvCount = preg_match_all("/{[ \t]*\d+[ \t]*}/", $editvars[$key], $matches);
// If left contain something but right is empty or only spaces || count of {x} are different betwin left and right if($withvars[$key] && !$editvars[$key] || $withvars_value_cbvCount != $editvars_value_cbvCount) { $textarea_issue_class = " langeditor_textarea_issue"; } else { $textarea_issue_class = ""; }
$form_container->output_row($key, "", $form->generate_text_area("", $withvars[$key], array('readonly' => true, 'rows' => 2, 'class' => "langeditor_textarea_editwith {$editwith_dir_class}")), "", array('width' => '50%', 'skip_construct' => true)); $form_container->output_row($key, "", $form->generate_text_area("edit[$key]", $editvars[$key], array('id' => 'lang_'.$key, 'rows' => 2, 'class' => "langeditor_textarea_edit {$textarea_issue_class} {$editlang_dir_class}")), 'lang_'.$key, array('width' => '50%')); }
// Create form fields for extra variables that are present only in edited file $present_in_edit_vars_only = (array)array_diff_key($editvars, $withvars); if($present_in_edit_vars_only) { foreach($present_in_edit_vars_only as $key => $value) { if(my_strtolower($langinfo['charset']) == "utf-8") { $editvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return dec_to_utf8(hexdec($matches[1]));'), $editvars[$key]); } else { $editvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return "&#".hexdec($matches[1]).";";'), $editvars[$key]); }
$form_container->output_row("", "", "", "", array('width' => '50%', 'skip_construct' => true)); $form_container->output_row($key, "", $form->generate_text_area("edit[$key]", $editvars[$key], array('id' => 'lang_'.$key, 'rows' => 2, 'class' => "langeditor_textarea_edit {$editlang_dir_class}")), 'lang_'.$key, array('width' => '50%'));
|
}
|
}
|
$form_container->output_row($key, "", $form->generate_text_area("", $withvars[$key], array('disabled' => true, 'rows' => 2, 'style' => "width: 98%; padding: 4px;")), "", array('width' => '50%', 'skip_construct' => true)); $form_container->output_row($key, "", $form->generate_text_area("edit[$key]", $value, array('id' => 'lang_'.$key, 'rows' => 2, 'style' => "width: 98%; padding: 4px;")), 'lang_'.$key, array('width' => '50%'));
| |
}
|
}
|
|
|
} else { // Editing individually
|
} else { // Editing individually
|
$form_container->output_row_header($languages[$editlang]);
| $form_container->output_row_header(preg_replace("<\?|\?>", "<span>?</span>", $languages[$editlang]));
|
|
|
// Make each editing row
| // Make each editing row from current file that we edit
|
foreach($editvars as $key => $value) { if(my_strtolower($langinfo['charset']) == "utf-8")
| foreach($editvars as $key => $value) { if(my_strtolower($langinfo['charset']) == "utf-8")
|
Zeile 503 | Zeile 624 |
---|
{ $value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return "&#".hexdec($matches[1]).";";'), $value); }
|
{ $value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return "&#".hexdec($matches[1]).";";'), $value); }
|
$form_container->output_row($key, "", $form->generate_text_area("edit[$key]", $value, array('id' => 'lang_'.$key, 'rows' => 2, 'style' => "width: 98%; padding: 4px;")), 'lang_'.$key, array('width' => '50%'));
| $form_container->output_row($key, "", $form->generate_text_area("edit[$key]", $value, array('id' => 'lang_'.$key, 'rows' => 2, 'class' => "langeditor_textarea_edit {$editlang_dir_class}")), 'lang_'.$key, array('width' => '50%'));
|
}
|
}
|
}
| }
|
$form_container->end();
|
$form_container->end();
|
| if(!count($editvars)) { $no_write = 1; }
|
$buttons[] = $form->generate_submit_button($lang->save_language_file, array('disabled' => $no_write));
|
$buttons[] = $form->generate_submit_button($lang->save_language_file, array('disabled' => $no_write));
|
|
|
$form->output_submit_wrapper($buttons); $form->end(); } else {
|
$form->output_submit_wrapper($buttons); $form->end(); } else {
|
| // Build and output list of available language files
|
$page->output_header($lang->languages);
$sub_tabs['language_files'] = array(
| $page->output_header($lang->languages);
$sub_tabs['language_files'] = array(
|
Zeile 531 | Zeile 659 |
---|
$page->output_nav_tabs($sub_tabs, 'language_files');
|
$page->output_nav_tabs($sub_tabs, 'language_files');
|
| if(!file_exists(MYBB_ROOT."inc/languages/".$editlang.".php")) { flash_message($lang->error_invalid_set, 'error'); admin_redirect("index.php?module=config-languages"); }
|
require MYBB_ROOT."inc/languages/".$editlang.".php";
$table = new Table;
|
require MYBB_ROOT."inc/languages/".$editlang.".php";
$table = new Table;
|
$table->construct_header($lang->file); $table->construct_header($lang->controls, array("class" => "align_center", "width" => 100));
| if($editwithfolder) { $table->construct_header(preg_replace("<\?|\?>", "<span>?</span>", $languages[$editwith])); $table->construct_header($lang->phrases, array("class" => "align_center", "width" => 100)); $table->construct_header(preg_replace("<\?|\?>", "<span>?</span>", $languages[$editlang])); $table->construct_header($lang->issues, array("class" => "align_center", "width" => 100)); $table->construct_header($lang->controls, array("class" => "align_center", "width" => 100)); } else { $table->construct_header(preg_replace("<\?|\?>", "<span>?</span>", $languages[$editlang])); $table->construct_header($lang->phrases, array("class" => "align_center", "width" => 100)); $table->construct_header($lang->controls, array("class" => "align_center", "width" => 100)); }
|
// Get files in main folder $filenames = array();
| // Get files in main folder $filenames = array();
|
Zeile 552 | Zeile 697 |
---|
sort($filenames); }
|
sort($filenames); }
|
foreach($filenames as $key => $file) { $table->construct_cell("<strong>{$file}</strong>"); $table->construct_cell("<a href=\"index.php?module=config-languages&action=edit&lang={$editlang}&editwith={$editwith}&file={$file}\">{$lang->edit}</a>", array("class" => "align_center")); $table->construct_row(); }
| $edit_colspan = 3; // Get files from folder we want to peek at (if possible) if($editwithfolder) { $edit_colspan = 5; $filenameswith = array(); if($handle = opendir($editwithfolder)) { while(false !== ($file = readdir($handle))) { if(preg_match("#\.lang\.php$#", $file)) { $filenameswith[] = $file; } } closedir($handle); sort($filenameswith); } }
if($editwithfolder) { $files_left = array_diff($filenameswith, $filenames); $files_right = array_diff($filenames, $filenameswith); $files_both = array_intersect($filenameswith, $filenames);
foreach($files_left as $key => $file) { @include $editwithfolder.$file; $editvars_left = (array)$l; unset($l);
$icon_issues = "<span class='langeditor_ok' title='".$lang->issues_ok."'></span>"; if(count($editvars_left) >0) { $icon_issues = "<span class='langeditor_warning' title='".$lang->issues_warning."'></span>"; }
$table->construct_cell($file, array("class" => "langeditor_editwithfile")); $table->construct_cell(count($editvars_left), array("class" => "langeditor_phrases")); $table->construct_cell("", array("class" => "langeditor_editfile")); $table->construct_cell($icon_issues, array("class" => "langeditor_issues")); $table->construct_cell("<a href=\"index.php?module=config-languages&action=edit&lang={$editlang}&editwith={$editwith}&file={$file}\">{$lang->edit}</a>", array("class" => "langeditor_edit")); $table->construct_row(); } foreach($files_right as $key => $file) { @include $folder.$file; $editvars_right = (array)$l; unset($l);
$icon_issues = "<span class='langeditor_ok' title='".$lang->issues_ok."'></span>"; if(count($editvars_right >0)) { $icon_issues = "<span class='langeditor_nothingtocompare' title='".$lang->issues_nothingtocompare."'></span>"; }
$table->construct_cell("", array("class" => "langeditor_editwithfile")); $table->construct_cell("", array("class" => "langeditor_phrases")); $table->construct_cell($file, array("class" => "langeditor_editfile")); $table->construct_cell($icon_issues, array("class" => "langeditor_issues")); $table->construct_cell("<a href=\"index.php?module=config-languages&action=edit&lang={$editlang}&editwith={$editwith}&file={$file}\">{$lang->edit}</a>", array("class" => "langeditor_edit")); $table->construct_row(); } foreach($files_both as $key => $file) { @include $editwithfolder.$file; $editvars_left = (array)$l; unset($l); @include $folder.$file; $editvars_right = (array)$l; unset($l);
$table->construct_cell($file, array("class" => "langeditor_editwithfile")); $table->construct_cell(count($editvars_left), array("class" => "langeditor_phrases")); $table->construct_cell($file, array("class" => "langeditor_editfile"));
$icon_issues = "<span class='langeditor_ok' title='".$lang->issues_ok."'></span>";
// Find problems and differences in editfile in comparision to editwithfile foreach($editvars_left as $editvars_left_key => $editvars_left_value) { // Count {x} in left and right variable $editvars_left_value_cbvCount = preg_match_all("/{[ \t]*\d+[ \t]*}/", $editvars_left_value, $matches); $editvars_right_value_cbvCount = preg_match_all("/{[ \t]*\d+[ \t]*}/", $editvars_right[$editvars_left_key], $matches); // If left contain something but right is empty || count of {x} are different betwin left and right if($editvars_left_value && !$editvars_right[$editvars_left_key] || $editvars_left_value_cbvCount != $editvars_right_value_cbvCount) { $icon_issues = "<span class='langeditor_warning' title='".$lang->issues_warning."'></span>"; // One difference is enought, so lets abort checking for more. break; } }
$table->construct_cell($icon_issues, array("class" => "langeditor_issues")); $table->construct_cell("<a href=\"index.php?module=config-languages&action=edit&lang={$editlang}&editwith={$editwith}&file={$file}\">{$lang->edit}</a>", array("class" => "langeditor_edit")); $table->construct_row(); } } else { foreach($filenames as $key => $file) { @include $folder.$file; $editvars_count = (array)$l; unset($l);
$table->construct_cell($file, array("class" => "langeditor_editfile")); $table->construct_cell(count($editvars_count), array("class" => "langeditor_phrases")); $table->construct_cell("<a href=\"index.php?module=config-languages&action=edit&lang={$editlang}&editwith={$editwith}&file={$file}\">{$lang->edit}</a>", array("class" => "langeditor_edit")); $table->construct_row(); } }
|
if($table->num_rows() == 0) {
|
if($table->num_rows() == 0) {
|
$table->construct_cell($lang->no_language_files_front_end, array('colspan' => 3));
| $table->construct_cell($lang->no_language_files_front_end, array('colspan' => $edit_colspan));
|
$table->construct_row(); }
$table->output($lang->front_end);
|
$table->construct_row(); }
$table->output($lang->front_end);
|
|
|
if($langinfo['admin'] != 0) {
|
if($langinfo['admin'] != 0) {
|
| $table = new Table; if($editwithfolder) { $table->construct_header(preg_replace("<\?|\?>", "<span>?</span>", $languages[$editwith])); $table->construct_header($lang->phrases, array("class" => "align_center", "width" => 100)); $table->construct_header(preg_replace("<\?|\?>", "<span>?</span>", $languages[$editlang])); $table->construct_header($lang->issues, array("class" => "align_center", "width" => 100)); $table->construct_header($lang->controls, array("class" => "align_center", "width" => 100)); } else { $table->construct_header(preg_replace("<\?|\?>", "<span>?</span>", $languages[$editlang])); $table->construct_header($lang->phrases, array("class" => "align_center", "width" => 100)); $table->construct_header($lang->controls, array("class" => "align_center", "width" => 100)); }
|
// Get files in admin folder $adminfilenames = array(); if($handle = opendir($folder."admin"))
| // Get files in admin folder $adminfilenames = array(); if($handle = opendir($folder."admin"))
|
Zeile 582 | Zeile 850 |
---|
} closedir($handle); sort($adminfilenames);
|
} closedir($handle); sort($adminfilenames);
|
}
$table = new Table; $table->construct_header($lang->file); $table->construct_header($lang->controls, array("class" => "align_center", "width" => 100));
| }
$edit_colspan = 3; // Get files from admin folder we want to peek at (if possible) if($editwithfolder) { $edit_colspan = 5; $adminfilenameswith = array(); if($handle = opendir($editwithfolder."admin")) { while(false !== ($file = readdir($handle))) { if(preg_match("#\.lang\.php$#", $file)) { $adminfilenameswith[] = $file; } } closedir($handle); sort($adminfilenameswith); } }
if($editwithfolder) { $files_left = array_diff($adminfilenameswith, $adminfilenames); $files_right = array_diff($adminfilenames, $adminfilenameswith); $files_both = array_intersect($adminfilenameswith, $adminfilenames);
foreach($files_left as $key => $file) { @include $editwithfolder."admin/".$file; $editvars_left = (array)$l; unset($l);
$icon_issues = "<span class='langeditor_ok' title='".$lang->issues_ok."'></span>"; if(count($editvars_left) >0) { $icon_issues = "<span class='langeditor_warning' title='".$lang->issues_warning."'></span>"; }
$table->construct_cell($file, array("class" => "langeditor_editwithfile")); $table->construct_cell(count($editvars_left), array("class" => "langeditor_phrases")); $table->construct_cell("", array("class" => "langeditor_editfile")); $table->construct_cell($icon_issues, array("class" => "langeditor_issues")); $table->construct_cell("<a href=\"index.php?module=config-languages&action=edit&lang={$editlang}&editwith={$editwith}&file={$config['admindir']}/{$file}&inadmin=1\">{$lang->edit}</a>", array("class" => "langeditor_edit")); $table->construct_row(); } foreach($files_right as $key => $file) { @include $folder."admin/".$file; $editvars_right = (array)$l; unset($l);
$icon_issues = "<span class='langeditor_ok' title='".$lang->issues_ok."'></span>"; if(count($editvars_right >0)) { $icon_issues = "<span class='langeditor_nothingtocompare' title='".$lang->issues_nothingtocompare."'></span>"; }
$table->construct_cell("", array("class" => "langeditor_editwithfile")); $table->construct_cell("", array("class" => "langeditor_phrases")); $table->construct_cell($file, array("class" => "langeditor_editfile")); $table->construct_cell($icon_issues, array("class" => "langeditor_issues")); $table->construct_cell("<a href=\"index.php?module=config-languages&action=edit&lang={$editlang}&editwith={$editwith}&file={$config['admindir']}/{$file}&inadmin=1\">{$lang->edit}</a>", array("class" => "langeditor_edit")); $table->construct_row(); } foreach($files_both as $key => $file) { @include $editwithfolder."admin/".$file; $editvars_left = (array)$l; unset($l); @include $folder."admin/".$file; $editvars_right = (array)$l; unset($l);
$table->construct_cell($file, array("class" => "langeditor_editwithfile")); $table->construct_cell(count($editvars_left), array("class" => "langeditor_phrases")); $table->construct_cell($file, array("class" => "langeditor_editfile"));
$icon_issues = "<span class='langeditor_ok' title='".$lang->issues_ok."'></span>";
// Find problems and differences in editfile in comparision to editwithfile foreach($editvars_left as $editvars_left_key => $editvars_left_value) { // Count {x} in left and right variable $editvars_left_value_cbvCount = preg_match_all("/{[ \t]*\d+[ \t]*}/", $editvars_left_value, $matches); $editvars_right_value_cbvCount = preg_match_all("/{[ \t]*\d+[ \t]*}/", $editvars_right[$editvars_left_key], $matches); // If left contain something but right is empty || count of {x} are different betwin left and right if($editvars_left_value && !$editvars_right[$editvars_left_key] || $editvars_left_value_cbvCount != $editvars_right_value_cbvCount) { $icon_issues = "<span class='langeditor_warning' title='".$lang->issues_warning."'></span>"; // One difference is enought. break; } }
$table->construct_cell($icon_issues, array("class" => "langeditor_issues")); $table->construct_cell("<a href=\"index.php?module=config-languages&action=edit&lang={$editlang}&editwith={$editwith}&file={$config['admindir']}/{$file}&inadmin=1\">{$lang->edit}</a>", array("class" => "langeditor_edit")); $table->construct_row(); } } else { foreach($adminfilenames as $key => $file) { @include $folder."admin/".$file; $editvars_count = (array)$l; unset($l);
|
|
|
foreach($adminfilenames as $key => $file) { $table->construct_cell("<strong>{$file}</strong>"); $table->construct_cell("<a href=\"index.php?module=config-languages&action=edit&lang={$editlang}&editwith={$editwith}&file={$config['admindir']}/{$file}&inadmin=1\">{$lang->edit}</a>", array("class" => "align_center")); $table->construct_row();
| $table->construct_cell($file, array("class" => "langeditor_editfile")); $table->construct_cell(count($editvars_count), array("class" => "langeditor_phrases")); $table->construct_cell("<a href=\"index.php?module=config-languages&action=edit&lang={$editlang}&editwith={$editwith}&file={$config['admindir']}/{$file}&inadmin=1\">{$lang->edit}</a>", array("class" => "langeditor_edit")); $table->construct_row(); }
|
}
|
}
|
if($table->num_rows() == 0)
| if($table->num_rows() == 0)
|
{
|
{
|
$table->construct_cell($lang->no_language_files_admin_cp, array('colspan' => 3)); $table->construct_row();
| $table->construct_cell($lang->no_language_files_admin_cp, array('colspan' => $edit_colspan)); $table->construct_row();
|
}
$table->output($lang->admin_cp);
| }
$table->output($lang->admin_cp);
|
Zeile 619 | Zeile 990 |
---|
); $sub_tabs['find_language'] = array( 'title' => $lang->find_language_packs,
|
); $sub_tabs['find_language'] = array( 'title' => $lang->find_language_packs,
|
'link' => "http://www.mybb.com/downloads/translations",
| 'link' => "https://community.mybb.com/mods.php?action=browse&category=19",
|
'target' => "_blank" );
| 'target' => "_blank" );
|
Zeile 631 | Zeile 1002 |
---|
$table->construct_header($lang->languagevar); $table->construct_header($lang->version, array("class" => "align_center", "width" => 100)); $table->construct_header($lang->controls, array("class" => "align_center", "width" => 155));
|
$table->construct_header($lang->languagevar); $table->construct_header($lang->version, array("class" => "align_center", "width" => 100)); $table->construct_header($lang->controls, array("class" => "align_center", "width" => 155));
|
|
|
asort($languages);
foreach($languages as $key1 => $langname1) {
|
asort($languages);
foreach($languages as $key1 => $langname1) {
|
$langselectlangs[$key1] = $lang->sprintf($lang->edit_with, $langname1);
| $langselectlangs[$key1] = $lang->sprintf($lang->edit_with, preg_replace("<\?|\?>", "<span>?</span>", $langname1));
|
}
foreach($languages as $key => $langname)
| }
foreach($languages as $key => $langname)
|
Zeile 652 | Zeile 1023 |
---|
$author = $langinfo['author']; }
|
$author = $langinfo['author']; }
|
$table->construct_cell("<strong>{$langinfo['name']}</strong><br /><small>{$author}</small>");
| $table->construct_cell("<span class='langeditor_info_name'>".preg_replace("<\?|\?>", "<span>?</span>", $langinfo['name'])."</span><br /><span class='langeditor_info_author'>{$author}</span>");
|
$table->construct_cell($langinfo['version'], array("class" => "align_center"));
$popup = new PopupMenu("language_{$key}", $lang->options); $popup->add_item($lang->edit_language_variables, "index.php?module=config-languages&action=edit&lang={$key}"); foreach($langselectlangs as $key1 => $langname1) {
|
$table->construct_cell($langinfo['version'], array("class" => "align_center"));
$popup = new PopupMenu("language_{$key}", $lang->options); $popup->add_item($lang->edit_language_variables, "index.php?module=config-languages&action=edit&lang={$key}"); foreach($langselectlangs as $key1 => $langname1) {
|
$popup->add_item($langname1, "index.php?module=config-languages&action=edit&lang={$key}&editwith={$key1}"); }
| if($key != $key1) { $popup->add_item($langname1, "index.php?module=config-languages&action=edit&lang={$key}&editwith={$key1}"); } }
|
$popup->add_item($lang->edit_properties, "index.php?module=config-languages&action=edit_properties&lang={$key}"); $table->construct_cell($popup->fetch(), array("class" => "align_center")); $table->construct_row(); }
|
$popup->add_item($lang->edit_properties, "index.php?module=config-languages&action=edit_properties&lang={$key}"); $table->construct_cell($popup->fetch(), array("class" => "align_center")); $table->construct_row(); }
|
if($table->num_rows() == 0)
| if($table->num_rows() == 0)
|
{ $table->construct_cell($lang->no_language, array('colspan' => 3)); $table->construct_row();
| { $table->construct_cell($lang->no_language, array('colspan' => 3)); $table->construct_row();
|