Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
JsPush.php
Go to the documentation of this file.
1 <?php
23 #require_once 'Zend/Json.php';
24 
28 #require_once 'Zend/ProgressBar/Adapter.php';
29 
41 {
47  protected $_updateMethodName = 'Zend_ProgressBar_Update';
48 
54  protected $_finishMethodName;
55 
62  public function setUpdateMethodName($methodName)
63  {
64  $this->_updateMethodName = $methodName;
65 
66  return $this;
67  }
68 
75  public function setFinishMethodName($methodName)
76  {
77  $this->_finishMethodName = $methodName;
78 
79  return $this;
80  }
81 
93  public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $text)
94  {
95  $arguments = array(
96  'current' => $current,
97  'max' => $max,
98  'percent' => ($percent * 100),
99  'timeTaken' => $timeTaken,
100  'timeRemaining' => $timeRemaining,
101  'text' => $text
102  );
103 
104  $data = '<script type="text/javascript">'
105  . 'parent.' . $this->_updateMethodName . '(' . Zend_Json::encode($arguments) . ');'
106  . '</script>';
107 
108  // Output the data
109  $this->_outputData($data);
110  }
111 
117  public function finish()
118  {
119  if ($this->_finishMethodName === null) {
120  return;
121  }
122 
123  $data = '<script type="text/javascript">'
124  . 'parent.' . $this->_finishMethodName . '();'
125  . '</script>';
126 
127  $this->_outputData($data);
128  }
129 
138  protected function _outputData($data)
139  {
140  // 1024 padding is required for Safari, while 256 padding is required
141  // for Internet Explorer. The <br /> is required so Safari actually
142  // executes the <script />
143  echo str_pad($data . '<br />', 1024, ' ', STR_PAD_RIGHT) . "\n";
144 
145  flush();
146  ob_flush();
147  }
148 }
if($this->helper('Magento\Tax\Helper\Data') ->displayFullSummary()) foreach( $block->getTotal() ->getFullInfo() as $info)(isset($info['hidden']) && $info['hidden']) $percent
Definition: tax.phtml:33
setUpdateMethodName($methodName)
Definition: JsPush.php:62
endifif( $block->getLastPageNum()>1)( 'Page') ?></strong >< ul class $text
Definition: pager.phtml:43
setFinishMethodName($methodName)
Definition: JsPush.php:75
$arguments
static encode($valueToEncode, $cycleCheck=false, $options=array())
Definition: Json.php:130
notify($current, $max, $percent, $timeTaken, $timeRemaining, $text)
Definition: JsPush.php:93