YiiFoundation
  • Namespace
  • Class
  • Tree

Namespaces

  • foundation
    • enum
    • exception
    • helpers
    • widgets
      • base
  • PHP

Classes

  • Alert
  • ArrayHelper
  • Button
  • Foundation
  • Html
  • Icon
  • Nav
  • Panel
  • Pricing
  • Progress
  • Typo
 1 <?php
 2 /**
 3  * @copyright Copyright &copy; 2amigOS! Consulting Group 2013-
 4  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 5  * @package foundation.components
 6  * @version 1.0.0
 7  */
 8 namespace foundation\helpers;
 9 
10 use foundation\enum\Enum;
11 
12 /**
13  * Progress helpers deals with the different progress bars of Foundation.
14  *
15  * @author Antonio Ramirez <amigo.cobos@gmail.com>
16  * @package foundation\helpers
17  */
18 class Progress
19 {
20     /**
21      * Generates success coloured progress bar
22      * @param $percent
23      * @param array $htmlOptions
24      * @return string
25      */
26     public static function success($percent, $htmlOptions = array())
27     {
28         ArrayHelper::addValue('class', Enum::COLOR_SUCCESS, $htmlOptions);
29         return static::bar($percent, $htmlOptions);
30     }
31 
32     public static function important($percent, $htmlOptions = array())
33     {
34         ArrayHelper::addValue('class', Enum::COLOR_ALERT, $htmlOptions);
35         return static::bar($percent, $htmlOptions);
36     }
37 
38     public static function secondary($percent, $htmlOptions = array())
39     {
40         ArrayHelper::addValue('class', Enum::COLOR_SECONDARY, $htmlOptions);
41         return static::bar($percent, $htmlOptions);
42     }
43 
44     public static function bar($percent, $htmlOptions = array())
45     {
46         $percent = substr(trim($percent), -1) !== '%'
47             ? $percent . '%'
48             : $percent;
49 
50         ArrayHelper::addValue('class', Enum::PROGRESS, $htmlOptions);
51         ob_start();
52         echo \CHtml::openTag('div', $htmlOptions);
53         echo \CHtml::openTag('span', array('class' => Enum::PROGRESS_METER, 'style' => 'width:' . $percent));
54         echo \CHtml::closeTag('span');
55         echo \CHtml::closeTag('div');
56         return ob_get_clean();
57     }
58 }
YiiFoundation API documentation generated by ApiGen 2.8.0