first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1,185 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Search.categories
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
/**
* Categories Search plugin
*
* @package Joomla.Plugin
* @subpackage Search.categories
* @since 1.6
*/
class PlgSearchCategories extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* @return array An array of search areas
*/
public function onContentSearchAreas()
{
static $areas = array(
'categories' => 'PLG_SEARCH_CATEGORIES_CATEGORIES'
);
return $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
*/
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))
{
if (!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, \'\' 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')
->order($order);
if ($app->isSite() && JLanguageMultilang::isEnabled())
{
$query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();
$return = array();
if ($rows)
{
$count = count($rows);
for ($i = 0; $i < $count; $i++)
{
$rows[$i]->href = ContentHelperRoute::getCategoryRoute($rows[$i]->slug);
$rows[$i]->section = JText::_('JCATEGORY');
}
foreach ($rows as $category)
{
if (searchHelper::checkNoHTML($category, $searchText, array('name', 'title', 'text')))
{
$return[] = $category;
}
}
}
return $return;
}
}

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="search">
<name>plg_search_categories</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</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>
<filename>index.html</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="text"
default="50"
description="JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC"
label="JFIELD_PLG_SEARCH_SEARCHLIMIT_LABEL"
size="5"
/>
<field name="search_content" type="radio"
class="btn-group"
default="0"
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"
class="btn-group"
default="0"
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 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,171 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Search.contacts
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Contacts Search plugin
*
* @package Joomla.Plugin
* @subpackage Search.contacts
* @since 1.6
*/
class PlgSearchContacts extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* @return array An array of search areas
*/
public function onContentSearchAreas()
{
static $areas = array(
'contacts' => 'PLG_SEARCH_CONTACTS_CONTACTS'
);
return $areas;
}
/**
* Contacts 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 matching option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
*/
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))
{
if (!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 . ')'
)
->group('a.id, a.con_position, a.misc, c.alias, c.id')
->order($order);
// Filter by language
if ($app->isSite() && 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);
$rows = $db->loadObjectList();
if ($rows)
{
foreach ($rows as $key => $row)
{
$rows[$key]->href = 'index.php?option=com_contact&view=contact&id=' . $row->slug . '&catid=' . $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,53 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="search">
<name>plg_search_contacts</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</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>
<filename>index.html</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="text"
default="50"
description="JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC"
label="JFIELD_PLG_SEARCH_SEARCHLIMIT_LABEL"
size="5"
/>
<field name="search_content" type="radio"
class="btn-group"
default="0"
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"
class="btn-group"
default="0"
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 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,281 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Search.content
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_SITE . '/components/com_content/router.php';
/**
* Content Search plugin
*
* @package Joomla.Plugin
* @subpackage Search.content
* @since 1.6
*/
class PlgSearchContent extends JPlugin
{
/**
* @return array An array of search areas
*/
public function onContentSearchAreas()
{
static $areas = array(
'content' => 'JGLOBAL_ARTICLES'
);
return $areas;
}
/**
* Content 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 the search it to be restricted to areas, null if search all
*/
public 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_SITE . '/components/com_content/helpers/route.php';
require_once JPATH_ADMINISTRATOR . '/components/com_search/helpers/search.php';
$searchText = $text;
if (is_array($areas))
{
if (!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;
$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.title LIKE ' . $word;
$wheres2[] = 'a.introtext LIKE ' . $word;
$wheres2[] = 'a.fulltext LIKE ' . $word;
$wheres2[] = 'a.metakey LIKE ' . $word;
$wheres2[] = 'a.metadesc LIKE ' . $word;
$wheres[] = implode(' OR ', $wheres2);
}
$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';
$query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created')
->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.introtext, a.fulltext, c.title, a.alias, c.alias, c.id')
->order($order);
// Filter by language
if ($app->isSite() && 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);
$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)
{
$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';
$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'
);
//.'CONCAT_WS("/", c.title) AS section, \'2\' AS browsernav' );
$query->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);
// Filter by language
if ($app->isSite() && 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);
$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 = JFactory::getDate($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 $article)
{
if (SearchHelper::checkNoHTML($article, $searchText, array('text', 'title', 'metadesc', 'metakey')))
{
$new_row[] = $article;
}
}
$results = array_merge($results, (array) $new_row);
}
}
return $results;
}
}

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="search">
<name>plg_search_content</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</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>
<filename>index.html</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="text"
default="50"
description="PLG_SEARCH_CONTENT_FIELD_SEARCHLIMIT_DESC"
label="PLG_SEARCH_CONTENT_FIELD_SEARCHLIMIT_LABEL"
size="5"
/>
<field name="search_content" type="radio"
class="btn-group"
default="0"
description="PLG_SEARCH_CONTENT_FIELD_CONTENT_DESC"
label="PLG_SEARCH_CONTENT_FIELD_CONTENT_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="search_archived" type="radio"
class="btn-group"
default="0"
description="PLG_SEARCH_CONTENT_FIELD_ARCHIVED_DESC"
label="PLG_SEARCH_CONTENT_FIELD_ARCHIVED_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

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

