| Conditions | 21 |
| Paths | 96 |
| Total Lines | 70 |
| Code Lines | 55 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 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 |
||
| 16 | public function main($id, $mode) |
||
| 17 | { |
||
| 18 | global $config, $user, $template, $request; |
||
| 19 | |||
| 20 | $user->add_lang_ext('tas2580/socialbuttons', 'common'); |
||
| 21 | $this->tpl_name = 'acp_socialbuttons_body'; |
||
| 22 | $this->page_title = $user->lang('ACP_SOCIALBUTTONS_TITLE'); |
||
| 23 | |||
| 24 | add_form_key('acp_socialbuttons'); |
||
| 25 | |||
| 26 | // Form is submitted |
||
| 27 | if ($request->is_set_post('submit')) |
||
| 28 | { |
||
| 29 | if (!check_form_key('acp_socialbuttons')) |
||
| 30 | { |
||
| 31 | trigger_error($user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); |
||
| 32 | } |
||
| 33 | $forums = implode(',', $request->variable('enable_f', array(0))); |
||
| 34 | $desc_forums = implode(',', $request->variable('enable_og_desc_f', array(0))); |
||
| 35 | // Set the new settings to config |
||
| 36 | $config->set('socialbuttons_position', $request->variable('position', 0)); |
||
| 37 | $config->set('socialbuttons_enable_forums', $forums); |
||
| 38 | $config->set('socialbuttons_display_on_index', $request->variable('display_on_index', 0)); |
||
| 39 | $config->set('socialbuttons_enable', $request->variable('enable', 0)); |
||
| 40 | $config->set('socialbuttons_cachetime', $request->variable('cachetime', 0)); |
||
| 41 | $config->set('socialbuttons_multiplicator', $request->variable('multiplicator', 1)); |
||
| 42 | $config->set('socialbuttons_facebook', $request->variable('facebook', 0)); |
||
| 43 | $config->set('socialbuttons_twitter', $request->variable('twitter', 0)); |
||
| 44 | $config->set('socialbuttons_google', $request->variable('google', 0)); |
||
| 45 | $config->set('socialbuttons_linkedin', $request->variable('linkedin', 0)); |
||
| 46 | $config->set('socialbuttons_style', $request->variable('style', 1)); |
||
| 47 | $config->set('socialbuttons_showshares', $request->variable('showshares', 0)); |
||
| 48 | $config->set('socialbuttons_use_seo_urls', $request->variable('use_seo_urls', '')); |
||
| 49 | $config->set('socialbuttons_enable_og', $request->variable('enable_og', 0)); |
||
| 50 | $config->set('socialbuttons_enable_og_title', $request->variable('enable_og_title', 0)); |
||
| 51 | $config->set('socialbuttons_enable_og_desc', $request->variable('enable_og_desc', 0)); |
||
| 52 | $config->set('socialbuttons_og_image', $request->variable('og_image', '')); |
||
| 53 | $config->set('socialbuttons_enable_og_desc_forums', $desc_forums); |
||
| 54 | trigger_error($user->lang('ACP_SAVED') . adm_back_link($this->u_action)); |
||
| 55 | } |
||
| 56 | |||
| 57 | // Send the curent settings to template |
||
| 58 | $position = isset($config['socialbuttons_position']) ? $config['socialbuttons_position'] : false; |
||
| 59 | $multiplicator = isset($config['socialbuttons_multiplicator']) ? $config['socialbuttons_multiplicator'] : true; |
||
| 60 | $style = isset($config['socialbuttons_style']) ? $config['socialbuttons_style'] : true; |
||
| 61 | $desc_forums = isset($config['socialbuttons_enable_og_desc_forums']) ? explode(',', $config['socialbuttons_enable_og_desc_forums']) : array(); |
||
| 62 | $forums = isset($config['socialbuttons_enable_forums']) ? explode(',', $config['socialbuttons_enable_forums']) : array(); |
||
| 63 | |||
| 64 | $template->assign_vars(array( |
||
| 65 | 'U_ACTION' => $this->u_action, |
||
| 66 | 'POSITION_OPTIONS' => $this->position_select($position), |
||
| 67 | 'MULTIPLICATOR_OPTIONS' => $this->multiplicator_select($multiplicator), |
||
| 68 | 'BUTTON_STYLES' => $this->button_style($style), |
||
| 69 | 'S_ENABLE' => isset($config['socialbuttons_enable']) ? $config['socialbuttons_enable'] : false, |
||
| 70 | 'S_DISPLAY_ON_INDEX' => isset($config['socialbuttons_display_on_index']) ? $config['socialbuttons_display_on_index'] : false, |
||
| 71 | 'S_USE_SEO_URLS' => isset($config['socialbuttons_use_seo_urls']) ? $config['socialbuttons_use_seo_urls'] : false, |
||
| 72 | 'S_SHOWSHARES' => isset($config['socialbuttons_showshares']) ? $config['socialbuttons_showshares'] : false, |
||
| 73 | 'CACHETIME' => isset($config['socialbuttons_cachetime']) ? $config['socialbuttons_cachetime'] : false, |
||
| 74 | 'S_FACEBOOK' => isset($config['socialbuttons_facebook']) ? $config['socialbuttons_facebook'] : '', |
||
| 75 | 'S_TWITTER' => isset($config['socialbuttons_twitter']) ? $config['socialbuttons_twitter'] : '', |
||
| 76 | 'S_GOOGLE' => isset($config['socialbuttons_google']) ? $config['socialbuttons_google'] : '', |
||
| 77 | 'S_LINKEDIN' => isset($config['socialbuttons_linkedin']) ? $config['socialbuttons_linkedin'] : '', |
||
| 78 | 'S_ENABLE_OG' => isset($config['socialbuttons_enable_og']) ? $config['socialbuttons_enable_og'] : '', |
||
| 79 | 'S_ENABLE_OG_TITLE' => isset($config['socialbuttons_enable_og_title']) ? $config['socialbuttons_enable_og_title'] : '', |
||
| 80 | 'S_ENABLE_OG_DESC' => isset($config['socialbuttons_enable_og_desc']) ? $config['socialbuttons_enable_og_desc'] : '', |
||
| 81 | 'OG_IMAGE' => isset($config['socialbuttons_og_image']) ? $config['socialbuttons_og_image'] : '', |
||
| 82 | 'FORUM_DESC_SELECT' => make_forum_select($desc_forums, false, false, true), |
||
| 83 | 'FORUM_ENABLE_SELECT' => make_forum_select($forums, false, false, true), |
||
| 84 | )); |
||
| 85 | } |
||
| 86 | |||
| 139 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.