widget.grid-online.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of MODX Revolution.
  4. *
  5. * Copyright (c) MODX, LLC. All Rights Reserved.
  6. *
  7. * For complete copyright and license information, see the COPYRIGHT and LICENSE
  8. * files found in the top-level directory of this distribution.
  9. */
  10. /*
  11. * This file is part of MODX Revolution.
  12. *
  13. * Copyright (c) MODX, LLC. All Rights Reserved.
  14. *
  15. * For complete copyright and license information, see the COPYRIGHT and LICENSE
  16. * files found in the top-level directory of this distribution.
  17. */
  18. class modDashboardWidgetWhoIsOnline extends modDashboardWidgetInterface {
  19. public function render() {
  20. $date_timezone = $this->modx->getOption('date_timezone');
  21. $timezone = !empty($date_timezone) ? $date_timezone : date_default_timezone_get();
  22. $timeformat = $this->modx->getOption('manager_time_format');
  23. $datetime = new DateTime($timezone);
  24. $curtime = $datetime->format($timeformat);
  25. $this->modx->setPlaceholder('curtime',$curtime);
  26. $this->controller->addJavascript($this->modx->getOption('manager_url').'assets/modext/widgets/security/modx.grid.user.online.js');
  27. $this->controller->addHtml('
  28. <script type="text/javascript">
  29. Ext.applyIf(MODx.lang, '. $this->modx->toJSON($this->modx->lexicon->loadCache('core', 'dashboard')) .');
  30. Ext.onReady(function() {
  31. MODx.load({
  32. xtype: "modx-grid-user-online"
  33. ,renderTo: "modx-grid-user-online"
  34. });
  35. });
  36. </script>');
  37. return $this->getFileChunk('dashboard/onlineusers.tpl');
  38. }
  39. }
  40. return 'modDashboardWidgetWhoIsOnline';