Merge pull request #6635 from iMattPro/ticket/17335

[ticket/17335] Fix language var issues in the extension manager
This commit is contained in:
Marc Alexander 2024-06-23 21:59:26 +02:00 committed by GitHub
commit c28b944d93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 88 additions and 49 deletions

View file

@ -99,23 +99,42 @@
</table> </table>
<table class="table1"> <table class="table1">
<tbody>
<tr> <tr>
<th>{L_EXTENSION_INSTALL_HEADLINE}</th> <th>{L_EXTENSION_INSTALLING_HEADLINE}</th>
</tr> </tr>
<tr> <tr>
<td class="row3">{L_EXTENSION_INSTALL_EXPLAIN}</td> <td class="row3">
<ol>
{% for step in lang_raw('EXTENSION_INSTALLING_EXPLAIN') %}
<li>{{ step }}</li>
{% endfor %}
</ol>
</td>
</tr> </tr>
<tr> <tr>
<th>{L_EXTENSION_UPDATE_HEADLINE}</th> <th>{L_EXTENSION_UPDATING_HEADLINE}</th>
</tr> </tr>
<tr> <tr>
<td class="row3">{L_EXTENSION_UPDATE_EXPLAIN}</td> <td class="row3">
<ol>
{% for step in lang_raw('EXTENSION_UPDATING_EXPLAIN') %}
<li>{{ step }}</li>
{% endfor %}
</ol>
</td>
</tr> </tr>
<tr> <tr>
<th>{L_EXTENSION_REMOVE_HEADLINE}</th> <th>{L_EXTENSION_REMOVING_HEADLINE}</th>
</tr> </tr>
<tr> <tr>
<td class="row3">{L_EXTENSION_REMOVE_EXPLAIN}</td> <td class="row3">
<ol>
{% for step in lang_raw('EXTENSION_REMOVING_EXPLAIN') %}
<li>{{ step }}</li>
{% endfor %}
</ol>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View file

