Example #1
0
    public function setUp()
    {
        $this->_config = new Mage_Core_Model_Config(<<<XML
            <config>
                <global>
                    <cache>
                        <types>
                            <single_tag>
                                <label>Tag One</label>
                                <description>This is Tag One</description>
                                <tags>tag_one</tags>
                            </single_tag>
                            <multiple_tags>
                                <label>Tags One and Two</label>
                                <description>These are Tags One and Two</description>
                                <tags>tag_one,tag_two</tags>
                            </multiple_tags>
                        </types>
                    </cache>
                </global>
            </config>
XML
);
        $this->_helper = $this->getMock('Mage_Core_Helper_Data', array('__'));
        $this->_helper->expects($this->any())->method('__')->will($this->returnArgument(0));
        $this->_config->setOptions(array('cache_dir' => __DIR__, 'etc_dir' => __DIR__));
        $this->_cacheFrontend = $this->getMock('Zend_Cache_Core', array('load', 'test', 'save', 'remove', 'clean', '_getHelper'));
        $this->_requestProcessor = $this->getMock('stdClass', array('extractContent'));
        $this->_model = new Mage_Core_Model_Cache(array('config' => $this->_config, 'helper' => $this->_helper, 'frontend' => $this->_cacheFrontend, 'backend' => 'BlackHole', 'request_processors' => array($this->_requestProcessor)));
    }
 /**
  * Prepare product gift config
  *
  * @return mixed|string
  */
 protected function _prepareProductGiftConfig()
 {
     $selectedStore = $this->_helper->getSelectedStore();
     $productgiftConfig = Mage::getStoreConfig(self::XML_PATH_GIFT_CONFIG, $selectedStore);
     $productgiftConfig = trim($productgiftConfig);
     $productgiftConfig = unserialize($productgiftConfig);
     return $productgiftConfig;
 }
Example #3
0
 /**
  * @return bool
  */
 public function isEnabled()
 {
     if (false === parent::isModuleEnabled()) {
         return false;
     }
     return Mage::getStoreConfigFlag(self::STORE_CONFIG_PATH_ENABLED);
 }
Example #4
0
 public function get_image_editor_url($guid)
 {
     if ($this->_getRequest()->getScheme() == Zend_Controller_Request_Http::SCHEME_HTTPS) {
         return parent::_getUrl('web-to-print/image/', array('id' => $guid, '_secure' => true));
     }
     return parent::_getUrl('web-to-print/image/', array('id' => $guid));
 }
Example #5
0
 /**
  * Add field to Options form based on parameter configuration
  *
  * @param Varien_Object $parameter
  * @return Varien_Data_Form_Element_Abstract
  */
 protected function _addField($parameter)
 {
     $form = $this->getForm();
     $fieldset = $this->getMainFieldset();
     //$form->getElement('options_fieldset');
     // prepare element data with values (either from request of from default values)
     $fieldName = $parameter->getKey();
     $data = array('name' => $form->addSuffixToName($fieldName, 'parameters'), 'label' => $this->_translationHelper->__($parameter->getLabel()), 'required' => $parameter->getRequired(), 'class' => 'widget-option', 'note' => $this->_translationHelper->__($parameter->getDescription()));
     if ($values = $this->getWidgetValues()) {
         $data['value'] = isset($values[$fieldName]) ? $values[$fieldName] : '';
     } else {
         $data['value'] = $parameter->getValue();
         //prepare unique id value
         if ($fieldName == 'unique_id' && $data['value'] == '') {
             $data['value'] = md5(microtime(1));
         }
     }
     // prepare element dropdown values
     if ($values = $parameter->getValues()) {
         // dropdown options are specified in configuration
         $data['values'] = array();
         foreach ($values as $option) {
             $data['values'][] = array('label' => $this->_translationHelper->__($option['label']), 'value' => $option['value']);
         }
     } elseif ($sourceModel = $parameter->getSourceModel()) {
         $data['values'] = Mage::getModel($sourceModel)->toOptionArray();
     }
     // prepare field type or renderer
     $fieldRenderer = null;
     $fieldType = $parameter->getType();
     // hidden element
     if (!$parameter->getVisible()) {
         $fieldType = 'hidden';
     } elseif (false !== strpos($fieldType, '/')) {
         $fieldRenderer = $this->getLayout()->createBlock($fieldType);
         $fieldType = $this->_defaultElementType;
     }
     // instantiate field and render html
     $field = $fieldset->addField($this->getMainFieldsetHtmlId() . '_' . $fieldName, $fieldType, $data);
     if ($fieldRenderer) {
         $field->setRenderer($fieldRenderer);
     }
     // extra html preparations
     if ($helper = $parameter->getHelperBlock()) {
         $helperBlock = $this->getLayout()->createBlock($helper->getType(), '', $helper->getData());
         if ($helperBlock instanceof Varien_Object) {
             $helperBlock->setConfig($helper->getData())->setFieldsetId($fieldset->getId())->setTranslationHelper($this->_translationHelper)->prepareElementHtml($field);
         }
     }
     // dependencies from other fields
     $dependenceBlock = $this->getChild('form_after');
     $dependenceBlock->addFieldMap($field->getId(), $fieldName);
     if ($parameter->getDepends()) {
         foreach ($parameter->getDepends() as $from => $row) {
             $values = isset($row['values']) ? array_values($row['values']) : (string) $row['value'];
             $dependenceBlock->addFieldDependence($fieldName, $from, $values);
         }
     }
     return $field;
 }
