liberty
[ class tree: liberty ] [ index: liberty ] [ all elements ]

Source for file mime.application.php

Documentation is available at mime.application.php

  1. <?php
  2. /**
  3.  * @version     $Header$
  4.  *
  5.  * @author      xing  <xing@synapse.plus.com>
  6.  * @version     $Revision$
  7.  *  created      Thursday May 08, 2008
  8.  * @package     liberty
  9.  * @subpackage  liberty_mime_handler
  10.  *
  11.  * @TODO since plugins can do just about anything here, we might need the<br>
  12.  *  option to create specific tables during install. if required we can scan for<br>
  13.  *  files called:<br>
  14.  *  table.plugin_guid.php<br>
  15.  *  where plugins can insert their own tables<br>
  16.  ***/
  17.  
  18.  
  19. /**
  20.  * setup
  21.  */
  22. global $gLibertySystem;
  23.  
  24. /**
  25.  *  This is the name of the plugin - max char length is 16
  26.  * As a naming convention, the liberty mime handler definition should start with:
  27.  * PLUGIN_MIME_GUID_
  28.  */
  29. define'PLUGIN_MIME_GUID_APPLICATION''mimeapplication' );
  30.  
  31. $pluginParams array (
  32.     // Set of functions and what they are called in this paricular plugin
  33.     // Use the GUID as your namespace
  34.     'verify_function'    => 'mime_default_verify',
  35.     'store_function'     => 'mime_application_store',
  36.     'update_function'    => 'mime_application_update',
  37.     'load_function'      => 'mime_default_load',
  38.     'download_function'  => 'mime_default_download',
  39.     'expunge_function'   => 'mime_default_expunge',
  40.     // Brief description of what the plugin does
  41.     'title'              => 'Default App File Handler',
  42.     'description'        => 'This mime handler can handle any application file type, creates thumbnails when possible and will make the file available as an attachment.',
  43.     // Templates to display the files
  44.     'view_tpl'           => 'bitpackage:liberty/mime/application/view.tpl',
  45.     // This should be the same for all mime plugins
  46.     'plugin_type'        => MIME_PLUGIN,
  47.     // Set this to TRUE if you want the plugin active right after installation
  48.     'auto_activate'      => FALSE,
  49.     // Help page on bitweaver.org
  50.     //'help_page'          => 'MimeHelpPage',
  51.  
  52.     // Here you can use a perl regular expression to pick out file extensions you want to handle
  53.     // e.g.: Some image types: '#^image/(jpe?g|gif|png)#i'
  54.     // This plugin will be picked if nothing matches.
  55.     'mimetypes'           => array(
  56.         '#application/.*#i',
  57.     ),
  58. );
  59. $gLibertySystem->registerPluginPLUGIN_MIME_GUID_APPLICATION$pluginParams );
  60.  
  61. /**
  62.  * Store the data in the database
  63.  * 
  64.  * @param array $pStoreRow File data needed to store details in the database - sanitised and generated in the verify function
  65.  * @access public
  66.  * @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
  67.  */
  68. function mime_application_store&$pStoreRow {
  69.     // this will set the correct pluign guid, even if we let default handle the store process
  70.     $pStoreRow['attachment_plugin_guid'PLUGIN_MIME_GUID_APPLICATION;
  71.     $pStoreRow['log'array();
  72.  
  73.     // if storing works, we process the image
  74.     if$ret mime_default_store$pStoreRow )) {
  75.         // Dummy for later
  76.     }
  77.     return $ret;
  78. }
  79.  
  80. /**
  81.  * mime_application_update update file information in the database if there were changes.
  82.  * 
  83.  * @param array $pStoreRow File data needed to update details in the database
  84.  * @access public
  85.  * @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
  86.  */
  87. function mime_application_update&$pStoreRow$pParams NULL {
  88.     $ret FALSE;
  89.  
  90.     // this will set the correct pluign guid, even if we let default handle the store process
  91.     $pStoreRow['attachment_plugin_guid'PLUGIN_MIME_GUID_APPLICATION;
  92.  
  93.     // if storing works, we process the image
  94.     if!empty$pStoreRow['upload'&& $ret mime_default_update$pStoreRow )) {
  95.         // Dummy for later
  96.     }
  97.     return $ret;
  98. }
  99.  
  100. ?>

Documentation generated on Wed, 29 Jul 2015 13:57:05 +0000 by phpDocumentor 1.5.0-lsces