1 | <?php |
||
17 | class ScribuntoLuaLibrary extends Scribunto_LuaLibraryBase { |
||
18 | |||
19 | /** |
||
20 | * @var LibraryFactory |
||
21 | */ |
||
22 | private $libraryFactory; |
||
23 | |||
24 | /** |
||
25 | * This is the name of the key for error messages |
||
26 | * |
||
27 | * @var string |
||
28 | * @since 1.0 |
||
29 | */ |
||
30 | const SMW_ERROR_FIELD = 'error'; |
||
31 | |||
32 | /** |
||
33 | * @since 1.0 |
||
34 | */ |
||
35 | 43 | public function register() { |
|
48 | |||
49 | /** |
||
50 | * This mirrors the functionality of the parser function #ask and makes it |
||
51 | * available in lua. |
||
52 | * |
||
53 | * @since 1.0 |
||
54 | * |
||
55 | * @param string|array $arguments parameters passed from lua, string or array depending on call |
||
56 | * |
||
57 | * @return array array( null ) or array[] |
||
58 | */ |
||
59 | 9 | public function ask( $arguments = null ) { |
|
77 | 2 | ||
78 | /** |
||
79 | 8 | * Returns property type |
|
80 | * |
||
81 | * @since 1.0 |
||
82 | * |
||
83 | * @param string $propertyName |
||
84 | * |
||
85 | * @return array |
||
86 | */ |
||
87 | public function getPropertyType( $propertyName = null ) { |
||
104 | |||
105 | /** |
||
106 | 3 | * Returns query results in for of the standard API return format |
|
107 | * |
||
108 | * @since 1.0 |
||
109 | * |
||
110 | * @param string|array $arguments |
||
111 | * |
||
112 | * @return array |
||
113 | */ |
||
114 | public function getQueryResult( $arguments = null ) { |
||
134 | 7 | ||
135 | /** |
||
136 | * This mirrors the functionality of the parser function #info and makes it |
||
137 | * available to lua. |
||
138 | * |
||
139 | * @since 1.0 |
||
140 | * |
||
141 | * @param string $text text to show inside the info popup |
||
142 | * @param string $icon identifier for the icon to use |
||
143 | * |
||
144 | * @return string[] |
||
145 | */ |
||
146 | public function info( $text, $icon = 'info' ) { |
||
174 | 4 | ||
175 | /** |
||
176 | * This mirrors the functionality of the parser function #set and makes it |
||
177 | * available in lua. |
||
178 | * |
||
179 | * @since 1.0 |
||
180 | * |
||
181 | * @param string|array $arguments arguments passed from lua, string or array depending on call |
||
182 | * |
||
183 | * @return null|array|array[] |
||
184 | */ |
||
185 | public function set( $arguments ) { |
||
210 | 16 | ||
211 | /** |
||
212 | * This mirrors the functionality of the parser function #subobject and |
||
213 | * makes it available to lua. |
||
214 | * |
||
215 | * @param string|array $arguments arguments passed from lua, string or array depending on call |
||
216 | * @param string $subobjectId if you need to manually assign an id, do this here |
||
217 | * |
||
218 | * @return null|array|array[] |
||
219 | */ |
||
220 | public function subobject( $arguments, $subobjectId = null ) { |
||
254 | 17 | ||
255 | /** |
||
256 | * This takes an array and converts it so, that the result is a viable lua table. |
||
257 | * I.e. the resulting table has its numerical indices start with 1 |
||
258 | * If `$ar` is not an array, it is simply returned |
||
259 | * @param mixed $ar |
||
260 | * @return mixed array |
||
261 | */ |
||
262 | private function convertArrayToLuaTable( $ar ) { |
||
273 | 18 | ||
274 | 25 | /** |
|
275 | 25 | * Takes a result returned from a parser function call and prepares it to be |
|
276 | * used as parsed string. |
||
277 | * |
||
278 | 43 | * @since 1.0 |
|
279 | * |
||
280 | * @param string|array $parserFunctionResult |
||
281 | * |
||
282 | 43 | * @return string |
|
283 | */ |
||
284 | private function doPostProcessParserFunctionCallResult( $parserFunctionResult ) { |
||
301 | |||
302 | 54 | /** |
|
303 | * Returns the LibraryFactory singleton (and creates it first, if not already present) |
||
304 | * |
||
305 | * @since 1.0 |
||
306 | * |
||
307 | * @return LibraryFactory |
||
308 | */ |
||
309 | private function getLibraryFactory() { |
||
321 | |||
322 | /** |
||
323 | * Tests, if supplied parameter `$queryResult` is a valid {@see QueryResult} |
||
324 | * |
||
325 | * @since 1.0 |
||
326 | * |
||
327 | * @param mixed $queryResult |
||
328 | 54 | * |
|
329 | * @return bool |
||
330 | */ |
||
331 | 54 | private function isAQueryResult( $queryResult ) { |
|
334 | |||
335 | /** |
||
336 | * Takes the $arguments passed from lua and pre-processes them: make sure, |
||
337 | 54 | * we have a sequence array (not associative) |
|
338 | 54 | * |
|
339 | 50 | * @since 1.0 |
|
340 | 19 | * |
|
341 | 19 | * @param string|array $arguments |
|
342 | 50 | * |
|
343 | 54 | * @return array |
|
344 | */ |
||
345 | 54 | private function processLuaArguments( $arguments ) { |
|
364 | |||
365 | } |
||
366 |