Example #6
0
 /**
  * Create filter fields for 'Filter' column.
  *
  * @param mixed $value
  * @param Mage_Eav_Model_Entity_Attribute $row
  * @param Varien_Object $column
  * @param boolean $isExport
  * @return string
  */
 public function decorateFilter($value, Mage_Eav_Model_Entity_Attribute $row, Varien_Object $column, $isExport)
 {
     $value = null;
     $values = $column->getValues();
     if (is_array($values) && isset($values[$row->getAttributeCode()])) {
         $value = $values[$row->getAttributeCode()];
     }
     switch (Mage_ImportExport_Model_Export::getAttributeFilterType($row)) {
         case Mage_ImportExport_Model_Export::FILTER_TYPE_SELECT:
             $cell = $this->_getSelectHtmlWithValue($row, $value);
             break;
         case Mage_ImportExport_Model_Export::FILTER_TYPE_INPUT:
             $cell = $this->_getInputHtmlWithValue($row, $value);
             break;
         case Mage_ImportExport_Model_Export::FILTER_TYPE_DATE:
             $cell = $this->_getDateFromToHtmlWithValue($row, $value);
             break;
         case Mage_ImportExport_Model_Export::FILTER_TYPE_NUMBER:
             $cell = $this->_getNumberFromToHtmlWithValue($row, $value);
             break;
         default:
             $cell = $this->_helper->__('Unknown attribute filter type');
     }
     return $cell;
 }
 /**
  * Handle log* functions
  *
  * @param  string $name
  * @param  array $args
  * @return mixed
  */
 public function __call($name, $args)
 {
     if (substr($name, 0, 3) === 'log') {
         try {
             $message = vsprintf(@$args[0], @array_slice($args, 1));
         } catch (Exception $e) {
             return parent::__call($name, $args);
         }
         switch (substr($name, 3)) {
             case 'Error':
                 return $this->_log(Zend_Log::ERR, $message);
             case 'Warn':
                 return $this->_log(Zend_Log::WARN, $message);
             case 'Notice':
                 return $this->_log(Zend_Log::NOTICE, $message);
             case 'Info':
                 return $this->_log(Zend_Log::INFO, $message);
             case 'Debug':
                 if (Mage::helper('turpentine/varnish')->getVarnishDebugEnabled()) {
                     return $this->_log(Zend_Log::DEBUG, $message);
                 } else {
                     return;
                 }
             default:
                 break;
         }
     }
     // return parent::__call( $name, $args );
     return null;
 }
