forked from bradfrost/patternlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
styleguide.php
71 lines (58 loc) · 2.2 KB
/
styleguide.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
64
65
66
67
68
69
70
71
<?php include_once('functions.php'); ?>
<!DOCTYPE html>
<html>
<head>
<title>Style Guide</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="styleguide/css/styleguide.css" media="all" />
<link rel="stylesheet" href="css/style.css" media="all" />
</head>
<body>
<!--Style Guide Main Content-->
<div class="sg-main" role="main">
<!--Patterns-->
<div id="patterns">
<?php
/* Loop through patterns directory and sub-directories */
function displayPatterns($dir,$exclude){
global $patternsPath;
global $absolutePath;
$ffs = scandir($dir);
//Loop through directories
foreach($ffs as $ff){
if(is_array($exclude) and !in_array($ff,$exclude)){
if($ff != '.' && $ff != '..'){
$fName = basename($ff,'.php');
$noNum = substr(strstr($fName,"-"), 1);
$fPlain = str_replace("-", " ", $noNum);
$fCaps = ucwords($fPlain);
$pathToFile = str_replace($patternsPath, "", $dir);
if(is_dir($dir.'/'.$ff)){ /*If main section */
echo '<div class="sg-section" id="'.$fName.'">';
} else { /* If SubItem */
//if(strlen(strstr($ff, '.', true)) < 1) continue; //Continue if hidden file
echo '<h2 class="sg-head sg-sub" id="'.$fName.'"><a href="'.$absolutePath.'?url='.$pathToFile.'/'.$ff.'" class="sg-pop">'.$fCaps.'</a></h2>';
echo '<div class="sg-pattern">';
include $dir.'/'.$ff;
echo '</div>';
}
if(is_dir($dir.'/'.$ff)) {
if($ff!='03-Templates' || $ff!='04-Pages') { //Exclude displaying the templates
displayPatterns($dir.'/'.$ff,$exclude);
}
}
if(is_dir($dir.'/'.$ff)){ /*If main section */
echo '</div>';
echo '<!-====================================================================================================-->';
}
}
}
}
}
displayPatterns($patternsPath,array('index.php'));
?>
</div> <!--end #patterns-->
</div><!--End Style Guide Main Content-->
</body>
</html>