This repository was archived by the owner on Mar 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.php
More file actions
98 lines (83 loc) · 3.32 KB
/
Copy pathmodule.php
File metadata and controls
98 lines (83 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* webtrees: online genealogy
* Copyright (C) 2018 JustCarmen (http://justcarmen.nl)
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 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, see <http://www.gnu.org/licenses/>.
*/
namespace JustCarmen\WebtreesAddOns\JustLight;
use Composer\Autoload\ClassLoader;
use Fisharebest\Webtrees\Database;
use Fisharebest\Webtrees\Filter;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Log;
use Fisharebest\Webtrees\Module\AbstractModule;
use Fisharebest\Webtrees\Module\ModuleConfigInterface;
use JustCarmen\WebtreesAddOns\JustLight\Template\AdminTemplate;
class JustLightThemeOptionsModule extends AbstractModule implements ModuleConfigInterface {
const CUSTOM_VERSION = '1.7.11';
const CUSTOM_WEBSITE = 'http://www.justcarmen.nl/themes/justlight/';
// How to update the database schema for this module
const SCHEMA_TARGET_VERSION = 2;
const SCHEMA_SETTING_NAME = 'JL_SCHEMA_VERSION';
const SCHEMA_MIGRATION_PREFIX = '\JustCarmen\WebtreesAddOns\JustLight\Schema';
/** @var string location of the JustBlack Theme Options module files */
var $directory;
public function __construct() {
parent::__construct('justlight_theme_options');
$this->directory = WT_MODULES_DIR . $this->getName();
// register the namespace
$loader = new ClassLoader();
$loader->addPsr4('JustCarmen\\WebtreesAddOns\\JustLight\\', $this->directory . '/app');
$loader->register();
}
/**
* Get the module class.
*
* Class functions are called with $this inside the source directory.
*/
private function module() {
return new JustLightThemeOptionsClass;
}
// Extend Module
public function getTitle() {
return /* I18N: Name of a module */ I18N::translate('JustLight Theme Options');
}
// Extend Module
public function getDescription() {
return /* I18N: Description of the module */ I18N::translate('Set options for the JustLight theme within the admin interface');
}
// Extend ModuleConfigInterface
public function modAction($mod_action) {
Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
switch ($mod_action) {
case 'admin_config':
if (Filter::postBool('save') && Filter::checkCsrf()) {
$this->module()->saveOptions();
}
$template = new AdminTemplate;
return $template->pageContent();
case 'admin_reset':
Database::prepare("DELETE FROM `##module_setting` WHERE setting_name LIKE 'JL%'")->execute();
Log::addConfigurationLog($this->getTitle() . ' reset to default values');
$template = new AdminTemplate;
return $template->pageContent();
default:
http_response_code(404);
break;
}
}
// Implement ModuleConfigInterface
public function getConfigLink() {
return 'module.php?mod=' . $this->getName() . '&mod_action=admin_config';
}
}
return new JustLightThemeOptionsModule;