Skip to content

Commit

Permalink
Merge pull request #7 from magmodules/1.3.0
Browse files Browse the repository at this point in the history
1.3.0
  • Loading branch information
Marvin-Magmodules authored Feb 13, 2018
2 parents 506b625 + 5a13627 commit 4154184
Show file tree
Hide file tree
Showing 69 changed files with 2,152 additions and 1,091 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*/

Expand All @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*/

Expand All @@ -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(
Expand All @@ -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');
Expand All @@ -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(
Expand All @@ -82,5 +114,4 @@ public function _prepareArrayRow(Varien_Object $row)
);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(
Expand All @@ -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) {
Expand All @@ -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');
}

}
Loading

0 comments on commit 4154184

Please sign in to comment.