diff options
Diffstat (limited to 'lib/noticelist.php')
-rw-r--r-- | lib/noticelist.php | 218 |
1 files changed, 117 insertions, 101 deletions
diff --git a/lib/noticelist.php b/lib/noticelist.php index 71db067d0..c57d6ce19 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -31,6 +31,9 @@ if (!defined('LACONICA')) { exit(1); } +require_once INSTALLDIR.'/lib/favorform.php'; +require_once INSTALLDIR.'/lib/disfavorform.php'; + /** * widget for displaying a list of notices * @@ -50,7 +53,7 @@ if (!defined('LACONICA')) { * @see ProfileNoticeList */ -class NoticeList +class NoticeList extends Widget { /** the current stream of notices being displayed. */ @@ -62,8 +65,9 @@ class NoticeList * @param Notice $notice stream of notices from DB_DataObject */ - function __construct($notice) + function __construct($notice, $out=null) { + parent::__construct($out); $this->notice = $notice; } @@ -78,7 +82,9 @@ class NoticeList function show() { - common_element_start('ul', array('id' => 'notices')); + $this->out->elementStart('div', array('id' =>'notices_primary')); + $this->out->element('h2', null, _('Notices')); + $this->out->elementStart('ul', array('class' => 'notices')); $cnt = 0; @@ -93,7 +99,8 @@ class NoticeList $item->show(); } - common_element_end('ul'); + $this->out->elementEnd('ul'); + $this->out->elementEnd('div'); return $cnt; } @@ -111,7 +118,7 @@ class NoticeList function newListItem($notice) { - return new NoticeListItem($notice); + return new NoticeListItem($notice, $this->out); } } @@ -133,7 +140,7 @@ class NoticeList * @see ProfileNoticeListItem */ -class NoticeListItem +class NoticeListItem extends Widget { /** The notice this item will show. */ @@ -151,8 +158,9 @@ class NoticeListItem * @param Notice $notice The notice we'll display */ - function __construct($notice) + function __construct($notice, $out=null) { + parent::__construct($out); $this->notice = $notice; $this->profile = $notice->getProfile(); } @@ -169,17 +177,36 @@ class NoticeListItem function show() { $this->showStart(); - $this->showFaveForm(); + $this->showNotice(); + $this->showNoticeInfo(); + $this->showNoticeOptions(); + $this->showEnd(); + } + + function showNotice() + { + $this->out->elementStart('div', 'entry-title'); $this->showAuthor(); $this->showContent(); - $this->startTimeSection(); + $this->out->elementEnd('div'); + } + + function showNoticeInfo() + { + $this->out->elementStart('div', 'entry-content'); $this->showNoticeLink(); $this->showNoticeSource(); $this->showReplyTo(); + $this->out->elementEnd('div'); + } + + function showNoticeOptions() + { + $this->out->elementStart('div', 'notice-options'); + $this->showFaveForm(); $this->showReplyLink(); $this->showDeleteLink(); - $this->endTimeSection(); - $this->showEnd(); + $this->out->elementEnd('div'); } /** @@ -191,8 +218,9 @@ class NoticeListItem function showStart() { // XXX: RDFa - common_element_start('li', array('class' => 'notice_single hentry', - 'id' => 'notice-' . $this->notice->id)); + // TODO: add notice_type class e.g., notice_video, notice_image + $this->out->elementStart('li', array('class' => 'hentry notice', + 'id' => 'notice-' . $this->notice->id)); } /** @@ -206,9 +234,11 @@ class NoticeListItem $user = common_current_user(); if ($user) { if ($user->hasFave($this->notice)) { - common_disfavor_form($this->notice); + $disfavor = new DisfavorForm($this->out, $this->notice); + $disfavor->show(); } else { - common_favor_form($this->notice); + $favor = new FavorForm($this->out, $this->notice); + $favor->show(); } } } @@ -223,10 +253,13 @@ class NoticeListItem function showAuthor() { - common_element_start('span', 'vcard author'); + $this->out->elementStart('span', 'vcard author'); + $this->out->elementStart('a', array('href' => $this->profile->profileurl, + 'class' => 'url')); $this->showAvatar(); $this->showNickname(); - common_element_end('span'); + $this->out->elementEnd('a'); + $this->out->elementEnd('span'); } /** @@ -241,18 +274,17 @@ class NoticeListItem function showAvatar() { $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE); - common_element_start('a', array('href' => $this->profile->profileurl)); - common_element('img', array('src' => ($avatar) ? - common_avatar_display_url($avatar) : - common_default_avatar(AVATAR_STREAM_SIZE), - 'class' => 'avatar stream photo', - 'width' => AVATAR_STREAM_SIZE, - 'height' => AVATAR_STREAM_SIZE, - 'alt' => - ($this->profile->fullname) ? - $this->profile->fullname : - $this->profile->nickname)); - common_element_end('a'); + + $this->out->element('img', array('src' => ($avatar) ? + common_avatar_display_url($avatar) : + common_default_avatar(AVATAR_STREAM_SIZE), + 'class' => 'avatar photo', + 'width' => AVATAR_STREAM_SIZE, + 'height' => AVATAR_STREAM_SIZE, + 'alt' => + ($this->profile->fullname) ? + $this->profile->fullname : + $this->profile->nickname)); } /** @@ -265,9 +297,8 @@ class NoticeListItem function showNickname() { - common_element('a', array('href' => $this->profile->profileurl, - 'class' => 'nickname fn url'), - $this->profile->nickname); + $this->out->element('span', array('class' => 'nickname fn'), + $this->profile->nickname); } /** @@ -283,31 +314,16 @@ class NoticeListItem function showContent() { // FIXME: URL, image, video, audio - common_element_start('p', array('class' => 'content entry-title')); + $this->out->elementStart('p', array('class' => 'entry-content')); if ($this->notice->rendered) { - common_raw($this->notice->rendered); + $this->out->raw($this->notice->rendered); } else { // XXX: may be some uncooked notices in the DB, // we cook them right now. This should probably disappear in future // versions (>> 0.4.x) - common_raw(common_render_content($this->notice->content, $this->notice)); + $this->out->raw(common_render_content($this->notice->content, $this->notice)); } - common_element_end('p'); - } - - /** - * show the "time" section of a notice - * - * This is the greyed-out section that appears beneath the content, including - * links to delete or reply to the notice. Probably should be called something - * else. - * - * @return void - */ - - function startTimeSection() - { - common_element_start('p', 'time'); + $this->out->elementEnd('p'); } /** @@ -328,14 +344,18 @@ class NoticeListItem preg_match('/^http/', $this->notice->uri)) { $noticeurl = $this->notice->uri; } - common_element_start('a', array('class' => 'permalink', - 'rel' => 'bookmark', - 'href' => $noticeurl)); + $this->out->elementStart('dl', 'timestamp'); + $this->out->element('dt', null, _('Published')); + $this->out->elementStart('dd', null); + $this->out->elementStart('a', array('rel' => 'bookmark', + 'href' => $noticeurl)); $dt = common_date_iso8601($this->notice->created); - common_element('abbr', array('class' => 'published', - 'title' => $dt), - common_date_string($this->notice->created)); - common_element_end('a'); + $this->out->element('abbr', array('class' => 'published', + 'title' => $dt), + common_date_string($this->notice->created)); + $this->out->elementEnd('a'); + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); } /** @@ -350,26 +370,31 @@ class NoticeListItem function showNoticeSource() { if ($this->notice->source) { - common_element('span', null, _(' from ')); + $this->out->elementStart('dl', 'device'); + $this->out->element('dt', null, _('From')); $source_name = _($this->notice->source); switch ($this->notice->source) { - case 'web': - case 'xmpp': - case 'mail': - case 'omb': - case 'api': - common_element('span', 'noticesource', $source_name); + case 'web': + case 'xmpp': + case 'mail': + case 'omb': + case 'api': + $this->out->element('dd', 'noticesource', $source_name); break; - default: + default: $ns = Notice_source::staticGet($this->notice->source); if ($ns) { - common_element('a', array('href' => $ns->url), - $ns->name); + $this->out->elementStart('dd', null); + $this->out->element('a', array('href' => $ns->url, + 'rel' => 'external'), + $ns->name); + $this->out->elementEnd('dd'); } else { - common_element('span', 'noticesource', $source_name); + $this->out->element('dd', 'noticesource', $source_name); } break; } + $this->out->elementEnd('dl'); } } @@ -387,11 +412,14 @@ class NoticeListItem if ($this->notice->reply_to) { $replyurl = common_local_url('shownotice', array('notice' => $this->notice->reply_to)); - common_text(' ('); - common_element('a', array('class' => 'inreplyto', - 'href' => $replyurl), - _('in reply to...')); - common_text(')'); + $this->out->elementStart('dl', 'response'); + $this->out->element('dt', null, _('To')); + $this->out->elementStart('dd'); + $this->out->element('a', array('href' => $replyurl, + 'rel' => 'in-reply-to'), + _('in reply to')); + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); } } @@ -409,16 +437,13 @@ class NoticeListItem $reply_url = common_local_url('newnotice', array('replyto' => $this->profile->nickname)); - $reply_js = - 'return doreply("'.$this->profile->nickname.'",'.$this->notice->id.');'; - - common_element_start('a', - array('href' => $reply_url, - 'onclick' => $reply_js, - 'title' => _('reply'), - 'class' => 'replybutton')); - common_raw(' →'); - common_element_end('a'); + $this->out->elementStart('dl', 'notice_reply'); + $this->out->element('dt', null, _('Reply to this notice')); + $this->out->elementStart('dd'); + $this->out->element('a', array('href' => $reply_url, + 'title' => _('Reply to this notice')), _('Reply')); + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); } /** @@ -433,26 +458,17 @@ class NoticeListItem if ($user && $this->notice->profile_id == $user->id) { $deleteurl = common_local_url('deletenotice', array('notice' => $this->notice->id)); - common_element_start('a', array('class' => 'deletenotice', - 'href' => $deleteurl, - 'title' => _('delete'))); - common_raw(' ×'); - common_element_end('a'); + $this->out->elementStart('dl', 'notice_delete'); + $this->out->element('dt', null, _('Delete this notice')); + $this->out->elementStart('dd'); + $this->out->element('a', array('href' => $deleteurl, + 'title' => _('Delete this notice')), _('Delete')); + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); } } /** - * end the time section - * - * @return void - */ - - function endTimeSection() - { - common_element_end('p'); - } - - /** * finish the notice * * Close the last elements in the notice list item @@ -462,6 +478,6 @@ class NoticeListItem function showEnd() { - common_element_end('li'); + $this->out->elementEnd('li'); } } |