public function BiblioStyleCiteProc::render in Bibliography Module 7.3
Render the Biblio according to the style plugin.
Return value
A an HTML string.
Overrides BiblioStyleBase::render
1 call to BiblioStyleCiteProc::render()
- BiblioStyleExampleCiteProc::render in modules/
biblio_example/ plugins/ biblio_style/ example_citeproc/ BiblioStyleExampleCiteProc.class.php - Render the Biblio according to the style plugin.
1 method overrides BiblioStyleCiteProc::render()
- BiblioStyleExampleCiteProc::render in modules/
biblio_example/ plugins/ biblio_style/ example_citeproc/ BiblioStyleExampleCiteProc.class.php - Render the Biblio according to the style plugin.
File
- plugins/
biblio_style/ citeproc/ BiblioStyleCiteProc.class.php, line 10 - Chicago biblio style.
Class
- BiblioStyleCiteProc
- @file Chicago biblio style.
Code
public function render($options = array(), $langcode = NULL) {
global $language;
$langcode = $langcode ? $langcode : $language->language;
// Make sure the CSL file exists.
$style_name = $this->plugin['options']['style_name'] . '.csl';
// @todo: Allow adding more styles in the Library.
$file_path = $this->plugin['options']['style_path'] . '/' . $style_name;
if (!file_exists($file_path)) {
throw new Exception(format_string('@style file does not exist in @path.', array(
'@style' => $style_name,
'@path' => $file_path,
)));
}
$csl_file_contents = file_get_contents($file_path);
// @todo: Define CiteProc as library.
include_once libraries_get_path('citeproc-php') . '/CiteProc.php';
$citeproc = new citeproc($csl_file_contents, $langcode);
// Pass CiteProc the mapped biblio.
$mapped_data = $this
->map();
if (!empty($this->plugin['options']['label_as_link'])) {
// Add a prefix and suffix to the title, so it's later easier to replace
// it with a link to the Biblio.
$mapped_data->title = '---REPLACE---' . $mapped_data->title . '---REPLACE---';
}
$output = $citeproc
->render($mapped_data);
if (!empty($this->plugin['options']['label_as_link'])) {
// Show label as link.
$matches = array();
preg_match('/---REPLACE---(.*)---REPLACE---/i', $output, $matches);
$url = entity_uri('biblio', $this->biblio);
$output = str_replace($matches[0], l($matches[1], $url['path'], $url['options']), $output);
}
return $output;
}