Index: trunk/phase3/includes/WebRequest.php |
— | — | @@ -625,10 +625,10 @@ |
626 | 626 | $file = new WebRequestUpload( $this, $key ); |
627 | 627 | return $file->getName(); |
628 | 628 | } |
629 | | - |
| 629 | + |
630 | 630 | /** |
631 | 631 | * Return a WebRequestUpload object corresponding to the key |
632 | | - * |
| 632 | + * |
633 | 633 | * @param @key string |
634 | 634 | * @return WebRequestUpload |
635 | 635 | */ |
— | — | @@ -727,7 +727,7 @@ |
728 | 728 | $ext = substr( $pi, $dotPos ); |
729 | 729 | return !in_array( $ext, array( $wgScriptExtension, '.php', '.php5' ) ); |
730 | 730 | } |
731 | | - |
| 731 | + |
732 | 732 | /** |
733 | 733 | * Parse the Accept-Language header sent by the client into an array |
734 | 734 | * @return array( languageCode => q-value ) sorted by q-value in descending order |
— | — | @@ -740,15 +740,15 @@ |
741 | 741 | if ( !$acceptLang ) { |
742 | 742 | return array(); |
743 | 743 | } |
744 | | - |
| 744 | + |
745 | 745 | // Return the language codes in lower case |
746 | 746 | $acceptLang = strtolower( $acceptLang ); |
747 | | - |
| 747 | + |
748 | 748 | // Break up string into pieces (languages and q factors) |
749 | 749 | $lang_parse = null; |
750 | 750 | preg_match_all( '/([a-z]{1,8}(-[a-z]{1,8})?|\*)\s*(;\s*q\s*=\s*(1|0(\.[0-9]+)?)?)?/', |
751 | 751 | $acceptLang, $lang_parse ); |
752 | | - |
| 752 | + |
753 | 753 | if ( !count( $lang_parse[1] ) ) { |
754 | 754 | return array(); |
755 | 755 | } |
— | — | @@ -777,10 +777,10 @@ |
778 | 778 | protected $request; |
779 | 779 | protected $doesExist; |
780 | 780 | protected $fileInfo; |
781 | | - |
| 781 | + |
782 | 782 | /** |
783 | 783 | * Constructor. Should only be called by WebRequest |
784 | | - * |
| 784 | + * |
785 | 785 | * @param $request WebRequest The associated request |
786 | 786 | * @param $key string Key in $_FILES array (name of form field) |
787 | 787 | */ |
— | — | @@ -791,26 +791,26 @@ |
792 | 792 | $this->fileInfo = $_FILES[$key]; |
793 | 793 | } |
794 | 794 | } |
795 | | - |
| 795 | + |
796 | 796 | /** |
797 | 797 | * Return whether a file with this name was uploaded. |
798 | | - * |
| 798 | + * |
799 | 799 | * @return bool |
800 | 800 | */ |
801 | 801 | public function exists() { |
802 | 802 | return $this->doesExist; |
803 | 803 | } |
804 | | - |
| 804 | + |
805 | 805 | /** |
806 | 806 | * Return the original filename of the uploaded file |
807 | | - * |
| 807 | + * |
808 | 808 | * @return mixed Filename or null if non-existent |
809 | 809 | */ |
810 | 810 | public function getName() { |
811 | 811 | if ( !$this->exists() ) { |
812 | 812 | return null; |
813 | 813 | } |
814 | | - |
| 814 | + |
815 | 815 | global $wgContLang; |
816 | 816 | $name = $this->fileInfo['name']; |
817 | 817 | |
— | — | @@ -821,51 +821,51 @@ |
822 | 822 | wfDebug( __METHOD__ . ": {$this->fileInfo['name']} normalized to '$name'\n" ); |
823 | 823 | return $name; |
824 | 824 | } |
825 | | - |
| 825 | + |
826 | 826 | /** |
827 | 827 | * Return the file size of the uploaded file |
828 | | - * |
| 828 | + * |
829 | 829 | * @return int File size or zero if non-existent |
830 | 830 | */ |
831 | 831 | public function getSize() { |
832 | 832 | if ( !$this->exists() ) { |
833 | 833 | return 0; |
834 | 834 | } |
835 | | - |
| 835 | + |
836 | 836 | return $this->fileInfo['size']; |
837 | 837 | } |
838 | | - |
| 838 | + |
839 | 839 | /** |
840 | 840 | * Return the path to the temporary file |
841 | | - * |
| 841 | + * |
842 | 842 | * @return mixed Path or null if non-existent |
843 | 843 | */ |
844 | 844 | public function getTempName() { |
845 | 845 | if ( !$this->exists() ) { |
846 | 846 | return null; |
847 | 847 | } |
848 | | - |
| 848 | + |
849 | 849 | return $this->fileInfo['tmp_name']; |
850 | 850 | } |
851 | | - |
| 851 | + |
852 | 852 | /** |
853 | 853 | * Return the upload error. See link for explanation |
854 | 854 | * http://www.php.net/manual/en/features.file-upload.errors.php |
855 | | - * |
| 855 | + * |
856 | 856 | * @return int One of the UPLOAD_ constants, 0 if non-existent |
857 | 857 | */ |
858 | 858 | public function getError() { |
859 | 859 | if ( !$this->exists() ) { |
860 | 860 | return 0; # UPLOAD_ERR_OK |
861 | 861 | } |
862 | | - |
| 862 | + |
863 | 863 | return $this->fileInfo['error']; |
864 | 864 | } |
865 | | - |
| 865 | + |
866 | 866 | /** |
867 | 867 | * Returns whether this upload failed because of overflow of a maximum set |
868 | 868 | * in php.ini |
869 | | - * |
| 869 | + * |
870 | 870 | * @return bool |
871 | 871 | */ |
872 | 872 | public function isIniSizeOverflow() { |
— | — | @@ -879,7 +879,7 @@ |
880 | 880 | # post_max_size is exceeded |
881 | 881 | return true; |
882 | 882 | } |
883 | | - |
| 883 | + |
884 | 884 | return false; |
885 | 885 | } |
886 | 886 | } |
— | — | @@ -936,7 +936,23 @@ |
937 | 937 | } |
938 | 938 | |
939 | 939 | public function appendQuery( $query ) { |
940 | | - $this->notImplemented( __METHOD__ ); |
| 940 | + global $wgTitle; |
| 941 | + $basequery = ''; |
| 942 | + foreach( $this->data as $var => $val ) { |
| 943 | + if ( $var == 'title' ) |
| 944 | + continue; |
| 945 | + if ( is_array( $val ) ) |
| 946 | + /* This will happen given a request like |
| 947 | + * http://en.wikipedia.org/w/index.php?title[]=Special:Userlogin&returnto[]=Main_Page |
| 948 | + */ |
| 949 | + continue; |
| 950 | + $basequery .= '&' . urlencode( $var ) . '=' . urlencode( $val ); |
| 951 | + } |
| 952 | + $basequery .= '&' . $query; |
| 953 | + |
| 954 | + # Trim the extra & |
| 955 | + $basequery = substr( $basequery, 1 ); |
| 956 | + return $wgTitle->getLocalURL( $basequery ); |
941 | 957 | } |
942 | 958 | |
943 | 959 | public function getHeader( $name ) { |