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