32 # State constants for the definition list colon extraction
50 $pass =
new self(
$text, $lineStart );
51 return $pass->execute();
59 $this->lineStart = $lineStart;
69 if ( $this->lastSection !==
'' ) {
70 $result =
'</' . $this->lastSection .
">\n";
73 $this->lastSection =
'';
87 $shorter = min( strlen( $st1 ), strlen( $st2 ) );
89 for ( $i = 0; $i < $shorter; ++$i ) {
90 if ( $st1[$i] !== $st2[$i] ) {
107 if (
'*' === $char ) {
109 } elseif (
'#' === $char ) {
111 } elseif (
':' === $char ) {
113 } elseif (
';' === $char ) {
115 $this->DTopen =
true;
130 if (
'*' === $char ||
'#' === $char ) {
131 return "</li>\n<li>";
132 } elseif (
':' === $char ||
';' === $char ) {
134 if ( $this->DTopen ) {
137 if (
';' === $char ) {
138 $this->DTopen =
true;
139 return $close .
'<dt>';
141 $this->DTopen =
false;
142 return $close .
'<dd>';
145 return '<!-- ERR 2 -->';
155 if (
'*' === $char ) {
156 $text =
"</li></ul>";
157 } elseif (
'#' === $char ) {
158 $text =
"</li></ol>";
159 } elseif (
':' === $char ) {
160 if ( $this->DTopen ) {
161 $this->DTopen =
false;
162 $text =
"</dt></dl>";
164 $text =
"</dd></dl>";
167 return '<!-- ERR 3 -->';
178 # Parsing through the text line by line. The main thing
179 # happening here is handling of block-level elements p, pre,
180 # and making lists from lines starting with * # : etc.
184 $this->DTopen = $inBlockElem =
false;
186 $pendingPTag =
false;
187 $inBlockquote =
false;
189 foreach ( $textLines
as $inputLine ) {
191 if ( !$this->lineStart ) {
193 $this->lineStart =
true;
201 $lastPrefixLength = strlen( $lastPrefix );
202 $preCloseMatch = preg_match(
'/<\\/pre/i', $inputLine );
203 $preOpenMatch = preg_match(
'/<pre/i', $inputLine );
204 # If not in a <pre> element, scan for and figure out what prefixes are there.
205 if ( !$this->inPre ) {
206 # Multiple prefixes may abut each other for nested lists.
207 $prefixLength = strspn( $inputLine,
'*#:;' );
208 $prefix = substr( $inputLine, 0, $prefixLength );
211 # ; and : are both from definition-lists, so they're equivalent
212 # for the purposes of determining whether or not we need to open/close
214 $prefix2 = str_replace(
';',
':', $prefix );
215 $t = substr( $inputLine, $prefixLength );
216 $this->inPre = (bool)$preOpenMatch;
218 # Don't interpret any other prefixes in preformatted text
220 $prefix = $prefix2 =
'';
225 if ( $prefixLength && $lastPrefix === $prefix2 ) {
226 # Same as the last item, so no need to deal with nesting or opening stuff
228 $pendingPTag =
false;
230 if ( substr( $prefix, -1 ) ===
';' ) {
231 # The one nasty exception: definition lists work like this:
232 # ; title : definition text
233 # So we check for : in the remainder text to split up the
234 # title and definition, without b0rking links.
241 } elseif ( $prefixLength || $lastPrefixLength ) {
242 # We need to open or close prefixes, or both.
244 # Either open or close a level...
245 $commonPrefixLength = $this->
getCommon( $prefix, $lastPrefix );
246 $pendingPTag =
false;
248 # Close all the prefixes which aren't shared.
249 while ( $commonPrefixLength < $lastPrefixLength ) {
254 # Continue the current prefix if appropriate.
255 if ( $prefixLength <= $commonPrefixLength && $commonPrefixLength > 0 ) {
259 # Open prefixes where appropriate.
260 if ( $lastPrefix && $prefixLength > $commonPrefixLength ) {
263 while ( $prefixLength > $commonPrefixLength ) {
264 $char = substr( $prefix, $commonPrefixLength, 1 );
267 if (
';' === $char ) {
268 # @todo FIXME: This is dupe of code above
274 ++$commonPrefixLength;
276 if ( !$prefixLength && $lastPrefix ) {
279 $lastPrefix = $prefix2;
282 # If we have no prefixes, go to paragraph mode.
283 if ( 0 == $prefixLength ) {
284 # No prefix (not in list)--go to paragraph mode
285 # @todo consider using a stack for nestable elements like span, table and div
286 $openMatch = preg_match(
287 '/(?:<table|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|'
288 .
'<p|<ul|<ol|<dl|<li|<\\/tr|<\\/td|<\\/th)/iS',
291 $closeMatch = preg_match(
292 '/(?:<\\/table|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|'
293 .
'<td|<th|<\\/?blockquote|<\\/?div|<hr|<\\/pre|<\\/p|<\\/mw:|'
295 .
'-pre|<\\/li|<\\/ul|<\\/ol|<\\/dl|<\\/?center)/iS',
299 if ( $openMatch || $closeMatch ) {
300 $pendingPTag =
false;
301 # @todo bug 5718: paragraph closed
303 if ( $preOpenMatch && !$preCloseMatch ) {
307 while ( preg_match(
'/<(\\/?)blockquote[\s>]/i',
$t,
308 $bqMatch, PREG_OFFSET_CAPTURE, $bqOffset )
310 $inBlockquote = !$bqMatch[1][0];
311 $bqOffset = $bqMatch[0][1] + strlen( $bqMatch[0][0] );
313 $inBlockElem = !$closeMatch;
314 } elseif ( !$inBlockElem && !$this->inPre ) {
315 if (
' ' == substr(
$t, 0, 1 )
316 && ( $this->lastSection ===
'pre' || trim(
$t ) !=
'' )
320 if ( $this->lastSection !==
'pre' ) {
321 $pendingPTag =
false;
323 $this->lastSection =
'pre';
325 $t = substr(
$t, 1 );
328 if ( trim(
$t ) ===
'' ) {
329 if ( $pendingPTag ) {
330 $output .= $pendingPTag .
'<br />';
331 $pendingPTag =
false;
332 $this->lastSection =
'p';
334 if ( $this->lastSection !==
'p' ) {
336 $this->lastSection =
'';
337 $pendingPTag =
'<p>';
339 $pendingPTag =
'</p><p>';
343 if ( $pendingPTag ) {
345 $pendingPTag =
false;
346 $this->lastSection =
'p';
347 } elseif ( $this->lastSection !==
'p' ) {
349 $this->lastSection =
'p';
355 # somewhere above we forget to get out of pre block (bug 785)
356 if ( $preCloseMatch && $this->inPre ) {
357 $this->inPre =
false;
359 if ( $pendingPTag ===
false ) {
361 if ( $prefixLength === 0 ) {
366 while ( $prefixLength ) {
369 if ( !$prefixLength ) {
373 if ( $this->lastSection !==
'' ) {
374 $output .=
'</' . $this->lastSection .
'>';
375 $this->lastSection =
'';
392 $colonPos = strpos( $str,
':' );
393 if ( $colonPos ===
false ) {
398 $ltPos = strpos( $str,
'<' );
399 if ( $ltPos ===
false || $ltPos > $colonPos ) {
400 # Easy; no tag nesting to worry about
401 $before = substr( $str, 0, $colonPos );
402 $after = substr( $str, $colonPos + 1 );
406 # Ugly state machine to walk through avoiding tags.
407 $state = self::COLON_STATE_TEXT;
409 $len = strlen( $str );
410 for ( $i = 0; $i < $len; $i++ ) {
414 case self::COLON_STATE_TEXT:
417 # Could be either a <start> tag or an </end> tag
418 $state = self::COLON_STATE_TAGSTART;
421 if ( $level === 0 ) {
423 $before = substr( $str, 0, $i );
424 $after = substr( $str, $i + 1 );
427 # Embedded in a tag; don't break it.
430 # Skip ahead looking for something interesting
431 $colonPos = strpos( $str,
':', $i );
432 if ( $colonPos ===
false ) {
433 # Nothing else interesting
436 $ltPos = strpos( $str,
'<', $i );
437 if ( $level === 0 ) {
438 if ( $ltPos ===
false || $colonPos < $ltPos ) {
440 $before = substr( $str, 0, $colonPos );
441 $after = substr( $str, $colonPos + 1 );
445 if ( $ltPos ===
false ) {
446 # Nothing else interesting to find; abort!
447 # We're nested, but there's no close tags left. Abort!
450 # Skip ahead to next tag start
452 $state = self::COLON_STATE_TAGSTART;
455 case self::COLON_STATE_TAG:
460 $state = self::COLON_STATE_TEXT;
463 # Slash may be followed by >?
464 $state = self::COLON_STATE_TAGSLASH;
470 case self::COLON_STATE_TAGSTART:
473 $state = self::COLON_STATE_CLOSETAG;
476 $state = self::COLON_STATE_COMMENT;
479 # Illegal early close? This shouldn't happen D:
480 $state = self::COLON_STATE_TEXT;
483 $state = self::COLON_STATE_TAG;
486 case self::COLON_STATE_CLOSETAG:
491 wfDebug( __METHOD__ .
": Invalid input; too many close tags\n" );
494 $state = self::COLON_STATE_TEXT;
497 case self::COLON_STATE_TAGSLASH:
499 # Yes, a self-closed tag <blah/>
500 $state = self::COLON_STATE_TEXT;
502 # Probably we're jumping the gun, and this is an attribute
503 $state = self::COLON_STATE_TAG;
506 case self::COLON_STATE_COMMENT:
508 $state = self::COLON_STATE_COMMENTDASH;
511 case self::COLON_STATE_COMMENTDASH:
513 $state = self::COLON_STATE_COMMENTDASHDASH;
515 $state = self::COLON_STATE_COMMENT;
518 case self::COLON_STATE_COMMENTDASHDASH:
520 $state = self::COLON_STATE_TEXT;
522 $state = self::COLON_STATE_COMMENT;
526 throw new MWException(
"State machine error in " . __METHOD__ );
530 wfDebug( __METHOD__ .
": Invalid input; not enough close tags (level $level, state $state)\n" );
external whereas SearchGetNearMatch runs after $term
const COLON_STATE_TAGSTART
__construct($text, $lineStart)
Private constructor.
const COLON_STATE_COMMENTDASH
const COLON_STATE_COMMENT
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message.Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item.Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page.Return false to stop further processing of the tag $reader:XMLReader object &$pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag.Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload.Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports.&$fullInterwikiPrefix:Interwiki prefix, may contain colons.&$pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable.Can be used to lazy-load the import sources list.&$importSources:The value of $wgImportSources.Modify as necessary.See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page.$context:IContextSource object &$pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect.&$title:Title object for the current page &$request:WebRequest &$ignoreRedirect:boolean to skip redirect check &$target:Title/string of redirect target &$article:Article object 'InternalParseBeforeLinks':during Parser's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InternalParseBeforeSanitize':during Parser's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings.Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not.Return true without providing an interwiki to continue interwiki search.$prefix:interwiki prefix we are looking for.&$iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user's email has been invalidated successfully.$user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification.Callee may modify $url and $query, URL will be constructed as $url.$query &$url:URL to index.php &$query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) &$article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() &$ip:IP being check &$result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from &$allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn't match your organization.$addr:The e-mail address entered by the user &$result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user &$result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we're looking for a messages file for &$file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language &$magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces.Do not use this hook to add namespaces.Use CanonicalNamespaces for that.&$namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language &$specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names.&$names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page's language links.This is called in various places to allow extensions to define the effective language links for a page.$title:The page's Title.&$links:Associative array mapping language codes to prefixed links of the form"language:title".&$linkFlags:Associative array mapping prefixed links to arrays of flags.Currently unused, but planned to provide support for marking individual language links in the UI, e.g.for featured articles. 'LanguageSelector':Hook to change the language selector available on a page.$out:The output page.$cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED!Use HtmlPageLinkRendererBegin instead.Used when generating internal and interwiki links in Linker::link(), before processing starts.Return false to skip default processing and return $ret.See documentation for Linker::link() for details on the expected meanings of parameters.$skin:the Skin object $target:the Title that the link is pointing to &$html:the contents that the< a > tag should have(raw HTML) $result
openList($char)
Open the list item element identified by the prefix character.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
nextItem($char)
Close the current list item and open the next one.
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
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
execute()
Execute the pass.
getCommon($st1, $st2)
getCommon() returns the length of the longest common substring of both arguments, starting at the beg...
const COLON_STATE_COMMENTDASHDASH
findColonNoLinks($str, &$before, &$after)
Split up a string on ':', ignoring any occurrences inside tags to prevent illegal overlapping...
static doBlockLevels($text, $lineStart)
Make lists from lines starting with ':', '*', '#', etc.
static explode($separator, $subject)
Workalike for explode() with limited memory usage.
closeParagraph()
If a pre or p is open, return the corresponding close tag and update the state.
const COLON_STATE_TAGSLASH
const COLON_STATE_CLOSETAG
closeList($char)
Close the current list item identified by the prefix character.