Index: trunk/phase3/includes/WebRequest.php |
— | — | @@ -443,6 +443,16 @@ |
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
| 447 | + * Get the values passed in the query string. |
| 448 | + * No transformation is performed on the values. |
| 449 | + * |
| 450 | + * @return Array |
| 451 | + */ |
| 452 | + public function getQueryValues() { |
| 453 | + return $_GET; |
| 454 | + } |
| 455 | + |
| 456 | + /** |
447 | 457 | * Returns true if the present request was reached by a POST operation, |
448 | 458 | * false otherwise (GET, HEAD, or command-line). |
449 | 459 | * |
— | — | @@ -541,25 +551,7 @@ |
542 | 552 | * @return String |
543 | 553 | */ |
544 | 554 | public function appendQuery( $query ) { |
545 | | - global $wgTitle; |
546 | | - $basequery = ''; |
547 | | - foreach( $_GET as $var => $val ) { |
548 | | - if ( $var == 'title' ) { |
549 | | - continue; |
550 | | - } |
551 | | - if ( is_array( $val ) ) { |
552 | | - /* This will happen given a request like |
553 | | - * http://en.wikipedia.org/w/index.php?title[]=Special:Userlogin&returnto[]=Main_Page |
554 | | - */ |
555 | | - continue; |
556 | | - } |
557 | | - $basequery .= '&' . urlencode( $var ) . '=' . urlencode( $val ); |
558 | | - } |
559 | | - $basequery .= '&' . $query; |
560 | | - |
561 | | - # Trim the extra & |
562 | | - $basequery = substr( $basequery, 1 ); |
563 | | - return $wgTitle->getLocalURL( $basequery ); |
| 555 | + return $this->appendQueryArray( wfCgiToArray( $query ) ); |
564 | 556 | } |
565 | 557 | |
566 | 558 | /** |
— | — | @@ -586,7 +578,7 @@ |
587 | 579 | */ |
588 | 580 | public function appendQueryArray( $array, $onlyquery = false ) { |
589 | 581 | global $wgTitle; |
590 | | - $newquery = $_GET; |
| 582 | + $newquery = $this->getQueryValues(); |
591 | 583 | unset( $newquery['title'] ); |
592 | 584 | $newquery = array_merge( $newquery, $array ); |
593 | 585 | $query = wfArrayToCGI( $newquery ); |
— | — | @@ -995,6 +987,14 @@ |
996 | 988 | return $this->data; |
997 | 989 | } |
998 | 990 | |
| 991 | + public function getQueryValues() { |
| 992 | + if ( $this->wasPosted ) { |
| 993 | + return array(); |
| 994 | + } else { |
| 995 | + return $this->data; |
| 996 | + } |
| 997 | + } |
| 998 | + |
999 | 999 | public function wasPosted() { |
1000 | 1000 | return $this->wasPosted; |
1001 | 1001 | } |
— | — | @@ -1007,28 +1007,6 @@ |
1008 | 1008 | $this->notImplemented( __METHOD__ ); |
1009 | 1009 | } |
1010 | 1010 | |
1011 | | - public function appendQuery( $query ) { |
1012 | | - global $wgTitle; |
1013 | | - $basequery = ''; |
1014 | | - foreach( $this->data as $var => $val ) { |
1015 | | - if ( $var == 'title' ) { |
1016 | | - continue; |
1017 | | - } |
1018 | | - if ( is_array( $val ) ) { |
1019 | | - /* This will happen given a request like |
1020 | | - * http://en.wikipedia.org/w/index.php?title[]=Special:Userlogin&returnto[]=Main_Page |
1021 | | - */ |
1022 | | - continue; |
1023 | | - } |
1024 | | - $basequery .= '&' . urlencode( $var ) . '=' . urlencode( $val ); |
1025 | | - } |
1026 | | - $basequery .= '&' . $query; |
1027 | | - |
1028 | | - # Trim the extra & |
1029 | | - $basequery = substr( $basequery, 1 ); |
1030 | | - return $wgTitle->getLocalURL( $basequery ); |
1031 | | - } |
1032 | | - |
1033 | 1011 | public function getHeader( $name ) { |
1034 | 1012 | return isset( $this->headers[$name] ) ? $this->headers[$name] : false; |
1035 | 1013 | } |