You are here

function views_install in Views (for Drupal 7) 5

Same name and namespace in other branches
  1. 8.3 views.install \views_install()
  2. 6.3 views.install \views_install()
  3. 6.2 views.install \views_install()
  4. 7.3 views.install \views_install()

File

./views.install, line 3

Code

function views_install() {
  drupal_set_message('Installing views');
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      db_query("CREATE TABLE if not exists {view_view} (\n        vid int(10) unsigned NOT NULL default '0',\n        name varchar(32) NOT NULL UNIQUE,\n        description varchar(255),\n        access varchar(255),\n        -- page fields\n        page int(1),\n        page_title varchar(255),\n        page_header longtext,\n        page_header_format int(4) NOT NULL,\n        page_empty longtext,\n        page_empty_format int(4) NOT NULL,\n        page_footer longtext,\n        page_footer_format int(4) NOT NULL,\n        page_type varchar(20),\n        use_pager int(1),\n        nodes_per_page int(5),\n        url varchar(255),\n        -- menu fields\n        menu int(1),\n        menu_tab int(1),\n        menu_tab_weight int(4),\n        menu_title varchar(255),\n        menu_tab_default int(1),\n        menu_tab_default_parent_type varchar(10),\n        menu_parent_title varchar(255),\n        menu_parent_tab_weight int(4),\n        -- block fields\n        block int(1),\n        block_title varchar(255),\n        block_use_page_header int(1),\n        block_header longtext,\n        block_header_format int(4) NOT NULL,\n        block_use_page_footer int(1),\n        block_footer longtext,\n        block_footer_format int(4) NOT NULL,\n        block_use_page_empty int(1),\n        block_empty longtext,\n        block_empty_format int(4) NOT NULL,\n        block_type varchar(20),\n        nodes_per_block int(5),\n        block_more int(1),\n        -- breadcrumb\n        breadcrumb_no_home int(1), -- true means start breadcrumb trail from 'Home'.\n        -- other\n        changed int(11),\n        view_args_php longtext,\n        is_cacheable int(1),\n        PRIMARY KEY (vid),\n        KEY (name)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE if not exists {view_sort} (\n        vid int(10) unsigned NOT NULL default '0',\n        position int(2),\n        field varchar(255),\n        sortorder varchar(5),\n        options varchar(255),\n        tablename varchar(255),\n        KEY (vid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE if not exists {view_argument} (\n        vid int(10) unsigned NOT NULL default '0',\n        type varchar(255),\n        argdefault varchar(255),\n        title varchar(255),\n        options varchar(255),\n        position int(2),\n        wildcard varchar(32),\n        wildcard_substitution varchar(32),\n        KEY (vid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE if not exists {view_tablefield} (\n        vid int(10) unsigned NOT NULL default '0',\n        tablename varchar(255),\n        field varchar(255),\n        label varchar(255),\n        handler varchar(255),\n        sortable int(1),\n        defaultsort varchar(5),\n        options varchar(255),\n        position int(2),\n        KEY (vid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE if not exists {view_filter} (\n        vid int(10) unsigned NOT NULL default '0',\n        tablename varchar(255),\n        field varchar(255),\n        value longtext,\n        operator varchar(20),\n        options varchar(255),\n        position int(2),\n        KEY (vid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE if not exists {view_exposed_filter} (\n        vid int(10) unsigned NOT NULL default '0',\n        field varchar(255),\n        label varchar(255),\n        optional int(1),\n        is_default int(1),\n        operator int(1),\n        single int(1),\n        position int(2),\n        KEY (vid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE {cache_views} (\n        cid varchar(255) NOT NULL default '',\n        data longblob,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid),\n        INDEX expire (expire)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      $success = TRUE;
      break;
    case 'pgsql':
      db_query("CREATE TABLE {view_view} (\n        vid SERIAL,\n        name varchar(32) NOT NULL UNIQUE,\n        description varchar(255),\n        access varchar(255),\n        -- page fields\n        page smallint,\n        page_title varchar(255),\n        page_header text,\n        page_header_format smallint NOT NULL,\n        page_empty text,\n        page_empty_format smallint NOT NULL,\n        page_footer text,\n        page_footer_format smallint NOT NULL,\n        page_type varchar(20),\n        use_pager smallint,\n        nodes_per_page smallint, \n        url varchar(255),\n        -- menu fields\n        menu smallint,\n        menu_tab smallint,\n        menu_tab_weight smallint,\n        menu_title varchar(255),\n        menu_tab_default smallint,\n        menu_tab_default_parent_type varchar(10),\n        menu_parent_title varchar(255),\n        menu_parent_tab_weight smallint,\n        -- block fields\n        block smallint,\n        block_title varchar(255),\n        block_use_page_header smallint,\n        block_header text,\n        block_header_format smallint NOT NULL,\n        block_use_page_footer smallint,\n        block_footer text,\n        block_footer_format smallint NOT NULL,\n        block_use_page_empty smallint,\n        block_empty text,\n        block_empty_format smallint NOT NULL,\n        block_type varchar(20),\n        nodes_per_block smallint,\n        block_more smallint,\n        -- breadcrumb\n        breadcrumb_no_home smallint, -- true means start breadcrumb trail from 'Home'.\n        -- other\n        changed integer,\n        view_args_php text,\n        is_cacheable smallint,\n        PRIMARY KEY (vid)\n      )");
      db_query("CREATE INDEX {view_view}_name_idx ON {view_view} (name)");
      db_query("CREATE TABLE {view_sort} (\n        vid integer NOT NULL default '0',\n        position smallint,\n        field varchar(255),\n        sortorder varchar(5),\n        options varchar(255),\n        tablename varchar(255)\n      )");
      db_query("CREATE INDEX {view_sort}_vid_idx ON {view_sort} (vid)");
      db_query("CREATE TABLE {view_argument} (\n        vid integer NOT NULL default '0',\n        type varchar(255),\n        argdefault varchar(255),\n        title varchar(255),\n        options varchar(255),\n        position smallint,\n        wildcard varchar(32),\n        wildcard_substitution varchar(32)\n      )");
      db_query("CREATE INDEX {view_argument}_vid_idx ON {view_argument} (vid)");
      db_query("CREATE TABLE {view_tablefield} (\n        vid integer NOT NULL default '0',\n        tablename varchar(255),\n        field varchar(255),\n        label varchar(255),\n        handler varchar(255),\n        sortable smallint,\n        defaultsort varchar(5),\n        options varchar(255),\n        position smallint\n      )");
      db_query("CREATE INDEX {view_tablefield}_vid_idx ON {view_tablefield} (vid)");
      db_query("CREATE TABLE {view_filter} (\n        vid integer NOT NULL default '0',\n        tablename varchar(255),\n        field varchar(255),\n        value text,\n        operator varchar(20),\n        options varchar(255),\n        position smallint\n      )");
      db_query("CREATE INDEX {view_filter}_vid_idx ON {view_filter} (vid)");
      db_query("CREATE TABLE {view_exposed_filter} (\n        vid integer NOT NULL default '0',\n        field varchar(255),\n        label varchar(255),\n        optional smallint,\n        is_default smallint,\n        operator smallint,\n        single smallint,\n        position smallint\n      )");
      db_query("CREATE INDEX {view_exposed_filter}_vid_idx ON {view_exposed_filter} (vid)");
      db_query("CREATE TABLE {cache_views} (\n        cid varchar(255),\n        data bytea,\n        expire integer,\n        created integer,\n        headers text,\n        PRIMARY KEY (cid)\n      )");
      db_query("CREATE INDEX {cache_views}_expire_idx ON {cache_views} (expire)");
      $success = TRUE;
      break;
  }

  // End case
  db_query("UPDATE {system} SET weight = 10 WHERE name = 'views'");
  if ($success) {
    module_enable(array(
      'views_ui',
    ));
    drupal_set_message(t('Views module installed tables successfully.'));
  }
  else {
    drupal_set_message(t('The installation of views module was unsuccessful.'), 'error');
  }
}