xref: /webtrees/app/Module/GoogleWebmasterToolsModule.php (revision 0cfd6963ac65bd7fe86283b801b4f23d665c6004)
137eb8894SGreg Roach<?php
237eb8894SGreg Roach/**
337eb8894SGreg Roach * webtrees: online genealogy
437eb8894SGreg Roach * Copyright (C) 2019 webtrees development team
537eb8894SGreg Roach * This program is free software: you can redistribute it and/or modify
637eb8894SGreg Roach * it under the terms of the GNU General Public License as published by
737eb8894SGreg Roach * the Free Software Foundation, either version 3 of the License, or
837eb8894SGreg Roach * (at your option) any later version.
937eb8894SGreg Roach * This program is distributed in the hope that it will be useful,
1037eb8894SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1137eb8894SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1237eb8894SGreg Roach * GNU General Public License for more details.
1337eb8894SGreg Roach * You should have received a copy of the GNU General Public License
1437eb8894SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
1537eb8894SGreg Roach */
1637eb8894SGreg Roachdeclare(strict_types=1);
1737eb8894SGreg Roach
1837eb8894SGreg Roachnamespace Fisharebest\Webtrees\Module;
1937eb8894SGreg Roach
2037eb8894SGreg Roach/**
2137eb8894SGreg Roach * Class GoogleWebmasterToolsModule - add support for Google webmaster tools.
2237eb8894SGreg Roach */
238e5c5efeSGreg Roachclass GoogleWebmasterToolsModule extends AbstractModule implements ModuleAnalyticsInterface, ModuleConfigInterface, ModuleExternalUrlInterface
2437eb8894SGreg Roach{
2537eb8894SGreg Roach    use ModuleAnalyticsTrait;
268e5c5efeSGreg Roach    use ModuleConfigTrait;
278e5c5efeSGreg Roach    use ModuleExternalUrlTrait;
2837eb8894SGreg Roach
2937eb8894SGreg Roach    /**
30*0cfd6963SGreg Roach     * How should this module be identified in the control panel, etc.?
3137eb8894SGreg Roach     *
3237eb8894SGreg Roach     * @return string
3337eb8894SGreg Roach     */
345699f0a8SGreg Roach    public function title(): string
355699f0a8SGreg Roach    {
3637eb8894SGreg Roach        return 'Google™ webmaster tools';
3737eb8894SGreg Roach    }
3837eb8894SGreg Roach
3937eb8894SGreg Roach    /**
4037eb8894SGreg Roach     * Form fields to edit the parameters.
4137eb8894SGreg Roach     *
4237eb8894SGreg Roach     * @return string
4337eb8894SGreg Roach     */
4437eb8894SGreg Roach    public function analyticsFormFields(): string
4537eb8894SGreg Roach    {
468e5c5efeSGreg Roach        return view('modules/google-webmaster-tools/form', $this->analyticsParameters());
4737eb8894SGreg Roach    }
4837eb8894SGreg Roach
4937eb8894SGreg Roach    /**
5037eb8894SGreg Roach     * Home page for the service.
5137eb8894SGreg Roach     *
5237eb8894SGreg Roach     * @return string
5337eb8894SGreg Roach     */
548e5c5efeSGreg Roach    public function externalUrl(): string
5537eb8894SGreg Roach    {
5637eb8894SGreg Roach        return 'https://www.google.com/webmasters';
5737eb8894SGreg Roach    }
5837eb8894SGreg Roach
5937eb8894SGreg Roach    /**
6037eb8894SGreg Roach     * The parameters that need to be embedded in the snippet.
6137eb8894SGreg Roach     *
6237eb8894SGreg Roach     * @return string[]
6337eb8894SGreg Roach     */
6437eb8894SGreg Roach    public function analyticsParameters(): array
6537eb8894SGreg Roach    {
6637eb8894SGreg Roach        return [
6737eb8894SGreg Roach            'GOOGLE_WEBMASTER_ID' => $this->getPreference('GOOGLE_WEBMASTER_ID')
6837eb8894SGreg Roach        ];
6937eb8894SGreg Roach    }
7037eb8894SGreg Roach
7137eb8894SGreg Roach    /**
7237eb8894SGreg Roach     * Embed placeholders in the snippet.
7337eb8894SGreg Roach     *
7437eb8894SGreg Roach     * @param string[] $parameters
7537eb8894SGreg Roach     *
7637eb8894SGreg Roach     * @return string
7737eb8894SGreg Roach     */
7837eb8894SGreg Roach    public function analyticsSnippet(array $parameters): string
7937eb8894SGreg Roach    {
808e5c5efeSGreg Roach        return view('modules/google-webmaster-tools/snippet', $parameters);
8137eb8894SGreg Roach    }
8237eb8894SGreg Roach}
83