public function Biblio::getText in Bibliography Module 7.3
Get the text, rendered using a Biblio style plugin.
Parameters
$style_name: The Biblio style plugin.
$options: Optional; Array with settings specific to the select style name.
$skip_cache: Optional; Determine if cache values should be skipped . Defaults to FALSE.
1 call to Biblio::getText()
- Biblio::buildContent in includes/
biblio.controller.inc - Builds a structured array representing the entity's content.
File
- includes/
biblio.controller.inc, line 80
Class
- Biblio
- Biblio class.
Code
public function getText($style_name, $options = array(), $skip_cache = FALSE) {
if (!($plugin = biblio_get_biblio_style($style_name))) {
// @todo: Add own exception.
throw new Exception(format_string('Biblio style "@style" does not exist.', array(
'@style' => $style_name,
)));
}
foreach ($plugin['assets']['js'] as $js_file) {
drupal_add_js($js_file);
}
foreach ($plugin['assets']['css'] as $css_file) {
drupal_add_css($css_file);
}
if (!variable_get('biblio_debug') && ($output = $this
->getCache($style_name, $options, $skip_cache))) {
return $output;
}
$plugin['options'] = drupal_array_merge_deep($plugin['options'], $options);
$class = ctools_plugin_load_class('biblio', 'biblio_style', $style_name, 'class');
$biblio_style = new $class($plugin, $this);
$output = $biblio_style
->render($options);
// @todo: We do this because the title might have link. Is there a nicer way?
$this->title = strip_tags($this->title);
if ($skip_cache) {
return $output;
}
// Cache the output.
$this->cache = $output;
$this->cache_id = md5(serialize(array(
$style_name,
$options,
)));
// Make sure the cache isn't cleared on save.
$this->_skip_cache = TRUE;
$wrapper = entity_metadata_wrapper('biblio', $this);
if (isset($wrapper->biblio_first_letter)) {
// Assign first letter to ease grouping.
$trimmed = trim(strip_tags($output), ' “');
$wrapper->biblio_first_letter
->set(strtoupper(drupal_substr($trimmed, 0, 1)));
}
$this
->save();
return $output;
}