]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add some hooks for the profile page
authorEvan Prodromou <evan@status.net>
Fri, 9 Oct 2009 19:28:12 +0000 (15:28 -0400)
committerEvan Prodromou <evan@status.net>
Fri, 9 Oct 2009 19:28:12 +0000 (15:28 -0400)
EVENTS.txt
actions/showstream.php

index 02b11a8a6772db26a76e620c672bbf937a6e0c69..68c7a2961bce45c1487ecdeda340d1297c5a6258 100644 (file)
@@ -291,3 +291,45 @@ EndShowHeadElements: Right before the </head> tag; put <script>s here if you nee
 - $action: the current action
 
 CheckSchema: chance to check the schema
+
+StartShowLargeProfileSection: Starting to show the section of the
+                              profile page with the actual profile data;
+                              hook to prevent showing the profile (e.g.)
+- $action: the current action
+- &$profile: the profile being shown
+
+StartShowLargeProfileElements: inside the section, before the first
+                               element; prepend elements here
+- $action: the current action
+- &$profile: the profile being shown
+
+EndShowLargeProfileElements: inside the section, after the last element;
+                             append elements here
+- $action: the current action
+- &$profile: the profile being shown
+
+EndShowLargeProfileSection: After showing the section of the profile
+                            page with the profile elements
+- $action: the current action
+- &$profile: the profile being shown
+
+StartShowLargeEntityActionsSection: Starting to show the section of the
+                                    profile page with action links; hook
+                                    to hide them (for example)
+- $action: the current action
+- &$profile: the profile being shown
+
+StartShowLargeEntityActionsElements: inside the list, before the first
+                                     element; prepend elements here
+- $action: the current action
+- &$profile: the profile being shown
+
+EndShowLargeEntityActionsElements: inside the list, after the last element;
+                                   append elements here
+- $action: the current action
+- &$profile: the profile being shown
+
+EndShowLargeEntityActionsSection: After showing the section of the profile
+                                  page with the entity actions
+- $action: the current action
+- &$profile: the profile being shown
index 07d5d9eae083ef85cbb44fd595219895a72ac7a0..83ac496cad8b4b559a8c9c27b5a04d872593bc66 100644 (file)
@@ -181,168 +181,195 @@ class ShowstreamAction extends ProfileAction
 
     function showProfile()
     {
-        $this->elementStart('div', 'entity_profile vcard author');
-        $this->element('h2', null, _('User profile'));
-
-        $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
-        $this->elementStart('dl', 'entity_depiction');
-        $this->element('dt', null, _('Photo'));
-        $this->elementStart('dd');
-        $this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE),
-                                    'class' => 'photo avatar',
-                                    'width' => AVATAR_PROFILE_SIZE,
-                                    'height' => AVATAR_PROFILE_SIZE,
-                                    'alt' => $this->profile->nickname));
-        $this->elementEnd('dd');
-
-        $user = User::staticGet('id', $this->profile->id);
-        $cur = common_current_user();
-        if ($cur && $cur->id == $user->id) {
-            $this->elementStart('dd');
-            $this->element('a', array('href' => common_local_url('avatarsettings')), _('Edit Avatar'));
-            $this->elementEnd('dd');
-        }
+        $this->showProfileData();
+        $this->showEntityActions();
+    }
 
-        $this->elementEnd('dl');
-
-        $this->elementStart('dl', 'entity_nickname');
-        $this->element('dt', null, _('Nickname'));
-        $this->elementStart('dd');
-        $hasFN = ($this->profile->fullname) ? 'nickname url uid' : 'fn nickname url uid';
-        $this->element('a', array('href' => $this->profile->profileurl,
-                                  'rel' => 'me', 'class' => $hasFN),
-                       $this->profile->nickname);
-        $this->elementEnd('dd');
-        $this->elementEnd('dl');
-
-        if ($this->profile->fullname) {
-            $this->elementStart('dl', 'entity_fn');
-            $this->element('dt', null, _('Full name'));
-            $this->elementStart('dd');
-            $this->element('span', 'fn', $this->profile->fullname);
-            $this->elementEnd('dd');
-            $this->elementEnd('dl');
-        }
+    function showProfileData()
+    {
+        if (Event::handle('StartShowLargeProfileSection', array(&$this, &$this->profile))) {
+
+            $this->elementStart('div', 'entity_profile vcard author');
+            $this->element('h2', null, _('User profile'));
+
+            if (Event::handle('StartShowLargeProfileElements', array(&$this, &$this->profile))) {
+
+                $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
+                $this->elementStart('dl', 'entity_depiction');
+                $this->element('dt', null, _('Photo'));
+                $this->elementStart('dd');
+                $this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE),
+                                            'class' => 'photo avatar',
+                                            'width' => AVATAR_PROFILE_SIZE,
+                                            'height' => AVATAR_PROFILE_SIZE,
+                                            'alt' => $this->profile->nickname));
+                $this->elementEnd('dd');
+
+                $user = User::staticGet('id', $this->profile->id);
+                $cur = common_current_user();
+                if ($cur && $cur->id == $user->id) {
+                    $this->elementStart('dd');
+                    $this->element('a', array('href' => common_local_url('avatarsettings')), _('Edit Avatar'));
+                    $this->elementEnd('dd');
+                }
 
