?? odt.searchbot.php
字號:
<?php/*** @package ODT_Indexer* @copyright (C) 2006 Websmurf* @author Websmurf* * --------------------------------------------------------------------------------* All rights reserved. ODT Indexer is a component for Joomla and Mambo. * You can use it to search through ODT files** This program is free software; you can redistribute it and/or* modify it under the terms of the Creative Commons - Attribution-NoDerivs 2.5 * license as published by the Creative Commons Organisation* http://creativecommons.org/licenses/by-nd/2.5/.** This program 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. * --------------------------------------------------------------------------------**/// no direct accessdefined( '_VALID_MOS' ) or die( 'Restricted access' );$_MAMBOTS->registerFunction( 'onSearch', 'botSearchODT' );/*** 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*/function botSearchODT( $text, $phrase='', $ordering='' ) { global $my, $database; global $mosConfig_offset, $mainframe; // load mambot params info $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'odt.searchbot'" . "\n AND folder = 'search'" ; $database->setQuery( $query ); $database->loadObject($mambot); $botParams = new mosParameters( $mambot->params ); $limit = $botParams->def( 'search_limit', 50 ); $nullDate = $database->getNullDate(); $now = date( 'Y-m-d H:i:s', time()+$mosConfig_offset*60*60 ); $text = trim( $text ); if ($text == '') { return array(); } $wheres = array(); switch ($phrase) { case 'exact': $where = "LOWER(a.content) LIKE '%$text%'"; break; case 'all': case 'any': default: $words = explode( ' ', $text ); $wheres = array(); foreach ($words as $word) { $wheres[] = "LOWER(a.content) LIKE '%$text%'"; } $where = '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wheres ) . ')'; break; } // echo "|". $where . "|"; $morder = ''; switch ($ordering) { case 'oldest': $order = 'a.indexed ASC'; break; case 'newest': $order = 'a.indexed DESC'; break; case 'category': case 'popular': case 'alpha': default: $order = 'a.path DESC'; break; } // search content items $query = "SELECT a.name AS title," . "\n a.content AS text," . "\n CONCAT( '". $mainframe->getCfg('live_site') . "/', a.path ) AS href," . "\n '1' AS browsernav" . "\n FROM #__odtindex AS a" . "\n WHERE ( $where )"// . "\n AND a.published = 1"// . "\n AND a.access <= $my->gid" . "\n GROUP BY a.id" . "\n ORDER BY $order" ; $database->setQuery( $query, 0, $limit ); $list = $database->loadObjectList(); echo $database->getErrorMsg();// echo $database->getQuery(); return $list;}?>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -