* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
 * @param array $basedir
 * @param array $subdir      The currently chosen subdirectry
 * @param array $directories The subdirectories of $basedir to be used for navigation
 * @param array $documents   The documents to be listed in the current view
 * @param stdClass $node     The drupal node object
 */
?>
<section class="cmisro container">
    <h1><?php 
echo $basedir['title'];
?>
</h1>
    <nav>
    <?php 
$uri = _cmisro_folder_uri($node->nid, $basedir['id']);
foreach ($directories as $dir) {
    $attr = $dir['id'] === $subdir['id'] ? ['attributes' => ['class' => ['current']]] : [];
    echo l($dir['title'], $uri . "/{$dir['id']}", $attr);
}
?>
    </nav>
    <div class="listing">
        <dl><dd><dl>
                <?php 
foreach ($documents as $o) {
    $a = theme('cmisro_item', ['object' => $o]);
    echo "<dd>{$a}</dd>";
}
?>
                </dl>
/**
 * @implements hook_field_formatter_view()
 * @see https://api.drupal.org/api/drupal/modules!field!field.api.php/function/hook_field_formatter_view/7
 */
function cmisro_field_formatter_view($entity_type, $entity, $field, $instance, $lang, $items, $display)
{
    $element = [];
    switch ($display['type']) {
        case 'cmisro_reference_formatter':
            foreach ($items as $delta => $item) {
                try {
                    $element[$delta] = ['#markup' => theme('cmisro_reference', ['reference' => $item['reference']])];
                } catch (\Exception $e) {
                    // The item references should have already been checked when the user
                    // originally saved them in the content.
                    // If there's a problem with one of them at display-time,
                    // we can just ignore it.
                }
            }
            break;
            /**
             * Render a link to the custom route we've declared
             * @see cmisro_menu()
             */
        /**
         * Render a link to the custom route we've declared
         * @see cmisro_menu()
         */
        case 'cmisro_directorylisting_formatter':
            foreach ($items as $i => $item) {
                try {
                    $o = _cmisro_getObject($item['reference']);
                    $uri = _cmisro_folder_uri($entity->nid, $o['id']);
                    $attr = current_path() === $uri ? ['attributes' => ['class' => ['current']]] : [];
                    $element[$i] = ['#markup' => l($o['title'], $uri, $attr)];
                } catch (\Exception $e) {
                    // The item references should have already been checked when the user
                    // originally saved them in the content.
                    // If there's a problem with one of them at display-time,
                    // we can just ignore it.
                }
            }
            break;
    }
    return $element;
}