Source for file Strmincompat.php

Documentation is available at Strmincompat.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Strmincompat.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: 6895f08f855ce5eb58ca11f48bc52b995c22ec9c $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Validator_Strmincompat
  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.     /** @public    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.      */
  39.     public function validate($name$var$params)
  40.     {
  41.         $true true;
  42.         $type $this->getFormType($name);
  43.         if (isset($params['strmincompat']== false || $this->isEmpty($var$type)) {
  44.             return $true;
  45.         }
  46.  
  47.         $ctl $this->backend->getController();
  48.         $client_enc $ctl->getClientEncoding();
  49.         if (mb_enabled()
  50.         && (strcasecmp('EUC-JP'$client_enc!= 0
  51.          && strcasecmp('eucJP-win'$client_enc!= 0)) {
  52.             $var mb_convert_encoding($var'EUC-JP'$client_enc);
  53.         }
  54.  
  55.         if ($type == VAR_TYPE_STRING{
  56.             $min_param $params['strmincompat'];
  57.             if (strlen($var$min_param{
  58.                 if (isset($params['error'])) {
  59.                     $msg $params['error'];
  60.                 else {
  61.                     $msg _et('Please input more than %d full-size (%d half-size) characters to {form}.');
  62.                 }
  63.                 return Ethna::raiseNotice($msgE_FORM_MIN_STRING,
  64.                             array(intval($min_param/2)$min_param));
  65.             }
  66.         }
  67.  
  68.         return $true;
  69.     }
  70. }
  71. // }}}

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