diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-05-26 23:24:01 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-05-26 23:24:01 -0400 |
commit | 648d967226f3b47aa6237d2be9d1a82df4f78402 (patch) | |
tree | 2592f56f0073ee21ce320a158233fdb1bd2710c4 /lib/util.php | |
parent | 6335c9cf59b384da24506c4a3f799315fbbc4b09 (diff) | |
parent | 0b53a820c2b4224b66b2a24f67302b4c5ca1deed (diff) |
Merge branch '0.8.x' into userdesign
Conflicts:
lib/attachmentlist.php
lib/noticelist.php
Diffstat (limited to 'lib/util.php')
-rw-r--r-- | lib/util.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/util.php b/lib/util.php index fbef8764a..d56f44f7b 100644 --- a/lib/util.php +++ b/lib/util.php @@ -496,6 +496,27 @@ function common_linkify($url) { } $attrs = array('href' => $longurl, 'rel' => 'external'); + +// 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. + $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)) { + $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 { + $attrs['class'] = 'attachment thumbnail'; + } + $attrs['id'] = "attachment-{$file->file_id}"; + } return XMLStringer::estring('a', $attrs, $display); } |