History of TreasuryPackage

Version 13

TreasuryPackage

a pluggable file gallery for bitweaver

Created by: Anonymous, Last modification: 31 Mar 2007 (19:56 UTC) by xing
{r2}

Basic feature outline

  • Nested galleries.
    • It is possible to create galleries withn galleries making it easy to structurally organise file uploads.
    • Nested galleries use the LibertyStructure stystem, providing a uniform interface and behaviour.
  • Every gallery can have an image associated with it.
    • Gallery images are independent of gallery content and can therefor be used to illustrate the content of given gallery.
  • Pluggable MIME handlers
    • Any file that is uploaded is processed by the default MIME handler. You can simply drop a new MIME handler into the treasury/plugins directory, turn it on in the treasury admin screen. Any files that are uploaded with a defined set of MIME types will then be handled by the selected MIME handler (see below for a tutorial).
    • Default MIME handler creates thumbnails and inserts data in various places making the files available as globally available attachments.
    • If you don't like the thumbnail generated automagically, you can upload your own image, which will be scaled automatically.
  • Treasury allows the use of bitweaver services. This means you can use packages like pigeonholes to categorise galleries and files.
  • It is possible to assign individual permissions to galleries. This makes it possible to create public galleries or restrict galleries from public view.

PEAR::HTTP_Download

Installing PEAR::HTTP_Download will enable users to resume downloads and use download managers to connect and download files from your server. you can install this by executing the following as admin:

pear install --alldeps HTTP_Download

If you don't have admin privilidges on the server, you will have to ask the system admin to install this for you.
Note: This is not required.

Pluggable MIME handlers

Treasury allows you to specify how it should handle files of a given filetype. for instance, you might want to create a preview of videos that have been uploaded, or you might want to extract a chunk of text from textfiles, or parse excel files and convert them comma seperated values files...

anyway, the idea is that you can do anything with any of the files based on the MIME type of the uploaded file.

Available Plugins

  • Default mime handler
    a generic plugin that takes care of any filetype, creates thumbnails of images, inserts file details into liberty_attachments, making the files available in any wiki page or article.
  • Video handler
    requires mplayer to be installed on the server. extracts screen shots from various video types and displays these when viewing the file.
  • Flash handler
    will display the flash file inline when viewing the particular file page.
  • Theme handler
    a plugin specifically written for bitweaver styles and icon styles. this plugin will extract some relevant information when uploading a style or icon style.
  • Flashvideo creator - Required: ffmpeg - Optional: ffmpeg-php
    see TreasuryFlvPlugin for installation and plugin details

Create a custom Plugin

let's set up a custom plugin that uses all the features of the default plugin but does some extra stuff. this plugin is part of the distribution and is used here on bitweaver.org to process uploaded flash files.

Initiate the plugin and define the basics. most of this should be self explanatory and inline comments explain bits as well.

Plugin setup


<?php
/**
 * setup
 */
global $gTreasurySystem;

/**
 * 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 treasury mime handler definition should start with:
 * TREASURY_MIME_GUID_
 */
define'TREASURY_MIME_GUID_FLASH''mime_flash' );

$pluginParams = array(
    
// simply refer to the default functions - we only want to use a custom view_tpl here
    
'verify_function'    => 'treasury_default_verify',
    
'store_function'     => 'treasury_flash_store',
    
'update_function'    => 'treasury_flash_update',
    
'load_function'      => 'treasury_flash_load',
    
'download_function'  => 'treasury_default_download',
    
'expunge_function'   => 'treasury_default_expunge',

    
// Brief description of what the plugin does
    
'title'              => 'Macromedia Flash File Handler',
    
'description'        => 'Allow upload and viewing of flash files.',

    
// Template used when viewing the item
    
'view_tpl'           => 'bitpackage:treasury/view_flash_inc.tpl',

    
// This should be the same for all mime plugins
    
'plugin_type'        => TREASURY_MIME,

    
// 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
    
'processing_options' =>
        
'<label>'.tra"Width" ).': <input type="text" size="5" name="plugin[swf_width]" />px </label>
'
.
        
