xref: /webtrees/app/Module/BingWebmasterToolsModule.php (revision 37eb8894d5d4381f3fd9b791a53a32f0012b32ec)
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        return 'Bing™ webmaster tools';
34    }
35
36    /**
37     * Form fields to edit the parameters.
38     *
39     * @return string
40     */
41    public function analyticsFormFields(): string
42    {
43        return view('admin/analytics/bing-webmaster-form', $this->analyticsParameters());
44    }
45
46    /**
47     * Home page for the service.
48     *
49     * @return string
50     */
51    public function analyticsHomePageUrl(): string
52    {
53        return 'https://www.bing.com/toolbox/webmaster';
54    }
55
56    /**
57     * The parameters that need to be embedded in the snippet.
58     *
59     * @return string[]
60     */
61    public function analyticsParameters(): array
62    {
63        return [
64            'BING_WEBMASTER_ID' => $this->getPreference('BING_WEBMASTER_ID')
65        ];
66    }
67
68    /**
69     * Embed placeholders in the snippet.
70     *
71     * @param string[] $parameters
72     *
73     * @return string
74     */
75    public function analyticsSnippet(array $parameters): string
76    {
77        return view('admin/analytics/bing-webmaster-snippet', $parameters);
78    }
79}
80