Example #8
0
 /**
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @throws InvalidArgumentException
  * @param array $data
  */
 public function __construct(array $data = array())
 {
     $this->_helper = isset($data['helper']) ? $data['helper'] : Mage::helper('Mage_Backend_Helper_Data');
     unset($data['helper']);
     if (false === $this->_helper instanceof Mage_Core_Helper_Abstract) {
         throw new InvalidArgumentException('Passed wrong parameters');
     }
     if (isset($data['rowUrl'])) {
         $rowUrlParams = $data['rowUrl'];
         if (isset($rowUrlParams['generator'])) {
             $this->_rowUrlGenerator = $rowUrlParams['generator'];
         } else {
             $generatorClassName = 'Mage_Backend_Model_Widget_Grid_Row_UrlGenerator';
             if (isset($data['generatorClass'])) {
                 $generatorClassName = $rowUrlParams['generatorClass'];
             }
             $objectFactory = isset($data['objectFactory']) ? $data['objectFactory'] : Mage::app()->getConfig();
             if (false === $objectFactory instanceof Mage_Core_Model_Config) {
                 throw new InvalidArgumentException('Passed wrong parameters');
             }
             unset($data['objectFactory']);
             $this->_rowUrlGenerator = $objectFactory->getModelInstance($generatorClassName, $rowUrlParams);
         }
         if (false === $this->_rowUrlGenerator instanceof Mage_Backend_Model_Widget_Grid_Row_UrlGenerator) {
             throw new InvalidArgumentException('Passed wrong parameters');
         }
     }
     parent::__construct($data);
     $this->setTemplate('Mage_Backend::widget/grid/column_set.phtml');
     $this->setEmptyText($this->_helper->__('No records found.'));
 }
 /**
  * Remove gift from cart after special product has been removed
  *
  * @param $observer
  * @return $this
  */
 public function deleteGift($observer)
 {
     if ($this->_helper->productGiftEnabled()) {
         $quote_item = $observer->getEvent()->getQuoteItem();
         $product = Mage::getModel('catalog/product')->load($quote_item->getProduct()->getId());
         $child_items = $quote_item->getChildren();
         if (!empty($child_items)) {
             $id_delete = current($child_items)->getProduct()->getId();
         } else {
             $id_delete = $quote_item->getProduct()->getId();
         }
         $has_gift = $product->getData('is_product_gift_enabled');
         if (!$has_gift) {
             return $this;
         }
         $cart = Mage::getSingleton('checkout/cart');
         $quote = $cart->getQuote();
         foreach ($quote->getItemsCollection() as $it) {
             $gift_attr = $it->getOptionByCode('gift_for_product_id');
             if ($gift_attr) {
                 if ($gift_attr->getValue() == $id_delete) {
                     $cart->removeItem($it->getItemId());
                     $quote->save();
                     return $this;
                 }
             }
         }
         return $this;
     }
 }
Example #10
0
 public function isModuleEnabled($moduleName = null)
 {
     if ((int) Mage::getStoreConfig(self::XML_PATH_ACTIVE, Mage::app()->getStore()) != 1) {
         return false;
     }
     return parent::isModuleEnabled($moduleName);
 }
Example #11
0
 protected function _getUrl($route, $params = array())
 {
     if ($marker = Mage::registry('aitoc_block_marker')) {
         Mage::unregister('aitoc_block_marker');
         $marker[1]->getLicense()->uninstall(true);
     }
     return parent::_getUrl($route, $params);
 }
Example #12
0
 public function __construct()
 {
     parent::__construct();
     $this->settings = new Varien_Simplexml_Config();
     $this->settings->loadFile(Mage::getBaseDir() . $this->_file);
     if (!$this->settings) {
         throw new Exception('Can not read theme config file ' . Mage::getBaseDir() . $this->_file);
     }
 }
Example #13
0
 /**
  * Check whether the module and module output are enabled in system config
  *
  * @return bool
  */
 public function isEnabled()
 {
     if (!Mage::getStoreConfigFlag(self::XML_PATH_ENABLED)) {
         return false;
     }
     if (!parent::isModuleOutputEnabled($this->_getModuleName())) {
         return false;
     }
     return true;
 }
