This commit is contained in:
2024-12-31 11:07:09 +01:00
parent df7915205d
commit e089172b15
1916 changed files with 165422 additions and 271 deletions

View File

@ -0,0 +1,208 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Finder.highlight
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Component\ComponentHelper;
use \Joomla\CMS\Table\Table;
use \Joomla\Component\Finder\Administrator\Indexer\Adapter;
use \Joomla\Component\Finder\Administrator\Indexer\Helper;
use \Joomla\Component\Finder\Administrator\Indexer\Indexer;
use \Joomla\Component\Finder\Administrator\Indexer\Result;
use \Joomla\Database\DatabaseQuery;
use \Joomla\Registry\Registry;
use \Joomla\CMS\Router\Route;
/**
* highlight finder plugin.
*
* @package Joomla.Plugin
* @since 1.0.0
*/
class PlgFinderHighlightshighlights extends Adapter
{
/**
* The plugin identifier.
*
* @var string
* @since 1.0.0
*/
protected $context = 'Highlight';
/**
* The extension name.
*
* @var string
* @since 1.0.0
*/
protected $extension = 'com_highlights';
/**
* The sublayout to use when rendering the results.
*
* @var string
* @since 1.0.0
*/
protected $layout = 'highlight';
/**
* The type of highlight that the adapter indexes.
*
* @var string
* @since 1.0.0
*/
protected $type_title = 'Highlight';
/**
* The table name.
*
* @var string
* @since 1.0.0
*/
protected $table = '#__highlights_';
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 1.0.0
*/
protected $autoloadLanguage = true;
/**
* Method to setup the indexer to be run.
*
* @return boolean True on success.
*
* @since 2.5
*/
protected function setup()
{
return true;
}
/**
* Smart Search after save highlight method.
* Reindexes the link information for an highlight that has been saved.
* It also makes adjustments if the access level of an item or the
* category to which it belongs has changed.
*
* @param string $context The context of the highlight passed to the plugin.
* @param Table $row A Table object.
* @param boolean $isNew True if the highlight has just been created.
*
* @return void
*
* @since 1.0.0
* @throws Exception on database error.
*/
public function onFinderAfterSave($context, $row, $isNew): void
{
// We only want to handle highlight here.
if ($context === 'com_highlights.highlight')
{
// Reindex the item.
$this->reindex($row->id);
}
}
/**
* Method to update the link information for items that have been changed
* from outside the edit screen. This is fired when the item is published,
* unpublished, archived, or unarchived from the list view.
*
* @param string $context The context for the highlight passed to the plugin.
* @param array $pks An array of primary key ids of the highlight that has changed state.
* @param integer $value The value of the state that the highlight has been changed to.
*
* @return void
*
* @since 1.0.0
*/
public function onFinderChangeState($context, $pks, $value)
{
// We only want to handle highlight here.
if ($context === 'com_highlights.highlight')
{
$this->itemStateChange($pks, $value);
}
}
/**
* Method to get a SQL query to load the published and access states for
* an highlight and category.
*
* @return QueryInterface A database object.
*
* @since 1.0.0
*/
protected function getStateQuery()
{
$query = $this->db->getQuery(true);
// Item ID
$query->select('a.id');
$query->select('1 AS access');
$query->from($this->table . ' AS a');
return $query;
}
/**
* Method to index an item. The item must be a Result object.
*
* @param Result $item The item to index as a Result object.
*
* @return void
*
* @since 1.0.0
* @throws Exception on database error.
*/
protected function index(Result $item)
{
$item->setLanguage();
// Check if the extension is enabled.
if (ComponentHelper::isEnabled($this->extension) === false)
{
return;
}
$item->url = $this->getUrl($item->id, $this->extension, $this->layout);
$item->route = $item->url;
$item->context = 'com_highlights.highlight';
$this->indexer->index($item);
}
/**
* Method to get the SQL query used to retrieve the list of highlight items.
*
* @param mixed $query A DatabaseQuery object or null.
*
* @return DatabaseQuery A database object.
*
* @since 1.0.0
*/
protected function getListQuery($query = null)
{
$db = $this->db;
// Check if we can use the supplied SQL query.
$query = $query instanceof DatabaseQuery ? $query : $db->getQuery(true)
->select('a.id, a.titolo AS title, a.titolo AS summary, a.state AS state, 1 AS access');
$query->from($this->table . ' as a');
return $query;
}
}

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="4.0" type="plugin" group="finder">
<name>plg_finder_highlightshighlights</name>
<author>Eddy Prosperi</author>
<creationDate>2024-12-30</creationDate>
<copyright>2024 Eddy Prosperi</copyright>
<license>GNU General Public License versione 2 o successiva; vedi LICENSE.txt</license>
<authorEmail>eddy.prosperi@protocollicreativi.it</authorEmail>
<authorUrl>http://</authorUrl>
<version>CVS: 1.0.0</version>
<description>PLG_FINDER_COM_HIGHLIGHTS_XML_DESCRIPTION</description>
<files>
<filename plugin="highlightshighlights">highlightshighlights.php</filename>
<filename>index.html</filename>
</files>
<languages folder="languages">
<language tag="en-GB">en-GB/plg_finder_highlightshighlights.ini</language>
<language tag="en-GB">en-GB/plg_finder_highlightshighlights.sys.ini</language>
<language tag="it-IT">it-IT/plg_finder_highlightshighlights.ini</language>
<language tag="it-IT">it-IT/plg_finder_highlightshighlights.sys.ini</language>
</languages>
<config>
</config>
<updateservers>
<server type="extension" priority="1" name="com_highlights">https://www.component-creator.com/index.php?task=builder.preupdatecheckhook&amp;option=com_combuilder&amp;component=NzY0NzgtMjEzOTAw</server>
</updateservers>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>