event.class.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * @package modx
  4. * @subpackage manager.controllers
  5. */
  6. class SystemEventManagerController extends modManagerController {
  7. public $logArray = array();
  8. /**
  9. * Check for any permissions or requirements to load page
  10. * @return bool
  11. */
  12. public function checkPermissions() {
  13. return $this->modx->hasPermission('error_log_view');
  14. }
  15. /**
  16. * Register custom CSS/JS for the page
  17. * @return void
  18. */
  19. public function loadCustomCssJs() {
  20. $mgrUrl = $this->modx->getOption('manager_url',null,MODX_MANAGER_URL);
  21. $this->addJavascript($mgrUrl.'assets/modext/widgets/system/modx.panel.error.log.js');
  22. $this->addJavascript($mgrUrl.'assets/modext/sections/system/error.log.js');
  23. $this->addHtml('<script type="text/javascript">
  24. MODx.hasEraseErrorLog = "'.($this->modx->hasPermission('error_log_erase') ? 1 : 0).'"
  25. Ext.onReady(function() {
  26. MODx.load({
  27. xtype: "modx-page-error-log"
  28. ,record: '.$this->modx->toJSON($this->logArray).'
  29. });
  30. });
  31. </script>');
  32. }
  33. /**
  34. * Custom logic code here for setting placeholders, etc
  35. * @param array $scriptProperties
  36. * @return mixed
  37. */
  38. public function process(array $scriptProperties = array()) {
  39. $f = $this->modx->getOption(xPDO::OPT_CACHE_PATH) . 'logs/error.log';
  40. $this->logArray['name'] = $f;
  41. if (file_exists($f)) {
  42. $this->logArray['size'] = round(@filesize($f) / 1000 / 1000, 2);
  43. $this->logArray['log'] = '';
  44. if ($this->logArray['size'] > 1) {
  45. $this->logArray['tooLarge'] = true;
  46. $this->logArray['size'] .= ' MiB';
  47. } else {
  48. $this->logArray['tooLarge'] = false;
  49. }
  50. }
  51. }
  52. /**
  53. * Return the pagetitle
  54. *
  55. * @return string
  56. */
  57. public function getPageTitle() {
  58. return $this->modx->lexicon('error_log');
  59. }
  60. /**
  61. * Return the location of the template file
  62. * @return string
  63. */
  64. public function getTemplateFile() {
  65. return '';
  66. }
  67. /**
  68. * Specify the language topics to load
  69. * @return array
  70. */
  71. public function getLanguageTopics() {
  72. return array('system_events');
  73. }
  74. }