[BUGFIX] EXT:frontend still uses old table name sys_language_overlay
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / View / AdminPanelView.php
1 <?php
2 namespace TYPO3\CMS\Frontend\View;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2008-2011 Jeff Segars <jeff@webempoweredchurch.org>
8 * (c) 2008-2011 David Slayback <dave@webempoweredchurch.org>
9 * All rights reserved
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 * A copy is found in the textfile GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the scri.pt!
29 ***************************************************************/
30 /**
31 * View class for the admin panel in frontend editing.
32 *
33 * @author Jeff Segars <jeff@webempoweredchurch.org>
34 * @author David Slayback <dave@webempoweredchurch.org>
35 * @author Dmitry Dulepov <dmitry@typo3.org>
36 */
37 class AdminPanelView {
38
39 /**
40 * Determines whether the update button should be shown.
41 *
42 * @var boolean
43 */
44 protected $extNeedUpdate = FALSE;
45
46 /**
47 * Force preview?
48 *
49 * @var boolean
50 */
51 protected $ext_forcePreview = FALSE;
52
53 /**
54 * Constructor
55 */
56 public function __construct() {
57 $this->initialize();
58 }
59
60 /*****************************************************
61 *
62 * Admin Panel Configuration/Initialization
63 *
64 ****************************************************/
65 /**
66 * Initializes settings for the admin panel.
67 *
68 * @return void
69 */
70 public function initialize() {
71 $this->saveConfigOptions();
72 // Setting some values based on the admin panel
73 $GLOBALS['TSFE']->forceTemplateParsing = $this->extGetFeAdminValue('tsdebug', 'forceTemplateParsing');
74 $GLOBALS['TSFE']->displayEditIcons = $this->extGetFeAdminValue('edit', 'displayIcons');
75 $GLOBALS['TSFE']->displayFieldEditIcons = $this->extGetFeAdminValue('edit', 'displayFieldIcons');
76 if ($this->extGetFeAdminValue('tsdebug', 'displayQueries')) {
77 // do not override if the value is already set in t3lib_db
78 if ($GLOBALS['TYPO3_DB']->explainOutput == 0) {
79 // Enable execution of EXPLAIN SELECT queries
80 $GLOBALS['TYPO3_DB']->explainOutput = 3;
81 }
82 }
83 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_editIcons')) {
84 $GLOBALS['TSFE']->displayFieldEditIcons = 1;
85 $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup'] = 1;
86 }
87 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_simUser')) {
88 $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateUserGroup'] = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_simUser'));
89 $this->ext_forcePreview = TRUE;
90 }
91 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_simTime')) {
92 $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateDate'] = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_simTime'));
93 $this->ext_forcePreview = TRUE;
94 }
95 if ($GLOBALS['TSFE']->forceTemplateParsing || $GLOBALS['TSFE']->displayEditIcons || $GLOBALS['TSFE']->displayFieldEditIcons) {
96 $GLOBALS['TSFE']->set_no_cache();
97 }
98 }
99
100 /**
101 * Obtains header data for the admin panel.
102 *
103 * @return string
104 */
105 public function getAdminPanelHeaderData() {
106 $result = '';
107 // Include BE styles
108 $GLOBALS['TSFE']->includeTCA();
109 if (!empty($GLOBALS['TBE_STYLES']['stylesheets']['admPanel'])) {
110 $result = '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($GLOBALS['TBE_STYLES']['stylesheets']['admPanel'])) . '" />';
111 }
112 return $result;
113 }
114
115 /**
116 * Checks if a Admin Panel section ("module") is available for the user. If so, TRUE is returned.
117 *
118 * @param string $key The module key, eg. "edit", "preview", "info" etc.
119 * @return boolean
120 */
121 public function isAdminModuleEnabled($key) {
122 $result = FALSE;
123 // Returns TRUE if the module checked is "preview" and the forcePreview flag is set.
124 if ($key == 'preview' && $this->ext_forcePreview) {
125 $result = TRUE;
126 }
127 // If key is not set, only "all" is checked
128 if ($GLOBALS['BE_USER']->extAdminConfig['enable.']['all']) {
129 $result = TRUE;
130 }
131 if ($GLOBALS['BE_USER']->extAdminConfig['enable.'][$key]) {
132 $result = TRUE;
133 }
134 return $result;
135 }
136
137 /**
138 * Saves any change in settings made in the Admin Panel.
139 * Called from index_ts.php right after access check for the Admin Panel
140 *
141 * @return void
142 */
143 public function saveConfigOptions() {
144 $input = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('TSFE_ADMIN_PANEL');
145 if (is_array($input)) {
146 // Setting
147 $GLOBALS['BE_USER']->uc['TSFE_adminConfig'] = array_merge(!is_array($GLOBALS['BE_USER']->uc['TSFE_adminConfig']) ? array() : $GLOBALS['BE_USER']->uc['TSFE_adminConfig'], $input);
148 // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
149 unset($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['action']);
150 // Actions:
151 if ($input['action']['clearCache'] && $this->isAdminModuleEnabled('cache')) {
152 $GLOBALS['BE_USER']->extPageInTreeInfo = array();
153 $theStartId = intval($input['cache_clearCacheId']);
154 $GLOBALS['TSFE']->clearPageCacheContent_pidList($GLOBALS['BE_USER']->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache', 'clearCacheLevels'), 0, $GLOBALS['BE_USER']->getPagePermsClause(1)) . $theStartId);
155 }
156 // Saving
157 $GLOBALS['BE_USER']->writeUC();
158 }
159 $GLOBALS['TT']->LR = $this->extGetFeAdminValue('tsdebug', 'LR');
160 if ($this->extGetFeAdminValue('cache', 'noCache')) {
161 $GLOBALS['TSFE']->set_no_cache();
162 }
163 }
164
165 /**
166 * Returns the value for a Admin Panel setting. You must specify both the module-key and the internal setting key.
167 *
168 * @param string $sectionName Module key
169 * @param string $val Setting key
170 * @return string The setting value
171 */
172 public function extGetFeAdminValue($sectionName, $val = '') {
173 // Check if module is enabled.
174 if ($this->isAdminModuleEnabled($sectionName)) {
175 // Exceptions where the values can be overridden from backend:
176 // deprecated
177 if ($sectionName . '_' . $val == 'edit_displayIcons' && $GLOBALS['BE_USER']->extAdminConfig['module.']['edit.']['forceDisplayIcons']) {
178 return TRUE;
179 }
180 if ($sectionName . '_' . $val == 'edit_displayFieldIcons' && $GLOBALS['BE_USER']->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons']) {
181 return TRUE;
182 }
183 // Override all settings with user TSconfig
184 if ($val && $GLOBALS['BE_USER']->extAdminConfig['override.'][$sectionName . '.'][$val]) {
185 return $GLOBALS['BE_USER']->extAdminConfig['override.'][$sectionName . '.'][$val];
186 }
187 if ($GLOBALS['BE_USER']->extAdminConfig['override.'][$sectionName]) {
188 return $GLOBALS['BE_USER']->extAdminConfig['override.'][$sectionName];
189 }
190 $retVal = $val ? $GLOBALS['BE_USER']->uc['TSFE_adminConfig'][$sectionName . '_' . $val] : 1;
191 if ($sectionName == 'preview' && $this->ext_forcePreview) {
192 return !$val ? TRUE : $retVal;
193 }
194 // Regular check:
195 // See if the menu is expanded!
196 if ($this->isAdminModuleOpen($sectionName)) {
197 return $retVal;
198 }
199 }
200 }
201
202 /**
203 * Enables the force preview option.
204 *
205 * @return void
206 */
207 public function forcePreview() {
208 $this->ext_forcePreview = TRUE;
209 }
210
211 /**
212 * Returns TRUE if admin panel module is open
213 *
214 * @param string $pre Module key
215 * @return boolean TRUE, if the admin panel is open for the specified admin panel module key.
216 */
217 public function isAdminModuleOpen($pre) {
218 return $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top'] && $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_' . $pre];
219 }
220
221 /*****************************************************
222 *
223 * Admin Panel Rendering
224 *
225 ****************************************************/
226 /**
227 * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
228 *
229 * @return string HTML for the Admin Panel
230 */
231 public function display() {
232 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_tsfe.php');
233 $moduleContent = '';
234 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']) {
235 if ($this->isAdminModuleEnabled('preview')) {
236 $moduleContent .= $this->getPreviewModule();
237 }
238 if ($this->isAdminModuleEnabled('cache')) {
239 $moduleContent .= $this->getCacheModule();
240 }
241 if ($this->isAdminModuleEnabled('edit')) {
242 $moduleContent .= $this->getEditModule();
243 }
244 if ($this->isAdminModuleEnabled('tsdebug')) {
245 $moduleContent .= $this->getTSDebugModule();
246 }
247 if ($this->isAdminModuleEnabled('info')) {
248 $moduleContent .= $this->getInfoModule();
249 }
250 }
251 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'])) {
252 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'] as $classRef) {
253 $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
254 if (!$hookObject instanceof \TYPO3\CMS\Frontend\View\AdminPanelViewHookInterface) {
255 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Frontend\\View\\AdminPanelViewHookInterface', 1311942539);
256 }
257 $moduleContent .= $hookObject->extendAdminPanel($moduleContent, $this);
258 }
259 }
260 $row = $this->extGetLL('adminPanelTitle') . ': <span class="typo3-adminPanel-beuser">' . htmlspecialchars($GLOBALS['BE_USER']->user['username']) . '</span>';
261 $isVisible = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top'];
262 $cssClassName = 'typo3-adminPanel-panel-' . ($isVisible ? 'open' : 'closed');
263 $header = '<tr class="typo3-adminPanel-hRow">' . '<td colspan="2" id="typo3-adminPanel-header" class="' . $cssClassName . '">' . '<span class="typo3-adminPanel-header-title">' . $row . '</span>' . $this->linkSectionHeader('top', '<span class="typo3-adminPanel-header-button"></span>', 'typo3-adminPanel-header-buttonWrapper') . '<input type="hidden" name="TSFE_ADMIN_PANEL[display_top]" value="' . $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top'] . '" /></td>' . '</tr>';
264 if ($moduleContent) {
265 $footer = '<tr class="typo3-adminPanel-fRow">' . '<td colspan="2" id="typo3-adminPanel-footer">' . ($this->extNeedUpdate ? ' <input class="typo3-adminPanel-update" type="submit" value="' . $this->extGetLL('update') . '" />' : '') . '</td>' . '</tr>';
266 } else {
267 $footer = '';
268 }
269 $query = !\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('id') ? '<input type="hidden" name="id" value="' . $GLOBALS['TSFE']->id . '" />' : '';
270 // The dummy field is needed for Firefox: to force a page reload on submit
271 // with must change the form value with JavaScript (see "onsubmit" attribute of the "form" element")
272 $query .= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="" />';
273 foreach (\TYPO3\CMS\Core\Utility\GeneralUtility::_GET() as $key => $value) {
274 if ($key != 'TSFE_ADMIN_PANEL') {
275 if (is_array($value)) {
276 $query .= $this->getHiddenFields($key, $value);
277 } else {
278 $query .= '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />';
279 }
280 }
281 }
282 $out = '
283 <!--
284 TYPO3 admin panel start
285 -->
286 <a id="TSFE_ADMIN"></a>
287 <form id="TSFE_ADMIN_PANEL_FORM" name="TSFE_ADMIN_PANEL_FORM" action="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT')) . '#TSFE_ADMIN" method="get" onsubmit="document.forms.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[DUMMY]\'].value=Math.random().toString().substring(2,8)">' . $query . '<table class="typo3-adminPanel">' . $header . $moduleContent . $footer . '</table></form>';
288 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']) {
289 $out .= '<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
290 $out .= '<script type="text/javascript">/*<![CDATA[*/' . \TYPO3\CMS\Core\Utility\GeneralUtility::minifyJavaScript('
291 var evalFunc = new evalFunc();
292 // TSFEtypo3FormFieldSet()
293 function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { //
294 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
295 var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
296 if (checkbox && theValue==checkboxValue) {
297 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
298 alert(theField);
299 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
300 } else {
301 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
302 if (document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"]) {
303 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
304 }
305 }
306 }
307 // TSFEtypo3FormFieldGet()
308 function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { //
309 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
310 if (checkbox_off) {
311 document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
312 }else{
313 document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
314 }
315 TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
316 }') . '/*]]>*/</script><script language="javascript" type="text/javascript">' . $this->extJSCODE . '</script>';
317 }
318 $out .= '<script src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl('t3lib/js/adminpanel.js') . '" type="text/javascript"></script><script type="text/javascript">/*<![CDATA[*/' . 'typo3AdminPanel = new TYPO3AdminPanel();typo3AdminPanel.init("typo3-adminPanel-header", "TSFE_ADMIN_PANEL_FORM");' . '/*]]>*/</script>
319 <!--
320 TYPO3 admin panel end
321 -->
322 ';
323 return $out;
324 }
325
326 /**
327 * Fetches recursively all GET parameters as hidden fields.
328 * Called from display()
329 *
330 * @param string $key Current key
331 * @param array $val Current value
332 * @return string Hidden fields
333 * @see display()
334 */
335 protected function getHiddenFields($key, array $val) {
336 $out = '';
337 foreach ($val as $k => $v) {
338 if (is_array($v)) {
339 $out .= $this->getHiddenFields($key . '[' . $k . ']', $v);
340 } else {
341 $out .= '<input type="hidden" name="' . htmlspecialchars($key) . '[' . htmlspecialchars($k) . ']" value="' . htmlspecialchars($v) . '">' . LF;
342 }
343 }
344 return $out;
345 }
346
347 /*****************************************************
348 *
349 * Creating sections of the Admin Panel
350 *
351 ****************************************************/
352 /**
353 * Creates the content for the "preview" section ("module") of the Admin Panel
354 *
355 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
356 * @see display()
357 */
358 protected function getPreviewModule() {
359 $out = $this->extGetHead('preview');
360 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_preview']) {
361 $this->extNeedUpdate = TRUE;
362 $out .= $this->extGetItem('preview_showHiddenPages', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_showHiddenPages'] ? ' checked="checked"' : '') . ' />');
363 $out .= $this->extGetItem('preview_showHiddenRecords', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_showHiddenRecords'] ? ' checked="checked"' : '') . ' />');
364 // Simulate date
365 $out .= $this->extGetItem('preview_simulateDate', '<input type="text" name="TSFE_ADMIN_PANEL[preview_simulateDate]_hr" onchange="TSFEtypo3FormFieldGet(\'TSFE_ADMIN_PANEL[preview_simulateDate]\', \'datetime\', \'\', 1,0);" /><input type="hidden" name="TSFE_ADMIN_PANEL[preview_simulateDate]" value="' . $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateDate'] . '" />');
366 $this->extJSCODE .= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 0, 0);';
367 // Simulate fe_user:
368 $options = '<option value="0">&nbsp;</option>';
369 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('fe_groups.uid, fe_groups.title', 'fe_groups,pages', 'pages.uid=fe_groups.pid AND pages.deleted=0 ' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('fe_groups') . ' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
370 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
371 $options .= '<option value="' . $row['uid'] . '"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateUserGroup'] == $row['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars(('[' . $row['uid'] . '] ' . $row['title'])) . '</option>';
372 }
373 $out .= $this->extGetItem('preview_simulateUserGroup', '<select name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">' . $options . '</select>');
374 }
375 return $out;
376 }
377
378 /**
379 * Creates the content for the "cache" section ("module") of the Admin Panel
380 *
381 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
382 * @see display()
383 */
384 protected function getCacheModule() {
385 $out = $this->extGetHead('cache');
386 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_cache']) {
387 $this->extNeedUpdate = TRUE;
388 $out .= $this->extGetItem('cache_noCache', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_noCache]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[cache_noCache]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_noCache'] ? ' checked="checked"' : '') . ' />');
389 $levels = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_clearCacheLevels'];
390 $options = '';
391 $options .= '<option value="0"' . ($levels == 0 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_0') . '</option>';
392 $options .= '<option value="1"' . ($levels == 1 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_1') . '</option>';
393 $options .= '<option value="2"' . ($levels == 2 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_2') . '</option>';
394 $out .= $this->extGetItem('cache_clearLevels', '<select name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">' . $options . '</select>' . '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="' . $GLOBALS['TSFE']->id . '" /> <input type="submit" value="' . $this->extGetLL('update') . '" />');
395 // Generating tree:
396 $depth = $this->extGetFeAdminValue('cache', 'clearCacheLevels');
397 $outTable = '';
398 $GLOBALS['BE_USER']->extPageInTreeInfo = array();
399 $GLOBALS['BE_USER']->extPageInTreeInfo[] = array($GLOBALS['TSFE']->page['uid'], htmlspecialchars($GLOBALS['TSFE']->page['title']), $depth + 1);
400 $GLOBALS['BE_USER']->extGetTreeList($GLOBALS['TSFE']->id, $depth, 0, $GLOBALS['BE_USER']->getPagePermsClause(1));
401 foreach ($GLOBALS['BE_USER']->extPageInTreeInfo as $row) {
402 $outTable .= '<tr>' . '<td><img src="typo3/gfx/clear.gif" width="' . ($depth + 1 - $row[2]) * 18 . '" height="1" alt="" /><img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/i/pages.gif', 'width="18" height="16"') . ' align="top" alt="" /> ' . htmlspecialchars($row[1]) . '</td><td>' . $GLOBALS['BE_USER']->extGetNumberOfCachedPages($row[0]) . '</td></tr>';
403 }
404 $outTable = '<br /><table>' . $outTable . '</table>';
405 $outTable .= '<input type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="' . $this->extGetLL('cache_doit') . '" />';
406 $out .= $this->extGetItem('cache_cacheEntries', $outTable);
407 }
408 return $out;
409 }
410
411 /**
412 * Creates the content for the "edit" section ("module") of the Admin Panel
413 *
414 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
415 * @see display()
416 */
417 protected function getEditModule() {
418 $out = $this->extGetHead('edit');
419 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_edit']) {
420 // If another page module was specified, replace the default Page module with the new one
421 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
422 $pageModule = \TYPO3\CMS\Backend\Utility\BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
423 $this->extNeedUpdate = TRUE;
424 $out .= $this->extGetItem('edit_displayFieldIcons', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_displayFieldIcons'] ? ' checked="checked"' : '') . ' />');
425 $out .= $this->extGetItem('edit_displayIcons', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_displayIcons'] ? ' checked="checked"' : '') . ' />');
426 $out .= $this->extGetItem('edit_editFormsOnPage', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_editFormsOnPage]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_editFormsOnPage]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editFormsOnPage'] ? ' checked="checked"' : '') . ' />');
427 $out .= $this->extGetItem('edit_editNoPopup', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_editNoPopup]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_editNoPopup]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup'] ? ' checked="checked"' : '') . ' />');
428 $out .= $this->extGetItem('', $this->ext_makeToolBar());
429 if (!\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_view')) {
430 $out .= $this->extGetItem('', '<a href="#" onclick="' . htmlspecialchars(('
431 if (parent.opener && parent.opener.top && parent.opener.top.TS) {
432 parent.opener.top.fsMod.recentIds["web"]=' . intval($GLOBALS['TSFE']->page['uid']) . ';
433 if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav) {
434 parent.opener.top.content.nav_frame.refresh_nav();
435 }
436 parent.opener.top.goToModule("' . $pageModule . '");
437 parent.opener.top.focus();
438 } else {
439 vHWin=window.open(\'' . TYPO3_mainDir . \TYPO3\CMS\Backend\Utility\BackendUtility::getBackendScript() . '\',\'' . md5(('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'])) . '\',\'status=1,menubar=1,scrollbars=1,resizable=1\');
440 vHWin.focus();
441 }
442 return false;
443 ')) . '">' . $this->extGetLL('edit_openAB') . '</a>');
444 }
445 }
446 return $out;
447 }
448
449 /**
450 * Creates the content for the "tsdebug" section ("module") of the Admin Panel
451 *
452 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
453 * @see display()
454 */
455 protected function getTSDebugModule() {
456 $out = $this->extGetHead('tsdebug');
457 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_tsdebug']) {
458 $this->extNeedUpdate = TRUE;
459 $out .= $this->extGetItem('tsdebug_tree', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_tree'] ? ' checked="checked"' : '') . ' />');
460 $out .= $this->extGetItem('tsdebug_displayTimes', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayTimes'] ? ' checked="checked"' : '') . ' />');
461 $out .= $this->extGetItem('tsdebug_displayMessages', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayMessages'] ? ' checked="checked"' : '') . ' />');
462 $out .= $this->extGetItem('tsdebug_LR', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_LR'] ? ' checked="checked"' : '') . ' />');
463 $out .= $this->extGetItem('tsdebug_displayContent', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayContent'] ? ' checked="checked"' : '') . ' />');
464 $out .= $this->extGetItem('tsdebug_displayQueries', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayQueries'] ? ' checked="checked"' : '') . ' />');
465 $out .= $this->extGetItem('tsdebug_forceTemplateParsing', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_forceTemplateParsing'] ? ' checked="checked"' : '') . ' />');
466 $GLOBALS['TT']->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug', 'tree');
467 $GLOBALS['TT']->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug', 'displayTimes');
468 $GLOBALS['TT']->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug', 'displayMessages');
469 $GLOBALS['TT']->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug', 'displayContent');
470 $GLOBALS['TT']->printConf['flag_queries'] = $this->extGetFeAdminValue('tsdebug', 'displayQueries');
471 $out .= '<tr><td colspan="2">' . $GLOBALS['TT']->printTSlog() . '</td></tr>';
472 }
473 return $out;
474 }
475
476 /**
477 * Creates the content for the "info" section ("module") of the Admin Panel
478 *
479 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
480 * @see display()
481 */
482 protected function getInfoModule() {
483 $out = $this->extGetHead('info');
484 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_info']) {
485 $tableArr = array();
486 if ($this->extGetFeAdminValue('cache', 'noCache')) {
487 $theBytes = 0;
488 $count = 0;
489 if (count($GLOBALS['TSFE']->imagesOnPage)) {
490 $tableArr[] = array('*Images on this page:*', '');
491 foreach ($GLOBALS['TSFE']->imagesOnPage as $file) {
492 $fs = @filesize($file);
493 $tableArr[] = array('&ndash; ' . $file, \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($fs));
494 $theBytes += $fs;
495 $count++;
496 }
497 }
498 // Add an empty line
499 $tableArr[] = array('', '');
500 $tableArr[] = array('*Total number of images:*', $count);
501 $tableArr[] = array('*Total image file sizes:*', \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($theBytes));
502 $tableArr[] = array('*Document size:*', \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize(strlen($GLOBALS['TSFE']->content)));
503 $tableArr[] = array('*Total page load:*', \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize(strlen($GLOBALS['TSFE']->content) + $theBytes));
504 $tableArr[] = array('', '');
505 }
506 $tableArr[] = array('id:', $GLOBALS['TSFE']->id);
507 $tableArr[] = array('type:', $GLOBALS['TSFE']->type);
508 $tableArr[] = array('gr_list:', $GLOBALS['TSFE']->gr_list);
509 $tableArr[] = array('no_cache:', $GLOBALS['TSFE']->no_cache ? 1 : 0);
510 $tableArr[] = array('USER_INT objects:', count($GLOBALS['TSFE']->config['INTincScript']));
511 $tableArr[] = array('fe_user, name:', $GLOBALS['TSFE']->fe_user->user['username']);
512 $tableArr[] = array('fe_user, uid:', $GLOBALS['TSFE']->fe_user->user['uid']);
513 // Add an empty line
514 $tableArr[] = array('', '');
515 // Parsetime:
516 $tableArr[] = array('*Total parsetime:*', $GLOBALS['TSFE']->scriptParseTime . ' ms');
517 $table = '';
518 foreach ($tableArr as $arr) {
519 // Put text wrapped by "*" between <strong> tags
520 if (strlen($arr[0])) {
521 $value1 = preg_replace('/^\\*(.*)\\*$/', '$1', $arr[0], -1, $count);
522 $value1 = ($count ? '<strong>' : '') . $value1 . ($count ? '</strong>' : '');
523 } else {
524 $value1 = '&nbsp;';
525 }
526 $value2 = strlen($arr[1]) ? $arr[1] : '&nbsp;';
527 $value2 = $value2;
528 $table .= '<tr class="typo3-adminPanel-itemRow">' . '<td class="typo3-adminPanel-section-content-title">' . $value1 . '</td>' . '<td class="typo3-adminPanel-section-content">' . $value2 . '</td>' . '</tr>';
529 }
530 $out .= $table;
531 }
532 return $out;
533 }
534
535 /*****************************************************
536 *
537 * Admin Panel Layout Helper functions
538 *
539 ****************************************************/
540 /**
541 * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
542 * It will have a plus/minus icon and a label which is linked so that it submits the form which surrounds the whole Admin Panel when clicked, alterting the TSFE_ADMIN_PANEL[display_' . $pre . '] value
543 * See the functions get*Module
544 *
545 * @param string $sectionSuffix The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
546 * @return string HTML table row.
547 * @see extGetItem()
548 */
549 public function extGetHead($sectionSuffix) {
550 $settingName = 'display_' . $sectionSuffix;
551 $isVisible = $GLOBALS['BE_USER']->uc['TSFE_adminConfig'][$settingName];
552 $cssClassName = 'typo3-adminPanel-section-' . ($isVisible ? 'open' : 'closed');
553 return '<tr class="typo3-adminPanel-section-title"><td colspan="2">' . $this->linkSectionHeader($sectionSuffix, $this->extGetLL($sectionSuffix), $cssClassName) . '<input type="hidden" name="TSFE_ADMIN_PANEL[' . $settingName . ']" value="' . $isVisible . '" /></td></tr>';
554 }
555
556 /**
557 * Wraps a string in a link which will open/close a certain part of the Admin Panel
558 *
559 * @param string $sectionSuffix The code for the display_ label/key
560 * @param string $sectionTitle Input string
561 * @param string $className The classname for the <a> tag
562 * @return string $className Linked input string
563 * @see extGetHead()
564 */
565 public function linkSectionHeader($sectionSuffix, $sectionTitle, $className = '') {
566 return '<div class="typo3-adminPanel-label"><a href="javascript:void(0)" onclick="' . htmlspecialchars(('document.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[display_' . $sectionSuffix . ']\'].value=' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_' . $sectionSuffix] ? '0' : '1') . ';document.TSFE_ADMIN_PANEL_FORM.submit();return false;')) . '"' . ($className ? ' class="' . $className . '"' : '') . '>' . $sectionTitle . '</a></div>';
567 }
568
569 /**
570 * Returns a row (with 4 columns) for content in a section of the Admin Panel.
571 * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
572 *
573 * @param string $title Key to label
574 * @param string $content The HTML content for the forth table cell.
575 * @param string $checkboxContent The HTML for a checkbox or hidden fields
576 * @return string HTML table row.
577 * @see extGetHead()
578 */
579 public function extGetItem($title, $content = '', $checkboxContent = '') {
580 $out = '<tr class="typo3-adminPanel-itemRow">' . '<td class="typo3-adminPanel-section-content">' . $checkboxContent . ($title ? $this->extGetLL($title) : '&nbsp;') . $content . '</td></tr>';
581 return $out;
582 }
583
584 /**
585 * Creates the tool bar links for the "edit" section of the Admin Panel.
586 *
587 * @return string A string containing images wrapped in <a>-tags linking them to proper functions.
588 */
589 public function ext_makeToolBar() {
590 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
591 $tsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig($this->pageinfo['uid'], 'mod.web_list');
592 $tsConfig = $tsConfig['properties']['newContentWiz.']['overrideWithExtension'];
593 $newContentWizScriptPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($tsConfig) ? \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($tsConfig) . 'mod1/db_new_content_el.php' : TYPO3_mainDir . 'sysext/cms/layout/db_new_content_el.php';
594 $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
595 $langAllowed = $GLOBALS['BE_USER']->checkLanguageAccess($GLOBALS['TSFE']->sys_language_uid);
596 $id = $GLOBALS['TSFE']->id;
597 $toolBar = '<a href="' . htmlspecialchars((TYPO3_mainDir . 'show_rechis.php?element=' . rawurlencode(('pages:' . $id)) . '&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')))) . '#latest">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/history2.gif', 'width="13" height="12"') . ' hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_recordHistory') . '" alt="" /></a>';
598 if ($perms & 16 && $langAllowed) {
599 $params = '';
600 if ($GLOBALS['TSFE']->sys_language_uid) {
601 $params = '&sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid;
602 }
603 $toolBar .= '<a href="' . htmlspecialchars(($newContentWizScriptPath . '?id=' . $id . $params . '&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/new_record.gif', 'width="16" height="12"') . ' hspace="1" border="0" align="top" title="' . $this->extGetLL('edit_newContentElement') . '" alt="" /></a>';
604 }
605 if ($perms & 2) {
606 $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'move_el.php?table=pages&uid=' . $id . '&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/move_page.gif', 'width="11" height="12') . ' hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_move_page') . '" alt="" /></a>';
607 }
608 if ($perms & 8) {
609 $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'db_new.php?id=' . $id . '&pagesOnly=1&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/new_page.gif', 'width="13" height="12"') . ' hspace="0" border="0" align="top" title="' . $this->extGetLL('edit_newPage') . '" alt="" /></a>';
610 }
611 if ($perms & 2) {
612 $params = '&edit[pages][' . $id . ']=edit';
613 $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/edit2.gif', 'width="11" height="12"') . 'hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_editPageProperties') . '" alt="" /></a>';
614 if ($GLOBALS['TSFE']->sys_language_uid && $langAllowed) {
615 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
616 'uid,pid,t3ver_state',
617 'pages_language_overlay',
618 'pid=' . intval($id) .
619 ' AND sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid .
620 $GLOBALS['TSFE']->sys_page->enableFields('pages_language_overlay'),
621 '',
622 '',
623 '1'
624 );
625 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
626 $GLOBALS['TSFE']->sys_page->versionOL('pages_language_overlay', $row);
627 if (is_array($row)) {
628 $params = '&edit[pages_language_overlay][' . $row['uid'] . ']=edit';
629 $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/edit3.gif', 'width="11" height="12"') . ' hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_editPageOverlay') . '" alt="" /></a>';
630 }
631 }
632 }
633 if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
634 $urlParams = array();
635 $urlParams['id'] = $id;
636 $urlParams['returnUrl'] = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI');
637 $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_list', $urlParams))) . '">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/list.gif', 'width="11" height="11"') . ' hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_db_list') . '" alt="" /></a>';
638 }
639 return $toolBar;
640 }
641
642 /**
643 * Returns the label for key, $key. If a translation for the language set in $GLOBALS['BE_USER']->uc['lang'] is found that is returned, otherwise the default value.
644 * IF the global variable $LOCAL_LANG is NOT an array (yet) then this function loads the global $LOCAL_LANG array with the content of "sysext/lang/locallang_tsfe.php" so that the values therein can be used for labels in the Admin Panel
645 *
646 * FIXME The function should convert to $TSFE->renderCharset, not to UTF8!
647 *
648 * @param string $key Key for a label in the $LOCAL_LANG array of "sysext/lang/locallang_tsfe.php
649 * @return string The value for the $key
650 */
651 public function extGetLL($key) {
652 // Label string in the default backend output charset.
653 $labelStr = htmlspecialchars($GLOBALS['LANG']->getLL($key));
654 $labelStr = $GLOBALS['LANG']->csConvObj->utf8_to_entities($labelStr);
655 return $labelStr;
656 }
657
658 }
659
660
661 ?>