Example #1
0
 /**
  * Render required attributes
  * @param Varien_Data_Form_Element_Fieldset $fldAttr
  * @param Amasty_Banners_Model_Rule $model
  */
 protected function prepareAttributes($fldAttr, $model)
 {
     $hlp = Mage::helper('ambanners');
     /*
      * Add Empty Fields user for new conditions
      */
     $fieldSet = $this->getForm()->addFieldset('attributestmp', array('legend' => $hlp->__('Attribute Tmp')));
     $fieldSet->addField('attr_code[][]', 'select', array('label' => $hlp->__('Has attribute'), 'name' => 'attr_code[]', 'values' => $this->getAttributes(), 'onchange' => 'showOptions(this)'));
     $fieldSet->addField('attr_value[][]', 'text', array('label' => $hlp->__('Attribute value is'), 'name' => 'attr_value[]'));
     $array = $model->getAttributesAsArray();
     foreach ($array as $attributeCode => $attributeValue) {
         if (empty($attributeCode)) {
             continue;
         }
         if (is_array($attributeValue)) {
             foreach ($attributeValue as $i => $value) {
                 /*
                  * Add Attribute Names
                  */
                 $elementCode = $attributeCode . '-' . $value . '-' . $i;
                 $fldAttr->addField('attr_code[' . $elementCode . ']', 'select', array('label' => $hlp->__('Has attribute'), 'name' => 'attr_code[' . $elementCode . ']', 'values' => $this->getAttributes(), 'onchange' => 'showOptions(this)', 'value' => $attributeCode, 'note' => $hlp->__('If attribute is related to configurable products, please make sure that attribute is used in layered navigation'), 'after_element_html' => '<a href="#" onclick="landingRemove(this);return false;" title="' . $hlp->__('Remove') . '">' . $hlp->__('X') . '</a>'));
                 /*
                  * Add Attribute Options
                  */
                 $attribute = Mage::getModel('catalog/product')->getResource()->getAttribute($attributeCode);
                 if ('select' === $attribute->getFrontendInput() || 'multiselect' === $attribute->getFrontendInput()) {
                     $options = $attribute->getFrontend()->getSelectOptions();
                     $fldAttr->addField('attr_value[' . $elementCode . ']', 'select', array('label' => $hlp->__('Attribute value is'), 'name' => 'attr_value[' . $elementCode . ']', 'values' => $options, 'value' => $value));
                 } else {
                     $fldAttr->addField('attr_value[' . $elementCode . ']', 'text', array('label' => $hlp->__('Attribute value is'), 'name' => 'attr_value[' . $elementCode . ']', 'value' => $value));
                 }
             }
         }
     }
 }
Example #2
0
 /**
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param string $id
  * @param string $type
  * @param array $options
  * @return Varien_Data_Form_Element_Abstract
  */
 public function addField($fieldset, $id, $type, $options)
 {
     /** @noinspection PhpParamsInspection */
     $field = $fieldset->addField($id, $type, $options);
     if (isset($options['values'])) {
         $field->setValues($options['values']);
     }
     $field->setRenderer($this->getFieldRenderer());
     return $field;
 }
Example #3
0
 /**
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @return Varien_Data_Form_Element_Abstract
  */
 private function createFieldConditions(Varien_Data_Form_Element_Fieldset $fieldset)
 {
     /** @var Varien_Data_Form_Element_Abstract $result */
     $result = $fieldset->addField('conditions', 'text', array('name' => 'conditions', 'label' => Mage::helper('catalogrule')->__('Conditions'), 'title' => Mage::helper('catalogrule')->__('Conditions'), 'required' => true));
     /** @var Mage_Rule_Block_Conditions $blockRuleConditions */
     $blockRuleConditions = Mage::getBlockSingleton('rule/conditions');
     $result->setData('rule', $this->getRule());
     $result->setRenderer($blockRuleConditions);
     df_assert($result instanceof Varien_Data_Form_Element_Abstract);
     return $result;
 }
Example #4
0
 /**
  * This method makes life a little easier for us by pre-populating 
  * fields with $_POST data where applicable and wraps our post data in 
  * 'newsData' so we can easily separate all relevant information in
  * the controller. You can of course omit this method entirely and call
  * the $fieldset->addField() method directly.
  */
 protected function _addFieldsToFieldset(Varien_Data_Form_Element_Fieldset $fieldset, $fields)
 {
     $requestData = new Varien_Object($this->getRequest()->getPost('newsData'));
     foreach ($fields as $name => $_data) {
         if ($requestValue = $requestData->getData($name)) {
             $_data['value'] = $requestValue;
         }
         // wrap all fields with newsData group
         $_data['name'] = "newsData[{$name}]";
         // generally label and title always the same
         $_data['title'] = $_data['label'];
         // finally call vanilla functionality to add field
         $fieldset->addField($name, $_data['input'], $_data);
     }
     return $this;
 }
 /**
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param string $id
  * @param string $type
  * @param array $options
  * @return Varien_Data_Form_Element_Abstract
  */
 public function addField($fieldset, $id, $type, $options)
 {
     if (isset($options['renderer'])) {
         $renderer = $this->getLayout()->getBlockSingleton($options['renderer']);
         unset($options['renderer']);
     } else {
         $renderer = $this->getFieldRenderer();
     }
     /** @noinspection PhpParamsInspection */
     $field = $fieldset->addField($id, $type, $options);
     if (isset($options['values'])) {
         $field->setValues($options['values']);
     }
     $field->setRenderer($renderer);
     return $field;
 }
