You are here

function finder_ui_php_setting in Finder 7.2

Modify a PHP setting element.

Used for security reasons to prevent an unauthorized user editing the field. Also makes variables available for the PHP input.

Parameters

$element: The original array for the element.

$variables: Array where keys are variable names (without the $) to make available in the PHP, and the values are descriptions already passed through t().

2 calls to finder_ui_php_setting()
finder_ui in modules/finder_ui/includes/finder.inc
Finder UI.
finder_ui_element in modules/finder_ui/includes/element.inc
Finder UI element.

File

modules/finder_ui/includes/common.inc, line 154
common.inc

Code

function finder_ui_php_setting($element, $variables = array()) {
  if (user_access('use PHP for settings')) {
    $var_list = array();
    foreach ($variables as $variable => $description) {
      $var_list[] = '<em>$' . $variable . '</em> - ' . $description;
    }
    if (!empty($var_list)) {
      $element['#description'] = (isset($element['#description']) ? $element['#description'] : '') . '<div>' . t('Available variables') . ':' . theme('item_list', array(
        'items' => $var_list,
      )) . '</div>';
    }
  }
  else {
    $element['#disabled'] = TRUE;
    $element['#prefix'] = '<div class="messages warning">' . t("You don't have permission to modify %setting.", array(
      '%setting' => $element['#title'],
    )) . '</div>' . (isset($element['#prefix']) ? $element['#prefix'] : '');
    $element['#value'] = $element['#default_value'];
  }
  return $element;
}