biblio_ris.install in Bibliography Module 6.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() {
drupal_install_schema('biblio_ris');
_save_ris_maps();
}
function biblio_ris_uninstall() {
drupal_uninstall_schema('biblio_ris');
if (db_table_exists('biblio_type_maps')) {
db_query("DELETE FROM {biblio_type_maps} WHERE format = 'ris'");
}
}
function biblio_ris_requirements($phase) {
$requirements = array();
$t = get_t();
if ($phase == 'install') {
if (!module_exists('biblio')) {
$requirements['biblio_ris'] = array(
'title' => $t('Biblio'),
'description' => $t('The Biblio module must be installed first'),
'severity' => REQUIREMENT_ERROR,
);
}
if (!db_table_exists('biblio_type_maps')) {
$requirements['biblio_ris_table'] = array(
'title' => $t('Biblio table '),
'description' => $t("Missing db table 'biblio_type_maps', you probably have to update your biblio module"),
'severity' => REQUIREMENT_ERROR,
);
}
}
return $requirements;
}
function biblio_ris_enable() {
biblio_ris_set_system_weight();
}
function biblio_ris_set_system_weight() {
return update_sql("UPDATE {system} SET weight = 22 WHERE name = 'biblio_ris'");
}
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);
db_query("INSERT INTO {biblio_type_maps} (format,type_map,type_names,field_map) VALUES ('%s','%s','%s','%s')", array(
$maps['format'],
$maps['type_map'],
$maps['type_names'],
$maps['field_map'],
));
//drupal_write_record('biblio_type_maps', $maps);
}
function _reset_ris_map($type) {
$count = db_result(db_query("SELECT COUNT(*) FROM {biblio_type_maps} WHERE format='ris'"));
if ($count && $type) {
//update
$function = '_get_ris_' . $type;
if (!function_exists($function)) {
return;
}
$map = $function();
drupal_write_record('biblio_type_maps', $map, 'format');
}
else {
// install
db_query("DELETE FROM {biblio_type_maps} WHERE format='ris'");
_save_ris_maps();
}
}
function _get_ris_type_map() {
$map['type_map'] = serialize(array(
'ABST' => 129,
'ADVS' => 114,
'ART' => 112,
'BILL' => 117,
'BOOK' => 100,
'CASE' => 116,
'CHAP' => 101,
'COMP' => 113,
'CONF' => 103,
'CTLG' => 129,
'DATA' => 125,
'ELEC' => 129,
'GEN' => 129,
'HEAR' => 115,
'ICOMM' => 107,
'INPR' => 129,
'JFULL' => 129,
'JOUR' => 102,
'MAP' => 122,
'MGZN' => 106,
'MPCT' => 110,
'MUSIC' => 129,
'NEWS' => 105,
'PAMP' => 129,
'PAT' => 119,
'PCOMM' => 120,
'RPRT' => 109,
'SER' => 100,
'SLIDE' => 129,
'SOUND' => 129,
'STAT' => 125,
'THES' => 108,
'UNBILl' => 129,
'UNPB' => 124,
'VIDEO' => 129,
));
$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' => 'title',
//- Primary title
'TI' => 'title',
//- Book title
'BT' => 'title',
//- Book title
'CT' => '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_secondary_title',
//- Periodical full name
'JO' => 'biblio_short_title',
//- Periodical standard abbreviation
'JA' => 'biblio_secondary_title',
//- 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_secondary_title',
//- Title secondary
'CY' => 'biblio_place_published',
//- City of Publication
'PB' => 'biblio_publisher',
//- Publisher
'U1' => 'biblio_custom1',
//- User definable 1
'U2' => 'biblio_custom2',
//- User definable 2
'U3' => 'biblio_custom3',
//- User definable 3
'U4' => 'biblio_custom4',
//- User definable 4
'U5' => 'biblio_custom5',
//- User definable 5
'T3' => 'biblio_tertiary_title',
//- 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' => '',
//- Misc. 3
'AD' => '',
//- Address
'UR' => 'biblio_url',
//- Web/URL
'L1' => '',
//- Link to PDF
'L2' => '',
//- Link to Full-text
'L3' => '',
//- Related records
'L4' => '',
//- Images
'ER' => '',
));
$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(
'nid' => array(
'type' => 'int',
'not null' => TRUE,
),
'biblio_ris_md5' => array(
'type' => 'char',
'length' => 32,
'not null' => TRUE,
),
),
'primary key' => array(
'nid',
),
);
return $schema;
}
Functions
Name | Description |
---|---|
biblio_ris_enable | |
biblio_ris_install | Implementation of hook_install(). |
biblio_ris_requirements | |
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 |