-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHandler.cfc
99 lines (77 loc) · 4.23 KB
/
Handler.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<cfcomponent>
<cfset variables.name = "mangoNewsMe">
<cfset variables.id = "com.cftips.mangoNewsMe">
<cfset variables.package = "com/cftips/mangoNewsMe"/>
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="init" access="public" output="false" returntype="any">
<cfargument name="mainManager" type="any" required="true" />
<cfargument name="preferences" type="any" required="true" />
<cfset var blogid = arguments.mainManager.getBlog().getId() />
<cfset var path = blogid & "/" & variables.package />
<cfset variables.preferencesManager = arguments.preferences />
<cfset variables.manager = arguments.mainManager />
<cfset variables.moderate = variables.preferencesManager.get(path,"enabled","0") />
<cfreturn this/>
</cffunction>
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="getName" access="public" output="false" returntype="string">
<cfreturn variables.name />
</cffunction>
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="setName" access="public" output="false" returntype="void">
<cfargument name="name" type="string" required="true" />
<cfset variables.name = arguments.name />
<cfreturn />
</cffunction>
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="getId" access="public" output="false" returntype="any">
<cfreturn variables.id />
</cffunction>
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="setId" access="public" output="false" returntype="void">
<cfargument name="id" type="any" required="true" />
<cfset variables.id = arguments.id />
<cfreturn />
</cffunction>
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="setup" hint="This is run when a plugin is activated" access="public" output="false" returntype="any">
<cfreturn "mangoNewsMe plugin activated. <br />
Check the admin Overview section to view the Mango Blog news pod." />
</cffunction>
<cffunction name="unsetup" hint="This is run when a plugin is de-activated" access="public" output="false" returntype="any">
<cfreturn "shareMe plugin de-activated"/>
</cffunction>
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="handleEvent" hint="Asynchronous event handling" access="public" output="false" returntype="any">
<cfargument name="event" type="any" required="true" />
<cfreturn />
</cffunction>
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="processEvent" hint="Synchronous event handling" access="public" output="false" returntype="any">
<cfargument name="event" type="any" required="true" />
<cfset var eventName = arguments.event.name />
<cfset var pod = "" />
<!--- admin dashboard event --->
<cfif eventName EQ "dashboardPod">
<!--- add a pod with Mango Blog News --->
<cfset feedurl = "http://www.mangoblog.org/feeds/rss.cfm">
<cffeed action="read" source="#feedurl#" properties="meta" query="entries">
<cfsavecontent variable="content">
<cfoutput>
<cfloop query="entries" startrow="1" endrow="5">
<p>
<b><a href="#rsslink#">#title#</a></b> <i>#LSDateFormat(CreateODBCDate(publisheddate), "mmmm d, yyyy")#</i><br /><br />
<strong>Category: #CATEGORYLABEL#</strong><br />
<br />
#Left(REReplaceNoCase(content,"<[^>]*>","","ALL"), 75)#>[...]
</p>
</cfloop>
</cfoutput></cfsavecontent>
<cfset pod = structnew() />
<cfset pod.title = "Mango Blog News" />
<cfset pod.content = content />
<cfset arguments.event.addPod(pod)>
</cfif>
<cfreturn arguments.event />
</cffunction>
</cfcomponent>