s4

changeset 509:d34b8f36501c

Progressive search does not restrict author
author HIROSE Yuuji <yuuji@gentei.org>
date Thu, 14 Mar 2019 10:28:42 +0900
parents 944739c3ac5c
children 2a70b6c7ffad
files s4-blog.sh s4-funcs.sh
diffstat 2 files changed, 25 insertions(+), 9 deletions(-) [+]
line diff
     1.1 --- a/s4-blog.sh	Wed Mar 13 20:16:56 2019 +0900
     1.2 +++ b/s4-blog.sh	Thu Mar 14 10:28:42 2019 +0900
     1.3 @@ -830,25 +830,30 @@
     1.4    msg=""
     1.5    if [ -n "$owner" ]; then
     1.6      cond="where key='owner' and val='$owner'"
     1.7 -    search_form_args="author=$owner"
     1.8      if isuser $owner; then
     1.9 -      msg="(`linkhome $owner` さんの記録からの検索)"
    1.10 +      msg="(`linkhome $owner` さんの記録から)"
    1.11      else
    1.12        linkhome $owner 1>&3
    1.13 -      msg="(`linkhome $owner` グループからの検索)"
    1.14 +      msg="(`linkhome $owner` グループから)"
    1.15      fi
    1.16    elif { author=`getpar author`; test -n "$author"; }; then
    1.17      atptn=`sqlquotestr $author`
    1.18      #kc="$kc${kc:+ AND }author=$atptn"
    1.19      authcond="WHERE author=$atptn"
    1.20 -    search_form_args="author=$author"
    1.21      if isuser $author; then
    1.22 -      msg="(`linkhome $author` さんの書き込みからの検索)"
    1.23 +      msg="(`linkhome $author` さんの書き込みから)"
    1.24      fi
    1.25    fi
    1.26 -  search_form "$search_form_args" "$kwd"
    1.27 -  echo "「$kwd」による検索結果" $search_form_args| html p
    1.28 -  echo "$msg" | html p
    1.29 +  bloglist=`getpar bloglist|sed 's/[^0-9,]//g'`
    1.30 +  if [ -n "$bloglist" ]; then
    1.31 +    blogcond="AND bl.rid IN ($bloglist)"
    1.32 +  fi
    1.33 +     
    1.34 +  sf=`search_form "$search_form_args" "$kwd" | sed '1d;$d'` # rm <div></div>
    1.35 +  echo "$sf" | sed -e "/POST SENTENCE/s/.*/__PS__/" -e "/EOF/q" \
    1.36 +    | _m4 -D__PS__="による検索結果$msg"
    1.37 +  echo "(上記入力窓で再検索すると下記の掲示板のみに絞って再検索します)" \
    1.38 +    | html p 'class="small"'
    1.39    # article_s:	id=article-id, key='text', val='TEXT'
    1.40    # article:	id=article-id, blogid=blogkd
    1.41    # blog:		id=blog-id, author=LeaderAuthor
    1.42 @@ -889,7 +894,7 @@
    1.43  	substr(content, 0, 78) TEXT
    1.44  FROM ar JOIN bl
    1.45  	ON ar.blogid=bl.id
    1.46 -WHERE $kc AND bl.id IN (SELECT id FROM blog_s $cond)
    1.47 +WHERE $kc AND bl.id IN (SELECT id FROM blog_s $cond) $blogcond
    1.48  ORDER by DATE DESC, TITLE, ctime;"
    1.49    sedopt="s,<TR><TD>\([^<]*\)</TD>,<TR><TD><a\
    1.50   href=\"?replyblog+\1\">VIEW</a></TD>,"
    1.51 @@ -904,9 +909,18 @@
    1.52      found=$((`grep "^<TR><TD>" $result | wc -l` + 0))	# Cast to INT
    1.53      one=${found%1}
    1.54      echo "$found match${one:+es} found"
    1.55 +    # <a href="?replyblog+39#12345">VIEW</a>
    1.56 +    # -> 39,49,55, -> 39,49,55
    1.57 +    # -> <input type="hidden" name="bloglist" value="39,49,55">
    1.58 +    sed -n "/.*href=.*replyblog\+\([0-9][0-9]*\).*/s//\1/p" "$result" \
    1.59 +      | sort | uniq | tr '\n' ',' \
    1.60 +      | sed -e 's/,$//' \
    1.61 +	    -e 's/^/<input type="hidden" name="bloglist" value="/' \
    1.62 +	    -e 's/$/">/'
    1.63    else
    1.64      echo orz...
    1.65    fi
    1.66 +  echo "$sf" | sed "1,/-- EOF/d"		# Close <form>
    1.67  }
    1.68  listblog() (
    1.69    # $1={user,group}
     2.1 --- a/s4-funcs.sh	Wed Mar 13 20:16:56 2019 +0900
     2.2 +++ b/s4-funcs.sh	Thu Mar 14 10:28:42 2019 +0900
     2.3 @@ -1674,8 +1674,10 @@
     2.4  	<form action="$myname">$auth
     2.5  	<input type="text" name="kwd" value="$inikwd" title="$help"
     2.6  	 placeholder=" $placeholder " width="10" accesskey="k">
     2.7 +	 <!-- POST SENTENCE -->
     2.8  	 ${touchpanel:+<p class="help">$help</p>}
     2.9  	<input type="hidden" name="stage" value="searchart">
    2.10 +	<!-- EOF -->
    2.11  	</form>
    2.12  	</div>
    2.13  	EOF