本文整理汇总了PHP中IContextSource类的典型用法代码示例。如果您正苦于以下问题:PHP IContextSource类的具体用法?PHP IContextSource怎么用?PHP IContextSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IContextSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:whysasse,项目名称:kmwiki,代码行数:38,代码来源:SpamBlacklistHooks.php
示例2: __construct
/**
* Generates a brief review form for a page
* @param \IContextSource|\RequestContext $context
* @param FlaggableWikiPage $article
* @param Revision $rev
*/
public function __construct(IContextSource $context, FlaggableWikiPage $article, Revision $rev)
{
$this->user = $context->getUser();
$this->request = $context->getRequest();
$this->article = $article;
$this->rev = $rev;
}
开发者ID:crippsy14,项目名称:orange-smorange,代码行数:13,代码来源:RevisionReviewFormUI.php
示例3: __construct
function __construct(IContextSource $context, $userName = null, $search = '', $including = false)
{
global $wgMiserMode;
$this->mIncluding = $including;
if ($userName) {
$nt = Title::newFromText($userName, NS_USER);
if (!is_null($nt)) {
$this->mUserName = $nt->getText();
$this->mQueryConds['img_user_text'] = $this->mUserName;
}
}
if ($search != '' && !$wgMiserMode) {
$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 ($context->getRequest()->getText('sort', 'img_date') == 'img_date') {
$this->mDefaultDirection = true;
} else {
$this->mDefaultDirection = false;
}
} else {
$this->mDefaultDirection = true;
}
parent::__construct($context);
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:SpecialListfiles.php
示例4: getDisplayNameMessage
public function getDisplayNameMessage(\IContextSource $context)
{
if ($this->getType() === self::TYPE_FEATURED) {
return $context->msg('cx-suggestionlist-featured');
}
return new \RawMessage($this->getName());
}
开发者ID:Rjaylyn,项目名称:mediawiki-extensions-ContentTranslation,代码行数:7,代码来源:SuggestionList.php
示例5: addNavigationLinks
/**
* @param $context IContextSource
* @param $pageType
*/
public static function addNavigationLinks(IContextSource $context, $pageType)
{
$linkDefs = array('home' => 'Special:AbuseFilter', 'recentchanges' => 'Special:AbuseFilter/history', 'examine' => 'Special:AbuseFilter/examine', 'log' => 'Special:AbuseLog');
if ($context->getUser()->isAllowed('abusefilter-modify')) {
$linkDefs = array_merge($linkDefs, array('test' => 'Special:AbuseFilter/test', 'tools' => 'Special:AbuseFilter/tools', 'import' => 'Special:AbuseFilter/import'));
}
// Save some translator work
$msgOverrides = array('recentchanges' => 'abusefilter-filter-log');
$links = array();
foreach ($linkDefs as $name => $page) {
// Give grep a chance to find the usages:
// abusefilter-topnav-home, abusefilter-topnav-test, abusefilter-topnav-examine
// abusefilter-topnav-log, abusefilter-topnav-tools, abusefilter-topnav-import
$msgName = "abusefilter-topnav-{$name}";
if (isset($msgOverrides[$name])) {
$msgName = $msgOverrides[$name];
}
$msg = wfMessage($msgName)->parse();
$title = Title::newFromText($page);
if ($name == $pageType) {
$links[] = Xml::tags('strong', null, $msg);
} else {
$links[] = Linker::link($title, $msg);
}
}
$linkStr = wfMessage('parentheses', $context->getLanguage()->pipeList($links))->text();
$linkStr = wfMessage('abusefilter-topnav')->parse() . " {$linkStr}";
$linkStr = Xml::tags('div', array('class' => 'mw-abusefilter-navigation'), $linkStr);
$context->getOutput()->setSubtitle($linkStr);
}
开发者ID:aahashderuffy,项目名称:extensions,代码行数:34,代码来源:AbuseFilter.class.php
示例6: __construct
function __construct(IContextSource $context, $par = null)
{
$this->like = $context->getRequest()->getText('like');
$this->showbots = $context->getRequest()->getBool('showbots', 0);
if (is_numeric($par)) {
$this->setLimit($par);
}
parent::__construct($context);
}
开发者ID:whysasse,项目名称:kmwiki,代码行数:9,代码来源:SpecialNewimages.php
示例7: __construct
/**
* Constructor.
*
* @param IContextSource $context
* @param array $conds
* @param string $className
*/
public function __construct(IContextSource $context, array $conds, $className)
{
$this->conds = $conds;
$this->className = $className;
$this->context = $context;
$this->mDefaultDirection = true;
parent::__construct($context);
$this->context->getOutput()->addModules('ep.pager');
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:16,代码来源:EPPager.php
示例8: displayPager
/**
* Display a pager with articles.
*
* @since 0.1
*
* @param IContextSource $context
* @param array $conditions
*/
public static function displayPager(IContextSource $context, array $conditions = array())
{
$pager = new EPArticlePager($context, $conditions);
if ($pager->getNumRows()) {
$context->getOutput()->addHTML($pager->getFilterControl() . $pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar() . $pager->getMultipleItemControl());
} else {
$context->getOutput()->addHTML($pager->getFilterControl(true));
$context->getOutput()->addWikiMsg('ep-articles-noresults');
}
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:18,代码来源:EPArticle.php
示例9: useExternalEngine
/**
* Check whether external edit or diff should be used.
*
* @param $context IContextSource context to use
* @param $type String can be either 'edit' or 'diff'
* @return Bool
*/
public static function useExternalEngine(IContextSource $context, $type)
{
global $wgUseExternalEditor;
if (!$wgUseExternalEditor) {
return false;
}
$pref = $type == 'diff' ? 'externaldiff' : 'externaleditor';
$request = $context->getRequest();
return !$request->getVal('internaledit') && ($context->getUser()->getOption($pref) || $request->getVal('externaledit'));
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:17,代码来源:ExternalEdit.php
示例10: newFromContext
/**
* Fetch an appropriate changes list class for the specified context
* Some users might want to use an enhanced list format, for instance
*
* @param $context IContextSource to use
* @return ChangesList|EnhancedChangesList|OldChangesList derivative
*/
public static function newFromContext( IContextSource $context ) {
$user = $context->getUser();
$sk = $context->getSkin();
$list = null;
if ( wfRunHooks( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) {
$new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
return $new ? new EnhancedChangesList( $context ) : new OldChangesList( $context );
} else {
return $list;
}
}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:18,代码来源:ChangesList.php
示例11: __construct
/**
* @param IContextSource|Skin $obj
* @throws MWException
*/
public function __construct($obj)
{
if ($obj instanceof Skin) {
// @todo: deprecate constructing with Skin
$context = $obj->getContext();
} else {
if (!$obj instanceof IContextSource) {
throw new MWException('EnhancedChangesList must be constructed with a ' . 'context source or skin.');
}
$context = $obj;
}
parent::__construct($context);
// message is set by the parent ChangesList class
$this->cacheEntryFactory = new RCCacheEntryFactory($context, $this->message);
}
开发者ID:D66Ha,项目名称:mediawiki,代码行数:19,代码来源:EnhancedChangesList.php
示例12: __construct
function __construct(IContextSource $context, $userName = null, $search = '', $including = false, $showAll = false)
{
$this->mIncluding = $including;
$this->mShowAll = $showAll;
if ($userName) {
$nt = Title::newFromText($userName, NS_USER);
if (!is_null($nt)) {
$this->mUserName = $nt->getText();
}
}
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 ($context->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:whysasse,项目名称:kmwiki,代码行数:29,代码来源:SpecialListfiles.php
示例13: getHelp
/**
* Generate help for the specified modules
*
* Help is placed into the OutputPage object returned by
* $context->getOutput().
*
* Recognized options include:
* - headerlevel: (int) Header tag level
* - nolead: (bool) Skip the inclusion of api-help-lead
* - noheader: (bool) Skip the inclusion of the top-level section headers
* - submodules: (bool) Include help for submodules of the current module
* - recursivesubmodules: (bool) Include help for submodules recursively
* - helptitle: (string) Title to link for additional modules' help. Should contain $1.
* - toc: (bool) Include a table of contents
*
* @param IContextSource $context
* @param ApiBase[]|ApiBase $modules
* @param array $options Formatting options (described above)
* @return string
*/
public static function getHelp(IContextSource $context, $modules, array $options)
{
global $wgContLang;
if (!is_array($modules)) {
$modules = array($modules);
}
$out = $context->getOutput();
$out->addModuleStyles('mediawiki.hlist');
$out->addModuleStyles('mediawiki.apihelp');
if (!empty($options['toc'])) {
$out->addModules('mediawiki.toc');
}
$out->setPageTitle($context->msg('api-help-title'));
$cache = ObjectCache::getMainWANInstance();
$cacheKey = null;
if (count($modules) == 1 && $modules[0] instanceof ApiMain && $options['recursivesubmodules'] && $context->getLanguage() === $wgContLang) {
$cacheHelpTimeout = $context->getConfig()->get('APICacheHelpTimeout');
if ($cacheHelpTimeout > 0) {
// Get help text from cache if present
$cacheKey = wfMemcKey('apihelp', $modules[0]->getModulePath(), (int) (!empty($options['toc'])), str_replace(' ', '_', SpecialVersion::getVersion('nodb')));
$cached = $cache->get($cacheKey);
if ($cached) {
$out->addHTML($cached);
return;
}
}
}
if ($out->getHTML() !== '') {
// Don't save to cache, there's someone else's content in the page
// already
$cacheKey = null;
}
$options['recursivesubmodules'] = !empty($options['recursivesubmodules']);
$options['submodules'] = $options['recursivesubmodules'] || !empty($options['submodules']);
// Prepend lead
if (empty($options['nolead'])) {
$msg = $context->msg('api-help-lead');
if (!$msg->isDisabled()) {
$out->addHTML($msg->parseAsBlock());
}
}
$haveModules = array();
$html = self::getHelpInternal($context, $modules, $options, $haveModules);
if (!empty($options['toc']) && $haveModules) {
$out->addHTML(Linker::generateTOC($haveModules, $context->getLanguage()));
}
$out->addHTML($html);
$helptitle = isset($options['helptitle']) ? $options['helptitle'] : null;
$html = self::fixHelpLinks($out->getHTML(), $helptitle, $haveModules);
$out->clearHTML();
$out->addHTML($html);
if ($cacheKey !== null) {
$cache->set($cacheKey, $out->getHTML(), $cacheHelpTimeout);
}
}
开发者ID:paladox,项目名称:2,代码行数:75,代码来源:ApiHelp.php
示例14: getHtml
/**
* @param IContextSource $context
*
* @return string HTML
*/
public function getHtml(IContextSource $context)
{
$context->getOutput()->addModules('ext.translate.statsbar');
$total = $this->stats[MessageGroupStats::TOTAL];
$proofread = $this->stats[MessageGroupStats::PROOFREAD];
$translated = $this->stats[MessageGroupStats::TRANSLATED];
$fuzzy = $this->stats[MessageGroupStats::FUZZY];
if (!$total) {
$untranslated = null;
$wproofread = $wtranslated = $wfuzzy = $wuntranslated = 0;
} else {
// Proofread is subset of translated
$untranslated = $total - $translated - $fuzzy;
$wproofread = round(100 * $proofread / $total, 2);
$wtranslated = round(100 * ($translated - $proofread) / $total, 2);
$wfuzzy = round(100 * $fuzzy / $total, 2);
$wuntranslated = round(100 - $wproofread - $wtranslated - $wfuzzy, 2);
}
return Html::rawElement('div', array('class' => 'tux-statsbar', 'data-total' => $total, 'data-group' => $this->group, 'data-language' => $this->language), Html::element('span', array('class' => 'tux-proofread', 'style' => "width: {$wproofread}%", 'data-proofread' => $proofread)) . Html::element('span', array('class' => 'tux-translated', 'style' => "width: {$wtranslated}%", 'data-translated' => $translated)) . Html::element('span', array('class' => 'tux-fuzzy', 'style' => "width: {$wfuzzy}%", 'data-fuzzy' => $fuzzy)) . Html::element('span', array('class' => 'tux-untranslated', 'style' => "width: {$wuntranslated}%", 'data-untranslated' => $untranslated)));
}
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:25,代码来源:StatsBar.php
示例15: getDescription
/**
* MediaWiki extensions all should have key in their i18n files
* describing them. This override method implements the logic
* to retrieve them. Also URLs are included if available.
* Needs the Configure extension.
* @param IContextSource $context
* @return string
*/
public function getDescription(IContextSource $context = null)
{
$language = $this->getSourceLanguage();
if ($context) {
$language = $context->getLanguage()->getCode();
}
$msgkey = $this->getFromConf('BASIC', 'descriptionmsg');
$desc = '';
if ($msgkey) {
$desc = $this->getMessage($msgkey, $language);
if (strval($desc) === '') {
$desc = $this->getMessage($msgkey, $this->getSourceLanguage());
}
}
if (strval($desc) === '') {
// That failed, default to 'description'
$desc = parent::getDescription($context);
}
$url = $this->getFromConf('BASIC', 'extensionurl');
if ($url) {
$desc .= "\n\n{$url}";
}
return $desc;
}
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:32,代码来源:MediaWikiExtensionMessageGroup.php
示例16: onRequestContextCreateSkin
/**
* RequestContextCreateSkin hook handler
* @see https://www.mediawiki.org/wiki/Manual:Hooks/RequestContextCreateSkin
*
* @param IContextSource $context
* @param Skin $skin
* @return bool
*/
public static function onRequestContextCreateSkin($context, &$skin)
{
// FIXME: This shouldn't be a global, it should be possible for other extensions
// to set this via a static variable or set function in ULS
global $wgULSPosition;
$mobileContext = MobileContext::singleton();
$mobileContext->doToggling();
if (!$mobileContext->shouldDisplayMobileView() || $mobileContext->isBlacklistedPage()) {
return true;
}
// enable wgUseMediaWikiUIEverywhere
self::enableMediaWikiUI();
// FIXME: Remove hack around Universal Language selector bug 57091
$wgULSPosition = 'none';
// Handle any X-Analytics header values in the request by adding them
// as log items. X-Analytics header values are serialized key=value
// pairs, separated by ';', used for analytics purposes.
if ($xanalytics = $mobileContext->getRequest()->getHeader('X-Analytics')) {
$xanalytics_arr = explode(';', $xanalytics);
if (count($xanalytics_arr) > 1) {
foreach ($xanalytics_arr as $xanalytics_item) {
$mobileContext->addAnalyticsLogItemFromXAnalytics($xanalytics_item);
}
} else {
$mobileContext->addAnalyticsLogItemFromXAnalytics($xanalytics);
}
}
// log whether user is using alpha/beta/stable
$mobileContext->logMobileMode();
$skinName = $mobileContext->getMFConfig()->get('MFDefaultSkinClass');
$betaSkinName = $skinName . 'Beta';
$alphaSkinName = $skinName . 'Alpha';
// Force alpha for test mode to sure all modules can run
$name = $context->getTitle()->getDBkey();
$inTestMode = $name === SpecialPage::getTitleFor('JavaScriptTest', 'qunit')->getDBkey();
if (($mobileContext->isAlphaGroupMember() || $inTestMode) && class_exists($alphaSkinName)) {
$skinName = $alphaSkinName;
} elseif ($mobileContext->isBetaGroupMember() && class_exists($betaSkinName)) {
$skinName = $betaSkinName;
}
$skin = new $skinName($context);
return false;
}
开发者ID:GoProjectOwner,项目名称:mediawiki-extensions-MobileFrontend,代码行数:51,代码来源:MobileFrontend.hooks.php
示例17: onGetEmailAuthentication
public static function onGetEmailAuthentication(User &$user, IContextSource $context, &$disableEmailPrefs, &$emailauthenticated)
{
if ($user->getEmail()) {
$emailTimestamp = $user->getEmailAuthenticationTimestamp();
$optionNewEmail = $user->getGlobalAttribute('new_email');
$msgKeyPrefixEmail = empty($optionNewEmail) && !$emailTimestamp ? 'usersignup-user-pref-unconfirmed-' : 'usersignup-user-pref-';
if (empty($optionNewEmail) && $emailTimestamp) {
$lang = $context->getLanguage();
$displayUser = $context->getUser();
$time = $lang->userTimeAndDate($emailTimestamp, $displayUser);
$d = $lang->userDate($emailTimestamp, $displayUser);
$t = $lang->userTime($emailTimestamp, $displayUser);
$emailauthenticated = $context->msg($msgKeyPrefixEmail . 'emailauthenticated', $time, $d, $t)->parse() . '<br />';
$disableEmailPrefs = false;
} else {
$disableEmailPrefs = true;
$emailauthenticated = $context->msg($msgKeyPrefixEmail . 'emailnotauthenticated', array($optionNewEmail))->parse() . '<br />' . Linker::linkKnown(SpecialPage::getTitleFor('Confirmemail'), $context->msg('usersignup-user-pref-emailconfirmlink')->escaped()) . '<br />';
}
} else {
$disableEmailPrefs = true;
$emailauthenticated = $context->msg('usersignup-user-pref-noemailprefs')->escaped();
}
return true;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:24,代码来源:UserLoginHooksHelper.class.php
示例18: getTimezoneOptions
/**
* @param $context IContextSource
* @return array
*/
static function getTimezoneOptions( IContextSource $context ) {
$opt = array();
global $wgLocalTZoffset;
$timestamp = MWTimestamp::getLocalInstance();
// Check that $wgLocalTZoffset is the same as the local time zone offset
if ( $wgLocalTZoffset == $timestamp->format( 'Z' ) / 60 ) {
$server_tz_msg = $context->msg( 'timezoneuseserverdefault', $timestamp->getTimezone()->getName() )->text();
} else {
$tzstring = sprintf( '%+03d:%02d', floor( $wgLocalTZoffset / 60 ), abs( $wgLocalTZoffset ) % 60 );
$server_tz_msg = $context->msg( 'timezoneuseserverdefault', $tzstring )->text();
}
$opt[$server_tz_msg] = "System|$wgLocalTZoffset";
$opt[$context->msg( 'timezoneuseoffset' )->text()] = 'other';
$opt[$context->msg( 'guesstimezone' )->text()] = 'guess';
if ( function_exists( 'timezone_identifiers_list' ) ) {
# Read timezone list
$tzs = timezone_identifiers_list();
sort( $tzs );
$tzRegions = array();
$tzRegions['Africa'] = $context->msg( 'timezoneregion-africa' )->text();
$tzRegions['America'] = $context->msg( 'timezoneregion-america' )->text();
$tzRegions['Antarctica'] = $context->msg( 'timezoneregion-antarctica' )->text();
$tzRegions['Arctic'] = $context->msg( 'timezoneregion-arctic' )->text();
$tzRegions['Asia'] = $context->msg( 'timezoneregion-asia' )->text();
$tzRegions['Atlantic'] = $context->msg( 'timezoneregion-atlantic' )->text();
$tzRegions['Australia'] = $context->msg( 'timezoneregion-australia' )->text();
$tzRegions['Europe'] = $context->msg( 'timezoneregion-europe' )->text();
$tzRegions['Indian'] = $context->msg( 'timezoneregion-indian' )->text();
$tzRegions['Pacific'] = $context->msg( 'timezoneregion-pacific' )->text();
asort( $tzRegions );
$prefill = array_fill_keys( array_values( $tzRegions ), array() );
$opt = array_merge( $opt, $prefill );
$now = date_create( 'now' );
foreach ( $tzs as $tz ) {
$z = explode( '/', $tz, 2 );
# timezone_identifiers_list() returns a number of
# backwards-compatibility entries. This filters them out of the
# list presented to the user.
if ( count( $z ) != 2 || !array_key_exists( $z[0], $tzRegions ) ) {
continue;
}
# Localize region
$z[0] = $tzRegions[$z[0]];
$minDiff = floor( timezone_offset_get( timezone_open( $tz ), $now ) / 60 );
$display = str_replace( '_', ' ', $z[0] . '/' . $z[1] );
$value = "ZoneInfo|$minDiff|$tz";
$opt[$z[0]][$display] = $value;
}
}
return $opt;
}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:66,代码来源:Preferences.php
示例19: capturePath
/**
* Just like executePath() but will override global variables and execute
* the page in "inclusion" mode. Returns true if the execution was
* successful or false if there was no such special page, or a title object
* if it was a redirect.
*
* Also saves the current $wgTitle, $wgOut, $wgRequest, $wgUser and $wgLang
* variables so that the special page will get the context it'd expect on a
* normal request, and then restores them to their previous values after.
*
* @param $title Title
* @param $context IContextSource
*
* @return String: HTML fragment
*/
static function capturePath(Title $title, IContextSource $context)
{
global $wgOut, $wgTitle, $wgRequest, $wgUser, $wgLang;
// Save current globals
$oldTitle = $wgTitle;
$oldOut = $wgOut;
$oldRequest = $wgRequest;
$oldUser = $wgUser;
$oldLang = $wgLang;
// Set the globals to the current context
$wgTitle = $title;
$wgOut = $context->getOutput();
$wgRequest = $context->getRequest();
$wgUser = $context->getUser();
$wgLang = $context->getLanguage();
// The useful part
$ret = self::executePath($title, $context, true);
// And restore the old globals
$wgTitle = $oldTitle;
$wgOut = $oldOut;
$wgRequest = $oldRequest;
$wgUser = $oldUser;
$wgLang = $oldLang;
return $ret;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:40,代码来源:SpecialPageFactory.php
示例20: onLoggableUserIPData
/**
* Handler for non-standard (edit/log) entries that need IP data
*
* @param $context IContextSource
* @param $data Array
* @return bool
*/
protected static function onLoggableUserIPData(IContextSource $context, array $data)
{
$user = $context->getUser();
$request = $context->getRequest();
// Get IP address
$ip = $request->getIP();
// Get XFF header
$xff = $request->getHeader('X-Forwarded-For');
list($xff_ip, $isSquidOnly) = IP::getClientIPfromXFF($xff);
// Get agent
$agent = $request->getHeader('User-Agent');
$dbw = wfGetDB(DB_MASTER);
$cuc_id = $dbw->nextSequenceValue('cu_changes_cu_id_seq');
$rcRow = array('cuc_id' => $cuc_id, 'cuc_page_id' => $data['pageid'], 'cuc_namespace' => $data['namespace'], 'cuc_title' => $data['title'], 'cuc_minor' => 0, 'cuc_user' => $user->getId(), 'cuc_user_text' => $user->getName(), 'cuc_actiontext' => $data['action'], 'cuc_comment' => $data['comment'], 'cuc_this_oldid' => 0, 'cuc_last_oldid' => 0, 'cuc_type' => RC_LOG, 'cuc_timestamp' => $dbw->timestamp($data['timestamp']), 'cuc_ip' => IP::sanitizeIP($ip), 'cuc_ip_hex' => $ip ? IP::toHex($ip) : null, 'cuc_xff' => !$isSquidOnly ? $xff : '', 'cuc_xff_hex' => $xff_ip && !$isSquidOnly ? IP::toHex($xff_ip) : null, 'cuc_agent' => $agent);
$dbw->insert('cu_changes', $rcRow, __METHOD__);
return true;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:24,代码来源:CheckUser.hooks.php
注:本文中的IContextSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论