You are here

function skinr_skin_info_process in Skinr 7.2

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 skinr_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 skinr_implements() for details.

1 call to skinr_skin_info_process()
skinr_get_skin_info in ./skinr.module
Retrieves all skins registered by modules and themes.

File

./skinr.module, line 1416
Handles core Skinr functionality.

Code

function skinr_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'] = skinr_skin_info_status_default($skin_infos[$skin_name]);
    _skinr_preprocess_attached($skin_infos[$skin_name]['attached'], $source);
    foreach ($skin_infos[$skin_name]['options'] as $option_name => $option) {
      if (isset($option['attached'])) {
        _skinr_preprocess_attached($skin_infos[$skin_name]['options'][$option_name]['attached'], $source);
      }

      // Validate class by running it through drupal_html_class().
      if (!is_array($skin_infos[$skin_name]['options'][$option_name]['class'])) {

        // Raise an error.
        watchdog('skinr', 'The class for option %option in skin %skin needs to be an array.', array(
          '%option' => $option_name,
          '%skin' => $skin_name,
        ), WATCHDOG_WARNING);

        // Reset to array to prevent errors.
        $skin_infos[$skin_name]['options'][$option_name]['class'] = array();
      }
      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);
      }
    }
  }
}