| 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-explorer pre { |
| 29 | line-height: 1.3em; |
| 30 | font-size: 11px; |
| 31 | margin: 0; |
| 32 | border: 0 none; |
| 33 | } |
| 34 | pre#api-result { |
| 35 | padding:1em; |
| 36 | max-height: 50em; |
| 37 | border: 1px solid lightgrey; |
| 38 | } |
| 39 | #api-params-table th:first-child, |
| 40 | #api-params-table td:first-child { |
| 41 | width: 35%; |
| 42 | } |
| 43 | #api-params-table td:first-child + td, |
| 44 | #api-params-table th:first-child + th, |
| 45 | #api-generated td:first-child { |
| 46 | width: 9em; |
| 47 | } |
| 48 | #api-params { |
| 49 | min-height: 1em; |
| 50 | } |
| 51 | #api-params .red-icon { |
| 52 | margin-top: .5em; |
| 53 | } |
| 54 | #api-explorer label { |
| 55 | display: inline; |
| 56 | font-weight: bold; |
| 57 | } |
| 58 | #api-generated-wraper, |
| 59 | #api-result { |
| 60 | overflow: auto; |
| 61 | } |
| 62 | #api-explorer .api-options-row + .api-options-row label { |
| 63 | display: none; |
| 64 | } |
| 65 | .api-options-row td:first-child { |
| 66 | text-align: right; |
| 67 | } |
| 68 | .select2-choice .icon { |
| 69 | margin-top: .2em; |
| 70 | background-image: url("{/literal}{$config->resourceBase}{literal}/i/icons/jquery-ui-2786C2.png"); |
| 71 | } |
| 72 | .select2-default .icon { |
| 73 | background-image: url("{/literal}{$config->resourceBase}{literal}/i/icons/jquery-ui-52534D.png"); |
| 74 | opacity: .8; |
| 75 | } |
| 76 | pre ol.linenums li { |
| 77 | list-style-type: decimal; |
| 78 | color: #CFCFCF; |
| 79 | } |
| 80 | pre ol.linenums li:hover { |
| 81 | color: #9c9c9c; |
| 82 | } |
| 83 | {/literal} |
| 84 | </style> |
| 85 | |
| 86 | <form id="api-explorer"> |
| 87 | <label for="api-entity">{ts}Entity{/ts}:</label> |
| 88 | <select class="crm-form-select crm-select2" id="api-entity" name="entity"> |
| 89 | <option value="" selected="selected">{ts}Choose{/ts}...</option> |
| 90 | {crmAPI entity="Entity" action="get" var="entities" version=3} |
| 91 | {foreach from=$entities.values item=entity} |
| 92 | <option value="{$entity}">{$entity}</option> |
| 93 | {/foreach} |
| 94 | </select> |
| 95 | |
| 96 | <label for="api-action">{ts}Action{/ts}:</label> |
| 97 | <input class="crm-form-text" id="api-action" name="action" value="get"> |
| 98 | |
| 99 | |
| 100 | <label for="debug-checkbox" title="{ts}Display debug output with results.{/ts}"> |
| 101 | <input type="checkbox" class="crm-form-checkbox api-param-checkbox api-input" id="debug-checkbox" name="debug" value="1" >debug |
| 102 | </label> |
| 103 | | |
| 104 | |
| 105 | <label for="sequential-checkbox" title="{ts}Sequential is more compact format, well-suited for json and smarty.{/ts}"> |
| 106 | <input type="checkbox" class="crm-form-checkbox api-param-checkbox api-input" id="sequential-checkbox" name="sequential" checked="checked" value="1">sequential |
| 107 | </label> |
| 108 | |
| 109 | <table id="api-params-table"> |
| 110 | <thead style="display: none;"> |
| 111 | <tr> |
| 112 | <th>{ts}Name{/ts} {help id='param-name'}</th> |
| 113 | <th>{ts}Operator{/ts} {help id='param-op'}</th> |
| 114 | <th>{ts}Value{/ts} {help id='param-value'}</th> |
| 115 | </tr> |
| 116 | </thead> |
| 117 | <tbody id="api-params"></tbody> |
| 118 | </table> |
| 119 | <div id="api-param-buttons" style="display: none;"> |
| 120 | <a href="#" class="crm-hover-button" id="api-params-add"><span class="icon ui-icon-plus"></span>{ts}Add Parameter{/ts}</a> |
| 121 | <a href="#" class="crm-hover-button" id="api-option-add"><span class="icon ui-icon-gear"></span>{ts}Add Option{/ts}</a> |
| 122 | <a href="#" class="crm-hover-button" id="api-chain-add"><span class="icon ui-icon-link"></span>{ts}Chain API Call{/ts}</a> |
| 123 | </div> |
| 124 | <div id="api-generated-wraper"> |
| 125 | <table id="api-generated" border=1> |
| 126 | <caption>{ts}Code{/ts}</caption> |
| 127 | <tr><td>Rest</td><td><pre class="prettyprint" id="api-rest"></pre></td></tr> |
| 128 | <tr><td>Smarty</td><td><pre class="prettyprint linenums" id="api-smarty" title='smarty syntax (for get actions)'></pre></td></tr> |
| 129 | <tr><td>Php</td><td><pre class="prettyprint linenums" id="api-php" title='php syntax'></pre></td></tr> |
| 130 | <tr><td>Javascript</td><td><pre class="prettyprint linenums" id="api-json" title='javascript syntax'></pre></td></tr> |
| 131 | </table> |
| 132 | </div> |
| 133 | <input type="submit" value="{ts}Execute{/ts}" class="form-submit"/> |
| 134 | <pre id="api-result" class="linenums"> |
| 135 | {ts}The result of api calls are displayed in this area.{/ts} |
| 136 | </pre> |
| 137 | </form> |
| 138 | |
| 139 | {strip} |
| 140 | <script type="text/template" id="api-param-tpl"> |
| 141 | <tr class="api-param-row"> |
| 142 | <td><input style="width: 100%;" class="crm-form-text api-param-name api-input" value="<%= name %>" placeholder="{ts}Parameter{/ts}" /></td> |
| 143 | <td> |
| 144 | <select class="crm-form-select api-param-op"> |
| 145 | {foreach from=$operators item='op'} |
| 146 | <option value="{$op|htmlspecialchars}">{$op|htmlspecialchars}</option> |
| 147 | {/foreach} |
| 148 | </select> |
| 149 | </td> |
| 150 | <td> |
| 151 | <input style="width: 85%;" class="crm-form-text api-param-value api-input" placeholder="{ts}Value{/ts}"/> |
| 152 | <a class="crm-hover-button api-param-remove" href="#"><span class="icon ui-icon-close"></span></a> |
| 153 | </td> |
| 154 | </tr> |
| 155 | </script> |
| 156 | |
| 157 | <script type="text/template" id="api-return-tpl"> |
| 158 | <tr class="api-return-row"> |
| 159 | <td colspan="3"> |
| 160 | <label for="api-return-value">{ts}Fields to return{/ts}:</label> |
| 161 | <input type="hidden" class="api-param-name" value="return" /> |
| 162 | <input style="width: 50%;" id="api-return-value" class="crm-form-text api-param-value api-input" placeholder="{ts}Leave blank for default{/ts}"/> |
| 163 | </td> |
| 164 | </tr> |
| 165 | </script> |
| 166 | |
| 167 | <script type="text/template" id="api-options-tpl"> |
| 168 | <tr class="api-options-row"> |
| 169 | <td> |
| 170 | <label>{ts}Options{/ts}: </label> |
| 171 | </td> |
| 172 | <td> |
| 173 | <input class="crm-form-text api-option-name api-input" style="width: 12em;" placeholder="{ts}Option{/ts}"/> |
| 174 | </td> |
| 175 | <td> |
| 176 | <input style="width: 85%;" class="crm-form-text api-option-value api-input" placeholder="{ts}Value{/ts}"/> |
| 177 | <a class="crm-hover-button api-param-remove" href="#"><span class="icon ui-icon-close"></span></a> |
| 178 | </td> |
| 179 | </tr> |
| 180 | </script> |
| 181 | |
| 182 | <script type="text/template" id="api-chain-tpl"> |
| 183 | <tr class="api-chain-row"> |
| 184 | <td> |
| 185 | <select style="width: 100%;" class="crm-form-select api-chain-entity"> |
| 186 | <option value=""></option> |
| 187 | {foreach from=$entities.values item=entity} |
| 188 | <option value="{$entity}">{$entity}</option> |
| 189 | {/foreach} |
| 190 | </select> |
| 191 | </td> |
| 192 | <td> |
| 193 | <select class="crm-form-select api-chain-action"> |
| 194 | <option value="get">get</option> |
| 195 | <option value="getsingle">getsingle</option> |
| 196 | <option value="getcount">getcount</option> |
| 197 | <option value="create">create</option> |
| 198 | <option value="delete">delete</option> |
| 199 | </select> |
| 200 | </td> |
| 201 | <td> |
| 202 | <input style="width: 85%;" class="crm-form-text api-param-value api-input" value="{ldelim}{rdelim}" placeholder="{ts}Api Params{/ts}"/> |
| 203 | <a class="crm-hover-button api-param-remove" href="#"><span class="icon ui-icon-close"></span></a> |
| 204 | </td> |
| 205 | </tr> |
| 206 | </script> |
| 207 | {/strip} |