| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * http://www.lockon.co.jp/
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /* ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹ */
|
|---|
| 9 | class SC_FormParam {
|
|---|
| 10 |
|
|---|
| 11 | var $param;
|
|---|
| 12 | var $disp_name;
|
|---|
| 13 | var $keyname;
|
|---|
| 14 | var $length;
|
|---|
| 15 | var $convert;
|
|---|
| 16 | var $arrCheck;
|
|---|
| 17 | var $default; // ²¿¤âÆþÎϤµ¤ì¤Æ¤¤¤Ê¤¤¤È¤¤Ëɽ¼¨¤¹¤ëÃÍ
|
|---|
| 18 | var $input_db; // DB¤Ë¤½¤Î¤Þ¤ÞÁÞÆþ²Äǽ¤«Èݤ«
|
|---|
| 19 | var $html_disp_name;
|
|---|
| 20 |
|
|---|
| 21 | // ¥³¥ó¥¹¥È¥é¥¯¥¿
|
|---|
| 22 | function SC_FormParam() {
|
|---|
| 23 | $this->check_dir = IMAGE_SAVE_DIR;
|
|---|
| 24 | $this->disp_name = array();
|
|---|
| 25 | $this->keyname = array();
|
|---|
| 26 | $this->length = array();
|
|---|
| 27 | $this->convert = array();
|
|---|
| 28 | $this->arrCheck = array();
|
|---|
| 29 | $this->default = array();
|
|---|
| 30 | $this->input_db = array();
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | // ¥Ñ¥é¥á¡¼¥¿¤ÎÄɲÃ
|
|---|
| 34 | function addParam($disp_name, $keyname, $length="", $convert="", $arrCheck=array(), $default="", $input_db="true") {
|
|---|
| 35 | $this->disp_name[] = $disp_name;
|
|---|
| 36 | $this->keyname[] = $keyname;
|
|---|
| 37 | $this->length[] = $length;
|
|---|
| 38 | $this->convert[] = $convert;
|
|---|
| 39 | $this->arrCheck[] = $arrCheck;
|
|---|
| 40 | $this->default[] = $default;
|
|---|
| 41 | $this->input_db[] = $input_db;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | // ¥Ñ¥é¥á¡¼¥¿¤ÎÆþÎÏ
|
|---|
| 45 | // $arrVal :$arrVal['keyname']¡¦¡¦¤ÎÇÛÎó¤ò°ìÃפ·¤¿¥¡¼¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤Ë³ÊǼ¤¹¤ë
|
|---|
| 46 | // $seq :true¤Î¾ì¹ç¡¢$arrVal[0]¢·¤ÎÇÛÎó¤òÅÐÏ¿½ç¤Ë¥¤¥ó¥¹¥¿¥ó¥¹¤Ë³ÊǼ¤¹¤ë
|
|---|
| 47 | function setParam($arrVal, $seq = false) {
|
|---|
| 48 | $cnt = 0;
|
|---|
| 49 | if(!$seq){
|
|---|
| 50 | foreach($this->keyname as $val) {
|
|---|
| 51 | if(isset($arrVal[$val])) {
|
|---|
| 52 | $this->setValue($val, $arrVal[$val]);
|
|---|
| 53 | }
|
|---|
| 54 | }
|
|---|
| 55 | } else {
|
|---|
| 56 | foreach($this->keyname as $val) {
|
|---|
| 57 | $this->param[$cnt] = $arrVal[$cnt];
|
|---|
| 58 | $cnt++;
|
|---|
| 59 | }
|
|---|
| 60 | }
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | // ²èÌÌɽ¼¨ÍÑ¥¿¥¤¥È¥ëÀ¸À®
|
|---|
| 64 | function setHtmlDispNameArray() {
|
|---|
| 65 | $cnt = 0;
|
|---|
| 66 | foreach($this->keyname as $val) {
|
|---|
| 67 | $find = false;
|
|---|
| 68 | foreach($this->arrCheck[$cnt] as $val) {
|
|---|
| 69 | if($val == "EXIST_CHECK") {
|
|---|
| 70 | $find = true;
|
|---|
| 71 | }
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | if($find) {
|
|---|
| 75 | $this->html_disp_name[$cnt] = $this->disp_name[$cnt] . "<span class='red'>(¢¨ ɬ¿Ü)</span>";
|
|---|
| 76 | } else {
|
|---|
| 77 | $this->html_disp_name[$cnt] = $this->disp_name[$cnt];
|
|---|
| 78 | }
|
|---|
| 79 | $cnt++;
|
|---|
| 80 | }
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | // ²èÌÌɽ¼¨ÍÑ¥¿¥¤¥È¥ë¼èÆÀ
|
|---|
| 84 | function getHtmlDispNameArray() {
|
|---|
| 85 | return $this->html_disp_name;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | // Ê£¿ôÎó¥Ñ¥é¥á¡¼¥¿¤Î¼èÆÀ
|
|---|
| 89 | function setParamList($arrVal, $keyname) {
|
|---|
| 90 | // DB¤Î·ï¿ô¤ò¼èÆÀ¤¹¤ë¡£
|
|---|
| 91 | $count = count($arrVal);
|
|---|
| 92 | $no = 1;
|
|---|
| 93 | for($cnt = 0; $cnt < $count; $cnt++) {
|
|---|
| 94 | $key = $keyname.$no;
|
|---|
| 95 | if($arrVal[$cnt][$keyname] != "") {
|
|---|
| 96 | $this->setValue($key, $arrVal[$cnt][$keyname]);
|
|---|
| 97 | }
|
|---|
| 98 | $no++;
|
|---|
| 99 | }
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | function setDBDate($db_date, $year_key = 'year', $month_key = 'month', $day_key = 'day') {
|
|---|
| 103 | list($y, $m, $d) = split("[- ]", $db_date);
|
|---|
| 104 | $this->setValue($year_key, $y);
|
|---|
| 105 | $this->setValue($month_key, $m);
|
|---|
| 106 | $this->setValue($day_key, $d);
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | // ¥¡¼¤ËÂбþ¤·¤¿Ãͤò¥»¥Ã¥È¤¹¤ë¡£
|
|---|
| 110 | function setValue($key, $param) {
|
|---|
| 111 | $cnt = 0;
|
|---|
| 112 | foreach($this->keyname as $val) {
|
|---|
| 113 | if($val == $key) {
|
|---|
| 114 | $this->param[$cnt] = $param;
|
|---|
| 115 | break;
|
|---|
| 116 | }
|
|---|
| 117 | $cnt++;
|
|---|
| 118 | }
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | function toLower($key) {
|
|---|
| 122 | $cnt = 0;
|
|---|
| 123 | foreach($this->keyname as $val) {
|
|---|
| 124 | if($val == $key) {
|
|---|
| 125 | $this->param[$cnt] = strtolower($this->param[$cnt]);
|
|---|
| 126 | break;
|
|---|
| 127 | }
|
|---|
| 128 | $cnt++;
|
|---|
| 129 | }
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | // ¥¨¥é¡¼¥Á¥§¥Ã¥¯
|
|---|
| 133 | function checkError($br = true, $keyname = "") {
|
|---|
| 134 | // Ï¢ÁÛÇÛÎó¤Î¼èÆÀ
|
|---|
| 135 | $arrRet = $this->getHashArray($keyname);
|
|---|
| 136 | $objErr = new SC_CheckError($arrRet);
|
|---|
| 137 | $cnt = 0;
|
|---|
| 138 | foreach($this->keyname as $val) {
|
|---|
| 139 | foreach($this->arrCheck[$cnt] as $func) {
|
|---|
| 140 | switch($func) {
|
|---|
| 141 | case 'EXIST_CHECK':
|
|---|
| 142 | case 'NUM_CHECK':
|
|---|
| 143 | case 'EMAIL_CHECK':
|
|---|
| 144 | case 'EMAIL_CHAR_CHECK':
|
|---|
| 145 | case 'ALNUM_CHECK':
|
|---|
| 146 | case 'KANA_CHECK':
|
|---|
| 147 | case 'URL_CHECK':
|
|---|
| 148 | case 'SPTAB_CHECK':
|
|---|
| 149 | case 'ZERO_CHECK':
|
|---|
| 150 | case 'ALPHA_CHECK':
|
|---|
| 151 | case 'ZERO_START':
|
|---|
| 152 | case 'FIND_FILE':
|
|---|
| 153 | case 'NO_SPTAB':
|
|---|
| 154 | case 'DIR_CHECK':
|
|---|
| 155 | case 'DOMAIN_CHECK':
|
|---|
| 156 |
|
|---|
| 157 | if(!is_array($this->param[$cnt])) {
|
|---|
| 158 | $objErr->doFunc(array($this->disp_name[$cnt], $val), array($func));
|
|---|
| 159 | } else {
|
|---|
| 160 | $max = count($this->param[$cnt]);
|
|---|
| 161 | for($i = 0; $i < $max; $i++) {
|
|---|
| 162 | $objSubErr = new SC_CheckError($this->param[$cnt]);
|
|---|
| 163 | $objSubErr->doFunc(array($this->disp_name[$cnt], $i), array($func));
|
|---|
| 164 | if(count($objSubErr->arrErr) > 0) {
|
|---|
| 165 | foreach($objSubErr->arrErr as $mess) {
|
|---|
| 166 | if($mess != "") {
|
|---|
| 167 | $objErr->arrErr[$val] = $mess;
|
|---|
| 168 | }
|
|---|
| 169 | }
|
|---|
| 170 | }
|
|---|
| 171 | }
|
|---|
| 172 | }
|
|---|
| 173 | break;
|
|---|
| 174 | case 'LENGTH_CHECK':
|
|---|
| 175 | case 'MAX_LENGTH_CHECK':
|
|---|
| 176 | case 'NUM_COUNT_CHECK':
|
|---|
| 177 | if(!is_array($this->param[$cnt])) {
|
|---|
| 178 | $objErr->doFunc(array($this->disp_name[$cnt], $val, $this->length[$cnt]), array($func));
|
|---|
| 179 | } else {
|
|---|
| 180 | $max = count($this->param[$cnt]);
|
|---|
| 181 | for($i = 0; $i < $max; $i++) {
|
|---|
| 182 | $objSubErr = new SC_CheckError($this->param[$cnt]);
|
|---|
| 183 | $objSubErr->doFunc(array($this->disp_name[$cnt], $i, $this->length[$cnt]), array($func));
|
|---|
| 184 | if(count($objSubErr->arrErr) > 0) {
|
|---|
| 185 | foreach($objSubErr->arrErr as $mess) {
|
|---|
| 186 | if($mess != "") {
|
|---|
| 187 | $objErr->arrErr[$val] = $mess;
|
|---|
| 188 | }
|
|---|
| 189 | }
|
|---|
| 190 | }
|
|---|
| 191 | }
|
|---|
| 192 | }
|
|---|
| 193 | break;
|
|---|
| 194 | // ¾®Ê¸»ú¤ËÊÑ´¹
|
|---|
| 195 | case 'CHANGE_LOWER':
|
|---|
| 196 | $this->param[$cnt] = strtolower($this->param[$cnt]);
|
|---|
| 197 | break;
|
|---|
| 198 | // ¥Õ¥¡¥¤¥ë¤Î¸ºß¥Á¥§¥Ã¥¯
|
|---|
| 199 | case 'FILE_EXISTS':
|
|---|
| 200 | if($this->param[$cnt] != "" && !file_exists($this->check_dir . $this->param[$cnt])) {
|
|---|
| 201 | $objErr->arrErr[$val] = "¢¨ " . $this->disp_name[$cnt] . "¤Î¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Þ¤»¤ó¡£<br>";
|
|---|
| 202 | }
|
|---|
| 203 | break;
|
|---|
| 204 | default:
|
|---|
| 205 | $objErr->arrErr[$val] = "¢¨¢¨¡¡¥¨¥é¡¼¥Á¥§¥Ã¥¯·Á¼°($func)¤Ë¤ÏÂбþ¤·¤Æ¤¤¤Þ¤»¤ó¡¡¢¨¢¨ <br>";
|
|---|
| 206 | break;
|
|---|
| 207 | }
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | if (isset($objErr->arrErr[$val]) && !$br) {
|
|---|
| 211 | $objErr->arrErr[$val] = ereg_replace("<br>$", "", $objErr->arrErr[$val]);
|
|---|
| 212 | }
|
|---|
| 213 | $cnt++;
|
|---|
| 214 | }
|
|---|
| 215 | return $objErr->arrErr;
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | // ÆþÎÏʸ»ú¤ÎÊÑ´¹
|
|---|
| 219 | function convParam() {
|
|---|
| 220 | /*
|
|---|
| 221 | * ʸ»úÎó¤ÎÊÑ´¹
|
|---|
| 222 | * K : ¡ÖȾ³Ñ(Êݶ¸)ÊÒ²¾Ì¾¡×¤ò¡ÖÁ´³ÑÊÒ²¾Ì¾¡×¤ËÊÑ´¹
|
|---|
| 223 | * C : ¡ÖÁ´³Ñ¤Ò¤é²¾Ì¾¡×¤ò¡ÖÁ´³Ñ¤«¤¿²¾Ì¾¡×¤ËÊÑ´¹
|
|---|
| 224 | * V : ÂùÅÀÉÕ¤¤Îʸ»ú¤ò°ìʸ»ú¤ËÊÑ´¹¡£"K","H"¤È¶¦¤Ë»ÈÍѤ·¤Þ¤¹
|
|---|
| 225 | * n : ¡ÖÁ´³Ñ¡×¿ô»ú¤ò¡ÖȾ³Ñ(Êݶ¸)¡×¤ËÊÑ´¹
|
|---|
| 226 | * a : ¡ÖÁ´³Ñ¡×±Ñ»ú¤ò¡ÖȾ³Ñ¡×±Ñ»ú¤ËÊÑ´¹
|
|---|
| 227 | */
|
|---|
| 228 | $cnt = 0;
|
|---|
| 229 | foreach ($this->keyname as $val) {
|
|---|
| 230 | if(!is_array($this->param[$cnt])) {
|
|---|
| 231 | if($this->convert[$cnt] != "") {
|
|---|
| 232 | $this->param[$cnt] = mb_convert_kana($this->param[$cnt] ,$this->convert[$cnt]);
|
|---|
| 233 | }
|
|---|
| 234 | } else {
|
|---|
| 235 | $max = count($this->param[$cnt]);
|
|---|
| 236 | for($i = 0; $i < $max; $i++) {
|
|---|
| 237 | if($this->convert[$cnt] != "") {
|
|---|
| 238 | $this->param[$cnt][$i] = mb_convert_kana($this->param[$cnt][$i] ,$this->convert[$cnt]);
|
|---|
| 239 | }
|
|---|
| 240 | }
|
|---|
| 241 | }
|
|---|
| 242 | $cnt++;
|
|---|
| 243 | }
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 | // Ï¢ÁÛÇÛÎó¤ÎºîÀ®
|
|---|
| 247 | function getHashArray($keyname = "") {
|
|---|
| 248 | $cnt = 0;
|
|---|
| 249 | foreach($this->keyname as $val) {
|
|---|
| 250 | if($keyname == "" || $keyname == $val) {
|
|---|
| 251 | $arrRet[$val] = $this->param[$cnt];
|
|---|
| 252 | $cnt++;
|
|---|
| 253 | }
|
|---|
| 254 | }
|
|---|
| 255 | return $arrRet;
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | // DB³ÊǼÍÑÇÛÎó¤ÎºîÀ®
|
|---|
| 259 | function getDbArray() {
|
|---|
| 260 | $cnt = 0;
|
|---|
| 261 | foreach ($this->keyname as $val) {
|
|---|
| 262 | if ($this->input_db[$cnt]) {
|
|---|
| 263 | $arrRet[$val] = $this->param[$cnt];
|
|---|
| 264 | }
|
|---|
| 265 | $cnt++;
|
|---|
| 266 | }
|
|---|
| 267 | return $arrRet;
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| 270 | // ÇÛÎó¤Î½Ä²£¤òÆþ¤ìÂØ¤¨¤ÆÊÖ¤¹
|
|---|
| 271 | function getSwapArray($arrKey) {
|
|---|
| 272 | foreach($arrKey as $keyname) {
|
|---|
| 273 | $arrVal = $this->getValue($keyname);
|
|---|
| 274 | $max = count($arrVal);
|
|---|
| 275 | for($i = 0; $i < $max; $i++) {
|
|---|
| 276 | $arrRet[$i][$keyname] = $arrVal[$i];
|
|---|
| 277 | }
|
|---|
| 278 | }
|
|---|
| 279 | return $arrRet;
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | // ¹àÌÜ̾°ìÍ÷¤Î¼èÆÀ
|
|---|
| 283 | function getTitleArray() {
|
|---|
| 284 | return $this->disp_name;
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | // ¹àÌÜ¿ô¤òÊÖ¤¹
|
|---|
| 288 | function getCount() {
|
|---|
| 289 | $count = count($this->keyname);
|
|---|
| 290 | return $count;
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 | // ¥Õ¥©¡¼¥à¤ËÅϤ¹ÍѤΥѥé¥á¡¼¥¿¤òÊÖ¤¹
|
|---|
| 294 | function getFormParamList() {
|
|---|
| 295 | $cnt = 0;
|
|---|
| 296 | foreach($this->keyname as $val) {
|
|---|
| 297 | // ¥¡¼Ì¾
|
|---|
| 298 | $arrRet[$val]['keyname'] = $this->keyname[$cnt];
|
|---|
| 299 | // ʸ»ú¿ôÀ©¸Â
|
|---|
| 300 | $arrRet[$val]['length'] = $this->length[$cnt];
|
|---|
| 301 | // ÆþÎÏÃÍ
|
|---|
| 302 | $arrRet[$val]['value'] = $this->param[$cnt];
|
|---|
| 303 | // ɽ¼¨Ì¾
|
|---|
| 304 | $arrRet[$val]['name'] = $this->disp_name[$cnt];
|
|---|
| 305 | // ÊÑ´¹·¿
|
|---|
| 306 | $arrRet[$val]['convert'] = $this->convert[$cnt];
|
|---|
| 307 |
|
|---|
| 308 | if($this->default[$cnt] != "" && $this->param[$cnt] == "") {
|
|---|
| 309 | $arrRet[$val]['value'] = $this->default[$cnt];
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | $cnt++;
|
|---|
| 313 | }
|
|---|
| 314 | return $arrRet;
|
|---|
| 315 | }
|
|---|
| 316 |
|
|---|
| 317 | // ¥¡¼Ì¾¤Î°ìÍ÷¤òÊÖ¤¹
|
|---|
| 318 | function getKeyList() {
|
|---|
| 319 | foreach($this->keyname as $val) {
|
|---|
| 320 | $arrRet[] = $val;
|
|---|
| 321 | }
|
|---|
| 322 | return $arrRet;
|
|---|
| 323 | }
|
|---|
| 324 |
|
|---|
| 325 | // ¥¡¼Ì¾¤È°ìÃפ·¤¿ÃͤòÊÖ¤¹
|
|---|
| 326 | function getValue($keyname) {
|
|---|
| 327 | $cnt = 0;
|
|---|
| 328 | foreach($this->keyname as $val) {
|
|---|
| 329 | if($val == $keyname) {
|
|---|
| 330 | $ret = $this->param[$cnt];
|
|---|
| 331 | break;
|
|---|
| 332 | }
|
|---|
| 333 | $cnt++;
|
|---|
| 334 | }
|
|---|
| 335 | return $ret;
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | function splitCheckBoxes($keyname) {
|
|---|
| 339 | $cnt = 0;
|
|---|
| 340 | foreach($this->keyname as $val) {
|
|---|
| 341 | if($val == $keyname) {
|
|---|
| 342 | $this->param[$cnt] = sfSplitCheckBoxes($this->param[$cnt]);
|
|---|
| 343 | }
|
|---|
| 344 | $cnt++;
|
|---|
| 345 | }
|
|---|
| 346 | }
|
|---|
| 347 |
|
|---|
| 348 | function splitParamCheckBoxes($keyname) {
|
|---|
| 349 | $cnt = 0;
|
|---|
| 350 | foreach($this->keyname as $val) {
|
|---|
| 351 | if($val == $keyname) {
|
|---|
| 352 | if(!is_array($this->param[$cnt])) {
|
|---|
| 353 | $this->param[$cnt] = split("-", $this->param[$cnt]);
|
|---|
| 354 | }
|
|---|
| 355 | }
|
|---|
| 356 | $cnt++;
|
|---|
| 357 | }
|
|---|
| 358 | }
|
|---|
| 359 | }
|
|---|
| 360 | ?> |
|---|