-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from magmodules/1.3.0
1.3.0
- Loading branch information
Showing
69 changed files
with
2,152 additions
and
1,091 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* @category Magmodules | ||
* @package Magmodules_Sooqr | ||
* @author Magmodules <[email protected]> | ||
* @copyright Copyright (c) 2017 (http://www.magmodules.eu) | ||
* @copyright Copyright (c) 2018 (http://www.magmodules.eu) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
|
@@ -33,8 +33,15 @@ class Magmodules_Sooqr_Block_Adminhtml_Config_Form_Field_Extra | |
public function __construct() | ||
{ | ||
$layout = Mage::app()->getFrontController()->getAction()->getLayout(); | ||
$rendererAttribute = $layout->createBlock('sooqr/adminhtml_config_form_renderer_select', '', array('is_render_to_js_template' => true)); | ||
$rendererAttribute->setOptions(Mage::getModel('sooqr/adminhtml_system_config_source_attribute')->toOptionArray()); | ||
$rendererAttribute = $layout->createBlock( | ||
'sooqr/adminhtml_config_form_renderer_select', | ||
'', | ||
array('is_render_to_js_template' => true) | ||
); | ||
$rendererAttribute->setOptions( | ||
Mage::getModel('sooqr/adminhtml_system_config_source_attribute')->toOptionArray() | ||
); | ||
|
||
$this->addColumn( | ||
'attribute', array( | ||
'label' => Mage::helper('sooqr')->__('Attribute'), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* @category Magmodules | ||
* @package Magmodules_Sooqr | ||
* @author Magmodules <[email protected]> | ||
* @copyright Copyright (c) 2017 (http://www.magmodules.eu) | ||
* @copyright Copyright (c) 2018 (http://www.magmodules.eu) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
|
@@ -28,16 +28,39 @@ class Magmodules_Sooqr_Block_Adminhtml_Config_Form_Field_Filter | |
protected $_renders = array(); | ||
|
||
/** | ||
* Magmodules_Sooqr_Block_Adminhtml_Config_Form_Field_Shipping constructor. | ||
* Magmodules_Sooqr_Block_Adminhtml_Config_Form_Field_Filter constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
$layout = Mage::app()->getFrontController()->getAction()->getLayout(); | ||
$rendererAttributes = $layout->createBlock('sooqr/adminhtml_config_form_renderer_select', '', array('is_render_to_js_template' => true)); | ||
$rendererAttributes->setOptions(Mage::getModel('sooqr/adminhtml_system_config_source_attribute')->toOptionArray()); | ||
$rendererAttributes = $layout->createBlock( | ||
'sooqr/adminhtml_config_form_renderer_select', | ||
'', | ||
array('is_render_to_js_template' => true) | ||
); | ||
$rendererAttributes->setOptions( | ||
Mage::getModel('sooqr/adminhtml_system_config_source_attribute')->toOptionArray() | ||
); | ||
|
||
$rendererConditions = $layout->createBlock( | ||
'sooqr/adminhtml_config_form_renderer_select', | ||
'', | ||
array('is_render_to_js_template' => true) | ||
); | ||
|
||
$rendererConditions->setOptions( | ||
Mage::getModel('sooqr/adminhtml_system_config_source_conditions')->toOptionArray() | ||
); | ||
|
||
$rendererTypes = $layout->createBlock( | ||
'sooqr/adminhtml_config_form_renderer_select', | ||
'', | ||
array('is_render_to_js_template' => true) | ||
); | ||
|
||
$rendererConditions = $layout->createBlock('sooqr/adminhtml_config_form_renderer_select', '', array('is_render_to_js_template' => true)); | ||
$rendererConditions->setOptions(Mage::getModel('sooqr/adminhtml_system_config_source_conditions')->toOptionArray()); | ||
$rendererTypes->setOptions( | ||
Mage::getModel('sooqr/adminhtml_system_config_source_producttypes')->toOptionArray() | ||
); | ||
|
||
$this->addColumn( | ||
'attribute', array( | ||
|
@@ -62,8 +85,17 @@ public function __construct() | |
) | ||
); | ||
|
||
$this->addColumn( | ||
'product_type', array( | ||
'label' => Mage::helper('sooqr')->__('Apply To'), | ||
'style' => 'width:150px', | ||
'renderer' => $rendererTypes | ||
) | ||
); | ||
|
||
$this->_renders['attribute'] = $rendererAttributes; | ||
$this->_renders['condition'] = $rendererConditions; | ||
$this->_renders['product_type'] = $rendererTypes; | ||
|
||
$this->_addAfter = false; | ||
$this->_addButtonLabel = Mage::helper('sooqr')->__('Add Filter'); | ||
|
@@ -73,7 +105,7 @@ public function __construct() | |
/** | ||
* @param Varien_Object $row | ||
*/ | ||
public function _prepareArrayRow(Varien_Object $row) | ||
protected function _prepareArrayRow(Varien_Object $row) | ||
{ | ||
foreach ($this->_renders as $key => $render) { | ||
$row->setData( | ||
|
@@ -82,5 +114,4 @@ public function _prepareArrayRow(Varien_Object $row) | |
); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,68 +14,77 @@ | |
* @category Magmodules | ||
* @package Magmodules_Sooqr | ||
* @author Magmodules <[email protected]> | ||
* @copyright Copyright (c) 2017 (http://www.magmodules.eu) | ||
* @copyright Copyright (c) 2018 (http://www.magmodules.eu) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
class Magmodules_Sooqr_Block_Adminhtml_Config_Form_Renderer_Select extends Mage_Core_Block_Html_Select | ||
{ | ||
|
||
/** | ||
* @param $inputName | ||
* | ||
* @return $this | ||
*/ | ||
public function setInputName($inputName) | ||
{ | ||
$this->setData('inputname', $inputName); | ||
return $this; | ||
} | ||
|
||
public function getInputName() | ||
{ | ||
return $this->getData('inputname'); | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param $columnName | ||
* | ||
* @return $this | ||
*/ | ||
public function setColumnName($columnName) | ||
{ | ||
$this->setData('columnname', $columnName); | ||
return $this; | ||
} | ||
|
||
public function getColumnName() | ||
{ | ||
return $this->getData('columnname'); | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param $column | ||
* | ||
* @return $this | ||
*/ | ||
public function setColumn($column) | ||
{ | ||
$this->setData('column', $column); | ||
return $this; | ||
} | ||
|
||
public function getColumn() | ||
{ | ||
return $this->getData('column'); | ||
return $this; | ||
} | ||
|
||
public function getExtraParams() | ||
/** | ||
* @return mixed | ||
*/ | ||
public function getHtml() | ||
{ | ||
$column = $this->getColumn(); | ||
if ($column && isset($column['style'])) { | ||
return ' style="' . $column['style'] . '" '; | ||
} else { | ||
return ''; | ||
} | ||
return $this->toHtml(); | ||
} | ||
|
||
public function _toHtml() | ||
/** | ||
* @return string | ||
*/ | ||
protected function _toHtml() | ||
{ | ||
if (!$this->_beforeToHtml()) { | ||
return ''; | ||
} | ||
|
||
$html = '<select name="' . $this->getInputName() . '" class="' . $this->getClass() . '" ' . $this->getExtraParams() . '>'; | ||
$html = sprintf( | ||
'<select name="%s" class="%s" %s>', | ||
$this->getInputName(), | ||
$this->getClass(), | ||
$this->getExtraParams() | ||
); | ||
|
||
$values = $this->getValue(); | ||
|
||
if (!is_array($values)) { | ||
if (!is_null($values)) { | ||
if (!empty($values)) { | ||
$values = array($values); | ||
} else { | ||
$values = array(); | ||
|
@@ -97,7 +106,7 @@ public function _toHtml() | |
} | ||
|
||
if (is_array($value)) { | ||
$html .= '<optgroup label="' . $label . '">'; | ||
$html .= '<optgroup label="' . htmlspecialchars($label, ENT_QUOTES | ENT_HTML5) . '">'; | ||
foreach ($value as $keyGroup => $optionGroup) { | ||
if (!is_array($optionGroup)) { | ||
$optionGroup = array( | ||
|
@@ -106,30 +115,62 @@ public function _toHtml() | |
); | ||
} | ||
|
||
$html .= $this->_optionToHtml( | ||
$optionGroup, | ||
in_array($optionGroup['value'], $values) | ||
); | ||
$html .= $this->_optionToHtml($optionGroup, in_array($optionGroup['value'], $values)); | ||
} | ||
|
||
$html .= '</optgroup>'; | ||
} else { | ||
$html .= $this->_optionToHtml( | ||
array( | ||
'value' => $value, | ||
'label' => $label, | ||
'params' => $params | ||
), | ||
in_array($value, $values) | ||
'value' => $value, | ||
'label' => $label, | ||
'params' => $params | ||
), in_array($value, $values) | ||
); | ||
} | ||
} | ||
|
||
$html .= '</select>'; | ||
|
||
return $html; | ||
} | ||
|
||
public function _optionToHtml($option, $selected = false) | ||
/** | ||
* @return mixed | ||
*/ | ||
public function getInputName() | ||
{ | ||
return $this->getData('inputname'); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getExtraParams() | ||
{ | ||
$column = $this->getColumn(); | ||
if ($column && isset($column['style'])) { | ||
return ' style="' . $column['style'] . '" '; | ||
} else { | ||
return ''; | ||
} | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getColumn() | ||
{ | ||
return $this->getData('column'); | ||
} | ||
|
||
/** | ||
* @param $option | ||
* @param bool $selected | ||
* | ||
* @return string | ||
*/ | ||
protected function _optionToHtml($option, $selected = false) | ||
{ | ||
$selectedHtml = $selected ? ' selected="selected"' : ''; | ||
if ($this->getIsRenderToJsTemplate() === true) { | ||
|
@@ -151,21 +192,28 @@ public function _optionToHtml($option, $selected = false) | |
|
||
return sprintf( | ||
'<option value="%s"%s %s>%s</option>', | ||
$this->htmlEscape($option['value']), | ||
$this->escapeHtml($option['value']), | ||
$selectedHtml, | ||
$params, | ||
$this->htmlEscape($option['label']) | ||
$params, $this->escapeHtml($option['label']) | ||
); | ||
} | ||
|
||
public function getHtml() | ||
/** | ||
* @param $optionValue | ||
* | ||
* @return string | ||
*/ | ||
public function calcOptionHash($optionValue) | ||
{ | ||
return $this->toHtml(); | ||
return sprintf('%u', crc32($this->getColumnName() . $this->getInputName() . $optionValue)); | ||
} | ||
|
||
public function calcOptionHash($optionValue) | ||
/** | ||
* @return mixed | ||
*/ | ||
public function getColumnName() | ||
{ | ||
return sprintf('%u', crc32($this->getColumnName() . $this->getInputName() . $optionValue)); | ||
return $this->getData('columnname'); | ||
} | ||
|
||
} |
Oops, something went wrong.