Skip to content

Commit

Permalink
Update to release v1.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Mar 4, 2022
1 parent 833d79e commit 0b13058
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 56 deletions.
6 changes: 6 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
69 changes: 35 additions & 34 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
37 changes: 20 additions & 17 deletions src/DetailView.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-detail-view
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2022
* @version 1.8.6
* @version 1.8.7
*/

namespace kartik\detail;
Expand All @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}
Expand All @@ -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'),
Expand Down Expand Up @@ -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)) {
Expand All @@ -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 " .
Expand Down
2 changes: 1 addition & 1 deletion src/DetailViewAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-detail-view
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2022
* @version 1.8.6
* @version 1.8.7
*/

namespace kartik\detail;
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/kv-detail-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @package yii2-detail-view
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2022
* @version 1.8.6
* @version 1.8.7
*
* Styles for yii2-detail-view extension
*
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/kv-detail-view.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/assets/js/kv-detail-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @package yii2-detail-view
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2022
* @version 1.8.6
* @version 1.8.7
*
* Client extension for the yii2-detail-view extension
*
Expand Down
2 changes: 1 addition & 1 deletion src/assets/js/kv-detail-view.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0b13058

Please sign in to comment.