Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -44,7 +44,6 @@ |
45 | 45 | |
46 | 46 | var $mArticle; |
47 | 47 | var $mTitle; |
48 | | - var $action; |
49 | 48 | var $mMetaData = ''; |
50 | 49 | var $isConflict = false; |
51 | 50 | var $isCssJsSubpage = false; |
— | — | @@ -62,8 +61,7 @@ |
63 | 62 | var $allowBlankSummary = false; |
64 | 63 | var $autoSumm = ''; |
65 | 64 | var $hookError = ''; |
66 | | - #var $mPreviewTemplates; |
67 | | - var $mParserOutput; |
| 65 | + var $mPreviewTemplates; |
68 | 66 | var $mBaseRevision = false; |
69 | 67 | |
70 | 68 | # Form values |
— | — | @@ -94,7 +92,6 @@ |
95 | 93 | function EditPage( $article ) { |
96 | 94 | $this->mArticle =& $article; |
97 | 95 | $this->mTitle = $article->getTitle(); |
98 | | - $this->action = 'submit'; |
99 | 96 | |
100 | 97 | # Placeholders for text injection by hooks (empty per default) |
101 | 98 | $this->editFormPageTop = |
— | — | @@ -1062,29 +1059,6 @@ |
1063 | 1060 | return true; |
1064 | 1061 | } |
1065 | 1062 | |
1066 | | - function setHeaders() { |
1067 | | - global $wgOut, $wgTitle; |
1068 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
1069 | | - if ( $this->formtype == 'preview' ) { |
1070 | | - $wgOut->setPageTitleActionText( wfMsg( 'preview' ) ); |
1071 | | - } |
1072 | | - if ( $this->isConflict ) { |
1073 | | - $wgOut->setPageTitle( wfMsg( 'editconflict', $wgTitle->getPrefixedText() ) ); |
1074 | | - } elseif( $this->section != '' ) { |
1075 | | - $msg = $this->section == 'new' ? 'editingcomment' : 'editingsection'; |
1076 | | - $wgOut->setPageTitle( wfMsg( $msg, $wgTitle->getPrefixedText() ) ); |
1077 | | - } else { |
1078 | | - # Use the title defined by DISPLAYTITLE magic word when present |
1079 | | - if( isset($this->mParserOutput) |
1080 | | - && ( $dt = $this->mParserOutput->getDisplayTitle() ) !== false ) { |
1081 | | - $title = $dt; |
1082 | | - } else { |
1083 | | - $title = $wgTitle->getPrefixedText(); |
1084 | | - } |
1085 | | - $wgOut->setPageTitle( wfMsg( 'editing', $title ) ); |
1086 | | - } |
1087 | | - } |
1088 | | - |
1089 | 1063 | /** |
1090 | 1064 | * Send the edit form and related headers to $wgOut |
1091 | 1065 | * @param $formCallback Optional callable that takes an OutputPage |
— | — | @@ -1108,41 +1082,46 @@ |
1109 | 1083 | |
1110 | 1084 | wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) ) ; |
1111 | 1085 | |
1112 | | - #need to parse the preview early so that we know which templates are used, |
1113 | | - #otherwise users with "show preview after edit box" will get a blank list |
1114 | | - #we parse this near the beginning so that setHeaders can do the title |
1115 | | - #setting work instead of leaving it in getPreviewText |
1116 | | - $previewOutput = ''; |
1117 | | - if ( $this->formtype == 'preview' ) { |
1118 | | - $previewOutput = $this->getPreviewText(); |
1119 | | - } |
| 1086 | + $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
1120 | 1087 | |
1121 | | - $this->setHeaders(); |
1122 | | - |
1123 | 1088 | # Enabled article-related sidebar, toplinks, etc. |
1124 | 1089 | $wgOut->setArticleRelated( true ); |
1125 | 1090 | |
| 1091 | + if ( $this->formtype == 'preview' ) { |
| 1092 | + $wgOut->setPageTitleActionText( wfMsg( 'preview' ) ); |
| 1093 | + } |
| 1094 | + |
1126 | 1095 | if ( $this->isConflict ) { |
| 1096 | + $s = wfMsg( 'editconflict', $wgTitle->getPrefixedText() ); |
| 1097 | + $wgOut->setPageTitle( $s ); |
1127 | 1098 | $wgOut->addWikiMsg( 'explainconflict' ); |
1128 | 1099 | |
1129 | 1100 | $this->textbox2 = $this->textbox1; |
1130 | 1101 | $this->textbox1 = $this->getContent(); |
1131 | 1102 | $this->edittime = $this->mArticle->getTimestamp(); |
1132 | 1103 | } else { |
1133 | | - if( $this->section != '' && $this->section != 'new' ) { |
1134 | | - $matches = array(); |
1135 | | - if( !$this->summary && !$this->preview && !$this->diff ) { |
1136 | | - preg_match( "/^(=+)(.+)\\1/mi", |
1137 | | - $this->textbox1, |
1138 | | - $matches ); |
1139 | | - if( !empty( $matches[2] ) ) { |
1140 | | - global $wgParser; |
1141 | | - $this->summary = "/* " . |
1142 | | - $wgParser->stripSectionName(trim($matches[2])) . |
1143 | | - " */ "; |
| 1104 | + if( $this->section != '' ) { |
| 1105 | + if( $this->section == 'new' ) { |
| 1106 | + $s = wfMsg('editingcomment', $wgTitle->getPrefixedText() ); |
| 1107 | + } else { |
| 1108 | + $s = wfMsg('editingsection', $wgTitle->getPrefixedText() ); |
| 1109 | + $matches = array(); |
| 1110 | + if( !$this->summary && !$this->preview && !$this->diff ) { |
| 1111 | + preg_match( "/^(=+)(.+)\\1/mi", |
| 1112 | + $this->textbox1, |
| 1113 | + $matches ); |
| 1114 | + if( !empty( $matches[2] ) ) { |
| 1115 | + global $wgParser; |
| 1116 | + $this->summary = "/* " . |
| 1117 | + $wgParser->stripSectionName(trim($matches[2])) . |
| 1118 | + " */ "; |
| 1119 | + } |
1144 | 1120 | } |
1145 | 1121 | } |
| 1122 | + } else { |
| 1123 | + $s = wfMsg( 'editing', $wgTitle->getPrefixedText() ); |
1146 | 1124 | } |
| 1125 | + $wgOut->setPageTitle( $s ); |
1147 | 1126 | |
1148 | 1127 | if ( $this->missingComment ) { |
1149 | 1128 | $wgOut->wrapWikiMsg( '<div id="mw-missingcommenttext">$1</div>', 'missingcommenttext' ); |
— | — | @@ -1238,7 +1217,20 @@ |
1239 | 1218 | $wgOut->addHTML( "</div>\n" ); |
1240 | 1219 | } |
1241 | 1220 | |
1242 | | - $q = 'action='.$this->action; |
| 1221 | + #need to parse the preview early so that we know which templates are used, |
| 1222 | + #otherwise users with "show preview after edit box" will get a blank list |
| 1223 | + if ( $this->formtype == 'preview' ) { |
| 1224 | + $previewOutput = $this->getPreviewText(); |
| 1225 | + } |
| 1226 | + |
| 1227 | + $rows = $wgUser->getIntOption( 'rows' ); |
| 1228 | + $cols = $wgUser->getIntOption( 'cols' ); |
| 1229 | + |
| 1230 | + $ew = $wgUser->getOption( 'editwidth' ); |
| 1231 | + if ( $ew ) $ew = " style=\"width:100%\""; |
| 1232 | + else $ew = ''; |
| 1233 | + |
| 1234 | + $q = 'action=submit'; |
1243 | 1235 | #if ( "no" == $redirect ) { $q .= "&redirect=no"; } |
1244 | 1236 | $action = $wgTitle->escapeLocalURL( $q ); |
1245 | 1237 | |
— | — | @@ -1290,9 +1282,16 @@ |
1291 | 1283 | $wgOut->addHTML( $this->editFormPageTop ); |
1292 | 1284 | |
1293 | 1285 | if ( $wgUser->getOption( 'previewontop' ) ) { |
1294 | | - $this->displayPreviewArea( $previewOutput ); |
1295 | | - // Spacer for the edit toolbar |
1296 | | - $wgOut->addHTML( '<p><br /></p>' ); |
| 1286 | + |
| 1287 | + if ( 'preview' == $this->formtype ) { |
| 1288 | + $this->showPreview( $previewOutput ); |
| 1289 | + } else { |
| 1290 | + $wgOut->addHTML( '<div id="wikiPreview"></div>' ); |
| 1291 | + } |
| 1292 | + |
| 1293 | + if ( 'diff' == $this->formtype ) { |
| 1294 | + $this->showDiff(); |
| 1295 | + } |
1297 | 1296 | } |
1298 | 1297 | |
1299 | 1298 | |
— | — | @@ -1331,7 +1330,7 @@ |
1332 | 1331 | if( !$this->preview && !$this->diff ) { |
1333 | 1332 | $wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' ); |
1334 | 1333 | } |
1335 | | - $templates = $this->getTemplates(); |
| 1334 | + $templates = ($this->preview || $this->section != '') ? $this->mPreviewTemplates : $this->mArticle->getUsedTemplates(); |
1336 | 1335 | $formattedtemplates = $sk->formatTemplates( $templates, $this->preview, $this->section != ''); |
1337 | 1336 | |
1338 | 1337 | $hiddencats = $this->mArticle->getHiddenCategories(); |
— | — | @@ -1342,15 +1341,11 @@ |
1343 | 1342 | $metadata = $this->mMetaData ; |
1344 | 1343 | $metadata = htmlspecialchars( $wgContLang->recodeForEdit( $metadata ) ) ; |
1345 | 1344 | $top = wfMsgWikiHtml( 'metadata_help' ); |
1346 | | - /* ToDo: Replace with clean code */ |
1347 | | - $ew = $wgUser->getOption( 'editwidth' ); |
1348 | | - if ( $ew ) $ew = " style=\"width:100%\""; |
1349 | | - else $ew = ''; |
1350 | | - /* /ToDo */ |
1351 | 1345 | $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>" ; |
1352 | 1346 | } |
1353 | 1347 | else $metadata = "" ; |
1354 | 1348 | |
| 1349 | + $hidden = ''; |
1355 | 1350 | $recreate = ''; |
1356 | 1351 | if ($this->wasDeletedSinceLastEdit()) { |
1357 | 1352 | if ( 'save' != $this->formtype ) { |
— | — | @@ -1359,6 +1354,7 @@ |
1360 | 1355 | // Hide the toolbar and edit area, use can click preview to get it back |
1361 | 1356 | // Add an confirmation checkbox and explanation. |
1362 | 1357 | $toolbar = ''; |
| 1358 | + $hidden = 'type="hidden" style="display:none;"'; |
1363 | 1359 | $recreate = $wgOut->parse( wfMsg( 'confirmrecreate', $this->lastDelete->user_name , $this->lastDelete->log_comment )); |
1364 | 1360 | $recreate .= |
1365 | 1361 | "<br /><input tabindex='1' type='checkbox' value='1' name='wpRecreate' id='wpRecreate' />". |
— | — | @@ -1392,27 +1388,40 @@ |
1393 | 1389 | wfRunHooks( 'EditPage::showEditForm:fields', array( &$this, &$wgOut ) ); |
1394 | 1390 | |
1395 | 1391 | // Put these up at the top to ensure they aren't lost on early form submission |
1396 | | - $this->showFormBeforeText(); |
| 1392 | + $wgOut->addHTML( " |
| 1393 | +<input type='hidden' value=\"" . htmlspecialchars( $this->section ) . "\" name=\"wpSection\" /> |
| 1394 | +<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n |
| 1395 | +<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n |
| 1396 | +<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n" ); |
1397 | 1397 | |
| 1398 | + $encodedtext = htmlspecialchars( $this->safeUnicodeOutput( $this->textbox1 ) ); |
| 1399 | + if( $encodedtext !== '' ) { |
| 1400 | + // Ensure there's a newline at the end, otherwise adding lines |
| 1401 | + // is awkward. |
| 1402 | + // But don't add a newline if the ext is empty, or Firefox in XHTML |
| 1403 | + // mode will show an extra newline. A bit annoying. |
| 1404 | + $encodedtext .= "\n"; |
| 1405 | + } |
| 1406 | + |
1398 | 1407 | $wgOut->addHTML( <<<END |
1399 | | -{$recreate} |
| 1408 | +$recreate |
1400 | 1409 | {$commentsubject} |
1401 | 1410 | {$subjectpreview} |
1402 | 1411 | {$this->editFormTextBeforeContent} |
| 1412 | +<textarea tabindex='1' accesskey="," name="wpTextbox1" id="wpTextbox1" rows='{$rows}' |
| 1413 | +cols='{$cols}'{$ew} $hidden>{$encodedtext}</textarea> |
1403 | 1414 | END |
1404 | 1415 | ); |
1405 | | - $this->showTextbox1(); |
1406 | 1416 | |
1407 | 1417 | $wgOut->wrapWikiMsg( "<div id=\"editpage-copywarn\">\n$1\n</div>", $copywarnMsg ); |
1408 | | - $wgOut->addHTML( <<<END |
1409 | | -{$this->editFormTextAfterWarn} |
| 1418 | + $wgOut->addHTML( $this->editFormTextAfterWarn ); |
| 1419 | + $wgOut->addHTML( " |
1410 | 1420 | {$metadata} |
1411 | 1421 | {$editsummary} |
1412 | 1422 | {$summarypreview} |
1413 | 1423 | {$checkboxhtml} |
1414 | 1424 | {$safemodehtml} |
1415 | | -END |
1416 | | -); |
| 1425 | +"); |
1417 | 1426 | |
1418 | 1427 | $wgOut->addHTML( |
1419 | 1428 | "<div class='editButtons'> |
— | — | @@ -1436,18 +1445,20 @@ |
1437 | 1446 | $token = htmlspecialchars( $wgUser->editToken() ); |
1438 | 1447 | $wgOut->addHTML( "\n<input type='hidden' value=\"$token\" name=\"wpEditToken\" />\n" ); |
1439 | 1448 | |
1440 | | - $this->showEditTools(); |
| 1449 | + $wgOut->addHtml( '<div class="mw-editTools">' ); |
| 1450 | + $wgOut->addWikiMsgArray( 'edittools', array(), array( 'content' ) ); |
| 1451 | + $wgOut->addHtml( '</div>' ); |
1441 | 1452 | |
1442 | | - $wgOut->addHTML( <<<END |
1443 | | -{$this->editFormTextAfterTools} |
| 1453 | + $wgOut->addHTML( $this->editFormTextAfterTools ); |
| 1454 | + |
| 1455 | + $wgOut->addHTML( " |
1444 | 1456 | <div class='templatesUsed'> |
1445 | 1457 | {$formattedtemplates} |
1446 | 1458 | </div> |
1447 | 1459 | <div class='hiddencats'> |
1448 | 1460 | {$formattedhiddencats} |
1449 | 1461 | </div> |
1450 | | -END |
1451 | | -); |
| 1462 | +"); |
1452 | 1463 | |
1453 | 1464 | if ( $this->isConflict && wfRunHooks( 'EditPageBeforeConflictDiff', array( &$this, &$wgOut ) ) ) { |
1454 | 1465 | $wgOut->wrapWikiMsg( '==$1==', "yourdiff" ); |
— | — | @@ -1457,76 +1468,26 @@ |
1458 | 1469 | $de->showDiff( wfMsg( "yourtext" ), wfMsg( "storedversion" ) ); |
1459 | 1470 | |
1460 | 1471 | $wgOut->wrapWikiMsg( '==$1==', "yourtext" ); |
1461 | | - $this->showTextbox2(); |
| 1472 | + $wgOut->addHTML( "<textarea tabindex='6' id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}'>" |
| 1473 | + . htmlspecialchars( $this->safeUnicodeOutput( $this->textbox2 ) ) . "\n</textarea>" ); |
1462 | 1474 | } |
1463 | 1475 | $wgOut->addHTML( $this->editFormTextBottom ); |
1464 | 1476 | $wgOut->addHTML( "</form>\n" ); |
1465 | 1477 | if ( !$wgUser->getOption( 'previewontop' ) ) { |
1466 | | - $this->displayPreviewArea( $previewOutput ); |
1467 | | - } |
1468 | 1478 | |
1469 | | - wfProfileOut( $fname ); |
1470 | | - } |
| 1479 | + if ( $this->formtype == 'preview') { |
| 1480 | + $this->showPreview( $previewOutput ); |
| 1481 | + } else { |
| 1482 | + $wgOut->addHTML( '<div id="wikiPreview"></div>' ); |
| 1483 | + } |
1471 | 1484 | |
1472 | | - protected function showFormBeforeText() { |
1473 | | - return " |
1474 | | -<input type='hidden' value=\"" . htmlspecialchars( $this->section ) . "\" name=\"wpSection\" /> |
1475 | | -<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n |
1476 | | -<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n |
1477 | | -<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n"; |
1478 | | - } |
1479 | | - |
1480 | | - protected function showTextbox1() { |
1481 | | - $attribs = array( 'tabindex' => 1 ); |
1482 | | - |
1483 | | - if( $this->wasDeletedSinceLastEdit() ) |
1484 | | - $attribs['type'] = 'hidden'; |
1485 | | - |
1486 | | - $this->showTextbox( $this->textbox1, 'wpTextbox1', $attribs ); |
1487 | | - } |
1488 | | - |
1489 | | - protected function showTextbox2() { |
1490 | | - $this->showTextbox( $encodedtext, 'wpTextbox2', array( 'tabindex' => 6 ) ); |
1491 | | - } |
1492 | | - |
1493 | | - protected function showTextbox( $content, $name, $attribs = array() ) { |
1494 | | - global $wgOut, $wgUser; |
1495 | | - |
1496 | | - $encodedtext = htmlspecialchars( $this->safeUnicodeOutput( $content ) ); |
1497 | | - if( $encodedtext !== '' ) { |
1498 | | - // Ensure there's a newline at the end, otherwise adding lines |
1499 | | - // is awkward. |
1500 | | - // But don't add a newline if the ext is empty, or Firefox in XHTML |
1501 | | - // mode will show an extra newline. A bit annoying. |
1502 | | - $encodedtext .= "\n"; |
1503 | | - } |
1504 | | - |
1505 | | - $attribs = array( |
1506 | | - 'accesskey' => ',', |
1507 | | - 'id' => $name, |
1508 | | - ); |
1509 | | - |
1510 | | - if( $wgUser->getOption( 'editwidth' ) ) |
1511 | | - $attribs['style'] = 'width: 100%'; |
1512 | | - |
1513 | | - $wgOut->addHTML( Xml::textarea( |
1514 | | - $name, |
1515 | | - $encodedtext, |
1516 | | - $wgUser->getIntOption( 'cols' ), $wgUser->getIntOption( 'rows' ), |
1517 | | - $attribs ) ); |
1518 | | - } |
| 1485 | + if ( $this->formtype == 'diff') { |
| 1486 | + $this->showDiff(); |
| 1487 | + } |
1519 | 1488 | |
1520 | | - protected function displayPreviewArea( $previewOutput ) { |
1521 | | - global $wgOut; |
1522 | | - if ( $this->formtype == 'preview') { |
1523 | | - $this->showPreview( $previewOutput ); |
1524 | | - } else { |
1525 | | - $wgOut->addHTML( '<div id="wikiPreview"></div>' ); |
1526 | 1489 | } |
1527 | 1490 | |
1528 | | - if ( $this->formtype == 'diff') { |
1529 | | - $this->showDiff(); |
1530 | | - } |
| 1491 | + wfProfileOut( $fname ); |
1531 | 1492 | } |
1532 | 1493 | |
1533 | 1494 | /** |
— | — | @@ -1563,19 +1524,12 @@ |
1564 | 1525 | function doLivePreviewScript() { |
1565 | 1526 | global $wgOut, $wgTitle; |
1566 | 1527 | $wgOut->addScriptFile( 'preview.js' ); |
1567 | | - $liveAction = $wgTitle->getLocalUrl( "action={$this->action}&wpPreview=true&live=true" ); |
| 1528 | + $liveAction = $wgTitle->getLocalUrl( 'action=submit&wpPreview=true&live=true' ); |
1568 | 1529 | return "return !lpDoPreview(" . |
1569 | 1530 | "editform.wpTextbox1.value," . |
1570 | 1531 | '"' . $liveAction . '"' . ")"; |
1571 | 1532 | } |
1572 | 1533 | |
1573 | | - protected function showEditTools() { |
1574 | | - global $wgOut; |
1575 | | - $wgOut->addHtml( '<div class="mw-editTools">' ); |
1576 | | - $wgOut->addWikiMsgArray( 'edittools', array(), array( 'content' ) ); |
1577 | | - $wgOut->addHtml( '</div>' ); |
1578 | | - } |
1579 | | - |
1580 | 1534 | function getLastDelete() { |
1581 | 1535 | $dbr = wfGetDB( DB_SLAVE ); |
1582 | 1536 | $fname = 'EditPage::getLastDelete'; |
— | — | @@ -1615,7 +1569,8 @@ |
1616 | 1570 | function getPreviewText() { |
1617 | 1571 | global $wgOut, $wgUser, $wgTitle, $wgParser, $wgLang, $wgContLang; |
1618 | 1572 | |
1619 | | - wfProfileIn( __METHOD__ ); |
| 1573 | + $fname = 'EditPage::getPreviewText'; |
| 1574 | + wfProfileIn( $fname ); |
1620 | 1575 | |
1621 | 1576 | if ( $this->mTriedSave && !$this->mTokenOk ) { |
1622 | 1577 | if ( $this->mTokenOkExceptSuffix ) { |
— | — | @@ -1649,9 +1604,9 @@ |
1650 | 1605 | } |
1651 | 1606 | $parserOptions->setTidy(true); |
1652 | 1607 | $parserOutput = $wgParser->parse( $previewtext , $this->mTitle, $parserOptions ); |
1653 | | - //$wgOut->addHTML( $parserOutput->mText ); |
| 1608 | + $wgOut->addHTML( $parserOutput->mText ); |
1654 | 1609 | $previewHTML = ''; |
1655 | | - } elseif( $rt = Title::newFromRedirect( $this->textbox1 ) ) { |
| 1610 | + } else if( $rt = Title::newFromRedirect( $this->textbox1 ) ) { |
1656 | 1611 | $previewHTML = $this->mArticle->viewRedirect( $rt, false ); |
1657 | 1612 | } else { |
1658 | 1613 | $toparse = $this->textbox1; |
— | — | @@ -1688,9 +1643,20 @@ |
1689 | 1644 | $this->mTitle, $parserOptions ); |
1690 | 1645 | |
1691 | 1646 | $previewHTML = $parserOutput->getText(); |
1692 | | - $this->mParserOutput = $parserOutput; |
1693 | 1647 | $wgOut->addParserOutputNoText( $parserOutput ); |
1694 | 1648 | |
| 1649 | + # ParserOutput might have altered the page title, so reset it |
| 1650 | + # Also, use the title defined by DISPLAYTITLE magic word when present |
| 1651 | + if( ( $dt = $parserOutput->getDisplayTitle() ) !== false ) { |
| 1652 | + $wgOut->setPageTitle( wfMsg( 'editing', $dt ) ); |
| 1653 | + } else { |
| 1654 | + $wgOut->setPageTitle( wfMsg( 'editing', $wgTitle->getPrefixedText() ) ); |
| 1655 | + } |
| 1656 | + |
| 1657 | + foreach ( $parserOutput->getTemplates() as $ns => $template) |
| 1658 | + foreach ( array_keys( $template ) as $dbk) |
| 1659 | + $this->mPreviewTemplates[] = Title::makeTitle($ns, $dbk); |
| 1660 | + |
1695 | 1661 | if ( count( $parserOutput->getWarnings() ) ) { |
1696 | 1662 | $note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() ); |
1697 | 1663 | } |
— | — | @@ -1699,26 +1665,18 @@ |
1700 | 1666 | $previewhead = '<h2>' . htmlspecialchars( wfMsg( 'preview' ) ) . "</h2>\n" . |
1701 | 1667 | "<div class='previewnote'>" . $wgOut->parse( $note ) . "</div>\n"; |
1702 | 1668 | if ( $this->isConflict ) { |
1703 | | - $previewhead .='<h2>' . htmlspecialchars( wfMsg( 'previewconflict' ) ) . "</h2>\n"; |
| 1669 | + $previewhead.='<h2>' . htmlspecialchars( wfMsg( 'previewconflict' ) ) . "</h2>\n"; |
1704 | 1670 | } |
1705 | 1671 | |
1706 | | - wfProfileOut( __METHOD__ ); |
1707 | | - return $previewhead . $previewHTML; |
1708 | | - } |
1709 | | - |
1710 | | - function getTemplates() { |
1711 | | - if( $this->preview || $this->section != '' ) { |
1712 | | - $templates = array(); |
1713 | | - if( !isset($this->mParserOutput) ) return $templates; |
1714 | | - foreach( $this->mParserOutput->getTemplates() as $ns => $template) { |
1715 | | - foreach( array_keys( $template ) as $dbk ) { |
1716 | | - $templates[] = Title::makeTitle($ns, $dbk); |
1717 | | - } |
1718 | | - } |
1719 | | - return $templates; |
| 1672 | + if( $wgUser->getOption( 'previewontop' ) ) { |
| 1673 | + // Spacer for the edit toolbar |
| 1674 | + $previewfoot = '<p><br /></p>'; |
1720 | 1675 | } else { |
1721 | | - return $this->mArticle->getUsedTemplates(); |
| 1676 | + $previewfoot = ''; |
1722 | 1677 | } |
| 1678 | + |
| 1679 | + wfProfileOut( $fname ); |
| 1680 | + return $previewhead . $previewHTML . $previewfoot; |
1723 | 1681 | } |
1724 | 1682 | |
1725 | 1683 | /** |
— | — | @@ -1739,8 +1697,8 @@ |
1740 | 1698 | |
1741 | 1699 | # Spit out the source or the user's modified version |
1742 | 1700 | if( $source !== false ) { |
1743 | | - $rows = $wgUser->getIntOption( 'rows' ); |
1744 | | - $cols = $wgUser->getIntOption( 'cols' ); |
| 1701 | + $rows = $wgUser->getOption( 'rows' ); |
| 1702 | + $cols = $wgUser->getOption( 'cols' ); |
1745 | 1703 | $attribs = array( 'id' => 'wpTextbox1', 'name' => 'wpTextbox1', 'cols' => $cols, 'rows' => $rows, 'readonly' => 'readonly' ); |
1746 | 1704 | $wgOut->addHtml( '<hr />' ); |
1747 | 1705 | $wgOut->addWikiMsg( $first ? 'blockedoriginalsource' : 'blockededitsource', $this->mTitle->getPrefixedText() ); |