public function csl_if::evaluate in Bibliography Module 7
Same name and namespace in other branches
- 6.2 modules/CiteProc/CSL.inc \csl_if::evaluate()
- 7.2 modules/CiteProc/CSL.inc \csl_if::evaluate()
1 method overrides csl_if::evaluate()
- csl_else::evaluate in modules/
CiteProc/ CSL.inc
File
- modules/
CiteProc/ CSL.inc, line 1932 - CiteProc-PHP.
Class
Code
public function evaluate($data) {
$match = ($match = $this->match) ? $match : 'all';
if ($types = $this->type) {
$types = explode(' ', $types);
$matches = 0;
foreach ($types as $type) {
if (isset($data->biblio_type)) {
if ($data->biblio_type == $type && $match == 'any') {
return TRUE;
}
if ($data->biblio_type != $type && $match == 'all') {
return FALSE;
}
if ($data->biblio_type == $type) {
$matches++;
}
}
}
if ($match == 'all' && $matches == count($types)) {
return TRUE;
}
if ($match == 'none' && $matches == 0) {
return TRUE;
}
return FALSE;
}
if ($variables = $this->variable) {
$variables = explode(' ', $variables);
$matches = 0;
foreach ($variables as $var) {
if (isset($data->{$var}) && !empty($data->{$var}) && $match == 'any') {
return TRUE;
}
if ((!isset($data->{$var}) || empty($data->{$var})) && $match == 'all') {
return FALSE;
}
if (isset($data->{$var}) && !empty($data->{$var})) {
$matches++;
}
}
if ($match == 'all' && $matches == count($variables)) {
return TRUE;
}
if ($match == 'none' && $matches == 0) {
return TRUE;
}
return FALSE;
}
if ($is_numeric = $this->{'is-numeric'}) {
$variables = explode(' ', $is_numeric);
$matches = 0;
foreach ($variables as $var) {
if (isset($data->{$var})) {
if (is_numeric($data->{$var}) && $match == 'any') {
return TRUE;
}
if (!is_numeric($data->{$var})) {
if (preg_match('/(?:^\\d+|\\d+$)/', $data->{$var})) {
$matches++;
}
elseif ($match == 'all') {
return FALSE;
}
}
if (is_numeric($data->{$var})) {
$matches++;
}
}
}
if ($match == 'all' && $matches == count($variables)) {
return TRUE;
}
if ($match == 'none' && $matches == 0) {
return TRUE;
}
return FALSE;
}
if (isset($this->locator)) {
$test = explode(' ', $this->type);
}
return FALSE;
}