예제 #1
0
 protected function _toHtml()
 {
     $element = $this->getElement();
     /* @var $fieldset Varien_Data_Form_Element_Fieldset */
     $fieldset = $element->getForm()->getElement($this->getFieldsetId());
     $chooserId = $this->getUniqId();
     $config = $this->getConfig();
     // add chooser element to fieldset
     $chooser = $fieldset->addField('chooser' . $element->getId(), 'note', array('label' => $config->getLabel() ? $config->getLabel() : '', 'value_class' => 'value2'));
     $hiddenHtml = '';
     if ($this->getHiddenEnabled()) {
         $hidden = new Varien_Data_Form_Element_Hidden($element->getData());
         $hidden->setId("{$chooserId}value")->setForm($element->getForm());
         if ($element->getRequired()) {
             $hidden->addClass('required-entry');
         }
         $hiddenHtml = $hidden->getElementHtml();
         $element->setValue('');
     }
     $buttons = $config->getButtons();
     $chooseButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')->setId($chooserId . 'control')->setClass('btn-chooser')->setLabel($buttons['open'])->setOnclick($chooserId . '.choose()');
     $delButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')->setId($chooserId . 'del_control')->setClass('btn-del-img')->setLabel(' Delete image ')->setOnclick('del(this)');
     $chooser->setData('after_element_html', $hiddenHtml . $chooseButton->toHtml() . $delButton->toHtml());
     // render label and chooser scripts
     $configJson = Mage::helper('core')->jsonEncode($config->getData());
     return '
         <label class="widget-option-label" id="' . $chooserId . 'label">' . ($this->getLabel() ? $this->getLabel() : Mage::helper('widget')->__('Not Selected')) . '</label>
         <div id="' . $chooserId . 'advice-container" class="hidden"></div>
         <script type="text/javascript">
             ' . $chooserId . ' = new WysiwygWidget.chooser("' . $chooserId . '", "' . $this->getSourceUrl() . '", ' . $configJson . ');
         </script>
     ';
 }
예제 #2
0
    /**
     * Return chooser HTML and init scripts
     *
     * @return string
     */
    protected function _toHtml()
    {
        $element = $this->getElement();
        /* @var $fieldset Varien_Data_Form_Element_Fieldset */
        $fieldset = $element->getForm()->getElement($this->getFieldsetId());
        $chooserId = $this->getUniqId();
        $config = $this->getConfig();
        // add chooser element to fieldset
        $chooser = $fieldset->addField('chooser' . $element->getId(), 'note', array('label' => $config->getLabel() ? $config->getLabel() : '', 'value_class' => 'value2'));
        $hiddenHtml = '';
        if ($this->getHiddenEnabled()) {
            $hidden = new Varien_Data_Form_Element_Hidden($element->getData());
            $hidden->setId("{$chooserId}value")->setForm($element->getForm());
            if ($element->getRequired()) {
                $hidden->addClass('required-entry');
            }
            $hiddenHtml = $hidden->getElementHtml();
            $element->setValue('');
        }
        $buttons = $config->getButtons();
        $chooseButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')->setId($chooserId . 'control')->setClass('btn-chooser')->setLabel($buttons['open'])->setOnclick($chooserId . '.choose()')->setDisabled($element->getReadonly());
        $chooser->setData('after_element_html', $hiddenHtml . $chooseButton->toHtml());
        // render label and chooser scripts
        $configJson = Mage::helper('core')->jsonEncode($config->getData());
        return '
            <label class="widget-option-label" id="' . $chooserId . 'label">' . ($this->getLabel() ? $this->getLabel() : Mage::helper('widget')->__('Not Selected')) . '</label>
            <div id="' . $chooserId . 'advice-container" class="hidden"></div>
            <script type="text/javascript">//<![CDATA[
                (function() {
                    var instantiateChooser = function() {
                        window.' . $chooserId . ' = new WysiwygWidget.chooser(
                            "' . $chooserId . '",
                            "' . $this->getSourceUrl() . '",
                            ' . $configJson . '
                        );
                        if ($("' . $chooserId . 'value")) {
                            $("' . $chooserId . 'value").advaiceContainer = "' . $chooserId . 'advice-container";
                        }
                    }

                    if (document.loaded) { //allow load over ajax
                        instantiateChooser();
                    } else {
                        document.observe("dom:loaded", instantiateChooser);
                    }
                })();
            //]]></script>
        ';
    }
