diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2006-12-26 17:10:46 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2006-12-26 17:10:46 +0000 |
| commit | 7be1d39d496dded45e0e9f816dec9f3e8d1c7141 (patch) | |
| tree | 7c8db1924535fce18a918de927e40ae164872edf | |
| parent | d6039b3a7ca9081049c279bc788034fac43a6b49 (diff) | |
| download | search-7be1d39d496dded45e0e9f816dec9f3e8d1c7141.tar.gz search-7be1d39d496dded45e0e9f816dec9f3e8d1c7141.tar.bz2 search-7be1d39d496dded45e0e9f816dec9f3e8d1c7141.zip | |
fix some baic search issues
| -rw-r--r-- | admin/admin_search_inc.php | 62 | ||||
| -rw-r--r-- | refresh_functions.php | 12 | ||||
| -rw-r--r-- | search_lib.php | 7 | ||||
| -rw-r--r-- | templates/admin_search.tpl | 53 |
4 files changed, 75 insertions, 59 deletions
diff --git a/admin/admin_search_inc.php b/admin/admin_search_inc.php index 07262d9..ca401be 100644 --- a/admin/admin_search_inc.php +++ b/admin/admin_search_inc.php @@ -1,10 +1,13 @@ <?php -// $Header: /cvsroot/bitweaver/_bit_search/admin/admin_search_inc.php,v 1.11 2006/08/18 11:10:31 sylvieg Exp $ +// $Header: /cvsroot/bitweaver/_bit_search/admin/admin_search_inc.php,v 1.12 2006/12/26 17:10:46 squareing Exp $ // Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. // All Rights Reserved. See copyright.txt for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +$feedback = array(); + $formSearchToggles = array( 'search_stats' => array( 'label' => 'Search Statistics', @@ -16,6 +19,7 @@ $formSearchToggles = array( 'note' => 'Index articles, blogs and wiki pages immdiately on submission. If unchecked, pages will be updated randomly according the the refresh rate below.', ), ); + $formSearchInts = array( 'search_refresh_rate' => array( 'label' => 'Search Refresh Rate', @@ -43,39 +47,43 @@ $formSearchInts = array( ), ); -if (isset($_REQUEST["searchaction"])) { - switch (strtolower($_REQUEST["searchaction"])) { - case "change preferences" : - foreach( $formSearchInts as $item => $data ) { - simple_set_int( $item, SEARCH_PKG_NAME ); - $formSearchInts[$item]['value'] = $_REQUEST[$item]; - } - foreach( $formSearchToggles as $item => $data ) { - simple_set_toggle( $item, SEARCH_PKG_NAME ); - } - break; - case "clear searchwords" : - require_once( SEARCH_PKG_PATH.'/refresh_functions.php'); - delete_search_words_and_syllables(); - break; - case "delete index only" : - require_once( SEARCH_PKG_PATH.'/refresh_functions.php'); - delete_index_content_type($_REQUEST["where"]); - break; - case "delete and rebuild index" : - require_once( SEARCH_PKG_PATH.'/refresh_functions.php'); - rebuild_index($_REQUEST["where"]); - break; +if( !empty( $_REQUEST['del_index'] ) ) { + require_once( SEARCH_PKG_PATH.'/refresh_functions.php' ); + delete_index_content_type( $_REQUEST["where"] ); + $feedback['success'] = tra( "The search index was successfully deleted." ); +} + +if( !empty( $_REQUEST['del_index_reindex'] ) ) { + require_once( SEARCH_PKG_PATH.'/refresh_functions.php' ); + $count = rebuild_index( $_REQUEST["where"] ); + $feedback['success'] = tra( "The search index was successfully deleted." ).tra( "Number of items re-indexed" ).": ".$count; +} + +if( !empty( $_REQUEST['del_searchwords'] ) ) { + require_once( SEARCH_PKG_PATH.'/refresh_functions.php' ); + delete_search_words_and_syllables(); + $feedback['success'] = tra( "The searchwords were successfully purged from the database." ); +} + +if( !empty( $_REQUEST['store_prefs'] ) ) { + foreach( $formSearchInts as $item => $data ) { + simple_set_int( $item, SEARCH_PKG_NAME ); + $formSearchInts[$item]['value'] = $_REQUEST[$item]; + } + foreach( $formSearchToggles as $item => $data ) { + simple_set_toggle( $item, SEARCH_PKG_NAME ); } } + foreach( $formSearchInts as $item => $data ) { $formSearchInts[$item]['value'] = $gBitSystem->getConfig( $item ); } -$gBitSmarty->assign( 'formSearchToggles',$formSearchToggles ); -$gBitSmarty->assign( 'formSearchInts',$formSearchInts ); +$gBitSmarty->assign( 'formSearchToggles', $formSearchToggles ); +$gBitSmarty->assign( 'formSearchInts', $formSearchInts ); +$gBitSmarty->assign( 'feedback', $feedback ); /* usually done in mod_package_search.php - but the module can be not here the first time */ -if ( empty($contentTypes) ) { +if( empty( $contentTypes ) ) { $contentTypes = array( '' => 'All Content' ); foreach( $gLibertySystem->mContentTypes as $cType ) { $contentTypes[$cType['content_type_guid']] = $cType['content_description']; diff --git a/refresh_functions.php b/refresh_functions.php index 33aab06..8ca0927 100644 --- a/refresh_functions.php +++ b/refresh_functions.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_search/refresh_functions.php,v 1.28 2006/10/11 06:05:45 spiderr Exp $ + * $Header: /cvsroot/bitweaver/_bit_search/refresh_functions.php,v 1.29 2006/12/26 17:10:46 squareing Exp $ * * Copyright (c) 2004 bitweaver.org * Copyright (c) 2003 tikwiki.org @@ -8,7 +8,7 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: refresh_functions.php,v 1.28 2006/10/11 06:05:45 spiderr Exp $ + * $Id: refresh_functions.php,v 1.29 2006/12/26 17:10:46 squareing Exp $ * @author Luis Argerich (lrargerich@yahoo.com) * @package search * @subpackage functions @@ -186,11 +186,12 @@ function rebuild_index($pContentType, $pUnindexedOnly = false) { delete_index_content_type($pContentType); } $query = "SELECT `content_id`, `content_type_guid` FROM `" . BIT_DB_PREFIX . "liberty_content`"; - if ( $pContentType <> "pages") { + if( !empty( $pContentType ) && $pContentType != "pages" ) { $whereClause = " WHERE `content_type_guid` = ?"; $arguments[] = $pContentType; } - if ($pUnindexedOnly) { + + if( $pUnindexedOnly ) { if (empty($whereClause)) { $whereClause = " WHERE "; } else { @@ -198,8 +199,9 @@ function rebuild_index($pContentType, $pUnindexedOnly = false) { } $whereClause .= "`content_id` NOT IN (SELECT DISTINCT `content_id` FROM `" . BIT_DB_PREFIX . "search_index`)" ; } + $orderBy = " ORDER BY `content_type_guid` "; - $result = $gBitSystem->mDb->query($query . $whereClause . $orderBy, $arguments); + $result = $gBitSystem->mDb->query( $query.$whereClause.$orderBy, $arguments ); $count = 0; if( $result ) { $count = $result->RecordCount(); diff --git a/search_lib.php b/search_lib.php index a7288fc..8bd45a2 100644 --- a/search_lib.php +++ b/search_lib.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_search/search_lib.php,v 1.27 2006/10/21 20:21:52 lsces Exp $ + * $Header: /cvsroot/bitweaver/_bit_search/search_lib.php,v 1.28 2006/12/26 17:10:46 squareing Exp $ * * Copyright (c) 2004 bitweaver.org * Copyright (c) 2003 tikwiki.org @@ -8,7 +8,7 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: search_lib.php,v 1.27 2006/10/21 20:21:52 lsces Exp $ + * $Id: search_lib.php,v 1.28 2006/12/26 17:10:46 squareing Exp $ * @author Luis Argerich (lrargerich@yahoo.com) * @package search */ @@ -196,7 +196,7 @@ class SearchLib extends BitBase { LEFT OUTER JOIN `".BIT_DB_PREFIX."liberty_content_hits` lch ON (lc.`content_id` = lch.`content_id`) $joinSql WHERE ( - SELECT FIRST 1 SUM(i_count) + SELECT SUM(i_count) FROM `" . BIT_DB_PREFIX . "search_index` si WHERE si.`content_id`=lc.`content_id` GROUP BY @@ -206,6 +206,7 @@ class SearchLib extends BitBase { )>0 $whereSql ORDER BY 9 DESC, 5 DESC "; + //SELECT FIRST 1 SUM(i_count) $querycant = "SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "liberty_content` lc diff --git a/templates/admin_search.tpl b/templates/admin_search.tpl index daf0ff7..0077865 100644 --- a/templates/admin_search.tpl +++ b/templates/admin_search.tpl @@ -1,41 +1,46 @@ {strip} {jstabs} {jstab title="Search Settings"} + {formfeedback hash=$feedback} + {form legend="Search Settings"} <input type="hidden" name="page" value="{$page}" /> - {foreach from=$formSearchToggles key=item item=output} - <div class="row"> - {formlabel label=`$output.label` for=$item} - {forminput} - {html_checkboxes name="$item" values="y" checked=$gBitSystem->getConfig($item) labels=false id=$item} - {formhelp note=`$output.note` page=`$output.page`} - {/forminput} - </div> - {/foreach} + {foreach from=$formSearchToggles key=item item=output} + <div class="row"> + {formlabel label=`$output.label` for=$item} + {forminput} + {html_checkboxes name="$item" values="y" checked=$gBitSystem->getConfig($item) labels=false id=$item} + {formhelp note=`$output.note` page=`$output.page`} + {/forminput} + </div> + {/foreach} - {foreach from=$formSearchInts key=item item=output} - <div class="row"> - {formlabel label=`$output.label` for=$item} - {forminput} - <input size="5" type="text" name="{$item}" id="{$item}" value="{$output.value|escape}" /> - {formhelp note=`$output.note` page=`$output.page`} - {/forminput} - </div> - {/foreach} + {foreach from=$formSearchInts key=item item=output} + <div class="row"> + {formlabel label=`$output.label` for=$item} + {forminput} + <input size="5" type="text" name="{$item}" id="{$item}" value="{$output.value|escape}" /> + {formhelp note=`$output.note` page=`$output.page`} + {/forminput} + </div> + {/foreach} - <div class="row submit"> - <input type="submit" name="searchaction" value="{tr}Change preferences{/tr}" /> - </div> + <div class="row submit"> + <input type="submit" name="store_prefs" value="{tr}Change preferences{/tr}" /> + </div> {/form} {/jstab} + {jstab title="Delete / Rebuild Index"} + {formfeedback hash=$feedback} + {form legend="Delete / Rebuild Index"} <input type="hidden" name="page" value="{$page}" /> <div class="row"> {formlabel label="Clear Searchwords:" for="clearss"} {forminput} - <input type="submit" class="wikiaction" name="searchaction" value="{tr}Clear Searchwords{/tr}"/> + <input type="submit" name="del_searchwords" value="{tr}Clear Searchwords{/tr}"/> {formhelp note="This clears out the cache of recently searched for terms and the syllables derived from those search terms."} {/forminput} </div> @@ -54,9 +59,9 @@ {/forminput} </div> <div class="row submit"> - <input type="submit" class="wikiaction" name="searchaction" value="{tr}Delete Index Only{/tr}"/> + <input type="submit" name="del_index" value="{tr}Delete Index Only{/tr}"/> - <input type="submit" class="wikiaction" name="searchaction" value="{tr}Delete and Rebuild Index{/tr}"/> + <input type="submit" name="del_index_reindex" value="{tr}Delete and Rebuild Index{/tr}"/> </div> {/form} {/jstab} |
