public function run() { // default vars $options = array(); $options["patternPaths"] = $this->patternPaths; $patternExtension = Config::getOption("patternExtension"); $patternSourceDir = Config::getOption("patternSourceDir"); $htmlHead = Template::getHTMLHead(); $htmlFoot = Template::getHTMLFoot(); $patternHead = Template::getPatternHead(); $patternFoot = Template::getPatternFoot(); $stringLoader = Template::getStringLoader(); // re-load the pattern data since we modified it $store = PatternData::get(); // load the pattern loader $patternEngineBasePath = PatternEngine::getInstance()->getBasePath(); $patternLoaderClass = $patternEngineBasePath . "\\Loaders\\PatternLoader"; $patternLoader = new $patternLoaderClass($options); // iterate to process each pattern FileChangeList::touchParentPatterns($store); foreach ($store as $patternStoreKey => $patternStoreData) { if ($patternStoreData["category"] == "pattern" && !$patternStoreData["hidden"]) { $fileName = FileChangeList::getFileNameByPatternData($patternStoreData); if (!Config::getOption("update") || FileChangeList::hasChanged($fileName)) { $data = Data::getPatternSpecificData($patternStoreKey); // add the pattern data so it can be exported $patternData = array(); //$patternFooterData["patternFooterData"]["cssEnabled"] = (Config::$options["enableCSS"] && isset($this->patternCSS[$p])) ? "true" : "false"; $patternData["cssEnabled"] = false; $patternData["lineage"] = isset($patternStoreData["lineages"]) ? $patternStoreData["lineages"] : array(); $patternData["lineageR"] = isset($patternStoreData["lineagesR"]) ? $patternStoreData["lineagesR"] : array(); $patternData["patternBreadcrumb"] = $patternStoreData["breadcrumb"]; $patternData["patternDesc"] = isset($patternStoreData["desc"]) ? $patternStoreData["desc"] : ""; $patternData["patternExtension"] = $patternExtension; $patternData["patternName"] = $patternStoreData["nameClean"]; $patternData["patternPartial"] = $patternStoreData["partial"]; $patternData["patternState"] = $patternStoreData["state"]; // extra copy for the code view $patternData["extraOutput"] = isset($patternStoreData["extraOutput"]) ? $patternStoreData["extraOutput"] : array(); // add the pattern lab specific mark-up // set a default var $exportClean = isset($options["exportClean"]) ? $options["exportClean"] : false; $data["patternLabHead"] = !$this->exportFiles ? $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $data["cacheBuster"]))) : ""; $data["patternLabFoot"] = !$this->exportFiles ? $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $data["cacheBuster"], "patternData" => json_encode($patternData)))) : ""; if (isset($patternStoreData["patternRaw"])) { $header = !$this->exportClean ? $stringLoader->render(array("string" => $patternHead, "data" => $data)) : ""; $code = $patternLoader->render(array("pattern" => $patternStoreData["patternRaw"], "data" => $data)); $footer = !$this->exportClean ? $stringLoader->render(array("string" => $patternFoot, "data" => $data)) : ""; PatternData::setPatternOption($patternStoreKey, "header", $header); PatternData::setPatternOption($patternStoreKey, "code", $code); PatternData::setPatternOption($patternStoreKey, "footer", $footer); } } } } }
/** * Generates the view all pages */ protected function generateViewAllPages() { // set-up the dispatcher $dispatcherInstance = Dispatcher::getInstance(); // note the beginning of the operation $dispatcherInstance->dispatch("builder.generateViewAllPagesStart"); // default vars $patternPublicDir = Config::getOption("patternPublicDir"); $htmlHead = Template::getHTMLHead(); $htmlFoot = Template::getHTMLFoot(); $patternHead = Template::getPatternHead(); $patternFoot = Template::getPatternFoot(); $filesystemLoader = Template::getFilesystemLoader(); $stringLoader = Template::getStringLoader(); // make sure the pattern dir exists if (!is_dir($patternPublicDir)) { mkdir($patternPublicDir); } // add view all to each list $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { if ($patternStoreData["category"] == "patternSubtype") { // grab the partials into a data object for the style guide $ppExporter = new PatternPartialsExporter(); $partials = $ppExporter->run($patternStoreData["type"], $patternStoreData["name"]); if (!empty($partials["partials"])) { // add the pattern data so it can be exported $patternData = array(); $patternData["patternPartial"] = "viewall-" . $patternStoreData["typeDash"] . "-" . $patternStoreData["nameDash"]; // add the pattern lab specific mark-up $partials["patternLabHead"] = $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $partials["cacheBuster"]))); $partials["patternLabFoot"] = $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); // render the parts and join them $header = $stringLoader->render(array("string" => $patternHead, "data" => $partials)); $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); $footer = $stringLoader->render(array("string" => $patternFoot, "data" => $partials)); $viewAllPage = $header . $code . $footer; // if the pattern directory doesn't exist create it $patternPath = $patternStoreData["pathDash"]; if (!is_dir($patternPublicDir . "/" . $patternPath)) { mkdir($patternPublicDir . "/" . $patternPath); file_put_contents($patternPublicDir . "/" . $patternPath . "/index.html", $viewAllPage); } else { file_put_contents($patternPublicDir . "/" . $patternPath . "/index.html", $viewAllPage); } } } else { if ($patternStoreData["category"] == "patternType" && PatternData::hasPatternSubtype($patternStoreData["nameDash"])) { // grab the partials into a data object for the style guide $ppExporter = new PatternPartialsExporter(); $partials = $ppExporter->run($patternStoreData["name"]); if (!empty($partials["partials"])) { // add the pattern data so it can be exported $patternData = array(); $patternData["patternPartial"] = "viewall-" . $patternStoreData["nameDash"] . "-all"; // add the pattern lab specific mark-up $partials["patternLabHead"] = $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $partials["cacheBuster"]))); $partials["patternLabFoot"] = $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); // render the parts and join them $header = $stringLoader->render(array("string" => $patternHead, "data" => $partials)); $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); $footer = $stringLoader->render(array("string" => $patternFoot, "data" => $partials)); $viewAllPage = $header . $code . $footer; // if the pattern directory doesn't exist create it $patternPath = $patternStoreData["pathDash"]; if (!is_dir($patternPublicDir . "/" . $patternPath)) { mkdir($patternPublicDir . "/" . $patternPath); file_put_contents($patternPublicDir . "/" . $patternPath . "/index.html", $viewAllPage); } else { file_put_contents($patternPublicDir . "/" . $patternPath . "/index.html", $viewAllPage); } } } } } // note the end of the operation $dispatcherInstance->dispatch("builder.generateViewAllPagesEnd"); }
public function run() { // default vars $options = array(); $options["patternPaths"] = $this->patternPaths; $patternExtension = Config::getOption("patternExtension"); $patternSourceDir = Config::getOption("patternSourceDir"); $htmlHead = Template::getHTMLHead(); $htmlFoot = Template::getHTMLFoot(); $patternHead = Template::getPatternHead(); $patternFoot = Template::getPatternFoot(); $stringLoader = Template::getStringLoader(); // re-load the pattern data since we modified it $store = PatternData::get(); /* rtl support start */ foreach (array_keys($store) as $patternStoreKey) { if ($store[$patternStoreKey]['isFile']) { $store[$patternStoreKey]['patternTextDirection'] = 'ltr'; $store[$patternStoreKey . '-rtl'] = $store[$patternStoreKey]; $store[$patternStoreKey . '-rtl']['name'] .= '-rtl'; $store[$patternStoreKey . '-rtl']['pathDash'] .= '-rtl'; $store[$patternStoreKey . '-rtl']['patternTextDirection'] = 'rtl'; $store[$patternStoreKey . '-rtl']['nameDash'] .= '-rtl'; $store[$patternStoreKey . '-rtl']['nameClean'] .= ' (RTL)'; $store[$patternStoreKey . '-rtl']['partial'] .= '-rtl'; } } foreach ($store as $patternStoreKey => $patternStoreData) { PatternData::setOption($patternStoreKey, $patternStoreData); } /* rtl support end */ // load the pattern loader $patternEngineBasePath = PatternEngine::getInstance()->getBasePath(); $patternLoaderClass = $patternEngineBasePath . "\\Loaders\\PatternLoader"; $patternLoader = new $patternLoaderClass($options); // iterate to process each pattern foreach ($store as $patternStoreKey => $patternStoreData) { if ($patternStoreData["category"] == "pattern" && !$patternStoreData["hidden"]) { $data = Data::getPatternSpecificData($patternStoreKey); // add the pattern data so it can be exported $patternData = array(); //$patternFooterData["patternFooterData"]["cssEnabled"] = (Config::$options["enableCSS"] && isset($this->patternCSS[$p])) ? "true" : "false"; $patternData["cssEnabled"] = false; $patternData["lineage"] = isset($patternStoreData["lineages"]) ? $patternStoreData["lineages"] : array(); $patternData["lineageR"] = isset($patternStoreData["lineagesR"]) ? $patternStoreData["lineagesR"] : array(); $patternData["patternBreadcrumb"] = $patternStoreData["breadcrumb"]; $patternData["patternDesc"] = isset($patternStoreData["desc"]) ? $patternStoreData["desc"] : ""; $patternData["patternExtension"] = $patternExtension; $patternData["patternName"] = $patternStoreData["nameClean"]; $patternData["patternPartial"] = $patternStoreData["partial"]; $patternData["patternState"] = $patternStoreData["state"]; // extra copy for the code view $patternData["extraOutput"] = isset($patternStoreData["extraOutput"]) ? $patternStoreData["extraOutput"] : array(); // add the pattern lab specific mark-up // set a default var $exportClean = isset($options["exportClean"]) ? $options["exportClean"] : false; $data["patternLabHead"] = !$this->exportFiles ? $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $data["cacheBuster"]))) : ""; $data["patternLabFoot"] = !$this->exportFiles ? $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $data["cacheBuster"], "patternData" => json_encode($patternData)))) : ""; /* add text-direction */ $data['patternTextDirection'] = $store[$patternStoreKey]['patternTextDirection']; /* add text-direction end */ if (isset($patternStoreData["patternRaw"])) { $header = !$this->exportClean ? $stringLoader->render(array("string" => $patternHead, "data" => $data)) : ""; $code = $patternLoader->render(array("pattern" => $patternStoreData["patternRaw"], "data" => $data)); $footer = !$this->exportClean ? $stringLoader->render(array("string" => $patternFoot, "data" => $data)) : ""; PatternData::setPatternOption($patternStoreKey, "header", $header); PatternData::setPatternOption($patternStoreKey, "code", $code); PatternData::setPatternOption($patternStoreKey, "footer", $footer); } } } }