+ public function getUri()
+ {
+ return $this->uri;
+ }
+
+ /*
+ * Get a Notice object by URI. Will call external plugins for help
+ * using the event StartGetNoticeFromURI.
+ *
+ * @param string $uri A unique identifier for a resource (notice in this case)
+ */
+ static function fromUri($uri)
+ {
+ $notice = null;
+
+ if (Event::handle('StartGetNoticeFromUri', array($uri, &$notice))) {
+ $notice = Notice::getKV('uri', $uri);
+ Event::handle('EndGetNoticeFromUri', array($uri, $notice));
+ }
+
+ if (!$notice instanceof Notice) {
+ throw new UnknownUriException($uri);
+ }
+
+ return $notice;
+ }
+
+ /*
+ * @param $root boolean If true, link to just the conversation root.
+ *
+ * @return URL to conversation
+ */
+ public function getConversationUrl($anchor=true)
+ {
+ return Conversation::getUrlFromNotice($this, $anchor);
+ }
+
+ /*
+ * Get the local representation URL of this notice.
+ */
+ public function getLocalUrl()
+ {
+ return common_local_url('shownotice', array('notice' => $this->id), null, null, false);
+ }
+
+ public function getTitle()
+ {
+ $title = null;
+ if (Event::handle('GetNoticeTitle', array($this, &$title))) {
+ // TRANS: Title of a notice posted without a title value.
+ // TRANS: %1$s is a user name, %2$s is the notice creation date/time.
+ $title = sprintf(_('%1$s\'s status on %2$s'),
+ $this->getProfile()->getFancyName(),
+ common_exact_date($this->created));
+ }
+ return $title;
+ }
+
+ public function getContent()
+ {
+ return $this->content;
+ }
+
+ /*
+ * Get the original representation URL of this notice.
+ */
+ public function getUrl()
+ {
+ // The risk is we start having empty urls and non-http uris...
+ // and we can't really handle any other protocol right now.
+ switch (true) {
+ case common_valid_http_url($this->url): // should we allow non-http/https URLs?
+ return $this->url;
+ case $this->isLocal():
+ // let's generate a valid link to our locally available notice on demand
+ return common_local_url('shownotice', array('notice' => $this->id), null, null, false);
+ case common_valid_http_url($this->uri):
+ return $this->uri;
+ default:
+ common_debug('No URL available for notice: id='.$this->id);
+ throw new InvalidUrlException($this->url);
+ }
+ }
+
+ public function get_object_type($canonical=false) {
+ return $canonical
+ ? ActivityObject::canonicalType($this->object_type)
+ : $this->object_type;
+ }
+
+ public static function getByUri($uri)
+ {
+ $notice = new Notice();
+ $notice->uri = $uri;
+ if (!$notice->find(true)) {
+ throw new NoResultException($notice);
+ }
+ return $notice;
+ }
+