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

Source for file mime.pbase.php

Documentation is available at mime.pbase.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.  
  12. /**
  13.  * setup
  14.  */
  15. global $gLibertySystem;
  16.  
  17. /**
  18.  *  This is the name of the plugin - max char length is 16
  19.  * As a naming convention, the liberty mime handler definition should start with:
  20.  * PLUGIN_MIME_GUID_
  21.  */
  22. define'PLUGIN_MIME_GUID_PBASE''mimepbase' );
  23.  
  24. $pluginParams array (
  25.     // Set of functions and what they are called in this paricular plugin
  26.     // Use the GUID as your namespace
  27.     'verify_function'     => 'mime_pbase_verify',
  28.     'store_function'      => 'mime_pbase_store',
  29.     //'update_function'     => 'mime_pbase_update',
  30.     'load_function'       => 'mime_pbase_load',
  31.     //'download_function'   => 'mime_pbase_download',
  32.     //'expunge_function'    => 'mime_pbase_expunge',
  33.     // Brief description of what the plugin does
  34.     'title'               => 'Display image from PBase',
  35.     'description'         => 'Use a PBase image ID to display it on your website.',
  36.     // Templates to display the files
  37.     'upload_tpl'          => 'bitpackage:liberty/mime/pbase/upload.tpl',
  38.     // url to page with options for this plugin
  39.     //'plugin_settings_url' => LIBERTY_PKG_URL.'admin/mime_pbase.php',
  40.     // This should be the same for all mime plugins
  41.     'plugin_type'         => MIME_PLUGIN,
  42.     // Set this to TRUE if you want the plugin active right after installation
  43.     'auto_activate'       => FALSE,
  44.     // Help page on bitweaver.org
  45.     //'help_page'           => 'LibertyMime+PBase+Plugin',
  46. );
  47. $gLibertySystem->registerPluginPLUGIN_MIME_GUID_PBASE$pluginParams );
  48.  
  49. function mime_pbase_verify&$pStoreRow {
  50.     global $gBitSystem$gBitUser;
  51.     $ret FALSE;
  52.     if@BitBase::verifyId$pStoreRow['pbase_id')) {
  53.         $pStoreRow['user_id']       @BitBase::verifyId$gBitUser->mUserId $gBitUser->mUserId ROOT_USER_ID;
  54.         $pStoreRow['attachment_id'$gBitSystem->mDb->GenID'liberty_attachments_id_seq' );
  55.         $ret TRUE;
  56.     else {
  57.         $pStoreRow['errors']['pbase_id'"No valid PBase ID given.";
  58.     }
  59.     return $ret;
  60. }
  61.  
  62. /**
  63.  * Store the data in the database
  64.  * 
  65.  * @param array $pStoreRow File data needed to store details in the database - sanitised and generated in the verify function
  66.  * @access public
  67.  * @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
  68.  */
  69. function mime_pbase_store&$pStoreRow {
  70.     global $gBitSystem;
  71.     $ret FALSE;
  72.     if@BitBase::verifyId$pStoreRow['pbase_id')) {
  73.         // add the data into liberty_attachments to make this file available as attachment
  74.         $storeHash array(
  75.             "attachment_id"          => $pStoreRow['attachment_id'],
  76.             "content_id"             => $pStoreRow['content_id'],
  77.             "attachment_plugin_guid" => PLUGIN_MIME_GUID_PBASE,
  78.             "foreign_id"             => $pStoreRow['pbase_id'],
  79.             "user_id"                => $pStoreRow['user_id'],
  80.         );
  81.         $gBitSystem->mDb->associateInsertBIT_DB_PREFIX."liberty_attachments"$storeHash );
  82.         $ret TRUE;
  83.     else {
  84.         $pStoreRow['errors']['pbase_id'"No valid PBase ID given.";
  85.     }
  86.     return $ret;
  87. }
  88.  
  89. /**
  90.  * mime_pbase_update update file information in the database if there were changes.
  91.  * 
  92.  * @param array $pStoreRow File data needed to update details in the database
  93.  * @access public
  94.  * @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
  95.  */
  96. function mime_pbase_update&$pStoreRow$pParams NULL {
  97. }
  98.  
  99. /**
  100.  * Load file data from the database
  101.  * 
  102.  * @param array $pFileHash Contains all file information
  103.  * @param array $pPrefs Attachment preferences taken liberty_attachment_prefs
  104.  * @param array $pParams Parameters for loading the plugin - e.g.: might contain values such as thumbnail size from the view page
  105.  * @access public
  106.  * @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
  107.  */
  108. function mime_pbase_load&$pFileHash&$pPrefs$pParams NULL {
  109.     $ret array();
  110.     if$ret mime_default_load$pFileHash$pPrefs$pParams )) {
  111.         $ret['display_url']             'http://www.pbase.com/image/'.$pFileHash['foreign_id'];
  112.         $ret['thumbnail_url']['small']  'http://www.pbase.com/image/'.$pFileHash['foreign_id'].'/small.jpg';
  113.         $ret['thumbnail_url']['medium''http://www.pbase.com/image/'.$pFileHash['foreign_id'].'/medium.jpg';
  114.         $ret['thumbnail_url']['large']  'http://www.pbase.com/image/'.$pFileHash['foreign_id'].'/large.jpg';
  115.         $ret['is_mime'TRUE;
  116.     }
  117.     return $ret;
  118. }
  119. ?>

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