Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions views/helpers/CollectionTreeFullList.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Collection Tree
*
*
* @copyright Copyright 2007-2012 Roy Rosenzweig Center for History and New Media
* @license http://www.gnu.org/licenses/gpl-3.0.txt GNU GPLv3
*/
Expand All @@ -26,16 +26,17 @@ public function collectionTreeFullList($linkToCollectionShow = true)
return null;
}
$collectionTable = get_db()->getTable('Collection');
$html = '<div id="collection-tree"><ul>';
$html = '<h1>Collection Tree</h1><div id="collection-tree"><ul>';
foreach ($rootCollections as $rootCollection) {
$html .= '<li>';
if ($linkToCollectionShow) {
$html .= link_to_collection(null, array(), 'show', $collectionTable->find($rootCollection['id']));
$html .= link_to_collection(null, ["aria-label" => $rootCollection["name"]], 'show', $collectionTable->find($rootCollection['id']));
} else {
$html .= $rootCollection['name'] ? $rootCollection['name'] : __('[Untitled]');
}
$collectionTree = get_db()->getTable('CollectionTree')->getDescendantTree($rootCollection['id']);
$html .= $this->view->collectionTreeList($collectionTree, $linkToCollectionShow);
$html .= $this->view->collectionTreeList($collectionTree, $linkToCollectionShow, $rootCollection["name"]);
$html .= '</li>';
}
$html .= '</ul></div>';
Expand Down
14 changes: 11 additions & 3 deletions views/helpers/CollectionTreeList.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ class CollectionTree_View_Helper_CollectionTreeList extends Zend_View_Helper_Abs
* @see CollectionTreeTable::getDescendantTree()
* @param array $collectionTree
* @param bool $linkToCollectionShow
* @param string $parentString
* @return string
*/
public function collectionTreeList($collectionTree, $linkToCollectionShow = true)
public function collectionTreeList($collectionTree, $linkToCollectionShow = true, $parentString = '')
{
if (!$collectionTree) {
return;
Expand All @@ -31,10 +32,17 @@ public function collectionTreeList($collectionTree, $linkToCollectionShow = true
$collectionTable = get_db()->getTable('Collection');
$html = '<ul>';
foreach ($collectionTree as $collection) {
$path = '';
if (strlen($parentString) > 0) {
$path = $parentString.' / '.$collection['name'];
}
else {
$path = $collection['name'];
}
$html .= '<li>';
// No link to current collection.
if ($linkToCollectionShow && !isset($collection['current']) && isset($collection['id'])) {
$html .= link_to_collection(null, array(), 'show', $collectionTable->find($collection['id']));
$html .= link_to_collection(null, ["aria-label" => $path], 'show', $collectionTable->find($collection['id']));
}
// No link to private parent collection.
elseif (!isset($collection['id'])) {
Expand All @@ -44,7 +52,7 @@ public function collectionTreeList($collectionTree, $linkToCollectionShow = true
else {
$html .= empty($collection['name']) ? __('[Untitled]') : $collection['name'];
}
$html .= $this->collectionTreeList($collection['children'], $linkToCollectionShow);
$html .= $this->collectionTreeList($collection['children'], $linkToCollectionShow, $path);
$html .= '</li>';
}
$html .= '</ul>';
Expand Down