| Conditions | 30 |
| Paths | 16 |
| Total Lines | 180 |
| Code Lines | 67 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 16 | function template_modify_subscription() |
||
| 17 | { |
||
| 18 | global $context, $scripturl, $txt, $modSettings; |
||
| 19 | |||
| 20 | echo ' |
||
| 21 | <div id="admincenter"> |
||
| 22 | <form action="', $scripturl, '?action=admin;area=paidsubscribe;sa=modify;sid=', $context['sub_id'], '" method="post"> |
||
| 23 | <div class="cat_bar"> |
||
| 24 | <h3 class="catbg">', $txt['paid_' . $context['action_type'] . '_subscription'], '</h3> |
||
| 25 | </div>'; |
||
| 26 | |||
| 27 | if (!empty($context['disable_groups'])) |
||
| 28 | echo ' |
||
| 29 | <div class="information"> |
||
| 30 | <span class="alert">', $txt['paid_mod_edit_note'], '</span> |
||
| 31 | </div>'; |
||
| 32 | |||
| 33 | echo ' |
||
| 34 | <div class="windowbg2"> |
||
| 35 | <dl class="settings"> |
||
| 36 | <dt> |
||
| 37 | ', $txt['paid_mod_name'], ': |
||
| 38 | </dt> |
||
| 39 | <dd> |
||
| 40 | <input type="text" name="name" value="', $context['sub']['name'], '" size="30" class="input_text"> |
||
| 41 | </dd> |
||
| 42 | <dt> |
||
| 43 | ', $txt['paid_mod_desc'], ': |
||
| 44 | </dt> |
||
| 45 | <dd> |
||
| 46 | <textarea name="desc" rows="3" cols="40">', $context['sub']['desc'], '</textarea> |
||
| 47 | </dd> |
||
| 48 | <dt> |
||
| 49 | <label for="repeatable_check">', $txt['paid_mod_repeatable'], '</label>: |
||
| 50 | </dt> |
||
| 51 | <dd> |
||
| 52 | <input type="checkbox" name="repeatable" id="repeatable_check"', empty($context['sub']['repeatable']) ? '' : ' checked', ' class="input_check"> |
||
| 53 | </dd> |
||
| 54 | <dt> |
||
| 55 | <label for="activated_check">', $txt['paid_mod_active'], '</label>:<br><span class="smalltext">', $txt['paid_mod_active_desc'], '</span> |
||
| 56 | </dt> |
||
| 57 | <dd> |
||
| 58 | <input type="checkbox" name="active" id="activated_check"', empty($context['sub']['active']) ? '' : ' checked', ' class="input_check"> |
||
| 59 | </dd> |
||
| 60 | </dl> |
||
| 61 | <hr> |
||
| 62 | <dl class="settings"> |
||
| 63 | <dt> |
||
| 64 | ', $txt['paid_mod_prim_group'], ':<br><span class="smalltext">', $txt['paid_mod_prim_group_desc'], '</span> |
||
| 65 | </dt> |
||
| 66 | <dd> |
||
| 67 | <select name="prim_group"', !empty($context['disable_groups']) ? ' disabled' : '', '> |
||
| 68 | <option value="0"', $context['sub']['prim_group'] == 0 ? ' selected' : '', '>', $txt['paid_mod_no_group'], '</option>'; |
||
| 69 | |||
| 70 | // Put each group into the box. |
||
| 71 | foreach ($context['groups'] as $id => $name) |
||
| 72 | echo ' |
||
| 73 | <option value="', $id, '"', $context['sub']['prim_group'] == $id ? ' selected' : '', '>', $name, '</option>'; |
||
| 74 | |||
| 75 | echo ' |
||
| 76 | </select> |
||
| 77 | </dd> |
||
| 78 | <dt> |
||
| 79 | ', $txt['paid_mod_add_groups'], ':<br><span class="smalltext">', $txt['paid_mod_add_groups_desc'], '</span> |
||
| 80 | </dt> |
||
| 81 | <dd>'; |
||
| 82 | |||
| 83 | // Put a checkbox in for each group |
||
| 84 | foreach ($context['groups'] as $id => $name) |
||
| 85 | echo ' |
||
| 86 | <label for="addgroup_', $id, '"><input type="checkbox" id="addgroup_', $id, '" name="addgroup[', $id, ']"', in_array($id, $context['sub']['add_groups']) ? ' checked' : '', !empty($context['disable_groups']) ? ' disabled' : '', ' class="input_check"> <span class="smalltext">', $name, '</span></label><br>'; |
||
| 87 | |||
| 88 | echo ' |
||
| 89 | </dd> |
||
| 90 | <dt> |
||
| 91 | ', $txt['paid_mod_reminder'], ':<br><span class="smalltext">', $txt['paid_mod_reminder_desc'], ' ', $txt['zero_to_disable'], '</span> |
||
| 92 | </dt> |
||
| 93 | <dd> |
||
| 94 | <input type="number" name="reminder" value="', $context['sub']['reminder'], '" size="6" class="input_text"> |
||
| 95 | </dd> |
||
| 96 | <dt> |
||
| 97 | ', $txt['paid_mod_email'], ':<br><span class="smalltext">', $txt['paid_mod_email_desc'], '</span> |
||
| 98 | </dt> |
||
| 99 | <dd> |
||
| 100 | <textarea name="emailcomplete" rows="6" cols="40">', $context['sub']['email_complete'], '</textarea> |
||
| 101 | </dd> |
||
| 102 | </dl> |
||
| 103 | <hr> |
||
| 104 | <input type="radio" name="duration_type" id="duration_type_fixed" value="fixed"', empty($context['sub']['duration']) || $context['sub']['duration'] == 'fixed' ? ' checked' : '', ' class="input_radio" onclick="toggleDuration(\'fixed\');"> |
||
| 105 | <strong><label for="duration_type_fixed">', $txt['paid_mod_fixed_price'], '</label></strong> |
||
| 106 | <br> |
||
| 107 | <div id="fixed_area" ', empty($context['sub']['duration']) || $context['sub']['duration'] == 'fixed' ? '' : 'style="display: none;"', '> |
||
| 108 | <fieldset> |
||
| 109 | <dl class="settings"> |
||
| 110 | <dt> |
||
| 111 | ', $txt['paid_cost'], ' (', str_replace('%1.2f', '', $modSettings['paid_currency_symbol']), '): |
||
| 112 | </dt> |
||
| 113 | <dd> |
||
| 114 | <input type="number" name="cost" value="', empty($context['sub']['cost']['fixed']) ? '0' : $context['sub']['cost']['fixed'], '" size="4" class="input_text"> |
||
| 115 | </dd> |
||
| 116 | <dt> |
||
| 117 | ', $txt['paid_mod_span'], ': |
||
| 118 | </dt> |
||
| 119 | <dd> |
||
| 120 | <input type="number" name="span_value" value="', $context['sub']['span']['value'], '" size="4" class="input_text"> |
||
| 121 | <select name="span_unit"> |
||
| 122 | <option value="D"', $context['sub']['span']['unit'] == 'D' ? ' selected' : '', '>', $txt['paid_mod_span_days'], '</option> |
||
| 123 | <option value="W"', $context['sub']['span']['unit'] == 'W' ? ' selected' : '', '>', $txt['paid_mod_span_weeks'], '</option> |
||
| 124 | <option value="M"', $context['sub']['span']['unit'] == 'M' ? ' selected' : '', '>', $txt['paid_mod_span_months'], '</option> |
||
| 125 | <option value="Y"', $context['sub']['span']['unit'] == 'Y' ? ' selected' : '', '>', $txt['paid_mod_span_years'], '</option> |
||
| 126 | </select> |
||
| 127 | </dd> |
||
| 128 | </dl> |
||
| 129 | </fieldset> |
||
| 130 | </div> |
||
| 131 | <input type="radio" name="duration_type" id="duration_type_flexible" value="flexible"', !empty($context['sub']['duration']) && $context['sub']['duration'] == 'flexible' ? ' checked' : '', ' class="input_radio" onclick="toggleDuration(\'flexible\');"> |
||
| 132 | <strong><label for="duration_type_flexible">', $txt['paid_mod_flexible_price'], '</label></strong> |
||
| 133 | <br> |
||
| 134 | <div id="flexible_area" ', !empty($context['sub']['duration']) && $context['sub']['duration'] == 'flexible' ? '' : 'style="display: none;"', '> |
||
| 135 | <fieldset>'; |
||
| 136 | |||
| 137 | //!! Removed until implemented |
||
| 138 | if (!empty($sdflsdhglsdjgs)) |
||
|
|
|||
| 139 | echo ' |
||
| 140 | <dl class="settings"> |
||
| 141 | <dt> |
||
| 142 | <label for="allow_partial_check">', $txt['paid_mod_allow_partial'], '</label>:<br><span class="smalltext">', $txt['paid_mod_allow_partial_desc'], '</span> |
||
| 143 | </dt> |
||
| 144 | <dd> |
||
| 145 | <input type="checkbox" name="allow_partial" id="allow_partial_check"', empty($context['sub']['allow_partial']) ? '' : ' checked', ' class="input_check"> |
||
| 146 | </dd> |
||
| 147 | </dl>'; |
||
| 148 | |||
| 149 | echo ' |
||
| 150 | <div class="information"> |
||
| 151 | <strong>', $txt['paid_mod_price_breakdown'], '</strong><br> |
||
| 152 | ', $txt['paid_mod_price_breakdown_desc'], ' |
||
| 153 | </div> |
||
| 154 | <dl class="settings"> |
||
| 155 | <dt> |
||
| 156 | <strong>', $txt['paid_duration'], '</strong> |
||
| 157 | </dt> |
||
| 158 | <dd> |
||
| 159 | <strong>', $txt['paid_cost'], ' (', preg_replace('~%[df\.\d]+~', '', $modSettings['paid_currency_symbol']), ')</strong> |
||
| 160 | </dd> |
||
| 161 | <dt> |
||
| 162 | ', $txt['paid_per_day'], ': |
||
| 163 | </dt> |
||
| 164 | <dd> |
||
| 165 | <input type="number" name="cost_day" value="', empty($context['sub']['cost']['day']) ? '0' : $context['sub']['cost']['day'], '" size="5" class="input_text"> |
||
| 166 | </dd> |
||
| 167 | <dt> |
||
| 168 | ', $txt['paid_per_week'], ': |
||
| 169 | </dt> |
||
| 170 | <dd> |
||
| 171 | <input type="number" name="cost_week" value="', empty($context['sub']['cost']['week']) ? '0' : $context['sub']['cost']['week'], '" size="5" class="input_text"> |
||
| 172 | </dd> |
||
| 173 | <dt> |
||
| 174 | ', $txt['paid_per_month'], ': |
||
| 175 | </dt> |
||
| 176 | <dd> |
||
| 177 | <input type="number" name="cost_month" value="', empty($context['sub']['cost']['month']) ? '0' : $context['sub']['cost']['month'], '" size="5" class="input_text"> |
||
| 178 | </dd> |
||
| 179 | <dt> |
||
| 180 | ', $txt['paid_per_year'], ': |
||
| 181 | </dt> |
||
| 182 | <dd> |
||
| 183 | <input type="number" name="cost_year" value="', empty($context['sub']['cost']['year']) ? '0' : $context['sub']['cost']['year'], '" size="5" class="input_text"> |
||
| 184 | </dd> |
||
| 185 | </dl> |
||
| 186 | </fieldset> |
||
| 187 | </div> |
||
| 188 | <input type="submit" name="save" value="', $txt['paid_settings_save'], '" class="button_submit"> |
||
| 189 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||
| 190 | <input type="hidden" name="', $context['admin-pms_token_var'], '" value="', $context['admin-pms_token'], '"> |
||
| 191 | </div> |
||
| 192 | </form> |
||
| 193 | </div>'; |
||
| 194 | |||
| 195 | } |
||
| 196 | |||
| 611 | ?> |
This check looks for calls to
isset(...)orempty()on variables that are yet undefined. These calls will always produce the same result and can be removed.This is most likely caused by the renaming of a variable or the removal of a function/method parameter.