root/trunk/website/blog/admin/page.cfm @ 5

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

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

RevLine 
[5]1<cfsetting enablecfoutputonly=true>
2<cfprocessingdirective pageencoding="utf-8">
3<!---
4        Name         : /client/admin/page.cfm
5        Author       : Raymond Camden
6        Created      : 07/07/06
7        Last Updated : 07/12/06
8        History      : Mention code, textblock support (rkc 7/12/06)
9--->
10
11<cfparam name="url.id" default="0">
12
13<cfif url.id is not 0>
14        <cftry>
15        <cfset page = application.page.getPage(url.id)>
16        <cfif structIsEmpty(page)>
17                <cflocation url="pages.cfm" addToken="false">
18        </cfif>
19        <cfcatch>
20                <cflocation url="pages.cfm" addToken="false">
21        </cfcatch>
22        </cftry>
23        <cfparam name="form.title" default="#page.title#">
24        <cfparam name="form.body" default="#page.body#">
25        <cfparam name="form.alias" default="#page.alias#">
26<cfelse>
27        <cfparam name="form.title" default="">
28        <cfparam name="form.body" default="">
29        <cfparam name="form.alias" default="">
30</cfif>
31
32<cfif structKeyExists(form, "cancel")>
33        <cflocation url="pages.cfm" addToken="false">
34</cfif>
35
36<cfif structKeyExists(form, "save")>
37        <cfset errors = arrayNew(1)>
38       
39        <cfif not len(trim(form.title))>
40                <cfset arrayAppend(errors, "The title cannot be blank.")>
41        </cfif>
42        <cfif not len(trim(form.body))>
43                <cfset arrayAppend(errors, "The body cannot be blank.")>
44        </cfif>
45        <cfif len(form.title) and not len(form.alias)>
46                <cfset form.alias = application.blog.makeTitle(form.title)>
47        </cfif>
48       
49        <cfif not arrayLen(errors)>
50                <cfset application.page.savePage(url.id, left(form.title,255), left(form.alias,50), form.body)>
51                <cflocation url="pages.cfm" addToken="false">
52        </cfif>
53       
54</cfif>
55
56<cfmodule template="../tags/adminlayout.cfm" title="Page Editor">
57
58        <cfoutput>
59        <p>
60        Use the form below to create a page for your blog. The alias will be auto-generated if left blank, which is recommended.
61        Aliases must be unique per page. If you change your page title, you may want to remove the alias so it will be auto-generated again.
62        </p>
63       
64        <p>
65        You can use &lt;code&gt;....&lt;/code&gt; to add formatting to code blocks.<br />
66        You can dynamically include textblocks using &lt;textblock label="..."&gt;.
67        </p>
68        </cfoutput>
69       
70        <cfif structKeyExists(variables, "errors") and arrayLen(errors)>
71                <cfoutput>
72                <div class="errors">
73                Please correct the following error(s):
74                <ul>
75                <cfloop index="x" from="1" to="#arrayLen(errors)#">
76                <li>#errors[x]#</li>
77                </cfloop>
78                </ul>
79                </div>
80                </cfoutput>
81        </cfif>
82       
83        <cfoutput>
84        <form action="page.cfm?id=#url.id#" method="post">
85        <table>
86                <tr>
87                        <td align="right">title:</td>
88                        <td><input type="text" name="title" value="#form.title#" class="txtField" maxlength="255"></td>
89                </tr>
90                <tr>
91                        <td align="right">alias:</td>
92                        <td><input type="text" name="alias" value="#form.alias#" class="txtField" maxlength="100"></td>
93                </tr>
94                <tr valign="top">
95                        <td align="right">body:</td>
96                        <td></cfoutput><cfmodule template="../tags/textarea.cfm" fieldname="body" value="#htmlEditFormat(form.body)#" class="txtArea" /><cfoutput></td>
97                </tr>
98                <cfif len(form.alias)>
99                <tr valign="top">
100                        <td align="right">url:</td>
101                        <td><a href="#application.rooturl#/page.cfm/#form.alias#">#application.rooturl#/page.cfm/#form.alias#</a></td>
102                </tr>
103                </cfif>
104                <tr>
105                        <td>&nbsp;</td>
106                        <td><input type="submit" name="cancel" value="Cancel"> <input type="submit" name="save" value="Save"></td>
107                </tr>
108        </table>
109        </form>
110        </cfoutput>
111</cfmodule>
112
113<cfsetting enablecfoutputonly=false>
Note: See TracBrowser for help on using the browser.