예제 #1
0
파일: common.php 프로젝트: PciPca/Map
function get_html_docs($obj)
{
    global $config, $data, $dataset, $errors;
    $name = str_replace('/', '_', $obj['name']);
    $filename = "data/{$dataset}/{$name}.mkdn";
    $name = str_replace('_', '\\_', $obj['name']);
    $type = $obj['type'];
    if ($config['types'][$type]) {
        $type = $config['types'][$type]['long'];
    }
    $markdown = "## {$name} *{$type}*\n\n";
    if (file_exists($filename)) {
        $markdown .= "### Documentation\n\n";
        $markdown .= file_get_contents($filename);
    } else {
        $markdown .= "<div class=\"alert alert-warning\">No documentation for this \$\$\\int_x f(x) dx = 0\$\$ object</div>";
    }
    if ($obj) {
        $markdown .= "\n\n";
        $markdown .= get_depends_markdown('Depends on', $obj['depends']);
        $markdown .= get_depends_markdown('Depended on by', $obj['dependedOnBy']);
    }
    // Use {{object_id}} to link to an object
    $arr = explode('{{', $markdown);
    $markdown = $arr[0];
    for ($i = 1; $i < count($arr); $i++) {
        $pieces = explode('}}', $arr[$i], 2);
        $name = $pieces[0];
        $id_string = get_id_string($name);
        $name_esc = str_replace('_', '\\_', $name);
        $class = 'select-object';
        if (!isset($data[$name])) {
            $class .= ' missing';
            $errors[] = "Object '{$obj['name']}' links to unrecognized object '{$name}'";
        }
        $markdown .= "<a href=\"#{$id_string}\" class=\"{$class}\" data-name=\"{$name}\">{$name_esc}</a>";
        $markdown .= $pieces[1];
    }
    $html = Markdown::defaultTransform($markdown);
    // IE can't handle <pre><code> (it eats all the line breaks)
    $html = str_replace('<pre><code>', '<pre>', $html);
    $html = str_replace('</code></pre>', '</pre>', $html);
    return $html;
}
예제 #2
0
<!--[if IE 8]>         <html class="lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=Edge">
        <meta charset="utf-8">
        <title><?php 
echo $config['title'];
?>
</title>
        <link rel="stylesheet" href="bootstrap.css">
        <link rel="stylesheet" href="style.css">
        <link rel="stylesheet" href="print.css">
    </head>
    <body>
        <a class="btn btn-default nav-button" id="nav-graph" href="graph.php<?php 
echo $dataset_qs;
?>
">
            View graph
        </a>
        <div id="docs-list">
<?php 
foreach ($data as $obj) {
    $id = get_id_string($obj['name']);
    echo "<div class=\"docs\" id=\"{$id}\">{$obj['docs']}</div>\n";
}
?>
        </div>
    </body>
</html>