views.install 8.03 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
      // the callback to load the displays
38 39 40
      'load all callback' => 'views_get_all_views',
      'load callback' => 'views_storage_load',
      'save callback' => 'views_storage_save',
merlinofchaos's avatar
merlinofchaos committed
41 42 43 44 45 46 47 48
      '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',
49
      'status callback' => 'views_export_status',
merlinofchaos's avatar
merlinofchaos committed
50 51 52 53 54 55 56 57 58 59 60 61 62
      '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',
63
        'length' => '128',
merlinofchaos's avatar
merlinofchaos committed
64 65 66 67
        '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.',
      ),
68 69 70 71 72 73
      '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
74 75 76 77 78 79 80 81 82 83 84 85 86 87
      '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',
88
        'length' => '64',
merlinofchaos's avatar
merlinofchaos committed
89 90 91 92
        'default' => '',
        'not null' => TRUE,
        'description' => 'What table this view is based on, such as node, user, comment, or term.',
      ),
93
      'core' => array(
merlinofchaos's avatar
merlinofchaos committed
94 95
        'type' => 'int',
        'default' => 0,
96
        'description' => 'Stores the drupal core version of the view.',
merlinofchaos's avatar
merlinofchaos committed
97 98 99
      ),
    ),
    'primary key' => array('vid'),
100
    'unique keys' => array('name' => array('name')),
merlinofchaos's avatar
merlinofchaos committed
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 138 139 140
  );

  $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(
141 142
        'type' => 'text',
        'size' => 'big',
merlinofchaos's avatar
merlinofchaos committed
143 144 145 146 147
        '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:{}',
      ),
    ),
148
    'primary key' => array('vid', 'id'),
merlinofchaos's avatar
merlinofchaos committed
149 150 151 152 153 154 155 156 157
    '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;

158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
  $schema['temp_store'] = array(
    'description' => t('A temporary data store for objects that are being edited. Allows state to be saved in a stateless environment.'),
    'fields' => array(
      'owner_id' => array(
        'type' => 'varchar',
        'length' => '64',
        'not null' => TRUE,
        'description' => 'The session ID this object belongs to.',
      ),
      'subsystem' => array(
        'type' => 'varchar',
        'length' => '128',
        'not null' => TRUE,
        'description' => 'The owner (type of the object) for this data store. Allows multiple subsystems to use this data store.',
      ),
      'temp_key' => array(
        'type' => 'varchar',
        'length' => '128',
        'not null' => TRUE,
        'description' => 'The key of the object this data store is attached to.',
      ),
      'updated' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The time this data store was created or updated.',
      ),
      'data' => array(
        'type' => 'text',
        'size' => 'big',
        'description' => 'Serialized data being stored.',
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array('owner_id', 'subsystem', 'temp_key'),
    'indexes' => array('updated' => array('updated')),
  );

merlinofchaos's avatar
merlinofchaos committed
197 198 199 200
  return $schema;
}

/**
201
 * Implements hook_update_last_removed().
merlinofchaos's avatar
merlinofchaos committed
202
 */
203 204
function views_update_last_removed() {
  return 7301;
merlinofchaos's avatar
merlinofchaos committed
205
}
206 207 208 209 210

/**
 * Convert settings to the config system.
 */
function views_update_8000() {
211
  update_variables_to_config('views.settings', array(
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
    'views_ui_show_listing_filters' => 'ui.show.listing_filters',
    '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',
232
  ));
233
}