1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 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 | case 'FILE_NAME_CHECK': |
---|
157 | case 'MOBILE_EMAIL_CHECK': |
---|
158 | |
---|
159 | if(!is_array($this->param[$cnt])) { |
---|
160 | $objErr->doFunc(array($this->disp_name[$cnt], $val), array($func)); |
---|
161 | } else { |
---|
162 | $max = count($this->param[$cnt]); |
---|
163 | for($i = 0; $i < $max; $i++) { |
---|
164 | $objSubErr = new SC_CheckError($this->param[$cnt]); |
---|
165 | $objSubErr->doFunc(array($this->disp_name[$cnt], $i), array($func)); |
---|
166 | if(count($objSubErr->arrErr) > 0) { |
---|
167 | foreach($objSubErr->arrErr as $mess) { |
---|
168 | if($mess != "") { |
---|
169 | $objErr->arrErr[$val] = $mess; |
---|
170 | } |
---|
171 | } |
---|
172 | } |
---|
173 | } |
---|
174 | } |
---|
175 | break; |
---|
176 | case 'MAX_LENGTH_CHECK': |
---|
177 | case 'NUM_COUNT_CHECK': |
---|
178 | if(!is_array($this->param[$cnt])) { |
---|
179 | $objErr->doFunc(array($this->disp_name[$cnt], $val, $this->length[$cnt]), array($func)); |
---|
180 | } else { |
---|
181 | $max = count($this->param[$cnt]); |
---|
182 | for($i = 0; $i < $max; $i++) { |
---|
183 | $objSubErr = new SC_CheckError($this->param[$cnt]); |
---|
184 | $objSubErr->doFunc(array($this->disp_name[$cnt], $i, $this->length[$cnt]), array($func)); |
---|
185 | if(count($objSubErr->arrErr) > 0) { |
---|
186 | foreach($objSubErr->arrErr as $mess) { |
---|
187 | if($mess != "") { |
---|
188 | $objErr->arrErr[$val] = $mess; |
---|
189 | } |
---|
190 | } |
---|
191 | } |
---|
192 | } |
---|
193 | } |
---|
194 | break; |
---|
195 | // ¾®Ê¸»ú¤ËÊÑ´¹ |
---|
196 | case 'CHANGE_LOWER': |
---|
197 | $this->param[$cnt] = strtolower($this->param[$cnt]); |
---|
198 | break; |
---|
199 | // ¥Õ¥¡¥¤¥ë¤Î¸ºß¥Á¥§¥Ã¥¯ |
---|
200 | case 'FILE_EXISTS': |
---|
201 | if($this->param[$cnt] != "" && !file_exists($this->check_dir . $this->param[$cnt])) { |
---|
202 | $objErr->arrErr[$val] = "¢¨ " . $this->disp_name[$cnt] . "¤Î¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Þ¤»¤ó¡£<br>"; |
---|
203 | } |
---|
204 | break; |
---|
205 | default: |
---|
206 | $objErr->arrErr[$val] = "¢¨¢¨¡¡¥¨¥é¡¼¥Á¥§¥Ã¥¯·Á¼°($func)¤Ë¤ÏÂбþ¤·¤Æ¤¤¤Þ¤»¤ó¡¡¢¨¢¨ <br>"; |
---|
207 | break; |
---|
208 | } |
---|
209 | } |
---|
210 | |
---|
211 | if (isset($objErr->arrErr[$val]) && !$br) { |
---|
212 | $objErr->arrErr[$val] = ereg_replace("<br>$", "", $objErr->arrErr[$val]); |
---|
213 | } |
---|
214 | $cnt++; |
---|
215 | } |
---|
216 | return $objErr->arrErr; |
---|
217 | } |
---|
218 | |
---|
219 | // ÆþÎÏʸ»ú¤ÎÊÑ´¹ |
---|
220 | function convParam() { |
---|
221 | /* |
---|
222 | * ʸ»úÎó¤ÎÊÑ´¹ |
---|
223 | * K : ¡ÖȾ³Ñ(Êݶ¸)ÊÒ²¾Ì¾¡×¤ò¡ÖÁ´³ÑÊÒ²¾Ì¾¡×¤ËÊÑ´¹ |
---|
224 | * C : ¡ÖÁ´³Ñ¤Ò¤é²¾Ì¾¡×¤ò¡ÖÁ´³Ñ¤«¤¿²¾Ì¾¡×¤ËÊÑ´¹ |
---|
225 | * V : ÂùÅÀÉÕ¤¤Îʸ»ú¤ò°ìʸ»ú¤ËÊÑ´¹¡£"K","H"¤È¶¦¤Ë»ÈÍѤ·¤Þ¤¹ |
---|
226 | * n : ¡ÖÁ´³Ñ¡×¿ô»ú¤ò¡ÖȾ³Ñ(Êݶ¸)¡×¤ËÊÑ´¹ |
---|
227 | * a : ¡ÖÁ´³Ñ¡×±Ñ»ú¤ò¡ÖȾ³Ñ¡×±Ñ»ú¤ËÊÑ´¹ |
---|
228 | */ |
---|
229 | $cnt = 0; |
---|
230 | foreach ($this->keyname as $val) { |
---|
231 | if(!is_array($this->param[$cnt])) { |
---|
232 | if($this->convert[$cnt] != "") { |
---|
233 | $this->param[$cnt] = mb_convert_kana($this->param[$cnt] ,$this->convert[$cnt]); |
---|
234 | } |
---|
235 | } else { |
---|
236 | $max = count($this->param[$cnt]); |
---|
237 | for($i = 0; $i < $max; $i++) { |
---|
238 | if($this->convert[$cnt] != "") { |
---|
239 | $this->param[$cnt][$i] = mb_convert_kana($this->param[$cnt][$i] ,$this->convert[$cnt]); |
---|
240 | } |
---|
241 | } |
---|
242 | } |
---|
243 | $cnt++; |
---|
244 | } |
---|
245 | } |
---|
246 | |
---|
247 | // Ï¢ÁÛÇÛÎó¤ÎºîÀ® |
---|
248 | function getHashArray($keyname = "") { |
---|
249 | $cnt = 0; |
---|
250 | foreach($this->keyname as $val) { |
---|
251 | if($keyname == "" || $keyname == $val) { |
---|
252 | $arrRet[$val] = $this->param[$cnt]; |
---|
253 | $cnt++; |
---|
254 | } |
---|
255 | } |
---|
256 | return $arrRet; |
---|
257 | } |
---|
258 | |
---|
259 | // DB³ÊǼÍÑÇÛÎó¤ÎºîÀ® |
---|
260 | function getDbArray() { |
---|
261 | $cnt = 0; |
---|
262 | foreach ($this->keyname as $val) { |
---|
263 | if ($this->input_db[$cnt]) { |
---|
264 | $arrRet[$val] = $this->param[$cnt]; |
---|
265 | } |
---|
266 | $cnt++; |
---|
267 | } |
---|
268 | return $arrRet; |
---|
269 | } |
---|
270 | |
---|
271 | // ÇÛÎó¤Î½Ä²£¤òÆþ¤ìÂØ¤¨¤ÆÊÖ¤¹ |
---|
272 | function getSwapArray($arrKey) { |
---|
273 | foreach($arrKey as $keyname) { |
---|
274 | $arrVal = $this->getValue($keyname); |
---|
275 | $max = count($arrVal); |
---|
276 | for($i = 0; $i < $max; $i++) { |
---|
277 | $arrRet[$i][$keyname] = $arrVal[$i]; |
---|
278 | } |
---|
279 | } |
---|
280 | return $arrRet; |
---|
281 | } |
---|
282 | |
---|
283 | // ¹àÌÜ̾°ìÍ÷¤Î¼èÆÀ |
---|
284 | function getTitleArray() { |
---|
285 | return $this->disp_name; |
---|
286 | } |
---|
287 | |
---|
288 | // ¹àÌÜ¿ô¤òÊÖ¤¹ |
---|
289 | function getCount() { |
---|
290 | $count = count($this->keyname); |
---|
291 | return $count; |
---|
292 | } |
---|
293 | |
---|
294 | // ¥Õ¥©¡¼¥à¤ËÅϤ¹ÍѤΥѥé¥á¡¼¥¿¤òÊÖ¤¹ |
---|
295 | function getFormParamList() { |
---|
296 | $cnt = 0; |
---|
297 | foreach($this->keyname as $val) { |
---|
298 | // ¥¡¼Ì¾ |
---|
299 | $arrRet[$val]['keyname'] = $this->keyname[$cnt]; |
---|
300 | // ʸ»ú¿ôÀ©¸Â |
---|
301 | $arrRet[$val]['length'] = $this->length[$cnt]; |
---|
302 | // ÆþÎÏÃÍ |
---|
303 | $arrRet[$val]['value'] = $this->param[$cnt]; |
---|
304 | |
---|
305 | if($this->default[$cnt] != "" && $this->param[$cnt] == "") { |
---|
306 | $arrRet[$val]['value'] = $this->default[$cnt]; |
---|
307 | } |
---|
308 | |
---|
309 | $cnt++; |
---|
310 | } |
---|
311 | return $arrRet; |
---|
312 | } |
---|
313 | |
---|
314 | // ¥¡¼Ì¾¤Î°ìÍ÷¤òÊÖ¤¹ |
---|
315 | function getKeyList() { |
---|
316 | foreach($this->keyname as $val) { |
---|
317 | $arrRet[] = $val; |
---|
318 | } |
---|
319 | return $arrRet; |
---|
320 | } |
---|
321 | |
---|
322 | // ¥¡¼Ì¾¤È°ìÃפ·¤¿ÃͤòÊÖ¤¹ |
---|
323 | function getValue($keyname) { |
---|
324 | $cnt = 0; |
---|
325 | foreach($this->keyname as $val) { |
---|
326 | if($val == $keyname) { |
---|
327 | $ret = $this->param[$cnt]; |
---|
328 | break; |
---|
329 | } |
---|
330 | $cnt++; |
---|
331 | } |
---|
332 | return $ret; |
---|
333 | } |
---|
334 | |
---|
335 | function splitCheckBoxes($keyname) { |
---|
336 | $cnt = 0; |
---|
337 | foreach($this->keyname as $val) { |
---|
338 | if($val == $keyname) { |
---|
339 | $this->param[$cnt] = sfSplitCheckBoxes($this->param[$cnt]); |
---|
340 | } |
---|
341 | $cnt++; |
---|
342 | } |
---|
343 | } |
---|
344 | |
---|
345 | function splitParamCheckBoxes($keyname) { |
---|
346 | $cnt = 0; |
---|
347 | foreach($this->keyname as $val) { |
---|
348 | if($val == $keyname) { |
---|
349 | if(!is_array($this->param[$cnt])) { |
---|
350 | $this->param[$cnt] = split("-", $this->param[$cnt]); |
---|
351 | } |
---|
352 | } |
---|
353 | $cnt++; |
---|
354 | } |
---|
355 | } |
---|
356 | } |
---|
357 | ?> |
---|