1. Laurent Orluc
  2. Plugins and Modules
  3. Tuesday, 09 October 2012
  4.  Subscribe via email
Well, the search plugin provided with version 3.1.1 of hotspots is not working at all, here is a corrected version of it

It's sad to pay for things that we have to correct ! this is not serious !

This code should be placed in plugins/search/hotspots/hotspots.php

<?php
/* * *************************************************************
* Copyright notice
*
* Copyright 2011 Daniel Dimitrov. (http://compojoom.com)
* All rights reserved
*
* This script is part of the Hotspots project. The Hotspots project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
* ************************************************************* */

defined('_JEXEC') or die('Restricted access');

jimport('joomla.plugin.plugin');

function HotSpotAreas() {
return array('hotspots' => 'Territoires');
}

class plgSearchHotspots 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();
}

// **************************************
// Joomla 1.5
// **************************************

/**
* @return array An array of search areas
*/
function onSearchAreas() {
//return $this->areas();
return HotSpotAreas();
}

function onSearch($text, $phrase='', $ordering='', $areas=null) {
return $this->search($text, $phrase = '', $ordering = '', $areas = null);
}

// **************************************
// Joomla 1.7
// **************************************

/**
* @return array An array of search areas
*/
function onContentSearchAreas() {
return HotSpotAreas();
}

function onContentSearch($text, $phrase='', $ordering='', $areas=null) {
return $this->search($text, $phrase = '', $ordering = '', $areas);
}


// ****************************************
// Search function that do the job
// ****************************************

private function search($text, $phrase='', $ordering='', $areas=null) {
if (!$text) {
return array();
}

if (is_array($areas)) {
if (!array_intersect($areas, array_keys(HotSpotAreas()))) {
return array();
}
}
$db = & JFactory::getDBO();
if ($phrase == 'exact') {
$text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
$where = "(LOWER(m.name) LIKE $text)
OR (LOWER(m.description_small) LIKE $text)" .
" OR (LOWER(m.description) LIKE $text)
OR (LOWER(m.street) LIKE $text)" .
" OR (LOWER(m.plz) LIKE $text)";
} else {
$words = explode(' ', $text);
$wherees = array();
foreach ($words as $word) {
$word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
$wheres[] = "(LOWER(m.name) LIKE $word)
OR (LOWER(m.description_small) LIKE $word)" .
" OR (LOWER(m.description) LIKE $word)
OR (LOWER(m.street) LIKE $word)" .
" OR (LOWER(m.plz) LIKE $word)";
}
if ($phrase == 'all') {
$seperator = "AND";
} else {
$seperator = "OR";
}
$where = '(' . implode(";) $seperator (", $wheres) . ')';
}
$where .= ' AND c.published = 1 AND m.published = 1';

switch ($ordering) {
case 'oldest':
$order = 'm.postdate ASC';
break;
case 'alpha':
$order = 'm.name ASC';
break;
case 'newest':
default:
$order = 'm.created DESC';
break;
}
jimport('joomla.html.parameter');
$plugin = & JPluginHelper::getPlugin('search', 'hotspots');
$pluginParams = new JParameter($plugin->params);
$limit = $pluginParams->get('search_limit', 50);

$query = "SELECT m.id, m.name AS title, m.description_small AS text, m.created, m.catid, " .
" 'Territoire' AS section," .
" c.cat_name, " .
" '2' AS browsernav" .
' FROM ' . $db->nameQuote('#__hotspots_marker') . ' AS m' .
' LEFT JOIN ' . $db->nameQuote('#__hotspots_categorie') . ' AS c' .
' ON m.catid = c.id ' .
" WHERE $where" .
" ORDER BY $order";
$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();

if (is_array($rows)) {
foreach ($rows as $key => $row) {
$urlcat = $row->catid . ':' . JFilterOutput::stringURLSafe($row->cat_name);
$urlid = $row->id . ':' . JFilterOutput::stringURLSafe($row->title);
$itemId = $this->getHotspotsItemid('com_hotspots');
$rows[$key]->href = JRoute::_("index.php?option=com_hotspots&view=hotspot&catid=" . $urlcat . "&id=" . $urlid . '&Itemid=' . $itemId);
}
}

return $rows;
}

/**
*
* @staticvar <int> $ids
* @param <string> $component
* @return <int>
*/
function getHotspotsItemid($component='') {
static $ids;
if (!isset($ids)) {
$ids = array();
}
if (!isset($ids[$component])) {
$database = & JFactory::getDBO();
$query = "SELECT id FROM #__menu"
. "\n WHERE link LIKE '%option=$component%'"
. "\n AND type = 'component'"
. "\n AND published = 1 LIMIT 1";
$database->setQuery($query);
$ids[$component] = $database->loadResult();
}
return $ids[$component];
}

}
Responses (1)


There are %s replies to this question. If you want to see them you need a valid subscription.
If you have a valid subscription, please login now.
Visit store now

Last questions

Dowload all Hotspots entries
Hi there, I'm looking for a way to dowload all the Hotspots entries. I've got t...
0 Replies
Posted on Sunday, 06 April 2025
  • #kml
  • #download
Set number of hotspots / user groups
Hi, I'm working with Hotspots for my new website and I love it! After trying ...
0 Replies
Posted on Monday, 31 March 2025
J5 compatibility for Hotspots
Hi guys, Just started to update my old J3x website. Is there J5 compatibility p...
1 Replies
Posted on Monday, 24 February 2025
  • #Hotspots
  • #hotspots Joomla 5
Text size in the comment input form
Hello. How can I increase the font size in the comment input field? For examp...
0 Replies
Posted on Wednesday, 26 February 2025
  • #CComment 6
Problem with enlarged image
Hello. When you click on the image in the comments, it does not appear in the ce...
1 Replies
Posted on Wednesday, 26 February 2025