/** * @param string $type * @param string $expectedFile * @dataProvider getPlaceholderImageUrlDataProvider * @magentoAppIsolation enabled * * @group module:Mage_Catalog */ public function testGetPlaceholderImageUrl($type, $expectedFile) { Mage::getDesign()->setDesignTheme('default/default/default', 'adminhtml'); $url = $this->_model->getPlaceholderImageUrl($type); $this->assertStringEndsWith($expectedFile, $url); $this->assertFileExists(Mage::getBaseDir('media') . "/skin/adminhtml/default/default/default/en_US/{$expectedFile}"); }
/** * @param string $type * @param string $expectedFile * @return string * * @dataProvider getPlaceholderImageUrlDataProvider * @magentoAppIsolation enabled */ public function testGetPlaceholderImageUrl($type, $expectedFile) { Mage::getDesign()->setDesignTheme('default/basic', 'adminhtml'); $expectedPubFile = Mage::getBaseDir('media') . "/theme/adminhtml/default/basic/en_US/{$expectedFile}"; if (file_exists($expectedPubFile)) { unlink($expectedPubFile); } $url = $this->_model->getPlaceholderImageUrl($type); $this->assertStringEndsWith($expectedFile, $url); $this->assertFileExists($expectedPubFile); return $expectedPubFile; }
/** * @return array */ public function widgetPlaceholderImagesDataProvider() { $result = array(); $model = new Mage_Widget_Model_Widget(); foreach ($model->getWidgetsArray() as $row) { $instance = new Mage_Widget_Model_Widget_Instance(); $config = $instance->setType($row['type'])->getWidgetConfig(); // @codingStandardsIgnoreStart if (isset($config->placeholder_image)) { $result[] = array((string) $config->placeholder_image); } // @codingStandardsIgnoreEnd } return $result; }
public function getWidgetDeclaration($type, $params = array(), $asIs = true) { if (preg_match('~(^athlete/widget_banner_category)~', $type)) { $params['text'] = str_replace("\r\n", '\\n', $params['text']); } return parent::getWidgetDeclaration($type, $params, $asIs); }
public function getWidgetDeclaration($type, $params = array(), $asIs = true) { if (preg_match('~(^ves_blog/widget_latest)~', $type)) { $params['latestmod_desc'] = base64_encode($params['latestmod_desc']); } return parent::getWidgetDeclaration($type, $params, $asIs); }
public function getWidgetDeclaration($type, $params = array(), $asIs = true) { if (preg_match('~(^ves_tabshome/widget_tab)~', $type)) { $params['pretext'] = base64_encode($params['pretext']); } return parent::getWidgetDeclaration($type, $params, $asIs); }
/** * Collect all declared widget blocks and templates * * @return array */ public function widgetTemplatesDataProvider() { $result = array(); $model = new Mage_Widget_Model_Widget(); foreach ($model->getWidgetsArray() as $row) { $instance = new Mage_Widget_Model_Widget_Instance(); $config = $instance->setType($row['type'])->getWidgetConfig(); $class = Mage::getConfig()->getBlockClassName($row['type']); if (is_subclass_of($class, 'Mage_Core_Block_Template')) { $templates = $config->xpath('/widgets/' . $row['code'] . '/parameters/template/values/*/value'); foreach ($templates as $template) { $result[] = array($class, (string) $template); } } } return $result; }
public function getWidgetDeclaration($type, $params = array(), $asIs = true) { $field_pattern = array("pretext", "shortcode", "html", "raw_html", "content", "latestmod_desc", "custom_css"); $widget_types = array("ves_base/widget_accordionbg"); foreach ($params as $k => $v) { if (in_array($k, $field_pattern) || preg_match("/^content_(.*)/", $k) || preg_match("/^header_(.*)/", $k) && in_array($type, $widget_types)) { $params[$k] = base64_encode($params[$k]); } } return parent::getWidgetDeclaration($type, $params, $asIs); }
/** * Return widget presentation code in WYSIWYG editor * * @param string $type Widget Type * @param array $params Pre-configured Widget Params * @param bool $asIs Return result as widget directive(true) or as placeholder image(false) * @return string Widget directive ready to parse */ public function getWidgetDeclaration($type, $params = array(), $asIs = true) { $html = parent::getWidgetDeclaration($type, $params, $asIs); if (preg_match('/id="([^"]*)"/i', $html, $idMatch) && preg_match('/src="([^"]*)"/i', $html, $srcMatch)) { $params = base64_decode(strtr($idMatch[1], ':_-', '+/=')); $params = str_replace('{{widget', '', $params); $params = str_replace('}}', '', $params); $image = Mage::getModel('SwiftOtter_Widget/Image')->init($type, $params); $html = str_replace($srcMatch[0], sprintf('src="%s"', $image->getPath(true)), $html); } return $html; }
/** * Return widget presentation code in WYSIWYG editor * * @param string $type Widget Type * @param array $params Pre-configured Widget Params * @param bool $asIs Return result as widget directive(true) or as placeholder image(false) * @return string Widget directive ready to parse */ public function getWidgetDeclaration($type, $params = array(), $asIs = true) { if ($type != 'tabs/group') { for ($i = 1; $i <= 10; $i++) { if (isset($params['title_' . $i]) && is_array($params['title_' . $i])) { unset($params['title_' . $i]); } } return parent::getWidgetDeclaration($type, $params, $asIs); } $directive = '{{widget type="' . $type . '"'; foreach ($params as $name => $value) { // Retrieve default option value if pre-configured if (is_array($value)) { if ($type == 'tabs/group') { if (implode('', $value)) { $value = base64_encode(serialize($value)); } else { $value = ''; } } else { $value = implode(',', $value); } } elseif (trim($value) == '') { $widget = $this->getConfigAsObject($type); $parameters = $widget->getParameters(); if (isset($parameters[$name]) && is_object($parameters[$name])) { $value = $parameters[$name]->getValue(); } } if ($value) { $directive .= sprintf(' %s="%s"', $name, $value); } } $directive .= '}}'; if ($asIs) { return $directive; } $config = Mage::getSingleton('widget/widget_config'); $imageName = str_replace('/', '__', $type) . '.gif'; if (is_file($config->getPlaceholderImagesBaseDir() . DS . $imageName)) { $image = $config->getPlaceholderImagesBaseUrl() . $imageName; } else { $image = $config->getPlaceholderImagesBaseUrl() . 'default.gif'; } $html = sprintf('<img id="%s" src="%s" title="%s">', $this->_idEncode($directive), $image, Mage::helper('core')->urlEscape($directive)); return $html; }
/** * Return widget presentation code in WYSIWYG editor * * @param string $type Widget Type * @param array $params Pre-configured Widget Params * @param bool $asIs Return result as widget directive(true) or as placeholder image(false) * @return string Widget directive ready to parse */ public function getWidgetDeclaration($type, $params = array(), $asIs = true) { if (!in_array($type, array('slideshow/create'))) { return parent::getWidgetDeclaration($type, $params, $asIs); } $directive = '{{widget type="' . $type . '"'; $helper = Mage::helper('slideshow'); foreach ($params as $name => $value) { // Retrieve default option value if pre-configured if ($type == 'slideshow/create') { if ((strstr($name, 'text') && !in_array($name, array('textmouseover', 'texteffect', 'textsync')) || strstr($name, 'url')) && trim($value) != '') { $value = $helper->html_encode($value); } } if (is_array($value)) { $value = implode(',', $value); } elseif (trim($value) == '') { $widget = $this->getConfigAsObject($type); $parameters = $widget->getParameters(); if (isset($parameters[$name]) && is_object($parameters[$name])) { $value = $parameters[$name]->getValue(); } } if ($value) { $directive .= sprintf(' %s="%s"', $name, $value); } } $directive .= '}}'; if ($asIs) { return $directive; } $config = Mage::getSingleton('widget/widget_config'); $imageName = str_replace('/', '__', $type) . '.gif'; if (is_file($config->getPlaceholderImagesBaseDir() . DS . $imageName)) { $image = $config->getPlaceholderImagesBaseUrl() . $imageName; } else { $image = $config->getPlaceholderImagesBaseUrl() . 'default.gif'; } $html = sprintf('<img id="%s" src="%s" title="%s">', $this->_idEncode($directive), $image, Mage::helper('core')->urlEscape($directive)); return $html; }
public function getTabsArray($filters = array()) { return parent::getWidgetsArray($filters); }