Example #6
0
 public function toHtml()
 {
     $model = $this->getModel();
     parent::__construct(array('legend' => __('URL Settings')));
     $this->addField('url_template', 'text', array('name' => 'properties[url_template]', 'label' => __('Url Template'), 'required' => true, 'value' => $model->getProperty('url_template'), 'note' => Mage::helper('searchindex/help')->field('url_template')));
     return parent::toHtml();
 }
Example #7
0
 public function toHtml()
 {
     $model = $this->getModel();
     parent::__construct(array('legend' => __('Additional')));
     $this->addField('ignore', 'multiselect', array('name' => 'properties[ignore]', 'label' => __('Ingnored Pages'), 'required' => false, 'value' => $model->getProperty('ignore'), 'values' => Mage::getSingleton('adminhtml/system_config_source_cms_page')->toOptionArray(), 'note' => Mage::helper('searchindex/help')->field('ignore')));
     return parent::toHtml();
 }
Example #8
0
 public function toHtml()
 {
     $html = parent::toHtml();
     if (!@class_exists('Extendware_EWCore_Model_Autoload')) {
         return $html;
     }
     $tips = $this->_getExtendwareTips($this, 'hover', array('opentip' => array('tipJoint' => 'top right')));
     if (empty($tips) === false) {
         $id = 'ew-' . Mage::helper('core')->getRandomString(8);
         $code = '<div class="ewcore-tooltip-fieldset-label" id="' . $id . '"></div>';
         $html = preg_replace('/<div\\s+?class="form-buttons">/s', '<div class="form-buttons">' . $code, $html);
         foreach ($tips as $tip) {
             if (array_key_exists('title', $tip) === false) {
                 $tip['title'] = (string) $this->getData('legend');
             }
             $scripts[] = $this->_getExtendwareTipJs('$("' . $id . '")', $tip);
         }
     }
     foreach ($this->getElements() as $element) {
         $rowHtml = $this->_extractRowHtml($element->getId(), $html);
         if (empty($rowHtml)) {
             continue;
         }
         $tips = $this->_getExtendwareTips($element, Mage::helper('ewcore/config')->getDefaultFormHelpTriggerMode());
         foreach ($tips as $tip) {
             if (array_key_exists('title', $tip) === false) {
                 $tip['title'] = (string) $element->getData('label');
             }
             if (strpos($tip['mode'], 'label') !== false or strpos($tip['mode'], 'both') !== false) {
                 if (preg_match('/<td\\s+?class="label">(.+?)<\\/td>/is', $rowHtml, $match)) {
                     $id = 'ew-' . Mage::helper('core')->getRandomString(8);
                     $classes = 'ewcore-tooltip-label ' . (strpos($tip['mode'], 'click') !== false ? 'ewcore-tooltip-label-clickable' : '');
                     $label = preg_replace('/<label([^>]*?)>(.*?)<\\/label>/si', '<label\\1><span id="' . $id . '" class="' . $classes . '">\\2</span></label>', $match[0]);
                     $html = str_replace($rowHtml, str_replace($match[0], $label, $rowHtml), $html);
                     $scripts[] = $this->_getExtendwareTipJs('$("' . $id . '")', $tip);
                 }
             }
             if (strpos($tip['mode'], 'input') !== false or strpos($tip['mode'], 'both') !== false) {
                 if (!preg_match('/<select\\s+/si', $rowHtml)) {
                     $scripts[] = $this->_getExtendwareTipJs('$("' . $element->getHtmlId() . '")', $tip);
                 }
             }
             if ($tip['mode'] == 'hover') {
                 $id = 'ew-' . Mage::helper('core')->getRandomString(8);
                 $newRowHtml = str_replace('<tr>', '<tr id="' . $id . '">', $rowHtml);
                 $html = str_replace($rowHtml, $newRowHtml, $html);
                 $scripts[] = $this->_getExtendwareTipJs('$("' . $id . '")', $tip);
             }
         }
     }
     if (empty($scripts) === false) {
         $html .= '<script type="text/javascript">try{';
         foreach ($scripts as $script) {
             $html .= $script . "\n";
         }
         $html .= '} catch(e) {}</script>';
     }
     return $html;
 }
