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