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