Source for file mime.pdf.php
Documentation is available at mime.pdf.php
* @author xing <xing@synapse.plus.com>
* created Thursday May 08, 2008
* @subpackage liberty_mime_handler
* This is the name of the plugin - max char length is 16
* As a naming convention, the liberty mime handler definition should start with:
define( 'PLUGIN_MIME_GUID_PDF', 'mimepdf' );
// Set of functions and what they are called in this paricular plugin
// Use the GUID as your namespace
'verify_function' => 'mime_default_verify',
'store_function' => 'mime_pdf_store',
'update_function' => 'mime_pdf_update',
'load_function' => 'mime_pdf_load',
'download_function' => 'mime_default_download',
'expunge_function' => 'mime_default_expunge',
//'help_function' => 'mime_pdf_help',
// Brief description of what the plugin does
'title' => 'Browsable PDFs',
'description' => 'Convert PDFs to flash files that can be browsed online.',
// Templates to display the files
'view_tpl' => 'bitpackage:liberty/mime/pdf/view.tpl',
//'attachment_tpl' => 'bitpackage:liberty/mime/image/attachment.tpl',
// url to page with options for this plugin
// This should be the same for all mime plugins
// Set this to TRUE if you want the plugin active right after installation
'auto_activate' => FALSE,
// Help page on bitweaver.org
//'help_page' => 'LibertyMime+Image+Plugin',
// this should pick up all image
* Store the data in the database
* @param array $pStoreRow File data needed to store details in the database - sanitised and generated in the verify function
* @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
// this will set the correct pluign guid, even if we let default handle the store process
$pStoreRow['log'] = array();
// if storing works, we process the image
// if it all goes tits up, we'll know why
$pStoreRow['errors'] = $pStoreRow['log'];
* mime_pdf_update update file information in the database if there were changes.
* @param array $pStoreRow File data needed to update details in the database
* @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
global $gThumbSizes, $gBitSystem;
// this will set the correct pluign guid, even if we let default handle the store process
// if storing works, we process the image
* Load file data from the database
* @param array $pFileHash Contains all file information
* @param array $pPrefs Attachment preferences taken liberty_attachment_prefs
* @param array $pParams Parameters for loading the plugin - e.g.: might contain values such as thumbnail size from the view page
* @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
function mime_pdf_load( &$pFileHash, &$pPrefs, $pParams = NULL ) {
// don't load a mime image if we don't have an image for this file
if( !empty( $ret['source_file'] )) {
$source_path = dirname( $ret['source_file'] ). '/';
// if the swf file exists, we pass it back that it can be viewed.
if( is_file( $source_path. 'pdf.swf' )) {
* mime_pdf_convert_pdf2swf Convert a PDF to a SWF video
* @param array $pFileHash file details.
* @param array $pFileHash[upload] should contain a complete hash from $_FILES
* @return TRUE on success, FALSE on failure
if( !empty( $pFileHash['upload'] ) && @BitBase::verifyId( $pFileHash['attachment_id'] )) {
$source .= 'original.jpg';
$source .= $pFileHash['upload']['name'];
$tmp_file = "$destPath/tmp.swf";
$swf_file = "$destPath/pdf.swf";
$pdf2swfcommand = "$pdf2swf -s insertstop -s jpegquality=". $gBitSystem->getConfig( 'liberty_thumbnail_quality', 85 ). " '$source' -o '$tmp_file'";
$combinecommand = "$swfcombine '$pdfviewer' loader='$swfloader' '#1'='$tmp_file' -o '$swf_file'";
// combination went wrong. remove swf file
$pFileHash['log']['swfcombine'] = "There was a problem combining the PDF SWF with the viewer.";
$pFileHash['log']['pdf2swf'] = "There was a problem converting the PDF to SWF.";
return( empty( $pFileHash['log'] ));
|