Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Versions
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 isActive
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 getDescription
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * Versions tab
5 *
6 * PHP version 8
7 *
8 * Copyright (C) The National Library of Finland 2019-2020.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2,
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 *
23 * @category VuFind
24 * @package  RecordTabs
25 * @author   Ere Maijala <ere.maijala@helsinki.fi>
26 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
27 * @link     https://vufind.org/wiki/development:plugins:record_tabs Wiki
28 */
29
30namespace VuFind\RecordTab;
31
32use VuFind\I18n\Translator\TranslatorAwareInterface;
33use VuFind\I18n\Translator\TranslatorAwareTrait;
34
35/**
36 * Versions tab
37 *
38 * @category VuFind
39 * @package  RecordTabs
40 * @author   Ere Maijala <ere.maijala@helsinki.fi>
41 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
42 * @link     https://vufind.org/wiki/development:plugins:record_tabs Wiki
43 */
44class Versions extends \VuFind\RecordTab\AbstractBase implements TranslatorAwareInterface
45{
46    use TranslatorAwareTrait;
47
48    /**
49     * Main configuration
50     *
51     * @var \Laminas\Config\Config
52     */
53    protected $config;
54
55    /**
56     * Search options plugin manager
57     *
58     * @var \VuFind\Search\Options\PluginManager
59     */
60    protected $searchOptionsManager;
61
62    /**
63     * Constructor
64     *
65     * @param \Laminas\Config\Config               $config Configuration
66     * @param \VuFind\Search\Options\PluginManager $som    Search options plugin
67     * manager
68     */
69    public function __construct(
70        \Laminas\Config\Config $config,
71        \VuFind\Search\Options\PluginManager $som
72    ) {
73        $this->config = $config;
74        $this->searchOptionsManager = $som;
75    }
76
77    /**
78     * Is this tab active?
79     *
80     * @return bool
81     */
82    public function isActive()
83    {
84        $options = $this->searchOptionsManager
85            ->get($this->getRecordDriver()->getSourceIdentifier());
86        return $options->getVersionsAction()
87            && $this->getRecordDriver()->tryMethod('getOtherVersionCount') > 0;
88    }
89
90    /**
91     * Get the on-screen description for this tab.
92     *
93     * @return string
94     */
95    public function getDescription()
96    {
97        $count = $this->getRecordDriver()->tryMethod('getOtherVersionCount');
98        return $this->translate('other_versions_title', ['%%count%%' => $count]);
99    }
100}