Skip to content

Commit

Permalink
Merge branch 'master' into docs-guide-ja-structure-views-rev
Browse files Browse the repository at this point in the history
  • Loading branch information
softark committed Jan 31, 2015
2 parents 259eb1a + 1961957 commit 3d6109d
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/guide/structure-views.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 2 additions & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------------
Expand Down
6 changes: 3 additions & 3 deletions framework/grid/DataColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ protected function renderFilterCellContent()
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();
Expand Down
18 changes: 15 additions & 3 deletions framework/helpers/BaseConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,10 +769,22 @@ public static function prompt($text, $options = [])
*/
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;
}
}
}

/**
Expand Down
3 changes: 0 additions & 3 deletions framework/helpers/HtmlPurifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
*
* 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 <[email protected]>
* @since 2.0
*/
Expand Down
1 change: 1 addition & 0 deletions tests/unit/data/i18n/messages/ru/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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{лежит # кошки}}!',
];
71 changes: 71 additions & 0 deletions tests/unit/extensions/bootstrap/CollapseTest.php
Original file line number Diff line number Diff line change
@@ -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">&lt;h1&gt;Collapsible Group Item #2&lt;/h1&gt;</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">&lt;h1&gt;Collapsible Group Item #4&lt;/h1&gt;</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);
}
}
17 changes: 17 additions & 0 deletions tests/unit/framework/i18n/I18NTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ public function testMissingTranslationFormatting()
$this->assertEquals('1 item', $this->i18n->translate('test', '{0, number} {0, plural, one{item} other{items}}', 1, 'hu'));
}

/**
* 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
*/
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/framework/web/UrlManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public function testCreateUrl()
$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,
Expand Down

0 comments on commit 3d6109d

Please sign in to comment.