" ); class Search extends CMSModule { private $_tools_loaded = false; private function load_tools() { if( !$this->_tools_loaded ) { $fn = dirname(__FILE__).'/search.tools.php'; include_once($fn); $this->_tools_loaded = true; } } function LazyLoadFrontend() { return TRUE; } function LazyLoadAdmin() { return TRUE; } function GetName() { return 'Search'; } function GetFriendlyName() { return $this->Lang('search'); } function IsPluginModule() { return true; } function HasAdmin() { return true; } function HandlesEvents () { return true; } function GetVersion() { return '1.7.11'; } function MinimumCMSVersion() { return '1.11.7'; } function GetAdminDescription() { return $this->Lang('description'); } function GetAuthor() { return 'Ted Kulp'; } function GetAuthorEmail() { return 'ted@cmsmadesimple.org'; } function GetChangeLog() { return @file_get_contents(dirname(__FILE__).'/changelog.inc'); } function GetHelp($lang='en_US') { return $this->Lang('help'); } function GetEventDescription( $eventname ) { return $this->lang('eventdesc-' . $eventname); } function GetEventHelp( $eventname ) { return $this->lang('eventhelp-' . $eventname); } function RegisterEvents() { $this->AddEventHandler( 'Core', 'ContentEditPost', false ); $this->AddEventHandler( 'Core', 'ContentDeletePost', false ); // $this->AddEventHandler( 'Core', 'AddTemplatePost', false ); // $this->AddEventHandler( 'Core', 'EditTemplatePost', false ); // $this->AddEventHandler( 'Core', 'DeleteTemplatePost', false ); // $this->AddEventHandler( 'Core', 'AddGlobalContentPost', false ); // $this->AddEventHandler( 'Core', 'EditGlobalContentPost', false ); // $this->AddEventHandler( 'Core', 'DeleteGlobalContentPost', false ); $this->AddEventHandler( 'Core', 'ModuleUninstalled', false ); } function VisibleToAdminUser() { return $this->CheckPermission('Modify Site Preferences') || $this->CheckPermission('Modify Templates'); } public function InitializeAdmin() { $this->CreateParameter('inline','false',$this->Lang('param_inline')); $this->CreateParameter('passthru_*','null',$this->Lang('param_passthru')); $this->CreateParameter('modules','null',$this->Lang('param_modules')); $this->CreateParameter('resultpage', 'null', $this->Lang('param_resultpage')); $this->CreateParameter('searchtext','null',$this->Lang('param_searchtext')); $this->CreateParameter('detailpage','null',$this->Lang('param_detailpage')); $this->CreateParameter('submit',$this->Lang('searchsubmit'),$this->Lang('param_submit')); $this->CreateParameter('action','default',$this->Lang('param_action')); $this->CreateParameter('pageid','null',$this->Lang('param_pageid')); $this->CreateParameter('count','null',$this->Lang('param_count')); $this->CreateParameter('search_method','get',$this->Lang('search_method')); } public function InitializeFrontend() { $this->RestrictUnknownParams(); $this->SetParameterType('inline',CLEAN_STRING); $this->SetParameterType(CLEAN_REGEXP.'/passthru_.*/',CLEAN_STRING); $this->SetParameterType('modules',CLEAN_STRING); $this->SetParameterType('resultpage',CLEAN_STRING); $this->SetParameterType('detailpage',CLEAN_STRING); $this->SetParameterType('searchtext',CLEAN_STRING); $this->SetParameterType('searchinput',CLEAN_STRING); $this->SetParameterType('submit',CLEAN_STRING); $this->SetParameterType('origreturnid',CLEAN_INT); $this->SetParameterType('pageid',CLEAN_INT); $this->SetParameterType('count',CLEAN_INT); $this->SetParameterType('use_or',CLEAN_INT); $this->SetParameterType('search_method',CLEAN_STRING); } function GetSearchHtmlTemplate() { return ' {$startform} {*
*} {if isset($hidden)}{$hidden}{/if} {$endform}'; } function GetResultsHtmlTemplate() { $text = <<{\$searchresultsfor} "{\$phrase}" {if \$itemcount > 0}

{\$timetaken}: {\$timetook}

{else}

{\$noresultsfound}

{/if} EOT; return $text; } function DefaultStopWords() { return $this->Lang('default_stopwords'); } function RemoveStopWordsFromArray($words) { $stop_words = preg_split("/[\s,]+/", $this->GetPreference('stopwords', $this->DefaultStopWords())); return array_diff($words, $stop_words); } function StemPhrase($phrase) { $this->load_tools(); return search_StemPhrase($this,$phrase); } function AddWords($module = 'Search', $id = -1, $attr = '', $content = '', $expires = NULL) { $this->load_tools(); return search_AddWords($this,$module,$id,$attr,$content,$expires); } function DeleteWords($module = 'Search', $id = -1, $attr = '') { $this->load_tools(); return search_DeleteWords($this,$module,$id,$attr); } function DeleteAllWords($module = 'Search', $id = -1, $attr = '') { $db = $this->GetDb(); $db->Execute('DELETE FROM '.cms_db_prefix().'module_search_index'); $db->Execute('DELETE FROM '.cms_db_prefix().'module_search_items'); @$this->SendEvent('SearchAllItemsDeleted',array($module, $id, $attr)); } function Reindex() { $this->load_tools(); return search_Reindex($this); } function DoEvent($originator,$eventname,&$params) { $this->load_tools(); return search_DoEvent($this, $originator, $eventname, $params); } function HasCapability($capability,$params = array()) { if( strtolower($capability) == 'search' ) return TRUE; return FALSE; } } # vim:ts=4 sw=4 noet ?>