Source for file Strmaxcompat.php

Documentation is available at Strmaxcompat.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Strmaxcompat.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: 2191a293f1e89cdff794b1f1d4d823f59bb3ba5e $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Validator_Strmaxcompat
  13. /**
  14.  *  最大値チェックプラグイン
  15.  *  (マルチバイト文字列(EUC_JP)用. Ethna 2.3.x までの互換性保持用)
  16.  *
  17.  *  NOTE:
  18.  *    - EUC_JP 専用のプラグインです。
  19.  *    - クライアントエンコーディングがEUC_JP以外の場合は、入力を無条件でEUC_JPに変換します
  20.  *      (但し mbstringが入っていない場合は除く)
  21.  *    - エラーメッセージは、全角半角を区別したものが出力されます。
  22.  *
  23.  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
  24.  *  @access     public
  25.  *  @package    Ethna
  26.  */
  27. {
  28.     /** @var    bool    配列を受け取るかフラグ */
  29.     public $accept_array = false;
  30.  
  31.     /**
  32.      *  最大値のチェックを行う
  33.      *
  34.      *  @access public
  35.      *  @param  string  $name       フォームの名前
  36.      *  @param  mixed   $var        フォームの値
  37.      *  @param  array   $params     プラグインのパラメータ
  38.      *  @return true: 成功  Ethna_Error: エラー
  39.      */
  40.     public function validate($name$var$params)
  41.     {
  42.         $true true;
  43.         $type $this->getFormType($name);
  44.         if (isset($params['strmaxcompat']== false || $this->isEmpty($var$type)) {
  45.             return $true;
  46.         }
  47.  
  48.         $ctl $this->backend->getController();
  49.         $client_enc $ctl->getClientEncoding();
  50.         if (mb_enabled()
  51.         && (strcasecmp('EUC-JP'$client_enc!= 0
  52.          && strcasecmp('eucJP-win'$client_enc!= 0)) {
  53.             $var mb_convert_encoding($var'EUC-JP'$client_enc);
  54.         }
  55.  
  56.         if ($type == VAR_TYPE_STRING{
  57.             $max_param $params['strmaxcompat'];
  58.             if (strlen($var$max_param{
  59.                 if (isset($params['error'])) {
  60.                     $msg $params['error'];
  61.                 else {
  62.                     $msg _et('Please input less than %d full-size (%d half-size) characters to {form}.');
  63.                 }
  64.                 return Ethna::raiseNotice($msgE_FORM_MAX_STRING,
  65.                             array(intval($max_param/2)$max_param));
  66.             }
  67.         }
  68.  
  69.         return $true;
  70.     }
  71. }
  72. // }}}

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