From e78fc1e90c3030f8c20afe8c6b73901d651902fa Mon Sep 17 00:00:00 2001 From: phpnut Date: Sat, 20 Oct 2007 05:55:37 +0000 Subject: [PATCH] Fixes #3305, Console i18n extract using wrong paths. Closes #3396, i18n fixes Fixed TranslateBehavior::_getLocale() throwing error if I18n class had not been loaded Added [P]roject to bake Updated locale pot file Removed css and js directories from skel git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5809 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/console/libs/bake.php | 6 +- cake/console/libs/tasks/extract.php | 49 +- cake/console/libs/tasks/project.php | 17 +- .../libs/templates/skel/vendors/css/empty | 0 .../libs/templates/skel/vendors/js/empty | 0 cake/dispatcher.php | 2 +- cake/libs/controller/components/auth.php | 8 +- cake/libs/controller/controller.php | 4 +- cake/libs/error.php | 2 +- cake/libs/model/behaviors/translate.php | 3 + cake/libs/model/behaviors/tree.php | 10 +- cake/libs/view/helpers/form.php | 6 +- .../view/templates/errors/missing_action.ctp | 4 +- cake/libs/view/templates/pages/home.ctp | 6 +- cake/locale/default.pot | 1448 ++++++++++++----- 15 files changed, 1113 insertions(+), 452 deletions(-) delete mode 100644 cake/console/libs/templates/skel/vendors/css/empty delete mode 100644 cake/console/libs/templates/skel/vendors/js/empty diff --git a/cake/console/libs/bake.php b/cake/console/libs/bake.php index 3593e7eda..49c1ae31d 100644 --- a/cake/console/libs/bake.php +++ b/cake/console/libs/bake.php @@ -55,9 +55,10 @@ class BakeShell extends Shell { $this->out('[M]odel'); $this->out('[V]iew'); $this->out('[C]ontroller'); + $this->out('[P]roject'); $this->out('[Q]uit'); - $classToBake = strtoupper($this->in('What would you like to Bake?', array('D', 'M', 'V', 'C', 'Q'))); + $classToBake = strtoupper($this->in('What would you like to Bake?', array('D', 'M', 'V', 'C', 'P', 'Q'))); switch($classToBake) { case 'D': $this->DbConfig->execute(); @@ -71,6 +72,9 @@ class BakeShell extends Shell { case 'C': $this->Controller->execute(); break; + case 'P': + $this->Project->execute(); + break; case 'Q': exit(0); break; diff --git a/cake/console/libs/tasks/extract.php b/cake/console/libs/tasks/extract.php index b062c8e33..f49cb3658 100644 --- a/cake/console/libs/tasks/extract.php +++ b/cake/console/libs/tasks/extract.php @@ -84,7 +84,21 @@ class ExtractTask extends Shell{ if (isset($this->params['path'])) { $this->path = $this->params['path']; } else { - $this->path = ROOT . DS . APP_DIR; + $response = ''; + while ($response == '') { + $response = $this->in("What is the full path you would like to extract?\nExample: " . $this->params['root'] . DS . "myapp\n[Q]uit", null, 'Q'); + if (strtoupper($response) === 'Q') { + $this->out('Extract Aborted'); + exit(); + } + } + + if (is_dir($response)) { + $this->path = $response; + } else { + $this->err('The directory path you supplied was not found. Please try again.'); + $this->initialize(); + } } if (isset($this->params['debug'])) { @@ -95,7 +109,21 @@ class ExtractTask extends Shell{ if (isset($this->params['output'])) { $this->__output = $this->params['output']; } else { - $this->__output = APP . 'locale' . DS; + $response = ''; + while ($response == '') { + $response = $this->in("What is the full path you would like to output?\nExample: " . $this->path . DS . "locale\n[Q]uit", null, $this->path . DS . "locale"); + if (strtoupper($response) === 'Q') { + $this->out('Extract Aborted'); + exit(); + } + } + + if (is_dir($response)) { + $this->__output = $response . DS; + } else { + $this->err('The directory path you supplied was not found. Please try again.'); + $this->initialize(); + } } if (empty($this->files)) { @@ -413,6 +441,23 @@ class ExtractTask extends Shell{ } else { $fileList = 'No version information was available in the source files.'; } + + if (is_file($this->__output . $file)) { + $response = ''; + while ($response == '') { + $response = $this->in("\n\nError: ".$file . ' already exists in this location. Overwrite?', array('y','n', 'q'), 'n'); + if (strtoupper($response) === 'Q') { + $this->out('Extract Aborted'); + exit(); + } elseif (strtoupper($response) === 'N') { + $response = ''; + while ($response == '') { + $response = $this->in("What would you like to name this file?\nExample: new_" . $file, null, "new_" . $file); + $file = $response; + } + } + } + } $fp = fopen($this->__output . $file, 'w'); fwrite($fp, str_replace('--VERSIONS--', $fileList, join('', $content))); fclose($fp); diff --git a/cake/console/libs/tasks/project.php b/cake/console/libs/tasks/project.php index eacaa72b1..fdad09341 100644 --- a/cake/console/libs/tasks/project.php +++ b/cake/console/libs/tasks/project.php @@ -87,8 +87,19 @@ class ProjectTask extends Shell { while ($response == false && is_dir($project) === true && config('core') === true) { $response = $this->in('A project already exists in this location: '.$project.' Overwrite?', array('y','n'), 'n'); if (low($response) === 'n') { - $this->out('Bake Aborted'); - exit(); + $response = false; + + while (!$response) { + $response = $this->in("What is the full path for this app including the app directory name?\nExample: ".$this->params['root'] . DS . "myapp\n[Q]uit", null, 'Q'); + if (strtoupper($response) === 'Q') { + $this->out('Bake Aborted'); + exit(); + } + $this->params['working'] = null; + $this->params['app'] = null; + $this->execute($response); + exit(); + } } } } @@ -187,6 +198,8 @@ class ProjectTask extends Shell { } elseif (low($looksGood) == 'q' || low($looksGood) == 'quit') { $this->out('Bake Aborted.'); } else { + $this->params['working'] = null; + $this->params['app'] = null; $this->execute(false); } } diff --git a/cake/console/libs/templates/skel/vendors/css/empty b/cake/console/libs/templates/skel/vendors/css/empty deleted file mode 100644 index e69de29bb..000000000 diff --git a/cake/console/libs/templates/skel/vendors/js/empty b/cake/console/libs/templates/skel/vendors/js/empty deleted file mode 100644 index e69de29bb..000000000 diff --git a/cake/dispatcher.php b/cake/dispatcher.php index c1685d592..33c0b63fb 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -135,7 +135,7 @@ class Dispatcher extends Object { Router::setRequestInfo(array($this->params, array('base' => $this->base, 'webroot' => $this->webroot))); return $this->cakeError('error404', array(array('url' => strtolower($controller), - 'message' => 'Was not found on this server', + 'message' => __('Was not found on this server'), 'base' => $this->base))); } else { Router::setRequestInfo(array($this->params, array('base' => $this->base, 'webroot' => $this->webroot))); diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index e32550e79..4467d816a 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -166,7 +166,7 @@ class AuthComponent extends Object { * @var string * @access public */ - var $loginError = 'Login failed. Invalid username or password.'; + var $loginError = ''; /** * Error to display when user attempts to access an object or action to which they do not have * acccess. @@ -174,7 +174,7 @@ class AuthComponent extends Object { * @var string * @access public */ - var $authError = 'You are not authorized to access that location.'; + var $authError = ''; /** * Determines whether AuthComponent will automatically redirect and exit if login is successful. * @@ -229,6 +229,8 @@ class AuthComponent extends Object { $this->params = $controller->params; $crud = array('create', 'read', 'update', 'delete'); $this->actionMap = am($this->actionMap, array_combine($crud, $crud)); + $this->loginError = __('Login failed. Invalid username or password.', true); + $this->authError = __('You are not authorized to access that location.', true); $admin = Configure::read('Routing.admin'); if (!empty($admin)) { @@ -367,7 +369,7 @@ class AuthComponent extends Object { */ function __setDefaults() { if (empty($this->userModel)) { - trigger_error(__('Could not find $userModel. Please set AuthComponent::$userModel in beforeFilter().', true), E_USER_WARNING); + trigger_error(__("Could not find \$userModel. Please set AuthComponent::\$userModel in beforeFilter().", true), E_USER_WARNING); return false; } if (empty($this->loginAction)) { diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index dab06769f..fcce5c9d6 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -546,12 +546,12 @@ class Controller extends Object { call_user_func_array(array(&$this, $action), $args); } /** - * contoroller callback to tie into Auth component. + * controller callback to tie into Auth component. * * @return bool */ function isAuthorized() { - trigger_error(__($this->name.'::isAuthorized() is not defined.', true), E_USER_WARNING); + trigger_error(sprintf(__('%s::isAuthorized() is not defined.', true), $this->name), E_USER_WARNING); return false; } /** diff --git a/cake/libs/error.php b/cake/libs/error.php index 8f9d9cdd2..0acca089e 100644 --- a/cake/libs/error.php +++ b/cake/libs/error.php @@ -130,7 +130,7 @@ class ErrorHandler extends Object{ header("HTTP/1.0 404 Not Found"); $this->error(array('code' => '404', - 'name' => 'Not found', + 'name' => __('Not found', true), 'message' => sprintf(__("The requested address %s was not found on this server.", true), $url, $message), 'base' => $base)); exit(); diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index 431795213..a9f087f0b 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -276,6 +276,9 @@ class TranslateBehavior extends ModelBehavior { */ function _getLocale(&$model) { if (!isset($model->locale) || is_null($model->locale)) { + if (!class_exists('I18n')) { + uses('i18n'); + } $I18n =& I18n::getInstance(); $model->locale = $I18n->l10n->locale; } diff --git a/cake/libs/model/behaviors/tree.php b/cake/libs/model/behaviors/tree.php index 76717cebd..6b183ef65 100644 --- a/cake/libs/model/behaviors/tree.php +++ b/cake/libs/model/behaviors/tree.php @@ -541,7 +541,7 @@ class TreeBehavior extends ModelBehavior { */ function setparent(&$model, $parentId = null , $created = null) { extract($this->settings[$model->name]); - if ($created ===false && $parentId == $model->field($parent)) { + if ($created === false && $parentId == $model->field($parent)) { return true; } return $model->saveField($parent, $parentId); @@ -641,11 +641,11 @@ class TreeBehavior extends ModelBehavior { if (empty ($parentNode)) { return false; - } - elseif (($model->id == $parentId)) { + + } elseif (($model->id == $parentId)) { return false; - } - elseif (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) { + + } elseif (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) { return false; } diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index e2360da42..9dcfb9df3 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -922,9 +922,13 @@ class FormHelper extends AppHelper { * @param array $options * @return string A HTML submit button */ - function submit($caption = 'Submit', $options = array()) { + function submit($caption = null, $options = array()) { + if (!$caption) { + $caption = __('Submit'); + } $options['value'] = $caption; $secured = null; + if (isset($this->params['_Token']) && !empty($this->params['_Token'])) { $secured = $this->secure($this->fields); $this->fields = array(); diff --git a/cake/libs/view/templates/errors/missing_action.ctp b/cake/libs/view/templates/errors/missing_action.ctp index cf30bcc35..0797a542c 100644 --- a/cake/libs/view/templates/errors/missing_action.ctp +++ b/cake/libs/view/templates/errors/missing_action.ctp @@ -28,8 +28,8 @@

%1$s is not defined in controller %2$s', true), $action, $controller);?>

-

-

+

: +

<?php
class extends AppController {
   function () {
diff --git a/cake/libs/view/templates/pages/home.ctp b/cake/libs/view/templates/pages/home.ctp index 494711602..7bc2d3e84 100644 --- a/cake/libs/view/templates/pages/home.ctp +++ b/cake/libs/view/templates/pages/home.ctp @@ -47,7 +47,7 @@ endif; __('Your cache is set up and initialized properly.'); $settings = Cache::settings(); echo '

'; - echo sprintf(__('%s is being used to cache, to change this edit config'.DS.'core.php ', true), $settings['engine'] . 'Engine'); + echo sprintf(__('%s is being used to cache, to change this edit config/core.php ', true), $settings['engine'] . 'Engine'); echo '

'; echo 'Settings: