| Conditions | 19 |
| Paths | 18432 |
| Total Lines | 144 |
| Code Lines | 77 |
| 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 |
||
| 44 | function admin_plug_args($quoi, $erreur, $format) |
||
| 45 | { |
||
| 46 | if (!$quoi) $quoi = 'actifs'; |
||
| 47 | // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite |
||
| 48 | // format brut par plugin |
||
| 49 | $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false); |
||
| 50 | // format resume mis en forme |
||
| 51 | $erreur_activation = plugin_donne_erreurs(); |
||
| 52 | $commencer_page = charger_fonction('commencer_page', 'inc'); |
||
| 53 | echo $commencer_page(_T('icone_admin_plugin'), "configuration", "plugin"); |
||
| 54 | |||
| 55 | echo debut_gauche('plugin',true); |
||
| 56 | echo recuperer_fond('prive/squelettes/navigation/configurer',array('exec'=>'admin_plugin')); |
||
| 57 | |||
| 58 | echo pipeline('affiche_gauche', |
||
| 59 | array( |
||
| 60 | 'args'=>array('exec'=>'admin_plugin'), |
||
| 61 | 'data'=>afficher_librairies() |
||
| 62 | ) |
||
| 63 | ); |
||
| 64 | |||
| 65 | echo debut_droite('plugin', true); |
||
| 66 | echo gros_titre(_T('icone_admin_plugin'),'',false); |
||
| 67 | |||
| 68 | // Barre d'onglets de premier niveau |
||
| 69 | echo barre_onglets("plugins", "plugins_actifs"); |
||
| 70 | // Barre d'onglets de second niveau |
||
| 71 | $onglet2 = $quoi=='actifs' ? 'plugins_actifs' : 'admin_plugin'; |
||
| 72 | echo debut_onglet('onglets_simple second'); |
||
| 73 | echo onglet(_T('plugins_tous_liste'), generer_url_ecrire("admin_plugin", "voir=tous"), 'admin_plugin', $onglet2); |
||
| 74 | echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire("admin_plugin"), 'plugins_actifs', $onglet2); |
||
| 75 | echo fin_onglet(); |
||
| 76 | |||
| 77 | // message d'erreur au retour d'une operation |
||
| 78 | if ($erreur) |
||
| 79 | echo "<div class='error'>$erreur</div>"; |
||
| 80 | if ($erreur_activation){ |
||
| 81 | echo "<div class='error'>$erreur_activation</div>"; |
||
| 82 | } |
||
| 83 | |||
| 84 | // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs |
||
| 85 | $actifs = unserialize($GLOBALS['meta']['plugin']); |
||
| 86 | $lcpa = $actifs + unserialize($GLOBALS['meta']['plugin_attente']); |
||
| 87 | |||
| 88 | // Les affichages se basent sur le repertoire, pas sur le nom |
||
| 89 | $actifs = liste_chemin_plugin($actifs, ''); |
||
| 90 | if (defined('_DIR_PLUGINS_SUPPL')) |
||
| 91 | $lcpas = liste_chemin_plugin($lcpa,_DIR_PLUGINS_SUPPL); |
||
| 92 | $lcpa = liste_chemin_plugin($lcpa); |
||
| 93 | |||
| 94 | // on installe les plugins maintenant, |
||
| 95 | // cela permet aux scripts d'install de faire des affichages (moches...) |
||
| 96 | plugin_installes_meta(); |
||
| 97 | |||
| 98 | echo "<div class='liste-plugins formulaire_spip'>"; |
||
| 99 | echo debut_cadre_trait_couleur('plugin-24.png',true,'',_T('plugins_liste'), 'plugins'); |
||
| 100 | |||
| 101 | if ($quoi!=='actifs'){ |
||
| 102 | $lpf = liste_plugin_files(); |
||
| 103 | if ($lpf) |
||
| 104 | echo "<p>"._T('texte_presente_plugin')."</p>"; |
||
| 105 | else { |
||
| 106 | if (!@is_dir(_DIR_PLUGINS)) |
||
| 107 | echo "<p>"._T('plugin_info_automatique_ftp',array('rep'=>joli_repertoire(_DIR_PLUGINS))) |
||
| 108 | . " — "._T('plugin_info_automatique_creer')."</p>"; |
||
| 109 | } |
||
| 110 | $lcpaffiche = $lpf; |
||
| 111 | if (defined('_DIR_PLUGINS_SUPPL')) |
||
| 112 | $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL); |
||
| 113 | } |
||
| 114 | else { |
||
| 115 | // la liste |
||
| 116 | // $quoi=='actifs' |
||
| 117 | $lcpaffiche = $lcpa; |
||
| 118 | if (defined('_DIR_PLUGINS_SUPPL')) |
||
| 119 | $lcpaffichesup = $lcpas; |
||
| 120 | } |
||
| 121 | |||
| 122 | if ($quoi=='actifs' OR $lpf){ |
||
| 123 | $nb = count($lcpa); |
||
| 124 | if (defined('_DIR_PLUGINS_SUPPL')) |
||
| 125 | $nb += count($lcpas); |
||
| 126 | echo "<h3>".sinon(singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), _T('plugins_actif_aucun'))."</h3>"; |
||
| 127 | } |
||
| 128 | |||
| 129 | if (empty($format)) |
||
| 130 | $format = 'liste'; |
||
| 131 | elseif (!in_array($format,array('liste','repertoires'))) |
||
| 132 | $format = 'repertoires'; |
||
| 133 | |||
| 134 | $afficher = charger_fonction("afficher_$format",'plugins'); |
||
| 135 | $corps = $afficher(self(),$lcpaffiche, $lcpa, $actifs); |
||
| 136 | if (defined('_DIR_PLUGINS_SUPPL')) |
||
| 137 | $corps .= $afficher(self(),$lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
||
| 138 | |||
| 139 | if ($corps) |
||
| 140 | $corps .= "\n<div class='boutons' style='display:none;'>" |
||
| 141 | . "<input type='submit' class='submit save' value='"._T('bouton_enregistrer') |
||
| 142 | ."' />" |
||
| 143 | . "</div>"; |
||
| 144 | |||
| 145 | echo redirige_action_post('activer_plugins','activer','admin_plugin','', $corps); |
||
| 146 | |||
| 147 | echo fin_cadre_trait_couleur(true); |
||
| 148 | |||
| 149 | if ($quoi=='actifs') |
||
| 150 | echo affiche_les_plugins_verrouilles($actifs); |
||
| 151 | echo "</div>"; |
||
| 152 | |||
| 153 | echo http_script(" |
||
| 154 | jQuery(function(){ |
||
| 155 | jQuery('.plugins li.item a[rel=info]').click(function(){ |
||
| 156 | var li = jQuery(this).parents('li').eq(0); |
||
| 157 | var prefix = li.find('input.checkbox').attr('name'); |
||
| 158 | if (!jQuery('div.details',li).html()) { |
||
| 159 | jQuery('div.details',li).prepend(ajax_image_searching).load( |
||
| 160 | jQuery(this).attr('href').replace(/admin_plugin|plugins/, 'info_plugin'), function(){ |
||
| 161 | li.addClass('on'); |
||
| 162 | } |
||
| 163 | ); |
||
| 164 | } |
||
| 165 | else { |
||
| 166 | if (jQuery('div.details',li).toggle().is(':visible')) |
||
| 167 | li.addClass('on'); |
||
| 168 | else |
||
| 169 | li.removeClass('on'); |
||
| 170 | } |
||
| 171 | return false; |
||
| 172 | }); |
||
| 173 | jQuery('.plugins li.item input.checkbox').change(function(){ |
||
| 174 | jQuery(this).parents('form').eq(0).find('.boutons').slideDown(); |
||
| 175 | }); |
||
| 176 | }); |
||
| 177 | "); |
||
| 178 | |||
| 179 | echo pipeline('affiche_milieu', |
||
| 180 | array( |
||
| 181 | 'args'=>array('exec'=>'admin_plugin'), |
||
| 182 | 'data'=>'' |
||
| 183 | ) |
||
| 184 | ); |
||
| 185 | |||
| 186 | echo fin_gauche(), fin_page(); |
||
| 187 | } |
||
| 188 | |||
| 249 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.