r105510 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105509‎ | r105510 | r105511 >
Date:02:02, 8 December 2011
Author:aaron
Status:ok
Tags:
Comment:
FU r104688:
* Removed a bit of cruft in from a comment (c&p error)
* Clarified 'value' params comment (AFAIK)
* Broke some long lines and made some other w/s cleanups
Modified paths:
  • /trunk/phase3/includes/PathRouter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/PathRouter.php
@@ -17,10 +17,8 @@
1818 * - Matches /foo/Bar explicitly and uses "Baz" as the title
1919 * $router->add( '/help/$1', array( 'title' => 'Help:$1' ) );
2020 * - Matches /help/Foo with "Help:Foo" as the title
21 - * $router->add( '/help/$1', array( 'title' => 'Help:$1' ) );
22 - * - Matches
2321 * $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
2523 * $router->add( '/$1', array( 'data:foo' => 'bar' ), array( 'callback' => 'functionname' ) );
2624 * - Matches /Foo, adds the key 'foo' with the value 'bar' to the data array
2725 * and calls functionname( &$matches, $data );
@@ -32,23 +30,26 @@
3331 *
3432 * Params:
3533 * - 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' );`
3940 *
4041 * 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.
4344 * - When the option key 'strict' is set (Using addStrict is simpler than doing this directly)
4445 * the path won't have $1 implicitly added to it.
4546 * - 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.
4749 *
4850 * @since 1.19
4951 * @author Daniel Friesen
5052 */
5153 class PathRouter {
52 -
5354 protected function doAdd( $path, $params, $options, $key = null ) {
5455 if ( $path[0] !== '/' ) {
5556 $path = '/' . $path;
@@ -95,10 +96,10 @@
9697 }
9798
9899 $pattern = (object)array(
99 - 'path' => $path,
100 - 'params' => $params,
 100+ 'path' => $path,
 101+ 'params' => $params,
101102 'options' => $options,
102 - 'key' => $key,
 103+ 'key' => $key,
103104 );
104105 $pattern->weight = self::makeWeight( $pattern );
105106 $this->patterns[] = $pattern;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r104688Followup r104274, r104676. Fix the bug that broke fr. Forgot to rawurldecode ...dantman15:09, 30 November 2011

Status & tagging log