00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Adminhtml_Block_System_Convert_Gui_Edit_Tab_Wizard extends Mage_Adminhtml_Block_Widget_Container
00035 {
00036
00037 protected $_storeModel;
00038 protected $_attributes;
00039 protected $_addMapButtonHtml;
00040 protected $_removeMapButtonHtml;
00041 protected $_shortDateFormat;
00042
00043 public function __construct()
00044 {
00045 parent::__construct();
00046 $this->setTemplate('system/convert/profile/wizard.phtml');
00047 }
00048
00049 protected function _prepareLayout()
00050 {
00051 if ($head = $this->getLayout()->getBlock('head')) {
00052 $head->setCanLoadCalendarJs(true);
00053 }
00054 return $this;
00055 }
00056
00057 public function getAttributes($entityType)
00058 {
00059 if (!isset($this->_attributes[$entityType])) {
00060 switch ($entityType) {
00061 case 'product':
00062 $attributes = Mage::getSingleton('catalog/convert_parser_product')
00063 ->getExternalAttributes();
00064 break;
00065
00066 case 'customer':
00067 $attributes = Mage::getSingleton('customer/convert_parser_customer')
00068 ->getExternalAttributes();
00069 break;
00070 }
00071
00072 array_splice($attributes, 0, 0, array(''=>$this->__('Choose an attribute')));
00073 $this->_attributes[$entityType] = $attributes;
00074 }
00075 return $this->_attributes[$entityType];
00076 }
00077
00078 public function getValue($key, $default='', $defaultNew = null)
00079 {
00080 if (null !== $defaultNew) {
00081 if (0 == $this->getProfileId()) {
00082 $default = $defaultNew;
00083 }
00084 }
00085
00086 $value = $this->getData($key);
00087 return $this->htmlEscape(strlen($value) > 0 ? $value : $default);
00088 }
00089
00090 public function getSelected($key, $value)
00091 {
00092 return $this->getData($key)==$value ? 'selected="selected"' : '';
00093 }
00094
00095 public function getChecked($key)
00096 {
00097 return $this->getData($key) ? 'checked="checked"' : '';
00098 }
00099
00100 public function getMappings($entityType)
00101 {
00102 $maps = $this->getData('gui_data/map/'.$entityType.'/db');
00103 return $maps ? $maps : array();
00104 }
00105
00106 public function getAddMapButtonHtml()
00107 {
00108 if (!$this->_addMapButtonHtml) {
00109 $this->_addMapButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')
00110 ->setClass('add')->setLabel($this->__('Add Field Mapping'))
00111 ->setOnClick("addFieldMapping()")->toHtml();
00112 }
00113 return $this->_addMapButtonHtml;
00114 }
00115
00116 public function getRemoveMapButtonHtml()
00117 {
00118 if (!$this->_removeMapButtonHtml) {
00119 $this->_removeMapButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')
00120 ->setClass('delete')->setLabel($this->__('Remove'))
00121 ->setOnClick("removeFieldMapping(this)")->toHtml();
00122 }
00123 return $this->_removeMapButtonHtml;
00124 }
00125
00126 public function getProductTypeFilterOptions()
00127 {
00128 $options = Mage::getSingleton('catalog/product_type')->getOptionArray();
00129 array_splice($options, 0, 0, array(''=>$this->__('Any Type')));
00130 return $options;
00131 }
00132
00133 public function getProductAttributeSetFilterOptions()
00134 {
00135 $options = Mage::getResourceModel('eav/entity_attribute_set_collection')
00136 ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
00137 ->load()
00138 ->toOptionHash();
00139
00140 $opt = array();
00141 $opt = array(''=>$this->__('Any Attribute Set'));
00142 if ($options) foreach($options as $index => $value) {
00143 $opt[$index] = $value;
00144 }
00145
00146 return $opt;
00147 }
00148
00149 public function getProductVisibilityFilterOptions()
00150 {
00151 $options = Mage::getSingleton('catalog/product_visibility')->getOptionArray();
00152
00153 array_splice($options, 0, 0, array(''=>$this->__('Any Visibility')));
00154 return $options;
00155 }
00156
00157 public function getProductStatusFilterOptions()
00158 {
00159 $options = Mage::getSingleton('catalog/product_status')->getOptionArray();
00160
00161 array_splice($options, 0, 0, array(''=>$this->__('Any Status')));
00162 return $options;
00163 }
00164
00165 public function getStoreFilterOptions()
00166 {
00167 if (!$this->_filterStores) {
00168 #$this->_filterStores = array(''=>$this->__('Any Store'));
00169 $this->_filterStores = array();
00170 foreach (Mage::getConfig()->getNode('stores')->children() as $storeNode) {
00171 if ($storeNode->getName()==='default') {
00172
00173 }
00174 $this->_filterStores[$storeNode->getName()] = (string)$storeNode->system->store->name;
00175 }
00176 }
00177 return $this->_filterStores;
00178 }
00179
00180 public function getCustomerGroupFilterOptions()
00181 {
00182 $options = Mage::getResourceModel('customer/group_collection')
00183 ->addFieldToFilter('customer_group_id', array('gt'=>0))
00184 ->load()
00185 ->toOptionHash();
00186
00187 array_splice($options, 0, 0, array(''=>$this->__('Any Group')));
00188 return $options;
00189 }
00190
00191 public function getCountryFilterOptions()
00192 {
00193 $options = Mage::getResourceModel('directory/country_collection')
00194 ->load()->toOptionArray(false);
00195 array_unshift($options, array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('All countries')));
00196 return $options;
00197 }
00198
00199
00200
00201
00202
00203
00204 protected function _getStoreModel() {
00205 if (is_null($this->_storeModel)) {
00206 $this->_storeModel = Mage::getSingleton('adminhtml/system_store');
00207 }
00208 return $this->_storeModel;
00209 }
00210
00211 public function getWebsiteCollection()
00212 {
00213 return $this->_getStoreModel()->getWebsiteCollection();
00214 }
00215
00216 public function getGroupCollection()
00217 {
00218 return $this->_getStoreModel()->getGroupCollection();
00219 }
00220
00221 public function getStoreCollection()
00222 {
00223 return $this->_getStoreModel()->getStoreCollection();
00224 }
00225
00226 public function getShortDateFormat()
00227 {
00228 if (!$this->_shortDateFormat) {
00229 $this->_shortDateFormat = Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
00230 }
00231 return $this->_shortDateFormat;
00232 }
00233
00234 }
00235