Subversion Repositories wimsdev

Rev

Rev 15381 | Blame | Compare with Previous | Last modification | View Log | RSS feed

Processing search request.
!nocache
!if $wims_referer!=$empty and $wims_user=$empty and $wims_new_session=yes
  refcut=!replace internal :// by $ $ in $wims_referer
  refcut=!word 2 of $refcut
  refcut=!translate internal /. to $ , in $refcut
  !distribute words $refcut into refsite, refsearch
  refdom=!item -2 of $refsite
  refdom=!lower $refdom
  reffields=!defof $refdom in searchengines
  !if $reffields!=$empty
    !distribute items $reffields into refs,refl
    refsearch=!translate internal ?&= to ,, $ in $refsearch
    !for rs in $refsearch
      refw1=!word 1 of $rs
      !if $refw1=$refs
        refS=!word 2 to -1 of $rs
        refS=!lower $refS
        refS=!unhttp $refS
        refS=!translate internal + to $ 4 in $refS
        refS=!replace word wims by $ in $refS
        refS=!trim $refS
      !endif
      !if $refw1=$refl
        refL=!word 2 of $rs
      !endif
    !next rs
    !if $refS!=$empty
      search_category=A
      search_keywords=$refS
    !endif
  !endif
!endif
!reset test_exist

s2dir=!replace internal sessions/ by s2/ in $wims_sesdir
s2dir=!translate internal _ to $ $ in $s2dir
s2dir=!word 1 of $s2dir
!if $wims_class!=$empty
  fromtodir=log/classes/$wims_class
!else
  fromtodir=$s2dir
!endif
!if $wims_accessright!=$empty and $wims_class!=$empty
  !default search_package=!getdef package in wimshome/$s2dir/home_search
  !bound search_package within $wims_accessright default bases/site
!else
  search_package=bases/site
!endif
!if $search_package=bases/site
  search_package1=wimshome/public_html/$search_package
  search_package2=$search_package
!else
  search_package1=wimshome/public_html/modules/$search_package/.index
  search_package2=modules/$search_package/.index
!endif

# Limit of shown items
gotlim=1000
gotlim2=50
list_batch=20
!default search_lang=$lang
!read adm/search_engine/mklist_form.proc $search_lang
!read adm/lang/levelname.phtml.$lang
!set Listlevel=$wims_listlevel
!set search_levelcnt=!itemcnt $Listlevel
!set listlevel=!makelist level x for x in $Listlevel
!set listlevel=!nospace $listlevel
!set listlevel=!lowercase $listlevel
!if $search_level=all
  search_level=$(listlevel)
!endif
!set tmp=!defof search_level_from,search_level_to in wimshome/$fromtodir/home_search2
!default search_level_from=$(tmp[1])
!default search_level_to=$(tmp[2])
!if $wims_user=supervisor and $search_level=$empty
  !set cl=!positionof item $class_level in $Listlevel
  !default search_level_from=$[max(1,$cl-1)]
  !default search_level_to=$[$cl+1]
!endif
!if $search_level_from=1 and $search_level_to=$search_levelcnt
  !reset search_level_from search_level_to
!endif

!if $list=clear
  search_category=V
  search_keywords=
  list=
  !writefile wimshome/$s2dir/home_search package=$search_package
  gotcnt=0
  !exit
!endif

!if _tool isin $wims_session
  search_category=T
!endif

search_keywords=!detag $search_keywords
search_keywords=!trim $search_keywords
!if $search_keywords=wimshelp
  search_level=$list_level
  !goto levelfind
!endif

search_keywords=!translate " to $ $ in $search_keywords
!if $search_category$search_keywords$search_level=$empty
  !! read the preceding option in the user search
  !read wimshome/$s2dir/home_search
  !read wimshome/$fromtodir/home_search2
  readback=yes
!else
  !if $search_level=$empty
    !if $search_level_from!=$empty
      !default search_level_to=-1
      search_level=$(listlevel[$search_level_from .. $search_level_to])
    !endif
    !if $search_level!=$empty
      search_level=!append item levellang to $search_level
    !endif
    search_level=!nospace $search_level
    search_level=!lowercase $search_level
    search_level=!listuniq $search_level
    search_domain=!trim $search_domain
    search_keywords=!trim $search_keywords
  !endif
!endif
:levelfind
!!setdef search_level=$search_level  in wimshome/$wims_sesdir/var.stat

