* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-
class ShowbookmarkAction extends ShownoticeAction
{
protected $bookmark = null;
- /**
- * For initializing members of the class.
- *
- * @param array $argarray misc. arguments
- *
- * @return boolean true
- */
-
- function prepare($argarray)
+ function getNotice()
{
- OwnerDesignAction::prepare($argarray);
-
- $this->user = User::staticGet('id', $this->trimmed('user'));
-
- if (empty($this->user)) {
- throw new ClientException(_('No such user.'), 404);
- }
-
- $this->profile = $this->user->getProfile();
-
- if (empty($this->profile)) {
- throw new ServerException(_('User without a profile.'));
- }
-
- $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
-
- sscanf($this->trimmed('crc32'), '%08x', $crc32);
-
- if (empty($crc32)) {
- throw new ClientException(_('No such URL.'), 404);
- }
-
- $dt = DateTime::createFromFormat('YmdHis',
- $this->trimmed('created'),
- new DateTimeZone('UTC'));
+ $this->id = $this->trimmed('id');
- if (empty($dt)) {
- throw new ClientException(_('No such create date.'), 404);
- }
-
- $bookmarks = Bookmark::getByCRC32($this->profile,
- $crc32);
-
- foreach ($bookmarks as $bookmark) {
- $bdt = new DateTime($bookmark->created, new DateTimeZone('UTC'));
- if ($bdt->getTimestamp() == $dt->getTimestamp()) {
- $this->bookmark = $bookmark;
- break;
- }
- }
+ $this->bookmark = Bookmark::getKV('id', $this->id);
if (empty($this->bookmark)) {
- throw new ClientException(_('No such bookmark.'), 404);
+ // TRANS: Client exception thrown when referring to a non-existing bookmark.
+ throw new ClientException(_m('No such bookmark.'), 404);
}
- $this->notice = Notice::staticGet('uri', $this->bookmark->uri);
+ $notice = Notice::getKV('uri', $this->bookmark->uri);
- if (empty($this->notice)) {
+ if (empty($notice)) {
// Did we used to have it, and it got deleted?
- throw new ClientException(_('No such bookmark.'), 404);
+ // TRANS: Client exception thrown when referring to a non-existing bookmark.
+ throw new ClientException(_m('No such bookmark.'), 404);
}
- return true;
+ return $notice;
+ }
+
+ /**
+ * Title of the page
+ *
+ * Used by Action class for layout.
+ *
+ * @return string page tile
+ */
+ function title()
+ {
+ // TRANS: Title for bookmark.
+ // TRANS: %1$s is a user nickname, %2$s is a bookmark title.
+ return sprintf(_m('%1$s\'s bookmark for "%2$s"'),
+ $this->user->nickname,
+ $this->bookmark->title);
+ }
+
+ /**
+ * Overload page title display to show bookmark link
+ *
+ * @return void
+ */
+ function showPageTitle()
+ {
+ $this->elementStart('h1');
+ $this->element('a',
+ array('href' => $this->bookmark->url),
+ $this->bookmark->title);
+ $this->elementEnd('h1');
}
}