Api Explorer - add syntax highlighting
[civicrm-core.git] / templates / CRM / Admin / Page / APIExplorer.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 *}
26 <style>
27 {literal}
28 #api-result {
29 padding:1em;
30 max-height: 50em;
31 }
32 #api-params-table th:first-child,
33 #api-params-table td:first-child {
34 width: 35%;
35 }
36 #api-params-table td:first-child + td,
37 #api-params-table th:first-child + th {
38 width: 10em;
39 }
40 #api-params {
41 min-height: 1em;
42 }
43 #api-params .red-icon {
44 margin-top: .5em;
45 }
46 #api-generated td:first-child {
47 width: 10em;
48 }
49 #api-explorer label {
50 display:inline;
51 font-weight: bold;
52 }
53 #api-explorer pre {
54 line-height: 1.3em;
55 font-size: 11px;
56 margin: 0;
57 }
58 #api-generated-wraper,
59 #api-result {
60 overflow: auto;
61 }
62 .select2-choice .icon {
63 margin-top: .2em;
64 background-image: url("{/literal}{$config->resourceBase}{literal}/i/icons/jquery-ui-2786C2.png");
65 }
66 {/literal}
67 </style>
68 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css" />
69 <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js"></script>
70
71 <form id="api-explorer">
72 <label for="api-entity">{ts}Entity{/ts}:</label>
73 <select class="crm-form-select crm-select2" id="api-entity" name="entity">
74 <option value="" selected="selected">{ts}Choose{/ts}...</option>
75 {crmAPI entity="Entity" action="get" var="entities" version=3}
76 {foreach from=$entities.values item=entity}
77 <option value="{$entity}">{$entity}</option>
78 {/foreach}
79 </select>
80 &nbsp;&nbsp;
81 <label for="api-action">{ts}Action{/ts}:</label>
82 <select class="crm-form-select crm-select2" id="api-action" name="action">
83 {foreach from=$actions item='act'}
84 <option value="{$act}">{$act}</option>
85 {/foreach}
86 </select>
87 &nbsp;&nbsp;
88
89 <label for="debug-checkbox" title="{ts}Display debug output with results.{/ts}">
90 <input type="checkbox" class="crm-form-checkbox api-param-checkbox" id="debug-checkbox" name="debug" checked="checked" value="1" >debug
91 </label>
92 &nbsp;|&nbsp;
93
94 <label for="sequential-checkbox" title="{ts}Sequential is more compact format, well-suited for json and smarty.{/ts}">
95 <input type="checkbox" class="crm-form-checkbox api-param-checkbox" id="sequential-checkbox" name="sequential" checked="checked" value="1">sequential
96 </label>
97
98 <table id="api-params-table">
99 <thead style="display: none;">
100 <tr>
101 <th>{ts}Name{/ts} {help id='param-name'}</th>
102 <th>{ts}Operator{/ts} {help id='param-op'}</th>
103 <th>{ts}Value{/ts} {help id='param-value'}</th>
104 </tr>
105 </thead>
106 <tbody id="api-params"></tbody>
107 </table>
108 <div id="api-param-buttons" style="display: none;">
109 <a href="#" class="crm-hover-button" id="api-params-add"><span class="icon ui-icon-plus"></span>{ts}Add Parameter{/ts}</a>
110 <a href="#" class="crm-hover-button" id="api-chain-add"><span class="icon ui-icon-link"></span>{ts}Chain API Call{/ts}</a>
111 </div>
112 <div id="api-generated-wraper">
113 <table id="api-generated" border=1>
114 <caption>{ts}Code{/ts}</caption>
115 <tr><td>Rest</td><td><pre class="prettyprint linenums" id="api-rest"></pre></td></tr>
116 <tr><td>Smarty</td><td><pre class="prettyprint linenums" id="api-smarty" title='smarty syntax (for get actions)'></pre></td></tr>
117 <tr><td>Php</td><td><pre class="prettyprint linenums" id="api-php" title='php syntax'></pre></td></tr>
118 <tr><td>Javascript</td><td><pre class="prettyprint linenums" id="api-json" title='javascript syntax'></pre></td></tr>
119 </table>
120 </div>
121 <input type="submit" value="{ts}Execute{/ts}" class="form-submit"/>
122 <pre class="prettyprint" id="api-result">
123 {ts}The result of api calls are displayed in this area.{/ts}
124 </pre>
125 </form>
126 {strip}
127 <script type="text/template" id="api-param-tpl">
128 <tr class="api-param-row">
129 <td><input style="width: 100%;" class="crm-form-text api-param-name" value="<%= name %>" placeholder="{ts}Parameter{/ts}" /></td>
130 <td>
131 <select class="crm-form-select api-param-op">
132 {foreach from=$operators item='op'}
133 <option value="{$op|htmlspecialchars}">{$op|htmlspecialchars}</option>
134 {/foreach}
135 </select>
136 </td>
137 <td>
138 <input style="width: 85%;" class="crm-form-text api-param-value" placeholder="{ts}Value{/ts}"/>
139 <a class="crm-hover-button api-param-remove" href="#"><span class="icon ui-icon-close"></span></a>
140 </td>
141 </tr>
142 </script>
143
144 <script type="text/template" id="api-chain-tpl">
145 <tr class="api-chain-row">
146 <td>
147 <select style="width: 100%;" class="crm-form-select api-chain-entity" placeholder="{ts}Entity{/ts}">
148 <option value=""></option>
149 {foreach from=$entities.values item=entity}
150 <option value="{$entity}">{$entity}</option>
151 {/foreach}
152 </select>
153 </td>
154 <td>
155 <select class="crm-form-select api-chain-action">
156 {foreach from=$actions item='act'}
157 <option value="{$act}">{$act}</option>
158 {/foreach}
159 </select>
160 </td>
161 <td>
162 <input style="width: 85%;" class="crm-form-text api-param-value" value="{ldelim}{rdelim}" placeholder="{ts}Api Params{/ts}"/>
163 <a class="crm-hover-button api-param-remove" href="#"><span class="icon ui-icon-close"></span></a>
164 </td>
165 </tr>
166 </script>
167 {/strip}