Code Duplication    Length = 29-29 lines in 3 locations

classes/fields/date.php 1 location

@@ 173-201 (lines=29) @@
170
     *
171
     * @since 2.0
172
     */
173
    public function input ( $name, $value = null, $options = null, $pod = null, $id = null ) {
174
        $options = (array) $options;
175
        $form_field_type = PodsForm::$field_type;
176
177
        if ( is_array( $value ) )
178
            $value = implode( ' ', $value );
179
180
        // Format Value
181
        $value = $this->display( $value, $name, $options, null, $pod, $id );
182
183
        $field_type = 'date';
184
185
        if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) {
186
            if ( pods_var( 'read_only', $options, false ) ) {
187
                $options[ 'readonly' ] = true;
188
189
                $field_type = 'text';
190
            }
191
            else
192
                return;
193
        }
194
        elseif ( !pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) {
195
            $options[ 'readonly' ] = true;
196
197
            $field_type = 'text';
198
        }
199
200
        pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
201
    }
202
203
    /**
204
     * Change the value or perform actions after validation but before saving to the DB

classes/fields/datetime.php 1 location

@@ 220-248 (lines=29) @@
217
     *
218
     * @since 2.0
219
     */
220
    public function input ( $name, $value = null, $options = null, $pod = null, $id = null ) {
221
        $options = (array) $options;
222
        $form_field_type = PodsForm::$field_type;
223
224
        if ( is_array( $value ) )
225
            $value = implode( ' ', $value );
226
227
        // Format Value
228
        $value = $this->display( $value, $name, $options, null, $pod, $id );
229
230
        $field_type = 'datetime';
231
232
        if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) {
233
            if ( pods_var( 'read_only', $options, false ) ) {
234
                $options[ 'readonly' ] = true;
235
236
                $field_type = 'text';
237
            }
238
            else
239
                return;
240
        }
241
        elseif ( !pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) {
242
            $options[ 'readonly' ] = true;
243
244
            $field_type = 'text';
245
        }
246
247
        pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
248
    }
249
250
    /**
251
     * Change the value or perform actions after validation but before saving to the DB

classes/fields/time.php 1 location

@@ 183-211 (lines=29) @@
180
     *
181
     * @since 2.0
182
     */
183
    public function input ( $name, $value = null, $options = null, $pod = null, $id = null ) {
184
        $options = (array) $options;
185
        $form_field_type = PodsForm::$field_type;
186
187
        if ( is_array( $value ) )
188
            $value = implode( ' ', $value );
189
190
        // Format Value
191
        $value = $this->display( $value, $name, $options, null, $pod, $id );
192
193
        $field_type = 'time';
194
195
        if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) {
196
            if ( pods_var( 'read_only', $options, false ) ) {
197
                $options[ 'readonly' ] = true;
198
199
                $field_type = 'text';
200
            }
201
            else
202
                return;
203
        }
204
        elseif ( !pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) {
205
            $options[ 'readonly' ] = true;
206
207
            $field_type = 'text';
208
        }
209
210
        pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
211
    }
212
213
    /**
214
     * Change the value or perform actions after validation but before saving to the DB