Browse Source

Fixes #3656: Encode / in "r" query parameter in docs as it really is

tags/2.0.8
Alexander Makarov 9 years ago
parent
commit
d3b5f4a284
  1. 26
      docs/guide/helper-url.md
  2. 4
      docs/guide/output-pagination.md
  3. 2
      docs/guide/output-sorting.md
  4. 26
      docs/guide/runtime-routing.md
  5. 4
      docs/guide/start-databases.md
  6. 2
      docs/guide/start-forms.md
  7. 2
      docs/guide/start-gii.md
  8. 2
      docs/guide/start-hello.md
  9. 2
      docs/guide/structure-views.md
  10. 22
      framework/helpers/BaseUrl.php
  11. 6
      framework/web/UrlManager.php

26
docs/guide/helper-url.md

@ -42,14 +42,14 @@ You may specify the route as a string, e.g., `site/index`. You may also use an a
query parameters for the URL being created. The array format must be: query parameters for the URL being created. The array format must be:
```php ```php
// generates: /index.php?r=site/index&param1=value1&param2=value2 // generates: /index.php?r=site%2Findex&param1=value1&param2=value2
['site/index', 'param1' => 'value1', 'param2' => 'value2'] ['site/index', 'param1' => 'value1', 'param2' => 'value2']
``` ```
If you want to create a URL with an anchor, you can use the array format with a `#` parameter. For example, If you want to create a URL with an anchor, you can use the array format with a `#` parameter. For example,
```php ```php
// generates: /index.php?r=site/index&param1=value1#name // generates: /index.php?r=site%2Findex&param1=value1#name
['site/index', 'param1' => 'value1', '#' => 'name'] ['site/index', 'param1' => 'value1', '#' => 'name']
``` ```
@ -69,19 +69,19 @@ to the above rules.
Below are some examples of using this method: Below are some examples of using this method:
```php ```php
// /index.php?r=site/index // /index.php?r=site%2Findex
echo Url::toRoute('site/index'); echo Url::toRoute('site/index');
// /index.php?r=site/index&src=ref1#name // /index.php?r=site%2Findex&src=ref1#name
echo Url::toRoute(['site/index', 'src' => 'ref1', '#' => 'name']); echo Url::toRoute(['site/index', 'src' => 'ref1', '#' => 'name']);
// /index.php?r=post/edit&id=100 assume the alias "@postEdit" is defined as "post/edit" // /index.php?r=post%2Fedit&id=100 assume the alias "@postEdit" is defined as "post/edit"
echo Url::toRoute(['@postEdit', 'id' => 100]); echo Url::toRoute(['@postEdit', 'id' => 100]);
// http://www.example.com/index.php?r=site/index // http://www.example.com/index.php?r=site%2Findex
echo Url::toRoute('site/index', true); echo Url::toRoute('site/index', true);
// https://www.example.com/index.php?r=site/index // https://www.example.com/index.php?r=site%2Findex
echo Url::toRoute('site/index', 'https'); echo Url::toRoute('site/index', 'https');
``` ```
@ -105,13 +105,13 @@ will be replaced with the specified one.
Below are some usage examples: Below are some usage examples:
```php ```php
// /index.php?r=site/index // /index.php?r=site%2Findex
echo Url::to(['site/index']); echo Url::to(['site/index']);
// /index.php?r=site/index&src=ref1#name // /index.php?r=site%2Findex&src=ref1#name
echo Url::to(['site/index', 'src' => 'ref1', '#' => 'name']); echo Url::to(['site/index', 'src' => 'ref1', '#' => 'name']);
// /index.php?r=post/edit&id=100 assume the alias "@postEdit" is defined as "post/edit" // /index.php?r=post%2Fedit&id=100 assume the alias "@postEdit" is defined as "post/edit"
echo Url::to(['@postEdit', 'id' => 100]); echo Url::to(['@postEdit', 'id' => 100]);
// the currently requested URL // the currently requested URL
@ -137,12 +137,12 @@ passing a `$params` parameter to the method. For example,
```php ```php
// assume $_GET = ['id' => 123, 'src' => 'google'], current route is "post/view" // assume $_GET = ['id' => 123, 'src' => 'google'], current route is "post/view"
// /index.php?r=post/view&id=123&src=google // /index.php?r=post%2Fview&id=123&src=google
echo Url::current(); echo Url::current();
// /index.php?r=post/view&id=123 // /index.php?r=post%2Fview&id=123
echo Url::current(['src' => null]); echo Url::current(['src' => null]);
// /index.php?r=post/view&id=100&src=google // /index.php?r=post%2Fview&id=100&src=google
echo Url::current(['id' => 100]); echo Url::current(['id' => 100]);
``` ```

