Stats.template.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines http://www.simplemachines.org
  7. * @copyright 2014 Simple Machines and individual contributors
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. function template_main()
  13. {
  14. global $context, $settings, $txt, $scripturl, $modSettings;
  15. echo '
  16. <div id="statistics" class="main_section">
  17. <div class="cat_bar">
  18. <h3 class="catbg">', $context['page_title'], '</h3>
  19. </div>
  20. <div class="roundframe title_top">
  21. <div class="title_bar">
  22. <h4 class="titlebg">
  23. <span class="stats_icon general"></span>', $txt['general_stats'], '
  24. </h4>
  25. </div>
  26. <div class="stats_left half top_row">
  27. <dl class="stats">
  28. <dt>', $txt['total_members'], ':</dt>
  29. <dd>', $context['show_member_list'] ? '<a href="' . $scripturl . '?action=mlist">' . $context['num_members'] . '</a>' : $context['num_members'], '</dd>
  30. <dt>', $txt['total_posts'], ':</dt>
  31. <dd>', $context['num_posts'], '</dd>
  32. <dt>', $txt['total_topics'], ':</dt>
  33. <dd>', $context['num_topics'], '</dd>
  34. <dt>', $txt['total_cats'], ':</dt>
  35. <dd>', $context['num_categories'], '</dd>
  36. <dt>', $txt['users_online'], ':</dt>
  37. <dd>', $context['users_online'], '</dd>
  38. <dt>', $txt['most_online'], ':</dt>
  39. <dd>', $context['most_members_online']['number'], ' - ', $context['most_members_online']['date'], '</dd>
  40. <dt>', $txt['users_online_today'], ':</dt>
  41. <dd>', $context['online_today'], '</dd>';
  42. if (!empty($modSettings['hitStats']))
  43. echo '
  44. <dt>', $txt['num_hits'], ':</dt>
  45. <dd>', $context['num_hits'], '</dd>';
  46. echo '
  47. </dl>
  48. </div>
  49. <div class="stats_right half top_row">
  50. <dl class="stats">
  51. <dt>', $txt['average_members'], ':</dt>
  52. <dd>', $context['average_members'], '</dd>
  53. <dt>', $txt['average_posts'], ':</dt>
  54. <dd>', $context['average_posts'], '</dd>
  55. <dt>', $txt['average_topics'], ':</dt>
  56. <dd>', $context['average_topics'], '</dd>
  57. <dt>', $txt['total_boards'], ':</dt>
  58. <dd>', $context['num_boards'], '</dd>
  59. <dt>', $txt['latest_member'], ':</dt>
  60. <dd>', $context['common_stats']['latest_member']['link'], '</dd>
  61. <dt>', $txt['average_online'], ':</dt>
  62. <dd>', $context['average_online'], '</dd>';
  63. if (!empty($context['gender']))
  64. echo '
  65. <dt>', $txt['gender_ratio'], ':</dt>
  66. <dd>', $context['gender']['ratio'], '</dd>';
  67. if (!empty($modSettings['hitStats']))
  68. echo '
  69. <dt>', $txt['average_hits'], ':</dt>
  70. <dd>', $context['average_hits'], '</dd>';
  71. echo '
  72. </dl>
  73. </div>
  74. </div>
  75. <div class="roundframe title_top">
  76. <div id="top_posters">
  77. <div class="title_bar">
  78. <h4 class="titlebg">
  79. <span class="stats_icon posters"></span>', $txt['top_posters'], '
  80. </h4>
  81. </div>
  82. <div class="windowbg2">
  83. <div class="content">
  84. <dl class="stats">';
  85. foreach ($context['top_posters'] as $poster)
  86. {
  87. echo '
  88. <dt>
  89. ', $poster['link'], '
  90. </dt>
  91. <dd class="statsbar">';
  92. if (!empty($poster['post_percent']))
  93. echo '
  94. <div class="bar" style="width: ', $poster['post_percent'] + 4, 'px;">
  95. <div style="width: ', $poster['post_percent'], 'px;"></div>
  96. </div>';
  97. else
  98. echo '
  99. <div class="bar empty"></div>';
  100. echo '
  101. <span class="righttext">', $poster['num_posts'], '</span>
  102. </dd>';
  103. }
  104. echo '
  105. </dl>
  106. </div>
  107. </div>
  108. </div>
  109. <div id="top_boards">
  110. <div class="title_bar">
  111. <h4 class="titlebg">
  112. <span class="stats_icon boards"></span>', $txt['top_boards'], '
  113. </h4>
  114. </div>
  115. <div class="windowbg2">
  116. <div class="content">
  117. <dl class="stats">';
  118. foreach ($context['top_boards'] as $board)
  119. {
  120. echo '
  121. <dt>
  122. ', $board['link'], '
  123. </dt>
  124. <dd class="statsbar">';
  125. if (!empty($board['post_percent']))
  126. echo '
  127. <div class="bar" style="width: ', $board['post_percent'] + 4, 'px;">
  128. <div style="width: ', $board['post_percent'], 'px;"></div>
  129. </div>';
  130. else
  131. echo '
  132. <div class="bar empty"></div>';
  133. echo '
  134. <span class="righttext">', $board['num_posts'], '</span>
  135. </dd>';
  136. }
  137. echo '
  138. </dl>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. <div class="roundframe title_top">
  144. <div id="top_topics_replies">
  145. <div class="title_bar">
  146. <h4 class="titlebg">
  147. <span class="stats_icon replies"></span>', $txt['top_topics_replies'], '
  148. </h4>
  149. </div>
  150. <div class="windowbg2">
  151. <div class="content">
  152. <dl class="stats">';
  153. foreach ($context['top_topics_replies'] as $topic)
  154. {
  155. echo '
  156. <dt>
  157. ', $topic['link'], '
  158. </dt>
  159. <dd class="statsbar">';
  160. if (!empty($topic['post_percent']))
  161. echo '
  162. <div class="bar" style="width: ', $topic['post_percent'] + 4, 'px;">
  163. <div style="width: ', $topic['post_percent'], 'px;"></div>
  164. </div>';
  165. else
  166. echo '
  167. <div class="bar empty"></div>';
  168. echo '
  169. <span class="righttext">' . $topic['num_replies'] . '</span>
  170. </dd>';
  171. }
  172. echo '
  173. </dl>
  174. </div>
  175. </div>
  176. </div>
  177. <div id="top_topics_views">
  178. <div class="title_bar">
  179. <h4 class="titlebg">
  180. <span class="stats_icon views"></span>', $txt['top_topics_views'], '
  181. </h4>
  182. </div>
  183. <div class="windowbg2">
  184. <div class="content">
  185. <dl class="stats">';
  186. foreach ($context['top_topics_views'] as $topic)
  187. {
  188. echo '
  189. <dt>', $topic['link'], '</dt>
  190. <dd class="statsbar">';
  191. if (!empty($topic['post_percent']))
  192. echo '
  193. <div class="bar" style="width: ', $topic['post_percent'] + 4, 'px;">
  194. <div style="width: ', $topic['post_percent'], 'px;"></div>
  195. </div>';
  196. else
  197. echo '
  198. <div class="bar empty"></div>';
  199. echo '
  200. <span class="righttext">' . $topic['num_views'] . '</span>
  201. </dd>';
  202. }
  203. echo '
  204. </dl>
  205. </div>
  206. </div>
  207. </div>
  208. </div>
  209. <div class="roundframe title_top">
  210. <div id="top_topics_starter">
  211. <div class="title_bar">
  212. <h4 class="titlebg">
  213. <span class="stats_icon starters"></span>', $txt['top_starters'], '
  214. </h4>
  215. </div>
  216. <div class="windowbg2">
  217. <div class="content">
  218. <dl class="stats">';
  219. foreach ($context['top_starters'] as $poster)
  220. {
  221. echo '
  222. <dt>
  223. ', $poster['link'], '
  224. </dt>
  225. <dd class="statsbar">';
  226. if (!empty($poster['post_percent']))
  227. echo '
  228. <div class="bar" style="width: ', $poster['post_percent'] + 4, 'px;">
  229. <div style="width: ', $poster['post_percent'], 'px;"></div>
  230. </div>';
  231. echo '
  232. <span class="righttext">', $poster['num_topics'], '</span>
  233. </dd>';
  234. }
  235. echo '
  236. </dl>
  237. </div>
  238. </div>
  239. </div>
  240. <div id="most_online">
  241. <div class="title_bar">
  242. <h4 class="titlebg">
  243. <span class="stats_icon history"></span>', $txt['most_time_online'], '
  244. </h4>
  245. </div>
  246. <div class="windowbg2">
  247. <div class="content">
  248. <dl class="stats">';
  249. foreach ($context['top_time_online'] as $poster)
  250. {
  251. echo '
  252. <dt>
  253. ', $poster['link'], '
  254. </dt>
  255. <dd class="statsbar">';
  256. if (!empty($poster['time_percent']))
  257. echo '
  258. <div class="bar" style="width: ', $poster['time_percent'] + 4, 'px;">
  259. <div style="width: ', $poster['time_percent'], 'px;"></div>
  260. </div>';
  261. else
  262. echo '
  263. <div class="bar empty"></div>';
  264. echo '
  265. <span>', $poster['time_online'], '</span>
  266. </dd>';
  267. }
  268. echo '
  269. </dl>
  270. </div>
  271. </div>
  272. </div>
  273. </div>
  274. <br class="clear">
  275. <div class="cat_bar">
  276. <h3 class="catbg">
  277. <span class="stats_icon history"></span>', $txt['forum_history'], '
  278. </h3>
  279. </div>
  280. <div class="roundframe title_top">';
  281. if (!empty($context['yearly']))
  282. {
  283. echo '
  284. <table border="0" cellspacing="1" cellpadding="4" class="table_grid" id="stats">
  285. <thead>
  286. <tr class="catbg" valign="middle" align="center">
  287. <th class="first_th lefttext">', $txt['yearly_summary'], '</th>
  288. <th>', $txt['stats_new_topics'], '</th>
  289. <th>', $txt['stats_new_posts'], '</th>
  290. <th>', $txt['stats_new_members'], '</th>
  291. <th', empty($modSettings['hitStats']) ? ' class="last_th"' : '', '>', $txt['most_online'], '</th>';
  292. if (!empty($modSettings['hitStats']))
  293. echo '
  294. <th class="last_th">', $txt['page_views'], '</th>';
  295. echo '
  296. </tr>
  297. </thead>
  298. <tbody>';
  299. foreach ($context['yearly'] as $id => $year)
  300. {
  301. echo '
  302. <tr class="windowbg2" valign="middle" align="center" id="year_', $id, '">
  303. <th class="lefttext">
  304. <img id="year_img_', $id, '" src="', $settings['images_url'], '/selected_open.png" alt="*"> <a href="#year_', $id, '" id="year_link_', $id, '">', $year['year'], '</a>
  305. </th>
  306. <th>', $year['new_topics'], '</th>
  307. <th>', $year['new_posts'], '</th>
  308. <th>', $year['new_members'], '</th>
  309. <th>', $year['most_members_online'], '</th>';
  310. if (!empty($modSettings['hitStats']))
  311. echo '
  312. <th>', $year['hits'], '</th>';
  313. echo '
  314. </tr>';
  315. foreach ($year['months'] as $month)
  316. {
  317. echo '
  318. <tr class="windowbg2" valign="middle" align="center" id="tr_month_', $month['id'], '">
  319. <th class="stats_month">
  320. <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'], '" onclick="return doingExpandCollapse;">', $month['month'], ' ', $month['year'], '</a>
  321. </th>
  322. <th>', $month['new_topics'], '</th>
  323. <th>', $month['new_posts'], '</th>
  324. <th>', $month['new_members'], '</th>
  325. <th>', $month['most_members_online'], '</th>';
  326. if (!empty($modSettings['hitStats']))
  327. echo '
  328. <th>', $month['hits'], '</th>';
  329. echo '
  330. </tr>';
  331. if ($month['expanded'])
  332. {
  333. foreach ($month['days'] as $day)
  334. {
  335. echo '
  336. <tr class="windowbg2" valign="middle" align="center" id="tr_day_', $day['year'], '-', $day['month'], '-', $day['day'], '">
  337. <td class="stats_day">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>
  338. <td>', $day['new_topics'], '</td>
  339. <td>', $day['new_posts'], '</td>
  340. <td>', $day['new_members'], '</td>
  341. <td>', $day['most_members_online'], '</td>';
  342. if (!empty($modSettings['hitStats']))
  343. echo '
  344. <td>', $day['hits'], '</td>';
  345. echo '
  346. </tr>';
  347. }
  348. }
  349. }
  350. }
  351. echo '
  352. </tbody>
  353. </table>
  354. </div>
  355. </div>
  356. <script src="', $settings['default_theme_url'], '/scripts/stats.js"></script>
  357. <script><!-- // --><![CDATA[
  358. var oStatsCenter = new smf_StatsCenter({
  359. sTableId: \'stats\',
  360. reYearPattern: /year_(\d+)/,
  361. sYearImageCollapsed: \'selected.png\',
  362. sYearImageExpanded: \'selected_open.png\',
  363. sYearImageIdPrefix: \'year_img_\',
  364. sYearLinkIdPrefix: \'year_link_\',
  365. reMonthPattern: /tr_month_(\d+)/,
  366. sMonthImageCollapsed: \'selected.png\',
  367. sMonthImageExpanded: \'selected_open.png\',
  368. sMonthImageIdPrefix: \'img_\',
  369. sMonthLinkIdPrefix: \'m\',
  370. reDayPattern: /tr_day_(\d+-\d+-\d+)/,
  371. sDayRowClassname: \'windowbg2\',
  372. sDayRowIdPrefix: \'tr_day_\',
  373. aCollapsedYears: [';
  374. foreach ($context['collapsed_years'] as $id => $year)
  375. {
  376. echo '
  377. \'', $year, '\'', $id != count($context['collapsed_years']) - 1 ? ',' : '';
  378. }
  379. echo '
  380. ],
  381. aDataCells: [
  382. \'date\',
  383. \'new_topics\',
  384. \'new_posts\',
  385. \'new_members\',
  386. \'most_members_online\'', empty($modSettings['hitStats']) ? '' : ',
  387. \'hits\'', '
  388. ]
  389. });
  390. // ]]></script>';
  391. }
  392. }
  393. ?>