class-gf-installation-wizard-step.php
3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
abstract class GF_Installation_Wizard_Step extends stdClass {
protected $_name = '';
protected $_field_validation_results = array();
protected $_validation_summary = '';
public $defaults = array();
private $_step_values;
function __construct( $values = array() ){
if ( empty ( $this->_name ) ) {
throw new Exception( 'Name not set' );
}
$this->_step_values = empty ( $values ) ? $this->defaults : $values;
}
function get_name(){
return $this->_name;
}
function is( $key ) {
return $key == $this->get_name();
}
function get_title(){
return '';
}
public function __set( $key, $value ) {
$this->_step_values[ $key ] = $value;
}
public function __isset( $key ) {
return isset( $this->_step_values[ $key ] );
}
public function __unset( $key ) {
unset( $this->_step_values[ $key ] );
}
function &__get( $key ){
if ( ! isset( $this->_step_values[ $key ] ) ) {
$this->_step_values[ $key ] = '';
}
return $this->_step_values[ $key ];
}
function get_values(){
$set_values = $this->_step_values ? $this->_step_values : array();
$values = array_merge( $this->defaults, $set_values);
return $values;
}
function display(){
}
function validate(){
// Assign $this->_validation_result;
return true;
}
function get_field_validation_result( $key ){
if ( ! isset( $this->_field_validation_results[ $key ] ) ) {
$this->_field_validation_results[ $key ] = '';
}
return $this->_field_validation_results[ $key ];
}
function set_field_validation_result( $key, $text ){
$this->_field_validation_results[ $key ] = $text;
}
function set_validation_summary( $text ) {
$this->_validation_summary = $text;
}
function get_validation_summary(){
return $this->_validation_summary;
}
function validation_message( $key, $echo = true ){
$message = '';
$validation_result = $this->get_field_validation_result( $key );
if ( ! empty ( $validation_result ) ) {
$message = sprintf( '<div class="validation_message">%s</div>', $validation_result );
}
if ( $echo ) {
echo $message;
}
return $message;
}
function is_complete(){
}
function get_next_button_text(){
return __( 'Next', 'gravityforms' );
}
function get_previous_button_text(){
return __( 'Back', 'gravityforms' );
}
function update( $posted_values = array() ){
$step_values = $this->get_values();
if ( empty ( $step_values ) ) {
$step_values = array();
}
$new_values = array_merge( $step_values, $posted_values );
update_option( 'gform_installation_wizard_' . $this->get_name(), $new_values );
$this->_step_values = $new_values;
}
function summary( $echo = true ){
return '';
}
function install(){
// do something
}
function flush_values(){
delete_option( 'gform_installation_wizard_' . $this->get_name() );
}
function get_posted_values() {
$posted_values = stripslashes_deep( $_POST );
$values = array();
foreach ( $posted_values as $key => $value ) {
if ( strpos( $key, '_', 0 ) !== 0 ) {
$values[ $key ] = $value;
}
}
$values = array_merge( $this->defaults, $values);
return $values;
}
}