Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.
   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4: */
   3  // +----------------------------------------------------------------------+
   4  // | PHP version 4.0                                                      |
   5  // +----------------------------------------------------------------------+
   6  // | Copyright (c) 1997-2003 The PHP Group                                |
   7  // +----------------------------------------------------------------------+
   8  // | This source file is subject to version 2.0 of the PHP license,       |
   9  // | that is bundled with this package in the file LICENSE, and is        |
  10  // | available at through the world-wide-web at                           |
  11  // | http://www.php.net/license/2_02.txt.                                 |
  12  // | If you did not receive a copy of the PHP license and are unable to   |
  13  // | obtain it through the world-wide-web, please send a note to          |
  14  // | license@php.net so we can mail you a copy immediately.               |
  15  // +----------------------------------------------------------------------+
  16  // | Author: Alexey Borzov <borz_off@cs.msu.su>                           |
  17  // +----------------------------------------------------------------------+
  18  //
  19  // $Id$
  20  
  21  /**
  22   * An abstract base class for QuickForm renderers
  23   * 
  24   * The class implements a Visitor design pattern
  25   *
  26   * @abstract
  27   * @author Alexey Borzov <borz_off@cs.msu.su>
  28   */
  29  class HTML_QuickForm_Renderer
  30  {
  31     /**
  32      * Constructor
  33      *
  34      * @access public
  35      */
  36      public function __construct() {
  37      } // end constructor
  38  
  39      /**
  40       * Old syntax of class constructor. Deprecated in PHP7.
  41       *
  42       * @deprecated since Moodle 3.1
  43       */
  44      public function HTML_QuickForm_Renderer() {
  45          debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
  46          self::__construct();
  47      }
  48  
  49     /**
  50      * Called when visiting a form, before processing any form elements
  51      *
  52      * @param    object    An HTML_QuickForm object being visited
  53      * @access   public
  54      * @return   void 
  55      * @abstract
  56      */
  57      function startForm(&$form)
  58      {
  59          return;
  60      } // end func startForm
  61  
  62     /**
  63      * Called when visiting a form, after processing all form elements
  64      * 
  65      * @param    object     An HTML_QuickForm object being visited
  66      * @access   public
  67      * @return   void 
  68      * @abstract
  69      */
  70      function finishForm(&$form)
  71      {
  72          return;
  73      } // end func finishForm
  74  
  75     /**
  76      * Called when visiting a header element
  77      *
  78      * @param    object     An HTML_QuickForm_header element being visited
  79      * @access   public
  80      * @return   void 
  81      * @abstract
  82      */
  83      function renderHeader(&$header)
  84      {
  85          return;
  86      } // end func renderHeader
  87  
  88     /**
  89      * Called when visiting an element
  90      *
  91      * @param    object     An HTML_QuickForm_element object being visited
  92      * @param    bool       Whether an element is required
  93      * @param    string     An error message associated with an element
  94      * @access   public
  95      * @return   void 
  96      * @abstract
  97      */
  98      function renderElement(&$element, $required, $error)
  99      {
 100          return;
 101      } // end func renderElement
 102  
 103     /**
 104      * Called when visiting a hidden element
 105      * 
 106      * @param    object     An HTML_QuickForm_hidden object being visited
 107      * @access   public
 108      * @return   void
 109      * @abstract 
 110      */
 111      function renderHidden(&$element)
 112      {
 113          return;
 114      } // end func renderHidden
 115  
 116     /**
 117      * Called when visiting a raw HTML/text pseudo-element
 118      * 
 119      * Seems that this should not be used when using a template-based renderer
 120      *
 121      * @param    object     An HTML_QuickForm_html element being visited
 122      * @access   public
 123      * @return   void 
 124      * @abstract
 125      */
 126      function renderHtml(&$data)
 127      {
 128          return;
 129      } // end func renderHtml
 130  
 131     /**
 132      * Called when visiting a group, before processing any group elements
 133      *
 134      * @param    object     An HTML_QuickForm_group object being visited
 135      * @param    bool       Whether a group is required
 136      * @param    string     An error message associated with a group
 137      * @access   public
 138      * @return   void 
 139      * @abstract
 140      */
 141      function startGroup(&$group, $required, $error)
 142      {
 143          return;
 144      } // end func startGroup
 145  
 146     /**
 147      * Called when visiting a group, after processing all group elements
 148      *
 149      * @param    object     An HTML_QuickForm_group object being visited
 150      * @access   public
 151      * @return   void 
 152      * @abstract
 153      */
 154      function finishGroup(&$group)
 155      {
 156          return;
 157      } // end func finishGroup
 158  } // end class HTML_QuickForm_Renderer
 159  ?>