<?php
/**
 * Copyright 2002 by Gero Kohnert
 *
 *  CVS Info:  $Id: handler.pinc,v 1.12 2005/01/17 05:11:26 saraj Exp $
 *  $Author: saraj $
 */

/**
 * run handler for given input and type
 */
Function handle($type,&$obj,$arg) {
  global $tutos;
  $msg = "";
  if (!isset($tutos[handler][$type]) || (count($tutos[handler][$type]) == 0) ) {
    return $arg;
  }
  $cnt = count($tutos[handler][$type]);
  if ($cnt > 1) {
    $msg = $arg;
  }
  foreach($tutos[handler][$type] as $i => $f) {
    if (file_exists($tutos['base'] ."/". $f)) {
      include_once  $tutos['base'] ."/". $f;
	  if (class_exists($i)) {
        $x = new $i($obj->dbconn);
        if ( ! is_subclass_of($x,'tutos_handler') ) {
           Fatal_Error("Wrong handler class: ". $i);
        }
        $msg .= $x->handle($obj,$arg,$cnt);
	  } else {
        $msg .= $i ." not correctly configured";
	  }
    }
  }
  return $msg;
}

/**
 * INTERFACE !!
 * This class is the base for all extension handlers
 * @package BASE
 * @module tutos_handler
 */
class tutos_handler {
  /**
   * run the handler
   */
  function handle(&$obj,$cnt) {
  }
}

?>