summaryrefslogtreecommitdiff
path: root/lib/attachmentlist.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-03-22 10:35:54 -0700
committerBrion Vibber <brion@pobox.com>2010-03-22 10:51:01 -0700
commit5697e4edb0fc4bb1d4c9365100501e795b2553de (patch)
treeab9755aa99f605c71ef0be611efedf2acd6d3412 /lib/attachmentlist.php
parent8a221228ebac156cbbb4693b06e25a0c59c858c3 (diff)
Replace the "give up and dump object" attachment view fallback with a client-side redirect to the target URL, which will at least be useful.
Diffstat (limited to 'lib/attachmentlist.php')
-rw-r--r--lib/attachmentlist.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php
index 51ceca857..fe38281af 100644
--- a/lib/attachmentlist.php
+++ b/lib/attachmentlist.php
@@ -306,7 +306,7 @@ class Attachment extends AttachmentListItem
function showRepresentation() {
if (empty($this->oembed->type)) {
if (empty($this->attachment->mimetype)) {
- $this->out->element('pre', null, 'oh well... not sure how to handle the following: ' . print_r($this->attachment, true));
+ $this->showFallback();
} else {
switch ($this->attachment->mimetype) {
case 'image/gif':
@@ -332,6 +332,8 @@ class Attachment extends AttachmentListItem
$this->out->element('param', array('name' => 'autoStart', 'value' => 1));
$this->out->elementEnd('object');
break;
+ default:
+ $this->showFallback();
}
}
} else {
@@ -354,9 +356,23 @@ class Attachment extends AttachmentListItem
break;
default:
- $this->out->element('pre', null, 'oh well... not sure how to handle the following oembed: ' . print_r($this->oembed, true));
+ $this->showFallback();
}
}
}
+
+ function showFallback()
+ {
+ // If we don't know how to display an attachment inline, we probably
+ // shouldn't have gotten to this point.
+ //
+ // But, here we are... displaying details on a file or remote URL
+ // either on the main view or in an ajax-loaded lightbox. As a lesser
+ // of several evils, we'll try redirecting to the actual target via
+ // client-side JS.
+
+ common_log(LOG_ERR, "Empty or unknown type for file id {$this->attachment->id}; falling back to client-side redirect.");
+ $this->out->raw('<script>window.location = ' . json_encode($this->attachment->url) . ';</script>');
+ }
}