You are here

class citeproc in Bibliography Module 7

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

Hierarchy

Expanded class hierarchy of citeproc

File

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

View source
class citeproc {
  public $bibliography;
  public $citation;
  public $style;
  protected $macros;
  private $info;
  protected $locale;
  protected $style_locale;
  public $quash;
  private $mapper;

  /**
   *
   */
  public function __construct($csl = NULL, $lang = 'en') {
    if ($csl) {
      $this
        ->init($csl, $lang);
    }
  }

  /**
   *
   */
  public function init($csl, $lang) {
    $this->mapper = new csl_mapper();
    $this->quash = array();
    $csl_doc = new DOMDocument();
    if ($csl_doc
      ->loadXML($csl)) {
      $style_nodes = $csl_doc
        ->getElementsByTagName('style');
      if ($style_nodes) {
        foreach ($style_nodes as $style) {
          $this->style = new csl_style($style);
        }
      }
      $info_nodes = $csl_doc
        ->getElementsByTagName('info');
      if ($info_nodes) {
        foreach ($info_nodes as $info) {
          $this->info = new csl_info($info);
        }
      }
      $this->locale = new csl_locale($lang);
      $this->locale
        ->set_style_locale($csl_doc);
      $macro_nodes = $csl_doc
        ->getElementsByTagName('macro');
      if ($macro_nodes) {
        $this->macros = new csl_macros($macro_nodes, $this);
      }
      $citation_nodes = $csl_doc
        ->getElementsByTagName('citation');
      foreach ($citation_nodes as $citation) {
        $this->citation = new csl_citation($citation, $this);
      }
      $bibliography_nodes = $csl_doc
        ->getElementsByTagName('bibliography');
      foreach ($bibliography_nodes as $bibliography) {
        $this->bibliography = new csl_bibliography($bibliography, $this);
      }
    }
  }

  /**
   *
   */
  public function render($data, $mode = NULL) {
    $text = '';
    switch ($mode) {
      case 'citation':
        $text .= isset($this->citation) ? $this->citation
          ->render($data) : '';
        break;
      case 'bibliography':
      default:
        $text .= isset($this->bibliography) ? $this->bibliography
          ->render($data) : '';
        break;
    }
    return $text;
  }

  /**
   *
   */
  public function render_macro($name, $data, $mode) {
    return $this->macros
      ->render_macro($name, $data, $mode);
  }

  /**
   *
   */
  public function get_locale($type, $arg1, $arg2 = NULL, $arg3 = NULL) {
    return $this->locale
      ->get_locale($type, $arg1, $arg2, $arg3);
  }

  /**
   *
   */
  public function map_field($field) {
    if ($this->mapper) {
      return $this->mapper
        ->map_field($field);
    }
    return $field;
  }

  /**
   *
   */
  public function map_type($field) {
    if ($this->mapper) {
      return $this->mapper
        ->map_type($field);
    }
    return $field;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
citeproc::$bibliography public property
citeproc::$citation public property
citeproc::$info private property
citeproc::$locale protected property
citeproc::$macros protected property
citeproc::$mapper private property
citeproc::$quash public property
citeproc::$style public property
citeproc::$style_locale protected property
citeproc::get_locale public function
citeproc::init public function
citeproc::map_field public function
citeproc::map_type public function
citeproc::render public function
citeproc::render_macro public function
citeproc::__construct public function