Mage_GoogleBase_Block_Adminhtml_Types_Edit_Form Class Reference

Inheritance diagram for Mage_GoogleBase_Block_Adminhtml_Types_Edit_Form:

Mage_Adminhtml_Block_Widget_Form Mage_Adminhtml_Block_Widget Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 getAttributeSetsSelectElement ($targetCountry)
 getItemTypesSelectElement ($targetCountry)
 getItemType ()
 getSaveUrl ()

Protected Member Functions

 _prepareForm ()
 _getCountriesArray ()
 _getAttributeSetsArray ($targetCountry)
 _getGbaseItemTypesArray ($targetCountry)


Detailed Description

Definition at line 35 of file Form.php.


Member Function Documentation

_getAttributeSetsArray ( targetCountry  )  [protected]

Definition at line 146 of file Form.php.

00147     {
00148         $entityType = Mage::getModel('catalog/product')->getResource()->getEntityType();
00149         $collection = Mage::getResourceModel('eav/entity_attribute_set_collection')
00150             ->setEntityTypeFilter($entityType->getId());
00151 
00152         $ids = array();
00153         $itemType = $this->getItemType();
00154         if ( !($itemType instanceof Varien_Object && $itemType->getId()) ) {
00155             $typesCollection = Mage::getResourceModel('googlebase/type_collection')
00156                 ->addCountryFilter($targetCountry)
00157                 ->load();
00158             foreach ($typesCollection as $type) {
00159                 $ids[] = $type->getAttributeSetId();
00160             }
00161         }
00162 
00163         $result = array('' => '');
00164         foreach ($collection as $attributeSet) {
00165             if (!in_array($attributeSet->getId(), $ids)) {
00166                 $result[$attributeSet->getId()] = $attributeSet->getAttributeSetName();
00167             }
00168         }
00169         return $result;
00170     }

_getCountriesArray (  )  [protected]

Definition at line 136 of file Form.php.

00137     {
00138         $_allowed = Mage::getSingleton('googlebase/config')->getAllowedCountries();
00139         $result = array();
00140         foreach ($_allowed as $iso => $info) {
00141             $result[$iso] = $info['name'];
00142         }
00143         return $result;
00144     }

_getGbaseItemTypesArray ( targetCountry  )  [protected]

Definition at line 172 of file Form.php.

00173     {
00174         $itemTypes = Mage::getModel('googlebase/service_feed')->getItemTypes($targetCountry);
00175         $result = array('' => '');
00176         foreach ($itemTypes as $type) {
00177             $result[$type->getId()] = $type->getName();
00178         }
00179         return $result;
00180     }

_prepareForm (  )  [protected]

Prepare form before rendering HTML

Returns:
Mage_Adminhtml_Block_Widget_Form

Reimplemented from Mage_Adminhtml_Block_Widget_Form.

Definition at line 37 of file Form.php.

00038     {
00039         $form = new Varien_Data_Form();
00040 
00041         $itemType = $this->getItemType();
00042 
00043         $fieldset = $form->addFieldset('base_fieldset', array(
00044             'legend'    => $this->__('Attribute Set and Item Type')
00045         ));
00046 
00047         if ( !($targetCountry = $itemType->getTargetCountry()) ) {
00048             $isoKeys = array_keys($this->_getCountriesArray());
00049             $targetCountry = isset($isoKeys[0]) ? $isoKeys[0] : null;
00050         }
00051         $countrySelect = $fieldset->addField('select_target_country', 'select', array(
00052             'label'     => $this->__('Target Country'),
00053             'title'     => $this->__('Target Country'),
00054             'name'      => 'target_country',
00055             'required'  => true,
00056             'options'   => $this->_getCountriesArray(),
00057             'value'     => $targetCountry,
00058         ));
00059         if ($itemType->getTargetCountry()) {
00060             $countrySelect->setDisabled(true);
00061         }
00062 
00063         $attributeSetsSelect = $this->getAttributeSetsSelectElement($targetCountry)->setValue($itemType->getAttributeSetId());
00064         if ($itemType->getAttributeSetId()) {
00065             $attributeSetsSelect->setDisabled(true);
00066         }
00067 
00068         $fieldset->addField('attribute_set', 'note', array(
00069             'label'     => $this->__('Attribute Set'),
00070             'title'     => $this->__('Attribute Set'),
00071             'required'  => true,
00072             'text'      => '<div id="attribute_set_select">' . $attributeSetsSelect->toHtml() . '</div>',
00073         ));
00074 
00075         $itemTypesSelect = $this->getItemTypesSelectElement($targetCountry)->setValue($itemType->getGbaseItemtype());
00076         if ($itemType->getGbaseItemtype()) {
00077             $itemTypesSelect->setDisabled(true);
00078         }
00079 
00080         $fieldset->addField('itemtype', 'note', array(
00081             'label'     => $this->__('Google Base Item Type'),
00082             'title'     => $this->__('Google Base Item Type'),
00083             'required'  => true,
00084             'text'      => '<div id="gbase_itemtype_select">' . $itemTypesSelect->toHtml() . '</div>',
00085         ));
00086 
00087         $attributesBlock = $this->getLayout()
00088             ->createBlock('googlebase/adminhtml_types_edit_attributes')
00089             ->setTargetCountry($targetCountry);
00090         if ($itemType->getId()) {
00091             $attributesBlock->setAttributeSetId($itemType->getAttributeSetId())
00092                 ->setGbaseItemtype($itemType->getGbaseItemtype())
00093                 ->setAttributeSetSelected(true);
00094         }
00095 
00096         $attributes = Mage::registry('attributes');
00097         if (is_array($attributes) && count($attributes) > 0) {
00098             $attributesBlock->setAttributesData($attributes);
00099         }
00100 
00101         $fieldset->addField('attributes_box', 'note', array(
00102             'label'     => $this->__('Attributes mapping'),
00103             'text'      => '<div id="attributes_details">' . $attributesBlock->toHtml() . '</div>',
00104         ));
00105 
00106         $form->addValues($itemType->getData());
00107         $form->setUseContainer(true);
00108         $form->setId('edit_form');
00109         $form->setMethod('post');
00110         $form->setAction($this->getSaveUrl());
00111         $this->setForm($form);
00112     }

getAttributeSetsSelectElement ( targetCountry  ) 

Definition at line 114 of file Form.php.

00115     {
00116         $field = new Varien_Data_Form_Element_Select();
00117         $field->setName('attribute_set_id')
00118             ->setId('select_attribute_set')
00119             ->setForm(new Varien_Data_Form())
00120             ->addClass('required-entry')
00121             ->setValues($this->_getAttributeSetsArray($targetCountry));
00122         return $field;
00123     }

getItemType (  ) 

Definition at line 182 of file Form.php.

00183     {
00184         return Mage::registry('current_item_type');
00185     }

getItemTypesSelectElement ( targetCountry  ) 

Definition at line 125 of file Form.php.

00126     {
00127         $field = new Varien_Data_Form_Element_Select();
00128         $field->setName('gbase_itemtype')
00129             ->setId('select_itemtype')
00130             ->setForm(new Varien_Data_Form())
00131             ->addClass('required-entry')
00132             ->setValues($this->_getGbaseItemTypesArray($targetCountry));
00133         return $field;
00134     }

getSaveUrl (  ) 

Definition at line 187 of file Form.php.

00188     {
00189         return $this->getUrl('*/*/save', array('type_id' => $this->getItemType()->getId()));
00190     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:14 2009 for Magento by  doxygen 1.5.8