You are here

function wysiwyg_get_css in Wysiwyg 7.2

Same name and namespace in other branches
  1. 5.2 wysiwyg.module \wysiwyg_get_css()
  2. 5 wysiwyg.module \wysiwyg_get_css()
  3. 6.2 wysiwyg.module \wysiwyg_get_css()
  4. 6 wysiwyg.module \wysiwyg_get_css()

Retrieve stylesheets for HTML/IFRAME-based editors.

This assumes that the content editing area only needs stylesheets defined for the scope 'theme'.

When the stylesheets a theme uses are not yet known it will return a single URL pointing to a page which will gather the stylesheets so they can be loaded indirectly via import rules.

Note: if set to explicitly use the current admin theme by name, no access check on the 'view the administration theme' permission is performed.

Parameters

$theme: The id of a theme to get stylesheets for. Defaults to the current theme.

Return value

An array containing CSS files, including proper base path.

6 calls to wysiwyg_get_css()
wysiwyg_ckeditor_settings in editors/ckeditor.inc
Return runtime editor settings for a given wysiwyg profile.
wysiwyg_fckeditor_settings in editors/fckeditor.inc
Return runtime editor settings for a given wysiwyg profile.
wysiwyg_tinymce_settings in editors/tinymce.inc
Return runtime editor settings for a given wysiwyg profile.
wysiwyg_wymeditor_settings in editors/wymeditor.inc
Return runtime editor settings for a given wysiwyg profile.
wysiwyg_yui_settings in editors/yui.inc
Return runtime editor settings for a given wysiwyg profile.

... See full list

File

./wysiwyg.module, line 741

Code

function wysiwyg_get_css($theme = NULL) {

  // Default to the node edit theme, if the user has access.
  if (empty($theme)) {
    $theme = variable_get('node_admin_theme') && user_access('view the administration theme') ? variable_get('admin_theme') : variable_get('theme_default', 'bartik');
  }
  elseif ($theme == 'wysiwyg_theme_admin' && user_access('view the administration theme') && ($admin_theme = variable_get('admin_theme'))) {
    $theme = $admin_theme;
  }

  // Make sure the theme system is initialized.
  $themes = list_themes();
  if (!isset($themes[$theme])) {
    drupal_theme_initialize();
  }

  // Ensure the selected theme is enabled (or is the admin theme).
  if (!drupal_theme_access($theme)) {
    $theme = variable_get('theme_default', 'bartik');
  }
  $cached = cache_get('wysiwyg_css');
  $css = array();

  // Trigger a cache update if:
  // this is NOT the wysiwyg_theme page (avoid loop),
  // the cache is empty or does not have the current theme,
  // the CSS/JS cache-busting query string has changed,
  // or the theme's aggregation state has changed.
  $update_cache = strpos(current_path(), 'wysiwyg_theme/') === FALSE && (!$cached || (empty($cached->data[$theme]) || $cached->data[$theme]['aggregated'] !== variable_get('preprocess_css', FALSE)) || $cached->data['_css_js_query_string'] !== variable_get('css_js_query_string'));
  if ($update_cache) {

    // Make the client perform another request to update css caches.
    $css[] = url('wysiwyg_theme/' . $theme, array(
      'absolute' => TRUE,
    ));
  }
  elseif (!empty($cached->data[$theme])) {
    $css = $cached->data[$theme]['files'];
  }
  return $css;
}