You are here

class csl_if in Bibliography Module 7

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

Hierarchy

Expanded class hierarchy of csl_if

File

modules/CiteProc/CSL.inc, line 1927
CiteProc-PHP.

View source
class csl_if extends csl_rendering_element {

  /**
   *
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
csl_collection::$elements protected property
csl_collection::add_element public function
csl_collection::format public function 1
csl_element::$attributes protected property
csl_element::$citeproc protected property
csl_element::get_attributes public function
csl_element::get_hier_attributes public function
csl_element::init public function 5
csl_element::name public function
csl_element::set_attributes public function
csl_element::__construct public function 2
csl_element::__get public function
csl_element::__isset public function
csl_element::__set public function
csl_element::__unset public function
csl_if::evaluate public function 1
csl_rendering_element::render public function Overrides csl_collection::render 11