1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
<?php
/**
* @version $Header$
*
* @author xing <xing@synapse.plus.com>
* @version $Revision$
* created Sunday Jul 02, 2006 14:42:13 CEST
* @package liberty
* @subpackage liberty_mime_handler
**/
/**
* setup
*/
global $gLibertySystem;
/**
* 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.tpl',
'inline_tpl' => 'bitpackage:liberty/mime/flash/inline.tpl',
'storage_tpl' => 'bitpackage:liberty/mime/flash/inline.tpl',
'attachment_tpl' => 'bitpackage:liberty/mime/flash/inline.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;
// 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_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( STORAGE_PKG_PATH.$pFileHash['upload']['dest_branch'].$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;
}
?>
|