Commit 7e1527ee authored by Dries's avatar Dries

- Patch #29465: new form API by Adrian et al.

  TODO:
  + The contact.module was broken; a new patch for contact.module is needed.
  + Documentation is needed.
  + The most important modules need to be updated ASAP.
parent 7b5b4605
Drupal x.x.x, xxxx-xx-xx (development version)
------------------------
- added free tagging support (folksonomies).
- added free tagging support.
- added a site-wide contact form.
- refactored the form API.
- theme system:
* added the PHPTemplate theme engine and removed the Xtemplate engine.
* converted the bluemarine theme from XTemplate to PHPTemplate.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -958,55 +958,6 @@ function theme_blocks($region) {
return $output;
}
/**
* 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 <em>foo</em>?").
* @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 .= '<p>'. $description ."</p>\n";
if (!is_null($extra)) {
$output .= $extra;
}
$output .= '<div class="container-inline">';
$output .= form_submit($yes ? $yes : t('Confirm'));
$output .= l($no ? $no : t('Cancel'), $path);
$output .= "</div>\n";
$output .= form_hidden($name, 1);
return form($output, 'post', NULL, array('class' => 'confirmation'));
}
/**
* Format a username.
*
......
......@@ -81,7 +81,8 @@ 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.'));
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 @@ function drupal_substr($text, $start, $length = NULL) {
}
}
......@@ -629,3 +629,8 @@ html.js fieldset.collapsed legend a {
display: block;
}
/*
** Temporary CSS for porting of drupal forms.
*/
form { border: 3px solid red; }
form.form-api { border : 0px; }
......@@ -58,4 +58,4 @@ jsUpload.prototype.oncomplete = function (data) {
// Replace form and re-attach behaviour
$(this.wrapper).innerHTML = data;
uploadAutoAttach();
}
\ No newline at end of file
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -42,7 +42,11 @@ function blog_access($op, $node) {
*/
function blog_user($type, &$edit, &$user) {
if ($type == 'view' && user_access('edit own blog', $user)) {
return array(t('History') => array('blog' => form_item(t('Blog'), l(t('view recent blog entries'), "blog/$user->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $user->name)))))));
$form['blog'] = array(
type => 'item', title => t('Blog'),
value => l(t('view recent blog entries'), "blog/$user->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $user->name))))
);
return array(t('History') => $form);
}
}
......@@ -196,7 +200,6 @@ function blog_form(&$node) {
global $nid;
$iid = $_GET['iid'];
$output = form_textfield(t('Title'), 'title', $node->title, 60, 128, NULL, NULL, TRUE);
if (empty($node->body)) {
/*
......@@ -213,16 +216,17 @@ function blog_form(&$node) {
// Note: $item->description has been validated on aggregation.
$node->body = '<a href="'. check_url($item->link) .'">'. check_plain($item->title) .'</a> - <em>'. $item->description .'</em> [<a href="'. check_url($item->flink) .'">'. check_plain($item->ftitle) ."</a>]\n";
}
}
if (function_exists('taxonomy_node_form')) {
$output .= implode('', taxonomy_node_form('blog', $node));
$form['taxonomy'] = taxonomy_node_form('blog', $node);
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
return $output;
$form['title'] = array(type => 'textfield', title => t('Title'), size => 60, maxlength => 128, required => TRUE, default_value => $node->title);
$form['body'] = array(type => 'textarea', title => t('Body'), default_value => $node->body, required => TRUE);
$form = array_merge($form, filter_form($node->format));
return $form;
}
/**
......
......@@ -42,7 +42,11 @@ function blog_access($op, $node) {
*/
function blog_user($type, &$edit, &$user) {
if ($type == 'view' && user_access('edit own blog', $user)) {
return array(t('History') => array('blog' => form_item(t('Blog'), l(t('view recent blog entries'), "blog/$user->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $user->name)))))));
$form['blog'] = array(
type => 'item', title => t('Blog'),
value => l(t('view recent blog entries'), "blog/$user->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $user->name))))
);
return array(t('History') => $form);
}
}
......@@ -196,7 +200,6 @@ function blog_form(&$node) {
global $nid;
$iid = $_GET['iid'];
$output = form_textfield(t('Title'), 'title', $node->title, 60, 128, NULL, NULL, TRUE);
if (empty($node->body)) {
/*
......@@ -213,16 +216,17 @@ function blog_form(&$node) {
// Note: $item->description has been validated on aggregation.
$node->body = '<a href="'. check_url($item->link) .'">'. check_plain($item->title) .'</a> - <em>'. $item->description .'</em> [<a href="'. check_url($item->flink) .'">'. check_plain($item->ftitle) ."</a>]\n";
}
}
if (function_exists('taxonomy_node_form')) {
$output .= implode('', taxonomy_node_form('blog', $node));
$form['taxonomy'] = taxonomy_node_form('blog', $node);
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
return $output;
$form['title'] = array(type => 'textfield', title => t('Title'), size => 60, maxlength => 128, required => TRUE, default_value => $node->title);
$form['body'] = array(type => 'textarea', title => t('Body'), default_value => $node->body, required => TRUE);
$form = array_merge($form, filter_form($node->format));
return $form;
}
/**
......
......@@ -548,10 +548,21 @@ function blogapi_blogger_title(&$contents) {
}
function blogapi_settings() {
$form['blogapi_engine'] = array(
type => 'select', title => t('XML-RPC Engine'), default_value => variable_get('blogapi_engine', 0),
options => array(0 => 'Blogger', 1 => 'MetaWeblog', 2 => 'Movabletype'),
description => t('RSD or Really-Simple-Discovery is a mechanism which allows external blogger tools to discover the APIs they can use to interact with Drupal. Here you can set the preferred method for blogger tools to interact with your site. The common XML-RPC engines are Blogger, MetaWeblog and Movabletype. If you are not sure which is the correct setting, choose Blogger.')
);
$node_types = node_get_types();
$defaults = isset($node_types['blog']) ? array('blog') : array();
$output .= form_checkboxes(t('Blog types'), "blogapi_node_types", variable_get('blogapi_node_types', $defaults), $node_types, t('Select the content types for which you wish to enable posting via blogapi. Each type will appear as a different "blog" in the client application (if supported).'), 0, 1);
return $output;
$form['blogapi_node_types'] = array(
type => 'checkboxes', title => t('Blog types'), required => TRUE,
default_value => variable_get('blogapi_node_types', $defaults), options => $node_types,
description => t('Select the content types for which you wish to enable posting via blogapi. Each type will appear as a different "blog" in the client application (if supported).')
);
return $form;
}
function blogapi_menu($may_cache) {
......
......@@ -548,10 +548,21 @@ function blogapi_blogger_title(&$contents) {
}
function blogapi_settings() {
$form['blogapi_engine'] = array(
type => 'select', title => t('XML-RPC Engine'), default_value => variable_get('blogapi_engine', 0),
options => array(0 => 'Blogger', 1 => 'MetaWeblog', 2 => 'Movabletype'),
description => t('RSD or Really-Simple-Discovery is a mechanism which allows external blogger tools to discover the APIs they can use to interact with Drupal. Here you can set the preferred method for blogger tools to interact with your site. The common XML-RPC engines are Blogger, MetaWeblog and Movabletype. If you are not sure which is the correct setting, choose Blogger.')
);
$node_types = node_get_types();
$defaults = isset($node_types['blog']) ? array('blog') : array();
$output .= form_checkboxes(t('Blog types'), "blogapi_node_types", variable_get('blogapi_node_types', $defaults), $node_types, t('Select the content types for which you wish to enable posting via blogapi. Each type will appear as a different "blog" in the client application (if supported).'), 0, 1);
return $output;
$form['blogapi_node_types'] = array(
type => 'checkboxes', title => t('Blog types'), required => TRUE,
default_value => variable_get('blogapi_node_types', $defaults), options => $node_types,
description => t('Select the content types for which you wish to enable posting via blogapi. Each type will appear as a different "blog" in the client application (if supported).')
);
return $form;
}
function blogapi_menu($may_cache) {
......
......@@ -233,28 +233,39 @@ function book_validate(&$node) {
* Implementation of hook_form().
*/
function book_form(&$node) {
$output = form_textfield(t('Title'), 'title', $node->title, 60, 128, NULL, NULL, TRUE);
$output .= form_select(t('Parent'), 'parent', ($node->parent ? $node->parent : arg(4)), book_toc($node->nid), t('The parent that this page belongs in. Note that pages whose parent is &lt;top-level&gt; are regarded as independent, top-level books.'));
$form['parent'] = array(
type => 'select', title => t('Parent'), default_value => ($node->parent ? $node->parent : arg(4)), options => book_toc($node->nid), weight => -15,
description => t('The parent that this page belongs in. Note that pages whose parent is &lt;top-level&gt; are regarded as independent, top-level books.')
);
if (function_exists('taxonomy_node_form')) {
$output .= implode('', taxonomy_node_form('book', $node));
$form['taxonomy'] = taxonomy_node_form('book', $node);
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
$form['title'] = array(type => 'textfield', title => t('Title'), size => 60, maxlength => 128, required => TRUE, default_value => $node->title);
$form['body'] = array(
type => 'textarea', title => t('Body'), default_value => $node->body, required => TRUE
);
$form = array_merge($form, filter_form($node->format));
$output .= form_textarea(t('Log message'), 'log', $node->log, 60, 5, t('An explanation of the additions or updates being made to help other authors understand your motivations.'));
$form['log'] = array(
type => 'textarea', title => t('Log message'), default_value => $node->log, rows => 5, weight => 19,
description => t('An explanation of the additions or updates being made to help other authors understand your motivations.')
);
if (user_access('administer nodes')) {
$output .= form_weight(t('Weight'), 'weight', $node->weight, 15, t('Pages at a given level are ordered first by weight and then by title.'));
$form['weight'] = array(
type => 'weight', title => t('Weight'), default_value => $node->weight, delta => 15, weight => -14,
description => t('Pages at a given level are ordered first by weight and then by title.')
);
}
else {
// If a regular user updates a book page, we create a new revision
// authored by that user:
$output .= form_hidden('revision', 1);
$form['revision'] = array(type => 'hidden', value => 1);
}
return $output;
return $form;
}
/**
......@@ -291,21 +302,32 @@ function book_outline() {
default:
$page = db_fetch_object(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid));
$output = form_select(t('Parent'), 'parent', $page->parent, book_toc($node->nid), t('The parent page in the book.'));
$output .= form_weight(t('Weight'), 'weight', $page->weight, 15, t('Pages at a given level are ordered first by weight and then by title.'));
$output .= form_textarea(t('Log message'), 'log', $node->log, 60, 5, t('An explanation to help other authors understand your motivations to put this post into the book.'));
$form['parent'] = array(
type => 'select', title => t('Parent'), default_value => $page->parent,
options => book_toc($node->nid), description => t('The parent page in the book.')
);
$form['weight'] = array(
type => 'weight', title => t('Weight'), default_value => $page->weight, delta => 15,
description => t('Pages at a given level are ordered first by weight and then by title.')
);
$form['log'] = array(
type => 'textarea', title => t('Log message'), cols => 60, rows => 5,
default_value => $node->log, description => t('An explanation to help other authors understand your motivations to put this post into the book.')
);
if ($page->nid) {
$output .= form_submit(t('Update book outline'));
$output .= form_submit(t('Remove from book outline'));
$form['update'] = array(type => 'submit', value => t('Update book outline'));
$form['remove'] = array(type => 'submit', value => t('Remove from book outline'));
}
else {
$output .= form_submit(t('Add to book outline'));
$form['add'] = array(type => 'submit', value => t('Add to book outline'));
}
drupal_set_title(check_plain($node->title));
return form($output);
return drupal_get_form('book_outline', $form);
}
}
}
......@@ -933,7 +955,19 @@ function book_node_visitor_opml_post($node, $depth) {
* Creates a row for the 'admin' view of a book. Each row represents a page in the book, in the tree representing the book
*/
function book_admin_edit_line($node, $depth = 0) {
return array('<div style="padding-left: '. (25 * $depth) .'px;">'. form_textfield(NULL, $node->nid .'][title', $node->title, 60, 255) .'</div>', form_weight(NULL, $node->nid .'][weight', $node->weight, 15), l(t('view'), 'node/'. $node->nid), l(t('edit'), 'node/'. $node->nid .'/edit'), l(t('delete'), 'node/'.$node->nid.'/delete'));
$form[tree] = TRUE;
$form[$node->nid]['title'] = array(type => 'textfield', default_value => $node->title, size => 60, maxlength => 255);
$form[$node->nid]['weight'] = array(type => 'weight', default_value => $node->weight, delta => 15);
$form['depth'] = array(value => $depth);
$form['nid'] = array(value => $node->nid);
return drupal_get_form('book_admin_edit_line', $form);
}
function theme_book_admin_edit_line($form) {
$nid = $form['nid'][value];
return array(
'<div style="padding-left: '. (25 * $form['depth'][value]) .'px;">'. form_render($form[$nid]['title']) .'</div>', form_render($form[$nid]['weight']), l(t('view'), 'node/'. $nid), l(t('edit'), 'node/'. $nid .'/edit'), l(t('delete'), 'node/'.$nid.'/delete')
);
}
function book_admin_edit_book($nid, $depth = 1) {
......@@ -956,15 +990,15 @@ function book_admin_edit_book($nid, $depth = 1) {
function book_admin_edit($nid, $depth = 0) {
$node = node_load($nid);
if ($node->nid) {
drupal_set_title(check_plain($node->title));
$header = array(t('Title'), t('Weight'), array('data' => t('Operations'), 'colspan' => '3'));
$rows[] = book_admin_edit_line($node);
$rows = array_merge($rows, book_admin_edit_book($nid));
$output .= theme('table', $header, $rows);
$output .= form_submit(t('Save book pages'));
$form['save'] = array(type => 'submit', value => t('Save book pages'));
drupal_set_title(check_plain($node->title));
return form($output);
return theme('table', $header, $rows) . $form;
}
else {
drupal_not_found();
......
......@@ -233,28 +233,39 @@ function book_validate(&$node) {
* Implementation of hook_form().
*/
function book_form(&$node) {
$output = form_textfield(t('Title'), 'title', $node->title, 60, 128, NULL, NULL, TRUE);
$output .= form_select(t('Parent'), 'parent', ($node->parent ? $node->parent : arg(4)), book_toc($node->nid), t('The parent that this page belongs in. Note that pages whose parent is &lt;top-level&gt; are regarded as independent, top-level books.'));
$form['parent'] = array(
type => 'select', title => t('Parent'), default_value => ($node->parent ? $node->parent : arg(4)), options => book_toc($node->nid), weight => -15,
description => t('The parent that this page belongs in. Note that pages whose parent is &lt;top-level&gt; are regarded as independent, top-level books.')
);
if (function_exists('taxonomy_node_form')) {
$output .= implode('', taxonomy_node_form('book', $node));
$form['taxonomy'] = taxonomy_node_form('book', $node);
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
$form['title'] = array(type => 'textfield', title => t('Title'), size => 60, maxlength => 128, required => TRUE, default_value => $node->title);
$form['body'] = array(
type => 'textarea', title => t('Body'), default_value => $node->body, required => TRUE
);
$form = array_merge($form, filter_form($node->format));
$output .= form_textarea(t('Log message'), 'log', $node->log, 60, 5, t('An explanation of the additions or updates being made to help other authors understand your motivations.'));
$form['log'] = array(
type => 'textarea', title => t('Log message'), default_value => $node->log, rows => 5, weight => 19,
description => t('An explanation of the additions or updates being made to help other authors understand your motivations.')
);
if (user_access('administer nodes')) {
$output .= form_weight(t('Weight'), 'weight', $node->weight, 15, t('Pages at a given level are ordered first by weight and then by title.'));
$form['weight'] = array(
type => 'weight', title => t('Weight'), default_value => $node->weight, delta => 15, weight => -14,
description => t('Pages at a given level are ordered first by weight and then by title.')
);
}
else {
// If a regular user updates a book page, we create a new revision
// authored by that user:
$output .= form_hidden('revision', 1);
$form['revision'] = array(type => 'hidden', value => 1);
}
return $output;
return $form;
}
/**
......@@ -291,21 +302,32 @@ function book_outline() {
default:
$page = db_fetch_object(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid));
$output = form_select(t('Parent'), 'parent', $page->parent, book_toc($node->nid), t('The parent page in the book.'));
$output .= form_weight(t('Weight'), 'weight', $page->weight, 15, t('Pages at a given level are ordered first by weight and then by title.'));
$output .= form_textarea(t('Log message'), 'log', $node->log, 60, 5, t('An explanation to help other authors understand your motivations to put this post into the book.'));
$form['parent'] = array(
type => 'select', title => t('Parent'), default_value => $page->parent,
options => book_toc($node->nid), description => t('The parent page in the book.')
);
$form['weight'] = array(
type => 'weight', title => t('Weight'), default_value => $page->weight, delta => 15,
description => t('Pages at a given level are ordered first by weight and then by title.')
);
$form['log'] = array(
type => 'textarea', title => t('Log message'), cols => 60, rows => 5,
default_value => $node->log, description => t('An explanation to help other authors understand your motivations to put this post into the book.')
);
if ($page->nid) {
$output .= form_submit(t('Update book outline'));
$output .= form_submit(t('Remove from book outline'));
$form['update'] = array(type => 'submit', value => t('Update book outline'));
$form['remove'] = array(type => 'submit', value => t('Remove from book outline'));
}
else {
$output .= form_submit(t('Add to book outline'));
$form['add'] = array(type => 'submit', value => t('Add to book outline'));
}
drupal_set_title(check_plain($node->title));
return form($output);
return drupal_get_form('book_outline', $form);
}
}
}
......@@ -933,7 +955,19 @@ function book_node_visitor_opml_post($node, $depth) {
* Creates a row for the 'admin' view of a book. Each row represents a page in the book, in the tree representing the book
*/
function book_admin_edit_line($node, $depth = 0) {
return array('<div style="padding-left: '. (25 * $depth) .'px;">'. form_textfield(NULL, $node->nid .'][title', $node->title, 60, 255) .'</div>', form_weight(NULL, $node->nid .'][weight', $node->weight, 15), l(t('view'), 'node/'. $node->nid), l(t('edit'), 'node/'. $node->nid .'/edit'), l(t('delete'), 'node/'.$node->nid.'/delete'));
$form[tree] = TRUE;
$form[$node->nid]['title'] = array(type => 'textfield', default_value => $node->title, size => 60, maxlength => 255);
$form[$node->nid]['weight'] = array(type => 'weight', default_value => $node->weight, delta => 15);
$form['depth'] = array(value => $depth);
$form['nid'] = array(value => $node->nid);
return drupal_get_form('book_admin_edit_line', $form);
}
function theme_book_admin_edit_line($form) {
$nid = $form['nid'][value];
return array(
'<div style="padding-left: '. (25 * $form['depth'][value]) .'px;">'. form_render($form[$nid]['title']) .'</div>', form_render($form[$nid]['weight']), l(t('view'), 'node/'. $nid), l(t('edit'), 'node/'. $nid .'/edit'), l(t('delete'), 'node/'.$nid.'/delete')
);
}
function book_admin_edit_book($nid, $depth = 1) {
......@@ -956,15 +990,15 @@ function book_admin_edit_book($nid, $depth = 1) {
function book_admin_edit($nid, $depth = 0) {
$node = node_load($nid);
if ($node->nid) {
drupal_set_title(check_plain($node->title));
$header = array(t('Title'), t('Weight'), array('data' => t('Operations'), 'colspan' => '3'));
$rows[] = book_admin_edit_line($node);
$rows = array_merge($rows, book_admin_edit_book($nid));
$output .= theme('table', $header, $rows);
$output .= form_submit(t('Save book pages'));
$form['save'] = array(type => 'submit', value => t('Save book pages'));
drupal_set_title(check_plain($node->title));
return form($output);
return theme('table', $header, $rows) . $form;
}
else {
drupal_not_found();
......
This diff is collapsed.
This diff is collapsed.
......@@ -33,19 +33,28 @@ function drupal_help($section) {
*/
function drupal_settings() {
// Check if all required fields are present for the Drupal directory
if ((variable_get('site_name', 'drupal') == 'drupal') || (variable_get('site_name', 'drupal') == ''))
if ((variable_get('site_name', 'drupal') == 'drupal') || (variable_get('site_name', 'drupal') == '')) {
form_set_error('drupal_directory', t('You must set the name of your site on the <a href="%url">administer &raquo; settings</a> page.', array('%url' => url('admin/settings'))));
else if (variable_get('site_mail', ini_get('sendmail_from')) == '')
}
else if (variable_get('site_mail', ini_get('sendmail_from')) == '') {
form_set_error('drupal_directory', t('You must set an e-mail address for your site on the <a href="%url">administer &raquo; settings</a> page.', array('%url' => url('admin/settings'))));
else if (variable_get('site_slogan', '') == '')
}
else if (variable_get('site_slogan', '') == '') {
form_set_error('drupal_directory', t('You must set your site slogan on the <a href="%url">administer &raquo; settings</a> page.', array('%url' => url('admin/settings'))));
else if (variable_get('site_mission', '') == '')
}
else if (variable_get('site_mission', '') == '') {
form_set_error('drupal_directory', t('You must set your site mission on the <a href="%url">administer &raquo; settings</a> page.' , array('%url' => url('admin/settings'))));
}
$form['drupal_server'] = array(type => 'textfield', title => t('Drupal XML-RPC server'), default_value => variable_get('drupal_server', 'http://www.drupal.org/xmlrpc.php'), size => 60, maxlength => 128, description => t('The URL of your root Drupal XML-RPC server.'));
$output = form_textfield(t('Drupal XML-RPC server'), 'drupal_server', variable_get('drupal_server', 'http://www.drupal.org/xmlrpc.php'), 60, 128, t('The URL of your root Drupal XML-RPC server.'));
$output .= form_radios(t('Drupal directory'), 'drupal_directory', variable_get('drupal_directory', 0), array(t('Disabled'), t('Enabled')), t("If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you must set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"%drupal-xml-rpc\", your web site will get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Requires the cron feature to be enabled.", array("%drupal-xml-rpc" => "http://www.drupal.org/xmlrpc.php", "%drupal-sites" => "http://www.drupal.org/drupal-sites/")));
$form['drupal_directory'] = array(
type => 'radios', title => t('Drupal directory'), default_value => variable_get('drupal_directory', 0),
options => array(t('Disabled'), t('Enabled')),
description => t("If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you must set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"%drupal-xml-rpc\", your web site will get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Requires the cron feature to be enabled.", array("%drupal-xml-rpc" => "http://www.drupal.org/xmlrpc.php", "%drupal-sites" => "http://www.drupal.org/drupal-sites/"))
);
return $output;
return $form;
}
/**
......
......@@ -33,19 +33,28 @@ function drupal_help($section) {
*/
function drupal_settings() {
// Check if all required fields are present for the Drupal directory
if ((variable_get('site_name', 'drupal') == 'drupal') || (variable_get('site_name', 'drupal') == ''))
if ((variable_get('site_name', 'drupal') == 'drupal') || (variable_get('site_name', 'drupal') == '')) {
form_set_error('drupal_directory', t('You must set the name of your site on the <a href="%url">administer &raquo; settings</a> page.', array('%url' => url('admin/settings'))));
else if (variable_get('site_mail', ini_get('sendmail_from')) == '')
}
else if (variable_get('site_mail', ini_get('sendmail_from')) == '') {
form_set_error('drupal_directory', t('You must set an e-mail address for your site on the <a href="%url">administer &raquo; settings</a> page.', array('%url' => url('admin/settings'))));
else if (variable_get('site_slogan', '') == '')
}
else if (variable_get('site_slogan', '') == '') {
form_set_error('drupal_directory', t('You must set your site slogan on the <a href="%url">administer &raquo; settings</a> page.', array('%url' => url('admin/settings'))));
else if (variable_get('site_mission', '') == '')
}
else if (variable_get('site_mission', '') == '') {
form_set_error('drupal_directory', t('You must set your site mission on the <a href="%url">administer &raquo; settings</a> page.' , array('%url' => url('admin/settings'))));
}
$form['drupal_server'] = array(type => 'textfield', title => t('Drupal XML-RPC server'), default_value => variable_get('drupal_server', 'http://www.drupal.org/xmlrpc.php'), size => 60, maxlength => 128, description => t('The URL of your root Drupal XML-RPC server.'));
$output = form_textfield(t('Drupal XML-RPC server'), 'drupal_server', variable_get('drupal_server', 'http://www.drupal.org/xmlrpc.php'), 60, 128, t('The URL of your root Drupal XML-RPC server.'));
$output .= form_radios(t('Drupal directory'), 'drupal_directory', variable_get('drupal_directory', 0), array(t('Disabled'), t('Enabled')), t("If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you must set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"%drupal-xml-rpc\", your web site will get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Requires the cron feature to be enabled.", array("%drupal-xml-rpc" => "http://www.drupal.org/xmlrpc.php", "%drupal-sites" => "http://www.drupal.org/drupal-sites/")));
$form['drupal_directory'] = array(
type => 'radios', title => t('Drupal directory'), default_value => variable_get('drupal_directory', 0),
options => array(t('Disabled'), t('Enabled')),
description => t("If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you must set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"%drupal-xml-rpc\", your web site will get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Requires the cron feature to be enabled.", array("%drupal-xml-rpc" => "http://www.drupal.org/xmlrpc.php", "%drupal-sites" => "http://www.drupal.org/drupal-sites/"))
);
return $output;
return $form;
}
/**
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -74,18 +74,25 @@ function page_validate(&$node) {
* Implementation of hook_form().
*/
function page_form(&$node) {
$output = form_textfield(t('Title'), 'title', $node->title, 60, 128, NULL, NULL, TRUE);
$form['title'] = array(type => 'textfield', title => t('Title'), size => 60, maxlength => 128, required => TRUE, default_value => $node->title);
if (function_exists('taxonomy_node_form')) {
$output .= implode('', taxonomy_node_form('page', $node));
$form['taxonomy'] = taxonomy_node_form('page', $node);
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
$form['body'] = array(
type => 'textarea', title => t('Body'), default_value => $node->body, required => TRUE
);
$form = array_merge($form, filter_form($node->format));
$output .= form_textarea(t('Log message'), 'log', $node->log, 60, 5, t('An explanation of the additions or updates being made to help other authors understand your motivations.'));
return $output;
$form['log'] = array(
type => 'textarea', title => t('Log message'), default_value => $node->log, rows => 5,
description => t('An explanation of the additions or updates being made to help other authors understand your motivations.')
);
return $form;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.