Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2670 | bpr | 1 | |
2 | Processing search request. |
||
33 | reyssat | 3 | !nocache |
4 | !if $wims_referer!=$empty and $wims_user=$empty and $wims_new_session=yes |
||
5 | refcut=!replace internal :// by $ $ in $wims_referer |
||
6 | refcut=!word 2 of $refcut |
||
7 | refcut=!translate internal /. to $ , in $refcut |
||
8 | !distribute words $refcut into refsite, refsearch |
||
9 | refdom=!item -2 of $refsite |
||
10 | refdom=!lower $refdom |
||
11 | reffields=!defof $refdom in searchengines |
||
12 | !if $reffields!=$empty |
||
13 | !distribute items $reffields into refs,refl |
||
14 | refsearch=!translate internal ?&= to ,, $ in $refsearch |
||
15 | !for rs in $refsearch |
||
16 | refw1=!word 1 of $rs |
||
17 | !if $refw1=$refs |
||
18 | refS=!word 2 to -1 of $rs |
||
19 | refS=!lower $refS |
||
20 | refS=!unhttp $refS |
||
21 | refS=!translate internal + to $ 4 in $refS |
||
22 | refS=!replace word wims by $ in $refS |
||
23 | refS=!trim $refS |
||
24 | !endif |
||
25 | !if $refw1=$refl |
||
26 | refL=!word 2 of $rs |
||
27 | !endif |
||
28 | !next rs |
||
29 | !if $refS!=$empty |
||
30 | search_category=A |
||
31 | search_keywords=$refS |
||
32 | !endif |
||
33 | !endif |
||
34 | !endif |
||
6739 | bpr | 35 | !reset test_exist |
33 | reyssat | 36 | |
37 | s2dir=!replace internal sessions/ by s2/ in $wims_sesdir |
||
38 | s2dir=!translate internal _ to $ $ in $s2dir |
||
39 | s2dir=!word 1 of $s2dir |
||
40 | !if $wims_accessright!=$empty and $wims_class!=$empty |
||
41 | !default search_package=!getdef package in wimshome/$s2dir/home_search |
||
42 | !bound search_package within $wims_accessright default bases/site |
||
43 | !else |
||
44 | search_package=bases/site |
||
45 | !endif |
||
46 | !if $search_package=bases/site |
||
47 | search_package1=wimshome/public_html/$search_package |
||
48 | search_package2=$search_package |
||
49 | !else |
||
50 | search_package1=wimshome/public_html/modules/$search_package/.index |
||
51 | search_package2=modules/$search_package/.index |
||
52 | !endif |
||
53 | |||
54 | # Limit of shown items |
||
55 | gotlim=1000 |
||
56 | gotlim2=50 |
||
57 | list_batch=20 |
||
2725 | bpr | 58 | !default search_lang=$lang |
2671 | bpr | 59 | !read adm/search_engine/mklist_form.proc $search_lang |
11391 | bpr | 60 | !read adm/lang/levelname.phtml.$lang |
11392 | bpr | 61 | !set Listlevel=$wims_listlevel |
11390 | bpr | 62 | !set levelcnt=!itemcnt $Listlevel |
63 | !set listlevel=!makelist level x for x in $Listlevel |
||
64 | !set listlevel=!nospace $listlevel |
||
65 | !set listlevel=!lowercase $listlevel |
||
66 | |||
33 | reyssat | 67 | !if $wims_user=supervisor |
11390 | bpr | 68 | !set cl=!positionof item $class_level in $Listlevel |
69 | !default search_level_from=$[max(1,$cl-1)] |
||
70 | !default search_level_to=$[$cl+1] |
||
33 | reyssat | 71 | !endif |
11406 | bpr | 72 | !if $search_level_from=1 and $search_level_to=$levelcnt |
73 | !reset search_level_from search_level_to |
||
74 | !endif |
||
33 | reyssat | 75 | |
76 | !if $list=clear |
||
77 | search_category=V |
||
78 | search_keywords= |
||
79 | list= |
||
80 | !writefile wimshome/$s2dir/home_search package=$search_package |
||
81 | gotcnt=0 |
||
82 | !exit |
||
83 | !endif |
||
84 | |||
85 | !if _tool isin $wims_session |
||
86 | search_category=T |
||
87 | !endif |
||
11390 | bpr | 88 | !if $search_level_from!=$empty |
89 | !default search_level_to=-1 |
||
90 | search_level=$(listlevel[$search_level_from .. $search_level_to]) |
||
91 | !endif |
||
33 | reyssat | 92 | search_keywords=!trim $search_keywords |
93 | search_keywords=!translate " to $ $ in $search_keywords |
||
11379 | bpr | 94 | !if $search_category$search_keywords$search_level=$empty |
33 | reyssat | 95 | !read wimshome/$s2dir/home_search |
96 | readback=yes |
||
97 | !else |
||
98 | search_level=!nospace $search_level |
||
11379 | bpr | 99 | search_level=!lowercase $search_level |
33 | reyssat | 100 | search_domain=!trim $search_domain |
101 | search_keywords=!trim $search_keywords |
||
102 | !endif |
||
103 | search_category=!replace exercise by X in $search_category |
||
104 | search_category=!replace tool by T in $search_category |
||
105 | search_category=!replace recreation by R in $search_category |
||
106 | search_category=!trim $search_category |
||
107 | search_category=!char 1 of $search_category |
||
108 | !bound search_category within $slist default V |
||
7562 | bpr | 109 | search_adresse=search_keywords="$search_keywords" |
110 | !if $search_category!=$empty |
||
111 | search_adresse=$search_adresse&search_category=$search_category |
||
112 | !endif |
||
113 | !if $search_lang!=$empty |
||
114 | search_adresse=$search_adresse&search_lang=$search_lang |
||
115 | !endif |
||
116 | !if $search_and!=$empty and $search_and!=no |
||
117 | search_adresse=$search_adresse&search_and=$search_and |
||
118 | !endif |
||
11379 | bpr | 119 | !if $search_level!=$empty |
120 | search_adresse=$search_adresse&search_level=$search_level |
||
121 | !endif |
||
33 | reyssat | 122 | !if $search_category=V |
123 | gotcnt=0 |
||
124 | !exit |
||
125 | !endif |
||
11379 | bpr | 126 | !if $search_keywords=$empty and $search_level!=$empty |
127 | srch=$search_level |
||
128 | search_and=no |
||
129 | !goto search |
||
130 | !endif |
||
33 | reyssat | 131 | !if $search_keywords!=$empty |
4649 | bpr | 132 | search_keywords_cnt=!wordcnt $search_keywords |
6461 | bpr | 133 | !!! the keyword may be the address of a module - if it is found, no other search is done |
4718 | bpr | 134 | !if (/ isin $search_keywords or %2F isin $search_keywords) and $search_keywords_cnt=1 |
4649 | bpr | 135 | k_=!replace internal module= by in $search_keywords |
4718 | bpr | 136 | k_=!replace internal %2F by / in $k_ |
137 | dictionary=$search_package2/serial |
||
138 | translator_unknown=leave |
||
4649 | bpr | 139 | try=!exec translator $k_ |
4718 | bpr | 140 | !if $try!= and $try != $k_ |
4649 | bpr | 141 | gotcnt=1 |
142 | gotm=$try |
||
143 | search_keywords=$k_ |
||
6739 | bpr | 144 | Gotcnt=1 |
4649 | bpr | 145 | !goto bailout |
146 | !endif |
||
147 | !endif |
||
6739 | bpr | 148 | k_=!lower $search_keywords |
149 | k_=!deaccent $k_ |
||
150 | l_=[ |
||
151 | e_== |
||
8276 | bpr | 152 | ##limitation of the number of tests (20 for 32 bits in version <= 4.08) |
153 | !reset partial_test |
||
6739 | bpr | 154 | !if f isvarof $k_ or g isvarof $k_ or x isvarof $k_ or y isvarof $k_ or\ |
7562 | bpr | 155 | z isvarof $k_ or b isvarof $k_ or c isvarof $k_ or i isvarof $k_ or\ |
8276 | bpr | 156 | ^ isin $k_ or / isin $k_ or $e_ isin $k_ |
157 | partial_test=1 |
||
158 | !endif |
||
159 | !if $partial_test=1 or\ |
||
7562 | bpr | 160 | .0 isin $k_ or .1 isin $k_ or .2 isin $k_ or .3 isin $k_ or\ |
161 | .4 isin $k_ or .5 isin $k_ or .6 isin $k_ or .7 isin $k_ or\ |
||
162 | .8 isin $k_ or .9 isin $k_ or $l_ isin $k_ |
||
6739 | bpr | 163 | error=expression |
164 | gotcnt=0 |
||
165 | !goto bailout |
||
166 | !endif |
||
167 | srch=!translate internal `'".+-_()[]{};: to $ $ in $search_keywords |
||
168 | srch=!replace , by , $ in $srch |
||
169 | srch=!deaccent $srch |
||
170 | srch=!lower $srch |
||
11379 | bpr | 171 | :search |
6470 | bpr | 172 | !!do not want to use the misprints and suffix for the moment |
6739 | bpr | 173 | Gotcnt=0 |
174 | !!! classes |
||
175 | !if $search_category iswordof A C |
||
176 | !read search.C |
||
6470 | bpr | 177 | dictionary=bases/sys/words.$search_lang |
6879 | bpr | 178 | suffix_dictionary= |
6470 | bpr | 179 | translator_unknown=leave |
180 | srch=!exec translator $srch |
||
181 | srch=!trim $srch |
||
6463 | bpr | 182 | gotmC=$gotm |
183 | gotwC=$gotw |
||
184 | gotcntC=$gotcnt |
||
185 | gottC=$gott |
||
186 | gotdC=$gotd |
||
6739 | bpr | 187 | !if $gotcntC >0 |
188 | !set test_exist=!append item C to $test_exist |
||
189 | !endif |
||
190 | Gotcnt=$[$Gotcnt + $(gotcntC)] |
||
191 | !endif |
||
6879 | bpr | 192 | !! use domaindic dictionnary to replace language by "english version" |
193 | !! the same is done in modind.c |
||
194 | dictionary=bases/sys/domaindic.$search_lang |
||
195 | suffix_dictionary= |
||
196 | translator_unknown=leave |
||
197 | srch=!exec translator $srch |
||
198 | srch=!trim $srch |
||
6463 | bpr | 199 | |
6879 | bpr | 200 | !! correct misprints in the search words |
6739 | bpr | 201 | dictionary=bases/sys/words.$search_lang |
202 | suffix_dictionary=bases/sys/suffix.$search_lang |
||
203 | translator_unknown=leave |
||
204 | srch=!exec translator $srch |
||
205 | srch=!trim $srch |
||
206 | !endif search_keywords!=$empty |
||
6463 | bpr | 207 | |
33 | reyssat | 208 | !writefile wimshome/$s2dir/home_search search_level=$search_level\ |
209 | search_category=$search_category\ |
||
210 | search_domain=$search_domain\ |
||
211 | search_keywords=$search_keywords\ |
||
212 | package=$search_package\ |
||
2670 | bpr | 213 | search_lang=$search_lang |
33 | reyssat | 214 | |
215 | !if $search_category isin LPS |
||
216 | !changeto search.$search_category |
||
217 | !endif |
||
218 | |||
6461 | bpr | 219 | !if $search_category isin A |
220 | !read search.S |
||
6463 | bpr | 221 | gotmS=$gotm |
222 | gotwS=$gotw |
||
223 | gotcntS=$gotcnt |
||
224 | gottS=$gott |
||
225 | gotdS=$gotd |
||
6739 | bpr | 226 | !if $gotcntS >0 |
227 | !set test_exist=!append item S to $test_exist |
||
228 | !endif |
||
229 | Gotcnt=$[$Gotcnt + $gotcntS] |
||
7084 | bpr | 230 | !for cat in X,D,T,R,M,P |
6739 | bpr | 231 | !read search.ker $cat |
232 | gotm$cat=$gotm |
||
233 | gotw$cat=$gotw |
||
234 | gotcnt$cat=$gotcnt |
||
235 | gott$cat=$gott |
||
236 | gotd$cat=$gotd |
||
237 | Gotcnt=$[$Gotcnt + $(gotcnt$cat)] |
||
238 | !if $(gotcnt$cat) >0 |
||
239 | !set test_exist=!append item $cat to $test_exist |
||
240 | !endif |
||
241 | !next |
||
6747 | bpr | 242 | !goto bailout |
6461 | bpr | 243 | !endif |
6747 | bpr | 244 | !if $search_category isin X,D,T,O,R,M |
245 | !read search.ker $search_category |
||
246 | gotm$search_category=$gotm |
||
247 | gotw$search_category=$gotw |
||
248 | gotcnt$search_category=$gotcnt |
||
249 | gott$search_category=$gott |
||
250 | gotd$search_category=$gotd |
||
251 | Gotcnt=$[$Gotcnt + $(gotcnt$search_category)] |
||
252 | !endif |
||
253 | |||
7084 | bpr | 254 | |
33 | reyssat | 255 | :bailout |
256 | translator_switch=leaveline |
||
257 | !bound list_start between integer 0 and 10000 default 0 |
||
258 | list_start=$[$list_batch*floor($list_start/$list_batch)] |
||
6470 | bpr | 259 | |
260 | !if $Gotcnt=0 |
||
33 | reyssat | 261 | gottype=popular |
262 | # sp=!replace internal wimshome/public_html/ by $ in $search_package1 |
||
2670 | bpr | 263 | # gotM=!sh head -c 10000 $sp/pop/$search_category.$search_lang |
264 | gotM=!record 0 of $search_package1/pop/$search_category.$search_lang |
||
33 | reyssat | 265 | gotM=!line 1 to $gotlim of $gotM |
266 | list_cc=!linecnt $gotM |
||
267 | !if $list_start>$list_cc |
||
268 | list_start=$[$list_batch*max(0,floor(($list_cc-1)/$list_batch))] |
||
269 | !endif |
||
270 | gotm= |
||
271 | !for i=1 to $list_batch |
||
272 | l_=!line $i+$list_start of $gotM |
||
273 | !distribute words $l_ into m_,w_ |
||
274 | !default w_=0 |
||
275 | gotm=$gotm $m_ |
||
276 | gotw=$gotw $w_ |
||
277 | !next i |
||
278 | gotcnt=!wordcnt $gotm |
||
279 | gotm=!words2lines $gotm |
||
280 | gotw=!words2lines $gotw |
||
281 | !else |
||
282 | gottype=search |
||
283 | !endif |
||
284 | |||
285 | !if / isin $gotm |
||
6739 | bpr | 286 | |
33 | reyssat | 287 | dictionary=$search_package2/serial |
288 | translator_unknown=leave |
||
289 | gotm=!exec translator $gotm |
||
290 | !endif |
||
291 | |||
292 | dictionary=$search_package2/title |
||
293 | gott=!exec translator $gotm |
||
294 | dictionary=$search_package2/description |
||
295 | gotd=!exec translator $gotm |
||
296 | dictionary=$search_package2/language |
||
297 | gotl=!exec translator $gotm |
||
298 | dictionary=$search_package2/author |
||
299 | translator_unknown=? |
||
300 | gota=!exec translator $gotm |
||
301 | |||
302 | !if / notin $gotm and $gotcnt>0 |
||
303 | dictionary=$search_package2/addr |
||
304 | gotm=!exec translator $gotm |
||
6739 | bpr | 305 | !endif |
33 | reyssat | 306 | |
6747 | bpr | 307 | !for cat in X,T,D,O,R,M |
6739 | bpr | 308 | dictionary=$search_package2/title |
309 | gott$cat=!exec translator $(gotm$cat) |
||
310 | dictionary=$search_package2/description |
||
311 | gotd$cat=!exec translator $(gotm$cat) |
||
312 | dictionary=$search_package2/language |
||
313 | gotl$cat=!exec translator $(gotm$cat) |
||
314 | dictionary=$search_package2/author |
||
315 | translator_unknown=? |
||
316 | gota$cat=!exec translator $(gotm$cat) |
||
317 | |||
318 | !if / notin $(gotm$cat) and $(gotcnt$cat)>0 |
||
319 | dictionary=$search_package2/addr |
||
320 | gotm$cat=!exec translator $(gotm$cat) |
||
7084 | bpr | 321 | !endif |
6739 | bpr | 322 | !next |
323 | !endif |
||
33 | reyssat | 324 | !if $search_category isin AT and $search_keywords!=$empty and\ |
7562 | bpr | 325 | P isin $slist and ($gotcnt<=8 or $gottype!=search) |
33 | reyssat | 326 | gotm1=$gotm |
327 | gotcnt1=$gotcnt |
||
328 | gottype1=$gottype |
||
329 | !read search.P |
||
7107 | bpr | 330 | !if $gotcnt>0 |
7084 | bpr | 331 | test_exist=!append item P to $test_exist |
332 | gottype=search |
||
333 | !endif |
||
33 | reyssat | 334 | !exchange gottype,gottype1 |
335 | !exchange gotcnt,gotcnt1 |
||
336 | !exchange gotm,gotm1 |
||
337 | !else |
||
338 | gotcnt1=0 |
||
339 | !endif |