]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/shownotice.php
Merge branch '1.0.x' into feedsub-wizard
[quix0rs-gnu-social.git] / actions / shownotice.php
index c8e9cfe66a5ceb80d9154239b2d42febeff8879e..b8927372bb10d1c72e83da54ab66ec052d4944b3 100644 (file)
@@ -78,6 +78,9 @@ class ShownoticeAction extends OwnerDesignAction
     function prepare($args)
     {
         parent::prepare($args);
+        if ($this->boolean('ajax')) {
+            StatusNet::setApi(true);
+        }
 
         $id = $this->arg('notice');
 
@@ -167,11 +170,7 @@ class ShownoticeAction extends OwnerDesignAction
 
     function title()
     {
-        if (!empty($this->profile->fullname)) {
-            $base = $this->profile->fullname . ' (' . $this->profile->nickname . ')';
-        } else {
-            $base = $this->profile->nickname;
-        }
+        $base = $this->profile->getFancyName();
 
         return sprintf(_('%1$s\'s status on %2$s'),
                        $base,
@@ -192,22 +191,26 @@ class ShownoticeAction extends OwnerDesignAction
     {
         parent::handle($args);
 
-        if ($this->notice->is_local == Notice::REMOTE_OMB) {
-            if (!empty($this->notice->url)) {
-                $target = $this->notice->url;
-            } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) {
-                // Old OMB posts saved the remote URL only into the URI field.
-                $target = $this->notice->uri;
-            } else {
-                // Shouldn't happen.
-                $target = false;
-            }
-            if ($target && $target != $this->selfUrl()) {
-                common_redirect($target, 301);
-                return false;
+        if ($this->boolean('ajax')) {
+            $this->showAjax();
+        } else {
+            if ($this->notice->is_local == Notice::REMOTE_OMB) {
+                if (!empty($this->notice->url)) {
+                    $target = $this->notice->url;
+                } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) {
+                    // Old OMB posts saved the remote URL only into the URI field.
+                    $target = $this->notice->uri;
+                } else {
+                    // Shouldn't happen.
+                    $target = false;
+                }
+                if ($target && $target != $this->selfUrl()) {
+                    common_redirect($target, 301);
+                    return false;
+                }
             }
+            $this->showPage();
         }
-        $this->showPage();
     }
 
     /**
@@ -236,6 +239,21 @@ class ShownoticeAction extends OwnerDesignAction
         $this->elementEnd('ol');
     }
 
+    function showAjax()
+    {
+        header('Content-Type: text/xml;charset=utf-8');
+        $this->xw->startDocument('1.0', 'UTF-8');
+        $this->elementStart('html');
+        $this->elementStart('head');
+        $this->element('title', null, _('Notice'));
+        $this->elementEnd('head');
+        $this->elementStart('body');
+        $nli = new NoticeListItem($this->notice, $this);
+        $nli->show();
+        $this->elementEnd('body');
+        $this->elementEnd('html');
+    }
+
     /**
      * Don't show page notice
      *
@@ -278,12 +296,6 @@ class ShownoticeAction extends OwnerDesignAction
                                          'content' => $id->toString()));
         }
 
-        if ($user->jabbermicroid && $user->jabber && $this->notice->uri) {
-            $id = new Microid('xmpp:', $user->jabber,
-                              $this->notice->uri);
-            $this->element('meta', array('name' => 'microid',
-                                         'content' => $id->toString()));
-        }
         $this->element('link',array('rel'=>'alternate',
             'type'=>'application/json+oembed',
             'href'=>common_local_url(
@@ -298,10 +310,20 @@ class ShownoticeAction extends OwnerDesignAction
                 array(),
                 array('format'=>'xml','url'=>$this->notice->uri)),
             'title'=>'oEmbed'),null);
+
+        // Extras to aid in sharing notices to Facebook
+        $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
+        $avatarUrl = ($avatar) ?
+                     $avatar->displayUrl() :
+                     Avatar::defaultImage(AVATAR_PROFILE_SIZE);
+        $this->element('meta', array('property' => 'og:image',
+                                     'content' => $avatarUrl));
+        $this->element('meta', array('property' => 'og:description',
+                                     'content' => $this->notice->content));
     }
 }
 
-class SingleNoticeItem extends NoticeListItem
+class SingleNoticeItem extends DoFollowListItem
 {
     /**
      * recipe function for displaying a single notice.
@@ -325,8 +347,38 @@ class SingleNoticeItem extends NoticeListItem
         $this->showEnd();
     }
 
+    /**
+     * For our zoomed-in special case we'll use a fuller list
+     * for the attachment info.
+     */
     function showNoticeAttachments() {
         $al = new AttachmentList($this->notice, $this->out);
         $al->show();
     }
+
+    /**
+     * show the avatar of the notice's author
+     *
+     * We use the larger size for single notice page.
+     *
+     * @return void
+     */
+
+    function showAvatar()
+    {
+       $avatar_size = AVATAR_PROFILE_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));
+    }
 }