From a6be6bc2fbb70bb3f099ad4c68651370951bf31f Mon Sep 17 00:00:00 2001 From: Kartik Visweswaran Date: Sat, 12 Dec 2015 00:22:58 +0530 Subject: [PATCH] Updates to release v1.3.4 --- CHANGE.md | 8 + Enum.php | 135 ++++---- Html.php | 684 +++++++++++++++++++++-------------------- messages/it/kvenum.php | 188 +++++------ messages/uk/kvenum.php | 118 ------- 5 files changed, 529 insertions(+), 604 deletions(-) delete mode 100644 messages/uk/kvenum.php diff --git a/CHANGE.md b/CHANGE.md index 67aeced..750cb73 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,6 +1,14 @@ Change Log: `yii2-helpers` ========================== +## Version 1.3.4 + +**Date:** 12-Dec-2015 + +- (enh #27): Add Ukranian Translations. +- (enh #28): Add Italian Translations. +- (enh #29): Code style and formatting enhancements. + ## Version 1.3.3 **Date:** 22-Oct-2015 diff --git a/Enum.php b/Enum.php index a1d4cfb..73f916a 100644 --- a/Enum.php +++ b/Enum.php @@ -10,6 +10,7 @@ use Yii; use yii\base\InvalidConfigException; +use yii\helpers\Inflector; /** * Collection of useful helper functions for Yii Applications @@ -18,9 +19,11 @@ * @since 1.0 * */ -class Enum extends \yii\helpers\Inflector +class Enum extends Inflector { - /* time intervals in seconds */ + /** + * @var array time intervals in seconds + */ public static $intervals = [ 'year' => 31556926, 'month' => 2629744, @@ -34,18 +37,17 @@ class Enum extends \yii\helpers\Inflector /** * Check if a variable is empty or not set. * - * @param reference $var variable to perform the check + * @param mixed $var variable to perform the check * * @return boolean */ - public static function isEmpty(&$var) + public static function isEmpty($var) { - return is_array($var) ? empty($var) : (!isset($var) || (strlen($var) == 0)); + return !isset($var) ? true : (is_array($var) ? empty($var) : ($var === null || $var === '')); } /** - * Check if a value exists in the array. This method is faster - * in performance than the built in PHP in_array method. + * Check if a value exists in the array. This method is faster in performance than the built in PHP in_array method. * * @param string $needle the value to search * @param array $haystack the array to scan @@ -60,11 +62,16 @@ public static function inArray($needle, $haystack) /** * Properize a string for possessive punctuation. - * e.g. - * properize("Chris"); //returns Chris' - * properize("David"); //returns David's * * @param string $string input string + * + * Example: + * ~~~ + * properize("Chris"); //returns Chris' + * properize("David"); //returns David's + * ~~~ + * + * @return string */ public static function properize($string) { @@ -75,15 +82,15 @@ public static function properize($string) /** * Get time elapsed (Facebook Style) * + * @param string $fromTime start date time + * @param bool $human if true returns an approximate human friendly output. If set to `false`, will attempt an + * exact conversion of time intervals. + * @param string $toTime end date time (defaults to current system time) + * @param string $append the string to append for the converted elapsed time. Defaults to ' ago'. + * * Example Output(s): * 10 hours ago * - * @param string $fromTime start date time - * @param boolean $human if true returns an approximate human friendly output. If set to `false`, - * will attempt an exact conversion of time intervals. - * @param string $toTime end date time (defaults to current system time) - * @param string $append the string to append for the converted elapsed time. Defaults to ' ago'. - * * @return string */ public static function timeElapsed($fromTime = null, $human = true, $toTime = null, $append = null) @@ -98,16 +105,16 @@ public static function timeElapsed($fromTime = null, $human = true, $toTime = nu /** * Get time interval (Facebook Style) * + * @param int $interval time interval in seconds + * @param string $append the string to append for the converted elapsed time. Defaults to ' ago'. + * @param bool $human if true returns an approximate human friendly output. If set to `false`, will attempt an + * exact conversion of time intervals. + * * Example Output(s): * 10 hours ago * - * @param int $interval time interval in seconds - * @param string $append the string to append for the converted elapsed time. Defaults to ' ago'. - * @param boolean $human if true returns an approximate human friendly output. If set to `false`, - * will attempt an exact conversion of time intervals. - * * @return string - */ + */ public static function timeInterval($interval, $append = null, $human = true) { static::initI18N(); @@ -121,12 +128,13 @@ public static function timeInterval($interval, $append = null, $human = true) if ($interval <= 0) { $elapsed = Yii::t('kvenum', 'a moment ago'); } elseif ($interval < 60) { - $elapsed = Yii::t('kvenum', '{n, plural, one{one second} other{# seconds}}', - ['n' => $interval]) . $append; + $elapsed = Yii::t('kvenum', '{n, plural, one{one second} other{# seconds}}', [ + 'n' => $interval + ]) . $append; } elseif ($interval >= 60 && $interval < $intervals['hour']) { $interval = floor($interval / $intervals['minute']); - $elapsed = Yii::t('kvenum', '{n, plural, one{one minute} other{# minutes}}', - ['n' => $interval]) . $append; + $elapsed = Yii::t('kvenum', '{n, plural, one{one minute} other{# minutes}}', ['n' => $interval]) . + $append; } elseif ($interval >= $intervals['hour'] && $interval < $intervals['day']) { $interval = floor($interval / $intervals['hour']); $elapsed = Yii::t('kvenum', '{n, plural, one{one hour} other{# hours}}', ['n' => $interval]) . $append; @@ -138,8 +146,8 @@ public static function timeInterval($interval, $append = null, $human = true) $elapsed = Yii::t('kvenum', '{n, plural, one{one week} other{# weeks}}', ['n' => $interval]) . $append; } elseif ($interval >= $intervals['month'] && $interval < $intervals['year']) { $interval = floor($interval / $intervals['month']); - $elapsed = Yii::t('kvenum', '{n, plural, one{one month} other{# months}}', - ['n' => $interval]) . $append; + $elapsed = Yii::t('kvenum', '{n, plural, one{one month} other{# months}}', ['n' => $interval]) . + $append; } elseif ($interval >= $intervals['year']) { $interval = floor($interval / $intervals['year']); $elapsed = Yii::t('kvenum', '{n, plural, one{one year} other{# years}}', ['n' => $interval]) . $append; @@ -172,17 +180,17 @@ public static function initI18N() * Example Output: * 1 year 5 months 3 days ago * - * @param integer $timeline elapsed number of seconds - * @param array $intervals configuration of time intervals in seconds + * @param int $time elapsed number of seconds + * @param array $intervals configuration of time intervals in seconds * * @return string */ - protected static function time2String($timeline, $intervals) + protected static function time2String($time, $intervals) { $output = ''; - foreach ($intervals AS $name => $seconds) { - $num = floor($timeline / $seconds); - $timeline -= ($num * $seconds); + foreach ($intervals as $name => $seconds) { + $num = floor($time / $seconds); + $time -= ($num * $seconds); if ($num > 0) { $output .= $num . ' ' . $name . (($num > 1) ? 's' : '') . ' '; } @@ -296,11 +304,10 @@ public static function numToWords($num) } /** - * Recursive function used in number to words conversion. - * Converts three digits per pass. + * Recursive function used in number to words conversion. Converts three digits per pass. * * @param double $num the source number - * @param double $tri the three digits converted per pass. + * @param int $tri the three digits converted per pass. * * @return string */ @@ -329,8 +336,7 @@ protected static function convertTri($num, $tri) $str .= $tens[(int)($y / 10)] . $ones[$y % 10]; } - // add triplet modifier only if there - // is some output to be modified... + // add triplet modifier only if there is some output to be modified... if ($str != "") { $str .= $triplets[$tri]; } @@ -491,13 +497,13 @@ public static function yearList($from, $to = null, $keys = false, $desc = true) /** * Generate a month or day array list for Gregorian calendar * - * @param string $unit whether 'day' or 'month' - * @param boolean $abbr whether to return abbreviated day or month - * @param boolean $start the first day or month to set. Defaults to `1`. - * @param string $case whether 'upper', lower', or null. If null, then - * the initcap case will be used. + * @param string $unit whether 'day' or 'month' + * @param bool $abbr whether to return abbreviated day or month + * @param int $start the first day or month to set. Defaults to `1`. + * @param string $case whether 'upper', lower', or null. If null, then the initcap case will be used. * * @return array list of days or months + * @throws InvalidConfigException */ protected static function genCalList($unit = 'day', $abbr = false, $start = 1, $case = null) { @@ -530,10 +536,9 @@ protected static function genCalList($unit = 'day', $abbr = false, $start = 1, $ /** * Generate a month array list for Gregorian calendar * - * @param boolean $abbr whether to return abbreviated month - * @param boolean $start the first month to set. Defaults to `1` for `January`. - * @param string $case whether 'upper', lower', or null. If null, then - * the initcap case will be used. + * @param bool $abbr whether to return abbreviated month + * @param int $start the first month to set. Defaults to `1` for `January`. + * @param string $case whether 'upper', lower', or null. If null, then the initcap case will be used. * * @return array list of months */ @@ -545,10 +550,9 @@ public static function monthList($abbr = false, $start = 1, $case = null) /** * Generate a day array list for Gregorian calendar * - * @param boolean $abbr whether to return abbreviated day - * @param boolean $start the first day to set. Defaults to `1` for `Sunday`. - * @param string $case whether 'upper', lower', or null. If null, then - * the initcap case will be used. + * @param bool $abbr whether to return abbreviated day + * @param int $start the first day to set. Defaults to `1` for `Sunday`. + * @param string $case whether 'upper', lower', or null. If null, then the initcap case will be used. * * @return array list of days */ @@ -560,11 +564,11 @@ public static function dayList($abbr = false, $start = 1, $case = null) /** * Generate a date picker array list for Gregorian Calendar. * - * @param integer $from the start day, defaults to 1 - * @param integer $to the end day, defaults to 31 - * @param integer $interval the date interval, defaults to 1. - * @param integer $intervalFromZero whether to start incrementing intervals from zero if $from = 1. - * @param integer $showLast whether to show the last date (set in $to) even if it does not match interval. + * @param int $from the start day, defaults to 1 + * @param int $to the end day, defaults to 31 + * @param int $interval the date interval, defaults to 1. + * @param bool $intervalFromZero whether to start incrementing intervals from zero if $from = 1. + * @param bool $showLast whether to show the last date (set in $to) even if it does not match interval. * * @return array * @throws InvalidConfigException @@ -734,7 +738,7 @@ public static function array2table( if ($recursive === true && is_array($cell) && !empty($cell)) { // Recursive mode - $table .= "\n" . array2table($cell, true, true) . "\n"; + $table .= "\n" . static::array2table($cell, true, true) . "\n"; } else { if (!is_null($cell) && is_bool($cell)) { $val = $cell ? 'true' : 'false'; @@ -776,8 +780,8 @@ public static function getType($var) return 'NULL'; } elseif (is_bool($var)) { return 'boolean'; - } elseif (is_float($var) || (is_numeric(str_replace(',', '', $var)) && strpos($var, - '.') > 0 && is_float((float)str_replace(',', '', $var))) + } elseif (is_float($var) || (is_numeric(str_replace(',', '', $var)) && strpos($var, '.') > 0 && + is_float((float)str_replace(',', '', $var))) ) { return 'float'; } elseif (is_int($var) || (is_numeric($var) && is_int((int)$var))) { @@ -812,8 +816,11 @@ public static function userIP($filterLocal = true) if (array_key_exists($key, $_SERVER) === true) { foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { if ($filterLocal) { - $checkFilter = filter_var($ip, FILTER_VALIDATE_IP, - FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE); + $checkFilter = filter_var( + $ip, + FILTER_VALIDATE_IP, + FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE + ); if ($checkFilter !== false) { return $ip; } @@ -921,8 +928,8 @@ public static function getBrowser($common = false, $browsers = [], $agent = null /** * Returns browser version * - * @param string $agent - * @param browser $code + * @param string $agent the user agent string + * @param string $code the browser string * * @return float */ diff --git a/Html.php b/Html.php index 0b87ddb..b565667 100644 --- a/Html.php +++ b/Html.php @@ -9,6 +9,8 @@ namespace kartik\helpers; use Yii; +use yii\base\Model; +use yii\helpers\ArrayHelper; /** * Provides implementation for various bootstrap HTML helper functions @@ -55,10 +57,12 @@ class Html extends \yii\helpers\Html const TYPE_DANGER = 'danger'; /** - * Generates an icon. + * Generates a bootstrap icon markup. + * + * @see http://getbootstrap.com/components/#glyphicons * * @param string $icon the bootstrap icon name without prefix (e.g. 'plus', 'pencil', 'trash') - * @param array $options html options for the icon container + * @param array $options HTML attributes / options for the icon container * @param string $prefix the css class prefix - defaults to 'glyphicon glyphicon-' * @param string $tag the icon container tag (usually 'span' or 'i') - defaults to 'span' * @@ -69,7 +73,7 @@ class Html extends \yii\helpers\Html * echo Html::icon('plus', ['class' => 'text-success']); * ~~~ * - * @see http://getbootstrap.com/components/#glyphicons + * @return string */ public static function icon($icon, $options = [], $prefix = 'glyphicon glyphicon-', $tag = 'span') { @@ -79,25 +83,20 @@ public static function icon($icon, $options = [], $prefix = 'glyphicon glyphicon } /** - * Generates a label. + * Generates a bootstrap label markup. * - * @param string $content the label content - * @param string $type the bootstrap label type - defaults to 'default' - * - is one of 'default, 'primary', 'success', 'info', 'danger', 'warning' - * @param array $options html options for the label container - * @param string $prefix the css class prefix - defaults to 'label label-' - * @param string $tag the label container tag - defaults to 'span' + * @see http://getbootstrap.com/components/#labels * - * Example(s): - * ~~~ - * echo Html::bsLabel('Default'); - * echo Html::bsLabel('Primary', Html::TYPE_PRIMARY); - * echo Html::bsLabel('Success', Html::TYPE_SUCCESS); - * ~~~ + * @param string $content the label content + * @param string $type the bootstrap label type. Defaults to 'default'. Should be one of the bootstrap contextual + * colors: 'default, 'primary', 'success', 'info', 'danger', 'warning'. + * @param array $options HTML attributes / options for the label container + * @param string $prefix the CSS class prefix. Defaults to 'label label-'. + * @param string $tag the label container tag. Defaults to 'span'. * - * @see http://getbootstrap.com/components/#labels + * @return string */ - public static function bsLabel($content, $type = '', $options = [], $prefix = 'label label-', $tag = 'span') + public static function bsLabel($content, $type = 'default', $options = [], $prefix = 'label label-', $tag = 'span') { if (Enum::isEmpty($type)) { $type = self::TYPE_DEFAULT; @@ -110,16 +109,13 @@ public static function bsLabel($content, $type = '', $options = [], $prefix = 'l /** * Generates a badge. * - * @param string $content the badge content - * @param array $options html options for the badge container - * @param string $tag the badge container tag - defaults to 'span' + * @see http://getbootstrap.com/components/#badges * - * Example(s): - * ~~~ - * echo Html::badge('1'); - * ~~~ + * @param string $content the badge content + * @param array $options HTML attributes / options for the label container + * @param string $tag the label container tag. Defaults to 'span'. * - * @see http://getbootstrap.com/components/#badges + * @return string */ public static function badge($content, $options = [], $tag = 'span') { @@ -128,21 +124,22 @@ public static function badge($content, $options = [], $tag = 'span') } /** - * Generates a list group. Flexible and powerful component for displaying not only - * simple lists of elements, but complex ones with custom content. - * - * @param array $items the list group items - each element in the array must contain these keys: - * - @param mixed $content the list item content - * - when passed as a string, it will display this directly as a raw content - * - when passed as an array, it requires these keys - * - @param string $heading the content heading - * - @param string $body the content body - * - @param string $url the url for linking the list item content (optional) - * - @param string $badge a badge component to be displayed for this list item (optional) - * - @param boolean $active to highlight the item as active (applicable only if $url is passed) - default false - * @param array $options html options for the list group container - * @param string $tag the list group container tag - defaults to 'div' - * @param string $itemTag the list item container tag - defaults to 'div' + * Generates a list group. Flexible and powerful component for displaying not only simple lists of elements, but + * complex ones with custom content. + * + * @see http://getbootstrap.com/components/#list-group + * + * @param array $items the list group items. The following array key properties can be setup: + * - $content: mixed, the list item content. When passed as a string, it will display this directly as a raw + * content. When passed as an array, it requires these keys + * - `heading`: string, the content heading + * - `body`: string, the content body + * - `url`: mixed, the url for linking the list item content (optional) + * - `badge`: string, any badge content to be displayed for this list item (optional) + * - `active`: bool, to highlight the item as active (applicable only if $url is passed). Defaults to `false`. + * @param array $options HTML attributes / options for the list group container + * @param string $tag the list group container tag. Defaults to 'div'. + * @param string $itemTag the list item container tag. Defaults to 'div'. * * Example(s): * ~~~ @@ -185,7 +182,7 @@ public static function badge($content, $options = [], $tag = 'span') * ]); * ~~~ * - * @see http://getbootstrap.com/components/#list-group + * @return string */ public static function listGroup($items = [], $options = [], $tag = 'div', $itemTag = 'div') { @@ -200,18 +197,18 @@ public static function listGroup($items = [], $options = [], $tag = 'div', $item /** * Processes and generates each list group item * - * @param array $item the list item configuration + * @param array $item the list item configuration * @param string $tag the list item container tag + * + * @return string */ protected static function generateListGroupItem($item, $tag) { static::addCssClass($item['options'], 'list-group-item'); - - /* Parse item content */ $content = isset($item['content']) ? $item['content'] : ''; if (is_array($content)) { - $heading = isset($content['heading']) ? $content['heading'] : ''; - $body = isset($content['body']) ? $content['body'] : ''; + $heading = ArrayHelper::getValue($content, 'heading', ''); + $body = ArrayHelper::getValue($content, 'body', ''); if (!Enum::isEmpty($heading)) { $heading = static::tag('h4', $heading, ['class' => 'list-group-item-heading']); } @@ -220,18 +217,13 @@ protected static function generateListGroupItem($item, $tag) } $content = $heading . "\n" . $body; } - - /* Parse item badge component */ - $badge = isset($item['badge']) ? $item['badge'] : ''; + $badge = ArrayHelper::getValue($item, 'badge', ''); + $url = ArrayHelper::getValue($item, 'url', ''); if (!Enum::isEmpty($badge)) { $content = static::badge($badge) . $content; } - - /* Parse item url */ - $url = isset($item['url']) ? $item['url'] : ''; if (!Enum::isEmpty($url)) { - /* Parse if item is active */ - if (isset($item['active']) && $item['active']) { + if (ArrayHelper::getValue($item, 'active', false)) { static::addCssClass($item['options'], 'active'); } return static::a($content, $url, $item['options']); @@ -241,38 +233,42 @@ protected static function generateListGroupItem($item, $tag) } /** - * Generates a jumbotron - a lightweight, flexible component that can optionally - * extend the entire viewport to showcase key content on your site. - * - * @param mixed $content the jumbotron content - * - when passed as a string, it will display this directly as a raw content - * - when passed as an array, it requires these keys - * - @param string $heading the jumbotron content title - * - @param string $body the jumbotron content body - * - @param array $buttons the jumbotron buttons - * - @param string $label the button label - * - @param string $icon the icon to place before the label - * - @param string $url the button url - * - @param string $type one of the color modifier constants - defaults to self::TYPE_DEFAULT - * - @param string $size one of the size modifier constants - * - @param array $options the button html options - * @param boolean $fullWidth whether this is a full width jumbotron without any corners - defaults to false - * @param array $options html options for the jumbotron + * Generates a jumbotron - a lightweight, flexible component that can optionally extend the entire viewport to + * showcase key content on your site. + * + * @see http://getbootstrap.com/components/#jumbotron + * + * @param mixed $content the list item content. When passed as a string, it will display this directly as a raw + * content. When passed as an array, it requires these keys + * - `heading`: string, the jumbotron heading title + * - `body`: string, the jumbotron content body + * - `buttons`: array, the configuration for jumbotron buttons. The following properties can be set: + * - `label`: string, the button label + * - `icon`: string, the icon to place before the label + * - `url`: mixed, the button url + * - `type`: string, one of the bootstrap color modifier constants. Defaults to `Html::TYPE_DEFAULT`. + * - `size`: string, one of the size modifier constants + * - `options`: array, the HTML attributes / options for the button. + * @param bool $fullWidth whether this is a full width jumbotron without any corners. Defaults to `false`. + * @param array $options HTML attributes / options for the jumbotron container * * Example(s): * ~~~ * echo Html::jumbotron( - * '

