mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-30 19:14:22 +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',
|
'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()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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' )
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue