public function run($depth, $ext, $path, $pathName, $name)
 {
     // load default vars
     $patternType = PatternData::getPatternType();
     $patternTypeDash = PatternData::getPatternTypeDash();
     $patternTypeClean = PatternData::getPatternTypeClean();
     $dirSep = PatternData::getDirSep();
     // set-up the names
     $patternSubtype = $name;
     // 02-blocks
     $patternSubtypeDash = $this->getPatternName($name, false);
     // blocks
     $patternSubtypeClean = str_replace("-", " ", $patternSubtypeDash);
     // blocks (dashes replaced with spaces)
     $patternSubtypePath = $pathName;
     // 00-atoms/02-blocks
     $patternSubtypePathDash = str_replace($dirSep, "-", $patternSubtypePath);
     // 00-atoms-02-blocks (file path)
     // create a key for the data store
     $patternStoreKey = $patternTypeDash . "-" . $patternSubtypeDash . "-plsubtype";
     // collect the data
     $patternStoreData = array("category" => "patternSubtype", "name" => $patternSubtype, "nameDash" => $patternSubtypeDash, "nameClean" => $patternSubtypeClean, "type" => $patternType, "typeDash" => $patternTypeDash, "breadcrumb" => $patternTypeClean, "depth" => $depth, "ext" => $ext, "path" => $path, "pathName" => $patternSubtypePath, "pathDash" => $patternSubtypePathDash, "isDir" => $this->isDirProp, "isFile" => $this->isFileProp);
     // if the pattern data store already exists make sure it is merged and overwrites this data
     $patternStoreData = PatternData::checkOption($patternStoreKey) ? array_replace_recursive(PatternData::getOption($patternStoreKey), $patternStoreData) : $patternStoreData;
     PatternData::setOption($patternStoreKey, $patternStoreData);
     // starting a new set of pattern types. it might not have any pattern subtypes
     PatternData::setPatternSubtype($patternSubtype);
     PatternData::setPatternSubtypeClean($patternSubtypeClean);
     PatternData::setPatternSubtypeDash($patternSubtypeDash);
     PatternData::setPatternSubtypeSet(true);
 }
 public function run($depth, $ext, $path, $pathName, $name)
 {
     // load default vars
     $patternSubtype = PatternData::getPatternSubtype();
     $patternSubtypeClean = PatternData::getPatternSubtypeClean();
     $patternSubtypeDash = PatternData::getPatternSubtypeDash();
     $patternType = PatternData::getPatternType();
     $patternTypeClean = PatternData::getPatternTypeClean();
     $patternTypeDash = PatternData::getPatternTypeDash();
     $dirSep = PatternData::getDirSep();
     $frontMeta = PatternData::getFrontMeta();
     // should this pattern get rendered?
     $hidden = $name[0] == "_";
     $noviewall = $name[0] == "-";
     // set-up the names
     $patternFull = in_array($name[0], $frontMeta) ? substr($name, 1) : $name;
     // 00-colors.mustache
     $pattern = str_replace("." . $this->extProp, "", $patternFull);
     // 00-colors
     $patternState = "";
     // check for pattern state
     if (strpos($pattern, "@") !== false) {
         $patternBits = explode("@", $pattern, 2);
         $pattern = $patternBits[0];
         $patternState = $patternBits[1];
     }
     // finish setting up vars
     $patternDash = $this->getPatternName($pattern, false);
     // colors
     $patternClean = str_replace("-", " ", $patternDash);
     // colors (dashes replaced with spaces)
     $patternPartial = $patternTypeDash . "-" . $patternDash;
     // atoms-colors
     $patternPath = str_replace("." . $this->extProp, "", $pathName);
     // 00-atoms/01-global/00-colors
     $patternPathDash = str_replace($dirSep, "-", $patternPath);
     // 00-atoms-01-global-00-colors (file path)
     // create a key for the data store
     $patternStoreKey = $patternPartial;
     // collect the data
     $patternStoreData = array("category" => "pattern", "name" => $pattern, "partial" => $patternPartial, "nameDash" => $patternDash, "nameClean" => $patternClean, "type" => $patternType, "typeDash" => $patternTypeDash, "breadcrumb" => $patternTypeClean, "state" => $patternState, "hidden" => $hidden, "noviewall" => $noviewall, "depth" => $depth, "ext" => $ext, "path" => $path, "pathName" => $patternPath, "pathDash" => $patternPathDash, "isDir" => $this->isDirProp, "isFile" => $this->isFileProp, "partialViewDescAdditions" => array(), "partialViewExampleAdditions" => array(), "extraHolder" => array(), "extraOutput" => array());
     // add any subtype info if necessary
     if ($depth == 2) {
         $patternStoreData["subtype"] = $patternSubtype;
         $patternStoreData["subtypeDash"] = $patternSubtypeDash;
         $patternStoreData["breadcrumb"] = $patternTypeClean . " > " . $patternSubtypeClean;
     }
     // if the pattern data store already exists make sure it is merged and overwrites this data
     $patternStoreData = PatternData::checkOption($patternStoreKey) ? array_replace_recursive(PatternData::getOption($patternStoreKey), $patternStoreData) : $patternStoreData;
     PatternData::setOption($patternStoreKey, $patternStoreData);
 }
 public function run($depth, $ext, $path, $pathName, $name)
 {
     // load default vars
     $patternType = PatternData::getPatternType();
     $patternTypeDash = PatternData::getPatternTypeDash();
     $dirSep = PatternData::getDirSep();
     // make sure the pattern isn't hidden
     $hidden = $name[0] == "_";
     // set-up the names, $name == 00-colors.md
     $doc = str_replace("." . $this->extProp, "", $name);
     // 00-colors
     $docDash = $this->getPatternName(str_replace("_", "", $doc), false);
     // colors
     $docPartial = $patternTypeDash . "-" . $docDash;
     // if the pattern isn't hidden do stuff
     if (!$hidden) {
         // default vars
         $patternSourceDir = Config::getOption("patternSourceDir");
         // parse data
         $text = file_get_contents($patternSourceDir . "/" . $pathName);
         list($yaml, $markdown) = Documentation::parse($text);
         // grab the title and unset it from the yaml so it doesn't get duped in the meta
         if (isset($yaml["title"])) {
             $title = $yaml["title"];
             unset($yaml["title"]);
         }
         // figure out if this is a pattern subtype
         $patternSubtypeDoc = false;
         if ($depth == 1) {
             // go through all of the directories to see if this one matches our doc
             foreach (glob($patternSourceDir . "/" . $patternType . "/*", GLOB_ONLYDIR) as $dir) {
                 $dir = str_replace($patternSourceDir . "/" . $patternType . "/", "", $dir);
                 if ($dir == $doc) {
                     $patternSubtypeDoc = true;
                     break;
                 }
             }
         }
         $category = $patternSubtypeDoc ? "patternSubtype" : "pattern";
         $patternStoreKey = $patternSubtypeDoc ? $docPartial . "-plsubtype" : $docPartial;
         $patternStoreData = array("category" => $category, "nameClean" => $title, "desc" => $markdown, "descExists" => true, "meta" => $yaml, "full" => $doc);
         // if the pattern data store already exists make sure this data overwrites it
         $patternStoreData = PatternData::checkOption($patternStoreKey) ? array_replace_recursive(PatternData::getOption($patternStoreKey), $patternStoreData) : $patternStoreData;
         PatternData::setOption($patternStoreKey, $patternStoreData);
     }
 }
 public function run($depth, $ext, $path, $pathName, $name)
 {
     // load default vars
     $patternSubtype = PatternData::getPatternSubtype();
     $patternSubtypeClean = PatternData::getPatternSubtypeClean();
     $patternSubtypeDash = PatternData::getPatternSubtypeDash();
     $patternType = PatternData::getPatternType();
     $patternTypeClean = PatternData::getPatternTypeClean();
     $patternTypeDash = PatternData::getPatternTypeDash();
     $dirSep = PatternData::getDirSep();
     $frontMeta = PatternData::getFrontMeta();
     // should this pattern get rendered?
     $hidden = $name[0] == "_";
     $noviewall = $name[0] == "-";
     // set-up the names
     $patternFull = in_array($name[0], $frontMeta) ? substr($name, 1) : $name;
     // 00-colors~foo.mustache
     $patternState = "";
     // check for pattern state
     if (strpos($patternFull, "@") !== false) {
         $patternBits = explode("@", $patternFull, 2);
         $patternState = str_replace("." . $ext, "", $patternBits[1]);
         $patternFull = preg_replace("/@(.*?)\\./", ".", $patternFull);
     }
     // finish setting up vars
     $patternBits = explode("~", $patternFull);
     $patternBase = $patternBits[0] . "." . Config::getOption("patternExtension");
     // 00-homepage.mustache
     $patternBaseDash = $this->getPatternName($patternBits[0], false);
     // homepage
     $patternBaseOrig = $patternTypeDash . "-" . $patternBaseDash;
     // pages-homepage
     $patternBaseData = $patternBits[0] . "." . $ext;
     // 00-homepage.json
     $stripJSON = str_replace("." . $ext, "", $patternBits[1]);
     $patternBitClean = preg_replace("/@(.*?)/", "", $patternBits[0]);
     $pattern = $patternBitClean . "-" . $stripJSON;
     // 00-homepage-00-emergency
     $patternInt = $patternBitClean . "-" . $this->getPatternName($stripJSON, false);
     // 00-homepage-emergency
     $patternDash = $this->getPatternName($patternInt, false);
     // homepage-emergency
     $patternClean = str_replace("-", " ", $patternDash);
     // homepage emergency
     $patternPartial = $patternTypeDash . "-" . $patternDash;
     // pages-homepage-emergency
     $patternPath = str_replace("." . $ext, "", str_replace("~", "-", $pathName));
     // 00-atoms/01-global/00-colors
     $patternPathDash = str_replace($dirSep, "-", $patternPath);
     // 00-atoms-01-global-00-colors (file path)
     // check the original pattern path. if it doesn't exist make a guess
     $patternPathOrig = PatternData::getPatternOption($patternBaseOrig, "pathName");
     // 04-pages/00-homepage
     $patternPathOrigDash = PatternData::getPatternOption($patternBaseOrig, "pathDash");
     // 04-pages-00-homepage
     if (!$patternPathOrig) {
         $patternPathOrigBits = explode("~", $pathName);
         $patternPathOrig = $patternPathOrigBits[0];
         // 04-pages/00-homepage
         $patternPathOrigDash = str_replace($dirSep, "-", $patternPathOrig);
         // 04-pages-00-homepage
     }
     // create a key for the data store
     $patternStoreKey = $patternPartial;
     // collect the data
     $patternStoreData = array("category" => "pattern", "name" => $pattern, "partial" => $patternPartial, "nameDash" => $patternDash, "nameClean" => $patternClean, "type" => $patternType, "typeDash" => $patternTypeDash, "breadcrumb" => array("patternType" => $patternTypeClean), "state" => $patternState, "hidden" => $hidden, "noviewall" => $noviewall, "depth" => $depth, "ext" => $ext, "path" => $path, "pathName" => $patternPath, "pathDash" => $patternPathDash, "isDir" => $this->isDirProp, "isFile" => $this->isFileProp, "pseudo" => true, "original" => $patternBaseOrig, "pathOrig" => $patternPathOrig, "pathOrigDash" => $patternPathOrigDash);
     // add any subtype info if necessary
     if ($depth > 1) {
         $patternStoreData["subtype"] = $patternSubtype;
         $patternStoreData["subtypeDash"] = $patternSubtypeDash;
         $patternStoreData["breadcrumb"] = array("patternType" => $patternTypeClean, "patternSubtype" => $patternSubtypeClean);
     }
     $patternDataBase = array();
     if (file_exists(Config::getOption("patternSourceDir") . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $patternBaseData)) {
         $data = file_get_contents(Config::getOption("patternSourceDir") . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $patternBaseData);
         if ($ext == "json") {
             $patternDataBase = json_decode($data, true);
             if ($jsonErrorMessage = JSON::hasError()) {
                 JSON::lastErrorMsg($patternBaseJSON, $jsonErrorMessage, $data);
             }
         } else {
             try {
                 $patternDataBase = YAML::parse($data);
             } catch (ParseException $e) {
                 printf("unable to parse " . $pathNameClean . ": %s..\n", $e->getMessage());
             }
             // single line of text won't throw a YAML error. returns as string
             if (gettype($patternDataBase) == "string") {
                 $patternDataBase = array();
             }
         }
     }
     // get the data for the pseudo-pattern
     $data = file_get_contents(Config::getOption("patternSourceDir") . DIRECTORY_SEPARATOR . $pathName);
     if ($ext == "json") {
         $patternData = json_decode($data, true);
         if ($jsonErrorMessage = JSON::hasError()) {
             JSON::lastErrorMsg($name, $jsonErrorMessage, $data);
         }
     } else {
         try {
             $patternData = YAML::parse($data);
         } catch (ParseException $e) {
             printf("unable to parse " . $pathNameClean . ": %s..\n", $e->getMessage());
         }
         // single line of text won't throw a YAML error. returns as string
         if (gettype($patternData) == "string") {
             $patternData = array();
         }
     }
     // make sure the pattern data is an array before merging the data
     $patternStoreData["data"] = is_array($patternData) ? array_replace_recursive($patternDataBase, $patternData) : $patternDataBase;
     // if the pattern data store already exists make sure it is merged and overwrites this data
     $patternStoreData = PatternData::checkOption($patternStoreKey) ? array_replace_recursive(PatternData::getOption($patternStoreKey), $patternStoreData) : $patternStoreData;
     PatternData::setOption($patternStoreKey, $patternStoreData);
 }