本文整理汇总了PHP中IContextSource::getTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP IContextSource::getTitle方法的具体用法?PHP IContextSource::getTitle怎么用?PHP IContextSource::getTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContextSource
的用法示例。
在下文中一共展示了IContextSource::getTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterMergedContent
/**
* Hook function for EditFilterMergedContent
*
* @param IContextSource $context
* @param Content $content
* @param Status $status
* @param string $summary
* @param User $user
* @param bool $minoredit
*
* @return bool
*/
static function filterMergedContent(IContextSource $context, Content $content, Status $status, $summary, User $user, $minoredit)
{
$title = $context->getTitle();
if (isset($title->spamBlackListFiltered) && $title->spamBlackListFiltered) {
// already filtered
return true;
}
// get the link from the not-yet-saved page content.
// no need to generate html to get external links
$pout = $content->getParserOutput($title, null, null, false);
$links = array_keys($pout->getExternalLinks());
// HACK: treat the edit summary as a link
if ($summary !== '') {
$links[] = $summary;
}
$spamObj = BaseBlacklist::getInstance('spam');
$matches = $spamObj->filter($links, $title);
if ($matches !== false) {
$status->fatal('spamprotectiontext');
foreach ($matches as $match) {
$status->fatal('spamprotectionmatch', $match);
}
}
// Always return true, EditPage will look at $status->isOk().
return true;
}
示例2: performAction
/**
* Perform one of the "standard" actions
*
* @param $page Page
* @param $requestTitle The original title, before any redirects were applied
*/
private function performAction(Page $page, Title $requestTitle)
{
global $wgUseSquid, $wgSquidMaxage;
wfProfileIn(__METHOD__);
$request = $this->context->getRequest();
$output = $this->context->getOutput();
$title = $this->context->getTitle();
$user = $this->context->getUser();
if (!wfRunHooks('MediaWikiPerformAction', array($output, $page, $title, $user, $request, $this))) {
wfProfileOut(__METHOD__);
return;
}
$act = $this->getAction();
$action = Action::factory($act, $page);
if ($action instanceof Action) {
# Let Squid cache things if we can purge them.
if ($wgUseSquid && in_array($request->getFullRequestURL(), $requestTitle->getSquidURLs())) {
$output->setSquidMaxage($wgSquidMaxage);
}
$action->show();
wfProfileOut(__METHOD__);
return;
}
if (wfRunHooks('UnknownAction', array($request->getVal('action', 'view'), $page))) {
$output->showErrorPage('nosuchaction', 'nosuchactiontext');
}
wfProfileOut(__METHOD__);
}
示例3: performAction
/**
* Perform one of the "standard" actions
*
* @param Page $page
* @param Title $requestTitle The original title, before any redirects were applied
*/
private function performAction(Page $page, Title $requestTitle)
{
$request = $this->context->getRequest();
$output = $this->context->getOutput();
$title = $this->context->getTitle();
$user = $this->context->getUser();
if (!Hooks::run('MediaWikiPerformAction', [$output, $page, $title, $user, $request, $this])) {
return;
}
$act = $this->getAction();
$action = Action::factory($act, $page, $this->context);
if ($action instanceof Action) {
// Narrow DB query expectations for this HTTP request
$trxLimits = $this->config->get('TrxProfilerLimits');
$trxProfiler = Profiler::instance()->getTransactionProfiler();
if ($request->wasPosted() && !$action->doesWrites()) {
$trxProfiler->setExpectations($trxLimits['POST-nonwrite'], __METHOD__);
$request->markAsSafeRequest();
}
# Let CDN cache things if we can purge them.
if ($this->config->get('UseSquid') && in_array(wfExpandUrl($request->getRequestURL(), PROTO_INTERNAL), $requestTitle->getCdnUrls())) {
$output->setCdnMaxage($this->config->get('SquidMaxage'));
}
$action->show();
return;
}
if (Hooks::run('UnknownAction', [$request->getVal('action', 'view'), $page])) {
$output->setStatusCode(404);
$output->showErrorPage('nosuchaction', 'nosuchactiontext');
}
}
示例4: performAction
/**
* Perform one of the "standard" actions
*
* @param $page Page
*/
private function performAction(Page $page)
{
wfProfileIn(__METHOD__);
$request = $this->context->getRequest();
$output = $this->context->getOutput();
$title = $this->context->getTitle();
$user = $this->context->getUser();
if (!wfRunHooks('MediaWikiPerformAction', array($output, $page, $title, $user, $request, $this))) {
wfProfileOut(__METHOD__);
return;
}
$act = $this->getAction();
$action = Action::factory($act, $page);
if ($action instanceof Action) {
$action->show();
wfProfileOut(__METHOD__);
return;
}
if (wfRunHooks('UnknownAction', array($request->getVal('action', 'view'), $page))) {
$output->showErrorPage('nosuchaction', 'nosuchactiontext');
}
wfProfileOut(__METHOD__);
}
示例5: performAction
/**
* Perform one of the "standard" actions
*
* @param Page $page
* @param Title $requestTitle The original title, before any redirects were applied
*/
private function performAction(Page $page, Title $requestTitle)
{
$request = $this->context->getRequest();
$output = $this->context->getOutput();
$title = $this->context->getTitle();
$user = $this->context->getUser();
if (!Hooks::run('MediaWikiPerformAction', array($output, $page, $title, $user, $request, $this))) {
return;
}
$act = $this->getAction();
$action = Action::factory($act, $page, $this->context);
if ($action instanceof Action) {
# Let CDN cache things if we can purge them.
if ($this->config->get('UseSquid') && in_array(wfExpandUrl($request->getRequestURL(), PROTO_INTERNAL), $requestTitle->getCdnUrls())) {
$output->setCdnMaxage($this->config->get('SquidMaxage'));
}
$action->show();
return;
}
if (Hooks::run('UnknownAction', array($request->getVal('action', 'view'), $page))) {
$output->setStatusCode(404);
$output->showErrorPage('nosuchaction', 'nosuchactiontext');
}
}
示例6: setContext
/**
* Set the language and the title from a context object
*
* @since 1.19
*
* @param IContextSource $context
*
* @return Message $this
*/
public function setContext(IContextSource $context)
{
$this->inLanguage($context->getLanguage());
$this->title($context->getTitle());
$this->interface = true;
return $this;
}
示例7: getCachedNotice
/**
* Returns a message that notifies the user he/she is looking at
* a cached version of the page, including a refresh link.
*
* @since 1.20
*
* @param IContextSource $context
* @param boolean $includePurgeLink
*
* @return string
*/
public function getCachedNotice(IContextSource $context, $includePurgeLink = true)
{
if ($this->cacheExpiry < 86400 * 3650) {
$message = $context->msg('cachedspecial-viewing-cached-ttl', $context->getLanguage()->formatDuration($this->cacheExpiry))->escaped();
} else {
$message = $context->msg('cachedspecial-viewing-cached-ts')->escaped();
}
if ($includePurgeLink) {
$refreshArgs = $context->getRequest()->getQueryValues();
unset($refreshArgs['title']);
$refreshArgs['action'] = 'purge';
$subPage = $context->getTitle()->getFullText();
$subPage = explode('/', $subPage, 2);
$subPage = count($subPage) > 1 ? $subPage[1] : false;
$message .= ' ' . Linker::link($context->getTitle($subPage), $context->msg('cachedspecial-refresh-now')->escaped(), array(), $refreshArgs);
}
return $message;
}
示例8: getTitle
/**
* Get the Title being used for this instance.
* IndexPager extends ContextSource as of 1.19.
*
* @since 0.1
*
* @return Title
*/
public function getTitle()
{
return $this->context->getTitle();
}
示例9: onInfoAction
public static function onInfoAction(IContextSource $ctx, &$pageinfo)
{
if (!self::$occupationController->isTalkpageOccupied($ctx->getTitle())) {
return true;
}
// All of the info in this section is wrong for Flow pages,
// so we'll just remove it.
unset($pageinfo['header-edits']);
// These keys are wrong on Flow pages, so we'll remove them
static $badMessageKeys = array('pageinfo-length', 'pageinfo-content-model');
foreach ($pageinfo['header-basic'] as $num => $val) {
if ($val[0] instanceof Message && in_array($val[0]->getKey(), $badMessageKeys)) {
unset($pageinfo['header-basic'][$num]);
}
}
return true;
}
示例10: makeOffsetLink
protected function makeOffsetLink($label, $offset, $nondefaults)
{
$query = array_merge($nondefaults, array('offset' => $offset));
$link = Linker::link($this->context->getTitle(), $label, array(), $query);
return $link;
}
示例11: filterEdit
/**
* Common implementation for the APIEditBeforeSave, EditFilterMerged
* and EditFilterMergedContent hooks.
*
* @param IContextSource $context the context of the edit
* @param Content|null $content the new Content generated by the edit
* @param string $text new page content (subject of filtering)
* @param Status $status Error message to return
* @param string $summary Edit summary for page
* @param bool $minoredit whether this is a minor edit according to the user.
*
* @return bool
*/
public static function filterEdit(IContextSource $context, $content, $text, Status $status, $summary, $minoredit)
{
// Load vars
$vars = new AbuseFilterVariableHolder();
$title = $context->getTitle();
// Some edits are running through multiple hooks, but we only want to filter them once
if (isset($title->editAlreadyFiltered)) {
return true;
} elseif ($title) {
$title->editAlreadyFiltered = true;
}
self::$successful_action_vars = false;
self::$last_edit_page = false;
$user = $context->getUser();
// Check for null edits.
$oldtext = '';
$oldcontent = null;
if ($title instanceof Title && $title->canExist() && $title->exists()) {
// Make sure we load the latest text saved in database (bug 31656)
$page = $context->getWikiPage();
$revision = $page->getRevision();
if (!$revision) {
return true;
}
if (defined('MW_SUPPORTS_CONTENTHANDLER')) {
$oldcontent = $revision->getContent(Revision::RAW);
$oldtext = AbuseFilter::contentToString($oldcontent);
} else {
$oldtext = AbuseFilter::revisionToString($revision, Revision::RAW);
}
// Cache article object so we can share a parse operation
$articleCacheKey = $title->getNamespace() . ':' . $title->getText();
AFComputedVariable::$articleCache[$articleCacheKey] = $page;
} else {
$page = null;
}
// Don't trigger for null edits.
if ($content && $oldcontent && $oldcontent->equals($content)) {
// Compare Content objects if available
return true;
} else {
if (strcmp($oldtext, $text) == 0) {
// Otherwise, compare strings
return true;
}
}
$vars->addHolders(AbuseFilter::generateUserVars($user), AbuseFilter::generateTitleVars($title, 'ARTICLE'));
$vars->setVar('action', 'edit');
$vars->setVar('summary', $summary);
$vars->setVar('minor_edit', $minoredit);
$vars->setVar('old_wikitext', $oldtext);
$vars->setVar('new_wikitext', $text);
// TODO: set old_content and new_content vars, use them
$vars->addHolders(AbuseFilter::getEditVars($title, $page));
$filter_result = AbuseFilter::filterAction($vars, $title);
if (!$filter_result->isOK()) {
$status->merge($filter_result);
return true;
// re-show edit form
}
self::$successful_action_vars = $vars;
self::$last_edit_page = $page;
return true;
}
示例12: profilePreferences
/**
* @param $user User
* @param $context IContextSource
* @param $defaultPreferences
* @return void
*/
static function profilePreferences($user, IContextSource $context, &$defaultPreferences)
{
global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode, $wgDisableTitleConversion, $wgDisableLangConversion, $wgMaxSigChars, $wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication, $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress;
## User info #####################################
// Information panel
$defaultPreferences['username'] = array('type' => 'info', 'label-message' => 'username', 'default' => $user->getName(), 'section' => 'personal/info');
$defaultPreferences['userid'] = array('type' => 'info', 'label-message' => 'uid', 'default' => $user->getId(), 'section' => 'personal/info');
# Get groups to which the user belongs
$userEffectiveGroups = $user->getEffectiveGroups();
$userGroups = $userMembers = array();
foreach ($userEffectiveGroups as $ueg) {
if ($ueg == '*') {
// Skip the default * group, seems useless here
continue;
}
$groupName = User::getGroupName($ueg);
$userGroups[] = User::makeGroupLinkHTML($ueg, $groupName);
$memberName = User::getGroupMember($ueg, $user->getName());
$userMembers[] = User::makeGroupLinkHTML($ueg, $memberName);
}
asort($userGroups);
asort($userMembers);
$lang = $context->getLanguage();
$defaultPreferences['usergroups'] = array('type' => 'info', 'label' => $context->msg('prefs-memberingroups')->numParams(count($userGroups))->parse(), 'default' => $context->msg('prefs-memberingroups-type', $lang->commaList($userGroups), $lang->commaList($userMembers))->plain(), 'raw' => true, 'section' => 'personal/info');
$defaultPreferences['editcount'] = array('type' => 'info', 'label-message' => 'prefs-edits', 'default' => $lang->formatNum($user->getEditCount()), 'section' => 'personal/info');
if ($user->getRegistration()) {
$displayUser = $context->getUser();
$userRegistration = $user->getRegistration();
$defaultPreferences['registrationdate'] = array('type' => 'info', 'label-message' => 'prefs-registration', 'default' => $context->msg('prefs-registration-date-time', $lang->userTimeAndDate($userRegistration, $displayUser), $lang->userDate($userRegistration, $displayUser), $lang->userTime($userRegistration, $displayUser))->parse(), 'section' => 'personal/info');
}
// Actually changeable stuff
$defaultPreferences['realname'] = array('type' => $wgAuth->allowPropChange('realname') ? 'text' : 'info', 'default' => $user->getRealName(), 'section' => 'personal/info', 'label-message' => 'yourrealname', 'help-message' => 'prefs-help-realname');
$defaultPreferences['gender'] = array('type' => 'select', 'section' => 'personal/info', 'options' => array($context->msg('gender-male')->text() => 'male', $context->msg('gender-female')->text() => 'female', $context->msg('gender-unknown')->text() => 'unknown'), 'label-message' => 'yourgender', 'help-message' => 'prefs-help-gender');
if ($wgAuth->allowPasswordChange()) {
$link = Linker::link(SpecialPage::getTitleFor('ChangePassword'), $context->msg('prefs-resetpass')->escaped(), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')));
$defaultPreferences['password'] = array('type' => 'info', 'raw' => true, 'default' => $link, 'label-message' => 'yourpassword', 'section' => 'personal/info');
}
if ($wgCookieExpiration > 0) {
$defaultPreferences['rememberpassword'] = array('type' => 'toggle', 'label' => $context->msg('tog-rememberpassword')->numParams(ceil($wgCookieExpiration / (3600 * 24)))->text(), 'section' => 'personal/info');
}
// Language
$languages = Language::getLanguageNames(false);
if (!array_key_exists($wgLanguageCode, $languages)) {
$languages[$wgLanguageCode] = $wgLanguageCode;
}
ksort($languages);
$options = array();
foreach ($languages as $code => $name) {
$display = wfBCP47($code) . ' - ' . $name;
$options[$display] = $code;
}
$defaultPreferences['language'] = array('type' => 'select', 'section' => 'personal/i18n', 'options' => $options, 'label-message' => 'yourlanguage');
/* see if there are multiple language variants to choose from*/
$variantArray = array();
if (!$wgDisableLangConversion) {
$variants = $wgContLang->getVariants();
foreach ($variants as $v) {
$v = str_replace('_', '-', strtolower($v));
$variantArray[$v] = $wgContLang->getVariantname($v, false);
}
$options = array();
foreach ($variantArray as $code => $name) {
$display = wfBCP47($code) . ' - ' . $name;
$options[$display] = $code;
}
if (count($variantArray) > 1) {
$defaultPreferences['variant'] = array('label-message' => 'yourvariant', 'type' => 'select', 'options' => $options, 'section' => 'personal/i18n', 'help-message' => 'prefs-help-variant');
}
}
if (count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
$defaultPreferences['noconvertlink'] = array('type' => 'toggle', 'section' => 'personal/i18n', 'label-message' => 'tog-noconvertlink');
}
// show a preview of the old signature first
$oldsigWikiText = $wgParser->preSaveTransform("~~~", $context->getTitle(), $user, ParserOptions::newFromContext($context));
$oldsigHTML = $context->getOutput()->parseInline($oldsigWikiText, true, true);
$defaultPreferences['oldsig'] = array('type' => 'info', 'raw' => true, 'label-message' => 'tog-oldsig', 'default' => $oldsigHTML, 'section' => 'personal/signature');
$defaultPreferences['nickname'] = array('type' => $wgAuth->allowPropChange('nickname') ? 'text' : 'info', 'maxlength' => $wgMaxSigChars, 'label-message' => 'yournick', 'validation-callback' => array('Preferences', 'validateSignature'), 'section' => 'personal/signature', 'filter-callback' => array('Preferences', 'cleanSignature'));
$defaultPreferences['fancysig'] = array('type' => 'toggle', 'label-message' => 'tog-fancysig', 'help-message' => 'prefs-help-signature', 'section' => 'personal/signature');
## Email stuff
if ($wgEnableEmail) {
$helpMessages[] = $wgEmailConfirmToEdit ? 'prefs-help-email-required' : 'prefs-help-email';
if ($wgEnableUserEmail) {
// additional messages when users can send email to each other
$helpMessages[] = 'prefs-help-email-others';
}
$link = Linker::link(SpecialPage::getTitleFor('ChangeEmail'), $context->msg($user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail')->escaped(), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')));
$emailAddress = $user->getEmail() ? htmlspecialchars($user->getEmail()) : '';
if ($wgAuth->allowPropChange('emailaddress')) {
$emailAddress .= $emailAddress == '' ? $link : " ({$link})";
}
$defaultPreferences['emailaddress'] = array('type' => 'info', 'raw' => true, 'default' => $emailAddress, 'label-message' => 'youremail', 'section' => 'personal/email', 'help-messages' => $helpMessages);
$disableEmailPrefs = false;
if ($wgEmailAuthentication) {
if ($user->getEmail()) {
//.........这里部分代码省略.........
示例13: trim
function __construct(IContextSource $context, $templatetext, $argv, $parser)
{
global $wgContLang;
$this->title = $context->getTitle();
$this->skin = $context->getSkin();
$this->parser = $parser;
$this->templatetext = $templatetext;
if (!is_null($this->templatetext)) {
$this->templatetext = trim($this->templatetext);
if ($this->templatetext == '') {
$this->templatetext = null;
}
}
$this->usetemplate = !is_null($this->templatetext);
$this->templateparser = null;
$this->templateoptions = null;
#$template = @$argv['template'];
#if ( $this->usetemplate ) {
#print "<pre>$templatetitle</pre>";
$this->templateparser = $parser;
#$this->templateparser = clone $parser;
#$this->templateparser->setOutputType( Parser::OT_HTML );
$this->templateoptions = new ParserOptions();
$this->templateoptions->setEditSection(false);
$this->templateoptions->setNumberHeadings(false);
$this->templateoptions->setRemoveComments(true);
//$this->templateoptions->setUseDynamicDates( false ); // removed in mw 1.21
$this->templateoptions->setInterwikiMagic(true);
//strip interlanguage-links
$this->templateoptions->setAllowSpecialInclusion(false);
#$this->templatetitle = Title::newFromText( $template, NS_TEMPLATE );
#$templatetext = $templateparser->fetchTemplate( $templatetitle );
#print "<pre>$templatetext</pre>";
#$templateoptions->setRemoveComments( true );
#$templateoptions->setMaxIncludeSize( self::MAX_INCLUDE_SIZE );
#}
if (!$this->usetemplate) {
$this->changelist = new OldChangesList($this->skin);
}
#$this->feedId = @$argv['id'];
$this->prefix = @$argv['prefix'];
$this->postfix = @$argv['postfix'];
$this->limit = @$argv['limit'];
if (!$this->limit) {
$this->limit = 10;
} elseif ($this->limit > 100) {
$this->limit = 100;
}
$this->unique = @$argv['unique'];
if ($this->unique === 'false' || $this->unique === 'no' || $this->unique === '0') {
$this->unique = false;
}
$this->namespaces = @$argv['namespaces'];
if (!is_null($this->namespaces)) {
$this->namespaces = preg_split('!\\s*(\\|\\s*)+!', trim($this->namespaces));
foreach ($this->namespaces as $i => $ns) {
$ns = $wgContLang->lc($ns);
if ($ns === '-' || $ns === '0' || $ns === 'main' || $ns === 'article') {
$this->namespaces[$i] = 0;
} else {
$this->namespaces[$i] = MWNamespace::getCanonicalIndex($ns);
if ($this->namespaces[$i] === false || $this->namespaces[$i] === null) {
$this->namespaces[$i] = $wgContLang->getNsIndex($ns);
}
}
if ($this->namespaces[$i] === false || $this->namespaces[$i] === null) {
unset($this->namespaces[$i]);
}
}
}
$this->categories = @$argv['categories'];
if (!is_null($this->categories)) {
$this->categories = preg_split('!\\s*(\\|\\s*)+!', trim($this->categories));
foreach ($this->categories as $i => $n) {
$t = Title::makeTitleSafe(NS_CATEGORY, $n);
$n = $t->getDBkey();
$this->categories[$i] = $n;
}
}
$this->pubtrigger = @$argv['trigger'];
if ($this->pubtrigger) {
$this->publication = true;
} else {
$this->publication = false;
}
$this->permalinks = @$argv['permalinks'];
if ($this->permalinks === 'false' || $this->permalinks === 'no' || $this->permalinks === '0') {
$this->permalinks = false;
}
$this->nominor = @$argv['nominor'];
if ($this->nominor === 'false' || $this->nominor === 'no' || $this->nominor === '0') {
$this->nominor = false;
}
$this->nobot = @$argv['nobot'];
if ($this->nobot === 'false' || $this->nobot === 'no' || $this->nobot === '0') {
$this->nobot = false;
}
$this->noanon = @$argv['noanon'];
if ($this->noanon === 'false' || $this->noanon === 'no' || $this->noanon === '0') {
$this->noanon = false;
//.........这里部分代码省略.........
示例14: loadFromFileCache
/**
* Read from cache to context output
* @param IContextSource $context
* @param integer $mode One of the HTMLFileCache::MODE_* constants
* @return void
*/
public function loadFromFileCache(IContextSource $context, $mode = self::MODE_NORMAL)
{
global $wgContLang;
$config = MediaWikiServices::getInstance()->getMainConfig();
wfDebug(__METHOD__ . "()\n");
$filename = $this->cachePath();
if ($mode === self::MODE_OUTAGE) {
// Avoid DB errors for queries in sendCacheControl()
$context->getTitle()->resetArticleID(0);
}
$context->getOutput()->sendCacheControl();
header("Content-Type: {$config->get('MimeType')}; charset=UTF-8");
header("Content-Language: {$wgContLang->getHtmlCode()}");
if ($this->useGzip()) {
if (wfClientAcceptsGzip()) {
header('Content-Encoding: gzip');
readfile($filename);
} else {
/* Send uncompressed */
wfDebug(__METHOD__ . " uncompressing cache file and sending it\n");
readgzfile($filename);
}
} else {
readfile($filename);
}
$context->getOutput()->disable();
// tell $wgOut that output is taken care of
}
示例15: profilePreferences
/**
* @param $user User
* @param $context IContextSource
* @param $defaultPreferences
* @return void
*/
static function profilePreferences( $user, IContextSource $context, &$defaultPreferences ) {
global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode,
$wgDisableTitleConversion, $wgDisableLangConversion, $wgMaxSigChars,
$wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication,
$wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress,
$wgSecureLogin;
// retrieving user name for GENDER and misc.
$userName = $user->getName();
## User info #####################################
// Information panel
$defaultPreferences['username'] = array(
'type' => 'info',
'label-message' => array( 'username', $userName ),
'default' => $userName,
'section' => 'personal/info',
);
$defaultPreferences['userid'] = array(
'type' => 'info',
'label-message' => array( 'uid', $userName ),
'default' => $user->getId(),
'section' => 'personal/info',
);
# Get groups to which the user belongs
$userEffectiveGroups = $user->getEffectiveGroups();
$userGroups = $userMembers = array();
foreach ( $userEffectiveGroups as $ueg ) {
if ( $ueg == '*' ) {
// Skip the default * group, seems useless here
continue;
}
$groupName = User::getGroupName( $ueg );
$userGroups[] = User::makeGroupLinkHTML( $ueg, $groupName );
$memberName = User::getGroupMember( $ueg, $userName );
$userMembers[] = User::makeGroupLinkHTML( $ueg, $memberName );
}
asort( $userGroups );
asort( $userMembers );
$lang = $context->getLanguage();
$defaultPreferences['usergroups'] = array(
'type' => 'info',
'label' => $context->msg( 'prefs-memberingroups' )->numParams(
count( $userGroups ) )->params( $userName )->parse(),
'default' => $context->msg( 'prefs-memberingroups-type',
$lang->commaList( $userGroups ),
$lang->commaList( $userMembers )
)->plain(),
'raw' => true,
'section' => 'personal/info',
);
$editCount = Linker::link( SpecialPage::getTitleFor( "Contributions", $userName ),
$lang->formatNum( $user->getEditCount() ) );
$defaultPreferences['editcount'] = array(
'type' => 'info',
'raw' => true,
'label-message' => 'prefs-edits',
'default' => $editCount,
'section' => 'personal/info',
);
if ( $user->getRegistration() ) {
$displayUser = $context->getUser();
$userRegistration = $user->getRegistration();
$defaultPreferences['registrationdate'] = array(
'type' => 'info',
'label-message' => 'prefs-registration',
'default' => $context->msg(
'prefs-registration-date-time',
$lang->userTimeAndDate( $userRegistration, $displayUser ),
$lang->userDate( $userRegistration, $displayUser ),
$lang->userTime( $userRegistration, $displayUser )
)->parse(),
'section' => 'personal/info',
);
}
$canViewPrivateInfo = $user->isAllowed( 'viewmyprivateinfo' );
$canEditPrivateInfo = $user->isAllowed( 'editmyprivateinfo' );
// Actually changeable stuff
$defaultPreferences['realname'] = array(
// (not really "private", but still shouldn't be edited without permission)
'type' => $canEditPrivateInfo && $wgAuth->allowPropChange( 'realname' ) ? 'text' : 'info',
'default' => $user->getRealName(),
'section' => 'personal/info',
'label-message' => 'yourrealname',
//.........这里部分代码省略.........