$pageLang = $this->getFunctionLang();
switch ( $index ) {
+ case '!':
+ $value = '|';
+ break;
case 'currentmonth':
$value = $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'm' ) );
break;
* private variables.**
*
* @param string $tag The tag to use, e.g. 'hook' for "<hook>"
- * @param mixed $callback The callback function (and object) to use for the tag
+ * @param callable $callback The callback function (and object) to use for the tag
* @throws MWException
- * @return mixed|null The old value of the mTagHooks array associated with the hook
+ * @return callable|null The old value of the mTagHooks array associated with the hook
*/
public function setHook( $tag, $callback ) {
$tag = strtolower( $tag );
* @todo better document or deprecate this
*
* @param string $tag The tag to use, e.g. 'hook' for "<hook>"
- * @param mixed $callback The callback function (and object) to use for the tag
+ * @param callable $callback The callback function (and object) to use for the tag
* @throws MWException
- * @return mixed|null The old value of the mTagHooks array associated with the hook
+ * @return callable|null The old value of the mTagHooks array associated with the hook
*/
function setTransparentTagHook( $tag, $callback ) {
$tag = strtolower( $tag );
* isHTML The returned text is HTML, armour it against wikitext transformation
*
* @param string $id The magic word ID
- * @param mixed $callback The callback function (and object) to use
+ * @param callable $callback The callback function (and object) to use
* @param int $flags A combination of the following flags:
* SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{#if:...}}
*
$ig->add( $title, $label, $alt, $link, $handlerOptions );
}
$html = $ig->toHTML();
+ wfRunHooks( 'AfterParserFetchFileAndTitle', array( $this, $ig, &$html ) );
wfProfileOut( __METHOD__ );
return $html;
}
return $html;
}
+
+ /**
+ * Return this parser if it is not doing anything, otherwise
+ * get a fresh parser. You can use this method by doing
+ * $myParser = $wgParser->getFreshParser(), or more simply
+ * $wgParser->getFreshParser()->parse( ... );
+ * if you're unsure if $wgParser is safe to use.
+ *
+ * @since 1.24
+ * @return Parser A parser object that is not parsing anything
+ */
+ public function getFreshParser() {
+ global $wgParserConf;
+ if ( $this->mInParse ) {
+ return new $wgParserConf['class']( $wgParserConf );
+ } else {
+ return $this;
+ }
+ }
}