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