protected function RISEncoder::buildEntry in Bibliography & Citation 2.0.x
Same name and namespace in other branches
- 8 modules/bibcite_ris/src/Encoder/RISEncoder.php \Drupal\bibcite_ris\Encoder\RISEncoder::buildEntry()
Build RIS entry string.
Parameters
array $data: Array of RIS values.
Return value
string Formatted RIS string.
1 call to RISEncoder::buildEntry()
- RISEncoder::encode in modules/
bibcite_ris/ src/ Encoder/ RISEncoder.php
File
- modules/
bibcite_ris/ src/ Encoder/ RISEncoder.php, line 200
Class
- RISEncoder
- RIS format encoder.
Namespace
Drupal\bibcite_ris\EncoderCode
protected function buildEntry(array $data) {
$entry = NULL;
// For not duplicating pages parse.
$pages_parsed = FALSE;
foreach ($data as $key => $value) {
switch ($key) {
// Pages found.
case "SP":
case "EP":
if (!$pages_parsed) {
$pages_parsed = TRUE;
$exp = explode(',', trim($value));
foreach ($exp as $page) {
// Interval of pages.
if (strpos(trim($page), '-') !== FALSE) {
$interval = explode('-', trim($page));
$entry .= $this
->buildLine('SP', $interval[0]);
$entry .= $this
->buildLine('EP', $interval[count(@$interval) - 1]);
}
else {
// From here to the end.
if ($page[strlen(trim($page)) - 1] === '+') {
$entry .= $this
->buildLine('SP', trim($page, ' +'));
}
else {
// Single page.
$entry .= $this
->buildLine('EP', trim($page));
}
}
}
}
break;
// Not pages.
default:
if (is_array($value)) {
$entry .= $this
->buildMultiLine($key, $value);
}
else {
$entry .= $this
->buildLine($key, $value);
}
break;
}
}
$entry .= $this
->buildEnd();
return $entry;
}