From 1a23e0fee3b922e1727b41220033e7feec052d01 Mon Sep 17 00:00:00 2001
From: Dorian Merz <merz@ub.uni-leipzig.de>
Date: Wed, 21 Jul 2021 14:59:07 +0200
Subject: [PATCH] refs #19493 [fid_adlr] link to holdings tab from hierarchy
 tree * remove specialized tree renderer * add linked tab config

---
 fid_adlr/config/vufind/HierarchyDefault.ini   |  5 ++
 module/fid_adlr/config/module.config.php      |  9 ---
 .../src/Hierarchy/TreeRenderer/JSTree.php     | 63 -------------------
 3 files changed, 5 insertions(+), 72 deletions(-)
 delete mode 100644 module/fid_adlr/src/Hierarchy/TreeRenderer/JSTree.php

diff --git a/fid_adlr/config/vufind/HierarchyDefault.ini b/fid_adlr/config/vufind/HierarchyDefault.ini
index 49711ebfe97..baed5f9b50a 100644
--- a/fid_adlr/config/vufind/HierarchyDefault.ini
+++ b/fid_adlr/config/vufind/HierarchyDefault.ini
@@ -27,3 +27,8 @@ relative_path = ../../../fid/config/vufind/HierarchyDefault.ini
 ;     Top  - any record where is_hierarchy = hierarchy_top
 ;     None - never link to the collection module
 link_type = "Top"
+
+[TreeRenderer]
+linkedTabForParents = Holdings
+linkedTabDefault = Holdings
+
diff --git a/module/fid_adlr/config/module.config.php b/module/fid_adlr/config/module.config.php
index 522d8c33be3..6c895ddf2ff 100644
--- a/module/fid_adlr/config/module.config.php
+++ b/module/fid_adlr/config/module.config.php
@@ -29,7 +29,6 @@ use fid_adlr\Controller\RecordController;
 use fid_adlr\Controller\RecordControllerDelegatorFactory;
 use fid_adlr\Controller\SearchController;
 use fid_adlr\Helper\Rss;
-use fid_adlr\Hierarchy\TreeRenderer\JSTree as AdlrJSTree;
 use VuFind\Controller\AbstractBaseWithConfigFactory;
 use Zend\Router\Http\Regex;
 use Zend\ServiceManager\Factory\InvokableFactory;
@@ -126,14 +125,6 @@ $config = [
                     'toc'             => 'fid_adlr\RecordTab\TOC'
                 ],
             ],
-            'hierarchy_treerenderer' => [
-                'factories' => [
-                   AdlrJSTree::class => 'VuFind\Hierarchy\TreeRenderer\JSTreeFactory'
-                ],
-                'aliases' => [
-                    'jstree' => AdlrJSTree::class
-                ],
-            ],
         ],
         'recorddriver_tabs'            => [
             'finc\RecordDriver\SolrDefault'  => [
diff --git a/module/fid_adlr/src/Hierarchy/TreeRenderer/JSTree.php b/module/fid_adlr/src/Hierarchy/TreeRenderer/JSTree.php
deleted file mode 100644
index 633eb47567e..00000000000
--- a/module/fid_adlr/src/Hierarchy/TreeRenderer/JSTree.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-/**
- * Hierarchy Tree Renderer for the JS_Tree plugin
- *
- * PHP version 5
- *
- * Copyright (C) Villanova University 2010.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * @category VuFind
- * @package  HierarchyTree_Renderer
- * @author   Luke O'Sullivan <l.osullivan@swansea.ac.uk>
- * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
- * @link     https://vufind.org/wiki/development:plugins:hierarchy_components Wiki
- */
-namespace fid_adlr\Hierarchy\TreeRenderer;
-
-/**
- * Hierarchy Tree Renderer
- *
- * This is a helper class for producing hierarchy trees.
- *
- * @category VuFind
- * @package  HierarchyTree_Renderer
- * @author   Luke O'Sullivan <l.osullivan@swansea.ac.uk>
- * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
- * @link     https://vufind.org/wiki/development:plugins:hierarchy_components Wiki
- */
-class JSTree extends \finc\Hierarchy\TreeRenderer\JSTree
-{
-    /**
-     * Get the URL for a record and cache it to avoid the relatively slow routing
-     * calls.
-     *
-     * @param string $route Route
-     * @param string $id    Record ID
-     *
-     * @return string URL
-     */
-    protected function getUrlFromRouteCache($route, $id)
-    {
-        static $cache = [];
-        if (!isset($cache[$route])) {
-            $params = [
-                'id' => '__record_id__'
-            ];
-            $cache[$route] = $this->router->fromRoute($route, $params);
-        }
-        return str_replace('__record_id__', $id, $cache[$route]);
-    }
-}
-- 
GitLab