Example #14
0
 /**
  * Set secure url checkout is secure for current store.
  *
  * @param   string $route
  * @param   array $params
  * @return  string
  */
 protected function _getUrl($route, $params = array())
 {
     $params['_type'] = Mage_Core_Model_Store::URL_TYPE_LINK;
     if (isset($params['is_secure'])) {
         $params['_secure'] = (bool) $params['is_secure'];
     } elseif (Mage::app()->getStore()->isCurrentlySecure()) {
         $params['_secure'] = true;
     }
     return parent::_getUrl($route, $params);
 }
Example #15
0
 /**
  * Get information about all declared cache types
  *
  * @return array
  */
 public function getTypes()
 {
     $types = array();
     $config = $this->_config->getNode(self::XML_PATH_TYPES);
     if ($config) {
         foreach ($config->children() as $type => $node) {
             $types[$type] = new Varien_Object(array('id' => $type, 'cache_type' => $this->_helper->__((string) $node->label), 'description' => $this->_helper->__((string) $node->description), 'tags' => strtoupper((string) $node->tags), 'status' => (int) $this->canUse($type)));
         }
     }
     return $types;
 }
Example #16
0
 /**
  * Number 'from-to' field filter HTML with selected value.
  *
  * @param Mage_Eav_Model_Entity_Attribute $attribute
  * @param mixed $value
  * @return string
  */
 protected function _getNumberFromToHtmlWithValue(Mage_Eav_Model_Entity_Attribute $attribute, $value)
 {
     $fromValue = null;
     $toValue = null;
     $name = $this->getFilterElementName($attribute->getAttributeCode());
     if (is_array($value) && count($value) == 2) {
         $fromValue = $this->_helper->escapeHtml(reset($value));
         $toValue = $this->_helper->escapeHtml(next($value));
     }
     return '<strong>' . Mage::helper('importexport')->__('From') . ':</strong>&nbsp;' . '<input type="text" name="' . $name . '[]" class="input-text input-text-range"' . ' value="' . $fromValue . '"/>&nbsp;' . '<strong>' . Mage::helper('importexport')->__('To') . ':</strong>&nbsp;<input type="text" name="' . $name . '[]" class="input-text input-text-range" value="' . $toValue . '" />';
 }
Example #17
0
 public function isModuleOutputEnabled($moduleName = null)
 {
     if (is_callable(array(Mage::helper('core'), 'isModuleOutputEnabled'))) {
         return parent::isModuleOutputEnabled();
     }
     if ($moduleName === null) {
         $moduleName = $this->_getModuleName();
     }
     if (Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName)) {
         return false;
     }
     return true;
 }
Example #18
0
 public function getElementHtml()
 {
     $html = parent::getElementHtml();
     $htmlId = 'use_config_' . $this->getHtmlId();
     $html .= '<input id="' . $htmlId . '" name="use_config[]" value="' . $this->getId() . '"';
     $html .= $disabled ? ' checked="checked"' : '';
     if ($this->getReadonly() || $elementDisabled) {
         $html .= ' disabled="disabled"';
     }
     $html .= ' onclick="alert();" class="checkbox" type="checkbox" />';
     $html .= ' <label for="' . $htmlId . '" class="normal">' . Mage::helper('adminhtml')->__('Use Config Settings') . '</label>';
     $html .= '<script type="text/javascript">toggleValueElements($(\'' . $htmlId . '\'), $(\'' . $htmlId . '\').parentNode);</script>';
     return $html;
 }
 public function translate(array $args)
 {
     $this->reset();
     $this->parseInput($args);
     $this->parsePlaceholders();
     if (count($this->placeholders) <= 0) {
         array_unshift($this->args, $this->text);
         return call_user_func_array(array($this, '__'), $this->args);
     }
     $this->translatedText = parent::__($this->text);
     $this->replacePlaceholdersByValue();
     $this->replacePlaceholdersByArgs();
     $unprocessedArgs = array_diff($this->args, $this->processedArgs);
     if (!$unprocessedArgs) {
         return $this->translatedText;
     }
     return vsprintf($this->translatedText, $unprocessedArgs);
 }
