| Server IP : 213.186.33.4 / Your IP : 216.73.216.193 Web Server : Apache System : Linux webm006.cluster103.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : awebpaca ( 35430) PHP Version : 8.5.0 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/awebpaca/boutiques/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ |
Upload File : |
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Images manage controller for Cms WYSIWYG editor
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Adminhtml_Cms_Wysiwyg_ImagesController extends Mage_Adminhtml_Controller_Action
{
/**
* Init storage
*
* @return Mage_Adminhtml_Cms_Page_Wysiwyg_ImagesController
*/
protected function _initAction()
{
$this->getStorage();
return $this;
}
public function indexAction()
{
$storeId = (int) $this->getRequest()->getParam('store');
try {
Mage::helper('cms/wysiwyg_images')->getCurrentPath();
} catch (Exception $e) {
$this->_getSession()->addError($e->getMessage());
}
$this->_initAction()->loadLayout('overlay_popup');
$block = $this->getLayout()->getBlock('wysiwyg_images.js');
if ($block) {
$block->setStoreId($storeId);
}
$this->renderLayout();
}
public function treeJsonAction()
{
try {
$this->_initAction();
$this->getResponse()->setBody(
$this->getLayout()->createBlock('adminhtml/cms_wysiwyg_images_tree')
->getTreeJson()
);
} catch (Exception $e) {
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array()));
}
}
public function contentsAction()
{
try {
$this->_initAction()->_saveSessionCurrentPath();
$this->loadLayout('empty');
$this->renderLayout();
} catch (Exception $e) {
$result = array('error' => true, 'message' => $e->getMessage());
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
public function newFolderAction()
{
try {
$this->_initAction();
$name = $this->getRequest()->getPost('name');
$path = $this->getStorage()->getSession()->getCurrentPath();
$result = $this->getStorage()->createDirectory($name, $path);
} catch (Exception $e) {
$result = array('error' => true, 'message' => $e->getMessage());
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
public function deleteFolderAction()
{
try {
$path = $this->getStorage()->getSession()->getCurrentPath();
$this->getStorage()->deleteDirectory($path);
} catch (Exception $e) {
$result = array('error' => true, 'message' => $e->getMessage());
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
public function deleteFilesAction()
{
$files = Mage::helper('core')->jsonDecode($this->getRequest()->getParam('files'));
try {
$helper = Mage::helper('cms/wysiwyg_images');
$path = $this->getStorage()->getSession()->getCurrentPath();
foreach ($files as $file) {
$file = $helper->idDecode($file);
$this->getStorage()->deleteFile($path . DS . $file);
}
} catch (Exception $e) {
$result = array('error' => true, 'message' => $e->getMessage());
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
/**
* Files upload processing
*/
public function uploadAction()
{
try {
$result = array();
$this->_initAction();
$targetPath = $this->getStorage()->getSession()->getCurrentPath();
$result = $this->getStorage()->uploadFile($targetPath, $this->getRequest()->getParam('type'));
} catch (Exception $e) {
$result = array('error' => $e->getMessage(), 'errorcode' => $e->getCode());
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
/**
* Fire when select image
*/
public function onInsertAction()
{
$helper = Mage::helper('cms/wysiwyg_images');
$storeId = $this->getRequest()->getParam('store');
$filename = $this->getRequest()->getParam('filename');
$filename = $helper->idDecode($filename);
$asIs = $this->getRequest()->getParam('as_is');
Mage::helper('catalog')->setStoreId($storeId);
$helper->setStoreId($storeId);
$image = $helper->getImageHtmlDeclaration($filename, $asIs);
$this->getResponse()->setBody($image);
}
/**
* Generate image thumbnail on the fly
*/
public function thumbnailAction()
{
$file = $this->getRequest()->getParam('file');
$file = Mage::helper('cms/wysiwyg_images')->idDecode($file);
$thumb = $this->getStorage()->resizeOnTheFly($file);
if ($thumb !== false) {
$image = Varien_Image_Adapter::factory('GD2');
$image->open($thumb);
$image->display();
} else {
// todo: genearte some placeholder
}
}
/**
* Register storage model and return it
*
* @return Mage_Cms_Model_Page_Wysiwyg_Images_Storage
*/
public function getStorage()
{
if (!Mage::registry('storage')) {
$storage = Mage::getModel('cms/wysiwyg_images_storage');
Mage::register('storage', $storage);
}
return Mage::registry('storage');
}
/**
* Save current path in session
*
* @return Mage_Adminhtml_Cms_Page_Wysiwyg_ImagesController
*/
protected function _saveSessionCurrentPath()
{
$this->getStorage()
->getSession()
->setCurrentPath(Mage::helper('cms/wysiwyg_images')->getCurrentPath());
return $this;
}
}