You are here

public function csl_number::roman in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 modules/CiteProc/CSL.inc \csl_number::roman()
  2. 7.2 modules/CiteProc/CSL.inc \csl_number::roman()
1 call to csl_number::roman()
csl_number::render in modules/CiteProc/CSL.inc

File

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

Class

csl_number

Code

public function roman($num) {
  $ret = "";
  if ($num < 6000) {
    $ROMAN_NUMERALS = array(
      array(
        "",
        "i",
        "ii",
        "iii",
        "iv",
        "v",
        "vi",
        "vii",
        "viii",
        "ix",
      ),
      array(
        "",
        "x",
        "xx",
        "xxx",
        "xl",
        "l",
        "lx",
        "lxx",
        "lxxx",
        "xc",
      ),
      array(
        "",
        "c",
        "cc",
        "ccc",
        "cd",
        "d",
        "dc",
        "dcc",
        "dccc",
        "cm",
      ),
      array(
        "",
        "m",
        "mm",
        "mmm",
        "mmmm",
        "mmmmm",
      ),
    );
    $numstr = strrev($num);
    $len = strlen($numstr);
    for ($pos = 0; $pos < $len; $pos++) {
      $n = $numstr[$pos];
      $ret = $ROMAN_NUMERALS[$pos][$n] . $ret;
    }
  }
  return $ret;
}