summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-01-21 11:52:06 -0500
committerEvan Prodromou <evan@controlyourself.ca>2009-01-21 11:52:06 -0500
commit0824bb2e1df68fd6634ca915e4c87664ee2ef872 (patch)
tree690a016561e9c4012871dbad7434a7341ef33fdf /lib
parent4491e82762e498a02ec4f8a9f6c98cc194071e1f (diff)
parent92e2f3babc89863518b8711a1b62661752d806f5 (diff)
Merge branch 'master' into groups
Diffstat (limited to 'lib')
-rw-r--r--lib/blockform.php14
-rw-r--r--lib/deleteaction.php72
-rw-r--r--lib/mailbox.php64
-rw-r--r--lib/messageform.php39
-rw-r--r--lib/noticelist.php4
-rw-r--r--lib/nudgeform.php31
-rw-r--r--lib/subscribeform.php13
-rw-r--r--lib/unblockform.php13
-rw-r--r--lib/unsubscribeform.php12
-rw-r--r--lib/util.php19
10 files changed, 190 insertions, 91 deletions
diff --git a/lib/blockform.php b/lib/blockform.php
index b7790681d..ea22c1cec 100644
--- a/lib/blockform.php
+++ b/lib/blockform.php
@@ -112,6 +112,18 @@ class BlockForm extends Form
return common_local_url('block');
}
+
+ /**
+ * Legend of the Form
+ *
+ * @return void
+ */
+ function formLegend()
+ {
+ $this->out->element('legend', null, _('Block this user'));
+ }
+
+
/**
* Data elements of the form
*
@@ -138,6 +150,6 @@ class BlockForm extends Form
function formActions()
{
- $this->out->submit('submit', _('Block'));
+ $this->out->submit('submit', _('block'), 'submit', null, _('Block this user'));
}
}
diff --git a/lib/deleteaction.php b/lib/deleteaction.php
index 9e89c0a54..91c6487a9 100644
--- a/lib/deleteaction.php
+++ b/lib/deleteaction.php
@@ -1,9 +1,12 @@
<?php
-/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+/**
+ * Laconica, the distributed open-source microblogging tool
*
- * This program is free software: you can redistribute it and/or modify
+ * Base class for deleting things
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
@@ -15,52 +18,57 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Personal
+ * @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/
*/
-if (!defined('LACONICA')) { exit(1); }
+if (!defined('LACONICA')) {
+ exit(1);
+}
class DeleteAction extends Action
{
+ var $user = null;
+ var $notice = null;
+ var $profile = null;
+ var $user_profile = null;
- function handle($args)
+ function prepare($args)
{
- parent::handle($args);
- $user = common_current_user();
- $notice_id = $this->trimmed('notice');
- $notice = Notice::staticGet($notice_id);
- if (!$notice) {
+ parent::prepare($args);
+
+ $this->user = common_current_user();
+ $notice_id = $this->trimmed('notice');
+ $this->notice = Notice::staticGet($notice_id);
+
+ if (!$this->notice) {
common_user_error(_('No such notice.'));
exit;
}
- $profile = $notice->getProfile();
- $user_profile = $user->getProfile();
+ $this->profile = $this->notice->getProfile();
+ $this->user_profile = $this->user->getProfile();
+
+ return true;
+ }
+
+ function handle($args)
+ {
+ parent::handle($args);
if (!common_logged_in()) {
common_user_error(_('Not logged in.'));
exit;
- } else if ($notice->profile_id != $user_profile->id) {
+ } else if ($this->notice->profile_id != $this->user_profile->id) {
common_user_error(_('Can\'t delete this notice.'));
exit;
}
}
- function show_top($arr=null)
- {
- $instr = $this->get_instructions();
- $output = common_markup_to_html($instr);
- common_element_start('div', 'instructions');
- common_raw($output);
- common_element_end('div');
- }
-
- function get_title()
- {
- return null;
- }
-
- function show_header()
- {
- return;
- }
}
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/messageform.php b/lib/messageform.php
index eca39cc06..61d3d75af 100644
--- a/lib/messageform.php
+++ b/lib/messageform.php
@@ -85,7 +85,7 @@ class MessageForm extends Form
function id()
{
- return 'message_form';
+ return 'form_notice';
}
/**
@@ -99,6 +99,18 @@ class MessageForm extends Form
return common_local_url('newmessage');
}
+
+ /**
+ * Legend of the Form
+ *
+ * @return void
+ */
+ function formLegend()
+ {
+ $this->out->element('legend', null, _('Send a direct notice'));
+ }
+
+
/**
* Data elements
*
@@ -122,18 +134,20 @@ class MessageForm extends Form
$mutual_users->free();
unset($mutual_users);
+ $this->out->elementStart('ul', 'form_data');
+ $this->out->elementStart('li', array('id' => 'notice_to'));
$this->out->dropdown('to', _('To'), $mutual, null, false,
$this->to->id);
+ $this->out->elementEnd('li');
- $this->out->elementStart('p');
-
- $this->out->element('textarea', array('id' => 'message_content',
- 'cols' => 60,
- 'rows' => 3,
+ $this->out->elementStart('li', array('id' => 'notice_text'));
+ $this->out->element('textarea', array('id' => 'notice_data-text',
+ 'cols' => 35,
+ 'rows' => 4,
'name' => 'content'),
($this->content) ? $this->content : '');
-
- $this->out->elementEnd('p');
+ $this->out->elementEnd('li');
+ $this->out->elementEnd('ul');
}
/**
@@ -144,9 +158,14 @@ class MessageForm extends Form
function formActions()
{
- $this->out->element('input', array('id' => 'message_send',
+ $this->out->elementStart('ul', 'form_actions');
+ $this->out->elementStart('li', array('id' => 'notice_submit'));
+ $this->out->element('input', array('id' => 'notice_action-submit',
+ 'class' => 'submit',
'name' => 'message_send',
'type' => 'submit',
'value' => _('Send')));
+ $this->out->elementEnd('li');
+ $this->out->elementEnd('ul');
}
-} \ No newline at end of file
+}
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;
}
diff --git a/lib/nudgeform.php b/lib/nudgeform.php
index 7d04e11e4..7380462a7 100644
--- a/lib/nudgeform.php
+++ b/lib/nudgeform.php
@@ -77,9 +77,22 @@ class NudgeForm extends Form
function id()
{
- return 'nudge';
+ return 'form_user_nudge';
}
+
+ /**
+ * class of the form
+ *
+ * @return string of the form class
+ */
+
+ function formClass()
+ {
+ return 'form_user_nudge';
+ }
+
+
/**
* Action of the form
*
@@ -92,6 +105,18 @@ class NudgeForm extends Form
array('nickname' => $this->profile->nickname));
}
+
+ /**
+ * Legend of the Form
+ *
+ * @return void
+ */
+ function formLegend()
+ {
+ $this->out->element('legend', null, _('Nudge this user'));
+ }
+
+
/**
* Action elements
*
@@ -100,6 +125,6 @@ class NudgeForm extends Form
function formActions()
{
- $this->out->submit('submit', _('Send a nudge'));
+ $this->out->submit('submit', _('Nudge'), 'submit', null, _('Send a nudge to this user'));
}
-} \ No newline at end of file
+}
diff --git a/lib/subscribeform.php b/lib/subscribeform.php
index 231e740a7..c65134e46 100644
--- a/lib/subscribeform.php
+++ b/lib/subscribeform.php
@@ -104,6 +104,17 @@ class SubscribeForm extends Form
return common_local_url('subscribe');
}
+
+ /**
+ * Legend of the Form
+ *
+ * @return void
+ */
+ function formLegend()
+ {
+ $this->out->element('legend', null, _('Subscribe to this user'));
+ }
+
/**
* Data elements of the form
*
@@ -125,6 +136,6 @@ class SubscribeForm extends Form
function formActions()
{
- $this->out->submit('submit', _('Subscribe'));
+ $this->out->submit('submit', _('Subscribe'), 'submit', null, _('Subscribe to this user'));
}
}
diff --git a/lib/unblockform.php b/lib/unblockform.php
index 025011a82..6a8831b29 100644
--- a/lib/unblockform.php
+++ b/lib/unblockform.php
@@ -111,6 +111,17 @@ class UnblockForm extends Form
}
/**
+ * Legend of the Form
+ *
+ * @return void
+ */
+ function formLegend()
+ {
+ $this->out->element('legend', null, _('Unblock this user'));
+ }
+
+
+ /**
* Data elements of the form
*
* @return void
@@ -136,6 +147,6 @@ class UnblockForm extends Form
function formActions()
{
- $this->out->submit('submit', _('Unblock'));
+ $this->out->submit('submit', _('Unblock'), 'submit', null, _('Unblock this user'));
}
}
diff --git a/lib/unsubscribeform.php b/lib/unsubscribeform.php
index 092369db7..ce91a1340 100644
--- a/lib/unsubscribeform.php
+++ b/lib/unsubscribeform.php
@@ -104,6 +104,16 @@ class UnsubscribeForm extends Form
}
/**
+ * Legend of the Form
+ *
+ * @return void
+ */
+ function formLegend()
+ {
+ $this->out->element('legend', null, _('Unsubscribe from this user'));
+ }
+
+ /**
* Data elements of the form
*
* @return void
@@ -124,6 +134,6 @@ class UnsubscribeForm extends Form
function formActions()
{
- $this->out->submit('submit', _('Unsubscribe'));
+ $this->out->submit('submit', _('Unsubscribe'), 'submit', null, _('Unsubscribe from this user'));
}
}
diff --git a/lib/util.php b/lib/util.php
index 56fbc29f5..4d4a3b20f 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1665,25 +1665,6 @@ function common_nudge_response()
common_element('p', array('id' => 'nudge_response'), _('Nudge sent!'));
}
-// XXX: Refactor this code
-function common_profile_new_message_nudge ($cur, $profile)
-{
- $user = User::staticGet('id', $profile->id);
-
- if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) {
- common_element_start('li', array('id' => 'profile_send_a_new_message'));
- common_element('a', array('href' => common_local_url('newmessage', array('to' => $user->id))),
- _('Send a message'));
- common_element_end('li');
-
- if ($user->email && $user->emailnotifynudge) {
- common_element_start('li', array('id' => 'profile_nudge'));
- common_nudge_form($user);
- common_element_end('li');
- }
- }
-}
-
function common_cache_key($extra)
{
return 'laconica:' . common_keyize(common_config('site', 'name')) . ':' . $extra;