primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,198 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Search.categories
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php');
/**
* Categories search plugin.
*
* @since 1.6
*/
class PlgSearchCategories extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Determine areas searchable by this plugin.
*
* @return array An array of search areas.
*
* @since 1.6
*/
public function onContentSearchAreas()
{
static $areas = array(
'categories' => 'PLG_SEARCH_CATEGORIES_CATEGORIES'
);
return $areas;
}
/**
* Search content (categories).
*
* The SQL must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav.
*
* @param string $text Target search string.
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
* @param mixed $areas An array if the search is to be restricted to areas or null to search all areas.
*
* @return array Search results.
*
* @since 1.6
*/
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
$db = JFactory::getDbo();
$user = JFactory::getUser();
$app = JFactory::getApplication();
$groups = implode(',', $user->getAuthorisedViewLevels());
$searchText = $text;
if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas())))
{
return array();
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$state = array();
if ($sContent)
{
$state[] = 1;
}
if ($sArchived)
{
$state[] = 2;
}
if (empty($state))
{
return array();
}
$text = trim($text);
if ($text === '')
{
return array();
}
/* TODO: The $where variable does not seem to be used at all
switch ($phrase)
{
case 'exact':
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE ' . $text;
$wheres2[] = 'a.description LIKE ' . $text;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'any':
case 'all';
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word)
{
$word = $db->quote('%' . $db->escape($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE ' . $word;
$wheres2[] = 'a.description LIKE ' . $word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
*/
switch ($ordering)
{
case 'alpha':
$order = 'a.title ASC';
break;
case 'category':
case 'popular':
case 'newest':
case 'oldest':
default:
$order = 'a.title DESC';
}
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
$query = $db->getQuery(true);
// SQLSRV changes.
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$query->select('a.title, a.description AS text, a.created_time AS created, \'2\' AS browsernav, a.id AS catid, ' . $case_when)
->from('#__categories AS a')
->where(
'(a.title LIKE ' . $text . ' OR a.description LIKE ' . $text . ') AND a.published IN (' . implode(',', $state) . ') AND a.extension = '
. $db->quote('com_content') . 'AND a.access IN (' . $groups . ')'
)
->group('a.id, a.title, a.description, a.alias, a.created_time')
->order($order);
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$rows = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
$return = array();
if ($rows)
{
foreach ($rows as $i => $row)
{
if (searchHelper::checkNoHtml($row, $searchText, array('name', 'title', 'text')))
{
$row->href = ContentHelperRoute::getCategoryRoute($row->slug);
$row->section = JText::_('JCATEGORY');
$return[] = $row;
}
}
}
return $return;
}
}

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="search" method="upgrade">
<name>plg_search_categories</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>(C) 2005 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_SEARCH_CATEGORIES_XML_DESCRIPTION</description>
<files>
<filename plugin="categories">categories.php</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_search_categories.ini</language>
<language tag="en-GB">en-GB.plg_search_categories.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="search_limit"
type="number"
label="JFIELD_PLG_SEARCH_SEARCHLIMIT_LABEL"
description="JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC"
default="50"
filter="integer"
size="5"
/>
<field
name="search_content"
type="radio"
label="JFIELD_PLG_SEARCH_ALL_LABEL"
description="JFIELD_PLG_SEARCH_ALL_DESC"
class="btn-group btn-group-yesno"
default="0"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="search_archived"
type="radio"
label="JFIELD_PLG_SEARCH_ARCHIVED_LABEL"
description="JFIELD_PLG_SEARCH_ARCHIVED_DESC"
class="btn-group btn-group-yesno"
default="0"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,190 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Search.contacts
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Contacts search plugin.
*
* @since 1.6
*/
class PlgSearchContacts extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Determine areas searchable by this plugin.
*
* @return array An array of search areas.
*
* @since 1.6
*/
public function onContentSearchAreas()
{
static $areas = array(
'contacts' => 'PLG_SEARCH_CONTACTS_CONTACTS'
);
return $areas;
}
/**
* Search content (contacts).
*
* The SQL must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav.
*
* @param string $text Target search string.
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
* @param string $areas An array if the search is to be restricted to areas or null to search all areas.
*
* @return array Search results.
*
* @since 1.6
*/
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
JLoader::register('ContactHelperRoute', JPATH_SITE . '/components/com_contact/helpers/route.php');
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas())))
{
return array();
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$state = array();
if ($sContent)
{
$state[] = 1;
}
if ($sArchived)
{
$state[] = 2;
}
if (empty($state))
{
return array();
}
$text = trim($text);
if ($text === '')
{
return array();
}
$section = JText::_('PLG_SEARCH_CONTACTS_CONTACTS');
switch ($ordering)
{
case 'alpha':
$order = 'a.name ASC';
break;
case 'category':
$order = 'c.title ASC, a.name ASC';
break;
case 'popular':
case 'newest':
case 'oldest':
default:
$order = 'a.name DESC';
}
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
$query = $db->getQuery(true);
// SQLSRV changes.
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select(
'a.name AS title, \'\' AS created, a.con_position, a.misc, '
. $case_when . ',' . $case_when1 . ', '
. $query->concatenate(array('a.name', 'a.con_position', 'a.misc'), ',') . ' AS text,'
. $query->concatenate(array($db->quote($section), 'c.title'), ' / ') . ' AS section,'
. '\'2\' AS browsernav'
);
$query->from('#__contact_details AS a')
->join('INNER', '#__categories AS c ON c.id = a.catid')
->where(
'(a.name LIKE ' . $text . ' OR a.misc LIKE ' . $text . ' OR a.con_position LIKE ' . $text
. ' OR a.address LIKE ' . $text . ' OR a.suburb LIKE ' . $text . ' OR a.state LIKE ' . $text
. ' OR a.country LIKE ' . $text . ' OR a.postcode LIKE ' . $text . ' OR a.telephone LIKE ' . $text
. ' OR a.fax LIKE ' . $text . ') AND a.published IN (' . implode(',', $state) . ') AND c.published=1 '
. ' AND a.access IN (' . $groups . ') AND c.access IN (' . $groups . ')'
)
->order($order);
// Filter by language.
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$tag = JFactory::getLanguage()->getTag();
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')')
->where('c.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$rows = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
if ($rows)
{
foreach ($rows as $key => $row)
{
$rows[$key]->href = ContactHelperRoute::getContactRoute($row->slug, $row->catslug);
$rows[$key]->text = $row->title;
$rows[$key]->text .= $row->con_position ? ', ' . $row->con_position : '';
$rows[$key]->text .= $row->misc ? ', ' . $row->misc : '';
}
}
return $rows;
}
}

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="search" method="upgrade">
<name>plg_search_contacts</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>(C) 2005 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_SEARCH_CONTACTS_XML_DESCRIPTION</description>
<files>
<filename plugin="contacts">contacts.php</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_search_contacts.ini</language>
<language tag="en-GB">en-GB.plg_search_contacts.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="search_limit"
type="number"
label="JFIELD_PLG_SEARCH_SEARCHLIMIT_LABEL"
description="JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC"
default="50"
filter="integer"
size="5"
/>
<field
name="search_content"
type="radio"
label="JFIELD_PLG_SEARCH_ALL_LABEL"
description="JFIELD_PLG_SEARCH_ALL_DESC"
class="btn-group btn-group-yesno"
default="0"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="search_archived"
type="radio"
label="JFIELD_PLG_SEARCH_ARCHIVED_LABEL"
description="JFIELD_PLG_SEARCH_ARCHIVED_DESC"
class="btn-group btn-group-yesno"
default="0"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,440 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Search.content
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Content search plugin.
*
* @since 1.6
*/
class PlgSearchContent extends JPlugin
{
/**
* Determine areas searchable by this plugin.
*
* @return array An array of search areas.
*
* @since 1.6
*/
public function onContentSearchAreas()
{
static $areas = array(
'content' => 'JGLOBAL_ARTICLES'
);
return $areas;
}
/**
* Search content (articles).
* The SQL must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav.
*
* @param string $text Target search string.
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
* @param mixed $areas An array if the search it to be restricted to areas or null to search all areas.
*
* @return array Search results.
*
* @since 1.6
*/
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
$db = JFactory::getDbo();
$serverType = $db->getServerType();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$tag = JFactory::getLanguage()->getTag();
JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php');
JLoader::register('SearchHelper', JPATH_ADMINISTRATOR . '/components/com_search/helpers/search.php');
$searchText = $text;
if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas())))
{
return array();
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$nullDate = $db->getNullDate();
$date = JFactory::getDate();
$now = $date->toSql();
$text = trim($text);
if ($text === '')
{
return array();
}
switch ($phrase)
{
case 'exact':
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE ' . $text;
$wheres2[] = 'a.introtext LIKE ' . $text;
$wheres2[] = 'a.fulltext LIKE ' . $text;
$wheres2[] = 'a.metakey LIKE ' . $text;
$wheres2[] = 'a.metadesc LIKE ' . $text;
$relevance[] = ' CASE WHEN ' . $wheres2[0] . ' THEN 5 ELSE 0 END ';
// Join over Fields.
$subQuery = $db->getQuery(true);
$subQuery->select("cfv.item_id")
->from("#__fields_values AS cfv")
->join('LEFT', '#__fields AS f ON f.id = cfv.field_id')
->where('(f.context IS NULL OR f.context = ' . $db->q('com_content.article') . ')')
->where('(f.state IS NULL OR f.state = 1)')
->where('(f.access IS NULL OR f.access IN (' . $groups . '))')
->where('cfv.value LIKE ' . $text);
// Filter by language.
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$subQuery->where('(f.language IS NULL OR f.language in (' . $db->quote($tag) . ',' . $db->quote('*') . '))');
}
if ($serverType == "mysql")
{
/* This generates a dependent sub-query so do no use in MySQL prior to version 6.0 !
* $wheres2[] = 'a.id IN( '. (string) $subQuery.')';
*/
$db->setQuery($subQuery);
$fieldids = $db->loadColumn();
if (count($fieldids))
{
$wheres2[] = 'a.id IN(' . implode(",", $fieldids) . ')';
}
}
else
{
$wheres2[] = $subQuery->castAsChar('a.id') . ' IN( ' . (string) $subQuery . ')';
}
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
$cfwhere = array();
foreach ($words as $word)
{
$word = $db->quote('%' . $db->escape($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'LOWER(a.title) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.introtext) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.fulltext) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.metakey) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.metadesc) LIKE LOWER(' . $word . ')';
$relevance[] = ' CASE WHEN ' . $wheres2[0] . ' THEN 5 ELSE 0 END ';
if ($phrase === 'all')
{
// Join over Fields.
$subQuery = $db->getQuery(true);
$subQuery->select("cfv.item_id")
->from("#__fields_values AS cfv")
->join('LEFT', '#__fields AS f ON f.id = cfv.field_id')
->where('(f.context IS NULL OR f.context = ' . $db->q('com_content.article') . ')')
->where('(f.state IS NULL OR f.state = 1)')
->where('(f.access IS NULL OR f.access IN (' . $groups . '))')
->where('LOWER(cfv.value) LIKE LOWER(' . $word . ')');
// Filter by language.
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$subQuery->where('(f.language IS NULL OR f.language in (' . $db->quote($tag) . ',' . $db->quote('*') . '))');
}
if ($serverType == "mysql")
{
$db->setQuery($subQuery);
$fieldids = $db->loadColumn();
if (count($fieldids))
{
$wheres2[] = 'a.id IN(' . implode(",", $fieldids) . ')';
}
}
else
{
$wheres2[] = $subQuery->castAsChar('a.id') . ' IN( ' . (string) $subQuery . ')';
}
}
else
{
$cfwhere[] = 'LOWER(cfv.value) LIKE LOWER(' . $word . ')';
}
$wheres[] = implode(' OR ', $wheres2);
}
if ($phrase === 'any')
{
// Join over Fields.
$subQuery = $db->getQuery(true);
$subQuery->select("cfv.item_id")
->from("#__fields_values AS cfv")
->join('LEFT', '#__fields AS f ON f.id = cfv.field_id')
->where('(f.context IS NULL OR f.context = ' . $db->q('com_content.article') . ')')
->where('(f.state IS NULL OR f.state = 1)')
->where('(f.access IS NULL OR f.access IN (' . $groups . '))')
->where('(' . implode(($phrase === 'all' ? ') AND (' : ') OR ('), $cfwhere) . ')');
// Filter by language.
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$subQuery->where('(f.language IS NULL OR f.language in (' . $db->quote($tag) . ',' . $db->quote('*') . '))');
}
if ($serverType == "mysql")
{
$db->setQuery($subQuery);
$fieldids = $db->loadColumn();
if (count($fieldids))
{
$wheres[] = 'a.id IN(' . implode(",", $fieldids) . ')';
}
}
else
{
$wheres[] = $subQuery->castAsChar('a.id') . ' IN( ' . (string) $subQuery . ')';
}
}
$where = '(' . implode(($phrase === 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
switch ($ordering)
{
case 'oldest':
$order = 'a.created ASC';
break;
case 'popular':
$order = 'a.hits DESC';
break;
case 'alpha':
$order = 'a.title ASC';
break;
case 'category':
$order = 'c.title ASC, a.title ASC';
break;
case 'newest':
default:
$order = 'a.created DESC';
break;
}
$rows = array();
$query = $db->getQuery(true);
// Search articles.
if ($sContent && $limit > 0)
{
$query->clear();
// SQLSRV changes.
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
if (!empty($relevance))
{
$query->select(implode(' + ', $relevance) . ' AS relevance');
$order = ' relevance DESC, ' . $order;
}
$query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, a.language, a.catid')
->select($query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS text')
->select('c.title AS section, ' . $case_when . ',' . $case_when1 . ', ' . '\'2\' AS browsernav')
->from('#__content AS a')
->join('INNER', '#__categories AS c ON c.id=a.catid')
->where(
'(' . $where . ') AND a.state=1 AND c.published = 1 AND a.access IN (' . $groups . ') '
. 'AND c.access IN (' . $groups . ')'
. 'AND (a.publish_up = ' . $db->quote($nullDate) . ' OR a.publish_up <= ' . $db->quote($now) . ') '
. 'AND (a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ')'
)
->group('a.id, a.title, a.metadesc, a.metakey, a.created, a.language, a.catid, a.introtext, a.fulltext, c.title, a.alias, c.alias, c.id')
->order($order);
// Filter by language.
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')')
->where('c.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
try
{
$list = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$list = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
$limit -= count($list);
if (isset($list))
{
foreach ($list as $key => $item)
{
$list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language);
}
}
$rows[] = $list;
}
// Search archived content.
if ($sArchived && $limit > 0)
{
$query->clear();
// SQLSRV changes.
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
if (!empty($relevance))
{
$query->select(implode(' + ', $relevance) . ' AS relevance');
$order = ' relevance DESC, ' . $order;
}
$query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, a.language, a.catid')
->select($query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS text')
->select('c.title AS section, ' . $case_when . ',' . $case_when1 . ', ' . '\'2\' AS browsernav')
->from('#__content AS a')
->join('INNER', '#__categories AS c ON c.id=a.catid AND c.access IN (' . $groups . ')')
->where(
'(' . $where . ') AND a.state = 2 AND c.published = 1 AND a.access IN (' . $groups
. ') AND c.access IN (' . $groups . ') '
. 'AND (a.publish_up = ' . $db->quote($nullDate) . ' OR a.publish_up <= ' . $db->quote($now) . ') '
. 'AND (a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ')'
)
->order($order);
// Join over Fields is no longer needed
// Filter by language.
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')')
->where('c.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
try
{
$list3 = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$list3 = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
if (isset($list3))
{
foreach ($list3 as $key => $item)
{
$list3[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language);
}
}
$rows[] = $list3;
}
$results = array();
if (count($rows))
{
foreach ($rows as $row)
{
$new_row = array();
foreach ($row as $article)
{
// Not efficient to get these ONE article at a TIME
// Lookup field values so they can be checked, GROUP_CONCAT would work in above queries, but isn't supported by non-MySQL DBs.
$query = $db->getQuery(true);
$query->select('fv.value')
->from('#__fields_values as fv')
->join('left', '#__fields as f on fv.field_id = f.id')
->where('f.context = ' . $db->quote('com_content.article'))
->where('fv.item_id = ' . $db->quote((int) $article->slug));
$db->setQuery($query);
$article->jcfields = implode(',', $db->loadColumn());
if (SearchHelper::checkNoHtml($article, $searchText, array('text', 'title', 'jcfields', 'metadesc', 'metakey')))
{
$new_row[] = $article;
}
}
$results = array_merge($results, (array) $new_row);
}
}
return $results;
}
}

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="search" method="upgrade">
<name>plg_search_content</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>(C) 2005 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_SEARCH_CONTENT_XML_DESCRIPTION</description>
<files>
<filename plugin="content">content.php</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_search_content.ini</language>
<language tag="en-GB">en-GB.plg_search_content.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="search_limit"
type="number"
label="PLG_SEARCH_CONTENT_FIELD_SEARCHLIMIT_LABEL"
description="PLG_SEARCH_CONTENT_FIELD_SEARCHLIMIT_DESC"
default="50"
filter="integer"
size="5"
/>
<field
name="search_content"
type="radio"
label="PLG_SEARCH_CONTENT_FIELD_CONTENT_LABEL"
description="PLG_SEARCH_CONTENT_FIELD_CONTENT_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="search_archived"
type="radio"
label="PLG_SEARCH_CONTENT_FIELD_ARCHIVED_LABEL"
description="PLG_SEARCH_CONTENT_FIELD_ARCHIVED_DESC"
class="btn-group btn-group-yesno"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

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

352
plugins/search/jem/jem.php Normal file
View File

@ -0,0 +1,352 @@
<?php
/**
* @package JEM
* @subpackage JEM Search Plugin
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Registry\Registry;
jimport('joomla.html.parameter');
class plgSearchJEM extends CMSPlugin
{
protected static $_areas = array(
'jemevents' => 'PLG_JEM_SEARCH_EVENTS',
'jemvenues' => 'PLG_JEM_SEARCH_VENUES',
'jemcategories' => 'PLG_JEM_SEARCH_JEM_CATEGORIES'
);
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
CMSPlugin::loadLanguage('plg_search_jem', JPATH_ADMINISTRATOR);
}
/**
* @return array An array of search areas
*/
function onContentSearchAreas()
{
include_once(JPATH_SITE . '/components/com_jem/factory.php');
if (!class_exists('JemFactory')) {
return array(); // we need jem please
}
return self::$_areas;
}
/**
* Categories Search method
*
* The sql must return the following fields that are
* used in a common display routine: href, title, section, created, text,
* browsernav
*
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
* @param mixed An array if restricted to areas, null if search all
*/
function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
include_once(JPATH_SITE . '/components/com_jem/factory.php');
if (!class_exists('JemFactory')) {
return array(); // we need jem please
}
$db = Factory::getContainer()->get('DatabaseDriver');
$app = Factory::getApplication();
$user = JemFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$tag = Factory::getApplication()->getLanguage()->getTag();
require_once(JPATH_SITE . '/components/com_jem/helpers/route.php');
if (is_array($areas)) {
if (!array_intersect($areas, array_keys(self::$_areas))) {
return array();
}
} else {
$areas = array_keys(self::$_areas);
}
// load plugin params info
$plugin = PluginHelper::getPlugin('search', 'jem');
$pluginParams = new Registry($plugin->params);
$limit = $pluginParams->def('search_limit', 50);
$text = trim($text);
if ($text == '') {
return array();
}
$searchJEM = $db->Quote(Text::_('PLG_JEM_SEARCH_JEM'));
$rows = array();
$query = $db->getQuery(true);
if (in_array('jemevents', $areas) && $limit > 0) {
$areaName = Text::_(self::$_areas['jemevents']);
switch ($phrase) {
case 'exact':
$text_q = $db->Quote('%' . $db->escape($text, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'LOWER(a.title) LIKE ' . $text_q;
$wheres2[] = 'LOWER(a.introtext) LIKE ' . $text_q;
$wheres2[] = 'LOWER(a.fulltext) LIKE ' . $text_q;
$wheres2[] = 'LOWER(a.meta_keywords) LIKE ' . $text_q;
$wheres2[] = 'LOWER(a.meta_description) LIKE ' . $text_q;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word) {
$word = $db->Quote('%' . $db->escape($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'LOWER(a.title) LIKE ' . $word;
$wheres2[] = 'LOWER(a.introtext) LIKE ' . $word;
$wheres2[] = 'LOWER(a.fulltext) LIKE ' . $word;
$wheres2[] = 'LOWER(a.meta_keywords) LIKE ' . $word;
$wheres2[] = 'LOWER(a.meta_description) LIKE ' . $word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
switch ($ordering) {
case 'oldest':
$order = 'a.dates ASC, a.times ASC';
break;
case 'alpha':
$order = 'a.title ASC';
break;
case 'category':
$order = 'c.catname ASC, a.title ASC';
break;
case 'newest':
default:
$order = 'a.dates DESC, a.times DESC';
}
$query->clear();
//sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select('a.title AS title, a.meta_description, a.meta_keywords, a.created AS created');
$query->select($query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS text');
$query->select($query->concatenate(array($db->quote($areaName), 'c.catname'), ' / ') . ' AS section');
$query->select($case_when . ',' . $case_when1 . ', ' . '\'2\' AS browsernav');
$query->select('rel.catid');
$query->from('#__jem_events AS a');
$query->join('LEFT', '#__jem_cats_event_relations AS rel ON rel.itemid = a.id');
$query->join('LEFT', '#__jem_categories AS c ON c.id = rel.catid');
$query->where(
'(' . $where . ')' . ' AND a.published=1 AND c.published = 1 AND a.access IN (' . $groups . ') '
. 'AND c.access IN (' . $groups . ') '
);
$query->group('a.id');
$query->order($order);
$db->setQuery($query, 0, $limit);
$list = $db->loadObjectList();
$limit -= count($list);
if (isset($list)) {
foreach ($list as $key => $row) {
$list[$key]->href = JEMHelperRoute::getEventRoute($row->slug);
// todo: list ALL accessable categories
// todo: show date/time somewhere because this is very useful information
}
}
$rows[] = $list;
}
if (in_array('jemvenues', $areas) && $limit > 0) {
$areaName = Text::_(self::$_areas['jemvenues']);
switch ($phrase) {
case 'exact':
$text_q = $db->Quote('%' . $db->escape($text, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'LOWER(venue) LIKE ' . $text_q;
$wheres2[] = 'LOWER(locdescription) LIKE ' . $text_q;
$wheres2[] = 'LOWER(city) LIKE ' . $text_q;
$wheres2[] = 'LOWER(meta_keywords) LIKE ' . $text_q;
$wheres2[] = 'LOWER(meta_description) LIKE ' . $text_q;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word) {
$word = $db->Quote('%' . $db->escape($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'LOWER(venue) LIKE ' . $word;
$wheres2[] = 'LOWER(locdescription) LIKE ' . $word;
$wheres2[] = 'LOWER(city) LIKE ' . $word;
$wheres2[] = 'LOWER(meta_keywords) LIKE ' . $word;
$wheres2[] = 'LOWER(meta_description) LIKE ' . $word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
switch ($ordering) {
case 'oldest':
$order = 'created DESC';
break;
case 'alpha':
$order = 'venue ASC';
break;
case 'newest':
$order = 'created ASC';
break;
default:
$order = 'venue ASC';
}
$query = 'SELECT venue AS title,'
. ' locdescription AS text,'
. ' created,'
. ' "2" AS browsernav,'
. ' CASE WHEN CHAR_LENGTH(alias) THEN CONCAT_WS(\':\', id, alias) ELSE id END as slug, '
. ' ' . $db->quote($areaName) . ' AS section'
. ' FROM #__jem_venues'
. ' WHERE ( ' . $where . ')'
. ' AND published = 1'
. ' ORDER BY ' . $order;
$db->setQuery($query, 0, $limit);
$list2 = $db->loadObjectList();
foreach ((array)$list2 as $key => $row) {
$list2[$key]->href = JEMHelperRoute::getVenueRoute($row->slug);
}
$rows[] = $list2;
}
if (in_array('jemcategories', $areas) && $limit > 0) {
$areaName = Text::_(self::$_areas['jemcategories']);
switch ($phrase) {
case 'exact':
$text_q = $db->Quote('%' . $db->escape($text, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'LOWER(catname) LIKE ' . $text_q;
$wheres2[] = 'LOWER(description) LIKE ' . $text_q;
$wheres2[] = 'LOWER(meta_keywords) LIKE ' . $text_q;
$wheres2[] = 'LOWER(meta_description) LIKE ' . $text_q;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word) {
$word = $db->Quote('%' . $db->escape($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'LOWER(catname) LIKE ' . $word;
$wheres2[] = 'LOWER(description) LIKE ' . $word;
$wheres2[] = 'LOWER(meta_keywords) LIKE ' . $word;
$wheres2[] = 'LOWER(meta_description) LIKE ' . $word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
$query = 'SELECT catname AS title,'
. ' description AS text,'
. ' "" AS created,'
. ' "2" AS browsernav,'
. ' CASE WHEN CHAR_LENGTH(alias) THEN CONCAT_WS(\':\', id, alias) ELSE id END as slug, '
. ' ' . $db->quote($areaName) . ' AS section'
. ' FROM #__jem_categories'
. ' WHERE ( ' . $where . ' )'
. ' AND published = 1'
. ' AND access IN (' . $groups . ') '
. ' ORDER BY catname';
$db->setQuery($query, 0, $limit);
$list3 = $db->loadObjectList();
foreach ((array)$list3 as $key => $row) {
$list3[$key]->href = JEMHelperRoute::getCategoryRoute($row->slug);
}
$rows[] = $list3;
}
$count = count($rows);
if ($count > 1) {
switch ($count) {
case 2:
$results = array_merge((array)$rows[0], (array)$rows[1]);
break;
case 3:
$results = array_merge((array)$rows[0], (array)$rows[1], (array)$rows[2]);
break;
case 4:
default:
$results = array_merge((array)$rows[0], (array)$rows[1], (array)$rows[2], (array)$rows[3]);
break;
}
return $results;
} else {
if ($count == 1) {
return $rows[0];
}
}
}
}
?>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="search" method="upgrade">
<name>plg_search_jem</name>
<author>JEM Community</author>
<authorEmail>info@joomlaeventmanager.net</authorEmail>
<authorUrl>https://www.joomlaeventmanager.net</authorUrl>
<creationDate>October 2024</creationDate>
<copyright>copyright (C) 2013-2024 joomlaeventmanager.net</copyright>
<license>https://www.gnu.org/licenses/gpl-3.0 GNU/GPL</license>
<version>4.3.1</version>
<description>PLG_SEARCH_JEM_XML_DESCRIPTION</description>
<files>
<filename plugin="jem">jem.php</filename>
<filename>index.html</filename>
<folder>language</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_search_jem.ini</language>
<language tag="en-GB">language/en-GB/plg_search_jem.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="search_limit" type="text"
size="5"
default="50"
label="PLG_JEM_SEARCH_SEARCH_LIMIT"
description="PLG_JEM_SEARCH_NUMBER_ITEMS_RETURN"
/>
</fieldset>
</fields>
</config>
</extension>

View File

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

View File

@ -0,0 +1,17 @@
; @package JEM
; @subpackage JEM Search Plugin
; @copyright (C) 2013-2024 joomlaeventmanager.net
; @copyright (C) 2005-2009 Christoph Lukes
; @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
;
; All translations can be found at https://app.transifex.com/jemproject/
; Please join the translation team if you want to contribute your changes to the translations
;
; Note: All ini files need to be saved as UTF-8, no BOM
PLG_JEM_SEARCH_JEM = "JEM"
PLG_JEM_SEARCH_SEARCH_LIMIT = "Search Limit"
PLG_JEM_SEARCH_NUMBER_ITEMS_RETURN = "Number of search items to return"
PLG_JEM_SEARCH_EVENTS = "Events"
PLG_JEM_SEARCH_VENUES = "Venues"
PLG_JEM_SEARCH_JEM_CATEGORIES = "Event categories"

View File

@ -0,0 +1,14 @@
; @package JEM
; @subpackage JEM Search Plugin
; @copyright (C) 2013-2024 joomlaeventmanager.net
; @copyright (C) 2005-2009 Christoph Lukes
; @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
;
; All translations can be found at https://app.transifex.com/jemproject/
; Please join the translation team if you want to contribute your changes to the translations
;
; Note: All ini files need to be saved as UTF-8, no BOM
PLG_SEARCH_JEM = "JEM - Search Plugin"
PLG_SEARCH_JEM_XML_DESCRIPTION = "JEM Search Plugin. This plugin integrates JEM Events and venues into Joomla's search functionality."

View File

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

View File

@ -0,0 +1,18 @@
; @version 2.0.0
; @package JEM
; @subpackage JEM Search Plugin
; @copyright (C) 2005-2009 Christoph Lukes
; @copyright (C) 2013-2014 joomlaeventmanager.net
; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;
; All translations can be found at https://www.transifex.com/projects/p/JEM/
; Please join the translation team if you want to contribute your changes to the translations
;
; Note : All ini files need to be saved as UTF-8 - No BOM
PLG_JEM_SEARCH_JEM="JEM"
PLG_JEM_SEARCH_SEARCH_LIMIT="Limite ricerca"
PLG_JEM_SEARCH_NUMBER_ITEMS_RETURN="Numero di oggetti ricercati da mostrare"
PLG_JEM_SEARCH_EVENTS="Eventi"
PLG_JEM_SEARCH_VENUES="Sedi"
PLG_JEM_SEARCH_JEM_CATEGORIES="Categorie eventi"

View File

@ -0,0 +1,15 @@
; @version 2.0.0
; @package JEM
; @subpackage JEM Search Plugin
; @copyright (C) 2005-2009 Christoph Lukes
; @copyright (C) 2013-2014 joomlaeventmanager.net
; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
;
; All translations can be found at https://www.transifex.com/projects/p/JEM/
; Please join the translation team if you want to contribute your changes to the translations
;
; Note : All ini files need to be saved as UTF-8 - No BOM
PLG_SEARCH_JEM="Ricerca - JEM"
PLG_SEARCH_JEM_XML_DESCRIPTION="JEM Plugin di ricerca. JEM is based on Eventlist by Christoph Lukes (http://www.schlu.net)"

View File

@ -0,0 +1,202 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Search.newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Newsfeeds search plugin.
*
* @since 1.6
*/
class PlgSearchNewsfeeds extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Determine areas searchable by this plugin.
*
* @return array An array of search areas.
*
* @since 1.6
*/
public function onContentSearchAreas()
{
static $areas = array(
'newsfeeds' => 'PLG_SEARCH_NEWSFEEDS_NEWSFEEDS'
);
return $areas;
}
/**
* Search content (newsfeeds).
*
* The SQL must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav.
*
* @param string $text Target search string.
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
* @param mixed $areas An array if the search it to be restricted to areas or null to search all areas.
*
* @return array Search results.
*
* @since 1.6
*/
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas())))
{
return array();
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$state = array();
if ($sContent)
{
$state[] = 1;
}
if ($sArchived)
{
$state[] = 2;
}
if (empty($state))
{
return array();
}
$text = trim($text);
if ($text === '')
{
return array();
}
switch ($phrase)
{
case 'exact':
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.name LIKE ' . $text;
$wheres2[] = 'a.link LIKE ' . $text;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word)
{
$word = $db->quote('%' . $db->escape($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.name LIKE ' . $word;
$wheres2[] = 'a.link LIKE ' . $word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase === 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
switch ($ordering)
{
case 'alpha':
$order = 'a.name ASC';
break;
case 'category':
$order = 'c.title ASC, a.name ASC';
break;
case 'oldest':
case 'popular':
case 'newest':
default:
$order = 'a.name ASC';
}
$searchNewsfeeds = JText::_('PLG_SEARCH_NEWSFEEDS_NEWSFEEDS');
$query = $db->getQuery(true);
// SQLSRV changes.
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select('a.name AS title, \'\' AS created, a.link AS text, ' . $case_when . ',' . $case_when1)
->select($query->concatenate(array($db->quote($searchNewsfeeds), 'c.title'), ' / ') . ' AS section')
->select('\'1\' AS browsernav')
->from('#__newsfeeds AS a')
->join('INNER', '#__categories as c ON c.id = a.catid')
->where('(' . $where . ') AND a.published IN (' . implode(',', $state) . ') AND c.published = 1 AND c.access IN (' . $groups . ')')
->order($order);
// Filter by language.
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$tag = JFactory::getLanguage()->getTag();
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')')
->where('c.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$rows = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
if ($rows)
{
foreach ($rows as $key => $row)
{
$rows[$key]->href = 'index.php?option=com_newsfeeds&view=newsfeed&catid=' . $row->catslug . '&id=' . $row->slug;
}
}
return $rows;
}
}

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="search" method="upgrade">
<name>plg_search_newsfeeds</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>(C) 2005 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_SEARCH_NEWSFEEDS_XML_DESCRIPTION</description>
<files>
<filename plugin="newsfeeds">newsfeeds.php</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_search_newsfeeds.ini</language>
<language tag="en-GB">en-GB.plg_search_newsfeeds.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="search_limit"
type="number"
label="JFIELD_PLG_SEARCH_SEARCHLIMIT_LABEL"
description="JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC"
default="50"
filter="integer"
size="5"
/>
<field
name="search_content"
type="radio"
label="JFIELD_PLG_SEARCH_ALL_LABEL"
description="JFIELD_PLG_SEARCH_ALL_DESC"
class="btn-group btn-group-yesno"
default="0"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="search_archived"
type="radio"
label="JFIELD_PLG_SEARCH_ARCHIVED_LABEL"
description="JFIELD_PLG_SEARCH_ARCHIVED_DESC"
class="btn-group btn-group-yesno"
default="0"
filter="integer"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,327 @@
<?php
/**
* @version 6.2.6 tabulizer $
* @package tabulizer
* @copyright Copyright © 2011 - All rights reserved.
* @license GNU/GPL
* @author Dimitrios Mourloukos
* @author mail info@alterora.gr
* @website www.tabulizer.com
*
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
/**
* Tabulizerds Search plugin
*
* @package Joomla.Plugin
* @subpackage Search.content
* @since 1.6
*/
class plgSearchTabulizerds extends JPlugin
{
/**
* Constructor
*
* @access protected
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.5
*/
public function __construct(& $subject, $config)
{
parent::__construct($subject, $config);
$this->loadLanguage();
}
/**
* @return array An array of search areas
*/
function onContentSearchAreas()
{
static $areas = array(
'tabulizerds' => 'PLG_SEARCH_TABULIZERDS_TABULIZERDS'
);
return $areas;
}
function onContentSearch( $text, $phrase='', $ordering='', $areas=null )
{
$db = JFactory::getDBO();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$tag = JFactory::getLanguage()->getTag();
require_once JPATH_ADMINISTRATOR . '/components/com_tabulizer/assets/classes/common/helper.php';
// If the array is not correct, return it:
if (is_array( $areas )) {
if (!array_intersect( $areas, array_keys( $this->onContentSearchAreas() ) )) {
return array();
}
}
// Use the PHP function trim to delete spaces in front of or at the back of the searching terms
$text = trim( $text );
// Return Array when nothing was filled in.
if ($text == '') {
return array();
}
$query = 'SELECT * FROM #__content WHERE (`introtext` LIKE '.$db->quote('%{tabulizer:data_source%').') OR (`fulltext` LIKE '.$db->quote('%{tabulizer:data_source%').')';
$db->setQuery($query);
$articles = $db->loadObjectList();
if (empty($articles)) {
return array();
}
$article_ids = array();
foreach ($articles as $article) {
$full_content = $article->introtext . $article->fulltext;
$ds_content = '';
# find occurances of tabulizer data source directive that contain specified user parameters (editor)
$pattern = TABULIZER_DATA_SOURCE_PARAMS_REGEX;
while (preg_match($pattern, $full_content, $regs, PREG_OFFSET_CAPTURE)) {
TabulizerPath::requireLib('data_source','common');
$data_source_tag = $regs[1][0];
$data_source_user_params = base64_decode($regs[2][0]);
if (preg_match('/^[a-z0-9\._\-]{2,128}$/i',$data_source_tag)) {
$ds_content .= TabulizerDataSource::getTableHTML($data_source_tag,$data_source_user_params);
}
// Replace the found tabulizer directive
$full_content = substr_replace($full_content, '', $regs[0][1], strlen($regs[0][0]));
}
# find occurances of tabulizer data source directive with no user parameters (editor)
$pattern = TABULIZER_DATA_SOURCE_REGEX;
while (preg_match($pattern, $full_content, $regs, PREG_OFFSET_CAPTURE)) {
TabulizerPath::requireLib('data_source','common');
$data_source_tag = $regs[1][0];
if (preg_match('/^[a-z0-9\._\-]{2,128}$/i',$data_source_tag)) {
$ds_content .= TabulizerDataSource::getTableHTML($data_source_tag);
}
// Replace the found tabulizer directive
$full_content = substr_replace($full_content, '', $regs[0][1], strlen($regs[0][0]));
}
if (!empty($ds_content)) {
// search for keywords
$found = false;
switch ($phrase) {
case 'exact':
if (preg_match('/'.preg_quote($text, '/').'/imu',$ds_content)) {
$found = true;
}
break;
case 'all':
$words = explode(' ', $text);
if (!empty($words)) {
$found = true;
foreach ($words as $word) {
if (!preg_match('/' . preg_quote($word, '/') . '/imu', $ds_content)) {
$found = false;
break;
}
}
}
break;
case 'any':
default:
$words = explode(' ', $text);
foreach ($words as $word) {
if (preg_match('/'.preg_quote($word, '/').'/imu',$ds_content)) {
$found = true;
}
}
break;
}
if ($found) $article_ids[] = $article->id;
}
}
if (empty($article_ids)) {
return array();
}
$where = 'a.id IN ('.implode(',',$article_ids).') ';
switch ($ordering) {
case 'oldest':
$order = 'a.created ASC';
break;
case 'popular':
$order = 'a.hits DESC';
break;
case 'alpha':
$order = 'a.title ASC';
break;
case 'category':
$order = 'c.title ASC, a.title ASC';
break;
case 'newest':
default:
$order = 'a.created DESC';
break;
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$nullDate = $db->getNullDate();
$date = new JDate();
$now = $date->toSql();
$rows = array();
$query = $db->getQuery(true);
// search articles
if ($sContent && $limit > 0)
{
$query->clear();
//sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id.' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id.' END as catslug';
$query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created');
$query->select($query->concatenate(array('a.introtext', 'a.fulltext')).' AS text');
$query->select('c.title AS section, '.$case_when.','.$case_when1.', '.'\'2\' AS browsernav');
$query->from('#__content AS a');
$query->innerJoin('#__categories AS c ON c.id=a.catid');
$query->where('('. $where .')' . 'AND a.state=1 AND c.published = 1 AND a.access IN ('.$groups.') '
.'AND c.access IN ('.$groups.') '
.'AND (a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).') '
.'AND (a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).')' );
$query->group('a.id, a.title, a.metadesc, a.metakey, a.created, a.introtext, a.fulltext, c.title, a.alias, c.alias, c.id');
$query->order($order);
// Filter by language
if ($app->isSite() && $app->getLanguageFilter()) {
$query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
$query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
$list = $db->loadObjectList();
$limit -= count($list);
if (isset($list))
{
foreach($list as $key => $item)
{
$list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug);
}
}
$rows[] = $list;
}
// search archived content
if ($sArchived && $limit > 0)
{
$searchArchived = JText::_('JARCHIVED');
$query->clear();
//sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id.' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id.' END as catslug';
$query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, '
.$query->concatenate(array("a.introtext", "a.fulltext")).' AS text,'
.$case_when.','.$case_when1.', '
.'c.title AS section, \'2\' AS browsernav');
$query->from('#__content AS a');
$query->innerJoin('#__categories AS c ON c.id=a.catid AND c.access IN ('. $groups .')');
$query->where('('. $where .') AND a.state = 2 AND c.published = 1 AND a.access IN ('. $groups
.') AND c.access IN ('. $groups .') '
.'AND (a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).') '
.'AND (a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).')' );
$query->order($order);
// Filter by language
if ($app->isSite() && $app->getLanguageFilter()) {
$query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
$query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
$list3 = $db->loadObjectList();
// find an itemid for archived to use if there isn't another one
$item = $app->getMenu()->getItems('link', 'index.php?option=com_content&view=archive', true);
$itemid = isset($item->id) ? '&Itemid='.$item->id : '';
if (isset($list3))
{
foreach($list3 as $key => $item)
{
$date = new JDate($item->created);
$created_month = $date->format("n");
$created_year = $date->format("Y");
$list3[$key]->href = JRoute::_('index.php?option=com_content&view=archive&year='.$created_year.'&month='.$created_month.$itemid);
}
}
$rows[] = $list3;
}
$results = array();
if (count($rows))
{
foreach($rows as $row)
{
$new_row = array();
foreach($row as $key => $article) {
$new_row[] = $article;
}
$results = array_merge($results, (array) $new_row);
}
}
return $results;
}
}
?>

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="search" method="upgrade">
<name>plg_search_tabulizerds</name>
<creationDate>2019-01-17</creationDate>
<copyright>Copyright (C) 2011. All rights reserved.</copyright>
<license>GNU General Public License</license>
<author>Dimitrios Mourloukos</author>
<authorEmail>info@alterora.gr</authorEmail>
<authorUrl>www.tabulizer.gr</authorUrl>
<version>6.2.6</version>
<description>PLG_SEARCH_TABULIZERDS_DESCRIPTION</description>
<files>
<filename plugin="tabulizerds">tabulizerds.php</filename>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_search_tabulizerds.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_search_tabulizerds.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="search_limit" type="text"
default="50"
description="JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC"
label="JFIELD_PLG_SEARCH_SEARCHLIMIT_LABEL"
size="5"
/>
<field name="search_content" type="radio"
default="1"
description="JFIELD_PLG_SEARCH_ALL_DESC"
label="JFIELD_PLG_SEARCH_ALL_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="search_archived" type="radio"
default="1"
description="JFIELD_PLG_SEARCH_ARCHIVED_DESC"
label="JFIELD_PLG_SEARCH_ARCHIVED_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,218 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Search.tags
*
* @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Tags search plugin.
*
* @since 3.3
*/
class PlgSearchTags extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.3
*/
protected $autoloadLanguage = true;
/**
* Determine areas searchable by this plugin.
*
* @return array An array of search areas.
*
* @since 3.3
*/
public function onContentSearchAreas()
{
static $areas = array(
'tags' => 'PLG_SEARCH_TAGS_TAGS'
);
return $areas;
}
/**
* Search content (tags).
*
* The SQL must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav.
*
* @param string $text Target search string.
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
* @param string $areas An array if the search is to be restricted to areas or null to search all areas.
*
* @return array Search results.
*
* @since 3.3
*/
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$app = JFactory::getApplication();
$user = JFactory::getUser();
$lang = JFactory::getLanguage();
$section = JText::_('PLG_SEARCH_TAGS_TAGS');
$limit = $this->params->def('search_limit', 50);
if (is_array($areas) && !array_intersect($areas, array_keys($this->onContentSearchAreas())))
{
return array();
}
$text = trim($text);
if ($text === '')
{
return array();
}
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
switch ($ordering)
{
case 'alpha':
$order = 'a.title ASC';
break;
case 'newest':
$order = 'a.created_time DESC';
break;
case 'oldest':
$order = 'a.created_time ASC';
break;
case 'popular':
default:
$order = 'a.title DESC';
}
$query->select('a.id, a.title, a.alias, a.note, a.published, a.access'
. ', a.checked_out, a.checked_out_time, a.created_user_id'
. ', a.path, a.parent_id, a.level, a.lft, a.rgt'
. ', a.language, a.created_time AS created, a.description');
$case_when_item_alias = ' CASE WHEN ';
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
$case_when_item_alias .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id . ' END as slug';
$query->select($case_when_item_alias);
$query->from('#__tags AS a');
$query->where('a.alias <> ' . $db->quote('root'));
$query->where('(a.title LIKE ' . $text . ' OR a.alias LIKE ' . $text . ')');
$query->where($db->qn('a.published') . ' = 1');
if (!$user->authorise('core.admin'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
if ($app->isClient('site') && JLanguageMultilang::isEnabled())
{
$tag = JFactory::getLanguage()->getTag();
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
}
$query->order($order);
$db->setQuery($query, 0, $limit);
try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$rows = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
if ($rows)
{
JLoader::register('TagsHelperRoute', JPATH_SITE . '/components/com_tags/helpers/route.php');
foreach ($rows as $key => $row)
{
$rows[$key]->href = TagsHelperRoute::getTagRoute($row->slug);
$rows[$key]->text = ($row->description !== '' ? $row->description : $row->title);
$rows[$key]->text .= $row->note;
$rows[$key]->section = $section;
$rows[$key]->created = $row->created;
$rows[$key]->browsernav = 0;
}
}
if (!$this->params->get('show_tagged_items', 0))
{
return $rows;
}
else
{
$final_items = $rows;
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_tags/models');
$tag_model = JModelLegacy::getInstance('Tag', 'TagsModel');
$tag_model->getState();
foreach ($rows as $key => $row)
{
$tag_model->setState('tag.id', $row->id);
$tagged_items = $tag_model->getItems();
if ($tagged_items)
{
foreach ($tagged_items as $k => $item)
{
// For 3rd party extensions we need to load the component strings from its sys.ini file
$parts = explode('.', $item->type_alias);
$comp = array_shift($parts);
$lang->load($comp, JPATH_SITE, null, false, true)
|| $lang->load($comp, JPATH_SITE . '/components/' . $comp, null, false, true);
// Making up the type string
$type = implode('_', $parts);
$type = $comp . '_CONTENT_TYPE_' . $type;
$new_item = new stdClass;
$new_item->href = $item->link;
$new_item->title = $item->core_title;
$new_item->text = $item->core_body;
if ($lang->hasKey($type))
{
$new_item->section = JText::sprintf('PLG_SEARCH_TAGS_ITEM_TAGGED_WITH', JText::_($type), $row->title);
}
else
{
$new_item->section = JText::sprintf('PLG_SEARCH_TAGS_ITEM_TAGGED_WITH', $item->content_type_title, $row->title);
}
$new_item->created = $item->displayDate;
$new_item->browsernav = 0;
$final_items[] = $new_item;
}
}
}
return $final_items;
}
}
}

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="search" method="upgrade">
<name>plg_search_tags</name>
<author>Joomla! Project</author>
<creationDate>March 2014</creationDate>
<copyright>(C) 2014 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_SEARCH_TAGS_XML_DESCRIPTION</description>
<files>
<filename plugin="tags">tags.php</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_search_tags.ini</language>
<language tag="en-GB">en-GB.plg_search_tags.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="search_limit"
type="number"
label="JFIELD_PLG_SEARCH_SEARCHLIMIT_LABEL"
description="JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC"
default="50"
filter="integer"
size="5"
/>
<field
name="show_tagged_items"
type="radio"
label="PLG_SEARCH_TAGS_FIELD_SHOW_TAGGED_ITEMS_LABEL"
description="PLG_SEARCH_TAGS_FIELD_SHOW_TAGGED_ITEMS_DESC"
class="btn-group btn-group-yesno"
default="0"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</config>
</extension>