1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
<?php
// $Header: /cvsroot/bitweaver/_bit_search/index.php,v 1.5 2006/01/10 21:16:31 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.
// Initialization
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();
$gBitSystem->verifyPackage( 'search' );
foreach( $gLibertySystem->mContentTypes as $cType ) {
$contentTypes[$cType['content_type_guid']] = $cType['content_description'];
}
$gBitSmarty->assign( 'contentTypes', $contentTypes );
if( !empty($_REQUEST["highlight"]) ) {
$_REQUEST["words"]=$_REQUEST["highlight"];
} else {
// a nice big, groovy search will be cool to have one day...
$gBitSystem->display( 'bitpackage:search/search.tpl');
die;
}
if ($feature_search_stats == 'y') {
$searchlib->register_search(isset($_REQUEST["words"]) ? $_REQUEST["words"] : '');
}
if (!isset($_REQUEST["where"])) {
$where = 'pages';
} else {
$where = $_REQUEST["where"];
}
$gBitSmarty->assign('where',$where);
$gBitSmarty->assign('where2',tra($where));
if($where=='wikis') {
$gBitSystem->verifyPackage( 'wiki' );
$gBitSystem->verifyPermission( 'bit_p_view' );
}
if($where=='directory') {
$gBitSystem->verifyPackage( 'directory' );
$gBitSystem->verifyPermission( 'bit_p_view_directory' );
}
if($where=='faqs') {
$gBitSystem->verifyPackage( 'faqs' );
$gBitSystem->verifyPermission( 'bit_p_view_faqs' );
}
if($where=='forums') {
$gBitSystem->verifyPackage( 'forums' );
$gBitSystem->verifyPermission( 'bit_p_forum_read' );
}
if($where=='files') {
$gBitSystem->verifyPackage( 'files' );
$gBitSystem->verifyPermission( 'bit_p_view_file_gallery' );
}
if($where=='articles') {
$gBitSystem->verifyPackage( 'articles' );
$gBitSystem->verifyPermission( 'bit_p_read_article' );
}
if (($where=='galleries' || $where=='images')) {
$gBitSystem->verifyPackage( 'image_gals' );
$gBitSystem->verifyPermission( 'bit_p_view_image_gallery' );
}
if(($where=='blogs' || $where=='posts')) {
$gBitSystem->verifyPackage( 'blogs' );
$gBitSystem->verifyPermission( 'bit_p_read_blog' );
}
if(($where=='trackers')) {
$gBitSystem->verifyPackage( 'trackers' );
$gBitSystem->verifyPermission( 'bit_p_view_trackers' );
}
// Already assigned above! $gBitSmarty->assign('where',$where);
if (!isset($_REQUEST["offset"])) {
$offset = 0;
} else {
$offset = $_REQUEST["offset"];
}
if (isset($_REQUEST['page'])) {
$page = &$_REQUEST['page'];
$offset = ($page - 1) * $maxRecords;
}
$gBitSmarty->assign_by_ref('offset', $offset);
$fulltext = $feature_search_fulltext == 'y';
// Build the query using words
if ((!isset($_REQUEST["words"])) || (empty($_REQUEST["words"]))) {
$results = $searchlib->find($where,' ', $offset, $maxRecords, $fulltext);
$gBitSmarty->assign('words', '');
} else {
$words = strip_tags($_REQUEST["words"]);
$results = $searchlib->find($where,$words, $offset, $maxRecords, $fulltext);
$gBitSmarty->assign('words', $words);
}
//if ($fulltext == 'y') {
// $CurrentIndex = -1;
// $CurrentData = NULL;
// foreach ($results["data"] as $current) {
// if ($current["relevance"] > 0) {
// $CurrentData[++$CurrentIndex] = $current;
// }
// }
// $results['data'] = $CurrentData;
// $results['cant'] = $CurrentIndex + 1;
//}
$stubContent = new LibertyContent();
if ( $results['cant'] > 0 ) {
foreach( array_keys( $results['data'] ) as $k ) {
if( !empty( $results['data'][$k]['data'] ) ) {
$results['data'][$k]['parsed'] = $stubContent->parseData( $results['data'][$k]['data'], $results['data'][$k]['format_guid'] );
}
}
}
$cant_pages = ceil($results["cant"] / $maxRecords);
$gBitSmarty->assign('cant_results', $results["cant"]);
$gBitSmarty->assign_by_ref('cant_pages', $cant_pages);
$gBitSmarty->assign('actual_page', 1 + ($offset / $maxRecords));
if ($results["cant"] > ($offset + $maxRecords)) {
$gBitSmarty->assign('next_offset', $offset + $maxRecords);
} else {
$gBitSmarty->assign('next_offset', -1);
}
// If offset is > 0 then prev_offset
if ($offset > 0) {
$gBitSmarty->assign('prev_offset', $offset - $maxRecords);
} else {
$gBitSmarty->assign('prev_offset', -1);
}
// Find search results (build array)
$gBitSmarty->assign_by_ref('results', $results["data"]);
// Display the template
$gBitSystem->display( 'bitpackage:search/search.tpl');
?>
|