Hello, world

This is a simple jumbotron-style component for calling extra attention to featured content or information.

' + * '

Hello, world

This is a simple jumbotron-style component for calling extra attention to featured + * content or information.

' * ); * echo Html::jumbotron( * [ * 'heading' => 'Hello, world!', - * 'body' => 'This is a simple jumbotron-style component for calling extra attention to featured content or information.' + * 'body' => 'This is a simple jumbotron-style component for calling extra attention to featured content or + * information.' * ] * ); * echo Html::jumbotron([ * 'heading' => 'Hello, world!', - * 'body' => 'This is a simple jumbotron-style component for calling extra attention to featured content or information.', + * 'body' => 'This is a simple jumbotron-style component for calling extra attention to featured content or + * information.', * 'buttons' => [ * [ * 'label' => 'Learn More', @@ -292,7 +288,7 @@ protected static function generateListGroupItem($item, $tag) * ]); * ~~~ * - * @see http://getbootstrap.com/components/#jumbotron + * @return string */ public static function jumbotron($content = [], $fullWidth = false, $options = []) { @@ -331,91 +327,76 @@ public static function jumbotron($content = [], $fullWidth = false, $options = [ /** * Generates a panel for boxing content. * - * @param array $content the panel content consisting of these components: - * - @param string $preHeading raw content that will be placed before $heading (optional) - * - @param string $heading the panel box heading (optional) - * - @param string $preBody raw content that will be placed before $body (optional) - * - @param string $body the panel body content - this will be wrapped in a "panel-body" container (optional) - * - @param string $postBody raw content that will be placed after $body (optional) - * - @param string $footer the panel box footer (optional) - * - @param string $postFooter raw content that will be placed after $footer (optional) - * - @param boolean $headingTitle whether to pre-style heading content with a '.panel-title' class. - * - @param boolean $footerTitle whether to pre-style footer content with a '.panel-title' class. - * @param string $type the panel type one of the color modifier constants - defaults to 'default' - * - TYPE_DEFAULT = 'default' - * - TYPE_PRIMARY = 'primary' - * - TYPE_SUCCESS = 'success' - * - TYPE_INFO = 'info' - * - TYPE_WARNING = 'warning' - * - TYPE_DANGER = 'danger' - * @param array $options html options for the panel container - * - * Example(s): - * ~~~ - * echo Html::panel( - * ['heading' => 'Panel Heading', 'body' => 'Panel Content'], - * Html::TYPE_SUCCESS - * ); - * echo Html::panel( - * [ - * 'heading' => 'Panel Heading', - * 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' . - * 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', - * 'postBody' => Html::listGroup([ - * [ - * 'content' => 'Cras justo odio', - * 'url' => '#', - * 'badge' => '14' - * ], - * [ - * 'content' => 'Dapibus ac facilisis in', - * 'url' => '#', - * 'badge' => '2' - * ], - * [ - * 'content' => 'Morbi leo risus', - * 'url' => '#', - * 'badge' => '1' - * ], - * ], [], 'ul', 'li'), - * 'footer'=> 'Panel Footer', - * 'headingTitle' => true, - * 'footerTitle' => true, - * ] - * ); - * ~~~ - * - * @param array $options html options for the panel * @see http://getbootstrap.com/components/#panels + * + * @param array $content the panel content configuration. The following properties can be setup: + * - `preHeading`: string, raw content that will be placed before `heading` (optional). + * - `heading`: string, the panel box heading (optional). + * - `preBody`: string, raw content that will be placed before $body (optional). + * - `body`: string, the panel body content - this will be wrapped in a "panel-body" container (optional). + * - `postBody`: string, raw content that will be placed after $body (optional). + * - `footer`: string, the panel box footer (optional). + * - `postFooter`: string, raw content that will be placed after $footer (optional). + * - `headingTitle`: bool, whether to pre-style heading content with a '.panel-title' class. Defaults to + * `false`. + * - `footerTitle`: bool, whether to pre-style footer content with a '.panel-title' class. Defaults to `false`. + * @param string $type the panel type which can be one of the bootstrap color modifier constants. Defaults to + * `default`. + * - `Html::TYPE_DEFAULT` or `default` + * - `Html::TYPE_PRIMARY` or `primary` + * - `Html::TYPE_SUCCESS` or `success` + * - `Html::TYPE_INFO` or `info` + * - `Html::TYPE_WARNING` or `warning` + * - `Html::TYPE_DANGER` or `danger` + * @param array $options HTML attributes / options for the panel container + * @param string $prefix the CSS prefix for panel type. Defaults to `panel panel-`. + * + * @return string */ - public static function panel($content = [], $type = 'default', $options = []) + public static function panel($content = [], $type = 'default', $options = [], $prefix = 'panel panel-') { if (!is_array($content)) { return ''; } else { - static::addCssClass($options, 'panel panel-' . $type); - $panel = (!Enum::isEmpty($content['preHeading'])) ? $content['preHeading'] . "\n" : ''; - $panel .= static::generatePanelTitle($content, 'heading'); - $panel .= (!Enum::isEmpty($content['preBody'])) ? $content['preBody'] . "\n" : ''; - $panel .= (!Enum::isEmpty($content['body'])) ? static::tag('div', $content['body'], ['class' => 'panel-body']) . "\n" : ''; - $panel .= (!Enum::isEmpty($content['postBody'])) ? $content['postBody'] . "\n" : ''; - $panel .= static::generatePanelTitle($content, 'footer'); - $panel .= (!Enum::isEmpty($content['postFooter'])) ? $content['postFooter'] . "\n" : ''; + static::addCssClass($options, $prefix . $type); + $panel = static::getPanelContent($content, 'preHeading') . + static::getPanelTitle($content, 'heading') . + static::getPanelContent($content, 'preBody') . + static::getPanelContent($content, 'body') . + static::getPanelContent($content, 'postBody') . + static::getPanelTitle($content, 'footer') . + static::getPanelContent($content, 'postFooter'); return static::tag('div', $panel, $options); } } + /** + * Generates panel content + * + * @param array $content the panel content components. + * @param string $type one of the content settings + * + * @return string + */ + protected static function getPanelContent($content, $type) + { + $out = ArrayHelper::getValue($content, $type, ''); + return Enum::isEmpty($out) ? $out . "\n" : ''; + } + /** * Generates panel title for heading and footer. * - * @param array $content the panel content components. - * @param string $type whether 'heading' or 'footer' + * @param array $content the panel content settings. + * @param string $type whether `heading` or `footer` + * + * @return string */ - protected static function generatePanelTitle($content, $type) + protected static function getPanelTitle($content, $type) { if (!Enum::isEmpty($content[$type])) { $title = $content[$type]; - if (isset($content["{$type}Title"]) && $content["{$type}Title"]) { + if (ArrayHelper::getValue($content, "{$type}Title", true) === true) { $title = static::tag("h3", $title, ["class" => "panel-title"]); } return static::tag("div", $title, ["class" => "panel-{$type}"]) . "\n"; @@ -427,9 +408,11 @@ protected static function generatePanelTitle($content, $type) /** * Generates a page header. * + * @see http://getbootstrap.com/components/#page-header + * * @param string $title the title to be shown * @param string $subTitle the subtitle to be shown as subtext within the title - * @param array $options html options for the page header + * @param array $options HTML attributes/ options for the page header * * Example(s): * ~~~ @@ -439,7 +422,7 @@ protected static function generatePanelTitle($content, $type) * ); * ~~~ * - * @see http://getbootstrap.com/components/#page-header + * @return string */ public static function pageHeader($title, $subTitle = '', $options = []) { @@ -455,23 +438,17 @@ public static function pageHeader($title, $subTitle = '', $options = []) /** * Generates a well container. * - * @param string $content the content - * @param string $size the well size - one of the size constants - * - SIZE_TINY = 'xs'; - * - SIZE_SMALL = 'sm'; - * - SIZE_MEDIUM = 'md'; - * - SIZE_LARGE = 'lg'; - * @param array $options html options for the well container. - * - * Example(s): - * ~~~ - * echo Html::well( - * 'Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo.', - * Html::LARGE - * ); - * ~~~ - * * @see http://getbootstrap.com/components/#wells + * + * @param string $content the content + * @param string $size the well size. Should be one of the bootstrap size modifiers: + * - `Html::SIZE_TINY` or `xs` + * - `Html::SIZE_SMALL` or `sm` + * - `Html::SIZE_MEDIUM` or `md` + * - `Html::SIZE_LARGE` or `lg` + * @param array $options HTML attributes / options for the well container. + * + * @return string */ public static function well($content, $size = '', $options = []) { @@ -483,18 +460,19 @@ public static function well($content, $size = '', $options = []) } /** - * Generates a media object. Abstract object styles for building various types of - * components (like blog comments, Tweets, etc) that feature a left-aligned or - * right-aligned image alongside textual content. - * - * @param string $heading the media heading - * @param string $body the media content - * @param string $src URL for the media article source - * @param string $img URL for the media image source - * @param array $srcOptions html options for the media article link - * @param array $imgOptions html options for the media image - * @param array $options html options for the media object container - * @param string $tag the media container tag - defaults to 'div' + * Generates a bootstrap media object. Abstract object styles for building various types of components (like blog + * comments, Tweets, etc) that feature a left-aligned or right-aligned image alongside textual content. + * + * @see http://getbootstrap.com/components/#media + * + * @param string $heading the media heading. + * @param string $body the media content. + * @param mixed $src URL for the media article source. + * @param mixed $img URL for the media image source. + * @param array $srcOptions html options for the media article link. + * @param array $imgOptions html options for the media image. + * @param array $options HTML attributes / options for the media object container. + * @param string $tag the media container tag. Defaults to 'div'. * * Example(s): * ~~~ @@ -506,10 +484,18 @@ public static function well($content, $size = '', $options = []) * ); * ~~~ * - * @see http://getbootstrap.com/components/#media + * @return string */ - public static function media($heading = '', $body = '', $src = '', $img = '', $srcOptions = [], $imgOptions = [], $options = [], $tag = 'div') - { + public static function media( + $heading = '', + $body = '', + $src = '', + $img = '', + $srcOptions = [], + $imgOptions = [], + $options = [], + $tag = 'div' + ) { static::addCssClass($options, 'media'); if (!isset($srcOptions['class'])) { @@ -519,46 +505,51 @@ public static function media($heading = '', $body = '', $src = '', $img = '', $s static::addCssClass($imgOptions, 'media-object'); $source = static::a(static::img($img, $imgOptions), $src, $srcOptions); - $heading = (!Enum::isEmpty($heading)) ? static::tag('h4', $heading, ['class' => 'media-heading']) : ''; - $content = (!Enum::isEmpty($body)) ? static::tag('div', $heading . "\n" . $body, ['class' => 'media-body']) : $heading; - + $heading = !Enum::isEmpty($heading) ? static::tag('h4', $heading, ['class' => 'media-heading']) : ''; + $content = !Enum::isEmpty($body) ? static::tag('div', $heading . "\n" . $body, ['class' => 'media-body']) : + $heading; return static::tag($tag, $source . "\n" . $content, $options); } /** - * Generates list of media (useful for comment threads or articles lists). - * - * @param array $items the media items - each element in the array will contain these keys: - * - @param string $items the sub media items (optional) - * - @param string $heading the media heading - * - @param string $body the media content - * - @param string $src URL for the media article source - * - @param string $img URL for the media image source - * - @param array $srcOptions html options for the media article link (optional) - * - @param array $imgOptions html options for the media image (optional) - * - @param array $itemOptions html options for each media item (optional) - * @param array $options html options for the media list container + * Generates bootstrap list of media (useful for comment threads or articles lists). + * + * @see http://getbootstrap.com/components/#media + * + * @param array $items the configuration of media items. The following properties can be set as array keys: + * - `items`: array, the sub media items (similar in configuration to items) (optional) + * - `heading`: string, the media heading + * - `body`: string, the media content + * - `src`: mixed, URL for the media article source + * - `img`: mixed, URL for the media image source + * - `srcOptions`: array, HTML attributes / options for the media article link (optional) + * - `imgOptions`: array, HTML attributes / options for the media image (optional) + * - `itemOptions`: array, HTML attributes / options for each media item (optional) + * @param array $options HTML attributes / options for the media list container * * Example(s): * ~~~ * echo Html::mediaList([ * [ * 'heading' => 'Media heading 1', - * 'body' => 'Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. '. + * 'body' => 'Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin + * commodo. '. * 'Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.', * 'src' => '#', * 'img' => 'http://placehold.it/64x64', * 'items' => [ * [ * 'heading' => 'Media heading 1.1', - * 'body' => 'Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. ' . + * 'body' => 'Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante + * sollicitudin commodo. ' . * 'Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.', * 'src' => '#', * 'img' => 'http://placehold.it/64x64' * ], * [ * 'heading' => 'Media heading 1.2', - * 'body' => 'Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. ' . + * 'body' => 'Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante + * sollicitudin commodo. ' . * 'Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.', * 'src' => '#', * 'img' => 'http://placehold.it/64x64' @@ -567,7 +558,8 @@ public static function media($heading = '', $body = '', $src = '', $img = '', $s * ], * [ * 'heading' => 'Media heading 2', - * 'body' => 'Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. '. + * 'body' => 'Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin + * commodo. '. * 'Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.', * 'src' => '#', * 'img' => 'http://placehold.it/64x64' @@ -575,7 +567,7 @@ public static function media($heading = '', $body = '', $src = '', $img = '', $s * ]); * ~~~ * - * @see http://getbootstrap.com/components/#media + * @return string */ public static function mediaList($items = [], $options = []) { @@ -587,8 +579,10 @@ public static function mediaList($items = [], $options = []) /** * Processes media items array to generate a recursive list. * - * @param array $items the media items + * @param array $items the media items * @param boolean $top whether item is the topmost parent + * + * @return string */ protected static function generateMediaList($items, $top = true) { @@ -606,8 +600,10 @@ protected static function generateMediaList($items, $top = true) /** * Processes and generates each media item * - * @param array $item the media item configuration + * @param array $item the media item configuration * @param string $tag the media item container tag + * + * @return string */ protected static function generateMediaItem($item, $tag) { @@ -622,12 +618,13 @@ protected static function generateMediaItem($item, $tag) } /** - * Generates a generic close icon button for - * dismissing content like modals and alerts. + * Generates a generic bootstrap close icon button for dismissing content like modals and alerts. + * + * @see http://getbootstrap.com/css/#helper-classes-close * - * @param string $label the close icon label - defaults to '×' - * @param array $options html options for the close icon button - * @param string $tag the html tag for rendering the close icon - defaults to 'button' + * @param string $label the close icon label. Defaults to `×`. + * @param array $options HTML attributes / options for the close icon button. + * @param string $tag the HTML tag for rendering the close icon. Defaults to `button`. * * Example(s): * ~~~ @@ -635,7 +632,7 @@ protected static function generateMediaItem($item, $tag) * echo Html::closeButton(Html::icon('remove-sign'); * ~~~ * - * @see http://getbootstrap.com/css/#helper-classes-close + * @return string */ public static function closeButton($label = '×', $options = [], $tag = 'button') { @@ -648,12 +645,14 @@ public static function closeButton($label = '×', $options = [], $tag = 'bu } /** - * Generates a caret. + * Generates a bootstrap caret. + * + * @see http://getbootstrap.com/css/#helper-classes-carets * - * @param string $direction whether to display as 'up' or 'down' direction - defaults to 'down' - * @param boolean $disabled if the caret is to be displayed as disabled - defaults to false - * @param array $options html options for the caret container. - * @param string $tag the html tag for rendering the caret - defaults to 'span' + * @param string $direction whether to display as 'up' or 'down' direction. Defaults to `down`. + * @param boolean $disabled if the caret is to be displayed as disabled. Defaults to `false`. + * @param array $options html options for the caret container. + * @param string $tag the html tag for rendering the caret. Defaults to `span`. * * Example(s): * ~~~ @@ -662,7 +661,7 @@ public static function closeButton($label = '×', $options = [], $tag = 'bu * echo 'Disabled Caret ' . Html::caret('down', true); * ~~~ * - * @see http://getbootstrap.com/css/#helper-classes-carets + * @return string */ public static function caret($direction = 'down', $disabled = false, $options = [], $tag = 'span') { @@ -684,12 +683,14 @@ public static function caret($direction = 'down', $disabled = false, $options = } /** - * Generates an abbreviation. + * Generates a bootstrap abbreviation. + * + * @see http://getbootstrap.com/css/#type-abbreviations * - * @param string $content the abbreviation content - * @param string $title the abbreviation title + * @param string $content the abbreviation content + * @param string $title the abbreviation title * @param boolean $initialism if set to true, will display a slightly smaller font-size. - * @param array $options html options for the abbreviation + * @param array $options html options for the abbreviation * * Example(s): * ~~~ @@ -697,7 +698,7 @@ public static function caret($direction = 'down', $disabled = false, $options = * echo Html::abbr('HTML', 'HyperText Markup Language', true); * ~~~ * - * @see http://getbootstrap.com/css/#type-abbreviations + * @return string */ public static function abbr($content, $title, $initialism = false, $options = []) { @@ -709,14 +710,16 @@ public static function abbr($content, $title, $initialism = false, $options = [] } /** - * Generates a blockquote. + * Generates a bootstrap blockquote. + * + * @see http://getbootstrap.com/css/#type-blockquotes * * @param string $content the blockquote content - * @param string $citeContent the content of the citation (optional) - this should typically - * include the wildtag '{source}' to embed the cite source + * @param string $citeContent the content of the citation (optional) - this should typically include the tag + * '{source}' to embed the cite source * @param string $citeTitle the cite source title (optional) * @param string $citeSource the cite source (optional) - * @param array $options html options for the blockquote + * @param array $options html options for the blockquote * * Example(s): * ~~~ @@ -728,8 +731,7 @@ public static function abbr($content, $title, $initialism = false, $options = [] * ); * ~~~ * - * @param array $options html options for the blockquote - * @see http://getbootstrap.com/css/#type-blockquotes + * @return string */ public static function blockquote($content, $citeContent = '', $citeTitle = '', $citeSource = '', $options = []) { @@ -742,17 +744,19 @@ public static function blockquote($content, $citeContent = '', $citeTitle = '', } /** - * Generates an address block. + * Generates a bootstrap address block. + * + * @see http://getbootstrap.com/css/#type-addresses * * @param string $name the addressee name - * @param array $lines the lines of address information - * @param array $phone the list of phone numbers - passed as $key => $value, where: - * - $key is the phone type could be 'Res', 'Off', 'Cell', 'Fax' - * - $value is the phone number - * @param array $email the list of email addresses - passed as $key => $value, where: - * - $key is the email type could be 'Res', 'Off' - * - $value is the email address - * @param array $options html options for the address + * @param array $lines the lines of address information + * @param array $phone the list of phone numbers - passed as $key => $value, where: + * - `$key`: string, is the phone type could be 'Res', 'Off', 'Cell', 'Fax' + * - `$value`: string, is the phone number + * @param array $email the list of email addresses - passed as $key => $value, where: + * - `$key`: string, is the email type could be 'Res', 'Off' + * - `$value`: string, is the email address + * @param array $options html options for the address * @param string $phoneLabel the prefix label for each phone - defaults to '(P)' * @param string $emailLabel the prefix label for each email - defaults to '(E)' * @@ -775,13 +779,20 @@ public static function blockquote($content, $citeContent = '', $citeTitle = '', * echo Html::well($address, Html::SIZE_TINY); * ~~~ * - * @see http://getbootstrap.com/css/#type-addresses + * @return string */ - public static function address($name, $lines = [], $phone = [], $email = [], $options = [], $phoneLabel = '(P)', $emailLabel = '(E)') - { + public static function address( + $name, + $lines = [], + $phone = [], + $email = [], + $options = [], + $phoneLabel = '(P)', + $emailLabel = '(E)' + ) { Enum::initI18N(); $addresses = ''; - if (!empty($lines)) { + if (!Enum::isEmpty($lines)) { $addresses = implode('
', $lines) . "
\n"; } @@ -806,35 +817,36 @@ public static function address($name, $lines = [], $phone = [], $email = [], $op } return static::tag('address', "{$name}
\n" . $addresses . $phones . $emails, $options); } - + /** * Generates a bootstrap toggle button group (checkbox or radio type) - * - * @param string $type whether checkbox or radio. - * @param string $name the name attribute of each checkbox. - * @param string|array $selection the selected value(s). - * @param array $items the data item used to generate the checkboxes/radios. - * The array keys are the checkbox/radio values, while the array values are the corresponding labels. - * @param array $options options (name => config) for the checkbox/radio list container tag. - * The following options are specially handled: * + * @see http://getbootstrap.com/javascript/#buttons-checkbox-radio + * + * @param string $type whether checkbox or radio. + * @param string $name the name attribute of each checkbox. + * @param string|array $selection the selected value(s). + * @param array $items the data item used to generate the checkboxes/radios. The array keys are the + * checkbox/radio values, while the array values are the corresponding labels. + * @param array $options options (name => config) for the checkbox/radio list container tag. The following + * options are specially handled: * - tag: string, the tag name of the container element. - * - unselect: string, the value that should be submitted when none of the checkboxes/radios is selected. - * By setting this option, a hidden input will be generated. - * - encode: boolean, whether to HTML-encode the checkbox/radio labels. Defaults to true. - * This option is ignored if `item` option is set. + * - unselect: string, the value that should be submitted when none of the checkboxes/radios is selected. By + * setting this option, a hidden input will be generated. + * - encode: boolean, whether to HTML-encode the checkbox/radio labels. Defaults to `true`. This option is ignored + * if `item` option is set. * - separator: string, the HTML code that separates items. * - itemOptions: array, the options for generating the checkbox/radio tag using [[checkbox/radio()]]. - * - item: callable, a callback that can be used to customize the generation of the HTML code - * corresponding to a single item in $items. The signature of this callback must be: + * - item: callable, a callback that can be used to customize the generation of the HTML code corresponding to a + * single item in $items. The signature of this callback must be: * * ~~~ * function ($index, $label, $name, $checked, $value) * ~~~ * - * where $index is the zero-based index of the checkbox/radio in the whole list; $label - * is the label for the checkbox/radio; and $name, $value and $checked represent the name, - * value and the checked status of the checkbox/radio input, respectively. + * where $index is the zero-based index of the checkbox/radio in the whole list; $label is the label for the + * checkbox/radio; and $name, $value and $checked represent the name, value and the checked status of the + * checkbox/radio input, respectively. * * See [[renderTagAttributes()]] for details on how attributes are being rendered. * @@ -849,7 +861,15 @@ public static function getButtonGroup($type, $name, $selection = null, $items = if (!isset($options['itemOptions']['labelOptions']['class'])) { $options['itemOptions']['labelOptions']['class'] = 'btn btn-default'; } - $options['item'] = function ($index, $label, $name, $checked, $value) use($type, $options) { + /** @noinspection PhpUnusedParameterInspection */ + /** + * @param string $index + * @param string $label + * @param string $name + * @param bool $checked + * @param string $value + */ + $options['item'] = function ($index, $label, $name, $checked, $value) use ($type, $options) { $opts = isset($options['itemOptions']) ? $options['itemOptions'] : []; $encode = !isset($options['encode']) || $options['encode']; if (!isset($opts['labelOptions'])) { @@ -865,18 +885,19 @@ public static function getButtonGroup($type, $name, $selection = null, $items = }; return static::$class($name, $selection, $items, $options); } - + /** - * Generates a bootstrap checkbox button group. A checkbox button group allows multiple selection, + * Generates a bootstrap checkbox button group. A checkbox button group allows multiple selection, * like [[listBox()]]. As a result, the corresponding submitted value is an array. - * - * @param string $name the name attribute of each checkbox. - * @param string|array $selection the selected value(s). - * @param array $items the data item used to generate the checkboxes. - * The array keys are the checkbox values, while the array values are the corresponding labels. - * @param array $options options (name => config) for the checkbox list container tag. - * The following options are specially handled: * + * @see http://getbootstrap.com/javascript/#buttons-checkbox-radio + * + * @param string $name the name attribute of each checkbox. + * @param mixed $selection the selected value(s). + * @param array $items the data item used to generate the checkboxes. The array keys are the checkbox values, + * while the array values are the corresponding labels. + * @param array $options options (name => config) for the checkbox list container tag. The following options are + * specially handled: * - tag: string, the tag name of the container element. * - unselect: string, the value that should be submitted when none of the checkboxes is selected. * By setting this option, a hidden input will be generated. @@ -891,88 +912,92 @@ public static function getButtonGroup($type, $name, $selection = null, $items = * function ($index, $label, $name, $checked, $value) * ~~~ * - * where $index is the zero-based index of the checkbox in the whole list; $label - * is the label for the checkbox; and $name, $value and $checked represent the name, - * value and the checked status of the checkbox input, respectively. + * where $index is the zero-based index of the checkbox in the whole list; $label is the label for the checkbox; + * and $name, $value and $checked represent the name, value and the checked status of the checkbox input, + * respectively. * * See [[renderTagAttributes()]] for details on how attributes are being rendered. * * @return string the generated checkbox button group - */ + */ public static function checkboxButtonGroup($name, $selection = null, $items = [], $options = []) { return static::getButtonGroup('checkbox', $name, $selection, $items, $options); } - + /** - * Generates a bootstrap radio button group. A radio button group is like a checkbox button group, - * except that it only allows single selection. - * + * Generates a bootstrap radio button group. A radio button group is like a checkbox button group, except that it + * only allows single selection. + * + * @see http://getbootstrap.com/javascript/#buttons-checkbox-radio + * * @param string $name the name attribute of each radio. - * @param string|array $selection the selected value(s). - * @param array $items the data item used to generate the radioes. - * The array keys are the radio values, while the array values are the corresponding labels. - * @param array $options options (name => config) for the radio list container tag. - * The following options are specially handled: + * @param mixed $selection the selected value(s). + * @param array $items the data item used to generate the radios. The array keys are the radio values, while the + * array values are the corresponding labels. + * @param array $options options (name => config) for the radio list container tag. The following options are + * specially handled: * * - tag: string, the tag name of the container element. - * - unselect: string, the value that should be submitted when none of the radioes is selected. - * By setting this option, a hidden input will be generated. - * - encode: boolean, whether to HTML-encode the radio labels. Defaults to true. - * This option is ignored if `item` option is set. + * - unselect: string, the value that should be submitted when none of the radios is selected. By setting this + * option, a hidden input will be generated. + * - encode: boolean, whether to HTML-encode the radio labels. Defaults to `true`. This option is ignored if `item` + * option is set. * - separator: string, the HTML code that separates items. * - itemOptions: array, the options for generating the radio tag using [[radio()]]. - * - item: callable, a callback that can be used to customize the generation of the HTML code - * corresponding to a single item in $items. The signature of this callback must be: + * - item: callable, a callback that can be used to customize the generation of the HTML code corresponding to a + * single item in $items. The signature of this callback must be: * * ~~~ * function ($index, $label, $name, $checked, $value) * ~~~ * - * where $index is the zero-based index of the radio in the whole list; $label - * is the label for the radio; and $name, $value and $checked represent the name, - * value and the checked status of the radio input, respectively. + * where $index is the zero-based index of the radio in the whole list; $label is the label for the radio; and + * $name, $value and $checked represent the name, value and the checked status of the radio input, + * respectively. * * See [[renderTagAttributes()]] for details on how attributes are being rendered. * * @return string the generated radio button group - */ + */ public static function radioButtonGroup($name, $selection = null, $items = [], $options = []) { return static::getButtonGroup('radio', $name, $selection, $items, $options); } /** - * Generates an active bootstrap checkbox button group. A checkbox button group allows multiple selection, - * like [[listBox()]]. As a result, the corresponding submitted value is an array. The selection of the - * checkbox button group is taken from the value of the model attribute. - * @param Model $model the model object - * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format - * about attribute expression. - * @param array $items the data item used to generate the checkboxes. - * The array keys are the checkbox values, and the array values are the corresponding labels. - * Note that the labels will NOT be HTML-encoded, while the values will. - * @param array $options options (name => config) for the checkbox list container tag. - * The following options are specially handled: + * Generates an active bootstrap checkbox button group. A checkbox button group allows multiple selection, like + * [[listBox()]]. As a result, the corresponding submitted value is an array. The selection of the checkbox button + * group is taken from the value of the model attribute. + * + * @see http://getbootstrap.com/javascript/#buttons-checkbox-radio + * + * @param Model $model the model object + * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format about + * attribute expression. + * @param array $items the data item used to generate the checkboxes. The array keys are the checkbox values, and + * the array values are the corresponding labels. Note that the labels will NOT be HTML-encoded, while the + * values will. + * @param array $options options (name => config) for the checkbox list container tag. The following options are + * specially handled: * * - tag: string, the tag name of the container element. - * - unselect: string, the value that should be submitted when none of the checkboxes is selected. - * You may set this option to be null to prevent default value submission. - * If this option is not set, an empty string will be submitted. - * - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true. - * This option is ignored if `item` option is set. + * - unselect: string, the value that should be submitted when none of the checkboxes is selected. You may set this + * option to be null to prevent default value submission. If this option is not set, an empty string will be + * submitted. + * - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to `true`. This option is ignored if + * `item` option is set. * - separator: string, the HTML code that separates items. * - itemOptions: array, the options for generating the checkbox tag using [[checkbox()]]. - * - item: callable, a callback that can be used to customize the generation of the HTML code - * corresponding to a single item in $items. The signature of this callback must be: + * - item: callable, a callback that can be used to customize the generation of the HTML code corresponding to a + * single item in $items. The signature of this callback must be: * * ~~~ * function ($index, $label, $name, $checked, $value) * ~~~ * - * where $index is the zero-based index of the checkbox in the whole list; $label - * is the label for the checkbox; and $name, $value and $checked represent the name, - * value and the checked status of the checkbox input. + * where $index is the zero-based index of the checkbox in the whole list; $label is the label for the checkbox; + * and $name, $value and $checked represent the name, value and the checked status of the checkbox input. * * See [[renderTagAttributes()]] for details on how attributes are being rendered. * @@ -984,36 +1009,39 @@ public static function activeCheckboxButtonGroup($model, $attribute, $items, $op } /** - * Generates an active bootstrap radio button group. A radio button group is like a checkbox button group, - * except that it only allows single selection. The selection of the radio buttons is taken from the value - * of the model attribute. - * @param Model $model the model object - * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format - * about attribute expression. - * @param array $items the data item used to generate the radio buttons. - * The array keys are the radio values, and the array values are the corresponding labels. - * Note that the labels will NOT be HTML-encoded, while the values will. - * @param array $options options (name => config) for the radio button list container tag. + * Generates an active bootstrap radio button group. A radio button group is like a checkbox button group, except + * that it only allows single selection. The selection of the radio buttons is taken from the value of the model + * attribute. + * + * @see http://getbootstrap.com/javascript/#buttons-checkbox-radio + * + * @param Model $model the model object + * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format about + * attribute expression. + * @param array $items the data item used to generate the radio buttons. The array keys are the radio values, and + * the array values are the corresponding labels. Note that the labels will NOT be HTML-encoded, while the + * values will. + * @param array $options options (name => config) for the radio button list container tag. * The following options are specially handled: * * - tag: string, the tag name of the container element. - * - unselect: string, the value that should be submitted when none of the radio buttons is selected. - * You may set this option to be null to prevent default value submission. - * If this option is not set, an empty string will be submitted. - * - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true. - * This option is ignored if `item` option is set. + * - unselect: string, the value that should be submitted when none of the radio buttons is selected. You may set + * this option to be null to prevent default value submission. If this option is not set, an empty string will + * be submitted. + * - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to `true`. This option is ignored if + * `item` option is set. * - separator: string, the HTML code that separates items. * - itemOptions: array, the options for generating the radio button tag using [[radio()]]. - * - item: callable, a callback that can be used to customize the generation of the HTML code - * corresponding to a single item in $items. The signature of this callback must be: + * - item: callable, a callback that can be used to customize the generation of the HTML code corresponding to a + * single item in $items. The signature of this callback must be: * * ~~~ * function ($index, $label, $name, $checked, $value) * ~~~ * - * where $index is the zero-based index of the radio button in the whole list; $label - * is the label for the radio button; and $name, $value and $checked represent the name, - * value and the checked status of the radio button input. + * where $index is the zero-based index of the radio button in the whole list; $label is the label for the radio + * button; and $name, $value and $checked represent the name, value and the checked status of the radio button + * input. * * See [[renderTagAttributes()]] for details on how attributes are being rendered. * @@ -1023,4 +1051,4 @@ public static function activeRadioButtonGroup($model, $attribute, $items, $optio { return static::activeListInput('radioButtonGroup', $model, $attribute, $items, $options); } -} \ No newline at end of file +} diff --git a/messages/it/kvenum.php b/messages/it/kvenum.php index bc81542..9da8a6f 100644 --- a/messages/it/kvenum.php +++ b/messages/it/kvenum.php @@ -17,102 +17,102 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return [ - 'Amaya' => 'Amaya', - 'Apple Safari' => 'Apple Safari', - 'April' => 'Aprile', - 'Arora' => 'Arora', - 'August' => 'Agosto', - 'Avant' => 'Avant', - 'Blackberry' => 'Blackberry', - 'Chromium' => 'Chromium', - 'December' => 'Dicembre', - 'Email' => 'Email', - 'Epiphany' => 'Epifania', - 'February' => 'Febbraio', - 'Friday' => 'Venerdì', - 'Galeon' => 'Galeon', - 'Google Chrome' => 'Google Chrome', - 'January' => 'Gennaio', - 'July' => 'Luglio', - 'June' => 'Giugno', - 'Konqueror' => 'Konqueror', - 'March' => 'Marzo', - 'Maxthon' => 'Maxthon', - 'May' => 'Maggio', - 'Microsoft Internet Explorer' => 'Microsoft Internet Explorer', - 'Microsoft Internet Explorer Mobile' => 'Microsoft Internet Explorer Mobile', - 'Minimo' => 'Minimo', - 'Mobile Safari' => 'Mobile Safari', - 'Monday' => 'Lunedì', - 'Mosaic' => 'Mosaic', - 'Mozilla Firefox' => 'Mozilla Firefox', - 'Mozilla Firefox Fennec' => 'Mozilla Firefox Fennec', - 'Mozilla Sea Monkey' => 'Mozilla Sea Monkey', - 'NetFront' => 'NetFront', - 'NetSurf' => 'NetSurf', - 'Netscape' => 'Netscape', - 'No' => 'No', - 'November' => 'Novembre', - 'October' => 'Ottobre', - 'Omniweb' => 'Omniweb', - 'Opera' => 'Opera', - 'Phone' => 'Phone', - 'Puffin' => 'Puffin', - 'Safari' => 'Safari', - 'Saturday' => 'Sabato', - 'September' => 'Settembre', - 'Sunday' => 'Domenica', - 'Thursday' => 'Giovedì', - 'Tuesday' => 'Martedì', - 'Wednesday' => 'Mercoledì', - 'Yes' => 'Sì', - 'a moment ago' => 'un attimo fa', - 'ago' => 'fa', - 'billion' => 'Miliardo', - 'eight' => 'otto', - 'eighteen' => 'diciotto', - 'eighty' => 'ottanta', - 'eleven' => 'undici', - 'fifteen' => 'quindici', - 'fifty' => 'cinquanta', - 'five' => 'cinque', - 'forty' => 'quaranta', - 'four' => 'quattro', - 'fourteen' => 'quattordici', - 'hundred' => 'centinaio', - 'million' => 'milione', - 'minus' => 'meno', - 'nine' => 'nove', - 'nineteen' => 'diciannove', - 'ninety' => 'novanta', - 'nonillion' => 'nonillion', - 'octillion' => 'octillion', - 'one' => 'uno', + 'Amaya' => '', + 'Apple Safari' => '', + 'April' => '', + 'Arora' => '', + 'August' => '', + 'Avant' => '', + 'Blackberry' => '', + 'Chromium' => '', + 'December' => '', + 'Email' => '', + 'Epiphany' => '', + 'February' => '', + 'Friday' => '', + 'Galeon' => '', + 'Google Chrome' => '', + 'January' => '', + 'July' => '', + 'June' => '', + 'Konqueror' => '', + 'March' => '', + 'Maxthon' => '', + 'May' => '', + 'Microsoft Internet Explorer' => '', + 'Microsoft Internet Explorer Mobile' => '', + 'Minimo' => '', + 'Mobile Safari' => '', + 'Monday' => '', + 'Mosaic' => '', + 'Mozilla Firefox' => '', + 'Mozilla Firefox Fennec' => '', + 'Mozilla Sea Monkey' => '', + 'NetFront' => '', + 'NetSurf' => '', + 'Netscape' => '', + 'No' => '', + 'November' => '', + 'October' => '', + 'Omniweb' => '', + 'Opera' => '', + 'Phone' => '', + 'Puffin' => '', + 'Safari' => '', + 'Saturday' => '', + 'September' => '', + 'Sunday' => '', + 'Thursday' => '', + 'Tuesday' => '', + 'Wednesday' => '', + 'Yes' => '', + 'a moment ago' => '', + 'ago' => '', + 'billion' => '', + 'eight' => '', + 'eighteen' => '', + 'eighty' => '', + 'eleven' => '', + 'fifteen' => '', + 'fifty' => '', + 'five' => '', + 'forty' => '', + 'four' => '', + 'fourteen' => '', + 'hundred' => '', + 'million' => '', + 'minus' => '', + 'nine' => '', + 'nineteen' => '', + 'ninety' => '', + 'nonillion' => '', + 'octillion' => '', + 'one' => '', 'quadrillion' => '', 'quintillion' => '', 'septillion' => '', - 'seven' => 'sette', - 'seventeen' => 'diciassette', - 'seventy' => 'settanta', + 'seven' => '', + 'seventeen' => '', + 'seventy' => '', 'sextillion' => '', - 'six' => 'sei', - 'sixteen' => 'sedici', - 'sixty' => 'sessanta', - 'ten' => 'dieci', - 'thirteen' => 'tredici', - 'thirty' => 'trenta', - 'thousand' => 'mille', - 'three' => 'tre', - 'trillion' => 'trilione', - 'twelve' => 'dodici', - 'twenty' => 'venti', - 'two' => 'due', - 'zero' => 'zero', - '{n, plural, one{un giorno} other{# giorni}}' => '', - '{n, plural, one{un ora} other{# ore}}' => '', - '{n, plural, one{un minuto} other{# minuti}}' => '', - '{n, plural, one{un mese} other{# mesi}}' => '', - '{n, plural, one{un secondo} other{# secondi}}' => '', - '{n, plural, one{una settimana} other{# settimane}}' => '', - '{n, plural, one{un anno} other{# anni}}' => '', + 'six' => '', + 'sixteen' => '', + 'sixty' => '', + 'ten' => '', + 'thirteen' => '', + 'thirty' => '', + 'thousand' => '', + 'three' => '', + 'trillion' => '', + 'twelve' => '', + 'twenty' => '', + 'two' => '', + 'zero' => '', + '{n, plural, one{one day} other{# days}}' => '', + '{n, plural, one{one hour} other{# hours}}' => '', + '{n, plural, one{one minute} other{# minutes}}' => '', + '{n, plural, one{one month} other{# months}}' => '', + '{n, plural, one{one second} other{# seconds}}' => '', + '{n, plural, one{one week} other{# weeks}}' => '', + '{n, plural, one{one year} other{# years}}' => '', ]; diff --git a/messages/uk/kvenum.php b/messages/uk/kvenum.php deleted file mode 100644 index b96abec..0000000 --- a/messages/uk/kvenum.php +++ /dev/null @@ -1,118 +0,0 @@ - 'Amaya', - 'Apple Safari' => 'Apple Safari', - 'April' => 'Квітень', - 'Arora' => 'Arora', - 'August' => 'Серпень', - 'Avant' => 'Avant', - 'Blackberry' => 'Blackberry', - 'Chromium' => 'Chromium', - 'December' => 'Грудень', - 'Email' => 'Email', - 'Epiphany' => 'Хрещення', - 'February' => 'Лютий', - 'Friday' => 'П’ятница', - 'Galeon' => 'Galeon', - 'Google Chrome' => 'Google Chrome', - 'January' => 'Січень', - 'July' => 'Липень', - 'June' => 'Червень', - 'Konqueror' => 'Konqueror', - 'March' => 'Березень', - 'Maxthon' => 'Maxthon', - 'May' => 'Травень', - 'Microsoft Internet Explorer' => 'Microsoft Internet Explorer', - 'Microsoft Internet Explorer Mobile' => 'Microsoft Internet Explorer Mobile', - 'Minimo' => 'Minimo', - 'Mobile Safari' => 'Mobile Safari', - 'Monday' => 'Понеділок', - 'Mosaic' => 'Mosaic', - 'Mozilla Firefox' => 'Mozilla Firefox', - 'Mozilla Firefox Fennec' => 'Mozilla Firefox Fennec', - 'Mozilla Sea Monkey' => 'Mozilla Sea Monkey', - 'NetFront' => 'NetFront', - 'NetSurf' => 'NetSurf', - 'Netscape' => 'Netscape', - 'No' => 'Ні', - 'November' => 'Листопад', - 'October' => 'Жовтень', - 'Omniweb' => 'Omniweb', - 'Opera' => 'Opera', - 'Phone' => 'Телефон', - 'Puffin' => 'Puffin', - 'Safari' => 'Safari', - 'Saturday' => 'Субота', - 'September' => 'Вересень', - 'Sunday' => 'Неділя', - 'Thursday' => 'Четвер', - 'Tuesday' => 'Вівторок', - 'Wednesday' => 'Середа', - 'Yes' => 'Так', - 'a moment ago' => 'щойно', - 'ago' => 'назад', - 'billion' => 'міліардів', - 'eight' => 'вісімь', - 'eighteen' => 'вісімнадцать', - 'eighty' => 'вісімдесят', - 'eleven' => 'одинадцать', - 'fifteen' => 'п’ятнадцать', - 'fifty' => 'п’ятдесят', - 'five' => 'п’ять', - 'forty' => 'сорок', - 'four' => 'чотири', - 'fourteen' => 'чотирнадцать', - 'hundred' => 'сто', - 'million' => 'міліон', - 'minus' => 'мінус', - 'nine' => 'дев’ять', - 'nineteen' => 'дев’ятнадцать', - 'ninety' => 'дев’яносто', - 'nonillion' => 'нонільйон', - 'octillion' => 'октильйон', - 'one' => 'один', - 'quadrillion' => 'квадрильйон', - 'quintillion' => 'квінтіліон', - 'septillion' => 'септиліонів', - 'seven' => 'сім', - 'seventeen' => 'сімнадцать', - 'seventy' => 'сімдесят', - 'sextillion' => 'секстиліонів', - 'six' => 'шість', - 'sixteen' => 'шістнадцать', - 'sixty' => 'шістдесят', - 'ten' => 'десять', - 'thirteen' => 'тринадцать', - 'thirty' => 'тридцять', - 'thousand' => 'тисяча', - 'three' => 'три', - 'trillion' => 'трильйон', - 'twelve' => 'дванадцять', - 'twenty' => 'двадцять', - 'two' => 'два', - 'zero' => 'нуль', - '{n, plural, one{one day} other{# days}}' => '{n, plural, one{один день} few{# дня} many{# днів} other{# дня}}', - '{n, plural, one{one hour} other{# hours}}' => '{n, plural, one{одна година} few{# годин} many{# годин} other{# годин}}', - '{n, plural, one{one minute} other{# minutes}}' => '{n, plural, one{одна хвилина} few{# хвилин} many{# хвилин} other{# хвилин}}', - '{n, plural, one{one month} other{# months}}' => '{n, plural, one{один місяць} few{# місяця} many{# місяців} other{# місяця}}', - '{n, plural, one{one second} other{# seconds}}' => '{n, plural, one{одна секунда} few{# секунди} many{# секунд} other{# секунди}}', - '{n, plural, one{one week} other{# weeks}}' => '{n, plural, one{одна неділя} few{# неділі} many{# неділь} other{# неділі}}', - '{n, plural, one{one year} other{# years}}' => '{n, plural, one{один рік} few{# роки} many{# років} other{# роки}}', -];