/** * Prints HTML for the elements from the given item in the given element set * and optionally specific element names. * If no element names are specified, all the elements in the set will be * output. * * @param Item $item The item whose metadata to output * @param string $setName The name of the set to output metadata for * @param array $elementNames Array of element names to be output */ private function _outputSetElements($item, $setName, $elementNames = null) { $outputTexts = array(); if (!$elementNames) { $elements = $item->getElementsBySetName($setName); foreach ($elements as $element) { foreach ($item->getElementTexts($setName, $element->name) as $text) { $outputTexts[] = array('element' => $element->name, 'text' => $text->text); } } } else { if (is_array($elementNames)) { foreach ($elementNames as $elementName) { $texts = $item->getElementTexts($setName, $elementName); foreach ($texts as $text) { $outputTexts[] = array('element' => $elementName, 'text' => $text->text); } } } } if (count($outputTexts)) { echo "<h3>{$setName}</h3>"; echo '<table class="element-texts" cellpadding="0" cellspacing="0">'; foreach ($outputTexts as $outputText) { echo '<tr class="element">' . '<th scope="row" class="element-name">' . $outputText['element'] . '</th>' . '<td class="element-value">' . $outputText['text'] . '</td>' . '</tr>'; } echo '</table>'; } }