-
Notifications
You must be signed in to change notification settings - Fork 2
/
hook_update_deploy_tools.module
204 lines (185 loc) · 7.88 KB
/
hook_update_deploy_tools.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
<?php
/**
* @file
* Hooks and other module requirements.
*/
// Use the class 4 autoloder to load classes as they are called.
require_once drupal_get_path('module', 'hook_update_deploy_tools') . '/vendor/autoload.php';
/**
* Implements hook_help().
*/
function hook_update_deploy_tools_help($path, $arg) {
switch ($path) {
case 'admin/help#hook_update_deploy_tools':
$content = file_get_contents(drupal_get_path('module', 'hook_update_deploy_tools') . '/README.md');
if (module_exists('markdown') && module_load_include('module', 'markdown', 'markdown') && function_exists('_filter_markdown')) {
// Markdown can be used.
module_load_include('module', 'markdown', 'markdown');
$output = filter_xss_admin(_filter_markdown($content, 'markdown'));
}
if (empty($output)) {
// Markdown is not available.
$output = '<pre>' . check_plain($content) . '</pre>';
}
return $output;
}
}
/**
* Implements hook_menu().
*/
function hook_update_deploy_tools_menu() {
$items['admin/config/development/hook_update_deploy_tools'] = array(
'title' => 'Hook Update Deploy Tools Settings',
'description' => 'Settings for the Hook Update Deploy Tools module.',
'page callback' => 'drupal_get_form',
'page arguments' => array('hook_update_deploy_tools_admin'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
if (module_exists('redirect')) {
$items['admin/config/search/redirect/hudt_import'] = array(
'title' => 'Import',
'description' => 'Import a csv list of redirects',
'page callback' => 'drupal_get_form',
'page arguments' => array('hook_update_deploy_tools_redirect_import'),
'access arguments' => array('administer redirects'),
'type' => MENU_LOCAL_TASK,
'weight' => 50,
);
}
return $items;
}
/**
* The callback function creates an admin form for a menu hook.
*/
function hook_update_deploy_tools_admin() {
$form = array();
$default_deploy = check_plain(variable_get('hook_update_deploy_tools_deploy_module', ''));
$description = t("This is the machine name for the custom deploy module for the site. example: site_deploy");
if (empty($default_deploy)) {
$vars = array('%drush' => 'drush site-deploy-init');
$description .= '</br>' . t("You currently have no deploy module declared. Run '%drush' to create one.", $vars);
}
$form['hook_update_deploy_tools_deploy_module'] = array(
'#type' => 'textfield',
'#title' => t('Machine name of the custom deploy module for this site.'),
'#default_value' => $default_deploy,
'#size' => 60,
'#maxlength' => 60,
'#description' => $description,
'#required' => FALSE,
);
$description = t("This is the machine name for the Feature controlling the menus. example: my_menu_feature.") . '</br>';
$description .= t("This determines where Menu import files must reside.") . '</br>';
$path = HookUpdateDeployTools\HudtInternal::getStoragePath('menu', TRUE);
$description .= t("Currently using: %path", array('%path' => $path));
$form['hook_update_deploy_tools_menu_feature'] = array(
'#type' => 'textfield',
'#title' => t('Machine name of menu Feature or custom deploy module'),
'#default_value' => check_plain(variable_get('hook_update_deploy_tools_menu_feature', '')),
'#size' => 60,
'#maxlength' => 60,
'#description' => $description,
'#required' => FALSE,
);
$description = t("This is the machine name for the Feature controlling the Nodes. example: my_nodes_feature.") . '</br>';
$description .= t("This determines where Node import files must reside.") . '</br>';
$path = HookUpdateDeployTools\HudtInternal::getStoragePath('node', TRUE);
$description .= t("Currently using: %path", array('%path' => $path));
$form['hook_update_deploy_tools_node_feature'] = array(
'#type' => 'textfield',
'#title' => t('Machine name of Node Feature or custom deploy module'),
'#default_value' => check_plain(variable_get('hook_update_deploy_tools_node_feature', '')),
'#size' => 60,
'#maxlength' => 60,
'#description' => $description,
'#required' => FALSE,
);
$description = t("This is the machine name for the Feature controlling the Panels. example: my_panels_feature.") . '</br>';
$description .= t("This determines where Panels import files must reside.") . '</br>';
$path = HookUpdateDeployTools\HudtInternal::getStoragePath('page_manager', TRUE);
$description .= t("Currently using: %path", array('%path' => $path));
$form['hook_update_deploy_tools_page_manager_feature'] = array(
'#type' => 'textfield',
'#title' => t('Machine name of Page Manager Feature or custom deploy module'),
'#default_value' => check_plain(variable_get('hook_update_deploy_tools_page_manager_feature', '')),
'#size' => 60,
'#maxlength' => 60,
'#description' => $description,
'#required' => FALSE,
);
$description = t("This is the machine name for the Feature controlling the Redirects. example: my_redirects_feature.") . '</br>';
$description .= t("This determines where Redirect import files must reside.") . '</br>';
$path = HookUpdateDeployTools\HudtInternal::getStoragePath('redirect', TRUE);
$description .= t("Currently using: %path", array('%path' => $path));
$form['hook_update_deploy_tools_redirect_feature'] = array(
'#type' => 'textfield',
'#title' => t('Machine name of Redirect Feature or custom deploy module'),
'#default_value' => check_plain(variable_get('hook_update_deploy_tools_redirect_feature', '')),
'#size' => 60,
'#maxlength' => 60,
'#description' => $description,
'#required' => FALSE,
);
$description = t("This is the machine name for the Feature controlling the Rules. example: my_rules_feature.") . '</br>';
$description .= t("This determines where Rules import files must reside.") . '</br>';
$path = HookUpdateDeployTools\HudtInternal::getStoragePath('rules', TRUE);
$description .= t("Currently using: %path", array('%path' => $path));
$form['hook_update_deploy_tools_rules_feature'] = array(
'#type' => 'textfield',
'#title' => t('Machine name of Rule Feature or custom deploy module'),
'#default_value' => check_plain(variable_get('hook_update_deploy_tools_rules_feature', '')),
'#size' => 60,
'#maxlength' => 60,
'#description' => $description,
'#required' => FALSE,
);
$description = t("This is the machine name for the Feature controlling the Terms. example: my_terms_feature.") . '</br>';
$description .= t("This determines where term import files must reside.") . '</br>';
$path = HookUpdateDeployTools\HudtInternal::getStoragePath('term', TRUE);
$description .= t("Currently using: %path", array('%path' => $path));
$form['hook_update_deploy_tools_term_feature'] = array(
'#type' => 'textfield',
'#title' => t('Machine name of Term Feature or custom deploy module'),
'#default_value' => check_plain(variable_get('hook_update_deploy_tools_term_feature', '')),
'#size' => 60,
'#maxlength' => 60,
'#description' => $description,
'#required' => FALSE,
);
return system_settings_form($form);
}
/**
* Creates the redirect import form.
*
* @return array
* Drupal form array.
*/
function hook_update_deploy_tools_redirect_import() {
return HookUpdateDeployTools\Redirects::getImportForm();
}
/**
* Submit handler for the redirect import.
*
* @param array $form
* Drupal form array.
* @param array $form_state
* Drupal form state array by reference.
*/
function hook_update_deploy_tools_redirect_import_parse_form($form, &$form_state) {
HookUpdateDeployTools\Redirects::parseForm($form, $form_state);
}
/**
* Used for debugging and HUDT development in drush and drupal simultaneously.
*
* @param mixed $thing
* The thing to output.
*/
function hudt_squeal($thing) {
if (function_exists('drush_print_r')) {
drush_print_r($thing);
}
elseif (function_exists('dpm')) {
dpm($thing);
}
}