Browse Source

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

tags/2.0.0-beta
Klimov Paul 11 years ago
parent
commit
eecfba643b
  1. 4
      docs/guide/upgrade-from-v1.md
  2. 3
      framework/CHANGELOG.md
  3. 3
      framework/base/ActionFilter.php
  4. 22
      framework/console/controllers/MessageController.php
  5. 14
      framework/helpers/BaseHtml.php
  6. 2
      framework/messages/fr/yii.php

4
docs/guide/upgrade-from-v1.md

@ -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,
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,
```php
@ -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
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.

3
framework/CHANGELOG.md

@ -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 #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 #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: 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)
@ -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 #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 #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 `Widget::autoIdPrefix` to support prefixing automatically generated widget IDs (qiangxue)
- Enh: Support for file aliases in console command 'message' (omnilight)

3
framework/base/ActionFilter.php

@ -51,6 +51,9 @@ class ActionFilter extends Behavior
{
if ($this->isActive($event->action)) {
$event->isValid = $this->beforeAction($event->action);
if (!$event->isValid) {
$event->handled = true;
}
}
return $event->isValid;
}

22
framework/console/controllers/MessageController.php

@ -173,9 +173,8 @@ class MessageController extends Controller
if (is_file($fileName)) {
if($format === 'po'){
$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);
$translated = array_combine($keys[0], $values[0]);
} else {
$translated = require($fileName);
@ -189,6 +188,9 @@ class MessageController extends Controller
$merged = [];
$untranslated = [];
foreach ($messages as $message) {
if($format === 'po'){
$message = preg_replace('/\"/', '\"', $message);
}
if (array_key_exists($message, $translated) && strlen($translated[$message]) > 0) {
$merged[$message] = $translated[$message];
} else {
@ -218,11 +220,18 @@ class MessageController extends Controller
if (false === $overwrite) {
$fileName .= '.merged';
}
if($format === 'po'){
if ($format === 'po'){
$out_str = '';
foreach($merged as $k=>$v){
$out_str .= "msgid \"$k\"\n";
$out_str .= "msgstr \"$v\"\n";
foreach ($merged as $k => $v){
$k = preg_replace('/(\")|(\\\")/', "\\\"", $k);
$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";
}
$merged = $out_str;
@ -233,6 +242,7 @@ class MessageController extends Controller
$merged = '';
sort($messages);
foreach($messages as $message) {
$message = preg_replace('/(\")|(\\\")/', '\\\"', $message);
$merged .= "msgid \"$message\"\n";
$merged .= "msgstr \"\"\n";
$merged .= "\n";

14
framework/helpers/BaseHtml.php

@ -1126,10 +1126,17 @@ class BaseHtml
public static function activeRadio($model, $attribute, $options = [])
{
$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)) {
$options['uncheck'] = '0';
}
$checked = "$value" === "{$options['value']}";
if (!array_key_exists('id', $options)) {
$options['id'] = static::getInputId($model, $attribute);
}
@ -1163,11 +1170,14 @@ class BaseHtml
$name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
$value = static::getAttributeValue($model, $attribute);
if (!array_key_exists('value', $options)) {
$options['value'] = '1';
}
if (!array_key_exists('uncheck', $options)) {
$options['uncheck'] = '0';
}
$checked = ($value != $options['uncheck']);
$checked = "$value" === "{$options['value']}";
if (!array_key_exists('id', $options)) {
$options['id'] = static::getInputId($model, $attribute);

2
framework/messages/fr/yii.php

@ -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 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 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} 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}}.',

Loading…
Cancel
Save