Commit fb9c1df0 authored by Dries's avatar Dries
Browse files

- Patch #328357 by bleen18, sun, skilip, alanburke, jenlampton, manarth, fgm,...

- Patch #328357 by bleen18, sun, skilip, alanburke, jenlampton, manarth, fgm, tstoeckler: allow module .info files to add CSS/JS.
parent 8e51c3b2
......@@ -604,9 +604,7 @@ function list_themes($refresh = FALSE) {
}
}
foreach ($theme->info['scripts'] as $script => $path) {
if (file_exists($path)) {
$theme->scripts[$script] = $path;
}
$theme->scripts[$script] = $path;
}
if (isset($theme->info['engine'])) {
$theme->engine = $theme->info['engine'];
......@@ -2274,6 +2272,7 @@ function template_preprocess_page(&$variables) {
$variables['theme_hook_suggestions'] = $suggestions;
}
}
/**
* Process variables for html.tpl.php
*
......
......@@ -13,3 +13,4 @@ files[] = aggregator.processor.inc
files[] = aggregator.install
files[] = aggregator.test
configure = admin/config/services/aggregator/settings
stylesheets[all][] = aggregator.css
......@@ -282,13 +282,6 @@ function _aggregator_category_title($category) {
return $category['title'];
}
/**
* Implements hook_init().
*/
function aggregator_init() {
drupal_add_css(drupal_get_path('module', 'aggregator') . '/aggregator.css', array('preprocess' => TRUE));
}
/**
* Find out whether there are any aggregator categories.
*
......
......@@ -10,3 +10,4 @@ files[] = book.pages.inc
files[] = book.install
files[] = book.test
configure = admin/content/book/settings
stylesheets[all][] = book.css
......@@ -214,13 +214,6 @@ function book_admin_paths() {
return $paths;
}
/**
* Implements hook_init().
*/
function book_init() {
drupal_add_css(drupal_get_path('module', 'book') . '/book.css', array('preprocess' => TRUE));
}
/**
* Implements hook_entity_info_alter().
*/
......
......@@ -12,3 +12,4 @@ files[] = comment.install
files[] = comment.test
files[] = comment.tokens.inc
configure = admin/content/comment
stylesheets[all][] = comment.css
......@@ -289,13 +289,6 @@ function comment_menu() {
return $items;
}
/**
* Implements hook_init().
*/
function comment_init() {
drupal_add_css(drupal_get_path('module', 'comment') . '/comment.css', array('preprocess' => TRUE));
}
/**
* Implements hook_menu_alter().
*/
......
......@@ -15,3 +15,4 @@ files[] = field.form.inc
files[] = tests/field.test
dependencies[] = field_sql_storage
required = TRUE
stylesheets[all][] = theme/field.css
......@@ -168,13 +168,6 @@ function field_theme() {
);
}
/**
* Implements hook_init().
*/
function field_init() {
drupal_add_css(drupal_get_path('module', 'field') . '/theme/field.css', array('preprocess' => TRUE));
}
/**
* Implements hook_cron().
*
......
......@@ -12,3 +12,4 @@ files[] = forum.pages.inc
files[] = forum.install
files[] = forum.test
configure = admin/structure/forum
stylesheets[all][] = forum.css
......@@ -217,13 +217,6 @@ function forum_menu_local_tasks_alter(&$data, $router_item, $root_path) {
}
}
/**
* Implements hook_init().
*/
function forum_init() {
drupal_add_css(drupal_get_path('module', 'forum') . '/forum.css', array('preprocess' => TRUE));
}
/**
* Implements hook_entity_info_alter().
*/
......
......@@ -13,3 +13,4 @@ files[] = node.test
files[] = node.tokens.inc
required = TRUE
configure = admin/structure/types
stylesheets[all][] = node.css
......@@ -2012,13 +2012,6 @@ function _node_custom_theme() {
}
}
/**
* Implements hook_init().
*/
function node_init() {
drupal_add_css(drupal_get_path('module', 'node') . '/node.css', array('preprocess' => TRUE));
}
function node_last_changed($nid) {
return db_query('SELECT changed FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetch()->changed;
}
......
......@@ -9,3 +9,4 @@ files[] = poll.pages.inc
files[] = poll.install
files[] = poll.test
files[] = poll.tokens.inc
stylesheets[all][] = poll.css
......@@ -27,13 +27,6 @@ function poll_help($path, $arg) {
}
}
/**
* Implements hook_init().
*/
function poll_init() {
drupal_add_css(drupal_get_path('module', 'poll') . '/poll.css', array('preprocess' => TRUE));
}
/**
* Implements hook_theme().
*/
......
......@@ -11,3 +11,4 @@ files[] = search.install
files[] = search.test
files[] = search.extender.inc
configure = admin/config/search/settings
stylesheets[all][] = search.css
......@@ -97,13 +97,6 @@ function search_help($path, $arg) {
}
}
/**
* Implements hook_init().
*/
function search_init() {
drupal_add_css(drupal_get_path('module', 'search') . '/search.css', array('preprocess' => TRUE));
}
/**
* Implements hook_theme().
*/
......
......@@ -580,6 +580,27 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase {
$this->assertEqual(array(), drupal_add_css(), t('Default CSS is empty.'));
}
/**
* Test that stylesheets in module .info files are loaded.
*/
function testModuleInfo() {
$this->drupalGet('');
// Verify common_test.css in a STYLE media="all" tag.
$elements = $this->xpath('//style[@media=:media and contains(text(), :filename)]', array(
':media' => 'all',
':filename' => 'tests/common_test.css',
));
$this->assertTrue(count($elements), "Stylesheet with media 'all' in module .info file found.");
// Verify common_test.print.css in a STYLE media="print" tag.
$elements = $this->xpath('//style[@media=:media and contains(text(), :filename)]', array(
':media' => 'print',
':filename' => 'tests/common_test.print.css',
));
$this->assertTrue(count($elements), "Stylesheet with media 'print' in module .info file found.");
}
/**
* Tests adding a file stylesheet.
*/
......
......@@ -5,4 +5,6 @@ package = Testing
version = VERSION
core = 7.x
files[] = common_test.module
stylesheets[all][] = common_test.css
stylesheets[print][] = common_test.print.css
hidden = TRUE
......@@ -1441,9 +1441,10 @@ function hook_boot() {
* used to set up global parameters which are needed later in the request.
* when this hook is called, all modules are already loaded in memory.
*
* For example, this hook is a typical place for modules to add CSS or JS
* that should be present on every page. This hook is not run on cached
* pages - though CSS or JS added this way will be present on a cached page.
* This hook is not run on cached pages.
*
* To add CSS or JS that should be present on all pages, modules should not
* implement this hook, but declare these files in their .info file.
*/
function hook_init() {
drupal_add_css(drupal_get_path('module', 'book') . '/book.css');
......@@ -3955,7 +3956,7 @@ function hook_filetransfer_backends() {
/**
* Control site status before menu dispatching.
*
* The hook is called after checking whether the site is offline but before
* The hook is called after checking whether the site is offline but before
* the current router item is retrieved and executed by
* menu_execute_active_handler(). If the site is in offline mode,
* $menu_site_status is set to MENU_SITE_OFFLINE.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment