Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.0' into 2.0-class-loading
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 2, 2011
2 parents ba694c4 + e384195 commit 42b3f99
Show file tree
Hide file tree
Showing 24 changed files with 179 additions and 53 deletions.
1 change: 0 additions & 1 deletion lib/Cake/Console/cake.php
Expand Up @@ -22,4 +22,3 @@
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'ShellDispatcher.php');

return ShellDispatcher::run($argv);

3 changes: 3 additions & 0 deletions lib/Cake/Controller/Component/CookieComponent.php
Expand Up @@ -172,6 +172,9 @@ class CookieComponent extends Component {
public function __construct(ComponentCollection $collection, $settings = array()) {
$this->key = Configure::read('Security.salt');
parent::__construct($collection, $settings);
if (isset($this->time)) {
$this->_expire($this->time);
}
}

/**
Expand Down
10 changes: 3 additions & 7 deletions lib/Cake/Controller/Component/EmailComponent.php
Expand Up @@ -566,11 +566,7 @@ function _createHeader() {
$headers = array();

if ($this->delivery == 'smtp') {
if (is_array($this->to)) {
$headers['To'] = implode(', ', array_map(array($this, '_formatAddress'), $this->to));
} else {
$headers['To'] = $this->_formatAddress($this->to);
}
$headers['To'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->to));
}
$headers['From'] = $this->_formatAddress($this->from);

Expand All @@ -585,11 +581,11 @@ function _createHeader() {
}

if (!empty($this->cc)) {
$headers['cc'] = implode(', ', array_map(array($this, '_formatAddress'), $this->cc));
$headers['Cc'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->cc));
}

if (!empty($this->bcc) && $this->delivery != 'smtp') {
$headers['Bcc'] = implode(', ', array_map(array($this, '_formatAddress'), $this->bcc));
$headers['Bcc'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->bcc));
}
if ($this->delivery == 'smtp') {
$headers['Subject'] = $this->_encode($this->subject);
Expand Down
6 changes: 4 additions & 2 deletions lib/Cake/I18n/I18n.php
Expand Up @@ -319,8 +319,10 @@ private function __bindTextDomain($domain) {
$this->__domains[$domain][$this->__lang][$this->category] = array();
return $domain;
}

if ($head = $this->__domains[$domain][$this->__lang][$this->category][""]) {

if (isset($this->__domains[$domain][$this->__lang][$this->category][""])) {
$head = $this->__domains[$domain][$this->__lang][$this->category][""];

foreach (explode("\n", $head) as $line) {
$header = strtok($line,":");
$line = trim(strtok("\n"));
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Behavior/AclBehavior.php
Expand Up @@ -87,7 +87,7 @@ public function afterSave($model, $created) {
}
$data = array(
'parent_id' => isset($parent[0][$type]['id']) ? $parent[0][$type]['id'] : null,
'model' => $model->alias,
'model' => $model->name,
'foreign_key' => $model->id
);
if (!$created) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Routing/Router.php
Expand Up @@ -845,7 +845,7 @@ public static function url($url = null, $full = false) {
} elseif (isset($url[$prefix]) && !$url[$prefix]) {
unset($url[$prefix]);
}
if (isset($url[$prefix]) && strpos($url['action'], $prefix) === 0) {
if (isset($url[$prefix]) && strpos($url['action'], $prefix . '_') === 0) {
$url['action'] = substr($url['action'], strlen($prefix) + 1);
}
}
Expand Down
3 changes: 3 additions & 0 deletions lib/Cake/TestSuite/Fixture/CakeTestFixture.php
Expand Up @@ -158,6 +158,9 @@ public function create(&$db) {
* @return boolean True on success, false on failure
*/
public function drop(&$db) {
if (empty($this->fields)) {
return false;
}
$this->Schema->build(array($this->table => $this->fields));
return (
$db->execute($db->dropSchema($this->Schema), array('log' => false)) !== false
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper.php
Expand Up @@ -688,7 +688,7 @@ public function value($options = array(), $field = null, $key = 'value') {
}

$habtmKey = $this->field();
if (empty($result) && isset($data[$habtmKey][$habtmKey])) {
if (empty($result) && isset($data[$habtmKey][$habtmKey]) && is_array($data[$habtmKey])) {
$result = $data[$habtmKey][$habtmKey];
} elseif (empty($result) && isset($data[$habtmKey]) && is_array($data[$habtmKey])) {
if (ClassRegistry::isKeySet($habtmKey)) {
Expand Down
8 changes: 6 additions & 2 deletions lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -240,8 +240,12 @@ function create($model = null, $options = array()) {
$options);
$this->_inputDefaults = $options['inputDefaults'];
unset($options['inputDefaults']);

if (empty($options['url']) || is_array($options['url'])) {
if ($options['action'] === null && $options['url'] === null) {
$options['action'] = $this->request->here;
if (!isset($options['id'])) {
$options['id'] = $this->domId($this->request['action'] . 'Form');
}
} elseif (empty($options['url']) || is_array($options['url'])) {
if (empty($options['url']['controller'])) {
if (!empty($model) && $model != $this->defaultModel) {
$options['url']['controller'] = Inflector::underscore(Inflector::pluralize($model));
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper/JqueryEngineHelper.php
Expand Up @@ -265,7 +265,7 @@ function request($url, $options = array()) {
unset($options['update']);
}
$callbacks = array('success', 'error', 'beforeSend', 'complete');
if (isset($options['dataExpression'])) {
if (!empty($options['dataExpression'])) {
$callbacks[] = 'data';
unset($options['dataExpression']);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper/MootoolsEngineHelper.php
Expand Up @@ -252,7 +252,7 @@ function request($url, $options = array()) {
}
$options['url'] = $url;
$options = $this->_prepareCallbacks('request', $options);
if (isset($options['dataExpression'])) {
if (!empty($options['dataExpression'])) {
$callbacks[] = 'data';
unset($options['dataExpression']);
} elseif (!empty($data)) {
Expand Down
38 changes: 22 additions & 16 deletions lib/Cake/View/Helper/NumberHelper.php
Expand Up @@ -40,16 +40,16 @@ class NumberHelper extends AppHelper {
*/
protected $_currencies = array(
'USD' => array(
'before' => '$', 'after' => 'c', 'zero' => 0, 'places' => 2, 'thousands' => ',',
'decimals' => '.', 'negative' => '()', 'escape' => true
'wholeSymbol' => '$', 'wholePosition' => 'before', 'fractionSymbol' => 'c', 'fractionPosition' => 'after',
'zero' => 0, 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()', 'escape' => true
),
'GBP' => array(
'before'=>'£', 'after' => 'p', 'zero' => 0, 'places' => 2, 'thousands' => ',',
'decimals' => '.', 'negative' => '()','escape' => false
'wholeSymbol'=>'£', 'wholePosition' => 'before', 'fractionSymbol' => 'p', 'fractionPosition' => 'after',
'zero' => 0, 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()','escape' => false
),
'EUR' => array(
'before'=>'€', 'after' => false, 'zero' => 0, 'places' => 2, 'thousands' => '.',
'decimals' => ',', 'negative' => '()', 'escape' => false
'wholeSymbol'=>'€', 'wholePosition' => 'before', 'fractionSymbol' => false, 'fractionPosition' => 'after',
'zero' => 0, 'places' => 2, 'thousands' => '.', 'decimals' => ',', 'negative' => '()', 'escape' => false
)
);

Expand All @@ -60,8 +60,8 @@ class NumberHelper extends AppHelper {
* @access protected
*/
protected $_currencyDefaults = array(
'before'=>'', 'after' => '', 'zero' => '0', 'places' => 2, 'thousands' => ',',
'decimals' => '.','negative' => '()', 'escape' => true
'wholeSymbol'=>'', 'wholePosition' => 'before', 'fractionSymbol' => '', 'fractionPosition' => 'after',
'zero' => '0', 'places' => 2, 'thousands' => ',', 'decimals' => '.','negative' => '()', 'escape' => true
);

/**
Expand Down Expand Up @@ -192,26 +192,32 @@ public function currency($number, $currency = 'USD', $options = array()) {

$options = array_merge($default, $options);

$result = null;
if (isset($options['before']) && $options['before'] !== '') {
$options['wholeSymbol'] = $options['before'];
}
if (isset($options['after']) && !$options['after'] !== '') {
$options['fractionSymbol'] = $options['after'];
}

$result = $options['before'] = $options['after'] = null;

$symbolKey = 'whole';
if ($number == 0 ) {
if ($options['zero'] !== 0 ) {
return $options['zero'];
}
$options['after'] = null;
} elseif ($number < 1 && $number > -1 ) {
if ($options['after'] !== false) {
if ($options['fractionSymbol'] !== false) {
$multiply = intval('1' . str_pad('', $options['places'], '0'));
$number = $number * $multiply;
$options['before'] = null;
$options['places'] = null;
$symbolKey = 'fraction';
}
} elseif (empty($options['before'])) {
$options['before'] = null;
} else {
$options['after'] = null;
}

$position = $options[$symbolKey.'Position'] != 'after' ? 'before' : 'after';
$options[$position] = $options[$symbolKey.'Symbol'];

$abs = abs($number);
$result = $this->format($abs, $options);

Expand Down
15 changes: 10 additions & 5 deletions lib/Cake/View/Helper/PrototypeEngineHelper.php
Expand Up @@ -45,10 +45,8 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
'error' => 'onFailure'
),
'sortable' => array(
'start' => 'onStart',
'sort' => 'onChange',
'complete' => 'onUpdate',
'distance' => 'snap',
),
'drag' => array(
'snapGrid' => 'snap',
Expand Down Expand Up @@ -243,7 +241,7 @@ public function request($url, $options = array()) {
}
$safe = array_keys($this->_callbackArguments['request']);
$options = $this->_prepareCallbacks('request', $options, $safe);
if (isset($options['dataExpression'])) {
if (!empty($options['dataExpression'])) {
$safe[] = 'parameters';
unset($options['dataExpression']);
}
Expand All @@ -259,6 +257,9 @@ public function request($url, $options = array()) {
*
* #### Note: Requires scriptaculous to be loaded.
*
* The scriptaculous implementation of sortables does not suppot the 'start'
* and 'distance' options.
*
* @param array $options Array of options for the sortable.
* @return string Completed sortable script.
* @access public
Expand Down Expand Up @@ -327,10 +328,14 @@ function slider($options = array()) {
unset($options['handle']);

if (isset($options['min']) && isset($options['max'])) {
$options['range'] = array($options['min'], $options['max']);
$options['range'] = sprintf('$R(%s,%s)', $options['min'], $options['max']);
unset($options['min'], $options['max']);
}
$optionString = $this->_processOptions('slider', $options);
$options = $this->_mapOptions('slider', $options);
$options = $this->_prepareCallbacks('slider', $options);
$optionString = $this->_parseOptions(
$options, array_merge(array_keys($this->_callbackArguments['slider']), array('range'))
);
if (!empty($optionString)) {
$optionString = ', {' . $optionString . '}';
}
Expand Down
9 changes: 9 additions & 0 deletions lib/Cake/View/Helper/TimeHelper.php
Expand Up @@ -103,6 +103,15 @@ private function __translateSpecifier($specifier) {
return sprintf("%02d", date('Y', $this->__time) / 100);
case 'D':
return '%m/%d/%y';
case 'e':
if (DS === '/') {
return '%e';
}
$day = date('j', $this->__time);
if ($day < 10) {
$day = ' ' . $day;
}
return $day;
case 'eS' :
return date('jS', $this->__time);
case 'b':
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/elements/email/html/default.ctp
Expand Up @@ -20,6 +20,6 @@
$content = explode("\n", $content);

foreach ($content as $line):
echo '<p> ' . $line . '</p>';
echo '<p> ' . $line . "</p>\n";
endforeach;
?>
2 changes: 1 addition & 1 deletion lib/Cake/tests/cases/libs/cache.test.php
Expand Up @@ -401,6 +401,6 @@ function testSetOnAlternateConfigs() {
$settings = Cache::settings('file_config');

$this->assertEquals('test_file_', $settings['prefix']);
$this->assertEquals(31536000, $settings['duration']);
$this->assertEquals(strtotime('+1 year') - time(), $settings['duration']);
}
}
4 changes: 4 additions & 0 deletions lib/Cake/tests/cases/libs/cake_test_fixture.test.php
Expand Up @@ -389,6 +389,10 @@ function testDrop() {

$return = $Fixture->drop($this->criticDb);
$this->assertFalse($return);

unset($Fixture->fields);
$return = $Fixture->drop($this->criticDb);
$this->assertFalse($return);
}

/**
Expand Down
Expand Up @@ -745,6 +745,8 @@ function testSmtpSendSocket() {
function testSendDebug() {
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->cc = 'cc@example.com';
$this->Controller->EmailTest->bcc = 'bcc@example.com';
$this->Controller->EmailTest->subject = 'Cake Debug Test';
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
$this->Controller->EmailTest->template = null;
Expand All @@ -757,6 +759,8 @@ function testSendDebug() {
$this->assertPattern('/Subject: Cake Debug Test\n/', $result);
$this->assertPattern('/Reply-To: noreply@example.com\n/', $result);
$this->assertPattern('/From: noreply@example.com\n/', $result);
$this->assertPattern('/Cc: cc@example.com\n/', $result);
$this->assertPattern('/Bcc: bcc@example.com\n/', $result);
$this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result);
$this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result);
$this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result);
Expand Down
11 changes: 6 additions & 5 deletions lib/Cake/tests/cases/libs/model/model_validation.test.php
Expand Up @@ -129,13 +129,14 @@ function testInvalidFieldsWithFieldListParams() {
$TestModel = new ValidationTest1();
$TestModel->validate = $validate = array(
'title' => array(
'rule' => 'customValidator',
'rule' => 'alphaNumeric',
'required' => true
),
'name' => array(
'rule' => 'allowEmpty',
'rule' => 'alphaNumeric',
'required' => true
));
$TestModel->set(array('title' => '$$', 'name' => '##'));
$TestModel->invalidFields(array('fieldList' => array('title')));
$expected = array(
'title' => 'This field cannot be left blank'
Expand Down Expand Up @@ -173,9 +174,9 @@ function testInvalidFieldsWithFieldListParams() {
*/
function testInvalidFieldsWhitelist() {
$TestModel = new ValidationTest1();
$TestModel->validate = $validate = array(
$TestModel->validate = array(
'title' => array(
'rule' => 'customValidator',
'rule' => 'alphaNumeric',
'required' => true
),
'name' => array(
Expand All @@ -184,7 +185,7 @@ function testInvalidFieldsWhitelist() {
));

$TestModel->whitelist = array('name');
$TestModel->save(array('name' => '#$$#'));
$TestModel->save(array('name' => '#$$#', 'title' => '$$$$'));

$expected = array('name' => 'This field cannot be left blank');
$this->assertEqual($TestModel->validationErrors, $expected);
Expand Down
4 changes: 4 additions & 0 deletions lib/Cake/tests/cases/libs/router.test.php
Expand Up @@ -1596,6 +1596,10 @@ function testUrlGenerationWithAutoPrefixes() {
$result = Router::url(array('action' => 'protected_edit', 1, 'protected' => true));
$expected = '/protected/images/edit/1';
$this->assertEqual($result, $expected);

$result = Router::url(array('action' => 'protectededit', 1, 'protected' => true));
$expected = '/protected/images/protectededit/1';
$this->assertEqual($result, $expected);

$result = Router::url(array('action' => 'edit', 1, 'protected' => true));
$expected = '/protected/images/edit/1';
Expand Down

0 comments on commit 42b3f99

Please sign in to comment.