public function execute() { $user = $this->getUser(); $params = $this->extractRequestParams(); $page = Title::newFromText($params['page']); if (!$page) { $this->dieUsageMsg('invalidtitle', $params['page']); } $availableNamespaces = $this->veConfig->get('VisualEditorAvailableNamespaces'); if (!isset($availableNamespaces[$page->getNamespace()]) || !$availableNamespaces[$page->getNamespace()]) { $this->dieUsage("VisualEditor is not enabled in namespace " . $page->getNamespace(), 'novenamespace'); } $parserParams = array(); if (isset($params['oldid'])) { $parserParams['oldid'] = $params['oldid']; } $html = $params['html']; if (substr($html, 0, 11) === 'rawdeflate,') { $html = gzinflate(base64_decode(substr($html, 11))); } if ($params['cachekey'] !== null) { $wikitext = $this->trySerializationCache($params['cachekey']); if (!is_string($wikitext)) { $this->dieUsage('No cached serialization found with that key', 'badcachekey'); } } else { $wikitext = $this->postHTML($page, $html, $parserParams, $params['etag']); if ($wikitext === false) { $this->dieUsage('Error contacting the Parsoid/RESTbase server', 'docserver'); } } $saveresult = $this->saveWikitext($page, $wikitext, $params); $editStatus = $saveresult['edit']['result']; // Error if ($editStatus !== 'Success') { $result = array('result' => 'error', 'edit' => $saveresult['edit']); if (isset($saveresult['edit']['spamblacklist'])) { $matches = explode('|', $saveresult['edit']['spamblacklist']); $matcheslist = $this->getLanguage()->listToText($matches); $result['edit']['sberrorparsed'] = $this->msg('spamprotectiontext')->parse() . ' ' . $this->msg('spamprotectionmatch', $matcheslist)->parse(); } // Success } else { if (isset($saveresult['edit']['newrevid'])) { $newRevId = intval($saveresult['edit']['newrevid']); if ($this->veConfig->get('VisualEditorUseChangeTagging')) { // Defer till after the RC row is inserted // @TODO: doEditContent should let callers specify desired tags DeferredUpdates::addCallableUpdate(function () use($newRevId) { ChangeTags::addTags('visualeditor', null, $newRevId, null); }); } } else { $newRevId = $page->getLatestRevId(); } // Return result of parseWikitext instead of saveWikitext so that the // frontend can update the page rendering without a refresh. $result = $this->parseWikitext($page, $newRevId); if ($result === false) { $this->dieUsage('Error contacting the Parsoid/RESTBase server', 'docserver'); } $result['isRedirect'] = $page->isRedirect(); if (class_exists('FlaggablePageView')) { $view = FlaggablePageView::singleton(); // Defeat !$this->isPageView( $request ) || $request->getVal( 'oldid' ) check in setPageContent $view->getContext()->setRequest(new DerivativeRequest($this->getRequest(), array('diff' => null, 'oldid' => '', 'action' => 'view') + $this->getRequest()->getValues())); // The two parameters here are references but we don't care // about what FlaggedRevs does with them. $outputDone = null; $useParserCache = null; $view->setPageContent($outputDone, $useParserCache); $view->displayTag(); } $result['contentSub'] = $this->getOutput()->getSubtitle(); $lang = $this->getLanguage(); if (isset($saveresult['edit']['newtimestamp'])) { $ts = $saveresult['edit']['newtimestamp']; $result['lastModified'] = array('date' => $lang->userDate($ts, $user), 'time' => $lang->userTime($ts, $user)); } if (isset($saveresult['edit']['newrevid'])) { $result['newrevid'] = intval($saveresult['edit']['newrevid']); } $result['result'] = 'success'; } $this->getResult()->addValue(null, $this->getModuleName(), $result); }
public function clear() { self::$instance = null; }
public static function addReviewCheck($editPage, &$checkboxes, &$tabindex) { $view = FlaggablePageView::singleton(); $view->addReviewCheck($editPage, $checkboxes, $tabindex); return true; }