index.class.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * Loads the MODx.Browser page
  4. *
  5. * @package modx
  6. * @subpackage manager.controllers
  7. */
  8. class BrowserManagerController extends modManagerController {
  9. public $ctx;
  10. public $loadBaseJavascript = true;
  11. public $loadHeader = false;
  12. public $loadFooter = false;
  13. /**
  14. * Check for any permissions or requirements to load page
  15. * @return bool
  16. */
  17. public function checkPermissions() {
  18. return $this->modx->hasPermission('file_manager');
  19. }
  20. /**
  21. * Register custom CSS/JS for the page
  22. * @return void
  23. */
  24. public function loadCustomCssJs() {
  25. /* invoke OnRichTextBrowserInit */
  26. $this->addHtml('<script type="text/javascript">
  27. MODx.siteId = "'.$this->modx->user->getUserToken($this->modx->context->get('key')).'";
  28. MODx.ctx = "'.$this->ctx.'";
  29. </script>');
  30. }
  31. /**
  32. * Custom logic code here for setting placeholders, etc
  33. * @param array $scriptProperties
  34. * @return mixed
  35. */
  36. public function process(array $scriptProperties = array()) {
  37. $placeholders = array();
  38. $scriptProperties['ctx'] = !empty($scriptProperties['ctx']) ? $scriptProperties['ctx'] : 'web';
  39. $rtecallback = $this->modx->invokeEvent('OnRichTextBrowserInit', $scriptProperties);
  40. if (is_array($rtecallback)) $rtecallback = trim(implode(',',$rtecallback),',');
  41. $placeholders['rtecallback'] = $rtecallback;
  42. $this->ctx = $scriptProperties['ctx'];
  43. $placeholders['_ctx'] = $this->ctx;
  44. $_SERVER['HTTP_MODAUTH'] = $this->modx->user->getUserToken($this->modx->context->get('key'));
  45. $placeholders['site_id'] = $_SERVER['HTTP_MODAUTH'];
  46. $placeholders['source'] = $this->modx->getOption('source',$scriptProperties,$this->modx->getOption('default_media_source',null,1));
  47. return $placeholders;
  48. }
  49. /**
  50. * Return the pagetitle
  51. *
  52. * @return string
  53. */
  54. public function getPageTitle() {
  55. return $this->modx->lexicon('modx_resource_browser');
  56. }
  57. /**
  58. * Return the location of the template file
  59. * @return string
  60. */
  61. public function getTemplateFile() {
  62. return 'browser/index.tpl';
  63. }
  64. /**
  65. * Specify the language topics to load
  66. * @return array
  67. */
  68. public function getLanguageTopics() {
  69. return array('file');
  70. }
  71. }