Mage_Adminhtml_System_Convert_ProfileController Class Reference

Inheritance diagram for Mage_Adminhtml_System_Convert_ProfileController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action Mage_Adminhtml_System_Convert_GuiController

List of all members.

Public Member Functions

 indexAction ()
 gridAction ()
 editAction ()
 newAction ()
 deleteAction ()
 saveAction ()
 runAction ()
 batchRunAction ()
 batchFinishAction ()
 historyAction ()

Protected Member Functions

 _initProfile ($idFieldName= 'id')
 _isAllowed ()


Detailed Description

Definition at line 34 of file ProfileController.php.


Member Function Documentation

_initProfile ( idFieldName = 'id'  )  [protected]

Definition at line 37 of file ProfileController.php.

00038     {
00039         $profileId = (int) $this->getRequest()->getParam($idFieldName);
00040         $profile = Mage::getModel('dataflow/profile');
00041 
00042         if ($profileId) {
00043             $profile->load($profileId);
00044             if (!$profile->getId()) {
00045                 Mage::getSingleton('adminhtml/session')->addError('The profile you are trying to save no longer exists');
00046                 $this->_redirect('*/*');
00047                 return false;
00048             }
00049         }
00050 
00051         Mage::register('current_convert_profile', $profile);
00052 
00053         return $this;
00054     }

_isAllowed (  )  [protected]

Reimplemented from Mage_Adminhtml_Controller_Action.

Reimplemented in Mage_Adminhtml_System_Convert_GuiController.

Definition at line 295 of file ProfileController.php.

00296     {
00297 //        switch ($this->getRequest()->getActionName()) {
00298 //            case 'index':
00299 //                $aclResource = 'admin/system/convert/profiles';
00300 //                break;
00301 //            case 'grid':
00302 //                $aclResource = 'admin/system/convert/profiles';
00303 //                break;
00304 //            case 'run':
00305 //                $aclResource = 'admin/system/convert/profiles/run';
00306 //                break;
00307 //            default:
00308 //                $aclResource = 'admin/system/convert/profiles/edit';
00309 //                break;
00310 //        }
00311 
00312         return Mage::getSingleton('admin/session')->isAllowed('admin/system/convert/profiles');
00313     }

batchFinishAction (  ) 

Definition at line 263 of file ProfileController.php.

00264     {
00265         if ($batchId = $this->getRequest()->getParam('id')) {
00266             $batchModel = Mage::getModel('dataflow/batch')->load($batchId);
00267             /* @var $batchModel Mage_Dataflow_Model_Batch */
00268 
00269             if ($batchModel->getId()) {
00270                 $result = array();
00271                 try {
00272                     $batchModel->beforeFinish();
00273                 }
00274                 catch (Mage_Core_Exception $e) {
00275                     $result['error'] = $e->getMessage();
00276                 }
00277                 catch (Exception $e) {
00278                     $result['error'] = Mage::helper('adminhtml')->__('Error while finished process. Please refresh cache');
00279                 }
00280                 $batchModel->delete();
00281                 $this->getResponse()->setBody(Zend_Json::encode($result));
00282             }
00283         }
00284     }

batchRunAction (  ) 

Definition at line 206 of file ProfileController.php.

00207     {
00208         if ($this->getRequest()->isPost()) {
00209             $batchId = $this->getRequest()->getPost('batch_id',0);
00210             $rowIds  = $this->getRequest()->getPost('rows');
00211 
00212             $batchModel = Mage::getModel('dataflow/batch')->load($batchId);
00213             /* @var $batchModel Mage_Dataflow_Model_Batch */
00214 
00215             if (!$batchModel->getId()) {
00216                 //exit
00217                 return ;
00218             }
00219             if (!is_array($rowIds) || count($rowIds) < 1) {
00220                 //exit
00221                 return ;
00222             }
00223             if (!$batchModel->getAdapter()) {
00224                 //exit
00225                 return ;
00226             }
00227 
00228             $batchImportModel = $batchModel->getBatchImportModel();
00229             $importIds = $batchImportModel->getIdCollection();
00230 
00231             $adapter = Mage::getModel($batchModel->getAdapter());
00232             $adapter->setBatchParams($batchModel->getParams());
00233 
00234             $errors = array();
00235             $saved  = 0;
00236 
00237             foreach ($rowIds as $importId) {
00238                 $batchImportModel->load($importId);
00239                 if (!$batchImportModel->getId()) {
00240                     $errors[] = Mage::helper('dataflow')->__('Skip undefined row');
00241                     continue;
00242                 }
00243 
00244                 $importData = $batchImportModel->getBatchData();
00245                 try {
00246                     $adapter->saveRow($importData);
00247                 }
00248                 catch (Exception $e) {
00249                     $errors[] = $e->getMessage();
00250                     continue;
00251                 }
00252                 $saved ++;
00253             }
00254 
00255             $result = array(
00256                 'savedRows' => $saved,
00257                 'errors'    => $errors
00258             );
00259             $this->getResponse()->setBody(Zend_Json::encode($result));
00260         }
00261     }

