public static function addNavigationLinks(IContextSource $context, $pageType) { $linkDefs = array('home' => 'Special:AbuseFilter', 'recentchanges' => 'Special:AbuseFilter/history', 'test' => 'Special:AbuseFilter/test', 'examine' => 'Special:AbuseFilter/examine', 'log' => 'Special:AbuseLog'); if ($context->getUser()->isAllowed('abusefilter-modify')) { $linkDefs = array_merge($linkDefs, array('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 = wfMsgExt($msgName, 'parseinline'); $title = Title::newFromText($page); if ($name == $pageType) { $links[] = Xml::tags('strong', null, $msg); } else { $links[] = $context->getSkin()->link($title, $msg); } } $linkStr = wfMsg('parentheses', $context->getLanguage()->pipeList($links)); $linkStr = wfMsgExt('abusefilter-topnav', 'parseinline') . " {$linkStr}"; $linkStr = Xml::tags('div', array('class' => 'mw-abusefilter-navigation'), $linkStr); $context->getOutput()->setSubtitle($linkStr); }
/** * 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; } }
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; } $this->notalk = @$argv['notalk']; if ($this->notalk === 'false' || $this->notalk === 'no' || $this->notalk === '0') { $this->notalk = false; } $this->onlypatrolled = @$argv['onlypatrolled']; if ($this->onlypatrolled === 'false' || $this->onlypatrolled === 'no' || $this->onlypatrolled === '0') { $this->onlypatrolled = false; } $this->onlynew = @$argv['onlynew']; if ($this->onlynew === 'false' || $this->onlynew === 'no' || $this->onlynew === '0') { $this->onlynew = false; } $this->types = array(RC_EDIT, RC_NEW); /* this doesn't work right if ( $unique ) { $group[] = 'rc_namespace AND rc_title'; } */ }