flash file handler
git-svn-id: file:///home/shish/svn/shimmie2/trunk@624 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
a5a6f4781c
commit
18934b481c
66
contrib/handle_flash/main.php
Normal file
66
contrib/handle_flash/main.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: Flash File Handler
|
||||
* Author: Shish <webmaster@shishnet.org>
|
||||
* Description: Handle Flash files
|
||||
*/
|
||||
|
||||
class FlashFileHandler extends Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event($event) {
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object("handle_flash", "FlashFileHandlerTheme");
|
||||
|
||||
if(is_a($event, 'DataUploadEvent') && $event->type == "swf" && $this->check_contents($event->tmpname)) {
|
||||
$hash = $event->hash;
|
||||
$ha = substr($hash, 0, 2);
|
||||
if(!copy($event->tmpname, "images/$ha/$hash")) {
|
||||
$event->veto("Flash Handler failed to move file from uploads to archive");
|
||||
return;
|
||||
}
|
||||
send_event(new ThumbnailGenerationEvent($event->hash, $event->type));
|
||||
$image = $this->create_image_from_data("images/$ha/$hash", $event->metadata);
|
||||
if(is_null($image)) {
|
||||
$event->veto("Flash Handler failed to create image object from data");
|
||||
return;
|
||||
}
|
||||
send_event(new ImageAdditionEvent($event->user, $image));
|
||||
}
|
||||
|
||||
if(is_a($event, 'ThumbnailGenerationEvent') && $event->type == "swf") {
|
||||
$hash = $event->hash;
|
||||
$ha = substr($hash, 0, 2);
|
||||
copy("ext/handle_flash/thumb.jpg", "thumbs/$ha/$hash");
|
||||
}
|
||||
|
||||
if(is_a($event, 'DisplayingImageEvent') && $event->image->ext == "swf") {
|
||||
$this->theme->display_image($event->page, $event->image);
|
||||
}
|
||||
}
|
||||
|
||||
private function create_image_from_data($filename, $metadata) {
|
||||
global $config;
|
||||
|
||||
$image = new Image();
|
||||
|
||||
// FIXME: need more flash format specs :|
|
||||
$image->width = 0;
|
||||
$image->height = 0;
|
||||
|
||||
$image->filesize = $metadata['size'];
|
||||
$image->hash = $metadata['hash'];
|
||||
$image->filename = $metadata['filename'];
|
||||
$image->ext = $metadata['extension'];
|
||||
$image->tag_array = tag_explode($metadata['tags']);
|
||||
$image->source = $metadata['source'];
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
private function check_contents($file) {
|
||||
// FIXME: flash magic header?
|
||||
return (file_exists($file));
|
||||
}
|
||||
}
|
||||
add_event_listener(new FlashFileHandler());
|
||||
?>
|
19
contrib/handle_flash/theme.php
Normal file
19
contrib/handle_flash/theme.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
class FlashFileHandlerTheme extends Themelet {
|
||||
public function display_image($page, $image) {
|
||||
$ilink = $image->get_image_link();
|
||||
// FIXME: object and embed have "height" and "width"
|
||||
$html = "
|
||||
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
|
||||
codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'>
|
||||
<param name='movie' value='$ilink'/>
|
||||
<param name='quality' value='high' />
|
||||
<embed src='$ilink' quality='high'
|
||||
pluginspage='http://www.macromedia.com/go/getflashplayer'
|
||||
type='application/x-shockwave-flash'></embed>
|
||||
</object>";
|
||||
$page->add_block(new Block("Image", $html, "main", 0));
|
||||
}
|
||||
}
|
||||
?>
|
BIN
contrib/handle_flash/thumb.jpg
Normal file
BIN
contrib/handle_flash/thumb.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
Loading…
x
Reference in New Issue
Block a user