You are here

class csl_if in Bibliography Module 7.2

Same name and namespace in other branches
  1. 6.2 modules/CiteProc/CSL.inc \csl_if
  2. 7 modules/CiteProc/CSL.inc \csl_if

Hierarchy

Expanded class hierarchy of csl_if

File

modules/CiteProc/CSL.inc, line 1386

View source
class csl_if extends csl_rendering_element {
  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;
  }

}

Members