xref: /webtrees/app/Module/BingWebmasterToolsModule.php (revision 5699f0a83a2de4eb36061c6fe323f79158f888c2)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees\Module;
19
20/**
21 * Class BingWebmasterToolsModule - add support for Bing webmaster tools
22 */
23class BingWebmasterToolsModule extends AbstractModule implements ModuleAnalyticsInterface
24{
25    use ModuleAnalyticsTrait;
26
27    /**
28     * How should this module be labelled on tabs, menus, etc.?
29     *
30     * @return string
31     */
32    public function title(): string
33    {
34        return 'Bing™ webmaster tools';
35    }
36
37    /**
38     * Form fields to edit the parameters.
39     *
40     * @return string
41     */
42    public function analyticsFormFields(): string
43    {
44        return view('admin/analytics/bing-webmaster-form', $this->analyticsParameters());
45    }
46
47    /**
48     * Home page for the service.
49     *
50     * @return string
51     */
52    public function analyticsHomePageUrl(): string
53    {
54        return 'https://www.bing.com/toolbox/webmaster';
55    }
56
57    /**
58     * The parameters that need to be embedded in the snippet.
59     *
60     * @return string[]
61     */
62    public function analyticsParameters(): array
63    {
64        return [
65            'BING_WEBMASTER_ID' => $this->getPreference('BING_WEBMASTER_ID')
66        ];
67    }
68
69    /**
70     * Embed placeholders in the snippet.
71     *
72     * @param string[] $parameters
73     *
74     * @return string
75     */
76    public function analyticsSnippet(array $parameters): string
77    {
78        return view('admin/analytics/bing-webmaster-snippet', $parameters);
79    }
80}
81