summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-10-11 19:44:35 +0000
committerDries Buytaert <dries@buytaert.net>2005-10-11 19:44:35 +0000
commit75fe6b6c0ae85d2b53cb803d5b028b050fd6d454 (patch)
tree70ea02551300ed5a696b4d289cfc4722924d58ca /includes
parentecf5ed57d66a182ae0e269942169e0a6cf3a3912 (diff)
downloadbrdo-75fe6b6c0ae85d2b53cb803d5b028b050fd6d454.tar.gz
brdo-75fe6b6c0ae85d2b53cb803d5b028b050fd6d454.tar.bz2
- Patch #33752 by chx, adrian, et al: another batch of form API changes/fixes.
Diffstat (limited to 'includes')
-rw-r--r--includes/form.inc617
-rw-r--r--includes/locale.inc72
-rw-r--r--includes/unicode.inc2
3 files changed, 190 insertions, 501 deletions
diff --git a/includes/form.inc b/includes/form.inc
index fa7e56368..2074d6e51 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -10,319 +10,10 @@
*/
/**
- * Form property constants.
- *
- * These constants are defined to keep the namespace of the form tree available for elements.
- * Properties are strings that start with '_' (underscore) and have special meaning for the form api.
- */
-
-/**
- * Keyword: type.
- * Required: true
- * Description: Used to specify the form element type. Form elements are defined by implementation of hook_elements.
- */
-define('type', '_type');
-
-define('theme', '_theme');
-
-define('theme_used', '_theme_used');
-/**
- * Keyword: name.
- * Internal: For use within the form api. Should not be set by the developer.
- * Description: The form_builder function populates this property based on the location of the form element in the form tree.
- */
-define('name', '_name');
-
-/**
- * Keyword: id.
- * Internal: For use within the form api. Should not be set by the developer.
- * Description: The form_builder function populates this property based on the location of the form element in the form tree.
- * This is used for the form_set_error notification, along with the stylesheets to be used.
- */
-define('id', '_id');
-
-/**
- * Keyword: printed
- * Internal: For use within the form api. Should not be set by the developer.
- * Description: Used by form_render to ascertain wether or not a form element has been printed yet
- */
-define('printed', '_printed');
-
-/**
- * Keyword: built
- * Internal: For use within the form api. Should not be set by the developer.
- * Description: Used by _form_builder to ascertain wether or not a form element has been built yet
- */
-define('built', '_built');
-
-/**
- * Keyword: processed
- * Internal: For use within the form api. Should not be set by the developer.
- * Description: Used by _form_builder to ascertain wether or not a form element has been processed (ie: expanded to multiple elements)
- */
-define('processed', '_processed');
-
-
-/**
- * Keyword: variable
- * Internal: For use within the form api. Should not be set by the developer.
- * Description: used by form builder to populate a global form_variables array.
- */
-define('variable', '_variable');
-
-/**
- * Keyword: id.
- * Internal: For use within the form api. Should not be set by the developer.
- * Description: The form_builder function uses this property to keep track of the parent form elements, and uses this to generate the id and name properties.
- */
-define('parents', '_parents');
-
-/**
- * Keyword: input.
- * Description: Wether or not an input is possible for this form element. True / False. Set in the hook_elements implementation.
- */
-define('input', '_input');
-
-/**
- * Keyword: validated.
- * Description: Wether or not an input has been validated.
- */
-define('validated', '_validated');
-
-/**
- * Keyword: value.
- * Used: For all form elements except 'textarea' and the 'default' fallback.
- * Description: The value the form element should be set as. Setting this yourself is not required, although it might be a good idea for form elements that
- * don't change. See the default_value property.
- */
-define('value', '_value');
-
-/**
- * Keyword: default_value.
- * Used: For all form elements that have a value property.
- * Description: The value the form element should be initialized as. If no submission for this element exists, the element will be set to this value.
- * This means that you do not have to set the value properties for form elements, as they will be automatically handled by the form api.
- */
-define('default_value', '_default_value');
-
-/**
- * Keyword: return_value.
- * Used: For select , radio and checkbox elements.
- * Description: The value the form element will return.
- */
-define('return_value', '_return_value');
-
-/**
- * Keyword: title
- * Used: For all form elements that have visible output.
- * Description: The title of the form element. The developer should use the t() function to translate this property.
- */
-define('title', '_title');
-
-/**
- * Keyword: description
- * Used: For all form elements that have visible output.
- * Description: The description of the form element. The developer should use the t() function to translate this property.
- */
-define('description', '_description');
-
-/**
- * Keyword: required
- * Used: For all form elements that have visible output.
- * Description: Wether or not the element is required. This automatically validates for empty fields, and flags inputs as required.
- */
-define('required', '_required');
-
-/**
- * Keyword: cols
- * Used: textarea elements.
- * Description: How many columns wide the textarea should be.
- */
-define('cols', '_cols');
-
-/**
- * Keyword: rows
- * Used: textarea elements.
- * Description: How many rows high the textarea should be.
- */
-define('rows', '_rows');
-
-/**
- * Keyword: size
- * Used: textfield elements.
- * Description: How many characters wide should the textfield be.
- */
-define('size', '_size');
-
-/**
- * Keyword: maxlength
- * Used: For textfield element types.
- * Description: The maximum amount of characters to accept as input.
- */
-define('maxlength', '_maxlength');
-
-/**
- * Keyword: valid
- * Used: For all form elements that have the value property.
- * Description: A list of validation functions that need to be passed.
- */
-define('valid', '_valid');
-define('validation_arguments', '_validation_arguments');
-
-/**
- * Keyword: weight
- * Used: all elements.
- * Description: Used by the form_render function to sort the list of elements before being output.
- */
-define('weight', '_weight');
-
-/**
- * Keyword: collapsible
- * Used: fieldset elements.
- * Description: Wether or not the fieldset can be collapsed with javascript.
- */
-define('collapsible', '_collapsible');
-
-/**
- * Keyword: collapsed
- * Used: fieldset elements.
- * Description: Wether or not the fieldset is collapsed by default. See collapsible property.
- */
-define('collapsed', '_collapsed');
-
-/**
- * Keyword: autocomplete_path
- * Used: textfield elements.
- * Description: The path the AJAX autocomplete script uses as the source for autocompletion.
- */
-define('autocomplete_path', '_autocomplete_path');
-
-/**
- * Keyword: action
- * Used: form elements.
- * Description: The path to which the form will be submitted.
- */
-define('action', '_action');
-
-/**
- * Keyword: method
- * Used: form elements.
- * Description: The HTTP method the form will be submitted with (GET/POST). Default is 'post'.
- */
-define('method', '_method');
-
-/**
- * Keyword: attributes
- * Used: all visible form elements.
- * Description: Additional html attributes, such as 'class' can be set using this mechanism.
- */
-define('attributes', '_attributes');
-
-/**
- * Keyword: options
- * Used: select boxes, checkboxes and radios form elements.
- * Description: An associative array containing the options to be used. In the format 'return_value' => 'Display Value'
- *
- * It is possible to group options together; to do this, change the format of
- * $options to an associative array in which the keys are group labels, and the
- * values are associative arrays in the normal $options format.
- */
-define('options', '_options');
-
-/**
- * Keyword: extra
- * Used: select boxes.
- * Description: Additional HTML to inject into the select element tag.
- */
-define('extra', '_extra');
-
-/**
- * Keyword: multiple
- * Used: select boxes.
- * Description: Wether the user may select more than one item.
- */
-define('multiple', '_multiple');
-
-/**
- * Keyword: button_type
- * Used: buttons.
- * Description: The type of button to display (cancel or submit)
- */
-define('button_type', '_button_type');
-
-
-
-/**
- * Keyword: error
- * Used: All visible form elements.
- * Description: Wether or not a form element has been flagged as having an error.
- */
-define('error', '_error');
-
-/**
- * Keyword: prefix
- * Used: markup element.
- * Description: Text to include before the value and children properties.
- */
-define('prefix', '_prefix');
-
-/**
- * Keyword: suffix
- * Used: markup element.
- * Description: Text to include after the value and children properties.
- */
-define('suffix', '_suffix');
-
-/**
- * Keyword: error
- * Used: weight form element.
- * Description: Number of weights to have selectable.
- */
-define('delta', '_delta');
-
-/**
- * Multiple elements. For use in the poll module, and for file uploads.
- */
-
-/**
- * Keyword : process
- * Used : By any element, used to modify a form element.
- */
-define('process', '_process');
-
-/**
- * Keyword: multiple
- */
-define('multiple', '_multiple');
-
-/**
- * Keyword: min
- */
-define('minimum', '_minimum');
-
-/**
- * Keyword: max
- */
-define('maximum', '_maximum');
-
-/**
- * Keyword: increment
- */
-define('increment', '_increment');
-
-define('spawned', '_spawned');
-
-define('tree', '_tree');
-
-define('token', '_token');
-
-define('execute', '_execute');
-
-/**
* Check if the key is a property.
*/
function element_property($key) {
- return (substr($key, 0, 1) == '_');
+ return $key{0} == '#';
}
function element_properties($element) {
@@ -333,7 +24,7 @@ function element_properties($element) {
* Check if the key is a child.
*/
function element_child($key) {
- return (substr($key, 0, 1) != '_');
+ return $key{0} != '#';
}
function element_children($element) {
@@ -358,10 +49,10 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
global $form_values, $form_execute;
$form_values = array();
$form_execute = FALSE;
- $form[type] = 'form';
- $form[attributes]['class'] .= ' form-api';
- if (isset($form[token])) {
- $form['form_token'] = array(type => 'hidden', value => md5($_SERVER['REMOTE_ADDR'] . $form[token] . variable_get('drupal_private_key', '')));
+ $form['#type'] = 'form';
+ $form['#attributes']['class'] .= ' form-api';
+ if (isset($form['#token'])) {
+ $form['form_token'] = array('#type' => 'hidden', '#value' => md5($_SERVER['REMOTE_ADDR'] . $form['#token'] . variable_get('drupal_private_key', '')));
}
$form = array_merge(_element_info('form'), $form);
@@ -375,18 +66,21 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
$function($form);
}
- if (!$form[built]) {
+ if (!$form['#built']) {
$form = _form_builder($form);
}
- if ($form_execute) {
- drupal_execute_form($form_id, $form, $callback);
+ if (!empty($_POST['edit'])) {
+ drupal_validate_form($form_id, $form, $callback);
+ if ($form_execute && !form_get_errors()) {
+ drupal_execute_form($form_id, $form, $callback);
+ }
}
if (function_exists('theme_' . $form_id)) {
- $form[theme] = $form_id;
+ $form['#theme'] = $form_id;
}
elseif (function_exists('theme_' . $callback)) {
- $form[theme] = $callback;
+ $form['#theme'] = $callback;
}
return form_render($form);
}
@@ -394,8 +88,8 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
function drupal_validate_form($form_id, &$form, $callback = NULL) {
global $form_values;
- if (isset($form[token])) {
- if ($form_values['form_token'] != md5($_SERVER['REMOTE_ADDR'] . $form[token] . variable_get('drupal_private_key', ''))) {
+ if (isset($form['#token'])) {
+ if ($form_values['form_token'] != md5($_SERVER['REMOTE_ADDR'] . $form['#token'] . variable_get('drupal_private_key', ''))) {
// setting this error will cause the form to fail validation
form_set_error('form_token', t('Validation error, please try again. If this error persists, please contact the site administrator.'));
}
@@ -418,21 +112,16 @@ function drupal_validate_form($form_id, &$form, $callback = NULL) {
function drupal_execute_form($form_id, $form, $callback = NULL) {
global $form_values;
- if (!empty($_POST['edit'])) {
- drupal_validate_form($form_id, $form, $callback);
- if (!form_get_errors()) {
- foreach (module_implements('form_execute_alter') as $module) {
- $function = $module .'_form_execute_alter';
- $function($form_id, $form_values);
- }
+ foreach (module_implements('form_execute_alter') as $module) {
+ $function = $module .'_form_execute_alter';
+ $function($form_id, $form_values);
+ }
- if (function_exists($form_id . '_execute')) {
- call_user_func($form_id . '_execute', $form_id, $form_values);
- }
- elseif (function_exists($callback . '_execute')) {
- call_user_func($callback . '_execute', $form_id, $form_values);
- }
- }
+ if (function_exists($form_id . '_execute')) {
+ call_user_func($form_id . '_execute', $form_id, $form_values);
+ }
+ elseif (function_exists($callback . '_execute')) {
+ call_user_func($callback . '_execute', $form_id, $form_values);
}
}
@@ -444,30 +133,27 @@ function _form_validate(&$elements) {
}
/* Validate the current input */
- if (!$elements[validated] && $elements[input]) {
- if ($elements[required]) {
- if (!$elements[value]) {
- form_error($elements, t('%name field is required', array('%name' => $elements[title])));
- }
- if ($elements[valid]) {
- if (is_array($elements[valid])) {
- foreach ($elements[valid] as $key => $valid) {
- $args = is_array($elements[validation_arguments][$key]) ? $elements[validation_arguments][$key] : array();
- if (function_exists('valid_' . $valid)) {
- call_user_func_array('valid_' . $valid, array_merge(array($elements), $args));
- }
+ if (!$elements['#validated'] && $elements['#input']) {
+ if ($elements['#required'] && !$elements['#value']) {
+ form_error($elements, t('%name field is required', array('%name' => $elements['#title'])));
+ }
+ if ($elements['#valid']) {
+ if (is_array($elements['#valid'])) {
+ foreach ($elements['#valid'] as $key => $valid) {
+ $args = is_array($elements['#validation_arguments'][$key]) ? $elements['#validation_arguments'][$key] : array();
+ if (function_exists($valid . '_valid')) {
+ call_user_func_array($valid . '_valid', array_merge(array($elements), $args));
}
}
- else {
- $args = is_array($elements[validation_arguments]) ? $elements[validation_arguments] : array();
- if (function_exists('valid_' . $elements[valid])) {
- call_user_func_array('valid_' . $elements[valid], array_merge(array($elements), $args));
- }
+ }
+ else {
+ $args = is_array($elements['#validation_arguments']) ? $elements['#validation_arguments'] : array();
+ if (function_exists($elements['#valid'] . '_valid')) {
+ call_user_func_array($elements['#valid'] . '_valid', array_merge(array($elements), $args));
}
-
}
}
- $elements[validated] = TRUE;
+ $elements['#validated'] = TRUE;
}
}
@@ -475,8 +161,8 @@ function _form_validate(&$elements) {
* Flag an element as having an error.
*/
function form_error(&$element, $message) {
- $element[error] = TRUE;
- $GLOBALS['form'][$element[name]] = $message;
+ $element['#error'] = TRUE;
+ $GLOBALS['form'][$element['#name']] = $message;
drupal_set_message($message, 'error');
}
@@ -490,56 +176,57 @@ function _form_builder($form, $parents = array(), $multiple = FALSE) {
global $form_values;
global $form_execute;
- if ($form[built] == TRUE) {
+ if ($form['#built'] == TRUE) {
return $form;
}
- $form[built] = TRUE;
+ $form['#built'] = TRUE;
- $form[parents] = ($form[parents]) ? $form[parents] : $parents;
+ $form['#parents'] = ($form['#parents']) ? $form['#parents'] : $parents;
/* Use element defaults */
- if ((!empty($form[type])) && ($info = _element_info($form[type]))) {
+ if ((!empty($form['#type'])) && ($info = _element_info($form['#type']))) {
$form += $info;
}
- if ($form[input]) {
- if (!$form[tree]) {
- $form[parents] = array(array_pop($form[parents]));
+ if ($form['#input']) {
+ if (!$form['#tree']) {
+ $form['#parents'] = array(array_pop($form['#parents']));
}
- $form[name] = ($form[name]) ? $form[name] : 'edit[' . implode('][', $form[parents]) . ']';
- $form[id] = ($form[id]) ? $form[id] : 'edit-' . implode('-', $form[parents]);
+ $form['#name'] = ($form['#name']) ? $form['#name'] : 'edit[' . implode('][', $form['#parents']) . ']';
+ $form['#id'] = ($form['#id']) ? $form['#id'] : 'edit-' . implode('-', $form['#parents']);
$posted = isset($_POST['edit']);
$edit = $posted ? $_POST['edit'] : array();
$ref =& $form_values;
- foreach ($form[parents] as $parent) {
+ foreach ($form['#parents'] as $parent) {
$edit = isset($edit[$parent]) ? $edit[$parent] : NULL;
$ref =& $ref[$parent];
}
- $default_value = $posted ? $edit : $form[default_value];
- $form[value] = isset($form[value]) ? $form[value] : $default_value;
- if (isset($form[execute])) {
- if ($_POST[$form[name]] == $form[value]) {
- $form_execute = $form_execute || $form[execute];
+ if (!isset($form['#value'])) {
+ $form['#value'] = $posted ? $edit : $form['#default_value'];
+ }
+ if (isset($form['#execute'])) {
+ if ($_POST[$form['#name']] == $form['#value']) {
+ $form_execute = $form_execute || $form['#execute'];
}
}
- $ref = $form[value];
+ $ref = $form['#value'];
}
// Allow for elements to expand to multiple elements. Radios, checkboxes and files for instance.
- if (function_exists($form[process]) && !$form[processed]) {
- $form = call_user_func($form[process], $form);
- $form[processed] = TRUE;
+ if (function_exists($form['#process']) && !$form['#processed']) {
+ $form = call_user_func($form['#process'], $form);
+ $form['#processed'] = TRUE;
}
// Recurse through all child elements.
$count = 0;
foreach (element_children($form) as $key) {
- $form[$key][tree] = (isset($form[$key][tree])) ? $form[$key][tree] : $form[tree];
+ $form[$key]['#tree'] = (isset($form[$key]['#tree'])) ? $form[$key]['#tree'] : $form['#tree'];
# Assign a decimal placeholder weight, to preserve original array order
- $form[$key][weight] = $form[$key][weight] ? $form[$key][weight] : $count/10;
- $form[$key] = _form_builder($form[$key], array_merge($form[parents], array($key)));
+ $form[$key]['#weight'] = $form[$key]['#weight'] ? $form[$key]['#weight'] : $count/10;
+ $form[$key] = _form_builder($form[$key], array_merge($form['#parents'], array($key)));
$count++;
}
@@ -564,14 +251,14 @@ function form_render(&$elements) {
uasort($elements, "_form_sort");
}
- if (!$elements[children]) {
+ if (!$elements['#children']) {
/* render all the children using a theme function */
- if ($elements[theme] && !$elements[theme_used]) {
- $elements[theme_used] = TRUE;
- $previous_type = $elements[type];
- $elements[type] = 'markup';
- $content = theme($elements[theme], $elements);
- $elements[type] = $previous_type;
+ if ($elements['#theme'] && !$elements['#theme_used']) {
+ $elements['#theme_used'] = TRUE;
+ $previous_type = $elements['#type'];
+ $elements['#type'] = 'markup';
+ $content = theme($elements['#theme'], $elements);
+ $elements['#type'] = $previous_type;
}
/* render each of the children using form_render and concatenate them */
if (!$content) {
@@ -581,26 +268,28 @@ function form_render(&$elements) {
}
}
if ($content) {
- $elements[children] = $content;
+ $elements['#children'] = $content;
}
/* Call the form element renderer */
- if (!$elements[printed]) {
- $content = theme(($elements[type]) ? $elements[type]: 'markup', $elements);
- $elements[printed] = TRUE;
+ if (!$elements['#printed']) {
+ $content = theme(($elements['#type']) ? $elements['#type']: 'markup', $elements);
+ $elements['#printed'] = TRUE;
}
- return $elements[prefix] . $content . $elements[suffix];
+ if ($content) {
+ return $elements['#prefix'] . $content . $elements['#suffix'];
+ }
}
/**
* Function used by uasort in form render to sort form via weight.
*/
function _form_sort($a, $b) {
- if ($a[weight] == $b[weight]) {
+ if ($a['#weight'] == $b['#weight']) {
return 0;
}
- return ($a[weight] < $b[weight]) ? -1 : 1;
+ return ($a['#weight'] < $b['#weight']) ? -1 : 1;
}
/**
@@ -609,10 +298,10 @@ function _form_sort($a, $b) {
function _element_info($type, $refresh = null) {
static $cache;
$basic_defaults = array(
- description => NULL,
- attributes => array(),
- required => FALSE,
- tree => FALSE
+ '#description' => NULL,
+ '#attributes' => array(),
+ '#required' => FALSE,
+ '#tree' => FALSE
);
if ($refresh || !is_array($cache)) {
$cache = array();
@@ -647,19 +336,19 @@ function _element_info($type, $refresh = null) {
*/
function theme_select($element) {
$select = '';
- foreach ($element[options] as $key => $choice) {
+ foreach ($element['#options'] as $key => $choice) {
if (is_array($choice)) {
$select .= '<optgroup label="'. $key .'">';
foreach ($choice as $key => $choice) {
- $select .= '<option value="'. $key .'"'. (is_array($element[value]) ? (in_array($key, $element[value]) ? ' selected="selected"' : '') : ($element[value] == $key ? ' selected="selected"' : '')) .'>'. check_plain($choice) .'</option>';
+ $select .= '<option value="'. $key .'"'. (is_array($element['#value']) ? (in_array($key, $element['#value']) ? ' selected="selected"' : '') : ($element['#value'] == $key ? ' selected="selected"' : '')) .'>'. check_plain($choice) .'</option>';
}
$select .= '</optgroup>';
}
else {
- $select .= '<option value="'. $key .'"'. (is_array($element[value]) ? (in_array($key, $element[value]) ? ' selected="selected"' : '') : ($element[value] == $key ? ' selected="selected"' : '')) .'>'. check_plain($choice) .'</option>';
+ $select .= '<option value="'. $key .'"'. (is_array($element['#value']) ? (in_array($key, $element['#value']) ? ' selected="selected"' : '') : ($element['#value'] == $key ? ' selected="selected"' : '')) .'>'. check_plain($choice) .'</option>';
}
}
- return theme('form_element', $element[title], '<select name="'. $element[name] .''. ($element[multiple] ? '[]' : '') .'"'. ($element[multiple] ? ' multiple="multiple" ' : '') . ($element[extra] ? ' '. $element[extra] : '') .' id="' . $element[id] .'">'. $select .'</select>', $element[description], $element[name], $element[required], _form_get_error($element[name]));
+ return theme('form_element', $element['#title'], '<select name="'. $element['#name'] .''. ($element['#multiple'] ? '[]' : '') .'"'. ($element['#multiple'] ? ' multiple="multiple" ' : '') . ($element['#extra'] ? ' '. $element['#extra'] : '') .' id="' . $element['#id'] .'">'. $select .'</select>', $element['#description'], $element['#name'], $element['#required'], _form_get_error($element['#name']));
}
/**
@@ -672,16 +361,16 @@ function theme_select($element) {
* A themed HTML string representing the form item group.
*/
function theme_fieldset($element) {
- if ($element[collapsible]) {
+ if ($element['#collapsible']) {
drupal_add_js('misc/collapse.js');
- $element[attributes]['class'] .= ' collapsible';
- if ($element[collapsed]) {
- $element[attributes]['class'] .= ' collapsed';
+ $element['#attributes']['class'] .= ' collapsible';
+ if ($element['#collapsed']) {
+ $element['#attributes']['class'] .= ' collapsed';
}
}
- return '<fieldset' . drupal_attributes($element[attributes]) .'>' . ($element[title] ? '<legend>'. $element[title] .'</legend>' : '') . $element[children] . $element[value] . ($element[description] ? '<div class="description">'. $element[description] .'</div>' : '') . "</fieldset>\n";
+ return '<fieldset' . drupal_attributes($element['#attributes']) .'>' . ($element['#title'] ? '<legend>'. $element['#title'] .'</legend>' : '') . $element['#children'] . $element['#value'] . ($element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') . "</fieldset>\n";
}
@@ -697,15 +386,15 @@ function theme_fieldset($element) {
*/
function theme_radio($element) {
$output = '<input type="radio" ';
- $output .= 'class="'. _form_get_class('form-radio', $element[required], _form_get_error($element[name])) .'" ';
- $output .= 'name="' . $element[name] .'" ';
- $output .= 'value="'. $element[return_value] .'" ';
- $output .= ($element[value] == $element[return_value]) ? ' checked="checked" ' : ' ';
- $output .= drupal_attributes($element[attributes]) .' />';
- if (!is_null($element[title])) {
- $output = '<label class="option">'. $output .' '. $element[title] .'</label>';
+ $output .= 'class="'. _form_get_class('form-radio', $element['#required'], _form_get_error($element['#name'])) .'" ';
+ $output .= 'name="' . $element['#name'] .'" ';
+ $output .= 'value="'. $element['#return_value'] .'" ';
+ $output .= ($element['#value'] == $element['#return_value']) ? ' checked="checked" ' : ' ';
+ $output .= drupal_attributes($element['#attributes']) .' />';
+ if (!is_null($element['#title'])) {
+ $output = '<label class="option">'. $output .' '. $element['#title'] .'</label>';
}
- return theme('form_element', NULL, $output, $element[description], $element[name], $element[required], _form_get_error($element[name]));
+ return theme('form_element', NULL, $output, $element['#description'], $element['#name'], $element['#required'], _form_get_error($element['#name']));
}
/**
@@ -718,11 +407,11 @@ function theme_radio($element) {
* A themed HTML string representing the radio button set.
*/
function theme_radios($element) {
- if ($element[title] || $element[description]) {
- return theme('form_element', $element[title], $element[children], $element[description], $element[id], $element[required], _form_get_error($element[name]));
+ if ($element['#title'] || $element['#description']) {
+ return theme('form_element', $element['#title'], $element['#children'], $element['#description'], $element['#id'], $element['#required'], _form_get_error($element['#name']));
}
else {
- return $element[children];
+ return $element['#children'];
}
}
@@ -736,8 +425,8 @@ function theme_radios($element) {
* A themed HTML string representing the radio button set.
*/
function theme_date($element) {
- $output = '<div class="container-inline">' . $element[children] . '</div>';
- return theme('form_element', $element[title], $output, $element[description], $element[id], $element[required], _form_get_error($element[name]));
+ $output = '<div class="container-inline">' . $element['#children'] . '</div>';
+ return theme('form_element', $element['#title'], $output, $element['#description'], $element['#id'], $element['#required'], _form_get_error($element['#name']));
}
/**
@@ -745,8 +434,8 @@ function theme_date($element) {
*/
function expand_date($element) {
// Default to current date
- if (!isset($element[value])) {
- $element[value] = array('day' => format_date(time(), 'custom', 'j'),
+ if (!isset($element['#value'])) {
+ $element['#value'] = array('day' => format_date(time(), 'custom', 'j'),
'month' => format_date(time(), 'custom', 'n'),
'year' => format_date(time(), 'custom', 'Y'));
}
@@ -773,7 +462,7 @@ function expand_date($element) {
$options = drupal_map_assoc(range(1900, 2050));
break;
}
- $element[$type] = array(type => 'radio', value => $element[value][$type], attributes => $element[attributes], parents => $element[parents], options => $options, tree => TRUE);
+ $element[$type] = array('#type' => 'radio', '#value' => $element['#value'][$type], '#attributes' => $element['#attributes'], '#parents' => $element['#parents'], '#options' => $options, '#tree' => TRUE);
}
return $element;
@@ -785,10 +474,10 @@ function expand_date($element) {
* to a list of radios, using the options array as index.
*/
function expand_radios($element) {
- if (count($element[options]) > 0) {
- foreach ($element[options] as $key => $choice) {
+ if (count($element['#options']) > 0) {
+ foreach ($element['#options'] as $key => $choice) {
if (!$element[$key]) {
- $element[$key] = array(type => 'radio', title => $choice, return_value => $key, default_value => $element[default_value], attributes => $element[attributes], parents => $element[parents], spawned => TRUE);
+ $element[$key] = array('#type' => 'radio', '#title' => $choice, '#return_value' => $key, '#default_value' => $element['#default_value'], '#attributes' => $element['#attributes'], '#parents' => $element['#parents'], '#spawned' => TRUE);
}
}
}
@@ -807,7 +496,7 @@ function expand_radios($element) {
* A themed HTML string representing the form item.
*/
function theme_item($element) {
- return theme('form_element', $element[title], $element[value] . $element[children], $element[description], $element[id], $element[required], $element[error]);
+ return theme('form_element', $element['#title'], $element['#value'] . $element['#children'], $element['#description'], $element['#id'], $element['#required'], $element['#error']);
}
@@ -823,18 +512,18 @@ function theme_item($element) {
function theme_checkbox($element) {
$checkbox = '<input ';
$checkbox .= 'type="checkbox" ';
- $checkbox .= 'class="'. _form_get_class('form-checkbox', $element[required], _form_get_error($element[name])) . '" ';
- $checkbox .= 'name="'. $element[name] .'" ';
- $checkbox .= 'id="'. $element[id].'" ' ;
- $checkbox .= 'value="'. $element[return_value] .'" ';
- $checkbox .= ($element[value] == $element[return_value]) ? ' checked="checked" ' : ' ';
- $checkbox .= drupal_attributes($element[attributes]) . ' />';
-
- if (!is_null($element[title])) {
- $checkbox = '<label class="option">'. $checkbox .' '. $element[title] .'</label>';
+ $checkbox .= 'class="'. _form_get_class('form-checkbox', $element['#required'], _form_get_error($element['#name'])) . '" ';
+ $checkbox .= 'name="'. $element['#name'] .'" ';
+ $checkbox .= 'id="'. $element['#id'].'" ' ;
+ $checkbox .= 'value="'. $element['#return_value'] .'" ';
+ $checkbox .= ($element['#value'] == $element['#return_value']) ? ' checked="checked" ' : ' ';
+ $checkbox .= drupal_attributes($element['#attributes']) . ' />';
+
+ if (!is_null($element['#title'])) {
+ $checkbox = '<label class="option">'. $checkbox .' '. $element['#title'] .'</label>';
}
- return theme('form_element', NULL, $checkbox, $element[description], $element[name], $element[required], _form_get_error($element[name]));
+ return theme('form_element', NULL, $checkbox, $element['#description'], $element['#name'], $element['#required'], _form_get_error($element['#name']));
}
/**
@@ -846,23 +535,23 @@ function theme_checkbox($element) {
* A themed HTML string representing the checkbox set.
*/
function theme_checkboxes($element) {
- if ($element[title] || $element[description]) {
- return theme('form_element', $element[title], $element[children], $element[description], 'edit-'. $element[name], $element[required], _form_get_error($element[name]));
+ if ($element['#title'] || $element['#description']) {
+ return theme('form_element', $element['#title'], $element['#children'], $element['#description'], 'edit-'. $element['#name'], $element['#required'], _form_get_error($element['#name']));
}
else {
- return $element[children];
+ return $element['#children'];
}
}
function expand_checkboxes($element) {
- $value = is_array($element[value]) ? $element[value] : array();
- if (count($element[options]) > 0) {
- if (!isset($element[default_value]) || $element[default_value] == 0) {
- $element[default_value] = array();
+ $value = is_array($element['#value']) ? $element['#value'] : array();
+ if (count($element['#options']) > 0) {
+ if (!isset($element['#default_value']) || $element['#default_value'] == 0) {
+ $element['#default_value'] = array();
}
- foreach ($element[options] as $key => $choice) {
+ foreach ($element['#options'] as $key => $choice) {
if (!isset($element[$key])) {
- $element[$key] = array(type => 'checkbox', processed => TRUE, title => $choice, tree => TRUE, default_value => in_array($key, $value), attributes => $element[attributes]);
+ $element[$key] = array('#type' => 'checkbox', '#processed' => TRUE, '#title' => $choice, '#tree' => TRUE, '#default_value' => in_array($key, $value), '#attributes' => $element['#attributes']);
}
}
}
@@ -875,7 +564,7 @@ function theme_submit($element) {
}
function theme_button($element) {
- return '<input type="submit" class="form-'. $element[button_type] .'" name="'. $element[name] .'" value="'. check_plain($element[value]) .'" '. drupal_attributes($element[attributes]) ." />\n";
+ return '<input type="submit" class="form-'. $element['#button_type'] .'" name="'. $element['#name'] .'" value="'. check_plain($element['#value']) .'" '. drupal_attributes($element['#attributes']) ." />\n";
}
/**
@@ -888,7 +577,7 @@ function theme_button($element) {
* A themed HTML string representing the hidden form field.
*/
function theme_hidden($element) {
- return '<input type="hidden" name="'. $element[name] . '" id="' . $element[id] . '" value="'. check_plain($element[value]) ."\" " . drupal_attributes($element[attributes]) ." />\n";
+ return '<input type="hidden" name="'. $element['#name'] . '" id="' . $element['#id'] . '" value="'. check_plain($element['#value']) ."\" " . drupal_attributes($element['#attributes']) ." />\n";
}
/**
@@ -901,15 +590,15 @@ function theme_hidden($element) {
* A themed HTML string representing the textfield.
*/
function theme_textfield($element) {
- $size = $element[size] ? ' size="' . $element[size] . '"' : '';
- if ($element[autocomplete_path]) {
+ $size = $element['#size'] ? ' size="' . $element['#size'] . '"' : '';
+ if ($element['#autocomplete_path']) {
drupal_add_js('misc/autocomplete.js');
$class = ' form-autocomplete';
- $extra = '<input class="autocomplete" type="hidden" id="'. $element[id] .'-autocomplete" value="'. check_url(url($element[autocomplete_path], NULL, NULL, TRUE)) .'" disabled="disabled" />';
+ $extra = '<input class="autocomplete" type="hidden" id="'. $element['#id'] .'-autocomplete" value="'. check_url(url($element['#autocomplete_path'], NULL, NULL, TRUE)) .'" disabled="disabled" />';
}
- $output = '<input type="text" maxlength="'. $element[maxlength] .'" class="'. _form_get_class("form-text$class", $element[required], _form_get_error($element[name])) .'" name="'. $element[name] .'" id="'. $element[id] .'" '. $size .' value="'. check_plain($element[value]) .'"'. drupal_attributes($element[attributes]) .' />';
- return theme('form_element', $element[title], $output, $element[description], $element[id], $element[required], _form_get_error($element[name])). $extra;
+ $output = '<input type="text" maxlength="'. $element['#maxlength'] .'" class="'. _form_get_class("form-text$class", $element['#required'], _form_get_error($element['#name'])) .'" name="'. $element['#name'] .'" id="'. $element['#id'] .'" '. $size .' value="'. check_plain($element['#value']) .'"'. drupal_attributes($element['#attributes']) .' />';
+ return theme('form_element', $element['#title'], $output, $element['#description'], $element['#id'], $element['#required'], _form_get_error($element['#name'])). $extra;
}
/**
@@ -923,8 +612,8 @@ function theme_textfield($element) {
*/
function theme_form($element) {
// Anonymous div to satisfy XHTML compliancy.
- $action = $element[action] ? 'action="' . check_url($element[action]) . '" ' : '';
- return '<form '. $action . ' method="'. $element[method] .'" '. drupal_attributes($element[attributes]) .">\n<div>". $element[children] ."\n</div></form>\n";
+ $action = $element['#action'] ? 'action="' . check_url($element['#action']) . '" ' : '';
+ return '<form '. $action . ' method="'. $element['#method'] .'" '. drupal_attributes($element['#attributes']) .">\n<div>". $element['#children'] ."\n</div></form>\n";
}
@@ -938,9 +627,9 @@ function theme_form($element) {
* A themed HTML string representing the textarea.
*/
function theme_textarea($element) {
- $cols = $element[cols] ? ' cols="'. $element[cols] .'"' : '';
+ $cols = $element['#cols'] ? ' cols="'. $element['#cols'] .'"' : '';
- return theme('form_element', $element[title], '<textarea'. $cols .' rows="'. $element[rows] .'" name="'. $element[name] .'" id="' . $element[id] .'" class="'. _form_get_class('textarea', $element[required], _form_get_error($element[name])) .'"'. drupal_attributes($element[attributes]) .'>'. check_plain($element[value]) .'</textarea>', $element[description], $element[id], $element[required], _form_get_error($element[name]));
+ return theme('form_element', $element['#title'], '<textarea'. $cols .' rows="'. $element['#rows'] .'" name="'. $element['#name'] .'" id="' . $element['#id'] .'" class="'. _form_get_class('textarea', $element['#required'], _form_get_error($element['#name'])) .'"'. drupal_attributes($element['#attributes']) .'>'. check_plain($element['#value']) .'</textarea>', $element['#description'], $element['#id'], $element['#required'], _form_get_error($element['#name']));
}
/**
@@ -956,7 +645,7 @@ function theme_textarea($element) {
*/
function theme_markup($element) {
- return $element[value] . $element[children];
+ return $element['#value'] . $element['#children'];
}
@@ -971,11 +660,11 @@ function theme_markup($element) {
* A themed HTML string representing the form.
*/
function theme_password($element) {
- $size = $element[size] ? ' size="'. $element[size] .'" ' : '';
+ $size = $element['#size'] ? ' size="'. $element['#size'] .'" ' : '';
- $output = '<input type="password" maxlength="'. $element[maxlength] .'" class="'. _form_get_class("form-text $class", $element[required], _form_get_error($element[name])) .'" name="'. $element[name] .'" id="'. $element[id] .'" '. $size . drupal_attributes($element[attributes]) .' />';
+ $output = '<input type="password" maxlength="'. $element['#maxlength'] .'" class="'. _form_get_class("form-text $class", $element['#required'], _form_get_error($element['#name'])) .'" name="'. $element['#name'] .'" id="'. $element['#id'] .'" '. $size . drupal_attributes($element['#attributes']) .' />';
- return theme('form_element', $element[title], $output, $element[description], $element[id], $element[required], _form_get_error($element[name]));
+ return theme('form_element', $element['#title'], $output, $element['#description'], $element['#id'], $element['#required'], _form_get_error($element['#name']));
}
/**
@@ -988,11 +677,11 @@ function theme_password($element) {
* A themed HTML string representing the form.
*/
function theme_weight($element) {
- for ($n = (-1 * $element[delta]); $n <= $element[delta]; $n++) {
+ for ($n = (-1 * $element['#delta']); $n <= $element['#delta']; $n++) {
$weights[$n] = $n;
}
- $element[options] = $weights;
- $element[type] = 'select';
+ $element['#options'] = $weights;
+ $element['#type'] = 'select';
return form_render($element);
}
@@ -1034,7 +723,7 @@ function form_get_errors() {
* provided by file.inc.
*/
function theme_file($element) {
- return theme('form_element', $element[title], '<input type="file" class="'. _form_get_class('form-file', $element[required], _form_get_error($element[name])) .'" name="'. $element[name] .'" id="'. form_clean_id($element[id]) .'" size="'. $element[size] ."\" />\n", $element[description], $element[id], $element[required], _form_get_error($element[name]));
+ return theme('form_element', $element['#title'], '<input type="file" class="'. _form_get_class('form-file', $element['#required'], _form_get_error($element['#name'])) .'" name="'. $element['#name'] .'" id="'. form_clean_id($element['#id']) .'" size="'. $element['#size'] ."\" />\n", $element['#description'], $element['#id'], $element['#required'], _form_get_error($element['#name']));
}
/**
diff --git a/includes/locale.inc b/includes/locale.inc
index 817839b1a..403433869 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -39,8 +39,8 @@ function _locale_admin_manage_screen() {
$languages = locale_supported_languages(TRUE, TRUE);
$options = array();
- $form[action] = url('admin/locale');
- $form['name'] = array(tree => TRUE);
+ $form['#action'] = url('admin/locale');
+ $form['name'] = array('#tree' => TRUE);
foreach ($languages['name'] as $key => $lang) {
$options[$key] = '';
$status = db_fetch_object(db_query("SELECT isdefault, enabled FROM {locales_meta} WHERE locale = '%s'", $key));
@@ -51,7 +51,7 @@ function _locale_admin_manage_screen() {
$isdefault = $key;
}
if ($key == 'en') {
- $form['name']['en'] = array(type => 'markup', value => check_plain($lang));
+ $form['name']['en'] = array('#type' => 'markup', '#value' => check_plain($lang));
}
else {
$original = db_fetch_object(db_query("SELECT COUNT(*) AS strings FROM {locales_source}"));
@@ -59,13 +59,13 @@ function _locale_admin_manage_screen() {
$ratio = ($original->strings > 0 && $translation->translation > 0) ? round(($translation->translation/$original->strings)*100., 2) : 0;
- $form['name'][$key] = array(type => 'textfield', default_value => $lang, size => 15, maxlength => 64);
- $form['translation'][$key] = array(type => 'markup', default_value => "$translation->translation/$original->strings ($ratio%)");
+ $form['name'][$key] = array('#type' => 'textfield', '#default_value' => $lang, '#size' => 15, '#maxlength' => 64);
+ $form['translation'][$key] = array('#type' => 'markup', '#default_value' => "$translation->translation/$original->strings ($ratio%)");
}
}
- $form['enabled'] = array(type => 'checkboxes', options => $options, default_value => $enabled, return_value => 1);
- $form['sitedefault'] = array(type => 'radios', options => $options, default_value => $isdefault, return_value => 1);
- $form['submit'] = array(type => 'submit', value => t('Save configuration'));
+ $form['enabled'] = array('#type' => 'checkboxes', '#options' => $options, '#default_value' => $enabled, '#return_value' => 1);
+ $form['sitedefault'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $isdefault, '#return_value' => 1);
+ $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
return drupal_get_form('_locale_admin_manage_screen', $form);
}
@@ -91,17 +91,17 @@ function _locale_admin_manage_add_screen() {
$isocodes = _locale_prepare_iso_list();
$form = array();
- $form['header'] = array(prefix => '<h2>', value => t('Language list'), suffix => '</h2>');
- $form['langcode'] = array(type => 'select', title => t('Language name'), default_value => key($isocodes), options => $isocodes, description => t('Select your language here, or add it below, if you are unable to find it.'));
- $form['submit'] = array(type => 'submit', value => t('Add language'));
+ $form['header'] = array('#prefix' => '<h2>', '#value' => t('Language list'), '#suffix' => '</h2>');
+ $form['langcode'] = array('#type' => 'select', '#title' => t('Language name'), '#default_value' => key($isocodes), '#options' => $isocodes, '#description' => t('Select your language here, or add it below, if you are unable to find it.'));
+ $form['submit'] = array('#type' => 'submit', '#value' => t('Add language'));
$output = drupal_get_form('locale_add_language', $form);
$edit = &$_POST['edit'];
$form = array();
- $form['header'] = array(prefix => '<h2>', value => t('Custom language') , suffix => '</h2>');
- $form['langcode'] = array(type => 'textfield', title => t('Language code'), default_value => $edit['langcode'], size => 12, maxlength => 60, description => t("Commonly this is an <a href=\"%iso-codes\">ISO 639 language code</a> with an optional country code for regional variants. Examples include 'en', 'en-US' and 'zh-cn'.", array('%iso-codes' => 'http://www.w3.org/WAI/ER/IG/ert/iso639.htm')));
- $form['langname'] = array(type => 'textfield', title => t('Language name in English'), default_value => $edit['langname'], size => 60, maxlength => 64, description => t('Name of the language. Will be available for translation in all languages.'));
- $form['submit'] = array(type => 'submit', value => t('Add custom language'));
+ $form['header'] = array('#prefix' => '<h2>', '#value' => t('Custom language') , '#suffix' => '</h2>');
+ $form['langcode'] = array('#type' => 'textfield', '#title' => t('Language code'), '#default_value' => $edit['langcode'], '#size' => 12, '#maxlength' => 60, '#description' => t("Commonly this is an <a href=\"%iso-codes\">ISO 639 language code</a> with an optional country code for regional variants. Examples include 'en', 'en-US' and 'zh-cn'.", array('%iso-codes' => 'http://www.w3.org/WAI/ER/IG/ert/iso639.htm')));
+ $form['langname'] = array('#type' => 'textfield', '#title' => t('Language name in English'), '#default_value' => $edit['langname'], '#size' => 60, '#maxlength' => 64, '#description' => t('Name of the language. Will be available for translation in all languages.'));
+ $form['submit'] = array('#type' => 'submit', '#value' => t('Add custom language'));
$output .= drupal_get_form('_locale_custom_language', $form);
@@ -127,12 +127,12 @@ function _locale_admin_import_screen() {
}
$form = array();
- $form['file'] = array(type => 'file', title => t('Language file'), size => 50, description => t('A gettext Portable Object (.po) file.'));
- $form['langcode'] = array(type => 'select', title => t('Import into'), options => $languages, description => t('Choose the language you want to add strings into. If you choose a language which is not yet set up, then it will be added.'));
- $form['mode'] = array(type => 'radios', title => t('Mode'), default_value => 'overwrite', options => array('overwrite' => t('Strings in the uploaded file replace existing ones, new ones are added'), 'keep' => t('Existing strings are kept, only new strings are added')));
- $form['submit'] = array(type => 'submit', value => t('Import'));
- $form[attributes]['enctype'] = 'multipart/form-data';
- $form[action] = 'admin/locale/language/import';
+ $form['file'] = array('#type' => 'file', '#title' => t('Language file'), '#size' => 50, '#description' => t('A gettext Portable Object (.po) file.'));
+ $form['langcode'] = array('#type' => 'select', '#title' => t('Import into'), '#options' => $languages, '#description' => t('Choose the language you want to add strings into. If you choose a language which is not yet set up, then it will be added.'));
+ $form['mode'] = array('#type' => 'radios', '#title' => t('Mode'), '#default_value' => 'overwrite', '#options' => array('overwrite' => t('Strings in the uploaded file replace existing ones, new ones are added'), 'keep' => t('Existing strings are kept, only new strings are added')));
+ $form['submit'] = array('#type' => 'submit', '#value' => t('Import'));
+ $form['#attributes']['enctype'] = 'multipart/form-data';
+ $form['#action'] = 'admin/locale/language/import';
return drupal_get_form('_locale_admin_import', $form);
}
@@ -733,8 +733,8 @@ function _locale_admin_export_screen() {
if (count($languages)) {
$output .= '<h2>'. t('Export translation') .'</h2>';
$form = array();
- $form['langcode'] = array(type => 'select', title => t('Language name'), options => $languages, description => t('Select the language you would like to export in gettext Portable Object (.po) format.'));
- $form['submit'] = array(type => 'submit', value => t('Export'));
+ $form['langcode'] = array('#type' => 'select', '#title' => t('Language name'), '#options' => $languages, '#description' => t('Select the language you would like to export in gettext Portable Object (.po) format.'));
+ $form['submit'] = array('#type' => 'submit', '#value' => t('Export'));
$output .= drupal_get_form('_locale_export_po', $form);
}
@@ -742,7 +742,7 @@ function _locale_admin_export_screen() {
$output .= '<h2>'. t('Export template') .'</h2>';
$output .= t('<p>Generate a gettext Portable Object Template (.pot) file with all the interface strings from the Drupal locale database.</p>');
$form = array();
- $form['submit'] = array(type => 'submit', value => t('Export'));
+ $form['submit'] = array('#type' => 'submit', '#value' => t('Export'));
$output .= drupal_get_form('_locale_export_pot', $form);
return $output;
@@ -980,18 +980,18 @@ function _locale_string_edit($lid) {
while ($translation = db_fetch_object($result)) {
$orig = $translation->source;
$form[$translation->locale] = (strlen($orig) > 40) ?
- array(type => 'textarea', title => $languages['name'][$translation->locale], default_value => $translation->translation, cols => 60, rows => 15)
- : array(type => 'textfield', title => $languages['name'][$translation->locale], default_value => $translation->translation, size => 60, maxlength => 128);
+ array('#type' => 'textarea', '#title' => $languages['name'][$translation->locale], '#default_value' => $translation->translation, '#cols' => 60, '#rows' => 15)
+ : array('#type' => 'textfield', '#title' => $languages['name'][$translation->locale], '#default_value' => $translation->translation, '#size' => 60, '#maxlength' => 128);
unset($languages['name'][$translation->locale]);
}
- $form = array(type => 'item', title => t('Original text'), value => wordwrap(check_plain($orig, 0)));
+ $form = array('#type' => 'item', '#title' => t('Original text'), '#value' => wordwrap(check_plain($orig, 0)));
foreach ($languages['name'] as $key => $lang) {
$form[$key] = (strlen($orig) > 40) ?
-array(type => 'textarea', title => $lang, cols => 60, rows => 15) :
-array(type => 'textfield', title => $lang, size => 60, maxlength => 128);
+array('#type' => 'textarea', '#title' => $lang, '#cols' => 60, '#rows' => 15) :
+array('#type' => 'textfield', '#title' => $lang, '#size' => 60, '#maxlength' => 128);
}
- $form['submit'] = array(type => 'submit', value => t('Save translations'));
+ $form['submit'] = array('#type' => 'submit', '#value' => t('Save translations'));
return $form;
}
@@ -1122,12 +1122,12 @@ function _locale_string_seek_form() {
// Present edit form preserving previous user settings
$query = _locale_string_seek_query();
$form = array();
- $form['search'] = array(type => 'fieldset', title => t('Search'));
- $form['search']['string'] = array(type => 'textfield', title => t('Strings to search for'), default_value => $query->string, size => 30, maxlength => 30, description => t('Leave blank to show all strings. The search is case sensitive.'));
- $form['search']['language'] = array(type => 'radios', title => t('Language'), default_value => ($query->language ? $query->language : 'all'), options => array_merge(array('all' => t('All languages'), 'en' => t('English (provided by Drupal)')), $languages['name']));
- $form['search']['searchin'] = array(type => 'radios', title => t('Search in'), default_value => ($query->searchin ? $query->searchin : 'all'), options => array('all' => t('All strings in that language'), 'translated' => t('Only translated strings'), 'untranslated' => t('Only untranslated strings')));
- $form['search']['submit'] = array(type => 'submit', value => t('Search'));
- $form[action] = 'admin/locale/string/search';
+ $form['search'] = array('#type' => 'fieldset', '#title' => t('Search'));
+ $form['search']['string'] = array('#type' => 'textfield', '#title' => t('Strings to search for'), '#default_value' => $query->string, '#size' => 30, '#maxlength' => 30, '#description' => t('Leave blank to show all strings. The search is case sensitive.'));
+ $form['search']['language'] = array('#type' => 'radios', '#title' => t('Language'), '#default_value' => ($query->language ? $query->language : 'all'), '#options' => array_merge(array('all' => t('All languages'), 'en' => t('English (provided by Drupal)')), $languages['name']));
+ $form['search']['searchin'] = array('#type' => 'radios', '#title' => t('Search in'), '#default_value' => ($query->searchin ? $query->searchin : 'all'), '#options' => array('all' => t('All strings in that language'), 'translated' => t('Only translated strings'), 'untranslated' => t('Only untranslated strings')));
+ $form['search']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
+ $form['#action'] = 'admin/locale/string/search';
return drupal_get_form('_locale_string_seek', $form);
}
diff --git a/includes/unicode.inc b/includes/unicode.inc
index ce6ba32ac..3508aad64 100644
--- a/includes/unicode.inc
+++ b/includes/unicode.inc
@@ -81,7 +81,7 @@ function unicode_settings() {
$options = array(UNICODE_SINGLEBYTE => t('Standard PHP: operations on Unicode strings are emulated on a best-effort basis. Install the <a href="%url">PHP mbstring extension</a> for improved Unicode support.', array('%url' => 'http://www.php.net/mbstring')),
UNICODE_MULTIBYTE => t('Multi-byte: operations on Unicode strings are supported through the <a href="%url">PHP mbstring extension</a>.', array('%url' => 'http://www.php.net/mbstring')),
UNICODE_ERROR => t('Invalid: the current configuration is incompatible with Drupal.'));
- $form['settings'] = array(type => 'item', title =>t('String handling method'), value => $options[$status]);
+ $form['settings'] = array('#type' => 'item', '#title' =>t('String handling method'), '#value' => $options[$status]);
return $form;
}