51 $sect =
$wgParser->getSection( $text, $sectionId,
false );
53 if ( $sect ===
false ) {
56 return new static( $sect );
75 if ( $sectionModelId != $myModelId ) {
76 throw new MWException(
"Incompatible content model for section: " .
77 "document uses $myModelId but " .
78 "section uses $sectionModelId." );
84 if ( strval( $sectionId ) ===
'' ) {
85 return $with; # XXX:
copy first?
88 if ( $sectionId ===
'new' ) {
89 # Inserting a new section
90 $subject = $sectionTitle ?
wfMessage(
'newsectionheaderdefaultlevel' )
91 ->rawParams( $sectionTitle )->inContentLanguage()->text() .
"\n\n" :
'';
92 if ( Hooks::run(
'PlaceNewSection', [ $this, $oldtext, $subject, &$text ] ) ) {
93 $text = strlen( trim( $oldtext ) ) > 0
94 ?
"{$oldtext}\n\n{$subject}{$text}"
95 :
"{$subject}{$text}";
98 # Replacing an existing section; roll out the big guns
101 $text =
$wgParser->replaceSection( $oldtext, $sectionId, $text );
104 $newContent =
new static( $text );
118 $text =
wfMessage(
'newsectionheaderdefaultlevel' )
119 ->rawParams(
$header )->inContentLanguage()->text();
123 return new static( $text );
142 return ( $text === $pst ) ? $this :
new static( $pst );
161 return new static( $plt );
176 if ( $this->redirectTargetAndText !==
null ) {
182 $this->redirectTargetAndText = [
null, $this->
getNativeData() ];
188 if ( $redir->matchStartAndRemove( $text ) ) {
193 if ( preg_match(
'!^\s*:?\s*\[{2}(.*?)(?:\|.*?)?\]{2}\s*!', $text, $m ) ) {
196 if ( strpos( $m[1],
'%' ) !==
false ) {
198 $m[1] = rawurldecode( ltrim( $m[1],
':' ) );
200 $title = Title::newFromText( $m[1] );
203 $this->redirectTargetAndText = [
null, $this->
getNativeData() ];
207 $this->redirectTargetAndText = [
$title, substr( $text, strlen( $m[0] ) ) ];
212 $this->redirectTargetAndText = [
null, $this->
getNativeData() ];
247 # Remember that redirect pages can have categories, templates, etc.,
248 # so the regex has to be fairly general
249 $newText = preg_replace(
'/ \[ \[ [^\]]* \] \] /x',
251 $this->getNativeData(), 1 );
253 return new static( $newText );
274 switch ( $wgArticleCountMethod ) {
279 return strpos( $text,
',' ) !==
false;
281 if ( $hasLinks ===
null ) { #
not known, find out
288 $links = $po->getLinks();
289 $hasLinks = !empty( $links );
303 $truncatedtext = parent::getTextForSummary( $maxlength );
305 # clean up unfinished links
306 # XXX: make this optional? wasn't there in autosummary, but required for
308 $truncatedtext = preg_replace(
'/\[\[([^\]]*)\]?$/',
'$1', $truncatedtext );
310 return $truncatedtext;
352 "getHtml() not implemented for wikitext. "
353 .
"Use getParserOutput()->getText()."
$wgMaxRedirects
Max number of redirects to follow when resolving redirects.
$wgArticleCountMethod
Method used to determine if a page in a content namespace should be counted as a valid article.
getParserOutput(Title $title, $revId=null, ParserOptions $options=null, $generateHtml=true)
Returns a ParserOutput object containing information derived from this content.
static getRedirectHeaderHtml(Language $lang, $target, $forceKnown=false)
Return the HTML for the top of a redirect page.
This class encapsulates "magic words" such as "#redirect", NOTOC, etc.
static & get( $id)
Factory: creates an object representing an ID.
match( $text)
Returns true if the text contains the word.
Set options of the Parser.
addLink(Title $title, $id=null)
Record a local or interwiki inline link for saving in future link tables.
getRawText()
Get the cacheable text with <mw:editsection> markers still in it.
addModuleStyles( $modules)
static getMain()
Static methods.
Content object implementation for representing flat text.
getNativeData()
Returns the text represented by this Content object, as a string.
Represents a title within MediaWiki.
getFullText()
Get the prefixed title with spaces, plus any fragment (part beginning with '#')
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Content object for wiki text pages.
updateRedirect(Title $target)
This implementation replaces the first link on the page with the given new target if this Content obj...
getRedirectTarget()
Implement redirect extraction for wikitext.
getTextForSummary( $maxlength=250)
preloadTransform(Title $title, ParserOptions $popts, $params=[])
Returns a Content object with preload transformations applied (or this object if no transformations a...
fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
Returns a ParserOutput object resulting from parsing the content's text using $wgParser.
getRedirectTargetAndText()
Extract the redirect target and the remaining text on the page.
addSectionHeader( $header)
Returns a new WikitextContent object with the given section heading prepended.
isCountable( $hasLinks=null, Title $title=null)
Returns true if this content is not a redirect, and this content's text is countable according to the...
matchMagicWord(MagicWord $word)
This implementation calls $word->match() on the this TextContent object's text.
preSaveTransform(Title $title, User $user, ParserOptions $popts)
Returns a Content object with pre-save transformations applied using Parser::preSaveTransform().
replaceSection( $sectionId, Content $with, $sectionTitle='')
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
when a variable name is used in a it is silently declared as a new local masking the global
const CONTENT_MODEL_WIKITEXT
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context $revId
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive false for true for descending in case the handler function wants to provide a converted Content object Note that $result getContentModel() must return $toModel. 'CustomEditor' $rcid is used in generating this variable which contains information about the new such as the revision s whether the revision was marked as a minor edit or not
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state $generateHtml
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Base interface for content objects.
getNativeData()
Returns native representation of the data.
getModel()
Returns the ID of the content model used by this Content object.