本文整理汇总了PHP中Article::doEdit方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::doEdit方法的具体用法?PHP Article::doEdit怎么用?PHP Article::doEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::doEdit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: efSharedHelpArticleCreation
/**
* @param WikiPage $article
* @param $user
* @param $text
* @param $summary
* @param $minoredit
* @param $watchthis
* @param $sectionanchor
* @param $flags
* @param $revision
* @param Status $status
* @param $baseRevId
* @return bool
*/
function efSharedHelpArticleCreation(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId)
{
global $wgCityId, $wgHelpWikiId;
// only run on help wikis
if ($wgCityId !== $wgHelpWikiId) {
return true;
}
// not likely if we got here, but... healthy paranoia ;)
if (wfReadOnly()) {
return true;
}
if ($article->mTitle->getNamespace() !== NS_HELP) {
return true;
}
if (!$status->isOK()) {
return true;
}
if (!($flags & EDIT_NEW)) {
return true;
}
$talkTitle = Title::newFromText($article->mTitle->getText(), NS_HELP_TALK);
if ($talkTitle->exists()) {
return true;
}
$talkArticle = new Article($talkTitle);
$redir = $article->getRedirectTarget();
if ($redir) {
$target = $redir->getTalkNsText() . ':' . $redir->getText();
$talkArticle->doEdit("#REDIRECT [[{$target}]]", wfMsgForContent('sharedhelp-autotalkcreate-summary'));
} else {
$talkArticle->doEdit('{{talkheader}}', wfMsgForContent('sharedhelp-autotalkcreate-summary'));
}
return true;
}
示例2: addPage
/**
*
* Add/update a page to wiki
* @param string $pagename
* @param string $text
* @param boolean $hasSemanticInternal whether this text contains semanticInternal Object.
* SemanticInternal Object needs some special handling. First there is a bug in current
* SemanticInternal Object implemenattion: the semantic internal properties can not be
* saved in the very first time. Second, if the semantic internal object saving is not from
* a special page action, but a regular page saving action, the semantic internal object
* is confused about the "CURRENT" page. So asynchronous saving through a task is needed.
*
* @param $summary
*/
public static function addPage($pagename, $text, $force = true, $astask = false, $hasSemanticInternal = false, $summary = "Auto generation")
{
global $wgUser;
$title = str_replace(' ', '_', $pagename);
$t = Title::makeTitleSafe(NS_MAIN, $title);
$article = new Article($t);
if ($article->exists() && !$force) {
return false;
}
if (!$astask) {
$e = $article->exists();
//do adding inline
$article->doEdit($text, $summary);
if ($hasSemanticInternal && !$e) {
//one more time
$article->doEdit($text, $summary);
}
return true;
} else {
//add article asynchronously.
$jobs = array();
$job_params = array();
$job_params['user_id'] = $wgUser->getId();
$job_params['edit_summary'] = $summary;
$job_params['text'] = $text;
$jobs[] = new DTImportJob($t, $job_params);
if ($hasSemanticInternal && !$article->exists()) {
$jobs[] = new DTImportJob($t, $job_params);
}
Job::batchInsert($jobs);
}
}
示例3: execute
/**
* Show the special page
*
* @param $par Mixed: parameter passed to the page or null
*/
public function execute($par)
{
global $wgOut, $wgUser, $wgRequest;
// Set page title and other stuff
$this->setHeaders();
# Show a message if the database is in read-only mode
if (wfReadOnly()) {
$wgOut->readOnlyPage();
return;
}
# If user is blocked, s/he doesn't need to access this page
if ($wgUser->isBlocked()) {
throw new UserBlockedError($this->getUser()->mBlock);
}
$title = $wgRequest->getVal('wpTitle');
$category = $wgRequest->getVal('wpCategory');
if (empty($title) || empty($category)) {
return;
}
$oTitle = Title::newFromText($title);
if (!is_object($oTitle)) {
return;
}
$oArticle = new Article($oTitle);
if ($oTitle->exists()) {
$text = $oArticle->getContent();
} else {
$text = self::getCreateplate($category);
}
$text .= "\n[[Category:" . $category . ']]';
$oArticle->doEdit($text, wfMsgForContent('createincategory-comment', $category));
$wgOut->redirect($oTitle->getFullUrl());
}
示例4: run
/**
* Run a pageSchemasCreatePage job
* @return boolean success
*/
function run() {
wfProfileIn( __METHOD__ );
if ( is_null( $this->title ) ) {
$this->error = "pageSchemasCreatePage: Invalid title";
wfProfileOut( __METHOD__ );
return false;
}
$article = new Article( $this->title );
if ( !$article ) {
$this->error = 'pageSchemasCreatePage: Article not found "' . $this->title->getPrefixedDBkey() . '"';
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 = wfMsgForContent( 'ps-generatepages-editsummary' );
$article->doEdit( $page_text, $edit_summary );
$wgUser = $actual_user;
wfProfileOut( __METHOD__ );
return true;
}
示例5: run
/**
* Run a dtImport job
* @return boolean success
*/
function run()
{
wfProfileIn(__METHOD__);
if (is_null($this->title)) {
$this->error = "dtImport: Invalid title";
wfProfileOut(__METHOD__);
return false;
}
$article = new Article($this->title);
if (!$article) {
$this->error = 'dtImport: Article not found "' . $this->title->getPrefixedDBkey() . '"';
wfProfileOut(__METHOD__);
return false;
}
$for_pages_that_exist = $this->params['for_pages_that_exist'];
if ($for_pages_that_exist == 'skip' && $this->title->exists()) {
return true;
}
// change global $wgUser variable to the one specified by
// the job only for the extent of this import
global $wgUser;
$actual_user = $wgUser;
$wgUser = User::newFromId($this->params['user_id']);
$text = $this->params['text'];
if ($for_pages_that_exist == 'append' && $this->title->exists()) {
$text = $article->getContent() . "\n" . $text;
}
$edit_summary = $this->params['edit_summary'];
$article->doEdit($text, $edit_summary);
$wgUser = $actual_user;
wfProfileOut(__METHOD__);
return true;
}
示例6: createPost
function createPost($info, $subject, $super = null)
{
$userName = $info['user'];
if (strpos($userName, '#') !== false) {
$pos = strpos($userName, '#');
$userName = substr($userName, 0, $pos);
}
$user = User::newFromName($userName, false);
if (!$user) {
throw new MWException("Username " . $info['user'] . " is invalid.");
}
global $article;
if ($super) {
$title = Threads::newReplyTitle($super, $user);
} else {
$title = Threads::newThreadTitle($subject, $article);
}
print "Creating thread {$title} as a subthread of " . ($super ? $super->title() : 'none') . "\n";
$root = new Article($title);
$root->doEdit($info['content'], 'Imported from JSON', EDIT_NEW, false, $user);
$t = LqtView::postEditUpdates($super ? 'reply' : 'new', $super, $root, $article, $subject, 'Imported from JSON', null);
$t = Threads::withId($t->id());
// Some weirdness.
return $t;
}
示例7: execute
function execute()
{
global $wgRequest, $wgOut, $wgUser, $wgArticle;
$sitting_of = $wgRequest->getVal('sitting_of');
$session_number = $wgRequest->getVal('session_number');
$sitting_start_date_time = $wgRequest->getVal('sitting_start_date_and_time');
$sitting_end_date_time = $wgRequest->getVal('sitting_end_date_and_time');
$sitting_session_number = $wgRequest->getVal('sitting_session_number');
$wpEditToken = $wgRequest->getVal('wpEditToken');
$sitting_desc = $wgRequest->getVal('sitting_desc');
$sitting_start_date = substr($sitting_start_date_time, 0, strpos($sitting_start_date_time, ' '));
$sitting_start_time = substr($sitting_start_date_time, strpos($sitting_start_date_time, ' ') + 1);
$sitting_end_date = substr($sitting_end_date_time, 0, strpos($sitting_end_date_time, ' '));
$sitting_end_time = substr($sitting_end_date_time, strpos($sitting_end_date_time, ' ') + 1);
$sitting_name = $sitting_of . '-' . $sitting_start_date;
//$sitting_of.'-'.$sitting_start_date_time.'-'
$title = Title::newFromText($sitting_name, MV_NS_SITTING);
$wgArticle = new Article($title);
$wgArticle->doEdit($sitting_desc, wfMsg('mv_summary_add_sitting'));
$dbkey = $title->getDBKey();
$sitting = new MV_Sitting(array('name' => $dbkey, 'start_date' => $sitting_start_date, 'start_time' => $sitting_start_time, 'end_date' => $sitting_end_date, 'end_time' => $sitting_end_time));
//$sitting->db_load_sitting();
//$sitting->db_load_streams();
if ($sitting->insertSitting()) {
if ($wgArticle->exists()) {
$wgOut->redirect($title->getLocalURL("action=staff"));
} else {
$html .= 'Article ' . $sitting_name . ' does not exist';
$wgOut->addHtml($html);
}
} else {
$WgOut->addHTML('Error: Duplicate Sitting Name?');
}
}
示例8: adminPostTalkMessage
public static function adminPostTalkMessage($to_user, $from_user, $comment)
{
global $wgLang;
$existing_talk = '';
//make sure we have everything we need...
if (empty($to_user) || empty($from_user) || empty($comment)) {
return false;
}
$from = $from_user->getName();
if (!$from) {
return false;
}
//whoops
$from_realname = $from_user->getRealName();
$dateStr = $wgLang->date(wfTimestampNow());
$formattedComment = wfMsg('postcomment_formatted_comment', $dateStr, $from, $from_realname, $comment);
$talkPage = $to_user->getUserPage()->getTalkPage();
if ($talkPage->getArticleId() > 0) {
$r = Revision::newFromTitle($talkPage);
$existing_talk = $r->getText() . "\n\n";
}
$text = $existing_talk . $formattedComment . "\n\n";
$flags = EDIT_FORCE_BOT | EDIT_SUPPRESS_RC;
$article = new Article($talkPage);
$result = $article->doEdit($text, "", $flags);
return $result;
}
示例9: edit
/**
* A naive wrapper for \WikiPage::doEdit().
*/
public function edit()
{
$responseData = new \StdClass();
$responseData->success = false;
$responseData->title = null;
$responseData->text = null;
$responseData->summary = null;
$responseData->user_id = 0;
$responseData->user_name = null;
$this->response->setFormat('json');
$this->response->setCacheValidity(\WikiaResponse::CACHE_DISABLED);
if ($this->getVal('secret') != $this->wg->TheSchwartzSecretToken || !$this->request->wasPosted()) {
$this->response->setVal('data', $responseData);
return;
}
$titleText = $this->getVal('title');
$responseData->title = $titleText;
$title = \Title::newFromText($titleText);
\Wikia\Util\Assert::true($title instanceof \Title);
$article = new \Article($title);
\Wikia\Util\Assert::true($article instanceof \Article);
$text = $this->getVal('text');
$responseData->text = $text;
$summary = $this->getVal('summary');
$responseData->summary = $summary;
if ($this->wg->User->isLoggedIn()) {
$responseData->user_id = $this->wg->User->getId();
$responseData->user_name = $this->wg->User->getName();
$responseData->success = $article->doEdit($text, $summary)->isOK();
}
$this->response->setVal('data', $responseData);
}
示例10: create
/**
* Create category.
*
* @param $category String: Name of category to create.
* @param $code String: Code of language that the category is for.
* @param $level String: Level that the category is for.
*/
public static function create($category, $code, $level = null)
{
$category = strip_tags($category);
$title = Title::makeTitleSafe(NS_CATEGORY, $category);
if ($title === null || $title->exists()) {
return;
}
global $wgLanguageCode;
$language = BabelLanguageCodes::getName($code, $wgLanguageCode);
if ($level === null) {
$text = wfMsgForContent('babel-autocreate-text-main', $language, $code);
} else {
$text = wfMsgForContent('babel-autocreate-text-levels', $level, $language, $code);
}
$user = self::user();
# Do not add a message if the username is invalid or if the account that adds it, is blocked
if (!$user || $user->isBlocked()) {
return;
}
if (!$title->quickUserCan('create', $user)) {
return;
# The Babel AutoCreate account is not allowed to create the page
}
/* $article->doEdit will call $wgParser->parse.
* Calling Parser::parse recursively is baaaadd... (bug 29245)
* @todo FIXME: surely there is a better way?
*/
global $wgParser, $wgParserConf;
$oldParser = $wgParser;
$parserClass = $wgParserConf['class'];
$wgParser = new $parserClass($wgParserConf);
$article = new Article($title, 0);
$article->doEdit($text, wfMsgForContent('babel-autocreate-reason', wfMsgForContent('babel-url')), EDIT_FORCE_BOT, false, $user);
$wgParser = $oldParser;
}
示例11: run
/**
* Run a createPage job
* @return boolean success
*/
function run()
{
if (is_null($this->title)) {
$this->error = "createPage: Invalid title";
return false;
}
$article = new Article($this->title, 0);
if (!$article) {
$this->error = 'createPage: Article not found "' . $this->title->getPrefixedDBkey() . '"';
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 = '';
if (array_key_exists('edit_summary', $this->params)) {
$edit_summary = $this->params['edit_summary'];
}
$article->doEdit($page_text, $edit_summary);
$wgUser = $actual_user;
return true;
}
示例12: create
/**
* Create a new poll
* @param wgRequest question
* @param wgRequest answer (expects PHP array style in the form <input name=answer[]>)
* Page Content should be of a different style so we have to translate
* *question 1\n
* *question 2\n
*/
public static function create()
{
wfProfileIn(__METHOD__);
$app = F::app();
$title = $app->wg->Request->getVal('question');
$answers = $app->wg->Request->getArray('answer');
// array
$title_object = Title::newFromText($title, NS_WIKIA_POLL);
if (is_object($title_object) && $title_object->exists()) {
$res = array('success' => false, 'error' => $app->renderView('Error', 'Index', array(wfMsg('wikiapoll-error-duplicate'))));
} else {
if ($title_object == null) {
$res = array('success' => false, 'error' => $app->renderView('Error', 'Index', array(wfMsg('wikiapoll-error-invalid-title'))));
} else {
$content = "";
foreach ($answers as $answer) {
$content .= "*{$answer}\n";
}
/* @var $article WikiPage */
$article = new Article($title_object, NS_WIKIA_POLL);
$article->doEdit($content, 'Poll Created', EDIT_NEW, false, $app->wg->User);
$title_object = $article->getTitle();
// fixme: check status object
$res = array('success' => true, 'pollId' => $article->getID(), 'url' => $title_object->getLocalUrl(), 'question' => $title_object->getPrefixedText());
}
}
wfProfileOut(__METHOD__);
return $res;
}
示例13: run
/**
* Run a refreshLinks job
* @return boolean success
*/
function run()
{
global $wgTitle, $wgUser, $wgLang, $wrGedcomExportDirectory;
$wgTitle = $this->title;
// FakeTitle (the default) generates errors when accessed, and sometimes I log wgTitle, so set it to something else
$wgUser = User::newFromName('WeRelate agent');
// set the user
$treeId = $this->params['tree_id'];
$treeName = $this->params['name'];
$treeUser = $this->params['user'];
$filename = "{$wrGedcomExportDirectory}/{$treeId}.ged";
$ge = new GedcomExporter();
$error = $ge->exportGedcom($treeId, $filename);
if ($error) {
$this->error = $error;
return false;
}
// leave a message for the tree requester
$userTalkTitle = Title::newFromText($treeUser, NS_USER_TALK);
$article = new Article($userTalkTitle, 0);
if ($article->getID() != 0) {
$text = $article->getContent();
} else {
$text = '';
}
$title = Title::makeTitle(NS_SPECIAL, 'Trees');
$msg = wfMsg('GedcomExportReady', $wgLang->date(wfTimestampNow(), true, false), $treeName, $title->getFullURL(wfArrayToCGI(array('action' => 'downloadExport', 'user' => $treeUser, 'name' => $treeName))));
$text .= "\n\n" . $msg;
$success = $article->doEdit($text, 'GEDCOM export ready');
if (!$success) {
$this->error = 'Unable to edit user talk page: ' . $treeUser;
return false;
}
return true;
}
示例14: onUnknownAction
public static function onUnknownAction($action, $article)
{
global $wgOut, $wgRequest, $wgUser, $wgParser, $wgBlikiPostGroup;
if ($action == 'blog' && in_array($wgBlikiPostGroup, $wgUser->getEffectiveGroups())) {
$newtitle = $wgRequest->getText('newtitle');
$title = Title::newFromText($newtitle);
$error = false;
if (!is_object($title)) {
$wgOut->addWikitext('<div class="previewnote">Error: Bad title!</div>');
$error = true;
} elseif ($title->exists()) {
$wgOut->addWikitext('<div class="previewnote">Error: Title already exists!</div>');
$error = true;
}
if (!$error) {
$summary = $wgRequest->getText('summary');
$content = $wgRequest->getText('content');
$user = $wgUser->getName();
$date = date('U');
$sig = '<div class="blog-sig">{{BlogSig|' . "{$user}|@{$date}" . '}}</div>';
$type = $wgRequest->getText('type');
switch ($type) {
// Preview the item
case "Full preview":
$wikitext = "{$sig}\n{$summary}\n\n{$content}";
self::preview($type, $title, $wikitext);
$article->view();
break;
// Preview the item in news/blog format
// Preview the item in news/blog format
case "Summary preview":
$wikitext = "{|class=\"blog\"\n|\n== [[Post a blog item|{$newtitle}]] ==\n|-\n!{$sig}\n|-\n|{$summary}\n|}__NOEDITSECTION__";
$title = Title::newFromText('Blog');
self::preview($type, $title, $wikitext);
$article->view();
break;
// Create the item with tags as category links
// Create the item with tags as category links
case "Post":
$wikitext = '{{' . "Blog|1={$summary}|2={$content}" . '}}';
$wikitext .= "<noinclude>[[Category:Blog items]][[Category:Posts by {$user}]]";
foreach (array_keys($_POST) as $k) {
if (preg_match("|^tag(.+)\$|", $k, $m)) {
$wikitext .= '[[Category:' . str_replace('_', ' ', $m[1]) . ']]';
}
}
$wikitext .= "</noinclude>";
$article = new Article($title);
$article->doEdit($wikitext, 'Blog item created via post form', EDIT_NEW);
$wgOut->redirect($title->getFullURL());
break;
}
} else {
$article->view();
}
return false;
}
return true;
}
示例15: execute
function execute()
{
global $reportersTable, $wgOut, $wgRequest;
$nameKey = 'mpnamencgsblahbladggfdsafh';
$tit = Title::newFromText($nameKey, MV_NS_MVD);
$art = new Article($tit);
$art->doEdit($_REQUEST['smw_Spoken_By'], '', EDIT_NEW);
}