Merge pull request #5225 from totten/master-angstz
[civicrm-core.git] / templates / CRM / Admin / Page / APIExplorer.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
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 #mainTabContainer {
29 background: transparent;
30 border: 0 none;
31 }
32 #mainTabContainer pre {
33 line-height: 14px;
34 font-size: 11px;
35 margin: 0;
36 border: 0 none;
37 }
38 #mainTabContainer ul.ui-tabs-nav {
39 font-size: 1.1em;
40 margin-bottom: .6em;
41 }
42 pre#api-result,
43 div#doc-result,
44 pre#example-result {
45 padding:1em;
46 max-height: 50em;
47 border: 1px solid lightgrey;
48 margin-top: 1em;
49 overflow: auto;
50 }
51 #api-params-table th:first-child,
52 #api-params-table td:first-child {
53 width: 35%;
54 }
55 #api-params-table td:first-child + td,
56 #api-params-table th:first-child + th,
57 #api-generated td:first-child {
58 width: 9em;
59 }
60 #api-params {
61 min-height: 1em;
62 }
63 #api-params .red-icon {
64 margin-top: .5em;
65 }
66 #mainTabContainer label {
67 display: inline;
68 font-weight: bold;
69 }
70 #api-generated-wraper,
71 #api-result {
72 overflow: auto;
73 }
74 #api-explorer .api-options-row + .api-options-row label {
75 display: none;
76 }
77 .api-options-row td:first-child {
78 text-align: right;
79 }
80 .select2-choice .icon {
81 margin-top: .2em;
82 background-image: url("{/literal}{$config->resourceBase}{literal}/i/icons/jquery-ui-2786C2.png");
83 }
84 .select2-default .icon {
85 background-image: url("{/literal}{$config->resourceBase}{literal}/i/icons/jquery-ui-52534D.png");
86 opacity: .8;
87 }
88 pre ol.linenums li {
89 list-style-type: decimal;
90 color: #CFCFCF;
91 }
92 pre ol.linenums li:hover {
93 color: #828282;
94 background-color: #f2f2f2;
95 }
96 pre li.L1, pre li.L3, pre li.L5, pre li.L7, pre li.L9,
97 #api-generated td + td,
98 #mainTabContainer pre {
99 background-color: #f9f9f9;
100 }
101 .api-doc-code {
102 margin-top: 1em;
103 border-top: 1px solid #d3d3d3;
104 }
105 .api-doc-code .collapsible-title {
106 font-weight: bold;
107 margin-top: .5em;
108 }
109 .doc-filename {
110 text-align: right;
111 font-style: italic;
112 }
113 {/literal}
114 </style>
115
116 <div id="mainTabContainer">
117 <ul>
118 <li class="ui-corner-all" title="GUI to build and execute API calls">
119 <a href="#explorer-tab">{ts}Explorer{/ts}</a>
120 </li>
121 <li class="ui-corner-all" title="Auto-generated examples from the test suite">
122 <a href="#examples-tab">{ts}Examples{/ts}</a>
123 </li>
124 <li class="ui-corner-all" title="API source-code and code-level documentation">
125 <a href="#docs-tab">{ts}Code Docs{/ts}</a>
126 </li>
127 </ul>
128
129 <div id="explorer-tab">
130
131 <form id="api-explorer">
132 <label for="api-entity">{ts}Entity{/ts}:</label>
133 <select class="crm-form-select big required" id="api-entity" name="entity">
134 <option value="" selected="selected">{ts}Choose{/ts}...</option>
135 {crmAPI entity="Entity" action="get" var="entities" version=3}
136 {foreach from=$entities.values item=entity}
137 <option value="{$entity}" {if !empty($entities.deprecated) && in_array($entity, $entities.deprecated)}class="strikethrough"{/if}>
138 {$entity}
139 </option>
140 {/foreach}
141 </select>
142 &nbsp;&nbsp;
143 <label for="api-action">{ts}Action{/ts}:</label>
144 <input class="crm-form-text" id="api-action" name="action" value="get">
145 &nbsp;&nbsp;
146
147 <label for="debug-checkbox" title="{ts}Display debug output with results.{/ts}">
148 <input type="checkbox" class="crm-form-checkbox api-param-checkbox api-input" id="debug-checkbox" name="debug" value="1" >debug
149 </label>
150 &nbsp;|&nbsp;
151
152 <label for="sequential-checkbox" title="{ts}Sequential is more compact format, well-suited for json and smarty.{/ts}">
153 <input type="checkbox" class="crm-form-checkbox api-param-checkbox api-input" id="sequential-checkbox" name="sequential" checked="checked" value="1">sequential
154 </label>
155
156 <table id="api-params-table">
157 <thead style="display: none;">
158 <tr>
159 <th>{ts}Name{/ts} {help id='param-name'}</th>
160 <th>{ts}Operator{/ts} {help id='param-op'}</th>
161 <th>{ts}Value{/ts} {help id='param-value'}</th>
162 </tr>
163 </thead>
164 <tbody id="api-params"></tbody>
165 </table>
166 <div id="api-param-buttons" style="display: none;">
167 <a href="#" class="crm-hover-button" id="api-params-add"><span class="icon ui-icon-plus"></span>{ts}Add Parameter{/ts}</a>
168 <a href="#" class="crm-hover-button" id="api-option-add"><span class="icon ui-icon-gear"></span>{ts}Add Option{/ts}</a>
169 <a href="#" class="crm-hover-button" id="api-chain-add"><span class="icon ui-icon-link"></span>{ts}Chain API Call{/ts}</a>
170 </div>
171 <div id="api-generated-wraper">
172 <table id="api-generated" border=1>
173 <caption>{ts}Code{/ts}</caption>
174 <tr><td>Rest</td><td><pre id="api-rest"></pre></td></tr>
175 <tr><td>Smarty</td><td><pre class="linenums" id="api-smarty" title='smarty syntax (for get actions)'></pre></td></tr>
176 <tr><td>Php</td><td><pre class="linenums" id="api-php" title='php syntax'></pre></td></tr>
177 <tr><td>Javascript</td><td><pre class="linenums" id="api-json" title='javascript syntax'></pre></td></tr>
178 {if $config->userSystem->is_drupal}
179 <tr><td>Drush</td><td><pre id="api-drush" title='drush syntax'></pre></td></tr>
180 {/if}
181 {if $config->userSystem->is_wordpress}
182 <tr><td>WP-CLI</td><td><pre id="api-wpcli" title='wp-cli syntax'></pre></td></tr>
183 {/if}
184 </table>
185 </div>
186 <div class="crm-submit-buttons">
187 <span class="crm-button crm-icon-button">
188 <span class="crm-button-icon ui-icon-check"> </span> <input type="submit" value="{ts}Execute{/ts}" class="crm-form-submit" accesskey="S" title="{ts}Execute API call and display results{/ts}"/>
189 </span>
190 </div>
191 <pre id="api-result" class="linenums">
192 {ts}Results are displayed here.{/ts}
193 </pre>
194 </form>
195 </div>
196
197 <div id="examples-tab">
198 <form id="api-examples">
199 <label for="example-entity">{ts}Entity{/ts}:</label>
200 <select class="crm-form-select big required" id="example-entity" name="entity">
201 <option value="" selected="selected">{ts}Choose{/ts}...</option>
202 {foreach from=$examples item=entity}
203 <option value="{$entity}" {if !empty($entities.deprecated) && in_array($entity, $entities.deprecated)}class="strikethrough"{/if}>
204 {$entity}
205 </option>
206 {/foreach}
207 </select>
208 &nbsp;&nbsp;
209 <label for="example-action">{ts}Example{/ts}:</label>
210 <select class="crm-form-select big crm-select2" id="example-action" name="action">
211 <option value="" selected="selected">{ts}Choose{/ts}...</option>
212 </select>
213 <pre id="example-result" class="linenums lang-php" title="{ts escape='html'}Results are displayed here.{/ts}">
214 {ts}Results are displayed here.{/ts}
215 </pre>
216 </form>
217 </div>
218
219 <div id="docs-tab">
220 <form id="api-docs">
221 <label for="doc-entity">{ts}Entity{/ts}:</label>
222 <select class="crm-form-select big required" id="doc-entity" name="entity">
223 <option value="" selected="selected">{ts}Choose{/ts}...</option>
224 {foreach from=$entities.values item=entity}
225 <option value="{$entity}" {if !empty($entities.deprecated) && in_array($entity, $entities.deprecated)}class="strikethrough"{/if}>
226 {$entity}
227 </option>
228 {/foreach}
229 </select>
230 &nbsp;&nbsp;
231 <label for="doc-action">{ts}Action{/ts}:</label>
232 <select class="crm-form-select big crm-select2" id="doc-action" name="action">
233 <option value="" selected="selected">{ts}Choose{/ts}...</option>
234 </select>
235 <div id="doc-result" title="{ts escape='html'}Results are displayed here.{/ts}">
236 {ts}Results are displayed here.{/ts}
237 </div>
238 </form>
239 </div>
240 </div>
241
242 {strip}
243 <script type="text/template" id="api-param-tpl">
244 <tr class="api-param-row">
245 <td><input style="width: 100%;" class="crm-form-text api-param-name api-input" value="<%= name %>" placeholder="{ts}Parameter{/ts}" /></td>
246 <td>
247 <select class="crm-form-select api-param-op">
248 {foreach from=$operators item='op'}
249 <option value="{$op|htmlspecialchars}">{$op|htmlspecialchars}</option>
250 {/foreach}
251 </select>
252 </td>
253 <td>
254 <input style="width: 85%;" class="crm-form-text api-param-value api-input" placeholder="{ts}Value{/ts}"/>
255 <a class="crm-hover-button api-param-remove" href="#"><span class="icon ui-icon-close"></span></a>
256 </td>
257 </tr>
258 </script>
259
260 <script type="text/template" id="api-return-tpl">
261 <tr class="api-return-row">
262 <td colspan="3">
263 <label for="api-return-value">{ts}Fields to return{/ts}:</label> &nbsp;
264 <input type="hidden" class="api-param-name" value="return" />
265 <input style="width: 50%;" id="api-return-value" class="crm-form-text api-param-value api-input" placeholder="{ts}Leave blank for default{/ts}"/>
266 </td>
267 </tr>
268 </script>
269
270 <script type="text/template" id="api-options-tpl">
271 <tr class="api-options-row">
272 <td>
273 <label>{ts}Options{/ts}: &nbsp;</label>
274 </td>
275 <td>
276 <input class="crm-form-text api-option-name api-input" style="width: 12em;" placeholder="{ts}Option{/ts}"/>
277 </td>
278 <td>
279 <input style="width: 85%;" class="crm-form-text api-option-value api-input" placeholder="{ts}Value{/ts}"/>
280 <a class="crm-hover-button api-param-remove" href="#"><span class="icon ui-icon-close"></span></a>
281 </td>
282 </tr>
283 </script>
284
285 <script type="text/template" id="api-chain-tpl">
286 <tr class="api-chain-row">
287 <td>
288 <select style="width: 100%;" class="crm-form-select api-chain-entity">
289 <option value=""></option>
290 {foreach from=$entities.values item=entity}
291 <option value="{$entity}" {if !empty($entities.deprecated) && in_array($entity, $entities.deprecated)}class="strikethrough"{/if}>
292 {$entity}
293 </option>
294 {/foreach}
295 </select>
296 </td>
297 <td>
298 <select class="crm-form-select api-chain-action">
299 <option value="get">get</option>
300 </select>
301 </td>
302 <td>
303 <input style="width: 85%;" class="crm-form-text api-param-value api-input" value="{ldelim}{rdelim}" placeholder="{ts}Api Params{/ts}"/>
304 <a class="crm-hover-button api-param-remove" href="#"><span class="icon ui-icon-close"></span></a>
305 </td>
306 </tr>
307 </script>
308
309 <script type="text/template" id="doc-code-tpl">
310 <div class="crm-collapsible collapsed api-doc-code">
311 <div class="collapsible-title">{ts}Source Code{/ts}</div>
312 <div>
313 <div class="doc-filename"><%- file %></div>
314 <pre class="prettyprint lang-php linenums"><%- code %></pre>
315 </div>
316 </div>
317 </script>
318 {/strip}