Expose PPFrame::getTitle to Lua

This field already exists in PHP with exactly the content requested in
bug 47089, so we may as well expose it on the frame object.

Bug: 47089
Change-Id: I672820589f6ebc7c4daad29b5eb156733a5bc5cc
This commit is contained in:
Brad Jorsch 2013-12-06 13:10:39 -05:00 committed by Tim Starling
parent 7cab36cea5
commit 0763e22292
3 changed files with 27 additions and 0 deletions

View file

@ -81,6 +81,7 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase {
'preprocess', 'preprocess',
'incrementExpensiveFunctionCount', 'incrementExpensiveFunctionCount',
'isSubsting', 'isSubsting',
'getFrameTitle',
); );
$lib = array(); $lib = array();
@ -401,6 +402,14 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase {
return array( $newFrameId ); return array( $newFrameId );
} }
/**
* Handler for getTitle()
*/
function getFrameTitle( $frameId ) {
$frame = $this->getFrameById( $frameId );
return array( $frame->getTitle()->getPrefixedText() );
}
/** /**
* Handler for getExpandedArgument() * Handler for getExpandedArgument()
*/ */

View file

@ -536,6 +536,11 @@ local function newFrame( frameId, ... )
) )
end end
function frame:getTitle()
checkSelf( self, 'getTitle' )
return php.getFrameTitle( frameId )
end
-- For backwards compat -- For backwards compat
function frame:argumentPairs() function frame:argumentPairs()
checkSelf( self, 'argumentPairs' ) checkSelf( self, 'argumentPairs' )

View file

@ -137,6 +137,10 @@ function p.isSubsting( frame )
return tostring( mw.isSubsting() ) return tostring( mw.isSubsting() )
end end
function p.getFrameTitle( frame )
return frame:getTitle()
end
return p return p
!! endarticle !! endarticle
@ -385,3 +389,12 @@ Scribunto: isSubsting during normal parse
<p>false <p>false
</p> </p>
!! end !! end
!! test
Scribunto: frame:getTitle
!! input
{{#invoke:test|getFrameTitle}}
!! result
<p>Module:Test
</p>
!! end