Skip to content

Commit

Permalink
Now displays the configuration code (which is used for Mage::getStore…
Browse files Browse the repository at this point in the history
…Config) with the configuration fields. (Closes #7)
  • Loading branch information
avstudnitz committed Mar 27, 2013
1 parent ae56afd commit 5b86c92
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
4 changes: 3 additions & 1 deletion readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Works for product and category attributes too (as of v0.3.0)

Facts
-----
- version: 0.4.0
- version: 0.5.0
- extension key: AvS_ScopeHint
- [extension on Magento Connect](http://www.magentocommerce.com/magento-connect/scope-hint.html)
- Magento Connect 1.0 extension key: magento-community/AvS_ScopeHint
Expand All @@ -21,6 +21,8 @@ See the [screenshot](http://www.avs-webentwicklung.de/fileadmin/modules/AvS_Scop

Works for category and product editing too.

Now displays the configuration code (which is used for Mage::getStoreConfig) with the configuration fields.

Requirements
------------
- PHP >= 5.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function getScopeLabel()
$html = parent::getScopeLabel();

$html .= '<div class="scopehint" style="padding: 6px 6px 0 6px; display: inline-block;">';
$html .= $this->_getScopeHint($this->getElement());
$html .= $this->_getScopeHintHtml($this->getElement());
$html .= '</div>';


Expand All @@ -26,7 +26,7 @@ public function getScopeLabel()
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
protected function _getScopeHint($element)
protected function _getScopeHintHtml($element)
{
if (Mage::registry('current_category')) {
$type = 'category';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ public function render(Varien_Data_Form_Element_Abstract $element)
if ($element->getScope()) {
$html .= $element->getScopeLabel();
}
$html .= '<br />';
$html .= $this->_getConfigCode($element);
$html .= '</td>';

$html .= '<td class="scopehint" style="padding: 6px 6px 0 6px;">';
$html .= $this->_getScopeHint($element);
$html .= $this->_getScopeHintHtml($element);
$html .= '</td>';

$html .= '<td class="">';
Expand All @@ -112,12 +114,33 @@ public function render(Varien_Data_Form_Element_Abstract $element)
return $html;
}

protected function _getScopeHint($element)
/**
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
protected function _getScopeHintHtml(Varien_Data_Form_Element_Abstract $element)
{
return $this->getLayout()
->createBlock('scopehint/hint', 'scopehint')
->setElement($element)
->setType('config')
->toHtml();
}

/**
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
protected function _getConfigCode(Varien_Data_Form_Element_Abstract $element)

This comment has been minimized.

Copy link
@amenk

amenk Mar 27, 2013

Collaborator

such an ugly function - but if you think that works :-)

This comment has been minimized.

Copy link
@avstudnitz

avstudnitz Mar 27, 2013

Author Owner

I have taken it from somewhere, don't remember as I first used it a while ago. If you see some better way, feel free to update it :-)

{
$configCode = preg_replace('#\[value\](\[\])?$#', '', $element->getName());
$configCode = str_replace('[fields]', '', $configCode);
$configCode = str_replace('groups[', '[', $configCode);
$configCode = str_replace('][', '/', $configCode);
$configCode = str_replace(']', '', $configCode);
$configCode = str_replace('[', '', $configCode);
$configCode = Mage::app()->getRequest()->getParam('section') . '/' . $configCode;
return $configCode;
}

}
2 changes: 1 addition & 1 deletion src/app/code/community/AvS/ScopeHint/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<modules>
<AvS_ScopeHint>
<version>0.4.0</version>
<version>0.5.0</version>
</AvS_ScopeHint>
</modules>

Expand Down

0 comments on commit 5b86c92

Please sign in to comment.