-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleConfig.cfc
More file actions
150 lines (127 loc) · 4.94 KB
/
Copy pathModuleConfig.cfc
File metadata and controls
150 lines (127 loc) · 4.94 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
/**
* ContentBox - A Modular Content Platform
* Copyright since 2012 by Ortus Solutions, Corp
* www.ortussolutions.com/products/contentbox
* ---
* This module enhances ckeditor to allow them to use code mirror for its source editing
**/
component {
// Module Properties
this.title = "CKWordCount";
this.author = "Aktigo Internet and Media Applications GmbH";
this.webURL = "http://www.akitogo.com";
this.description = "Adds WordCount support to CKEditor";
this.version = "1.0.0";
// 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 = "CKWordCount";
function configure(){
// Compressor Settings
settings = {
showParagraphs = true,
showWordCount = true,
showCharCount = true,
maxWordCount = 7000,
maxCharCount = 70000
};
// SES Routes
routes = [
// Module Entry Point
{pattern="/", handler="home",action="index"},
// Convention Route
{pattern="/:handler/:action?"}
];
// Interceptors
interceptors = [
];
// map objects
binder.map( "fileUtils@CKWordCount" ).to( "coldbox.system.core.util.FileUtils" );
}
/**
* CKEditor Plugin Integrations
*/
function cbadmin_ckeditorExtraPlugins( event, interceptData ){
arrayAppend( arguments.interceptData.extraPlugins, "wordcount" );
}
/**
* CKEditor Config Integration
*/
function cbadmin_ckeditorExtraConfig( event, interceptData ){
var settingService = wirebox.getInstance("SettingService@cb");
var args = { name="cbox-CKWordCount" };
var allSettings = deserializeJSON( settingService.findWhere( criteria=args ).getValue() );
var extraConfigExists = "";
if( len(arguments.interceptData.extraConfig) ){
extraConfigExists = ",";
}
arguments.interceptData.extraConfig &= "#extraConfigExists# wordcount : { 'maxWordCount': #allSettings.maxWordCount#, 'maxCharCount': #allSettings.maxCharCount#, 'showParagraphs': #allSettings.showParagraphs#, 'showWordCount': #allSettings.showWordCount#, 'showCharCount': #allSettings.showCharCount#}";
}
/**
* Fired when the module is registered and activated.
*/
function onLoad(){
// Let's add ourselves to the main menu in the Modules section
var menuService = wirebox.getInstance( "AdminMenuService@cb" );
// Add Menu Contribution
menuService.addSubMenu(
topMenu = menuService.MODULES,
name = "CKWordCount",
label = "CK Word Count",
href = "#menuService.buildModuleLink( 'CKWordCount', 'home.settings' )#"
);
// Override settings?
var settingService = wirebox.getInstance( "SettingService@cb" );
var args = { name="cbox-CKWordCount" };
var setting = settingService.findWhere( criteria=args );
if( !isNull( setting ) ){
// override settings from contentbox custom setting
controller.getSetting( "modules" ).CKWordCount.settings = deserializeJSON( setting.getvalue() );
}
}
/**
* Fired when the module is activated
*/
function onActivate(){
var settingService = wirebox.getInstance( "SettingService@cb" );
// store default settings
var findArgs = { name="cbox-CKWordCount" };
var setting = settingService.findWhere( criteria=findArgs );
if( isNull( setting ) ){
var args = { name="cbox-CKWordCount", value=serializeJSON( settings ) };
var wordCountSettings = settingService.new( properties=args );
settingService.save( wordCountSettings );
}
// Install the ckeditor plugin
var ckeditorPluginsPath = controller.getSetting( "modules" )[ "contentbox-admin" ].path & "/modules/contentbox-ckeditor/includes/ckeditor/plugins/wordcount";
var fileUtils = wirebox.getInstance( "fileUtils@CKWordCount" );
var pluginPath = controller.getSetting( "modules" )[ "CKWordCount" ].path & "/includes/wordcount";
fileUtils.directoryCopy( source=pluginPath, destination=ckeditorPluginsPath );
}
/**
* Fired when the module is unregistered and unloaded
*/
function onUnload(){
// Let's remove ourselves to the main menu in the Modules section
var menuService = wirebox.getInstance( "AdminMenuService@cb" );
// Remove Menu Contribution
menuService.removeSubMenu( topMenu=menuService.MODULES, name="CKWordCount" );
}
/**
* Fired when the module is deactivated by ContentBox Only
*/
function onDeactivate(){
var settingService = wirebox.getInstance( "SettingService@cb" );
var args = { name="cbox-CKWordCount" };
var setting = settingService.findWhere( criteria=args );
if( !isNull( setting ) ){
settingService.delete( setting );
}
// Uninstall the ckeditor plugin
var ckeditorPluginsPath = controller.getSetting( "modules" )[ "contentbox-admin" ].path & "/modules/contentbox-ckeditor/includes/ckeditor/plugins/wordcount";
var fileUtils = wirebox.getInstance( "fileUtils@CKWordCount" );
fileUtils.directoryRemove( path=ckeditorPluginsPath, recurse=true );
}
}