Skip to content

Commit

Permalink
First commit (start as of version 0.8.4.4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mage-eag committed Jun 20, 2012
1 parent 5b91363 commit 1594278
Show file tree
Hide file tree
Showing 172 changed files with 19,782 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category BL
* @package BL_CustomGrid
* @copyright Copyright (c) 2011 Benoît Leulliette <[email protected]>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

abstract class BL_CustomGrid_Block_Column_Renderer_Abstract
extends Mage_Adminhtml_Block_Widget_Form_Container
{
abstract protected function _getController();
abstract protected function _getFormId();
abstract public function getRenderer();

public function __construct()
{
parent::__construct();

$this->_blockGroup = 'customgrid';
$this->_controller = $this->_getController();
$this->_mode = 'config';
$this->_headerText = $this->getRenderer()->getName();

$this->removeButton('reset');
$this->removeButton('back');
$this->_updateButton('save', 'label', $this->__('Apply Configuration'));
$this->_updateButton('save', 'id', 'insert_button');
$this->_updateButton('save', 'onclick', 'blcgRendererConfig.insertRenderer()');

$this->_formScripts[] = 'blcgRendererConfig = new blcg.Renderer.Config("' . $this->_getFormId() . '", "'
. $this->getRequest()->getParam('renderer_target_id') . '");';
}

protected function _beforeToHtml()
{
if ($formBlock = $this->getChild('form')) {
$formBlock->setRendererParams($this->getRendererParams());
}
return parent::_beforeToHtml();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category BL
* @package BL_CustomGrid
* @copyright Copyright (c) 2011 Benoît Leulliette <[email protected]>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class BL_CustomGrid_Block_Column_Renderer_Attribute
extends BL_CustomGrid_Block_Column_Renderer_Abstract
{
protected function _getController()
{
return 'column_renderer_attribute';
}

protected function _getFormId()
{
return 'column_renderer_attribute_options_form';
}

public function getFormHtml()
{
$html = '<div class="blcg-attribute-renderer-help">' . $this->getRenderer()->getHelp() . '</div>';
$html .= parent::getFormHtml();
return $html;
}

public function getRenderer()
{
return Mage::registry('current_attribute_column_renderer');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category BL
* @package BL_CustomGrid
* @copyright Copyright (c) 2011 Benoît Leulliette <[email protected]>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class BL_CustomGrid_Block_Column_Renderer_Attribute_Config_Form
extends BL_CustomGrid_Block_Column_Renderer_Config_Form_Abstract
{
protected function _getFormId()
{
return 'column_renderer_attribute_options_form';
}

public function getRenderer()
{
$renderer = Mage::registry('current_attribute_column_renderer');
if (!$renderer) {
Mage::throwException($this->__('Renderer is not specified'));
}
return $renderer;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category BL
* @package BL_CustomGrid
* @copyright Copyright (c) 2011 Benoît Leulliette <[email protected]>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class BL_CustomGrid_Block_Column_Renderer_Attribute_Select
extends Mage_Adminhtml_Block_Template
{
static protected $_instanceNumber = 0;
protected $_instanceId;

public function _construct()
{
parent::_construct();
$this->_instanceId = ++self::$_instanceNumber;
$this->setTemplate('bl/customgrid/column/renderer/attribute/select.phtml');
}

public function getJsObjectName()
{
return $this->getHtmlId() . 'JsObject';
}

protected function _getAttributes()
{
if ($model = $this->getGridModel()) {
return $model->getAvailableAttributes(true, true);
} else {
return array();
}
}

/**
* Return array of available renderers based on configuration
*
* @return array
*/
protected function _getAvailableRenderers($withEmpty=false)
{
return Mage::getSingleton('customgrid/column_renderer_attribute')
->getRenderersArray($withEmpty);
}

public function getAttributesJsonConfig()
{
$config = array();

foreach ($this->_getAttributes() as $attribute) {
$config[] = array(
'code' => $attribute->getAttributeCode(),
'rendererCode' => $attribute->getRendererCode(),
'editableValues' => (bool) $attribute->getEditableValues(),
);
}

return Mage::helper('core')->jsonEncode($config);
}

public function getRenderersJsonConfig($withEmpty=false)
{
$config = array();

foreach ($this->_getAvailableRenderers($withEmpty) as $renderer) {
$values = array(
'code' => $renderer['code'],
'isCustomizable' => $renderer['is_customizable'],
);
if (isset($renderer['config_window'])) {
$values['windowConfig'] = array(
'width' => $renderer['config_window']['width'],
'height' => $renderer['config_window']['height'],
'title' => $this->htmlEscape($renderer['config_window']['title']),
);
}
$config[] = $values;
}

return Mage::helper('core')->jsonEncode($config);
}

public function getEditableJsonConfig()
{
return Mage::helper('core')->jsonEncode(array(
'editableContainerId' => ($this->hasData('editable_container_id') ? $this->getData('editable_container_id') : null),
'editableCheckboxId' => ($this->hasData('editable_checkbox_id') ? $this->getData('editable_checkbox_id') : null),
'yesMessageText' => '<span class="nobr">'.$this->__('Yes').'</span>',
'noMessageText' => '<span class="nobr">'.$this->__('No').'</span>',
));
}

protected function _beforeToHtml()
{
if ($this->_getData('id') == '') {
$this->setData('id', $this->_instanceId);
}
if ($this->_getData('html_id') == '') {
$this->setData('html_id', 'blcgAttributeRendererSelect'.$this->getId());
}
if ($this->_getData('select_id') == '') {
$this->setData('select_id', $this->getHtmlId().'-select');
}
return parent::_beforeToHtml();
}

protected function _toHtml()
{
$html = parent::_toHtml();
if ($this->getOutputAsJs()) {
$html = $this->helper('customgrid/js')->prepareHtmlForJsOutput($html, true);
}
return $html;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category BL
* @package BL_CustomGrid
* @copyright Copyright (c) 2011 Benoît Leulliette <[email protected]>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class BL_CustomGrid_Block_Column_Renderer_Collection
extends BL_CustomGrid_Block_Column_Renderer_Abstract
{
protected function _getController()
{
return 'column_renderer_collection';
}

protected function _getFormId()
{
return 'column_renderer_collection_options_form';
}

public function getFormHtml()
{
$html = '<div class="blcg-collection-renderer-help">' . $this->getRenderer()->getHelp() . '</div>';
$html .= parent::getFormHtml();
return $html;
}

public function getRenderer()
{
return Mage::registry('current_collection_column_renderer');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category BL
* @package BL_CustomGrid
* @copyright Copyright (c) 2011 Benoît Leulliette <[email protected]>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class BL_CustomGrid_Block_Column_Renderer_Collection_Config_Form
extends BL_CustomGrid_Block_Column_Renderer_Config_Form_Abstract
{
protected function _getFormId()
{
return 'column_renderer_collection_options_form';
}

public function getRenderer()
{
$renderer = Mage::registry('current_collection_column_renderer');
if (!$renderer) {
Mage::throwException($this->__('Renderer is not specified'));
}
return $renderer;
}
}
Loading

0 comments on commit 1594278

Please sign in to comment.