X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=0b247f154c164de429c89f783990f579cdc0a782;hb=418e7767b4e6d27344bd81da8a8ddd319784f4b3;hp=4163a127a844d2072d857dcfc5da60d19e94fa0a;hpb=25a0b5503fbe17a34efc6970e2d70ab66efecfec;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/EditPage.php b/includes/EditPage.php index 4163a127a8..0b247f154c 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -103,13 +103,15 @@ class EditPage { $this->editFormTextBeforeContent = $this->editFormTextAfterWarn = $this->editFormTextAfterTools = - $this->editFormTextBottom = ""; + $this->editFormTextBottom = + $this->mPreloadText = ""; } function getArticle() { return $this->mArticle; } + /** * Fetch initial editing page content. * @private @@ -200,6 +202,11 @@ class EditPage { wfProfileOut( __METHOD__ ); return $text; } + + /** Use this method before edit() to preload some text into the edit box */ + public function setPreloadedText( $text ) { + $this->mPreloadText = $text; + } /** * Get the contents of a page from its title and remove includeonly tags @@ -208,7 +215,9 @@ class EditPage { * @return string The contents of the page. */ protected function getPreloadedText( $preload ) { - if ( $preload === '' ) { + if ( !empty($this->mPreloadText) ) { + return $this->mPreloadText; + } elseif ( $preload === '' ) { return ''; } else { $preloadTitle = Title::newFromText( $preload ); @@ -324,7 +333,7 @@ class EditPage { protected function wasDeletedSinceLastEdit() { if ( $this->deletedSinceEdit ) return true; - if ( $this->mTitle->isDeleted() ) { + if ( $this->mTitle->isDeletedQuick() ) { $this->lastDelete = $this->getLastDelete(); if ( $this->lastDelete ) { $deleteTime = wfTimestamp( TS_MW, $this->lastDelete->log_timestamp ); @@ -352,7 +361,7 @@ class EditPage { * the newly-edited page. */ function edit() { - global $wgOut, $wgUser, $wgRequest; + global $wgOut, $wgRequest, $wgEnableJS2system; // Allow extensions to modify/prevent this form or submission if ( !wfRunHooks( 'AlternateEdit', array( &$this ) ) ) { return; @@ -380,6 +389,10 @@ class EditPage { } $wgOut->addScriptFile( 'edit.js' ); + + if($wgEnableJS2system) + $wgOut->addScriptClass( 'editPage' ); + $permErrors = $this->getEditPermissionErrors(); if ( $permErrors ) { wfDebug( __METHOD__.": User can't edit\n" ); @@ -403,6 +416,11 @@ class EditPage { } } } + + // If they used redlink=1 and the page exists, redirect to the main article + if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) { + $wgOut->redirect( $this->mTitle->getFullURL() ); + } wfProfileIn( __METHOD__."-business-end" ); @@ -421,7 +439,6 @@ class EditPage { # Optional notices on a per-namespace and per-page basis $editnotice_ns = 'editnotice-'.$this->mTitle->getNamespace(); - $editnotice_page = $editnotice_ns.'-'.$this->mTitle->getDBkey(); if ( !wfEmptyMsg( $editnotice_ns, wfMsgForContent( $editnotice_ns ) ) ) { $wgOut->addWikiText( wfMsgForContent( $editnotice_ns ) ); } @@ -434,8 +451,6 @@ class EditPage { $wgOut->addWikiText( wfMsgForContent( $editnotice_base ) ); } } - } else if ( !wfEmptyMsg( $editnotice_page, wfMsgForContent( $editnotice_page ) ) ) { - $wgOut->addWikiText( wfMsgForContent( $editnotice_page ) ); } # Attempt submission here. This will check for edit conflicts, @@ -647,12 +662,16 @@ class EditPage { } } + // FIXME: unused variable? $this->oldid = $request->getInt( 'oldid' ); $this->live = $request->getCheck( 'live' ); $this->editintro = $request->getText( 'editintro' ); wfProfileOut( $fname ); + + // Allow extensions to modify form data + wfRunHooks( 'EditPage::importFormData', array( &$this, $request ) ); } /** @@ -705,9 +724,9 @@ class EditPage { $wgOut->wrapWikiMsg( '