X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2FEditPage.php;h=3bc10379efd165d40b452f778a195f0019cc9f4a;hb=d739acf579157b55924fc2e1dedd9b349fd786ac;hp=ad1c6c66835898ff96c15f09f881d71870700a01;hpb=d6bf15d117600920f512bf45d7265237303070f0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/EditPage.php b/includes/EditPage.php index ad1c6c6683..3bc10379ef 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -48,6 +48,8 @@ class EditPage { var $mMetaData = ''; var $isConflict = false; var $isCssJsSubpage = false; + var $isCssSubpage = false; + var $isJsSubpage = false; var $deletedSinceEdit = false; var $formtype; var $firsttime; @@ -103,13 +105,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 +204,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 +217,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 ); @@ -352,7 +363,7 @@ class EditPage { * the newly-edited page. */ function edit() { - global $wgOut, $wgRequest; + global $wgOut, $wgRequest, $wgEnableJS2system; // Allow extensions to modify/prevent this form or submission if ( !wfRunHooks( 'AlternateEdit', array( &$this ) ) ) { return; @@ -380,6 +391,10 @@ class EditPage { } $wgOut->addScriptFile( 'edit.js' ); + + if($wgEnableJS2system) + $wgOut->addScriptClass( 'editPage' ); + $permErrors = $this->getEditPermissionErrors(); if ( $permErrors ) { wfDebug( __METHOD__.": User can't edit\n" ); @@ -414,6 +429,8 @@ class EditPage { $this->isConflict = false; // css / js subpages of user pages get a special treatment $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage(); + $this->isCssSubpage = $this->mTitle->isCssSubpage(); + $this->isJsSubpage = $this->mTitle->isJsSubpage(); $this->isValidCssJsSubpage = $this->mTitle->isValidCssJsSubpage(); # Show applicable editing introductions @@ -649,12 +666,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 ) ); } /** @@ -865,7 +886,7 @@ class EditPage { } // Run post-section-merge edit filter - if ( !wfRunHooks( 'EditFilterMerged', array( $this, $this->textbox1, &$this->hookError, $this->summary ) ) ) { + if ( !wfRunHooks( 'EditFilterMerged', array( &$this, $this->textbox1, &$this->hookError, $this->summary ) ) ) { # Error messages etc. could be handled within the hook... wfProfileOut( $fname ); return self::AS_HOOK_ERROR; @@ -953,7 +974,7 @@ class EditPage { $oldtext = $this->mArticle->getContent(); // Run post-section-merge edit filter - if ( !wfRunHooks( 'EditFilterMerged', array( $this, $text, &$this->hookError, $this->summary ) ) ) { + if ( !wfRunHooks( 'EditFilterMerged', array( &$this, $text, &$this->hookError, $this->summary ) ) ) { # Error messages etc. could be handled within the hook... wfProfileOut( $fname ); return self::AS_HOOK_ERROR; @@ -1058,7 +1079,7 @@ class EditPage { } return true; } - + /** * Check given input text against $wgSpamRegex, and return the text of the first match. * @return mixed -- matching string or false @@ -1146,8 +1167,6 @@ class EditPage { $sk = $wgUser->getSkin(); - wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) ) ; - #need to parse the preview early so that we know which templates are used, #otherwise users with "show preview after edit box" will get a blank list #we parse this near the beginning so that setHeaders can do the title @@ -1156,6 +1175,8 @@ class EditPage { if ( $this->formtype == 'preview' ) { $previewOutput = $this->getPreviewText(); } + + wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) ) ; $this->setHeaders(); @@ -1226,7 +1247,10 @@ class EditPage { # Check the skin exists if ( $this->isValidCssJsSubpage ) { if ( $this->formtype !== 'preview' ) { - $wgOut->addWikiMsg( 'usercssjsyoucanpreview' ); + if ( $this->isCssSubpage ) + $wgOut->addWikiMsg( 'usercssyoucanpreview' ); + if ( $this->isJsSubpage ) + $wgOut->addWikiMsg( 'userjsyoucanpreview' ); } } else { $wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() ); @@ -1282,15 +1306,18 @@ class EditPage { $wgOut->addHTML( "\n" ); } - $q = 'action='.$this->action; - #if ( "no" == $redirect ) { $q .= "&redirect=no"; } - $action = $wgTitle->escapeLocalURL( $q ); + $action = $wgTitle->escapeLocalURL( array( 'action' => $this->action ) ); $summary = wfMsgExt( 'summary', 'parseinline' ); $subject = wfMsgExt( 'subject', 'parseinline' ); - $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(), - wfMsgExt('cancel', array('parseinline')) ); + $cancel = $sk->link( + $wgTitle, + wfMsgExt( 'cancel', array( 'parseinline' ) ), + array(), + array(), + array( 'known', 'noclasses' ) + ); $separator = wfMsgExt( 'pipe-separator' , 'escapenoentities' ); $edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' )); $edithelp = ''. @@ -1306,6 +1333,8 @@ class EditPage { $copywarnMsg = array( 'copyrightwarning2', '[[' . wfMsgForContent( 'copyrightpage' ) . ']]' ); } + // Allow for site and per-namespace customization of contribution/copyright notice. + wfRunHooks( 'EditPageCopyrightWarning', array( $this->mTitle, &$copywarnMsg ) ); if ( $wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage ) { # prepare toolbar for edit buttons @@ -1314,6 +1343,7 @@ class EditPage { $toolbar = ''; } + // activate checkboxes if user wants them to be always active if ( !$this->preview && !$this->diff ) { # Sort out the "watch" checkbox @@ -1327,7 +1357,7 @@ class EditPage { # Already watched $this->watchthis = true; } - + # May be overriden by request parameters if( $wgRequest->getBool( 'watchthis' ) ) { $this->watchthis = true; @@ -1536,6 +1566,7 @@ END $token = htmlspecialchars( $wgUser->editToken() ); $wgOut->addHTML( "\n\n" ); + $this->showTosSummary(); $this->showEditTools(); $wgOut->addHTML( <<addScriptFile( 'preview.js' ); - $liveAction = $wgTitle->getLocalUrl( "action={$this->action}&wpPreview=true&live=true" ); + $liveAction = $wgTitle->getLocalUrl( array( + 'action' => $this->action, + 'wpPreview' => 'true', + 'live' => 'true' + ) ); return "return !lpDoPreview(" . "editform.wpTextbox1.value," . '"' . $liveAction . '"' . ")"; } + protected function showTosSummary() { + $msg = 'editpage-tos-summary'; + // Give a chance for site and per-namespace customizations of + // terms of service summary link that might exist separately + // from the copyright notice. + // + // This will display between the save button and the edit tools, + // so should remain short! + wfRunHooks( 'EditPageTosSummary', array( $this->mTitle, &$msg ) ); + $text = wfMsg( $msg ); + if( !wfEmptyMsg( $msg, $text ) && $text !== '-' ) { + global $wgOut; + $wgOut->addHTML( '
' ); + $wgOut->addWikiMsgArray( $msg, array() ); + $wgOut->addHTML( '
' ); + } + } + protected function showEditTools() { global $wgOut; $wgOut->addHTML( '
' ); @@ -1864,7 +1917,13 @@ END $skin = $wgUser->getSkin(); $loginTitle = SpecialPage::getTitleFor( 'Userlogin' ); - $loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $wgTitle->getPrefixedUrl() ); + $loginLink = $skin->link( + $loginTitle, + wfMsgHtml( 'loginreqlink' ), + array(), + array( 'returnto' => $wgTitle->getPrefixedText() ), + array( 'known', 'noclasses' ) + ); $wgOut->setPageTitle( wfMsg( 'whitelistedittitle' ) ); $wgOut->setRobotPolicy( 'noindex,nofollow' ); @@ -2134,6 +2193,9 @@ END $toolbar.="/*]]>*/\n"; $toolbar.="\n
"; + + wfRunHooks( 'EditPageBeforeEditToolbar', array( &$toolbar ) ); + return $toolbar; } @@ -2449,7 +2511,8 @@ END global $wgUser; $loglist = new LogEventsList( $wgUser->getSkin(), $out ); $pager = new LogPager( $loglist, array('move', 'delete'), false, - $this->mTitle->getPrefixedText(), '', array('log_action'=>'delete') ); + $this->mTitle->getPrefixedText(), '', array( "log_action != 'revision'" ) ); + $count = $pager->getNumRows(); if ( $count > 0 ) { $pager->mLimit = 10;