update.class.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * @package modx
  4. * @subpackage manager.controllers
  5. */
  6. class StaticResourceUpdateManagerController extends ResourceUpdateManagerController {
  7. /**
  8. * Register custom CSS/JS for the page
  9. * @return void
  10. */
  11. public function loadCustomCssJs() {
  12. $managerUrl = $this->context->getOption('manager_url', MODX_MANAGER_URL, $this->modx->_userConfig);
  13. $this->addJavascript($managerUrl.'assets/modext/widgets/element/modx.panel.tv.renders.js');
  14. $this->addJavascript($managerUrl.'assets/modext/widgets/resource/modx.grid.resource.security.local.js');
  15. $this->addJavascript($managerUrl.'assets/modext/widgets/resource/modx.panel.resource.tv.js');
  16. $this->addJavascript($managerUrl.'assets/modext/widgets/resource/modx.panel.resource.js');
  17. $this->addJavascript($managerUrl.'assets/modext/widgets/resource/modx.panel.resource.static.js');
  18. $this->addJavascript($managerUrl.'assets/modext/sections/resource/update.js');
  19. $this->addJavascript($managerUrl.'assets/modext/sections/resource/static/update.js');
  20. $this->addHtml('<script type="text/javascript">
  21. // <![CDATA[
  22. MODx.config.publish_document = "'.$this->canPublish.'";
  23. MODx.onDocFormRender = "'.$this->onDocFormRender.'";
  24. MODx.ctx = "'.$this->resource->get('context_key').'";
  25. Ext.onReady(function() {
  26. MODx.load({
  27. xtype: "modx-page-static-update"
  28. ,resource: "'.$this->resource->get('id').'"
  29. ,record: '.$this->modx->toJSON($this->resourceArray).'
  30. ,publish_document: "'.$this->canPublish.'"
  31. ,preview_url: "'.$this->previewUrl.'"
  32. ,locked: '.($this->locked ? 1 : 0).'
  33. ,lockedText: "'.$this->lockedText.'"
  34. ,canSave: '.($this->canSave ? 1 : 0).'
  35. ,canEdit: "'.($this->modx->hasPermission('edit_document') ? 1 : 0).'"
  36. ,canCreate: "'.($this->modx->hasPermission('new_document') ? 1 : 0).'"
  37. ,canDelete: "'.($this->modx->hasPermission('delete_document') ? 1 : 0).'"
  38. ,show_tvs: '.(!empty($this->tvCounts) ? 1 : 0).'
  39. });
  40. });
  41. // ]]>
  42. </script>');
  43. /* load RTE */
  44. $this->loadRichTextEditor();
  45. }
  46. /**
  47. * Used to set values on the resource record sent to the template for derivative classes
  48. *
  49. * @return void|string
  50. */
  51. public function prepareResource() {
  52. /* get openTo directory */
  53. $baseUrlRelative = false;
  54. $wctx = $this->resource->get('context_key');
  55. if (!empty($wctx)) {
  56. $workingContext = $this->modx->getContext($wctx);
  57. if (!$workingContext) {
  58. return $this->failure($this->modx->lexicon('permission_denied'));
  59. }
  60. } else {
  61. $workingContext =& $this->modx->context;
  62. }
  63. $this->modx->getService('fileHandler','modFileHandler', '', array('context' => $workingContext->get('key')));
  64. $baseUrl = $this->modx->fileHandler->getBaseUrl();
  65. if (!empty($this->resourceArray['content'])) {
  66. $this->resourceArray['openTo'] = str_replace($baseUrl,'',dirname($this->resourceArray['content']).'/');
  67. } else {
  68. $this->resourceArray['openTo'] = '/';
  69. }
  70. }
  71. /**
  72. * Return the location of the template file
  73. * @return string
  74. */
  75. public function getTemplateFile() {
  76. return 'resource/staticresource/update.tpl';
  77. }
  78. }