-
Notifications
You must be signed in to change notification settings - Fork 1
/
MobileMura.cfc
119 lines (91 loc) · 4.16 KB
/
MobileMura.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!---
MobileMura/MobileMura.cfc
Copyright 2011 Guust Nieuwenhuis
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--->
<cfcomponent>
<cffunction name="updateTemplate" output="false" returntype="any" access="public" >
<cfargument name="contentBean" />
<cfset var $ = application.serviceFactory.getBean("muraScope").init(session.siteID) />
<cfset var c = arguments.contentBean />
<cfset var p = arguments.contentBean />
<cfset var mobileTemplate = "" />
<!--- check if a template is set --->
<!--- inherit from parent == empty string --->
<!--- if the template is an empty string: look for the parents template --->
<cfloop condition="NOT Len(c.getTemplate())" >
<!--- get the template --->
<cfset c = c.getParent() />
</cfloop>
<!--- the 'mobiletemplate' is set --->
<cfif Len(arguments.contentBean.getValue("mobiletemplate"))>
<!--- Inherit From Parent --->
<cfif arguments.contentBean.getValue("mobiletemplate") EQ "-1">
<cfset i = true />
<cfloop condition="i" >
<cfif p.hasParent()>
<cfset p = p.getParent() />
<cfif Len(p.getExtendedAttribute("mobiletemplate"))>
<cfif p.getExtendedAttribute("mobiletemplate") EQ "-1">
<cfelseif p.getExtendedAttribute("mobiletemplate") EQ "0">
<cfset mobileTemplate = p.getTemplate() />
<cfset i = false />
<cfelse>
<cfset mobileTemplate = p.getExtendedAttribute("mobiletemplate") />
<cfset i = false />
</cfif>
</cfif>
<cfelse>
<cfset mobileTemplate = p.getTemplate() />
<cfset i = false />
</cfif>
</cfloop>
<!--- Desktop Template --->
<cfelseif arguments.contentBean.getValue("mobiletemplate") EQ "-2">
<cfset mobileTemplate = "" />
<cfelse>
<cfset mobileTemplate = arguments.contentBean.getValue("mobiletemplate") />
</cfif>
<!--- the 'mobiletemplate' isn't set --->
<cfelse>
<cfset mobileTemplate = "" />
</cfif>
<!--- if a mobiletemplate is set and if the file exists --->
<cfif Len(mobileTemplate) AND FileExists($.siteConfig().getTemplateIncludeDir() & "/" & mobileTemplate)>
<!--- change the template --->
<cfset arguments.contentBean.setTemplate(mobileTemplate) />
</cfif>
<cfreturn />
</cffunction>
<cffunction name="updateTheme" output="false" returntype="any">
<cfargument name="MuraScope" type="Any" required="true">
<!---<cflog log="MobileMura" type="information" text="MobileTheme: #getMobileMuraData(session.siteid).getMobileTheme()#" />--->
<cfif Len(getMobileMuraData(session.siteid).getMobileTheme())>
<!---<cflog log="MobileMura" type="information" text="entered cfif" />--->
<cfset MuraScope.event("altTheme",getMobileMuraData(session.siteid).getMobileTheme()) />
<cfif fileExists(expandPath(MuraScope.siteConfig('themeIncludePath')) & "/contentRenderer.cfc" )>
<cfset themeRenderer=createObject("component","#MuraScope.siteConfig('themeAssetMap')#.contentRenderer").init()>
<cfset themeRenderer.injectMethod("mura",MuraScope)>
<cfset themeRenderer.injectMethod("$",MuraScope)>
<cfset themeRenderer.injectMethod("event",MuraScope.event())>
<cfset MuraScope.event("themeRenderer",themeRenderer)>
</cfif>
<!---<cflog log="MobileMura" type="information" text="altTheme: #MuraScope.event('altTheme')#" />--->
</cfif>
<cfreturn />
</cffunction>
<cffunction name="getMobileMuraData" output="false" returntype="any">
<cfargument name="siteID" type="Any" required="true">
<cfset var myDataObject = createObject("component","mura.extend.extendObject").init(Type="Custom",SubType="MobileMuraData",SiteID=arguments.siteID)>
<cfset myDataObject.setID( siteID ) />
<cfreturn myDataObject />
</cffunction>
</cfcomponent>