4
docs/guide/output-pagination.md

@ -61,10 +61,10 @@ containing the page parameter. For example,
// If you do not specify this, the currently requested route will be used // If you do not specify this, the currently requested route will be used
$pagination->route = 'article/index'; $pagination->route = 'article/index';
// displays: /index.php?r=article/index&page=100 // displays: /index.php?r=article%2Findex&page=100
echo $pagination->createUrl(100); echo $pagination->createUrl(100);
// displays: /index.php?r=article/index&page=101 // displays: /index.php?r=article%2Findex&page=101
echo $pagination->createUrl(101); echo $pagination->createUrl(101);
``` ```

2
docs/guide/output-sorting.md

@ -80,7 +80,7 @@ $sort->route = 'article/index';
// display links leading to sort by name and age, respectively // display links leading to sort by name and age, respectively
echo $sort->link('name') . ' | ' . $sort->link('age'); echo $sort->link('name') . ' | ' . $sort->link('age');
// displays: /index.php?r=article/index&sort=age // displays: /index.php?r=article%2Findex&sort=age
echo $sort->createUrl('age'); echo $sort->createUrl('age');
``` ```

26
docs/guide/runtime-routing.md

@ -30,7 +30,7 @@ Depending on the `urlManager` configuration, the created URL may look like one o
And if the created URL is requested later, it will still be parsed back into the original route and query parameter value. And if the created URL is requested later, it will still be parsed back into the original route and query parameter value.
``` ```
/index.php?r=post/view&id=100 /index.php?r=post%2Fview&id=100
/index.php/post/100 /index.php/post/100
/posts/100 /posts/100
``` ```
@ -133,19 +133,19 @@ their associated query parameters. For example,
```php ```php
use yii\helpers\Url; use yii\helpers\Url;
// creates a URL to a route: /index.php?r=post/index // creates a URL to a route: /index.php?r=post%2Findex
echo Url::to(['post/index']); echo Url::to(['post/index']);
// creates a URL to a route with parameters: /index.php?r=post/view&id=100 // creates a URL to a route with parameters: /index.php?r=post%2Fview&id=100
echo Url::to(['post/view', 'id' => 100]); echo Url::to(['post/view', 'id' => 100]);
// creates an anchored URL: /index.php?r=post/view&id=100#content // creates an anchored URL: /index.php?r=post%2Fview&id=100#content
echo Url::to(['post/view', 'id' => 100, '#' => 'content']); echo Url::to(['post/view', 'id' => 100, '#' => 'content']);
// creates an absolute URL: http://www.example.com/index.php?r=post/index // creates an absolute URL: http://www.example.com/index.php?r=post%2Findex
echo Url::to(['post/index'], true); echo Url::to(['post/index'], true);
// creates an absolute URL using the https scheme: https://www.example.com/index.php?r=post/index // creates an absolute URL using the https scheme: https://www.example.com/index.php?r=post%2Findex
echo Url::to(['post/index'], 'https'); echo Url::to(['post/index'], 'https');
``` ```
@ -170,19 +170,19 @@ For example, assume the current module is `admin` and the current controller is
```php ```php
use yii\helpers\Url; use yii\helpers\Url;
// currently requested route: /index.php?r=admin/post/index // currently requested route: /index.php?r=admin%2Fpost%2Findex
echo Url::to(['']); echo Url::to(['']);
// a relative route with action ID only: /index.php?r=admin/post/index // a relative route with action ID only: /index.php?r=admin%2Fpost%2Findex
echo Url::to(['index']); echo Url::to(['index']);
// a relative route: /index.php?r=admin/post/index // a relative route: /index.php?r=admin%2Fpost%2Findex
echo Url::to(['post/index']); echo Url::to(['post/index']);
// an absolute route: /index.php?r=post/index // an absolute route: /index.php?r=post%2Findex
echo Url::to(['/post/index']); echo Url::to(['/post/index']);
// /index.php?r=post/index assume the alias "@posts" is defined as "/post/index" // /index.php?r=post%2Findex assume the alias "@posts" is defined as "/post/index"
echo Url::to(['@posts']); echo Url::to(['@posts']);
``` ```
@ -197,7 +197,7 @@ Instead of passing an array as its first parameter, you should pass a string in
```php ```php
use yii\helpers\Url; use yii\helpers\Url;
// currently requested URL: /index.php?r=admin/post/index // currently requested URL: /index.php?r=admin%2Fpost%2Findex
echo Url::to(); echo Url::to();
// an aliased URL: http://example.com // an aliased URL: http://example.com
@ -214,7 +214,7 @@ methods. For example,
```php ```php
use yii\helpers\Url; use yii\helpers\Url;
// home page URL: /index.php?r=site/index // home page URL: /index.php?r=site%2Findex
echo Url::home(); echo Url::home();
// the base URL, useful if the application is deployed in a sub-folder of the Web root // the base URL, useful if the application is deployed in a sub-folder of the Web root

