Conditions | 4 |
Paths | 2 |
Total Lines | 76 |
Code Lines | 45 |
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 |
||
26 | public function index() { |
||
27 | |||
28 | print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; |
||
29 | print "<div dojoType=\"dijit.layout.AccordionPane\" |
||
30 | title=\"<i class='material-icons'>report</i> ".__('Event Log')."\">"; |
||
31 | |||
32 | if (LOG_DESTINATION == "sql") { |
||
|
|||
33 | |||
34 | $res = $this->pdo->query("SELECT errno, errstr, filename, lineno, |
||
35 | created_at, login, context FROM ttrss_error_log |
||
36 | LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id) |
||
37 | ORDER BY ttrss_error_log.id DESC |
||
38 | LIMIT 100"); |
||
39 | |||
40 | print "<button dojoType=\"dijit.form.Button\" |
||
41 | onclick=\"Helpers.updateEventLog()\">".__('Refresh')."</button> "; |
||
42 | |||
43 | print " <button dojoType=\"dijit.form.Button\" |
||
44 | class=\"alt-danger\" onclick=\"Helpers.clearEventLog()\">".__('Clear')."</button> "; |
||
45 | |||
46 | print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">"; |
||
47 | |||
48 | print "<tr class=\"title\"> |
||
49 | <td width='5%'>".__("Error")."</td> |
||
50 | <td>".__("Filename")."</td> |
||
51 | <td>".__("Message")."</td> |
||
52 | <td width='5%'>".__("User")."</td> |
||
53 | <td width='5%'>".__("Date")."</td> |
||
54 | </tr>"; |
||
55 | |||
56 | while ($line = $res->fetch()) { |
||
57 | print "<tr>"; |
||
58 | |||
59 | foreach ($line as $k => $v) { |
||
60 | $line[$k] = htmlspecialchars($v); |
||
61 | } |
||
62 | |||
63 | print "<td class='errno'>".Logger::$errornames[$line["errno"]]." (".$line["errno"].")</td>"; |
||
64 | print "<td class='filename'>".$line["filename"].":".$line["lineno"]."</td>"; |
||
65 | print "<td class='errstr'>".$line["errstr"]."<hr/>".nl2br($line["context"])."</td>"; |
||
66 | print "<td class='login'>".$line["login"]."</td>"; |
||
67 | |||
68 | print "<td class='timestamp'>". |
||
69 | make_local_datetime( |
||
70 | $line["created_at"], false)."</td>"; |
||
71 | |||
72 | print "</tr>"; |
||
73 | } |
||
74 | |||
75 | print "</table>"; |
||
76 | } else { |
||
77 | |||
78 | print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); |
||
79 | |||
80 | } |
||
81 | |||
82 | print "</div>"; |
||
83 | |||
84 | print "<div dojoType=\"dijit.layout.AccordionPane\" |
||
85 | title=\"<i class='material-icons'>info</i> ".__('PHP Information')."\">"; |
||
86 | |||
87 | ob_start(); |
||
88 | phpinfo(); |
||
89 | $info = ob_get_contents(); |
||
90 | ob_end_clean(); |
||
91 | |||
92 | print "<div class='phpinfo'>"; |
||
93 | print preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $info); |
||
94 | print "</div>"; |
||
95 | |||
96 | print "</div>"; |
||
97 | |||
98 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, |
||
99 | "hook_prefs_tab", "prefSystem"); |
||
100 | |||
101 | print "</div>"; #container |
||
102 | } |
||
105 |