search_category=!replace exercise by X in $search_category
search_category=!replace tool by T in $search_category
search_category=!replace recreation by R in $search_category
search_category=!trim $search_category
search_category=!char 1 of $search_category
!bound search_category within $slist default V
search_adresse=search_keywords="$search_keywords"
!if $search_category!=$empty
  search_adresse=$search_adresse&search_category=$search_category
!endif
!if $search_lang!=$empty
  search_adresse=$search_adresse&search_lang=$search_lang
!endif
!if $search_and!=$empty and $search_and!=no
  search_adresse=$search_adresse&search_and=$search_and
!endif
!if $search_level!=$empty
  search_adresse=$search_adresse&search_level=$search_level
!endif
!if $search_category=V
  gotcnt=0
  !exit
!endif
!if $search_keywords=$empty and $search_level!=$empty
  srch=$search_level
  search_and=no
  !goto search
!endif
!if $search_keywords!=$empty
  search_keywords_cnt=!wordcnt $search_keywords
  !!! the keyword may be the address of a module - if it is found, no other search is done
  !if (/ isin $search_keywords or %2F isin $search_keywords) and $search_keywords_cnt=1
    k_=!replace internal module= by in $search_keywords
    k_=!replace internal %2F by / in $k_
    dictionary=$search_package2/serial
    translator_unknown=leave
    try=!exec translator $k_
    !if $try= or $try = $k_
      tmp=!replace internal . by , in $k_
      !for l in en, fr, it, nl
        try2=!exec translator $(tmp[1]).$l
        !if $try2!= and $try2 != $(tmp[1]).$l
          gotcnt=1
          gotm=$try2
          search_keywords=$k_
          Gotcnt=1
          !goto bailout
        !endif
      !next
    !endif
    !if $try!= and $try != $k_
      gotcnt=1
      gotm=$try
      search_keywords=$k_
      Gotcnt=1
      !goto bailout
    !endif
  !endif
  k_=!lower $search_keywords
  k_=!deaccent $k_
  l_=[
  e_==
  ##limitation of the number of tests (20 for 32 bits in version <= 4.08)
  !reset partial_test
  !if f isvarof $k_ or g isvarof $k_ or x isvarof $k_ or y isvarof $k_ or\
      z isvarof $k_ or b isvarof $k_ or c isvarof $k_ or i isvarof $k_ or\
      ^ isin $k_ or / isin $k_ or $e_ isin $k_
    partial_test=1
  !endif
  !if $partial_test=1 or\
      .0 isin $k_ or .1 isin $k_ or .2 isin $k_ or .3 isin $k_ or\
      .4 isin $k_ or .5 isin $k_ or .6 isin $k_ or .7 isin $k_ or\
      .8 isin $k_ or .9 isin $k_ or $l_ isin $k_
    error=expression
    gotcnt=0
    !goto bailout
  !endif
  srch=!translate internal `'".+-_()[]{};: to $             $ in $search_keywords
  srch=!replace , by , $ in $srch
  srch=!deaccent $srch
  srch=!lower $srch
  :search
  !!do not want to use the misprints and suffix for the moment
  Gotcnt=0
  !!! classes
  !if $search_category iswordof A C
    !read search.C
    dictionary=bases/sys/words.$search_lang
    suffix_dictionary=
    translator_unknown=leave
    srch=!exec translator $srch
    srch=!trim $srch
    gotmC=$gotm
    gotwC=$gotw
    gotcntC=$gotcnt
    gottC=$gott
    gotdC=$gotd
    !if $gotcntC >0
      !set test_exist=!append item C to $test_exist
    !endif
    Gotcnt=$[$Gotcnt + $(gotcntC)]
  !endif
  !! use domaindic dictionnary to replace language by "english version"
  !! the same is done in modind.c
  dictionary=bases/sys/domaindic.$search_lang
  suffix_dictionary=
  translator_unknown=leave
  srch=!exec translator $srch
  srch=!trim $srch
  !! keep no modified keywords for use in displaying OEF exercises
  srch0=!replace internal $ $ by _ in $srch
  !! correct misprints in the search words
  dictionary=bases/sys/words.$search_lang
  suffix_dictionary=bases/sys/suffix.$search_lang
  translator_unknown=leave
  srch=!exec translator $srch
  srch=!trim $srch
!endif  search_keywords!=$empty

!writefile wimshome/$s2dir/home_search search_level=$search_level\
search_category=$search_category\
search_domain=$search_domain\
search_keywords=$search_keywords\
package=$search_package\
search_lang=$search_lang

!writefile wimshome/$fromtodir/home_search2 search_level_from=$search_level_from\
search_level_to=$search_level_to

!if $search_category isin LPSG
  !changeto search.$search_category
!endif

!if $search_category isin A
  !for T in S,G
    !read search.$T
    gotm$T=$gotm
    gotw$T=$gotw
    gotcnt$T=$gotcnt
    gott$T=$gott
    gotd$T=$gotd
    !if $(gotcnt$T)>0
      !set test_exist=!append item $T to $test_exist
    !endif
    Gotcnt=$[$Gotcnt + $(gotcnt$T)]
  !next
  !for cat in X,D,T,R,M,P
    !read search.ker $cat
    gotm$cat=$gotm
    gotw$cat=$gotw
    gotcnt$cat=$gotcnt
    gott$cat=$gott
    gotd$cat=$gotd
    Gotcnt=$[$Gotcnt + $(gotcnt$cat)]
    !if $(gotcnt$cat) >0
      !set test_exist=!append item $cat to $test_exist
    !endif
  !next
  !goto bailout
!endif
!if $search_category isin X,D,T,O,R,M
  !read search.ker $search_category
  gotm$search_category=$gotm
  gotw$search_category=$gotw
  gotcnt$search_category=$gotcnt
  gott$search_category=$gott
  gotd$search_category=$gotd
  Gotcnt=$[$Gotcnt + $(gotcnt$search_category)]
!endif

:bailout
translator_switch=leaveline
!bound list_start between integer 0 and 10000 default 0
list_start=$[$list_batch*floor($list_start/$list_batch)]

!if $Gotcnt=0
  gottype=popular
  # sp=!replace internal wimshome/public_html/ by $ in $search_package1
  # gotM=!sh head -c 10000 $sp/pop/$search_category.$search_lang
  gotM=!record 0 of $search_package1/pop/$search_category.$search_lang
  gotM=!line 1 to $gotlim of $gotM
  list_cc=!linecnt $gotM
  !if $list_start>$list_cc
    list_start=$[$list_batch*max(0,floor(($list_cc-1)/$list_batch))]
  !endif
  gotm=
  !for i=1 to $list_batch
    l_=!line $i+$list_start of $gotM
    !distribute words $l_ into m_,w_
    !default w_=0
    gotm=$gotm $m_
    gotw=$gotw $w_
  !next i
  gotcnt=!wordcnt $gotm
  gotm=!words2lines $gotm
  gotw=!words2lines $gotw
!else
  gottype=search
!endif

!if / isin $gotm

  dictionary=$search_package2/serial
  translator_unknown=leave
  gotm=!exec translator $gotm
!endif

dictionary=$search_package2/title
gott=!exec translator $gotm
dictionary=$search_package2/description
gotd=!exec translator $gotm
dictionary=$search_package2/language
gotl=!exec translator $gotm
dictionary=$search_package2/author
translator_unknown=?
gota=!exec translator $gotm

!if / notin $gotm and $gotcnt>0
  dictionary=$search_package2/addr
  gotm=!exec translator $gotm
!endif

!for cat in X,T,D,O,R,M
  dictionary=$search_package2/title
  gott$cat=!exec translator $(gotm$cat)
  dictionary=$search_package2/description
  gotd$cat=!exec translator $(gotm$cat)
  dictionary=$search_package2/language
  gotl$cat=!exec translator $(gotm$cat)
  dictionary=$search_package2/author
  translator_unknown=?
  gota$cat=!exec translator $(gotm$cat)

  !if / notin $(gotm$cat) and $(gotcnt$cat)>0
    dictionary=$search_package2/addr
    gotm$cat=!exec translator $(gotm$cat)
  !endif
!next

!if $search_category isin AT and $search_keywords!=$empty and\
    P isin $slist and ($gotcnt<=8 or $gottype!=search)
  gotm1=$gotm
  gotcnt1=$gotcnt
  gottype1=$gottype
  !read search.P
  !if $gotcnt>0
    test_exist=!append item P to $test_exist
    gottype=search
  !endif
  !exchange gottype,gottype1
  !exchange gotcnt,gotcnt1
  !exchange gotm,gotm1
!else
  gotcnt1=0
!endif