51 $source =
new Source( $config );
52 $source->title = $title;
68 $source = Source::createFromTitle( $title, $config);
69 $source->text = $text;
85 $source =
new Source( $config );
86 $source->page = $page;
87 $source->content = $content;
99 $source =
new Source( $config );
100 $source->title = $parser->getTitle();
116 $source = Source::createFromParser( $parser, $config );
117 $source->text = $text;
126 $this->config = $config;
134 return $this->hasDesiredNamespace() && !$this->hasNoAutolinksMagicWord();
143 return in_array( $this->getTitle()->getNamespace(), $this->config->sourceNamespaces );
152 return \MagicWord::get(
'MAG_LINKTITLES_NOAUTOLINKS' )->match( $this->getText() );
161 if ( $this->title === null ) {
163 if ( $this->page != null) {
164 $this->title = $this->page->getTitle();
166 throw new Exception(
'Unable to create Title for this Source because Page is null.' );
177 return $this->getTitle()->getNamespace();
188 if ( $this->content === null ) {
189 $this->content = $this->getPage()->getContent();
191 return $this->content;
200 return $this->getContent() != null;
211 if ( $this->text === null ) {
212 $content = $this->getContent();
213 $this->text = $content->getContentHandler()->serializeContent( $content );
225 $this->content = $this->content->getContentHandler()->unserializeContent( $text );
227 return $this->content;
235 if ( $this->page === null ) {
237 if ( $this->title != null) {
238 $this->page = \WikiPage::factory( $this->title );
240 throw new Exception(
'Unable to create Page for this Source because Title is null.' );
getContent()
Gets the Content object for the source page.
__construct(Config $config)
Private constructor.
canBeLinked()
Determines whether or not this page may be linked to.
getTitle()
Gets the title.
static createFromPageandContent(\WikiPage $page,\Content $content, Config $config)
Creates a Source object with a given WikiPage and a Content.
static createFromParser(\Parser $parser, Config $config)
Creates a Source object with a given Parser.
hasDesiredNamespace()
Determines whether the Source is in a desired namespace, i.e.
getText()
Gets the text of the corresponding Wiki page.
getPage()
Returns the source page object.
static createFromTitle(\Title $title, Config $config)
Creates a Source object from a .
static createFromParserAndText(\Parser $parser, $text, Config $config)
Creates a Source object with a given Parser and text.
setText($text)
Unserializes text to the page's content.
Holds LinkTitles configuration.
static createFromTitleAndText(\Title $title, $text, Config $config)
Creates a Source object with a given Title and a text.
getNamespace()
Gets the namespace of the source Title.
$config
The LinKTitles configuration for this Source.
The LinkTitles class holds configuration for the LinkTitles extension.
hasNoAutolinksMagicWord()
Determines whether the source page contains the NOAUTOLINKS magic word.
hasContent()
Determines whether the source page has content.
Represents a page that is a potential link target.