<?php
// Mobileでの使用例
class QF_Form {
var $_form;
var $mode_at;
var $mode_va;
function QF_Form($frmName, $argAction) {
$this->_form = new HTML_QuickForm($frmName, 'post', $argAction);
// DoCoMo
if (ereg( "DoCoMo", $_SERVER["HTTP_USER_AGENT"] )) {
$this->mode_at = "istyle";
$this->mode_va = array("1", "2", "3", "4");
// ezweb
} elseif (ereg( "UP\.Browser", $_SERVER["HTTP_USER_AGENT"] )) {
if (ereg( "^UP\.Browser", $_SERVER["HTTP_USER_AGENT"] )) {
header ("Location: http://www.okushin.co.jp/information/tanuki03/");
} else {
$this->mode_at = "format";
$this->mode_va = array("*M", "*M", "*m", "*N");
}
// vodephone
} elseif (ereg( "J-PHONE", $_SERVER["HTTP_USER_AGENT"] )) {
$this->mode_at = "mode";
$this->mode_va = array("hiragana", "katakana", "alphabet", "numeric");
// L-mode
} elseif (ereg( "L-mode", $_SERVER["HTTP_USER_AGENT"] )) {
$this->mode_at = "istyle";
$this->mode_va = array("1", "2", "3", "4");
} else {
$this->mode_at = "istyle";
$this->mode_va = array("1", "2", "3", "4");
}
}
// 「モード属性」
function getMode_at() {
return $this->mode_at;
}
// 「ひらがなモード」
function getMode_va_hira() {
return $this->mode_va[0];
}
// 「カタカナモード」
function getMode_va_kata() {
return $this->mode_va[1];
}
// 「アルファベット属性」
function getMode_va_alph() {
return $this->mode_va[2];
}
// 「数字記号属性」
function getMode_va_num() {
return $this->mode_va[3];
}
}
class Test_Form extends QF_Form {
// フォームの項目を定義
function setItems() {
$this->_form->addElement('text', 'mail', '登録メールアドレス',
array('size' => 15, 'maxlength' => 50,
$this->getMode_at() => $this->getMode_va_alph()));
$this->_form->addElement('text', 'passwd', 'パスワード',
array('size' => 15, 'maxlength' => 50,
$this->getMode_at() => $this->getMode_va_alph()));
$this->_form->addElement('textarea', 'impressions', 'ご意見ご感想',
array('cols' => 15, 'rows' => 5,
$this->getMode_at() => $this->getMode_va_hira()));
}
?>
|