Example #9
0
 protected function _addFieldsToFieldset(Varien_Data_Form_Element_Fieldset $fieldset, $fields)
 {
     $requestData = new Varien_Object($this->getRequest()->getPost('accordionData'));
     foreach ($fields as $name => $_data) {
         if ($requestValue = $requestData->getData($name)) {
             $_data['value'] = $requestValue;
         }
         # code...
         $_data['name'] = "accordionData[{$name}]";
         $_data['title'] = $_data['label'];
         if (!array_key_exists('value', $_data)) {
             $_data['value'] = $this->_getAccordion()->getData($name);
         }
         $fieldset->addField($name, $_data['input'], $_data);
     }
     return $this;
 }
Example #10
0
 public function toHtml()
 {
     $model = $this->getModel();
     parent::__construct(array('legend' => __('Database Settings')));
     $this->addField('db_connection_name', 'text', array('name' => 'properties[db_connection_name]', 'label' => __('Database Connection Name'), 'required' => true, 'value' => $model->getProperty('db_connection_name') ? $model->getProperty('db_connection_name') : 'default_setup', 'note' => Mage::helper('searchindex/help')->field('db_connection_name')));
     $this->addField('db_table_prefix', 'text', array('name' => 'properties[db_table_prefix]', 'label' => __('Table Prefix'), 'required' => false, 'value' => $model->getProperty('db_table_prefix'), 'note' => Mage::helper('searchindex/help')->field('db_table_prefix')));
     return parent::toHtml();
 }
 public function toHtml()
 {
     $model = $this->getModel();
     if (!Mage::app()->isSingleStoreMode()) {
         parent::__construct(array('legend' => Mage::helper('searchindex')->__('Store Settings')));
         $this->addField('store_id', 'multiselect', array('label' => Mage::helper('searchindex')->__('Store View'), 'required' => true, 'name' => 'properties[store_id]', 'value' => $model->getProperty('store_id'), 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm()));
     }
     return parent::toHtml();
 }
Example #12
0
 /**
  * @param Aitoc_Aitsys_Model_Module $module
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  */
 protected function _addModule(Aitoc_Aitsys_Model_Module $module, Varien_Data_Form_Element_Fieldset $fieldset)
 {
     if ($module->isIgnore()) {
         return false;
     }
     $aModule = $module;
     $label = $module->getInfo()->getLabel() . ($module->getInfo()->getVersion() ? ' v' . $module->getInfo()->getVersion() : '');
     $message = '';
     $messageType = 'notice-msg';
     $isDemo = false;
     if ($this->tool()->platform()->hasDemoMode()) {
         $xml = simplexml_load_file(Mage::getBaseDir() . "/aitmodules.xml");
         $link = (string) $xml->modules->{$aModule}['key'];
         if ($link == '') {
             $link = $this->tool()->getAitocUrl();
         }
         $message = Mage::helper('aitsys')->__("The extension is already enabled on this Demo Magento installation and can't be disabled for security reasons. Please proceed to the next step outlined in the extension's <a href='%s' target='_blank'>User Manual</a> to see how it works.", $link);
         $isDemo = true;
     } elseif (defined('COMPILER_INCLUDE_PATH')) {
         $compilerUrl = version_compare(Mage::getVersion(), '1.5.0.0', '>=') ? Mage::helper('adminhtml')->getUrl('adminhtml/compiler_process/index/') : Mage::helper('adminhtml')->getUrl('compiler/process/index/');
         $message = Mage::helper('aitsys')->__('Before activating or deactivating the extension please turn off the compiler at <br /><a href="%s">System > Tools > Compilation</a>', $compilerUrl);
         $messageType = 'warning-msg';
     } elseif (!$module->getInfo()->isMagentoCompatible()) {
         $message = Mage::helper('aitsys/strings')->getString('ER_ENT_HASH');
     } elseif (!$module->getAccess()) {
         $message = Mage::helper('aitsys')->__('File does not have write permissions: %s', $aModule['file']);
         $messageType = 'error-msg';
     }
     if ($module->getInfo()->getSerial()) {
         $info = 'S/N: ' . $module->getInfo()->getSerial();
     }
     if ($aModule['key'] == 'Aitoc_Common') {
         $info = 'Used by other AITOC\'s modules. Do not disable.';
     }
     if ($message && $messageType != 'notice-msg' || $isDemo) {
         $field = $fieldset->addField('ignore_' . $aModule['key'], 'note', array('name' => 'ignore[' . $aModule['key'] . ']', 'label' => $label, 'info' => empty($info) ? '' : $info, 'note' => '<ul class="messages"><li class="' . $messageType . '"><ul><li>' . $message . '</li></ul></li></ul>', 'module' => $module));
         if (!$isDemo) {
             $field->setRenderer($this->_elementRenderer);
         }
         return;
     }
     $fieldset->addField('hidden_enable_' . $aModule['key'], 'hidden', array('name' => 'enable[' . $aModule['key'] . ']', 'value' => 0));
     $fieldset->addField('enable_' . $aModule['key'], 'checkbox', array('name' => ($module->getAccess() ? 'enable' : 'ignore') . '[' . $aModule['key'] . ']', 'label' => $label, 'value' => 1, 'checked' => $aModule['value'], 'note' => $message ? '<ul class="messages"><li class="' . $messageType . '"><ul><li>' . $message . '</li></ul></li></ul>' : '', 'info' => empty($info) ? '' : $info, 'module' => $module))->setRenderer($this->_elementRenderer);
 }
