mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 20:46:24 +00:00
Merge branch 'master' into 2.4
This commit is contained in:
commit
8ff59586f6
5 changed files with 117 additions and 10 deletions
|
@ -24,6 +24,7 @@
|
||||||
if (!defined('DS')) {
|
if (!defined('DS')) {
|
||||||
define('DS', DIRECTORY_SEPARATOR);
|
define('DS', DIRECTORY_SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These defines should only be edited if you have cake installed in
|
* These defines should only be edited if you have cake installed in
|
||||||
* a directory layout other than the way it is distributed.
|
* a directory layout other than the way it is distributed.
|
||||||
|
@ -72,6 +73,9 @@ if (!defined('WWW_ROOT')) {
|
||||||
|
|
||||||
// for built-in server
|
// for built-in server
|
||||||
if (php_sapi_name() == 'cli-server') {
|
if (php_sapi_name() == 'cli-server') {
|
||||||
|
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['REQUEST_URI'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
|
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,5 +97,6 @@ if (!empty($failed)) {
|
||||||
|
|
||||||
App::uses('Dispatcher', 'Routing');
|
App::uses('Dispatcher', 'Routing');
|
||||||
|
|
||||||
|
|
||||||
$Dispatcher = new Dispatcher();
|
$Dispatcher = new Dispatcher();
|
||||||
$Dispatcher->dispatch(new CakeRequest(), new CakeResponse());
|
$Dispatcher->dispatch(new CakeRequest(), new CakeResponse());
|
||||||
|
|
|
@ -125,10 +125,11 @@ class ServerShell extends AppShell {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$command = sprintf("php -S %s:%d -t %s",
|
$command = sprintf("php -S %s:%d -t %s %s",
|
||||||
$this->_host,
|
$this->_host,
|
||||||
$this->_port,
|
$this->_port,
|
||||||
$this->_documentRoot
|
$this->_documentRoot,
|
||||||
|
WEBROOT_DIR . '/index.php'
|
||||||
);
|
);
|
||||||
|
|
||||||
$port = ($this->_port == self::DEFAULT_PORT) ? '' : ':' . $this->_port;
|
$port = ($this->_port == self::DEFAULT_PORT) ? '' : ':' . $this->_port;
|
||||||
|
|
|
@ -74,6 +74,9 @@ if (!defined('WWW_ROOT')) {
|
||||||
|
|
||||||
// for built-in server
|
// for built-in server
|
||||||
if (php_sapi_name() == 'cli-server') {
|
if (php_sapi_name() == 'cli-server') {
|
||||||
|
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['REQUEST_URI'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
|
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2445,6 +2445,33 @@ class FormHelperTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$result = $this->Form->input('Contact.multiple', array('multiple' => 'checkbox', 'disabled' => $disabled, 'options' => $options));
|
$result = $this->Form->input('Contact.multiple', array('multiple' => 'checkbox', 'disabled' => $disabled, 'options' => $options));
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
// make sure 50 does only disable 50, and not 50f5c0cf
|
||||||
|
$options = array('50' => 'Fifty', '50f5c0cf' => 'Stringy');
|
||||||
|
$disabled = array(50);
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
array('div' => array('class' => 'input select')),
|
||||||
|
array('label' => array('for' => "ContactMultiple")),
|
||||||
|
'Multiple',
|
||||||
|
'/label',
|
||||||
|
array('input' => array('type' => 'hidden', 'name' => "data[Contact][multiple]", 'value' => '', 'id' => "ContactMultiple")),
|
||||||
|
array('div' => array('class' => 'checkbox')),
|
||||||
|
array('input' => array('type' => 'checkbox', 'name' => "data[Contact][multiple][]", 'value' => 50, 'disabled' => 'disabled', 'id' => "ContactMultiple50")),
|
||||||
|
array('label' => array('for' => "ContactMultiple50")),
|
||||||
|
'Fifty',
|
||||||
|
'/label',
|
||||||
|
'/div',
|
||||||
|
array('div' => array('class' => 'checkbox')),
|
||||||
|
array('input' => array('type' => 'checkbox', 'name' => "data[Contact][multiple][]", 'value' => '50f5c0cf', 'id' => "ContactMultiple50f5c0cf")),
|
||||||
|
array('label' => array('for' => "ContactMultiple50f5c0cf")),
|
||||||
|
'Stringy',
|
||||||
|
'/label',
|
||||||
|
'/div',
|
||||||
|
'/div'
|
||||||
|
);
|
||||||
|
$result = $this->Form->input('Contact.multiple', array('multiple' => 'checkbox', 'disabled' => $disabled, 'options' => $options));
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2996,6 +3023,31 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests inputs() works with plugin models
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testInputsPluginModel() {
|
||||||
|
$this->loadFixtures('Post');
|
||||||
|
App::build(array(
|
||||||
|
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
|
||||||
|
));
|
||||||
|
CakePlugin::load('TestPlugin');
|
||||||
|
$this->Form->request['models'] = array(
|
||||||
|
'TestPluginPost' => array('plugin' => 'TestPlugin', 'className' => 'TestPluginPost')
|
||||||
|
);
|
||||||
|
$this->Form->create('TestPlugin.TestPluginPost');
|
||||||
|
$result = $this->Form->inputs();
|
||||||
|
|
||||||
|
$this->assertContains('data[TestPluginPost][id]', $result);
|
||||||
|
$this->assertContains('data[TestPluginPost][author_id]', $result);
|
||||||
|
$this->assertContains('data[TestPluginPost][title]', $result);
|
||||||
|
$this->assertTrue(ClassRegistry::isKeySet('TestPluginPost'));
|
||||||
|
$this->assertFalse(ClassRegistry::isKeySet('TestPlugin'));
|
||||||
|
$this->assertEquals('TestPluginPost', $this->Form->model());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testSelectAsCheckbox method
|
* testSelectAsCheckbox method
|
||||||
*
|
*
|
||||||
|
@ -4221,7 +4273,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
'Contact' => array(),
|
'Contact' => array(),
|
||||||
'ContactTag' => array(
|
'ContactTag' => array(
|
||||||
array(
|
array(
|
||||||
'id' => 1,
|
'id' => '1',
|
||||||
'name' => 'blue'
|
'name' => 'blue'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
|
@ -4252,6 +4304,48 @@ class FormHelperTest extends CakeTestCase {
|
||||||
'/select'
|
'/select'
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
// make sure only 50 is selected, and not 50f5c0cf
|
||||||
|
$this->View->viewVars['contactTags'] = array(
|
||||||
|
'1' => 'blue',
|
||||||
|
'50f5c0cf' => 'red',
|
||||||
|
'50' => 'green'
|
||||||
|
);
|
||||||
|
$this->Form->request->data = array(
|
||||||
|
'Contact' => array(),
|
||||||
|
'ContactTag' => array(
|
||||||
|
array(
|
||||||
|
'id' => 1,
|
||||||
|
'name' => 'blue'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 50,
|
||||||
|
'name' => 'green'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->Form->create('Contact');
|
||||||
|
$result = $this->Form->input('ContactTag', array('div' => false, 'label' => false));
|
||||||
|
$expected = array(
|
||||||
|
'input' => array(
|
||||||
|
'type' => 'hidden', 'name' => 'data[ContactTag][ContactTag]', 'value' => '', 'id' => 'ContactTagContactTag_'
|
||||||
|
),
|
||||||
|
'select' => array(
|
||||||
|
'name' => 'data[ContactTag][ContactTag][]', 'id' => 'ContactTagContactTag',
|
||||||
|
'multiple' => 'multiple'
|
||||||
|
),
|
||||||
|
array('option' => array('value' => '1', 'selected' => 'selected')),
|
||||||
|
'blue',
|
||||||
|
'/option',
|
||||||
|
array('option' => array('value' => '50f5c0cf')),
|
||||||
|
'red',
|
||||||
|
'/option',
|
||||||
|
array('option' => array('value' => '50', 'selected' => 'selected')),
|
||||||
|
'green',
|
||||||
|
'/option',
|
||||||
|
'/select'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -329,7 +329,8 @@ class FormHelper extends AppHelper {
|
||||||
|
|
||||||
$key = null;
|
$key = null;
|
||||||
if ($model !== false) {
|
if ($model !== false) {
|
||||||
$key = $this->_introspectModel($model, 'key');
|
list($plugin, $model) = pluginSplit($model, true);
|
||||||
|
$key = $this->_introspectModel($plugin . $model, 'key');
|
||||||
$this->setEntity($model, true);
|
$this->setEntity($model, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2612,9 +2613,10 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name !== null) {
|
if ($name !== null) {
|
||||||
|
$isNumeric = is_numeric($name);
|
||||||
if (
|
if (
|
||||||
(!$selectedIsArray && !$selectedIsEmpty && (string)$attributes['value'] == (string)$name) ||
|
(!$selectedIsArray && !$selectedIsEmpty && (string)$attributes['value'] == (string)$name) ||
|
||||||
($selectedIsArray && in_array($name, $attributes['value'], true))
|
($selectedIsArray && in_array($name, $attributes['value'], !$isNumeric))
|
||||||
) {
|
) {
|
||||||
if ($attributes['style'] === 'checkbox') {
|
if ($attributes['style'] === 'checkbox') {
|
||||||
$htmlOptions['checked'] = true;
|
$htmlOptions['checked'] = true;
|
||||||
|
@ -2629,19 +2631,21 @@ class FormHelper extends AppHelper {
|
||||||
if ($attributes['style'] === 'checkbox') {
|
if ($attributes['style'] === 'checkbox') {
|
||||||
$htmlOptions['value'] = $name;
|
$htmlOptions['value'] = $name;
|
||||||
|
|
||||||
$disabledType = null;
|
|
||||||
$hasDisabled = !empty($attributes['disabled']);
|
$hasDisabled = !empty($attributes['disabled']);
|
||||||
if ($hasDisabled) {
|
if ($hasDisabled) {
|
||||||
$disabledType = gettype($attributes['disabled']);
|
$disabledIsArray = is_array($attributes['disabled']);
|
||||||
|
if ($disabledIsArray) {
|
||||||
|
$disabledIsNumeric = is_numeric($htmlOptions['value']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
$hasDisabled &&
|
$hasDisabled &&
|
||||||
$disabledType === 'array' &&
|
$disabledIsArray &&
|
||||||
in_array($htmlOptions['value'], $attributes['disabled'])
|
in_array($htmlOptions['value'], $attributes['disabled'], !$disabledIsNumeric)
|
||||||
) {
|
) {
|
||||||
$htmlOptions['disabled'] = 'disabled';
|
$htmlOptions['disabled'] = 'disabled';
|
||||||
}
|
}
|
||||||
if ($hasDisabled && $disabledType !== 'array') {
|
if ($hasDisabled && !$disabledIsArray) {
|
||||||
$htmlOptions['disabled'] = $attributes['disabled'] === true ? 'disabled' : $attributes['disabled'];
|
$htmlOptions['disabled'] = $attributes['disabled'] === true ? 'disabled' : $attributes['disabled'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue