'blankpage' => array('code' => 'emptypage', 'info' => "Creating new, empty pages is not allowed"),
'editconflict' => array('code' => 'editconflict', 'info' => "Edit conflict detected"),
'hashcheckfailed' => array('code' => 'badmd5', 'info' => "The supplied MD5 hash was incorrect"),
+ 'missingtext' => array('code' => 'notext', 'info' => "One of the text, appendtext and prependtext parameters must be set"),
);
/**
$params = $this->extractRequestParams();
if(is_null($params['title']))
$this->dieUsageMsg(array('missingparam', 'title'));
- if(is_null($params['text']))
- $this->dieUsageMsg(array('missingparam', 'text'));
+ if(is_null($params['text']) && is_null($params['appendtext']) && is_null($params['prependtext']))
+ $this->dieUsageMsg(array('missingtext'));
if(is_null($params['token']))
$this->dieUsageMsg(array('missingparam', 'token'));
if(!$wgUser->matchEditToken($params['token']))
if(!empty($errors))
$this->dieUsageMsg($errors[0]);
+ $articleObj = new Article($titleObj);
+ if(!is_null($params['appendtext']) || !is_null($params['prependtext']))
+ {
+ $content = $articleObj->getContent();
+ $params['text'] = $params['prependtext'] . $content . $params['appendtext'];
+ }
+
# See if the MD5 hash checks out
if(isset($params['md5']))
if(md5($params['text']) !== $params['md5'])
$this->dieUsageMsg(array('hashcheckfailed'));
- $articleObj = new Article($titleObj);
$ep = new EditPage($articleObj);
-
// EditPage wants to parse its stuff from a WebRequest
// That interface kind of sucks, but it's workable
$reqArr = array('wpTextbox1' => $params['text'],
'watch' => false,
'unwatch' => false,
'md5' => null,
+ 'prependtext' => null,
+ 'appendtext' => null,
);
}
'captchaid' => 'CAPTCHA ID from previous request',
'captchaword' => 'Answer to the CAPTCHA',
'md5' => 'The MD5 hash of the new article text. If set, the edit won\'t be done unless the hash is correct',
+ 'prependtext' => array( 'Add this text to the beginning of the page. Overrides text.',
+ 'Don\'t use together with section: that won\'t do what you expect.'),
+ 'appendtext' => 'Add this text to the end of the page. Overrides text',
);
}