views.install 6.64 KB
Newer Older
merlinofchaos's avatar
merlinofchaos committed
1 2 3 4 5 6 7
<?php

/**
 * @file
 * Contains install and update functions for Views.
 */

8 9
use Drupal\Core\Database\Database;

merlinofchaos's avatar
merlinofchaos committed
10 11 12 13 14 15 16 17 18 19
/**
 * Implements hook_install().
 */
function views_install() {
  db_query("UPDATE {system} SET weight = 10 WHERE name = 'views'");
}

/**
 * Implements hook_schema().
 */
20
function views_schema() {
merlinofchaos's avatar
merlinofchaos committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
  $schema['views_view'] = array(
    'description' => 'Stores the general data for a view.',
    'export' => array(
      'identifier' => 'view',
      'bulk export' => TRUE,
      'primary key' => 'vid',
      'default hook' => 'views_default_views',
      'admin_title' => 'human_name',
      'admin_description' => 'description',
      'api' => array(
        'owner' => 'views',
        'api' => 'views_default',
        'minimum_version' => '2',
        'current_version' => '3.0',
      ),
36
      'object' => 'Drupal\views\View',
merlinofchaos's avatar
merlinofchaos committed
37 38 39 40 41 42 43 44 45
      // the callback to load the displays
      'subrecords callback' => 'views_load_display_records',
      // the variable that holds enabled/disabled status
      'status' => 'views_defaults',
      // CRUD callbacks
      'create callback' => 'views_new_view',
      'save callback' => 'views_save_view',
      'delete callback' => 'views_delete_view',
      'export callback' => 'views_export_view',
46
      'status callback' => 'views_export_status',
merlinofchaos's avatar
merlinofchaos committed
47 48 49 50 51 52 53 54 55 56 57 58 59
      'cache defaults' => TRUE,
      'default cache bin' => 'cache_views',
    ),
    'fields' => array(
      'vid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The view ID of the field, defined by the database.',
        'no export' => TRUE,
      ),
      'name' => array(
        'type' => 'varchar',
60
        'length' => '128',
merlinofchaos's avatar
merlinofchaos committed
61 62 63 64
        'default' => '',
        'not null' => TRUE,
        'description' => 'The unique name of the view. This is the primary field views are loaded from, and is used so that views may be internal and not necessarily in the database. May only be alphanumeric characters plus underscores.',
      ),
65 66 67 68 69 70
      'human_name' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => 'A human readable name used to be displayed in the admin interface',
      ),
merlinofchaos's avatar
merlinofchaos committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84
      'description' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => 'A description of the view for the admin interface.',
      ),
      'tag' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => 'A tag used to group/sort views in the admin interface',
      ),
      'base_table' => array(
        'type' => 'varchar',
85
        'length' => '64',
merlinofchaos's avatar
merlinofchaos committed
86 87 88 89
        'default' => '',
        'not null' => TRUE,
        'description' => 'What table this view is based on, such as node, user, comment, or term.',
      ),
90
      'core' => array(
merlinofchaos's avatar
merlinofchaos committed
91 92
        'type' => 'int',
        'default' => 0,
93
        'description' => 'Stores the drupal core version of the view.',
merlinofchaos's avatar
merlinofchaos committed
94 95 96
      ),
    ),
    'primary key' => array('vid'),
97
    'unique keys' => array('name' => array('name')),
merlinofchaos's avatar
merlinofchaos committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
  );

  $schema['views_display'] = array(
    'description' => 'Stores information about each display attached to a view.',
    'fields' => array(
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The view this display is attached to.',
        'no export' => TRUE,
      ),
      'id' => array(
        'type' => 'varchar',
        'length' => '64',
        'default' => '',
        'not null' => TRUE,
        'description' => 'An identifier for this display; usually generated from the display_plugin, so should be something like page or page_1 or block_2, etc.',
      ),
      'display_title' => array(
        'type' => 'varchar',
        'length' => '64',
        'default' => '',
        'not null' => TRUE,
        'description' => 'The title of the display, viewable by the administrator.',
      ),
      'display_plugin' => array(
        'type' => 'varchar',
        'length' => '64',
        'default' => '',
        'not null' => TRUE,
        'description' => 'The type of the display. Usually page, block or embed, but is pluggable so may be other things.',
      ),
      'position' => array(
        'type' => 'int',
        'default' => 0,
        'description' => 'The order in which this display is loaded.',
      ),
      'display_options' => array(
138 139
        'type' => 'text',
        'size' => 'big',
merlinofchaos's avatar
merlinofchaos committed
140 141 142 143 144
        'description' => 'A serialized array of options for this display; it contains options that are generally only pertinent to that display plugin type.',
        'serialize' => TRUE,
        'serialized default' => 'a:0:{}',
      ),
    ),
145
    'primary key' => array('vid', 'id'),
merlinofchaos's avatar
merlinofchaos committed
146 147 148 149 150 151 152 153 154 155 156 157 158
    'indexes' => array('vid' => array('vid', 'position')),
  );

  $schema['cache_views'] = drupal_get_schema_unprocessed('system', 'cache');

  $schema['cache_views_data'] = drupal_get_schema_unprocessed('system', 'cache');
  $schema['cache_views_data']['description'] = 'Cache table for views to store pre-rendered queries, results, and display output.';
  $schema['cache_views_data']['fields']['serialized']['default'] = 1;

  return $schema;
}

/**
159
 * Implements hook_update_last_removed().
merlinofchaos's avatar
merlinofchaos committed
160
 */
161 162
function views_update_last_removed() {
  return 7301;
merlinofchaos's avatar
merlinofchaos committed
163
}
164 165 166 167 168

/**
 * Convert settings to the config system.
 */
function views_update_8000() {
169
  update_variables_to_config('views.settings', array(
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
    'views_ui_show_listing_filters' => 'ui.show.listing_filters',
    'views_ui_show_advanced_help_warning' => 'ui.show.advanced_help_warning',
    'views_ui_show_master_display' => 'ui.show.master_display',
    'views_ui_show_advanced_column' => 'ui.show.advanced_column',
    'views_ui_display_embed' => 'ui.show.display_embed',
    'views_ui_custom_theme' => 'ui.custom_theme',
    'views_exposed_filter_any_label' => 'exposed_filter_any_label',
    'views_ui_always_live_preview' => 'ui.always_live_preview',
    'views_ui_always_live_preview_button' => 'ui.always_live_preview_button',
    'views_ui_show_preview_information' => 'ui.show.preview_information',
    'views_ui_show_sql_query_where' => 'ui.show.sql_query.where',
    'views_ui_show_sql_query' => 'ui.show_sql.query.enabled',
    'views_ui_show_performance_statistics' => 'ui.show.performance_statistics',
    'views_show_additional_queries' => 'ui.show.additional_queries',
    'views_skip_cache' => 'skip_cache',
    'views_sql_signature' => 'sql_signature',
    'views_no_javascript' => 'no_javascript',
    'views_devel_output' => 'debug.output',
    'views_localization_plugin' => 'localization_plugin',
    'views_devel_region' => 'debug.region',
    'views_display_extenders' => 'display_extenders',
191
  ));
192
}