* @category UI
* @package Laconica
* @author Evan Prodromou <evan@controlyourself.ca>
+ * @author Sarven Capadisli <csarven@controlyourself.ca>
* @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/
exit(1);
}
+require_once INSTALLDIR.'/lib/favorform.php';
+require_once INSTALLDIR.'/lib/disfavorform.php';
+
/**
* widget for displaying a list of notices
*
* @see ProfileNoticeList
*/
-class NoticeList
+class NoticeList extends Widget
{
/** the current stream of notices being displayed. */
* @param Notice $notice stream of notices from DB_DataObject
*/
- function __construct($notice)
+ function __construct($notice, $out=null)
{
+ parent::__construct($out);
$this->notice = $notice;
}
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;
$item->show();
}
- common_element_end('ul');
+ $this->out->elementEnd('ul');
+ $this->out->elementEnd('div');
return $cnt;
}
function newListItem($notice)
{
- return new NoticeListItem($notice);
+ return new NoticeListItem($notice, $this->out);
}
}
* @see ProfileNoticeListItem
*/
-class NoticeListItem
+class NoticeListItem extends Widget
{
/** The notice this item will show. */
* @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();
}
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->showFaveForm();
- $this->showReplyLink();
- $this->showDeleteLink();
- $this->elementEnd('div');
+ $user = common_current_user();
+ if ($user) {
+ $this->out->elementStart('div', 'notice-options');
+ $this->showFaveForm();
+ $this->showReplyLink();
+ $this->showDeleteLink();
+ $this->out->elementEnd('div');
+ }
}
-
/**
* start a single notice.
*
{
// XXX: RDFa
// TODO: add notice_type class e.g., notice_video, notice_image
- common_element_start('li', array('class' => 'hentry notice',
- 'id' => 'notice-' . $this->notice->id));
+ $this->out->elementStart('li', array('class' => 'hentry notice',
+ 'id' => 'notice-' . $this->notice->id));
}
/**
$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();
}
}
}
function showAuthor()
{
- $this->elementStart('span', 'vcard author');
- $this->elementStart('a', array('href' => $this->profile->profileurl,
- 'class' => 'url'));
+ $this->out->elementStart('span', 'vcard author');
+ $attrs = array('href' => $this->profile->profileurl,
+ 'class' => 'url');
+ if (!empty($this->profile->fullname)) {
+ $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ') ';
+ }
+ $this->out->elementStart('a', $attrs);
$this->showAvatar();
$this->showNickname();
- $this->elementEnd('a');
- $this->elementEnd('span');
+ $this->out->elementEnd('a');
+ $this->out->elementEnd('span');
}
/**
function showAvatar()
{
- $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
-
- $this->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));
+ 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) ?
+ $avatar->displayUrl() :
+ Avatar::defaultImage($avatar_size),
+ 'class' => 'avatar photo',
+ 'width' => $avatar_size,
+ 'height' => $avatar_size,
+ 'alt' =>
+ ($this->profile->fullname) ?
+ $this->profile->fullname :
+ $this->profile->nickname));
}
/**
function showNickname()
{
- $this->element('span', array('class' => 'nickname fn'),
- $this->profile->nickname);
+ $this->out->element('span', array('class' => 'nickname fn'),
+ $this->profile->nickname);
}
/**
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');
}
/**
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',
- '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);
- $this->element('abbr', array('class' => 'published',
- 'title' => $dt),
- common_date_string($this->notice->created));
- $this->elementEnd('a');
- $this->elementEnd('dd');
- $this->elementEnd('dl');
+ $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');
}
/**
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':
- case 'xmpp':
- case 'mail':
- case 'omb':
- case 'api':
- $this->element('dd', 'noticesource', $source_name);
+ case 'web':
+ case 'xmpp':
+ case 'mail':
+ case 'omb':
+ case 'system':
+ case 'api':
+ $this->out->element('dd', null, $source_name);
break;
- default:
+ default:
$ns = Notice_source::staticGet($this->notice->source);
if ($ns) {
- $this->elementStart('dd', null);
- $this->element('a', array('href' => $ns->url,
- 'rel' => 'external'),
- $ns->name);
- $this->elementEnd('dd');
+ $this->out->elementStart('dd', null);
+ $this->out->element('a', array('href' => $ns->url,
+ 'rel' => 'external'),
+ $ns->name);
+ $this->out->elementEnd('dd');
} else {
- $this->element('dd', 'noticesource', $source_name);
+ $this->out->element('dd', null, $source_name);
}
break;
}
- $this->elementEnd('dl');
+ $this->out->elementEnd('dl');
}
}
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,
- 'rel' => 'in-reply-to'),
- _('in reply to'));
- $this->elementEnd('dd');
- $this->elementEnd('dl');
+ $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');
}
}
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');
+ if (common_logged_in()) {
+ $reply_url = common_local_url('newnotice',
+ array('replyto' => $this->profile->nickname));
+
+ $this->out->elementStart('dl', 'notice_reply');
+ $this->out->element('dt', null, _('Reply to this notice'));
+ $this->out->elementStart('dd');
+ $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');
+ }
}
/**
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');
}
}
function showEnd()
{
- common_element_end('li');
+ $this->out->elementEnd('li');
}
}