Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions Classes/Utility/PageRenderer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

namespace GeorgRinger\BackendDebug\Utility;

/***************************************************************
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong header, this is not part of the core

* Copyright notice
*
* (c) 2018
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3
* project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by
* the Free Software Foundation; either version 3 of the
* License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be
* useful,
* but WITHOUT ANY WARRANTY; without even the implied
* warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the
* script!
***************************************************************/

use TYPO3\CMS\Core\Utility\GeneralUtility;


class PageRenderer
{

/**
* Adds JavaCript and CSS to the Backend
*
* @param $params
* @param \TYPO3\CMS\Core\Page\PageRenderer $parent
*/
public function setup(&$params, \TYPO3\CMS\Core\Page\PageRenderer &$parent)
{

$params['jsInline']['BackendDebug'] = [
'code' => $this->getContextCode(),
'section' => 1,
'compress' => FALSE,
'forceOnTop' => TRUE,
];

$parent->addCssInlineBlock('BackendDebug', $this->getCssCode());
}

/**
* JavaScript Inline Code
*
* @return string
*/
protected function getContextCode()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove, see below

{
$context = strtolower(GeneralUtility::getApplicationContext());
$debug = $GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] ? 'debug' : 'nodebug';
$code = <<<EOT
var $ = TYPO3.jQuery;
$(document).ready(function(){
$('body').addClass('$context').addClass('$debug');
});
EOT;

return $code;
}

/**
* CSS Inline Code
*
* @return string
*/
protected function getCssCode()
{
return <<<EOT
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just check the $GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] there and include the CSS if set, no need to use additional JS

body.debug .t3-page-ce-header-icons-left a:after,
body.debug .t3js-entity td.col-icon a.t3js-contextmenutrigger:after {
content: "[ID: " attr(data-uid) "]";
padding-left: 5px;
}
EOT;

}
}
2 changes: 2 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Backend\Form\Element\SelectSingleElement::class] = [
'className' => \GeorgRinger\BackendDebug\Xclass\SelectSingleElement::class,
];

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'][] = 'GeorgRinger\BackendDebug\Utility\PageRenderer->setup';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ::class for the class and please don't call it PageRenderer but place it to BackendDebug\Hooks\PageRendererHook

};

$boot();
Expand Down