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