Location: PHPKode > projects > SUPA - Screenshot UPload Applet > supa/action.php
<?php
/**
 * Example Action Plugin: Inserts a button into the toolbar
 *
 * @author Gina Haeussge <hide@address.com>
 */
 
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
require_once (DOKU_PLUGIN . 'action.php');

define( 'SUPA_UPLOAD_MIMETYPE', 'application/x-supa-screenshot' );
 
class action_plugin_supa extends DokuWiki_Action_Plugin {

  /**
   * Return some info
   */
  function getInfo() {
      return array (
          'author' => 'Christoph Linder',
          'email' => 'hide@address.com',
          'date' => '2008-11-12',
          'name' => 'Supa Action Plugin',
          'desc' => 'Generate the screenshot applet form on the mediamanager window',
          'url' => 'http://www.sourceforge.net/projects/supa',
      );
  }

  /**
   * Register the eventhandlers
   */
  function register(&$controller) {
    //$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'get_applet', array ());
    $controller->register_hook('MEDIAMANAGER_STARTED', 'BEFORE', $this, 'decode_upload', array ());
  }

  /**
   * Inserts the toolbar button
   */
   /*
  function get_applet( &$event, $param) {
    if( $_POST['supa__action'] ) {
      $supa = &plugin_load( 'helper', 'supa' );
      if( !$supa ) {
        //FIXME: error message
        die();
      }
      $ns = $_POST['supa__action__ns'];
      $auth = auth_quickaclcheck( "$ns:*" );

      $supa->getApplet( $ns, $auth );
      
      die();
    }
  }
  */

  function decode_upload( &$event ) {
    //FIXME: handle flash uploads?
    $f = &$_FILES['Filedata'];
    $id = $_REQUEST['id'];

    //print_r( $f );
    if( !$f || ! preg_match( '/\.supascreenshot$/', $f['name'] ) ) {
      return true;
    }

    //print_r( $_REQUEST );
    /*
    echo "name: ".$f['name']."\n";
    echo "type: ".$f['type']."\n";
    echo "tmp_name: ".$f['tmp_name'],"\n";
    echo "error: ".$f['error']."\n";
    echo "size: ".$f['size']."\n";
    */

    $supa = &plugin_load( 'helper', 'supa' );
    if( !$supa ) {
      msg( "Error while initializing Supa plugin", -1 );
      return false;
    }
    //FIXME: do not pass the $_FILES array but separate values
    $ret = $supa->decodeScreenshotFile( $f, $id ); 
    if( $ret ) {
      $_REQUEST['id'] = $id;
      $_POST['id'] = $id;
      $_GET['id'] = $id;
    }
    return $ret;
  }

}

Return current item: SUPA - Screenshot UPload Applet