1: <?php
2: /**
3: * Pry Framework
4: *
5: * LICENSE
6: *
7: * This source file is subject to the new BSD license that is bundled
8: * with this package in the file LICENSE.txt.
9: *
10: * @version $Revision: 276 $
11: */
12:
13: /**
14: * Element IP. Permet de valider une adresse IP dans un champs text
15: *
16: * @category Pry
17: * @package Form
18: * @subpackage Form_Element
19: * @version 1.0.0
20: * @author Olivier ROGER <oroger.fr>
21: *
22: */
23: class Form_Element_Ip extends Form_Element_Text
24: {
25:
26: /**
27: * Constructeur. Défini la taille mini et maxi de l'ip
28: *
29: * @param string $nom
30: * @param Form_Form $form
31: */
32: public function __construct($nom,$form)
33: {
34: parent::__construct($nom,$form);
35: $this->maxlength(15);
36: $this->minLength(7);
37: $this->showMask = true;
38: }
39:
40: /**
41: * Validation de l'adresse IP
42: *
43: * @param string $value
44: * @access public
45: * @return boolean
46: */
47: public function isValid($value)
48: {
49: if(parent::isValid($value))
50: {
51: if(Util_String::isIp($value) || (!$this->required && $value==''))
52: return true;
53: else
54: $this->errorMsg = Form_Error::NOTIP;
55: }
56: return false;
57: }
58:
59: }
60: ?>