2
0

Stats.template.php 12 KB

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