| Conditions | 14 |
| Paths | 77 |
| Total Lines | 141 |
| 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 |
||
| 241 | function template_forum_history() |
||
| 242 | { |
||
| 243 | global $context, $settings, $txt, $modSettings; |
||
| 244 | |||
| 245 | echo ' |
||
| 246 | <div id="forum_history" class="forum_category"> |
||
| 247 | <h2 class="category_header hdicon cat_img_clock"> |
||
| 248 | ', $txt['forum_history'], ' |
||
| 249 | </h2> |
||
| 250 | <div class="flow_hidden">'; |
||
| 251 | |||
| 252 | if (!empty($context['yearly'])) |
||
| 253 | { |
||
| 254 | echo ' |
||
| 255 | <table class="table_grid" id="stats"> |
||
| 256 | <thead> |
||
| 257 | <tr> |
||
| 258 | <th class="history_head lefttext">', $txt['yearly_summary'], '</th> |
||
| 259 | <th class="history_head">', $txt['stats_new_topics'], '</th> |
||
| 260 | <th class="history_head">', $txt['stats_new_posts'], '</th> |
||
| 261 | <th class="history_head">', $txt['stats_new_members'], '</th> |
||
| 262 | <th class="history_head">', $txt['most_online'], '</th>'; |
||
| 263 | |||
| 264 | if (!empty($modSettings['hitStats'])) |
||
| 265 | echo ' |
||
| 266 | <th class="history_head">', $txt['page_views'], '</th>'; |
||
| 267 | |||
| 268 | echo ' |
||
| 269 | </tr> |
||
| 270 | </thead> |
||
| 271 | <tbody>'; |
||
| 272 | |||
| 273 | foreach ($context['yearly'] as $id => $year) |
||
| 274 | { |
||
| 275 | echo ' |
||
| 276 | <tr id="year_', $id, '"> |
||
| 277 | <th class="stats_year lefttext"> |
||
| 278 | <img id="year_img_', $id, '" src="', $settings['images_url'], '/selected_open.png" alt="*" /> <a href="#year_', $id, '" id="year_link_', $id, '">', $year['year'], '</a> |
||
| 279 | </th> |
||
| 280 | <th>', $year['new_topics'], '</th> |
||
| 281 | <th>', $year['new_posts'], '</th> |
||
| 282 | <th>', $year['new_members'], '</th> |
||
| 283 | <th>', $year['most_members_online'], '</th>'; |
||
| 284 | |||
| 285 | if (!empty($modSettings['hitStats'])) |
||
| 286 | echo ' |
||
| 287 | <th>', $year['hits'], '</th>'; |
||
| 288 | |||
| 289 | echo ' |
||
| 290 | </tr>'; |
||
| 291 | |||
| 292 | foreach ($year['months'] as $month) |
||
| 293 | { |
||
| 294 | echo ' |
||
| 295 | <tr id="tr_month_', $month['id'], '"> |
||
| 296 | <th class="stats_month lefttext"> |
||
| 297 | <img src="', $settings['images_url'], '/', $month['expanded'] ? 'selected_open.png' : 'selected.png', '" alt="" id="img_', $month['id'], '" /> <a id="m', $month['id'], '" href="', $month['href'], '">', $month['month'], ' ', $month['year'], '</a> |
||
| 298 | </th> |
||
| 299 | <th>', $month['new_topics'], '</th> |
||
| 300 | <th>', $month['new_posts'], '</th> |
||
| 301 | <th>', $month['new_members'], '</th> |
||
| 302 | <th>', $month['most_members_online'], '</th>'; |
||
| 303 | |||
| 304 | if (!empty($modSettings['hitStats'])) |
||
| 305 | echo ' |
||
| 306 | <th>', $month['hits'], '</th>'; |
||
| 307 | |||
| 308 | echo ' |
||
| 309 | </tr>'; |
||
| 310 | |||
| 311 | if ($month['expanded']) |
||
| 312 | { |
||
| 313 | foreach ($month['days'] as $day) |
||
| 314 | { |
||
| 315 | echo ' |
||
| 316 | <tr id="tr_day_', $day['year'], '-', $day['month'], '-', $day['day'], '"> |
||
| 317 | <td class="stats_day lefttext">', $day['year'], '-', $day['month'], '-', $day['day'], '</td> |
||
| 318 | <td>', $day['new_topics'], '</td> |
||
| 319 | <td>', $day['new_posts'], '</td> |
||
| 320 | <td>', $day['new_members'], '</td> |
||
| 321 | <td>', $day['most_members_online'], '</td>'; |
||
| 322 | |||
| 323 | if (!empty($modSettings['hitStats'])) |
||
| 324 | echo ' |
||
| 325 | <td>', $day['hits'], '</td>'; |
||
| 326 | |||
| 327 | echo ' |
||
| 328 | </tr>'; |
||
| 329 | } |
||
| 330 | } |
||
| 331 | } |
||
| 332 | } |
||
| 333 | |||
| 334 | echo ' |
||
| 335 | </tbody> |
||
| 336 | </table> |
||
| 337 | </div> |
||
| 338 | </div> |
||
| 339 | <script> |
||
| 340 | var oStatsCenter = new elk_StatsCenter({ |
||
| 341 | sTableId: \'stats\', |
||
| 342 | |||
| 343 | reYearPattern: /year_(\d+)/, |
||
| 344 | sYearImageCollapsed: \'selected.png\', |
||
| 345 | sYearImageExpanded: \'selected_open.png\', |
||
| 346 | sYearImageIdPrefix: \'year_img_\', |
||
| 347 | sYearLinkIdPrefix: \'year_link_\', |
||
| 348 | |||
| 349 | reMonthPattern: /tr_month_(\d+)/, |
||
| 350 | sMonthImageCollapsed: \'selected.png\', |
||
| 351 | sMonthImageExpanded: \'selected_open.png\', |
||
| 352 | sMonthImageIdPrefix: \'img_\', |
||
| 353 | sMonthLinkIdPrefix: \'m\', |
||
| 354 | |||
| 355 | reDayPattern: /tr_day_(\d+-\d+-\d+)/, |
||
| 356 | sDayRowClassname: \'\', |
||
| 357 | sDayRowIdPrefix: \'tr_day_\', |
||
| 358 | |||
| 359 | aCollapsedYears: ['; |
||
| 360 | |||
| 361 | foreach ($context['collapsed_years'] as $id => $year) |
||
| 362 | { |
||
| 363 | echo ' |
||
| 364 | \'', $year, '\'', $id != count($context['collapsed_years']) - 1 ? ',' : ''; |
||
| 365 | } |
||
| 366 | |||
| 367 | echo ' |
||
| 368 | ], |
||
| 369 | |||
| 370 | aDataCells: [ |
||
| 371 | \'date\', |
||
| 372 | \'new_topics\', |
||
| 373 | \'new_posts\', |
||
| 374 | \'new_members\', |
||
| 375 | \'most_members_online\'', empty($modSettings['hitStats']) ? '' : ', |
||
| 376 | \'hits\'', ' |
||
| 377 | ] |
||
| 378 | }); |
||
| 379 | </script>'; |
||
| 380 | } |
||
| 381 | } |
||
| 382 |