Conditions | 13 |
Paths | 8 |
Total Lines | 108 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
179 | function template_modify_language_entries() |
||
180 | { |
||
181 | global $context, $txt, $scripturl; |
||
182 | |||
183 | echo ' |
||
184 | <div id="admincenter"> |
||
185 | <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=languages;sa=editlang;lid=', $context['lang_id'], '" method="post" accept-charset="UTF-8"> |
||
186 | <h2 class="category_header">', $txt['edit_languages'], '</h2> |
||
187 | <div class="information"> |
||
188 | ', $txt['edit_language_entries_primary'], ' |
||
189 | </div> |
||
190 | <div class="content"> |
||
191 | <fieldset> |
||
192 | <legend>', $context['primary_settings']['name'], '</legend> |
||
193 | <dl class="settings"> |
||
194 | <dt> |
||
195 | <label for="locale">', $txt['languages_locale'], ':</label> |
||
196 | </dt> |
||
197 | <dd> |
||
198 | <input type="text" name="locale" id="locale" size="20" value="', $context['primary_settings']['locale'], '"', (empty($context['file_entries']) ? '' : ' disabled="disabled"'), ' class="input_text" /> |
||
199 | </dd> |
||
200 | <dt> |
||
201 | <label for="dictionary">', $txt['languages_dictionary'], ':</label> |
||
202 | </dt> |
||
203 | <dd> |
||
204 | <input type="text" name="dictionary" id="dictionary" size="20" value="', $context['primary_settings']['dictionary'], '"', (empty($context['file_entries']) ? '' : ' disabled="disabled"'), ' class="input_text" /> |
||
205 | </dd> |
||
206 | <dt> |
||
207 | <label for="spelling">', $txt['languages_spelling'], ':</label> |
||
208 | </dt> |
||
209 | <dd> |
||
210 | <input type="text" name="spelling" id="spelling" size="20" value="', $context['primary_settings']['spelling'], '"', (empty($context['file_entries']) ? '' : ' disabled="disabled"'), ' class="input_text" /> |
||
211 | </dd> |
||
212 | <dt> |
||
213 | <label for="rtl">', $txt['languages_rtl'], ':</label> |
||
214 | </dt> |
||
215 | <dd> |
||
216 | <input type="checkbox" name="rtl" id="rtl" ', $context['primary_settings']['rtl'] ? ' checked="checked"' : '', ' class="input_check"', (empty($context['file_entries']) ? '' : ' disabled="disabled"'), ' /> |
||
217 | </dd> |
||
218 | </dl> |
||
219 | </fieldset> |
||
220 | <div class="submitbutton"> |
||
221 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> |
||
222 | <input type="hidden" name="', $context['admin-mlang_token_var'], '" value="', $context['admin-mlang_token'], '" /> |
||
223 | <input type="submit" name="save_main" value="', $txt['save'], '"', !empty($context['file_entries']) ? ' disabled="disabled"' : '', ' />'; |
||
224 | |||
225 | // Allow deleting entries. |
||
226 | if (!empty($context['langpack_uninstall_link'])) |
||
227 | { |
||
228 | // English can't be deleted though. |
||
229 | echo ' |
||
230 | <a href="', $context['langpack_uninstall_link'], '" class="linkbutton">' . $txt['delete'] . '</a>'; |
||
231 | } |
||
232 | |||
233 | echo ' |
||
234 | </div> |
||
235 | </div> |
||
236 | </form> |
||
237 | |||
238 | <form id="entry_form" action="', $scripturl, '?action=admin;area=languages;sa=editlang;lid=', $context['lang_id'], ';entries#entry_form" method="post" accept-charset="UTF-8"> |
||
239 | <div class="category_header"> |
||
240 | <h3 class="floatleft"> |
||
241 | ', $txt['edit_language_entries'], ' |
||
242 | </h3> |
||
243 | <div id="taskpad" class="floatright"> |
||
244 | <label for="tfid">', $txt['edit_language_entries_file'], '</label>: |
||
245 | <select id="tfid" name="tfid" onchange="if (this.value != -1) document.forms.entry_form.submit();">'; |
||
246 | |||
247 | foreach ($context['possible_files'] as $file) |
||
248 | { |
||
249 | echo ' |
||
250 | <option value="', $file['id'], '"', $file['selected'] ? ' selected="selected"' : '', '> => ', $file['name'], '</option>'; |
||
251 | } |
||
252 | |||
253 | echo ' |
||
254 | </select> |
||
255 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> |
||
256 | <input type="hidden" name="', $context['admin-mlang_token_var'], '" value="', $context['admin-mlang_token'], '" /> |
||
257 | <noscript><input type="submit" value="', $txt['go'], '" /></noscript> |
||
258 | </div> |
||
259 | </div>'; |
||
260 | |||
261 | // Already have some file entries? |
||
262 | if (!empty($context['file_entries'])) |
||
263 | { |
||
264 | echo ' |
||
265 | <div class="content"> |
||
266 | <ul class="strings_edit settings">'; |
||
267 | |||
268 | foreach ($context['file_entries'] as $entry) |
||
269 | { |
||
270 | echo ' |
||
271 | <li> |
||
272 | <label for="entry_', $entry['key'], '" class="smalltext">', $entry['display_key'], '</label> |
||
273 | <input type="hidden" name="comp[', $entry['key'], ']" value="', $entry['value'], '" /> |
||
274 | <textarea id="entry_', $entry['key'], '" name="entry[', $entry['key'], ']" cols="40" rows="', $entry['rows'] < 2 ? 2 : $entry['rows'], '">', $entry['value'], '</textarea> |
||
275 | </li>'; |
||
276 | } |
||
277 | |||
278 | echo ' |
||
279 | </ul> |
||
280 | <div class="submitbutton"> |
||
281 | <input type="submit" name="save_entries" value="', $txt['save'], '" /> |
||
282 | </div> |
||
283 | </div>'; |
||
284 | } |
||
285 | |||
286 | echo ' |
||
287 | </form> |
||
339 |