/**
  * Move static files from source/ to public/
  */
 protected function moveStatic()
 {
     // set-up the dispatcher
     $dispatcherInstance = Dispatcher::getInstance();
     // note the start of the operation
     $dispatcherInstance->dispatch("generator.moveStaticStart");
     // common values
     $publicDir = Config::getOption("publicDir");
     $sourceDir = Config::getOption("sourceDir");
     $ignoreExt = Config::getOption("ie");
     $ignoreDir = Config::getOption("id");
     // iterate over all of the other files in the source directory
     $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourceDir), \RecursiveIteratorIterator::SELF_FIRST);
     // make sure dots are skipped
     $objects->setFlags(\FilesystemIterator::SKIP_DOTS);
     foreach ($objects as $name => $object) {
         // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored
         $fileName = str_replace($sourceDir . DIRECTORY_SEPARATOR, "", $name);
         if ($fileName[0] != "_" && !in_array($object->getExtension(), $ignoreExt) && !in_array($object->getFilename(), $ignoreDir)) {
             // catch directories that have the ignored dir in their path
             $ignored = FileUtil::ignoreDir($fileName);
             // check to see if it's a new directory
             if (!$ignored && $object->isDir() && !is_dir($publicDir . "/" . $fileName)) {
                 mkdir($publicDir . "/" . $fileName);
             }
             // check to see if it's a new file or a file that has changed
             $sourceFileName = $sourceDir . DIRECTORY_SEPARATOR . $fileName;
             if (!$ignored && $object->isFile() && FileChangeList::hasChanged($sourceFileName)) {
                 FileUtil::moveStaticFile($fileName);
                 FileChangeList::update($sourceFileName);
             }
         }
     }
     // note the end of the operation
     $dispatcherInstance->dispatch("generator.moveStaticEnd");
 }
 /**
  * Generates all of the patterns and puts them in the public directory
  * @param   {Array}     various options that might affect the export. primarily the location.
  */
 protected function generatePatterns($options = array())
 {
     // set-up the dispatcher
     $dispatcherInstance = Dispatcher::getInstance();
     // note the beginning of the operation
     $dispatcherInstance->dispatch("builder.generatePatternsStart");
     // set-up common vars
     $exportFiles = isset($options["exportFiles"]) && $options["exportFiles"];
     $exportDir = Config::getOption("exportDir");
     $patternPublicDir = !$exportFiles ? Config::getOption("patternPublicDir") : Config::getOption("patternExportDir");
     $patternSourceDir = Config::getOption("patternSourceDir");
     $patternExtension = Config::getOption("patternExtension");
     // make sure the export dir exists
     if ($exportFiles && !is_dir($exportDir)) {
         mkdir($exportDir);
     }
     // make sure patterns exists
     if (!is_dir($patternPublicDir)) {
         mkdir($patternPublicDir);
     }
     // loop over the pattern data store to render the individual patterns
     $store = PatternData::get();
     foreach ($store as $patternStoreKey => $patternStoreData) {
         $fileName = FileChangeList::getFileNameByPatternData($patternStoreData);
         if (!Config::getOption("update") || FileChangeList::hasChanged($fileName)) {
             if ($patternStoreData["category"] == "pattern" && !$patternStoreData["hidden"]) {
                 $path = $patternStoreData["pathDash"];
                 $pathName = isset($patternStoreData["pseudo"]) ? $patternStoreData["pathOrig"] : $patternStoreData["pathName"];
                 // modify the pattern mark-up
                 $markup = $patternStoreData["code"];
                 $markupEncoded = htmlentities($markup, ENT_COMPAT, "UTF-8");
                 $markupFull = $patternStoreData["header"] . $markup . $patternStoreData["footer"];
                 $markupEngine = htmlentities(file_get_contents($patternSourceDir . "/" . $pathName . "." . $patternExtension), ENT_COMPAT, "UTF-8");
                 // if the pattern directory doesn't exist create it
                 if (!is_dir($patternPublicDir . "/" . $path)) {
                     mkdir($patternPublicDir . "/" . $path);
                 }
                 // write out the various pattern files
                 file_put_contents($patternPublicDir . "/" . $path . "/" . $path . ".html", $markupFull);
                 if (!$exportFiles) {
                     file_put_contents($patternPublicDir . "/" . $path . "/" . $path . ".escaped.html", $markupEncoded);
                     file_put_contents($patternPublicDir . "/" . $path . "/" . $path . "." . $patternExtension, $markupEngine);
                 }
                 /*
                 Not being used and should be moved to a plug-in
                 if (Config::$options["enableCSS"] && isset($this->patternCSS[$p])) {
                   file_put_contents($patternPublicDir.$path."/".$path.".css",htmlentities($this->patternCSS[$p]));
                 }
                 */
             }
             FileChangeList::update($fileName);
         }
     }
     // note the end of the operation
     $dispatcherInstance->dispatch("builder.generatePatternsEnd");
 }