diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index 5c4bb9968695517e928b1b19573edf0295837ccb..de6f5d033e2042cf8d487c0607cdd9b487a8b75b 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -245,14 +245,14 @@ function ajax_render($commands = array()) { $items[$type] = array(); } else { - $function = 'drupal_add_' . $type; + $function = '_drupal_add_' . $type; $items[$type] = $function(); drupal_alter($type, $items[$type]); // @todo Inline CSS and JS items are indexed numerically. These can't be // reliably diffed with array_diff_key(), since the number can change // due to factors unrelated to the inline content, so for now, we strip // the inline items from Ajax responses, and can add support for them - // when drupal_add_css() and drupal_add_js() are changed to use a hash + // when _drupal_add_css() and _drupal_add_js() are changed to use a hash // of the inline content as the array key. foreach ($items[$type] as $key => $item) { if (is_numeric($key)) { @@ -290,7 +290,7 @@ function ajax_render($commands = array()) { } // Now add a command to merge changes and additions to drupalSettings. - $scripts = drupal_add_js(); + $scripts = _drupal_add_js(); if (!empty($scripts['settings'])) { $settings = drupal_merge_js_settings($scripts['settings']['data']); array_unshift($commands, ajax_command_settings($settings, TRUE)); diff --git a/core/includes/common.inc b/core/includes/common.inc index 86fd220ac41cdeb7b92f7ee08beb4704c93f722d..009900800313dea30dd6094c3c1ab453ca3bcf51 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1402,7 +1402,7 @@ function drupal_add_html_head_link($attributes, $header = FALSE) { /** * Adds a cascading stylesheet to the stylesheet queue. * - * Calling drupal_static_reset('drupal_add_css') will clear all cascading + * Calling drupal_static_reset('_drupal_add_css') will clear all cascading * stylesheets added so far. * * If CSS aggregation/compression is enabled, all cascading style sheets added @@ -1421,7 +1421,7 @@ function drupal_add_html_head_link($attributes, $header = FALSE) { * all typical visitors and most pages of a site. It is critical that all * preprocessed files are added unconditionally on every page, even if the * files do not happen to be needed on a page. This is normally done by calling - * drupal_add_css() in a hook_page_build() implementation. + * _drupal_add_css() in a hook_page_build() implementation. * * Non-preprocessed files should only be added to the page when they are * actually needed. @@ -1494,9 +1494,9 @@ function drupal_add_html_head_link($attributes, $header = FALSE) { * - Then by the 'every_page' flag, with TRUE coming before FALSE. * - Then by weight. * - Then by the order in which the CSS was added. For example, all else - * being the same, a stylesheet added by a call to drupal_add_css() that + * being the same, a stylesheet added by a call to _drupal_add_css() that * happened later in the page request gets added to the page after one for - * which drupal_add_css() happened earlier in the page request. + * which _drupal_add_css() happened earlier in the page request. * Available constants are: * - CSS_BASE: Styles for HTML elements ("base" styles). * - CSS_LAYOUT: Styles that layout a page. @@ -1523,7 +1523,7 @@ function drupal_add_html_head_link($attributes, $header = FALSE) { * * @see drupal_get_css() */ -function drupal_add_css($data = NULL, $options = NULL) { +function _drupal_add_css($data = NULL, $options = NULL) { $css = &drupal_static(__FUNCTION__, array()); // Construct the options, taking the defaults into consideration. @@ -1613,13 +1613,13 @@ function drupal_add_css($data = NULL, $options = NULL) { * @return * A string of XHTML CSS tags. * - * @see drupal_add_css() + * @see _drupal_add_css() */ function drupal_get_css($css = NULL, $skip_alter = FALSE) { global $theme_info; if (!isset($css)) { - $css = drupal_add_css(); + $css = _drupal_add_css(); } // Allow modules and themes to alter the CSS items. @@ -1672,12 +1672,12 @@ function drupal_get_css($css = NULL, $skip_alter = FALSE) { * * @param $a * First item for comparison. The compared items should be associative arrays - * of member items from drupal_add_css() or drupal_add_js(). + * of member items from _drupal_add_css() or _drupal_add_js(). * @param $b * Second item for comparison. * - * @see drupal_add_css() - * @see drupal_add_js() + * @see _drupal_add_css() + * @see _drupal_add_js() */ function drupal_sort_css_js($a, $b) { // First order by group, so that all items in the CSS_AGGREGATE_DEFAULT group @@ -1759,7 +1759,7 @@ function drupal_sort_css_js($a, $b) { * * @param $element * A render array containing: - * - '#items': The CSS items as returned by drupal_add_css() and altered by + * - '#items': The CSS items as returned by _drupal_add_css() and altered by * drupal_get_css(). * * @return @@ -1981,17 +1981,17 @@ function drupal_html_id($id) { * * Examples: * @code - * drupal_add_js('core/misc/collapse.js'); - * drupal_add_js('core/misc/collapse.js', 'file'); - * drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline'); - * drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', + * _drupal_add_js('core/misc/collapse.js'); + * _drupal_add_js('core/misc/collapse.js', 'file'); + * _drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline'); + * _drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', * array('type' => 'inline', 'scope' => 'footer', 'weight' => 5) * ); - * drupal_add_js('http://example.com/example.js', 'external'); - * drupal_add_js(array('myModule' => array('key' => 'value')), 'setting'); + * _drupal_add_js('http://example.com/example.js', 'external'); + * _drupal_add_js(array('myModule' => array('key' => 'value')), 'setting'); * @endcode * - * Calling drupal_static_reset('drupal_add_js') will clear all JavaScript added + * Calling drupal_static_reset('_drupal_add_js') will clear all JavaScript added * so far. * * If JavaScript aggregation is enabled, all JavaScript files added with @@ -2008,7 +2008,7 @@ function drupal_html_id($id) { * all typical visitors and most pages of a site. It is critical that all * preprocessed files are added unconditionally on every page, even if the * files are not needed on a page. This is normally done by calling - * drupal_add_js() in a hook_page_build() implementation. + * _drupal_add_js() in a hook_page_build() implementation. * * Non-preprocessed files should only be added to the page when they are * actually needed. @@ -2085,9 +2085,9 @@ function drupal_html_id($id) { * - Then by the 'every_page' flag, with TRUE coming before FALSE. * - Then by weight. * - Then by the order in which the JavaScript was added. For example, all - * else being the same, JavaScript added by a call to drupal_add_js() that + * else being the same, JavaScript added by a call to _drupal_add_js() that * happened later in the page request gets added to the page after one for - * which drupal_add_js() happened earlier in the page request. + * which _drupal_add_js() happened earlier in the page request. * - cache: If set to FALSE, the JavaScript file is loaded anew on every page * call; in other words, it is not cached. Used only when 'type' references * a JavaScript file. Defaults to TRUE. @@ -2104,13 +2104,13 @@ function drupal_html_id($id) { * @return * The current array of JavaScript files, settings, and in-line code, * including Drupal defaults, anything previously added with calls to - * drupal_add_js(), and this function call's additions. + * _drupal_add_js(), and this function call's additions. * * @deprecated as of Drupal 8.0. Use the #attached key in render arrays instead. * * @see drupal_get_js() */ -function drupal_add_js($data = NULL, $options = NULL) { +function _drupal_add_js($data = NULL, $options = NULL) { $javascript = &drupal_static(__FUNCTION__, array()); // Construct the options, taking the defaults into consideration. @@ -2128,7 +2128,7 @@ function drupal_add_js($data = NULL, $options = NULL) { $options['preprocess'] = $options['cache'] && empty($options['attributes']) ? $options['preprocess'] : FALSE; // Tweak the weight so that files of the same weight are included in the - // order of the calls to drupal_add_js(). + // order of the calls to _drupal_add_js(). $options['weight'] += count($javascript) / 1000; if (isset($data)) { switch ($options['type']) { @@ -2189,7 +2189,7 @@ function drupal_add_js($data = NULL, $options = NULL) { * (optional) The default data parameter for the JavaScript item array. * * @see drupal_get_js() - * @see drupal_add_js() + * @see _drupal_add_js() */ function drupal_js_defaults($data = NULL) { return array( @@ -2217,7 +2217,7 @@ function drupal_js_defaults($data = NULL) { * * Note that hook_js_alter(&$javascript) is called during this function call * to allow alterations of the JavaScript during its presentation. Calls to - * drupal_add_js() from hook_js_alter() will not be added to the output + * _drupal_add_js() from hook_js_alter() will not be added to the output * presentation. The correct way to add JavaScript during hook_js_alter() * is to add another element to the $javascript array, deriving from * drupal_js_defaults(). See locale_js_alter() for an example of this. @@ -2239,13 +2239,13 @@ function drupal_js_defaults($data = NULL) { * @return * All JavaScript code segments and includes for the scope as HTML tags. * - * @see drupal_add_js() + * @see _drupal_add_js() * @see locale_js_alter() * @see drupal_js_defaults() */ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALSE, $is_ajax = FALSE) { if (!isset($javascript)) { - $javascript = drupal_add_js(); + $javascript = _drupal_add_js(); } if (empty($javascript)) { return ''; @@ -2294,17 +2294,17 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS // Skip if no files were added to the page otherwise jQuery.extend() will // overwrite the drupalSettings.ajaxPageState.css object with an empty // array. - $css = drupal_add_css(); + $css = _drupal_add_css(); if (!empty($css)) { // Cast the array to an object to be on the safe side even if not empty. $setting['ajaxPageState']['css'] = (object) array_fill_keys(array_keys($css), 1); } - drupal_add_js($setting, 'setting'); + _drupal_add_js($setting, 'setting'); // If we're outputting the header scope, then this might be the final time // that drupal_get_js() is running, so add the settings to this output as well - // as to the drupal_add_js() cache. If $items['settings'] doesn't exist, it's + // as to the _drupal_add_js() cache. If $items['settings'] doesn't exist, it's // because drupal_get_js() was intentionally passed a $javascript argument // stripped of settings, potentially in order to override how settings get // output, so in this case, do not add the setting to this output. @@ -2356,7 +2356,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS * * By following jQuery.extend() merge logic rather than common PHP array merge * logic, the following are ensured: - * - drupal_add_js() is idempotent: calling it twice with the same parameters + * - _drupal_add_js() is idempotent: calling it twice with the same parameters * does not change the output sent to the browser. * - If pieces of the page are rendered in separate PHP requests and the * returned settings are merged by JavaScript, the resulting settings are the @@ -2365,7 +2365,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS * @param $settings_items * An array of settings arrays, as returned by: * @code - * $js = drupal_add_js(); + * $js = _drupal_add_js(); * $settings_items = $js['settings']['data']; * @endcode * @@ -2373,7 +2373,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS * A merged $settings array, suitable for JSON encoding and returning to the * browser. * - * @see drupal_add_js() + * @see _drupal_add_js() * @see drupal_pre_render_scripts() */ function drupal_merge_js_settings($settings_items) { @@ -2406,7 +2406,7 @@ function drupal_merge_attached(array $a, array $b) { * * @param $element * A render array containing: - * - #items: The JavaScript items as returned by drupal_add_js() and + * - #items: The JavaScript items as returned by _drupal_add_js() and * altered by drupal_get_js(). * - #group_callback: A function to call to group #items. Following * this function, #aggregate_callback is called to aggregate items within @@ -2437,6 +2437,7 @@ function drupal_pre_render_scripts($elements) { * to elements using the #attached property. The #attached property is an * associative array, where the keys are the the attachment types and the values * are the attached data. For example: + * * @code * $build['#attached'] = array( * 'library' => array(array('taxonomy', 'taxonomy')), @@ -2474,8 +2475,8 @@ function drupal_pre_render_scripts($elements) { * dependencies were met. * * @see drupal_add_library() - * @see drupal_add_js() - * @see drupal_add_css() + * @see _drupal_add_js() + * @see _drupal_add_css() * @see drupal_render() */ function drupal_process_attached($elements, $dependency_check = FALSE) { @@ -2500,7 +2501,7 @@ function drupal_process_attached($elements, $dependency_check = FALSE) { unset($elements['#attached']['library']); // Add both the JavaScript and the CSS. - // The parameters for drupal_add_js() and drupal_add_css() require special + // The parameters for _drupal_add_js() and _drupal_add_css() require special // handling. foreach (array('js', 'css') as $type) { foreach ($elements['#attached'][$type] as $data => $options) { @@ -2516,7 +2517,7 @@ function drupal_process_attached($elements, $dependency_check = FALSE) { $data = $options['data']; unset($options['data']); } - call_user_func('drupal_add_' . $type, $data, $options); + call_user_func('_drupal_add_' . $type, $data, $options); } unset($elements['#attached'][$type]); } diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 37f04f90a39dde36f74c6026f2b066e0707310c3..46113c605b30ec6ba15ede354a8b04ac2a1c76af 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2495,7 +2495,7 @@ function template_preprocess_maintenance_page(&$variables) { // While this code is used in the installer, the language module may not be // enabled yet (even maybe no database set up yet), but an RTL language // selected should result in RTL stylesheets loaded properly already. - $css = drupal_add_css(); + $css = _drupal_add_css(); include_once DRUPAL_ROOT . '/core/modules/language/language.module'; // Wrapping drupal_get_css() and drupal_get_js() in an object so they can // be called when printed. diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponse.php b/core/lib/Drupal/Core/Ajax/AjaxResponse.php index 256ea955817fb3b80aa1b744aac12a1cb057d9c5..85cebb96927def58589f3574fb337880927e7b3f 100644 --- a/core/lib/Drupal/Core/Ajax/AjaxResponse.php +++ b/core/lib/Drupal/Core/Ajax/AjaxResponse.php @@ -104,14 +104,14 @@ protected function ajaxRender(Request $request) { $items[$type] = array(); } else { - $function = 'drupal_add_' . $type; + $function = '_drupal_add_' . $type; $items[$type] = $function(); drupal_alter($type, $items[$type]); // @todo Inline CSS and JS items are indexed numerically. These can't be // reliably diffed with array_diff_key(), since the number can change // due to factors unrelated to the inline content, so for now, we // strip the inline items from Ajax responses, and can add support for - // them when drupal_add_css() and drupal_add_js() are changed to use + // them when _drupal_add_css() and _drupal_add_js() are changed to use // a hash of the inline content as the array key. foreach ($items[$type] as $key => $item) { if (is_numeric($key)) { @@ -150,7 +150,7 @@ protected function ajaxRender(Request $request) { } // Prepend a command to merge changes and additions to drupalSettings. - $scripts = drupal_add_js(); + $scripts = _drupal_add_js(); if (!empty($scripts['settings'])) { $settings = drupal_merge_js_settings($scripts['settings']['data']); // During Ajax requests basic path-specific settings are excluded from @@ -158,7 +158,7 @@ protected function ajaxRender(Request $request) { // from already has the right values for the keys below. An Ajax request // would update them with values for the Ajax request and incorrectly // override the page's values. - // @see drupal_add_js + // @see _drupal_add_js() foreach (array('basePath', 'currentPath', 'scriptPath', 'pathPrefix') as $item) { unset($settings[$item]); } diff --git a/core/lib/Drupal/Core/Asset/CssCollectionGrouper.php b/core/lib/Drupal/Core/Asset/CssCollectionGrouper.php index 2ccabfa045316dc5592b4d3cd96d41dc38a71789..a8f4355698a96cdf16c547db4f695b66262a376f 100644 --- a/core/lib/Drupal/Core/Asset/CssCollectionGrouper.php +++ b/core/lib/Drupal/Core/Asset/CssCollectionGrouper.php @@ -58,7 +58,7 @@ public function group(array $css_assets) { // Group file items if their 'preprocess' flag is TRUE. // Help ensure maximum reuse of aggregate files by only grouping // together items that share the same 'group' value and 'every_page' - // flag. See drupal_add_css() for details about that. + // flag. See _drupal_add_css() for details about that. $group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['every_page'], $item['media'], $item['browsers']) : FALSE; break; diff --git a/core/lib/Drupal/Core/Asset/JsCollectionGrouper.php b/core/lib/Drupal/Core/Asset/JsCollectionGrouper.php index 9f0aed0d9754d4a5e164b934783c5e8bbb7ece1e..3547b5120e1ec7ebef54c0c617745390bd2abc5b 100644 --- a/core/lib/Drupal/Core/Asset/JsCollectionGrouper.php +++ b/core/lib/Drupal/Core/Asset/JsCollectionGrouper.php @@ -45,7 +45,7 @@ public function group(array $js_assets) { // Group file items if their 'preprocess' flag is TRUE. // Help ensure maximum reuse of aggregate files by only grouping // together items that share the same 'group' value and 'every_page' - // flag. See drupal_add_js() for details about that. + // flag. See _drupal_add_js() for details about that. $group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['every_page'], $item['browsers']) : FALSE; break; diff --git a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php index b9de5f8b651e34f865aca27851978ef249bef37e..5f920d48450ce907c45be1b33248bbc1057e3899 100644 --- a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php +++ b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php @@ -39,7 +39,7 @@ public function render(array $js_assets) { // A dummy query-string is added to filenames, to gain control over // browser-caching. The string changes on every update or full cache // flush, forcing browsers to load a new copy of the files, as the - // URL changed. Files that should not be cached (see drupal_add_js()) + // URL changed. Files that should not be cached (see _drupal_add_js()) // get REQUEST_TIME as query-string instead, to enforce reload on every // page request. $default_query_string = $this->state->get('system.css_js_query_string') ?: '0'; diff --git a/core/modules/edit/lib/Drupal/edit/EditController.php b/core/modules/edit/lib/Drupal/edit/EditController.php index 4621f94d87c37e0a61405909a03bc9748a331f77..1e62ab6c379c2e06b0c122a4802e8b11eceb96b8 100644 --- a/core/modules/edit/lib/Drupal/edit/EditController.php +++ b/core/modules/edit/lib/Drupal/edit/EditController.php @@ -275,8 +275,8 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view // When working with a hidden form, we don't want any CSS or JS to be loaded. if ($request->request->get('nocssjs') === 'true') { - drupal_static_reset('drupal_add_css'); - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_css'); + drupal_static_reset('_drupal_add_js'); } return $response; diff --git a/core/modules/editor/editor.api.php b/core/modules/editor/editor.api.php index 0f44381576b06a00f3837b3ba11596ff0ae845cd..fe9548b12837405e9df7052f6e877197d2928828 100644 --- a/core/modules/editor/editor.api.php +++ b/core/modules/editor/editor.api.php @@ -91,7 +91,7 @@ function hook_editor_default_settings_alter(&$default_settings, $editor) { * Modifies JavaScript settings that are added for text editors. * * @param array $settings - * All the settings that will be added to the page via drupal_add_js() for + * All the settings that will be added to the page via _drupal_add_js() for * the text formats to which a user has access. * @param array $formats * The list of format objects for which settings are being added. diff --git a/core/modules/file/lib/Drupal/file/Controller/FileWidgetAjaxController.php b/core/modules/file/lib/Drupal/file/Controller/FileWidgetAjaxController.php index dde6bbe83be7c15388ad1d782c0412770c6236c6..4036a1ff3aa25cf7fe6d34472f64fcacc1cec903 100644 --- a/core/modules/file/lib/Drupal/file/Controller/FileWidgetAjaxController.php +++ b/core/modules/file/lib/Drupal/file/Controller/FileWidgetAjaxController.php @@ -75,7 +75,7 @@ public function upload(Request $request) { $status_messages = array('#theme' => 'status_messages'); $form['#prefix'] .= drupal_render($status_messages); $output = drupal_render($form); - $js = drupal_add_js(); + $js = _drupal_add_js(); $settings = drupal_merge_js_settings($js['settings']['data']); $response = new AjaxResponse(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php index eced53876cd56f63b08679cc7da26cc8b2cbba9c..b70a1e655784e72bf05bf75f56d976d4075bc4ff 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php @@ -31,10 +31,10 @@ public static function getInfo() { */ public function testAJAXRender() { // Verify that settings command is generated when JavaScript settings are - // set via drupal_add_js(). + // set via _drupal_add_js(). $commands = $this->drupalGetAJAX('ajax-test/render'); $expected = new SettingsCommand(array('ajax' => 'test'), TRUE); - $this->assertCommand($commands, $expected->render(), 'ajax_render() loads settings added with drupal_add_js().'); + $this->assertCommand($commands, $expected->render(), 'ajax_render() loads settings added with _drupal_add_js().'); } /** @@ -46,7 +46,7 @@ public function testOrder() { // Expected commands, in a very specific order. $expected_commands[0] = new SettingsCommand(array('ajax' => 'test'), TRUE); - drupal_static_reset('drupal_add_css'); + drupal_static_reset('_drupal_add_css'); $attached = array( '#attached' => array( 'css' => array( @@ -56,8 +56,8 @@ public function testOrder() { ), ); drupal_render($attached); - $expected_commands[1] = new AddCssCommand(drupal_get_css(drupal_add_css(), TRUE)); - drupal_static_reset('drupal_add_js'); + $expected_commands[1] = new AddCssCommand(drupal_get_css(_drupal_add_css(), TRUE)); + drupal_static_reset('_drupal_add_js'); $attached = array( '#attached' => array( 'js' => array( @@ -66,8 +66,8 @@ public function testOrder() { ), ); drupal_render($attached); - $expected_commands[2] = new PrependCommand('head', drupal_get_js('header', drupal_add_js(), TRUE)); - drupal_static_reset('drupal_add_js'); + $expected_commands[2] = new PrependCommand('head', drupal_get_js('header', _drupal_add_js(), TRUE)); + drupal_static_reset('_drupal_add_js'); $attached = array( '#attached' => array( 'js' => array( @@ -76,7 +76,7 @@ public function testOrder() { ), ); drupal_render($attached); - $expected_commands[3] = new AppendCommand('body', drupal_get_js('footer', drupal_add_js(), TRUE)); + $expected_commands[3] = new AppendCommand('body', drupal_get_js('footer', _drupal_add_js(), TRUE)); $expected_commands[4] = new HtmlCommand('body', 'Hello, world!'); // Load any page with at least one CSS file, at least one JavaScript file @@ -123,7 +123,7 @@ public function testLazyLoad() { 'css' => drupal_get_path('module', 'system') . '/css/system.admin.css', 'js' => drupal_get_path('module', 'system') . '/system.js', ); - // CSS files are stored by basename, see drupal_add_css(). + // CSS files are stored by basename, see _drupal_add_css(). $expected_css_basename = drupal_basename($expected['css']); // @todo D8: Add a drupal_css_defaults() helper function. diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php index 052ea57a13eb3b393be21ece58dec5fe56729480..5c016ce4ce4ed979e722055ce93b180881195e58 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php @@ -32,15 +32,15 @@ public static function getInfo() { function setUp() { parent::setUp(); - // Reset drupal_add_css() before each test. - drupal_static_reset('drupal_add_css'); + // Reset _drupal_add_css() before each test. + drupal_static_reset('_drupal_add_css'); } /** * Checks that default stylesheets are empty. */ function testDefault() { - $this->assertEqual(array(), drupal_add_css(), 'Default CSS is empty.'); + $this->assertEqual(array(), _drupal_add_css(), 'Default CSS is empty.'); } /** @@ -48,7 +48,7 @@ function testDefault() { */ function testAddFile() { $path = drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css'; - $css = drupal_add_css($path); + $css = _drupal_add_css($path); $this->assertEqual($css['simpletest.module.css']['data'], $path); } @@ -57,7 +57,7 @@ function testAddFile() { */ function testAddExternal() { $path = 'http://example.com/style.css'; - $css = drupal_add_css($path, 'external'); + $css = _drupal_add_css($path, 'external'); $this->assertEqual($css[$path]['type'], 'external', 'Adding an external CSS file caches it properly.'); } @@ -65,8 +65,8 @@ function testAddExternal() { * Makes sure that resetting the CSS empties the cache. */ function testReset() { - drupal_static_reset('drupal_add_css'); - $this->assertEqual(array(), drupal_add_css(), 'Resetting the CSS empties the cache.'); + drupal_static_reset('_drupal_add_css'); + $this->assertEqual(array(), _drupal_add_css(), 'Resetting the CSS empties the cache.'); } /** @@ -74,7 +74,7 @@ function testReset() { */ function testRenderFile() { $css = drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css'; - drupal_add_css($css); + _drupal_add_css($css); $styles = drupal_get_css(); $this->assertTrue(strpos($styles, $css) > 0, 'Rendered CSS includes the added stylesheet.'); // Verify that newlines are properly added inside style tags. @@ -88,7 +88,7 @@ function testRenderFile() { */ function testRenderExternal() { $css = 'http://example.com/style.css'; - drupal_add_css($css, 'external'); + _drupal_add_css($css, 'external'); $styles = drupal_get_css(); // Stylesheet URL may be the href of a LINK tag or in an @import statement // of a STYLE tag. @@ -105,7 +105,7 @@ function testRenderInlinePreprocess() { $css = 'body { padding: 0px; }'; $css_preprocessed = ''; - drupal_add_css($css, array('type' => 'inline')); + _drupal_add_css($css, array('type' => 'inline')); $styles = drupal_get_css(); $this->assertEqual(trim($styles), $css_preprocessed, 'Rendering preprocessed inline CSS adds it to the page.'); } @@ -115,7 +115,7 @@ function testRenderInlinePreprocess() { */ function testRenderInlineNoPreprocess() { $css = 'body { padding: 0px; }'; - drupal_add_css($css, array('type' => 'inline', 'preprocess' => FALSE)); + _drupal_add_css($css, array('type' => 'inline', 'preprocess' => FALSE)); $styles = drupal_get_css(); $this->assertTrue(strpos($styles, $css) > 0, 'Rendering non-preprocessed inline CSS adds it to the page.'); } @@ -125,12 +125,12 @@ function testRenderInlineNoPreprocess() { */ function testRenderOrder() { // Load a module CSS file. - drupal_add_css(drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css'); + _drupal_add_css(drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css'); // Load a few system CSS files in a custom, early-loading aggregate group. $test_aggregate_group = -100; $system_path = drupal_get_path('module', 'system'); - drupal_add_css($system_path . '/css/system.module.css', array('group' => $test_aggregate_group, 'weight' => -10)); - drupal_add_css($system_path . '/css/system.theme.css', array('group' => $test_aggregate_group)); + _drupal_add_css($system_path . '/css/system.module.css', array('group' => $test_aggregate_group, 'weight' => -10)); + _drupal_add_css($system_path . '/css/system.theme.css', array('group' => $test_aggregate_group)); $expected = array( $system_path . '/css/system.module.css', @@ -157,16 +157,16 @@ function testRenderOrder() { function testRenderOverride() { $system = drupal_get_path('module', 'system'); - drupal_add_css($system . '/css/system.module.css'); - drupal_add_css($system . '/tests/css/system.module.css'); + _drupal_add_css($system . '/css/system.module.css'); + _drupal_add_css($system . '/tests/css/system.module.css'); // The dummy stylesheet should be the only one included. $styles = drupal_get_css(); $this->assert(strpos($styles, $system . '/tests/css/system.module.css') !== FALSE, 'The overriding CSS file is output.'); $this->assert(strpos($styles, $system . '/css/system.module.css') === FALSE, 'The overridden CSS file is not output.'); - drupal_add_css($system . '/tests/css/system.module.css'); - drupal_add_css($system . '/css/system.module.css'); + _drupal_add_css($system . '/tests/css/system.module.css'); + _drupal_add_css($system . '/css/system.module.css'); // The standard stylesheet should be the only one included. $styles = drupal_get_css(); @@ -180,8 +180,8 @@ function testRenderOverride() { function testAddCssFileWithQueryString() { $css_without_query_string = drupal_get_path('module', 'node') . '/css/node.admin.css'; $css_with_query_string = '/' . drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2'; - drupal_add_css($css_without_query_string); - drupal_add_css($css_with_query_string); + _drupal_add_css($css_without_query_string); + _drupal_add_css($css_with_query_string); $styles = drupal_get_css(); $query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0'; diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php index 3f584aa6d0be956044714bd6ec04ef7c2ab98181..2e529e43febaac274bbe69f3e811df41d15d5ac2 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php @@ -47,8 +47,8 @@ function setUp() { $config->set('js.preprocess', 0); $config->save(); - // Reset drupal_add_js() and drupal_add_library() statics before each test. - drupal_static_reset('drupal_add_js'); + // Reset _drupal_add_js() and drupal_add_library() statics before each test. + drupal_static_reset('_drupal_add_js'); drupal_static_reset('drupal_add_library'); } @@ -64,14 +64,14 @@ function tearDown() { * Tests that default JavaScript is empty. */ function testDefault() { - $this->assertEqual(array(), drupal_add_js(), 'Default JavaScript is empty.'); + $this->assertEqual(array(), _drupal_add_js(), 'Default JavaScript is empty.'); } /** * Tests adding a JavaScript file. */ function testAddFile() { - $javascript = drupal_add_js('core/misc/collapse.js'); + $javascript = _drupal_add_js('core/misc/collapse.js'); $this->assertTrue(array_key_exists('core/misc/collapse.js', $javascript), 'JavaScript files are correctly added.'); } @@ -81,11 +81,11 @@ function testAddFile() { function testAddSetting() { // Add a file in order to test default settings. drupal_add_library('system', 'drupalSettings'); - $javascript = drupal_add_js(); + $javascript = _drupal_add_js(); $last_settings = reset($javascript['settings']['data']); $this->assertTrue(array_key_exists('currentPath', $last_settings), 'The current path JavaScript setting is set correctly.'); - $javascript = drupal_add_js(array('drupal' => 'rocks', 'dries' => 280342800), 'setting'); + $javascript = _drupal_add_js(array('drupal' => 'rocks', 'dries' => 280342800), 'setting'); $last_settings = end($javascript['settings']['data']); $this->assertEqual(280342800, $last_settings['dries'], 'JavaScript setting is set correctly.'); $this->assertEqual('rocks', $last_settings['drupal'], 'The other JavaScript setting is set correctly.'); @@ -96,7 +96,7 @@ function testAddSetting() { */ function testAddExternal() { $path = 'http://example.com/script.js'; - $javascript = drupal_add_js($path, 'external'); + $javascript = _drupal_add_js($path, 'external'); $this->assertTrue(array_key_exists('http://example.com/script.js', $javascript), 'Added an external JavaScript file.'); } @@ -107,8 +107,8 @@ function testAttributes() { $default_query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0'; drupal_add_library('system', 'drupal'); - drupal_add_js('http://example.com/script.js', array('attributes' => array('defer' => 'defer'))); - drupal_add_js('core/misc/collapse.js', array('attributes' => array('defer' => 'defer'))); + _drupal_add_js('http://example.com/script.js', array('attributes' => array('defer' => 'defer'))); + _drupal_add_js('core/misc/collapse.js', array('attributes' => array('defer' => 'defer'))); $javascript = drupal_get_js(); $expected_1 = ''; @@ -128,8 +128,8 @@ function testAggregatedAttributes() { $default_query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0'; drupal_add_library('system', 'drupal'); - drupal_add_js('http://example.com/script.js', array('attributes' => array('defer' => 'defer'))); - drupal_add_js('core/misc/collapse.js', array('attributes' => array('defer' => 'defer'))); + _drupal_add_js('http://example.com/script.js', array('attributes' => array('defer' => 'defer'))); + _drupal_add_js('core/misc/collapse.js', array('attributes' => array('defer' => 'defer'))); $javascript = drupal_get_js(); $expected_1 = ''; @@ -152,40 +152,40 @@ function testHeaderSetting() { $this->assertTrue(strpos($javascript, 'currentPath') > 0, 'Rendered JavaScript header returns currentPath setting.'); // Only the second of these two entries should appear in drupalSettings. - drupal_add_js(array('commonTest' => 'commonTestShouldNotAppear'), 'setting'); - drupal_add_js(array('commonTest' => 'commonTestShouldAppear'), 'setting'); + _drupal_add_js(array('commonTest' => 'commonTestShouldNotAppear'), 'setting'); + _drupal_add_js(array('commonTest' => 'commonTestShouldAppear'), 'setting'); // Only the second of these entries should appear in drupalSettings. - drupal_add_js(array('commonTestJsArrayLiteral' => array('commonTestJsArrayLiteralOldValue')), 'setting'); - drupal_add_js(array('commonTestJsArrayLiteral' => array('commonTestJsArrayLiteralNewValue')), 'setting'); + _drupal_add_js(array('commonTestJsArrayLiteral' => array('commonTestJsArrayLiteralOldValue')), 'setting'); + _drupal_add_js(array('commonTestJsArrayLiteral' => array('commonTestJsArrayLiteralNewValue')), 'setting'); // Only the second of these two entries should appear in drupalSettings. - drupal_add_js(array('commonTestJsObjectLiteral' => array('key' => 'commonTestJsObjectLiteralOldValue')), 'setting'); - drupal_add_js(array('commonTestJsObjectLiteral' => array('key' => 'commonTestJsObjectLiteralNewValue')), 'setting'); + _drupal_add_js(array('commonTestJsObjectLiteral' => array('key' => 'commonTestJsObjectLiteralOldValue')), 'setting'); + _drupal_add_js(array('commonTestJsObjectLiteral' => array('key' => 'commonTestJsObjectLiteralNewValue')), 'setting'); // Real world test case: multiple elements in a render array are adding the // same (or nearly the same) JavaScript settings. When merged, they should // contain all settings and not duplicate some settings. $settings_one = array('moduleName' => array('ui' => array('button A', 'button B'), 'magical flag' => 3.14159265359)); - drupal_add_js(array('commonTestRealWorldIdentical' => $settings_one), 'setting'); - drupal_add_js(array('commonTestRealWorldIdentical' => $settings_one), 'setting'); + _drupal_add_js(array('commonTestRealWorldIdentical' => $settings_one), 'setting'); + _drupal_add_js(array('commonTestRealWorldIdentical' => $settings_one), 'setting'); $settings_two = array('moduleName' => array('ui' => array('button A', 'button B'), 'magical flag' => 3.14159265359, 'thingiesOnPage' => array('id1' => array()))); - drupal_add_js(array('commonTestRealWorldAlmostIdentical' => $settings_two), 'setting'); + _drupal_add_js(array('commonTestRealWorldAlmostIdentical' => $settings_two), 'setting'); $settings_two = array('moduleName' => array('ui' => array('button C', 'button D'), 'magical flag' => 3.14, 'thingiesOnPage' => array('id2' => array()))); - drupal_add_js(array('commonTestRealWorldAlmostIdentical' => $settings_two), 'setting'); + _drupal_add_js(array('commonTestRealWorldAlmostIdentical' => $settings_two), 'setting'); $javascript = drupal_get_js('header'); - // Test whether drupal_add_js can be used to override a previous setting. + // Test whether _drupal_add_js can be used to override a previous setting. $this->assertTrue(strpos($javascript, 'commonTestShouldAppear') > 0, 'Rendered JavaScript header returns custom setting.'); - $this->assertTrue(strpos($javascript, 'commonTestShouldNotAppear') === FALSE, 'drupal_add_js() correctly overrides a custom setting.'); + $this->assertTrue(strpos($javascript, 'commonTestShouldNotAppear') === FALSE, '_drupal_add_js() correctly overrides a custom setting.'); - // Test whether drupal_add_js can be used to add and override a JavaScript + // Test whether _drupal_add_js can be used to add and override a JavaScript // array literal (an indexed PHP array) values. $array_override = strpos($javascript, 'commonTestJsArrayLiteralNewValue') > 0 && strpos($javascript, 'commonTestJsArrayLiteralOldValue') === FALSE; - $this->assertTrue($array_override, 'drupal_add_js() correctly overrides settings within an array literal (indexed array).'); + $this->assertTrue($array_override, '_drupal_add_js() correctly overrides settings within an array literal (indexed array).'); - // Test whether drupal_add_js can be used to add and override a JavaScript + // Test whether _drupal_add_js can be used to add and override a JavaScript // object literal (an associate PHP array) values. $associative_array_override = strpos($javascript, 'commonTestJsObjectLiteralNewValue') > 0 && strpos($javascript, 'commonTestJsObjectLiteralOldValue') === FALSE; - $this->assertTrue($associative_array_override, 'drupal_add_js() correctly overrides settings within an object literal (associative array).'); + $this->assertTrue($associative_array_override, '_drupal_add_js() correctly overrides settings within an object literal (associative array).'); // Parse the generated drupalSettings ', @@ -329,16 +329,16 @@ function testAggregation() { // Now ensure that with aggregation on, one file is made for the // 'every_page' files, and one file is made for the others. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $config = \Drupal::config('system.performance'); $config->set('js.preprocess', 1); $config->save(); drupal_add_library('system', 'drupal'); - drupal_add_js('core/misc/ajax.js'); - drupal_add_js('core/misc/collapse.js', array('every_page' => TRUE)); - drupal_add_js('core/misc/autocomplete.js'); - drupal_add_js('core/misc/batch.js', array('every_page' => TRUE)); - $js_items = drupal_add_js(); + _drupal_add_js('core/misc/ajax.js'); + _drupal_add_js('core/misc/collapse.js', array('every_page' => TRUE)); + _drupal_add_js('core/misc/autocomplete.js'); + _drupal_add_js('core/misc/batch.js', array('every_page' => TRUE)); + $js_items = _drupal_add_js(); $javascript = drupal_get_js(); $expected = implode("\n", array( '', @@ -353,14 +353,14 @@ function testAggregation() { function testAggregationOrder() { // Enable JavaScript aggregation. \Drupal::config('system.performance')->set('js.preprocess', 1)->save(); - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); // Add two JavaScript files to the current request and build the cache. drupal_add_library('system', 'drupal'); - drupal_add_js('core/misc/ajax.js'); - drupal_add_js('core/misc/autocomplete.js'); + _drupal_add_js('core/misc/ajax.js'); + _drupal_add_js('core/misc/autocomplete.js'); - $js_items = drupal_add_js(); + $js_items = _drupal_add_js(); $scripts_html = array( '#type' => 'scripts', '#items' => array( @@ -376,14 +376,14 @@ function testAggregationOrder() { // Reset variables and add a file in a different scope first. \Drupal::state()->delete('system.js_cache_files'); - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); drupal_add_library('system', 'drupal'); - drupal_add_js('some/custom/javascript_file.js', array('scope' => 'footer')); - drupal_add_js('core/misc/ajax.js'); - drupal_add_js('core/misc/autocomplete.js'); + _drupal_add_js('some/custom/javascript_file.js', array('scope' => 'footer')); + _drupal_add_js('core/misc/ajax.js'); + _drupal_add_js('core/misc/autocomplete.js'); // Rebuild the cache. - $js_items = drupal_add_js(); + $js_items = _drupal_add_js(); $scripts_html = array( '#type' => 'scripts', '#items' => array( @@ -404,16 +404,16 @@ function testAggregationOrder() { */ function testRenderOrder() { // Add a bunch of JavaScript in strange ordering. - drupal_add_js('(function($){alert("Weight 5 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)); - drupal_add_js('(function($){alert("Weight 0 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer')); - drupal_add_js('(function($){alert("Weight 0 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer')); - drupal_add_js('(function($){alert("Weight -8 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8)); - drupal_add_js('(function($){alert("Weight -8 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8)); - drupal_add_js('(function($){alert("Weight -8 #3");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8)); - drupal_add_js('http://example.com/example.js?Weight -5 #1', array('type' => 'external', 'scope' => 'footer', 'weight' => -5)); - drupal_add_js('(function($){alert("Weight -8 #4");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8)); - drupal_add_js('(function($){alert("Weight 5 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)); - drupal_add_js('(function($){alert("Weight 0 #3");})(jQuery);', array('type' => 'inline', 'scope' => 'footer')); + _drupal_add_js('(function($){alert("Weight 5 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)); + _drupal_add_js('(function($){alert("Weight 0 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer')); + _drupal_add_js('(function($){alert("Weight 0 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer')); + _drupal_add_js('(function($){alert("Weight -8 #1");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8)); + _drupal_add_js('(function($){alert("Weight -8 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8)); + _drupal_add_js('(function($){alert("Weight -8 #3");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8)); + _drupal_add_js('http://example.com/example.js?Weight -5 #1', array('type' => 'external', 'scope' => 'footer', 'weight' => -5)); + _drupal_add_js('(function($){alert("Weight -8 #4");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => -8)); + _drupal_add_js('(function($){alert("Weight 5 #2");})(jQuery);', array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)); + _drupal_add_js('(function($){alert("Weight 0 #3");})(jQuery);', array('type' => 'inline', 'scope' => 'footer')); // Construct the expected result from the regex. $expected = array( @@ -449,7 +449,7 @@ function testRenderDifferentWeight() { // flag, then by weight (see drupal_sort_css_js()), so to test the effect of // weight, we need the other two options to be the same. drupal_add_library('system', 'jquery'); - drupal_add_js('core/misc/collapse.js', array('group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => -21)); + _drupal_add_js('core/misc/collapse.js', array('group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => -21)); $javascript = drupal_get_js(); $this->assertTrue(strpos($javascript, 'core/misc/collapse.js') < strpos($javascript, 'core/assets/vendor/jquery/jquery.js'), 'Rendering a JavaScript file above jQuery.'); } @@ -461,8 +461,8 @@ function testRenderDifferentWeight() { */ function testAlter() { // Add both tableselect.js and simpletest.js, with a larger weight on SimpleTest. - drupal_add_js('core/misc/tableselect.js'); - drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js', array('weight' => 9999)); + _drupal_add_js('core/misc/tableselect.js'); + _drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js', array('weight' => 9999)); // Render the JavaScript, testing if simpletest.js was altered to be before // tableselect.js. See simpletest_js_alter() to see where this alteration @@ -564,7 +564,7 @@ function testGetLibrary() { */ function testAddJsFileWithQueryString() { $js = drupal_get_path('module', 'node') . '/node.js'; - drupal_add_js($js); + _drupal_add_js($js); $query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0'; $scripts = drupal_get_js(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php index 12d02b0b7caa734c01393f19c4546a72e3fc2130..148dcdd33555532275696059c59d03a9fe398cdb 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php @@ -369,7 +369,7 @@ function testDrupalRenderChildrenAttached() { // Load the element from cache and verify the presence of the #attached // JavaScript. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $element = array('#cache' => array('keys' => array('simpletest', 'drupal_render', 'children_attached'))); $this->assertTrue(strlen(drupal_render($element)) > 0, 'The element was retrieved from cache.'); $scripts = drupal_get_js(); @@ -461,7 +461,7 @@ function testDrupalRenderPostRenderCache() { ); // #cache disabled. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $element = $test_element; $element['#markup'] = '

#cache disabled

'; $output = drupal_render($element); @@ -477,7 +477,7 @@ function testDrupalRenderPostRenderCache() { \Drupal::request()->setMethod('GET'); // GET request: #cache enabled, cache miss. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $element = $test_element; $element['#cache'] = array('cid' => 'post_render_cache_test_GET'); $element['#markup'] = '

#cache enabled, GET

'; @@ -501,7 +501,7 @@ function testDrupalRenderPostRenderCache() { $this->assertIdentical($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.'); // GET request: #cache enabled, cache hit. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $element['#cache'] = array('cid' => 'post_render_cache_test_GET'); $element['#markup'] = '