4
docs/guide/start-databases.md

@ -225,7 +225,7 @@ Trying it Out <span id="trying-it-out"></span>
To see how all of the above code works, use your browser to access the following URL: To see how all of the above code works, use your browser to access the following URL:
``` ```
http://hostname/index.php?r=country/index http://hostname/index.php?r=country%2Findex
``` ```
![Country List](images/start-country-list.png) ![Country List](images/start-country-list.png)
@ -235,7 +235,7 @@ If you click on the button "2", you will see the page display another five count
Observe more carefully and you will find that the URL in the browser also changes to Observe more carefully and you will find that the URL in the browser also changes to
``` ```
http://hostname/index.php?r=country/index&page=2 http://hostname/index.php?r=country%2Findex&page=2
``` ```
Behind the scenes, [[yii\data\Pagination|Pagination]] is providing all of the necessary functionality to paginate a data set: Behind the scenes, [[yii\data\Pagination|Pagination]] is providing all of the necessary functionality to paginate a data set:

2
docs/guide/start-forms.md

@ -187,7 +187,7 @@ Trying it Out <span id="trying-it-out"></span>
To see how it works, use your browser to access the following URL: To see how it works, use your browser to access the following URL:
``` ```
http://hostname/index.php?r=site/entry http://hostname/index.php?r=site%2Fentry
``` ```
You will see a page displaying a form with two input fields. In front of each input field, a label indicates what data is to be entered. If you click the submit button without You will see a page displaying a form with two input fields. In front of each input field, a label indicates what data is to be entered. If you click the submit button without

2
docs/guide/start-gii.md

@ -107,7 +107,7 @@ Trying it Out <span id="trying-it-out"></span>
To see how it works, use your browser to access the following URL: To see how it works, use your browser to access the following URL:
``` ```
http://hostname/index.php?r=country/index http://hostname/index.php?r=country%2Findex
``` ```
You will see a data grid showing the countries from the database table. You may sort the grid, You will see a data grid showing the countries from the database table. You may sort the grid,

2
docs/guide/start-hello.md

@ -102,7 +102,7 @@ Trying it Out <span id="trying-it-out"></span>
After creating the action and the view, you may access the new page by accessing the following URL: After creating the action and the view, you may access the new page by accessing the following URL:
``` ```
http://hostname/index.php?r=site/say&message=Hello+World http://hostname/index.php?r=site%2Fsay&message=Hello+World
``` ```
![Hello World](images/start-hello-world.png) ![Hello World](images/start-hello-world.png)

2
docs/guide/structure-views.md

