X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fshownotice.php;h=8f73dc824af6d6180fab885c571b7c265d8ebf0e;hb=adc5901d21be286ff3459f2cd2bf4373625ac5e5;hp=b0d973a991cad8e61cfa2d8ce632013e89f3201b;hpb=adfb79a9bbdfb43f35c0f022c1de6118b10ce115;p=quix0rs-gnu-social.git diff --git a/actions/shownotice.php b/actions/shownotice.php index b0d973a991..8f73dc824a 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -45,7 +45,7 @@ require_once INSTALLDIR.'/lib/feedlist.php'; * @link http://laconi.ca/ */ -class ShownoticeAction extends Action +class ShownoticeAction extends OwnerDesignAction { /** * Notice object to show @@ -83,18 +83,25 @@ class ShownoticeAction extends Action $this->notice = Notice::staticGet($id); - if (!$this->notice) { + if (empty($this->notice)) { $this->clientError(_('No such notice.'), 404); return false; } $this->profile = $this->notice->getProfile(); - if (!$this->profile) { + if (empty($this->profile)) { $this->serverError(_('Notice has no profile'), 500); return false; } + $this->user = User::staticGet('id', $this->profile->id); + + if (empty($this->user)) { + $this->serverError(_('Not a local notice'), 500); + return false; + } + $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); return true; @@ -158,8 +165,14 @@ class ShownoticeAction extends Action function title() { + if (!empty($this->profile->fullname)) { + $base = $this->profile->fullname . ' (' . $this->user->nickname . ') '; + } else { + $base = $this->user->nickname; + } + return sprintf(_('%1$s\'s status on %2$s'), - $this->profile->nickname, + $base, common_exact_date($this->notice->created)); } @@ -209,7 +222,7 @@ class ShownoticeAction extends Action function showContent() { $this->elementStart('ol', array('class' => 'notices xoxo')); - $nli = new NoticeListItem($this->notice, $this); + $nli = new SingleNoticeItem($this->notice, $this); $nli->show(); $this->elementEnd('ol'); } @@ -262,5 +275,45 @@ class ShownoticeAction extends Action $this->element('meta', array('name' => 'microid', 'content' => $id->toString())); } + $this->element('link',array('rel'=>'alternate', + 'type'=>'application/json+oembed', + 'href'=>common_local_url( + 'api', + array('apiaction'=>'oembed','method'=>'oembed.json'), + array('url'=>$this->notice->uri)), + 'title'=>'oEmbed'),null); + $this->element('link',array('rel'=>'alternate', + 'type'=>'text/xml+oembed', + 'href'=>common_local_url( + 'api', + array('apiaction'=>'oembed','method'=>'oembed.xml'), + array('url'=>$this->notice->uri)), + 'title'=>'oEmbed'),null); + } +} + +class SingleNoticeItem extends NoticeListItem +{ + /** + * recipe function for displaying a single notice. + * + * We overload to show attachments. + * + * @return void + */ + + function show() + { + $this->showStart(); + $this->showNotice(); + $this->showNoticeAttachments(); + $this->showNoticeInfo(); + $this->showNoticeOptions(); + $this->showEnd(); + } + + function showNoticeAttachments() { + $al = new AttachmentList($this->notice, $this->out); + $al->show(); } }