-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasePlugin.cfc
100 lines (81 loc) · 4.36 KB
/
BasePlugin.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
100
<cfcomponent output="false">
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="getManager" access="public" output="false" returntype="any">
<cfreturn variables.mainManager />
</cffunction>
<cffunction name="setManager" access="public" output="false" returntype="void">
<cfargument name="mainManager" type="any" required="true" />
<cfset variables.mainManager = arguments.mainManager />
</cffunction>
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="getPreferencesManager" access="public" output="false" returntype="any">
<cfreturn variables.preferencesManager />
</cffunction>
<cffunction name="setPreferencesManager" access="public" output="false" returntype="void">
<cfargument name="preferencesManager" type="any" required="true" />
<cfset variables.preferencesManager = arguments.preferencesManager />
</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 />
</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 />
</cffunction>
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="getPackage" access="public" output="false" returntype="any">
<cfreturn variables.package />
</cffunction>
<cffunction name="setPackage" access="public" output="false" returntype="void">
<cfargument name="package" type="any" required="true" />
<cfset variables.package = arguments.package />
</cffunction>
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="getSettingsPath" access="public" output="false" returntype="any">
<cfreturn getManager().getBlog().getId() & "/" & getPackage() />
</cffunction>
<cffunction name="getAssetPath" access="public" output="false" returntype="any">
<cfreturn getManager().getBlog().getBasePath() & "assets/plugins/" & getPluginDirName() & "/" />
</cffunction>
<cffunction name="getAdminAssetPath" access="public" output="false" returntype="any">
<cfreturn getManager().getBlog().getBasePath() & "admin/assets/plugins/" & getPluginDirName() & "/" />
</cffunction>
<cffunction name="getPluginDirName" access="private" output="false" returntype="any">
<cfset var name = getMetaData(this).name />
<cfset var dir = ListGetAt(name, ListLen(name, ".")-1, ".")>
<cfreturn dir />
</cffunction>
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
<cffunction name="initSettings" access="public" output="true" returntype="void">
<cfset var key = "" />
<cfset variables.settings = StructNew() />
<cfloop collection="#arguments#" item="key">
<cfset variables.settings[key] = getPreferencesManager().get(getSettingsPath(), key, arguments[key]) />
</cfloop>
</cffunction>
<cffunction name="setSettings" access="public" output="false" returntype="void">
<cfset var key = "" />
<cfloop collection="#arguments#" item="key">
<cfset variables.settings[key] = arguments[key] />
</cfloop>
</cffunction>
<cffunction name="getSetting" access="public" output="false" returntype="any">
<cfargument name="key" type="any" required="true" />
<cfreturn variables.settings[arguments.key] />
</cffunction>
<cffunction name="persistSettings" access="public" output="false" returntype="void">
<cfset var key = "" />
<cfloop collection="#variables.settings#" item="key">
<cfset getPreferencesManager().put(getSettingsPath(), key, variables.settings[key]) />
</cfloop>
</cffunction>
</cfcomponent>