You are here

content_theme_debugger.module in Content Theme 7

Same filename and directory in other branches
  1. 6 content_theme_debugger/content_theme_debugger.module

This module displays a list of modules which override the system default theme sorted by module's call-up.

File

content_theme_debugger/content_theme_debugger.module
View source
<?php

/**
 * @file
 * This module displays a list of modules which override the system default
 * theme sorted by module's call-up.
 */

/**
 * Implements hook_help().
 */
function content_theme_debugger_help($path, $arg) {
  switch ($path) {
    case 'admin/help#content_theme_debugger':
      $output = '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The Content Theme Debugger module Displays a list of modules which override the system default theme sorted by module\'s call-up. For more information, see the online handbook entry for <a href="@content_theme">Content Theme module</a>.', array(
        '@content_theme' => 'http://drupal.org/project/content_theme',
      )) . '</p>';
      return $output;
  }
}

/**
 * Implements hook_block_info().
 */
function content_theme_debugger_block_info() {
  $info = array();
  $info['content_theme_debugger'] = array(
    'info' => t('Content Theme Debugger'),
    'cache' => DRUPAL_NO_CACHE,
  );
  return $info;
}

/**
 * Implements hook_block_configure().
 */
function content_theme_debugger_block_configure($delta = '') {
  $form = array();
  if ($delta == 'content_theme_debugger') {
    $form['content_theme_debugger_blacklist'] = array(
      '#type' => 'textarea',
      '#title' => t('Blacklist'),
      '#description' => t('Enter one module per line of each modules that should not execute <em>hook_custom_theme()</em>. Example modules are <em>og</em> for the Organic Groups module and <em>views</em> for the Views module.'),
      '#default_value' => variable_get('content_theme_debugger_blacklist', "ctools\nog\nviews"),
    );
  }
  return $form;
}

/**
 * Implements hook_block_save().
 */
function content_theme_debugger_block_save($delta = '', $edit = array()) {
  if ($delta == 'content_theme_debugger') {
    variable_set('content_theme_debugger_blacklist', $edit['content_theme_debugger_blacklist']);
  }
}

/**
 * Implements hook_block_view().
 */
function content_theme_debugger_block_view($delta = '') {
  $block = array();
  if ($delta == 'content_theme_debugger') {
    $content_theme_debugger_blacklist = variable_get('content_theme_debugger_blacklist', "ctools\nog\nviews");
    $blacklist = preg_split("/\r\n|\n|\r|\\s/", $content_theme_debugger_blacklist, -1, PREG_SPLIT_NO_EMPTY);
    $items = array();
    $items[] = t('Default theme => !theme', array(
      '!theme' => variable_get('theme_default', 'bartik'),
    ));
    foreach (module_implements('custom_theme') as $module) {
      if (!in_array($module, $blacklist)) {
        $theme = module_invoke($module, 'custom_theme');
        if (is_null($theme)) {
          $items[] = t('Module !module => %theme', array(
            '!module' => $module,
            '%theme' => 'NULL',
          ));
        }
        else {
          if (empty($theme)) {
            $items[] = t("Module !module => ''", array(
              '!module' => $module,
            ));
          }
          else {
            if (is_array($theme)) {
              $items[] = t('Module !module => !theme', array(
                '!module' => $module,
                '!theme' => serialize($theme),
              ));
            }
            else {
              $items[] = t('Module !module => !theme', array(
                '!module' => $module,
                '!theme' => $theme,
              ));
            }
          }
        }
      }
    }
    $block['subject'] = t('Content Theme Debugger');
    $block['content'] = theme('item_list', array(
      'items' => $items,
    ));
  }
  return $block;
}