base.php
2.02 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
<?php
/**
* @package AllediaFreeDefaultFiles
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright Copyright (C) Open Sources Training, LLC, All rights reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die('Restricted access');
/**
* Form field to show an advertisement for the pro version
*/
class JFormFieldBase extends JFormField
{
public $fromInstaller = false;
protected $class = '';
protected $media;
protected $attributes;
protected $element;
public function __construct()
{
$this->element = new stdClass;
}
protected function getInput()
{
return '';
}
protected function getStyle($path)
{
$html = '';
if (file_exists($path)) {
$style = file_get_contents($path);
$html .= '<style>' . $style . '</style>';
}
return $html;
}
protected function getLabel()
{
return '';
}
public function getInputUsingCustomElement($element)
{
$this->element = $element;
return $this->getInput();
}
/**
* Method to get an attribute of the field
* The JFormField in Joomla 3 already has this method, but we are
* copying here for Joomla 2.5 compatibility.
*
* @param string $name Name of the attribute to get
* @param mixed $default Optional value to return if attribute not found
*
* @return mixed Value of the attribute / default
*
* @since 3.2
*/
public function getAttribute($name, $default = null)
{
if ($this->element instanceof SimpleXMLElement) {
$attributes = $this->element->attributes();
// Ensure that the attribute exists
if (property_exists($attributes, $name)) {
$value = $attributes->$name;
if ($value !== null) {
return (string) $value;
}
}
}
return $default;
}
}