Example #1
0
 /**
  * Get files collection
  *
  * @return array
  */
 public function getFilesCollection()
 {
     $paths = $this->mediaWriteDirectory->search('.*', $this->_helper->getCurrentPath());
     $files = [];
     $requestParams = $this->_helper->getRequestParams();
     $storageType = $this->_helper->getStorageType();
     foreach ($paths as $path) {
         if (!$this->mediaWriteDirectory->isFile($path)) {
             continue;
         }
         $fileName = pathinfo($path, PATHINFO_BASENAME);
         $file = ['text' => $fileName, 'id' => $this->urlEncoder->encode($fileName)];
         if (self::TYPE_IMAGE == $storageType) {
             $requestParams['file'] = $fileName;
             $file['thumbnailParams'] = $requestParams;
             $size = @getimagesize($path);
             if (is_array($size)) {
                 $file['width'] = $size[0];
                 $file['height'] = $size[1];
             }
         }
         $files[] = $file;
     }
     return $files;
 }
Example #2
0
 public function testGetRequestParams()
 {
     $this->request->expects($this->at(0))->method('getParam')->with(\Magento\Theme\Helper\Storage::PARAM_THEME_ID)->will($this->returnValue(6));
     $this->request->expects($this->at(1))->method('getParam')->with(\Magento\Theme\Helper\Storage::PARAM_CONTENT_TYPE)->will($this->returnValue('image'));
     $this->request->expects($this->at(2))->method('getParam')->with(\Magento\Theme\Helper\Storage::PARAM_NODE)->will($this->returnValue('node'));
     $expectedResult = [\Magento\Theme\Helper\Storage::PARAM_THEME_ID => 6, \Magento\Theme\Helper\Storage::PARAM_CONTENT_TYPE => \Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE, \Magento\Theme\Helper\Storage::PARAM_NODE => 'node'];
     $this->assertEquals($expectedResult, $this->helper->getRequestParams());
 }
Example #3
0
 /**
  * Json source URL
  *
  * @return string
  */
 public function getTreeLoaderUrl()
 {
     return $this->getUrl('adminhtml/*/treeJson', $this->_storageHelper->getRequestParams());
 }
Example #4
0
 /**
  * Insert file action target URL
  *
  * @return string
  */
 public function getOnInsertUrl()
 {
     return $this->getUrl('adminhtml/*/onInsert', $this->_storageHelper->getRequestParams());
 }
Example #5
0
 /**
  * Prepare layout
  *
  * @return \Magento\Backend\Block\Media\Uploader
  */
 protected function _prepareLayout()
 {
     $this->getConfig()->setUrl($this->getUrl('adminhtml/*/upload', $this->_storageHelper->getRequestParams()));
     return parent::_prepareLayout();
 }