From b6c2961568b6e93e21a1740f23e63e8b0bf9912b Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 9 Jun 2024 12:19:47 -0700 Subject: [PATCH 1/4] [ticket/17335] Fix language var issues in the extension manager PHPBB-17335 Signed-off-by: Matt Friedman --- phpBB/adm/style/acp_ext_list.html | 39 ++++++++++++++-------------- phpBB/language/en/acp/extensions.php | 39 +++++++++++++++------------- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/phpBB/adm/style/acp_ext_list.html b/phpBB/adm/style/acp_ext_list.html index bb22ac861c..dd006bc2cc 100644 --- a/phpBB/adm/style/acp_ext_list.html +++ b/phpBB/adm/style/acp_ext_list.html @@ -99,25 +99,26 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +
{L_EXTENSION_INSTALL_HEADLINE}
{L_EXTENSION_INSTALL_EXPLAIN}
{L_EXTENSION_UPDATE_HEADLINE}
{L_EXTENSION_UPDATE_EXPLAIN}
{L_EXTENSION_REMOVE_HEADLINE}
{L_EXTENSION_REMOVE_EXPLAIN}
{L_EXTENSION_INSTALLING_HEADLINE}
{L_EXTENSION_INSTALLING_EXPLAIN}
{L_EXTENSION_UPDATING_HEADLINE}
{L_EXTENSION_UPDATING_EXPLAIN}
{L_EXTENSION_REMOVING_HEADLINE}
{L_EXTENSION_REMOVING_EXPLAIN}
diff --git a/phpBB/language/en/acp/extensions.php b/phpBB/language/en/acp/extensions.php index c6eb147b86..3a8322ae0b 100644 --- a/phpBB/language/en/acp/extensions.php +++ b/phpBB/language/en/acp/extensions.php @@ -36,14 +36,15 @@ if (empty($lang) || !is_array($lang)) $lang = array_merge($lang, array( - 'EXTENSION_ALREADY_INSTALLED' => 'The “%s” extension has already been installed.', - 'EXTENSION_ALREADY_INSTALLED_MANUALLY' => 'The “%s” extension has already been installed manually.', - 'EXTENSION_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.', - 'EXTENSION_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.', - 'EXTENSION_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_ALREADY_INSTALLED' => 'The “%s” extension has already been installed.', + 'EXTENSIONS_ALREADY_INSTALLED_MANUALLY' => 'The “%s” extension has already been installed manually.', + 'EXTENSIONS_ALREADY_MANAGED' => 'The “%s” extension is already managed.', + 'EXTENSIONS_CANNOT_MANAGE_FILESYSTEM_ERROR' => 'The “%s” extension cannot be managed because the existing files could not be removed from the filesystem.', + 'EXTENSIONS_CANNOT_MANAGE_INSTALL_ERROR' => 'The “%s” extension could not be installed. The prior installation of this extension has been restored.', + '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.', + 'EXTENSIONS_MANAGED_WITH_ENABLE_ERROR' => 'The “%s” extension has been installed but an error occurred while enabling it.', + 'EXTENSIONS_NOT_INSTALLED' => 'The “%s” extension is not installed.', + 'EXTENSIONS_NOT_MANAGED' => 'The “%s” extension is not being managed.', 'ENABLING_EXTENSIONS' => 'Enabling extensions', 'DISABLING_EXTENSIONS' => 'Disabling extensions', @@ -74,6 +75,8 @@ $lang = array_merge($lang, array( 'EXTENSION_DELETE_DATA_EXPLAIN' => 'Deleting an extension’s 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_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 extension’s 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.', @@ -86,25 +89,25 @@ $lang = array_merge($lang, array( 'EXTENSION_NAME' => 'Extension Name', 'EXTENSION_ACTIONS' => 'Actions', 'EXTENSION_OPTIONS' => 'Options', - 'EXTENSION_INSTALL_HEADLINE'=> 'Installing an extension', - 'EXTENSION_INSTALL_EXPLAIN' => '
    + 'EXTENSION_INSTALLING_HEADLINE'=> 'Installing an extension', + 'EXTENSION_INSTALLING_EXPLAIN' => '
    1. Download an extension from phpBB’s extensions database
    2. Unzip the extension and upload it to the ext/ directory of your phpBB board
    3. Enable the extension, here in the Extensions manager
    ', - 'EXTENSION_UPDATE_HEADLINE' => 'Updating an extension', - 'EXTENSION_UPDATE_EXPLAIN' => '
      + 'EXTENSION_REMOVING_EXPLAIN' => '
        +
      1. Disable the extension
      2. +
      3. Delete the extension’s data
      4. +
      5. Delete the extension’s files from the filesystem
      6. +
      ', + 'EXTENSION_UPDATING_HEADLINE' => 'Updating an extension', + 'EXTENSION_UPDATING_EXPLAIN' => '
      1. Disable the extension
      2. Delete the extension’s files from the filesystem
      3. Upload the new files
      4. Enable the extension
      ', - 'EXTENSION_REMOVE_HEADLINE' => 'Completely removing an extension from your board', - 'EXTENSION_REMOVE_EXPLAIN' => '
        -
      1. Disable the extension
      2. -
      3. Delete the extension’s data
      4. -
      5. Delete the extension’s files from the filesystem
      6. -
      ', + 'EXTENSION_REMOVING_HEADLINE' => 'Deleting an extension from your board', 'EXTENSION_DELETE_DATA_CONFIRM' => 'Are you sure that you wish to delete the data associated with “%s”?

      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?', From 173e1ceeba784b8171102324a8625317225597f2 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 10 Jun 2024 20:46:58 -0700 Subject: [PATCH 2/4] [ticket/17335] Move HTML from lang to template PHPBB-17335 Signed-off-by: Matt Friedman --- phpBB/adm/style/acp_ext_list.html | 25 ++++++++++++++++--- phpBB/language/en/acp/extensions.php | 36 ++++++++++++++-------------- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/phpBB/adm/style/acp_ext_list.html b/phpBB/adm/style/acp_ext_list.html index dd006bc2cc..b8b3d2c68a 100644 --- a/phpBB/adm/style/acp_ext_list.html +++ b/phpBB/adm/style/acp_ext_list.html @@ -104,19 +104,38 @@ {L_EXTENSION_INSTALLING_HEADLINE} - {L_EXTENSION_INSTALLING_EXPLAIN} + +
        +
      1. {{ lang(['EXTENSION_INSTALLING_EXPLAIN', 'step_1']) }}
      2. +
      3. {{ lang(['EXTENSION_INSTALLING_EXPLAIN', 'step_2']) }}
      4. +
      5. {{ lang(['EXTENSION_INSTALLING_EXPLAIN', 'step_3']) }}
      6. +
      + {L_EXTENSION_UPDATING_HEADLINE} - {L_EXTENSION_UPDATING_EXPLAIN} + +
        +
      1. {{ lang(['EXTENSION_UPDATING_EXPLAIN', 'step_1']) }}
      2. +
      3. {{ lang(['EXTENSION_UPDATING_EXPLAIN', 'step_2']) }}
      4. +
      5. {{ lang(['EXTENSION_UPDATING_EXPLAIN', 'step_3']) }}
      6. +
      7. {{ lang(['EXTENSION_UPDATING_EXPLAIN', 'step_4']) }}
      8. +
      + {L_EXTENSION_REMOVING_HEADLINE} - {L_EXTENSION_REMOVING_EXPLAIN} + +
        +
      1. {{ lang(['EXTENSION_REMOVING_EXPLAIN', 'step_1']) }}
      2. +
      3. {{ lang(['EXTENSION_REMOVING_EXPLAIN', 'step_2']) }}
      4. +
      5. {{ lang(['EXTENSION_REMOVING_EXPLAIN', 'step_3']) }}
      6. +
      + diff --git a/phpBB/language/en/acp/extensions.php b/phpBB/language/en/acp/extensions.php index 3a8322ae0b..311cfa74f3 100644 --- a/phpBB/language/en/acp/extensions.php +++ b/phpBB/language/en/acp/extensions.php @@ -89,25 +89,25 @@ $lang = array_merge($lang, array( 'EXTENSION_NAME' => 'Extension Name', 'EXTENSION_ACTIONS' => 'Actions', 'EXTENSION_OPTIONS' => 'Options', - 'EXTENSION_INSTALLING_HEADLINE'=> 'Installing an extension', - 'EXTENSION_INSTALLING_EXPLAIN' => '
        -
      1. Download an extension from phpBB’s extensions database
      2. -
      3. Unzip the extension and upload it to the ext/ directory of your phpBB board
      4. -
      5. Enable the extension, here in the Extensions manager
      6. -
      ', - 'EXTENSION_REMOVING_EXPLAIN' => '
        -
      1. Disable the extension
      2. -
      3. Delete the extension’s data
      4. -
      5. Delete the extension’s files from the filesystem
      6. -
      ', - 'EXTENSION_UPDATING_HEADLINE' => 'Updating an extension', - 'EXTENSION_UPDATING_EXPLAIN' => '
        -
      1. Disable the extension
      2. -
      3. Delete the extension’s files from the filesystem
      4. -
      5. Upload the new files
      6. -
      7. Enable the extension
      8. -
      ', + 'EXTENSION_INSTALLING_HEADLINE' => 'Installing an extension', + 'EXTENSION_INSTALLING_EXPLAIN' => [ + 'step_1' => 'Download an extension from phpBB’s extensions database', + 'step_2' => 'Unzip the extension and upload it to the ext/ directory of your phpBB board', + 'step_3' => 'Enable the extension, here in the Extensions manager', + ], 'EXTENSION_REMOVING_HEADLINE' => 'Deleting an extension from your board', + 'EXTENSION_REMOVING_EXPLAIN' => [ + 'step_1' => 'Disable the extension', + 'step_2' => 'Delete the extension’s data', + 'step_3' => 'Delete the extension‘s files from the filesystem', + ], + 'EXTENSION_UPDATING_HEADLINE' => 'Updating an extension', + 'EXTENSION_UPDATING_EXPLAIN' => [ + 'step_1' => 'Disable the extension', + 'step_2' => 'Delete the extension’s files from the filesystem', + 'step_3' => 'Upload the new files', + 'step_4' => 'Enable the extension', + ], 'EXTENSION_DELETE_DATA_CONFIRM' => 'Are you sure that you wish to delete the data associated with “%s”?

      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?', From 48cc96b489366641a818888ad45578c2a2948398 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 14 Jun 2024 23:10:09 +0200 Subject: [PATCH 3/4] [ticket/17335] Add lang_raw twig function for templates PHPBB-17335 --- phpBB/phpbb/template/twig/extension.php | 13 +++++++++++++ tests/template/template_test.php | 6 +++--- tests/template/templates/lang_twig.html | 4 ++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php index 2e920dbe4b..7fde9e2cac 100644 --- a/phpBB/phpbb/template/twig/extension.php +++ b/phpBB/phpbb/template/twig/extension.php @@ -93,6 +93,7 @@ class extension extends \Twig\Extension\AbstractExtension new \Twig\TwigFunction('lang', array($this, 'lang')), new \Twig\TwigFunction('lang_defined', array($this, 'lang_defined')), new \Twig\TwigFunction('lang_js', [$this, 'lang_js']), + new \Twig\TwigFunction('lang_raw', [$this, 'lang_raw']), 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'); } + + /** + * 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]); + } } diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 8faa52d8ac..4fc9858366 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -365,15 +365,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), array(), array(), - "VARIABLE\n1_VARIABLE\nVARIABLE\n1_VARIABLE", + "VARIABLE\n1_VARIABLE\nVARIABLE\n1_VARIABLE\nVARIABLE\n1_VARIABLE\nARY_VARIABLE", ), array( 'lang_twig.html', array(), array(), array(), - "Value'\n1 O'Clock\nValue\\u0027\n1\\u0020O\\u0027Clock", - array('VARIABLE' => "Value'", '1_VARIABLE' => "1 O'Clock"), + "Value'\n1 O'Clock\nValue\\u0027\n1\\u0020O\\u0027Clock\nValue'\n1 O'Clock\nfoo|bar", + array('VARIABLE' => "Value'", '1_VARIABLE' => "1 O'Clock", 'ARY_VARIABLE' => ['foo', 'bar']), ), array( 'loop_nested_multilevel_ref.html', diff --git a/tests/template/templates/lang_twig.html b/tests/template/templates/lang_twig.html index bf31012819..a331c7f506 100644 --- a/tests/template/templates/lang_twig.html +++ b/tests/template/templates/lang_twig.html @@ -3,3 +3,7 @@ {{ lang_js('VARIABLE') }} {{ lang_js('1_VARIABLE') }} + +{{ lang_raw('VARIABLE') }} +{{ lang_raw('1_VARIABLE') }} +{{ lang_raw('ARY_VARIABLE')|join('|') }} From 444137531ff0d6650170e4cd76e82049c8656f8c Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 14 Jun 2024 14:43:40 -0700 Subject: [PATCH 4/4] [ticket/17335] Use lang_raw PHPBB-17335 Signed-off-by: Matt Friedman --- phpBB/adm/style/acp_ext_list.html | 19 +++++++++---------- phpBB/language/en/acp/extensions.php | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/phpBB/adm/style/acp_ext_list.html b/phpBB/adm/style/acp_ext_list.html index b8b3d2c68a..dc6dcf1797 100644 --- a/phpBB/adm/style/acp_ext_list.html +++ b/phpBB/adm/style/acp_ext_list.html @@ -106,9 +106,9 @@
        -
      1. {{ lang(['EXTENSION_INSTALLING_EXPLAIN', 'step_1']) }}
      2. -
      3. {{ lang(['EXTENSION_INSTALLING_EXPLAIN', 'step_2']) }}
      4. -
      5. {{ lang(['EXTENSION_INSTALLING_EXPLAIN', 'step_3']) }}
      6. + {% for step in lang_raw('EXTENSION_INSTALLING_EXPLAIN') %} +
      7. {{ step }}
      8. + {% endfor %}
      @@ -118,10 +118,9 @@
        -
      1. {{ lang(['EXTENSION_UPDATING_EXPLAIN', 'step_1']) }}
      2. -
      3. {{ lang(['EXTENSION_UPDATING_EXPLAIN', 'step_2']) }}
      4. -
      5. {{ lang(['EXTENSION_UPDATING_EXPLAIN', 'step_3']) }}
      6. -
      7. {{ lang(['EXTENSION_UPDATING_EXPLAIN', 'step_4']) }}
      8. + {% for step in lang_raw('EXTENSION_UPDATING_EXPLAIN') %} +
      9. {{ step }}
      10. + {% endfor %}
      @@ -131,9 +130,9 @@
        -
      1. {{ lang(['EXTENSION_REMOVING_EXPLAIN', 'step_1']) }}
      2. -
      3. {{ lang(['EXTENSION_REMOVING_EXPLAIN', 'step_2']) }}
      4. -
      5. {{ lang(['EXTENSION_REMOVING_EXPLAIN', 'step_3']) }}
      6. + {% for step in lang_raw('EXTENSION_REMOVING_EXPLAIN') %} +
      7. {{ step }}
      8. + {% endfor %}
      diff --git a/phpBB/language/en/acp/extensions.php b/phpBB/language/en/acp/extensions.php index 311cfa74f3..bf854cdb7b 100644 --- a/phpBB/language/en/acp/extensions.php +++ b/phpBB/language/en/acp/extensions.php @@ -91,22 +91,22 @@ $lang = array_merge($lang, array( 'EXTENSION_OPTIONS' => 'Options', 'EXTENSION_INSTALLING_HEADLINE' => 'Installing an extension', 'EXTENSION_INSTALLING_EXPLAIN' => [ - 'step_1' => 'Download an extension from phpBB’s extensions database', - 'step_2' => 'Unzip the extension and upload it to the ext/ directory of your phpBB board', - 'step_3' => 'Enable the extension, here in the Extensions manager', + 0 => 'Download an extension from phpBB’s extensions database', + 1 => 'Unzip the extension and upload it to the ext/ directory of your phpBB board', + 2 => 'Enable the extension, here in the Extensions manager', ], 'EXTENSION_REMOVING_HEADLINE' => 'Deleting an extension from your board', 'EXTENSION_REMOVING_EXPLAIN' => [ - 'step_1' => 'Disable the extension', - 'step_2' => 'Delete the extension’s data', - 'step_3' => 'Delete the extension‘s files from the filesystem', + 0 => 'Disable the extension', + 1 => 'Delete the extension’s data', + 2 => 'Delete the extension‘s files from the filesystem', ], 'EXTENSION_UPDATING_HEADLINE' => 'Updating an extension', 'EXTENSION_UPDATING_EXPLAIN' => [ - 'step_1' => 'Disable the extension', - 'step_2' => 'Delete the extension’s files from the filesystem', - 'step_3' => 'Upload the new files', - 'step_4' => 'Enable the extension', + 0 => 'Disable the extension', + 1 => 'Delete the extension’s files from the filesystem', + 2 => 'Upload the new files', + 3 => 'Enable the extension', ], 'EXTENSION_DELETE_DATA_CONFIRM' => 'Are you sure that you wish to delete the data associated with “%s”?

      This removes all of its data and settings and cannot be undone!',