X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=5ab5adc923a92b338f49cd72d201d696186d748e;hb=35c222b736c3d5a5500f654f2572d54209d05cea;hp=7ebcde0faae0d21c6039dec8d527c531ec89c055;hpb=f0973112fbe032534330ad73bb9ff9192c6f9c2d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/EditPage.php b/includes/EditPage.php index 7ebcde0faa..5ab5adc923 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -409,10 +409,13 @@ class EditPage { wfProfileOut( __METHOD__ ); return; } - if ( !$this->mTitle->getArticleID() ) + + if ( !$this->mTitle->getArticleID() ) { wfRunHooks( 'EditFormPreloadText', array( &$this->textbox1, &$this->mTitle ) ); - else + } else { wfRunHooks( 'EditFormInitialText', array( $this ) ); + } + } $this->showEditForm(); @@ -606,8 +609,10 @@ class EditPage { // modified by subclasses wfProfileIn( get_class( $this ) . "::importContentFormData" ); $textbox1 = $this->importContentFormData( $request ); - if ( isset( $textbox1 ) ) + if ( isset( $textbox1 ) ) { $this->textbox1 = $textbox1; + } + wfProfileOut( get_class( $this ) . "::importContentFormData" ); } @@ -1057,7 +1062,8 @@ class EditPage { $title = Title::newFromText( $preload ); # Check for existence to avoid getting MediaWiki:Noarticletext - if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) { + if ( $title === null || !$title->exists() || !$title->userCan( 'read', $wgUser ) ) { + //TODO: somehow show a warning to the user! return $handler->makeEmptyContent(); } @@ -1065,7 +1071,8 @@ class EditPage { if ( $page->isRedirect() ) { $title = $page->getRedirectTarget(); # Same as before - if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) { + if ( $title === null || !$title->exists() || !$title->userCan( 'read', $wgUser ) ) { + //TODO: somehow show a warning to the user! return $handler->makeEmptyContent(); } $page = WikiPage::factory( $title ); @@ -1075,9 +1082,25 @@ class EditPage { $content = $page->getContent( Revision::RAW ); if ( !$content ) { + //TODO: somehow show a warning to the user! return $handler->makeEmptyContent(); } + if ( $content->getModel() !== $handler->getModelID() ) { + $converted = $content->convert( $handler->getModelID() ); + + if ( !$converted ) { + //TODO: somehow show a warning to the user! + wfDebug( "Attempt to preload incompatible content: " + . "can't convert " . $content->getModel() + . " to " . $handler->getModelID() ); + + return $handler->makeEmptyContent(); + } + + $content = $converted; + } + return $content->preloadTransform( $title, $parserOptions ); } @@ -1347,7 +1370,7 @@ class EditPage { if ( $new ) { // Late check for create permission, just in case *PARANOIA* - if ( !$this->mTitle->userCan( 'create' ) ) { + if ( !$this->mTitle->userCan( 'create', $wgUser ) ) { $status->fatal( 'nocreatetext' ); $status->value = self::AS_NO_CREATE_PERMISSION; wfDebug( __METHOD__ . ": no create permission\n" ); @@ -1393,8 +1416,8 @@ class EditPage { // passed. if ( $this->summary === '' ) { $cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle ); - $this->summary = wfMessage( 'newsectionsummary', $cleanSectionTitle ) - ->inContentLanguage()->text() ; + $this->summary = wfMessage( 'newsectionsummary' ) + ->rawParams( $cleanSectionTitle )->inContentLanguage()->text(); } } elseif ( $this->summary !== '' ) { // Insert the section title above the content. @@ -1405,8 +1428,8 @@ class EditPage { // Create a link to the new section from the edit summary. $cleanSummary = $wgParser->stripSectionName( $this->summary ); - $this->summary = wfMessage( 'newsectionsummary', $cleanSummary ) - ->inContentLanguage()->text(); + $this->summary = wfMessage( 'newsectionsummary' ) + ->rawParams( $cleanSummary )->inContentLanguage()->text(); } } @@ -1469,10 +1492,9 @@ class EditPage { $content = $textbox_content; // do not try to merge here! } elseif ( $this->isConflict ) { # Attempt merge - if ( $this->mergeChangesInto( $content ) ) { + if ( $this->mergeChangesIntoContent( $content ) ) { // Successful merge! Maybe we should tell the user the good news? $this->isConflict = false; - $content = $this->toEditContent( $content ); wfDebug( __METHOD__ . ": Suppressing edit conflict, successful merge.\n" ); } else { $this->section = ''; @@ -1549,16 +1571,16 @@ class EditPage { // passed. if ( $this->summary === '' ) { $cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle ); - $this->summary = wfMessage( 'newsectionsummary', $cleanSectionTitle ) - ->inContentLanguage()->text(); + $this->summary = wfMessage( 'newsectionsummary' ) + ->rawParams( $cleanSectionTitle )->inContentLanguage()->text(); } } elseif ( $this->summary !== '' ) { $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->summary ); # This is a new section, so create a link to the new section # in the revision summary. $cleanSummary = $wgParser->stripSectionName( $this->summary ); - $this->summary = wfMessage( 'newsectionsummary', $cleanSummary ) - ->inContentLanguage()->text(); + $this->summary = wfMessage( 'newsectionsummary' ) + ->rawParams( $cleanSummary )->inContentLanguage()->text(); } } elseif ( $this->section != '' ) { # Try to get a section anchor from the section source, redirect to edited section if header found @@ -1660,37 +1682,15 @@ class EditPage { function mergeChangesInto( &$editText ){ ContentHandler::deprecated( __METHOD__, "1.21" ); - wfProfileIn( __METHOD__ ); - - $db = wfGetDB( DB_MASTER ); - - // This is the revision the editor started from - $baseRevision = $this->getBaseRevision(); - if ( is_null( $baseRevision ) ) { - wfProfileOut( __METHOD__ ); - return false; - } - $baseText = $baseRevision->getText(); - - // The current state, we want to merge updates into it - $currentRevision = Revision::loadFromTitle( $db, $this->mTitle ); - if ( is_null( $currentRevision ) ) { - wfProfileOut( __METHOD__ ); - return false; - } - $currentText = $currentRevision->getText(); + $editContent = $this->toEditContent( $editText ); - $result = ''; - $editText = $this->toEditText( $editText ); + $ok = $this->mergeChangesIntoContent( $editContent ); - if ( wfMerge( $baseText, $editText, $currentText, $result ) ) { - $editText = $result; - wfProfileOut( __METHOD__ ); + if ( $ok ) { + $editText = $this->toEditText( $editContent ); return true; - } else { - wfProfileOut( __METHOD__ ); - return false; } + return false; } /** @@ -1939,7 +1939,7 @@ class EditPage { * an exception will be raised. Set $this->allowNonTextContent to true to allow editing of non-textual * content. * - * @param Content|null|false|string $content + * @param Content|null|bool|string $content * @return String the editable text form of the content. * * @throws MWException if $content is not an instance of TextContent and $this->allowNonTextContent is not true. @@ -2265,7 +2265,7 @@ class EditPage { if ( $revision ) { // Let sysop know that this will make private content public if saved - if ( !$revision->userCan( Revision::DELETED_TEXT ) ) { + if ( !$revision->userCan( Revision::DELETED_TEXT, $wgUser ) ) { $wgOut->wrapWikiMsg( "