more module updates
This commit is contained in:
@@ -84,6 +84,8 @@
|
||||
* - "repeat": Array of variable properties for children variables.
|
||||
* - "localize": Boolean value, TRUE for variables that should be localized. This may be used by other modules.
|
||||
* - "validate callback": Callback to validate the variable value, it will be added to form element #validate.
|
||||
*
|
||||
* @see hook_variable_info_alter()
|
||||
*/
|
||||
function hook_variable_info($options) {
|
||||
$variables['site_name'] = array(
|
||||
@@ -102,6 +104,17 @@ function hook_variable_info($options) {
|
||||
return $variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter the variable definitions.
|
||||
*
|
||||
* @param $info
|
||||
* The variable info array, keyed by variable name.
|
||||
*
|
||||
* @see hook_variable_info()
|
||||
*/
|
||||
function hook_variable_info_alter(&$info) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Define types of variables or list of values used by a module.
|
||||
*
|
||||
@@ -145,6 +158,8 @@ function hook_variable_info($options) {
|
||||
*
|
||||
* A special attribute:
|
||||
* - "type": Variable subtype, the properties for the subtype will be added to these ones.
|
||||
*
|
||||
* @see hook_variable_type_info_alter()
|
||||
*/
|
||||
function hook_variable_type_info() {
|
||||
$type['mail_address'] = array(
|
||||
@@ -162,6 +177,17 @@ function hook_variable_type_info() {
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter the variable type definitions.
|
||||
*
|
||||
* @param $info
|
||||
* The variable type info array, keyed by variable type name.
|
||||
*
|
||||
* @see hook_variable_type_info()
|
||||
*/
|
||||
function hook_variable_type_info_alter(&$info) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Define groups of variables used by a module.
|
||||
*
|
||||
@@ -181,6 +207,8 @@ function hook_variable_type_info() {
|
||||
* - "description": The human readable description of the group. Must be localized.
|
||||
* - "access": Permission required to edit group's variables. Will default to 'administer site configuration'.
|
||||
* - "path": Array of administration paths where these variables can be accessed.
|
||||
*
|
||||
* @see hook_variable_group_info_alter()
|
||||
*/
|
||||
function hook_variable_group_info() {
|
||||
$groups['system_site_information'] = array(
|
||||
@@ -197,6 +225,17 @@ function hook_variable_group_info() {
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter the variable group definitions.
|
||||
*
|
||||
* @param $info
|
||||
* The variable type info array, keyed by variable group name.
|
||||
*
|
||||
* @see hook_variable_group_info()
|
||||
*/
|
||||
function hook_variable_group_info_alter(&$info) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter system settings forms.
|
||||
*
|
||||
|
@@ -154,14 +154,19 @@ function variable_form_element_options($variable, $options = array()) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement validate callback
|
||||
* Execute submit callbacks for variables in form.
|
||||
*/
|
||||
function variable_form_element_validate($element, &$form_state, $form) {
|
||||
$variable = $element['#variable'];
|
||||
variable_include($variable);
|
||||
$variable['value'] = isset($element['#value']) ? $element['#value'] : NULL;
|
||||
if ($error = call_user_func($variable['validate callback'], $variable)) {
|
||||
form_error($element, $error);
|
||||
function variable_form_submit_callback($form, &$form_state) {
|
||||
if (isset($form['#variable_edit_form'])) {
|
||||
// This may contain some realm options.
|
||||
$options = isset($form['#variable_options']) ? $form['#variable_options'] : array();
|
||||
foreach ($form['#variable_edit_form'] as $name) {
|
||||
$variable = variable_get_info($name);
|
||||
if ($variable && isset($variable['submit callback'])) {
|
||||
variable_include($variable);
|
||||
$variable['submit callback']($variable, $options, $form, $form_state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,9 +12,9 @@ files[] = includes/taxonomy.variable.inc
|
||||
files[] = includes/translation.variable.inc
|
||||
files[] = includes/user.variable.inc
|
||||
files[] = variable.test
|
||||
; Information added by drupal.org packaging script on 2013-08-09
|
||||
version = "7.x-2.3"
|
||||
; Information added by Drupal.org packaging script on 2014-04-23
|
||||
version = "7.x-2.5"
|
||||
core = "7.x"
|
||||
project = "variable"
|
||||
datestamp = "1376034993"
|
||||
datestamp = "1398250128"
|
||||
|
||||
|
@@ -415,16 +415,35 @@ function variable_hook_info() {
|
||||
* Form for variable list
|
||||
*
|
||||
* @param $list
|
||||
* Variable name or list of variable names
|
||||
* Variable name or list of variable names.
|
||||
* @param $options
|
||||
* Optional array with variable options.
|
||||
*/
|
||||
function variable_edit_form($form, $form_state, $list, $options = array()) {
|
||||
// Pass on the values on the form for further reference.
|
||||
$form['#variable_edit_form'] = $list;
|
||||
form_load_include($form_state, 'form.inc', 'variable');
|
||||
function variable_edit_form($form, &$form_state, $list, $options = array()) {
|
||||
$list = is_array($list) ? $list : array($list);
|
||||
$form = variable_base_form($form, $form_state, $list, $options);
|
||||
$form += variable_edit_subform($list, $options);
|
||||
return variable_settings_form($form, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build base form for variable list without fields.
|
||||
*
|
||||
* @param $list
|
||||
* List of variable names.
|
||||
* @param $options
|
||||
* Optional array with variable options.
|
||||
*/
|
||||
function variable_base_form($form, &$form_state, $list, $options = array()) {
|
||||
form_load_include($form_state, 'form.inc', 'variable');
|
||||
// Pass on the values on the form for further reference.
|
||||
$form['#variable_edit_form'] = $list;
|
||||
$form['#variable_options'] = $options;
|
||||
// Run submit callback for variables in form.
|
||||
$form['#submit'][] = 'variable_form_submit_callback';
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form elements for variable list.
|
||||
*
|
||||
@@ -682,7 +701,23 @@ function variable_form_alter(&$form, &$form_state, $form_id) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement validate callback.
|
||||
*
|
||||
* This needs to be in the module as it may be needed by form ajax callbacks.
|
||||
*/
|
||||
function variable_form_element_validate($element, &$form_state, $form) {
|
||||
$options = isset($form['#variable_options']) ? $form['#variable_options'] : array();
|
||||
$variable = $element['#variable'];
|
||||
variable_include($variable);
|
||||
$variable['value'] = isset($element['#value']) ? $element['#value'] : NULL;
|
||||
|
||||
$error = $variable['validate callback']($variable, $options, $element, $form, $form_state);
|
||||
|
||||
if ($error) {
|
||||
form_error($element, $error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_module_implements_alter().
|
||||
@@ -765,6 +800,7 @@ function variable_settings_form_submit($form, &$form_state) {
|
||||
form_state_values_clean($form_state);
|
||||
// This may contain some realm options.
|
||||
$options = isset($form['#variable_options']) ? $form['#variable_options'] : array();
|
||||
|
||||
// Now run regular settings submission but using variable_set_value()
|
||||
foreach ($form_state['values'] as $key => $value) {
|
||||
if (is_array($value) && isset($form_state['values']['array_filter'])) {
|
||||
|
@@ -376,7 +376,10 @@ function variable_format_multiple($variable, $options = array()) {
|
||||
* Validate numeric variable.
|
||||
*/
|
||||
function variable_validate_number($variable) {
|
||||
if (!is_numeric($variable['value'])) {
|
||||
if (empty($variable['required']) && empty($variable['value'])) {
|
||||
return;
|
||||
}
|
||||
elseif (!is_numeric($variable['value'])) {
|
||||
return t('The value is not a number.');
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ description = Variable Administration UI
|
||||
dependencies[] = variable
|
||||
package = Variable
|
||||
core = 7.x
|
||||
; Information added by drupal.org packaging script on 2013-08-09
|
||||
version = "7.x-2.3"
|
||||
; Information added by Drupal.org packaging script on 2014-04-23
|
||||
version = "7.x-2.5"
|
||||
core = "7.x"
|
||||
project = "variable"
|
||||
datestamp = "1376034993"
|
||||
datestamp = "1398250128"
|
||||
|
||||
|
@@ -105,5 +105,3 @@ function variable_admin_realm_title($realm) {
|
||||
$info = variable_realm_info($realm);
|
||||
return isset($info['title']) ? $info['title'] : $realm;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,11 +0,0 @@
|
||||
name = Variable advanced
|
||||
description = Provides access to advanced low level variables. By using this you will be able to break your site badly.
|
||||
dependencies[] = variable
|
||||
package = Variable
|
||||
core = 7.x
|
||||
; Information added by drupal.org packaging script on 2013-08-09
|
||||
version = "7.x-2.3"
|
||||
core = "7.x"
|
||||
project = "variable"
|
||||
datestamp = "1376034993"
|
||||
|
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Drupal module - Advanced variable otpions.
|
||||
*/
|
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Advanced variables.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_variable_group_info().
|
||||
*/
|
||||
function variable_advanced_variable_group_info() {
|
||||
$groups['advanced'] = array(
|
||||
'title' => t('Advanced options'),
|
||||
'description' => t('Advanced settings not usually exposed. Changing these variables may seriously break your site so make sure you know what you do.'),
|
||||
);
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_variable_info().
|
||||
*/
|
||||
function variable_advanced_variable_info($options) {
|
||||
// Bootstrap caching options
|
||||
$variables['page_cache_invoke_hooks'] = array(
|
||||
'title' => t('Cache invoke hooks'),
|
||||
'type' => 'enable',
|
||||
'default' => 1,
|
||||
'group' => 'advanced',
|
||||
'description' => T('Invoke <em>boot</em> and <em>exit</em> hooks when the page is served from cache.'),
|
||||
);
|
||||
$variables['actions_max_stack'] = array(
|
||||
'title' => t('Actions recursion level'),
|
||||
'type' => 'number',
|
||||
'default' => 35,
|
||||
'group' => 'advanced',
|
||||
'description' => t('Maximum recursion level for actions before the execution is aborted.', array(), $options),
|
||||
);
|
||||
// Bootstrap language variables.
|
||||
$variables['language_count'] = array(
|
||||
'title' => t('Language count'),
|
||||
'type' => 'number',
|
||||
'default' => 1,
|
||||
'group' => 'advanced',
|
||||
'description' => t('Number of enabled languages, used for quick bootstrap. Not to be changed manually.', array(), $options),
|
||||
);
|
||||
$variables['language_types'] = array(
|
||||
'title' => t('Language types'),
|
||||
'type' => 'array',
|
||||
'default callback' => 'drupal_language_types',
|
||||
'group' => 'advanced',
|
||||
'description' => t('Available language types.'),
|
||||
);
|
||||
// Bootstrap proxy configuration
|
||||
$variables['reverse_proxy'] = array(
|
||||
'title' => t('Reverse proxy'),
|
||||
'type' => 'enable',
|
||||
'default' => 0,
|
||||
'group' => 'advanced',
|
||||
'description' => t('If Drupal is behind a reverse proxy, we use the X-Forwarded-For header instead of $_SERVER[\'REMOTE_ADDR\'], which would be the IP address of the proxy server, and not the client\'s. The actual header name can be configured by the reverse_proxy_header variable.', array(), $options),
|
||||
);
|
||||
$variables['reverse_proxy_header'] = array(
|
||||
'title' => t('Reverse proxy header'),
|
||||
'default' => 'HTTP_X_FORWARDED_FOR',
|
||||
'group' => 'advanced',
|
||||
);
|
||||
$variables['reverse_proxy_addresses'] = array(
|
||||
'title' => t('Reverse proxy addresses'),
|
||||
'type' => 'array',
|
||||
'group' => 'advanced',
|
||||
'default' => array(),
|
||||
'description' => t('If an array of known reverse proxy IPs is provided, then trust the XFF header if request really comes from one of them.', array(), $options),
|
||||
);
|
||||
return $variables;
|
||||
}
|
@@ -6,9 +6,9 @@ package = Example modules
|
||||
core = 7.x
|
||||
files[] = variable_example.variable.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-09
|
||||
version = "7.x-2.3"
|
||||
; Information added by Drupal.org packaging script on 2014-04-23
|
||||
version = "7.x-2.5"
|
||||
core = "7.x"
|
||||
project = "variable"
|
||||
datestamp = "1376034993"
|
||||
datestamp = "1398250128"
|
||||
|
||||
|
@@ -86,7 +86,13 @@ function variable_realm_edit_variables_form($form, &$form_state, $realm_name, $r
|
||||
$form['realm_name'] = array('#type' => 'value', '#value' => $realm_name);
|
||||
$form['realm_key'] = array('#type' => 'value', '#value' => $realm_key);
|
||||
$options['realm'] = variable_realm($realm_name, $realm_key);
|
||||
|
||||
if ($variable_list = $controller->getEnabledVariables()) {
|
||||
$form = variable_base_form($form, $form_state, $variable_list, $options);
|
||||
// variable_base_form() adds its own submit handler overriding the default,
|
||||
// so we need to add it as a explicit submit callback here.
|
||||
$form['#submit'][] = 'variable_realm_edit_variables_form_submit';
|
||||
|
||||
// Group variables by variable group for vertical tabls
|
||||
$group_list = array();
|
||||
foreach ($variable_list as $variable_name) {
|
||||
|
@@ -8,9 +8,9 @@ version = 7.x-2.x
|
||||
files[] = variable_realm.class.inc
|
||||
files[] = variable_realm_union.class.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-09
|
||||
version = "7.x-2.3"
|
||||
; Information added by Drupal.org packaging script on 2014-04-23
|
||||
version = "7.x-2.5"
|
||||
core = "7.x"
|
||||
project = "variable"
|
||||
datestamp = "1376034993"
|
||||
datestamp = "1398250128"
|
||||
|
||||
|
@@ -29,10 +29,10 @@ function variable_realm_boot() {
|
||||
* Implements hook_init()
|
||||
*
|
||||
* Let realms be overriden by query string parameters, but only for:
|
||||
* - Admin paths (not variable admin pages)
|
||||
* - Admin paths (not variable realm admin pages)
|
||||
*/
|
||||
function variable_realm_init() {
|
||||
if (arg(0) == 'admin' && arg(3) != 'variable' && ($params = variable_realm_params()) && user_access('administer site configuration')) {
|
||||
if (arg(0) == 'admin' && (arg(3) != 'variable' || arg(4) != 'realm') && ($params = variable_realm_params()) && user_access('administer site configuration')) {
|
||||
foreach ($params as $realm_name => $realm_key) {
|
||||
variable_realm_switch($realm_name, $realm_key, FALSE);
|
||||
}
|
||||
|
@@ -8,9 +8,9 @@ version = 7.x-2.x
|
||||
files[] = variable_store.class.inc
|
||||
files[] = variable_store.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-09
|
||||
version = "7.x-2.3"
|
||||
; Information added by Drupal.org packaging script on 2014-04-23
|
||||
version = "7.x-2.5"
|
||||
core = "7.x"
|
||||
project = "variable"
|
||||
datestamp = "1376034993"
|
||||
datestamp = "1398250128"
|
||||
|
||||
|
@@ -9,9 +9,9 @@ files[] = includes/views_plugin_argument_default_variable.inc
|
||||
files[] = includes/views_handler_field_variable_title.inc
|
||||
files[] = includes/views_handler_field_variable_value.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-09
|
||||
version = "7.x-2.3"
|
||||
; Information added by Drupal.org packaging script on 2014-04-23
|
||||
version = "7.x-2.5"
|
||||
core = "7.x"
|
||||
project = "variable"
|
||||
datestamp = "1376034993"
|
||||
datestamp = "1398250128"
|
||||
|
||||
|
Reference in New Issue
Block a user