Exemplo n.º 1
0
 /**
  * Delete a directory and all files within it (http://php.net/manual/en/function.rmdir.php#92050)
  * @param  string $dir The filepath of the directory to delete
  * @return boolean  Whether the file has deleted
  */
 public static function deleteDirectory($dir)
 {
     if (!file_exists($dir)) {
         return true;
     }
     if (!is_dir($dir)) {
         return unlink($dir);
     }
     foreach (scandir($dir) as $item) {
         if ($item == '.' || $item == '..') {
             continue;
         }
         if (!Secretary::deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
             return false;
         }
     }
     return rmdir($dir);
 }
Exemplo n.º 2
0
}
if (is_dir('upload')) {
    // Overwrite the contents of an already existing upload folder
    if (!DEBUG) {
        // We don't care about overwriting in debug mode, otherwise trigger a warning
        CL::println("An upload folder already exists.", 0, Colour::Red);
        CL::println("This process will overwrite ALL data in the upload folder.", 0, Colour::Red);
        CL::println("Type 'yes' to contoinue. Any other input will terminate the program.");
        $handle = fopen("php://stdin", "r");
        $line = fgets($handle);
        if (trim($line) != 'yes') {
            CL::println("Oki-doki. Terminating program.");
            exit;
        }
    }
    Secretary::deleteDirectory('upload');
}
mkdir('upload');
CL::printDebug("Created Upload Folder.", 0, Colour::Green);
/*
 *  This is where all the magic happens.
 *
 */
chdir("source");
$markdowns = Secretary::rglob("*.md");
CL::printDebug("Found " . count($markdowns) . " Markdown Files");
CL::printDebug("----------------------------------------------");
$files = FilesProcessor::process("", $defaults, array("Template" => $defaults["Template"]));
chdir("../upload");
/*
 *  We've converted all the files, now lets start the exporting