<?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/hook-dynamic-loading'] = array(
    'title' => 'Test hook dynamic loading (skinr_hook)',
    'page callback' => 'skinr_test_hook_dynamic_loading',
    'access arguments' => array('access content'),
  );
  return $items;
}

/**
 * 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!';
}

/**
 * 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');
}