Example #13
0
 /**
  * Populate form fieldset with group data
  *
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  */
 public function populateFieldset(Varien_Data_Form_Element_Fieldset $fieldset)
 {
     $originalData = array();
     foreach ($this->_data as $key => $value) {
         if (!is_array($value)) {
             $originalData[$key] = $value;
         }
     }
     $fieldset->setOriginalData($originalData);
 }
Example #14
0
 /**
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param string $id
  * @param string $status
  * @return string
  */
 protected function _getFieldHtml($fieldset, $id, $status)
 {
     $configData = $this->getConfigData();
     $path = 'sales/order_statuses/status_' . $id;
     //TODO: move as property of form
     $data = isset($configData[$path]) ? $configData[$path] : array();
     $e = $this->_getDummyElement();
     $field = $fieldset->addField($id, 'text', array('name' => 'groups[order_statuses][fields][status_' . $id . '][value]', 'label' => $status, 'value' => isset($data['value']) ? $data['value'] : $status, 'default_value' => isset($data['default_value']) ? $data['default_value'] : '', 'old_value' => isset($data['old_value']) ? $data['old_value'] : '', 'inherit' => isset($data['inherit']) ? $data['inherit'] : '', 'can_use_default_value' => $this->getForm()->canUseDefaultValue($e), 'can_use_website_value' => $this->getForm()->canUseWebsiteValue($e)))->setRenderer($this->_getFieldRenderer());
     return $field->toHtml();
 }
Example #15
0
 /**
  * This method makes life a little easier for us by pre-populating
  * fields with $_POST data where applicable and wrapping our post data
  * in 'brandData' so that we can easily separate all relevant information
  * in the controller. You could of course omit this method entirely
  * and call the $fieldset->addField() method directly.
  * @return self
  */
 protected function _addFieldsToFieldset(Varien_Data_Form_Element_Fieldset $fieldset, $fields)
 {
     foreach ($fields as $name => $_data) {
         // Wrap all fields with brandData group.
         $_data['name'] = "configData[{$name}]";
         // Generally, label and title are always the same.
         $_data['title'] = $_data['label'];
         // If no new value exists, use the existing data.
         if (!array_key_exists('value', $_data)) {
             $_data['value'] = $this->_getValue()->getData($name);
         }
         if ($name == "test_mode") {
             $_data['checked'] = $this->_getValue()->getData($name);
         }
         // Finally, call vanilla functionality to add field.
         $fieldset->addField($name, $_data['input'], $_data);
     }
     return $this;
 }
Example #16
0
 /**
  * This method makes life a little easier for us by pre-populating 
  * fields with $_POST data where applicable and wraps our post data in 
  * 'brandData' so we can easily separate all relevant information in
  * the controller. You can of course omit this method entirely and call
  * the $fieldset->addField() method directly.
  */
 protected function _addFieldsToFieldset(Varien_Data_Form_Element_Fieldset $fieldset, $fields)
 {
     $requestData = new Varien_Object($this->getRequest()->getPost('mappingData'));
     foreach ($fields as $name => $_data) {
         if ($requestValue = $requestData->getData($name)) {
             $_data['value'] = $requestValue;
         }
         // wrap all fields with brandData group
         $_data['name'] = "mappingData[{$name}]";
         // generally label and title always the same
         $_data['title'] = $_data['label'];
         // if no new value exists, use existing brand data
         if (!array_key_exists('value', $_data)) {
             $_data['value'] = $this->_getBrand()->getData($name);
         }
         // finally call vanilla functionality to add field
         $fieldset->addField($name, $_data['input'], $_data);
     }
     return $this;
 }
Example #17
0
 /**
  * This method makes life a little easier for us by pre-populating
  * fields with $_POST data where applicable and wrapping our post data
  * in 'commentData' so that we can easily separate all relevant information
  * in the controller. You could of course omit this method entirely
  * and call the $fieldset->addField() method directly.
  */
 protected function _addFieldsToFieldset(Varien_Data_Form_Element_Fieldset $fieldset, $fields)
 {
     $requestData = new Varien_Object($this->getRequest()->getPost('commentData'));
     foreach ($fields as $name => $_data) {
         if ($requestValue = $requestData->getData($name)) {
             $_data['value'] = $requestValue;
         }
         // Wrap all fields with commentData group.
         $_data['name'] = "commentData[{$name}]";
         // Generally, label and title are always the same.
         $_data['title'] = $_data['label'];
         // If no new value exists, use the existing comment data.
         if (!array_key_exists('value', $_data)) {
             $_data['value'] = $this->_getComment()->getData($name);
         }
         // Finally, call vanilla functionality to add field.
         $fieldset->addField($name, $_data['input'], $_data);
     }
     return $this;
 }
