? .DS_Store ? .svn ? 2 ? erlend oye - unrest (advanced) ? forms.patch ? database/.svn ? includes/.svn ? includes/form.inc ? includes/legacy.inc ? misc/.svn ? modules/.svn ? modules/node.module.tmp ? scripts/.svn ? sites/.svn ? sites/forms.drupal.dev ? sites/default/.svn ? themes/.svn ? themes/bluemarine/.svn ? themes/chameleon/.svn ? themes/chameleon/marvin/.svn ? themes/engines/.svn ? themes/engines/phptemplate/.svn ? themes/pushbutton/.svn Index: update.php =================================================================== RCS file: /cvs/drupal/drupal/update.php,v retrieving revision 1.156 diff -u -r1.156 update.php --- update.php 31 Aug 2005 17:56:07 -0000 1.156 +++ update.php 2 Oct 2005 00:38:09 -0000 @@ -54,11 +54,20 @@ $dates[$i] = "No updates available"; // make update form and output it. - $form = form_select("Perform updates from", "start", (isset($selected) ? $selected : -1), $dates, "This defaults to the first available update since the last update you performed."); - $form .= form_submit("Update"); + $form['start'] = array( + type => 'select', + title => t('Perform updates from'), + default_value => (isset($selected) ? $selected : -1), + options => $dates, + description => t('This defaults to the first available update since the last update you performed.') + ); + $form['submit'] = array( + type => 'submit', + value => t('Update') + ); drupal_set_title('Drupal database update'); - return form($form); + return drupal_get_form('update_script_selection_form', $form); } function update_do_updates() { Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.480 diff -u -r1.480 common.inc --- includes/common.inc 29 Sep 2005 12:33:34 -0000 1.480 +++ includes/common.inc 2 Oct 2005 00:38:20 -0000 @@ -490,38 +490,6 @@ } /** - * An unchecked checkbox is not present in $_POST so we fix it here by - * proving a default value of 0. Also, with form_checkboxes() we expect - * an array, but HTML does not send the empty array. This is also taken - * care off. - */ -function fix_checkboxes() { - if (isset($_POST['form_array'])) { - $_POST['edit'] = _fix_checkboxes($_POST['edit'], $_POST['form_array'], array()); - } - if (isset($_POST['form_zero'])) { - $_POST['edit'] = _fix_checkboxes($_POST['edit'], $_POST['form_zero'], 0); - } -} - -function _fix_checkboxes($array1, $array2, $value) { - if (is_array($array2) && count($array2)) { - foreach ($array2 as $k => $v) { - if (is_array($v) && count($v)) { - $array1[$k] = _fix_checkboxes($array1[$k], $v, $value); - } - else if (!isset($array1[$k])) { - $array1[$k] = $value; - } - } - } - else { - $array1 = $value; - } - return $array1; -} - -/** * @name Conversion * @{ * Converts data structures to different types. @@ -560,6 +528,7 @@ return $array; } + /** * @} End of "Conversion". */ @@ -1011,600 +980,6 @@ */ /** - * @defgroup form Form generation - * @{ - * Functions to enable output of HTML forms and form elements. - * - * Drupal uses these functions to achieve consistency in its form presentation, - * while at the same time simplifying code and reducing the amount of HTML that - * must be explicitly generated by modules. - */ - -/** - * Generate a form from a set of form elements. - * - * @param $form - * An HTML string containing one or more form elements. - * @param $method - * The query method to use ("post" or "get"). - * @param $action - * The URL to send the form contents to, if not the current page. - * @param $attributes - * An associative array of attributes to add to the form tag. - * @result - * An HTML string with the contents of $form wrapped in a form tag. - */ -function form($form, $method = 'post', $action = NULL, $attributes = NULL) { - if (!$action) { - $action = request_uri(); - } - // Anonymous div to satisfy XHTML compliancy. - return '
\n
". $form ."\n
\n"; -} - -/** - * Set a hidden 'form_token' field to be included in a form, used to validate - * that the resulting submission was actually generated by a local form. - * - * @param $key - * A unique key to identify the form that is currently being displayed. - * This identical key is later used to validate that the resulting submission - * actually originated with this form. - * @result - * A themed HTML string representing the hidden token field. - */ -function form_token($key) { - // this private key should always be kept secret - if (!variable_get('drupal_private_key', '')) { - variable_set('drupal_private_key', mt_rand()); - } - - // the verification token is an md5 hash of the form key and our private key - return form_hidden('form_token', md5($_SERVER['REMOTE_ADDR'] . $key . variable_get('drupal_private_key', ''))); -} - -/** - * Verify that the hidden 'form_token' field was actually generated with our - * private key. - * - * @param $edit - * An array containing the form that needs to be validated. - * @param $key - * The same key that was used to generate the 'form_token'. - * @param $error_message - * An optional error message to display if the form does not validate. - * @result - * There is nothing returned from this function, but if the 'form_token' does - * not validate an error is generated, preventing the submission. - */ -function form_validate($edit, $key, $error_message = NULL) { - if ($error_message == NULL) { - // set a generic default error message - $error = t('Validation error, please try again. If this error persists, please contact the site administrator.'); - } - - if ($edit['form_token'] != md5($_SERVER['REMOTE_ADDR'] . $key . variable_get('drupal_private_key', ''))) { - // setting this error will cause the form to fail validation - form_set_error('form_token', $error); - } -} - -/** - * File an error against the form element with the specified name. - */ -function form_set_error($name, $message) { - $GLOBALS['form'][$name] = $message; - drupal_set_message($message, 'error'); -} - -/** - * Return an associative array of all errors. - */ -function form_get_errors() { - if (array_key_exists('form', $GLOBALS)) { - return $GLOBALS['form']; - } -} - -/** - * Return the error message filed against the form with the specified name. - */ -function _form_get_error($name) { - if (array_key_exists('form', $GLOBALS)) { - return $GLOBALS['form'][$name]; - } -} - -function _form_get_class($name, $required, $error) { - return $name. ($required ? ' required' : '') . ($error ? ' error' : ''); -} - -/** - * Format a general form item. - * - * @param $title - * The label for the form item. - * @param $value - * The contents of the form item. - * @param $description - * Explanatory text to display after the form item. - * @param $id - * A unique identifier for the form item. - * @param $required - * Whether the user must fill in this form element before submitting the form. - * @param $error - * An error message to display alongside the form element. - * @return - * A themed HTML string representing the form item. - */ -function form_item($title, $value, $description = NULL, $id = NULL, $required = FALSE, $error = FALSE) { - return theme('form_element', $title, $value, $description, $id, $required, $error); -} - -/** - * Format a group of form items. - * - * @param $legend - * The label for the form item group. - * @param $group - * The form items within the group, as an HTML string. - * @param $description - * Explanatory text to display after the form item group. - * @param $attributes - * An associative array of HTML attributes to add to the fieldset tag. - * @return - * A themed HTML string representing the form item group. - */ -function form_group($legend, $group, $description = NULL, $attributes = NULL) { - return '' . ($legend ? ''. $legend .'' : '') . $group . ($description ? '
'. $description .'
' : '') . "\n"; -} - -/** - * Format a group of form items. - * - * @param $legend - * The label for the form item group. - * @param $group - * The form items within the group, as an HTML string. - * @param $collapsed - * A boolean value decided whether the group starts collapsed. - * @param $description - * Explanatory text to display after the form item group. - * @param $attributes - * An associative array of HTML attributes to add to the fieldset tag. - * @return - * A themed HTML string representing the form item group. - */ -function form_group_collapsible($legend, $group, $collapsed = FALSE, $description = NULL, $attributes = NULL) { - drupal_add_js('misc/collapse.js'); - - $attributes['class'] .= ' collapsible'; - if ($collapsed) { - $attributes['class'] .= ' collapsed'; - } - - return '' . ($legend ? ''. $legend .'' : '') . $group . ($description ? '
'. $description .'
' : '') . "\n"; -} - -/** - * Format a radio button. - * - * @param $title - * The label for the radio button. - * @param $name - * The internal name used to refer to the button. - * @param $value - * The value that the form element takes on when selected. - * @param $checked - * Whether the button will be initially selected when the page is rendered. - * @param $description - * Explanatory text to display after the form item. - * @param $attributes - * An associative array of HTML attributes to add to the button. - * @param $required - * Whether the user must select this radio button before submitting the form. - * @return - * A themed HTML string representing the radio button. - */ -function form_radio($title, $name, $value = 1, $checked = FALSE, $description = NULL, $attributes = NULL, $required = FALSE) { - $element = ''; - if (!is_null($title)) { - $element = ''; - } - return theme('form_element', NULL, $element, $description, $name, $required, _form_get_error($name)); -} - -/** - * Format a set of radio buttons. - * - * @param $title - * The label for the radio buttons as a group. - * @param $name - * The internal name used to refer to the buttons. - * @param $value - * The currently selected radio button's key. - * @param $options - * An associative array of buttons to display. The keys in this array are - * button values, while the values are the labels to display for each button. - * @param $description - * Explanatory text to display after the form item. - * @param $required - * Whether the user must select a radio button before submitting the form. - * @param $attributes - * An associative array of HTML attributes to add to each button. - * @return - * A themed HTML string representing the radio button set. - */ -function form_radios($title, $name, $value, $options, $description = NULL, $required = FALSE, $attributes = NULL) { - if (count($options) > 0) { - $choices = ''; - foreach ($options as $key => $choice) { - $choices .= '
'; - } - return theme('form_element', $title, $choices, $description, NULL, $required, _form_get_error($name)); - } -} - -/** - * Format a checkbox. - * - * @param $title - * The label for the checkbox. - * @param $name - * The internal name used to refer to the button. - * @param $value - * The value that the form element takes on when selected. - * @param $checked - * Whether the button will be initially selected when the page is rendered. - * @param $description - * Explanatory text to display after the form item. - * @param $attributes - * An associative array of HTML attributes to add to the button. - * @param $required - * Whether the user must check this box before submitting the form. - * @return - * A themed HTML string representing the checkbox. - */ -function form_checkbox($title, $name, $value = 1, $checked = FALSE, $description = NULL, $attributes = NULL, $required = FALSE) { - $element = ''; - if (!is_null($title)) { - $element = ''; - } - return form_hidden($name, 1, 'form_zero') . theme('form_element', NULL, $element, $description, $name, $required, _form_get_error($name)); -} - -/** - * Format a set of checkboxes. - * - * @param $title - * The label for the checkboxes as a group. - * @param $name - * The internal name used to refer to the buttons. - * @param $values - * A linear array of keys of the initially checked boxes. - * @param $options - * An associative array of buttons to display. The keys in this array are - * button values, while the values are the labels to display for each button. - * @param $description - * Explanatory text to display after the form item. - * @param $attributes - * An associative array of HTML attributes to add to each button. - * @param $required - * Whether the user must check a box before submitting the form. - * @return - * A themed HTML string representing the checkbox set. - */ -function form_checkboxes($title, $name, $values, $options, $description = NULL, $attributes = NULL, $required = FALSE) { - if (count($options) > 0) { - if (!isset($values) || $values == 0) { - $values = array(); - } - $choices = ''; - foreach ($options as $key => $choice) { - $choices .= '
'; - } - return form_hidden($name, 1, 'form_array') . theme('form_element', $title, $choices, $description, NULL, $required, _form_get_error($name)); - } -} - -/** - * Format a single-line text field. - * - * @param $title - * The label for the text field. - * @param $name - * The internal name used to refer to the field. - * @param $value - * The initial value for the field at page load time. - * @param $size - * A measure of the visible size of the field (passed directly to HTML). - * @param $maxlength - * The maximum number of characters that may be entered in the field. - * @param $description - * Explanatory text to display after the form item. - * @param $attributes - * An associative array of HTML attributes to add to the form item. - * @param $required - * Whether the user must enter some text in the field. - * @return - * A themed HTML string representing the field. - */ -function form_textfield($title, $name, $value, $size, $maxlength, $description = NULL, $attributes = NULL, $required = FALSE) { - $size = $size ? ' size="'. $size .'"' : ''; - return theme('form_element', $title, '', $description, 'edit-'. $name, $required, _form_get_error($name)); -} - -/** - * Format a single-line text field that uses Ajax for autocomplete. - * - * @param $title - * The label for the text field. - * @param $name - * The internal name used to refer to the field. - * @param $value - * The initial value for the field at page load time. - * @param $size - * A measure of the visible size of the field (passed directly to HTML). - * @param $maxlength - * The maximum number of characters that may be entered in the field. - * @param $callback_path - * A drupal path for the Ajax autocomplete callback. - * @param $description - * Explanatory text to display after the form item. - * @param $attributes - * An associative array of HTML attributes to add to the form item. - * @param $required - * Whether the user must enter some text in the field. - * @return - * A themed HTML string representing the field. - */ -function form_autocomplete($title, $name, $value, $size, $maxlength, $callback_path, $description = NULL, $attributes = NULL, $required = FALSE) { - drupal_add_js('misc/autocomplete.js'); - - $size = $size ? ' size="'. $size .'"' : ''; - - $output = theme('form_element', $title, '', $description, 'edit-'. $name, $required, _form_get_error($name)); - $output .= ''; - - return $output; -} - -/** - * Format a single-line text field that does not display its contents visibly. - * - * @param $title - * The label for the text field. - * @param $name - * The internal name used to refer to the field. - * @param $value - * The initial value for the field at page load time. - * @param $size - * A measure of the visible size of the field (passed directly to HTML). - * @param $maxlength - * The maximum number of characters that may be entered in the field. - * @param $description - * Explanatory text to display after the form item. - * @param $attributes - * An associative array of HTML attributes to add to the form item. - * @param $required - * Whether the user must enter some text in the field. - * @return - * A themed HTML string representing the field. - */ -function form_password($title, $name, $value, $size, $maxlength, $description = NULL, $attributes = NULL, $required = FALSE) { - $size = $size ? ' size="'. $size .'"' : ''; - return theme('form_element', $title, '', $description, 'edit-'. $name, $required, _form_get_error($name)); -} - -/** - * Format a multiple-line text field. - * - * @param $title - * The label for the text field. - * @param $name - * The internal name used to refer to the field. - * @param $value - * The initial value for the field at page load time. - * @param $cols - * The width of the field, in columns of text. - * @param $rows - * The height of the field, in rows of text. - * @param $description - * Explanatory text to display after the form item. - * @param $attributes - * An associative array of HTML attributes to add to the form item. - * @param $required - * Whether the user must enter some text in the field. - * @return - * A themed HTML string representing the field. - */ -function form_textarea($title, $name, $value, $cols, $rows, $description = NULL, $attributes = NULL, $required = FALSE) { - $cols = $cols ? ' cols="'. $cols .'"' : ''; - $pre = ''; - $post = ''; - - // optionally plug in a WYSIWYG editor - foreach (module_list() as $module_name) { - if (module_hook($module_name, 'textarea')) { - $pre .= module_invoke($module_name, 'textarea', 'pre', $name); - $post .= module_invoke($module_name, 'textarea', 'post', $name); - } - } - - return theme('form_element', $title, $pre .''. check_plain($value) .''. $post, $description, 'edit-'. $name, $required, _form_get_error($name)); -} - -/** - * Format a dropdown menu or scrolling selection box. - * - * @param $title - * The label for the form element. - * @param $name - * The internal name used to refer to the form element. - * @param $value - * The key of the currently selected item, or a linear array of keys of all the - * currently selected items if multiple selections are allowed. - * @param $options - * An associative array of buttons to display. The keys in this array are - * button values, while the values are the labels to display for each button. - * @param $description - * Explanatory text to display after the form item. - * @param $extra - * Additional HTML to inject into the select element tag. - * @param $multiple - * Whether the user may select more than one item. - * @param $required - * Whether the user must select a value before submitting the form. - * @return - * A themed HTML string representing the form element. - * - * 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. - */ -function form_select($title, $name, $value, $options, $description = NULL, $extra = 0, $multiple = FALSE, $required = FALSE) { - $select = ''; - foreach ($options as $key => $choice) { - if (is_array($choice)) { - $select .= ''; - foreach ($choice as $key => $choice) { - $select .= ''; - } - $select .= ''; - } - else { - $select .= ''; - } - } - return theme('form_element', $title, '', $description, 'edit-'. $name, $required, _form_get_error($name)); -} - -/** - * Format a file upload field. - * - * @param $title - * The label for the file upload field. - * @param $name - * The internal name used to refer to the field. - * @param $size - * A measure of the visible size of the field (passed directly to HTML). - * @param $description - * Explanatory text to display after the form item. - * @param $required - * Whether the user must upload a file to the field. - * @return - * A themed HTML string representing the field. - * - * For assistance with handling the uploaded file correctly, see the API - * provided by file.inc. - */ -function form_file($title, $name, $size, $description = NULL, $required = FALSE) { - return theme('form_element', $title, '\n", $description, 'edit-'. $name, $required, _form_get_error($name)); -} - -/** - * Store data in a hidden form field. - * - * @param $name - * The internal name used to refer to the field. - * @param $value - * The stored data. - * @param $edit - * The array name to prefix to the $name. - * @param $attributes - * An array of HTML attributes for the input tag. - * @return - * A themed HTML string representing the hidden field. - * - * This function can be useful in retaining information between page requests, - * but be sure to validate the data on the receiving page as it is possible for - * an attacker to change the value before it is submitted. - */ -function form_hidden($name, $value, $edit = 'edit', $attributes = NULL) { - return '\n"; -} - -/** - * Format an action button. - * - * @param $value - * Both the label for the button, and the value passed to the target page - * when this button is clicked. - * @param $name - * The internal name used to refer to the button. - * @param $type - * What type to pass to the HTML input tag. - * @param $attributes - * An associative array of HTML attributes to add to the form item. - * @return - * A themed HTML string representing the button. - */ -function form_button($value, $name = 'op', $type = 'submit', $attributes = NULL) { - return '\n"; -} - -/** - * Format a form submit button. - * - * @param $value - * Both the label for the button, and the value passed to the target page - * when this button is clicked. - * @param $name - * The internal name used to refer to the button. - * @param $attributes - * An associative array of HTML attributes to add to the form item. - * @return - * A themed HTML string representing the button. - */ -function form_submit($value, $name = 'op', $attributes = NULL) { - return form_button($value, $name, 'submit', $attributes); -} - -/** - * Format a weight selection menu. - * - * @param $title - * The label for the form element. - * @param $name - * The internal name used to refer to the form element. - * @param $value - * The selected weight value at page load time. - * @param $delta - * The largest in absolute value the weight can be. For example, if set to 10, - * weights could range from -10 to 10 inclusive. - * @param $description - * Explanatory text to display after the form item. - * @param $extra - * Additional HTML to inject into the select element tag. - * @return - * A themed HTML string representing the form element. - */ -function form_weight($title = NULL, $name = 'weight', $value = 0, $delta = 10, $description = NULL, $extra = 0) { - for ($n = (-1 * $delta); $n <= $delta; $n++) { - $weights[$n] = $n; - } - - return form_select($title, $name, $value, $weights, $description, $extra); -} - -/** - * Remove invalid characters from an HTML ID attribute string - * - * @param $id - * The ID to clean - * @return - * The cleaned ID - */ -function form_clean_id($id = NULL) { - $id = str_replace('][', '-', $id); - return $id; -} - -/** - * @} End of "defgroup form". - */ - -/** * Generate an internal Drupal URL. * * @param $path @@ -1633,7 +1008,7 @@ // Apache. $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) ? 'index.php' : ''; } - + $path = drupal_get_path_alias($path); if (isset($fragment)) { @@ -1963,6 +1338,8 @@ require_once './includes/file.inc'; require_once './includes/unicode.inc'; require_once './includes/image.inc'; + require_once './includes/form.inc'; + require_once './includes/legacy.inc'; // Set the Drupal custom error handler. set_error_handler('error_handler'); // Emit the correct charset HTTP header. Index: includes/locale.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/locale.inc,v retrieving revision 1.51 diff -u -r1.51 locale.inc --- includes/locale.inc 24 Sep 2005 07:53:26 -0000 1.51 +++ includes/locale.inc 2 Oct 2005 00:38:33 -0000 @@ -36,17 +36,22 @@ * User interface for the language management screen */ function _locale_admin_manage_screen() { - $edit = &$_POST['edit']; $languages = locale_supported_languages(TRUE, TRUE); - $header = array(array('data' => t('Code')), array('data' => t('English name')), array('data' => t('Enabled')), array('data' => t('Default')), array('data' => t('Translated')), array('data' => t('Operations'))); - + $options = array(); + $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)); - + if ($status->enabled) { + $enabled[] = $key; + } + if ($status->isdefault) { + $isdefault = $key; + } if ($key == 'en') { - $rows[] = array('en', check_plain($lang), form_checkbox('', 'enabled][en', 1, $status->enabled), form_radio('', 'sitedefault', $key, $status->isdefault), message_na(), ''); + $form['name']['en'] = array(type => 'markup', value => check_plain($lang)); } else { $original = db_fetch_object(db_query("SELECT COUNT(*) AS strings FROM {locales_source}")); @@ -54,11 +59,28 @@ $ratio = ($original->strings > 0 && $translation->translation > 0) ? round(($translation->translation/$original->strings)*100., 2) : 0; - $rows[] = array(check_plain($key), ($key != 'en' ? form_textfield('', 'name]['. $key, $lang, 15, 64) : $lang), form_checkbox('', 'enabled]['. $key, 1, $status->enabled), form_radio('', 'sitedefault', $key, $status->isdefault), "$translation->translation/$original->strings ($ratio%)", ($key != 'en' ? l(t('delete'), 'admin/locale/language/delete/'. urlencode($key)) : '')); + $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%)"); } } - - return form(theme('table', $header, $rows) . form_submit(t('Save configuration')), 'post', url('admin/locale')); + $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); +} + +function theme__locale_admin_manage_screen($form) { + foreach ($form['name'] as $key => $element) { + // Don't take form control structures + if (is_array($element) && element_child($key)) { + $rows[] = array(check_plain($key), form_render($form['name'][$key]), form_render($form['enabled'][$key]), form_render($form['sitedefault'][$key]), ($key != 'en' ? form_render($form['translation'][$key]) : message_na()), ($key != 'en' ? l(t('delete'), 'admin/locale/language/delete/'. urlencode($key)) : '')); + } + } + $header = array(array('data' => t('Code')), array('data' => t('English name')), array('data' => t('Enabled')), array('data' => t('Default')), array('data' => t('Translated')), array('data' => t('Operations'))); + $output = theme('table', $header, $rows); + $output .= form_render($form); + return $output; } /** @@ -68,28 +90,30 @@ $isocodes = _locale_prepare_iso_list(); - $output = '

'. t('From language list') .'

'; - $form = form_select(t('Language name'), 'langcode', key($isocodes), $isocodes, t('Select your language here, or add it below, if you are unable to find it.')); - $form .= form_submit(t('Add language')); - $output .= form($form); + $form = array(); + $form['header'] = array(prefix => '

', value => t('Language list'), suffix => '

'); + $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']; - $output .= '

'. t('Custom language') .'

'; - $form = form_textfield(t('Language code'), 'langcode', $edit['langcode'], 60, 12, t("Commonly this is an ISO 639 language code 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 .= form_textfield(t('Language name in English'), 'langname', $edit['langname'], 60, 64, t('Name of the language. Will be available for translation in all languages.')); - $form .= form_submit(t('Add language')); - $output .= form($form); + $form = array(); + $form['header'] = array(prefix => '

', value => t('Custom language') , suffix => '

'); + $form['langcode'] = array(type => 'textfield', title => t('Language code'), default_value => $edit['langcode'], size => 12, maxlength => 60, description => t("Commonly this is an ISO 639 language code 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); return $output; } - /** * User interface for the translation import screen */ function _locale_admin_import_screen() { $languages = locale_supported_languages(FALSE, TRUE); - $languages = array_map("t", $languages['name']); + $languages = array_map('t', $languages['name']); unset($languages['en']); if (!count($languages)) { @@ -102,12 +126,15 @@ ); } - $form = form_file(t('Language file'), 'file', 50, t('A gettext Portable Object (.po) file.')); - $form .= form_select(t('Import into'), 'langcode', '', $languages, 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 .= form_radios(t('Mode'), 'mode', 'overwrite', 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 .= form_submit(t('Import')); - $output = form($form, 'post', url('admin/locale/language/import'), array('enctype' => 'multipart/form-data')); - return $output; + $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'; + + return drupal_get_form('_locale_admin_import', $form); } /** @@ -705,16 +732,18 @@ // Offer language specific export if any language is set up if (count($languages)) { $output .= '

'. t('Export translation') .'

'; - $form = form_select(t('Language name'), 'langcode', '', $languages, t('Select the language you would like to export in gettext Portable Object (.po) format.')); - $form .= form_submit(t('Export')); - $output .= form($form); + $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')); + $output .= drupal_get_form('_locale_export_po', $form); } // Complete template export of the strings $output .= '

