本文整理汇总了PHP中wfEscapeWikiText函数的典型用法代码示例。如果您正苦于以下问题:PHP wfEscapeWikiText函数的具体用法?PHP wfEscapeWikiText怎么用?PHP wfEscapeWikiText使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfEscapeWikiText函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($par)
{
$this->checkPermissions();
$this->checkReadOnly();
list($this->target, $this->type) = SpecialBlock::getTargetAndType($par, $this->getRequest());
$this->block = Block::newFromTarget($this->target);
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
$out->setPageTitle($this->msg('unblockip'));
$out->addModules('mediawiki.special');
$form = new HTMLForm($this->getFields(), $this->getContext());
$form->setWrapperLegendMsg('unblockip');
$form->setSubmitCallback(array(__CLASS__, 'processUIUnblock'));
$form->setSubmitTextMsg('ipusubmit');
$form->addPreText($this->msg('unblockiptext')->parseAsBlock());
if ($form->show()) {
switch ($this->type) {
case Block::TYPE_USER:
case Block::TYPE_IP:
$out->addWikiMsg('unblocked', wfEscapeWikiText($this->target));
break;
case Block::TYPE_RANGE:
$out->addWikiMsg('unblocked-range', wfEscapeWikiText($this->target));
break;
case Block::TYPE_ID:
case Block::TYPE_AUTO:
$out->addWikiMsg('unblocked-id', wfEscapeWikiText($this->target));
break;
}
}
}
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:32,代码来源:SpecialUnblock.php
示例2: __construct
function __construct(IContextSource $context, $userName = null, $search = '', $including = false, $showAll = false)
{
$this->setContext($context);
$this->mIncluding = $including;
$this->mShowAll = $showAll;
if ($userName !== null && $userName !== '') {
$nt = Title::newFromText($userName, NS_USER);
$user = User::newFromName($userName, false);
if (!is_null($nt)) {
$this->mUserName = $nt->getText();
}
if (!$user || $user->isAnon() && !User::isIP($user->getName())) {
$this->getOutput()->wrapWikiMsg("<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>", array('listfiles-userdoesnotexist', wfEscapeWikiText($userName)));
}
}
if ($search !== '' && !$this->getConfig()->get('MiserMode')) {
$this->mSearch = $search;
$nt = Title::newFromURL($this->mSearch);
if ($nt) {
$dbr = wfGetDB(DB_SLAVE);
$this->mQueryConds[] = 'LOWER(img_name)' . $dbr->buildLike($dbr->anyString(), strtolower($nt->getDBkey()), $dbr->anyString());
}
}
if (!$including) {
if ($this->getRequest()->getText('sort', 'img_date') == 'img_date') {
$this->mDefaultDirection = IndexPager::DIR_DESCENDING;
} else {
$this->mDefaultDirection = IndexPager::DIR_ASCENDING;
}
} else {
$this->mDefaultDirection = IndexPager::DIR_DESCENDING;
}
parent::__construct($context);
}
开发者ID:mb720,项目名称:mediawiki,代码行数:34,代码来源:SpecialListfiles.php
示例3: execute
function execute()
{
global $wgOut, $wgUser;
$wgOut->setPagetitle(wfMsgHtml("mergehistory"));
if ($this->mTargetID && $this->mDestID && $this->mAction == "submit" && $this->mMerge) {
return $this->merge();
}
if (!$this->mSubmitted) {
$this->showMergeForm();
return;
}
$errors = array();
if (!$this->mTargetObj instanceof Title) {
$errors[] = wfMsgExt('mergehistory-invalid-source', array('parse'));
} elseif (!$this->mTargetObj->exists()) {
$errors[] = wfMsgExt('mergehistory-no-source', array('parse'), wfEscapeWikiText($this->mTargetObj->getPrefixedText()));
}
if (!$this->mDestObj instanceof Title) {
$errors[] = wfMsgExt('mergehistory-invalid-destination', array('parse'));
} elseif (!$this->mDestObj->exists()) {
$errors[] = wfMsgExt('mergehistory-no-destination', array('parse'), wfEscapeWikiText($this->mDestObj->getPrefixedText()));
}
if ($this->mTargetObj->equals($this->mDestObj)) {
$errors[] = wfMsgExt('mergehistory-same-destination', array('parse'));
}
if (count($errors)) {
$this->showMergeForm();
$wgOut->addHTML(implode("\n", $errors));
} else {
$this->showHistory();
}
}
开发者ID:amjadtbssm,项目名称:website,代码行数:32,代码来源:SpecialMergeHistory.php
示例4: Html5SetSpamMessage
function Html5SetSpamMessage($match = false)
{
Html5editor::$spam_message = wfMsg('spamprotectiontext');
if ($match) {
Html5editor::$spam_message .= wfMsgExt('spamprotectionmatch', 'parse', wfEscapeWikiText($match));
}
return true;
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:8,代码来源:Html5editor.php
示例5: makeSafe
/**
* This function limits the possible charactes passed as template keys and
* values to letters, numbers, hypens and underscores. The function also
* performs standard escaping of the passed values.
*
* @param $string The unsafe string to escape and check for invalid characters
* @return mixed|String A string matching the regex or an empty string
*/
function makeSafe($string)
{
$num = preg_match('([a-zA-Z0-9_-]+)', $string, $matches);
if ($num == 1) {
# theoretically this is overkill, but better safe than sorry
return wfEscapeWikiText(htmlspecialchars($matches[0]));
}
return '';
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:17,代码来源:FundraiserLandingPage.body.php
示例6: execute
function execute($params = null)
{
global $IP, $wgWikiaLocalSettingsPath;
/* go with each supplied wiki and delete the supplied article
load all configs for particular wikis before doing so
(from wikifactory, not by _obsolete_ maintenance scripts
and from LocalSettings as worked on fps)
*/
$this->mTaskID = $params->task_id;
$oUser = User::newFromId($params->task_user_id);
if ($oUser instanceof User) {
$oUser->load();
$this->mUser = $oUser->getName();
} else {
$this->log("Invalid user - id: " . $params->task_user_id);
return true;
}
$data = unserialize($params->task_arguments);
foreach ($data['page_list'] as $imageData) {
$retval = "";
list($wikiId, $imageId) = $imageData;
$dbname = WikiFactory::getWikiByID($wikiId);
if (!$dbname) {
continue;
}
$title = GlobalTitle::newFromId($imageId, $wikiId);
if (!is_object($title)) {
$this->log('Apparently the article does not exist anymore');
continue;
}
$city_url = WikiFactory::getVarValueByName("wgServer", $wikiId);
if (empty($city_url)) {
continue;
}
$city_path = WikiFactory::getVarValueByName("wgScript", $wikiId);
$city_lang = WikiFactory::getVarValueByName("wgLanguageCode", $wikiId);
$reason = wfMsgExt('imagereview-reason', array('language' => $city_lang));
$sCommand = "perl /usr/wikia/backend/bin/run_maintenance --id={$wikiId} --script=wikia/deleteOn.php ";
$sCommand .= "-- ";
$sCommand .= "-u " . escapeshellarg($this->mUser) . " ";
$sCommand .= "-t " . escapeshellarg($title->getPrefixedText()) . " ";
if ($reason) {
$sCommand .= "-r " . escapeshellarg($reason) . " ";
}
$actual_title = wfShellExec($sCommand, $retval);
if ($retval) {
$this->addLog('Article deleting error! (' . $city_url . '). Error code returned: ' . $retval . ' Error was: ' . $actual_title);
} else {
$this->addLog('Removed: <a href="' . $city_url . $city_path . '?title=' . wfEscapeWikiText($actual_title) . '">' . $city_url . $city_path . '?title=' . $actual_title . '</a>');
}
$this->flagUser($imageId, $wikiId);
$this->flagWiki($wikiId);
}
return true;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:55,代码来源:ImageReviewTask.php
示例7: wfSpecialImport
/**
* Constructor
*/
function wfSpecialImport($page = '')
{
global $wgUser, $wgOut, $wgLang, $wgRequest, $wgTitle;
global $wgImportSources;
###
# $wgOut->addWikiText( "Special:Import is not ready for this beta release, sorry." );
# return;
###
if ($wgRequest->wasPosted() && $wgRequest->getVal('action') == 'submit') {
switch ($wgRequest->getVal("source")) {
case "upload":
if ($wgUser->isAllowed('importupload')) {
$source = ImportStreamSource::newFromUpload("xmlimport");
} else {
return $wgOut->permissionRequired('importupload');
}
break;
case "interwiki":
$source = ImportStreamSource::newFromInterwiki($wgRequest->getVal("interwiki"), $wgRequest->getText("frompage"));
break;
default:
$source = new WikiError("Unknown import source type");
}
if (WikiError::isError($source)) {
$wgOut->addWikiText(wfEscapeWikiText($source->getMessage()));
} else {
$importer = new WikiImporter($source);
$result = $importer->doImport();
if (WikiError::isError($result)) {
$wgOut->addWikiText(wfMsg("importfailed", wfEscapeWikiText($result->getMessage())));
} else {
# Success!
$wgOut->addWikiText(wfMsg("importsuccess"));
}
}
}
$action = $wgTitle->escapeLocalUrl('action=submit');
if ($wgUser->isAllowed('importupload')) {
$wgOut->addWikiText(wfMsg("importtext"));
$wgOut->addHTML("\n<fieldset>\n\t<legend>" . wfMsgHtml('upload') . "</legend>\n\t<form enctype='multipart/form-data' method='post' action=\"{$action}\">\n\t\t<input type='hidden' name='action' value='submit' />\n\t\t<input type='hidden' name='source' value='upload' />\n\t\t<input type='hidden' name='MAX_FILE_SIZE' value='2000000' />\n\t\t<input type='file' name='xmlimport' value='' size='30' />\n\t\t<input type='submit' value='" . wfMsgHtml("uploadbtn") . "'/>\n\t</form>\n</fieldset>\n");
} else {
if (empty($wgImportSources)) {
$wgOut->addWikiText(wfMsg('importnosources'));
}
}
if (!empty($wgImportSources)) {
$wgOut->addHTML("\n<fieldset>\n\t<legend>" . wfMsgHtml('importinterwiki') . "</legend>\n\t<form method='post' action=\"{$action}\">\n\t\t<input type='hidden' name='action' value='submit' />\n\t\t<input type='hidden' name='source' value='interwiki' />\n\t\t<select name='interwiki'>\n");
foreach ($wgImportSources as $interwiki) {
$iw = htmlspecialchars($interwiki);
$wgOut->addHTML("<option value=\"{$iw}\">{$iw}</option>\n");
}
$wgOut->addHTML("\n\t\t</select>\n\t\t<input name='frompage' />\n\t\t<input type='submit' />\n\t</form>\n</fieldset>\n");
}
}
开发者ID:BackupTheBerlios,项目名称:openzaurus-svn,代码行数:57,代码来源:SpecialImport.php
示例8: format
/**
* @see ValueFormatter::format
*
* @param MonolingualTextValue $value
*
* @throws InvalidArgumentException
* @return string HTML
*/
public function format($value)
{
if (!$value instanceof MonolingualTextValue) {
throw new InvalidArgumentException('Data value type mismatch. Expected a MonolingualTextValue.');
}
$text = $value->getText();
$languageCode = $value->getLanguageCode();
$languageName = $this->languageNameLookup->getName($languageCode);
$msg = wfMessage('wikibase-monolingualtext')->params(wfEscapeWikiText($text), wfEscapeWikiText($languageCode), wfEscapeWikiText($languageName));
return $msg->parse();
}
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:19,代码来源:MonolingualHtmlFormatter.php
示例9: execute
/**
* Main execution function
*
* @param $par Mixed: Parameters passed to the page
*/
public function execute($par)
{
$out = $this->getOutput();
$title = ShortUrlUtils::decodeURL($par);
if ($title !== false) {
$out->redirect($title->getFullURL(), '301');
} else {
$parEsc = wfEscapeWikiText($par);
$out->showErrorPage('shorturl-not-found-title', 'shorturl-not-found-message', array($parEsc));
}
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:16,代码来源:SpecialShortUrl.php
示例10: formatSnak
/**
* @see SnakFormatter::format
*
* Formats the given Snak as an wikitext link to an authoritative resource.
* The URL of that link is determined using a SnakUrlExpander.
* If the snak could not be expanded into a URL, the identifier is returned as simple text.
*
* @param Snak $snak
*
* @throws ParameterTypeException if $snak is not a PropertyValueSnak, or if $snak->getDataValue()
* does not return a StringValue.
* @return string Wikitext
*/
public function formatSnak(Snak $snak)
{
Assert::parameterType('Wikibase\\DataModel\\Snak\\PropertyValueSnak', $snak, '$snak');
/** @var PropertyValueSnak $snak */
$id = $snak->getDataValue()->getValue();
$url = $this->urlExpander->expandUrl($snak);
if ($url === null) {
return wfEscapeWikiText($id);
} else {
return '[' . $this->escapeWikitextInUrl($url) . ' ' . wfEscapeWikiText($id) . ']';
}
}
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:25,代码来源:WikitextExternalIdentifierFormatter.php
示例11: delete
public function delete($pageList, $suppress = false)
{
global $IP;
$user = \User::newFromId($this->createdBy);
$userName = $user->getName();
$articlesDeleted = 0;
foreach ($pageList as $imageData) {
list($wikiId, $imageId) = $imageData;
if (!\WikiFactory::isPublic($wikiId)) {
$this->notice('wiki has been disabled', ['wiki_id' => $wikiId]);
continue;
}
$dbname = \WikiFactory::getWikiByID($wikiId);
if (!$dbname) {
$this->warning('did not find database', ['wiki_id' => $wikiId]);
continue;
}
$cityUrl = \WikiFactory::getVarValueByName('wgServer', $wikiId);
if (empty($cityUrl)) {
$this->warning('could not determine city url', ['wiki_id' => $wikiId]);
continue;
}
$cityLang = \WikiFactory::getVarValueByName('wgLanguageCode', $wikiId);
$reason = wfMsgExt('imagereview-reason', ['language' => $cityLang]);
$command = "SERVER_ID={$wikiId} php {$IP}/maintenance/wikia/deleteOn.php" . ' -u ' . escapeshellarg($userName) . ' --id ' . $imageId;
if ($reason) {
$command .= ' -r ' . escapeshellarg($reason);
}
if ($suppress) {
$command .= ' -s';
}
$title = wfShellExec($command, $exitStatus);
if ($exitStatus !== 0) {
$this->error('article deletion error', ['city_url' => $cityUrl, 'exit_status' => $exitStatus, 'error' => $title]);
continue;
}
$cityPath = \WikiFactory::getVarValueByName('wgScript', $wikiId);
$escapedTitle = wfEscapeWikiText($title);
$this->info('removed image', ['link' => "{$cityUrl}{$cityPath}?title={$escapedTitle}", 'title' => $escapedTitle]);
++$articlesDeleted;
}
$success = $articlesDeleted == count($pageList);
if (!$success) {
$this->sendNotification();
}
return $success;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:47,代码来源:ImageReviewTask.class.php
示例12: show
function show()
{
global $wgOut;
$wgOut->setRobotpolicy('noindex,nofollow');
if (is_null($this->mTitle) || !$this->mTitle->exists() || $this->mTitle->getNamespace() == NS_MEDIAWIKI) {
$wgOut->showFatalError(wfMsg('badarticleerror'));
return;
}
if ($this->save()) {
$wgOut->redirect($this->mTitle->getFullUrl());
return;
}
$wgOut->setPageTitle(wfMsg('confirmprotect'));
$wgOut->setSubtitle(wfMsg('protectsub', $this->mTitle->getPrefixedText()));
$wgOut->addWikiText(wfMsg($this->disabled ? "protect-viewtext" : "protect-text", wfEscapeWikiText($this->mTitle->getPrefixedText())));
$wgOut->addHTML($this->buildForm());
$this->showLogExtract($wgOut);
}
开发者ID:negabaro,项目名称:alfresco,代码行数:18,代码来源:ProtectionForm.php
示例13: listForm
function listForm($username, $reason)
{
global $wgUser, $wgOut, $wgLang;
$pages = $this->getNewPages($username);
$escapedName = wfEscapeWikiText($username);
if (count($pages) == 0) {
$wgOut->addWikiText(wfMsg('nuke-nopages', $escapedName));
return $this->promptForm();
}
$wgOut->addWikiText(wfMsg('nuke-list', $escapedName));
$nuke = Title::makeTitle(NS_SPECIAL, 'Nuke');
$submit = wfElement('input', array('type' => 'submit', 'value' => wfMsgHtml('nuke-submit-delete')));
$wgOut->addHTML(wfElement('form', array('action' => $nuke->getLocalURL('action=delete'), 'method' => 'post'), null) . "\n<div>" . wfMsgHtml('deletecomment') . ': ' . wfElement('input', array('name' => 'wpReason', 'value' => $reason, 'size' => 60)) . "</div><br />" . $submit . wfElement('input', array('type' => 'hidden', 'name' => 'wpEditToken', 'value' => $wgUser->editToken())) . "\n<ul>\n");
$sk =& $wgUser->getSkin();
foreach ($pages as $info) {
list($title, $edits) = $info;
$wgOut->addHTML('<li>' . wfElement('input', array('type' => 'checkbox', 'name' => "pages[]", 'value' => $title->getPrefixedDbKey(), 'checked' => 'checked')) . ' ' . $sk->makeKnownLinkObj($title) . ' (' . $sk->makeKnownLinkObj($title, wfMsgExt('nchanges', array('parsemag'), $wgLang->formatNum($edits)), 'action=history') . ")</li>\n");
}
$wgOut->addHTML("</ul>\n{$submit}</form>");
}
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:20,代码来源:SpecialNuke.php
示例14: execute
public function execute($par)
{
$this->checkPermissions();
$this->checkReadOnly();
list($this->target, $this->type) = SpecialBlock::getTargetAndType($par, $this->getRequest());
$this->block = Block::newFromTarget($this->target);
if ($this->target instanceof User) {
# Set the 'relevant user' in the skin, so it displays links like Contributions,
# User logs, UserRights, etc.
$this->getSkin()->setRelevantUser($this->target);
}
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
$out->setPageTitle($this->msg('unblockip'));
$out->addModules(['mediawiki.special', 'mediawiki.userSuggest']);
$form = new HTMLForm($this->getFields(), $this->getContext());
$form->setWrapperLegendMsg('unblockip');
$form->setSubmitCallback([__CLASS__, 'processUIUnblock']);
$form->setSubmitTextMsg('ipusubmit');
$form->addPreText($this->msg('unblockiptext')->parseAsBlock());
if ($form->show()) {
switch ($this->type) {
case Block::TYPE_IP:
$out->addWikiMsg('unblocked-ip', wfEscapeWikiText($this->target));
break;
case Block::TYPE_USER:
$out->addWikiMsg('unblocked', wfEscapeWikiText($this->target));
break;
case Block::TYPE_RANGE:
$out->addWikiMsg('unblocked-range', wfEscapeWikiText($this->target));
break;
case Block::TYPE_ID:
case Block::TYPE_AUTO:
$out->addWikiMsg('unblocked-id', wfEscapeWikiText($this->target));
break;
}
}
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:39,代码来源:SpecialUnblock.php
示例15: showCurrent
private function showCurrent()
{
global $wgOut, $wgMemc;
$wgOut->addHTML("<fieldset>\n");
$wgOut->addHTML("<legend>CurrentValue</legend>\n");
$sysopId = $wgMemc->get(wfMemcKey("last-sysop-id"));
if ($sysopId) {
$this->mSysop = User::newFromId($sysopId);
$sysopName = wfEscapeWikiText($this->mSysop->getName());
$groups = $this->mSysop->getEffectiveGroups();
$wgOut->addHTML("ID: <code>" . $sysopId . "</code><br/>");
$wgOut->addHTML("Name: <code>" . $sysopName . "</code><br/>");
$wgOut->addHTML("Groups: <code>" . implode(", ", $groups) . "</code><br/>");
$action_url = $this->mTitle->getFullURL();
$wgOut->addHTML("<form action='{$action_url}' method='post'>\n");
$wgOut->addHTML("<input type='hidden' name='method' value='clear' />\n");
$wgOut->addHTML("<input type='submit' value='clear' />\n");
$wgOut->addHTML("</form>\n");
} else {
$wgOut->addHTML("<i>n/a</i>");
}
$wgOut->addHTML("</fieldset>\n");
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:23,代码来源:HAWelcomeEdit.body.php
示例16: getHelpInternal
//.........这里部分代码省略.........
// Add usage info
$info = array();
// Required?
if (!empty($settings[ApiBase::PARAM_REQUIRED])) {
$info[] = $context->msg('api-help-param-required')->parse();
}
// Custom info?
if (!empty($settings[ApiBase::PARAM_HELP_MSG_INFO])) {
foreach ($settings[ApiBase::PARAM_HELP_MSG_INFO] as $i) {
$tag = array_shift($i);
$info[] = $context->msg("apihelp-{$path}-paraminfo-{$tag}")->numParams(count($i))->params($context->getLanguage()->commaList($i))->params($module->getModulePrefix())->parse();
}
}
// Type documentation
if (!isset($settings[ApiBase::PARAM_TYPE])) {
$dflt = isset($settings[ApiBase::PARAM_DFLT]) ? $settings[ApiBase::PARAM_DFLT] : null;
if (is_bool($dflt)) {
$settings[ApiBase::PARAM_TYPE] = 'boolean';
} elseif (is_string($dflt) || is_null($dflt)) {
$settings[ApiBase::PARAM_TYPE] = 'string';
} elseif (is_int($dflt)) {
$settings[ApiBase::PARAM_TYPE] = 'integer';
}
}
if (isset($settings[ApiBase::PARAM_TYPE])) {
$type = $settings[ApiBase::PARAM_TYPE];
$multi = !empty($settings[ApiBase::PARAM_ISMULTI]);
$hintPipeSeparated = true;
$count = ApiBase::LIMIT_SML2 + 1;
if (is_array($type)) {
$count = count($type);
$links = isset($settings[ApiBase::PARAM_VALUE_LINKS]) ? $settings[ApiBase::PARAM_VALUE_LINKS] : array();
$type = array_map(function ($v) use($links) {
$ret = wfEscapeWikiText($v);
if (isset($links[$v])) {
$ret = "[[{$links[$v]}|{$ret}]]";
}
return $ret;
}, $type);
$i = array_search('', $type, true);
if ($i === false) {
$type = $context->getLanguage()->commaList($type);
} else {
unset($type[$i]);
$type = $context->msg('api-help-param-list-can-be-empty')->numParams(count($type))->params($context->getLanguage()->commaList($type))->parse();
}
$info[] = $context->msg('api-help-param-list')->params($multi ? 2 : 1)->params($type)->parse();
$hintPipeSeparated = false;
} else {
switch ($type) {
case 'submodule':
$groups[] = $name;
if (isset($settings[ApiBase::PARAM_SUBMODULE_MAP])) {
$map = $settings[ApiBase::PARAM_SUBMODULE_MAP];
ksort($map);
$submodules = array();
foreach ($map as $v => $m) {
$submodules[] = "[[Special:ApiHelp/{$m}|{$v}]]";
}
} else {
$submodules = $module->getModuleManager()->getNames($name);
sort($submodules);
$prefix = $module->isMain() ? '' : $module->getModulePath() . '+';
$submodules = array_map(function ($name) use($prefix) {
return "[[Special:ApiHelp/{$prefix}{$name}|{$name}]]";
}, $submodules);
开发者ID:paladox,项目名称:2,代码行数:67,代码来源:ApiHelp.php
示例17: checkOverwrite
/**
* Check if there's an overwrite conflict and, if so, if restrictions
* forbid this user from performing the upload.
*
* @return mixed true on success, WikiError on failure
* @access private
*/
function checkOverwrite($name)
{
$img = Image::newFromName($name);
if (is_null($img)) {
// Uh... this shouldn't happen ;)
// But if it does, fall through to previous behavior
return false;
}
$error = '';
if ($img->exists()) {
global $wgUser, $wgOut;
if ($img->isLocal()) {
if (!$wgUser->isAllowed('reupload')) {
$error = 'fileexists-forbidden';
}
} else {
if (!$wgUser->isAllowed('reupload') || !$wgUser->isAllowed('reupload-shared')) {
$error = "fileexists-shared-forbidden";
}
}
}
if ($error) {
$errorText = wfMsg($error, wfEscapeWikiText($img->getName()));
return new WikiError($wgOut->parse($errorText));
}
// Rockin', go ahead and upload
return true;
}
开发者ID:k-hasan-19,项目名称:wiki,代码行数:35,代码来源:SpecialUpload.php
示例18: execute
public function execute($par)
{
$this->useTransactionalTimeLimit();
$this->checkPermissions();
$this->checkReadOnly();
$this->loadRequestParams();
$this->setHeaders();
$this->outputHeader();
if ($this->mTargetID && $this->mDestID && $this->mAction == 'submit' && $this->mMerge) {
$this->merge();
return;
}
if (!$this->mSubmitted) {
$this->showMergeForm();
return;
}
$errors = [];
if (!$this->mTargetObj instanceof Title) {
$errors[] = $this->msg('mergehistory-invalid-source')->parseAsBlock();
} elseif (!$this->mTargetObj->exists()) {
$errors[] = $this->msg('mergehistory-no-source', wfEscapeWikiText($this->mTargetObj->getPrefixedText()))->parseAsBlock();
}
if (!$this->mDestObj instanceof Title) {
$errors[] = $this->msg('mergehistory-invalid-destination')->parseAsBlock();
} elseif (!$this->mDestObj->exists()) {
$errors[] = $this->msg('mergehistory-no-destination', wfEscapeWikiText($this->mDestObj->getPrefixedText()))->parseAsBlock();
}
if ($this->mTargetObj && $this->mDestObj && $this->mTargetObj->equals($this->mDestObj)) {
$errors[] = $this->msg('mergehistory-same-destination')->parseAsBlock();
}
if (count($errors)) {
$this->showMergeForm();
$this->getOutput()->addHTML(implode("\n", $errors));
} else {
$this->showHistory();
}
}
开发者ID:paladox,项目名称:mediawiki,代码行数:37,代码来源:SpecialMergeHistory.php
示例19: show
/**
* Show the input form with optional error message
*
* @param string $err error message or null if there's no error
*/
function show($err = null)
{
global $wgOut;
$wgOut->setRobotPolicy('noindex,nofollow');
$wgOut->addBacklinkSubtitle($this->mTitle);
if (is_array($err)) {
$wgOut->wrapWikiMsg("<p class='error'>\n\$1\n</p>\n", $err);
} elseif (is_string($err)) {
$wgOut->addHTML("<p class='error'>{$err}</p>\n");
}
if ($this->mTitle->getRestrictionTypes() === array()) {
// No restriction types available for the current title
// this might happen if an extension alters the available types
$wgOut->setPageTitle(wfMessage('protect-norestrictiontypes-title', $this->mTitle->getPrefixedText()));
$wgOut->addWikiText(wfMessage('protect-norestrictiontypes-text')->text());
// Show the log in case protection was possible once
$this->showLogExtract($wgOut);
// return as there isn't anything else we can do
return;
}
list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
if ($cascadeSources && count($cascadeSources) > 0) {
$titles = '';
foreach ($cascadeSources as $title) {
$titles .= '* [[:' . $title->getPrefixedText() . "]]\n";
}
$wgOut->wrapWikiMsg("<div id=\"mw-protect-cascadeon\">\n\$1\n" . $titles . "</div>", array('protect-cascadeon', count($cascadeSources)));
}
# Show an appropriate message if the user isn't allowed or able to change
# the protection settings at this time
if ($this->disabled) {
$wgOut->setPageTitle(wfMessage('protect-title-notallowed', $this->mTitle->getPrefixedText()));
$wgOut->addWikiText($wgOut->formatPermissionsErrorMessage($this->mPermErrors, 'protect'));
} else {
$wgOut->setPageTitle(wfMessage('protect-title', $this->mTitle->getPrefixedText()));
$wgOut->addWikiMsg('protect-text', wfEscapeWikiText($this->mTitle->getPrefixedText()));
}
$wgOut->addHTML($this->buildForm());
$this->showLogExtract($wgOut);
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:45,代码来源:ProtectionForm.php
示例20: showHistory
protected function showHistory()
{
$this->checkReadOnly();
$out = $this->getOutput();
if ($this->mAllowed) {
$out->addModules('mediawiki.special.undelete');
}
$out->wrapWikiMsg("<div class='mw-undelete-pagetitle'>\n\$1\n</div>\n", array('undeletepagetitle', wfEscapeWikiText($this->mTargetObj->getPrefixedText())));
$archive = new PageArchive($this->mTargetObj, $this->getConfig());
Hooks::run('UndeleteForm::showHistory', array(&$archive, $this->mTargetObj));
/*
$text = $archive->getLastRevisionText();
if( is_null( $text ) ) {
$out->addWikiMsg( 'nohistory' );
return;
}
*/
$out->addHTML('<div class="mw-undelete-history">');
if ($this->mAllowed) {
$out->addWikiMsg('undeletehistory');
$out->addWikiMsg('undeleterevdel');
} else {
$out->addWikiMsg('undeletehistorynoadmin');
}
$out->addHTML('</div>');
# List all stored revisions
$revisions = $archive->listRevisions();
$files = $archive->listFiles();
$haveRevisions = $revisions && $revisions->numRows() > 0;
$haveFiles = $files && $files->numRows() > 0;
# Batch existence check on user and talk pages
if ($haveRevisions) {
$batch = new LinkBatch();
foreach ($revisions as $row) {
$batch->addObj(Title::makeTitleSafe(NS_USER, $row->ar_user_text));
$batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->ar_user_text));
}
$batch->execute();
$revisions->seek(0);
}
if ($haveFiles) {
$batch = new LinkBatch();
foreach ($files as $row) {
$batch->addObj(Title::makeTitleSafe(NS_USER, $row->fa_user_text));
$batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->fa_user_text));
}
$batch->execute();
$files->seek(0);
}
if ($this->mAllowed) {
$action = $this->getPageTitle()->getLocalURL(array('action' => 'submit'));
# Start the form here
$top = Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'undelete'));
$out->addHTML($top);
}
# Show relevant lines from the deletion log:
$deleteLogPage = new LogPage('delete');
$out->addHTML(Xml::element('h2', null, $deleteLogPage->getName()->text()) . "\n");
LogEventsList::showLogExtract($out, 'delete', $this->mTargetObj);
# Show relevant lines from the suppression log:
$suppressLogPage = new LogPage('suppress');
if ($this->getUser()->isAllowed('suppressionlog')) {
$out->addHTML(Xml::element('h2', null, $suppressLogPage->getName()->text()) . "\n");
LogEventsList::showLogExtract($out, 'suppress', $this->mTargetObj);
}
if ($this->mAllowed && ($haveRevisions || $haveFiles)) {
# Format the user-visible controls (comment field, submission button)
# in a nice little table
if ($this->getUser()->isAllowed('suppressrevision')) {
$unsuppressBox = "<tr>\n\t\t\t\t\t\t<td> </td>\n\t\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel($this->msg('revdelete-unsuppress')->text(), 'wpUnsuppress', 'mw-undelete-unsuppress', $this->mUnsuppress) . "</td>\n\t\t\t\t\t</tr>";
} else {
$unsuppressBox = '';
}
$table = Xml::fieldset($this->msg('undelete-fieldset-title')->text()) . Xml::openElement('table', array('id' => 'mw-undelete-table')) . "<tr>\n\t\t\t\t\t<td colspan='2' class='mw-undelete-extrahelp'>" . $this->msg('undeleteextrahelp')->parseAsBlock() . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label($this->msg('undeletecomment')->text(), 'wpComment') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('wpComment', 50, $this->mComment, array('id' => 'wpComment', 'autofocus' => '')) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td> </td>\n\t\t\t\t<td class='mw-submit'>" . Xml::submitButton($this->msg('undeletebtn')->text(), array('name' => 'restore', 'id' => 'mw-undelete-submit')) . ' ' . Xml::submitButton($this->msg('undeleteinvert')->text(), array('name' => 'invert', 'id' => 'mw-undelete-invert')) . "</td>\n\t\t\t</tr>" . $unsuppressBox . Xml::closeElement('table') . Xml::closeElement('fieldset');
$out->addHTML($table);
}
$out->addHTML(Xml::element('h2', null, $this->msg('history')->text()) . "\n");
if ($haveRevisions) {
# The page's stored (deleted) history:
$out->addHTML('<ul>');
$remaining = $revisions->numRows();
$earliestLiveTime = $this->mTargetObj->getEarliestRevTime();
foreach ($revisions as $row) {
$remaining--;
$out->addHTML($this->formatRevisionRow($row, $earliestLiveTime, $remaining));
}
$revisions->free();
$out->addHTML('</ul>');
} else {
$out->addWikiMsg('nohistory');
}
if ($haveFiles) {
$out->addHTML(Xml::element('h2', null, $this->msg('filehist')->text()) . "\n");
$out->addHTML('<ul>');
foreach ($files as $row) {
$out->addHTML($this->formatFileRow($row));
}
$files->free();
$out->addHTML('</ul>');
}
//.........这里部分代码省略.........
开发者ID:raymondzhangl,项目名称:mediawiki,代码行数:101,代码来源:SpecialUndelete.php
注:本文中的wfEscapeWikiText函数示例整理自Github/MSDocs等源码及 |
请发表评论