Conditions | 10 |
Paths | 40 |
Total Lines | 85 |
Code Lines | 63 |
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 |
||
44 | function b_donations_donors_show($options) |
||
45 | { |
||
46 | global $xoopsDB; |
||
47 | $utility = new Xdonations\Utility(); |
||
48 | $tr_config = $utility::getConfigInfo(); |
||
49 | //determine the currency |
||
50 | $PP_CURR_CODE = explode('|', $tr_config['pp_curr_code']); // [USD,GBP,JPY,CAD,EUR] |
||
51 | $PP_CURR_CODE = $PP_CURR_CODE[0]; |
||
52 | $currencySign = $utility::defineCurrency($PP_CURR_CODE); |
||
53 | |||
54 | $dmshowdate = $options[1]; |
||
55 | $dmshowamt = $options[2]; |
||
56 | $block = []; |
||
57 | $swingd = $tr_config['swing_day']; |
||
58 | |||
59 | if (($swingd < 0) || ($swingd > 31)) { |
||
60 | $swingd = 6; |
||
61 | } |
||
62 | |||
63 | if (date('d') >= $swingd) { |
||
64 | $query_Recordset1 = "SELECT custom AS muser_id, option_selection1 as showname, DATE_FORMAT(payment_date, '%b %e') AS date, CONCAT('" |
||
65 | . $currencySign |
||
66 | . "',SUM(mc_gross)) AS amt FROM " |
||
67 | . $xoopsDB->prefix('donations_transactions') |
||
68 | . " WHERE (payment_date >= DATE_FORMAT(NOW(),'%Y-%m-" |
||
69 | . $swingd |
||
70 | . "')) GROUP BY txn_id ORDER BY payment_date DESC"; |
||
71 | } else { |
||
72 | $query_Recordset1 = "SELECT custom AS muser_id, option_selection1 as showname, DATE_FORMAT(payment_date, '%b-%e') AS date, CONCAT('" |
||
73 | . $currencySign |
||
74 | . "',SUM(mc_gross)) AS amt FROM " |
||
75 | . $xoopsDB->prefix('donations_transactions') |
||
76 | . " WHERE (payment_date < DATE_FORMAT(NOW(), '%Y-%m-" |
||
77 | . $swingd |
||
78 | . "')) AND payment_date > DATE_FORMAT(SUBDATE(NOW(),INTERVAL " |
||
79 | . $swingd |
||
80 | . " DAY), '%Y-%m-" |
||
81 | . $swingd |
||
82 | . "') GROUP BY txn_id ORDER BY payment_date DESC"; |
||
83 | } |
||
84 | |||
85 | $Recordset1 = $xoopsDB->query($query_Recordset1); |
||
86 | $totalRows_Recordset1 = $xoopsDB->getRowsNum($Recordset1); |
||
87 | |||
88 | $ROWS_DONATORS = ''; |
||
89 | // Fill out the donators table tag |
||
90 | while (false !== ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))) { |
||
91 | if ($row_Recordset1['amt'] > $currencySign . '0') { |
||
92 | $ROWS_DONATORS .= '<tr>'; |
||
93 | $ROWS_DONATORS .= '<td style="font-weight: bold;"> '; |
||
94 | |||
95 | $muser_id = $row_Recordset1['muser_id']; |
||
96 | if (0 == strcmp($row_Recordset1['showname'], 'Yes') && ($userfoin = $utility::getUserInfo($muser_id))) { |
||
97 | $ROWS_DONATORS .= "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userfoin->getVar('uid') . "'>" . xdshorten($userfoin->getVar('uname')) . "</a>\n"; |
||
98 | } else { |
||
99 | $ROWS_DONATORS .= _MB_XDONATION_ANONYMOUS_SHORT; |
||
100 | } |
||
101 | |||
102 | $ROWS_DONATORS .= "</td>\n"; |
||
103 | if ($dmshowamt) { |
||
104 | $ROWS_DONATORS .= "<td style=\"width: 2px;\"> </td>\n"; |
||
105 | $ROWS_DONATORS .= '<td style="width: 55px; font-weight: bold;"> '; |
||
106 | $ROWS_DONATORS .= $row_Recordset1['amt']; |
||
107 | $ROWS_DONATORS .= "</td>\n"; |
||
108 | } |
||
109 | if ($dmshowdate) { |
||
110 | $ROWS_DONATORS .= "<td style=\"width: 2px;\"> </td>\n"; |
||
111 | $ROWS_DONATORS .= '<td style="font-weight: bold;"> '; |
||
112 | $ROWS_DONATORS .= $row_Recordset1['date']; |
||
113 | $ROWS_DONATORS .= "</td>\n"; |
||
114 | } |
||
115 | $ROWS_DONATORS .= "</tr>\n"; |
||
116 | } |
||
117 | } |
||
118 | |||
119 | // Ok, output the page |
||
120 | |||
121 | $block['showamt'] = $dmshowamt; |
||
122 | $block['showdate'] = $dmshowdate; |
||
123 | $block['list'] = $ROWS_DONATORS; |
||
124 | $block['amount'] = _MB_XDONATION_AMOUNT; |
||
125 | $block['date'] = _MB_XDONATION_DATE; |
||
126 | $block['name'] = _MB_XDONATION_NAME; |
||
127 | |||
128 | return $block; |
||
129 | } |
||
181 |