diff options
| author | wjames5 <will@tekimaki.com> | 2008-05-12 21:30:57 +0000 |
|---|---|---|
| committer | wjames5 <will@tekimaki.com> | 2008-05-12 21:30:57 +0000 |
| commit | 6a6fa2e3e09feecdb77406c547d22e4561f4060e (patch) | |
| tree | b9500dae43d71007e2d3a71ce49dd8ac672ef15d /plugins/mime.flash.php | |
| parent | 165dd88906d59477cba2bfbbf2875d5aa28a5a77 (diff) | |
| download | liberty-6a6fa2e3e09feecdb77406c547d22e4561f4060e.tar.gz liberty-6a6fa2e3e09feecdb77406c547d22e4561f4060e.tar.bz2 liberty-6a6fa2e3e09feecdb77406c547d22e4561f4060e.zip | |
add flash swf mime type handler
Diffstat (limited to 'plugins/mime.flash.php')
| -rw-r--r-- | plugins/mime.flash.php | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/plugins/mime.flash.php b/plugins/mime.flash.php new file mode 100644 index 0000000..ae3e08b --- /dev/null +++ b/plugins/mime.flash.php @@ -0,0 +1,120 @@ +<?php +/** + * @version $Header: /cvsroot/bitweaver/_bit_liberty/plugins/mime.flash.php,v 1.1 2008/05/12 21:30:57 wjames5 Exp $ + * + * @author xing <xing@synapse.plus.com> + * @version $Revision: 1.1 $ + * created Sunday Jul 02, 2006 14:42:13 CEST + * @package liberty + * @subpackage liberty_mime_handler + **/ + +/** + * setup + */ +global $gLibertySystem; + +/** + * depending on the scan the default file might not be included yet. we need get it manually + */ +require_once( 'mime.default.php' ); + +/** + * This is the name of the plugin - max char length is 16 + * As a naming convention, the liberty mime handler definition should start with: + * PLUGIN_MIME_GUID_ + */ +define( 'PLUGIN_MIME_GUID_FLASH', 'mimeflash' ); + +$pluginParams = array( + // simply refer to the default functions - we only want to use a custom view_tpl here + 'verify_function' => 'mime_default_verify', + 'store_function' => 'mime_flash_store', + 'update_function' => 'mime_flash_update', + 'load_function' => 'mime_default_load', + 'download_function' => 'mime_default_download', + 'expunge_function' => 'mime_default_expunge', + // Brief description of what the plugin does + 'title' => 'Macromedia Flash', + 'description' => 'Allow upload and viewing of flash files.', + // Template used when viewing the item + 'view_tpl' => 'bitpackage:liberty/mime_flash_view_inc.tpl', + 'inline_tpl' => 'bitpackage:liberty/mime_flash_inline_inc.tpl', + // This should be the same for all mime plugins + 'plugin_type' => MIME_PLUGIN, + // Set this to TRUE if you want the plugin active right after installation + 'auto_activate' => FALSE, + // Allow for additional processing options - passed in during verify and store + /* Depricated we should be able to get this automagically from the swf + 'processing_options' => + '<label>'.tra( "Width" ).': <input type="text" size="5" name="plugin[swf_width]" />px </label><br />'. + '<label>'.tra( "Height" ).': <input type="text" size="5" name="plugin[swf_height]" />px </label><br />'. + tra( 'If this is a flash file please insert the width and hight.' ), + */ + // this should pick up all videos + 'mimetypes' => array( + '#application/x-shockwave-flash#i', + ), +); + +$gLibertySystem->registerPlugin( PLUGIN_MIME_GUID_FLASH, $pluginParams ); + +/** + * Update file settings - taken over by mime_default_store appart from the width and height settings + * + * @access public + * @return TRUE on success, FALSE on failure - $pStoreRow['errors'] will contain reason + */ +function mime_flash_update( &$pStoreRow ) { + global $gBitSystem; + if( $ret = mime_default_update( $pStoreRow ) ) { + mime_flash_store_preferences( $pStoreRow ); + } + return $ret; +} + +/** + * Store file settings - taken over by mime_default_store appart from the width and height settings + * + * @access public + * @return TRUE on success, FALSE on failure - $pStoreRow['errors'] will contain reason + */ +function mime_flash_store( &$pStoreRow ) { + global $gBitSystem; + + // this will set the correct pluign guid, even if we let default handle the store process + $pStoreRow['attachment_plugin_guid'] = PLUGIN_MIME_GUID_FLASH; + + if( $ret = mime_default_store( $pStoreRow ) ) { + mime_flash_store_preferences( $pStoreRow ); + } + return $ret; +} + +/** + * mime_flash_store_preferences + * + * @param array $pFileHash Flash information + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ +function mime_flash_store_preferences( &$pFileHash ) { + $ret = FALSE; + + if( @BitBase::verifyId( $pFileHash['attachment_id'] )) { + list( $pFileHash['preferences']['width'], $pFileHash['preferences']['height'], $type, $attr) = getimagesize( BIT_ROOT_PATH.$pFileHash['upload']['dest_path'].$pFileHash['upload']['name'] ); + + // store width of video + if( !empty( $pFileHash['preferences']['width'] )) { + LibertyMime::storeAttachmentPreference( $pFileHash['attachment_id'], 'width', $pFileHash['preferences']['width'] ); + } + // store height of video + if( !empty( $pFileHash['preferences']['height'] )) { + LibertyMime::storeAttachmentPreference( $pFileHash['attachment_id'], 'height', $pFileHash['preferences']['height'] ); + } + $ret = TRUE; + } + + return $ret; +} +?> |