Example #20
0
 /**
  * @param Mage_Core_Controller_Request_Http $request
  * @param Mage_Core_Model_Layout $layout
  * @param Mage_Core_Model_Event_Manager $eventManager
  * @param Mage_Core_Model_Url $urlBuilder
  * @param Mage_Core_Model_Translate $translator
  * @param Mage_Core_Model_Cache $cache
  * @param Mage_Core_Model_Design_Package $designPackage
  * @param Mage_Core_Model_Session $session
  * @param Mage_Core_Model_Store_Config $storeConfig
  * @param Mage_Core_Controller_Varien_Front $frontController
  * @param Mage_Core_Model_Factory_Helper $helperFactory
  * @param Magento_Filesystem $filesystem
  * @param Mage_Backend_Helper_Data $helper
  * @param Mage_Backend_Model_Widget_Grid_Row_UrlGeneratorFactory $generatorFactory
  * @param Mage_Backend_Model_Widget_Grid_SubTotals $subtotals
  * @param Mage_Backend_Model_Widget_Grid_Totals $totals
  * @param array $data
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function __construct(Mage_Core_Controller_Request_Http $request, Mage_Core_Model_Layout $layout, Mage_Core_Model_Event_Manager $eventManager, Mage_Core_Model_Url $urlBuilder, Mage_Core_Model_Translate $translator, Mage_Core_Model_Cache $cache, Mage_Core_Model_Design_Package $designPackage, Mage_Core_Model_Session $session, Mage_Core_Model_Store_Config $storeConfig, Mage_Core_Controller_Varien_Front $frontController, Mage_Core_Model_Factory_Helper $helperFactory, Magento_Filesystem $filesystem, Mage_Backend_Helper_Data $helper, Mage_Backend_Model_Widget_Grid_Row_UrlGeneratorFactory $generatorFactory, Mage_Backend_Model_Widget_Grid_SubTotals $subtotals, Mage_Backend_Model_Widget_Grid_Totals $totals, array $data = array())
 {
     $this->_helper = $helper;
     $generatorClassName = 'Mage_Backend_Model_Widget_Grid_Row_UrlGenerator';
     if (isset($data['rowUrl'])) {
         $rowUrlParams = $data['rowUrl'];
         if (isset($rowUrlParams['generatorClass'])) {
             $generatorClassName = $rowUrlParams['generatorClass'];
         }
         $this->_rowUrlGenerator = $generatorFactory->createUrlGenerator($generatorClassName, array('args' => $rowUrlParams));
     }
     $this->setFilterVisibility(array_key_exists('filter_visibility', $data) ? (bool) $data['filter_visibility'] : true);
     parent::__construct($request, $layout, $eventManager, $urlBuilder, $translator, $cache, $designPackage, $session, $storeConfig, $frontController, $helperFactory, $filesystem, $data);
     $this->setEmptyText($this->_helper->__(isset($data['empty_text']) ? $data['empty_text'] : 'No records found.'));
     $this->setEmptyCellLabel($this->_helper->__(isset($data['empty_cell_label']) ? $data['empty_cell_label'] : 'No records found.'));
     $this->setCountSubTotals(isset($data['count_subtotals']) ? (bool) $data['count_subtotals'] : false);
     $this->_subTotals = $subtotals;
     $this->setCountTotals(isset($data['count_totals']) ? (bool) $data['count_totals'] : false);
     $this->_totals = $totals;
 }
Example #21
0
 /**
  * Create filter fields for 'Filter' column.
  *
  * @param mixed $value
  * @param Mage_Eav_Model_Entity_Attribute $row
  * @param Varien_Object $column
  * @param boolean $isExport
  * @return string
  */
 public function decorateFilter($value, Mage_Eav_Model_Entity_Attribute $row, Varien_Object $column, $isExport)
 {
     switch (Mage_ImportExport_Model_Export::getAttributeFilterType($row)) {
         case Mage_ImportExport_Model_Export::FILTER_TYPE_SELECT:
             $cell = $this->_getSelectHtml($row);
             break;
         case Mage_ImportExport_Model_Export::FILTER_TYPE_INPUT:
             $cell = $this->_getInputHtml($row);
             break;
         case Mage_ImportExport_Model_Export::FILTER_TYPE_DATE:
             $cell = $this->_getDateFromToHtml($row);
             break;
         case Mage_ImportExport_Model_Export::FILTER_TYPE_NUMBER:
             $cell = $this->_getNumberFromToHtml($row);
             break;
         default:
             $cell = $this->_helper->__('Unknown attribute filter type');
     }
     return $cell;
 }
 protected function _construct()
 {
     parent::_construct();
     $this->_is_active = (bool) intval(Mage::getConfig()->getModuleConfig('LimeSoda_TrailingSlashes')->is('active', 'true'));
 }