'. t('Export template') .'

'; - $form = t('

Generate a gettext Portable Object Template (.pot) file with all the interface strings from the Drupal locale database.

'); - $form .= form_submit(t('Export')); - $output .= form($form); + $output .= t('

Generate a gettext Portable Object Template (.pot) file with all the interface strings from the Drupal locale database.

'); + $form = array(); + $form['submit'] = array(type => 'submit', value => t('Export')); + $output .= drupal_get_form('_locale_export_pot', $form); return $output; } @@ -947,20 +976,24 @@ unset($languages['name']['en']); $result = db_query('SELECT DISTINCT s.source, t.translation, t.locale FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid WHERE s.lid = %d', $lid); - $form = ''; + $form = array(); while ($translation = db_fetch_object($result)) { $orig = $translation->source; - $form .= (strlen($orig) > 40) ? form_textarea($languages['name'][$translation->locale], $translation->locale, $translation->translation, 60, 15) : form_textfield($languages['name'][$translation->locale], $translation->locale, $translation->translation, 60, 128); + $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); unset($languages['name'][$translation->locale]); } + $form = array(type => 'item', title => t('Original text'), value => wordwrap(check_plain($orig, 0))); foreach ($languages['name'] as $key => $lang) { - $form .= (strlen($orig) > 40) ? form_textarea($lang, $key, '', 60, 15) : form_textfield($lang, $key, '', 60, 128); + $form[$key] = (strlen($orig) > 40) ? +array(type => 'textarea', title => $lang, cols => 60, rows => 15) : +array(type => 'textfield', title => $lang, size => 60, maxlength => 128); } - $form = form_item(t('Original text'), wordwrap(check_plain($orig, 0))) . $form; - $form .= form_submit(t('Save translations')); + $form['submit'] = array(type => 'submit', value => t('Save translations')); - return form($form); + return $form; } /** @@ -1065,9 +1098,18 @@ } } +<<<<<<< locale.inc + if ($pager = theme('pager', NULL, 50, 0, $request)) { + $rows[] = array(array('data' => "$pager", 'colspan' => '5')); + } + if (count($rows)) { + $output .= theme('table', $header, $rows); + } +======= $output .= theme('table', $header, $rows); $output .= theme('pager', NULL, 50, 0, $request); +>>>>>>> 1.51 } return $output; @@ -1085,14 +1127,15 @@ // Present edit form preserving previous user settings $query = _locale_string_seek_query(); - $form .= form_textfield(t('Strings to search for'), 'string', $query->string, 30, 30, t('Leave blank to show all strings. The search is case sensitive.')); - $form .= form_radios(t('Language'), 'language', ($query->language ? $query->language : 'all'), array_merge(array('all' => t('All languages'), 'en' => t('English (provided by Drupal)')), $languages['name'])); - $form .= form_radios(t('Search in'), 'searchin', ($query->searchin ? $query->searchin : 'all'), array('all' => t('All strings in that language'), 'translated' => t('Only translated strings'), 'untranslated' => t('Only untranslated strings'))); + $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 .= form_submit(t('Search')); - $output = form(form_group(t('Search strings'), $form), 'post', url('admin/locale/string/search')); - - return $output; + return drupal_get_form('_locale_string_seek', $form); } // --------------------------------------------------------------------------------- Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.260 diff -u -r1.260 theme.inc --- includes/theme.inc 29 Sep 2005 08:02:55 -0000 1.260 +++ includes/theme.inc 2 Oct 2005 00:38:36 -0000 @@ -959,55 +959,6 @@ } /** - * Output a confirmation form - * - * This function outputs a complete form for confirming an action. A link is - * offered to go back to the item that is being changed in case the user changes - * his/her mind. - * - * You should use $_POST['edit'][$name] (where $name is usually 'confirm') to - * check if the confirmation was successful. - * - * @param $question - * The question to ask the user (e.g. "Are you sure you want to delete the - * block foo?"). - * @param $path - * The page to go to if the user denies the action. - * @param $description - * Additional text to display (defaults to "This action cannot be undone."). - * @param $yes - * A caption for the button which confirms the action (e.g. "Delete", - * "Replace", ...). - * @param $no - * A caption for the link which denies the action (e.g. "Cancel"). - * @param $extra - * Additional HTML to inject into the form, for example form_hidden()s. - * @param $name - * The internal name used to refer to the confirmation item. - * @return - * A themed HTML string representing the form. - */ -function theme_confirm($question, $path, $description = NULL, $yes = NULL, $no = NULL, $extra = NULL, $name = 'confirm') { - drupal_set_title($question); - - if (is_null($description)) { - $description = t('This action cannot be undone.'); - } - - $output .= '

