Subversion Repositories wimsdev

Rev

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