*/ class Mage_Widget_Adminhtml_WidgetController extends Mage_Adminhtml_Controller_Action { /** * Wisywyg widget plugin main page */ public function indexAction() { // save extra params for widgets insertion form $skipped = $this->getRequest()->getParam('skip_widgets'); $skipped = Mage::getSingleton('widget/widget_config')->decodeWidgetsFromQuery($skipped); Mage::register('skip_widgets', $skipped); $this->loadLayout('empty')->renderLayout(); } /** * Ajax responder for loading plugin options form */ public function loadOptionsAction() { try { $this->loadLayout('empty'); if ($paramsJson = $this->getRequest()->getParam('widget')) { $request = Mage::helper('core')->jsonDecode($paramsJson); if (is_array($request)) { $optionsBlock = $this->getLayout()->getBlock('wysiwyg_widget.options'); if (isset($request['widget_type'])) { $optionsBlock->setWidgetType($request['widget_type']); } if (isset($request['values'])) { $optionsBlock->setWidgetValues($request['values']); } } $this->renderLayout(); } } catch (Mage_Core_Exception $e) { $result = array('error' => true, 'message' => $e->getMessage()); $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); } } /** * Format widget pseudo-code for inserting into wysiwyg editor */ public function buildWidgetAction() { $type = $this->getRequest()->getPost('widget_type'); $params = $this->getRequest()->getPost('parameters', array()); $asIs = $this->getRequest()->getPost('as_is'); $html = Mage::getSingleton('widget/widget')->getWidgetDeclaration($type, $params, $asIs); $this->getResponse()->setBody($html); } /** * Check is allowed access to action * * @return bool */ protected function _isAllowed() { return Mage::getSingleton('admin/session')->isAllowed('cms/widget_instance'); } }