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:  * GoogleBase Admin Item Types Controller
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_GoogleBase
 32:  * @name       Mage_GoogleBase_Adminhtml_Googlebase_TypesController
 33:  * @author     Magento Core Team <core@magentocommerce.com>
 34: */
 35: class Mage_GoogleBase_Adminhtml_Googlebase_TypesController extends Mage_Adminhtml_Controller_Action
 36: {
 37:     /**
 38:      * Dispatches controller_action_postdispatch_adminhtml Event (as not Adminhtml router)
 39:      */
 40:     public function postDispatch()
 41:     {
 42:         parent::postDispatch();
 43:         if ($this->getFlag('', self::FLAG_NO_POST_DISPATCH)) {
 44:             return;
 45:         }
 46:         Mage::dispatchEvent('controller_action_postdispatch_adminhtml', array('controller_action' => $this));
 47:     }
 48: 
 49:     protected function _initItemType()
 50:     {
 51:         $this->_title($this->__('Catalog'))
 52:              ->_title($this->__('Google Base'))
 53:              ->_title($this->__('Manage Attributes'));
 54: 
 55:         Mage::register('current_item_type', Mage::getModel('googlebase/type'));
 56:         $typeId = $this->getRequest()->getParam('id');
 57:         if (!is_null($typeId)) {
 58:             Mage::registry('current_item_type')->load($typeId);
 59:         }
 60:     }
 61: 
 62:     protected function _initAction()
 63:     {
 64:         $this->loadLayout()
 65:             ->_setActiveMenu('catalog/googlebase/types')
 66:             ->_addBreadcrumb(Mage::helper('adminhtml')->__('Catalog'), Mage::helper('adminhtml')->__('Catalog'))
 67:             ->_addBreadcrumb(Mage::helper('adminhtml')->__('Google Base'), Mage::helper('adminhtml')->__('Google Base'));
 68:         return $this;
 69:     }
 70: 
 71:     public function indexAction()
 72:     {
 73:         $this->_title($this->__('Catalog'))
 74:              ->_title($this->__('Google base'))
 75:              ->_title($this->__('Manage Attributes'));
 76: 
 77:         $this->_initAction()
 78:             ->_addBreadcrumb(Mage::helper('googlebase')->__('Item Types'), Mage::helper('googlebase')->__('Item Types'))
 79:             ->_addContent($this->getLayout()->createBlock('googlebase/adminhtml_types'))
 80:             ->renderLayout();
 81:     }
 82: 
 83:     /**
 84:      * Grid for AJAX request
 85:      */
 86:     public function gridAction()
 87:     {
 88:         $this->getResponse()->setBody(
 89:             $this->getLayout()->createBlock('googlebase/adminhtml_types_grid')->toHtml()
 90:         );
 91:     }
 92: 
 93:     public function newAction()
 94:     {
 95:         try {
 96:             $this->_initItemType();
 97: 
 98:             $this->_title($this->__('New ItemType'));
 99: 
100:             $this->_initAction()
101:                 ->_addBreadcrumb(Mage::helper('googlebase')->__('New Item Type'), Mage::helper('adminhtml')->__('New Item Type'))
102:                 ->_addContent($this->getLayout()->createBlock('googlebase/adminhtml_types_edit'))
103:                 ->renderLayout();
104:         } catch (Exception $e) {
105:             $this->_getSession()->addError($e->getMessage());
106:             $this->_redirect('*/*/index', array('store' => $this->_getStore()->getId()));
107:         }
108:     }
109: 
110:     public function editAction()
111:     {
112:         $this->_title($this->__('Catalog'))
113:              ->_title($this->__('Google base'))
114:              ->_title($this->__('Manage Attributes'));
115: 
116:         $id = $this->getRequest()->getParam('id');
117:         $model = Mage::getModel('googlebase/type');
118: 
119:         try {
120:             $result = array();
121:             if ($id) {
122:                 $model->load($id);
123:                 $collection = Mage::getResourceModel('googlebase/attribute_collection')
124:                     ->addTypeFilter($model->getTypeId())
125:                     ->load();
126:                 foreach ($collection as $attribute) {
127:                     $result[] = $attribute->getData();
128:                 }
129:             }
130: 
131:             $this->_title($this->__('Edit Item Type'));
132: 
133:             Mage::register('current_item_type', $model);
134:             Mage::register('attributes', $result);
135: 
136:             $this->_initAction()
137:                 ->_addBreadcrumb($id ? Mage::helper('googlebase')->__('Edit Item Type') : Mage::helper('googlebase')->__('New Item Type'), $id ? Mage::helper('googlebase')->__('Edit Item Type') : Mage::helper('googlebase')->__('New Item Type'))
138:                 ->_addContent($this->getLayout()->createBlock('googlebase/adminhtml_types_edit'))
139:                 ->renderLayout();
140:         } catch (Exception $e) {
141:             $this->_getSession()->addError($e->getMessage());
142:             $this->_redirect('*/*/index');
143:         }
144:     }
145: 
146:     public function saveAction()
147:     {
148:         $typeModel = Mage::getModel('googlebase/type');
149:         $id = $this->getRequest()->getParam('type_id');
150:         if (!is_null($id)) {
151:             $typeModel->load($id);
152:         }
153: 
154:         try {
155:             if ($typeModel->getId()) {
156:                 $collection = Mage::getResourceModel('googlebase/attribute_collection')
157:                     ->addTypeFilter($typeModel->getId())
158:                     ->load();
159:                 foreach ($collection as $attribute) {
160:                     $attribute->delete();
161:                 }
162:             }
163:             $typeModel->setAttributeSetId($this->getRequest()->getParam('attribute_set_id'))
164:                 ->setGbaseItemtype($this->getRequest()->getParam('gbase_itemtype'))
165:                 ->setTargetCountry($this->getRequest()->getParam('target_country'))
166:                 ->save();
167: 
168: 
169:             $attributes = $this->getRequest()->getParam('attributes');
170:             if (is_array($attributes)) {
171:                 $typeId = $typeModel->getId();
172:                 foreach ($attributes as $attrInfo) {
173:                     if (isset($attrInfo['delete']) && $attrInfo['delete'] == 1) {
174:                         continue;
175:                     }
176:                     Mage::getModel('googlebase/attribute')
177:                         ->setAttributeId($attrInfo['attribute_id'])
178:                         ->setGbaseAttribute($attrInfo['gbase_attribute'])
179:                         ->setTypeId($typeId)
180:                         ->save();
181:                 }
182:             }
183: 
184:             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('googlebase')->__('The item type has been saved.'));
185:         } catch (Exception $e) {
186:             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
187:         }
188:         $this->_redirect('*/*/index', array('store' => $this->_getStore()->getId()));
189:     }
190: 
191:     public function deleteAction ()
192:     {
193:         try {
194:             $id = $this->getRequest()->getParam('id');
195:             $model = Mage::getModel('googlebase/type');
196:             $model->load($id);
197:             if ($model->getTypeId()) {
198:                 $model->delete();
199:             }
200:             $this->_getSession()->addSuccess($this->__('Item Type was deleted'));
201:         } catch (Exception $e) {
202:             $this->_getSession()->addError($e->getMessage());
203:         }
204:         $this->_redirect('*/*/index', array('store' => $this->_getStore()->getId()));
205:     }
206: 
207:     public function loadAttributesAction ()
208:     {
209:         try {
210:             $this->getResponse()->setBody(
211:             $this->getLayout()->createBlock('googlebase/adminhtml_types_edit_attributes')
212:                 ->setAttributeSetId($this->getRequest()->getParam('attribute_set_id'))
213:                 ->setGbaseItemtype($this->getRequest()->getParam('gbase_itemtype'))
214:                 ->setTargetCountry($this->getRequest()->getParam('target_country'))
215:                 ->setAttributeSetSelected(true)
216:                 ->toHtml()
217:             );
218:         } catch (Exception $e) {
219:             // just need to output text with error
220:             $this->_getSession()->addError($e->getMessage());
221:         }
222:     }
223: 
224:     public function loadItemTypesAction()
225:     {
226:         try {
227:             $this->getResponse()->setBody(
228:                 $this->getLayout()->getBlockSingleton('googlebase/adminhtml_types_edit_form')
229:                     ->getItemTypesSelectElement($this->getRequest()->getParam('target_country'))
230:                     ->toHtml()
231:             );
232:         } catch (Exception $e) {
233:             // just need to output text with error
234:             $this->_getSession()->addError($e->getMessage());
235:         }
236:     }
237: 
238:     protected function loadAttributeSetsAction()
239:     {
240:         try {
241:             $this->getResponse()->setBody(
242:                 $this->getLayout()->getBlockSingleton('googlebase/adminhtml_types_edit_form')
243:                     ->getAttributeSetsSelectElement($this->getRequest()->getParam('target_country'))
244:                     ->toHtml()
245:             );
246:         } catch (Exception $e) {
247:             // just need to output text with error
248:             $this->_getSession()->addError($e->getMessage());
249:         }
250:     }
251: 
252:     public function _getStore()
253:     {
254:         $storeId = (int) $this->getRequest()->getParam('store', 0);
255:         if ($storeId == 0) {
256:             return Mage::app()->getDefaultStoreView();
257:         }
258:         return Mage::app()->getStore($storeId);
259:     }
260: 
261:     protected function _isAllowed()
262:     {
263:         return Mage::getSingleton('admin/session')->isAllowed('catalog/googlebase/types');
264:     }
265: }
266: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0