-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.php
63 lines (50 loc) · 1.63 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* RAML2HTML for PHP -- A Simple API Docs Script for RAML & PHP
* @version 1.3beta
* @author Mike Stowe <me@mikestowe.com>
* @link https://github.com/mikestowe/php-raml2html
* @link http://www.mikestowe.com/2014/05/raml-2-html.php
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL v2
*/
require_once('inc/spyc.php');
require_once('inc/ramlDataObject.php');
require_once('inc/raml.php');
require_once('inc/ramlPathObject.php');
require_once('inc/markdown.php');
require_once('inc/codeSamples.php');
require_once('config.php');
// Dangling Function
function formatResponse($text) {
return str_replace(array(" ", "\n"), array(" ", "<br />"), htmlspecialchars($text, ENT_QUOTES));
}
// Handle Caching and Build
$RAML = false;
if ($cacheTimeLimit && function_exists('apc_fetch')) {
$RAML = apc_fetch('RAML' . md5($RAMLsource));
} elseif (!$cacheTimeLimit && function_exists('apc_fetch')) {
// Remove existing cache files
apc_delete('RAML' . md5($RAMLsource));
}
if (!$RAML) {
$RAMLarray = spyc_load(file_get_contents($RAMLsource));
$RAML = new RAML2HTML\RAML($RAMLactionVerbs);
$RAML->setIncludePath(dirname($RAMLsource) . '/');
$RAML->buildFromArray($RAMLarray);
if ($cacheTimeLimit && function_exists('apc_store')) {
apc_store('RAML' . md5($RAMLsource), $RAML, $cacheTimeLimit);
}
}
// Set Current Path
if (isset($_GET['path'])) {
$RAML->setCurrentPath($_GET['path']);
unset($_GET['path']);
}
// Set Current Action
if (isset($_GET['action']) && $RAML->isActionValid($_GET['action'])) {
$RAML->setCurrentAction($_GET['action']);
unset($_GET['action']);
}
// Render Template
require_once($docsTheme);
?>