public function bxd($args = '') { if (gettype($args) == 'array') { $cont = isset($args['cont']) ? $args['cont'] : self::$page; $entr = isset($args['entr']) ? $args['entr'] : self::$page . '.' . self::$ext; self::$recr = isset($args['recr']) && $args['recr'] ? true : false; if (isset($args['fltr'])) { if (gettype($args['fltr']) == "array") { self::$fltr = array_map('strtolower', $args['fltr']); } elseif (gettype($args['fltr']) == "string") { self::$fltr[] = strtolower($args['fltr']); } } else { self::$fltr = array(); } $rndr = isset($args['rndr']) ? $args['rndr'] : ''; } else { $cont = $args != '' ? $args : self::$page; $entr = $cont . '.' . self::$ext; // this is the same as the container name if not provided self::$recr = false; $fltr = ''; $rndr = ''; } if ($entr == '*') { $file = self::bxdFiles(self::$baseDir . $cont . DIRECTORY_SEPARATOR, self::$fltr, $recr); } else { $file = self::$baseDir . $cont . DIRECTORY_SEPARATOR . $entr; echo "assembled File: " . $file . "<br>"; //$content = self::bxdContent($file); } print_r($cont . ' / ' . $entr . ' / ' . $recr . ' / ' . $fltr . ' / ' . $rndr); echo '<br>'; //echo self::$baseDir; echo '<br>'; // echo $file; // echo '<br>'; if (gettype($file) == 'array') { foreach ($file as $entry) { echo $entry . " -> " . self::bxdFileType($entry) . "<br>"; } } else { echo $file . " -> " . self::bxdFileType($file) . "<br>"; $content = self::bxdContent($file); $parts = preg_split('/[\\n]*[-]{3}[\\n]/', $content, 3); print_r($parts); } }
<?php require_once './bxd/bxd.php'; $box = new bxd(); $box->bxd(array('cont' => 'aaa', 'entr' => '404.md')); echo '<hr>'; $box->bxd(array('cont' => 'aaa', 'entr' => 'aaa.txt', 'recr' => true, 'fltr' => 'md', 'rndr' => 'render')); echo '<hr>'; $box->bxd(array('cont' => 'aaa', 'entr' => '*')); echo '<hr>'; echo "'cont'=>'aaa','entr'=>'*', 'recr'=>true <br>"; $box->bxd(array('cont' => 'aaa', 'entr' => '*', 'recr' => true)); echo '<hr>'; echo "'cont'=>'aaa','entr'=>'*','fltr'=>array('md', 'jpg'), 'recr'=>true <br>"; $box->bxd(array('cont' => 'aaa', 'entr' => '*', 'fltr' => array('md', 'jpg'), 'recr' => true)); echo '<hr>'; $box->bxd('aaa'); echo '<hr>'; $box->bxd(); // // //function expandDirectories($base_dir) { // $files = array(); // foreach(scandir($base_dir) as $file) { // if($file == '.' || $file == '..') continue; // $dir = $base_dir.DIRECTORY_SEPARATOR.$file; // if(is_dir($dir)) { //// $files []= $dir; // $files = array_merge($files, expandDirectories($dir)); // } else { // $files []= $dir;