Example #18
0
 public function toHtml()
 {
     $model = $this->getModel();
     parent::__construct(array('legend' => __('Additional Search Index Configuration')));
     $this->addField('include_category', 'select', array('name' => 'properties[include_category]', 'label' => __('Search by parent categories names'), 'required' => true, 'value' => $model->getProperty('include_category'), 'values' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray(), 'note' => Mage::helper('searchindex/help')->field('include_category')));
     $this->addField('include_bundled', 'select', array('name' => 'properties[include_bundled]', 'label' => __('Search by child products attributes (for bundle and configurable products)'), 'required' => true, 'value' => $model->getProperty('include_bundled'), 'values' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray(), 'note' => Mage::helper('searchindex/help')->field('include_bundled')));
     $this->addField('include_tag', 'select', array('name' => 'properties[include_tag]', 'label' => __('Search by product tags'), 'required' => true, 'value' => $model->getProperty('include_tag'), 'values' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray(), 'note' => Mage::helper('searchindex/help')->field('include_tag')));
     $this->addField('include_id', 'select', array('name' => 'properties[include_id]', 'label' => __('Search by product id'), 'required' => true, 'value' => $model->getProperty('include_id'), 'values' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray(), 'note' => Mage::helper('searchindex/help')->field('include_id')));
     $this->addField('out_of_stock_to_end', 'select', array('name' => 'properties[out_of_stock_to_end]', 'label' => __('Push "out of stock" products to the end'), 'required' => false, 'value' => $model->getProperty('out_of_stock_to_end'), 'values' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray(), 'note' => Mage::helper('searchindex/help')->field('out_of_stock_to_end')));
     return parent::toHtml();
 }
 public function toHtml()
 {
     $model = $this->getModel();
     parent::__construct(array('legend' => __('Attribute')));
     $attributes = Mage::getSingleton('eav/config')->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getAttributeCollection();
     $values = array();
     foreach ($attributes as $attr) {
         if (in_array($attr->getData('frontend_input'), array('select', 'multiselect'))) {
             $values[$attr->getAttributeCode()] = $attr->getFrontendLabel() . ' [' . $attr->getAttributeCode() . ']';
         }
     }
     $this->addField('attribute', 'select', array('name' => 'properties[attribute]', 'label' => __('Attribute'), 'required' => true, 'value' => $model->getProperty('attribute'), 'values' => $values));
     $this->addField('url_template', 'text', array('name' => 'properties[url_template]', 'label' => __('Url Template'), 'required' => true, 'value' => $model->getProperty('url_template')));
     return parent::toHtml();
 }
Example #20
0
 /**
  * Prepare form fieldset
  * All fields are visible
  *
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  *
  * @return Mage_Adminhtml_Block_Sales_Order_Create_Giftmessage_Form
  */
 protected function _prepareVisibleFields(Varien_Data_Form_Element_Fieldset $fieldset)
 {
     $fieldset->addField('sender', 'text', array('name' => $this->_getFieldName('sender'), 'label' => Mage::helper('sales')->__('From'), 'required' => $this->getMessage()->getMessage() ? true : false));
     $fieldset->addField('recipient', 'text', array('name' => $this->_getFieldName('recipient'), 'label' => Mage::helper('sales')->__('To'), 'required' => $this->getMessage()->getMessage() ? true : false));
     $fieldset->addField('message', 'textarea', array('name' => $this->_getFieldName('message'), 'label' => Mage::helper('sales')->__('Message'), 'rows' => '5', 'cols' => '20'));
     return $this;
 }
