Wikia code/includes/EditPage.php
Appearance
< Wikia code | includes
This page is obsolete. It is being retained for archival purposes. It may document extensions or features that are obsolete and/or no longer supported. Do not rely on the information here being up-to-date. The information shown below refers to the now unmaintained 1.16 MediaWiki release. The current stable release number is 1.42.3. |
--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\EditPage.php 2011-07-18 22:31:28.113281300 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\EditPage.php 2011-08-17 15:28:46.476562500 +0100
@@ -75,6 +75,11 @@
var $edittime = '', $section = '', $starttime = '';
var $oldid = 0, $editintro = '', $scrolltop = null, $bot = true;
+ // wikia changes begin
+ var $login = false, $autosave = false;
+ public $customOutputPage = null;
+ // wikia changes end
+
# Placeholders for text injection by hooks (must be HTML)
# extensions should take care to _append_ to the present value
public $editFormPageTop; // Before even the preview
@@ -179,6 +184,9 @@
!$oldrev->isDeleted( Revision::DELETED_TEXT ) ) {
$undotext = $this->mArticle->getUndoText( $undorev, $oldrev );
+
+ wfRunHooks( 'EditPage::getContent::end', array( &$this, $undotext, $undorev, $oldrev ) );
+
if ( $undotext === false ) {
# Warn the user that something went wrong
$this->editFormPageTop .= $wgOut->parse( '<div class="error mw-undo-failure">' . wfMsgNoTrans( 'undo-failure' ) . '</div>' );
@@ -209,6 +217,9 @@
}
}
}
+ // wikia changes begin
+ wfRunHooks( 'EditPage::getContent::end', array( &$this, &$text ) );
+ // wikia changes end
wfProfileOut( __METHOD__ );
return $text;
@@ -239,6 +250,11 @@
// TODO FIXME: AAAAAAAAAAA, this shouldn't be implementing
// its own mini-parser! -ævar
$text = preg_replace( '~</?includeonly>~', '', $text );
+
+ // wikia changes begin: Remove <noinclude> - Datrio
+ $text = preg_replace( '/<noinclude>.*<\/noinclude>/', '', $text );
+ // wikia changes end
+
return $text;
} else
return '';
@@ -310,7 +326,12 @@
$this->preview = true;
}
+ /* Wikia change begin - @author: Marcin, #BugId: 7845 */
+ global $wgEnableEditPageReskinExt;
+ if ( empty($wgEnableEditPageReskinExt) || !Wikia::isOasis() ) {
$wgOut->addScriptFile( 'edit.js' );
+ }
+ /* Wikia change end */
if ( $wgUser->getOption( 'uselivepreview', false ) ) {
$wgOut->includeJQuery();
@@ -328,6 +349,8 @@
} else {
if ( $this->save ) {
$this->formtype = 'save';
+ } else if ( $this->login ) {
+ // wikia change but what is purpose for it?
} else if ( $this->preview ) {
$this->formtype = 'preview';
} else if ( $this->diff ) {
@@ -338,6 +361,9 @@
$this->formtype = 'preview';
} else {
$this->formtype = 'initial';
+ // wikia changes begin
+ $this->autosave = $wgRequest->getBool( 'autosave' );
+ // wikia changes end
}
}
}
@@ -361,7 +387,10 @@
$this->showIntro();
if ( $this->mTitle->isTalkPage() ) {
- $wgOut->addWikiMsg( 'talkpagetext' );
+ // Wikia change - start
+ // BugId:7092
+ $wgOut->wrapWikiMsg('<div id="talkpagetext">$1</div>', 'talkpagetext');
+ // Wikia change - end
}
# Optional notices on a per-namespace and per-page basis
@@ -440,7 +469,12 @@
* Redirect to the article page if redlink=1
*/
function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) {
- global $wgRequest, $wgOut;
+ global $wgRequest;
+ // Wikia - start - @author: ADi - removed wgOut from global to allow injecting it
+ // define wgOut
+ $wgOut = !empty($this->customOutputPage) ? $this->customOutputPage : $GLOBALS['wgOut'];
+ // Wikia - end
+
if ( $wgRequest->getBool( 'redlink' ) ) {
// The edit page was reached via a red link.
// Redirect to the article page and let them click the edit tab if
@@ -596,6 +630,13 @@
$this->allowBlankSummary = $request->getBool( 'wpIgnoreBlankSummary' ) || !$wgUser->getOption( 'forceeditsummary');
}
+ // wikia changes begin
+ if ( $request->getBool( 'wpLogin' ) ) {
+ $this->login = true;
+ $this->preview = false;
+ }
+ // wikia changes end
+
$this->autoSumm = $request->getText( 'wpAutoSummary' );
} else {
# Not a posted form? Start with nothing.
@@ -635,6 +676,10 @@
// Custom edit intro for new sections
$this->section === 'new' ? 'MediaWiki:addsection-editintro' : '' );
+ // wikia changes begin
+ wfRunHooks( 'EditPage::importFormData::finished', array( &$this, $request ) );
+ // wikia changes end
+
wfProfileOut( __METHOD__ );
// Allow extensions to modify form data
@@ -979,6 +1024,7 @@
# Handle the user preference to force summaries here, but not for null edits
if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp( $oldtext, $text )
+ && $wgUser->getOption( 'forceeditsummary')
&& !Title::newFromRedirect( $text ) ) # check if it's not a redirect
{
if ( md5( $this->summary ) == $this->autoSumm ) {
@@ -1117,7 +1163,18 @@
*/
function initialiseForm() {
global $wgUser;
+
+
+ //Wikia Change
+ //https://wikia.fogbugz.com/default.asp?3319#21795
+ if ( ( !empty( $this->mArticle->mRevision ) && $this->mArticle->mRevision->isCurrent() ) || empty( $this->mArticle->mRevision ) ) {
$this->edittime = $this->mArticle->getTimestamp();
+ } else {
+ $rev = Revision::newFromTitle( $this->mTitle );
+ $this->edittime = $rev->getTimestamp();
+ }
+ //
+
$this->textbox1 = $this->getContent( false );
// activate checkboxes if user wants them to be always active
# Sort out the "watch" checkbox
@@ -1196,8 +1253,10 @@
# Enabled article-related sidebar, toplinks, etc.
$wgOut->setArticleRelated( true );
- if ( $this->showHeader() === false )
+ if ( $this->showHeader() === false ) {
+ wfProfileOut( __METHOD__ );
return;
+ }
$action = htmlspecialchars($this->getActionURL($wgTitle));
@@ -1215,6 +1274,10 @@
$this->displayPreviewArea( $previewOutput, true );
}
+ // wikia change begin
+ wfRunHooks( 'EditPage::showEditForm:initial2', array( &$this ) ) ;
+ // wikia change end
+
$wgOut->addHTML( $this->editFormTextTop );
$templates = $this->getTemplates();
@@ -1233,15 +1296,33 @@
$toolbar = '';
// @todo move this to a cleaner conditional instead of blanking a variable
}
+ /* Wikia change begin - @author: macbre */
+ /* Allow EditPageLayout extension to wrap #EditPage section using <form> tag */
+ if (empty($this->dontWrapWithForm)) {
$wgOut->addHTML( <<<HTML
-{$toolbar}
<form id="editform" name="editform" method="post" action="$action" enctype="multipart/form-data">
HTML
);
+ global $wgEnableEditPageReskinExt;
+ if ( empty($wgEnableEditPageReskinExt) ) {
+ $wgOut->addHTML( '<a name="EditPage"></a>' );
+ }
+ }
+ /* Wikia change end */
+ /* Wikia change begin - @author: Marooned */
+ /* used by captcha, CreatePage and maybe other extensions - moved above the toolbar */
if ( is_callable( $formCallback ) ) {
call_user_func_array( $formCallback, array( &$wgOut ) );
}
+ /* Wikia change end */
+
+ /* Wikia change begin - @author: Marooned */
+ /* add possibility to add visible fields inside <form> but before toolbar - used in CreatePage */
+ wfRunHooks( 'EditPage::showEditForm:beforeToolbar', array( &$this, &$wgOut ) );
+ /* Wikia change end */
+
+ $wgOut->addHTML( "$toolbar" );
wfRunHooks( 'EditPage::showEditForm:fields', array( &$this, &$wgOut ) );
@@ -1279,6 +1361,10 @@
$wgOut->addHTML( $this->getSummaryPreview( true, $this->summary ) );
}
+ // wikia change begin
+ wfRunHooks ('EditForm:BeforeDisplayingTextbox', array (&$this, &$hidden) ) ;
+ // wikia change end
+
$wgOut->addHTML( $this->editFormTextBeforeContent );
if ( $this->isConflict ) {
@@ -1291,6 +1377,16 @@
$this->showContentForm();
}
+ // wikia change begin
+ wfRunHooks ('EditForm:AfterDisplayingTextbox', array (&$this, &$hidden) ) ;
+
+ $rows = $wgUser->getIntOption( 'rows' );
+ $cols = $wgUser->getIntOption( 'cols' );
+ $ew = $wgUser->getOption( 'editwidth' );
+
+ wfRunHooks( 'EditForm::MultiEdit:Form', array( $rows, $cols, $ew, htmlspecialchars( $this->safeUnicodeOutput( $this->textbox1 ) ) ) );
+ // wikia change end
+
$wgOut->addHTML( $this->editFormTextAfterContent );
$wgOut->addWikiText( $this->getCopywarn() );
@@ -1304,22 +1400,37 @@
$this->showTosSummary();
$this->showEditTools();
+ /* Wikia change begin - @author: Marooned */
+ /* Give a possibility to modify hiddencats container using MediaWiki hook */
$wgOut->addHTML( <<<HTML
{$this->editFormTextAfterTools}
<div class='templatesUsed'>
{$formattedtemplates}
</div>
+HTML
+);
+ $categoriesText = <<<HTML
<div class='hiddencats'>
{$formattedhiddencats}
</div>
HTML
-);
+;
+ wfRunHooks( 'EditPage::CategoryBox', array( &$categoriesText ) );
+ $wgOut->addHTML( $categoriesText );
+ /* Wikia change end */
if ( $this->isConflict )
$this->showConflict();
$wgOut->addHTML( $this->editFormTextBottom );
+
+ /* Wikia change begin - @author: macbre */
+ /* Allow EditPageLayout extension to wrap #EditPage section using <form> tag */
+ if (empty($this->dontWrapWithForm)) {
$wgOut->addHTML( "</form>\n" );
+ }
+ /* Wikia change end */
+
if ( !$wgUser->getOption( 'previewontop' ) ) {
$this->displayPreviewArea( $previewOutput, false );
}
@@ -1328,7 +1439,12 @@
}
protected function showHeader() {
- global $wgOut, $wgUser, $wgTitle, $wgMaxArticleSize, $wgLang;
+ // Wikia - start - @author: wladek - removed wgOut from global to allow injecting it
+ global $wgUser, $wgTitle, $wgMaxArticleSize, $wgLang;
+ // define wgOut
+ $wgOut = !empty($this->customOutputPage) ? $this->customOutputPage : $GLOBALS['wgOut'];
+ // Wikia - end
+
if ( $this->isConflict ) {
$wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1</div>", 'explainconflict' );
$this->edittime = $this->mArticle->getTimestamp();
@@ -1384,9 +1500,14 @@
}
if ( !$this->mArticle->mRevision->isCurrent() ) {
+ /* Wikia change begin - @author: Marooned */
+ /* Add new hook and condition to allow alternate message to be displayed when editing old revision */
+ if ( wfRunHooks( 'EditPage::showEditForm:oldRevisionNotice', array( &$this ) ) ) {
$this->mArticle->setOldSubtitle( $this->mArticle->mRevision->getId() );
$wgOut->addWikiMsg( 'editingold' );
}
+ /* Wikia change end */
+ }
}
}
@@ -1398,7 +1519,17 @@
if ( $this->isCssJsSubpage ) {
# Check the skin exists
if ( !$this->isValidCssJsSubpage ) {
- $wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() );
+ /* Wikia change begin - @author: Uberfuzzy */
+ $CssJsSubSkin = $wgTitle->getSkinFromCssJsSubpage();
+ if( $CssJsSubSkin == 'wikia' ) {
+ # rt75168, confusing "there is no wikia" message
+ } elseif( $CssJsSubSkin == 'global') {
+ # confusing "there is no global" message
+ #TODO: draft a message about what global css/js is, maybe link to help page if we still have one
+ } else {
+ $wgOut->addWikiMsg( 'userinvalidcssjstitle', $CssJsSubSkin );
+ }
+ /* Wikia change end */
}
if ( $this->formtype !== 'preview' ) {
if ( $this->isCssSubpage )
@@ -1543,8 +1674,12 @@
protected function showFormBeforeText() {
global $wgOut;
+
+ /* Wikia change begin - @author: Inez */
+ /* Make AjaxLogin work on EditPage without losing user changes */
$section = htmlspecialchars( $this->section );
$wgOut->addHTML( <<<INPUTS
+<input type='hidden' value="" name="wpLogin" id="wpLogin" />
<input type='hidden' value="{$section}" name="wpSection" />
<input type='hidden' value="{$this->starttime}" name="wpStarttime" />
<input type='hidden' value="{$this->edittime}" name="wpEdittime" />
@@ -1549,8 +1684,8 @@
<input type='hidden' value="{$this->starttime}" name="wpStarttime" />
<input type='hidden' value="{$this->edittime}" name="wpEdittime" />
<input type='hidden' value="{$this->scrolltop}" name="wpScrolltop" id="wpScrolltop" />
-
INPUTS
+ /* Wikia change end */
);
if ( !$this->checkUnicodeCompliantBrowser() )
$wgOut->addHTML(Xml::hidden( 'safemode', '1' ));
@@ -1670,6 +1805,13 @@
$wgOut->addHTML( '</div>' );
+ /* Wikia change begin - @author: uknkown */
+ /* TODO: Find out what it is exactly for */
+ if ( $this->autosave ) {
+ $wgOut->addHTML( "<script type='text/javascript'>document.editform.wpPreview.click();</script>" );
+ }
+ /* Wikia change end */
+
if ( $this->formtype == 'diff') {
$this->showDiff();
}
@@ -1738,7 +1880,7 @@
protected function showStandardInputs( &$tabindex = 2 ) {
global $wgOut, $wgUser;
- $wgOut->addHTML( "<div class='editOptions'>\n" );
+ $wgOut->addHTML( "<div class='editOptions' id='editOptions'>\n" );
if ( $this->section != 'new' ) {
$this->showSummaryInput( false, $this->summary );
@@ -1747,6 +1889,11 @@
$checkboxes = $this->getCheckboxes( $tabindex, $wgUser->getSkin(),
array( 'minor' => $this->minoredit, 'watch' => $this->watchthis ) );
+
+ // wikia change begin, @author eloy
+ wfRunHooks ( 'EditPage::showEditForm:checkboxes', array ( &$this, &$checkboxes ) ) ;
+ // wikia change end
+
$wgOut->addHTML( "<div class='editCheckboxes'>" . implode( $checkboxes, "\n" ) . "</div>\n" );
$wgOut->addHTML( "<div class='editButtons'>\n" );
$wgOut->addHTML( implode( $this->getEditButtons( $tabindex ), "\n" ) . "\n" );
@@ -1754,7 +1901,7 @@
$cancel = $this->getCancelLink();
$separator = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
$edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' ) );
- $edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
+ $edithelp = '<a target="helpwindow" href="'.$edithelpurl.'" id="wpEdithelp">'.
htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '.
htmlspecialchars( wfMsg( 'newwindow' ) );
$wgOut->addHTML( " <span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n" );
@@ -1822,6 +1969,16 @@
wfProfileIn( __METHOD__ );
+ // wikia change begin
+ // TODO: remove?
+ // @see https://trac.wikia-inc.com/changeset/6028
+ global $wgRequest;
+ if ($wgUser->getOption( 'showtoolbar' ) && !$wgUser->getOption( 'riched_disable' ) && !$this->previewOnOpen() ) {
+ $oldTextBox1 = $this->textbox1;
+ $this->importFormData( $wgRequest );
+ }
+ // wikia change end
+
if ( $this->mTriedSave && !$this->mTokenOk ) {
if ( $this->mTokenOkExceptSuffix ) {
$note = wfMsg( 'token_suffix_mismatch' );
@@ -1898,6 +2055,11 @@
$conflict = '<hr />';
}
+ // wikia change begin
+ // BugId:5451
+ wfRunHooks( 'EditPageGetPreviewNote', array( $this, &$note ) );
+ // wikia change end
+
$previewhead = "<div class='previewnote'>\n" .
'<h2 id="mw-previewheader">' . htmlspecialchars( wfMsg( 'preview' ) ) . "</h2>" .
$wgOut->parse( $note ) . $conflict . "</div>\n";
@@ -1925,7 +2087,10 @@
* Call the stock "user is blocked" page
*/
function blockedPage() {
- global $wgOut;
+ // Wikia - start - @author: ADi - removed wgOut from global to allow injecting it
+ // define wgOut
+ $wgOut = !empty($this->customOutputPage) ? $this->customOutputPage : $GLOBALS['wgOut'];
+ // Wikia - end
$wgOut->blockedPage( false ); # Standard block notice on the top, don't 'return'
# If the user made changes, preserve them when showing the markup
@@ -1956,7 +2121,7 @@
$loginLink = $skin->link(
$loginTitle,
wfMsgHtml( 'loginreqlink' ),
- array(),
+ array( 'rel' => 'nofollow' ),
array( 'returnto' => $wgTitle->getPrefixedText() ),
array( 'known', 'noclasses' )
);
@@ -2208,7 +2373,11 @@
'key' => 'R'
)
);
- $toolbar = "<div id='toolbar'>\n";
+
+ // wikia change begin
+ wfRunHooks( 'ToolbarGenerate', array( &$toolarray ) );
+ $toolbar = "<div id='toolbar' style='clear:both'>\n";
+ // wikia change end
$script = '';
foreach ( $toolarray as $tool ) {
@@ -2229,6 +2398,11 @@
array_map( array( 'Xml', 'encodeJsVar' ), $params ) );
$script .= "addButton($paramList);\n";
}
+
+ // wikia change begin
+ $script .= "mwWikiaUploadNamespace = '".$wgContLang->getNsText(NS_IMAGE)."';\nmwWikiaUploadTooltip = '".wfMsg('insertimagetitle')."';\n";
+ // wikia change end
+
$toolbar .= Html::inlineScript( "\n$script\n" );
$toolbar .= "\n</div>";
@@ -2398,6 +2572,9 @@
$newtext = $this->mArticle->preSaveTransform( $newtext );
$oldtitle = wfMsgExt( 'currentrev', array( 'parseinline' ) );
$newtitle = wfMsgExt( 'yourtext', array( 'parseinline' ) );
+
+ wfRunHooks( 'EditPageBeforeDiffText', array( $this, &$newtext, &$oldtext, &$newtitle, &$oldtitle) );
+
if ( $oldtext !== false || $newtext != '' ) {
$de = new DifferenceEngine( $this->mTitle );
$de->setText( $oldtext, $newtext );