function _tableofcontents_roman in Table of Contents 6.3
Same name and namespace in other branches
- 7.2 tableofcontents.themes.inc \_tableofcontents_roman()
- 7 tableofcontents.pages.inc \_tableofcontents_roman()
1 call to _tableofcontents_roman()
- _tableofcontents_convert_number in ./tableofcontents.pages.inc
- Transform a decimal number in one of:
File
- ./tableofcontents.pages.inc, line 1062
- Applies the filter functions.
Code
function _tableofcontents_roman($arabic) {
static $ones = array(
"",
"I",
"II",
"III",
"IV",
"V",
"VI",
"VII",
"VIII",
"IX",
);
static $tens = array(
"",
"X",
"XX",
"XXX",
"XL",
"L",
"LX",
"LXX",
"LXXX",
"XC",
);
static $hundreds = array(
"",
"C",
"CC",
"CCC",
"CD",
"D",
"DC",
"DCC",
"DCCC",
"CM",
);
static $thousands = array(
"",
"M",
"MM",
"MMM",
"MMMM",
);
if ($arabic > 4999) {
return $arabic;
}
elseif ($arabic == 0) {
return "N";
}
else {
$m = fmod($arabic, 1000);
$roman = $thousands[($arabic - $m) / 1000];
$arabic = $m;
$m = fmod($arabic, 100);
$roman .= $hundreds[($arabic - $m) / 100];
$arabic = $m;
$m = fmod($arabic, 10);
$roman .= $tens[($arabic - $m) / 10];
$arabic = $m;
$m = fmod($arabic, 1);
$roman .= $ones[($arabic - $m) / 1];
return $roman;
}
}