You are here

class csl_date_part in Bibliography Module 7

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

Hierarchy

Expanded class hierarchy of csl_date_part

File

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

View source
class csl_date_part extends csl_format {

  /**
   *
   */
  public function render($date, $mode = NULL) {
    $text = '';
    switch ($this->name) {
      case 'year':
        $text = isset($date[0]) ? $date[0] : '';
        if ($text > 0 && $text < 500) {
          $text = $text . $this->citeproc
            ->get_locale('term', 'ad');
        }
        elseif ($text < 0) {
          $text = $text * -1;
          $text = $text . $this->citeproc
            ->get_locale('term', 'bc');
        }

        // Return ((isset($this->prefix))? $this->prefix : '') . $date[0] . ((isset($this->suffix))? $this->suffix : '');.
        break;
      case 'month':
        $text = isset($date[1]) ? $date[1] : '';
        if (empty($text) || $text < 1 || $text > 12) {
          return;
        }

        // $form = $this->form;.
        switch ($this->form) {
          case 'numeric':
            break;
          case 'numeric-leading-zeros':
            if ($text < 10) {
              $text = '0' . $text;
              break;
            }
            break;
          case 'short':
            $month = 'month-' . sprintf('%02d', $text);
            $text = $this->citeproc
              ->get_locale('term', $month, 'short');
            break;
          default:
            $month = 'month-' . sprintf('%02d', $text);
            $text = $this->citeproc
              ->get_locale('term', $month);
            break;
        }
        break;
      case 'day':
        $text = isset($date[2]) ? $date[2] : '';
        break;
    }
    return $this
      ->format($text);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
csl_collection::$elements protected property
csl_collection::add_element public function
csl_date_part::render public function Overrides csl_rendering_element::render
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::__get public function
csl_element::__isset public function
csl_element::__set public function
csl_element::__unset public function
csl_format::$format protected property 1
csl_format::$no_op protected property
csl_format::format public function Overrides csl_collection::format 1
csl_format::init_formatting public function 5
csl_format::__construct public function Overrides csl_element::__construct 2