Example #21
0
 /**
  * Init fieldset fields
  *
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param Varien_Simplexml_Element $group
  * @param Varien_Simplexml_Element $section
  * @param string $fieldPrefix
  * @param string $labelPrefix
  * @return Mage_Adminhtml_Block_System_Config_Form
  */
 public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = '')
 {
     if (!$this->_configDataObject) {
         $this->_initObjects();
     }
     // Extends for config data
     $configDataAdditionalGroups = array();
     foreach ($group->fields as $elements) {
         $elements = (array) $elements;
         // sort either by sort_order or by child node values bypassing the sort_order
         if ($group->sort_fields && $group->sort_fields->by) {
             $fieldset->setSortElementsByAttribute((string) $group->sort_fields->by, $group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC);
         } else {
             usort($elements, array($this, '_sortForm'));
         }
         foreach ($elements as $element) {
             if (!$this->_canShowField($element)) {
                 continue;
             }
             if ((string) $element->getAttribute('type') == 'group') {
                 $this->_initGroup($fieldset->getForm(), $element, $section, $fieldset);
                 continue;
             }
             /**
              * Look for custom defined field path
              */
             $path = (string) $element->config_path;
             if (empty($path)) {
                 $path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $element->getName();
             } elseif (strrpos($path, '/') > 0) {
                 // Extend config data with new section group
                 $groupPath = substr($path, 0, strrpos($path, '/'));
                 if (!isset($configDataAdditionalGroups[$groupPath])) {
                     $this->_configData = $this->_configDataObject->extendConfig($groupPath, false, $this->_configData);
                     $configDataAdditionalGroups[$groupPath] = true;
                 }
             }
             $data = $this->_configDataObject->getConfigDataValue($path, $inherit, $this->_configData);
             if ($element->frontend_model) {
                 $fieldRenderer = Mage::getBlockSingleton((string) $element->frontend_model);
             } else {
                 $fieldRenderer = $this->_defaultFieldRenderer;
             }
             $fieldRenderer->setForm($this);
             $fieldRenderer->setConfigData($this->_configData);
             $helperName = $this->_configFields->getAttributeModule($section, $group, $element);
             $fieldType = (string) $element->frontend_type ? (string) $element->frontend_type : 'text';
             $name = 'groups[' . $group->getName() . '][fields][' . $fieldPrefix . $element->getName() . '][value]';
             $label = Mage::helper($helperName)->__($labelPrefix) . ' ' . Mage::helper($helperName)->__((string) $element->label);
             $hint = (string) $element->hint ? Mage::helper($helperName)->__((string) $element->hint) : '';
             if ($element->backend_model) {
                 $model = Mage::getModel((string) $element->backend_model);
                 if (!$model instanceof Mage_Core_Model_Config_Data) {
                     Mage::throwException('Invalid config field backend model: ' . (string) $element->backend_model);
                 }
                 $model->setPath($path)->setValue($data)->setWebsite($this->getWebsiteCode())->setStore($this->getStoreCode())->afterLoad();
                 $data = $model->getValue();
             }
             $comment = $this->_prepareFieldComment($element, $helperName, $data);
             $tooltip = $this->_prepareFieldTooltip($element, $helperName);
             $id = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $element->getName();
             if ($element->depends) {
                 foreach ($element->depends->children() as $dependent) {
                     /* @var $dependent Mage_Core_Model_Config_Element */
                     if (isset($dependent->fieldset)) {
                         $dependentFieldGroupName = (string) $dependent->fieldset;
                         if (!isset($this->_fieldsets[$dependentFieldGroupName])) {
                             $dependentFieldGroupName = $group->getName();
                         }
                     } else {
                         $dependentFieldGroupName = $group->getName();
                     }
                     $dependentFieldNameValue = $dependent->getName();
                     $dependentFieldGroup = $dependentFieldGroupName == $group->getName() ? $group : $this->_fieldsets[$dependentFieldGroupName]->getGroup();
                     $dependentId = $section->getName() . '_' . $dependentFieldGroupName . '_' . $fieldPrefix . $dependentFieldNameValue;
                     $shouldBeAddedDependence = true;
                     $dependentValue = (string) (isset($dependent->value) ? $dependent->value : $dependent);
                     if (isset($dependent['separator'])) {
                         $dependentValue = explode((string) $dependent['separator'], $dependentValue);
                     }
                     $dependentFieldName = $fieldPrefix . $dependent->getName();
                     $dependentField = $dependentFieldGroup->fields->{$dependentFieldName};
                     /*
                      * If dependent field can't be shown in current scope and real dependent config value
                      * is not equal to preferred one, then hide dependence fields by adding dependence
                      * based on not shown field (not rendered field)
                      */
                     if (!$this->_canShowField($dependentField)) {
                         $dependentFullPath = $section->getName() . '/' . $dependentFieldGroupName . '/' . $fieldPrefix . $dependent->getName();
                         $dependentValueInStore = Mage::getStoreConfig($dependentFullPath, $this->getStoreCode());
                         if (is_array($dependentValue)) {
                             $shouldBeAddedDependence = !in_array($dependentValueInStore, $dependentValue);
                         } else {
                             $shouldBeAddedDependence = $dependentValue != $dependentValueInStore;
                         }
                     }
                     if ($shouldBeAddedDependence) {
                         $this->_getDependence()->addFieldMap($id, $id)->addFieldMap($dependentId, $dependentId)->addFieldDependence($id, $dependentId, $dependentValue);
                     }
                 }
             }
             $sharedClass = '';
             if ($element->shared && $element->config_path) {
                 $sharedClass = ' shared shared-' . str_replace('/', '-', $element->config_path);
             }
             $requiresClass = '';
             if ($element->requires) {
                 $requiresClass = ' requires';
                 foreach (explode(',', $element->requires) as $groupName) {
                     $requiresClass .= ' requires-' . $section->getName() . '_' . $groupName;
                 }
             }
             $field = $fieldset->addField($id, $fieldType, array('name' => $name, 'label' => $label, 'comment' => $comment, 'tooltip' => $tooltip, 'hint' => $hint, 'value' => $data, 'inherit' => $inherit, 'class' => $element->frontend_class . $sharedClass . $requiresClass, 'field_config' => $element, 'scope' => $this->getScope(), 'scope_id' => $this->getScopeId(), 'scope_label' => $this->getScopeLabel($element), 'can_use_default_value' => $this->canUseDefaultValue((int) $element->show_in_default), 'can_use_website_value' => $this->canUseWebsiteValue((int) $element->show_in_website)));
             $this->_prepareFieldOriginalData($field, $element);
             if (isset($element->validate)) {
                 $field->addClass($element->validate);
             }
             if (isset($element->frontend_type) && 'multiselect' === (string) $element->frontend_type && isset($element->can_be_empty)) {
                 $field->setCanBeEmpty(true);
             }
             $field->setRenderer($fieldRenderer);
             if ($element->source_model) {
                 // determine callback for the source model
                 $factoryName = (string) $element->source_model;
                 $method = false;
                 if (preg_match('/^([^:]+?)::([^:]+?)$/', $factoryName, $matches)) {
                     array_shift($matches);
                     list($factoryName, $method) = array_values($matches);
                 }
                 $sourceModel = Mage::getSingleton($factoryName);
                 if ($sourceModel instanceof Varien_Object) {
                     $sourceModel->setPath($path);
                 }
                 if ($method) {
                     if ($fieldType == 'multiselect') {
                         $optionArray = $sourceModel->{$method}();
                     } else {
                         $optionArray = array();
                         foreach ($sourceModel->{$method}() as $value => $label) {
                             $optionArray[] = array('label' => $label, 'value' => $value);
                         }
                     }
                 } else {
                     $optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
                 }
                 $field->setValues($optionArray);
             }
         }
     }
     return $this;
 }
