Source for file jFormsControl.class.php

Documentation is available at jFormsControl.class.php

  1. <?php
  2. /**
  3. @package     jelix
  4. @subpackage  forms
  5. @author      Laurent Jouanneau
  6. @contributor Dominique Papin, Olivier Demah
  7. @copyright   2006-2008 Laurent Jouanneau, 2008 Dominique Papin
  8. @copyright   2009 Olivier Demah
  9. @link        http://www.jelix.org
  10. @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
  11. */
  12. /**
  13.  * base class for all jforms control
  14.  * @package     jelix
  15.  * @subpackage  forms
  16.  */
  17. abstract class jFormsControl {
  18.     public $type = null;
  19.     public $ref='';
  20.     public $datatype;
  21.     public $required = false;
  22.     public $label='';
  23.     public $defaultValue='';
  24.     public $help = '';
  25.     public $hint='';
  26.     public $alertInvalid='';
  27.     public $alertRequired='';
  28.  
  29.     public $initialReadOnly = false;
  30.     public $initialActivation = true;
  31.  
  32.     protected $form;
  33.     protected $container;
  34.  
  35.  
  36.     function __construct($ref){
  37.         $this->ref = $ref;
  38.         $this->datatype = new jDatatypeString();
  39.     }
  40.  
  41.     function setForm($form{
  42.         $this->form = $form;
  43.         $this->container = $form->getContainer();
  44.         if($this->initialReadOnly)
  45.             $this->container->setReadOnly($this->reftrue);
  46.         if(!$this->initialActivation)
  47.             $this->container->deactivate($this->reftrue);
  48.     }
  49.  
  50.     /**
  51.      * says if the control can have multiple values
  52.      */
  53.     function isContainer(){
  54.         return false;
  55.     }
  56.  
  57.     function check(){
  58.         $value $this->container->data[$this->ref];
  59.         if(trim($value== ''{
  60.             if($this->required)
  61.                 return $this->container->errors[$this->refjForms::ERRDATA_REQUIRED;
  62.         }elseif(!$this->datatype->check($value)){
  63.             return $this->container->errors[$this->refjForms::ERRDATA_INVALID;
  64.         }elseif($this->datatype instanceof jIFilteredDatatype{
  65.             $this->container->data[$this->ref$this->datatype->getFilteredValue();
  66.         }
  67.         return null;
  68.     }
  69.  
  70.     function setData($value{
  71.         $this->container->data[$this->ref$value;
  72.     }
  73.  
  74.     function setReadOnly($r true){
  75.         $this->container->setReadOnly($this->ref$r);
  76.     }
  77.  
  78.     function setValueFromRequest($request{
  79.         $this->setData($request->getParam($this->ref,''));
  80.     }
  81.  
  82.     function setDataFromDao($value$daoDatatype{
  83.         $this->setData($value);
  84.     }
  85.  
  86.     function getDisplayValue($value){
  87.         return $value;
  88.     }
  89.  
  90.     /**
  91.      * says if the content is html or not
  92.      * @since 1.2
  93.      */
  94.     public function isHtmlContent({
  95.         return false;
  96.     }
  97.  
  98.     public function deactivate($deactivation=true{
  99.         $this->container->deactivate($this->ref$deactivation);
  100.     }
  101.  
  102.     /**
  103.     * check if the control is activated
  104.     * @return boolean true if it is activated
  105.     */
  106.     public function isActivated({
  107.         return $this->container->isActivated($this->ref);
  108.     }
  109.  
  110.     /**
  111.      * check if the control is readonly
  112.      * @return boolean true if it is readonly
  113.      */
  114.     public function isReadOnly({
  115.         return $this->container->isReadOnly($this->ref);
  116.     }
  117. }
  118.  
  119. require(JELIX_LIB_PATH.'forms/controls/jFormsControlDatasource.class.php');
  120. require(JELIX_LIB_PATH.'forms/controls/jFormsControlGroups.class.php');
  121.  
  122. require(JELIX_LIB_PATH.'forms/controls/jFormsControlCaptcha.class.php');
  123. require(JELIX_LIB_PATH.'forms/controls/jFormsControlCheckbox.class.php');
  124. require(JELIX_LIB_PATH.'forms/controls/jFormsControlCheckboxes.class.php');
  125. require(JELIX_LIB_PATH.'forms/controls/jFormsControlChoice.class.php');
  126. require(JELIX_LIB_PATH.'forms/controls/jFormsControlGroup.class.php');
  127. require(JELIX_LIB_PATH.'forms/controls/jFormsControlReset.class.php');
  128. require(JELIX_LIB_PATH.'forms/controls/jFormsControlHidden.class.php');
  129. require(JELIX_LIB_PATH.'forms/controls/jFormsControlHtmlEditor.class.php');
  130. require(JELIX_LIB_PATH.'forms/controls/jFormsControlInput.class.php');
  131. require(JELIX_LIB_PATH.'forms/controls/jFormsControlListbox.class.php');
  132. require(JELIX_LIB_PATH.'forms/controls/jFormsControlRadiobuttons.class.php');
  133. require(JELIX_LIB_PATH.'forms/controls/jFormsControlMenulist.class.php');
  134. require(JELIX_LIB_PATH.'forms/controls/jFormsControlOutput.class.php');
  135. require(JELIX_LIB_PATH.'forms/controls/jFormsControlRepeat.class.php');
  136. require(JELIX_LIB_PATH.'forms/controls/jFormsControlSecret.class.php');
  137. require(JELIX_LIB_PATH.'forms/controls/jFormsControlSecretConfirm.class.php');
  138. require(JELIX_LIB_PATH.'forms/controls/jFormsControlSubmit.class.php');
  139. require(JELIX_LIB_PATH.'forms/controls/jFormsControlSwitch.class.php');
  140. require(JELIX_LIB_PATH.'forms/controls/jFormsControlTextarea.class.php');
  141. require(JELIX_LIB_PATH.'forms/controls/jFormsControlUpload.class.php');
  142. require(JELIX_LIB_PATH.'forms/controls/jFormsControlDate.class.php');
  143. require(JELIX_LIB_PATH.'forms/controls/jFormsControlDatetime.class.php');
  144. require(JELIX_LIB_PATH.'forms/controls/jFormsControlWikiEditor.class.php');

Documentation generated on Mon, 19 Sep 2011 14:12:50 +0200 by phpDocumentor 1.4.3