diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-06-25 14:02:41 -0700 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-06-25 14:02:41 -0700 |
commit | b53b6b8769d5531c16ba58d4560119bcee8b39ff (patch) | |
tree | 69524e7f95d68fde05ffa91cf9d4106f37682e5a /lib | |
parent | a7cdf32df541bf73a47f1255b3e9f0a22c4724b4 (diff) | |
parent | e268cb5fd1a81835180a0f6190b7929d03ce42d7 (diff) |
Merge branch '0.8.x' of git@gitorious.org:+laconica-developers/laconica/dev into 0.8.x
Diffstat (limited to 'lib')
-rw-r--r-- | lib/noticelist.php | 2 | ||||
-rw-r--r-- | lib/util.php | 35 |
2 files changed, 32 insertions, 5 deletions
diff --git a/lib/noticelist.php b/lib/noticelist.php index 6f05c63d6..44726a17b 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -432,7 +432,7 @@ class NoticeListItem extends Widget $this->out->elementStart('dl', 'response'); $this->out->element('dt', null, _('To')); $this->out->elementStart('dd'); - $this->out->element('a', array('href' => $convurl), + $this->out->element('a', array('href' => $convurl.'#notice-'.$this->notice->id), _('in context')); $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); diff --git a/lib/util.php b/lib/util.php index 30b767c3e..f6d50b180 100644 --- a/lib/util.php +++ b/lib/util.php @@ -497,6 +497,22 @@ function common_linkify($url) { $attrs = array('href' => $longurl, 'rel' => 'external'); + $is_attachment = false; + $attachment_id = null; + $has_thumb = false; + + // Check to see whether there's a filename associated with this URL. + // If there is, it's an upload and qualifies as an attachment + + $localfile = File::staticGet('url', $longurl); + + if (!empty($localfile)) { + if (isset($localfile->filename)) { + $is_attachment = true; + $attachment_id = $localfile->id; + } + } + // if this URL is an attachment, then we set class='attachment' and id='attahcment-ID' // where ID is the id of the attachment for the given URL. // @@ -504,24 +520,35 @@ function common_linkify($url) { // we're currently picking up oembeds only. // I think the best option is another file_view table in the db // and associated dbobject. + $query = "select file_oembed.file_id as file_id from file join file_oembed on file.id = file_oembed.file_id where file.url='$longurl'"; $file = new File; $file->query($query); $file->fetch(); if (!empty($file->file_id)) { + $is_attachment = true; + $attachment_id = $file->file_id; + $query = "select file_thumbnail.file_id as file_id from file join file_thumbnail on file.id = file_thumbnail.file_id where file.url='$longurl'"; $file2 = new File; $file2->query($query); $file2->fetch(); - if (empty($file2->file_id)) { - $attrs['class'] = 'attachment'; - } else { + if (!empty($file2)) { + $has_thumb = true; + } + } + + // Add clippy + if ($is_attachment) { + $attrs['class'] = 'attachment'; + if ($has_thumb) { $attrs['class'] = 'attachment thumbnail'; } - $attrs['id'] = "attachment-{$file->file_id}"; + $attrs['id'] = "attachment-{$attachment_id}"; } + return XMLStringer::estring('a', $attrs, $display); } |