@ -694,7 +694,7 @@ Now if you create a view named `about` under the directory `@app/views/site/page
display this view by the following URL: display this view by the following URL:
``` ```
http://localhost/index.php?r=site/page&view=about http://localhost/index.php?r=site%2Fpage&view=about
``` ```
The `GET` parameter `view` tells [[yii\web\ViewAction]] which view is requested. The action will then look The `GET` parameter `view` tells [[yii\web\ViewAction]] which view is requested. The action will then look

22
framework/helpers/BaseUrl.php

@ -65,19 +65,19 @@ class BaseUrl
* Below are some examples of using this method: * Below are some examples of using this method:
* *
* ```php * ```php
* // /index.php?r=site/index * // /index.php?r=site%2Findex
* echo Url::toRoute('site/index'); * echo Url::toRoute('site/index');
* *
* // /index.php?r=site/index&src=ref1#name * // /index.php?r=site%2Findex&src=ref1#name
* echo Url::toRoute(['site/index', 'src' => 'ref1', '#' => 'name']); * echo Url::toRoute(['site/index', 'src' => 'ref1', '#' => 'name']);
* *
* // http://www.example.com/index.php?r=site/index * // http://www.example.com/index.php?r=site%2Findex
* echo Url::toRoute('site/index', true); * echo Url::toRoute('site/index', true);
* *
* // https://www.example.com/index.php?r=site/index * // https://www.example.com/index.php?r=site%2Findex
* echo Url::toRoute('site/index', 'https'); * echo Url::toRoute('site/index', 'https');
* *
* // /index.php?r=post/index assume the alias "@posts" is defined as "post/index" * // /index.php?r=post%2Findex assume the alias "@posts" is defined as "post/index"
* echo Url::toRoute('@posts'); * echo Url::toRoute('@posts');
* ``` * ```
* *
@ -167,13 +167,13 @@ class BaseUrl
* Below are some examples of using this method: * Below are some examples of using this method:
* *
* ```php * ```php
* // /index.php?r=site/index * // /index.php?r=site%2Findex
* echo Url::to(['site/index']); * echo Url::to(['site/index']);
* *
* // /index.php?r=site/index&src=ref1#name * // /index.php?r=site%2Findex&src=ref1#name
* echo Url::to(['site/index', 'src' => 'ref1', '#' => 'name']); * echo Url::to(['site/index', 'src' => 'ref1', '#' => 'name']);
* *
* // /index.php?r=post/index assume the alias "@posts" is defined as "/post/index" * // /index.php?r=post%2Findex assume the alias "@posts" is defined as "/post/index"
* echo Url::to(['@posts']); * echo Url::to(['@posts']);
* *
* // the currently requested URL * // the currently requested URL
@ -361,13 +361,13 @@ class BaseUrl
* ```php * ```php
* // assume $_GET = ['id' => 123, 'src' => 'google'], current route is "post/view" * // assume $_GET = ['id' => 123, 'src' => 'google'], current route is "post/view"
* *
* // /index.php?r=post/view&id=123&src=google * // /index.php?r=post%2Fview&id=123&src=google
* echo Url::current(); * echo Url::current();
* *
* // /index.php?r=post/view&id=123 * // /index.php?r=post%2Fview&id=123
* echo Url::current(['src' => null]); * echo Url::current(['src' => null]);
* *
* // /index.php?r=post/view&id=100&src=google * // /index.php?r=post%2Fview&id=100&src=google
* echo Url::current(['id' => 100]); * echo Url::current(['id' => 100]);
* ``` * ```
* *

6
framework/web/UrlManager.php

@ -46,7 +46,7 @@ class UrlManager extends Component
* @var boolean whether to enable pretty URLs. Instead of putting all parameters in the query * @var boolean whether to enable pretty URLs. Instead of putting all parameters in the query
* string part of a URL, pretty URLs allow using path info to represent some of the parameters * string part of a URL, pretty URLs allow using path info to represent some of the parameters
* and can thus produce more user-friendly URLs, such as "/news/Yii-is-released", instead of * and can thus produce more user-friendly URLs, such as "/news/Yii-is-released", instead of
* "/index.php?r=news/view&id=100". * "/index.php?r=news%2Fview&id=100".
*/ */
public $enablePrettyUrl = false; public $enablePrettyUrl = false;
/** /**
@ -282,7 +282,7 @@ class UrlManager extends Component
* array format must be: * array format must be:
* *
* ```php * ```php
* // generates: /index.php?r=site/index&param1=value1&param2=value2 * // generates: /index.php?r=site%2Findex&param1=value1&param2=value2
* ['site/index', 'param1' => 'value1', 'param2' => 'value2'] * ['site/index', 'param1' => 'value1', 'param2' => 'value2']
* ``` * ```
* *
@ -290,7 +290,7 @@ class UrlManager extends Component
* For example, * For example,
* *
* ```php * ```php
* // generates: /index.php?r=site/index&param1=value1#name * // generates: /index.php?r=site%2Findex&param1=value1#name
* ['site/index', 'param1' => 'value1', '#' => 'name'] * ['site/index', 'param1' => 'value1', '#' => 'name']
* ``` * ```
* *

Loading…
Cancel
Save