Structures_Form
[ class tree: Structures_Form ] [ index: Structures_Form ] [ all elements ]

Source for file GroupInterface.php

Documentation is available at GroupInterface.php

  1. <?php
  2. /**
  3.  * An interface to enforce consistency among all group elements used in a
  4.  * Structures_Form.
  5.  *
  6.  * In HTML_QuickForm, all form elements extend a common base class. In PHP-GTK
  7.  * 2 this is not possible because the elements need to be added to containes.
  8.  * To be added to a container a class must extends GtkWidget. While it is not
  9.  * possible to force all form elements to inherit from the same base class we
  10.  * can use an interface to enforce some consistency.
  11.  *
  12.  * A group is a way to logically and visually group elements together. It must
  13.  * be able to add, remove, reorder and return the elements in the group. It
  14.  * must also be able to return the value for one or all of elements in the
  15.  * group. When passed an array of values, the group object should set the value
  16.  * for each element in the array.
  17.  *
  18.  * Groups must also implement the Structures_Form_ElementInterface.
  19.  *
  20.  * NOTE: This interface provides new meanings for some of the methods defined
  21.  *       by Structures_Form_ElementInterface. Make sure that any group that
  22.  *       implements this interface, implements the correct definition of the
  23.  *       method! The methods are given new meanings but not new names to make
  24.  *       it easier for Structures_Form to get and set values.
  25.  *
  26.  * A note contributors: I welcome contributions from others but I will not
  27.  * include any classes in the package that are not accompanied by a complete
  28.  * set of PHPUnit2 unit tests. Also, I am a stickler for documentation. Please
  29.  * make sure that your contributions are fully documented. Docblocks are not
  30.  * enough. There must be inline documentation. Please see Structures/Form.php
  31.  * for an example of what I mean by fully documented.
  32.  *
  33.  * @author    Scott Mattocks
  34.  * @package   Structures_Form
  35.  * @license   PHP License
  36.  * @version   0.8.0devel
  37.  * @copyright Copyright 2006 Scott Mattocks
  38.  */
  39.  
  40.     /**
  41.      * Returns an element from a group.
  42.      *
  43.      * This method should return the element with the given name. If there is
  44.      * no element with the given name, this method should return false.
  45.      *
  46.      * @access public
  47.      * @param  string $name The element name.
  48.      * @return object The element object.
  49.      */
  50.     public function getElement($name);
  51.  
  52.     /**
  53.      * Returns an array containing all elements in the group.
  54.      *
  55.      * The array should be of the form: array(<name> => <element>)
  56.      *
  57.      * @access public
  58.      * @return array 
  59.      */
  60.     public function getAllElements();
  61.  
  62.     /**
  63.      * Returns whether or not an element with the given name exists in the
  64.      * group.
  65.      *
  66.      * @access public
  67.      * @param  string  $name The name of the element.
  68.      * @return boolean true if the element is a member of the group.
  69.      */
  70.     public function elementExists($name);
  71.  
  72.     /**
  73.      * Adds an element to the group.
  74.      *
  75.      * @access public
  76.      * @param  object  $element An element object.
  77.      * @return boolean true if the element was added.
  78.      */
  79.     public function addElement($element);
  80.  
  81.     /**
  82.      * Removes an element from the group.
  83.      *
  84.      * This method should fail gracefully (no errors or notices) if the element
  85.      * is not part of the group.
  86.      *
  87.      * @access public
  88.      * @param  object $element The element object to remove.
  89.      * @return void 
  90.      */
  91.     public function removeElement($element);
  92.  
  93.     // NOTE: The meaning of these methods has been redefined for groups!!!
  94.  
  95.     /**
  96.      * Sets the values of the group elements.
  97.      *
  98.      * This method should set the value of each element in the group. This
  99.      * should be done by calling the element's setValue() method.
  100.      *
  101.      * @access public
  102.      * @param  array   $values The values to set for the group elements.
  103.      * @return boolean true if the value was changed.
  104.      */
  105.     //public function setValue($values);
  106.  
  107.     /**
  108.      * Returns an array of the group elements' values.
  109.      *
  110.      * This method should return an array of the form: array(<name> => <value>)
  111.      * The name and value should be obtained by calling getName() and
  112.      * getValue() respectively for each member of the group.
  113.      *
  114.      * @access public
  115.      * @return array 
  116.      */
  117.     //public function getValue();
  118.  
  119.     /**
  120.      * Clears the current values of the group elements.
  121.      *
  122.      * This method should clear the current value of each element in the group.
  123.      * If not all values can be cleared, this method should return false. To
  124.      * clear the elements' values, clearValue() should be called on each
  125.      * element.
  126.      *
  127.      * @access public
  128.      * @return boolean true if the value was cleared.
  129.      */
  130.     //public function clearValue();
  131.  
  132.     /**
  133.      * Freezes the elements in the group so that its value may not be changed.
  134.      *
  135.      * This method should call freeze() on every member of the group.
  136.      *
  137.      * To make life easier down the road this method should also call
  138.      * set_data('frozen', true);
  139.      *
  140.      * @access public
  141.      * @return void 
  142.      */
  143.     //public function freeze();
  144.  
  145.     /**
  146.      * Unfreezes the element so that its value may not be changed.
  147.      *
  148.      * This method should call unfreeze() on every member of the group.
  149.      *
  150.      * To make life easier down the road this method should also call
  151.      * set_data('frozen', false);
  152.      *
  153.      * @access public
  154.      * @return void 
  155.      */
  156.     //public function unfreeze();
  157.  
  158.     /**
  159.      * Returns whether or not the group is currently frozen.
  160.      * 
  161.      * This method should just return the value from get_data('frozen')
  162.      *
  163.      * @access public
  164.      * @return boolean 
  165.      */
  166.     //public function isFrozen();
  167.  
  168.     /**
  169.      * Sets the label that identifies the group.
  170.      *
  171.      * @access public
  172.      * @param  string $label A label identifying the group.
  173.      * @return void 
  174.      */
  175.     //public function setLabel($label);
  176.  
  177.     /**
  178.      * Returns the label that identifies the group.
  179.      *
  180.      * @access public
  181.      * @return string 
  182.      */
  183.     //public function getLabel();
  184.  
  185.     /**
  186.      * Sets whether or not the group is required. Requiring a group requires
  187.      * all elements in the group.
  188.      *
  189.      * This method should call setRequired($required) on all members of the
  190.      * group.
  191.      *
  192.      * @access public
  193.      * @param  boolean $required 
  194.      * @return void 
  195.      */
  196.     //public function setRequired($required);
  197.  
  198.     /**
  199.      * Returns whether or not an element is required.
  200.      * 
  201.      * This method should simply return the value of get_data('required');
  202.      *
  203.      * @access public
  204.      * @return boolean 
  205.      */
  206.     //public function getRequired();
  207. }
  208. ?>

Documentation generated on Mon, 11 Mar 2019 14:44:13 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.