[phpwebapp-commits] CVS: top10/templates/proj_details/comments comments.js,NONE,1.1 new_comment.html
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2003-09-25 15:50:30
|
Update of /cvsroot/phpwebapp/top10/templates/proj_details/comments In directory sc8-pr-cvs1:/tmp/cvs-serv4503/templates/proj_details/comments Modified Files: new_comment.html comments.php comments.html comments.db Added Files: comments.js Log Message: Adding comments. --- NEW FILE: comments.js --- // -*-C-*- //tell emacs to use C mode function send_comment() { var form = document.new_comment; var username = form.username.value; var subject = form.subject.value; var comment = form.comment.value; if (comment=='') { alert("Please enter a comment!"); form.comment.focus(); return; } if (subject=='') { var msg = "You did not specify a subject. Send the comment anyway?"; if (!confirm(msg)) { form.subject.focus(); return; } } var event_args = "username=" + username + ";" + "subject=" + subject + ";" + "comment=" + comment; SendEvent("comments", "add_comment", event_args); } Index: new_comment.html =================================================================== RCS file: /cvsroot/phpwebapp/top10/templates/proj_details/comments/new_comment.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** new_comment.html 24 Sep 2003 14:00:46 -0000 1.1 --- new_comment.html 25 Sep 2003 15:50:25 -0000 1.2 *************** *** 1,11 **** ! <table width="100%"> ! <tr> ! <td colspan="2">Submit a new comment:</td> ! </tr> ! <form> <tr> <td>Username:</td> <td> ! <input type="text" size="20" value="{{username}}"> </td> </tr> --- 1,9 ---- ! <h4>Add a new comment:</h4> ! <table width="100%" bgcolor="#e6e6ee"> ! <form name="new_comment" onsubmit="send_comment(); return false;"> <tr> <td>Username:</td> <td> ! <input type="text" name="username" value="{{username}}" size="20"> </td> </tr> *************** *** 13,17 **** <td>Subject:</td> <td> ! <input type="text" size="80"> </td> </tr> --- 11,15 ---- <td>Subject:</td> <td> ! <input type="text" name="subject" size="80"> </td> </tr> *************** *** 19,23 **** <td valign="top">Comment:</td> <td> ! <textarea rows="10" cols="70"></textarea> </td> </tr> --- 17,21 ---- <td valign="top">Comment:</td> <td> ! <textarea name="comment" rows="10" cols="70"></textarea> </td> </tr> *************** *** 25,29 **** <td></td> <td> ! <a class="button" href="">Submit</a> </td> </tr> --- 23,27 ---- <td></td> <td> ! <a class="button" href="javascript:send_comment()">Submit</a> </td> </tr> Index: comments.php =================================================================== RCS file: /cvsroot/phpwebapp/top10/templates/proj_details/comments/comments.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** comments.php 24 Sep 2003 14:00:47 -0000 1.1 --- comments.php 25 Sep 2003 15:50:26 -0000 1.2 *************** *** 2,7 **** class comments extends WebObject { ! function onRender() { } } --- 2,14 ---- class comments extends WebObject { ! function on_add_comment($event_args) { + $params = $event_args; + $params["date"] = date("Y-m-d"); + $params["ip"] = $_SERVER["REMOTE_ADDR"]; + $comment = $params["comment"]; + $allowed_tags = "<b><i><a><br><p><ol><ul><li><hr>"; + $params["comment"] = strip_tags($comment, $allowed_tags); + WebApp::execDBCmd("insert_comment", $params); } } Index: comments.html =================================================================== RCS file: /cvsroot/phpwebapp/top10/templates/proj_details/comments/comments.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** comments.html 24 Sep 2003 14:00:47 -0000 1.1 --- comments.html 25 Sep 2003 15:50:26 -0000 1.2 *************** *** 2,13 **** <Repeat rs="comment_list"> <IfEmpty> ! No comments submitted yet.<br> </IfEmpty> ! Username: {{username}}, Date: {{date}} <br> ! Comment: <br> ! {{comment}} ! <hr> </Repeat> - <br> <Include SRC="{{./}}new_comment.html" /> --- 2,37 ---- <Repeat rs="comment_list"> <IfEmpty> ! <h4>No comments submitted yet.</h4> </IfEmpty> ! <Header> ! <h4>Comments:</h4> ! <table width="100%" border="0" cellspacing="1"> ! </Header> ! <RepeatBody> ! <Var name="bgcolor1">({{CurrentRowNr}} % 2 ? "#ddddd6" : "#e6e6ee")</Var> ! <Var name="bgcolor2">({{CurrentRowNr}} % 2 ? "#eeeee6" : "#f6f6ff")</Var> ! <tr> ! <td bgcolor="#dddddd" width="1%" nowrap><b>{{username}}</b></td> ! <td bgcolor="{{bgcolor1}}"> ! <table width="100%" cellspacing="0" cellpadding="0" border="0"> ! <tr> ! <td><b>{{subject}}</b></td> ! <td align="right"> ! <a class="button" href="del_comment('{{comment_id}}')">X</a> ! </td> ! </tr> ! </table> ! </td> ! </tr> ! <tr> ! <td bgcolor="#e4e4e4" width="1%" nowrap valign="top">{{date}}</td> ! <td bgcolor="{{bgcolor2}}">{{comment}}</td> ! </tr> ! <tr bgcolor="#ffffff"><td></td></tr> ! </RepeatBody> ! <Footer> ! </table> ! </Footer> </Repeat> <Include SRC="{{./}}new_comment.html" /> Index: comments.db =================================================================== RCS file: /cvsroot/phpwebapp/top10/templates/proj_details/comments/comments.db,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** comments.db 24 Sep 2003 14:00:47 -0000 1.1 --- comments.db 25 Sep 2003 15:50:26 -0000 1.2 *************** *** 8,9 **** --- 8,22 ---- </Query> </Recordset> + + <dbCommand ID="insert_comment"> + <Query> + INSERT INTO comments + SET + proj_id = '{{proj_id}}', + username = '{{username}}', + comment = '{{comment}}', + date = '{{date}}', + ip = '{{ip}}' + </Query> + </dbCommand> + <!--# ToDo: add the field 'subject' #--> |