You are here

function biblio_install in Bibliography Module 5

Same name and namespace in other branches
  1. 6.2 biblio.install \biblio_install()
  2. 6 biblio.install \biblio_install()
  3. 7.3 biblio.install \biblio_install()
  4. 7 biblio.install \biblio_install()
  5. 7.2 biblio.install \biblio_install()

File

./biblio.install, line 2

Code

function biblio_install() {
  $result = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $result[] = db_query("alter table {node} modify title varchar(255);");
      $result[] = db_query("alter table {node_revisions} modify title varchar(255);");
      $result[] = db_query("CREATE TABLE {biblio} (\n        `nid` int(10) NOT NULL default '0',\n        `vid` int(10) NOT NULL default '0',\n        `biblio_type` int(11) NOT NULL default '0',\n        `biblio_number` varchar(10) default NULL,\n        `biblio_section` varchar(10) default NULL,\n        `biblio_other_number` varchar(24) default NULL,\n        `biblio_secondary_title` varchar(255) default NULL,\n        `biblio_tertiary_title` varchar(255) default NULL,\n        `biblio_short_title` varchar(255) default NULL,\n        `biblio_alternate_title` varchar(255) default NULL,\n        `biblio_translated_title` varchar(255) default NULL,\n        `biblio_authors` varchar(255) default NULL,\n        `biblio_secondary_authors` varchar(255) default NULL,\n        `biblio_tertiary_authors` varchar(255) default NULL,\n        `biblio_corp_author` varchar(255) default NULL,\n        `biblio_other_author_affiliations` varchar(255) default NULL,\n        `biblio_edition` varchar(255) default NULL,\n        `biblio_publisher` varchar(255) default NULL,\n        `biblio_original_publication` varchar(255) default NULL,\n        `biblio_reprint_edition` varchar(255) default NULL,\n        `biblio_place_published` varchar(255) default NULL,\n        `biblio_year` int(11) NOT NULL default '9999',\n        `biblio_volume` varchar(10) default NULL,\n        `biblio_number_of_volumes` varchar(10) default NULL,\n        `biblio_pages` varchar(128) default NULL,\n        `biblio_date` varchar(16) default NULL,\n        `biblio_isbn` varchar(24) default NULL,\n        `biblio_issn` varchar(24) default NULL,\n        `biblio_lang` varchar(24) default 'eng',\n        `biblio_abst_e` text,\n        `biblio_abst_f` text,\n        `biblio_full_text` tinyint(4) default '0',\n        `biblio_keywords` varchar(255) default NULL,\n        `biblio_url` varchar(255) default NULL,\n        `biblio_doi` varchar(100) default NULL,\n        `biblio_issue` varchar(10) default NULL,\n        `biblio_type_of_work` varchar(255) default NULL,\n        `biblio_accession_number` varchar(24) default NULL,\n        `biblio_call_number` varchar(24) default NULL,\n        `biblio_notes` text,\n        `biblio_coins` text,\n        `biblio_research_notes` text,\n        `biblio_custom1` text,\n        `biblio_custom2` text,\n        `biblio_custom3` text,\n        `biblio_custom4` text,\n        `biblio_custom5` text,\n        `biblio_custom6` text,\n        `biblio_custom7` text,\n        `biblio_auth_address` text,\n        `biblio_remote_db_name` varchar(255) default NULL,\n        `biblio_remote_db_provider` varchar(255) default NULL,\n        `biblio_citekey` varchar(16) default NULL,\n        `biblio_label` varchar(255) default NULL,\n        `biblio_access_date` varchar(255) default NULL,\n       PRIMARY KEY  (`vid`),\n        KEY `nid` (`nid`),\n        KEY `type` (`biblio_type`),\n        KEY `year` (`biblio_year`),\n        FULLTEXT KEY `keywords` (`biblio_keywords`),\n        FULLTEXT KEY `publisher` (`biblio_publisher`),\n        FULLTEXT KEY `authors` (`biblio_authors`)\n      )  /*!40100 ENGINE=MyISAM DEFAULT CHARACTER SET utf8 */;");
      $result[] = db_query("CREATE TABLE {biblio_author_index} (\n                  `aid` int(11) NOT NULL default '0',\n                  `author` varchar(100) NOT NULL default '',\n                  PRIMARY KEY  (`aid`)\n      ) /*!40100 DEFAULT CHARSET=utf8 */;");
      $result[] = db_query("CREATE TABLE {biblio_has_author} (\n                  `nid` int(11) NOT NULL default '0',\n                  `aid` int(11) NOT NULL default '0',\n                  `rank` int(11) NOT NULL default '0',\n                  PRIMARY KEY  (`nid`,`aid`,`rank`)\n      ) /*!40100 DEFAULT CHARSET=utf8 */;");
      $result[] = db_query("CREATE TABLE {biblio_fields} (\n        `fid` int(11) NOT NULL default '0',\n        `name` varchar(128) NOT NULL default '',\n        `title` varchar(128) NOT NULL default '',\n        `common` tinyint(1) NOT NULL default '0',\n        `type` varchar(128) NOT NULL default '',\n        `size` int(11) NOT NULL default '0',\n        `maxsize` int(11) NOT NULL default '0',\n        `hint` varchar(255) default '',\n        `required` tinyint(1) NOT NULL default '0',\n        `autocomplete` tinyint(1) NOT NULL default '0',\n        `visible` tinyint(4) NOT NULL default '0',\n        `weight` int(11) NOT NULL default '0',\n        PRIMARY KEY  (`fid`)\n      )  /*!40100 DEFAULT CHARACTER SET utf8 */;");
      $result[] = db_query("INSERT INTO {biblio_fields} (`fid`,`name`,`title`,`common`,`type`,`size`,`maxsize`,`hint`,`required`,`visible`,`autocomplete`,`weight`) VALUES\n       (1,'biblio_authors','Authors',1,'textfield',60,255,'Author names must be separated by semicolons',1,0,0,1),\n       (2,'biblio_secondary_authors','Secondary Authors',0,'textfield',60,255,'',0,0,0,21),\n       (3,'biblio_tertiary_authors','Tertiary Authors',0,'textfield',60,255,'',0,0,0,26),\n       (4,'biblio_corp_author','Corporate Author',0,'textfield',60,255,'',0,0,1,25),\n       (5,'biblio_secondary_title','Secondary Title',0,'textfield',60,255,'',0,0,1,12),\n       (6,'biblio_tertiary_title','Tertiary Title',0,'textfield',60,255,'',0,0,1,13),\n       (7,'biblio_accession_number','Accession Number',1,'textfield',24,24,'',0,0,0,151),\n       (8,'biblio_isbn','ISBN Number',1,'textfield',24,24,'',0,0,0,150),\n       (9,'biblio_call_number','Call Number',1,'textfield',24,24,'',0,0,0,152),\n       (10,'biblio_other_number','Other Numbers',1,'textfield',10,24,'',0,0,0,153),\n       (11,'biblio_other_author_affiliations','Other Author Affiliations',0,'textfield',60,255,'',0,0,0,24),\n       (12,'biblio_publisher','Publisher',0,'textfield',60,255,'',0,0,1,19);");
      $result[] = db_query("INSERT INTO {biblio_fields} (`fid`,`name`,`title`,`common`,`type`,`size`,`maxsize`,`hint`,`required`,`visible`,`autocomplete`,`weight`) VALUES\n       (13,'biblio_place_published','Place Published',0,'textfield',60,255,'',0,0,1,20),\n       (14,'biblio_year','Year of Publication',1,'textfield',9,9,'(Submitted, In Press or YYYY)',1,0,0,-45),\n       (15,'biblio_edition','Edition',0,'textfield',60,255,'',0,0,0,15),\n       (16,'biblio_volume','Volume',0,'textfield',10,10,'',0,0,0,14),\n       (17,'biblio_number','Number',0,'textfield',10,10,'',0,0,0,16),\n       (18,'biblio_pages','Pagination',0,'textfield',24,128,'',0,0,0,17),\n       (19,'biblio_date','Date Published',0,'textfield',16,16,'(mm/yyyy)',0,0,0,18),\n       (20,'biblio_lang','Publication Language',0,'textfield',24,24,'',0,0,0,23),\n       (21,'biblio_abst_e','Abstract',1,'textarea',60,65535 ,'',0,0,0,155),\n       (22,'biblio_abst_f','French Abstract',0,'textarea',60,65535 ,'',0,0,0,156),\n       (23,'biblio_keywords','Key Words',1,'textfield',60,255,'',0,0,0,154),\n       (24,'biblio_type_of_work','Type of Work',0,'textfield',60,255,'Masters Thesis, PhD Thesis, etc.',0,0,0,22),\n       (25,'biblio_url','URL',1,'textfield',60,255,'',0,0,0,158);");
      $result[] = db_query("INSERT INTO {biblio_fields} (`fid`,`name`,`title`,`common`,`type`,`size`,`maxsize`,`hint`,`required`,`visible`,`autocomplete`,`weight`) VALUES\n       (26,'biblio_notes','Notes',1,'textarea',60,65535 ,'',0,0,0,157),\n       (27,'biblio_issue','Issue',0,'textfield',10,10,'',0,0,0,15),\n       (28,'biblio_research_notes','Reseach Notes',0,'textarea',60,65535 ,'',0,0,0,160),\n       (29,'biblio_custom1','Custom 1',0,'textarea',60,65535,'',0,0,0,161),\n       (30,'biblio_custom2','Custom 2',0,'textarea',60,65535,'',0,0,0,162),\n       (31,'biblio_custom3','Custom 3',0,'textarea',60,65535,'',0,0,0,163),\n       (32,'biblio_custom4','Custom 4',0,'textarea',60,65535,'',0,0,0,164),\n       (33,'biblio_custom5','Custom 5',0,'textarea',60,65535,'',0,0,0,165),\n       (34,'biblio_custom6','Custom 6',0,'textarea',60,65535,'',0,0,0,167),\n       (35,'biblio_custom7','Custom 7',0,'textarea',60,65535,'',0,0,0,168),\n       (36,'biblio_number_of_volumes','Number of Volumes',0,'textfield',10,10,'',0,0,0,15),\n       (37,'biblio_short_title','Short Title',0,'textfield',60,255,'',0,0,0,169),\n       (38,'biblio_alternate_title','Alternate Title',0,'textfield',60,255,'',0,0,0,170),\n       (39,'biblio_translated_title','Translated Title',0,'textfield',60,255,'',0,0,0,170),\n       (40,'biblio_original_publication','Original Publication',0,'textfield',60,255,'',0,0,0,171),\n       (41,'biblio_reprint_edition','Reprint Edition',0,'textfield',120,255,'',0,0,0,172),\n       (42,'biblio_section','Section',0,'textfield',10,10,'',0,0,0,15),\n       (43,'biblio_citekey','Citation Key',0,'textfield',16,16,'',0,0,1,175),\n       (44,'biblio_coins','COinS Data',1,'textarea',60,65535 ,'This will be automatically generated, only edit if you know what you are doing.',0,0,0,176),\n       (45,'biblio_issn','ISSN Number',1,'textfield',24,24,'',0,0,0,150),\n       (46,'biblio_doi','DOI',1,'textfield',60,255,'',0,0,0,159),\n       (47,'biblio_auth_address','Author Address',0,'textarea',60,65535,'',0,0,0,178),\n       (48,'biblio_remote_db_name','Remote Database Name',0,'textfield',60,255,'',0,0,0,176),\n       (49,'biblio_remote_db_provider','Remote Database Provider',0,'textfield',60,255,'',0,0,0,177),\n       (50,'biblio_label','Label',0,'textfield',60,255,'',0,0,0,178),\n       (51,'biblio_access_date','Access Date',0,'textfield',60,255,'',0,0,0,179)\n       ;");
      $result[] = db_query("CREATE TABLE {biblio_types} (\n        `tid` int(11) NOT NULL auto_increment,\n        `name` varchar(64) NOT NULL default '',\n        `description` varchar(255) default NULL,\n        `weight` int(11) NOT NULL default '0',\n        `visible` tinyint(1) NOT NULL default '1' ,\n        PRIMARY KEY  (`tid`)\n      )  /*!40100 DEFAULT CHARACTER SET utf8 */;");

      // some default types...

      /*      $result[] = db_query("INSERT INTO {biblio_types} (`tid`,`name`,`description`) VALUES
             (-1,'Select Type...',NULL),
             (1,'Journal Paper',NULL),
             (2,'Refereed Conference Paper',NULL),
             (3,'Non-Refereed Conference Paper',NULL),
             (4,'Conference Poster Presentation',NULL),
             (5,'Report',NULL),
             (6,'Book or Book Chapter',NULL),
             (7,'Thesis',NULL),
             (8,'Patent',NULL),
             (9,'Other Publication',NULL);");
       */
      $result[] = db_query("INSERT INTO {biblio_types} (`tid`,`name`,`description`,weight) VALUES\n       (-1,'Select Type...',NULL,-10),\n        (100,'Book',NULL,1),\n\t\t\t\t(101,'Book Chapter',NULL,2),\n\t\t\t\t(102,'Journal Article',NULL,3),\n\t\t\t\t(103,'Conference Paper',NULL,4),\n\t\t\t\t(104,'Conference Proceedings',NULL,5),\n\t\t\t\t(105,'Newspaper Article',NULL,6),\n\t\t\t\t(106,'Magazine Article',NULL,7),\n\t\t\t\t(107,'Web Article',NULL,8),\n\t\t\t\t(108,'Thesis',NULL,9),\n\t\t\t\t(109,'Report',NULL,10),\n\t\t\t\t(110,'Film',NULL,11),\n\t\t\t\t(111,'Broadcast',NULL,12),\n\t\t\t\t(112,'Artwork',NULL,13),\n\t\t\t\t(113,'Software',NULL,14),\n\t\t\t\t(114,'Audiovisual',NULL,15),\n\t\t\t\t(115,'Hearing',NULL,16),\n\t\t\t\t(116,'Case',NULL,17),\n\t\t\t\t(117,'Bill',NULL,18),\n\t\t\t\t(118,'Statute',NULL,19),\n\t\t\t\t(119,'Patent',NULL,20),\n\t\t\t\t(120,'Personal',NULL,21),\n\t\t\t\t(121,'Manuscript',NULL,22),\n\t\t\t\t(122,'Map',NULL,23),\n\t\t\t\t(123,'Chart',NULL,24),\n\t\t\t\t(124,'Unpublished',NULL,25),\n\t\t\t\t(125,'Database',NULL,26),\n\t\t\t\t(126,'Government Report',NULL,27),\n\t\t\t\t(127,'Classical'\t,NULL,28),\n\t\t\t\t(128,'Legal Ruling'\t,NULL,29),\n\t\t\t\t(129,'Miscellaneous'\t,NULL,30),\n\t\t\t\t(130,'Miscellaneous Section'\t,NULL,31);");

      // some customizations of the default types
      _add_types($result);
      break;
    case 'pgsql':
      break;
  }
  if (count($result) == count(array_filter($result))) {
    drupal_set_message(t('The biblio module has successfully added its tables to the database.'));
  }
  else {
    drupal_set_message(t('Drupal was unable to install the database tables for the biblio module.'), 'error');
  }
}