Source for file referencefield.php

Documentation is available at referencefield.php

  1. <?php
  2. /**
  3. * a non-editable reference object to explain a table entry
  4. *
  5. * e.g. translates the userid into the user's real name.
  6. *
  7. *
  8. * @author    Stuart Prescott
  9. * @copyright  Copyright Stuart Prescott
  10. * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11. * @version    $Id$
  12. * @package    Bumblebee
  13. * @subpackage FormsLibrary
  14. */
  15.  
  16. /** Load ancillary functions */
  17. require_once 'inc/typeinfo.php';
  18.  
  19. /** parent object */
  20. require_once 'field.php';
  21. /** uses ExampleEntries object */
  22. require_once 'exampleentries.php';
  23.  
  24. /**
  25. * a non-editable reference object to explain a table entry
  26. *
  27. * @package    Bumblebee
  28. * @subpackage FormsLibrary
  29. */
  30. class ReferenceField extends Field {
  31.    /** @var ExampleEntries   list of example entries from the db */
  32.    var $example;
  33.  
  34.   /**
  35.   *  Create a new reference field object
  36.   *
  37.   * @param string $name   the name of the field (db name, and html field name
  38.   * @param string $longname  long name to be used in the label of the field in display
  39.   * @param string $description  used in the html title or longdesc for the field
  40.   */
  41.   function ReferenceField($name, $longname='', $description='') {
  42.     parent::Field($name, $longname, $description);
  43.   }
  44.  
  45.   /**
  46.   * add an extra field to the end of the formatted data
  47.   *
  48.   * @param string $table       db table for extra field
  49.   * @param string $matchfield  id/key field
  50.   * @param string $field       field to return in the list of examples
  51.   * @param integer $numentries (optional) the number of entries to return
  52.   */
  53.   function extraInfo($table, $matchfield, $field, $numentries=1) {
  54.     $this->example = new ExampleEntries('id', $table, $matchfield, $field, $numentries);
  55.   }
  56.  
  57.   function displayInTable($cols=3) {
  58.     $t = "<tr><td>$this->longname</td>\n"
  59.         ."<td title='$this->description'>";
  60.     $t .= xssqw($this->getValue());
  61.     $refdata = array('id'=>$this->getValue());
  62.     $t .= ' ('. $this->example->format($refdata).')';
  63.     $t .= "<input type='hidden' name='$this->namebase$this->name' "
  64.          ."value='".xssqw($this->getValue())."' />";
  65.     if (isset($this->duplicateName)) {
  66.       $t .= "<input type='hidden' name='$this->duplicateName' "
  67.            ."value='".xssqw($this->getValue())."' />";
  68.     }
  69.     $t .= "</td>\n";
  70.     for ($i=0; $i<$cols-2; $i++) {
  71.       $t .= '<td></td>';
  72.     }
  73.     $t .= '</tr>';
  74.     return $t;
  75.   }
  76.  
  77. } // class ReferenceField
  78.  
  79.  
  80. ?>

Documentation generated on Tue, 06 Mar 2007 10:01:56 +0000 by phpDocumentor 1.3.0