Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -989,100 +989,20 @@ |
990 | 990 | */ |
991 | 991 | function wfArrayToCGI( $array1, $array2 = NULL ) |
992 | 992 | { |
993 | | - if ( !is_null( $array2 ) ) { |
994 | | - $array1 = $array1 + $array2; |
995 | | - } |
996 | | - |
997 | | - $cgi = ''; |
998 | | - foreach ( $array1 as $key => $value ) { |
999 | | - if ( '' !== $value ) { |
1000 | | - if ( '' != $cgi ) { |
1001 | | - $cgi .= '&'; |
1002 | | - } |
1003 | | - $cgi .= urlencode( $key ) . '=' . urlencode( $value ); |
1004 | | - } |
1005 | | - } |
1006 | | - return $cgi; |
1007 | | -} |
1008 | | -/** |
1009 | | - * Build a query string from complex data input and return. |
1010 | | - * |
1011 | | - * @param mixed $query The query data to build the string from |
1012 | | - * @param string $prefix A prefix to add to numeric keys to make them valid |
1013 | | - * @param string $dataKey A key name to use on the data |
1014 | | - * @return string The query string |
1015 | | - */ |
1016 | | -function wfBuildQuery( $query, $prefix = null, $dataKey = null ) { |
1017 | | - # Passthrough strings and blank data |
1018 | | - if( is_null($query) || is_string($query) ) return (string) $query; |
1019 | | - |
1020 | | - # Recursively build the query. |
1021 | | - $data = array(); |
1022 | | - $keyNum = 0; |
1023 | | - foreach( (array) $query as $key => $value ) { |
1024 | | - if( is_int($key) && $prefix != null ) { |
1025 | | - # Prefix numeric keys when given a prefix. |
1026 | | - $key = "{$prefix}{$key}"; |
1027 | | - } |
1028 | | - if( isset($dataKey) && $dataKey != '' ) { |
1029 | | - # Add array type data to keys when needed |
1030 | | - # but don't add the key inside the [] when they are sequential |
1031 | | - if( $keyNum === $key ) $key = "{$dataKey}[]"; |
1032 | | - else $key = "{$dataKey}[{$key}]"; |
1033 | | - |
1034 | | - } |
1035 | | - # Push the data onto the end of the array recursing if needed. |
1036 | | - array_push($data, |
1037 | | - is_array($value) || is_object($value) |
1038 | | - ? wfBuildQuery($value,null,$key) |
1039 | | - : urlencode($key)."=".urlencode($value) ); |
1040 | | - $keyNum++; |
1041 | | - }; |
1042 | | - # Implode and return. |
1043 | | - return implode('&', $data); |
1044 | | -}; |
| 993 | + if ( !is_null( $array2 ) ) { |
| 994 | + $array1 = $array1 + $array2; |
| 995 | + } |
1045 | 996 | |
1046 | | -/** |
1047 | | - * Parse a query string into an array. |
1048 | | - * |
1049 | | - * @param mixed $query The query string to parse |
1050 | | - * @return array The array data for the query |
1051 | | - */ |
1052 | | -function wfParseQuery( $query ) { |
1053 | | - # Passthrough non-strings. |
1054 | | - if( !is_string($query) ) return $query; |
1055 | | - |
1056 | | - $data = array(); |
1057 | | - # Separate all name-value pairs |
1058 | | - $pairs = explode('&', $query); |
1059 | | - foreach($pairs as $pair) { |
1060 | | - # Pull out the names and the values |
1061 | | - list($name, $value) = explode('=', $pair, 2); |
1062 | | - # Decode the variable name and look for arrays |
1063 | | - $m = array(); |
1064 | | - $name = urldecode($name); |
1065 | | - if( preg_match('/^(.*?)((\[.*?\])+)$/S', $name, $m) !== 0 ) { |
1066 | | - $name = $m[1]; |
1067 | | - $braces = $m[2]; |
1068 | | - $indexes = explode( '][', substr( $braces, 1, -1 ) ); |
1069 | | - |
1070 | | - if(!isset($data[$name])) $data[$name] = array(); |
1071 | | - $recursive =& $data[$name]; |
1072 | | - foreach( $indexes as $index ) { |
1073 | | - if( $index != "" ) { |
1074 | | - if(!isset($recursive[$index])) $recursive[$index] = array(); |
1075 | | - $recursive =& $recursive[$index]; |
1076 | | - } else { |
1077 | | - $i = array_push( $recursive, array() ) - 1; |
1078 | | - $recursive =& $recursive[$i]; |
1079 | | - } |
| 997 | + $cgi = ''; |
| 998 | + foreach ( $array1 as $key => $value ) { |
| 999 | + if ( '' !== $value ) { |
| 1000 | + if ( '' != $cgi ) { |
| 1001 | + $cgi .= '&'; |
1080 | 1002 | } |
1081 | | - $recursive = urldecode($value); |
1082 | | - } else { |
1083 | | - $data[$name] = urldecode($value); |
| 1003 | + $cgi .= urlencode( $key ) . '=' . urlencode( $value ); |
1084 | 1004 | } |
1085 | 1005 | } |
1086 | | - return $data; |
| 1006 | + return $cgi; |
1087 | 1007 | } |
1088 | 1008 | |
1089 | 1009 | /** |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -760,10 +760,8 @@ |
761 | 761 | * @param string $variant language variant of url (for sr, zh..) |
762 | 762 | * @return string the URL |
763 | 763 | */ |
764 | | - public function getFullURL( $query = null, $variant = false ) { |
| 764 | + public function getFullURL( $query = '', $variant = false ) { |
765 | 765 | global $wgContLang, $wgServer, $wgRequest; |
766 | | - |
767 | | - $query = wfBuildQuery( $query ); |
768 | 766 | |
769 | 767 | if ( '' == $this->mInterwiki ) { |
770 | 768 | $url = $this->getLocalUrl( $query, $variant ); |
— | — | @@ -801,12 +799,10 @@ |
802 | 800 | * @param string $variant language variant of url (for sr, zh..) |
803 | 801 | * @return string the URL |
804 | 802 | */ |
805 | | - public function getLocalURL( $query = null, $variant = false ) { |
| 803 | + public function getLocalURL( $query = '', $variant = false ) { |
806 | 804 | global $wgArticlePath, $wgScript, $wgServer, $wgRequest; |
807 | 805 | global $wgVariantArticlePath, $wgContLang, $wgUser; |
808 | | - |
809 | | - $query = wfBuildQuery( $query ); |
810 | | - |
| 806 | + |
811 | 807 | // internal links should point to same variant as current page (only anonymous users) |
812 | 808 | if($variant == false && $wgContLang->hasVariants() && !$wgUser->isLoggedIn()){ |
813 | 809 | $pref = $wgContLang->getPreferredVariant(false); |