changeset 836:b3516ee2bb4d

Filename renaming added to article EDIT
author HIROSE Yuuji <yuuji@gentei.org>
date Tue, 23 Jun 2020 12:58:31 +0900
parents fa23017ba273
children a6462eea48be
files examples/common/default/default.css s4-cgi.sh s4-funcs.sh
diffstat 3 files changed, 38 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/examples/common/default/default.css	Tue Jun 23 12:47:34 2020 +0900
+++ b/examples/common/default/default.css	Tue Jun 23 12:58:31 2020 +0900
@@ -62,14 +62,17 @@
 input.action ~ input:not(.action), input.action ~ textarea {
     display: none;
 }
-input.action[value="edit"]:checked ~ input {display: inline;}
+input.action[value="edit"]:checked ~ input[class="edit"],
+input.action[value="mv"]:checked ~ input[type="text"] {display: inline;}
 input.action[value="edit"]:checked ~ textarea {display: block;}
-input.action[value="edit"]:checked ~ span {display: none;}
+input.action[value="edit"]:checked ~ span,
+input.action[value="mv"]:checked ~ span {display: none;}
 input.action[value="rm"]:checked ~ span {background: red;}
 label.confirm {display: none;}
 input.action[value="rm"]:checked ~ label.confirm {
     display: inline;
 }
+
 input.hidesub ~ input[type="submit"] {visibility: hidden;}
 input.hidesub:focus ~ input[type="submit"],
 p:active input[type="submit"]
--- a/s4-cgi.sh	Tue Jun 23 12:47:34 2020 +0900
+++ b/s4-cgi.sh	Tue Jun 23 12:58:31 2020 +0900
@@ -74,6 +74,9 @@
   # `dir' should contain $name.count and $name.N where N is 1 upto N
   i=1 name=$1 dir=$2 func=$3
   n=`cat $dir/$name.count`
+  case "$func" in
+    *file) addrename=yes ;;
+  esac
   echo '<table class="text">'
   while [ $i -le $n ]; do
     file=$name.$i
@@ -85,11 +88,15 @@
  value="keep"><label for="keep.$vname" title="Keep">温存</label>
 <input class="action" type="radio" name="action.$vname" id="edit.$vname"
  value="edit"><label for="edit.$vname" title="Replace">修正</label>
+${addrename:+<input class="action" type="radio" name="action.$vname"
+ id="mv.$vname" value="mv"><label for="mv.$vname"
+  title="Rename">名前変更</label>}
 <input class="action" type="radio" name="action.$vname" id="rm.$vname"
  value="rm"><label for="rm.$vname" title="Remove">削除</label>
 <label class="confirm" title="OK?">本当に消します<input class="confirm" type="checkbox"
  name="confirm.$vname" value="yes">はい</label><br>
 `$func $vname "$val" "$4"`<span>$val</span>
+${addrename:+<input class="mv" type="text" name="mv.$vname" value="$val">}
 </td></tr>
 EOF
     i=$((i+1))
@@ -101,14 +108,14 @@
 )
 # In these functions, $2 should be quoted because it can be null
 cgi_multi_text() {
-  cgi_multi $1 "$2" cgi_text "$3"
+  cgi_multi $1 "$2" cgi_text "$3 class=\"edit\""
 }
 cgi_multi_textarea() {
-  cgi_multi $1 "$2" cgi_textarea "$3"
+  cgi_multi $1 "$2" cgi_textarea "$3 class=\"edit\""
 }
 cgi_multi_file() {
   # $1=name $2=val(filename)
-  cgi_multi $1 "$2" cgi_file "$3"
+  cgi_multi $1 "$2" cgi_file "$3 class=\"edit\""
 }
 cgi_datalist_h() {
   # $1=id $2...=hexed-args
--- a/s4-funcs.sh	Tue Jun 23 12:47:34 2020 +0900
+++ b/s4-funcs.sh	Tue Jun 23 12:58:31 2020 +0900
@@ -729,7 +729,7 @@
 	user|skey) unset _$i ;;
       esac
     fi
-    query "DELETE FROM par WHERE var='$i';"
+    query "DELETE FROM par WHERE var='$i' AND sessid='$session';"
   done
 }
 replpar() {
@@ -2941,7 +2941,7 @@
 	fi
 	subj=`getpar subject`
 	afiles=""
-	for fn in `query "SELECT DISTINCT val FROM par WHERE var='files';"`
+	for fn in `query "SELECT DISTINCT val FROM par WHERE var='files' AND sessid='$session';"`
 	do
 	  f=$tmpd/$fn
 	  if [ -s $f ]; then
@@ -3978,7 +3978,7 @@
 	# sessID|address.1.22|string|Somewhere-x.y.z
 	sql=""
 ##err dots from query "select var from par where var like '$col.%';"
-        for v in `query "select var from par where var like '$col.%';"`; do
+        for v in `query "select var from par where var like '$col.%' AND sessid='$session';"`; do
 	  # v=address.1.22
 	  st_rowid=${v##*.}
 	  origcol=${v%%.*}	# original column derived from
@@ -4014,10 +4014,29 @@
 		  ;;
 		*)
 		  newsql="update $tb2 set val=(select val from par where var \
-like '$col.%.$st_rowid')"
+like '$col.%.$st_rowid' AND sessid='$session')"
 		  ;;
 	      esac
 	      ;;
+	    mv)
+	      # regularize filename and strip directory part
+	      newname=`getpar mv.$v|tr -d '":;#<>?^%$!'|tr -d "'"|tr ' ' _`
+	      newname=`basename $newname`
+	      err "newname($v)=$newname"
+	      newext="${newname##*.}"
+	      if test x"$newname" != x"$newext" \
+		  && echo "${file_accept#*=}" \
+		    | fgrep -w "$newext" >/dev/null 1>&2
+	      then
+		newsql="UPDATE $tb2 SET val='$newname'"
+	      else
+		html p<<-EOF
+		$newname は取り扱えないファイル名です。
+		空白を含まない名前で拡張子を正しくつけて下さい。
+		EOF
+		continue
+	      fi
+	      ;;
 	    *)			# maybe "keep", do not modify value
 	      continue
 	      ;;

yatex.org