You are here

function views_system_rebuild_theme_data in Views System 7.4

Same name and namespace in other branches
  1. 8 views_system.module \views_system_rebuild_theme_data()

Helper function to rebuild theme's data.

6 calls to views_system_rebuild_theme_data()
views_system_enable in ./views_system.install
Implements hook_enable().
views_system_flush_caches in ./views_system.module
Implements hook_flush_caches().
views_system_form_system_themes_admin_form_alter in ./views_system.module
Implements hook_form_FORM_ID_alter(); update data on themes page.
views_system_modules_disabled in ./views_system.module
Implements hook_modules_disabled().
views_system_modules_enabled in ./views_system.module
Implements hook_modules_enabled().

... See full list

File

./views_system.module, line 162
Extends the Views module and provides fields, filter criteria, and sort criteria for Modules/Themes/Theme engines.

Code

function views_system_rebuild_theme_data() {
  db_query("DELETE FROM {views_system} WHERE type = 'theme' OR type = 'theme_engine'");
  $default_theme = variable_get('theme_default', 'bartik');
  $admin_theme = variable_get('admin_theme', '0');
  $query = db_insert('views_system')
    ->fields(array(
    'admin_theme',
    'base_theme',
    'core',
    'datestamp',
    'default_theme',
    'description',
    'engine',
    'features',
    'filename',
    'files',
    'label',
    'mtime',
    'operations',
    'origin',
    'pathname',
    'php',
    'project',
    'project_status_url',
    'regions',
    'regions_hidden',
    'required',
    'required_by',
    'requires',
    'screenshot',
    'scripts',
    'settings',
    'stylesheets',
    'type',
    'version',
    'visible',
  ));
  $themes = system_rebuild_theme_data();
  foreach ($themes as $theme) {
    $core = preg_match('/^themes\\//i', $theme->filename);
    $contributed = !$core && isset($theme->info['project']);
    $data = array();
    $data['admin_theme'] = (int) ($theme->name == $admin_theme || $theme->name == $default_theme && $admin_theme == '0');
    $data['base_theme'] = !empty($theme->info['base theme']) ? $theme->info['base theme'] : '';
    $data['core'] = !empty($theme->info['core']) ? $theme->info['core'] : '';
    $data['datestamp'] = !empty($theme->info['datestamp']) ? (int) $theme->info['datestamp'] : NULL;
    $data['default_theme'] = (int) ($theme->name == $default_theme);
    $data['description'] = !empty($theme->info['description']) ? $theme->info['description'] : '';
    $data['engine'] = !empty($theme->info['engine']) ? $theme->info['engine'] : '';
    $data['features'] = !empty($theme->info['features']) ? serialize($theme->info['features']) : '';
    $data['filename'] = basename($theme->filename);
    $data['files'] = !empty($theme->info['files']) ? serialize($theme->info['files']) : '';
    $data['label'] = $theme->info['name'];
    $data['mtime'] = (int) $theme->info['mtime'];
    $data['operations'] = $theme->status ? 'admin/appearance/settings/' . $theme->name : '';
    $data['origin'] = $core ? 'core' : ($contributed ? 'contributed' : 'custom');
    $data['pathname'] = $theme->filename;
    $data['php'] = !empty($theme->info['php']) ? $theme->info['php'] : '';
    $data['project'] = !empty($theme->info['project']) ? $theme->info['project'] : '';
    $data['project_status_url'] = !empty($theme->info['project_status_url']) ? $theme->info['project_status_url'] : '';
    $data['regions'] = !empty($theme->info['regions']) ? serialize($theme->info['regions']) : '';
    $data['regions_hidden'] = !empty($theme->info['regions_hidden']) ? serialize($theme->info['regions_hidden']) : '';
    $data['required'] = !empty($theme->info['required']) ? (int) $theme->info['required'] : 0;
    $required_by = array();
    if (isset($theme->sub_themes)) {
      foreach ($theme->sub_themes as $name => $value) {
        $required_by[$name] = isset($themes[$name]->info['name']) ? $themes[$name]->info['name'] : $name;
      }
    }
    $data['required_by'] = !empty($required_by) ? serialize($required_by) : '';
    $requires = array();
    if (isset($theme->base_themes)) {
      foreach ($theme->base_themes as $name => $value) {
        $requires[$name] = isset($themes[$name]->info['name']) ? $themes[$name]->info['name'] : $name;
      }
    }
    $data['requires'] = !empty($requires) ? serialize($requires) : '';
    $data['screenshot'] = !empty($theme->info['screenshot']) && file_exists($theme->info['screenshot']) ? $theme->info['screenshot'] : '';
    $data['scripts'] = !empty($theme->info['scripts']) ? serialize($theme->info['scripts']) : '';
    $data['settings'] = !empty($theme->info['settings']) ? serialize($theme->info['settings']) : '';
    $data['stylesheets'] = !empty($theme->info['stylesheets']) ? serialize($theme->info['stylesheets']) : '';
    $data['type'] = $theme->type;
    $data['version'] = !empty($theme->info['version']) ? $theme->info['version'] : '';
    $data['visible'] = !empty($theme->info['hidden']) ? (int) (!$theme->info['hidden']) : 1;
    $query
      ->values($data);
  }
  $query
    ->execute();
}