/** * Show error message for missing or incorrect captcha on EditPage. * @param EditPage $editPage * @param OutputPage $out */ function showEditFormFields(&$editPage, &$out) { $page = $editPage->getArticle()->getPage(); if (!isset($page->ConfirmEdit_ActivateCaptcha)) { return; } if ($this->action !== 'edit') { unset($page->ConfirmEdit_ActivateCaptcha); $out->addWikiText($this->getMessage($this->action)); $out->addHTML($this->getForm($out)); } }
/** * Insert the captcha prompt into an edit form. * @param OutputPage $out */ function editCallback(&$out) { $out->addWikiText($this->getMessage($this->action)); $out->addHTML($this->getForm()); $this->addCSS(&$out); }
/** * Send the text to be displayed above the options * * @param $out OutputPage * @param $opts FormOptions */ function setTopText(OutputPage $out, FormOptions $opts) { $out->addWikiText(wfMsgForContentNoTrans('recentchangestext')); }
/** * This is the meaty bit -- restores archived revisions of the given page * to the cur/old tables. If the page currently exists, all revisions will * be stuffed into old, otherwise the most recent will go into cur. * The deletion log will be updated with an undeletion notice. * * Returns true on success. * * @param array $timestamps Pass an empty array to restore all revisions, otherwise list the ones to undelete. * @return bool */ function undelete($timestamps) { global $wgUser, $wgOut, $wgLang, $wgDeferredUpdateList; global $wgUseSquid, $wgInternalServer, $wgLinkCache; global $wgDBtype; $fname = "doUndeleteArticle"; $restoreAll = empty($timestamps); $restoreRevisions = count($timestamps); $dbw =& wfGetDB(DB_MASTER); extract($dbw->tableNames('page', 'archive')); # Does this page already exist? We'll have to update it... $article = new Article($this->title); $options = $wgDBtype == 'PostgreSQL' ? '' : 'FOR UPDATE'; $page = $dbw->selectRow('page', array('page_id', 'page_latest'), array('page_namespace' => $this->title->getNamespace(), 'page_title' => $this->title->getDBkey()), $fname, $options); if ($page) { # Page already exists. Import the history, and if necessary # we'll update the latest revision field in the record. $newid = 0; $pageId = $page->page_id; $previousRevId = $page->page_latest; $previousTimestamp = $page->rev_timestamp; } else { # Have to create a new article... $newid = $article->insertOn($dbw); $pageId = $newid; $previousRevId = 0; $previousTimestamp = 0; } if ($restoreAll) { $oldones = '1'; # All revisions... } else { $oldts = implode(',', array_map(array(&$dbw, 'addQuotes'), array_map(array(&$dbw, 'timestamp'), $timestamps))); $oldones = "ar_timestamp IN ( {$oldts} )"; } /** * Restore each revision... */ $result = $dbw->select('archive', array('ar_rev_id', 'ar_text', 'ar_comment', 'ar_user', 'ar_user_text', 'ar_timestamp', 'ar_minor_edit', 'ar_flags', 'ar_text_id'), array('ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey(), $oldones), $fname, array('ORDER BY' => 'ar_timestamp')); $revision = null; while ($row = $dbw->fetchObject($result)) { $revision = new Revision(array('page' => $pageId, 'id' => $row->ar_rev_id, 'text' => Revision::getRevisionText($row, 'ar_'), 'comment' => $row->ar_comment, 'user' => $row->ar_user, 'user_text' => $row->ar_user_text, 'timestamp' => $row->ar_timestamp, 'minor_edit' => $row->ar_minor_edit, 'text_id' => $row->ar_text_id)); $revision->insertOn($dbw); } if ($revision) { # FIXME: Update latest if newer as well... if ($newid) { # FIXME: update article count if changed... $article->updateRevisionOn($dbw, $revision, $previousRevId); # Finally, clean up the link tables $wgLinkCache = new LinkCache(); # Select for update $wgLinkCache->forUpdate(true); # Create a dummy OutputPage to update the outgoing links $dummyOut = new OutputPage(); $dummyOut->addWikiText($revision->getText()); $u = new LinksUpdate($newid, $this->title->getPrefixedDBkey()); array_push($wgDeferredUpdateList, $u); #TODO: SearchUpdate, etc. } if ($newid) { Article::onArticleCreate($this->title); } else { Article::onArticleEdit($this->title); } } else { # Something went terribly worong! } # Now that it's safely stored, take it out of the archive $dbw->delete('archive', array('ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey(), $oldones), $fname); # Touch the log! $log = new LogPage('delete'); if ($restoreAll) { $reason = ''; } else { $reason = wfMsgForContent('undeletedrevisions', $restoreRevisions); } $log->addEntry('restore', $this->title, $reason); return true; }
/** * Print extra field for 'title' * * @param OutputPage $wgOut */ public function renderFormHeader($wgOut) { global $wgRequest; $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/"); $oTmpl->set_vars(array("formErrors" => $this->mFormErrors, "formData" => $this->mFormData, "isReload" => $wgRequest->getVal('wpIsReload', 0) == 1, "editIntro" => $wgOut->parse($this->mEditIntro))); $wgOut->setPageTitle(wfMsg("createpage")); $wgOut->addScriptFile('edit.js'); if ($this->mPreviewTitle == null) { $wgOut->addHTML('<div id="custom_createpagetext">'); $wgOut->addWikiText(wfMsgForContent('newarticletext')); $wgOut->addHTML('</div>'); } $wgOut->addHTML($oTmpl->render("createFormHeader")); }
/** * What we should do if the permission action is clicked. * @param OutputPage $output * @param Article $article * @param Title $title * @param User $user * @param WebRequest $request * @Param MediaWiki $wiki */ static function displayACLForm($output, $article, $title, $user, $request, $wiki) { global $wgParser; if ($request->getVal('action') != self::$ACTION) { return true; } $text = ""; $owner = MWUtil::pageOwner($title, true); $text .= "Page owner is '''" . $owner->getName() . "'''."; ACL::loadUserGroups(); $ownergroups = ACL::getUserGroups($owner); $ogroups = " Owner belongs to these user groups:"; if ($ownergroups) { foreach ($ownergroups as $g) { $ogroups .= $g['name'] . ","; } } else { $ogroups = " Owner does not belong to any user group"; } $text .= $ogroups . "\n\n"; $permissionpage = ACL_ACL . ":" . $article->getID(); $permissiontitle = Title::newFromText($permissionpage); $ns = $title->getNSText(); if (!$ns) { $ns = "Main"; } $sp = SpecialPage::getPage("FormEdit"); $sp_url = $sp->getTitle()->getLocalURL(); $sp_url .= "?form=" . self::$FORM . "&target={$permissionpage}&ACL Page Permission[PageId]={$article->getID()}&ACL Page Permission[PageName]={$title->getDBkey()}&ACL Page Permission[Namespace]={$ns}"; if ($permissiontitle->exists()) { $text .= "[[{$permissionpage}|View Page Permission]]\n\n----\n"; $output->addWikiText($text); $output->addHTML("<a href='{$sp_url}'>Edit permission for this page</a>"); } else { $text .= "No page specific Permission is set."; $output->addWikiText($text); $output->addHTML("<a href='{$sp_url}'>Set permission for this page</a>"); } return false; }
protected function showUserpage( $step ) { global $wgRequest; $textareaId = 'userpagetext'; $header = new HtmlTag( 'h2' ); $step_message = 'translate-fs-userpage-title'; $header->style( 'opacity', 0.4 )->content( wfMsg( $step_message ) ); if ( $step ) { $this->out->addHtml( $header ); return $step; } $userpage = $this->user->getUserPage(); $preload = "I am My Name and...."; if ( $wgRequest->wasPosted() && $this->user->matchEditToken( $wgRequest->getVal( 'token' ) ) && $wgRequest->getText( 'step' ) === 'userpage' ) { $babel = array(); for ( $i = 0; $i < 5; $i++ ) { $language = $wgRequest->getText( "babel-$i-language", '-' ); if ( $language === '-' ) continue; $level = $wgRequest->getText( "babel-$i-level", '-' ); $babel[$language] = $level; } arsort( $babel ); $babeltext = '{{#babel:'; foreach ( $babel as $language => $level ) { if ( $level === 'N' ) $level = ''; else $level = "-$level"; $babeltext .= "$language$level|"; } $babeltext = trim( $babeltext, '|' ); $babeltext .= "}}\n"; $article = new Article( $userpage, 0 ); $status = $article->doEdit( $babeltext . $wgRequest->getText( $textareaId ), $this->getTitle() ); if ( $status->isOK() ) { $header->content( $header->content . wfMsg( 'translate-fs-pagetitle-done' ) ); $this->out->addHtml( $header ); $this->out->addWikiMsg( 'translate-fs-userpage-done' ); return false; } else { $this->out->addWikiText( $status->getWikiText() ); $preload = $wgRequest->getText( 'userpagetext' ); } } if ( $userpage->exists() ) { $revision = Revision::newFromTitle( $userpage ); $text = $revision->getText(); $preload = $text; if ( preg_match( '/{{#babel:/i', $text ) ) { $header->content( $header->content . wfMsg( 'translate-fs-pagetitle-done' ) ); $this->out->addHtml( $header ); return false; } } $this->out->addHtml( $header->style( 'opacity', false ) ); $this->out->addWikiMsg( 'translate-fs-userpage-help' ); global $wgLang; $form = new HtmlTag( 'form' ); $items = new TagContainer(); $form->param( 'method', 'post' )->content( $items ); $items[] = new RawHtml( Html::hidden( 'step', 'userpage' ) ); $items[] = new RawHtml( Html::hidden( 'token', $this->user->editToken() ) ); $items[] = new RawHtml( Html::hidden( 'title', $this->getTitle() ) ); $languages = $this->languages( $wgLang->getCode() ); $selector = new XmlSelect(); $selector->addOption( wfMessage( 'translate-fs-selectlanguage' )->text(), '-' ); $selector->addOptions( $languages ); // Building a skill selector $skill = new XmlSelect(); $levels = 'N,5,4,3,2,1'; foreach ( explode( ',', $levels ) as $level ) { $skill->addOption( wfMessage( "translate-fs-userpage-level-$level" )->text(), $level ); } for ( $i = 0; $i < 5; $i++ ) { // Prefill en-2 and [wgLang]-N if [wgLang] != en if ( $i === 0 ) { $skill->setDefault( '2' ); $selector->setDefault( 'en' ); } elseif ( $i === 1 && $wgLang->getCode() !== 'en' ) { $skill->setDefault( 'N' ); $selector->setDefault( $wgLang->getCode() ); } else { $skill->setDefault( false ); $selector->setDefault( false ); } // [skill level selector][language selector] $skill->setAttribute( 'name', "babel-$i-level" ); $selector->setAttribute( 'name', "babel-$i-language" ); $items[] = New RawHtml( $skill->getHtml() . $selector->getHtml() . '<br />' ); } $textarea = new HtmlTag( 'textarea', $preload ); $items[] = $textarea->param( 'rows' , 5 )->id( $textareaId )->param( 'name', $textareaId ); $items[] = new RawHtml( Xml::submitButton( wfMsg( 'translate-fs-userpage-submit' ) ) ); $this->out->addHtml( $form ); return $step_message; }
/** * Insert the captcha prompt into an edit form. * * @param \OutputPage $out */ public function editCallback(&$out) { $out->addWikiText($this->captcha->getMessage($this->action)); $out->addHTML($this->captcha->getForm()); }