1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-05-04 13:57:55 +02:00

keeps only the main debugbar functionality on iframes (#606)

This commit is contained in:
erikn69 2024-03-01 10:22:12 -05:00 committed by GitHub
parent 266cee2946
commit b6113ae0e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 55 additions and 1 deletions

13
demo/iframes/iframe1.php Normal file
View File

@ -0,0 +1,13 @@
<?php
include '../bootstrap.php';
$debugbarRenderer->setBaseUrl('../../src/DebugBar/Resources');
$debugbar['messages']->addMessage('I\'m a IFRAME');
render_demo_page(function() {
?>
<iframe src="iframe2.php" style="display:none;"></iframe>
<?php
});

9
demo/iframes/iframe2.php Normal file
View File

@ -0,0 +1,9 @@
<?php
include '../bootstrap.php';
$debugbarRenderer->setBaseUrl('../../src/DebugBar/Resources');
$debugbar['messages']->addMessage('I\'m a Deeper Hidden Iframe');
render_demo_page(function() {});

13
demo/iframes/index.php Normal file
View File

@ -0,0 +1,13 @@
<?php
include '../bootstrap.php';
$debugbarRenderer->setBaseUrl('../../src/DebugBar/Resources');
$debugbar['messages']->addMessage('Top Page(Main debugbar)');
render_demo_page(function() {
?>
<iframe src="iframe1.php" height="350" style="width:100%;"></iframe>
<?php
});

View File

@ -31,6 +31,10 @@ render_demo_page(function() {
<li><a href="ajax.php" class="ajax">load ajax content</a></li>
<li><a href="ajax_exception.php" class="ajax">load ajax content with exception</a></li>
</ul>
<h2>IFRAMES</h2>
<ul>
<li><a href="iframes/index.php">load through iframes</a></li>
</ul>
<h2>Stack</h2>
<ul>
<li><a href="stack.php">perform a redirect</a></li>

View File

@ -422,6 +422,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
this.activePanelName = null;
this.datesetTitleFormater = new DatasetTitleFormater(this);
this.options.bodyMarginBottomHeight = parseInt($('body').css('margin-bottom'));
this.hasParent = window.parent && window.parent.phpdebugbar && window.parent.phpdebugbar != this;
this.registerResizeHandler();
},
@ -431,7 +432,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
* @this {DebugBar}
*/
registerResizeHandler: function() {
if (typeof this.resize.bind == 'undefined') return;
if (typeof this.resize.bind == 'undefined' || this.hasParent) return;
var f = this.resize.bind(this);
this.respCSSSize = 0;
@ -472,6 +473,10 @@ if (typeof(PhpDebugBar) == 'undefined') {
* @this {DebugBar}
*/
render: function() {
if (this.hasParent) {
this.$el.hide();
}
var self = this;
this.$el.appendTo('body');
this.$dragCapture = $('<div />').addClass(csscls('drag-capture')).appendTo(this.$el);
@ -571,6 +576,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
* @this {DebugBar}
*/
restoreState: function() {
if (this.hasParent) return;
// bar height
var height = localStorage.getItem('phpdebugbar-height');
this.setHeight(height || this.$body.height());
@ -921,6 +927,15 @@ if (typeof(PhpDebugBar) == 'undefined') {
* @return {String} Dataset's id
*/
addDataSet: function(data, id, suffix, show) {
if (this.hasParent) {
if (!suffix || ('(iframe)').indexOf(suffix) < 0) {
suffix = '(iframe)' + (suffix || '');
}
window.parent.phpdebugbar.addDataSet(data, id, suffix, show);
return;
}
var label = this.datesetTitleFormater.format(id, data, suffix);
id = id || (getObjectSize(this.datasets) + 1);
this.datasets[id] = data;