#cache enabled, GET

'; $output = drupal_render($element); @@ -518,7 +518,7 @@ function testDrupalRenderPostRenderCache() { \Drupal::request()->setMethod('POST'); // POST request: #cache enabled, cache miss. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $element = $test_element; $element['#cache'] = array('cid' => 'post_render_cache_test_POST'); $element['#markup'] = '

#cache enabled, POST

'; @@ -551,7 +551,7 @@ function testDrupalRenderChildrenPostRenderCache() { // Test case 1. // Create an element with a child and subchild. Each element has the same // #post_render_cache callback, but with different contexts. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $context_1 = array('foo' => $this->randomString()); $context_2 = array('bar' => $this->randomString()); $context_3 = array('baz' => $this->randomString()); @@ -621,7 +621,7 @@ function testDrupalRenderChildrenPostRenderCache() { $this->assertIdentical($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.'); // GET request: #cache enabled, cache hit. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $element = $test_element; $output = drupal_render($element); $this->assertIdentical($output, '

overridden

', 'Output is overridden.'); @@ -639,7 +639,7 @@ function testDrupalRenderChildrenPostRenderCache() { // #post_render_cache callbacks. I.e. the #post_render_cache callbacks may // not yet have run, or otherwise the cached parent element would contain // personalized data, thereby breaking the render cache. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $element = $test_element; $element['#cache']['keys'] = array('simpletest', 'drupal_render', 'children_post_render_cache', 'nested_cache_parent'); $element['child']['#cache']['keys'] = array('simpletest', 'drupal_render', 'children_post_render_cache', 'nested_cache_child'); @@ -699,7 +699,7 @@ function testDrupalRenderChildrenPostRenderCache() { $this->assertIdentical($cached_child_element, $expected_child_element, 'The correct data is cached for the child: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.'); // GET request: #cache enabled, cache hit, parent element. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $element = $test_element; $element['#cache']['keys'] = array('simpletest', 'drupal_render', 'children_post_render_cache', 'nested_cache_parent'); $output = drupal_render($element); @@ -711,7 +711,7 @@ function testDrupalRenderChildrenPostRenderCache() { $this->assertIdentical($settings['common_test'], $expected_settings, '#attached is modified; JavaScript settings for each #post_render_cache callback are added to page.'); // GET request: #cache enabled, cache hit, child element. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $element = $test_element; $element['child']['#cache']['keys'] = array('simpletest', 'drupal_render', 'children_post_render_cache', 'nested_cache_child'); $element = $element['child']; @@ -744,7 +744,7 @@ function testDrupalRenderRenderCachePlaceholder() { $expected_output = '' . $context['bar'] . ''; // #cache disabled. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $element = $test_element; $output = drupal_render($element); $this->assertIdentical($output, $expected_output, 'Placeholder was replaced in output'); @@ -756,7 +756,7 @@ function testDrupalRenderRenderCachePlaceholder() { \Drupal::request()->setMethod('GET'); // GET request: #cache enabled, cache miss. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $element = $test_element; $element['#cache'] = array('cid' => 'render_cache_placeholder_test_GET'); $output = drupal_render($element); @@ -785,7 +785,7 @@ function testDrupalRenderRenderCachePlaceholder() { $this->assertIdentical($cached_element, $expected_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by #post_render_cache callbacks.'); // GET request: #cache enabled, cache hit. - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); $element = $test_element; $element['#cache'] = array('cid' => 'render_cache_placeholder_test_GET'); $output = drupal_render($element); diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php index 1cea46aa05460b8982c5bd7afad45832ecb7b587..1a9d3d17254015d78cb53387b0cf4a98178c5e3e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php @@ -28,10 +28,10 @@ function testThemeTableStickyHeaders() { $header = array('one', 'two', 'three'); $rows = array(array(1,2,3), array(4,5,6), array(7,8,9)); $this->content = theme('table', array('header' => $header, 'rows' => $rows, 'sticky' => TRUE)); - $js = drupal_add_js(); + $js = _drupal_add_js(); $this->assertTrue(isset($js['core/misc/tableheader.js']), 'tableheader.js was included when $sticky = TRUE.'); $this->assertRaw('sticky-enabled', 'Table has a class of sticky-enabled when $sticky = TRUE.'); - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); } /** @@ -44,10 +44,10 @@ function testThemeTableNoStickyHeaders() { $caption = NULL; $colgroups = array(); $this->content = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes, 'caption' => $caption, 'colgroups' => $colgroups, 'sticky' => FALSE)); - $js = drupal_add_js(); + $js = _drupal_add_js(); $this->assertFalse(isset($js['core/misc/tableheader.js']), 'tableheader.js was not included because $sticky = FALSE.'); $this->assertNoRaw('sticky-enabled', 'Table does not have a class of sticky-enabled because $sticky = FALSE.'); - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_js'); } /** diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index cabea758d2d29e228986cdfad2b3edd97c233d87..1de6b1532d776962eb2f79e2f657de78b0616b8e 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -270,7 +270,7 @@ function hook_element_info_alter(&$type) { * @param $javascript * An array of all JavaScript being presented on the page. * - * @see drupal_add_js() + * @see _drupal_add_js() * @see drupal_get_js() * @see drupal_js_defaults() */ @@ -293,11 +293,11 @@ function hook_js_alter(&$javascript) { * version_compare() to compare different versions. * - 'js': An array of JavaScript elements; each element's key is used as $data * argument, each element's value is used as $options array for - * drupal_add_js(). To add library-specific (not module-specific) JavaScript + * _drupal_add_js(). To add library-specific (not module-specific) JavaScript * settings, the key may be skipped, the value must specify * 'type' => 'setting', and the actual settings must be contained in a 'data' * element of the value. - * - 'css': Like 'js', an array of CSS elements passed to drupal_add_css(). + * - 'css': Like 'js', an array of CSS elements passed to _drupal_add_css(). * - 'dependencies': An array of libraries that are required for a library. Each * element is an array listing the module and name of another library. Note * that all dependencies for each dependent library will also be added when @@ -390,7 +390,7 @@ function hook_library_info_alter(&$libraries, $module) { * @param $css * An array of all CSS items (files and inline CSS) being requested on the page. * - * @see drupal_add_css() + * @see _drupal_add_css() * @see drupal_get_css() */ function hook_css_alter(&$css) { @@ -2572,7 +2572,7 @@ function hook_install_tasks(&$install_state) { * * Elements available to be altered are only those added using * drupal_add_html_head_link() or drupal_add_html_head(). CSS and JS files - * are handled using drupal_add_css() and drupal_add_js(), so the head links + * are handled using _drupal_add_css() and _drupal_add_js(), so the head links * for those files will not appear in the $head_elements array. * * @param $head_elements diff --git a/core/modules/system/tests/modules/ajax_test/ajax_test.module b/core/modules/system/tests/modules/ajax_test/ajax_test.module index eba9efb532e3eb5868b30ecc4f039b39dba70e20..2ea9eb96f933382e793d5a7f6acc9824824e7fda 100644 --- a/core/modules/system/tests/modules/ajax_test/ajax_test.module +++ b/core/modules/system/tests/modules/ajax_test/ajax_test.module @@ -24,7 +24,7 @@ function ajax_test_system_theme_info() { * Menu callback: Returns an element suitable for use by ajax_render(). * * Additionally ensures that ajax_render() incorporates JavaScript settings - * generated during the page request by invoking drupal_add_js() with a dummy + * generated during the page request by invoking _drupal_add_js() with a dummy * setting. * * @deprecated \Drupal\ajax_test\Controller\AjaxTestController::render() diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTest.php index 29d3a216082aff6f4c9671f3b3fed10946ede9e5..dca282f237acb8ac83d6ce23c37a2d4c5e2703d7 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTest.php @@ -142,17 +142,17 @@ function testHeaderStorage() { $output = $view->preview(); drupal_render($output); unset($view->pre_render_called); - drupal_static_reset('drupal_add_css'); - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_css'); + drupal_static_reset('_drupal_add_js'); $view->destroy(); $view->setDisplay(); $output = $view->preview(); drupal_render($output); - $css = drupal_add_css(); + $css = _drupal_add_css(); $css_path = drupal_get_path('module', 'views_test_data') . '/views_cache.test.css'; $js_path = drupal_get_path('module', 'views_test_data') . '/views_cache.test.js'; - $js = drupal_add_js(); + $js = _drupal_add_js(); $this->assertTrue(isset($css[basename($css_path)]), 'Make sure the css is added for cached views.'); $this->assertTrue(isset($js[$js_path]), 'Make sure the js is added for cached views.'); @@ -176,15 +176,15 @@ function testHeaderStorage() { $output = $view->preview(); drupal_render($output); - drupal_static_reset('drupal_add_css'); - drupal_static_reset('drupal_add_js'); + drupal_static_reset('_drupal_add_css'); + drupal_static_reset('_drupal_add_js'); $view->destroy(); $output = $view->preview(); drupal_render($output); - $css = drupal_add_css(); - $js = drupal_add_js(); + $css = _drupal_add_css(); + $js = _drupal_add_js(); $this->assertFalse(isset($css['system.maintenance.css']), 'Make sure that unrelated css is not added.'); $this->assertFalse(isset($js[drupal_get_path('module', 'user') . '/user.permissions.js']), 'Make sure that unrelated js is not added.'); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/ViewsFormBase.php index cfb0a8bd89735175941736a09954947ef2123e23..2f1273c5f9ea406825e388378af5e3accbd3f62b 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/ViewsFormBase.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/ViewsFormBase.php @@ -122,11 +122,11 @@ public function getForm(ViewStorageInterface $view, $display_id, $js) { // With the below logic, we may end up rendering a form twice (or two forms // each sharing the same element ids), potentially resulting in - // drupal_add_js() being called twice to add the same setting. drupal_get_js() + // _drupal_add_js() being called twice to add the same setting. drupal_get_js() // is ok with that, but until ajax_render() is (http://drupal.org/node/208611), - // reset the drupal_add_js() static before rendering the second time. - $drupal_add_js_original = drupal_add_js(); - $drupal_add_js = &drupal_static('drupal_add_js'); + // reset the _drupal_add_js() static before rendering the second time. + $drupal_add_js_original = _drupal_add_js(); + $drupal_add_js = &drupal_static('_drupal_add_js'); $response = views_ajax_form_wrapper($form_state['form_id'], $form_state); // If the form has not been submitted, or was not set for rerendering, stop. diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewFormControllerBase.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewFormControllerBase.php index c938ce3b1ad67dadd07d469c00796d6b492ae826..2151a8954ec78e0567c46d997f9d6a853da17148 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewFormControllerBase.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewFormControllerBase.php @@ -73,8 +73,8 @@ protected function prepareEntity() { * * This returns an array of arrays. Each array represents a single * file. The array format is: - * - file: The fully qualified name of the file to send to drupal_add_css - * - options: An array of options to pass to drupal_add_css. + * - file: The fully qualified name of the file to send to _drupal_add_css + * - options: An array of options to pass to _drupal_add_css. */ public static function getAdminCSS() { $module_path = drupal_get_path('module', 'views_ui');