class csl_group in Bibliography Module 7
Same name and namespace in other branches
- 6.2 modules/CiteProc/CSL.inc \csl_group
- 7.2 modules/CiteProc/CSL.inc \csl_group
Hierarchy
- class \csl_collection
- class \csl_element
- class \csl_rendering_element
- class \csl_format
- class \csl_group
- class \csl_format
- class \csl_rendering_element
- class \csl_element
Expanded class hierarchy of csl_group
File
- modules/
CiteProc/ CSL.inc, line 1667 - CiteProc-PHP.
View source
class csl_group extends csl_format {
/**
*
*/
public function render($data, $mode = NULL) {
$text = '';
$text_parts = array();
$terms = $variables = $have_variables = $element_count = 0;
foreach ($this->elements as $element) {
$element_count++;
if ($element instanceof csl_text && ($element->source == 'term' || $element->source == 'value')) {
$terms++;
}
if ($element instanceof csl_label) {
$terms++;
}
if ($element->source == 'variable' && isset($element->variable) && !empty($data->{$element->variable})) {
$variables++;
}
$text = $element
->render($data, $mode);
$delimiter = $this->delimiter;
if (!empty($text)) {
if ($delimiter && $element_count < count($this->elements)) {
// Check to see if the delimiter is already the last character of the text string
// if so, remove it so we don't have two of them when we paste together the group.
$stext = strip_tags(trim($text));
if (strrpos($stext, $delimiter[0]) + 1 == drupal_strlen($stext) && drupal_strlen($stext) > 1) {
$text = str_replace($stext, '----REPLACE----', $text);
$stext = drupal_substr($stext, 0, -1);
$text = str_replace('----REPLACE----', $stext, $text);
}
}
$text_parts[] = $text;
if ($element->source == 'variable' || isset($element->variable)) {
$have_variables++;
}
if ($element->source == 'macro') {
$have_variables++;
}
}
}
if (empty($text_parts)) {
return;
}
if ($variables && !$have_variables) {
// There has to be at least one other none empty value before the term is output.
return;
}
if (count($text_parts) == $terms) {
// There has to be at least one other none empty value before the term is output.
return;
}
$delimiter = $this->delimiter;
// Insert the delimiter if supplied.
$text = implode($delimiter, $text_parts);
return $this
->format($text);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
csl_collection:: |
protected | property | ||
csl_collection:: |
public | function | ||
csl_element:: |
protected | property | ||
csl_element:: |
protected | property | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | 5 | |
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_format:: |
protected | property | 1 | |
csl_format:: |
protected | property | ||
csl_format:: |
public | function |
Overrides csl_collection:: |
1 |
csl_format:: |
public | function | 5 | |
csl_format:: |
public | function |
Overrides csl_element:: |
2 |
csl_group:: |
public | function |
Overrides csl_rendering_element:: |