root/trunk/website/blog/admin/comment.cfm @ 32

Revision 5, 3.6 kB (checked in by DanWilson, 17 years ago)

Initial Commit Of ModelGlue? Website (upgrade to blogcfc 511)

Line 
1<cfsetting enablecfoutputonly=true>
2<cfprocessingdirective pageencoding="utf-8">
3<!---
4        Name         : comment.cfm
5        Author       : Raymond Camden
6        Created      : 04/07/06
7        Last Updated : 12/07/06
8        History      : Support for moderation (tr 12/7/06)
9--->
10
11<cftry>
12        <cfset comment = application.blog.getComment(url.id)>
13        <cfif comment.recordCount is 0>
14                <cflocation url="comments.cfm" addToken="false">
15        </cfif>
16        <cfcatch>
17                <cflocation url="comments.cfm" addToken="false">
18        </cfcatch>
19</cftry>
20
21<cfif structKeyExists(form, "cancel")>
22        <cflocation url="comments.cfm" addToken="false">
23</cfif>
24
25<cfif structKeyExists(form, "save")>
26        <cfset errors = arrayNew(1)>
27       
28        <cfif not len(trim(form.name))>
29                <cfset arrayAppend(errors, "The name cannot be blank.")>
30        </cfif>
31        <cfif not len(trim(form.email)) or not isEmail(form.email)>
32                <cfset arrayAppend(errors, "The email cannot be blank and must be a valid email address.")>
33        </cfif>
34        <cfif len(form.website) and not isURL(form.website)>
35                <cfset arrayAppend(errors, "Website must be a valid URL.")>
36        </cfif>
37        <cfif not len(trim(form.comment))>
38                <cfset arrayAppend(errors, "The comment cannot be blank.")>
39        </cfif>
40       
41        <cfif not arrayLen(errors)>
42                <cfset application.blog.saveComment(url.id, left(form.name,50), left(form.email,50), left(form.website,255), form.comment, form.subscribe, form.moderated)>
43                <cflocation url="comments.cfm" addToken="false">
44        </cfif>
45       
46</cfif>
47
48<cfparam name="form.name" default="#comment.name#">
49<cfparam name="form.email" default="#comment.email#">
50<cfparam name="form.website" default="#comment.website#">
51<cfparam name="form.comment" default="#comment.comment#">
52<cfparam name="form.subscribe" default="#comment.subscribe#">
53<cfparam name="form.moderated" default="#comment.moderated#">
54
55<cfmodule template="../tags/adminlayout.cfm" title="Comment Editor">
56
57        <cfif structKeyExists(variables, "errors") and arrayLen(errors)>
58                <cfoutput>
59                <div class="errors">
60                Please correct the following error(s):
61                <ul>
62                <cfloop index="x" from="1" to="#arrayLen(errors)#">
63                <li>#errors[x]#</li>
64                </cfloop>
65                </ul>
66                </div>
67                </cfoutput>
68        </cfif>
69       
70        <cfoutput>
71        <form action="comment.cfm?id=#comment.id#" method="post">
72        <table>
73                <tr>
74                        <td align="right">posted:</td>
75                        <td>#application.localeUtils.dateLocaleFormat(comment.posted)# #application.localeUtils.timeLocaleFormat(comment.posted)#</td>
76                </tr>
77                <tr>
78                        <td align="right">name:</td>
79                        <td><input type="text" name="name" value="#form.name#" class="txtField" maxlength="50"></td>
80                </tr>
81                <tr>
82                        <td align="right">email:</td>
83                        <td><input type="text" name="email" value="#form.email#" class="txtField" maxlength="50"></td>
84                </tr>
85                <tr>
86                        <td align="right">website:</td>
87                        <td><input type="text" name="website" value="#form.website#" class="txtField"></td>
88                </tr>
89                <tr valign="top">
90                        <td align="right">comment:</td>
91                        <td><textarea name="comment" class="txtArea">#form.comment#</textarea></td>
92                </tr>
93                <tr>
94                        <td align="right">subscribed:</td>
95                        <td>
96                        <select name="subscribe">
97                        <option value="yes" <cfif form.subscribe>selected</cfif>>Yes</option>
98                        <option value="no" <cfif not form.subscribe>selected</cfif>>No</option>
99                        </select>
100                        </td>
101                </tr>
102                <tr>
103                        <td align="right">moderated:</td>
104                        <td>
105                        <select name="moderated">
106                        <option value="yes" <cfif form.moderated>selected</cfif>>Yes</option>
107                        <option value="no" <cfif not form.moderated>selected</cfif>>No</option>
108                        </select>
109                        </td>
110                </tr>
111                <tr>
112                        <td>&nbsp;</td>
113                        <td><input type="submit" name="cancel" value="Cancel"> <input type="submit" name="save" value="Save"></td>
114                </tr>
115        </table>
116        </form>
117        </cfoutput>
118</cfmodule>
119
120<cfsetting enablecfoutputonly=false>
Note: See TracBrowser for help on using the browser.