forked from GNUsocial/gnu-social
Enable events for showing Attachment representation
This commit is contained in:
parent
074b2b621c
commit
b0c4e8fc3d
12
EVENTS.txt
12
EVENTS.txt
@ -1445,3 +1445,15 @@ CreateFileImageThumbnailSource: Hook to create image thumbnail source from a Fil
|
||||
- $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.
|
||||
|
@ -28,9 +28,7 @@
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL') && !defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* widget for displaying a list of notice attachments
|
||||
@ -289,10 +287,29 @@ class Attachment extends AttachmentListItem
|
||||
}
|
||||
|
||||
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':
|
||||
@ -348,32 +365,13 @@ class Attachment extends AttachmentListItem
|
||||
// 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)
|
||||
@ -428,9 +426,4 @@ class Attachment extends AttachmentListItem
|
||||
|
||||
return $scrubbed;
|
||||
}
|
||||
|
||||
function showFallback()
|
||||
{
|
||||
// still needed: should show a link?
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user