This repository was archived by the owner on Apr 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapi_methods.php
71 lines (50 loc) · 1.56 KB
/
api_methods.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
include("include/init.php");
loadlib("api");
loadlib("api_methods");
if (! $GLOBALS['cfg']['enable_feature_api']){
error_disabled();
}
if (! $GLOBALS['cfg']['enable_feature_api_documentation']){
error_disabled();
}
if ($GLOBALS['cfg']['api_require_loggedin']){
login_ensure_loggedin();
}
$method_classes = array();
$method_names = array();
ksort($GLOBALS['cfg']['api']['methods']);
$user_id = ($GLOBALS['cfg']['user']) ? $GLOBALS['cfg']['user']['id'] : 0;
foreach ($GLOBALS['cfg']['api']['methods'] as $method_name => $details){
$details['name'] = $method_name;
if (! api_methods_can_view_method($details, $user_id)){
continue;
}
$parts = explode(".", $method_name);
array_pop($parts);
$method_prefix = $parts[0];
$method_class = implode(".", $parts);
if (! is_array($method_classes[$method_class])){
$method_classes[$method_class] = array(
'methods' => array(),
'prefix' => $method_prefix,
);
}
$method_classes[$method_class]['methods'][] = $details;
$method_names[] = $details['name'];
}
foreach ($method_classes as $class_name => $ignore){
usort($method_classes[$class_name]['methods'], function($a, $b) {
return strcmp($a['name'], $b['name']);
});
}
$GLOBALS['smarty']->assign_by_ref("method_classes", $method_classes);
$formats = $GLOBALS['cfg']['api']['formats'];
$GLOBALS['smarty']->assign_by_ref("response_formats", $formats);
if (get_isset("print")){
$GLOBALS['smarty']->display("page_api_methods_print.txt");
exit();
}
$GLOBALS['smarty']->display("page_api_methods.txt");
exit();
?>