diff -r 000000000000 -r 4eba9c11703f web/Zend/ProgressBar/Adapter/JsPull.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/Zend/ProgressBar/Adapter/JsPull.php Mon Dec 13 18:29:26 2010 +0100 @@ -0,0 +1,117 @@ +_exitAfterSend = $exitAfterSend; + } + + /** + * Defined by Zend_ProgressBar_Adapter_Interface + * + * @param float $current Current progress value + * @param float $max Max progress value + * @param float $percent Current percent value + * @param integer $timeTaken Taken time in seconds + * @param integer $timeRemaining Remaining time in seconds + * @param string $text Status text + * @return void + */ + public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $text) + { + $arguments = array( + 'current' => $current, + 'max' => $max, + 'percent' => ($percent * 100), + 'timeTaken' => $timeTaken, + 'timeRemaining' => $timeRemaining, + 'text' => $text, + 'finished' => false + ); + + $data = Zend_Json::encode($arguments); + + // Output the data + $this->_outputData($data); + } + + /** + * Defined by Zend_ProgressBar_Adapter_Interface + * + * @return void + */ + public function finish() + { + $data = Zend_Json::encode(array('finished' => true)); + + $this->_outputData($data); + } + + /** + * Outputs given data the user agent. + * + * This split-off is required for unit-testing. + * + * @param string $data + * @return void + */ + protected function _outputData($data) + { + echo $data; + + if ($this->_exitAfterSend) { + exit; + } + } +}