| 1 |
<?php |
<?php |
| 2 |
// $Id: biblio.module,v 1.196.2.13 2009/11/10 02:50:32 rjerome Exp $ |
// $Id: biblio.module,v 1.196.2.14 2009/11/10 22:09:18 rjerome Exp $ |
| 3 |
/** |
/** |
| 4 |
* biblio.module for Drupal |
* biblio.module for Drupal |
| 5 |
* |
* |
| 1085 |
$options["$option->tid"] = $option->name; |
$options["$option->tid"] = $option->name; |
| 1086 |
} |
} |
| 1087 |
if (!isset($node->nid)) {// only show the doi lookup and paste boxes if this is a new entry |
if (!isset($node->nid)) {// only show the doi lookup and paste boxes if this is a new entry |
| 1088 |
if(phpversion() > 5 && !isset($form_state['storage']['biblio_doi'])) { |
if($user->uid > 0 && phpversion() > 5 && !isset($form_state['storage']['biblio_doi'])) { |
| 1089 |
$form['doi_lookup'] = array( |
$form['doi_lookup'] = array( |
| 1090 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 1091 |
'#title' => t('DOI Lookup'), |
'#title' => t('DOI Lookup'), |
| 1562 |
* @return none |
* @return none |
| 1563 |
*/ |
*/ |
| 1564 |
function _biblio_prepare_submit(&$node) { |
function _biblio_prepare_submit(&$node) { |
| 1565 |
require_once(drupal_get_path('module', 'biblio') .'/biblio.contributors.inc'); |
// this is now done within the _save_contributors() function |
| 1566 |
$node->biblio_contributors = biblio_parse_contributors($node->biblio_contributors); |
//$node->biblio_contributors = biblio_parse_contributors($node->biblio_contributors); |
| 1567 |
|
|
| 1568 |
$node->biblio_year = _biblio_numeric_year($node->biblio_year); |
$node->biblio_year = _biblio_numeric_year($node->biblio_year); |
| 1569 |
|
|
| 1584 |
* database inserts. |
* database inserts. |
| 1585 |
*/ |
*/ |
| 1586 |
function biblio_insert($node) { |
function biblio_insert($node) { |
| 1587 |
|
require_once(drupal_get_path('module', 'biblio') .'/biblio.contributors.inc'); |
| 1588 |
require_once(drupal_get_path('module', 'biblio') .'/biblio.keywords.inc'); |
require_once(drupal_get_path('module', 'biblio') .'/biblio.keywords.inc'); |
| 1589 |
_biblio_prepare_submit($node); |
_biblio_prepare_submit($node); |
| 1590 |
drupal_write_record('biblio', $node); |
drupal_write_record('biblio', $node); |
| 1638 |
|
|
| 1639 |
require_once(drupal_get_path('module', 'biblio') .'/biblio.contributors.inc'); |
require_once(drupal_get_path('module', 'biblio') .'/biblio.contributors.inc'); |
| 1640 |
require_once(drupal_get_path('module', 'biblio') .'/biblio.keywords.inc'); |
require_once(drupal_get_path('module', 'biblio') .'/biblio.keywords.inc'); |
| 1641 |
|
$vids = array(); |
| 1642 |
|
foreach($nodes as $nid => $node) $vids[] = $node->vid; |
| 1643 |
|
|
| 1644 |
$result = db_query('SELECT b.*, bt.name as biblio_type_name |
$result = db_query('SELECT b.*, bt.name as biblio_type_name |
| 1645 |
FROM {biblio} b |
FROM {biblio} b |
| 1646 |
LEFT JOIN {biblio_types} bt on b.biblio_type = bt.tid |
LEFT JOIN {biblio_types} bt on b.biblio_type = bt.tid |
| 1647 |
WHERE b.nid IN (:nids)', array(':nids' => array_keys($nodes)), array('fetch' => PDO::FETCH_ASSOC)); |
WHERE b.vid IN (:vids)', array(':vids' => $vids), array('fetch' => PDO::FETCH_ASSOC)); |
| 1648 |
foreach ($result as $record) { |
foreach ($result as $record) { |
| 1649 |
// $nodes[$record['nid']]->biblio = $record; |
// $nodes[$record['nid']]->biblio = $record; |
| 1650 |
foreach ($record as $key => $value) { |
foreach ($record as $key => $value) { |
| 2172 |
} |
} |
| 2173 |
//TODO title value?? |
//TODO title value?? |
| 2174 |
$hash_string = str_replace(' ', '', drupal_strtolower($node->title['zxx'][0]['value'])); |
$hash_string = str_replace(' ', '', drupal_strtolower($node->title['zxx'][0]['value'])); |
| 2175 |
$hash_string .= str_replace(' ', '', drupal_strtolower($node->biblio_contributors[1][0]['lastname'])); |
if (isset($node->biblio_contributors[1][0])) { |
| 2176 |
|
$hash_string .= str_replace(' ', '', drupal_strtolower($node->biblio_contributors[1][0]['lastname'])); |
| 2177 |
|
} |
| 2178 |
$hash_string .= $node->biblio_year; |
$hash_string .= $node->biblio_year; |
| 2179 |
|
|
| 2180 |
$sum = md5($hash_string); |
$sum = md5($hash_string); |