Version Description
- TODO : {}
Download this release
Release Info
Developer | inc2734 |
Plugin | MW WP Form |
Version | 1.1.2 |
Comparing to | |
See all releases |
Code changes from version 1.1.1 to 1.1.2
- mw-wp-form.php +50 -60
- readme.txt +5 -2
- system/mw_form.php +47 -66
- system/mw_wp_form_data.php +12 -2
mw-wp-form.php
CHANGED
@@ -3,11 +3,11 @@
|
|
3 |
* Plugin Name: MW WP Form
|
4 |
* Plugin URI: http://2inc.org/blog/category/products/wordpress_plugins/mw-wp-form/
|
5 |
* Description: MW WP Form can create mail form with a confirmation screen.
|
6 |
-
* Version: 1.1.
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created : September 25, 2012
|
10 |
-
* Modified: November
|
11 |
* Text Domain: mw-wp-form
|
12 |
* Domain Path: /languages/
|
13 |
* License: GPL2
|
@@ -269,17 +269,20 @@ class mw_wp_form {
|
|
269 |
$this->viewFlg = 'complete';
|
270 |
$this->fileUpload();
|
271 |
|
272 |
-
|
273 |
-
$REQUEST_URI = $this->parse_url( $_SERVER['REQUEST_URI'] );
|
274 |
-
if ( ! ( $this->is_management_different_url() && $REQUEST_URI == $this->complete ) )
|
275 |
$this->apply_filters_mwform_mail();
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
|
281 |
$this->redirect( $this->complete );
|
282 |
-
$this->Form->clearToken();
|
283 |
} else {
|
284 |
if ( !empty( $this->validation_error ) ) {
|
285 |
$this->redirect( $this->validation_error );
|
@@ -288,24 +291,11 @@ class mw_wp_form {
|
|
288 |
}
|
289 |
}
|
290 |
}
|
291 |
-
$this->Session->clearValues();
|
292 |
|
293 |
add_shortcode( 'mwform_formkey', array( $this, '_mwform_formkey' ) );
|
294 |
add_shortcode( 'mwform', array( $this, '_mwform' ) );
|
295 |
add_shortcode( 'mwform_complete_message', array( $this, '_mwform_complete_message' ) );
|
296 |
-
|
297 |
-
|
298 |
-
/**
|
299 |
-
* is_management_different_url
|
300 |
-
* 管理画面作成・個別URLのときtrueを返す
|
301 |
-
* @return Boolean
|
302 |
-
*/
|
303 |
-
protected function is_management_different_url() {
|
304 |
-
if ( !empty( $this->options_by_formkey ) && ( $this->input !== $this->complete || $this->preview !== $this->complete ) ) {
|
305 |
-
return true;
|
306 |
-
} else {
|
307 |
-
return false;
|
308 |
-
}
|
309 |
}
|
310 |
|
311 |
/**
|
@@ -481,47 +471,47 @@ class mw_wp_form {
|
|
481 |
protected function apply_filters_mwform_mail() {
|
482 |
$Mail = new MW_Mail();
|
483 |
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
if (
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
$
|
505 |
-
realpath( $wp_upload_dir['basedir'] ),
|
506 |
-
$upload_file_url
|
507 |
-
);
|
508 |
-
if ( file_exists( $filepath ) ) {
|
509 |
-
$filepath = $this->File->moveTempFileToUploadDir( $filepath );
|
510 |
-
$new_upload_file_url = str_replace(
|
511 |
-
realpath( $wp_upload_dir['basedir'] ),
|
512 |
$wp_upload_dir['baseurl'],
|
513 |
-
$
|
|
|
514 |
);
|
515 |
-
|
516 |
-
|
517 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
}
|
|
|
519 |
}
|
520 |
-
$Mail->attachments = $attachments;
|
521 |
}
|
522 |
-
}
|
523 |
|
524 |
-
if ( $this->options_by_formkey ) {
|
525 |
// 送信先を指定
|
526 |
$Mail->to = get_bloginfo( 'admin_email' );
|
527 |
if ( $mailto = $this->options_by_formkey['mail_to'] )
|
@@ -683,7 +673,7 @@ class mw_wp_form {
|
|
683 |
$redirect = ( empty( $url ) ) ? $_SERVER['REQUEST_URI'] : $url;
|
684 |
$redirect = $this->parse_url( $redirect );
|
685 |
$REQUEST_URI = $this->parse_url( $_SERVER['REQUEST_URI'] );
|
686 |
-
if ( $
|
687 |
wp_redirect( $redirect );
|
688 |
exit();
|
689 |
}
|
3 |
* Plugin Name: MW WP Form
|
4 |
* Plugin URI: http://2inc.org/blog/category/products/wordpress_plugins/mw-wp-form/
|
5 |
* Description: MW WP Form can create mail form with a confirmation screen.
|
6 |
+
* Version: 1.1.2
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created : September 25, 2012
|
10 |
+
* Modified: November 22, 2013
|
11 |
* Text Domain: mw-wp-form
|
12 |
* Domain Path: /languages/
|
13 |
* License: GPL2
|
269 |
$this->viewFlg = 'complete';
|
270 |
$this->fileUpload();
|
271 |
|
272 |
+
if ( $this->Data->getValue( $this->Form->getTokenName() ) ) {
|
|
|
|
|
273 |
$this->apply_filters_mwform_mail();
|
274 |
+
$this->Data->clearValue( $this->Form->getTokenName() );
|
275 |
+
|
276 |
+
// 手動フォーム対応
|
277 |
+
$REQUEST_URI = $this->parse_url( $_SERVER['REQUEST_URI'] );
|
278 |
+
$input = $this->parse_url( $this->input );
|
279 |
+
$complete = $this->parse_url( $this->complete );
|
280 |
+
if ( !$this->options_by_formkey && $REQUEST_URI !== $complete && $input !== $complete ) {
|
281 |
+
$this->Data->clearValues();
|
282 |
+
}
|
283 |
+
}
|
284 |
|
285 |
$this->redirect( $this->complete );
|
|
|
286 |
} else {
|
287 |
if ( !empty( $this->validation_error ) ) {
|
288 |
$this->redirect( $this->validation_error );
|
291 |
}
|
292 |
}
|
293 |
}
|
|
|
294 |
|
295 |
add_shortcode( 'mwform_formkey', array( $this, '_mwform_formkey' ) );
|
296 |
add_shortcode( 'mwform', array( $this, '_mwform' ) );
|
297 |
add_shortcode( 'mwform_complete_message', array( $this, '_mwform_complete_message' ) );
|
298 |
+
add_action( 'wp_footer', array( $this->Data, 'clearValues' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
}
|
300 |
|
301 |
/**
|
471 |
protected function apply_filters_mwform_mail() {
|
472 |
$Mail = new MW_Mail();
|
473 |
|
474 |
+
if ( $this->options_by_formkey ) {
|
475 |
+
$admin_mail_subject = $this->options_by_formkey['mail_subject'];
|
476 |
+
if ( !empty( $this->options_by_formkey['admin_mail_subject'] ) )
|
477 |
+
$admin_mail_subject = $this->options_by_formkey['admin_mail_subject'];
|
478 |
+
|
479 |
+
$admin_mail_content = $this->options_by_formkey['mail_content'];
|
480 |
+
if ( !empty( $this->options_by_formkey['admin_mail_content'] ) )
|
481 |
+
$admin_mail_content = $this->options_by_formkey['admin_mail_content'];
|
482 |
+
|
483 |
+
// 添付ファイルのデータをためた配列を作成
|
484 |
+
$attachments = array();
|
485 |
+
// $Mail->attachments を設定(メールにファイルを添付)
|
486 |
+
$upload_file_keys = $this->Data->getValue( MWF_Config::UPLOAD_FILE_KEYS );
|
487 |
+
if ( $upload_file_keys !== null ) {
|
488 |
+
if ( is_array( $upload_file_keys ) ) {
|
489 |
+
$wp_upload_dir = wp_upload_dir();
|
490 |
+
foreach ( $upload_file_keys as $key ) {
|
491 |
+
$upload_file_url = $this->Data->getValue( $key );
|
492 |
+
if ( !$upload_file_url )
|
493 |
+
continue;
|
494 |
+
$filepath = str_replace(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
$wp_upload_dir['baseurl'],
|
496 |
+
realpath( $wp_upload_dir['basedir'] ),
|
497 |
+
$upload_file_url
|
498 |
);
|
499 |
+
if ( file_exists( $filepath ) ) {
|
500 |
+
$filepath = $this->File->moveTempFileToUploadDir( $filepath );
|
501 |
+
$new_upload_file_url = str_replace(
|
502 |
+
realpath( $wp_upload_dir['basedir'] ),
|
503 |
+
$wp_upload_dir['baseurl'],
|
504 |
+
$filepath
|
505 |
+
);
|
506 |
+
$attachments[$key] = $filepath;
|
507 |
+
$this->Data->setValue( $key, $new_upload_file_url );
|
508 |
+
$this->Form = new MW_Form( $this->Data->getValues(), $this->key );
|
509 |
+
}
|
510 |
}
|
511 |
+
$Mail->attachments = $attachments;
|
512 |
}
|
|
|
513 |
}
|
|
|
514 |
|
|
|
515 |
// 送信先を指定
|
516 |
$Mail->to = get_bloginfo( 'admin_email' );
|
517 |
if ( $mailto = $this->options_by_formkey['mail_to'] )
|
673 |
$redirect = ( empty( $url ) ) ? $_SERVER['REQUEST_URI'] : $url;
|
674 |
$redirect = $this->parse_url( $redirect );
|
675 |
$REQUEST_URI = $this->parse_url( $_SERVER['REQUEST_URI'] );
|
676 |
+
if ( !empty( $_POST ) || $redirect != $REQUEST_URI ) {
|
677 |
wp_redirect( $redirect );
|
678 |
exit();
|
679 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40
|
|
4 |
Tags: plugin, form, confirm, preview, shortcode
|
5 |
Requires at least: 3.4
|
6 |
Tested up to: 3.6.1
|
7 |
-
Stable tag: 1.1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -37,8 +37,11 @@ http://2inc.org/blog/category/products/wordpress_plugins/mw-wp-form/
|
|
37 |
|
38 |
== Changelog ==
|
39 |
|
|
|
|
|
|
|
40 |
= 1.1.1 =
|
41 |
-
*
|
42 |
|
43 |
= 1.1.0 =
|
44 |
* Added : mwform_value_識別子 フィルターフック追加
|
4 |
Tags: plugin, form, confirm, preview, shortcode
|
5 |
Requires at least: 3.4
|
6 |
Tested up to: 3.6.1
|
7 |
+
Stable tag: 1.1.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
37 |
|
38 |
== Changelog ==
|
39 |
|
40 |
+
= 1.1.2 =
|
41 |
+
* TODO : メール件名にも{キー}が使用できるようにしたい
|
42 |
+
|
43 |
= 1.1.1 =
|
44 |
+
* Cahged : セッションまわりの処理をリファクタリング
|
45 |
|
46 |
= 1.1.0 =
|
47 |
* Added : mwform_value_識別子 フィルターフック追加
|
system/mw_form.php
CHANGED
@@ -3,11 +3,11 @@
|
|
3 |
* Name: MW Form
|
4 |
* URI: http://2inc.org
|
5 |
* Description: フォームクラス
|
6 |
-
* Version: 1.3.
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created: September 25, 2012
|
10 |
-
* Modified:
|
11 |
* License: GPL2
|
12 |
*
|
13 |
* Copyright 2013 Takashi Kitajima (email : inc@2inc.org)
|
@@ -46,13 +46,12 @@ class MW_Form {
|
|
46 |
*/
|
47 |
public function __construct( $data, $key = '' ) {
|
48 |
$this->data = $data;
|
49 |
-
if (
|
50 |
-
$this->key = $key.'_token';
|
51 |
-
}
|
52 |
$this->Session = MW_Session::start( $this->key );
|
53 |
$this->modeCheck = $this->modeCheck();
|
54 |
$this->token = sha1( $this->key . session_id() );
|
55 |
-
if ( $this->isInput() && empty( $_POST ) ) {
|
56 |
$this->Session->save( array( $this->tokenName => $this->token ) );
|
57 |
}
|
58 |
// 戻る、確認画面へのポスト、完了画面へのポストでないときはデータを破棄
|
@@ -66,21 +65,23 @@ class MW_Form {
|
|
66 |
* clearToken
|
67 |
* トークン用のセッションを破棄
|
68 |
*/
|
69 |
-
|
70 |
$this->Session->clearValue( $this->tokenName );
|
71 |
}
|
72 |
|
|
|
|
|
|
|
|
|
73 |
/**
|
74 |
* isComplete
|
75 |
* 完了画面かどうか
|
76 |
* @return Boolean
|
77 |
*/
|
78 |
public function isComplete() {
|
79 |
-
$
|
80 |
-
|
81 |
-
|
82 |
-
}
|
83 |
-
return $_ret;
|
84 |
}
|
85 |
|
86 |
/**
|
@@ -89,11 +90,9 @@ class MW_Form {
|
|
89 |
* @return Boolean
|
90 |
*/
|
91 |
public function isPreview() {
|
92 |
-
$
|
93 |
-
|
94 |
-
|
95 |
-
}
|
96 |
-
return $_ret;
|
97 |
}
|
98 |
|
99 |
/**
|
@@ -102,11 +101,9 @@ class MW_Form {
|
|
102 |
* @return Boolean
|
103 |
*/
|
104 |
public function isInput() {
|
105 |
-
$
|
106 |
-
|
107 |
-
|
108 |
-
}
|
109 |
-
return $_ret;
|
110 |
}
|
111 |
|
112 |
/**
|
@@ -137,13 +134,18 @@ class MW_Form {
|
|
137 |
* @return Boolean
|
138 |
*/
|
139 |
protected function check() {
|
140 |
-
if ( isset( $
|
141 |
-
$requestToken = $
|
142 |
-
$_ret = false;
|
143 |
$s_token = $this->Session->getValue( $this->tokenName );
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
|
149 |
/**
|
@@ -174,7 +176,6 @@ class MW_Form {
|
|
174 |
$_ret = null;
|
175 |
if ( isset( $this->data[$key] ) ) {
|
176 |
$_ret = $this->data[$key];
|
177 |
-
$_ret = $this->e( $_ret );
|
178 |
}
|
179 |
return $_ret;
|
180 |
}
|
@@ -194,7 +195,6 @@ class MW_Form {
|
|
194 |
foreach ( $this->data[$key]['data'] as $value ) {
|
195 |
if ( !( $value === '' || $value === null ) ) {
|
196 |
$_ret = implode( $separator, $this->data[$key]['data'] );
|
197 |
-
$_ret = $this->e( $_ret );
|
198 |
break;
|
199 |
}
|
200 |
}
|
@@ -232,7 +232,6 @@ class MW_Form {
|
|
232 |
}
|
233 |
}
|
234 |
$_ret = implode( $separator, $rightData );
|
235 |
-
$_ret = $this->e( $_ret );
|
236 |
}
|
237 |
}
|
238 |
return $_ret;
|
@@ -250,7 +249,7 @@ class MW_Form {
|
|
250 |
if ( isset( $this->data[$key] ) && !is_array( $this->data[$key] ) ) {
|
251 |
if ( isset( $data[$this->data[$key]] ) ) {
|
252 |
$_ret = $data[$this->data[$key]];
|
253 |
-
$_ret =
|
254 |
}
|
255 |
}
|
256 |
return $_ret;
|
@@ -307,7 +306,7 @@ class MW_Form {
|
|
307 |
);
|
308 |
$options = array_merge( $defaults, $options );
|
309 |
$_ret = sprintf( '<form method="%s" action="%s" enctype="%s">',
|
310 |
-
$this->method,
|
311 |
return $_ret;
|
312 |
}
|
313 |
|
@@ -340,7 +339,7 @@ class MW_Form {
|
|
340 |
$options = array_merge( $defaults, $options );
|
341 |
$value = ( isset( $this->data[$name] ) )? $this->data[$name] : $options['value'];
|
342 |
$_ret = sprintf( '<input type="text" name="%s" value="%s" size="%d" maxlength="%d" />',
|
343 |
-
|
344 |
);
|
345 |
return $_ret;
|
346 |
}
|
@@ -353,10 +352,10 @@ class MW_Form {
|
|
353 |
* @return String htmlタグ
|
354 |
*/
|
355 |
public function hidden( $name, $value ) {
|
356 |
-
|
357 |
if ( is_array( $value ) )
|
358 |
$value = $this->getZipValue( $name );
|
359 |
-
$_ret = sprintf( '<input type="hidden" name="%s" value="%s" />',
|
360 |
return $_ret;
|
361 |
}
|
362 |
|
@@ -376,7 +375,7 @@ class MW_Form {
|
|
376 |
$options = array_merge( $defaults, $options );
|
377 |
$value = ( isset( $this->data[$name] ) )? $this->data[$name] : $options['value'];
|
378 |
$_ret = sprintf( '<input type="password" name="%s" value="%s" size="%d" maxlength="%d" />',
|
379 |
-
|
380 |
);
|
381 |
return $_ret;
|
382 |
}
|
@@ -450,7 +449,7 @@ class MW_Form {
|
|
450 |
$options = array_merge( $defaults, $options );
|
451 |
$value = ( isset( $this->data[$name] ) )? $this->data[$name] : $options['value'];
|
452 |
$_ret = sprintf( '<textarea name="%s" cols="%d" rows="%d">%s</textarea>',
|
453 |
-
|
454 |
);
|
455 |
return $_ret;
|
456 |
}
|
@@ -469,11 +468,11 @@ class MW_Form {
|
|
469 |
);
|
470 |
$options = array_merge( $defaults, $options );
|
471 |
$value = ( isset( $this->data[$name] ) )? $this->data[$name] : $options['value'];
|
472 |
-
$_ret = sprintf( '<select name="%s">',
|
473 |
foreach ( $children as $key => $_value ) {
|
474 |
$selected = ( $key == $value )? ' selected="selected"' : '';
|
475 |
$_ret .= sprintf( '<option value="%s"%s>%s</option>',
|
476 |
-
|
477 |
);
|
478 |
}
|
479 |
$_ret .= '</select>';
|
@@ -498,7 +497,7 @@ class MW_Form {
|
|
498 |
foreach ( $children as $key => $_value ) {
|
499 |
$checked = ( $key == $value )? ' checked="checked"' : '';
|
500 |
$_ret .= sprintf( '<label><input type="radio" name="%s" value="%s"%s />%s</label>',
|
501 |
-
|
502 |
);
|
503 |
}
|
504 |
return $_ret;
|
@@ -530,7 +529,7 @@ class MW_Form {
|
|
530 |
foreach ( $children as $key => $_value ) {
|
531 |
$checked = ( is_array( $value ) && in_array( $key, $value ) )? ' checked="checked"' : '';
|
532 |
$_ret .= sprintf( '<label><input type="checkbox" name="%s" value="%s"%s />%s</label>',
|
533 |
-
|
534 |
);
|
535 |
}
|
536 |
$_ret .= $this->separator( $name, $separator );
|
@@ -545,7 +544,7 @@ class MW_Form {
|
|
545 |
* @return String submitボタン
|
546 |
*/
|
547 |
public function submit( $name, $value ) {
|
548 |
-
$_ret = sprintf( '<input type="submit" name="%s" value="%s" />',
|
549 |
return $_ret;
|
550 |
}
|
551 |
|
@@ -557,7 +556,7 @@ class MW_Form {
|
|
557 |
* @return String ボタン
|
558 |
*/
|
559 |
public function button( $name, $value ) {
|
560 |
-
$_ret = sprintf( '<input type="button" name="%s" value="%s" />',
|
561 |
return $_ret;
|
562 |
}
|
563 |
|
@@ -579,7 +578,7 @@ class MW_Form {
|
|
579 |
$options = array_merge( $defaults, $options );
|
580 |
$value = ( isset( $this->data[$name] ) )? $this->data[$name] : $options['value'];
|
581 |
$_ret = sprintf( '<input type="text" name="%s" value="%s" size="%d" />',
|
582 |
-
|
583 |
);
|
584 |
$_ret .= sprintf( '
|
585 |
<script type="text/javascript">
|
@@ -587,7 +586,7 @@ class MW_Form {
|
|
587 |
$("input[name=\'%s\']").datepicker({%s});
|
588 |
} );
|
589 |
</script>
|
590 |
-
'
|
591 |
return $_ret;
|
592 |
}
|
593 |
|
@@ -604,26 +603,8 @@ class MW_Form {
|
|
604 |
);
|
605 |
$options = array_merge( $defaults, $options );
|
606 |
$_ret = sprintf( '<input type="file" name="%s" size="%d" />',
|
607 |
-
|
608 |
);
|
609 |
return $_ret;
|
610 |
}
|
611 |
-
|
612 |
-
/**
|
613 |
-
* e
|
614 |
-
* htmlサニタイズ
|
615 |
-
* @param Mixed
|
616 |
-
* @return Mixed
|
617 |
-
*/
|
618 |
-
public function e( $str ){
|
619 |
-
if ( is_null( $str ) ) {
|
620 |
-
return null;
|
621 |
-
} elseif ( is_array( $str ) ) {
|
622 |
-
return array_map( array( $this, 'e' ), $str );
|
623 |
-
} else {
|
624 |
-
$str = stripslashes( $str );
|
625 |
-
return htmlspecialchars( $str, ENT_QUOTES, $this->ENCODE );
|
626 |
-
}
|
627 |
-
}
|
628 |
-
}
|
629 |
-
?>
|
3 |
* Name: MW Form
|
4 |
* URI: http://2inc.org
|
5 |
* Description: フォームクラス
|
6 |
+
* Version: 1.3.5
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created: September 25, 2012
|
10 |
+
* Modified: November 22, 2013
|
11 |
* License: GPL2
|
12 |
*
|
13 |
* Copyright 2013 Takashi Kitajima (email : inc@2inc.org)
|
46 |
*/
|
47 |
public function __construct( $data, $key = '' ) {
|
48 |
$this->data = $data;
|
49 |
+
if ( $key )
|
50 |
+
$this->key = $key . '_token';
|
|
|
51 |
$this->Session = MW_Session::start( $this->key );
|
52 |
$this->modeCheck = $this->modeCheck();
|
53 |
$this->token = sha1( $this->key . session_id() );
|
54 |
+
if ( $this->isInput() && empty( $_POST ) && !$this->Session->getValue( $this->tokenName ) ) {
|
55 |
$this->Session->save( array( $this->tokenName => $this->token ) );
|
56 |
}
|
57 |
// 戻る、確認画面へのポスト、完了画面へのポストでないときはデータを破棄
|
65 |
* clearToken
|
66 |
* トークン用のセッションを破棄
|
67 |
*/
|
68 |
+
private function clearToken() {
|
69 |
$this->Session->clearValue( $this->tokenName );
|
70 |
}
|
71 |
|
72 |
+
public function getTokenName() {
|
73 |
+
return $this->tokenName;
|
74 |
+
}
|
75 |
+
|
76 |
/**
|
77 |
* isComplete
|
78 |
* 完了画面かどうか
|
79 |
* @return Boolean
|
80 |
*/
|
81 |
public function isComplete() {
|
82 |
+
if ( !empty( $this->data ) && $this->modeCheck === 'complete' )
|
83 |
+
return true;
|
84 |
+
return false;
|
|
|
|
|
85 |
}
|
86 |
|
87 |
/**
|
90 |
* @return Boolean
|
91 |
*/
|
92 |
public function isPreview() {
|
93 |
+
if ( !empty( $this->data ) && $this->modeCheck === 'preview' )
|
94 |
+
return true;
|
95 |
+
return false;
|
|
|
|
|
96 |
}
|
97 |
|
98 |
/**
|
101 |
* @return Boolean
|
102 |
*/
|
103 |
public function isInput() {
|
104 |
+
if ( $this->modeCheck === 'input' )
|
105 |
+
return true;
|
106 |
+
return false;
|
|
|
|
|
107 |
}
|
108 |
|
109 |
/**
|
134 |
* @return Boolean
|
135 |
*/
|
136 |
protected function check() {
|
137 |
+
if ( isset( $_POST[$this->tokenName] ) )
|
138 |
+
$requestToken = $_POST[$this->tokenName];
|
|
|
139 |
$s_token = $this->Session->getValue( $this->tokenName );
|
140 |
+
|
141 |
+
if ( isset( $requestToken ) && !empty( $s_token ) && $requestToken === $s_token ) {
|
142 |
+
$this->clearToken();
|
143 |
+
return true;
|
144 |
+
} elseif ( empty( $_POST ) && $this->data ) {
|
145 |
+
$this->clearToken();
|
146 |
+
return true;
|
147 |
+
}
|
148 |
+
return false;
|
149 |
}
|
150 |
|
151 |
/**
|
176 |
$_ret = null;
|
177 |
if ( isset( $this->data[$key] ) ) {
|
178 |
$_ret = $this->data[$key];
|
|
|
179 |
}
|
180 |
return $_ret;
|
181 |
}
|
195 |
foreach ( $this->data[$key]['data'] as $value ) {
|
196 |
if ( !( $value === '' || $value === null ) ) {
|
197 |
$_ret = implode( $separator, $this->data[$key]['data'] );
|
|
|
198 |
break;
|
199 |
}
|
200 |
}
|
232 |
}
|
233 |
}
|
234 |
$_ret = implode( $separator, $rightData );
|
|
|
235 |
}
|
236 |
}
|
237 |
return $_ret;
|
249 |
if ( isset( $this->data[$key] ) && !is_array( $this->data[$key] ) ) {
|
250 |
if ( isset( $data[$this->data[$key]] ) ) {
|
251 |
$_ret = $data[$this->data[$key]];
|
252 |
+
$_ret = esc_html( $_ret );
|
253 |
}
|
254 |
}
|
255 |
return $_ret;
|
306 |
);
|
307 |
$options = array_merge( $defaults, $options );
|
308 |
$_ret = sprintf( '<form method="%s" action="%s" enctype="%s">',
|
309 |
+
$this->method, esc_attr( $options['action'] ), esc_attr( $options['enctype'] ) );
|
310 |
return $_ret;
|
311 |
}
|
312 |
|
339 |
$options = array_merge( $defaults, $options );
|
340 |
$value = ( isset( $this->data[$name] ) )? $this->data[$name] : $options['value'];
|
341 |
$_ret = sprintf( '<input type="text" name="%s" value="%s" size="%d" maxlength="%d" />',
|
342 |
+
esc_attr( $name ), esc_attr( $value ), esc_attr( $options['size'] ), esc_attr( $options['maxlength'] )
|
343 |
);
|
344 |
return $_ret;
|
345 |
}
|
352 |
* @return String htmlタグ
|
353 |
*/
|
354 |
public function hidden( $name, $value ) {
|
355 |
+
//$value = ( isset( $this->data[$name] ) )? $this->data[$name] : $value;
|
356 |
if ( is_array( $value ) )
|
357 |
$value = $this->getZipValue( $name );
|
358 |
+
$_ret = sprintf( '<input type="hidden" name="%s" value="%s" />', esc_attr( $name ), esc_attr( $value ) );
|
359 |
return $_ret;
|
360 |
}
|
361 |
|
375 |
$options = array_merge( $defaults, $options );
|
376 |
$value = ( isset( $this->data[$name] ) )? $this->data[$name] : $options['value'];
|
377 |
$_ret = sprintf( '<input type="password" name="%s" value="%s" size="%d" maxlength="%d" />',
|
378 |
+
esc_attr( $name ), esc_attr( $value ), esc_attr( $options['size'] ), esc_attr( $options['maxlength'] )
|
379 |
);
|
380 |
return $_ret;
|
381 |
}
|
449 |
$options = array_merge( $defaults, $options );
|
450 |
$value = ( isset( $this->data[$name] ) )? $this->data[$name] : $options['value'];
|
451 |
$_ret = sprintf( '<textarea name="%s" cols="%d" rows="%d">%s</textarea>',
|
452 |
+
esc_attr( $name ), esc_attr( $options['cols'] ), esc_attr( $options['rows'] ), esc_html( $value )
|
453 |
);
|
454 |
return $_ret;
|
455 |
}
|
468 |
);
|
469 |
$options = array_merge( $defaults, $options );
|
470 |
$value = ( isset( $this->data[$name] ) )? $this->data[$name] : $options['value'];
|
471 |
+
$_ret = sprintf( '<select name="%s">', esc_attr( $name ) );
|
472 |
foreach ( $children as $key => $_value ) {
|
473 |
$selected = ( $key == $value )? ' selected="selected"' : '';
|
474 |
$_ret .= sprintf( '<option value="%s"%s>%s</option>',
|
475 |
+
esc_attr( $key ), $selected, esc_html( $_value )
|
476 |
);
|
477 |
}
|
478 |
$_ret .= '</select>';
|
497 |
foreach ( $children as $key => $_value ) {
|
498 |
$checked = ( $key == $value )? ' checked="checked"' : '';
|
499 |
$_ret .= sprintf( '<label><input type="radio" name="%s" value="%s"%s />%s</label>',
|
500 |
+
esc_attr( $name ), esc_attr( $key ), $checked, esc_html( $_value )
|
501 |
);
|
502 |
}
|
503 |
return $_ret;
|
529 |
foreach ( $children as $key => $_value ) {
|
530 |
$checked = ( is_array( $value ) && in_array( $key, $value ) )? ' checked="checked"' : '';
|
531 |
$_ret .= sprintf( '<label><input type="checkbox" name="%s" value="%s"%s />%s</label>',
|
532 |
+
esc_attr( $name.'[data][]' ), esc_attr( $key ), $checked, esc_html( $_value )
|
533 |
);
|
534 |
}
|
535 |
$_ret .= $this->separator( $name, $separator );
|
544 |
* @return String submitボタン
|
545 |
*/
|
546 |
public function submit( $name, $value ) {
|
547 |
+
$_ret = sprintf( '<input type="submit" name="%s" value="%s" />', esc_attr( $name ), esc_attr( $value ) );
|
548 |
return $_ret;
|
549 |
}
|
550 |
|
556 |
* @return String ボタン
|
557 |
*/
|
558 |
public function button( $name, $value ) {
|
559 |
+
$_ret = sprintf( '<input type="button" name="%s" value="%s" />', esc_attr( $name ), esc_attr( $value ) );
|
560 |
return $_ret;
|
561 |
}
|
562 |
|
578 |
$options = array_merge( $defaults, $options );
|
579 |
$value = ( isset( $this->data[$name] ) )? $this->data[$name] : $options['value'];
|
580 |
$_ret = sprintf( '<input type="text" name="%s" value="%s" size="%d" />',
|
581 |
+
esc_attr( $name ), esc_attr( $value ), esc_attr( $options['size'] )
|
582 |
);
|
583 |
$_ret .= sprintf( '
|
584 |
<script type="text/javascript">
|
586 |
$("input[name=\'%s\']").datepicker({%s});
|
587 |
} );
|
588 |
</script>
|
589 |
+
', esc_html( $name ), $options['js'] );
|
590 |
return $_ret;
|
591 |
}
|
592 |
|
603 |
);
|
604 |
$options = array_merge( $defaults, $options );
|
605 |
$_ret = sprintf( '<input type="file" name="%s" size="%d" />',
|
606 |
+
esc_attr( $name ), esc_attr( $options['size'] )
|
607 |
);
|
608 |
return $_ret;
|
609 |
}
|
610 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
system/mw_wp_form_data.php
CHANGED
@@ -3,11 +3,11 @@
|
|
3 |
* Name: MW WP Form Data
|
4 |
* URI: http://2inc.org
|
5 |
* Description: mw_wp_form のデータ操作用
|
6 |
-
* Version: 1.0.
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created : October 10, 2013
|
10 |
-
* Modified:
|
11 |
* License: GPL2
|
12 |
*
|
13 |
* Copyright 2013 Takashi Kitajima (email : inc@2inc.org)
|
@@ -92,6 +92,16 @@ class mw_wp_form_data {
|
|
92 |
$this->Session->clearValue( $key );
|
93 |
}
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
/**
|
96 |
* pushValue
|
97 |
* 指定した $key をキーと配列にデータを追加
|
3 |
* Name: MW WP Form Data
|
4 |
* URI: http://2inc.org
|
5 |
* Description: mw_wp_form のデータ操作用
|
6 |
+
* Version: 1.0.1
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created : October 10, 2013
|
10 |
+
* Modified: November 22, 2013
|
11 |
* License: GPL2
|
12 |
*
|
13 |
* Copyright 2013 Takashi Kitajima (email : inc@2inc.org)
|
92 |
$this->Session->clearValue( $key );
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
+
* clearValues
|
97 |
+
* データを消す
|
98 |
+
* @param String $key データのキー
|
99 |
+
*/
|
100 |
+
public function clearValues() {
|
101 |
+
unset( $this->data );
|
102 |
+
$this->Session->clearValues();
|
103 |
+
}
|
104 |
+
|
105 |
/**
|
106 |
* pushValue
|
107 |
* 指定した $key をキーと配列にデータを追加
|