'<label>'.tra"Height" ).': <input type="text" size="5" name="plugin[swf_height]" />px </label>
'
.
        
tra'If this is a flash file please insert the width and hight.' ),

    
// this should pick up all flash files
    
'mimetypes'          => array(
        
'#application/x-shockwave-flash#i',
    ),
);

$gTreasurySystem->registerPluginTREASURY_MIME_GUID_FLASH$pluginParams );
?>


We are using a few custom function for this plugin to handle the custom data that has been passed in as processing options

File processing functions


<?php
/**
 * Update file settings - taken over by treasury_default_store appart from the width and height settings
 *
 * @access public
 * @return TRUE on success, FALSE on failure - $pStoreRow['errors'] will contain reason
 */
function treasury_flash_update( &$pStoreRow, &$pCommonObject ) {
    global 
$gBitSystem;
    if( 
$ret treasury_default_update$pStoreRow$pCommonObject ) ) {
        if( @
BitBase::verifyId$pStoreRow['plugin']['swf_width'] )) {
            
$pCommonObject->storePreference'swf_width'$pStoreRow['plugin']['swf_width'] );
        }

        if( @
BitBase::verifyId$pStoreRow['plugin']['swf_height'] )) {
            
$pCommonObject->storePreference'swf_height'$pStoreRow['plugin']['swf_height'] );
        }
    }
    return 
$ret;
}

/**
 * Store file settings - taken over by treasury_default_store appart from the width and height settings
 *
 * @access public
 * @return TRUE on success, FALSE on failure - $pStoreRow['errors'] will contain reason
 */
function treasury_flash_store( &$pStoreRow, &$pCommonObject ) {
    global 
$gBitSystem;
    if( 
$ret treasury_default_store$pStoreRow$pCommonObject ) ) {
        if( @
BitBase::verifyId$pStoreRow['plugin']['swf_width'] )) {
            
$pCommonObject->storePreference'swf_width'$pStoreRow['plugin']['swf_width'] );
        }

        if( @
BitBase::verifyId$pStoreRow['plugin']['swf_height'] )) {
            
$pCommonObject->storePreference'swf_height'$pStoreRow['plugin']['swf_height'] );
        }
    }
    return 
$ret;
}

/**
 * Load file data from the database
 *
 * @param array $pFileHash contains all file information
 * @param array $pCommonObject is the full object loaded. only set when we are actually loading the object, not just listing items
 * @access public
 * @return TRUE on success, FALSE on failure - ['errors'] will contain reason for failure
 */
function treasury_flash_load( &$pFileHash, &$pCommonObject ) {
    if( 
$ret treasury_default_load$pFileHash$pCommonObject ) ) {
        
// override default download_url since we want to point users to the view_tpl
        
$pFileHash['download_url'] = TreasuryItem::getDisplayUrl$pFileHash['content_id'], $pFileHash );
        
// this is the true download url we will use in the view_tpl
        
$pFileHash['download_swf'] = TreasuryItem::getDownloadUrl$pFileHash['content_id'] );
    }
    return 
$ret ;
}
?>

Page History
Date/CommentUserIPVersion
29 Apr 2009 (14:12 UTC)
update docs to explain customization feature
Will69.203.72.16117
Current • Source
Kozuch85.207.244.16016
View • Compare • Difference • Source
xing194.152.164.4514
View • Compare • Difference • Source
xing194.152.164.4513
View • Compare • Difference • Source
xing194.152.164.4512
View • Compare • Difference • Source
xing194.152.164.4511
View • Compare • Difference • Source
xing194.152.164.4510
View • Compare • Difference • Source
xing194.152.164.459
View • Compare • Difference • Source
xing194.152.164.458
View • Compare • Difference • Source
xing194.208.52.997
View • Compare • Difference • Source
xing194.208.52.996
View • Compare • Difference • Source
xing194.152.164.455
View • Compare • Difference • Source
Fábio Rampazzo Mathias201.52.178.714
View • Compare • Difference • Source
xing194.152.164.453
View • Compare • Difference • Source
xing194.152.164.452
View • Compare • Difference • Source
xing194.152.164.451
View • Compare • Difference • Source