|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
|
3
|
|
|
/** |
|
4
|
|
|
* @class editor |
|
5
|
|
|
* @author NAVER ([email protected]) |
|
6
|
|
|
* @brief high class of the editor odule |
|
7
|
|
|
*/ |
|
8
|
|
|
class editor extends ModuleObject |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @brief Implement if additional tasks are necessary when installing |
|
12
|
|
|
*/ |
|
13
|
|
|
function moduleInstall() |
|
14
|
|
|
{ |
|
15
|
|
|
// Register action forward (to use in administrator mode) |
|
16
|
|
|
$oModuleController = getController('module'); |
|
17
|
|
|
// Add the default editor component |
|
18
|
|
|
$oEditorController = getAdminController('editor'); |
|
19
|
|
|
$oEditorController->insertComponent('colorpicker_text',true); |
|
20
|
|
|
$oEditorController->insertComponent('colorpicker_bg',true); |
|
21
|
|
|
$oEditorController->insertComponent('emoticon',true); |
|
22
|
|
|
$oEditorController->insertComponent('url_link',true); |
|
23
|
|
|
$oEditorController->insertComponent('image_link',true); |
|
24
|
|
|
$oEditorController->insertComponent('multimedia_link',true); |
|
25
|
|
|
$oEditorController->insertComponent('quotation',true); |
|
26
|
|
|
$oEditorController->insertComponent('table_maker',true); |
|
27
|
|
|
$oEditorController->insertComponent('poll_maker',true); |
|
28
|
|
|
$oEditorController->insertComponent('image_gallery',true); |
|
29
|
|
|
// Create a directory to use in the editor module |
|
30
|
|
|
FileHandler::makeDir('./files/cache/editor'); |
|
31
|
|
|
// 2007. 10. 17 Add a trigger to delete automatically saved document whenever the document(insert or update) is modified |
|
32
|
|
|
$oModuleController->insertTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after'); |
|
33
|
|
|
$oModuleController->insertTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after'); |
|
34
|
|
|
// 2007. 10. 23 Add an editor trigger on the module addition setup |
|
35
|
|
|
$oModuleController->insertTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before'); |
|
36
|
|
|
// 2009. 04. 14 Add a trigger from compiled codes of the editor component |
|
37
|
|
|
$oModuleController->insertTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before'); |
|
38
|
|
|
|
|
39
|
|
|
return new BaseObject(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @brief a method to check if successfully installed |
|
44
|
|
|
*/ |
|
45
|
|
View Code Duplication |
function checkUpdate() |
|
|
|
|
|
|
46
|
|
|
{ |
|
47
|
|
|
$oDB = &DB::getInstance(); |
|
48
|
|
|
$oModuleModel = getModel('module'); |
|
49
|
|
|
$oModuleController = getController('module'); |
|
50
|
|
|
$version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
|
51
|
|
|
if($oModuleModel->needUpdate($version_update_id)) |
|
52
|
|
|
{ |
|
53
|
|
|
// 2009. 06. 15 Save module_srl when auto-saving |
|
54
|
|
|
if(!$oDB->isColumnExists("editor_autosave","module_srl")) return true; |
|
55
|
|
|
if(!$oDB->isIndexExists("editor_autosave","idx_module_srl")) return true; |
|
56
|
|
|
|
|
57
|
|
|
// 2007. 10. 17 Add a trigger to delete automatically saved document whenever the document(insert or update) is modified |
|
58
|
|
|
if(!$oModuleModel->getTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) return true; |
|
59
|
|
|
if(!$oModuleModel->getTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) return true; |
|
60
|
|
|
// 2007. 10. 23 Add an editor trigger on the module addition setup |
|
61
|
|
|
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before')) return true; |
|
62
|
|
|
// 2009. 04. 14 Add a trigger from compiled codes of the editor component |
|
63
|
|
|
if(!$oModuleModel->getTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before')) return true; |
|
64
|
|
|
// 2009. 06. 19 Remove unused trigger |
|
65
|
|
|
if($oModuleModel->getTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before')) return true; |
|
66
|
|
|
|
|
67
|
|
|
// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
|
68
|
|
|
if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'editor', 'controller', 'triggerCopyModule', 'after')) return true; |
|
69
|
|
|
|
|
70
|
|
|
if(!$oDB->isIndexExists('editor_autosave', 'certify_key')) return true; |
|
71
|
|
|
|
|
72
|
|
|
$oModuleController->insertUpdatedLog($version_update_id); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
return false; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @brief Execute update |
|
80
|
|
|
*/ |
|
81
|
|
|
function moduleUpdate() |
|
82
|
|
|
{ |
|
83
|
|
|
$oDB = &DB::getInstance(); |
|
84
|
|
|
$oModuleModel = getModel('module'); |
|
85
|
|
|
$oModuleController = getController('module'); |
|
86
|
|
|
$version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
|
87
|
|
|
if($oModuleModel->needUpdate($version_update_id)) |
|
88
|
|
|
{ |
|
89
|
|
|
// Save module_srl when auto-saving 15/06/2009 |
|
90
|
|
|
if(!$oDB->isColumnExists("editor_autosave","module_srl")) |
|
91
|
|
|
$oDB->addColumn("editor_autosave","module_srl","number",11); |
|
92
|
|
|
|
|
93
|
|
|
// create an index on module_srl |
|
94
|
|
|
if(!$oDB->isIndexExists("editor_autosave","idx_module_srl")) $oDB->addIndex("editor_autosave","idx_module_srl", "module_srl"); |
|
95
|
|
|
|
|
96
|
|
|
// 2007. 10. 17 Add a trigger to delete automatically saved document whenever the document(insert or update) is modified |
|
97
|
|
View Code Duplication |
if(!$oModuleModel->getTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) |
|
98
|
|
|
$oModuleController->insertTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after'); |
|
99
|
|
View Code Duplication |
if(!$oModuleModel->getTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) |
|
100
|
|
|
$oModuleController->insertTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after'); |
|
101
|
|
|
// 2007. 10. Add an editor trigger on the module addition setup |
|
102
|
|
|
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before')) |
|
103
|
|
|
$oModuleController->insertTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before'); |
|
104
|
|
|
// 2009. 04. 14 Add a trigger from compiled codes of the editor component |
|
105
|
|
|
if(!$oModuleModel->getTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before')) |
|
106
|
|
|
$oModuleController->insertTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before'); |
|
107
|
|
|
// 2009. 06. 19 Remove unused trigger |
|
108
|
|
|
if($oModuleModel->getTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before')) |
|
109
|
|
|
$oModuleController->deleteTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before'); |
|
110
|
|
|
|
|
111
|
|
|
// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
|
112
|
|
|
if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'editor', 'controller', 'triggerCopyModule', 'after')) |
|
113
|
|
|
{ |
|
114
|
|
|
$oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'editor', 'controller', 'triggerCopyModule', 'after'); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
if(!$oDB->isColumnExists('editor_autosave','certify_key')) |
|
118
|
|
|
{ |
|
119
|
|
|
$oDB->addColumn('editor_autosave', 'certify_key', 'varchar', 100); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
$oModuleController->insertUpdatedLog($version_update_id); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
return new BaseObject(0, 'success_updated'); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* @brief Re-generate the cache file |
|
130
|
|
|
*/ |
|
131
|
|
|
function recompileCache() |
|
132
|
|
|
{ |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
/* End of file editor.class.php */ |
|
136
|
|
|
/* Location: ./modules/editor/editor.class.php */ |
|
137
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.