-        if ($this->profile->location) {
-            $this->elementStart('dl', 'entity_location');
-            $this->element('dt', null, _('Location'));
-            $this->element('dd', 'label', $this->profile->location);
-            $this->elementEnd('dl');
-        }
+                $this->elementEnd('dl');
+
+                $this->elementStart('dl', 'entity_nickname');
+                $this->element('dt', null, _('Nickname'));
+                $this->elementStart('dd');
+                $hasFN = ($this->profile->fullname) ? 'nickname url uid' : 'fn nickname url uid';
+                $this->element('a', array('href' => $this->profile->profileurl,
+                                          'rel' => 'me', 'class' => $hasFN),
+                               $this->profile->nickname);
+                $this->elementEnd('dd');
+                $this->elementEnd('dl');
+
+                if ($this->profile->fullname) {
+                    $this->elementStart('dl', 'entity_fn');
+                    $this->element('dt', null, _('Full name'));
+                    $this->elementStart('dd');
+                    $this->element('span', 'fn', $this->profile->fullname);
+                    $this->elementEnd('dd');
+                    $this->elementEnd('dl');
+                }
 
-        if ($this->profile->homepage) {
-            $this->elementStart('dl', 'entity_url');
-            $this->element('dt', null, _('URL'));
-            $this->elementStart('dd');
-            $this->element('a', array('href' => $this->profile->homepage,
-                                      'rel' => 'me', 'class' => 'url'),
-                           $this->profile->homepage);
-            $this->elementEnd('dd');
-            $this->elementEnd('dl');
-        }
+                if ($this->profile->location) {
+                    $this->elementStart('dl', 'entity_location');
+                    $this->element('dt', null, _('Location'));
+                    $this->element('dd', 'label', $this->profile->location);
+                    $this->elementEnd('dl');
+                }
 
-        if ($this->profile->bio) {
-            $this->elementStart('dl', 'entity_note');
-            $this->element('dt', null, _('Note'));
-            $this->element('dd', 'note', $this->profile->bio);
-            $this->elementEnd('dl');
-        }
+                if ($this->profile->homepage) {
+                    $this->elementStart('dl', 'entity_url');
+                    $this->element('dt', null, _('URL'));
+                    $this->elementStart('dd');
+                    $this->element('a', array('href' => $this->profile->homepage,
+                                              'rel' => 'me', 'class' => 'url'),
+                                   $this->profile->homepage);
+                    $this->elementEnd('dd');
+                    $this->elementEnd('dl');
+                }
 
-        $tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
-
-        if (count($tags) > 0) {
-            $this->elementStart('dl', 'entity_tags');
-            $this->element('dt', null, _('Tags'));
-            $this->elementStart('dd');
-            $this->elementStart('ul', 'tags xoxo');
-            foreach ($tags as $tag) {
-                $this->elementStart('li');
-                // Avoid space by using raw output.
-                $pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
-                  common_local_url('peopletag', array('tag' => $tag)) .
-                  '">' . $tag . '</a>';
-                $this->raw($pt);
-                $this->elementEnd('li');
-            }
-            $this->elementEnd('ul');
-            $this->elementEnd('dd');
-            $this->elementEnd('dl');
-        }
+                if ($this->profile->bio) {
+                    $this->elementStart('dl', 'entity_note');
+                    $this->element('dt', null, _('Note'));
+                    $this->element('dd', 'note', $this->profile->bio);
+                    $this->elementEnd('dl');
+                }
 
-        $this->elementEnd('div');
+                $tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
+
+                if (count($tags) > 0) {
+                    $this->elementStart('dl', 'entity_tags');
+                    $this->element('dt', null, _('Tags'));
+                    $this->elementStart('dd');
+                    $this->elementStart('ul', 'tags xoxo');
+                    foreach ($tags as $tag) {
+                        $this->elementStart('li');
+                        // Avoid space by using raw output.
+                        $pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
+                          common_local_url('peopletag', array('tag' => $tag)) .
+                          '">' . $tag . '</a>';
+                        $this->raw($pt);
+                        $this->elementEnd('li');
+                    }
+                    $this->elementEnd('ul');
+                    $this->elementEnd('dd');
+                    $this->elementEnd('dl');
+                }
 
-        $this->elementStart('div', 'entity_actions');
-        $this->element('h2', null, _('User actions'));
-        $this->elementStart('ul');
+                Event::handle('EndShowLargeProfileElements', array(&$this, &$this->profile));
+            }
 
