Stats.template.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2013 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, $options, $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. <img src="', $settings['images_url'], '/stats_info.png" class="icon" alt="" /> ', $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. <img src="', $settings['images_url'], '/stats_posters.png" class="icon" alt="" /> ', $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. echo '
  106. <span class="righttext">', $poster['num_posts'], '</span>
  107. </dd>';
  108. }
  109. echo '
  110. </dl>
  111. </div>
  112. </div>
  113. </div>
  114. <div id="top_boards">
  115. <div class="title_bar">
  116. <h4 class="titlebg statstitle">
  117. <img src="', $settings['images_url'], '/stats_board.png" class="icon" alt="" /> ', $txt['top_boards'], '
  118. </h4>
  119. </div>
  120. <div class="windowbg2">
  121. <div class="content">
  122. <dl class="stats">';
  123. foreach ($context['top_boards'] as $board)
  124. {
  125. echo '
  126. <dt>
  127. ', $board['link'], '
  128. </dt>
  129. <dd class="statsbar">';
  130. if (!empty($board['post_percent']))
  131. echo '
  132. <div class="bar" style="width: ', $board['post_percent'] + 4, 'px;">
  133. <div style="width: ', $board['post_percent'], 'px;"></div>
  134. </div>';
  135. echo '
  136. <span class="righttext">', $board['num_posts'], '</span>
  137. </dd>';
  138. }
  139. echo '
  140. </dl>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. <div class="flow_hidden">
  146. <div id="top_topics_replies">
  147. <div class="title_bar">
  148. <h4 class="titlebg statstitle">
  149. <img src="', $settings['images_url'], '/stats_replies.png" class="icon" alt="" /> ', $txt['top_topics_replies'], '
  150. </h4>
  151. </div>
  152. <div class="windowbg2">
  153. <div class="content">
  154. <dl class="stats">';
  155. foreach ($context['top_topics_replies'] as $topic)
  156. {
  157. echo '
  158. <dt>
  159. ', $topic['link'], '
  160. </dt>
  161. <dd class="statsbar">';
  162. if (!empty($topic['post_percent']))
  163. echo '
  164. <div class="bar" style="width: ', $topic['post_percent'] + 4, 'px;">
  165. <div style="width: ', $topic['post_percent'], 'px;"></div>
  166. </div>';
  167. echo '
  168. <span class="righttext">' . $topic['num_replies'] . '</span>
  169. </dd>';
  170. }
  171. echo '
  172. </dl>
  173. </div>
  174. </div>
  175. </div>
  176. <div id="top_topics_views">
  177. <div class="title_bar">
  178. <h4 class="titlebg statstitle">
  179. <img src="', $settings['images_url'], '/stats_views.png" class="icon" alt="" /> ', $txt['top_topics_views'], '
  180. </h4>
  181. </div>
  182. <div class="windowbg2">
  183. <div class="content">
  184. <dl class="stats">';
  185. foreach ($context['top_topics_views'] as $topic)
  186. {
  187. echo '
  188. <dt>', $topic['link'], '</dt>
  189. <dd class="statsbar">';
  190. if (!empty($topic['post_percent']))
  191. echo '
  192. <div class="bar" style="width: ', $topic['post_percent'] + 4, 'px;">
  193. <div style="width: ', $topic['post_percent'], 'px;"></div>
  194. </div>';
  195. echo '
  196. <span class="righttext">' . $topic['num_views'] . '</span>
  197. </dd>';
  198. }
  199. echo '
  200. </dl>
  201. </div>
  202. </div>
  203. </div>
  204. </div>
  205. <div class="flow_hidden">
  206. <div id="top_topics_starter">
  207. <div class="title_bar">
  208. <h4 class="titlebg statstitle">
  209. <img src="', $settings['images_url'], '/stats_replies.png" class="icon" alt="" /> ', $txt['top_starters'], '
  210. </h4>
  211. </div>
  212. <div class="windowbg2">
  213. <div class="content">
  214. <dl class="stats">';
  215. foreach ($context['top_starters'] as $poster)
  216. {
  217. echo '
  218. <dt>
  219. ', $poster['link'], '
  220. </dt>
  221. <dd class="statsbar">';
  222. if (!empty($poster['post_percent']))
  223. echo '
  224. <div class="bar" style="width: ', $poster['post_percent'] + 4, 'px;">
  225. <div style="width: ', $poster['post_percent'], 'px;"></div>
  226. </div>';
  227. echo '
  228. <span class="righttext">', $poster['num_topics'], '</span>
  229. </dd>';
  230. }
  231. echo '
  232. </dl>
  233. </div>
  234. </div>
  235. </div>
  236. <div id="most_online">
  237. <div class="title_bar">
  238. <h4 class="titlebg statstitle">
  239. <img src="', $settings['images_url'], '/stats_views.png" class="icon" alt="" /> ', $txt['most_time_online'], '
  240. </h4>
  241. </div>
  242. <div class="windowbg2">
  243. <div class="content">
  244. <dl class="stats">';
  245. foreach ($context['top_time_online'] as $poster)
  246. {
  247. echo '
  248. <dt>
  249. ', $poster['link'], '
  250. </dt>
  251. <dd class="statsbar">';
  252. if (!empty($poster['time_percent']))
  253. echo '
  254. <div class="bar" style="width: ', $poster['time_percent'] + 4, 'px;">
  255. <div style="width: ', $poster['time_percent'], 'px;"></div>
  256. </div>';
  257. echo '
  258. <span>', $poster['time_online'], '</span>
  259. </dd>';
  260. }
  261. echo '
  262. </dl>
  263. </div>
  264. </div>
  265. </div>
  266. </div>
  267. <br class="clear" />
  268. <div class="cat_bar">
  269. <h3 class="catbg">
  270. <img src="', $settings['images_url'], '/stats_history.png" class="icon" alt="" /> ', $txt['forum_history'], '
  271. </h3>
  272. </div>
  273. <div class="flow_hidden">';
  274. if (!empty($context['yearly']))
  275. {
  276. echo '
  277. <table border="0" width="100%" cellspacing="1" cellpadding="4" class="table_grid" id="stats">
  278. <thead>
  279. <tr class="titlebg" valign="middle" align="center">
  280. <th class="first_th lefttext" width="25%">', $txt['yearly_summary'], '</th>
  281. <th width="15%">', $txt['stats_new_topics'], '</th>
  282. <th width="15%">', $txt['stats_new_posts'], '</th>
  283. <th width="15%">', $txt['stats_new_members'], '</th>
  284. <th', empty($modSettings['hitStats']) ? ' class="last_th"' : '', ' width="15%">', $txt['most_online'], '</th>';
  285. if (!empty($modSettings['hitStats']))
  286. echo '
  287. <th class="last_th">', $txt['page_views'], '</th>';
  288. echo '
  289. </tr>
  290. </thead>
  291. <tbody>';
  292. foreach ($context['yearly'] as $id => $year)
  293. {
  294. echo '
  295. <tr class="windowbg2" valign="middle" align="center" id="year_', $id, '">
  296. <th class="lefttext" width="25%">
  297. <img id="year_img_', $id, '" src="', $settings['images_url'], '/selected_open.png" alt="*" /> <a href="#year_', $id, '" id="year_link_', $id, '">', $year['year'], '</a>
  298. </th>
  299. <th width="15%">', $year['new_topics'], '</th>
  300. <th width="15%">', $year['new_posts'], '</th>
  301. <th width="15%">', $year['new_members'], '</th>
  302. <th width="15%">', $year['most_members_online'], '</th>';
  303. if (!empty($modSettings['hitStats']))
  304. echo '
  305. <th>', $year['hits'], '</th>';
  306. echo '
  307. </tr>';
  308. foreach ($year['months'] as $month)
  309. {
  310. echo '
  311. <tr class="windowbg2" valign="middle" align="center" id="tr_month_', $month['id'], '">
  312. <th class="stats_month">
  313. <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>
  314. </th>
  315. <th width="15%">', $month['new_topics'], '</th>
  316. <th width="15%">', $month['new_posts'], '</th>
  317. <th width="15%">', $month['new_members'], '</th>
  318. <th width="15%">', $month['most_members_online'], '</th>';
  319. if (!empty($modSettings['hitStats']))
  320. echo '
  321. <th>', $month['hits'], '</th>';
  322. echo '
  323. </tr>';
  324. if ($month['expanded'])
  325. {
  326. foreach ($month['days'] as $day)
  327. {
  328. echo '
  329. <tr class="windowbg2" valign="middle" align="center" id="tr_day_', $day['year'], '-', $day['month'], '-', $day['day'], '">
  330. <td class="stats_day">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>
  331. <td>', $day['new_topics'], '</td>
  332. <td>', $day['new_posts'], '</td>
  333. <td>', $day['new_members'], '</td>
  334. <td>', $day['most_members_online'], '</td>';
  335. if (!empty($modSettings['hitStats']))
  336. echo '
  337. <td>', $day['hits'], '</td>';
  338. echo '
  339. </tr>';
  340. }
  341. }
  342. }
  343. }
  344. echo '
  345. </tbody>
  346. </table>
  347. </div>
  348. </div>
  349. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/stats.js"></script>
  350. <script type="text/javascript"><!-- // --><![CDATA[
  351. var oStatsCenter = new smf_StatsCenter({
  352. sTableId: \'stats\',
  353. reYearPattern: /year_(\d+)/,
  354. sYearImageCollapsed: \'selected.png\',
  355. sYearImageExpanded: \'selected_open.png\',
  356. sYearImageIdPrefix: \'year_img_\',
  357. sYearLinkIdPrefix: \'year_link_\',
  358. reMonthPattern: /tr_month_(\d+)/,
  359. sMonthImageCollapsed: \'selected.png\',
  360. sMonthImageExpanded: \'selected_open.png\',
  361. sMonthImageIdPrefix: \'img_\',
  362. sMonthLinkIdPrefix: \'m\',
  363. reDayPattern: /tr_day_(\d+-\d+-\d+)/,
  364. sDayRowClassname: \'windowbg2\',
  365. sDayRowIdPrefix: \'tr_day_\',
  366. aCollapsedYears: [';
  367. foreach ($context['collapsed_years'] as $id => $year)
  368. {
  369. echo '
  370. \'', $year, '\'', $id != count($context['collapsed_years']) - 1 ? ',' : '';
  371. }
  372. echo '
  373. ],
  374. aDataCells: [
  375. \'date\',
  376. \'new_topics\',
  377. \'new_posts\',
  378. \'new_members\',
  379. \'most_members_online\'', empty($modSettings['hitStats']) ? '' : ',
  380. \'hits\'', '
  381. ]
  382. });
  383. // ]]></script>';
  384. }
  385. }
  386. ?>