From ba3e5449ed1b661604e2ff71dfbdd7eb7f762d6a Mon Sep 17 00:00:00 2001 From: David McCabe Date: Sat, 3 Nov 2007 03:20:12 +0000 Subject: [PATCH] Liquid Threads EditPage take 3: Now we use $this->mTitle for the database side, $wgTitle for the UI side. There is a note at the top of the file. Also added $suppressIntro, $didSave, and $editFormTextBeforeContent. --- includes/EditPage.php | 84 ++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index ea6ecffe27..42f5b41b6e 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -8,6 +8,12 @@ * The actual database and text munging is still in Article, * but it should get easier to call those from alternate * interfaces. + * + * EditPage cares about two distinct titles: + * $wgTitle is the page that forms submit to, links point to, + * redirects go to, etc. $this->mTitle (as well as $mArticle) is the + * page in the database that is actually being edited. These are + * usually the same, but they are now allowed to be different. */ class EditPage { const AS_SUCCESS_UPDATE = 200; @@ -65,22 +71,29 @@ class EditPage { # extensions should take care to _append_ to the present value public $editFormPageTop; // Before even the preview public $editFormTextTop; + public $editFormTextBeforeContent; public $editFormTextAfterWarn; public $editFormTextAfterTools; public $editFormTextBottom; + + /* $didSave should be set to true whenever an article was succesfully altered. */ + public $didSave = false; + + public $suppressIntro = false; /** * @todo document * @param $article */ function EditPage( $article ) { - $this->mArticle =& $article; global $wgTitle; - $this->mTitle =& $wgTitle; + $this->mArticle =& $article; + $this->mTitle = $article->getTitle(); # Placeholders for text injection by hooks (empty per default) $this->editFormPageTop = $this->editFormTextTop = + $this->editFormTextBeforeContent = $this->editFormTextAfterWarn = $this->editFormTextAfterTools = $this->editFormTextBottom = ""; @@ -395,8 +408,8 @@ class EditPage { $this->isConflict = false; // css / js subpages of user pages get a special treatment - $this->isCssJsSubpage = $wgTitle->isCssJsSubpage(); - $this->isValidCssJsSubpage = $wgTitle->isValidCssJsSubpage(); + $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage(); + $this->isValidCssJsSubpage = $this->mTitle->isValidCssJsSubpage(); /* Notice that we can't use isDeleted, because it returns true if article is ever deleted * no matter it's current state @@ -610,6 +623,7 @@ class EditPage { */ private function showIntro() { global $wgOut, $wgUser; + if( $this->suppressIntro ) return; if( !$this->showCustomIntro() && !$this->mTitle->exists() ) { if( $wgUser->isLoggedIn() ) { $wgOut->addWikiText( wfMsg( 'newarticletext' ) ); @@ -688,7 +702,7 @@ class EditPage { wfProfileOut( $fname ); return self::AS_HOOK_ERROR_EXPECTED; } - if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) { + if ( $wgUser->isBlockedFrom( $wgTitle, false ) ) { # Check block state against master, thus 'false'. wfProfileOut( "$fname-checks" ); wfProfileOut( $fname ); @@ -913,8 +927,8 @@ class EditPage { $this->textbox1 = $this->getContent(false); if ($this->textbox1 === false) return false; - if ( !$this->mArticle->exists() && $this->mArticle->mTitle->getNamespace() == NS_MEDIAWIKI ) - $this->textbox1 = wfMsgWeirdKey( $this->mArticle->mTitle->getText() ); + if ( !$this->mArticle->exists() && $this->mTitle->getNamespace() == NS_MEDIAWIKI ) + $this->textbox1 = wfMsgWeirdKey( $this->mTitle->getText() ); wfProxyCheck(); return true; } @@ -926,7 +940,7 @@ class EditPage { * near the top, for captchas and the like. */ function showEditForm( $formCallback=null ) { - global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize; + global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle; $fname = 'EditPage::showEditForm'; wfProfileIn( $fname ); @@ -945,7 +959,7 @@ class EditPage { } if ( $this->isConflict ) { - $s = wfMsg( 'editconflict', $this->mTitle->getPrefixedText() ); + $s = wfMsg( 'editconflict', $wgTitle->getPrefixedText() ); $wgOut->setPageTitle( $s ); $wgOut->addWikiText( wfMsg( 'explainconflict' ) ); @@ -956,9 +970,9 @@ class EditPage { if( $this->section != '' ) { if( $this->section == 'new' ) { - $s = wfMsg('editingcomment', $this->mTitle->getPrefixedText() ); + $s = wfMsg('editingcomment', $wgTitle->getPrefixedText() ); } else { - $s = wfMsg('editingsection', $this->mTitle->getPrefixedText() ); + $s = wfMsg('editingsection', $wgTitle->getPrefixedText() ); $matches = array(); if( !$this->summary && !$this->preview && !$this->diff ) { preg_match( "/^(=+)(.+)\\1/mi", @@ -973,7 +987,7 @@ class EditPage { } } } else { - $s = wfMsg( 'editing', $this->mTitle->getPrefixedText() ); + $s = wfMsg( 'editing', $wgTitle->getPrefixedText() ); } $wgOut->setPageTitle( $s ); @@ -1018,7 +1032,7 @@ class EditPage { if( $this->isValidCssJsSubpage ) { $wgOut->addWikiText( wfMsg( 'usercssjsyoucanpreview' ) ); } else { - $wgOut->addWikiText( wfMsg( 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ) ); + $wgOut->addWikiText( wfMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() ) ); } } } @@ -1075,12 +1089,12 @@ class EditPage { $q = 'action=submit'; #if ( "no" == $redirect ) { $q .= "&redirect=no"; } - $action = $this->mTitle->escapeLocalURL( $q ); + $action = $wgTitle->escapeLocalURL( $q ); $summary = wfMsg('summary'); $subject = wfMsg('subject'); - $cancel = $sk->makeKnownLink( $this->mTitle->getPrefixedText(), + $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')) ); $edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' )); $edithelp = ''. @@ -1219,6 +1233,7 @@ END $recreate {$commentsubject} {$subjectpreview} +{$this->editFormTextBeforeContent}