Conditions | 18 |
Paths | 12 |
Total Lines | 199 |
Code Lines | 118 |
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 |
||
228 | public function configureBlock($block_id) |
||
229 | { |
||
230 | if (Filter::postBool('save') && Filter::checkCsrf()) { |
||
231 | $this->setBlockSetting($block_id, 'filter', Filter::post('filter', 'indi|event|all', 'all')); |
||
232 | $this->setBlockSetting($block_id, 'controls', Filter::postBool('controls')); |
||
233 | $this->setBlockSetting($block_id, 'start', Filter::postBool('start')); |
||
234 | $this->setBlockSetting($block_id, 'filter_avi', Filter::postBool('filter_avi')); |
||
235 | $this->setBlockSetting($block_id, 'filter_bmp', Filter::postBool('filter_bmp')); |
||
236 | $this->setBlockSetting($block_id, 'filter_gif', Filter::postBool('filter_gif')); |
||
237 | $this->setBlockSetting($block_id, 'filter_jpeg', Filter::postBool('filter_jpeg')); |
||
238 | $this->setBlockSetting($block_id, 'filter_mp3', Filter::postBool('filter_mp3')); |
||
239 | $this->setBlockSetting($block_id, 'filter_ole', Filter::postBool('filter_ole')); |
||
240 | $this->setBlockSetting($block_id, 'filter_pcx', Filter::postBool('filter_pcx')); |
||
241 | $this->setBlockSetting($block_id, 'filter_pdf', Filter::postBool('filter_pdf')); |
||
242 | $this->setBlockSetting($block_id, 'filter_png', Filter::postBool('filter_png')); |
||
243 | $this->setBlockSetting($block_id, 'filter_tiff', Filter::postBool('filter_tiff')); |
||
244 | $this->setBlockSetting($block_id, 'filter_wav', Filter::postBool('filter_wav')); |
||
245 | $this->setBlockSetting($block_id, 'filter_audio', Filter::postBool('filter_audio')); |
||
246 | $this->setBlockSetting($block_id, 'filter_book', Filter::postBool('filter_book')); |
||
247 | $this->setBlockSetting($block_id, 'filter_card', Filter::postBool('filter_card')); |
||
248 | $this->setBlockSetting($block_id, 'filter_certificate', Filter::postBool('filter_certificate')); |
||
249 | $this->setBlockSetting($block_id, 'filter_coat', Filter::postBool('filter_coat')); |
||
250 | $this->setBlockSetting($block_id, 'filter_document', Filter::postBool('filter_document')); |
||
251 | $this->setBlockSetting($block_id, 'filter_electronic', Filter::postBool('filter_electronic')); |
||
252 | $this->setBlockSetting($block_id, 'filter_fiche', Filter::postBool('filter_fiche')); |
||
253 | $this->setBlockSetting($block_id, 'filter_film', Filter::postBool('filter_film')); |
||
254 | $this->setBlockSetting($block_id, 'filter_magazine', Filter::postBool('filter_magazine')); |
||
255 | $this->setBlockSetting($block_id, 'filter_manuscript', Filter::postBool('filter_manuscript')); |
||
256 | $this->setBlockSetting($block_id, 'filter_map', Filter::postBool('filter_map')); |
||
257 | $this->setBlockSetting($block_id, 'filter_newspaper', Filter::postBool('filter_newspaper')); |
||
258 | $this->setBlockSetting($block_id, 'filter_other', Filter::postBool('filter_other')); |
||
259 | $this->setBlockSetting($block_id, 'filter_painting', Filter::postBool('filter_painting')); |
||
260 | $this->setBlockSetting($block_id, 'filter_photo', Filter::postBool('filter_photo')); |
||
261 | $this->setBlockSetting($block_id, 'filter_tombstone', Filter::postBool('filter_tombstone')); |
||
262 | $this->setBlockSetting($block_id, 'filter_video', Filter::postBool('filter_video')); |
||
263 | } |
||
264 | |||
265 | $filter = $this->getBlockSetting($block_id, 'filter', 'all'); |
||
266 | $controls = $this->getBlockSetting($block_id, 'controls', '1'); |
||
267 | $start = $this->getBlockSetting($block_id, 'start', '0') || Filter::getBool('start'); |
||
268 | |||
269 | echo '<tr><td class="descriptionbox wrap width33">'; |
||
270 | echo /* I18N: Label for a configuration option */ I18N::translate('Show only individuals, events, or all'); |
||
271 | echo '</td><td class="optionbox">'; |
||
272 | echo FunctionsEdit::selectEditControl('filter', array('indi' => I18N::translate('Individuals'), 'event' => I18N::translate('Facts and events'), 'all' => I18N::translate('All')), null, $filter, ''); |
||
273 | echo '</td></tr>'; |
||
274 | |||
275 | $filters = array( |
||
276 | 'avi' => $this->getBlockSetting($block_id, 'filter_avi', '0'), |
||
277 | 'bmp' => $this->getBlockSetting($block_id, 'filter_bmp', '1'), |
||
278 | 'gif' => $this->getBlockSetting($block_id, 'filter_gif', '1'), |
||
279 | 'jpeg' => $this->getBlockSetting($block_id, 'filter_jpeg', '1'), |
||
280 | 'mp3' => $this->getBlockSetting($block_id, 'filter_mp3', '0'), |
||
281 | 'ole' => $this->getBlockSetting($block_id, 'filter_ole', '1'), |
||
282 | 'pcx' => $this->getBlockSetting($block_id, 'filter_pcx', '1'), |
||
283 | 'pdf' => $this->getBlockSetting($block_id, 'filter_pdf', '0'), |
||
284 | 'png' => $this->getBlockSetting($block_id, 'filter_png', '1'), |
||
285 | 'tiff' => $this->getBlockSetting($block_id, 'filter_tiff', '1'), |
||
286 | 'wav' => $this->getBlockSetting($block_id, 'filter_wav', '0'), |
||
287 | 'audio' => $this->getBlockSetting($block_id, 'filter_audio', '0'), |
||
288 | 'book' => $this->getBlockSetting($block_id, 'filter_book', '1'), |
||
289 | 'card' => $this->getBlockSetting($block_id, 'filter_card', '1'), |
||
290 | 'certificate' => $this->getBlockSetting($block_id, 'filter_certificate', '1'), |
||
291 | 'coat' => $this->getBlockSetting($block_id, 'filter_coat', '1'), |
||
292 | 'document' => $this->getBlockSetting($block_id, 'filter_document', '1'), |
||
293 | 'electronic' => $this->getBlockSetting($block_id, 'filter_electronic', '1'), |
||
294 | 'fiche' => $this->getBlockSetting($block_id, 'filter_fiche', '1'), |
||
295 | 'film' => $this->getBlockSetting($block_id, 'filter_film', '1'), |
||
296 | 'magazine' => $this->getBlockSetting($block_id, 'filter_magazine', '1'), |
||
297 | 'manuscript' => $this->getBlockSetting($block_id, 'filter_manuscript', '1'), |
||
298 | 'map' => $this->getBlockSetting($block_id, 'filter_map', '1'), |
||
299 | 'newspaper' => $this->getBlockSetting($block_id, 'filter_newspaper', '1'), |
||
300 | 'other' => $this->getBlockSetting($block_id, 'filter_other', '1'), |
||
301 | 'painting' => $this->getBlockSetting($block_id, 'filter_painting', '1'), |
||
302 | 'photo' => $this->getBlockSetting($block_id, 'filter_photo', '1'), |
||
303 | 'tombstone' => $this->getBlockSetting($block_id, 'filter_tombstone', '1'), |
||
304 | 'video' => $this->getBlockSetting($block_id, 'filter_video', '0'), |
||
305 | ); |
||
306 | |||
307 | ?> |
||
308 | <tr> |
||
309 | <td class="descriptionbox wrap width33"> |
||
310 | <?php echo I18N::translate('Filter'); ?> |
||
311 | </td> |
||
312 | <td class="optionbox"> |
||
313 | <center><b><?php echo GedcomTag::getLabel('FORM'); ?></b></center> |
||
314 | <table class="width100"> |
||
315 | <tr> |
||
316 | <td class="width33"> |
||
317 | <label> |
||
318 | <input type="checkbox" value="yes" name="filter_avi" <?php echo $filters['avi'] ? 'checked' : ''; ?>> |
||
319 | avi |
||
320 | </td> |
||
321 | <td class="width33"> |
||
322 | <label> |
||
323 | <input type="checkbox" value="yes" name="filter_bmp" <?php echo $filters['bmp'] ? 'checked' : ''; ?>> |
||
324 | bmp |
||
325 | </label> |
||
326 | </td> |
||
327 | <td class="width33"> |
||
328 | <label> |
||
329 | <input type="checkbox" value="yes" name="filter_gif" <?php echo $filters['gif'] ? 'checked' : ''; ?>> |
||
330 | gif |
||
331 | </label> |
||
332 | </td> |
||
333 | </tr> |
||
334 | <tr> |
||
335 | <td class="width33"> |
||
336 | <label> |
||
337 | <input type="checkbox" value="yes" name="filter_jpeg" <?php echo $filters['jpeg'] ? 'checked' : ''; ?>> |
||
338 | jpeg |
||
339 | </label> |
||
340 | </td> |
||
341 | <td class="width33"> |
||
342 | <label> |
||
343 | <input type="checkbox" value="yes" name="filter_mp3" <?php echo $filters['mp3'] ? 'checked' : ''; ?>> |
||
344 | mp3 |
||
345 | </label> |
||
346 | </td> |
||
347 | <td class="width33"> |
||
348 | <label> |
||
349 | <input type="checkbox" value="yes" name="filter_ole" <?php echo $filters['ole'] ? 'checked' : ''; ?>> |
||
350 | ole |
||
351 | </label> |
||
352 | </td> |
||
353 | </tr> |
||
354 | <tr> |
||
355 | <td class="width33"> |
||
356 | <label> |
||
357 | <input type="checkbox" value="yes" name="filter_pcx" <?php echo $filters['pcx'] ? 'checked' : ''; ?>> |
||
358 | pcx |
||
359 | </label> |
||
360 | </td> |
||
361 | <td class="width33"> |
||
362 | <label> |
||
363 | <input type="checkbox" value="yes" name="filter_pdf" <?php echo $filters['pdf'] ? 'checked' : ''; ?>> |
||
364 | |||
365 | </label> |
||
366 | </td> |
||
367 | <td class="width33"> |
||
368 | <label> |
||
369 | <input type="checkbox" value="yes" name="filter_png" <?php echo $filters['png'] ? 'checked' : ''; ?>> |
||
370 | png |
||
371 | </label> |
||
372 | </td> |
||
373 | </tr> |
||
374 | <tr> |
||
375 | <td class="width33"> |
||
376 | <label> |
||
377 | <input type="checkbox" value="yes" name="filter_tiff" <?php echo $filters['tiff'] ? 'checked' : ''; ?>> |
||
378 | tiff |
||
379 | </label> |
||
380 | </td> |
||
381 | <td class="width33"> |
||
382 | <label> |
||
383 | <input type="checkbox" value="yes" name="filter_wav" <?php echo $filters['wav'] ? 'checked' : ''; ?>> |
||
384 | wav |
||
385 | </label> |
||
386 | </td> |
||
387 | <td class="width33"></td> |
||
388 | <td class="width33"></td> |
||
389 | </tr> |
||
390 | </table> |
||
391 | <br> |
||
392 | <center><b><?php echo GedcomTag::getLabel('TYPE'); ?></b></center> |
||
393 | <table class="width100"> |
||
394 | <tr> |
||
395 | <?php |
||
396 | //-- Build the list of checkboxes |
||
397 | $i = 0; |
||
398 | foreach (GedcomTag::getFileFormTypes() as $typeName => $typeValue) { |
||
399 | $i++; |
||
400 | if ($i > 3) { |
||
401 | $i = 1; |
||
402 | echo '</tr><tr>'; |
||
403 | } |
||
404 | echo '<td class="width33"><label><input type="checkbox" value="yes" name="filter_' . $typeName . '" '; |
||
405 | echo $filters[$typeName] ? 'checked' : ''; |
||
406 | echo '> ' . $typeValue . '</label></td>'; |
||
407 | } |
||
408 | ?> |
||
409 | </tr> |
||
410 | </table> |
||
411 | </td> |
||
412 | </tr> |
||
413 | |||
414 | <?php |
||
415 | |||
416 | echo '<tr><td class="descriptionbox wrap width33">'; |
||
417 | echo /* I18N: Label for a configuration option */ I18N::translate('Show slide show controls'); |
||
418 | echo '</td><td class="optionbox">'; |
||
419 | echo FunctionsEdit::editFieldYesNo('controls', $controls); |
||
420 | echo '</td></tr>'; |
||
421 | |||
422 | echo '<tr><td class="descriptionbox wrap width33">'; |
||
423 | echo /* I18N: Label for a configuration option */ I18N::translate('Start slide show on page load'); |
||
424 | echo '</td><td class="optionbox">'; |
||
425 | echo FunctionsEdit::editFieldYesNo('start', $start); |
||
426 | echo '</td></tr>'; |
||
427 | } |
||
429 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.