Dotclear

Changeset 2216


Ignore:
Timestamp:
05/04/10 01:36:29 (13 years ago)
Author:
Oaz
Message:

Back to stable commit. Refactored and added tests for captcha

Location:
plugins/myForms/trunk
Files:
3 added
2 deleted
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • plugins/myForms/trunk/Field.php

    r2214 r2216  
    3939  } 
    4040   
     41  public function Id() { 
     42    return $this->attributes['id']; 
     43  } 
     44   
    4145  public function Input($defaultValue=false) { 
    42     global $_REQUEST; 
    43     if(isset($_REQUEST["myforms"][$this->Name()])) { 
    44       return $_REQUEST["myforms"][$this->Name()]; 
    45     } else { 
    46       return $defaultValue; 
    47     } 
     46       return self::GetInput($this->Name(),$defaultValue); 
    4847  } 
    4948   
     
    7574   
    7675  public function AttributesAsString() { 
    77     $str = "id='myforms_".$this->attributes['id']."' name='myforms[".$this->attributes['name']."]'"; 
     76    $str = self::GetNameAndId($this->Name(), $this->Id() ); 
    7877    foreach( $this->attributes as $k => $v ) 
    7978      if( $k != 'name' && $k != 'id' ) 
     
    111110    $field = self::BuildObject($class,$attr,$content); 
    112111    return $field->Display(); 
     112  } 
     113   
     114  public static function GetNameAndId($name,$id) { 
     115    return "id='myforms_".$id."' name='myforms[".$name."]'"; 
     116  } 
     117   
     118  public static function GetInput($name,$defaultValue=false) { 
     119    global $_REQUEST; 
     120    if(isset($_REQUEST["myforms"][$name])) { 
     121      return $_REQUEST["myforms"][$name]; 
     122    } else { 
     123      return $defaultValue; 
     124    } 
    113125  } 
    114126   
  • plugins/myForms/trunk/_public.php

    r2214 r2216  
    2929require_once("fields/RadioButtonField.php"); 
    3030require_once("fields/FileField.php"); 
     31require_once("fields/CaptchaField.php"); 
    3132 
    3233require_once("TplCore.php"); 
    33 require_once("Captcha.php"); 
    34 require_once("TplFields.php"); 
    35  
    3634require_once("TplEmail.php"); 
    3735require_once("TplDatabase.php"); 
     
    176174    self::$formIsValid = false; 
    177175  } 
    178   
    179   public static function validateCaptcha() { 
    180     global $_REQUEST; 
    181     $captchaIsValid = !isset($_REQUEST["myforms"]) || MyFormsCaptcha::isValid($_REQUEST["myforms"]["captcha"],$_REQUEST["myforms"]["captcharef"]); 
    182     self::$captchaIsValidated = self::$captchaIsValidated && $captchaIsValid; 
    183     return $captchaIsValid; 
    184   } 
    185    
    186   public static function validateField($fieldName,$condition) { 
    187     global $_REQUEST; 
    188     $fieldIsValid = !isset($_REQUEST["myforms"]) || preg_match('#'.$condition.'#', @$_REQUEST["myforms"][$fieldName]); 
    189     self::$allFieldsAreValidated = self::$allFieldsAreValidated && $fieldIsValid; 
    190     return $fieldIsValid; 
    191   } 
    192    
     176      
    193177  public static function checkQueryMatches($queryFilter) 
    194178  { 
     
    276260          exit; 
    277261  } 
    278    
    279   /* 
    280   public static function getFieldValue($name,$defaultValue) 
    281   { 
    282     global $_REQUEST; 
    283     if(isset($_REQUEST["myforms"][$name])) { 
    284       return $_REQUEST["myforms"][$name]; 
    285     } else { 
    286       return $defaultValue; 
    287     } 
    288   } 
    289   */ 
    290   /* 
    291   public static function getFileFieldValue($name,$data) 
    292   { 
    293     global $_FILES; 
    294     if(isset($_FILES["myforms"][$data][$name])) 
    295       return $_FILES["myforms"][$data][$name]; 
    296     else 
    297       return ''; 
    298   } 
    299 */ 
     262 
    300263} 
    301264 
  • plugins/myForms/trunk/tests/_All

    r2214 r2216  
    1919<tr><td><a href="Screens">Screens</a></td></tr> 
    2020<tr><td><a href="File">File</a></td></tr> 
     21<tr><td><a href="Captcha">Captcha</a></td></tr> 
    2122</tbody></table> 
    2223</body> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map