$output = MathRenderer::renderMath( $content );
break;
case 'gallery':
- $output = $this->renderImageGallery( $content );
+ $output = $this->renderImageGallery( $content, $params );
break;
default:
if( isset( $this->mTagHooks[$tagName] ) ) {
$text = $linestart . $wgContLang->getNsText( intval( $part1 ) );
$found = true;
} else {
- $index = Namespace::getCanonicalIndex( strtolower( $part1 ) );
+ $param = str_replace( ' ', '_', strtolower( $part1 ) );
+ $index = Namespace::getCanonicalIndex( strtolower( $param ) );
if ( !is_null( $index ) ) {
$text = $linestart . $wgContLang->getNsText( $index );
$found = true;
$colonPos = strpos( $part1, ':' );
if ( $colonPos !== false ) {
$function = strtolower( substr( $part1, 1, $colonPos - 1 ) );
+ if ( !isset( $this->mFunctionHooks[$function] ) ) {
+ foreach ($this->mFunctionHooks as $key => $value) {
+ if( is_int( $key ) ) {
+ $mwExtension =& MagicWord::get( $key );
+ if( $mwExtension->matchVariableStartToEnd( $function ) ) {
+ $function = $key;
+ break;
+ }
+ }
+ }
+ }
if ( isset( $this->mFunctionHooks[$function] ) ) {
$funcArgs = array_map( 'trim', $args );
$funcArgs = array_merge( array( &$this, trim( substr( $part1, $colonPos + 1 ) ) ), $funcArgs );
$substText = '{{' . $substWord->getSynonym( 0 );
$text = preg_replace( $substRegex, $substText, $text );
- $text = cleanSigInSig( $text );
+ $text = $this->cleanSigInSig( $text );
$text = $this->replaceVariables( $text );
$this->clearState();
*
* @public
*
- * @param string $name The function name. Function names are case-insensitive.
+ * @param mixed $id The magic word ID, or (deprecated) the function name. Function names are case-insensitive.
* @param mixed $callback The callback function (and object) to use
*
* @return The old callback function for this name, if any
*/
- function setFunctionHook( $name, $callback ) {
- $name = strtolower( $name );
- $oldVal = @$this->mFunctionHooks[$name];
- $this->mFunctionHooks[$name] = $callback;
+ function setFunctionHook( $id, $callback ) {
+ if( is_string( $id ) ) {
+ $id = strtolower( $id );
+ }
+ $oldVal = @$this->mFunctionHooks[$id];
+ $this->mFunctionHooks[$id] = $callback;
return $oldVal;
}
* labeled 'The number "1"' and
* 'A tree'.
*/
- function renderImageGallery( $text ) {
+ function renderImageGallery( $text, $params ) {
$ig = new ImageGallery();
$ig->setShowBytes( false );
$ig->setShowFilename( false );
$ig->setParsing();
- $lines = explode( "\n", $text );
+ $ig->useSkin( $this->mOptions->getSkin() );
+ if( isset( $params['caption'] ) )
+ $ig->setCaption( $params['caption'] );
+
+ $lines = explode( "\n", $text );
foreach ( $lines as $line ) {
# match lines like these:
# Image:someimage.jpg|This is some image