diff --git a/cake/scripts/bake2.php b/cake/scripts/bake2.php index 50735c68c..7b10aeb4b 100644 --- a/cake/scripts/bake2.php +++ b/cake/scripts/bake2.php @@ -30,7 +30,7 @@ defineConstants(); $cakeDir = CORE_PATH.DS.'cake'.DS; $argCount = count($argv); - + if ($argCount == 1 || isHelpParam($argv[1])) { showHelp(); } else { @@ -38,7 +38,7 @@ $appPath = false; $params = null; $showHelp = false; - + if ($argCount > 2) { if (isHelpParam($argv[2])) { $showHelp = true; @@ -46,7 +46,7 @@ $appPath = getAppPath($argv[2]); } } - + if ($appPath != false) { defineAppConstants($appPath); $params = prepareParams($argv, 3); @@ -54,16 +54,16 @@ defineAppConstantsWithDefaultValues(); $params = prepareParams($argv, 2); } - + includeCoreFiles($cakeDir); - + if ($showHelp) { showHelpForTask($taskName); } else { executeTask($taskName, $params); } } - + function defineAppConstants($appPath) { $delimiter = strrpos($appPath, DS); $root = substr($appPath, 0, $delimiter); @@ -73,23 +73,23 @@ define('APP_DIR', $appdir); define('APP_PATH', ROOT.DS.APP_DIR.DS); // TODO: how to handle situation with a non-standard webroot setup? - define('WWW_ROOT', APP_PATH.DS.'webroot'.DS); + define('WWW_ROOT', APP_PATH.DS.'webroot'.DS); } - + function defineAppConstantsWithDefaultValues() { define('ROOT', CORE_PATH); define('APP_DIR', 'app'); define('APP_PATH', ROOT.DS.APP_DIR.DS); define('WWW_ROOT', APP_PATH.DS.'webroot'.DS); } - + function defineConstants() { define('PHP5', (phpversion() >= 5)); define('DS', DIRECTORY_SEPARATOR); define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__)))); define('CORE_PATH', CAKE_CORE_INCLUDE_PATH.DS); } - + function executeTask($taskName, $params) { $class = getTaskClass($taskName); @@ -99,18 +99,18 @@ echo "Task not found: " . $taskName . "\n"; } } - + function getAppPath($appPathShortcut) { $iniFile = CORE_PATH.DS.'apps.ini'; - + if (file_exists($iniFile)) { $appArray = readConfigFile($iniFile); - + if (array_key_exists($appPathShortcut, $appArray)) { return $appArray[$appPathShortcut]; } } - + return false; } @@ -119,32 +119,32 @@ $taskPath = 'tasks'.DS.$taskName.'_task.php'; $fileExists = true; require($scriptDir.DS.'tasks'.DS.'bake_task.php'); - + if (file_exists(VENDORS.$taskPath)) { require(VENDORS.$taskPath); } elseif (file_exists($scriptDir.DS.$taskPath)) { - require($scriptDir.DS.$taskPath); + require($scriptDir.DS.$taskPath); } else { $fileExists = false; } - + if ($fileExists) { $className = $taskName.'Task'; return new $className; } - + return null; } - + function includeCoreFiles($cakePath) { require($cakePath.'basics.php'); require($cakePath.'config'.DS.'paths.php'); } - + function isHelpParam($param) { return ($param == 'help' || $param == '--help'); } - + function prepareParams($originalParams, $elementsToRemove) { $params = $originalParams; @@ -154,13 +154,13 @@ return $params; } - + function readConfigFile($fileName) { $fileLineArray = file($fileName); foreach($fileLineArray as $fileLine) { $dataLine = trim($fileLine); - + $delimiter = strpos($dataLine, '='); if ($delimiter > 0) { @@ -172,11 +172,11 @@ return $iniSetting; } - + function showHelp() { echo "Usage: php bake2.php task [param1, ...]\n"; } - + function showHelpForTask($taskName) { $class = getTaskClass($taskName); $class->help();