Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Content.php
Go to the documentation of this file.
1 <?php
7 
14 class Content extends \Magento\Backend\Block\Widget\Container
15 {
19  protected $_jsonEncoder;
20 
26  public function __construct(
27  \Magento\Backend\Block\Widget\Context $context,
28  \Magento\Framework\Json\EncoderInterface $jsonEncoder,
29  array $data = []
30  ) {
31  $this->_jsonEncoder = $jsonEncoder;
32  parent::__construct($context, $data);
33  }
34 
40  protected function _construct()
41  {
42  parent::_construct();
43  $this->_headerText = __('Media Storage');
44  $this->buttonList->remove('back');
45  $this->buttonList->remove('edit');
46  $this->buttonList->add(
47  'cancel',
48  ['class' => 'cancel action-quaternary', 'label' => __('Cancel'), 'type' => 'button',
49  'onclick' => 'MediabrowserUtility.closeDialog();'],
50  0,
51  0,
52  'header'
53  );
54 
55  $this->buttonList->add(
56  'delete_folder',
57  ['class' => 'delete no-display action-quaternary', 'label' => __('Delete Folder'), 'type' => 'button'],
58  0,
59  0,
60  'header'
61  );
62 
63  $this->buttonList->add(
64  'delete_files',
65  ['class' => 'delete no-display action-quaternary', 'label' => __('Delete Selected'), 'type' => 'button'],
66  0,
67  0,
68  'header'
69  );
70 
71  $this->buttonList->add(
72  'new_folder',
73  ['class' => 'save', 'label' => __('Create Folder'), 'type' => 'button'],
74  0,
75  0,
76  'header'
77  );
78 
79  $this->buttonList->add(
80  'insert_files',
81  ['class' => 'save no-display action-primary', 'label' => __('Add Selected'), 'type' => 'button'],
82  0,
83  0,
84  'header'
85  );
86  }
87 
93  public function getContentsUrl()
94  {
95  return $this->getUrl('cms/*/contents', [
96  'type' => $this->getRequest()->getParam('type'),
97  ]);
98  }
99 
105  public function getFilebrowserSetupObject()
106  {
107  $setupObject = new \Magento\Framework\DataObject();
108 
109  $setupObject->setData(
110  [
111  'newFolderPrompt' => __('New Folder Name:'),
112  'deleteFolderConfirmationMessage' => __('Are you sure you want to delete this folder?'),
113  'deleteFileConfirmationMessage' => __('Are you sure you want to delete this file?'),
114  'targetElementId' => $this->getTargetElementId(),
115  'contentsUrl' => $this->getContentsUrl(),
116  'onInsertUrl' => $this->getOnInsertUrl(),
117  'newFolderUrl' => $this->getNewfolderUrl(),
118  'deleteFolderUrl' => $this->getDeletefolderUrl(),
119  'deleteFilesUrl' => $this->getDeleteFilesUrl(),
120  'headerText' => $this->getHeaderText(),
121  'showBreadcrumbs' => true,
122  ]
123  );
124 
125  return $this->_jsonEncoder->encode($setupObject);
126  }
127 
133  public function getNewfolderUrl()
134  {
135  return $this->getUrl('cms/*/newFolder');
136  }
137 
143  protected function getDeletefolderUrl()
144  {
145  return $this->getUrl('cms/*/deleteFolder');
146  }
147 
153  public function getDeleteFilesUrl()
154  {
155  return $this->getUrl('cms/*/deleteFiles');
156  }
157 
163  public function getOnInsertUrl()
164  {
165  return $this->getUrl('cms/*/onInsert');
166  }
167 
173  public function getTargetElementId()
174  {
175  return $this->getRequest()->getParam('target_element_id');
176  }
177 }
__construct(\Magento\Backend\Block\Widget\Context $context, \Magento\Framework\Json\EncoderInterface $jsonEncoder, array $data=[])
Definition: Content.php:26
__()
Definition: __.php:13