1 | <?php |
||
20 | class ScribuntoLuaLibrary extends Scribunto_LuaLibraryBase { |
||
21 | |||
22 | /** |
||
23 | * This is the name of the key for error messages |
||
24 | * |
||
25 | * @var string |
||
26 | * @since 1.0 |
||
27 | */ |
||
28 | const SMW_ERROR_FIELD = 'error'; |
||
29 | |||
30 | /** |
||
31 | * @since 1.0 |
||
32 | */ |
||
33 | public function register() { |
||
34 | |||
35 | 13 | $lib = array( |
|
36 | 'getPropertyType' => array( $this, 'getPropertyType' ), |
||
37 | 'getQueryResult' => array( $this, 'getQueryResult' ), |
||
38 | 13 | 'info' => array( $this, 'info' ), |
|
39 | 13 | 'set' => array( $this, 'set' ), |
|
40 | 13 | 'subobject' => array( $this, 'subobject' ), |
|
41 | 13 | ); |
|
42 | 13 | ||
43 | $this->getEngine()->registerInterface( __DIR__ . '/' . 'mw.smw.lua', $lib, array() ); |
||
44 | 13 | } |
|
45 | 13 | ||
46 | /** |
||
47 | * Returns query results in for of the standard API return format |
||
48 | * |
||
49 | * @since 1.0 |
||
50 | * |
||
51 | * @param string|array $arguments |
||
52 | * |
||
53 | * @return array |
||
54 | */ |
||
55 | public function getQueryResult( $arguments = null ) { |
||
80 | |||
81 | /** |
||
82 | * Returns property type |
||
83 | * |
||
84 | * @since 1.0 |
||
85 | * |
||
86 | * @param string $propertyName |
||
87 | * |
||
88 | * @return array |
||
89 | */ |
||
90 | public function getPropertyType( $propertyName = null ) { |
||
107 | |||
108 | /** |
||
109 | * This mirrors the functionality of the parser function #info and makes it available to lua. |
||
110 | * |
||
111 | * @since 1.0 |
||
112 | * |
||
113 | * @param string $text text to show inside the info popup |
||
114 | * @param string $icon identifier for the icon to use |
||
115 | * |
||
116 | * @uses \SMW\ParserFunctionFactory::__construct |
||
117 | * |
||
118 | * @return string[] |
||
119 | */ |
||
120 | public function info( $text, $icon = 'info' ) { |
||
148 | |||
149 | /** |
||
150 | * This mirrors the functionality of the parser function #set and makes it available in lua. |
||
151 | * |
||
152 | * @since 1.0 |
||
153 | * |
||
154 | * @param string|array $parameters parameters passed from lua, string or array depending on call |
||
155 | * |
||
156 | * @uses \SMW\ParserFunctionFactory::__construct, ParameterProcessorFactory::newFromArray |
||
157 | * |
||
158 | * @return null|array|array[] |
||
159 | */ |
||
160 | public function set( $parameters ) { |
||
189 | |||
190 | /** |
||
191 | * This mirrors the functionality of the parser function #subobject and makes it available to lua. |
||
192 | * |
||
193 | * @param string|array $parameters parameters passed from lua, string or array depending on call |
||
194 | * @param string $subobjectId if you need to manually assign an id, do this here |
||
195 | * |
||
196 | * @uses \SMW\ParserFunctionFactory::__construct, \SMW\ParameterProcessorFactory::newFromArray |
||
197 | * |
||
198 | * @return null|array|array[] |
||
199 | */ |
||
200 | 6 | public function subobject( $parameters, $subobjectId = null ) { |
|
240 | 4 | ||
241 | /** |
||
242 | 3 | * Takes a result returned from a parser function call and prepares it to be used as parsed string. |
|
243 | 3 | * |
|
244 | 4 | * @since 1.0 |
|
245 | * |
||
246 | 4 | * @param string|array $parserFunctionResult |
|
247 | * |
||
248 | * @return string |
||
249 | */ |
||
250 | private function getParsedResult( $parserFunctionResult ) { |
||
267 | |||
268 | /** |
||
269 | * Takes the $arguments passed from lua and pre-processes them: make sure, we have a sequence array (not associative) |
||
270 | * |
||
271 | * @since 1.0 |
||
272 | * |
||
273 | * @param string|array $arguments |
||
274 | * |
||
275 | * @return array |
||
276 | */ |
||
277 | private function processLuaArguments( $arguments ) { |
||
298 | |||
299 | } |
||
300 |