index.class.php 2.5 KB

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