<commit_before><?php
/**
 * Magento
 *
 * 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
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Hackathon
 * @package     Hackathon_MageMonitoring
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

class Hackathon_MageMonitoring_Block_Tab_Config extends Mage_Adminhtml_Block_Template
{
    public function __construct()
    {
        parent::__construct();
        $this->setTemplate('monitoring/tab/config.phtml');
    }

/**
     * Prepare Global Layout
     *
     * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main
     */
    protected function _prepareLayout()
    {
        $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);

        $this->setChild('tab_tree',
            $this->getLayout()->createBlock('magemonitoring/tab_config_tree_tab')
        );

        $this->setChild('edit_widget_config_form',
            $this->getLayout()->createBlock('magemonitoring/tab_config_formconfig')
        );

        $this->setChild('delete_tab_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('Delete Selected Tab'),
                'onclick'   => 'editSet.submit();',
                'class'     => 'delete'
        )));

        $this->setChild('add_tab_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('Add New Tab'),
                'onclick'   => 'editSet.addTab();',
                'class'     => 'add'
        )));

        $this->setChild('back_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('Back'),
                'onclick'   => 'setLocation(\''.$this->getUrl('*/*/').'\')',
                'class'     => 'back'
        )));

        $this->setChild('reset_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('Reset'),
                'onclick'   => 'window.location.reload()'
        )));

        $this->setChild('save_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('Save Tab Config'),
                'onclick'   => 'editSet.save();',
                'class'     => 'save'
        )));

        $this->setChild('delete_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('Factory Configuration'),
                'onclick'   => 'deleteConfirm(\''. $this->jsQuoteEscape(Mage::helper('catalog')->__('Really delete tab configuration?')) . '\', \'' . '\')',
                'class'     => 'delete'
        )));

        $this->setChild('rename_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('New Tab Name'),
                'onclick'   => 'editSet.rename()'
        )));

        return parent::_prepareLayout();
    }

    /**
     * Retrieve Attribute Set Group Tree HTML
     *
     * @return string
     */
    public function getTabTreeHtml()
    {
        return $this->getChildHtml('tab_tree');
    }

    /**
     * Retrieve Attribute Set Edit Form HTML
     *
     * @return string
     */
    public function getEditWidgetConfigFormHtml()
    {
        return $this->getChildHtml('edit_widget_config_form');
    }

    /**
     * Retrieve Block Header Text
     *
     * @return string
     */
    protected function _getHeader()
    {
        return Mage::helper('catalog')->__('Edit Tab Config');
    }

    /**
     * Retrieve Attribute Set Save URL
     *
     * @return string
     */
    public function getMoveUrl()
    {
        return $this->getUrl('*/widgetAjax/saveTabConfig');
    }

    public function getEditWidgetConfigFormUrl()
    {
        return $this->getUrl('*/widgetAjax/getWidgetConfigForm');
    }

    /**
     * Retrieve Attribute Set Group Save URL
     *
     * @return string
     */
    public function getTabUrl()
    {
        return $this->getUrl('*/catalog_product_group/save', array('id' => $this->_getSetId()));
    }

    /**
     * Retrieve Tab Tree as JSON format
     *
     * @return string
     */
    public function getTabTreeJson()
    {
        $tabsJson = array();
        $setId = $this->_getSetId();

        if (!$this->_configuredWidgets) {
            $this->_configuredWidgets = Mage::helper('magemonitoring')->getConfiguredWidgets();
        }

        $tabs = Mage::getStoreConfig('magemonitoring/tabs');

        /* @var $node MageMonitoring Tab */
        foreach ($tabs as $tabId => $tab) {
            $tabJson = array();
            $tabJson['text']       = $tab['titel'];
            $tabJson['id']         = $tabId;
            $tabJson['cls']        = 'folder';
            $tabJson['allowDrop']  = true;
            $tabJson['allowDrag']  = true;


            if (is_array($tab['widgets'])) {
                $tabJson['children'] = array();
                foreach ($this->_configuredWidgets[$tabId] as $widgetDbId => $widget) {
                    /* @var $child MageMonitoring Widget */
                    $widgetJson = array(
                        'text'              => $widget->getName(),
                        'id'                => $widget->getConfigId(),
                        'impl'              => $widget->getId(),
                        'cls'               => (false) ? 'system-leaf' : 'leaf',
                        'allowDrop'         => false,
                        'allowDrag'         => true,
                        'leaf'              => true,
                        'is_user_defined'   => false,
                        'is_configurable'   => false,
                        'entity_id'         => $widget->getConfigId()
                    );

                    $tabJson['children'][] = $widgetJson;
                }
            } else {
                $tabJson['allowChildren'] = false;
            }

            $tabsJson[] = $tabJson;
        }<commit_msg>Fix for renamed node name<commit_after><?php
/**
 * Magento
 *
 * 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
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Hackathon
 * @package     Hackathon_MageMonitoring
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

class Hackathon_MageMonitoring_Block_Tab_Config extends Mage_Adminhtml_Block_Template
{
    public function __construct()
    {
        parent::__construct();
        $this->setTemplate('monitoring/tab/config.phtml');
    }

/**
     * Prepare Global Layout
     *
     * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main
     */
    protected function _prepareLayout()
    {
        $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);

        $this->setChild('tab_tree',
            $this->getLayout()->createBlock('magemonitoring/tab_config_tree_tab')
        );

        $this->setChild('edit_widget_config_form',
            $this->getLayout()->createBlock('magemonitoring/tab_config_formconfig')
        );

        $this->setChild('delete_tab_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('Delete Selected Tab'),
                'onclick'   => 'editSet.submit();',
                'class'     => 'delete'
        )));

        $this->setChild('add_tab_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('Add New Tab'),
                'onclick'   => 'editSet.addTab();',
                'class'     => 'add'
        )));

        $this->setChild('back_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('Back'),
                'onclick'   => 'setLocation(\''.$this->getUrl('*/*/').'\')',
                'class'     => 'back'
        )));

        $this->setChild('reset_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('Reset'),
                'onclick'   => 'window.location.reload()'
        )));

        $this->setChild('save_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('Save Tab Config'),
                'onclick'   => 'editSet.save();',
                'class'     => 'save'
        )));

        $this->setChild('delete_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('Factory Configuration'),
                'onclick'   => 'deleteConfirm(\''. $this->jsQuoteEscape(Mage::helper('catalog')->__('Really delete tab configuration?')) . '\', \'' . '\')',
                'class'     => 'delete'
        )));

        $this->setChild('rename_button',
            $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
                'label'     => Mage::helper('catalog')->__('New Tab Name'),
                'onclick'   => 'editSet.rename()'
        )));

        return parent::_prepareLayout();
    }

    /**
     * Retrieve Attribute Set Group Tree HTML
     *
     * @return string
     */
    public function getTabTreeHtml()
    {
        return $this->getChildHtml('tab_tree');
    }

    /**
     * Retrieve Attribute Set Edit Form HTML
     *
     * @return string
     */
    public function getEditWidgetConfigFormHtml()
    {
        return $this->getChildHtml('edit_widget_config_form');
    }

    /**
     * Retrieve Block Header Text
     *
     * @return string
     */
    protected function _getHeader()
    {
        return Mage::helper('catalog')->__('Edit Tab Config');
    }

    /**
     * Retrieve Attribute Set Save URL
     *
     * @return string
     */
    public function getMoveUrl()
    {
        return $this->getUrl('*/widgetAjax/saveTabConfig');
    }

    public function getEditWidgetConfigFormUrl()
    {
        return $this->getUrl('*/widgetAjax/getWidgetConfigForm');
    }

    /**
     * Retrieve Attribute Set Group Save URL
     *
     * @return string
     */
    public function getTabUrl()
    {
        return $this->getUrl('*/catalog_product_group/save', array('id' => $this->_getSetId()));
    }

    /**
     * Retrieve Tab Tree as JSON format
     *
     * @return string
     */
    public function getTabTreeJson()
    {
        $tabsJson = array();
        $setId = $this->_getSetId();

        if (!$this->_configuredWidgets) {
            $this->_configuredWidgets = Mage::helper('magemonitoring')->getConfiguredWidgets();
        }

        $tabs = Mage::getStoreConfig('magemonitoring/tabs');

        /* @var $node MageMonitoring Tab */
        foreach ($tabs as $tabId => $tab) {
            $tabJson = array();
            $tabJson['text']       = $tab['title'];
            $tabJson['id']         = $tabId;
            $tabJson['cls']        = 'folder';
            $tabJson['allowDrop']  = true;
            $tabJson['allowDrag']  = true;


            if (is_array($tab['widgets'])) {
                $tabJson['children'] = array();
                foreach ($this->_configuredWidgets[$tabId] as $widgetDbId => $widget) {
                    /* @var $child MageMonitoring Widget */
                    $widgetJson = array(
                        'text'              => $widget->getName(),
                        'id'                => $widget->getConfigId(),
                        'impl'              => $widget->getId(),
                        'cls'               => (false) ? 'system-leaf' : 'leaf',
                        'allowDrop'         => false,
                        'allowDrag'         => true,
                        'leaf'              => true,
                        'is_user_defined'   => false,
                        'is_configurable'   => false,
                        'entity_id'         => $widget->getConfigId()
                    );

                    $tabJson['children'][] = $widgetJson;
                }
            } else {
                $tabJson['allowChildren'] = false;
            }

            $tabsJson[] = $tabJson;
        }
{'fraction_non_alphanumeric': 0.1503737780333525, 'fraction_numerical': 0.0011500862564692352, 'mean_word_length': 1.8991456553448636, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 197, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2891715', 'n_tokens_mistral': 3942, 'n_tokens_neox': 3774, 'n_words': 734}