当前位置: 首页>>代码示例>>PHP>>正文


PHP WikiPage::doEditContent方法代码示例

本文整理汇总了PHP中WikiPage::doEditContent方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiPage::doEditContent方法的具体用法?PHP WikiPage::doEditContent怎么用?PHP WikiPage::doEditContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WikiPage的用法示例。


在下文中一共展示了WikiPage::doEditContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDefinitions

 public function getDefinitions()
 {
     $groups = MessageGroups::getAllGroups();
     $keys = array();
     /**
      * @var $g MessageGroup
      */
     foreach ($groups as $g) {
         $states = $g->getMessageGroupStates()->getStates();
         foreach (array_keys($states) as $state) {
             $keys["Translate-workflow-state-{$state}"] = $state;
         }
     }
     $defs = TranslateUtils::getContents(array_keys($keys), $this->getNamespace());
     foreach ($keys as $key => $state) {
         if (!isset($defs[$key])) {
             // @todo Use jobqueue
             $title = Title::makeTitleSafe($this->getNamespace(), $key);
             $page = new WikiPage($title);
             $content = ContentHandler::makeContent($state, $title);
             $page->doEditContent($content, wfMessage('translate-workflow-autocreated-summary', $state)->inContentLanguage()->text(), 0, false, FuzzyBot::getUser());
         } else {
             // Use the wiki translation as definition if available.
             // getContents returns array( content, last author )
             list($content, ) = $defs[$key];
             $keys[$key] = $content;
         }
     }
     return $keys;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:30,代码来源:WorkflowStatesMessageGroup.php

示例2: update

 /**
  * Add or update message contents
  */
 function update($translation, $user)
 {
     $savePage = function ($title, $text) {
         $wikiPage = new WikiPage($title);
         $content = ContentHandler::makeContent($text, $title);
         $result = $wikiPage->doEditContent($content, '/* PR admin */', EDIT_FORCE_BOT);
         return $wikiPage;
     };
     $savePage($this->getTitle(), $translation);
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-Promoter,代码行数:13,代码来源:AdMessage.php

示例3: createPage

 public function createPage(Title $title)
 {
     $page = new \WikiPage($title);
     $pageContent = 'Content of ' . $title->getFullText();
     $editMessage = 'SPL system test: create page';
     if (class_exists('WikitextContent')) {
         $page->doEditContent(new \WikitextContent($pageContent), $editMessage);
     } else {
         $page->doEdit($pageContent, $editMessage);
     }
 }
开发者ID:transonlohk,项目名称:SubPageList,代码行数:11,代码来源:PageCreator.php

示例4: makePage

 /**
  * Helper function for addDBData -- adds a simple page to the database
  *
  * @param string $title Title of page to be created
  * @param string $lang Language and content of the created page
  * @param string|null $content Content of the created page, or null for a generic string
  */
 protected function makePage($title, $lang, $content = null)
 {
     global $wgContLang;
     if ($content === null) {
         $content = $lang;
     }
     if ($lang !== $wgContLang->getCode()) {
         $title = "{$title}/{$lang}";
     }
     $title = Title::newFromText($title, NS_MEDIAWIKI);
     $wikiPage = new WikiPage($title);
     $contentHandler = ContentHandler::makeContent($content, $title);
     $wikiPage->doEditContent($contentHandler, "{$lang} translation test case");
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:21,代码来源:MessageCacheTest.php

示例5: run

 /**
  * Run a pageSchemasCreatePage job
  * @return boolean success
  */
 function run()
 {
     wfProfileIn(__METHOD__);
     if (is_null($this->title)) {
         $this->error = wfMessage('ps-createpage-invalidtitle')->text();
         wfProfileOut(__METHOD__);
         return false;
     }
     if (method_exists('WikiPage', 'getContent')) {
         // MW >= 1.21
         if ($this->title->getContentModel() !== CONTENT_MODEL_WIKITEXT) {
             $this->error = wfMessage('ps-createpage-irregulartext', $this->title->getPrefixedDBkey())->text();
             wfProfileOut(__METHOD__);
             return false;
         }
         $wikiPage = new WikiPage($this->title);
     } else {
         $article = new Article($this->title);
         if (!$article) {
             $this->error = wfMessage('ps-createpage-notfound', $this->title->getPrefixedDBkey())->text();
             wfProfileOut(__METHOD__);
             return false;
         }
     }
     $page_text = $this->params['page_text'];
     // Change global $wgUser variable to the one
     // specified by the job only for the extent of this
     // replacement.
     global $wgUser;
     $actual_user = $wgUser;
     $wgUser = User::newFromId($this->params['user_id']);
     $edit_summary = wfMessage('ps-generatepages-editsummary')->inContentLanguage()->parse();
     if (method_exists('WikiPage', 'getContent')) {
         // MW >= 1.21
         $content = new WikitextContent($page_text);
         $wikiPage->doEditContent($content, $edit_summary);
     } else {
         $article->doEdit($page_text, $edit_summary);
     }
     $wgUser = $actual_user;
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:47,代码来源:PS_CreatePageJob.php

示例6: onUploadVerifyFile

 /**
 	@brief Intercept image uploads and queue them for moderation.
 */
 public static function onUploadVerifyFile($upload, $mime, &$status)
 {
     global $wgRequest, $wgUser, $wgOut;
     if (ModerationCanSkip::canSkip($wgUser)) {
         return;
     }
     $result = $upload->validateName();
     if ($result !== true) {
         $status = array($upload->getVerificationErrorCode($result['status']));
         return;
     }
     $special = new ModerationSpecialUpload($wgRequest);
     $special->publicLoadRequest();
     $title = $upload->getTitle();
     $model = $title->getContentModel();
     try {
         $file = $upload->stashFile($wgUser);
     } catch (MWException $e) {
         $status = array("api-error-stashfailed");
         return;
     }
     $key = $file->getFileKey();
     $pageText = '';
     if (!$special->mForReUpload) {
         $pageText = $special->getInitialPageText($special->mComment, $special->mLicense, $special->mCopyrightStatus, $special->mCopyrightSource);
     }
     $content = ContentHandler::makeContent($pageText, null, $model);
     /* Step 1. Create a page in File namespace (it will be queued for moderation) */
     $page = new WikiPage($title);
     $status = $page->doEditContent($content, $special->mComment, 0, $title->getLatestRevID(), $wgUser);
     $wgOut->redirect('');
     # Disable redirection after doEditContent()
     /*
     	Step 2. Populate mod_stash_key field in newly inserted row
     	of the moderation table (to indicate that this is an upload,
     	not just editing the text on image page)
     */
     $dbw = wfGetDB(DB_MASTER);
     $dbw->update('moderation', array('mod_stash_key' => $key), array('mod_id' => ModerationEditHooks::$LastInsertId), __METHOD__);
     $status = array("moderation-image-queued");
 }
开发者ID:ATCARES,项目名称:mediawiki-moderation,代码行数:44,代码来源:ModerationUploadHooks.php

示例7: deleteUnneededTaskBoxTemplates

 function deleteUnneededTaskBoxTemplates()
 {
     $results = self::getQueryResults("[[Category:Page with Task]]", array('title'), true);
     if ($results->getCount() === 0) {
         return FALSE;
     }
     while ($row = $results->getNext()) {
         $pageTitle = $row[0]->getNextObject();
         $targetTitle = Title::newFromText($pageTitle->getLongWikiText());
         if (!$targetTitle instanceof Title) {
             throw new MWException(wfMessage('tm-error-title'));
         }
         $page = new WikiPage($targetTitle);
         $content = $page->getContent();
         if (strpos($content->getNativeData(), '{{TaskBox}}') !== false) {
             $resultsTasks = self::getQueryResults("[[Category:Task(s)]] [[Entity::" . $pageTitle->getLongWikiText() . "]]", array('title'), true);
             if ($resultsTasks->getCount() === 0) {
                 $newContent = new WikitextContent(str_replace('{{TaskBox}}', '', $content->getNativeData()));
                 $page->doEditContent($newContent, wfMessage('tm-tasbox-removed'), EDIT_MINOR);
             }
         }
     }
     return TRUE;
 }
开发者ID:ATCARES,项目名称:TaskManagement,代码行数:24,代码来源:TaskManagementUtils.php

示例8: internalAttemptSave


//.........这里部分代码省略.........
             }
         }
         if ($this->isConflict) {
             $status->setResult(false, self::AS_CONFLICT_DETECTED);
             return $status;
         }
         if (!$this->runPostMergeFilters($content, $status, $wgUser)) {
             return $status;
         }
         if ($this->section == 'new') {
             // Handle the user preference to force summaries here
             if (!$this->allowBlankSummary && trim($this->summary) == '') {
                 $this->missingSummary = true;
                 $status->fatal('missingsummary');
                 // or 'missingcommentheader' if $section == 'new'. Blegh
                 $status->value = self::AS_SUMMARY_NEEDED;
                 return $status;
             }
             // Do not allow the user to post an empty comment
             if ($this->textbox1 == '') {
                 $this->missingComment = true;
                 $status->fatal('missingcommenttext');
                 $status->value = self::AS_TEXTBOX_EMPTY;
                 return $status;
             }
         } elseif (!$this->allowBlankSummary && !$content->equals($this->getOriginalContent($wgUser)) && !$content->isRedirect() && md5($this->summary) == $this->autoSumm) {
             $this->missingSummary = true;
             $status->fatal('missingsummary');
             $status->value = self::AS_SUMMARY_NEEDED;
             return $status;
         }
         # All's well
         $sectionanchor = '';
         if ($this->section == 'new') {
             $this->summary = $this->newSectionSummary($sectionanchor);
         } elseif ($this->section != '') {
             # Try to get a section anchor from the section source, redirect
             # to edited section if header found.
             # XXX: Might be better to integrate this into Article::replaceSection
             # for duplicate heading checking and maybe parsing.
             $hasmatch = preg_match("/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1, $matches);
             # We can't deal with anchors, includes, html etc in the header for now,
             # headline would need to be parsed to improve this.
             if ($hasmatch && strlen($matches[2]) > 0) {
                 $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText($matches[2]);
             }
         }
         $result['sectionanchor'] = $sectionanchor;
         // Save errors may fall down to the edit form, but we've now
         // merged the section into full text. Clear the section field
         // so that later submission of conflict forms won't try to
         // replace that into a duplicated mess.
         $this->textbox1 = $this->toEditText($content);
         $this->section = '';
         $status->value = self::AS_SUCCESS_UPDATE;
     }
     if (!$this->allowSelfRedirect && $content->isRedirect() && $content->getRedirectTarget()->equals($this->getTitle())) {
         // If the page already redirects to itself, don't warn.
         $currentTarget = $this->getCurrentContent()->getRedirectTarget();
         if (!$currentTarget || !$currentTarget->equals($this->getTitle())) {
             $this->selfRedirect = true;
             $status->fatal('selfredirect');
             $status->value = self::AS_SELF_REDIRECT;
             return $status;
         }
     }
     // Check for length errors again now that the section is merged in
     $this->kblength = (int) (strlen($this->toEditText($content)) / 1024);
     if ($this->kblength > $wgMaxArticleSize) {
         $this->tooBig = true;
         $status->setResult(false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED);
         return $status;
     }
     $flags = EDIT_AUTOSUMMARY | ($new ? EDIT_NEW : EDIT_UPDATE) | ($this->minoredit && !$this->isNew ? EDIT_MINOR : 0) | ($bot ? EDIT_FORCE_BOT : 0);
     $doEditStatus = $this->page->doEditContent($content, $this->summary, $flags, false, $wgUser, $content->getDefaultFormat(), $this->changeTags);
     if (!$doEditStatus->isOK()) {
         // Failure from doEdit()
         // Show the edit conflict page for certain recognized errors from doEdit(),
         // but don't show it for errors from extension hooks
         $errors = $doEditStatus->getErrorsArray();
         if (in_array($errors[0][0], array('edit-gone-missing', 'edit-conflict', 'edit-already-exists'))) {
             $this->isConflict = true;
             // Destroys data doEdit() put in $status->value but who cares
             $doEditStatus->value = self::AS_END;
         }
         return $doEditStatus;
     }
     $result['nullEdit'] = $doEditStatus->hasMessage('edit-no-change');
     if ($result['nullEdit']) {
         // We don't know if it was a null edit until now, so increment here
         $wgUser->pingLimiter('linkpurge');
     }
     $result['redirect'] = $content->isRedirect();
     $this->updateWatchlist();
     // If the content model changed, add a log entry
     if ($changingContentModel) {
         $this->addContentModelChangeLogEntry($wgUser, $oldContentModel, $this->contentModel, $this->summary);
     }
     return $status;
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:101,代码来源:EditPage.php

示例9: createAllPages

 function createAllPages()
 {
     $out = $this->getOutput();
     $req = $this->getRequest();
     $user = $this->getUser();
     $template_name = trim($req->getVal("template_name"));
     $template_multiple = $req->getBool("template_multiple");
     // If this is a multiple-instance template, there
     // shouldn't be a corresponding form or category.
     if ($template_multiple) {
         $form_name = null;
         $category_name = null;
     } else {
         $form_name = trim($req->getVal("form_name"));
         $category_name = trim($req->getVal("category_name"));
     }
     if ($template_name === '' || !$template_multiple && ($form_name === '' || $category_name === '')) {
         $out->addWikiMsg('sf_createclass_missingvalues');
         return;
     }
     $fields = array();
     $jobs = array();
     // Cycle through all the rows passed in.
     for ($i = 1; $req->getVal("field_name_{$i}") != ''; $i++) {
         // Go through the query values, setting the appropriate
         // local variables.
         $field_name = trim($req->getVal("field_name_{$i}"));
         $property_name = trim($req->getVal("property_name_{$i}"));
         $property_type = $req->getVal("property_type_{$i}");
         $allowed_values = $req->getVal("allowed_values_{$i}");
         $is_list = $req->getCheck("is_list_{$i}");
         // Create an SFTemplateField object based on these
         // values, and add it to the $fields array.
         $field = SFTemplateField::create($field_name, $field_name, $property_name, $is_list);
         if (defined('CARGO_VERSION')) {
             $field->setFieldType($property_type);
             // Hopefully it's safe to use a Cargo
             // utility method here.
             $possibleValues = CargoUtils::smartSplit(',', $allowed_values);
             $field->setPossibleValues($possibleValues);
         }
         $fields[] = $field;
         // Create the property, and make a job for it.
         if (defined('SMW_VERSION') && !empty($property_name)) {
             $full_text = SFCreateProperty::createPropertyText($property_type, '', $allowed_values);
             $property_title = Title::makeTitleSafe(SMW_NS_PROPERTY, $property_name);
             $params = array();
             $params['user_id'] = $user->getId();
             $params['page_text'] = $full_text;
             $params['edit_summary'] = wfMessage('sf_createproperty_editsummary', $property_type)->inContentLanguage()->text();
             $jobs[] = new SFCreatePageJob($property_title, $params);
         }
     }
     // Also create the "connecting property", if there is one.
     $connectingProperty = trim($req->getVal('connecting_property'));
     if (defined('SMW_VERSION') && $connectingProperty != '') {
         global $smwgContLang;
         $datatypeLabels = $smwgContLang->getDatatypeLabels();
         $property_type = $datatypeLabels['_wpg'];
         $full_text = SFCreateProperty::createPropertyText($property_type, '', $allowed_values);
         $property_title = Title::makeTitleSafe(SMW_NS_PROPERTY, $connectingProperty);
         $params = array();
         $params['user_id'] = $user->getId();
         $params['page_text'] = $full_text;
         $params['edit_summary'] = wfMessage('sf_createproperty_editsummary', $property_type)->inContentLanguage()->text();
         $jobs[] = new SFCreatePageJob($property_title, $params);
     }
     // Create the template, and save it (might as well save
     // one page, instead of just creating jobs for all of them).
     $template_format = $req->getVal("template_format");
     $sfTemplate = new SFTemplate($template_name, $fields);
     if (defined('CARGO_VERSION')) {
         $sfTemplate->mCargoTable = trim($req->getVal("cargo_table"));
     }
     if (defined('SMW_VERSION') && $template_multiple) {
         $sfTemplate->setConnectingProperty($connectingProperty);
     } else {
         $sfTemplate->setCategoryName($category_name);
     }
     $sfTemplate->setFormat($template_format);
     $full_text = $sfTemplate->createText();
     $template_title = Title::makeTitleSafe(NS_TEMPLATE, $template_name);
     $edit_summary = '';
     if (method_exists('WikiPage', 'doEditContent')) {
         // MW 1.21+
         $template_page = new WikiPage($template_title);
         $content = new WikitextContent($full_text);
         $template_page->doEditContent($content, $edit_summary);
     } else {
         // MW <= 1.20
         $template_article = new Article($template_title);
         $template_article->doEdit($full_text, $edit_summary);
     }
     // Create the form, and make a job for it.
     if ($form_name != '') {
         $form_template = SFTemplateInForm::create($template_name, '', false);
         $form_items = array();
         $form_items[] = array('type' => 'template', 'name' => $form_template->getTemplateName(), 'item' => $form_template);
         $form = SFForm::create($form_name, $form_items);
         $full_text = $form->createMarkup();
//.........这里部分代码省略.........
开发者ID:paladox,项目名称:mediawiki-extensions-SemanticForms,代码行数:101,代码来源:SF_CreateClass.php

示例10: addRevision

 /**
  * Adds a revision to a page, while returning the resuting text's id
  *
  * @param WikiPage $page The page to add the revision to
  * @param string $text The revisions text
  * @param string $summary The revisions summare
  * @return int
  * @throws MWException
  */
 private function addRevision($page, $text, $summary)
 {
     $status = $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle()), $summary);
     if ($status->isGood()) {
         $value = $status->getValue();
         $revision = $value['revision'];
         $id = $revision->getTextId();
         if ($id > 0) {
             return $id;
         }
     }
     throw new MWException("Could not determine text id");
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:22,代码来源:fetchTextTest.php

示例11: run

 /**
  * Run a replaceText job
  * @return boolean success
  */
 function run()
 {
     wfProfileIn(__METHOD__);
     if (is_null($this->title)) {
         $this->error = "replaceText: Invalid title";
         wfProfileOut(__METHOD__);
         return false;
     }
     if (array_key_exists('move_page', $this->params)) {
         global $wgUser;
         $actual_user = $wgUser;
         $wgUser = User::newFromId($this->params['user_id']);
         $cur_page_name = $this->title->getText();
         if ($this->params['use_regex']) {
             $new_page_name = preg_replace("/" . $this->params['target_str'] . "/U", $this->params['replacement_str'], $cur_page_name);
         } else {
             $new_page_name = str_replace($this->params['target_str'], $this->params['replacement_str'], $cur_page_name);
         }
         $new_title = Title::newFromText($new_page_name, $this->title->getNamespace());
         $reason = $this->params['edit_summary'];
         $create_redirect = $this->params['create_redirect'];
         $this->title->moveTo($new_title, true, $reason, $create_redirect);
         if ($this->params['watch_page']) {
             if (class_exists('WatchAction')) {
                 // Class was added in MW 1.19
                 WatchAction::doWatch($new_title, $wgUser);
             } else {
                 Action::factory('watch', new WikiPage($new_title))->execute();
             }
         }
         $wgUser = $actual_user;
     } else {
         // WikiPage::getContent() replaced
         // Article::fetchContent() starting in MW 1.21.
         if (method_exists('WikiPage', 'getContent')) {
             if ($this->title->getContentModel() !== CONTENT_MODEL_WIKITEXT) {
                 $this->error = 'replaceText: Wiki page "' . $this->title->getPrefixedDBkey() . '" does not hold regular wikitext.';
                 wfProfileOut(__METHOD__);
                 return false;
             }
             $wikiPage = new WikiPage($this->title);
             // Is this check necessary?
             if (!$wikiPage) {
                 $this->error = 'replaceText: Wiki page not found for "' . $this->title->getPrefixedDBkey() . '."';
                 wfProfileOut(__METHOD__);
                 return false;
             }
             $article_text = $wikiPage->getContent()->getNativeData();
         } else {
             $article = new Article($this->title, 0);
             if (!$article) {
                 $this->error = 'replaceText: Article not found for "' . $this->title->getPrefixedDBkey() . '"';
                 wfProfileOut(__METHOD__);
                 return false;
             }
             $article_text = $article->fetchContent();
         }
         wfProfileIn(__METHOD__ . '-replace');
         $target_str = $this->params['target_str'];
         $replacement_str = $this->params['replacement_str'];
         // @todo FIXME eh?
         $num_matches;
         if ($this->params['use_regex']) {
             $new_text = preg_replace('/' . $target_str . '/U', $replacement_str, $article_text, -1, $num_matches);
         } else {
             $new_text = str_replace($target_str, $replacement_str, $article_text, $num_matches);
         }
         // If there's at least one replacement, modify the page,
         // using the passed-in edit summary.
         if ($num_matches > 0) {
             // Change global $wgUser variable to the one
             // specified by the job only for the extent of
             // this replacement.
             global $wgUser;
             $actual_user = $wgUser;
             $wgUser = User::newFromId($this->params['user_id']);
             $edit_summary = $this->params['edit_summary'];
             $flags = EDIT_MINOR;
             if ($wgUser->isAllowed('bot')) {
                 $flags |= EDIT_FORCE_BOT;
             }
             if (method_exists('WikiPage', 'getContent')) {
                 $new_content = new WikitextContent($new_text);
                 $wikiPage->doEditContent($new_content, $edit_summary, $flags);
             } else {
                 $article->doEdit($new_text, $edit_summary, $flags);
             }
             $wgUser = $actual_user;
         }
         wfProfileOut(__METHOD__ . '-replace');
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:98,代码来源:ReplaceTextJob.php

示例12: createPage

 protected function createPage($page, $text, $model = null)
 {
     if (is_string($page)) {
         if (!preg_match('/:/', $page) && ($model === null || $model === CONTENT_MODEL_WIKITEXT)) {
             $ns = $this->getDefaultWikitextNS();
             $page = MWNamespace::getCanonicalName($ns) . ':' . $page;
         }
         $page = Title::newFromText($page);
     }
     if ($page instanceof Title) {
         $page = new WikiPage($page);
     }
     if ($page->exists()) {
         $page->doDeleteArticle("done");
     }
     $content = ContentHandler::makeContent($text, $page->getTitle(), $model);
     $page->doEditContent($content, "testing", EDIT_NEW);
     return $page;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:19,代码来源:RevisionStorageTest.php

示例13: getCategorizationChange

 /**
  * @return RecentChange
  */
 private function getCategorizationChange($timestamp, $thisId, $lastId)
 {
     $wikiPage = new WikiPage(Title::newFromText('Testpage'));
     $wikiPage->doEditContent(new WikitextContent('Some random text'), 'page created');
     $wikiPage = new WikiPage(Title::newFromText('Category:Foo'));
     $wikiPage->doEditContent(new WikitextContent('Some random text'), 'category page created');
     $user = $this->getTestUser();
     $recentChange = $this->testRecentChangesHelper->makeCategorizationRecentChange($user, 'Category:Foo', $wikiPage->getId(), $thisId, $lastId, $timestamp);
     return $recentChange;
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:13,代码来源:EnhancedChangesListTest.php

示例14: import

 /**
  * Does the actual edit.
  * @param Title $title
  * @param string $translation
  * @param string $comment Edit summary.
  */
 public function import($title, $translation, $comment)
 {
     $flags = EDIT_FORCE_BOT;
     if ($this->norc) {
         $flags |= EDIT_SUPPRESS_RC;
     }
     $this->reportProgress("Importing {$title->getPrefixedText()}: ", $title);
     $wikipage = new WikiPage($title);
     $content = ContentHandler::makeContent($translation, $title);
     $status = $wikipage->doEditContent($content, $comment, $flags, false, FuzzyBot::getUser());
     $success = $status === true || is_object($status) && $status->isOK();
     $this->reportProgress($success ? 'OK' : 'FAILED', $title);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:19,代码来源:sync-group.php

示例15: approveEditById

 function approveEditById($id)
 {
     $dbw = wfGetDB(DB_MASTER);
     $row = $dbw->selectRow('moderation', array('mod_id AS id', 'mod_timestamp AS timestamp', 'mod_user AS user', 'mod_user_text AS user_text', 'mod_cur_id AS cur_id', 'mod_namespace AS namespace', 'mod_title AS title', 'mod_comment AS comment', 'mod_minor AS minor', 'mod_bot AS bot', 'mod_last_oldid AS last_oldid', 'mod_ip AS ip', 'mod_header_xff AS header_xff', 'mod_header_ua AS header_ua', 'mod_text AS text', 'mod_merged_revid AS merged_revid', 'mod_rejected AS rejected', 'mod_stash_key AS stash_key'), array('mod_id' => $id), __METHOD__);
     if (!$row) {
         throw new ModerationError('moderation-edit-not-found');
     }
     if ($row->merged_revid) {
         throw new ModerationError('moderation-already-merged');
     }
     if ($row->rejected && $row->timestamp < $this->mSpecial->earliestReapprovableTimestamp) {
         throw new ModerationError('moderation-rejected-long-ago');
     }
     # Prepare everything
     $title = Title::makeTitle($row->namespace, $row->title);
     $model = $title->getContentModel();
     $user = $row->user ? User::newFromId($row->user) : User::newFromName($row->user_text, false);
     $flags = EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY;
     if ($row->bot && $user->isAllowed('bot')) {
         $flags |= EDIT_FORCE_BOT;
     }
     if ($row->minor) {
         # doEditContent() checks the right
         $flags |= EDIT_MINOR;
     }
     # For CheckUser extension to work properly, IP, XFF and UA
     # should be set to the correct values for the original user
     # (not from the moderator)
     $cuHook = new ModerationCheckUserHook();
     $cuHook->install($row->ip, $row->header_xff, $row->header_ua);
     $approveHook = new ModerationApproveHook();
     $approveHook->install(array('rev_timestamp' => $dbw->timestamp($row->timestamp), 'rev_user' => $user->getId(), 'rev_user_text' => $user->getName()));
     $status = Status::newGood();
     if ($row->stash_key) {
         # This is the upload from stash.
         $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash($user);
         try {
             $file = $stash->getFile($row->stash_key);
         } catch (MWException $e) {
             throw new ModerationError('moderation-missing-stashed-image');
         }
         $upload = new UploadFromStash($user, $stash);
         $upload->initialize($row->stash_key, $title->getText());
         $status = $upload->performUpload($row->comment, $row->text, 0, $user);
     } else {
         # This is normal edit (not an upload).
         $new_content = ContentHandler::makeContent($row->text, null, $model);
         $page = new WikiPage($title);
         if (!$page->exists()) {
             # New page
             $status = $page->doEditContent($new_content, $row->comment, $flags, false, $user);
         } else {
             # Existing page
             $latest = $page->getLatest();
             if ($latest == $row->last_oldid) {
                 # Page hasn't changed since this edit was queued for moderation.
                 $status = $page->doEditContent($new_content, $row->comment, $flags, $row->last_oldid, $user);
             } else {
                 # Page has changed!
                 # Let's attempt merging, as MediaWiki does in private EditPage::mergeChangesIntoContent().
                 $base_content = $row->last_oldid ? Revision::newFromId($row->last_oldid)->getContent(Revision::RAW) : ContentHandler::makeContent('', null, $model);
                 $latest_content = Revision::newFromId($latest)->getContent(Revision::RAW);
                 $handler = ContentHandler::getForModelID($base_content->getModel());
                 $merged_content = $handler->merge3($base_content, $new_content, $latest_content);
                 if ($merged_content) {
                     $status = $page->doEditContent($merged_content, $row->comment, $flags, $latest, $user);
                 } else {
                     $dbw = wfGetDB(DB_MASTER);
                     $dbw->update('moderation', array('mod_conflict' => 1), array('mod_id' => $id), __METHOD__);
                     $dbw->commit(__METHOD__);
                     throw new ModerationError('moderation-edit-conflict');
                 }
             }
         }
     }
     $approveHook->deinstall();
     $cuHook->deinstall();
     if (!$status->isGood()) {
         throw new ModerationError($status->getMessage());
     }
     $logEntry = new ManualLogEntry('moderation', 'approve');
     $logEntry->setPerformer($this->moderator);
     $logEntry->setTarget($title);
     $logEntry->setParameters(array('revid' => $approveHook->lastRevId));
     $logid = $logEntry->insert();
     $logEntry->publish($logid);
     # Approved edits are removed from "moderation" table,
     # because they already exist in page history, recentchanges etc.
     $dbw = wfGetDB(DB_MASTER);
     $dbw->delete('moderation', array('mod_id' => $id), __METHOD__);
 }
开发者ID:ATCARES,项目名称:mediawiki-moderation,代码行数:91,代码来源:ModerationActionApprove.php


注:本文中的WikiPage::doEditContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。