Skip to content

Commit a2007b9

Browse files
committed
#82: prefix container list with level
1 parent a92a2e2 commit a2007b9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

includes/jstreebuilder.inc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class JSTreeBuilder {
8484
* Never actually got used?
8585
*/
8686
protected function getComponentTree(DOMElement $element) {
87+
$level = $this->translateLevelCode($this->xpath->evaluate('string(./@level)', $element));
8788
$unitid = $this->stringifyNode('ead:did/ead:unitid', $element);
8889
$title = $this->stringifyNode('ead:did/ead:unittitle', $element);
8990
$date = $this->stringifyNode('ead:did/ead:unitdate', $element);
@@ -96,6 +97,9 @@ class JSTreeBuilder {
9697
if ($unitid) {
9798
$text = $unitid.' '.$text;
9899
}
100+
if ($level) {
101+
$text = $level.' '.$text;
102+
}
99103
$info = array(
100104
'id' => $element->getAttribute('id'),
101105
'text' => $text,
@@ -109,6 +113,28 @@ class JSTreeBuilder {
109113
return $info;
110114
}
111115

116+
/**
117+
* Given the string of a component's level
118+
* return a human-readable representation
119+
* @param string $level the code from an EAD component's level attribute
120+
* @return string A human-readable representation
121+
*/
122+
protected function translateLevelCode($level) {
123+
$value = '';
124+
switch ($level) {
125+
case 'recordgrp':
126+
$value = t('Record Group');
127+
break;
128+
case 'subgrp':
129+
$value = t('Subgroup');
130+
break;
131+
default:
132+
$value = t(ucfirst($level));
133+
}
134+
return $value;
135+
}
136+
137+
112138
/**
113139
* Given the xpath to a single node in a DOMElement,
114140
* return the text content of the node and its children

0 commit comments

Comments
 (0)