From b67bb182b008b5f7b66d39df7bb8dab449b7002a Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 23 Feb 2010 04:59:34 +0100 Subject: [PATCH] Refactored preview info and form for authorizing a remote subscription --- plugins/OStatus/actions/ostatussub.php | 113 +++++++++++++++++++++---- 1 file changed, 97 insertions(+), 16 deletions(-) diff --git a/plugins/OStatus/actions/ostatussub.php b/plugins/OStatus/actions/ostatussub.php index ffa88cb088..206fb309d2 100644 --- a/plugins/OStatus/actions/ostatussub.php +++ b/plugins/OStatus/actions/ostatussub.php @@ -87,29 +87,35 @@ class OStatusSubAction extends Action */ function showPreviewForm() { + if ($this->oprofile->isGroup()) { + $this->previewGroup(); + } else { + $this->previewUser(); + } + + $this->elementStart('div', 'entity_actions'); + $this->elementStart('ul'); + $this->elementStart('li', 'entity_subscribe'); $this->elementStart('form', array('method' => 'post', 'id' => 'form_ostatus_sub', - 'class' => 'form_settings', + 'class' => 'form_remote_authorize', 'action' => common_local_url('ostatussub'))); - + $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); $this->hidden('profile', $this->profile_uri); - - $this->elementStart('fieldset', array('id' => 'settings_feeds')); - if ($this->oprofile->isGroup()) { - $this->previewGroup(); - $this->submit('subscribe', _m('Join')); + $this->submit('submit', _m('Join'), 'submit', null, + _m('Join this group')); } else { - $this->previewUser(); - $this->submit('subscribe', _m('Subscribe')); + $this->submit('submit', _m('Subscribe'), 'submit', null, + _m('Subscribe to this user')); } - - $this->elementEnd('fieldset'); - $this->elementEnd('form'); + $this->elementEnd('li'); + $this->elementEnd('ul'); + $this->elementEnd('div'); } /** @@ -120,8 +126,7 @@ class OStatusSubAction extends Action $oprofile = $this->oprofile; $profile = $oprofile->localProfile(); - $this->text(sprintf(_m("Remote user %s"), $profile->nickname)); - // ... + $this->showEntity($profile); } /** @@ -132,8 +137,84 @@ class OStatusSubAction extends Action $oprofile = $this->oprofile; $group = $oprofile->localGroup(); - $this->text(sprintf(_m("Remote group %s"), $group->nickname)); - // .. + $this->showEntity($group); + } + + + function showEntity($entity) + { + $nickname = $entity->nickname; + $profile = $entity->profileurl; + $fullname = $entity->fullname; + $homepage = $entity->homepage; + $bio = $entity->bio; + $location = $entity->location; + $avatar = $entity->avatarurl; + + $this->elementStart('div', 'entity_profile vcard'); + $this->elementStart('dl', 'entity_depiction'); + $this->element('dt', null, _('Photo')); + $this->elementStart('dd'); + if ($avatar) { + $this->element('img', array('src' => $avatar, + 'class' => 'photo avatar', + 'width' => AVATAR_PROFILE_SIZE, + 'height' => AVATAR_PROFILE_SIZE, + 'alt' => $nickname)); + } + $this->elementEnd('dd'); + $this->elementEnd('dl'); + + $this->elementStart('dl', 'entity_nickname'); + $this->element('dt', null, _('Nickname')); + $this->elementStart('dd'); + $hasFN = ($fullname !== '') ? 'nickname' : 'fn nickname'; + $this->elementStart('a', array('href' => $profile, + 'class' => 'url '.$hasFN)); + $this->raw($nickname); + $this->elementEnd('a'); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + + if (!is_null($fullname)) { + $this->elementStart('dl', 'entity_fn'); + $this->elementStart('dd'); + $this->elementStart('span', 'fn'); + $this->raw($fullname); + $this->elementEnd('span'); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + } + if (!is_null($location)) { + $this->elementStart('dl', 'entity_location'); + $this->element('dt', null, _('Location')); + $this->elementStart('dd', 'label'); + $this->raw($location); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + } + + if (!is_null($homepage)) { + $this->elementStart('dl', 'entity_url'); + $this->element('dt', null, _('URL')); + $this->elementStart('dd'); + $this->elementStart('a', array('href' => $homepage, + 'class' => 'url')); + $this->raw($homepage); + $this->elementEnd('a'); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + } + + if (!is_null($bio)) { + $this->elementStart('dl', 'entity_note'); + $this->element('dt', null, _('Note')); + $this->elementStart('dd', 'note'); + $this->raw($bio); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + } + $this->elementEnd('div'); } /** -- 2.39.5