예제 #3
0
 /**
  * Return chooser HTML and init scripts
  *
  * @return string
  */
 protected function _toHtml()
 {
     if (is_null(Mage::registry('megamenu_adminhtml_widget_chooser'))) {
         return parent::_toHtml();
     }
     //unregister
     Mage::unregister('megamenu_adminhtml_widget_chooser');
     $element = $this->getElement();
     $htmlIdPrefix = $element->getForm()->getHtmlIdPrefix();
     /* @var $fieldset Varien_Data_Form_Element_Fieldset */
     // $fieldset  = $element->getForm()->getElement($this->getFieldsetId());// getForm >> getFieldset >> field
     $chooserId = $this->getUniqId();
     // echo $chooserId;die;	//options_fieldset_megamenu_sm_megamenu_product_id44c9ff3c66b2985cea68c24a0e23ef5b
     // $sourceUrl chua' megamenu gay loi khi ajax	 :http://127.0.0.1/mage1510/index.php/*megamenu*/catalog_product_widget/chooser/uniq_id/options_fieldset_megamenu_id_pathc0244322fc3e6acc4edb
     $admin = Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');
     $SourceUrl = str_replace("/megamenu/", "/{$admin}/", $this->getSourceUrl());
     $SourceUrl = str_replace("/uniq_id/", "/uniq_id/" . $htmlIdPrefix, $SourceUrl);
     $this->setSourceUrl($SourceUrl);
     $config = $this->getConfig();
     // add chooser element to fieldset
     // $chooser = $fieldset->addField('chooser' . $element->getId(), 'note', array(
     // 'label'       => $config->getLabel() ? $config->getLabel() : '',
     // 'value_class' => 'value2',
     // ));
     $hiddenHtml = '';
     if ($this->getHiddenEnabled()) {
         $hidden = new Varien_Data_Form_Element_Hidden($element->getData());
         $hidden->setId("{$chooserId}value")->setForm($element->getForm());
         if ($element->getRequired()) {
             $hidden->addClass('required-entry');
         }
         $hiddenHtml = $hidden->getElementHtml();
         $element->setValue('');
     }
     // $config->getData() ;// array(1) {    ["buttons"] => array(2) {      ["open"] => string(17) "Select Product..."      ["close"] => string(5) "Close"    }  }
     $configJson = Mage::helper('core')->jsonEncode($config->getData());
     $js = '
         <script type="text/javascript">
             ' . $htmlIdPrefix . $chooserId . ' = new WysiwygWidget.chooser("' . $htmlIdPrefix . $chooserId . '", "' . $this->getSourceUrl() . '", ' . $configJson . ');
             // $("' . $chooserId . 'value").advaiceContainer = "' . $chooserId . 'advice-container";
         </script>
     ';
     $buttons = $config->getButtons();
     $chooseButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')->setId($htmlIdPrefix . $chooserId . 'control')->setClass('btn-chooser')->setLabel($buttons['open'])->setOnclick($htmlIdPrefix . $chooserId . '.choose();$$(\'.' . $hidden->getName() . '\')[0].id=\'\';$$(\'.data_type\')[0].id=\'' . $htmlIdPrefix . $chooserId . 'value\';');
     // ->setOnclick($htmlIdPrefix.$chooserId.'.choose();$$(\'.'.$hidden->getName().'\')[0].name=$$(\'.data_type\')[0].name;');
     // $chooser->setData('after_element_html', $hiddenHtml . $chooseButton->toHtml().$js);
     // render label and chooser scripts
     $configJson = Mage::helper('core')->jsonEncode($config->getData());
     return '<div id="' . $htmlIdPrefix . 'box_' . $chooserId . '">
         <label style="background-color: #EEE2BE; float: left; font-size: 15px; height: 21px; width: 46%; margin-right:3px; overflow:hidden;" class="widget-option-label" id="' . $htmlIdPrefix . $chooserId . 'label">' . ($this->getLabel() ? $this->getLabel() : Mage::helper('widget')->__('Not Selected')) . '</label>
         <div id="' . $htmlIdPrefix . $chooserId . 'advice-container" class="hidden"></div>
     ' . $hiddenHtml . $chooseButton->toHtml() . $js . '</div>';
 }
예제 #4
0
 /**
  * Return chooser HTML and init scripts
  *
  * @return string
  */
 protected function _toHtml()
 {
     if (is_null(Mage::registry('megamenu_adminhtml_widget_chooser'))) {
         return parent::_toHtml();
     }
     Mage::unregister('megamenu_adminhtml_widget_chooser');
     $element = $this->getElement();
     $htmlIdPrefix = $element->getForm()->getHtmlIdPrefix();
     $chooserId = $this->getUniqId();
     $admin = Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');
     $SourceUrl = str_replace("/megamenu/", "/{$admin}/", $this->getSourceUrl());
     $SourceUrl = str_replace("/uniq_id/", "/uniq_id/" . $htmlIdPrefix, $SourceUrl);
     $this->setSourceUrl($SourceUrl);
     $config = $this->getConfig();
     $hiddenHtml = '';
     if ($this->getHiddenEnabled()) {
         $hidden = new Varien_Data_Form_Element_Hidden($element->getData());
         $hidden->setId("{$chooserId}value")->setForm($element->getForm());
         if ($element->getRequired()) {
             $hidden->addClass('required-entry');
         }
         $hiddenHtml = $hidden->getElementHtml();
         $element->setValue('');
     }
     $configJson = Mage::helper('core')->jsonEncode($config->getData());
     $js = '
         <script type="text/javascript">
             ' . $htmlIdPrefix . $chooserId . ' = new WysiwygWidget.chooser("' . $htmlIdPrefix . $chooserId . '", "' . $this->getSourceUrl() . '", ' . $configJson . ');
         </script>
     ';
     $buttons = $config->getButtons();
     $chooseButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')->setId($htmlIdPrefix . $chooserId . 'control')->setClass('btn-chooser')->setLabel($buttons['open'])->setOnclick($htmlIdPrefix . $chooserId . '.choose();$$(\'.' . $hidden->getName() . '\')[0].id=\'\';$$(\'.data_type\')[0].id=\'' . $htmlIdPrefix . $chooserId . 'value\';');
     $configJson = Mage::helper('core')->jsonEncode($config->getData());
     return '<div id="' . $htmlIdPrefix . 'box_' . $chooserId . '">
         <label style="background-color: #EEE2BE; float: left; font-size: 15px; height: 21px; width: 46%; margin-right:3px; overflow:hidden;" class="widget-option-label" id="' . $htmlIdPrefix . $chooserId . 'label">' . ($this->getLabel() ? $this->getLabel() : Mage::helper('widget')->__('Not Selected')) . '</label>
         <div id="' . $htmlIdPrefix . $chooserId . 'advice-container" class="hidden"></div>
     ' . $hiddenHtml . $chooseButton->toHtml() . $js . '</div>';
 }