mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Fixed bad replacements :)
This commit is contained in:
@ -9,7 +9,7 @@ El siguiente código muestra el típico patrón de uso para el almacenamiento en
|
|||||||
// intenta recuperar $data de la caché
|
// intenta recuperar $data de la caché
|
||||||
$data = $cache->get($key);
|
$data = $cache->get($key);
|
||||||
|
|
||||||
if ($data === `false`) {
|
if ($data === false) {
|
||||||
|
|
||||||
// $data no ha sido encontrada en la caché, calcularla desde cero
|
// $data no ha sido encontrada en la caché, calcularla desde cero
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ $cache->set($key, $data, 45);
|
|||||||
sleep(50);
|
sleep(50);
|
||||||
|
|
||||||
$data = $cache->get($key);
|
$data = $cache->get($key);
|
||||||
if ($data === `false`) {
|
if ($data === false) {
|
||||||
// $data ha caducado o no ha sido encontrado en la memoria caché
|
// $data ha caducado o no ha sido encontrado en la memoria caché
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -121,7 +121,7 @@ Cuando se utiliza [widgets](structure-widgets.md), a menudo es necesario utiliza
|
|||||||
use yii\widgets\Menu;
|
use yii\widgets\Menu;
|
||||||
|
|
||||||
echo Menu::widget([
|
echo Menu::widget([
|
||||||
'activateItems' => `false`,
|
'activateItems' => false,
|
||||||
'items' => [
|
'items' => [
|
||||||
['label' => 'Home', 'url' => ['site/index']],
|
['label' => 'Home', 'url' => ['site/index']],
|
||||||
['label' => 'Products', 'url' => ['product/index']],
|
['label' => 'Products', 'url' => ['product/index']],
|
||||||
|
@ -32,8 +32,8 @@ A continuación, vamos a describir el uso principal y las propiedades de cada va
|
|||||||
|
|
||||||
Este validador comprueba si el valor de la entrada (input) es booleano.
|
Este validador comprueba si el valor de la entrada (input) es booleano.
|
||||||
|
|
||||||
- ``true`Value`: El valor representando *`true`*. Valor por defecto a `'1'`.
|
- `trueValue`: El valor representando `true`. Valor por defecto a `'1'`.
|
||||||
- ``false`Value`: El valor representando *`false`*. Valor por defecto a `'0'`.
|
- `falseValue`: El valor representando `false`. Valor por defecto a `'0'`.
|
||||||
- `strict`: Si el tipo del valor de la entrada (input) debe corresponder con `trueValue` y `falseValue`. Valor por defecto a `false`.
|
- `strict`: Si el tipo del valor de la entrada (input) debe corresponder con `trueValue` y `falseValue`. Valor por defecto a `false`.
|
||||||
|
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ $query->filterWhere([
|
|||||||
|
|
||||||
La seule différence entre [[yii\db\Query::filterWhere()|filterWhere()]] et [[yii\db\Query::where()|where()]] est que la première ignore les valeurs vides fournies dans la condition au [format haché](#hash-format). Ainsi si `$email` est vide alors que `$username` ne l'est pas, le code ci dessus produit la condition SQL `WHERE username=:username`.
|
La seule différence entre [[yii\db\Query::filterWhere()|filterWhere()]] et [[yii\db\Query::where()|where()]] est que la première ignore les valeurs vides fournies dans la condition au [format haché](#hash-format). Ainsi si `$email` est vide alors que `$username` ne l'est pas, le code ci dessus produit la condition SQL `WHERE username=:username`.
|
||||||
|
|
||||||
> Info: une valeur est considérée comme vide si elle est `null`e, un tableau vide, ou un chaîne de caractères vide, ou un chaîne de caractères constituée d'espaces uniquement.
|
> Info: une valeur est considérée comme vide si elle est nulle, un tableau vide, ou un chaîne de caractères vide, ou un chaîne de caractères constituée d'espaces uniquement.
|
||||||
|
|
||||||
Comme avec [[yii\db\Query::andWhere()|andWhere()]] et [[yii\db\Query::orWhere()|orWhere()]], vous pouvez utiliser [[yii\db\Query::andFilterWhere()|andFilterWhere()]] et [[yii\db\Query::orFilterWhere()|orFilterWhere()]] pour ajouter des conditions de filtrage supplémentaires à une condition existante.
|
Comme avec [[yii\db\Query::andWhere()|andWhere()]] et [[yii\db\Query::orWhere()|orWhere()]], vous pouvez utiliser [[yii\db\Query::andFilterWhere()|andFilterWhere()]] et [[yii\db\Query::orFilterWhere()|orFilterWhere()]] pour ajouter des conditions de filtrage supplémentaires à une condition existante.
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ public function behaviors()
|
|||||||
'access' => [
|
'access' => [
|
||||||
'class' => 'yii\filters\AccessControl',
|
'class' => 'yii\filters\AccessControl',
|
||||||
'rules' => [
|
'rules' => [
|
||||||
['allow' => `true`, 'actions' => ['admin'], 'roles' => ['@']],
|
['allow' => true, 'actions' => ['admin'], 'roles' => ['@']],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -308,7 +308,7 @@ public function behaviors()
|
|||||||
'access' => [
|
'access' => [
|
||||||
'class' => 'yii\filters\AccessControl',
|
'class' => 'yii\filters\AccessControl',
|
||||||
'rules' => [
|
'rules' => [
|
||||||
['allow' => `true`, 'actions' => ['admin'], 'roles' => ['@']],
|
['allow' => true, 'actions' => ['admin'], 'roles' => ['@']],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -109,7 +109,7 @@ class HelloWidget extends Widget
|
|||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
if ($this->message === `null`) {
|
if ($this->message === null) {
|
||||||
$this->message = 'Hello World';
|
$this->message = 'Hello World';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ It contains code like the following:
|
|||||||
* Yii console bootstrap file.
|
* Yii console bootstrap file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', `true`);
|
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||||
defined('YII_ENV') or define('YII_ENV', 'dev');
|
defined('YII_ENV') or define('YII_ENV', 'dev');
|
||||||
|
|
||||||
require(__DIR__ . '/vendor/autoload.php');
|
require(__DIR__ . '/vendor/autoload.php');
|
||||||
|
@ -27,15 +27,15 @@ In the following, we will describe the main usage and properties of every core v
|
|||||||
['selected', 'boolean'],
|
['selected', 'boolean'],
|
||||||
|
|
||||||
// checks if "deleted" is of boolean type, either `true` or `false`
|
// checks if "deleted" is of boolean type, either `true` or `false`
|
||||||
['deleted', 'boolean', '`true`Value' => `true`, '`false`Value' => `false`, 'strict' => `true`],
|
['deleted', 'boolean', 'trueValue' => true, 'falseValue' => false, 'strict' => true],
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
This validator checks if the input value is a boolean.
|
This validator checks if the input value is a boolean.
|
||||||
|
|
||||||
- ``true`Value`: the value representing *`true`*. Defaults to `'1'`.
|
- `trueValue`: the value representing `true`. Defaults to `'1'`.
|
||||||
- ``false`Value`: the value representing *`false`*. Defaults to `'0'`.
|
- `falseValue`: the value representing `false`. Defaults to `'0'`.
|
||||||
- `strict`: whether the type of the input value should match that of ``true`Value` and ``false`Value`. Defaults to `false`.
|
- `strict`: whether the type of the input value should match that of `trueValue` and `falseValue`. Defaults to `false`.
|
||||||
|
|
||||||
|
|
||||||
> Note: Because data input submitted via HTML forms are all strings, you normally should leave the
|
> Note: Because data input submitted via HTML forms are all strings, you normally should leave the
|
||||||
@ -105,7 +105,7 @@ you can use a combination of compare and date validator like the following:
|
|||||||
```php
|
```php
|
||||||
['fromDate', 'date', 'timestampAttribute' => 'fromDate'],
|
['fromDate', 'date', 'timestampAttribute' => 'fromDate'],
|
||||||
['toDate', 'date', 'timestampAttribute' => 'toDate'],
|
['toDate', 'date', 'timestampAttribute' => 'toDate'],
|
||||||
['fromDate', 'compare', 'compareAttribute' => 'toDate', 'operator' => '<', 'enableClientValidation' => `false`],
|
['fromDate', 'compare', 'compareAttribute' => 'toDate', 'operator' => '<', 'enableClientValidation' => false],
|
||||||
```
|
```
|
||||||
|
|
||||||
As validators are executed in the order they are specified this will first validate that the values entered in
|
As validators are executed in the order they are specified this will first validate that the values entered in
|
||||||
@ -153,7 +153,7 @@ or `1970-01-01` in the input field of a date picker.
|
|||||||
|
|
||||||
```php
|
```php
|
||||||
[
|
[
|
||||||
[['from_date', 'to_date'], 'default', 'value' => `null`],
|
[['from_date', 'to_date'], 'default', 'value' => null],
|
||||||
[['from_date', 'to_date'], 'date'],
|
[['from_date', 'to_date'], 'date'],
|
||||||
],
|
],
|
||||||
```
|
```
|
||||||
@ -271,7 +271,7 @@ This validator checks if the input value is a valid email address.
|
|||||||
['a1', 'exist', 'targetAttribute' => ['a2', 'a1' => 'a3']],
|
['a1', 'exist', 'targetAttribute' => ['a2', 'a1' => 'a3']],
|
||||||
|
|
||||||
// a1 needs to exist. If a1 is an array, then every element of it must exist.
|
// a1 needs to exist. If a1 is an array, then every element of it must exist.
|
||||||
['a1', 'exist', 'allowArray' => `true`],
|
['a1', 'exist', 'allowArray' => true],
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ section for complete coverage about uploading files and performing validation ab
|
|||||||
```php
|
```php
|
||||||
[
|
[
|
||||||
// trim "username" and "email" inputs
|
// trim "username" and "email" inputs
|
||||||
[['username', 'email'], 'filter', 'filter' => 'trim', 'skipOnArray' => `true`],
|
[['username', 'email'], 'filter', 'filter' => 'trim', 'skipOnArray' => true],
|
||||||
|
|
||||||
// normalize "phone" input
|
// normalize "phone" input
|
||||||
['phone', 'filter', 'filter' => function ($value) {
|
['phone', 'filter', 'filter' => function ($value) {
|
||||||
@ -400,11 +400,11 @@ validation purpose:
|
|||||||
|
|
||||||
// checks if "ip_address" is a valid IPv6 address or subnet,
|
// checks if "ip_address" is a valid IPv6 address or subnet,
|
||||||
// value will be expanded to full IPv6 notation.
|
// value will be expanded to full IPv6 notation.
|
||||||
['ip_address', 'ip', 'ipv4' => `false`, 'subnet' => `null`, 'expandIPv6' => `true`],
|
['ip_address', 'ip', 'ipv4' => false, 'subnet' => null, 'expandIPv6' => true],
|
||||||
|
|
||||||
// checks if "ip_address" is a valid IPv4 or IPv6 address,
|
// checks if "ip_address" is a valid IPv4 or IPv6 address,
|
||||||
// allows negation character `!` at the beginning
|
// allows negation character `!` at the beginning
|
||||||
['ip_address', 'ip', 'negation' => `true`],
|
['ip_address', 'ip', 'negation' => true],
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ class Module extends \yii\base\Module
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function t($category, $message, $params = [], $language = `null`)
|
public static function t($category, $message, $params = [], $language = null)
|
||||||
{
|
{
|
||||||
return Yii::t('modules/users/' . $category, $message, $params, $language);
|
return Yii::t('modules/users/' . $category, $message, $params, $language);
|
||||||
}
|
}
|
||||||
@ -547,7 +547,7 @@ class Menu extends Widget
|
|||||||
echo $this->render('index');
|
echo $this->render('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function t($category, $message, $params = [], $language = `null`)
|
public static function t($category, $message, $params = [], $language = null)
|
||||||
{
|
{
|
||||||
return Yii::t('widgets/menu/' . $category, $message, $params, $language);
|
return Yii::t('widgets/menu/' . $category, $message, $params, $language);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ You may place the following line of code at the beginning of the [entry script](
|
|||||||
disable debug mode:
|
disable debug mode:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', `false`);
|
defined('YII_DEBUG') or define('YII_DEBUG', false);
|
||||||
```
|
```
|
||||||
|
|
||||||
> Info: The default value of `YII_DEBUG` is `false`. So if you are certain that you do not change its default
|
> Info: The default value of `YII_DEBUG` is `false`. So if you are certain that you do not change its default
|
||||||
@ -66,7 +66,7 @@ return [
|
|||||||
'dsn' => 'mysql:host=localhost;dbname=mydatabase',
|
'dsn' => 'mysql:host=localhost;dbname=mydatabase',
|
||||||
'username' => 'root',
|
'username' => 'root',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
'enableSchemaCache' => `true`,
|
'enableSchemaCache' => true,
|
||||||
|
|
||||||
// Duration of schema cache.
|
// Duration of schema cache.
|
||||||
'schemaCacheDuration' => 3600,
|
'schemaCacheDuration' => 3600,
|
||||||
@ -121,7 +121,7 @@ component as the database connection and store the session data in the `session`
|
|||||||
|
|
||||||
```sql
|
```sql
|
||||||
CREATE TABLE session (
|
CREATE TABLE session (
|
||||||
id CHAR(40) NOT `NULL` PRIMARY KEY,
|
id CHAR(40) NOT NULL PRIMARY KEY,
|
||||||
expire INTEGER,
|
expire INTEGER,
|
||||||
data BLOB
|
data BLOB
|
||||||
)
|
)
|
||||||
|
@ -22,7 +22,7 @@ component's behavior:
|
|||||||
'cachePath' => '@runtime/Twig/cache',
|
'cachePath' => '@runtime/Twig/cache',
|
||||||
// Array of twig options:
|
// Array of twig options:
|
||||||
'options' => [
|
'options' => [
|
||||||
'auto_reload' => `true`,
|
'auto_reload' => true,
|
||||||
],
|
],
|
||||||
'globals' => ['html' => '\yii\helpers\Html'],
|
'globals' => ['html' => '\yii\helpers\Html'],
|
||||||
'uses' => ['yii\bootstrap'],
|
'uses' => ['yii\bootstrap'],
|
||||||
|
Reference in New Issue
Block a user