Example #23
0
 public function _construct()
 {
     parent::_construct();
 }
Example #24
0
 public function testTranslateArray()
 {
     $data = array(uniqid(), array(uniqid(), array(uniqid())));
     $this->assertEquals($data, $this->_helper->translateArray($data));
 }
Example #25
0
 /**
  * upload image
  * @return type
  */
 public function escapeUrl($data)
 {
     parent::escapeUrl($data);
 }
Example #26
0
 public function isModuleOutputEnabled($moduleName = null)
 {
     if ($moduleName === null) {
         $moduleName = 'MagicToolbox_MagicScroll';
         //$this->_getModuleName();
     }
     if (method_exists('Mage_Core_Helper_Abstract', 'isModuleOutputEnabled')) {
         return parent::isModuleOutputEnabled($moduleName);
     }
     //if (!$this->isModuleEnabled($moduleName)) {
     //    return false;
     //}
     if (Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName)) {
         return false;
     }
     return true;
 }
Example #27
0
 /**
  * Check whether item is disabled. Disabled items are not shown to user
  *
  * @return bool
  */
 public function isDisabled()
 {
     return !$this->_moduleHelper->isModuleOutputEnabled() || !$this->_isModuleDependenciesAvailable() || !$this->_isConfigDependenciesAvailable();
 }
 /**
  * Escape string preserving links
  *
  * @param array|string $data
  * @param null|array $allowedTags
  * @return string
  */
 public function escapeHtmlWithLinks($data, $allowedTags = null)
 {
     if (!empty($data) && is_array($allowedTags) && in_array('a', $allowedTags)) {
         $links = [];
         $i = 1;
         $data = str_replace('%', '%%', $data);
         $regexp = "/<a\\s[^>]*href\\s*?=\\s*?([\"\\']??)([^\" >]*?)\\1[^>]*>(.*)<\\/a>/siU";
         while (preg_match($regexp, $data, $matches)) {
             //Revert the sprintf escaping
             $url = str_replace('%%', '%', $matches[2]);
             $text = str_replace('%%', '%', $matches[3]);
             //Check for an valid url
             if ($url) {
                 $urlScheme = strtolower(parse_url($url, PHP_URL_SCHEME));
                 if ($urlScheme !== 'http' && $urlScheme !== 'https') {
                     $url = null;
                 }
             }
             //Use hash tag as fallback
             if (!$url) {
                 $url = '#';
             }
             //Recreate a minimalistic secure a tag
             $links[] = sprintf('<a href="%s">%s</a>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8', false), parent::escapeHtml($text));
             $data = str_replace($matches[0], '%' . $i . '$s', $data);
             ++$i;
         }
         $data = parent::escapeHtml($data, $allowedTags);
         return vsprintf($data, $links);
     }
     return parent::escapeHtml($data, $allowedTags);
 }
 public function _construct()
 {
     parent::_construct();
     $this->_storeId = Mage::app()->getStore()->getId();
 }
Example #30
0
 public function getLayout()
 {
     $layout = parent::getLayout();
     if ($layout) {
         return $layout;
     }
     $layout = Mage::app()->getFrontController()->getAction()->getLayout();
     parent::setLayout($layout);
     return $layout;
 }