diff --git a/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php b/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php index 9362261dfd775261c4c409f5241416379b48bc75..f24357777df2328bfc24e55daf19cba5db39e80d 100644 --- a/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php +++ b/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php @@ -445,6 +445,9 @@ class UtilController extends AbstractBase ->get('VuFind\SearchResultsPluginManager')->get('Solr') ->getFullFieldFacets(array('hierarchy_top_id')); foreach ($hierarchies['hierarchy_top_id']['data']['list'] as $hierarchy) { + if (empty($hierarchy['value'])) { + continue; + } Console::writeLine("Building tree for {$hierarchy['value']}..."); $driver = $recordLoader->load($hierarchy['value']); if ($driver->getHierarchyType()) { diff --git a/themes/bootstrap3/js/hierarchyTree.js b/themes/bootstrap3/js/hierarchyTree.js index 0342bb7afe0520aa997a04aa7cc5b0b11519db0e..111a8922310672adbcae038a1e71f54d900932bf 100644 --- a/themes/bootstrap3/js/hierarchyTree.js +++ b/themes/bootstrap3/js/hierarchyTree.js @@ -1,6 +1,6 @@ /*global hierarchySettings, html_entity_decode, jqEscape, path, vufindString*/ -var hierarchyID, recordID; +var hierarchyID, recordID, htmlID; var baseTreeSearchFullURL; function getRecord(recordID) @@ -50,7 +50,7 @@ function doTreeSearch() $('#hierarchyTree').find('.jstree-search').removeClass('jstree-search'); var tree = $('#hierarchyTree').jstree(true); tree.close_all(); - tree._open_to(recordID.replace(':', '-')); + tree._open_to(htmlID); $('#treeSearchLoadingImg').addClass('hidden'); } else { if(searchAjax) { @@ -68,11 +68,11 @@ function doTreeSearch() var tree = $('#hierarchyTree').jstree(true); tree.close_all(); for(var i=data.results.length;i--;) { - var id = data.results[i].replace(':', '-'); + var id = htmlEncodeId(data.results[i]); tree._open_to(id); } for(var i=data.results.length;i--;) { - var id = data.results[i].replace(':', '-'); + var id = htmlEncodeId(data.results[i]); $('#hierarchyTree').find('#'+id).addClass('jstree-search'); } changeNoResultLabel(false); @@ -94,8 +94,11 @@ function buildJSONNodes(xml) var id = content.children("name[class='JSTreeID']"); var name = content.children('name[href]'); jsonNode.push({ - 'id': id.text().replace(':', '-'), + 'id': htmlEncodeId(id.text()), 'text': name.text(), + 'li_attr': { + 'recordid': id.text() + }, 'a_attr': { 'href': name.attr('href') }, @@ -111,23 +114,24 @@ $(document).ready(function() // Code for the search button hierarchyID = $("#hierarchyTree").find(".hiddenHierarchyId")[0].value; recordID = $("#hierarchyTree").find(".hiddenRecordId")[0].value; + htmlID = htmlEncodeId(recordID); var context = $("#hierarchyTree").find(".hiddenContext")[0].value; $("#hierarchyTree") .bind("ready.jstree", function (event, data) { var tree = $("#hierarchyTree").jstree(true); - tree.select_node(recordID.replace(':', '-')); - tree._open_to(recordID.replace(':', '-')); + tree.select_node(htmlID); + tree._open_to(htmlID); if (context == "Collection") { - getRecord(recordID.replace('-', ':')); + getRecord(recordID); } $("#hierarchyTree").bind('select_node.jstree', function(e, data) { if (context == "Record") { window.location.href = data.node.a_attr.href; } else { - getRecord(data.node.id.replace('-', ':')); + getRecord(data.node.li_attr.recordid); } }); @@ -187,3 +191,8 @@ $(document).ready(function() } }); }); + +function htmlEncodeId(id) +{ + return id.replace(/\W/g, "-"); // Also change Hierarchy/TreeRenderer/JSTree.php +} \ No newline at end of file