From 617a18140aac6c255c3e3b81c689d1be0f64a238 Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Thu, 22 Aug 2019 17:42:41 +0800 Subject: [PATCH] Add missing i18n message and unify error display Add the missing message about requiring the imageRotate plugin, and merge the two places in which this error message is added. --- language/en_UK/plugin.lang.php | 3 ++- maintain.class.php | 42 ++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/language/en_UK/plugin.lang.php b/language/en_UK/plugin.lang.php index 76e25c0..e64ea39 100644 --- a/language/en_UK/plugin.lang.php +++ b/language/en_UK/plugin.lang.php @@ -4,4 +4,5 @@ $lang['Rotate clockwise'] = 'Rotate clockwise'; $lang['Rotate counterclockwise'] = 'Rotate counterclockwise'; $lang['Rotate HD Images'] = 'Rotate HD Images'; -?> \ No newline at end of file +$lang['To install this plugin, you need to install the rotateImage plugin first.'] = 'To install this plugin, you need to install the rotateImage plugin first.'; +?> diff --git a/maintain.class.php b/maintain.class.php index 30f09a6..e0d75bd 100644 --- a/maintain.class.php +++ b/maintain.class.php @@ -25,6 +25,25 @@ function __construct($plugin_id) $this->rotateImage_installed = file_exists(PHPWG_PLUGINS_PATH . 'rotateImage/main.inc.php')?true:false; } + /** + * Add an error message about the imageRotate plugin not being installed. + * + * @param string[] $errors The error array to add to. + */ + protected function addRotateImageError(&$errors) + { + load_language('plugin.lang', __DIR__ . '/'); + $msg = sprintf(l10n('To install this plugin, you need to install the rotateImage plugin first.')); + if(is_array($errors)) + { + array_push($errors, $msg); + } + else + { + $errors = array($msg); + } + } + /** * Plugin installation * @@ -37,16 +56,7 @@ function install($plugin_version, &$errors=array()) if (!$this->rotateImage_installed) { - $msg = sprintf(l10n('To install this plugin, you need to install the rotateImage plugin first.')); - if(is_array($errors)) - { - array_push($errors, $msg); - } - else - { - $errors = Array($msg); - } - $result = false; + $this->addRotateImageError($errors); } else { @@ -90,15 +100,7 @@ function activate($plugin_version, &$errors=array()) if (!$this->rotateImage_installed || !$rotateImage_active) { - $msg = sprintf(l10n('To install this plugin, you need to install and activate the rotateImage plugin first.')); - if(is_array($errors)) - { - array_push($errors, $msg); - } - else - { - $errors = Array($msg); - } + $this->addRotateImageError($errors); } } @@ -143,4 +145,4 @@ function uninstall() } rmdir($this->dir); } -} \ No newline at end of file +}