Permalink
Browse files

Merge pull request #2982 from ADmad/3.0-helper-inline

Remove deprecated "inline" option from helpers.
  • Loading branch information...
2 parents 3c72044 + 2ebf1d1 commit 6f913249beeb22dff518f7c86bde5e985de84259 @jippi jippi committed Mar 11, 2014
@@ -1360,11 +1360,8 @@ 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` - Set to true to append form to view block "postLink" or provide
+ * custom block name.
* - Other options are the same of HtmlHelper::link() method.
* - The option `onclick` will be replaced.
*
@@ -1376,11 +1373,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'])) {
@@ -1422,6 +1415,9 @@ public function postLink($title, $url = null, $options = array(), $confirmMessag
$out .= $this->formatTemplate('formend', []);
if ($options['block']) {
+ if ($options['block'] === true) {
+ $options['block'] = __FUNCTION__;
+ }
$this->_View->append($options['block'], $out);
$out = '';
}
@@ -183,20 +183,18 @@ public function docType($type = 'html5') {
*
* `$this->Html->meta('icon', 'favicon.ico');
*
- * Append the meta tag to `$scripts_for_layout`:
+ * Append the meta tag to custom view block "meta":
*
- * `$this->Html->meta('description', 'A great page', array('inline' => false));`
+ * `$this->Html->meta('description', 'A great page', array('block' => true));`
*
* 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` - Set to true to append output to view block "meta" or provide
+ * custom block name.
*
* @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 +204,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(
@@ -266,6 +260,9 @@ public function meta($type, $url = null, $options = array()) {
if (empty($options['block'])) {
return $out;
}
+ if ($options['block'] === true) {
+ $options['block'] = __FUNCTION__;
+ }
$this->_View->append($options['block'], $out);
}
@@ -367,20 +364,18 @@ 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:
+ * Add the stylesheet to view block "css":
*
- * `$this->Html->css('styles.css', array('inline' => false));`
+ * `$this->Html->css('styles.css', array('block' => true));`
*
* 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.
+ * - `block` Set to true to append output to view block "css" or provide
+ * custom block name.
* - `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 +400,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 = '';
@@ -445,6 +436,9 @@ public function css($path, $options = array()) {
if (empty($options['block'])) {
return $out;
}
+ if ($options['block'] === true) {
+ $options['block'] = __FUNCTION__;
+ }
$this->_View->append($options['block'], $out);
}
@@ -465,41 +459,27 @@ 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.
+ * - `block` Set to true to append output to view block "script" or provide
+ * custom block name.
* - `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 = '';
@@ -528,6 +508,9 @@ public function script($url, $options = array()) {
if (empty($options['block'])) {
return $out;
}
+ if ($options['block'] === true) {
+ $options['block'] = __FUNCTION__;
+ }
$this->_View->append($options['block'], $out);
}
@@ -537,10 +520,8 @@ 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`.
+ * - `block` Set to true to append output to view block "script" or provide
+ * custom block name.
*
* @param string $script The script to wrap
* @param array $options The options to use. Options not listed above will be
@@ -549,14 +530,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']),
@@ -566,6 +544,9 @@ public function scriptBlock($script, $options = array()) {
if (empty($options['block'])) {
return $out;
}
+ if ($options['block'] === true) {
+ $options['block'] = 'script';
+ }
$this->_View->append($options['block'], $out);
}
@@ -577,23 +558,24 @@ 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` Set to true to append output to view block "script" or provide
+ * custom block name.
*
* @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
@@ -5191,7 +5191,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' => true));
$this->assertTags($result, array(
'a' => array('href' => '#', 'onclick' => 'preg:/document\.post_\w+\.submit\(\); event\.returnValue = false; return false;/'),
'Delete',
@@ -5209,7 +5209,7 @@ public function testPostLinkFormBuffer() {
));
$result = $this->Form->postLink('Delete', '/posts/delete/2',
- array('inline' => false, 'method' => 'DELETE')
+ array('block' => true, 'method' => 'DELETE')
);
$this->assertTags($result, array(
'a' => array('href' => '#', 'onclick' => 'preg:/document\.post_\w+\.submit\(\); event\.returnValue = false; return false;/'),
@@ -566,10 +566,10 @@ public function testCssLink() {
->method('append')
->with('css', $this->matchesRegularExpression('/more_css_in_head.css/'));
- $result = $this->Html->css('css_in_head', array('inline' => false));
+ $result = $this->Html->css('css_in_head', array('block' => true));
$this->assertNull($result);
- $result = $this->Html->css('more_css_in_head', array('inline' => false));
+ $result = $this->Html->css('more_css_in_head', array('block' => true));
$this->assertNull($result);
$result = $this->Html->css('screen', array('rel' => 'import'));
@@ -608,10 +608,10 @@ public function testCssLinkBC() {
);
$this->assertTags($result, $expected);
- $result = $this->Html->css('css_in_head', null, array('inline' => false));
+ $result = $this->Html->css('css_in_head', null, array('block' => true));
$this->assertNull($result);
- $result = $this->Html->css('more_css_in_head', null, array('inline' => false));
+ $result = $this->Html->css('more_css_in_head', null, array('block' => true));
$this->assertNull($result);
}
@@ -764,12 +764,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 +793,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 +891,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 +955,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'));
@@ -978,17 +978,10 @@ public function testScriptWithBlocks() {
->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);
+ $result = $this->Html->script('script_in_head', array('block' => true));
$this->assertNull($result);
$result = $this->Html->script('second_script', array('block' => 'headScripts'));
@@ -1092,7 +1085,7 @@ public function testScriptBlock() {
->method('append')
->with('scriptTop', $this->stringContains('alert('));
- $result = $this->Html->scriptBlock('window.foo = 2;', array('inline' => false));
+ $result = $this->Html->scriptBlock('window.foo = 2;', array('block' => true));
$this->assertNull($result);
$result = $this->Html->scriptBlock('alert("hi")', array('block' => 'scriptTop'));
@@ -1155,7 +1148,7 @@ 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' => true));
$this->assertNull($result);
echo 'this is some javascript';
@@ -1622,7 +1615,7 @@ public function testMetaWithBlocks() {
->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' => true));
$this->assertNull($result);
$result = $this->Html->meta('icon', 'favicon.ico', array('block' => 'metaTags'));

0 comments on commit 6f91324

Please sign in to comment.