bengi
19-05-2007, 13:15:04
Arkadaşlar sözlük bileşeninde en çok istediğim özellik olan sözlükte en çok arananlar ve en son aranan kelimenin bu bot yardımıyla yapılabileceğini buldum. Ancak bu bot joomla 1 0 12 çalışmasına rağmen joomla 1.5 de çalıştıramadım . Admin panelindeki link te aranan kelimeleri listeliyor ancak sitenin ön bölümünde arama sonucunu göstermiyor. Kod yapısıyla ilgili olarak joomla 1.5 nasıl uyumlu yapabilirim ?
<?php
##########################################
# Glossary Searchbot for Mambo 4.5.1 #
# Copyright : Martin Brampton #
# Homepage : www.remository.com #
# Version : 1.6 (7 September 2005) #
# License : Released under GPL #
##########################################
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$_MAMBOTS->registerFunction( 'onSearch', 'botSearchGlossary' );
/**
* Search method
* @param array Named 'text' element is the search term
*/
function botSearchGlossary( $text, $matchtype='', $order='' ) {
global $database, $mosConfig_live_site;
$text = trim($text);
if (!$text) return array();
switch ($matchtype) {
case 'exact':
$text = '"'.$text.'"';
$isbool = 'IN BOOLEAN MODE';
break;
case 'all':
$words = explode(' ',$text);
foreach ($words as $i=>$value) $words[$i] = '+'.$value;
$text = implode(' ',$words);
$isbool = 'IN BOOLEAN MODE';
break;
case 'any':
default:
$isbool = '';
}
if ($isbool) {
$database->setQuery('SELECT VERSION()');
if (substr($database->loadResult(),0,1) < 4) $isbool = '';
}
$section = "\n 'File Repository' AS section,";
switch ($order) {
case 'popular':
$seq = 'NULL';
break;
case 'category':
$seq = 'b.title ASC, a.tterm ASC';
break;
case 'oldest':
$seq = 'a.tdate ASC';
break;
case 'newest':
$seq = 'a.tdate DESC';
break;
case 'alpha':
default:
$seq = 'a.tterm ASC';
}
$seq = ' ORDER BY '.$seq;
# Perform database query and return result list
$sql = "SELECT DISTINCT a.tterm AS title,"
. "\n a.tdefinition AS text,"
. "\n a.tdate AS created,"
. "\n CONCAT_WS( ' / ', 'Glossary', b.title ) AS section,"
. "\n concat( 'index.php?option=com_glossary&func=display&catid=', a.catid, '&search=', a.tterm) AS href, "
. "\n '2' AS browsernav,"
. "\n a.id AS resultid"
. "\n FROM #__glossary AS a,"
. "\n #__menu AS m,"
. "\n #__categories AS b"
. "\n WHERE MATCH (a.tdefinition) AGAINST ('$text' $isbool)"
. "\n OR a.tterm LIKE '%$text%'"
. "\n AND m.link = 'index.php?option=com_glossary'"
. "\n AND b.id = a.catid"
. $seq;
$database->setQuery($sql);
$results = $database->loadObjectList();
$ids = array();
if ($results) {
foreach ($results as $key=>$hit) {
if (in_array($hit->resultid,$ids)) unset($results[$key]);
else $ids[] = $hit->resultid;
}
}
else $results = array();
return $results;
}
?>
<?php
##########################################
# Glossary Searchbot for Mambo 4.5.1 #
# Copyright : Martin Brampton #
# Homepage : www.remository.com #
# Version : 1.6 (7 September 2005) #
# License : Released under GPL #
##########################################
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$_MAMBOTS->registerFunction( 'onSearch', 'botSearchGlossary' );
/**
* Search method
* @param array Named 'text' element is the search term
*/
function botSearchGlossary( $text, $matchtype='', $order='' ) {
global $database, $mosConfig_live_site;
$text = trim($text);
if (!$text) return array();
switch ($matchtype) {
case 'exact':
$text = '"'.$text.'"';
$isbool = 'IN BOOLEAN MODE';
break;
case 'all':
$words = explode(' ',$text);
foreach ($words as $i=>$value) $words[$i] = '+'.$value;
$text = implode(' ',$words);
$isbool = 'IN BOOLEAN MODE';
break;
case 'any':
default:
$isbool = '';
}
if ($isbool) {
$database->setQuery('SELECT VERSION()');
if (substr($database->loadResult(),0,1) < 4) $isbool = '';
}
$section = "\n 'File Repository' AS section,";
switch ($order) {
case 'popular':
$seq = 'NULL';
break;
case 'category':
$seq = 'b.title ASC, a.tterm ASC';
break;
case 'oldest':
$seq = 'a.tdate ASC';
break;
case 'newest':
$seq = 'a.tdate DESC';
break;
case 'alpha':
default:
$seq = 'a.tterm ASC';
}
$seq = ' ORDER BY '.$seq;
# Perform database query and return result list
$sql = "SELECT DISTINCT a.tterm AS title,"
. "\n a.tdefinition AS text,"
. "\n a.tdate AS created,"
. "\n CONCAT_WS( ' / ', 'Glossary', b.title ) AS section,"
. "\n concat( 'index.php?option=com_glossary&func=display&catid=', a.catid, '&search=', a.tterm) AS href, "
. "\n '2' AS browsernav,"
. "\n a.id AS resultid"
. "\n FROM #__glossary AS a,"
. "\n #__menu AS m,"
. "\n #__categories AS b"
. "\n WHERE MATCH (a.tdefinition) AGAINST ('$text' $isbool)"
. "\n OR a.tterm LIKE '%$text%'"
. "\n AND m.link = 'index.php?option=com_glossary'"
. "\n AND b.id = a.catid"
. $seq;
$database->setQuery($sql);
$results = $database->loadObjectList();
$ids = array();
if ($results) {
foreach ($results as $key=>$hit) {
if (in_array($hit->resultid,$ids)) unset($results[$key]);
else $ids[] = $hit->resultid;
}
}
else $results = array();
return $results;
}
?>