Plugins

From MIDAS Wiki

Jump to: navigation, search

Contents

Available Plugins

  1. Project A user interface module for managing projects, experiments and tasks, process data and visualize results throught interactive tables and graphs
  2. BatchMake Server-side processing with MIDAS
  3. Dicom Receive/expose DICOM from/to DICOM nodes

Plugin Development

Plugins can be used to:

  1. Add features and functionality to MIDAS
  2. Change the layout of MIDAS

Creating a plugin for MIDAS

In this section we show how to create a plugin for MIDAS called 'myplugin'. It is recommend to read the CakePHP documentation regarding plugins for more information.

  1. Create a directory in the midas/plugins directory called 'myplugin'
  2. In myplugin/views/layouts create a 'plugin.thtml' layout by copying the default.thtml layout of the main midas
  3. In myplugin/webroot/css, create a plugin.style.css and maybe plugin.styleIE6.css
  4. Create a myplugin/myplugin_app_controller.php
 <?php
 class MypluginAppController extends AppController 
 {
   function __construct()
     {
     AppController::__construct();
     } 
 }
 ?>
  1. Create a myplugin/myplugin_app_model.php
 <?php
 class MyPluginAppModel extends AppModel
   {
 
   }
 ?>
  1. Create a myplugin/controllers/myplugin_controller.php you should implement these functions:
 class MypluginController extends MypluginAppController
   {
   var $name = 'Nonproliferation';
 
 /** Create Item */
 function create()
   {
   $vars = array();
   $vars['noview'] = true;
   return $vars;
   }
 /** View the community */
 function viewcommunity()
   {
   $vars = array();
   $vars['noview'] = true;
   return $vars;
   }
 /** View the collection */
 function viewcollection()
   {
   $vars = array();
   $vars['noview'] = true;
   return $vars;
   }
 /** Update Item */
 function updateItem()
   {
   $vars = array();
   $vars['noview'] = true;
   return $vars;
   }
 /** customize the item view*/
 function view()
   {
   $vars = array();
   $vars['noview'] = true;
   return $vars;
   }
 }  // end class MypluginController

Changing the layout

In order to change the layout of MIDAS, for instance to add your logo or change the color, and even change the way resources are displayed:

  1. In the config.php give a name to $MIDAS_CUSTOM_APPLICATION for instance:
 $MIDAS_CUSTOM_APPLICATION='myplugin';

Changing the layout for an item

If for instance you want to display more information regarding an item:

  • Copy the views/item/view.thtml file from the main MIDAS tree into plugins/myplugin/views/item/view.thml
  • In your myplugin_controller.php add the variables your want to display. For instance you want to display the related music for an item. Note that the value is usually store in the database but for simplicity reason we are hard-coding it in this example.
 /** customize the item view*/
 function view()
   {
   $vars = array();
   $vars['noview'] = true;
   $vars['itemRelatedMusic'] = 'Hip Hop'; <-- Added line
   return $vars;  
   }
  • In the view.thml you can display the itemRelatedMusic as follow:
 echo $myplugin_vars['itemRelatedMusic'];

Note that the array passed to the view is always of the forms $Name of the plugin_vars

Upgrading plugins

Plugins are automatically upgraded based on the version number in the pluginname/config/version.php.

In order to implement the upgrade for plugins:

  1. Create a model in pluginname/models/pluginname_upgrade.php
  2. Implement the upgrade() function. This function is automatically called by MIDAS when necessary.
Personal tools