This repository was archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRockAwesome.module.php
65 lines (59 loc) · 1.82 KB
/
RockAwesome.module.php
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
<?php namespace ProcessWire;
/**
* RockAwesome Autoload Module
*
* @author Bernhard Baumrock, 16.03.2020
* @license Licensed under MIT
* @link https://www.baumrock.com
*/
class RockAwesome extends WireData implements Module, ConfigurableModule {
public static function getModuleInfo() {
return [
'title' => 'RockAwesome Autoload Module',
'version' => '0.0.2',
'summary' => 'Autoload Module to attach hooks',
'autoload' => true,
'singular' => true,
'icon' => 'bolt',
'requires' => ['FieldtypeRockAwesome'],
'installs' => [],
];
}
public function init() {
$conf = $this->modules->getConfig('InputfieldRockAwesome');
if(!array_key_exists('stylesheet', $conf)) {
$url = $this->pages->get(2)->url."module/edit?name=InputfieldRockAwesome";
$link = "<a href='$url'>here</a>";
$this->warning("See setup instructions $link", Notice::allowMarkup);
return;
}
$fa = $this->modules->getConfig('InputfieldRockAwesome')['stylesheet'];
$this->fa = trim($fa, "/");
// show warning if not exists
$file = $this->config->paths->root . $this->fa;
if(!is_file($file)) $this->warning("$file does not exist");
$this->fa = "/".$this->fa;
if($this->autoloadFA) $this->loadFA();
}
/**
* Load Fontawesome Styles
* @return void
*/
public function loadFA() {
$this->config->styles->add($this->fa);
}
/**
* Config inputfields
* @param InputfieldWrapper $inputfields
*/
public function getModuleConfigInputfields($inputfields) {
$inputfields->add([
'name' => 'autoloadFA',
'label' => 'Autoload FontAwesome styles on all admin pages',
'type' => 'checkbox',
'notes' => 'Style is located at ' . $this->fa,
'required' => false,
'checked' => $this->autoloadFA ? "checked" : "",
]);
}
}