Field_File::getInput()   A
last analyzed

Complexity

Conditions 6
Paths 32

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
nc 32
nop 0
dl 0
loc 14
rs 9.2222
c 0
b 0
f 0
1
<?php
2
/**
3
 * Part of the Joomla Framework Form Package
4
 *
5
 * @copyright  Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
6
 * @license    GNU General Public License version 2 or later; see LICENSE
7
 */
8
9
namespace Joomla\Form;
10
11
/**
12
 * Form Field class for the Joomla Framework.
13
 * Provides an input field for files
14
 *
15
 * @link        http://www.w3.org/TR/html-markup/input.file.html#input.file
16
 * @since       1.0
17
 * @deprecated  The joomla/form package is deprecated
18
 */
19
class Field_File extends Field
0 ignored issues
show
Deprecated Code introduced by
The class Joomla\Form\Field has been deprecated with message: The joomla/form package is deprecated

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
20
{
21
	/**
22
	 * The form field type.
23
	 *
24
	 * @var    string
25
	 * @since  1.0
26
	 */
27
	public $type = 'File';
28
29
	/**
30
	 * Method to get the field input markup for the file field.
31
	 * Field attributes allow specification of a maximum file size and a string
32
	 * of accepted file extensions.
33
	 *
34
	 * @return  string  The field input markup.
35
	 *
36
	 * @since   1.0
37
	 *
38
	 * @note    The field does not include an upload mechanism.
39
	 * @see     JFormFieldMedia
40
	 */
41
	protected function getInput()
42
	{
43
		// Initialize some field attributes.
44
		$accept = $this->element['accept'] ? ' accept="' . (string) $this->element['accept'] . '"' : '';
45
		$size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
46
		$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
47
		$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
48
49
		// Initialize JavaScript field attributes.
50
		$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
51
52
		return '<input type="file" name="' . $this->name . '" id="' . $this->id . '"' . ' value=""' . $accept . $disabled . $class . $size
53
			. $onchange . ' />';
54
	}
55
}
56