public function BiblioStyleBibtex::render in Bibliography Module 7.3
@inheritdoc
Overrides BiblioStyleBase::render
File
- plugins/
biblio_style/ bibtex/ BiblioStyleBibtex.class.php, line 253 - BibTeX style.
Class
- BiblioStyleBibtex
- @file BibTeX style.
Code
public function render($options = array(), $langcode = NULL) {
// We clone the biblio, as we might change the values.
$biblio = clone $this->biblio;
$wrapper = entity_metadata_wrapper('biblio', $biblio);
$type = $this->biblio->type;
if ($type == 'thesis' && !empty($wrapper->biblio_type_of_work) && strpos($wrapper->biblio_type_of_work
->value(), 'masters') === TRUE) {
$type = 'mastersthesis';
}
$type_info = biblio_get_types_info($type);
$output = array();
$output[] = '@' . $type_info['name'] . '{';
$map = $this
->getMapping();
foreach ($map['field'] as $key => $info) {
$method = $info['method'];
$property = $info['property'];
$use_key = $info['use_key'];
$wrapper = entity_metadata_wrapper('biblio', $this->biblio);
if (empty($wrapper->{$property})) {
continue;
}
if (!($value = $this
->{$method}($wrapper, $property))) {
continue;
}
$first_entry =& drupal_static(__METHOD__, array());
// If we reached here, it means we have a first entity, so we can turn off
// this flag.
$first_entry[$this->biblio->bid] = FALSE;
$prefix = ",\n\t";
if ($key == 'bibtexCitation') {
// Place bibtexCitation as the second element of the output, right after
// the Biblio type.
$output = array_merge(array_slice($output, 0, 1), array(
$value,
), array_slice($output, 1));
}
elseif ($use_key) {
$opening_tag = $this->plugin['options']['opening_tag'];
$closing_tag = $this->plugin['options']['closing_tag'];
$output[] = $prefix . $key . ' = ' . $opening_tag . $value . $closing_tag;
}
else {
$output[] = $prefix . $value;
}
}
$output[] = "\n}\n";
// Convert any special characters to the latex equivalents.
$converter = new PARSEENTRIES();
$output = implode("", $output);
$output = $converter
->searchReplaceText($this
->getTranstab(), $output, FALSE);
return $output;
}