Stats.template.php 13 KB

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