You are here

function skinr_process_info_files in Skinr 6

Themes are allowed to set Skinr styles in their .info files.

@todo Do we want to allow manual addition of styles? @todo Use DB caching. No need to keep processing things every page load.

2 calls to skinr_process_info_files()
skinr_form_alter in ./skinr.module
Implementation of hook_form_alter().
skinr_preprocess in ./skinr.module
Implementation of hook_preprocess().

File

./skinr.module, line 583

Code

function skinr_process_info_files() {
  static $cache = NULL;
  if (is_null($cache)) {
    $themes = list_themes();
    foreach ($themes as $theme) {
      $cache[$theme->name] = array(
        'options' => array(),
        'skins' => array(),
      );
      if (!empty($theme->info['skinr'])) {
        $info = (array) $theme->info['skinr'];

        // Store skinr options.
        if (!empty($info['options'])) {
          $cache[$theme->name]['options'] = $info['options'];
          unset($info['options']);
        }

        // Inherit skins from parent theme, if inherit_skins is set to true.
        if (!empty($cache[$theme->name]['options']['inherit_skins'])) {
          $info = array_merge(skinr_inherited_skins($theme->name, $themes), $info);
        }
        foreach ($info as $id => $skin) {
          $processed_skin = array(
            'title' => isset($skin['title']) ? $skin['title'] : '',
            'type' => isset($skin['type']) ? $skin['type'] : 'checkboxes',
            'description' => isset($skin['description']) ? $skin['description'] : '',
            'weight' => isset($skin['weight']) ? $skin['weight'] : NULL,
            'features' => isset($skin['features']) ? $skin['features'] : array(
              '*',
            ),
            'templates' => isset($skin['templates']) ? $skin['templates'] : array(),
            'options' => isset($skin['options']) ? $skin['options'] : array(),
            'stylesheets' => isset($skin['stylesheets']) ? $skin['stylesheets'] : array(),
            'scripts' => isset($skin['scripts']) ? $skin['scripts'] : array(),
          );
          $cache[$theme->name]['skins'][$id] = $processed_skin;
        }
      }
    }
  }
  return $cache;
}