root/trunk/website/org/camden/blog/textblock.cfc @ 5

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

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

Line 
1<!---
2        Name         : textblock
3        Author       : Raymond Camden
4        Created      :
5        Last Updated : August 22, 2006
6        History      : Updates for Oracle and username/password added by Deanna Schneider (8/22/06)
7        Purpose          : Blog CFC
8--->
9<cfcomponent output="false" displayName="Textblock">
10
11<cfset variables.username = "">
12<cfset variables.password = "">
13<cfset variables.dsn = "">
14<cfset variables.blog = "">
15
16<cffunction name="init" access="public" returnType="textblock" output="false">
17        <cfargument name="dsn" type="string" required="true">
18        <cfargument name="username" type="string" required="true">
19        <cfargument name="password" type="string" required="true">
20        <cfargument name="blog" type="string" required="true">
21       
22        <cfset variables.dsn = arguments.dsn>
23        <cfset variables.username = arguments.username>
24        <cfset variables.password = arguments.password>
25        <cfset variables.blog = arguments.blog>
26               
27        <cfreturn this>
28</cffunction>
29
30<cffunction name="deleteTextblock" returnType="void" output="false" access="public">
31        <cfargument name="id" type="uuid" required="true">
32       
33        <cfquery datasource="#variables.dsn#" username="#variables.username#" password="#variables.password#">
34        delete from tblblogtextblocks
35        where   id = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.id#" maxlength="35">
36        and             blog = <cfqueryparam cfsqltype="cf_sql_varchar" value="#variables.blog#" maxlength="50">
37        </cfquery>
38</cffunction>
39
40<cffunction name="getTextBlock" access="public" returnType="struct" output="false">
41        <cfargument name="label" type="string" required="false">
42        <cfargument name="id" type="uuid" required="false">
43        <cfset var q = "">
44        <cfset var s = structNew()>
45       
46        <cfquery name="q" datasource="#variables.dsn#"  username="#variables.username#" password="#variables.password#">
47        select          id, label, body
48        from            tblblogtextblocks
49        where           blog = <cfqueryparam cfsqltype="cf_sql_varchar" value="#variables.blog#" maxlength="50">
50        <cfif structKeyExists(arguments, "label")>
51        and             label = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.label#" maxlength="255">
52        </cfif>
53        <cfif structKeyExists(arguments, "id")>
54        and             id = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.id#" maxlength="35">
55        </cfif>
56        </cfquery>
57       
58        <cfif q.recordCount>
59                <cfset s.id = q.id>
60                <cfset s.label = q.label>
61                <cfset s.body = q.body>
62        </cfif>
63       
64        <cfreturn s>
65</cffunction>
66
67<cffunction name="getTextBlockContent" access="public" returnType="string" output="false">
68        <cfargument name="label" type="string" required="true">
69        <cfset var q = "">
70       
71        <cfquery name="q" datasource="#variables.dsn#"  username="#variables.username#" password="#variables.password#">
72        select          id, label, body
73        from            tblblogtextblocks
74        where           blog = <cfqueryparam cfsqltype="cf_sql_varchar" value="#variables.blog#" maxlength="50">
75        and                     label = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.label#" maxlength="255">
76        </cfquery>
77       
78        <cfreturn q.body>
79</cffunction>
80
81
82<cffunction name="getTextBlocks" access="public" returnType="query" output="false">
83        <cfset var q = "">
84       
85        <cfquery name="q" datasource="#variables.dsn#"  username="#variables.username#" password="#variables.password#">
86        select          id, label, body
87        from            tblblogtextblocks
88        where           blog = <cfqueryparam cfsqltype="cf_sql_varchar" value="#variables.blog#" maxlength="50">       
89        order by        label asc
90        </cfquery>
91       
92        <cfreturn q>
93</cffunction>
94
95<cffunction name="saveTextblock" returnType="void" output="false" access="public">
96        <cfargument name="id" type="string" required="true">
97        <cfargument name="label" type="string" required="true">
98        <cfargument name="body" type="string" required="true">
99       
100        <cfif arguments.id is 0>
101                <cfset arguments.id = createUUID()>
102
103                <cfquery datasource="#variables.dsn#"  username="#variables.username#" password="#variables.password#">
104                insert into tblblogtextblocks(id, label, body, blog)
105                values(
106                        <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.id#" maxlength="35">,
107                        <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.label#" maxlength="255">,
108                        <cfqueryparam cfsqltype="cf_sql_longvarchar" value="#arguments.body#">,
109                        <cfqueryparam cfsqltype="cf_sql_varchar" value="#variables.blog#" maxlength="35">
110                        )
111                </cfquery>
112
113        <cfelse>
114       
115                <cfquery datasource="#variables.dsn#"  username="#variables.username#" password="#variables.password#">
116                update tblblogtextblocks
117                set
118                                label = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.label#" maxlength="255">,
119                                body = <cfqueryparam cfsqltype="cf_sql_longvarchar" value="#arguments.body#">
120                where   id = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.id#" maxlength="35">
121                </cfquery>
122               
123        </cfif>
124       
125</cffunction>
126
127</cfcomponent>
Note: See TracBrowser for help on using the browser.