/** * Look up the creation timestamp for a given notice ID, even * if it's been deleted. * * @param int $id * @return mixed string recorded creation timestamp, or false if can't be found */ public static function getAsTimestamp($id) { if (!$id) { return false; } $notice = Notice::getKV('id', $id); if ($notice) { return $notice->created; } $deleted = Deleted_notice::getKV('id', $id); if ($deleted) { return $deleted->created; } return false; }
/** * Show the notice * * @return void */ function showNotice() { if (!empty($this->notice)) { switch ($this->format) { case 'xml': $this->showSingleXmlStatus($this->notice); break; case 'json': $this->show_single_json_status($this->notice); break; case 'atom': $this->showSingleAtomStatus($this->notice); break; default: // TRANS: Exception thrown requesting an unsupported notice output format. // TRANS: %s is the requested output format. throw new Exception(sprintf(_("Unsupported format: %s."), $this->format)); } } else { // XXX: Twitter just sets a 404 header and doens't bother // to return an err msg $deleted = Deleted_notice::getKV($this->notice_id); if (!empty($deleted)) { $this->clientError(_('Status deleted.'), 410, $this->format); } else { $this->clientError(_('No status with that ID found.'), 404, $this->format); } } }
/** * Fetch the notice to show. This may be overridden by child classes to * customize what we fetch without duplicating all of the prepare() method. * * @return Notice */ protected function getNotice() { $id = $this->arg('notice'); $notice = Notice::getKV('id', $id); if ($notice instanceof Notice) { // Alright, got it! return $notice; } // Did we use to have it, and it got deleted? $deleted = Deleted_notice::getKV('id', $id); if ($deleted instanceof Deleted_notice) { // TRANS: Client error displayed trying to show a deleted notice. $this->clientError(_('Notice deleted.'), 410); } // TRANS: Client error displayed trying to show a non-existing notice. $this->clientError(_('No such notice.'), 404); }