Source for file Strmax.php

Documentation is available at Strmax.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Strmax.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: bb5661b2690e69187dd01b67cd752b7236a2b199 $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Validator_Strmax
  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['strmax']== false || $this->isEmpty($var$type)) {
  42.             return $true;
  43.         }
  44.  
  45.         if ($type == VAR_TYPE_STRING{
  46.             $max_param $params['strmax'];
  47.             if (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($params['strmax']));
  55.             }
  56.         }
  57.  
  58.         return $true;
  59.     }
  60. }
  61. // }}}

Documentation generated on Fri, 11 Nov 2011 03:59:07 +0900 by phpDocumentor 1.4.3