function displayPatchwork($dir) { global $patternsPath; global $styleguidePath; $ffs = scandir($dir); foreach ($ffs as $ff) { if ($ff != '.' && $ff != '..') { $fName = basename($ff, '.html'); $fPlain = ucwords(str_replace('-', '. ', $fName)); $pathToFile = str_replace($patternsPath, '', $dir); if (is_dir($dir . '/' . $ff)) { // If main section if ($fName == 'article') { echo "<section class=\"xx-section\" id=\"" . $fName . "\">\n"; echo " <h2 class=\"xx-section-title\">" . $fPlain . "</h2>\n"; } else { echo "<section class=\"xx-section\" id=\"" . $fName . "\">\n"; echo " <h2 class=\"xx-section-title\">" . $fPlain . "</h2>\n"; } } else { // If sub section if (pathinfo($ff, PATHINFO_EXTENSION) == 'html' && $fName != 'header' && $fName != 'head' && $fName != 'foot') { // Skip non-HTML files echo "<div class=\"pattern\" id=\"" . $fName . "\">\n"; echo "\n"; include $dir . '/' . $ff; echo "\n"; echo "</div>\n\n"; } } if (is_dir($dir . '/' . $ff)) { // If main section displayPatchwork($dir . '/' . $ff); echo "</section>\n\n"; } } } }
<?php displayOptions($patternsPath); ?> </select> <input type="hidden" name="uri" value="<?php echo $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; ?> "> <button type="submit" id="pattern-submit">Go</button> </form> </div> <main role="main"> <?php displayPatchwork($patternsPath); ?> </main><!--@main--> </section> <?php } ?> </body> <script src="js/pattern-lib.js"></script> </html>