Example #22
0
 protected function _addEditableSelectField(Varien_Data_Form_Element_Fieldset $fieldset, $field, $name, array $options, $required = true)
 {
     $helper = $this->getAction()->getModuleHelper();
     $fieldset->addField($field, 'select', array('name' => $this->_getFormElementName($field), 'label' => $helper->__($name), 'title' => $helper->__($name), 'value' => $this->_getValueIfObjectIsSet($field), 'values' => $options, 'required' => $required));
 }
Example #23
0
 /**
  * Add a field to the form or fieldset
  * Form and fieldset have same abstract
  *
  * @param Varien_Data_Form|Varien_Data_Form_Element_Fieldset $formOrFieldset
  * @param string $elementName
  * @param array $options
  * @param string $type
  * @return Varien_Data_Form_Element_Abstract
  */
 protected function _addField($formOrFieldset, $elementName, $options = array(), $type = 'text')
 {
     $options = array_merge($options, array('name' => $elementName, 'label' => $this->_profile->getFieldLabel($elementName), 'note' => $this->_profile->getFieldComment($elementName), 'disabled' => $this->_isReadOnly));
     if (in_array($elementName, array('period_unit', 'period_frequency'))) {
         $options['required'] = true;
     }
     return $formOrFieldset->addField($elementName, $type, $options);
 }
Example #24
0
 /**
  * Add image uploader to fieldset
  *
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param string $fieldName
  * @param string $title
  * @param string $note
  * @param string $default
  * @param boolean $required 
  */
 public function addImage($fieldset, $fieldName, $title, $note = '', $default = '', $required = false)
 {
     $fieldset->addField($fieldName, 'image', array('name' => $fieldName, 'label' => $title, 'note' => !empty($note) ? $note : null, 'required' => $required));
 }
Example #25
0
 /**
  * Add font selector to fieldset
  *
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param string $fieldPrefix
  * @param string $title
  */
 public function addFont($fieldset, $fieldPrefix, $title)
 {
     $element = $fieldset->addField($fieldPrefix, 'font', array('name' => $fieldPrefix, 'label' => $title));
     $element->initFields(array('name' => $fieldPrefix, 'fontNames' => Mage::helper('xmlconnect')->getDeviceHelper()->getFontList(), 'fontSizes' => Mage::helper('xmlconnect')->getDeviceHelper()->getFontSizes()));
 }
