mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Removed bug fix for Helper::_confirm to keep the code compatible
This commit is contained in:
parent
34afc377ec
commit
e3b0aca95e
3 changed files with 11 additions and 10 deletions
|
@ -8095,7 +8095,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
),
|
),
|
||||||
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
||||||
'/form',
|
'/form',
|
||||||
'a' => array('href' => '#', 'onclick' => 'preg:/if \(confirm\("Confirm\?"\)\) \{ document\.post_\w+\.submit\(\); \} else \{ \} event\.returnValue = false; return false;/'),
|
'a' => array('href' => '#', 'onclick' => 'preg:/if \(confirm\("Confirm\?"\)\) \{ document\.post_\w+\.submit\(\); \} event\.returnValue = false; return false;/'),
|
||||||
'Delete',
|
'Delete',
|
||||||
'/a'
|
'/a'
|
||||||
));
|
));
|
||||||
|
@ -8108,7 +8108,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
),
|
),
|
||||||
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
||||||
'/form',
|
'/form',
|
||||||
'a' => array('href' => '#', 'onclick' => 'preg:/if \(confirm\("'Confirm' this \\\\"deletion\\\\"\?"\)\) \{ document\.post_\w+\.submit\(\); \} else \{ \} event\.returnValue = false; return false;/'),
|
'a' => array('href' => '#', 'onclick' => 'preg:/if \(confirm\("'Confirm' this \\\\"deletion\\\\"\?"\)\) \{ document\.post_\w+\.submit\(\); \} event\.returnValue = false; return false;/'),
|
||||||
'Delete',
|
'Delete',
|
||||||
'/a'
|
'/a'
|
||||||
));
|
));
|
||||||
|
@ -8142,7 +8142,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
),
|
),
|
||||||
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
||||||
'/form',
|
'/form',
|
||||||
'a' => array('class' => 'btn btn-danger', 'href' => '#', 'onclick' => 'preg:/if \(confirm\(\"\;Confirm thing\"\;\)\) \{ document\.post_\w+\.submit\(\); \} else \{ \} event\.returnValue = false; return false;/'),
|
'a' => array('class' => 'btn btn-danger', 'href' => '#', 'onclick' => 'preg:/if \(confirm\(\"\;Confirm thing\"\;\)\) \{ document\.post_\w+\.submit\(\); \} event\.returnValue = false; return false;/'),
|
||||||
'/a'
|
'/a'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -8454,7 +8454,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
'div' => array('class' => 'submit'),
|
'div' => array('class' => 'submit'),
|
||||||
'input' => array(
|
'input' => array(
|
||||||
'type' => 'submit', 'value' => 'Test',
|
'type' => 'submit', 'value' => 'Test',
|
||||||
'onclick' => 'preg:/if \(confirm\("Confirm\?"\)\) \{ \} else \{ event\.returnValue = false; return false; \}/'
|
'onclick' => 'preg:/if \(confirm\("Confirm\?"\)\) \{ return true; \} event\.returnValue = false; return false;/'
|
||||||
),
|
),
|
||||||
'/div'
|
'/div'
|
||||||
);
|
);
|
||||||
|
@ -8544,7 +8544,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
'div' => array('class' => 'submit'),
|
'div' => array('class' => 'submit'),
|
||||||
'input' => array(
|
'input' => array(
|
||||||
'type' => 'image', 'src' => 'img/cake.power.gif',
|
'type' => 'image', 'src' => 'img/cake.power.gif',
|
||||||
'onclick' => 'preg:/if \(confirm\("Confirm\?"\)\) \{ \} else \{ event\.returnValue = false; return false; \}/'
|
'onclick' => 'preg:/if \(confirm\("Confirm\?"\)\) \{ return true; \} event\.returnValue = false; return false;/'
|
||||||
),
|
),
|
||||||
'/div'
|
'/div'
|
||||||
);
|
);
|
||||||
|
|
|
@ -546,13 +546,13 @@ class Helper extends Object {
|
||||||
*
|
*
|
||||||
* @param string $message Message to be displayed
|
* @param string $message Message to be displayed
|
||||||
* @param string $okCode Code to be executed after user chose 'OK'
|
* @param string $okCode Code to be executed after user chose 'OK'
|
||||||
* @param string $cancelCode Code to be executed after user chose 'Cancel'
|
* @param string $cancelCode Code to be executed after user chose 'Cancel', also executed when okCode doesn't return
|
||||||
* @param array $options Array of options
|
* @param array $options Array of options
|
||||||
* @return string onclick JS code
|
* @return string onclick JS code
|
||||||
*/
|
*/
|
||||||
protected function _confirm($message, $okCode, $cancelCode = '', $options = array()) {
|
protected function _confirm($message, $okCode, $cancelCode = '', $options = array()) {
|
||||||
$message = json_encode($message);
|
$message = json_encode($message);
|
||||||
$confirm = "if (confirm({$message})) { {$okCode} } else { {$cancelCode} }";
|
$confirm = "if (confirm({$message})) { {$okCode} } {$cancelCode}";
|
||||||
if (isset($options['escape']) && $options['escape'] === false) {
|
if (isset($options['escape']) && $options['escape'] === false) {
|
||||||
$confirm = h($confirm);
|
$confirm = h($confirm);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1920,9 +1920,9 @@ class FormHelper extends AppHelper {
|
||||||
if ($confirmMessage) {
|
if ($confirmMessage) {
|
||||||
$options['onclick'] = $this->_confirm($confirmMessage, $onClick, '', $options);
|
$options['onclick'] = $this->_confirm($confirmMessage, $onClick, '', $options);
|
||||||
} else {
|
} else {
|
||||||
$options['onclick'] = $onClick;
|
$options['onclick'] = $onClick . ' ';
|
||||||
}
|
}
|
||||||
$options['onclick'] .= ' event.returnValue = false; return false;';
|
$options['onclick'] .= 'event.returnValue = false; return false;';
|
||||||
|
|
||||||
$out .= $this->Html->link($title, $url, $options);
|
$out .= $this->Html->link($title, $url, $options);
|
||||||
return $out;
|
return $out;
|
||||||
|
@ -2012,8 +2012,9 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($confirmMessage) {
|
if ($confirmMessage) {
|
||||||
|
$okCode = 'return true;';
|
||||||
$cancelCode = 'event.returnValue = false; return false;';
|
$cancelCode = 'event.returnValue = false; return false;';
|
||||||
$options['onclick'] = $this->_confirm($confirmMessage, '', $cancelCode, $options);
|
$options['onclick'] = $this->_confirm($confirmMessage, $okCode, $cancelCode, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($isUrl) {
|
if ($isUrl) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue