-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
executable file
·58 lines (55 loc) · 2.08 KB
/
functions.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
<?php
// Display title of each markup samples as a list item
function listMarkupAsListItems ($type) {
$files = array();
$handle=opendir('markup/'.$type);
while (false !== ($file = readdir($handle))):
if(stristr($file,'.html')):
$files[] = $file;
endif;
endwhile;
sort($files);
foreach ($files as $file):
$filename = preg_replace("/\.html$/i", "", $file);
$title = preg_replace("/\-/i", " ", $filename);
$title = ucwords($title);
echo '<li><a href="#sg-'.$filename.'">'.$title.'</a></li>';
endforeach;
}
// Display markup view and source
function showMarkup($type) {
$files = array();
$handle=opendir('markup/'.$type);
while (false !== ($file = readdir($handle))):
if(stristr($file,'.html')):
$files[] = $file;
endif;
endwhile;
sort($files);
foreach ($files as $file):
$filename = preg_replace("/\.html$/i", "", $file);
$title = preg_replace("/\-/i", " ", $filename);
$documentation = 'doc/'.$type.'/'.$file;
echo '<span class="anchor" id="sg-'.$filename.'"></span>';
echo '<div class="sg-markup sg-section">';
echo '<div class="sg-display">';
echo '<h2 class="sg-h2">'.$title.'</h2>';
if (file_exists($documentation)) {
echo '<div class="sg-doc">';
echo '<h3 class="sg-h2">Information</h3>';
include($documentation);
echo '</div>';
}
include('markup/'.$type.'/'.$file);
echo '</div>';
echo '<div class="sg-markup-controls"><button type="button" class="sg-btn sg-btn--source">View Source</button> <a class="sg-btn--top" href="#top">Back to Top</a></div>';
echo '<div class="sg-source sg-animated">';
echo '<button type="button" class="sg-btn sg-btn--select">Copy Source</button>';
echo '<pre class="line-numbers"><code class="language-markup">';
echo htmlspecialchars(file_get_contents('markup/'.$type.'/'.$file));
echo '</code></pre>';
echo '</div>';
echo '</div>';
endforeach;
}
?>