From 6186bfe022bfd60e4241170b91aebae592c21548 Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Fri, 25 Jun 2021 17:04:12 +0700 Subject: [PATCH] Convert weblinks system plugin --- src/plugins/system/weblinks/weblinks.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/plugins/system/weblinks/weblinks.php b/src/plugins/system/weblinks/weblinks.php index ef3f33a..76ffde5 100644 --- a/src/plugins/system/weblinks/weblinks.php +++ b/src/plugins/system/weblinks/weblinks.php @@ -9,13 +9,25 @@ defined('_JEXEC') or die; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Plugin\CMSPlugin; + /** * System plugin for Joomla Web Links. * * @since __DEPLOY_VERSION__ */ -class PlgSystemWeblinks extends JPlugin +class PlgSystemWeblinks extends CMSPlugin { + /** + * Database Driver Instance + * + * @var \Joomla\Database\DatabaseDriver + * @since 4.0.0 + */ + protected $db; + /** * Load the language file on instantiation. * @@ -51,17 +63,16 @@ class PlgSystemWeblinks extends JPlugin return array(); } - if (!JComponentHelper::isEnabled('com_weblinks')) + if (!ComponentHelper::isEnabled('com_weblinks')) { return array(); } - $db = JFactory::getDbo(); - $query = $db->getQuery(true) + $query = $this->db->getQuery(true) ->select('COUNT(id) AS count_links') ->from('#__weblinks') ->where('state = 1'); - $webLinks = $db->setQuery($query)->loadResult(); + $webLinks = $this->db->setQuery($query)->loadResult(); if (!$webLinks) { @@ -69,7 +80,7 @@ class PlgSystemWeblinks extends JPlugin } return array(array( - 'title' => JText::_('PLG_SYSTEM_WEBLINKS_STATISTICS'), + 'title' => Text::_('PLG_SYSTEM_WEBLINKS_STATISTICS'), 'icon' => 'out-2', 'data' => $webLinks ));