Index: trunk/extensions/FirefoggChunkedUpload/ApiFirefoggChunkedUpload.php |
— | — | @@ -6,10 +6,6 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | class ApiFirefoggChunkedUpload extends ApiUpload { |
10 | | - /* public function __construct( $main, $action ) { */ |
11 | | - /* parent::__construct( $main, $action ); */ |
12 | | - /* } */ |
13 | | - |
14 | 10 | public function execute() { |
15 | 11 | global $wgUser; |
16 | 12 | |
— | — | @@ -51,13 +47,13 @@ |
52 | 48 | |
53 | 49 | public function getUpload() { return $this->mUpload; } |
54 | 50 | |
55 | | - public function performUploadInit($comment, $pageText, $watch, $user) { |
| 51 | + public function performUploadInit($comment, $pageText, $watchlist, $user) { |
56 | 52 | $check = $this->mUpload->validateNameAndOverwrite(); |
57 | 53 | if( $check !== true ) { |
58 | 54 | $this->getVerificationError( $check ); |
59 | 55 | } |
60 | 56 | |
61 | | - $session = $this->mUpload->setupChunkSession( $comment, $pageText, $watch ); |
| 57 | + $session = $this->mUpload->setupChunkSession( $comment, $pageText, $watchlist ); |
62 | 58 | return array('uploadUrl' => |
63 | 59 | wfExpandUrl( wfScript( 'api' ) ) . "?" . |
64 | 60 | wfArrayToCGI( array( |
— | — | @@ -80,7 +76,7 @@ |
81 | 77 | |
82 | 78 | public function performUploadDone($user) { |
83 | 79 | $this->mUpload->finalizeFile(); |
84 | | - $status = parent::performUpload( $this->comment, $this->pageText, $this->watch, $user ); |
| 80 | + $status = parent::performUpload( $this->comment, $this->pageText, $this->watchlist, $user ); |
85 | 81 | |
86 | 82 | if ( $status['result'] !== 'Success' ) { |
87 | 83 | return $status; |
— | — | @@ -97,12 +93,12 @@ |
98 | 94 | */ |
99 | 95 | public function performUpload( ) { |
100 | 96 | wfDebug( "\n\n\performUpload(chunked): comment: " . $this->comment . |
101 | | - ' pageText: ' . $this->pageText . ' watch: ' . $this->watch ); |
| 97 | + ' pageText: ' . $this->pageText . ' watch: ' . $this->watchlist ); |
102 | 98 | $ret = "unknown error"; |
103 | 99 | |
104 | 100 | global $wgUser; |
105 | 101 | if ( $this->mUpload->getChunkMode() == FirefoggChunkedUploadHandler::INIT ) { |
106 | | - $ret = $this->performUploadInit($this->comment, $this->pageText, $this->watch, $wgUser); |
| 102 | + $ret = $this->performUploadInit($this->comment, $this->pageText, $this->watchlist, $wgUser); |
107 | 103 | } else if ( $this->mUpload->getChunkMode() == FirefoggChunkedUploadHandler::CHUNK ) { |
108 | 104 | $ret = $this->performUploadChunk(); |
109 | 105 | } else if ( $this->mUpload->getChunkMode() == FirefoggChunkedUploadHandler::DONE ) { |
— | — | @@ -127,7 +123,7 @@ |
128 | 124 | if( $params['chunksession'] === null ) { |
129 | 125 | $required[] = 'filename'; |
130 | 126 | $required[] = 'comment'; |
131 | | - $required[] = 'watch'; |
| 127 | + $required[] = 'watchlist'; |
132 | 128 | $required[] = 'ignorewarnings'; |
133 | 129 | } |
134 | 130 | |
— | — | @@ -143,11 +139,19 @@ |
144 | 140 | 'filename' => null, |
145 | 141 | 'token' => null, |
146 | 142 | 'comment' => null, |
147 | | - 'watch' => false, |
148 | 143 | 'ignorewarnings' => false, |
149 | 144 | 'chunksession' => null, |
150 | 145 | 'chunk' => null, |
151 | 146 | 'done' => false, |
| 147 | + 'watchlist' => array( |
| 148 | + ApiBase::PARAM_DFLT => 'preferences', |
| 149 | + ApiBase::PARAM_TYPE => array( |
| 150 | + 'watch', |
| 151 | + 'unwatch', |
| 152 | + 'preferences', |
| 153 | + 'nochange' |
| 154 | + ), |
| 155 | + ), |
152 | 156 | ); |
153 | 157 | } |
154 | 158 | |
— | — | @@ -156,7 +160,7 @@ |
157 | 161 | 'filename' => 'Target filename', |
158 | 162 | 'token' => 'Edit token. You can get one of these through prop=info', |
159 | 163 | 'comment' => 'Upload comment', |
160 | | - 'watch' => 'Watch the page', |
| 164 | + 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch', |
161 | 165 | 'ignorewarnings' => 'Ignore any warnings', |
162 | 166 | 'chunksession' => 'The session key, established on the first contact during the chunked upload', |
163 | 167 | 'chunk' => 'The data in this chunk of a chunked upload', |
Index: trunk/extensions/FirefoggChunkedUpload/tests/UploadFromChunksTest.php |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | $this->doApiRequest( array( |
119 | 119 | 'action' => 'firefoggupload', |
120 | 120 | 'comment' => 'test', |
121 | | - 'watch' => true, |
| 121 | + 'watchlist' => 'watch', |
122 | 122 | 'filename' => 'tmp.txt', |
123 | 123 | 'token' => $token ), $data ); |
124 | 124 | } catch ( UsageException $e ) { |
— | — | @@ -141,7 +141,7 @@ |
142 | 142 | $data = $this->doApiRequest( array( |
143 | 143 | 'action' => 'firefoggupload', |
144 | 144 | 'comment' => 'test', |
145 | | - 'watch' => true, |
| 145 | + 'watchlist' => 'watch', |
146 | 146 | 'filename' => 'TestPic.png', |
147 | 147 | 'token' => $token ), $data ); |
148 | 148 | |
— | — | @@ -216,7 +216,7 @@ |
217 | 217 | $data = $this->doApiRequest( array( |
218 | 218 | 'action' => 'firefoggupload', |
219 | 219 | 'comment' => 'test', |
220 | | - 'watch' => true, |
| 220 | + 'watchlist' => 'watch', |
221 | 221 | 'filename' => 'tmp.png', |
222 | 222 | 'token' => $token ), $data ); |
223 | 223 | return $data; |
— | — | @@ -284,7 +284,7 @@ |
285 | 285 | $data = $this->doApiRequest( array( |
286 | 286 | 'action' => 'firefoggupload', |
287 | 287 | 'comment' => 'test', |
288 | | - 'watch' => true, |
| 288 | + 'watchlist' => 'watch', |
289 | 289 | 'filename' => 'twar.png', |
290 | 290 | 'token' => $token ), $data ); |
291 | 291 | |
Index: trunk/extensions/FirefoggChunkedUpload/FirefoggChunkedUploadHandler.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | protected $comment; |
17 | 17 | protected $repoPath; |
18 | 18 | protected $pageText; |
19 | | - protected $watch; |
| 19 | + protected $watchlist; |
20 | 20 | |
21 | 21 | public $status; |
22 | 22 | |
— | — | @@ -27,11 +27,11 @@ |
28 | 28 | * Set session information for chunked uploads and allocate a unique key. |
29 | 29 | * @param $comment string |
30 | 30 | * @param $pageText string |
31 | | - * @param $watch bodolean |
| 31 | + * @param $watchlist bodolean |
32 | 32 | * |
33 | 33 | * @returns string the session key for this chunked upload |
34 | 34 | */ |
35 | | - public function setupChunkSession( $comment, $pageText, $watch ) { |
| 35 | + public function setupChunkSession( $comment, $pageText, $watchlist ) { |
36 | 36 | if ( !isset( $this->sessionKey ) ) { |
37 | 37 | $this->sessionKey = $this->getSessionKey(); |
38 | 38 | } |
— | — | @@ -47,8 +47,8 @@ |
48 | 48 | if ( isset( $pageText ) ) { |
49 | 49 | $_SESSION[self::SESSION_KEYNAME][$this->sessionKey]['pageText'] = $pageText; |
50 | 50 | } |
51 | | - if ( isset( $watch ) ) { |
52 | | - $_SESSION[self::SESSION_KEYNAME][$this->sessionKey]['watch'] = $watch; |
| 51 | + if ( isset( $watchlist ) ) { |
| 52 | + $_SESSION[self::SESSION_KEYNAME][$this->sessionKey]['watchlist'] = $watchlist; |
53 | 53 | } |
54 | 54 | $_SESSION[self::SESSION_KEYNAME][$this->sessionKey]['version'] = self::SESSION_VERSION; |
55 | 55 | |
— | — | @@ -110,7 +110,7 @@ |
111 | 111 | if ( isset( $sessionData[$this->sessionKey]['version'] ) |
112 | 112 | && $sessionData[$this->sessionKey]['version'] == self::SESSION_VERSION ) |
113 | 113 | { |
114 | | - foreach ( array( 'comment', 'pageText', 'watch', 'mFilteredName', 'repoPath', 'mFileSize', 'mDesiredDestName' ) |
| 114 | + foreach ( array( 'comment', 'pageText', 'watchlist', 'mFilteredName', 'repoPath', 'mFileSize', 'mDesiredDestName' ) |
115 | 115 | as $key ) { |
116 | 116 | if ( isset( $sessionData[$this->sessionKey][$key] ) ) { |
117 | 117 | $this->$key = $sessionData[$this->sessionKey][$key]; |