deleteAction (  ) 

Delete profile action

Definition at line 135 of file ProfileController.php.

00136     {
00137         $this->_initProfile();
00138         $profile = Mage::registry('current_convert_profile');
00139         if ($profile->getId()) {
00140             try {
00141                 $profile->delete();
00142                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Profile was deleted'));
00143             }
00144             catch (Exception $e){
00145                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00146             }
00147         }
00148         $this->_redirect('*/*');
00149     }

editAction (  ) 

Profile edit action

Append edit tabs to left block

Reimplemented in Mage_Adminhtml_System_Convert_GuiController.

Definition at line 96 of file ProfileController.php.

00097     {
00098         $this->_initProfile();
00099         $this->loadLayout();
00100 
00101         $profile = Mage::registry('current_convert_profile');
00102 
00103         // set entered data if was error when we do save
00104         $data = Mage::getSingleton('adminhtml/session')->getConvertProfileData(true);
00105 
00106         if (!empty($data)) {
00107             $profile->addData($data);
00108         }
00109 
00110         $this->_setActiveMenu('system/convert');
00111 
00112         $this->_addContent(
00113             $this->getLayout()->createBlock('adminhtml/system_convert_profile_edit')
00114         );
00115 
00116         /**
00117          * Append edit tabs to left block
00118          */
00119         $this->_addLeft($this->getLayout()->createBlock('adminhtml/system_convert_profile_edit_tabs'));
00120 
00121         $this->renderLayout();
00122     }

gridAction (  ) 

Reimplemented in Mage_Adminhtml_System_Convert_GuiController.

Definition at line 88 of file ProfileController.php.

00089     {
00090         $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/system_convert_profile_grid')->toHtml());
00091     }

historyAction (  ) 

Customer orders grid

Definition at line 290 of file ProfileController.php.

00290                                     {
00291         $this->_initProfile();
00292         $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/system_convert_profile_edit_tab_history')->toHtml());
00293     }

indexAction (  ) 

Profiles list action

Set active menu item

Append profiles block to content

Add breadcrumb item

Reimplemented in Mage_Adminhtml_System_Convert_GuiController.

Definition at line 59 of file ProfileController.php.

00060     {
00061         if ($this->getRequest()->getQuery('ajax')) {
00062             $this->_forward('grid');
00063             return;
00064         }
00065         $this->loadLayout();
00066 
00067         /**
00068          * Set active menu item
00069          */
00070         $this->_setActiveMenu('system/convert');
00071 
00072         /**
00073          * Append profiles block to content
00074          */
00075         $this->_addContent(
00076             $this->getLayout()->createBlock('adminhtml/system_convert_profile', 'convert_profile')
00077         );
00078 
00079         /**
00080          * Add breadcrumb item
00081          */
00082         $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Import/Export'), Mage::helper('adminhtml')->__('Import/Export Advanced'));
00083         $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Advanced Profiles'), Mage::helper('adminhtml')->__('Advanced Profiles'));
00084 
00085         $this->renderLayout();
00086     }

newAction (  ) 

Create new profile action

Definition at line 127 of file ProfileController.php.

00128     {
00129         $this->_forward('edit');
00130     }

runAction (  ) 

Definition at line 190 of file ProfileController.php.

00191     {
00192         $this->_initProfile();
00193         #$this->loadLayout();
00194 
00195         #$this->_setActiveMenu('system/convert');
00196 
00197         #$this->_addContent(
00198         #    $this->getLayout()->createBlock('adminhtml/system_convert_profile_run')
00199         #);
00200         $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/system_convert_profile_run')->toHtml());
00201         $this->getResponse()->sendResponse();
00202 
00203         #$this->renderLayout();
00204     }

saveAction (  ) 

Save profile action

Definition at line 154 of file ProfileController.php.

00155     {
00156         if ($data = $this->getRequest()->getPost()) {
00157             if (!$this->_initProfile('profile_id')) {
00158                 return ;
00159             }
00160             $profile = Mage::registry('current_convert_profile');
00161 
00162             // Prepare profile saving data
00163             if (isset($data)) {
00164                 $profile->addData($data);
00165             }
00166 
00167             try {
00168                 $profile->save();
00169 
00170                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Profile was successfully saved'));
00171             }
00172             catch (Exception $e){
00173                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00174                 Mage::getSingleton('adminhtml/session')->setConvertProfileData($data);
00175                 $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('id'=>$profile->getId())));
00176                 return;
00177             }
00178             if ($this->getRequest()->getParam('continue')) {
00179                 $this->_redirect('*/*/edit', array('id'=>$profile->getId()));
00180             } else {
00181                 $this->_redirect('*/*');
00182             }
00183         }
00184         else {
00185             Mage::getSingleton('adminhtml/session')->addError($this->__('Invalid POST data (please check post_max_size and upload_max_filesize settings in you php.ini file)'));
00186             $this->_redirect('*/*');
00187         }
00188     }


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

Generated on Sat Jul 4 17:23:29 2009 for Magento by  doxygen 1.5.8