'. $description ."

\n"; - if (!is_null($extra)) { - $output .= $extra; - } - $output .= '
'; - $output .= form_submit($yes ? $yes : t('Confirm')); - $output .= l($no ? $no : t('Cancel'), $path); - $output .= "
\n"; - - $output .= form_hidden($name, 1); - return form($output, 'post', NULL, array('class' => 'confirmation')); -} - -/** * Format a username. * * @param $object Index: includes/unicode.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/unicode.inc,v retrieving revision 1.8 diff -u -r1.8 unicode.inc --- includes/unicode.inc 1 Oct 2005 13:45:39 -0000 1.8 +++ includes/unicode.inc 2 Oct 2005 00:38:43 -0000 @@ -81,7 +81,8 @@ $options = array(UNICODE_SINGLEBYTE => t('Standard PHP: operations on Unicode strings are emulated on a best-effort basis. Install the PHP mbstring extension for improved Unicode support.', array('%url' => 'http://www.php.net/mbstring')), UNICODE_MULTIBYTE => t('Multi-byte: operations on Unicode strings are supported through the PHP mbstring extension.', array('%url' => 'http://www.php.net/mbstring')), UNICODE_ERROR => t('Invalid: the current configuration is incompatible with Drupal.')); - return form_item(t('String handling method'), $options[$status]); + $form['settings'] = array(type => 'item', title =>t('String handling method'), value => $options[$status]); + return $form; } /** @@ -474,3 +475,4 @@ } } + Index: misc/drupal.css =================================================================== RCS file: /cvs/drupal/drupal/misc/drupal.css,v retrieving revision 1.120 diff -u -r1.120 drupal.css --- misc/drupal.css 7 Sep 2005 20:56:00 -0000 1.120 +++ misc/drupal.css 2 Oct 2005 00:38:46 -0000 @@ -629,3 +629,8 @@ display: block; } +/* +** Temporary CSS for porting of drupal forms. +*/ +form { border: 3px solid red; } +form.form-api { border : 0px; } Index: modules/aggregator.module =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator.module,v retrieving revision 1.255 diff -u -r1.255 aggregator.module --- modules/aggregator.module 24 Sep 2005 07:53:26 -0000 1.255 +++ modules/aggregator.module 2 Oct 2005 00:39:01 -0000 @@ -72,12 +72,30 @@ $items = array(0 => t('none')) + drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items'); $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval'); - $output = ''; - $output .= form_textfield(t('Allowed HTML tags'), 'aggregator_allowed_html_tags', variable_get('aggregator_allowed_html_tags', '