Same name and namespace in other branches
  1. 4.6.x modules/blog.module \blog_form()
  2. 4.7.x modules/blog.module \blog_form()
  3. 5.x modules/blog/blog.module \blog_form()
  4. 7.x modules/blog/blog.module \blog_form()

Implementation of hook_form().

File

modules/blog/blog.module, line 76
Enables keeping an easily and regularly updated web page or a blog.

Code

function blog_form(&$node) {
  global $nid;
  $iid = isset($_GET['iid']) ? (int) $_GET['iid'] : 0;
  $type = node_get_types('type', $node);
  if (empty($node->body)) {

    // If the user clicked a "blog it" link, we load the data from the
    // database and quote it in the blog.
    if ($nid && ($blog = node_load($nid))) {
      $node->body = '<em>' . $blog->body . '</em> [' . l($blog->name, "node/{$nid}") . ']';
    }
    if ($iid && ($item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {aggregator_item} i, {aggregator_feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid)))) {
      $node->title = $item->title;

      // 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";
    }
  }
  $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_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
  return $form;
}