You are here

function fusion_apply_skin_info_process in Fusion Accelerator 7

Same name and namespace in other branches
  1. 7.2 fusion_apply/fusion_apply.module \fusion_apply_skin_info_process()

Parse a skin_infos array as returned from a skins plugin.

This function inserts any missing defaults and updates the stylesheet and script paths to be relative to Drupal's root.

@todo Merge into fusion_apply_get_skin_info() and remove this function.

Parameters

$skin_infos: An array of skins as returned from skin plugins.

$source: An associative array containing information about the source of the skin. See fusion_apply_implements() for details.

1 call to fusion_apply_skin_info_process()
fusion_apply_get_skin_info in fusion_apply/fusion_apply.module
Retrieves all skins registered by modules and themes.

File

fusion_apply/fusion_apply.module, line 797
Handles core Fusion Apply functionality.

Code

function fusion_apply_skin_info_process(&$skin_infos, $source) {
  foreach ($skin_infos as $skin_name => $skin_info) {

    // Populate default properties.
    $skin_infos[$skin_name] += array(
      'name' => '',
      'title' => '',
      'type' => 'checkboxes',
      'description' => '',
      'group' => 'general',
      'theme hooks' => array(
        '*',
      ),
      'attached' => array(),
      'options' => array(),
      'weight' => NULL,
      'default status' => 0,
      'status' => array(),
    );

    // Merge in name.
    $skin_infos[$skin_name]['name'] = $skin_name;

    // Merge in source information.
    $skin_infos[$skin_name]['source'] = $source;

    // Merge in default status for all themes.
    $skin_infos[$skin_name]['status'] = fusion_apply_skin_info_status_default($skin_infos[$skin_name]);

    // Add path to stylesheets.
    if (isset($skin_infos[$skin_name]['attached']['css'])) {
      _fusion_apply_add_path_to_files($skin_infos[$skin_name]['attached']['css'], $source['path']);
    }

    // Add path to scripts.
    if (isset($skin_infos[$skin_name]['attached']['js'])) {
      _fusion_apply_add_path_to_files($skin_infos[$skin_name]['attached']['js'], $source['path']);
    }
    foreach ($skin_infos[$skin_name]['options'] as $option_name => $option) {

      // Add path to stylesheets.
      if (isset($option['attached']['css'])) {
        _fusion_apply_add_path_to_files($skin_infos[$skin_name]['options'][$option_name]['attached']['css'], $source['path']);
      }

      // Add path to scripts.
      if (isset($option['attached']['js'])) {
        _fusion_apply_add_path_to_files($skin_infos[$skin_name]['options'][$option_name]['attached']['js'], $source['path']);
      }

      // Validate class by running it through drupal_html_class().
      if (!is_array($skin_infos[$skin_name]['options'][$option_name]['class'])) {
        $skin_infos[$skin_name]['options'][$option_name]['class'] = array(
          $skin_infos[$skin_name]['options'][$option_name]['class'],
        );
      }
      foreach ($skin_infos[$skin_name]['options'][$option_name]['class'] as $key => $class) {
        $skin_infos[$skin_name]['options'][$option_name]['class'][$key] = drupal_html_class($class);
      }
    }
  }
}