Index: trunk/phase3/includes/PathRouter.php |
— | — | @@ -17,10 +17,8 @@ |
18 | 18 | * - Matches /foo/Bar explicitly and uses "Baz" as the title |
19 | 19 | * $router->add( '/help/$1', array( 'title' => 'Help:$1' ) ); |
20 | 20 | * - Matches /help/Foo with "Help:Foo" as the title |
21 | | - * $router->add( '/help/$1', array( 'title' => 'Help:$1' ) ); |
22 | | - * - Matches |
23 | 21 | * $router->add( '/$1', array( 'foo' => array( 'value' => 'bar$2' ) ); |
24 | | - * - Matches /Foo and sets 'foo=bar$2' without $2 being replaced |
| 22 | + * - Matches /Foo and sets 'foo' to 'bar$2' without $2 being replaced |
25 | 23 | * $router->add( '/$1', array( 'data:foo' => 'bar' ), array( 'callback' => 'functionname' ) ); |
26 | 24 | * - Matches /Foo, adds the key 'foo' with the value 'bar' to the data array |
27 | 25 | * and calls functionname( &$matches, $data ); |
— | — | @@ -32,23 +30,26 @@ |
33 | 31 | * |
34 | 32 | * Params: |
35 | 33 | * - In a pattern $1, $2, etc... will be replaced with the relevant contents |
36 | | - * - If you used a keyed array as a path pattern $key will be replaced with the relevant contents |
37 | | - * - The default behavior is equivalent to `array( 'title' => '$1' )`, if you don't want the title parameter you can explicitly use `array( 'title' => false )` |
38 | | - * - You can specify a value that won't have replacements in it using `'foo' => array( 'value' => 'bar' );` |
| 34 | + * - If you used a keyed array as a path pattern, $key will be replaced with |
| 35 | + * the relevant contents |
| 36 | + * - The default behavior is equivalent to `array( 'title' => '$1' )`, |
| 37 | + * if you don't want the title parameter you can explicitly use `array( 'title' => false )` |
| 38 | + * - You can specify a value that won't have replacements in it |
| 39 | + * using `'foo' => array( 'value' => 'bar' );` |
39 | 40 | * |
40 | 41 | * Options: |
41 | | - * - The option keys $1, $2, etc... can be specified to restrict the possible values of that variable. |
42 | | - * A string can be used for a single value, or an array for multiple. |
| 42 | + * - The option keys $1, $2, etc... can be specified to restrict the possible values |
| 43 | + * of that variable. A string can be used for a single value, or an array for multiple. |
43 | 44 | * - When the option key 'strict' is set (Using addStrict is simpler than doing this directly) |
44 | 45 | * the path won't have $1 implicitly added to it. |
45 | 46 | * - The option key 'callback' can specify a callback that will be run when a path is matched. |
46 | | - * The callback will have the arguments ( &$matches, $data ) and the matches array can be modified. |
| 47 | + * The callback will have the arguments ( &$matches, $data ) and the matches array can |
| 48 | + * be modified. |
47 | 49 | * |
48 | 50 | * @since 1.19 |
49 | 51 | * @author Daniel Friesen |
50 | 52 | */ |
51 | 53 | class PathRouter { |
52 | | - |
53 | 54 | protected function doAdd( $path, $params, $options, $key = null ) { |
54 | 55 | if ( $path[0] !== '/' ) { |
55 | 56 | $path = '/' . $path; |
— | — | @@ -95,10 +96,10 @@ |
96 | 97 | } |
97 | 98 | |
98 | 99 | $pattern = (object)array( |
99 | | - 'path' => $path, |
100 | | - 'params' => $params, |
| 100 | + 'path' => $path, |
| 101 | + 'params' => $params, |
101 | 102 | 'options' => $options, |
102 | | - 'key' => $key, |
| 103 | + 'key' => $key, |
103 | 104 | ); |
104 | 105 | $pattern->weight = self::makeWeight( $pattern ); |
105 | 106 | $this->patterns[] = $pattern; |