You are here

function themekey_set_debug_message in ThemeKey 6.4

Same name and namespace in other branches
  1. 6.2 themekey.module \themekey_set_debug_message()
  2. 6.3 themekey.module \themekey_set_debug_message()
  3. 7.3 themekey.module \themekey_set_debug_message()
  4. 7 themekey.module \themekey_set_debug_message()
  5. 7.2 themekey.module \themekey_set_debug_message()

Replacement for drupal_set_message() during ThemeKey's initialization. drupal_set_message() might call init_theme() too early, which causes ThemeKey to not switch the theme.

themekey_set_debug_message() put the untranslated messages on a stack and hands them over to drupal_set_message() on demand.

Parameters

$msg: the message as string. If the message is 'flush' all messages stored on the stack will be printed using drupal_set_message()

$placeholder: associative array of string replacments for $msg @see t()

$translate: boolean, if set to TRUE $msg will be handled by t() when handed over to drupal_set_message()

6 calls to themekey_set_debug_message()
themekey_check_theme_enabled in ./themekey_base.inc
Checks if a theme is enabled and fires warning messages to the site's administrator
themekey_debug_properties in ./themekey_debug.module
Iterates over all ThemeKey Properties and prints out their current values.
themekey_footer in ./themekey.module
Implements hook_footer().
themekey_init in ./themekey.module
Implements hook_init().
themekey_match_condition in ./themekey_base.inc
Detects if a ThemeKey rule matches to the current page request.

... See full list

File

./themekey.module, line 238
ThemeKey is designed as a generic theme switching module.

Code

function themekey_set_debug_message($msg, $placeholder = array(), $translate = TRUE) {
  static $msg_stack = array();
  global $user, $theme;
  if (1 == $user->uid || variable_get('themekey_debug_non_admin_users', FALSE)) {
    if ('flush' == $msg) {
      $messages = array();
      if (variable_get('themekey_debug_trace_rule_switching', FALSE)) {
        $messages[] = t('Current theme: %theme', array(
          '%theme' => $theme,
        ));
      }
      foreach ($msg_stack as $key => $msg) {
        $messages[] = $msg['translate'] ? t($msg['msg'], $msg['placeholder']) : $msg['msg'];
        unset($msg_stack[$key]);
      }
      if (!empty($messages)) {
        return theme('themekey_debug_messages', $messages);
      }
    }
    else {
      $msg_stack[] = array(
        'msg' => $msg,
        'placeholder' => $placeholder,
        'translate' => $translate,
      );
    }
  }
}