MediaWiki  1.23.8
MagicWord.php
Go to the documentation of this file.
1 <?php
61 class MagicWord {
66  var $mRegex = '';
67  var $mRegexStart = '';
69  var $mBaseRegex = '';
70  var $mVariableRegex = '';
72  var $mModified = false;
73  var $mFound = false;
74 
75  static public $mVariableIDsInitialised = false;
76  static public $mVariableIDs = array(
77  'currentmonth',
78  'currentmonth1',
79  'currentmonthname',
80  'currentmonthnamegen',
81  'currentmonthabbrev',
82  'currentday',
83  'currentday2',
84  'currentdayname',
85  'currentyear',
86  'currenttime',
87  'currenthour',
88  'localmonth',
89  'localmonth1',
90  'localmonthname',
91  'localmonthnamegen',
92  'localmonthabbrev',
93  'localday',
94  'localday2',
95  'localdayname',
96  'localyear',
97  'localtime',
98  'localhour',
99  'numberofarticles',
100  'numberoffiles',
101  'numberofedits',
102  'articlepath',
103  'pageid',
104  'sitename',
105  'server',
106  'servername',
107  'scriptpath',
108  'stylepath',
109  'pagename',
110  'pagenamee',
111  'fullpagename',
112  'fullpagenamee',
113  'namespace',
114  'namespacee',
115  'namespacenumber',
116  'currentweek',
117  'currentdow',
118  'localweek',
119  'localdow',
120  'revisionid',
121  'revisionday',
122  'revisionday2',
123  'revisionmonth',
124  'revisionmonth1',
125  'revisionyear',
126  'revisiontimestamp',
127  'revisionuser',
128  'revisionsize',
129  'subpagename',
130  'subpagenamee',
131  'talkspace',
132  'talkspacee',
133  'subjectspace',
134  'subjectspacee',
135  'talkpagename',
136  'talkpagenamee',
137  'subjectpagename',
138  'subjectpagenamee',
139  'numberofusers',
140  'numberofactiveusers',
141  'numberofpages',
142  'currentversion',
143  'rootpagename',
144  'rootpagenamee',
145  'basepagename',
146  'basepagenamee',
147  'currenttimestamp',
148  'localtimestamp',
149  'directionmark',
150  'contentlanguage',
151  'numberofadmins',
152  'numberofviews',
153  'cascadingsources',
154  );
155 
156  /* Array of caching hints for ParserCache */
157  static public $mCacheTTLs = array(
158  'currentmonth' => 86400,
159  'currentmonth1' => 86400,
160  'currentmonthname' => 86400,
161  'currentmonthnamegen' => 86400,
162  'currentmonthabbrev' => 86400,
163  'currentday' => 3600,
164  'currentday2' => 3600,
165  'currentdayname' => 3600,
166  'currentyear' => 86400,
167  'currenttime' => 3600,
168  'currenthour' => 3600,
169  'localmonth' => 86400,
170  'localmonth1' => 86400,
171  'localmonthname' => 86400,
172  'localmonthnamegen' => 86400,
173  'localmonthabbrev' => 86400,
174  'localday' => 3600,
175  'localday2' => 3600,
176  'localdayname' => 3600,
177  'localyear' => 86400,
178  'localtime' => 3600,
179  'localhour' => 3600,
180  'numberofarticles' => 3600,
181  'numberoffiles' => 3600,
182  'numberofedits' => 3600,
183  'currentweek' => 3600,
184  'currentdow' => 3600,
185  'localweek' => 3600,
186  'localdow' => 3600,
187  'numberofusers' => 3600,
188  'numberofactiveusers' => 3600,
189  'numberofpages' => 3600,
190  'currentversion' => 86400,
191  'currenttimestamp' => 3600,
192  'localtimestamp' => 3600,
193  'pagesinnamespace' => 3600,
194  'numberofadmins' => 3600,
195  'numberofviews' => 3600,
196  'numberingroup' => 3600,
197  );
198 
199  static public $mDoubleUnderscoreIDs = array(
200  'notoc',
201  'nogallery',
202  'forcetoc',
203  'toc',
204  'noeditsection',
205  'newsectionlink',
206  'nonewsectionlink',
207  'hiddencat',
208  'index',
209  'noindex',
210  'staticredirect',
211  'notitleconvert',
212  'nocontentconvert',
213  );
214 
215  static public $mSubstIDs = array(
216  'subst',
217  'safesubst',
218  );
219 
220  static public $mObjects = array();
221  static public $mDoubleUnderscoreArray = null;
222 
225  function __construct( $id = 0, $syn = array(), $cs = false ) {
226  $this->mId = $id;
227  $this->mSynonyms = (array)$syn;
228  $this->mCaseSensitive = $cs;
229  }
230 
238  static function &get( $id ) {
239  if ( !isset( self::$mObjects[$id] ) ) {
240  $mw = new MagicWord();
241  $mw->load( $id );
242  self::$mObjects[$id] = $mw;
243  }
244  return self::$mObjects[$id];
245  }
246 
252  static function getVariableIDs() {
253  if ( !self::$mVariableIDsInitialised ) {
254  # Get variable IDs
255  wfRunHooks( 'MagicWordwgVariableIDs', array( &self::$mVariableIDs ) );
256  self::$mVariableIDsInitialised = true;
257  }
258  return self::$mVariableIDs;
259  }
260 
265  static function getSubstIDs() {
266  return self::$mSubstIDs;
267  }
268 
275  static function getCacheTTL( $id ) {
276  if ( array_key_exists( $id, self::$mCacheTTLs ) ) {
277  return self::$mCacheTTLs[$id];
278  } else {
279  return -1;
280  }
281  }
282 
288  static function getDoubleUnderscoreArray() {
289  if ( is_null( self::$mDoubleUnderscoreArray ) ) {
290  wfRunHooks( 'GetDoubleUnderscoreIDs', array( &self::$mDoubleUnderscoreIDs ) );
291  self::$mDoubleUnderscoreArray = new MagicWordArray( self::$mDoubleUnderscoreIDs );
292  }
294  }
295 
300  public static function clearCache() {
301  self::$mObjects = array();
302  }
303 
310  function load( $id ) {
312  wfProfileIn( __METHOD__ );
313  $this->mId = $id;
314  $wgContLang->getMagic( $this );
315  if ( !$this->mSynonyms ) {
316  $this->mSynonyms = array( 'brionmademeputthishere' );
317  wfProfileOut( __METHOD__ );
318  throw new MWException( "Error: invalid magic word '$id'" );
319  }
320  wfProfileOut( __METHOD__ );
321  }
322 
327  function initRegex() {
328  // Sort the synonyms by length, descending, so that the longest synonym
329  // matches in precedence to the shortest
330  $synonyms = $this->mSynonyms;
331  usort( $synonyms, array( $this, 'compareStringLength' ) );
332 
333  $escSyn = array();
334  foreach ( $synonyms as $synonym ) {
335  // In case a magic word contains /, like that's going to happen;)
336  $escSyn[] = preg_quote( $synonym, '/' );
337  }
338  $this->mBaseRegex = implode( '|', $escSyn );
339 
340  $case = $this->mCaseSensitive ? '' : 'iu';
341  $this->mRegex = "/{$this->mBaseRegex}/{$case}";
342  $this->mRegexStart = "/^(?:{$this->mBaseRegex})/{$case}";
343  $this->mRegexStartToEnd = "/^(?:{$this->mBaseRegex})$/{$case}";
344  $this->mVariableRegex = str_replace( "\\$1", "(.*?)", $this->mRegex );
345  $this->mVariableStartToEndRegex = str_replace( "\\$1", "(.*?)",
346  "/^(?:{$this->mBaseRegex})$/{$case}" );
347  }
348 
359  function compareStringLength( $s1, $s2 ) {
360  $l1 = strlen( $s1 );
361  $l2 = strlen( $s2 );
362  if ( $l1 < $l2 ) {
363  return 1;
364  } elseif ( $l1 > $l2 ) {
365  return -1;
366  } else {
367  return 0;
368  }
369  }
370 
376  function getRegex() {
377  if ( $this->mRegex == '' ) {
378  $this->initRegex();
379  }
380  return $this->mRegex;
381  }
382 
390  function getRegexCase() {
391  if ( $this->mRegex === '' ) {
392  $this->initRegex();
393  }
394 
395  return $this->mCaseSensitive ? '' : 'iu';
396  }
397 
403  function getRegexStart() {
404  if ( $this->mRegex == '' ) {
405  $this->initRegex();
406  }
407  return $this->mRegexStart;
408  }
409 
416  function getRegexStartToEnd() {
417  if ( $this->mRegexStartToEnd == '' ) {
418  $this->initRegex();
419  }
421  }
422 
428  function getBaseRegex() {
429  if ( $this->mRegex == '' ) {
430  $this->initRegex();
431  }
432  return $this->mBaseRegex;
433  }
434 
442  function match( $text ) {
443  return (bool)preg_match( $this->getRegex(), $text );
444  }
445 
453  function matchStart( $text ) {
454  return (bool)preg_match( $this->getRegexStart(), $text );
455  }
456 
465  function matchStartToEnd( $text ) {
466  return (bool)preg_match( $this->getRegexStartToEnd(), $text );
467  }
468 
479  function matchVariableStartToEnd( $text ) {
480  $matches = array();
481  $matchcount = preg_match( $this->getVariableStartToEndRegex(), $text, $matches );
482  if ( $matchcount == 0 ) {
483  return null;
484  } else {
485  # multiple matched parts (variable match); some will be empty because of
486  # synonyms. The variable will be the second non-empty one so remove any
487  # blank elements and re-sort the indices.
488  # See also bug 6526
489 
490  $matches = array_values( array_filter( $matches ) );
491 
492  if ( count( $matches ) == 1 ) {
493  return $matches[0];
494  } else {
495  return $matches[1];
496  }
497  }
498  }
499 
508  function matchAndRemove( &$text ) {
509  $this->mFound = false;
510  $text = preg_replace_callback( $this->getRegex(), array( &$this, 'pregRemoveAndRecord' ), $text );
511  return $this->mFound;
512  }
513 
518  function matchStartAndRemove( &$text ) {
519  $this->mFound = false;
520  $text = preg_replace_callback( $this->getRegexStart(), array( &$this, 'pregRemoveAndRecord' ), $text );
521  return $this->mFound;
522  }
523 
529  function pregRemoveAndRecord() {
530  $this->mFound = true;
531  return '';
532  }
533 
543  function replace( $replacement, $subject, $limit = -1 ) {
544  $res = preg_replace( $this->getRegex(), StringUtils::escapeRegexReplacement( $replacement ), $subject, $limit );
545  $this->mModified = $res !== $subject;
546  return $res;
547  }
548 
559  function substituteCallback( $text, $callback ) {
560  $res = preg_replace_callback( $this->getVariableRegex(), $callback, $text );
561  $this->mModified = $res !== $text;
562  return $res;
563  }
564 
570  function getVariableRegex() {
571  if ( $this->mVariableRegex == '' ) {
572  $this->initRegex();
573  }
574  return $this->mVariableRegex;
575  }
576 
583  if ( $this->mVariableStartToEndRegex == '' ) {
584  $this->initRegex();
585  }
587  }
588 
596  function getSynonym( $i ) {
597  return $this->mSynonyms[$i];
598  }
599 
603  function getSynonyms() {
604  return $this->mSynonyms;
605  }
606 
613  function getWasModified() {
614  return $this->mModified;
615  }
616 
630  function replaceMultiple( $magicarr, $subject, &$result ) {
631  $search = array();
632  $replace = array();
633  foreach ( $magicarr as $id => $replacement ) {
634  $mw = MagicWord::get( $id );
635  $search[] = $mw->getRegex();
636  $replace[] = $replacement;
637  }
638 
639  $result = preg_replace( $search, $replace, $subject );
640  return $result !== $subject;
641  }
642 
650  function addToArray( &$array, $value ) {
652  foreach ( $this->mSynonyms as $syn ) {
653  $array[$wgContLang->lc( $syn )] = $value;
654  }
655  }
656 
660  function isCaseSensitive() {
661  return $this->mCaseSensitive;
662  }
663 
667  function getId() {
668  return $this->mId;
669  }
670 }
671 
677  var $names = array();
678  var $hash;
680  var $matches;
681 
685  function __construct( $names = array() ) {
686  $this->names = $names;
687  }
688 
694  public function add( $name ) {
695  $this->names[] = $name;
696  $this->hash = $this->baseRegex = $this->regex = null;
697  }
698 
704  public function addArray( $names ) {
705  $this->names = array_merge( $this->names, array_values( $names ) );
706  $this->hash = $this->baseRegex = $this->regex = null;
707  }
708 
712  function getHash() {
713  if ( is_null( $this->hash ) ) {
715  $this->hash = array( 0 => array(), 1 => array() );
716  foreach ( $this->names as $name ) {
717  $magic = MagicWord::get( $name );
718  $case = intval( $magic->isCaseSensitive() );
719  foreach ( $magic->getSynonyms() as $syn ) {
720  if ( !$case ) {
721  $syn = $wgContLang->lc( $syn );
722  }
723  $this->hash[$case][$syn] = $name;
724  }
725  }
726  }
727  return $this->hash;
728  }
729 
733  function getBaseRegex() {
734  if ( is_null( $this->baseRegex ) ) {
735  $this->baseRegex = array( 0 => '', 1 => '' );
736  foreach ( $this->names as $name ) {
737  $magic = MagicWord::get( $name );
738  $case = intval( $magic->isCaseSensitive() );
739  foreach ( $magic->getSynonyms() as $i => $syn ) {
740  // Group name must start with a non-digit in PCRE 8.34+
741  $it = strtr( $i, '0123456789', 'abcdefghij' );
742  $group = "(?P<{$it}_{$name}>" . preg_quote( $syn, '/' ) . ')';
743  if ( $this->baseRegex[$case] === '' ) {
744  $this->baseRegex[$case] = $group;
745  } else {
746  $this->baseRegex[$case] .= '|' . $group;
747  }
748  }
749  }
750  }
751  return $this->baseRegex;
752  }
753 
757  function getRegex() {
758  if ( is_null( $this->regex ) ) {
759  $base = $this->getBaseRegex();
760  $this->regex = array( '', '' );
761  if ( $this->baseRegex[0] !== '' ) {
762  $this->regex[0] = "/{$base[0]}/iuS";
763  }
764  if ( $this->baseRegex[1] !== '' ) {
765  $this->regex[1] = "/{$base[1]}/S";
766  }
767  }
768  return $this->regex;
769  }
770 
776  function getVariableRegex() {
777  return str_replace( "\\$1", "(.*?)", $this->getRegex() );
778  }
779 
785  function getRegexStart() {
786  $base = $this->getBaseRegex();
787  $newRegex = array( '', '' );
788  if ( $base[0] !== '' ) {
789  $newRegex[0] = "/^(?:{$base[0]})/iuS";
790  }
791  if ( $base[1] !== '' ) {
792  $newRegex[1] = "/^(?:{$base[1]})/S";
793  }
794  return $newRegex;
795  }
796 
803  $base = $this->getBaseRegex();
804  $newRegex = array( '', '' );
805  if ( $base[0] !== '' ) {
806  $newRegex[0] = str_replace( "\\$1", "(.*?)", "/^(?:{$base[0]})$/iuS" );
807  }
808  if ( $base[1] !== '' ) {
809  $newRegex[1] = str_replace( "\\$1", "(.*?)", "/^(?:{$base[1]})$/S" );
810  }
811  return $newRegex;
812  }
813 
818  public function getNames() {
819  return $this->names;
820  }
821 
832  function parseMatch( $m ) {
833  reset( $m );
834  while ( list( $key, $value ) = each( $m ) ) {
835  if ( $key === 0 || $value === '' ) {
836  continue;
837  }
838  $parts = explode( '_', $key, 2 );
839  if ( count( $parts ) != 2 ) {
840  // This shouldn't happen
841  // continue;
842  throw new MWException( __METHOD__ . ': bad parameter name' );
843  }
844  list( /* $synIndex */, $magicName ) = $parts;
845  $paramValue = next( $m );
846  return array( $magicName, $paramValue );
847  }
848  // This shouldn't happen either
849  throw new MWException( __METHOD__ . ': parameter not found' );
850  }
851 
862  public function matchVariableStartToEnd( $text ) {
863  $regexes = $this->getVariableStartToEndRegex();
864  foreach ( $regexes as $regex ) {
865  if ( $regex !== '' ) {
866  $m = array();
867  if ( preg_match( $regex, $text, $m ) ) {
868  return $this->parseMatch( $m );
869  }
870  }
871  }
872  return array( false, false );
873  }
874 
883  public function matchStartToEnd( $text ) {
884  $hash = $this->getHash();
885  if ( isset( $hash[1][$text] ) ) {
886  return $hash[1][$text];
887  }
889  $lc = $wgContLang->lc( $text );
890  if ( isset( $hash[0][$lc] ) ) {
891  return $hash[0][$lc];
892  }
893  return false;
894  }
895 
904  public function matchAndRemove( &$text ) {
905  $found = array();
906  $regexes = $this->getRegex();
907  foreach ( $regexes as $regex ) {
908  if ( $regex === '' ) {
909  continue;
910  }
911  preg_match_all( $regex, $text, $matches, PREG_SET_ORDER );
912  foreach ( $matches as $m ) {
913  list( $name, $param ) = $this->parseMatch( $m );
914  $found[$name] = $param;
915  }
916  $text = preg_replace( $regex, '', $text );
917  }
918  return $found;
919  }
920 
931  public function matchStartAndRemove( &$text ) {
932  $regexes = $this->getRegexStart();
933  foreach ( $regexes as $regex ) {
934  if ( $regex === '' ) {
935  continue;
936  }
937  if ( preg_match( $regex, $text, $m ) ) {
938  list( $id, ) = $this->parseMatch( $m );
939  if ( strlen( $m[0] ) >= strlen( $text ) ) {
940  $text = '';
941  } else {
942  $text = substr( $text, strlen( $m[0] ) );
943  }
944  return $id;
945  }
946  }
947  return false;
948  }
949 }
MagicWord\$mId
$mId
#+
Definition: MagicWord.php:65
MagicWordArray
Class for handling an array of magic words.
Definition: MagicWord.php:676
MagicWordArray\getVariableStartToEndRegex
getVariableStartToEndRegex()
Get an anchored regex for matching variables with parameters.
Definition: MagicWord.php:802
$result
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. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag '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 '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. '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 '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 '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 wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() '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 User::isValidEmailAddr(), 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. '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 '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) '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. 'LinkBegin':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
Definition: hooks.txt:1528
MagicWordArray\getNames
getNames()
Definition: MagicWord.php:818
MagicWordArray\matchStartAndRemove
matchStartAndRemove(&$text)
Return the ID of the magic word at the start of $text, and remove the prefix from $text.
Definition: MagicWord.php:931
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
MagicWordArray\getHash
getHash()
Get a 2-d hashtable for this array.
Definition: MagicWord.php:712
MagicWordArray\getRegexStart
getRegexStart()
Get a regex anchored to the start of the string that does not match parameters.
Definition: MagicWord.php:785
MagicWord\$mBaseRegex
$mBaseRegex
Definition: MagicWord.php:69
MagicWord\substituteCallback
substituteCallback( $text, $callback)
Variable handling: {{SUBST:xxx}} style words Calls back a function to determine what to replace xxx w...
Definition: MagicWord.php:559
MagicWord\matchVariableStartToEnd
matchVariableStartToEnd( $text)
Returns NULL if there's no match, the value of $1 otherwise The return code is the matched string,...
Definition: MagicWord.php:479
MagicWordArray\__construct
__construct( $names=array())
Definition: MagicWord.php:685
MagicWord\getSynonyms
getSynonyms()
Definition: MagicWord.php:603
MagicWord\load
load( $id)
Initialises this object with an ID.
Definition: MagicWord.php:310
wfProfileIn
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
MagicWord\isCaseSensitive
isCaseSensitive()
Definition: MagicWord.php:660
MagicWordArray\$hash
$hash
Definition: MagicWord.php:678
MagicWord\getRegexStartToEnd
getRegexStartToEnd()
Gets a regex matching the word from start to end of a string.
Definition: MagicWord.php:416
StringUtils\escapeRegexReplacement
static escapeRegexReplacement( $string)
Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter.
Definition: StringUtils.php:296
MagicWord\get
static & get( $id)
Factory: creates an object representing an ID.
Definition: MagicWord.php:238
MagicWord\getRegex
getRegex()
Gets a regex representing matching the word.
Definition: MagicWord.php:376
$limit
if( $sleep) $limit
Definition: importImages.php:99
MagicWord\getId
getId()
Definition: MagicWord.php:667
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
MagicWordArray\$baseRegex
$baseRegex
Definition: MagicWord.php:679
MagicWord\$mModified
$mModified
Definition: MagicWord.php:72
MagicWord\$mRegex
$mRegex
Definition: MagicWord.php:66
MagicWordArray\$names
$names
Definition: MagicWord.php:677
MagicWordArray\matchStartToEnd
matchStartToEnd( $text)
Match some text, without parameter capture Returns the magic word name, or false if there was no capt...
Definition: MagicWord.php:883
MagicWord\$mDoubleUnderscoreIDs
static $mDoubleUnderscoreIDs
Definition: MagicWord.php:199
MagicWord\initRegex
initRegex()
Preliminary initialisation.
Definition: MagicWord.php:327
MagicWord\replace
replace( $replacement, $subject, $limit=-1)
Replaces the word with something else.
Definition: MagicWord.php:543
MagicWord\matchStartToEnd
matchStartToEnd( $text)
Returns true if the text matched the word.
Definition: MagicWord.php:465
MagicWord\getVariableIDs
static getVariableIDs()
Get an array of parser variable IDs.
Definition: MagicWord.php:252
MWException
MediaWiki exception.
Definition: MWException.php:26
MagicWord\getCacheTTL
static getCacheTTL( $id)
Allow external reads of TTL array.
Definition: MagicWord.php:275
MagicWord\$mObjects
static $mObjects
Definition: MagicWord.php:220
MagicWord\$mRegexStartToEnd
$mRegexStartToEnd
Definition: MagicWord.php:68
MagicWord\$mCaseSensitive
$mCaseSensitive
Definition: MagicWord.php:65
MagicWord\getWasModified
getWasModified()
Returns true if the last call to replace() or substituteCallback() returned a modified text,...
Definition: MagicWord.php:613
wfProfileOut
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4010
MagicWordArray\add
add( $name)
Add a magic word by name.
Definition: MagicWord.php:694
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
MagicWord\$mDoubleUnderscoreArray
static $mDoubleUnderscoreArray
Definition: MagicWord.php:221
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
MagicWord\pregRemoveAndRecord
pregRemoveAndRecord()
Used in matchAndRemove()
Definition: MagicWord.php:529
MagicWord
This class encapsulates "magic words" such as "#redirect", NOTOC, etc.
Definition: MagicWord.php:61
MagicWord\replaceMultiple
replaceMultiple( $magicarr, $subject, &$result)
$magicarr is an associative array of (magic word ID => replacement) This method uses the php feature ...
Definition: MagicWord.php:630
MagicWordArray\getBaseRegex
getBaseRegex()
Get the base regex.
Definition: MagicWord.php:733
MagicWord\getRegexStart
getRegexStart()
Gets a regex matching the word, if it is at the string start.
Definition: MagicWord.php:403
list
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
Definition: deferred.txt:11
MagicWord\getBaseRegex
getBaseRegex()
regex without the slashes and what not
Definition: MagicWord.php:428
MagicWord\clearCache
static clearCache()
Clear the self::$mObjects variable For use in parser tests.
Definition: MagicWord.php:300
MagicWordArray\getRegex
getRegex()
Get an unanchored regex that does not match parameters.
Definition: MagicWord.php:757
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
$matches
if(!defined( 'MEDIAWIKI')) if(!isset( $wgVersion)) $matches
Definition: NoLocalSettings.php:33
MagicWordArray\matchAndRemove
matchAndRemove(&$text)
Returns an associative array, ID => param value, for all items that match Removes the matched items f...
Definition: MagicWord.php:904
$value
$value
Definition: styleTest.css.php:45
MagicWord\$mFound
$mFound
Definition: MagicWord.php:73
MagicWordArray\getVariableRegex
getVariableRegex()
Get a regex for matching variables with parameters.
Definition: MagicWord.php:776
MagicWord\$mVariableIDs
static $mVariableIDs
Definition: MagicWord.php:76
MagicWord\matchStartAndRemove
matchStartAndRemove(&$text)
Definition: MagicWord.php:518
MagicWord\getVariableRegex
getVariableRegex()
Matches the word, where $1 is a wildcard.
Definition: MagicWord.php:570
MagicWordArray\parseMatch
parseMatch( $m)
Parse a match array from preg_match Returns array(magic word ID, parameter value) If there is no para...
Definition: MagicWord.php:832
MagicWord\$mCacheTTLs
static $mCacheTTLs
Definition: MagicWord.php:157
MagicWordArray\$matches
$matches
Definition: MagicWord.php:680
MagicWord\$mSubstIDs
static $mSubstIDs
Definition: MagicWord.php:215
MagicWord\addToArray
addToArray(&$array, $value)
Adds all the synonyms of this MagicWord to an array, to allow quick lookup in a list of magic words.
Definition: MagicWord.php:650
MagicWord\getSubstIDs
static getSubstIDs()
Get an array of parser substitution modifier IDs.
Definition: MagicWord.php:265
MagicWord\$mVariableIDsInitialised
static $mVariableIDsInitialised
Definition: MagicWord.php:75
MagicWord\$mVariableStartToEndRegex
$mVariableStartToEndRegex
Definition: MagicWord.php:71
as
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
Definition: distributors.txt:9
MagicWord\matchStart
matchStart( $text)
Returns true if the text starts with the word.
Definition: MagicWord.php:453
MagicWord\getDoubleUnderscoreArray
static getDoubleUnderscoreArray()
Get a MagicWordArray of double-underscore entities.
Definition: MagicWord.php:288
MagicWordArray\$regex
$regex
Definition: MagicWord.php:679
MagicWord\getRegexCase
getRegexCase()
Gets the regexp case modifier to use, i.e.
Definition: MagicWord.php:390
MagicWordArray\matchVariableStartToEnd
matchVariableStartToEnd( $text)
Match some text, with parameter capture Returns an array with the magic word name in the first elemen...
Definition: MagicWord.php:862
MagicWord\$mSynonyms
$mSynonyms
Definition: MagicWord.php:65
MagicWord\getVariableStartToEndRegex
getVariableStartToEndRegex()
Matches the entire string, where $1 is a wildcard.
Definition: MagicWord.php:582
MagicWord\$mVariableRegex
$mVariableRegex
Definition: MagicWord.php:70
MagicWord\$mRegexStart
$mRegexStart
Definition: MagicWord.php:67
$res
$res
Definition: database.txt:21
MagicWordArray\addArray
addArray( $names)
Add a number of magic words by name.
Definition: MagicWord.php:704
MagicWord\getSynonym
getSynonym( $i)
Accesses the synonym list directly.
Definition: MagicWord.php:596
MagicWord\compareStringLength
compareStringLength( $s1, $s2)
A comparison function that returns -1, 0 or 1 depending on whether the first string is longer,...
Definition: MagicWord.php:359
MagicWord\matchAndRemove
matchAndRemove(&$text)
Returns true if the text matches the word, and alters the input string, removing all instances of the...
Definition: MagicWord.php:508
MagicWord\match
match( $text)
Returns true if the text contains the word.
Definition: MagicWord.php:442
MagicWord\__construct
__construct( $id=0, $syn=array(), $cs=false)
#-
Definition: MagicWord.php:225