root/trunk/website/blog/admin/category.cfm @ 31

Revision 5, 3.2 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         : category.cfm
5        Author       : Raymond Camden
6        Created      : 04/07/06
7        Last Updated :
8        History      :
9--->
10
11<cftry>
12        <cfif url.id neq 0>
13                <cfset cat = application.blog.getCategory(url.id)>
14                <cfparam name="form.name" default="#cat.categoryname#">
15                <cfparam name="form.alias" default="#cat.categoryalias#">
16        <cfelse>
17                <cfparam name="form.name" default="">
18                <cfparam name="form.alias" default="">
19        </cfif>
20        <cfcatch>
21                <cflocation url="categories.cfm" addToken="false">
22        </cfcatch>
23</cftry>
24
25<cfif structKeyExists(form, "cancel")>
26        <cflocation url="categories.cfm" addToken="false">
27</cfif>
28
29<cfif structKeyExists(form, "save")>
30        <cfset errors = arrayNew(1)>
31       
32        <cfif not len(trim(form.name))>
33                <cfset arrayAppend(errors, "The name cannot be blank.")>
34        </cfif>
35        <cfif not len(trim(form.alias))>
36                <cfset form.alias = application.blog.makeTitle(form.name)>
37        <cfelseif reFind("[^[:alnum:] -]", form.alias)>
38                <cfset arrayAppend(errors, "Your alias may only contain letters, numbers, spaces, or hyphens.")>
39        </cfif>
40        <cfif not arrayLen(errors)>
41                <cftry>
42                <cfif url.id neq 0>
43                        <cfset application.blog.saveCategory(url.id, left(form.name,50), left(form.alias, 50))>
44                <cfelse>
45                        <cfset application.blog.addCategory(left(form.name,50), left(form.alias,50))>
46                </cfif>
47                <cfcatch>
48                        <cfif findNoCase("already exists as a category", cfcatch.message)>
49                                <cfset arrayAppend(errors, "A category with this name already exists.")>
50                        <cfelse>
51                                <cfrethrow>
52                        </cfif>
53                </cfcatch>
54                </cftry>
55
56                <cfif not arrayLen(errors)>
57                        <!--- clear the archive pod cache --->
58                        <cfmodule template="../tags/scopecache.cfm" action="clear" scope="application" cachename="pod_archives" />
59                        <cflocation url="categories.cfm" addToken="false">
60                </cfif>
61        </cfif>
62       
63</cfif>
64
65
66<cfmodule template="../tags/adminlayout.cfm" title="Category Editor">
67
68        <cfif structKeyExists(variables, "errors") and arrayLen(errors)>
69                <cfoutput>
70                <div class="errors">
71                Please correct the following error(s):
72                <ul>
73                <cfloop index="x" from="1" to="#arrayLen(errors)#">
74                <li>#errors[x]#</li>
75                </cfloop>
76                </ul>
77                </div>
78                </cfoutput>
79        </cfif>
80       
81        <cfoutput>
82        <p>
83        Use the form below to edit your category. The alias field is used when creating SES (Search Engine Safe) URLs.
84        If you leave the field blank, one will be generated for you. If wish to create it yourself, do not use any non-alphanumeric characters
85        in the alias. Spaces should be replaced with dashes.
86        </p>
87       
88        <form action="category.cfm?id=#url.id#" method="post">
89        <table>
90                <tr>
91                        <td align="right">name:</td>
92                        <td><input type="text" name="name" value="#form.name#" class="txtField" maxlength="50"></td>
93                </tr>
94                <tr>
95                        <td align="right">alias:</td>
96                        <td><input type="text" name="alias" value="#form.alias#" class="txtField" maxlength="50"></td>
97                </tr>
98                <tr>
99                        <td>&nbsp;</td>
100                        <td><input type="submit" name="save" value="Save"> <input type="submit" name="cancel" value="Cancel"></td>
101                </tr>
102        </table>
103        </form>
104        <script language="javaScript" TYPE="text/javascript">
105        <!--
106        document.forms[0].name.focus();
107        //-->
108        </script>
109        </cfoutput>
110</cfmodule>
111
112<cfsetting enablecfoutputonly=false>
Note: See TracBrowser for help on using the browser.