@ -36,14 +36,15 @@ if (empty($lang) || !is_array($lang))
$lang = array_merge($lang, array( $lang = array_merge($lang, array(
'EXTENSION_ALREADY_INSTALLED' => 'The “%s” extension has already been installed.', 'EXTENSIONS_ALREADY_INSTALLED' => 'The “%s” extension has already been installed.',
'EXTENSION_ALREADY_INSTALLED_MANUALLY' => 'The “%s” extension has already been installed manually.', 'EXTENSIONS_ALREADY_INSTALLED_MANUALLY' => 'The “%s” extension has already been installed manually.',
'EXTENSION_ALREADY_MANAGED' => 'The “%s” extension is already managed.', 'EXTENSIONS_ALREADY_MANAGED' => 'The “%s” extension is already managed.',
'EXTENSION_CANNOT_MANAGE_FILESYSTEM_ERROR' => 'The “%s” extension cannot be managed because the existing files could not be removed from the filesystem.', 'EXTENSIONS_CANNOT_MANAGE_FILESYSTEM_ERROR' => 'The “%s” extension cannot be managed because the existing files could not be removed from the filesystem.',
'EXTENSION_CANNOT_MANAGE_INSTALL_ERROR' => 'The “%s” extension could not be installed. The prior installation of this extension has been restored.', 'EXTENSIONS_CANNOT_MANAGE_INSTALL_ERROR' => 'The “%s” extension could not be installed. The prior installation of this extension has been restored.',
'EXTENSION_MANAGED_WITH_CLEAN_ERROR' => 'The “%1$s” extension has been installed but an error occurred and the old files could not be removed. You might want to delete the “%2$s” files manually.', 'EXTENSIONS_MANAGED_WITH_CLEAN_ERROR' => 'The “%1$s” extension has been installed but an error occurred and the old files could not be removed. You might want to delete the “%2$s” files manually.',
'EXTENSION_MANAGED_WITH_ENABLE_ERROR' => 'The “%s” extension has been installed but an error occurred while enabling it.', 'EXTENSIONS_MANAGED_WITH_ENABLE_ERROR' => 'The “%s” extension has been installed but an error occurred while enabling it.',
'EXTENSION_NOT_INSTALLED' => 'The “%s” extension is not installed.', 'EXTENSIONS_NOT_INSTALLED' => 'The “%s” extension is not installed.',
'EXTENSIONS_NOT_MANAGED' => 'The “%s” extension is not being managed.',
'ENABLING_EXTENSIONS' => 'Enabling extensions', 'ENABLING_EXTENSIONS' => 'Enabling extensions',
'DISABLING_EXTENSIONS' => 'Disabling extensions', 'DISABLING_EXTENSIONS' => 'Disabling extensions',
@ -74,6 +75,8 @@ $lang = array_merge($lang, array(
'EXTENSION_DELETE_DATA_EXPLAIN' => 'Deleting an extensions data removes all of its data and settings. The extension files are retained so it can be enabled again.', 'EXTENSION_DELETE_DATA_EXPLAIN' => 'Deleting an extensions data removes all of its data and settings. The extension files are retained so it can be enabled again.',
'EXTENSION_DISABLE_EXPLAIN' => 'Disabling an extension retains its files, data and settings but removes any functionality added by the extension.', 'EXTENSION_DISABLE_EXPLAIN' => 'Disabling an extension retains its files, data and settings but removes any functionality added by the extension.',
'EXTENSION_ENABLE_EXPLAIN' => 'Enabling an extension allows you to use it on your board.', 'EXTENSION_ENABLE_EXPLAIN' => 'Enabling an extension allows you to use it on your board.',
'EXTENSION_REMOVE_EXPLAIN' => 'Removing an extension removes all of its files, data and settings.',
'EXTENSION_UPDATE_EXPLAIN' => 'Updating an extension will install the latest version compatible with your board, removing old files and replacing them with new ones, and updating the database if necessary.',
'EXTENSION_DELETE_DATA_IN_PROGRESS' => 'The extensions data is currently being deleted. Please do not leave or refresh this page until it is completed.', 'EXTENSION_DELETE_DATA_IN_PROGRESS' => 'The extensions data is currently being deleted. Please do not leave or refresh this page until it is completed.',
'EXTENSION_DISABLE_IN_PROGRESS' => 'The extension is currently being disabled. Please do not leave or refresh this page until it is completed.', 'EXTENSION_DISABLE_IN_PROGRESS' => 'The extension is currently being disabled. Please do not leave or refresh this page until it is completed.',
@ -86,25 +89,25 @@ $lang = array_merge($lang, array(
'EXTENSION_NAME' => 'Extension Name', 'EXTENSION_NAME' => 'Extension Name',
'EXTENSION_ACTIONS' => 'Actions', 'EXTENSION_ACTIONS' => 'Actions',
'EXTENSION_OPTIONS' => 'Options', 'EXTENSION_OPTIONS' => 'Options',
'EXTENSION_INSTALL_HEADLINE'=> 'Installing an extension', 'EXTENSION_INSTALLING_HEADLINE' => 'Installing an extension',
'EXTENSION_INSTALL_EXPLAIN' => '<ol> 'EXTENSION_INSTALLING_EXPLAIN' => [
<li>Download an extension from phpBBs extensions database</li> 0 => 'Download an extension from phpBBs extensions database',
<li>Unzip the extension and upload it to the <samp>ext/</samp> directory of your phpBB board</li> 1 => 'Unzip the extension and upload it to the <samp>ext/</samp> directory of your phpBB board',
<li>Enable the extension, here in the Extensions manager</li> 2 => 'Enable the extension, here in the Extensions manager',
</ol>', ],
'EXTENSION_UPDATE_HEADLINE' => 'Updating an extension', 'EXTENSION_REMOVING_HEADLINE' => 'Deleting an extension from your board',
'EXTENSION_UPDATE_EXPLAIN' => '<ol> 'EXTENSION_REMOVING_EXPLAIN' => [
<li>Disable the extension</li> 0 => 'Disable the extension',
<li>Delete the extensions files from the filesystem</li> 1 => 'Delete the extensions data',
<li>Upload the new files</li> 2 => 'Delete the extensions files from the filesystem',
<li>Enable the extension</li> ],
</ol>', 'EXTENSION_UPDATING_HEADLINE' => 'Updating an extension',
'EXTENSION_REMOVE_HEADLINE' => 'Completely removing an extension from your board', 'EXTENSION_UPDATING_EXPLAIN' => [
'EXTENSION_REMOVE_EXPLAIN' => '<ol> 0 => 'Disable the extension',
<li>Disable the extension</li> 1 => 'Delete the extensions files from the filesystem',
<li>Delete the extensions data</li> 2 => 'Upload the new files',
<li>Delete the extensions files from the filesystem</li> 3 => 'Enable the extension',
</ol>', ],
'EXTENSION_DELETE_DATA_CONFIRM' => 'Are you sure that you wish to delete the data associated with “%s”?<br /><br />This removes all of its data and settings and cannot be undone!', 'EXTENSION_DELETE_DATA_CONFIRM' => 'Are you sure that you wish to delete the data associated with “%s”?<br /><br />This removes all of its data and settings and cannot be undone!',
'EXTENSION_DISABLE_CONFIRM' => 'Are you sure that you wish to disable the “%s” extension?', 'EXTENSION_DISABLE_CONFIRM' => 'Are you sure that you wish to disable the “%s” extension?',

View file

@ -93,6 +93,7 @@ class extension extends \Twig\Extension\AbstractExtension
new \Twig\TwigFunction('lang', array($this, 'lang')), new \Twig\TwigFunction('lang', array($this, 'lang')),
new \Twig\TwigFunction('lang_defined', array($this, 'lang_defined')), new \Twig\TwigFunction('lang_defined', array($this, 'lang_defined')),
new \Twig\TwigFunction('lang_js', [$this, 'lang_js']), new \Twig\TwigFunction('lang_js', [$this, 'lang_js']),
new \Twig\TwigFunction('lang_raw', [$this, 'lang_raw']),
new \Twig\TwigFunction('get_class', 'get_class'), new \Twig\TwigFunction('get_class', 'get_class'),
); );
} }
@ -214,4 +215,16 @@ class extension extends \Twig\Extension\AbstractExtension
return twig_escape_filter($this->environment, call_user_func_array([$this, 'lang'], $args), 'js'); return twig_escape_filter($this->environment, call_user_func_array([$this, 'lang'], $args), 'js');
} }
/**
* Get raw value associated with lang key
*
* @param string $key
*
* @return array|string Raw value associated with lang key
*/
public function lang_raw(string $key): array|string
{
return call_user_func_array(array($this->language, 'lang_raw'), [$key]);
}
} }

