Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_GoogleBase_Adminhtml_Googlebase_ItemsController
  • Mage_GoogleBase_Adminhtml_Googlebase_SelectionController
  • Mage_GoogleBase_Adminhtml_Googlebase_TypesController
  • Mage_GoogleBase_Block_Adminhtml_Captcha
  • Mage_GoogleBase_Block_Adminhtml_Items
  • Mage_GoogleBase_Block_Adminhtml_Items_Item
  • Mage_GoogleBase_Block_Adminhtml_Items_Product
  • Mage_GoogleBase_Block_Adminhtml_Store_Switcher
  • Mage_GoogleBase_Block_Adminhtml_Types
  • Mage_GoogleBase_Block_Adminhtml_Types_Edit
  • Mage_GoogleBase_Block_Adminhtml_Types_Edit_Attributes
  • Mage_GoogleBase_Block_Adminhtml_Types_Edit_Form
  • Mage_GoogleBase_Block_Adminhtml_Types_Grid
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_GoogleBase
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Attributes box for Google Base attributes mapping
 29:  *
 30:  * @category    Mage
 31:  * @package     Mage_GoogleBase
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_GoogleBase_Block_Adminhtml_Types_Edit_Attributes extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element
 35: {
 36:     public function __construct()
 37:     {
 38:         $this->setTemplate('googlebase/types/edit/attributes.phtml');
 39:     }
 40: 
 41:     protected function _prepareLayout()
 42:     {
 43:         $this->setChild('add_button',
 44:             $this->getLayout()->createBlock('adminhtml/widget_button')
 45:                 ->setData(array(
 46:                     'label' => Mage::helper('googlebase')->__('Add New Attribute'),
 47:                     'class' => 'add',
 48:                     'id'    => 'add_new_attribute',
 49:                     'on_click' => 'gBaseAttribute.add()'
 50:                 ))
 51:         );
 52:         $this->setChild('delete_button',
 53:             $this->getLayout()->createBlock('adminhtml/widget_button')
 54:                 ->setData(array(
 55:                     'label' => Mage::helper('googlebase')->__('Remove'),
 56:                     'class' => 'delete delete-product-option',
 57:                     'on_click' => 'gBaseAttribute.remove(event)'
 58:                 ))
 59:         );
 60: 
 61:         parent::_prepareLayout();
 62:     }
 63: 
 64:     public function getFieldId()
 65:     {
 66:         return 'gbase_attribute';
 67:     }
 68: 
 69:     public function getFieldName ()
 70:     {
 71:         return 'attributes';
 72:     }
 73: 
 74:     public function getGbaseAttributesSelectHtml()
 75:     {
 76:         $options = array('' => $this->__('Custom attribute, no mapping'));
 77: 
 78:         $attributes = Mage::getModel('googlebase/service_feed')
 79:             ->getAttributes($this->getGbaseItemtype(), $this->getTargetCountry());
 80:         foreach ($attributes as $attr) {
 81:             $options[$attr->getId()] = $attr->getName();
 82:         }
 83: 
 84:         $select = $this->getLayout()->createBlock('adminhtml/html_select')
 85:             ->setId($this->getFieldId() . '_{{index}}_gattribute')
 86:             ->setName($this->getFieldName() . '[{{index}}][gbase_attribute]')
 87:             ->setOptions($options);
 88:         return $select->getHtml();
 89:     }
 90: 
 91:     /**
 92:      * Build HTML select element of attribute set attributes
 93:      *
 94:      * @param boolean $escapeJsQuotes
 95:      * @return string
 96:      */
 97:     public function getAttributesSelectHtml($escapeJsQuotes = false)
 98:     {
 99:         $select = $this->getLayout()->createBlock('adminhtml/html_select')
100:             ->setId($this->getFieldId() . '_{{index}}_attribute')
101:             ->setName($this->getFieldName() . '[{{index}}][attribute_id]')
102:             ->setOptions($this->_getAttributes($this->getAttributeSetId(), $escapeJsQuotes));
103:         return $select->getHtml();
104:     }
105: 
106:     public function getAddButtonHtml()
107:     {
108:         return $this->getChildHtml('add_button');
109:     }
110: 
111:     public function getDeleteButtonHtml()
112:     {
113:         return $this->getChildHtml('delete_button');
114:     }
115: 
116:     /**
117:      * Get attributes of an attribute set
118:      * Skip attributes not needed for Google Base
119:      *
120:      * @param int $setId
121:      * @param boolean $escapeJsQuotes
122:      * @return array
123:      */
124:     public function _getAttributes($setId, $escapeJsQuotes = false)
125:     {
126:         $attributes = Mage::getModel('googlebase/attribute')->getAllowedAttributes($setId);
127:         $result = array();
128: 
129:         foreach ($attributes as $attribute) {
130:             /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
131:             $result[$attribute->getAttributeId()] = $escapeJsQuotes ? $this->jsQuoteEscape($attribute->getFrontendLabel()) : $attribute->getFrontendLabel();
132:         }
133:         return $result;
134:     }
135: 
136:     protected function _toJson($data)
137:     {
138:         return Mage::helper('core')->jsonEncode($data);
139:     }
140: }
141: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0