[ Index ]

PHP Cross Reference of Eventum

title

Body

[close]

/include/custom_field/ -> class.dynamic.php (source)

   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4 encoding=utf-8: */
   3  // +----------------------------------------------------------------------+
   4  // | Eventum - Issue Tracking System                                      |
   5  // +----------------------------------------------------------------------+
   6  // | Copyright (c) 2003, 2004, 2005, 2006, 2007 MySQL AB                  |
   7  // |                                                                      |
   8  // | This program is free software; you can redistribute it and/or modify |
   9  // | it under the terms of the GNU General Public License as published by |
  10  // | the Free Software Foundation; either version 2 of the License, or    |
  11  // | (at your option) any later version.                                  |
  12  // |                                                                      |
  13  // | This program is distributed in the hope that it will be useful,      |
  14  // | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
  15  // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
  16  // | GNU General Public License for more details.                         |
  17  // |                                                                      |
  18  // | You should have received a copy of the GNU General Public License    |
  19  // | along with this program; if not, write to:                           |
  20  // |                                                                      |
  21  // | Free Software Foundation, Inc.                                       |
  22  // | 59 Temple Place - Suite 330                                          |
  23  // | Boston, MA 02111-1307, USA.                                          |
  24  // +----------------------------------------------------------------------+
  25  // | Authors: Bryan Alsdorf <bryan@mysql.com>                             |
  26  // +----------------------------------------------------------------------+
  27  //
  28  
  29  require_once (APP_INC_PATH . "class.user.php");
  30  require_once (APP_INC_PATH . "db_access.php");
  31  
  32  
  33  /**
  34   * Custom field backend to assist other backends in dynamically changing the
  35   * contents of one field or hiding/showing based on another field.
  36   * 
  37   * @author Bryan Alsdorf <bryan@mysql.com>
  38   */
  39  class Dynamic_Custom_Field_Backend
  40  {
  41      function getList($fld_id)
  42      {
  43          $list = array();
  44          $data = $this->getStructuredData();
  45          foreach ($data as $row) {
  46              $list += $row['options'];
  47          }
  48          return $list;
  49      }
  50      
  51      
  52      /**
  53       * Returns a multi dimension array of data to display. The values listed
  54       * in the "keys" array are possible values for the controlling field to display
  55       * options from the "options" array.
  56       * For example, if you have a field 'name' that you want to display different
  57       * options in, depending on the contents of the 'color' field the array should
  58       * have the following structure:
  59       * array(
  60       *      array(
  61       *          "keys" =>   array("male", "dude"),
  62       *          "options"   =>  array(
  63       *              "bryan" =>  "Bryan",
  64       *              "joao"  =>  "Joao",
  65       *              "bob"   =>  "Bob"
  66       *          )
  67       *      ),
  68       *      array(
  69       *          "keys"  =>  array("female", "chick"),
  70       *          "options"   =>  array(
  71       *              "freya" =>  "Freya",
  72       *              "becky" =>  "Becky",
  73       *              "sharon"    =>  "Sharon",
  74       *              "layla"     =>  "Layla"
  75       *          )
  76       *      )
  77       * );
  78       * 
  79       * @return  array An array of data to display
  80       */
  81     function getStructuredData()
  82     {
  83         return array();
  84     }
  85     
  86     
  87      /**
  88       * Returns the ID of the "controlling" custom field.
  89       * 
  90       * @return   integer The ID of the controlling custom field
  91       */
  92      function getControllingCustomFieldID()
  93      {
  94          return 0;
  95      }
  96     
  97     
  98      /**
  99       * Returns the name of the "controlling" custom field.
 100       * 
 101       * @return   string The name of the controlling custom field
 102       */
 103      function getControllingCustomFieldName()
 104      {
 105          return '';
 106      }
 107      
 108      
 109      /**
 110       * Returns true if this row should be hidden if it has no value
 111       * 
 112       * @return  boolean True if this field should be hidden before options are set
 113       */
 114      function hideWhenNoOptions()
 115      {
 116          return false;
 117      }
 118  }
 119  
 120  


Generated: Wed Dec 19 21:21:33 2007 Cross-referenced by PHPXref 0.7