hook_update_deploy_tools.module in Hook Update Deploy Tools 7
Same filename and directory in other branches
Hooks and other module requirements.
File
hook_update_deploy_tools.moduleView source
<?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);
}
}
Functions
Name | Description |
---|---|
hook_update_deploy_tools_admin | The callback function creates an admin form for a menu hook. |
hook_update_deploy_tools_help | Implements hook_help(). |
hook_update_deploy_tools_menu | Implements hook_menu(). |
hook_update_deploy_tools_redirect_import | Creates the redirect import form. |
hook_update_deploy_tools_redirect_import_parse_form | Submit handler for the redirect import. |
hudt_squeal | Used for debugging and HUDT development in drush and drupal simultaneously. |