X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fshownotice.php;h=7be9618f864f7bc99f9e7199d4b9bf2c82101fa0;hb=14a76926a225dec3d29aeffa13ab7ece74f708e5;hp=ccae49bb3e4a59e13c526117962ec130cd7ced4b;hpb=3d8a8aa03c7672966006aa0b7be5da699decbcb3;p=quix0rs-gnu-social.git diff --git a/actions/shownotice.php b/actions/shownotice.php index ccae49bb3e..7be9618f86 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -1,6 +1,6 @@ . * * @category Personal - * @package Laconica - * @author Evan Prodromou - * @copyright 2008-2009 Control Yourself, Inc. + * @package StatusNet + * @author Evan Prodromou + * @copyright 2008-2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } @@ -39,13 +39,13 @@ require_once INSTALLDIR.'/lib/feedlist.php'; * Show a single notice * * @category Personal - * @package Laconica - * @author Evan Prodromou + * @package StatusNet + * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ -class ShownoticeAction extends Action +class ShownoticeAction extends OwnerDesignAction { /** * Notice object to show @@ -83,18 +83,26 @@ class ShownoticeAction extends Action $this->notice = Notice::staticGet($id); - if (!$this->notice) { - $this->clientError(_('No such notice.'), 404); + if (empty($this->notice)) { + // Did we used to have it, and it got deleted? + $deleted = Deleted_notice::staticGet($id); + if (!empty($deleted)) { + $this->clientError(_('Notice deleted.'), 410); + } else { + $this->clientError(_('No such notice.'), 404); + } return false; } $this->profile = $this->notice->getProfile(); - if (!$this->profile) { - $this->serverError(_('Notice has no profile'), 500); + if (empty($this->profile)) { + $this->serverError(_('Notice has no profile.'), 500); return false; } + $this->user = User::staticGet('id', $this->profile->id); + $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); return true; @@ -106,7 +114,7 @@ class ShownoticeAction extends Action * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } @@ -122,7 +130,7 @@ class ShownoticeAction extends Action function lastModified() { - return max(strtotime($this->notice->created), + return max(strtotime($this->notice->modified), strtotime($this->profile->modified), ($this->avatar) ? strtotime($this->avatar->modified) : 0); } @@ -158,8 +166,14 @@ class ShownoticeAction extends Action function title() { + if (!empty($this->profile->fullname)) { + $base = $this->profile->fullname . ' (' . $this->profile->nickname . ') '; + } else { + $base = $this->profile->nickname; + } + return sprintf(_('%1$s\'s status on %2$s'), - $this->profile->nickname, + $base, common_exact_date($this->notice->created)); } @@ -177,15 +191,22 @@ class ShownoticeAction extends Action { parent::handle($args); - if ($this->notice->is_local == 0) { + if ($this->notice->is_local == Notice::REMOTE_OMB) { if (!empty($this->notice->url)) { - common_redirect($this->notice->url, 301); + $target = $this->notice->url; } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) { - common_redirect($this->notice->uri, 301); + // 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; } - } else { - $this->showPage(); } + $this->showPage(); } /** @@ -208,10 +229,10 @@ class ShownoticeAction extends Action function showContent() { - $this->elementStart('ul', array('class' => 'notices')); - $nli = new NoticeListItem($this->notice, $this); + $this->elementStart('ol', array('class' => 'notices xoxo')); + $nli = new SingleNoticeItem($this->notice, $this); $nli->show(); - $this->elementEnd('ul'); + $this->elementEnd('ol'); } /** @@ -262,5 +283,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( + 'oembed', + array(), + array('format'=>'json','url'=>$this->notice->uri)), + 'title'=>'oEmbed'),null); + $this->element('link',array('rel'=>'alternate', + 'type'=>'text/xml+oembed', + 'href'=>common_local_url( + 'oembed', + array(), + array('format'=>'xml','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(); } }