Merge branch '2.0' into 2.1

This commit is contained in:
AD7six 2011-10-20 08:57:49 +02:00
commit 53bc963315
57 changed files with 255 additions and 186 deletions

View file

@ -297,7 +297,7 @@
* *
*/ */
$engine = 'File'; $engine = 'File';
if (extension_loaded('apc') && (php_sapi_name() !== 'cli' || ini_get('apc.enable_cli'))) { if (extension_loaded('apc') && function_exists('apc_dec') && (php_sapi_name() !== 'cli' || ini_get('apc.enable_cli'))) {
$engine = 'Apc'; $engine = 'Apc';
} }

View file

@ -611,7 +611,7 @@ pre {
overflow: auto; overflow: auto;
position: relative; position: relative;
-moz-border-radius: 4px; -moz-border-radius: 4px;
-wekbkit-border-radius: 4px; -webkit-border-radius: 4px;
border-radius: 4px; border-radius: 4px;
} }
.cake-stack-trace a { .cake-stack-trace a {

View file

@ -49,7 +49,7 @@
* The absolute path to the "cake" directory, WITHOUT a trailing DS. * The absolute path to the "cake" directory, WITHOUT a trailing DS.
* *
* Un-comment this line to specify a fixed path to CakePHP. * Un-comment this line to specify a fixed path to CakePHP.
* This should point at the directory containg `Cake`. * This should point at the directory containing `Cake`.
* *
* For ease of development CakePHP uses PHP's include_path. If you * For ease of development CakePHP uses PHP's include_path. If you
* cannot modify your include_path set this value. * cannot modify your include_path set this value.

View file

@ -3,7 +3,7 @@
* Requests collector. * Requests collector.
* *
* This file collects requests if: * This file collects requests if:
* - no mod_rewrite is avilable or .htaccess files are not supported * - no mod_rewrite is available or .htaccess files are not supported
* - requires App.baseUrl to be uncommented in app/Config/core.php * - requires App.baseUrl to be uncommented in app/Config/core.php
* - app/webroot is not set as a document root. * - app/webroot is not set as a document root.
* *

View file

@ -96,7 +96,7 @@ class Cache {
* *
* - `duration` Specify how long items in this cache configuration last. * - `duration` Specify how long items in this cache configuration last.
* - `prefix` Prefix appended to all entries. Good for when you need to share a keyspace * - `prefix` Prefix appended to all entries. Good for when you need to share a keyspace
* with either another cache config or annother application. * with either another cache config or another application.
* - `probability` Probability of hitting a cache gc cleanup. Setting to 0 will disable * - `probability` Probability of hitting a cache gc cleanup. Setting to 0 will disable
* cache::gc from ever being called automatically. * cache::gc from ever being called automatically.
* - `servers' Used by memcache. Give the address of the memcached servers to use. * - `servers' Used by memcache. Give the address of the memcached servers to use.

View file

@ -37,7 +37,7 @@ class ApcEngine extends CacheEngine {
*/ */
public function init($settings = array()) { public function init($settings = array()) {
parent::init(array_merge(array('engine' => 'Apc', 'prefix' => Inflector::slug(APP_DIR) . '_'), $settings)); parent::init(array_merge(array('engine' => 'Apc', 'prefix' => Inflector::slug(APP_DIR) . '_'), $settings));
return function_exists('apc_cache_info'); return function_exists('apc_dec');
} }
/** /**

View file

@ -128,6 +128,7 @@ class FileEngine extends CacheEngine {
$this->_File->flock(LOCK_EX); $this->_File->flock(LOCK_EX);
} }
$this->_File->rewind();
$success = $this->_File->ftruncate(0) && $this->_File->fwrite($contents) && $this->_File->fflush(); $success = $this->_File->ftruncate(0) && $this->_File->fwrite($contents) && $this->_File->fflush();
if ($this->settings['lock']) { if ($this->settings['lock']) {

View file

@ -144,7 +144,8 @@ class CommandListShell extends Shell {
$this->out(" " . $row); $this->out(" " . $row);
} }
$this->out(); $this->out();
$this->out(__d('cake_console', "To run a command, type <info>cake shell_name [args]</info>")); $this->out(__d('cake_console', "To run an app or core command, type <info>cake shell_name [args]</info>"));
$this->out(__d('cake_console', "To run a plugin command, type <info>cake Plugin.shell_name [args]</info>"));
$this->out(__d('cake_console', "To get help on a specific command, type <info>cake shell_name --help</info>"), 2); $this->out(__d('cake_console', "To get help on a specific command, type <info>cake shell_name --help</info>"), 2);
} }

View file

@ -141,12 +141,15 @@ class UpgradeShell extends Shell {
$this->_files = array(); $this->_files = array();
chdir($cwd); chdir($cwd);
} }
$this->_moveViewFiles();
$moves = array( $moves = array(
'config' => 'Config',
'Config' . DS . 'schema' => 'Config' . DS . 'Schema',
'libs' => 'Lib', 'libs' => 'Lib',
'tests' => 'Test', 'tests' => 'Test',
'views' => 'View',
'models' => 'Model',
'Model' . DS . 'behaviors' => 'Model' . DS . 'Behavior',
'Model' . DS . 'datasources' => 'Model' . DS . 'Datasource',
'Test' . DS . 'cases' => 'Test' . DS . 'Case', 'Test' . DS . 'cases' => 'Test' . DS . 'Case',
'Test' . DS . 'fixtures' => 'Test' . DS . 'Fixture', 'Test' . DS . 'fixtures' => 'Test' . DS . 'Fixture',
'vendors' . DS . 'shells' . DS . 'templates' => 'Console' . DS . 'Templates', 'vendors' . DS . 'shells' . DS . 'templates' => 'Console' . DS . 'Templates',
@ -156,7 +159,8 @@ class UpgradeShell extends Shell {
$this->out(__d('cake_console', 'Moving %s to %s', $old, $new)); $this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
if (!$this->params['dry-run']) { if (!$this->params['dry-run']) {
if ($this->params['git']) { if ($this->params['git']) {
exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($new)); exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($old . '__'));
exec('git mv -f ' . escapeshellarg($old . '__') . ' ' . escapeshellarg($new));
} else { } else {
$Folder = new Folder($old); $Folder = new Folder($old);
$Folder->move($new); $Folder->move($new);
@ -164,18 +168,19 @@ class UpgradeShell extends Shell {
} }
} }
} }
$this->_moveViewFiles();
$sourceDirs = array( $sourceDirs = array(
'.' => array('recursive' => false), '.' => array('recursive' => false),
'Console', 'Console',
'Controller',
'controllers', 'controllers',
'Controller',
'Lib' => array('checkFolder' => false), 'Lib' => array('checkFolder' => false),
'Model',
'models', 'models',
'Test' => array('regex' => '@class (\S*Test) extends CakeTestCase@'), 'Model',
'tests', 'tests',
'View', 'Test' => array('regex' => '@class (\S*Test) extends CakeTestCase@'),
'views', 'views',
'View',
'vendors/shells', 'vendors/shells',
); );
@ -515,23 +520,27 @@ class UpgradeShell extends Shell {
* @return void * @return void
*/ */
protected function _moveViewFiles() { protected function _moveViewFiles() {
if (!is_dir('views')) { if (!is_dir('View')) {
return; return;
} }
$dirs = scandir('views'); $dirs = scandir('View');
foreach ($dirs as $old) { foreach ($dirs as $old) {
if (!is_dir('views' . DS . $old) || $old === '.' || $old === '..') { if (!is_dir('View' . DS . $old) || $old === '.' || $old === '..') {
continue; continue;
} }
$new = 'View' . DS . Inflector::camelize($old); $new = 'View' . DS . Inflector::camelize($old);
$old = 'views' . DS . $old; $old = 'View' . DS . $old;
if ($new == $old) {
continue;
}
$this->out(__d('cake_console', 'Moving %s to %s', $old, $new)); $this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
if (!$this->params['dry-run']) { if (!$this->params['dry-run']) {
if ($this->params['git']) { if ($this->params['git']) {
exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($new)); exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($old . '__'));
exec('git mv -f ' . escapeshellarg($old . '__') . ' ' . escapeshellarg($new));
} else { } else {
$Folder = new Folder($old); $Folder = new Folder($old);
$Folder->move($new); $Folder->move($new);
@ -620,7 +629,8 @@ class UpgradeShell extends Shell {
$this->out(__d('cake_console', 'Moving %s to %s', $file, $new), 1, Shell::VERBOSE); $this->out(__d('cake_console', 'Moving %s to %s', $file, $new), 1, Shell::VERBOSE);
if (!$this->params['dry-run']) { if (!$this->params['dry-run']) {
if ($this->params['git']) { if ($this->params['git']) {
exec('git mv -f ' . escapeshellarg($file) . ' ' . escapeshellarg($new)); exec('git mv -f ' . escapeshellarg($file) . ' ' . escapeshellarg($file . '__'));
exec('git mv -f ' . escapeshellarg($file. '__') . ' ' . escapeshellarg($new));
} else { } else {
rename($file, $new); rename($file, $new);
} }

View file

@ -206,6 +206,7 @@ class ShellDispatcher {
protected function _getShell($shell) { protected function _getShell($shell) {
list($plugin, $shell) = pluginSplit($shell, true); list($plugin, $shell) = pluginSplit($shell, true);
$plugin = Inflector::camelize($plugin);
$class = Inflector::camelize($shell) . 'Shell'; $class = Inflector::camelize($shell) . 'Shell';
App::uses('Shell', 'Console'); App::uses('Shell', 'Console');

View file

@ -297,7 +297,7 @@
* *
*/ */
$engine = 'File'; $engine = 'File';
if (extension_loaded('apc') && (php_sapi_name() !== 'cli' || ini_get('apc.enable_cli'))) { if (extension_loaded('apc') && function_exists('apc_dec') && (php_sapi_name() !== 'cli' || ini_get('apc.enable_cli'))) {
$engine = 'Apc'; $engine = 'Apc';
} }

View file

@ -49,7 +49,7 @@
* The absolute path to the "cake" directory, WITHOUT a trailing DS. * The absolute path to the "cake" directory, WITHOUT a trailing DS.
* *
* Un-comment this line to specify a fixed path to CakePHP. * Un-comment this line to specify a fixed path to CakePHP.
* This should point at the directory containg `Cake`. * This should point at the directory containing `Cake`.
* *
* For ease of development CakePHP uses PHP's include_path. If you * For ease of development CakePHP uses PHP's include_path. If you
* cannot modify your include_path set this value. * cannot modify your include_path set this value.

View file

@ -18,7 +18,7 @@
App::uses('ComponentCollection', 'Controller'); App::uses('ComponentCollection', 'Controller');
/** /**
* Base class for an individual Component. Components provide resuable bits of * Base class for an individual Component. Components provide reusable bits of
* controller logic that can be composed into a controller. Components also * controller logic that can be composed into a controller. Components also
* provide request life-cycle callbacks for injecting logic at specific points. * provide request life-cycle callbacks for injecting logic at specific points.
* *

View file

@ -536,7 +536,7 @@ class AuthComponent extends Component {
/** /**
* Get the current user from the session. * Get the current user from the session.
* *
* @param string $key field to retrive. Leave null to get entire User record * @param string $key field to retrieve. Leave null to get entire User record
* @return mixed User record. or null if no user is logged in. * @return mixed User record. or null if no user is logged in.
* @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user * @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user
*/ */

View file

@ -140,7 +140,7 @@ class RequestHandlerComponent extends Component {
$preferredTypes = $this->mapType($preferred); $preferredTypes = $this->mapType($preferred);
$similarTypes = array_intersect($extensions, $preferredTypes); $similarTypes = array_intersect($extensions, $preferredTypes);
if (count($similarTypes) === 1 && !in_array('html', $preferredTypes)) { if (count($similarTypes) === 1 && !in_array('html', $preferredTypes)) {
$this->ext = $similarTypes[0]; $this->ext = array_shift($similarTypes);
} }
} }

View file

@ -274,7 +274,7 @@ class SecurityComponent extends Component {
} }
/** /**
* Black-hole an invalid request with a 404 error or custom callback. If SecurityComponent::$blackHoleCallback * Black-hole an invalid request with a 400 error or custom callback. If SecurityComponent::$blackHoleCallback
* is specified, it will use this callback by executing the method indicated in $error * is specified, it will use this callback by executing the method indicated in $error
* *
* @param Controller $controller Instantiating controller * @param Controller $controller Instantiating controller
@ -282,15 +282,11 @@ class SecurityComponent extends Component {
* @return mixed If specified, controller blackHoleCallback's response, or no return otherwise * @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
* @see SecurityComponent::$blackHoleCallback * @see SecurityComponent::$blackHoleCallback
* @link http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html#handling-blackhole-callbacks * @link http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html#handling-blackhole-callbacks
* @throws BadRequestException
*/ */
public function blackHole($controller, $error = '') { public function blackHole($controller, $error = '') {
if ($this->blackHoleCallback == null) { if ($this->blackHoleCallback == null) {
$code = 404; throw new BadRequestException(__d('cake_dev', 'The request has been black-holed'));
if ($error == 'login') {
$code = 401;
$controller->header($this->loginRequest());
}
return $controller->redirect(null, $code, true);
} else { } else {
return $this->_callback($controller, $this->blackHoleCallback, array($error)); return $this->_callback($controller, $this->blackHoleCallback, array($error));
} }

View file

@ -171,7 +171,7 @@ class Controller extends Object {
/** /**
* Instance of ComponentCollection used to handle callbacks. * Instance of ComponentCollection used to handle callbacks.
* *
* @var string * @var ComponentCollection
*/ */
public $Components = null; public $Components = null;

View file

@ -212,7 +212,7 @@ class Scaffold {
* Saves or updates the scaffolded model. * Saves or updates the scaffolded model.
* *
* @param CakeRequest $request Request Object for scaffolding * @param CakeRequest $request Request Object for scaffolding
* @param string $action add or edt * @param string $action add or edit
* @return mixed Success on save/update, add/edit form if data is empty or error if save or update fails * @return mixed Success on save/update, add/edit form if data is empty or error if save or update fails
* @throws NotFoundException * @throws NotFoundException
*/ */

View file

@ -194,7 +194,7 @@ class CakePlugin {
} }
/** /**
* Retruns true if the plugin $plugin is already loaded * Returns true if the plugin $plugin is already loaded
* If plugin is null, it will return a list of all loaded plugins * If plugin is null, it will return a list of all loaded plugins
* *
* @param string $plugin * @param string $plugin

View file

@ -2,7 +2,7 @@
/** /**
* BehaviorCollection * BehaviorCollection
* *
* Provides managment and interface for interacting with collections of behaviors. * Provides management and interface for interacting with collections of behaviors.
* *
* PHP 5 * PHP 5
* *

View file

@ -590,7 +590,7 @@ class CakeSchema extends Object {
$value['key'] = 'primary'; $value['key'] = 'primary';
} }
if (!isset($db->columns[$value['type']])) { if (!isset($db->columns[$value['type']])) {
trigger_error(__d('cake_dev', 'Schema generation error: invalid column type %s does not exist in DBO', $value['type']), E_USER_NOTICE); trigger_error(__d('cake_dev', 'Schema generation error: invalid column type %s for %s.%s does not exist in DBO', $value['type'], $Obj->name, $name), E_USER_NOTICE);
continue; continue;
} else { } else {
$defaultCol = $db->columns[$value['type']]; $defaultCol = $db->columns[$value['type']];

View file

@ -722,7 +722,7 @@ class Model extends Object {
} }
/** /**
* Handles the lazy loading of model associations by lookin in the association arrays for the requested variable * Handles the lazy loading of model associations by looking in the association arrays for the requested variable
* *
* @param string $name variable tested for existance in class * @param string $name variable tested for existance in class
* @return boolean true if the variable exists (if is a not loaded model association it will be created), false otherwise * @return boolean true if the variable exists (if is a not loaded model association it will be created), false otherwise
@ -3032,7 +3032,7 @@ class Model extends Object {
* Runs validation for hasAndBelongsToMany associations that have 'with' keys * Runs validation for hasAndBelongsToMany associations that have 'with' keys
* set. And data in the set() data set. * set. And data in the set() data set.
* *
* @param array $options Array of options to use on Valdation of with models * @param array $options Array of options to use on Validation of with models
* @return boolean Failure of validation on with models. * @return boolean Failure of validation on with models.
* @see Model::validates() * @see Model::validates()
*/ */

View file

@ -23,7 +23,7 @@
* Model behavior base class. * Model behavior base class.
* *
* Defines the Behavior interface, and contains common model interaction functionality. Behaviors * Defines the Behavior interface, and contains common model interaction functionality. Behaviors
* allow you to simulate mixins, and create resuable blocks of application logic, that can be reused across * allow you to simulate mixins, and create reusable blocks of application logic, that can be reused across
* several models. Behaviors also provide a way to hook into model callbacks and augment their behavior. * several models. Behaviors also provide a way to hook into model callbacks and augment their behavior.
* *
* ### Mixin methods * ### Mixin methods

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Dispatcher takes the URL information, parses it for paramters and * Dispatcher takes the URL information, parses it for parameters and
* tells the involved controllers what to do. * tells the involved controllers what to do.
* *
* This is the heart of Cake's operation. * This is the heart of Cake's operation.

View file

@ -144,7 +144,7 @@ class Router {
protected static $_requests = array(); protected static $_requests = array();
/** /**
* Initial state is popualated the first time reload() is called which is at the bottom * Initial state is populated the first time reload() is called which is at the bottom
* of this file. This is a cheat as get_class_vars() returns the value of static vars even if they * of this file. This is a cheat as get_class_vars() returns the value of static vars even if they
* have changed. * have changed.
* *

View file

@ -97,6 +97,23 @@ class FileEngineTest extends CakeTestCase {
Cache::delete('test', 'file_test'); Cache::delete('test', 'file_test');
} }
/**
* Test read/write on the same cache key. Ensures file handles are re-wound.
*
* @return void
*/
public function testConsecutiveReadWrite() {
Cache::write('rw', 'first write', 'file_test');
$result = Cache::read('rw', 'file_test');
Cache::write('rw', 'second write', 'file_test');
$result2 = Cache::read('rw', 'file_test');
Cache::delete('rw', 'file_test');
$this->assertEquals('first write', $result);
$this->assertEquals('second write', $result2);
}
/** /**
* testExpiry method * testExpiry method
* *

View file

@ -284,10 +284,10 @@ class ExtractTaskTest extends CakeTestCase {
$this->Task->execute(); $this->Task->execute();
$result = file_get_contents($this->path . DS . 'default.pot'); $result = file_get_contents($this->path . DS . 'default.pot');
$pattern = '#Model/PersisterOne.php:validation for field title#'; $pattern = preg_quote('#Model' . DS . 'PersisterOne.php:validation for field title#', '\\');
$this->assertPattern($pattern, $result); $this->assertPattern($pattern, $result);
$pattern = '#Model/PersisterOne.php:validation for field body#'; $pattern = preg_quote('#Model' . DS . 'PersisterOne.php:validation for field body#', '\\');
$this->assertPattern($pattern, $result); $this->assertPattern($pattern, $result);
$pattern = '#msgid "Post title is required"#'; $pattern = '#msgid "Post title is required"#';
@ -329,10 +329,10 @@ class ExtractTaskTest extends CakeTestCase {
$this->Task->execute(); $this->Task->execute();
$result = file_get_contents($this->path . DS . 'test_plugin.pot'); $result = file_get_contents($this->path . DS . 'test_plugin.pot');
$pattern = '#Plugin/TestPlugin/Model/TestPluginPost.php:validation for field title#'; $pattern = preg_quote('#Plugin' . DS. 'TestPlugin' . DS. 'Model' . DS. 'TestPluginPost.php:validation for field title#', '\\');
$this->assertPattern($pattern, $result); $this->assertPattern($pattern, $result);
$pattern = '#Plugin/TestPlugin/Model/TestPluginPost.php:validation for field body#'; $pattern = preg_quote('#Plugin' . DS. 'TestPlugin' . DS. 'Model' . DS. 'TestPluginPost.php:validation for field body#', '\\');
$this->assertPattern($pattern, $result); $this->assertPattern($pattern, $result);
$pattern = '#msgid "Post title is required"#'; $pattern = '#msgid "Post title is required"#';
@ -369,10 +369,10 @@ class ExtractTaskTest extends CakeTestCase {
$this->Task->execute(); $this->Task->execute();
$result = file_get_contents($this->path . DS . 'test_plugin.pot'); $result = file_get_contents($this->path . DS . 'test_plugin.pot');
$pattern = '#Model/TestPluginPost.php:validation for field title#'; $pattern = preg_quote('#Model' . DS. 'TestPluginPost.php:validation for field title#', '\\');
$this->assertPattern($pattern, $result); $this->assertPattern($pattern, $result);
$pattern = '#Model/TestPluginPost.php:validation for field body#'; $pattern = preg_quote('#Model' . DS. 'TestPluginPost.php:validation for field body#', '\\');
$this->assertPattern($pattern, $result); $this->assertPattern($pattern, $result);
$pattern = '#msgid "Post title is required"#'; $pattern = '#msgid "Post title is required"#';

View file

@ -167,21 +167,21 @@ class ProjectTaskTest extends CakeTestCase {
$path = $this->Task->path . 'bake_test_app'; $path = $this->Task->path . 'bake_test_app';
$empty = array( $empty = array(
'Console' . DS . 'Command' . DS . 'Task', 'Console' . DS . 'Command' . DS . 'Task' => 'empty',
'Controller' . DS . 'Component', 'Controller' . DS . 'Component' => 'empty',
'Model' . DS . 'Behavior', 'Model' . DS . 'Behavior' => 'empty',
'View' . DS . 'Helper', 'View' . DS . 'Helper' => 'AppHelper.php',
'View' . DS . 'Errors', 'View' . DS . 'Errors' => 'empty',
'View' . DS . 'Scaffolds', 'View' . DS . 'Scaffolds' => 'empty',
'Test' . DS . 'Case' . DS . 'Model', 'Test' . DS . 'Case' . DS . 'Model' . DS . 'Behavior' => 'empty',
'Test' . DS . 'Case' . DS . 'Controller', 'Test' . DS . 'Case' . DS . 'Controller' . DS . 'Component' => 'empty',
'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper', 'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' => 'empty',
'Test' . DS . 'Fixture', 'Test' . DS . 'Fixture' => 'empty',
'webroot' . DS . 'js' 'webroot' . DS . 'js' => 'empty'
); );
foreach ($empty as $dir) { foreach ($empty as $dir => $file) {
$this->assertTrue(is_file($path . DS . $dir . DS . 'empty'), 'Missing empty file in ' . $dir); $this->assertTrue(is_file($path . DS . $dir . DS . $file), sprintf('Missing %s file in %s', $file, $dir));
} }
} }

View file

@ -129,6 +129,7 @@ class ShellDispatcherTest extends CakeTestCase {
* @return void * @return void
*/ */
public function tearDown() { public function tearDown() {
parent::tearDown();
CakePlugin::unload(); CakePlugin::unload();
} }
@ -399,6 +400,10 @@ class ShellDispatcherTest extends CakeTestCase {
$result = $Dispatcher->getShell('sample'); $result = $Dispatcher->getShell('sample');
$this->assertInstanceOf('SampleShell', $result); $this->assertInstanceOf('SampleShell', $result);
$Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('test_plugin.example');
$this->assertInstanceOf('ExampleShell', $result);
$Dispatcher = new TestShellDispatcher(); $Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('TestPlugin.example'); $result = $Dispatcher->getShell('TestPlugin.example');
$this->assertInstanceOf('ExampleShell', $result); $this->assertInstanceOf('ExampleShell', $result);

View file

@ -193,6 +193,21 @@ class RequestHandlerComponentTest extends CakeTestCase {
$this->assertEquals('json', $this->RequestHandler->ext); $this->assertEquals('json', $this->RequestHandler->ext);
} }
/**
* Test that RequestHandler sets $this->ext when jQuery sends its wonky-ish headers
* and the application is configured to handle multiplate extensions
*
* @return void
*/
public function testInitializeContentTypeWithjQueryAcceptAndMultiplesExtensions() {
$_SERVER['HTTP_ACCEPT'] = 'application/json, text/javascript, */*; q=0.01';
$this->assertNull($this->RequestHandler->ext);
Router::parseExtensions('rss', 'json');
$this->RequestHandler->initialize($this->Controller);
$this->assertEquals('json', $this->RequestHandler->ext);
}
/** /**
* Test that RequestHandler does not set $this->ext when multple accepts are sent. * Test that RequestHandler does not set $this->ext when multple accepts are sent.
* *

View file

@ -6009,6 +6009,23 @@ class FormHelperTest extends CakeTestCase {
$this->assertEquals(array('save'), $result, 'Only submits with name attributes should be unlocked.'); $this->assertEquals(array('save'), $result, 'Only submits with name attributes should be unlocked.');
} }
/**
* Test submit image with timestamps.
*
* @return void
*/
function testSubmitImageTimestamp() {
Configure::write('Asset.timestamp', 'force');
$result = $this->Form->submit('cake.power.gif');
$expected = array(
'div' => array('class' => 'submit'),
'input' => array('type' => 'image', 'src' => 'preg:/img\/cake\.power\.gif\?\d*/'),
'/div'
);
$this->assertTags($result, $expected);
}
/** /**
* test the create() method * test the create() method
* *

View file

@ -104,6 +104,11 @@ class TextHelperTest extends CakeTestCase {
$result = $this->Text->highlight($text, $phrases, array('format' => '<b>\1</b>')); $result = $this->Text->highlight($text, $phrases, array('format' => '<b>\1</b>'));
$this->assertEqual($result, $text); $this->assertEqual($result, $text);
$text = 'This is a (test) text';
$phrases = '(test';
$result = $this->Text->highlight($text, $phrases, array('format' => '<b>\1</b>'));
$this->assertEqual('This is a <b>(test</b>) text', $result);
$text = 'Ich saß in einem Café am Übergang'; $text = 'Ich saß in einem Café am Übergang';
$expected = 'Ich <b>saß</b> in einem <b>Café</b> am <b>Übergang</b>'; $expected = 'Ich <b>saß</b> in einem <b>Café</b> am <b>Übergang</b>';
$phrases = array('saß', 'café', 'übergang'); $phrases = array('saß', 'café', 'übergang');

View file

@ -20,11 +20,11 @@
<!--nocache--> <!--nocache-->
<span class="notice"> <span class="notice">
<?php <?php
echo __d('cake', 'Your tmp directory is '); echo __('Your tmp directory is ');
if (is_writable(TMP)): if (is_writable(TMP)):
echo __d('cake', 'writable.'); echo __('writable.');
else: else:
echo __d('cake', 'NOT writable.'); echo __('NOT writable.');
endif; endif;
?> ?>
</span> </span>
@ -33,12 +33,12 @@
<p> <p>
<span class="notice"> <span class="notice">
<?php <?php
echo __d('cake', 'Your cache is '); echo __('Your cache is ');
if (Cache::isInitialized('default')): if (Cache::isInitialized('default')):
echo __d('cake', 'set up and initialized properly.'); echo __('set up and initialized properly.');
$settings = Cache::settings(); $settings = Cache::settings();
echo '<p>' . $settings['engine']; echo '<p>' . $settings['engine'];
echo __d('cake', ' is being used to cache, to change this edit config/core.php '); echo __(' is being used to cache, to change this edit config/core.php ');
echo '</p>'; echo '</p>';
echo 'Settings: <ul>'; echo 'Settings: <ul>';
@ -48,10 +48,10 @@
echo '</ul>'; echo '</ul>';
else: else:
echo __d('cake', 'NOT working.'); echo __('NOT working.');
echo '<br />'; echo '<br />';
if (is_writable(TMP)): if (is_writable(TMP)):
echo __d('cake', 'Edit: config/core.php to insure you have the newset version of this file and the variable $cakeCache set properly'); echo __('Edit: config/core.php to insure you have the newset version of this file and the variable $cakeCache set properly');
endif; endif;
endif; endif;
?> ?>
@ -60,15 +60,15 @@
<p> <p>
<span class="notice"> <span class="notice">
<?php <?php
echo __d('cake', 'Your database configuration file is '); echo __('Your database configuration file is ');
$filePresent = null; $filePresent = null;
if (file_exists(APP . 'Config'.'database.php')): if (file_exists(APP . 'Config'.'database.php')):
echo __d('cake', 'present.'); echo __('present.');
$filePresent = true; $filePresent = true;
else: else:
echo __d('cake', 'NOT present.'); echo __('NOT present.');
echo '<br/>'; echo '<br/>';
echo __d('cake', 'Rename config/database.php.default to config/database.php'); echo __('Rename config/database.php.default to config/database.php');
endif; endif;
?> ?>
</span> </span>
@ -82,60 +82,60 @@ if (!empty($filePresent)):
?> ?>
<p> <p>
<span class="notice"> <span class="notice">
<?php echo __d('cake', 'Cake'); <?php echo __('Cake');
if ($connected->isConnected()): if ($connected->isConnected()):
__d('cake', ' is able to '); __(' is able to ');
else: else:
__d('cake', ' is NOT able to '); __(' is NOT able to ');
endif; endif;
__d('cake', 'connect to the database.'); __('connect to the database.');
?> ?>
</span> </span>
</p> </p>
<?php endif; ?> <?php endif; ?>
<h2><?php echo __d('cake', 'Release Notes for CakePHP %s.', Configure::version()); ?></h2> <h2><?php echo __('Release Notes for CakePHP %s.', Configure::version()); ?></h2>
<a href="https://trac.cakephp.org/wiki/notes/1.2.x.x"><?php echo __d('cake', 'Read the release notes and get the latest version'); ?> </a> <a href="https://trac.cakephp.org/wiki/notes/1.2.x.x"><?php echo __('Read the release notes and get the latest version'); ?> </a>
<h2><?php echo __d('cake', 'Editing this Page'); ?></h2> <h2><?php echo __('Editing this Page'); ?></h2>
<p> <p>
<?php echo __d('cake', 'To change the content of this page, create: /app/View/Pages/home.ctp.'); ?><br /> <?php echo __('To change the content of this page, create: /app/View/Pages/home.ctp.'); ?><br />
<?php echo __d('cake', 'To change its layout, create: /app/View/Layouts/default.ctp.'); ?><br /> <?php echo __('To change its layout, create: /app/View/Layouts/default.ctp.'); ?><br />
<a href="http://manual.cakephp.org/"><?php echo __d('cake', 'See the views section of the manual for more info.'); ?> </a><br /> <a href="http://manual.cakephp.org/"><?php echo __('See the views section of the manual for more info.'); ?> </a><br />
<?php echo __d('cake', 'You can also add some CSS styles for your pages at: app/webroot/css/.'); ?> <?php echo __('You can also add some CSS styles for your pages at: app/webroot/css/.'); ?>
</p> </p>
<h2><?php echo __d('cake', 'Getting Started'); ?></h2> <h2><?php echo __('Getting Started'); ?></h2>
<p> <p>
<a href="http://manual.cakephp.org/appendix/blog_tutorial"><?php echo __d('cake', 'The 15 min Blog Tutorial'); ?></a><br /> <a href="http://manual.cakephp.org/appendix/blog_tutorial"><?php echo __('The 15 min Blog Tutorial'); ?></a><br />
<a href="http://www-128.ibm.com/developerworks/edu/os-dw-os-php-cake1.html"><?php echo __d('cake', 'Cook up Web sites fast with CakePHP'); ?></a><br /> <a href="http://www-128.ibm.com/developerworks/edu/os-dw-os-php-cake1.html"><?php echo __('Cook up Web sites fast with CakePHP'); ?></a><br />
<a href="http://www-128.ibm.com/developerworks/edu/os-dw-os-php-wiki1.html"><?php echo __d('cake', 'Create an interactive production wiki using PHP'); ?></a> <a href="http://www-128.ibm.com/developerworks/edu/os-dw-os-php-wiki1.html"><?php echo __('Create an interactive production wiki using PHP'); ?></a>
</p> </p>
<h2><?php echo __d('cake', 'More about Cake'); ?></h2> <h2><?php echo __('More about Cake'); ?></h2>
<p> <p>
<?php echo __d('cake', 'CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC.'); ?> <?php echo __('CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC.'); ?>
</p> </p>
<p> <p>
<?php echo __d('cake', 'Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.'); ?> <?php echo __('Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.'); ?>
</p> </p>
<ul> <ul>
<li><a href="http://cakefoundation.org/"><?php echo __d('cake', 'Cake Software Foundation'); ?> </a> <li><a href="http://cakefoundation.org/"><?php echo __('Cake Software Foundation'); ?> </a>
<ul><li><?php echo __d('cake', 'Promoting development related to CakePHP'); ?></li></ul></li> <ul><li><?php echo __('Promoting development related to CakePHP'); ?></li></ul></li>
<li><a href="http://bakery.cakephp.org"><?php echo __d('cake', 'The Bakery'); ?> </a> <li><a href="http://bakery.cakephp.org"><?php echo __('The Bakery'); ?> </a>
<ul><li><?php echo __d('cake', 'Everything CakePHP'); ?></li></ul></li> <ul><li><?php echo __('Everything CakePHP'); ?></li></ul></li>
<li><a href="http://astore.amazon.com/cakesoftwaref-20/"><?php echo __d('cake', 'Book Store'); ?> </a> <li><a href="http://astore.amazon.com/cakesoftwaref-20/"><?php echo __('Book Store'); ?> </a>
<ul><li><?php echo __d('cake', 'Recommended Software Books'); ?></li></ul></li> <ul><li><?php echo __('Recommended Software Books'); ?></li></ul></li>
<li><a href="http://www.cafepress.com/cakefoundation"><?php echo __d('cake', 'CakeSchwag'); ?> </a> <li><a href="http://www.cafepress.com/cakefoundation"><?php echo __('CakeSchwag'); ?> </a>
<ul><li><?php echo __d('cake', 'Get your own CakePHP gear - Doughnate to Cake'); ?></li></ul></li> <ul><li><?php echo __('Get your own CakePHP gear - Doughnate to Cake'); ?></li></ul></li>
<li><a href="http://www.cakephp.org"><?php echo __d('cake', 'CakePHP'); ?> </a> <li><a href="http://www.cakephp.org"><?php echo __('CakePHP'); ?> </a>
<ul><li><?php echo __d('cake', 'The Rapid Development Framework'); ?></li></ul></li> <ul><li><?php echo __('The Rapid Development Framework'); ?></li></ul></li>
<li><a href="http://manual.cakephp.org"><?php echo __d('cake', 'CakePHP Manual'); ?> </a> <li><a href="http://manual.cakephp.org"><?php echo __('CakePHP Manual'); ?> </a>
<ul><li><?php echo __d('cake', 'Your Rapid Development Cookbook'); ?></li></ul></li> <ul><li><?php echo __('Your Rapid Development Cookbook'); ?></li></ul></li>
<li><a href="http://api.cakephp.org"><?php echo __d('cake', 'CakePHP API'); ?> </a> <li><a href="http://api.cakephp.org"><?php echo __('CakePHP API'); ?> </a>
<ul><li><?php echo __d('cake', 'Docblock Your Best Friend'); ?></li></ul></li> <ul><li><?php echo __('Docblock Your Best Friend'); ?></li></ul></li>
<li><a href="http://www.cakeforge.org"><?php echo __d('cake', 'CakeForge'); ?> </a> <li><a href="http://www.cakeforge.org"><?php echo __('CakeForge'); ?> </a>
<ul><li><?php echo __d('cake', 'Open Development for CakePHP'); ?></li></ul></li> <ul><li><?php echo __('Open Development for CakePHP'); ?></li></ul></li>
<li><a href="https://trac.cakephp.org/"><?php echo __d('cake', 'CakePHP Trac'); ?> </a> <li><a href="https://trac.cakephp.org/"><?php echo __('CakePHP Trac'); ?> </a>
<ul><li><?php echo __d('cake', 'For the Development of CakePHP (Tickets, SVN browser, Roadmap, Changelogs)'); ?></li></ul></li> <ul><li><?php echo __('For the Development of CakePHP (Tickets, SVN browser, Roadmap, Changelogs)'); ?></li></ul></li>
<li><a href="http://groups-beta.google.com/group/cake-php"><?php echo __d('cake', 'CakePHP Google Group'); ?> </a> <li><a href="http://groups-beta.google.com/group/cake-php"><?php echo __('CakePHP Google Group'); ?> </a>
<ul><li><?php echo __d('cake', 'Community mailing list'); ?></li></ul></li> <ul><li><?php echo __('Community mailing list'); ?></li></ul></li>
<li><a href="irc://irc.freenode.net/cakephp">irc.freenode.net #cakephp</a> <li><a href="irc://irc.freenode.net/cakephp">irc.freenode.net #cakephp</a>
<ul><li><?php echo __d('cake', 'Live chat about CakePHP'); ?></li></ul></li> <ul><li><?php echo __('Live chat about CakePHP'); ?></li></ul></li>
</ul> </ul>

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* A class to contain test cases and run them with shered fixtures * A class to contain test cases and run them with shared fixtures
* *
* PHP 5 * PHP 5
* *

View file

@ -204,7 +204,7 @@ class Debugger {
* @param integer $line Line that triggered the error * @param integer $line Line that triggered the error
* @param array $context Context * @param array $context Context
* @return boolean true if error was handled * @return boolean true if error was handled
* @deprecated This function is supersceeded by Debugger::outputError() * @deprecated This function is superseded by Debugger::outputError()
*/ */
public static function showError($code, $description, $file = null, $line = null, $context = null) { public static function showError($code, $description, $file = null, $line = null, $context = null) {
$_this = Debugger::getInstance(); $_this = Debugger::getInstance();

View file

@ -255,7 +255,7 @@ class String {
/** /**
* Cleans up a String::insert() formated string with given $options depending on the 'clean' key in * Cleans up a String::insert() formated string with given $options depending on the 'clean' key in
* $options. The default method used is text but html is also available. The goal of this function * $options. The default method used is text but html is also available. The goal of this function
* is to replace all whitespace and uneeded markup around placeholders that did not get replaced * is to replace all whitespace and unneeded markup around placeholders that did not get replaced
* by String::insert(). * by String::insert().
* *
* @param string $str * @param string $str

View file

@ -336,7 +336,7 @@ class Validation {
* @see Validation::date * @see Validation::date
* @see Validation::time * @see Validation::time
*/ */
public function datetime($check, $dateFormat = 'ymd', $regex = null) { public static function datetime($check, $dateFormat = 'ymd', $regex = null) {
$valid = false; $valid = false;
$parts = explode(' ', $check); $parts = explode(' ', $check);
if (!empty($parts) && count($parts) > 1) { if (!empty($parts) && count($parts) > 1) {
@ -522,7 +522,7 @@ class Validation {
* Valid Options * Valid Options
* *
* - in => provide a list of choices that selections must be made from * - in => provide a list of choices that selections must be made from
* - max => maximun number of non-zero choices that can be made * - max => maximum number of non-zero choices that can be made
* - min => minimum number of non-zero choices that can be made * - min => minimum number of non-zero choices that can be made
* *
* @param mixed $check Value to check * @param mixed $check Value to check
@ -556,7 +556,7 @@ class Validation {
* Checks if a value is numeric. * Checks if a value is numeric.
* *
* @param string $check Value to check * @param string $check Value to check
* @return boolean Succcess * @return boolean Success
*/ */
public static function numeric($check) { public static function numeric($check) {
return is_numeric($check); return is_numeric($check);
@ -715,7 +715,7 @@ class Validation {
* *
* @param string $check Value to check * @param string $check Value to check
* @param array $list List to check against * @param array $list List to check against
* @return boolean Succcess * @return boolean Success
*/ */
public static function inList($check, $list) { public static function inList($check, $list) {
return in_array($check, $list); return in_array($check, $list);

View file

@ -18,9 +18,9 @@
?> ?>
<h2><?php echo $name; ?></h2> <h2><?php echo $name; ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __d('cake', 'Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf( <?php printf(
__d('cake', 'The requested address %s was not found on this server.'), __('The requested address %s was not found on this server.'),
"<strong>'{$url}'</strong>" "<strong>'{$url}'</strong>"
); ?> ); ?>
</p> </p>

View file

@ -18,8 +18,8 @@
?> ?>
<h2><?php echo $name; ?></h2> <h2><?php echo $name; ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __d('cake', 'Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php echo __d('cake', 'An Internal Error Has Occurred.'); ?> <?php echo __('An Internal Error Has Occurred.'); ?>
</p> </p>
<?php <?php
if (Configure::read('debug') > 0 ): if (Configure::read('debug') > 0 ):

View file

@ -1638,6 +1638,7 @@ class FormHelper extends AppHelper {
} else { } else {
$url = $this->webroot(trim($caption, '/')); $url = $this->webroot(trim($caption, '/'));
} }
$url = $this->assetTimestamp($url);
$tag = $this->Html->useTag('submitimage', $url, $options); $tag = $this->Html->useTag('submitimage', $url, $options);
} else { } else {
$options['value'] = $caption; $options['value'] = $caption;

View file

@ -84,7 +84,7 @@ class NumberHelper extends AppHelper {
public function toReadableSize($size) { public function toReadableSize($size) {
switch (true) { switch (true) {
case $size < 1024: case $size < 1024:
return __dn('cake', '%d Byte', '%d Bytes', $size, $size); return __n('%d Byte', '%d Bytes', $size, $size);
case round($size / 1024) < 1024: case round($size / 1024) < 1024:
return __('%d KB', $this->precision($size / 1024, 0)); return __('%d KB', $this->precision($size / 1024, 0));
case round($size / 1024 / 1024, 2) < 1024: case round($size / 1024 / 1024, 2) < 1024:

View file

@ -77,7 +77,7 @@ class TextHelper extends AppHelper {
$with = array(); $with = array();
foreach ($phrase as $key => $segment) { foreach ($phrase as $key => $segment) {
$segment = "($segment)"; $segment = '(' . preg_quote($segment, '|') . ')';
if ($html) { if ($html) {
$segment = "(?![^<]+>)$segment(?![^<]+>)"; $segment = "(?![^<]+>)$segment(?![^<]+>)";
} }
@ -88,7 +88,7 @@ class TextHelper extends AppHelper {
return preg_replace($replace, $with, $text); return preg_replace($replace, $with, $text);
} else { } else {
$phrase = "($phrase)"; $phrase = '(' . preg_quote($phrase, '|') . ')';
if ($html) { if ($html) {
$phrase = "(?![^<]+>)$phrase(?![^<]+>)"; $phrase = "(?![^<]+>)$phrase(?![^<]+>)";
} }

View file

@ -80,19 +80,19 @@ class TimeHelper extends AppHelper {
protected function _translateSpecifier($specifier) { protected function _translateSpecifier($specifier) {
switch ($specifier[1]) { switch ($specifier[1]) {
case 'a': case 'a':
$abday = __dc('cake', 'abday', 5); $abday = __c('abday', 5);
if (is_array($abday)) { if (is_array($abday)) {
return $abday[date('w', $this->__time)]; return $abday[date('w', $this->__time)];
} }
break; break;
case 'A': case 'A':
$day = __dc('cake', 'day', 5); $day = __c('day', 5);
if (is_array($day)) { if (is_array($day)) {
return $day[date('w', $this->__time)]; return $day[date('w', $this->__time)];
} }
break; break;
case 'c': case 'c':
$format = __dc('cake', 'd_t_fmt', 5); $format = __c('d_t_fmt', 5);
if ($format != 'd_t_fmt') { if ($format != 'd_t_fmt') {
return $this->convertSpecifiers($format, $this->__time); return $this->convertSpecifiers($format, $this->__time);
} }
@ -114,13 +114,13 @@ class TimeHelper extends AppHelper {
return date('jS', $this->__time); return date('jS', $this->__time);
case 'b': case 'b':
case 'h': case 'h':
$months = __dc('cake', 'abmon', 5); $months = __c('abmon', 5);
if (is_array($months)) { if (is_array($months)) {
return $months[date('n', $this->__time) -1]; return $months[date('n', $this->__time) -1];
} }
return '%b'; return '%b';
case 'B': case 'B':
$months = __dc('cake', 'mon', 5); $months = __c('mon', 5);
if (is_array($months)) { if (is_array($months)) {
return $months[date('n', $this->__time) -1]; return $months[date('n', $this->__time) -1];
} }
@ -131,14 +131,14 @@ class TimeHelper extends AppHelper {
case 'P': case 'P':
$default = array('am' => 0, 'pm' => 1); $default = array('am' => 0, 'pm' => 1);
$meridiem = $default[date('a',$this->__time)]; $meridiem = $default[date('a',$this->__time)];
$format = __dc('cake', 'am_pm', 5); $format = __c('am_pm', 5);
if (is_array($format)) { if (is_array($format)) {
$meridiem = $format[$meridiem]; $meridiem = $format[$meridiem];
return ($specifier[1] == 'P') ? strtolower($meridiem) : strtoupper($meridiem); return ($specifier[1] == 'P') ? strtolower($meridiem) : strtoupper($meridiem);
} }
break; break;
case 'r': case 'r':
$complete = __dc('cake', 't_fmt_ampm', 5); $complete = __c('t_fmt_ampm', 5);
if ($complete != 't_fmt_ampm') { if ($complete != 't_fmt_ampm') {
return str_replace('%p',$this->_translateSpecifier(array('%p', 'p')),$complete); return str_replace('%p',$this->_translateSpecifier(array('%p', 'p')),$complete);
} }
@ -152,13 +152,13 @@ class TimeHelper extends AppHelper {
case 'u': case 'u':
return ($weekDay = date('w', $this->__time)) ? $weekDay : 7; return ($weekDay = date('w', $this->__time)) ? $weekDay : 7;
case 'x': case 'x':
$format = __dc('cake', 'd_fmt', 5); $format = __c('d_fmt', 5);
if ($format != 'd_fmt') { if ($format != 'd_fmt') {
return $this->convertSpecifiers($format, $this->__time); return $this->convertSpecifiers($format, $this->__time);
} }
break; break;
case 'X': case 'X':
$format = __dc('cake', 't_fmt', 5); $format = __c('t_fmt', 5);
if ($format != 't_fmt') { if ($format != 't_fmt') {
return $this->convertSpecifiers($format, $this->__time); return $this->convertSpecifiers($format, $this->__time);
} }
@ -613,33 +613,33 @@ class TimeHelper extends AppHelper {
} else { } else {
if ($years > 0) { if ($years > 0) {
// years and months and days // years and months and days
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d year', '%d years', $years, $years); $relativeDate .= ($relativeDate ? ', ' : '') . __n('%d year', '%d years', $years, $years);
$relativeDate .= $months > 0 ? ($relativeDate ? ', ' : '') . __dn('cake', '%d month', '%d months', $months, $months) : ''; $relativeDate .= $months > 0 ? ($relativeDate ? ', ' : '') . __n('%d month', '%d months', $months, $months) : '';
$relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . __dn('cake', '%d week', '%d weeks', $weeks, $weeks) : ''; $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . __n('%d week', '%d weeks', $weeks, $weeks) : '';
$relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . __dn('cake', '%d day', '%d days', $days, $days) : ''; $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . __n('%d day', '%d days', $days, $days) : '';
} elseif (abs($months) > 0) { } elseif (abs($months) > 0) {
// months, weeks and days // months, weeks and days
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d month', '%d months', $months, $months); $relativeDate .= ($relativeDate ? ', ' : '') . __n('%d month', '%d months', $months, $months);
$relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . __dn('cake', '%d week', '%d weeks', $weeks, $weeks) : ''; $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . __n('%d week', '%d weeks', $weeks, $weeks) : '';
$relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . __dn('cake', '%d day', '%d days', $days, $days) : ''; $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . __n('%d day', '%d days', $days, $days) : '';
} elseif (abs($weeks) > 0) { } elseif (abs($weeks) > 0) {
// weeks and days // weeks and days
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d week', '%d weeks', $weeks, $weeks); $relativeDate .= ($relativeDate ? ', ' : '') . __n('%d week', '%d weeks', $weeks, $weeks);
$relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . __dn('cake', '%d day', '%d days', $days, $days) : ''; $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . __n('%d day', '%d days', $days, $days) : '';
} elseif (abs($days) > 0) { } elseif (abs($days) > 0) {
// days and hours // days and hours
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d day', '%d days', $days, $days); $relativeDate .= ($relativeDate ? ', ' : '') . __n('%d day', '%d days', $days, $days);
$relativeDate .= $hours > 0 ? ($relativeDate ? ', ' : '') . __dn('cake', '%d hour', '%d hours', $hours, $hours) : ''; $relativeDate .= $hours > 0 ? ($relativeDate ? ', ' : '') . __n('%d hour', '%d hours', $hours, $hours) : '';
} elseif (abs($hours) > 0) { } elseif (abs($hours) > 0) {
// hours and minutes // hours and minutes
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d hour', '%d hours', $hours, $hours); $relativeDate .= ($relativeDate ? ', ' : '') . __n('%d hour', '%d hours', $hours, $hours);
$relativeDate .= $minutes > 0 ? ($relativeDate ? ', ' : '') . __dn('cake', '%d minute', '%d minutes', $minutes, $minutes) : ''; $relativeDate .= $minutes > 0 ? ($relativeDate ? ', ' : '') . __n('%d minute', '%d minutes', $minutes, $minutes) : '';
} elseif (abs($minutes) > 0) { } elseif (abs($minutes) > 0) {
// minutes only // minutes only
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d minute', '%d minutes', $minutes, $minutes); $relativeDate .= ($relativeDate ? ', ' : '') . __n('%d minute', '%d minutes', $minutes, $minutes);
} else { } else {
// seconds only // seconds only
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d second', '%d seconds', $seconds, $seconds); $relativeDate .= ($relativeDate ? ', ' : '') . __n('%d second', '%d seconds', $seconds, $seconds);
} }
if (!$backwards) { if (!$backwards) {

View file

@ -20,32 +20,32 @@
<?php <?php
echo $this->Form->create(); echo $this->Form->create();
echo $this->Form->inputs($scaffoldFields, array('created', 'modified', 'updated')); echo $this->Form->inputs($scaffoldFields, array('created', 'modified', 'updated'));
echo $this->Form->end(__d('cake', 'Submit')); echo $this->Form->end(__('Submit'));
?> ?>
</div> </div>
<div class="actions"> <div class="actions">
<h3><?php echo __d('cake', 'Actions'); ?></h3> <h3><?php echo __('Actions'); ?></h3>
<ul> <ul>
<?php if ($this->request->action != 'add'): ?> <?php if ($this->request->action != 'add'): ?>
<li><?php echo $this->Form->postLink( <li><?php echo $this->Form->postLink(
__d('cake', 'Delete'), __('Delete'),
array('action' => 'delete', $this->Form->value($modelClass . '.' . $primaryKey)), array('action' => 'delete', $this->Form->value($modelClass . '.' . $primaryKey)),
null, null,
__d('cake', 'Are you sure you want to delete # %s?', $this->Form->value($modelClass . '.' . $primaryKey))); __('Are you sure you want to delete # %s?', $this->Form->value($modelClass . '.' . $primaryKey)));
?></li> ?></li>
<?php endif;?> <?php endif;?>
<li><?php echo $this->Html->link(__d('cake', 'List') . ' ' . $pluralHumanName, array('action' => 'index'));?></li> <li><?php echo $this->Html->link(__('List') . ' ' . $pluralHumanName, array('action' => 'index'));?></li>
<?php <?php
$done = array(); $done = array();
foreach ($associations as $_type => $_data) { foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) { foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>" . $this->Html->link(__d('cake', 'List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "</li>\n";
echo "\t\t<li>" . $this->Html->link(__d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add')) . "</li>\n";
$done[] = $_details['controller']; $done[] = $_details['controller'];
} }
} }
} }
?> ?>
</ul> </ul>
</div> </div>

View file

@ -23,7 +23,7 @@
<?php foreach ($scaffoldFields as $_field):?> <?php foreach ($scaffoldFields as $_field):?>
<th><?php echo $this->Paginator->sort($_field);?></th> <th><?php echo $this->Paginator->sort($_field);?></th>
<?php endforeach;?> <?php endforeach;?>
<th><?php echo __d('cake', 'Actions');?></th> <th><?php echo __('Actions');?></th>
</tr> </tr>
<?php <?php
$i = 0; $i = 0;
@ -46,13 +46,13 @@ foreach (${$pluralVar} as ${$singularVar}):
} }
echo '<td class="actions">'; echo '<td class="actions">';
echo $this->Html->link(__d('cake', 'View'), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])); echo $this->Html->link(__('View'), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey]));
echo $this->Html->link(__d('cake', 'Edit'), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])); echo $this->Html->link(__('Edit'), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey]));
echo $this->Form->postLink( echo $this->Form->postLink(
__d('cake', 'Delete'), __('Delete'),
array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]),
null, null,
__d('cake', 'Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] __('Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey]
); );
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
@ -63,28 +63,28 @@ endforeach;
</table> </table>
<p><?php <p><?php
echo $this->Paginator->counter(array( echo $this->Paginator->counter(array(
'format' => __d('cake', 'Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
)); ));
?></p> ?></p>
<div class="paging"> <div class="paging">
<?php <?php
echo $this->Paginator->prev('< ' . __d('cake', 'previous'), array(), null, array('class' => 'prev disabled')); echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers(array('separator' => '')); echo $this->Paginator->numbers(array('separator' => ''));
echo $this->Paginator->next(__d('cake', 'next') .' >', array(), null, array('class' => 'next disabled')); echo $this->Paginator->next(__('next') .' >', array(), null, array('class' => 'next disabled'));
?> ?>
</div> </div>
</div> </div>
<div class="actions"> <div class="actions">
<h3><?php echo __d('cake', 'Actions'); ?></h3> <h3><?php echo __('Actions'); ?></h3>
<ul> <ul>
<li><?php echo $this->Html->link(__d('cake', 'New %s', $singularHumanName), array('action' => 'add')); ?></li> <li><?php echo $this->Html->link(__('New %s', $singularHumanName), array('action' => 'add')); ?></li>
<?php <?php
$done = array(); $done = array();
foreach ($associations as $_type => $_data) { foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) { foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "<li>" . $this->Html->link(__d('cake', 'List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>"; echo "<li>" . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>";
echo "<li>" . $this->Html->link(__d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>"; echo "<li>" . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>";
$done[] = $_details['controller']; $done[] = $_details['controller'];
} }
} }

View file

@ -17,7 +17,7 @@
*/ */
?> ?>
<div class="<?php echo $pluralVar;?> view"> <div class="<?php echo $pluralVar;?> view">
<h2><?php echo __d('cake', 'View %s', $singularHumanName); ?></h2> <h2><?php echo __('View %s', $singularHumanName); ?></h2>
<dl> <dl>
<?php <?php
$i = 0; $i = 0;
@ -42,20 +42,20 @@ foreach ($scaffoldFields as $_field) {
</dl> </dl>
</div> </div>
<div class="actions"> <div class="actions">
<h3><?php echo __d('cake', 'Actions'); ?></h3> <h3><?php echo __('Actions'); ?></h3>
<ul> <ul>
<?php <?php
echo "\t\t<li>" .$this->Html->link(__d('cake', 'Edit %s', $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n"; echo "\t\t<li>" .$this->Html->link(__('Edit %s', $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n";
echo "\t\t<li>" .$this->Html->link(__d('cake', 'Delete %s', $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __d('cake', 'Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). " </li>\n"; echo "\t\t<li>" .$this->Html->link(__('Delete %s', $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). " </li>\n";
echo "\t\t<li>" .$this->Html->link(__d('cake', 'List %s', $pluralHumanName), array('action' => 'index')). " </li>\n"; echo "\t\t<li>" .$this->Html->link(__('List %s', $pluralHumanName), array('action' => 'index')). " </li>\n";
echo "\t\t<li>" .$this->Html->link(__d('cake', 'New %s', $singularHumanName), array('action' => 'add')). " </li>\n"; echo "\t\t<li>" .$this->Html->link(__('New %s', $singularHumanName), array('action' => 'add')). " </li>\n";
$done = array(); $done = array();
foreach ($associations as $_type => $_data) { foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) { foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>" . $this->Html->link(__d('cake', 'List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n";
echo "\t\t<li>" . $this->Html->link(__d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n";
$done[] = $_details['controller']; $done[] = $_details['controller'];
} }
} }
@ -67,7 +67,7 @@ foreach ($scaffoldFields as $_field) {
if (!empty($associations['hasOne'])) : if (!empty($associations['hasOne'])) :
foreach ($associations['hasOne'] as $_alias => $_details): ?> foreach ($associations['hasOne'] as $_alias => $_details): ?>
<div class="related"> <div class="related">
<h3><?php echo __d('cake', "Related %s", Inflector::humanize($_details['controller'])); ?></h3> <h3><?php echo __("Related %s", Inflector::humanize($_details['controller'])); ?></h3>
<?php if (!empty(${$singularVar}[$_alias])):?> <?php if (!empty(${$singularVar}[$_alias])):?>
<dl> <dl>
<?php <?php
@ -82,7 +82,7 @@ foreach ($associations['hasOne'] as $_alias => $_details): ?>
<?php endif; ?> <?php endif; ?>
<div class="actions"> <div class="actions">
<ul> <ul>
<li><?php echo $this->Html->link(__d('cake', 'Edit %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?> <li><?php echo $this->Html->link(__('Edit %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?>
</ul> </ul>
</div> </div>
</div> </div>
@ -102,7 +102,7 @@ foreach ($relations as $_alias => $_details):
$otherSingularVar = Inflector::variable($_alias); $otherSingularVar = Inflector::variable($_alias);
?> ?>
<div class="related"> <div class="related">
<h3><?php echo __d('cake', "Related %s", Inflector::humanize($_details['controller'])); ?></h3> <h3><?php echo __("Related %s", Inflector::humanize($_details['controller'])); ?></h3>
<?php if (!empty(${$singularVar}[$_alias])):?> <?php if (!empty(${$singularVar}[$_alias])):?>
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr>
@ -128,9 +128,9 @@ $otherSingularVar = Inflector::variable($_alias);
} }
echo "\t\t\t<td class=\"actions\">\n"; echo "\t\t\t<td class=\"actions\">\n";
echo "\t\t\t\t" . $this->Html->link(__d('cake', 'View'), array('controller' => $_details['controller'], 'action' => 'view', ${$otherSingularVar}[$_details['primaryKey']])). "\n"; echo "\t\t\t\t" . $this->Html->link(__('View'), array('controller' => $_details['controller'], 'action' => 'view', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
echo "\t\t\t\t" . $this->Html->link(__d('cake', 'Edit'), array('controller' => $_details['controller'], 'action' => 'edit', ${$otherSingularVar}[$_details['primaryKey']])). "\n"; echo "\t\t\t\t" . $this->Html->link(__('Edit'), array('controller' => $_details['controller'], 'action' => 'edit', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
echo "\t\t\t\t" . $this->Html->link(__d('cake', 'Delete'), array('controller' => $_details['controller'], 'action' => 'delete', ${$otherSingularVar}[$_details['primaryKey']]), null, __d('cake', 'Are you sure you want to delete', true).' #' . ${$otherSingularVar}[$_details['primaryKey']] . '?'). "\n"; echo "\t\t\t\t" . $this->Html->link(__('Delete'), array('controller' => $_details['controller'], 'action' => 'delete', ${$otherSingularVar}[$_details['primaryKey']]), null, __('Are you sure you want to delete', true).' #' . ${$otherSingularVar}[$_details['primaryKey']] . '?'). "\n";
echo "\t\t\t</td>\n"; echo "\t\t\t</td>\n";
echo "\t\t</tr>\n"; echo "\t\t</tr>\n";
endforeach; endforeach;
@ -139,7 +139,7 @@ $otherSingularVar = Inflector::variable($_alias);
<?php endif; ?> <?php endif; ?>
<div class="actions"> <div class="actions">
<ul> <ul>
<li><?php echo $this->Html->link(__d('cake', "New %s", Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'));?> </li> <li><?php echo $this->Html->link(__("New %s", Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'));?> </li>
</ul> </ul>
</div> </div>
</div> </div>