summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2007-07-02 08:05:56 +0000
committerLester Caine <lester@lsces.co.uk>2007-07-02 08:05:56 +0000
commit3ec286b17a552caf59e52260dbe66332cc605f9c (patch)
treeeb0577524378188558bc8b8b3b3a8b2a716ecd13 /index.php
parent2392cea082831bbc68262ceeefcabc12d1378bbd (diff)
downloadsearch-3ec286b17a552caf59e52260dbe66332cc605f9c.tar.gz
search-3ec286b17a552caf59e52260dbe66332cc605f9c.tar.bz2
search-3ec286b17a552caf59e52260dbe66332cc605f9c.zip
Complete conversion of pagination and tidy up content type selection
Diffstat (limited to 'index.php')
-rw-r--r--index.php59
1 files changed, 22 insertions, 37 deletions
diff --git a/index.php b/index.php
index 6ec6b8b..f898c89 100644
--- a/index.php
+++ b/index.php
@@ -1,6 +1,6 @@
<?php
-// $Header: /cvsroot/bitweaver/_bit_search/index.php,v 1.21 2006/12/31 13:01:16 squareing Exp $
+// $Header: /cvsroot/bitweaver/_bit_search/index.php,v 1.22 2007/07/02 08:05:56 lsces 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.
@@ -10,7 +10,6 @@
require_once( '../bit_setup_inc.php' );
require_once( SEARCH_PKG_PATH.'/search_lib.php');
-// note: lib/search/searchlib.php is new. the old one was lib/searchlib.php
$searchlib = &new SearchLib();
@@ -24,6 +23,7 @@ if( empty( $contentTypes ) ) {
$contentTypes[$cType['content_type_guid']] = $cType['content_description'];
}
}
+asort($contentTypes);
$gBitSmarty->assign( 'contentTypes', $contentTypes );
if( !empty($_REQUEST["highlight"]) ) {
@@ -38,9 +38,11 @@ if ($gBitSystem->isFeatureActive("stats_search")) {
$searchlib->register_search(isset($_REQUEST["words"]) ? $_REQUEST["words"] : '');
}
-$content_type_guid = '';
-if (isset($_REQUEST["content_type_guid"])) {
- $content_type_guid = $_REQUEST["content_type_guid"];
+if (!isset($_REQUEST["content_type_guid"])) {
+ $_REQUEST["content_type_guid"] = '';
+ $where2 = "Page";
+} else {
+ $where2 = $contentTypes[$_REQUEST["content_type_guid"]];
}
LibertyContent::prepGetList($_REQUEST);
@@ -54,60 +56,43 @@ $gBitSmarty->assign('searchType', $_REQUEST['usePart'] ? "Using Partial Word Sea
// Build the query using words
if ((!isset($_REQUEST["words"])) || (empty($_REQUEST["words"]))) {
- $words = '';
+ $_REQUEST["words"] = '';
} else {
- $words = strip_tags($_REQUEST["words"]);
-}
-$gBitSmarty->assign('words', $words);
-$results = $searchlib->find($content_type_guid, $words, $_REQUEST['offset'], $_REQUEST['max_records'], $_REQUEST["usePart"]);
-$cant = $results['cant'];
-
-switch ($content_type_guid) {
- case "bitarticle" : $where2 = "Article"; break;
- case "bitpage" : $where2 = "Wiki Page"; break;
- case "bitblogpost" : $where2 = "Blog Post"; break;
- case "bitcomment" : $where2 = "Comment"; break;
- default : $where2 = "Page"; break;
+ $_REQUEST["words"] = strip_tags($_REQUEST["words"]);
}
+$gBitSmarty->assign('words', $_REQUEST["words"]);
+$results = $searchlib->find( $_REQUEST );
-if ($cant <> 1) $where2 .= "s";
-$gBitSmarty->assign('content_type_guid', $content_type_guid);
+if ($_REQUEST['cant'] <> 1) $where2 .= "s";
$gBitSmarty->assign('where2', tra($where2));
+$gBitSmarty->assign('content_type_guid', $_REQUEST["content_type_guid"]);
$stubContent = new LibertyContent();
-if ( $cant > 0 ) {
- foreach( array_keys( $results['data'] ) as $k ) {
- if( empty( $results['data'][$k]['title'] ) ) {
+if ( $_REQUEST['cant'] > 0 ) {
+ foreach( array_keys( $results ) as $k ) {
+ if( empty( $results[$k]['title'] ) ) {
$date_format = $gBitSystem->get_long_date_format();
if( $gBitSystem->mServerTimestamp->get_display_offset() ) {
$date_format = preg_replace( "/ ?%Z/", "", $date_format );
} else {
$date_format = preg_replace( "/%Z/", "UTC", $date_format );
}
- $date_string = $gBitSystem->mServerTimestamp->getDisplayDateFromUTC( $results['data'][$k]['created'] );
- $results['data'][$k]['title'] = $gBitSystem->mServerTimestamp->strftime( $date_format, $date_string, true );
+ $date_string = $gBitSystem->mServerTimestamp->getDisplayDateFromUTC( $results[$k]['created'] );
+ $results[$k]['title'] = $gBitSystem->mServerTimestamp->strftime( $date_format, $date_string, true );
}
- if( !empty( $results['data'][$k]['data'] ) ) {
- $results['data'][$k]['parsed'] = $stubContent->parseData( $results['data'][$k] );
+ if( !empty( $results[$k]['data'] ) ) {
+ $results[$k]['parsed'] = $stubContent->parseData( $results[$k] );
}
}
}
-// calculate page number
-$numPages = ceil( $cant / $gBitSystem->getConfig( 'max_records' ) );
-$gBitSmarty->assign( 'numPages', $numPages );
-
-$_REQUEST['cant'] = $cant;
-$_REQUEST['control']['parameters']['highlight'] = $_REQUEST["highlight"];
-$_REQUEST['control']['parameters']['content_type_guid'] = $content_type_guid;
LibertyContent::postGetList( $_REQUEST );
-$gBitSmarty->assign_by_ref( 'listInfo', $_REQUEST["control"] );
-$gBitSmarty->assign('cant_results', $cant);
+$gBitSmarty->assign_by_ref( 'listInfo', $_REQUEST['listInfo'] );
$partialOnOff = $_REQUEST["usePart"] ? 'checked' : '';
$gBitSmarty->assign('partialOnOff', $partialOnOff);
// Find search results (build array)
-$gBitSmarty->assign_by_ref('results', $results["data"]);
+$gBitSmarty->assign_by_ref('results', $results);
// Display the template
$gBitSystem->display( 'bitpackage:search/search.tpl', 'Search Results for: '.strip_tags($_REQUEST["highlight"]));