From 20af1927967592e56189f48d88d82fad989870ca Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 23 Dec 2008 14:08:51 -0500 Subject: bring lib/noticelist.php into line with PEAR code standards darcs-hash:20081223190851-84dde-ecad63595159aca2ae014325c9af29a9ace21c3d.gz --- lib/noticelist.php | 567 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 405 insertions(+), 162 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index 415c062e4..c9344a716 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -1,173 +1,366 @@ . + * along with this program. If not, see . + * + * @category UI + * @package Laconica + * @author Evan Prodromou + * @copyright 2008 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} + +/** + * widget for displaying a list of notices + * + * There are a number of actions that display a list of notices, in + * reverse chronological order. This widget abstracts out most of the + * code for UI for notice lists. It's overridden to hide some + * data for e.g. the profile page. + * + * @category UI + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * @see Notice + * @see StreamAction + * @see NoticeListItem + * @see ProfileNoticeList + */ -class NoticeList { +class NoticeList +{ + /** the current stream of notices being displayed. */ - var $notice = NULL; + var $notice = null; - function __construct($notice) { + /** + * constructor + * + * @param Notice $notice stream of notices from DB_DataObject + */ + + function __construct($notice) + { $this->notice = $notice; } - function show() { + /** + * show the list of notices + * + * "Uses up" the stream by looping through it. So, probably can't + * be called twice on the same list. + * + * @return int count of notices listed. + */ - common_element_start('ul', array('id' => 'notices')); + function show() + { + common_element_start('ul', array('id' => 'notices')); - $cnt = 0; + $cnt = 0; - while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) { - $cnt++; + while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) { + $cnt++; - if ($cnt > NOTICES_PER_PAGE) { - break; - } + if ($cnt > NOTICES_PER_PAGE) { + break; + } - $item = $this->new_list_item($this->notice); + $item = $this->newListItem($this->notice); $item->show(); - } + } - common_element_end('ul'); + common_element_end('ul'); return $cnt; - } + } - function new_list_item($notice) { + /** + * returns a new list item for the current notice + * + * Recipe (factory?) method; overridden by sub-classes to give + * a different list item class. + * + * @param Notice $notice the current notice + * + * @return NoticeListItem a list item for displaying the notice + */ + + function newListItem($notice) + { return new NoticeListItem($notice); } } -class NoticeListItem { +/** + * widget for displaying a single notice + * + * This widget has the core smarts for showing a single notice: what to display, + * where, and under which circumstances. Its key method is show(); this is a recipe + * that calls all the other show*() methods to build up a single notice. The + * ProfileNoticeListItem subclass, for example, overrides showAuthor() to skip + * author info (since that's implicit by the data in the page). + * + * @category UI + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * @see NoticeList + * @see ProfileNoticeListItem + */ + +class NoticeListItem +{ + /** The notice this item will show. */ - var $notice = NULL; - var $profile = NULL; + var $notice = null; - function __construct($notice) { - $this->notice = $notice; - $this->profile = $notice->getProfile(); - } - - function show() { - $this->show_start(); - $this->show_fave_form(); - $this->show_author(); - $this->show_content(); - $this->show_start_time_section(); - $this->show_notice_link(); - $this->show_notice_source(); - $this->show_reply_to(); - $this->show_reply_link(); - $this->show_delete_link(); - $this->show_end_time_section(); - $this->show_end(); - } - - function show_start() { - # XXX: RDFa - common_element_start('li', array('class' => 'notice_single hentry', - 'id' => 'notice-' . $this->notice->id)); - } - - function show_fave_form() { + /** The profile of the author of the notice, extracted once for convenience. */ + + var $profile = null; + + /** + * constructor + * + * Also initializes the profile attribute. + * + * @param Notice $notice The notice we'll display + */ + + function __construct($notice) + { + $this->notice = $notice; + $this->profile = $notice->getProfile(); + } + + /** + * recipe function for displaying a single notice. + * + * This uses all the other methods to correctly display a notice. Override + * it or one of the others to fine-tune the output. + * + * @return void + */ + + function show() + { + $this->showStart(); + $this->showFaveForm(); + $this->showAuthor(); + $this->showContent(); + $this->startTimeSection(); + $this->showNoticeLink(); + $this->showNoticeSource(); + $this->showReplyTo(); + $this->showReplyLink(); + $this->showDeleteLink(); + $this->endTimeSection(); + $this->showEnd(); + } + + /** + * start a single notice. + * + * @return void + */ + + function showStart() + { + // XXX: RDFa + common_element_start('li', array('class' => 'notice_single hentry', + 'id' => 'notice-' . $this->notice->id)); + } + + /** + * show the "favorite" form + * + * @return void + */ + + function showFaveForm() + { $user = common_current_user(); - if ($user) { - if ($user->hasFave($this->notice)) { - common_disfavor_form($this->notice); - } else { - common_favor_form($this->notice); - } - } - } - - function show_author() { - common_element_start('span', 'vcard author'); - $this->show_avatar(); - $this->show_nickname(); - common_element_end('span'); - } - - function show_avatar() { - $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'); - } - - function show_nickname() { - common_element('a', array('href' => $this->profile->profileurl, - 'class' => 'nickname fn url'), - $this->profile->nickname); - } - - function show_content() { - # FIXME: URL, image, video, audio - common_element_start('p', array('class' => 'content entry-title')); - if ($this->notice->rendered) { - common_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)); - } - common_element_end('p'); - } - - function show_start_time_section() { - common_element_start('p', 'time'); - } - - function show_notice_link() { - $noticeurl = common_local_url('shownotice', array('notice' => $this->notice->id)); - # XXX: we need to figure this out better. Is this right? - if (strcmp($this->notice->uri, $noticeurl) != 0 && preg_match('/^http/', $this->notice->uri)) { - $noticeurl = $this->notice->uri; - } - common_element_start('a', array('class' => 'permalink', - 'rel' => 'bookmark', - 'href' => $noticeurl)); - common_element('abbr', array('class' => 'published', - 'title' => common_date_iso8601($this->notice->created)), - common_date_string($this->notice->created)); - common_element_end('a'); - } - - function show_notice_source() { - if ($this->notice->source) { - common_element('span', null, _(' from ')); + if ($user) { + if ($user->hasFave($this->notice)) { + common_disfavor_form($this->notice); + } else { + common_favor_form($this->notice); + } + } + } + + /** + * show the author of a notice + * + * By default, this shows the avatar and (linked) nickname of the author. + * + * @return void + */ + + function showAuthor() + { + common_element_start('span', 'vcard author'); + $this->showAvatar(); + $this->showNickname(); + common_element_end('span'); + } + + /** + * show the avatar of the notice's author + * + * This will use the default avatar if no avatar is assigned for the author. + * It makes a link to the author's profile. + * + * @return void + */ + + 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'); + } + + /** + * show the nickname of the author + * + * Links to the author's profile page + * + * @return void + */ + + function showNickname() + { + common_element('a', array('href' => $this->profile->profileurl, + 'class' => 'nickname fn url'), + $this->profile->nickname); + } + + /** + * show the content of the notice + * + * Shows the content of the notice. This is pre-rendered for efficiency + * at save time. Some very old notices might not be pre-rendered, so + * they're rendered on the spot. + * + * @return void + */ + + function showContent() + { + // FIXME: URL, image, video, audio + common_element_start('p', array('class' => 'content entry-title')); + if ($this->notice->rendered) { + common_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)); + } + 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'); + } + + /** + * show the link to the main page for the notice + * + * Displays a link to the page for a notice, with "relative" time. Tries to + * get remote notice URLs correct, but doesn't always succeed. + * + * @return void + */ + + function showNoticeLink() + { + $noticeurl = common_local_url('shownotice', + array('notice' => $this->notice->id)); + // XXX: we need to figure this out better. Is this right? + if (strcmp($this->notice->uri, $noticeurl) != 0 && + preg_match('/^http/', $this->notice->uri)) { + $noticeurl = $this->notice->uri; + } + common_element_start('a', array('class' => 'permalink', + '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'); + } + + /** + * Show the source of the notice + * + * Either the name (and link) of the API client that posted the notice, + * or one of other other channels. + * + * @return void + */ + + function showNoticeSource() + { + if ($this->notice->source) { + common_element('span', null, _(' from ')); $source_name = _($this->notice->source); switch ($this->notice->source) { - case 'web': - case 'xmpp': - case 'mail': - case 'omb': - case 'api': + case 'web': + case 'xmpp': + case 'mail': + case 'omb': + case 'api': common_element('span', 'noticesource', $source_name); break; - default: + default: $ns = Notice_source::staticGet($this->notice->source); if ($ns) { common_element('a', array('href' => $ns->url), @@ -177,48 +370,98 @@ class NoticeListItem { } break; } - } + } } - function show_reply_to() { - 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(')'); - } + /** + * show link to notice this notice is a reply to + * + * If this notice is a reply, show a link to the notice it is replying to. The + * heavy lifting for figuring out replies happens at save time. + * + * @return void + */ + + function showReplyTo() + { + 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(')'); + } } - function show_reply_link() { - common_element_start('a', - array('href' => common_local_url('newnotice', - array('replyto' => $this->profile->nickname)), - 'onclick' => 'return doreply("'.$this->profile->nickname.'", '.$this->notice->id.');', - 'title' => _('reply'), - 'class' => 'replybutton')); - common_raw(' →'); - common_element_end('a'); + /** + * show a link to reply to the current notice + * + * Should either do the reply in the current notice form (if available), or + * link out to the notice-posting form. A little flakey, doesn't always work. + * + * @return void + */ + + function showReplyLink() + { + $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'); } - function show_delete_link() { + /** + * if the user is the author, let them delete the notice + * + * @return void + */ + + function showDeleteLink() + { $user = common_current_user(); - 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'); - } + 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'); + } } - function show_end_time_section() { - common_element_end('p'); + /** + * end the time section + * + * @return void + */ + + function endTimeSection() + { + common_element_end('p'); } - function show_end() { - common_element_end('li'); + /** + * finish the notice + * + * Close the last elements in the notice list item + * + * @return void + */ + + function showEnd() + { + common_element_end('li'); } } -- cgit v1.2.3-54-g00ecf From 17ece0777b22b15c60b27b32f0f7e24ecc447661 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 23 Dec 2008 14:14:30 -0500 Subject: incorrect label on notice list file comment darcs-hash:20081223191430-84dde-7f50fbf9c39c3f397196ffca318d51de6624d7c9.gz --- _darcs/inventory | 4 +- ...dde-7f50fbf9c39c3f397196ffca318d51de6624d7c9.gz | Bin 0 -> 173 bytes _darcs/pristine/lib/noticelist.php | 2 +- _darcs/tentative_pristine | 575 +-------------------- lib/noticelist.php | 2 +- 5 files changed, 6 insertions(+), 577 deletions(-) create mode 100644 _darcs/patches/20081223191430-84dde-7f50fbf9c39c3f397196ffca318d51de6624d7c9.gz (limited to 'lib/noticelist.php') diff --git a/_darcs/inventory b/_darcs/inventory index b1d1b1e70..c66eff2b7 100644 --- a/_darcs/inventory +++ b/_darcs/inventory @@ -47,4 +47,6 @@ Evan Prodromou **20081222201304 [reformat and document lib/mail.php for phpcs conformance Evan Prodromou **20081223173330] [bring lib/noticelist.php into line with PEAR code standards -Evan Prodromou **20081223190851] \ No newline at end of file +Evan Prodromou **20081223190851] +[incorrect label on notice list file comment +Evan Prodromou **20081223191430] \ No newline at end of file diff --git a/_darcs/patches/20081223191430-84dde-7f50fbf9c39c3f397196ffca318d51de6624d7c9.gz b/_darcs/patches/20081223191430-84dde-7f50fbf9c39c3f397196ffca318d51de6624d7c9.gz new file mode 100644 index 000000000..1d39cc7a1 Binary files /dev/null and b/_darcs/patches/20081223191430-84dde-7f50fbf9c39c3f397196ffca318d51de6624d7c9.gz differ diff --git a/_darcs/pristine/lib/noticelist.php b/_darcs/pristine/lib/noticelist.php index c9344a716..71db067d0 100644 --- a/_darcs/pristine/lib/noticelist.php +++ b/_darcs/pristine/lib/noticelist.php @@ -2,7 +2,7 @@ /** * Laconica, the distributed open-source microblogging tool * - * utilities for sending email + * widget for displaying a list of notices * * PHP version 5 * diff --git a/_darcs/tentative_pristine b/_darcs/tentative_pristine index e7d3612c8..e09c8fa72 100644 --- a/_darcs/tentative_pristine +++ b/_darcs/tentative_pristine @@ -1,576 +1,3 @@ -hunk ./actions/showstream.php 441 -- function new_list_item($notice) { -+ function newListItem($notice) { -hunk ./actions/showstream.php 447 -- function show_author() { -+ function showAuthor() { -hunk ./lib/noticelist.php 2 --/* -- * Laconica - a distributed open-source microblogging tool -- * Copyright (C) 2008, Controlez-Vous, Inc. -+/** -+ * Laconica, the distributed open-source microblogging tool hunk ./lib/noticelist.php 5 -- * This program is free software: you can redistribute it and/or modify -+ * utilities for sending email -+ * -+ * PHP version 5 -+ * -+ * LICENCE: This program is free software: you can redistribute it and/or modify -hunk ./lib/noticelist.php 16 -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -hunk ./lib/noticelist.php 20 -- * along with this program. If not, see . -+ * along with this program. If not, see . -+ * -+ * @category UI -+ * @package Laconica -+ * @author Evan Prodromou -+ * @copyright 2008 Control Yourself, Inc. -+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 -+ * @link http://laconi.ca/ -+ */ -+ -+if (!defined('LACONICA')) { -+ exit(1); -+} -+ -+/** +- * utilities for sending email + * widget for displaying a list of notices -+ * -+ * There are a number of actions that display a list of notices, in -+ * reverse chronological order. This widget abstracts out most of the -+ * code for UI for notice lists. It's overridden to hide some -+ * data for e.g. the profile page. -+ * -+ * @category UI -+ * @package Laconica -+ * @author Evan Prodromou -+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 -+ * @link http://laconi.ca/ -+ * @see Notice -+ * @see StreamAction -+ * @see NoticeListItem -+ * @see ProfileNoticeList -hunk ./lib/noticelist.php 53 --if (!defined('LACONICA')) { exit(1); } -+class NoticeList -+{ -+ /** the current stream of notices being displayed. */ -hunk ./lib/noticelist.php 57 --class NoticeList { -+ var $notice = null; -hunk ./lib/noticelist.php 59 -- var $notice = NULL; -+ /** -+ * constructor -+ * -+ * @param Notice $notice stream of notices from DB_DataObject -+ */ -hunk ./lib/noticelist.php 65 -- function __construct($notice) { -+ function __construct($notice) -+ { -hunk ./lib/noticelist.php 70 -- function show() { -+ /** -+ * show the list of notices -+ * -+ * "Uses up" the stream by looping through it. So, probably can't -+ * be called twice on the same list. -+ * -+ * @return int count of notices listed. -+ */ -hunk ./lib/noticelist.php 79 -- common_element_start('ul', array('id' => 'notices')); -+ function show() -+ { -+ common_element_start('ul', array('id' => 'notices')); -hunk ./lib/noticelist.php 83 -- $cnt = 0; -+ $cnt = 0; -hunk ./lib/noticelist.php 85 -- while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) { -- $cnt++; -+ while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) { -+ $cnt++; -hunk ./lib/noticelist.php 88 -- if ($cnt > NOTICES_PER_PAGE) { -- break; -- } -+ if ($cnt > NOTICES_PER_PAGE) { -+ break; -+ } -hunk ./lib/noticelist.php 92 -- $item = $this->new_list_item($this->notice); -+ $item = $this->newListItem($this->notice); -hunk ./lib/noticelist.php 94 -- } -+ } -hunk ./lib/noticelist.php 96 -- common_element_end('ul'); -+ common_element_end('ul'); -hunk ./lib/noticelist.php 99 -- } -+ } -+ -+ /** -+ * returns a new list item for the current notice -+ * -+ * Recipe (factory?) method; overridden by sub-classes to give -+ * a different list item class. -+ * -+ * @param Notice $notice the current notice -+ * -+ * @return NoticeListItem a list item for displaying the notice -+ */ -hunk ./lib/noticelist.php 112 -- function new_list_item($notice) { -+ function newListItem($notice) -+ { -hunk ./lib/noticelist.php 118 --class NoticeListItem { -+/** -+ * widget for displaying a single notice -+ * -+ * This widget has the core smarts for showing a single notice: what to display, -+ * where, and under which circumstances. Its key method is show(); this is a recipe -+ * that calls all the other show*() methods to build up a single notice. The -+ * ProfileNoticeListItem subclass, for example, overrides showAuthor() to skip -+ * author info (since that's implicit by the data in the page). -+ * -+ * @category UI -+ * @package Laconica -+ * @author Evan Prodromou -+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 -+ * @link http://laconi.ca/ -+ * @see NoticeList -+ * @see ProfileNoticeListItem -+ */ -+ -+class NoticeListItem -+{ -+ /** The notice this item will show. */ -hunk ./lib/noticelist.php 140 -- var $notice = NULL; -- var $profile = NULL; -+ var $notice = null; -hunk ./lib/noticelist.php 142 -- function __construct($notice) { -- $this->notice = $notice; -- $this->profile = $notice->getProfile(); -+ /** The profile of the author of the notice, extracted once for convenience. */ -+ -+ var $profile = null; -+ -+ /** -+ * constructor -+ * -+ * Also initializes the profile attribute. -+ * -+ * @param Notice $notice The notice we'll display -+ */ -+ -+ function __construct($notice) -+ { -+ $this->notice = $notice; -+ $this->profile = $notice->getProfile(); -hunk ./lib/noticelist.php 160 -- function show() { -- $this->show_start(); -- $this->show_fave_form(); -- $this->show_author(); -- $this->show_content(); -- $this->show_start_time_section(); -- $this->show_notice_link(); -- $this->show_notice_source(); -- $this->show_reply_to(); -- $this->show_reply_link(); -- $this->show_delete_link(); -- $this->show_end_time_section(); -- $this->show_end(); -- } -+ /** -+ * recipe function for displaying a single notice. -+ * -+ * This uses all the other methods to correctly display a notice. Override -+ * it or one of the others to fine-tune the output. -+ * -+ * @return void -+ */ -hunk ./lib/noticelist.php 169 -- function show_start() { -- # XXX: RDFa -- common_element_start('li', array('class' => 'notice_single hentry', -- 'id' => 'notice-' . $this->notice->id)); -+ function show() -+ { -+ $this->showStart(); -+ $this->showFaveForm(); -+ $this->showAuthor(); -+ $this->showContent(); -+ $this->startTimeSection(); -+ $this->showNoticeLink(); -+ $this->showNoticeSource(); -+ $this->showReplyTo(); -+ $this->showReplyLink(); -+ $this->showDeleteLink(); -+ $this->endTimeSection(); -+ $this->showEnd(); -hunk ./lib/noticelist.php 185 -- function show_fave_form() { -+ /** -+ * start a single notice. -+ * -+ * @return void -+ */ -+ -+ function showStart() -+ { -+ // XXX: RDFa -+ common_element_start('li', array('class' => 'notice_single hentry', -+ 'id' => 'notice-' . $this->notice->id)); -+ } -+ -+ /** -+ * show the "favorite" form -+ * -+ * @return void -+ */ -+ -+ function showFaveForm() -+ { -hunk ./lib/noticelist.php 207 -- if ($user) { -- if ($user->hasFave($this->notice)) { -- common_disfavor_form($this->notice); -- } else { -- common_favor_form($this->notice); -- } -- } -+ if ($user) { -+ if ($user->hasFave($this->notice)) { -+ common_disfavor_form($this->notice); -+ } else { -+ common_favor_form($this->notice); -+ } -+ } -hunk ./lib/noticelist.php 216 -- function show_author() { -- common_element_start('span', 'vcard author'); -- $this->show_avatar(); -- $this->show_nickname(); -- common_element_end('span'); -+ /** -+ * show the author of a notice -+ * -+ * By default, this shows the avatar and (linked) nickname of the author. -+ * -+ * @return void -+ */ -+ -+ function showAuthor() -+ { -+ common_element_start('span', 'vcard author'); -+ $this->showAvatar(); -+ $this->showNickname(); -+ common_element_end('span'); -hunk ./lib/noticelist.php 232 -- function show_avatar() { -- $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'); -+ /** -+ * show the avatar of the notice's author -+ * -+ * This will use the default avatar if no avatar is assigned for the author. -+ * It makes a link to the author's profile. -+ * -+ * @return void -+ */ -+ -+ 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'); -hunk ./lib/noticelist.php 258 -- function show_nickname() { -- common_element('a', array('href' => $this->profile->profileurl, -- 'class' => 'nickname fn url'), -- $this->profile->nickname); -+ /** -+ * show the nickname of the author -+ * -+ * Links to the author's profile page -+ * -+ * @return void -+ */ -+ -+ function showNickname() -+ { -+ common_element('a', array('href' => $this->profile->profileurl, -+ 'class' => 'nickname fn url'), -+ $this->profile->nickname); -hunk ./lib/noticelist.php 273 -- function show_content() { -- # FIXME: URL, image, video, audio -- common_element_start('p', array('class' => 'content entry-title')); -- if ($this->notice->rendered) { -- common_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)); -- } -- common_element_end('p'); -+ /** -+ * show the content of the notice -+ * -+ * Shows the content of the notice. This is pre-rendered for efficiency -+ * at save time. Some very old notices might not be pre-rendered, so -+ * they're rendered on the spot. -+ * -+ * @return void -+ */ -+ -+ function showContent() -+ { -+ // FIXME: URL, image, video, audio -+ common_element_start('p', array('class' => 'content entry-title')); -+ if ($this->notice->rendered) { -+ common_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)); -+ } -+ common_element_end('p'); -hunk ./lib/noticelist.php 298 -- function show_start_time_section() { -- common_element_start('p', 'time'); -+ /** -+ * 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'); -hunk ./lib/noticelist.php 313 -- function show_notice_link() { -- $noticeurl = common_local_url('shownotice', array('notice' => $this->notice->id)); -- # XXX: we need to figure this out better. Is this right? -- if (strcmp($this->notice->uri, $noticeurl) != 0 && preg_match('/^http/', $this->notice->uri)) { -- $noticeurl = $this->notice->uri; -- } -- common_element_start('a', array('class' => 'permalink', -- 'rel' => 'bookmark', -- 'href' => $noticeurl)); -- common_element('abbr', array('class' => 'published', -- 'title' => common_date_iso8601($this->notice->created)), -- common_date_string($this->notice->created)); -- common_element_end('a'); -+ /** -+ * show the link to the main page for the notice -+ * -+ * Displays a link to the page for a notice, with "relative" time. Tries to -+ * get remote notice URLs correct, but doesn't always succeed. -+ * -+ * @return void -+ */ -+ -+ function showNoticeLink() -+ { -+ $noticeurl = common_local_url('shownotice', -+ array('notice' => $this->notice->id)); -+ // XXX: we need to figure this out better. Is this right? -+ if (strcmp($this->notice->uri, $noticeurl) != 0 && -+ preg_match('/^http/', $this->notice->uri)) { -+ $noticeurl = $this->notice->uri; -+ } -+ common_element_start('a', array('class' => 'permalink', -+ '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'); -hunk ./lib/noticelist.php 341 -- function show_notice_source() { -- if ($this->notice->source) { -- common_element('span', null, _(' from ')); -+ /** -+ * Show the source of the notice -+ * -+ * Either the name (and link) of the API client that posted the notice, -+ * or one of other other channels. -+ * -+ * @return void -+ */ -+ -+ function showNoticeSource() -+ { -+ if ($this->notice->source) { -+ common_element('span', null, _(' from ')); -hunk ./lib/noticelist.php 356 -- case 'web': -- case 'xmpp': -- case 'mail': -- case 'omb': -- case 'api': -+ case 'web': -+ case 'xmpp': -+ case 'mail': -+ case 'omb': -+ case 'api': -hunk ./lib/noticelist.php 363 -- default: -+ default: -hunk ./lib/noticelist.php 373 -- } -+ } -hunk ./lib/noticelist.php 376 -- function show_reply_to() { -- 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(')'); -- } -+ /** -+ * show link to notice this notice is a reply to -+ * -+ * If this notice is a reply, show a link to the notice it is replying to. The -+ * heavy lifting for figuring out replies happens at save time. -+ * -+ * @return void -+ */ -+ -+ function showReplyTo() -+ { -+ 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(')'); -+ } -hunk ./lib/noticelist.php 398 -- function show_reply_link() { -- common_element_start('a', -- array('href' => common_local_url('newnotice', -- array('replyto' => $this->profile->nickname)), -- 'onclick' => 'return doreply("'.$this->profile->nickname.'", '.$this->notice->id.');', -- 'title' => _('reply'), -- 'class' => 'replybutton')); -- common_raw(' →'); -- common_element_end('a'); -+ /** -+ * show a link to reply to the current notice -+ * -+ * Should either do the reply in the current notice form (if available), or -+ * link out to the notice-posting form. A little flakey, doesn't always work. -+ * -+ * @return void -+ */ -+ -+ function showReplyLink() -+ { -+ $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'); -hunk ./lib/noticelist.php 424 -- function show_delete_link() { -+ /** -+ * if the user is the author, let them delete the notice -+ * -+ * @return void -+ */ -+ -+ function showDeleteLink() -+ { -hunk ./lib/noticelist.php 433 -- 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'); -- } -+ 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'); -+ } -hunk ./lib/noticelist.php 444 -- function show_end_time_section() { -- common_element_end('p'); -+ /** -+ * end the time section -+ * -+ * @return void -+ */ -+ -+ function endTimeSection() -+ { -+ common_element_end('p'); -hunk ./lib/noticelist.php 455 -- function show_end() { -- common_element_end('li'); -+ /** -+ * finish the notice -+ * -+ * Close the last elements in the notice list item -+ * -+ * @return void -+ */ -+ -+ function showEnd() -+ { -+ common_element_end('li'); diff --git a/lib/noticelist.php b/lib/noticelist.php index c9344a716..71db067d0 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -2,7 +2,7 @@ /** * Laconica, the distributed open-source microblogging tool * - * utilities for sending email + * widget for displaying a list of notices * * PHP version 5 * -- cgit v1.2.3-54-g00ecf From 442dcfde0e998e7bc2936a28805629951208ce38 Mon Sep 17 00:00:00 2001 From: sarven Date: Thu, 15 Jan 2009 00:03:06 +0000 Subject: showAuthor() minor update. Using a single anchor to wrap both avatar and nickname instead of two anchors. --- lib/noticelist.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index 71db067d0..45d4abb29 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -191,7 +191,8 @@ class NoticeListItem function showStart() { // XXX: RDFa - common_element_start('li', array('class' => 'notice_single hentry', + // TODO: add notice_type class e.g., notice_video, notice_image + common_element_start('li', array('class' => 'hentry notice', 'id' => 'notice-' . $this->notice->id)); } @@ -224,8 +225,11 @@ class NoticeListItem function showAuthor() { common_element_start('span', 'vcard author'); + common_element_start('a', array('href' => $this->profile->profileurl), + 'class' => 'url'); $this->showAvatar(); $this->showNickname(); + common_element_end('a'); common_element_end('span'); } @@ -241,18 +245,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', + 'class' => 'avatar photo', 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'alt' => ($this->profile->fullname) ? $this->profile->fullname : $this->profile->nickname)); - common_element_end('a'); } /** @@ -265,8 +268,7 @@ class NoticeListItem function showNickname() { - common_element('a', array('href' => $this->profile->profileurl, - 'class' => 'nickname fn url'), + common_element('span', array('class' => 'nickname fn'), $this->profile->nickname); } -- cgit v1.2.3-54-g00ecf From 46b1e2fcec9ff084496a4ac11a65c1673f92e1f0 Mon Sep 17 00:00:00 2001 From: sarven Date: Thu, 15 Jan 2009 00:21:59 +0000 Subject: showReplyTo() update --- lib/noticelist.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index 45d4abb29..0fe967da3 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -389,11 +389,15 @@ 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', + $this->elementStart('dl', 'response'); + $this->element('dt', null, _('To')); + $this->elementStart('dd'); + $this->element('a', array('class' => 'inreplyto', 'href' => $replyurl), - _('in reply to...')); - common_text(')'); + 'rel' => 'in-reply-to', + _('in reply to')); + $this->elementEnd('dd'); + $this->elementEnd('dl'); } } -- cgit v1.2.3-54-g00ecf From 35645308dc76527f6c0087887e693869f53f7f0b Mon Sep 17 00:00:00 2001 From: sarven Date: Thu, 15 Jan 2009 00:30:06 +0000 Subject: Updated: showNoticeSource() showReplyTo() --- lib/noticelist.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index 0fe967da3..b4ea4d41c 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -225,8 +225,8 @@ class NoticeListItem function showAuthor() { common_element_start('span', 'vcard author'); - common_element_start('a', array('href' => $this->profile->profileurl), - 'class' => 'url'); + common_element_start('a', array('href' => $this->profile->profileurl, + 'class' => 'url')); $this->showAvatar(); $this->showNickname(); common_element_end('a'); @@ -352,7 +352,8 @@ class NoticeListItem function showNoticeSource() { if ($this->notice->source) { - common_element('span', null, _(' from ')); + $this->elementStart('dl', 'device'); + $this->element('dt', null, _('From')); $source_name = _($this->notice->source); switch ($this->notice->source) { case 'web': @@ -360,18 +361,22 @@ class NoticeListItem case 'mail': case 'omb': case 'api': - common_element('span', 'noticesource', $source_name); + $this->element('dd', 'noticesource', $source_name); break; default: $ns = Notice_source::staticGet($this->notice->source); if ($ns) { - common_element('a', array('href' => $ns->url), + $this->elementStart('dd', null); + $this->element('a', array('href' => $ns->url, + 'rel' => 'external'), $ns->name); + $this->elementEnd('dd'); } else { - common_element('span', 'noticesource', $source_name); + $this->element('dd', 'noticesource', $source_name); } break; } + $this->elementEnd('dl'); } } @@ -393,8 +398,8 @@ class NoticeListItem $this->element('dt', null, _('To')); $this->elementStart('dd'); $this->element('a', array('class' => 'inreplyto', - 'href' => $replyurl), - 'rel' => 'in-reply-to', + 'href' => $replyurl, + 'rel' => 'in-reply-to'), _('in reply to')); $this->elementEnd('dd'); $this->elementEnd('dl'); -- cgit v1.2.3-54-g00ecf From c50a6bc52351454a77a99f3005a8f6fd404bb3a5 Mon Sep 17 00:00:00 2001 From: sarven Date: Thu, 15 Jan 2009 00:36:17 +0000 Subject: Updated: showNoticeLink() --- lib/noticelist.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index b4ea4d41c..26aa7ed33 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -330,14 +330,18 @@ class NoticeListItem preg_match('/^http/', $this->notice->uri)) { $noticeurl = $this->notice->uri; } - common_element_start('a', array('class' => 'permalink', - 'rel' => 'bookmark', + $this->elementStart('dl', 'timestamp'); + $this->element('dt', _('Published')); + $this->elementStart('dd', null); + $this->element('a', array('rel' => 'bookmark', 'href' => $noticeurl)); $dt = common_date_iso8601($this->notice->created); - common_element('abbr', array('class' => 'published', + $this->element('abbr', array('class' => 'published', 'title' => $dt), common_date_string($this->notice->created)); - common_element_end('a'); + $this->elementEnd('a'); + $this->elementEnd('dd'); + $this->elementEnd('dl'); } /** @@ -397,8 +401,7 @@ class NoticeListItem $this->elementStart('dl', 'response'); $this->element('dt', null, _('To')); $this->elementStart('dd'); - $this->element('a', array('class' => 'inreplyto', - 'href' => $replyurl, + $this->element('a', array('href' => $replyurl, 'rel' => 'in-reply-to'), _('in reply to')); $this->elementEnd('dd'); -- cgit v1.2.3-54-g00ecf From 1b66ac64b79326a55ca987e8bcc35d552c9a0be9 Mon Sep 17 00:00:00 2001 From: sarven Date: Thu, 15 Jan 2009 00:54:16 +0000 Subject: Refactored show() into showNotice(), showNoticeInfo(), showNoticeOptions(). Kept the existing naming convention for the rest of the methods the same for now. --- lib/noticelist.php | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index 26aa7ed33..fe5a6eb8a 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -169,17 +169,36 @@ class NoticeListItem function show() { $this->showStart(); - $this->showFaveForm(); + $this->showNotice(); + $this->showNoticeInfo(); + $this->showNoticeOptions(); + $this->showEnd(); + } + + function showNotice() + { + $this->elementStart('div', 'entry-title'); $this->showAuthor(); - $this->showContent(); - $this->startTimeSection(); + $this->showNoticeContent(); + $this->elementEnd('div'); + } + + function showNoticeInfo() + { + $this->elementStart('div', 'entry-content'); $this->showNoticeLink(); $this->showNoticeSource(); $this->showReplyTo(); + $this->elementEnd('div'); + } + + function showNoticeOptions() + { + $this->elementStart('div', 'notice-options'); + $this->showFaveForm(); $this->showReplyLink(); $this->showDeleteLink(); - $this->endTimeSection(); - $this->showEnd(); + $this->elementEnd('div'); } /** -- cgit v1.2.3-54-g00ecf From 901b2acc9f3a9718e3707d69743c26178aff9e8a Mon Sep 17 00:00:00 2001 From: sarven Date: Thu, 15 Jan 2009 00:57:01 +0000 Subject: Resaved. --- lib/noticelist.php | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index fe5a6eb8a..be3128b4b 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -179,7 +179,7 @@ class NoticeListItem { $this->elementStart('div', 'entry-title'); $this->showAuthor(); - $this->showNoticeContent(); + $this->showContent(); $this->elementEnd('div'); } @@ -201,6 +201,7 @@ class NoticeListItem $this->elementEnd('div'); } + /** * start a single notice. * @@ -243,13 +244,13 @@ class NoticeListItem function showAuthor() { - common_element_start('span', 'vcard author'); - common_element_start('a', array('href' => $this->profile->profileurl, + $this->elementStart('span', 'vcard author'); + $this->elementStart('a', array('href' => $this->profile->profileurl, 'class' => 'url')); $this->showAvatar(); $this->showNickname(); - common_element_end('a'); - common_element_end('span'); + $this->elementEnd('a'); + $this->elementEnd('span'); } /** @@ -265,7 +266,7 @@ class NoticeListItem { $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE); - common_element('img', array('src' => ($avatar) ? + $this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE), 'class' => 'avatar photo', @@ -287,7 +288,7 @@ class NoticeListItem function showNickname() { - common_element('span', array('class' => 'nickname fn'), + $this->element('span', array('class' => 'nickname fn'), $this->profile->nickname); } @@ -304,7 +305,7 @@ class NoticeListItem function showContent() { // FIXME: URL, image, video, audio - common_element_start('p', array('class' => 'content entry-title')); + common_element_start('p', array('class' => 'entry-content')); if ($this->notice->rendered) { common_raw($this->notice->rendered); } else { @@ -316,21 +317,6 @@ class NoticeListItem 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'); - } - /** * show the link to the main page for the notice * @@ -474,17 +460,6 @@ class NoticeListItem } } - /** - * end the time section - * - * @return void - */ - - function endTimeSection() - { - common_element_end('p'); - } - /** * finish the notice * -- cgit v1.2.3-54-g00ecf From 082db2ad7d6005859bdb70b1b37d3945c49f03bd Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 20:19:32 +0000 Subject: A little further with notice lists --- actions/public.php | 3 +- lib/noticelist.php | 108 +++++++++++++++++++++++++++-------------------------- 2 files changed, 57 insertions(+), 54 deletions(-) (limited to 'lib/noticelist.php') diff --git a/actions/public.php b/actions/public.php index b13678bf0..76e922dff 100644 --- a/actions/public.php +++ b/actions/public.php @@ -32,6 +32,7 @@ if (!defined('LACONICA')) { } require_once INSTALLDIR.'/lib/publicgroupnav.php'; +require_once INSTALLDIR.'/lib/noticelist.php'; /** * Action for displaying the public stream @@ -167,7 +168,7 @@ class PublicAction extends Action return; } - $nl = new NoticeList($notice); + $nl = new NoticeList($notice, $this); $cnt = $nl->show(); diff --git a/lib/noticelist.php b/lib/noticelist.php index be3128b4b..fb3e66f9f 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -50,7 +50,7 @@ if (!defined('LACONICA')) { * @see ProfileNoticeList */ -class NoticeList +class NoticeList extends Widget { /** the current stream of notices being displayed. */ @@ -62,8 +62,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 +79,7 @@ class NoticeList function show() { - common_element_start('ul', array('id' => 'notices')); + $this->out->elementStart('ul', array('id' => 'notices')); $cnt = 0; @@ -93,7 +94,7 @@ class NoticeList $item->show(); } - common_element_end('ul'); + $this->out->elementEnd('ul'); return $cnt; } @@ -111,7 +112,7 @@ class NoticeList function newListItem($notice) { - return new NoticeListItem($notice); + return new NoticeListItem($notice, $this->out); } } @@ -133,7 +134,7 @@ class NoticeList * @see ProfileNoticeListItem */ -class NoticeListItem +class NoticeListItem extends Widget { /** The notice this item will show. */ @@ -151,8 +152,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(); } @@ -177,28 +179,28 @@ class NoticeListItem function showNotice() { - $this->elementStart('div', 'entry-title'); + $this->out->elementStart('div', 'entry-title'); $this->showAuthor(); $this->showContent(); - $this->elementEnd('div'); + $this->out->elementEnd('div'); } function showNoticeInfo() { - $this->elementStart('div', 'entry-content'); + $this->out->elementStart('div', 'entry-content'); $this->showNoticeLink(); $this->showNoticeSource(); $this->showReplyTo(); - $this->elementEnd('div'); + $this->out->elementEnd('div'); } function showNoticeOptions() { - $this->elementStart('div', 'notice-options'); + $this->out->elementStart('div', 'notice-options'); $this->showFaveForm(); $this->showReplyLink(); $this->showDeleteLink(); - $this->elementEnd('div'); + $this->out->elementEnd('div'); } @@ -212,7 +214,7 @@ class NoticeListItem { // XXX: RDFa // TODO: add notice_type class e.g., notice_video, notice_image - common_element_start('li', array('class' => 'hentry notice', + $this->out->elementStart('li', array('class' => 'hentry notice', 'id' => 'notice-' . $this->notice->id)); } @@ -244,13 +246,13 @@ class NoticeListItem function showAuthor() { - $this->elementStart('span', 'vcard author'); - $this->elementStart('a', array('href' => $this->profile->profileurl, + $this->out->elementStart('span', 'vcard author'); + $this->out->elementStart('a', array('href' => $this->profile->profileurl, 'class' => 'url')); $this->showAvatar(); $this->showNickname(); - $this->elementEnd('a'); - $this->elementEnd('span'); + $this->out->elementEnd('a'); + $this->out->elementEnd('span'); } /** @@ -266,7 +268,7 @@ class NoticeListItem { $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE); - $this->element('img', array('src' => ($avatar) ? + $this->out->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE), 'class' => 'avatar photo', @@ -288,7 +290,7 @@ class NoticeListItem function showNickname() { - $this->element('span', array('class' => 'nickname fn'), + $this->out->element('span', array('class' => 'nickname fn'), $this->profile->nickname); } @@ -305,16 +307,16 @@ class NoticeListItem function showContent() { // FIXME: URL, image, video, audio - common_element_start('p', array('class' => 'entry-content')); + $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'); + $this->out->elementEnd('p'); } /** @@ -335,18 +337,18 @@ class NoticeListItem preg_match('/^http/', $this->notice->uri)) { $noticeurl = $this->notice->uri; } - $this->elementStart('dl', 'timestamp'); - $this->element('dt', _('Published')); - $this->elementStart('dd', null); - $this->element('a', array('rel' => 'bookmark', + $this->out->elementStart('dl', 'timestamp'); + $this->out->element('dt', _('Published')); + $this->out->elementStart('dd', null); + $this->out->element('a', array('rel' => 'bookmark', 'href' => $noticeurl)); $dt = common_date_iso8601($this->notice->created); - $this->element('abbr', array('class' => 'published', + $this->out->element('abbr', array('class' => 'published', 'title' => $dt), common_date_string($this->notice->created)); - $this->elementEnd('a'); - $this->elementEnd('dd'); - $this->elementEnd('dl'); + $this->out->elementEnd('a'); + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); } /** @@ -361,8 +363,8 @@ class NoticeListItem function showNoticeSource() { if ($this->notice->source) { - $this->elementStart('dl', 'device'); - $this->element('dt', null, _('From')); + $this->out->elementStart('dl', 'device'); + $this->out->element('dt', null, _('From')); $source_name = _($this->notice->source); switch ($this->notice->source) { case 'web': @@ -370,22 +372,22 @@ class NoticeListItem case 'mail': case 'omb': case 'api': - $this->element('dd', 'noticesource', $source_name); + $this->out->element('dd', 'noticesource', $source_name); break; default: $ns = Notice_source::staticGet($this->notice->source); if ($ns) { - $this->elementStart('dd', null); - $this->element('a', array('href' => $ns->url, + $this->out->elementStart('dd', null); + $this->out->element('a', array('href' => $ns->url, 'rel' => 'external'), $ns->name); - $this->elementEnd('dd'); + $this->out->elementEnd('dd'); } else { - $this->element('dd', 'noticesource', $source_name); + $this->out->element('dd', 'noticesource', $source_name); } break; } - $this->elementEnd('dl'); + $this->out->elementEnd('dl'); } } @@ -403,14 +405,14 @@ class NoticeListItem if ($this->notice->reply_to) { $replyurl = common_local_url('shownotice', array('notice' => $this->notice->reply_to)); - $this->elementStart('dl', 'response'); - $this->element('dt', null, _('To')); - $this->elementStart('dd'); - $this->element('a', array('href' => $replyurl, + $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->elementEnd('dd'); - $this->elementEnd('dl'); + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); } } @@ -431,13 +433,13 @@ class NoticeListItem $reply_js = 'return doreply("'.$this->profile->nickname.'",'.$this->notice->id.');'; - common_element_start('a', + $this->out->elementStart('a', array('href' => $reply_url, 'onclick' => $reply_js, 'title' => _('reply'), 'class' => 'replybutton')); - common_raw(' →'); - common_element_end('a'); + $this->out->raw(' →'); + $this->out->elementEnd('a'); } /** @@ -452,11 +454,11 @@ 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', + $this->out->elementStart('a', array('class' => 'deletenotice', 'href' => $deleteurl, 'title' => _('delete'))); - common_raw(' ×'); - common_element_end('a'); + $this->out->raw(' ×'); + $this->out->elementEnd('a'); } } @@ -470,6 +472,6 @@ class NoticeListItem function showEnd() { - common_element_end('li'); + $this->out->elementEnd('li'); } } -- cgit v1.2.3-54-g00ecf From c52d49f2fab9f08714ac6c3f950f23ee8497412f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 21:19:44 +0000 Subject: Fix some formatting in list items --- lib/noticelist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index 0fc6d513f..ad3af4391 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -342,7 +342,7 @@ class NoticeListItem extends Widget $this->out->elementStart('dl', 'timestamp'); $this->out->element('dt', _('Published')); $this->out->elementStart('dd', null); - $this->out->element('a', array('rel' => 'bookmark', + $this->out->elementStart('a', array('rel' => 'bookmark', 'href' => $noticeurl)); $dt = common_date_iso8601($this->notice->created); $this->out->element('abbr', array('class' => 'published', -- cgit v1.2.3-54-g00ecf From 8b3459812764d05044bcdfb18627f80c34dc239d Mon Sep 17 00:00:00 2001 From: sarven Date: Thu, 15 Jan 2009 22:19:40 +0000 Subject: Changed to class --- lib/noticelist.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index ad3af4391..7f63089b3 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -79,7 +79,8 @@ class NoticeList extends Widget function show() { - $this->out->elementStart('ul', array('id' => 'notices')); + $this->out->element('h2', null, _('Notices')); + $this->out->elementStart('ul', array('class' => 'notices')); $cnt = 0; -- cgit v1.2.3-54-g00ecf From 7ce054b1ed0f4af923aa4e041005d514a7358056 Mon Sep 17 00:00:00 2001 From: sarven Date: Thu, 15 Jan 2009 22:31:32 +0000 Subject: Wrapper for notices --- lib/noticelist.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index 7f63089b3..eb5416ee4 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -79,6 +79,7 @@ class NoticeList extends Widget function show() { + $this->out->elementStart('div', array('id' =>'notices_primary')); $this->out->element('h2', null, _('Notices')); $this->out->elementStart('ul', array('class' => 'notices')); @@ -96,6 +97,7 @@ class NoticeList extends Widget } $this->out->elementEnd('ul'); + $this->out->elementEnd('div'); return $cnt; } -- cgit v1.2.3-54-g00ecf From a18351bc390cc0c4081286220120a6b5e8402a19 Mon Sep 17 00:00:00 2001 From: sarven Date: Thu, 15 Jan 2009 23:32:02 +0000 Subject: Published title --- lib/noticelist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index eb5416ee4..dd4c4a188 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -343,7 +343,7 @@ class NoticeListItem extends Widget $noticeurl = $this->notice->uri; } $this->out->elementStart('dl', 'timestamp'); - $this->out->element('dt', _('Published')); + $this->out->element('dt', null, _('Published')); $this->out->elementStart('dd', null); $this->out->elementStart('a', array('rel' => 'bookmark', 'href' => $noticeurl)); -- cgit v1.2.3-54-g00ecf From e697faf23bf70ed43d074a2f437aae362580e003 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 23:43:58 +0000 Subject: Add some includes to noticelist --- lib/noticelist.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index eb5416ee4..ccdd57feb 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 * -- cgit v1.2.3-54-g00ecf From 179ad6c13b06559959943ec6685b840f7ea3d18a Mon Sep 17 00:00:00 2001 From: sarven Date: Fri, 16 Jan 2009 01:33:42 +0000 Subject: showReplyLink --- lib/noticelist.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index 6f4d1c04e..fde93a3b6 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -438,16 +438,13 @@ class NoticeListItem extends Widget $reply_url = common_local_url('newnotice', array('replyto' => $this->profile->nickname)); - $reply_js = - 'return doreply("'.$this->profile->nickname.'",'.$this->notice->id.');'; - - $this->out->elementStart('a', - array('href' => $reply_url, - 'onclick' => $reply_js, - 'title' => _('reply'), - 'class' => 'replybutton')); - $this->out->raw(' →'); - $this->out->elementEnd('a'); + $this->out->elementStart('dl', 'reply'); + $this->out->element('dt', null, _('Reply to this notice')); + $this->out->elementStart('dd'); + $this->out->element('a', array('href' => $reply_url, + 'title' => _('reply')), _('Reply')); + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); } /** -- cgit v1.2.3-54-g00ecf From 607e65be81d6b42990706884f96fa024301c7893 Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 02:32:13 +0000 Subject: Delete notice markup and styles --- lib/noticelist.php | 14 ++++++++------ theme/base/css/display.css | 17 +++++++++-------- theme/identica/css/display.css | 6 +++--- 3 files changed, 20 insertions(+), 17 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index fde93a3b6..1283e43e4 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -438,7 +438,7 @@ class NoticeListItem extends Widget $reply_url = common_local_url('newnotice', array('replyto' => $this->profile->nickname)); - $this->out->elementStart('dl', 'reply'); + $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, @@ -459,11 +459,13 @@ class NoticeListItem extends Widget if ($user && $this->notice->profile_id == $user->id) { $deleteurl = common_local_url('deletenotice', array('notice' => $this->notice->id)); - $this->out->elementStart('a', array('class' => 'deletenotice', - 'href' => $deleteurl, - 'title' => _('delete'))); - $this->out->raw(' ×'); - $this->out->elementEnd('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')), _('Delete')); + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); } } diff --git a/theme/base/css/display.css b/theme/base/css/display.css index fb7e71acd..20e66c351 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -775,25 +775,26 @@ outline:none; margin-left:2%; float:left; } -.notice-options .reply, +.notice-options .notice_reply, .notice-options .notice_delete , .notice-options .notice_favorite { float:left; margin-right:11px; } -.notice-options .reply { +.notice-options .notice_reply { margin-top:1px; } -.notice-options .reply dt { +.notice-options .notice_reply dt { display:none; } -.notice-options .reply a, +.notice-options .notice_reply a, .notice-options form input.submit { display:block; border:0; } -.notice-options .reply a { +.notice-options .notice_reply a, +.notice-options .notice_delete a { text-decoration:none; padding-left:20px; } @@ -802,7 +803,7 @@ cursor:pointer; padding:0 0 0 17px; } -.notice-options .notice_delete legend, +.notice-options .notice_delete dt, .notice-options .notice_favorite legend { display:none; } @@ -813,8 +814,8 @@ padding:0; } -.notice-options form.notice_delete { -margin-left:2em; +.notice-options .notice_delete { +margin-left:3em; } /*END: NOTICES */ diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index aed4f95e5..94e97d414 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -173,17 +173,17 @@ background-image:url(../images/icons/twotone/green/flag.gif); background-image:url(../images/icons/twotone/green/document.gif); } -.notice-options .reply a, +.notice-options .notice_reply a, .notice-options form input.submit { background-color:transparent; } -.notice-options .reply a { +.notice-options .notice_reply a { background:transparent url(../images/icons/twotone/green/reply.gif) no-repeat 0 45%; } .notice-options form.notice_favorite input.submit { background:transparent url(../images/icons/twotone/green/favourite.gif) no-repeat 0 45%; } -.notice-options form.notice_delete input.submit { +.notice-options .notice_delete a { background:transparent url(../images/icons/twotone/green/trash.gif) no-repeat 0 45%; } -- cgit v1.2.3-54-g00ecf From 5a81b6d04ea7e2f7c5e5799ada8a611ec9406317 Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 20:57:48 +0000 Subject: Added @title to input submit (reusing $label value until we really need to make it custom) --- lib/favorform.php | 4 ++-- lib/htmloutputter.php | 3 ++- lib/noticelist.php | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/favorform.php b/lib/favorform.php index 977f19183..519b305b6 100644 --- a/lib/favorform.php +++ b/lib/favorform.php @@ -111,7 +111,7 @@ class FavorForm extends Form */ function formLegend() { - $this->out->element('legend', null, _('Delete this notice')); + $this->out->element('legend', null, _('Favor this notice')); } @@ -137,7 +137,7 @@ class FavorForm extends Form function formActions() { $this->out->submit('favor-submit-' . $this->notice->id, - _('Favorite')); + _('Favor this notice')); } /** diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 71f17604b..f83998bc2 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -319,7 +319,8 @@ class HTMLOutputter extends XMLOutputter 'id' => $id, 'name' => ($name) ? $name : $id, 'class' => $cls, - 'value' => $label)); + 'value' => $label, + 'title' => $label)); } /** diff --git a/lib/noticelist.php b/lib/noticelist.php index 1283e43e4..9c433f81a 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -442,7 +442,7 @@ class NoticeListItem extends Widget $this->out->element('dt', null, _('Reply to this notice')); $this->out->elementStart('dd'); $this->out->element('a', array('href' => $reply_url, - 'title' => _('reply')), _('Reply')); + 'title' => _('Reply to this notice')), _('Reply')); $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } @@ -463,7 +463,7 @@ class NoticeListItem extends Widget $this->out->element('dt', null, _('Delete this notice')); $this->out->elementStart('dd'); $this->out->element('a', array('href' => $deleteurl, - 'title' => _('delete')), _('Delete')); + 'title' => _('Delete this notice')), _('Delete')); $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } -- cgit v1.2.3-54-g00ecf From 02b49e3f87ebe3fb64a24b21356d03d3b3d697e9 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 19 Jan 2009 16:35:04 +0000 Subject: Reformat notice list code --- lib/noticelist.php | 65 +++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index 9c433f81a..c57d6ce19 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -67,7 +67,7 @@ class NoticeList extends Widget function __construct($notice, $out=null) { - parent::__construct($out); + parent::__construct($out); $this->notice = $notice; } @@ -160,7 +160,7 @@ class NoticeListItem extends Widget function __construct($notice, $out=null) { - parent::__construct($out); + parent::__construct($out); $this->notice = $notice; $this->profile = $notice->getProfile(); } @@ -209,7 +209,6 @@ class NoticeListItem extends Widget $this->out->elementEnd('div'); } - /** * start a single notice. * @@ -221,7 +220,7 @@ class NoticeListItem extends Widget // XXX: RDFa // TODO: add notice_type class e.g., notice_video, notice_image $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(); if ($user) { if ($user->hasFave($this->notice)) { - $disfavor = new DisfavorForm($this->out, $this->notice); - $disfavor->show(); + $disfavor = new DisfavorForm($this->out, $this->notice); + $disfavor->show(); } else { - $favor = new FavorForm($this->out, $this->notice); - $favor->show(); + $favor = new FavorForm($this->out, $this->notice); + $favor->show(); } } } @@ -256,7 +255,7 @@ class NoticeListItem extends Widget { $this->out->elementStart('span', 'vcard author'); $this->out->elementStart('a', array('href' => $this->profile->profileurl, - 'class' => 'url')); + 'class' => 'url')); $this->showAvatar(); $this->showNickname(); $this->out->elementEnd('a'); @@ -277,15 +276,15 @@ class NoticeListItem extends Widget $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE); $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)); + 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)); } /** @@ -299,7 +298,7 @@ class NoticeListItem extends Widget function showNickname() { $this->out->element('span', array('class' => 'nickname fn'), - $this->profile->nickname); + $this->profile->nickname); } /** @@ -346,14 +345,14 @@ class NoticeListItem extends Widget $noticeurl = $this->notice->uri; } $this->out->elementStart('dl', 'timestamp'); - $this->out->element('dt', null, _('Published')); + $this->out->element('dt', null, _('Published')); $this->out->elementStart('dd', null); $this->out->elementStart('a', array('rel' => 'bookmark', - 'href' => $noticeurl)); + 'href' => $noticeurl)); $dt = common_date_iso8601($this->notice->created); $this->out->element('abbr', array('class' => 'published', - 'title' => $dt), - common_date_string($this->notice->created)); + 'title' => $dt), + common_date_string($this->notice->created)); $this->out->elementEnd('a'); $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); @@ -375,20 +374,20 @@ class NoticeListItem extends Widget $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': + 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) { $this->out->elementStart('dd', null); $this->out->element('a', array('href' => $ns->url, - 'rel' => 'external'), - $ns->name); + 'rel' => 'external'), + $ns->name); $this->out->elementEnd('dd'); } else { $this->out->element('dd', 'noticesource', $source_name); @@ -417,8 +416,8 @@ class NoticeListItem extends Widget $this->out->element('dt', null, _('To')); $this->out->elementStart('dd'); $this->out->element('a', array('href' => $replyurl, - 'rel' => 'in-reply-to'), - _('in reply to')); + 'rel' => 'in-reply-to'), + _('in reply to')); $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } -- cgit v1.2.3-54-g00ecf From 9376003871652300b5960437fd37461fdd85e63b Mon Sep 17 00:00:00 2001 From: sarven Date: Wed, 21 Jan 2009 05:27:16 +0000 Subject: Mailbox markup for Inbox/Outbox direct notices Please enter the commit message for your changes. --- lib/mailbox.php | 64 ++++++++++++++++++++++++++++++++++++------------------ lib/noticelist.php | 4 ++-- 2 files changed, 45 insertions(+), 23 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/mailbox.php b/lib/mailbox.php index 9af0dbd2f..8d5d44e49 100644 --- a/lib/mailbox.php +++ b/lib/mailbox.php @@ -111,9 +111,10 @@ class MailboxAction extends PersonalAction $message = $this->getMessages(); if ($message) { - $cnt = 0; - $this->elementStart('ul', array('id' => 'messages')); + $this->elementStart('div', array('id' =>'notices_primary')); + $this->element('h2', null, _('Notices')); + $this->elementStart('ul', 'notices'); while ($message->fetch() && $cnt <= MESSAGES_PER_PAGE) { $cnt++; @@ -130,7 +131,7 @@ class MailboxAction extends PersonalAction $this->pagination($this->page > 1, $cnt > MESSAGES_PER_PAGE, $this->page, $this->trimmed('action'), array('nickname' => $this->user->nickname)); - + $this->elementEnd('div'); $message->free(); unset($message); } @@ -169,30 +170,35 @@ class MailboxAction extends PersonalAction function showMessage($message) { - $this->elementStart('li', array('class' => 'message_single', + $this->elementStart('li', array('class' => 'hentry notice', 'id' => 'message-' . $message->id)); $profile = $this->getMessageProfile($message); + $this->elementStart('div', 'entry-title'); + $this->elementStart('span', 'vcard author'); + $this->elementStart('a', array('href' => $profile->profileurl, + 'class' => 'url')); $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE); - $this->elementStart('a', array('href' => $profile->profileurl)); $this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE), - 'class' => 'avatar stream', + 'class' => 'photo avatar', 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'alt' => ($profile->fullname) ? $profile->fullname : $profile->nickname)); + $this->element('span', array('class' => 'nickname fn'), + $profile->nickname); $this->elementEnd('a'); - $this->element('a', array('href' => $profile->profileurl, - 'class' => 'nickname'), - $profile->nickname); + $this->elementEnd('span'); + // FIXME: URL, image, video, audio - $this->elementStart('p', array('class' => 'content')); + $this->elementStart('p', array('class' => 'entry-content')); $this->raw($message->rendered); $this->elementEnd('p'); + $this->elementEnd('div'); $messageurl = common_local_url('showmessage', array('message' => $message->id)); @@ -202,17 +208,30 @@ class MailboxAction extends PersonalAction preg_match('/^http/', $message->uri)) { $messageurl = $message->uri; } - $this->elementStart('p', 'time'); - $this->element('a', array('class' => 'permalink', - 'href' => $messageurl, - 'title' => common_exact_date($message->created)), - common_date_string($message->created)); + + $this->elementStart('div', 'entry-content'); + $this->elementStart('dl', 'timestamp'); + $this->element('dt', null, _('Published')); + $this->elementStart('dd', null); + $dt = common_date_iso8601($message->created); + $this->elementStart('a', array('rel' => 'bookmark', + 'href' => $messageurl)); + $this->element('abbr', array('class' => 'published', + 'title' => $dt), + common_date_string($message->created)); + $this->elementEnd('a'); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + if ($message->source) { - $this->text(_(' from ')); + $this->elementStart('dl', 'device'); + $this->elementStart('dt'); + $this->text(_('From')); + $this->elementEnd('dt'); $this->showSource($message->source); + $this->elementEnd('dl'); } - - $this->elementEnd('p'); + $this->elementEnd('div'); $this->elementEnd('li'); } @@ -255,15 +274,18 @@ class MailboxAction extends PersonalAction case 'mail': case 'omb': case 'api': - $this->element('span', 'noticesource', $source_name); + $this->element('dd', null, $source_name); break; default: $ns = Notice_source::staticGet($source); if ($ns) { - $this->element('a', array('href' => $ns->url), + $this->elementStart('dd', null); + $this->element('a', array('href' => $ns->url, + 'rel' => 'external'), $ns->name); + $this->elementEnd('dd'); } else { - $this->element('span', 'noticesource', $source_name); + $this->element('dd', null, $source_name); } break; } diff --git a/lib/noticelist.php b/lib/noticelist.php index c57d6ce19..07912c552 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -379,7 +379,7 @@ class NoticeListItem extends Widget case 'mail': case 'omb': case 'api': - $this->out->element('dd', 'noticesource', $source_name); + $this->out->element('dd', null, $source_name); break; default: $ns = Notice_source::staticGet($this->notice->source); @@ -390,7 +390,7 @@ class NoticeListItem extends Widget $ns->name); $this->out->elementEnd('dd'); } else { - $this->out->element('dd', 'noticesource', $source_name); + $this->out->element('dd', null, $source_name); } break; } -- cgit v1.2.3-54-g00ecf From 0daf242100925396aad4cc9fea5de0de2ec98ce8 Mon Sep 17 00:00:00 2001 From: sarven Date: Fri, 23 Jan 2009 02:43:18 +0000 Subject: Using util.js to set onclick reply anchor --- js/util.js | 18 ++++++++++++++++-- lib/noticelist.php | 8 ++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'lib/noticelist.php') diff --git a/js/util.js b/js/util.js index de486cf74..6ca5f8cbc 100644 --- a/js/util.js +++ b/js/util.js @@ -176,6 +176,7 @@ $(document).ready(function(){ counter(); $("#notices_primary .notice:first").css({display:"none"}); $("#notices_primary .notice:first").fadeIn(2500); + NoticeHover(); } $("#notice_action-submit").removeAttr("disabled"); $("#notice_action-submit").removeClass("disabled"); @@ -184,6 +185,19 @@ $(document).ready(function(){ $("#form_notice").ajaxForm(PostNotice); $("#form_notice").each(addAjaxHidden); + NoticeHover(); + + $('#content .notice').each(function() { + var notice = $(this); + $('.notice_reply', $(this)).click(function() { + var nickname = ($('.author .nickname', notice).length > 0) ? $('.author .nickname', notice) : $('.author .nickname'); + NoticeReply(nickname.text(), $('.notice_id', notice).text()); + return false; + }); + }); +}); + +function NoticeHover() { $("#content .notice").hover( function () { $(this).addClass('hover'); @@ -192,9 +206,9 @@ $(document).ready(function(){ $(this).removeClass('hover'); } ); -}); +} -function doreply(nick,id) { +function NoticeReply(nick,id) { rgx_username = /^[0-9a-zA-Z\-_.]*$/; if (nick.match(rgx_username)) { replyto = "@" + nick + " "; diff --git a/lib/noticelist.php b/lib/noticelist.php index 07912c552..8b0c5f322 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -22,6 +22,7 @@ * @category UI * @package Laconica * @author Evan Prodromou + * @author Sarven Capadisli * @copyright 2008 Control Yourself, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://laconi.ca/ @@ -440,8 +441,11 @@ class NoticeListItem extends Widget $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->elementStart('a', array('href' => $reply_url, + 'title' => _('Reply to this notice'))); + $this->out->text(_('Reply')); + $this->out->element('span', 'notice_id', $this->notice->id); + $this->out->elementEnd('a'); $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } -- cgit v1.2.3-54-g00ecf From 597245ffc3fc15876f005c98aa585288f4901635 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Fri, 23 Jan 2009 04:52:39 +0000 Subject: make avatar bigger on single notice pages --- lib/noticelist.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index 8b0c5f322..20bf3c9f1 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -274,14 +274,19 @@ class NoticeListItem extends Widget function showAvatar() { - $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE); + if ('shownotice' === $this->out->trimmed('action')) { + $avatar_size = AVATAR_PROFILE_SIZE; + } else { + $avatar_size = AVATAR_STREAM_SIZE; + } + $avatar = $this->profile->getAvatar($avatar_size); $this->out->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : - common_default_avatar(AVATAR_STREAM_SIZE), + common_default_avatar($avatar_size), 'class' => 'avatar photo', - 'width' => AVATAR_STREAM_SIZE, - 'height' => AVATAR_STREAM_SIZE, + 'width' => $avatar_size, + 'height' => $avatar_size, 'alt' => ($this->profile->fullname) ? $this->profile->fullname : -- cgit v1.2.3-54-g00ecf