4 * Various core parser functions, registered in Parser::firstCallInit()
7 class CoreParserFunctions
{
8 static function register( $parser ) {
9 global $wgAllowDisplayTitle, $wgAllowSlowParserFunctions;
11 # Syntax for arguments (see self::setFunctionHook):
12 # "name for lookup in localized magic words array",
14 # optional SFH_NO_HASH to omit the hash from calls (e.g. {{int:...}
15 # instead of {{#int:...}})
17 $parser->setFunctionHook( 'int', array( __CLASS__
, 'intFunction' ), SFH_NO_HASH
);
18 $parser->setFunctionHook( 'ns', array( __CLASS__
, 'ns' ), SFH_NO_HASH
);
19 $parser->setFunctionHook( 'urlencode', array( __CLASS__
, 'urlencode' ), SFH_NO_HASH
);
20 $parser->setFunctionHook( 'lcfirst', array( __CLASS__
, 'lcfirst' ), SFH_NO_HASH
);
21 $parser->setFunctionHook( 'ucfirst', array( __CLASS__
, 'ucfirst' ), SFH_NO_HASH
);
22 $parser->setFunctionHook( 'lc', array( __CLASS__
, 'lc' ), SFH_NO_HASH
);
23 $parser->setFunctionHook( 'uc', array( __CLASS__
, 'uc' ), SFH_NO_HASH
);
24 $parser->setFunctionHook( 'localurl', array( __CLASS__
, 'localurl' ), SFH_NO_HASH
);
25 $parser->setFunctionHook( 'localurle', array( __CLASS__
, 'localurle' ), SFH_NO_HASH
);
26 $parser->setFunctionHook( 'fullurl', array( __CLASS__
, 'fullurl' ), SFH_NO_HASH
);
27 $parser->setFunctionHook( 'fullurle', array( __CLASS__
, 'fullurle' ), SFH_NO_HASH
);
28 $parser->setFunctionHook( 'formatnum', array( __CLASS__
, 'formatnum' ), SFH_NO_HASH
);
29 $parser->setFunctionHook( 'grammar', array( __CLASS__
, 'grammar' ), SFH_NO_HASH
);
30 $parser->setFunctionHook( 'gender', array( __CLASS__
, 'gender' ), SFH_NO_HASH
);
31 $parser->setFunctionHook( 'plural', array( __CLASS__
, 'plural' ), SFH_NO_HASH
);
32 $parser->setFunctionHook( 'numberofpages', array( __CLASS__
, 'numberofpages' ), SFH_NO_HASH
);
33 $parser->setFunctionHook( 'numberofusers', array( __CLASS__
, 'numberofusers' ), SFH_NO_HASH
);
34 $parser->setFunctionHook( 'numberofactiveusers', array( __CLASS__
, 'numberofactiveusers' ), SFH_NO_HASH
);
35 $parser->setFunctionHook( 'numberofarticles', array( __CLASS__
, 'numberofarticles' ), SFH_NO_HASH
);
36 $parser->setFunctionHook( 'numberoffiles', array( __CLASS__
, 'numberoffiles' ), SFH_NO_HASH
);
37 $parser->setFunctionHook( 'numberofadmins', array( __CLASS__
, 'numberofadmins' ), SFH_NO_HASH
);
38 $parser->setFunctionHook( 'numberingroup', array( __CLASS__
, 'numberingroup' ), SFH_NO_HASH
);
39 $parser->setFunctionHook( 'numberofedits', array( __CLASS__
, 'numberofedits' ), SFH_NO_HASH
);
40 $parser->setFunctionHook( 'numberofviews', array( __CLASS__
, 'numberofviews' ), SFH_NO_HASH
);
41 $parser->setFunctionHook( 'numberofcontribs', array( __CLASS__
, 'numberofcontribs' ), SFH_NO_HASH
);
42 $parser->setFunctionHook( 'language', array( __CLASS__
, 'language' ), SFH_NO_HASH
);
43 $parser->setFunctionHook( 'padleft', array( __CLASS__
, 'padleft' ), SFH_NO_HASH
);
44 $parser->setFunctionHook( 'padright', array( __CLASS__
, 'padright' ), SFH_NO_HASH
);
45 $parser->setFunctionHook( 'anchorencode', array( __CLASS__
, 'anchorencode' ), SFH_NO_HASH
);
46 $parser->setFunctionHook( 'special', array( __CLASS__
, 'special' ) );
47 $parser->setFunctionHook( 'defaultsort', array( __CLASS__
, 'defaultsort' ), SFH_NO_HASH
);
48 $parser->setFunctionHook( 'filepath', array( __CLASS__
, 'filepath' ), SFH_NO_HASH
);
49 $parser->setFunctionHook( 'pagesincategory', array( __CLASS__
, 'pagesincategory' ), SFH_NO_HASH
);
50 $parser->setFunctionHook( 'pagesize', array( __CLASS__
, 'pagesize' ), SFH_NO_HASH
);
51 $parser->setFunctionHook( 'protectionlevel', array( __CLASS__
, 'protectionlevel' ), SFH_NO_HASH
);
52 $parser->setFunctionHook( 'namespace', array( __CLASS__
, 'mwnamespace' ), SFH_NO_HASH
);
53 $parser->setFunctionHook( 'namespacee', array( __CLASS__
, 'namespacee' ), SFH_NO_HASH
);
54 $parser->setFunctionHook( 'talkspace', array( __CLASS__
, 'talkspace' ), SFH_NO_HASH
);
55 $parser->setFunctionHook( 'talkspacee', array( __CLASS__
, 'talkspacee' ), SFH_NO_HASH
);
56 $parser->setFunctionHook( 'subjectspace', array( __CLASS__
, 'subjectspace' ), SFH_NO_HASH
);
57 $parser->setFunctionHook( 'subjectspacee', array( __CLASS__
, 'subjectspacee' ), SFH_NO_HASH
);
58 $parser->setFunctionHook( 'pagename', array( __CLASS__
, 'pagename' ), SFH_NO_HASH
);
59 $parser->setFunctionHook( 'pagenamee', array( __CLASS__
, 'pagenamee' ), SFH_NO_HASH
);
60 $parser->setFunctionHook( 'fullpagename', array( __CLASS__
, 'fullpagename' ), SFH_NO_HASH
);
61 $parser->setFunctionHook( 'fullpagenamee', array( __CLASS__
, 'fullpagenamee' ), SFH_NO_HASH
);
62 $parser->setFunctionHook( 'basepagename', array( __CLASS__
, 'basepagename' ), SFH_NO_HASH
);
63 $parser->setFunctionHook( 'basepagenamee', array( __CLASS__
, 'basepagenamee' ), SFH_NO_HASH
);
64 $parser->setFunctionHook( 'subpagename', array( __CLASS__
, 'subpagename' ), SFH_NO_HASH
);
65 $parser->setFunctionHook( 'subpagenamee', array( __CLASS__
, 'subpagenamee' ), SFH_NO_HASH
);
66 $parser->setFunctionHook( 'talkpagename', array( __CLASS__
, 'talkpagename' ), SFH_NO_HASH
);
67 $parser->setFunctionHook( 'talkpagenamee', array( __CLASS__
, 'talkpagenamee' ), SFH_NO_HASH
);
68 $parser->setFunctionHook( 'subjectpagename', array( __CLASS__
, 'subjectpagename' ), SFH_NO_HASH
);
69 $parser->setFunctionHook( 'subjectpagenamee', array( __CLASS__
, 'subjectpagenamee' ), SFH_NO_HASH
);
70 $parser->setFunctionHook( 'tag', array( __CLASS__
, 'tagObj' ), SFH_OBJECT_ARGS
);
71 $parser->setFunctionHook( 'formatdate', array( __CLASS__
, 'formatDate' ) );
73 if ( $wgAllowDisplayTitle ) {
74 $parser->setFunctionHook( 'displaytitle', array( __CLASS__
, 'displaytitle' ), SFH_NO_HASH
);
76 if ( $wgAllowSlowParserFunctions ) {
77 $parser->setFunctionHook( 'pagesinnamespace', array( __CLASS__
, 'pagesinnamespace' ), SFH_NO_HASH
);
81 static function intFunction( $parser, $part1 = '' /*, ... */ ) {
82 if ( strval( $part1 ) !== '' ) {
83 $args = array_slice( func_get_args(), 2 );
84 $message = wfMsgGetKey( $part1, true, false, false );
85 $message = wfMsgReplaceArgs( $message, $args );
86 $message = $parser->replaceVariables( $message ); // like $wgMessageCache->transform()
89 return array( 'found' => false );
93 static function formatDate( $parser, $date, $defaultPref = null ) {
94 $df = DateFormatter
::getInstance();
98 $pref = $parser->mOptions
->getDateFormat();
100 // Specify a different default date format other than the the normal default
101 // iff the user has 'default' for their setting
102 if ($pref == 'default' && $defaultPref)
103 $pref = $defaultPref;
105 $date = $df->reformat( $pref, $date, array('match-whole') );
109 static function ns( $parser, $part1 = '' ) {
111 if ( intval( $part1 ) ||
$part1 == "0" ) {
112 $index = intval( $part1 );
114 $index = $wgContLang->getNsIndex( str_replace( ' ', '_', $part1 ) );
116 if ( $index !== false ) {
117 return $wgContLang->getFormattedNsText( $index );
119 return array( 'found' => false );
123 static function urlencode( $parser, $s = '' ) {
124 return urlencode( $s );
127 static function lcfirst( $parser, $s = '' ) {
129 return $wgContLang->lcfirst( $s );
132 static function ucfirst( $parser, $s = '' ) {
134 return $wgContLang->ucfirst( $s );
137 static function lc( $parser, $s = '' ) {
139 if ( is_callable( array( $parser, 'markerSkipCallback' ) ) ) {
140 return $parser->markerSkipCallback( $s, array( $wgContLang, 'lc' ) );
142 return $wgContLang->lc( $s );
146 static function uc( $parser, $s = '' ) {
148 if ( is_callable( array( $parser, 'markerSkipCallback' ) ) ) {
149 return $parser->markerSkipCallback( $s, array( $wgContLang, 'uc' ) );
151 return $wgContLang->uc( $s );
155 static function localurl( $parser, $s = '', $arg = null ) { return self
::urlFunction( 'getLocalURL', $s, $arg ); }
156 static function localurle( $parser, $s = '', $arg = null ) { return self
::urlFunction( 'escapeLocalURL', $s, $arg ); }
157 static function fullurl( $parser, $s = '', $arg = null ) { return self
::urlFunction( 'getFullURL', $s, $arg ); }
158 static function fullurle( $parser, $s = '', $arg = null ) { return self
::urlFunction( 'escapeFullURL', $s, $arg ); }
160 static function urlFunction( $func, $s = '', $arg = null ) {
161 $title = Title
::newFromText( $s );
162 # Due to order of execution of a lot of bits, the values might be encoded
163 # before arriving here; if that's true, then the title can't be created
164 # and the variable will fail. If we can't get a decent title from the first
165 # attempt, url-decode and try for a second.
166 if( is_null( $title ) )
167 $title = Title
::newFromUrl( urldecode( $s ) );
168 if( !is_null( $title ) ) {
169 # Convert NS_MEDIA -> NS_FILE
170 if( $title->getNamespace() == NS_MEDIA
) {
171 $title = Title
::makeTitle( NS_FILE
, $title->getDBkey() );
173 if( !is_null( $arg ) ) {
174 $text = $title->$func( $arg );
176 $text = $title->$func();
180 return array( 'found' => false );
184 static function formatNum( $parser, $num = '', $raw = null) {
185 if ( self
::israw( $raw ) ) {
186 return $parser->getFunctionLang()->parseFormattedNumber( $num );
188 return $parser->getFunctionLang()->formatNum( $num );
192 static function grammar( $parser, $case = '', $word = '' ) {
193 return $parser->getFunctionLang()->convertGrammar( $word, $case );
196 static function gender( $parser, $user ) {
197 wfProfileIn( __METHOD__
);
198 $forms = array_slice( func_get_args(), 2);
201 $gender = User
::getDefaultOption( 'gender' );
204 $title = Title
::newFromText( $user );
206 if (is_object( $title ) && $title->getNamespace() == NS_USER
)
207 $user = $title->getText();
209 // check parameter, or use $wgUser if in interface message
210 $user = User
::newFromName( $user );
212 $gender = $user->getOption( 'gender' );
213 } elseif ( $parser->mOptions
->getInterfaceMessage() ) {
215 $gender = $wgUser->getOption( 'gender' );
217 $ret = $parser->getFunctionLang()->gender( $gender, $forms );
218 wfProfileOut( __METHOD__
);
221 static function plural( $parser, $text = '') {
222 $forms = array_slice( func_get_args(), 2);
223 $text = $parser->getFunctionLang()->parseFormattedNumber( $text );
224 return $parser->getFunctionLang()->convertPlural( $text, $forms );
228 * Override the title of the page when viewed, provided we've been given a
229 * title which will normalise to the canonical title
231 * @param Parser $parser Parent parser
232 * @param string $text Desired title text
235 static function displaytitle( $parser, $text = '' ) {
236 global $wgRestrictDisplayTitle;
238 #list of disallowed tags for DISPLAYTITLE
239 #these will be escaped even though they are allowed in normal wiki text
240 $bad = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li',
241 'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rp' );
243 #only requested titles that normalize to the actual title are allowed through
244 #mimic the escaping process that occurs in OutputPage::setPageTitle
245 $text = Sanitizer
::normalizeCharReferences( Sanitizer
::removeHTMLtags( $text, null, array(), array(), $bad ) );
246 $title = Title
::newFromText( Sanitizer
::stripAllTags( $text ) );
248 if( !$wgRestrictDisplayTitle ) {
249 $parser->mOutput
->setDisplayTitle( $text );
251 if ( $title instanceof Title
&& $title->getFragment() == '' && $title->equals( $parser->mTitle
) ) {
252 $parser->mOutput
->setDisplayTitle( $text );
259 static function isRaw( $param ) {
262 $mwRaw =& MagicWord
::get( 'rawsuffix' );
264 if ( is_null( $param ) ) {
267 return $mwRaw->match( $param );
271 static function formatRaw( $num, $raw ) {
272 if( self
::isRaw( $raw ) ) {
276 return $wgContLang->formatNum( $num );
279 static function numberofpages( $parser, $raw = null ) {
280 return self
::formatRaw( SiteStats
::pages(), $raw );
282 static function numberofusers( $parser, $raw = null ) {
283 return self
::formatRaw( SiteStats
::users(), $raw );
285 static function numberofactiveusers( $parser, $raw = null ) {
286 return self
::formatRaw( SiteStats
::activeUsers(), $raw );
288 static function numberofarticles( $parser, $raw = null ) {
289 return self
::formatRaw( SiteStats
::articles(), $raw );
291 static function numberoffiles( $parser, $raw = null ) {
292 return self
::formatRaw( SiteStats
::images(), $raw );
294 static function numberofadmins( $parser, $raw = null ) {
295 return self
::formatRaw( SiteStats
::numberingroup('sysop'), $raw );
297 static function numberofedits( $parser, $raw = null ) {
298 return self
::formatRaw( SiteStats
::edits(), $raw );
300 static function numberofviews( $parser, $raw = null ) {
301 return self
::formatRaw( SiteStats
::views(), $raw );
303 static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) {
304 return self
::formatRaw( SiteStats
::pagesInNs( intval( $namespace ) ), $raw );
306 static function numberingroup( $parser, $name = '', $raw = null) {
307 return self
::formatRaw( SiteStats
::numberingroup( strtolower( $name ) ), $raw );
312 * Given a title, return the namespace name that would be given by the
313 * corresponding magic word
314 * Note: function name changed to "mwnamespace" rather than "namespace"
315 * to not break PHP 5.3
317 static function mwnamespace( $parser, $title = null ) {
318 $t = Title
::newFromText( $title );
321 return str_replace( '_', ' ', $t->getNsText() );
323 static function namespacee( $parser, $title = null ) {
324 $t = Title
::newFromText( $title );
327 return wfUrlencode( $t->getNsText() );
329 static function talkspace( $parser, $title = null ) {
330 $t = Title
::newFromText( $title );
331 if ( is_null($t) ||
!$t->canTalk() )
333 return str_replace( '_', ' ', $t->getTalkNsText() );
335 static function talkspacee( $parser, $title = null ) {
336 $t = Title
::newFromText( $title );
337 if ( is_null($t) ||
!$t->canTalk() )
339 return wfUrlencode( $t->getTalkNsText() );
341 static function subjectspace( $parser, $title = null ) {
342 $t = Title
::newFromText( $title );
345 return str_replace( '_', ' ', $t->getSubjectNsText() );
347 static function subjectspacee( $parser, $title = null ) {
348 $t = Title
::newFromText( $title );
351 return wfUrlencode( $t->getSubjectNsText() );
354 * Functions to get and normalize pagenames, corresponding to the magic words
357 static function pagename( $parser, $title = null ) {
358 $t = Title
::newFromText( $title );
361 return wfEscapeWikiText( $t->getText() );
363 static function pagenamee( $parser, $title = null ) {
364 $t = Title
::newFromText( $title );
367 return $t->getPartialURL();
369 static function fullpagename( $parser, $title = null ) {
370 $t = Title
::newFromText( $title );
371 if ( is_null($t) ||
!$t->canTalk() )
373 return wfEscapeWikiText( $t->getPrefixedText() );
375 static function fullpagenamee( $parser, $title = null ) {
376 $t = Title
::newFromText( $title );
377 if ( is_null($t) ||
!$t->canTalk() )
379 return $t->getPrefixedURL();
381 static function subpagename( $parser, $title = null ) {
382 $t = Title
::newFromText( $title );
385 return $t->getSubpageText();
387 static function subpagenamee( $parser, $title = null ) {
388 $t = Title
::newFromText( $title );
391 return $t->getSubpageUrlForm();
393 static function basepagename( $parser, $title = null ) {
394 $t = Title
::newFromText( $title );
397 return $t->getBaseText();
399 static function basepagenamee( $parser, $title = null ) {
400 $t = Title
::newFromText( $title );
403 return wfUrlEncode( str_replace( ' ', '_', $t->getBaseText() ) );
405 static function talkpagename( $parser, $title = null ) {
406 $t = Title
::newFromText( $title );
407 if ( is_null($t) ||
!$t->canTalk() )
409 return wfEscapeWikiText( $t->getTalkPage()->getPrefixedText() );
411 static function talkpagenamee( $parser, $title = null ) {
412 $t = Title
::newFromText( $title );
413 if ( is_null($t) ||
!$t->canTalk() )
415 return $t->getTalkPage()->getPrefixedUrl();
417 static function subjectpagename( $parser, $title = null ) {
418 $t = Title
::newFromText( $title );
421 return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedText() );
423 static function subjectpagenamee( $parser, $title = null ) {
424 $t = Title
::newFromText( $title );
427 return $t->getSubjectPage()->getPrefixedUrl();
431 * Return the number of pages in the given category, or 0 if it's nonexis-
432 * tent. This is an expensive parser function and can't be called too many
435 static function pagesincategory( $parser, $name = '', $raw = null ) {
436 static $cache = array();
437 $category = Category
::newFromName( $name );
439 if( !is_object( $category ) ) {
441 return self
::formatRaw( 0, $raw );
444 # Normalize name for cache
445 $name = $category->getName();
448 if( isset( $cache[$name] ) ) {
449 $count = $cache[$name];
450 } elseif( $parser->incrementExpensiveFunctionCount() ) {
451 $count = $cache[$name] = (int)$category->getPageCount();
453 return self
::formatRaw( $count, $raw );
457 * Return the size of the given page, or 0 if it's nonexistent. This is an
458 * expensive parser function and can't be called too many times per page.
460 * @FIXME This doesn't work correctly on preview for getting the size of
462 * @FIXME Title::getLength() documentation claims that it adds things to
463 * the link cache, so the local cache here should be unnecessary, but in
464 * fact calling getLength() repeatedly for the same $page does seem to
465 * run one query for each call?
467 static function pagesize( $parser, $page = '', $raw = null ) {
468 static $cache = array();
469 $title = Title
::newFromText($page);
471 if( !is_object( $title ) ) {
473 return self
::formatRaw( 0, $raw );
476 # Normalize name for cache
477 $page = $title->getPrefixedText();
480 if( isset( $cache[$page] ) ) {
481 $length = $cache[$page];
482 } elseif( $parser->incrementExpensiveFunctionCount() ) {
483 $rev = Revision
::newFromTitle($title);
484 $id = $rev ?
$rev->getPage() : 0;
485 $length = $cache[$page] = $rev ?
$rev->getSize() : 0;
487 // Register dependency in templatelinks
488 $parser->mOutput
->addTemplate( $title, $id, $rev ?
$rev->getId() : 0 );
490 return self
::formatRaw( $length, $raw );
494 * Returns the requested protection level for the current page
496 static function protectionlevel( $parser, $type = '' ) {
497 $restrictions = $parser->mTitle
->getRestrictions( strtolower( $type ) );
498 # Title::getRestrictions returns an array, its possible it may have
499 # multiple values in the future
500 return implode( $restrictions, ',' );
503 static function language( $parser, $arg = '' ) {
505 $lang = $wgContLang->getLanguageName( strtolower( $arg ) );
506 return $lang != '' ?
$lang : $arg;
510 * Returns the number of contributions by a certain user. This is an
511 * expensive parser function and can't be called too many times per page
513 static function numberofcontribs( $parser, $user = null, $raw = null ) {
514 if ( is_null($user) ||
!User
::isValidUserName( $user ) ) {
517 if ( !$parser->incrementExpensiveFunctionCount() ) {
520 $u = User
::newFromName( $user );
521 $id = User
::idFromName( $u->mName
);
522 return self
::formatRaw( User
::edits( $id ), $raw );
526 * Unicode-safe str_pad with the restriction that $length is forced to be <= 500
528 static function pad( $string, $length, $padding = '0', $direction = STR_PAD_RIGHT
) {
529 $lengthOfPadding = mb_strlen( $padding );
530 if ( $lengthOfPadding == 0 ) return $string;
532 # The remaining length to add counts down to 0 as padding is added
533 $length = min( $length, 500 ) - mb_strlen( $string );
534 # $finalPadding is just $padding repeated enough times so that
535 # mb_strlen( $string ) + mb_strlen( $finalPadding ) == $length
537 while ( $length > 0 ) {
538 # If $length < $lengthofPadding, truncate $padding so we get the
539 # exact length desired.
540 $finalPadding .= mb_substr( $padding, 0, $length );
541 $length -= $lengthOfPadding;
544 if ( $direction == STR_PAD_LEFT
) {
545 return $finalPadding . $string;
547 return $string . $finalPadding;
551 static function padleft( $parser, $string = '', $length = 0, $padding = '0' ) {
552 return self
::pad( $string, $length, $padding, STR_PAD_LEFT
);
555 static function padright( $parser, $string = '', $length = 0, $padding = '0' ) {
556 return self
::pad( $string, $length, $padding );
559 static function anchorencode( $parser, $text ) {
560 $a = urlencode( $text );
561 $a = strtr( $a, array( '%' => '.', '+' => '_' ) );
562 # leave colons alone, however
563 $a = str_replace( '.3A', ':', $a );
567 static function special( $parser, $text ) {
568 $title = SpecialPage
::getTitleForAlias( $text );
570 return $title->getPrefixedText();
572 return wfMsgForContent( 'nosuchspecialpage' );
576 public static function defaultsort( $parser, $text ) {
577 $text = trim( $text );
578 if( strlen( $text ) == 0 )
580 $old = $parser->getCustomDefaultSort();
581 $parser->setDefaultSort( $text );
582 if( $old === false ||
$old == $text )
585 return( '<span class="error">' .
586 wfMsg( 'duplicate-defaultsort',
587 htmlspecialchars( $old ),
588 htmlspecialchars( $text ) ) .
592 public static function filepath( $parser, $name='', $option='' ) {
593 $file = wfFindFile( $name );
595 $url = $file->getFullUrl();
596 if( $option == 'nowiki' ) {
597 return array( $url, 'nowiki' => true );
606 * Parser function to extension tag adaptor
608 public static function tagObj( $parser, $frame, $args ) {
610 if ( !count( $args ) ) {
613 $tagName = strtolower( trim( $frame->expand( array_shift( $args ) ) ) );
615 if ( count( $args ) ) {
616 $inner = $frame->expand( array_shift( $args ) );
621 $stripList = $parser->getStripList();
622 if ( !in_array( $tagName, $stripList ) ) {
623 return '<span class="error">' .
624 wfMsg( 'unknown_extension_tag', $tagName ) .
628 $attributes = array();
629 foreach ( $args as $arg ) {
630 $bits = $arg->splitArg();
631 if ( strval( $bits['index'] ) === '' ) {
632 $name = trim( $frame->expand( $bits['name'], PPFrame
::STRIP_COMMENTS
) );
633 $value = trim( $frame->expand( $bits['value'] ) );
634 if ( preg_match( '/^(?:["\'](.+)["\']|""|\'\')$/s', $value, $m ) ) {
635 $value = isset( $m[1] ) ?
$m[1] : '';
637 $attributes[$name] = $value;
644 'attributes' => $attributes,
645 'close' => "</$tagName>",
647 return $parser->extensionSubstitution( $params, $frame );