-
Notifications
You must be signed in to change notification settings - Fork 1
/
nodetools.module
232 lines (206 loc) · 6.31 KB
/
nodetools.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?php
function nodetools_modules_enabled($modules) {
foreach($modules as $module) {
$node_info_array = module_invoke($module, 'node_info');
// If module implements hoon_node_info
if (!empty($node_info_array)) {
foreach($node_info_array as $type => $node_info) {
$node_info['type'] = $type;
nodetools_set_node_submission_form_settings($node_info);
nodetools_set_node_publishing_settings($node_info);
nodetools_set_node_display_settings($node_info);
nodetools_set_node_comment_settings($node_info);
nodetools_set_node_menu_settings($node_info);
/**
* TODO: Add multilingual support
* language_content_type_{$type}
* value <string>:
* 0 => Disabled
* 1 => Enabled
* 2 => Enabled, with entity translation
*/
}
}
}
}
function nodetools_modules_disabled($modules) {
$variables = array(
'comment_default_mode_',
'comment_default_per_page_',
'comment_form_location_',
'comment_',
'comment_preview_',
'comment_subject_field_',
'entity_translation_comment_filter_',
'entity_translation_node_metadata_',
'language_content_type_',
'menu_options_',
'menu_parent_',
'node_options_',
'node_preview_',
'node_submitted_',
'additional_settings__active_tab_',
'comment_anonymous_',
);
foreach ($modules as $module) {
$node_info_array = module_invoke($module, 'node_info');
if (!empty($node_info_array)) {
foreach($node_info_array as $type => $node_info) {
foreach ($variables as $variable) {
$variable_name = $variable . $type;
variable_del($variable_name);
}
}
}
}
}
function nodetools_set_node_submission_form_settings($node_info) {
/**
* Submission form settings (core functional)
* ------------------------------------------
*
* Preview before submitting
* node_preview_{$type}
* value <string>:
* 0 => Disabled
* 1 => Optional
* 2 => Required
*/
if (isset($node_info['node-preview'])) {
variable_set("node_preview_{$node_info['type']}", $node_info['node-preview']);
}
}
function nodetools_set_node_publishing_settings($node_info) {
/**
* Publishing options (core functional)
* ------------------------------------
*
* Default options
* node_options_{$type}
* value <array>:
* array('status', 'promote', 'sticky', 'revision')
*/
if (isset($node_info['node-options'])) {
variable_set("node_options_{$node_info['type']}", $node_info['node-options']);
}
}
function nodetools_set_node_display_settings($node_info) {
/**
* Display settings
* ----------------
*
* Display author and date information
* node_submitted_{$type}
* value <string>:
* 0 => Hide author and date information
* 1 => Display author and date information
*/
if (isset($node_info['node-submitted'])) {
variable_set("node_submitted_{$node_info['type']}", $node_info['node-submitted']);
}
}
function nodetools_set_node_comment_settings($node_info) {
/**
* Comment settings
* ----------------
*
* Default comment setting for new content
* comment_{$type}
* values:
* 0 => hidden
* 1 => closed
* 2 => open
*
* Threading
* comment_default_mode_{$type}
* values:
* 0 => don't show
* 1 => show
*
* Anonymous commenting settings
* comment_anonymous_{$type}
* values:
* 0 => Anonymous posters may not enter contact information
* 1 => Anonymous posters may leave contact information
* 2 => Anonymous posters must leave contact information
*
* Comments per page
* comment_default_per_page_{$type}
* values:
* 10, 30, 50, 70, 90, 150, 200, 250, 300
*
* Show reply form on the same page as comments
* comment_form_location_{$type}
* values:
* 0 => hide
* 1 => show
*
* Preview comment
* comment_preview_{$type}
* values:
* 0 => disabled
* 1 => optional
* 2 => required
*
* Allow comment title
* comment_subject_field_{$type}
* values:
* 0 => disallow
* 1 => allow
*/
if (module_exists('comment')) {
if (isset($node_info['comment'])) {
// set data
if (isset($node_info['comment']['status'])) {
variable_set("comment_{$node_info['type']}", $node_info['comment']['status']);
}
if (isset($node_info['comment']['default-mode'])) {
variable_set("comment_default_mode_{$node_info['type']}", $node_info['comment']['default-mode']);
}
if (isset($node_info['comment']['anonymous'])) {
variable_set("comment_anonymous_{$node_info['type']}", $node_info['comment']['anonymous']);
}
if (isset($node_info['comment']['default-per-page'])) {
variable_set("comment_default_per_page_{$node_info['type']}", $node_info['comment']['default-per-page']);
}
if (isset($node_info['comment']['form-location'])) {
variable_set("comment_form_location_{$node_info['type']}", $node_info['comment']['form-location']);
}
if (isset($node_info['comment']['preview'])) {
variable_set("comment_preview_{$node_info['type']}", $node_info['comment']['preview']);
}
if (isset($node_info['comment']['subject-field'])) {
variable_set("comment_subject_field_{$node_info['type']}", $node_info['comment']['subject-field']);
}
}
}
}
function nodetools_set_node_menu_settings($node_info) {
/**
* Menu settings
* -------------
*
* Available menus
* menu_options_{$type}
* value <array>:
* Array of menu ids.
* Example array('main-menu', 'menu-footer-links')
*
* Default parent item
* menu_parent_{$type}
* value <string>
* {menu-id}:{item-id}
* Example: 'main-menu:0'
*/
if (module_exists('menu')) {
if (isset($node_info['menu'])) {
// set data
if (isset($node_info['menu']['options'])) {
variable_set("menu_options_{$node_info['type']}", $node_info['menu']['options']);
}
if (isset($node_info['menu']['parent'])) {
variable_set("menu_parent_{$node_info['type']}", $node_info['menu']['parent']);
}
}
}
}