本文整理汇总了PHP中_et函数的典型用法代码示例。如果您正苦于以下问题:PHP _et函数的具体用法?PHP _et怎么用?PHP _et使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_et函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* 最大値のチェックを行う
*
* @access public
* @param string $name フォームの名前
* @param mixed $var フォームの値
* @param array $params プラグインのパラメータ
* @return true: 成功 Ethna_Error: エラー
*/
public function validate($name, $var, $params)
{
$true = true;
$type = $this->getFormType($name);
if (isset($params['strmaxcompat']) == false || $this->isEmpty($var, $type)) {
return $true;
}
$ctl = $this->backend->getController();
$client_enc = $ctl->getClientEncoding();
if (mb_enabled() && (strcasecmp('EUC-JP', $client_enc) != 0 && strcasecmp('eucJP-win', $client_enc) != 0)) {
$var = mb_convert_encoding($var, 'EUC-JP', $client_enc);
}
if ($type == VAR_TYPE_STRING) {
$max_param = $params['strmaxcompat'];
if (strlen($var) > $max_param) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input less than %d full-size (%d half-size) characters to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_MAX_STRING, array(intval($max_param / 2), $max_param));
}
}
return $true;
}
示例2: validate
/**
* 最小値のチェックを行う
*
* @access public
* @param string $name フォームの名前
* @param mixed $var フォームの値
* @param array $params プラグインのパラメータ
*/
public function validate($name, $var, $params)
{
$true = true;
$type = $this->getFormType($name);
if (isset($params['min']) == false || $this->isEmpty($var, $type)) {
return $true;
}
switch ($type) {
case VAR_TYPE_INT:
if ($var < $params['min']) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input more than %d(int) to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_INT, array($params['min']));
}
break;
case VAR_TYPE_FLOAT:
if ($var < $params['min']) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input more than %f(float) to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_FLOAT, array($params['min']));
}
break;
case VAR_TYPE_DATETIME:
$t_min = strtotime($params['min']);
$t_var = strtotime($var);
if ($t_var < $t_min) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input datetime value %s or later to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_DATETIME, array($params['min']));
}
break;
case VAR_TYPE_FILE:
$st = stat($var['tmp_name']);
if ($st[7] < $params['min'] * 1024) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please specify file whose size is more than %d KB.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_FILE, array($params['min']));
}
break;
case VAR_TYPE_STRING:
$params['mbstrmin'] = $params['min'];
unset($params['min']);
$vld = $this->plugin->getPlugin('Validator', 'Mbstrmin');
return $vld->validate($name, $var, $params);
break;
}
return $true;
}
示例3: smarty_function_form_submit
/**
* smarty function:フォームのsubmitボタン生成
*
* @param string $submit フォーム項目名
*/
function smarty_function_form_submit($params, &$smarty)
{
$view = Ethna_Container::getInstance()->getView();
if ($view === null) {
return null;
}
//ここでi18n変換をかます
$params['value'] = _et($params['value']);
return $view->getFormSubmit($params);
}
示例4: jsonI18n
protected function jsonI18n(&$params)
{
if (!is_array($params)) {
$params = _et($params);
return true;
} else {
foreach ($params as $key => $value) {
$this->jsonI18n($params[$key]);
}
}
}
示例5: validate
/**
* フォーム値の型チェックを行う
*
* @access public
* @param string $name フォームの名前
* @param mixed $var フォームの値
* @param array $params プラグインのパラメータ
*/
public function validate($name, $var, $params)
{
$true = true;
$type = $params['type'];
if ($type == VAR_TYPE_FILE || $this->isEmpty($var, $type)) {
return $true;
}
foreach (array_keys(to_array($var)) as $key) {
switch ($type) {
case VAR_TYPE_INT:
if (!preg_match('/^-?\\d+$/', $var)) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input integer value to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_INT);
}
break;
case VAR_TYPE_FLOAT:
if (!preg_match('/^-?\\d+$/', $var) && !preg_match('/^-?\\d+\\.\\d+$/', $var)) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input float value to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_FLOAT);
}
break;
case VAR_TYPE_BOOLEAN:
if ($var != "1" && $var != "0") {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('You can input 0 or 1 to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_BOOLEAN);
}
break;
case VAR_TYPE_DATETIME:
$r = strtotime($var);
if ($r == -1 || $r === false) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input valid datetime to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_DATETIME);
}
break;
}
}
return $true;
}
示例6: perform
/**
*
* @see Ethna_ActionClass::perform()
*/
function perform()
{
$days = $this->config->get('license_warning_days');
try {
$licenseDao = DaoFactory::LicenseMst();
$userDao = DaoFactory::UserMst();
$companyDao = DaoFactory::CompanyMst();
sort($days, SORT_NUMERIC);
$result = array();
foreach ($days as $day) {
$params = array('day' => $day);
$res = $licenseDao->LicenseMST_GetLicenseValidDays($params)->fetchAll(PDO::FETCH_ASSOC);
$result = array_merge($result, $res);
}
foreach ($result as $value) {
$send_email[$value['COMPANY_ID']][] = array('TERMINAL_ID' => $value['TERMINAL_ID'], 'END_YMD' => $value['END_YMD']);
}
//send e-mail
$headers = "From: {$this->config->get('admin_email_address')}";
foreach ($send_email as $company => $arr) {
$invalid_terminal_list = '';
foreach ($arr as $key => $value) {
$invalid_terminal_list .= "\n{$value['TERMINAL_ID']}\t\t\t{$value['END_YMD']}";
}
//get admin user's e-mail address and language
$companyInfo = $companyDao->Retrieve('COMPANY_ID = ?', array($company));
//$companyInfo['CONTACT']
$userInfo = $userDao->Retrieve("LOGIN_ID = 'admin' AND COMPANY_ID = ? ", array($company));
//$userInfo['E_MAIL']
//$userInfo['DEFAULT_LOCALE'] zh-Hans-CN en_US ja_JP
if ($userInfo['DEFAULT_LOCALE'] == 'zh-Hans-CN') {
$this->backend->getController()->setLocale('zh-Hans-CN');
$subject = _et($this->config->get('system_name')) . "终端证书即将到期";
$send_message = "\n{$companyInfo['COMPANY_NAME']} \n{$companyInfo['CONTACT']} 您好!\n \t\n非常感谢您使用我们的{$this->config->get('app_name')}服务。\n您的以下终端的证书即将过期,为了不影响业务请尽快到证书管理页面购买新的证书。\n\n终端\t\t\t到期日\n" . $invalid_terminal_list . "\n\n新的证书可以从后台管理系统的证书管理页面购买,也可以直接到AsShop购买。\n如有任何问题请随即和我们取得联系。\n\n服务总站 http://www.asx4.net\nAsWiki\t\thttps://wiki.asx4.net\nAsHelp \thttps://support.asx4.net\nAsShop\thttps://ec.asx4.net\n \t\n";
} elseif ($userInfo['DEFAULT_LOCALE'] == 'ja_JP') {
$this->backend->getController()->setLocale('ja_JP');
$subject = _et($this->config->get('system_name')) . "端末のライセンスの期限が近づいています";
$send_message = "\n{$companyInfo['COMPANY_NAME']} \n{$companyInfo['CONTACT']} 様\n \t\n{$this->config->get('app_name')}をご利用いただきまして誠にありがとうございます。\n下記の端末のライセンスの期限が近づいています。業務に影響を与えないように早めに新しいライセンスをご購入ください。\n\n端末ID\t\t\t期限\n" . $invalid_terminal_list . "\n\nライセンスは管理画面のライセンスマスタ画面か、AsShopからご購入いただけます。\nご不明な点がございましたら、お問い合わせください。\n\nサービスホーム http://www.asx4.net\nAsWiki \t\t\t\thttps://wiki.asx4.net\nAsHelp \t\t\t\thttps://support.asx4.net\nAsShop \t\t\t\thttps://ec.asx4.net \n \t\n";
} else {
$this->backend->getController()->setLocale('en_US');
$subject = _et($this->config->get('system_name')) . " Terminal will be out of license soon";
$send_message = "\n{$companyInfo['COMPANY_NAME']} \nHi {$companyInfo['CONTACT']}\n \t\nThanks for using our {$this->config->get('app_name')} service. \nThe following terminal will be out of license soon. Please buy new license as soon as possible.\n\nTerminal ID\t\t\tValid Until\n" . $invalid_terminal_list . "\n\nYou can buy new licenses from the LICENSE MANAGEMENT page in our admin system or buy form the AsShop directly.\nIf you have any question, please don't hesitate to contact us.\n\nService Home\t\thttp://www.asx4.net\nAsWiki \t\t\thttps://wiki.asx4.net\nAsHelp \t\t\thttps://support.asx4.net\nAsShop \t\t\thttps://ec.asx4.net\n";
}
mb_send_mail($userInfo['E_MAIL'], $subject, $send_message, $headers);
}
} catch (Exception $e) {
$this->logger->log(LOG_ERR, $e->getMessage());
die($e->getMessage());
}
}
示例7: _et
/**
* 正規表現によるフォーム値のチェックを行う
*
* @access public
* @param string $name フォームの名前
* @param mixed $var フォームの値
* @param array $params プラグインのパラメータ
*/
function &validate($name, $var, $params)
{
$true = true;
$type = $this->getFormType($name);
if (isset($params['regexp']) == false || $type == VAR_TYPE_FILE || $this->isEmpty($var, $type)) {
return $true;
}
if (preg_match($params['regexp'], $var) == 0) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input {form} properly.');
}
return Ethna::raiseNotice($msg, E_FORM_REGEXP);
}
return $true;
}
示例8: _et
/**
* 最小値のチェックを行う (シングルバイト文字列用)
*
* @access public
* @param string $name フォームの名前
* @param mixed $var フォームの値
* @param array $params プラグインのパラメータ
*/
function &validate($name, $var, $params)
{
$true = true;
$type = $this->getFormType($name);
if (isset($params['strmin']) == false || $this->isEmpty($var, $type)) {
return $true;
}
if ($type == VAR_TYPE_STRING) {
$min_param = $params['strmin'];
if (strlen($var) < $min_param) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input more than %d characters to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_STRING, array($min_param));
}
}
return $true;
}
示例9: validate
/**
* 正規表現によるフォーム値のチェックを行う(マルチバイト対応)
*
* @access public
* @param string $name フォームの名前
* @param mixed $var フォームの値
* @param array $params プラグインのパラメータ
*/
public function validate($name, $var, $params)
{
$true = true;
$type = $this->getFormType($name);
if (isset($params['mbregexp']) == false || $type == VAR_TYPE_FILE || $this->isEmpty($var, $type)) {
return $true;
}
$ctl = $this->backend->getController();
$cli_enc = $ctl->getClientEncoding();
$encoding = isset($params['encoding']) ? $params['encoding'] : $cli_enc;
mb_regex_encoding($encoding);
if (mb_ereg($params['mbregexp'], $var) !== 1) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input {form} properly.');
}
return Ethna::raiseNotice($msg, E_FORM_REGEXP);
}
return $true;
}
示例10: send
/**
* メールを送信する
*
* $attach の指定方法:
* - 既存のファイルを添付するとき
* <code>
* array('filename' => '/tmp/hoge.xls', 'content-type' => 'application/vnd.ms-excel')
* </code>
* - 文字列に名前を付けて添付するとき
* <code>
* array('name' => 'foo.txt', 'content' => 'this is foo.')
* </code>
* 'content-type' 省略時は 'application/octet-stream' となる。
* 複数添付するときは上の配列を添字0から始まるふつうの配列に入れる。
*
* @access public
* @param string $to メール送信先アドレス (nullのときは送信せずに内容を return する)
* @param string $template メールテンプレート名 or タイプ
* @param array $macro テンプレートマクロ or $templateがMAILSENDER_TYPE_DIRECTのときはメール送信内容)
* @param array $attach 添付ファイル
*/
function send($to, $template, $macro, $attach = null)
{
// メール内容を作成
if ($template === MAILSENDER_TYPE_DIRECT) {
$mail = $macro;
} else {
$renderer = $this->getTemplateEngine();
// 基本情報設定
$env_datetime = _et('%Y/%m/%d %H:%M:%S');
$renderer->setProp("env_datetime", strftime($env_datetime));
$renderer->setProp("env_useragent", $_SERVER["HTTP_USER_AGENT"]);
$renderer->setProp("env_remoteaddr", $_SERVER["REMOTE_ADDR"]);
// デフォルトマクロ設定
$macro = $this->_setDefaultMacro($macro);
// ユーザ定義情報設定
if (is_array($macro)) {
foreach ($macro as $key => $value) {
$renderer->setProp($key, $value);
}
}
if (isset($this->def[$template])) {
$template = $this->def[$template];
}
$mail = $renderer->perform(sprintf('%s/%s', $this->mail_dir, $template), true);
if (Ethna::isError($mail)) {
return $mail;
}
}
if ($to === null) {
return $mail;
}
// メール内容をヘッダと本文に分離
$mail = str_replace("\r\n", "\n", $mail);
list($header, $body) = $this->_parse($mail);
// 添付ファイル (multipart)
if ($attach !== null) {
$attach = isset($attach[0]) ? $attach : array($attach);
$boundary = Ethna_Util::getRandom();
$body = "This is a multi-part message in MIME format.\n\n" . "--{$boundary}\n" . "Content-Type: text/plain; charset=utf-8\n" . "Content-Transfer-Encoding: 8bit\n\n" . "{$body}\n";
foreach ($attach as $part) {
if (isset($part['content']) === false && isset($part['filename']) && is_readable($part['filename'])) {
$part['content'] = file_get_contents($part['filename']);
$part['filename'] = basename($part['filename']);
}
if (isset($part['content']) === false) {
continue;
}
if (isset($part['content-type']) === false) {
$part['content-type'] = 'application/octet-stream';
}
if (isset($part['name']) === false) {
$part['name'] = $part['filename'];
}
if (isset($part['filename']) === false) {
$part['filename'] = $part['name'];
}
$part['name'] = preg_replace_callback('/([^\\x00-\\x7f]+)/', function ($matches) {
return Ethna_Util::encode_MIME($matches[1]);
}, $part['name']);
// XXX: rfc2231
$part['filename'] = preg_replace_callback('/([^\\x00-\\x7f]+)/', function ($matches) {
return Ethna_Util::encode_MIME($matches[1]);
}, $part['filename']);
$body .= "--{$boundary}\n" . "Content-Type: " . $part['content-type'] . ";\n" . "\tname=\"" . $part['name'] . "\"\n" . "Content-Transfer-Encoding: base64\n" . "Content-Disposition: attachment;\n" . "\tfilename=\"" . $part['filename'] . "\"\n\n";
$body .= chunk_split(base64_encode($part['content']));
}
$body .= "--{$boundary}--";
}
// ヘッダ
if (isset($header['mime-version']) === false) {
$header['mime-version'] = array('Mime-Version', '1.0');
}
if (isset($header['subject']) === false) {
$header['subject'] = array('Subject', 'no subject in original');
}
if (isset($header['content-type']) === false) {
$header['content-type'] = array('Content-Type', $attach === null ? 'text/plain; charset=utf-8' : "multipart/mixed; \n\tboundary=\"{$boundary}\"");
}
if (isset($header['content-transfer-encoding']) === false) {
//.........这里部分代码省略.........
示例11: getConfiguration
/**
* Ethnaの設定一覧を取得する
*
* @access public
* @return array 設定一覧を格納した配列
* @todo respect access controll
*/
function getConfiguration()
{
$r = array();
// core
$elts = array();
$elts[_et('Application ID')] = $this->ctl->getAppId();
$elts[_et('Application URL')] = $this->ctl->getURL();
$elts[_et('Ethna Version')] = ETHNA_VERSION;
$elts[_et('Ethna Base Directory')] = ETHNA_BASE;
$r['Core'] = $elts;
// class
$elts = array();
$elts[_et('Backend')] = $this->class_factory->getObjectName('backend');
$elts[_et('ClassFactory')] = $this->class_factory->getObjectName('class');
$elts[_et('Config')] = $this->class_factory->getObjectName('config');
$elts['DB'] = $this->class_factory->getObjectName('db');
$elts[_et('Error')] = $this->class_factory->getObjectName('error');
$elts[_et('Form')] = $this->class_factory->getObjectName('form');
$elts[_et('Log')] = $this->class_factory->getObjectName('logger');
$elts['i18n'] = $this->class_factory->getObjectName('i18n');
$elts[_et('Plugin')] = $this->class_factory->getObjectName('plugin');
$elts[_et('Session')] = $this->class_factory->getObjectName('session');
$elts['SQL'] = $this->class_factory->getObjectName('sql');
$elts[_et('View')] = $this->class_factory->getObjectName('view');
$r[_et('Class')] = $elts;
// DB
$elts = array();
$db_list = array();
foreach ($dbl = $this->_getInvisibleProperty($this->ctl, 'db') as $key => $db) {
if ($key == "") {
$tmp = '$db';
} else {
$tmp = sprintf('$db_%s', $key);
}
$elts[$tmp] = $this->getAttrName('db_type', $db);
$db_list[$key] = $tmp;
}
$r[_et('DB Type')] = $elts;
// DSN
$elts = array();
foreach ($db_list as $key => $name) {
$config_key = "dsn";
if ($key != "") {
$config_key .= "_{$key}";
}
$dsn = $this->config->get($config_key);
if ($dsn) {
$elts[$name] = implode("\n", to_array($dsn));
}
}
$r['DSN'] = $elts;
// directory
$elts = array();
$elts[_et('Application')] = $this->ctl->getBasedir();
$elts[_et('Action')] = $this->ctl->getActiondir();
$elts[_et('View')] = $this->ctl->getViewdir();
$elts[_et('Filter')] = $this->ctl->getDirectory('filter');
$elts[_et('Plugin')] = $this->ctl->getDirectory('plugin');
$elts[_et('Template')] = $this->ctl->getTemplatedir();
$elts[_et('Template Cache')] = $this->ctl->getDirectory('template_c');
$elts[_et('Smarty Plugin')] = implode(',', $this->ctl->getDirectory('plugins'));
$elts[_et('Configuration File')] = $this->ctl->getDirectory('etc');
$elts[_et('Locale')] = $this->ctl->getDirectory('locale');
$elts[_et('Logging')] = $this->ctl->getDirectory('log');
$elts[_et('Temporary File')] = $this->ctl->getDirectory('tmp');
$r[_et('Directory')] = $elts;
// ext
$elts = array();
$elts[_et('Template')] = $this->ctl->getExt('tpl');
$elts[_et('PHP Script')] = $this->ctl->getExt('php');
$r[_et('File Extention')] = $elts;
// filter
$elts = array();
$n = 1;
foreach ($this->_getInvisibleProperty($this->ctl, 'filter') as $filter) {
$key = sprintf(_et('Filter(%d)'), $n);
if (class_exists($filter)) {
$elts[$key] = $filter;
$n++;
}
}
$r[_et('Filter')] = $elts;
// manager
$elts = array();
foreach ($this->ctl->getManagerList() as $key => $manager) {
$name = sprintf('$%s', $key);
$elts[$name] = $this->ctl->getManagerClassName($manager);
}
$r[_et('Application Manager')] = $elts;
return $r;
}
示例12: validate
/**
* 最小値のチェックを行う
*
* @access public
* @param string $name フォームの名前
* @param mixed $var フォームの値
* @param array $params プラグインのパラメータ
*/
function validate($name, $var, $params)
{
$true = true;
$type = $this->getFormType($name);
if (isset($params['min']) == false || $this->isEmpty($var, $type)) {
return $true;
}
switch ($type) {
case VAR_TYPE_INT:
if ($var < $params['min']) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input more than %d(int) to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_INT, array($params['min']));
}
break;
case VAR_TYPE_FLOAT:
if ($var < $params['min']) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input more than %f(float) to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_FLOAT, array($params['min']));
}
break;
case VAR_TYPE_DATETIME:
$t_min = strtotime($params['min']);
$t_var = strtotime($var);
if ($t_var < $t_min) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input datetime value %s or later to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_DATETIME, array($params['min']));
}
break;
case VAR_TYPE_FILE:
$st = stat($var['tmp_name']);
if ($st[7] < $params['min'] * 1024) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please specify file whose size is more than %d KB.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_FILE, array($params['min']));
}
break;
case VAR_TYPE_STRING:
//
// マルチバイトエンコーディングと、そうでない場合で
// 異なるプラグインを呼ぶ。
//
// これは Ethna_Controller#client_encoding の値によ
// って動きが決まる
//
$ctl = Ethna_Controller::getInstance();
$client_enc = $ctl->getClientEncoding();
$plugin = $this->backend->getPlugin();
// select Plugin.
if (mb_enabled() && strcasecmp('UTF-8', $client_enc) == 0) {
$plugin_name = 'Mbstrmin';
$params['mbstrmin'] = $params['min'];
} elseif (strcasecmp('EUC-JP', $client_enc == 0) || strcasecmp('eucJP-win', $client_enc == 0)) {
$plugin_name = 'Strmincompat';
$params['strmincompat'] = $params['min'];
} else {
$plugin_name = 'Strmin';
$params['strmin'] = $params['min'];
}
unset($params['min']);
$vld = $plugin->getPlugin('Validator', $plugin_name);
return $vld->validate($name, $var, $params);
break;
}
return $true;
}
示例13: getEra
/**
* 元号制での年を返す
*
* @access public
* @param int $t unix time
* @return string 元号(不明な場合はnull)
*/
public static function getEra($t)
{
$tm = localtime($t, true);
$year = $tm['tm_year'] + 1900;
if ($year >= 1989) {
$heisei_str = _et('Heisei');
return array($heisei_str, $year - 1988);
} else {
if ($year >= 1926) {
$showa_str = _et('Showa');
return array($showa_str, $year - 1925);
}
}
return null;
}
示例14: _getFormInput_Submit
/**
* フォームタグを取得する(type="submit")
*
* @access protected
*/
function _getFormInput_Submit($name, $def, $params)
{
$params['type'] = 'submit';
if (isset($def['type'])) {
$params['name'] = is_array($def['type']) ? $name . '[]' : $name;
} else {
$params['name'] = $name;
}
if (isset($params['value']) === false) {
if (isset($def['name'])) {
$params['value'] = _et($def['name']);
}
}
if (is_array($params['value'])) {
$params['value'] = $params['value'][0];
}
return $this->_getFormInput_Html('input', $params);
}
示例15: switch
/**
* アップロードされたファイルのチェックを行う
* XXX: プラグインのエラーコードを修正する
*
* @access public
* @param string $name フォームの名前
* @param mixed $var フォームの値
* @param array $params プラグインのパラメータ
*/
function &validate($name, $var, $params)
{
$true = true;
if ($this->getFormType($name) != VAR_TYPE_FILE) {
return $true;
}
// そもそもアップロードされていない場合はスキップ
if ($var['error'] == UPLOAD_ERR_NO_FILE) {
return $true;
}
// エラーコードの検査
$msg = '';
switch ($var['error']) {
case UPLOAD_ERR_INI_SIZE:
$msg = _et("Uploaded file size exceeds php.ini's upload_max_filesize directive.");
break;
case UPLOAD_ERR_FORM_SIZE:
$msg = _et('Uploaded File size exceeds MAX_FILE_SIZE specified in HTML Form.');
break;
case UPLOAD_ERR_PARTIAL:
$msg = _et('File was only uploaded patially.');
break;
case UPLOAD_ERR_NO_FILE:
$msg = _et('File was not uploaded.');
break;
case UPLOAD_ERR_NO_TMP_DIR:
$msg = _et('Temporary folder was not found.');
break;
case UPLOAD_ERR_CANT_WRITE:
$msg = _et('Could not write uploaded file to disk.');
break;
}
if ($msg != '') {
if (isset($params['error'])) {
$msg = $params['error'];
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_FILE);
}
// tmp_name の検査
if (isset($var['tmp_name']) == false || is_uploaded_file($var['tmp_name']) == false) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('invalid tmp_name.');
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_FILE);
}
// size の検査
if (isset($params['size_max'])) {
$st = stat($var['tmp_name']);
if ($st[7] > $this->_getSizeAsBytes($params['size_max'])) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Uploaded file size must be less than %s.');
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_FILE, array($params['size_max']));
}
}
if (isset($params['size_min'])) {
$st = stat($var['tmp_name']);
if ($st[7] < $this->_getSizeAsBytes($params['size_min'])) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Uploaded file size must be more than %s.');
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_FILE, array($params['size_min']));
}
}
// type の検査
if (isset($params['type'])) {
$type_list = to_array($params['type']);
$posted_mime = explode('/', $var['type'], 2);
foreach ($type_list as $type) {
$wanted_mime = explode('/', $type, 2);
$test = count($wanted_mime) == 1 ? strcasecmp($wanted_mime[0], $posted_mime[0]) == 0 : strcasecmp($type, $var['type']) == 0;
if ($test == true) {
break;
}
}
if ($test == false) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Invalid file type.');
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_FILE);
}
}
// name(ファイル名)の検査
//.........这里部分代码省略.........