-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAdminTemplateColumns.module
112 lines (85 loc) · 3.19 KB
/
AdminTemplateColumns.module
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/**
* Admin Template Columns
*
* Adds left and right column fieldsets to use in admin templates and applies styling to remove their borders and padding (otherwise we wouldn't need the module! :))
*
*/
class AdminTemplateColumns extends ModuleJS implements Module {
/**
* getModuleInfo is a module required by all modules to tell ProcessWire about them
*
* @return array
*
*/
public static function getModuleInfo() {
return array(
// The module'ss title, typically a little more descriptive than the class name
'title' => 'Admin Template Columns',
// version: major, minor, revision, i.e. 100 = 1.0.0
'version' => 101,
// summary is brief description of what this module is
'summary' => "Adds left and right column fieldsets to use in any admin templates and applies styling to remove their borders and padding",
'href' => 'http://processwire.com/talk/topic/4428-admintemplatecolumns/',
// Optional URL to more information about the module
//'href' => 'http://www.processwire.com',
// singular=true: indicates that only one instance of the module is allowed.
// This is usually what you want for modules that attach hooks.
'singular' => true,
// autoload=true: indicates the module should be started with ProcessWire.
// This is necessary for any modules that attach runtime hooks, otherwise those
// hooks won't get attached unless some other code calls the module on it's own.
// Note that autoload modules are almost always also 'singular' (seen above).
'autoload' => 'template=admin',
);
}
/**
* Initialize the module
*
*/
public function init() {
parent::init();
}
/**
* Install the module
*
*/
public function ___install() {
// If the fields don't already exist, create them (likely the user uninstalled then reinstalled the module since we're using a pretty unique field name)
if(!$this->fields->get('admin_column_left')) {
$field = new Field();
$field->type = $this->modules->get("FieldtypeFieldsetOpen");
$field->name = 'admin_column_left';
$field->label = 'Left Column';
$field->description = '';
$field->columnWidth = 70;
$field->save();
}
if(!$this->fields->get('admin_column_left_END')) {
$field = new Field();
$field->type = $this->modules->get("FieldtypeFieldsetClose");
$field->name = "admin_column_left_END";
$field->label = "Left Column End";
$field->description = '';
$field->save();
}
if(!$this->fields->get('admin_column_right')) {
$field = new Field();
$field->type = $this->modules->get("FieldtypeFieldsetOpen");
$field->name = 'admin_column_right';
$field->label = 'Right Column';
$field->description = '';
$field->columnWidth = 29;
$field->save();
}
if(!$this->fields->get('admin_column_right_END')) {
$field = new Field();
$field->type = $this->modules->get("FieldtypeFieldsetClose");
$field->name = "admin_column_right_END";
$field->label = "Right Column End";
$field->description = '';
$field->save();
}
$this->message("Added fieldsets 'admin_column_left' and 'admin_column_right' to left or right align fields in columns in your templates in the page editor");
}
}