| Conditions | 5 | 
| Paths | 384 | 
| Total Lines | 127 | 
| Code Lines | 87 | 
| 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  | 
            ||
| 74 |     public function html() { | 
            ||
| 75 | $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here.  | 
            ||
| 76 | global $lang;  | 
            ||
| 77 | global $ID;  | 
            ||
| 78 | |||
| 79 | $this->setupLocale(true);  | 
            ||
| 80 | |||
| 81 |         echo $this->locale_xhtml('intro'); | 
            ||
| 82 | |||
| 83 | echo '<div id="config__manager">';  | 
            ||
| 84 | |||
| 85 |         if($this->configuration->isLocked()) { | 
            ||
| 86 |             echo '<div class="info">' . $this->getLang('locked') . '</div>'; | 
            ||
| 87 | }  | 
            ||
| 88 | |||
| 89 | // POST to script() instead of wl($ID) so config manager still works if  | 
            ||
| 90 | // rewrite config is broken. Add $ID as hidden field to remember  | 
            ||
| 91 | // current ID in most cases.  | 
            ||
| 92 | echo '<form action="' . script() . '" method="post">';  | 
            ||
| 93 | echo '<div class="no"><input type="hidden" name="id" value="' . $ID . '" /></div>';  | 
            ||
| 94 | formSecurityToken();  | 
            ||
| 95 |         $this->printH1('dokuwiki_settings', $this->getLang('_header_dokuwiki')); | 
            ||
| 96 | |||
| 97 | $in_fieldset = false;  | 
            ||
| 98 | $first_plugin_fieldset = true;  | 
            ||
| 99 | $first_template_fieldset = true;  | 
            ||
| 100 |         foreach($this->configuration->getSettings() as $setting) { | 
            ||
| 101 |             if(is_a($setting, SettingHidden::class)) { | 
            ||
| 102 | continue;  | 
            ||
| 103 |             } else if(is_a($setting, settingFieldset::class)) { | 
            ||
| 104 | // config setting group  | 
            ||
| 105 |                 if($in_fieldset) { | 
            ||
| 106 | echo '</table>';  | 
            ||
| 107 | echo '</div>';  | 
            ||
| 108 | echo '</fieldset>';  | 
            ||
| 109 |                 } else { | 
            ||
| 110 | $in_fieldset = true;  | 
            ||
| 111 | }  | 
            ||
| 112 |                 if($first_plugin_fieldset && $setting->getType() == 'plugin') { | 
            ||
| 113 |                     $this->printH1('plugin_settings', $this->getLang('_header_plugin')); | 
            ||
| 114 | $first_plugin_fieldset = false;  | 
            ||
| 115 |                 } else if($first_template_fieldset && $setting->getType() == 'template') { | 
            ||
| 116 |                     $this->printH1('template_settings', $this->getLang('_header_template')); | 
            ||
| 117 | $first_template_fieldset = false;  | 
            ||
| 118 | }  | 
            ||
| 119 | echo '<fieldset id="' . $setting->getKey() . '">';  | 
            ||
| 120 | echo '<legend>' . $setting->prompt($this) . '</legend>';  | 
            ||
| 121 | echo '<div class="table">';  | 
            ||
| 122 | echo '<table class="inline">';  | 
            ||
| 123 |             } else { | 
            ||
| 124 | // config settings  | 
            ||
| 125 | list($label, $input) = $setting->html($this, $this->hasErrors);  | 
            ||
| 126 | |||
| 127 | $class = $setting->isDefault()  | 
            ||
| 128 | ? ' class="default"'  | 
            ||
| 129 | : ($setting->isProtected() ? ' class="protected"' : '');  | 
            ||
| 130 | $error = $setting->hasError()  | 
            ||
| 131 | ? ' class="value error"'  | 
            ||
| 132 | : ' class="value"';  | 
            ||
| 133 | $icon = $setting->caution()  | 
            ||
| 134 | ? '<img src="' . self::IMGDIR . $setting->caution() . '.png" ' .  | 
            ||
| 135 | 'alt="' . $setting->caution() . '" title="' . $this->getLang($setting->caution()) . '" />'  | 
            ||
| 136 | : '';  | 
            ||
| 137 | |||
| 138 | echo '<tr' . $class . '>';  | 
            ||
| 139 | echo '<td class="label">';  | 
            ||
| 140 | echo '<span class="outkey">' . $setting->getPrettyKey() . '</span>';  | 
            ||
| 141 | echo $icon . $label;  | 
            ||
| 142 | echo '</td>';  | 
            ||
| 143 | echo '<td' . $error . '>' . $input . '</td>';  | 
            ||
| 144 | echo '</tr>';  | 
            ||
| 145 | }  | 
            ||
| 146 | }  | 
            ||
| 147 | |||
| 148 | echo '</table>';  | 
            ||
| 149 | echo '</div>';  | 
            ||
| 150 |         if($in_fieldset) { | 
            ||
| 151 | echo '</fieldset>';  | 
            ||
| 152 | }  | 
            ||
| 153 | |||
| 154 | // show undefined settings list  | 
            ||
| 155 | $undefined_settings = $this->configuration->getUndefined();  | 
            ||
| 156 |         if($allow_debug && !empty($undefined_settings)) { | 
            ||
| 157 | /**  | 
            ||
| 158 | * Callback for sorting settings  | 
            ||
| 159 | *  | 
            ||
| 160 | * @param Setting $a  | 
            ||
| 161 | * @param Setting $b  | 
            ||
| 162 | * @return int if $a is lower/equal/higher than $b  | 
            ||
| 163 | */  | 
            ||
| 164 |             function settingNaturalComparison($a, $b) { | 
            ||
| 165 | return strnatcmp($a->getKey(), $b->getKey());  | 
            ||
| 166 | }  | 
            ||
| 167 | |||
| 168 | usort($undefined_settings, 'settingNaturalComparison');  | 
            ||
| 169 |             $this->printH1('undefined_settings', $this->getLang('_header_undefined')); | 
            ||
| 170 | echo '<fieldset>';  | 
            ||
| 171 | echo '<div class="table">';  | 
            ||
| 172 | echo '<table class="inline">';  | 
            ||
| 173 |             foreach($undefined_settings as $setting) { | 
            ||
| 174 | list($label, $input) = $setting->html($this);  | 
            ||
| 175 | echo '<tr>';  | 
            ||
| 176 | echo '<td class="label">' . $label . '</td>';  | 
            ||
| 177 | echo '<td>' . $input . '</td>';  | 
            ||
| 178 | echo '</tr>';  | 
            ||
| 179 | }  | 
            ||
| 180 | echo '</table>';  | 
            ||
| 181 | echo '</div>';  | 
            ||
| 182 | echo '</fieldset>';  | 
            ||
| 183 | }  | 
            ||
| 184 | |||
| 185 | // finish up form  | 
            ||
| 186 | echo '<p>';  | 
            ||
| 187 | echo '<input type="hidden" name="do" value="admin" />';  | 
            ||
| 188 | echo '<input type="hidden" name="page" value="config" />';  | 
            ||
| 189 | |||
| 190 |         if(!$this->configuration->isLocked()) { | 
            ||
| 191 | echo '<input type="hidden" name="save" value="1" />';  | 
            ||
| 192 | echo '<button type="submit" name="submit" accesskey="s">' . $lang['btn_save'] . '</button>';  | 
            ||
| 193 | echo '<button type="reset">' . $lang['btn_reset'] . '</button>';  | 
            ||
| 194 | }  | 
            ||
| 195 | |||
| 196 | echo '</p>';  | 
            ||
| 197 | |||
| 198 | echo '</form>';  | 
            ||
| 199 | echo '</div>';  | 
            ||
| 200 | }  | 
            ||
| 201 | |||
| 286 |