You are here

skinr_test.module in Skinr 7.2

Skinr testing module.

Other modules should be able to place their Skinr support/integration code into a conditionally loaded $module.skinr.inc file, so this .module file only exists, because Drupal requires a .module file to exist.

File

tests/skinr_test/skinr_test.module
View source
<?php

/**
 * @file
 * Skinr testing module.
 *
 * Other modules should be able to place their Skinr support/integration code
 * into a conditionally loaded $module.skinr.inc file, so this .module file
 * only exists, because Drupal requires a .module file to exist.
 */

/**
 * Implements hook_menu().
 */
function skinr_test_menu() {
  $items['skinr-test/current-theme-default'] = array(
    'title' => 'Test skinr_current_theme()',
    'page callback' => 'skinr_test_skinr_current_theme',
    'access arguments' => array(
      'access content',
    ),
  );
  $items['skinr-test/current-theme-callback'] = array(
    'title' => 'Test skinr_current_theme() with \'theme callback\'',
    'page callback' => 'skinr_test_skinr_current_theme',
    'access arguments' => array(
      'access content',
    ),
    'theme callback' => 'skinr_test_skinr_current_theme_callback',
  );
  $items['skinr-test/current-theme-hook-custom-theme'] = array(
    'title' => 'Test skinr_current_theme() with hook_custom_theme()',
    'page callback' => 'skinr_test_skinr_current_theme',
    'access arguments' => array(
      'access content',
    ),
  );
  $items['admin/skinr-test/current-theme-admin'] = array(
    'title' => 'Test skinr_current_theme() for admin theme',
    'page callback' => 'skinr_test_skinr_current_theme',
    'access arguments' => array(
      'access content',
    ),
  );
  $items['admin/skinr-test/current-theme-admin-exclude'] = array(
    'title' => 'Test skinr_current_theme() excluding admin theme',
    'page callback' => 'skinr_test_skinr_current_theme_admin_exclude',
    'access arguments' => array(
      'access content',
    ),
  );
  $items['skinr-test/hook-dynamic-loading'] = array(
    'title' => 'Test hook dynamic loading (skinr_hook)',
    'page callback' => 'skinr_test_hook_dynamic_loading',
    'access arguments' => array(
      'access content',
    ),
  );
  $items['skinr-test/skinr-implements-api'] = array(
    'title' => 'Test skinr_implements_api()',
    'page callback' => 'skinr_test_skinr_implements_api',
    'access arguments' => array(
      'access content',
    ),
  );
  return $items;
}

/**
 * Page callback for default 'skinr_current_theme' test.
 *
 * Displays the current theme.
 */
function skinr_test_skinr_current_theme() {
  return 'Current theme is ' . skinr_current_theme() . '.';
}

/**
 * Theme callback for skinr-test/current-theme-hook-custom-theme.
 */
function skinr_test_skinr_current_theme_callback() {
  return 'garland';
}

/**
 * Implements hook_custom_theme().
 */
function skinr_test_custom_theme() {
  if (current_path() == 'skinr-test/current-theme-hook-custom-theme') {
    return 'garland';
  }
}

/**
 * Page callback for 'skinr_current_theme' test.
 *
 * Displays the current theme.
 */
function skinr_test_skinr_current_theme_admin_exclude() {
  return 'Current theme is ' . skinr_current_theme(TRUE) . '.';
}

/**
 * Page callback for 'hook dynamic loading' test.
 *
 * If the hook is dynamically loaded correctly, the menu callback should
 * return 'success!'.
 */
function skinr_test_hook_dynamic_loading() {
  if (skinr_hook('skinr_test', 'skinr_group_info') && function_exists('skinr_test_skinr_group_info')) {
    return 'success!';
  }
  return 'failed!';
}

/**
 * Page callback for 'skinr_implements_api' test.
 *
 * If the hook is dynamically loaded correctly, the menu callback should
 * return a list of extensions.
 */
function skinr_test_skinr_implements_api() {
  $extensions = skinr_implements_api();
  $output = '';
  foreach ($extensions as $extension_name => $extension) {
    $output .= $extension_name . '<br />';
  }
  return $output;
}

/**
 * Implements hook_system_theme_info().
 *
 * @see http://drupal.org/node/953336
 */
function skinr_test_system_theme_info() {
  $path = drupal_get_path('module', 'skinr_test');
  $test_themes = array(
    'basetheme',
    'subtheme',
    'basetheme_other',
    'subtheme_other',
  );
  foreach ($test_themes as $theme) {
    $themes["skinr_test_{$theme}"] = $path . "/themes/skinr_test_{$theme}/skinr_test_{$theme}.info";
  }
  return $themes;
}

//
// Presave hooks
//

/**
 * Implements hook_skinr_skin_presave().
 */
function skinr_test_skinr_skin_presave() {
  $_SESSION['skinr_test'][] = __FUNCTION__ . ' called';
}

//
// Insert hooks
//

/**
 * Implements hook_skinr_skin_insert().
 */
function skinr_test_skinr_skin_insert() {
  $_SESSION['skinr_test'][] = __FUNCTION__ . ' called';
}

//
// Load hooks
//

/**
 * Implements hook_skinr_skin_load().
 */
function skinr_test_skinr_skin_load() {
  $_SESSION['skinr_test'][] = __FUNCTION__ . ' called';
}

//
// Update hooks
//

/**
 * Implements hook_skinr_skin_update().
 */
function skinr_test_skinr_skin_update() {
  $_SESSION['skinr_test'][] = __FUNCTION__ . ' called';
}

//
// Delete hooks
//

/**
 * Implements hook_skinr_skin_delete().
 */
function skinr_test_skinr_skin_delete() {
  $_SESSION['skinr_test'][] = __FUNCTION__ . ' called';
}

Functions

Namesort descending Description
skinr_test_custom_theme Implements hook_custom_theme().
skinr_test_hook_dynamic_loading Page callback for 'hook dynamic loading' test.
skinr_test_menu Implements hook_menu().
skinr_test_skinr_current_theme Page callback for default 'skinr_current_theme' test.
skinr_test_skinr_current_theme_admin_exclude Page callback for 'skinr_current_theme' test.
skinr_test_skinr_current_theme_callback Theme callback for skinr-test/current-theme-hook-custom-theme.
skinr_test_skinr_implements_api Page callback for 'skinr_implements_api' test.
skinr_test_skinr_skin_delete Implements hook_skinr_skin_delete().
skinr_test_skinr_skin_insert Implements hook_skinr_skin_insert().
skinr_test_skinr_skin_load Implements hook_skinr_skin_load().
skinr_test_skinr_skin_presave Implements hook_skinr_skin_presave().
skinr_test_skinr_skin_update Implements hook_skinr_skin_update().
skinr_test_system_theme_info Implements hook_system_theme_info().