View File

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

232
plugins/search/k2/k2.php Normal file
View File

@ -0,0 +1,232 @@
<?php
/**
* @version $Id: k2.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
jimport('joomla.plugin.plugin');
jimport('joomla.html.parameter');
class plgSearchK2 extends JPlugin
{
function onContentSearchAreas()
{
return $this->onSearchAreas();
}
function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
return $this->onSearch($text, $phrase, $ordering, $areas);
}
function onSearchAreas()
{
JPlugin::loadLanguage('plg_search_k2', JPATH_ADMINISTRATOR);
static $areas = array('k2' => 'K2_ITEMS');
return $areas;
}
function onSearch($text, $phrase = '', $ordering = '', $areas = null)
{
JPlugin::loadLanguage('plg_search_k2', JPATH_ADMINISTRATOR);
jimport('joomla.html.parameter');
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$jnow = JFactory::getDate();
$now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();
$nullDate = $db->getNullDate();
$user = JFactory::getUser();
if (K2_JVERSION != '15')
{
$accessCheck = " IN(".implode(',', $user->getAuthorisedViewLevels()).") ";
}
else
{
$aid = $user->get('aid');
$accessCheck = " <= {$aid} ";
}
$tagIDs = array();
$itemIDs = array();
require_once (JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_search'.DS.'helpers'.DS.'search.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'route.php');
$searchText = $text;
if (is_array($areas))
{
if (!array_intersect($areas, array_keys($this->onSearchAreas())))
{
return array();
}
}
$plugin = JPluginHelper::getPlugin('search', 'k2');
$pluginParams = class_exists('JParameter') ? new JParameter($plugin->params) : new JRegistry($plugin->params);
$limit = $pluginParams->def('search_limit', 50);
$text = JString::trim($text);
if ($text == '')
{
return array();
}
$rows = array();
if ($limit > 0)
{
if ($pluginParams->get('search_tags'))
{
$tagQuery = JString::str_ireplace('*', '', $text);
$words = explode(' ', $tagQuery);
for ($i = 0; $i < count($words); $i++)
{
$words[$i] .= '*';
}
$tagQuery = implode(' ', $words);
$escaped = K2_JVERSION == '15' ? $db->getEscaped($tagQuery, true) : $db->escape($tagQuery, true);
$tagQuery = $db->Quote($escaped, false);
$query = "SELECT id FROM #__k2_tags WHERE MATCH(name) AGAINST ({$tagQuery} IN BOOLEAN MODE) AND published=1";
$db->setQuery($query);
$tagIDs = K2_JVERSION == '30' ? $db->loadColumn() : $db->loadResultArray();
if (count($tagIDs))
{
JArrayHelper::toInteger($tagIDs);
$query = "SELECT itemID FROM #__k2_tags_xref WHERE tagID IN (".implode(',', $tagIDs).")";
$db->setQuery($query);
$itemIDs = K2_JVERSION == '30' ? $db->loadColumn() : $db->loadResultArray();
}
}
if ($phrase == 'exact')
{
$text = JString::trim($text, '"');
$escaped = K2_JVERSION == '15' ? $db->getEscaped($text, true) : $db->escape($text, true);
$text = $db->Quote('"'.$db->getEscaped($text, true).'"', false);
}
else
{
$text = JString::str_ireplace('*', '', $text);
$words = explode(' ', $text);
for ($i = 0; $i < count($words); $i++)
{
if ($phrase == 'all')
$words[$i] = '+'.$words[$i];
$words[$i] .= '*';
}
$text = implode(' ', $words);
$escaped = K2_JVERSION == '15' ? $db->getEscaped($text, true) : $db->escape($text, true);
$text = $db->Quote($escaped, false);
}
$query = "
SELECT i.title AS title,
i.metadesc,
i.metakey,
c.name as section,
i.image_caption,
i.image_credits,
i.video_caption,
i.video_credits,
i.extra_fields_search,
i.created,
CONCAT(i.introtext, i.fulltext) AS text,
CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(':', i.id, i.alias) ELSE i.id END as slug,
CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(':', c.id, c.alias) ELSE c.id END as catslug
FROM #__k2_items AS i
INNER JOIN #__k2_categories AS c ON c.id=i.catid AND c.access {$accessCheck}
WHERE (";
if ($pluginParams->get('search_tags') && count($itemIDs))
{
JArrayHelper::toInteger($itemIDs);
$query .= " i.id IN (".implode(',', $itemIDs).") OR ";
}
$query .= "MATCH(i.title, i.introtext, i.`fulltext`,i.extra_fields_search,i.image_caption,i.image_credits,i.video_caption,i.video_credits,i.metadesc,i.metakey) AGAINST ({$text} IN BOOLEAN MODE)
)
AND i.trash = 0
AND i.published = 1
AND i.access {$accessCheck}
AND c.published = 1
AND c.access {$accessCheck}
AND c.trash = 0
AND ( i.publish_up = ".$db->Quote($nullDate)." OR i.publish_up <= ".$db->Quote($now)." )
AND ( i.publish_down = ".$db->Quote($nullDate)." OR i.publish_down >= ".$db->Quote($now)." )";
if (K2_JVERSION != '15' && $mainframe->isSite() && $mainframe->getLanguageFilter())
{
$languageTag = JFactory::getLanguage()->getTag();
$query .= " AND c.language IN (".$db->Quote($languageTag).", ".$db->Quote('*').") AND i.language IN (".$db->Quote($languageTag).", ".$db->Quote('*').") ";
}
$query .= " GROUP BY i.id ";
switch ($ordering)
{
case 'oldest' :
$query .= 'ORDER BY i.created ASC';
break;
case 'popular' :
$query .= 'ORDER BY i.hits DESC';
break;
case 'alpha' :
$query .= 'ORDER BY i.title ASC';
break;
case 'category' :
$query .= 'ORDER BY c.name ASC, i.title ASC';
break;
case 'newest' :
default :
$query .= 'ORDER BY i.created DESC';
break;
}
$db->setQuery($query, 0, $limit);
$list = $db->loadObjectList();
$limit -= count($list);
if (isset($list))
{
foreach ($list as $key => $item)
{
$list[$key]->href = JRoute::_(K2HelperRoute::getItemRoute($item->slug, $item->catslug));
}
}
$rows[] = $list;
}
$results = array();
if (count($rows))
{
foreach ($rows as $row)
{
$new_row = array();
foreach ($row as $key => $item)
{
$item->browsernav = '';
$item->tag = $searchText;
if (searchHelper::checkNoHTML($item, $searchText, array('text', 'title', 'metakey', 'metadesc', 'section', 'image_caption', 'image_credits', 'video_caption', 'video_credits', 'extra_fields_search', 'tag')))
{
$new_row[] = $item;
}
}
$results = array_merge($results, (array)$new_row);
}
}
return $results;
}
}

26
plugins/search/k2/k2.xml Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="search" method="upgrade">
<name>Search - K2</name>
<author>JoomlaWorks</author>
<creationDate>July 8th, 2013</creationDate>
<copyright>Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.</copyright>
<authorEmail>please-use-the-contact-form@joomlaworks.net</authorEmail>
<authorUrl>www.joomlaworks.net</authorUrl>
<version>2.6.7</version>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<description>K2_THIS_PLUGIN_EXTENDS_THE_DEFAULT_JOOMLA_SEARCH_FUNCTIONALITY_TO_K2_CONTENT</description>
<files>
<filename plugin="k2">k2.php</filename>
</files>
<config>
<fields name="params">
<fieldset name="basic">
<field name="search_limit" type="text" size="5" default="50" label="K2_SEARCH_LIMIT" description="K2_THE_NUMBER_OF_ITEMS_TO_RETURN_WHEN_PERFORMING_A_SEARCH"/>
<field name="search_tags" type="radio" default="0" label="K2_ENABLE_SEARCHING_IN_TAGS" description="K2_SELECT_IF_YOU_WANT_TO_SEARCH_ITEMS_TAGS_NOTE_THAT_THIS_CAN_BE_VERY_SLOW_ON_LARGE_SITES">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

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

View File

@ -0,0 +1,182 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Search.newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Newsfeeds Search plugin
*
* @package Joomla.Plugin
* @subpackage Search.newsfeeds
* @since 1.6
*/
class PlgSearchNewsfeeds extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* @return array An array of search areas
*/
public function onContentSearchAreas()
{
static $areas = array(
'newsfeeds' => 'PLG_SEARCH_NEWSFEEDS_NEWSFEEDS'
);
return $areas;
}
/**
* Newsfeeds 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 the search it to be restricted to areas, null if search all
*/
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))
{
if (!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->isSite() && 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);
$rows = $db->loadObjectList();
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,55 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="search">
<name>plg_search_newsfeeds</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</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>
<filename>index.html</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="text"
default="50"
description="JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC"
label="JFIELD_PLG_SEARCH_SEARCHLIMIT_LABEL"
size="5"
/>
<field name="search_content" type="radio"
class="btn-group"
default="0"
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"
class="btn-group"
default="0"
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 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,207 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Search.weblinks
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php';
/**
* Weblinks Search plugin
*
* @package Joomla.Plugin
* @subpackage Search.weblinks
* @since 1.6
*/
class PlgSearchWeblinks extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* @return array An array of search areas
*/
public function onContentSearchAreas()
{
static $areas = array(
'weblinks' => 'PLG_SEARCH_WEBLINKS_WEBLINKS'
);
return $areas;
}
/**
* Weblink 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 the search it to be restricted to areas, null if search all
*/
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$searchText = $text;
if (is_array($areas))
{
if (!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_WEBLINKS');
/* 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.url LIKE ' . $text;
$wheres2[] = 'a.description LIKE ' . $text;
$wheres2[] = 'a.title 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.url LIKE ' . $word;
$wheres2[] = 'a.description LIKE ' . $word;
$wheres2[] = 'a.title LIKE ' . $word;
$wheres[] = implode(' OR ', $wheres2);
}
$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';
}
$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.title AS title, a.description AS text, a.created AS created, a.url, '
. $case_when . ',' . $case_when1 . ', '
. $query->concatenate(array($db->quote($section), "c.title"), " / ") . ' AS section, \'1\' AS browsernav'
)
->from('#__weblinks AS a')
->join('INNER', '#__categories AS c ON c.id = a.catid')
->where('(' . $where . ') AND a.state in (' . implode(',', $state) . ') AND c.published=1 AND c.access IN (' . $groups . ')')
->order($order);
// Filter by language
if ($app->isSite() && 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);
$rows = $db->loadObjectList();
$return = array();
if ($rows)
{
foreach ($rows as $key => $row)
{
$rows[$key]->href = WeblinksHelperRoute::getWeblinkRoute($row->slug, $row->catslug);
}
foreach ($rows as $weblink)
{
if (searchHelper::checkNoHTML($weblink, $searchText, array('url', 'text', 'title')))
{
$return[] = $weblink;
}
}
}
return $return;
}
}

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="search">
<name>plg_search_weblinks</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</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_WEBLINKS_XML_DESCRIPTION</description>
<files>
<filename plugin="weblinks">weblinks.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_search_weblinks.ini</language>
<language tag="en-GB">en-GB.plg_search_weblinks.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"
class="btn-group"
default="0"
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"
class="btn-group"
default="0"
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>