Ejemplo n.º 1
0
 public function form(&$node, &$form_state)
 {
     $type = $this->getNodeTypeInfo();
     $cuser = FALSE;
     $member = FALSE;
     // previous state either from existing node or from rebuilding of form from previous post
     $state = isset($form_state['values']) ? (object) $form_state['values'] : $node;
     $defaults = (object) array('name' => '', 'capacity' => '', 'affiliation' => '', 'email' => '', 'bio' => '', 'format' => FILTER_FORMAT_DEFAULT);
     $cuid = isset($state->cuid) ? $state->cuid : 0;
     if ($cuid > 1) {
         $cuser = user_load($cuid);
         if ($cuser) {
             $member = _member_get_node($cuser);
             $defaults->name = $member ? $member->title : $cuser->name;
             $defaults->email = $cuser->mail;
             if ($member) {
                 $defaults->capacity = $member->jobtitle;
                 $defaults->affiliation = $member->affiliation;
                 $defaults->bio = $member->body;
                 $defaults->format = $member->format;
             }
         }
     }
     $wt = -20;
     if (!$cuser) {
         $form['cuid'] = array('#type' => 'select', '#options' => $this->cuidOptions(TRUE), '#default_value' => 0, '#description' => t('Select an existing user.  You may need to !create first.', array('!create' => l('create a new user', 'admin/user/user/create', array('attributes' => array('target' => 'new_user'))))), '#weight' => $wt++);
         $form['populate_user'] = array('#type' => 'submit', '#value' => t('Populate'), '#submit' => array('contributor_populate_from_user'), '#weight' => $wt++);
     } else {
         $form['cuid_show'] = array('#value' => t('<p>Contributor information for user \'!name\'.</p>', array('!name' => $defaults->name)), '#weight' => -20);
         $form['cuid'] = array('#type' => 'value', '#value' => $cuid);
     }
     $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => FALSE, '#default_value' => !empty($state->title) ? $state->title : $defaults->name, '#weight' => $wt++);
     $form['capacity'] = array('#type' => 'textfield', '#title' => t('Capacity, position or job title'), '#required' => FALSE, '#default_value' => !empty($state->capacity) ? $state->capacity : $defaults->capacity, '#weight' => $wt++);
     $form['affiliation'] = array('#type' => 'textfield', '#title' => t('Affiliation'), '#required' => FALSE, '#default_value' => !empty($state->affiliation) ? $state->affiliation : $defaults->affiliation, '#weight' => $wt++);
     $form['email'] = array('#type' => 'textfield', '#title' => t('Email'), '#required' => FALSE, '#default_value' => !empty($state->email) ? $state->email : $defaults->email, '#weight' => $wt++);
     if (empty($state->body)) {
         $state->body = $defaults->bio;
         $state->format = $defaults->format;
     }
     $this->addNodeBodyField($form, $state, $wt++);
     return $form;
 }
Ejemplo n.º 2
0
/**
 * Override a formatted list of recent comments to be displayed in the comment block.
 */
function phptemplate_comment_block()
{
    $items = array();
    foreach (phptemplate_comment_get_recent() as $comment) {
        $link = l($comment->subject, 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid));
        $date = t('@time ago', array('@time' => format_interval(time() - $comment->timestamp)));
        if ($author = _member_get_node($comment->uid)) {
            $capacity = ($author->jobtitle === '' ? '' : $author->jobtitle . ', ') . ($author->affiliation === '' ? '' : $author->affiliation);
            $author = theme('member_link', $author);
        } else {
            $author = theme_username(user_load(array('uid' => $comment->uid)));
            $capacity = '';
        }
        $content = '<div class="title clear-block">' . $link . ' <span class="date">' . $date . '</span></div>';
        $content .= '<div class="comment clear-block">' . scf_au_truncate_by_word_count($comment->comment, 30) . '</div>';
        $content .= '<div class="byline vcard clear-block">By <span class="fn">' . $author . '</span>';
        $content .= ($capacity === '' ? '' : ', <span class="title">' . $capacity . '</span>') . '</div>';
        $items[] = $content;
    }
    if ($items) {
        return theme('item_list', $items);
    }
}
Ejemplo n.º 3
0
 * - $picture: Authors picture.
 * - $signature: Authors signature.
 * - $status: Comment status. Possible values are:
 *   comment-unpublished, comment-published or comment-review.
 * - $submitted: By line with date and time.
 * - $title: Linked title.
 *
 * These two variables are provided for context.
 * - $comment: Full comment object.
 * - $node: Node object the comments are attached to.
 *
 * @see template_preprocess_comment()
 * @see theme_comment()
 */
$date = t('@time ago', array('@time' => format_interval(time() - $comment->timestamp)));
if ($author = _member_get_node($comment->uid)) {
    $capacity = ($author->jobtitle === '' ? '' : $author->jobtitle . ', ') . ($author->affiliation === '' ? '' : $author->affiliation);
    $author = theme('member_link', $author);
} else {
    $author = theme_username(user_load(array('uid' => $comment->uid)));
    $capacity = '';
}
?>
<div class="comment<?php 
print $comment->new ? ' comment-new' : '';
print ' ' . $status;
?>
 clear-block">
  <h3 class="clear-block">
    <?php 
print $title;