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
6463 bpr 132
!!do not want to use the misprints and suffix
6465 bpr 133
 
6463 bpr 134
!if $search_category isin A
135
  !read search.C
136
   gotmC=$gotm
137
   gotwC=$gotw
138
   gotcntC=$gotcnt
139
   gottC=$gott
140
   gotdC=$gotd
141
!endif
142
 
6390 bpr 143
 !! correct misprints in the search words
2670 bpr 144
 dictionary=bases/sys/words.$search_lang
2857 bpr 145
 suffix_dictionary=bases/sys/suffix.$search_lang
33 reyssat 146
 translator_unknown=leave
147
 srch=!exec translator $srch
148
 srch=!trim $srch
149
!endif
6463 bpr 150
 
33 reyssat 151
!writefile wimshome/$s2dir/home_search search_level=$search_level\
152
search_category=$search_category\
153
search_domain=$search_domain\
154
search_keywords=$search_keywords\
155
package=$search_package\
2670 bpr 156
search_lang=$search_lang
33 reyssat 157
 
158
!if $search_category isin LPS
159
 !changeto search.$search_category
160
!endif
161
 
6461 bpr 162
!if $search_category isin A
163
 !read search.S
6463 bpr 164
 gotmS=$gotm
165
 gotwS=$gotw
166
 gotcntS=$gotcnt
167
 gottS=$gott
168
 gotdS=$gotd
6461 bpr 169
!endif
170
 
2670 bpr 171
!read search.ker $search_lang
33 reyssat 172
:bailout
173
 
174
translator_switch=leaveline
175
!bound list_start between integer 0 and 10000 default 0
176
list_start=$[$list_batch*floor($list_start/$list_batch)]
177
!if $gotcnt=0
178
 gottype=popular
179
 # sp=!replace internal wimshome/public_html/ by $ in $search_package1
2670 bpr 180
 # gotM=!sh head -c 10000 $sp/pop/$search_category.$search_lang
181
 gotM=!record 0 of $search_package1/pop/$search_category.$search_lang
33 reyssat 182
 gotM=!line 1 to $gotlim of $gotM
183
 list_cc=!linecnt $gotM
184
 !if $list_start>$list_cc
185
  list_start=$[$list_batch*max(0,floor(($list_cc-1)/$list_batch))]
186
 !endif
187
 gotm=
188
 !for i=1 to $list_batch
189
  l_=!line $i+$list_start of $gotM
190
  !distribute words $l_ into m_,w_
191
  !default w_=0
192
  gotm=$gotm $m_
193
  gotw=$gotw $w_
194
 !next i
195
 gotcnt=!wordcnt $gotm
196
 gotm=!words2lines $gotm
197
 gotw=!words2lines $gotw
198
!else
199
 gottype=search
200
!endif
201
 
202
!if / isin $gotm
203
 dictionary=$search_package2/serial
204
 translator_unknown=leave
205
 gotm=!exec translator $gotm
206
!endif
207
 
208
dictionary=$search_package2/title
209
gott=!exec translator $gotm
210
dictionary=$search_package2/description
211
gotd=!exec translator $gotm
212
dictionary=$search_package2/language
213
gotl=!exec translator $gotm
214
dictionary=$search_package2/author
215
translator_unknown=?
216
gota=!exec translator $gotm
217
 
218
!if / notin $gotm and $gotcnt>0
219
 dictionary=$search_package2/addr
220
 gotm=!exec translator $gotm
221
!endif 
222
 
223
!if $search_category isin AT and $search_keywords!=$empty and\
224
	P isin $slist and ($gotcnt<=8 or $gottype!=search)
225
 gotm1=$gotm
226
 gotcnt1=$gotcnt
227
 gottype1=$gottype
228
 !read search.P
229
 !exchange gottype,gottype1
230
 !exchange gotcnt,gotcnt1
231
 !exchange gotm,gotm1
232
!else
233
 gotcnt1=0
234
!endif
235