Просмотр файла mc-2.7.0/modules/forum/helpers/forum_widget.php

Размер файла: 1.7Kb
  1. <?php
  2.  
  3. /**
  4. * MobileCMS
  5. *
  6. * Open source content management system for mobile sites
  7. *
  8. * @author MobileCMS Team <support@mobilecms.pro>
  9. * @copyright Copyright (c) 2011-2019, MobileCMS Team
  10. * @link https://mobilecms.pro Official site
  11. * @license MIT license
  12. */
  13. defined('IN_SYSTEM') or die('<b>403<br />Запрет доступа!</b>');
  14.  
  15. /**
  16. * Виджет гостевой книги
  17. */
  18. class forum_widget {
  19.  
  20. /**
  21. * Показ виджета
  22. */
  23. public static function display($widget_id) {
  24. $db = Registry::get('db');
  25.  
  26. $stat = $db->get_row("SELECT
  27. (SELECT COUNT(*) FROM #__forum_topics) AS topics,
  28. (SELECT COUNT(*) FROM #__forum_messages) AS messages,
  29. (SELECT COUNT(*) FROM #__forum_topics WHERE time > UNIX_TIMESTAMP() - 3600 * 24) AS new_topics,
  30. (SELECT COUNT(*) FROM #__forum_messages WHERE time > UNIX_TIMESTAMP() - 3600 * 24) AS new_messages
  31. ");
  32.  
  33. $text = '<img src="' . URL . 'modules/forum/images/forum.png" alt="" /> <a href="' . a_url('forum') . '">Форум</a> <span class="count">[' . $stat['topics'] . '/' . $stat['messages'] . ']</span>' . ($stat['new_topics'] > 0 || $stat['new_messages'] > 0 ? ' <span class="new">+<a href="' . a_url('forum/viewforum', 'type=new') . '">' . $stat['new_topics'] . '</a>/<a href="' . a_url('forum/new_messages') . '">' . $stat['new_messages'] . '</a></span>' : '') . '<br />';
  34.  
  35. return $text;
  36. }
  37.  
  38. /**
  39. * Настройка виджета
  40. */
  41. public static function setup($widget) {
  42. a_notice('Данный виджет не требует настройки', a_url('index_page/admin'));
  43. }
  44.  
  45. }
  46.  
  47. ?>