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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
//
// Display.h
//
// Display: Takes results of search and fills in the HTML templates
//
// Part of the ht://Dig package <http://www.htdig.org/>
// Copyright (c) 1995-2004 The ht://Dig Group
// For copyright details, see the file COPYING in your distribution
// or the GNU Library General Public License (LGPL) version 2 or later
// <http://www.gnu.org/copyleft/lgpl.html>
//
// $Id: Display.h,v 1.27 2004/05/28 13:15:24 lha Exp $
//
#ifndef _Display_h_
#define _Display_h_
#include "Object.h"
#include "ResultList.h"
#include "ResultMatch.h"
#include "TemplateList.h"
#include "cgi.h"
#include "StringMatch.h"
#include "List.h"
#include "DocumentDB.h"
#include "Database.h"
#include "Dictionary.h"
#include "HtRegex.h"
class Display : public Object
{
public:
//
// Construction/Destruction
//
// Display(const String& docFile, const String& indexFile, const String& excerptFile);
Display(Dictionary *selected_collections);
~Display();
void setStartTemplate(const String& templateName);
void setMatchTemplate(const String& templateName);
void setEndTemplate(const String& templateName);
// inline void setResults(ResultList *results);
// inline void setSearchWords(List *searchWords);
inline void setLimit(HtRegex *);
inline void setExclude(HtRegex *);
// inline void setAllWordsPattern(StringMatch *);
inline void setLogicalWords(char *);
inline void setOriginalWords(char *);
inline void setCGI(cgi *);
void display(int pageNumber);
void displayMatch(ResultMatch *match, DocumentRef *ref, int current);
void displayHTTPheaders();
void displayHeader();
void displayFooter();
void displayNomatch();
void displaySyntaxError(const String &);
int hasTemplateError() {return templateError;}
protected:
//
// Multiple database support
//
Dictionary *selected_collections;
//
// Search Policy
char *search_policy;
//
// The list of search results.
//
// ResultList *results;
//
// The database that contains documents.
//
// DocumentDB docDB;
//
// A list of words that we are searching for
//
// List *searchWords;
//
// Pattern that all result URLs must match or exclude
//
HtRegex *limitTo;
HtRegex *excludeFrom;
//
// Pattern of all the words
//
// StringMatch *allWordsPattern;
//
// Variables for substitution into text are stored in a dictionary
//
Dictionary vars;
//
// Since the creation of excerpts is somewhat time consuming, we will
// only compute them if they're actually going to be used. This is the
// flag that tells us if we will need the excerpt.
//
int needExcerpt;
//
// Since we might have errors we cannot recover from, this tells us
// what happened.
//
int templateError;
//
// To allow the result templates to be dependant on the match URL, we need
// the following:
//
StringMatch URLtemplate;
List URLtemplateList;
//
// To allow the star images to be dependant on the match URL, we need
// the following:
//
StringMatch URLimage;
List URLimageList;
//
// Maximum number of stars to display
//
int maxStars;
double maxScore;
double minScore;
//
// For display, we have different versions of the list of words.
//
String logicalWords;
String originalWords;
//
// To be able to recreate the URL that will get to us again, we need
// the info from the HTML form that called us.
//
cgi *input;
//
// Match output is done through templates. This is the interface to these
// templates.
//
TemplateList templates;
Template *currentTemplate;
//
// Methods...
//
List *buildMatchList();
void sort(List *);
int includeURL(const String&);
String *readFile(const String&);
void expandVariables(const String&);
void outputVariable(const String&);
String *excerpt(ResultMatch *match, DocumentRef *ref,
String urlanchor, int fanchor, int &first);
const String buildExcerpts(StringMatch *allWordsPattern,
ResultMatch *match, char *head,
String urlanchor, int fanchor );
String hilight(ResultMatch *match, const String& str,
const String& urlanchor, int fanchor);
void setupTemplates();
void setupImages();
String *generateStars(DocumentRef *, int);
void displayParsedFile(const String&);
void setVariables(int, List *);
void createURL(String &, int);
void logSearch(int, List *);
};
//*****************************************************************************
inline void
Display::setLimit(HtRegex *limit)
{
limitTo = limit;
}
inline void
Display::setExclude(HtRegex *exclude)
{
excludeFrom = exclude;
}
#if 0
inline void
Display::setAllWordsPattern(StringMatch *pattern)
{
allWordsPattern = pattern;
}
inline void
Display::setResults(ResultList *results)
{
this->results = results;
}
inline void
Display::setSearchWords(List *searchWords)
{
this->searchWords = searchWords;
}
#endif
inline void
Display::setLogicalWords(char *s)
{
logicalWords = s;
vars.Add("LOGICAL_WORDS", new String(logicalWords));
}
inline void
Display::setOriginalWords(char *s)
{
originalWords = s;
vars.Add("WORDS", new String(originalWords));
}
inline void
Display::setCGI(cgi *aCgi)
{
input = aCgi;
}
#endif
|