From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- library/vendor/Zend/ProgressBar/Adapter/JsPull.php | 115 +++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 library/vendor/Zend/ProgressBar/Adapter/JsPull.php (limited to 'library/vendor/Zend/ProgressBar/Adapter/JsPull.php') diff --git a/library/vendor/Zend/ProgressBar/Adapter/JsPull.php b/library/vendor/Zend/ProgressBar/Adapter/JsPull.php new file mode 100644 index 0000000..cb9b5bd --- /dev/null +++ b/library/vendor/Zend/ProgressBar/Adapter/JsPull.php @@ -0,0 +1,115 @@ +_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; + } + } +} -- cgit v1.2.3