Stats.template.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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. <img src="', $settings['images_url'], '/stats_info.png" class="icon" alt="" /> ', $txt['general_stats'], '
  23. </h4>
  24. </div>
  25. <div class="flow_hidden">
  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 class="clear"></div>
  51. </div>
  52. </div>
  53. </div>
  54. <div id="stats_right">
  55. <div class="windowbg2">
  56. <div class="content top_row">
  57. <dl class="stats">
  58. <dt>', $txt['average_members'], ':</dt>
  59. <dd>', $context['average_members'], '</dd>
  60. <dt>', $txt['average_posts'], ':</dt>
  61. <dd>', $context['average_posts'], '</dd>
  62. <dt>', $txt['average_topics'], ':</dt>
  63. <dd>', $context['average_topics'], '</dd>
  64. <dt>', $txt['total_boards'], ':</dt>
  65. <dd>', $context['num_boards'], '</dd>
  66. <dt>', $txt['latest_member'], ':</dt>
  67. <dd>', $context['common_stats']['latest_member']['link'], '</dd>
  68. <dt>', $txt['average_online'], ':</dt>
  69. <dd>', $context['average_online'], '</dd>
  70. <dt>', $txt['gender_ratio'], ':</dt>
  71. <dd>', $context['gender']['ratio'], '</dd>';
  72. if (!empty($modSettings['hitStats']))
  73. echo '
  74. <dt>', $txt['average_hits'], ':</dt>
  75. <dd>', $context['average_hits'], '</dd>';
  76. echo '
  77. </dl>
  78. <div class="clear"></div>
  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">
  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 class="clear"></div>
  112. </div>
  113. </div>
  114. </div>
  115. <div id="top_boards">
  116. <div class="title_bar">
  117. <h4 class="titlebg">
  118. <img src="', $settings['images_url'], '/stats_board.png" class="icon" alt="" /> ', $txt['top_boards'], '
  119. </h4>
  120. </div>
  121. <div class="windowbg2">
  122. <div class="content">
  123. <dl class="stats">';
  124. foreach ($context['top_boards'] as $board)
  125. {
  126. echo '
  127. <dt>
  128. ', $board['link'], '
  129. </dt>
  130. <dd class="statsbar">';
  131. if (!empty($board['post_percent']))
  132. echo '
  133. <div class="bar" style="width: ', $board['post_percent'] + 4, 'px;">
  134. <div style="width: ', $board['post_percent'], 'px;"></div>
  135. </div>';
  136. echo '
  137. <span class="righttext">', $board['num_posts'], '</span>
  138. </dd>';
  139. }
  140. echo '
  141. </dl>
  142. <div class="clear"></div>
  143. </div>
  144. </div>
  145. </div>
  146. </div>
  147. <div class="flow_hidden">
  148. <div id="top_topics_replies">
  149. <div class="title_bar">
  150. <h4 class="titlebg">
  151. <img src="', $settings['images_url'], '/stats_replies.png" class="icon" alt="" /> ', $txt['top_topics_replies'], '
  152. </h4>
  153. </div>
  154. <div class="windowbg2">
  155. <div class="content">
  156. <dl class="stats">';
  157. foreach ($context['top_topics_replies'] as $topic)
  158. {
  159. echo '
  160. <dt>
  161. ', $topic['link'], '
  162. </dt>
  163. <dd class="statsbar">';
  164. if (!empty($topic['post_percent']))
  165. echo '
  166. <div class="bar" style="width: ', $topic['post_percent'] + 4, 'px;">
  167. <div style="width: ', $topic['post_percent'], 'px;"></div>
  168. </div>';
  169. echo '
  170. <span class="righttext">' . $topic['num_replies'] . '</span>
  171. </dd>';
  172. }
  173. echo '
  174. </dl>
  175. <div class="clear"></div>
  176. </div>
  177. </div>
  178. </div>
  179. <div id="top_topics_views">
  180. <div class="title_bar">
  181. <h4 class="titlebg">
  182. <img src="', $settings['images_url'], '/stats_views.png" class="icon" alt="" /> ', $txt['top_topics_views'], '
  183. </h4>
  184. </div>
  185. <div class="windowbg2">
  186. <div class="content">
  187. <dl class="stats">';
  188. foreach ($context['top_topics_views'] as $topic)
  189. {
  190. echo '
  191. <dt>', $topic['link'], '</dt>
  192. <dd class="statsbar">';
  193. if (!empty($topic['post_percent']))
  194. echo '
  195. <div class="bar" style="width: ', $topic['post_percent'] + 4, 'px;">
  196. <div style="width: ', $topic['post_percent'], 'px;"></div>
  197. </div>';
  198. echo '
  199. <span class="righttext">' . $topic['num_views'] . '</span>
  200. </dd>';
  201. }
  202. echo '
  203. </dl>
  204. <div class="clear"></div>
  205. </div>
  206. </div>
  207. </div>
  208. </div>
  209. <div class="flow_hidden">
  210. <div id="top_topics_starter">
  211. <div class="title_bar">
  212. <h4 class="titlebg">
  213. <img src="', $settings['images_url'], '/stats_replies.png" class="icon" alt="" /> ', $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 class="clear"></div>
  238. </div>
  239. </div>
  240. </div>
  241. <div id="most_online">
  242. <div class="title_bar">
  243. <h4 class="titlebg">
  244. <img src="', $settings['images_url'], '/stats_views.png" class="icon" alt="" /> ', $txt['most_time_online'], '
  245. </h4>
  246. </div>
  247. <div class="windowbg2">
  248. <div class="content">
  249. <dl class="stats">';
  250. foreach ($context['top_time_online'] as $poster)
  251. {
  252. echo '
  253. <dt>
  254. ', $poster['link'], '
  255. </dt>
  256. <dd class="statsbar">';
  257. if (!empty($poster['time_percent']))
  258. echo '
  259. <div class="bar" style="width: ', $poster['time_percent'] + 4, 'px;">
  260. <div style="width: ', $poster['time_percent'], 'px;"></div>
  261. </div>';
  262. echo '
  263. <span>', $poster['time_online'], '</span>
  264. </dd>';
  265. }
  266. echo '
  267. </dl>
  268. <div class="clear"></div>
  269. </div>
  270. </div>
  271. </div>
  272. </div>
  273. <br class="clear" />
  274. <div class="flow_hidden">
  275. <div class="cat_bar">
  276. <h3 class="catbg">
  277. <img src="', $settings['images_url'], '/stats_history.png" class="icon" alt="" /> ', $txt['forum_history'], '
  278. </h3>
  279. </div>';
  280. if (!empty($context['yearly']))
  281. {
  282. echo '
  283. <table border="0" width="100%" cellspacing="1" cellpadding="4" class="table_grid" id="stats">
  284. <thead>
  285. <tr class="titlebg" valign="middle" align="center">
  286. <th class="lefttext" width="25%">', $txt['yearly_summary'], '</th>
  287. <th width="15%">', $txt['stats_new_topics'], '</th>
  288. <th width="15%">', $txt['stats_new_posts'], '</th>
  289. <th width="15%">', $txt['stats_new_members'], '</th>
  290. <th width="15%">', $txt['most_online'], '</th>';
  291. if (!empty($modSettings['hitStats']))
  292. echo '
  293. <th>', $txt['page_views'], '</th>';
  294. echo '
  295. </tr>
  296. </thead>
  297. <tbody>';
  298. foreach ($context['yearly'] as $id => $year)
  299. {
  300. echo '
  301. <tr class="windowbg2" valign="middle" align="center" id="year_', $id, '">
  302. <th class="lefttext" width="25%">
  303. <img id="year_img_', $id, '" src="', $settings['images_url'], '/collapse.png" alt="*" /> <a href="#year_', $id, '" id="year_link_', $id, '">', $year['year'], '</a>
  304. </th>
  305. <th width="15%">', $year['new_topics'], '</th>
  306. <th width="15%">', $year['new_posts'], '</th>
  307. <th width="15%">', $year['new_members'], '</th>
  308. <th width="15%">', $year['most_members_online'], '</th>';
  309. if (!empty($modSettings['hitStats']))
  310. echo '
  311. <th>', $year['hits'], '</th>';
  312. echo '
  313. </tr>';
  314. foreach ($year['months'] as $month)
  315. {
  316. echo '
  317. <tr class="windowbg2" valign="middle" align="center" id="tr_month_', $month['id'], '">
  318. <th class="stats_month">
  319. <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>
  320. </th>
  321. <th width="15%">', $month['new_topics'], '</th>
  322. <th width="15%">', $month['new_posts'], '</th>
  323. <th width="15%">', $month['new_members'], '</th>
  324. <th width="15%">', $month['most_members_online'], '</th>';
  325. if (!empty($modSettings['hitStats']))
  326. echo '
  327. <th>', $month['hits'], '</th>';
  328. echo '
  329. </tr>';
  330. if ($month['expanded'])
  331. {
  332. foreach ($month['days'] as $day)
  333. {
  334. echo '
  335. <tr class="windowbg2" valign="middle" align="center" id="tr_day_', $day['year'], '-', $day['month'], '-', $day['day'], '">
  336. <td class="stats_day">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>
  337. <td>', $day['new_topics'], '</td>
  338. <td>', $day['new_posts'], '</td>
  339. <td>', $day['new_members'], '</td>
  340. <td>', $day['most_members_online'], '</td>';
  341. if (!empty($modSettings['hitStats']))
  342. echo '
  343. <td>', $day['hits'], '</td>';
  344. echo '
  345. </tr>';
  346. }
  347. }
  348. }
  349. }
  350. echo '
  351. </tbody>
  352. </table>
  353. </div>
  354. </div>
  355. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/stats.js"></script>
  356. <script type="text/javascript"><!-- // --><![CDATA[
  357. var oStatsCenter = new smf_StatsCenter({
  358. sTableId: \'stats\',
  359. reYearPattern: /year_(\d+)/,
  360. sYearImageCollapsed: \'expand.png\',
  361. sYearImageExpanded: \'collapse.png\',
  362. sYearImageIdPrefix: \'year_img_\',
  363. sYearLinkIdPrefix: \'year_link_\',
  364. reMonthPattern: /tr_month_(\d+)/,
  365. sMonthImageCollapsed: \'expand.png\',
  366. sMonthImageExpanded: \'collapse.png\',
  367. sMonthImageIdPrefix: \'img_\',
  368. sMonthLinkIdPrefix: \'m\',
  369. reDayPattern: /tr_day_(\d+-\d+-\d+)/,
  370. sDayRowClassname: \'windowbg2\',
  371. sDayRowIdPrefix: \'tr_day_\',
  372. aCollapsedYears: [';
  373. foreach ($context['collapsed_years'] as $id => $year)
  374. {
  375. echo '
  376. \'', $year, '\'', $id != count($context['collapsed_years']) - 1 ? ',' : '';
  377. }
  378. echo '
  379. ],
  380. aDataCells: [
  381. \'date\',
  382. \'new_topics\',
  383. \'new_posts\',
  384. \'new_members\',
  385. \'most_members_online\'', empty($modSettings['hitStats']) ? '' : ',
  386. \'hits\'', '
  387. ]
  388. });
  389. // ]]></script>';
  390. }
  391. }
  392. ?>