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.             if (!$this->datatype->allowWhitespace())  {
  63.                 $this->container->data[$this->reftrim($value);
  64.             }
  65.         }elseif(!$this->datatype->check($value)){
  66.             return $this->container->errors[$this->refjForms::ERRDATA_INVALID;
  67.         }elseif($this->datatype instanceof jIFilteredDatatype{
  68.             $this->container->data[$this->ref$this->datatype->getFilteredValue();
  69.         }
  70.         return null;
  71.     }
  72.  
  73.     function setData($value{
  74.         $this->container->data[$this->ref$value;
  75.     }
  76.  
  77.     function setReadOnly($r true){
  78.         $this->container->setReadOnly($this->ref$r);
  79.     }
  80.  
  81.     function setValueFromRequest($request{
  82.         $this->setData($request->getParam($this->ref,''));
  83.     }
  84.  
  85.     function setDataFromDao($value$daoDatatype{
  86.         $this->setData($value);
  87.     }
  88.  
  89.     function getDisplayValue($value){
  90.         return $value;
  91.     }
  92.  
  93.     /**
  94.      * says if the content is html or not
  95.      * @since 1.2
  96.      */
  97.     public function isHtmlContent({
  98.         return false;
  99.     }
  100.  
  101.     public function deactivate($deactivation=true{
  102.         $this->container->deactivate($this->ref$deactivation);
  103.     }
  104.  
  105.     /**
  106.     * check if the control is activated
  107.     * @return boolean true if it is activated
  108.     */
  109.     public function isActivated({
  110.         return $this->container->isActivated($this->ref);
  111.     }
  112.  
  113.     /**
  114.      * check if the control is readonly
  115.      * @return boolean true if it is readonly
  116.      */
  117.     public function isReadOnly({
  118.         return $this->container->isReadOnly($this->ref);
  119.     }
  120. }
  121.  
  122. require(JELIX_LIB_PATH.'forms/controls/jFormsControlDatasource.class.php');
  123. require(JELIX_LIB_PATH.'forms/controls/jFormsControlGroups.class.php');
  124.  
  125. require(JELIX_LIB_PATH.'forms/controls/jFormsControlButton.class.php');
  126. require(JELIX_LIB_PATH.'forms/controls/jFormsControlCaptcha.class.php');
  127. require(JELIX_LIB_PATH.'forms/controls/jFormsControlCheckbox.class.php');
  128. require(JELIX_LIB_PATH.'forms/controls/jFormsControlCheckboxes.class.php');
  129. require(JELIX_LIB_PATH.'forms/controls/jFormsControlChoice.class.php');
  130. require(JELIX_LIB_PATH.'forms/controls/jFormsControlGroup.class.php');
  131. require(JELIX_LIB_PATH.'forms/controls/jFormsControlReset.class.php');
  132. require(JELIX_LIB_PATH.'forms/controls/jFormsControlHidden.class.php');
  133. require(JELIX_LIB_PATH.'forms/controls/jFormsControlHtmlEditor.class.php');
  134. require(JELIX_LIB_PATH.'forms/controls/jFormsControlInput.class.php');
  135. require(JELIX_LIB_PATH.'forms/controls/jFormsControlListbox.class.php');
  136. require(JELIX_LIB_PATH.'forms/controls/jFormsControlRadiobuttons.class.php');
  137. require(JELIX_LIB_PATH.'forms/controls/jFormsControlMenulist.class.php');
  138. require(JELIX_LIB_PATH.'forms/controls/jFormsControlOutput.class.php');
  139. require(JELIX_LIB_PATH.'forms/controls/jFormsControlRepeat.class.php');
  140. require(JELIX_LIB_PATH.'forms/controls/jFormsControlSecret.class.php');
  141. require(JELIX_LIB_PATH.'forms/controls/jFormsControlSecretConfirm.class.php');
  142. require(JELIX_LIB_PATH.'forms/controls/jFormsControlSubmit.class.php');
  143. require(JELIX_LIB_PATH.'forms/controls/jFormsControlSwitch.class.php');
  144. require(JELIX_LIB_PATH.'forms/controls/jFormsControlTextarea.class.php');
  145. require(JELIX_LIB_PATH.'forms/controls/jFormsControlUpload.class.php');
  146. require(JELIX_LIB_PATH.'forms/controls/jFormsControlDate.class.php');
  147. require(JELIX_LIB_PATH.'forms/controls/jFormsControlDatetime.class.php');
  148. require(JELIX_LIB_PATH.'forms/controls/jFormsControlWikiEditor.class.php');

Documentation generated on Wed, 04 Jan 2017 22:54:42 +0100 by phpDocumentor 1.4.3