mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/12527] Restore missing files and variables check
PHPBB3-12527
This commit is contained in:
parent
c334d8431d
commit
63e195d7f0
3 changed files with 110 additions and 36 deletions
|
@ -36,46 +36,32 @@
|
|||
</fieldset>
|
||||
</form>
|
||||
|
||||
<br /><br />
|
||||
<!-- IF .missing_files -->
|
||||
<h3 class="error">{L_MISSING_FILES}</h3>
|
||||
|
||||
<!-- IF S_MISSING_FILES -->
|
||||
<div class="errorbox">
|
||||
<h3>{L_MISSING_FILES}</h3>
|
||||
<p>{MISSING_FILES}</p>
|
||||
</div>
|
||||
<br /><br />
|
||||
<fieldset>
|
||||
<legend>{L_MISSING_LANG_FILES}</legend>
|
||||
<!-- BEGIN missing_files -->
|
||||
» {missing_files.FILE_NAME}<br />
|
||||
<!-- END missing_files -->
|
||||
</fieldset>
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF S_MISSING_VARS -->
|
||||
<h1>{L_MISSING_LANG_VARIABLES}</h1>
|
||||
<!-- IF .missing_varfile -->
|
||||
<h3 class="error">{L_MISSING_VARS_EXPLAIN}</h3>
|
||||
|
||||
<p>{L_MISSING_VARS_EXPLAIN}</p>
|
||||
|
||||
<form id="missing" method="post" action="{U_MISSING_ACTION}">
|
||||
|
||||
<table class="table1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{L_LANGUAGE_KEY}</th>
|
||||
<th>{L_LANGUAGE_VARIABLE}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- BEGIN missing -->
|
||||
<tr class="row4">
|
||||
<td><strong>{missing.FILE}</strong></td>
|
||||
<td style="text-align: right;"><input type="submit" name="missing_file[{missing.KEY}]" value="{L_SELECT}" class="button2" /></td>
|
||||
</tr>
|
||||
{missing.TPL}
|
||||
<!-- END missing -->
|
||||
</tbody>
|
||||
</table>
|
||||
<div>{S_FORM_TOKEN}</div>
|
||||
</form>
|
||||
|
||||
<br /><br />
|
||||
<fieldset>
|
||||
<legend>{L_MISSING_LANG_VARIABLES}</legend>
|
||||
<!-- BEGIN missing_varfile -->
|
||||
<dl>
|
||||
<dt><label>{missing_varfile.FILE_NAME}</label></dt>
|
||||
<!-- BEGIN variable -->
|
||||
<dd>{missing_varfile.variable.VAR_NAME}</dd>
|
||||
<!-- END variable -->
|
||||
</dl>
|
||||
<!-- END missing_varfile -->
|
||||
</fieldset>
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- ELSE -->
|
||||
|
||||
<h1>{L_ACP_LANGUAGE_PACKS}</h1>
|
||||
|
|
|
@ -110,6 +110,8 @@ class acp_language
|
|||
$lang_entries = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$lang_iso = $lang_entries['lang_iso'];
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_DETAILS' => true,
|
||||
'U_ACTION' => $this->u_action . "&action=details&id=$lang_id",
|
||||
|
@ -117,10 +119,67 @@ class acp_language
|
|||
|
||||
'LANG_LOCAL_NAME' => $lang_entries['lang_local_name'],
|
||||
'LANG_ENGLISH_NAME' => $lang_entries['lang_english_name'],
|
||||
'LANG_ISO' => $lang_entries['lang_iso'],
|
||||
'LANG_ISO' => $lang_iso,
|
||||
'LANG_AUTHOR' => $lang_entries['lang_author'],
|
||||
'L_MISSING_FILES' => $user->lang('THOSE_MISSING_LANG_FILES', $lang_entries['lang_local_name']),
|
||||
'L_MISSING_VARS_EXPLAIN' => $user->lang('THOSE_MISSING_LANG_VARIABLES', $lang_entries['lang_local_name']),
|
||||
));
|
||||
|
||||
// If current lang is different from the default lang, then highlight missing files and variables
|
||||
if ($lang_iso != $config['default_lang'])
|
||||
{
|
||||
try
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \phpbb\recursive_dot_prefix_filter_iterator(
|
||||
new \RecursiveDirectoryIterator(
|
||||
$phpbb_root_path . 'language/' . $config['default_lang'] . '/',
|
||||
\FilesystemIterator::SKIP_DOTS
|
||||
)
|
||||
),
|
||||
\RecursiveIteratorIterator::LEAVES_ONLY
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
foreach ($iterator as $file_info)
|
||||
{
|
||||
/** @var \RecursiveDirectoryIterator $file_info */
|
||||
$relative_path = $iterator->getInnerIterator()->getSubPathname();
|
||||
$relative_path = str_replace(DIRECTORY_SEPARATOR, '/', $relative_path);
|
||||
|
||||
if (file_exists($phpbb_root_path . 'language/' . $lang_iso . '/' . $relative_path))
|
||||
{
|
||||
if (substr($relative_path, 0 - strlen($phpEx)) === $phpEx)
|
||||
{
|
||||
$missing_vars = $this->compare_language_files($config['default_lang'], $lang_iso, $relative_path);
|
||||
|
||||
if (!empty($missing_vars))
|
||||
{
|
||||
$template->assign_block_vars('missing_varfile', array(
|
||||
'FILE_NAME' => $relative_path,
|
||||
));
|
||||
|
||||
foreach ($missing_vars as $var)
|
||||
{
|
||||
$template->assign_block_vars('missing_varfile.variable', array(
|
||||
'VAR_NAME' => $var,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$template->assign_block_vars('missing_files', array(
|
||||
'FILE_NAME' => $relative_path,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
break;
|
||||
|
||||
|
@ -362,4 +421,32 @@ class acp_language
|
|||
|
||||
unset($new_ary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two language files
|
||||
*/
|
||||
function compare_language_files($source_lang, $dest_lang, $file)
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
$source_file = $phpbb_root_path . 'language/' . $source_lang . '/' . $file;
|
||||
$dest_file = $phpbb_root_path . 'language/' . $dest_lang . '/' . $file;
|
||||
|
||||
if (!file_exists($dest_file))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$lang = array();
|
||||
include($source_file);
|
||||
$lang_entry_src = $lang;
|
||||
|
||||
$lang = array();
|
||||
include($dest_file);
|
||||
$lang_entry_dst = $lang;
|
||||
|
||||
unset($lang);
|
||||
|
||||
return array_diff(array_keys($lang_entry_src), array_keys($lang_entry_dst));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ $lang = array_merge($lang, array(
|
|||
'LANG_LOCAL_NAME' => 'Local name',
|
||||
|
||||
'MISSING_LANGUAGE_FILE' => 'Missing language file: <strong style="color:red">%s</strong>',
|
||||
'MISSING_LANG_FILES' => 'Missing language files',
|
||||
'MISSING_LANG_VARIABLES' => 'Missing language variables',
|
||||
'MODS_FILES' => 'MODs language files',
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue