diff --git a/docs/guide/structure-views.md b/docs/guide/structure-views.md index 2212ea0..a214be0 100644 --- a/docs/guide/structure-views.md +++ b/docs/guide/structure-views.md @@ -238,7 +238,7 @@ A view name is resolved into the corresponding view file path according to the f * If the view is rendered with a [[yii\base\View::context|context]] and the context implements [[yii\base\ViewContextInterface]], the view file path is formed by prefixing the [[yii\base\ViewContextInterface::getViewPath()|view path]] of the context to the view name. This mainly applies to the views rendered within controllers and widgets. For example, - `site/about` will be resolved into `@app/views/site/about.php` if the context is the controller `SiteController`. + `about` will be resolved into `@app/views/site/about.php` if the context is the controller `SiteController`. * If a view is rendered within another view, the directory containing the other view file will be prefixed to the new view name to form the actual view file path. For example, `item` will be resolved into `@app/views/post/item.php` if it is being rendered in the view `@app/views/post/index.php`. diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 0a3eb60..27aa8c2 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -16,9 +16,11 @@ Yii Framework 2 Change Log - Enh #6852: Added `yii\helpers\BaseHtmlPurifier::helpers()` in order to be able to configure `HtmlPurifier` helper globally via subclassing (Alex-Code) - Enh #6882: Added `yii\web\ErrorHandler::getTypeUrl()` in order to allow providing custom types/classes/methods URLs for subclasses (brandonkelly) - Enh #6896: Added `yii\log\FileTarget::$enableRotation` to allow disabling log rotation when external tools are configured for this (cebe) +- Enh #7008: Removed extra white space in GridView filter cell (uran1980) - Enh #7051: Added support for preventing swapping values between different cookies (pavimus, qiangxue) - Chg #5690: adjusted paths in message config generated by `yii message/config` to reflect directory structure better (mikehaertl, samdark) - Chg #6661: Hyperlinks that are enclosed within an exist form will use the same form for submission if they specify both of the `href` and `data-method` attributes (qiangxue) +- Chg #7094: Console confirmation must be answered correctly. To return `true`: `y` or `yes`. To return `false`: `n` or `not`. Any other input the question will be asked again (thiagotalma) 2.0.2 January 11, 2015 ---------------------- diff --git a/framework/grid/DataColumn.php b/framework/grid/DataColumn.php index e7f6d8b..255717f 100644 --- a/framework/grid/DataColumn.php +++ b/framework/grid/DataColumn.php @@ -159,15 +159,15 @@ class DataColumn extends Column if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) { if ($model->hasErrors($this->attribute)) { Html::addCssClass($this->filterOptions, 'has-error'); - $error = Html::error($model, $this->attribute, $this->grid->filterErrorOptions); + $error = ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions); } else { $error = ''; } if (is_array($this->filter)) { $options = array_merge(['prompt' => ''], $this->filterInputOptions); - return Html::activeDropDownList($model, $this->attribute, $this->filter, $options) . ' ' . $error; + return Html::activeDropDownList($model, $this->attribute, $this->filter, $options) . $error; } else { - return Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . ' ' . $error; + return Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error; } } else { return parent::renderFilterCellContent(); diff --git a/framework/helpers/BaseConsole.php b/framework/helpers/BaseConsole.php index dc65a0a..366cee1 100644 --- a/framework/helpers/BaseConsole.php +++ b/framework/helpers/BaseConsole.php @@ -769,10 +769,22 @@ class BaseConsole */ public static function confirm($message, $default = false) { - static::stdout($message . ' (yes|no) [' . ($default ? 'yes' : 'no') . ']:'); - $input = trim(static::stdin()); + while (true) { + static::stdout($message . ' (yes|no) [' . ($default ? 'yes' : 'no') . ']:'); + $input = trim(static::stdin()); - return empty($input) ? $default : !strncasecmp($input, 'y', 1); + if (empty($input)) { + return $default; + } + + if (!strcasecmp ($input, 'y') || !strcasecmp ($input, 'yes') ) { + return true; + } + + if (!strcasecmp ($input, 'n') || !strcasecmp ($input, 'no') ) { + return false; + } + } } /** diff --git a/framework/helpers/HtmlPurifier.php b/framework/helpers/HtmlPurifier.php index 0d910ac..71b229b 100644 --- a/framework/helpers/HtmlPurifier.php +++ b/framework/helpers/HtmlPurifier.php @@ -26,9 +26,6 @@ namespace yii\helpers; * * For more details please refer to [HTMLPurifier documentation](http://htmlpurifier.org/). * - * Note that you should add `ezyang/htmlpurifier` to your composer.json `require` section and run `composer install` - * before using it. - * * @author Alexander Makarov <sam@rmcreative.ru> * @since 2.0 */ diff --git a/tests/unit/data/i18n/messages/ru/test.php b/tests/unit/data/i18n/messages/ru/test.php index 8c5ed86..fd6c6c7 100644 --- a/tests/unit/data/i18n/messages/ru/test.php +++ b/tests/unit/data/i18n/messages/ru/test.php @@ -4,4 +4,5 @@ */ return [ 'The dog runs fast.' => 'Собака бегает быстро.', + 'There {n, plural, =0{no cats} =1{one cat} other{are # cats}} on lying on the sofa!' => 'На диване {n, plural, =0{нет кошек} =1{лежит одна кошка} one{лежит # кошка} few{лежит # кошки} many{лежит # кошек} other{лежит # кошки}}!', ]; diff --git a/tests/unit/extensions/bootstrap/CollapseTest.php b/tests/unit/extensions/bootstrap/CollapseTest.php new file mode 100644 index 0000000..e56b719 --- /dev/null +++ b/tests/unit/extensions/bootstrap/CollapseTest.php @@ -0,0 +1,71 @@ +<?php +namespace yiiunit\extensions\bootstrap; + +use yii\bootstrap\Collapse; + +class CollapseTest extends BootstrapTestCase +{ + public function testRender() + { + Collapse::$counter = 0; + $output = Collapse::widget([ + 'items' => [ + [ + 'label' => 'Collapsible Group Item #1', + 'content' => 'test content1', + ], + [ + 'label' => '<h1>Collapsible Group Item #2</h1>', + 'content' => '<h2>test content2</h2>', + 'contentOptions' => [ + 'class' => 'testContentOptions2' + ], + 'options' => [ + 'class' => 'testClass2', + 'id' => 'testId2' + ], + 'encode' => true + ], + [ + 'label' => '<h1>Collapsible Group Item #3</h1>', + 'content' => '<h2>test content3</h2>', + 'contentOptions' => [ + 'class' => 'testContentOptions3' + ], + 'options' => [ + 'class' => 'testClass3', + 'id' => 'testId3' + ], + 'encode' => false + ], + [ + 'label' => '<h1>Collapsible Group Item #4</h1>', + 'content' => '<h1>test content4</h1>', + ], + ] + ]); + + $this->assertEquals(<<<HTML +<div id="w0" class="panel-group"> +<div class="panel panel-default"><div class="panel-heading"><h4 class="panel-title"><a class="collapse-toggle" href="#w0-collapse1" data-toggle="collapse" data-parent="#w0">Collapsible Group Item #1</a> +</h4></div> +<div id="w0-collapse1" class="panel-collapse collapse"><div class="panel-body">test content1</div> +</div></div> +<div id="testId2" class="testClass2 panel panel-default"><div class="panel-heading"><h4 class="panel-title"><a class="collapse-toggle" href="#w0-collapse2" data-toggle="collapse" data-parent="#w0"><h1>Collapsible Group Item #2</h1></a> +</h4></div> +<div id="w0-collapse2" class="testContentOptions2 panel-collapse collapse"><div class="panel-body"><h2>test content2</h2></div> +</div></div> +<div id="testId3" class="testClass3 panel panel-default"><div class="panel-heading"><h4 class="panel-title"><a class="collapse-toggle" href="#w0-collapse3" data-toggle="collapse" data-parent="#w0"><h1>Collapsible Group Item #3</h1></a> +</h4></div> +<div id="w0-collapse3" class="testContentOptions3 panel-collapse collapse"><div class="panel-body"><h2>test content3</h2></div> +</div></div> +<div class="panel panel-default"><div class="panel-heading"><h4 class="panel-title"><a class="collapse-toggle" href="#w0-collapse4" data-toggle="collapse" data-parent="#w0"><h1>Collapsible Group Item #4</h1></a> +</h4></div> +<div id="w0-collapse4" class="panel-collapse collapse"><div class="panel-body"><h1>test content4</h1></div> +</div></div> +</div> + +HTML + , $output); + } +} diff --git a/tests/unit/framework/i18n/I18NTest.php b/tests/unit/framework/i18n/I18NTest.php index a3ab856..a6a343d 100644 --- a/tests/unit/framework/i18n/I18NTest.php +++ b/tests/unit/framework/i18n/I18NTest.php @@ -127,6 +127,23 @@ class I18NTest extends TestCase } /** + * https://github.com/yiisoft/yii2/issues/7093 + */ + public function testRussianPlurals() + { + $this->assertEquals('На диване лежит 6 кошек!', $this->i18n->translate('test', 'There {n, plural, =0{no cats} =1{one cat} other{are # cats}} on lying on the sofa!', ['n' => 6], 'ru')); + } + + public function testUsingSourceLanguageForMissingTranslation() + { + \Yii::$app->sourceLanguage = 'ru'; + \Yii::$app->language = 'en'; + + $msg = '{n, plural, =0{Нет комментариев} =1{# комментарий} one{# комментарий} few{# комментария} many{# комментариев} other{# комментария}}'; + $this->assertEquals('5 комментариев', \Yii::t('app', $msg, ['n' => 5])); + } + + /** * https://github.com/yiisoft/yii2/issues/2519 */ public function testMissingTranslationEvent() diff --git a/tests/unit/framework/web/UrlManagerTest.php b/tests/unit/framework/web/UrlManagerTest.php index 7ade7f2..4a2097d 100644 --- a/tests/unit/framework/web/UrlManagerTest.php +++ b/tests/unit/framework/web/UrlManagerTest.php @@ -84,6 +84,10 @@ class UrlManagerTest extends TestCase $url = $manager->createUrl(['post/index', 'page' => 1]); $this->assertEquals('/post/index?page=1', $url); + // rules with defaultAction + $url = $manager->createUrl(['/post', 'page' => 1]); + $this->assertEquals('/post?page=1', $url); + // pretty URL with rules and suffix $manager = new UrlManager([ 'enablePrettyUrl' => true,