Commit eecfba64 by Klimov Paul

Merge branch 'master' of github.com:yiisoft/yii2 into 1837-3rd-party-doc

parents 8cb701ae e0f20abd
...@@ -183,7 +183,7 @@ A model is now associated with a form name returned by its `formName()` method. ...@@ -183,7 +183,7 @@ A model is now associated with a form name returned by its `formName()` method.
mainly used when using HTML forms to collect user inputs for a model. Previously in 1.1, mainly used when using HTML forms to collect user inputs for a model. Previously in 1.1,
this is usually hardcoded as the class name of the model. this is usually hardcoded as the class name of the model.
A new methods called `load()` and `Model::loadMultiple()` is introduced to simplify the data population from user inputs New methods called `load()` and `Model::loadMultiple()` are introduced to simplify the data population from user inputs
to a model. For example, to a model. For example,
```php ```php
...@@ -522,4 +522,4 @@ Yii is fully inegrated with the package manager for PHP named Composer that reso ...@@ -522,4 +522,4 @@ Yii is fully inegrated with the package manager for PHP named Composer that reso
up to date updating it semi-automatically and manages autoloading for third party libraries no matter which autoloading up to date updating it semi-automatically and manages autoloading for third party libraries no matter which autoloading
these are using. these are using.
In order to learn more refer to [composer](composer.md) and [installation](installation.md) sections of the guide. In order to learn more refer to [composer](composer.md) and [installation](installation.md) sections of the guide.
\ No newline at end of file
...@@ -27,7 +27,7 @@ Yii Framework 2 Change Log ...@@ -27,7 +27,7 @@ Yii Framework 2 Change Log
- Bug #1827: Debugger toolbar is loaded twice if an action is calling `run()` to execute another action (qiangxue) - Bug #1827: Debugger toolbar is loaded twice if an action is calling `run()` to execute another action (qiangxue)
- Bug #1870: Validation errors weren't properly translated when using clientside validation (samdark) - Bug #1870: Validation errors weren't properly translated when using clientside validation (samdark)
- Bug #1937: Fixed wrong behavior or advanced app's `init --env` when called without parameter actually specified (samdark) - Bug #1937: Fixed wrong behavior or advanced app's `init --env` when called without parameter actually specified (samdark)
- Bug #1959: `Html::activeCheckbox` wasn't respecting custom values for checked/unckecked state (klevron, samdark) - Bug #1959: `Html::activeCheckbox` wasn't respecting custom values for checked/unchecked state (klevron, samdark)
- Bug #1965: `Controller::findLayoutFile()` returns incorrect file path when layout name starts with a slash (qiangxue) - Bug #1965: `Controller::findLayoutFile()` returns incorrect file path when layout name starts with a slash (qiangxue)
- Bug: Fixed `Call to a member function registerAssetFiles() on a non-object` in case of wrong `sourcePath` for an asset bundle (samdark) - Bug: Fixed `Call to a member function registerAssetFiles() on a non-object` in case of wrong `sourcePath` for an asset bundle (samdark)
- Bug: Fixed incorrect event name for `yii\jui\Spinner` (samdark) - Bug: Fixed incorrect event name for `yii\jui\Spinner` (samdark)
...@@ -65,6 +65,7 @@ Yii Framework 2 Change Log ...@@ -65,6 +65,7 @@ Yii Framework 2 Change Log
- Enh #1894: The path aliases `@webroot` and `@web` are now available right after the application is initialized (qiangxue) - Enh #1894: The path aliases `@webroot` and `@web` are now available right after the application is initialized (qiangxue)
- Enh #1921: Grid view ActionColumn now allow to name buttons like `{controller/action}` (creocoder) - Enh #1921: Grid view ActionColumn now allow to name buttons like `{controller/action}` (creocoder)
- Enh #1973: `yii message/extract` is now able to generate `.po` files (SergeiKutanov, samdark) - Enh #1973: `yii message/extract` is now able to generate `.po` files (SergeiKutanov, samdark)
- Enh #1984: ActionFilter will now mark event as handled when action run is aborted (cebe)
- Enh: Added `favicon.ico` and `robots.txt` to default application templates (samdark) - Enh: Added `favicon.ico` and `robots.txt` to default application templates (samdark)
- Enh: Added `Widget::autoIdPrefix` to support prefixing automatically generated widget IDs (qiangxue) - Enh: Added `Widget::autoIdPrefix` to support prefixing automatically generated widget IDs (qiangxue)
- Enh: Support for file aliases in console command 'message' (omnilight) - Enh: Support for file aliases in console command 'message' (omnilight)
......
...@@ -51,6 +51,9 @@ class ActionFilter extends Behavior ...@@ -51,6 +51,9 @@ class ActionFilter extends Behavior
{ {
if ($this->isActive($event->action)) { if ($this->isActive($event->action)) {
$event->isValid = $this->beforeAction($event->action); $event->isValid = $this->beforeAction($event->action);
if (!$event->isValid) {
$event->handled = true;
}
} }
return $event->isValid; return $event->isValid;
} }
......
...@@ -173,9 +173,8 @@ class MessageController extends Controller ...@@ -173,9 +173,8 @@ class MessageController extends Controller
if (is_file($fileName)) { if (is_file($fileName)) {
if($format === 'po'){ if($format === 'po'){
$translated = file_get_contents($fileName); $translated = file_get_contents($fileName);
preg_match_all('/(?<=msgid ").*(?="\nmsgstr)/', $translated, $keys); preg_match_all('/(?<=msgid ").*(?="\n(#*)msgstr)/', $translated, $keys);
preg_match_all('/(?<=msgstr ").*(?="\n\n)/', $translated, $values); preg_match_all('/(?<=msgstr ").*(?="\n\n)/', $translated, $values);
$translated = array_combine($keys[0], $values[0]); $translated = array_combine($keys[0], $values[0]);
} else { } else {
$translated = require($fileName); $translated = require($fileName);
...@@ -189,6 +188,9 @@ class MessageController extends Controller ...@@ -189,6 +188,9 @@ class MessageController extends Controller
$merged = []; $merged = [];
$untranslated = []; $untranslated = [];
foreach ($messages as $message) { foreach ($messages as $message) {
if($format === 'po'){
$message = preg_replace('/\"/', '\"', $message);
}
if (array_key_exists($message, $translated) && strlen($translated[$message]) > 0) { if (array_key_exists($message, $translated) && strlen($translated[$message]) > 0) {
$merged[$message] = $translated[$message]; $merged[$message] = $translated[$message];
} else { } else {
...@@ -218,11 +220,18 @@ class MessageController extends Controller ...@@ -218,11 +220,18 @@ class MessageController extends Controller
if (false === $overwrite) { if (false === $overwrite) {
$fileName .= '.merged'; $fileName .= '.merged';
} }
if($format === 'po'){ if ($format === 'po'){
$out_str = ''; $out_str = '';
foreach($merged as $k=>$v){ foreach ($merged as $k => $v){
$out_str .= "msgid \"$k\"\n"; $k = preg_replace('/(\")|(\\\")/', "\\\"", $k);
$out_str .= "msgstr \"$v\"\n"; $v = preg_replace('/(\")|(\\\")/', "\\\"", $v);
if (substr($v, 0, 2) === '@@' && substr($v, -2) === '@@') {
$out_str .= "#msgid \"$k\"\n";
$out_str .= "#msgstr \"$v\"\n";
} else {
$out_str .= "msgid \"$k\"\n";
$out_str .= "msgstr \"$v\"\n";
}
$out_str .= "\n"; $out_str .= "\n";
} }
$merged = $out_str; $merged = $out_str;
...@@ -233,6 +242,7 @@ class MessageController extends Controller ...@@ -233,6 +242,7 @@ class MessageController extends Controller
$merged = ''; $merged = '';
sort($messages); sort($messages);
foreach($messages as $message) { foreach($messages as $message) {
$message = preg_replace('/(\")|(\\\")/', '\\\"', $message);
$merged .= "msgid \"$message\"\n"; $merged .= "msgid \"$message\"\n";
$merged .= "msgstr \"\"\n"; $merged .= "msgstr \"\"\n";
$merged .= "\n"; $merged .= "\n";
......
...@@ -1126,10 +1126,17 @@ class BaseHtml ...@@ -1126,10 +1126,17 @@ class BaseHtml
public static function activeRadio($model, $attribute, $options = []) public static function activeRadio($model, $attribute, $options = [])
{ {
$name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute); $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
$checked = static::getAttributeValue($model, $attribute); $value = static::getAttributeValue($model, $attribute);
if (!array_key_exists('value', $options)) {
$options['value'] = '1';
}
if (!array_key_exists('uncheck', $options)) { if (!array_key_exists('uncheck', $options)) {
$options['uncheck'] = '0'; $options['uncheck'] = '0';
} }
$checked = "$value" === "{$options['value']}";
if (!array_key_exists('id', $options)) { if (!array_key_exists('id', $options)) {
$options['id'] = static::getInputId($model, $attribute); $options['id'] = static::getInputId($model, $attribute);
} }
...@@ -1163,11 +1170,14 @@ class BaseHtml ...@@ -1163,11 +1170,14 @@ class BaseHtml
$name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute); $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
$value = static::getAttributeValue($model, $attribute); $value = static::getAttributeValue($model, $attribute);
if (!array_key_exists('value', $options)) {
$options['value'] = '1';
}
if (!array_key_exists('uncheck', $options)) { if (!array_key_exists('uncheck', $options)) {
$options['uncheck'] = '0'; $options['uncheck'] = '0';
} }
$checked = ($value != $options['uncheck']); $checked = "$value" === "{$options['value']}";
if (!array_key_exists('id', $options)) { if (!array_key_exists('id', $options)) {
$options['id'] = static::getInputId($model, $attribute); $options['id'] = static::getInputId($model, $attribute);
......
...@@ -73,7 +73,7 @@ return array ( ...@@ -73,7 +73,7 @@ return array (
'{attribute} must be less than or equal to "{compareValue}".' => '{attribute} doit être inférieur ou égal à « {compareValue} ».', '{attribute} must be less than or equal to "{compareValue}".' => '{attribute} doit être inférieur ou égal à « {compareValue} ».',
'{attribute} must be no greater than {max}.' => '{attribute} ne doit pas être supérieur à {max}.', '{attribute} must be no greater than {max}.' => '{attribute} ne doit pas être supérieur à {max}.',
'{attribute} must be no less than {min}.' => '{attribute} ne doit pas être inférieur à {min}.', '{attribute} must be no less than {min}.' => '{attribute} ne doit pas être inférieur à {min}.',
'{attribute} must be repeated exactly.' => '{attribute} doit être répété à l\'identique.', '{attribute} must be repeated exactly.' => '{attribute} doit être identique.',
'{attribute} must not be equal to "{compareValue}".' => '{attribute} ne doit pas être égal à « {compareValue} ».', '{attribute} must not be equal to "{compareValue}".' => '{attribute} ne doit pas être égal à « {compareValue} ».',
'{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => '{attribute} doit comporter au moins {min, number} {min, plural, one{caractère} other{caractères}}.', '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => '{attribute} doit comporter au moins {min, number} {min, plural, one{caractère} other{caractères}}.',
'{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.' => '{attribute} doit comporter au plus {max, number} {max, plural, one{caractère} other{caractères}}.', '{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.' => '{attribute} doit comporter au plus {max, number} {max, plural, one{caractère} other{caractères}}.',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment