コード例 #1
0
 /**
  * Prints a pane from this page
  * @param string $paneId
  */
 public function printPane($paneId)
 {
     // If we are going to show an export
     if (ModulaiseController::$buildMode == SHOW_EXPORT) {
         switch ($paneId) {
             case PANE_JS_HEAD:
                 echo ModulaiseUtils::getJsImportStatement(FOLDER_COMPILED . "/js/" . FILENAME_JSHEAD_COMPILED);
                 return true;
             case PANE_JS_FOOT:
                 echo ModulaiseUtils::getJsImportStatement(FOLDER_COMPILED . "/js/" . FILENAME_JSFOOT_COMPILED);
                 return true;
             case PANE_CSS:
                 echo ModulaiseUtils::getCssImportStatement(FOLDER_COMPILED . "/css/" . FILENAME_CSS_COMPILED);
                 return true;
             default:
                 return $this->paneContent->printPane($paneId);
                 return true;
         }
     }
     return $this->paneContent->printPane($paneId);
 }
コード例 #2
0
 /**
  * Prints ant properties
  */
 public static function getAntProperties()
 {
     // read all module templates
     $allModuleTemplates = ModulaiseUtils::getDirectoryAsArray(ModulaiseController::$DIR_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . PATH_BOILERPLATES_MODULES);
     echo "# List all moduletemplates from boilerplates/modules folder\n";
     $firstLoop = true;
     // loop all modules files
     foreach ($allModuleTemplates as $templateName) {
         if ($firstLoop) {
             echo "ALL_MODULE_TEMPLATES_DEFAULT=" . $templateName . "\n";
             echo "ALL_MODULE_TEMPLATES=";
             $firstLoop = false;
         } else {
             echo ",";
         }
         echo $templateName;
     }
     // read all page templates
     $allPageTemplates = ModulaiseUtils::getDirectoryAsArray(ModulaiseController::$DIR_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . PATH_BOILERPLATES_PAGES);
     echo "\n\n# List all pagetemplates from boilerplates/pages folder\n";
     $firstLoop = true;
     // loop all modules files
     foreach ($allPageTemplates as $templateName) {
         if ($firstLoop) {
             echo "ALL_PAGE_TEMPLATES_DEFAULT=" . $templateName . "\n";
             echo "ALL_PAGE_TEMPLATES=";
             $firstLoop = false;
         } else {
             echo ",";
         }
         echo $templateName;
     }
     // read all project templates
     $allBoilerPlates = ModulaiseUtils::getDirectoryAsArray(ModulaiseController::$DIR_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . PATH_BOILERPLATES_PROJECTS);
     echo "\n\n# List all boilerplates from boilerplates/projects folder\n";
     $firstLoop = true;
     // loop all modules files
     foreach ($allBoilerPlates as $boilerPlate) {
         if ($firstLoop) {
             echo "ALL_BOILERPLATES_DEFAULT=" . $boilerPlate . "\n";
             echo "ALL_BOILERPLATES=";
             $firstLoop = false;
         } else {
             echo ",";
         }
         echo $boilerPlate;
     }
     // read all build packages
     $allBuildPackages = ModulaiseUtils::getDirectoryAsArray(ModulaiseController::$DIR_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . PATH_BUILDS);
     // flip, we want latest builds first
     $allBuildPackages = array_reverse($allBuildPackages, true);
     echo "\n\n# List all buildPackages from build folder\n";
     $firstLoop = true;
     $i = 0;
     // loop all modules files
     foreach ($allBuildPackages as $buildTag) {
         $i++;
         if ($i < 20 && ModulaiseUtils::EndsWith($buildTag, ".zip")) {
             if ($firstLoop) {
                 echo "ALL_BUILDPACKAGES_DEFAULT=" . substr($buildTag, 0, -4) . "\n";
                 echo "ALL_BUILDPACKAGES=";
                 $firstLoop = false;
             } else {
                 echo ",";
             }
             echo substr($buildTag, 0, -4);
         }
     }
     // read all deploy destinations
     $allDeployDestinations = ModulaiseUtils::getDirectoryAsArray(ModulaiseController::$DIR_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . PATH_TO_DEPLOY_TARGETS, ONLY_DIRECTORIES);
     echo "\n\n# List all deploy destinations from config-project folder\n";
     $firstLoop = true;
     // loop all modules files
     foreach ($allDeployDestinations as $destination) {
         if ($firstLoop) {
             echo "ALL_DEPLOY_DESTINATIONS_DEFAULT=" . $destination . "\n";
             echo "ALL_DEPLOY_DESTINATIONS=";
             $firstLoop = false;
         } else {
             echo ",";
         }
         echo $destination;
     }
 }
コード例 #3
0
 /**
  * Prints a comment
  */
 public static function printComment($comment)
 {
     ModulaiseUtils::printComment($comment);
 }
コード例 #4
0
 /**
  * Adds a css snippet for export purposes
  */
 public function addExportCssSnippet($moduleId, $paneId, $priorityId, $snippetPath)
 {
     $debug = false;
     $priorityId = intval($priorityId);
     $fileName = ModulaiseController::$DIR_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . ModulaiseController::$PATH_MODULES . DIRECTORY_SEPARATOR . $moduleId . DIRECTORY_SEPARATOR . $snippetPath;
     if ($debug) {
         ModulaiseController::printComment("\n\n" . get_class() . "->addFileSnippet(): " . $moduleId . ", " . $paneId . ", " . $priorityId . ", " . $snippetPath . "\n\n");
     }
     // check if the file to include exists:
     if (isset($fileName) && is_file($fileName)) {
         // extract variables from the global scope:
         extract($GLOBALS, EXTR_REFS);
         ob_start();
         include $fileName;
         $snippet = ob_get_clean();
     } else {
         ob_clean();
         return false;
     }
     // If there is a media type { } around the snippet this function extracts it
     $snippet = ModulaiseUtils::extractCss($snippet);
     // add to content
     if (!$this->addContent($paneId, $priorityId, $snippet)) {
         ModulaiseController::printComment("\n\nERROR:\n" . get_class() . "->addFileSnippet(): " . $paneId . ", " . $priorityId . ", " . $snippetPath . "\n\n");
         die;
     }
     return true;
 }
コード例 #5
0
 public static function getPages()
 {
     // Get all pages
     $returnArray = array();
     $pageDirectory = ModulaiseController::$DIR_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . PATH_PAGES;
     $allPages = ModulaiseUtils::getDirectoryAsArray($pageDirectory);
     foreach ($allPages as $file) {
         if (ModulaiseUtils::EndsWith($file, ".php")) {
             $pageName = substr($file, 0, -4);
             $currentLink = PATH_PAGES . "/" . substr($file, 0, -4) . ".php";
             $cacheLink = PATH_PAGES . "/" . substr($file, 0, -4) . ".php?writeCachedHtml=true";
             $exportLink = PATH_PAGES_COMPILED . "/" . substr($file, 0, -4) . ".html";
             array_push($returnArray, new ModulaiseIndexPageElement($pageName, $currentLink, $exportLink, $cacheLink));
         }
     }
     return $returnArray;
 }
