forked from jmohler1970/BS-4-CF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.cfc
227 lines (133 loc) · 7 KB
/
application.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
component extends="framework.one" accessors="true" {
this.name="bs-4-cf-282";
this.applicationManagement = true;
this.sessionManagement = true;
variables.framework = {
home = "docs.home", // For PlumaCMS, change this to wiki.home or main.home aka login OR wiki.home
baseURL = 'useCGIScriptName',
defaultItem = "home",
generateSES = true,
SESomitIndex = false
};
variables.framework.routes = [
// PlumaCMS
{ "backups/delete/:id" = "backups/delete/slug/:id"},
{ "backups/edit/:id" = "backups/edit/slug/:id"},
{ "backups/restore/:id" = "backups/restore/slug/:id"},
{ "components" = "theme/components" },
{ "edit/:id" = "pages/edit/slug/:id" },
{ "edit" = "pages/edit" },
{ "filedelete" = "pages/delete" },
{ "logout" = "login/logout" },
{ "pages/home" = "pages/home" },
{ "wiki/:id" = "wiki/home/slug/:id" },
// documentation
{ "_bootstrap" = "302:/main/home" },
{ "common" = "docs/common" },
{ "theme" = "theme/home" },
{ "bootswatch/:id" = "bootswatch/home/bootswatch/:id" }
];
function setupApplication() {
application.initialized = now();
local.objAppFile = fileopen(expandpath('./Application.cfc'), 'read');
application.GSVERSION = "Version 3.3.5.#right(year(local.objAppFile.lastmodified), 2)#.#month(local.objAppFile.lastmodified)#.#day(local.objAppFile.lastmodified)#";
fileclose(objAppFile);
// Common variables and paths
application.GSAUTHOR = "James Mohler and Web World Inc";
application.GSSITE_FULL_NAME = "PlumaCMS";
application.GSSITE_LINK_BACK_URL = "https://github.com/jmohler1970";
application.GSROOTPATH = getdirectoryfrompath(getBaseTemplatePath());
application.GSBACKUPSPATH = application.GSROOTPATH & "backups/";
application.GSDATAPATH = application.GSROOTPATH & "data/";
application.GSDATAOTHERPATH = application.GSROOTPATH & "data/other/";
application.GSTHUMBNAILPATH = application.GSROOTPATH & "data/thumbs/";
application.GSDATAPAGESPATH = application.GSROOTPATH & "data/pages/";
application.GSDATAUPLOADPATH = application.GSROOTPATH & "data/uploads/";
application.GSUSERSPATH = application.GSROOTPATH & "data/users/";
// End Pluma
// Support for complicated variables. This used to have to be in FW/1
application.objFormUtilities = new framework.formUtilities();
application.Bootstrap = {
// Antisamy options
isSafeHTML = [ "cf_buttongroup", "cf_buttontoolbar", "cf_column", "cf_container", "cf_dropmenu",
"cf_fieldset", "cf_formgroup", "cf_head",
"cf_jumbotron", "cf_modal", "cf_navbar", "cf_navbarlinks", "cf_navlink",
"cf_panel", "cf_row", "cf_table", "cf_tabview", "cf_tr","cf_well"], // these tags to not run through getSafeHTML
profile = "", // blank means use system default
throwOnError = false, // Default behavior for getSafeHTML()
// Cacheing
cache = {content = "Bootstrap", language = "i18n" }, // Only Bootstrap should use this
// i18n options
langRoot = expandPath("vendor/lang") & "/",
arLang = [],
actionRoot = "http://" & cgi.server_name & (cgi.server_port == 80 ? "" : ":" & cgi.server_port) & cgi.script_name & "/",
validLook = ["", "link", "default", "primary", "success", "info", "warning", "danger"], // There does not guarantee they are valid
iconLibrary = {"default" = "glyphicon glyphicon-", "awesome" = "fa fa-", "jquery-ui" = "ui-icon ui-icon-"}, // be sure to include ending dashes
imageLibrary = {"default" = replace(cgi.script_name, "/index.cfm", "") & "/assets/"}, // used by b:graphicImage
// used by b:outputStyleSheet
styleSheetLibrary = {"default" = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css",
local = replace(cgi.script_name, "/index.cfm", "") & "/assets/",
innovation = replace(cgi.script_name, "/index.cfm", "") & "/layouts/innovation/",
vendor = replace(cgi.script_name, "/index.cfm", "") & "/vendor/"
},
// used by b:outputScript
scriptLibrary = {"default" = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js",
local = replace(cgi.script_name, "/index.cfm", "") & "/assets/",
vendor = replace(cgi.script_name, "/index.cfm", "") & "/vendor/"
}
};
application.GSConfig = new model.services.settings().getWebsite();
application.geti18n = function(required string key, any placeholder = []) output="false" {
if (!isArray(arguments.placeholder)) arguments.placeholder = [arguments.placeholder];
if (CacheIdExists(application.lang, application.Bootstrap.cache.language)) {
local.stLang = cacheGet(application.lang, application.Bootstrap.cache.language);
if (local.stLang.keyExists(arguments.key)) {
local.myString = local.stLang[arguments.key];
for (var i in arguments.placeholder) {
local.myString = local.myString.replace('%s', i); // only does first match
}
return getSafeHTML(local.myString);
} // end keyExists
} // end cacheIdExists
return "{#arguments.key#}";
}; // end function
// Language control
application.lang = "en_US"; // needs to be smarter
} // end setupApplication
function setupSession() {
session.authenticated = false;
session.bootswatch = "default";
}
function setupRequest() {
if(application.Bootstrap.arLang.isEmpty()) {
for(local.langFile in DirectoryList(application.Bootstrap.langRoot, false, "path", "*.php")) {
application.Bootstrap.arLang.append(local.langFile.listLast("/").listFirst("."));
}
}
if(!cacheRegionExists(application.Bootstrap.cache.content)) CacheRegionNew(application.Bootstrap.cache.content);
if(!cacheRegionExists(application.Bootstrap.cache.language)) CacheRegionNew(application.Bootstrap.cache.language);
if(cacheGetAllIds(application.Bootstrap.cache.language).isEmpty()) {
// load i18n
local.languageService = new model.services.language();
local.i18n = {};
local.i18n.append( local.languageService.readPHP(application.Bootstrap.langroot) ); // traditional language file
// simple append won't work
local.stTitle = local.languageService.readProperties( expandPath(".") & "/title.properties" );
for (local.languageKey in local.stTitle) {
local.i18n[local.languageKey].append( local.stTitle[local.languageKey] ); // titles are here
}
for (local.languageKey in local.i18n) {
CachePut(local.languageKey, local.i18n[local.languageKey], 1, 1, application.Bootstrap.cache.language);
}
}
} // end setupRequest
function after() {
if ( isDefined('form') ) rc.Append(application.objFormUtilities.buildFormCollections(form));
if(rc.keyExists("lang")) {
application.lang = rc.lang;
}
if(rc.keyExists("bootswatch") and rc.bootswatch != "assets") {
session.bootswatch = rc.bootswatch;
}
}
}