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