View file

@ -365,15 +365,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(), array(),
array(), array(),
array(), array(),
"VARIABLE\n1_VARIABLE\nVARIABLE\n1_VARIABLE", "VARIABLE\n1_VARIABLE\nVARIABLE\n1_VARIABLE\nVARIABLE\n1_VARIABLE\nARY_VARIABLE",
), ),
array( array(
'lang_twig.html', 'lang_twig.html',
array(), array(),
array(), array(),
array(), array(),
"Value'\n1 O'Clock\nValue\\u0027\n1\\u0020O\\u0027Clock", "Value'\n1 O'Clock\nValue\\u0027\n1\\u0020O\\u0027Clock\nValue'\n1 O'Clock\nfoo|bar",
array('VARIABLE' => "Value'", '1_VARIABLE' => "1 O'Clock"), array('VARIABLE' => "Value'", '1_VARIABLE' => "1 O'Clock", 'ARY_VARIABLE' => ['foo', 'bar']),
), ),
array( array(
'loop_nested_multilevel_ref.html', 'loop_nested_multilevel_ref.html',

View file

@ -3,3 +3,7 @@
{{ lang_js('VARIABLE') }} {{ lang_js('VARIABLE') }}
{{ lang_js('1_VARIABLE') }} {{ lang_js('1_VARIABLE') }}
{{ lang_raw('VARIABLE') }}
{{ lang_raw('1_VARIABLE') }}
{{ lang_raw('ARY_VARIABLE')|join('|') }}