30
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-06-26 01:32:35 +00:00

Convert weblinks finder plugin

This commit is contained in:
Tuan Pham Ngoc 2021-06-25 16:49:01 +07:00
parent 23650d0891
commit 13c2dc32da

View File

@ -9,17 +9,19 @@
defined('JPATH_BASE') or die; defined('JPATH_BASE') or die;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\Component\Finder\Administrator\Indexer\Adapter;
use Joomla\Component\Finder\Administrator\Indexer\Helper;
use Joomla\Component\Finder\Administrator\Indexer\Indexer;
use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
use Joomla\Registry\Registry; use Joomla\Registry\Registry;
// Load the base adapter.
JLoader::register('FinderIndexerAdapter', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php');
/** /**
* Smart Search adapter for Joomla Web Links. * Smart Search adapter for Joomla Web Links.
* *
* @since 2.5 * @since 2.5
*/ */
class PlgFinderWeblinks extends FinderIndexerAdapter class PlgFinderWeblinks extends Adapter
{ {
/** /**
* The plugin identifier. * The plugin identifier.
@ -245,7 +247,7 @@ class PlgFinderWeblinks extends FinderIndexerAdapter
protected function index(FinderIndexerResult $item, $format = 'html') protected function index(FinderIndexerResult $item, $format = 'html')
{ {
// Check if the extension is enabled // Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false) if (ComponentHelper::isEnabled($this->extension) == false)
{ {
return; return;
} }
@ -263,8 +265,8 @@ class PlgFinderWeblinks extends FinderIndexerAdapter
// Build the necessary route and path information. // Build the necessary route and path information.
$item->url = $this->getURL($item->id, $this->extension, $this->layout); $item->url = $this->getURL($item->id, $this->extension, $this->layout);
$item->route = WeblinksHelperRoute::getWeblinkRoute($item->slug, $item->catslug, $item->language); $item->route = RouteHelper::getWeblinkRoute($item->slug, $item->catslug, $item->language);
$item->path = FinderIndexerHelper::getContentPath($item->route); $item->path = Helper::getContentPath($item->route);
/* /*
* Add the meta-data processing instructions based on the newsfeeds * Add the meta-data processing instructions based on the newsfeeds
@ -274,12 +276,12 @@ class PlgFinderWeblinks extends FinderIndexerAdapter
$item->metaauthor = $item->metadata->get('author'); $item->metaauthor = $item->metadata->get('author');
// Handle the link to the meta-data. // Handle the link to the meta-data.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); $item->addInstruction(Indexer::META_CONTEXT, 'link');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); $item->addInstruction(Indexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); $item->addInstruction(Indexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); $item->addInstruction(Indexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); $item->addInstruction(Indexer::META_CONTEXT, 'author');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); $item->addInstruction(Indexer::META_CONTEXT, 'created_by_alias');
// Add the type taxonomy data. // Add the type taxonomy data.
$item->addTaxonomy('Type', 'Web Link'); $item->addTaxonomy('Type', 'Web Link');
@ -291,7 +293,7 @@ class PlgFinderWeblinks extends FinderIndexerAdapter
$item->addTaxonomy('Language', $item->language); $item->addTaxonomy('Language', $item->language);
// Get content extras. // Get content extras.
FinderIndexerHelper::getContentExtras($item); Helper::getContentExtras($item);
// Index the item. // Index the item.
$this->indexer->index($item); $this->indexer->index($item);
@ -306,9 +308,6 @@ class PlgFinderWeblinks extends FinderIndexerAdapter
*/ */
protected function setup() protected function setup()
{ {
// Load dependent classes.
require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php';
return true; return true;
} }
@ -323,7 +322,7 @@ class PlgFinderWeblinks extends FinderIndexerAdapter
*/ */
protected function getListQuery($query = null) protected function getListQuery($query = null)
{ {
$db = JFactory::getDbo(); $db = $this->db;
// Check if we can use the supplied SQL query. // Check if we can use the supplied SQL query.
$query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true) $query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true)