public function csl_label::evaluateStringPluralism in Bibliography Module 7
Same name and namespace in other branches
- 6.2 modules/CiteProc/CSL.inc \csl_label::evaluateStringPluralism()
1 call to csl_label::evaluateStringPluralism()
- csl_label::render in modules/
CiteProc/ CSL.inc
File
- modules/
CiteProc/ CSL.inc, line 1606 - CiteProc-PHP.
Class
Code
public function evaluateStringPluralism($data, $variable) {
$field = $this->citeproc
->map_field($variable);
$str = $data->{$field};
$plural = 'single';
if (!empty($str)) {
// $regex = '/(?:[0-9],\s*[0-9]|\s+and\s+|&|([0-9]+)\s*[\-\x2013]\s*([0-9]+))/';.
switch ($variable) {
case 'page':
$page_regex = "/([a-zA-Z]*)([0-9]+)\\s*(?:–|-)\\s*([a-zA-Z]*)([0-9]+)/";
$err = preg_match($page_regex, $str, $m);
if ($err !== FALSE && count($m) == 0) {
$plural = 'single';
}
elseif ($err !== FALSE && count($m)) {
$plural = 'multiple';
}
break;
default:
}
}
return $plural;
}