1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Adminhtml_Block_System_Convert_Gui_Edit_Tab_Wizard extends Mage_Adminhtml_Block_Widget_Container
35: {
36:
37: protected $_storeModel;
38: protected $_attributes;
39: protected $_addMapButtonHtml;
40: protected $_removeMapButtonHtml;
41: protected $_shortDateFormat;
42:
43: public function __construct()
44: {
45: parent::__construct();
46: $this->setTemplate('system/convert/profile/wizard.phtml');
47: }
48:
49: protected function _prepareLayout()
50: {
51: if ($head = $this->getLayout()->getBlock('head')) {
52: $head->setCanLoadCalendarJs(true);
53: }
54: return $this;
55: }
56:
57: public function getAttributes($entityType)
58: {
59: if (!isset($this->_attributes[$entityType])) {
60: switch ($entityType) {
61: case 'product':
62: $attributes = Mage::getSingleton('catalog/convert_parser_product')
63: ->getExternalAttributes();
64: break;
65:
66: case 'customer':
67: $attributes = Mage::getSingleton('customer/convert_parser_customer')
68: ->getExternalAttributes();
69: break;
70: }
71:
72: array_splice($attributes, 0, 0, array(''=>$this->__('Choose an attribute')));
73: $this->_attributes[$entityType] = $attributes;
74: }
75: return $this->_attributes[$entityType];
76: }
77:
78: public function getValue($key, $default='', $defaultNew = null)
79: {
80: if (null !== $defaultNew) {
81: if (0 == $this->getProfileId()) {
82: $default = $defaultNew;
83: }
84: }
85:
86: $value = $this->getData($key);
87: return $this->htmlEscape(strlen($value) > 0 ? $value : $default);
88: }
89:
90: public function getSelected($key, $value)
91: {
92: return $this->getData($key)==$value ? 'selected="selected"' : '';
93: }
94:
95: public function getChecked($key)
96: {
97: return $this->getData($key) ? 'checked="checked"' : '';
98: }
99:
100: public function getMappings($entityType)
101: {
102: $maps = $this->getData('gui_data/map/'.$entityType.'/db');
103: return $maps ? $maps : array();
104: }
105:
106: public function getAddMapButtonHtml()
107: {
108: if (!$this->_addMapButtonHtml) {
109: $this->_addMapButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')
110: ->setClass('add')->setLabel($this->__('Add Field Mapping'))
111: ->setOnClick("addFieldMapping()")->toHtml();
112: }
113: return $this->_addMapButtonHtml;
114: }
115:
116: public function getRemoveMapButtonHtml()
117: {
118: if (!$this->_removeMapButtonHtml) {
119: $this->_removeMapButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')
120: ->setClass('delete')->setLabel($this->__('Remove'))
121: ->setOnClick("removeFieldMapping(this)")->toHtml();
122: }
123: return $this->_removeMapButtonHtml;
124: }
125:
126: public function getProductTypeFilterOptions()
127: {
128: $options = Mage::getSingleton('catalog/product_type')->getOptionArray();
129: array_splice($options, 0, 0, array(''=>$this->__('Any Type')));
130: return $options;
131: }
132:
133: public function getProductAttributeSetFilterOptions()
134: {
135: $options = Mage::getResourceModel('eav/entity_attribute_set_collection')
136: ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
137: ->load()
138: ->toOptionHash();
139:
140: $opt = array();
141: $opt = array(''=>$this->__('Any Attribute Set'));
142: if ($options) foreach($options as $index => $value) {
143: $opt[$index] = $value;
144: }
145:
146: return $opt;
147: }
148:
149: public function getProductVisibilityFilterOptions()
150: {
151: $options = Mage::getSingleton('catalog/product_visibility')->getOptionArray();
152:
153: array_splice($options, 0, 0, array(''=>$this->__('Any Visibility')));
154: return $options;
155: }
156:
157: public function getProductStatusFilterOptions()
158: {
159: $options = Mage::getSingleton('catalog/product_status')->getOptionArray();
160:
161: array_splice($options, 0, 0, array(''=>$this->__('Any Status')));
162: return $options;
163: }
164:
165: public function getStoreFilterOptions()
166: {
167: if (!$this->_filterStores) {
168:
169: $this->_filterStores = array();
170: foreach (Mage::getConfig()->getNode('stores')->children() as $storeNode) {
171: if ($storeNode->getName()==='default') {
172:
173: }
174: $this->_filterStores[$storeNode->getName()] = (string)$storeNode->system->store->name;
175: }
176: }
177: return $this->_filterStores;
178: }
179:
180: public function getCustomerGroupFilterOptions()
181: {
182: $options = Mage::getResourceModel('customer/group_collection')
183: ->addFieldToFilter('customer_group_id', array('gt'=>0))
184: ->load()
185: ->toOptionHash();
186:
187: array_splice($options, 0, 0, array(''=>$this->__('Any Group')));
188: return $options;
189: }
190:
191: public function getCountryFilterOptions()
192: {
193: $options = Mage::getResourceModel('directory/country_collection')
194: ->load()->toOptionArray(false);
195: array_unshift($options, array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('All countries')));
196: return $options;
197: }
198:
199: 200: 201: 202: 203:
204: protected function _getStoreModel() {
205: if (is_null($this->_storeModel)) {
206: $this->_storeModel = Mage::getSingleton('adminhtml/system_store');
207: }
208: return $this->_storeModel;
209: }
210:
211: public function getWebsiteCollection()
212: {
213: return $this->_getStoreModel()->getWebsiteCollection();
214: }
215:
216: public function getGroupCollection()
217: {
218: return $this->_getStoreModel()->getGroupCollection();
219: }
220:
221: public function getStoreCollection()
222: {
223: return $this->_getStoreModel()->getStoreCollection();
224: }
225:
226: public function getShortDateFormat()
227: {
228: if (!$this->_shortDateFormat) {
229: $this->_shortDateFormat = Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
230: }
231: return $this->_shortDateFormat;
232: }
233:
234: }
235:
236: