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