コード例 #6
0
 /**
  * Concatinates CSS and JavaScript
  */
 public static function buildCompiled()
 {
     echo "\nConcatinating CSS and JavaScript\n--------------------------------------------------------------------------------\n";
     // set the PageController buildMode value to BUILD_EXPORT
     ModulaiseController::$buildMode = BUILD_EXPORT;
     // Reset global modules
     ModulaiseController::initialize();
     // Create a page containing all modules and then in turn print js_head, js_foot and css
     ModulaiseController::createPage("EXPORT", "EXPORT");
     // add all global modules to global modules array
     $allModuleNames = ModulaiseUtils::getDirectoryAsArray(ModulaiseController::$DIR_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . ModulaiseController::$PATH_MODULES, ONLY_DIRECTORIES);
     // build a list with all non-global modules
     foreach ($allModuleNames as $moduleId) {
         echo "Compiling module        : " . $moduleId . "\n";
         if (substr($moduleId, 0, 1) != "0") {
             ModulaiseController::addModule("EXPORT", $moduleId);
         }
     }
     $buildTagComment = "/*\n\nBuildtag: " . ModulaiseController::$buildTag . "\n\n*/\n\n";
     // Write PANE_JS_HEAD
     // the file to write
     $writeFile = ModulaiseController::$DIR_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . ModulaiseController::$PATH_MODULES . DIRECTORY_SEPARATOR . FOLDER_COMPILED . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "js_head.concatinated.js";
     echo "Writing file            : " . $writeFile . "\n";
     // capture output start
     $captureOutput = new ModulaiseCaptureOutput();
     $captureOutput->start();
     echo $buildTagComment;
     if (ModulaiseController::paneHasContent(PANE_JS_HEAD)) {
         // render the pane
         ModulaiseController::printPane(PANE_JS_HEAD);
     }
     // capture output end
     $output = $captureOutput->end();
     // write the output to file
     ModulaiseUtils::writeFile($writeFile, $output);
     // Write PANE_JS_FOOT
     // the file to write
     $writeFile = ModulaiseController::$DIR_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . ModulaiseController::$PATH_MODULES . DIRECTORY_SEPARATOR . FOLDER_COMPILED . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "js_foot.concatinated.js";
     echo "Writing file            : " . $writeFile . "\n";
     // capture output start
     $captureOutput = new ModulaiseCaptureOutput();
     $captureOutput->start();
     echo $buildTagComment;
     if (ModulaiseController::paneHasContent(PANE_JS_FOOT)) {
         // render the pane
         ModulaiseController::printPane(PANE_JS_FOOT);
     }
     // capture output end
     $output = $captureOutput->end();
     // write the output to file
     ModulaiseUtils::writeFile($writeFile, $output);
     // Write each and every PANE_CSS
     // Prepare an empty array to hold the css
     $concatinated_css = array();
     $debug = false;
     // get the pane names
     $paneNames = ModulaiseController::getPaneNames();
     foreach ($paneNames as $name) {
         if ($debug === true) {
             echo "paneName=" . $name . "\n";
         }
         $pos = strpos($name, PANE_CSS);
         if (!($pos === false)) {
             $nameArrays = explode("--", $name);
             // leading zero
             $nameArrays[1] = $nameArrays[1] < 10 ? "0" . $nameArrays[1] : $nameArrays[1];
             // the file to write
             $writeFile = ModulaiseController::$DIR_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . ModulaiseController::$PATH_MODULES . DIRECTORY_SEPARATOR . FOLDER_COMPILED . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . $nameArrays[1] . DELIMITER . $nameArrays[2] . ".concatinated.css";
             echo "Writing file            : " . $writeFile . "\n";
             // capture output start
             $captureOutput = new ModulaiseCaptureOutput();
             $captureOutput->start();
             echo $buildTagComment;
             if (ModulaiseController::paneHasContent($name)) {
                 // render the pane
                 ModulaiseController::printPane($name);
             }
             // capture output end
             $output = $captureOutput->end();
             // write the output to file
             ModulaiseUtils::writeFile($writeFile, $output);
             // Remove comments and blank lines from output
             $output = preg_replace('!/\\*.*?\\*/!s', '', $output);
             //$output = preg_replace('/\n\s*\n/', '', $output);
             //$output = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "", $output);
             $output = trim($output);
             if ($debug === true) {
                 echo "output=\"" . $output . "\"\n";
             }
             // if there is something to add
             if ($output != "") {
                 // also add the snippet to the concatinated array
                 $concatinated_css[$nameArrays[1] . "--" . $nameArrays[2]][] = $output;
             }
         }
     }
     // Write everything as one big pane
     // the file to write
     $writeFile = ModulaiseController::$DIR_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . ModulaiseController::$PATH_MODULES . DIRECTORY_SEPARATOR . FOLDER_COMPILED . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "css.concatinated.css";
     echo "Writing file            : " . $writeFile . "\n";
     // capture output start
     $captureOutput = new ModulaiseCaptureOutput();
     $captureOutput->start();
     echo $buildTagComment;
     // now use the concatinated_css array to concatinate everything into its right place
     foreach ($concatinated_css as $css_name => $contentsArray) {
         $nameArrays = explode("--", $css_name);
         $mediaType = ModulaiseUtils::getMediaType($nameArrays[1]);
         if ($mediaType != "@media all") {
             echo "/*!NEWLINE*/" . $mediaType . " {";
         } else {
             echo "/*!NEWLINE*/";
         }
         foreach ($contentsArray as $key => $content) {
             echo $content . "\n";
         }
         if ($mediaType != "@media all") {
             echo "}";
         }
         echo "/*!NEWLINE*/";
     }
     // render the pane
     //print_r($concatinated_css);
     // capture output end
     $output = $captureOutput->end();
     // write the output to file
     ModulaiseUtils::writeFile($writeFile, $output);
     if ($debug) {
         // write an extra output file
         ModulaiseUtils::writeFile($writeFile . ".text", $output);
     }
 }