- $file: 'File' object to source the image from
- &$imgPath: Path to image file which can be used as source for our thumbnail algorithm.
- $media: MIME media type ('image', 'video', 'audio' etc.)
+
+StartShowAttachmentRepresentation: Attachment representation, full file (or in rare cases thumbnails/previews).
+- $out: HTMLOutputter class to use for outputting HTML.
+- $file: 'File' object which we're going to show representation for.
+
+EndShowAttachmentRepresentation: Executed after Attachment representation, despite perhaps being unsupported media.
+- $out: HTMLOutputter class to use for outputting HTML.
+- $file: 'File' object which we're going to show representation for.
+
+ShowUnsupportedAttachmentRepresentation: Attachment representation, full file (or in rare cases thumbnails/previews).
+- $out: HTMLOutputter class to use for outputting HTML.
+- $file: 'File' object which we're going to show representation for.
* @link http://status.net/
*/
-if (!defined('GNUSOCIAL') && !defined('STATUSNET')) {
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* widget for displaying a list of notice attachments
}
function showRepresentation() {
- if (empty($this->oembed->type)) {
- if (empty($this->attachment->mimetype)) {
- $this->showFallback();
- } else {
+ if (Event::handle('StartShowAttachmentRepresentation', array($this->out, $this->attachment))) {
+ if (!empty($this->oembed->type)) {
+ switch ($this->oembed->type) {
+ case 'rich':
+ case 'video':
+ case 'link':
+ if (!empty($this->oembed->html)) {
+ require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
+ $config = array(
+ 'safe'=>1,
+ 'elements'=>'*+object+embed');
+ $this->out->raw(htmLawed($this->oembed->html,$config));
+ }
+ break;
+
+ case 'photo':
+ $this->out->element('img', array('src' => $this->oembed->url, 'width' => $this->oembed->width, 'height' => $this->oembed->height, 'alt' => 'alt'));
+ break;
+
+ default:
+ Event::handle('ShowUnsupportedAttachmentRepresentation', array($this->out, $this->attachment));
+ }
+ } elseif (!empty($this->attachment->mimetype)) {
switch ($this->attachment->mimetype) {
case 'image/gif':
case 'image/png':
// Fall through to default.
default:
- $this->showFallback();
+ Event::handle('ShowUnsupportedAttachmentRepresentation', array($this->out, $this->attachment));
}
- }
- } else {
- switch ($this->oembed->type) {
- case 'rich':
- case 'video':
- case 'link':
- if (!empty($this->oembed->html)) {
- require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
- $config = array(
- 'safe'=>1,
- 'elements'=>'*+object+embed');
- $this->out->raw(htmLawed($this->oembed->html,$config));
- //$this->out->raw($this->oembed->html);
- }
- break;
-
- case 'photo':
- $this->out->element('img', array('src' => $this->oembed->url, 'width' => $this->oembed->width, 'height' => $this->oembed->height, 'alt' => 'alt'));
- break;
-
- default:
- $this->showFallback();
+ } else {
+ Event::handle('ShowUnsupportedAttachmentRepresentation', array($this->out, $this->attachment));
}
}
+ Event::handle('EndShowAttachmentRepresentation', array($this->out, $this->attachment));
}
protected function showHtmlFile(File $attachment)
return $scrubbed;
}
-
- function showFallback()
- {
- // still needed: should show a link?
- }
}