-        if (empty($cur)) { // not logged in
-            $this->elementStart('li', 'entity_subscribe');
-            $this->showRemoteSubscribeLink();
-            $this->elementEnd('li');
-        } else {
-            if ($cur->id == $this->profile->id) { // your own page
-                $this->elementStart('li', 'entity_edit');
-                $this->element('a', array('href' => common_local_url('profilesettings'),
-                                          'title' => _('Edit profile settings')),
-                               _('Edit'));
-                $this->elementEnd('li');
-            } else { // someone else's page
+            $this->elementEnd('div');
+            Event::handle('EndShowLargeProfileSection', array(&$this, &$this->profile));
+        }
+    }
 
-                // subscribe/unsubscribe button
+    function showEntityActions()
+    {
+        if (Event::handle('StartShowLargeEntityActionsSection', array(&$this, &$this->profile))) {
 
-                $this->elementStart('li', 'entity_subscribe');
+            $this->elementStart('div', 'entity_actions');
+            $this->element('h2', null, _('User actions'));
+            $this->elementStart('ul');
 
-                if ($cur->isSubscribed($this->profile)) {
-                    $usf = new UnsubscribeForm($this, $this->profile);
-                    $usf->show();
+            if (Event::handle('StartShowLargeEntityActionsElements', array(&$this, &$this->profile))) {
+                if (empty($cur)) { // not logged in
+                    $this->elementStart('li', 'entity_subscribe');
+                    $this->showRemoteSubscribeLink();
+                    $this->elementEnd('li');
                 } else {
-                    $sf = new SubscribeForm($this, $this->profile);
-                    $sf->show();
-                }
-                $this->elementEnd('li');
-
-                if ($cur->mutuallySubscribed($user)) {
+                    if ($cur->id == $this->profile->id) { // your own page
+                        $this->elementStart('li', 'entity_edit');
+                        $this->element('a', array('href' => common_local_url('profilesettings'),
+                                                  'title' => _('Edit profile settings')),
+                                       _('Edit'));
+                        $this->elementEnd('li');
+                    } else { // someone else's page
 
-                    // message
+                        // subscribe/unsubscribe button
 
-                    $this->elementStart('li', 'entity_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');
+                        $this->elementStart('li', 'entity_subscribe');
 
-                    // nudge
+                        if ($cur->isSubscribed($this->profile)) {
+                            $usf = new UnsubscribeForm($this, $this->profile);
+                            $usf->show();
+                        } else {
+                            $sf = new SubscribeForm($this, $this->profile);
+                            $sf->show();
+                        }
+                        $this->elementEnd('li');
 
-                    if ($user->email && $user->emailnotifynudge) {
-                        $this->elementStart('li', 'entity_nudge');
-                        $nf = new NudgeForm($this, $user);
-                        $nf->show();
+                        if ($cur->mutuallySubscribed($user)) {
+
+                            // message
+
+                            $this->elementStart('li', 'entity_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');
+
+                            // nudge
+
+                            if ($user->email && $user->emailnotifynudge) {
+                                $this->elementStart('li', 'entity_nudge');
+                                $nf = new NudgeForm($this, $user);
+                                $nf->show();
+                                $this->elementEnd('li');
+                            }
+                        }
+
+                        // block/unblock
+
+                        $blocked = $cur->hasBlocked($this->profile);
+                        $this->elementStart('li', 'entity_block');
+                        if ($blocked) {
+                            $ubf = new UnblockForm($this, $this->profile,
+                                                   array('action' => 'showstream',
+                                                         'nickname' => $this->profile->nickname));
+                            $ubf->show();
+                        } else {
+                            $bf = new BlockForm($this, $this->profile,
+                                                array('action' => 'showstream',
+                                                      'nickname' => $this->profile->nickname));
+                            $bf->show();
+                        }
                         $this->elementEnd('li');
                     }
                 }
 
-                // block/unblock
-
-                $blocked = $cur->hasBlocked($this->profile);
-                $this->elementStart('li', 'entity_block');
-                if ($blocked) {
-                    $ubf = new UnblockForm($this, $this->profile,
-                                           array('action' => 'showstream',
-                                                 'nickname' => $this->profile->nickname));
-                    $ubf->show();
-                } else {
-                    $bf = new BlockForm($this, $this->profile,
-                                        array('action' => 'showstream',
-                                              'nickname' => $this->profile->nickname));
-                    $bf->show();
-                }
-                $this->elementEnd('li');
+                Event::handle('EndShowLargeEntityActionsElements', array(&$this, &$this->profile));
             }
-        }
 
-        $this->elementEnd('ul');
-        $this->elementEnd('div');
+            $this->elementEnd('ul');
+            $this->elementEnd('div');
+
+            Event::handle('EndShowLargeEntityActionsSection', array(&$this, &$this->profile));
+        }
     }
 
     function showRemoteSubscribeLink()