Index: branches/Wikidata/phase3/includes/Article.php |
— | — | @@ -1894,7 +1894,9 @@ |
1895 | 1895 | * @return mixed |
1896 | 1896 | */ |
1897 | 1897 | public function generateReason( &$hasHistory ) { |
1898 | | - return $this->mPage->getAutoDeleteReason( $hasHistory ); |
| 1898 | + $title = $this->mPage->getTitle(); |
| 1899 | + $handler = ContentHandler::getForTitle( $title ); |
| 1900 | + return $handler->getAutoDeleteReason( $title, $hasHistory ); |
1899 | 1901 | } |
1900 | 1902 | |
1901 | 1903 | // ****** B/C functions for static methods ( __callStatic is PHP>=5.3 ) ****** // |
— | — | @@ -1932,6 +1934,7 @@ |
1933 | 1935 | * @param $newtext |
1934 | 1936 | * @param $flags |
1935 | 1937 | * @return string |
| 1938 | + * @deprecated since 1.20, use ContentHandler::getAutosummary() instead |
1936 | 1939 | */ |
1937 | 1940 | public static function getAutosummary( $oldtext, $newtext, $flags ) { |
1938 | 1941 | return WikiPage::getAutosummary( $oldtext, $newtext, $flags ); |
Index: branches/Wikidata/phase3/includes/Content.php |
— | — | @@ -16,22 +16,30 @@ |
17 | 17 | return $this->mModelName; |
18 | 18 | } |
19 | 19 | |
20 | | - public abstract function getSearchText( ); |
| 20 | + public abstract function getTextForSearchIndex( ); |
21 | 21 | |
22 | 22 | public abstract function getWikitextForTransclusion( ); |
23 | 23 | |
| 24 | + public abstract function getTextForSummary( $maxlength = 250 ); |
| 25 | + |
24 | 26 | /** |
25 | 27 | * Returns native represenation of the data. Interpretation depends on the data model used, |
26 | 28 | * as given by getDataModel(). |
27 | 29 | * |
| 30 | + * @return mixed the native representation of the content. Could be a string, a nested array |
| 31 | + * structure, an object, a binary blob... anything, really. |
28 | 32 | */ |
29 | | - public abstract function getNativeData( ); |
| 33 | + public abstract function getNativeData( ); #FIXME: review all calls carefully, caller must be aware of content model! |
30 | 34 | |
31 | 35 | /** |
32 | 36 | * returns the content's nominal size in bogo-bytes. |
33 | 37 | */ |
34 | 38 | public abstract function getSize( ); #XXX: do we really need/want this here? we could just use the byte syse of the serialized form... |
35 | 39 | |
| 40 | + public function isEmpty() { |
| 41 | + return $this->getSize() == 0; |
| 42 | + } |
| 43 | + |
36 | 44 | /** |
37 | 45 | * Returns true if this content is countable as a "real" wiki page, provided |
38 | 46 | * that it's also in a countable location (e.g. a current revision in the main namespace). |
— | — | @@ -43,12 +51,16 @@ |
44 | 52 | |
45 | 53 | public abstract function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = NULL ); |
46 | 54 | |
47 | | - public function getRedirectChain() { |
| 55 | + public function getRedirectChain() { #TODO: document! |
48 | 56 | return null; |
49 | 57 | } |
50 | 58 | |
| 59 | + public function getRedirectTarget() { |
| 60 | + return null; |
| 61 | + } |
| 62 | + |
51 | 63 | public function isRedirect() { |
52 | | - return false; |
| 64 | + return $this->getRedirectTarget() != null; |
53 | 65 | } |
54 | 66 | |
55 | 67 | /** |
— | — | @@ -64,7 +76,7 @@ |
65 | 77 | } |
66 | 78 | |
67 | 79 | /** |
68 | | - * Replaces a section of the content. |
| 80 | + * Replaces a section of the content and returns a Content object with the section replaced. |
69 | 81 | * |
70 | 82 | * @param $section empty/null/false or a section number (0, 1, 2, T1, T2...), or "new" |
71 | 83 | * @param $with Content: new content of the section |
— | — | @@ -85,6 +97,7 @@ |
86 | 98 | |
87 | 99 | # TODO: EditPage::getPreloadedText( $preload ) // $wgParser->getPreloadText |
88 | 100 | # TODO: tie into EditPage, make it use Content-objects throughout, make edit form aware of content model and format |
| 101 | + # TODO: tie into WikiPage, make it use Content-objects throughout, especially in doEdit(), doDelete(), etc |
89 | 102 | # TODO: make model-aware diff view! |
90 | 103 | # TODO: handle ImagePage and CategoryPage |
91 | 104 | |
— | — | @@ -106,6 +119,18 @@ |
107 | 120 | $this->mText = $text; |
108 | 121 | } |
109 | 122 | |
| 123 | + public function getTextForSummary( $maxlength = 250 ) { |
| 124 | + global $wgContLang; |
| 125 | + |
| 126 | + $text = $this->getNativeData(); |
| 127 | + |
| 128 | + $truncatedtext = $wgContLang->truncate( |
| 129 | + preg_replace( "/[\n\r]/", ' ', $text ), |
| 130 | + max( 0, $maxlength ) ); |
| 131 | + |
| 132 | + return $truncatedtext; |
| 133 | + } |
| 134 | + |
110 | 135 | /** |
111 | 136 | * returns the content's nominal size in bogo-bytes. |
112 | 137 | */ |
— | — | @@ -149,7 +174,7 @@ |
150 | 175 | * |
151 | 176 | * @return String the raw text |
152 | 177 | */ |
153 | | - public function getSearchText( ) { #FIXME: use! |
| 178 | + public function getTextForSearchIndex( ) { #FIXME: use! |
154 | 179 | return $this->getNativeData(); |
155 | 180 | } |
156 | 181 | |
— | — | @@ -286,9 +311,9 @@ |
287 | 312 | return Title::newFromRedirectArray( $text ); |
288 | 313 | } |
289 | 314 | |
290 | | - public function isRedirect() { |
| 315 | + public function getRedirectTarget() { |
291 | 316 | $text = $this->getNativeData(); |
292 | | - return Title::newFromRedirect( $text ) !== null; |
| 317 | + return Title::newFromRedirect( $text ); |
293 | 318 | } |
294 | 319 | |
295 | 320 | /** |
— | — | @@ -326,6 +351,16 @@ |
327 | 352 | } |
328 | 353 | } |
329 | 354 | |
| 355 | + public function getTextForSummary( $maxlength = 250 ) { |
| 356 | + $truncatedtext = parent::getTextForSummary( $maxlength ); |
| 357 | + |
| 358 | + #clean up unfinished links |
| 359 | + #XXX: make this optional? wasn't there in autosummary, but required for deletion summary. |
| 360 | + $truncatedtext = preg_replace( '/\[\[([^\]]*)\]?$/', '$1', $truncatedtext ); |
| 361 | + |
| 362 | + return $truncatedtext; |
| 363 | + } |
| 364 | + |
330 | 365 | } |
331 | 366 | |
332 | 367 | class MessageContent extends TextContent { |
Index: branches/Wikidata/phase3/includes/ContentHandler.php |
— | — | @@ -104,6 +104,12 @@ |
105 | 105 | return ContentHandler::getForModelName( $modelName ); |
106 | 106 | } |
107 | 107 | |
| 108 | + /** |
| 109 | + * @static |
| 110 | + * @param $modelName String the name of the content model for which to get a handler. Use CONTENT_MODEL_XXX constants. |
| 111 | + * @return ContentHandler |
| 112 | + * @throws MWException |
| 113 | + */ |
108 | 114 | public static function getForModelName( $modelName ) { |
109 | 115 | global $wgContentHandlers; |
110 | 116 | |
— | — | @@ -143,8 +149,20 @@ |
144 | 150 | return $this->mSupportedFormats[0]; |
145 | 151 | } |
146 | 152 | |
| 153 | + /** |
| 154 | + * @abstract |
| 155 | + * @param Content $content |
| 156 | + * @param null $format |
| 157 | + * @return String |
| 158 | + */ |
147 | 159 | public abstract function serialize( Content $content, $format = null ); |
148 | 160 | |
| 161 | + /** |
| 162 | + * @abstract |
| 163 | + * @param $blob String |
| 164 | + * @param null $format |
| 165 | + * @return Content |
| 166 | + */ |
149 | 167 | public abstract function unserialize( $blob, $format = null ); |
150 | 168 | |
151 | 169 | public abstract function emptyContent(); |
— | — | @@ -216,6 +234,153 @@ |
217 | 235 | return false; |
218 | 236 | } |
219 | 237 | |
| 238 | + /** |
| 239 | + * Return an applicable autosummary if one exists for the given edit. |
| 240 | + * |
| 241 | + * @param $oldContent Content: the previous text of the page. |
| 242 | + * @param $newContent Content: The submitted text of the page. |
| 243 | + * @param $flags Int bitmask: a bitmask of flags submitted for the edit. |
| 244 | + * |
| 245 | + * @return string An appropriate autosummary, or an empty string. |
| 246 | + */ |
| 247 | + public function getAutosummary( Content $oldContent, Content $newContent, $flags ) { |
| 248 | + global $wgContLang; |
| 249 | + |
| 250 | + # Decide what kind of autosummary is needed. |
| 251 | + |
| 252 | + # Redirect autosummaries |
| 253 | + $ot = $oldContent->getRedirectTarget(); |
| 254 | + $rt = $newContent->getRedirectTarget(); |
| 255 | + |
| 256 | + if ( is_object( $rt ) && ( !is_object( $ot ) || !$rt->equals( $ot ) || $ot->getFragment() != $rt->getFragment() ) ) { |
| 257 | + |
| 258 | + $truncatedtext = $newContent->getTextForSummary( |
| 259 | + 250 |
| 260 | + - strlen( wfMsgForContent( 'autoredircomment' ) ) |
| 261 | + - strlen( $rt->getFullText() ) ); |
| 262 | + |
| 263 | + return wfMsgForContent( 'autoredircomment', $rt->getFullText(), $truncatedtext ); |
| 264 | + } |
| 265 | + |
| 266 | + # New page autosummaries |
| 267 | + if ( $flags & EDIT_NEW && $newContent->getSize() > 0 ) { |
| 268 | + # If they're making a new article, give its text, truncated, in the summary. |
| 269 | + |
| 270 | + $truncatedtext = $newContent->getTextForSummary( |
| 271 | + 200 - strlen( wfMsgForContent( 'autosumm-new' ) ) ); |
| 272 | + |
| 273 | + return wfMsgForContent( 'autosumm-new', $truncatedtext ); |
| 274 | + } |
| 275 | + |
| 276 | + # Blanking autosummaries |
| 277 | + if ( $oldContent->getSize() > 0 && $newContent->getSize() == 0 ) { |
| 278 | + return wfMsgForContent( 'autosumm-blank' ); |
| 279 | + } elseif ( $oldContent->getSize() > 10 * $newContent->getSize() && $newContent->getSize() < 500 ) { |
| 280 | + # Removing more than 90% of the article |
| 281 | + |
| 282 | + $truncatedtext = $newContent->getTextForSummary( |
| 283 | + 200 - strlen( wfMsgForContent( 'autosumm-replace' ) ) ); |
| 284 | + |
| 285 | + return wfMsgForContent( 'autosumm-replace', $truncatedtext ); |
| 286 | + } |
| 287 | + |
| 288 | + # If we reach this point, there's no applicable autosummary for our case, so our |
| 289 | + # autosummary is empty. |
| 290 | + return ''; |
| 291 | + } |
| 292 | + |
| 293 | + /** |
| 294 | + * Auto-generates a deletion reason |
| 295 | + * |
| 296 | + * @param $title Title: the page's title |
| 297 | + * @param &$hasHistory Boolean: whether the page has a history |
| 298 | + * @return mixed String containing deletion reason or empty string, or boolean false |
| 299 | + * if no revision occurred |
| 300 | + */ |
| 301 | + public function getAutoDeleteReason( Title $title, &$hasHistory ) { |
| 302 | + global $wgContLang; |
| 303 | + |
| 304 | + $dbw = wfGetDB( DB_MASTER ); |
| 305 | + |
| 306 | + // Get the last revision |
| 307 | + $rev = Revision::newFromTitle( $title ); |
| 308 | + |
| 309 | + if ( is_null( $rev ) ) { |
| 310 | + return false; |
| 311 | + } |
| 312 | + |
| 313 | + // Get the article's contents |
| 314 | + $content = $rev->getContent(); |
| 315 | + $blank = false; |
| 316 | + |
| 317 | + // If the page is blank, use the text from the previous revision, |
| 318 | + // which can only be blank if there's a move/import/protect dummy revision involved |
| 319 | + if ( $content->getSize() == 0 ) { |
| 320 | + $prev = $rev->getPrevious(); |
| 321 | + |
| 322 | + if ( $prev ) { |
| 323 | + $content = $rev->getContent(); |
| 324 | + $blank = true; |
| 325 | + } |
| 326 | + } |
| 327 | + |
| 328 | + // Find out if there was only one contributor |
| 329 | + // Only scan the last 20 revisions |
| 330 | + $res = $dbw->select( 'revision', 'rev_user_text', |
| 331 | + array( 'rev_page' => $title->getArticleID(), $dbw->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' ), |
| 332 | + __METHOD__, |
| 333 | + array( 'LIMIT' => 20 ) |
| 334 | + ); |
| 335 | + |
| 336 | + if ( $res === false ) { |
| 337 | + // This page has no revisions, which is very weird |
| 338 | + return false; |
| 339 | + } |
| 340 | + |
| 341 | + $hasHistory = ( $res->numRows() > 1 ); |
| 342 | + $row = $dbw->fetchObject( $res ); |
| 343 | + |
| 344 | + if ( $row ) { // $row is false if the only contributor is hidden |
| 345 | + $onlyAuthor = $row->rev_user_text; |
| 346 | + // Try to find a second contributor |
| 347 | + foreach ( $res as $row ) { |
| 348 | + if ( $row->rev_user_text != $onlyAuthor ) { // Bug 22999 |
| 349 | + $onlyAuthor = false; |
| 350 | + break; |
| 351 | + } |
| 352 | + } |
| 353 | + } else { |
| 354 | + $onlyAuthor = false; |
| 355 | + } |
| 356 | + |
| 357 | + // Generate the summary with a '$1' placeholder |
| 358 | + if ( $blank ) { |
| 359 | + // The current revision is blank and the one before is also |
| 360 | + // blank. It's just not our lucky day |
| 361 | + $reason = wfMsgForContent( 'exbeforeblank', '$1' ); |
| 362 | + } else { |
| 363 | + if ( $onlyAuthor ) { |
| 364 | + $reason = wfMsgForContent( 'excontentauthor', '$1', $onlyAuthor ); |
| 365 | + } else { |
| 366 | + $reason = wfMsgForContent( 'excontent', '$1' ); |
| 367 | + } |
| 368 | + } |
| 369 | + |
| 370 | + if ( $reason == '-' ) { |
| 371 | + // Allow these UI messages to be blanked out cleanly |
| 372 | + return ''; |
| 373 | + } |
| 374 | + |
| 375 | + // Max content length = max comment length - length of the comment (excl. $1) |
| 376 | + $text = $content->getTextForSummary( 255 - ( strlen( $reason ) - 2 ) ); |
| 377 | + |
| 378 | + // Now replace the '$1' placeholder |
| 379 | + $reason = str_replace( '$1', $text, $reason ); |
| 380 | + |
| 381 | + return $reason; |
| 382 | + } |
| 383 | + |
| 384 | + |
220 | 385 | #TODO: cover patch/undo just like merge3. |
221 | 386 | |
222 | 387 | #TODO: how to handle extra message for JS/CSS previews?? |
— | — | @@ -280,6 +445,7 @@ |
281 | 446 | return new WikitextContent(""); |
282 | 447 | } |
283 | 448 | |
| 449 | + |
284 | 450 | } |
285 | 451 | |
286 | 452 | class JavaScriptContentHandler extends TextContentHandler { |
Index: branches/Wikidata/phase3/includes/api/ApiDelete.php |
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | // Need to pass a throwaway variable because generateReason expects |
125 | 125 | // a reference |
126 | 126 | $hasHistory = false; |
127 | | - $reason = $page->getAutoDeleteReason( $hasHistory ); |
| 127 | + $reason = $page->getAutoDeleteReason( $hasHistory ); #FIXME: use ContentHandler::getAutoDeleteReason() |
128 | 128 | if ( $reason === false ) { |
129 | 129 | return array( array( 'cannotdelete', $title->getPrefixedText() ) ); |
130 | 130 | } |
Index: branches/Wikidata/phase3/includes/WikiPage.php |
— | — | @@ -1271,7 +1271,7 @@ |
1272 | 1272 | |
1273 | 1273 | # Provide autosummaries if one is not provided and autosummaries are enabled. |
1274 | 1274 | if ( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) { |
1275 | | - $summary = self::getAutosummary( $oldtext, $text, $flags ); #FIXME: auto-summary from ContentHandler |
| 1275 | + $summary = self::getAutosummary( $oldtext, $text, $flags ); #FIXME: ContentHandler::getAutosummary() |
1276 | 1276 | } |
1277 | 1277 | |
1278 | 1278 | $editInfo = $this->prepareTextForEdit( $text, null, $user ); |
— | — | @@ -2385,53 +2385,16 @@ |
2386 | 2386 | * @param $newtext String: The submitted text of the page. |
2387 | 2387 | * @param $flags Int bitmask: a bitmask of flags submitted for the edit. |
2388 | 2388 | * @return string An appropriate autosummary, or an empty string. |
| 2389 | + * @deprecated since 1.20, use ContentHandler::getAutosummary() instead |
2389 | 2390 | */ |
2390 | 2391 | public static function getAutosummary( $oldtext, $newtext, $flags ) { |
2391 | | - global $wgContLang; |
| 2392 | + # NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't. |
2392 | 2393 | |
2393 | | - # Decide what kind of autosummary is needed. |
| 2394 | + $handler = ContentHandler::getForModelName( CONTENT_MODEL_WIKITEXT ); |
| 2395 | + $oldContent = $handler->unserialize( $oldtext ); |
| 2396 | + $newContent = $handler->unserialize( $newtext ); |
2394 | 2397 | |
2395 | | - # Redirect autosummaries |
2396 | | - $ot = Title::newFromRedirect( $oldtext ); |
2397 | | - $rt = Title::newFromRedirect( $newtext ); |
2398 | | - |
2399 | | - if ( is_object( $rt ) && ( !is_object( $ot ) || !$rt->equals( $ot ) || $ot->getFragment() != $rt->getFragment() ) ) { |
2400 | | - $truncatedtext = $wgContLang->truncate( |
2401 | | - str_replace( "\n", ' ', $newtext ), |
2402 | | - max( 0, 250 |
2403 | | - - strlen( wfMsgForContent( 'autoredircomment' ) ) |
2404 | | - - strlen( $rt->getFullText() ) |
2405 | | - ) ); |
2406 | | - return wfMsgForContent( 'autoredircomment', $rt->getFullText(), $truncatedtext ); |
2407 | | - } |
2408 | | - |
2409 | | - # New page autosummaries |
2410 | | - if ( $flags & EDIT_NEW && strlen( $newtext ) ) { |
2411 | | - # If they're making a new article, give its text, truncated, in the summary. |
2412 | | - |
2413 | | - $truncatedtext = $wgContLang->truncate( |
2414 | | - str_replace( "\n", ' ', $newtext ), |
2415 | | - max( 0, 200 - strlen( wfMsgForContent( 'autosumm-new' ) ) ) ); |
2416 | | - |
2417 | | - return wfMsgForContent( 'autosumm-new', $truncatedtext ); |
2418 | | - } |
2419 | | - |
2420 | | - # Blanking autosummaries |
2421 | | - if ( $oldtext != '' && $newtext == '' ) { |
2422 | | - return wfMsgForContent( 'autosumm-blank' ); |
2423 | | - } elseif ( strlen( $oldtext ) > 10 * strlen( $newtext ) && strlen( $newtext ) < 500 ) { |
2424 | | - # Removing more than 90% of the article |
2425 | | - |
2426 | | - $truncatedtext = $wgContLang->truncate( |
2427 | | - $newtext, |
2428 | | - max( 0, 200 - strlen( wfMsgForContent( 'autosumm-replace' ) ) ) ); |
2429 | | - |
2430 | | - return wfMsgForContent( 'autosumm-replace', $truncatedtext ); |
2431 | | - } |
2432 | | - |
2433 | | - # If we reach this point, there's no applicable autosummary for our case, so our |
2434 | | - # autosummary is empty. |
2435 | | - return ''; |
| 2398 | + return $handler->getAutosummary( $oldContent, $newContent, $flags ); |
2436 | 2399 | } |
2437 | 2400 | |
2438 | 2401 | /** |
— | — | @@ -2440,92 +2403,13 @@ |
2441 | 2404 | * @param &$hasHistory Boolean: whether the page has a history |
2442 | 2405 | * @return mixed String containing deletion reason or empty string, or boolean false |
2443 | 2406 | * if no revision occurred |
| 2407 | + * @deprecated since 1.20, use ContentHandler::getAutoDeleteReason() instead |
2444 | 2408 | */ |
2445 | 2409 | public function getAutoDeleteReason( &$hasHistory ) { |
2446 | | - global $wgContLang; |
| 2410 | + #NOTE: stub for backwards-compatibility. |
2447 | 2411 | |
2448 | | - $dbw = wfGetDB( DB_MASTER ); |
2449 | | - // Get the last revision |
2450 | | - $rev = Revision::newFromTitle( $this->getTitle() ); |
2451 | | - |
2452 | | - if ( is_null( $rev ) ) { |
2453 | | - return false; |
2454 | | - } |
2455 | | - |
2456 | | - // Get the article's contents |
2457 | | - $contents = $rev->getText(); |
2458 | | - $blank = false; |
2459 | | - |
2460 | | - // If the page is blank, use the text from the previous revision, |
2461 | | - // which can only be blank if there's a move/import/protect dummy revision involved |
2462 | | - if ( $contents == '' ) { |
2463 | | - $prev = $rev->getPrevious(); |
2464 | | - |
2465 | | - if ( $prev ) { |
2466 | | - $contents = $prev->getText(); |
2467 | | - $blank = true; |
2468 | | - } |
2469 | | - } |
2470 | | - |
2471 | | - // Find out if there was only one contributor |
2472 | | - // Only scan the last 20 revisions |
2473 | | - $res = $dbw->select( 'revision', 'rev_user_text', |
2474 | | - array( 'rev_page' => $this->getID(), $dbw->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' ), |
2475 | | - __METHOD__, |
2476 | | - array( 'LIMIT' => 20 ) |
2477 | | - ); |
2478 | | - |
2479 | | - if ( $res === false ) { |
2480 | | - // This page has no revisions, which is very weird |
2481 | | - return false; |
2482 | | - } |
2483 | | - |
2484 | | - $hasHistory = ( $res->numRows() > 1 ); |
2485 | | - $row = $dbw->fetchObject( $res ); |
2486 | | - |
2487 | | - if ( $row ) { // $row is false if the only contributor is hidden |
2488 | | - $onlyAuthor = $row->rev_user_text; |
2489 | | - // Try to find a second contributor |
2490 | | - foreach ( $res as $row ) { |
2491 | | - if ( $row->rev_user_text != $onlyAuthor ) { // Bug 22999 |
2492 | | - $onlyAuthor = false; |
2493 | | - break; |
2494 | | - } |
2495 | | - } |
2496 | | - } else { |
2497 | | - $onlyAuthor = false; |
2498 | | - } |
2499 | | - |
2500 | | - // Generate the summary with a '$1' placeholder |
2501 | | - if ( $blank ) { |
2502 | | - // The current revision is blank and the one before is also |
2503 | | - // blank. It's just not our lucky day |
2504 | | - $reason = wfMsgForContent( 'exbeforeblank', '$1' ); |
2505 | | - } else { |
2506 | | - if ( $onlyAuthor ) { |
2507 | | - $reason = wfMsgForContent( 'excontentauthor', '$1', $onlyAuthor ); |
2508 | | - } else { |
2509 | | - $reason = wfMsgForContent( 'excontent', '$1' ); |
2510 | | - } |
2511 | | - } |
2512 | | - |
2513 | | - if ( $reason == '-' ) { |
2514 | | - // Allow these UI messages to be blanked out cleanly |
2515 | | - return ''; |
2516 | | - } |
2517 | | - |
2518 | | - // Replace newlines with spaces to prevent uglyness |
2519 | | - $contents = preg_replace( "/[\n\r]/", ' ', $contents ); |
2520 | | - // Calculate the maximum amount of chars to get |
2521 | | - // Max content length = max comment length - length of the comment (excl. $1) |
2522 | | - $maxLength = 255 - ( strlen( $reason ) - 2 ); |
2523 | | - $contents = $wgContLang->truncate( $contents, $maxLength ); |
2524 | | - // Remove possible unfinished links |
2525 | | - $contents = preg_replace( '/\[\[([^\]]*)\]?$/', '$1', $contents ); |
2526 | | - // Now replace the '$1' placeholder |
2527 | | - $reason = str_replace( '$1', $contents, $reason ); |
2528 | | - |
2529 | | - return $reason; |
| 2412 | + $handler = ContentHandler::getForTitle( $this->getTitle() ); |
| 2413 | + $handler->getAutoDeleteReason( $this->getTitle(), $hasHistory ); |
2530 | 2414 | } |
2531 | 2415 | |
2532 | 2416 | /** |