diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 9594796..4fd72f1 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -116,7 +116,7 @@ Licensing
---------
It should also be made clear that **all code contributed to yii2-helpers** must be
-licensable under the [BSD-3 license][licensing]. Code that cannot be released
+licensable under the [BSD-3-Clause license][licensing]. Code that cannot be released
under this license **cannot be accepted** into the project.
[issue-search]: https://github.com/kartik-v/yii2-helpers/search?q=&type=Issues
diff --git a/CHANGE.md b/CHANGE.md
index 6cc15d4..0397801 100644
--- a/CHANGE.md
+++ b/CHANGE.md
@@ -1,15 +1,28 @@
Change Log: `yii2-helpers`
==========================
+## Version 1.3.7
+
+**Date:** 26-Sep-2018
+
+- Enhancements to support Bootstrap v4.x.
+- Move all source code to `src` directory.
+- (enh #44): Secure `userIP` function.
+- (enh #43): Update Vietnamese Translations.
+- (enh #42): Update Hungarian Translations.
+- (enh #41): Update German Translations.
+- (enh #40): Fixed `a moment ago` readout.
+- (enh #39): Update Greek Translations.
+
## Version 1.3.6
**Date:** 26-Nov-2016
-- (enh #33): Update Italian Translations.
-- (enh #35): Add Slovak Translations.
-- (enh #36): Update Russian Translations.
-- (enh #37): Update Finnish Translations.
- (bug #38): Fix buttonGroup `item` parsing when set as Closure.
+- (enh #37): Update Finnish Translations.
+- (enh #36): Update Russian Translations.
+- (enh #35): Add Slovak Translations.
+- (enh #33): Update Italian Translations.
- Update message config to include all default standard translation files.
- Add github contribution and issue/PR logging templates.
- Add branch alias for dev-master latest release.
@@ -19,9 +32,9 @@ Change Log: `yii2-helpers`
**Date:** 12-Dec-2015
-- (enh #27): Add Ukranian Translations.
-- (enh #28): Add Italian Translations.
- (enh #29): Code style and formatting enhancements.
+- (enh #28): Add Italian Translations.
+- (enh #27): Add Ukranian Translations.
## Version 1.3.3
@@ -44,23 +57,23 @@ Change Log: `yii2-helpers`
**Date:** 15-Jun-2015
-- (enh #15): Initialize i18N for getBrowser method.
-- (enh #16): Add Russian translation messages.
-- (enh #17, #18): Update Russian translation messages.
-- (enh #19): Add Portuguese Brazilian translation messages.
-- (bug #21): Remove duplicate browsers in list.
- (enh #22): Add Spanish translations.
+- (bug #21): Remove duplicate browsers in list.
+- (enh #19): Add Portuguese Brazilian translation messages.
+- (enh #17, #18): Update Russian translation messages.
+- (enh #16): Add Russian translation messages.
+- (enh #15): Initialize i18N for getBrowser method.
## Version 1.3.0
**Date:** 23-Jan-2015
-- (enh #7): Implement translations.
-- (enh #8): Convert days, months, ones, tens, triplets to static methods
-- (enh #9): Add/Enhance new methods for `dayList`, `monthList` and `dateList`.
-- (enh #10): Enhance `timeList` method to include ranges and intervals.
-- (enh #11): Add French Translations and fix `genCalList`.
- (enh #12): Completed French Translations.
+- (enh #11): Add French Translations and fix `genCalList`.
+- (enh #10): Enhance `timeList` method to include ranges and intervals.
+- (enh #9): Add/Enhance new methods for `dayList`, `monthList` and `dateList`.
+- (enh #8): Convert days, months, ones, tens, triplets to static methods
+- (enh #7): Implement translations.
## Version 1.2.0
diff --git a/README.md b/README.md
index d959c00..2d969f7 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
yii2-helpers
============
-[![Latest Stable Version](https://img.shields.io/packagist/v/kartik-v/yii2-helpers.svg)](https://packagist.org/packages/kartik-v/yii2-helpers)
+[![Latest Stable Version](https://poser.pugx.org/kartik-v/yii2-helpers/v/stable)](https://packagist.org/packages/kartik-v/yii2-helpers)
+[![Latest Unstable Version](https://poser.pugx.org/kartik-v/yii2-helpers/v/unstable)](https://packagist.org/packages/kartik-v/yii2-helpers)
[![License](https://poser.pugx.org/kartik-v/yii2-helpers/license)](https://packagist.org/packages/kartik-v/yii2-helpers)
[![Total Downloads](https://poser.pugx.org/kartik-v/yii2-helpers/downloads)](https://packagist.org/packages/kartik-v/yii2-helpers)
[![Monthly Downloads](https://poser.pugx.org/kartik-v/yii2-helpers/d/monthly)](https://packagist.org/packages/kartik-v/yii2-helpers)
@@ -12,7 +13,7 @@ This extension is a collection of useful helper functions for Yii Framework 2.0.
### Html Class
[```VIEW DEMO```](http://demos.krajee.com/helper-functions/html)
-This class extends the [Yii Html Helper](https://github.com/yiisoft/yii2/blob/master/framework/helpers/Html.php) to incorporate additional HTML markup functionality and features available in [Bootstrap 3.0](http://getbootstrap.com/). The helper functions available in this class are:
+This class extends the [Yii Html Helper](https://github.com/yiisoft/yii2/blob/master/framework/helpers/Html.php) to incorporate additional HTML markup functionality and features available in [Bootstrap 3.x / 4.x](http://getbootstrap.com/). The helper functions available in this class are:
- Icon
- Label
- Badge
@@ -92,4 +93,4 @@ echo Enum::properize('Chris');
## License
-**yii2-helpers** is released under the BSD 3-Clause License. See the bundled `LICENSE.md` for details.
+**yii2-helpers** is released under the BSD-3-Clause License. See the bundled `LICENSE.md` for details.
diff --git a/composer.json b/composer.json
index 3f502bb..b2e92ad 100644
--- a/composer.json
+++ b/composer.json
@@ -12,13 +12,13 @@
"homepage": "http://www.krajee.com/"
}
],
- "minimum-stability": "stable",
"require": {
+ "kartik-v/yii2-krajee-base": ">=1.9",
"yiisoft/yii2-bootstrap": "*"
},
"autoload": {
"psr-4": {
- "kartik\\helpers\\": ""
+ "kartik\\helpers\\": "src"
}
},
"extra": {
diff --git a/Enum.php b/src/Enum.php
similarity index 92%
rename from Enum.php
rename to src/Enum.php
index ee18330..6a9371e 100644
--- a/Enum.php
+++ b/src/Enum.php
@@ -1,9 +1,9 @@
86400,
'hour' => 3600,
'minute' => 60,
- 'second' => 1
+ 'second' => 1,
];
/**
@@ -69,7 +69,7 @@ public static function isEmpty($var)
* ~~~
*
* @param string $needle the value to search
- * @param array $haystack the array to scan
+ * @param array $haystack the array to scan
*
* @return boolean
*/
@@ -109,7 +109,7 @@ public static function properize($string)
* ~~~
*
* @param string $fromTime start date time
- * @param boolean $human if true returns an approximate human friendly output. If set to `false`, will attempt an
+ * @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'.
@@ -144,7 +144,7 @@ public static function initI18N()
Yii::$app->i18n->translations['kvenum*'] = [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => "@kvenum/messages",
- 'forceTranslation' => true
+ 'forceTranslation' => true,
];
}
@@ -160,7 +160,7 @@ public static function initI18N()
* ~~~
*
* @param integer $interval time interval in seconds
- * @param string $append the string to append for the converted elapsed time. Defaults to `' ago'`.
+ * @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.
*
@@ -179,7 +179,7 @@ public static function timeInterval($interval, $append = null, $human = true)
if ($interval <= 0) {
$elapsed = Yii::t('kvenum', 'a moment');
} elseif ($interval < 60) {
- $elapsed = Yii::t('kvenum', '{n, plural, one{one second} other{# seconds}}', [ 'n' => $interval]);
+ $elapsed = Yii::t('kvenum', '{n, plural, one{one second} other{# seconds}}', ['n' => $interval]);
} elseif ($interval >= 60 && $interval < $intervals['hour']) {
$interval = floor($interval / $intervals['minute']);
$elapsed = Yii::t('kvenum', '{n, plural, one{one minute} other{# minutes}}', ['n' => $interval]);
@@ -211,7 +211,7 @@ public static function timeInterval($interval, $append = null, $human = true)
* Example Output:
* 1 year 5 months 3 days ago
*
- * @param integer $time elapsed number of seconds
+ * @param integer $time elapsed number of seconds
* @param array $intervals configuration of time intervals in seconds
*
* @return string
@@ -240,7 +240,7 @@ protected static function time2String($time, $intervals)
* echo Enum::formatBytes(17328347842.25, 3); // returns: 16.138 GB
* ~~~
*
- * @param double $bytes number of bytes
+ * @param double $bytes number of bytes
* @param integer $precision the number of decimal places to round off
*
* @return string
@@ -359,7 +359,7 @@ public static function ones()
' ' . Yii::t('kvenum', 'sixteen'),
' ' . Yii::t('kvenum', 'seventeen'),
' ' . Yii::t('kvenum', 'eighteen'),
- ' ' . Yii::t('kvenum', 'nineteen')
+ ' ' . Yii::t('kvenum', 'nineteen'),
];
}
@@ -391,7 +391,7 @@ public static function tens()
' ' . Yii::t('kvenum', 'sixty'),
' ' . Yii::t('kvenum', 'seventy'),
' ' . Yii::t('kvenum', 'eighty'),
- ' ' . Yii::t('kvenum', 'ninety')
+ ' ' . Yii::t('kvenum', 'ninety'),
];
}
@@ -451,7 +451,7 @@ public static function days()
Yii::t('kvenum', 'Wednesday'),
Yii::t('kvenum', 'Thursday'),
Yii::t('kvenum', 'Friday'),
- Yii::t('kvenum', 'Saturday')
+ Yii::t('kvenum', 'Saturday'),
];
}
@@ -527,8 +527,8 @@ 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 integer $start the first day or month to set. Defaults to `1`.
+ * @param boolean $abbr whether to return abbreviated day or month
+ * @param integer $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
@@ -572,8 +572,8 @@ protected static function genCalList($unit = 'day', $abbr = false, $start = 1, $
* print_r(Enum::monthList(true, 4, 'upper'));
* ~~~
*
- * @param boolean $abbr whether to return abbreviated month
- * @param integer $start the first month to set. Defaults to `1` for `January`.
+ * @param boolean $abbr whether to return abbreviated month
+ * @param integer $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
@@ -586,8 +586,8 @@ 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 integer $start the first day to set. Defaults to `1` for `Sunday`.
+ * @param boolean $abbr whether to return abbreviated day
+ * @param integer $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
@@ -607,9 +607,9 @@ public static function dayList($abbr = false, $start = 1, $case = null)
* print_r(Enum::dateList(1, 10));
* ~~~
*
- * @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 $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 boolean $intervalFromZero whether to start incrementing intervals from zero if $from = 1.
* @param boolean $showLast whether to show the last date (set in $to) even if it does not match interval.
*
@@ -651,11 +651,11 @@ public static function dateList($from = 1, $to = 31, $interval = 1, $intervalFro
* echo implode(', ', Enum::timeList('sec', 5));
* ~~~
*
- * @param string $unit the time unit ('hour', 'min', 'sec', 'ms')
+ * @param string $unit the time unit ('hour', 'min', 'sec', 'ms')
* @param integer $interval the time interval.
* @param integer $from the time from (defaults to 23 for hour
* @param integer $to the time to (defaults to 1).
- * @param boolean $padZero whether to pad zeros to the left of each time unit value.
+ * @param boolean $padZero whether to pad zeros to the left of each time unit value.
*
* @return array
* @throws InvalidConfigException if $unit passed is invalid
@@ -734,7 +734,7 @@ public static function boolList($false = null, $true = null)
* echo Enum::array2table($data);
* ~~~
*
- * @param array $array the associative array to be converted
+ * @param array $array the associative array to be converted
* @param boolean $transpose whether to show keys as rows instead of columns. This parameter should be used only
* for a single dimensional associative array. If used for a multidimensional array, the sub array will be imploded
* as text.
@@ -787,7 +787,7 @@ public static function array2table(
}
if (!isset($array[0]) || !is_array($array[0])) {
- $array = array($array);
+ $array = [$array];
}
// Take the keys from the first row as the headings
foreach (array_keys($array[0]) as $heading) {
@@ -894,32 +894,14 @@ public static function getType($var)
*/
public static function userIP($filterLocal = true)
{
- $ipSources = [
- 'HTTP_CLIENT_IP',
- 'HTTP_X_FORWARDED_FOR',
- 'HTTP_X_FORWARDED',
- 'HTTP_X_CLUSTER_CLIENT_IP',
- 'HTTP_FORWARDED_FOR',
- 'HTTP_FORWARDED',
- 'REMOTE_ADDR'
- ];
- foreach ($ipSources as $key) {
- 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
- );
- if ($checkFilter !== false) {
- return $ip;
- }
- } else {
- return $ip;
- }
- }
+ $ip = Yii::$app->request->getUserIP();
+ if ($filterLocal) {
+ $checkFilter = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);
+ if ($checkFilter !== false) {
+ return $ip;
}
+ } else {
+ return $ip;
}
return 'Unknown';
}
@@ -934,8 +916,8 @@ public static function userIP($filterLocal = true)
* ~~~
*
* @param boolean $common show common browsers only
- * @param array $browsers the list of browsers
- * @param string $agent user agent
+ * @param array $browsers the list of browsers
+ * @param string $agent user agent
*
* @return array the browser information
*/
@@ -988,7 +970,7 @@ public static function getBrowser($common = false, $browsers = [], $agent = null
'code' => 'other',
'name' => Yii::t('kvenum', 'Other'),
'version' => "?",
- 'platform' => Yii::t('kvenum', 'Unknown')
+ 'platform' => Yii::t('kvenum', 'Unknown'),
];
$ios = Yii::t('kvenum', 'iOS');
$unix = Yii::t('kvenum', 'Unix');
diff --git a/Html.php b/src/Html.php
similarity index 87%
rename from Html.php
rename to src/Html.php
index 29cfe86..238f3ca 100644
--- a/Html.php
+++ b/src/Html.php
@@ -1,18 +1,21 @@
addCssClass($options, Widget::BS_LABEL);
+ $widget->addCssClass($options, "label-{$type}");
+ }
return static::tag($tag, $content, $options);
}
@@ -190,10 +214,12 @@ public static function bsLabel($content, $type = 'default', $options = [], $pref
* @param string $tag the label container tag. Defaults to 'span'.
*
* @return string
+ * @throws InvalidConfigException
*/
public static function badge($content, $options = [], $tag = 'span')
{
- static::addCssClass($options, 'badge');
+ $widget = new Widget();
+ $widget->addCssClass($options, Widget::BS_BADGE);
return static::tag($tag, $content, $options);
}
@@ -256,20 +282,29 @@ public static function badge($content, $options = [], $tag = 'span')
* - `badge`: _string_, any badge content to be displayed for this list item (optional)
* - `badgeOptions`: _array_, the HTML attributes / options for badge container (optional).
* - `active`: _boolean_, to highlight the item as active (applicable only if $url is passed). Defaults to `false`.
- * - `options`: _array_, HTML attributes / options for the list group item container (optional).
- * @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'.
+ * - `options`: _array_, HTML attributes / options for the list group item container (optional). The following
+ * special option is recognized:
+ * - `tag`: _string_, the list group container tag. Defaults to 'div'.
+ * @param array $options HTML attributes for the list group container. The following special option is recognized:
+ * - `tag`: _string_, the list group container tag. Defaults to 'div'.
+ * @param array $itemOptions HTML attributes for the list group item options (will be overridden by `options` at
+ * the item level). The following special option is recognized:
+ * - `tag`: _string_, the list group container tag. Defaults to 'div'.
+ * @param array $badgeOptions HTML attributes for the list group item badge options (will be overridden by
+ * `badgeOptions` at the item level)
*
* @return string
+ * @return string
+ * @throws InvalidConfigException
*/
- public static function listGroup($items = [], $options = [], $tag = 'div', $itemTag = 'div')
+ public static function listGroup($items = [], $options = [], $itemOptions = [], $badgeOptions = [])
{
static::addCssClass($options, 'list-group');
$content = '';
foreach ($items as $item) {
- $content .= static::getListGroupItem($item, $itemTag) . "\n";
+ $content .= static::getListGroupItem($item, $itemOptions, $badgeOptions) . "\n";
}
+ $tag = ArrayHelper::remove($options, 'tag', 'div');
return static::tag($tag, $content, $options);
}
@@ -402,19 +437,26 @@ public static function jumbotron($content = [], $fullWidth = false, $options = [
* @param string $prefix the CSS prefix for panel type. Defaults to `panel panel-`.
*
* @return string
+ * @throws InvalidConfigException
*/
- public static function panel($content = [], $type = 'default', $options = [], $prefix = 'panel panel-')
+ public static function panel($content = [], $type = 'default', $options = [], $prefix = null)
{
if (!is_array($content)) {
return '';
} else {
- static::addCssClass($options, $prefix . $type);
+ $widget = new Widget();
+ if (isset($prefix)) {
+ static::addCssClass($options, $prefix . $type);
+ } else {
+ $widget->addCssClass($options, Widget::BS_PANEL);
+ $widget->addCssClass($options, "panel-{$type}");
+ }
$panel = static::getPanelContent($content, 'preHeading') .
- static::getPanelTitle($content, 'heading') .
+ static::getPanelTitle($content, 'heading', $widget) .
static::getPanelContent($content, 'preBody') .
static::getPanelContent($content, 'body') .
static::getPanelContent($content, 'postBody') .
- static::getPanelTitle($content, 'footer') .
+ static::getPanelTitle($content, 'footer', $widget) .
static::getPanelContent($content, 'postFooter');
return static::tag('div', $panel, $options);
}
@@ -458,19 +500,25 @@ public static function pageHeader($title, $subTitle = '', $options = [])
*
* @param string $content the content
* @param string $size the well size. Should be one of the bootstrap size modifiers:
- * - [[SIZE_TINY]] or `xs`
* - [[SIZE_SMALL]] or `sm`
- * - [[SIZE_MEDIUM]] or `md`
* - [[SIZE_LARGE]] or `lg`
* @param array $options HTML attributes / options for the well container.
*
* @return string
+ * @throws InvalidConfigException
*/
public static function well($content, $size = '', $options = [])
{
- static::addCssClass($options, 'well');
+ $widget = new Widget();
if (!Enum::isEmpty($size)) {
- static::addCssClass($options, 'well-' . $size);
+ if ($size === self::SIZE_SMALL) {
+ $widget->addCssClass($options, Widget::BS_WELL_SM);
+ }
+ if ($size === self::SIZE_LARGE) {
+ $widget->addCssClass($options, Widget::BS_WELL_LG);
+ }
+ } else {
+ $widget->addCssClass($options, Widget::BS_WELL);
}
return static::tag('div', $content, $options);
}
@@ -714,16 +762,42 @@ public static function abbr($content, $title, $initialism = false, $options = []
* '{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 attributes for the blockquote main container
+ * @param array $contentOptions HTML attributes for the blockquote content container. For Bootstrap 4.x, the CSS
+ * class `mb-0` will be set if the class attribute is not set. The following option is specially recognized:
+ * - `tag`: _string_, the tag to render the content. Defaults to `p`.
+ * @param array $footerOptions HTML attributes for the blockquote footer container. Applicable only for Bootstrap
+ * 4.x releases.
* @return string
+ * @throws InvalidConfigException
*/
- public static function blockquote($content, $citeContent = '', $citeTitle = '', $citeSource = '', $options = [])
- {
- $content = static::tag('p', $content);
+ public static function blockquote(
+ $content,
+ $citeContent = '',
+ $citeTitle = '',
+ $citeSource = '',
+ $options = [],
+ $contentOptions = [],
+ $footerOptions = []
+ ) {
+ $widget = new Widget();
+ $isBs4 = $widget->isBs4();
+ if ($isBs4) {
+ static::addCssClass($options, 'blockquote');
+ if (!isset($contentOptions['class'])) {
+ $contentOptions['class'] = 'mb-0';
+ }
+ }
+ $tag = ArrayHelper::remove($contentOptions, 'tag', 'p');
+ $content = static::tag($tag, $content, $contentOptions);
if (!Enum::isEmpty($citeContent)) {
$source = static::tag('cite', $citeSource, ['title' => $citeTitle]);
- $content .= "\n" . str_replace('{source}', $source, $citeContent) . "";
+ if ($isBs4) {
+ static::addCssClass($footerOptions, 'blockquote-footer');
+ $content .= Html::tag('div', str_replace('{source}', $source, $citeContent), $footerOptions);
+ } else {
+ $content .= "\n" . str_replace('{source}', $source, $citeContent) . "";
+ }
}
return static::tag('blockquote', $content, $options);
}
@@ -842,20 +916,21 @@ public static function address(
public static function getButtonGroup($type, $name, $selection = null, $items = [], $options = [])
{
$class = $type . 'List';
- static::addCssClass($options, 'btn-group');
+ static::addCssClass($options, ['btn-group', 'btn-group-toggle']);
$options['data-toggle'] = 'buttons';
$options['inline'] = true;
+ $widget = new Widget();
if (!isset($options['itemOptions']['labelOptions']['class'])) {
- $options['itemOptions']['labelOptions']['class'] = 'btn btn-default';
+ $options['itemOptions']['labelOptions']['class'] = 'btn ' . $widget->getDefaultBtnCss();
}
if (!isset($options['item']) || !$options['item'] instanceof Closure) {
- /** @noinspection PhpUnusedParameterInspection */
/**
* @param string $index
* @param string $label
* @param string $name
* @param boolean $checked
* @param string $value
+ * @return ActiveField
*/
$options['item'] = function ($index, $label, $name, $checked, $value) use ($type, $options) {
$opts = isset($options['itemOptions']) ? $options['itemOptions'] : [];
@@ -1083,16 +1158,28 @@ public static function activeRadioButtonGroup($model, $attribute, $items, $optio
* - `badgeOptions`: _array_, the HTML attributes / options for badge container (optional).
* - `active`: _boolean_, to highlight the item as active (applicable only if $url is passed). Defaults to `false`.
* - `options`: _array_, HTML attributes / options for the list group item container (optional).
- * @param string $tag the list item container tag (applied if it is not a link)
+ * @param array $itemOptions HTML attributes for the list group item options (will be overridden by `options` at
+ * the item level). The following special option is recognized:
+ * - `tag`: _string_, the list group container tag. Defaults to 'div'.
+ * @param array $badgeOptions HTML attributes for the list group item badge options (will be overridden by
+ * `badgeOptions` at the item level)
*
* @return string
+ * @throws InvalidConfigException
*/
- protected static function getListGroupItem($item, $tag)
+ protected static function getListGroupItem($item, $itemOptions = [], $badgeOptions = [])
{
- static::addCssClass($item['options'], 'list-group-item');
+ $widget = new Widget();
+ $isBs4 = $widget->isBs4();
$heading = $body = $badge = $content = $url = $active = '';
- $options = $headingOptions = $bodyOptions = $badgeOptions = [];
- extract($item);
+ $itemOptions += ArrayHelper::getValue($item, 'options', []);
+ $badgeOptions += ArrayHelper::getValue($item, 'badgeOptions', []);
+ $url = ArrayHelper::getValue($item, 'url');
+ $badge = ArrayHelper::getValue($item, 'badge', '');
+ $content = ArrayHelper::getValue($item, 'content', '');
+ $active = ArrayHelper::getValue($item, 'active', false);
+ static::addCssClass($itemOptions, 'list-group-item');
+ $hasUrl = !Enum::isEmpty($url);
if (is_array($content)) {
extract($content);
if (!Enum::isEmpty($heading)) {
@@ -1106,15 +1193,23 @@ protected static function getListGroupItem($item, $tag)
$content = $heading . "\n" . $body;
}
if (!Enum::isEmpty($badge)) {
- $content = static::badge($badge, $badgeOptions) . $content;
+ if ($isBs4 && empty($badgeOptions['class'])) {
+ $badgeOptions['class'] = 'badge-secondary';
+ }
+ $badge = static::badge($badge, $badgeOptions);
+ $content = $isBs4 ? $content . $badge : $badge . $content;
+ }
+ $tag = ArrayHelper::remove($itemOptions, 'tag', 'div');
+ if ($active) {
+ static::addCssClass($itemOptions, 'active');
}
- if (!Enum::isEmpty($url)) {
- if ($active) {
- static::addCssClass($options, 'active');
+ if ($hasUrl) {
+ if ($isBs4) {
+ static::addCssClass($itemOptions, 'list-group-item-action');
}
- return static::a($content, $url, $options);
+ return static::a($content, $url, $itemOptions);
} else {
- return static::tag($tag, $content, $options);
+ return static::tag($tag, $content, $itemOptions);
}
}
@@ -1137,17 +1232,22 @@ protected static function getPanelContent($content, $type)
*
* @param array $content the panel content settings.
* @param string $type whether `heading` or `footer`
+ * @param Widget $widget the widget object
*
* @return string
+ * @throws InvalidConfigException
*/
- protected static function getPanelTitle($content, $type)
+ protected static function getPanelTitle($content, $type, $widget)
{
$title = ArrayHelper::getValue($content, $type, '');
if (!Enum::isEmpty($title)) {
if (ArrayHelper::getValue($content, "{$type}Title", true) === true) {
- $title = static::tag("h3", $title, ["class" => "panel-title"]);
+ $isBs4 = $widget->isBs4();
+ $tag = $isBs4 ? 'h5' : 'h3';
+ $css = $isBs4 ? 'm-0' : 'panel-title';
+ $title = static::tag($tag, $title, ['class' => $css]);
}
- return static::tag("div", $title, ["class" => "panel-{$type}"]) . "\n";
+ return static::tag("div", $title, ["class" => $widget->getCssClass("panel-{$type}")]) . "\n";
} else {
return '';
}
diff --git a/messages/af/kvenum.php b/src/messages/af/kvenum.php
similarity index 100%
rename from messages/af/kvenum.php
rename to src/messages/af/kvenum.php
diff --git a/messages/ar/kvenum.php b/src/messages/ar/kvenum.php
similarity index 100%
rename from messages/ar/kvenum.php
rename to src/messages/ar/kvenum.php
diff --git a/messages/az/kvenum.php b/src/messages/az/kvenum.php
similarity index 100%
rename from messages/az/kvenum.php
rename to src/messages/az/kvenum.php
diff --git a/messages/bg/kvenum.php b/src/messages/bg/kvenum.php
similarity index 100%
rename from messages/bg/kvenum.php
rename to src/messages/bg/kvenum.php
diff --git a/messages/bs/kvenum.php b/src/messages/bs/kvenum.php
similarity index 100%
rename from messages/bs/kvenum.php
rename to src/messages/bs/kvenum.php
diff --git a/messages/ca/kvenum.php b/src/messages/ca/kvenum.php
similarity index 100%
rename from messages/ca/kvenum.php
rename to src/messages/ca/kvenum.php
diff --git a/messages/config.php b/src/messages/config.php
similarity index 100%
rename from messages/config.php
rename to src/messages/config.php
diff --git a/messages/cs/kvenum.php b/src/messages/cs/kvenum.php
similarity index 100%
rename from messages/cs/kvenum.php
rename to src/messages/cs/kvenum.php
diff --git a/messages/da/kvenum.php b/src/messages/da/kvenum.php
similarity index 100%
rename from messages/da/kvenum.php
rename to src/messages/da/kvenum.php
diff --git a/messages/de/kvenum.php b/src/messages/de/kvenum.php
similarity index 100%
rename from messages/de/kvenum.php
rename to src/messages/de/kvenum.php
diff --git a/messages/el/kvenum.php b/src/messages/el/kvenum.php
similarity index 100%
rename from messages/el/kvenum.php
rename to src/messages/el/kvenum.php
diff --git a/messages/en/kvenum.php b/src/messages/en/kvenum.php
similarity index 100%
rename from messages/en/kvenum.php
rename to src/messages/en/kvenum.php
diff --git a/messages/eo/kvenum.php b/src/messages/eo/kvenum.php
similarity index 100%
rename from messages/eo/kvenum.php
rename to src/messages/eo/kvenum.php
diff --git a/messages/es/kvenum.php b/src/messages/es/kvenum.php
similarity index 100%
rename from messages/es/kvenum.php
rename to src/messages/es/kvenum.php
diff --git a/messages/et/kvenum.php b/src/messages/et/kvenum.php
similarity index 100%
rename from messages/et/kvenum.php
rename to src/messages/et/kvenum.php
diff --git a/messages/eu/kvenum.php b/src/messages/eu/kvenum.php
similarity index 100%
rename from messages/eu/kvenum.php
rename to src/messages/eu/kvenum.php
diff --git a/messages/fa/kvenum.php b/src/messages/fa/kvenum.php
similarity index 100%
rename from messages/fa/kvenum.php
rename to src/messages/fa/kvenum.php
diff --git a/messages/fi/kvenum.php b/src/messages/fi/kvenum.php
similarity index 100%
rename from messages/fi/kvenum.php
rename to src/messages/fi/kvenum.php
diff --git a/messages/fo/kvenum.php b/src/messages/fo/kvenum.php
similarity index 100%
rename from messages/fo/kvenum.php
rename to src/messages/fo/kvenum.php
diff --git a/messages/fr/kvenum.php b/src/messages/fr/kvenum.php
similarity index 100%
rename from messages/fr/kvenum.php
rename to src/messages/fr/kvenum.php
diff --git a/messages/gl/kvenum.php b/src/messages/gl/kvenum.php
similarity index 100%
rename from messages/gl/kvenum.php
rename to src/messages/gl/kvenum.php
diff --git a/messages/gu/kvenum.php b/src/messages/gu/kvenum.php
similarity index 100%
rename from messages/gu/kvenum.php
rename to src/messages/gu/kvenum.php
diff --git a/messages/he/kvenum.php b/src/messages/he/kvenum.php
similarity index 100%
rename from messages/he/kvenum.php
rename to src/messages/he/kvenum.php
diff --git a/messages/hi/kvenum.php b/src/messages/hi/kvenum.php
similarity index 100%
rename from messages/hi/kvenum.php
rename to src/messages/hi/kvenum.php
diff --git a/messages/hr/kvenum.php b/src/messages/hr/kvenum.php
similarity index 100%
rename from messages/hr/kvenum.php
rename to src/messages/hr/kvenum.php
diff --git a/messages/hu/kvenum.php b/src/messages/hu/kvenum.php
similarity index 100%
rename from messages/hu/kvenum.php
rename to src/messages/hu/kvenum.php
diff --git a/messages/hy/kvenum.php b/src/messages/hy/kvenum.php
similarity index 100%
rename from messages/hy/kvenum.php
rename to src/messages/hy/kvenum.php
diff --git a/messages/id/kvenum.php b/src/messages/id/kvenum.php
similarity index 100%
rename from messages/id/kvenum.php
rename to src/messages/id/kvenum.php
diff --git a/messages/is/kvenum.php b/src/messages/is/kvenum.php
similarity index 100%
rename from messages/is/kvenum.php
rename to src/messages/is/kvenum.php
diff --git a/messages/it/kvenum.php b/src/messages/it/kvenum.php
similarity index 100%
rename from messages/it/kvenum.php
rename to src/messages/it/kvenum.php
diff --git a/messages/ja/kvenum.php b/src/messages/ja/kvenum.php
similarity index 100%
rename from messages/ja/kvenum.php
rename to src/messages/ja/kvenum.php
diff --git a/messages/ka/kvenum.php b/src/messages/ka/kvenum.php
similarity index 100%
rename from messages/ka/kvenum.php
rename to src/messages/ka/kvenum.php
diff --git a/messages/kk/kvenum.php b/src/messages/kk/kvenum.php
similarity index 100%
rename from messages/kk/kvenum.php
rename to src/messages/kk/kvenum.php
diff --git a/messages/kn/kvenum.php b/src/messages/kn/kvenum.php
similarity index 100%
rename from messages/kn/kvenum.php
rename to src/messages/kn/kvenum.php
diff --git a/messages/ko/kvenum.php b/src/messages/ko/kvenum.php
similarity index 100%
rename from messages/ko/kvenum.php
rename to src/messages/ko/kvenum.php
diff --git a/messages/ky/kvenum.php b/src/messages/ky/kvenum.php
similarity index 100%
rename from messages/ky/kvenum.php
rename to src/messages/ky/kvenum.php
diff --git a/messages/lt/kvenum.php b/src/messages/lt/kvenum.php
similarity index 100%
rename from messages/lt/kvenum.php
rename to src/messages/lt/kvenum.php
diff --git a/messages/lv/kvenum.php b/src/messages/lv/kvenum.php
similarity index 100%
rename from messages/lv/kvenum.php
rename to src/messages/lv/kvenum.php
diff --git a/messages/mi/kvenum.php b/src/messages/mi/kvenum.php
similarity index 100%
rename from messages/mi/kvenum.php
rename to src/messages/mi/kvenum.php
diff --git a/messages/mk/kvenum.php b/src/messages/mk/kvenum.php
similarity index 100%
rename from messages/mk/kvenum.php
rename to src/messages/mk/kvenum.php
diff --git a/messages/mn/kvenum.php b/src/messages/mn/kvenum.php
similarity index 100%
rename from messages/mn/kvenum.php
rename to src/messages/mn/kvenum.php
diff --git a/messages/mr/kvenum.php b/src/messages/mr/kvenum.php
similarity index 100%
rename from messages/mr/kvenum.php
rename to src/messages/mr/kvenum.php
diff --git a/messages/ms/kvenum.php b/src/messages/ms/kvenum.php
similarity index 100%
rename from messages/ms/kvenum.php
rename to src/messages/ms/kvenum.php
diff --git a/messages/mt/kvenum.php b/src/messages/mt/kvenum.php
similarity index 100%
rename from messages/mt/kvenum.php
rename to src/messages/mt/kvenum.php
diff --git a/messages/nb/kvenum.php b/src/messages/nb/kvenum.php
similarity index 100%
rename from messages/nb/kvenum.php
rename to src/messages/nb/kvenum.php
diff --git a/messages/nl/kvenum.php b/src/messages/nl/kvenum.php
similarity index 100%
rename from messages/nl/kvenum.php
rename to src/messages/nl/kvenum.php
diff --git a/messages/nn/kvenum.php b/src/messages/nn/kvenum.php
similarity index 100%
rename from messages/nn/kvenum.php
rename to src/messages/nn/kvenum.php
diff --git a/messages/pl/kvenum.php b/src/messages/pl/kvenum.php
similarity index 100%
rename from messages/pl/kvenum.php
rename to src/messages/pl/kvenum.php
diff --git a/messages/pt-BR/kvenum.php b/src/messages/pt-BR/kvenum.php
similarity index 100%
rename from messages/pt-BR/kvenum.php
rename to src/messages/pt-BR/kvenum.php
diff --git a/messages/pt/kvenum.php b/src/messages/pt/kvenum.php
similarity index 100%
rename from messages/pt/kvenum.php
rename to src/messages/pt/kvenum.php
diff --git a/messages/qu/kvenum.php b/src/messages/qu/kvenum.php
similarity index 100%
rename from messages/qu/kvenum.php
rename to src/messages/qu/kvenum.php
diff --git a/messages/ro/kvenum.php b/src/messages/ro/kvenum.php
similarity index 100%
rename from messages/ro/kvenum.php
rename to src/messages/ro/kvenum.php
diff --git a/messages/ru/kvenum.php b/src/messages/ru/kvenum.php
similarity index 100%
rename from messages/ru/kvenum.php
rename to src/messages/ru/kvenum.php
diff --git a/messages/sa/kvenum.php b/src/messages/sa/kvenum.php
similarity index 100%
rename from messages/sa/kvenum.php
rename to src/messages/sa/kvenum.php
diff --git a/messages/se/kvenum.php b/src/messages/se/kvenum.php
similarity index 100%
rename from messages/se/kvenum.php
rename to src/messages/se/kvenum.php
diff --git a/messages/sk/kvenum.php b/src/messages/sk/kvenum.php
similarity index 100%
rename from messages/sk/kvenum.php
rename to src/messages/sk/kvenum.php
diff --git a/messages/sl/kvenum.php b/src/messages/sl/kvenum.php
similarity index 100%
rename from messages/sl/kvenum.php
rename to src/messages/sl/kvenum.php
diff --git a/messages/sq/kvenum.php b/src/messages/sq/kvenum.php
similarity index 100%
rename from messages/sq/kvenum.php
rename to src/messages/sq/kvenum.php
diff --git a/messages/sr-Latn/kvenum.php b/src/messages/sr-Latn/kvenum.php
similarity index 100%
rename from messages/sr-Latn/kvenum.php
rename to src/messages/sr-Latn/kvenum.php
diff --git a/messages/sr/kvenum.php b/src/messages/sr/kvenum.php
similarity index 100%
rename from messages/sr/kvenum.php
rename to src/messages/sr/kvenum.php
diff --git a/messages/sv/kvenum.php b/src/messages/sv/kvenum.php
similarity index 100%
rename from messages/sv/kvenum.php
rename to src/messages/sv/kvenum.php
diff --git a/messages/sw/kvenum.php b/src/messages/sw/kvenum.php
similarity index 100%
rename from messages/sw/kvenum.php
rename to src/messages/sw/kvenum.php
diff --git a/messages/ta/kvenum.php b/src/messages/ta/kvenum.php
similarity index 100%
rename from messages/ta/kvenum.php
rename to src/messages/ta/kvenum.php
diff --git a/messages/te/kvenum.php b/src/messages/te/kvenum.php
similarity index 100%
rename from messages/te/kvenum.php
rename to src/messages/te/kvenum.php
diff --git a/messages/th/kvenum.php b/src/messages/th/kvenum.php
similarity index 100%
rename from messages/th/kvenum.php
rename to src/messages/th/kvenum.php
diff --git a/messages/tj/kvenum.php b/src/messages/tj/kvenum.php
similarity index 100%
rename from messages/tj/kvenum.php
rename to src/messages/tj/kvenum.php
diff --git a/messages/tl/kvenum.php b/src/messages/tl/kvenum.php
similarity index 100%
rename from messages/tl/kvenum.php
rename to src/messages/tl/kvenum.php
diff --git a/messages/tn/kvenum.php b/src/messages/tn/kvenum.php
similarity index 100%
rename from messages/tn/kvenum.php
rename to src/messages/tn/kvenum.php
diff --git a/messages/tr/kvenum.php b/src/messages/tr/kvenum.php
similarity index 100%
rename from messages/tr/kvenum.php
rename to src/messages/tr/kvenum.php
diff --git a/messages/ts/kvenum.php b/src/messages/ts/kvenum.php
similarity index 100%
rename from messages/ts/kvenum.php
rename to src/messages/ts/kvenum.php
diff --git a/messages/tt/kvenum.php b/src/messages/tt/kvenum.php
similarity index 100%
rename from messages/tt/kvenum.php
rename to src/messages/tt/kvenum.php
diff --git a/messages/uk/kvenum.php b/src/messages/uk/kvenum.php
similarity index 100%
rename from messages/uk/kvenum.php
rename to src/messages/uk/kvenum.php
diff --git a/messages/ur/kvenum.php b/src/messages/ur/kvenum.php
similarity index 100%
rename from messages/ur/kvenum.php
rename to src/messages/ur/kvenum.php
diff --git a/messages/vi/kvenum.php b/src/messages/vi/kvenum.php
similarity index 100%
rename from messages/vi/kvenum.php
rename to src/messages/vi/kvenum.php
diff --git a/messages/zh-CN/kvenum.php b/src/messages/zh-CN/kvenum.php
similarity index 100%
rename from messages/zh-CN/kvenum.php
rename to src/messages/zh-CN/kvenum.php
diff --git a/messages/zh-TW/kvenum.php b/src/messages/zh-TW/kvenum.php
similarity index 100%
rename from messages/zh-TW/kvenum.php
rename to src/messages/zh-TW/kvenum.php
diff --git a/messages/zu/kvenum.php b/src/messages/zu/kvenum.php
similarity index 100%
rename from messages/zu/kvenum.php
rename to src/messages/zu/kvenum.php