From 2e3391006fd3b30431a479c9c9ee5cc214daac48 Mon Sep 17 00:00:00 2001 From: phpnut Date: Sat, 8 Mar 2008 07:14:33 +0000 Subject: [PATCH] "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 --- cake/console/cake.php | 12 ++++++----- cake/console/libs/acl.php | 3 ++- cake/console/libs/i18n.php | 32 +++++++---------------------- cake/console/libs/tasks/extract.php | 32 ++++++++++++++++++----------- 4 files changed, 36 insertions(+), 43 deletions(-) diff --git a/cake/console/cake.php b/cake/console/cake.php index dc179db58..fafa2fa99 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -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; diff --git a/cake/console/libs/acl.php b/cake/console/libs/acl.php index 856853150..b1e6bcfd7 100644 --- a/cake/console/libs/acl.php +++ b/cake/console/libs/acl.php @@ -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. diff --git a/cake/console/libs/i18n.php b/cake/console/libs/i18n.php index f3a16db53..2dddf8e97 100644 --- a/cake/console/libs/i18n.php +++ b/cake/console/libs/i18n.php @@ -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. diff --git a/cake/console/libs/tasks/extract.php b/cake/console/libs/tasks/extract.php index 82b048380..d27bf1340 100644 --- a/cake/console/libs/tasks/extract.php +++ b/cake/console/libs/tasks/extract.php @@ -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));