-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModuleConfig.cfc
More file actions
166 lines (138 loc) · 5.77 KB
/
ModuleConfig.cfc
File metadata and controls
166 lines (138 loc) · 5.77 KB
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
/**
********************************************************************************
Copyright 2017 Computer Know How, LLC, www.compknowhow.com
********************************************************************************
Author: Seth Engen
Description: This module adds icon font support to the CKEditor window.
********************************************************************************
**/
component {
// Module Properties
this.title = "CKIconFont";
this.author = "Computer Know How, LLC";
this.webURL = "http://www.compknowhow.com";
this.description = "Adds icon font support to CKEditor 4 in ContentBox";
this.version = "1.1";
// If true, looks for views in the parent first, if not found, then in the module. Else vice-versa
this.viewParentLookup = true;
// If true, looks for layouts in the parent first, if not found, then in module. Else vice-versa
this.layoutParentLookup = true;
// Module Entry Point
this.entryPoint = "ckiconfont";
function configure(){
// Settings
settings = {
version = "1",
stylesheet = "//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css",
label = 'fa'
};
// SES Routes
routes = [
// Module Entry Point
{pattern="/", handler="home",action="index"},
// Convention Route
{pattern="/:handler/:action?"}
];
// Map objects
binder.map("fileUtils@ckiconfont").to("coldbox.system.core.util.FileUtils");
}
/**
* CKEditor Plugin Integrations
*/
function cbadmin_ckeditorExtraPlugins(event, interceptData){
// Add the 'iconfont' plugin to the CKEditors extra plugins (note: will not show in settings)
arrayAppend( arguments.interceptData.extraPlugins, "iconfont" );
}
/**
* CKEditor Toolbar Integrations
*/
function cbadmin_ckeditorToolbar(event, interceptData){
// Get the location of the CKEditor 'styles' toolbar section
var dimensionNumber = 0;
for (i=1; i LTE arrayLen(arguments.interceptData.toolbar); i++) {
if (isStruct(arguments.interceptData.toolbar[i]) AND structFind(arguments.interceptData.toolbar[i],'name') IS 'styles') {
dimensionNumber = i;
}
}
// Add our 'IconFont' button to the toolbar (with a space)
arrayAppend( arguments.interceptData.toolbar[dimensionNumber].items, "-" );
arrayAppend( arguments.interceptData.toolbar[dimensionNumber].items, "IconFont" );
}
/**
* CKEditor Config Integration
*/
function cbadmin_ckeditorExtraConfig(event, interceptData){
var settingService = controller.getWireBox().getInstance("SettingService@cb");
// Get the IconFont settings
var args = {name="cbox-ckiconfont"};
var settings = deserializeJSON( settingService.findWhere(criteria=args).getValue() );
// Add the settings to the CKEditor extra config
arguments.interceptData.extraConfig &= "iconfont_stylesheet : '" & settings.stylesheet & "'";
arguments.interceptData.extraConfig &= ", iconfont_label : '" & settings.label & "'";
}
/**
* CKEditor Contents CSS
*/
function cbadmin_ckeditorContentsCss(event, interceptData){
var settingService = controller.getWireBox().getInstance("SettingService@cb");
// Get the IconFont settings
var args = {name="cbox-ckiconfont"};
var settings = deserializeJSON( settingService.findWhere(criteria=args).getValue() );
arrayAppend(arguments.interceptData.contentsCss, settings.stylesheet);
}
/**
* Fired when the module is registered and activated.
*/
function onLoad(){
var menuService = controller.getWireBox().getInstance("AdminMenuService@cb");
// Add a 'CK Icon Fonts' contribution to the modules menu
menuService.addSubMenu(topMenu=menuService.MODULES,name="CKIconFont",label="CK Icon Fonts",href="#menuService.buildModuleLink('ckiconfont','home.settings')#");
}
/**
* Fired when the module is activated
*/
function onActivate(){
var settingService = controller.getWireBox().getInstance("SettingService@cb");
// Store default settings
var findArgs = {name="cbox-ckiconfont"};
var setting = settingService.findWhere(criteria=findArgs);
if( isNull(setting) ){
var args = {name="cbox-ckiconfont", value=serializeJSON( settings )};
var ckIconFontSettings = settingService.new(properties=args);
settingService.save( ckIconFontSettings );
}
// Flush the settings cache so our new settings are reflected
settingService.flushSettingsCache();
// Install the ckeditor plugin
var ckeditorPluginsPath = controller.getSetting("modules")["contentbox-admin"].path & "/modules/contentbox-ckeditor/includes/ckeditor/plugins/iconfont";
var fileUtils = controller.getWireBox().getInstance("fileUtils@ckiconfont");
var pluginPath = controller.getSetting("modules")["ckiconfont"].path & "/includes/iconfont";
fileUtils.directoryCopy(source=pluginPath, destination=ckeditorPluginsPath);
}
/**
* Fired when the module is unregistered and unloaded
*/
function onUnload(){
var menuService = controller.getWireBox().getInstance("AdminMenuService@cb");
// Remove the 'CK Icon Fonts' contribution from the modules menu
menuService.removeSubMenu(topMenu=menuService.MODULES,name="CKIconFont");
}
/**
* Fired when the module is deactivated by ContentBox Only
*/
function onDeactivate(){
var settingService = controller.getWireBox().getInstance("SettingService@cb");
// Remove the settings
var args = {name="cbox-ckiconfont"};
var setting = settingService.findWhere(criteria=args);
if( !isNull(setting) ){
settingService.delete( setting );
}
// Flush the settings cache so our new settings are reflected
settingService.flushSettingsCache();
// Uninstall the ckeditor plugin
var ckeditorPluginsPath = controller.getSetting("modules")["contentbox-admin"].path & "/modules/contentbox-ckeditor/includes/ckeditor/plugins/iconfont";
var fileUtils = controller.getWireBox().getInstance("fileUtils@ckiconfont");
fileUtils.directoryRemove(path=ckeditorPluginsPath, recurse=true);
}
}