예제 #1
0
function renderGroup($groupName, $xml)
{
    ?>
        <a name="<?php 
    echo str_replace(' ', '', $groupName);
    ?>
" class="anchor"></a>
        <div class="container">
            <h2 class="group"><?php 
    echo $groupName;
    ?>
</h2>
<?php 
    foreach ($xml->group as $group) {
        if ($group['name'] == $groupName) {
            ?>
            <p class="description"><?php 
            echo $group->description;
            ?>
</p>
<?php 
        }
    }
    ?>
        </div>
<?php 
    foreach ($xml->endpoint as $endpoint) {
        if ($endpoint['group'] == $groupName) {
            renderEndpoint($endpoint, $xml);
        }
    }
}
예제 #2
0
/**
 * Displays a human-readable HTML error message to the user
 *
 * @param string $msg Error message to display to the user
 *
 * @return void
 */
function printHTMLErrorMsg($msg)
{
    ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <?php 
    $meta = "<!-- DATE: %s URL: http://%s%s -->\n";
    printf($meta, strftime('%Y-%m-%d %H:%m:%S'), $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']);
    ?>
    <title>Helioviewer.org API - Error</title>
    <link rel="stylesheet" type="text/css" href="<?php 
    echo HV_WEB_ROOT_URL;
    ?>
/docs/css/bootstrap-theme.min.css">
    <link rel="stylesheet" type="text/css" href="<?php 
    echo HV_WEB_ROOT_URL;
    ?>
/docs/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="<?php 
    echo HV_WEB_ROOT_URL;
    ?>
/docs/css/main.css">
</head>
<body>
    <div style='width: 50%; margin-left: auto; margin-right: auto; margin-top: 1em; text-align: center;'>
        <img src='<?php 
    echo HV_WEB_ROOT_URL . '/' . HV_API_LOGO;
    ?>
' alt='Helioviewer logo'>
        <div style="margin-top: 0.5em; padding: 0.5em; border: 1px solid red; background-color: pink; border-radius: 3px; font-size: 1.4em;">
            <b>Error:</b> <?php 
    echo $msg;
    ?>
        </div>
    </div>
<?php 
    include_once HV_ROOT_DIR . '/docs/index.php';
    $api_version = 'v2';
    import_xml($api_version, $api_xml_path, $xml);
    foreach ($xml->endpoint as $endpoint) {
        if ($endpoint['name'] == $_GET['action']) {
            renderEndpoint($endpoint, $xml);
            break;
        }
    }
    footer($api_version, $api_xml_path);
    ?>
</body>
</html>
<?php 
}