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 |
33 | reyssat | 60 | |
11390 | bpr | 61 | !set Listlevel=K1,K2,K3,E1,E2,E3,E4,E5,E6,H1,H2,H3,H5,H6,U1,U2,U3,U4,U5,R |
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 |
72 | |||
73 | !if $list=clear |
||
74 | search_category=V |
||
75 | search_keywords= |
||
76 | list= |
||
77 | !writefile wimshome/$s2dir/home_search package=$search_package |
||
78 | gotcnt=0 |
||
79 | !exit |
||
80 | !endif |
||
81 | |||
82 | !if _tool isin $wims_session |
||
83 | search_category=T |
||
84 | !endif |
||
11390 | bpr | 85 | !if $search_level_from!=$empty |
86 | !default search_level_to=-1 |
||
87 | search_level=$(listlevel[$search_level_from .. $search_level_to]) |
||
88 | !endif |
||
33 | reyssat | 89 | search_keywords=!trim $search_keywords |
90 | search_keywords=!translate " to $ $ in $search_keywords |
||
11379 | bpr | 91 | !if $search_category$search_keywords$search_level=$empty |
33 | reyssat | 92 | !read wimshome/$s2dir/home_search |
93 | readback=yes |
||
94 | !else |
||
95 | search_level=!nospace $search_level |
||
11379 | bpr | 96 | search_level=!lowercase $search_level |
33 | reyssat | 97 | search_domain=!trim $search_domain |
98 | search_keywords=!trim $search_keywords |
||
99 | !endif |
||
100 | search_category=!replace exercise by X in $search_category |
||
101 | search_category=!replace tool by T in $search_category |
||
102 | search_category=!replace recreation by R in $search_category |
||
103 | search_category=!trim $search_category |
||
104 | search_category=!char 1 of $search_category |
||
105 | !bound search_category within $slist default V |
||
7562 | bpr | 106 | search_adresse=search_keywords="$search_keywords" |
107 | !if $search_category!=$empty |
||
108 | search_adresse=$search_adresse&search_category=$search_category |
||
109 | !endif |
||
110 | !if $search_lang!=$empty |
||
111 | search_adresse=$search_adresse&search_lang=$search_lang |
||
112 | !endif |
||
113 | !if $search_and!=$empty and $search_and!=no |
||
114 | search_adresse=$search_adresse&search_and=$search_and |
||
115 | !endif |
||
11379 | bpr | 116 | !if $search_level!=$empty |
117 | search_adresse=$search_adresse&search_level=$search_level |
||
118 | !endif |
||
33 | reyssat | 119 | !if $search_category=V |
120 | gotcnt=0 |
||
121 | !exit |
||
122 | !endif |
||
11379 | bpr | 123 | !if $search_keywords=$empty and $search_level!=$empty |
124 | srch=$search_level |
||
125 | search_and=no |
||
126 | !goto search |
||
127 | !endif |
||
33 | reyssat | 128 | !if $search_keywords!=$empty |
4649 | bpr | 129 | search_keywords_cnt=!wordcnt $search_keywords |
6461 | bpr | 130 | !!! the keyword may be the address of a module - if it is found, no other search is done |
4718 | bpr | 131 | !if (/ isin $search_keywords or %2F isin $search_keywords) and $search_keywords_cnt=1 |
4649 | bpr | 132 | k_=!replace internal module= by in $search_keywords |
4718 | bpr | 133 | k_=!replace internal %2F by / in $k_ |
134 | dictionary=$search_package2/serial |
||
135 | translator_unknown=leave |
||
4649 | bpr | 136 | try=!exec translator $k_ |
4718 | bpr | 137 | !if $try!= and $try != $k_ |
4649 | bpr | 138 | gotcnt=1 |
139 | gotm=$try |
||
140 | search_keywords=$k_ |
||
6739 | bpr | 141 | Gotcnt=1 |
4649 | bpr | 142 | !goto bailout |
143 | !endif |
||
144 | !endif |
||
6739 | bpr | 145 | k_=!lower $search_keywords |
146 | k_=!deaccent $k_ |
||
147 | l_=[ |
||
148 | e_== |
||
8276 | bpr | 149 | ##limitation of the number of tests (20 for 32 bits in version <= 4.08) |
150 | !reset partial_test |
||
6739 | bpr | 151 | !if f isvarof $k_ or g isvarof $k_ or x isvarof $k_ or y isvarof $k_ or\ |
7562 | bpr | 152 | z isvarof $k_ or b isvarof $k_ or c isvarof $k_ or i isvarof $k_ or\ |
8276 | bpr | 153 | ^ isin $k_ or / isin $k_ or $e_ isin $k_ |
154 | partial_test=1 |
||
155 | !endif |
||
156 | !if $partial_test=1 or\ |
||
7562 | bpr | 157 | .0 isin $k_ or .1 isin $k_ or .2 isin $k_ or .3 isin $k_ or\ |
158 | .4 isin $k_ or .5 isin $k_ or .6 isin $k_ or .7 isin $k_ or\ |
||
159 | .8 isin $k_ or .9 isin $k_ or $l_ isin $k_ |
||
6739 | bpr | 160 | error=expression |
161 | gotcnt=0 |
||
162 | !goto bailout |
||
163 | !endif |
||
164 | srch=!translate internal `'".+-_()[]{};: to $ $ in $search_keywords |
||
165 | srch=!replace , by , $ in $srch |
||
166 | srch=!deaccent $srch |
||
167 | srch=!lower $srch |
||
11379 | bpr | 168 | :search |
6470 | bpr | 169 | !!do not want to use the misprints and suffix for the moment |
6739 | bpr | 170 | Gotcnt=0 |
171 | !!! classes |
||
172 | !if $search_category iswordof A C |
||
173 | !read search.C |
||
6470 | bpr | 174 | dictionary=bases/sys/words.$search_lang |
6879 | bpr | 175 | suffix_dictionary= |
6470 | bpr | 176 | translator_unknown=leave |
177 | srch=!exec translator $srch |
||
178 | srch=!trim $srch |
||
6463 | bpr | 179 | gotmC=$gotm |
180 | gotwC=$gotw |
||
181 | gotcntC=$gotcnt |
||
182 | gottC=$gott |
||
183 | gotdC=$gotd |
||
6739 | bpr | 184 | !if $gotcntC >0 |
185 | !set test_exist=!append item C to $test_exist |
||
186 | !endif |
||
187 | Gotcnt=$[$Gotcnt + $(gotcntC)] |
||
188 | !endif |
||
6879 | bpr | 189 | !! use domaindic dictionnary to replace language by "english version" |
190 | !! the same is done in modind.c |
||
191 | dictionary=bases/sys/domaindic.$search_lang |
||
192 | suffix_dictionary= |
||
193 | translator_unknown=leave |
||
194 | srch=!exec translator $srch |
||
195 | srch=!trim $srch |
||
6463 | bpr | 196 | |
6879 | bpr | 197 | !! correct misprints in the search words |
6739 | bpr | 198 | dictionary=bases/sys/words.$search_lang |
199 | suffix_dictionary=bases/sys/suffix.$search_lang |
||
200 | translator_unknown=leave |
||
201 | srch=!exec translator $srch |
||
202 | srch=!trim $srch |
||
203 | !endif search_keywords!=$empty |
||
6463 | bpr | 204 | |
33 | reyssat | 205 | !writefile wimshome/$s2dir/home_search search_level=$search_level\ |
206 | search_category=$search_category\ |
||
207 | search_domain=$search_domain\ |
||
208 | search_keywords=$search_keywords\ |
||
209 | package=$search_package\ |
||
2670 | bpr | 210 | search_lang=$search_lang |
33 | reyssat | 211 | |
212 | !if $search_category isin LPS |
||
213 | !changeto search.$search_category |
||
214 | !endif |
||
215 | |||
6461 | bpr | 216 | !if $search_category isin A |
217 | !read search.S |
||
6463 | bpr | 218 | gotmS=$gotm |
219 | gotwS=$gotw |
||
220 | gotcntS=$gotcnt |
||
221 | gottS=$gott |
||
222 | gotdS=$gotd |
||
6739 | bpr | 223 | !if $gotcntS >0 |
224 | !set test_exist=!append item S to $test_exist |
||
225 | !endif |
||
226 | Gotcnt=$[$Gotcnt + $gotcntS] |
||
7084 | bpr | 227 | !for cat in X,D,T,R,M,P |
6739 | bpr | 228 | !read search.ker $cat |
229 | gotm$cat=$gotm |
||
230 | gotw$cat=$gotw |
||
231 | gotcnt$cat=$gotcnt |
||
232 | gott$cat=$gott |
||
233 | gotd$cat=$gotd |
||
234 | Gotcnt=$[$Gotcnt + $(gotcnt$cat)] |
||
235 | !if $(gotcnt$cat) >0 |
||
236 | !set test_exist=!append item $cat to $test_exist |
||
237 | !endif |
||
238 | !next |
||
6747 | bpr | 239 | !goto bailout |
6461 | bpr | 240 | !endif |
6747 | bpr | 241 | !if $search_category isin X,D,T,O,R,M |
242 | !read search.ker $search_category |
||
243 | gotm$search_category=$gotm |
||
244 | gotw$search_category=$gotw |
||
245 | gotcnt$search_category=$gotcnt |
||
246 | gott$search_category=$gott |
||
247 | gotd$search_category=$gotd |
||
248 | Gotcnt=$[$Gotcnt + $(gotcnt$search_category)] |
||
249 | !endif |
||
250 | |||
7084 | bpr | 251 | |
33 | reyssat | 252 | :bailout |
253 | translator_switch=leaveline |
||
254 | !bound list_start between integer 0 and 10000 default 0 |
||
255 | list_start=$[$list_batch*floor($list_start/$list_batch)] |
||
6470 | bpr | 256 | |
257 | !if $Gotcnt=0 |
||
33 | reyssat | 258 | gottype=popular |
259 | # sp=!replace internal wimshome/public_html/ by $ in $search_package1 |
||
2670 | bpr | 260 | # gotM=!sh head -c 10000 $sp/pop/$search_category.$search_lang |
261 | gotM=!record 0 of $search_package1/pop/$search_category.$search_lang |
||
33 | reyssat | 262 | gotM=!line 1 to $gotlim of $gotM |
263 | list_cc=!linecnt $gotM |
||
264 | !if $list_start>$list_cc |
||
265 | list_start=$[$list_batch*max(0,floor(($list_cc-1)/$list_batch))] |
||
266 | !endif |
||
267 | gotm= |
||
268 | !for i=1 to $list_batch |
||
269 | l_=!line $i+$list_start of $gotM |
||
270 | !distribute words $l_ into m_,w_ |
||
271 | !default w_=0 |
||
272 | gotm=$gotm $m_ |
||
273 | gotw=$gotw $w_ |
||
274 | !next i |
||
275 | gotcnt=!wordcnt $gotm |
||
276 | gotm=!words2lines $gotm |
||
277 | gotw=!words2lines $gotw |
||
278 | !else |
||
279 | gottype=search |
||
280 | !endif |
||
281 | |||
282 | !if / isin $gotm |
||
6739 | bpr | 283 | |
33 | reyssat | 284 | dictionary=$search_package2/serial |
285 | translator_unknown=leave |
||
286 | gotm=!exec translator $gotm |
||
287 | !endif |
||
288 | |||
289 | dictionary=$search_package2/title |
||
290 | gott=!exec translator $gotm |
||
291 | dictionary=$search_package2/description |
||
292 | gotd=!exec translator $gotm |
||
293 | dictionary=$search_package2/language |
||
294 | gotl=!exec translator $gotm |
||
295 | dictionary=$search_package2/author |
||
296 | translator_unknown=? |
||
297 | gota=!exec translator $gotm |
||
298 | |||
299 | !if / notin $gotm and $gotcnt>0 |
||
300 | dictionary=$search_package2/addr |
||
301 | gotm=!exec translator $gotm |
||
6739 | bpr | 302 | !endif |
33 | reyssat | 303 | |
6747 | bpr | 304 | !for cat in X,T,D,O,R,M |
6739 | bpr | 305 | dictionary=$search_package2/title |
306 | gott$cat=!exec translator $(gotm$cat) |
||
307 | dictionary=$search_package2/description |
||
308 | gotd$cat=!exec translator $(gotm$cat) |
||
309 | dictionary=$search_package2/language |
||
310 | gotl$cat=!exec translator $(gotm$cat) |
||
311 | dictionary=$search_package2/author |
||
312 | translator_unknown=? |
||
313 | gota$cat=!exec translator $(gotm$cat) |
||
314 | |||
315 | !if / notin $(gotm$cat) and $(gotcnt$cat)>0 |
||
316 | dictionary=$search_package2/addr |
||
317 | gotm$cat=!exec translator $(gotm$cat) |
||
7084 | bpr | 318 | !endif |
6739 | bpr | 319 | !next |
320 | !endif |
||
33 | reyssat | 321 | !if $search_category isin AT and $search_keywords!=$empty and\ |
7562 | bpr | 322 | P isin $slist and ($gotcnt<=8 or $gottype!=search) |
33 | reyssat | 323 | gotm1=$gotm |
324 | gotcnt1=$gotcnt |
||
325 | gottype1=$gottype |
||
326 | !read search.P |
||
7107 | bpr | 327 | !if $gotcnt>0 |
7084 | bpr | 328 | test_exist=!append item P to $test_exist |
329 | gottype=search |
||
330 | !endif |
||
33 | reyssat | 331 | !exchange gottype,gottype1 |
332 | !exchange gotcnt,gotcnt1 |
||
333 | !exchange gotm,gotm1 |
||
334 | !else |
||
335 | gotcnt1=0 |
||
336 | !endif |