Source for file SC_FormParam.php
Documentation is available at SC_FormParam.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* :XXX: addParam と setParam で言う「パラメーター」が用語として競合しているように感じる。(2009/10/17 Seasoft 塚田)
* @author LOCKON CO.,LTD.
/** 何も入力されていないときに表示する値 */
$this->check_dir = IMAGE_SAVE_REALDIR;
function addParam($disp_name, $keyname, $length = "", $convert = "", $arrCheck = array(), $default = "", $input_db = 'true') {
// $arrVal :$arrVal['keyname']・・の配列を一致したキーのインスタンスに格納する
// $seq :trueの場合、$arrVal[0]~の配列を登録順にインスタンスに格納する
function setParam($arrVal, $seq = false) {
if(isset ($arrVal[$val])) {
$this->param[$cnt] = $arrVal[$cnt];
foreach($this->arrCheck[$cnt] as $val) {
if($val == "EXIST_CHECK") {
for($cnt = 0; $cnt < $count; $cnt++ ) {
if($arrVal[$cnt][$keyname] != "") {
$this->setValue($key, $arrVal[$cnt][$keyname]);
function setDBDate($db_date, $year_key = 'year', $month_key = 'month', $day_key = 'day') {
list ($y, $m, $d) = preg_split("/[- ]/", $db_date);
$this->param[$cnt] = $param;
// 複数一致の場合もあるので break してはいけない。
// 複数一致の場合もあるので break してはいけない。
$objErr->arrErr = array();
foreach($this->arrCheck[$cnt] as $func) {
if (!isset ($this->param[$cnt])) $this->param[$cnt] = "";
case 'MOBILE_EMAIL_CHECK':
case 'FILE_NAME_CHECK_BY_NOUPLOAD':
$this->param[$cnt], $objErr->arrErr,
$objErr->arrErr[$val] = "※ " . $this->disp_name[$cnt] . "のファイルが存在しません。<br>";
$objErr->arrErr[$val] = "※ " . $this->disp_name[$cnt] . "のファイルが存在しません。<br>";
$objErr->arrErr[$val] = "※※ エラーチェック形式($func)には対応していません ※※ <br>";
if (isset ($objErr->arrErr[$val]) && !$br) {
$objErr->arrErr[$val] = preg_replace("/<br(\s+\/)?>/i", "", $objErr->arrErr[$val]);
* SC_CheckError::doFunc() を再帰的に実行する.
* 再帰実行した場合は, エラーメッセージを多次元配列で格納する
* TODO 二次元以上のエラーメッセージへの対応
* @param string $disp_name 表示名
* @param string $func チェック種別
* @param mixed $value チェック対象の値. 配列の場合は再帰的にチェックする.
* @param array $arrErr エラーメッセージを格納する配列
* @param string $error_key エラーメッセージを格納する配列のキー
* @param integer $length チェック対象の値の長さ
* @param integer $depth 再帰実行した場合の深度
* @param integer $error_last_key エラーメッセージを格納する配列の末端のキー
function recursionCheck($disp_name, $func, $value, &$arrErr, $error_key,
$length = 0, $depth = 0, $error_last_key = null) {
foreach ($value as $key => $in) {
$objErr = new SC_CheckError_Ex(array(0 => $value));
$objErr->doFunc(array($disp_name, 0, $length), array($func));
if (!SC_Utils_Ex::isBlank($objErr->arrErr)) {
foreach($objErr->arrErr as $message) {
if(!SC_Utils_Ex::isBlank($message)) {
// 再帰した場合は多次元配列のエラーメッセージを生成
$error_var = '$arrErr[$error_key]';
for ($i = 0; $i < $depth; $i++ ) {
$error_var .= '[' . $error_last_key . ']';
eval ($error_var . ' = $message;');
* フォームの入力パラメーターに応じて, 再帰的に mb_convert_kana 関数を実行する.
if (!isset ($this->param[$cnt])) $this->param[$cnt] = "";
* 再帰的に mb_convert_kana を実行する.
* @param mixed $value 変換する値. 配列の場合は再帰的に実行する.
* @param string $convert mb_convert_kana の変換オプション
if (!SC_Utils_Ex::isBlank($value)) {
$value = mb_convert_kana($value, $convert);
* @param array $arrKey 対象のキー
foreach($this->keyname as $index => $keyname) {
if (empty($arrKey) || in_array($keyname, $arrKey)) {
$arrRet[$keyname] = isset ($this->param[$index]) ? $this->param[$index] : '';
$arrRet[$val] = isset ($this->param[$cnt]) ? $this->param[$cnt] : "";
* @param array $arrKey 対象のキー
* @return array 縦横を入れ替えた配列
return SC_Utils_Ex::sfSwapArray($arrTmp);
$arrRet[$val]['keyname'] = $this->keyname[$cnt];
$arrRet[$val]['length'] = $this->length[$cnt];
if (isset ($this->param[$cnt])) {
$arrRet[$val]['value'] = $this->param[$cnt];
if (!isset ($this->param[$cnt])) $this->param[$cnt] = "";
if($this->default[$cnt] != "" && $this->param[$cnt] == "") {
$arrRet[$val]['value'] = $this->default[$cnt];
function getValue($keyname, $default = '') {
$ret = isset ($this->param[$cnt]) ? $this->param[$cnt] : "";
if (SC_Utils_Ex::isBlank($ret[$key])) {
if (SC_Utils_Ex::isBlank($ret)) {
* 入力パラメーターの先頭及び末尾にある空白文字を削除する.
* @param boolean $has_wide_space 全角空白も削除する場合 true
if (!isset ($this->param[$cnt])) $this->param[$cnt] = "";
* 再帰的に入力パラメーターの先頭及び末尾にある空白文字を削除する.
* @param mixed $value 変換する値. 配列の場合は再帰的に実行する.
* @param boolean $has_wide_space 全角空白も削除する場合 true
$pattern = '/^[ \r\n\t]*(.*?)[ \r\n\t]*$/u';
if (!SC_Utils_Ex::isBlank($value)) {
* 引数で指定した文字列で始まるパラメーター名の入力値を連想配列で取得する.
* @param string $prefix パラメーター名の接頭辞
* @return array 検索結果引き継ぎ用の連想配列.
$arrResults[$key] = isset ($this->param[$cnt])
? $this->param[$cnt] : "";
$arrRet[$cnt]['keyname'] = $this->keyname[$cnt];
$arrRet[$cnt]['length'] = $this->length[$cnt];
$arrRet[$cnt]['disp_name'] = $this->disp_name[$cnt];
if (isset ($this->param[$cnt])) {
$arrRet[$cnt]['value'] = $this->param[$cnt];
if (!isset ($this->param[$cnt])) $this->param[$cnt] = "";
if($this->default[$cnt] != "" && $this->param[$cnt] == "") {
$arrRet[$cnt]['value'] = $this->default[$cnt];
Documentation generated on Fri, 24 Feb 2012 14:02:33 +0900 by Seasoft
|