本文整理汇总了PHP中IContextSource类的典型用法代码示例。如果您正苦于以下问题:PHP IContextSource类的具体用法?PHP IContextSource怎么用?PHP IContextSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IContextSource类的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: __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;
}
示例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);
}
示例4: getDisplayNameMessage
public function getDisplayNameMessage(\IContextSource $context)
{
if ($this->getType() === self::TYPE_FEATURED) {
return $context->msg('cx-suggestionlist-featured');
}
return new \RawMessage($this->getName());
}
示例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);
}
示例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);
}
示例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');
}
示例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');
}
}
示例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'));
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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)));
}
示例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;
}