| Conditions | 14 |
| Paths | 2 |
| Total Lines | 117 |
| Lines | 3 |
| Ratio | 2.56 % |
| 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 |
||
| 189 | function template_email_members_compose() |
||
| 190 | { |
||
| 191 | global $context, $txt, $scripturl; |
||
| 192 | |||
| 193 | echo ' |
||
| 194 | <div id="admincenter"> |
||
| 195 | <form name="newsmodify" action="', $scripturl, '?action=admin;area=news;sa=mailingsend" method="post" accept-charset="UTF-8"> |
||
| 196 | <h2 class="category_header"> |
||
| 197 | ', $txt['admin_newsletters'], ' |
||
| 198 | </h2> |
||
| 199 | <div class="information"> |
||
| 200 | ', str_replace('{help_emailmembers}', $scripturl . '?action=quickhelp;help=emailmembers" onclick="return reqOverlayDiv(this.href);', $txt['email_variables']), ' |
||
| 201 | </div>'; |
||
| 202 | |||
| 203 | // The preview section |
||
| 204 | echo ' |
||
| 205 | <div id="preview_section"', isset($context['preview_message']) ? '' : ' class="hide"', '> |
||
| 206 | <h2 class="category_header"> |
||
| 207 | <span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span> |
||
| 208 | </h2> |
||
| 209 | <div id="preview_body"> |
||
| 210 | ', empty($context['preview_message']) ? '<br />' : $context['preview_message'], ' |
||
| 211 | </div> |
||
| 212 | </div>'; |
||
| 213 | |||
| 214 | // Any errors to speak of? |
||
| 215 | echo ' |
||
| 216 | <div class="content"> |
||
| 217 | <div id="post_error" class="', (empty($context['error_type']) || $context['error_type'] != 'serious' ? 'warningbox' : 'errorbox'), empty($context['post_error']['messages']) ? ' hide"' : '"', '> |
||
| 218 | <dl> |
||
| 219 | <dt> |
||
| 220 | <strong id="error_serious">', $txt['error_while_submitting'], '</strong> |
||
| 221 | </dt> |
||
| 222 | <dd> |
||
| 223 | <ul class="error" id="post_error_list"> |
||
| 224 | ', empty($context['post_error']['messages']) ? '' : '<li>' . implode('</li><li>', $context['post_error']['messages']) . '</li>', ' |
||
| 225 | </ul> |
||
| 226 | </dd> |
||
| 227 | </dl> |
||
| 228 | </div>'; |
||
| 229 | |||
| 230 | // Show the editor area |
||
| 231 | echo ' |
||
| 232 | <div class="editor_wrapper"> |
||
| 233 | <dl id="post_header"> |
||
| 234 | <dt class="clear_left"> |
||
| 235 | <label for="subject"', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' id="caption_subject">', $txt['subject'], ':</label> |
||
| 236 | </dt> |
||
| 237 | <dd id="pm_subject"> |
||
| 238 | <input type="text" id="subject" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="60" maxlength="60"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/> |
||
| 239 | </dd> |
||
| 240 | </dl> |
||
| 241 | <hr class="clear" />'; |
||
| 242 | |||
| 243 | // Show BBC buttons, smileys and textbox. |
||
| 244 | echo ' |
||
| 245 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); |
||
| 246 | |||
| 247 | echo ' |
||
| 248 | <ul> |
||
| 249 | <li> |
||
| 250 | <label for="send_pm"> |
||
| 251 | <input type="checkbox" name="send_pm" id="send_pm" ', !empty($context['send_pm']) ? 'checked="checked"' : '', 'onclick="checkboxes_status(this);" /> ', $txt['email_as_pms'], ' |
||
| 252 | </label> |
||
| 253 | </li> |
||
| 254 | <li> |
||
| 255 | <label for="send_html"> |
||
| 256 | <input type="checkbox" name="send_html" id="send_html" ', !empty($context['send_html']) ? 'checked="checked"' : '', 'onclick="checkboxes_status(this);" /> ', $txt['email_as_html'], ' |
||
| 257 | </label> |
||
| 258 | </li> |
||
| 259 | <li> |
||
| 260 | <label for="parse_html"> |
||
| 261 | <input type="checkbox" name="parse_html" id="parse_html" checked="checked" disabled="disabled" /> ', $txt['email_parsed_html'], ' |
||
| 262 | </label> |
||
| 263 | </li> |
||
| 264 | </ul> |
||
| 265 | <div class="submitbutton"> |
||
| 266 | ', template_control_richedit_buttons($context['post_box_name']), ' |
||
| 267 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> |
||
| 268 | <input type="hidden" name="email_force" value="', $context['email_force'], '" /> |
||
| 269 | <input type="hidden" name="total_emails" value="', $context['total_emails'], '" /> |
||
| 270 | <input type="hidden" name="max_id_member" value="', $context['max_id_member'], '" /> |
||
| 271 | </div> |
||
| 272 | </div> |
||
| 273 | </div>'; |
||
| 274 | |||
| 275 | View Code Duplication | foreach ($context['recipients'] as $key => $values) |
|
| 276 | echo ' |
||
| 277 | <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '" />'; |
||
| 278 | |||
| 279 | // The vars used to preview a newsletter without loading a new page, used by post.js previewControl() |
||
| 280 | addInlineJavascript(' |
||
| 281 | var form_name = "newsmodify", |
||
| 282 | preview_area = "news", |
||
| 283 | txt_preview_title = "' . $txt['preview_title'] . '", |
||
| 284 | txt_preview_fetch = "' . $txt['preview_fetch'] . '"; |
||
| 285 | |||
| 286 | function checkboxes_status (item) |
||
| 287 | { |
||
| 288 | if (item.id == \'send_html\') |
||
| 289 | document.getElementById(\'parse_html\').disabled = !document.getElementById(\'parse_html\').disabled; |
||
| 290 | |||
| 291 | if (item.id == \'send_pm\') |
||
| 292 | { |
||
| 293 | if (!document.getElementById(\'send_html\').checked) |
||
| 294 | document.getElementById(\'parse_html\').disabled = true; |
||
| 295 | else |
||
| 296 | document.getElementById(\'parse_html\').disabled = false; |
||
| 297 | |||
| 298 | document.getElementById(\'send_html\').disabled = !document.getElementById(\'send_html\').disabled; |
||
| 299 | } |
||
| 300 | }', true); |
||
| 301 | |||
| 302 | echo ' |
||
| 303 | </form> |
||
| 304 | </div>'; |
||
| 305 | } |
||
| 306 | |||
| 374 |