From 14a6cba5804de469a05c8b094ff3465a0acb9bea Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Wed, 17 May 2017 15:02:17 +0100 Subject: [PATCH 01/30] Add new parameter to XML files changelogurl --- .../components/com_admin/sql/updates/mysql/4.0.0-2017-05-17.sql | 1 + .../com_admin/sql/updates/postgresql/4.0.0-2017-05-17.sql | 1 + installation/sql/mysql/joomla.sql | 1 + installation/sql/postgresql/joomla.sql | 1 + libraries/joomla/updater/updateadapter.php | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-05-17.sql create mode 100644 administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-05-17.sql diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-05-17.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-05-17.sql new file mode 100644 index 0000000000000..bf20296420cc2 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-05-17.sql @@ -0,0 +1 @@ +ALTER TABLE `#__updates` ADD COLUMN `changelogurl` text AFTER `infourl`; diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-05-17.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-05-17.sql new file mode 100644 index 0000000000000..5e5d0f78ca3ae --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-05-17.sql @@ -0,0 +1 @@ +ALTER TABLE "#__updates" ADD COLUMN "changelogurl" text AFTER `infourl`; diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index 12b3bfc4b8dfb..bb0ca7b022157 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -1877,6 +1877,7 @@ CREATE TABLE IF NOT EXISTS `#__updates` ( `data` text NOT NULL, `detailsurl` text NOT NULL, `infourl` text NOT NULL, + `changelogurl` text, `extra_query` varchar(1000) DEFAULT '', PRIMARY KEY (`update_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci COMMENT='Available Updates'; diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index b1feaa7b5f3d0..bef813ecc2e75 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -1854,6 +1854,7 @@ CREATE TABLE IF NOT EXISTS "#__updates" ( "data" text NOT NULL, "detailsurl" text NOT NULL, "infourl" text NOT NULL, + "changelogurl" text, "extra_query" varchar(1000) DEFAULT '', PRIMARY KEY ("update_id") ); diff --git a/libraries/joomla/updater/updateadapter.php b/libraries/joomla/updater/updateadapter.php index 350ca4246c8b4..80199df3c19f8 100644 --- a/libraries/joomla/updater/updateadapter.php +++ b/libraries/joomla/updater/updateadapter.php @@ -48,7 +48,7 @@ abstract class JUpdateAdapter extends JAdapterInstance * @var array * @since 12.1 */ - protected $updatecols = array('NAME', 'ELEMENT', 'TYPE', 'FOLDER', 'CLIENT', 'VERSION', 'DESCRIPTION', 'INFOURL', 'EXTRA_QUERY'); + protected $updatecols = array('NAME', 'ELEMENT', 'TYPE', 'FOLDER', 'CLIENT', 'VERSION', 'DESCRIPTION', 'INFOURL', 'CHANGELOGURL', 'EXTRA_QUERY'); /** * Should we try appending a .xml extension to the update site's URL? From 4a5a587246674baecd6193f283f1d15c4f9804a5 Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Wed, 17 May 2017 19:49:22 +0100 Subject: [PATCH 02/30] Modal on Update view using the changelogurl --- .../com_installer/views/update/tmpl/default.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/administrator/components/com_installer/views/update/tmpl/default.php b/administrator/components/com_installer/views/update/tmpl/default.php index bd8e1dbc16a1c..47b1ec08a5caf 100644 --- a/administrator/components/com_installer/views/update/tmpl/default.php +++ b/administrator/components/com_installer/views/update/tmpl/default.php @@ -105,6 +105,15 @@ version; ?> + version . " - " . $item->name; + $modal_params['height'] = '500px'; + $body = ''; + ?> + version; ?> + + folder_translated; ?> From 9a05ceec0e72d9846a9e24a78ae913b20ca49b3c Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Wed, 17 May 2017 19:58:35 +0100 Subject: [PATCH 03/30] CodeStyle --- .../views/update/tmpl/default.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/administrator/components/com_installer/views/update/tmpl/default.php b/administrator/components/com_installer/views/update/tmpl/default.php index 47b1ec08a5caf..905105d85a0ea 100644 --- a/administrator/components/com_installer/views/update/tmpl/default.php +++ b/administrator/components/com_installer/views/update/tmpl/default.php @@ -78,11 +78,9 @@ items as $i => $item) : ?> - client_id ? JText::_('JADMINISTRATOR') : JText::_('JSITE'); - $manifest = json_decode($item->manifest_cache); - $current_version = isset($manifest->version) ? $manifest->version : JText::_('JLIB_UNKNOWN'); - ?> + client_id ? JText::_('JADMINISTRATOR') : JText::_('JSITE'); ?> + manifest_cache); ?> + version) ? $manifest->version : JText::_('JLIB_UNKNOWN'); ?> update_id); ?> @@ -105,12 +103,11 @@ version; ?> - version . " - " . $item->name; - $modal_params['height'] = '500px'; - $body = ''; - ?> + + version . " - " . $item->name; ?> + + changelogurl . '">'; ?> + version; ?> From 8f7c94d96ad84dcce8790062ae16acbea2814753 Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Tue, 23 May 2017 18:25:45 +0100 Subject: [PATCH 04/30] Added new column on Update view / button changelog / codestyle changes --- .../views/update/tmpl/default.php | 32 +++++++++++++++---- .../language/en-GB/en-GB.com_installer.ini | 1 + 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/administrator/components/com_installer/views/update/tmpl/default.php b/administrator/components/com_installer/views/update/tmpl/default.php index 905105d85a0ea..639e45fbe0b79 100644 --- a/administrator/components/com_installer/views/update/tmpl/default.php +++ b/administrator/components/com_installer/views/update/tmpl/default.php @@ -58,6 +58,9 @@ + + + @@ -101,16 +104,31 @@ current_version; ?> - + version; ?> - - version . " - " . $item->name; ?> - - changelogurl . '">'; ?> + + + changelogurl != NULL):?> + - version; ?> + $item->version . " - " . $item->name, + 'bodyHeight' => '60', + 'modalWidth' => '60', + ), + ''); + ?> + + + + N/A + - + folder_translated; ?> diff --git a/administrator/language/en-GB/en-GB.com_installer.ini b/administrator/language/en-GB/en-GB.com_installer.ini index 969567226408c..30f76d7a8655c 100644 --- a/administrator/language/en-GB/en-GB.com_installer.ini +++ b/administrator/language/en-GB/en-GB.com_installer.ini @@ -9,6 +9,7 @@ COM_INSTALLER_CACHETIMEOUT_DESC="For how many hours should Joomla cache update i COM_INSTALLER_CACHETIMEOUT_LABEL="Updates Caching (in hours)" COM_INSTALLER_CONFIGURATION="Installer: Options" COM_INSTALLER_CONFIRM_UNINSTALL="Are you sure you want to uninstall? Confirming will permanently delete the selected item(s)!" +COM_INSTALLER_CHANGELOG="Changelog" COM_INSTALLER_CURRENT_VERSION="Installed" COM_INSTALLER_DISCOVER_FILTER_SEARCH_DESC="Search in discovered extension name. Prefix with ID: to search for an extension ID." COM_INSTALLER_DISCOVER_FILTER_SEARCH_LABEL="Search Discovered Extensions" From e5907c6f91f2d64954ce8be6636e9b224f385576 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Tue, 23 May 2017 19:44:11 +0100 Subject: [PATCH 05/30] Null to lower case --- .../components/com_installer/views/update/tmpl/default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_installer/views/update/tmpl/default.php b/administrator/components/com_installer/views/update/tmpl/default.php index 639e45fbe0b79..13777466b6363 100644 --- a/administrator/components/com_installer/views/update/tmpl/default.php +++ b/administrator/components/com_installer/views/update/tmpl/default.php @@ -108,7 +108,7 @@ version; ?> - changelogurl != NULL):?> + changelogurl != null):?> Date: Mon, 3 Jul 2017 23:31:21 +0100 Subject: [PATCH 06/30] Added changelog modal in the manage view and bug fix --- .../sql/updates/mysql/4.0.0-2017-06-03.sql | 1 + .../updates/postgresql/4.0.0-2017-06-03.sql | 1 + .../com_installer/tmpl/manage/default.php | 24 ++++++++++++++++++- .../com_installer/tmpl/update/default.php | 4 ++-- installation/sql/mysql/joomla.sql | 1 + installation/sql/postgresql/joomla.sql | 1 + 6 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-06-03.sql create mode 100644 administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-06-03.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-06-03.sql new file mode 100644 index 0000000000000..2ff9531468516 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-06-03.sql @@ -0,0 +1 @@ +ALTER TABLE `#__extensions` ADD COLUMN `changelogurl` text AFTER `element`; diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql new file mode 100644 index 0000000000000..9081497651966 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql @@ -0,0 +1 @@ +ALTER TABLE "#__extensions" ADD COLUMN "changelogurl" text AFTER "element"; \ No newline at end of file diff --git a/administrator/components/com_installer/tmpl/manage/default.php b/administrator/components/com_installer/tmpl/manage/default.php index a37ced54022ed..5c8e23454a3df 100644 --- a/administrator/components/com_installer/tmpl/manage/default.php +++ b/administrator/components/com_installer/tmpl/manage/default.php @@ -107,7 +107,29 @@ type_translated; ?> - version != '' ? $item->version : ' '; ?> + version != ''): ?> + changelogurl != null): ?> + version?> + extension_id, + array( + 'title' => $item->version . " - " . $item->name, + 'bodyHeight' => '60', + 'modalWidth' => '60', + ), + ''); + ?> + + version; ?> + + + changelogurl != null):?> + + creationDate != '' ? $item->creationDate : ' '; ?> diff --git a/administrator/components/com_installer/tmpl/update/default.php b/administrator/components/com_installer/tmpl/update/default.php index 13777466b6363..fe5f2bfdf449b 100644 --- a/administrator/components/com_installer/tmpl/update/default.php +++ b/administrator/components/com_installer/tmpl/update/default.php @@ -109,12 +109,12 @@ changelogurl != null):?> - + extension_id, array( 'title' => $item->version . " - " . $item->name, 'bodyHeight' => '60', diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index b740ef2d8711b..fedd58f002a94 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -461,6 +461,7 @@ CREATE TABLE IF NOT EXISTS `#__extensions` ( `name` varchar(100) NOT NULL, `type` varchar(20) NOT NULL, `element` varchar(100) NOT NULL, + `changelogurl` text, `folder` varchar(100) NOT NULL, `client_id` tinyint(3) NOT NULL, `enabled` tinyint(3) NOT NULL DEFAULT 0, diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index 50306805c46aa..424c891badd99 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -472,6 +472,7 @@ CREATE TABLE IF NOT EXISTS "#__extensions" ( "name" varchar(100) NOT NULL, "type" varchar(20) NOT NULL, "element" varchar(100) NOT NULL, + "changelogurl" text, "folder" varchar(100) NOT NULL, "client_id" smallint NOT NULL, "enabled" smallint DEFAULT 0 NOT NULL, From 6d1453a2b20f8a563f83424743e4dcadd582e6c0 Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Mon, 3 Jul 2017 23:35:40 +0100 Subject: [PATCH 07/30] NL --- .../com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql index 9081497651966..95d49f4a69a5a 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql @@ -1 +1 @@ -ALTER TABLE "#__extensions" ADD COLUMN "changelogurl" text AFTER "element"; \ No newline at end of file +ALTER TABLE "#__extensions" ADD COLUMN "changelogurl" text AFTER "element"; From 37625756d5f00c3dc5fdbe4bc47f53f778ea23d2 Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Thu, 6 Jul 2017 10:58:15 +0100 Subject: [PATCH 08/30] Read changelogurl parameter of an extensions in the xml installation file --- .../src/CMS/Installer/Adapter/ComponentAdapter.php | 1 + libraries/src/CMS/Installer/InstallerAdapter.php | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libraries/src/CMS/Installer/Adapter/ComponentAdapter.php b/libraries/src/CMS/Installer/Adapter/ComponentAdapter.php index 98ecc20a83376..f65f3fde0afe4 100644 --- a/libraries/src/CMS/Installer/Adapter/ComponentAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/ComponentAdapter.php @@ -764,6 +764,7 @@ protected function storeExtension($deleteExisting = false) $this->extension->name = $this->name; $this->extension->type = 'component'; $this->extension->element = $this->element; + $this->extension->changelogurl = $this->changelogurl; // If we are told to delete existing extension entries then do so. if ($deleteExisting) diff --git a/libraries/src/CMS/Installer/InstallerAdapter.php b/libraries/src/CMS/Installer/InstallerAdapter.php index 7850e67cb96cc..4f913577fd0fd 100644 --- a/libraries/src/CMS/Installer/InstallerAdapter.php +++ b/libraries/src/CMS/Installer/InstallerAdapter.php @@ -22,6 +22,14 @@ */ abstract class InstallerAdapter { + /** + * Changelog Url of an extensions + * + * @var string + * @since __DEPLOY_VERSION__ + * */ + protected $changelogurl = null; + /** * ID for the currently installed extension if present * @@ -677,7 +685,7 @@ public function install() // Set the extension's name and element $this->name = $this->getName(); $this->element = $this->getElement(); - + $this->changelogurl = (string) $this->getManifest()->changelogurl; /* * --------------------------------------------------------------------------------------------- * Extension Precheck and Setup Section From 65fea021e10c3fa6eb6ddf5bb34f1fbabb67184a Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Thu, 6 Jul 2017 11:02:00 +0100 Subject: [PATCH 09/30] codestyle --- libraries/src/CMS/Installer/Adapter/ComponentAdapter.php | 6 +++--- libraries/src/CMS/Installer/InstallerAdapter.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/src/CMS/Installer/Adapter/ComponentAdapter.php b/libraries/src/CMS/Installer/Adapter/ComponentAdapter.php index f65f3fde0afe4..4736c131c5ada 100644 --- a/libraries/src/CMS/Installer/Adapter/ComponentAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/ComponentAdapter.php @@ -761,9 +761,9 @@ protected function storeExtension($deleteExisting = false) } // Add or update an entry to the extension table - $this->extension->name = $this->name; - $this->extension->type = 'component'; - $this->extension->element = $this->element; + $this->extension->name = $this->name; + $this->extension->type = 'component'; + $this->extension->element = $this->element; $this->extension->changelogurl = $this->changelogurl; // If we are told to delete existing extension entries then do so. diff --git a/libraries/src/CMS/Installer/InstallerAdapter.php b/libraries/src/CMS/Installer/InstallerAdapter.php index 4f913577fd0fd..589bd2e903042 100644 --- a/libraries/src/CMS/Installer/InstallerAdapter.php +++ b/libraries/src/CMS/Installer/InstallerAdapter.php @@ -686,6 +686,7 @@ public function install() $this->name = $this->getName(); $this->element = $this->getElement(); $this->changelogurl = (string) $this->getManifest()->changelogurl; + /* * --------------------------------------------------------------------------------------------- * Extension Precheck and Setup Section From ac1d41dddc29a60134e5340c6e1213e0eac0757a Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Thu, 6 Jul 2017 12:19:25 +0100 Subject: [PATCH 10/30] Added feature to Libraries / Modules / Packages and Plugins --- .../CMS/Installer/Adapter/LibraryAdapter.php | 1 + .../CMS/Installer/Adapter/ModuleAdapter.php | 1 + .../CMS/Installer/Adapter/PackageAdapter.php | 1 + .../CMS/Installer/Adapter/PluginAdapter.php | 21 ++++++++++--------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/libraries/src/CMS/Installer/Adapter/LibraryAdapter.php b/libraries/src/CMS/Installer/Adapter/LibraryAdapter.php index d5e9ccb2dfd5b..5b869d1447aac 100644 --- a/libraries/src/CMS/Installer/Adapter/LibraryAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/LibraryAdapter.php @@ -380,6 +380,7 @@ protected function storeExtension() $this->extension->name = $this->name; $this->extension->type = 'library'; $this->extension->element = $this->element; + $this->extension->changelogurl = $this->changelogurl; // There is no folder for libraries $this->extension->folder = ''; diff --git a/libraries/src/CMS/Installer/Adapter/ModuleAdapter.php b/libraries/src/CMS/Installer/Adapter/ModuleAdapter.php index 61580957241d2..ad182a18f9ebb 100644 --- a/libraries/src/CMS/Installer/Adapter/ModuleAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/ModuleAdapter.php @@ -606,6 +606,7 @@ protected function storeExtension() $this->extension->name = $this->name; $this->extension->type = 'module'; $this->extension->element = $this->element; + $this->extension->changelogurl = $this->changelogurl; // There is no folder for modules $this->extension->folder = ''; diff --git a/libraries/src/CMS/Installer/Adapter/PackageAdapter.php b/libraries/src/CMS/Installer/Adapter/PackageAdapter.php index 11f5200830809..0d3a0e9ce24cc 100644 --- a/libraries/src/CMS/Installer/Adapter/PackageAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/PackageAdapter.php @@ -548,6 +548,7 @@ protected function storeExtension() $this->extension->name = $this->name; $this->extension->type = 'package'; $this->extension->element = $this->element; + $this->extension->changelogurl = $this->changelogurl; // There is no folder for packages $this->extension->folder = ''; diff --git a/libraries/src/CMS/Installer/Adapter/PluginAdapter.php b/libraries/src/CMS/Installer/Adapter/PluginAdapter.php index 64a4bfbb2fda2..38f4df10225ca 100644 --- a/libraries/src/CMS/Installer/Adapter/PluginAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/PluginAdapter.php @@ -476,16 +476,17 @@ protected function storeExtension() else { // Store in the extensions table (1.6) - $this->extension->name = $this->name; - $this->extension->type = 'plugin'; - $this->extension->ordering = 0; - $this->extension->element = $this->element; - $this->extension->folder = $this->group; - $this->extension->enabled = 0; - $this->extension->protected = 0; - $this->extension->access = 1; - $this->extension->client_id = 0; - $this->extension->params = $this->parent->getParams(); + $this->extension->name = $this->name; + $this->extension->type = 'plugin'; + $this->extension->ordering = 0; + $this->extension->element = $this->element; + $this->extension->folder = $this->group; + $this->extension->enabled = 0; + $this->extension->protected = 0; + $this->extension->access = 1; + $this->extension->client_id = 0; + $this->extension->params = $this->parent->getParams(); + $this->extension->changelogurl = $this->changelogurl; // Update the manifest cache for the entry $this->extension->manifest_cache = $this->parent->generateManifestCache(); From b3d9a98cc5922b113f71086cee9ea3246a25b465 Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Thu, 6 Jul 2017 15:29:19 +0100 Subject: [PATCH 11/30] Added Language changelogurl in install and update --- libraries/src/CMS/Installer/Adapter/LanguageAdapter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/src/CMS/Installer/Adapter/LanguageAdapter.php b/libraries/src/CMS/Installer/Adapter/LanguageAdapter.php index 4a1b162b9ac38..c4e04b7f957fd 100644 --- a/libraries/src/CMS/Installer/Adapter/LanguageAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/LanguageAdapter.php @@ -479,6 +479,7 @@ protected function _install($cname, $basePath, $clientId, &$element) $row->set('name', $this->name); $row->set('type', 'language'); $row->set('element', $this->tag); + $row->set('changelogurl', (string) $this->getManifest()->changelogurl); // There is no folder for languages $row->set('folder', ''); @@ -758,6 +759,7 @@ public function update() $row->set('type', 'language'); $row->set('element', $this->tag); $row->set('manifest_cache', $this->parent->generateManifestCache()); + $row->set('changelogurl', (string) $this->getManifest()->changelogurl); // Clean installed languages cache. \JFactory::getCache()->clean('com_languages'); From a75ab12446795afa7800ba1123ad17925217ec8e Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Thu, 6 Jul 2017 15:59:23 +0100 Subject: [PATCH 12/30] Changelog to Templates added --- libraries/src/CMS/Installer/Adapter/TemplateAdapter.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/src/CMS/Installer/Adapter/TemplateAdapter.php b/libraries/src/CMS/Installer/Adapter/TemplateAdapter.php index 6e3293b4812ce..f52a8805a1937 100644 --- a/libraries/src/CMS/Installer/Adapter/TemplateAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/TemplateAdapter.php @@ -520,8 +520,8 @@ protected function storeExtension() } else { - $this->extension->type = 'template'; - $this->extension->element = $this->element; + $this->extension->type = 'template'; + $this->extension->element = $this->element; // There is no folder for templates $this->extension->folder = ''; @@ -538,6 +538,8 @@ protected function storeExtension() // Update the manifest cache for the entry $this->extension->manifest_cache = $this->parent->generateManifestCache(); + $this->extension->changelogurl = $this->changelogurl; + if (!$this->extension->store()) { // Install failed, roll back changes From 417b5f918a16a3c04f4eb0d6c4317838f06c7766 Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Fri, 7 Jul 2017 12:45:48 +0100 Subject: [PATCH 13/30] added changelog url to Files --- libraries/src/CMS/Installer/Adapter/FileAdapter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/src/CMS/Installer/Adapter/FileAdapter.php b/libraries/src/CMS/Installer/Adapter/FileAdapter.php index 12f7ee142d79e..0280dcf8483ec 100644 --- a/libraries/src/CMS/Installer/Adapter/FileAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/FileAdapter.php @@ -406,6 +406,7 @@ protected function storeExtension() $this->extension->name = $this->name; $this->extension->type = 'file'; $this->extension->element = $this->element; + $this->extension->changelogurl = $this->changelogurl; // There is no folder for files so leave it blank $this->extension->folder = ''; From ad91562cad63bd0053abe0741ae2248fc38b2766 Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Wed, 26 Jul 2017 19:15:37 +0100 Subject: [PATCH 14/30] Codestyle --- .../components/com_installer/tmpl/manage/default.php | 4 ++-- .../components/com_installer/tmpl/update/default.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/administrator/components/com_installer/tmpl/manage/default.php b/administrator/components/com_installer/tmpl/manage/default.php index ed69388056221..9e67de4171713 100644 --- a/administrator/components/com_installer/tmpl/manage/default.php +++ b/administrator/components/com_installer/tmpl/manage/default.php @@ -106,8 +106,8 @@ type_translated; ?> - version != ''): ?> - changelogurl != null): ?> + version != ''): ?> + changelogurl != null): ?> version?> version; ?> - changelogurl != null):?> + changelogurl != null):?> Date: Wed, 26 Jul 2017 21:20:39 +0100 Subject: [PATCH 15/30] Added namespaces and replaced Jhtml for JHtml --- .../com_installer/tmpl/update/default.php | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/administrator/components/com_installer/tmpl/update/default.php b/administrator/components/com_installer/tmpl/update/default.php index c80765f729da4..33152744758c0 100644 --- a/administrator/components/com_installer/tmpl/update/default.php +++ b/administrator/components/com_installer/tmpl/update/default.php @@ -9,7 +9,7 @@ defined('_JEXEC') or die; -JHtml::_('behavior.multiselect'); +\JHtml::_('behavior.multiselect'); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); @@ -32,41 +32,41 @@ $this)); ?> items)) : ?>
- +
@@ -79,16 +79,16 @@ items as $i => $item) : ?> - client_id ? JText::_('JADMINISTRATOR') : JText::_('JSITE'); ?> + client_id ? \JText::_('JADMINISTRATOR') : \JText::_('JSITE'); ?> manifest_cache); ?> - version) ? $manifest->version : JText::_('JLIB_UNKNOWN'); ?> + version) ? $manifest->version : \JText::_('JLIB_UNKNOWN'); ?>
- + - + - + - + - + - + - + - + - + - +
- update_id); ?> + update_id); ?> @@ -110,7 +110,7 @@ extension_id, array( @@ -123,7 +123,7 @@ - N/A + @@ -150,7 +150,7 @@ - + From 4119c94af14eeab5cd8f829b9c629a714699bbd5 Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Wed, 26 Jul 2017 21:51:00 +0100 Subject: [PATCH 16/30] Update files merged --- .../components/com_admin/sql/updates/mysql/4.0.0-2017-05-17.sql | 1 - .../components/com_admin/sql/updates/mysql/4.0.0-2017-06-03.sql | 1 + .../com_admin/sql/updates/postgresql/4.0.0-2017-05-17.sql | 1 - .../com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql | 1 + 4 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-05-17.sql delete mode 100644 administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-05-17.sql diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-05-17.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-05-17.sql deleted file mode 100644 index bf20296420cc2..0000000000000 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-05-17.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `#__updates` ADD COLUMN `changelogurl` text AFTER `infourl`; diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-06-03.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-06-03.sql index 2ff9531468516..2166de7eb35be 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-06-03.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2017-06-03.sql @@ -1 +1,2 @@ ALTER TABLE `#__extensions` ADD COLUMN `changelogurl` text AFTER `element`; +ALTER TABLE `#__updates` ADD COLUMN `changelogurl` text AFTER `infourl`; diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-05-17.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-05-17.sql deleted file mode 100644 index 5e5d0f78ca3ae..0000000000000 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-05-17.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "#__updates" ADD COLUMN "changelogurl" text AFTER `infourl`; diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql index 95d49f4a69a5a..01461657441e8 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2017-06-03.sql @@ -1 +1,2 @@ ALTER TABLE "#__extensions" ADD COLUMN "changelogurl" text AFTER "element"; +ALTER TABLE "#__updates" ADD COLUMN "changelogurl" text AFTER `infourl`; From cc525be6dd8001c7839f34842451b3ef7f7a9315 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Wed, 26 Jul 2017 22:13:17 +0100 Subject: [PATCH 17/30] Update default.php --- .../com_installer/tmpl/update/default.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/administrator/components/com_installer/tmpl/update/default.php b/administrator/components/com_installer/tmpl/update/default.php index 33152744758c0..8f35587dc31cc 100644 --- a/administrator/components/com_installer/tmpl/update/default.php +++ b/administrator/components/com_installer/tmpl/update/default.php @@ -9,7 +9,7 @@ defined('_JEXEC') or die; -\JHtml::_('behavior.multiselect'); +JHtml::_('behavior.multiselect'); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); @@ -32,26 +32,26 @@ $this)); ?> items)) : ?>
- +
@@ -84,7 +84,7 @@ version) ? $manifest->version : \JText::_('JLIB_UNKNOWN'); ?>
- + - + - + - + - + @@ -60,13 +60,13 @@ - + - + - +
- update_id); ?> + update_id); ?> - + @@ -150,7 +150,7 @@ - + From 62be1da318b4b39c908f66bd5cf836a86a5ec9b6 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Wed, 26 Jul 2017 22:15:19 +0100 Subject: [PATCH 19/30] Update default.php --- administrator/components/com_installer/tmpl/update/default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_installer/tmpl/update/default.php b/administrator/components/com_installer/tmpl/update/default.php index 3d4e12fe8dc89..1299d4ee86040 100644 --- a/administrator/components/com_installer/tmpl/update/default.php +++ b/administrator/components/com_installer/tmpl/update/default.php @@ -88,7 +88,7 @@ From 5380927ccecec8301b2a473d8e0400bc9c0f891b Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Wed, 9 Aug 2017 20:12:28 +0100 Subject: [PATCH 20/30] Code style --- .../components/com_installer/tmpl/update/default.php | 2 +- libraries/src/CMS/Installer/Adapter/PackageAdapter.php | 6 +++--- libraries/src/CMS/Installer/Adapter/TemplateAdapter.php | 4 ++-- libraries/src/CMS/Installer/InstallerAdapter.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/administrator/components/com_installer/tmpl/update/default.php b/administrator/components/com_installer/tmpl/update/default.php index 1299d4ee86040..dd906dd414b74 100644 --- a/administrator/components/com_installer/tmpl/update/default.php +++ b/administrator/components/com_installer/tmpl/update/default.php @@ -107,7 +107,7 @@ changelogurl != null):?> - + extension->name = $this->name; - $this->extension->type = 'package'; - $this->extension->element = $this->element; + $this->extension->name = $this->name; + $this->extension->type = 'package'; + $this->extension->element = $this->element; $this->extension->changelogurl = $this->changelogurl; // There is no folder for packages diff --git a/libraries/src/CMS/Installer/Adapter/TemplateAdapter.php b/libraries/src/CMS/Installer/Adapter/TemplateAdapter.php index 3c4b8e73933cf..5a990c309d287 100644 --- a/libraries/src/CMS/Installer/Adapter/TemplateAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/TemplateAdapter.php @@ -520,8 +520,8 @@ protected function storeExtension() } else { - $this->extension->type = 'template'; - $this->extension->element = $this->element; + $this->extension->type = 'template'; + $this->extension->element = $this->element; // There is no folder for templates $this->extension->folder = ''; diff --git a/libraries/src/CMS/Installer/InstallerAdapter.php b/libraries/src/CMS/Installer/InstallerAdapter.php index 7b41d4212f926..d015dfd1116f3 100644 --- a/libraries/src/CMS/Installer/InstallerAdapter.php +++ b/libraries/src/CMS/Installer/InstallerAdapter.php @@ -677,8 +677,8 @@ public function install() } // Set the extension's name and element - $this->name = $this->getName(); - $this->element = $this->getElement(); + $this->name = $this->getName(); + $this->element = $this->getElement(); $this->changelogurl = (string) $this->getManifest()->changelogurl; /* From 775e102474fd105761ccd2d96e545045c26407a3 Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Wed, 9 Aug 2017 20:15:19 +0100 Subject: [PATCH 21/30] Code style --- libraries/src/CMS/Installer/Adapter/FileAdapter.php | 6 +++--- libraries/src/CMS/Installer/Adapter/LibraryAdapter.php | 6 +++--- libraries/src/CMS/Installer/Adapter/ModuleAdapter.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/src/CMS/Installer/Adapter/FileAdapter.php b/libraries/src/CMS/Installer/Adapter/FileAdapter.php index d6bc020b4665c..f77548b647d19 100644 --- a/libraries/src/CMS/Installer/Adapter/FileAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/FileAdapter.php @@ -403,9 +403,9 @@ protected function storeExtension() else { // Add an entry to the extension table with a whole heap of defaults - $this->extension->name = $this->name; - $this->extension->type = 'file'; - $this->extension->element = $this->element; + $this->extension->name = $this->name; + $this->extension->type = 'file'; + $this->extension->element = $this->element; $this->extension->changelogurl = $this->changelogurl; // There is no folder for files so leave it blank diff --git a/libraries/src/CMS/Installer/Adapter/LibraryAdapter.php b/libraries/src/CMS/Installer/Adapter/LibraryAdapter.php index 9114adb3874d8..ba768b8af11b8 100644 --- a/libraries/src/CMS/Installer/Adapter/LibraryAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/LibraryAdapter.php @@ -378,9 +378,9 @@ protected function storeExtension() return; } - $this->extension->name = $this->name; - $this->extension->type = 'library'; - $this->extension->element = $this->element; + $this->extension->name = $this->name; + $this->extension->type = 'library'; + $this->extension->element = $this->element; $this->extension->changelogurl = $this->changelogurl; // There is no folder for libraries diff --git a/libraries/src/CMS/Installer/Adapter/ModuleAdapter.php b/libraries/src/CMS/Installer/Adapter/ModuleAdapter.php index 47bfde4f05ef5..92701a7943b34 100644 --- a/libraries/src/CMS/Installer/Adapter/ModuleAdapter.php +++ b/libraries/src/CMS/Installer/Adapter/ModuleAdapter.php @@ -603,9 +603,9 @@ protected function storeExtension() } else { - $this->extension->name = $this->name; - $this->extension->type = 'module'; - $this->extension->element = $this->element; + $this->extension->name = $this->name; + $this->extension->type = 'module'; + $this->extension->element = $this->element; $this->extension->changelogurl = $this->changelogurl; // There is no folder for modules From 84e2e4395cc7a34f87407c6d691076bed7835c83 Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Mon, 14 Aug 2017 18:25:50 +0100 Subject: [PATCH 22/30] code style --- libraries/src/CMS/Installer/InstallerAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/CMS/Installer/InstallerAdapter.php b/libraries/src/CMS/Installer/InstallerAdapter.php index d015dfd1116f3..365adfe4c4028 100644 --- a/libraries/src/CMS/Installer/InstallerAdapter.php +++ b/libraries/src/CMS/Installer/InstallerAdapter.php @@ -23,7 +23,7 @@ abstract class InstallerAdapter { /** - * Changelog Url of an extensions + * Changelog URL of extensions * * @var string * @since __DEPLOY_VERSION__ From 7688ea8dd62e61aabd77bd0c5a6afcccb4c9cbae Mon Sep 17 00:00:00 2001 From: NunoLopes96 Date: Tue, 15 Aug 2017 19:51:07 +0100 Subject: [PATCH 23/30] CodeStyle --- administrator/components/com_installer/tmpl/manage/default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_installer/tmpl/manage/default.php b/administrator/components/com_installer/tmpl/manage/default.php index 9e67de4171713..c3767bb115bfd 100644 --- a/administrator/components/com_installer/tmpl/manage/default.php +++ b/administrator/components/com_installer/tmpl/manage/default.php @@ -127,7 +127,7 @@ echo ' '; endif; ?> changelogurl != null):?> - + From 31f820e740413f7dc7c7e895d628f260bbb9e106 Mon Sep 17 00:00:00 2001 From: Roland Dalmulder Date: Mon, 28 May 2018 10:47:10 +0200 Subject: [PATCH 24/30] Working on the changelog notification --- .../Controller/ManageController.php | 51 ++++++++-- .../com_installer/Model/ManageModel.php | 96 +++++++++++++++---- .../com_installer/tmpl/manage/default.php | 83 ++++++++++------ 3 files changed, 174 insertions(+), 56 deletions(-) diff --git a/administrator/components/com_installer/Controller/ManageController.php b/administrator/components/com_installer/Controller/ManageController.php index 4dcc9a936bde9..1ec20d234a310 100644 --- a/administrator/components/com_installer/Controller/ManageController.php +++ b/administrator/components/com_installer/Controller/ManageController.php @@ -10,9 +10,14 @@ defined('_JEXEC') or die; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\BaseController; -use Joomla\Utilities\ArrayHelper; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Response\JsonResponse; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\Utilities\ArrayHelper; /** * Installer Manage Controller @@ -45,12 +50,14 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu * * @return void * + * @throws \Exception + * * @since 1.6 */ public function publish() { // Check for request forgeries. - \JSession::checkToken() or jexit(\JText::_('JINVALID_TOKEN')); + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); $ids = $this->input->get('cid', array(), 'array'); $values = array('publish' => 1, 'unpublish' => 0); @@ -59,7 +66,7 @@ public function publish() if (empty($ids)) { - $this->setMessage(\JText::_('COM_INSTALLER_ERROR_NO_EXTENSIONS_SELECTED'), 'warning'); + $this->setMessage(Text::_('COM_INSTALLER_ERROR_NO_EXTENSIONS_SELECTED'), 'warning'); } else { @@ -82,11 +89,11 @@ public function publish() $ntext = 'COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED'; } - $this->setMessage(\JText::plural($ntext, count($ids))); + $this->setMessage(Text::plural($ntext, count($ids))); } } - $this->setRedirect(\JRoute::_('index.php?option=com_installer&view=manage', false)); + $this->setRedirect(Route::_('index.php?option=com_installer&view=manage', false)); } /** @@ -94,12 +101,14 @@ public function publish() * * @return void * + * @throws \Exception + * * @since 1.5 */ public function remove() { // Check for request forgeries. - \JSession::checkToken() or jexit(\JText::_('JINVALID_TOKEN')); + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); /* @var \Joomla\Component\Installer\Administrator\Model\ManageModel $model */ $model = $this->getModel('manage'); @@ -107,7 +116,7 @@ public function remove() $eid = $this->input->get('cid', array(), 'array'); $eid = ArrayHelper::toInteger($eid, array()); $model->remove($eid); - $this->setRedirect(\JRoute::_('index.php?option=com_installer&view=manage', false)); + $this->setRedirect(Route::_('index.php?option=com_installer&view=manage', false)); } /** @@ -122,7 +131,7 @@ public function remove() public function refresh() { // Check for request forgeries. - \JSession::checkToken() or jexit(\JText::_('JINVALID_TOKEN')); + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); /* @var \Joomla\Component\Installer\Administrator\Model\ManageModel $model */ $model = $this->getModel('manage'); @@ -130,6 +139,30 @@ public function refresh() $uid = $this->input->get('cid', array(), 'array'); $uid = ArrayHelper::toInteger($uid, array()); $model->refresh($uid); - $this->setRedirect(\JRoute::_('index.php?option=com_installer&view=manage', false)); + $this->setRedirect(Route::_('index.php?option=com_installer&view=manage', false)); + } + + /** + * Load the changelog for a given extension. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function loadChangelog() + { + /* @var \Joomla\Component\Installer\Administrator\Model\ManageModel $model */ + $model = $this->getModel('manage'); + + $eid = $this->input->get('eid', 0, 'int'); + + if (!$eid) + { + return; + } + + $output = $model->loadChangelog($eid); + + echo (new JsonResponse($output)); } } diff --git a/administrator/components/com_installer/Model/ManageModel.php b/administrator/components/com_installer/Model/ManageModel.php index 8cea3bcdbe08e..4fd980a126a65 100644 --- a/administrator/components/com_installer/Model/ManageModel.php +++ b/administrator/components/com_installer/Model/ManageModel.php @@ -10,7 +10,12 @@ defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Http\HttpFactory; +use Joomla\CMS\Installer\Installer; +use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Extension; use Joomla\Component\Templates\Administrator\Table\StyleTable; use Joomla\Database\DatabaseQuery; @@ -59,11 +64,13 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu * * @return void * + * @throws \Exception + * * @since 1.6 */ protected function populateState($ordering = 'name', $direction = 'asc') { - $app = \JFactory::getApplication(); + $app = Factory::getApplication(); // Load the filter state. $this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string')); @@ -89,13 +96,15 @@ protected function populateState($ordering = 'name', $direction = 'asc') * * @return boolean True on success * + * @throws \Exception + * * @since 1.5 */ public function publish(&$eid = array(), $value = 1) { - if (!\JFactory::getUser()->authorise('core.edit.state', 'com_installer')) + if (!Factory::getUser()->authorise('core.edit.state', 'com_installer')) { - \JFactory::getApplication()->enqueueMessage(\JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'error'); + Factory::getApplication()->enqueueMessage(Text::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'error'); return false; } @@ -112,7 +121,7 @@ public function publish(&$eid = array(), $value = 1) } // Get a table object for the extension type - $table = new \Joomla\CMS\Table\Extension($this->getDbo()); + $table = new Extension($this->getDbo()); // Enable the extension in the table and store it in the database foreach ($eid as $i => $id) @@ -125,7 +134,7 @@ public function publish(&$eid = array(), $value = 1) if ($style->load(array('template' => $table->element, 'client_id' => $table->client_id, 'home' => 1))) { - \JFactory::getApplication()->enqueueMessage(\JText::_('COM_INSTALLER_ERROR_DISABLE_DEFAULT_TEMPLATE_NOT_PERMITTED'), 'notice'); + Factory::getApplication()->enqueueMessage(Text::_('COM_INSTALLER_ERROR_DISABLE_DEFAULT_TEMPLATE_NOT_PERMITTED'), 'notice'); unset($eid[$i]); continue; } @@ -134,7 +143,7 @@ public function publish(&$eid = array(), $value = 1) if ($table->protected == 1) { $result = false; - \JFactory::getApplication()->enqueueMessage(\JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'error'); + Factory::getApplication()->enqueueMessage(Text::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'error'); } else { @@ -162,7 +171,7 @@ public function publish(&$eid = array(), $value = 1) /** * Refreshes the cached manifest information for an extension. * - * @param int $eid extension identifier (key in #__extensions) + * @param array|integer $eid extension identifier (key in #__extensions) * * @return boolean result of refresh * @@ -176,7 +185,7 @@ public function refresh($eid) } // Get an installer object for the extension type - $installer = \JInstaller::getInstance(); + $installer = Installer::getInstance(); $result = 0; // Uninstall the chosen extensions @@ -195,13 +204,15 @@ public function refresh($eid) * * @return boolean True on success * + * @throws \Exception + * * @since 1.5 */ public function remove($eid = array()) { - if (!\JFactory::getUser()->authorise('core.delete', 'com_installer')) + if (!Factory::getUser()->authorise('core.delete', 'com_installer')) { - \JFactory::getApplication()->enqueueMessage(\JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'), 'error'); + Factory::getApplication()->enqueueMessage(Text::_('JERROR_CORE_DELETE_NOT_PERMITTED'), 'error'); return false; } @@ -216,11 +227,11 @@ public function remove($eid = array()) } // Get an installer object for the extension type - $installer = \JInstaller::getInstance(); - $row = new \Joomla\CMS\Table\Extension($this->getDbo()); + $installer = Installer::getInstance(); + $row = new Extension($this->getDbo()); // Uninstall the chosen extensions - $msgs = array(); + $msgs = array(); $result = false; foreach ($eid as $id) @@ -230,7 +241,7 @@ public function remove($eid = array()) $result = false; $langstring = 'COM_INSTALLER_TYPE_TYPE_' . strtoupper($row->type); - $rowtype = \JText::_($langstring); + $rowtype = Text::_($langstring); if (strpos($rowtype, $langstring) !== false) { @@ -245,24 +256,24 @@ public function remove($eid = array()) if ($result === false) { // There was an error in uninstalling the package - $msgs[] = \JText::sprintf('COM_INSTALLER_UNINSTALL_ERROR', $rowtype); + $msgs[] = Text::sprintf('COM_INSTALLER_UNINSTALL_ERROR', $rowtype); continue; } // Package uninstalled successfully - $msgs[] = \JText::sprintf('COM_INSTALLER_UNINSTALL_SUCCESS', $rowtype); + $msgs[] = Text::sprintf('COM_INSTALLER_UNINSTALL_SUCCESS', $rowtype); $result = true; continue; } // There was an error in uninstalling the package - $msgs[] = \JText::sprintf('COM_INSTALLER_UNINSTALL_ERROR', $rowtype); + $msgs[] = Text::sprintf('COM_INSTALLER_UNINSTALL_ERROR', $rowtype); } $msg = implode('
', $msgs); - $app = \JFactory::getApplication(); + $app = Factory::getApplication(); $app->enqueueMessage($msg); $this->setState('action', 'remove'); $this->setState('name', $installer->get('name')); @@ -371,4 +382,53 @@ protected function getListQuery() return $query; } + + /** + * Load the changelog details for a given extension. + * + * @param integer $eid The extension ID + * + * @return string The output to show in the modal. + * + * @since __DEPLOY_VERSION__ + */ + public function loadChangelog($eid) + { + // Get the changelog URL + $db = $this->getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('changelogurl')) + ->from($db->quoteName('#__extensions')) + ->where($db->quoteName('extension_id') . ' = ' . (int) $eid); + $db->setQuery($query); + + $changelogUrl = $db->loadResult(); + + if (!$changelogUrl) + { + return ''; + } + + // Get the changelog details + $http = HttpFactory::getHttp([], array('curl', 'stream')); + $result = $http->get($changelogUrl); + + if ($result->code !== 200) + { + return ''; + } + + $xml = new \SimpleXMLElement($result->body); + + ?> +
';
+		print_r($xml);
+		echo '';
+		?>
escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?>
-
+
sidebar; ?> @@ -30,43 +34,43 @@ $this)); ?> items)) : ?> - + @@ -81,18 +85,18 @@ items as $i => $item) : ?> @@ -152,9 +156,30 @@ - + + \ No newline at end of file From 1c797e61018360e318720dbc27e0b1f485babeb9 Mon Sep 17 00:00:00 2001 From: Roland Dalmulder Date: Mon, 4 Jun 2018 23:05:10 +0200 Subject: [PATCH 25/30] Adding the badges and reading the XML --- .../com_installer/Model/ManageModel.php | 58 +++++++++++++++---- .../com_installer/tmpl/manage/default.php | 2 +- .../com_installer/tmpl/update/default.php | 4 +- .../language/en-GB/en-GB.com_installer.ini | 9 ++- layouts/joomla/installer/changelog.php | 55 ++++++++++++++++++ 5 files changed, 113 insertions(+), 15 deletions(-) create mode 100644 layouts/joomla/installer/changelog.php diff --git a/administrator/components/com_installer/Model/ManageModel.php b/administrator/components/com_installer/Model/ManageModel.php index 4fd980a126a65..cd8cb5911e627 100644 --- a/administrator/components/com_installer/Model/ManageModel.php +++ b/administrator/components/com_installer/Model/ManageModel.php @@ -14,6 +14,7 @@ use Joomla\CMS\Http\HttpFactory; use Joomla\CMS\Installer\Installer; use Joomla\CMS\Language\Text; +use Joomla\CMS\Layout\FileLayout; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\Table\Extension; use Joomla\Component\Templates\Administrator\Table\StyleTable; @@ -397,21 +398,29 @@ public function loadChangelog($eid) // Get the changelog URL $db = $this->getDbo(); $query = $db->getQuery(true) - ->select($db->quoteName('changelogurl')) + ->select( + $db->quoteName( + array( + 'element', + 'type', + 'changelogurl' + ) + ) + ) ->from($db->quoteName('#__extensions')) ->where($db->quoteName('extension_id') . ' = ' . (int) $eid); $db->setQuery($query); - $changelogUrl = $db->loadResult(); + $extension = $db->loadObject(); - if (!$changelogUrl) + if (!$extension->changelogurl) { return ''; } // Get the changelog details $http = HttpFactory::getHttp([], array('curl', 'stream')); - $result = $http->get($changelogUrl); + $result = $http->get($extension->changelogurl); if ($result->code !== 200) { @@ -420,15 +429,40 @@ public function loadChangelog($eid) $xml = new \SimpleXMLElement($result->body); - ?> -
';
-		print_r($xml);
-		echo '';
-		?>
changelog) + { + return ''; + } + + // Get the changelog + $changelog = $xml->changelog; + + // Validate the extension + if ((string) $changelog->element !== $extension->element && (string) $changelog->type !== $extension->type) + { + return ''; + } + + // Read all the entries + $entries = array( + 'security' => array(), + 'fix' => array(), + 'addition' => array(), + 'change' => array(), + 'removed' => array(), + 'language' => array(), + 'note' => array() + ); + + foreach ((array) $changelog->entries as $changeType => $item) + { + $entries[(string) $changeType] = array_values((array) $item->item); + } + $layout = new FileLayout('joomla.installer.changelog'); + $output = $layout->render($entries); + return $output; } } diff --git a/administrator/components/com_installer/tmpl/manage/default.php b/administrator/components/com_installer/tmpl/manage/default.php index afea5b3432eba..f1770966f7fb2 100644 --- a/administrator/components/com_installer/tmpl/manage/default.php +++ b/administrator/components/com_installer/tmpl/manage/default.php @@ -172,7 +172,7 @@ function loadChangelog(extensionId) { { var result = JSON.parse(response); console.log(result.data); - document.querySelectorAll('#changelog_modal .modal-body')[0].innerText = result.data; + document.querySelectorAll('#changelog_modal .modal-body')[0].innerHTML = result.data; // Do nothing }, diff --git a/administrator/components/com_installer/tmpl/update/default.php b/administrator/components/com_installer/tmpl/update/default.php index 430f7fa4669d9..8b4268109ce5e 100644 --- a/administrator/components/com_installer/tmpl/update/default.php +++ b/administrator/components/com_installer/tmpl/update/default.php @@ -7,6 +7,8 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +use Joomla\CMS\Language\Text; + defined('_JEXEC') or die; JHtml::_('behavior.multiselect'); @@ -105,7 +107,7 @@
diff --git a/administrator/components/com_installer/tmpl/update/default.php b/administrator/components/com_installer/tmpl/update/default.php index 533869b63fb12..230d9ecc329c5 100644 --- a/administrator/components/com_installer/tmpl/update/default.php +++ b/administrator/components/com_installer/tmpl/update/default.php @@ -72,7 +72,7 @@ - @@ -107,7 +107,7 @@ version; ?>
- + - + - + - + - + - + - + - + - + - + - +
- extension_id); ?> + extension_id); ?> element) : ?> X - status, $i, $item->status < 2, 'cb'); ?> + status, $i, $item->status < 2, 'cb'); ?> @@ -106,17 +110,17 @@ version != ''): ?> changelogurl != null): ?> - version?> + version?> + extension_id, - array( - 'title' => $item->version . " - " . $item->name, - 'bodyHeight' => '60', - 'modalWidth' => '60', - ), - ''); + echo HTMLHelper::_( + 'bootstrap.renderModal', + 'changelog_modal', + array( + 'title' => $item->version . " - " . $item->name, + ), + '' + ); ?> version; ?> @@ -132,7 +136,7 @@ creationDate != '' ? $item->creationDate : ' '; ?> - + author != '' ? $item->author : ' '; ?> changelogurl != null):?> - + $items) +{ + switch ($changeType) + { + case 'security': + $class = 'badge-danger'; + break; + case 'fix': + $class = 'badge-dark'; + break; + case 'language': + $class = 'badge-jlanguage'; + break; + case 'addition': + $class = 'badge-success'; + break; + case 'change': + $class = 'badge-warning'; + break; + case 'removed': + $class = 'badge-light'; + break; + default: + case 'note': + $class = 'badge-info'; + break; + } + + $output .= '
' . Text::_('COM_INSTALLER_CHANGELOG_' . $changeType) . '
'; + $output .= '
    '; + + foreach ($items as $item) + { + $output .= '
  • ' . $item . '
  • '; + } + + $output .= '
'; +} + +echo $output; \ No newline at end of file From 5c1d96d7ddb25cc0f963a7a95254767c6d5edd96 Mon Sep 17 00:00:00 2001 From: Roland Dalmulder Date: Sun, 10 Jun 2018 08:14:26 +0200 Subject: [PATCH 26/30] Work on changelog layout --- layouts/joomla/installer/changelog.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/layouts/joomla/installer/changelog.php b/layouts/joomla/installer/changelog.php index c9e2bc533175d..4d65f8888c21b 100644 --- a/layouts/joomla/installer/changelog.php +++ b/layouts/joomla/installer/changelog.php @@ -41,7 +41,8 @@ break; } - $output .= '
' . Text::_('COM_INSTALLER_CHANGELOG_' . $changeType) . '
'; + $output .= '
'; + $output .= '
' . Text::_('COM_INSTALLER_CHANGELOG_' . $changeType) . '
'; $output .= '
    '; foreach ($items as $item) @@ -50,6 +51,8 @@ } $output .= '
'; + $output .= '
'; + $output .= '
'; } echo $output; \ No newline at end of file From 79497a8bc8c0fae70ed4c78b4289ddd235abf5b1 Mon Sep 17 00:00:00 2001 From: Roland Dalmulder Date: Sun, 1 Jul 2018 22:58:36 +0200 Subject: [PATCH 27/30] Start code cleanup --- .../com_installer/tmpl/manage/default.php | 154 ++++++------- .../com_installer/tmpl/update/default.php | 217 +++++++++--------- .../Installer/Adapter/ComponentAdapter.php | 184 ++++++++------- .../src/Installer/Adapter/FileAdapter.php | 28 +-- .../src/Installer/Adapter/LanguageAdapter.php | 80 +++---- .../src/Installer/Adapter/LibraryAdapter.php | 82 +++---- .../src/Installer/Adapter/ModuleAdapter.php | 43 ++-- .../src/Installer/Adapter/PackageAdapter.php | 66 +++--- .../src/Installer/Adapter/PluginAdapter.php | 51 ++-- .../src/Installer/Adapter/TemplateAdapter.php | 72 +++--- libraries/src/Installer/InstallerAdapter.php | 59 +++-- 11 files changed, 532 insertions(+), 504 deletions(-) diff --git a/administrator/components/com_installer/tmpl/manage/default.php b/administrator/components/com_installer/tmpl/manage/default.php index f1770966f7fb2..72830972a6b98 100644 --- a/administrator/components/com_installer/tmpl/manage/default.php +++ b/administrator/components/com_installer/tmpl/manage/default.php @@ -13,8 +13,6 @@ use Joomla\CMS\Language\Text; use Joomla\CMS\Router\Route; -HTMLHelper::_('behavior.multiselect'); - $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?> @@ -39,37 +37,37 @@ - - - - - - - - - @@ -82,75 +80,74 @@ - items as $i => $item) : ?> - - - - - - - + + - - - - - - - + + + + + + + + + + + +
+ + + + + + + + +
- extension_id); ?> - - element) : ?> - X - - status, $i, $item->status < 2, 'cb'); ?> - - - - - client_translated; ?> - - type_translated; ?> - - version != ''): ?> - changelogurl != null): ?> - version?> - - $item->version . " - " . $item->name, - ), - '' - ); - ?> + items as $i => $item) : ?> +
+ extension_id); ?> + + element) : ?> + X - version; ?> + status, $i, $item->status < 2, 'cb'); ?> - - changelogurl != null):?> - - - - creationDate != '' ? $item->creationDate : ' '; ?> - - - author != '' ? $item->author : ' '; ?> - - - folder_translated; ?> - - package_id ?: ' '; ?> - - extension_id; ?> -
+ + + client_translated; ?> + + type_translated; ?> + + version != ''): ?> + changelogurl != null): ?> + + version?> + + $item->version . " - " . $item->name, + ), + '' + ); + ?> + + version; ?> + + + + creationDate) && $item->creationDate !== '' ? $item->creationDate : ' '; ?> + + + author) && $item->author !== '' ? $item->author : ' '; ?> + + + folder_translated; ?> + + package_id ?: ' '; ?> + + extension_id; ?> +
@@ -171,7 +168,6 @@ function loadChangelog(extensionId) { onSuccess: function(response, xhr) { var result = JSON.parse(response); - console.log(result.data); document.querySelectorAll('#changelog_modal .modal-body')[0].innerHTML = result.data; // Do nothing diff --git a/administrator/components/com_installer/tmpl/update/default.php b/administrator/components/com_installer/tmpl/update/default.php index 8b4268109ce5e..533869b63fb12 100644 --- a/administrator/components/com_installer/tmpl/update/default.php +++ b/administrator/components/com_installer/tmpl/update/default.php @@ -7,17 +7,18 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -use Joomla\CMS\Language\Text; - defined('_JEXEC') or die; -JHtml::_('behavior.multiselect'); +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?>
-
+
sidebar; ?> @@ -27,130 +28,130 @@ showMessage) : ?> loadTemplate('message'); ?> - ftp) : ?> loadTemplate('ftp'); ?> - $this)); ?> + $this)); ?> items)) : ?> - + - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - items as $i => $item) : ?> - client_id ? \JText::_('JADMINISTRATOR') : \JText::_('JSITE'); ?> - manifest_cache); ?> - version) ? $manifest->version : \JText::_('JLIB_UNKNOWN'); ?> - - - - - - - - + + + + + + + - - - - - + + + + + +
- - - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + +
- pagination->getListFooter(); ?> -
+ pagination->getListFooter(); ?> +
- update_id); ?> - - - - client_translated; ?> - - type_translated; ?> - - current_version; ?> - - version; ?> - - changelogurl != null):?> - + items as $i => $item) : ?> + client_id ? Text::_('JADMINISTRATOR') : Text::_('JSITE'); ?> + manifest_cache); ?> + version) ? $manifest->version : Text::_('JLIB_UNKNOWN'); ?> +
+ update_id); ?> + + + + client_translated; ?> + + type_translated; ?> + + current_version; ?> + + version; ?> + + changelogurl != null):?> + - extension_id, - array( - 'title' => $item->version . " - " . $item->name, - 'bodyHeight' => '60', - 'modalWidth' => '60', - ), - ''); - ?> + extension_id, + array( + 'title' => $item->version . " - " . $item->name, + 'bodyHeight' => '60', + 'modalWidth' => '60', + ), + ''); + ?> - - - - + + + + - - - folder_translated; ?> - - install_type; ?> - - - detailsurl; ?> - infourl)) : ?> -
- escape($item->infourl); ?> -
-
+ folder_translated; ?> + + install_type; ?> + + + detailsurl; ?> + infourl)) : ?> +
+ escape($item->infourl); ?> + +
+
- +
diff --git a/libraries/src/Installer/Adapter/ComponentAdapter.php b/libraries/src/Installer/Adapter/ComponentAdapter.php index 977db8d39b170..dbc52729da0e8 100644 --- a/libraries/src/Installer/Adapter/ComponentAdapter.php +++ b/libraries/src/Installer/Adapter/ComponentAdapter.php @@ -13,6 +13,8 @@ use Joomla\CMS\Application\ApplicationHelper; use Joomla\CMS\Installer\Installer; use Joomla\CMS\Installer\InstallerAdapter; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Log\Log; use Joomla\CMS\Table\Asset; use Joomla\CMS\Table\Extension; use Joomla\CMS\Table\Table; @@ -587,11 +589,11 @@ public function prepareDiscoverInstall() $db = $this->db; $query = $db->getQuery(true) - ->select($db->qn('extension_id')) - ->from($db->qn('#__extensions')) - ->where($db->qn('name') . ' = ' . $db->q($this->extension->name)) - ->where($db->qn('type') . ' = ' . $db->q($this->extension->type)) - ->where($db->qn('element') . ' = ' . $db->q($this->extension->element)); + ->select($db->quoteName('extension_id')) + ->from($db->quoteName('#__extensions')) + ->where($db->quoteName('name') . ' = ' . $db->quote($this->extension->name)) + ->where($db->quoteName('type') . ' = ' . $db->quote($this->extension->type)) + ->where($db->quoteName('element') . ' = ' . $db->quote($this->extension->element)); $db->setQuery($query); @@ -774,11 +776,11 @@ protected function storeExtension($deleteExisting = false) $db = $this->parent->getDbo(); $query = $db->getQuery(true) - ->select($db->qn('extension_id')) - ->from($db->qn('#__extensions')) - ->where($db->qn('name') . ' = ' . $db->q($this->extension->name)) - ->where($db->qn('type') . ' = ' . $db->q($this->extension->type)) - ->where($db->qn('element') . ' = ' . $db->q($this->extension->element)); + ->select($db->quoteName('extension_id')) + ->from($db->quoteName('#__extensions')) + ->where($db->quoteName('name') . ' = ' . $db->quote($this->extension->name)) + ->where($db->quoteName('type') . ' = ' . $db->quote($this->extension->type)) + ->where($db->quoteName('element') . ' = ' . $db->quote($this->extension->element)); $db->setQuery($query); @@ -820,7 +822,7 @@ protected function storeExtension($deleteExisting = false) { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_COMP_INSTALL_ROLLBACK', $this->extension->getError() ) @@ -846,18 +848,27 @@ protected function storeExtension($deleteExisting = false) protected function _buildAdminMenus($component_id = null) { $db = $this->parent->getDbo(); - $option = $this->element; // If a component exists with this option in the table within the protected menutype 'main' then we don't need to add menus $query = $db->getQuery(true) - ->select('m.id, e.extension_id') - ->from('#__menu AS m') - ->join('LEFT', '#__extensions AS e ON m.component_id = e.extension_id') - ->where('m.parent_id = 1') - ->where('m.client_id = 1') - ->where('m.menutype = ' . $db->quote('main')) - ->where('e.element = ' . $db->quote($option)); + ->select( + $db->quoteName( + array( + 'm.id', + 'e.extension_id' + ) + ) + ) + ->from($db->quoteName('#__menu', 'm')) + ->leftJoin( + $db->quoteName('#__extensions', 'e') + . ' ON ' . $db->quoteName('m.component_id') . ' = ' . $db->quoteName('e.extension_id') + ) + ->where($db->quoteName('m.parent_id') . ' = 1') + ->where($db->quoteName('m.client_id') . ' = 1') + ->where($db->quoteName('m.menutype') . ' = ' . $db->quote('main')) + ->where($db->quoteName('e.element') . ' = ' . $db->quote($option)); $db->setQuery($query); @@ -890,10 +901,10 @@ protected function _buildAdminMenus($component_id = null) { // Lets find the extension id $query->clear() - ->select('e.extension_id') - ->from('#__extensions AS e') - ->where('e.type = ' . $db->quote('component')) - ->where('e.element = ' . $db->quote($option)); + ->select($db->quoteName('e.extension_id')) + ->from($db->quoteName('#__extensions', 'e')) + ->where($db->quoteName('e.type') . ' = ' . $db->quote('component')) + ->where($db->quoteName('e.element') . ' = ' . $db->quote($option)); $db->setQuery($query); $component_id = $db->loadResult(); @@ -920,37 +931,37 @@ protected function _buildAdminMenus($component_id = null) if ($menuElement) { // I have a menu element, use this information - $data['menutype'] = 'main'; - $data['client_id'] = 1; - $data['title'] = (string) trim($menuElement); - $data['alias'] = (string) $menuElement; - $data['link'] = 'index.php?option=' . $option; - $data['type'] = 'component'; - $data['published'] = 1; - $data['parent_id'] = 1; + $data['menutype'] = 'main'; + $data['client_id'] = 1; + $data['title'] = (string) trim($menuElement); + $data['alias'] = (string) $menuElement; + $data['link'] = 'index.php?option=' . $option; + $data['type'] = 'component'; + $data['published'] = 1; + $data['parent_id'] = 1; $data['component_id'] = $component_id; - $data['img'] = ((string) $menuElement->attributes()->img) ?: 'class:component'; - $data['home'] = 0; - $data['path'] = ''; - $data['params'] = ''; + $data['img'] = ((string) $menuElement->attributes()->img) ?: 'class:component'; + $data['home'] = 0; + $data['path'] = ''; + $data['params'] = ''; } else { // No menu element was specified, Let's make a generic menu item - $data = array(); - $data['menutype'] = 'main'; - $data['client_id'] = 1; - $data['title'] = $option; - $data['alias'] = $option; - $data['link'] = 'index.php?option=' . $option; - $data['type'] = 'component'; - $data['published'] = 1; - $data['parent_id'] = 1; + $data = array(); + $data['menutype'] = 'main'; + $data['client_id'] = 1; + $data['title'] = $option; + $data['alias'] = $option; + $data['link'] = 'index.php?option=' . $option; + $data['type'] = 'component'; + $data['published'] = 1; + $data['parent_id'] = 1; $data['component_id'] = $component_id; - $data['img'] = 'class:component'; - $data['home'] = 0; - $data['path'] = ''; - $data['params'] = ''; + $data['img'] = 'class:component'; + $data['home'] = 0; + $data['path'] = ''; + $data['params'] = ''; } // Try to create the menu item in the database @@ -973,17 +984,17 @@ protected function _buildAdminMenus($component_id = null) foreach ($this->getManifest()->administration->submenu->menu as $child) { - $data = array(); - $data['menutype'] = 'main'; - $data['client_id'] = 1; - $data['title'] = (string) trim($child); - $data['alias'] = (string) $child; - $data['type'] = 'component'; - $data['published'] = 1; - $data['parent_id'] = $parent_id; + $data = array(); + $data['menutype'] = 'main'; + $data['client_id'] = 1; + $data['title'] = (string) trim($child); + $data['alias'] = (string) $child; + $data['type'] = 'component'; + $data['published'] = 1; + $data['parent_id'] = $parent_id; $data['component_id'] = $component_id; - $data['img'] = ((string) $child->attributes()->img) ?: 'class:component'; - $data['home'] = 0; + $data['img'] = ((string) $child->attributes()->img) ?: 'class:component'; + $data['home'] = 0; // Set the sub menu link if ((string) $child->attributes()->link) @@ -1024,7 +1035,7 @@ protected function _buildAdminMenus($component_id = null) $request[] = 'sub=' . $child->attributes()->sub; } - $qstring = count($request) ? '&' . implode('&', $request) : ''; + $qstring = count($request) ? '&' . implode('&', $request) : ''; $data['link'] = 'index.php?option=' . $option . $qstring; } @@ -1052,6 +1063,8 @@ protected function _buildAdminMenus($component_id = null) * * @return boolean True if successful. * + * @throws \Exception + * * @since 3.1 */ protected function _removeAdminMenus($id) @@ -1063,16 +1076,15 @@ protected function _removeAdminMenus($id) // Get the ids of the menu items $query = $db->getQuery(true) - ->select('id') - ->from('#__menu') + ->select($db->quoteName('id')) + ->from($db->quoteName('#__menu')) ->where($db->quoteName('client_id') . ' = 1') - ->where($db->quoteName('menutype') . ' = ' . $db->q('main')) + ->where($db->quoteName('menutype') . ' = ' . $db->quote('main')) ->where($db->quoteName('component_id') . ' = ' . (int) $id); $db->setQuery($query); - $ids = $db->loadColumn(); - + $ids = $db->loadColumn(); $result = true; // Check for error @@ -1129,12 +1141,12 @@ protected function _updateMenus($component_id, $clientId = null) // Update all menu items which contain 'index.php?option=com_extension' or 'index.php?option=com_extension&...' // to use the new component id. $query = $db->getQuery(true) - ->update('#__menu') - ->set('component_id = ' . $db->quote($component_id)) - ->where('type = ' . $db->quote('component')) + ->update($db->quoteName('#__menu')) + ->set($db->quoteName('component_id') . ' = ' . $db->quote($component_id)) + ->where($db->quoteName('type') . ' = ' . $db->quote('component')) ->where('(' - . 'link LIKE ' . $db->quote('index.php?option=' . $option) . ' OR ' - . 'link LIKE ' . $db->q($db->escape('index.php?option=' . $option . '&') . '%', false) + . $db->quoteName('link') . ' LIKE ' . $db->quote('index.php?option=' . $option) . ' OR ' + . $db->quoteName('link') . ' LIKE ' . $db->quote($db->escape('index.php?option=' . $option . '&') . '%', false) . ')'); if (isset($clientId)) @@ -1164,6 +1176,8 @@ protected function _updateMenus($component_id, $clientId = null) * * @return boolean True on success * + * @throws \Exception + * * @since 3.1 */ protected function _rollback_menu($step) @@ -1180,8 +1194,8 @@ protected function _rollback_menu($step) */ public function discover() { - $results = array(); - $site_components = \JFolder::folders(JPATH_SITE . '/components'); + $results = array(); + $site_components = \JFolder::folders(JPATH_SITE . '/components'); $admin_components = \JFolder::folders(JPATH_ADMINISTRATOR . '/components'); foreach ($site_components as $component) @@ -1240,16 +1254,16 @@ public function discover() public function refreshManifestCache() { // Need to find to find where the XML file is since we don't store this normally - $client = ApplicationHelper::getClientInfo($this->parent->extension->client_id); - $short_element = str_replace('com_', '', $this->parent->extension->element); - $manifestPath = $client->path . '/components/' . $this->parent->extension->element . '/' . $short_element . '.xml'; + $client = ApplicationHelper::getClientInfo($this->parent->extension->client_id); + $short_element = str_replace('com_', '', $this->parent->extension->element); + $manifestPath = $client->path . '/components/' . $this->parent->extension->element . '/' . $short_element . '.xml'; $this->parent->manifest = $this->parent->isManifest($manifestPath); $this->parent->setPath('manifest', $manifestPath); - $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); + $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); $this->parent->extension->manifest_cache = json_encode($manifest_details); - $this->parent->extension->name = $manifest_details['name']; - $this->parent->extension->namespace = $manifest_details['namespace']; + $this->parent->extension->name = $manifest_details['name']; + $this->parent->extension->namespace = $manifest_details['namespace']; try { @@ -1257,7 +1271,7 @@ public function refreshManifestCache() } catch (\RuntimeException $e) { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_COMP_REFRESH_MANIFEST_CACHE'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_COMP_REFRESH_MANIFEST_CACHE'), Log::WARNING, 'jerror'); return false; } @@ -1270,6 +1284,10 @@ public function refreshManifestCache() * @param integer $parentId The parent menu item ID * * @return bool|int Menu item ID on success, false on failure + * + * @throws \Exception + * + * @since 3.1 */ protected function _createAdminMenuItem(array &$data, $parentId) { @@ -1295,12 +1313,12 @@ protected function _createAdminMenuItem(array &$data, $parentId) $query = $db->getQuery(true) ->select('id') ->from('#__menu') - ->where('menutype = ' . $db->q($data['menutype'])) + ->where('menutype = ' . $db->quote($data['menutype'])) ->where('client_id = 1') - ->where('link = ' . $db->q($data['link'])) - ->where('type = ' . $db->q($data['type'])) - ->where('parent_id = ' . $db->q($data['parent_id'])) - ->where('home = ' . $db->q($data['home'])); + ->where('link = ' . $db->quote($data['link'])) + ->where('type = ' . $db->quote($data['type'])) + ->where('parent_id = ' . $db->quote($data['parent_id'])) + ->where('home = ' . $db->quote($data['home'])); $db->setQuery($query); $menu_id = $db->loadResult(); diff --git a/libraries/src/Installer/Adapter/FileAdapter.php b/libraries/src/Installer/Adapter/FileAdapter.php index 5289da2793452..4a0541056cfff 100644 --- a/libraries/src/Installer/Adapter/FileAdapter.php +++ b/libraries/src/Installer/Adapter/FileAdapter.php @@ -12,6 +12,8 @@ use Joomla\CMS\Installer\Installer; use Joomla\CMS\Installer\InstallerAdapter; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Log\Log; use Joomla\CMS\Table\Table; \JLoader::import('joomla.filesystem.folder'); @@ -62,7 +64,7 @@ protected function copyBaseFiles() if (!$created = \JFolder::create($folder)) { throw new \RuntimeException( - \JText::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_FAIL_SOURCE_DIRECTORY', $folder) + Text::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_FAIL_SOURCE_DIRECTORY', $folder) ); } @@ -112,7 +114,7 @@ protected function finaliseInstall() if (!$this->parent->copyFiles(array($manifest), true)) { // Install failed, rollback changes - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_FILE_INSTALL_COPY_SETUP')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_FILE_INSTALL_COPY_SETUP')); } // If there is a manifest script, let's copy it. @@ -133,9 +135,9 @@ protected function finaliseInstall() { // Install failed, rollback changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_MANIFEST', - \JText::_('JLIB_INSTALLER_' . strtoupper($this->route)) + Text::_('JLIB_INSTALLER_' . strtoupper($this->route)) ) ); } @@ -338,7 +340,7 @@ protected function setupUninstall() // Remove this row entry since its invalid $this->extension->delete($this->extension->extension_id); - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_INVALID_NOTFOUND_MANIFEST')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_INVALID_NOTFOUND_MANIFEST')); } // Set the files root path @@ -352,13 +354,13 @@ protected function setupUninstall() // If we cannot load the XML file return null if (!$xml) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_LOAD_MANIFEST')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_LOAD_MANIFEST')); } // Check for a valid XML root tag. if ($xml->getName() != 'extension') { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_INVALID_MANIFEST')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_INVALID_MANIFEST')); } $this->setManifest($xml); @@ -392,9 +394,9 @@ protected function storeExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_ROLLBACK', - \JText::_('JLIB_INSTALLER_' . strtoupper($this->route)), + Text::_('JLIB_INSTALLER_' . strtoupper($this->route)), $this->extension->getError() ) ); @@ -423,9 +425,9 @@ protected function storeExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_ROLLBACK', - \JText::_('JLIB_INSTALLER_' . strtoupper($this->route)), + Text::_('JLIB_INSTALLER_' . strtoupper($this->route)), $this->extension->getError() ) ); @@ -530,7 +532,7 @@ protected function populateFilesAndFolderList() // Check if source folder exists if (!\JFolder::exists($sourceFolder)) { - \JLog::add(\JText::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_FAIL_SOURCE_DIRECTORY', $sourceFolder), \JLog::WARNING, 'jerror'); + Log::add(Text::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_FAIL_SOURCE_DIRECTORY', $sourceFolder), Log::WARNING, 'jerror'); // If installation fails, rollback $this->parent->abort(); @@ -597,7 +599,7 @@ public function refreshManifestCache() } catch (\RuntimeException $e) { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_PACK_REFRESH_MANIFEST_CACHE'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_PACK_REFRESH_MANIFEST_CACHE'), Log::WARNING, 'jerror'); return false; } diff --git a/libraries/src/Installer/Adapter/LanguageAdapter.php b/libraries/src/Installer/Adapter/LanguageAdapter.php index 578da3a4d382a..0381459e32c95 100644 --- a/libraries/src/Installer/Adapter/LanguageAdapter.php +++ b/libraries/src/Installer/Adapter/LanguageAdapter.php @@ -16,6 +16,8 @@ use Joomla\CMS\Installer\InstallerAdapter; use Joomla\CMS\Language\Language; use Joomla\CMS\Language\LanguageHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Log\Log; use Joomla\CMS\Table\Table; use Joomla\CMS\Table\Update; use Joomla\Registry\Registry; @@ -158,7 +160,7 @@ protected function finaliseUninstall(): bool if (!empty($count)) { - \JLog::add(\JText::plural('JLIB_INSTALLER_NOTICE_LANG_RESET_USERS', $count), \JLog::NOTICE, 'jerror'); + Log::add(Text::plural('JLIB_INSTALLER_NOTICE_LANG_RESET_USERS', $count), Log::NOTICE, 'jerror'); } // Remove the extension table entry @@ -185,7 +187,7 @@ protected function removeExtensionFiles() if (!\JFolder::delete($path)) { // If deleting failed we'll leave the extension entry in tact just in case - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_LANG_UNINSTALL_DIRECTORY'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_LANG_UNINSTALL_DIRECTORY'), Log::WARNING, 'jerror'); $this->ignoreUninstallQueries = true; } @@ -218,7 +220,7 @@ protected function setupUninstall() // Check the element isn't blank to prevent nuking the languages directory...just in case if (empty($this->extension->element)) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_LANG_UNINSTALL_ELEMENT_EMPTY')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_LANG_UNINSTALL_ELEMENT_EMPTY')); } // Verify that it's not the default language for that client @@ -226,7 +228,7 @@ protected function setupUninstall() if ($params->get($client->name) === $this->extension->element) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_LANG_UNINSTALL_DEFAULT')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_LANG_UNINSTALL_DEFAULT')); } // Construct the path from the client, the language and the extension element name @@ -241,7 +243,7 @@ protected function setupUninstall() // If the folder doesn't exist lets just nuke the row as well and presume the user killed it for us $this->extension->delete(); - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_LANG_UNINSTALL_PATH_EMPTY')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_LANG_UNINSTALL_PATH_EMPTY')); } // We do findManifest to avoid problem when uninstalling a list of extension: getManifest cache its manifest file @@ -296,7 +298,7 @@ public function install() if ($client === null) { - $this->parent->abort(\JText::sprintf('JLIB_INSTALLER_ABORT', \JText::sprintf('JLIB_INSTALLER_ERROR_UNKNOWN_CLIENT_TYPE', $cname))); + $this->parent->abort(Text::sprintf('JLIB_INSTALLER_ABORT', Text::sprintf('JLIB_INSTALLER_ERROR_UNKNOWN_CLIENT_TYPE', $cname))); return false; } @@ -345,7 +347,7 @@ protected function _install($cname, $basePath, $clientId, &$element) // Check if we found the tag - if we didn't, we may be trying to install from an older language package if (!$tag) { - $this->parent->abort(\JText::sprintf('JLIB_INSTALLER_ABORT', \JText::_('JLIB_INSTALLER_ERROR_NO_LANGUAGE_TAG'))); + $this->parent->abort(Text::sprintf('JLIB_INSTALLER_ABORT', Text::_('JLIB_INSTALLER_ERROR_NO_LANGUAGE_TAG'))); return false; } @@ -379,9 +381,9 @@ protected function _install($cname, $basePath, $clientId, &$element) { $this->parent ->abort( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT', - \JText::sprintf('JLIB_INSTALLER_ERROR_CREATE_FOLDER_FAILED', $this->parent->getPath('extension_site')) + Text::sprintf('JLIB_INSTALLER_ERROR_CREATE_FOLDER_FAILED', $this->parent->getPath('extension_site')) ) ); @@ -406,19 +408,19 @@ protected function _install($cname, $basePath, $clientId, &$element) if (file_exists($this->parent->getPath('extension_site'))) { // If the site exists say so. - \JLog::add( - \JText::sprintf('JLIB_INSTALLER_ABORT', \JText::sprintf('JLIB_INSTALLER_ERROR_FOLDER_IN_USE', $this->parent->getPath('extension_site'))), - \JLog::WARNING, 'jerror' + Log::add( + Text::sprintf('JLIB_INSTALLER_ABORT', Text::sprintf('JLIB_INSTALLER_ERROR_FOLDER_IN_USE', $this->parent->getPath('extension_site'))), + Log::WARNING, 'jerror' ); } else { // If the admin exists say so. - \JLog::add( - \JText::sprintf('JLIB_INSTALLER_ABORT', - \JText::sprintf('JLIB_INSTALLER_ERROR_FOLDER_IN_USE', $this->parent->getPath('extension_administrator')) + Log::add( + Text::sprintf('JLIB_INSTALLER_ABORT', + Text::sprintf('JLIB_INSTALLER_ERROR_FOLDER_IN_USE', $this->parent->getPath('extension_administrator')) ), - \JLog::WARNING, 'jerror' + Log::WARNING, 'jerror' ); } @@ -467,7 +469,7 @@ protected function _install($cname, $basePath, $clientId, &$element) if ($description) { - $this->parent->set('message', \JText::_($description)); + $this->parent->set('message', Text::_($description)); } else { @@ -493,7 +495,7 @@ protected function _install($cname, $basePath, $clientId, &$element) if (!$row->check() || !$row->store()) { // Install failed, roll back changes - $this->parent->abort(\JText::sprintf('JLIB_INSTALLER_ABORT', $row->getError())); + $this->parent->abort(Text::sprintf('JLIB_INSTALLER_ABORT', $row->getError())); return false; } @@ -562,9 +564,9 @@ protected function _install($cname, $basePath, $clientId, &$element) if (!$tableLanguage->bind($languageData) || !$tableLanguage->check() || !$tableLanguage->store() || !$tableLanguage->reorder()) { - \JLog::add( - \JText::sprintf('JLIB_INSTALLER_WARNING_UNABLE_TO_INSTALL_CONTENT_LANGUAGE', $siteLanguageManifest['name'], $tableLanguage->getError()), - \JLog::NOTICE, + Log::add( + Text::sprintf('JLIB_INSTALLER_WARNING_UNABLE_TO_INSTALL_CONTENT_LANGUAGE', $siteLanguageManifest['name'], $tableLanguage->getError()), + Log::NOTICE, 'jerror' ); } @@ -647,7 +649,7 @@ public function update() if ($client === null || (empty($cname) && $cname !== 0)) { - $this->parent->abort(\JText::sprintf('JLIB_INSTALLER_ABORT', \JText::sprintf('JLIB_INSTALLER_ERROR_UNKNOWN_CLIENT_TYPE', $cname))); + $this->parent->abort(Text::sprintf('JLIB_INSTALLER_ABORT', Text::sprintf('JLIB_INSTALLER_ERROR_UNKNOWN_CLIENT_TYPE', $cname))); return false; } @@ -667,7 +669,7 @@ public function update() // Check if we found the tag - if we didn't, we may be trying to install from an older language package if (!$tag) { - $this->parent->abort(\JText::sprintf('JLIB_INSTALLER_ABORT', \JText::_('JLIB_INSTALLER_ERROR_NO_LANGUAGE_TAG'))); + $this->parent->abort(Text::sprintf('JLIB_INSTALLER_ABORT', Text::_('JLIB_INSTALLER_ERROR_NO_LANGUAGE_TAG'))); return false; } @@ -767,7 +769,7 @@ public function update() if (!$row->check() || !$row->store()) { // Install failed, roll back changes - $this->parent->abort(\JText::sprintf('JLIB_INSTALLER_ABORT', $row->getError())); + $this->parent->abort(Text::sprintf('JLIB_INSTALLER_ABORT', $row->getError())); return false; } @@ -785,8 +787,8 @@ public function update() */ public function discover() { - $results = array(); - $site_languages = \JFolder::folders(JPATH_SITE . '/language'); + $results = array(); + $site_languages = \JFolder::folders(JPATH_SITE . '/language'); $admin_languages = \JFolder::folders(JPATH_ADMINISTRATOR . '/language'); foreach ($site_languages as $language) @@ -839,18 +841,18 @@ public function discover() public function discover_install() { // Need to find to find where the XML file is since we don't store this normally - $client = ApplicationHelper::getClientInfo($this->parent->extension->client_id); - $short_element = $this->parent->extension->element; - $manifestPath = $client->path . '/language/' . $short_element . '/' . $short_element . '.xml'; + $client = ApplicationHelper::getClientInfo($this->parent->extension->client_id); + $short_element = $this->parent->extension->element; + $manifestPath = $client->path . '/language/' . $short_element . '/' . $short_element . '.xml'; $this->parent->manifest = $this->parent->isManifest($manifestPath); $this->parent->setPath('manifest', $manifestPath); $this->parent->setPath('source', $client->path . '/language/' . $short_element); $this->parent->setPath('extension_root', $this->parent->getPath('source')); - $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); + $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); $this->parent->extension->manifest_cache = json_encode($manifest_details); - $this->parent->extension->state = 0; - $this->parent->extension->name = $manifest_details['name']; - $this->parent->extension->enabled = 1; + $this->parent->extension->state = 0; + $this->parent->extension->name = $manifest_details['name']; + $this->parent->extension->enabled = 1; // @todo remove code: $this->parent->extension->params = $this->parent->getParams(); try @@ -860,7 +862,7 @@ public function discover_install() } catch (\RuntimeException $e) { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_LANG_DISCOVER_STORE_DETAILS'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_LANG_DISCOVER_STORE_DETAILS'), Log::WARNING, 'jerror'); return false; } @@ -880,13 +882,13 @@ public function discover_install() */ public function refreshManifestCache() { - $client = ApplicationHelper::getClientInfo($this->parent->extension->client_id); - $manifestPath = $client->path . '/language/' . $this->parent->extension->element . '/' . $this->parent->extension->element . '.xml'; + $client = ApplicationHelper::getClientInfo($this->parent->extension->client_id); + $manifestPath = $client->path . '/language/' . $this->parent->extension->element . '/' . $this->parent->extension->element . '.xml'; $this->parent->manifest = $this->parent->isManifest($manifestPath); $this->parent->setPath('manifest', $manifestPath); - $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); + $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); $this->parent->extension->manifest_cache = json_encode($manifest_details); - $this->parent->extension->name = $manifest_details['name']; + $this->parent->extension->name = $manifest_details['name']; if ($this->parent->extension->store()) { @@ -894,7 +896,7 @@ public function refreshManifestCache() } else { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_MOD_REFRESH_MANIFEST_CACHE'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_MOD_REFRESH_MANIFEST_CACHE'), Log::WARNING, 'jerror'); return false; } diff --git a/libraries/src/Installer/Adapter/LibraryAdapter.php b/libraries/src/Installer/Adapter/LibraryAdapter.php index 2250a00376577..c2c2c9cecbd12 100644 --- a/libraries/src/Installer/Adapter/LibraryAdapter.php +++ b/libraries/src/Installer/Adapter/LibraryAdapter.php @@ -10,9 +10,14 @@ defined('JPATH_PLATFORM') or die; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Path; +use Joomla\CMS\Filter\InputFilter; use Joomla\CMS\Installer\Installer; use Joomla\CMS\Installer\InstallerAdapter; use Joomla\CMS\Installer\Manifest\LibraryManifest; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Log\Log; use Joomla\CMS\Table\Table; use Joomla\CMS\Table\Update; @@ -55,7 +60,7 @@ protected function checkExtensionInFilesystem() else { // Abort the install, no upgrade possible - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_LIB_INSTALL_ALREADY_INSTALLED')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_LIB_INSTALL_ALREADY_INSTALLED')); } } } @@ -72,7 +77,7 @@ protected function copyBaseFiles() { if ($this->parent->parseFiles($this->getManifest()->files, -1) === false) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_LIB_COPY_FILES')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_LIB_COPY_FILES')); } } @@ -89,10 +94,10 @@ protected function finaliseInstall() // Clobber any possible pending updates /** @var Update $update */ $update = Table::getInstance('update'); - $uid = $update->find( + $uid = $update->find( array( 'element' => $this->element, - 'type' => $this->type, + 'type' => $this->type, ) ); @@ -104,20 +109,20 @@ protected function finaliseInstall() // Lastly, we will copy the manifest file to its appropriate place. if ($this->route !== 'discover_install') { - $manifest = array(); - $manifest['src'] = $this->parent->getPath('manifest'); + $manifest = array(); + $manifest['src'] = $this->parent->getPath('manifest'); $manifest['dest'] = JPATH_MANIFESTS . '/libraries/' . basename($this->parent->getPath('manifest')); if (!$this->parent->copyFiles(array($manifest), true)) { // Install failed, rollback changes - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_LIB_INSTALL_COPY_SETUP')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_LIB_INSTALL_COPY_SETUP')); } // If there is a manifest script, let's copy it. if ($this->manifest_script) { - $path['src'] = $this->parent->getPath('source') . '/' . $this->manifest_script; + $path['src'] = $this->parent->getPath('source') . '/' . $this->manifest_script; $path['dest'] = $this->parent->getPath('extension_root') . '/' . $this->manifest_script; if ($this->parent->isOverwrite() || !file_exists($path['dest'])) @@ -126,9 +131,9 @@ protected function finaliseInstall() { // Install failed, rollback changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_MANIFEST', - \JText::_('JLIB_INSTALLER_' . strtoupper($this->route)) + Text::_('JLIB_INSTALLER_' . strtoupper($this->route)) ) ); } @@ -151,10 +156,9 @@ protected function finaliseUninstall(): bool // Remove the schema version $query = $db->getQuery(true) - ->delete('#__schemas') - ->where('extension_id = ' . $this->extension->extension_id); - $db->setQuery($query); - $db->execute(); + ->delete($db->quoteName('#__schemas')) + ->where($db->quoteName('extension_id') . ' = ' . (int) $this->extension->extension_id); + $db->setQuery($query)->execute(); // Clobber any possible pending updates $update = Table::getInstance('update'); @@ -188,7 +192,7 @@ public function getElement($element = null) { if (!$element) { - $manifestPath = \JPath::clean($this->parent->getPath('manifest')); + $manifestPath = Path::clean($this->parent->getPath('manifest')); $element = preg_replace('/\.xml/', '', basename($manifestPath)); } @@ -213,9 +217,9 @@ public function loadLanguage($path = null) $this->parent->setPath('source', JPATH_PLATFORM . '/' . $this->getElement()); } - $extension = 'lib_' . $this->getElement(); + $extension = 'lib_' . $this->getElement(); $librarypath = (string) $this->getManifest()->libraryname; - $source = $path ?: JPATH_PLATFORM . '/' . $librarypath; + $source = $path ?: JPATH_PLATFORM . '/' . $librarypath; $this->doLoadLanguage($extension, $source, JPATH_SITE); } @@ -242,7 +246,7 @@ protected function parseOptionalTags() */ public function prepareDiscoverInstall() { - $manifestPath = JPATH_MANIFESTS . '/libraries/' . $this->extension->element . '.xml'; + $manifestPath = JPATH_MANIFESTS . '/libraries/' . $this->extension->element . '.xml'; $this->parent->manifest = $this->parent->isManifest($manifestPath); $this->parent->setPath('manifest', $manifestPath); $this->setManifest($this->parent->getManifest()); @@ -294,7 +298,7 @@ protected function setupInstallPaths() if (!$group) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_LIB_INSTALL_NOFILE')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_LIB_INSTALL_NOFILE')); } $this->parent->setPath('extension_root', JPATH_PLATFORM . '/' . implode(DIRECTORY_SEPARATOR, explode('/', $group))); @@ -317,7 +321,7 @@ protected function setupUninstall() // Remove this row entry since its invalid $this->extension->delete($this->extension->extension_id); - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_LIB_UNINSTALL_INVALID_NOTFOUND_MANIFEST')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_LIB_UNINSTALL_INVALID_NOTFOUND_MANIFEST')); } $manifest = new LibraryManifest($manifestFile); @@ -333,13 +337,13 @@ protected function setupUninstall() // If we cannot load the XML file return null if (!$xml) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_LIB_UNINSTALL_LOAD_MANIFEST')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_LIB_UNINSTALL_LOAD_MANIFEST')); } // Check for a valid XML root tag. if ($xml->getName() !== 'extension') { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_LIB_UNINSTALL_INVALID_MANIFEST')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_LIB_UNINSTALL_INVALID_MANIFEST')); } $this->setManifest($xml); @@ -364,15 +368,15 @@ protected function storeExtension() $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); $this->extension->manifest_cache = json_encode($manifest_details); - $this->extension->state = 0; - $this->extension->name = $manifest_details['name']; - $this->extension->enabled = 1; - $this->extension->params = $this->parent->getParams(); + $this->extension->state = 0; + $this->extension->name = $manifest_details['name']; + $this->extension->enabled = 1; + $this->extension->params = $this->parent->getParams(); if (!$this->extension->store()) { // Install failed, roll back changes - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_LIB_DISCOVER_STORE_DETAILS')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_LIB_DISCOVER_STORE_DETAILS')); } return; @@ -398,7 +402,7 @@ protected function storeExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_LIB_INSTALL_ROLLBACK', $this->extension->getError() ) @@ -437,8 +441,8 @@ public function update() */ // Set the extensions name - $name = (string) $this->getManifest()->name; - $name = \JFilterInput::getInstance()->clean($name, 'string'); + $name = (string) $this->getManifest()->name; + $name = InputFilter::getInstance()->clean($name, 'string'); $element = str_replace('.xml', '', basename($this->parent->getPath('manifest'))); $this->name = $name; @@ -446,8 +450,8 @@ public function update() // We don't want to compromise this instance! $installer = new Installer; - $db = $this->parent->getDbo(); - $query = $db->getQuery(true) + $db = $this->parent->getDbo(); + $query = $db->getQuery(true) ->select($db->quoteName('extension_id')) ->from($db->quoteName('#__extensions')) ->where($db->quoteName('type') . ' = ' . $db->quote('library')) @@ -463,7 +467,7 @@ public function update() // Clear the cached data $this->currentExtensionId = null; - $this->extension = Table::getInstance('Extension', 'JTable', array('dbo' => $this->db)); + $this->extension = Table::getInstance('Extension', 'JTable', array('dbo' => $this->db)); } // Now create the new files @@ -485,8 +489,8 @@ public function discover() foreach ($file_list as $file) { $manifest_details = Installer::parseXMLInstallFile(JPATH_MANIFESTS . '/libraries/' . $file); - $file = \JFile::stripExt($file); - $extension = Table::getInstance('extension'); + $file = File::stripExt($file); + $extension = Table::getInstance('extension'); $extension->set('type', 'library'); $extension->set('client_id', 0); $extension->set('element', $file); @@ -511,13 +515,13 @@ public function discover() public function refreshManifestCache() { // Need to find to find where the XML file is since we don't store this normally - $manifestPath = JPATH_MANIFESTS . '/libraries/' . $this->parent->extension->element . '.xml'; + $manifestPath = JPATH_MANIFESTS . '/libraries/' . $this->parent->extension->element . '.xml'; $this->parent->manifest = $this->parent->isManifest($manifestPath); $this->parent->setPath('manifest', $manifestPath); - $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); + $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); $this->parent->extension->manifest_cache = json_encode($manifest_details); - $this->parent->extension->name = $manifest_details['name']; + $this->parent->extension->name = $manifest_details['name']; try { @@ -525,7 +529,7 @@ public function refreshManifestCache() } catch (\RuntimeException $e) { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_LIB_REFRESH_MANIFEST_CACHE'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_LIB_REFRESH_MANIFEST_CACHE'), Log::WARNING, 'jerror'); return false; } diff --git a/libraries/src/Installer/Adapter/ModuleAdapter.php b/libraries/src/Installer/Adapter/ModuleAdapter.php index 3d4bb90f57b68..65f7bfc19b586 100644 --- a/libraries/src/Installer/Adapter/ModuleAdapter.php +++ b/libraries/src/Installer/Adapter/ModuleAdapter.php @@ -13,6 +13,7 @@ use Joomla\CMS\Application\ApplicationHelper; use Joomla\CMS\Installer\Installer; use Joomla\CMS\Installer\InstallerAdapter; +use Joomla\CMS\Language\Text; use Joomla\CMS\Table\Table; use Joomla\Utilities\ArrayHelper; @@ -65,9 +66,9 @@ protected function checkExistingExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_ROLLBACK', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $e->getMessage() ), $e->getCode(), @@ -89,7 +90,7 @@ protected function copyBaseFiles() // Copy all necessary files if ($this->parent->parseFiles($this->getManifest()->files, -1) === false) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_MOD_COPY_FILES')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_MOD_COPY_FILES')); } // If there is a manifest script, let's copy it. @@ -103,7 +104,7 @@ protected function copyBaseFiles() if (!$this->parent->copyFiles(array($path))) { // Install failed, rollback changes - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_MOD_INSTALL_MANIFEST')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_MOD_INSTALL_MANIFEST')); } } } @@ -196,7 +197,7 @@ protected function finaliseInstall() if (!$this->parent->copyManifest(-1)) { // Install failed, rollback changes - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_MOD_INSTALL_COPY_SETUP')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_MOD_INSTALL_COPY_SETUP')); } } } @@ -257,7 +258,7 @@ protected function finaliseUninstall(): bool } catch (\RuntimeException $e) { - \JLog::add(\JText::sprintf('JLIB_INSTALLER_ERROR_MOD_UNINSTALL_EXCEPTION', $e->getMessage()), \JLog::WARNING, 'jerror'); + \JLog::add(Text::sprintf('JLIB_INSTALLER_ERROR_MOD_UNINSTALL_EXCEPTION', $e->getMessage()), \JLog::WARNING, 'jerror'); $retval = false; } @@ -271,7 +272,7 @@ protected function finaliseUninstall(): bool if (!$module->delete()) { - \JLog::add(\JText::sprintf('JLIB_INSTALLER_ERROR_MOD_UNINSTALL_EXCEPTION', $module->getError()), \JLog::WARNING, 'jerror'); + \JLog::add(Text::sprintf('JLIB_INSTALLER_ERROR_MOD_UNINSTALL_EXCEPTION', $module->getError()), \JLog::WARNING, 'jerror'); $retval = false; } } @@ -430,7 +431,7 @@ public function refreshManifestCache() } else { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_MOD_REFRESH_MANIFEST_CACHE'), \JLog::WARNING, 'jerror'); + \JLog::add(Text::_('JLIB_INSTALLER_ERROR_MOD_REFRESH_MANIFEST_CACHE'), \JLog::WARNING, 'jerror'); return false; } @@ -471,9 +472,9 @@ protected function setupInstallPaths() if ($client === false) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_MOD_UNKNOWN_CLIENT', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $client->name ) ); @@ -493,9 +494,9 @@ protected function setupInstallPaths() if (empty($this->element)) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_MOD_INSTALL_NOFILE', - \JText::_('JLIB_INSTALLER_' . $this->route) + Text::_('JLIB_INSTALLER_' . $this->route) ) ); } @@ -519,7 +520,7 @@ protected function setupUninstall() if ($client === false) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ERROR_MOD_UNINSTALL_UNKNOWN_CLIENT', $this->extension->client_id ) @@ -563,7 +564,7 @@ protected function storeExtension() if (!$this->extension->store()) { // Install failed, roll back changes - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_MOD_DISCOVER_STORE_DETAILS')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_MOD_DISCOVER_STORE_DETAILS')); } return; @@ -576,9 +577,9 @@ protected function storeExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_MOD_INSTALL_ALLREADY_EXISTS', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $this->name ) ); @@ -600,9 +601,9 @@ protected function storeExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_MOD_ROLLBACK', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $this->extension->getError() ) ); @@ -631,9 +632,9 @@ protected function storeExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_MOD_ROLLBACK', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $this->extension->getError() ) ); @@ -649,7 +650,7 @@ protected function storeExtension() ); // Create unpublished module - $name = preg_replace('#[\*?]#', '', \JText::_($this->name)); + $name = preg_replace('#[\*?]#', '', Text::_($this->name)); /** @var \JTableModule $module */ $module = Table::getInstance('module'); diff --git a/libraries/src/Installer/Adapter/PackageAdapter.php b/libraries/src/Installer/Adapter/PackageAdapter.php index c32f5ad5e771c..bd551c4cf51a0 100644 --- a/libraries/src/Installer/Adapter/PackageAdapter.php +++ b/libraries/src/Installer/Adapter/PackageAdapter.php @@ -15,6 +15,8 @@ use Joomla\CMS\Installer\InstallerAdapter; use Joomla\CMS\Installer\InstallerHelper; use Joomla\CMS\Installer\Manifest\PackageManifest; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Log\Log; use Joomla\CMS\Table\Table; use Joomla\CMS\Table\Update; use Joomla\Event\Event; @@ -86,9 +88,9 @@ protected function checkExtensionInFilesystem() { // We didn't have overwrite set, find an update function or find an update tag so lets call it safe throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_DIRECTORY', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $this->type, $this->parent->getPath('extension_root') ) @@ -119,8 +121,8 @@ protected function copyBaseFiles() if (!count($this->getManifest()->files->children())) { throw new \RuntimeException( - \JText::sprintf('JLIB_INSTALLER_ABORT_PACK_INSTALL_NO_FILES', - \JText::_('JLIB_INSTALLER_' . strtoupper($this->route)) + Text::sprintf('JLIB_INSTALLER_ABORT_PACK_INSTALL_NO_FILES', + Text::_('JLIB_INSTALLER_' . strtoupper($this->route)) ) ); } @@ -156,9 +158,9 @@ protected function copyBaseFiles() if (!$installResult) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_PACK_INSTALL_ERROR_EXTENSION', - \JText::_('JLIB_INSTALLER_' . strtoupper($this->route)), + Text::_('JLIB_INSTALLER_' . strtoupper($this->route)), basename($file) ) ); @@ -227,7 +229,7 @@ protected function finaliseInstall() } catch (\JDatabaseExceptionExecuting $e) { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_PACK_SETTING_PACKAGE_ID'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_PACK_SETTING_PACKAGE_ID'), Log::WARNING, 'jerror'); } } @@ -240,9 +242,9 @@ protected function finaliseInstall() { // Install failed, rollback changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_PACK_INSTALL_COPY_SETUP', - \JText::_('JLIB_INSTALLER_ABORT_PACK_INSTALL_NO_FILES') + Text::_('JLIB_INSTALLER_ABORT_PACK_INSTALL_NO_FILES') ) ); } @@ -256,9 +258,9 @@ protected function finaliseInstall() if (!\JFolder::create($this->parent->getPath('extension_root'))) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_CREATE_DIRECTORY', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $this->parent->getPath('extension_root') ) ); @@ -286,7 +288,7 @@ protected function finaliseInstall() if (!$this->parent->copyFiles(array($path))) { // Install failed, rollback changes - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_PACKAGE_INSTALL_MANIFEST')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_PACKAGE_INSTALL_MANIFEST')); } } } @@ -429,12 +431,12 @@ protected function removeExtensionFiles() if (!$tmpInstaller->uninstall($extension->type, $id)) { $error = true; - \JLog::add(\JText::sprintf('JLIB_INSTALLER_ERROR_PACK_UNINSTALL_NOT_PROPER', basename($extension->filename)), \JLog::WARNING, 'jerror'); + Log::add(Text::sprintf('JLIB_INSTALLER_ERROR_PACK_UNINSTALL_NOT_PROPER', basename($extension->filename)), Log::WARNING, 'jerror'); } } else { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_PACK_UNINSTALL_UNKNOWN_EXTENSION'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_PACK_UNINSTALL_UNKNOWN_EXTENSION'), Log::WARNING, 'jerror'); } } @@ -444,7 +446,7 @@ protected function removeExtensionFiles() // Clean up manifest file after we're done if there were no errors if ($error) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_PACK_UNINSTALL_MANIFEST_NOT_REMOVED')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_PACK_UNINSTALL_MANIFEST_NOT_REMOVED')); } } @@ -463,9 +465,9 @@ protected function setupInstallPaths() if (empty($packagepath)) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_PACK_INSTALL_NO_PACK', - \JText::_('JLIB_INSTALLER_' . strtoupper($this->route)) + Text::_('JLIB_INSTALLER_' . strtoupper($this->route)) ) ); } @@ -494,20 +496,20 @@ protected function setupUninstall() // Because packages may not have their own folders we cannot use the standard method of finding an installation manifest if (!file_exists($manifestFile)) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_PACK_UNINSTALL_MISSINGMANIFEST')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_PACK_UNINSTALL_MISSINGMANIFEST')); } $xml = simplexml_load_file($manifestFile); if (!$xml) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_PACK_UNINSTALL_LOAD_MANIFEST')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_PACK_UNINSTALL_LOAD_MANIFEST')); } // Check for a valid XML root tag. if ($xml->getName() !== 'extension') { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_PACK_UNINSTALL_INVALID_MANIFEST')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_PACK_UNINSTALL_INVALID_MANIFEST')); } $this->setManifest($xml); @@ -532,9 +534,9 @@ protected function storeExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_ALREADY_EXISTS', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $this->name ) ); @@ -566,7 +568,7 @@ protected function storeExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_PACK_INSTALL_ROLLBACK', $this->extension->getError() ) @@ -602,9 +604,9 @@ protected function triggerManifestScript($method) { // The script failed, rollback changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_INSTALL_CUSTOM_INSTALL_FAILURE', - \JText::_('JLIB_INSTALLER_' . $this->route) + Text::_('JLIB_INSTALLER_' . $this->route) ) ); } @@ -627,9 +629,9 @@ protected function triggerManifestScript($method) { // The script failed, rollback changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_INSTALL_CUSTOM_INSTALL_FAILURE', - \JText::_('JLIB_INSTALLER_' . $this->route) + Text::_('JLIB_INSTALLER_' . $this->route) ) ); } @@ -668,10 +670,10 @@ protected function _getExtensionId($type, $id, $client, $group) $db = $this->parent->getDbo(); $query = $db->getQuery(true) - ->select('extension_id') - ->from('#__extensions') - ->where('type = ' . $db->quote($type)) - ->where('element = ' . $db->quote($id)); + ->select($db->quoteName('extension_id')) + ->from($db->quoteName('#__extensions')) + ->where($db->quoteName('type') . ' = ' . $db->quote($type)) + ->where($db->quoteName('element') . ' = ' . $db->quote($id)); switch ($type) { @@ -728,7 +730,7 @@ public function refreshManifestCache() } catch (\RuntimeException $e) { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_PACK_REFRESH_MANIFEST_CACHE'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_PACK_REFRESH_MANIFEST_CACHE'), Log::WARNING, 'jerror'); return false; } diff --git a/libraries/src/Installer/Adapter/PluginAdapter.php b/libraries/src/Installer/Adapter/PluginAdapter.php index b5b6004b266f6..a0128cc41bd85 100644 --- a/libraries/src/Installer/Adapter/PluginAdapter.php +++ b/libraries/src/Installer/Adapter/PluginAdapter.php @@ -13,6 +13,8 @@ use Joomla\CMS\Application\ApplicationHelper; use Joomla\CMS\Installer\Installer; use Joomla\CMS\Installer\InstallerAdapter; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Log\Log; use Joomla\CMS\Table\Table; use Joomla\CMS\Table\Update; @@ -61,9 +63,9 @@ protected function checkExistingExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_ROLLBACK', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $e->getMessage() ), $e->getCode(), @@ -86,9 +88,9 @@ protected function copyBaseFiles() if ($this->parent->parseFiles($this->getManifest()->files, -1, $this->oldFiles) === false) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_PLG_COPY_FILES', - \JText::_('JLIB_INSTALLER_' . $this->route) + Text::_('JLIB_INSTALLER_' . $this->route) ) ); } @@ -105,9 +107,9 @@ protected function copyBaseFiles() { // Install failed, rollback changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_PLG_INSTALL_MANIFEST', - \JText::_('JLIB_INSTALLER_' . $this->route) + Text::_('JLIB_INSTALLER_' . $this->route) ) ); } @@ -178,9 +180,9 @@ protected function finaliseInstall() { // Install failed, rollback changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_PLG_INSTALL_COPY_SETUP', - \JText::_('JLIB_INSTALLER_' . $this->route) + Text::_('JLIB_INSTALLER_' . $this->route) ) ); } @@ -201,10 +203,9 @@ protected function finaliseUninstall(): bool // Remove the schema version $query = $db->getQuery(true) - ->delete('#__schemas') - ->where('extension_id = ' . $this->extension->extension_id); - $db->setQuery($query); - $db->execute(); + ->delete($db->quoteName('#__schemas')) + ->where($db->quoteName('extension_id') . ' = ' . $this->extension->extension_id); + $db->setQuery($query)->execute(); // Now we will no longer need the plugin object, so let's delete it $this->extension->delete($this->extension->extension_id); @@ -382,9 +383,9 @@ protected function setupInstallPaths() if (empty($this->element) && empty($this->group)) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_PLG_INSTALL_NO_FILE', - \JText::_('JLIB_INSTALLER_' . $this->route) + Text::_('JLIB_INSTALLER_' . $this->route) ) ); } @@ -404,7 +405,7 @@ protected function setupUninstall() // Get the plugin folder so we can properly build the plugin path if (trim($this->extension->folder) === '') { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_PLG_UNINSTALL_FOLDER_FIELD_EMPTY')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_PLG_UNINSTALL_FOLDER_FIELD_EMPTY')); } // Set the plugin root path @@ -437,15 +438,15 @@ protected function storeExtension() $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); $this->extension->manifest_cache = json_encode($manifest_details); - $this->extension->state = 0; - $this->extension->name = $manifest_details['name']; - $this->extension->enabled = 'editors' === $this->extension->folder ? 1 : 0; - $this->extension->params = $this->parent->getParams(); + $this->extension->state = 0; + $this->extension->name = $manifest_details['name']; + $this->extension->enabled = 'editors' === $this->extension->folder ? 1 : 0; + $this->extension->params = $this->parent->getParams(); if (!$this->extension->store()) { // Install failed, roll back changes - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_PLG_DISCOVER_STORE_DETAILS')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_PLG_DISCOVER_STORE_DETAILS')); } return; @@ -458,9 +459,9 @@ protected function storeExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_PLG_INSTALL_ALLREADY_EXISTS', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $this->name ) ); @@ -501,9 +502,9 @@ protected function storeExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_PLG_INSTALL_ROLLBACK', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $this->extension->getError() ) ); @@ -624,7 +625,7 @@ public function refreshManifestCache() } else { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_PLG_REFRESH_MANIFEST_CACHE'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_PLG_REFRESH_MANIFEST_CACHE'), Log::WARNING, 'jerror'); return false; } diff --git a/libraries/src/Installer/Adapter/TemplateAdapter.php b/libraries/src/Installer/Adapter/TemplateAdapter.php index 853426f4ff371..8f6730fff9d77 100644 --- a/libraries/src/Installer/Adapter/TemplateAdapter.php +++ b/libraries/src/Installer/Adapter/TemplateAdapter.php @@ -13,6 +13,8 @@ use Joomla\CMS\Application\ApplicationHelper; use Joomla\CMS\Installer\Installer; use Joomla\CMS\Installer\InstallerAdapter; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Log\Log; use Joomla\CMS\Table\Table; use Joomla\CMS\Table\Update; @@ -57,9 +59,9 @@ protected function checkExistingExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_ROLLBACK', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $e->getMessage() ), $e->getCode(), @@ -82,7 +84,7 @@ protected function copyBaseFiles() if ($this->parent->parseFiles($this->getManifest()->files, -1) === false) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_TPL_INSTALL_COPY_FILES', 'files' ) @@ -92,7 +94,7 @@ protected function copyBaseFiles() if ($this->parent->parseFiles($this->getManifest()->images, -1) === false) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_TPL_INSTALL_COPY_FILES', 'images' ) @@ -102,7 +104,7 @@ protected function copyBaseFiles() if ($this->parent->parseFiles($this->getManifest()->css, -1) === false) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_TPL_INSTALL_COPY_FILES', 'css' ) @@ -120,9 +122,9 @@ protected function copyBaseFiles() if (!$this->parent->copyFiles(array($path))) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_MANIFEST', - \JText::_('JLIB_INSTALLER_' . strtoupper($this->getRoute())) + Text::_('JLIB_INSTALLER_' . strtoupper($this->getRoute())) ) ); } @@ -163,7 +165,7 @@ protected function finaliseInstall() if (!$this->parent->copyManifest(-1)) { // Install failed, rollback changes - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_TPL_INSTALL_COPY_SETUP')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_TPL_INSTALL_COPY_SETUP')); } } } @@ -305,7 +307,7 @@ protected function parseQueries() $values = array( $db->quote($this->extension->element), $this->extension->client_id, $db->quote(0), - $db->quote(\JText::sprintf('JLIB_INSTALLER_DEFAULT_STYLE', \JText::_($this->extension->name))), + $db->quote(Text::sprintf('JLIB_INSTALLER_DEFAULT_STYLE', Text::_($this->extension->name))), $db->quote($this->extension->params), ); @@ -331,8 +333,8 @@ protected function parseQueries() */ public function prepareDiscoverInstall() { - $client = ApplicationHelper::getClientInfo($this->extension->client_id); - $manifestPath = $client->path . '/templates/' . $this->extension->element . '/templateDetails.xml'; + $client = ApplicationHelper::getClientInfo($this->extension->client_id); + $manifestPath = $client->path . '/templates/' . $this->extension->element . '/templateDetails.xml'; $this->parent->manifest = $this->parent->isManifest($manifestPath); $this->parent->setPath('manifest', $manifestPath); $this->setManifest($this->parent->getManifest()); @@ -359,7 +361,7 @@ protected function removeExtensionFiles() } else { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_TEMPLATE_DIRECTORY'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_TEMPLATE_DIRECTORY'), Log::WARNING, 'jerror'); } } @@ -383,16 +385,16 @@ protected function setupInstallPaths() if ($client === false) { - throw new \RuntimeException(\JText::sprintf('JLIB_INSTALLER_ABORT_TPL_INSTALL_UNKNOWN_CLIENT', $cname)); + throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_TPL_INSTALL_UNKNOWN_CLIENT', $cname)); } - $basePath = $client->path; + $basePath = $client->path; $this->clientId = $client->id; } else { // No client attribute was found so we assume the site as the client - $basePath = JPATH_SITE; + $basePath = JPATH_SITE; $this->clientId = 0; } @@ -400,9 +402,9 @@ protected function setupInstallPaths() if (empty($this->element)) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_MOD_INSTALL_NOFILE', - \JText::_('JLIB_INSTALLER_' . strtoupper($this->route)) + Text::_('JLIB_INSTALLER_' . strtoupper($this->route)) ) ); } @@ -427,7 +429,7 @@ protected function setupUninstall() // For a template the id will be the template name which represents the subfolder of the templates folder that the template resides in. if (!$name) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_TEMPLATE_ID_EMPTY')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_TEMPLATE_ID_EMPTY')); } // Deny remove default template @@ -441,7 +443,7 @@ protected function setupUninstall() if ($db->loadResult() != 0) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_TEMPLATE_DEFAULT')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_TEMPLATE_DEFAULT')); } // Get the template root path @@ -449,7 +451,7 @@ protected function setupUninstall() if (!$client) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_INVALID_CLIENT')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_INVALID_CLIENT')); } $this->parent->setPath('extension_root', $client->path . '/templates/' . strtolower($name)); @@ -467,7 +469,7 @@ protected function setupUninstall() // Make sure we delete the folders \JFolder::delete($this->parent->getPath('extension_root')); - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_INVALID_NOTFOUND_MANIFEST')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_INVALID_NOTFOUND_MANIFEST')); } // Attempt to load the language file; might have uninstall strings @@ -498,7 +500,7 @@ protected function storeExtension() if (!$this->extension->store()) { // Install failed, roll back changes - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ERROR_TPL_DISCOVER_STORE_DETAILS')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_TPL_DISCOVER_STORE_DETAILS')); } return; @@ -511,7 +513,7 @@ protected function storeExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::_('JLIB_INSTALLER_ABORT_TPL_INSTALL_ALREADY_INSTALLED') + Text::_('JLIB_INSTALLER_ABORT_TPL_INSTALL_ALREADY_INSTALLED') ); } @@ -544,9 +546,9 @@ protected function storeExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_ROLLBACK', - \JText::_('JLIB_INSTALLER_' . strtoupper($this->route)), + Text::_('JLIB_INSTALLER_' . strtoupper($this->route)), $this->extension->getError() ) ); @@ -560,10 +562,10 @@ protected function storeExtension() */ public function discover() { - $results = array(); - $site_list = \JFolder::folders(JPATH_SITE . '/templates'); + $results = array(); + $site_list = \JFolder::folders(JPATH_SITE . '/templates'); $admin_list = \JFolder::folders(JPATH_ADMINISTRATOR . '/templates'); - $site_info = ApplicationHelper::getClientInfo('site', true); + $site_info = ApplicationHelper::getClientInfo('site', true); $admin_info = ApplicationHelper::getClientInfo('administrator', true); foreach ($site_list as $template) @@ -577,7 +579,7 @@ public function discover() } $manifest_details = Installer::parseXMLInstallFile(JPATH_SITE . "/templates/$template/templateDetails.xml"); - $extension = Table::getInstance('extension'); + $extension = Table::getInstance('extension'); $extension->set('type', 'template'); $extension->set('client_id', $site_info->id); $extension->set('element', $template); @@ -601,7 +603,7 @@ public function discover() } $manifest_details = Installer::parseXMLInstallFile(JPATH_ADMINISTRATOR . "/templates/$template/templateDetails.xml"); - $extension = Table::getInstance('extension'); + $extension = Table::getInstance('extension'); $extension->set('type', 'template'); $extension->set('client_id', $admin_info->id); $extension->set('element', $template); @@ -627,14 +629,14 @@ public function discover() public function refreshManifestCache() { // Need to find to find where the XML file is since we don't store this normally. - $client = ApplicationHelper::getClientInfo($this->parent->extension->client_id); - $manifestPath = $client->path . '/templates/' . $this->parent->extension->element . '/templateDetails.xml'; + $client = ApplicationHelper::getClientInfo($this->parent->extension->client_id); + $manifestPath = $client->path . '/templates/' . $this->parent->extension->element . '/templateDetails.xml'; $this->parent->manifest = $this->parent->isManifest($manifestPath); $this->parent->setPath('manifest', $manifestPath); - $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); + $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); $this->parent->extension->manifest_cache = json_encode($manifest_details); - $this->parent->extension->name = $manifest_details['name']; + $this->parent->extension->name = $manifest_details['name']; try { @@ -642,7 +644,7 @@ public function refreshManifestCache() } catch (\RuntimeException $e) { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_TPL_REFRESH_MANIFEST_CACHE'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_TPL_REFRESH_MANIFEST_CACHE'), Log::WARNING, 'jerror'); return false; } diff --git a/libraries/src/Installer/InstallerAdapter.php b/libraries/src/Installer/InstallerAdapter.php index 15adb33c2bcf4..151aff3b42eeb 100644 --- a/libraries/src/Installer/InstallerAdapter.php +++ b/libraries/src/Installer/InstallerAdapter.php @@ -9,6 +9,8 @@ namespace Joomla\CMS\Installer; use Joomla\CMS\Installer\Manifest\PackageManifest; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Log\Log; use Joomla\CMS\Table\Extension; use Joomla\CMS\Table\Table; use Joomla\CMS\Table\TableInterface; @@ -223,9 +225,9 @@ protected function checkExistingExtension() { // Install failed, roll back changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_ROLLBACK', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $e->getMessage() ), $e->getCode(), @@ -267,9 +269,9 @@ protected function checkExtensionInFilesystem() { // We didn't have overwrite set, find an update function or find an update tag so lets call it safe throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_DIRECTORY', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $this->type, $this->parent->getPath('extension_root') ) @@ -306,9 +308,9 @@ protected function createExtensionRoot() if (!$created = \JFolder::create($this->parent->getPath('extension_root'))) { throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_CREATE_DIRECTORY', - \JText::_('JLIB_INSTALLER_' . $this->route), + Text::_('JLIB_INSTALLER_' . $this->route), $this->parent->getPath('extension_root') ) ); @@ -346,7 +348,7 @@ public function discover_install() if ($description) { - $this->parent->message = \JText::_($description); + $this->parent->message = Text::_($description); } else { @@ -495,7 +497,7 @@ protected function doDatabaseTransactions() // Only rollback if installing if ($route === 'install') { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_INSTALL_ABORTED')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_INSTALL_ABORTED')); } return false; @@ -669,14 +671,11 @@ public function install() { // Get the extension's description $description = (string) $this->getManifest()->description; + $this->parent->message = ''; if ($description) { - $this->parent->message = \JText::_($description); - } - else - { - $this->parent->message = ''; + $this->parent->message = Text::_($description); } // Set the extension's name and element @@ -893,7 +892,7 @@ protected function parseQueries() // This method may throw an exception, but it is caught by the parent caller if (!$this->doDatabaseTransactions()) { - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_INSTALL_ABORTED')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_INSTALL_ABORTED')); } // Set the schema version to be the latest update version @@ -911,7 +910,7 @@ protected function parseQueries() if ($result === false) { // Install failed, rollback changes - throw new \RuntimeException(\JText::_('JLIB_INSTALLER_ABORT_INSTALL_ABORTED')); + throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_INSTALL_ABORTED')); } } } @@ -1085,9 +1084,9 @@ protected function triggerManifestScript($method) // The script failed, rollback changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_INSTALL_CUSTOM_INSTALL_FAILURE', - \JText::_('JLIB_INSTALLER_' . $this->route) + Text::_('JLIB_INSTALLER_' . $this->route) ) ); } @@ -1107,9 +1106,9 @@ protected function triggerManifestScript($method) // The script failed, rollback changes throw new \RuntimeException( - \JText::sprintf( + Text::sprintf( 'JLIB_INSTALLER_ABORT_INSTALL_CUSTOM_INSTALL_FAILURE', - \JText::_('JLIB_INSTALLER_' . $this->route) + Text::_('JLIB_INSTALLER_' . $this->route) ) ); } @@ -1143,7 +1142,7 @@ public function uninstall($id) { if (!$this->extension->load((int) $id)) { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_UNKNOWN_EXTENSION'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_UNKNOWN_EXTENSION'), Log::WARNING, 'jerror'); return false; } @@ -1151,7 +1150,7 @@ public function uninstall($id) // Protected extensions cannot be removed if ($this->extension->protected) { - \JLog::add(\JText::_('JLIB_INSTALLER_ERROR_UNINSTALL_PROTECTED_EXTENSION'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_UNINSTALL_PROTECTED_EXTENSION'), Log::WARNING, 'jerror'); return false; } @@ -1162,9 +1161,9 @@ public function uninstall($id) */ if ($this->extension->package_id && !$this->parent->isPackageUninstall() && !$this->canUninstallPackageChild($this->extension->package_id)) { - \JLog::add( - \JText::sprintf('JLIB_INSTALLER_ERROR_CANNOT_UNINSTALL_CHILD_OF_PACKAGE', $this->extension->name), - \JLog::WARNING, + Log::add( + Text::sprintf('JLIB_INSTALLER_ERROR_CANNOT_UNINSTALL_CHILD_OF_PACKAGE', $this->extension->name), + Log::WARNING, 'jerror' ); @@ -1178,7 +1177,7 @@ public function uninstall($id) } catch (\RuntimeException $e) { - \JLog::add($e->getMessage(), \JLog::WARNING, 'jerror'); + Log::add($e->getMessage(), Log::WARNING, 'jerror'); return false; } @@ -1201,7 +1200,7 @@ public function uninstall($id) } catch (\RuntimeException $e) { - \JLog::add($e->getMessage(), \JLog::WARNING, 'jerror'); + Log::add($e->getMessage(), Log::WARNING, 'jerror'); return false; } @@ -1230,7 +1229,7 @@ public function uninstall($id) } catch (\RuntimeException $e) { - \JLog::add($e->getMessage(), \JLog::WARNING, 'jerror'); + Log::add($e->getMessage(), Log::WARNING, 'jerror'); $retval = false; } @@ -1247,7 +1246,7 @@ public function uninstall($id) } catch (\RuntimeException $e) { - \JLog::add($e->getMessage(), \JLog::WARNING, 'jerror'); + Log::add($e->getMessage(), Log::WARNING, 'jerror'); $retval = false; } @@ -1264,7 +1263,7 @@ public function uninstall($id) } catch (\RuntimeException $e) { - \JLog::add($e->getMessage(), \JLog::WARNING, 'jerror'); + Log::add($e->getMessage(), Log::WARNING, 'jerror'); $retval = false; } @@ -1276,7 +1275,7 @@ public function uninstall($id) } catch (\RuntimeException $e) { - \JLog::add($e->getMessage(), \JLog::WARNING, 'jerror'); + Log::add($e->getMessage(), Log::WARNING, 'jerror'); $retval = false; } From f4574963a6a0722cface8ae79a994fbec8de8d7f Mon Sep 17 00:00:00 2001 From: Roland Dalmulder Date: Mon, 2 Jul 2018 08:39:43 +0200 Subject: [PATCH 28/30] Use namespaced Log --- libraries/src/Installer/Adapter/ModuleAdapter.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/src/Installer/Adapter/ModuleAdapter.php b/libraries/src/Installer/Adapter/ModuleAdapter.php index 65f7bfc19b586..677af341dd388 100644 --- a/libraries/src/Installer/Adapter/ModuleAdapter.php +++ b/libraries/src/Installer/Adapter/ModuleAdapter.php @@ -14,6 +14,7 @@ use Joomla\CMS\Installer\Installer; use Joomla\CMS\Installer\InstallerAdapter; use Joomla\CMS\Language\Text; +use Joomla\CMS\Log\Log; use Joomla\CMS\Table\Table; use Joomla\Utilities\ArrayHelper; @@ -258,7 +259,7 @@ protected function finaliseUninstall(): bool } catch (\RuntimeException $e) { - \JLog::add(Text::sprintf('JLIB_INSTALLER_ERROR_MOD_UNINSTALL_EXCEPTION', $e->getMessage()), \JLog::WARNING, 'jerror'); + Log::add(Text::sprintf('JLIB_INSTALLER_ERROR_MOD_UNINSTALL_EXCEPTION', $e->getMessage()), Log::WARNING, 'jerror'); $retval = false; } @@ -272,7 +273,7 @@ protected function finaliseUninstall(): bool if (!$module->delete()) { - \JLog::add(Text::sprintf('JLIB_INSTALLER_ERROR_MOD_UNINSTALL_EXCEPTION', $module->getError()), \JLog::WARNING, 'jerror'); + Log::add(Text::sprintf('JLIB_INSTALLER_ERROR_MOD_UNINSTALL_EXCEPTION', $module->getError()), Log::WARNING, 'jerror'); $retval = false; } } @@ -431,7 +432,7 @@ public function refreshManifestCache() } else { - \JLog::add(Text::_('JLIB_INSTALLER_ERROR_MOD_REFRESH_MANIFEST_CACHE'), \JLog::WARNING, 'jerror'); + Log::add(Text::_('JLIB_INSTALLER_ERROR_MOD_REFRESH_MANIFEST_CACHE'), Log::WARNING, 'jerror'); return false; } From b934fa7f073e4ae27f73671b4d3f1e01ad4b91d5 Mon Sep 17 00:00:00 2001 From: Roland Dalmulder Date: Mon, 2 Jul 2018 08:47:39 +0200 Subject: [PATCH 29/30] Fix language entry --- administrator/language/en-GB/en-GB.com_installer.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/en-GB.com_installer.ini b/administrator/language/en-GB/en-GB.com_installer.ini index 87fe84540f39e..4db12216f249f 100644 --- a/administrator/language/en-GB/en-GB.com_installer.ini +++ b/administrator/language/en-GB/en-GB.com_installer.ini @@ -9,7 +9,7 @@ COM_INSTALLER_CACHETIMEOUT_LABEL="Updates Caching (in hours)" COM_INSTALLER_CHANGELOG="Changelog" COM_INSTALLER_CHANGELOG_SECURITY="Security Fixes" COM_INSTALLER_CHANGELOG_FIX="Bug Fixes" -COM_INSTALLER_CHANGELOG_LANGUAGE="Changelog" +COM_INSTALLER_CHANGELOG_LANGUAGE="Language" COM_INSTALLER_CHANGELOG_ADDITION="New Features" COM_INSTALLER_CHANGELOG_CHANGE="Changes" COM_INSTALLER_CHANGELOG_REMOVED="Removed Features" From 541e07e8fcc5bec764d6026cb193e2fcc4c8283d Mon Sep 17 00:00:00 2001 From: Roland Dalmulder Date: Mon, 2 Jul 2018 19:07:37 +0200 Subject: [PATCH 30/30] Code style fixes --- .../components/com_installer/tmpl/manage/default.php | 6 +++--- .../components/com_installer/tmpl/update/default.php | 8 ++++---- administrator/language/en-GB/en-GB.com_installer.ini | 8 ++++---- libraries/src/Installer/Adapter/LanguageAdapter.php | 8 +++----- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/administrator/components/com_installer/tmpl/manage/default.php b/administrator/components/com_installer/tmpl/manage/default.php index 72830972a6b98..a46961112caa2 100644 --- a/administrator/components/com_installer/tmpl/manage/default.php +++ b/administrator/components/com_installer/tmpl/manage/default.php @@ -107,8 +107,8 @@ type_translated; ?>
- version != ''): ?> - changelogurl != null): ?> + version !== '') : ?> + changelogurl !== null) : ?> version?> @@ -125,7 +125,7 @@ version; ?> -
+ pagination->getListFooter(); ?>
- changelogurl != null):?> + changelogurl != null) : ?> changelogurl . '">'); ?> - + - + diff --git a/administrator/language/en-GB/en-GB.com_installer.ini b/administrator/language/en-GB/en-GB.com_installer.ini index 4db12216f249f..b9d4541065596 100644 --- a/administrator/language/en-GB/en-GB.com_installer.ini +++ b/administrator/language/en-GB/en-GB.com_installer.ini @@ -7,13 +7,13 @@ COM_INSTALLER="Installer" COM_INSTALLER_AUTHOR_INFORMATION="Author Information" COM_INSTALLER_CACHETIMEOUT_LABEL="Updates Caching (in hours)" COM_INSTALLER_CHANGELOG="Changelog" -COM_INSTALLER_CHANGELOG_SECURITY="Security Fixes" -COM_INSTALLER_CHANGELOG_FIX="Bug Fixes" -COM_INSTALLER_CHANGELOG_LANGUAGE="Language" COM_INSTALLER_CHANGELOG_ADDITION="New Features" COM_INSTALLER_CHANGELOG_CHANGE="Changes" -COM_INSTALLER_CHANGELOG_REMOVED="Removed Features" +COM_INSTALLER_CHANGELOG_FIX="Bug Fixes" +COM_INSTALLER_CHANGELOG_LANGUAGE="Language" COM_INSTALLER_CHANGELOG_NOTE="Notes" +COM_INSTALLER_CHANGELOG_REMOVED="Removed Features" +COM_INSTALLER_CHANGELOG_SECURITY="Security Fixes" COM_INSTALLER_CONFIGURATION="Installer: Options" COM_INSTALLER_CONFIRM_UNINSTALL="Are you sure you want to uninstall? Confirming will permanently delete the selected item(s)!" COM_INSTALLER_CURRENT_VERSION="Installed" diff --git a/libraries/src/Installer/Adapter/LanguageAdapter.php b/libraries/src/Installer/Adapter/LanguageAdapter.php index 0381459e32c95..87569f4a19799 100644 --- a/libraries/src/Installer/Adapter/LanguageAdapter.php +++ b/libraries/src/Installer/Adapter/LanguageAdapter.php @@ -894,11 +894,9 @@ public function refreshManifestCache() { return true; } - else - { - Log::add(Text::_('JLIB_INSTALLER_ERROR_MOD_REFRESH_MANIFEST_CACHE'), Log::WARNING, 'jerror'); - return false; - } + Log::add(Text::_('JLIB_INSTALLER_ERROR_MOD_REFRESH_MANIFEST_CACHE'), Log::WARNING, 'jerror'); + + return false; } }