| Conditions | 26 |
| Paths | 12289 |
| Total Lines | 173 |
| Code Lines | 93 |
| 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 |
||
| 23 | function exec_admin_plugin_dist($retour='') { |
||
|
|
|||
| 24 | |||
| 25 | if (!autoriser('configurer', 'plugins')) { |
||
| 26 | include_spip('inc/minipres'); |
||
| 27 | echo minipres(); |
||
| 28 | } else { |
||
| 29 | // on fait la verif du path avant tout, |
||
| 30 | // et l'installation des qu'on est dans la colonne principale |
||
| 31 | // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
||
| 32 | // pour etre sur que les bons fichiers seront charges lors de l'install |
||
| 33 | if (actualise_plugins_actifs()==-1 AND _request('actualise')<2){ |
||
| 34 | include_spip('inc/headers'); |
||
| 35 | redirige_par_entete(parametre_url(self(),'actualise',_request('actualise')+1,'&')); |
||
| 36 | } |
||
| 37 | |||
| 38 | if ($erreur_activation = isset($GLOBALS['meta']['plugin_erreur_activation'])){ |
||
| 39 | $erreur_activation = $GLOBALS['meta']['plugin_erreur_activation']; |
||
| 40 | // l'effacement reel de la meta se fera au moment de l'affichage |
||
| 41 | // mais on la vide pour ne pas l'afficher dans le bandeau haut |
||
| 42 | unset($GLOBALS['meta']['plugin_erreur_activation']); |
||
| 43 | } |
||
| 44 | |||
| 45 | $format = ''; |
||
| 46 | if (_request('format')!==NULL) |
||
| 47 | $format = _request('format'); // liste ou repertoires |
||
| 48 | |||
| 49 | $commencer_page = charger_fonction('commencer_page', 'inc'); |
||
| 50 | echo $commencer_page(_T('icone_admin_plugin'), "configuration", "plugin"); |
||
| 51 | echo "<br />\n"; |
||
| 52 | echo "<br />\n"; |
||
| 53 | |||
| 54 | $quoi = _request('voir'); |
||
| 55 | $quoi = $quoi ? $quoi : 'actifs'; |
||
| 56 | |||
| 57 | echo gros_titre(_T('icone_admin_plugin'),'',false); |
||
| 58 | echo barre_onglets("plugins", $quoi=='actifs'?"plugins_actifs":"admin_plugin"); |
||
| 59 | |||
| 60 | echo debut_gauche('plugin',true); |
||
| 61 | echo debut_boite_info(true); |
||
| 62 | $s = ""; |
||
| 63 | $s .= _T('info_gauche_admin_tech'); |
||
| 64 | echo $s; |
||
| 65 | echo fin_boite_info(true); |
||
| 66 | |||
| 67 | // la valeur de retour de la fonction ci-dessus n'est pas compatible |
||
| 68 | // avec ce que fait actualise_plugins_actifs, il faut recalculer. A revoir. |
||
| 69 | $lcpa = liste_chemin_plugin_actifs(); |
||
| 70 | |||
| 71 | echo pipeline('affiche_gauche', |
||
| 72 | array( |
||
| 73 | 'args'=>array('exec'=>'admin_plugin'), |
||
| 74 | 'data'=>afficher_librairies() |
||
| 75 | ) |
||
| 76 | ); |
||
| 77 | |||
| 78 | echo debut_droite('plugin', true); |
||
| 79 | |||
| 80 | // message d'erreur au retour d'un operation |
||
| 81 | if (_request('erreur')){ |
||
| 82 | echo "<div class='erreur_message-plugins'>" . _T(_request('erreur')) . "</div>"; |
||
| 83 | } |
||
| 84 | if ($erreur_activation){ |
||
| 85 | echo "<div class='erreur_message-plugins'>" . $erreur_activation . "</div>"; |
||
| 86 | effacer_meta('plugin_erreur_activation'); |
||
| 87 | } |
||
| 88 | |||
| 89 | |||
| 90 | // on fait l'installation ici, |
||
| 91 | // cela permet aux scripts d'install de faire des affichages (moches...) |
||
| 92 | installe_plugins(); |
||
| 93 | |||
| 94 | $lpf = liste_plugin_files(); |
||
| 95 | $plugins_interessants = @array_keys(unserialize($GLOBALS['meta']['plugins_interessants'])); |
||
| 96 | if (!is_array($plugins_interessants)) |
||
| 97 | $plugins_interessants = array(); |
||
| 98 | |||
| 99 | echo "<div class='liste-plugins formulaire_spip'>"; |
||
| 100 | |||
| 101 | echo debut_cadre_trait_couleur('plugin-24.gif',true,'',_T('plugins_liste'), |
||
| 102 | 'plugins'); |
||
| 103 | |||
| 104 | if ($quoi!=='actifs'){ |
||
| 105 | if ($lpf) |
||
| 106 | echo "<p>"._T('texte_presente_plugin')."</p>"; |
||
| 107 | else { |
||
| 108 | if (!@is_dir(_DIR_PLUGINS)) |
||
| 109 | echo "<p>"._T('plugin_info_automatique_ftp',array('rep'=>joli_repertoire(_DIR_PLUGINS))) |
||
| 110 | . " — "._T('plugin_info_automatique_creer')."</p>"; |
||
| 111 | } |
||
| 112 | } |
||
| 113 | |||
| 114 | if ($quoi=='actifs' OR $lpf) |
||
| 115 | echo "<h3>".sinon( |
||
| 116 | singulier_ou_pluriel(count($lcpa), 'plugins_actif_un', 'plugins_actifs', 'count'), |
||
| 117 | _T('plugins_actif_aucun') |
||
| 118 | )."</h3>"; |
||
| 119 | |||
| 120 | $sub = "\n<div class='boutons'>" |
||
| 121 | . "<input type='submit' class='submit save' value='"._T('bouton_enregistrer') |
||
| 122 | ."' />" |
||
| 123 | . "</div>"; |
||
| 124 | |||
| 125 | $no_button = false; |
||
| 126 | |||
| 127 | // la liste |
||
| 128 | if ($quoi=='actifs'){ |
||
| 129 | $aff = affiche_les_plugins($lcpa, $lcpa, $format); |
||
| 130 | $no_button = !strlen($aff); |
||
| 131 | $corps = $aff; |
||
| 132 | } |
||
| 133 | elseif ($quoi=='tous') |
||
| 134 | $corps = affiche_les_plugins($lpf, $lcpa, $format); |
||
| 135 | else { |
||
| 136 | $dir_auto = substr(_DIR_PLUGINS_AUTO, strlen(_DIR_PLUGINS)); |
||
| 137 | $lcpaffiche = array(); |
||
| 138 | foreach ($lpf as $f) |
||
| 139 | if (!strpos($f, '/') |
||
| 140 | OR ($dir_auto AND substr($f, 0, strlen($dir_auto)) == $dir_auto) |
||
| 141 | OR in_array($f, $lcpa) |
||
| 142 | OR in_array($f, $plugins_interessants)) |
||
| 143 | $lcpaffiche[] = $f; |
||
| 144 | |||
| 145 | $corps = affiche_les_plugins($lcpaffiche, $lcpa, $format); |
||
| 146 | } |
||
| 147 | |||
| 148 | if (!$no_button) |
||
| 149 | $corps .= "\n<br />" . $sub; |
||
| 150 | |||
| 151 | echo redirige_action_post('activer_plugins','activer','admin_plugin','', $corps); |
||
| 152 | |||
| 153 | echo fin_cadre_trait_couleur(true); |
||
| 154 | |||
| 155 | if ($quoi=='actifs') |
||
| 156 | echo affiche_les_extensions(liste_chemin_plugin_actifs(_DIR_EXTENSIONS)); |
||
| 157 | echo "</div>"; |
||
| 158 | |||
| 159 | echo http_script(" |
||
| 160 | jQuery(function(){ |
||
| 161 | jQuery('#plugins .boutons').hide(); |
||
| 162 | jQuery('.plugins li.item a[rel=info]').click(function(){ |
||
| 163 | var li = jQuery(this).parents('li').eq(0); |
||
| 164 | var prefix = li.find('input.checkbox').attr('name'); |
||
| 165 | if (!jQuery('div.details',li).html()) { |
||
| 166 | jQuery('div.details',li).prepend(ajax_image_searching).load( |
||
| 167 | jQuery(this).attr('href').replace(/admin_plugin|plugins/, 'info_plugin'), function(){ |
||
| 168 | li.addClass('on'); |
||
| 169 | } |
||
| 170 | ); |
||
| 171 | } |
||
| 172 | else { |
||
| 173 | if (jQuery('div.details',li).toggle().is(':visible')) |
||
| 174 | li.addClass('on'); |
||
| 175 | else |
||
| 176 | li.removeClass('on'); |
||
| 177 | } |
||
| 178 | return false; |
||
| 179 | }); |
||
| 180 | jQuery('.plugins li.item input.checkbox').change(function(){ |
||
| 181 | jQuery(this).parents('form').eq(0).find('.boutons').slideDown(); |
||
| 182 | }); |
||
| 183 | }); |
||
| 184 | "); |
||
| 185 | |||
| 186 | echo pipeline('affiche_milieu', |
||
| 187 | array( |
||
| 188 | 'args'=>array('exec'=>'admin_plugin'), |
||
| 189 | 'data'=>'' |
||
| 190 | ) |
||
| 191 | ); |
||
| 192 | |||
| 193 | echo fin_gauche(), fin_page(); |
||
| 194 | } |
||
| 195 | } |
||
| 196 | |||
| 256 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.