Conditions | 16 |
Paths | 4 |
Total Lines | 179 |
Code Lines | 44 |
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 |
||
176 | function template_email_members_compose() |
||
177 | { |
||
178 | global $context, $txt, $scripturl; |
||
179 | |||
180 | echo ' |
||
181 | <div id="preview_section"', isset($context['preview_message']) ? '' : ' class="hidden"', '> |
||
182 | <div class="cat_bar"> |
||
183 | <h3 class="catbg"> |
||
184 | <span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span> |
||
185 | </h3> |
||
186 | </div> |
||
187 | <div class="windowbg"> |
||
188 | <div class="post" id="preview_body"> |
||
189 | ', empty($context['preview_message']) ? '<br>' : $context['preview_message'], ' |
||
190 | </div> |
||
191 | </div> |
||
192 | </div> |
||
193 | <br>'; |
||
194 | |||
195 | echo ' |
||
196 | <form name="newsmodify" action="', $scripturl, '?action=admin;area=news;sa=mailingsend" method="post" accept-charset="', $context['character_set'], '"> |
||
197 | <div class="cat_bar"> |
||
198 | <h3 class="catbg"> |
||
199 | <a href="', $scripturl, '?action=helpadmin;help=email_members" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a> ', $txt['admin_newsletters'], ' |
||
200 | </h3> |
||
201 | </div> |
||
202 | <div class="information noup"> |
||
203 | ', sprintf($txt['email_variables'], $scripturl), ' |
||
204 | </div> |
||
205 | <div class="windowbg noup"> |
||
206 | <div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors"> |
||
207 | <dl> |
||
208 | <dt> |
||
209 | <strong id="error_serious">', $txt['error_while_submitting'], '</strong> |
||
210 | </dt> |
||
211 | <dd class="error" id="error_list"> |
||
212 | ', empty($context['post_error']['messages']) ? '' : implode('<br>', $context['post_error']['messages']), ' |
||
213 | </dd> |
||
214 | </dl> |
||
215 | </div> |
||
216 | <dl id="post_header"> |
||
217 | <dt> |
||
218 | <label', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' for="subject" id="caption_subject">', $txt['subject'], '</label> |
||
219 | </dt> |
||
220 | <dd id="pm_subject"> |
||
221 | <input type="text" id="subject" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="84"', isset($context['post_error']['no_subject']) ? ' class="error"' : '', '> |
||
222 | </dd> |
||
223 | </dl> |
||
224 | <div id="bbcBox_message"></div>'; |
||
225 | |||
226 | // What about smileys? |
||
227 | if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) |
||
228 | echo ' |
||
229 | <div id="smileyBox_message"></div>'; |
||
230 | |||
231 | // Show BBC buttons, smileys and textbox. |
||
232 | echo ' |
||
233 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); |
||
234 | |||
235 | echo ' |
||
236 | <ul> |
||
237 | <li><label for="send_pm"><input type="checkbox" name="send_pm" id="send_pm"', !empty($context['send_pm']) ? ' checked' : '', ' onclick="checkboxes_status(this);"> ', $txt['email_as_pms'], '</label></li> |
||
238 | <li><label for="send_html"><input type="checkbox" name="send_html" id="send_html"', !empty($context['send_html']) ? ' checked' : '', ' onclick="checkboxes_status(this);"> ', $txt['email_as_html'], '</label></li> |
||
239 | <li><label for="parse_html"><input type="checkbox" name="parse_html" id="parse_html" checked disabled> ', $txt['email_parsed_html'], '</label></li> |
||
240 | </ul> |
||
241 | <span id="post_confirm_buttons"> |
||
242 | ', template_control_richedit_buttons($context['post_box_name']), ' |
||
243 | </span> |
||
244 | </div><!-- .windowbg --> |
||
245 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||
246 | <input type="hidden" name="email_force" value="', $context['email_force'], '"> |
||
247 | <input type="hidden" name="total_emails" value="', $context['total_emails'], '">'; |
||
248 | |||
249 | foreach ($context['recipients'] as $key => $values) |
||
250 | echo ' |
||
251 | <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">'; |
||
252 | |||
253 | echo ' |
||
254 | <script>'; |
||
255 | |||
256 | // The functions used to preview a posts without loading a new page. |
||
257 | echo ' |
||
258 | var txt_preview_title = "', $txt['preview_title'], '"; |
||
259 | var txt_preview_fetch = "', $txt['preview_fetch'], '"; |
||
260 | function previewPost() |
||
261 | { |
||
262 | if (window.XMLHttpRequest) |
||
263 | { |
||
264 | // Opera didn\'t support setRequestHeader() before 8.01. |
||
265 | // @todo Remove support for old browsers |
||
266 | if (\'opera\' in window) |
||
267 | { |
||
268 | // Handle the WYSIWYG editor. |
||
269 | if (textFields[i] == ', JavaScriptEscape($context['post_box_name']), ' && ', JavaScriptEscape('oEditorHandle_' . $context['post_box_name']), ' in window && oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled) |
||
270 | x[x.length] = \'message_mode=1&\' + textFields[i] + \'=\' + oEditorHandle_', $context['post_box_name'], '.getText(false).php_to8bit().php_urlencode(); |
||
271 | else |
||
272 | x[x.length] = textFields[i] + \'=\' + document.forms.newsmodify[textFields[i]].value.php_to8bit().php_urlencode(); |
||
273 | } |
||
274 | // @todo Currently not sending poll options and option checkboxes. |
||
275 | var x = new Array(); |
||
276 | var textFields = [\'subject\', ', JavaScriptEscape($context['post_box_name']), ']; |
||
277 | var checkboxFields = [\'send_html\', \'send_pm\']; |
||
278 | |||
279 | for (var i = 0, n = textFields.length; i < n; i++) |
||
280 | if (textFields[i] in document.forms.newsmodify) |
||
281 | { |
||
282 | // Handle the WYSIWYG editor. |
||
283 | if (textFields[i] == ', JavaScriptEscape($context['post_box_name']), ' && ', JavaScriptEscape('oEditorHandle_' . $context['post_box_name']), ' in window && oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled) |
||
284 | x[x.length] = \'message_mode=1&\' + textFields[i] + \'=\' + oEditorHandle_', $context['post_box_name'], '.getText(false).replace(/&#/g, \'&#\').php_to8bit().php_urlencode(); |
||
285 | else |
||
286 | x[x.length] = textFields[i] + \'=\' + document.forms.newsmodify[textFields[i]].value.replace(/&#/g, \'&#\').php_to8bit().php_urlencode(); |
||
287 | } |
||
288 | for (var i = 0, n = checkboxFields.length; i < n; i++) |
||
289 | if (checkboxFields[i] in document.forms.newsmodify && document.forms.newsmodify.elements[checkboxFields[i]].checked) |
||
290 | x[x.length] = checkboxFields[i] + \'=\' + document.forms.newsmodify.elements[checkboxFields[i]].value; |
||
291 | |||
292 | x[x.length] = \'item=newsletterpreview\'; |
||
293 | |||
294 | sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=xmlhttp;sa=previews;xml\', x.join(\'&\'), onDocSent); |
||
295 | |||
296 | document.getElementById(\'preview_section\').style.display = \'\'; |
||
297 | setInnerHTML(document.getElementById(\'preview_subject\'), txt_preview_title); |
||
298 | setInnerHTML(document.getElementById(\'preview_body\'), txt_preview_fetch); |
||
299 | |||
300 | return false; |
||
301 | } |
||
302 | else |
||
303 | return submitThisOnce(document.forms.newsmodify); |
||
304 | } |
||
305 | function onDocSent(XMLDoc) |
||
306 | { |
||
307 | if (!XMLDoc) |
||
308 | { |
||
309 | document.forms.newsmodify.preview.onclick = new function () |
||
310 | { |
||
311 | return true; |
||
312 | } |
||
313 | document.forms.newsmodify.preview.click(); |
||
314 | } |
||
315 | |||
316 | // Show the preview section. |
||
317 | var preview = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'preview\')[0]; |
||
318 | setInnerHTML(document.getElementById(\'preview_subject\'), preview.getElementsByTagName(\'subject\')[0].firstChild.nodeValue); |
||
319 | |||
320 | var bodyText = \'\'; |
||
321 | for (var i = 0, n = preview.getElementsByTagName(\'body\')[0].childNodes.length; i < n; i++) |
||
322 | bodyText += preview.getElementsByTagName(\'body\')[0].childNodes[i].nodeValue; |
||
323 | |||
324 | setInnerHTML(document.getElementById(\'preview_body\'), bodyText); |
||
325 | document.getElementById(\'preview_body\').className = \'post\'; |
||
326 | |||
327 | // Show a list of errors (if any). |
||
328 | var errors = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'errors\')[0]; |
||
329 | var errorList = new Array(); |
||
330 | for (var i = 0, numErrors = errors.getElementsByTagName(\'error\').length; i < numErrors; i++) |
||
331 | errorList[errorList.length] = errors.getElementsByTagName(\'error\')[i].firstChild.nodeValue; |
||
332 | document.getElementById(\'errors\').style.display = numErrors == 0 ? \'none\' : \'\'; |
||
333 | setInnerHTML(document.getElementById(\'error_list\'), numErrors == 0 ? \'\' : errorList.join(\'<br>\')); |
||
334 | |||
335 | // Adjust the color of captions if the given data is erroneous. |
||
336 | var captions = errors.getElementsByTagName(\'caption\'); |
||
337 | for (var i = 0, numCaptions = errors.getElementsByTagName(\'caption\').length; i < numCaptions; i++) |
||
338 | if (document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\'))) |
||
339 | document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')).className = captions[i].getAttribute(\'class\'); |
||
340 | |||
341 | if (errors.getElementsByTagName(\'post_error\').length == 1) |
||
342 | document.forms.newsmodify.', $context['post_box_name'], '.style.border = \'1px solid red\'; |
||
343 | else if (document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor == \'red\' || document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor == \'red red red red\') |
||
344 | { |
||
345 | if (\'runtimeStyle\' in document.forms.newsmodify.', $context['post_box_name'], ') |
||
346 | document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor = \'\'; |
||
347 | else |
||
348 | document.forms.newsmodify.', $context['post_box_name'], '.style.border = null; |
||
349 | } |
||
350 | location.hash = \'#\' + \'preview_section\'; |
||
351 | } |
||
352 | </script>'; |
||
353 | |||
354 | echo ' |
||
355 | <script> |
||
446 | ?> |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.