Example #26
0
 /**
  * Init fieldset fields
  *
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param Varien_Simplexml_Element $group
  * @param Varien_Simplexml_Element $section
  * @param string $fieldPrefix
  * @param string $labelPrefix
  * @return Mage_Adminhtml_Block_System_Config_Form
  */
 public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = '')
 {
     foreach ($group->fields as $elements) {
         $elements = (array) $elements;
         // sort either by sort_order or by child node values bypassing the sort_order
         if ($group->sort_fields && $group->sort_fields->by) {
             $fieldset->setSortElementsByAttribute((string) $group->sort_fields->by, $group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC);
         } else {
             usort($elements, array($this, '_sortForm'));
         }
         foreach ($elements as $e) {
             if (!$this->_canShowField($e)) {
                 continue;
             }
             $path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $e->getName();
             $id = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $e->getName();
             if (isset($this->_configData[$path])) {
                 $data = $this->_configData[$path];
                 $inherit = false;
             } else {
                 $data = $this->_configRoot->descend($path);
                 $inherit = true;
             }
             if ($e->frontend_model) {
                 $fieldRenderer = Mage::getBlockSingleton((string) $e->frontend_model);
             } else {
                 $fieldRenderer = $this->_defaultFieldRenderer;
             }
             $fieldRenderer->setForm($this);
             $fieldRenderer->setConfigData($this->_configData);
             $helperName = $this->_configFields->getAttributeModule($section, $group, $e);
             $fieldType = (string) $e->frontend_type ? (string) $e->frontend_type : 'text';
             $name = 'groups[' . $group->getName() . '][fields][' . $fieldPrefix . $e->getName() . '][value]';
             $label = Mage::helper($helperName)->__($labelPrefix) . ' ' . Mage::helper($helperName)->__((string) $e->label);
             $comment = (string) $e->comment ? Mage::helper($helperName)->__((string) $e->comment) : '';
             if ($e->backend_model) {
                 $model = Mage::getModel((string) $e->backend_model);
                 if (!$model instanceof Mage_Core_Model_Config_Data) {
                     Mage::throwException('Invalid config field backend model: ' . (string) $e->backend_model);
                 }
                 $model->setPath($path)->setValue($data)->afterLoad();
                 $data = $model->getValue();
             }
             $field = $fieldset->addField($id, $fieldType, array('name' => $name, 'label' => $label, 'comment' => $comment, 'value' => $data, 'inherit' => $inherit, 'class' => $e->frontend_class, 'field_config' => $e, 'scope' => $this->getScope(), 'scope_id' => $this->getScopeId(), 'can_use_default_value' => $this->canUseDefaultValue((int) $e->show_in_default), 'can_use_website_value' => $this->canUseWebsiteValue((int) $e->show_in_website)));
             if (isset($e->validate)) {
                 $field->addClass($e->validate);
             }
             if (isset($e->frontend_type) && 'multiselect' === (string) $e->frontend_type && isset($e->can_be_empty)) {
                 $field->setCanBeEmpty(true);
             }
             $field->setRenderer($fieldRenderer);
             if ($e->source_model) {
                 $sourceModel = Mage::getSingleton((string) $e->source_model);
                 if ($sourceModel instanceof Varien_Object) {
                     $sourceModel->setPath($path);
                 }
                 $field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
             }
         }
     }
     return $this;
 }
Example #27
0
 /**
  * Add password creation fields in new user form
  *
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  */
 protected function _addNewUserPasswordFields(Varien_Data_Form_Element_Fieldset $fieldset)
 {
     $fieldset->addField('password', 'password', array('name' => 'password', 'label' => Mage::helper('Mage_User_Helper_Data')->__('Password'), 'id' => 'customer_pass', 'title' => Mage::helper('Mage_User_Helper_Data')->__('Password'), 'class' => 'input-text required-entry validate-admin-password', 'required' => true));
     $fieldset->addField('confirmation', 'password', array('name' => 'password_confirmation', 'label' => Mage::helper('Mage_User_Helper_Data')->__('Password Confirmation'), 'id' => 'confirmation', 'title' => Mage::helper('Mage_User_Helper_Data')->__('Password Confirmation'), 'class' => 'input-text required-entry validate-cpassword', 'required' => true));
 }
Example #28
0
 /**
  * Prepare store element
  *
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  */
 protected function _prepareStoreElement($fieldset)
 {
     // get store switcher or a hidden field with it's id
     if (Mage::app()->isSingleStoreMode()) {
         $fieldset->addField('store_id', 'hidden', array('name' => 'store_id', 'value' => Mage::app()->getStore(true)->getId()), 'id_path');
     } else {
         /** @var $renderer Mage_Adminhtml_Block_Store_Switcher_Form_Renderer_Fieldset_Element */
         $renderer = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Store_Switcher_Form_Renderer_Fieldset_Element');
         $storeElement = $fieldset->addField('store_id', 'select', array('label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Store'), 'title' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Store'), 'name' => 'store_id', 'required' => true, 'values' => $this->_getRestrictedStoresList(), 'disabled' => $this->_getModel()->getIsSystem(), 'value' => $this->_formValues['store_id']), 'id_path');
         $storeElement->setRenderer($renderer);
     }
 }
Example #29
0
 /**
  * Add page input to fieldset
  *
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param string $fieldPrefix
  */
 protected function _addPage($fieldset, $fieldPrefix)
 {
     $element = $fieldset->addField($fieldPrefix, 'page', array('name' => $fieldPrefix));
     $element->initFields(array('name' => $fieldPrefix, 'values' => $this->_pages));
 }
Example #30
0
 /**
  * Enter description here...
  *
  * @param string $elementId
  * @param unknown_type $config
  * @param unknown_type $after
  * @return Varien_Data_Form_Element_Fieldset
  */
 public function addFieldset($elementId, $config, $after = false)
 {
     $element = new Varien_Data_Form_Element_Fieldset($config);
     $element->setId($elementId);
     $this->addElement($element, $after);
     return $element;
 }