Bootstrap\View\Helper\BootstrapHtmlHelper::progress PHP Метод

progress() публичный Метод

Create a Twitter Bootstrap style progress bar.
public progress ( $widths, $options = [] )
$widths - The width (in %) of the bar (style primary, without display) - An array of bar, with (for each bar) : - width (only field required) - type (primary, info, danger, success, warning, default is primary) - min (integer, default 0) - max (integer, default 100) - display (boolean, default false, for text display)
$options Options that will be passed to Html::div method (only for main div) If $widths is only a integer (first case), $options may contains value for the fields specified above. Available BootstrapHtml options: - striped: boolean, specify if progress bar should be striped - active: boolean, specify if progress bar should be active
    public function progress($widths, $options = [])
    {
        $options += ['striped' => false, 'active' => false, 'format' => $this->config('progressTextFormat')];
        $striped = $options['striped'];
        $active = $options['active'];
        unset($options['active'], $options['striped']);
        $bars = '';
        if (!is_array($widths)) {
            $widths = [array_merge(['width' => $widths], $options)];
        }
        foreach ($widths as $width) {
            $width += ['type' => $this->config('progress.type'), 'min' => 0, 'max' => 100, 'display' => false];
            $class = 'progress-bar progress-bar-' . $width['type'];
            $content = $this->tag('span', sprintf($options['format'], $width['width']), ['class' => $width['display'] ? '' : 'sr-only']);
            $bars .= $this->div($class, $content, ['aria-valuenow' => $width['width'], 'aria-valuemin' => $width['min'], 'aria-valuemax' => $width['max'], 'role' => 'progressbar', 'style' => 'width: ' . $width['width'] . '%;']);
        }
        $options = $this->addClass($options, 'progress');
        if ($active) {
            $options = $this->addClass($options, 'active');
        }
        if ($striped) {
            $options = $this->addClass($options, 'progress-striped');
        }
        $classes = $options['class'];
        unset($options['class'], $options['active'], $options['type'], $options['striped'], $options['format']);
        return $this->div($classes, $bars, $options);
    }