示例#1
0
文件: index.php 项目: njenkins/twfy
function api_documentation_front($method, $explorer) {
	global $PAGE, $this_page, $DATA, $methods;
	$this_page = 'api_doc_front';
	$DATA->set_page_metadata($this_page, 'title', "$method function");
	$PAGE->page_start();
	$PAGE->stripe_start();
	include_once 'api_' . $method . '.php';
	print '<p align="center"><strong>http://www.openaustralia.org/api/' . $method . '</strong></p>';
	api_call_user_func_or_error('api_' . $method . '_front', array(), 'No documentation yet', 'html');
?>
<h4>Explorer</h4>
<p>Try out this function without writing any code!</p>
<form method="get" action="?#output">
<p>
<? foreach ($methods[$method]['parameters'] as $parameter) {
	print $parameter . ': <input type="text" name="'.$parameter.'" value="';
	if ($val = get_http_var($parameter))
		print htmlspecialchars($val);
	print '" size="30"><br>';
}
?>
Output:
<input id="output_js" type="radio" name="output" value="js"<? if (get_http_var('output')=='js' || !get_http_var('output')) print ' checked'?>>
<label for="output_js">JS</label>
<input id="output_xml" type="radio" name="output" value="xml"<? if (get_http_var('output')=='xml') print ' checked'?>>
<label for="output_xml">XML</label>
<input id="output_php" type="radio" name="output" value="php"<? if (get_http_var('output')=='php') print ' checked'?>>
<label for="output_php">Serialised PHP</label>
<input id="output_rabx" type="radio" name="output" value="rabx"<? if (get_http_var('output')=='rabx') print ' checked'?>>
<label for="output_rabx">RABX</label>

<input type="submit" value="Go">
</p>
</form>
<?
	if ($explorer) {
		$qs = array();
		foreach ($methods[$method]['parameters'] as $parameter) {
			if (get_http_var($parameter))
				$qs[] = htmlspecialchars(rawurlencode($parameter) . '=' . urlencode(get_http_var($parameter)));
		}
		print '<h4><a name="output"></a>Output</h4>';
		print '<p>URL for this: <strong>http://www.openaustralia.org/api/';
		print $method . '?' . join('&amp;', $qs) . '&amp;output='.get_http_var('output').'</strong></p>';
		print '<pre>' . htmlspecialchars($explorer) . '</pre>';
	}
	$sidebar = api_sidebar();
	$PAGE->stripe_end(array($sidebar));
	$PAGE->page_end();
}
示例#2
0
function api_documentation_front($method, $explorer)
{
    global $methods;
    page_header('API');
    $api_url = OPTION_BASE_URL . '/api/' . $method;
    ?>
<div class="main">
<h2>Journa<i>listed</i> API - <code><?php 
    echo $method;
    ?>
</code></h2>

<code><?php 
    echo $api_url;
    ?>
</code>
<?php 
    //   include_once 'api_' . $method . '.php';
    api_call_user_func_or_error('api_' . $method . '_front', array(), 'No documentation yet', 'html');
    ?>
<h4>Explorer</h4>
<p>Try out this function without writing any code!</p>
<form method="get" action="?#output">
<p>
<?php 
    foreach ($methods[$method]['parameters'] as $parameter) {
        print $parameter . ': <input type="text" name="' . $parameter . '" value="';
        if ($val = get_http_var($parameter)) {
            print htmlspecialchars($val);
        }
        print '" size="30"><br>';
    }
    ?>
Output:
<input id="output_js" type="radio" name="output" value="js"<?php 
    if (get_http_var('output') == 'js' || !get_http_var('output')) {
        print ' checked';
    }
    ?>
>
<label for="output_js">JS</label>
<input id="output_xml" type="radio" name="output" value="xml"<?php 
    if (get_http_var('output') == 'xml') {
        print ' checked';
    }
    ?>
>
<label for="output_xml">XML</label>
<input id="output_php" type="radio" name="output" value="php"<?php 
    if (get_http_var('output') == 'php') {
        print ' checked';
    }
    ?>
>
<label for="output_php">Serialised PHP</label>
<input id="output_rabx" type="radio" name="output" value="rabx"<?php 
    if (get_http_var('output') == 'rabx') {
        print ' checked';
    }
    ?>
>
<label for="output_rabx">RABX</label>

<input type="submit" value="Go">
</p>
</form>
<?php 
    if ($explorer) {
        $qs = array();
        foreach ($methods[$method]['parameters'] as $parameter) {
            if (get_http_var($parameter)) {
                $qs[] = htmlspecialchars(rawurlencode($parameter) . '=' . urlencode(get_http_var($parameter)));
            }
        }
        print '<h4><a name="output"></a>Output</h4>';
        print '<p>URL for this: <strong>' . OPTION_BASE_URL . '/api/';
        print $method . '?' . join('&amp;', $qs) . '&amp;output=' . get_http_var('output') . '</strong></p>';
        print '<pre><code>' . htmlspecialchars($explorer) . '</code></pre>';
    }
    ?>
</div>  <!-- end main -->
<div class="sidebar">
<?php 
    api_sidebar();
    ?>
</div> <!-- end sidebar -->
<?php 
    page_footer();
}