t('Better Messages settings'), 'description' => t('Better handling of Drupal messages UI'), 'page callback' => 'drupal_get_form', 'page arguments' => array('better_messages_admin'), 'access callback' => 'user_access', 'access arguments' => array('administer site configuration'), 'file' => 'better_messages.inc', ); return $items; } /** * Implementation of hook_perm(). */ function better_messages_perm() { return array('access better messages'); } /* Implementation of hook_theme */ function better_messages_theme() { return array( 'better_messages_content' => array( 'arguments' => array('display' => null), ), 'better_messages_skin' => array( 'template' => 'better_messages', 'arguments' => array('content' => null), ), ); } /* Help function to scan for skins */ function better_messages_get_skins() { $default_theme = variable_get('theme_default', 'none'); // Call skins in modules skins directory $default_skins_directory = drupal_get_path('module', 'better_messages') .'/skins'; $files = file_scan_directory($default_skins_directory, '\.css$'); // Now we call skins in the default theme skins directory $theme_skins_directory = drupal_get_path('theme', $default_theme) . '/skins'; $theme_files = file_scan_directory($theme_skins_directory, '\.css$'); // Merge the options and make the names readable. $files = array_merge($files, $theme_files); $skins = array(); foreach ($files as $file) { $skins[$file->filename] = drupal_ucfirst($file->name); } ksort($skins); return $skins; } /* Implementation of hook_theme_registry_alter to add better_messages theme function */ function better_messages_theme_registry_alter(&$theme_registry) { $theme_registry['status_messages']['function'] = "theme_better_messages"; } function theme_better_messages($display = NULL) { $output = ''; $better_messages = better_messages_process_visibility(); $access = user_access('access better messages'); $message = drupal_get_messages($display, false); if ($better_messages && $access && !empty($message)) { $disable_autoclose = array_key_exists('error', $message); better_messages_add_files($disable_autoclose); $message = theme('better_messages_content', $display); // We save the intial output to SESSION so we can put it in