Fixing bad merge in last commit

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3926 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-11-23 06:55:44 +00:00
parent 26350a3890
commit 6ed2c67521

View file

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