, */ use_helper('stPartial'); /** * * @param stProgressBarTaskInterface $task * @param array $options * @return string */ function st_progress_bar(stProgressBarTaskInterface $task, array $options = []) { $className = get_class($task); $parameters = [ 'name' => $className, 'class' => $className, 'method' => 'execute', 'steps' => $task->count(), 'step' => 0, 'msg'=> '', ]; if (isset($options['application'])) { $parameters['application'] = $options['application']; } $content = st_get_component('stProgressBar', 'initProgressBar', $parameters); $content .= progress_bar_update($className, 0, $options); return $content; } /** * Obsługa paska postępu * * @param mixed $task * @param string $className nazwa klasy, w której znajduję się metoda do wywołania * @param string $methodName nazwa metody, która ma zostać wywołana z numerem kroku jako parametrem * @param integer $steps ilość kroków * * @package stProgressBarPlugin * @subpackage helpers * @deprecated since 8.1.4.0 use st_progress_bar() */ function progress_bar($task, $className = null, $methodName = null, $steps = null, $params = array()) { if (null === $className && is_object($task) && $task instanceof stProgressBarTaskInterface) { /** * @var stProgressBarTaskInterface $task */ $name = get_class($task); $className = $name; $steps = $task->count(); $methodName = 'execute'; } elseif (null !== $task) { $name = $task; if (class_exists($className)) { $task = new $className(); } else { throw new Exception("Class $className don't exist."); } } else { throw new Exception("Variable task must be an stProgressBarTaskInterface instance or a string name"); } if (is_callable(array($task, $methodName))) { if (is_int($steps)) { $parameters = [ 'name' => $name, 'class' => $className, 'method' => $methodName, 'steps' => $steps, 'step' => '0', 'msg'=>'', ]; if (function_exists('st_get_component')) { return st_get_component('stProgressBar','initProgressBar', $parameters).progress_bar_update($name, 0, $params); } else { return get_component('stProgressBar','initProgressBar', $parameters).progress_bar_update($name, 0, $params); } } else { throw new Exception("Parameter \$steps ($steps) is not integer."); } } else { throw new Exception("Method $methodName in class $className don't exist."); } } function progress_bar_error($title, $text) { $tag = content_tag('div',content_tag('h2',$title).content_tag('p',$text,array('style'=>'padding-left: 10px; padding-right: 10px;')),array('class'=>'form-errors', 'style'=>'margin-top: 10px;')); return str_replace(array("'","\n"), array("\\'","\\n'\n\t+'"), $tag); } function progress_bar_update($name, $step, $params) { $i18n = sfContext::getInstance()->getI18N(); sfContext::getInstance()->getResponse()->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/prototype'); if (!isset($params['msg'])) { $params['msg'] = ""; } return ''; }