/** * @magentoAppIsolation enabled */ public function testGetFilesCollection() { Mage::getDesign()->setDesignTheme('default/default/default', 'adminhtml'); $model = new Mage_Cms_Model_Wysiwyg_Images_Storage(); $collection = $model->getFilesCollection(self::$_baseDir, 'media'); $this->assertInstanceOf('Mage_Cms_Model_Wysiwyg_Images_Storage_Collection', $collection); foreach ($collection as $item) { $this->assertInstanceOf('Varien_Object', $item); $this->assertStringEndsWith('/1.swf', $item->getUrl()); $this->assertStringMatchesFormat('http://%s/media/skin/adminhtml/%s/%s/%s/%s/Mage_Cms/images/placeholder_thumbnail.jpg', $item->getThumbUrl()); return; } }
public function resizeFile($source, $keepRatio = true) { if ($dest = parent::resizeFile($source, $keepRatio)) { if ($this->getS3Helper()->checkS3Usage()) { /** @var Arkade_S3_Model_Core_File_Storage_S3 $storageModel */ $storageModel = $this->getS3Helper()->getStorageDatabaseModel(); $filePath = ltrim(str_replace(Mage::getConfig()->getOptions()->getMediaDir(), '', $dest), DS); $storageModel->saveFile($filePath); } } return $dest; }
public function uploadFile($targetPath, $type = null) { if (!$this->_getConfigHelper()->isEnabled()) { return parent::uploadFile($targetPath, $type); } $uploader = new Cloudinary_Cloudinary_Model_Cms_Uploader('image'); if ($allowed = $this->getAllowedExtensions($type)) { $uploader->setAllowedExtensions($allowed); } $uploader->setAllowRenameFiles(true); $uploader->setFilesDispersion(false); $result = $uploader->save($targetPath); if (!$result) { Mage::throwException(Mage::helper('cms')->__('Cannot upload file.')); } // create thumbnail $this->resizeFile($targetPath . DS . $uploader->getUploadedFileName(), true); $result['cookie'] = array('name' => session_name(), 'value' => $this->getSession()->getSessionId(), 'lifetime' => $this->getSession()->getCookieLifetime(), 'path' => $this->getSession()->getCookiePath(), 'domain' => $this->getSession()->getCookieDomain()); return $result; }
/** * Delete file (and its thumbnail if exists) from storage * * @param string $target File path to be deleted * @return Mage_Cms_Model_Wysiwyg_Images_Storage */ public function deleteFile($target) { if (!Mage::helper('uaudio_storage')->isEnabled()) { return parent::deleteFile($target); } $thumb = str_replace('//', '/', $this->getThumbsPath($target)) . DS . pathinfo($target, PATHINFO_BASENAME); $this->_getStorageModel()->deleteFile($target); $this->_getStorageModel()->deleteFile($thumb); return $this; }