本文整理汇总了PHP中wfReadOnlyReason函数的典型用法代码示例。如果您正苦于以下问题:PHP wfReadOnlyReason函数的具体用法?PHP wfReadOnlyReason怎么用?PHP wfReadOnlyReason使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfReadOnlyReason函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConstruction
public function testConstruction()
{
$e = new ReadOnlyError();
$this->assertEquals('readonly', $e->title);
$this->assertEquals('readonlytext', $e->msg);
$this->assertEquals(wfReadOnlyReason() ?: array(), $e->params);
}
示例2: __construct
function __construct(Article $article)
{
// Set instance variables.
$this->mArticle = $article;
$this->mTitle = $article->getTitle();
$this->mApplicableTypes = $this->mTitle->getRestrictionTypes();
$this->mContext = $article->getContext();
// Check if the form should be disabled.
// If it is, the form will be available in read-only to show levels.
$this->mPermErrors = $this->mTitle->getUserPermissionsErrors('protect', $this->mContext->getUser(), $this->mContext->getRequest()->wasPosted() ? 'secure' : 'full');
if (wfReadOnly()) {
$this->mPermErrors[] = ['readonlytext', wfReadOnlyReason()];
}
$this->disabled = $this->mPermErrors != [];
$this->disabledAttrib = $this->disabled ? ['disabled' => 'disabled'] : [];
$this->loadData();
}
示例3: __construct
function __construct(Page $article)
{
global $wgUser;
// Set instance variables.
$this->mArticle = $article;
$this->mTitle = $article->getTitle();
$this->mApplicableTypes = $this->mTitle->getRestrictionTypes();
// Check if the form should be disabled.
// If it is, the form will be available in read-only to show levels.
$this->mPermErrors = $this->mTitle->getUserPermissionsErrors('protect', $wgUser);
if (wfReadOnly()) {
$this->mPermErrors[] = array('readonlytext', wfReadOnlyReason());
}
$this->disabled = $this->mPermErrors != array();
$this->disabledAttrib = $this->disabled ? array('disabled' => 'disabled') : array();
$this->loadData();
}
示例4: databases
/**
* Get status of database clusters
*
* Returns:
* - clusters: associative array of cluster statuses
* cluster name is the key and one of "ok", "warning", "critical" as a value
* - messages: list of notices
* - errors: list of errors
*/
public function databases()
{
$cluster = $this->getVal('cluster');
$clusters = $this->getAllClusters();
if ($cluster) {
$clusters = array_intersect([$cluster], $clusters);
}
$this->clusters = $clusters;
$this->testClusters();
$this->setVal('clusters', $this->status);
if ($this->errors) {
$this->setVal('errors', $this->errors);
}
if ($this->messages) {
$this->setVal('messages', $this->messages);
}
$this->setVal('readWrite', ['status' => !wfReadOnly(), 'reason' => wfReadOnlyReason()]);
}
示例5: formHTML
/**
* This function is the real heart of the entire Semantic Forms
* extension. It handles two main actions: (1) displaying a form on the
* screen, given a form definition and possibly page contents (if an
* existing page is being edited); and (2) creating actual page
* contents, if the form was already submitted by the user.
*
* It also does some related tasks, like figuring out the page name (if
* only a page formula exists).
*/
function formHTML($form_def, $form_submitted, $source_is_page, $form_id = null, $existing_page_content = null, $page_name = null, $page_name_formula = null, $is_query = false, $is_embedded = false)
{
global $wgRequest, $wgUser, $wgParser;
global $sfgTabIndex;
// used to represent the current tab index in the form
global $sfgFieldNum;
// used for setting various HTML IDs
// initialize some variables
$wiki_page = new SFWikiPage();
$sfgTabIndex = 1;
$sfgFieldNum = 1;
$source_page_matches_this_form = false;
$form_page_title = null;
$generated_page_name = $page_name_formula;
// $form_is_partial is true if:
// (a) 'partial' == 1 in the arguments
// (b) 'partial form' is found in the form definition
// in the latter case, it may remain false until close to the end of
// the parsing, so we have to assume that it will become a possibility
$form_is_partial = false;
$new_text = "";
// If we have existing content and we're not in an active replacement
// situation, preserve the original content. We do this because we want
// to pass the original content on IF this is a partial form.
// TODO: A better approach here would be to pass the revision ID of the
// existing page content through the replace value, which would
// minimize the html traffic and would allow us to do a concurrent
// update check. For now, we pass it through a hidden text field.
if (!$wgRequest->getCheck('partial')) {
$original_page_content = $existing_page_content;
} else {
$original_page_content = null;
if ($wgRequest->getCheck('sf_free_text')) {
if (!isset($existing_page_content) || $existing_page_content == '') {
$existing_page_content = $wgRequest->getVal('sf_free_text');
}
$form_is_partial = true;
}
}
// Disable all form elements if user doesn't have edit
// permission - two different checks are needed, because
// editing permissions can be set in different ways.
// HACK - sometimes we don't know the page name in advance, but
// we still need to set a title here for testing permissions.
if ($is_embedded) {
// If this is an embedded form (probably a 'RunQuery'),
// just use the name of the actual page we're on.
global $wgTitle;
$this->mPageTitle = $wgTitle;
} elseif ($is_query) {
// We're in Special:RunQuery - just use that as the
// title.
global $wgTitle;
$this->mPageTitle = $wgTitle;
} elseif ($page_name === '' || $page_name === null) {
$this->mPageTitle = Title::newFromText($wgRequest->getVal('namespace') . ":Semantic Forms permissions test");
} else {
$this->mPageTitle = Title::newFromText($page_name);
}
global $wgOut;
// Show previous set of deletions for this page, if it's been
// deleted before.
if (!$form_submitted && ($this->mPageTitle && !$this->mPageTitle->exists() && is_null($page_name_formula))) {
$this->showDeletionLog($wgOut);
}
// Unfortunately, we can't just call userCan() here because,
// since MW 1.16, it has a bug in which it ignores a setting of
// "$wgEmailConfirmToEdit = true;". Instead, we'll just get the
// permission errors from the start, and use those to determine
// whether the page is editable.
if (!$is_query) {
// $userCanEditPage = ( $wgUser->isAllowed( 'edit' ) && $this->mPageTitle->userCan( 'edit' ) );
$permissionErrors = $this->mPageTitle->getUserPermissionsErrors('edit', $wgUser);
// The handling of $wgReadOnly and $wgReadOnlyFile
// has to be done separately.
if (wfReadOnly()) {
$permissionErrors = array(array('readonlytext', array(wfReadOnlyReason())));
}
$userCanEditPage = count($permissionErrors) == 0;
Hooks::run('sfUserCanEditPage', array($this->mPageTitle, &$userCanEditPage));
}
$form_text = "";
if ($is_query || $userCanEditPage) {
$form_is_disabled = false;
// Show "Your IP address will be recorded" warning if
// user is anonymous, and it's not a query.
if ($wgUser->isAnon() && !$is_query) {
// Based on code in MediaWiki's EditPage.php.
$anonEditWarning = wfMessage('anoneditwarning', '{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}', '{{fullurl:Special:UserLogin/signup|returnto={{FULLPAGENAMEE}}}}')->parse();
$form_text .= Html::rawElement('div', array('id' => 'mw-anon-edit-warning', 'class' => 'warningbox'), $anonEditWarning);
//.........这里部分代码省略.........
示例6: appendGeneralInfo
protected function appendGeneralInfo($property)
{
global $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion;
$data = array();
$mainPage = Title::newMainPage();
$data['mainpage'] = $mainPage->getPrefixedText();
$data['base'] = wfExpandUrl($mainPage->getFullURL(), PROTO_CURRENT);
$data['sitename'] = $GLOBALS['wgSitename'];
// wgLogo can either be a relative or an absolute path
// make sure we always return an absolute path
$data['logo'] = wfExpandUrl($GLOBALS['wgLogo'], PROTO_RELATIVE);
$data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}";
$data['phpversion'] = phpversion();
$data['phpsapi'] = PHP_SAPI;
$data['dbtype'] = $GLOBALS['wgDBtype'];
$data['dbversion'] = $this->getDB()->getServerVersion();
$allowFrom = array('');
$allowException = true;
if (!$GLOBALS['wgAllowExternalImages']) {
if ($GLOBALS['wgEnableImageWhitelist']) {
$data['imagewhitelistenabled'] = '';
}
$allowFrom = $GLOBALS['wgAllowExternalImagesFrom'];
$allowException = !empty($allowFrom);
}
if ($allowException) {
$data['externalimages'] = (array) $allowFrom;
$this->getResult()->setIndexedTagName($data['externalimages'], 'prefix');
}
if (!$wgDisableLangConversion) {
$data['langconversion'] = '';
}
if (!$wgDisableTitleConversion) {
$data['titleconversion'] = '';
}
if ($wgContLang->linkPrefixExtension()) {
$linkPrefixCharset = $wgContLang->linkPrefixCharset();
$data['linkprefixcharset'] = $linkPrefixCharset;
// For backwards compatability
$data['linkprefix'] = "/^((?>.*[^{$linkPrefixCharset}]|))(.+)\$/sDu";
} else {
$data['linkprefixcharset'] = '';
$data['linkprefix'] = '';
}
$linktrail = $wgContLang->linkTrail();
if ($linktrail) {
$data['linktrail'] = $linktrail;
} else {
$data['linktrail'] = '';
}
$git = SpecialVersion::getGitHeadSha1($GLOBALS['IP']);
if ($git) {
$data['git-hash'] = $git;
} else {
$svn = SpecialVersion::getSvnRevision($GLOBALS['IP']);
if ($svn) {
$data['rev'] = $svn;
}
}
// 'case-insensitive' option is reserved for future
$data['case'] = $GLOBALS['wgCapitalLinks'] ? 'first-letter' : 'case-sensitive';
$data['lang'] = $GLOBALS['wgLanguageCode'];
$fallbacks = array();
foreach ($wgContLang->getFallbackLanguages() as $code) {
$fallbacks[] = array('code' => $code);
}
$data['fallback'] = $fallbacks;
$this->getResult()->setIndexedTagName($data['fallback'], 'lang');
if ($wgContLang->hasVariants()) {
$variants = array();
foreach ($wgContLang->getVariants() as $code) {
$variants[] = array('code' => $code, 'name' => $wgContLang->getVariantname($code));
}
$data['variants'] = $variants;
$this->getResult()->setIndexedTagName($data['variants'], 'lang');
}
if ($wgContLang->isRTL()) {
$data['rtl'] = '';
}
$data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding();
if (wfReadOnly()) {
$data['readonly'] = '';
$data['readonlyreason'] = wfReadOnlyReason();
}
if ($GLOBALS['wgEnableWriteAPI']) {
$data['writeapi'] = '';
}
$tz = $GLOBALS['wgLocaltimezone'];
$offset = $GLOBALS['wgLocalTZoffset'];
if (is_null($tz)) {
$tz = 'UTC';
$offset = 0;
} elseif (is_null($offset)) {
$offset = 0;
}
$data['timezone'] = $tz;
$data['timeoffset'] = intval($offset);
$data['articlepath'] = $GLOBALS['wgArticlePath'];
$data['scriptpath'] = $GLOBALS['wgScriptPath'];
$data['script'] = $GLOBALS['wgScript'];
//.........这里部分代码省略.........
示例7: sendMessage
//.........这里部分代码省略.........
}
$formData['wikiCreationDateOne'] = wfTimestamp(TS_DB, $timestamp);
if ($formData['wikiCreationDateOption'] === 'between') {
if ($formData['wikiCreationDateTwo'] !== '') {
$timestamp = wfTimestamp(TS_UNIX, $formData['wikiCreationDateTwo']);
if (!$timestamp) {
$validDateTime = false;
}
$formData['wikiCreationDateTwo'] = wfTimestamp(TS_DB, $timestamp);
} else {
$validDateTime = false;
}
}
}
if ($mSendModeUsers === 'REGISTRATION') {
$timestamp = wfTimestamp(TS_UNIX, $formData['registrationDateOne']);
if (!$timestamp) {
$validDateTime = false;
}
$formData['registrationDateOne'] = wfTimestamp(TS_MW, $timestamp);
if ($formData['registrationDateOption'] === 'between') {
if ($formData['registrationDateTwo'] !== '') {
$timestamp = wfTimestamp(TS_UNIX, $formData['registrationDateTwo']);
if (!$timestamp) {
$validDateTime = false;
}
$formData['registrationDateTwo'] = wfTimestamp(TS_MW, $timestamp);
} else {
$validDateTime = false;
}
}
}
if (wfReadOnly()) {
$reason = wfReadOnlyReason();
$result['errMsg'] = wfMsg('readonlytext', $reason);
} elseif ($mText == '') {
$result['errMsg'] = wfMsg('swm-error-empty-message');
} elseif (mb_strlen($mText) > 500) {
$result['errMsg'] = wfMsg('swm-error-long-message');
} elseif ($mSendModeWikis == 'WIKI' && is_null($mWikiId)) {
//this wiki doesn't exist
$result['errMsg'] = wfMsg('swm-error-no-such-wiki');
} elseif ($mSendModeUsers == 'WIKIS' && empty($formData['listWikiNames'])) {
$result['errMsg'] = wfMsg('swm-error-no-wiki-list');
} elseif ($mSendModeUsers == 'USER' && !User::idFromName($mRecipientName)) {
$result['errMsg'] = wfMsg('swm-error-no-such-user');
} elseif ($mSendModeUsers == 'USERS' && empty($formData['listUserNames'])) {
$result['errMsg'] = wfMsg('swm-error-no-user-list');
} elseif (!$validDateTime) {
$result['errMsg'] = wfMsg('swm-error-invalid-time');
} elseif ($mSendModeUsers === 'REGISTRATION' && $formData['registrationDateOption'] === 'between' && $formData['registrationDateTwo'] <= $formData['registrationDateOne']) {
$result['errMsg'] = wfMsg('swm-error-registered-tobeforefrom');
} elseif ($mSendModeWikis === 'CREATED' && $formData['wikiCreationDateOption'] === 'between' && $formData['wikiCreationDateTwo'] <= $formData['wikiCreationDateOne']) {
$result['errMsg'] = wfMsg('swm-error-created-tobeforefrom');
} elseif ($mSendModeUsers === 'EDITCOUNT' && (!is_numeric($formData['editCountOne']) || $formData['editCountOption'] === 'between' && !is_numeric($formData['editCountTwo']))) {
$result['errMsg'] = wfMsg('swm-error-editcount-notnumber');
} elseif ($mSendModeUsers === 'EDITCOUNT' && $formData['editCountOption'] === 'between' && $formData['editCountTwo'] <= $formData['editCountOne']) {
$result['errMsg'] = wfMsg('swm-error-editcount-tolessthanfrom');
} else {
global $wgParser, $wgUser;
$title = Title::newFromText(uniqid('tmp'));
$options = ParserOptions::newFromUser($wgUser);
//Parse some wiki markup [eg. ~~~~]
$mText = $wgParser->preSaveTransform($mText, $title, $wgUser, $options);
$DB = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB);
$dbResult = (bool) $DB->Query('INSERT INTO ' . MSG_TEXT_DB . ' (msg_sender_id, msg_text, msg_mode, msg_expire, msg_recipient_name, msg_group_name, msg_wiki_name, msg_hub_id, msg_lang, msg_cluster_id)' . ' VALUES (' . $DB->AddQuotes($mSender->GetID()) . ', ' . $DB->AddQuotes($mText) . ', ' . ($sendToAll ? MSG_MODE_ALL : MSG_MODE_SELECTED) . ', ' . $DB->AddQuotes($mExpire) . ', ' . $DB->AddQuotes($mRecipientName) . ', ' . $DB->AddQuotes($mGroupName) . ', ' . $DB->AddQuotes($mWikiName) . ', ' . $DB->AddQuotes($mHubId) . ' , ' . $DB->AddQuotes($mLang) . ' , ' . $DB->AddQuotes($mClusterId) . ');', __METHOD__);
示例8: dieReadOnly
/**
* Helper function for readonly errors
*/
public function dieReadOnly()
{
$parsed = $this->parseMsg(array('readonlytext'));
$this->dieUsage($parsed['info'], $parsed['code'], 0, array('readonlyreason' => wfReadOnlyReason()));
}
示例9: appendGeneralInfo
protected function appendGeneralInfo($property)
{
global $wgContLang;
$data = array();
$mainPage = Title::newMainPage();
$data['mainpage'] = $mainPage->getPrefixedText();
$data['base'] = wfExpandUrl($mainPage->getFullUrl(), PROTO_CURRENT);
$data['sitename'] = $GLOBALS['wgSitename'];
$data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}";
$data['phpversion'] = phpversion();
$data['phpsapi'] = php_sapi_name();
$data['dbtype'] = $GLOBALS['wgDBtype'];
$data['dbversion'] = $this->getDB()->getServerVersion();
$svn = SpecialVersion::getSvnRevision($GLOBALS['IP']);
if ($svn) {
$data['rev'] = $svn;
}
// 'case-insensitive' option is reserved for future
$data['case'] = $GLOBALS['wgCapitalLinks'] ? 'first-letter' : 'case-sensitive';
if (isset($GLOBALS['wgRightsCode'])) {
$data['rightscode'] = $GLOBALS['wgRightsCode'];
}
$data['rights'] = $GLOBALS['wgRightsText'];
$data['lang'] = $GLOBALS['wgLanguageCode'];
$fallbacks = array();
foreach ($wgContLang->getFallbackLanguages() as $code) {
$fallbacks[] = array('code' => $code);
}
$data['fallback'] = $fallbacks;
$this->getResult()->setIndexedTagName($data['fallback'], 'lang');
if ($wgContLang->isRTL()) {
$data['rtl'] = '';
}
$data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding();
if (wfReadOnly()) {
$data['readonly'] = '';
$data['readonlyreason'] = wfReadOnlyReason();
}
if ($GLOBALS['wgEnableWriteAPI']) {
$data['writeapi'] = '';
}
$tz = $GLOBALS['wgLocaltimezone'];
$offset = $GLOBALS['wgLocalTZoffset'];
if (is_null($tz)) {
$tz = 'UTC';
$offset = 0;
} elseif (is_null($offset)) {
$offset = 0;
}
$data['timezone'] = $tz;
$data['timeoffset'] = intval($offset);
$data['articlepath'] = $GLOBALS['wgArticlePath'];
$data['scriptpath'] = $GLOBALS['wgScriptPath'];
$data['script'] = $GLOBALS['wgScript'];
$data['variantarticlepath'] = $GLOBALS['wgVariantArticlePath'];
$data['server'] = $GLOBALS['wgServer'];
$data['wikiid'] = wfWikiID();
$data['time'] = wfTimestamp(TS_ISO_8601, time());
if ($GLOBALS['wgMiserMode']) {
$data['misermode'] = '';
}
wfRunHooks('APIQuerySiteInfoGeneralInfo', array($this, &$data));
return $this->getResult()->addValue('query', $property, $data);
}
示例10: doUpdateRestrictions
/**
* Update the article's restriction field, and leave a log entry.
* This works for protection both existing and non-existing pages.
*
* @param array $limit Set of restriction keys
* @param array $expiry Per restriction type expiration
* @param int &$cascade Set to false if cascading protection isn't allowed.
* @param string $reason
* @param User $user The user updating the restrictions
* @param string|string[] $tags Change tags to add to the pages and protection log entries
* ($user should be able to add the specified tags before this is called)
* @return Status Status object; if action is taken, $status->value is the log_id of the
* protection log entry.
*/
public function doUpdateRestrictions(array $limit, array $expiry, &$cascade, $reason, User $user, $tags = null)
{
global $wgCascadingRestrictionLevels, $wgContLang;
if (wfReadOnly()) {
return Status::newFatal('readonlytext', wfReadOnlyReason());
}
$this->loadPageData('fromdbmaster');
$restrictionTypes = $this->mTitle->getRestrictionTypes();
$id = $this->getId();
if (!$cascade) {
$cascade = false;
}
// Take this opportunity to purge out expired restrictions
Title::purgeExpiredRestrictions();
// @todo FIXME: Same limitations as described in ProtectionForm.php (line 37);
// we expect a single selection, but the schema allows otherwise.
$isProtected = false;
$protect = false;
$changed = false;
$dbw = wfGetDB(DB_MASTER);
foreach ($restrictionTypes as $action) {
if (!isset($expiry[$action]) || $expiry[$action] === $dbw->getInfinity()) {
$expiry[$action] = 'infinity';
}
if (!isset($limit[$action])) {
$limit[$action] = '';
} elseif ($limit[$action] != '') {
$protect = true;
}
// Get current restrictions on $action
$current = implode('', $this->mTitle->getRestrictions($action));
if ($current != '') {
$isProtected = true;
}
if ($limit[$action] != $current) {
$changed = true;
} elseif ($limit[$action] != '') {
// Only check expiry change if the action is actually being
// protected, since expiry does nothing on an not-protected
// action.
if ($this->mTitle->getRestrictionExpiry($action) != $expiry[$action]) {
$changed = true;
}
}
}
if (!$changed && $protect && $this->mTitle->areRestrictionsCascading() != $cascade) {
$changed = true;
}
// If nothing has changed, do nothing
if (!$changed) {
return Status::newGood();
}
if (!$protect) {
// No protection at all means unprotection
$revCommentMsg = 'unprotectedarticle';
$logAction = 'unprotect';
} elseif ($isProtected) {
$revCommentMsg = 'modifiedarticleprotection';
$logAction = 'modify';
} else {
$revCommentMsg = 'protectedarticle';
$logAction = 'protect';
}
// Truncate for whole multibyte characters
$reason = $wgContLang->truncate($reason, 255);
$logRelationsValues = [];
$logRelationsField = null;
$logParamsDetails = [];
// Null revision (used for change tag insertion)
$nullRevision = null;
if ($id) {
// Protection of existing page
if (!Hooks::run('ArticleProtect', [&$this, &$user, $limit, $reason])) {
return Status::newGood();
}
// Only certain restrictions can cascade...
$editrestriction = isset($limit['edit']) ? [$limit['edit']] : $this->mTitle->getRestrictions('edit');
foreach (array_keys($editrestriction, 'sysop') as $key) {
$editrestriction[$key] = 'editprotected';
// backwards compatibility
}
foreach (array_keys($editrestriction, 'autoconfirmed') as $key) {
$editrestriction[$key] = 'editsemiprotected';
// backwards compatibility
}
$cascadingRestrictionLevels = $wgCascadingRestrictionLevels;
//.........这里部分代码省略.........
示例11: showEditForm
/**
* Replace entire showEditForm, need to add our own textbox and stuff
*/
function showEditForm($formCallback = null)
{
global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle, $wgRequest;
# If $wgTitle is null, that means we're in API mode.
# Some hook probably called this function without checking
# for is_null($wgTitle) first. Bail out right here so we don't
# do lots of work just to discard it right after.
if (is_null($wgTitle)) {
return;
}
$fname = 'EditPage::showEditForm';
wfProfileIn($fname);
$sk = $wgUser->getSkin();
wfRunHooks('EditPage::showEditForm:initial', array(&$this));
#need to parse the preview early so that we know which templates are used,
#otherwise users with "show preview after edit box" will get a blank list
#we parse this near the beginning so that setHeaders can do the title
#setting work instead of leaving it in getPreviewText
$previewOutput = '';
if ($this->formtype == 'preview') {
$previewOutput = $this->getPreviewText();
}
$this->setHeaders();
# Enabled article-related sidebar, toplinks, etc.
$wgOut->setArticleRelated(true);
if ($this->isConflict) {
$wgOut->wrapWikiMsg("<div class='mw-explainconflict'>\n\$1</div>", 'explainconflict');
$this->textbox2 = $this->textbox1;
$this->textbox1 = $this->getContent();
$this->edittime = $this->mArticle->getTimestamp();
# MeanEditor: too complicated for visual editing
$this->noVisualEditor = false;
} else {
if ($this->section != '' && $this->section != 'new') {
$matches = array();
if (!$this->summary && !$this->preview && !$this->diff) {
preg_match("/^(=+)(.+)\\1/mi", $this->textbox1, $matches);
if (!empty($matches[2])) {
global $wgParser;
$this->summary = "/* " . $wgParser->stripSectionName(trim($matches[2])) . " */ ";
}
}
}
if ($this->missingComment) {
$wgOut->wrapWikiMsg('<div id="mw-missingcommenttext">$1</div>', 'missingcommenttext');
}
if ($this->missingSummary && $this->section != 'new') {
$wgOut->wrapWikiMsg('<div id="mw-missingsummary">$1</div>', 'missingsummary');
}
if ($this->missingSummary && $this->section == 'new') {
$wgOut->wrapWikiMsg('<div id="mw-missingcommentheader">$1</div>', 'missingcommentheader');
}
if ($this->hookError !== '') {
$wgOut->addWikiText($this->hookError);
}
if (!$this->checkUnicodeCompliantBrowser()) {
$wgOut->addWikiMsg('nonunicodebrowser');
}
if (isset($this->mArticle) && isset($this->mArticle->mRevision)) {
// Let sysop know that this will make private content public if saved
if (!$this->mArticle->mRevision->userCan(Revision::DELETED_TEXT)) {
$wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-permission');
} else {
if ($this->mArticle->mRevision->isDeleted(Revision::DELETED_TEXT)) {
$wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-view');
}
}
if (!$this->mArticle->mRevision->isCurrent()) {
$this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId());
$wgOut->addWikiMsg('editingold');
}
}
}
if (wfReadOnly()) {
$wgOut->wrapWikiMsg("<div id=\"mw-read-only-warning\">\n\$1\n</div>", array('readonlywarning', wfReadOnlyReason()));
# MeanEditor: visual editing makes no sense here
$this->noVisualEditor = true;
} elseif ($wgUser->isAnon() && $this->formtype != 'preview') {
$wgOut->wrapWikiMsg('<div id="mw-anon-edit-warning">$1</div>', 'anoneditwarning');
} else {
if ($this->isCssJsSubpage) {
# Check the skin exists
if ($this->isValidCssJsSubpage) {
if ($this->formtype !== 'preview') {
$wgOut->addWikiMsg('usercssjsyoucanpreview');
}
} else {
$wgOut->addWikiMsg('userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage());
}
}
}
$classes = array();
// Textarea CSS
if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
} elseif ($this->mTitle->isProtected('edit')) {
# Is the title semi-protected?
if ($this->mTitle->isSemiProtected()) {
//.........这里部分代码省略.........
示例12: showHeader
protected function showHeader()
{
global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
if ($this->mTitle->isTalkPage()) {
$wgOut->addWikiMsg('talkpagetext');
}
# Optional notices on a per-namespace and per-page basis
$editnotice_ns = 'editnotice-' . $this->mTitle->getNamespace();
$editnotice_ns_message = wfMessage($editnotice_ns)->inContentLanguage();
if ($editnotice_ns_message->exists()) {
$wgOut->addWikiText($editnotice_ns_message->plain());
}
if (MWNamespace::hasSubpages($this->mTitle->getNamespace())) {
$parts = explode('/', $this->mTitle->getDBkey());
$editnotice_base = $editnotice_ns;
while (count($parts) > 0) {
$editnotice_base .= '-' . array_shift($parts);
$editnotice_base_msg = wfMessage($editnotice_base)->inContentLanguage();
if ($editnotice_base_msg->exists()) {
$wgOut->addWikiText($editnotice_base_msg->plain());
}
}
} else {
# Even if there are no subpages in namespace, we still don't want / in MW ns.
$editnoticeText = $editnotice_ns . '-' . str_replace('/', '-', $this->mTitle->getDBkey());
$editnoticeMsg = wfMessage($editnoticeText)->inContentLanguage();
if ($editnoticeMsg->exists()) {
$wgOut->addWikiText($editnoticeMsg->plain());
}
}
if ($this->isConflict) {
$wgOut->wrapWikiMsg("<div class='mw-explainconflict'>\n\$1\n</div>", 'explainconflict');
$this->edittime = $this->mArticle->getTimestamp();
} else {
if ($this->section != '' && !$this->isSectionEditSupported()) {
// We use $this->section to much before this and getVal('wgSection') directly in other places
// at this point we can't reset $this->section to '' to fallback to non-section editing.
// Someone is welcome to try refactoring though
$wgOut->showErrorPage('sectioneditnotsupported-title', 'sectioneditnotsupported-text');
return false;
}
if ($this->section != '' && $this->section != 'new') {
if (!$this->summary && !$this->preview && !$this->diff) {
$sectionTitle = self::extractSectionTitle($this->textbox1);
if ($sectionTitle !== false) {
$this->summary = "/* {$sectionTitle} */ ";
}
}
}
if ($this->missingComment) {
$wgOut->wrapWikiMsg("<div id='mw-missingcommenttext'>\n\$1\n</div>", 'missingcommenttext');
}
if ($this->missingSummary && $this->section != 'new') {
$wgOut->wrapWikiMsg("<div id='mw-missingsummary'>\n\$1\n</div>", 'missingsummary');
}
if ($this->missingSummary && $this->section == 'new') {
$wgOut->wrapWikiMsg("<div id='mw-missingcommentheader'>\n\$1\n</div>", 'missingcommentheader');
}
if ($this->hookError !== '') {
$wgOut->addWikiText($this->hookError);
}
if (!$this->checkUnicodeCompliantBrowser()) {
$wgOut->addWikiMsg('nonunicodebrowser');
}
if ($this->section != 'new') {
$revision = $this->mArticle->getRevisionFetched();
if ($revision) {
// Let sysop know that this will make private content public if saved
if (!$revision->userCan(Revision::DELETED_TEXT)) {
$wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1\n</div>\n", 'rev-deleted-text-permission');
} elseif ($revision->isDeleted(Revision::DELETED_TEXT)) {
$wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1\n</div>\n", 'rev-deleted-text-view');
}
if (!$revision->isCurrent()) {
$this->mArticle->setOldSubtitle($revision->getId());
$wgOut->addWikiMsg('editingold');
}
} elseif ($this->mTitle->exists()) {
// Something went wrong
$wgOut->wrapWikiMsg("<div class='errorbox'>\n\$1\n</div>\n", array('missing-article', $this->mTitle->getPrefixedText(), wfMsgNoTrans('missingarticle-rev', $this->oldid)));
}
}
}
if (wfReadOnly()) {
$wgOut->wrapWikiMsg("<div id=\"mw-read-only-warning\">\n\$1\n</div>", array('readonlywarning', wfReadOnlyReason()));
} elseif ($wgUser->isAnon()) {
if ($this->formtype != 'preview') {
$wgOut->wrapWikiMsg("<div id=\"mw-anon-edit-warning\">\n\$1</div>", 'anoneditwarning');
} else {
$wgOut->wrapWikiMsg("<div id=\"mw-anon-preview-warning\">\n\$1</div>", 'anonpreviewwarning');
}
} else {
if ($this->isCssJsSubpage) {
# Check the skin exists
if ($this->isWrongCaseCssJsPage) {
$wgOut->wrapWikiMsg("<div class='error' id='mw-userinvalidcssjstitle'>\n\$1\n</div>", array('userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage()));
}
if ($this->getTitle()->isSubpageOf($wgUser->getUserPage())) {
if ($this->formtype !== 'preview') {
if ($this->isCssSubpage) {
//.........这里部分代码省略.........
示例13: processEditErrors
/**
* Translates an EditPage error code into a corresponding message ID
* @param $error The error code
* @return String
*/
public static function processEditErrors($error)
{
switch ($error) {
case EditPage::AS_SUCCESS_NEW_ARTICLE:
case EditPage::AS_SUCCESS_UPDATE:
return null;
case EditPage::AS_SPAM_ERROR:
return 'spamprotectiontext';
case EditPage::AS_BLOCKED_PAGE_FOR_USER:
return 'blockedtitle';
case EditPage::AS_IMAGE_REDIRECT_ANON:
return 'uploadnologin';
case EditPage::AS_READ_ONLY_PAGE_ANON:
return 'loginreqtitle';
case EditPage::AS_READ_ONLY_PAGE_LOGGED:
case EditPage::AS_READ_ONLY_PAGE:
return array('readonlytext', array(wfReadOnlyReason()));
case EditPage::AS_RATE_LIMITED:
return 'actionthrottledtext';
case EditPage::AS_NO_CREATE_PERMISSION:
return 'nocreatetext';
case EditPage::AS_BLANK_ARTICLE:
return 'autoedit-blankpage';
case EditPage::AS_IMAGE_REDIRECT_LOGGED:
return 'badaccess';
case EditPage::AS_HOOK_ERROR_EXPECTED:
case EditPage::AS_HOOK_ERROR:
return 'sf_formedit_hookerror';
case EditPage::AS_CONFLICT_DETECTED:
return 'editconflict';
case EditPage::AS_CONTENT_TOO_BIG:
case EditPage::AS_ARTICLE_WAS_DELETED:
case EditPage::AS_SUMMARY_NEEDED:
case EditPage::AS_TEXTBOX_EMPTY:
case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
case EditPage::AS_END:
case EditPage::AS_FILTERING:
default:
return array('internalerror_text', array($error));
}
}
示例14: showHeader
protected function showHeader()
{
global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
if ($this->isConflict) {
$wgOut->wrapWikiMsg("<div class='mw-explainconflict'>\n\$1\n</div>", 'explainconflict');
$this->edittime = $this->mArticle->getTimestamp();
} else {
if ($this->section != '' && !$this->isSectionEditSupported()) {
// We use $this->section to much before this and getVal('wgSection') directly in other places
// at this point we can't reset $this->section to '' to fallback to non-section editing.
// Someone is welcome to try refactoring though
$wgOut->showErrorPage('sectioneditnotsupported-title', 'sectioneditnotsupported-text');
return false;
}
if ($this->section != '' && $this->section != 'new') {
$matches = array();
if (!$this->summary && !$this->preview && !$this->diff) {
preg_match("/^(=+)(.+)\\1/mi", $this->textbox1, $matches);
if (!empty($matches[2])) {
global $wgParser;
$this->summary = "/* " . $wgParser->stripSectionName(trim($matches[2])) . " */ ";
}
}
}
if ($this->missingComment) {
$wgOut->wrapWikiMsg("<div id='mw-missingcommenttext'>\n\$1\n</div>", 'missingcommenttext');
}
if ($this->missingSummary && $this->section != 'new') {
$wgOut->wrapWikiMsg("<div id='mw-missingsummary'>\n\$1\n</div>", 'missingsummary');
}
if ($this->missingSummary && $this->section == 'new') {
$wgOut->wrapWikiMsg("<div id='mw-missingcommentheader'>\n\$1\n</div>", 'missingcommentheader');
}
if ($this->hookError !== '') {
$wgOut->addWikiText($this->hookError);
}
if (!$this->checkUnicodeCompliantBrowser()) {
$wgOut->addWikiMsg('nonunicodebrowser');
}
if (isset($this->mArticle) && isset($this->mArticle->mRevision)) {
// Let sysop know that this will make private content public if saved
if (!$this->mArticle->mRevision->userCan(Revision::DELETED_TEXT)) {
$wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1\n</div>\n", 'rev-deleted-text-permission');
} elseif ($this->mArticle->mRevision->isDeleted(Revision::DELETED_TEXT)) {
$wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1\n</div>\n", 'rev-deleted-text-view');
}
if (!$this->mArticle->mRevision->isCurrent()) {
$this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId());
$wgOut->addWikiMsg('editingold');
}
}
}
if (wfReadOnly()) {
$wgOut->wrapWikiMsg("<div id=\"mw-read-only-warning\">\n\$1\n</div>", array('readonlywarning', wfReadOnlyReason()));
} elseif ($wgUser->isAnon()) {
if ($this->formtype != 'preview') {
$wgOut->wrapWikiMsg("<div id=\"mw-anon-edit-warning\">\n\$1</div>", 'anoneditwarning');
} else {
$wgOut->wrapWikiMsg("<div id=\"mw-anon-preview-warning\">\n\$1</div>", 'anonpreviewwarning');
}
} else {
if ($this->isCssJsSubpage) {
# Check the skin exists
if ($this->isWrongCaseCssJsPage) {
$wgOut->wrapWikiMsg("<div class='error' id='mw-userinvalidcssjstitle'>\n\$1\n</div>", array('userinvalidcssjstitle', $this->getContextTitle()->getSkinFromCssJsSubpage()));
}
if ($this->formtype !== 'preview') {
if ($this->isCssSubpage) {
$wgOut->wrapWikiMsg("<div id='mw-usercssyoucanpreview'>\n\$1\n</div>", array('usercssyoucanpreview'));
}
if ($this->isJsSubpage) {
$wgOut->wrapWikiMsg("<div id='mw-userjsyoucanpreview'>\n\$1\n</div>", array('userjsyoucanpreview'));
}
}
}
}
if ($this->mTitle->getNamespace() != NS_MEDIAWIKI && $this->mTitle->isProtected('edit')) {
# Is the title semi-protected?
if ($this->mTitle->isSemiProtected()) {
$noticeMsg = 'semiprotectedpagewarning';
} else {
# Then it must be protected based on static groups (regular)
$noticeMsg = 'protectedpagewarning';
}
LogEventsList::showLogExtract($wgOut, 'protect', $this->mTitle->getPrefixedText(), '', array('lim' => 1, 'msgKey' => array($noticeMsg)));
}
if ($this->mTitle->isCascadeProtected()) {
# Is this page under cascading protection from some source pages?
list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
$notice = "<div class='mw-cascadeprotectedwarning'>\n\$1\n";
$cascadeSourcesCount = count($cascadeSources);
if ($cascadeSourcesCount > 0) {
# Explain, and list the titles responsible
foreach ($cascadeSources as $page) {
$notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
}
}
$notice .= '</div>';
$wgOut->wrapWikiMsg($notice, array('cascadeprotectedwarning', $cascadeSourcesCount));
}
//.........这里部分代码省略.........
示例15: doAction
/**
* Depending on the requested action this method will try to store/preview
* the data in mOptions or retrieve the edit form.
*
* The form and target page will be available in mOptions after execution of
* the method.
*
* Errors and warnings are logged in the API result under the 'errors' key.
* The general request status is maintained in mStatus.
*
* @global $wgRequest
* @global $wgOut
* @global SFFormPrinter $sfgFormPrinter
* @throws MWException
*/
public function doAction()
{
global $wgOut, $wgParser, $wgRequest, $sfgFormPrinter;
// if the wiki is read-only, do not save
if (wfReadOnly()) {
if ($this->mAction === self::ACTION_SAVE) {
throw new MWException(wfMessage('sf_autoedit_readonly', wfReadOnlyReason())->parse());
}
// even if not saving notify client anyway. Might want to dislay a notice
$this->logMessage(wfMessage('sf_autoedit_readonly', wfReadOnlyReason())->parse(), self::NOTICE);
}
// find the title of the form to be used
$formTitle = $this->getFormTitle();
// get the form content
$formContent = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $this->getTextForPage($formTitle));
// signals that the form was submitted
// always true, else we would not be here
$isFormSubmitted = $this->mAction === self::ACTION_SAVE || $this->mAction === self::ACTION_PREVIEW || $this->mAction === self::ACTION_DIFF;
// the article id of the form to be used
$formArticleId = $formTitle->getArticleID();
// the name of the target page; might be empty when using the one-step-process
$targetName = $this->mOptions['target'];
// if the target page was not specified, try finding the page name formula
// (Why is this not done in SFFormPrinter::formHTML?)
if ($targetName === '') {
// Parse the form to see if it has a 'page name' value set.
if (preg_match('/{{{\\s*info.*page name\\s*=\\s*(.*)}}}/msU', $formContent, $matches)) {
$pageNameElements = SFUtils::getFormTagComponents(trim($matches[1]));
$targetNameFormula = $pageNameElements[0];
} else {
throw new MWException(wfMessage('sf_autoedit_notargetspecified')->parse());
}
$targetTitle = null;
} else {
$targetNameFormula = null;
$targetTitle = Title::newFromText($targetName);
}
$preloadContent = '';
// save $wgRequest for later restoration
$oldRequest = $wgRequest;
$pageExists = false;
// preload data if not explicitly excluded and if the preload page exists
if (!isset($this->mOptions['preload']) || $this->mOptions['preload'] !== false) {
if (isset($this->mOptions['preload']) && is_string($this->mOptions['preload'])) {
$preloadTitle = Title::newFromText($this->mOptions['preload']);
} else {
$preloadTitle = Title::newFromText($targetName);
}
if ($preloadTitle !== null && $preloadTitle->exists()) {
// the content of the page that was specified to be used for preloading
$preloadContent = $this->getTextForPage($preloadTitle);
$pageExists = true;
} else {
if (isset($this->mOptions['preload'])) {
$this->logMessage(wfMessage('sf_autoedit_invalidpreloadspecified', $this->mOptions['preload'])->parse(), self::WARNING);
}
}
}
// Allow extensions to set/change the preload text, for new
// pages.
if (!$pageExists) {
Hooks::run('sfEditFormPreloadText', array(&$preloadContent, $targetTitle, $formTitle));
}
// Flag to keep track of formHTML() runs.
$formHtmlHasRun = false;
if ($preloadContent !== '') {
// @HACK - we need to set this for the preload to take
// effect in the form.
$pageExists = true;
// Spoof $wgRequest for SFFormPrinter::formHTML().
if (isset($_SESSION)) {
$wgRequest = new FauxRequest($this->mOptions, true, $_SESSION);
} else {
$wgRequest = new FauxRequest($this->mOptions, true);
}
// Call SFFormPrinter::formHTML() to get at the form
// HTML of the existing page.
list($formHTML, $formJS, $targetContent, $form_page_title, $generatedTargetNameFormula) = $sfgFormPrinter->formHTML($formContent, $isFormSubmitted, $pageExists, $formArticleId, $preloadContent, $targetName, $targetNameFormula);
// Parse the data to be preloaded from the form HTML of
// the existing page.
$data = $this->parseDataFromHTMLFrag($formHTML);
// ...and merge/overwrite it with the new data.
$this->mOptions = SFUtils::array_merge_recursive_distinct($data, $this->mOptions);
}
// We already preloaded stuff for saving/previewing -
//.........这里部分代码省略.........