MkFramework
 All Data Structures Functions
plugin_valid.php
1 <?php
2 /*
3 This file is part of Mkframework.
4 
5 Mkframework is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License.
8 
9 Mkframework is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13 
14 You should have received a copy of the GNU Lesser General Public License
15 along with Mkframework. If not, see <http://www.gnu.org/licenses/>.
16 
17 */
24 
25  private $bCheck;
26  private $tPost;
27  private $tCheck;
28 
29  private $oCheck;
30 
36  public function __construct($tPost){
37  $this->tPost=$tPost;
38  $sClass=_root::getConfigVar('check.class','plugin_check');
39  $this->oCheck=new $sClass;
40  $this->bCheck=true;
41  }
42 
49  public function exist($sName){
50  if(isset($this->tPost[$sName])){
51  return true;
52  }
53  $this->ko('exist',$sName);
54  return false;
55  }
62  public function getValue($sName){
63  if(!isset($this->tPost[$sName])){
64  return null;
65  }
66  return $this->tPost[$sName];
67  }
68 
73  public function __call($sMethod,$tParam=null){
74  $sField='';
75  if($tParam==null){
76  $bCheck=call_user_func(array($this->oCheck,$sMethod));
77  }else{
78  $sField=$tParam[0];
79  $tParam[0]=$this->getValue($tParam[0]);
80  $bCheck=call_user_func_array(array($this->oCheck,$sMethod),$tParam);
81  }
82  if($bCheck){
83  return $this->ok();
84  }
85  $sKoMessage=$this->oCheck->getLastErrorMsg();
86 
87  return $this->ko($sKoMessage,$sField);
88  }
89 
90 
96  public function isValid(){
97  return $this->bCheck;
98  }
104  public function getListError(){
105  return $this->tCheck;
106  }
107 
108  private function ko($sCheck,$sField=null){
109  $this->bCheck=false;
110  $this->tCheck[ $sField ][]= $sCheck;
111  return false;
112  }
113  private function ok(){
114  return true;
115  }
116 
117 
118 
119 
120 }
getValue($sName)
static getConfigVar($sCatAndVar, $uDefaut=null)
Definition: class_root.php:654
__construct($tPost)
__call($sMethod, $tParam=null)
exist($sName)