Mage_Dataflow_Model_Session_Adapter_Iterator Class Reference

Inheritance diagram for Mage_Dataflow_Model_Session_Adapter_Iterator:

Mage_Dataflow_Model_Convert_Adapter_Abstract Mage_Dataflow_Model_Convert_Container_Abstract Mage_Dataflow_Model_Convert_Adapter_Interface Mage_Dataflow_Model_Convert_Container_Interface

List of all members.

Public Member Functions

 walk ()
 updateProgress ($args)

Protected Member Functions

 _getProgressBarHtml ($sessionId, $totalRows)
 _parseCallback ($callback, $defaultMethod=null)


Detailed Description

Definition at line 3 of file Iterator.php.


Member Function Documentation

_getProgressBarHtml ( sessionId,
totalRows 
) [protected]

Definition at line 26 of file Iterator.php.

00027     {
00028         return '
00029 <li>
00030     <div style="position:relative">
00031         <div id="progress_bar_'.$sessionId.'" style="position:absolute; background:green; height:2px; width:0; top:-2px; left:-2px; overflow:hidden; "></div>
00032         <div>
00033             '.$this->__('Total records: %s', '<strong>'.$totalRows.'</strong>').',
00034             '.$this->__('Processed records: %s', '<strong><span id="records_processed_'.$sessionId.'">0</span></strong>').',
00035             '.$this->__('ETA: %s', '<strong><span id="finish_eta_'.$sessionId.'">N/A</span></strong>').',
00036             '.$this->__('Memory Used: %s', '<strong><span id="memory_'.$sessionId.'">'.memory_get_usage(true).'</span></strong>').'
00037         </div>
00038     </div>
00039 </li>
00040 <script type="text/javascript">
00041 function updateProgress(sessionId, idx, time, memory) {
00042     var total_rows = '.$totalRows.';
00043     var elapsed_time = time-'.time().';
00044     var total_time = Math.round(elapsed_time*total_rows/idx);
00045     var eta = total_time-elapsed_time;
00046     var eta_str = "";
00047     var eta_hours = Math.floor(eta/3600);
00048     var eta_minutes = Math.floor(eta/60)%60;
00049 
00050     if (total_rows==idx) {
00051         eta_str = "'.$this->__('Done').'";
00052     } else if (!eta_hours && !eta_minutes) {
00053         eta_str = "'.$this->__('Less than a minute').'";
00054     } else {
00055         if (eta_hours) {
00056             eta_str += eta_hours+" "+(eta_hours>1 ? "'.$this->__('hours').'" : "'.$this->__('hour').'");
00057         }
00058         if (eta_minutes) {
00059             eta_str += eta_minutes+" "+(eta_minutes>1 ? "'.$this->__('minutes').'" : "'.$this->__('minute').'");
00060         }
00061     }
00062 
00063     document.getElementById("records_processed_'.$sessionId.'").innerHTML= idx;
00064     document.getElementById("finish_eta_'.$sessionId.'").innerHTML = eta_str;
00065     document.getElementById("memory_'.$sessionId.'").innerHTML = memory;
00066     document.getElementById("progress_bar_'.$sessionId.'").style.width = (idx/total_rows*100)+"%";
00067 }
00068 </script>';
00069     }

_parseCallback ( callback,
defaultMethod = null 
) [protected]

Definition at line 80 of file Iterator.php.

00081     {
00082         if (!preg_match('#^([a-z0-9_/]+)(::([a-z0-9_]+))?$#i', $callback, $match)) {
00083             return false;
00084         }
00085         if (!($model = Mage::getModel($match[1]))) {
00086             return false;
00087         }
00088         if (!($method = $match[3] ? $match[3] : $defaultMethod)) {
00089             return false;
00090         }
00091         return array($model, $method);
00092     }

updateProgress ( args  ) 

Definition at line 71 of file Iterator.php.

00072     {
00073         $memory = !empty($args['memory']) ? $args['memory'] : '';
00074         echo '<script>updateProgress("'.$args['row']['session_id'].'", "'.$args['idx'].'", "'.time().'", "'.$memory.'");</script>';
00075         echo '<li>'.$memory.'</li>';
00076 
00077         return array();
00078     }

walk (  ) 

Definition at line 5 of file Iterator.php.

00006     {
00007         $sessionId = Mage::registry('current_dataflow_session_id');
00008         $import = Mage::getResourceModel('dataflow/import');
00009         $total = $import->loadTotalBySessionId($sessionId);
00010 
00011         $callbacks = array();
00012         if ($mapperCb = $this->_parseCallback($this->getVar('mapper'), 'mapRow')) {
00013             $callbacks[] = $mapperCb;
00014         }
00015         if ($adapterCb = $this->_parseCallback($this->getVar('adapter'), 'saveRow')) {
00016             $callbacks[] = $adapterCb;
00017         }
00018         $callbacks[] = array($this, 'updateProgress');
00019 
00020         echo $this->_getProgressBarHtml($sessionId, $total['cnt']);
00021 
00022         Mage::getModel('core/resource_iterator')
00023             ->walk($import->select($sessionId), $callbacks);
00024     }


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

Generated on Sat Jul 4 17:24:06 2009 for Magento by  doxygen 1.5.8