Stats.template.php 12 KB

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