2006-08-16 16:20:55 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
|
|
* Short description for file.
|
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
2007-02-02 10:39:45 +00:00
|
|
|
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
|
|
|
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
2006-08-16 16:20:55 +00:00
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
2007-02-02 10:39:45 +00:00
|
|
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
|
|
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
2006-08-16 16:20:55 +00:00
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.scripts.bake
|
2007-02-02 10:39:45 +00:00
|
|
|
* @since CakePHP(tm) v 1.2
|
2006-08-16 16:20:55 +00:00
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
|
*/
|
2007-05-04 19:32:05 +00:00
|
|
|
class Bake2Script extends CakeScript {
|
|
|
|
|
|
|
|
var $task = null;
|
|
|
|
|
|
|
|
function initialize() {
|
|
|
|
pr($this->args);
|
|
|
|
if(isset($this->args[0])) {
|
|
|
|
$this->task = $this->args[0];
|
2006-09-10 13:50:23 +00:00
|
|
|
}
|
2006-08-16 16:20:55 +00:00
|
|
|
}
|
2006-11-23 06:55:44 +00:00
|
|
|
|
2007-05-04 19:32:05 +00:00
|
|
|
function main() {
|
|
|
|
if($this->task == null) {
|
|
|
|
$this->err('No Task specified');
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
$task = $this->_loadTask($this->task);
|
|
|
|
if ($task !== null) {
|
|
|
|
$task->execute($this->args);
|
2006-10-22 12:34:50 +00:00
|
|
|
} else {
|
2007-05-04 19:32:05 +00:00
|
|
|
$this->err("Task not found: " . $this->task . "\n");
|
2006-10-22 12:34:50 +00:00
|
|
|
}
|
2006-08-16 16:20:55 +00:00
|
|
|
}
|
2006-11-23 06:55:44 +00:00
|
|
|
|
2007-05-04 19:32:05 +00:00
|
|
|
function _loadTask($taskName = null) {
|
|
|
|
$loaded = false;
|
|
|
|
foreach($this->Dispatch->scriptPaths as $path) {
|
|
|
|
$this->taskPath = $path . 'tasks' . DS . $taskName.'_task.php';
|
|
|
|
if (file_exists($this->taskPath)) {
|
|
|
|
$loaded = true;
|
|
|
|
break;
|
2006-08-16 16:20:55 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-04 19:32:05 +00:00
|
|
|
|
|
|
|
if ($loaded) {
|
|
|
|
require SCRIPTS . 'tasks' . DS . 'bake_task.php';
|
|
|
|
require $this->taskPath;
|
|
|
|
|
|
|
|
$this->taskClass = $taskName.'Task';
|
|
|
|
if(class_exists($this->taskClass)) {
|
|
|
|
return new $this->taskClass($this);
|
|
|
|
}
|
2006-09-10 13:50:23 +00:00
|
|
|
}
|
2006-10-22 12:34:50 +00:00
|
|
|
return null;
|
2006-09-10 13:50:23 +00:00
|
|
|
}
|
2006-11-23 06:55:44 +00:00
|
|
|
|
2007-05-04 19:32:05 +00:00
|
|
|
function _readConfigFile($fileName) {
|
2006-08-16 16:20:55 +00:00
|
|
|
$fileLineArray = file($fileName);
|
|
|
|
|
|
|
|
foreach($fileLineArray as $fileLine) {
|
|
|
|
$dataLine = trim($fileLine);
|
2006-11-23 06:55:44 +00:00
|
|
|
|
2006-08-16 16:20:55 +00:00
|
|
|
$delimiter = strpos($dataLine, '=');
|
|
|
|
|
|
|
|
if ($delimiter > 0) {
|
|
|
|
$key = strtolower(trim(substr($dataLine, 0, $delimiter)));
|
|
|
|
$value = trim(substr($dataLine, $delimiter + 1));
|
|
|
|
$iniSetting[$key] = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $iniSetting;
|
|
|
|
}
|
2006-11-23 06:55:44 +00:00
|
|
|
|
2007-05-04 19:32:05 +00:00
|
|
|
function help() {
|
2006-08-16 16:20:55 +00:00
|
|
|
echo "Usage: php bake2.php task [param1, ...]\n";
|
|
|
|
}
|
2007-05-04 19:32:05 +00:00
|
|
|
}
|
2006-08-16 16:20:55 +00:00
|
|
|
?>
|