Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cValidatorAbstract
  • cValidatorEmail
  • cValidatorFactory
  • cValidatorRegex
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: 
 3: /**
 4:  * This file contains the regular expression validator class.
 5:  *
 6:  * @package    Core
 7:  * @subpackage Validation
 8:  * @author     Murat Purc <murat@purc.de>
 9:  * @copyright  four for business AG <www.4fb.de>
10:  * @license    http://www.contenido.org/license/LIZENZ.txt
11:  * @link       http://www.4fb.de
12:  * @link       http://www.contenido.org
13:  */
14: 
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16: 
17: /**
18:  * Regular expression validation.
19:  *
20:  * Supports following options:
21:  * <pre>
22:  * - pattern  (string)  The regular expression pattern
23:  * </pre>
24:  *
25:  * @package    Core
26:  * @subpackage Validation
27:  */
28: class cValidatorRegex extends cValidatorAbstract {
29: 
30:     /**
31:      *
32:      * @see cValidatorAbstract::_isValid()
33:      * @param mixed $value
34:      * @return bool
35:      */
36:     protected function _isValid($value) {
37:         if (!is_string($value)) {
38:             $this->addError('Invalid value', 1);
39:             return false;
40:         } elseif (!$this->getOption('pattern')) {
41:             $this->addError('Missing pattern', 2);
42:             return false;
43:         }
44: 
45:         $status = @preg_match($this->getOption('pattern'), $value);
46:         if (false === $status) {
47:             $this->addError('Pattern error', 3);
48:             return false;
49:         }
50: 
51:         if (!$status) {
52:             $this->addError('No match', 4);
53:             return false;
54:         }
55: 
56:         return true;
57:     }
58: 
59: }
60: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0