Reformat notice list code

This commit is contained in:
Evan Prodromou 2009-01-19 16:35:04 +00:00
parent b635b6de04
commit 02b49e3f87
1 changed files with 32 additions and 33 deletions

View File

@ -67,7 +67,7 @@ class NoticeList extends Widget
function __construct($notice, $out=null) function __construct($notice, $out=null)
{ {
parent::__construct($out); parent::__construct($out);
$this->notice = $notice; $this->notice = $notice;
} }
@ -160,7 +160,7 @@ class NoticeListItem extends Widget
function __construct($notice, $out=null) function __construct($notice, $out=null)
{ {
parent::__construct($out); parent::__construct($out);
$this->notice = $notice; $this->notice = $notice;
$this->profile = $notice->getProfile(); $this->profile = $notice->getProfile();
} }
@ -209,7 +209,6 @@ class NoticeListItem extends Widget
$this->out->elementEnd('div'); $this->out->elementEnd('div');
} }
/** /**
* start a single notice. * start a single notice.
* *
@ -221,7 +220,7 @@ class NoticeListItem extends Widget
// XXX: RDFa // XXX: RDFa
// TODO: add notice_type class e.g., notice_video, notice_image // TODO: add notice_type class e.g., notice_video, notice_image
$this->out->elementStart('li', array('class' => 'hentry notice', $this->out->elementStart('li', array('class' => 'hentry notice',
'id' => 'notice-' . $this->notice->id)); 'id' => 'notice-' . $this->notice->id));
} }
/** /**
@ -235,11 +234,11 @@ class NoticeListItem extends Widget
$user = common_current_user(); $user = common_current_user();
if ($user) { if ($user) {
if ($user->hasFave($this->notice)) { if ($user->hasFave($this->notice)) {
$disfavor = new DisfavorForm($this->out, $this->notice); $disfavor = new DisfavorForm($this->out, $this->notice);
$disfavor->show(); $disfavor->show();
} else { } else {
$favor = new FavorForm($this->out, $this->notice); $favor = new FavorForm($this->out, $this->notice);
$favor->show(); $favor->show();
} }
} }
} }
@ -256,7 +255,7 @@ class NoticeListItem extends Widget
{ {
$this->out->elementStart('span', 'vcard author'); $this->out->elementStart('span', 'vcard author');
$this->out->elementStart('a', array('href' => $this->profile->profileurl, $this->out->elementStart('a', array('href' => $this->profile->profileurl,
'class' => 'url')); 'class' => 'url'));
$this->showAvatar(); $this->showAvatar();
$this->showNickname(); $this->showNickname();
$this->out->elementEnd('a'); $this->out->elementEnd('a');
@ -277,15 +276,15 @@ class NoticeListItem extends Widget
$avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE); $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
$this->out->element('img', array('src' => ($avatar) ? $this->out->element('img', array('src' => ($avatar) ?
common_avatar_display_url($avatar) : common_avatar_display_url($avatar) :
common_default_avatar(AVATAR_STREAM_SIZE), common_default_avatar(AVATAR_STREAM_SIZE),
'class' => 'avatar photo', 'class' => 'avatar photo',
'width' => AVATAR_STREAM_SIZE, 'width' => AVATAR_STREAM_SIZE,
'height' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE,
'alt' => 'alt' =>
($this->profile->fullname) ? ($this->profile->fullname) ?
$this->profile->fullname : $this->profile->fullname :
$this->profile->nickname)); $this->profile->nickname));
} }
/** /**
@ -299,7 +298,7 @@ class NoticeListItem extends Widget
function showNickname() function showNickname()
{ {
$this->out->element('span', array('class' => 'nickname fn'), $this->out->element('span', array('class' => 'nickname fn'),
$this->profile->nickname); $this->profile->nickname);
} }
/** /**
@ -349,11 +348,11 @@ class NoticeListItem extends Widget
$this->out->element('dt', null, _('Published')); $this->out->element('dt', null, _('Published'));
$this->out->elementStart('dd', null); $this->out->elementStart('dd', null);
$this->out->elementStart('a', array('rel' => 'bookmark', $this->out->elementStart('a', array('rel' => 'bookmark',
'href' => $noticeurl)); 'href' => $noticeurl));
$dt = common_date_iso8601($this->notice->created); $dt = common_date_iso8601($this->notice->created);
$this->out->element('abbr', array('class' => 'published', $this->out->element('abbr', array('class' => 'published',
'title' => $dt), 'title' => $dt),
common_date_string($this->notice->created)); common_date_string($this->notice->created));
$this->out->elementEnd('a'); $this->out->elementEnd('a');
$this->out->elementEnd('dd'); $this->out->elementEnd('dd');
$this->out->elementEnd('dl'); $this->out->elementEnd('dl');
@ -375,20 +374,20 @@ class NoticeListItem extends Widget
$this->out->element('dt', null, _('From')); $this->out->element('dt', null, _('From'));
$source_name = _($this->notice->source); $source_name = _($this->notice->source);
switch ($this->notice->source) { switch ($this->notice->source) {
case 'web': case 'web':
case 'xmpp': case 'xmpp':
case 'mail': case 'mail':
case 'omb': case 'omb':
case 'api': case 'api':
$this->out->element('dd', 'noticesource', $source_name); $this->out->element('dd', 'noticesource', $source_name);
break; break;
default: default:
$ns = Notice_source::staticGet($this->notice->source); $ns = Notice_source::staticGet($this->notice->source);
if ($ns) { if ($ns) {
$this->out->elementStart('dd', null); $this->out->elementStart('dd', null);
$this->out->element('a', array('href' => $ns->url, $this->out->element('a', array('href' => $ns->url,
'rel' => 'external'), 'rel' => 'external'),
$ns->name); $ns->name);
$this->out->elementEnd('dd'); $this->out->elementEnd('dd');
} else { } else {
$this->out->element('dd', 'noticesource', $source_name); $this->out->element('dd', 'noticesource', $source_name);
@ -417,8 +416,8 @@ class NoticeListItem extends Widget
$this->out->element('dt', null, _('To')); $this->out->element('dt', null, _('To'));
$this->out->elementStart('dd'); $this->out->elementStart('dd');
$this->out->element('a', array('href' => $replyurl, $this->out->element('a', array('href' => $replyurl,
'rel' => 'in-reply-to'), 'rel' => 'in-reply-to'),
_('in reply to')); _('in reply to'));
$this->out->elementEnd('dd'); $this->out->elementEnd('dd');
$this->out->elementEnd('dl'); $this->out->elementEnd('dl');
} }