You are here

function blog_form in Drupal 5

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

Implementation of hook_form().

File

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

Code

function blog_form(&$node) {
  global $nid;
  $iid = $_GET['iid'];
  $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' => $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['body_filter']['filter'] = filter_form($node->format);
  return $form;
}