TUTOS PHP Cross Reference Groupware Applications

Source: /php/handler.pinc - 92 lines - 2354 bytes - Summary - Text - Print

Description: Copyright 2002 - 2013 by Gero Kohnert This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

   1  <?php
   2  /**
   3   * Copyright 2002 - 2013 by Gero Kohnert
   4   *
   5   *  This program is free software; you can redistribute it and/or modify it
   6   *  under the terms of the GNU General Public License as published by the
   7   *  Free Software Foundation; version 2 of the License.
   8   *
   9   *  SVN Info  $Id: handler.pinc 1183 2013-11-22 12:09:54Z gokohnert $
  10   *  $Author: gokohnert $
  11   */
  12  $tutos['files'][__FILE__] = '$Rev: 1183 $';
  13  
  14  /**
  15   * run handler for given input and type
  16   */
  17  Function handle($type,$obj,$arg) {
  18      global $tutos,$msg,$info;
  19  
  20      $r = '';
  21      $cnt = 0;
  22      if (!isset($tutos[handler][$type]) || (count($tutos[handler][$type]) == 0) ) {
  23          return $arg;
  24      }
  25      // First Check
  26      foreach($tutos[handler][$type] as $i => $f) {
  27          if (file_exists($tutos['base'] .'/php/'. $f)) {
  28              include_once  $tutos['base'] .'/php/'. $f;
  29              if (class_exists($i)) {
  30                  $x = new $i();
  31                  if ( ! is_subclass_of($x,'tutos_handler') ) {
  32                      Fatal_Error('Wrong handler class: '. $i);
  33                  }
  34                  if ($x->check($obj,$arg)) {
  35                      $cnt++;
  36                  }
  37                  unset($x);
  38              }
  39          }
  40      }
  41      if ($cnt > 1) {
  42          $r = $arg;
  43      }
  44  
  45      foreach($tutos[handler][$type] as $i => $f) {
  46          if (file_exists($tutos['base'] .'/php/'. $f)) {
  47              include_once  $tutos['base'] .'/php/'. $f;
  48              if (class_exists($i)) {
  49                  $x = new $i($obj->dbconn);
  50                  if ( ! is_subclass_of($x,'tutos_handler') ) {
  51                      Fatal_Error('Wrong handler class: '. $i);
  52                  }
  53                  if ($x->check($obj,$arg)) {
  54                      $r .= $x->handle($obj,$arg,$cnt);
  55                  }
  56                  unset($x);
  57              } else {
  58                  $r .= $i .' not correctly configured';
  59              }
  60          } else {
  61              $r .= $arg.'<br /> ('. $i .' handler not found)';
  62          }
  63      }
  64      if ($r == '') {
  65          $r = $arg;
  66      }
  67      return $r;
  68  }
  69  
  70  /**
  71   * INTERFACE !!
  72   * This class is the base for all extension handlers
  73   * @package BASE
  74   * @module tutos_handler
  75   */
  76  abstract class tutos_handler
  77  {
  78      /**
  79       * run the handler
  80       */
  81      function handle($obj,$arg,$cnt) {
  82      }
  83  
  84      /**
  85       * check if all is ok
  86       */
  87      function check($obj,$arg) {
  88          return false;
  89      }
  90  }
  91  
  92  ?>

title

Description

title

Description

title

Description

title

title

Body