Conditions | 14 |
Paths | 4608 |
Total Lines | 113 |
Code Lines | 81 |
Lines | 7 |
Ratio | 6.19 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
21 | function dispEditorAdminIndex() |
||
22 | { |
||
23 | $component_count = 0; |
||
24 | $site_module_info = Context::get('site_module_info'); |
||
25 | $site_srl = (int)$site_module_info->site_srl; |
||
26 | |||
27 | // Get a type of component |
||
28 | $oEditorModel = getModel('editor'); |
||
29 | $oModuleModel = getModel('module'); |
||
30 | $editor_config = $oModuleModel->getModuleConfig('editor'); |
||
31 | |||
32 | if(!$editor_config) |
||
33 | { |
||
34 | $editor_config = new stdClass(); |
||
35 | } |
||
36 | |||
37 | //editor_config init |
||
38 | if(!$editor_config->editor_height) $editor_config->editor_height = 300; |
||
39 | if(!$editor_config->comment_editor_height) $editor_config->comment_editor_height = 100; |
||
40 | if(!$editor_config->editor_skin) $editor_config->editor_skin = 'ckeditor'; |
||
41 | if(!$editor_config->comment_editor_skin) $editor_config->comment_editor_skin = 'ckeditor'; |
||
42 | if(!$editor_config->sel_editor_colorset) $editor_config->sel_editor_colorset= 'moono'; |
||
43 | if(!$editor_config->sel_comment_editor_colorset) $editor_config->sel_comment_editor_colorset= 'moono'; |
||
44 | |||
45 | $component_list = $oEditorModel->getComponentList(false, $site_srl, true); |
||
46 | $editor_skin_list = FileHandler::readDir(_XE_PATH_.'modules/editor/skins'); |
||
47 | |||
48 | $skin_info = $oModuleModel->loadSkinInfo($this->module_path,$editor_config->editor_skin); |
||
|
|||
49 | |||
50 | $contents = FileHandler::readDir(_XE_PATH_.'modules/editor/styles'); |
||
51 | $content_style_list = array(); |
||
52 | View Code Duplication | for($i=0,$c=count($contents);$i<$c;$i++) |
|
53 | { |
||
54 | $style = $contents[$i]; |
||
55 | $info = $oModuleModel->loadSkinInfo($this->module_path,$style,'styles'); |
||
56 | $content_style_list[$style] = new stdClass(); |
||
57 | $content_style_list[$style]->title = $info->title; |
||
58 | } |
||
59 | |||
60 | // Get install info, update info, count |
||
61 | $oAutoinstallModel = getModel('autoinstall'); |
||
62 | foreach($component_list as $component_name => $xml_info) |
||
63 | { |
||
64 | $component_count++; |
||
65 | $xml_info->path = './modules/editor/components/'.$xml_info->component_name; |
||
66 | $xml_info->delete_url = $oAutoinstallModel->getRemoveUrlByPath($xml_info->path); |
||
67 | $xml_info->package_srl = $oAutoinstallModel->getPackageSrlByPath($xml_info->path); |
||
68 | if($xml_info->package_srl) $targetpackages[$xml_info->package_srl] = 0; |
||
69 | } |
||
70 | |||
71 | if(is_array($targetpackages)) $packages = $oAutoinstallModel->getInstalledPackages(array_keys($targetpackages)); |
||
72 | |||
73 | foreach($component_list as $component_name => $xml_info) |
||
74 | { |
||
75 | if($packages[$xml_info->package_srl]) $xml_info->need_update = $packages[$xml_info->package_srl]->need_update; |
||
76 | } |
||
77 | $editor_config_default = array( "editor_height" => "300", "comment_editor_height" => "100","content_font_size"=>"13"); |
||
78 | |||
79 | //editor preview |
||
80 | $config = $oEditorModel->getEditorConfig(); |
||
81 | |||
82 | $option = new stdClass(); |
||
83 | $option->allow_fileupload = false; |
||
84 | $option->content_style = $config->content_style; |
||
85 | $option->content_font = $config->content_font; |
||
86 | $option->content_font_size = $config->content_font_size; |
||
87 | $option->enable_autosave = false; |
||
88 | $option->enable_default_component = true; |
||
89 | $option->enable_component = true; |
||
90 | $option->disable_html = false; |
||
91 | $option->height = $config->editor_height; |
||
92 | $option->skin = $config->editor_skin; |
||
93 | $option->content_key_name = 'dummy_content'; |
||
94 | $option->primary_key_name = 'dummy_key'; |
||
95 | $option->colorset = $config->sel_editor_colorset; |
||
96 | $editor = $oEditorModel->getEditor(0, $option); |
||
97 | |||
98 | Context::set('preview_editor', $editor); |
||
99 | |||
100 | $option_com = new stdClass(); |
||
101 | $option_com->allow_fileupload = false; |
||
102 | $option_com->content_style = $config->content_style; |
||
103 | $option_com->content_font = $config->content_font; |
||
104 | $option_com->content_font_size = $config->content_font_size; |
||
105 | $option_com->enable_autosave = false; |
||
106 | $option_com->enable_default_component = true; |
||
107 | $option_com->enable_component = true; |
||
108 | $option_com->disable_html = false; |
||
109 | $option_com->height = $config->comment_editor_height; |
||
110 | $option_com->skin = $config->comment_editor_skin; |
||
111 | $option_com->content_key_name = 'dummy_content2'; |
||
112 | $option_com->primary_key_name = 'dummy_key2'; |
||
113 | $option_com->content_style = $config->comment_content_style; |
||
114 | $option_com->colorset = $config->sel_comment_editor_colorset; |
||
115 | |||
116 | $editor_comment = $oEditorModel->getEditor(0, $option_com); |
||
117 | |||
118 | Context::set('preview_editor_comment', $editor_comment); |
||
119 | |||
120 | Context::set('editor_config', $editor_config); |
||
121 | Context::set('editor_skin_list', $editor_skin_list); |
||
122 | Context::set('editor_colorset_list', $skin_info->colorset); |
||
123 | Context::set('content_style_list', $content_style_list); |
||
124 | Context::set('component_list', $component_list); |
||
125 | Context::set('component_count', $component_count); |
||
126 | Context::set('editor_config_default', $editor_config_default); |
||
127 | |||
128 | $security = new Security(); |
||
129 | $security->encodeHTML('component_list....'); |
||
130 | |||
131 | $this->setTemplatePath($this->module_path.'tpl'); |
||
132 | $this->setTemplateFile('admin_index'); |
||
133 | } |
||
134 | |||
190 |
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.