@@ -16,16 +16,16 @@ discard block |
||
16 | 16 | $oModuleController = getController('module'); |
17 | 17 | // Add the default editor component |
18 | 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); |
|
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 | 29 | // Create a directory to use in the editor module |
30 | 30 | FileHandler::makeDir('./files/cache/editor'); |
31 | 31 | // 2007. 10. 17 Add a trigger to delete automatically saved document whenever the document(insert or update) is modified |
@@ -48,27 +48,27 @@ discard block |
||
48 | 48 | $oModuleModel = getModel('module'); |
49 | 49 | $oModuleController = getController('module'); |
50 | 50 | $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
51 | - if($oModuleModel->needUpdate($version_update_id)) |
|
51 | + if ($oModuleModel->needUpdate($version_update_id)) |
|
52 | 52 | { |
53 | 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; |
|
54 | + if (!$oDB->isColumnExists("editor_autosave", "module_srl")) return true; |
|
55 | + if (!$oDB->isIndexExists("editor_autosave", "idx_module_srl")) return true; |
|
56 | 56 | |
57 | 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; |
|
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 | 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; |
|
61 | + if (!$oModuleModel->getTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before')) return true; |
|
62 | 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; |
|
63 | + if (!$oModuleModel->getTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before')) return true; |
|
64 | 64 | // 2009. 06. 19 Remove unused trigger |
65 | - if($oModuleModel->getTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before')) return true; |
|
65 | + if ($oModuleModel->getTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before')) return true; |
|
66 | 66 | |
67 | 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; |
|
68 | + if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'editor', 'controller', 'triggerCopyModule', 'after')) return true; |
|
69 | 69 | |
70 | - if(!$oDB->isColumnExists("editor_autosave", "certify_key")) return true; |
|
71 | - if(!$oDB->isIndexExists('editor_autosave', 'idx_certify_key')) return true; |
|
70 | + if (!$oDB->isColumnExists("editor_autosave", "certify_key")) return true; |
|
71 | + if (!$oDB->isIndexExists('editor_autosave', 'idx_certify_key')) return true; |
|
72 | 72 | |
73 | 73 | $oModuleController->insertUpdatedLog($version_update_id); |
74 | 74 | } |
@@ -85,42 +85,42 @@ discard block |
||
85 | 85 | $oModuleModel = getModel('module'); |
86 | 86 | $oModuleController = getController('module'); |
87 | 87 | $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
88 | - if($oModuleModel->needUpdate($version_update_id)) |
|
88 | + if ($oModuleModel->needUpdate($version_update_id)) |
|
89 | 89 | { |
90 | 90 | // Save module_srl when auto-saving 15/06/2009 |
91 | - if(!$oDB->isColumnExists("editor_autosave","module_srl")) |
|
92 | - $oDB->addColumn("editor_autosave","module_srl","number",11); |
|
91 | + if (!$oDB->isColumnExists("editor_autosave", "module_srl")) |
|
92 | + $oDB->addColumn("editor_autosave", "module_srl", "number", 11); |
|
93 | 93 | |
94 | 94 | // create an index on module_srl |
95 | - if(!$oDB->isIndexExists("editor_autosave","idx_module_srl")) $oDB->addIndex("editor_autosave","idx_module_srl", "module_srl"); |
|
95 | + if (!$oDB->isIndexExists("editor_autosave", "idx_module_srl")) $oDB->addIndex("editor_autosave", "idx_module_srl", "module_srl"); |
|
96 | 96 | |
97 | 97 | // 2007. 10. 17 Add a trigger to delete automatically saved document whenever the document(insert or update) is modified |
98 | - if(!$oModuleModel->getTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) |
|
98 | + if (!$oModuleModel->getTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) |
|
99 | 99 | $oModuleController->insertTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after'); |
100 | - if(!$oModuleModel->getTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) |
|
100 | + if (!$oModuleModel->getTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) |
|
101 | 101 | $oModuleController->insertTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after'); |
102 | 102 | // 2007. 10. Add an editor trigger on the module addition setup |
103 | - if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before')) |
|
103 | + if (!$oModuleModel->getTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before')) |
|
104 | 104 | $oModuleController->insertTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before'); |
105 | 105 | // 2009. 04. 14 Add a trigger from compiled codes of the editor component |
106 | - if(!$oModuleModel->getTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before')) |
|
106 | + if (!$oModuleModel->getTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before')) |
|
107 | 107 | $oModuleController->insertTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before'); |
108 | 108 | // 2009. 06. 19 Remove unused trigger |
109 | - if($oModuleModel->getTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before')) |
|
109 | + if ($oModuleModel->getTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before')) |
|
110 | 110 | $oModuleController->deleteTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before'); |
111 | 111 | |
112 | 112 | // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
113 | - if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'editor', 'controller', 'triggerCopyModule', 'after')) |
|
113 | + if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'editor', 'controller', 'triggerCopyModule', 'after')) |
|
114 | 114 | { |
115 | 115 | $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'editor', 'controller', 'triggerCopyModule', 'after'); |
116 | 116 | } |
117 | 117 | |
118 | 118 | // @see https://github.com/xpressengine/xe-core/issues/2229 |
119 | - if(!$oDB->isColumnExists('editor_autosave','certify_key')) |
|
119 | + if (!$oDB->isColumnExists('editor_autosave', 'certify_key')) |
|
120 | 120 | { |
121 | 121 | $oDB->addColumn('editor_autosave', 'certify_key', 'varchar', 100); |
122 | 122 | } |
123 | - if(!$oDB->isIndexExists("editor_autosave","idx_certify_key")) |
|
123 | + if (!$oDB->isIndexExists("editor_autosave", "idx_certify_key")) |
|
124 | 124 | { |
125 | 125 | $oDB->addIndex("editor_autosave", "certify_key"); |
126 | 126 | } |
@@ -51,24 +51,44 @@ discard block |
||
51 | 51 | if($oModuleModel->needUpdate($version_update_id)) |
52 | 52 | { |
53 | 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; |
|
54 | + if(!$oDB->isColumnExists("editor_autosave","module_srl")) { |
|
55 | + return true; |
|
56 | + } |
|
57 | + if(!$oDB->isIndexExists("editor_autosave","idx_module_srl")) { |
|
58 | + return true; |
|
59 | + } |
|
56 | 60 | |
57 | 61 | // 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; |
|
62 | + if(!$oModuleModel->getTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) { |
|
63 | + return true; |
|
64 | + } |
|
65 | + if(!$oModuleModel->getTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) { |
|
66 | + return true; |
|
67 | + } |
|
60 | 68 | // 2007. 10. 23 Add an editor trigger on the module addition setup |
61 | - if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before')) return true; |
|
69 | + if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before')) { |
|
70 | + return true; |
|
71 | + } |
|
62 | 72 | // 2009. 04. 14 Add a trigger from compiled codes of the editor component |
63 | - if(!$oModuleModel->getTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before')) return true; |
|
73 | + if(!$oModuleModel->getTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before')) { |
|
74 | + return true; |
|
75 | + } |
|
64 | 76 | // 2009. 06. 19 Remove unused trigger |
65 | - if($oModuleModel->getTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before')) return true; |
|
77 | + if($oModuleModel->getTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before')) { |
|
78 | + return true; |
|
79 | + } |
|
66 | 80 | |
67 | 81 | // 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; |
|
82 | + if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'editor', 'controller', 'triggerCopyModule', 'after')) { |
|
83 | + return true; |
|
84 | + } |
|
69 | 85 | |
70 | - if(!$oDB->isColumnExists("editor_autosave", "certify_key")) return true; |
|
71 | - if(!$oDB->isIndexExists('editor_autosave', 'idx_certify_key')) return true; |
|
86 | + if(!$oDB->isColumnExists("editor_autosave", "certify_key")) { |
|
87 | + return true; |
|
88 | + } |
|
89 | + if(!$oDB->isIndexExists('editor_autosave', 'idx_certify_key')) { |
|
90 | + return true; |
|
91 | + } |
|
72 | 92 | |
73 | 93 | $oModuleController->insertUpdatedLog($version_update_id); |
74 | 94 | } |
@@ -88,26 +108,34 @@ discard block |
||
88 | 108 | if($oModuleModel->needUpdate($version_update_id)) |
89 | 109 | { |
90 | 110 | // Save module_srl when auto-saving 15/06/2009 |
91 | - if(!$oDB->isColumnExists("editor_autosave","module_srl")) |
|
92 | - $oDB->addColumn("editor_autosave","module_srl","number",11); |
|
111 | + if(!$oDB->isColumnExists("editor_autosave","module_srl")) { |
|
112 | + $oDB->addColumn("editor_autosave","module_srl","number",11); |
|
113 | + } |
|
93 | 114 | |
94 | 115 | // create an index on module_srl |
95 | - if(!$oDB->isIndexExists("editor_autosave","idx_module_srl")) $oDB->addIndex("editor_autosave","idx_module_srl", "module_srl"); |
|
116 | + if(!$oDB->isIndexExists("editor_autosave","idx_module_srl")) { |
|
117 | + $oDB->addIndex("editor_autosave","idx_module_srl", "module_srl"); |
|
118 | + } |
|
96 | 119 | |
97 | 120 | // 2007. 10. 17 Add a trigger to delete automatically saved document whenever the document(insert or update) is modified |
98 | - if(!$oModuleModel->getTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) |
|
99 | - $oModuleController->insertTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after'); |
|
100 | - if(!$oModuleModel->getTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) |
|
101 | - $oModuleController->insertTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after'); |
|
121 | + if(!$oModuleModel->getTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) { |
|
122 | + $oModuleController->insertTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after'); |
|
123 | + } |
|
124 | + if(!$oModuleModel->getTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) { |
|
125 | + $oModuleController->insertTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after'); |
|
126 | + } |
|
102 | 127 | // 2007. 10. Add an editor trigger on the module addition setup |
103 | - if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before')) |
|
104 | - $oModuleController->insertTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before'); |
|
128 | + if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before')) { |
|
129 | + $oModuleController->insertTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before'); |
|
130 | + } |
|
105 | 131 | // 2009. 04. 14 Add a trigger from compiled codes of the editor component |
106 | - if(!$oModuleModel->getTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before')) |
|
107 | - $oModuleController->insertTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before'); |
|
132 | + if(!$oModuleModel->getTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before')) { |
|
133 | + $oModuleController->insertTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before'); |
|
134 | + } |
|
108 | 135 | // 2009. 06. 19 Remove unused trigger |
109 | - if($oModuleModel->getTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before')) |
|
110 | - $oModuleController->deleteTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before'); |
|
136 | + if($oModuleModel->getTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before')) { |
|
137 | + $oModuleController->deleteTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before'); |
|
138 | + } |
|
111 | 139 | |
112 | 140 | // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
113 | 141 | if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'editor', 'controller', 'triggerCopyModule', 'after')) |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function getEditorConfig($module_srl = null) |
25 | 25 | { |
26 | - if(!$GLOBALS['__editor_module_config__'][$module_srl] && $module_srl) |
|
26 | + if (!$GLOBALS['__editor_module_config__'][$module_srl] && $module_srl) |
|
27 | 27 | { |
28 | 28 | // Get trackback settings of the selected module |
29 | 29 | $oModuleModel = getModel('module'); |
@@ -34,55 +34,55 @@ discard block |
||
34 | 34 | $oModuleModel = getModel('module'); |
35 | 35 | $editor_default_config = $oModuleModel->getModuleConfig('editor'); |
36 | 36 | |
37 | - if(!is_object($editor_config)) $editor_config = new stdClass(); |
|
37 | + if (!is_object($editor_config)) $editor_config = new stdClass(); |
|
38 | 38 | |
39 | - if($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
40 | - if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
41 | - if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
42 | - if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
43 | - if(!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
44 | - if(!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
45 | - if(!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
46 | - if(!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
47 | - if(!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant= array(); |
|
39 | + if ($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
40 | + if (!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
41 | + if (!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
42 | + if (!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
43 | + if (!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
44 | + if (!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
45 | + if (!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
46 | + if (!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
47 | + if (!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant = array(); |
|
48 | 48 | |
49 | - if(!$editor_config->editor_height) |
|
49 | + if (!$editor_config->editor_height) |
|
50 | 50 | { |
51 | 51 | $editor_config->editor_height = ($editor_default_config->editor_height) ? $editor_default_config->editor_height : 500; |
52 | 52 | } |
53 | - if(!$editor_config->comment_editor_height) |
|
53 | + if (!$editor_config->comment_editor_height) |
|
54 | 54 | { |
55 | 55 | $editor_config->comment_editor_height = ($editor_default_config->comment_editor_height) ? $editor_default_config->comment_editor_height : 120; |
56 | 56 | } |
57 | - if(!$editor_config->editor_skin) |
|
57 | + if (!$editor_config->editor_skin) |
|
58 | 58 | { |
59 | 59 | $editor_config->editor_skin = ($editor_default_config->editor_skin) ? $editor_default_config->editor_skin : 'ckeditor'; |
60 | 60 | } |
61 | - if(!$editor_config->comment_editor_skin) |
|
61 | + if (!$editor_config->comment_editor_skin) |
|
62 | 62 | { |
63 | 63 | $editor_config->comment_editor_skin = ($editor_default_config->comment_editor_skin) ? $editor_default_config->comment_editor_skin : 'ckeditor'; |
64 | 64 | } |
65 | - if(!$editor_config->content_style) |
|
65 | + if (!$editor_config->content_style) |
|
66 | 66 | { |
67 | 67 | $editor_config->content_style = ($editor_default_config->content_style) ? $editor_default_config->content_style : 'ckeditor_light'; |
68 | 68 | } |
69 | - if(!$editor_config->content_font && $editor_default_config->content_font) |
|
69 | + if (!$editor_config->content_font && $editor_default_config->content_font) |
|
70 | 70 | { |
71 | 71 | $editor_config->content_font = $editor_default_config->content_font; |
72 | 72 | } |
73 | - if(!$editor_config->content_font_size && $editor_default_config->content_font_size) |
|
73 | + if (!$editor_config->content_font_size && $editor_default_config->content_font_size) |
|
74 | 74 | { |
75 | 75 | $editor_config->content_font_size = $editor_default_config->content_font_size; |
76 | 76 | } |
77 | - if(!$editor_config->sel_editor_colorset && $editor_default_config->sel_editor_colorset) |
|
77 | + if (!$editor_config->sel_editor_colorset && $editor_default_config->sel_editor_colorset) |
|
78 | 78 | { |
79 | 79 | $editor_config->sel_editor_colorset = $editor_default_config->sel_editor_colorset; |
80 | 80 | } |
81 | - if(!$editor_config->sel_comment_editor_colorset && $editor_default_config->sel_comment_editor_colorset) |
|
81 | + if (!$editor_config->sel_comment_editor_colorset && $editor_default_config->sel_comment_editor_colorset) |
|
82 | 82 | { |
83 | 83 | $editor_config->sel_comment_editor_colorset = $editor_default_config->sel_comment_editor_colorset; |
84 | 84 | } |
85 | - if(!$editor_config->comment_content_style && $editor_default_config->comment_content_style) |
|
85 | + if (!$editor_config->comment_content_style && $editor_default_config->comment_content_style) |
|
86 | 86 | { |
87 | 87 | $editor_config->comment_content_style = $editor_default_config->comment_content_style; |
88 | 88 | } |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | |
93 | 93 | function loadDrComponents() |
94 | 94 | { |
95 | - $drComponentPath = _XE_PATH_ . 'modules/editor/skins/dreditor/drcomponents/'; |
|
95 | + $drComponentPath = _XE_PATH_.'modules/editor/skins/dreditor/drcomponents/'; |
|
96 | 96 | $drComponentList = FileHandler::readDir($drComponentPath); |
97 | 97 | |
98 | 98 | $oTemplate = &TemplateHandler::getInstance(); |
99 | 99 | |
100 | 100 | $drComponentInfo = array(); |
101 | - if($drComponentList) |
|
101 | + if ($drComponentList) |
|
102 | 102 | { |
103 | - foreach($drComponentList as $i => $drComponent) |
|
103 | + foreach ($drComponentList as $i => $drComponent) |
|
104 | 104 | { |
105 | 105 | unset($obj); |
106 | 106 | $obj = $this->getDrComponentXmlInfo($drComponent); |
107 | - Context::loadLang(sprintf('%s%s/lang/',$drComponentPath,$drComponent)); |
|
108 | - $path = sprintf('%s%s/tpl/',$drComponentPath,$drComponent); |
|
109 | - $obj->html = $oTemplate->compile($path,$drComponent); |
|
107 | + Context::loadLang(sprintf('%s%s/lang/', $drComponentPath, $drComponent)); |
|
108 | + $path = sprintf('%s%s/tpl/', $drComponentPath, $drComponent); |
|
109 | + $obj->html = $oTemplate->compile($path, $drComponent); |
|
110 | 110 | $drComponentInfo[$drComponent] = $obj; |
111 | 111 | } |
112 | 112 | } |
113 | - Context::set('drComponentList',$drComponentInfo); |
|
113 | + Context::set('drComponentList', $drComponentInfo); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | function getDrComponentXmlInfo($drComponentName) |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $xml_file = sprintf('%sinfo.xml', $component_path); |
123 | 123 | $cache_file = sprintf('./files/cache/editor/dr_%s.%s.php', $drComponentName, $lang_type); |
124 | 124 | // Return information after including it after cached xml file exists |
125 | - if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
125 | + if (file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
126 | 126 | { |
127 | 127 | include($cache_file); |
128 | 128 | return $xml_info; |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | $buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link); |
152 | 152 | |
153 | 153 | // Author information |
154 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
154 | + if (!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
155 | 155 | else $author_list = $xml_doc->component->author; |
156 | 156 | |
157 | - for($i=0; $i < count($author_list); $i++) |
|
157 | + for ($i = 0; $i < count($author_list); $i++) |
|
158 | 158 | { |
159 | 159 | $buff .= sprintf('$xml_info->author['.$i.']->name = "%s";', $author_list[$i]->name->body); |
160 | 160 | $buff .= sprintf('$xml_info->author['.$i.']->email_address = "%s";', $author_list[$i]->attrs->email_address); |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | |
164 | 164 | // List extra variables (text type only in the editor component) |
165 | 165 | $extra_vars = $xml_doc->component->extra_vars->var; |
166 | - if($extra_vars) |
|
166 | + if ($extra_vars) |
|
167 | 167 | { |
168 | - if(!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
169 | - foreach($extra_vars as $key => $val) |
|
168 | + if (!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
169 | + foreach ($extra_vars as $key => $val) |
|
170 | 170 | { |
171 | 171 | unset($obj); |
172 | 172 | $key = $val->attrs->name; |
@@ -198,47 +198,47 @@ discard block |
||
198 | 198 | * Editor's default options |
199 | 199 | */ |
200 | 200 | // Option setting to allow file upload |
201 | - if($upload_target_srl) |
|
201 | + if ($upload_target_srl) |
|
202 | 202 | { |
203 | 203 | $option->editor_sequence = $upload_target_srl; |
204 | 204 | } |
205 | - if(!$option->allow_fileupload) $allow_fileupload = false; |
|
205 | + if (!$option->allow_fileupload) $allow_fileupload = false; |
|
206 | 206 | else $allow_fileupload = true; |
207 | 207 | // content_style setting |
208 | - if(!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
208 | + if (!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
209 | 209 | Context::set('content_style', $option->content_style); |
210 | - Context::set('content_style_path', getScriptPath() . ltrim($this->module_path, './') . 'styles/' . $option->content_style); |
|
210 | + Context::set('content_style_path', getScriptPath().ltrim($this->module_path, './').'styles/'.$option->content_style); |
|
211 | 211 | // Default font setting |
212 | 212 | Context::set('content_font', addslashes($option->content_font)); |
213 | 213 | Context::set('content_font_size', $option->content_font_size); |
214 | 214 | |
215 | 215 | // Option setting to allow auto-save |
216 | - if(!$option->enable_autosave) $enable_autosave = false; |
|
217 | - elseif(Context::get($option->primary_key_name)) $enable_autosave = false; |
|
216 | + if (!$option->enable_autosave) $enable_autosave = false; |
|
217 | + elseif (Context::get($option->primary_key_name)) $enable_autosave = false; |
|
218 | 218 | else $enable_autosave = true; |
219 | 219 | // Option setting to allow the default editor component |
220 | - if(!$option->enable_default_component) $enable_default_component = false; |
|
220 | + if (!$option->enable_default_component) $enable_default_component = false; |
|
221 | 221 | else $enable_default_component = true; |
222 | 222 | // Option setting to allow other extended components |
223 | - if(!$option->enable_component) $enable_component = false; |
|
223 | + if (!$option->enable_component) $enable_component = false; |
|
224 | 224 | else $enable_component = true; |
225 | 225 | // Setting for html-mode |
226 | - if($option->disable_html) $html_mode = false; |
|
226 | + if ($option->disable_html) $html_mode = false; |
|
227 | 227 | else $html_mode = true; |
228 | 228 | // Set Height |
229 | - if(!$option->height) $editor_height = 300; |
|
229 | + if (!$option->height) $editor_height = 300; |
|
230 | 230 | else $editor_height = $option->height; |
231 | 231 | // Skin Setting |
232 | 232 | $skin = $option->skin; |
233 | - if(!$skin) $skin = 'ckeditor'; |
|
233 | + if (!$skin) $skin = 'ckeditor'; |
|
234 | 234 | |
235 | 235 | $colorset = $option->colorset; |
236 | - if(!$colorset) $colorset = 'moono'; |
|
236 | + if (!$colorset) $colorset = 'moono'; |
|
237 | 237 | Context::set('colorset', $colorset); |
238 | 238 | Context::set('skin', $skin); |
239 | 239 | Context::set('module_type', $option->module_type); |
240 | 240 | |
241 | - if($skin=='dreditor') |
|
241 | + if ($skin == 'dreditor') |
|
242 | 242 | { |
243 | 243 | $this->loadDrComponents(); |
244 | 244 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | /** |
247 | 247 | * Check the automatic backup feature (do not use if the post is edited) |
248 | 248 | */ |
249 | - if($enable_autosave) |
|
249 | + if ($enable_autosave) |
|
250 | 250 | { |
251 | 251 | // Extract auto-saved data |
252 | 252 | $saved_doc = $this->getSavedDoc($upload_target_srl); |
@@ -258,26 +258,26 @@ discard block |
||
258 | 258 | /** |
259 | 259 | * Extract editor's unique number (in order to display multiple editors on a single page) |
260 | 260 | */ |
261 | - if($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
261 | + if ($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
262 | 262 | else |
263 | 263 | { |
264 | - if(!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
265 | - $editor_sequence = $_SESSION['_editor_sequence_'] ++; |
|
264 | + if (!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
265 | + $editor_sequence = $_SESSION['_editor_sequence_']++; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Upload setting by using configuration of the file module internally |
270 | 270 | */ |
271 | 271 | $files_count = 0; |
272 | - if($allow_fileupload) |
|
272 | + if ($allow_fileupload) |
|
273 | 273 | { |
274 | 274 | $oFileModel = getModel('file'); |
275 | 275 | // Get upload configuration to set on SWFUploader |
276 | 276 | $file_config = $oFileModel->getUploadConfig(); |
277 | - $file_config->allowed_attach_size = $file_config->allowed_attach_size*1024*1024; |
|
278 | - $file_config->allowed_filesize = $file_config->allowed_filesize*1024*1024; |
|
277 | + $file_config->allowed_attach_size = $file_config->allowed_attach_size * 1024 * 1024; |
|
278 | + $file_config->allowed_filesize = $file_config->allowed_filesize * 1024 * 1024; |
|
279 | 279 | |
280 | - Context::set('file_config',$file_config); |
|
280 | + Context::set('file_config', $file_config); |
|
281 | 281 | // Configure upload status such as file size |
282 | 282 | $upload_status = $oFileModel->getUploadStatus(); |
283 | 283 | Context::set('upload_status', $upload_status); |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | $oFileController = getController('file'); |
286 | 286 | $oFileController->setUploadInfo($editor_sequence, $upload_target_srl); |
287 | 287 | // Check if the file already exists |
288 | - if($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
288 | + if ($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
289 | 289 | } |
290 | - Context::set('files_count', (int)$files_count); |
|
290 | + Context::set('files_count', (int) $files_count); |
|
291 | 291 | |
292 | 292 | Context::set('allow_fileupload', $allow_fileupload); |
293 | 293 | // Set editor_sequence value |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | * Check editor component |
305 | 305 | */ |
306 | 306 | $site_module_info = Context::get('site_module_info'); |
307 | - $site_srl = (int)$site_module_info->site_srl; |
|
308 | - if($enable_component) |
|
307 | + $site_srl = (int) $site_module_info->site_srl; |
|
308 | + if ($enable_component) |
|
309 | 309 | { |
310 | - if(!Context::get('component_list')) |
|
310 | + if (!Context::get('component_list')) |
|
311 | 311 | { |
312 | 312 | $component_list = $this->getComponentList(true, $site_srl); |
313 | 313 | Context::set('component_list', $component_list); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $tpl_path = sprintf('%sskins/%s/', $this->module_path, $skin); |
335 | 335 | $tpl_file = 'editor.html'; |
336 | 336 | |
337 | - if(!file_exists($tpl_path.$tpl_file)) |
|
337 | + if (!file_exists($tpl_path.$tpl_file)) |
|
338 | 338 | { |
339 | 339 | $skin = 'ckeditor'; |
340 | 340 | $tpl_path = sprintf('%sskins/%s/', $this->module_path, $skin); |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $config->module_type = $type; |
365 | 365 | |
366 | 366 | // Configurations listed according to a type |
367 | - if($type == 'document') |
|
367 | + if ($type == 'document') |
|
368 | 368 | { |
369 | 369 | $config->editor_skin = $editor_config->editor_skin; |
370 | 370 | $config->content_style = $editor_config->content_style; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | $config->enable_autosave = 'N'; |
394 | 394 | } |
395 | 395 | // Check a group_list of the currently logged-in user for permission check |
396 | - if(Context::get('is_logged')) |
|
396 | + if (Context::get('is_logged')) |
|
397 | 397 | { |
398 | 398 | $logged_info = Context::get('logged_info'); |
399 | 399 | $group_list = $logged_info->group_list; |
@@ -412,12 +412,12 @@ discard block |
||
412 | 412 | $option->colorset = $config->sel_editor_colorset; |
413 | 413 | // Permission check for file upload |
414 | 414 | $option->allow_fileupload = false; |
415 | - if($logged_info->is_admin=='Y') $option->allow_fileupload = true; |
|
416 | - elseif(count($config->upload_file_grant)) |
|
415 | + if ($logged_info->is_admin == 'Y') $option->allow_fileupload = true; |
|
416 | + elseif (count($config->upload_file_grant)) |
|
417 | 417 | { |
418 | - foreach($group_list as $group_srl => $group_info) |
|
418 | + foreach ($group_list as $group_srl => $group_info) |
|
419 | 419 | { |
420 | - if(in_array($group_srl, $config->upload_file_grant)) |
|
420 | + if (in_array($group_srl, $config->upload_file_grant)) |
|
421 | 421 | { |
422 | 422 | $option->allow_fileupload = true; |
423 | 423 | break; |
@@ -427,12 +427,12 @@ discard block |
||
427 | 427 | else $option->allow_fileupload = true; |
428 | 428 | // Permission check for using default components |
429 | 429 | $option->enable_default_component = false; |
430 | - if($logged_info->is_admin=='Y') $option->enable_default_component = true; |
|
431 | - elseif(count($config->enable_default_component_grant)) |
|
430 | + if ($logged_info->is_admin == 'Y') $option->enable_default_component = true; |
|
431 | + elseif (count($config->enable_default_component_grant)) |
|
432 | 432 | { |
433 | - foreach($group_list as $group_srl => $group_info) |
|
433 | + foreach ($group_list as $group_srl => $group_info) |
|
434 | 434 | { |
435 | - if(in_array($group_srl, $config->enable_default_component_grant)) |
|
435 | + if (in_array($group_srl, $config->enable_default_component_grant)) |
|
436 | 436 | { |
437 | 437 | $option->enable_default_component = true; |
438 | 438 | break; |
@@ -442,12 +442,12 @@ discard block |
||
442 | 442 | else $option->enable_default_component = true; |
443 | 443 | // Permisshion check for using extended components |
444 | 444 | $option->enable_component = false; |
445 | - if($logged_info->is_admin=='Y') $option->enable_component = true; |
|
446 | - elseif(count($config->enable_component_grant)) |
|
445 | + if ($logged_info->is_admin == 'Y') $option->enable_component = true; |
|
446 | + elseif (count($config->enable_component_grant)) |
|
447 | 447 | { |
448 | - foreach($group_list as $group_srl => $group_info) |
|
448 | + foreach ($group_list as $group_srl => $group_info) |
|
449 | 449 | { |
450 | - if(in_array($group_srl, $config->enable_component_grant)) |
|
450 | + if (in_array($group_srl, $config->enable_component_grant)) |
|
451 | 451 | { |
452 | 452 | $option->enable_component = true; |
453 | 453 | break; |
@@ -457,12 +457,12 @@ discard block |
||
457 | 457 | else $option->enable_component = true; |
458 | 458 | // HTML editing privileges |
459 | 459 | $enable_html = false; |
460 | - if($logged_info->is_admin=='Y') $enable_html = true; |
|
461 | - elseif(count($config->enable_html_grant)) |
|
460 | + if ($logged_info->is_admin == 'Y') $enable_html = true; |
|
461 | + elseif (count($config->enable_html_grant)) |
|
462 | 462 | { |
463 | - foreach($group_list as $group_srl => $group_info) |
|
463 | + foreach ($group_list as $group_srl => $group_info) |
|
464 | 464 | { |
465 | - if(in_array($group_srl, $config->enable_html_grant)) |
|
465 | + if (in_array($group_srl, $config->enable_html_grant)) |
|
466 | 466 | { |
467 | 467 | $enable_html = true; |
468 | 468 | break; |
@@ -471,12 +471,12 @@ discard block |
||
471 | 471 | } |
472 | 472 | else $enable_html = true; |
473 | 473 | |
474 | - if($enable_html) $option->disable_html = false; |
|
474 | + if ($enable_html) $option->disable_html = false; |
|
475 | 475 | else $option->disable_html = true; |
476 | 476 | // Set Height |
477 | 477 | $option->height = $config->editor_height; |
478 | 478 | // Set an option for Auto-save |
479 | - $option->enable_autosave = $config->enable_autosave=='Y'?true:false; |
|
479 | + $option->enable_autosave = $config->enable_autosave == 'Y' ?true:false; |
|
480 | 480 | // Other settings |
481 | 481 | $option->primary_key_name = $primary_key_name; |
482 | 482 | $option->content_key_name = $content_key_name; |
@@ -492,31 +492,31 @@ discard block |
||
492 | 492 | $auto_save_args = new stdClass(); |
493 | 493 | $auto_save_args->module_srl = Context::get('module_srl'); |
494 | 494 | // Get the current module if module_srl doesn't exist |
495 | - if(!$auto_save_args->module_srl) |
|
495 | + if (!$auto_save_args->module_srl) |
|
496 | 496 | { |
497 | 497 | $current_module_info = Context::get('current_module_info'); |
498 | 498 | $auto_save_args->module_srl = $current_module_info->module_srl; |
499 | 499 | } |
500 | 500 | // Find a document by using member_srl for logged-in user and ipaddress for non-logged user |
501 | - if(Context::get('is_logged')) |
|
501 | + if (Context::get('is_logged')) |
|
502 | 502 | { |
503 | 503 | $logged_info = Context::get('logged_info'); |
504 | 504 | $auto_save_args->member_srl = $logged_info->member_srl; |
505 | 505 | } |
506 | 506 | else |
507 | 507 | { |
508 | - $auto_save_args->certify_key = $_COOKIE['autosave_certify_key_' . $auto_save_args->module_srl]; |
|
508 | + $auto_save_args->certify_key = $_COOKIE['autosave_certify_key_'.$auto_save_args->module_srl]; |
|
509 | 509 | // @see https://github.com/xpressengine/xe-core/issues/2208 |
510 | 510 | // 변경 이전에 작성된 게시물 호환성 유지 |
511 | - if(!$auto_save_args->certify_key) $auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
511 | + if (!$auto_save_args->certify_key) $auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
512 | 512 | } |
513 | 513 | // Extract auto-saved data from the DB |
514 | 514 | $output = executeQuery('editor.getSavedDocument', $auto_save_args); |
515 | 515 | $saved_doc = $output->data; |
516 | 516 | // Return null if no result is auto-saved |
517 | - if(!$saved_doc) return; |
|
517 | + if (!$saved_doc) return; |
|
518 | 518 | |
519 | - if($saved_doc->certify_key && !isset($auto_save_args->certify_key)) |
|
519 | + if ($saved_doc->certify_key && !isset($auto_save_args->certify_key)) |
|
520 | 520 | { |
521 | 521 | return; |
522 | 522 | } |
@@ -524,16 +524,16 @@ discard block |
||
524 | 524 | // Check if the auto-saved document already exists |
525 | 525 | $oDocumentModel = getModel('document'); |
526 | 526 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
527 | - if($oSaved->isExists()) return; |
|
527 | + if ($oSaved->isExists()) return; |
|
528 | 528 | // Move all the files if the auto-saved data contains document_srl and file |
529 | 529 | // Then set document_srl to editor_sequence |
530 | - if($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
|
530 | + if ($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
|
531 | 531 | { |
532 | 532 | $saved_doc->module_srl = $auto_save_args->module_srl; |
533 | 533 | $oFileController = getController('file'); |
534 | 534 | $oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl); |
535 | 535 | } |
536 | - else if($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
536 | + else if ($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
537 | 537 | // Change auto-saved data |
538 | 538 | $saved_doc->certify_key = $auto_save_args->certify_key; |
539 | 539 | $oEditorController = getController('editor'); |
@@ -550,18 +550,18 @@ discard block |
||
550 | 550 | */ |
551 | 551 | function getComponentObject($component, $editor_sequence = 0, $site_srl = 0) |
552 | 552 | { |
553 | - if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) return; |
|
553 | + if (!preg_match('/^[a-zA-Z0-9_-]+$/', $component) || !preg_match('/^[0-9]+$/', $editor_sequence.$site_srl)) return; |
|
554 | 554 | |
555 | - if(!$this->loaded_component_list[$component][$editor_sequence]) |
|
555 | + if (!$this->loaded_component_list[$component][$editor_sequence]) |
|
556 | 556 | { |
557 | 557 | // Create an object of the component and execute |
558 | 558 | $class_path = sprintf('%scomponents/%s/', $this->module_path, $component); |
559 | 559 | $class_file = sprintf('%s%s.class.php', $class_path, $component); |
560 | - if(!file_exists($class_file)) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
560 | + if (!file_exists($class_file)) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
561 | 561 | // Create an object after loading the class file |
562 | 562 | require_once($class_file); |
563 | 563 | $oComponent = new $component($editor_sequence, $class_path); |
564 | - if(!$oComponent) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
564 | + if (!$oComponent) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
565 | 565 | // Add configuration information |
566 | 566 | $component_info = $this->getComponent($component, $site_srl); |
567 | 567 | $oComponent->setInfo($component_info); |
@@ -582,14 +582,14 @@ discard block |
||
582 | 582 | /** |
583 | 583 | * @brief Return the cache file name of editor component list |
584 | 584 | */ |
585 | - function getCacheFile($filter_enabled= true, $site_srl = 0) |
|
585 | + function getCacheFile($filter_enabled = true, $site_srl = 0) |
|
586 | 586 | { |
587 | 587 | $lang = Context::getLangType(); |
588 | 588 | $cache_path = _XE_PATH_.'files/cache/editor/cache/'; |
589 | 589 | FileHandler::makeDir($cache_path); |
590 | - $cache_file = $cache_path.'component_list.' . $lang .'.'; |
|
591 | - if($filter_enabled) $cache_file .= 'filter.'; |
|
592 | - if($site_srl) $cache_file .= $site_srl.'.'; |
|
590 | + $cache_file = $cache_path.'component_list.'.$lang.'.'; |
|
591 | + if ($filter_enabled) $cache_file .= 'filter.'; |
|
592 | + if ($site_srl) $cache_file .= $site_srl.'.'; |
|
593 | 593 | $cache_file .= 'php'; |
594 | 594 | return $cache_file; |
595 | 595 | } |
@@ -597,19 +597,19 @@ discard block |
||
597 | 597 | /** |
598 | 598 | * @brief Return a component list (DB Information included) |
599 | 599 | */ |
600 | - function getComponentList($filter_enabled = true, $site_srl=0, $from_db=false) |
|
600 | + function getComponentList($filter_enabled = true, $site_srl = 0, $from_db = false) |
|
601 | 601 | { |
602 | 602 | $cache_file = $this->getCacheFile(false, $site_srl); |
603 | - if($from_db || !file_exists($cache_file)) |
|
603 | + if ($from_db || !file_exists($cache_file)) |
|
604 | 604 | { |
605 | 605 | $oEditorController = getController('editor'); |
606 | 606 | $oEditorController->makeCache(false, $site_srl); |
607 | 607 | } |
608 | 608 | |
609 | - if(!file_exists($cache_file)) return; |
|
609 | + if (!file_exists($cache_file)) return; |
|
610 | 610 | include($cache_file); |
611 | 611 | $logged_info = Context::get('logged_info'); |
612 | - if($logged_info && is_array($logged_info->group_list)) |
|
612 | + if ($logged_info && is_array($logged_info->group_list)) |
|
613 | 613 | { |
614 | 614 | $group_list = array_keys($logged_info->group_list); |
615 | 615 | } |
@@ -618,45 +618,45 @@ discard block |
||
618 | 618 | $group_list = array(); |
619 | 619 | } |
620 | 620 | |
621 | - if(count($component_list)) |
|
621 | + if (count($component_list)) |
|
622 | 622 | { |
623 | - foreach($component_list as $key => $val) |
|
623 | + foreach ($component_list as $key => $val) |
|
624 | 624 | { |
625 | - if(!trim($key)) continue; |
|
626 | - if(!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
|
625 | + if (!trim($key)) continue; |
|
626 | + if (!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
|
627 | 627 | { |
628 | 628 | FileHandler::removeFile($cache_file); |
629 | 629 | return $this->getComponentList($filter_enabled, $site_srl); |
630 | 630 | } |
631 | - if(!$filter_enabled) continue; |
|
632 | - if($val->enabled == "N") |
|
631 | + if (!$filter_enabled) continue; |
|
632 | + if ($val->enabled == "N") |
|
633 | 633 | { |
634 | 634 | unset($component_list->{$key}); |
635 | 635 | continue; |
636 | 636 | } |
637 | - if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
638 | - if($val->target_group) |
|
637 | + if ($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
638 | + if ($val->target_group) |
|
639 | 639 | { |
640 | - if(!$logged_info) |
|
640 | + if (!$logged_info) |
|
641 | 641 | { |
642 | 642 | $val->enabled = "N"; |
643 | 643 | } |
644 | 644 | else |
645 | 645 | { |
646 | 646 | $is_granted = false; |
647 | - foreach($group_list as $group_srl) |
|
647 | + foreach ($group_list as $group_srl) |
|
648 | 648 | { |
649 | - if(in_array($group_srl, $val->target_group)) $is_granted = true; |
|
649 | + if (in_array($group_srl, $val->target_group)) $is_granted = true; |
|
650 | 650 | } |
651 | - if(!$is_granted) $val->enabled = "N"; |
|
651 | + if (!$is_granted) $val->enabled = "N"; |
|
652 | 652 | } |
653 | 653 | } |
654 | - if($val->enabled != "N" && $val->mid_list) |
|
654 | + if ($val->enabled != "N" && $val->mid_list) |
|
655 | 655 | { |
656 | 656 | $mid = Context::get('mid'); |
657 | - if(!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
657 | + if (!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
658 | 658 | } |
659 | - if($val->enabled == "N") |
|
659 | + if ($val->enabled == "N") |
|
660 | 660 | { |
661 | 661 | unset($component_list->{$key}); |
662 | 662 | continue; |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | $args = new stdClass(); |
675 | 675 | $args->component_name = $component_name; |
676 | 676 | |
677 | - if($site_srl) |
|
677 | + if ($site_srl) |
|
678 | 678 | { |
679 | 679 | $args->site_srl = $site_srl; |
680 | 680 | $output = executeQuery('editor.getSiteComponent', $args); |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | } |
686 | 686 | $component = $output->data; |
687 | 687 | |
688 | - if(!$output->data) return false; |
|
688 | + if (!$output->data) return false; |
|
689 | 689 | |
690 | 690 | $component_name = $component->component_name; |
691 | 691 | |
@@ -697,25 +697,25 @@ discard block |
||
697 | 697 | |
698 | 698 | $xml_info->mid_list = array(); |
699 | 699 | |
700 | - if($component->extra_vars) |
|
700 | + if ($component->extra_vars) |
|
701 | 701 | { |
702 | 702 | $extra_vars = unserialize($component->extra_vars); |
703 | 703 | |
704 | - if($extra_vars->target_group) |
|
704 | + if ($extra_vars->target_group) |
|
705 | 705 | { |
706 | 706 | $xml_info->target_group = $extra_vars->target_group; |
707 | 707 | unset($extra_vars->target_group); |
708 | 708 | } |
709 | 709 | |
710 | - if($extra_vars->mid_list) |
|
710 | + if ($extra_vars->mid_list) |
|
711 | 711 | { |
712 | 712 | $xml_info->mid_list = $extra_vars->mid_list; |
713 | 713 | unset($extra_vars->mid_list); |
714 | 714 | } |
715 | 715 | |
716 | - if($xml_info->extra_vars) |
|
716 | + if ($xml_info->extra_vars) |
|
717 | 717 | { |
718 | - foreach($xml_info->extra_vars as $key => $val) |
|
718 | + foreach ($xml_info->extra_vars as $key => $val) |
|
719 | 719 | { |
720 | 720 | $xml_info->extra_vars->{$key}->value = $extra_vars->{$key}; |
721 | 721 | } |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | $cache_file = sprintf('./files/cache/editor/%s.%s.php', $component, $lang_type); |
740 | 740 | |
741 | 741 | // Include and return xml file information if cached file exists |
742 | - if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
742 | + if (file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
743 | 743 | { |
744 | 744 | include($cache_file); |
745 | 745 | |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | $component_info->component_name = $component; |
757 | 757 | $component_info->title = $xml_doc->component->title->body; |
758 | 758 | |
759 | - if($xml_doc->component->version) |
|
759 | + if ($xml_doc->component->version) |
|
760 | 760 | { |
761 | 761 | $component_info->description = str_replace('\n', "\n", $xml_doc->component->description->body); |
762 | 762 | $component_info->version = $xml_doc->component->version->body; |
@@ -782,10 +782,10 @@ discard block |
||
782 | 782 | |
783 | 783 | // Author information |
784 | 784 | $author_list = array(); |
785 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
785 | + if (!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
786 | 786 | else $author_list = $xml_doc->component->author; |
787 | 787 | |
788 | - for($i = 0; $i < count($author_list); $i++) |
|
788 | + for ($i = 0; $i < count($author_list); $i++) |
|
789 | 789 | { |
790 | 790 | $author = new stdClass; |
791 | 791 | $author->name = $author_list[$i]->name->body; |
@@ -796,39 +796,39 @@ discard block |
||
796 | 796 | |
797 | 797 | // List extra variables (text type only for editor component) |
798 | 798 | $extra_vars = $xml_doc->component->extra_vars; |
799 | - if($extra_vars) |
|
799 | + if ($extra_vars) |
|
800 | 800 | { |
801 | 801 | $extra_var_groups = $extra_vars->group; |
802 | - if(!$extra_var_groups) |
|
802 | + if (!$extra_var_groups) |
|
803 | 803 | { |
804 | 804 | $extra_var_groups = $extra_vars; |
805 | 805 | } |
806 | - if(!is_array($extra_var_groups)) |
|
806 | + if (!is_array($extra_var_groups)) |
|
807 | 807 | { |
808 | 808 | $extra_var_groups = array($extra_var_groups); |
809 | 809 | } |
810 | 810 | |
811 | - foreach($extra_var_groups as $group) |
|
811 | + foreach ($extra_var_groups as $group) |
|
812 | 812 | { |
813 | 813 | $extra_vars = $group->var; |
814 | - if(!is_array($group->var)) |
|
814 | + if (!is_array($group->var)) |
|
815 | 815 | { |
816 | 816 | $extra_vars = array($group->var); |
817 | 817 | } |
818 | 818 | |
819 | - foreach($extra_vars as $key => $val) |
|
819 | + foreach ($extra_vars as $key => $val) |
|
820 | 820 | { |
821 | - if(!$val) |
|
821 | + if (!$val) |
|
822 | 822 | { |
823 | 823 | continue; |
824 | 824 | } |
825 | 825 | |
826 | 826 | $obj = new stdClass(); |
827 | - if(!$val->attrs) |
|
827 | + if (!$val->attrs) |
|
828 | 828 | { |
829 | 829 | $val->attrs = new stdClass(); |
830 | 830 | } |
831 | - if(!$val->attrs->type) |
|
831 | + if (!$val->attrs->type) |
|
832 | 832 | { |
833 | 833 | $val->attrs->type = 'text'; |
834 | 834 | } |
@@ -838,26 +838,26 @@ discard block |
||
838 | 838 | $obj->title = $val->title->body; |
839 | 839 | $obj->type = $val->attrs->type; |
840 | 840 | $obj->description = $val->description->body; |
841 | - if($obj->name) |
|
841 | + if ($obj->name) |
|
842 | 842 | { |
843 | 843 | $obj->value = $extra_vals->{$obj->name}; |
844 | 844 | } |
845 | - if(strpos($obj->value, '|@|') != FALSE) |
|
845 | + if (strpos($obj->value, '|@|') != FALSE) |
|
846 | 846 | { |
847 | 847 | $obj->value = explode('|@|', $obj->value); |
848 | 848 | } |
849 | - if($obj->type == 'mid_list' && !is_array($obj->value)) |
|
849 | + if ($obj->type == 'mid_list' && !is_array($obj->value)) |
|
850 | 850 | { |
851 | 851 | $obj->value = array($obj->value); |
852 | 852 | } |
853 | 853 | |
854 | 854 | // 'Select'type obtained from the option list. |
855 | - if($val->options && !is_array($val->options)) |
|
855 | + if ($val->options && !is_array($val->options)) |
|
856 | 856 | { |
857 | 857 | $val->options = array($val->options); |
858 | 858 | } |
859 | 859 | |
860 | - for($i = 0, $c = count($val->options); $i < $c; $i++) |
|
860 | + for ($i = 0, $c = count($val->options); $i < $c; $i++) |
|
861 | 861 | { |
862 | 862 | $obj->options[$i] = new stdClass(); |
863 | 863 | $obj->options[$i]->title = $val->options[$i]->title->body; |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | |
872 | 872 | $buff = array(); |
873 | 873 | $buff[] = '<?php if(!defined(\'__XE__\')) exit();'; |
874 | - $buff[] = '$xml_info = ' . var_export($component_info, TRUE) . ';'; |
|
874 | + $buff[] = '$xml_info = '.var_export($component_info, TRUE).';'; |
|
875 | 875 | $buff = str_replace('stdClass::__set_state', '(object)', implode(PHP_EOL, $buff)); |
876 | 876 | |
877 | 877 | FileHandler::writeFile($cache_file, $buff, 'w'); |
@@ -34,17 +34,37 @@ discard block |
||
34 | 34 | $oModuleModel = getModel('module'); |
35 | 35 | $editor_default_config = $oModuleModel->getModuleConfig('editor'); |
36 | 36 | |
37 | - if(!is_object($editor_config)) $editor_config = new stdClass(); |
|
38 | - |
|
39 | - if($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
40 | - if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
41 | - if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
42 | - if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
43 | - if(!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
44 | - if(!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
45 | - if(!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
46 | - if(!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
47 | - if(!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant= array(); |
|
37 | + if(!is_object($editor_config)) { |
|
38 | + $editor_config = new stdClass(); |
|
39 | + } |
|
40 | + |
|
41 | + if($editor_config->enable_autosave != 'N') { |
|
42 | + $editor_config->enable_autosave = 'Y'; |
|
43 | + } |
|
44 | + if(!is_array($editor_config->enable_html_grant)) { |
|
45 | + $editor_config->enable_html_grant = array(); |
|
46 | + } |
|
47 | + if(!is_array($editor_config->enable_comment_html_grant)) { |
|
48 | + $editor_config->enable_comment_html_grant = array(); |
|
49 | + } |
|
50 | + if(!is_array($editor_config->upload_file_grant)) { |
|
51 | + $editor_config->upload_file_grant = array(); |
|
52 | + } |
|
53 | + if(!is_array($editor_config->comment_upload_file_grant)) { |
|
54 | + $editor_config->comment_upload_file_grant = array(); |
|
55 | + } |
|
56 | + if(!is_array($editor_config->enable_default_component_grant)) { |
|
57 | + $editor_config->enable_default_component_grant = array(); |
|
58 | + } |
|
59 | + if(!is_array($editor_config->enable_comment_default_component_grant)) { |
|
60 | + $editor_config->enable_comment_default_component_grant = array(); |
|
61 | + } |
|
62 | + if(!is_array($editor_config->enable_component_grant)) { |
|
63 | + $editor_config->enable_component_grant = array(); |
|
64 | + } |
|
65 | + if(!is_array($editor_config->enable_comment_component_grant)) { |
|
66 | + $editor_config->enable_comment_component_grant= array(); |
|
67 | + } |
|
48 | 68 | |
49 | 69 | if(!$editor_config->editor_height) |
50 | 70 | { |
@@ -151,8 +171,11 @@ discard block |
||
151 | 171 | $buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link); |
152 | 172 | |
153 | 173 | // Author information |
154 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
155 | - else $author_list = $xml_doc->component->author; |
|
174 | + if(!is_array($xml_doc->component->author)) { |
|
175 | + $author_list[] = $xml_doc->component->author; |
|
176 | + } else { |
|
177 | + $author_list = $xml_doc->component->author; |
|
178 | + } |
|
156 | 179 | |
157 | 180 | for($i=0; $i < count($author_list); $i++) |
158 | 181 | { |
@@ -165,7 +188,9 @@ discard block |
||
165 | 188 | $extra_vars = $xml_doc->component->extra_vars->var; |
166 | 189 | if($extra_vars) |
167 | 190 | { |
168 | - if(!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
191 | + if(!is_array($extra_vars)) { |
|
192 | + $extra_vars = array($extra_vars); |
|
193 | + } |
|
169 | 194 | foreach($extra_vars as $key => $val) |
170 | 195 | { |
171 | 196 | unset($obj); |
@@ -202,10 +227,15 @@ discard block |
||
202 | 227 | { |
203 | 228 | $option->editor_sequence = $upload_target_srl; |
204 | 229 | } |
205 | - if(!$option->allow_fileupload) $allow_fileupload = false; |
|
206 | - else $allow_fileupload = true; |
|
230 | + if(!$option->allow_fileupload) { |
|
231 | + $allow_fileupload = false; |
|
232 | + } else { |
|
233 | + $allow_fileupload = true; |
|
234 | + } |
|
207 | 235 | // content_style setting |
208 | - if(!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
236 | + if(!$option->content_style) { |
|
237 | + $option->content_style = 'ckeditor_light'; |
|
238 | + } |
|
209 | 239 | Context::set('content_style', $option->content_style); |
210 | 240 | Context::set('content_style_path', getScriptPath() . ltrim($this->module_path, './') . 'styles/' . $option->content_style); |
211 | 241 | // Default font setting |
@@ -213,27 +243,47 @@ discard block |
||
213 | 243 | Context::set('content_font_size', $option->content_font_size); |
214 | 244 | |
215 | 245 | // Option setting to allow auto-save |
216 | - if(!$option->enable_autosave) $enable_autosave = false; |
|
217 | - elseif(Context::get($option->primary_key_name)) $enable_autosave = false; |
|
218 | - else $enable_autosave = true; |
|
246 | + if(!$option->enable_autosave) { |
|
247 | + $enable_autosave = false; |
|
248 | + } elseif(Context::get($option->primary_key_name)) { |
|
249 | + $enable_autosave = false; |
|
250 | + } else { |
|
251 | + $enable_autosave = true; |
|
252 | + } |
|
219 | 253 | // Option setting to allow the default editor component |
220 | - if(!$option->enable_default_component) $enable_default_component = false; |
|
221 | - else $enable_default_component = true; |
|
254 | + if(!$option->enable_default_component) { |
|
255 | + $enable_default_component = false; |
|
256 | + } else { |
|
257 | + $enable_default_component = true; |
|
258 | + } |
|
222 | 259 | // Option setting to allow other extended components |
223 | - if(!$option->enable_component) $enable_component = false; |
|
224 | - else $enable_component = true; |
|
260 | + if(!$option->enable_component) { |
|
261 | + $enable_component = false; |
|
262 | + } else { |
|
263 | + $enable_component = true; |
|
264 | + } |
|
225 | 265 | // Setting for html-mode |
226 | - if($option->disable_html) $html_mode = false; |
|
227 | - else $html_mode = true; |
|
266 | + if($option->disable_html) { |
|
267 | + $html_mode = false; |
|
268 | + } else { |
|
269 | + $html_mode = true; |
|
270 | + } |
|
228 | 271 | // Set Height |
229 | - if(!$option->height) $editor_height = 300; |
|
230 | - else $editor_height = $option->height; |
|
272 | + if(!$option->height) { |
|
273 | + $editor_height = 300; |
|
274 | + } else { |
|
275 | + $editor_height = $option->height; |
|
276 | + } |
|
231 | 277 | // Skin Setting |
232 | 278 | $skin = $option->skin; |
233 | - if(!$skin) $skin = 'ckeditor'; |
|
279 | + if(!$skin) { |
|
280 | + $skin = 'ckeditor'; |
|
281 | + } |
|
234 | 282 | |
235 | 283 | $colorset = $option->colorset; |
236 | - if(!$colorset) $colorset = 'moono'; |
|
284 | + if(!$colorset) { |
|
285 | + $colorset = 'moono'; |
|
286 | + } |
|
237 | 287 | Context::set('colorset', $colorset); |
238 | 288 | Context::set('skin', $skin); |
239 | 289 | Context::set('module_type', $option->module_type); |
@@ -258,10 +308,13 @@ discard block |
||
258 | 308 | /** |
259 | 309 | * Extract editor's unique number (in order to display multiple editors on a single page) |
260 | 310 | */ |
261 | - if($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
262 | - else |
|
311 | + if($option->editor_sequence) { |
|
312 | + $editor_sequence = $option->editor_sequence; |
|
313 | + } else |
|
263 | 314 | { |
264 | - if(!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
315 | + if(!$_SESSION['_editor_sequence_']) { |
|
316 | + $_SESSION['_editor_sequence_'] = 1; |
|
317 | + } |
|
265 | 318 | $editor_sequence = $_SESSION['_editor_sequence_'] ++; |
266 | 319 | } |
267 | 320 | |
@@ -285,7 +338,9 @@ discard block |
||
285 | 338 | $oFileController = getController('file'); |
286 | 339 | $oFileController->setUploadInfo($editor_sequence, $upload_target_srl); |
287 | 340 | // Check if the file already exists |
288 | - if($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
341 | + if($upload_target_srl) { |
|
342 | + $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
343 | + } |
|
289 | 344 | } |
290 | 345 | Context::set('files_count', (int)$files_count); |
291 | 346 | |
@@ -377,8 +432,7 @@ discard block |
||
377 | 432 | $config->enable_html_grant = $editor_config->enable_html_grant; |
378 | 433 | $config->editor_height = $editor_config->editor_height; |
379 | 434 | $config->enable_autosave = $editor_config->enable_autosave; |
380 | - } |
|
381 | - else |
|
435 | + } else |
|
382 | 436 | { |
383 | 437 | $config->editor_skin = $editor_config->comment_editor_skin; |
384 | 438 | $config->content_style = $editor_config->comment_content_style; |
@@ -397,8 +451,7 @@ discard block |
||
397 | 451 | { |
398 | 452 | $logged_info = Context::get('logged_info'); |
399 | 453 | $group_list = $logged_info->group_list; |
400 | - } |
|
401 | - else |
|
454 | + } else |
|
402 | 455 | { |
403 | 456 | $group_list = array(); |
404 | 457 | } |
@@ -412,8 +465,9 @@ discard block |
||
412 | 465 | $option->colorset = $config->sel_editor_colorset; |
413 | 466 | // Permission check for file upload |
414 | 467 | $option->allow_fileupload = false; |
415 | - if($logged_info->is_admin=='Y') $option->allow_fileupload = true; |
|
416 | - elseif(count($config->upload_file_grant)) |
|
468 | + if($logged_info->is_admin=='Y') { |
|
469 | + $option->allow_fileupload = true; |
|
470 | + } elseif(count($config->upload_file_grant)) |
|
417 | 471 | { |
418 | 472 | foreach($group_list as $group_srl => $group_info) |
419 | 473 | { |
@@ -423,12 +477,14 @@ discard block |
||
423 | 477 | break; |
424 | 478 | } |
425 | 479 | } |
480 | + } else { |
|
481 | + $option->allow_fileupload = true; |
|
426 | 482 | } |
427 | - else $option->allow_fileupload = true; |
|
428 | 483 | // Permission check for using default components |
429 | 484 | $option->enable_default_component = false; |
430 | - if($logged_info->is_admin=='Y') $option->enable_default_component = true; |
|
431 | - elseif(count($config->enable_default_component_grant)) |
|
485 | + if($logged_info->is_admin=='Y') { |
|
486 | + $option->enable_default_component = true; |
|
487 | + } elseif(count($config->enable_default_component_grant)) |
|
432 | 488 | { |
433 | 489 | foreach($group_list as $group_srl => $group_info) |
434 | 490 | { |
@@ -438,12 +494,14 @@ discard block |
||
438 | 494 | break; |
439 | 495 | } |
440 | 496 | } |
497 | + } else { |
|
498 | + $option->enable_default_component = true; |
|
441 | 499 | } |
442 | - else $option->enable_default_component = true; |
|
443 | 500 | // Permisshion check for using extended components |
444 | 501 | $option->enable_component = false; |
445 | - if($logged_info->is_admin=='Y') $option->enable_component = true; |
|
446 | - elseif(count($config->enable_component_grant)) |
|
502 | + if($logged_info->is_admin=='Y') { |
|
503 | + $option->enable_component = true; |
|
504 | + } elseif(count($config->enable_component_grant)) |
|
447 | 505 | { |
448 | 506 | foreach($group_list as $group_srl => $group_info) |
449 | 507 | { |
@@ -453,12 +511,14 @@ discard block |
||
453 | 511 | break; |
454 | 512 | } |
455 | 513 | } |
514 | + } else { |
|
515 | + $option->enable_component = true; |
|
456 | 516 | } |
457 | - else $option->enable_component = true; |
|
458 | 517 | // HTML editing privileges |
459 | 518 | $enable_html = false; |
460 | - if($logged_info->is_admin=='Y') $enable_html = true; |
|
461 | - elseif(count($config->enable_html_grant)) |
|
519 | + if($logged_info->is_admin=='Y') { |
|
520 | + $enable_html = true; |
|
521 | + } elseif(count($config->enable_html_grant)) |
|
462 | 522 | { |
463 | 523 | foreach($group_list as $group_srl => $group_info) |
464 | 524 | { |
@@ -468,11 +528,15 @@ discard block |
||
468 | 528 | break; |
469 | 529 | } |
470 | 530 | } |
531 | + } else { |
|
532 | + $enable_html = true; |
|
471 | 533 | } |
472 | - else $enable_html = true; |
|
473 | 534 | |
474 | - if($enable_html) $option->disable_html = false; |
|
475 | - else $option->disable_html = true; |
|
535 | + if($enable_html) { |
|
536 | + $option->disable_html = false; |
|
537 | + } else { |
|
538 | + $option->disable_html = true; |
|
539 | + } |
|
476 | 540 | // Set Height |
477 | 541 | $option->height = $config->editor_height; |
478 | 542 | // Set an option for Auto-save |
@@ -502,19 +566,22 @@ discard block |
||
502 | 566 | { |
503 | 567 | $logged_info = Context::get('logged_info'); |
504 | 568 | $auto_save_args->member_srl = $logged_info->member_srl; |
505 | - } |
|
506 | - else |
|
569 | + } else |
|
507 | 570 | { |
508 | 571 | $auto_save_args->certify_key = $_COOKIE['autosave_certify_key_' . $auto_save_args->module_srl]; |
509 | 572 | // @see https://github.com/xpressengine/xe-core/issues/2208 |
510 | 573 | // 변경 이전에 작성된 게시물 호환성 유지 |
511 | - if(!$auto_save_args->certify_key) $auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
574 | + if(!$auto_save_args->certify_key) { |
|
575 | + $auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
576 | + } |
|
512 | 577 | } |
513 | 578 | // Extract auto-saved data from the DB |
514 | 579 | $output = executeQuery('editor.getSavedDocument', $auto_save_args); |
515 | 580 | $saved_doc = $output->data; |
516 | 581 | // Return null if no result is auto-saved |
517 | - if(!$saved_doc) return; |
|
582 | + if(!$saved_doc) { |
|
583 | + return; |
|
584 | + } |
|
518 | 585 | |
519 | 586 | if($saved_doc->certify_key && !isset($auto_save_args->certify_key)) |
520 | 587 | { |
@@ -524,7 +591,9 @@ discard block |
||
524 | 591 | // Check if the auto-saved document already exists |
525 | 592 | $oDocumentModel = getModel('document'); |
526 | 593 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
527 | - if($oSaved->isExists()) return; |
|
594 | + if($oSaved->isExists()) { |
|
595 | + return; |
|
596 | + } |
|
528 | 597 | // Move all the files if the auto-saved data contains document_srl and file |
529 | 598 | // Then set document_srl to editor_sequence |
530 | 599 | if($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
@@ -532,8 +601,9 @@ discard block |
||
532 | 601 | $saved_doc->module_srl = $auto_save_args->module_srl; |
533 | 602 | $oFileController = getController('file'); |
534 | 603 | $oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl); |
604 | + } else if($upload_target_srl) { |
|
605 | + $saved_doc->document_srl = $upload_target_srl; |
|
535 | 606 | } |
536 | - else if($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
537 | 607 | // Change auto-saved data |
538 | 608 | $saved_doc->certify_key = $auto_save_args->certify_key; |
539 | 609 | $oEditorController = getController('editor'); |
@@ -550,18 +620,24 @@ discard block |
||
550 | 620 | */ |
551 | 621 | function getComponentObject($component, $editor_sequence = 0, $site_srl = 0) |
552 | 622 | { |
553 | - if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) return; |
|
623 | + if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) { |
|
624 | + return; |
|
625 | + } |
|
554 | 626 | |
555 | 627 | if(!$this->loaded_component_list[$component][$editor_sequence]) |
556 | 628 | { |
557 | 629 | // Create an object of the component and execute |
558 | 630 | $class_path = sprintf('%scomponents/%s/', $this->module_path, $component); |
559 | 631 | $class_file = sprintf('%s%s.class.php', $class_path, $component); |
560 | - if(!file_exists($class_file)) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
632 | + if(!file_exists($class_file)) { |
|
633 | + return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
634 | + } |
|
561 | 635 | // Create an object after loading the class file |
562 | 636 | require_once($class_file); |
563 | 637 | $oComponent = new $component($editor_sequence, $class_path); |
564 | - if(!$oComponent) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
638 | + if(!$oComponent) { |
|
639 | + return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
640 | + } |
|
565 | 641 | // Add configuration information |
566 | 642 | $component_info = $this->getComponent($component, $site_srl); |
567 | 643 | $oComponent->setInfo($component_info); |
@@ -588,8 +664,12 @@ discard block |
||
588 | 664 | $cache_path = _XE_PATH_.'files/cache/editor/cache/'; |
589 | 665 | FileHandler::makeDir($cache_path); |
590 | 666 | $cache_file = $cache_path.'component_list.' . $lang .'.'; |
591 | - if($filter_enabled) $cache_file .= 'filter.'; |
|
592 | - if($site_srl) $cache_file .= $site_srl.'.'; |
|
667 | + if($filter_enabled) { |
|
668 | + $cache_file .= 'filter.'; |
|
669 | + } |
|
670 | + if($site_srl) { |
|
671 | + $cache_file .= $site_srl.'.'; |
|
672 | + } |
|
593 | 673 | $cache_file .= 'php'; |
594 | 674 | return $cache_file; |
595 | 675 | } |
@@ -606,14 +686,15 @@ discard block |
||
606 | 686 | $oEditorController->makeCache(false, $site_srl); |
607 | 687 | } |
608 | 688 | |
609 | - if(!file_exists($cache_file)) return; |
|
689 | + if(!file_exists($cache_file)) { |
|
690 | + return; |
|
691 | + } |
|
610 | 692 | include($cache_file); |
611 | 693 | $logged_info = Context::get('logged_info'); |
612 | 694 | if($logged_info && is_array($logged_info->group_list)) |
613 | 695 | { |
614 | 696 | $group_list = array_keys($logged_info->group_list); |
615 | - } |
|
616 | - else |
|
697 | + } else |
|
617 | 698 | { |
618 | 699 | $group_list = array(); |
619 | 700 | } |
@@ -622,39 +703,50 @@ discard block |
||
622 | 703 | { |
623 | 704 | foreach($component_list as $key => $val) |
624 | 705 | { |
625 | - if(!trim($key)) continue; |
|
706 | + if(!trim($key)) { |
|
707 | + continue; |
|
708 | + } |
|
626 | 709 | if(!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
627 | 710 | { |
628 | 711 | FileHandler::removeFile($cache_file); |
629 | 712 | return $this->getComponentList($filter_enabled, $site_srl); |
630 | 713 | } |
631 | - if(!$filter_enabled) continue; |
|
714 | + if(!$filter_enabled) { |
|
715 | + continue; |
|
716 | + } |
|
632 | 717 | if($val->enabled == "N") |
633 | 718 | { |
634 | 719 | unset($component_list->{$key}); |
635 | 720 | continue; |
636 | 721 | } |
637 | - if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
722 | + if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") { |
|
723 | + continue; |
|
724 | + } |
|
638 | 725 | if($val->target_group) |
639 | 726 | { |
640 | 727 | if(!$logged_info) |
641 | 728 | { |
642 | 729 | $val->enabled = "N"; |
643 | - } |
|
644 | - else |
|
730 | + } else |
|
645 | 731 | { |
646 | 732 | $is_granted = false; |
647 | 733 | foreach($group_list as $group_srl) |
648 | 734 | { |
649 | - if(in_array($group_srl, $val->target_group)) $is_granted = true; |
|
735 | + if(in_array($group_srl, $val->target_group)) { |
|
736 | + $is_granted = true; |
|
737 | + } |
|
738 | + } |
|
739 | + if(!$is_granted) { |
|
740 | + $val->enabled = "N"; |
|
650 | 741 | } |
651 | - if(!$is_granted) $val->enabled = "N"; |
|
652 | 742 | } |
653 | 743 | } |
654 | 744 | if($val->enabled != "N" && $val->mid_list) |
655 | 745 | { |
656 | 746 | $mid = Context::get('mid'); |
657 | - if(!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
747 | + if(!in_array($mid, $val->mid_list)) { |
|
748 | + $val->enabled = "N"; |
|
749 | + } |
|
658 | 750 | } |
659 | 751 | if($val->enabled == "N") |
660 | 752 | { |
@@ -678,14 +770,15 @@ discard block |
||
678 | 770 | { |
679 | 771 | $args->site_srl = $site_srl; |
680 | 772 | $output = executeQuery('editor.getSiteComponent', $args); |
681 | - } |
|
682 | - else |
|
773 | + } else |
|
683 | 774 | { |
684 | 775 | $output = executeQuery('editor.getComponent', $args); |
685 | 776 | } |
686 | 777 | $component = $output->data; |
687 | 778 | |
688 | - if(!$output->data) return false; |
|
779 | + if(!$output->data) { |
|
780 | + return false; |
|
781 | + } |
|
689 | 782 | |
690 | 783 | $component_name = $component->component_name; |
691 | 784 | |
@@ -764,8 +857,7 @@ discard block |
||
764 | 857 | $component_info->homepage = $xml_doc->component->link->body; |
765 | 858 | $component_info->license = $xml_doc->component->license->body; |
766 | 859 | $component_info->license_link = $xml_doc->component->license->attrs->link; |
767 | - } |
|
768 | - else |
|
860 | + } else |
|
769 | 861 | { |
770 | 862 | sscanf($xml_doc->component->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); |
771 | 863 | $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); |
@@ -782,8 +874,11 @@ discard block |
||
782 | 874 | |
783 | 875 | // Author information |
784 | 876 | $author_list = array(); |
785 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
786 | - else $author_list = $xml_doc->component->author; |
|
877 | + if(!is_array($xml_doc->component->author)) { |
|
878 | + $author_list[] = $xml_doc->component->author; |
|
879 | + } else { |
|
880 | + $author_list = $xml_doc->component->author; |
|
881 | + } |
|
787 | 882 | |
788 | 883 | for($i = 0; $i < count($author_list); $i++) |
789 | 884 | { |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | private $path = NULL; ///< target directory |
17 | 17 | private $filename = NULL; ///< target filename |
18 | 18 | private $file = NULL; ///< target file (fullpath) |
19 | - private $xe_path = NULL; ///< XpressEngine base path |
|
19 | + private $xe_path = NULL; ///< XpressEngine base path |
|
20 | 20 | private $web_path = NULL; ///< tpl file web path |
21 | 21 | private $compiled_file = NULL; ///< tpl file web path |
22 | 22 | private $skipTags = NULL; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | { |
32 | 32 | ini_set('pcre.jit', "0"); |
33 | 33 | $this->xe_path = rtrim(getScriptPath(), '/'); |
34 | - $this->compiled_path = _XE_PATH_ . $this->compiled_path; |
|
34 | + $this->compiled_path = _XE_PATH_.$this->compiled_path; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | { |
43 | 43 | static $oTemplate = NULL; |
44 | 44 | |
45 | - if(__DEBUG__ == 3) |
|
45 | + if (__DEBUG__ == 3) |
|
46 | 46 | { |
47 | - if(!isset($GLOBALS['__TemplateHandlerCalled__'])) |
|
47 | + if (!isset($GLOBALS['__TemplateHandlerCalled__'])) |
|
48 | 48 | { |
49 | 49 | $GLOBALS['__TemplateHandlerCalled__'] = 1; |
50 | 50 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | - if(!$oTemplate) |
|
57 | + if (!$oTemplate) |
|
58 | 58 | { |
59 | 59 | $oTemplate = new TemplateHandler(); |
60 | 60 | } |
@@ -72,23 +72,23 @@ discard block |
||
72 | 72 | protected function init($tpl_path, $tpl_filename, $tpl_file = '') |
73 | 73 | { |
74 | 74 | // verify arguments |
75 | - if(substr($tpl_path, -1) != '/') |
|
75 | + if (substr($tpl_path, -1) != '/') |
|
76 | 76 | { |
77 | 77 | $tpl_path .= '/'; |
78 | 78 | } |
79 | - if(!is_dir($tpl_path)) |
|
79 | + if (!is_dir($tpl_path)) |
|
80 | 80 | { |
81 | 81 | return; |
82 | 82 | } |
83 | - if(!file_exists($tpl_path . $tpl_filename) && file_exists($tpl_path . $tpl_filename . '.html')) |
|
83 | + if (!file_exists($tpl_path.$tpl_filename) && file_exists($tpl_path.$tpl_filename.'.html')) |
|
84 | 84 | { |
85 | 85 | $tpl_filename .= '.html'; |
86 | 86 | } |
87 | 87 | |
88 | 88 | // create tpl_file variable |
89 | - if(!$tpl_file) |
|
89 | + if (!$tpl_file) |
|
90 | 90 | { |
91 | - $tpl_file = $tpl_path . $tpl_filename; |
|
91 | + $tpl_file = $tpl_path.$tpl_filename; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | // set template file infos. |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | $this->filename = $tpl_filename; |
97 | 97 | $this->file = $tpl_file; |
98 | 98 | |
99 | - $this->web_path = $this->xe_path . '/' . ltrim(preg_replace('@^' . preg_quote(_XE_PATH_, '@') . '|\./@', '', $this->path), '/'); |
|
99 | + $this->web_path = $this->xe_path.'/'.ltrim(preg_replace('@^'.preg_quote(_XE_PATH_, '@').'|\./@', '', $this->path), '/'); |
|
100 | 100 | |
101 | 101 | // get compiled file name |
102 | - $hash = md5($this->file . __XE_VERSION__); |
|
102 | + $hash = md5($this->file.__XE_VERSION__); |
|
103 | 103 | $this->compiled_file = "{$this->compiled_path}{$hash}.compiled.php"; |
104 | 104 | |
105 | 105 | // compare various file's modified time for check changed |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $buff = false; |
121 | 121 | |
122 | 122 | // store the starting time for debug information |
123 | - if(__DEBUG__ == 3) |
|
123 | + if (__DEBUG__ == 3) |
|
124 | 124 | { |
125 | 125 | $start = getMicroTime(); |
126 | 126 | } |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | $this->init($tpl_path, $tpl_filename, $tpl_file); |
130 | 130 | |
131 | 131 | // if target file does not exist exit |
132 | - if(!$this->file || !file_exists($this->file)) |
|
132 | + if (!$this->file || !file_exists($this->file)) |
|
133 | 133 | { |
134 | 134 | return "Err : '{$this->file}' template file does not exists."; |
135 | 135 | } |
136 | 136 | |
137 | 137 | // for backward compatibility |
138 | - if(is_null(self::$rootTpl)) |
|
138 | + if (is_null(self::$rootTpl)) |
|
139 | 139 | { |
140 | 140 | self::$rootTpl = $this->file; |
141 | 141 | } |
@@ -147,23 +147,23 @@ discard block |
||
147 | 147 | $oCacheHandler = CacheHandler::getInstance('template'); |
148 | 148 | |
149 | 149 | // get cached buff |
150 | - if($oCacheHandler->isSupport()) |
|
150 | + if ($oCacheHandler->isSupport()) |
|
151 | 151 | { |
152 | - $cache_key = 'template:' . $this->file; |
|
152 | + $cache_key = 'template:'.$this->file; |
|
153 | 153 | $buff = $oCacheHandler->get($cache_key, $latest_mtime); |
154 | 154 | } |
155 | 155 | else |
156 | 156 | { |
157 | - if(is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file)) |
|
157 | + if (is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file)) |
|
158 | 158 | { |
159 | - $buff = 'file://' . $this->compiled_file; |
|
159 | + $buff = 'file://'.$this->compiled_file; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - if($buff === FALSE) |
|
163 | + if ($buff === FALSE) |
|
164 | 164 | { |
165 | 165 | $buff = $this->parse(); |
166 | - if($oCacheHandler->isSupport()) |
|
166 | + if ($oCacheHandler->isSupport()) |
|
167 | 167 | { |
168 | 168 | $oCacheHandler->put($cache_key, $buff); |
169 | 169 | } |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | |
176 | 176 | $output = $this->_fetch($buff); |
177 | 177 | |
178 | - if($__templatehandler_root_tpl == $this->file) |
|
178 | + if ($__templatehandler_root_tpl == $this->file) |
|
179 | 179 | { |
180 | 180 | $__templatehandler_root_tpl = null; |
181 | 181 | } |
182 | 182 | |
183 | 183 | // store the ending time for debug information |
184 | - if(__DEBUG__ == 3) |
|
184 | + if (__DEBUG__ == 3) |
|
185 | 185 | { |
186 | 186 | $GLOBALS['__template_elapsed__'] += getMicroTime() - $start; |
187 | 187 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $this->init($tpl_path, $tpl_filename, null); |
201 | 201 | |
202 | 202 | // if target file does not exist exit |
203 | - if(!$this->file || !file_exists($this->file)) |
|
203 | + if (!$this->file || !file_exists($this->file)) |
|
204 | 204 | { |
205 | 205 | Context::close(); |
206 | 206 | exit("Cannot find the template file: '{$this->file}'"); |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | */ |
217 | 217 | protected function parse($buff = null) |
218 | 218 | { |
219 | - if(is_null($buff)) |
|
219 | + if (is_null($buff)) |
|
220 | 220 | { |
221 | - if(!is_readable($this->file)) |
|
221 | + if (!is_readable($this->file)) |
|
222 | 222 | { |
223 | 223 | return; |
224 | 224 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | } |
229 | 229 | |
230 | 230 | // HTML tags to skip |
231 | - if(is_null($this->skipTags)) |
|
231 | + if (is_null($this->skipTags)) |
|
232 | 232 | { |
233 | 233 | $this->skipTags = array('marquee'); |
234 | 234 | } |
@@ -250,13 +250,13 @@ discard block |
||
250 | 250 | |
251 | 251 | // form auto generation |
252 | 252 | $temp = preg_replace_callback('/(<form(?:<\?php.+?\?>|[^<>]+)*?>)(.*?)(<\/form>)/is', array($this, '_compileFormAuthGeneration'), $buff); |
253 | - if($temp) |
|
253 | + if ($temp) |
|
254 | 254 | { |
255 | 255 | $buff = $temp; |
256 | 256 | } |
257 | 257 | |
258 | 258 | // prevent from calling directly before writing into file |
259 | - $buff = '<?php if(!defined("__XE__"))exit;?>' . $buff; |
|
259 | + $buff = '<?php if(!defined("__XE__"))exit;?>'.$buff; |
|
260 | 260 | |
261 | 261 | // remove php script reopening |
262 | 262 | $buff = preg_replace(array('/(\n|\r\n)+/', '/(;)?( )*\?\>\<\?php([\n\t ]+)?/'), array("\n", ";\n"), $buff); |
@@ -276,40 +276,40 @@ discard block |
||
276 | 276 | private function _compileFormAuthGeneration($matches) |
277 | 277 | { |
278 | 278 | // form ruleset attribute move to hidden tag |
279 | - if($matches[1]) |
|
279 | + if ($matches[1]) |
|
280 | 280 | { |
281 | 281 | preg_match('/ruleset="([^"]*?)"/is', $matches[1], $m); |
282 | - if($m[0]) |
|
282 | + if ($m[0]) |
|
283 | 283 | { |
284 | - $matches[1] = preg_replace('/' . addcslashes($m[0], '?$') . '/i', '', $matches[1]); |
|
284 | + $matches[1] = preg_replace('/'.addcslashes($m[0], '?$').'/i', '', $matches[1]); |
|
285 | 285 | |
286 | - if(strpos($m[1], '@') !== FALSE) |
|
286 | + if (strpos($m[1], '@') !== FALSE) |
|
287 | 287 | { |
288 | 288 | $path = str_replace('@', '', $m[1]); |
289 | - $path = './files/ruleset/' . $path . '.xml'; |
|
289 | + $path = './files/ruleset/'.$path.'.xml'; |
|
290 | 290 | } |
291 | - else if(strpos($m[1], '#') !== FALSE) |
|
291 | + else if (strpos($m[1], '#') !== FALSE) |
|
292 | 292 | { |
293 | 293 | $fileName = str_replace('#', '', $m[1]); |
294 | 294 | $fileName = str_replace('<?php echo ', '', $fileName); |
295 | 295 | $fileName = str_replace(' ?>', '', $fileName); |
296 | - $path = '#./files/ruleset/' . $fileName . '.xml'; |
|
296 | + $path = '#./files/ruleset/'.$fileName.'.xml'; |
|
297 | 297 | |
298 | 298 | preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm); |
299 | 299 | $module_path = $mm[1]; |
300 | 300 | list($rulsetFile) = explode('.', $fileName); |
301 | - $autoPath = $module_path . '/ruleset/' . $rulsetFile . '.xml'; |
|
301 | + $autoPath = $module_path.'/ruleset/'.$rulsetFile.'.xml'; |
|
302 | 302 | $m[1] = $rulsetFile; |
303 | 303 | } |
304 | - else if(preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm)) |
|
304 | + else if (preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm)) |
|
305 | 305 | { |
306 | 306 | $module_path = $mm[1]; |
307 | - $path = $module_path . '/ruleset/' . $m[1] . '.xml'; |
|
307 | + $path = $module_path.'/ruleset/'.$m[1].'.xml'; |
|
308 | 308 | } |
309 | 309 | |
310 | - $matches[2] = '<input type="hidden" name="ruleset" value="' . $m[1] . '" />' . $matches[2]; |
|
310 | + $matches[2] = '<input type="hidden" name="ruleset" value="'.$m[1].'" />'.$matches[2]; |
|
311 | 311 | //assign to addJsFile method for js dynamic recache |
312 | - $matches[1] = '<?php Context::addJsFile("' . $path . '", FALSE, "", 0, "body", TRUE, "' . $autoPath . '") ?' . '>' . $matches[1]; |
|
312 | + $matches[1] = '<?php Context::addJsFile("'.$path.'", FALSE, "", 0, "body", TRUE, "'.$autoPath.'") ?'.'>'.$matches[1]; |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
@@ -317,22 +317,22 @@ discard block |
||
317 | 317 | preg_match_all('/<input[^>]* name="(act|mid|vid)"/is', $matches[2], $m2); |
318 | 318 | $checkVar = array('act', 'mid', 'vid'); |
319 | 319 | $resultArray = array_diff($checkVar, $m2[1]); |
320 | - if(is_array($resultArray)) |
|
320 | + if (is_array($resultArray)) |
|
321 | 321 | { |
322 | 322 | $generatedHidden = ''; |
323 | - foreach($resultArray AS $key => $value) |
|
323 | + foreach ($resultArray AS $key => $value) |
|
324 | 324 | { |
325 | - $generatedHidden .= '<input type="hidden" name="' . $value . '" value="<?php echo $__Context->' . $value . ' ?>" />'; |
|
325 | + $generatedHidden .= '<input type="hidden" name="'.$value.'" value="<?php echo $__Context->'.$value.' ?>" />'; |
|
326 | 326 | } |
327 | - $matches[2] = $generatedHidden . $matches[2]; |
|
327 | + $matches[2] = $generatedHidden.$matches[2]; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | // return url generate |
331 | - if(!preg_match('/no-error-return-url="true"/i', $matches[1])) |
|
331 | + if (!preg_match('/no-error-return-url="true"/i', $matches[1])) |
|
332 | 332 | { |
333 | 333 | preg_match('/<input[^>]*name="error_return_url"[^>]*>/is', $matches[2], $m3); |
334 | - if(!$m3[0]) |
|
335 | - $matches[2] = '<input type="hidden" name="error_return_url" value="<?php echo htmlspecialchars(getRequestUriByServerEnviroment(), ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" />' . $matches[2]; |
|
334 | + if (!$m3[0]) |
|
335 | + $matches[2] = '<input type="hidden" name="error_return_url" value="<?php echo htmlspecialchars(getRequestUriByServerEnviroment(), ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" />'.$matches[2]; |
|
336 | 336 | } |
337 | 337 | else |
338 | 338 | { |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | */ |
351 | 351 | private function _fetch($buff) |
352 | 352 | { |
353 | - if(!$buff) |
|
353 | + if (!$buff) |
|
354 | 354 | { |
355 | 355 | return; |
356 | 356 | } |
@@ -358,20 +358,20 @@ discard block |
||
358 | 358 | $__Context = &$GLOBALS['__Context__']; |
359 | 359 | $__Context->tpl_path = $this->path; |
360 | 360 | |
361 | - if($_SESSION['is_logged']) |
|
361 | + if ($_SESSION['is_logged']) |
|
362 | 362 | { |
363 | 363 | $__Context->logged_info = Context::get('logged_info'); |
364 | 364 | } |
365 | 365 | |
366 | 366 | $level = ob_get_level(); |
367 | 367 | ob_start(); |
368 | - if(substr($buff, 0, 7) == 'file://') |
|
368 | + if (substr($buff, 0, 7) == 'file://') |
|
369 | 369 | { |
370 | - if(__DEBUG__) |
|
370 | + if (__DEBUG__) |
|
371 | 371 | { |
372 | 372 | //load cache file from disk |
373 | 373 | $eval_str = FileHandler::readFile(substr($buff, 7)); |
374 | - $eval_str_buffed = "?>" . $eval_str; |
|
374 | + $eval_str_buffed = "?>".$eval_str; |
|
375 | 375 | @eval($eval_str_buffed); |
376 | 376 | $error_info = error_get_last(); |
377 | 377 | //parse error |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | } |
388 | 388 | else |
389 | 389 | { |
390 | - $eval_str = "?>" . $buff; |
|
390 | + $eval_str = "?>".$buff; |
|
391 | 391 | @eval($eval_str); |
392 | 392 | $error_info = error_get_last(); |
393 | 393 | //parse error |
@@ -416,31 +416,31 @@ discard block |
||
416 | 416 | private function _replacePath($match) |
417 | 417 | { |
418 | 418 | //return origin conde when src value started '${'. |
419 | - if(preg_match('@^\${@', $match[1])) |
|
419 | + if (preg_match('@^\${@', $match[1])) |
|
420 | 420 | { |
421 | 421 | return $match[0]; |
422 | 422 | } |
423 | 423 | |
424 | 424 | //return origin code when src value include variable. |
425 | - if(preg_match('@^[\'|"]\s*\.\s*\$@', $match[1])) |
|
425 | + if (preg_match('@^[\'|"]\s*\.\s*\$@', $match[1])) |
|
426 | 426 | { |
427 | 427 | return $match[0]; |
428 | 428 | } |
429 | 429 | |
430 | 430 | $src = preg_replace('@^(\./)+@', '', trim($match[1])); |
431 | 431 | |
432 | - $src = $this->web_path . $src; |
|
432 | + $src = $this->web_path.$src; |
|
433 | 433 | $src = str_replace('/./', '/', $src); |
434 | 434 | |
435 | 435 | // for backward compatibility |
436 | 436 | $src = preg_replace('@/((?:[\w-]+/)+)\1@', '/\1', $src); |
437 | 437 | |
438 | - while(($tmp = preg_replace('@[^/]+/\.\./@', '', $src, 1)) !== $src) |
|
438 | + while (($tmp = preg_replace('@[^/]+/\.\./@', '', $src, 1)) !== $src) |
|
439 | 439 | { |
440 | 440 | $src = $tmp; |
441 | 441 | } |
442 | 442 | |
443 | - return substr($match[0], 0, -strlen($match[1]) - 6) . "src=\"{$src}\""; |
|
443 | + return substr($match[0], 0, -strlen($match[1]) - 6)."src=\"{$src}\""; |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
@@ -450,19 +450,19 @@ discard block |
||
450 | 450 | */ |
451 | 451 | private function _parseInline($buff) |
452 | 452 | { |
453 | - if(!preg_match_all('/<([a-zA-Z]+\d?)(?:\s)/', $buff, $match)) |
|
453 | + if (!preg_match_all('/<([a-zA-Z]+\d?)(?:\s)/', $buff, $match)) |
|
454 | 454 | { |
455 | 455 | return $buff; |
456 | 456 | } |
457 | 457 | |
458 | 458 | $tags = array_diff(array_unique($match[1]), $this->skipTags); |
459 | 459 | |
460 | - if(!count($tags)) |
|
460 | + if (!count($tags)) |
|
461 | 461 | { |
462 | 462 | return $buff; |
463 | 463 | } |
464 | 464 | |
465 | - $tags = '(?:' . implode('|', $tags) . ')'; |
|
465 | + $tags = '(?:'.implode('|', $tags).')'; |
|
466 | 466 | $split_regex = "@(<(?>/?{$tags})(?>[^<>\{\}\"']+|<!--.*?-->|{[^}]+}|\".*?\"|'.*?'|.)*?>)@s"; |
467 | 467 | |
468 | 468 | $nodes = preg_split($split_regex, $buff, -1, PREG_SPLIT_DELIM_CAPTURE); |
@@ -470,14 +470,14 @@ discard block |
||
470 | 470 | // list of self closing tags |
471 | 471 | $self_closing = array('area' => 1, 'base' => 1, 'basefont' => 1, 'br' => 1, 'hr' => 1, 'input' => 1, 'img' => 1, 'link' => 1, 'meta' => 1, 'param' => 1, 'frame' => 1, 'col' => 1); |
472 | 472 | |
473 | - for($idx = 1, $node_len = count($nodes); $idx < $node_len; $idx+=2) |
|
473 | + for ($idx = 1, $node_len = count($nodes); $idx < $node_len; $idx += 2) |
|
474 | 474 | { |
475 | - if(!($node = $nodes[$idx])) |
|
475 | + if (!($node = $nodes[$idx])) |
|
476 | 476 | { |
477 | 477 | continue; |
478 | 478 | } |
479 | 479 | |
480 | - if(preg_match_all('@\s(loop|cond)="([^"]+)"@', $node, $matches)) |
|
480 | + if (preg_match_all('@\s(loop|cond)="([^"]+)"@', $node, $matches)) |
|
481 | 481 | { |
482 | 482 | // this tag |
483 | 483 | $tag = substr($node, 1, strpos($node, ' ') - 1); |
@@ -486,37 +486,37 @@ discard block |
||
486 | 486 | $closing = 0; |
487 | 487 | |
488 | 488 | // process opening tag |
489 | - foreach($matches[1] as $n => $stmt) |
|
489 | + foreach ($matches[1] as $n => $stmt) |
|
490 | 490 | { |
491 | 491 | $expr = $matches[2][$n]; |
492 | 492 | $expr = $this->_replaceVar($expr); |
493 | 493 | $closing++; |
494 | 494 | |
495 | - switch($stmt) |
|
495 | + switch ($stmt) |
|
496 | 496 | { |
497 | 497 | case 'cond': |
498 | 498 | $nodes[$idx - 1] .= "<?php if({$expr}){ ?>"; |
499 | 499 | break; |
500 | 500 | case 'loop': |
501 | - if(!preg_match('@^(?:(.+?)=>(.+?)(?:,(.+?))?|(.*?;.*?;.*?)|(.+?)\s*=\s*(.+?))$@', $expr, $expr_m)) |
|
501 | + if (!preg_match('@^(?:(.+?)=>(.+?)(?:,(.+?))?|(.*?;.*?;.*?)|(.+?)\s*=\s*(.+?))$@', $expr, $expr_m)) |
|
502 | 502 | { |
503 | 503 | break; |
504 | 504 | } |
505 | - if($expr_m[1]) |
|
505 | + if ($expr_m[1]) |
|
506 | 506 | { |
507 | 507 | $expr_m[1] = trim($expr_m[1]); |
508 | 508 | $expr_m[2] = trim($expr_m[2]); |
509 | - if($expr_m[3]) |
|
509 | + if ($expr_m[3]) |
|
510 | 510 | { |
511 | - $expr_m[2] .= '=>' . trim($expr_m[3]); |
|
511 | + $expr_m[2] .= '=>'.trim($expr_m[3]); |
|
512 | 512 | } |
513 | 513 | $nodes[$idx - 1] .= "<?php if({$expr_m[1]}&&count({$expr_m[1]}))foreach({$expr_m[1]} as {$expr_m[2]}){ ?>"; |
514 | 514 | } |
515 | - elseif($expr_m[4]) |
|
515 | + elseif ($expr_m[4]) |
|
516 | 516 | { |
517 | 517 | $nodes[$idx - 1] .= "<?php for({$expr_m[4]}){ ?>"; |
518 | 518 | } |
519 | - elseif($expr_m[5]) |
|
519 | + elseif ($expr_m[5]) |
|
520 | 520 | { |
521 | 521 | $nodes[$idx - 1] .= "<?php while({$expr_m[5]}={$expr_m[6]}){ ?>"; |
522 | 522 | } |
@@ -526,28 +526,28 @@ discard block |
||
526 | 526 | $node = preg_replace('@\s(loop|cond)="([^"]+)"@', '', $node); |
527 | 527 | |
528 | 528 | // find closing tag |
529 | - $close_php = '<?php ' . str_repeat('}', $closing) . ' ?>'; |
|
529 | + $close_php = '<?php '.str_repeat('}', $closing).' ?>'; |
|
530 | 530 | // self closing tag |
531 | - if($node{1} == '!' || substr($node, -2, 1) == '/' || isset($self_closing[$tag])) |
|
531 | + if ($node{1} == '!' || substr($node, -2, 1) == '/' || isset($self_closing[$tag])) |
|
532 | 532 | { |
533 | - $nodes[$idx + 1] = $close_php . $nodes[$idx + 1]; |
|
533 | + $nodes[$idx + 1] = $close_php.$nodes[$idx + 1]; |
|
534 | 534 | } |
535 | 535 | else |
536 | 536 | { |
537 | 537 | $depth = 1; |
538 | - for($i = $idx + 2; $i < $node_len; $i+=2) |
|
538 | + for ($i = $idx + 2; $i < $node_len; $i += 2) |
|
539 | 539 | { |
540 | 540 | $nd = $nodes[$i]; |
541 | - if(strpos($nd, $tag) === 1) |
|
541 | + if (strpos($nd, $tag) === 1) |
|
542 | 542 | { |
543 | 543 | $depth++; |
544 | 544 | } |
545 | - elseif(strpos($nd, '/' . $tag) === 1) |
|
545 | + elseif (strpos($nd, '/'.$tag) === 1) |
|
546 | 546 | { |
547 | 547 | $depth--; |
548 | - if(!$depth) |
|
548 | + if (!$depth) |
|
549 | 549 | { |
550 | - $nodes[$i - 1] .= $nodes[$i] . $close_php; |
|
550 | + $nodes[$i - 1] .= $nodes[$i].$close_php; |
|
551 | 551 | $nodes[$i] = ''; |
552 | 552 | break; |
553 | 553 | } |
@@ -556,13 +556,13 @@ discard block |
||
556 | 556 | } |
557 | 557 | } |
558 | 558 | |
559 | - if(strpos($node, '|cond="') !== false) |
|
559 | + if (strpos($node, '|cond="') !== false) |
|
560 | 560 | { |
561 | 561 | $node = preg_replace('@(\s[-\w:]+(?:="[^"]+?")?)\|cond="(.+?)"@s', '<?php if($2){ ?>$1<?php } ?>', $node); |
562 | 562 | $node = $this->_replaceVar($node); |
563 | 563 | } |
564 | 564 | |
565 | - if($nodes[$idx] != $node) |
|
565 | + if ($nodes[$idx] != $node) |
|
566 | 566 | { |
567 | 567 | $nodes[$idx] = $node; |
568 | 568 | } |
@@ -582,30 +582,30 @@ discard block |
||
582 | 582 | private function _parseResource($m) |
583 | 583 | { |
584 | 584 | // {@ ... } or {$var} or {func(...)} |
585 | - if($m[1]) |
|
585 | + if ($m[1]) |
|
586 | 586 | { |
587 | - if(preg_match('@^(\w+)\(@', $m[1], $mm) && !function_exists($mm[1])) |
|
587 | + if (preg_match('@^(\w+)\(@', $m[1], $mm) && !function_exists($mm[1])) |
|
588 | 588 | { |
589 | 589 | return $m[0]; |
590 | 590 | } |
591 | 591 | |
592 | 592 | $echo = 'echo '; |
593 | - if($m[1]{0} == '@') |
|
593 | + if ($m[1]{0} == '@') |
|
594 | 594 | { |
595 | 595 | $echo = ''; |
596 | 596 | $m[1] = substr($m[1], 1); |
597 | 597 | } |
598 | - return '<?php ' . $echo . $this->_replaceVar($m[1]) . ' ?>'; |
|
598 | + return '<?php '.$echo.$this->_replaceVar($m[1]).' ?>'; |
|
599 | 599 | } |
600 | 600 | |
601 | - if($m[3]) |
|
601 | + if ($m[3]) |
|
602 | 602 | { |
603 | 603 | $attr = array(); |
604 | - if($m[5]) |
|
604 | + if ($m[5]) |
|
605 | 605 | { |
606 | - if(preg_match_all('@,(\w+)="([^"]+)"@', $m[6], $mm)) |
|
606 | + if (preg_match_all('@,(\w+)="([^"]+)"@', $m[6], $mm)) |
|
607 | 607 | { |
608 | - foreach($mm[1] as $idx => $name) |
|
608 | + foreach ($mm[1] as $idx => $name) |
|
609 | 609 | { |
610 | 610 | $attr[$name] = $mm[2][$idx]; |
611 | 611 | } |
@@ -614,21 +614,21 @@ discard block |
||
614 | 614 | } |
615 | 615 | else |
616 | 616 | { |
617 | - if(!preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $mm)) |
|
617 | + if (!preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $mm)) |
|
618 | 618 | { |
619 | 619 | return $m[0]; |
620 | 620 | } |
621 | - foreach($mm[1] as $idx => $name) |
|
621 | + foreach ($mm[1] as $idx => $name) |
|
622 | 622 | { |
623 | 623 | $attr[$name] = $mm[2][$idx]; |
624 | 624 | } |
625 | 625 | } |
626 | 626 | |
627 | - switch($m[3]) |
|
627 | + switch ($m[3]) |
|
628 | 628 | { |
629 | 629 | // <!--#include--> or <include ..> |
630 | 630 | case 'include': |
631 | - if(!$this->file || !$attr['target']) |
|
631 | + if (!$this->file || !$attr['target']) |
|
632 | 632 | { |
633 | 633 | return ''; |
634 | 634 | } |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | $pathinfo = pathinfo($attr['target']); |
637 | 637 | $fileDir = $this->_getRelativeDir($pathinfo['dirname']); |
638 | 638 | |
639 | - if(!$fileDir) |
|
639 | + if (!$fileDir) |
|
640 | 640 | { |
641 | 641 | return ''; |
642 | 642 | } |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | case 'load_js_plugin': |
647 | 647 | $plugin = $this->_replaceVar($m[5]); |
648 | 648 | $s = "<!--#JSPLUGIN:{$plugin}-->"; |
649 | - if(strpos($plugin, '$__Context') === false) |
|
649 | + if (strpos($plugin, '$__Context') === false) |
|
650 | 650 | { |
651 | 651 | $plugin = "'{$plugin}'"; |
652 | 652 | } |
@@ -662,13 +662,13 @@ discard block |
||
662 | 662 | $doUnload = ($m[3] === 'unload'); |
663 | 663 | $isRemote = !!preg_match('@^(https?:)?//@i', $attr['target']); |
664 | 664 | |
665 | - if(!$isRemote) |
|
665 | + if (!$isRemote) |
|
666 | 666 | { |
667 | - if(!preg_match('@^\.?/@', $attr['target'])) |
|
667 | + if (!preg_match('@^\.?/@', $attr['target'])) |
|
668 | 668 | { |
669 | - $attr['target'] = './' . $attr['target']; |
|
669 | + $attr['target'] = './'.$attr['target']; |
|
670 | 670 | } |
671 | - if(substr($attr['target'], -5) == '/lang') |
|
671 | + if (substr($attr['target'], -5) == '/lang') |
|
672 | 672 | { |
673 | 673 | $pathinfo['dirname'] .= '/lang'; |
674 | 674 | $pathinfo['basename'] = ''; |
@@ -677,18 +677,18 @@ discard block |
||
677 | 677 | |
678 | 678 | $relativeDir = $this->_getRelativeDir($pathinfo['dirname']); |
679 | 679 | |
680 | - $attr['target'] = $relativeDir . '/' . $pathinfo['basename']; |
|
680 | + $attr['target'] = $relativeDir.'/'.$pathinfo['basename']; |
|
681 | 681 | } |
682 | 682 | |
683 | - switch($pathinfo['extension']) |
|
683 | + switch ($pathinfo['extension']) |
|
684 | 684 | { |
685 | 685 | case 'xml': |
686 | - if($isRemote || $doUnload) |
|
686 | + if ($isRemote || $doUnload) |
|
687 | 687 | { |
688 | 688 | return ''; |
689 | 689 | } |
690 | 690 | // language file? |
691 | - if($pathinfo['basename'] == 'lang.xml' || substr($pathinfo['dirname'], -5) == '/lang') |
|
691 | + if ($pathinfo['basename'] == 'lang.xml' || substr($pathinfo['dirname'], -5) == '/lang') |
|
692 | 692 | { |
693 | 693 | $result = "Context::loadLang('{$relativeDir}');"; |
694 | 694 | } |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | } |
699 | 699 | break; |
700 | 700 | case 'js': |
701 | - if($doUnload) |
|
701 | + if ($doUnload) |
|
702 | 702 | { |
703 | 703 | $result = "Context::unloadFile('{$attr['target']}','{$attr['targetie']}');"; |
704 | 704 | } |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | } |
710 | 710 | break; |
711 | 711 | case 'css': |
712 | - if($doUnload) |
|
712 | + if ($doUnload) |
|
713 | 713 | { |
714 | 714 | $result = "Context::unloadFile('{$attr['target']}','{$attr['targetie']}','{$attr['media']}');"; |
715 | 715 | } |
@@ -722,9 +722,9 @@ discard block |
||
722 | 722 | } |
723 | 723 | |
724 | 724 | $result = "<?php {$result} ?>"; |
725 | - if($metafile) |
|
725 | + if ($metafile) |
|
726 | 726 | { |
727 | - $result = "<!--#Meta:{$metafile}-->" . $result; |
|
727 | + $result = "<!--#Meta:{$metafile}-->".$result; |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | return $result; |
@@ -732,45 +732,45 @@ discard block |
||
732 | 732 | } |
733 | 733 | |
734 | 734 | // <[email protected]> such as <!--@if($cond)-->, <!--@else-->, <!--@end--> |
735 | - if($m[7]) |
|
735 | + if ($m[7]) |
|
736 | 736 | { |
737 | 737 | $m[7] = substr($m[7], 1); |
738 | - if(!$m[7]) |
|
738 | + if (!$m[7]) |
|
739 | 739 | { |
740 | - return '<?php ' . $this->_replaceVar($m[8]) . '{ ?>' . $m[9]; |
|
740 | + return '<?php '.$this->_replaceVar($m[8]).'{ ?>'.$m[9]; |
|
741 | 741 | } |
742 | - if(!preg_match('/^(?:((?:end)?(?:if|switch|for(?:each)?|while)|end)|(else(?:if)?)|(break@)?(case|default)|(break))$/', $m[7], $mm)) |
|
742 | + if (!preg_match('/^(?:((?:end)?(?:if|switch|for(?:each)?|while)|end)|(else(?:if)?)|(break@)?(case|default)|(break))$/', $m[7], $mm)) |
|
743 | 743 | { |
744 | 744 | return ''; |
745 | 745 | } |
746 | - if($mm[1]) |
|
746 | + if ($mm[1]) |
|
747 | 747 | { |
748 | - if($mm[1]{0} == 'e') |
|
748 | + if ($mm[1]{0} == 'e') |
|
749 | 749 | { |
750 | - return '<?php } ?>' . $m[9]; |
|
750 | + return '<?php } ?>'.$m[9]; |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | $precheck = ''; |
754 | - if($mm[1] == 'switch') |
|
754 | + if ($mm[1] == 'switch') |
|
755 | 755 | { |
756 | 756 | $m[9] = ''; |
757 | 757 | } |
758 | - elseif($mm[1] == 'foreach') |
|
758 | + elseif ($mm[1] == 'foreach') |
|
759 | 759 | { |
760 | 760 | $var = preg_replace('/^\s*\(\s*(.+?) .*$/', '$1', $m[8]); |
761 | 761 | $precheck = "if({$var}&&count({$var}))"; |
762 | 762 | } |
763 | - return '<?php ' . $this->_replaceVar($precheck . $m[7] . $m[8]) . '{ ?>' . $m[9]; |
|
763 | + return '<?php '.$this->_replaceVar($precheck.$m[7].$m[8]).'{ ?>'.$m[9]; |
|
764 | 764 | } |
765 | - if($mm[2]) |
|
765 | + if ($mm[2]) |
|
766 | 766 | { |
767 | - return "<?php }{$m[7]}" . $this->_replaceVar($m[8]) . "{ ?>" . $m[9]; |
|
767 | + return "<?php }{$m[7]}".$this->_replaceVar($m[8])."{ ?>".$m[9]; |
|
768 | 768 | } |
769 | - if($mm[4]) |
|
769 | + if ($mm[4]) |
|
770 | 770 | { |
771 | - return "<?php " . ($mm[3] ? 'break;' : '') . "{$m[7]} " . trim($m[8], '()') . ": ?>" . $m[9]; |
|
771 | + return "<?php ".($mm[3] ? 'break;' : '')."{$m[7]} ".trim($m[8], '()').": ?>".$m[9]; |
|
772 | 772 | } |
773 | - if($mm[5]) |
|
773 | + if ($mm[5]) |
|
774 | 774 | { |
775 | 775 | return "<?php break; ?>"; |
776 | 776 | } |
@@ -789,30 +789,30 @@ discard block |
||
789 | 789 | $_path = $path; |
790 | 790 | |
791 | 791 | $fileDir = strtr(realpath($this->path), '\\', '/'); |
792 | - if($path{0} != '/') |
|
792 | + if ($path{0} != '/') |
|
793 | 793 | { |
794 | - $path = strtr(realpath($fileDir . '/' . $path), '\\', '/'); |
|
794 | + $path = strtr(realpath($fileDir.'/'.$path), '\\', '/'); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | // for backward compatibility |
798 | - if(!$path) |
|
798 | + if (!$path) |
|
799 | 799 | { |
800 | 800 | $dirs = explode('/', $fileDir); |
801 | 801 | $paths = explode('/', $_path); |
802 | 802 | $idx = array_search($paths[0], $dirs); |
803 | 803 | |
804 | - if($idx !== false) |
|
804 | + if ($idx !== false) |
|
805 | 805 | { |
806 | - while($dirs[$idx] && $dirs[$idx] === $paths[0]) |
|
806 | + while ($dirs[$idx] && $dirs[$idx] === $paths[0]) |
|
807 | 807 | { |
808 | 808 | array_splice($dirs, $idx, 1); |
809 | 809 | array_shift($paths); |
810 | 810 | } |
811 | - $path = strtr(realpath($fileDir . '/' . implode('/', $paths)), '\\', '/'); |
|
811 | + $path = strtr(realpath($fileDir.'/'.implode('/', $paths)), '\\', '/'); |
|
812 | 812 | } |
813 | 813 | } |
814 | 814 | |
815 | - $path = preg_replace('/^' . preg_quote(_XE_PATH_, '/') . '/', '', $path); |
|
815 | + $path = preg_replace('/^'.preg_quote(_XE_PATH_, '/').'/', '', $path); |
|
816 | 816 | |
817 | 817 | return $path; |
818 | 818 | } |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | */ |
825 | 825 | function _replaceVar($php) |
826 | 826 | { |
827 | - if(!strlen($php)) |
|
827 | + if (!strlen($php)) |
|
828 | 828 | { |
829 | 829 | return ''; |
830 | 830 | } |