Code Duplication    Length = 26-26 lines in 4 locations

classes/fields/email.php 1 location

@@ 121-146 (lines=26) @@
118
     *
119
     * @since 2.0
120
     */
121
    public function input ( $name, $value = null, $options = null, $pod = null, $id = null ) {
122
        $options = (array) $options;
123
        $form_field_type = PodsForm::$field_type;
124
125
        if ( is_array( $value ) )
126
            $value = implode( ' ', $value );
127
128
        $field_type = 'email';
129
130
        if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) {
131
            if ( pods_var( 'read_only', $options, false ) ) {
132
                $options[ 'readonly' ] = true;
133
134
                $field_type = 'text';
135
            }
136
            else
137
                return;
138
        }
139
        elseif ( !pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) {
140
            $options[ 'readonly' ] = true;
141
142
            $field_type = 'text';
143
        }
144
145
        pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
146
    }
147
148
    /**
149
     * Build regex necessary for JS validation

classes/fields/phone.php 1 location

@@ 146-171 (lines=26) @@
143
     *
144
     * @since 2.0
145
     */
146
    public function input ( $name, $value = null, $options = null, $pod = null, $id = null ) {
147
        $options = (array) $options;
148
        $form_field_type = PodsForm::$field_type;
149
150
        if ( is_array( $value ) )
151
            $value = implode( ' ', $value );
152
153
        $field_type = 'phone';
154
155
        if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) {
156
            if ( pods_var( 'read_only', $options, false ) ) {
157
                $options[ 'readonly' ] = true;
158
159
                $field_type = 'text';
160
            }
161
            else
162
                return;
163
        }
164
        elseif ( !pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) {
165
            $options[ 'readonly' ] = true;
166
167
            $field_type = 'text';
168
        }
169
170
        pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
171
    }
172
173
    /**
174
     * Validate a value before it's saved

classes/fields/slug.php 1 location

@@ 89-114 (lines=26) @@
86
     *
87
     * @since 2.0
88
     */
89
    public function input ( $name, $value = null, $options = null, $pod = null, $id = null ) {
90
        $options = (array) $options;
91
        $form_field_type = PodsForm::$field_type;
92
93
        if ( is_array( $value ) )
94
            $value = implode( '-', $value );
95
96
        $field_type = 'slug';
97
98
        if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) {
99
            if ( pods_var( 'read_only', $options, false ) ) {
100
                $options[ 'readonly' ] = true;
101
102
                $field_type = 'text';
103
            }
104
            else
105
                return;
106
        }
107
        elseif ( !pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) {
108
            $options[ 'readonly' ] = true;
109
110
            $field_type = 'text';
111
        }
112
113
        pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
114
    }
115
116
    /**
117
     * Build regex necessary for JS validation

classes/fields/website.php 1 location

@@ 177-202 (lines=26) @@
174
	 *
175
	 * @since 2.0
176
	 */
177
	public function input ( $name, $value = null, $options = null, $pod = null, $id = null ) {
178
		$options = (array) $options;
179
		$form_field_type = PodsForm::$field_type;
180
181
		if ( is_array( $value ) )
182
			$value = implode( ' ', $value );
183
184
		$field_type = 'website';
185
186
		if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) {
187
			if ( pods_var( 'read_only', $options, false ) ) {
188
				$options[ 'readonly' ] = true;
189
190
				$field_type = 'text';
191
			}
192
			else
193
				return;
194
		}
195
		elseif ( !pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) {
196
			$options[ 'readonly' ] = true;
197
198
			$field_type = 'text';
199
		}
200
201
		pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
202
	}
203
204
	/**
205
	 * Validate a value before it's saved