Commit f7440d4d authored by Steven Wittens's avatar Steven Wittens

#130971: Kitchen sink (E_NOTICE compliance / Code style / Bugfix in book toc)

parent f2ca2907
......@@ -355,7 +355,9 @@ function drupal_get_filename($type, $name, $filename = NULL) {
}
}
if (isset($files[$type][$name])) {
return $files[$type][$name];
}
}
/**
......
......@@ -351,6 +351,7 @@ function drupal_not_found() {
if (empty($return)) {
drupal_set_title(t('Page not found'));
$return = '';
}
// To conserve CPU and bandwidth, omit the blocks
print theme('page', $return, FALSE);
......@@ -871,6 +872,7 @@ function format_rss_item($title, $link, $description, $args = array()) {
* with the same format as $array itself for nesting.
*/
function format_xml_elements($array) {
$output = '';
foreach ($array as $key => $value) {
if (is_numeric($key)) {
if ($value['key']) {
......@@ -1972,7 +1974,12 @@ function drupal_mail($mailkey, $to, $subject, $body, $from = NULL, $headers = ar
// Bundle up the variables into a structured array for altering.
$message = array('#mail_id' => $mailkey, '#to' => $to, '#subject' => $subject, '#body' => $body, '#from' => $from, '#headers' => $headers);
drupal_alter('mail', $message);
list($mailkey, $to, $subject, $body, $from, $headers) = $message;
$mailkey = $message['#mail_id'];
$to = $message['#to'];
$subject = $message['#subject'];
$body = $message['#body'];
$from = $message['#from'];
$headers = $message['#headers'];
// Allow for custom mail backend
if (variable_get('smtp_library', '') && file_exists(variable_get('smtp_library', ''))) {
......
......@@ -382,7 +382,7 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) {
@chmod($dest, 0664);
}
if (is_object($file)) {
if (isset($file) && is_object($file)) {
$file->filename = $basename;
$file->filepath = $dest;
$source = $file;
......
......@@ -319,7 +319,7 @@ function drupal_prepare_form($form_id, &$form) {
$form['form_token'] = array('#type' => 'token', '#default_value' => drupal_get_token($form['#token']));
}
}
else if ($user->uid && !$form['#programmed']) {
else if (isset($user->uid) && $user->uid && !$form['#programmed']) {
$form['#token'] = $form_id;
$form['form_token'] = array(
'#id' => form_clean_id('edit-'. $form_id .'-form-token'),
......@@ -1263,7 +1263,14 @@ function expand_radios($element) {
if (count($element['#options']) > 0) {
foreach ($element['#options'] as $key => $choice) {
if (!isset($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' => isset($element['#default_value']) ? $element['#default_value'] : NULL,
'#attributes' => $element['#attributes'],
'#parents' => $element['#parents'],
);
}
}
}
......
......@@ -204,7 +204,7 @@ function drupal_rewrite_settings($settings = array(), $prefix = '') {
// Write new value to settings.php in the following format:
// $'setting' = 'value'; // 'comment'
$setting = $settings[$variable[1]];
$buffer .= '$'. $variable[1] ." = '". $setting['value'] ."';". ($setting['comment'] ? ' // '. $setting['comment'] ."\n" : "\n");
$buffer .= '$'. $variable[1] ." = '". $setting['value'] ."';". (!empty($setting['comment']) ? ' // '. $setting['comment'] ."\n" : "\n");
unset($settings[$variable[1]]);
}
else {
......
......@@ -1301,7 +1301,7 @@ function _locale_import_parse_quoted($string) {
*/
function _locale_export_po($language) {
global $user;
$header = '';
// Get language specific strings, or all strings
if ($language) {
$meta = db_fetch_object(db_query("SELECT * FROM {languages} WHERE language = '%s'", $language));
......
......@@ -632,7 +632,8 @@ function menu_rebuild() {
$item = &$menu[$path];
$number_parts = $item['_number_parts'];
if (isset($item['parent'])) {
$parent_parts = explode('/', $menu_path_map[$item['parent']], 6);
$item['parent'] = $menu_path_map[$item['parent']];
$parent_parts = explode('/', $item['parent'], 6);
$slashes = count($parent_parts) - 1;
}
else {
......@@ -723,7 +724,7 @@ function menu_rebuild() {
$item['parent'] = implode('/', array_slice($item['_parts'], 0, $item['_number_parts'] - 1));
}
else {
$item['_depth'] = $item['parent'] ? $menu[$menu_path_map[$item['parent']]]['_depth'] + 1 : 1;
$item['_depth'] = $item['parent'] ? $menu[$item['parent']]['_depth'] + 1 : 1;
}
}
else {
......
......@@ -70,11 +70,11 @@ function sess_write($key, $value) {
// session table rows without breaking throttle module and "Who's Online"
// block.
if ($user->uid || $value || count($_COOKIE)) {
db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, $user->cache, $_SERVER["REMOTE_ADDR"], $value, time());
db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, isset($user->cache) ? $user->cache : '', $_SERVER["REMOTE_ADDR"], $value, time());
}
}
else {
db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, $user->cache, $_SERVER["REMOTE_ADDR"], $value, time(), $key);
db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, isset($user->cache) ? $user->cache : '', $_SERVER["REMOTE_ADDR"], $value, time(), $key);
// TODO: this can be an expensive query. Perhaps only execute it every x minutes. Requires investigation into cache expiration.
if ($user->uid) {
......
......@@ -611,7 +611,7 @@ function theme_links($links, $attributes = array('class' => 'links')) {
// Pass in $link as $options, they share the same keys.
$output .= l($link['title'], $link['href'], $link);
}
else if ($link['title']) {
else if (!empty($link['title'])) {
// Some links are actually not links, but we wrap these in <span> for adding title and class attributes
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
......@@ -810,6 +810,9 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) {
}
$output .= " </tr></thead>\n";
}
else {
$ts = array();
}
// Format the table rows:
$output .= "<tbody>\n";
......
......@@ -310,7 +310,7 @@ function aggregator_block($op = 'list', $delta = 0, $edit = array()) {
/**
* Generate a form to add/edit/delete aggregator categories.
*/
function aggregator_form_category($edit = array()) {
function aggregator_form_category($edit = array('title' => '', 'description' => '', 'cid' => NULL)) {
$form['title'] = array('#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $edit['title'],
......@@ -392,13 +392,13 @@ function aggregator_form_category_submit($form_id, $form_values) {
* Add/edit/delete aggregator categories.
*/
function aggregator_save_category($edit) {
if ($edit['cid'] && $edit['title']) {
if (!empty($edit['cid']) && !empty($edit['title'])) {
db_query("UPDATE {aggregator_category} SET title = '%s', description = '%s' WHERE cid = %d", $edit['title'], $edit['description'], $edit['cid']);
}
else if ($edit['cid']) {
else if (!empty($edit['cid'])) {
db_query('DELETE FROM {aggregator_category} WHERE cid = %d', $edit['cid']);
}
else if ($edit['title']) {
else if (!empty($edit['title'])) {
// A single unique id for bundles and feeds, to use in blocks
$next_id = db_next_id('{aggregator_category}_cid');
db_query("INSERT INTO {aggregator_category} (cid, title, description, block) VALUES (%d, '%s', '%s', 5)", $next_id, $edit['title'], $edit['description']);
......@@ -408,7 +408,7 @@ function aggregator_save_category($edit) {
/**
* Generate a form to add/edit feed sources.
*/
function aggregator_form_feed($edit = array()) {
function aggregator_form_feed($edit = array('refresh' => 900, 'title' => '', 'url' => '', 'fid' => NULL)) {
$period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
if ($edit['refresh'] == '') {
......@@ -568,7 +568,7 @@ function aggregator_remove($feed) {
while ($item = db_fetch_object($result)) {
$items[] = "iid = $item->iid";
}
if ($items) {
if (!empty($items)) {
db_query('DELETE FROM {aggregator_category_item} WHERE '. implode(' OR ', $items));
}
db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $feed['fid']);
......@@ -677,6 +677,7 @@ function aggregator_element_data($parser, $data) {
// it or its contents will end up in the item array.
break;
default:
$channel += array($tag => '');
$channel[$tag] .= $data;
}
}
......
......@@ -191,6 +191,10 @@ function _block_rehash() {
// Reinsert new set of blocks into table.
foreach ($blocks as $block) {
$block += array(
'visibility' => NULL,
'throttle' => NULL,
);
db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, throttle, title) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d, '%s')", $block['module'], $block['delta'], $theme_key, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle'], $block['title']);
}
db_unlock_tables();
......@@ -238,7 +242,7 @@ function block_admin_display($theme = NULL) {
);
if ($throttle) {
$form[$i]['throttle'] = array('#type' => 'checkbox', '#default_value' => $block['throttle']);
$form[$i]['throttle'] = array('#type' => 'checkbox', '#default_value' => isset($block['throttle']) ? $block['throttle'] : FALSE);
}
$form[$i]['configure'] = array('#value' => l(t('configure'), 'admin/build/block/configure/'. $block['module'] .'/'. $block['delta']));
if ($block['module'] == 'block') {
......@@ -567,6 +571,10 @@ function block_box_delete_submit($form_id, $form_values) {
* Define the custom block form.
*/
function block_box_form($edit = array()) {
$edit += array(
'info' => '',
'body' => '',
);
$form['info'] = array(
'#type' => 'textfield',
'#title' => t('Block description'),
......
......@@ -133,7 +133,7 @@ function blog_page_user($uid) {
$account = user_load(array((is_numeric($uid) ? 'uid' : 'name') => $uid, 'status' => 1));
if ($account->uid) {
if (!empty($account->uid)) {
drupal_set_title($title = t("@name's blog", array('@name' => $account->name)));
if (($account->uid == $user->uid) && user_access('edit own blog')) {
......
......@@ -196,14 +196,14 @@ function book_submit(&$node) {
*/
function book_form(&$node) {
$type = node_get_types('type', $node);
if ($node->nid && !$node->parent && !user_access('create new books')) {
if (!empty($node->nid) && !$node->parent && !user_access('create new books')) {
$form['parent'] = array('#type' => 'value', '#value' => $node->parent);
}
else {
$form['parent'] = array('#type' => 'select',
'#title' => t('Parent'),
'#default_value' => ($node->parent ? $node->parent : arg(4)),
'#options' => book_toc($node->nid),
'#default_value' => (isset($node->parent) ? $node->parent : arg(4)),
'#options' => book_toc(isset($node->nid) ? $node->nid : 0),
'#weight' => -4,
'#description' => user_access('create new books') ? t('The parent section in which to place this page. Note that each page whose parent is &lt;top-level&gt; is an independent, top-level book.') : t('The parent that this page belongs in.'),
);
......@@ -226,7 +226,7 @@ function book_form(&$node) {
if (user_access('administer nodes')) {
$form['weight'] = array('#type' => 'weight',
'#title' => t('Weight'),
'#default_value' => $node->weight,
'#default_value' => isset($node->weight) ? $node->weight : 0,
'#delta' => 15,
'#weight' => 5,
'#description' => t('Pages at a given level are ordered first by weight and then by title.'),
......@@ -251,13 +251,13 @@ function book_form(&$node) {
function book_outline($node) {
$form['parent'] = array('#type' => 'select',
'#title' => t('Parent'),
'#default_value' => $node->parent,
'#default_value' => isset($node->parent) ? $node->parent : 0,
'#options' => book_toc($node->nid),
'#description' => t('The parent page in the book.'),
);
$form['weight'] = array('#type' => 'weight',
'#title' => t('Weight'),
'#default_value' => $node->weight,
'#default_value' => isset($node->weight) ? $node->weight : 0,
'#delta' => 15,
'#description' => t('Pages at a given level are ordered first by weight and then by title.'),
);
......@@ -266,7 +266,7 @@ function book_outline($node) {
'#description' => t('An explanation to help other authors understand your motivations to put this post into the book.'),
);
$form['nid'] = array('#type' => 'value', '#value' => $nid);
$form['nid'] = array('#type' => 'value', '#value' => isset($node->nid) ? $node->nid : 0);
if (isset($node->parent)) {
$form['update'] = array('#type' => 'submit',
'#value' => t('Update book outline'),
......
......@@ -145,7 +145,7 @@ function theme_color_scheme_form($form) {
$info = $form['info']['#value'];
$path = drupal_get_path('theme', $theme) .'/';
drupal_add_css($path . $info['preview_css']);
$output = '';
// Wrapper
$output .= '<div class="color-form clear-block">';
......
......@@ -384,7 +384,7 @@ function comment_form_alter($form, $form_id) {
'#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'),
);
}
elseif (isset($form['type'])) {
elseif (isset($form['type']) && isset($form['#node'])) {
if ($form['type']['#value'] .'_node_form' == $form_id) {
$node = $form['#node'];
$form['comment_settings'] = array(
......@@ -1535,7 +1535,23 @@ function comment_form($edit, $title = NULL) {
$form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => !empty($edit['subject']) ? $edit['subject'] : '');
}
$form['comment_filter']['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => !empty($edit['comment']) ? $edit['comment'] : $user->signature, '#required' => TRUE);
if (!empty($edit['comment'])) {
$default = $edit['comment'];
}
elseif (isset($user->signature)) {
$default = $user->signature;
}
else {
$default = '';
}
$form['comment_filter']['comment'] = array(
'#type' => 'textarea',
'#title' => t('Comment'),
'#rows' => 15,
'#default_value' => $default,
'#required' => TRUE,
);
if (!isset($edit['format'])) {
$edit['format'] = FILTER_FORMAT_DEFAULT;
}
......
......@@ -98,7 +98,15 @@ function contact_menu() {
function _contact_user_tab_access($account) {
global $user;
return $account && (($user->uid != $account->uid && $account->contact) || user_access('administer users'));
if (!isset($account->contact)) {
$account->contact = FALSE;
}
return
$account &&
(
($user->uid != $account->uid && $account->contact) ||
user_access('administer users')
);
}
/**
......@@ -121,7 +129,7 @@ function contact_user($type, &$edit, &$user, $category = NULL) {
return $form;
}
elseif ($type == 'validate') {
return array('contact' => $edit['contact']);
return array('contact' => isset($edit['contact']) ? $edit['contact'] : FALSE);
}
elseif ($type == 'insert') {
$edit['contact'] = variable_get('contact_default_status', 1);
......@@ -149,6 +157,16 @@ function contact_admin_edit($cid = NULL) {
if (arg(3) == "edit" && $cid > 0) {
$edit = db_fetch_array(db_query("SELECT * FROM {contact} WHERE cid = %d", $cid));
}
else {
$edit = array(
'category' => '',
'recipients' => '',
'reply' => '',
'weight' => 0,
'selected' => 0,
'cid' => NULL,
);
}
$form['category'] = array('#type' => 'textfield',
'#title' => t('Category'),
'#maxlength' => 255,
......
......@@ -210,7 +210,7 @@ function forum_admin_settings() {
function forum_form_alter(&$form, $form_id) {
// hide critical options from forum vocabulary
if ($form_id == 'taxonomy_form_vocabulary') {
if ($form['vid']['#value'] == _forum_get_vid()) {
if (isset($form['vid']) && $form['vid']['#value'] == _forum_get_vid()) {
$form['help_forum_vocab'] = array(
'#value' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'),
'#weight' => -1,
......@@ -280,16 +280,14 @@ function forum_block($op = 'list', $delta = 0, $edit = array()) {
break;
}
if ($content) {
if (!empty($content)) {
$content .= '<div class="more-link">'. l(t('more'), 'forum', array('title' => t('Read the latest forum topics.'))) .'</div>';
}
$block['subject'] = $title;
$block['content'] = $content;
return $block;
}
}
}
}
/**
......@@ -439,6 +437,12 @@ function forum_delete(&$node) {
* @param $edit Associative array containing a container term to be added or edited.
*/
function forum_form_container($edit = array()) {
$edit += array(
'name' => '',
'description' => '',
'tid' => 0,
'weight' => 0,
);
// Handle a delete operation.
$form['name'] = array(
'#title' => t('Container name'),
......@@ -481,7 +485,7 @@ function forum_form_container($edit = array()) {
}
function forum_form_main($type, $edit = array()) {
if ($_POST['op'] == t('Delete') || $_POST['confirm']) {
if ((isset($_POST['op']) && $_POST['op'] == t('Delete')) || !empty($_POST['confirm'])) {
return drupal_get_form('forum_confirm_delete', $edit['tid']);
}
switch ($type) {
......@@ -500,6 +504,12 @@ function forum_form_main($type, $edit = array()) {
* @param $edit Associative array containing a forum term to be added or edited.
*/
function forum_form_forum($edit = array()) {
$edit += array(
'name' => '',
'description' => '',
'tid' => NULL,
'weight' => 0,
);
$form['name'] = array('#type' => 'textfield',
'#title' => t('Forum name'),
'#default_value' => $edit['name'],
......@@ -1077,7 +1087,7 @@ function theme_forum_topic_navigation($node) {
// get previous and next topic
$sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
$result = db_query(db_rewrite_sql($sql), $node->tid);
$result = db_query(db_rewrite_sql($sql), isset($node->tid) ? $node->tid : 0);
$stop = 0;
while ($topic = db_fetch_object($result)) {
......@@ -1097,13 +1107,13 @@ function theme_forum_topic_navigation($node) {
}
}
if ($prev || $next) {
if (!empty($prev) || !empty($next)) {
$output .= '<div class="forum-topic-navigation clear-block">';
if ($prev) {
if (!empty($prev)) {
$output .= l(t('‹ ') . $prev->title, 'node/'. $prev->nid, array('class' => 'topic-previous', 'title' => t('Go to previous forum topic')));
}
if ($prev && $next) {
if (!empty($prev) && !empty($next)) {
// Word break (a is an inline element)
$output .= ' ';
}
......
......@@ -20,24 +20,20 @@ function node_overview_types() {
if (function_exists($type->module .'_form')) {
$name = check_plain($name);
$type_url_str = str_replace('_', '-', $type->type);
// Populate the operations field.
$operations = array();
$row = array(
l($name, 'admin/content/types/'. $type_url_str),
check_plain($type->type),
check_plain($type->description),
);
// Set the edit column.
$operations[] = array('data' => l(t('edit'), 'admin/content/types/'. $type_url_str));
$row[] = array('data' => l(t('edit'), 'admin/content/types/'. $type_url_str));
// Set the delete column.
if ($type->custom) {
$operations[] = array('data' => l(t('delete'), 'admin/content/types/'. $type_url_str .'/delete'));
$row[] = array('data' => l(t('delete'), 'admin/content/types/'. $type_url_str .'/delete'));
}
else {
$operations[] = array('data' => '');
}
$row = array(array('data' => l($name, 'admin/content/types/'. $type_url_str), 'class' => $class), array('data' => check_plain($type->type), 'class' => $class), array('data' => check_plain($type->description), 'class' => $class));
foreach ($operations as $operation) {
$operation['class'] = $class;
$row[] = $operation;
$row[] = array('data' => '');
}
$rows[] = $row;
}
......@@ -172,7 +168,7 @@ function node_type_form($type = NULL) {
);
$form['orig_type'] = array(
'#type' => 'value',
'#value' => $type->orig_type,
'#value' => isset($type->orig_type) ? $type->orig_type : '',
);
$form['module'] = array(
'#type' => 'value',
......
......@@ -65,7 +65,7 @@ function node_cron() {
*/
function node_title_list($result, $title = NULL) {
while ($node = db_fetch_object($result)) {
$items[] = l($node->title, 'node/'. $node->nid, $node->comment_count ? array('title' => format_plural($node->comment_count, '1 comment', '@count comments')) : '');
$items[] = l($node->title, 'node/'. $node->nid, !empty($node->comment_count) ? array('title' => format_plural($node->comment_count, '1 comment', '@count comments')) : '');
}
return theme('node_list', $items, $title);
......@@ -290,6 +290,15 @@ function node_type_save($info) {
$is_existing = FALSE;
$existing_type = !empty($info->old_type) ? $info->old_type : $info->type;
$is_existing = db_num_rows(db_query("SELECT * FROM {node_type} WHERE type = '%s'", $existing_type));
if (!isset($info->help)) {
$info->help = '';
}
if (!isset($info->min_word_count)) {
$info->min_word_count = 0;
}
if (!isset($info->body_label)) {
$info->body_label = '';
}
if ($is_existing) {
db_query("UPDATE {node_type} SET type = '%s', name = '%s', module = '%s', has_title = %d, title_label = '%s', has_body = %d, body_label = '%s', description = '%s', help = '%s', min_word_count = %d, custom = %d, modified = %d, locked = %d WHERE type = '%s'", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $existing_type);
......@@ -734,7 +743,7 @@ function node_prepare($node, $teaser = FALSE) {
*/
function node_build_content($node, $teaser = FALSE, $page = FALSE) {
// Remove the delimiter (if any) that separates the teaser from the body.
$node->body = str_replace('<!--break-->', '', $node->body);
$node->body = isset($node->body) ? str_replace('<!--break-->', '', $node->body) : '';
// The 'view' hook can be implemented to overwrite the default function
// to display nodes.
......@@ -1519,6 +1528,7 @@ function node_admin_nodes() {
$form['options']['submit'] = array('#type' => 'submit', '#value' => t('Update'));
$destination = drupal_get_destination();
$nodes = array();
while ($node = db_fetch_object($result)) {
$nodes[$node->nid] = '';
$form['title'][$node->nid] = array('#value' => l($node->title, 'node/'. $node->nid) .' '. theme('mark', node_mark($node->nid, $node->changed)));
......@@ -1756,6 +1766,7 @@ function node_feed($nodes = 0, $channel = array()) {
$item_length = variable_get('feed_item_length', 'teaser');
$namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"');
$items = '';
while ($node = db_fetch_object($nodes)) {
// Load the specified node:
$item = node_load($node->nid);
......@@ -1780,7 +1791,7 @@ function node_feed($nodes = 0, $channel = array()) {
$extra = node_invoke_nodeapi($item, 'rss item');
$extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid .' at '. $base_url, 'attributes' => array('isPermaLink' => 'false'))));
foreach ($extra as $element) {
if ($element['namespace']) {
if (isset($element['namespace'])) {
$namespaces = array_merge($namespaces, $element['namespace']);
}
}
......@@ -1934,6 +1945,10 @@ function node_form($node, $form_values = NULL) {
foreach (array('nid', 'vid', 'uid', 'created', 'type') as $key) {
$form[$key] = array('#type' => 'value', '#value' => isset($node->$key) ? $node->$key : NULL);
}
if (!isset($node->nid)) {
$node->body = NULL;
$node->title = NULL;
}
// Changed must be sent to the client, for later overwrite error checking.
$form['changed'] = array('#type' => 'hidden', '#default_value' => isset($node->changed) ? $node->changed : NULL);
......@@ -2169,7 +2184,7 @@ function node_preview($node) {
// Extract a teaser, if it hasn't been set (e.g. by a module-provided
// 'teaser' form item).
if (!isset($node->teaser)) {
$node->teaser = node_teaser($node->body, $node->format);
$node->teaser = empty($node->body) ? '' : node_teaser($node->body, $node->format);
}
// Display a preview of the node:
......
......@@ -184,7 +184,7 @@ function path_set_alias($path = NULL, $alias = NULL, $pid = NULL, $language = ''
/**
* Return a form for editing or creating an individual URL alias.
*/
function path_form($edit = '') {
function path_form($edit = array('src' => '', 'dst' => '', 'pid' => NULL)) {
$form['#submit']['path_form_submit'] = array();
$form['#validate']['path_form_validate'] = array();
$form['#theme'] = 'path_form';
......@@ -272,7 +272,7 @@ function path_nodeapi(&$node, $op, $arg) {
* Implementation of hook_form_alter().
*/
function path_form_alter(&$form, $form_id) {
if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
$path = isset($form['#node']->path) ? $form['#node']->path : NULL;
$form['path'] = array(
'#type' => 'fieldset',
......@@ -362,7 +362,7 @@ function path_load($pid) {
function path_form_validate($form_id, $form_values) {
$src = $form_values['src'];
$dst = $form_values['dst'];
$pid = $form_values['pid'];
$pid = isset($form_values['pid']) ? $form_values['pid'] : 0;
// Language is only set if locale module is enabled, otherwise save for all languages.
$language = isset($form_values['language']) ? $form_values['language'] : '';
......@@ -376,7 +376,7 @@ function path_form_validate($form_id, $form_values) {
*/
function path_form_submit($form_id, $form_values) {
// Language is only set if locale module is enabled
path_set_alias($form_values['src'], $form_values['dst'], $form_values['pid'], isset($form_values['language']) ? $form_values['language'] : '');
path_set_alias($form_values['src'], $form_values['dst'], isset($form_values['pid']) ? $form_values['pid'] : 0, isset($form_values['language']) ? $form_values['language'] : '');
drupal_set_message(t('The alias has been saved.'));
return 'admin/build/path';
......
......@@ -133,7 +133,7 @@ function poll_form($node, $form_values = NULL) {
}
}
else {
$choices = max(2, count($node->choice) ? count($node->choice) : 5);
$choices = max(2, empty($node->choice) ? 5 : count($node->choice));
}
$form['choices'] = array(
......@@ -166,14 +166,14 @@ function poll_form($node, $form_values = NULL) {
$form['choice'][$a]['chtext'] = array(
'#type' => 'textfield',
'#title' => t('Choice @n', array('@n' => ($a + 1))),
'#default_value' => $node->choice[$a]['chtext'],
'#default_value' => isset($node->choice) ? $node->choice[$a]['chtext'] : '',
);
if ($admin) {
$form['choice'][$a]['chvotes'] = array(
'#type' => 'textfield',
'#title' => t('Votes for choice @n', array('@n' => ($a + 1))),
'#default_value' => (int)$node->choice[$a]['chvotes'],
'#default_value' => isset($node->choice) ? (int)$node->