Subversion Repositories wimsdev

Rev

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