From a42fef1621a69cefe0cfa7b9ee75df61b09a1526 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 14 Jan 2009 01:17:17 -0500 Subject: Move nudge form to its own class --- lib/nudgeform.php | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 lib/nudgeform.php (limited to 'lib/nudgeform.php') diff --git a/lib/nudgeform.php b/lib/nudgeform.php new file mode 100644 index 000000000..27ad44316 --- /dev/null +++ b/lib/nudgeform.php @@ -0,0 +1,105 @@ +. + * + * @category Form + * @package Laconica + * @author Evan Prodromou + * @author Sarven Capadisli + * @copyright 2009 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); +} + +require_once INSTALLDIR.'/lib/form.php'; + +/** + * Form for nudging a user + * + * @category Form + * @package Laconica + * @author Evan Prodromou + * @author Sarven Capadisli + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * + * @see DisfavorForm + */ + +class NudgeForm extends Form +{ + /** + * Profile of user to nudge + */ + + var $profile = null; + + /** + * Constructor + * + * @param HTMLOutputter $out output channel + * @param Profile $profile profile of user to nudge + */ + + function __construct($out=null, $profile=null) + { + parent::__construct($out); + + $this->notice = $profile; + } + + /** + * ID of the form + * + * @return int ID of the form + */ + + function id() + { + return 'nudge'; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + return common_local_url('nudge', + array('nickname' => $this->profile->nickname)); + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit('submit', _('Send a nudge')); + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf From ea1bd9668bfcd03955abe20be9df75ce950940b5 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 14 Jan 2009 01:22:20 -0500 Subject: Incorrectly set notice attribute, fixed --- lib/nudgeform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/nudgeform.php') diff --git a/lib/nudgeform.php b/lib/nudgeform.php index 27ad44316..7d04e11e4 100644 --- a/lib/nudgeform.php +++ b/lib/nudgeform.php @@ -66,7 +66,7 @@ class NudgeForm extends Form { parent::__construct($out); - $this->notice = $profile; + $this->profile = $profile; } /** -- cgit v1.2.3-54-g00ecf From 6c7842129841878b65c1d686de64f98f1edcb16f Mon Sep 17 00:00:00 2001 From: sarven Date: Wed, 21 Jan 2009 06:31:53 +0000 Subject: Moved common_profile_new_message_nudge() to showstream.php --- actions/nudge.php | 2 +- actions/showstream.php | 21 +++++++++++++++++++-- lib/nudgeform.php | 17 +++++++++++++++-- lib/util.php | 19 ------------------- 4 files changed, 35 insertions(+), 24 deletions(-) (limited to 'lib/nudgeform.php') diff --git a/actions/nudge.php b/actions/nudge.php index bb80ce357..456106459 100644 --- a/actions/nudge.php +++ b/actions/nudge.php @@ -88,7 +88,7 @@ class NudgeAction extends Action $this->notify($user, $other); if ($this->boolean('ajax')) { - common_start_html('text/xml;charset=utf-8', true); + $this->startHTML('text/xml;charset=utf-8', true); $this->elementStart('head'); $this->element('title', null, _('Nudge sent')); $this->elementEnd('head'); diff --git a/actions/showstream.php b/actions/showstream.php index 3882af845..a411fae5b 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -326,7 +326,24 @@ class ShowstreamAction extends Action } $this->elementEnd('li'); - common_profile_new_message_nudge($cur, $this->user, $this->profile); +// common_profile_new_message_nudge($cur, $this->user, $this->profile); + + $user = User::staticGet('id', $this->profile->id); + if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) { + $this->elementStart('li', array('id' => 'user_send_a_new_message')); + $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id))), + _('Send a message')); + $this->elementEnd('li'); + + if ($user->email && $user->emailnotifynudge) { + $this->elementStart('li', array('id' => 'user_nudge')); + $nf = new NudgeForm($this, $user); + $nf->show(); + $this->elementEnd('li'); + } + } + + if ($cur && $cur->id != $this->profile->id) { $blocked = $cur->hasBlocked($this->profile); @@ -349,7 +366,7 @@ class ShowstreamAction extends Action $url = common_local_url('remotesubscribe', array('nickname' => $this->profile->nickname)); $this->element('a', array('href' => $url, - 'id' => 'remotesubscribe'), + 'id' => 'user_subscribe_remote'), _('Subscribe')); } diff --git a/lib/nudgeform.php b/lib/nudgeform.php index 7d04e11e4..6374a7698 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 * @@ -102,4 +115,4 @@ class NudgeForm extends Form { $this->out->submit('submit', _('Send a nudge')); } -} \ No newline at end of file +} diff --git a/lib/util.php b/lib/util.php index 73c4cdcc8..ed7284183 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1645,25 +1645,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; -- cgit v1.2.3-54-g00ecf From 92e2f3babc89863518b8711a1b62661752d806f5 Mon Sep 17 00:00:00 2001 From: sarven Date: Wed, 21 Jan 2009 07:14:43 +0000 Subject: Added @title to user_action inputs and anchor and form legends --- actions/showstream.php | 5 +++-- lib/blockform.php | 14 +++++++++++++- lib/nudgeform.php | 14 +++++++++++++- lib/subscribeform.php | 13 ++++++++++++- lib/unblockform.php | 13 ++++++++++++- lib/unsubscribeform.php | 12 +++++++++++- 6 files changed, 64 insertions(+), 7 deletions(-) (limited to 'lib/nudgeform.php') diff --git a/actions/showstream.php b/actions/showstream.php index 6ed6abc9e..76249d14d 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -331,8 +331,9 @@ class ShowstreamAction extends Action $user = User::staticGet('id', $this->profile->id); if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) { $this->elementStart('li', array('id' => 'user_send-a-message')); - $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id))), - _('Send a message')); + $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)), + 'title' => _('Send a direct message to this user')), + _('Message')); $this->elementEnd('li'); if ($user->email && $user->emailnotifynudge) { 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/nudgeform.php b/lib/nudgeform.php index 6374a7698..7380462a7 100644 --- a/lib/nudgeform.php +++ b/lib/nudgeform.php @@ -105,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 * @@ -113,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')); } } 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 @@ -110,6 +110,17 @@ class UnblockForm extends Form return common_local_url('unblock'); } + /** + * Legend of the Form + * + * @return void + */ + function formLegend() + { + $this->out->element('legend', null, _('Unblock this user')); + } + + /** * Data elements of the form * @@ -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 @@ -103,6 +103,16 @@ class UnsubscribeForm extends Form return common_local_url('unsubscribe'); } + /** + * Legend of the Form + * + * @return void + */ + function formLegend() + { + $this->out->element('legend', null, _('Unsubscribe from this user')); + } + /** * Data elements of the form * @@ -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')); } } -- cgit v1.2.3-54-g00ecf