forked from science-ation/science-ation
Be a bit smarter with "notimplemented", add API impelmentation status, and basic details to the apidocs page
This commit is contained in:
parent
b5ed7c174f
commit
8b2de95005
21
api.php
21
api.php
@ -380,41 +380,48 @@ switch($request[0]) {
|
||||
}
|
||||
echo json_encode($ret);
|
||||
|
||||
/* APIDOC: zNOTIMPLEMENTED_school/list
|
||||
/* APIDOC: school/list
|
||||
notimplemented
|
||||
description(list schools)
|
||||
return(schools array)
|
||||
*/
|
||||
|
||||
/* APIDOC: zNOTIMPLEMENTED_account/edit
|
||||
/* APIDOC: account/edit
|
||||
notimplemented
|
||||
description(edit account information)
|
||||
post(account array)
|
||||
return(account array)
|
||||
*/
|
||||
|
||||
/* APIDOC: zNOTIMPLEMENTED_user/edit
|
||||
/* APIDOC: user/edit
|
||||
notimplemented
|
||||
description(edit user information for current conference)
|
||||
post(user array)
|
||||
return(user array)
|
||||
*/
|
||||
|
||||
/* APIDOC: zNOTIMPLEMENTED_user/connect_teacher_to_school
|
||||
/* APIDOC: user/connect_teacher_to_school
|
||||
notimplemented
|
||||
description(connects the current users teacher role to the specified school usign the schools access code)
|
||||
post(schools_id integer, accesscode varchar(16))
|
||||
return(school array)
|
||||
*/
|
||||
|
||||
/* APIDOC: zNOTIMPLEMENTED_role/list
|
||||
/* APIDOC: role/list
|
||||
notimplemented
|
||||
description(list roles and their corresponding registration types)
|
||||
return(roles array)
|
||||
*/
|
||||
|
||||
/* APIDOC: zNOTIMPLEMENTED_role/add
|
||||
/* APIDOC: role/add
|
||||
notimplemented
|
||||
post(role_id integer, password varchar(64) optional)
|
||||
description(add a role for the user to the current conference. Depending on the registraiton type, an optional password (singlepassword, schoolpassword, etc) can be specified)
|
||||
return(role array)
|
||||
*/
|
||||
|
||||
/* APIDOC: zNOTIMPLEMENTED_role/remove
|
||||
/* APIDOC: role/remove
|
||||
notimplemented
|
||||
post(role_id integer)
|
||||
description(remove a role from the user for the current conference)
|
||||
return(role array)
|
||||
|
@ -3,11 +3,15 @@ body {
|
||||
color: #666666;
|
||||
}
|
||||
h1 {
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
h2 {
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
color: black;
|
||||
}
|
||||
h2 {
|
||||
h3 {
|
||||
font-size: 1.0em;
|
||||
font-weight: bold;
|
||||
margin-bottom: 0px;
|
||||
|
63
apidoc.php
63
apidoc.php
@ -6,6 +6,8 @@
|
||||
</head>
|
||||
<body>
|
||||
<?
|
||||
$commands=array();
|
||||
$nicommands=array();
|
||||
//lets get sneaky here, and have the file parse itself!
|
||||
$lines=file("api.php");
|
||||
foreach($lines AS $line) {
|
||||
@ -18,6 +20,8 @@
|
||||
$cmd['description']=array();
|
||||
$cmd['post']=array();
|
||||
$cmd['return']=array();
|
||||
//assume its implemented unless we say otherwise
|
||||
$cmd['implemented']=true;
|
||||
$incmd=true;
|
||||
}
|
||||
if($incmd==true && preg_match("/description\((.*)\)/",$line,$matches)) {
|
||||
@ -31,20 +35,40 @@
|
||||
$returns=explode(",",$matches[1]);
|
||||
$cmd['return']=$returns;
|
||||
}
|
||||
if($incmd==true && $line=="notimplemented") {
|
||||
$cmd['implemented']=false;
|
||||
}
|
||||
if($incmd==true && $line=="*/") {
|
||||
$incmd=false;
|
||||
$commands[$cmd['command']]=$cmd;
|
||||
if($cmd['implemented'])
|
||||
$commands[$cmd['command']]=$cmd;
|
||||
else
|
||||
$nicommands[$cmd['command']]=$cmd;
|
||||
unset($cmd);
|
||||
}
|
||||
}
|
||||
|
||||
echo "<h1>Status</h1>\n";
|
||||
$numi=count($commands);
|
||||
$numni=count($nicommands);
|
||||
$total=$numi+$numni;
|
||||
$percent=round($numi/$total*100);
|
||||
echo "$numi of $total implemented ($percent%) <br />\n";
|
||||
|
||||
echo "<h1>Basics</h1>\n";
|
||||
echo "All API commands return \"status\", which is either \"ok\" or \"error\" <br />\n";
|
||||
echo "If status is \"error\", then the return also contains \"error\" which contains the error message <br />\n";
|
||||
|
||||
echo "<h1>Implemented API</h1>\n";
|
||||
|
||||
ksort($commands);
|
||||
foreach($commands AS $c=>$com) {
|
||||
echo "<h1>".htmlspecialchars($c)."</h1>";
|
||||
echo "<h2>".htmlspecialchars($c)."</h2>";
|
||||
echo "<div class=\"apidoc\">\n";
|
||||
echo $com['description'];
|
||||
echo "<br />";
|
||||
if(count($com['post'])) {
|
||||
echo "<h2>Post</h2>\n";
|
||||
echo "<h3>Post</h3>\n";
|
||||
echo "<ul>";
|
||||
foreach($com['post'] AS $p) {
|
||||
echo "<li>$p</li>\n";
|
||||
@ -52,7 +76,7 @@ foreach($commands AS $c=>$com) {
|
||||
echo "</ul>";
|
||||
}
|
||||
if(count($com['return'])) {
|
||||
echo "<h2>Return</h2>\n";
|
||||
echo "<h3>Return</h3>\n";
|
||||
echo "<ul>";
|
||||
foreach($com['return'] AS $p) {
|
||||
echo "<li>$p</li>\n";
|
||||
@ -62,6 +86,37 @@ foreach($commands AS $c=>$com) {
|
||||
echo "<br />";
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "<h1>Not Implemented API</h1>\n";
|
||||
|
||||
ksort($nicommands);
|
||||
foreach($nicommands AS $c=>$com) {
|
||||
echo "<h2>".htmlspecialchars($c)."</h2>";
|
||||
echo "<div class=\"apidoc\">\n";
|
||||
echo $com['description'];
|
||||
echo "<br />";
|
||||
if(count($com['post'])) {
|
||||
echo "<h3>Post</h3>\n";
|
||||
echo "<ul>";
|
||||
foreach($com['post'] AS $p) {
|
||||
echo "<li>$p</li>\n";
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
if(count($com['return'])) {
|
||||
echo "<h3>Return</h3>\n";
|
||||
echo "<ul>";
|
||||
foreach($com['return'] AS $p) {
|
||||
echo "<li>$p</li>\n";
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
echo "<br />";
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user