Skip to content

Commit

Permalink
discoverygarden#82: prefix container list with level
Browse files Browse the repository at this point in the history
  • Loading branch information
ctgraham committed May 31, 2022
1 parent a92a2e2 commit a2007b9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions includes/jstreebuilder.inc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class JSTreeBuilder {
* Never actually got used?
*/
protected function getComponentTree(DOMElement $element) {
$level = $this->translateLevelCode($this->xpath->evaluate('string(./@level)', $element));
$unitid = $this->stringifyNode('ead:did/ead:unitid', $element);
$title = $this->stringifyNode('ead:did/ead:unittitle', $element);
$date = $this->stringifyNode('ead:did/ead:unitdate', $element);
Expand All @@ -96,6 +97,9 @@ class JSTreeBuilder {
if ($unitid) {
$text = $unitid.' '.$text;
}
if ($level) {
$text = $level.' '.$text;
}
$info = array(
'id' => $element->getAttribute('id'),
'text' => $text,
Expand All @@ -109,6 +113,28 @@ class JSTreeBuilder {
return $info;
}

/**
* Given the string of a component's level
* return a human-readable representation
* @param string $level the code from an EAD component's level attribute
* @return string A human-readable representation
*/
protected function translateLevelCode($level) {
$value = '';
switch ($level) {
case 'recordgrp':
$value = t('Record Group');
break;
case 'subgrp':
$value = t('Subgroup');
break;
default:
$value = t(ucfirst($level));
}
return $value;
}


/**
* Given the xpath to a single node in a DOMElement,
* return the text content of the node and its children
Expand Down

0 comments on commit a2007b9

Please sign in to comment.