5
* This source file is subject to the new BSD license that is bundled
6
* with this package in the file LICENSE.txt.
7
* It is also available through the world-wide-web at this URL:
8
* http://framework.zend.com/license/new-bsd
9
* If you did not receive a copy of the license and are unable to
10
* obtain it through the world-wide-web, please send an email
11
* to license@zend.com so we can send you a copy immediately.
14
* @package Zend_ProgressBar
15
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
16
* @license http://framework.zend.com/license/new-bsd New BSD License
17
* @version $Id: JsPush.php 12233 2008-11-01 00:11:01Z dasprid $
23
require_once 'Zend/Json.php';
26
* @see Zend_ProgressBar_Adapter
28
require_once 'Zend/ProgressBar/Adapter.php';
31
* Zend_ProgressBar_Adapter_JsPull offers a simple method for updating a
32
* progressbar in a browser.
35
* @package Zend_ProgressBar
36
* @uses Zend_ProgressBar_Adapter_Interface
37
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
38
* @license http://framework.zend.com/license/new-bsd New BSD License
40
class Zend_ProgressBar_Adapter_JsPull extends Zend_ProgressBar_Adapter
43
* Wether to exit after json data send or not
47
protected $_exitAfterSend = true;
50
* Set wether to exit after json data send or not
52
* @param boolean $exitAfterSend
53
* @return Zend_ProgressBar_Adapter_JsPull
55
public function setExitAfterSend($exitAfterSend)
57
$this->_exitAfterSend = $exitAfterSend;
61
* Defined by Zend_ProgressBar_Adapter_Interface
63
* @param float $current Current progress value
64
* @param float $max Max progress value
65
* @param flaot $percent Current percent value
66
* @param integer $timeTaken Taken time in seconds
67
* @param integer $timeRemaining Remaining time in seconds
68
* @param string $text Status text
71
public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $text)
74
'current' => $current,
76
'percent' => ($percent * 100),
77
'timeTaken' => $timeTaken,
78
'timeRemaining' => $timeRemaining,
83
$data = Zend_Json::encode($arguments);
86
$this->_outputData($data);
90
* Defined by Zend_ProgressBar_Adapter_Interface
94
public function finish()
96
$data = Zend_Json::encode(array('finished' => true));
98
$this->_outputData($data);
102
* Outputs given data the user agent.
104
* This split-off is required for unit-testing.
106
* @param string $data
109
protected function _outputData($data)
113
if ($this->_exitAfterSend) {