mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Merge branch '1.3' into merger
Conflicts: cake/console/templates/default/views/index.ctp cake/libs/cache.php cake/libs/cake_log.php cake/libs/cake_socket.php cake/libs/view/helpers/form.php cake/libs/view/helpers/js.php cake/tests/cases/libs/view/helpers/js.test.php cake/tests/lib/reporter/cake_cli_reporter.php
This commit is contained in:
commit
4118477c0a
9 changed files with 94 additions and 15 deletions
|
@ -19,7 +19,7 @@
|
|||
<div class="<?php echo $pluralVar;?> form">
|
||||
<?php echo "<?php echo \$this->Form->create('{$modelClass}');?>\n";?>
|
||||
<fieldset>
|
||||
<legend><?php printf("<?php __('%s %s'); ?>", Inflector::humanize($action), $singularHumanName); ?></legend>
|
||||
<legend><?php printf("<?php __('%s %s'); ?>", Inflector::humanize($action), $singularHumanName); ?></legend>
|
||||
<?php
|
||||
echo "\t<?php\n";
|
||||
foreach ($fields as $field) {
|
||||
|
|
|
@ -89,6 +89,21 @@ class Cache {
|
|||
* Fast reads/writes, and benefits from memcache being distributed.
|
||||
* - `XcacheEngine` - Uses the Xcache extension, an alternative to APC.
|
||||
*
|
||||
* The following keys are used in core cache engines:
|
||||
*
|
||||
* - `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
|
||||
* with either another cache config or annother application.
|
||||
* - `probability` Probability of hitting a cache gc cleanup. Setting to 0 will disable
|
||||
* cache::gc from ever being called automatically.
|
||||
* - `servers' Used by memcache. Give the address of the memcached servers to use.
|
||||
* - `compress` Used by memcache. Enables memcache's compressed format.
|
||||
* - `serialize` Used by FileCache. Should cache objects be serialized first.
|
||||
* - `path` Used by FileCache. Path to where cachefiles should be saved.
|
||||
* - `lock` Used by FileCache. Should files be locked before writing to them?
|
||||
* - `user` Used by Xcache. Username for XCache
|
||||
* - `password` Used by Xcache. Password for XCache
|
||||
*
|
||||
* @see app/config/core.php for configuration settings
|
||||
* @param string $name Name of the configuration
|
||||
* @param array $settings Optional associative array of settings passed to the engine
|
||||
|
@ -144,7 +159,7 @@ class Cache {
|
|||
}
|
||||
self::$_engines[$name] = new $cacheClass();
|
||||
if (self::$_engines[$name]->init($config)) {
|
||||
if (time() % self::$_engines[$name]->settings['probability'] === 0) {
|
||||
if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) {
|
||||
self::$_engines[$name]->gc();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -219,4 +219,4 @@ class CakeLog {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -117,7 +117,7 @@ class CakeSocket {
|
|||
}
|
||||
|
||||
if (!empty($errNum) || !empty($errStr)) {
|
||||
$this->setLastError($errStr, $errNum);
|
||||
$this->setLastError($errNum, $errStr);
|
||||
throw new SocketException($errStr, $errNum);
|
||||
}
|
||||
|
||||
|
|
|
@ -364,10 +364,6 @@ class FormHelper extends AppHelper {
|
|||
unset($options['label']);
|
||||
}
|
||||
$submitOptions = $options;
|
||||
|
||||
if (!$submit) {
|
||||
$submit = __('Submit');
|
||||
}
|
||||
}
|
||||
$out .= $this->submit($submit, $submitOptions);
|
||||
}
|
||||
|
@ -1364,7 +1360,7 @@ class FormHelper extends AppHelper {
|
|||
* @link http://book.cakephp.org/view/1431/submit
|
||||
*/
|
||||
public function submit($caption = null, $options = array()) {
|
||||
if (!$caption) {
|
||||
if (!is_string($caption) && empty($caption)) {
|
||||
$caption = __('Submit');
|
||||
}
|
||||
$out = null;
|
||||
|
@ -1469,7 +1465,7 @@ class FormHelper extends AppHelper {
|
|||
$style = null;
|
||||
$tag = null;
|
||||
$attributes += array(
|
||||
'class' => null,
|
||||
'class' => null,
|
||||
'escape' => true,
|
||||
'secure' => null,
|
||||
'empty' => '',
|
||||
|
@ -2090,6 +2086,8 @@ class FormHelper extends AppHelper {
|
|||
|
||||
if (empty($attributes['class'])) {
|
||||
$attributes['class'] = 'checkbox';
|
||||
} elseif ($attributes['class'] === 'form-error') {
|
||||
$attributes['class'] = 'checkbox ' . $attributes['class'];
|
||||
}
|
||||
$label = $this->label(null, $title, $label);
|
||||
$item = $this->Html->useTag('checkboxmultiple', $name, $htmlOptions);
|
||||
|
@ -2224,7 +2222,7 @@ class FormHelper extends AppHelper {
|
|||
} else {
|
||||
$secure = (isset($this->request['_Token']) && !empty($this->request['_Token']));
|
||||
}
|
||||
|
||||
|
||||
$fieldName = null;
|
||||
if ($secure && !empty($options['name'])) {
|
||||
preg_match_all('/\[(.*?)\]/', $options['name'], $matches);
|
||||
|
|
|
@ -404,7 +404,10 @@ class JsHelper extends AppHelper {
|
|||
* @return array Array of js options and Htmloptions
|
||||
*/
|
||||
protected function _getHtmlOptions($options, $additional = array()) {
|
||||
$htmlKeys = array_merge(array('class', 'id', 'escape', 'onblur', 'onfocus', 'rel', 'title'), $additional);
|
||||
$htmlKeys = array_merge(
|
||||
array('class', 'id', 'escape', 'onblur', 'onfocus', 'rel', 'title', 'style'),
|
||||
$additional
|
||||
);
|
||||
$htmlOptions = array();
|
||||
foreach ($htmlKeys as $key) {
|
||||
if (isset($options[$key])) {
|
||||
|
|
|
@ -2972,7 +2972,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'published' => 'Y',
|
||||
'user_id' => 1
|
||||
))
|
||||
), array('validate' => 'only'));
|
||||
), array('validate' => 'first'));
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3633,6 +3633,42 @@ class FormHelperTest extends CakeTestCase {
|
|||
'label' => false
|
||||
));
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Form->validationErrors['Model']['tags'] = 'Select atleast one option';
|
||||
$result = $this->Form->input('Model.tags', array(
|
||||
'options' => array('one'),
|
||||
'multiple' => 'checkbox',
|
||||
'label' => false,
|
||||
'div' => false
|
||||
));
|
||||
$expected = array(
|
||||
'input' => array('type' => 'hidden', 'name' => 'data[Model][tags]', 'value' => '', 'id' => 'ModelTags'),
|
||||
array('div' => array('class' => 'checkbox form-error')),
|
||||
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][tags][]', 'value' => '0', 'id' => 'ModelTags0')),
|
||||
array('label' => array('for' => 'ModelTags0')),
|
||||
'one',
|
||||
'/label',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('Model.tags', array(
|
||||
'options' => array('one'),
|
||||
'multiple' => 'checkbox',
|
||||
'class' => 'mycheckbox',
|
||||
'label' => false,
|
||||
'div' => false
|
||||
));
|
||||
$expected = array(
|
||||
'input' => array('type' => 'hidden', 'name' => 'data[Model][tags]', 'value' => '', 'id' => 'ModelTags'),
|
||||
array('div' => array('class' => 'mycheckbox form-error')),
|
||||
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][tags][]', 'value' => '0', 'id' => 'ModelTags0')),
|
||||
array('label' => array('for' => 'ModelTags0')),
|
||||
'one',
|
||||
'/label',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5367,6 +5403,14 @@ class FormHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testSubmitButton() {
|
||||
$result = $this->Form->submit('');
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
'input' => array('type' => 'submit', 'value' => ''),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->submit('Test Submit');
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
|
@ -6482,6 +6526,24 @@ class FormHelperTest extends CakeTestCase {
|
|||
function testFormEnd() {
|
||||
$this->assertEqual($this->Form->end(), '</form>');
|
||||
|
||||
$result = $this->Form->end('');
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
'input' => array('type' => 'submit', 'value' => ''),
|
||||
'/div',
|
||||
'/form'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->end(array('label' => ''));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
'input' => array('type' => 'submit', 'value' => ''),
|
||||
'/div',
|
||||
'/form'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->end('save');
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
|
|
|
@ -483,7 +483,7 @@ class JsHelperTest extends CakeTestCase {
|
|||
function testSubmitWithMock() {
|
||||
$this->_useMock();
|
||||
|
||||
$options = array('update' => '#content', 'id' => 'test-submit');
|
||||
$options = array('update' => '#content', 'id' => 'test-submit', 'style' => 'margin: 0');
|
||||
|
||||
$this->Js->TestJsEngine->expects($this->at(0))
|
||||
->method('get');
|
||||
|
@ -508,7 +508,7 @@ class JsHelperTest extends CakeTestCase {
|
|||
$result = $this->Js->submit('Save', $options);
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save'),
|
||||
'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save', 'style' => 'margin: 0'),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
|
Loading…
Add table
Reference in a new issue