30 const URL =
'https://github.com/bovender/LinkTitles';
38 $isMinor, $isWatch, $section, &$flags, &$status ) {
40 if ( !$config->parseOnEdit || $isMinor )
return true;
41 $source = Source::createFromPageandContent( $wikiPage, $content, $config );
42 $linker =
new Linker( $config );
43 $result = $linker->linkContent( $source );
45 $content = $source->setText( $result );
55 public static function onInternalParseBeforeLinks( \Parser &$parser, &$text ) {
57 if ( !$config->parseOnRender )
return true;
58 $title = $parser->getTitle();
59 $source = Source::createFromParserAndText( $parser, $text, $config );
60 $linker =
new Linker( $config );
61 $result = $linker->linkContent( $source );
77 public static function processPage( \Title $title, \RequestContext $context ) {
79 $source = Source::createFromTitle( $title, $config );
80 if ( $source->hasContent() ) {
81 $linker =
new Linker( $config );
82 $result = $linker->linkContent( $source );
84 $content = $source->getContent()->getContentHandler()->unserializeContent( $result );
85 $source->getPage()->doEditContent(
87 \wfMessage(
'linktitles-bot-comment', self::URL ),
88 EDIT_MINOR | EDIT_FORCE_BOT,
108 public static function onGetDoubleUnderscoreIDs( array &$doubleUnderscoreIDs ) {
109 $doubleUnderscoreIDs[] =
'MAG_LINKTITLES_NOTARGET';
110 $doubleUnderscoreIDs[] =
'MAG_LINKTITLES_NOAUTOLINKS';
119 $parser->setHook(
'noautolinks',
'LinkTitles\Extension::doNoautolinksTag' );
120 $parser->setHook(
'autolinks',
'LinkTitles\Extension::doAutolinksTag' );
128 public static function doNoautolinksTag( $input, array $args, \Parser $parser, \PPFrame $frame ) {
130 $result = $parser->recursiveTagParse( $input, $frame );
140 public static function doAutolinksTag( $input, array $args, \Parser $parser, \PPFrame $frame ) {
142 $linker =
new Linker( $config );
143 $source = Source::createFromParserAndText( $parser, $input, $config );
145 $result = $linker->linkContent( $source );
148 return $parser->recursiveTagParse( $result, $frame );
150 return $parser->recursiveTagParse( $input, $frame );
Provides event handlers and entry points for the extension.
static processPage(\Title $title,\RequestContext $context)
Adds links to a single page.
Holds LinkTitles configuration.
The LinkTitles class holds configuration for the LinkTitles extension.
static onParserFirstCallInit(\Parser $parser)
Handles the ParserFirstCallInit hook and adds the <autolink>/</noautolink> tags.
Performs the actual linking of content to existing pages.
static onPageContentSave(&$wikiPage, &$user, &$content, &$summary, $isMinor, $isWatch, $section, &$flags, &$status)
Event handler for the PageContentSave hook.