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