Conditions | 7 |
Paths | 4 |
Total Lines | 57 |
Code Lines | 38 |
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 declare(strict_types=1); |
||
53 | function manage() |
||
54 | { |
||
55 | global $icons; |
||
56 | $faqAdapters = FaqAdapterFactory::installedAdapters(); |
||
57 | $myAdapter = FaqAdapterFactory::getFaqAdapter(); |
||
58 | xoops_cp_header(); |
||
59 | //echo $oAdminButton->renderButtons('manFaqAdapters'); |
||
60 | $adminObject = Admin::getInstance(); |
||
61 | $adminObject->displayNavigation(basename(__FILE__)); |
||
62 | |||
63 | echo "<form method='post' action='" . XHELP_ADMIN_URL . "/faqAdapter.php?op=updateActive'>"; |
||
|
|||
64 | echo "<table width='100%' cellspacing='1' class='outer'>"; |
||
65 | |||
66 | if (!empty($faqAdapters)) { |
||
67 | echo "<tr><th colspan='5'>" . _AM_XHELP_MENU_MANAGE_FAQ . '</th></tr>'; |
||
68 | echo "<tr class='head'> |
||
69 | <td>" . _AM_XHELP_TEXT_NAME . '</td> |
||
70 | <td>' . _AM_XHELP_TEXT_PLUGIN_VERSION . '</td> |
||
71 | <td>' . _AM_XHELP_TEXT_TESTED_VERSIONS . '</td> |
||
72 | <td>' . _AM_XHELP_TEXT_AUTHOR . '</td> |
||
73 | <td>' . _AM_XHELP_TEXT_ACTIVE . '</td> |
||
74 | </tr>'; |
||
75 | |||
76 | $activeAdapter = Utility::getMeta('faq_adapter'); |
||
77 | foreach ($faqAdapters as $name => $oAdapter) { |
||
78 | $modname = $name; |
||
79 | $author = $oAdapter->meta['author']; |
||
80 | $author_name = $author; |
||
81 | |||
82 | if ('' != $oAdapter->meta['url']) { // If a website is specified |
||
83 | $name = "<a href='" . $oAdapter->meta['url'] . "'>" . $oAdapter->meta['name'] . '</a>'; // Add link to module name |
||
84 | } |
||
85 | if ('' != $oAdapter->meta['author_email']) { |
||
86 | $author = "<a href='mailto:" . $oAdapter->meta['author_email'] . "'>" . $author_name . '</a>'; // Add link to email author |
||
87 | } |
||
88 | echo "<tr class='even'> |
||
89 | <td>" . $name . '</td> |
||
90 | <td>' . $oAdapter->meta['version'] . '</td> |
||
91 | <td>' . $oAdapter->meta['tested_versions'] . '</td> |
||
92 | <td>' . $author . "</td> |
||
93 | <td> |
||
94 | <input type='image' src='" . ($activeAdapter == $modname ? XHELP_IMAGE_URL . '/on.png' : XHELP_IMAGE_URL . '/off.png') . "' name='modname' value='" . $modname . "' style='border:0;background:transparent;'> |
||
95 | </td> |
||
96 | </tr>"; |
||
97 | } |
||
98 | } else { |
||
99 | // Display "no adapters found" message |
||
100 | echo '<tr><th>' . _AM_XHELP_MENU_MANAGE_FAQ . '</th></tr>'; |
||
101 | echo "<tr><td class='even'>" . _AM_XHELP_TEXT_NO_FILES . '</td></tr>'; |
||
102 | } |
||
103 | echo '</table></form>'; |
||
104 | |||
105 | if (is_object($myAdapter)) { |
||
106 | $faq = $myAdapter->createFaq(); |
||
107 | } |
||
108 | |||
109 | require_once __DIR__ . '/admin_footer.php'; |
||
110 | } |
||
137 |