first import
This commit is contained in:
127
sites/all/modules/mb/mb_extra/mb_extra.admin.inc
Normal file
127
sites/all/modules/mb/mb_extra/mb_extra.admin.inc
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Function file to administer the MB Extra module settings.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the MB Extra settings form.
|
||||
*/
|
||||
function mb_extra_admin() {
|
||||
$module = 'mb_extra';
|
||||
$form = array();
|
||||
|
||||
$description_tabs_destination = '<p>' . t('Use the node local task links with destination parameter.') . '</p>';
|
||||
$description_tabs_destination .= '<p>' . t('If activated the %overlay module is not available this feature.', array('%overlay' => t('Overlay'))) . '</p>';
|
||||
|
||||
$form[$module]['tabs_destination'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Content local tasks'),
|
||||
'#description' => $description_tabs_destination,
|
||||
'#collapsible' => false,
|
||||
'#collapsed' => false,
|
||||
'#tree' => true
|
||||
);
|
||||
$form[$module]['tabs_destination'][$module . '_destination_tabs'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Enable node tab links with destination parameter.'),
|
||||
'#default_value' => variable_get($module . '_destination_tabs', 0)
|
||||
);
|
||||
|
||||
$form[$module]['confirm_cancel'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Confirm cancel'),
|
||||
'#description' => '<p>' . t('Alter the confirm form cancel link to display it as button.') . '</p>',
|
||||
'#collapsible' => false,
|
||||
'#collapsed' => false,
|
||||
'#tree' => true
|
||||
);
|
||||
$form[$module]['confirm_cancel'][$module . '_confirm_cancel'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display link as button'),
|
||||
'#default_value' => variable_get($module . '_confirm_cancel', 0)
|
||||
);
|
||||
|
||||
$form['submit']['save'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'save',
|
||||
'#value' => t('Save')
|
||||
);
|
||||
$form['submit']['reset'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'reset',
|
||||
'#value' => t('Reset to defaults'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the MB Extra settings form page.
|
||||
*
|
||||
* @return
|
||||
* The complete HTML formatted administer page.
|
||||
*/
|
||||
function theme_mb_extra_admin($variables) {
|
||||
_mb_load_css('admin');
|
||||
|
||||
$module = 'mb_extra';
|
||||
$output = '';
|
||||
|
||||
$form = drupal_get_form($module . '_admin');
|
||||
|
||||
$output .= drupal_render($output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings from admin form.
|
||||
*/
|
||||
function mb_extra_admin_submit($form, &$form_state) {
|
||||
$module = 'mb_extra';
|
||||
|
||||
if ($form_state['clicked_button']['#id'] == 'edit-save') {
|
||||
variable_set($module . '_destination_tabs', $form_state['values']['tabs_destination'][$module . '_destination_tabs']);
|
||||
variable_set($module . '_confirm_cancel', $form_state['values']['confirm_cancel'][$module . '_confirm_cancel']);
|
||||
|
||||
drupal_set_message(t('The %module settings have been saved.', array('%module' => t('More Buttons Extra'))), 'status');
|
||||
}
|
||||
elseif ($form_state['clicked_button']['#id'] == 'edit-reset') {
|
||||
$form_state['redirect'] = 'admin/config/mb/buttons/more-buttons-extra/reset';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback to define the confirm form output.
|
||||
*
|
||||
* @return
|
||||
* The confirm form.
|
||||
*/
|
||||
function mb_extra_reset() {
|
||||
$question = t('Are you sure you want to reset all %module settings?', array('%module' => t('More Buttons Extra')));
|
||||
|
||||
$information = '<p>' . t('This action disables the extra settings. This action cannot be undone.') . '</p>';
|
||||
|
||||
return confirm_form(array(),
|
||||
$question,
|
||||
array('path' => 'admin/config/mb/buttons/more-buttons-extra', 'attributes' => array('class' => 'button')), $information,
|
||||
t('Reset'),
|
||||
t('Cancel')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resave extras system variables of the MB Content module to reset the module extra settings.
|
||||
*/
|
||||
function mb_extra_reset_submit($form, &$form_state) {
|
||||
// Resave variables.
|
||||
variable_set('mb_extra_destination_tabs', 0);
|
||||
variable_set('mb_extra_confirm_cancel', 0);
|
||||
|
||||
drupal_set_message(t('The %module settings have been set back.', array('%module' => t('More Buttons Extra'))), 'status');
|
||||
watchdog('More Buttons Extra', 'The %module settings have been set back.', array('%module' => t('More Buttons Extra')), WATCHDOG_NOTICE, l(t('view'), 'admin/config/mb/buttons/more-buttons-extra'));
|
||||
|
||||
$form_state['redirect'] = 'admin/config/mb/buttons/more-buttons-extra';
|
||||
}
|
14
sites/all/modules/mb/mb_extra/mb_extra.info
Normal file
14
sites/all/modules/mb/mb_extra/mb_extra.info
Normal file
@@ -0,0 +1,14 @@
|
||||
name = More Buttons Extra
|
||||
description = "Provides various functions for the expansion of core modules."
|
||||
package = "More Buttons"
|
||||
dependencies[] = mb
|
||||
core = 7.x
|
||||
files[] = mb_extra.module
|
||||
files[] = mb_extra.admin.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-02-25
|
||||
version = "7.x-1.x-dev"
|
||||
core = "7.x"
|
||||
project = "mb"
|
||||
datestamp = "1298619614"
|
||||
|
15
sites/all/modules/mb/mb_extra/mb_extra.install
Normal file
15
sites/all/modules/mb/mb_extra/mb_extra.install
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installs, updates, and uninstalls More Buttons Extra.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function mb_extra_uninstall() {
|
||||
// Remove variables.
|
||||
variable_del('mb_extra_destination_tabs');
|
||||
variable_del('mb_extra_confirm_cancel');
|
||||
}
|
108
sites/all/modules/mb/mb_extra/mb_extra.module
Normal file
108
sites/all/modules/mb/mb_extra/mb_extra.module
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides various functions for the expansion of core modules.
|
||||
*
|
||||
* Implemented:
|
||||
* - Alter menu local task links from node to insert destination parameter.
|
||||
* Children tabs supported to level 1.
|
||||
* - Alter the confirm form cancel link to display the link as button.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function mb_extra_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['admin/config/mb/buttons/more-buttons-extra'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('mb_extra_admin'),
|
||||
'title' => 'Extras',
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'file' => 'mb_extra.admin.inc',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 15
|
||||
);
|
||||
$items['admin/config/mb/buttons/more-buttons-extra/reset'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('mb_extra_reset'),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_CALLBACK,
|
||||
'file' => 'mb_extra.admin.inc'
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter the local tasks to use an destination parameter.
|
||||
*/
|
||||
function mb_extra_menu_local_tasks_alter(&$data, $router_item, $root_path) {
|
||||
if (module_exists('overlay')) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $base_url;
|
||||
|
||||
$module = 'mb_extra';
|
||||
|
||||
if ($router_item['tab_root'] == 'node/%') {
|
||||
if (variable_get($module . '_destination_tabs', 0) == TRUE && count($data['tabs']) > 0) {
|
||||
$destination = drupal_get_destination();
|
||||
|
||||
foreach (element_children($data['tabs'][0]['output']) as $key) {
|
||||
if ($data['tabs'][0]['output'][$key]['#link']['tab_root_href'] != $destination['destination'] && !stristr($destination['destination'], $data['tabs'][0]['output'][$key]['#link']['tab_root_href'])) {
|
||||
$params = $data['tabs'][0]['output'][$key]['#link'];
|
||||
$data['tabs'][0]['output'][$key]['#link']['href'] = $base_url . '/' . $params['href'] . '?destination=' . $destination['destination'];
|
||||
//$data['tabs'][0]['output'][$key]['#link']['tab_root_href'] = $base_url . '/' . $params['tab_root_href'] . '?destination=' . $destination['destination'];
|
||||
//$data['tabs'][0]['output'][$key]['#link']['tab_parent_href'] = $base_url . '/' . $params['tab_parent_href'] . '?destination=' . $destination['destination'];
|
||||
}
|
||||
}
|
||||
|
||||
// Children tabs level 1.
|
||||
if (isset($data['tabs'][1])) {
|
||||
foreach (element_children($data['tabs'][1]['output']) as $key) {
|
||||
if ($data['tabs'][1]['output'][$key]['#link']['tab_root_href'] != $destination['destination']) {
|
||||
$params = $data['tabs'][1]['output'][$key]['#link'];
|
||||
$data['tabs'][1]['output'][$key]['#link']['href'] = $base_url . '/' . $params['href'] . '?destination=' . $destination['destination'];
|
||||
//$data['tabs'][0]['output'][$key]['#link']['tab_root_href'] = $base_url . '/' . $params['tab_root_href'] . '?destination=' . $destination['destination'];
|
||||
//$data['tabs'][0]['output'][$key]['#link']['tab_parent_href'] = $base_url . '/' . $params['tab_parent_href'] . '?destination=' . $destination['destination'];
|
||||
|
||||
if (isset($data['tabs'][1]['output'][$key]['#active'])) {
|
||||
$data['tabs'][1]['output'][$key]['#link']['localized_options'] = array(
|
||||
'attributes' => array(
|
||||
'class' => 'active'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function mb_extra_theme() {
|
||||
return array(
|
||||
'mb_extra_admin' => array(
|
||||
'variables' => array('form' => NULL),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*/
|
||||
function mb_extra_form_alter(&$form, &$form_state, $form_id) {
|
||||
$module = 'mb_extra';
|
||||
|
||||
// Alter the confirm form cancel link to display the link as button.
|
||||
if (isset($form['confirm']) && variable_get($module . '_confirm_cancel', 0) == TRUE) {
|
||||
$form['actions']['cancel']['#attributes']['class'][] = 'button';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user