Commit 05a708fb authored by Dries's avatar Dries

- Patch #112715 by chx, webchick, asimmonds, et al: fixing E_ALL notices. Thanks.

parent 4c9fc80f
......@@ -1450,6 +1450,8 @@ function drupal_get_css($css = NULL) {
if (!isset($css)) {
$css = drupal_add_css();
}
$no_module_preprocess = '';
$no_theme_preprocess = '';
$preprocess_css = variable_get('preprocess_css', FALSE);
$directory = file_directory_path();
......@@ -2120,6 +2122,7 @@ function drupal_render(&$elements) {
if (!isset($elements['#sorted'])) {
uasort($elements, "_element_sort");
}
$elements += array('#title' => NULL, '#description' => NULL);
if (!isset($elements['#children'])) {
$children = element_children($elements);
/* Render all the children that use a theme function */
......@@ -2201,7 +2204,7 @@ function element_properties($element) {
* Check if the key is a child.
*/
function element_child($key) {
return $key[0] != '#';
return !isset($key[0]) || $key[0] != '#';
}
/**
......
......@@ -193,7 +193,7 @@ function file_check_upload($source = 'upload') {
}
// If a file was uploaded, process it.
if ($_FILES["files"]["name"][$source] && is_uploaded_file($_FILES["files"]["tmp_name"][$source])) {
if (isset($_FILES["files"]) && $_FILES["files"]["name"][$source] && is_uploaded_file($_FILES["files"]["tmp_name"][$source])) {
// Check for file upload errors and return FALSE if a
// lower level system error occurred.
......@@ -253,7 +253,7 @@ function file_check_upload($source = 'upload') {
else {
// In case of previews return previous file object.
if (file_exists($_SESSION['file_uploads'][$source]->filepath)) {
if (isset($_SESSION['file_uploads']) && file_exists($_SESSION['file_uploads'][$source]->filepath)) {
return $_SESSION['file_uploads'][$source];
}
}
......
......@@ -265,7 +265,9 @@ function drupal_process_form($form_id, &$form) {
// We've finished calling functions that alter the global values, so we can
// restore the ones that were there before this function was called.
list($form_values, $form_submitted, $form_button_counter) = array_pop($saved_globals);
return $redirect;
if (isset($redirect)) {
return $redirect;
}
}
/**
......@@ -306,9 +308,7 @@ function drupal_prepare_form($form_id, &$form) {
// If $base is set, it is used in place of $form_id when constructing validation,
// submission, and theming functions. Useful for mapping many similar or duplicate
// forms with different $form_ids to the same processing functions.
if (isset($form['#base'])) {
$base = $form['#base'];
}
$base = isset($form['#base']) ? $form['#base'] : '';
// Add a token, based on either #token or form_id, to any form displayed to
// authenticated users. This ensures that any submitted form was actually
......@@ -432,7 +432,9 @@ function drupal_submit_form($form_id, $form) {
}
}
}
return $goto;
if (isset($goto)) {
return $goto;
}
}
/**
......@@ -450,9 +452,7 @@ function drupal_submit_form($form_id, $form) {
*/
function drupal_render_form($form_id, &$form) {
// Don't override #theme if someone already set it.
if (isset($form['#base'])) {
$base = $form['#base'];
}
$base = isset($form['#base']) ? $form['#base'] : '';
if (!isset($form['#theme'])) {
if (theme_get_function($form_id)) {
......@@ -492,16 +492,16 @@ function drupal_redirect_form($form, $redirect = NULL) {
if (isset($form['#redirect'])) {
$goto = $form['#redirect'];
}
if ($goto !== FALSE) {
if (is_array($goto)) {
call_user_func_array('drupal_goto', $goto);
}
elseif (!isset($goto)) {
drupal_goto($_GET['q']);
}
else {
drupal_goto($goto);
if (!isset($goto) || ($goto !== FALSE)) {
if (isset($goto)) {
if (is_array($goto)) {
call_user_func_array('drupal_goto', $goto);
}
else {
drupal_goto($goto);
}
}
drupal_goto($_GET['q']);
}
}
......@@ -756,7 +756,7 @@ function form_builder($form_id, $form) {
if (isset($form['#process']) && !$form['#processed']) {
foreach ($form['#process'] as $process => $args) {
if (function_exists($process)) {
$args = array_merge(array($form), array($edit), $args);
$args = array_merge(array($form), array(isset($edit) ? $edit : NULL), $args);
$form = call_user_func_array($process, $args);
}
}
......@@ -929,7 +929,7 @@ function theme_select($element) {
$select = '';
$size = $element['#size'] ? ' size="' . $element['#size'] . '"' : '';
_form_set_class($element, array('form-select'));
$multiple = isset($element['#multiple']) && $element['#multiple'];
$multiple = $element['#multiple'];
return theme('form_element', $element, '<select name="'. $element['#name'] .''. ($multiple ? '[]' : '') .'"'. ($multiple ? ' multiple="multiple" ' : '') . drupal_attributes($element['#attributes']) .' id="'. $element['#id'] .'" '. $size .'>'. form_select_options($element) .'</select>');
}
......@@ -1038,7 +1038,7 @@ function theme_fieldset($element) {
}
}
return '<fieldset' . drupal_attributes($element['#attributes']) .'>' . ($element['#title'] ? '<legend>'. $element['#title'] .'</legend>' : '') . ($element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') . $element['#children'] . $element['#value'] . "</fieldset>\n";
return '<fieldset' . drupal_attributes($element['#attributes']) .'>' . ($element['#title'] ? '<legend>'. $element['#title'] .'</legend>' : '') . ($element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') . (!empty($element['#children']) ? $element['#children'] : '') . $element['#value'] . "</fieldset>\n";
}
/**
......@@ -1079,7 +1079,7 @@ function theme_radios($element) {
if (isset($element['#attributes']['class'])) {
$class .= ' '. $element['#attributes']['class'];
}
$element['#children'] = '<div class="'. $class .'">'. $element['#children'] .'</div>';
$element['#children'] = '<div class="'. $class .'">'. (!empty($element['#children']) ? $element['#children'] : '') .'</div>';
if ($element['#title'] || $element['#description']) {
unset($element['#id']);
return theme('form_element', $element, $element['#children']);
......@@ -1232,12 +1232,18 @@ function map_month($month) {
*/
function checkboxes_value(&$form) {
$value = array();
foreach ((array)$form['#default_value'] as $key) {
$form += array('#default_value' => array());
foreach ($form['#default_value'] as $key) {
$value[$key] = 1;
}
$form['#value'] = $value;
}
function password_confirm_value(&$form) {
$form += array('#default_value' => array());
$form['#value'] = $form['#default_value'] + array('pass1' => '', 'pass2' => '');
}
/**
* If no default value is set for weight select boxes, use 0.
*/
......@@ -1275,7 +1281,7 @@ function expand_radios($element) {
* A themed HTML string representing the form item.
*/
function theme_item($element) {
return theme('form_element', $element, $element['#value'] . $element['#children']);
return theme('form_element', $element, $element['#value'] . (!empty($element['#children']) ? $element['#children'] : ''));
}
/**
......@@ -1318,7 +1324,7 @@ function theme_checkboxes($element) {
if (isset($element['#attributes']['class'])) {
$class .= ' '. $element['#attributes']['class'];
}
$element['#children'] = '<div class="'. $class .'">'. $element['#children'] .'</div>';
$element['#children'] = '<div class="'. $class .'">'. (!empty($element['#children']) ? $element['#children'] : '') .'</div>';
if ($element['#title'] || $element['#description']) {
unset($element['#id']);
return theme('form_element', $element, $element['#children']);
......@@ -1492,6 +1498,7 @@ function process_weight($element) {
$element['#options'] = $weights;
$element['#type'] = 'select';
$element['#is_weight'] = TRUE;
$element += _element_info('select');
return $element;
}
......
......@@ -356,7 +356,7 @@ function _menu_tree($result = NULL, $depth = 0, $link = array('link' => '', 'has
list($remnant, $menu) = _menu_tree($result, $item->depth, $menu_link);
$tree .= theme('menu_tree', $link, $menu);
$link = $remnant;
$remnant = '';
$remnant = array('link' => '', 'has_children' => FALSE);
}
elseif ($item->depth == $depth) {
$tree .= theme('menu_link', $link);
......@@ -496,6 +496,7 @@ function menu_rebuild() {
'_has_children' => 0,
'title' => '',
'weight' => 0,
'type' => MENU_NORMAL_ITEM,
);
$sort[$path] = ($item['_visible'] ? $depth : $number_parts) . sprintf('%05d', $item['weight']) . $item['title'];
unset($item);
......@@ -527,11 +528,6 @@ function menu_rebuild() {
if (!isset($item['map callback']) && isset($item['map arguments'])) {
$item['map callback'] = 'menu_map';
}
foreach (array('access', 'map', 'page') as $type) {
if (isset($item["$type callback"]) && !isset($item["$type arguments"])) {
$item["$type arguments"] = array();
}
}
if (is_bool($item['access callback'])) {
$item['access callback'] = intval($item['access callback']);
}
......@@ -548,7 +544,15 @@ function menu_rebuild() {
$vancode = '';
$link = '';
}
db_query("INSERT INTO {menu} (mid, pid, path, access_callback, access_arguments, page_callback, page_arguments, map_callback, map_arguments, fit, number_parts, vancode, menu_link, visible, parents, depth, has_children) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, '%s', %d, %d)", $item['_mid'], $item['_pid'], $path, $item['access callback'], serialize($item['access arguments']), $item['page callback'], serialize($item['page arguments']), $item['map callback'], serialize($item['map arguments']), $item['_fit'], $item['_number_parts'], $vancode .'+', $link, $item['_visible'], $item['_parents'], $item['_depth'], $item['_has_children']);
$insert_item = $item + array(
'access arguments' => array(),
'access callback' => '',
'page arguments' => array(),
'page callback' => '',
'map arguments' => array(),
'map callback' => '',
);
db_query("INSERT INTO {menu} (mid, pid, path, access_callback, access_arguments, page_callback, page_arguments, map_callback, map_arguments, fit, number_parts, vancode, menu_link, visible, parents, depth, has_children) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, '%s', %d, %d)", $insert_item['_mid'], $insert_item['_pid'], $path, $insert_item['access callback'], serialize($insert_item['access arguments']), $insert_item['page callback'], serialize($insert_item['page arguments']), $insert_item['map callback'], serialize($insert_item['map arguments']), $insert_item['_fit'], $insert_item['_number_parts'], $vancode .'+', $link, $insert_item['_visible'], $insert_item['_parents'], $insert_item['_depth'], $insert_item['_has_children']);
// $item needs to be unset because of the reference above.
unset($item);
}
......
......@@ -127,7 +127,9 @@ function module_rebuild_cache() {
}
else {
// This is a new module.
db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $file->name, $file->info['description'], 'module', $file->filename, $file->status, $file->throttle, $bootstrap);
$files[$filename]->status = 0;
$files[$filename]->throttle = 0;
db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $file->name, $file->info['description'], 'module', $file->filename, 0, 0, $bootstrap);
}
}
$files = _module_build_dependents($files);
......
......@@ -107,7 +107,7 @@ function tablesort_header($cell, $header, $ts) {
* A properly formatted cell, ready for _theme_table_cell().
*/
function tablesort_cell($cell, $header, $ts, $i) {
if (isset($header[$i]) && $header[$i]['data'] == $ts['name'] && $header[$i]['field']) {
if (isset($header[$i]['data']) && $header[$i]['data'] == $ts['name'] && !empty($header[$i]['field'])) {
if (is_array($cell)) {
if (isset($cell['class'])) {
$cell['class'] .= ' active';
......@@ -162,6 +162,7 @@ function tablesort_get_order($headers) {
else {
// The first column specified is initial 'order by' field unless otherwise specified
if (is_array($headers[0])) {
$headers[0] += array('data' => NULL, 'field' => NULL);
return array('name' => $headers[0]['data'], 'sql' => $headers[0]['field']);
}
else {
......
......@@ -42,7 +42,7 @@ function init_theme() {
// Only select the user selected theme if it is available in the
// list of enabled themes.
$theme = $user->theme && $themes[$user->theme]->status ? $user->theme : variable_get('theme_default', 'garland');
$theme = !empty($user->theme) && $themes[$user->theme]->status ? $user->theme : variable_get('theme_default', 'garland');
// Allow modules to override the present theme... only select custom theme
// if it is available in the list of installed themes.
......@@ -611,7 +611,7 @@ function theme_image($path, $alt = '', $title = '', $attributes = NULL, $getsize
if (!$getsize || (is_file($path) && (list($width, $height, $type, $image_attributes) = @getimagesize($path)))) {
$attributes = drupal_attributes($attributes);
$url = (url($path) == $path) ? $path : (base_path() . $path);
return '<img src="'. check_url($url) .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $image_attributes . $attributes .' />';
return '<img src="'. check_url($url) .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. (isset($image_attributes) ? $image_attributes : '') . $attributes .' />';
}
}
......@@ -1089,7 +1089,7 @@ function _theme_table_cell($cell, $header = FALSE) {
$attributes = '';
if (is_array($cell)) {
$data = $cell['data'];
$data = isset($cell['data']) ? $cell['data'] : '';
$header |= isset($cell['header']);
unset($cell['data']);
unset($cell['header']);
......
......@@ -300,7 +300,9 @@ function aggregator_block($op = 'list', $delta = 0, $edit = array()) {
$block['content'] = theme('item_list', $items) . $read_more;
}
}
return $block;
if (isset($block)) {
return $block;
}
}
}
......@@ -1102,7 +1104,9 @@ function _aggregator_page_list($sql, $op, $header = '') {
}
$output .= '</div>';
$output .= $form['pager']['#value'];
$output .= $form['feed_icon']['#value'];
if (isset($form['feed_icon']['#value'])) {
$output .= $form['feed_icon']['#value'];
}
return $output;
}
}
......
......@@ -160,7 +160,7 @@ function _block_rehash() {
$block['module'] = $module;
$block['delta'] = $delta;
// If previously written to database, load values.
if ($old_blocks[$module][$delta]) {
if (!empty($old_blocks[$module][$delta])) {
$block['status'] = $old_blocks[$module][$delta]->status;
$block['weight'] = $old_blocks[$module][$delta]->weight;
$block['region'] = $old_blocks[$module][$delta]->region;
......@@ -310,7 +310,7 @@ function theme_block_admin_display($form) {
foreach (element_children($form) as $i) {
$block = &$form[$i];
// Only take form elements that are blocks.
if (is_array($block['info'])) {
if (isset($block['info'])) {
// Fetch values
$region = $block['region']['#default_value'];
$status = $region != BLOCK_REGION_NONE;
......@@ -337,7 +337,7 @@ function theme_block_admin_display($form) {
$row[] = drupal_render($block['throttle']);
}
$row[] = drupal_render($block['configure']);
$row[] = $block['delete'] ? drupal_render($block['delete']) : '';
$row[] = !empty($block['delete']) ? drupal_render($block['delete']) : '';
$rows[] = $row;
}
}
......@@ -624,14 +624,14 @@ function block_user($type, $edit, &$user, $category = NULL) {
}
}
if ($return) {
if (!empty($return)) {
return $form;
}
}
break;
case 'validate':
if (!$edit['block']) {
if (empty($edit['block'])) {
$edit['block'] = array();
}
return $edit;
......
......@@ -185,7 +185,7 @@ function blog_page_last() {
*/
function blog_form(&$node) {
global $nid;
$iid = $_GET['iid'];
$iid = isset($_GET['iid']) ? (int)$_GET['iid'] : 0;
$type = node_get_types('type', $node);
......@@ -207,8 +207,8 @@ function blog_form(&$node) {
}
$form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -5);
$form['body_filter']['body'] = array('#type' => 'textarea', '#title' => check_plain($type->body_label), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE);
$form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => !empty($node->title) ? $node->title : NULL, '#weight' => -5);
$form['body_filter']['body'] = array('#type' => 'textarea', '#title' => check_plain($type->body_label), '#default_value' => !empty($node->body) ? $node->title : NULL, '#rows' => 20, '#required' => TRUE);
$form['body_filter']['filter'] = filter_form($node->format);
return $form;
}
......
......@@ -445,7 +445,7 @@ function book_nodeapi(&$node, $op, $teaser, $page) {
break;
case 'update':
if (isset($node->parent)) {
if ($node->revision) {
if (!empty($node->revision)) {
db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight);
}
else {
......@@ -507,7 +507,7 @@ function theme_book_navigation($node) {
* This is a helper function for book_toc().
*/
function book_toc_recurse($nid, $indent, $toc, $children, $exclude) {
if ($children[$nid]) {
if (!empty($children[$nid])) {
foreach ($children[$nid] as $foo => $node) {
if (!$exclude || $exclude != $node->nid) {
$toc[$node->nid] = $indent .' '. $node->title;
......@@ -527,7 +527,7 @@ function book_toc($exclude = 0) {
$children = array();
while ($node = db_fetch_object($result)) {
if (!$children[$node->parent]) {
if (empty($children[$node->parent])) {
$children[$node->parent] = array();
}
$children[$node->parent][] = $node;
......@@ -958,6 +958,7 @@ function book_admin($nid = 0) {
*/
function book_admin_overview() {
$result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = 0 ORDER BY b.weight, n.title'));
$rows = array();
while ($book = db_fetch_object($result)) {
$rows[] = array(l($book->title, "node/$book->nid"), l(t('outline'), "admin/content/book/$book->nid"));
}
......
......@@ -791,6 +791,7 @@ function comment_save($edit) {
$edit['name'] = $user->name;
}
$edit += array('mail' => '', 'homepage' => '');
db_query("INSERT INTO {comments} (cid, nid, pid, uid, subject, comment, format, hostname, timestamp, status, score, users, thread, name, mail, homepage) VALUES (%d, %d, %d, %d, '%s', '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s')", $edit['cid'], $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], $_SERVER['REMOTE_ADDR'], $edit['timestamp'], $status, $score, $users, $thread, $edit['name'], $edit['mail'], $edit['homepage']);
_comment_update_node_statistics($edit['nid']);
......@@ -1150,7 +1151,7 @@ function comment_operations($action = NULL) {
function comment_admin($type = 'new') {
$edit = $_POST;
if ($edit['operation'] == 'delete' && $edit['comments']) {
if (isset($edit['operation']) && ($edit['operation'] == 'delete') && $edit['comments']) {
return drupal_get_form('comment_multiple_delete_confirm');
}
else {
......@@ -1192,7 +1193,7 @@ function comment_admin_overview($type = 'new', $arg) {
$form['timestamp'][$comment->cid] = array('#value' => format_date($comment->timestamp, 'small'));
$form['operations'][$comment->cid] = array('#value' => l(t('edit'), 'comment/edit/'. $comment->cid, array(), $destination));
}
$form['comments'] = array('#type' => 'checkboxes', '#options' => $comments);
$form['comments'] = array('#type' => 'checkboxes', '#options' => isset($comments) ? $comments: array());
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
return $form;
}
......@@ -1431,7 +1432,7 @@ function comment_form($edit, $title = NULL) {
$op = isset($_POST['op']) ? $_POST['op'] : '';
if ($user->uid) {
if ($edit['cid'] && user_access('administer comments')) {
if (!empty($edit['cid']) && user_access('administer comments')) {
if ($edit['author']) {
$author = $edit['author'];
}
......@@ -1537,19 +1538,19 @@ function comment_form($edit, $title = NULL) {
}
if (variable_get('comment_subject_field', 1) == 1) {
$form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => $edit['subject']);
$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' => $edit['comment'] ? $edit['comment'] : $user->signature, '#required' => TRUE);
$form['comment_filter']['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => !empty($edit['comment']) ? $edit['comment'] : $user->signature, '#required' => TRUE);
if (!isset($edit['format'])) {
$edit['format'] = FILTER_FORMAT_DEFAULT;
}
$form['comment_filter']['format'] = filter_form($edit['format']);
$form['cid'] = array('#type' => 'value', '#value' => $edit['cid']);
$form['cid'] = array('#type' => 'value', '#value' => !empty($edit['cid']) ? $edit['cid'] : NULL);
$form['pid'] = array('#type' => 'value', '#value' => $edit['pid']);
$form['nid'] = array('#type' => 'value', '#value' => $edit['nid']);
$form['uid'] = array('#type' => 'value', '#value' => $edit['uid']);
$form['uid'] = array('#type' => 'value', '#value' => !empty($edit['uid']) ? $edit['uid'] : NULL);
$form['preview'] = array('#type' => 'button', '#value' => t('Preview comment'), '#weight' => 19);
$form['#token'] = 'comment'. $edit['nid'] . $edit['pid'];
......@@ -1565,7 +1566,7 @@ function comment_form($edit, $title = NULL) {
$form['#after_build'] = array('comment_form_add_preview');
}
if ($_REQUEST['destination']) {
if (!empty($_REQUEST['destination'])) {
$form['#attributes']['destination'] = $_REQUEST['destination'];
}
......@@ -1603,7 +1604,7 @@ function comment_form_add_preview($form, $edit) {
$comment->uid = $account->uid;
$comment->name = check_plain($account->name);
}
$comment->timestamp = $edit['timestamp'] ? $edit['timestamp'] : time();
$comment->timestamp = !empty($edit['timestamp']) ? $edit['timestamp'] : time();
// Preview the comment with security check.
if (!form_get_errors()) {
......
......@@ -116,7 +116,7 @@ function contact_user($type, &$edit, &$user, $category = NULL) {
);
$form['contact']['contact'] = array('#type' => 'checkbox',
'#title' => t('Personal contact form'),
'#default_value' => $edit['contact'],
'#default_value' => !empty($edit['contact']) ? $edit['contact'] : FALSE,
'#description' => t('Allow other users to contact you by e-mail via <a href="@url">your personal contact form</a>. Note that while your e-mail address is not made public to other members of the community, privileged users such as site administrators are able to contact you even if you choose not to enable this feature.', array('@url' => url("user/$user->uid/contact"))),
);
return $form;
......
......@@ -507,12 +507,11 @@ function filter_admin_format_form_submit($form_id, $form_values) {
cache_clear_all($format .':', 'cache_filter', TRUE);
// If a new filter was added, return to the main list of filters. Otherwise, stay on edit filter page to show new changes.
if ($new) {
return 'admin/settings/filters/';
}
else {
return 'admin/settings/filters/'. $format;
$return = 'admin/settings/filters';
if (!empty($new)) {
$return .= '/'. $format;
}
return $return;
}
/**
......
......@@ -388,16 +388,16 @@ function forum_update($node) {
*/
function forum_form(&$node) {
$type = node_get_types('type', $node);
$form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#default_value' => $node->title, '#required' => TRUE, '#weight' => -5);
$form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#default_value' => !empty($node->title) ? $node->title : '', '#required' => TRUE, '#weight' => -5);
if ($node->nid) {
if (!empty($node->nid)) {
$forum_terms = taxonomy_node_get_terms_by_vocabulary(_forum_get_vid(), $node->nid);
// if editing, give option to leave shadows
$shadow = (count($forum_terms) > 1);
$form['shadow'] = array('#type' => 'checkbox', '#title' => t('Leave shadow copy'), '#default_value' => $shadow, '#description' => t('If you move this topic, you can leave a link in the old forum to the new forum.'));
}
$form['body_filter']['body'] = array('#type' => 'textarea', '#title' => check_plain($type->body_label), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE);
$form['body_filter']['body'] = array('#type' => 'textarea', '#title' => check_plain($type->body_label), '#default_value' => !empty($node->body) ? $node->body : '', '#rows' => 20, '#required' => TRUE);
$form['body_filter']['format'] = filter_form($node->format);
return $form;
......@@ -407,7 +407,7 @@ function forum_form(&$node) {
* Implementation of hook_prepare; assign forum taxonomy when adding a topic from within a forum.
*/
function forum_prepare(&$node) {
if (!$node->nid) {
if (empty($node->nid)) {
// new topic
$node->taxonomy[arg(3)]->vid = _forum_get_vid();
$node->taxonomy[arg(3)]->tid = arg(3);
......
......@@ -240,7 +240,7 @@ function locale_supported_languages($reset = FALSE, $getall = FALSE) {
unset($enabled); unset($all);
}
if (is_null($enabled)) {
if (!isset($enabled)) {
$enabled = $all = array();
$all['name'] = $all['formula'] = $enabled['name'] = $enabled['formula'] = array();
$result = db_query('SELECT locale, name, formula, enabled FROM {locales_meta} ORDER BY isdefault DESC, enabled DESC, name ASC');
......
......@@ -41,7 +41,7 @@ function node_help($section) {
if (arg(0) == 'node' && arg(1) == 'add' && $type = arg(2)) {
$type = node_get_types('type', str_replace('-', '_', arg(2)));
return '<p>'. filter_xss_admin($type->help) .'</p>';
return '<p>'. (isset($type->help) ? filter_xss_admin($type->help) : '') .'</p>';
}
}
......@@ -564,7 +564,7 @@ function node_save(&$node) {
}
$node = $node_current;
if ($node->revision) {
if (!empty($node->revision)) {
$node->old_vid = $node->vid;
$node->vid = db_next_id('{node_revisions}_vid');
}
......@@ -617,7 +617,7 @@ function node_save(&$node) {
}
$node_table_values[] = $node->nid;
$node_query = 'UPDATE {node} SET '. implode(', ', $arr) .' WHERE nid = %d';
if ($node->revision) {
if (!empty($node->revision)) {
$revisions_query = 'INSERT INTO {node_revisions} ('. implode(', ', array_keys($revisions_table_types)) .') VALUES ('. implode(', ', $revisions_table_types) .')';
}
else {
......@@ -1393,6 +1393,7 @@ function node_filter_form() {
* Theme node administration filter form.
*/
function theme_node_filter_form($form) {
$output = '';
$output .= '<div id="node-admin-filter">';
$output .= drupal_render($form['filters']);
$output .= '</div>';
......@@ -1404,14 +1405,15 @@ function theme_node_filter_form($form) {
* Theme node administration filter selector.
*/
function theme_node_filters($form) {
$output = '';
$output .= '<ul class="clear-block">';
if (sizeof($form['current'])) {
if (!empty($form['current'])) {
foreach (element_children($form['current']) as $key) {
$output .= '<li>'. drupal_render($form['current'][$key]) .'</li>';
}
}
$output .= '<li><dl class="multiselect">'. (sizeof($form['current']) ? '<dt><em>'. t('and') .'</em> '. t('where') .'</dt>' : '') .'<dd class="a">';
$output .= '<li><dl class="multiselect">'. (!empty($form['current']) ? '<dt><em>'. t('and') .'</em> '. t('where') .'</dt>' : '') .'<dd class="a">';
foreach (element_children($form['filter']) as $key) {
$output .= drupal_render($form['filter'][$key]);
}
......@@ -1495,7 +1497,7 @@ function node_admin_nodes_validate($form_id, $form_values) {
function node_admin_content() {
$output = drupal_get_form('node_filter_form');
if ($_POST['operation'] == 'delete' && $_POST['nodes']) {
if (isset($_POST['operation']) && ($_POST['operation'] == 'delete') && $_POST['nodes']) {
return drupal_get_form('node_multiple_delete_confirm');
}
// Call the form first, to allow for the form_values array to be populated.
......@@ -1542,6 +1544,7 @@ function node_admin_nodes() {
function theme_node_admin_nodes($form) {
// Overview table:
$header = array(theme('table_select_header_cell'), t('Title'), t('Type'), t('Author'), t('Status'), t('Operations'));
$output = '';
$output .= drupal_render($form['options']);
if (isset($form['title']) && is_array($form['title'])) {
......@@ -1720,7 +1723,8 @@ function node_revision_list($node) {
}
function node_admin_search() {
return drupal_get_form('search_form', url('admin/content/search'), $_POST['keys'], 'node') . search_data($_POST['keys'], 'node');
$keys = isset($_POST['keys']) ? $_POST['keys'] : NULL;
return drupal_get_form('search_form', url('admin/content/search'), $keys, 'node') . search_data($keys, 'node');
}
/**
......@@ -1889,7 +1893,7 @@ function node_validate($node, $form = array()) {
// Make sure the body has the minimum number of words.
// todo use a better word counting algorithm that will work in other languages
if (isset($node->body) && count(explode(' ', $node->body)) < $type->min_word_count) {
if (!empty($type->min_word_count) && isset($node->body) && count(explode(' ', $node->body)) < $type->min_word_count) {
form_set_error('body', t('The body of your @type is too short. You need at least %words words.', array('%words' => $type->min_word_count, '@type' => $type->name)));
}
......@@ -1953,12 +1957,14 @@ function node_form($node, $form_values = NULL) {
* These elements are just values so they are not even sent to the client.
*/
foreach (array('nid', 'vid', 'uid', 'created', 'type') as $key) {
$form[$key] = array('#type' => 'value', '#value' => $node->$key);
$form[$key] = array('#type' => 'value', '#value' => isset($node->$key) ? $node->$key : NULL);
}
// Changed must be sent to the client, for later overwrite error checking.
$form['changed'] = array('#type' => 'hidden', '#default_value' => $node->changed);
$form['changed'] = array('#type' => 'hidden', '#default_value' => isset($node->changed) ? $node->changed : NULL);
if (!isset($node->format)) {
$node->format = NULL;
}
// Get the node-specific bits.
$form = array_merge_recursive($form, node_invoke($node, 'form', $form_values));
if (!isset($form['title']['#weight'])) {
......@@ -2029,7 +2035,7 @@ function node_form($node, $form_values = NULL) {
// Add the buttons.
$form['preview'] = array('#type' => 'button', '#value' => t('Preview'), '#weight' => 40);
$form['submit'] = array('#type' => 'submit', '#value' => t('Submit'), '#weight' => 45);
if ($node->nid && node_access('delete', $node)) {
if (!empty($node->nid) && node_access('delete', $node)) {
$form['delete'] = array('#type' => 'button', '#value' => t('Delete'), '#weight' => 50);
}
$form['#after_build'] = array('node_form_add_preview');
......@@ -2388,7 +2394,7 @@ function node_page_view($node, $cid = NULL) {
* Menu callback; presents the node editing form, or redirects to delete confirmation.