Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <html> |
2 | <title>API Documentation</title> | |
3 | <style> | |
4 | {literal} | |
5 | #result {background:lightgrey;} | |
6 | #selector a {margin-right:10px;} | |
7 | .required {font-weight:bold;} | |
8 | .helpmsg {background:yellow;} | |
9 | .docHidden {display:none;} | |
10 | h2.entity {cursor:pointer} | |
11 | {/literal} | |
12 | </style> | |
6a488035 TO |
13 | <script> |
14 | if (!jQuery) {ldelim} | |
15 | var head= document.getElementsByTagName('head')[0]; | |
16 | var script= document.createElement('script'); | |
17 | script.type= 'text/javascript'; | |
18 | script.src= CRM.config.resourceBase + 'js/packages/jquery/jquery.js'; | |
19 | head.appendChild(script); | |
20 | {rdelim} | |
21 | restURL = '{crmURL p="civicrm/api/json"}'; | |
22 | if (restURL.indexOf('?') == -1 ) | |
23 | restURL = restURL + '?'; | |
24 | else | |
25 | restURL = restURL + '&'; | |
26 | {literal} | |
27 | if (typeof $ == "undefined") { | |
28 | $ = cj; | |
29 | } | |
30 | ||
31 | function APIDoc(entity){ | |
32 | $detail=$('#detail_'+entity); | |
33 | window.location.hash = entity; | |
34 | if ($detail.length == 1) { | |
35 | $detail.toggleClass('docHidden'); | |
36 | return; | |
37 | } // else fetch the field list | |
38 | return function(entity){ | |
39 | CRM.api (entity,'getFields',{version : 3} | |
40 | ,{ success:function (data){ | |
41 | var h="<table id=detail_"+entity+"><tr><th>Attribute</th><th>Name</th><th>type</th></tr>"; | |
42 | var type=""; | |
43 | $.each(data.values, function(key, value) { | |
44 | if (typeof value.type != 'undefined') { | |
45 | var types={1:"integer",2:"string",4:"date",12:"date time",16:"boolean",32:"blob"} | |
46 | type=value.type | |
47 | if (type in types) type=types[value.type]; | |
48 | } | |
49 | if(typeof value.title == 'undefined') { | |
50 | value.title=""; | |
51 | } | |
52 | if (typeof value.label != 'undefined') { | |
53 | value.title = value.label + " <i>"+value.extends+"::"+value.groupTitle+"</i>"; | |
54 | type = value.data_type; | |
55 | } | |
56 | h=h+"<tr><td>"+key+"</td><td>"+value.title+"</td><td>"+type+"</td></td>"; | |
57 | }); | |
58 | h=h+"</table>"; | |
59 | $("#"+entity).after(h); | |
60 | } | |
61 | }); | |
62 | }(entity);//closure so entity is available into success. | |
63 | } | |
64 | ||
65 | ||
66 | cj(function ($) { | |
67 | $('h2.entity').click ( function(){APIDoc($(this).attr('id'))} ); | |
68 | entity=window.location.hash; | |
69 | if (entity.substring(0, 1) === '#') { | |
70 | $entity=$(entity); | |
71 | if ($entity.length == 1) { | |
72 | $entity.click(); | |
73 | } | |
74 | } | |
75 | }); | |
76 | {/literal} | |
77 | </script> | |
78 | <body> | |
79 | You can see the list of parameters for each entity by clicking on its name.<br> | |
80 | You can <a href='{crmURL p="civicrm/api/explorer"}'>explore and try</a> the api directly on your install. | |
81 | ||
82 | {crmAPI entity="Entity" action="get" var="entities" version=3} | |
83 | {foreach from=$entities.values item=entity} | |
84 | <h2 id="{$entity}" class="entity">{$entity}</option> | |
85 | {/foreach} | |
86 | </body> | |
87 | </html> |