mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-24 00:05:00 +00:00
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:
parent
7cab36cea5
commit
0763e22292
|
@ -81,6 +81,7 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase {
|
|||
'preprocess',
|
||||
'incrementExpensiveFunctionCount',
|
||||
'isSubsting',
|
||||
'getFrameTitle',
|
||||
);
|
||||
|
||||
$lib = array();
|
||||
|
@ -401,6 +402,14 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase {
|
|||
return array( $newFrameId );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for getTitle()
|
||||
*/
|
||||
function getFrameTitle( $frameId ) {
|
||||
$frame = $this->getFrameById( $frameId );
|
||||
return array( $frame->getTitle()->getPrefixedText() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for getExpandedArgument()
|
||||
*/
|
||||
|
|
|
@ -536,6 +536,11 @@ local function newFrame( frameId, ... )
|
|||
)
|
||||
end
|
||||
|
||||
function frame:getTitle()
|
||||
checkSelf( self, 'getTitle' )
|
||||
return php.getFrameTitle( frameId )
|
||||
end
|
||||
|
||||
-- For backwards compat
|
||||
function frame:argumentPairs()
|
||||
checkSelf( self, 'argumentPairs' )
|
||||
|
|
|
@ -137,6 +137,10 @@ function p.isSubsting( frame )
|
|||
return tostring( mw.isSubsting() )
|
||||
end
|
||||
|
||||
function p.getFrameTitle( frame )
|
||||
return frame:getTitle()
|
||||
end
|
||||
|
||||
return p
|
||||
!! endarticle
|
||||
|
||||
|
@ -385,3 +389,12 @@ Scribunto: isSubsting during normal parse
|
|||
<p>false
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Scribunto: frame:getTitle
|
||||
!! input
|
||||
{{#invoke:test|getFrameTitle}}
|
||||
!! result
|
||||
<p>Module:Test
|
||||
</p>
|
||||
!! end
|
||||
|
|
Loading…
Reference in a new issue