OSDN Git Service

next.
authorvisor <visor@users.sourceforge.jp>
Thu, 4 Jun 2009 15:08:39 +0000 (00:08 +0900)
committervisor <visor@users.sourceforge.jp>
Thu, 4 Jun 2009 15:08:39 +0000 (00:08 +0900)
i/wiki.js
lib-wikifunc.ml
lib.ml

index 15766c6..fc44bc6 100644 (file)
--- a/i/wiki.js
+++ b/i/wiki.js
@@ -74,6 +74,9 @@ function showWiki(xml){
 function showWikiHandler(r){
        showWiki(r.responseXML.documentElement);
 }
+function reloadHander(r){
+       gotoPage();
+}
 //
 function SubmitForm(form,page,data,func){
        if(func){
@@ -134,7 +137,6 @@ function loadURL(url,data,target,f2){
 function opLogin(form){
        var f=function(r){
                if(r.responseText=='OK'){
-//                     gotoPage();
                        var f2=function(r){
                                $('LoginPane').hideDialog();
                                if(LoginOp){
@@ -147,11 +149,11 @@ function opLogin(form){
                        $('LoginMsgPane').replaceText('IDまたはパスワードが間違っています。');
                }
        };
-       callURL('../../op-login.hml',form.serialize(true),f);
+       callURL('../../op-login.hml',$(form).serialize(true),f);
 }
 //
 function opLogout(){
-       callURL('../../op-logout.hml',null,function(r){gotoPage();});
+       callURL('../../op-logout.hml',null,reloadHander);
 }
 //
 function opEditSel(sel){
@@ -176,20 +178,11 @@ function postWiki(form,data,func){
        callURL('../../op-post.hml',$H($(form).serialize(true)).update(data),func);
 }
 function opPreview(form){
-       var f=function(r){
-               showWiki(r.responseXML.documentElement);
-       };
-       postWiki(form,null,f);
+       postWiki(form,null,showWikiHandler);
 }
 function opSave(form){
-       var f=function(r){
-               showWiki(r.responseXML.documentElement);
-       };
-       postWiki(form,{'Save':'1'},f);
+       postWiki(form,{'Save':'1'},showWikiHandler);
 }
 function opSaveClose(form){
-       var f=function(r){
-               gotoPage();
-       };
-       postWiki(form,{'Save':'1'},f);
+       postWiki(form,{'Save':'1'},reloadHander);
 }
index 7d13ca3..ba9309e 100644 (file)
 )
 
 (defun-wiki-command PageIndex (vpage vtitle)
-       (wiki-page-index nil (wikivar vpage) (wikivar vtitle))
+       ($sqlite3 'database
+               (wiki-page-index nil (wikivar vpage) (wikivar vtitle))
+       )
 )
 
 (defun-wiki-command PageIndexCategory (cat vpage vtitle)
-       (wiki-page-index cat (wikivar vpage) (wikivar vtitle))
+       ($sqlite3 'database
+               (wiki-page-index cat (wikivar vpage) (wikivar vtitle))
+       )
 )
 
 (defun-wiki-command PageIndexSpecial (vpage vtitle)
-       (wiki-page-index-special (wikivar vpage) (wikivar vtitle))
+       ($sqlite3 'database
+               (wiki-page-index-special (wikivar vpage) (wikivar vtitle))
+       )
 )
 
 (defun-wiki-command CategoryIndex (vname)
-       (wiki-category-index (wikivar vname))
+       ($sqlite3 'database
+               (wiki-category-index (wikivar vname))
+       )
 )
 
 (defun-wiki-command AddCategory (cat)
        (if Writer
-                       (wiki-add-category cat)
+                       ($sqlite3 'database
+                               (wiki-add-category cat)
+                       )
        )
 )
 
 (defun-wiki-command DelCategory (cat)
        (if Writer
                ($sqlite3 'database
-                       (sql "begin")
-                       (sql "delete from WikiCategory where CID in (select CID from CategoryList where PID=:pid and CName=:cat)"
-                               :bind ':pid PID ':cat cat)
-                       (sql "delete from CategoryList where PID=:pid and CName=:cat"
-                               :bind ':pid PID ':cat cat)
-                       (sql "end")
+                       (wiki-delete-category cat)
                )
        )
 )
diff --git a/lib.ml b/lib.ml
index 143ec11..7fbed08 100644 (file)
--- a/lib.ml
+++ b/lib.ml
@@ -74,7 +74,7 @@
        (let (iid wid date uid nwid)
                (sql "begin")
                (sql "select IID,WID,Date,UID from WikiIndex where PID=:pid and Page=:page"
-                       :bind (list ':pid PID ':page Page)
+                       :bind (list ':pid PID ':page page)
                        :answer '(iid wid date uid))
                (if (and        (not-emptyp wid)
                                        (> date (- (now) 10800))
        )
 )
 
+(defun wiki-delete (page)
+       (sql "begin")
+       (sql "insert into BackupIndex(PID,Page,UID,IP,Date,WID) select PID,Page,UID,IP,Date,WID from WikiIndex where PID=:pid and Page=:page"
+               :bind (list ':pid PID ':page page))
+       (sql "delete from WikiIndex where PID=:pid and Page=:page"
+               :bind (list ':pid PID ':page page))
+       (sql "end")
+)
+
 (defun wiki-page-index (cat vpage vtitle)
-       ($sqlite3 'database
-               (if (null cat)
-                               (progn
-                                       (sql "select a.Page,b.Title from WikiIndex a,Wiki b using(WID) where a.PID=:pid and a.Page not like 'special-%' order by a.Page"
-                                               :bind ':pid PID
-                                               :@answer (list vpage vtitle))
-                               )
-                       (if (emptyp cat)
-                                       (sql "select a.Page,b.Title from WikiIndex a,Wiki b using(WID) where a.PID=:pid and a.IID not in (select IID from WikiCategory where PID=:pid) and a.Page not like 'special-%' order by a.Page"
-                                               :bind (list ':pid PID)
-                                               :@answer (list vpage vtitle))
-                               (sql "select a.Page,b.Title from CategoryList c,WikiCategory d using(CID),WikiIndex a using(IID),Wiki b using(WID) where a.PID=:pid and c.CName=:cat and a.Page not like 'special-%'  order by a.Page"
-                                       :bind (list ':pid PID ':cat cat)
+       (if (null cat)
+                       (progn
+                               (sql "select a.Page,b.Title from WikiIndex a,Wiki b using(WID) where a.PID=:pid and a.Page not like 'special-%' order by a.Page"
+                                       :bind ':pid PID
                                        :@answer (list vpage vtitle))
                        )
+               (if (emptyp cat)
+                               (sql "select a.Page,b.Title from WikiIndex a,Wiki b using(WID) where a.PID=:pid and a.IID not in (select IID from WikiCategory where PID=:pid) and a.Page not like 'special-%' order by a.Page"
+                                       :bind (list ':pid PID)
+                                       :@answer (list vpage vtitle))
+                       (sql "select a.Page,b.Title from CategoryList c,WikiCategory d using(CID),WikiIndex a using(IID),Wiki b using(WID) where a.PID=:pid and c.CName=:cat and a.Page not like 'special-%'  order by a.Page"
+                               :bind (list ':pid PID ':cat cat)
+                               :@answer (list vpage vtitle))
                )
        )
 )
 
 (defun wiki-page-index-special (vpage vtitle)
-       ($sqlite3 'database
-               (sql "select a.Page,b.Title from WikiIndex a,Wiki b using(WID) where a.PID=:pid and a.Page like 'special-%' order by a.Page"
-                       :bind ':pid PID
-                       :@answer (list vpage vtitle))
-       )
+       (sql "select a.Page,b.Title from WikiIndex a,Wiki b using(WID) where a.PID=:pid and a.Page like 'special-%' order by a.Page"
+               :bind ':pid PID
+               :@answer (list vpage vtitle))
 )
 
 (defun wiki-category-index (vname)
-       ($sqlite3 'database
-               (sql "select CName from CategoryList where PID=:pid order by CName"
-                       :bind ':pid PID
-                       :@answer (list vname))
-       )
+       (sql "select CName from CategoryList where PID=:pid order by CName"
+               :bind ':pid PID
+               :@answer (list vname))
 )
 
 (defun wiki-add-category (name)
        (if (not-emptyp name)
-                       ($sqlite3 'database
-                               (sql "insert into CategoryList(PID,CName) values(:pid,:cat)"
-                                       :bind (list ':pid PID ':cat name))
-                       )
+                       (sql "insert into CategoryList(PID,CName) values(:pid,:cat)"
+                               :bind (list ':pid PID ':cat name))
+       )
+)
+
+(defun wiki-delete-category (name)
+       (sql "begin")
+       (sql "delete from WikiCategory where CID in (select CID from CategoryList where PID=:pid and CName=:cat)"
+               :bind ':pid PID ':cat cat)
+       (sql "delete from CategoryList where PID=:pid and CName=:cat"
+               :bind ':pid PID ':cat cat)
+       (sql "end")
+)
+
+(defun wiki-set-category (page vlist)
+       (let (iid)
+               (sql "begin")
+               (sql "select IID from WikiIndex where PID=:pid and Page=:page"
+                       :bind (list ':pid PID ':page page)
+                       :answer '(iid))
+               (if (not-emptyp iid)
+                               (progn  (sql "delete from WikiCategory where IID=:iid"
+                                                       :bind ':iid iid)
+                                               (doarray vlist
+                                                       (sql "insert into WikiCategory(PID,IID,CID) select :pid,:iid,CID from CategoryList where PID=:pid and CName=:name"
+                                                               :bind (list ':pid PID ':iid iid ':name vlist))
+                                               )
+                               )
+               )
+               (sql "end")
        )
 )