Content.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Cms\Block\Adminhtml\Wysiwyg\Images;
  7. /**
  8. * Wysiwyg Images content block
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Content extends \Magento\Backend\Block\Widget\Container
  14. {
  15. /**
  16. * @var \Magento\Framework\Json\EncoderInterface
  17. */
  18. protected $_jsonEncoder;
  19. /**
  20. * @param \Magento\Backend\Block\Widget\Context $context
  21. * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
  22. * @param array $data
  23. */
  24. public function __construct(
  25. \Magento\Backend\Block\Widget\Context $context,
  26. \Magento\Framework\Json\EncoderInterface $jsonEncoder,
  27. array $data = []
  28. ) {
  29. $this->_jsonEncoder = $jsonEncoder;
  30. parent::__construct($context, $data);
  31. }
  32. /**
  33. * Block construction
  34. *
  35. * @return void
  36. */
  37. protected function _construct()
  38. {
  39. parent::_construct();
  40. $this->_headerText = __('Media Storage');
  41. $this->buttonList->remove('back');
  42. $this->buttonList->remove('edit');
  43. $this->buttonList->add(
  44. 'cancel',
  45. ['class' => 'cancel action-quaternary', 'label' => __('Cancel'), 'type' => 'button',
  46. 'onclick' => 'MediabrowserUtility.closeDialog();'],
  47. 0,
  48. 0,
  49. 'header'
  50. );
  51. $this->buttonList->add(
  52. 'delete_folder',
  53. ['class' => 'delete no-display action-quaternary', 'label' => __('Delete Folder'), 'type' => 'button'],
  54. 0,
  55. 0,
  56. 'header'
  57. );
  58. $this->buttonList->add(
  59. 'delete_files',
  60. ['class' => 'delete no-display action-quaternary', 'label' => __('Delete Selected'), 'type' => 'button'],
  61. 0,
  62. 0,
  63. 'header'
  64. );
  65. $this->buttonList->add(
  66. 'new_folder',
  67. ['class' => 'save', 'label' => __('Create Folder'), 'type' => 'button'],
  68. 0,
  69. 0,
  70. 'header'
  71. );
  72. $this->buttonList->add(
  73. 'insert_files',
  74. ['class' => 'save no-display action-primary', 'label' => __('Add Selected'), 'type' => 'button'],
  75. 0,
  76. 0,
  77. 'header'
  78. );
  79. }
  80. /**
  81. * Files action source URL
  82. *
  83. * @return string
  84. */
  85. public function getContentsUrl()
  86. {
  87. return $this->getUrl('cms/*/contents', [
  88. 'type' => $this->getRequest()->getParam('type'),
  89. ]);
  90. }
  91. /**
  92. * Javascript setup object for filebrowser instance
  93. *
  94. * @return string
  95. */
  96. public function getFilebrowserSetupObject()
  97. {
  98. $setupObject = new \Magento\Framework\DataObject();
  99. $setupObject->setData(
  100. [
  101. 'newFolderPrompt' => __('New Folder Name:'),
  102. 'deleteFolderConfirmationMessage' => __('Are you sure you want to delete this folder?'),
  103. 'deleteFileConfirmationMessage' => __('Are you sure you want to delete this file?'),
  104. 'targetElementId' => $this->getTargetElementId(),
  105. 'contentsUrl' => $this->getContentsUrl(),
  106. 'onInsertUrl' => $this->getOnInsertUrl(),
  107. 'newFolderUrl' => $this->getNewfolderUrl(),
  108. 'deleteFolderUrl' => $this->getDeletefolderUrl(),
  109. 'deleteFilesUrl' => $this->getDeleteFilesUrl(),
  110. 'headerText' => $this->getHeaderText(),
  111. 'showBreadcrumbs' => true,
  112. ]
  113. );
  114. return $this->_jsonEncoder->encode($setupObject);
  115. }
  116. /**
  117. * New directory action target URL
  118. *
  119. * @return string
  120. */
  121. public function getNewfolderUrl()
  122. {
  123. return $this->getUrl('cms/*/newFolder');
  124. }
  125. /**
  126. * Delete directory action target URL
  127. *
  128. * @return string
  129. */
  130. protected function getDeletefolderUrl()
  131. {
  132. return $this->getUrl('cms/*/deleteFolder');
  133. }
  134. /**
  135. * Description goes here...
  136. *
  137. * @return string
  138. */
  139. public function getDeleteFilesUrl()
  140. {
  141. return $this->getUrl('cms/*/deleteFiles');
  142. }
  143. /**
  144. * New directory action target URL
  145. *
  146. * @return string
  147. */
  148. public function getOnInsertUrl()
  149. {
  150. return $this->getUrl('cms/*/onInsert');
  151. }
  152. /**
  153. * Target element ID getter
  154. *
  155. * @return string
  156. */
  157. public function getTargetElementId()
  158. {
  159. return $this->getRequest()->getParam('target_element_id');
  160. }
  161. }