Skip to content
Permalink
Browse files

Remove deprecated "inline" option from helpers.

  • Loading branch information...
ADmad committed Mar 9, 2014
1 parent 218de22 commit 5df6c153102526efe5d9f827a3cab40b46b465b9
@@ -1377,11 +1377,7 @@ public function postButton($title, $url, $options = array()) {
* - `data` - Array with key/value to pass in input hidden
* - `method` - Request method to use. Set to 'delete' to simulate HTTP/1.1 DELETE request. Defaults to 'post'.
* - `confirm` - Can be used instead of $confirmMessage.
* - `inline` - Whether or not the associated form tag should be output inline.
* Set to false to have the form tag appended to the 'postLink' view block.
* Defaults to true.
* - `block` - Choose a custom block to append the form tag to. Using this option
* will override the inline option.
* - `block` - Choose a custom block to append the form tag to.
* - Other options are the same of HtmlHelper::link() method.
* - The option `onclick` will be replaced.
*
@@ -1393,11 +1389,7 @@ public function postButton($title, $url, $options = array()) {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::postLink
*/
public function postLink($title, $url = null, $options = array(), $confirmMessage = false) {
$options += array('inline' => true, 'block' => null);
if (!$options['inline'] && empty($options['block'])) {
$options['block'] = __FUNCTION__;
}
unset($options['inline']);
$options += array('block' => null);
$requestMethod = 'POST';
if (!empty($options['method'])) {
@@ -183,20 +183,13 @@ public function docType($type = 'html5') {
*
* `$this->Html->meta('icon', 'favicon.ico');
*
* Append the meta tag to `$scripts_for_layout`:
*
* `$this->Html->meta('description', 'A great page', array('inline' => false));`
*
* Append the meta tag to custom view block:
*
* `$this->Html->meta('description', 'A great page', array('block' => 'metaTags'));`
*
* ### Options
*
* - `inline` Whether or not the link element should be output inline. Set to false to
* have the meta tag included in `$scripts_for_layout`, and appended to the 'meta' view block.
* - `block` Choose a custom block to append the meta tag to. Using this option
* will override the inline option.
* - `block` Choose a block to append the meta tag to.
*
* @param string $type The title of the external resource
* @param string|array $url The address of the external resource or string for content attribute
@@ -206,11 +199,7 @@ public function docType($type = 'html5') {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::meta
*/
public function meta($type, $url = null, $options = array()) {
$options += array('inline' => true, 'block' => null);
if (!$options['inline'] && empty($options['block'])) {
$options['block'] = __FUNCTION__;
}
unset($options['inline']);
$options += array('block' => null);
if (!is_array($type)) {
$types = array(
@@ -367,20 +356,13 @@ public function link($title, $url = null, $options = array(), $confirmMessage =
*
* `echo $this->Html->css(array('one.css', 'two.css'));`
*
* Add the stylesheet to the `$scripts_for_layout` layout var:
*
* `$this->Html->css('styles.css', array('inline' => false));`
*
* Add the stylesheet to a custom block:
*
* `$this->Html->css('styles.css', array('block' => 'layoutCss'));`
*
* ### Options
*
* - `inline` If set to false, the generated tag will be appended to the 'css' block,
* and included in the `$scripts_for_layout` layout variable. Defaults to true.
* - `block` Set the name of the block link/style tag will be appended to.
* This overrides the `inline` option.
* - `plugin` False value will prevent parsing path as a plugin
* - `rel` Defaults to 'stylesheet'. If equal to 'import' the stylesheet will be imported.
* - `fullBase` If true the URL will get a full address for the css file.
@@ -405,11 +387,7 @@ public function css($path, $options = array()) {
unset($rel);
}
$options += array('block' => null, 'inline' => true, 'rel' => 'stylesheet');
if (!$options['inline'] && empty($options['block'])) {
$options['block'] = __FUNCTION__;
}
unset($options['inline']);
$options += array('block' => null, 'rel' => 'stylesheet');
if (is_array($path)) {
$out = '';
@@ -465,41 +443,26 @@ public function css($path, $options = array()) {
*
* `echo $this->Html->script(array('one.js', 'two.js'));`
*
* Add the script file to the `$scripts_for_layout` layout var:
*
* `$this->Html->script('styles.js', array('inline' => false));`
*
* Add the script file to a custom block:
*
* `$this->Html->script('styles.js', null, array('block' => 'bodyScript'));`
*
* ### Options
*
* - `inline` Whether script should be output inline or into `$scripts_for_layout`. When set to false,
* the script tag will be appended to the 'script' view block as well as `$scripts_for_layout`.
* - `block` The name of the block you want the script appended to. Leave undefined to output inline.
* Using this option will override the inline option.
* - `once` Whether or not the script should be checked for uniqueness. If true scripts will only be
* included once, use false to allow the same script to be included more than once per request.
* - `plugin` False value will prevent parsing path as a plugin
* - `fullBase` If true the url will get a full address for the script file.
*
* @param string|array $url String or array of javascript files to include
* @param array|boolean $options Array of options, and html attributes see above. If boolean sets $options['inline'] = value
* @return mixed String of `<script />` tags or null if $inline is false or if $once is true and the file has been
* included before.
* @param array $options Array of options, and html attributes see above.
* @return mixed String of `<script />` tags or null if block is specified in options
* or if $once is true and the file has been included before.
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::script
*/
public function script($url, $options = array()) {
if (is_bool($options)) {
list($inline, $options) = array($options, array());
$options['inline'] = $inline;
}
$options = array_merge(array('block' => null, 'inline' => true, 'once' => true), $options);
if (!$options['inline'] && empty($options['block'])) {
$options['block'] = __FUNCTION__;
}
unset($options['inline']);
$options = array_merge(array('block' => null, 'once' => true), $options);
if (is_array($url)) {
$out = '';
@@ -537,10 +500,7 @@ public function script($url, $options = array()) {
* ### Options
*
* - `safe` (boolean) Whether or not the $script should be wrapped in <![CDATA[ ]]>
* - `inline` (boolean) Whether or not the $script should be added to
* `$scripts_for_layout` / `script` block, or output inline. (Deprecated, use `block` instead)
* - `block` Which block you want this script block appended to.
* Defaults to `script`.
*
* @param string $script The script to wrap
* @param array $options The options to use. Options not listed above will be
@@ -549,14 +509,11 @@ public function script($url, $options = array()) {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::scriptBlock
*/
public function scriptBlock($script, $options = array()) {
$options += array('safe' => true, 'inline' => true);
$options += array('safe' => true, 'block' => null);
if ($options['safe']) {
$script = "\n" . '//<![CDATA[' . "\n" . $script . "\n" . '//]]>' . "\n";
}
if (!$options['inline'] && empty($options['block'])) {
$options['block'] = 'script';
}
unset($options['inline'], $options['safe']);
unset($options['safe']);
$out = $this->formatTemplate('javascriptblock', [
'attrs' => $this->_templater->formatAttributes($options, ['block']),
@@ -577,23 +534,23 @@ public function scriptBlock($script, $options = array()) {
* ### Options
*
* - `safe` Whether the code block should contain a CDATA
* - `inline` Should the generated script tag be output inline or in `$scripts_for_layout`
* - `block` View block the output should be appended to
*
* @param array $options Options for the code block.
* @return void
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::scriptStart
*/
public function scriptStart($options = array()) {
$options += array('safe' => true, 'inline' => true);
$options += array('safe' => true, 'block' => null);
$this->_scriptBlockOptions = $options;
ob_start();
return null;
}
/**
* End a Buffered section of JavaScript capturing.
* Generates a script tag inline or in `$scripts_for_layout` depending on the settings
* used when the scriptBlock was started
* Generates a script tag inline or appends to specified view block depending on
* the settings used when the scriptBlock was started
*
* @return mixed depending on the settings of scriptStart() either a script tag or null
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::scriptEnd
@@ -5046,7 +5046,7 @@ public function testPostLinkAfterGetForm() {
* @return void
*/
public function testPostLinkFormBuffer() {
$result = $this->Form->postLink('Delete', '/posts/delete/1', array('inline' => false));
$result = $this->Form->postLink('Delete', '/posts/delete/1', array('block' => 'postLink'));
$this->assertTags($result, array(
'a' => array('href' => '#', 'onclick' => 'preg:/document\.post_\w+\.submit\(\); event\.returnValue = false; return false;/'),
'Delete',
@@ -5064,7 +5064,7 @@ public function testPostLinkFormBuffer() {
));
$result = $this->Form->postLink('Delete', '/posts/delete/2',
array('inline' => false, 'method' => 'DELETE')
array('block' => 'postLink', 'method' => 'DELETE')
);
$this->assertTags($result, array(
'a' => array('href' => '#', 'onclick' => 'preg:/document\.post_\w+\.submit\(\); event\.returnValue = false; return false;/'),
@@ -559,18 +559,9 @@ public function testCssLink() {
$this->assertEquals(2, count($result));
$this->View->expects($this->at(0))
->method('append')
->with('css', $this->matchesRegularExpression('/css_in_head.css/'));
$this->View->expects($this->at(1))
->method('append')
->with('css', $this->matchesRegularExpression('/more_css_in_head.css/'));
$result = $this->Html->css('css_in_head', array('inline' => false));
$this->assertNull($result);
$result = $this->Html->css('more_css_in_head', array('inline' => false));
$this->assertNull($result);
$this->Html->css('more_css_in_head.css', array('block' => 'css'));
$result = $this->Html->css('screen', array('rel' => 'import'));
$expected = array(
@@ -607,12 +598,6 @@ public function testCssLinkBC() {
'/style'
);
$this->assertTags($result, $expected);
$result = $this->Html->css('css_in_head', null, array('inline' => false));
$this->assertNull($result);
$result = $this->Html->css('more_css_in_head', null, array('inline' => false));
$this->assertNull($result);
}
/**
@@ -764,12 +749,12 @@ public function testScriptTimestamping() {
touch(WWW_ROOT . 'js/__cake_js_test.js');
$timestamp = substr(strtotime('now'), 0, 8);
$result = $this->Html->script('__cake_js_test', array('inline' => true, 'once' => false));
$result = $this->Html->script('__cake_js_test', array('once' => false));
$this->assertRegExp('/__cake_js_test.js\?' . $timestamp . '[0-9]{2}"/', $result, 'Timestamp value not found %s');
Configure::write('debug', 0);
Configure::write('Asset.timestamp', 'force');
$result = $this->Html->script('__cake_js_test', array('inline' => true, 'once' => false));
$result = $this->Html->script('__cake_js_test', array('once' => false));
$this->assertRegExp('/__cake_js_test.js\?' . $timestamp . '[0-9]{2}"/', $result, 'Timestamp value not found %s');
unlink(WWW_ROOT . 'js/__cake_js_test.js');
Configure::write('Asset.timestamp', false);
@@ -793,12 +778,12 @@ public function testPluginScriptTimestamping() {
touch($pluginJsPath . DS . '__cake_js_test.js');
$timestamp = substr(strtotime('now'), 0, 8);
$result = $this->Html->script('TestPlugin.__cake_js_test', array('inline' => true, 'once' => false));
$result = $this->Html->script('TestPlugin.__cake_js_test', array('once' => false));
$this->assertRegExp('/test_plugin\/js\/__cake_js_test.js\?' . $timestamp . '[0-9]{2}"/', $result, 'Timestamp value not found %s');
Configure::write('debug', 0);
Configure::write('Asset.timestamp', 'force');
$result = $this->Html->script('TestPlugin.__cake_js_test', array('inline' => true, 'once' => false));
$result = $this->Html->script('TestPlugin.__cake_js_test', array('once' => false));
$this->assertRegExp('/test_plugin\/js\/__cake_js_test.js\?' . $timestamp . '[0-9]{2}"/', $result, 'Timestamp value not found %s');
unlink($pluginJsPath . DS . '__cake_js_test.js');
Configure::write('Asset.timestamp', false);
@@ -891,7 +876,7 @@ public function testScript() {
$result = $this->Html->script(array('foo', 'bar', 'baz'));
$this->assertNotRegExp('/foo.js/', $result);
$result = $this->Html->script('foo', array('inline' => true, 'once' => false));
$result = $this->Html->script('foo', array('once' => false));
$this->assertNotNull($result);
$result = $this->Html->script('jquery-1.3.2', array('defer' => true, 'encoding' => 'utf-8'));
@@ -955,7 +940,7 @@ public function testPluginScript() {
$result = $this->Html->script(array('TestPlugin.foo', 'TestPlugin.bar', 'TestPlugin.baz'));
$this->assertNotRegExp('/test_plugin\/js\/foo.js/', $result);
$result = $this->Html->script('TestPlugin.foo', array('inline' => true, 'once' => false));
$result = $this->Html->script('TestPlugin.foo', array('once' => false));
$this->assertNotNull($result);
$result = $this->Html->script('TestPlugin.jquery-1.3.2', array('defer' => true, 'encoding' => 'utf-8'));
@@ -974,23 +959,9 @@ public function testPluginScript() {
*/
public function testScriptWithBlocks() {
$this->View->expects($this->at(0))
->method('append')
->with('script', $this->matchesRegularExpression('/script_in_head.js/'));
$this->View->expects($this->at(1))
->method('append')
->with('script', $this->matchesRegularExpression('/bool_false.js/'));
$this->View->expects($this->at(2))
->method('append')
->with('headScripts', $this->matchesRegularExpression('/second_script.js/'));
$result = $this->Html->script('script_in_head', array('inline' => false));
$this->assertNull($result);
$result = $this->Html->script('bool_false', false);
$this->assertNull($result);
$result = $this->Html->script('second_script', array('block' => 'headScripts'));
$this->assertNull($result);
}
@@ -1085,16 +1056,9 @@ public function testScriptBlock() {
$this->assertTags($result, $expected);
$this->View->expects($this->at(0))
->method('append')
->with('script', $this->matchesRegularExpression('/window\.foo\s\=\s2;/'));
$this->View->expects($this->at(1))
->method('append')
->with('scriptTop', $this->stringContains('alert('));
$result = $this->Html->scriptBlock('window.foo = 2;', array('inline' => false));
$this->assertNull($result);
$result = $this->Html->scriptBlock('alert("hi")', array('block' => 'scriptTop'));
$this->assertNull($result);
@@ -1155,7 +1119,8 @@ public function testScriptStartAndScriptEnd() {
$this->View->expects($this->once())
->method('append');
$result = $this->Html->scriptStart(array('safe' => false, 'inline' => false));
$result = $this->Html->scriptStart(array('safe' => false, 'block' => 'scripts'));
$this->assertNull($result);
echo 'this is some javascript';
@@ -1616,13 +1581,13 @@ public function testMetaIcon() {
public function testMetaWithBlocks() {
$this->View->expects($this->at(0))
->method('append')
->with('meta', $this->stringContains('ROBOTS'));
->with('metas', $this->stringContains('ROBOTS'));
$this->View->expects($this->at(1))
->method('append')
->with('metaTags', $this->stringContains('favicon.ico'));
$result = $this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'), null, array('inline' => false));
$result = $this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'), null, array('block' => 'metas'));
$this->assertNull($result);
$result = $this->Html->meta('icon', 'favicon.ico', array('block' => 'metaTags'));

0 comments on commit 5df6c15

Please sign in to comment.
You can’t perform that action at this time.