From 0b130581bce1ff26a98750433489cdc4816080a1 Mon Sep 17 00:00:00 2001 From: Kartik Visweswaran Date: Fri, 4 Mar 2022 15:12:29 +0530 Subject: [PATCH] Update to release v1.8.7 --- CHANGE.md | 6 +++ composer.json | 69 ++++++++++++++------------- src/DetailView.php | 37 +++++++------- src/DetailViewAsset.php | 2 +- src/assets/css/kv-detail-view.css | 2 +- src/assets/css/kv-detail-view.min.css | 2 +- src/assets/js/kv-detail-view.js | 2 +- src/assets/js/kv-detail-view.min.js | 2 +- 8 files changed, 66 insertions(+), 56 deletions(-) diff --git a/CHANGE.md b/CHANGE.md index 6cb9b0e..0bed4ac 100755 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,6 +1,12 @@ Change Log: `yii2-detail-view` ============================== +## Version 1.8.7 + +**Date:** 04-Mar-2022 + +- Enhance compatibility for PHP 8.1. + ## Version 1.8.6 **Date:** 11-Jan-2022 diff --git a/composer.json b/composer.json index 798e9f2..e50b3f2 100755 --- a/composer.json +++ b/composer.json @@ -1,37 +1,38 @@ { - "name": "kartik-v/yii2-detail-view", - "description": "Enhanced Yii 2 Detail View widget with special Bootstrap styles, ability to edit data, and more.", - "keywords": [ - "yii2", - "extension", - "widget", - "detail", - "grid", - "form", - "detail view" - ], - "homepage": "https://github.com/kartik-v/yii2-detail-view", - "type": "yii2-extension", - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Kartik Visweswaran", - "email": "kartikv2@gmail.com", - "homepage": "http://www.krajee.com/" - } - ], - "require": { - "kartik-v/yii2-dialog": "~1.0", - "kartik-v/yii2-widget-activeform": ">=1.6.0" - }, - "autoload": { - "psr-4": { - "kartik\\detail\\": "src" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.8.x-dev" - } + "name": "kartik-v/yii2-detail-view", + "description": "Enhanced Yii 2 Detail View widget with special Bootstrap styles, ability to edit data, and more.", + "keywords": [ + "yii2", + "extension", + "widget", + "detail", + "grid", + "form", + "detail view" + ], + "homepage": "https://github.com/kartik-v/yii2-detail-view", + "type": "yii2-extension", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" } + ], + "require": { + "kartik-v/yii2-dialog": "~1.0", + "kartik-v/yii2-krajee-base": ">=3.0.4", + "kartik-v/yii2-widget-activeform": ">=1.6.2" + }, + "autoload": { + "psr-4": { + "kartik\\detail\\": "src" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.8.x-dev" + } + } } diff --git a/src/DetailView.php b/src/DetailView.php index 86938c6..99990e6 100644 --- a/src/DetailView.php +++ b/src/DetailView.php @@ -4,7 +4,7 @@ * @package yii2-detail-view * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022 - * @version 1.8.6 + * @version 1.8.7 */ namespace kartik\detail; @@ -14,6 +14,7 @@ use kartik\base\BootstrapInterface; use kartik\base\BootstrapTrait; use kartik\base\Config; +use kartik\base\Lib; use kartik\base\TranslationTrait; use kartik\base\WidgetTrait; use kartik\base\PluginAssetBundle; @@ -642,6 +643,7 @@ class DetailView extends YiiDetailView implements BootstrapInterface * - `tag`: _string_, the HTML tag to render the title. Defaults to: * - `span` for Bootstrap 4.x & Bootstrap 5.x. * - `h3` for Bootstrap 3.x. + * * The `titleOptions` defaults to: * - `[]` for Bootstrap 4.x & Bootstrap 5.x. * - `['class'=>'panel-title']` for Bootstrap 3.x. @@ -900,14 +902,14 @@ protected function runWidget() if (is_array($this->panel) && !empty($this->panel)) { $output = $this->renderPanel($output); } - $output = strtr(Html::tag('div', $this->mainTemplate, $this->container), ['{detail}' => $output]); + $output = Lib::strtr(Html::tag('div', $this->mainTemplate, $this->container), ['{detail}' => $output]); Html::addCssClass($this->viewButtonsContainer, 'kv-buttons-1'); $buttons = Html::tag('span', $this->renderButtons(), $this->viewButtonsContainer); if ($this->enableEditMode) { Html::addCssClass($this->editButtonsContainer, 'kv-buttons-2'); $buttons .= Html::tag('span', $this->renderButtons(2), $this->editButtonsContainer); } - echo str_replace('{buttons}', Html::tag('div', $buttons, $this->buttonContainer), $output); + echo Lib::str_replace('{buttons}', Html::tag('div', $buttons, $this->buttonContainer), $output); if ($this->enableEditMode) { /** * @var ActiveForm $formClass @@ -1111,15 +1113,15 @@ protected function renderAttributeItem($attribute) protected static function hasGridCol($container = []) { $css = ArrayHelper::getValue($container, 'class', ''); - $css = trim($css); - $css = preg_replace('/\s+/', ' ', $css); + $css = Lib::trim($css); + $css = Lib::preg_replace('/\s+/', ' ', $css); if (empty($css)) { return false; } - $classes = explode(' ', $css); + $classes = Lib::explode(' ', $css); if (!empty($classes)) { foreach ($classes as $class) { - if (substr(trim($class), 0, 4) === 'col-') { + if (Lib::substr(Lib::trim($class), 0, 4) === 'col-') { return true; } } @@ -1167,7 +1169,7 @@ protected function renderFormAttribute($config) } else { Html::removeCssClass($fieldConfig['options'], 'mb-3'); } - if (substr($input, 0, 8) == "\\kartik\\") { + if (Lib::substr($input, 0, 8) == "\\kartik\\") { Config::validateInputWidget($input, 'as an input widget for DetailView edit mode'); } elseif ($input !== self::INPUT_WIDGET && !in_array($input, self::$_inputsList)) { throw new InvalidConfigException( @@ -1271,7 +1273,7 @@ protected function renderPanel($items) static::initCss($afterOptions, 'kv-panel-after'); $panelAfter = Html::tag('div', $after, $afterOptions); } - $out = strtr($this->panelTemplate, [ + $out = Lib::strtr($this->panelTemplate, [ '{panelHeading}' => $panelHeading, '{type}' => $type, '{items}' => $items, @@ -1280,7 +1282,7 @@ protected function renderPanel($items) '{panelAfter}' => $panelAfter, ]); - return Html::tag('div', strtr($out, [ + return Html::tag('div', Lib::strtr($out, [ '{title}' => Html::tag($titleTag, $heading, $titleOptions), ]), $options); } @@ -1296,7 +1298,7 @@ protected function renderPanel($items) protected function renderButtons($mode = 1) { $buttons = "buttons{$mode}"; - return strtr( + return Lib::strtr( $this->$buttons, [ '{view}' => $this->renderButton('view'), @@ -1462,16 +1464,17 @@ protected function normalizeAttributes() protected function parseAttributeItem($attribute) { if (is_string($attribute)) { - if (!preg_match('/^([^:]+)(:(\w*))?(:(.*))?$/', $attribute, $matches)) { + $matches = []; + if (!Lib::preg_match('/^([^:]+)(:(\w*))?(:(.*))?$/', $attribute, $matches)) { throw new InvalidConfigException( 'The attribute must be specified in the format of "attribute", "attribute:format" or ' . '"attribute:format:label"' ); } $attribute = [ - 'attribute' => $matches[1], - 'format' => $matches[3] ?? 'text', - 'label' => $matches[5] ?? null, + 'attribute' => ArrayHelper::getValue($matches, 1), + 'format' => ArrayHelper::getValue($matches, 3, 'text'), + 'label' => ArrayHelper::getValue($matches, 5), ]; } if (!is_array($attribute)) { @@ -1492,11 +1495,11 @@ protected function parseAttributeItem($attribute) return $attribute; } $attr = ArrayHelper::getValue($attribute, 'updateAttr'); - if ($attr && !ctype_alnum(str_replace('_', '', $attr))) { + if ($attr && !ctype_alnum(Lib::str_replace('_', '', $attr))) { throw new InvalidConfigException("The 'updateAttr' name '{$attr}' is invalid."); } $attr = ArrayHelper::getValue($attribute, 'attribute', ''); - if ($attr && strpos($attr, '.') !== false) { + if ($attr && Lib::strpos($attr, '.') !== false) { throw new InvalidConfigException( "The attribute '{$attr}' is invalid. You cannot directly pass relational attributes in string format " . "within '\\kartik\\widgets\\DetailView'. Instead use the array format with 'attribute' property " . diff --git a/src/DetailViewAsset.php b/src/DetailViewAsset.php index 80a0108..83f48b3 100644 --- a/src/DetailViewAsset.php +++ b/src/DetailViewAsset.php @@ -4,7 +4,7 @@ * @package yii2-detail-view * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022 - * @version 1.8.6 + * @version 1.8.7 */ namespace kartik\detail; diff --git a/src/assets/css/kv-detail-view.css b/src/assets/css/kv-detail-view.css index 450a78a..cd84362 100644 --- a/src/assets/css/kv-detail-view.css +++ b/src/assets/css/kv-detail-view.css @@ -2,7 +2,7 @@ * @package yii2-detail-view * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022 - * @version 1.8.6 + * @version 1.8.7 * * Styles for yii2-detail-view extension * diff --git a/src/assets/css/kv-detail-view.min.css b/src/assets/css/kv-detail-view.min.css index ef303aa..5444218 100644 --- a/src/assets/css/kv-detail-view.min.css +++ b/src/assets/css/kv-detail-view.min.css @@ -2,7 +2,7 @@ * @package yii2-detail-view * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022 - * @version 1.8.6 + * @version 1.8.7 * * Styles for yii2-detail-view extension * diff --git a/src/assets/js/kv-detail-view.js b/src/assets/js/kv-detail-view.js index bc3814e..b086262 100644 --- a/src/assets/js/kv-detail-view.js +++ b/src/assets/js/kv-detail-view.js @@ -2,7 +2,7 @@ * @package yii2-detail-view * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022 - * @version 1.8.6 + * @version 1.8.7 * * Client extension for the yii2-detail-view extension * diff --git a/src/assets/js/kv-detail-view.min.js b/src/assets/js/kv-detail-view.min.js index 72cb7a1..7d9b95c 100644 --- a/src/assets/js/kv-detail-view.min.js +++ b/src/assets/js/kv-detail-view.min.js @@ -2,7 +2,7 @@ * @package yii2-detail-view * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022 - * @version 1.8.6 + * @version 1.8.7 * * Client extension for the yii2-detail-view extension *