You are here

function skinr_preprocess in Skinr 6.2

Same name and namespace in other branches
  1. 8.2 skinr.module \skinr_preprocess()
  2. 6 skinr.module \skinr_preprocess()
  3. 7.2 skinr.module \skinr_preprocess()

Implementation of hook_preprocess().

1 call to skinr_preprocess()
skinr_fieldgroup_view in modules/fieldgroup.skinr.inc
Implementation of hook_fieldgroup_view().

File

./skinr.module, line 34

Code

function skinr_preprocess(&$vars, $hook) {

  // Fix for update script.
  if (defined('MAINTENANCE_MODE')) {
    return;
  }
  static $data = NULL;

  // Caching the data returned from the following functions is reported to
  // improve performance.
  if (is_null($data)) {

    // Let's make sure this has been run. There have been problems where other
    // modules implement a theme function in their hook_init(), so we make doubly
    // sure that the includes are included.
    skinr_init();
    $data['current_theme'] = skinr_current_theme();
    $data['skinr_config'] = skinr_fetch_config();
    $data['theme_registry'] = theme_get_registry();
  }
  $original_hook = $hook;
  if (isset($data['theme_registry'][$hook]['original hook'])) {
    $original_hook = $data['theme_registry'][$hook]['original hook'];
  }
  foreach ($data['skinr_config'] as $module => $settings) {
    if (!empty($settings['preprocess'][$original_hook])) {
      $preprocess_settings = $settings['preprocess'][$original_hook];
      $sids = skinr_handler('preprocess_index_handler', 'preprocess', $preprocess_settings['index_handler'], $vars);
      if ($extracted = skinr_skin_extract($module, $sids, $settings, $data['current_theme'])) {
        foreach ($extracted['css'] as $file) {
          if ($file['enabled']) {
            _skinr_add_file($file['path'], 'css', $file['media']);
          }
        }
        foreach ($extracted['js'] as $file) {
          if ($file['enabled']) {
            _skinr_add_file($file['path'], 'js');
          }
        }
        if (!empty($extracted['template'])) {
          $vars['template_files'][] = $extracted['template'];
        }
        $vars['skinr'] = implode(' ', $extracted['classes']);
        $vars['skinr_array'] = $extracted['classes'];

        // Need to add a hook for skinr_ui to plug into.
        $context = array(
          'hook' => $hook,
          'vars' => &$vars,
          'skin' => &$extracted,
        );
        drupal_alter('skinr_preprocess', $context);

        // Reset styles to make sure all are included.
        $vars['styles'] = drupal_get_css();
        $vars['scripts'] = drupal_get_js();
      }
    }
  }
}