@@ -24,16 +24,29 @@ public static function options()
24
24
private static function arg_desc ($ arg_node )
25
25
{
26
26
$ attrs = $ arg_node ->attributes ();
27
- return array (
27
+ $ result = array (
28
28
'name ' => (string )$ attrs ['name ' ],
29
29
'is_required ' => $ arg_node ->getName () == 'req ' ,
30
30
'is_deprecated ' => (isset ($ attrs ['class ' ]) && (strpos ($ attrs ['class ' ], 'deprecated ' ) !== false )),
31
31
'class ' => 'public ' ,
32
+ 'infotags ' => [],
32
33
'description ' =>
33
34
(isset ($ attrs ['default ' ]) ? ("<p>Default value: <b> " .$ attrs ['default ' ]."</b></p> " ) : "" ).
34
35
self ::get_inner_xml ($ arg_node ),
35
-
36
36
);
37
+ if (isset ($ attrs ['infotags ' ])) {
38
+ foreach (explode (" " , (string )$ attrs ['infotags ' ]) as $ infotag ) {
39
+ switch ($ infotag ) {
40
+ case 'ocpl-specific ' :
41
+ case 'ocde-specific ' :
42
+ $ result ['infotags ' ][] = $ infotag ;
43
+ break ;
44
+ default :
45
+ throw new Exception ("Invalid infotag ' " .$ infotag ." in $ methodname.xml " );
46
+ }
47
+ }
48
+ }
49
+ return $ result ;
37
50
}
38
51
39
52
private static function get_inner_xml ($ node )
@@ -47,7 +60,7 @@ private static function get_inner_xml($node)
47
60
48
61
/* Find and replace %okapi:plugins%. */
49
62
50
- $ s = preg_replace_callback ('~%OKAPI:([a-z:/_#]+)%~ ' , array ("self " , "plugin_callback " ), $ s );
63
+ $ s = preg_replace_callback ('~%OKAPI:([a-z:/_#- ]+)%~ ' , array ("self " , "plugin_callback " ), $ s );
51
64
52
65
return $ s ;
53
66
}
@@ -78,6 +91,9 @@ private static function get_inner_xml($node)
78
91
* <a href="%OKAPI:methodretref:#returned_key%">any text</a> - to reference
79
92
* returned value within current method
80
93
*
94
+ * %OKAPI:infotag:TAGNAME% - to output a HTML with a proper infotag "badge".
95
+ * TAGNAME must match one of the infotags defined in services/apiref/method.
96
+ *
81
97
* NOTE!
82
98
*
83
99
* Since returned JSON dictionaries are not standardized (they are simply plain
@@ -120,6 +136,8 @@ public static function plugin_callback($matches)
120
136
$ result .= $ elements [1 ];
121
137
}
122
138
return $ result ;
139
+ case 'infotag ' :
140
+ return Okapi::format_infotags ([$ arr [1 ]]);
123
141
default :
124
142
throw new Exception ("Unknown plugin: " .$ input );
125
143
}
@@ -147,7 +165,8 @@ public static function call(OkapiRequest $request)
147
165
'min_auth_level ' => $ options ['min_auth_level ' ],
148
166
'oauth_consumer ' => $ options ['min_auth_level ' ] >= 2 ,
149
167
'oauth_token ' => $ options ['min_auth_level ' ] >= 3 ,
150
- )
168
+ ),
169
+ "infotags " => [],
151
170
);
152
171
if (!$ docs ->brief )
153
172
throw new Exception ("Missing <brief> element in the $ methodname.xml file. " );
@@ -167,6 +186,18 @@ public static function call(OkapiRequest $request)
167
186
if (!$ docs ->desc )
168
187
throw new Exception ("Missing <desc> element in the $ methodname.xml file. " );
169
188
$ result ['description ' ] = self ::get_inner_xml ($ docs ->desc );
189
+ if ($ docs ->infotags ) {
190
+ foreach (explode (" " , (string )$ docs ->infotags ) as $ infotag ) {
191
+ switch ($ infotag ) {
192
+ case 'ocpl-specific ' :
193
+ case 'ocde-specific ' :
194
+ $ result ['infotags ' ][] = $ infotag ;
195
+ break ;
196
+ default :
197
+ throw new Exception ("Invalid infotag ' " .$ infotag ." in $ methodname.xml " );
198
+ }
199
+ }
200
+ }
170
201
$ result ['arguments ' ] = array ();
171
202
foreach ($ docs ->req as $ arg ) { $ result ['arguments ' ][] = self ::arg_desc ($ arg ); }
172
203
foreach ($ docs ->opt as $ arg ) { $ result ['arguments ' ][] = self ::arg_desc ($ arg ); }
@@ -207,13 +238,15 @@ public static function call(OkapiRequest $request)
207
238
'is_required ' => false ,
208
239
'is_deprecated ' => false ,
209
240
'class ' => 'common-formatting ' ,
241
+ 'infotags ' => [],
210
242
'description ' => "<i>Standard <a href=' " .Settings::get ('SITE_URL ' )."okapi/introduction.html#common-formatting'>common formatting</a> argument.</i> "
211
243
);
212
244
$ result ['arguments ' ][] = array (
213
245
'name ' => 'callback ' ,
214
246
'is_required ' => false ,
215
247
'is_deprecated ' => false ,
216
248
'class ' => 'common-formatting ' ,
249
+ 'infotags ' => [],
217
250
'description ' => "<i>Standard <a href=' " .Settings::get ('SITE_URL ' )."okapi/introduction.html#common-formatting'>common formatting</a> argument.</i> "
218
251
);
219
252
}
0 commit comments