biblio_ris.install in Bibliography Module 7.2
Same filename and directory in other branches
Database table creation for biblio_ris module.
File
modules/RIS/biblio_ris.installView source
<?php
/**
* @file
* Database table creation for biblio_ris module.
*/
/**
* Implementation of hook_install().
*/
function biblio_ris_install() {
_save_ris_maps();
}
function biblio_ris_uninstall() {
if (db_table_exists('biblio_type_maps')) {
db_delete('biblio_type_maps')
->condition('format', 'ris')
->execute();
}
}
function biblio_ris_enable() {
biblio_ris_set_system_weight();
}
function biblio_ris_set_system_weight() {
db_update('system')
->fields(array(
'weight' => 27,
))
->condition('name', 'biblio_ris')
->execute();
}
function _save_ris_maps() {
$typemap = _get_ris_type_map();
$typenames = _get_ris_type_names();
$fieldmap = _get_ris_field_map();
$maps = array_merge($typemap, $typenames, $fieldmap);
biblio_save_map($maps);
}
function _reset_ris_map($type) {
$count = db_query("SELECT COUNT(*) FROM {biblio_type_maps} WHERE format='ris'")
->fetchField();
if ($count && $type) {
//update
$function = '_get_ris_' . $type;
if (!function_exists($function)) {
return;
}
$map = $function();
db_update('biblio_type_maps')
->fields($map)
->condition('format', 'ris')
->execute();
}
else {
// install
db_delete('biblio_type_maps')
->condition('format', 'ris')
->execute();
_save_ris_maps();
}
}
function _get_ris_type_map() {
$map['type_map'] = serialize(array(
'ABST' => 'miscellaneous',
'ADVS' => 'audiovisual',
'ART' => 'artwork',
'BILL' => 'bill',
'BOOK' => 'book',
'CASE' => 'case',
'CHAP' => 'book_chapter',
'COMP' => 'software',
'CONF' => 'conference_paper',
'CTLG' => 'miscellaneous',
'DATA' => 'database',
'ELEC' => 'miscellaneous',
'GEN' => 'miscellaneous',
'HEAR' => 'hearing',
'ICOMM' => 'web_article',
'INPR' => 'miscellaneous',
'JFULL' => 'miscellaneous',
'JOUR' => 'journal_article',
'MAP' => 'map',
'MGZN' => 'magazine_article',
'MPCT' => 'film',
'MUSIC' => 'miscellaneous',
'NEWS' => 'newspaper_article',
'PAMP' => 'miscellaneous',
'PAT' => 'patent',
'PCOMM' => 'personal',
'RPRT' => 'report',
'SER' => 'book',
'SLIDE' => 'miscellaneous',
'SOUND' => 'miscellaneous',
'STAT' => 'database',
'THES' => 'thesis',
'UNBILl' => 'miscellaneous',
'UNPB' => 'unpublished',
'VIDEO' => 'miscellaneous',
));
$map['format'] = 'ris';
return $map;
}
function _get_ris_type_names() {
$map['type_names'] = serialize(array(
'ABST' => 'Abstract',
'ADVS' => 'Audiovisual material',
'ART' => 'Art Work',
'BILL' => 'Bill/Resolution',
'BOOK' => 'Book, Whole',
'CASE' => 'Case',
'CHAP' => 'Book chapter',
'COMP' => 'Computer program',
'CONF' => 'Conference proceeding',
'CTLG' => 'Catalog',
'DATA' => 'Data file',
'ELEC' => 'Electronic Citation',
'GEN' => 'Generic',
'HEAR' => 'Hearing',
'ICOMM' => 'Internet Communication',
'INPR' => 'In Press',
'JFULL' => 'Journal (full)',
'JOUR' => 'Journal',
'MAP' => 'Map',
'MGZN' => 'Magazine article',
'MPCT' => 'Motion picture',
'MUSIC' => 'Music score',
'NEWS' => 'Newspaper',
'PAMP' => 'Pamphlet',
'PAT' => 'Patent',
'PCOMM' => 'Personal communication',
'RPRT' => 'Report',
'SER' => 'Serial (Book, Monograph)',
'SLIDE' => 'Slide',
'SOUND' => 'Sound recording',
'STAT' => 'Statute',
'THES' => 'Thesis/Dissertation',
'UNBILl' => 'Unenacted bill/resolution',
'UNPB' => 'Unpublished work',
'VIDEO' => 'Video recording',
));
$map['format'] = 'ris';
return $map;
}
function _get_ris_field_map() {
$map['field_map'] = serialize(array(
'ID' => '',
//- Reference ID (not imported to reference software)
'T1' => 'biblio_title',
//- Primary title
'TI' => 'biblio_title',
//- Book title
'BT' => 'biblio_title',
//- Book title
'CT' => 'biblio_title',
//- Title of unpublished reference
'A1' => '',
//- Primary author
'A2' => '',
//- Secondary author (each name on separate line)
'AU' => '',
//- Author (syntax. Last name, First name, Suffix)
'Y1' => 'biblio_year',
//- Primary date
'PY' => '',
//- Publication year (YYYY/MM/DD)
'N1' => 'biblio_notes',
//- Notes
'KW' => '',
//- Keywords (each keyword must be on separate line preceded KW -)
'RP' => '',
//- Reprint status (IN FILE, NOT IN FILE, ON REQUEST (MM/DD/YY))
'SP' => '',
//- Start page number
'EP' => '',
//- Ending page number
'JF' => 'biblio_title_secondary',
//- Periodical full name
'JO' => 'biblio_short_title',
//- Periodical standard abbreviation
'JA' => 'biblio_title_secondary',
//- Periodical in which article was published
'J1' => 'biblio_short_title',
//- Periodical name //- User abbreviation 1
'J2' => 'biblio_short_title',
//- Periodical name - User abbreviation 2
'VL' => 'biblio_volume',
//- Volume number
'IS' => 'biblio_issue',
//- Issue number
'CP' => 'biblio_issue',
//- Issue number
'T2' => 'biblio_title_secondary',
//- Title secondary
'CY' => 'biblio_place_published',
//- City of Publication
'PB' => 'biblio_publisher',
//- Publisher
'U1' => '',
//- User definable 1
'U2' => '',
//- User definable 2
'U3' => '',
//- User definable 3
'U4' => '',
//- User definable 4
'U5' => '',
//- User definable 5
'T3' => 'biblio_title_tertiary',
//- Title series
'AB' => 'biblio_abst_e',
//- Abstract
'N2' => 'biblio_abst_e',
//- Abstract
'SN' => 'biblio_isbn',
//- ISSN/ISBN (e.g. ISSN XXXX-XXXX)
'AV' => '',
//- Availability
'M1' => '',
//- Misc. 1
'M3' => 'biblio_type_of_work',
//- Misc. 3
'AD' => '',
//- Address
'UR' => 'biblio_url',
//- Web/URL
'L1' => '',
//- Link to PDF
'L2' => '',
//- Link to Full-text
'L3' => '',
//- Related records
'L4' => '',
//- Images
'ER' => '',
//- End of Reference (must be the last tag)
'DP' => 'biblio_remote_db_provider',
'DB' => 'biblio_remote_db_name',
'DO' => 'biblio_doi',
));
$map['format'] = 'ris';
return $map;
}
/**
* Implementation of hook_schema().
*
* Note: Pro Drupal Development models use of t() to translate 'description'
* for field definitions, but Drupal core does not use them. We follow core.
*/
function biblio_ris_schema() {
$schema = array();
$schema['biblio_ris'] = array(
'fields' => array(
'bid' => array(
'type' => 'int',
'not null' => TRUE,
),
'biblio_ris_md5' => array(
'type' => 'char',
'length' => 32,
'not null' => TRUE,
),
),
'primary key' => array(
'bid',
),
);
return $schema;
}
Functions
Name | Description |
---|---|
biblio_ris_enable | |
biblio_ris_install | Implementation of hook_install(). |
biblio_ris_schema | Implementation of hook_schema(). |
biblio_ris_set_system_weight | |
biblio_ris_uninstall | |
_get_ris_field_map | |
_get_ris_type_map | |
_get_ris_type_names | |
_reset_ris_map | |
_save_ris_maps |