+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
- * $Id$
- *
- */
-
-/**
- * Page for displaying list of contact Subtypes
- */
-class CRM_Admin_Page_APIDoc extends CRM_Core_Page {
-
- /**
- * @return string
- */
- public function run() {
- CRM_Utils_System::setTitle(ts('API Parameters'));
- return parent::run();
- }
-
- /**
- * @return string
- */
- public function getTemplateFileName() {
- return 'CRM/Core/APIDoc.tpl';
- }
-
- /**
- * Get user context.
- *
- * @param null $mode
- *
- * @return string
- * user context.
- */
- public function userContext($mode = NULL) {
- return 'civicrm/api/doc';
- }
-
-}
<page_callback>CRM_Core_Page_AJAX_Attachment::attachFile</page_callback>
<access_arguments>access CiviCRM;access AJAX API</access_arguments>
</item>
- <item>
- <path>civicrm/ajax/doc</path>
- <page_callback>CRM_Utils_REST::ajaxDoc</page_callback>
- <access_arguments>access CiviCRM</access_arguments>
- </item>
<item>
<path>civicrm/api/explorer</path>
<page_callback>CRM_Admin_Page_APIExplorer</page_callback>
<page_callback>CRM_Admin_Page_APIExplorer::getExampleFile</page_callback>
<access_arguments>access CiviCRM</access_arguments>
</item>
- <item>
- <path>civicrm/api/doc</path>
- <aapage_callback>CRM_Utils_REST::APIDoc</aapage_callback>
- <page_callback>CRM_Admin_Page_APIDoc</page_callback>
- <access_arguments>access CiviCRM</access_arguments>
- </item>
<item>
<path>civicrm/ajax/rest</path>
<page_callback>CRM_Utils_REST::ajax</page_callback>
CRM_Utils_System::civiExit();
}
- /**
- * Return smarty-generated API Documentation.
- *
- * @return string
- */
- public static function APIDoc() {
-
- CRM_Utils_System::setTitle("API Parameters");
- $template = CRM_Core_Smarty::singleton();
- return CRM_Utils_System::theme(
- $template->fetch('CRM/Core/APIDoc.tpl')
- );
- }
-
- public static function ajaxDoc() {
- return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/api/explorer'));
- }
-
/**
* used to load a template "inline", eg. for ajax, without having to build a menu for each template
*/
+++ /dev/null
-<html>
-<title>API Documentation</title>
-<style>
-{literal}
-#result {background:lightgrey;}
-#selector a {margin-right:10px;}
-.required {font-weight:bold;}
-.helpmsg {background:yellow;}
-.docHidden {display:none;}
-h2.entity {cursor:pointer}
-{/literal}
-</style>
-<script>
-if (!jQuery) {ldelim}
-var head= document.getElementsByTagName('head')[0];
-var script= document.createElement('script');
-script.type= 'text/javascript';
-script.src= CRM.config.resourceBase + 'bower_components/jquery/dist/jquery.min.js';
-head.appendChild(script);
-{rdelim}
-restURL = '{crmURL p="civicrm/api/json"}';
-if (restURL.indexOf('?') == -1 )
-restURL = restURL + '?';
-else
-restURL = restURL + '&';
-{literal}
-if (typeof $ == "undefined") {
- $ = cj;
-}
-
-function APIDoc(entity){
- $detail=$('#detail_'+entity);
- window.location.hash = entity;
- if ($detail.length == 1) {
- $detail.toggleClass('docHidden');
- return;
- } // else fetch the field list
- return function(entity){
- CRM.api (entity,'getFields',{version : 3}
- ,{ success:function (data){
- var h="<table id=detail_"+entity+"><tr><th>Attribute</th><th>Name</th><th>type</th></tr>";
- var type="";
- $.each(data.values, function(key, value) {
- if (typeof value.type != 'undefined') {
- var types={1:"integer",2:"string",4:"date",12:"date time",16:"boolean",32:"blob"}
- type=value.type
- if (type in types) type=types[value.type];
- }
- if(typeof value.title == 'undefined') {
- value.title="";
- }
- if (typeof value.label != 'undefined') {
- value.title = value.label + " <i>"+value.extends+"::"+value.groupTitle+"</i>";
- type = value.data_type;
- }
- h=h+"<tr><td>"+key+"</td><td>"+value.title+"</td><td>"+type+"</td></td>";
- });
- h=h+"</table>";
- $("#"+entity).after(h);
- }
- });
- }(entity);//closure so entity is available into success.
-}
-
-
-CRM.$(function($) {
- $('h2.entity').click ( function(){APIDoc($(this).attr('id'))} );
- entity=window.location.hash;
- if (entity.substring(0, 1) === '#') {
- $entity=$(entity);
- if ($entity.length == 1) {
- $entity.click();
- }
- }
- });
-{/literal}
-</script>
-<body>
-You can see the list of parameters for each entity by clicking on its name.<br>
-You can <a href='{crmURL p="civicrm/api/explorer"}'>explore and try</a> the api directly on your install.
-
-{crmAPI entity="Entity" action="get" var="entities" version=3}
-{foreach from=$entities.values item=entity}
-<h2 id="{$entity}" class="entity">{$entity}</option>
-{/foreach}
-</body>
-</html>