You are here

class citeproc in Bibliography Module 6.2

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

CiteProc-PHP

Copyright (C) 2010 - 2011 Ron Jerome, all rights reserved

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Hierarchy

Expanded class hierarchy of citeproc

File

modules/CiteProc/CSL.inc, line 23

View source
class citeproc {
  public $bibliography;
  public $citation;
  public $style;
  protected $macros;
  private $info;
  protected $locale;
  protected $style_locale;
  public $quash;
  private $mapper;
  function __construct($csl = NULL, $lang = 'en') {
    if ($csl) {
      $this
        ->init($csl, $lang);
    }
  }
  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);
      }
    }
  }
  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;
  }
  function render_macro($name, $data, $mode) {
    return $this->macros
      ->render_macro($name, $data, $mode);
  }
  function get_locale($type, $arg1, $arg2 = NULL, $arg3 = NULL) {
    return $this->locale
      ->get_locale($type, $arg1, $arg2, $arg3);
  }
  function map_field($field) {
    if ($this->mapper) {
      return $this->mapper
        ->map_field($field);
    }
    return $field;
  }
  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 function
citeproc::init function
citeproc::map_field function
citeproc::map_type function
citeproc::render function
citeproc::render_macro function
citeproc::__construct function