Subversion Repositories wimsdev

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
33 reyssat 1
# Processing search request.
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
34
 
35
s2dir=!replace internal sessions/ by s2/ in $wims_sesdir
36
s2dir=!translate internal _ to $ $ in $s2dir
37
s2dir=!word 1 of $s2dir
38
!if $wims_accessright!=$empty and $wims_class!=$empty
39
 !default search_package=!getdef package in wimshome/$s2dir/home_search
40
 !bound search_package within $wims_accessright default bases/site
41
!else
42
 search_package=bases/site
43
!endif
44
!if $search_package=bases/site
45
 search_package1=wimshome/public_html/$search_package
46
 search_package2=$search_package
47
!else
48
 search_package1=wimshome/public_html/modules/$search_package/.index
49
 search_package2=modules/$search_package/.index
50
!endif
51
 
52
# Limit of shown items
53
gotlim=1000
54
gotlim2=50
55
list_batch=20
56
 
57
rel_A=D,S
58
rel_T=X,D,R
59
rel_D=X,T,S,R
60
rel_X=T,D,S,R
61
rel_R=X,T,D,S
62
rel_P=T,X,D
63
rel_O=X,S,T,D,R
64
rel_S=X,R,T,D
65
 
66
slist=A D T X R P O S
67
module_P=wimshome/public_html/modules/tool/popup
68
wims_trustfile=$module_P.$lang/search.phtml $module_P.$lang/search.proc
69
test=!record 0 of $module_P.$lang/.test
70
!if yes notin $test
71
 slist=!translate P to $ $ in $slist
72
!endif
73
cnt=!record 0 of wimshome/public_html/bases/sheet/index/count.$lang
74
!if $cnt<=0
75
 slist=!translate S to $ $ in $slist
76
!endif
77
slist=!words2items $slist
78
plist=
79
!for i in $slist
80
 plist=!append item $(C_$i) to $plist
81
!next i
82
 
83
!if $wims_user=supervisor
84
 !default search_level=$class_level
85
!endif
86
 
87
!if $list=clear
88
 search_category=V
89
 search_keywords=
90
 list=
91
 !writefile wimshome/$s2dir/home_search package=$search_package
92
 gotcnt=0
93
 !exit
94
!endif
95
 
96
!if _tool isin $wims_session
97
 search_category=T
98
!endif
99
 
100
search_keywords=!trim $search_keywords
101
search_keywords=!translate " to $ $ in $search_keywords
102
!if $search_category$search_keywords=$empty
103
 !read wimshome/$s2dir/home_search
104
 readback=yes
105
!else
106
 search_level=!nospace $search_level
107
 search_domain=!trim $search_domain
108
 search_keywords=!trim $search_keywords
109
!endif
110
 
111
search_category=!replace exercise by X in $search_category
112
search_category=!replace tool by T in $search_category
113
search_category=!replace recreation by R in $search_category
114
search_category=!trim $search_category
115
search_category=!char 1 of $search_category
116
!bound search_category within $slist default V
117
!if $search_category=V
118
 gotcnt=0
119
 !exit
120
!endif
121
 
122
!if $search_keywords!=$empty
123
 k_=!lower $search_keywords
124
 k_=!deaccent $k_
125
 l_=[
126
 e_==
127
 !if f isvarof $k_ or g isvarof $k_ or x isvarof $k_ or y isvarof $k_ or\
128
	z isvarof $k_ or b isvarof $k_ or c isvarof $k_ or i isvarof $k_ or\
129
	^ isin $k_ or / isin $k_ or $e_ isin $k_ or\
130
	.0 isin $k_ or .1 isin $k_ or .2 isin $k_ or .3 isin $k_ or\
131
	.4 isin $k_ or .5 isin $k_ or .6 isin $k_ or .7 isin $k_ or\
132
	.8 isin $k_ or .9 isin $k_ or $l_ isin $k_
133
   error=expression
134
   gotcnt=0
135
   !goto bailout
136
 !endif
137
 srch=!translate internal `'".+-_()[]{};: to $             $ in $search_keywords
138
 srch=!replace , by , $ in $srch
139
 srch=!deaccent $srch
140
 srch=!lower $srch
141
 dictionary=bases/sys/words.$lang
142
 suffix_dictionary=bases/sys/suffix.$lang
143
 translator_unknown=leave
144
 srch=!exec translator $srch
145
 srch=!trim $srch
146
!endif
147
!writefile wimshome/$s2dir/home_search search_level=$search_level\
148
search_category=$search_category\
149
search_domain=$search_domain\
150
search_keywords=$search_keywords\
151
package=$search_package\
152
search_lang=$lang
153
 
154
!if $search_category isin LPS
155
 !changeto search.$search_category
156
!endif
157
 
158
!read search.ker
159
:bailout
160
 
161
translator_switch=leaveline
162
!bound list_start between integer 0 and 10000 default 0
163
list_start=$[$list_batch*floor($list_start/$list_batch)]
164
!if $gotcnt=0
165
 gottype=popular
166
 # sp=!replace internal wimshome/public_html/ by $ in $search_package1
167
 # gotM=!sh head -c 10000 $sp/pop/$search_category.$lang
168
 gotM=!record 0 of $search_package1/pop/$search_category.$lang
169
 gotM=!line 1 to $gotlim of $gotM
170
 list_cc=!linecnt $gotM
171
 !if $list_start>$list_cc
172
  list_start=$[$list_batch*max(0,floor(($list_cc-1)/$list_batch))]
173
 !endif
174
 gotm=
175
 !for i=1 to $list_batch
176
  l_=!line $i+$list_start of $gotM
177
  !distribute words $l_ into m_,w_
178
  !default w_=0
179
  gotm=$gotm $m_
180
  gotw=$gotw $w_
181
 !next i
182
 gotcnt=!wordcnt $gotm
183
 gotm=!words2lines $gotm
184
 gotw=!words2lines $gotw
185
!else
186
 gottype=search
187
!endif
188
 
189
!if / isin $gotm
190
 dictionary=$search_package2/serial
191
 translator_unknown=leave
192
 gotm=!exec translator $gotm
193
!endif
194
 
195
dictionary=$search_package2/title
196
gott=!exec translator $gotm
197
dictionary=$search_package2/description
198
gotd=!exec translator $gotm
199
dictionary=$search_package2/language
200
gotl=!exec translator $gotm
201
dictionary=$search_package2/author
202
translator_unknown=?
203
gota=!exec translator $gotm
204
 
205
!if / notin $gotm and $gotcnt>0
206
 dictionary=$search_package2/addr
207
 gotm=!exec translator $gotm
208
!endif 
209
 
210
!if $search_category isin AT and $search_keywords!=$empty and\
211
	P isin $slist and ($gotcnt<=8 or $gottype!=search)
212
 gotm1=$gotm
213
 gotcnt1=$gotcnt
214
 gottype1=$gottype
215
 !read search.P
216
 !exchange gottype,gottype1
217
 !exchange gotcnt,gotcnt1
218
 !exchange gotm,gotm1
219
!else
220
 gotcnt1=0
221
!endif
222