Source for file Mbstrmax.php

Documentation is available at Mbstrmax.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Mbstrmax.php
  5.  *
  6.  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
  7.  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
  8.  *  @package    Ethna
  9.  *  @version    $Id: bdee495577509e58e6010aa1687748a9a477faa4 $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Validator_Mbstrmax
  13. /**
  14.  *  最大値チェックプラグイン (マルチバイト文字列用)
  15.  *
  16.  *  NOTE:
  17.  *      - mbstring を有効にしておく必要があります。
  18.  *      - エラーメッセージは、全角半角を区別しません。
  19.  * 
  20.  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
  21.  *  @access     public
  22.  *  @package    Ethna
  23.  */
  24. {
  25.     /** @var    bool    配列を受け取るかフラグ */
  26.     public $accept_array = false;
  27.  
  28.     /**
  29.      *  最大値のチェックを行う
  30.      *
  31.      *  @access public
  32.      *  @param  string  $name       フォームの名前
  33.      *  @param  mixed   $var        フォームの値
  34.      *  @param  array   $params     プラグインのパラメータ
  35.      *  @return true: 成功  Ethna_Error: エラー
  36.      */
  37.     public function validate($name$var$params)
  38.     {
  39.         $true true;
  40.         $type $this->getFormType($name);
  41.         if (isset($params['mbstrmax']== false || $this->isEmpty($var$type)) {
  42.             return $true;
  43.         }
  44.  
  45.         if ($type == VAR_TYPE_STRING{
  46.             $max_param $params['mbstrmax'];
  47.             if (mb_strlen($var$max_param{
  48.                 if (isset($params['error'])) {
  49.                     $msg $params['error'];
  50.                 else {
  51.                     $msg _et('Please input less than %d characters to {form}.');
  52.                 }
  53.                 return Ethna::raiseNotice($msgE_FORM_MAX_STRING,
  54.                         array($max_param));
  55.             }
  56.         }
  57.  
  58.         return $true;
  59.     }
  60. }
  61. // }}}

Documentation generated on Fri, 11 Nov 2011 03:58:38 +0900 by phpDocumentor 1.4.3