diff --git a/token.install b/token.install index ded68e9..6e9fd7f 100644 --- a/token.install +++ b/token.install @@ -1,6 +1,13 @@ 'Token', + 'description' => 'Administrative settings for Token.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('token_admin'), + 'access arguments' => array('administer site configuration'), + 'file' => 'token.pages.inc', + ); /*$items['token/autocomplete/all/%menu_tail'] = array( 'page callback' => 'token_autocomplete', 'access callback' => TRUE, @@ -126,7 +134,12 @@ function token_theme() { 'file' => 'token.pages.inc', ), 'token_tree' => array( - 'variables' => array('token_types' => array(), 'global_types' => TRUE, 'click_insert' => TRUE, 'show_restricted' => FALSE, 'recursion_limit' => 4), + 'variables' => array( + 'token_types' => array(), + 'global_types' => TRUE, + 'click_insert' => TRUE, + 'show_restricted' => FALSE, + ), 'file' => 'token.pages.inc', ), ); diff --git a/token.pages.inc b/token.pages.inc index f4ece50..a6f3a34 100644 --- a/token.pages.inc +++ b/token.pages.inc @@ -63,7 +63,7 @@ function theme_token_tree($variables) { $options = array( 'flat' => TRUE, 'restricted' => $variables['show_restricted'], - 'depth' => $variables['recursion_limit'], + 'depth' => variable_get('token_tree_recursion_limit', 4), ); $tree = token_build_tree($type, $options); foreach ($tree as $token => $token_info) { @@ -259,3 +259,22 @@ function token_autocomplete_token($token_type) { $matches = drupal_map_assoc(array_keys($matches)); drupal_json_output($matches); } + +/* + * Menu callback for admin/config/token + * + * Allows adjustment of Token tree UI recursion limit + */ +function token_admin() { + $form['token_tree_recursion_limit'] = array( + '#type' => 'textfield', + '#title' => t('Token tree recursion limit'), + '#description' => t('The recursion limit for the Token Tree UI. Complex user, content type, and taxonomy field structures can be recursive. Default is 4, adjust lower to reduce processing and increase page load speeds.'), + '#default_value' => variable_get('token_tree_recursion_limit', 4), + '#size' => 4, + '#maxlength' => 2, + '#required' => TRUE, + ); + + return system_settings_form($form); +}