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