| Conditions | 2 |
| Paths | 2 |
| Total Lines | 59 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 38 | function PrintPage($articleID) |
||
| 39 | { |
||
| 40 | global $moduleDirName; |
||
| 41 | global $xoopsConfig, $xoopsModule; |
||
| 42 | /** @var Soapbox\Helper $helper */ |
||
| 43 | $helper = Soapbox\Helper::getInstance(); |
||
| 44 | |||
| 45 | $cleantags = new Soapbox\Cleantags(); |
||
| 46 | |||
| 47 | $myts = \MyTextSanitizer:: getInstance(); |
||
| 48 | $articleID = (int)$articleID; |
||
| 49 | //get entry object |
||
| 50 | /** @var \XoopsModules\Soapbox\EntrygetHandler $entrydataHandler */ |
||
| 51 | $entrydataHandler = new \XoopsModules\Soapbox\EntrygetHandler(); |
||
| 52 | $_entryob = $entrydataHandler->getArticleOnePermcheck($articleID, true, true); |
||
| 53 | if (!is_object($_entryob)) { |
||
| 54 | redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/index.php', 1, 'Not Found'); |
||
| 55 | } |
||
| 56 | //------------------------------------- |
||
| 57 | $articles = $_entryob->toArray(); |
||
| 58 | //get category object |
||
| 59 | $_categoryob = $_entryob->_sbcolumns; |
||
| 60 | //get vars |
||
| 61 | $category = $_categoryob->toArray(); |
||
| 62 | //------------------------------------- |
||
| 63 | //get author |
||
| 64 | $authorname = Soapbox\Utility::getAuthorName($category['author']); |
||
| 65 | //------------------------------------- |
||
| 66 | |||
| 67 | $datetime = $myts->htmlSpecialChars(formatTimestamp($articles['datesub'], $helper->getConfig('dateformat'))); |
||
| 68 | // $lead = $myts->htmlSpecialChars($lead); |
||
| 69 | // $bodytext = str_replace("[pagebreak]","<br style=\"page-break-after:always;\">",$bodytext); |
||
| 70 | // $bodytext = $myts->displayTarea($bodytext, $html, $smiley, $xcodes, '', $breaks); |
||
| 71 | $bodytext = str_replace('[pagebreak]', '<br style="page-break-after:always;">', $_entryob->getVar('bodytext', 'none')); |
||
| 72 | $bodytext = $cleantags->cleanTags($myts->displayTarea($bodytext, $articles['html'], $articles['smiley'], $articles['xcodes'], '', $articles['breaks'])); |
||
|
|
|||
| 73 | |||
| 74 | $sitename = $myts->htmlSpecialChars($xoopsConfig['sitename']); |
||
| 75 | $slogan = $myts->htmlSpecialChars($xoopsConfig['slogan']); |
||
| 76 | |||
| 77 | echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n"; |
||
| 78 | echo "<html>\n<head>\n"; |
||
| 79 | echo '<title>' . $sitename . "</title>\n"; |
||
| 80 | echo "<meta http-equiv='Content-Type' content='text/html; charset=" . _CHARSET . "'>\n"; |
||
| 81 | echo "<meta name='AUTHOR' content='" . $sitename . "'>\n"; |
||
| 82 | echo "<meta name='COPYRIGHT' content='Copyright (с) " . $sitename . "'>\n"; |
||
| 83 | echo "<meta name='DESCRIPTION' content='" . $slogan . "'>\n"; |
||
| 84 | echo "<meta name='GENERATOR' content='" . XOOPS_VERSION . "'>\n\n\n"; |
||
| 85 | |||
| 86 | //hack start 2003-3-18 by toshimitsu |
||
| 87 | //Column: --> _MD_SOAPBOX_COLUMNPRN , Author: --> _MD_SOAPBOX_AUTHORPRN |
||
| 88 | echo "<body bgcolor='#ffffff' text='#000000'> |
||
| 89 | <div style='width: 600px; border: 1px solid #000; padding: 20px;'> |
||
| 90 | <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'><h2 style='margin: 0;'>" . $sitename . '<br>' . $articles['headline'] . '</h2></div> |
||
| 91 | <div></div> |
||
| 92 | <div>' . _MD_SOAPBOX_COLUMNPRN . '<b>' . $category['name'] . "</b></div> |
||
| 93 | <div style='padding-bottom: 6px; border-bottom: 1px solid #ccc;'>" . _MD_SOAPBOX_AUTHORPRN . ' <b>' . $authorname . '</b></div> |
||
| 94 | <p>' . $articles['lead'] . '</p> |
||
| 95 | <p>' . $articles['bodytext'] . "</p> |
||
| 96 | <div style='padding-top: 12px; border-top: 2px solid #ccc;'><small><b>Published:</b> " . $datetime . '<br></div> |
||
| 97 | </div> |
||
| 104 |