joomla3.php
5.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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
/**
* @package FrameworkOnFramework
* @subpackage render
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*/
defined('FOF_INCLUDED') or die;
/**
* Joomla! 3 view renderer class
*
* @package FrameworkOnFramework
* @since 2.0
*/
class FOFRenderJoomla3 extends FOFRenderStrapper
{
/**
* Public constructor. Determines the priority of this class and if it should be enabled
*/
public function __construct()
{
$this->priority = 55;
$this->enabled = version_compare(JVERSION, '3.0', 'ge');
}
/**
* Echoes any HTML to show before the view template
*
* @param string $view The current view
* @param string $task The current task
* @param FOFInput $input The input array (request parameters)
* @param array $config The view configuration array
*
* @return void
*/
public function preRender($view, $task, $input, $config = array())
{
$format = $input->getCmd('format', 'html');
if (empty($format))
{
$format = 'html';
}
if ($format != 'html')
{
return;
}
$platform = FOFPlatform::getInstance();
if ($platform->isCli())
{
return;
}
if (version_compare(JVERSION, '3.3.0', 'ge'))
{
JHtml::_('behavior.core');
}
else
{
JHtml::_('behavior.framework', true);
}
JHtml::_('jquery.framework');
if ($platform->isBackend())
{
// Wrap output in various classes
$version = new JVersion;
$versionParts = explode('.', $version->RELEASE);
$minorVersion = str_replace('.', '', $version->RELEASE);
$majorVersion = array_shift($versionParts);
$option = $input->getCmd('option', '');
$view = $input->getCmd('view', '');
$layout = $input->getCmd('layout', '');
$task = $input->getCmd('task', '');
$classes = ' class="' . implode(
' ',
array(
'joomla-version-' . $majorVersion,
'joomla-version-' . $minorVersion,
'admin',
$option,
'view-' . $view,
'layout-' . $layout,
'task-' . $task,
)
) . '"';
}
else
{
$classes = '';
}
echo '<div id="akeeba-renderjoomla"' . $classes . ">\n";
// Render the submenu and toolbar
if ($input->getBool('render_toolbar', true))
{
$this->renderButtons($view, $task, $input, $config);
$this->renderLinkbar($view, $task, $input, $config);
}
}
/**
* Echoes any HTML to show after the view template
*
* @param string $view The current view
* @param string $task The current task
* @param FOFInput $input The input array (request parameters)
* @param array $config The view configuration array
*
* @return void
*/
public function postRender($view, $task, $input, $config = array())
{
$format = $input->getCmd('format', 'html');
if (empty($format))
{
$format = 'html';
}
if ($format != 'html')
{
return;
}
// Closing tag only if we're not in CLI
if (FOFPlatform::getInstance()->isCli())
{
return;
}
echo "</div>\n"; // Closes akeeba-renderjoomla div
}
/**
* Renders the submenu (link bar)
*
* @param string $view The active view name
* @param string $task The current task
* @param FOFInput $input The input object
* @param array $config Extra configuration variables for the toolbar
*
* @return void
*/
protected function renderLinkbar($view, $task, $input, $config = array())
{
$style = 'joomla';
if (array_key_exists('linkbar_style', $config))
{
$style = $config['linkbar_style'];
}
switch ($style)
{
case 'joomla':
$this->renderLinkbar_joomla($view, $task, $input);
break;
case 'classic':
default:
$this->renderLinkbar_classic($view, $task, $input);
break;
}
}
/**
* Renders a label for a fieldset.
*
* @param object $field The field of the label to render
* @param FOFForm &$form The form to render
* @param string $title The title of the label
*
* @return string The rendered label
*/
protected function renderFieldsetLabel($field, FOFForm &$form, $title)
{
$html = '';
$labelClass = $field->labelClass ? $field->labelClass : $field->labelclass; // Joomla! 2.5/3.x use different case for the same name
$required = $field->required;
$tooltip = $form->getFieldAttribute($field->fieldname, 'tooltip', '', $field->group);
if (!empty($tooltip))
{
JHtml::_('bootstrap.tooltip');
$tooltipText = '<strong>' . JText::_($title) . '</strong><br />' . JText::_($tooltip);
$html .= "\t\t\t\t" . '<label class="control-label hasTooltip ' . $labelClass . '" for="' . $field->id . '" title="' . $tooltipText . '" rel="tooltip">';
}
else
{
$html .= "\t\t\t\t" . '<label class="control-label ' . $labelClass . '" for="' . $field->id . '">';
}
$html .= JText::_($title);
if ($required)
{
$html .= ' *';
}
$html .= '</label>' . PHP_EOL;
return $html;
}
}