"Fixes #4201, Cake i18n script in command line.

Fixed i18n shell to prompt for task commands.
Changed i18n shell to create database tables using schema
Changed acl shell to create database tables using schema"

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6516 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2008-03-08 07:14:33 +00:00
parent d801e5c897
commit 2e3391006f
4 changed files with 36 additions and 43 deletions

View file

@ -251,7 +251,7 @@ class ShellDispatcher {
if (strpos($shell, '.') !== false) {
list($plugin, $shell) = explode('.', $this->args[0]);
}
$this->shell = $shell;
$this->shiftArgs();
$this->shellName = Inflector::camelize($this->shell);
@ -268,14 +268,14 @@ class ShellDispatcher {
$paths[] = $pluginPaths[$i] . $plugin . DS . 'vendors' . DS . 'shells' . DS;
}
}
$vendorPaths = Configure::read('vendorPaths');
$count = count($vendorPaths);
for ($i = 0; $i < $count; $i++) {
$paths[] = $vendorPaths[$i] . DS . 'shells' . DS;
}
$this->shellPaths = array_merge($paths, array(CONSOLE_LIBS));
$this->shellPaths = array_merge($paths, array(CONSOLE_LIBS));
foreach ($this->shellPaths as $path) {
$this->shellPath = $path . $this->shell . ".php";
if (file_exists($this->shellPath)) {
@ -283,9 +283,11 @@ class ShellDispatcher {
break;
}
}
if ($loaded) {
require CONSOLE_LIBS . 'shell.php';
if (!class_exists('Shell')) {
require CONSOLE_LIBS . 'shell.php';
}
require $this->shellPath;
if (class_exists($this->shellClass)) {
$command = null;

View file

@ -347,7 +347,8 @@ class AclShell extends Shell {
* @access public
*/
function initdb() {
$this->err('This command is deprecated. Please use, cake schema run create DbAcl');
$this->Dispatch->args = array('schema', 'run', 'create', 'DbAcl');
$this->Dispatch->dispatch();
}
/**
* Show help screen.

View file

@ -54,6 +54,7 @@ class I18nShell extends Shell {
* @access public
*/
function startup() {
if (isset($this->params['datasource'])) {
$this->dataSource = $this->params['datasource'];
}
@ -82,16 +83,16 @@ class I18nShell extends Shell {
switch($choice) {
case 'E':
$this->Extract->execute();
break;
break;
case 'I':
$this->initdb();
break;
break;
case 'H':
$this->help();
break;
break;
case 'Q':
exit(0);
break;
break;
default:
$this->out(__('You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.', true));
}
@ -104,27 +105,8 @@ class I18nShell extends Shell {
* @access public
*/
function initdb() {
$db =& ConnectionManager::getDataSource($this->dataSource);
$this->out(__('Initializing Database...', true), true);
$this->out(__('Creating i18n table ...', true), true);
$sql = ' CREATE TABLE '.$db->fullTableName('i18n').' (
'.$db->name('id').' '.$db->column($db->columns['primary_key']).',
'.$db->name('locale').' '.$db->column(array('name' => 'varchar', 'limit' => 6)).' NOT NULL,
'.$db->name('model').' '.$db->column($db->columns['string']).' NOT NULL,
'.$db->name('foreign_key').' '.$db->column($db->columns['integer']).' NOT NULL,
'.$db->name('field').' '.$db->column($db->columns['string']).' NOT NULL,
'.$db->name('content').' '.$db->column($db->columns['text']).',
PRIMARY KEY ('.$db->name('id').'),
INDEX locale ('.$db->name('locale').'),
INDEX model ('.$db->name('model').'),
INDEX foreign_key ('.$db->name('foreign_key').'),
INDEX field ('.$db->name('field').')
)';
if ($db->query($sql) === false) {
die('Error: ' . $db->lastError());
}
$this->out(__('Done.', true), true);
$this->Dispatch->args = array('schema', 'run', 'create', 'i18n');
$this->Dispatch->dispatch();
}
/**
* Show help screen.

View file

@ -129,6 +129,20 @@ class ExtractTask extends Shell{
* @access public
*/
function initialize() {
}
/**
* Override startup
*
* @access public
*/
function startup() {
}
/**
* Execution method always used for tasks
*
* @access public
*/
function execute() {
if (isset($this->params['files']) && !is_array($this->params['files'])) {
$this->files = explode(',', $this->params['files']);
}
@ -148,7 +162,7 @@ class ExtractTask extends Shell{
$this->path = $response;
} else {
$this->err('The directory path you supplied was not found. Please try again.');
$this->initialize();
$this->execute();
}
}
@ -173,27 +187,21 @@ class ExtractTask extends Shell{
$this->__output = $response . DS;
} else {
$this->err('The directory path you supplied was not found. Please try again.');
$this->initialize();
$this->execute();
}
}
if (empty($this->files)) {
$this->files = $this->__searchDirectory();
}
$this->__extract();
}
/**
* Override startup
* Extract text
*
* @access public
* @access private
*/
function startup() {
}
/**
* Execution method always used for tasks
*
* @access public
*/
function execute() {
function __extract() {
$this->out('');
$this->out('');
$this->out(__('Extracting...', true));