Source for file Ethna_Plugin_Validator_Mbregexp.php

Documentation is available at Ethna_Plugin_Validator_Mbregexp.php

  1. <?php
  2. // {{{ Ethna_Plugin_Validator_Mbegexp
  3. /**
  4.  *  マルチバイト対応正規表現によるバリデータプラグイン
  5.  *
  6.  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
  7.  *  @access     public
  8.  *  @package    Ethna
  9.  */
  10. {
  11.     /** @var    bool    配列を受け取るかフラグ */
  12.     var $accept_array = false;
  13.  
  14.     /**
  15.      *  正規表現によるフォーム値のチェックを行う(マルチバイト対応)
  16.      *
  17.      *  @access public
  18.      *  @param  string  $name       フォームの名前
  19.      *  @param  mixed   $var        フォームの値
  20.      *  @param  array   $params     プラグインのパラメータ
  21.      */
  22.     function &validate($name, $var, $params)
  23.     {
  24.         $true = true;
  25.         $type = $this->getFormType($name);
  26.         if (isset($params['mbregexp']) == false
  27.             || $type == VAR_TYPE_FILE || $this->isEmpty($var, $type)) {
  28.             return $true;
  29.         }
  30.  
  31.         $ctl =& $this->backend->getController();
  32.         $cli_enc = $ctl->getClientEncoding();
  33.         $encoding = (isset($params['encoding']))
  34.                   ? $params['encoding']
  35.                   : $cli_enc;
  36.         mb_regex_encoding($encoding);
  37.  
  38.         if (mb_ereg($params['mbregexp'], $var) !== 1) {
  39.             if (isset($params['error'])) {
  40.                 $msg = $params['error'];
  41.             } else {
  42.                 $msg = _et('Please input {form} properly.');
  43.             }
  44.             return Ethna::raiseNotice($msg, E_FORM_REGEXP);
  45.         }
  46.  
  47.         return $true;
  48.     }
  49. }
  50. // }}}
  51. ?>

Documentation generated on Fri, 11 Nov 2011 04:00:41 +0900 by phpDocumentor 1.4.3